From: Po-Wen Kao <powenkao@google.com>
To: linux-scsi@vger.kernel.org
Cc: Konstantin Vyshetsky <vkon@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>,
Li Qiang <liqiang01@kylinos.cn>,
John Garry <john.garry@linux.dev>,
HOYOUNG SEO <hy50.seo@samsung.com>,
Hyeoncheol Jeong <hyenc.jeong@samsung.com>
Subject: [PATCH v2 1/2] scsi: ufs: core: Defer debugfs init until after device init
Date: Tue, 24 Nov 2026 09:29:32 +0800 [thread overview]
Message-ID: <20261124012951.3143833-2-powenkao@google.com> (raw)
In-Reply-To: <20261124012951.3143833-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),
controller locks, and device descriptor (hba->dev_info.wspecversion) are
initialized.
Move ufs_debugfs_hba_init() and ufs_fault_inject_hba_init() into
ufshcd_init() alongside ufs_sysfs_add_nodes(), and move the matching
ufs_debugfs_hba_exit() from ufshcd_hba_exit() into ufshcd_remove()
alongside ufs_sysfs_remove_nodes(). Use disable_delayed_work_sync() in
ufs_debugfs_hba_exit() so an in-flight exception event cannot re-queue
debugfs_ee_work while scsi_remove_host() is still tearing down devices.
Moving the exit call symmetrically keeps probe error paths from tearing
down uncreated debugfs state, drains debugfs readers before
scsi_remove_host() removes the WLUN during unbind, and lets debugfs
initialization inspect both hba->ufs_version and
hba->dev_info.wspecversion directly.
Suggested-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Brian Kao <powenkao@google.com>
---
drivers/ufs/core/ufs-debugfs.c | 2 +-
drivers/ufs/core/ufshcd.c | 7 +++----
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/ufs/core/ufs-debugfs.c b/drivers/ufs/core/ufs-debugfs.c
index 9f83628f3e2c..e62b942b37dc 100644
--- a/drivers/ufs/core/ufs-debugfs.c
+++ b/drivers/ufs/core/ufs-debugfs.c
@@ -529,5 +529,5 @@ void ufs_debugfs_hba_init(struct ufs_hba *hba)
void ufs_debugfs_hba_exit(struct ufs_hba *hba)
{
debugfs_remove_recursive(hba->debugfs_root);
- cancel_delayed_work_sync(&hba->debugfs_ee_work);
+ disable_delayed_work_sync(&hba->debugfs_ee_work);
}
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 56a77f4a2a6e..f1df1d6734d9 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);
@@ -11027,6 +11023,7 @@ void ufshcd_remove(struct ufs_hba *hba)
ufs_bsg_remove(hba);
ufs_rpmb_remove(hba);
ufs_sysfs_remove_nodes(hba->dev);
+ ufs_debugfs_hba_exit(hba);
cancel_delayed_work_sync(&hba->ufs_rtc_update_work);
blk_mq_destroy_queue(hba->tmf_queue);
blk_put_queue(hba->tmf_queue);
@@ -11505,6 +11502,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.809.ga0b61035b5-goog
next prev parent reply other threads:[~2026-11-24 1:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 1:29 [PATCH v2 0/2] scsi: ufs: core: Add debugfs for PA TFS/FEC error counters Po-Wen Kao
2026-11-24 1:29 ` Po-Wen Kao [this message]
2026-11-24 1:29 ` [PATCH v2 2/2] " 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=20261124012951.3143833-2-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=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®