Messages in this thread | | | From | Michal Suchanek <> | Date | Fri, 20 Nov 2015 19:59:54 +0100 | Subject | Re: [PATCH v4 6/7] mtd: spi-nor: simplify write loop |
| |
On 20 November 2015 at 00:18, Brian Norris <computersforpeace@gmail.com> 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
| |