]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.6.4/usb-xhci-plat-properly-handle-probe-deferral-for-devm_clk_get.patch
5.0-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.6.4 / usb-xhci-plat-properly-handle-probe-deferral-for-devm_clk_get.patch
1 From de95c40d5beaa47f6dc8fe9ac4159b4672b51523 Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Wed, 1 Jun 2016 18:09:09 +0300
4 Subject: usb: xhci-plat: properly handle probe deferral for devm_clk_get()
5
6 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
7
8 commit de95c40d5beaa47f6dc8fe9ac4159b4672b51523 upstream.
9
10 On some platforms, the clocks might be registered by a platform
11 driver. When this is the case, the clock platform driver may very well
12 be probed after xhci-plat, in which case the first probe() invocation
13 of xhci-plat will receive -EPROBE_DEFER as the return value of
14 devm_clk_get().
15
16 The current code handles that as a normal error, and simply assumes
17 that this means that the system doesn't have a clock for the XHCI
18 controller, and continues probing without calling
19 clk_prepare_enable(). Unfortunately, this doesn't work on systems
20 where the XHCI controller does have a clock, but that clock is
21 provided by another platform driver. In order to fix this situation,
22 we handle the -EPROBE_DEFER error condition specially, and abort the
23 XHCI controller probe(). It will be retried later automatically, the
24 clock will be available, devm_clk_get() will succeed, and the probe()
25 will continue with the clock prepared and enabled as expected.
26
27 In practice, such issue is seen on the ARM64 Marvell 7K/8K platform,
28 where the clocks are registered by a platform driver.
29
30 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
31 Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
32 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
33
34 ---
35 drivers/usb/host/xhci-plat.c | 3 +++
36 1 file changed, 3 insertions(+)
37
38 --- a/drivers/usb/host/xhci-plat.c
39 +++ b/drivers/usb/host/xhci-plat.c
40 @@ -194,6 +194,9 @@ static int xhci_plat_probe(struct platfo
41 ret = clk_prepare_enable(clk);
42 if (ret)
43 goto put_hcd;
44 + } else if (PTR_ERR(clk) == -EPROBE_DEFER) {
45 + ret = -EPROBE_DEFER;
46 + goto put_hcd;
47 }
48
49 xhci = hcd_to_xhci(hcd);