From 46e3b9492ae04c5144bd155cd7981b0ab189318b Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sun, 29 May 2016 22:05:54 +0100 Subject: [PATCH] dwc3-exynos: Fix deferred probing storm Closes: #823552; thanks to Steinar H. Gunderson --- debian/changelog | 2 + ...c3-exynos-fix-deferred-probing-storm.patch | 81 +++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 84 insertions(+) create mode 100644 debian/patches/bugfix/arm/dwc3-exynos-fix-deferred-probing-storm.patch diff --git a/debian/changelog b/debian/changelog index e0c0a3e01..60b2feaa9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -99,6 +99,8 @@ linux (4.5.5-1) UNRELEASED; urgency=medium * ALSA: timer: Fix leak in SNDRV_TIMER_IOCTL_PARAMS (CVE-2016-4569) * ALSA: timer: Fix leak in events via snd_timer_user_ccallback or snd_timer_user_tinterrupt (CVE-2016-4578) + * dwc3-exynos: Fix deferred probing storm (Closes: #823552; thanks to + Steinar H. Gunderson) [ Roger Shimizu ] * [armhf] Enable SENSORS_PWM_FAN / PWM_SAMSUNG as module, as recommended by diff --git a/debian/patches/bugfix/arm/dwc3-exynos-fix-deferred-probing-storm.patch b/debian/patches/bugfix/arm/dwc3-exynos-fix-deferred-probing-storm.patch new file mode 100644 index 000000000..08d894fc4 --- /dev/null +++ b/debian/patches/bugfix/arm/dwc3-exynos-fix-deferred-probing-storm.patch @@ -0,0 +1,81 @@ +From: "Steinar H. Gunderson" +Date: Tue, 24 May 2016 20:13:15 +0200 +Forwarded: http://mid.gmane.org/E1b6Hj3-0001MI-AS@pannekake.samfundet.no +Subject: dwc3-exynos: Fix deferred probing storm. +Bug-Debian: https://bugs.debian.org/823552 + +dwc3-exynos has two problems during init if the regulators are slow +to come up (for instance if the I2C bus driver is not on the initramfs) +and return probe deferral. First, every time this happens, the driver +leaks the USB phys created; they need to be deallocated on error. + +Second, since the phy devices are created before the regulators fail, +this means that there's a new device to re-trigger deferred probing, +which causes it to essentially go into a busy loop of re-probing the +device until the regulators come up. + +Move the phy creation to after the regulators have succeeded, and also +fix cleanup on failure. On my ODROID XU4 system (with Debian's initramfs +which doesn't contain the I2C driver), this reduces the number of probe +attempts (for each of the two controllers) from more than 2000 to eight. + +Signed-off-by: Steinar H. Gunderson +Reviewed-by: Krzysztof Kozlowski +Reviewed-by: Vivek Gautam +Fixes: d720f057fda4 ("usb: dwc3: exynos: add nop transceiver support") +Cc: +--- + drivers/usb/dwc3/dwc3-exynos.c | 19 +++++++++++-------- + 1 file changed, 11 insertions(+), 8 deletions(-) + +diff --git a/drivers/usb/dwc3/dwc3-exynos.c b/drivers/usb/dwc3/dwc3-exynos.c +index dd5cb55..2f1fb7e 100644 +--- a/drivers/usb/dwc3/dwc3-exynos.c ++++ b/drivers/usb/dwc3/dwc3-exynos.c +@@ -128,12 +128,6 @@ static int dwc3_exynos_probe(struct platform_device *pdev) + + platform_set_drvdata(pdev, exynos); + +- ret = dwc3_exynos_register_phys(exynos); +- if (ret) { +- dev_err(dev, "couldn't register PHYs\n"); +- return ret; +- } +- + exynos->dev = dev; + + exynos->clk = devm_clk_get(dev, "usbdrd30"); +@@ -183,20 +177,29 @@ static int dwc3_exynos_probe(struct platform_device *pdev) + goto err3; + } + ++ ret = dwc3_exynos_register_phys(exynos); ++ if (ret) { ++ dev_err(dev, "couldn't register PHYs\n"); ++ goto err4; ++ } ++ + if (node) { + ret = of_platform_populate(node, NULL, NULL, dev); + if (ret) { + dev_err(dev, "failed to add dwc3 core\n"); +- goto err4; ++ goto err5; + } + } else { + dev_err(dev, "no device node, failed to add dwc3 core\n"); + ret = -ENODEV; +- goto err4; ++ goto err5; + } + + return 0; + ++err5: ++ platform_device_unregister(exynos->usb2_phy); ++ platform_device_unregister(exynos->usb3_phy); + err4: + regulator_disable(exynos->vdd10); + err3: + + diff --git a/debian/patches/series b/debian/patches/series index cfe15c2f0..e58ee645b 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -54,6 +54,7 @@ bugfix/sparc/sparc-implement-and-wire-up-modalias_show-for-vio.patch bugfix/sparc/sparc-implement-and-wire-up-vio_hotplug-for-vio.patch bugfix/x86/revert-sp5100_tco-fix-the-device-check-for-SB800-and.patch bugfix/powerpc/powerpc-fix-sstep-compile-on-powerpcspe.patch +bugfix/arm/dwc3-exynos-fix-deferred-probing-storm.patch # Arch features features/mips/MIPS-increase-MAX-PHYSMEM-BITS-on-Loongson-3-only.patch