diff mbox series

scsi/ipr: keep the order of locks

Message ID CAPm50aJ_aW4RmL3_n=5CpGL9D3dXENenFuo5QG0Q2DJO9Gv_1w@mail.gmail.com (mailing list archive)
State Deferred
Headers show
Series scsi/ipr: keep the order of locks | expand

Commit Message

Hao Peng Sept. 23, 2022, 2:51 p.m. UTC
From: Peng Hao <flyingpeng@tencent.com>

ipr_ata_post_internal:
    acquire host_lock
       acquire hrrq->_lock
             ipr_device_reset
                 ipr_send_blocking_cmd
                    release host_lock
                    acquire host_lock
       release hrrq->_lock
    release host_lock

As shown above, there are two lock acquisition order changes.
At the same time, when ipr_device_reset is executed, the lock
hrrq->_lock does not need to be held.

Signed-off-by: Peng Hao <flyingpeng@tencent.com>
---
 drivers/scsi/ipr.c | 2 ++
 1 file changed, 2 insertions(+)

                }
--
2.27.0

Comments

Martin K. Petersen Oct. 1, 2022, 9:32 a.m. UTC | #1
> As shown above, there are two lock acquisition order changes.  At the
> same time, when ipr_device_reset is executed, the lock hrrq->_lock
> does not need to be held.

Please make sure to copy the driver maintainer when submitting patches:

$ ./scripts/get_maintainer.pl drivers/scsi/ipr.c | head -1
Brian King <brking@us.ibm.com> (supporter:IBM Power Linux RAID adapter)
Hao Peng Oct. 2, 2022, 4:14 a.m. UTC | #2
On Sat, Oct 1, 2022 at 5:33 PM Martin K. Petersen
<martin.petersen@oracle.com> wrote:
>
>
> > As shown above, there are two lock acquisition order changes.  At the
> > same time, when ipr_device_reset is executed, the lock hrrq->_lock
> > does not need to be held.
>
> Please make sure to copy the driver maintainer when submitting patches:
>
> $ ./scripts/get_maintainer.pl drivers/scsi/ipr.c | head -1
> Brian King <brking@us.ibm.com> (supporter:IBM Power Linux RAID adapter)
>
> --
> Martin K. Petersen      Oracle Linux Engineering
diff mbox series

Patch

diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index 9d01a3e3c26a..6ca987dda397 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -6837,7 +6837,9 @@  static void ipr_ata_post_internal(struct
ata_queued_cmd *qc)
                spin_lock(&hrrq->_lock);
                list_for_each_entry(ipr_cmd, &hrrq->hrrq_pending_q, queue) {
                        if (ipr_cmd->qc == qc) {
+                               spin_unlock(&hrrq->_lock);
                                ipr_device_reset(ioa_cfg, sata_port->res);
+                               spin_lock(&hrrq->_lock);
                                break;
                        }