[v3,03/17] ufs: core: Introduce Multi-circular queue capability

Message ID 1718196085461c37138c194c49146efa5c5503dc.1666288432.git.quic_asutoshd@quicinc.com
State New
Headers
Series [v3,01/17] ufs: core: Probe for ext_iid support |

Commit Message

Asutosh Das Oct. 20, 2022, 6:03 p.m. UTC
  Add support to check for MCQ capability in the UFSHC.
This capability can be used by host drivers to control
MCQ enablement.

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>
---
 drivers/ufs/core/ufshcd.c |  4 ++++
 include/ufs/ufshcd.h      | 13 +++++++++++++
 2 files changed, 17 insertions(+)
  

Comments

Bart Van Assche Oct. 27, 2022, 9:09 p.m. UTC | #1
On 10/20/22 11:03, Asutosh Das wrote:
> +
> +	/*
> +	 * This capability allows the host controller driver to turn on/off
> +	 * MCQ mode. MCQ mode may be used to increase performance.
> +	 */
> +	UFSHCD_CAP_MCQ_EN				= 1 << 12,
>   };

I prefer that the above flag would only be introduced after a need 
appears to disable MCQ, e.g. discovery of a host controller that is too 
broken to enable MCQ.

Since UFSHCI 4.0 controllers must support UFSHCI 3.0, shouldn't users 
have a way to disable MCQ, e.g. via a kernel module parameter?

Thanks,

Bart.
  
Asutosh Das Oct. 28, 2022, 4:51 p.m. UTC | #2
On Thu, Oct 27 2022 at 14:10 -0700, Bart Van Assche wrote:
>On 10/20/22 11:03, Asutosh Das wrote:
>>+
>>+	/*
>>+	 * This capability allows the host controller driver to turn on/off
>>+	 * MCQ mode. MCQ mode may be used to increase performance.
>>+	 */
>>+	UFSHCD_CAP_MCQ_EN				= 1 << 12,
>>  };
>
>I prefer that the above flag would only be introduced after a need 
>appears to disable MCQ, e.g. discovery of a host controller that is 
>too broken to enable MCQ.
>
I think this flag is useful during chip bring-ups &/or debugs.
Considering that this is a fairly new hardware block even though the HC supports
MCQ there could be times to keep it disabled.

>Since UFSHCI 4.0 controllers must support UFSHCI 3.0, shouldn't users 
>have a way to disable MCQ, e.g. via a kernel module parameter?
>
I can add a kernel module parameter to disable MCQ.
I think adding it to host driver (e.g. ufs-qcom) would be good.
Please let me know if you have a better place in mind.

>Thanks,
>
>Bart.
  
Bart Van Assche Oct. 28, 2022, 9:44 p.m. UTC | #3
On 10/28/22 09:51, Asutosh Das wrote:
> On Thu, Oct 27 2022 at 14:10 -0700, Bart Van Assche wrote:
>> Since UFSHCI 4.0 controllers must support UFSHCI 3.0, shouldn't users 
>> have a way to disable MCQ, e.g. via a kernel module parameter?
>>
> I can add a kernel module parameter to disable MCQ.
> I think adding it to host driver (e.g. ufs-qcom) would be good.
> Please let me know if you have a better place in mind.

Since this functionality is useful for all host controllers please add 
it in the core UFS host controller driver (drivers/ufs/core/ufshcd.c).

Thanks,

Bart.
  
Avri Altman Oct. 30, 2022, 12:11 p.m. UTC | #4
> 
> On 10/20/22 11:03, Asutosh Das wrote:
> > +
> > +     /*
> > +      * This capability allows the host controller driver to turn on/off
> > +      * MCQ mode. MCQ mode may be used to increase performance.
> > +      */
> > +     UFSHCD_CAP_MCQ_EN                               = 1 << 12,
Needs rebase?
UFSHCD_CAP_WB_WITH_CLK_SCALING already occupies that bit.

Thanks,
Avri

> >   };
> 
> I prefer that the above flag would only be introduced after a need
> appears to disable MCQ, e.g. discovery of a host controller that is too
> broken to enable MCQ.
> 
> Since UFSHCI 4.0 controllers must support UFSHCI 3.0, shouldn't users
> have a way to disable MCQ, e.g. via a kernel module parameter?
> 
> Thanks,
> 
> Bart.
  

Patch

diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index e2be3f4..8d93797 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -2250,6 +2250,10 @@  static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
 	if (err)
 		dev_err(hba->dev, "crypto setup failed\n");
 
+	hba->mcq_sup = FIELD_GET(MASK_MCQ_SUPPORT, hba->capabilities);
+	if (!hba->mcq_sup)
+		return err;
+
 	hba->mcq_capabilities = ufshcd_readl(hba, REG_MCQCAP);
 	hba->ext_iid_sup = FIELD_GET(MASK_EXT_IID_SUPPORT,
 				     hba->mcq_capabilities);
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index c29f4c8..e779bc6 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -660,6 +660,12 @@  enum ufshcd_caps {
 	 * notification if it is supported by the UFS device.
 	 */
 	UFSHCD_CAP_TEMP_NOTIF				= 1 << 11,
+
+	/*
+	 * This capability allows the host controller driver to turn on/off
+	 * MCQ mode. MCQ mode may be used to increase performance.
+	 */
+	UFSHCD_CAP_MCQ_EN				= 1 << 12,
 };
 
 struct ufs_hba_variant_params {
@@ -820,6 +826,7 @@  struct ufs_hba_monitor {
  * @complete_put: whether or not to call ufshcd_rpm_put() from inside
  *	ufshcd_resume_complete()
  * @ext_iid_sup: is EXT_IID is supported by UFSHC
+ * @mcq_sup: is mcq supported by UFSHC
  */
 struct ufs_hba {
 	void __iomem *mmio_base;
@@ -969,8 +976,14 @@  struct ufs_hba {
 	u32 luns_avail;
 	bool complete_put;
 	bool ext_iid_sup;
+	bool mcq_sup;
 };
 
+static inline bool is_mcq_supported(struct ufs_hba *hba)
+{
+	return hba->mcq_sup && (hba->caps & UFSHCD_CAP_MCQ_EN);
+}
+
 /* Returns true if clocks can be gated. Otherwise false */
 static inline bool ufshcd_is_clkgating_allowed(struct ufs_hba *hba)
 {