From: Po-Wen Kao <powenkao@google.com>
To: linux-scsi@vger.kernel.org
Cc: Konstantin Vyshetsky <vkon@google.com>,
Randall Huang <huangrandall@google.com>,
Alim Akhtar <alim.akhtar@samsung.com>,
Bart Van Assche <bvanassche@acm.org>,
Bean Huo <beanhuo@micron.com>,
Stanley Jhu <stanleyjhu@google.com>,
"James E . J . Bottomley"
<James.Bottomley@HansenPartnership.com>,
"Martin K . Petersen" <mkp@kernel.org>,
Peter Wang <peter.wang@mediatek.com>,
Can Guo <can.guo@oss.qualcomm.com>,
linux-kernel@vger.kernel.org, Brian Kao <powenkao@google.com>,
John Garry <john.garry@linux.dev>,
Li Qiang <liqiang01@kylinos.cn>,
HOYOUNG SEO <hy50.seo@samsung.com>,
Hyeoncheol Jeong <hyenc.jeong@samsung.com>
Subject: [PATCH v3 2/3] scsi: ufs: core: Defer debugfs init until after device init
Date: Wed, 25 Nov 2026 19:34:00 +0800 [thread overview]
Message-ID: <20261125113435.1426680-3-powenkao@google.com> (raw)
In-Reply-To: <20261125113435.1426680-1-powenkao@google.com>
From: Brian Kao <powenkao@google.com>
ufshcd_hba_init() currently creates the debugfs hierarchy and fault
injection attributes before the controller version (hba->ufs_version),
locks (hba->host_sem, hba->ee_ctrl_mutex), UniPro link, and device
descriptor are initialized.
Move ufs_debugfs_hba_init() and ufs_fault_inject_hba_init() into
ufshcd_init() alongside ufs_sysfs_add_nodes(), and remove the now
redundant ufs_debugfs_hba_exit() call from ufshcd_hba_exit() since
probe failures occur before ufs_debugfs_hba_init(). Split out
ufs_debugfs_ee_init() to initialize hba->debugfs_ee_work and
hba->debugfs_ee_rate_limit_ms in ufshcd_init() next to hba->eeh_work,
before interrupts are enabled.
Note that hba->trigger_eh_attr and hba->timeout_attr are now
initialized after device init. Until then the zero-initialized
fault_attr has probability 0, so should_fail() returns false and
module-parameter fault injection takes effect after device init rather
than during early probe device-management commands.
Suggested-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Brian Kao <powenkao@google.com>
---
drivers/ufs/core/ufs-debugfs.c | 11 +++++++----
drivers/ufs/core/ufs-debugfs.h | 2 ++
drivers/ufs/core/ufshcd.c | 7 +++----
3 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/drivers/ufs/core/ufs-debugfs.c b/drivers/ufs/core/ufs-debugfs.c
index 89753c40b27b..a3731dea11c7 100644
--- a/drivers/ufs/core/ufs-debugfs.c
+++ b/drivers/ufs/core/ufs-debugfs.c
@@ -472,14 +472,17 @@ static const struct ufs_debugfs_attr ufs_tx_eqtr_attrs[] = {
{ }
};
-void ufs_debugfs_hba_init(struct ufs_hba *hba)
+void ufs_debugfs_ee_init(struct ufs_hba *hba)
{
- const struct ufs_debugfs_attr *attr;
- struct dentry *root;
-
/* Set default exception event rate limit period to 20ms */
hba->debugfs_ee_rate_limit_ms = 20;
INIT_DELAYED_WORK(&hba->debugfs_ee_work, ufs_debugfs_restart_ee);
+}
+
+void ufs_debugfs_hba_init(struct ufs_hba *hba)
+{
+ const struct ufs_debugfs_attr *attr;
+ struct dentry *root;
root = debugfs_create_dir(dev_name(hba->dev), ufs_debugfs_root);
if (IS_ERR_OR_NULL(root))
diff --git a/drivers/ufs/core/ufs-debugfs.h b/drivers/ufs/core/ufs-debugfs.h
index e5bba9671862..d0acfd045a8b 100644
--- a/drivers/ufs/core/ufs-debugfs.h
+++ b/drivers/ufs/core/ufs-debugfs.h
@@ -13,12 +13,14 @@ struct ufs_hba;
#ifdef CONFIG_DEBUG_FS
void __init ufs_debugfs_init(void);
void ufs_debugfs_exit(void);
+void ufs_debugfs_ee_init(struct ufs_hba *hba);
void ufs_debugfs_hba_init(struct ufs_hba *hba);
void ufs_debugfs_hba_exit(struct ufs_hba *hba);
void ufs_debugfs_exception_event(struct ufs_hba *hba, u16 status);
#else
static inline void ufs_debugfs_init(void) {}
static inline void ufs_debugfs_exit(void) {}
+static inline void ufs_debugfs_ee_init(struct ufs_hba *hba) {}
static inline void ufs_debugfs_hba_init(struct ufs_hba *hba) {}
static inline void ufs_debugfs_hba_exit(struct ufs_hba *hba) {}
static inline void ufs_debugfs_exception_event(struct ufs_hba *hba, u16 status) {}
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 646359d446c3..443dcd7ed12c 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -10115,9 +10115,6 @@ static int ufshcd_hba_init(struct ufs_hba *hba)
if (err)
goto out_disable_vreg;
- ufs_debugfs_hba_init(hba);
- ufs_fault_inject_hba_init(hba);
-
hba->is_powered = true;
goto out;
@@ -10139,7 +10136,6 @@ static void ufshcd_hba_exit(struct ufs_hba *hba)
ufshcd_exit_clk_gating(hba);
if (hba->eh_wq)
destroy_workqueue(hba->eh_wq);
- ufs_debugfs_hba_exit(hba);
ufshcd_vops_exit(hba);
ufshcd_setup_vreg(hba, false);
ufshcd_setup_clocks(hba, false);
@@ -11375,6 +11371,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
}
INIT_WORK(&hba->eh_work, ufshcd_err_handler);
INIT_WORK(&hba->eeh_work, ufshcd_exception_event_handler);
+ ufs_debugfs_ee_init(hba);
sema_init(&hba->host_sem, 1);
@@ -11506,6 +11503,8 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
ufs_sysfs_add_nodes(hba->dev);
hba->dme_qos_sysfs_handle = sysfs_get_dirent(hba->dev->kobj.sd,
"dme_qos_notification");
+ ufs_debugfs_hba_init(hba);
+ ufs_fault_inject_hba_init(hba);
async_schedule(ufshcd_async_scan, hba);
device_enable_async_suspend(dev);
--
2.56.1.839.g22a8290db9-goog
next prev parent reply other threads:[~2026-11-25 11:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:33 [PATCH v3 0/3] scsi: ufs: core: Add debugfs for PA TFS/FEC error counters Po-Wen Kao
2026-11-25 11:33 ` [PATCH v3 1/3] scsi: ufs: core: Remove debugfs before removing SCSI host Po-Wen Kao
2026-11-25 11:34 ` Po-Wen Kao [this message]
2026-11-25 11:34 ` [PATCH v3 3/3] scsi: ufs: core: Add debugfs for PA TFS/FEC error counters Po-Wen Kao
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=20261125113435.1426680-3-powenkao@google.com \
--to=powenkao@google.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=alim.akhtar@samsung.com \
--cc=beanhuo@micron.com \
--cc=bvanassche@acm.org \
--cc=can.guo@oss.qualcomm.com \
--cc=huangrandall@google.com \
--cc=hy50.seo@samsung.com \
--cc=hyenc.jeong@samsung.com \
--cc=john.garry@linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=liqiang01@kylinos.cn \
--cc=mkp@kernel.org \
--cc=peter.wang@mediatek.com \
--cc=stanleyjhu@google.com \
--cc=vkon@google.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®