[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAFmMkTFiqDtTw2v8RJktzY--WxGd7Fdz2fKA3YxXzA8ZiDS1XQ@mail.gmail.com>
Date: Thu, 30 Jul 2020 11:18:20 -0300
From: Daniel Gutson <daniel@...ypsium.com>
To: Arnd Bergmann <arnd@...db.de>
Cc: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Tudor Ambarus <tudor.ambarus@...rochip.com>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>,
Mika Westerberg <mika.westerberg@...ux.intel.com>,
Boris Brezillon <bbrezillon@...nel.org>,
linux-mtd <linux-mtd@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Alex Bazhaniuk <alex@...ypsium.com>,
Richard Hughes <hughsient@...il.com>
Subject: Re: [PATCH] Module argument to control whether intel-spi-pci attempts
to turn the SPI flash chip writeable
On Thu, Jul 30, 2020 at 11:09 AM Arnd Bergmann <arnd@...db.de> wrote:
>
> On Thu, Jul 30, 2020 at 2:21 PM Daniel Gutson <daniel@...ypsium.com> wrote:
> > El jue., 30 jul. 2020 2:31 a. m., Greg Kroah-Hartman <gregkh@...uxfoundation.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.
/* 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
Powered by blists - more mailing lists