Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@intel.com>
To: "Bao D. Nguyen" <quic_nguyenb@quicinc.com>,
	quic_asutoshd@quicinc.com, quic_cang@quicinc.com,
	bvanassche@acm.org, mani@kernel.org, stanley.chu@mediatek.com,
	beanhuo@micron.com, avri.altman@wdc.com,
	martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, Alim Akhtar <alim.akhtar@samsung.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	Arthur Simchaev <Arthur.Simchaev@wdc.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH v2 1/3] ufs: mcq: Add supporting functions for mcq abort
Date: Thu, 9 Mar 2023 07:58:42 +0200	[thread overview]
Message-ID: <16dd4f27-aee6-97ee-ed20-87c0523c247d@intel.com> (raw)
In-Reply-To: <68b786f390dbd93218a482d18c513bc332e82da3.1678338926.git.quic_nguyenb@quicinc.com>

On 9/03/23 07:28, Bao D. Nguyen wrote:
> Add supporting functions to handle ufs abort in mcq mode.
> 
> Signed-off-by: Bao D. Nguyen <quic_nguyenb@quicinc.com>
> ---
>  drivers/ufs/core/ufs-mcq.c     | 181 +++++++++++++++++++++++++++++++++++++++++
>  drivers/ufs/core/ufshcd-priv.h |  14 ++++
>  drivers/ufs/core/ufshcd.c      |   3 +-
>  include/ufs/ufshcd.h           |   1 +
>  include/ufs/ufshci.h           |  16 ++++
>  5 files changed, 214 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
> index 31df052..4c33c1a 100644
> --- a/drivers/ufs/core/ufs-mcq.c
> +++ b/drivers/ufs/core/ufs-mcq.c
> @@ -12,6 +12,9 @@
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
>  #include "ufshcd-priv.h"
> +#include <linux/delay.h>
> +#include <scsi/scsi_cmnd.h>
> +#include <linux/bitfield.h>
>  
>  #define MAX_QUEUE_SUP GENMASK(7, 0)
>  #define UFS_MCQ_MIN_RW_QUEUES 2
> @@ -27,6 +30,9 @@
>  #define MCQ_ENTRY_SIZE_IN_DWORD	8
>  #define CQE_UCD_BA GENMASK_ULL(63, 7)
>  
> +/* Max mcq register polling time in millisecond unit */
> +#define MCQ_POLL_MS 500
> +
>  static int rw_queue_count_set(const char *val, const struct kernel_param *kp)
>  {
>  	return param_set_uint_minmax(val, kp, UFS_MCQ_MIN_RW_QUEUES,
> @@ -429,3 +435,178 @@ int ufshcd_mcq_init(struct ufs_hba *hba)
>  	host->host_tagset = 1;
>  	return 0;
>  }
> +
> +static int ufshcd_mcq_poll_register(void __iomem *reg, u32 mask,
> +			u32 val, unsigned long timeout_ms)
> +{
> +	unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms);
> +	int err = 0;
> +
> +	/* ignore bits that we don't intend to wait on */
> +	val = val & mask;
> +
> +	while ((readl(reg) & mask) != val) {
> +		usleep_range(10, 50);
> +		if (time_after(jiffies, timeout)) {
> +			err = -ETIMEDOUT;
> +			break;
> +		}
> +	}

Should be able to use a macro from include/linux/iopoll.h
here

> +
> +	return err;
> +}



  reply	other threads:[~2023-03-09  5:58 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-09  5:28 [RFC PATCH v2 0/3] ufs: core: mcq: Add ufshcd_abort() support in MCQ mode Bao D. Nguyen
2023-03-09  5:28 ` [RFC PATCH v2 1/3] ufs: mcq: Add supporting functions for mcq abort Bao D. Nguyen
2023-03-09  5:58   ` Adrian Hunter [this message]
2023-03-09 18:15   ` Bart Van Assche
2023-03-09 22:47     ` Bao D. Nguyen
2023-03-09 22:54       ` Bart Van Assche
2023-03-09 22:56         ` Bao D. Nguyen
2023-03-09  5:28 ` [RFC PATCH v2 2/3] ufs: mcq: Add support for clean up mcq resources Bao D. Nguyen
2023-03-09  5:28 ` [RFC PATCH v2 3/3] ufs: mcq: Added ufshcd_mcq_abort() Bao D. Nguyen

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=16dd4f27-aee6-97ee-ed20-87c0523c247d@intel.com \
    --to=adrian.hunter@intel.com \
    --cc=Arthur.Simchaev@wdc.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=quic_asutoshd@quicinc.com \
    --cc=quic_cang@quicinc.com \
    --cc=quic_nguyenb@quicinc.com \
    --cc=stanley.chu@mediatek.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