mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: maimon.sagi@gmail.com
Cc: richardcochran@gmail.com, vadim.fedorenko@linux.dev,
	kuba@kernel.org, davem@davemloft.net, edumazet@google.com,
	pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org,
	jiri@resnulli.us, arkadiusz.kubalewski@intel.com, corbet@lwn.net,
	rdunlap@infradead.org, skhan@linuxfoundation.org,
	netdev@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 8/9] ptp: ocp: tolerate a latched FAILED when entering configuration mode
Date: Thu, 24 Sep 2026 14:29:33 +0000	[thread overview]
Message-ID: <179026017305.2160803.11471616461860982077@kernel.org> (raw)
In-Reply-To: <20260922142829.57740-9-maimon.sagi@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The patch relaxes only the EN_CFG_TP wait to
  adva_x1_cpld_wait_idle() (drivers/ptp/ptp_ocp.c:5030) but leaves the…

--

ptp: ocp: tolerate a latched FAILED when entering configuration mode

The first status wait after CPLD_CMD_EN_CFG_TP in adva_x1_cpld_flash() is
changed from adva_x1_cpld_wait_ready() to adva_x1_cpld_wait_idle(), so a
latched CPLD_STATUS_FAILED no longer turns the enable step into -EIO.  The
following CPLD_STATUS_ENAB check is left to decide whether the part entered
configuration mode.

> diff --git a/drivers/ptp/ptp_ocp.c b/drivers/ptp/ptp_ocp.c
> index 0d6d0c02882c1..4f2bf54a23c21 100644
> --- a/drivers/ptp/ptp_ocp.c
> +++ b/drivers/ptp/ptp_ocp.c
> @@ -5018,9 +5018,16 @@ static int adva_x1_cpld_flash(struct ptp_ocp *bp, struct devlink *devlink,
>  	 */
>  	bp->cpld_in_config_mode = true;
>  
> +	/* wait_idle(), not wait_ready(): FAILED is latched across operations
> +	 * and nothing here clears it, so treating it as fatal at the enable
> +	 * step would make every later flash of a part that has failed once
> +	 * return -EIO before reaching the ERASE and REFRESH that put it back
> +	 * into a defined state.  ENAB below is what says the enable worked;
> +	 * machxo2-spi.c likewise tests FAIL only after ISC_ENABLE completes.
> +	 */
>  	err = adva_x1_cpld_write(bp, CPLD_CMD_EN_CFG_TP);
>  	if (!err)
> -		err = adva_x1_cpld_wait_ready(bp, 5000);
> +		err = adva_x1_cpld_wait_idle(bp, 5000);
>  	if (err)
>  		goto exit_config;

[Severity: High]

Given the premise that FAILED is latched and nothing in the driver clears
it, does the sequence actually reach the ERASE and REFRESH that the new
comment says put the part back into a defined state?

The next wait in adva_x1_cpld_flash() is still the strict one:

	err = adva_x1_cpld_write(bp, CPLD_CMD_ERASE);
	if (!err)
		err = adva_x1_cpld_wait_ready(bp, CPLD_ERASE_MS);
	if (err)
		goto exit_config;

and adva_x1_cpld_wait_ready() stops polling on FAILED independently of
BUSY, with sleep_before_read == false, so the first status read can
observe the stale bit:

	ret = read_poll_timeout(adva_x1_cpld_read_status, err,
				err || (status & CPLD_STATUS_FAILED) ||
				!(status & CPLD_STATUS_BUSY),
				CPLD_POLL_US, max_ms * USEC_PER_MSEC, false,
				bp, &status);
	if (ret)
		return ret;
	...
	if (status & CPLD_STATUS_FAILED)
		return -EIO;

So on a part with FAILED latched from an earlier aborted update, wouldn't
"devlink dev flash ... component fw.cpld" still return -EIO, just a few
commands later than before?

Is the state the part is left in also worse than before this change?  The
ERASE has been ACKed by then, and this function documents that itself:

	/* Once the erase is issued the image is gone whatever happens next -
	 * an ACKed ERASE runs in the part even if the wait for it fails - so
	 * stop reporting the USERCODE before sending it rather than after
	 * the whole sequence has succeeded.

The goto exit_config path runs adva_x1_cpld_exit_config(), which only waits
BUSY out and sends CPLD_CMD_DIS_CFG, so CPLD_CMD_SET_DONE and
CPLD_CMD_REFRESH are never issued.  Before this patch the same device state
produced a refusal at the enable step with the configuration image intact;
afterwards it erases the configuration flash with DONE cleared and no
refresh.  On this board the CPLD is only reachable through the TMC mux
segment, so does an unconfigured part still have the access path needed to
write a replacement image?

Would the ERASE, page-write (adva_x1_cpld_wait_ready(bp, 100) in the page
loop) and SET_DONE waits need the same treatment, i.e. tolerating a
pre-existing FAILED and testing it only after the operation completes?
That is what the cited machxo2_write_init() in drivers/fpga/machxo2-spi.c
does - it issues ISC_ENABLE and ISC_ERASE, waits with
wait_until_not_busy(), and only then tests FAIL:

	ret = wait_until_not_busy(spi);
	if (ret)
		goto fail;

	get_status(spi, &status);
	if (test_bit(FAIL, &status)) {

The alternative reading, that the part clears FAILED at the start of each
new ISC operation, would make the enable wait harmless either way, but it
also contradicts the "FAILED is latched across operations and nothing in
the driver clears it" premise the commit message and the new comment are
built on.  Which of the two describes the hardware?

Checking the rest of the series, the ERASE wait is unchanged through
5b9611f9 ("ptp: ocp: confirm the CPLD really left configuration mode after
REFRESH"), so this does not appear to be addressed by a later patch.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20260922142829.57740-1-maimon.sagi%40gmail.com

  reply	other threads:[~2026-09-24 14:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 14:28 [PATCH net-next 0/9] ptp: ocp: TAP CPLD follow-up fixes Sagi Maimon
2026-09-22 14:28 ` [PATCH net-next 1/9] ptp: ocp: move the CPLD identification read off the sync worker Sagi Maimon
2026-09-24 14:29   ` netdev-bot+sashiko
2026-09-22 14:28 ` [PATCH net-next 2/9] ptp: ocp: do not cache EEPROM content after a failed TMC bus hand-back Sagi Maimon
2026-09-24 14:29   ` netdev-bot+sashiko
2026-09-22 14:28 ` [PATCH net-next 3/9] ptp: ocp: hand the TMC bus back once on an acquire timeout Sagi Maimon
2026-09-24 14:29   ` netdev-bot+sashiko
2026-09-22 14:28 ` [PATCH net-next 4/9] ptp: ocp: forget a CPLD i2c adapter number that no longer resolves Sagi Maimon
2026-09-24 14:29   ` netdev-bot+sashiko
2026-09-22 14:28 ` [PATCH net-next 5/9] ptp: ocp: correct the CPLD bookkeeping comments and the flash progress Sagi Maimon
2026-09-24 14:29   ` netdev-bot+sashiko
2026-09-22 14:28 ` [PATCH net-next 6/9] ptp: ocp: report fw.cpld with an empty value until the USERCODE is read Sagi Maimon
2026-09-24 14:29   ` netdev-bot+sashiko
2026-09-22 14:28 ` [PATCH net-next 7/9] ptp: ocp: drop only the USERCODE when flashing, and drop it before erasing Sagi Maimon
2026-09-24 14:29   ` netdev-bot+sashiko
2026-09-22 14:28 ` [PATCH net-next 8/9] ptp: ocp: tolerate a latched FAILED when entering configuration mode Sagi Maimon
2026-09-24 14:29   ` netdev-bot+sashiko [this message]
2026-09-22 14:28 ` [PATCH net-next 9/9] ptp: ocp: confirm the CPLD really left configuration mode after REFRESH Sagi Maimon
2026-09-24 14:29   ` netdev-bot+sashiko

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=179026017305.2160803.11471616461860982077@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=arkadiusz.kubalewski@intel.com \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maimon.sagi@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=rdunlap@infradead.org \
    --cc=richardcochran@gmail.com \
    --cc=skhan@linuxfoundation.org \
    --cc=vadim.fedorenko@linux.dev \
    /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

all inboxes | Powered by JetHome®