From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1163277AbbKTTAh (ORCPT ); Fri, 20 Nov 2015 14:00:37 -0500 Received: from mail-wm0-f54.google.com ([74.125.82.54]:33272 "EHLO mail-wm0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162019AbbKTTAf (ORCPT ); Fri, 20 Nov 2015 14:00:35 -0500 MIME-Version: 1.0 In-Reply-To: <20151119231857.GM64635@google.com> References: <20151119231857.GM64635@google.com> From: Michal Suchanek Date: Fri, 20 Nov 2015 19:59:54 +0100 Message-ID: Subject: Re: [PATCH v4 6/7] mtd: spi-nor: simplify write loop To: Brian Norris Cc: Hou Zhiqiang , Huang Shijie , David Woodhouse , Han Xu , =?UTF-8?B?UmFmYcWCIE1pxYJlY2tp?= , Huang Shijie , Ben Hutchings , Marek Vasut , Gabor Juhos , =?UTF-8?B?QmVhbiBIdW8g6ZyN5paM5paMLA==?= , MTD Maling List , Linux Kernel Mailing List Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 20 November 2015 at 00:18, Brian Norris wrote: > Hi Michal, > > Sorry this has sat so long... > > On Fri, Aug 14, 2015 at 09:23:08AM -0000, Michal Suchanek wrote: >> The spi-nor write loop assumes that what is passed to the hardware >> driver write() is what gets written. >> >> When write() writes less than page size at once data is dropped on the >> floor. Check the amount of data writen. > > Have you seen write() return less than the page size? I know you've > struggled with a SPI driver that can't do "very" (for some definition of > very) long transfers, due to unknown bugs, but I thought that "very" was > much larger than the page size. Not in the case of a driver that can transfer 63 bytes at a time. It because the DMA engine needed for normal operation was not merged yet, though. > >> This also means that write can start mid-page any time so there is >> no special case for first page. > > I think we'd have some problems if we start seeing hardware that can't > write ~256 bytes at a time. If nothing else, this can be a problem > because some SPI NOR flash are known to have inferior reliability if you > regularly write in small chunks. I believe this is because they actually > use some kind of internal ECC. > > So, if you're just guarding against a theoretical behavior, perhaps it's > best if this is done with some kind of assertion, as I'd rather not > encourage non-aligned writes if possible. I notice you used BUG_ON() in > another patch, but I'd suggest maybe something less harsh, like WARN() > or WARN_ONCE(). I agree that a warning is in order in the case when whole page cannot be written in one go. Thanks Michal