mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xu Yilun <yilun.xu@linux.intel.com>
To: Adrian Ng Ho Yin <adrian.ho.yin.ng@altera.com>
Cc: Moritz Fischer <mdf@kernel.org>, Xu Yilun <yilun.xu@intel.com>,
	Tom Rix <trix@redhat.com>,
	linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] fpga: stratix10-soc: prefer ERROR over BUFFER_DONE
Date: Mon, 28 Sep 2026 19:59:22 +0800	[thread overview]
Message-ID: <arpWmvYkDRBIqpif@yilunxu-OptiPlex-7050> (raw)
In-Reply-To: <77007ef350addaec2d9a9e3bfe90f4c303281893.1790090287.git.adrian.ho.yin.ng@altera.com>

On Wed, Sep 23, 2026 at 12:02:42AM +0800, Adrian Ng Ho Yin wrote:
> Check SVC_STATUS_ERROR before BUFFER_DONE so a combined
> BUFFER_DONE | ERROR callback aborts instead of being treated as success.
> Clear priv->status at the start of write_init so stale bits cannot leak
> into the next reconfiguration.

There is also a COMPLETED | ERROR combination, does it need the same
handling?

> 
> Signed-off-by: Adrian Ng Ho Yin <adrian.ho.yin.ng@altera.com>
> ---
>  drivers/fpga/stratix10-soc.c | 16 ++++++++++------
>  1 file changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/fpga/stratix10-soc.c b/drivers/fpga/stratix10-soc.c
> index 3ba0ffa1d9e0..c16ed571630b 100644
> --- a/drivers/fpga/stratix10-soc.c
> +++ b/drivers/fpga/stratix10-soc.c
> @@ -183,6 +183,9 @@ static int s10_ops_write_init(struct fpga_manager *mgr,
>  	uint i;
>  	int ret;
>  
> +	/* Drop stale status bits left by a previous aborted write. */
> +	priv->status = 0;
> +
>  	ctype.flags = 0;
>  	if (info->flags & FPGA_MGR_PARTIAL_RECONFIG) {
>  		dev_dbg(dev, "Requesting partial reconfiguration.\n");
> @@ -319,6 +322,13 @@ static int s10_ops_write(struct fpga_manager *mgr, const char *buf,
>  		wait_status = wait_for_completion_timeout(
>  			&priv->status_return_completion, S10_BUFFER_TIMEOUT);
>  
> +		/* ERROR must win over BUFFER_DONE when both are set. */
> +		if (test_and_clear_bit(SVC_STATUS_ERROR, &priv->status)) {
> +			dev_err(dev, "ERROR - giving up - SVC_STATUS_ERROR\n");
> +			ret = -EFAULT;
> +			break;
> +		}
> +
>  		if (test_and_clear_bit(SVC_STATUS_BUFFER_DONE, &priv->status) ||
>  		    test_and_clear_bit(SVC_STATUS_BUFFER_SUBMITTED,
>  				       &priv->status)) {
> @@ -326,12 +336,6 @@ static int s10_ops_write(struct fpga_manager *mgr, const char *buf,
>  			continue;
>  		}
>  
> -		if (test_and_clear_bit(SVC_STATUS_ERROR, &priv->status)) {
> -			dev_err(dev, "ERROR - giving up - SVC_STATUS_ERROR\n");
> -			ret = -EFAULT;
> -			break;
> -		}
> -

I think these command handlings in this series are much of the same
style:

 - init a completion
 - send command
 - wait_for_completion_timeout
 - check error status
 - check successful status
 - stratix10_svc_done

Now they are really a mess, hardly reviewable. Is it possible we make a
helper to regulate them?

>  		if (!wait_status) {
>  			dev_err(dev, "timeout waiting for svc layer buffers\n");
>  			ret = -ETIMEDOUT;
> -- 
> 2.49.GIT
> 
> 

  reply	other threads:[~2026-09-28 12:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 16:02 [PATCH 0/3] fpga: stratix10-soc: harden wait, ERROR order, and timeout Adrian Ng Ho Yin
2026-09-22 16:02 ` [PATCH 1/3] fpga: stratix10-soc: always wait for svc buffer completion Adrian Ng Ho Yin
2026-09-22 16:02 ` [PATCH 2/3] fpga: stratix10-soc: prefer ERROR over BUFFER_DONE Adrian Ng Ho Yin
2026-09-28 11:59   ` Xu Yilun [this message]
2026-09-22 16:02 ` [PATCH 3/3] fpga: stratix10-soc: floor config_complete_timeout_us Adrian Ng Ho Yin
2026-09-28 12:14   ` Xu Yilun
2026-10-20  7:49 ` [PATCH v3 0/3] fpga: stratix10-soc: harden wait, ERROR order, and timeout Adrian Ng Ho Yin
2026-10-20  7:49   ` [PATCH v3 1/3] fpga: stratix10-soc: always wait for svc buffer completion Adrian Ng Ho Yin
2026-10-20  7:49   ` [PATCH v3 2/3] fpga: stratix10-soc: use config_complete_timeout_us as a deadline Adrian Ng Ho Yin
2026-10-20  7:49   ` [PATCH v3 3/3] fpga: stratix10-soc: add SVC wait helper and prefer ERROR Adrian Ng Ho Yin

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=arpWmvYkDRBIqpif@yilunxu-OptiPlex-7050 \
    --to=yilun.xu@linux.intel.com \
    --cc=adrian.ho.yin.ng@altera.com \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdf@kernel.org \
    --cc=trix@redhat.com \
    --cc=yilun.xu@intel.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

all inboxes | Powered by JetHome®