[v2,1/7] PCI: endpoint: Pass EPF device ID to the probe function
Commit Message
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. And the only way to
do so is by storing the correct device ID in "struct pci_epf" during
"pci_epf_match_id()" and passing that to probe().
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
---
drivers/pci/endpoint/functions/pci-epf-ntb.c | 3 ++-
drivers/pci/endpoint/functions/pci-epf-test.c | 2 +-
drivers/pci/endpoint/pci-epf-core.c | 8 +++++---
include/linux/pci-epf.h | 4 +++-
4 files changed, 11 insertions(+), 6 deletions(-)
Comments
Hi Manivannan,
I love your patch! Yet something to improve:
[auto build test ERROR on pci/next]
[also build test ERROR on pci/for-linus jonmason-ntb/ntb-next linus/master v6.3-rc1 next-20230310]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Manivannan-Sadhasivam/PCI-endpoint-Pass-EPF-device-ID-to-the-probe-function/20230307-232050
base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link: https://lore.kernel.org/r/20230307151416.176595-2-manivannan.sadhasivam%40linaro.org
patch subject: [PATCH v2 1/7] PCI: endpoint: Pass EPF device ID to the probe function
config: x86_64-randconfig-a016-20220905 (https://download.01.org/0day-ci/archive/20230312/202303121526.qVIG9eBb-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/26f2c0c8a0b85aceb28bc5688851fab125a55ac6
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Manivannan-Sadhasivam/PCI-endpoint-Pass-EPF-device-ID-to-the-probe-function/20230307-232050
git checkout 26f2c0c8a0b85aceb28bc5688851fab125a55ac6
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 olddefconfig
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Link: https://lore.kernel.org/oe-kbuild-all/202303121526.qVIG9eBb-lkp@intel.com/
All errors (new ones prefixed by >>):
>> drivers/pci/endpoint/functions/pci-epf-vntb.c:1433:27: error: initialization of 'int (*)(struct pci_epf *, const struct pci_epf_device_id *)' from incompatible pointer type 'int (*)(struct pci_epf *)' [-Werror=incompatible-pointer-types]
1433 | .probe = epf_ntb_probe,
| ^~~~~~~~~~~~~
drivers/pci/endpoint/functions/pci-epf-vntb.c:1433:27: note: (near initialization for 'epf_ntb_driver.probe')
cc1: some warnings being treated as errors
vim +1433 drivers/pci/endpoint/functions/pci-epf-vntb.c
e35f56bb03304a Frank Li 2022-02-22 1430
e35f56bb03304a Frank Li 2022-02-22 1431 static struct pci_epf_driver epf_ntb_driver = {
e35f56bb03304a Frank Li 2022-02-22 1432 .driver.name = "pci_epf_vntb",
e35f56bb03304a Frank Li 2022-02-22 @1433 .probe = epf_ntb_probe,
e35f56bb03304a Frank Li 2022-02-22 1434 .id_table = epf_ntb_ids,
e35f56bb03304a Frank Li 2022-02-22 1435 .ops = &epf_ntb_ops,
e35f56bb03304a Frank Li 2022-02-22 1436 .owner = THIS_MODULE,
e35f56bb03304a Frank Li 2022-02-22 1437 };
e35f56bb03304a Frank Li 2022-02-22 1438
@@ -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;
@@ -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;
@@ -494,11 +494,13 @@ static const struct device_type pci_epf_type = {
};
static int
-pci_epf_match_id(const struct pci_epf_device_id *id, const struct pci_epf *epf)
+pci_epf_match_id(const struct pci_epf_device_id *id, struct pci_epf *epf)
{
while (id->name[0]) {
- if (strcmp(epf->name, id->name) == 0)
+ if (strcmp(epf->name, id->name) == 0) {
+ epf->id = id;
return true;
+ }
id++;
}
@@ -526,7 +528,7 @@ static int pci_epf_device_probe(struct device *dev)
epf->driver = driver;
- return driver->probe(epf);
+ return driver->probe(epf, epf->id);
}
static void pci_epf_device_remove(struct device *dev)
@@ -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;