public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: Can Guo <can.guo@oss.qualcomm.com>
To: avri.altman@wdc.com, bvanassche@acm.org, beanhuo@micron.com,
	peter.wang@mediatek.com, martin.petersen@oracle.com,
	mani@kernel.org
Cc: linux-scsi@vger.kernel.org, Can Guo <can.guo@oss.qualcomm.com>
Subject: [PATCH 0/2] scsi: ufs: Add persistent TX Equalization settings support
Date: Sun, 19 Apr 2026 06:52:27 -0700	[thread overview]
Message-ID: <20260419135229.1036926-1-can.guo@oss.qualcomm.com> (raw)

Hi,

This series is a follow-up to the earlier TX Equalization enablement series:

https://lore.kernel.org/all/20260325152154.1604082-1-can.guo@oss.qualcomm.com

In that cover letter, the "Next" section mentioned adding support for
UFS v5.0 Attributes qTxEQGnSettings and wTxEQGnSettingsExt, and enabling
persistent storage/retrieval of optimal TX Equalization settings. This
2-patch series implements that part.

Motivation
==========

TX EQTR procedure is required to find the optimal TX Equalization settings
for HS Gears (4-6) before changing Power Mode to the target HS Gears.
However, TX EQTR procedure introduces latencies to the first Power Mode
change.

With optimal TX Equalization settings stored in UFS v5.0 Attributes
qTxEQGnSettings and wTxEQGnSettingsExt, host software can reuse known-good
settings and avoid going through the TX EQTR procedure.

Array Attribute Model
=====================

qTxEQGnSettings and wTxEQGnSettingsExt are array-type Attributes. Each
element in an array-type Attribute is selected by an (Index, Selector) pair.

For these two attributes:
- Valid Index range: [0, Max HS Gear - 1]
- Valid Selector range: [0, 1]

This effectively forms a 2-dimensional array. For HS-Gear n, its TX
Equalization settings are stored/retrieved at Index (n - 1). Selector is
configurable via a module parameter so that platforms can choose the
Selector policy that matches their use.

Implementation Overview
=======================

1. Introduce a generic helper for 64-bit query attributes:
   ufshcd_query_attr_qword().

2. Add TX EQ settings persistence flow:
   - Read stored settings from qTxEQGnSettings & wTxEQGnSettingsExt.
   - Decode and populate per-gear TX EQ parameters.
   - Use Bit[15] in wTxEQGnSettingsExt as validity indication.
   - Store trained settings back to these attributes for future reuse.

3. Integrate with existing lifecycle:
   - Retrieve settings during device parameter initialization.
   - Store settings during shutdown.

New Module Parameters
=====================

Three module parameters are added for TX EQ settings persistence control:
- txeq_setting_sel (default: 0, range: 0..1)
    Selects which selector value is used when reading/writing
    qTxEQGnSettings and wTxEQGnSettingsExt.
- retrieve_txeq_setting (default: true)
    Enables/disables retrieving stored TX EQ settings from device attributes
    during initialization.
- store_txeq_setting (default: true)
    Enables/disables storing last trained TX EQ settings into device attributes
    during shutdown.

Testing
=======

Tested on a UFS v5.0 platform:
- TX Equalization setting store path, settings were correctly encoded and stored.
- TX Equalization setting retrieval path, settings were correctly extracted and reused.
- Full TX EQTR procedure was skipped for a given HS Gear when valid TX EQ settings
  were provided in qTxEQGnSettings & wTxEQGnSettingsExt for the given HS-Gear.


Can Guo (2):
  scsi: ufs: core: Introduce function ufshcd_query_attr_qword()
  scsi: ufs: core: Add support to retrieve and store TX Equalization
    settings

 drivers/ufs/core/ufs-sysfs.c   |  30 +++-
 drivers/ufs/core/ufs-txeq.c    | 241 +++++++++++++++++++++++++++++++++
 drivers/ufs/core/ufshcd-priv.h |   5 +-
 drivers/ufs/core/ufshcd.c      | 131 ++++++++++--------
 include/ufs/ufs.h              |   2 +
 include/ufs/ufshcd.h           |   2 +
 6 files changed, 346 insertions(+), 65 deletions(-)

-- 
2.34.1


             reply	other threads:[~2026-04-19 13:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-19 13:52 Can Guo [this message]
2026-04-19 13:52 ` [PATCH 1/2] scsi: ufs: core: Introduce function ufshcd_query_attr_qword() Can Guo
2026-04-20 12:31   ` Peter Wang (王信友)
2026-04-20 16:58   ` Bart Van Assche
2026-04-23 12:59     ` Can Guo
2026-04-20 22:04   ` Bean Huo
2026-04-23 13:30     ` Can Guo
2026-04-19 13:52 ` [PATCH 2/2] scsi: ufs: core: Add support to retrieve and store TX Equalization settings Can Guo
2026-04-20 12:33   ` Peter Wang (王信友)
2026-04-20 13:23     ` Can Guo
2026-04-20 16:28       ` Bart Van Assche
2026-04-23 13:49         ` Can Guo
2026-04-20 17:01   ` Bart Van Assche
2026-04-23 13:50     ` Can Guo
2026-04-20 22:09   ` Bean Huo

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=20260419135229.1036926-1-can.guo@oss.qualcomm.com \
    --to=can.guo@oss.qualcomm.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=peter.wang@mediatek.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