diff mbox series

[09/14] scsi: mpt3sas: Remove in_interrupt().

Message ID 20201126132952.2287996-10-bigeasy@linutronix.de
State New
Headers show
Series scsi: Remove in_interrupt() usage. | expand

Commit Message

Sebastian Andrzej Siewior Nov. 26, 2020, 1:29 p.m. UTC
From: "Ahmed S. Darwish" <a.darwish@linutronix.de>

_scsih_fw_event_cleanup_queue() waits for all outstanding firmware
events wokrqueue handlers to finish. If in_interrupt() is true, it
cancels itself and return early.

That in_interrupt() check is ill-defined and does not provide what the
name suggests: it does not cover all states in which it is safe to block
and call functions like cancel_work_sync().

That check is also not needed: _scsih_fw_event_cleanup_queue() is always
invoked from process context. Below is an analysis of its callers:

  - scsih_remove(), bound to PCI ->remove(), process context

  - scsih_shutdown(), bound to PCI ->shutdown(), process context

  - mpt3sas_scsih_clear_outstanding_scsi_tm_commands(), called by
      => _base_clear_outstanding_commands(), called by
        =>_base_fault_reset_work(), workqueue
        => mpt3sas_base_hard_reset_handler(), locks mutex

Remove the in_interrupt() check. Change _scsih_fw_event_cleanup_queue()
specification to a purely process-context function and mark it with
"Context: task, can sleep".

Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: Sathya Prakash <sathya.prakash@broadcom.com>
Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>
Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>
Cc: <MPT-FusionLinux.pdl@broadcom.com>
---
 drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Daniel Wagner Nov. 30, 2020, 3:16 p.m. UTC | #1
On Thu, Nov 26, 2020 at 02:29:47PM +0100, Sebastian Andrzej Siewior wrote:
> From: "Ahmed S. Darwish" <a.darwish@linutronix.de>

> 

> _scsih_fw_event_cleanup_queue() waits for all outstanding firmware

> events wokrqueue handlers to finish. If in_interrupt() is true, it

> cancels itself and return early.

> 

> That in_interrupt() check is ill-defined and does not provide what the

> name suggests: it does not cover all states in which it is safe to block

> and call functions like cancel_work_sync().

> 

> That check is also not needed: _scsih_fw_event_cleanup_queue() is always

> invoked from process context. Below is an analysis of its callers:

> 

>   - scsih_remove(), bound to PCI ->remove(), process context

> 

>   - scsih_shutdown(), bound to PCI ->shutdown(), process context

> 

>   - mpt3sas_scsih_clear_outstanding_scsi_tm_commands(), called by

>       => _base_clear_outstanding_commands(), called by

>         =>_base_fault_reset_work(), workqueue

>         => mpt3sas_base_hard_reset_handler(), locks mutex

> 

> Remove the in_interrupt() check. Change _scsih_fw_event_cleanup_queue()

> specification to a purely process-context function and mark it with

> "Context: task, can sleep".

> 

> Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>

> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

> Cc: Sathya Prakash <sathya.prakash@broadcom.com>

> Cc: Sreekanth Reddy <sreekanth.reddy@broadcom.com>

> Cc: Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>

> Cc: <MPT-FusionLinux.pdl@broadcom.com>


Reviewed-by: Daniel Wagner <dwagner@suse.de>
diff mbox series

Patch

diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index f081adb85addc..d91f45abe6b86 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -3673,6 +3673,8 @@  static struct fw_event_work *dequeue_next_fw_event(struct MPT3SAS_ADAPTER *ioc)
  *
  * Walk the firmware event queue, either killing timers, or waiting
  * for outstanding events to complete
+ *
+ * Context: task, can sleep
  */
 static void
 _scsih_fw_event_cleanup_queue(struct MPT3SAS_ADAPTER *ioc)
@@ -3680,7 +3682,7 @@  _scsih_fw_event_cleanup_queue(struct MPT3SAS_ADAPTER *ioc)
 	struct fw_event_work *fw_event;
 
 	if ((list_empty(&ioc->fw_event_list) && !ioc->current_event) ||
-	     !ioc->firmware_event_thread || in_interrupt())
+	    !ioc->firmware_event_thread)
 		return;
 
 	ioc->fw_events_cleanup = 1;