pds_core: Require callers of register/unregister to pass PF drvdata
authorBrett Creeley <brett.creeley@amd.com>
Mon, 7 Aug 2023 20:57:50 +0000 (13:57 -0700)
committerAlex Williamson <alex.williamson@redhat.com>
Wed, 16 Aug 2023 16:53:11 +0000 (10:53 -0600)
Pass a pointer to the PF's private data structure rather than
bouncing in and out of the PF's PCI function address.

Signed-off-by: Shannon Nelson <shannon.nelson@amd.com>
Signed-off-by: Brett Creeley <brett.creeley@amd.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20230807205755.29579-4-brett.creeley@amd.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/net/ethernet/amd/pds_core/auxbus.c
include/linux/pds/pds_common.h

index 561af8e5b3eabf78b878222b0d9c5995d0a4f6e3..63d28c0a7e0864c8b2e25e4d1df48f40944339a3 100644 (file)
  * Return: 0 on success, or
  *         negative for error
  */
-int pds_client_register(struct pci_dev *pf_pdev, char *devname)
+int pds_client_register(struct pdsc *pf, char *devname)
 {
        union pds_core_adminq_comp comp = {};
        union pds_core_adminq_cmd cmd = {};
-       struct pdsc *pf;
        int err;
        u16 ci;
 
-       pf = pci_get_drvdata(pf_pdev);
-       if (pf->state)
-               return -ENXIO;
-
        cmd.client_reg.opcode = PDS_AQ_CMD_CLIENT_REG;
        strscpy(cmd.client_reg.devname, devname,
                sizeof(cmd.client_reg.devname));
@@ -59,17 +54,12 @@ EXPORT_SYMBOL_GPL(pds_client_register);
  * Return: 0 on success, or
  *         negative for error
  */
-int pds_client_unregister(struct pci_dev *pf_pdev, u16 client_id)
+int pds_client_unregister(struct pdsc *pf, u16 client_id)
 {
        union pds_core_adminq_comp comp = {};
        union pds_core_adminq_cmd cmd = {};
-       struct pdsc *pf;
        int err;
 
-       pf = pci_get_drvdata(pf_pdev);
-       if (pf->state)
-               return -ENXIO;
-
        cmd.client_unreg.opcode = PDS_AQ_CMD_CLIENT_UNREG;
        cmd.client_unreg.client_id = cpu_to_le16(client_id);
 
@@ -198,7 +188,7 @@ int pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf)
 
        padev = pf->vfs[cf->vf_id].padev;
        if (padev) {
-               pds_client_unregister(pf->pdev, padev->client_id);
+               pds_client_unregister(pf, padev->client_id);
                auxiliary_device_delete(&padev->aux_dev);
                auxiliary_device_uninit(&padev->aux_dev);
                padev->client_id = 0;
@@ -243,7 +233,7 @@ int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf)
         */
        snprintf(devname, sizeof(devname), "%s.%s.%d",
                 PDS_CORE_DRV_NAME, pf->viftype_status[vt].name, cf->uid);
-       client_id = pds_client_register(pf->pdev, devname);
+       client_id = pds_client_register(pf, devname);
        if (client_id < 0) {
                err = client_id;
                goto out_unlock;
@@ -252,7 +242,7 @@ int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf)
        padev = pdsc_auxbus_dev_register(cf, pf, client_id,
                                         pf->viftype_status[vt].name);
        if (IS_ERR(padev)) {
-               pds_client_unregister(pf->pdev, client_id);
+               pds_client_unregister(pf, client_id);
                err = PTR_ERR(padev);
                goto out_unlock;
        }
index 435c8e8161c2f3a596c64dc869f816d4ee95ae85..04427dcc0a5979f0eadecbcee51a3094ff52497c 100644 (file)
@@ -41,9 +41,11 @@ enum pds_core_vif_types {
 
 #define PDS_VDPA_DEV_NAME      PDS_CORE_DRV_NAME "." PDS_DEV_TYPE_VDPA_STR
 
+struct pdsc;
+
 int pdsc_register_notify(struct notifier_block *nb);
 void pdsc_unregister_notify(struct notifier_block *nb);
 void *pdsc_get_pf_struct(struct pci_dev *vf_pdev);
-int pds_client_register(struct pci_dev *pf_pdev, char *devname);
-int pds_client_unregister(struct pci_dev *pf_pdev, u16 client_id);
+int pds_client_register(struct pdsc *pf, char *devname);
+int pds_client_unregister(struct pdsc *pf, u16 client_id);
 #endif /* _PDS_COMMON_H_ */