Skip to content

Commit 68cf9d8

Browse files
hz-chengrleon
authored andcommitted
RDMA/erdma: Introduce dma pool for hardware responses of CMDQ requests
Hardware response, such as the result of query statistics, may be too long to be directly accommodated within the CQE structure. To address this, we introduce a DMA pool to hold the hardware's responses of CMDQ requests. Signed-off-by: Cheng Xu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent d42fafb commit 68cf9d8

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

drivers/infiniband/hw/erdma/erdma.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ struct erdma_dev {
212212

213213
atomic_t num_ctx;
214214
struct list_head cep_list;
215+
216+
struct dma_pool *resp_pool;
215217
};
216218

217219
static inline void *get_queue_entry(void *qbuf, u32 idx, u32 depth, u32 shift)

drivers/infiniband/hw/erdma/erdma_hw.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,8 @@ struct erdma_cmdq_reflush_req {
357357
u32 rq_pi;
358358
};
359359

360+
#define ERDMA_HW_RESP_SIZE 256
361+
360362
/* cap qword 0 definition */
361363
#define ERDMA_CMD_DEV_CAP_MAX_CQE_MASK GENMASK_ULL(47, 40)
362364
#define ERDMA_CMD_DEV_CAP_FLAGS_MASK GENMASK_ULL(31, 24)

drivers/infiniband/hw/erdma/erdma_main.c

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,30 @@ static int erdma_device_init(struct erdma_dev *dev, struct pci_dev *pdev)
172172
{
173173
int ret;
174174

175+
dev->resp_pool = dma_pool_create("erdma_resp_pool", &pdev->dev,
176+
ERDMA_HW_RESP_SIZE, ERDMA_HW_RESP_SIZE,
177+
0);
178+
if (!dev->resp_pool)
179+
return -ENOMEM;
180+
175181
ret = dma_set_mask_and_coherent(&pdev->dev,
176182
DMA_BIT_MASK(ERDMA_PCI_WIDTH));
177183
if (ret)
178-
return ret;
184+
goto destroy_pool;
179185

180186
dma_set_max_seg_size(&pdev->dev, UINT_MAX);
181187

182188
return 0;
189+
190+
destroy_pool:
191+
dma_pool_destroy(dev->resp_pool);
192+
193+
return ret;
194+
}
195+
196+
static void erdma_device_uninit(struct erdma_dev *dev)
197+
{
198+
dma_pool_destroy(dev->resp_pool);
183199
}
184200

185201
static void erdma_hw_reset(struct erdma_dev *dev)
@@ -273,7 +289,7 @@ static int erdma_probe_dev(struct pci_dev *pdev)
273289

274290
err = erdma_request_vectors(dev);
275291
if (err)
276-
goto err_iounmap_func_bar;
292+
goto err_uninit_device;
277293

278294
err = erdma_comm_irq_init(dev);
279295
if (err)
@@ -314,6 +330,9 @@ static int erdma_probe_dev(struct pci_dev *pdev)
314330
err_free_vectors:
315331
pci_free_irq_vectors(dev->pdev);
316332

333+
err_uninit_device:
334+
erdma_device_uninit(dev);
335+
317336
err_iounmap_func_bar:
318337
devm_iounmap(&pdev->dev, dev->func_bar);
319338

@@ -339,6 +358,7 @@ static void erdma_remove_dev(struct pci_dev *pdev)
339358
erdma_aeq_destroy(dev);
340359
erdma_comm_irq_uninit(dev);
341360
pci_free_irq_vectors(dev->pdev);
361+
erdma_device_uninit(dev);
342362

343363
devm_iounmap(&pdev->dev, dev->func_bar);
344364
pci_release_selected_regions(pdev, ERDMA_BAR_MASK);

0 commit comments

Comments
 (0)