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 |
+ SPI_NOR_DUAL_READ |
SPI_NOR_QUAD_READ |
SPI_NOR_OCTAL_READ |
SPI_NOR_OCTAL_DTR_READ))
diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
index 442786685515..77f61a984cb3 100644
--- a/drivers/mtd/spi-nor/core.h
+++ b/drivers/mtd/spi-nor/core.h
@@ -535,6 +535,7 @@ struct flash_info {
u8 no_sfdp_flags;
#define SPI_NOR_SKIP_SFDP BIT(0)
#define SECT_4K BIT(1)
+#define SPI_NOR_TRY_SFDP BIT(2)
#define SPI_NOR_DUAL_READ BIT(3)
#define SPI_NOR_QUAD_READ BIT(4)
#define SPI_NOR_OCTAL_READ BIT(5)
--
2.45.2
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.
> + SPI_NOR_DUAL_READ |
> SPI_NOR_QUAD_READ |
> SPI_NOR_OCTAL_READ |
> SPI_NOR_OCTAL_DTR_READ))
> diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
> index 442786685515..77f61a984cb3 100644
> --- a/drivers/mtd/spi-nor/core.h
> +++ b/drivers/mtd/spi-nor/core.h
> @@ -535,6 +535,7 @@ struct flash_info {
> u8 no_sfdp_flags;
> #define SPI_NOR_SKIP_SFDP BIT(0)
> #define SECT_4K BIT(1)
> +#define SPI_NOR_TRY_SFDP BIT(2)
> #define SPI_NOR_DUAL_READ BIT(3)
> #define SPI_NOR_QUAD_READ BIT(4)
> #define SPI_NOR_OCTAL_READ BIT(5)
>
Tudor Ambarus <tudor.ambarus@linaro.org> writes:
> 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.
Maybe we should un-deprecate it? I don't understand why it should be
deprecated. It obviously has a valid purpose.
>> + SPI_NOR_DUAL_READ |
>> SPI_NOR_QUAD_READ |
>> SPI_NOR_OCTAL_READ |
>> SPI_NOR_OCTAL_DTR_READ))
>> diff --git a/drivers/mtd/spi-nor/core.h b/drivers/mtd/spi-nor/core.h
>> index 442786685515..77f61a984cb3 100644
>> --- a/drivers/mtd/spi-nor/core.h
>> +++ b/drivers/mtd/spi-nor/core.h
>> @@ -535,6 +535,7 @@ struct flash_info {
>> u8 no_sfdp_flags;
>> #define SPI_NOR_SKIP_SFDP BIT(0)
>> #define SECT_4K BIT(1)
>> +#define SPI_NOR_TRY_SFDP BIT(2)
>> #define SPI_NOR_DUAL_READ BIT(3)
>> #define SPI_NOR_QUAD_READ BIT(4)
>> #define SPI_NOR_OCTAL_READ BIT(5)
>>
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.
-michael
"Michael Walle" <mwalle@kernel.org> writes:
> 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
Actually, in the code we have two variants of 2.
(2a) non-SFDP flashes with SPI_NOR_SKIP_SFDP set
(2b) non-SFDP flashes without SPI_NOR_SKIP_SFDP and with none of the
DUAL/QUAD/OCTAL read bits set
These almost handled the same way. But
spi_nor_manufacturer_init_params() is only called for 2b, and not for
2a.
Is this desired behavior, or something that we want to align?
> 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.
/Esben
Hi Esben, > > 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 > > Actually, in the code we have two variants of 2. > > (2a) non-SFDP flashes with SPI_NOR_SKIP_SFDP set > (2b) non-SFDP flashes without SPI_NOR_SKIP_SFDP and with none of the > DUAL/QUAD/OCTAL read bits set Isn't (2b) my case (3)? The SPI_NOR_SKIP_SFDP flag was intended to be for flashes we know for a fact, there are no SFDP tables. I'm looking at spi_nor_init_params(). Maybe I'm missing something? -michael > These almost handled the same way. But > spi_nor_manufacturer_init_params() is only called for 2b, and not for > 2a. > > Is this desired behavior, or something that we want to align? > > > 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. > > /Esben
"Michael Walle" <mwalle@kernel.org> writes: >> > 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 >> >> Actually, in the code we have two variants of 2. >> >> (2a) non-SFDP flashes with SPI_NOR_SKIP_SFDP set >> (2b) non-SFDP flashes without SPI_NOR_SKIP_SFDP and with none of the >> DUAL/QUAD/OCTAL read bits set > > Isn't (2b) my case (3)? The SPI_NOR_SKIP_SFDP flag was intended to > be for flashes we know for a fact, there are no SFDP tables. > > I'm looking at spi_nor_init_params(). Maybe I'm missing something? Probably not. I might just be confusing things here. Your case (3) is conditional. Based on the magic flags checking in spi_nor_init_params_deprecated(), it is either doing static configuration only (this is what I tried to redefine as case (2b)) or parsing SFDP with fallback to static configuration. The issue I am getting at is that while the 2 different ways to end up doing static configuration only is almost identical, there is a slight difference. But I will be addressing this in a v3 patch of this series. Coming up shortly, and looking forward to discuss it. /Esben >> These almost handled the same way. But >> spi_nor_manufacturer_init_params() is only called for 2b, and not for >> 2a. >> >> Is this desired behavior, or something that we want to align? >> >> > 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. >> >> /Esben
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? I won't oppose too much, but to me it feels that we're trying to keep alive a dead man.
Tudor Ambarus <tudor.ambarus@linaro.org> writes: > 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? > > I won't oppose too much, but to me it feels that we're trying to keep > alive a dead man. Which dead man are you referring to? The legacy implementation or the old non-SFDP Macronix part? /Esben
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?) because the flash is first treated like in case (2). Then SFDP is tried based on that flag. Is it worth it? I don't know, Esben is doing the development here ;) So up to him. > 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). -michael
"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. /Esben
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/
Tudor Ambarus <tudor.ambarus@linaro.org> writes:
> 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/
Great. Let's do that.
But other than avoiding the "magic flags decide whether we use SFDP",
should I be doing anything different?
I assume we should still be calling the default_init() fixup functions,
both for manufacturer and flash level. Or should we leave this for the
deprecated case only?
If the semantics is basically the same as for the deprecated, why not
simply change the implementation of the deprecated approach to what we
need? So having 3 cases:
(1) SFDP only [indicated by size==0]
(2) static config only [indicated by no_sfdp_flags & SPI_NOR_SKIP_SFDP]
(3) SFDP with fallback to static config [indicated with size!=0 and
!(no_sfdp_flags & SPI_NOR_SKIP_SFDP]
Any reason that we should not be able to easily convert existing
depracted flash info specifications to the new SFDP with fallback to
static config?
Also I am wondering if anyone can remember or otherwise figure out why
we are doing this memcpy() dance with nor->params in
spi_nor_sfdp_init_params_deprecated()? Why not simply call
spi_nor_parse_sfdp() before
spi_nor_no_sfdp_init_params()/spi_nor_manufacturer_init_params()?
/Esben
Hi, On Fri Jun 7, 2024 at 3:30 PM CEST, Esben Haabendal wrote: > But other than avoiding the "magic flags decide whether we use SFDP", > should I be doing anything different? > > I assume we should still be calling the default_init() fixup functions, > both for manufacturer and flash level. Or should we leave this for the > deprecated case only? No, they have to be handled. > If the semantics is basically the same as for the deprecated, why not > simply change the implementation of the deprecated approach to what we > need? So having 3 cases: > > (1) SFDP only [indicated by size==0] > (2) static config only [indicated by no_sfdp_flags & SPI_NOR_SKIP_SFDP] > (3) SFDP with fallback to static config [indicated with size!=0 and > !(no_sfdp_flags & SPI_NOR_SKIP_SFDP] > > Any reason that we should not be able to easily convert existing > depracted flash info specifications to the new SFDP with fallback to > static config? IMHO the only difference is that dual/quad read will imply the sfdp fallback. So maybe the function can really be renamed accordingly and the "deprecated handling" is just that dual/quad read will set the sfdp fallback flag. > Also I am wondering if anyone can remember or otherwise figure out why > we are doing this memcpy() dance with nor->params in > spi_nor_sfdp_init_params_deprecated()? Why not simply call > spi_nor_parse_sfdp() before > spi_nor_no_sfdp_init_params()/spi_nor_manufacturer_init_params()? spi_nor_parse_sfdp() will overwrite the parameters set by the former. So if you'll swap the order, the latter (static) ones will overwrite the the ones from sfdp. The correct fix would be to make spi_nor_parse_sfdp() not fiddle around the parameters if it might fail. The quick fix here might be to push that memcpy into the parse function. But I haven't looked at the code right now. -michael
© 2016 - 2026 Red Hat, Inc.