mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Vicente <vicencb@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 07/13] uimage: improve transfer speed
Date: Mon, 8 Oct 2012 22:01:30 +0200	[thread overview]
Message-ID: <20121008200130.GQ1322@pengutronix.de> (raw)
In-Reply-To: <1349647287-28224-8-git-send-email-vicencb@gmail.com>

On Mon, Oct 08, 2012 at 12:01:21AM +0200, Vicente wrote:
> 
> Signed-off-by: Vicente <vicencb@gmail.com>

Do you have some numbers which cases this speeds up and how much?

Sascha

> ---
>  common/uimage.c | 26 ++++++++++++++++++++++++--
>  1 file changed, 24 insertions(+), 2 deletions(-)
> 
> diff --git a/common/uimage.c b/common/uimage.c
> index c72db41..18c5b01 100644
> --- a/common/uimage.c
> +++ b/common/uimage.c
> @@ -28,6 +28,8 @@
>  #include <rtc.h>
>  #include <filetype.h>
>  #include <memory.h>
> +#include <linux/stat.h>
> +#include <sizes.h>
>  
>  #ifdef CONFIG_UIMAGE_MULTI
>  static inline int uimage_is_multi_image(struct uimage_handle *handle)
> @@ -380,15 +382,35 @@ struct resource *file_to_sdram(const char *filename, unsigned long adr)
>  	struct resource *res;
>  	size_t size = BUFSIZ;
>  	size_t ofs = 0;
> +	size_t now;
>  	int fd;
> +	struct stat s;
>  
>  	fd = open(filename, O_RDONLY);
>  	if (fd < 0)
>  		return NULL;
>  
> -	while (1) {
> -		size_t now;
> +	/* TODO: use fstat(fd, &s) when implemented and avoid reopening file */
> +	if (stat(filename, &s) == 0 && s.st_size <= SZ_1G) {
> +		/*
> +		 * As the file size is known we can read it at once and improve
> +		 * transfer speed.
> +		 */
> +		res = request_sdram_region("image", adr, s.st_size);
> +		if (!res) {
> +			printf("unable to request SDRAM 0x%08lx-0x%08lx\n",
> +				adr, adr + s.st_size - 1);
> +			goto out;
> +		}
>  
> +		now = read_full(fd, (void *)(res->start), s.st_size);
> +		if (now < s.st_size) {
> +			release_sdram_region(res);
> +			res = NULL;
> +		}
> +		goto out;
> +	}
> +	while (1) {
>  		res = request_sdram_region("image", adr, size);
>  		if (!res) {
>  			printf("unable to request SDRAM 0x%08lx-0x%08lx\n",
> -- 
> 1.7.12.2
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2012-10-08 20:01 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-07 22:01 [PATCH 00/13] archosg9: add support for tablet, fourth round Vicente
2012-10-07 22:01 ` [PATCH 01/13] twl6030: add debug info Vicente
2012-10-07 22:01 ` [PATCH 02/13] omap4: add rename definitions to match datasheet Vicente
2012-10-07 22:01 ` [PATCH 03/13] ARM: ensure irqs are disabled Vicente
2012-10-08 20:21   ` Sascha Hauer
2012-10-07 22:01 ` [PATCH 04/13] omap: revert gpiolib Vicente
2012-10-07 22:01 ` [PATCH 05/13] omap4: add usb boot source Vicente
2012-10-07 22:01 ` [PATCH 06/13] bootm: close open files Vicente
2012-10-08 20:18   ` Sascha Hauer
2012-10-08 21:02     ` vj
2012-10-07 22:01 ` [PATCH 07/13] uimage: improve transfer speed Vicente
2012-10-08 20:01   ` Sascha Hauer [this message]
2012-10-08 20:48     ` vj
2012-10-07 22:01 ` [PATCH 08/13] fs: improve robustness Vicente
2012-10-07 22:01 ` [PATCH 09/13] omap4: add support for booting cpu from usb Vicente
2012-10-07 22:01 ` [PATCH 10/13] omap4: add serial communications over usb boot Vicente
2012-10-07 22:01 ` [PATCH 11/13] omap4: add filesystem support " Vicente
2012-10-07 22:01 ` [PATCH 12/13] omap4: add support for loading second stage from usb Vicente
2012-10-07 22:01 ` [PATCH 13/13] Add support for Archos G9 tablet Vicente

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121008200130.GQ1322@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=vicencb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox