[dpdk-dev] [PATCH v5 05/16] dma/idxd: create dmadev instances on pci probe

Kevin Laatz kevin.laatz at intel.com
Wed Sep 22 11:18:59 CEST 2021


On 22/09/2021 03:12, fengchengwen wrote:
> On 2021/9/17 23:24, Kevin Laatz wrote:
>> When a suitable device is found during the PCI probe, create a dmadev
>> instance for each HW queue. HW definitions required are also included.
>>
>> Signed-off-by: Bruce Richardson <bruce.richardson at intel.com>
>> Signed-off-by: Kevin Laatz <kevin.laatz at intel.com>
>> Reviewed-by: Conor Walsh <conor.walsh at intel.com>
>>
>> ---
>> v4: rebase changes
>> ---
>>   drivers/dma/idxd/idxd_hw_defs.h  |  71 ++++++++
>>   drivers/dma/idxd/idxd_internal.h |  16 ++
>>   drivers/dma/idxd/idxd_pci.c      | 278 ++++++++++++++++++++++++++++++-
>>   3 files changed, 362 insertions(+), 3 deletions(-)
>>   create mode 100644 drivers/dma/idxd/idxd_hw_defs.h
>>
[snip]
>> +
>> +static int
>> +idxd_dmadev_destroy(const char *name)
>> +{
>> +	int ret;
>> +	uint8_t err_code;
>> +	struct rte_dma_dev *dmadev;
>> +	struct idxd_dmadev *idxd;
>> +	int dev_id = rte_dma_get_dev_id(name);
>> +
>> +	if (!name) {
>> +		IDXD_PMD_ERR("Invalid device name");
>> +		return -EINVAL;
>> +	}
>> +
>> +	if (dev_id < 0) {
>> +		IDXD_PMD_ERR("Invalid device ID");
>> +		return -EINVAL;
>> +	}
>> +
>> +	dmadev = &rte_dma_devices[dev_id];
>> +	if (!dmadev) {
>> +		IDXD_PMD_ERR("Invalid device name (%s)", name);
>> +		return -EINVAL;
>> +	}
>> +
>> +	idxd = dmadev->dev_private;
>> +	if (!idxd) {
>> +		IDXD_PMD_ERR("Error getting dev_private");
>> +		return -EINVAL;
>> +	}
>> +
>> +	/* disable the device */
>> +	err_code = idxd_pci_dev_command(idxd, idxd_disable_dev);
>> +	if (err_code) {
>> +		IDXD_PMD_ERR("Error disabling device: code %#x", err_code);
>> +		return err_code;
>> +	}
>> +	IDXD_PMD_DEBUG("IDXD Device disabled OK");
> Recommended: move the above disable idxd device to rte_dma_close() ops.
> when create: mark state as READY
> when destroy: direct call rte_dma_pmd_release(name), the lib will call rte_dma_close().
>
>> +
>> +	/* free device memory */
>> +	IDXD_PMD_DEBUG("Freeing device driver memory");
>> +	dmadev->dev_private = NULL;
> The dmalib managed dev_private, so that driver could not do free again.
>
>> +	rte_free(idxd->batch_idx_ring);
>> +	rte_free(idxd->desc_ring);
> Please move above free ops to rte_dma_close() ops.
>

Will fix, thanks



More information about the dev mailing list