lkml.org 
[lkml]   [2021]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v4 3/4] mtd: spi-nor: otp: return -EROFS if region is read-only
    Am 2021-05-31 10:52, schrieb Tudor.Ambarus@microchip.com:
    > On 5/21/21 10:40 PM, Michael Walle wrote:
    >> EXTERNAL EMAIL: Do not click links or open attachments unless you know
    >> the content is safe
    >>
    >> SPI NOR flashes will just ignore program commands if the OTP region is
    >> locked. Thus, a user might not notice that the intended write didn't
    >> end
    >> up in the flash. Return -EROFS to the user in this case. From what I
    >> can
    >> tell, chips/cfi_cmdset_0001.c also return this error code.
    >>
    >> One could optimize spi_nor_mtd_otp_range_is_locked() to read the
    >> status
    >> register only once and not for every OTP region, but for that we would
    >> need some more invasive changes. Given that this is
    >> one-time-programmable memory and the normal access mode is reading, we
    >> just live with the small overhead.
    >
    > :)
    >
    > Shouldn't we change
    > struct spi_nor_otp_ops {
    > ...
    > int (*lock)(struct spi_nor *nor, unsigned int region);
    > int (*is_locked)(struct spi_nor *nor, unsigned int region);
    > };
    >
    > to:
    > struct spi_nor_otp_ops {
    > ...
    > int (*lock)(struct spi_nor *nor, loff_t addr, size_t len);
    >
    > int (*is_locked)(struct spi_nor *nor, loff_t addr, size_t len);
    > };
    >
    > instead?

    I had that, but then
    (1) it doesn't fit the hardware (the one's I know of) and the function
    itself would need to convert to the given range
    (2) each lock()/is_locked() would need to implement the "if at least
    one region is locked everything is locked", which might lead to
    different implementations.
    (3) in what address space is addr and len? I'd presume the one of the
    device (so is orthogonal to read()/write()). So if you get lets
    say addr=0x1000 len=512, you'd need to convert that into region
    0 and 1. Thus you'd have this mapping cluttered over all functions.
    And additionally, you'd first need to convert the mtd offsets
    addr=0 len=512 to addr=0x1000 and len=512.

    -michael

    \
     
     \ /
      Last update: 2021-06-01 15:03    [W:4.146 / U:0.112 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site