ufs: Add callback for vendor-specific RTT capability
Subsystems (4)
v3 cover ufs: Add callback for vendor-specific RTT capability
From: Ed Tsai <[email protected]>
The first patch adds the get_hba_nortt() callback to the UFS core layer, allowing vendor drivers to provide dynamic, platform-specific RTT capability handling.
The second patch implements this callback in the MediaTek UFS driver, distinguishing between legacy platforms (which require the RTT to be limited to 2) and newer MT6995 B0+ platforms (which can use the value from the capability register directly).
The third patch removes the max_num_rtt field from ufs_hba_variant_ops as it is now replaced by the get_hba_nortt() callback.
Changes in v3:
- Fix incomplete v2 that was sent prematurely - now properly removes max_num_rtt field in patch 3
Changes in v2:
- Keep max_num_rtt field in patch 1 to maintain bisectability
- Split removal of max_num_rtt into a separate patch (patch 3)
Ed Tsai (3):
ufs: core: Add get_hba_nortt callback for vendor-specific RTT
capability
ufs: mediatek: Implement get_hba_nortt callback for RTT capability
ufs: core: Remove max_num_rtt field from ufs_hba_variant_ops
drivers/ufs/core/ufshcd.c | 9 +++++---- drivers/ufs/host/ufs-mediatek.c | 12 +++++++++++- drivers/ufs/host/ufs-mediatek.h | 4 ++-- include/ufs/ufshcd.h | 5 +++-- 4 files changed, 21 insertions(+), 9 deletions(-)
Signature · 1 line
2.45.2
PATCH v3 1/3 ufs: core: Add get_hba_nortt callback for vendor-specific RTT capability
From: Ed Tsai <[email protected]>
The number of outstanding RTTs read from host controller capability register is problematic on some platforms. Add a new vendor callback get_hba_nortt() to allow platform vendors to override the default RTT capability value with platform-specific handling.
This patch keeps max_num_rtt field for bisectability and will be removed in a later patch once all platforms are migrated.
--- drivers/ufs/core/ufshcd.c | 5 ++++- include/ufs/ufshcd.h | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-)
drivers/ufs/core/ufshcd.c +4 -1
@@ -2529,7 +2529,10 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba) hba->nutmrs = ((hba->capabilities &MASK_TASK_MANAGEMENT_REQUEST_SLOTS ) >>16 ) +1 ; - hba->nortt =FIELD_GET (MASK_NUMBER_OUTSTANDING_RTT , hba->capabilities) +1 ; +if (hba->vops && hba->vops->get_hba_nortt) + hba->nortt = hba->vops->get_hba_nortt (hba); +else + hba->nortt =FIELD_GET (MASK_NUMBER_OUTSTANDING_RTT , hba->capabilities) +1 ;/* Read crypto capabilities */ err =ufshcd_hba_init_crypto_capabilities (hba);
include/ufs/ufshcd.h +3 -0
@@ -415,6 +415,8 @@ struct ufshcd_tx_eq_params {* @get_rx_fom: called to get Figure of Merit (FOM) value. * @tx_eqtr_notify: called before and after TX Equalization Training procedure * to allow platform vendor specific configs to take place. +* @get_hba_nortt: called to get maximum number of outstanding RTTs supported by +* the controller. */ struct ufs_hba_variant_ops {const char *name;
@@ -477,6 +479,7 @@ struct ufs_hba_variant_ops {int (*tx_eqtr_notify)(struct ufs_hba *hba,enum ufs_notify_change_status status,struct ufs_pa_layer_attr *pwr_mode); +int (*get_hba_nortt)(struct ufs_hba *hba); };/* clock gating state */
Signature · 1 line
2.45.2
Re: [PATCH v3 1/3] ufs: core: Add get_hba_nortt callback for vendor-specific RTT capability
Quoted 7 lines · On Mon, 2026-06-15 at 13:57 +0800, [email protected] wrote:
From: Ed Tsai <[email protected]>
The number of outstanding RTTs read from host controller capability register is problematic on some platforms. Add a new vendor callback
get_hba_nortt()to allow platform vendors to override the default RTT capability value with platform-specific handling.
Quoted 6 lines
This patch keeps
max_num_rttfield for bisectability and will be removed
in a later patch once all platforms are migrated.Signed-off-by Ed Tsai <[email protected]>---
Re: [PATCH v3 1/3] ufs: core: Add get_hba_nortt callback for vendor-specific RTT capability
In reply to [email protected]Quoted 7 lines · On 6/14/26 10:57 PM, [email protected] wrote:
The number of outstanding RTTs read from host controller capability register is problematic on some platforms. Add a new vendor callback
get_hba_nortt()to allow platform vendors to override the default RTT capability value with platform-specific handling.This patch keeps
max_num_rttfield for bisectability and will be removed in a later patch once all platforms are migrated.
PATCH v3 2/3 ufs: mediatek: Implement get_hba_nortt callback for RTT capability
In reply to [email protected]From: Ed Tsai <[email protected]>
Implement the get_hba_nortt callback to handle platform-specific RTT capability differences:
- For legacy platforms and IP versions before MT6995 B0, the RTT capability from host controller register is problematic, so limit it to 2 (MTK_MAX_NUM_RTT_LEGACY).
- For MT6995 B0 and later platforms, the issue is fixed and the value from host controller capability register can be used directly.
This replaces the previous max_num_rtt field in ufs_hba_variant_ops with dynamic platform-specific logic.
--- drivers/ufs/host/ufs-mediatek.c | 12 +++++++++++- drivers/ufs/host/ufs-mediatek.h | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-)
drivers/ufs/host/ufs-mediatek.c +11 -1
@@ -2183,6 +2183,16 @@ static int ufs_mtk_clk_scale_notify(struct ufs_hba *hba, bool scale_up,return 0 ; } +static int ufs_mtk_get_hba_nortt (struct ufs_hba *hba) +{ +struct ufs_mtk_host *host =ufshcd_get_variant (hba); + +if (host->legacy_ip_ver || host->ip_ver <IP_VER_MT6995_B0 ) +return MTK_MAX_NUM_RTT_LEGACY ; + +return FIELD_GET (MASK_NUMBER_OUTSTANDING_RTT , hba->capabilities) +1 ; +} +static int ufs_mtk_get_hba_mac (struct ufs_hba *hba) {struct ufs_mtk_host *host =ufshcd_get_variant (hba);
@@ -2322,7 +2332,6 @@ static void ufs_mtk_config_scsi_dev(struct scsi_device *sdev)*/ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = { .name ="mediatek.ufshci" , - .max_num_rtt =MTK_MAX_NUM_RTT , .init = ufs_mtk_init, .get_ufs_hci_version = ufs_mtk_get_ufs_hci_version, .setup_clocks = ufs_mtk_setup_clocks,
@@ -2339,6 +2348,7 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = { .event_notify = ufs_mtk_event_notify, .config_scaling_param = ufs_mtk_config_scaling_param, .clk_scale_notify = ufs_mtk_clk_scale_notify, + .get_hba_nortt = ufs_mtk_get_hba_nortt,/* mcq vops */ .get_hba_mac = ufs_mtk_get_hba_mac, .op_runtime_config = ufs_mtk_op_runtime_config,
drivers/ufs/host/ufs-mediatek.h +2 -2
@@ -203,8 +203,8 @@ 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 +/* MTK RTT support number for platforms before MT6995 B0 */ +#define MTK_MAX_NUM_RTT_LEGACY 2/* UFSHCI MTK ip version value */ enum {
Signature · 1 line
2.45.2
PATCH v3 3/3 ufs: core: Remove max_num_rtt field from ufs_hba_variant_ops
In reply to [email protected]From: Ed Tsai <[email protected]>
Remove the max_num_rtt field from ufs_hba_variant_ops as it has been replaced by the get_hba_nortt() callback which provides more flexible platform-specific RTT capability handling.
--- drivers/ufs/core/ufshcd.c | 4 +--- include/ufs/ufshcd.h | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-)
drivers/ufs/core/ufshcd.c +1 -3
@@ -8557,8 +8557,6 @@ static void ufshcd_set_rtt(struct ufs_hba *hba)struct ufs_dev_info *dev_info = &hba->dev_info;u32 rtt =0 ;u32 dev_rtt =0 ; -int host_rtt_cap = hba->vops && hba->vops->max_num_rtt ? - hba->vops->max_num_rtt : hba->nortt;/* RTT override makes sense only for UFS-4.0 and above */ if (dev_info->wspecversion <0x400 )
@@ -8574,7 +8572,7 @@ static void ufshcd_set_rtt(struct ufs_hba *hba)if (dev_rtt !=DEFAULT_MAX_NUM_RTT )return ; - rtt =min_t (int, dev_info->rtt_cap, host_rtt_cap); + rtt =min_t (int, dev_info->rtt_cap, hba->nortt);if (rtt == dev_rtt)return ;
include/ufs/ufshcd.h +0 -2
@@ -370,7 +370,6 @@ struct ufshcd_tx_eq_params {/** * struct ufs_hba_variant_ops - variant specific callbacks * @name: variant name -* @max_num_rtt: maximum RTT supported by the host * @init: called when the driver is initialized * @exit: called to cleanup everything done in init * @set_dma_mask: For setting another DMA mask than indicated by the 64AS
@@ -420,7 +419,6 @@ struct ufshcd_tx_eq_params {*/ struct ufs_hba_variant_ops {const char *name; -int max_num_rtt;int (*init)(struct ufs_hba *);void (*exit)(struct ufs_hba *);u32 (*get_ufs_hci_version)(struct ufs_hba *);
Signature · 1 line
2.45.2
Re: [PATCH v3 3/3] ufs: core: Remove max_num_rtt field from ufs_hba_variant_ops
Quoted 8 lines · On Mon, 2026-06-15 at 13:57 +0800, [email protected] wrote:
From: Ed Tsai <[email protected]>
Remove the
max_num_rttfield fromufs_hba_variant_opsas it has been replaced by theget_hba_nortt()callback which provides more flexible platform-specific RTT capability handling.Signed-off-by Ed Tsai <[email protected]>---
Re: [PATCH v3 3/3] ufs: core: Remove max_num_rtt field from ufs_hba_variant_ops
In reply to [email protected]Quoted 3 lines · On 6/14/26 10:57 PM, [email protected] wrote:
Remove the
max_num_rttfield fromufs_hba_variant_opsas it has been replaced by theget_hba_nortt()callback which provides more flexible platform-specific RTT capability handling.
Quoted 30 lines · On Mon, 2026-06-15 at 13:57 +0800, [email protected] wrote:
From: Ed Tsai <[email protected]>
The first patch adds the
get_hba_nortt()callback to the UFS core layer,
allowing vendor drivers to provide dynamic, platform-specific RTT capability handling.The second patch implements this callback in the MediaTek UFS driver, distinguishing between legacy platforms (which require the RTT to be limited to 2) and newer MT6995 B0+ platforms (which can use the value from the capability register directly).
The third patch removes the
max_num_rttfield fromufs_hba_variant_ops
as it is now replaced by theget_hba_nortt()callback.Changes in v3:
- Fix incomplete v2 that was sent prematurely - now properly removesmax_num_rttfield in patch 3Changes in v2:
- Keepmax_num_rttfield in patch 1 to maintain bisectability
- Split removal ofmax_num_rttinto a separate patch (patch 3)Ed Tsai (3):
ufs: core: Addget_hba_norttcallback for vendor-specific RTT capability
ufs: mediatek: Implementget_hba_norttcallback for RTT capability
ufs: core: Removemax_num_rttfield fromufs_hba_variant_ops
Quoted 6 lines
drivers/ufs/core/ufshcd.c | 9 +++++----
drivers/ufs/host/ufs-mediatek.c| 12 +++++++++++-drivers/ufs/host/ufs-mediatek.h| 4 ++-- include/ufs/ufshcd.h | 5 +++--4 files changed, 21 insertions(+), 9 deletions(-)
Hi Martin,
Just a gentle ping on this patch series.
All three patches have received reviewed tags from Bart and Peter. Could you please consider picking this up for the next cycle when you have a chance?
Thanks,
Ed.
Martin K. Petersen
AppliedEd,
Quoted 11 lines
The first patch adds the
get_hba_nortt()callback to the UFS core layer, allowing vendor drivers to provide dynamic, platform-specific RTT capability handling.The second patch implements this callback in the MediaTek UFS driver, distinguishing between legacy platforms (which require the RTT to be limited to 2) and newer MT6995 B0+ platforms (which can use the value from the capability register directly).
The third patch removes the
max_num_rttfield fromufs_hba_variant_opsas it is now replaced by theget_hba_nortt()callback.
Applied to 7.3/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen
Martin K. Petersen
AppliedQuoted 10 lines · On Mon, 15 Jun 2026 13:57:14 +0800, [email protected] wrote:
The first patch adds the
get_hba_nortt()callback to the UFS core layer, allowing vendor drivers to provide dynamic, platform-specific RTT capability handling.The second patch implements this callback in the MediaTek UFS driver, distinguishing between legacy platforms (which require the RTT to be limited to 2) and newer MT6995 B0+ platforms (which can use the value from the capability register directly).
[...]
Applied to 7.3/scsi-queue, thanks!
[1/3] ufs: core: Add get_hba_nortt callback for vendor-specific RTT capability
https://git.kernel.org/mkp/scsi/c/e7896d02cb4d [2/3] ufs: mediatek: Implement get_hba_nortt callback for RTT capability https://git.kernel.org/mkp/scsi/c/75f529a7bcd4 [3/3] ufs: core: Remove max_num_rtt field from ufs_hba_variant_ops https://git.kernel.org/mkp/scsi/c/7ebadbae3dd7
Signature · 1 line
Martin K. Petersen