Add post change sequence for link start notify
Subsystems (4)
v6 cover Add post change sequence for link start notify
From: Palash Kambar <[email protected]>
This patch series introduces two updates to the UFS subsystem aimed at improving link stability and power efficiency on platforms using the Qualcomm UFS host controller.
During link startup, the number of connected TX/RX lanes discovered may be fewer than the lanes specified in the device tree. The current UFS core driver configures all DT-defined lanes unconditionally, which can lead to mismatches during power mode changes. Patch 1/2 ensures to fail on this.
Additionally, certain Qualcomm platforms support Auto Hibern8 (AH8), where the UFS controller autonomously de-asserts clk_req signals to the GCC during Hibern8 state. Enabling this mechanism allows the clock controller to gate unused clocks, providing meaningful power savings. Patch 2/2 adds support for enabling this feature as recommended by the Hardware Programming Guidelines.
---
changes from V1
1) Addressed Shawn Lin's comments to fix comment to connected lanes.
2) Addressed Bart's comments to remove warning and trigger failure incase of lane mismatch.
changes from V2:
1) Addressed Shawn's comments to fix commit text.
2) Addressed Bart's comments to remove variable initializations and indentation fix.
changes from V3:
1) Addressed Manivannan's comments to remove extra comment and return logic.
changes from V4:
1) Addressed Manivannan's comments to fix indentation and return handling.
changes from V5:
1) Addressed Manivannan's comment and added back the missed tags from V3.
Palash Kambar (2):
ufs: core: Configure only active lanes during link
ufs: ufs-qcom: Enable Auto Hibern8 clock request support
drivers/ufs/core/ufshcd.c | 35 +++++++++++++++++++++++++++++++++++ drivers/ufs/host/ufs-qcom.c | 10 ++++++++++ drivers/ufs/host/ufs-qcom.h | 11 +++++++++++ 3 files changed, 56 insertions(+)
Signature · 1 line
2.34.1
PATCH v6 1/2 ufs: core: Configure only active lanes during link
From: Palash Kambar <[email protected]>
The number of connected lanes detected during UFS link startup can be fewer than the lanes specified in the device tree. The current driver logic attempts to configure all lanes defined in the device tree, regardless of their actual availability. This mismatch may cause failures during power mode changes.
Hence, Add a check during link startup to ensure that only the lanes actually discovered are considered valid. If a mismatch is detected, fail the initialization early, preventing the driver from entering an unsupported configuration that could cause power mode transition failures.
--- drivers/ufs/core/ufshcd.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/ufs/core/ufshcd.c +35 -0
@@ -5035,6 +5035,37 @@ void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val) }EXPORT_SYMBOL_GPL (ufshcd_update_evt_hist); +static int ufshcd_validate_link_params (struct ufs_hba *hba) +{ +int ret, val; + + ret =ufshcd_dme_get (hba,UIC_ARG_MIB (PA_CONNECTEDTXDATALANES ), + &val); +if (ret) +return ret; + +if (val != hba->lanes_per_direction) { +dev_err (hba->dev,"Tx lane mismatch [config,reported] [%d,%d]\n" , + hba->lanes_per_direction, val); + ret = -ENOLINK ; +return ret; + } + + ret =ufshcd_dme_get (hba,UIC_ARG_MIB (PA_CONNECTEDRXDATALANES ), + &val); +if (ret) +return ret; + +if (val != hba->lanes_per_direction) { +dev_err (hba->dev,"Rx lane mismatch [config,reported] [%d,%d]\n" , + hba->lanes_per_direction, val); + ret = -ENOLINK ; +return ret; + } + +return 0 ; +} +/** * ufshcd_link_startup - Initialize unipro link startup * @hba: per adapter instance
@@ -5108,6 +5139,10 @@ static int ufshcd_link_startup(struct ufs_hba *hba) goto out; } + ret =ufshcd_validate_link_params (hba); +if (ret) + goto out; +/* Include any host controller configuration via UIC commands */ ret =ufshcd_vops_link_startup_notify (hba,POST_CHANGE );if (ret)
Signature · 1 line
2.34.1
Manivannan Sadhasivam
maintainerRe: [PATCH V6 1/2] ufs: core: Configure only active lanes during link
Quoted 34 lines · On Thu, Apr 23, 2026 at 11:29:13AM +0530, [email protected] wrote:
From: Palash Kambar <[email protected]>
The number of connected lanes detected during UFS link startup can be fewer than the lanes specified in the device tree. The current driver logic attempts to configure all lanes defined in the device tree, regardless of their actual availability. This mismatch may cause failures during power mode changes.
Hence, Add a check during link startup to ensure that only the lanes actually discovered are considered valid. If a mismatch is detected, fail the initialization early, preventing the driver from entering an unsupported configuration that could cause power mode transition failures.
Reviewed-by Bart Van Assche <[email protected]>Reviewed-by Shawn Lin <[email protected]>Reviewed-by Manivannan Sadhasivam <[email protected]>Signed-off-by Palash Kambar <[email protected]>--- drivers/ufs/core/ufshcd.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)drivers/ufs/core/ufshcd.c +4
-0@@ -5035,6 +5035,37 @@ void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val) }EXPORT_SYMBOL_GPL (ufshcd_update_evt_hist); +static int ufshcd_validate_link_params (struct ufs_hba *hba) +{ +int ret, val; +
drivers/ufs/core/ufshcd.c void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val) · line 5051
Quoted 10 lines
drivers/ufs/core/ufshcd.c +10
-0+ ret =ufshcd_dme_get (hba,UIC_ARG_MIB (PA_CONNECTEDTXDATALANES ), + &val); +if (ret) +return ret; + +if (val != hba->lanes_per_direction) { +dev_err (hba->dev,"Tx lane mismatch [config,reported] [%d,%d]\n" , + hba->lanes_per_direction, val); + ret = -ENOLINK ; +return ret;
Really? If you had spent a minute in reading the patch after writing, you would've seen this obvious mistake.
drivers/ufs/core/ufshcd.c void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val) · line 5063
Quoted 12 lines
drivers/ufs/core/ufshcd.c +12
-0+ } + + ret =ufshcd_dme_get (hba,UIC_ARG_MIB (PA_CONNECTEDRXDATALANES ), + &val); +if (ret) +return ret; + +if (val != hba->lanes_per_direction) { +dev_err (hba->dev,"Rx lane mismatch [config,reported] [%d,%d]\n" , + hba->lanes_per_direction, val); + ret = -ENOLINK ; +return ret;
Same here.
- Mani
Signature · 1 line
மணிவண்ணன் சதாசிவம்
Re: [PATCH V6 1/2] ufs: core: Configure only active lanes during link
Quoted 40 lines · Manivannan Sadhasivam
Quoted 39 lines · On Thu, Apr 23, 2026 at 11:29:13AM +0530, [email protected] wrote:
From: Palash Kambar <[email protected]>
The number of connected lanes detected during UFS link startup can be fewer than the lanes specified in the device tree. The current driver logic attempts to configure all lanes defined in the device tree, regardless of their actual availability. This mismatch may cause failures during power mode changes.
Hence, Add a check during link startup to ensure that only the lanes actually discovered are considered valid. If a mismatch is detected, fail the initialization early, preventing the driver from entering an unsupported configuration that could cause power mode transition failures.
Reviewed-by Bart Van Assche <[email protected]>Reviewed-by Shawn Lin <[email protected]>Reviewed-by Manivannan Sadhasivam <[email protected]>Signed-off-by Palash Kambar <[email protected]>--- drivers/ufs/core/ufshcd.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)drivers/ufs/core/ufshcd.c +9
-0@@ -5035,6 +5035,37 @@ void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val) }EXPORT_SYMBOL_GPL (ufshcd_update_evt_hist); +static int ufshcd_validate_link_params (struct ufs_hba *hba) +{ +int ret, val; + + ret =ufshcd_dme_get (hba,UIC_ARG_MIB (PA_CONNECTEDTXDATALANES ), + &val); +if (ret) +return ret; +
Quoted 8 lines
drivers/ufs/core/ufshcd.c void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val) · line 5051
Quoted 5 lines
drivers/ufs/core/ufshcd.c +5
-0+if (val != hba->lanes_per_direction) { +dev_err (hba->dev,"Tx lane mismatch [config,reported] [%d,%d]\n" , + hba->lanes_per_direction, val); + ret = -ENOLINK ; +return ret;Really? If you had spent a minute in reading the patch after writing, you would've seen this obvious mistake.
Ok Mani, will update this. Thanks.
Quoted 18 lines
drivers/ufs/core/ufshcd.c void ufshcd_update_evt_hist(struct ufs_hba *hba, u32 id, u32 val) · line 5063
Quoted 13 lines
drivers/ufs/core/ufshcd.c +12
-0+ } + + ret =ufshcd_dme_get (hba,UIC_ARG_MIB (PA_CONNECTEDRXDATALANES ), + &val); +if (ret) +return ret; + +if (val != hba->lanes_per_direction) { +dev_err (hba->dev,"Rx lane mismatch [config,reported] [%d,%d]\n" , + hba->lanes_per_direction, val); + ret = -ENOLINK ; +return ret;Same here.
- Mani
PATCH v6 2/2 ufs: ufs-qcom: Enable Auto Hibern8 clock request support
In reply to [email protected]From: Palash Kambar <[email protected]>
On platforms that support Auto Hibern8 (AH8), the UFS controller can autonomously de-assert clk_req signals to the Global Clock Controller when entering the Hibern8 state. This allows Global Clock Controller (GCC) to gate unused clocks, improving power efficiency.
Enable the Clock Request feature by setting the UFS_HW_CLK_CTRL_EN bit in the UFS_AH8_CFG register, as recommended in the Hardware Programming Guidelines.
--- drivers/ufs/host/ufs-qcom.c | 10 ++++++++++ drivers/ufs/host/ufs-qcom.h | 11 +++++++++++ 2 files changed, 21 insertions(+)
drivers/ufs/host/ufs-qcom.c +10 -0
@@ -683,6 +683,13 @@ static int ufs_qcom_cfg_timers(struct ufs_hba *hba, bool is_pre_scale_up, unsignreturn 0 ; } +static void ufs_qcom_link_startup_post_change (struct ufs_hba *hba) +{ +if (ufshcd_is_auto_hibern8_supported (hba)) +ufshcd_rmwl (hba,UFS_HW_CLK_CTRL_EN ,UFS_HW_CLK_CTRL_EN , +UFS_AH8_CFG ); +} +static int ufs_qcom_link_startup_notify (struct ufs_hba *hba,enum ufs_notify_change_status status) {
@@ -708,6 +715,9 @@ static int ufs_qcom_link_startup_notify(struct ufs_hba *hba,*/ err =ufshcd_disable_host_tx_lcc (hba); +break ; +case POST_CHANGE : +ufs_qcom_link_startup_post_change (hba);break ;default :break ;
drivers/ufs/host/ufs-qcom.h +11 -0
@@ -228,6 +228,17 @@ enum {*/ #define NUM_TX_R1W1 13 +/* bit definitions for UFS_AH8_CFG register */ +#define CC_UFS_SYS_CLK_REQ_EN BIT(2) +#define CC_UFS_ICE_CORE_CLK_REQ_EN BIT(3) +#define CC_UFS_UNIPRO_CORE_CLK_REQ_EN BIT(4) +#define CC_UFS_AUXCLK_REQ_EN BIT(5) + +#define UFS_HW_CLK_CTRL_EN (CC_UFS_SYS_CLK_REQ_EN |\ + CC_UFS_ICE_CORE_CLK_REQ_EN |\ + CC_UFS_UNIPRO_CORE_CLK_REQ_EN |\ + CC_UFS_AUXCLK_REQ_EN) +static inline void ufs_qcom_get_controller_revision (struct ufs_hba *hba,u8 *major,u16 *minor,u16 *step)
Signature · 1 line
2.34.1