Skip to content

Commit 081c715

Browse files
Mani-Sadhasivambjorn-helgaas
authored andcommitted
PCI: endpoint: Pass EPF device ID to the probe function
Currently, the EPF probe function doesn't get the device ID argument needed to correctly identify the device table ID of the EPF device. When multiple entries are added to the "struct pci_epf_device_id" table, the probe function needs to identify the correct one. This is achieved by modifying the pci_epf_match_id() function to return the match ID pointer and passing it to the driver's probe function. pci_epf_device_match() function can return bool based on the return value of pci_epf_match_id(). Link: https://lore.kernel.org/r/20230602114756.36586-3-manivannan.sadhasivam@linaro.org Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Kishon Vijay Abraham I <kishon@kernel.org> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
1 parent ff2f19d commit 081c715

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

drivers/pci/endpoint/functions/pci-epf-ntb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2075,11 +2075,13 @@ static struct config_group *epf_ntb_add_cfs(struct pci_epf *epf,
20752075
/**
20762076
* epf_ntb_probe() - Probe NTB function driver
20772077
* @epf: NTB endpoint function device
2078+
* @id: NTB endpoint function device ID
20782079
*
20792080
* Probe NTB function driver when endpoint function bus detects a NTB
20802081
* endpoint function.
20812082
*/
2082-
static int epf_ntb_probe(struct pci_epf *epf)
2083+
static int epf_ntb_probe(struct pci_epf *epf,
2084+
const struct pci_epf_device_id *id)
20832085
{
20842086
struct epf_ntb *ntb;
20852087
struct device *dev;

drivers/pci/endpoint/functions/pci-epf-test.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,8 @@ static const struct pci_epf_device_id pci_epf_test_ids[] = {
952952
{},
953953
};
954954

955-
static int pci_epf_test_probe(struct pci_epf *epf)
955+
static int pci_epf_test_probe(struct pci_epf *epf,
956+
const struct pci_epf_device_id *id)
956957
{
957958
struct pci_epf_test *epf_test;
958959
struct device *dev = &epf->dev;

drivers/pci/endpoint/functions/pci-epf-vntb.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1395,13 +1395,15 @@ static struct pci_epf_ops epf_ntb_ops = {
13951395
/**
13961396
* epf_ntb_probe() - Probe NTB function driver
13971397
* @epf: NTB endpoint function device
1398+
* @id: NTB endpoint function device ID
13981399
*
13991400
* Probe NTB function driver when endpoint function bus detects a NTB
14001401
* endpoint function.
14011402
*
14021403
* Returns: Zero for success, or an error code in case of failure
14031404
*/
1404-
static int epf_ntb_probe(struct pci_epf *epf)
1405+
static int epf_ntb_probe(struct pci_epf *epf,
1406+
const struct pci_epf_device_id *id)
14051407
{
14061408
struct epf_ntb *ntb;
14071409
struct device *dev;

drivers/pci/endpoint/pci-epf-core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -461,16 +461,16 @@ static const struct device_type pci_epf_type = {
461461
.release = pci_epf_dev_release,
462462
};
463463

464-
static int
464+
static const struct pci_epf_device_id *
465465
pci_epf_match_id(const struct pci_epf_device_id *id, const struct pci_epf *epf)
466466
{
467467
while (id->name[0]) {
468468
if (strcmp(epf->name, id->name) == 0)
469-
return true;
469+
return id;
470470
id++;
471471
}
472472

473-
return false;
473+
return NULL;
474474
}
475475

476476
static int pci_epf_device_match(struct device *dev, struct device_driver *drv)
@@ -479,7 +479,7 @@ static int pci_epf_device_match(struct device *dev, struct device_driver *drv)
479479
struct pci_epf_driver *driver = to_pci_epf_driver(drv);
480480

481481
if (driver->id_table)
482-
return pci_epf_match_id(driver->id_table, epf);
482+
return !!pci_epf_match_id(driver->id_table, epf);
483483

484484
return !strcmp(epf->name, drv->name);
485485
}
@@ -494,7 +494,7 @@ static int pci_epf_device_probe(struct device *dev)
494494

495495
epf->driver = driver;
496496

497-
return driver->probe(epf);
497+
return driver->probe(epf, pci_epf_match_id(driver->id_table, epf));
498498
}
499499

500500
static void pci_epf_device_remove(struct device *dev)

include/linux/pci-epf.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ struct pci_epc_event_ops {
8989
* @id_table: identifies EPF devices for probing
9090
*/
9191
struct pci_epf_driver {
92-
int (*probe)(struct pci_epf *epf);
92+
int (*probe)(struct pci_epf *epf,
93+
const struct pci_epf_device_id *id);
9394
void (*remove)(struct pci_epf *epf);
9495

9596
struct device_driver driver;
@@ -131,6 +132,7 @@ struct pci_epf_bar {
131132
* @epc: the EPC device to which this EPF device is bound
132133
* @epf_pf: the physical EPF device to which this virtual EPF device is bound
133134
* @driver: the EPF driver to which this EPF device is bound
135+
* @id: Pointer to the EPF device ID
134136
* @list: to add pci_epf as a list of PCI endpoint functions to pci_epc
135137
* @lock: mutex to protect pci_epf_ops
136138
* @sec_epc: the secondary EPC device to which this EPF device is bound
@@ -158,6 +160,7 @@ struct pci_epf {
158160
struct pci_epc *epc;
159161
struct pci_epf *epf_pf;
160162
struct pci_epf_driver *driver;
163+
const struct pci_epf_device_id *id;
161164
struct list_head list;
162165
/* mutex to protect against concurrent access of pci_epf_ops */
163166
struct mutex lock;

0 commit comments

Comments
 (0)