]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
USB: chipidea: fix interrupt deadlock
authorJohan Hovold <johan@kernel.org>
Thu, 21 Oct 2021 08:34:47 +0000 (10:34 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 26 Nov 2021 10:58:41 +0000 (11:58 +0100)
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 <peter.chen@kernel.org>
Cc: stable@vger.kernel.org # 4.4
Signed-off-by: Johan Hovold <johan@kernel.org>
Link: https://lore.kernel.org/r/20211021083447.20078-1-johan@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/chipidea/core.c

index e104c99b3a1fcf1d825a6ee06c1ee912d0e630b2..9b3260a7cd2cc8fc2214b1d4af5442173d14a5b5 100644 (file)
@@ -518,7 +518,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;
@@ -571,6 +571,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_vbus_notifier(struct notifier_block *nb, unsigned long event,
                            void *ptr)
 {
@@ -584,7 +593,7 @@ static int ci_vbus_notifier(struct notifier_block *nb, unsigned long event,
 
        vbus->changed = true;
 
-       ci_irq(ci->irq, ci);
+       ci_irq(ci);
        return NOTIFY_DONE;
 }
 
@@ -601,7 +610,7 @@ static int ci_id_notifier(struct notifier_block *nb, unsigned long event,
 
        id->changed = true;
 
-       ci_irq(ci->irq, ci);
+       ci_irq(ci);
        return NOTIFY_DONE;
 }
 
@@ -1023,7 +1032,7 @@ static int ci_hdrc_probe(struct platform_device *pdev)
        }
 
        platform_set_drvdata(pdev, ci);
-       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;
@@ -1138,11 +1147,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)