diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2011-09-23 17:19:59 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2011-09-26 18:51:13 -0400 |
commit | 22d45f01a836c2f5826b8b4b9e029e5f79afec57 (patch) | |
tree | d7a8ea760ba9bf64c45beecc325d251e690d0111 /drivers/usb/host | |
parent | 421aa841a134f6a743111cf44d0c6d3b45e3cf8c (diff) |
usb/xhci: replace pci_*_consistent() with dma_*_coherent()
pci_*_consistent() calls dma_*_coherent() with GFP_ATOMIC and requires
pci_dev struct. This is a preparion for later where we no longer have
the pci struct around.
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r-- | drivers/usb/host/xhci-mem.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index a6ff8252699e..42a22b8e6922 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
@@ -317,7 +317,7 @@ static void xhci_free_stream_ctx(struct xhci_hcd *xhci, | |||
317 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); | 317 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); |
318 | 318 | ||
319 | if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE) | 319 | if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE) |
320 | pci_free_consistent(pdev, | 320 | dma_free_coherent(&pdev->dev, |
321 | sizeof(struct xhci_stream_ctx)*num_stream_ctxs, | 321 | sizeof(struct xhci_stream_ctx)*num_stream_ctxs, |
322 | stream_ctx, dma); | 322 | stream_ctx, dma); |
323 | else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE) | 323 | else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE) |
@@ -345,9 +345,9 @@ static struct xhci_stream_ctx *xhci_alloc_stream_ctx(struct xhci_hcd *xhci, | |||
345 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); | 345 | struct pci_dev *pdev = to_pci_dev(xhci_to_hcd(xhci)->self.controller); |
346 | 346 | ||
347 | if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE) | 347 | if (num_stream_ctxs > MEDIUM_STREAM_ARRAY_SIZE) |
348 | return pci_alloc_consistent(pdev, | 348 | return dma_alloc_coherent(&pdev->dev, |
349 | sizeof(struct xhci_stream_ctx)*num_stream_ctxs, | 349 | sizeof(struct xhci_stream_ctx)*num_stream_ctxs, |
350 | dma); | 350 | dma, mem_flags); |
351 | else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE) | 351 | else if (num_stream_ctxs <= SMALL_STREAM_ARRAY_SIZE) |
352 | return dma_pool_alloc(xhci->small_streams_pool, | 352 | return dma_pool_alloc(xhci->small_streams_pool, |
353 | mem_flags, dma); | 353 | mem_flags, dma); |
@@ -1551,10 +1551,9 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) | |||
1551 | if (!xhci->scratchpad) | 1551 | if (!xhci->scratchpad) |
1552 | goto fail_sp; | 1552 | goto fail_sp; |
1553 | 1553 | ||
1554 | xhci->scratchpad->sp_array = | 1554 | xhci->scratchpad->sp_array = dma_alloc_coherent(dev, |
1555 | pci_alloc_consistent(to_pci_dev(dev), | ||
1556 | num_sp * sizeof(u64), | 1555 | num_sp * sizeof(u64), |
1557 | &xhci->scratchpad->sp_dma); | 1556 | &xhci->scratchpad->sp_dma, flags); |
1558 | if (!xhci->scratchpad->sp_array) | 1557 | if (!xhci->scratchpad->sp_array) |
1559 | goto fail_sp2; | 1558 | goto fail_sp2; |
1560 | 1559 | ||
@@ -1571,8 +1570,8 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) | |||
1571 | xhci->dcbaa->dev_context_ptrs[0] = cpu_to_le64(xhci->scratchpad->sp_dma); | 1570 | xhci->dcbaa->dev_context_ptrs[0] = cpu_to_le64(xhci->scratchpad->sp_dma); |
1572 | for (i = 0; i < num_sp; i++) { | 1571 | for (i = 0; i < num_sp; i++) { |
1573 | dma_addr_t dma; | 1572 | dma_addr_t dma; |
1574 | void *buf = pci_alloc_consistent(to_pci_dev(dev), | 1573 | void *buf = dma_alloc_coherent(dev, xhci->page_size, &dma, |
1575 | xhci->page_size, &dma); | 1574 | flags); |
1576 | if (!buf) | 1575 | if (!buf) |
1577 | goto fail_sp5; | 1576 | goto fail_sp5; |
1578 | 1577 | ||
@@ -1585,7 +1584,7 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) | |||
1585 | 1584 | ||
1586 | fail_sp5: | 1585 | fail_sp5: |
1587 | for (i = i - 1; i >= 0; i--) { | 1586 | for (i = i - 1; i >= 0; i--) { |
1588 | pci_free_consistent(to_pci_dev(dev), xhci->page_size, | 1587 | dma_free_coherent(dev, xhci->page_size, |
1589 | xhci->scratchpad->sp_buffers[i], | 1588 | xhci->scratchpad->sp_buffers[i], |
1590 | xhci->scratchpad->sp_dma_buffers[i]); | 1589 | xhci->scratchpad->sp_dma_buffers[i]); |
1591 | } | 1590 | } |
@@ -1595,7 +1594,7 @@ static int scratchpad_alloc(struct xhci_hcd *xhci, gfp_t flags) | |||
1595 | kfree(xhci->scratchpad->sp_buffers); | 1594 | kfree(xhci->scratchpad->sp_buffers); |
1596 | 1595 | ||
1597 | fail_sp3: | 1596 | fail_sp3: |
1598 | pci_free_consistent(to_pci_dev(dev), num_sp * sizeof(u64), | 1597 | dma_free_coherent(dev, num_sp * sizeof(u64), |
1599 | xhci->scratchpad->sp_array, | 1598 | xhci->scratchpad->sp_array, |
1600 | xhci->scratchpad->sp_dma); | 1599 | xhci->scratchpad->sp_dma); |
1601 | 1600 | ||
@@ -1619,13 +1618,13 @@ static void scratchpad_free(struct xhci_hcd *xhci) | |||
1619 | num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2); | 1618 | num_sp = HCS_MAX_SCRATCHPAD(xhci->hcs_params2); |
1620 | 1619 | ||
1621 | for (i = 0; i < num_sp; i++) { | 1620 | for (i = 0; i < num_sp; i++) { |
1622 | pci_free_consistent(pdev, xhci->page_size, | 1621 | dma_free_coherent(&pdev->dev, xhci->page_size, |
1623 | xhci->scratchpad->sp_buffers[i], | 1622 | xhci->scratchpad->sp_buffers[i], |
1624 | xhci->scratchpad->sp_dma_buffers[i]); | 1623 | xhci->scratchpad->sp_dma_buffers[i]); |
1625 | } | 1624 | } |
1626 | kfree(xhci->scratchpad->sp_dma_buffers); | 1625 | kfree(xhci->scratchpad->sp_dma_buffers); |
1627 | kfree(xhci->scratchpad->sp_buffers); | 1626 | kfree(xhci->scratchpad->sp_buffers); |
1628 | pci_free_consistent(pdev, num_sp * sizeof(u64), | 1627 | dma_free_coherent(&pdev->dev, num_sp * sizeof(u64), |
1629 | xhci->scratchpad->sp_array, | 1628 | xhci->scratchpad->sp_array, |
1630 | xhci->scratchpad->sp_dma); | 1629 | xhci->scratchpad->sp_dma); |
1631 | kfree(xhci->scratchpad); | 1630 | kfree(xhci->scratchpad); |
@@ -1701,7 +1700,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) | |||
1701 | } | 1700 | } |
1702 | size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); | 1701 | size = sizeof(struct xhci_erst_entry)*(xhci->erst.num_entries); |
1703 | if (xhci->erst.entries) | 1702 | if (xhci->erst.entries) |
1704 | pci_free_consistent(pdev, size, | 1703 | dma_free_coherent(&pdev->dev, size, |
1705 | xhci->erst.entries, xhci->erst.erst_dma_addr); | 1704 | xhci->erst.entries, xhci->erst.erst_dma_addr); |
1706 | xhci->erst.entries = NULL; | 1705 | xhci->erst.entries = NULL; |
1707 | xhci_dbg(xhci, "Freed ERST\n"); | 1706 | xhci_dbg(xhci, "Freed ERST\n"); |
@@ -1741,7 +1740,7 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) | |||
1741 | 1740 | ||
1742 | xhci_write_64(xhci, 0, &xhci->op_regs->dcbaa_ptr); | 1741 | xhci_write_64(xhci, 0, &xhci->op_regs->dcbaa_ptr); |
1743 | if (xhci->dcbaa) | 1742 | if (xhci->dcbaa) |
1744 | pci_free_consistent(pdev, sizeof(*xhci->dcbaa), | 1743 | dma_free_coherent(&pdev->dev, sizeof(*xhci->dcbaa), |
1745 | xhci->dcbaa, xhci->dcbaa->dma); | 1744 | xhci->dcbaa, xhci->dcbaa->dma); |
1746 | xhci->dcbaa = NULL; | 1745 | xhci->dcbaa = NULL; |
1747 | 1746 | ||
@@ -2197,8 +2196,8 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2197 | * Section 5.4.8 - doorbell array must be | 2196 | * Section 5.4.8 - doorbell array must be |
2198 | * "physically contiguous and 64-byte (cache line) aligned". | 2197 | * "physically contiguous and 64-byte (cache line) aligned". |
2199 | */ | 2198 | */ |
2200 | xhci->dcbaa = pci_alloc_consistent(to_pci_dev(dev), | 2199 | xhci->dcbaa = dma_alloc_coherent(dev, sizeof(*xhci->dcbaa), &dma, |
2201 | sizeof(*xhci->dcbaa), &dma); | 2200 | GFP_KERNEL); |
2202 | if (!xhci->dcbaa) | 2201 | if (!xhci->dcbaa) |
2203 | goto fail; | 2202 | goto fail; |
2204 | memset(xhci->dcbaa, 0, sizeof *(xhci->dcbaa)); | 2203 | memset(xhci->dcbaa, 0, sizeof *(xhci->dcbaa)); |
@@ -2232,7 +2231,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2232 | dma_pool_create("xHCI 1KB stream ctx arrays", | 2231 | dma_pool_create("xHCI 1KB stream ctx arrays", |
2233 | dev, MEDIUM_STREAM_ARRAY_SIZE, 16, 0); | 2232 | dev, MEDIUM_STREAM_ARRAY_SIZE, 16, 0); |
2234 | /* Any stream context array bigger than MEDIUM_STREAM_ARRAY_SIZE | 2233 | /* Any stream context array bigger than MEDIUM_STREAM_ARRAY_SIZE |
2235 | * will be allocated with pci_alloc_consistent() | 2234 | * will be allocated with dma_alloc_coherent() |
2236 | */ | 2235 | */ |
2237 | 2236 | ||
2238 | if (!xhci->small_streams_pool || !xhci->medium_streams_pool) | 2237 | if (!xhci->small_streams_pool || !xhci->medium_streams_pool) |
@@ -2277,8 +2276,9 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags) | |||
2277 | if (xhci_check_trb_in_td_math(xhci, flags) < 0) | 2276 | if (xhci_check_trb_in_td_math(xhci, flags) < 0) |
2278 | goto fail; | 2277 | goto fail; |
2279 | 2278 | ||
2280 | xhci->erst.entries = pci_alloc_consistent(to_pci_dev(dev), | 2279 | xhci->erst.entries = dma_alloc_coherent(dev, |
2281 | sizeof(struct xhci_erst_entry)*ERST_NUM_SEGS, &dma); | 2280 | sizeof(struct xhci_erst_entry) * ERST_NUM_SEGS, &dma, |
2281 | GFP_KERNEL); | ||
2282 | if (!xhci->erst.entries) | 2282 | if (!xhci->erst.entries) |
2283 | goto fail; | 2283 | goto fail; |
2284 | xhci_dbg(xhci, "// Allocated event ring segment table at 0x%llx\n", | 2284 | xhci_dbg(xhci, "// Allocated event ring segment table at 0x%llx\n", |