Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Manikandan Muralidharan" <manikandan.m@microchip.com>,
	pratyush@kernel.org, mwalle@kernel.org,
	takahiro.kuwano@infineon.com, miquel.raynal@bootlin.com,
	richard@nod.at, vigneshr@ti.com, srini@kernel.org,
	linux-mtd@lists.infradead.org
Subject: Re: [PATCH v2 1/2] mtd: spi-nor: drop fw_devlink suppliers below a flash that failed to probe
Date: Mon, 30 Nov 2026 08:17:33 +0000	[thread overview]
Message-ID: <sashiko-outbox-240681@kernel.org> (raw)
In-Reply-To: <fc941df52e1674420774cc6f10859c55ef56d1cc.1796023057.git.manikandan.m@microchip.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] mtd: spi-nor: missing deferred probe trigger in spi_nor_probe()
  error path
- [Medium] mtd: spi-nor: incomplete supplier purging in spi_nor_probe()
  on error paths
--

commit c60e9abc61b54c89108b300ba9fa15df3cb4bd41
Author: Manikandan Muralidharan <manikandan.m@microchip.com>

mtd: spi-nor: drop fw_devlink suppliers below a flash that failed to probe

This commit calls fw_devlink_purge_absent_suppliers() on child fwnodes of a
SPI NOR flash when spi_nor_scan() fails with a non-deferral error so that
consumers waiting on child nodes are not blocked forever by fw_devlink.

> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index 99584ee0ecb32..c2661dc2395bc 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
[ ... ]
> @@ -3624,6 +3625,25 @@ static int spi_nor_create_write_dirmap(struct spi_nor *nor)
>  	return PTR_ERR_OR_ZERO(nor->dirmap.wdesc);
>  }
>  
> +/**
> + * spi_nor_purge_absent_suppliers() - drop fw_devlink links below a missing
> + * flash
> + * @dev:	pointer to the flash 'struct device'
> + *
> + * When the flash cannot be probed (e.g. it is not populated or not
> + * reachable), nothing described below its node, such as the SFDP NVMEM
> + * device or the partitions, is ever registered. Mark those nodes as never
> + * becoming devices and drop their consumer links, so that consumers such as
> + * an Ethernet MAC using an NVMEM cell are not deferred forever.
> + */
> +static void spi_nor_purge_absent_suppliers(struct device *dev)
> +{
> +	struct fwnode_handle *child;
> +
> +	device_for_each_child_node(dev, child)
> +		fw_devlink_purge_absent_suppliers(child);
> +}

[Severity: High]
Does purging the fwnode links on a failed probe wake consumers that are
already on deferred_probe_pending_list?

fw_devlink_purge_absent_suppliers() drops the consumer fwnode links via
fwnode_links_purge_consumers(), which does not call
driver_deferred_probe_trigger().  Because spi_nor_probe() then returns a
non-zero error, really_probe() jumps to probe_failed without calling
driver_bound() or driver_deferred_probe_trigger().

If the consumer already deferred in device_links_check_suppliers() before
spi_nor_probe() ran (for example, when spi-nor or the SPI controller driver
is loaded as a module after the deferred probe timeout, or when the flash is
probed after the consumer during the final deferred_probe_work_func() pass),
nothing moves the consumer from deferred_probe_pending_list to
deferred_probe_active_list unless an unrelated device binds later.

>  static int spi_nor_probe(struct spi_mem *spimem)
>  {
>  	struct spi_device *spi = spimem->spi;
> @@ -3672,8 +3692,12 @@ static int spi_nor_probe(struct spi_mem *spimem)
>  		flash_name = spi->modalias;
>  
>  	ret = spi_nor_scan(nor, flash_name, &hwcaps);
> -	if (ret)
> +	if (ret) {
> +		/* A deferred probe (e.g. on the reset GPIO) may still succeed. */
> +		if (ret != -EPROBE_DEFER)
> +			spi_nor_purge_absent_suppliers(dev);
>  		return ret;
> +	}

[Severity: Medium]
Can spi_nor_purge_absent_suppliers() miss the nvmem-layout child nodes when
spi_nor_scan() fails after registering the SFDP NVMEM device?

Inside spi_nor_scan(), spi_nor_init_params() calls
spi_nor_register_sfdp_nvmem() before spi_nor_late_init_params(),
spi_nor_setup(), spi_nor_init() and spi_nor_set_mtd_info().
spi_nor_register_sfdp_nvmem() uses devm_nvmem_register(), which populates
the nvmem-layout child device and sets fwnode->dev on the nvmem-layout
fwnode via nvmem_layout_create_device().

If a later step in spi_nor_scan() fails, spi_nor_purge_absent_suppliers()
runs before really_probe() calls devres_release_all().  At that point
fwnode->dev is still non-NULL on the nvmem-layout fwnode, so
fw_devlink_purge_absent_suppliers() returns early at the "if (fwnode->dev)
return;" check without purging consumer links on the layout node or
recursing into its child cell nodes (such as mac-address).

Also, if spi_nor_probe() fails with a permanent error outside
spi_nor_scan() (such as in devm_regulator_get_enable(), dirmap creation, or
mtd_device_register()), spi_nor_purge_absent_suppliers() is not called at
all.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796023057.git.manikandan.m@microchip.com?part=1

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

  reply	other threads:[~2026-11-30  8:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  7:45 [PATCH v2 0/2] mtd/nvmem: don't defer forever on absent NVMEM suppliers Manikandan Muralidharan
2026-11-30  7:45 ` [PATCH v2 1/2] mtd: spi-nor: drop fw_devlink suppliers below a flash that failed to probe Manikandan Muralidharan
2026-11-30  8:17   ` sashiko-bot [this message]
2026-11-30  7:45 ` [PATCH v2 2/2] nvmem: core: stop deferring for a cell after the deferred probe timeout Manikandan Muralidharan

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=sashiko-outbox-240681@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=manikandan.m@microchip.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=mwalle@kernel.org \
    --cc=pratyush@kernel.org \
    --cc=richard@nod.at \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=srini@kernel.org \
    --cc=takahiro.kuwano@infineon.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