diff mbox series

[for-next,1/2] RDMA/erdma: Introduce dma pool for hardware responses of CMDQ requests

Message ID 20231220085424.97407-2-chengyou@linux.alibaba.com (mailing list archive)
State Superseded
Headers show
Series RDMA/erdma: Introduce hardware statistics support | expand

Commit Message

Cheng Xu Dec. 20, 2023, 8:54 a.m. UTC
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 <chengyou@linux.alibaba.com>
---
 drivers/infiniband/hw/erdma/erdma.h      |  2 ++
 drivers/infiniband/hw/erdma/erdma_main.c | 38 ++++++++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)

Comments

Leon Romanovsky Dec. 20, 2023, 10:12 a.m. UTC | #1
On Wed, Dec 20, 2023 at 04:54:23PM +0800, Cheng Xu wrote:
> 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 <chengyou@linux.alibaba.com>
> ---
>  drivers/infiniband/hw/erdma/erdma.h      |  2 ++
>  drivers/infiniband/hw/erdma/erdma_main.c | 38 ++++++++++++++++++++++--
>  2 files changed, 38 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/erdma/erdma.h b/drivers/infiniband/hw/erdma/erdma.h
> index f190111840e9..5df401a30cb9 100644
> --- a/drivers/infiniband/hw/erdma/erdma.h
> +++ b/drivers/infiniband/hw/erdma/erdma.h
> @@ -212,6 +212,8 @@ struct erdma_dev {
>  
>  	atomic_t num_ctx;
>  	struct list_head cep_list;
> +
> +	struct dma_pool *resp_pool;
>  };
>  
>  static inline void *get_queue_entry(void *qbuf, u32 idx, u32 depth, u32 shift)
> diff --git a/drivers/infiniband/hw/erdma/erdma_main.c b/drivers/infiniband/hw/erdma/erdma_main.c
> index 0880c79a978c..541e77aea494 100644
> --- a/drivers/infiniband/hw/erdma/erdma_main.c
> +++ b/drivers/infiniband/hw/erdma/erdma_main.c
> @@ -168,18 +168,48 @@ static void erdma_comm_irq_uninit(struct erdma_dev *dev)
>  	free_irq(dev->comm_irq.msix_vector, dev);
>  }
>  
> +static int erdma_dma_pools_init(struct erdma_dev *dev)
> +{
> +	dev->resp_pool = dma_pool_create("erdma_resp_pool", &dev->pdev->dev,
> +					 ERDMA_HW_RESP_SIZE, ERDMA_HW_RESP_SIZE,
> +					 0);
> +	if (!dev->resp_pool)
> +		return -ENOMEM;
> +
> +	return 0;
> +}
> +
> +static void erdma_dma_pools_destroy(struct erdma_dev *dev)
> +{
> +	dma_pool_destroy(dev->resp_pool);
> +}

Please don't add extra layer of functions which will be called in same
file anyway. Call directly to dma_pool_destroy(), same goes for dma_pool_create().

Thanks
Cheng Xu Dec. 23, 2023, 7:14 a.m. UTC | #2
On 12/20/23 6:12 PM, Leon Romanovsky wrote:
> On Wed, Dec 20, 2023 at 04:54:23PM +0800, Cheng Xu wrote:
>> 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 <chengyou@linux.alibaba.com>
>> ---
>>  drivers/infiniband/hw/erdma/erdma.h      |  2 ++
>>  drivers/infiniband/hw/erdma/erdma_main.c | 38 ++++++++++++++++++++++--
>>  2 files changed, 38 insertions(+), 2 deletions(-)
>>

<...>

>> +static int erdma_dma_pools_init(struct erdma_dev *dev)
>> +{
>> +	dev->resp_pool = dma_pool_create("erdma_resp_pool", &dev->pdev->dev,
>> +					 ERDMA_HW_RESP_SIZE, ERDMA_HW_RESP_SIZE,
>> +					 0);
>> +	if (!dev->resp_pool)
>> +		return -ENOMEM;
>> +
>> +	return 0;
>> +}
>> +
>> +static void erdma_dma_pools_destroy(struct erdma_dev *dev)
>> +{
>> +	dma_pool_destroy(dev->resp_pool);
>> +}
> 
> Please don't add extra layer of functions which will be called in same
> file anyway. Call directly to dma_pool_destroy(), same goes for dma_pool_create().

Get it.

Will fix in v2.

Thanks,
Cheng Xu

 
> Thanks
diff mbox series

Patch

diff --git a/drivers/infiniband/hw/erdma/erdma.h b/drivers/infiniband/hw/erdma/erdma.h
index f190111840e9..5df401a30cb9 100644
--- a/drivers/infiniband/hw/erdma/erdma.h
+++ b/drivers/infiniband/hw/erdma/erdma.h
@@ -212,6 +212,8 @@  struct erdma_dev {
 
 	atomic_t num_ctx;
 	struct list_head cep_list;
+
+	struct dma_pool *resp_pool;
 };
 
 static inline void *get_queue_entry(void *qbuf, u32 idx, u32 depth, u32 shift)
diff --git a/drivers/infiniband/hw/erdma/erdma_main.c b/drivers/infiniband/hw/erdma/erdma_main.c
index 0880c79a978c..541e77aea494 100644
--- a/drivers/infiniband/hw/erdma/erdma_main.c
+++ b/drivers/infiniband/hw/erdma/erdma_main.c
@@ -168,18 +168,48 @@  static void erdma_comm_irq_uninit(struct erdma_dev *dev)
 	free_irq(dev->comm_irq.msix_vector, dev);
 }
 
+static int erdma_dma_pools_init(struct erdma_dev *dev)
+{
+	dev->resp_pool = dma_pool_create("erdma_resp_pool", &dev->pdev->dev,
+					 ERDMA_HW_RESP_SIZE, ERDMA_HW_RESP_SIZE,
+					 0);
+	if (!dev->resp_pool)
+		return -ENOMEM;
+
+	return 0;
+}
+
+static void erdma_dma_pools_destroy(struct erdma_dev *dev)
+{
+	dma_pool_destroy(dev->resp_pool);
+}
+
 static int erdma_device_init(struct erdma_dev *dev, struct pci_dev *pdev)
 {
 	int ret;
 
+	ret = erdma_dma_pools_init(dev);
+	if (ret)
+		return ret;
+
 	ret = dma_set_mask_and_coherent(&pdev->dev,
 					DMA_BIT_MASK(ERDMA_PCI_WIDTH));
 	if (ret)
-		return ret;
+		goto destroy_pool;
 
 	dma_set_max_seg_size(&pdev->dev, UINT_MAX);
 
 	return 0;
+
+destroy_pool:
+	erdma_dma_pools_destroy(dev);
+
+	return ret;
+}
+
+static void erdma_device_uninit(struct erdma_dev *dev)
+{
+	erdma_dma_pools_destroy(dev);
 }
 
 static void erdma_hw_reset(struct erdma_dev *dev)
@@ -273,7 +303,7 @@  static int erdma_probe_dev(struct pci_dev *pdev)
 
 	err = erdma_request_vectors(dev);
 	if (err)
-		goto err_iounmap_func_bar;
+		goto err_uninit_device;
 
 	err = erdma_comm_irq_init(dev);
 	if (err)
@@ -314,6 +344,9 @@  static int erdma_probe_dev(struct pci_dev *pdev)
 err_free_vectors:
 	pci_free_irq_vectors(dev->pdev);
 
+err_uninit_device:
+	erdma_device_uninit(dev);
+
 err_iounmap_func_bar:
 	devm_iounmap(&pdev->dev, dev->func_bar);
 
@@ -339,6 +372,7 @@  static void erdma_remove_dev(struct pci_dev *pdev)
 	erdma_aeq_destroy(dev);
 	erdma_comm_irq_uninit(dev);
 	pci_free_irq_vectors(dev->pdev);
+	erdma_device_uninit(dev);
 
 	devm_iounmap(&pdev->dev, dev->func_bar);
 	pci_release_selected_regions(pdev, ERDMA_BAR_MASK);