Re: [PATCH 1/2] scsi: ufs: Put SCSI host after remove it

From: cang
Date: Sun Dec 15 2019 - 20:36:43 EST


On 2019-12-16 05:55, Bart Van Assche wrote:
On 2019-12-14 14:24, cang@xxxxxxxxxxxxxx wrote:
How do you think if I replace my patch with below one?
In this way, you can also move blk_cleanup_queue() behind
cancel_work_sync(eh_work).

diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index b5966fa..bd4ae75 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -8251,15 +8251,17 @@ void ufshcd_remove(struct ufs_hba *hba)
ÂÂÂÂÂÂÂ ufs_bsg_remove(hba);
ÂÂÂÂÂÂÂ ufs_sysfs_remove_nodes(hba->dev);
ÂÂÂÂÂÂÂ scsi_remove_host(hba->host);
-ÂÂÂÂÂÂ /* disable interrupts */
-ÂÂÂÂÂÂ ufshcd_disable_intr(hba, hba->intr_mask);
-ÂÂÂÂÂÂ ufshcd_hba_stop(hba, true);
-
ÂÂÂÂÂÂÂ ufshcd_exit_clk_scaling(hba);
ÂÂÂÂÂÂÂ ufshcd_exit_clk_gating(hba);
ÂÂÂÂÂÂÂ if (ufshcd_is_clkscaling_supported(hba))
ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ device_remove_file(hba->dev,
&hba->clk_scaling.enable_attr);
+ÂÂÂÂÂÂ cancel_work_sync(&hba->eeh_work);
+ÂÂÂÂÂÂ cancel_work_sync(&hba->eh_work);
+ÂÂÂÂÂÂ /* disable interrupts */
+ÂÂÂÂÂÂ ufshcd_disable_intr(hba, hba->intr_mask);
+ÂÂÂÂÂÂ ufshcd_hba_stop(hba, true);
ÂÂÂÂÂÂÂ ufshcd_hba_exit(hba);
+ÂÂÂÂÂÂ ufshcd_dealloc_host(hba);
Â}
ÂEXPORT_SYMBOL_GPL(ufshcd_remove);

Hi Can,

To which kernel tree does the above patch apply? I'm asking this because
I don't see the recently added blk_cleanup_queue() calls in the above
patch. Please start from Martin's latest scsi-queue branch when
preparing SCSI patches.

Additionally, is it on purpose that there is no scsi_host_put() call in
the above code? I'd like to keep that call because without that call a
memory leak will occur when unloading the ufshcd-core kernel driver.

Thanks,

Bart.


Hi Bart,

This is applied to 5.5/scsi-queue. The two changes I patsed from you are
not merged yet, I am still doing code review to them, so there is no
blk_cleanup_queue() calls in my code base. I am just saying you may move
your blk_cleanup_queue() calls below cancel_work_sync(&hba->eh_work) if
my change applies. How do you think?

scsi_host_put() was there before but explicitly removed by
afa3dfd42d205b106787476647735aa1de1a5d02. I agree with you, without this
change, there is memory leak.

Thanks,

Can Guo.