FAILED: patch "[PATCH] USB: chipidea: fix interrupt deadlock" failed to apply to 4.14-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 9aaa81c3366e8393a62374e3a1c67c69edc07b8a Mon Sep 17 00:00:00 2001
From: Johan Hovold <[email protected]>
Date: Thu, 21 Oct 2021 10:34:47 +0200
Subject: [PATCH] USB: chipidea: fix interrupt deadlock
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.
drivers/usb/chipidea/core.c +16 -7
@@ -514,7 +514,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 ;
@@ -567,6 +567,15 @@ static irqreturn_t ci_irq(int irq, void *data)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) {
@@ -576,7 +585,7 @@ static int ci_cable_notifier(struct notifier_block *nb, unsigned long event, cbl->connected = event; cbl->changed = true; -ci_irq (ci->irq, ci); +ci_irq (ci);return NOTIFY_DONE ; }
@@ -617,7 +626,7 @@ static int ci_usb_role_switch_set(struct usb_role_switch *sw,if (cable) { cable->changed = true; cable->connected = false; -ci_irq (ci->irq, ci); +ci_irq (ci);spin_unlock_irqrestore (&ci->lock, flags);if (ci->wq && role !=USB_ROLE_NONE )flush_workqueue (ci->wq);
@@ -635,7 +644,7 @@ static int ci_usb_role_switch_set(struct usb_role_switch *sw,if (cable) { cable->changed = true; cable->connected = true; -ci_irq (ci->irq, ci); +ci_irq (ci); }spin_unlock_irqrestore (&ci->lock, flags);pm_runtime_put_sync (ci->dev);
@@ -1174,7 +1183,7 @@ static int ci_hdrc_probe(struct platform_device *pdev) } } - 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;
@@ -1295,11 +1304,11 @@ static void ci_extcon_wakeup_int(struct ci_hdrc *ci)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)