wireless: Use complete() instead complete_all()
Subsystems (3)
cover wireless: Use complete() instead complete_all()
From: Daniel Wagner <[email protected]>
Hi,
Using complete_all() is not wrong per se but it suggest that there might be more than one waiter. For -rt I am reviewing all complete_all() users and would like to leave only the real ones in the tree. The main problem for -rt about complete_all() is that it can be uses inside IRQ context and that can lead to unbounded amount work inside the interrupt handler. That is a no no for -rt.
The patches grouped per subsystem and in small batches to allow reviewing.
Patch #1 fixes a minor bug in the completion API usage. The current code works but it could work better.
cheers,
daniel
Daniel Wagner (3):
csiostor: fix completion usage
sym53c8xx_2: use complete() instead complete_all()
virtio_scsi: use complete() instead complete_all()
drivers/scsi/csiostor/csio_scsi.c | 5 ++--- drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +- drivers/scsi/virtio_scsi.c | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-)
Signature · 1 line
2.7.4
PATCH 1/3 csiostor: fix completion usage
From: Daniel Wagner <[email protected]>
The (re)initialzing of the completion object should be done before we trigger the transfer. Doing this after triggering the hardware opens up a race window. Without the timeout we would problaly even deadlock. Use also reinit_completion because we initalize the whole data structure in csio_scscim_init().
There is only one waiter for the completion, therefore there is no need to use complete_all(). Let's make that clear by using complete() instead of complete_all().
The usage pattern of the completion is:
waiter context waker context
csio_eh_abort_handler()
reinit_completion()
wait_for_completion_timeout()
csio_scsi_err_handler()
complete()
--- drivers/scsi/csiostor/csio_scsi.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/scsi/csiostor/csio_scsi.c +2 -3
@@ -1721,7 +1721,7 @@ csio_scsi_err_handler(struct csio_hw *hw, struct csio_ioreq *req)/* Wake up waiting threads */ csio_scsi_cmnd (req) =NULL ; -complete_all (&req->cmplobj); +complete (&req->cmplobj); }/*
@@ -1945,6 +1945,7 @@ csio_eh_abort_handler(struct scsi_cmnd *cmnd) ready =csio_is_lnode_ready (ln); tmo =CSIO_SCSI_ABRT_TMO_MS ; +reinit_completion (&ioreq->cmplobj);spin_lock_irq (&hw->lock); rv =csio_do_abrt_cls (hw, ioreq, (ready ?SCSI_ABORT :SCSI_CLOSE ));spin_unlock_irq (&hw->lock);
@@ -1964,8 +1965,6 @@ csio_eh_abort_handler(struct scsi_cmnd *cmnd) goto inval_scmnd; } -/* Wait for completion */ -init_completion (&ioreq->cmplobj);wait_for_completion_timeout (&ioreq->cmplobj,msecs_to_jiffies (tmo));/* FW didnt respond to abort within our timeout */
Signature · 1 line
2.7.4
PATCH 2/3 sym53c8xx_2: use complete() instead complete_all()
In reply to Daniel WagnerFrom: Daniel Wagner <[email protected]>
There is only one waiter for the completion, therefore there is no need to use complete_all(). Let's make that clear by using complete() instead of complete_all().
The usage pattern of the completion is:
waiter context waker context
sym_eh_handler()
struct completion eh_done
init_completion(eh_done)
pci_channel_offline()
wait_for_completion_timeout(eh_done)
sym2_io_resume()
complete(eh_done)--- drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/sym53c8xx_2/sym_glue.c +1 -1
@@ -1874,7 +1874,7 @@ static void sym2_io_resume(struct pci_dev *pdev)spin_lock_irq (shost->host_lock);if (sym_data->io_reset) -complete_all (sym_data->io_reset); +complete (sym_data->io_reset);spin_unlock_irq (shost->host_lock); }
Signature · 1 line
2.7.4
PATCH 3/3 virtio_scsi: use complete() instead complete_all()
In reply to Daniel WagnerFrom: Daniel Wagner <[email protected]>
There is only one waiter for the completion, therefore there is no need to use complete_all(). Let's make that clear by using complete() instead of complete_all().
The usage pattern of the completion is:
waiter context waker context
virtscsi_tmf()
DECLARE_COMPLETION_ONSTACK()
virtscsi_kick_cmd()
wait_for_completion()
virtscsi_complete_free()
complete()
--- drivers/scsi/virtio_scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/virtio_scsi.c +1 -1
@@ -258,7 +258,7 @@ static void virtscsi_complete_free(struct virtio_scsi *vscsi, void *buf)struct virtio_scsi_cmd *cmd = buf;if (cmd->comp) -complete_all (cmd->comp); +complete (cmd->comp); }static void virtscsi_ctrl_done (struct virtqueue *vq)
Signature · 1 line
2.7.4
Re: [PATCH 1/3] csiostor: fix completion usage
In reply to Daniel WagnerLooks good,
Re: [PATCH 2/3] sym53c8xx_2: use complete() instead complete_all()
In reply to Daniel WagnerLooks good,
Re: [PATCH 3/3] virtio_scsi: use complete() instead complete_all()
In reply to Daniel WagnerLooks good,
Martin K. Petersen
AppliedQuoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Daniel" == Daniel Wagner <[email protected]> writes:
Daniel> Using complete_all() is not wrong per se but it suggest that Daniel> there might be more than one waiter. For -rt I am reviewing all Daniel> complete_all() users and would like to leave only the real ones Daniel> in the tree. The main problem for -rt about complete_all() is Daniel> that it can be uses inside IRQ context and that can lead to Daniel> unbounded amount work inside the interrupt handler. That is a no Daniel> no for -rt.
Daniel> The patches grouped per subsystem and in small batches to allow Daniel> reviewing.
Applied to 4.9/scsi-queue.
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering