From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Rini Date: Mon, 28 Sep 2015 11:22:25 -0400 Subject: [U-Boot] [PATCH 1/5] fs/fat/fat_write: Fix buffer alignments In-Reply-To: <1443447932-14139-1-git-send-email-benoit@wsystem.com> References: <807994631.1713509.1365795559751.JavaMail.root@advansee.com> <1443447932-14139-1-git-send-email-benoit@wsystem.com> Message-ID: <20150928152225.GK22966@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Mon, Sep 28, 2015 at 03:45:28PM +0200, Beno?t Th?baudeau wrote: > set_cluster() was using a temporary buffer without enforcing its > alignment for DMA and cache. Moreover, it did not check the alignment of > the passed buffer, which can come directly from applicative code or from > the user. > > This could cause random data corruption, which has been observed on > i.MX25 writing to an SD card. > > Fix this by only passing ARCH_DMA_MINALIGN-aligned buffers to > disk_write(), which requires the introduction of a buffer bouncing > mechanism for the misaligned buffers passed to set_cluster(). > > By the way, improve the handling of the corresponding return values from > disk_write(): > - print them with debug() in case of error, > - consider that there is an error is disk_write() returns a smaller > block count than the requested one, not only if its return value is > negative. > > After this change, set_cluster() and get_cluster() are almost > symmetrical. > > Signed-off-by: Beno?t Th?baudeau OK. I know Stephen has a series to replace all of the FAT code for the next release once some performance issues are addressed. But I'm inclined to take this series (after some reviews and so forth) for this release at least because this sounds like some bad bugs and more things are starting to rely on fatwrite functionality (for example, env saved as a file in FAT is getting common on community-style boards). -- Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: