public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: Bart Van Assche <bvanassche@acm.org>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: Jaegeuk Kim <jaegeuk@kernel.org>,
	linux-scsi@vger.kernel.org,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	Bean Huo <beanhuo@micron.com>, Avri Altman <avri.altman@wdc.com>,
	Jinyoung Choi <j-young.choi@samsung.com>
Subject: Re: [PATCH v2] scsi: ufs: Fix the polling implementation
Date: Mon, 21 Nov 2022 15:48:51 +0200	[thread overview]
Message-ID: <298fc637-cf7f-28ba-9e88-6e26cdb45f69@intel.com> (raw)
In-Reply-To: <20221118233717.441298-1-bvanassche@acm.org>

On 19/11/22 01:37, Bart Van Assche wrote:
> Fix the following issues in ufshcd_poll():
> - If polling succeeds, return a positive value.
> - Do not complete polling requests from interrupt context because the
>   block layer expects these requests to be completed from thread
>   context. From block/bio.c:
> 
>     If REQ_ALLOC_CACHE is set, the final put of the bio MUST be done
>     from process context, not hard/soft IRQ.
> 
> Fixes: eaab9b573054 ("scsi: ufs: Implement polling support")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>

Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
> 
> Changes compared to v1:
> - Made sure that polled requests are not completed from interrupt context.
> 
>  drivers/ufs/core/ufshcd.c | 28 ++++++++++++++++++++++++++--
>  1 file changed, 26 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index 768cb49d269c..b4bf3c3bef0c 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -5344,6 +5344,26 @@ static void __ufshcd_transfer_req_compl(struct ufs_hba *hba,
>  	}
>  }
>  
> +/* Any value that is not an existing queue number is fine for this constant. */
> +enum {
> +	UFSHCD_POLL_FROM_INTERRUPT_CONTEXT = -1
> +};
> +
> +static void ufshcd_clear_polled(struct ufs_hba *hba,
> +				unsigned long *completed_reqs)
> +{
> +	int tag;
> +
> +	for_each_set_bit(tag, completed_reqs, hba->nutrs) {
> +		struct scsi_cmnd *cmd = hba->lrb[tag].cmd;
> +
> +		if (!cmd)
> +			continue;
> +		if (scsi_cmd_to_rq(cmd)->cmd_flags & REQ_POLLED)
> +			__clear_bit(tag, completed_reqs);
> +	}
> +}
> +
>  /*
>   * Returns > 0 if one or more commands have been completed or 0 if no
>   * requests have been completed.
> @@ -5360,13 +5380,17 @@ static int ufshcd_poll(struct Scsi_Host *shost, unsigned int queue_num)
>  	WARN_ONCE(completed_reqs & ~hba->outstanding_reqs,
>  		  "completed: %#lx; outstanding: %#lx\n", completed_reqs,
>  		  hba->outstanding_reqs);
> +	if (queue_num == UFSHCD_POLL_FROM_INTERRUPT_CONTEXT) {
> +		/* Do not complete polled requests from interrupt context. */
> +		ufshcd_clear_polled(hba, &completed_reqs);
> +	}
>  	hba->outstanding_reqs &= ~completed_reqs;
>  	spin_unlock_irqrestore(&hba->outstanding_lock, flags);
>  
>  	if (completed_reqs)
>  		__ufshcd_transfer_req_compl(hba, completed_reqs);
>  
> -	return completed_reqs;
> +	return completed_reqs != 0;
>  }
>  
>  /**
> @@ -5397,7 +5421,7 @@ static irqreturn_t ufshcd_transfer_req_compl(struct ufs_hba *hba)
>  	 * Ignore the ufshcd_poll() return value and return IRQ_HANDLED since we
>  	 * do not want polling to trigger spurious interrupt complaints.
>  	 */
> -	ufshcd_poll(hba->host, 0);
> +	ufshcd_poll(hba->host, UFSHCD_POLL_FROM_INTERRUPT_CONTEXT);
>  
>  	return IRQ_HANDLED;
>  }


  reply	other threads:[~2022-11-21 13:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18 23:37 [PATCH v2] scsi: ufs: Fix the polling implementation Bart Van Assche
2022-11-21 13:48 ` Adrian Hunter [this message]
2022-11-26  2:31 ` Martin K. Petersen
2022-12-01  3:45 ` Martin K. Petersen

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=298fc637-cf7f-28ba-9e88-6e26cdb45f69@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=j-young.choi@samsung.com \
    --cc=jaegeuk@kernel.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.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