From 649e4bf27ae4546d14f9d0c8ea255d95ea812b3f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 15 Nov 2021 13:28:52 +0100 Subject: [PATCH] 4.14-stable patches added patches: usb-chipidea-fix-interrupt-deadlock.patch --- queue-4.14/series | 1 + .../usb-chipidea-fix-interrupt-deadlock.patch | 88 +++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 queue-4.14/usb-chipidea-fix-interrupt-deadlock.patch diff --git a/queue-4.14/series b/queue-4.14/series index 1d99666d430..9796bc2cedc 100644 --- a/queue-4.14/series +++ b/queue-4.14/series @@ -189,3 +189,4 @@ mm-zsmalloc.c-close-race-window-between-zs_pool_dec_.patch llc-fix-out-of-bound-array-index-in-llc_sk_dev_hash.patch nfc-pn533-fix-double-free-when-pn533_fill_fragment_s.patch vsock-prevent-unnecessary-refcnt-inc-for-nonblocking.patch +usb-chipidea-fix-interrupt-deadlock.patch diff --git a/queue-4.14/usb-chipidea-fix-interrupt-deadlock.patch b/queue-4.14/usb-chipidea-fix-interrupt-deadlock.patch new file mode 100644 index 00000000000..db4c58d5814 --- /dev/null +++ b/queue-4.14/usb-chipidea-fix-interrupt-deadlock.patch @@ -0,0 +1,88 @@ +From 9aaa81c3366e8393a62374e3a1c67c69edc07b8a Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Thu, 21 Oct 2021 10:34:47 +0200 +Subject: USB: chipidea: fix interrupt deadlock + +From: Johan Hovold + +commit 9aaa81c3366e8393a62374e3a1c67c69edc07b8a upstream. + +Chipidea core was calling the interrupt handler from non-IRQ context +with interrupts enabled, something which can lead to a deadlock if +there's an actual interrupt trying to take a lock that's already held +(e.g. the controller lock in udc_irq()). + +Add a wrapper that can be used to fake interrupts instead of calling the +handler directly. + +Fixes: 3ecb3e09b042 ("usb: chipidea: Use extcon framework for VBUS and ID detect") +Fixes: 876d4e1e8298 ("usb: chipidea: core: add wakeup support for extcon") +Cc: Peter Chen +Cc: stable@vger.kernel.org # 4.4 +Signed-off-by: Johan Hovold +Link: https://lore.kernel.org/r/20211021083447.20078-1-johan@kernel.org +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/usb/chipidea/core.c | 19 ++++++++++++++----- + 1 file changed, 14 insertions(+), 5 deletions(-) + +--- a/drivers/usb/chipidea/core.c ++++ b/drivers/usb/chipidea/core.c +@@ -535,7 +535,7 @@ int hw_device_reset(struct ci_hdrc *ci) + return 0; + } + +-static irqreturn_t ci_irq(int irq, void *data) ++static irqreturn_t ci_irq_handler(int irq, void *data) + { + struct ci_hdrc *ci = data; + irqreturn_t ret = IRQ_NONE; +@@ -588,6 +588,15 @@ static irqreturn_t ci_irq(int irq, void + return ret; + } + ++static void ci_irq(struct ci_hdrc *ci) ++{ ++ unsigned long flags; ++ ++ local_irq_save(flags); ++ ci_irq_handler(ci->irq, ci); ++ local_irq_restore(flags); ++} ++ + static int ci_cable_notifier(struct notifier_block *nb, unsigned long event, + void *ptr) + { +@@ -597,7 +606,7 @@ static int ci_cable_notifier(struct noti + cbl->connected = event; + cbl->changed = true; + +- ci_irq(ci->irq, ci); ++ ci_irq(ci); + return NOTIFY_DONE; + } + +@@ -1051,7 +1060,7 @@ static int ci_hdrc_probe(struct platform + } + } + +- ret = devm_request_irq(dev, ci->irq, ci_irq, IRQF_SHARED, ++ ret = devm_request_irq(dev, ci->irq, ci_irq_handler, IRQF_SHARED, + ci->platdata->name, ci); + if (ret) + goto stop; +@@ -1175,11 +1184,11 @@ static void ci_extcon_wakeup_int(struct + + if (!IS_ERR(cable_id->edev) && ci->is_otg && + (otgsc & OTGSC_IDIE) && (otgsc & OTGSC_IDIS)) +- ci_irq(ci->irq, ci); ++ ci_irq(ci); + + if (!IS_ERR(cable_vbus->edev) && ci->is_otg && + (otgsc & OTGSC_BSVIE) && (otgsc & OTGSC_BSVIS)) +- ci_irq(ci->irq, ci); ++ ci_irq(ci); + } + + static int ci_controller_resume(struct device *dev) -- 2.47.2