linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: <Tudor.Ambarus@microchip.com>
To: <dac2@pensando.io>, <linux-mtd@lists.infradead.org>
Cc: michael@walle.cc
Subject: Re: [BUG]: spi-nor: spi_nor_init() fails when SR locked
Date: Tue, 21 Jul 2020 09:37:02 +0000	[thread overview]
Message-ID: <1ae4f44a-cbd2-b39e-68f7-3d0375c453bf@microchip.com> (raw)
In-Reply-To: <CA+nMikGSSc5NA80Z89fz4GCh+6Ux2Pr6UyjB5n+qoBkiOqAh=Q@mail.gmail.com>

Hi, David,

On 7/20/20 9:13 PM, David Clear wrote:
> 
> Hi Tudor,
> 
> I'm seeing a change of behavior in spi-nor/next vs. my older 4.14
> kernel w.r.t. how SR lock is working.
> 
> In my system with a Micron mt25qu02g, I'm using the hardware WP# to
> lock the SR.  When hardware write-protect is on, at the next reboot
> the kernel rejects the flash as it cannot unlock the whole device.
> 
> I traced the problem to spi_nor_write_sr1_and_check(), which is
> writing to the SR and reading back a different value (as the locked SR
> bits are immutable).
> 
> Call trace:
>  spi_nor_write_sr1_and_check+0x68/0x70
>  spi_nor_write_sr_and_check+0x34/0xd0
>  spi_nor_sr_unlock+0x108/0x230
>  spi_nor_unlock+0x54/0x80  (via spi_nor_unlock_all())
>  spi_nor_init+0x94/0x100
> 
> spi_nor_write_sr1_and_check() is returning -EIO here:
>         if (nor->bouncebuf[0] != sr1) {
>                 dev_dbg(nor->dev, "SR1: read back test failed\n");
>                 BUG();
>                 return -EIO;
>         }
> 
> In my specific case Linux doesn't have (and cannot be given, for
> product security reasons) control over the WP#.  In any case, I don't
> think a write-protected flash should be rejected here.
> 
> Can you suggest how we might proceed?  The way WP# is used is
> board-specific so perhaps a device-tree property of some sort in the
> flash device node can inform the code to do or not do the
> spi_nor_unlock_all()?
> 
> I can take a look at putting a patch together if you suggest an
> acceptable mechanism.
> 

Thanks for the detailed report. I'll have to study this a bit, I'll get
back to you in few days/one week. We tackled the unlock_all stuff in
the past, Michael did a patch, I'll check how that fits here.

https://patchwork.ozlabs.org/project/linux-mtd/patch/20200327155939.13153-1-michael@walle.cc/

Cheers,
ta

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2020-07-21  9:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-20 18:13 [BUG]: spi-nor: spi_nor_init() fails when SR locked David Clear
2020-07-21  9:37 ` Tudor.Ambarus [this message]
2020-07-21 17:02   ` David Clear

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ae4f44a-cbd2-b39e-68f7-3d0375c453bf@microchip.com \
    --to=tudor.ambarus@microchip.com \
    --cc=dac2@pensando.io \
    --cc=linux-mtd@lists.infradead.org \
    --cc=michael@walle.cc \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).