From: Tudor Ambarus <tudor.ambarus@linaro.org>
To: Esben Haabendal <esben@geanix.com>, Michael Walle <mwalle@kernel.org>
Cc: Pratyush Yadav <pratyush@kernel.org>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
Rasmus Villemoes <rasmus.villemoes@prevas.dk>
Subject: Re: [PATCH v2 1/2] mtd: spi-nor: core: add flag for doing optional SFDP
Date: Fri, 7 Jun 2024 10:22:55 +0100 [thread overview]
Message-ID: <1d683b33-16db-4d81-92cb-d98e35b87cba@linaro.org> (raw)
In-Reply-To: <874ja6aszh.fsf@geanix.com>
On 6/6/24 18:20, Esben Haabendal wrote:
> "Michael Walle" <mwalle@kernel.org> writes:
>
>> On Thu Jun 6, 2024 at 4:52 PM CEST, Tudor Ambarus wrote:
>>> On 6/6/24 14:59, Michael Walle wrote:
>>>> On Thu Jun 6, 2024 at 3:31 PM CEST, Tudor Ambarus wrote:
>>>>> On 6/3/24 14:09, Esben Haabendal wrote:
>>>>>> A dedicated flag for triggering call to
>>>>>> spi_nor_sfdp_init_params_deprecated() allows enabling optional SFDP read
>>>>>> and parse, with fallback to legacy flash parameters, without having dual,
>>>>>> quad or octal parameters set in the legacy flash parameters.
>>>>>>
>>>>>> With this, spi-nor flash parts without SFDP that is replaced with a
>>>>>> different flash NOR flash part that does have SFDP, but shares the same
>>>>>> manufacturer and device ID is easily handled.
>>>>>>
>>>>>> Signed-off-by: Esben Haabendal <esben@geanix.com>
>>>>>> ---
>>>>>> drivers/mtd/spi-nor/core.c | 3 ++-
>>>>>> drivers/mtd/spi-nor/core.h | 1 +
>>>>>> 2 files changed, 3 insertions(+), 1 deletion(-)
>>>>>>
>>>>>> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
>>>>>> index 3e1f1913536b..1c4d66fc993b 100644
>>>>>> --- a/drivers/mtd/spi-nor/core.c
>>>>>> +++ b/drivers/mtd/spi-nor/core.c
>>>>>> @@ -2933,7 +2933,8 @@ static void spi_nor_init_params_deprecated(struct spi_nor *nor)
>>>>>>
>>>>>> spi_nor_manufacturer_init_params(nor);
>>>>>>
>>>>>> - if (nor->info->no_sfdp_flags & (SPI_NOR_DUAL_READ |
>>>>>> + if (nor->info->no_sfdp_flags & (SPI_NOR_TRY_SFDP |
>>>>>
>>>>> I don't like that we update deprecated methods. The solution though is
>>>>> elegant.
>>>>
>>>> I actually had the same concern. But currently there is no
>>>> non-deprecated way to handle this case, right?
>>>>
>>>> Right now we have the following cases:
>>>> (1) pure SFDP parsing
>>>> (2) non-SFDP flashes with static configuration only
>>>> (3) legacy implementation, where the magic flags decide whether we
>>>> use SFDP
>>>>
>>>> Which case is eventually used depends on the ID of the flash -
>>>> assuming there will only be IDs which either fall into (1) *or* (2).
>>>> That assumption is clearly wrong :)
>>>>
>>>> I'd propose a new case in spi_nor_init_params()
>>>> (4) try SFDP with a fallback to the static flags from the
>>>> flash_info db.
>>>>
>>>
>>> that's not that bad, but I would avoid doing it if it's not common. You
>>> also have to update the core a bit, you can't use no_sfdp_flags &
>>> TRY_SFDP, it's misleading. Does it worth it?
>>
>> IMHO no_sfdp_flags is the correct place (maybe TRY_SFDP is wrong,
>> maybe SFDP_FALLBACK?)
>
> TRY_SFDP might not be the best choice. But SFDP_FALLBACK sounds to me
> like it is fallback _to_ SFDP, so rather counter-intuitive.
>
>> because the flash is first treated like in
>> case (2). Then SFDP is tried based on that flag.
>
> It is first treated like in case (2), and then tried for case (1),
> falling back to the result from case (2) if/when case (1) fails.
>
>> Is it worth it? I
>> don't know, Esben is doing the development here ;) So up to him.
>
> I am not sure exactly how it should look like, but I do like the idea
> proposed above, case (4). It is easier to describe and understand than
> the current legacy implementation.
>
>>> I won't oppose too much, but to me it feels that we're trying to keep
>>> alive a dead man.
>>
>> Maybe, but we'd have a readily solution if we face a similar
>> problem in the future. I'm really not sure, how many flashes there
>> are, but I think these magic bits (which tells the legacy
>> implementation to try SFDP) will mask quite a few of these.
>> I.e. in an ideal world where we could finally drop case (3) and
>> you'd need to split the flashes between case (1) or (2), I think
>> there will be quite some in (4).
>
> I like this. Judging by the way Macronix is handling this particular
> chip, I strongly assume that there are several other examples of this
> for other Macronix parts. Of-course, as long as the original part using
> the particular flash id supported SFDP, and all later flashes using the
> same id also does, none of this is needed.
>
okay, let's implement 4/
next prev parent reply other threads:[~2024-06-07 9:23 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-03 13:09 [PATCH v2 0/2] mtd: spi-nor: macronix: workaround for device id re-use Esben Haabendal
2024-06-03 13:09 ` [PATCH v2 1/2] mtd: spi-nor: core: add flag for doing optional SFDP Esben Haabendal
2024-06-06 13:31 ` Tudor Ambarus
2024-06-06 13:59 ` Michael Walle
2024-06-06 14:52 ` Tudor Ambarus
2024-06-06 15:06 ` Michael Walle
2024-06-06 17:20 ` Esben Haabendal
2024-06-07 9:22 ` Tudor Ambarus [this message]
2024-06-07 13:30 ` Esben Haabendal
2024-06-12 8:51 ` Michael Walle
2024-06-06 17:20 ` Esben Haabendal
2024-07-10 18:42 ` Esben Haabendal
2024-07-11 9:02 ` Michael Walle
2024-07-11 11:55 ` Esben Haabendal
2024-06-06 17:13 ` Esben Haabendal
2024-06-03 13:09 ` [PATCH v2 2/2] mtd: spi-nor: macronix: enable quad/dual speed for mx25l3205d chips Esben Haabendal
2024-06-06 13:33 ` Tudor Ambarus
2024-06-06 17:23 ` Esben Haabendal
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=1d683b33-16db-4d81-92cb-d98e35b87cba@linaro.org \
--to=tudor.ambarus@linaro.org \
--cc=esben@geanix.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=mwalle@kernel.org \
--cc=pratyush@kernel.org \
--cc=rasmus.villemoes@prevas.dk \
--cc=richard@nod.at \
--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).