Skip to content

Commit f903050

Browse files
committed
dmaengine: sdxi: completion: Use dma pool for sdxi_cst_blk
This has been a TODO for a while. Replace the wasteful dma_alloc_coherent() for every 32-byte completion status block with allocation from a pool. Signed-off-by: Nathan Lynch <nathan.lynch@amd.com>
1 parent cd39c72 commit f903050

3 files changed

Lines changed: 8 additions & 6 deletions

File tree

drivers/dma/sdxi/completion.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <linux/cleanup.h>
2-
#include <linux/slab.h>
32
#include <linux/dma-mapping.h>
3+
#include <linux/dmapool.h>
4+
#include <linux/slab.h>
45

56
#include "completion.h"
67
#include "descriptor.h"
@@ -24,9 +25,7 @@ struct sdxi_completion *sdxi_completion_alloc(struct sdxi_dev *sdxi)
2425
if (!sc)
2526
return NULL;
2627

27-
/* Should use a dma_pool. */
28-
cst_blk = dma_alloc_coherent(sdxi_to_dev(sdxi), sizeof(*cst_blk),
29-
&cst_blk_dma, GFP_NOWAIT);
28+
cst_blk = dma_pool_zalloc(sdxi->cst_blk_pool, GFP_NOWAIT, &cst_blk_dma);
3029
if (!cst_blk)
3130
return NULL;
3231

@@ -43,8 +42,7 @@ struct sdxi_completion *sdxi_completion_alloc(struct sdxi_dev *sdxi)
4342

4443
void sdxi_completion_free(struct sdxi_completion *sc)
4544
{
46-
dma_free_coherent(sdxi_to_dev(sc->sdxi), sizeof(*sc->cst_blk),
47-
sc->cst_blk, sc->cst_blk_dma);
45+
dma_pool_free(sc->sdxi->cst_blk_pool, sc->cst_blk, sc->cst_blk_dma);
4846
kfree(sc);
4947
}
5048

drivers/dma/sdxi/device.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,9 @@ static int sdxi_device_init(struct sdxi_dev *sdxi)
306306
if (sdxi_create_dma_pool(sdxi, &sdxi->cxt_ctl_pool,
307307
"CXT_CTL", sizeof(struct sdxi_cxt_ctl)))
308308
return -ENOMEM;
309+
if (sdxi_create_dma_pool(sdxi, &sdxi->cst_blk_pool,
310+
"CST_BLK", sizeof(struct sdxi_cst_blk)))
311+
return -ENOMEM;
309312

310313
err = sdxi_fn_activate(sdxi);
311314
if (err)

drivers/dma/sdxi/sdxi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ struct sdxi_dev {
124124
struct dma_pool *write_index_pool;
125125
struct dma_pool *cxt_sts_pool;
126126
struct dma_pool *cxt_ctl_pool;
127+
struct dma_pool *cst_blk_pool;
127128

128129
unsigned int nr_vectors;
129130
struct ida vectors;

0 commit comments

Comments
 (0)