scsi: ufs: add missing host_lock in setup_xfer_req
PATCH 1/1 scsi: ufs: add missing host_lock in setup_xfer_req
This patch adds a host_lock which existed before on ufshcd_vops_setup_xfer_req.
--- drivers/scsi/ufs/ufshcd.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.h +7 -2
@@ -1229,8 +1229,13 @@ static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,static inline void ufshcd_vops_setup_xfer_req (struct ufs_hba *hba,int tag,bool is_scsi_cmd) { -if (hba->vops && hba->vops->setup_xfer_req) -return hba->vops->setup_xfer_req (hba, tag, is_scsi_cmd); +if (hba->vops && hba->vops->setup_xfer_req) { +unsigned long flags; + +spin_lock_irqsave (hba->host->host_lock, flags); + hba->vops->setup_xfer_req (hba, tag, is_scsi_cmd); +spin_unlock_irqrestore (hba->host->host_lock, flags); + } } static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba,
Signature · 1 line
2.32.0.93.g670b81a890-goog
Quoted 8 lines · Jaegeuk Kim
drivers/scsi/ufs/ufshcd.h +0
-0@@ -1229,8 +1229,13 @@ static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,static inline void ufshcd_vops_setup_xfer_req (struct ufs_hba *hba,int tag,bool is_scsi_cmd) {
drivers/scsi/ufs/ufshcd.h static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba, · line 1239
Quoted 10 lines
drivers/scsi/ufs/ufshcd.h +7
-2-if (hba->vops && hba->vops->setup_xfer_req) -return hba->vops->setup_xfer_req (hba, tag, is_scsi_cmd); +if (hba->vops && hba->vops->setup_xfer_req) { +unsigned long flags; + +spin_lock_irqsave (hba->host->host_lock, flags); + hba->vops->setup_xfer_req (hba, tag, is_scsi_cmd); +spin_unlock_irqrestore (hba->host->host_lock, flags); + } }
Since this function has only one caller, how about moving it into ufshcd.c?
Thanks,
Bart.
Bart Van Assche
Reviewed-byQuoted 13 lines · Bart Van Assche
Quoted 12 lines · Jaegeuk Kim
drivers/scsi/ufs/ufshcd.h +2
-2@@ -1229,8 +1229,13 @@ static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,static inline void ufshcd_vops_setup_xfer_req (struct ufs_hba *hba,int tag,bool is_scsi_cmd) { -if (hba->vops && hba->vops->setup_xfer_req) -return hba->vops->setup_xfer_req (hba, tag, is_scsi_cmd); +if (hba->vops && hba->vops->setup_xfer_req) { +unsigned long flags;
Quoted 8 lines
drivers/scsi/ufs/ufshcd.h static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba, · line 1239
Quoted 6 lines
drivers/scsi/ufs/ufshcd.h +5
-0+ +spin_lock_irqsave (hba->host->host_lock, flags); + hba->vops->setup_xfer_req (hba, tag, is_scsi_cmd); +spin_unlock_irqrestore (hba->host->host_lock, flags); + } }Since this function has only one caller, how about moving it into
ufshcd.c?
(replying to my own email)
Since I just noticed that there are many other similar function definitions in ufshcd.h, let's postpone moving these definitions until a later time.
Quoted 23 lines · Jaegeuk Kim
This patch adds a
host_lockwhich existed before onufshcd_vops_setup_xfer_req.Cc Stanley Chu <[email protected]>Cc Can Guo <[email protected]>Cc Bean Huo <[email protected]>Cc Bart Van Assche <[email protected]>Cc Asutosh Das <[email protected]>Fixes a45f937110fa ("scsi: ufs: Optimize host lock on transfer requests send/compl paths")Signed-off-by Jaegeuk Kim <[email protected]>--- drivers/scsi/ufs/ufshcd.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)drivers/scsi/ufs/ufshcd.h +0
-2@@ -1229,8 +1229,13 @@ static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba,static inline void ufshcd_vops_setup_xfer_req (struct ufs_hba *hba,int tag,bool is_scsi_cmd) { -if (hba->vops && hba->vops->setup_xfer_req) -return hba->vops->setup_xfer_req (hba, tag, is_scsi_cmd);
drivers/scsi/ufs/ufshcd.h static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba, · line 1241
Quoted 10 lines
drivers/scsi/ufs/ufshcd.h +7
-0+if (hba->vops && hba->vops->setup_xfer_req) { +unsigned long flags; + +spin_lock_irqsave (hba->host->host_lock, flags); + hba->vops->setup_xfer_req (hba, tag, is_scsi_cmd); +spin_unlock_irqrestore (hba->host->host_lock, flags); + } } static inline void ufshcd_vops_setup_task_mgmt(struct ufs_hba *hba,
Can anyone help with reviewing this patch?
Thanks,
Bart.
Quoted 28 lines · Bart Van Assche
Quoted 20 lines
drivers/scsi/ufs/ufshcd.h +7
-2@@ -1229,8 +1229,13 @@ static inline int ufshcd_vops_pwr_change_notify(struct ufs_hba *hba, static inline void ufshcd_vops_setup_xfer_req(struct ufs_hba *hba, int tag, bool is_scsi_cmd) { - if (hba->vops && hba->vops->setup_xfer_req) - return hba->vops->setup_xfer_req(hba, tag, is_scsi_cmd); +if (hba->vops && hba->vops->setup_xfer_req) { +unsigned long flags; + +spin_lock_irqsave (hba->host->host_lock, flags); + hba->vops->setup_xfer_req (hba, tag, is_scsi_cmd); +spin_unlock_irqrestore (hba->host->host_lock, flags); + }}Quoted 2 lines
static inline void ufshcd_vops_setup_task_mgmt(struct
ufs_hba
*hba,Can anyone help with reviewing this patch?
Quoted 4 lines
Thanks,
Hi Bart,
This change only impacts on the Samsung exynos platform. and Can's optimization patch is to optimise the host_lock,, and removed host_lock, now add back in this function makes sense to me. but I am thinking how about hba->host_sem?
Bean
Bean
Quoted 1 line
Bart.
Quoted 4 lines · Bean Huo
This change only impacts on the Samsung exynos platform. and Can's optimization patch is to optimise the
host_lock,, and removedhost_lock, now add back in this function makes sense to me. but I am thinking how abouthba->host_sem?
Hi Bean,
Calls of exynos_ufs_specify_nexus_t_xfer_req() must be serialized, hence Jaegeuks' patch. This function is called from the I/O submission path so performance matters. My understanding is that spinlocks have less overhead than semaphores. Hence the choice for a spinlock.
Thanks,
Bart.
Quoted 18 lines · Bart Van Assche
Quoted 4 lines · Bean Huo
This change only impacts on the Samsung exynos platform. and Can's optimization patch is to optimise the
host_lock,, and removedhost_lock, now add back in this function makes sense to me. but I am thinking how abouthba->host_sem?Hi Bean,
Calls of
exynos_ufs_specify_nexus_t_xfer_req()must be serialized, henceJaegeuks' patch. This function is called from the I/O submission path so
Quoted 9 lines
performance matters. My understanding is that spinlocks have less
overhead than semaphores. Hence the choice for a spinlock.
Thanks,
Bart,
After adding spin_lock/unlock_irqsave()
in ufshcd_vops_setup_xfer_req(), there will be 4 times of call of host_lock lock/unlock in ufshcd_send_command(). Reduce the code scope of protection, but increase the number of calls to spin_lock/unlock_irqsave(). Almost each sub-funciton
in ufshcd_send_command() calls spin_lock/unlock_irqsave(). why not directly take spin_lock/unlock_irqsave() away from each sub-fun, and increase the scope in ufshcd_send_command()?
Bean
Quoted 1 line
Bart