[v1] crypto/ccp: bug fixes for ccp device probe flow

Message ID 20221124135645.5955-1-sunilprakashrao.uttarwar@amd.com (mailing list archive)
State Changes Requested, archived
Delegated to: akhil goyal
Headers
Series [v1] crypto/ccp: bug fixes for ccp device probe flow |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS

Commit Message

Sunil Uttarwar Nov. 24, 2022, 1:56 p.m. UTC
  - Fixed flow for probe and initialization of requested ccp devices
- Removed unnecessary code enumerating for all the PCI devices
  available in the system.
- Removed ccp_pmd_init_done flag controlling probe and initialization
  of only one CCP device even if other CCP devices available

Signed-off-by: Sunil Uttarwar <sunilprakashrao.uttarwar@amd.com>
---
 drivers/crypto/ccp/ccp_dev.c     | 28 ++++++++++------------------
 drivers/crypto/ccp/rte_ccp_pmd.c |  7 -------
 2 files changed, 10 insertions(+), 25 deletions(-)
  

Comments

Akhil Goyal Feb. 27, 2023, 6:29 p.m. UTC | #1
> - Fixed flow for probe and initialization of requested ccp devices
> - Removed unnecessary code enumerating for all the PCI devices
>   available in the system.
> - Removed ccp_pmd_init_done flag controlling probe and initialization
>   of only one CCP device even if other CCP devices available
> 
> Signed-off-by: Sunil Uttarwar <sunilprakashrao.uttarwar@amd.com>
Hi Sunil,

Kindly work with David for the patch that was not merged and rebase this patch as needed.

Marking this patch as changes requested.

Regards,
Akhil
  
David Marchand March 2, 2023, 11:53 a.m. UTC | #2
On Mon, Feb 27, 2023 at 7:29 PM Akhil Goyal <gakhil@marvell.com> wrote:
>
> > - Fixed flow for probe and initialization of requested ccp devices
> > - Removed unnecessary code enumerating for all the PCI devices
> >   available in the system.
> > - Removed ccp_pmd_init_done flag controlling probe and initialization
> >   of only one CCP device even if other CCP devices available
> >
> > Signed-off-by: Sunil Uttarwar <sunilprakashrao.uttarwar@amd.com>
> Hi Sunil,
>
> Kindly work with David for the patch that was not merged and rebase this patch as needed.
>
> Marking this patch as changes requested.

Sorry, I kept on postponing work on this patch of mine... thanks for
keeping on pinging me Akhil :-).
I sent a v3 which should address Sunil comment.
  

Patch

diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c
index 424ead82c3..9e3c2d6a63 100644
--- a/drivers/crypto/ccp/ccp_dev.c
+++ b/drivers/crypto/ccp/ccp_dev.c
@@ -683,13 +683,11 @@  ccp_probe_devices(struct rte_pci_device *pci_dev,
 {
 	int dev_cnt = 0;
 	int ccp_type = 0;
-	struct dirent *d;
 	DIR *dir;
 	int ret = 0;
 	int module_idx = 0;
-	uint16_t domain;
-	uint8_t bus, devid, function;
 	char dirname[PATH_MAX];
+	char name[RTE_CRYPTODEV_NAME_MAX_LEN];
 
 	module_idx = ccp_check_pci_uio_module();
 	if (module_idx < 0)
@@ -700,21 +698,15 @@  ccp_probe_devices(struct rte_pci_device *pci_dev,
 	dir = opendir(SYSFS_PCI_DEVICES);
 	if (dir == NULL)
 		return -1;
-	while ((d = readdir(dir)) != NULL) {
-		if (d->d_name[0] == '.')
-			continue;
-		if (ccp_parse_pci_addr_format(d->d_name, sizeof(d->d_name),
-					&domain, &bus, &devid, &function) != 0)
-			continue;
-		snprintf(dirname, sizeof(dirname), "%s/%s",
-			     SYSFS_PCI_DEVICES, d->d_name);
-		if (is_ccp_device(dirname, ccp_id, &ccp_type)) {
-			printf("CCP : Detected CCP device with ID = 0x%x\n",
-			       ccp_id[ccp_type].device_id);
-			ret = ccp_probe_device(ccp_type, pci_dev);
-			if (ret == 0)
-				dev_cnt++;
-		}
+	rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
+	snprintf(dirname, sizeof(dirname), "%s/%s",
+		     SYSFS_PCI_DEVICES, name);
+	if (is_ccp_device(dirname, ccp_id, &ccp_type)) {
+		printf("CCP : Detected CCP device with ID = 0x%x\n",
+		       ccp_id[ccp_type].device_id);
+		ret = ccp_probe_device(ccp_type, pci_dev);
+		if (ret == 0)
+			dev_cnt++;
 	}
 	closedir(dir);
 	return dev_cnt;
diff --git a/drivers/crypto/ccp/rte_ccp_pmd.c b/drivers/crypto/ccp/rte_ccp_pmd.c
index 221a0a5235..ea77d79efc 100644
--- a/drivers/crypto/ccp/rte_ccp_pmd.c
+++ b/drivers/crypto/ccp/rte_ccp_pmd.c
@@ -19,7 +19,6 @@ 
 /**
  * Global static parameter used to find if CCP device is already initialized.
  */
-static unsigned int ccp_pmd_init_done;
 uint8_t ccp_cryptodev_driver_id;
 uint8_t cryptodev_cnt;
 extern void *sha_ctx;
@@ -199,7 +198,6 @@  cryptodev_ccp_remove(struct rte_pci_device *pci_dev)
 	if (dev == NULL)
 		return -ENODEV;
 
-	ccp_pmd_init_done = 0;
 	rte_free(sha_ctx);
 
 	RTE_LOG(INFO, PMD, "Closing ccp device %s on numa socket %u\n",
@@ -288,10 +286,6 @@  cryptodev_ccp_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	};
 
 	sha_ctx = (void *)rte_malloc(NULL, SHA512_DIGEST_SIZE, 64);
-	if (ccp_pmd_init_done) {
-		RTE_LOG(INFO, PMD, "CCP PMD already initialized\n");
-		return -EFAULT;
-	}
 	rte_pci_device_name(&pci_dev->addr, name, sizeof(name));
 	if (name[0] == '\0')
 		return -EINVAL;
@@ -310,7 +304,6 @@  cryptodev_ccp_probe(struct rte_pci_driver *pci_drv __rte_unused,
 	rc = cryptodev_ccp_create(name, pci_dev, &init_params, pci_drv);
 	if (rc)
 		return rc;
-	ccp_pmd_init_done = 1;
 	return 0;
 }