From: Greg Kroah-Hartman Date: Wed, 12 May 2021 11:01:08 +0000 (+0200) Subject: 4.9-stable patches X-Git-Tag: v5.4.119~38 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=520b0cf9edac8f35e67ab6eaf2a4e1f8c716c049;p=thirdparty%2Fkernel%2Fstable-queue.git 4.9-stable patches added patches: usb-gadget-pch_udc-revert-d3cb25a12138-completely.patch --- diff --git a/queue-4.9/series b/queue-4.9/series index ea873943ab8..551ead7218a 100644 --- a/queue-4.9/series +++ b/queue-4.9/series @@ -92,3 +92,4 @@ alsa-hda-realtek-remove-redundant-entry-for-alc861-haier-uniwill-devices.patch kvm-s390-vsie-correctly-handle-mvpg-when-in-vsie.patch kvm-s390-vsie-fix-mvpg-handling-for-prefixing-and-mso.patch kvm-s390-split-kvm_s390_real_to_abs.patch +usb-gadget-pch_udc-revert-d3cb25a12138-completely.patch diff --git a/queue-4.9/usb-gadget-pch_udc-revert-d3cb25a12138-completely.patch b/queue-4.9/usb-gadget-pch_udc-revert-d3cb25a12138-completely.patch new file mode 100644 index 00000000000..bea40376a26 --- /dev/null +++ b/queue-4.9/usb-gadget-pch_udc-revert-d3cb25a12138-completely.patch @@ -0,0 +1,83 @@ +From 50a318cc9b54a36f00beadf77e578a50f3620477 Mon Sep 17 00:00:00 2001 +From: Andy Shevchenko +Date: Tue, 23 Mar 2021 17:36:24 +0200 +Subject: usb: gadget: pch_udc: Revert d3cb25a12138 completely + +From: Andy Shevchenko + +commit 50a318cc9b54a36f00beadf77e578a50f3620477 upstream. + +The commit d3cb25a12138 ("usb: gadget: udc: fix spin_lock in pch_udc") +obviously was not thought through and had made the situation even worse +than it was before. Two changes after almost reverted it. but a few +leftovers have been left as it. With this revert d3cb25a12138 completely. + +While at it, narrow down the scope of unlocked section to prevent +potential race when prot_stall is assigned. + +Fixes: d3cb25a12138 ("usb: gadget: udc: fix spin_lock in pch_udc") +Fixes: 9903b6bedd38 ("usb: gadget: pch-udc: fix lock") +Fixes: 1d23d16a88e6 ("usb: gadget: pch_udc: reorder spin_[un]lock to avoid deadlock") +Cc: Iago Abal +Signed-off-by: Andy Shevchenko +Link: https://lore.kernel.org/r/20210323153626.54908-5-andriy.shevchenko@linux.intel.com +Signed-off-by: Greg Kroah-Hartman +--- + drivers/usb/gadget/udc/pch_udc.c | 17 +++++++++++++---- + 1 file changed, 13 insertions(+), 4 deletions(-) + +--- a/drivers/usb/gadget/udc/pch_udc.c ++++ b/drivers/usb/gadget/udc/pch_udc.c +@@ -604,18 +604,22 @@ static void pch_udc_reconnect(struct pch + static inline void pch_udc_vbus_session(struct pch_udc_dev *dev, + int is_active) + { ++ unsigned long iflags; ++ ++ spin_lock_irqsave(&dev->lock, iflags); + if (is_active) { + pch_udc_reconnect(dev); + dev->vbus_session = 1; + } else { + if (dev->driver && dev->driver->disconnect) { +- spin_lock(&dev->lock); ++ spin_unlock_irqrestore(&dev->lock, iflags); + dev->driver->disconnect(&dev->gadget); +- spin_unlock(&dev->lock); ++ spin_lock_irqsave(&dev->lock, iflags); + } + pch_udc_set_disconnect(dev); + dev->vbus_session = 0; + } ++ spin_unlock_irqrestore(&dev->lock, iflags); + } + + /** +@@ -1172,20 +1176,25 @@ static int pch_udc_pcd_selfpowered(struc + static int pch_udc_pcd_pullup(struct usb_gadget *gadget, int is_on) + { + struct pch_udc_dev *dev; ++ unsigned long iflags; + + if (!gadget) + return -EINVAL; ++ + dev = container_of(gadget, struct pch_udc_dev, gadget); ++ ++ spin_lock_irqsave(&dev->lock, iflags); + if (is_on) { + pch_udc_reconnect(dev); + } else { + if (dev->driver && dev->driver->disconnect) { +- spin_lock(&dev->lock); ++ spin_unlock_irqrestore(&dev->lock, iflags); + dev->driver->disconnect(&dev->gadget); +- spin_unlock(&dev->lock); ++ spin_lock_irqsave(&dev->lock, iflags); + } + pch_udc_set_disconnect(dev); + } ++ spin_unlock_irqrestore(&dev->lock, iflags); + + return 0; + }