Linux-SCSI Archive mirror
 help / color / mirror / Atom feed
From: "Peter Wang (王信友)" <peter.wang@mediatek.com>
To: "hch@infradead.org" <hch@infradead.org>,
	"Avri.Altman@wdc.com" <Avri.Altman@wdc.com>
Cc: "beanhuo@micron.com" <beanhuo@micron.com>,
	"bvanassche@acm.org" <bvanassche@acm.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"martin.petersen@oracle.com" <martin.petersen@oracle.com>
Subject: Re: [PATCH v5 2/3] scsi: ufs: Allow platform vendors to set rtt
Date: Fri, 24 May 2024 06:06:49 +0000	[thread overview]
Message-ID: <0a57d6bab739d6a10584f2baba115d00dfc9c94c.camel@mediatek.com> (raw)
In-Reply-To: <Zk9Anwk1HEjUzSxc@infradead.org>

On Thu, 2024-05-23 at 06:11 -0700, hch@infradead.org wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  On Thu, May 23, 2024 at 01:09:25PM +0000, Avri Altman wrote:
> > > On Thu, May 23, 2024 at 03:58:25PM +0300, Avri Altman wrote:
> > > > Allow platform vendors to take precedence having their own rtt
> > > > negotiation mechanism.  This makes sense because the host
> controller's
> > > > nortt characteristic may vary among vendors.
> > > 
> > > Platform vendors have absolutelyt no business saying anything.
> > > 
> > > Fortunately that's not what you're actually doing, but I really
> don't understand
> > > your vendor fetish.
> > It was a specific request from MTK to allow override their host
> controller capabilities.
> 
> Then they need to submit a patch just like anyone who wants to
> improve
> Linux.  And not trick their NAND supplier into adding an unused hook…

Hi Arvi,

Could you help add below patch for mediatek?
With below mediatek patch, 
"Allow RTT negotiation" patch series will more complete and 
mediatek platform not affect by this patch series.

Thanks
Peter


diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-
mediatek.c
index c4f997196c57..f8725f3374f7 100644
--- a/drivers/ufs/host/ufs-mediatek.c
+++ b/drivers/ufs/host/ufs-mediatek.c
@@ -1777,6 +1777,32 @@ static int ufs_mtk_config_esi(struct ufs_hba
*hba)
        return ufs_mtk_config_mcq(hba, true);
 }
 
+static void ufs_mtk_set_rtt(struct ufs_hba *hba)
+{
+       struct ufs_dev_info *dev_info = &hba->dev_info;
+       u32 rtt = 0;
+       u32 dev_rtt = 0;
+
+       /* RTT override makes sense only for UFS-4.0 and above */
+       if (dev_info->wspecversion < 0x400)
+               return;
+
+       if (ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR,
+                                   QUERY_ATTR_IDN_MAX_NUM_OF_RTT, 0,
0, &dev_rtt)) {
+               dev_err(hba->dev, "failed reading bMaxNumOfRTT\n");
+               return;
+       }
+
+       /* override if not mediatek support */
+       if (dev_rtt == MTK_MAX_NUM_RTT)
+               return;
+
+       rtt = MTK_MAX_NUM_RTT;
+       if (ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_WRITE_ATTR,
+                                   QUERY_ATTR_IDN_MAX_NUM_OF_RTT, 0,
0, &rtt))
+               dev_err(hba->dev, "failed writing bMaxNumOfRTT\n");
+}
+
 /*
  * struct ufs_hba_mtk_vops - UFS MTK specific variant operations
  *
@@ -1805,6 +1831,7 @@ static const struct ufs_hba_variant_ops
ufs_hba_mtk_vops = {
        .op_runtime_config   = ufs_mtk_op_runtime_config,
        .mcq_config_resource = ufs_mtk_mcq_config_resource,
        .config_esi          = ufs_mtk_config_esi,
+       .set_rtt             = ufs_mtk_set_rtt,
 };
 
 /**
diff --git a/drivers/ufs/host/ufs-mediatek.h b/drivers/ufs/host/ufs-
mediatek.h
index 3ff17e95afab..05d76a6bd772 100644
--- a/drivers/ufs/host/ufs-mediatek.h
+++ b/drivers/ufs/host/ufs-mediatek.h
@@ -189,4 +189,7 @@ struct ufs_mtk_host {
 /* MTK delay of autosuspend: 500 ms */
 #define MTK_RPM_AUTOSUSPEND_DELAY_MS 500
 
+/* MTK RTT support number */
+#define MTK_MAX_NUM_RTT 2
+
 #endif /* !_UFS_MEDIATEK_H */


  reply	other threads:[~2024-05-24  6:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-23 12:58 [PATCH v5 0/3] scsi: ufs: Allow RTT negotiation Avri Altman
2024-05-23 12:58 ` [PATCH v5 1/3] " Avri Altman
2024-05-23 12:58 ` [PATCH v5 2/3] scsi: ufs: Allow platform vendors to set rtt Avri Altman
2024-05-23 13:03   ` Christoph Hellwig
2024-05-23 13:09     ` Avri Altman
2024-05-23 13:11       ` hch
2024-05-24  6:06         ` Peter Wang (王信友) [this message]
2024-05-24 13:56           ` Bart Van Assche
2024-05-25 14:55             ` Avri Altman
2024-05-23 12:58 ` [PATCH v5 3/3] scsi: ufs: sysfs: Make max_number_of_rtt read-write Avri Altman
2024-05-23 23:05   ` Bart Van Assche
2024-05-24  3:54     ` Avri Altman

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=0a57d6bab739d6a10584f2baba115d00dfc9c94c.camel@mediatek.com \
    --to=peter.wang@mediatek.com \
    --cc=Avri.Altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).