From: <Tudor.Ambarus@microchip.com>
To: <michael@walle.cc>
Cc: macromorgan@hotmail.com, vigneshr@ti.com, jaimeliao@mxic.com.tw,
richard@nod.at, esben@geanix.com, linux@rasmusvillemoes.dk,
knaerzche@gmail.com, linux-mtd@lists.infradead.org,
linux-arm-kernel@lists.infradead.org, code@reto-schneider.ch,
miquel.raynal@bootlin.com, heiko.thiery@gmail.com, sr@denx.de,
figgyc@figgyc.uk, p.yadav@ti.com, mail@david-bauer.net,
zhengxunli@mxic.com.tw
Subject: Re: [PATCH v2 17/35] mtd: spi-nor: Introduce spi_nor_nonsfdp_flags_init()
Date: Mon, 25 Oct 2021 12:18:10 +0000 [thread overview]
Message-ID: <8ce9a228-3d38-1be7-a987-fd20208539d8@microchip.com> (raw)
In-Reply-To: <b06ac5238d85f62ebe588f161e34cf59@walle.cc>
On 10/24/21 8:05 PM, Michael Walle wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>
> Am 2021-10-22 15:25, schrieb Tudor.Ambarus@microchip.com:
>> On 10/22/21 3:59 PM, Michael Walle wrote:
>>> EXTERNAL EMAIL: Do not click links or open attachments unless you know
>>> the content is safe
>>>
>>> Am 2021-10-22 14:42, schrieb Tudor.Ambarus@microchip.com:
>>>> On 10/22/21 3:10 PM, Pratyush Yadav wrote:
>>>>> EXTERNAL EMAIL: Do not click links or open attachments unless you
>>>>> know
>>>>> the content is safe
>>>>>
>>>>> On 22/10/21 01:21PM, Michael Walle wrote:
>>>>>> Am 2021-08-17 12:24, schrieb Pratyush Yadav:
>>>>>>> On 27/07/21 07:52AM, Tudor Ambarus wrote:
>>>>>>>> Used to initialize the NOR flags for settings that are not
>>>>>>>> defined
>>>>>>>> in the JESD216 SFDP standard, thus can not be retrieved when
>>>>>>>> parsing
>>>>>>>> SFDP. No functional change.
>>>>>>>
>>>>>>> I am worried if the order in which these flags are set can cause
>>>>>>> some
>>>>>>> subtle bugs.
>>>>>>>
>>>>>>> I can see one instance of it with SNOR_F_HAS_LOCK.
>>>>>>> spi_nor_late_init_params() checks for SNOR_F_HAS_LOCK and if there
>>>>>>> are
>>>>>>> no locking ops specified, it sets the default locking ops. This
>>>>>>> works
>>>>>>> fine before this patch because the flag is set before the function
>>>>>>> is
>>>>>>> called. But now, the flag will be set _after_ the function is
>>>>>>> called,
>>>>>>> and so you will never be able to set the default flags.
>>>>>>
>>>>>> Maybe we should just forbid to look at the SNOR_F_ flags in these
>>>>>> functions. Instead the information could also be deduced by looking
>>>>>> at
>>>>>> the SPI_NOR_ flags.
>>>>
>>>> not true.
>>>
>>> I guess you mean that some init flash init functions might set it,
>>> too.
>>> Right? IMHO this goes into the spaghetti code direction again.
>>> spi_nor_late_init_params() must not look at the SNOR_F_ flags. There
>>> are too much inter-function dependencies and it is really hard to
>>> follow the call chain.
>>
>> I don't think I understand what you are referring to. The flash_info
>> flags
>> are used just to set their SNOR_F correspondents. Take
>> SNOR_F_4B_OPCODES for
>> example. A flash that can't discover 4b opcodes support when parsing
>> SFDP,
>> will set the SPI_NOR_4B_OPCODES flash_info flag. Flashes that can
>> discover it,
>> will ignore/not set the SPI_NOR_4B_OPCODES flag, and let the SFDP do
>> its thing:
>> the SFDP code will set the SNOR_F_4B_OPCODES flag. The only flags that
>> are used
>> across the SPI NOR core are the nor->flags (SNOR_F).
>
> Sorry, I wasn't clear enough. I was talking about checking (already set)
> SNOR_F
> flags in all these init functions ({flash,manufacturer)->post_sfdp(),
> (flash,manufacturer)->late_init, ..). If we didn't allow this, then
> we would avoid all these "subtle bugs" which happen because some of
> these
> functions depend on another being called first. I.e. all the called
> functions within spi_nor_init_params() may only add SNOR_F flags, but
> must
> not actually use them. [I see that spi_nor_sfdp_init_params() will
> remove SNOR_F_4B_OPCODES. Mhh.]
Keeping the setting of SNOR_F flags based on the flash_info flags as late
as we can assures the reader that SNOR_F flags are not used across the
init params chain. It also indicates that the flash can't set the SNOR_F
capability by parsing SFDP, so it needed explicit flags at declaration.
It is clearer who sets and when.
>
> Btw. I wonder what is the difference between a member being in "struct
> spi_nor"
> and being in "struct spi_nor_flash_parameter". Apparently, it should
> contain the properties which can be set/changed in the fixups or by
> parsing the SFPD. But then there are also the flags which are also
> changed in the fixups.
>
> Maybe we should pass the "struct nor" as const and a second parameter
> "struct spi_nor_flash_parameter *params" which can be updated by the
> called function. This way we can be sure the functions won't change
> anything else. I don't suggest to do that right now, just to start
> a discussion.
I'll let this for other time, maybe a separate thread.
>
>>> The locking ops should also go into the (static) flash init which only
>>> depends on the SPI_NOR_ flags. If SNOR_F_HAS_LOCK will be added at
>>
>> we don't have to specify the locking methods, we have generic ones. A
>> single
>> flag is enough.
>
> Hm, I'm not really sure we need that SNOR_F_HAS_LOCK flag at all.
> "if (nor->params->locking_ops)" should be the same. At least the current
> code
> which checks the info->flags for SPI_NOR_HAS_LOCK will set the default
> locking ops instead of just setting the SNOR_F_HAS_LOCK.
SNOR_F_HAS_LOCK is kept for consistency. The core driver operates just on SNOR_F
flags. Here it's the same idea, I would like to set the locking ops as late in
the init chain as possible, to indicate that the locking ops are not needed earlier.
>
>>> in an init function, then this code should also take care of setting
>>
>> what init function? We're just setting some flags.
>
> all the functions called in spi_nor_init_params().
>
>>> the correct locking ops. Maybe both can be set together with a helper.
>
> -michael
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2021-10-25 12:20 UTC|newest]
Thread overview: 133+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-27 4:51 [PATCH v2 00/35] mtd: spi-nor: Handle ID collisions and clean params init Tudor Ambarus
2021-07-27 4:51 ` [PATCH v2 01/35] mtd: spi-nor: core: Introduce SPI_NOR_PARSE_SFDP Tudor Ambarus
2021-08-04 8:09 ` Pratyush Yadav
2021-08-23 22:17 ` Michael Walle
2021-07-27 4:51 ` [PATCH v2 02/35] mtd: spi-nor: core: Report correct name in case of ID collisions Tudor Ambarus
2021-08-04 8:23 ` Pratyush Yadav
2021-08-23 22:32 ` Michael Walle
2021-07-27 4:51 ` [PATCH v2 03/35] mtd: spi-nor: macronix: Handle ID collision b/w MX25L3233F and MX25L3205D Tudor Ambarus
2021-08-23 22:42 ` Michael Walle
2021-10-01 8:41 ` Tudor.Ambarus
2021-07-27 4:51 ` [PATCH v2 04/35] mtd: spi-nor: macronix: Handle ID collision b/w MX25L12805D and MX25L12835F Tudor Ambarus
2021-08-23 22:44 ` Michael Walle
2021-07-27 4:51 ` [PATCH v2 05/35] mtd: spi-nor: Introduce Manufacturer ID collisions driver Tudor Ambarus
2021-08-16 18:28 ` Pratyush Yadav
2021-08-23 22:47 ` Michael Walle
2021-10-01 9:16 ` Tudor.Ambarus
2021-10-24 17:44 ` Michael Walle
2021-11-06 9:58 ` Tudor.Ambarus
2021-07-27 4:51 ` [PATCH v2 06/35] mtd: spi-nor: manuf-id-collisions: Add support for xt25f128b Tudor Ambarus
2021-07-27 15:52 ` Chris Morgan
2021-07-28 4:10 ` Tudor.Ambarus
2021-08-16 18:43 ` Pratyush Yadav
2021-10-01 9:26 ` Tudor.Ambarus
2021-07-27 4:51 ` [PATCH v2 07/35] mtd: spi-nor: manuf-id-collisions: Add support for xm25qh64c Tudor Ambarus
2021-08-16 18:45 ` Pratyush Yadav
2021-07-27 4:51 ` [PATCH v2 08/35] mtd: spi-nor: core: Introduce the ate_init() hook Tudor Ambarus
2021-08-16 18:54 ` Pratyush Yadav
2021-09-09 21:40 ` Michael Walle
2021-10-01 9:44 ` Tudor.Ambarus
2021-10-01 9:38 ` Tudor.Ambarus
2021-07-27 4:51 ` [PATCH v2 09/35] mtd: spi-nor: atmel: Use flash late_init() for locking Tudor Ambarus
2021-08-16 19:06 ` Pratyush Yadav
2021-09-09 21:44 ` Michael Walle
2021-10-01 11:40 ` Tudor.Ambarus
2021-10-02 12:58 ` Michael Walle
2021-10-11 6:27 ` Pratyush Yadav
2021-07-27 4:51 ` [PATCH v2 10/35] mtd: spi-nor: sst: " Tudor Ambarus
2021-08-16 19:09 ` Pratyush Yadav
2021-10-01 11:43 ` Tudor.Ambarus
2021-10-01 12:19 ` Pratyush Yadav
2021-09-09 21:52 ` Michael Walle
2021-07-27 4:51 ` [PATCH v2 11/35] mtd: spi-nor: winbond: Use manufacturer late_init() for OTP ops Tudor Ambarus
2021-08-16 19:17 ` Pratyush Yadav
2021-09-09 21:50 ` Michael Walle
2021-10-01 11:58 ` Tudor.Ambarus
2021-10-01 11:54 ` Tudor.Ambarus
2021-10-11 6:54 ` Pratyush Yadav
2021-07-27 4:51 ` [PATCH v2 12/35] mtd: spi-nor: xilinx: Use manufacturer late_init() to set setup method Tudor Ambarus
2021-08-16 19:19 ` Pratyush Yadav
2021-09-09 21:53 ` Michael Walle
2021-07-27 4:52 ` [PATCH v2 13/35] mtd: spi-nor: sst: Use manufacturer late_init() to set _write() Tudor Ambarus
2021-08-16 19:20 ` Pratyush Yadav
2021-09-09 21:54 ` Michael Walle
2021-07-27 4:52 ` [PATCH v2 14/35] mtd: spi-nor: spansion: Use manufacturer late_init() Tudor Ambarus
2021-08-16 19:22 ` Pratyush Yadav
2021-09-09 22:02 ` Michael Walle
2021-10-01 12:14 ` Tudor.Ambarus
2021-10-02 13:14 ` Michael Walle
2021-07-27 4:52 ` [PATCH v2 15/35] mtd: spi-nor: core: Call spi_nor_post_sfdp_fixups() only when SFDP is defined Tudor Ambarus
2021-08-16 19:31 ` Pratyush Yadav
2021-10-01 12:31 ` Tudor.Ambarus
2021-07-27 4:52 ` [PATCH v2 16/35] mtd: spi-nor: core: Mark default_init() as deprecated Tudor Ambarus
2021-08-16 19:36 ` Pratyush Yadav
2021-10-01 14:18 ` Tudor.Ambarus
2021-10-01 17:06 ` Pratyush Yadav
2021-07-27 4:52 ` [PATCH v2 17/35] mtd: spi-nor: Introduce spi_nor_nonsfdp_flags_init() Tudor Ambarus
2021-08-17 10:24 ` Pratyush Yadav
2021-08-17 12:15 ` Tudor.Ambarus
2021-10-22 11:21 ` Michael Walle
2021-10-22 12:10 ` Pratyush Yadav
2021-10-22 12:42 ` Tudor.Ambarus
2021-10-22 12:59 ` Michael Walle
2021-10-22 13:25 ` Tudor.Ambarus
2021-10-24 17:05 ` Michael Walle
2021-10-25 12:18 ` Tudor.Ambarus [this message]
2021-07-27 4:52 ` [PATCH v2 18/35] mtd: spi-nor: Get rid of SPI_NOR_4B_OPCODES flag Tudor Ambarus
2021-08-17 12:16 ` Pratyush Yadav
2021-10-04 3:18 ` Tudor.Ambarus
2021-10-19 17:26 ` Pratyush Yadav
2021-10-20 9:55 ` Tudor.Ambarus
2021-10-21 8:44 ` Tudor.Ambarus
2021-10-21 9:30 ` Pratyush Yadav
2021-10-22 11:37 ` Michael Walle
2021-10-22 12:43 ` Tudor.Ambarus
2021-07-27 4:52 ` [PATCH v2 19/35] mtd: spi-nor: Get rid of SPI_NOR_IO_MODE_EN_VOLATILE flag Tudor Ambarus
2021-08-17 12:21 ` Pratyush Yadav
2021-10-04 3:52 ` Tudor.Ambarus
2021-10-11 6:15 ` Pratyush Yadav
2021-07-27 4:52 ` [PATCH v2 20/35] mtd: spi-nor: core: Use container_of to get the pointer to struct spi_nor Tudor Ambarus
2021-07-27 7:08 ` Rasmus Villemoes
2021-10-22 8:00 ` Tudor.Ambarus
2021-08-17 12:23 ` Pratyush Yadav
2021-07-27 4:52 ` [PATCH v2 21/35] mtd: spi-nor: Introduce spi_nor_set_mtd_info() Tudor Ambarus
2021-08-16 7:25 ` Tudor.Ambarus
2021-08-17 16:23 ` Pratyush Yadav
2021-10-22 11:53 ` Michael Walle
2021-07-27 4:52 ` [PATCH v2 22/35] mtd: spi-nor: core: Use common naming scheme for setting mtd_info fields Tudor Ambarus
2021-08-17 16:26 ` Pratyush Yadav
2021-10-22 11:57 ` Michael Walle
2021-10-22 12:51 ` Tudor.Ambarus
2021-10-22 13:08 ` Michael Walle
2021-10-22 13:34 ` Tudor.Ambarus
2021-07-27 4:52 ` [PATCH v2 23/35] mtd: spi-nor: Get rid of nor->page_size Tudor Ambarus
2021-08-17 16:33 ` Pratyush Yadav
2021-10-22 12:01 ` Michael Walle
2021-07-27 4:52 ` [PATCH v2 24/35] mtd: spi-nor: core: Fix spi_nor_flash_parameter otp description Tudor Ambarus
2021-08-17 16:47 ` Pratyush Yadav
2021-10-22 12:07 ` Michael Walle
2021-07-27 4:52 ` [PATCH v2 25/35] mtd: spi-nor: core: Move spi_nor_set_addr_width() in spi_nor_setup() Tudor Ambarus
2021-08-17 16:52 ` Pratyush Yadav
2021-10-22 12:12 ` Michael Walle
2021-10-22 12:36 ` Tudor.Ambarus
2021-07-27 4:52 ` [PATCH v2 26/35] mtd: spi-nor: core: Introduce spi_nor_init_default_params() Tudor Ambarus
2021-08-24 17:30 ` Pratyush Yadav
2021-10-04 4:17 ` Tudor.Ambarus
2021-10-22 12:41 ` Michael Walle
2021-10-22 12:55 ` Tudor.Ambarus
2021-07-27 4:52 ` [PATCH v2 27/35] mtd: spi-nor: core: Init flash params based on SFDP first for new flash additions Tudor Ambarus
2021-08-24 17:51 ` Pratyush Yadav
2021-10-04 5:01 ` Tudor.Ambarus
2021-10-04 11:36 ` Tudor.Ambarus
2021-07-27 4:52 ` [PATCH v2 28/35] mtd: spi-nor: sst: sst26vf064b: Use SPI_NOR_PARSE_SFDP Tudor Ambarus
2021-07-27 4:52 ` [PATCH v2 29/35] mtd: spi-nor: winbond: w25q256jvm: " Tudor Ambarus
2021-07-27 4:52 ` [PATCH v2 30/35] mtd: spi-nor: issi: is25lp256: " Tudor Ambarus
2021-07-27 4:52 ` [PATCH v2 31/35] mtd: spi-nor: spansion: s25fl256s0: Skip SFDP parsing Tudor Ambarus
2021-07-27 4:52 ` [PATCH v2 32/35] mtd: spi-nor: gigadevice: gd25q256: Use SPI_NOR_PARSE_SFDP Tudor Ambarus
2021-07-27 4:52 ` [PATCH v2 33/35] mtd: spi-nor: micron-st: n25q256a: " Tudor Ambarus
2021-07-27 4:52 ` [PATCH v2 34/35] mtd: spi-nor: macronix: mx25l25635e: " Tudor Ambarus
2021-07-27 4:52 ` [PATCH v2 35/35] docs: mtd: spi-nor: Add details about how to propose a new flash addition Tudor Ambarus
2021-07-27 7:22 ` Michael Walle
2021-07-27 8:09 ` Tudor.Ambarus
2021-07-27 8:49 ` Michael Walle
2021-08-24 17:58 ` Pratyush Yadav
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=8ce9a228-3d38-1be7-a987-fd20208539d8@microchip.com \
--to=tudor.ambarus@microchip.com \
--cc=code@reto-schneider.ch \
--cc=esben@geanix.com \
--cc=figgyc@figgyc.uk \
--cc=heiko.thiery@gmail.com \
--cc=jaimeliao@mxic.com.tw \
--cc=knaerzche@gmail.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux@rasmusvillemoes.dk \
--cc=macromorgan@hotmail.com \
--cc=mail@david-bauer.net \
--cc=michael@walle.cc \
--cc=miquel.raynal@bootlin.com \
--cc=p.yadav@ti.com \
--cc=richard@nod.at \
--cc=sr@denx.de \
--cc=vigneshr@ti.com \
--cc=zhengxunli@mxic.com.tw \
/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).