diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-01 20:06:09 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-01 20:06:09 -0400 |
commit | 3e75c6de1ac33fe3500f44573d9212dc82c99f59 (patch) | |
tree | ef10932e204ba8a9885051b06d4524d284207d61 /drivers/usb/host | |
parent | cb1595563880a81dab6eab9a5ecb4520d2e76077 (diff) | |
parent | 940ab8f1ef9369da5b58a1bec6820bfd4a7b9042 (diff) |
Merge tag 'usb-3.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB patches from Greg KH:
"Here's the big USB pull request for 3.15-rc1.
The normal set of patches, lots of controller driver updates, and a
smattering of individual USB driver updates as well.
All have been in linux-next for a while"
* tag 'usb-3.15-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: (249 commits)
xhci: Transition maintainership to Mathias Nyman.
USB: disable reset-resume when USB_QUIRK_RESET is set
USB: unbind all interfaces before rebinding any
usb: phy: Add ulpi IDs for SMSC USB3320 and TI TUSB1210
usb: gadget: tcm_usb_gadget: stop format strings
usb: gadget: f_fs: add missing spinlock and mutex unlock
usb: gadget: composite: switch over to ERR_CAST()
usb: gadget: inode: switch over to memdup_user()
usb: gadget: f_subset: switch over to PTR_RET
usb: gadget: lpc32xx_udc: fix wrong clk_put() sequence
USB: keyspan: remove dead debugging code
USB: serial: add missing newlines to dev_<level> messages.
USB: serial: add missing braces
USB: serial: continue to write on errors
USB: serial: continue to read on errors
USB: serial: make bulk_out_size a lower limit
USB: cypress_m8: fix potential scheduling while atomic
devicetree: bindings: document lsi,zevio-usb
usb: chipidea: add support for USB OTG controller on LSI Zevio SoCs
usb: chipidea: imx: Use dev_name() for ci_hdrc name to distinguish USBs
...
Diffstat (limited to 'drivers/usb/host')
-rw-r--r-- | drivers/usb/host/Kconfig | 1 | ||||
-rw-r--r-- | drivers/usb/host/ehci-platform.c | 182 | ||||
-rw-r--r-- | drivers/usb/host/ehci-tegra.c | 4 | ||||
-rw-r--r-- | drivers/usb/host/hwa-hc.c | 42 | ||||
-rw-r--r-- | drivers/usb/host/ohci-platform.c | 199 | ||||
-rw-r--r-- | drivers/usb/host/uhci-platform.c | 1 | ||||
-rw-r--r-- | drivers/usb/host/xhci-hub.c | 8 | ||||
-rw-r--r-- | drivers/usb/host/xhci-mem.c | 212 | ||||
-rw-r--r-- | drivers/usb/host/xhci-pci.c | 18 | ||||
-rw-r--r-- | drivers/usb/host/xhci-plat.c | 4 | ||||
-rw-r--r-- | drivers/usb/host/xhci-ring.c | 146 | ||||
-rw-r--r-- | drivers/usb/host/xhci.c | 33 | ||||
-rw-r--r-- | drivers/usb/host/xhci.h | 5 |
13 files changed, 674 insertions, 181 deletions
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig index a9707da7da0b..e22b82660831 100644 --- a/drivers/usb/host/Kconfig +++ b/drivers/usb/host/Kconfig | |||
@@ -584,7 +584,6 @@ config FHCI_DEBUG | |||
584 | config USB_U132_HCD | 584 | config USB_U132_HCD |
585 | tristate "Elan U132 Adapter Host Controller" | 585 | tristate "Elan U132 Adapter Host Controller" |
586 | depends on USB_FTDI_ELAN | 586 | depends on USB_FTDI_ELAN |
587 | default M | ||
588 | help | 587 | help |
589 | The U132 adapter is a USB to CardBus adapter specifically designed | 588 | The U132 adapter is a USB to CardBus adapter specifically designed |
590 | for PC cards that contain an OHCI host controller. Typical PC cards | 589 | for PC cards that contain an OHCI host controller. Typical PC cards |
diff --git a/drivers/usb/host/ehci-platform.c b/drivers/usb/host/ehci-platform.c index 01536cfd361d..b3a0e11073aa 100644 --- a/drivers/usb/host/ehci-platform.c +++ b/drivers/usb/host/ehci-platform.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright 2007 Steven Brown <sbrown@cortland.com> | 4 | * Copyright 2007 Steven Brown <sbrown@cortland.com> |
5 | * Copyright 2010-2012 Hauke Mehrtens <hauke@hauke-m.de> | 5 | * Copyright 2010-2012 Hauke Mehrtens <hauke@hauke-m.de> |
6 | * Copyright 2014 Hans de Goede <hdegoede@redhat.com> | ||
6 | * | 7 | * |
7 | * Derived from the ohci-ssb driver | 8 | * Derived from the ohci-ssb driver |
8 | * Copyright 2007 Michael Buesch <m@bues.ch> | 9 | * Copyright 2007 Michael Buesch <m@bues.ch> |
@@ -18,6 +19,7 @@ | |||
18 | * | 19 | * |
19 | * Licensed under the GNU/GPL. See COPYING for details. | 20 | * Licensed under the GNU/GPL. See COPYING for details. |
20 | */ | 21 | */ |
22 | #include <linux/clk.h> | ||
21 | #include <linux/dma-mapping.h> | 23 | #include <linux/dma-mapping.h> |
22 | #include <linux/err.h> | 24 | #include <linux/err.h> |
23 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
@@ -25,6 +27,7 @@ | |||
25 | #include <linux/io.h> | 27 | #include <linux/io.h> |
26 | #include <linux/module.h> | 28 | #include <linux/module.h> |
27 | #include <linux/of.h> | 29 | #include <linux/of.h> |
30 | #include <linux/phy/phy.h> | ||
28 | #include <linux/platform_device.h> | 31 | #include <linux/platform_device.h> |
29 | #include <linux/usb.h> | 32 | #include <linux/usb.h> |
30 | #include <linux/usb/hcd.h> | 33 | #include <linux/usb/hcd.h> |
@@ -33,6 +36,13 @@ | |||
33 | #include "ehci.h" | 36 | #include "ehci.h" |
34 | 37 | ||
35 | #define DRIVER_DESC "EHCI generic platform driver" | 38 | #define DRIVER_DESC "EHCI generic platform driver" |
39 | #define EHCI_MAX_CLKS 3 | ||
40 | #define hcd_to_ehci_priv(h) ((struct ehci_platform_priv *)hcd_to_ehci(h)->priv) | ||
41 | |||
42 | struct ehci_platform_priv { | ||
43 | struct clk *clks[EHCI_MAX_CLKS]; | ||
44 | struct phy *phy; | ||
45 | }; | ||
36 | 46 | ||
37 | static const char hcd_name[] = "ehci-platform"; | 47 | static const char hcd_name[] = "ehci-platform"; |
38 | 48 | ||
@@ -45,8 +55,6 @@ static int ehci_platform_reset(struct usb_hcd *hcd) | |||
45 | 55 | ||
46 | hcd->has_tt = pdata->has_tt; | 56 | hcd->has_tt = pdata->has_tt; |
47 | ehci->has_synopsys_hc_bug = pdata->has_synopsys_hc_bug; | 57 | ehci->has_synopsys_hc_bug = pdata->has_synopsys_hc_bug; |
48 | ehci->big_endian_desc = pdata->big_endian_desc; | ||
49 | ehci->big_endian_mmio = pdata->big_endian_mmio; | ||
50 | 58 | ||
51 | if (pdata->pre_setup) { | 59 | if (pdata->pre_setup) { |
52 | retval = pdata->pre_setup(hcd); | 60 | retval = pdata->pre_setup(hcd); |
@@ -64,38 +72,91 @@ static int ehci_platform_reset(struct usb_hcd *hcd) | |||
64 | return 0; | 72 | return 0; |
65 | } | 73 | } |
66 | 74 | ||
75 | static int ehci_platform_power_on(struct platform_device *dev) | ||
76 | { | ||
77 | struct usb_hcd *hcd = platform_get_drvdata(dev); | ||
78 | struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); | ||
79 | int clk, ret; | ||
80 | |||
81 | for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++) { | ||
82 | ret = clk_prepare_enable(priv->clks[clk]); | ||
83 | if (ret) | ||
84 | goto err_disable_clks; | ||
85 | } | ||
86 | |||
87 | if (priv->phy) { | ||
88 | ret = phy_init(priv->phy); | ||
89 | if (ret) | ||
90 | goto err_disable_clks; | ||
91 | |||
92 | ret = phy_power_on(priv->phy); | ||
93 | if (ret) | ||
94 | goto err_exit_phy; | ||
95 | } | ||
96 | |||
97 | return 0; | ||
98 | |||
99 | err_exit_phy: | ||
100 | phy_exit(priv->phy); | ||
101 | err_disable_clks: | ||
102 | while (--clk >= 0) | ||
103 | clk_disable_unprepare(priv->clks[clk]); | ||
104 | |||
105 | return ret; | ||
106 | } | ||
107 | |||
108 | static void ehci_platform_power_off(struct platform_device *dev) | ||
109 | { | ||
110 | struct usb_hcd *hcd = platform_get_drvdata(dev); | ||
111 | struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); | ||
112 | int clk; | ||
113 | |||
114 | if (priv->phy) { | ||
115 | phy_power_off(priv->phy); | ||
116 | phy_exit(priv->phy); | ||
117 | } | ||
118 | |||
119 | for (clk = EHCI_MAX_CLKS - 1; clk >= 0; clk--) | ||
120 | if (priv->clks[clk]) | ||
121 | clk_disable_unprepare(priv->clks[clk]); | ||
122 | } | ||
123 | |||
67 | static struct hc_driver __read_mostly ehci_platform_hc_driver; | 124 | static struct hc_driver __read_mostly ehci_platform_hc_driver; |
68 | 125 | ||
69 | static const struct ehci_driver_overrides platform_overrides __initconst = { | 126 | static const struct ehci_driver_overrides platform_overrides __initconst = { |
70 | .reset = ehci_platform_reset, | 127 | .reset = ehci_platform_reset, |
128 | .extra_priv_size = sizeof(struct ehci_platform_priv), | ||
71 | }; | 129 | }; |
72 | 130 | ||
73 | static struct usb_ehci_pdata ehci_platform_defaults; | 131 | static struct usb_ehci_pdata ehci_platform_defaults = { |
132 | .power_on = ehci_platform_power_on, | ||
133 | .power_suspend = ehci_platform_power_off, | ||
134 | .power_off = ehci_platform_power_off, | ||
135 | }; | ||
74 | 136 | ||
75 | static int ehci_platform_probe(struct platform_device *dev) | 137 | static int ehci_platform_probe(struct platform_device *dev) |
76 | { | 138 | { |
77 | struct usb_hcd *hcd; | 139 | struct usb_hcd *hcd; |
78 | struct resource *res_mem; | 140 | struct resource *res_mem; |
79 | struct usb_ehci_pdata *pdata; | 141 | struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev); |
80 | int irq; | 142 | struct ehci_platform_priv *priv; |
81 | int err; | 143 | struct ehci_hcd *ehci; |
144 | int err, irq, clk = 0; | ||
82 | 145 | ||
83 | if (usb_disabled()) | 146 | if (usb_disabled()) |
84 | return -ENODEV; | 147 | return -ENODEV; |
85 | 148 | ||
86 | /* | 149 | /* |
87 | * use reasonable defaults so platforms don't have to provide these. | 150 | * Use reasonable defaults so platforms don't have to provide these |
88 | * with DT probing on ARM, none of these are set. | 151 | * with DT probing on ARM. |
89 | */ | 152 | */ |
90 | if (!dev_get_platdata(&dev->dev)) | 153 | if (!pdata) |
91 | dev->dev.platform_data = &ehci_platform_defaults; | 154 | pdata = &ehci_platform_defaults; |
92 | 155 | ||
93 | err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); | 156 | err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); |
94 | if (err) | 157 | if (err) |
95 | return err; | 158 | return err; |
96 | 159 | ||
97 | pdata = dev_get_platdata(&dev->dev); | ||
98 | |||
99 | irq = platform_get_irq(dev, 0); | 160 | irq = platform_get_irq(dev, 0); |
100 | if (irq < 0) { | 161 | if (irq < 0) { |
101 | dev_err(&dev->dev, "no irq provided"); | 162 | dev_err(&dev->dev, "no irq provided"); |
@@ -107,17 +168,72 @@ static int ehci_platform_probe(struct platform_device *dev) | |||
107 | return -ENXIO; | 168 | return -ENXIO; |
108 | } | 169 | } |
109 | 170 | ||
171 | hcd = usb_create_hcd(&ehci_platform_hc_driver, &dev->dev, | ||
172 | dev_name(&dev->dev)); | ||
173 | if (!hcd) | ||
174 | return -ENOMEM; | ||
175 | |||
176 | platform_set_drvdata(dev, hcd); | ||
177 | dev->dev.platform_data = pdata; | ||
178 | priv = hcd_to_ehci_priv(hcd); | ||
179 | ehci = hcd_to_ehci(hcd); | ||
180 | |||
181 | if (pdata == &ehci_platform_defaults && dev->dev.of_node) { | ||
182 | if (of_property_read_bool(dev->dev.of_node, "big-endian-regs")) | ||
183 | ehci->big_endian_mmio = 1; | ||
184 | |||
185 | if (of_property_read_bool(dev->dev.of_node, "big-endian-desc")) | ||
186 | ehci->big_endian_desc = 1; | ||
187 | |||
188 | if (of_property_read_bool(dev->dev.of_node, "big-endian")) | ||
189 | ehci->big_endian_mmio = ehci->big_endian_desc = 1; | ||
190 | |||
191 | priv->phy = devm_phy_get(&dev->dev, "usb"); | ||
192 | if (IS_ERR(priv->phy)) { | ||
193 | err = PTR_ERR(priv->phy); | ||
194 | if (err == -EPROBE_DEFER) | ||
195 | goto err_put_hcd; | ||
196 | priv->phy = NULL; | ||
197 | } | ||
198 | |||
199 | for (clk = 0; clk < EHCI_MAX_CLKS; clk++) { | ||
200 | priv->clks[clk] = of_clk_get(dev->dev.of_node, clk); | ||
201 | if (IS_ERR(priv->clks[clk])) { | ||
202 | err = PTR_ERR(priv->clks[clk]); | ||
203 | if (err == -EPROBE_DEFER) | ||
204 | goto err_put_clks; | ||
205 | priv->clks[clk] = NULL; | ||
206 | break; | ||
207 | } | ||
208 | } | ||
209 | } | ||
210 | |||
211 | if (pdata->big_endian_desc) | ||
212 | ehci->big_endian_desc = 1; | ||
213 | if (pdata->big_endian_mmio) | ||
214 | ehci->big_endian_mmio = 1; | ||
215 | |||
216 | #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_MMIO | ||
217 | if (ehci->big_endian_mmio) { | ||
218 | dev_err(&dev->dev, | ||
219 | "Error: CONFIG_USB_EHCI_BIG_ENDIAN_MMIO not set\n"); | ||
220 | err = -EINVAL; | ||
221 | goto err_put_clks; | ||
222 | } | ||
223 | #endif | ||
224 | #ifndef CONFIG_USB_EHCI_BIG_ENDIAN_DESC | ||
225 | if (ehci->big_endian_desc) { | ||
226 | dev_err(&dev->dev, | ||
227 | "Error: CONFIG_USB_EHCI_BIG_ENDIAN_DESC not set\n"); | ||
228 | err = -EINVAL; | ||
229 | goto err_put_clks; | ||
230 | } | ||
231 | #endif | ||
232 | |||
110 | if (pdata->power_on) { | 233 | if (pdata->power_on) { |
111 | err = pdata->power_on(dev); | 234 | err = pdata->power_on(dev); |
112 | if (err < 0) | 235 | if (err < 0) |
113 | return err; | 236 | goto err_put_clks; |
114 | } | ||
115 | |||
116 | hcd = usb_create_hcd(&ehci_platform_hc_driver, &dev->dev, | ||
117 | dev_name(&dev->dev)); | ||
118 | if (!hcd) { | ||
119 | err = -ENOMEM; | ||
120 | goto err_power; | ||
121 | } | 237 | } |
122 | 238 | ||
123 | hcd->rsrc_start = res_mem->start; | 239 | hcd->rsrc_start = res_mem->start; |
@@ -126,22 +242,28 @@ static int ehci_platform_probe(struct platform_device *dev) | |||
126 | hcd->regs = devm_ioremap_resource(&dev->dev, res_mem); | 242 | hcd->regs = devm_ioremap_resource(&dev->dev, res_mem); |
127 | if (IS_ERR(hcd->regs)) { | 243 | if (IS_ERR(hcd->regs)) { |
128 | err = PTR_ERR(hcd->regs); | 244 | err = PTR_ERR(hcd->regs); |
129 | goto err_put_hcd; | 245 | goto err_power; |
130 | } | 246 | } |
131 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | 247 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
132 | if (err) | 248 | if (err) |
133 | goto err_put_hcd; | 249 | goto err_power; |
134 | 250 | ||
135 | device_wakeup_enable(hcd->self.controller); | 251 | device_wakeup_enable(hcd->self.controller); |
136 | platform_set_drvdata(dev, hcd); | 252 | platform_set_drvdata(dev, hcd); |
137 | 253 | ||
138 | return err; | 254 | return err; |
139 | 255 | ||
140 | err_put_hcd: | ||
141 | usb_put_hcd(hcd); | ||
142 | err_power: | 256 | err_power: |
143 | if (pdata->power_off) | 257 | if (pdata->power_off) |
144 | pdata->power_off(dev); | 258 | pdata->power_off(dev); |
259 | err_put_clks: | ||
260 | while (--clk >= 0) | ||
261 | clk_put(priv->clks[clk]); | ||
262 | err_put_hcd: | ||
263 | if (pdata == &ehci_platform_defaults) | ||
264 | dev->dev.platform_data = NULL; | ||
265 | |||
266 | usb_put_hcd(hcd); | ||
145 | 267 | ||
146 | return err; | 268 | return err; |
147 | } | 269 | } |
@@ -150,13 +272,19 @@ static int ehci_platform_remove(struct platform_device *dev) | |||
150 | { | 272 | { |
151 | struct usb_hcd *hcd = platform_get_drvdata(dev); | 273 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
152 | struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev); | 274 | struct usb_ehci_pdata *pdata = dev_get_platdata(&dev->dev); |
275 | struct ehci_platform_priv *priv = hcd_to_ehci_priv(hcd); | ||
276 | int clk; | ||
153 | 277 | ||
154 | usb_remove_hcd(hcd); | 278 | usb_remove_hcd(hcd); |
155 | usb_put_hcd(hcd); | ||
156 | 279 | ||
157 | if (pdata->power_off) | 280 | if (pdata->power_off) |
158 | pdata->power_off(dev); | 281 | pdata->power_off(dev); |
159 | 282 | ||
283 | for (clk = 0; clk < EHCI_MAX_CLKS && priv->clks[clk]; clk++) | ||
284 | clk_put(priv->clks[clk]); | ||
285 | |||
286 | usb_put_hcd(hcd); | ||
287 | |||
160 | if (pdata == &ehci_platform_defaults) | 288 | if (pdata == &ehci_platform_defaults) |
161 | dev->dev.platform_data = NULL; | 289 | dev->dev.platform_data = NULL; |
162 | 290 | ||
@@ -207,8 +335,10 @@ static int ehci_platform_resume(struct device *dev) | |||
207 | static const struct of_device_id vt8500_ehci_ids[] = { | 335 | static const struct of_device_id vt8500_ehci_ids[] = { |
208 | { .compatible = "via,vt8500-ehci", }, | 336 | { .compatible = "via,vt8500-ehci", }, |
209 | { .compatible = "wm,prizm-ehci", }, | 337 | { .compatible = "wm,prizm-ehci", }, |
338 | { .compatible = "generic-ehci", }, | ||
210 | {} | 339 | {} |
211 | }; | 340 | }; |
341 | MODULE_DEVICE_TABLE(of, vt8500_ehci_ids); | ||
212 | 342 | ||
213 | static const struct platform_device_id ehci_platform_table[] = { | 343 | static const struct platform_device_id ehci_platform_table[] = { |
214 | { "ehci-platform", 0 }, | 344 | { "ehci-platform", 0 }, |
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index af28b748e87a..27ac6ad53c3d 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c | |||
@@ -38,10 +38,6 @@ | |||
38 | 38 | ||
39 | #include "ehci.h" | 39 | #include "ehci.h" |
40 | 40 | ||
41 | #define TEGRA_USB_BASE 0xC5000000 | ||
42 | #define TEGRA_USB2_BASE 0xC5004000 | ||
43 | #define TEGRA_USB3_BASE 0xC5008000 | ||
44 | |||
45 | #define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) | 41 | #define PORT_WAKE_BITS (PORT_WKOC_E|PORT_WKDISC_E|PORT_WKCONN_E) |
46 | 42 | ||
47 | #define TEGRA_USB_DMA_ALIGN 32 | 43 | #define TEGRA_USB_DMA_ALIGN 32 |
diff --git a/drivers/usb/host/hwa-hc.c b/drivers/usb/host/hwa-hc.c index e07669993f58..d0d8fadf7066 100644 --- a/drivers/usb/host/hwa-hc.c +++ b/drivers/usb/host/hwa-hc.c | |||
@@ -261,8 +261,44 @@ static int __hwahc_op_wusbhc_start(struct wusbhc *wusbhc) | |||
261 | dev_err(dev, "cannot listen to notifications: %d\n", result); | 261 | dev_err(dev, "cannot listen to notifications: %d\n", result); |
262 | goto error_stop; | 262 | goto error_stop; |
263 | } | 263 | } |
264 | /* | ||
265 | * If WUSB_QUIRK_ALEREON_HWA_DISABLE_XFER_NOTIFICATIONS is set, | ||
266 | * disable transfer notifications. | ||
267 | */ | ||
268 | if (hwahc->wa.quirks & | ||
269 | WUSB_QUIRK_ALEREON_HWA_DISABLE_XFER_NOTIFICATIONS) { | ||
270 | struct usb_host_interface *cur_altsetting = | ||
271 | hwahc->wa.usb_iface->cur_altsetting; | ||
272 | |||
273 | result = usb_control_msg(hwahc->wa.usb_dev, | ||
274 | usb_sndctrlpipe(hwahc->wa.usb_dev, 0), | ||
275 | WA_REQ_ALEREON_DISABLE_XFER_NOTIFICATIONS, | ||
276 | USB_DIR_OUT | USB_TYPE_VENDOR | | ||
277 | USB_RECIP_INTERFACE, | ||
278 | WA_REQ_ALEREON_FEATURE_SET, | ||
279 | cur_altsetting->desc.bInterfaceNumber, | ||
280 | NULL, 0, | ||
281 | USB_CTRL_SET_TIMEOUT); | ||
282 | /* | ||
283 | * If we successfully sent the control message, start DTI here | ||
284 | * because no transfer notifications will be received which is | ||
285 | * where DTI is normally started. | ||
286 | */ | ||
287 | if (result == 0) | ||
288 | result = wa_dti_start(&hwahc->wa); | ||
289 | else | ||
290 | result = 0; /* OK. Continue normally. */ | ||
291 | |||
292 | if (result < 0) { | ||
293 | dev_err(dev, "cannot start DTI: %d\n", result); | ||
294 | goto error_dti_start; | ||
295 | } | ||
296 | } | ||
297 | |||
264 | return result; | 298 | return result; |
265 | 299 | ||
300 | error_dti_start: | ||
301 | wa_nep_disarm(&hwahc->wa); | ||
266 | error_stop: | 302 | error_stop: |
267 | __wa_clear_feature(&hwahc->wa, WA_ENABLE); | 303 | __wa_clear_feature(&hwahc->wa, WA_ENABLE); |
268 | return result; | 304 | return result; |
@@ -827,10 +863,12 @@ static void hwahc_disconnect(struct usb_interface *usb_iface) | |||
827 | static struct usb_device_id hwahc_id_table[] = { | 863 | static struct usb_device_id hwahc_id_table[] = { |
828 | /* Alereon 5310 */ | 864 | /* Alereon 5310 */ |
829 | { USB_DEVICE_AND_INTERFACE_INFO(0x13dc, 0x5310, 0xe0, 0x02, 0x01), | 865 | { USB_DEVICE_AND_INTERFACE_INFO(0x13dc, 0x5310, 0xe0, 0x02, 0x01), |
830 | .driver_info = WUSB_QUIRK_ALEREON_HWA_CONCAT_ISOC }, | 866 | .driver_info = WUSB_QUIRK_ALEREON_HWA_CONCAT_ISOC | |
867 | WUSB_QUIRK_ALEREON_HWA_DISABLE_XFER_NOTIFICATIONS }, | ||
831 | /* Alereon 5611 */ | 868 | /* Alereon 5611 */ |
832 | { USB_DEVICE_AND_INTERFACE_INFO(0x13dc, 0x5611, 0xe0, 0x02, 0x01), | 869 | { USB_DEVICE_AND_INTERFACE_INFO(0x13dc, 0x5611, 0xe0, 0x02, 0x01), |
833 | .driver_info = WUSB_QUIRK_ALEREON_HWA_CONCAT_ISOC }, | 870 | .driver_info = WUSB_QUIRK_ALEREON_HWA_CONCAT_ISOC | |
871 | WUSB_QUIRK_ALEREON_HWA_DISABLE_XFER_NOTIFICATIONS }, | ||
834 | /* FIXME: use class labels for this */ | 872 | /* FIXME: use class labels for this */ |
835 | { USB_INTERFACE_INFO(0xe0, 0x02, 0x01), }, | 873 | { USB_INTERFACE_INFO(0xe0, 0x02, 0x01), }, |
836 | {}, | 874 | {}, |
diff --git a/drivers/usb/host/ohci-platform.c b/drivers/usb/host/ohci-platform.c index 68f674cd095f..b6002c951c5c 100644 --- a/drivers/usb/host/ohci-platform.c +++ b/drivers/usb/host/ohci-platform.c | |||
@@ -3,6 +3,7 @@ | |||
3 | * | 3 | * |
4 | * Copyright 2007 Michael Buesch <m@bues.ch> | 4 | * Copyright 2007 Michael Buesch <m@bues.ch> |
5 | * Copyright 2011-2012 Hauke Mehrtens <hauke@hauke-m.de> | 5 | * Copyright 2011-2012 Hauke Mehrtens <hauke@hauke-m.de> |
6 | * Copyright 2014 Hans de Goede <hdegoede@redhat.com> | ||
6 | * | 7 | * |
7 | * Derived from the OCHI-SSB driver | 8 | * Derived from the OCHI-SSB driver |
8 | * Derived from the OHCI-PCI driver | 9 | * Derived from the OHCI-PCI driver |
@@ -14,11 +15,14 @@ | |||
14 | * Licensed under the GNU/GPL. See COPYING for details. | 15 | * Licensed under the GNU/GPL. See COPYING for details. |
15 | */ | 16 | */ |
16 | 17 | ||
18 | #include <linux/clk.h> | ||
19 | #include <linux/dma-mapping.h> | ||
17 | #include <linux/hrtimer.h> | 20 | #include <linux/hrtimer.h> |
18 | #include <linux/io.h> | 21 | #include <linux/io.h> |
19 | #include <linux/kernel.h> | 22 | #include <linux/kernel.h> |
20 | #include <linux/module.h> | 23 | #include <linux/module.h> |
21 | #include <linux/err.h> | 24 | #include <linux/err.h> |
25 | #include <linux/phy/phy.h> | ||
22 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
23 | #include <linux/usb/ohci_pdriver.h> | 27 | #include <linux/usb/ohci_pdriver.h> |
24 | #include <linux/usb.h> | 28 | #include <linux/usb.h> |
@@ -27,6 +31,13 @@ | |||
27 | #include "ohci.h" | 31 | #include "ohci.h" |
28 | 32 | ||
29 | #define DRIVER_DESC "OHCI generic platform driver" | 33 | #define DRIVER_DESC "OHCI generic platform driver" |
34 | #define OHCI_MAX_CLKS 3 | ||
35 | #define hcd_to_ohci_priv(h) ((struct ohci_platform_priv *)hcd_to_ohci(h)->priv) | ||
36 | |||
37 | struct ohci_platform_priv { | ||
38 | struct clk *clks[OHCI_MAX_CLKS]; | ||
39 | struct phy *phy; | ||
40 | }; | ||
30 | 41 | ||
31 | static const char hcd_name[] = "ohci-platform"; | 42 | static const char hcd_name[] = "ohci-platform"; |
32 | 43 | ||
@@ -36,10 +47,6 @@ static int ohci_platform_reset(struct usb_hcd *hcd) | |||
36 | struct usb_ohci_pdata *pdata = dev_get_platdata(&pdev->dev); | 47 | struct usb_ohci_pdata *pdata = dev_get_platdata(&pdev->dev); |
37 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); | 48 | struct ohci_hcd *ohci = hcd_to_ohci(hcd); |
38 | 49 | ||
39 | if (pdata->big_endian_desc) | ||
40 | ohci->flags |= OHCI_QUIRK_BE_DESC; | ||
41 | if (pdata->big_endian_mmio) | ||
42 | ohci->flags |= OHCI_QUIRK_BE_MMIO; | ||
43 | if (pdata->no_big_frame_no) | 50 | if (pdata->no_big_frame_no) |
44 | ohci->flags |= OHCI_QUIRK_FRAME_NO; | 51 | ohci->flags |= OHCI_QUIRK_FRAME_NO; |
45 | if (pdata->num_ports) | 52 | if (pdata->num_ports) |
@@ -48,11 +55,67 @@ static int ohci_platform_reset(struct usb_hcd *hcd) | |||
48 | return ohci_setup(hcd); | 55 | return ohci_setup(hcd); |
49 | } | 56 | } |
50 | 57 | ||
58 | static int ohci_platform_power_on(struct platform_device *dev) | ||
59 | { | ||
60 | struct usb_hcd *hcd = platform_get_drvdata(dev); | ||
61 | struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); | ||
62 | int clk, ret; | ||
63 | |||
64 | for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) { | ||
65 | ret = clk_prepare_enable(priv->clks[clk]); | ||
66 | if (ret) | ||
67 | goto err_disable_clks; | ||
68 | } | ||
69 | |||
70 | if (priv->phy) { | ||
71 | ret = phy_init(priv->phy); | ||
72 | if (ret) | ||
73 | goto err_disable_clks; | ||
74 | |||
75 | ret = phy_power_on(priv->phy); | ||
76 | if (ret) | ||
77 | goto err_exit_phy; | ||
78 | } | ||
79 | |||
80 | return 0; | ||
81 | |||
82 | err_exit_phy: | ||
83 | phy_exit(priv->phy); | ||
84 | err_disable_clks: | ||
85 | while (--clk >= 0) | ||
86 | clk_disable_unprepare(priv->clks[clk]); | ||
87 | |||
88 | return ret; | ||
89 | } | ||
90 | |||
91 | static void ohci_platform_power_off(struct platform_device *dev) | ||
92 | { | ||
93 | struct usb_hcd *hcd = platform_get_drvdata(dev); | ||
94 | struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); | ||
95 | int clk; | ||
96 | |||
97 | if (priv->phy) { | ||
98 | phy_power_off(priv->phy); | ||
99 | phy_exit(priv->phy); | ||
100 | } | ||
101 | |||
102 | for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--) | ||
103 | if (priv->clks[clk]) | ||
104 | clk_disable_unprepare(priv->clks[clk]); | ||
105 | } | ||
106 | |||
51 | static struct hc_driver __read_mostly ohci_platform_hc_driver; | 107 | static struct hc_driver __read_mostly ohci_platform_hc_driver; |
52 | 108 | ||
53 | static const struct ohci_driver_overrides platform_overrides __initconst = { | 109 | static const struct ohci_driver_overrides platform_overrides __initconst = { |
54 | .product_desc = "Generic Platform OHCI controller", | 110 | .product_desc = "Generic Platform OHCI controller", |
55 | .reset = ohci_platform_reset, | 111 | .reset = ohci_platform_reset, |
112 | .extra_priv_size = sizeof(struct ohci_platform_priv), | ||
113 | }; | ||
114 | |||
115 | static struct usb_ohci_pdata ohci_platform_defaults = { | ||
116 | .power_on = ohci_platform_power_on, | ||
117 | .power_suspend = ohci_platform_power_off, | ||
118 | .power_off = ohci_platform_power_off, | ||
56 | }; | 119 | }; |
57 | 120 | ||
58 | static int ohci_platform_probe(struct platform_device *dev) | 121 | static int ohci_platform_probe(struct platform_device *dev) |
@@ -60,17 +123,24 @@ static int ohci_platform_probe(struct platform_device *dev) | |||
60 | struct usb_hcd *hcd; | 123 | struct usb_hcd *hcd; |
61 | struct resource *res_mem; | 124 | struct resource *res_mem; |
62 | struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); | 125 | struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); |
63 | int irq; | 126 | struct ohci_platform_priv *priv; |
64 | int err = -ENOMEM; | 127 | struct ohci_hcd *ohci; |
65 | 128 | int err, irq, clk = 0; | |
66 | if (!pdata) { | ||
67 | WARN_ON(1); | ||
68 | return -ENODEV; | ||
69 | } | ||
70 | 129 | ||
71 | if (usb_disabled()) | 130 | if (usb_disabled()) |
72 | return -ENODEV; | 131 | return -ENODEV; |
73 | 132 | ||
133 | /* | ||
134 | * Use reasonable defaults so platforms don't have to provide these | ||
135 | * with DT probing on ARM. | ||
136 | */ | ||
137 | if (!pdata) | ||
138 | pdata = &ohci_platform_defaults; | ||
139 | |||
140 | err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); | ||
141 | if (err) | ||
142 | return err; | ||
143 | |||
74 | irq = platform_get_irq(dev, 0); | 144 | irq = platform_get_irq(dev, 0); |
75 | if (irq < 0) { | 145 | if (irq < 0) { |
76 | dev_err(&dev->dev, "no irq provided"); | 146 | dev_err(&dev->dev, "no irq provided"); |
@@ -83,17 +153,72 @@ static int ohci_platform_probe(struct platform_device *dev) | |||
83 | return -ENXIO; | 153 | return -ENXIO; |
84 | } | 154 | } |
85 | 155 | ||
156 | hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev, | ||
157 | dev_name(&dev->dev)); | ||
158 | if (!hcd) | ||
159 | return -ENOMEM; | ||
160 | |||
161 | platform_set_drvdata(dev, hcd); | ||
162 | dev->dev.platform_data = pdata; | ||
163 | priv = hcd_to_ohci_priv(hcd); | ||
164 | ohci = hcd_to_ohci(hcd); | ||
165 | |||
166 | if (pdata == &ohci_platform_defaults && dev->dev.of_node) { | ||
167 | if (of_property_read_bool(dev->dev.of_node, "big-endian-regs")) | ||
168 | ohci->flags |= OHCI_QUIRK_BE_MMIO; | ||
169 | |||
170 | if (of_property_read_bool(dev->dev.of_node, "big-endian-desc")) | ||
171 | ohci->flags |= OHCI_QUIRK_BE_DESC; | ||
172 | |||
173 | if (of_property_read_bool(dev->dev.of_node, "big-endian")) | ||
174 | ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC; | ||
175 | |||
176 | priv->phy = devm_phy_get(&dev->dev, "usb"); | ||
177 | if (IS_ERR(priv->phy)) { | ||
178 | err = PTR_ERR(priv->phy); | ||
179 | if (err == -EPROBE_DEFER) | ||
180 | goto err_put_hcd; | ||
181 | priv->phy = NULL; | ||
182 | } | ||
183 | |||
184 | for (clk = 0; clk < OHCI_MAX_CLKS; clk++) { | ||
185 | priv->clks[clk] = of_clk_get(dev->dev.of_node, clk); | ||
186 | if (IS_ERR(priv->clks[clk])) { | ||
187 | err = PTR_ERR(priv->clks[clk]); | ||
188 | if (err == -EPROBE_DEFER) | ||
189 | goto err_put_clks; | ||
190 | priv->clks[clk] = NULL; | ||
191 | break; | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | |||
196 | if (pdata->big_endian_desc) | ||
197 | ohci->flags |= OHCI_QUIRK_BE_DESC; | ||
198 | if (pdata->big_endian_mmio) | ||
199 | ohci->flags |= OHCI_QUIRK_BE_MMIO; | ||
200 | |||
201 | #ifndef CONFIG_USB_OHCI_BIG_ENDIAN_MMIO | ||
202 | if (ohci->flags & OHCI_QUIRK_BE_MMIO) { | ||
203 | dev_err(&dev->dev, | ||
204 | "Error: CONFIG_USB_OHCI_BIG_ENDIAN_MMIO not set\n"); | ||
205 | err = -EINVAL; | ||
206 | goto err_put_clks; | ||
207 | } | ||
208 | #endif | ||
209 | #ifndef CONFIG_USB_OHCI_BIG_ENDIAN_DESC | ||
210 | if (ohci->flags & OHCI_QUIRK_BE_DESC) { | ||
211 | dev_err(&dev->dev, | ||
212 | "Error: CONFIG_USB_OHCI_BIG_ENDIAN_DESC not set\n"); | ||
213 | err = -EINVAL; | ||
214 | goto err_put_clks; | ||
215 | } | ||
216 | #endif | ||
217 | |||
86 | if (pdata->power_on) { | 218 | if (pdata->power_on) { |
87 | err = pdata->power_on(dev); | 219 | err = pdata->power_on(dev); |
88 | if (err < 0) | 220 | if (err < 0) |
89 | return err; | 221 | goto err_put_clks; |
90 | } | ||
91 | |||
92 | hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev, | ||
93 | dev_name(&dev->dev)); | ||
94 | if (!hcd) { | ||
95 | err = -ENOMEM; | ||
96 | goto err_power; | ||
97 | } | 222 | } |
98 | 223 | ||
99 | hcd->rsrc_start = res_mem->start; | 224 | hcd->rsrc_start = res_mem->start; |
@@ -102,11 +227,11 @@ static int ohci_platform_probe(struct platform_device *dev) | |||
102 | hcd->regs = devm_ioremap_resource(&dev->dev, res_mem); | 227 | hcd->regs = devm_ioremap_resource(&dev->dev, res_mem); |
103 | if (IS_ERR(hcd->regs)) { | 228 | if (IS_ERR(hcd->regs)) { |
104 | err = PTR_ERR(hcd->regs); | 229 | err = PTR_ERR(hcd->regs); |
105 | goto err_put_hcd; | 230 | goto err_power; |
106 | } | 231 | } |
107 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); | 232 | err = usb_add_hcd(hcd, irq, IRQF_SHARED); |
108 | if (err) | 233 | if (err) |
109 | goto err_put_hcd; | 234 | goto err_power; |
110 | 235 | ||
111 | device_wakeup_enable(hcd->self.controller); | 236 | device_wakeup_enable(hcd->self.controller); |
112 | 237 | ||
@@ -114,11 +239,17 @@ static int ohci_platform_probe(struct platform_device *dev) | |||
114 | 239 | ||
115 | return err; | 240 | return err; |
116 | 241 | ||
117 | err_put_hcd: | ||
118 | usb_put_hcd(hcd); | ||
119 | err_power: | 242 | err_power: |
120 | if (pdata->power_off) | 243 | if (pdata->power_off) |
121 | pdata->power_off(dev); | 244 | pdata->power_off(dev); |
245 | err_put_clks: | ||
246 | while (--clk >= 0) | ||
247 | clk_put(priv->clks[clk]); | ||
248 | err_put_hcd: | ||
249 | if (pdata == &ohci_platform_defaults) | ||
250 | dev->dev.platform_data = NULL; | ||
251 | |||
252 | usb_put_hcd(hcd); | ||
122 | 253 | ||
123 | return err; | 254 | return err; |
124 | } | 255 | } |
@@ -127,13 +258,22 @@ static int ohci_platform_remove(struct platform_device *dev) | |||
127 | { | 258 | { |
128 | struct usb_hcd *hcd = platform_get_drvdata(dev); | 259 | struct usb_hcd *hcd = platform_get_drvdata(dev); |
129 | struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); | 260 | struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); |
261 | struct ohci_platform_priv *priv = hcd_to_ohci_priv(hcd); | ||
262 | int clk; | ||
130 | 263 | ||
131 | usb_remove_hcd(hcd); | 264 | usb_remove_hcd(hcd); |
132 | usb_put_hcd(hcd); | ||
133 | 265 | ||
134 | if (pdata->power_off) | 266 | if (pdata->power_off) |
135 | pdata->power_off(dev); | 267 | pdata->power_off(dev); |
136 | 268 | ||
269 | for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) | ||
270 | clk_put(priv->clks[clk]); | ||
271 | |||
272 | usb_put_hcd(hcd); | ||
273 | |||
274 | if (pdata == &ohci_platform_defaults) | ||
275 | dev->dev.platform_data = NULL; | ||
276 | |||
137 | return 0; | 277 | return 0; |
138 | } | 278 | } |
139 | 279 | ||
@@ -180,6 +320,12 @@ static int ohci_platform_resume(struct device *dev) | |||
180 | #define ohci_platform_resume NULL | 320 | #define ohci_platform_resume NULL |
181 | #endif /* CONFIG_PM */ | 321 | #endif /* CONFIG_PM */ |
182 | 322 | ||
323 | static const struct of_device_id ohci_platform_ids[] = { | ||
324 | { .compatible = "generic-ohci", }, | ||
325 | { } | ||
326 | }; | ||
327 | MODULE_DEVICE_TABLE(of, ohci_platform_ids); | ||
328 | |||
183 | static const struct platform_device_id ohci_platform_table[] = { | 329 | static const struct platform_device_id ohci_platform_table[] = { |
184 | { "ohci-platform", 0 }, | 330 | { "ohci-platform", 0 }, |
185 | { } | 331 | { } |
@@ -200,6 +346,7 @@ static struct platform_driver ohci_platform_driver = { | |||
200 | .owner = THIS_MODULE, | 346 | .owner = THIS_MODULE, |
201 | .name = "ohci-platform", | 347 | .name = "ohci-platform", |
202 | .pm = &ohci_platform_pm_ops, | 348 | .pm = &ohci_platform_pm_ops, |
349 | .of_match_table = ohci_platform_ids, | ||
203 | } | 350 | } |
204 | }; | 351 | }; |
205 | 352 | ||
diff --git a/drivers/usb/host/uhci-platform.c b/drivers/usb/host/uhci-platform.c index 44e6c9da8892..01833ab2b5c3 100644 --- a/drivers/usb/host/uhci-platform.c +++ b/drivers/usb/host/uhci-platform.c | |||
@@ -148,6 +148,7 @@ static void uhci_hcd_platform_shutdown(struct platform_device *op) | |||
148 | } | 148 | } |
149 | 149 | ||
150 | static const struct of_device_id platform_uhci_ids[] = { | 150 | static const struct of_device_id platform_uhci_ids[] = { |
151 | { .compatible = "generic-uhci", }, | ||
151 | { .compatible = "platform-uhci", }, | 152 | { .compatible = "platform-uhci", }, |
152 | {} | 153 | {} |
153 | }; | 154 | }; |
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 9992fbfec85f..1ad6bc1951c7 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
@@ -732,9 +732,11 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, | |||
732 | /* Set the U1 and U2 exit latencies. */ | 732 | /* Set the U1 and U2 exit latencies. */ |
733 | memcpy(buf, &usb_bos_descriptor, | 733 | memcpy(buf, &usb_bos_descriptor, |
734 | USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE); | 734 | USB_DT_BOS_SIZE + USB_DT_USB_SS_CAP_SIZE); |
735 | temp = readl(&xhci->cap_regs->hcs_params3); | 735 | if ((xhci->quirks & XHCI_LPM_SUPPORT)) { |
736 | buf[12] = HCS_U1_LATENCY(temp); | 736 | temp = readl(&xhci->cap_regs->hcs_params3); |
737 | put_unaligned_le16(HCS_U2_LATENCY(temp), &buf[13]); | 737 | buf[12] = HCS_U1_LATENCY(temp); |
738 | put_unaligned_le16(HCS_U2_LATENCY(temp), &buf[13]); | ||
739 | } | ||
738 | 740 | ||
739 | /* Indicate whether the host has LTM support. */ | 741 | /* Indicate whether the host has LTM support. */ |
740 | temp = readl(&xhci->cap_regs->hcc_params); | 742 | temp = readl(&xhci->cap_regs->hcc_params); |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index bce4391a0e7d..c089668308ad 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -149,14 +149,140 @@ static void xhci_link_rings(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | /* | ||
153 | * We need a radix tree for mapping physical addresses of TRBs to which stream | ||
154 | * ID they belong to. We need to do this because the host controller won't tell | ||
155 | * us which stream ring the TRB came from. We could store the stream ID in an | ||
156 | * event data TRB, but that doesn't help us for the cancellation case, since the | ||
157 | * endpoint may stop before it reaches that event data TRB. | ||
158 | * | ||
159 | * The radix tree maps the upper portion of the TRB DMA address to a ring | ||
160 | * segment that has the same upper portion of DMA addresses. For example, say I | ||
161 | * have segments of size 1KB, that are always 1KB aligned. A segment may | ||
162 | * start at 0x10c91000 and end at 0x10c913f0. If I use the upper 10 bits, the | ||
163 | * key to the stream ID is 0x43244. I can use the DMA address of the TRB to | ||
164 | * pass the radix tree a key to get the right stream ID: | ||
165 | * | ||
166 | * 0x10c90fff >> 10 = 0x43243 | ||
167 | * 0x10c912c0 >> 10 = 0x43244 | ||
168 | * 0x10c91400 >> 10 = 0x43245 | ||
169 | * | ||
170 | * Obviously, only those TRBs with DMA addresses that are within the segment | ||
171 | * will make the radix tree return the stream ID for that ring. | ||
172 | * | ||
173 | * Caveats for the radix tree: | ||
174 | * | ||
175 | * The radix tree uses an unsigned long as a key pair. On 32-bit systems, an | ||
176 | * unsigned long will be 32-bits; on a 64-bit system an unsigned long will be | ||
177 | * 64-bits. Since we only request 32-bit DMA addresses, we can use that as the | ||
178 | * key on 32-bit or 64-bit systems (it would also be fine if we asked for 64-bit | ||
179 | * PCI DMA addresses on a 64-bit system). There might be a problem on 32-bit | ||
180 | * extended systems (where the DMA address can be bigger than 32-bits), | ||
181 | * if we allow the PCI dma mask to be bigger than 32-bits. So don't do that. | ||
182 | */ | ||
183 | static int xhci_insert_segment_mapping(struct radix_tree_root *trb_address_map, | ||
184 | struct xhci_ring *ring, | ||
185 | struct xhci_segment *seg, | ||
186 | gfp_t mem_flags) | ||
187 | { | ||
188 | unsigned long key; | ||
189 | int ret; | ||
190 | |||
191 | key = (unsigned long)(seg->dma >> TRB_SEGMENT_SHIFT); | ||
192 | /* Skip any segments that were already added. */ | ||
193 | if (radix_tree_lookup(trb_address_map, key)) | ||
194 | return 0; | ||
195 | |||
196 | ret = radix_tree_maybe_preload(mem_flags); | ||
197 | if (ret) | ||
198 | return ret; | ||
199 | ret = radix_tree_insert(trb_address_map, | ||
200 | key, ring); | ||
201 | radix_tree_preload_end(); | ||
202 | return ret; | ||
203 | } | ||
204 | |||
205 | static void xhci_remove_segment_mapping(struct radix_tree_root *trb_address_map, | ||
206 | struct xhci_segment *seg) | ||
207 | { | ||
208 | unsigned long key; | ||
209 | |||
210 | key = (unsigned long)(seg->dma >> TRB_SEGMENT_SHIFT); | ||
211 | if (radix_tree_lookup(trb_address_map, key)) | ||
212 | radix_tree_delete(trb_address_map, key); | ||
213 | } | ||
214 | |||
215 | static int xhci_update_stream_segment_mapping( | ||
216 | struct radix_tree_root *trb_address_map, | ||
217 | struct xhci_ring *ring, | ||
218 | struct xhci_segment *first_seg, | ||
219 | struct xhci_segment *last_seg, | ||
220 | gfp_t mem_flags) | ||
221 | { | ||
222 | struct xhci_segment *seg; | ||
223 | struct xhci_segment *failed_seg; | ||
224 | int ret; | ||
225 | |||
226 | if (WARN_ON_ONCE(trb_address_map == NULL)) | ||
227 | return 0; | ||
228 | |||
229 | seg = first_seg; | ||
230 | do { | ||
231 | ret = xhci_insert_segment_mapping(trb_address_map, | ||
232 | ring, seg, mem_flags); | ||
233 | if (ret) | ||
234 | goto remove_streams; | ||
235 | if (seg == last_seg) | ||
236 | return 0; | ||
237 | seg = seg->next; | ||
238 | } while (seg != first_seg); | ||
239 | |||
240 | return 0; | ||
241 | |||
242 | remove_streams: | ||
243 | failed_seg = seg; | ||
244 | seg = first_seg; | ||
245 | do { | ||
246 | xhci_remove_segment_mapping(trb_address_map, seg); | ||
247 | if (seg == failed_seg) | ||
248 | return ret; | ||
249 | seg = seg->next; | ||
250 | } while (seg != first_seg); | ||
251 | |||
252 | return ret; | ||
253 | } | ||
254 | |||
255 | static void xhci_remove_stream_mapping(struct xhci_ring *ring) | ||
256 | { | ||
257 | struct xhci_segment *seg; | ||
258 | |||
259 | if (WARN_ON_ONCE(ring->trb_address_map == NULL)) | ||
260 | return; | ||
261 | |||
262 | seg = ring->first_seg; | ||
263 | do { | ||
264 | xhci_remove_segment_mapping(ring->trb_address_map, seg); | ||
265 | seg = seg->next; | ||
266 | } while (seg != ring->first_seg); | ||
267 | } | ||
268 | |||
269 | static int xhci_update_stream_mapping(struct xhci_ring *ring, gfp_t mem_flags) | ||
270 | { | ||
271 | return xhci_update_stream_segment_mapping(ring->trb_address_map, ring, | ||
272 | ring->first_seg, ring->last_seg, mem_flags); | ||
273 | } | ||
274 | |||
152 | /* XXX: Do we need the hcd structure in all these functions? */ | 275 | /* XXX: Do we need the hcd structure in all these functions? */ |
153 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring) | 276 | void xhci_ring_free(struct xhci_hcd *xhci, struct xhci_ring *ring) |
154 | { | 277 | { |
155 | if (!ring) | 278 | if (!ring) |
156 | return; | 279 | return; |
157 | 280 | ||
158 | if (ring->first_seg) | 281 | if (ring->first_seg) { |
282 | if (ring->type == TYPE_STREAM) | ||
283 | xhci_remove_stream_mapping(ring); | ||
159 | xhci_free_segments_for_ring(xhci, ring->first_seg); | 284 | xhci_free_segments_for_ring(xhci, ring->first_seg); |
285 | } | ||
160 | 286 | ||
161 | kfree(ring); | 287 | kfree(ring); |
162 | } | 288 | } |
@@ -349,6 +475,21 @@ int xhci_ring_expansion(struct xhci_hcd *xhci, struct xhci_ring *ring, | |||
349 | if (ret) | 475 | if (ret) |
350 | return -ENOMEM; | 476 | return -ENOMEM; |
351 | 477 | ||
478 | if (ring->type == TYPE_STREAM) | ||
479 | ret = xhci_update_stream_segment_mapping(ring->trb_address_map, | ||
480 | ring, first, last, flags); | ||
481 | if (ret) { | ||
482 | struct xhci_segment *next; | ||
483 | do { | ||
484 | next = first->next; | ||
485 | xhci_segment_free(xhci, first); | ||
486 | if (first == last) | ||
487 | break; | ||
488 | first = next; | ||
489 | } while (true); | ||
490 | return ret; | ||
491 | } | ||
492 | |||
352 | xhci_link_rings(xhci, ring, first, last, num_segs); | 493 | xhci_link_rings(xhci, ring, first, last, num_segs); |
353 | xhci_dbg_trace(xhci, trace_xhci_dbg_ring_expansion, | 494 | xhci_dbg_trace(xhci, trace_xhci_dbg_ring_expansion, |
354 | "ring expansion succeed, now has %d segments", | 495 | "ring expansion succeed, now has %d segments", |
@@ -434,12 +575,12 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci, | |||
434 | struct xhci_stream_ctx *stream_ctx, dma_addr_t dma) | 575 | struct xhci_stream_ctx *stream_ctx, dma_addr_t dma) |
435 | { | 576 | { |
436 | struct device *dev = xhci_to_hcd(xhci)->self.controller; | 577 | struct device *dev = xhci_to_hcd(xhci)->self.controller; |
578 | size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; | ||
437 | 579 | ||
438 | if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE) | 580 | if (size > MEDIUM_STREAM_ARRAY_SIZE) |
439 | dma_free_coherent(dev, | 581 | dma_free_coherent(dev, size, |
440 | sizeof(struct xhci_stream_ctx)*num_stream_ctxs, | ||
441 | stream_ctx, dma); | 582 | stream_ctx, dma); |
442 | else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE) | 583 | else if (size <= SMALL_STREAM_ARRAY_SIZE) |
443 | return dma_pool_free(xhci->small_streams_pool, | 584 | return dma_pool_free(xhci->small_streams_pool, |
444 | stream_ctx, dma); | 585 | stream_ctx, dma); |
445 | else | 586 | else |
@@ -462,12 +603,12 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci, | |||
462 | gfp_t mem_flags) | 603 | gfp_t mem_flags) |
463 | { | 604 | { |
464 | struct device *dev = xhci_to_hcd(xhci)->self.controller; | 605 | struct device *dev = xhci_to_hcd(xhci)->self.controller; |
606 | size_t size = sizeof(struct xhci_stream_ctx) * num_stream_ctxs; | ||
465 | 607 | ||
466 | if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE) | 608 | if (size > MEDIUM_STREAM_ARRAY_SIZE) |
467 | return dma_alloc_coherent(dev, | 609 | return dma_alloc_coherent(dev, size, |
468 | sizeof(struct xhci_stream_ctx)*num_stream_ctxs, | ||
469 | dma, mem_flags); | 610 | dma, mem_flags); |
470 | else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE) | 611 | else if (size <= SMALL_STREAM_ARRAY_SIZE) |
471 | return dma_pool_alloc(xhci->small_streams_pool, | 612 | return dma_pool_alloc(xhci->small_streams_pool, |
472 | mem_flags, dma); | 613 | mem_flags, dma); |
473 | else | 614 | else |
@@ -510,36 +651,6 @@ struct xhci_ring *xhci_stream_id_to_ring( | |||
510 | * The number of stream contexts in the stream context array may be bigger than | 651 | * The number of stream contexts in the stream context array may be bigger than |
511 | * the number of streams the driver wants to use. This is because the number of | 652 | * the number of streams the driver wants to use. This is because the number of |
512 | * stream context array entries must be a power of two. | 653 | * stream context array entries must be a power of two. |
513 | * | ||
514 | * We need a radix tree for mapping physical addresses of TRBs to which stream | ||
515 | * ID they belong to. We need to do this because the host controller won't tell | ||
516 | * us which stream ring the TRB came from. We could store the stream ID in an | ||
517 | * event data TRB, but that doesn't help us for the cancellation case, since the | ||
518 | * endpoint may stop before it reaches that event data TRB. | ||
519 | * | ||
520 | * The radix tree maps the upper portion of the TRB DMA address to a ring | ||
521 | * segment that has the same upper portion of DMA addresses. For example, say I | ||
522 | * have segments of size 1KB, that are always 64-byte aligned. A segment may | ||
523 | * start at 0x10c91000 and end at 0x10c913f0. If I use the upper 10 bits, the | ||
524 | * key to the stream ID is 0x43244. I can use the DMA address of the TRB to | ||
525 | * pass the radix tree a key to get the right stream ID: | ||
526 | * | ||
527 | * 0x10c90fff >> 10 = 0x43243 | ||
528 | * 0x10c912c0 >> 10 = 0x43244 | ||
529 | * 0x10c91400 >> 10 = 0x43245 | ||
530 | * | ||
531 | * Obviously, only those TRBs with DMA addresses that are within the segment | ||
532 | * will make the radix tree return the stream ID for that ring. | ||
533 | * | ||
534 | * Caveats for the radix tree: | ||
535 | * | ||
536 | * The radix tree uses an unsigned long as a key pair. On 32-bit systems, an | ||
537 | * unsigned long will be 32-bits; on a 64-bit system an unsigned long will be | ||
538 | * 64-bits. Since we only request 32-bit DMA addresses, we can use that as the | ||
539 | * key on 32-bit or 64-bit systems (it would also be fine if we asked for 64-bit | ||
540 | * PCI DMA addresses on a 64-bit system). There might be a problem on 32-bit | ||
541 | * extended systems (where the DMA address can be bigger than 32-bits), | ||
542 | * if we allow the PCI dma mask to be bigger than 32-bits. So don't do that. | ||
543 | */ | 654 | */ |
544 | struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, | 655 | struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, |
545 | unsigned int num_stream_ctxs, | 656 | unsigned int num_stream_ctxs, |
@@ -548,7 +659,6 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, | |||
548 | struct xhci_stream_info *stream_info; | 659 | struct xhci_stream_info *stream_info; |
549 | u32 cur_stream; | 660 | u32 cur_stream; |
550 | struct xhci_ring *cur_ring; | 661 | struct xhci_ring *cur_ring; |
551 | unsigned long key; | ||
552 | u64 addr; | 662 | u64 addr; |
553 | int ret; | 663 | int ret; |
554 | 664 | ||
@@ -603,6 +713,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, | |||
603 | if (!cur_ring) | 713 | if (!cur_ring) |
604 | goto cleanup_rings; | 714 | goto cleanup_rings; |
605 | cur_ring->stream_id = cur_stream; | 715 | cur_ring->stream_id = cur_stream; |
716 | cur_ring->trb_address_map = &stream_info->trb_address_map; | ||
606 | /* Set deq ptr, cycle bit, and stream context type */ | 717 | /* Set deq ptr, cycle bit, and stream context type */ |
607 | addr = cur_ring->first_seg->dma | | 718 | addr = cur_ring->first_seg->dma | |
608 | SCT_FOR_CTX(SCT_PRI_TR) | | 719 | SCT_FOR_CTX(SCT_PRI_TR) | |
@@ -612,10 +723,7 @@ struct xhci_stream_info *xhci_alloc_stream_info(struct xhci_hcd *xhci, | |||
612 | xhci_dbg(xhci, "Setting stream %d ring ptr to 0x%08llx\n", | 723 | xhci_dbg(xhci, "Setting stream %d ring ptr to 0x%08llx\n", |
613 | cur_stream, (unsigned long long) addr); | 724 | cur_stream, (unsigned long long) addr); |
614 | 725 | ||
615 | key = (unsigned long) | 726 | ret = xhci_update_stream_mapping(cur_ring, mem_flags); |
616 | (cur_ring->first_seg->dma >> TRB_SEGMENT_SHIFT); | ||
617 | ret = radix_tree_insert(&stream_info->trb_address_map, | ||
618 | key, cur_ring); | ||
619 | if (ret) { | 727 | if (ret) { |
620 | xhci_ring_free(xhci, cur_ring); | 728 | xhci_ring_free(xhci, cur_ring); |
621 | stream_info->stream_rings[cur_stream] = NULL; | 729 | stream_info->stream_rings[cur_stream] = NULL; |
@@ -635,9 +743,6 @@ cleanup_rings: | |||
635 | for (cur_stream = 1; cur_stream < num_streams; cur_stream++) { | 743 | for (cur_stream = 1; cur_stream < num_streams; cur_stream++) { |
636 | cur_ring = stream_info->stream_rings[cur_stream]; | 744 | cur_ring = stream_info->stream_rings[cur_stream]; |
637 | if (cur_ring) { | 745 | if (cur_ring) { |
638 | addr = cur_ring->first_seg->dma; | ||
639 | radix_tree_delete(&stream_info->trb_address_map, | ||
640 | addr >> TRB_SEGMENT_SHIFT); | ||
641 | xhci_ring_free(xhci, cur_ring); | 746 | xhci_ring_free(xhci, cur_ring); |
642 | stream_info->stream_rings[cur_stream] = NULL; | 747 | stream_info->stream_rings[cur_stream] = NULL; |
643 | } | 748 | } |
@@ -698,7 +803,6 @@ void xhci_free_stream_info(struct xhci_hcd *xhci, | |||
698 | { | 803 | { |
699 | int cur_stream; | 804 | int cur_stream; |
700 | struct xhci_ring *cur_ring; | 805 | struct xhci_ring *cur_ring; |
701 | dma_addr_t addr; | ||
702 | 806 | ||
703 | if (!stream_info) | 807 | if (!stream_info) |
704 | return; | 808 | return; |
@@ -707,9 +811,6 @@ void xhci_free_stream_info(struct xhci_hcd *xhci, | |||
707 | cur_stream++) { | 811 | cur_stream++) { |
708 | cur_ring = stream_info->stream_rings[cur_stream]; | 812 | cur_ring = stream_info->stream_rings[cur_stream]; |
709 | if (cur_ring) { | 813 | if (cur_ring) { |
710 | addr = cur_ring->first_seg->dma; | ||
711 | radix_tree_delete(&stream_info->trb_address_map, | ||
712 | addr >> TRB_SEGMENT_SHIFT); | ||
713 | xhci_ring_free(xhci, cur_ring); | 814 | xhci_ring_free(xhci, cur_ring); |
714 | stream_info->stream_rings[cur_stream] = NULL; | 815 | stream_info->stream_rings[cur_stream] = NULL; |
715 | } | 816 | } |
@@ -1711,7 +1812,6 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) | |||
1711 | 1812 | ||
1712 | if (xhci->lpm_command) | 1813 | if (xhci->lpm_command) |
1713 | xhci_free_command(xhci, xhci->lpm_command); | 1814 | xhci_free_command(xhci, xhci->lpm_command); |
1714 | xhci->cmd_ring_reserved_trbs = 0; | ||
1715 | if (xhci->cmd_ring) | 1815 | if (xhci->cmd_ring) |
1716 | xhci_ring_free(xhci, xhci->cmd_ring); | 1816 | xhci_ring_free(xhci, xhci->cmd_ring); |
1717 | xhci->cmd_ring = NULL; | 1817 | xhci->cmd_ring = NULL; |
@@ -1776,6 +1876,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) | |||
1776 | } | 1876 | } |
1777 | 1877 | ||
1778 | no_bw: | 1878 | no_bw: |
1879 | xhci->cmd_ring_reserved_trbs = 0; | ||
1779 | xhci->num_usb2_ports = 0; | 1880 | xhci->num_usb2_ports = 0; |
1780 | xhci->num_usb3_ports = 0; | 1881 | xhci->num_usb3_ports = 0; |
1781 | xhci->num_active_eps = 0; | 1882 | xhci->num_active_eps = 0; |
@@ -2274,11 +2375,12 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2274 | /* | 2375 | /* |
2275 | * Initialize the ring segment pool. The ring must be a contiguous | 2376 | * Initialize the ring segment pool. The ring must be a contiguous |
2276 | * structure comprised of TRBs. The TRBs must be 16 byte aligned, | 2377 | * structure comprised of TRBs. The TRBs must be 16 byte aligned, |
2277 | * however, the command ring segment needs 64-byte aligned segments, | 2378 | * however, the command ring segment needs 64-byte aligned segments |
2278 | * so we pick the greater alignment need. | 2379 | * and our use of dma addresses in the trb_address_map radix tree needs |
2380 | * TRB_SEGMENT_SIZE alignment, so we pick the greater alignment need. | ||
2279 | */ | 2381 | */ |
2280 | xhci->segment_pool = dma_pool_create("xHCI ring segments", dev, | 2382 | xhci->segment_pool = dma_pool_create("xHCI ring segments", dev, |
2281 | TRB_SEGMENT_SIZE, 64, xhci->page_size); | 2383 | TRB_SEGMENT_SIZE, TRB_SEGMENT_SIZE, xhci->page_size); |
2282 | 2384 | ||
2283 | /* See Table 46 and Note on Figure 55 */ | 2385 | /* See Table 46 and Note on Figure 55 */ |
2284 | xhci->device_pool = dma_pool_create("xHCI input/output contexts", dev, | 2386 | xhci->device_pool = dma_pool_create("xHCI input/output contexts", dev, |
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 04f986d9234f..47390e369cd4 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
@@ -190,6 +190,10 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
190 | struct usb_hcd *hcd; | 190 | struct usb_hcd *hcd; |
191 | 191 | ||
192 | driver = (struct hc_driver *)id->driver_data; | 192 | driver = (struct hc_driver *)id->driver_data; |
193 | |||
194 | /* Prevent runtime suspending between USB-2 and USB-3 initialization */ | ||
195 | pm_runtime_get_noresume(&dev->dev); | ||
196 | |||
193 | /* Register the USB 2.0 roothub. | 197 | /* Register the USB 2.0 roothub. |
194 | * FIXME: USB core must know to register the USB 2.0 roothub first. | 198 | * FIXME: USB core must know to register the USB 2.0 roothub first. |
195 | * This is sort of silly, because we could just set the HCD driver flags | 199 | * This is sort of silly, because we could just set the HCD driver flags |
@@ -199,7 +203,7 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
199 | retval = usb_hcd_pci_probe(dev, id); | 203 | retval = usb_hcd_pci_probe(dev, id); |
200 | 204 | ||
201 | if (retval) | 205 | if (retval) |
202 | return retval; | 206 | goto put_runtime_pm; |
203 | 207 | ||
204 | /* USB 2.0 roothub is stored in the PCI device now. */ | 208 | /* USB 2.0 roothub is stored in the PCI device now. */ |
205 | hcd = dev_get_drvdata(&dev->dev); | 209 | hcd = dev_get_drvdata(&dev->dev); |
@@ -222,11 +226,11 @@ static int xhci_pci_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
222 | goto put_usb3_hcd; | 226 | goto put_usb3_hcd; |
223 | /* Roothub already marked as USB 3.0 speed */ | 227 | /* Roothub already marked as USB 3.0 speed */ |
224 | 228 | ||
225 | /* We know the LPM timeout algorithms for this host, let the USB core | 229 | if (HCC_MAX_PSA(xhci->hcc_params) >= 4) |
226 | * enable and disable LPM for devices under the USB 3.0 roothub. | 230 | xhci->shared_hcd->can_do_streams = 1; |
227 | */ | 231 | |
228 | if (xhci->quirks & XHCI_LPM_SUPPORT) | 232 | /* USB-2 and USB-3 roothubs initialized, allow runtime pm suspend */ |
229 | hcd_to_bus(xhci->shared_hcd)->root_hub->lpm_capable = 1; | 233 | pm_runtime_put_noidle(&dev->dev); |
230 | 234 | ||
231 | return 0; | 235 | return 0; |
232 | 236 | ||
@@ -234,6 +238,8 @@ put_usb3_hcd: | |||
234 | usb_put_hcd(xhci->shared_hcd); | 238 | usb_put_hcd(xhci->shared_hcd); |
235 | dealloc_usb2_hcd: | 239 | dealloc_usb2_hcd: |
236 | usb_hcd_pci_remove(dev); | 240 | usb_hcd_pci_remove(dev); |
241 | put_runtime_pm: | ||
242 | pm_runtime_put_noidle(&dev->dev); | ||
237 | return retval; | 243 | return retval; |
238 | } | 244 | } |
239 | 245 | ||
diff --git a/drivers/usb/host/xhci-plat.c b/drivers/usb/host/xhci-plat.c index 8abda5c73ca1..151901ce1ba9 100644 --- a/drivers/usb/host/xhci-plat.c +++ b/drivers/usb/host/xhci-plat.c | |||
@@ -158,6 +158,9 @@ static int xhci_plat_probe(struct platform_device *pdev) | |||
158 | */ | 158 | */ |
159 | *((struct xhci_hcd **) xhci->shared_hcd->hcd_priv) = xhci; | 159 | *((struct xhci_hcd **) xhci->shared_hcd->hcd_priv) = xhci; |
160 | 160 | ||
161 | if (HCC_MAX_PSA(xhci->hcc_params) >= 4) | ||
162 | xhci->shared_hcd->can_do_streams = 1; | ||
163 | |||
161 | ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); | 164 | ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); |
162 | if (ret) | 165 | if (ret) |
163 | goto put_usb3_hcd; | 166 | goto put_usb3_hcd; |
@@ -226,6 +229,7 @@ static const struct dev_pm_ops xhci_plat_pm_ops = { | |||
226 | 229 | ||
227 | #ifdef CONFIG_OF | 230 | #ifdef CONFIG_OF |
228 | static const struct of_device_id usb_xhci_of_match[] = { | 231 | static const struct of_device_id usb_xhci_of_match[] = { |
232 | { .compatible = "generic-xhci" }, | ||
229 | { .compatible = "xhci-platform" }, | 233 | { .compatible = "xhci-platform" }, |
230 | { }, | 234 | { }, |
231 | }; | 235 | }; |
diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 0ed64eb68e48..5f926bea5ab1 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c | |||
@@ -546,9 +546,9 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, | |||
546 | struct xhci_dequeue_state *state) | 546 | struct xhci_dequeue_state *state) |
547 | { | 547 | { |
548 | struct xhci_virt_device *dev = xhci->devs[slot_id]; | 548 | struct xhci_virt_device *dev = xhci->devs[slot_id]; |
549 | struct xhci_virt_ep *ep = &dev->eps[ep_index]; | ||
549 | struct xhci_ring *ep_ring; | 550 | struct xhci_ring *ep_ring; |
550 | struct xhci_generic_trb *trb; | 551 | struct xhci_generic_trb *trb; |
551 | struct xhci_ep_ctx *ep_ctx; | ||
552 | dma_addr_t addr; | 552 | dma_addr_t addr; |
553 | 553 | ||
554 | ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id, | 554 | ep_ring = xhci_triad_to_transfer_ring(xhci, slot_id, |
@@ -573,8 +573,16 @@ void xhci_find_new_dequeue_state(struct xhci_hcd *xhci, | |||
573 | /* Dig out the cycle state saved by the xHC during the stop ep cmd */ | 573 | /* Dig out the cycle state saved by the xHC during the stop ep cmd */ |
574 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | 574 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, |
575 | "Finding endpoint context"); | 575 | "Finding endpoint context"); |
576 | ep_ctx = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index); | 576 | /* 4.6.9 the css flag is written to the stream context for streams */ |
577 | state->new_cycle_state = 0x1 & le64_to_cpu(ep_ctx->deq); | 577 | if (ep->ep_state & EP_HAS_STREAMS) { |
578 | struct xhci_stream_ctx *ctx = | ||
579 | &ep->stream_info->stream_ctx_array[stream_id]; | ||
580 | state->new_cycle_state = 0x1 & le64_to_cpu(ctx->stream_ring); | ||
581 | } else { | ||
582 | struct xhci_ep_ctx *ep_ctx | ||
583 | = xhci_get_ep_ctx(xhci, dev->out_ctx, ep_index); | ||
584 | state->new_cycle_state = 0x1 & le64_to_cpu(ep_ctx->deq); | ||
585 | } | ||
578 | 586 | ||
579 | state->new_deq_ptr = cur_td->last_trb; | 587 | state->new_deq_ptr = cur_td->last_trb; |
580 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | 588 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, |
@@ -892,6 +900,57 @@ remove_finished_td: | |||
892 | /* Return to the event handler with xhci->lock re-acquired */ | 900 | /* Return to the event handler with xhci->lock re-acquired */ |
893 | } | 901 | } |
894 | 902 | ||
903 | static void xhci_kill_ring_urbs(struct xhci_hcd *xhci, struct xhci_ring *ring) | ||
904 | { | ||
905 | struct xhci_td *cur_td; | ||
906 | |||
907 | while (!list_empty(&ring->td_list)) { | ||
908 | cur_td = list_first_entry(&ring->td_list, | ||
909 | struct xhci_td, td_list); | ||
910 | list_del_init(&cur_td->td_list); | ||
911 | if (!list_empty(&cur_td->cancelled_td_list)) | ||
912 | list_del_init(&cur_td->cancelled_td_list); | ||
913 | xhci_giveback_urb_in_irq(xhci, cur_td, -ESHUTDOWN); | ||
914 | } | ||
915 | } | ||
916 | |||
917 | static void xhci_kill_endpoint_urbs(struct xhci_hcd *xhci, | ||
918 | int slot_id, int ep_index) | ||
919 | { | ||
920 | struct xhci_td *cur_td; | ||
921 | struct xhci_virt_ep *ep; | ||
922 | struct xhci_ring *ring; | ||
923 | |||
924 | ep = &xhci->devs[slot_id]->eps[ep_index]; | ||
925 | if ((ep->ep_state & EP_HAS_STREAMS) || | ||
926 | (ep->ep_state & EP_GETTING_NO_STREAMS)) { | ||
927 | int stream_id; | ||
928 | |||
929 | for (stream_id = 0; stream_id < ep->stream_info->num_streams; | ||
930 | stream_id++) { | ||
931 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | ||
932 | "Killing URBs for slot ID %u, ep index %u, stream %u", | ||
933 | slot_id, ep_index, stream_id + 1); | ||
934 | xhci_kill_ring_urbs(xhci, | ||
935 | ep->stream_info->stream_rings[stream_id]); | ||
936 | } | ||
937 | } else { | ||
938 | ring = ep->ring; | ||
939 | if (!ring) | ||
940 | return; | ||
941 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | ||
942 | "Killing URBs for slot ID %u, ep index %u", | ||
943 | slot_id, ep_index); | ||
944 | xhci_kill_ring_urbs(xhci, ring); | ||
945 | } | ||
946 | while (!list_empty(&ep->cancelled_td_list)) { | ||
947 | cur_td = list_first_entry(&ep->cancelled_td_list, | ||
948 | struct xhci_td, cancelled_td_list); | ||
949 | list_del_init(&cur_td->cancelled_td_list); | ||
950 | xhci_giveback_urb_in_irq(xhci, cur_td, -ESHUTDOWN); | ||
951 | } | ||
952 | } | ||
953 | |||
895 | /* Watchdog timer function for when a stop endpoint command fails to complete. | 954 | /* Watchdog timer function for when a stop endpoint command fails to complete. |
896 | * In this case, we assume the host controller is broken or dying or dead. The | 955 | * In this case, we assume the host controller is broken or dying or dead. The |
897 | * host may still be completing some other events, so we have to be careful to | 956 | * host may still be completing some other events, so we have to be careful to |
@@ -915,9 +974,6 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) | |||
915 | { | 974 | { |
916 | struct xhci_hcd *xhci; | 975 | struct xhci_hcd *xhci; |
917 | struct xhci_virt_ep *ep; | 976 | struct xhci_virt_ep *ep; |
918 | struct xhci_virt_ep *temp_ep; | ||
919 | struct xhci_ring *ring; | ||
920 | struct xhci_td *cur_td; | ||
921 | int ret, i, j; | 977 | int ret, i, j; |
922 | unsigned long flags; | 978 | unsigned long flags; |
923 | 979 | ||
@@ -974,34 +1030,8 @@ void xhci_stop_endpoint_command_watchdog(unsigned long arg) | |||
974 | for (i = 0; i < MAX_HC_SLOTS; i++) { | 1030 | for (i = 0; i < MAX_HC_SLOTS; i++) { |
975 | if (!xhci->devs[i]) | 1031 | if (!xhci->devs[i]) |
976 | continue; | 1032 | continue; |
977 | for (j = 0; j < 31; j++) { | 1033 | for (j = 0; j < 31; j++) |
978 | temp_ep = &xhci->devs[i]->eps[j]; | 1034 | xhci_kill_endpoint_urbs(xhci, i, j); |
979 | ring = temp_ep->ring; | ||
980 | if (!ring) | ||
981 | continue; | ||
982 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | ||
983 | "Killing URBs for slot ID %u, " | ||
984 | "ep index %u", i, j); | ||
985 | while (!list_empty(&ring->td_list)) { | ||
986 | cur_td = list_first_entry(&ring->td_list, | ||
987 | struct xhci_td, | ||
988 | td_list); | ||
989 | list_del_init(&cur_td->td_list); | ||
990 | if (!list_empty(&cur_td->cancelled_td_list)) | ||
991 | list_del_init(&cur_td->cancelled_td_list); | ||
992 | xhci_giveback_urb_in_irq(xhci, cur_td, | ||
993 | -ESHUTDOWN); | ||
994 | } | ||
995 | while (!list_empty(&temp_ep->cancelled_td_list)) { | ||
996 | cur_td = list_first_entry( | ||
997 | &temp_ep->cancelled_td_list, | ||
998 | struct xhci_td, | ||
999 | cancelled_td_list); | ||
1000 | list_del_init(&cur_td->cancelled_td_list); | ||
1001 | xhci_giveback_urb_in_irq(xhci, cur_td, | ||
1002 | -ESHUTDOWN); | ||
1003 | } | ||
1004 | } | ||
1005 | } | 1035 | } |
1006 | spin_unlock_irqrestore(&xhci->lock, flags); | 1036 | spin_unlock_irqrestore(&xhci->lock, flags); |
1007 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | 1037 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, |
@@ -1073,17 +1103,18 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, | |||
1073 | unsigned int stream_id; | 1103 | unsigned int stream_id; |
1074 | struct xhci_ring *ep_ring; | 1104 | struct xhci_ring *ep_ring; |
1075 | struct xhci_virt_device *dev; | 1105 | struct xhci_virt_device *dev; |
1106 | struct xhci_virt_ep *ep; | ||
1076 | struct xhci_ep_ctx *ep_ctx; | 1107 | struct xhci_ep_ctx *ep_ctx; |
1077 | struct xhci_slot_ctx *slot_ctx; | 1108 | struct xhci_slot_ctx *slot_ctx; |
1078 | 1109 | ||
1079 | ep_index = TRB_TO_EP_INDEX(le32_to_cpu(trb->generic.field[3])); | 1110 | ep_index = TRB_TO_EP_INDEX(le32_to_cpu(trb->generic.field[3])); |
1080 | stream_id = TRB_TO_STREAM_ID(le32_to_cpu(trb->generic.field[2])); | 1111 | stream_id = TRB_TO_STREAM_ID(le32_to_cpu(trb->generic.field[2])); |
1081 | dev = xhci->devs[slot_id]; | 1112 | dev = xhci->devs[slot_id]; |
1113 | ep = &dev->eps[ep_index]; | ||
1082 | 1114 | ||
1083 | ep_ring = xhci_stream_id_to_ring(dev, ep_index, stream_id); | 1115 | ep_ring = xhci_stream_id_to_ring(dev, ep_index, stream_id); |
1084 | if (!ep_ring) { | 1116 | if (!ep_ring) { |
1085 | xhci_warn(xhci, "WARN Set TR deq ptr command for " | 1117 | xhci_warn(xhci, "WARN Set TR deq ptr command for freed stream ID %u\n", |
1086 | "freed stream ID %u\n", | ||
1087 | stream_id); | 1118 | stream_id); |
1088 | /* XXX: Harmless??? */ | 1119 | /* XXX: Harmless??? */ |
1089 | dev->eps[ep_index].ep_state &= ~SET_DEQ_PENDING; | 1120 | dev->eps[ep_index].ep_state &= ~SET_DEQ_PENDING; |
@@ -1099,12 +1130,10 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, | |||
1099 | 1130 | ||
1100 | switch (cmd_comp_code) { | 1131 | switch (cmd_comp_code) { |
1101 | case COMP_TRB_ERR: | 1132 | case COMP_TRB_ERR: |
1102 | xhci_warn(xhci, "WARN Set TR Deq Ptr cmd invalid because " | 1133 | xhci_warn(xhci, "WARN Set TR Deq Ptr cmd invalid because of stream ID configuration\n"); |
1103 | "of stream ID configuration\n"); | ||
1104 | break; | 1134 | break; |
1105 | case COMP_CTX_STATE: | 1135 | case COMP_CTX_STATE: |
1106 | xhci_warn(xhci, "WARN Set TR Deq Ptr cmd failed due " | 1136 | xhci_warn(xhci, "WARN Set TR Deq Ptr cmd failed due to incorrect slot or ep state.\n"); |
1107 | "to incorrect slot or ep state.\n"); | ||
1108 | ep_state = le32_to_cpu(ep_ctx->ep_info); | 1137 | ep_state = le32_to_cpu(ep_ctx->ep_info); |
1109 | ep_state &= EP_STATE_MASK; | 1138 | ep_state &= EP_STATE_MASK; |
1110 | slot_state = le32_to_cpu(slot_ctx->dev_state); | 1139 | slot_state = le32_to_cpu(slot_ctx->dev_state); |
@@ -1114,13 +1143,12 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, | |||
1114 | slot_state, ep_state); | 1143 | slot_state, ep_state); |
1115 | break; | 1144 | break; |
1116 | case COMP_EBADSLT: | 1145 | case COMP_EBADSLT: |
1117 | xhci_warn(xhci, "WARN Set TR Deq Ptr cmd failed because " | 1146 | xhci_warn(xhci, "WARN Set TR Deq Ptr cmd failed because slot %u was not enabled.\n", |
1118 | "slot %u was not enabled.\n", slot_id); | 1147 | slot_id); |
1119 | break; | 1148 | break; |
1120 | default: | 1149 | default: |
1121 | xhci_warn(xhci, "WARN Set TR Deq Ptr cmd with unknown " | 1150 | xhci_warn(xhci, "WARN Set TR Deq Ptr cmd with unknown completion code of %u.\n", |
1122 | "completion code of %u.\n", | 1151 | cmd_comp_code); |
1123 | cmd_comp_code); | ||
1124 | break; | 1152 | break; |
1125 | } | 1153 | } |
1126 | /* OK what do we do now? The endpoint state is hosed, and we | 1154 | /* OK what do we do now? The endpoint state is hosed, and we |
@@ -1130,23 +1158,28 @@ static void xhci_handle_cmd_set_deq(struct xhci_hcd *xhci, int slot_id, | |||
1130 | * cancelling URBs, which might not be an error... | 1158 | * cancelling URBs, which might not be an error... |
1131 | */ | 1159 | */ |
1132 | } else { | 1160 | } else { |
1161 | u64 deq; | ||
1162 | /* 4.6.10 deq ptr is written to the stream ctx for streams */ | ||
1163 | if (ep->ep_state & EP_HAS_STREAMS) { | ||
1164 | struct xhci_stream_ctx *ctx = | ||
1165 | &ep->stream_info->stream_ctx_array[stream_id]; | ||
1166 | deq = le64_to_cpu(ctx->stream_ring) & SCTX_DEQ_MASK; | ||
1167 | } else { | ||
1168 | deq = le64_to_cpu(ep_ctx->deq) & ~EP_CTX_CYCLE_MASK; | ||
1169 | } | ||
1133 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, | 1170 | xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb, |
1134 | "Successful Set TR Deq Ptr cmd, deq = @%08llx", | 1171 | "Successful Set TR Deq Ptr cmd, deq = @%08llx", deq); |
1135 | le64_to_cpu(ep_ctx->deq)); | 1172 | if (xhci_trb_virt_to_dma(ep->queued_deq_seg, |
1136 | if (xhci_trb_virt_to_dma(dev->eps[ep_index].queued_deq_seg, | 1173 | ep->queued_deq_ptr) == deq) { |
1137 | dev->eps[ep_index].queued_deq_ptr) == | ||
1138 | (le64_to_cpu(ep_ctx->deq) & ~(EP_CTX_CYCLE_MASK))) { | ||
1139 | /* Update the ring's dequeue segment and dequeue pointer | 1174 | /* Update the ring's dequeue segment and dequeue pointer |
1140 | * to reflect the new position. | 1175 | * to reflect the new position. |
1141 | */ | 1176 | */ |
1142 | update_ring_for_set_deq_completion(xhci, dev, | 1177 | update_ring_for_set_deq_completion(xhci, dev, |
1143 | ep_ring, ep_index); | 1178 | ep_ring, ep_index); |
1144 | } else { | 1179 | } else { |
1145 | xhci_warn(xhci, "Mismatch between completed Set TR Deq " | 1180 | xhci_warn(xhci, "Mismatch between completed Set TR Deq Ptr command & xHCI internal state.\n"); |
1146 | "Ptr command & xHCI internal state.\n"); | ||
1147 | xhci_warn(xhci, "ep deq seg = %p, deq ptr = %p\n", | 1181 | xhci_warn(xhci, "ep deq seg = %p, deq ptr = %p\n", |
1148 | dev->eps[ep_index].queued_deq_seg, | 1182 | ep->queued_deq_seg, ep->queued_deq_ptr); |
1149 | dev->eps[ep_index].queued_deq_ptr); | ||
1150 | } | 1183 | } |
1151 | } | 1184 | } |
1152 | 1185 | ||
@@ -4070,6 +4103,7 @@ static int queue_set_tr_deq(struct xhci_hcd *xhci, int slot_id, | |||
4070 | u32 trb_slot_id = SLOT_ID_FOR_TRB(slot_id); | 4103 | u32 trb_slot_id = SLOT_ID_FOR_TRB(slot_id); |
4071 | u32 trb_ep_index = EP_ID_FOR_TRB(ep_index); | 4104 | u32 trb_ep_index = EP_ID_FOR_TRB(ep_index); |
4072 | u32 trb_stream_id = STREAM_ID_FOR_TRB(stream_id); | 4105 | u32 trb_stream_id = STREAM_ID_FOR_TRB(stream_id); |
4106 | u32 trb_sct = 0; | ||
4073 | u32 type = TRB_TYPE(TRB_SET_DEQ); | 4107 | u32 type = TRB_TYPE(TRB_SET_DEQ); |
4074 | struct xhci_virt_ep *ep; | 4108 | struct xhci_virt_ep *ep; |
4075 | 4109 | ||
@@ -4088,7 +4122,9 @@ static int queue_set_tr_deq(struct xhci_hcd *xhci, int slot_id, | |||
4088 | } | 4122 | } |
4089 | ep->queued_deq_seg = deq_seg; | 4123 | ep->queued_deq_seg = deq_seg; |
4090 | ep->queued_deq_ptr = deq_ptr; | 4124 | ep->queued_deq_ptr = deq_ptr; |
4091 | return queue_command(xhci, lower_32_bits(addr) | cycle_state, | 4125 | if (stream_id) |
4126 | trb_sct = SCT_FOR_TRB(SCT_PRI_TR); | ||
4127 | return queue_command(xhci, lower_32_bits(addr) | trb_sct | cycle_state, | ||
4092 | upper_32_bits(addr), trb_stream_id, | 4128 | upper_32_bits(addr), trb_stream_id, |
4093 | trb_slot_id | trb_ep_index | type, false); | 4129 | trb_slot_id | trb_ep_index | type, false); |
4094 | } | 4130 | } |
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 924a6ccdb622..8fe4e124ddd4 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
@@ -390,6 +390,10 @@ static int xhci_try_enable_msi(struct usb_hcd *hcd) | |||
390 | } | 390 | } |
391 | 391 | ||
392 | legacy_irq: | 392 | legacy_irq: |
393 | if (!strlen(hcd->irq_descr)) | ||
394 | snprintf(hcd->irq_descr, sizeof(hcd->irq_descr), "%s:usb%d", | ||
395 | hcd->driver->description, hcd->self.busnum); | ||
396 | |||
393 | /* fall back to legacy interrupt*/ | 397 | /* fall back to legacy interrupt*/ |
394 | ret = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED, | 398 | ret = request_irq(pdev->irq, &usb_hcd_irq, IRQF_SHARED, |
395 | hcd->irq_descr, hcd); | 399 | hcd->irq_descr, hcd); |
@@ -2678,6 +2682,20 @@ static int xhci_configure_endpoint(struct xhci_hcd *xhci, | |||
2678 | return ret; | 2682 | return ret; |
2679 | } | 2683 | } |
2680 | 2684 | ||
2685 | static void xhci_check_bw_drop_ep_streams(struct xhci_hcd *xhci, | ||
2686 | struct xhci_virt_device *vdev, int i) | ||
2687 | { | ||
2688 | struct xhci_virt_ep *ep = &vdev->eps[i]; | ||
2689 | |||
2690 | if (ep->ep_state & EP_HAS_STREAMS) { | ||
2691 | xhci_warn(xhci, "WARN: endpoint 0x%02x has streams on set_interface, freeing streams.\n", | ||
2692 | xhci_get_endpoint_address(i)); | ||
2693 | xhci_free_stream_info(xhci, ep->stream_info); | ||
2694 | ep->stream_info = NULL; | ||
2695 | ep->ep_state &= ~EP_HAS_STREAMS; | ||
2696 | } | ||
2697 | } | ||
2698 | |||
2681 | /* Called after one or more calls to xhci_add_endpoint() or | 2699 | /* Called after one or more calls to xhci_add_endpoint() or |
2682 | * xhci_drop_endpoint(). If this call fails, the USB core is expected | 2700 | * xhci_drop_endpoint(). If this call fails, the USB core is expected |
2683 | * to call xhci_reset_bandwidth(). | 2701 | * to call xhci_reset_bandwidth(). |
@@ -2742,8 +2760,10 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev) | |||
2742 | /* Free any rings that were dropped, but not changed. */ | 2760 | /* Free any rings that were dropped, but not changed. */ |
2743 | for (i = 1; i < 31; ++i) { | 2761 | for (i = 1; i < 31; ++i) { |
2744 | if ((le32_to_cpu(ctrl_ctx->drop_flags) & (1 << (i + 1))) && | 2762 | if ((le32_to_cpu(ctrl_ctx->drop_flags) & (1 << (i + 1))) && |
2745 | !(le32_to_cpu(ctrl_ctx->add_flags) & (1 << (i + 1)))) | 2763 | !(le32_to_cpu(ctrl_ctx->add_flags) & (1 << (i + 1)))) { |
2746 | xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i); | 2764 | xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i); |
2765 | xhci_check_bw_drop_ep_streams(xhci, virt_dev, i); | ||
2766 | } | ||
2747 | } | 2767 | } |
2748 | xhci_zero_in_ctx(xhci, virt_dev); | 2768 | xhci_zero_in_ctx(xhci, virt_dev); |
2749 | /* | 2769 | /* |
@@ -2759,6 +2779,7 @@ int xhci_check_bandwidth(struct usb_hcd *hcd, struct usb_device *udev) | |||
2759 | if (virt_dev->eps[i].ring) { | 2779 | if (virt_dev->eps[i].ring) { |
2760 | xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i); | 2780 | xhci_free_or_cache_endpoint_ring(xhci, virt_dev, i); |
2761 | } | 2781 | } |
2782 | xhci_check_bw_drop_ep_streams(xhci, virt_dev, i); | ||
2762 | virt_dev->eps[i].ring = virt_dev->eps[i].new_ring; | 2783 | virt_dev->eps[i].ring = virt_dev->eps[i].new_ring; |
2763 | virt_dev->eps[i].new_ring = NULL; | 2784 | virt_dev->eps[i].new_ring = NULL; |
2764 | } | 2785 | } |
@@ -2954,7 +2975,7 @@ static int xhci_check_streams_endpoint(struct xhci_hcd *xhci, | |||
2954 | ret = xhci_check_args(xhci_to_hcd(xhci), udev, ep, 1, true, __func__); | 2975 | ret = xhci_check_args(xhci_to_hcd(xhci), udev, ep, 1, true, __func__); |
2955 | if (ret <= 0) | 2976 | if (ret <= 0) |
2956 | return -EINVAL; | 2977 | return -EINVAL; |
2957 | if (ep->ss_ep_comp.bmAttributes == 0) { | 2978 | if (usb_ss_max_streams(&ep->ss_ep_comp) == 0) { |
2958 | xhci_warn(xhci, "WARN: SuperSpeed Endpoint Companion" | 2979 | xhci_warn(xhci, "WARN: SuperSpeed Endpoint Companion" |
2959 | " descriptor for ep 0x%x does not support streams\n", | 2980 | " descriptor for ep 0x%x does not support streams\n", |
2960 | ep->desc.bEndpointAddress); | 2981 | ep->desc.bEndpointAddress); |
@@ -3121,6 +3142,12 @@ int xhci_alloc_streams(struct usb_hcd *hcd, struct usb_device *udev, | |||
3121 | xhci_dbg(xhci, "Driver wants %u stream IDs (including stream 0).\n", | 3142 | xhci_dbg(xhci, "Driver wants %u stream IDs (including stream 0).\n", |
3122 | num_streams); | 3143 | num_streams); |
3123 | 3144 | ||
3145 | /* MaxPSASize value 0 (2 streams) means streams are not supported */ | ||
3146 | if (HCC_MAX_PSA(xhci->hcc_params) < 4) { | ||
3147 | xhci_dbg(xhci, "xHCI controller does not support streams.\n"); | ||
3148 | return -ENOSYS; | ||
3149 | } | ||
3150 | |||
3124 | config_cmd = xhci_alloc_command(xhci, true, true, mem_flags); | 3151 | config_cmd = xhci_alloc_command(xhci, true, true, mem_flags); |
3125 | if (!config_cmd) { | 3152 | if (!config_cmd) { |
3126 | xhci_dbg(xhci, "Could not allocate xHCI command structure.\n"); | 3153 | xhci_dbg(xhci, "Could not allocate xHCI command structure.\n"); |
@@ -3519,6 +3546,8 @@ int xhci_discover_or_reset_device(struct usb_hcd *hcd, struct usb_device *udev) | |||
3519 | struct xhci_virt_ep *ep = &virt_dev->eps[i]; | 3546 | struct xhci_virt_ep *ep = &virt_dev->eps[i]; |
3520 | 3547 | ||
3521 | if (ep->ep_state & EP_HAS_STREAMS) { | 3548 | if (ep->ep_state & EP_HAS_STREAMS) { |
3549 | xhci_warn(xhci, "WARN: endpoint 0x%02x has streams on device reset, freeing streams.\n", | ||
3550 | xhci_get_endpoint_address(i)); | ||
3522 | xhci_free_stream_info(xhci, ep->stream_info); | 3551 | xhci_free_stream_info(xhci, ep->stream_info); |
3523 | ep->stream_info = NULL; | 3552 | ep->stream_info = NULL; |
3524 | ep->ep_state &= ~EP_HAS_STREAMS; | 3553 | ep->ep_state &= ~EP_HAS_STREAMS; |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 58ed9d088e63..d280e9213d08 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
@@ -703,6 +703,7 @@ struct xhci_ep_ctx { | |||
703 | 703 | ||
704 | /* deq bitmasks */ | 704 | /* deq bitmasks */ |
705 | #define EP_CTX_CYCLE_MASK (1 << 0) | 705 | #define EP_CTX_CYCLE_MASK (1 << 0) |
706 | #define SCTX_DEQ_MASK (~0xfL) | ||
706 | 707 | ||
707 | 708 | ||
708 | /** | 709 | /** |
@@ -1118,9 +1119,10 @@ enum xhci_setup_dev { | |||
1118 | #define TRB_TO_SUSPEND_PORT(p) (((p) & (1 << 23)) >> 23) | 1119 | #define TRB_TO_SUSPEND_PORT(p) (((p) & (1 << 23)) >> 23) |
1119 | #define LAST_EP_INDEX 30 | 1120 | #define LAST_EP_INDEX 30 |
1120 | 1121 | ||
1121 | /* Set TR Dequeue Pointer command TRB fields */ | 1122 | /* Set TR Dequeue Pointer command TRB fields, 6.4.3.9 */ |
1122 | #define TRB_TO_STREAM_ID(p) ((((p) & (0xffff << 16)) >> 16)) | 1123 | #define TRB_TO_STREAM_ID(p) ((((p) & (0xffff << 16)) >> 16)) |
1123 | #define STREAM_ID_FOR_TRB(p) ((((p)) & 0xffff) << 16) | 1124 | #define STREAM_ID_FOR_TRB(p) ((((p)) & 0xffff) << 16) |
1125 | #define SCT_FOR_TRB(p) (((p) << 1) & 0x7) | ||
1124 | 1126 | ||
1125 | 1127 | ||
1126 | /* Port Status Change Event TRB fields */ | 1128 | /* Port Status Change Event TRB fields */ |
@@ -1341,6 +1343,7 @@ struct xhci_ring { | |||
1341 | unsigned int num_trbs_free_temp; | 1343 | unsigned int num_trbs_free_temp; |
1342 | enum xhci_ring_type type; | 1344 | enum xhci_ring_type type; |
1343 | bool last_td_was_short; | 1345 | bool last_td_was_short; |
1346 | struct radix_tree_root *trb_address_map; | ||
1344 | }; | 1347 | }; |
1345 | 1348 | ||
1346 | struct xhci_erst_entry { | 1349 | struct xhci_erst_entry { |