public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.4 01/30] usb: usbtest: use irqsave() in USB's complete callback
@ 2018-09-07  0:38 Sasha Levin
  2018-09-07  0:38 ` [PATCH AUTOSEL 4.4 02/30] iommu/arm-smmu-v3: sync the OVACKFLG to PRIQ consumer register Sasha Levin
                   ` (29 more replies)
  0 siblings, 30 replies; 31+ messages in thread
From: Sasha Levin @ 2018-09-07  0:38 UTC (permalink / raw)
  To: stable@vger.kernel.org, linux-kernel@vger.kernel.org
  Cc: Sebastian Andrzej Siewior, Greg Kroah-Hartman, Sasha Levin

From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

[ Upstream commit 6f3fde684d0232e66ada3410f016a58e09a87689 ]

The USB completion callback does not disable interrupts while acquiring
the lock. We want to remove the local_irq_disable() invocation from
__usb_hcd_giveback_urb() and therefore it is required for the callback
handler to disable the interrupts while acquiring the lock.
The callback may be invoked either in IRQ or BH context depending on the
USB host controller.
Use the _irqsave() variant of the locking primitives.

Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/usb/misc/usbtest.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/usb/misc/usbtest.c b/drivers/usb/misc/usbtest.c
index bc92a498ec03..4632a29d5403 100644
--- a/drivers/usb/misc/usbtest.c
+++ b/drivers/usb/misc/usbtest.c
@@ -1053,11 +1053,12 @@ static void ctrl_complete(struct urb *urb)
 	struct usb_ctrlrequest	*reqp;
 	struct subcase		*subcase;
 	int			status = urb->status;
+	unsigned long		flags;
 
 	reqp = (struct usb_ctrlrequest *)urb->setup_packet;
 	subcase = container_of(reqp, struct subcase, setup);
 
-	spin_lock(&ctx->lock);
+	spin_lock_irqsave(&ctx->lock, flags);
 	ctx->count--;
 	ctx->pending--;
 
@@ -1156,7 +1157,7 @@ static void ctrl_complete(struct urb *urb)
 	/* signal completion when nothing's queued */
 	if (ctx->pending == 0)
 		complete(&ctx->complete);
-	spin_unlock(&ctx->lock);
+	spin_unlock_irqrestore(&ctx->lock, flags);
 }
 
 static int
@@ -1832,8 +1833,9 @@ struct transfer_context {
 static void complicated_callback(struct urb *urb)
 {
 	struct transfer_context	*ctx = urb->context;
+	unsigned long flags;
 
-	spin_lock(&ctx->lock);
+	spin_lock_irqsave(&ctx->lock, flags);
 	ctx->count--;
 
 	ctx->packet_count += urb->number_of_packets;
@@ -1873,7 +1875,7 @@ static void complicated_callback(struct urb *urb)
 		complete(&ctx->done);
 	}
 done:
-	spin_unlock(&ctx->lock);
+	spin_unlock_irqrestore(&ctx->lock, flags);
 }
 
 static struct urb *iso_alloc_urb(
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2018-09-07  5:43 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-07  0:38 [PATCH AUTOSEL 4.4 01/30] usb: usbtest: use irqsave() in USB's complete callback Sasha Levin
2018-09-07  0:38 ` [PATCH AUTOSEL 4.4 02/30] iommu/arm-smmu-v3: sync the OVACKFLG to PRIQ consumer register Sasha Levin
2018-09-07  0:38 ` [PATCH AUTOSEL 4.4 03/30] ALSA: msnd: Fix the default sample sizes Sasha Levin
2018-09-07  0:38 ` [PATCH AUTOSEL 4.4 04/30] ALSA: usb-audio: Fix multiple definitions in AU0828_DEVICE() macro Sasha Levin
2018-09-07  0:38 ` [PATCH AUTOSEL 4.4 05/30] xfrm: fix 'passing zero to ERR_PTR()' warning Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 07/30] clk: imx6ul: fix missing of_node_put() Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 06/30] gfs2: Special-case rindex for gfs2_grow Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 08/30] kbuild: add .DELETE_ON_ERROR special target Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 09/30] dmaengine: pl330: fix irq race with terminate_all Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 10/30] MIPS: ath79: fix system restart Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 11/30] media: videobuf2-core: check for q->error in vb2_core_qbuf() Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 12/30] mtd/maps: fix solutionengine.c printk format warnings Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 13/30] gfs2: Don't reject a supposedly full bitmap if we have blocks reserved Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 14/30] iio: ad9523: Fix displayed phase Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 15/30] fbdev: omapfb: off by one in omapfb_register_client() Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 16/30] video: goldfishfb: fix memory leak on driver remove Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 17/30] fbdev/via: fix defined but not used warning Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 18/30] perf powerpc: Fix callchain ip filtering when return address is in a register Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 19/30] fbdev: Distinguish between interlaced and progressive modes Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 20/30] ARM: exynos: Clear global variable on init error path Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 21/30] perf powerpc: Fix callchain ip filtering Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 22/30] powerpc/powernv: opal_put_chars partial write fix Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 23/30] MIPS: jz4740: Bump zload address Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 25/30] xen-netfront: fix queue name setting Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 24/30] mac80211: restrict delayed tailroom needed decrement Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 26/30] arm64: dts: qcom: db410c: Fix Bluetooth LED trigger Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 27/30] s390/qeth: fix race in used-buffer accounting Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 28/30] s390/qeth: reset layer2 attribute on layer switch Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 29/30] platform/x86: toshiba_acpi: Fix defined but not used build warnings Sasha Levin
2018-09-07  0:39 ` [PATCH AUTOSEL 4.4 30/30] crypto: sharah - Unregister correct algorithms for SAHARA 3 Sasha Levin
2018-09-07  5:43 ` [PATCH AUTOSEL 4.4 01/30] usb: usbtest: use irqsave() in USB's complete callback Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox