mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Can Guo <can.guo@oss.qualcomm.com>
To: Manivannan Sadhasivam <mani@kernel.org>
Cc: bvanassche@acm.org, beanhuo@micron.com, peter.wang@mediatek.com,
	martin.petersen@oracle.com, linux-scsi@vger.kernel.org,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	Ram Kumar Dwivedi <quic_rdwivedi@quicinc.com>,
	Nitin Rawat <quic_nitirawa@quicinc.com>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] scsi: ufs: core: Add support for static TX Equalization settings
Date: Thu, 28 May 2026 15:24:37 +0800	[thread overview]
Message-ID: <d57a0e9b-74f6-4472-842f-6479c7449cd8@oss.qualcomm.com> (raw)
In-Reply-To: <mt2asdx4vnuxo3eodrc7dlfdtv3b5bpjfvxxglmncny36otfav@htri3l5q4ba3>



On 5/28/2026 2:13 PM, Manivannan Sadhasivam wrote:
> On Wed, May 27, 2026 at 07:40:55AM -0700, Can Guo wrote:
>> Static TX Equalization settings and TX Precode enable indication from DT
>> properties txeq-preshoot-g[1-6], txeq-deemphasis-g[1-6], and
>> tx-precode-enable-g6 are board-specific baseline values. Values are
>> provided as per-lane tuples:
>>
>> <Host_Lane0 Device_Lane0>, [<Host_Lane1 Device_Lane1>]
>>
>> Parse DT u32 properties with explicit range checks by using
>> of_property_count_u32_elems()/of_property_read_u32_array().
>>
>> When adaptive TX Equalization is used, these static settings are not final:
>>
>> - If valid settings are retrieved from qTxEQGnSettings/wTxEQGnSettingsExt,
>>    those retrieved settings override static DT settings.
>> - If retrieval is not available/valid, TX EQTR runs and trained settings
>>    override static DT settings.
>>
>> So static DT settings are a fallback and are intended for cases where
>> adaptive TX Equalization is not enabled/used. Adaptive TX Equalization
>> remains the primary path when enabled.
>>
>> No behavior changes for platforms that do not provide these properties.
>>
>> Signed-off-by: Can Guo <can.guo@oss.qualcomm.com>
>> ---
>>   drivers/ufs/core/ufs-txeq.c      |   4 +-
>>   drivers/ufs/host/ufshcd-pltfrm.c | 128 +++++++++++++++++++++++++++++++
>>   include/ufs/ufshcd.h             |   2 +
>>   3 files changed, 133 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/ufs/core/ufs-txeq.c b/drivers/ufs/core/ufs-txeq.c
>> index 4b264adfdf49..634ec039e129 100644
>> --- a/drivers/ufs/core/ufs-txeq.c
>> +++ b/drivers/ufs/core/ufs-txeq.c
>> @@ -1297,7 +1297,7 @@ int ufshcd_config_tx_eq_settings(struct ufs_hba *hba,
>>   	}
>>   
>>   	params = &hba->tx_eq_params[gear - 1];
>> -	if (!params->is_valid || force_tx_eqtr) {
>> +	if (!params->is_valid || params->is_static || force_tx_eqtr) {
>>   		int ret;
>>   
>>   		ret = ufshcd_tx_eqtr(hba, params, pwr_mode);
>> @@ -1310,6 +1310,7 @@ int ufshcd_config_tx_eq_settings(struct ufs_hba *hba,
>>   		/* Mark TX Equalization settings as valid */
>>   		params->is_valid = true;
>>   		params->is_trained = true;
>> +		params->is_static = false;
>>   		params->is_applied = false;
>>   	}
>>   
>> @@ -1495,6 +1496,7 @@ static void ufshcd_extract_tx_eq_settings_attrs(struct ufs_hba *hba, u8 gear)
>>   	}
>>   
>>   	params->is_valid = true;
>> +	params->is_static = false;
> Maybe it's me, but I'm not able to understand how you want to apply these static
> EQ settings. In commit message you said, the static values should be used as a
> fallback, but you just check for 'params->is_static' while triggering
> ufshcd_tx_eqtr() which is supposed to perform adaptive TX EQ training. IMO, you
> don't need any check at all for applying static setting. If '(!params->is_valid
> || force_tx_eqtr)' condition is not satisfied, then the static setting should be
> used.
Thanks for the review.

The distinction is between two different sources that can pre-populate 
txeq_params with
is_valid set to true before ufshcd_config_tx_eq_settings() is called:

1. DT properties — parsed by ufshcd_pltfrm_parse_tx_eq_settings(),
     sets is_valid = true, is_static = true.
2. UFS Attributes (qTxEQGnSettings/wTxEQGnSettingsExt) — retrieved by
     ufshcd_retrieve_tx_eq_settings() (introduced in the 2nd series),
     sets is_valid = true, is_static = false.

Since both sources set is_valid = true, the is_valid flag alone cannot 
tell them apart.
The is_static flag is the discriminator:

- is_valid && is_static -> settings came from DT; they are a board-level 
baseline.
   TX EQTR should still run to find optimal settings, which will then 
overwrite the static ones.
- is_valid && !is_static -> settings came from UFS Attributes; they are 
previously trained
   known-good values. TX EQTR can be skipped.
- !is_valid -> no settings available yet; TX EQTR must run.

So the condition check on (!params->is_valid || params->is_static || 
force_tx_eqtr) handles
all three cases.

Thanks,
Can Guo.
>
> - Mani
>


  reply	other threads:[~2026-05-28  7:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260527144055.2758170-1-can.guo@oss.qualcomm.com>
2026-05-27 14:40 ` [PATCH 1/2] dt-bindings: ufs: Document static TX Equalization settings properties Can Guo
2026-05-28  6:18   ` Manivannan Sadhasivam
2026-05-30 11:36   ` Krzysztof Kozlowski
2026-05-27 14:40 ` [PATCH 2/2] scsi: ufs: core: Add support for static TX Equalization settings Can Guo
2026-05-28  6:13   ` Manivannan Sadhasivam
2026-05-28  7:24     ` Can Guo [this message]
2026-05-28  8:16       ` Manivannan Sadhasivam
2026-05-28  8:40         ` Can Guo
2026-05-28  9:29           ` Manivannan Sadhasivam
2026-05-28  9:31             ` Can Guo
2026-05-28  6:18   ` Manivannan Sadhasivam
2026-05-28  7:27     ` Can Guo
     [not found] <20260501134418.863432-1-can.guo@oss.qualcomm.com>
2026-05-01 13:44 ` Can Guo
2026-05-14 13:57   ` Bean Huo
2026-05-15  8:12     ` Can Guo

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=d57a0e9b-74f6-4472-842f-6479c7449cd8@oss.qualcomm.com \
    --to=can.guo@oss.qualcomm.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=peter.wang@mediatek.com \
    --cc=quic_nitirawa@quicinc.com \
    --cc=quic_rdwivedi@quicinc.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

all inboxes | Powered by JetHome®