Skip to content

Commit b021d05

Browse files
brettcreeleyawilliam
authored andcommitted
pds_core: Require callers of register/unregister to pass PF drvdata
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 <[email protected]> Signed-off-by: Brett Creeley <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Reviewed-by: Shameer Kolothum <[email protected]> Reviewed-by: Jason Gunthorpe <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent 38fe397 commit b021d05

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

drivers/net/ethernet/amd/pds_core/auxbus.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,13 @@
1414
* Return: 0 on success, or
1515
* negative for error
1616
*/
17-
int pds_client_register(struct pci_dev *pf_pdev, char *devname)
17+
int pds_client_register(struct pdsc *pf, char *devname)
1818
{
1919
union pds_core_adminq_comp comp = {};
2020
union pds_core_adminq_cmd cmd = {};
21-
struct pdsc *pf;
2221
int err;
2322
u16 ci;
2423

25-
pf = pci_get_drvdata(pf_pdev);
26-
if (pf->state)
27-
return -ENXIO;
28-
2924
cmd.client_reg.opcode = PDS_AQ_CMD_CLIENT_REG;
3025
strscpy(cmd.client_reg.devname, devname,
3126
sizeof(cmd.client_reg.devname));
@@ -59,17 +54,12 @@ EXPORT_SYMBOL_GPL(pds_client_register);
5954
* Return: 0 on success, or
6055
* negative for error
6156
*/
62-
int pds_client_unregister(struct pci_dev *pf_pdev, u16 client_id)
57+
int pds_client_unregister(struct pdsc *pf, u16 client_id)
6358
{
6459
union pds_core_adminq_comp comp = {};
6560
union pds_core_adminq_cmd cmd = {};
66-
struct pdsc *pf;
6761
int err;
6862

69-
pf = pci_get_drvdata(pf_pdev);
70-
if (pf->state)
71-
return -ENXIO;
72-
7363
cmd.client_unreg.opcode = PDS_AQ_CMD_CLIENT_UNREG;
7464
cmd.client_unreg.client_id = cpu_to_le16(client_id);
7565

@@ -198,7 +188,7 @@ int pdsc_auxbus_dev_del(struct pdsc *cf, struct pdsc *pf)
198188

199189
padev = pf->vfs[cf->vf_id].padev;
200190
if (padev) {
201-
pds_client_unregister(pf->pdev, padev->client_id);
191+
pds_client_unregister(pf, padev->client_id);
202192
auxiliary_device_delete(&padev->aux_dev);
203193
auxiliary_device_uninit(&padev->aux_dev);
204194
padev->client_id = 0;
@@ -243,7 +233,7 @@ int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf)
243233
*/
244234
snprintf(devname, sizeof(devname), "%s.%s.%d",
245235
PDS_CORE_DRV_NAME, pf->viftype_status[vt].name, cf->uid);
246-
client_id = pds_client_register(pf->pdev, devname);
236+
client_id = pds_client_register(pf, devname);
247237
if (client_id < 0) {
248238
err = client_id;
249239
goto out_unlock;
@@ -252,7 +242,7 @@ int pdsc_auxbus_dev_add(struct pdsc *cf, struct pdsc *pf)
252242
padev = pdsc_auxbus_dev_register(cf, pf, client_id,
253243
pf->viftype_status[vt].name);
254244
if (IS_ERR(padev)) {
255-
pds_client_unregister(pf->pdev, client_id);
245+
pds_client_unregister(pf, client_id);
256246
err = PTR_ERR(padev);
257247
goto out_unlock;
258248
}

include/linux/pds/pds_common.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,11 @@ enum pds_core_vif_types {
4141

4242
#define PDS_VDPA_DEV_NAME PDS_CORE_DRV_NAME "." PDS_DEV_TYPE_VDPA_STR
4343

44+
struct pdsc;
45+
4446
int pdsc_register_notify(struct notifier_block *nb);
4547
void pdsc_unregister_notify(struct notifier_block *nb);
4648
void *pdsc_get_pf_struct(struct pci_dev *vf_pdev);
47-
int pds_client_register(struct pci_dev *pf_pdev, char *devname);
48-
int pds_client_unregister(struct pci_dev *pf_pdev, u16 client_id);
49+
int pds_client_register(struct pdsc *pf, char *devname);
50+
int pds_client_unregister(struct pdsc *pf, u16 client_id);
4951
#endif /* _PDS_COMMON_H_ */

0 commit comments

Comments
 (0)