Commit 2efe58cf authored by Dave Jiang's avatar Dave Jiang Committed by Vinod Koul

dmaengine: idxd: cleanup completion record allocation

According to core-api/dma-api-howto.rst, the address from
dma_alloc_coherent is gauranteed to align to the smallest PAGE_SIZE order.
That supercedes the 64B/32B alignment requirement of the completion record.
Remove alignment adjustment code.
Tested-by: default avatarJacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: default avatarDave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/163517396063.3484297.7494385225280705372.stgit@djiang5-desk3.ch.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 1825ecc9
...@@ -135,8 +135,6 @@ int idxd_wq_alloc_resources(struct idxd_wq *wq) ...@@ -135,8 +135,6 @@ int idxd_wq_alloc_resources(struct idxd_wq *wq)
struct idxd_device *idxd = wq->idxd; struct idxd_device *idxd = wq->idxd;
struct device *dev = &idxd->pdev->dev; struct device *dev = &idxd->pdev->dev;
int rc, num_descs, i; int rc, num_descs, i;
int align;
u64 tmp;
if (wq->type != IDXD_WQT_KERNEL) if (wq->type != IDXD_WQT_KERNEL)
return 0; return 0;
...@@ -148,21 +146,13 @@ int idxd_wq_alloc_resources(struct idxd_wq *wq) ...@@ -148,21 +146,13 @@ int idxd_wq_alloc_resources(struct idxd_wq *wq)
if (rc < 0) if (rc < 0)
return rc; return rc;
align = idxd->data->align; wq->compls_size = num_descs * idxd->data->compl_size;
wq->compls_size = num_descs * idxd->data->compl_size + align; wq->compls = dma_alloc_coherent(dev, wq->compls_size, &wq->compls_addr, GFP_KERNEL);
wq->compls_raw = dma_alloc_coherent(dev, wq->compls_size, if (!wq->compls) {
&wq->compls_addr_raw, GFP_KERNEL);
if (!wq->compls_raw) {
rc = -ENOMEM; rc = -ENOMEM;
goto fail_alloc_compls; goto fail_alloc_compls;
} }
/* Adjust alignment */
wq->compls_addr = (wq->compls_addr_raw + (align - 1)) & ~(align - 1);
tmp = (u64)wq->compls_raw;
tmp = (tmp + (align - 1)) & ~(align - 1);
wq->compls = (struct dsa_completion_record *)tmp;
rc = alloc_descs(wq, num_descs); rc = alloc_descs(wq, num_descs);
if (rc < 0) if (rc < 0)
goto fail_alloc_descs; goto fail_alloc_descs;
...@@ -191,8 +181,7 @@ int idxd_wq_alloc_resources(struct idxd_wq *wq) ...@@ -191,8 +181,7 @@ int idxd_wq_alloc_resources(struct idxd_wq *wq)
fail_sbitmap_init: fail_sbitmap_init:
free_descs(wq); free_descs(wq);
fail_alloc_descs: fail_alloc_descs:
dma_free_coherent(dev, wq->compls_size, wq->compls_raw, dma_free_coherent(dev, wq->compls_size, wq->compls, wq->compls_addr);
wq->compls_addr_raw);
fail_alloc_compls: fail_alloc_compls:
free_hw_descs(wq); free_hw_descs(wq);
return rc; return rc;
...@@ -207,8 +196,7 @@ void idxd_wq_free_resources(struct idxd_wq *wq) ...@@ -207,8 +196,7 @@ void idxd_wq_free_resources(struct idxd_wq *wq)
free_hw_descs(wq); free_hw_descs(wq);
free_descs(wq); free_descs(wq);
dma_free_coherent(dev, wq->compls_size, wq->compls_raw, dma_free_coherent(dev, wq->compls_size, wq->compls, wq->compls_addr);
wq->compls_addr_raw);
sbitmap_queue_free(&wq->sbq); sbitmap_queue_free(&wq->sbq);
} }
......
...@@ -187,9 +187,7 @@ struct idxd_wq { ...@@ -187,9 +187,7 @@ struct idxd_wq {
struct dsa_completion_record *compls; struct dsa_completion_record *compls;
struct iax_completion_record *iax_compls; struct iax_completion_record *iax_compls;
}; };
void *compls_raw;
dma_addr_t compls_addr; dma_addr_t compls_addr;
dma_addr_t compls_addr_raw;
int compls_size; int compls_size;
struct idxd_desc **descs; struct idxd_desc **descs;
struct sbitmap_queue sbq; struct sbitmap_queue sbq;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment