From patchwork Fri Aug 19 19:37:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Shtylyov X-Patchwork-Id: 110721 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 1DECFB6F71 for ; Sat, 20 Aug 2011 05:39:49 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DF30228089; Fri, 19 Aug 2011 21:39:46 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Q+oWwXXAb8fx; Fri, 19 Aug 2011 21:39:46 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 4683828090; Fri, 19 Aug 2011 21:39:45 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1E75128090 for ; Fri, 19 Aug 2011 21:39:43 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ePsjBXIBIxaj for ; Fri, 19 Aug 2011 21:39:42 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail.dev.rtsoft.ru (mail.dev.rtsoft.ru [213.79.90.226]) by theia.denx.de (Postfix) with SMTP id 8E10A28089 for ; Fri, 19 Aug 2011 21:39:41 +0200 (CEST) Received: (qmail 6367 invoked from network); 19 Aug 2011 19:39:44 -0000 Received: from unknown (HELO wasted.dev.rtsoft.ru) (192.168.1.70) by 0 with SMTP; 19 Aug 2011 19:39:44 -0000 To: u-boot@lists.denx.de Content-Disposition: inline From: Sergei Shtylyov Organization: MontaVista Software Inc. Date: Fri, 19 Aug 2011 23:37:46 +0400 MIME-Version: 1.0 Message-Id: <201108192337.46310.sshtylyov@ru.mvista.com> Subject: [U-Boot] [PATCH 2/2] fat: replace LINEAR_PREFETCH_SIZE with PREFETCH_BLOCKS X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.9 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Currently in do_fat_read() when reading FAT sectors, we have to divide down LINEAR_PREFETCH_SIZE by the sector size, whereas it's defined as 2 sectors worth of bytes. In order to avoid redundant multiplication/division, introduce #define PREFETCH_BLOCKS instead of #define LINEAR_PREFETCH_SIZE. Signed-off-by: Sergei Shtylyov --- Slight optimization atop of commit 3831530dcb7b71329c272ccd6181f8038b6a6dd0 (VFAT: fix processing of scattered long file name entries) and my recently submitted patch fixing crash with big sector size. The patch was generated atop of the below patches posted earlier: http://marc.info/?l=u-boot&m=131283284822789 http://marc.info/?l=u-boot&m=131283289722891 fs/fat/fat.c | 9 ++++----- include/fat.h | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) Index: u-boot/fs/fat/fat.c =================================================================== --- u-boot.orig/fs/fat/fat.c +++ u-boot/fs/fat/fat.c @@ -440,10 +440,9 @@ get_vfatname (fsdata *mydata, int curclu { dir_entry *realdent; dir_slot *slotptr = (dir_slot *)retdent; - __u8 *buflimit = cluster + ((curclust == 0) ? - LINEAR_PREFETCH_SIZE : - (mydata->clust_size * mydata->sect_size) - ); + __u8 *buflimit = cluster + mydata->sect_size * ((curclust == 0) ? + PREFETCH_BLOCKS : + mydata->clust_size); __u8 counter = (slotptr->id & ~LAST_LONG_ENTRY_MASK) & 0xff; int idx = 0; @@ -880,7 +879,7 @@ do_fat_read (const char *filename, void if (disk_read(cursect, (mydata->fatsize == 32) ? (mydata->clust_size) : - LINEAR_PREFETCH_SIZE / mydata->sect_size, + PREFETCH_BLOCKS, do_fat_read_block) < 0) { debug("Error: reading rootdir block\n"); goto exit; Index: u-boot/include/fat.h =================================================================== --- u-boot.orig/include/fat.h +++ u-boot/include/fat.h @@ -33,7 +33,7 @@ /* Maximum Long File Name length supported here is 128 UTF-16 code units */ #define VFAT_MAXLEN_BYTES 256 /* Maximum LFN buffer in bytes */ #define VFAT_MAXSEQ 9 /* Up to 9 of 13 2-byte UTF-16 entries */ -#define LINEAR_PREFETCH_SIZE (mydata->sect_size*2) /* Prefetch buffer size */ +#define PREFETCH_BLOCKS 2 #define MAX_CLUSTSIZE 65536 #define DIRENTSPERBLOCK (mydata->sect_size / sizeof(dir_entry))