linux-arm-msm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Manivannan Sadhasivam <mani@kernel.org>
To: Asutosh Das <quic_asutoshd@quicinc.com>
Cc: quic_cang@quicinc.com, martin.petersen@oracle.com,
	linux-scsi@vger.kernel.org, quic_nguyenb@quicinc.com,
	quic_xiaosenh@quicinc.com, stanley.chu@mediatek.com,
	eddie.huang@mediatek.com, daejun7.park@samsung.com,
	bvanassche@acm.org, avri.altman@wdc.com, beanhuo@micron.com,
	linux-arm-msm@vger.kernel.org,
	Alim Akhtar <alim.akhtar@samsung.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	Andy Gross <agross@kernel.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Konrad Dybcio <konrad.dybcio@somainline.org>,
	Jinyoung Choi <j-young.choi@samsung.com>,
	Arthur Simchaev <Arthur.Simchaev@wdc.com>,
	Kiwoong Kim <kwmad.kim@samsung.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 14/16] ufs: mcq: Add completion support of a cqe
Date: Mon, 28 Nov 2022 22:30:15 +0530	[thread overview]
Message-ID: <20221128170015.GM62721@thinkpad> (raw)
In-Reply-To: <32219cb9b058d7329ad8234a8a287701af1a0e34.1669176158.git.quic_asutoshd@quicinc.com>

On Tue, Nov 22, 2022 at 08:10:27PM -0800, Asutosh Das wrote:
> Add support for completing requests from Completion Queue.
> Some host controllers support vendor specific registers
> that provide a bitmap of all CQ's which have at least one
> completed CQE. Add this support.
> The MCQ specification doesn't provide the Task Tag or its
> equivalent in the Completion Queue Entry.
> So use an indirect method to find the Task Tag from the
> Completion Queue Entry.
> 
> Co-developed-by: Can Guo <quic_cang@quicinc.com>
> Signed-off-by: Can Guo <quic_cang@quicinc.com>
> Signed-off-by: Asutosh Das <quic_asutoshd@quicinc.com>
> Reported-by: kernel test robot <lkp@intel.com>

What is this reported by for?

> Reviewed-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/ufs/core/ufs-mcq.c     | 57 ++++++++++++++++++++++++++++++++++++++++++
>  drivers/ufs/core/ufshcd-priv.h | 43 +++++++++++++++++++++++++++++++
>  drivers/ufs/core/ufshcd.c      | 37 +++++++++++++++++++++++++++
>  drivers/ufs/host/ufs-qcom.c    | 16 ++++++++++++
>  drivers/ufs/host/ufs-qcom.h    |  4 +++
>  include/ufs/ufshcd.h           |  7 ++++++
>  include/ufs/ufshci.h           |  3 +++
>  7 files changed, 167 insertions(+)
> 
> diff --git a/drivers/ufs/core/ufs-mcq.c b/drivers/ufs/core/ufs-mcq.c
> index 10a0d0d7..365ad98 100644
> --- a/drivers/ufs/core/ufs-mcq.c
> +++ b/drivers/ufs/core/ufs-mcq.c
> @@ -28,6 +28,7 @@
>  	((((c) >> 16) & MCQ_QCFGPTR_MASK) * MCQ_QCFGPTR_UNIT)
>  #define MCQ_QCFG_SIZE	0x40
>  #define MCQ_ENTRY_SIZE_IN_DWORD	8
> +#define CQE_UCD_BA GENMASK_ULL(63, 7)
>  
>  static int rw_queue_count_set(const char *val, const struct kernel_param *kp)
>  {
> @@ -333,6 +334,59 @@ static void __iomem *mcq_opr_base(struct ufs_hba *hba,
>  	return opr->base + opr->stride * i;
>  }
>  
> +u32 ufshcd_mcq_read_cqis(struct ufs_hba *hba, int i)
> +{
> +	return readl(mcq_opr_base(hba, OPR_CQIS, i) + REG_CQIS);
> +}
> +
> +void ufshcd_mcq_write_cqis(struct ufs_hba *hba, u32 val, int i)
> +{
> +	writel(val, mcq_opr_base(hba, OPR_CQIS, i) + REG_CQIS);
> +}
> +

It'd be good to add a comment about tag extraction as you did in description.

> +static int ufshcd_mcq_get_tag(struct ufs_hba *hba,
> +				     struct ufs_hw_queue *hwq,
> +				     struct cq_entry *cqe)
> +{
> +	dma_addr_t dma_addr;
> +
> +	/* sizeof(struct utp_transfer_cmd_desc) must be a multiple of 128 */
> +	BUILD_BUG_ON(sizeof(struct utp_transfer_cmd_desc) & GENMASK(6, 0));
> +
> +	/* Bits 63:7 UCD base address, 6:5 are reserved, 4:0 is SQ ID */
> +	dma_addr = le64_to_cpu(cqe->command_desc_base_addr) & CQE_UCD_BA;
> +
> +	return (dma_addr - hba->ucdl_dma_addr) /
> +		sizeof(struct utp_transfer_cmd_desc);
> +}
> +

[...]

> diff --git a/drivers/ufs/host/ufs-qcom.c b/drivers/ufs/host/ufs-qcom.c
> index dd53e85..89d29a1 100644
> --- a/drivers/ufs/host/ufs-qcom.c
> +++ b/drivers/ufs/host/ufs-qcom.c
> @@ -1454,6 +1454,21 @@ static int ufs_qcom_get_hba_mac(struct ufs_hba *hba)
>  	return MAX_SUPP_MAC;
>  }
>  
> +static int ufs_qcom_get_outstanding_cqs(struct ufs_hba *hba,
> +					unsigned long *ocqs)
> +{
> +	u32 cqis_vs;
> +	struct ufshcd_res_info *mcq_vs_res = &hba->res[RES_MCQ_VS];
> +
> +	if (!mcq_vs_res->base)
> +		return -EINVAL;
> +
> +	cqis_vs = readl(mcq_vs_res->base + UFS_MEM_CQIS_VS);
> +	*ocqs = cqis_vs;

Why can't you assign readl to *ocqs?

Thanks,
Mani
> +
> +	return 0;
> +}
> +
>  /*
>   * struct ufs_hba_qcom_vops - UFS QCOM specific variant operations
>   *
> @@ -1479,6 +1494,7 @@ static const struct ufs_hba_variant_ops ufs_hba_qcom_vops = {
>  	.program_key		= ufs_qcom_ice_program_key,
>  	.get_hba_mac		= ufs_qcom_get_hba_mac,
>  	.op_runtime_config	= ufs_qcom_op_runtime_config,
> +	.get_outstanding_cqs	= ufs_qcom_get_outstanding_cqs,
>  };
>  
>  /**
> diff --git a/drivers/ufs/host/ufs-qcom.h b/drivers/ufs/host/ufs-qcom.h
> index 44466a3..7769f03 100644
> --- a/drivers/ufs/host/ufs-qcom.h
> +++ b/drivers/ufs/host/ufs-qcom.h
> @@ -72,6 +72,10 @@ enum {
>  	UFS_UFS_DBG_RD_EDTL_RAM			= 0x1900,
>  };
>  
> +enum {
> +	UFS_MEM_CQIS_VS		= 0x8,
> +};
> +
>  #define UFS_CNTLR_2_x_x_VEN_REGS_OFFSET(x)	(0x000 + x)
>  #define UFS_CNTLR_3_x_x_VEN_REGS_OFFSET(x)	(0x400 + x)
>  
> diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
> index 853c525..d5fde64 100644
> --- a/include/ufs/ufshcd.h
> +++ b/include/ufs/ufshcd.h
> @@ -300,6 +300,7 @@ struct ufs_pwr_mode_info {
>   * @event_notify: called to notify important events
>   * @get_hba_mac: called to get vendor specific mac value, mandatory for mcq mode
>   * @op_runtime_config: called to config Operation and runtime regs Pointers
> + * @get_outstanding_cqs: called to get outstanding completion queues
>   */
>  struct ufs_hba_variant_ops {
>  	const char *name;
> @@ -340,6 +341,8 @@ struct ufs_hba_variant_ops {
>  				enum ufs_event_type evt, void *data);
>  	int	(*get_hba_mac)(struct ufs_hba *hba);
>  	int	(*op_runtime_config)(struct ufs_hba *hba);
> +	int	(*get_outstanding_cqs)(struct ufs_hba *hba,
> +				       unsigned long *ocqs);
>  };
>  
>  /* clock gating state  */
> @@ -1064,6 +1067,8 @@ struct ufs_hba {
>   * @id: hardware queue ID
>   * @sq_tp_slot: current slot to which SQ tail pointer is pointing
>   * @sq_lock: serialize submission queue access
> + * @cq_tail_slot: current slot to which CQ tail pointer is pointing
> + * @cq_head_slot: current slot to which CQ head pointer is pointing
>   */
>  struct ufs_hw_queue {
>  	void __iomem *mcq_sq_head;
> @@ -1079,6 +1084,8 @@ struct ufs_hw_queue {
>  	u32 id;
>  	u32 sq_tail_slot;
>  	spinlock_t sq_lock;
> +	u32 cq_tail_slot;
> +	u32 cq_head_slot;
>  };
>  
>  static inline bool is_mcq_enabled(struct ufs_hba *hba)
> diff --git a/include/ufs/ufshci.h b/include/ufs/ufshci.h
> index c85bdf2..1e557ba 100644
> --- a/include/ufs/ufshci.h
> +++ b/include/ufs/ufshci.h
> @@ -262,6 +262,9 @@ enum {
>  /* UTMRLRSR - UTP Task Management Request Run-Stop Register 80h */
>  #define UTP_TASK_REQ_LIST_RUN_STOP_BIT		0x1
>  
> +/* CQISy - CQ y Interrupt Status Register  */
> +#define UFSHCD_MCQ_CQIS_TAIL_ENT_PUSH_STS	0x1
> +
>  /* UICCMD - UIC Command */
>  #define COMMAND_OPCODE_MASK		0xFF
>  #define GEN_SELECTOR_INDEX_MASK		0xFFFF
> -- 
> 2.7.4
> 

-- 
மணிவண்ணன் சதாசிவம்

  reply	other threads:[~2022-11-28 17:00 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23  4:10 [PATCH v5 00/16] Add Multi Circular Queue Support Asutosh Das
2022-11-23  4:10 ` [PATCH v5 01/16] ufs: core: Optimize duplicate code to read extended feature Asutosh Das
2022-11-28 12:20   ` Manivannan Sadhasivam
2022-11-23  4:10 ` [PATCH v5 02/16] ufs: core: Probe for ext_iid support Asutosh Das
2022-11-28 12:53   ` Manivannan Sadhasivam
2022-11-23  4:10 ` [PATCH v5 03/16] ufs: core: Introduce Multi-circular queue capability Asutosh Das
2022-11-26  0:20   ` Bart Van Assche
2022-11-28 14:29   ` Manivannan Sadhasivam
2022-11-23  4:10 ` [PATCH v5 04/16] ufs: core: Defer adding host to scsi if mcq is supported Asutosh Das
2022-11-26  0:28   ` Bart Van Assche
2022-11-28 14:42   ` Manivannan Sadhasivam
2022-11-28 17:50     ` Asutosh Das
2022-11-23  4:10 ` [PATCH v5 05/16] ufs: core: mcq: Add Multi Circular Queue support Asutosh Das
2022-11-26  0:52   ` Bart Van Assche
2022-11-28 14:53   ` Manivannan Sadhasivam
2022-11-23  4:10 ` [PATCH v5 06/16] ufs: core: mcq: Configure resource regions Asutosh Das
2022-11-26  1:10   ` Bart Van Assche
2022-11-23  4:10 ` [PATCH v5 07/16] ufs: core: mcq: Calculate queue depth Asutosh Das
2022-11-26  1:14   ` Bart Van Assche
2022-11-28 15:15   ` Manivannan Sadhasivam
2022-11-28 19:54     ` Asutosh Das
2022-11-28 20:33       ` Bart Van Assche
2022-11-23  4:10 ` [PATCH v5 08/16] ufs: core: mcq: Allocate memory for mcq mode Asutosh Das
2022-11-26  1:20   ` Bart Van Assche
2022-11-28 15:48   ` Manivannan Sadhasivam
2022-11-23  4:10 ` [PATCH v5 09/16] ufs: core: mcq: Configure operation and runtime interface Asutosh Das
2022-11-26  1:28   ` Bart Van Assche
2022-11-28 22:08     ` Asutosh Das
2022-11-28 22:50       ` Bart Van Assche
2022-11-28 15:55   ` Manivannan Sadhasivam
2022-11-23  4:10 ` [PATCH v5 10/16] ufs: core: mcq: Use shared tags for MCQ mode Asutosh Das
2022-11-28 15:59   ` Manivannan Sadhasivam
2022-11-23  4:10 ` [PATCH v5 11/16] ufs: core: Prepare ufshcd_send_command for mcq Asutosh Das
2022-11-28 16:05   ` Manivannan Sadhasivam
2022-11-23  4:10 ` [PATCH v5 12/16] ufs: core: mcq: Find hardware queue to queue request Asutosh Das
2022-11-28 16:08   ` Manivannan Sadhasivam
2022-11-23  4:10 ` [PATCH v5 13/16] ufs: core: Prepare for completion in mcq Asutosh Das
2022-11-28 16:11   ` Manivannan Sadhasivam
2022-11-23  4:10 ` [PATCH v5 14/16] ufs: mcq: Add completion support of a cqe Asutosh Das
2022-11-28 17:00   ` Manivannan Sadhasivam [this message]
2022-11-28 17:47     ` Bart Van Assche
2022-11-23  4:10 ` [PATCH v5 15/16] ufs: core: mcq: Add completion support in poll Asutosh Das
2022-11-28 17:02   ` Manivannan Sadhasivam
2022-11-23  4:10 ` [PATCH v5 16/16] ufs: core: mcq: Enable Multi Circular Queue Asutosh Das
2022-11-28 17:03   ` Manivannan Sadhasivam

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=20221128170015.GM62721@thinkpad \
    --to=mani@kernel.org \
    --cc=Arthur.Simchaev@wdc.com \
    --cc=agross@kernel.org \
    --cc=alim.akhtar@samsung.com \
    --cc=andersson@kernel.org \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=daejun7.park@samsung.com \
    --cc=eddie.huang@mediatek.com \
    --cc=j-young.choi@samsung.com \
    --cc=jejb@linux.ibm.com \
    --cc=konrad.dybcio@somainline.org \
    --cc=kwmad.kim@samsung.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=quic_asutoshd@quicinc.com \
    --cc=quic_cang@quicinc.com \
    --cc=quic_nguyenb@quicinc.com \
    --cc=quic_xiaosenh@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;
as well as URLs for NNTP newsgroup(s).