* [PATCH 0/2] media: Use complete() instead complete_all()
@ 2016-09-16 11:18 Daniel Wagner
2016-09-16 11:18 ` [PATCH 1/2] [media] imon: use complete() instead of complete_all() Daniel Wagner
2016-09-16 11:18 ` [PATCH 2/2] [media] lirc_imon: use complete() instead complete_all() Daniel Wagner
0 siblings, 2 replies; 3+ messages in thread
From: Daniel Wagner @ 2016-09-16 11:18 UTC (permalink / raw)
To: linux-media
Cc: Greg Kroah-Hartman, Jarod Wilson, Mauro Carvalho Chehab,
linux-kernel, Daniel Wagner
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.
cheers,
daniel
Daniel Wagner (2):
[media] imon: use complete() instead of complete_all()
[media] lirc_imon: use complete() instead complete_all()
drivers/media/rc/imon.c | 6 ++++--
drivers/staging/media/lirc/lirc_imon.c | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] [media] imon: use complete() instead of complete_all()
2016-09-16 11:18 [PATCH 0/2] media: Use complete() instead complete_all() Daniel Wagner
@ 2016-09-16 11:18 ` Daniel Wagner
2016-09-16 11:18 ` [PATCH 2/2] [media] lirc_imon: use complete() instead complete_all() Daniel Wagner
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Wagner @ 2016-09-16 11:18 UTC (permalink / raw)
To: linux-media
Cc: Greg Kroah-Hartman, Jarod Wilson, Mauro Carvalho Chehab,
linux-kernel, Daniel Wagner
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().
While we are at it, we do a small optimization with the reinitialization
of the completion before we use it.
The usage pattern of the completion is:
waiter context waker context
send_packet()
init_completion()
usb_submit_urb()
wait_for_completion_interruptible()
usb_tx_callback()
complete()
imon_disonnect()
complete()
Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
---
drivers/media/rc/imon.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/media/rc/imon.c b/drivers/media/rc/imon.c
index 65f80b8..38cdfd6 100644
--- a/drivers/media/rc/imon.c
+++ b/drivers/media/rc/imon.c
@@ -611,7 +611,7 @@ static int send_packet(struct imon_context *ictx)
ictx->tx_urb->actual_length = 0;
}
- init_completion(&ictx->tx.finished);
+ reinit_completion(&ictx->tx.finished);
ictx->tx.busy = true;
smp_rmb(); /* ensure later readers know we're busy */
@@ -2233,6 +2233,8 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf,
ictx->tx_urb = tx_urb;
ictx->rf_device = false;
+ init_completion(&ictx->tx.finished);
+
ictx->vendor = le16_to_cpu(ictx->usbdev_intf0->descriptor.idVendor);
ictx->product = le16_to_cpu(ictx->usbdev_intf0->descriptor.idProduct);
@@ -2511,7 +2513,7 @@ static void imon_disconnect(struct usb_interface *interface)
/* Abort ongoing write */
if (ictx->tx.busy) {
usb_kill_urb(ictx->tx_urb);
- complete_all(&ictx->tx.finished);
+ complete(&ictx->tx.finished);
}
if (ifnum == 0) {
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] [media] lirc_imon: use complete() instead complete_all()
2016-09-16 11:18 [PATCH 0/2] media: Use complete() instead complete_all() Daniel Wagner
2016-09-16 11:18 ` [PATCH 1/2] [media] imon: use complete() instead of complete_all() Daniel Wagner
@ 2016-09-16 11:18 ` Daniel Wagner
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Wagner @ 2016-09-16 11:18 UTC (permalink / raw)
To: linux-media
Cc: Greg Kroah-Hartman, Jarod Wilson, Mauro Carvalho Chehab,
linux-kernel, Daniel Wagner
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().
While we are at it, we do a small optimization with the
reinitialization of the completion before we use it.
The usage pattern of the completion is:
waiter context waker context
send_packet()
reinit_completion()
usb_sumbit_urb()
wait_for_completion_interruptible()
usb_tx_callback()
complete()
imon_disconnect()
complete()
Signed-off-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
---
drivers/staging/media/lirc/lirc_imon.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c
index ff1926c..c449434 100644
--- a/drivers/staging/media/lirc/lirc_imon.c
+++ b/drivers/staging/media/lirc/lirc_imon.c
@@ -336,7 +336,7 @@ static int send_packet(struct imon_context *context)
context->tx_urb->actual_length = 0;
- init_completion(&context->tx.finished);
+ reinit_completion(&context->tx.finished);
atomic_set(&context->tx.busy, 1);
retval = usb_submit_urb(context->tx_urb, GFP_KERNEL);
@@ -499,6 +499,8 @@ static int ir_open(void *data)
context->rx.initial_space = 1;
context->rx.prev_bit = 0;
+ init_completion(&context->tx.finished);
+
context->ir_isopen = 1;
dev_info(context->driver->dev, "IR port opened\n");
@@ -937,7 +939,7 @@ static void imon_disconnect(struct usb_interface *interface)
/* Abort ongoing write */
if (atomic_read(&context->tx.busy)) {
usb_kill_urb(context->tx_urb);
- complete_all(&context->tx.finished);
+ complete(&context->tx.finished);
}
context->dev_present = 0;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-16 11:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-16 11:18 [PATCH 0/2] media: Use complete() instead complete_all() Daniel Wagner
2016-09-16 11:18 ` [PATCH 1/2] [media] imon: use complete() instead of complete_all() Daniel Wagner
2016-09-16 11:18 ` [PATCH 2/2] [media] lirc_imon: use complete() instead complete_all() Daniel Wagner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).