Message ID | 20230602114756.36586-3-manivannan.sadhasivam@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | Add support for MHI Endpoint function driver | expand |
On Fri, Jun 02, 2023 at 09:13:25PM +0900, Damien Le Moal wrote: > On 6/2/23 20:47, Manivannan Sadhasivam wrote: > > 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(). > > > > Reviewed-by: Kishon Vijay Abraham I <kishon@kernel.org> > > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> > > [...] > > > static int pci_epf_device_match(struct device *dev, struct device_driver *drv) > > @@ -510,8 +510,12 @@ static int pci_epf_device_match(struct device *dev, struct device_driver *drv) > > struct pci_epf *epf = to_pci_epf(dev); > > struct pci_epf_driver *driver = to_pci_epf_driver(drv); > > > > - if (driver->id_table) > > - return pci_epf_match_id(driver->id_table, epf); > > + if (driver->id_table) { > > + if (pci_epf_match_id(driver->id_table, epf)) > > + return true; > > + else > > + return false; > > You prefer keeping this pattern ? > > return pci_epf_match_id(driver->id_table, epf) != NULL; > > is no much nicer ! s/no/so Yes it is, I can change it myself to spare Mani few cycles. Lorenzo > > Anyway: > > Reviewed-by: Damien Le Moal <dlemoal@kernel.org> > > -- > Damien Le Moal > Western Digital Research >
On Mon, Jun 05, 2023 at 03:08:33PM +0200, Lorenzo Pieralisi wrote: > On Fri, Jun 02, 2023 at 09:13:25PM +0900, Damien Le Moal wrote: > > On 6/2/23 20:47, Manivannan Sadhasivam wrote: > > > 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(). > > > > > > Reviewed-by: Kishon Vijay Abraham I <kishon@kernel.org> > > > Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> > > > > [...] > > > > > static int pci_epf_device_match(struct device *dev, struct device_driver *drv) > > > @@ -510,8 +510,12 @@ static int pci_epf_device_match(struct device *dev, struct device_driver *drv) > > > struct pci_epf *epf = to_pci_epf(dev); > > > struct pci_epf_driver *driver = to_pci_epf_driver(drv); > > > > > > - if (driver->id_table) > > > - return pci_epf_match_id(driver->id_table, epf); > > > + if (driver->id_table) { > > > + if (pci_epf_match_id(driver->id_table, epf)) > > > + return true; > > > + else > > > + return false; > > > > You prefer keeping this pattern ? > > > > return pci_epf_match_id(driver->id_table, epf) != NULL; > > > > is no much nicer ! > > s/no/so > > Yes it is, I can change it myself to spare Mani few cycles. > Please do! - Mani > Lorenzo > > > > > Anyway: > > > > Reviewed-by: Damien Le Moal <dlemoal@kernel.org> > > > > -- > > Damien Le Moal > > Western Digital Research > >
On Fri, Jun 02, 2023 at 05:17:49PM +0530, Manivannan Sadhasivam wrote: > Currently, the EPF probe function doesn't get the device ID argument needed > to correctly identify the device table ID of the EPF device. > ... > +++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c > @@ -2075,11 +2075,12 @@ static struct config_group *epf_ntb_add_cfs(struct pci_epf *epf, > /** > * epf_ntb_probe() - Probe NTB function driver > * @epf: NTB endpoint function device > + * @id: NTB endpoint function device ID > * > * Probe NTB function driver when endpoint function bus detects a NTB > * endpoint function. > */ > -static int epf_ntb_probe(struct pci_epf *epf) > +static int epf_ntb_probe(struct pci_epf *epf, const struct pci_epf_device_id *id) > ... > +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c > @@ -1401,7 +1401,7 @@ static struct pci_epf_ops epf_ntb_ops = { > * > * Returns: Zero for success, or an error code in case of failure > */ > -static int epf_ntb_probe(struct pci_epf *epf) > +static int epf_ntb_probe(struct pci_epf *epf, const struct pci_epf_device_id *id) I updated the pci/endpoint branch to add kernel-doc for the new "id", same as you did in pci-epf-ntb.c. Just FYI, Lorenzo & Krzysztof -- hopefully there are no more updates before the merge window, but if you do add anything to this branch, update it first. Bjorn
diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c b/drivers/pci/endpoint/functions/pci-epf-ntb.c index 9a00448c7e61..980b4ecf19a2 100644 --- a/drivers/pci/endpoint/functions/pci-epf-ntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c @@ -2075,11 +2075,12 @@ static struct config_group *epf_ntb_add_cfs(struct pci_epf *epf, /** * epf_ntb_probe() - Probe NTB function driver * @epf: NTB endpoint function device + * @id: NTB endpoint function device ID * * Probe NTB function driver when endpoint function bus detects a NTB * endpoint function. */ -static int epf_ntb_probe(struct pci_epf *epf) +static int epf_ntb_probe(struct pci_epf *epf, const struct pci_epf_device_id *id) { struct epf_ntb *ntb; struct device *dev; diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/endpoint/functions/pci-epf-test.c index 0f9d2ec822ac..d5fcc78a5b73 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -980,7 +980,7 @@ static const struct pci_epf_device_id pci_epf_test_ids[] = { {}, }; -static int pci_epf_test_probe(struct pci_epf *epf) +static int pci_epf_test_probe(struct pci_epf *epf, const struct pci_epf_device_id *id) { struct pci_epf_test *epf_test; struct device *dev = &epf->dev; diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.c b/drivers/pci/endpoint/functions/pci-epf-vntb.c index b7c7a8af99f4..122eb7a12028 100644 --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c @@ -1401,7 +1401,7 @@ static struct pci_epf_ops epf_ntb_ops = { * * Returns: Zero for success, or an error code in case of failure */ -static int epf_ntb_probe(struct pci_epf *epf) +static int epf_ntb_probe(struct pci_epf *epf, const struct pci_epf_device_id *id) { struct epf_ntb *ntb; struct device *dev; diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index 2036e38be093..ea6e0aef0bb3 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -493,16 +493,16 @@ static const struct device_type pci_epf_type = { .release = pci_epf_dev_release, }; -static int -pci_epf_match_id(const struct pci_epf_device_id *id, const struct pci_epf *epf) +static const struct pci_epf_device_id +*pci_epf_match_id(const struct pci_epf_device_id *id, const struct pci_epf *epf) { while (id->name[0]) { if (strcmp(epf->name, id->name) == 0) - return true; + return id; id++; } - return false; + return NULL; } static int pci_epf_device_match(struct device *dev, struct device_driver *drv) @@ -510,8 +510,12 @@ static int pci_epf_device_match(struct device *dev, struct device_driver *drv) struct pci_epf *epf = to_pci_epf(dev); struct pci_epf_driver *driver = to_pci_epf_driver(drv); - if (driver->id_table) - return pci_epf_match_id(driver->id_table, epf); + if (driver->id_table) { + if (pci_epf_match_id(driver->id_table, epf)) + return true; + else + return false; + } return !strcmp(epf->name, drv->name); } @@ -526,7 +530,7 @@ static int pci_epf_device_probe(struct device *dev) epf->driver = driver; - return driver->probe(epf); + return driver->probe(epf, pci_epf_match_id(driver->id_table, epf)); } static void pci_epf_device_remove(struct device *dev) diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index a215dc8ce693..bc613f0df7e3 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -89,7 +89,7 @@ struct pci_epc_event_ops { * @id_table: identifies EPF devices for probing */ struct pci_epf_driver { - int (*probe)(struct pci_epf *epf); + int (*probe)(struct pci_epf *epf, const struct pci_epf_device_id *id); void (*remove)(struct pci_epf *epf); struct device_driver driver; @@ -131,6 +131,7 @@ struct pci_epf_bar { * @epc: the EPC device to which this EPF device is bound * @epf_pf: the physical EPF device to which this virtual EPF device is bound * @driver: the EPF driver to which this EPF device is bound + * @id: Pointer to the EPF device ID * @list: to add pci_epf as a list of PCI endpoint functions to pci_epc * @lock: mutex to protect pci_epf_ops * @sec_epc: the secondary EPC device to which this EPF device is bound @@ -158,6 +159,7 @@ struct pci_epf { struct pci_epc *epc; struct pci_epf *epf_pf; struct pci_epf_driver *driver; + const struct pci_epf_device_id *id; struct list_head list; /* mutex to protect against concurrent access of pci_epf_ops */ struct mutex lock;