Skip to content

Commit 2efe58c

Browse files
davejiangvinodkoul
authored andcommitted
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: Jacob Pan <[email protected]> Signed-off-by: Dave Jiang <[email protected]> Link: https://lore.kernel.org/r/163517396063.3484297.7494385225280705372.stgit@djiang5-desk3.ch.intel.com Signed-off-by: Vinod Koul <[email protected]>
1 parent 1825ecc commit 2efe58c

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

drivers/dma/idxd/device.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,6 @@ int idxd_wq_alloc_resources(struct idxd_wq *wq)
135135
struct idxd_device *idxd = wq->idxd;
136136
struct device *dev = &idxd->pdev->dev;
137137
int rc, num_descs, i;
138-
int align;
139-
u64 tmp;
140138

141139
if (wq->type != IDXD_WQT_KERNEL)
142140
return 0;
@@ -148,21 +146,13 @@ int idxd_wq_alloc_resources(struct idxd_wq *wq)
148146
if (rc < 0)
149147
return rc;
150148

151-
align = idxd->data->align;
152-
wq->compls_size = num_descs * idxd->data->compl_size + align;
153-
wq->compls_raw = dma_alloc_coherent(dev, wq->compls_size,
154-
&wq->compls_addr_raw, GFP_KERNEL);
155-
if (!wq->compls_raw) {
149+
wq->compls_size = num_descs * idxd->data->compl_size;
150+
wq->compls = dma_alloc_coherent(dev, wq->compls_size, &wq->compls_addr, GFP_KERNEL);
151+
if (!wq->compls) {
156152
rc = -ENOMEM;
157153
goto fail_alloc_compls;
158154
}
159155

160-
/* Adjust alignment */
161-
wq->compls_addr = (wq->compls_addr_raw + (align - 1)) & ~(align - 1);
162-
tmp = (u64)wq->compls_raw;
163-
tmp = (tmp + (align - 1)) & ~(align - 1);
164-
wq->compls = (struct dsa_completion_record *)tmp;
165-
166156
rc = alloc_descs(wq, num_descs);
167157
if (rc < 0)
168158
goto fail_alloc_descs;
@@ -191,8 +181,7 @@ int idxd_wq_alloc_resources(struct idxd_wq *wq)
191181
fail_sbitmap_init:
192182
free_descs(wq);
193183
fail_alloc_descs:
194-
dma_free_coherent(dev, wq->compls_size, wq->compls_raw,
195-
wq->compls_addr_raw);
184+
dma_free_coherent(dev, wq->compls_size, wq->compls, wq->compls_addr);
196185
fail_alloc_compls:
197186
free_hw_descs(wq);
198187
return rc;
@@ -207,8 +196,7 @@ void idxd_wq_free_resources(struct idxd_wq *wq)
207196

208197
free_hw_descs(wq);
209198
free_descs(wq);
210-
dma_free_coherent(dev, wq->compls_size, wq->compls_raw,
211-
wq->compls_addr_raw);
199+
dma_free_coherent(dev, wq->compls_size, wq->compls, wq->compls_addr);
212200
sbitmap_queue_free(&wq->sbq);
213201
}
214202

drivers/dma/idxd/idxd.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,7 @@ struct idxd_wq {
187187
struct dsa_completion_record *compls;
188188
struct iax_completion_record *iax_compls;
189189
};
190-
void *compls_raw;
191190
dma_addr_t compls_addr;
192-
dma_addr_t compls_addr_raw;
193191
int compls_size;
194192
struct idxd_desc **descs;
195193
struct sbitmap_queue sbq;

0 commit comments

Comments
 (0)