mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-16 04:04:06 +00:00
usb: xhci: using dma_alloc_noncoherent to alloc low memory pool
For RISCV_NONCACHEHERENT is set, using dma_alloc_noncoherent to alloc cached large block low memory buffer. And set default size to 4M. (largest size of continuous memory can be supported) Signed-off-by: Minda Chen <minda.chen@starfivetech.com>
This commit is contained in:
parent
baea6b2fea
commit
2904da4b8e
2 changed files with 21 additions and 17 deletions
|
@ -1889,7 +1889,8 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci)
|
|||
|
||||
if (xhci->lowmem_pool.pool) {
|
||||
pool = &xhci->lowmem_pool;
|
||||
dma_free_coherent(dev, pool->size, (void *)pool->cached_base, pool->dma_addr);
|
||||
dma_free_noncoherent(dev, pool->size, (void *)pool->cached_base,
|
||||
pool->dma_addr, DMA_BIDIRECTIONAL);
|
||||
gen_pool_destroy(pool->pool);
|
||||
pool->pool = NULL;
|
||||
}
|
||||
|
@ -2315,15 +2316,15 @@ int xhci_setup_local_lowmem(struct xhci_hcd *xhci, size_t size)
|
|||
if (!pool->pool) {
|
||||
/* minimal alloc one page */
|
||||
pool->pool = gen_pool_create(PAGE_SHIFT, dev_to_node(hcd->self.sysdev));
|
||||
if (IS_ERR(pool->pool))
|
||||
return PTR_ERR(pool->pool);
|
||||
if (!pool->pool)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
buffer = dma_alloc_coherent(hcd->self.sysdev, size, &dma_addr,
|
||||
GFP_KERNEL | GFP_DMA32);
|
||||
buffer = dma_alloc_noncoherent(hcd->self.sysdev, size, &dma_addr,
|
||||
DMA_BIDIRECTIONAL, GFP_ATOMIC);
|
||||
|
||||
if (IS_ERR(buffer)) {
|
||||
err = PTR_ERR(buffer);
|
||||
if (!buffer) {
|
||||
err = -ENOMEM;
|
||||
goto destroy_pool;
|
||||
}
|
||||
|
||||
|
@ -2333,11 +2334,11 @@ int xhci_setup_local_lowmem(struct xhci_hcd *xhci, size_t size)
|
|||
* for it.
|
||||
*/
|
||||
err = gen_pool_add_virt(pool->pool, (unsigned long)buffer,
|
||||
dma_addr, size, dev_to_node(hcd->self.sysdev));
|
||||
dma_addr, size, dev_to_node(hcd->self.sysdev));
|
||||
if (err < 0) {
|
||||
dev_err(hcd->self.sysdev, "gen_pool_add_virt failed with %d\n",
|
||||
err);
|
||||
dma_free_coherent(hcd->self.sysdev, size, buffer, dma_addr);
|
||||
dma_free_noncoherent(hcd->self.sysdev, size, buffer, dma_addr, DMA_BIDIRECTIONAL);
|
||||
goto destroy_pool;
|
||||
}
|
||||
|
||||
|
@ -2360,7 +2361,7 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
|
|||
unsigned int val, val2;
|
||||
u64 val_64;
|
||||
u32 page_size, temp;
|
||||
int i;
|
||||
int i, ret;
|
||||
|
||||
INIT_LIST_HEAD(&xhci->cmd_list);
|
||||
|
||||
|
@ -2490,9 +2491,11 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)
|
|||
xhci->isoc_bei_interval = AVOID_BEI_INTERVAL_MAX;
|
||||
|
||||
if (xhci->quirks & XHCI_LOCAL_BUFFER) {
|
||||
if (xhci_setup_local_lowmem(xhci,
|
||||
xhci->lowmem_pool.size))
|
||||
goto fail;
|
||||
ret = xhci_setup_local_lowmem(xhci, xhci->lowmem_pool.size);
|
||||
if (ret) {
|
||||
xhci->quirks &= ~XHCI_LOCAL_BUFFER;
|
||||
xhci_warn(xhci, "WARN: Can't alloc lowmem pool\n");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -255,10 +255,11 @@ int xhci_plat_probe(struct platform_device *pdev, struct device *sysdev, const s
|
|||
|
||||
if (device_property_read_bool(tmpdev, "xhci-lowmem-pool")) {
|
||||
xhci->quirks |= XHCI_LOCAL_BUFFER;
|
||||
if (device_property_read_u32(tmpdev, "lowmem-pool-size",
|
||||
&xhci->lowmem_pool.size)) {
|
||||
xhci->lowmem_pool.size = 8 << 20;
|
||||
} else
|
||||
ret = device_property_read_u32(tmpdev, "lowmem-pool-size",
|
||||
&xhci->lowmem_pool.size);
|
||||
if (ret || xhci->lowmem_pool.size >= 4)
|
||||
xhci->lowmem_pool.size = 4 << 20;
|
||||
else
|
||||
xhci->lowmem_pool.size <<= 20;
|
||||
}
|
||||
device_property_read_u32(tmpdev, "imod-interval-ns",
|
||||
|
|
Loading…
Add table
Reference in a new issue