diff options
author | Mathias Nyman <mathias.nyman@linux.intel.com> | 2020-07-23 17:45:07 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-07-23 18:05:26 +0300 |
commit | 0b832e997436d0336257cdc1bf2e265234239094 (patch) | |
tree | a0685514a9f735f1746bc1fcd59d92d3df5f911a /drivers/usb/host/xhci-dbgcap.c | |
parent | e3bc8004bde77e899e8d19487440f27b55e216b2 (diff) | |
download | linux-0b832e997436d0336257cdc1bf2e265234239094.tar.xz |
xhci: dbc: Don't use generic xhci erst allocation and free functions
The generic erst allocation and free functions take struct xhci_hcd pointer
as a parameter. Create own erst helpers for DbC in order to decouple xhci
and DbC
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20200723144530.9992-5-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/host/xhci-dbgcap.c')
-rw-r--r-- | drivers/usb/host/xhci-dbgcap.c | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/drivers/usb/host/xhci-dbgcap.c b/drivers/usb/host/xhci-dbgcap.c index 424b571d6ca9..138b0c994ad2 100644 --- a/drivers/usb/host/xhci-dbgcap.c +++ b/drivers/usb/host/xhci-dbgcap.c @@ -370,12 +370,36 @@ static void xhci_dbc_eps_exit(struct xhci_hcd *xhci) memset(dbc->eps, 0, sizeof(struct dbc_ep) * ARRAY_SIZE(dbc->eps)); } +static int dbc_erst_alloc(struct device *dev, struct xhci_ring *evt_ring, + struct xhci_erst *erst, gfp_t flags) +{ + erst->entries = dma_alloc_coherent(dev, sizeof(struct xhci_erst_entry), + &erst->erst_dma_addr, flags); + if (!erst->entries) + return -ENOMEM; + + erst->num_entries = 1; + erst->entries[0].seg_addr = cpu_to_le64(evt_ring->first_seg->dma); + erst->entries[0].seg_size = cpu_to_le32(TRBS_PER_SEGMENT); + erst->entries[0].rsvd = 0; + return 0; +} + +static void dbc_erst_free(struct device *dev, struct xhci_erst *erst) +{ + if (erst->entries) + dma_free_coherent(dev, sizeof(struct xhci_erst_entry), + erst->entries, erst->erst_dma_addr); + erst->entries = NULL; +} + static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) { int ret; dma_addr_t deq; u32 string_length; struct xhci_dbc *dbc = xhci->dbc; + struct device *dev = xhci_to_hcd(xhci)->self.controller; /* Allocate various rings for events and transfers: */ dbc->ring_evt = xhci_ring_alloc(xhci, 1, 1, TYPE_EVENT, 0, flags); @@ -391,7 +415,7 @@ static int xhci_dbc_mem_init(struct xhci_hcd *xhci, gfp_t flags) goto out_fail; /* Allocate and populate ERST: */ - ret = xhci_alloc_erst(xhci, dbc->ring_evt, &dbc->erst, flags); + ret = dbc_erst_alloc(dev, dbc->ring_evt, &dbc->erst, flags); if (ret) goto erst_fail; @@ -429,7 +453,7 @@ string_fail: xhci_free_container_ctx(xhci, dbc->ctx); dbc->ctx = NULL; ctx_fail: - xhci_free_erst(xhci, &dbc->erst); + dbc_erst_free(dev, &dbc->erst); erst_fail: xhci_ring_free(xhci, dbc->ring_out); dbc->ring_out = NULL; @@ -446,6 +470,7 @@ evt_fail: static void xhci_dbc_mem_cleanup(struct xhci_hcd *xhci) { struct xhci_dbc *dbc = xhci->dbc; + struct device *dev = xhci_to_hcd(xhci)->self.controller; if (!dbc) return; @@ -462,7 +487,7 @@ static void xhci_dbc_mem_cleanup(struct xhci_hcd *xhci) xhci_free_container_ctx(xhci, dbc->ctx); dbc->ctx = NULL; - xhci_free_erst(xhci, &dbc->erst); + dbc_erst_free(dev, &dbc->erst); xhci_ring_free(xhci, dbc->ring_out); xhci_ring_free(xhci, dbc->ring_in); xhci_ring_free(xhci, dbc->ring_evt); |