Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1482275 > unrolled thread

[PATCH 0/3] wireless: Use complete() instead complete_all()

Started byDaniel Wagner <wagi@monom.org>
First post2016-09-13 11:00 +0200
Last post2016-09-14 19:30 +0200
Articles 7 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 0/3] wireless: Use complete() instead complete_all() Daniel Wagner <wagi@monom.org> - 2016-09-13 11:00 +0200
    [PATCH 1/3] csiostor: fix completion usage Daniel Wagner <wagi@monom.org> - 2016-09-13 11:00 +0200
      Re: [PATCH 1/3] csiostor: fix completion usage Christoph Hellwig <hch@infradead.org> - 2016-09-14 09:30 +0200
    [PATCH 2/3] sym53c8xx_2: use complete() instead complete_all() Daniel Wagner <wagi@monom.org> - 2016-09-13 11:00 +0200
    [PATCH 3/3] virtio_scsi: use complete() instead complete_all() Daniel Wagner <wagi@monom.org> - 2016-09-13 11:00 +0200
      Re: [PATCH 3/3] virtio_scsi: use complete() instead complete_all() Christoph Hellwig <hch@infradead.org> - 2016-09-14 09:30 +0200
    Re: [PATCH 0/3] wireless: Use complete() instead complete_all() "Martin K. Petersen" <martin.petersen@oracle.com> - 2016-09-14 19:30 +0200

#1482275 — [PATCH 0/3] wireless: Use complete() instead complete_all()

FromDaniel Wagner <wagi@monom.org>
Date2016-09-13 11:00 +0200
Subject[PATCH 0/3] wireless: Use complete() instead complete_all()
Message-ID<sgRJo-7Xu-11@gated-at.bofh.it>
From: Daniel Wagner <daniel.wagner@bmw-carit.de>

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(-)

-- 
2.7.4

[toc] | [next] | [standalone]


#1482280 — [PATCH 1/3] csiostor: fix completion usage

FromDaniel Wagner <wagi@monom.org>
Date2016-09-13 11:00 +0200
Subject[PATCH 1/3] csiostor: fix completion usage
Message-ID<sgRJp-7Xu-55@gated-at.bofh.it>
In reply to#1482275
From: Daniel Wagner <daniel.wagner@bmw-carit.de>

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()

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
---
 drivers/scsi/csiostor/csio_scsi.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/scsi/csiostor/csio_scsi.c b/drivers/scsi/csiostor/csio_scsi.c
index c2a6f9f..89a52b9 100644
--- a/drivers/scsi/csiostor/csio_scsi.c
+++ b/drivers/scsi/csiostor/csio_scsi.c
@@ -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 */
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1482982 — Re: [PATCH 1/3] csiostor: fix completion usage

FromChristoph Hellwig <hch@infradead.org>
Date2016-09-14 09:30 +0200
SubjectRe: [PATCH 1/3] csiostor: fix completion usage
Message-ID<shcNP-6gS-23@gated-at.bofh.it>
In reply to#1482280
Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

[toc] | [prev] | [next] | [standalone]


#1482281 — [PATCH 2/3] sym53c8xx_2: use complete() instead complete_all()

FromDaniel Wagner <wagi@monom.org>
Date2016-09-13 11:00 +0200
Subject[PATCH 2/3] sym53c8xx_2: use complete() instead complete_all()
Message-ID<sgRJp-7Xu-47@gated-at.bofh.it>
In reply to#1482275
From: Daniel Wagner <daniel.wagner@bmw-carit.de>

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)

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
---
 drivers/scsi/sym53c8xx_2/sym_glue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/sym53c8xx_2/sym_glue.c b/drivers/scsi/sym53c8xx_2/sym_glue.c
index 5d00e51..d32e3ba 100644
--- a/drivers/scsi/sym53c8xx_2/sym_glue.c
+++ b/drivers/scsi/sym53c8xx_2/sym_glue.c
@@ -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);
 }
 
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1482282 — [PATCH 3/3] virtio_scsi: use complete() instead complete_all()

FromDaniel Wagner <wagi@monom.org>
Date2016-09-13 11:00 +0200
Subject[PATCH 3/3] virtio_scsi: use complete() instead complete_all()
Message-ID<sgRJp-7Xu-53@gated-at.bofh.it>
In reply to#1482275
From: Daniel Wagner <daniel.wagner@bmw-carit.de>

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()

Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
---
 drivers/scsi/virtio_scsi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c
index 7dbbb29..86924ff 100644
--- a/drivers/scsi/virtio_scsi.c
+++ b/drivers/scsi/virtio_scsi.c
@@ -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)
-- 
2.7.4

[toc] | [prev] | [next] | [standalone]


#1482976 — Re: [PATCH 3/3] virtio_scsi: use complete() instead complete_all()

FromChristoph Hellwig <hch@infradead.org>
Date2016-09-14 09:30 +0200
SubjectRe: [PATCH 3/3] virtio_scsi: use complete() instead complete_all()
Message-ID<shcNP-6gS-5@gated-at.bofh.it>
In reply to#1482282
Looks good,

Reviewed-by: Christoph Hellwig <hch@lst.de>

[toc] | [prev] | [next] | [standalone]


#1483503

From"Martin K. Petersen" <martin.petersen@oracle.com>
Date2016-09-14 19:30 +0200
Message-ID<shmau-3Iu-19@gated-at.bofh.it>
In reply to#1482275
>>>>> "Daniel" == Daniel Wagner <wagi@monom.org> 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.

-- 
Martin K. Petersen	Oracle Linux Engineering

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web