linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Gutson <daniel@eclypsium.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Richard Hughes <hughsient@gmail.com>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Tudor Ambarus <tudor.ambarus@microchip.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Boris Brezillon <bbrezillon@kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Richard Weinberger <richard@nod.at>,
	linux-mtd <linux-mtd@lists.infradead.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Alex Bazhaniuk <alex@eclypsium.com>,
	Mika Westerberg <mika.westerberg@linux.intel.com>
Subject: Re: [PATCH] Module argument to control whether intel-spi-pci attempts to turn the SPI flash chip writeable
Date: Thu, 30 Jul 2020 11:20:48 -0300	[thread overview]
Message-ID: <CAFmMkTFyKSUWYgKeTBGh9wkB4dajhdJ3xZ9CUvQwk8hS1LGU-Q@mail.gmail.com> (raw)
In-Reply-To: <CAFmMkTFiqDtTw2v8RJktzY--WxGd7Fdz2fKA3YxXzA8ZiDS1XQ@mail.gmail.com>

On Thu, Jul 30, 2020 at 11:18 AM Daniel Gutson <daniel@eclypsium.com> wrote:
>
> On Thu, Jul 30, 2020 at 11:09 AM Arnd Bergmann <arnd@arndb.de> wrote:
> >
> > On Thu, Jul 30, 2020 at 2:21 PM Daniel Gutson <daniel@eclypsium.com> wrote:
> > > El jue., 30 jul. 2020 2:31 a. m., Greg Kroah-Hartman <gregkh@linuxfoundation.org> escribió:
> > >>
> > >> Again, module parameters are working on a per-chunk-of-code basis, while
> > >> you want to work on a per-device basis,
> > >
> > >
> > > I think there is a misunderstanding.  What I want is to control (turn on or off) is a very specific code snippet that provides the "functionality" of trying to turn the chip writable. The rest of the device driver is fine.
> > > I assume that the one that doesn't understand is me.
> > >
> >
> > I looked at the source code again and found that the existing module
> > parameter applies to both the platform and pci device front-ends, both
> > of which go through
> >
> >         /* Prevent writes if not explicitly enabled */
> >         if (!ispi->writeable || !writeable)
> >                 ispi->nor.mtd.flags &= ~MTD_WRITEABLE;
> >
>
> I think you missed
> https://elixir.bootlin.com/linux/latest/source/drivers/mtd/spi-nor/controllers/intel-spi-pci.c#L44
>
>     /* Try to make the chip read/write */
>     pci_read_config_dword(pdev, BCR, &bcr);
>     if (!(bcr & BCR_WPD)) {
>         bcr |= BCR_WPD;
>         pci_write_config_dword(pdev, BCR, bcr);
>         pci_read_config_dword(pdev, BCR, &bcr);
>     }
>
> in the probe function, and is executed always and unconditionally.

To clarify, this is executed before intel-spi code.

>
> /* Try to make the chip read/write */
> pci_read_config_dword(pdev, BCR, &bcr);
> if (!(bcr & BCR_WPD)) {
> bcr |= BCR_WPD;
> pci_write_config_dword(pdev, BCR, bcr);
> pci_read_config_dword(pdev, BCR, &bcr);
> }
>
> > Setting the PCI device writable in hardware makes it possible to
> > actually write to it *only* if the module parameter is also set to '1'.
> > One might disagree with that design, but I don't think your patch
> > would make it any better, it just means one would have to set
> > two module parameters instead of one.
> >
> >      Arnd
>
>
>
> --
> Daniel Gutson
> Argentina Site Director
> Enginieering Director
> Eclypsium
>
> Below The Surface: Get the latest threat research and insights on
> firmware and supply chain threats from the research team at Eclypsium.
> https://eclypsium.com/research/#threatreport



-- 
Daniel Gutson
Argentina Site Director
Enginieering Director
Eclypsium

Below The Surface: Get the latest threat research and insights on
firmware and supply chain threats from the research team at Eclypsium.
https://eclypsium.com/research/#threatreport

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

  reply	other threads:[~2020-07-30 14:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-24 21:28 [PATCH] Module argument to control whether intel-spi-pci attempts to turn the SPI flash chip writeable Daniel Gutson
2020-07-25  5:56 ` Greg Kroah-Hartman
     [not found]   ` <CAFmMkTE_dT9+WJYyb19uQ_HmgJWZSARBy6PveheQJk++NuGbkQ@mail.gmail.com>
2020-07-26  7:17     ` Greg Kroah-Hartman
     [not found]       ` <CAFmMkTFzGfFDrJrdgHztzLK2K-zBWy6T2Tv+G4-rrbVpbahkgg@mail.gmail.com>
2020-07-27 15:15         ` Arnd Bergmann
2020-07-27 15:31           ` Daniel Gutson
2020-07-29 20:54             ` Daniel Gutson
2020-07-30  5:31               ` Greg Kroah-Hartman
     [not found]                 ` <CAFmMkTHXjfG7zMr0i_h65PvjAe4opPgvzdABH8W1EUGOmcA4Zg@mail.gmail.com>
2020-07-30 14:09                   ` Arnd Bergmann
2020-07-30 14:18                     ` Daniel Gutson
2020-07-30 14:20                       ` Daniel Gutson [this message]
2020-08-03  9:57 ` Mika Westerberg
2020-08-03 10:18   ` Richard Hughes
2020-08-03 10:27     ` Mika Westerberg
2020-08-03 12:58       ` Daniel Gutson
2020-08-03 13:05         ` Mika Westerberg
2020-08-03 13:17           ` Daniel Gutson

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=CAFmMkTFyKSUWYgKeTBGh9wkB4dajhdJ3xZ9CUvQwk8hS1LGU-Q@mail.gmail.com \
    --to=daniel@eclypsium.com \
    --cc=alex@eclypsium.com \
    --cc=arnd@arndb.de \
    --cc=bbrezillon@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=hughsient@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=tudor.ambarus@microchip.com \
    --cc=vigneshr@ti.com \
    /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).