On 01.12.2016 15:30, Felipe Balbi wrote:
Instead of always defaulting to a 256-entry array,
we can dynamically allocate devs based on what HW
tells us it supports.

Note that we can't, yet, purge MAX_HC_SLOTS
completely because of struct
xhci_device_context_array reliance on it.

Signed-off-by: Felipe Balbi <felipe.ba...@linux.intel.com>
---
  drivers/usb/host/xhci-hub.c  |  2 +-
  drivers/usb/host/xhci-mem.c  |  4 ++--
  drivers/usb/host/xhci-ring.c |  2 +-
  drivers/usb/host/xhci.c      | 19 +++++++++++++++----
  drivers/usb/host/xhci.h      |  2 +-
  5 files changed, 20 insertions(+), 9 deletions(-)

...

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1cd56417cbec..1113b5fea7b4 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -766,6 +766,8 @@ void xhci_shutdown(struct usb_hcd *hcd)
        /* Yet another workaround for spurious wakeups at shutdown with HSW */
        if (xhci->quirks & XHCI_SPURIOUS_WAKEUP)
                pci_set_power_state(to_pci_dev(hcd->self.controller), 
PCI_D3hot);
+
+       kfree(xhci->devs);

I don't think freeing xhci->devs at PCI .shutdown callback will work for driver 
unload, or for the
PCI hotplugged Alpine Ridge xhci solution.  xhci->devs would leak at next 
driver load.

xhci_mem_clenup() would be better

  }

  #ifdef CONFIG_PM
@@ -4896,6 +4898,11 @@ int xhci_gen_setup(struct usb_hcd *hcd, 
xhci_get_quirks_t get_quirks)

        xhci->quirks |= quirks;

+       xhci->devs = kcalloc(HCS_MAX_SLOTS(xhci->hcs_params1) + 1,
+                       sizeof(struct xhci_virt_device *), GFP_KERNEL);

maybe allocate the memory in xhci_mem_init(), it's done a bit later in 
xhci_gen_setup()
from xhci_init().

we halt, reset and set dma mask in between, but those should not depend on 
xhci->devs in
any way.

-Mathias
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to