* [PATCH v1 1/1] fpga: altera-cvp: Use pci_find_vsec_capability() when probing FPGA device
@ 2025-06-27 6:14 Andy Shevchenko
2025-06-27 10:06 ` kernel test robot
0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2025-06-27 6:14 UTC (permalink / raw)
To: Xu Yilun, Andy Shevchenko, linux-fpga, linux-kernel
Cc: Moritz Fischer, Wu Hao, Tom Rix
Currently altera_cvp_probe() open-codes pci_find_vsec_capability().
Refactor the former to use the latter. No functional change intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/fpga/altera-cvp.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)
diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c
index 5af0bd33890c..f6140a56c70b 100644
--- a/drivers/fpga/altera-cvp.c
+++ b/drivers/fpga/altera-cvp.c
@@ -22,9 +22,6 @@
#define TIMEOUT_US 2000 /* CVP STATUS timeout for USERMODE polling */
/* Vendor Specific Extended Capability Registers */
-#define VSE_PCIE_EXT_CAP_ID 0x0
-#define VSE_PCIE_EXT_CAP_ID_VAL 0x000b /* 16bit */
-
#define VSE_CVP_STATUS 0x1c /* 32bit */
#define VSE_CVP_STATUS_CFG_RDY BIT(18) /* CVP_CONFIG_READY */
#define VSE_CVP_STATUS_CFG_ERR BIT(19) /* CVP_CONFIG_ERROR */
@@ -577,25 +574,19 @@ static int altera_cvp_probe(struct pci_dev *pdev,
{
struct altera_cvp_conf *conf;
struct fpga_manager *mgr;
- int ret, offset;
u16 cmd, val;
+ u16 offset;
u32 regval;
-
- /* Discover the Vendor Specific Offset for this device */
- offset = pci_find_next_ext_capability(pdev, 0, PCI_EXT_CAP_ID_VNDR);
- if (!offset) {
- dev_err(&pdev->dev, "No Vendor Specific Offset.\n");
- return -ENODEV;
- }
+ int ret;
/*
* First check if this is the expected FPGA device. PCI config
* space access works without enabling the PCI device, memory
* space access is enabled further down.
*/
- pci_read_config_word(pdev, offset + VSE_PCIE_EXT_CAP_ID, &val);
- if (val != VSE_PCIE_EXT_CAP_ID_VAL) {
- dev_err(&pdev->dev, "Wrong EXT_CAP_ID value 0x%x\n", val);
+ offset = pci_find_vsec_capability(pdev, PCI_VENDOR_ID_ALTERA, 0);
+ if (!offset) {
+ dev_err(&pdev->dev, "Wrong EXT_CAP_ID value\n");
return -ENODEV;
}
--
2.47.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v1 1/1] fpga: altera-cvp: Use pci_find_vsec_capability() when probing FPGA device
2025-06-27 6:14 [PATCH v1 1/1] fpga: altera-cvp: Use pci_find_vsec_capability() when probing FPGA device Andy Shevchenko
@ 2025-06-27 10:06 ` kernel test robot
0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2025-06-27 10:06 UTC (permalink / raw)
To: Andy Shevchenko, Xu Yilun, linux-fpga, linux-kernel
Cc: oe-kbuild-all, Moritz Fischer, Wu Hao, Tom Rix
Hi Andy,
kernel test robot noticed the following build warnings:
[auto build test WARNING on linus/master]
[also build test WARNING on v6.16-rc3 next-20250626]
[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/Andy-Shevchenko/fpga-altera-cvp-Use-pci_find_vsec_capability-when-probing-FPGA-device/20250627-142050
base: linus/master
patch link: https://lore.kernel.org/r/20250627061431.522016-1-andriy.shevchenko%40linux.intel.com
patch subject: [PATCH v1 1/1] fpga: altera-cvp: Use pci_find_vsec_capability() when probing FPGA device
config: i386-buildonly-randconfig-001-20250627 (https://download.01.org/0day-ci/archive/20250627/202506271724.dQ1jAckC-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250627/202506271724.dQ1jAckC-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202506271724.dQ1jAckC-lkp@intel.com/
All warnings (new ones prefixed by >>):
drivers/fpga/altera-cvp.c: In function 'altera_cvp_probe':
>> drivers/fpga/altera-cvp.c:577:18: warning: unused variable 'val' [-Wunused-variable]
577 | u16 cmd, val;
| ^~~
vim +/val +577 drivers/fpga/altera-cvp.c
34d1dc17ce978a Anatolij Gustschin 2017-06-14 571
34d1dc17ce978a Anatolij Gustschin 2017-06-14 572 static int altera_cvp_probe(struct pci_dev *pdev,
34d1dc17ce978a Anatolij Gustschin 2017-06-14 573 const struct pci_device_id *dev_id)
34d1dc17ce978a Anatolij Gustschin 2017-06-14 574 {
34d1dc17ce978a Anatolij Gustschin 2017-06-14 575 struct altera_cvp_conf *conf;
7085e2a94f7df5 Alan Tull 2018-05-16 576 struct fpga_manager *mgr;
34d1dc17ce978a Anatolij Gustschin 2017-06-14 @577 u16 cmd, val;
823fd4b4a8bd1f Andy Shevchenko 2025-06-27 578 u16 offset;
68f60538daa4bc Andreas Puhm 2018-11-07 579 u32 regval;
823fd4b4a8bd1f Andy Shevchenko 2025-06-27 580 int ret;
34d1dc17ce978a Anatolij Gustschin 2017-06-14 581
34d1dc17ce978a Anatolij Gustschin 2017-06-14 582 /*
34d1dc17ce978a Anatolij Gustschin 2017-06-14 583 * First check if this is the expected FPGA device. PCI config
34d1dc17ce978a Anatolij Gustschin 2017-06-14 584 * space access works without enabling the PCI device, memory
34d1dc17ce978a Anatolij Gustschin 2017-06-14 585 * space access is enabled further down.
34d1dc17ce978a Anatolij Gustschin 2017-06-14 586 */
823fd4b4a8bd1f Andy Shevchenko 2025-06-27 587 offset = pci_find_vsec_capability(pdev, PCI_VENDOR_ID_ALTERA, 0);
823fd4b4a8bd1f Andy Shevchenko 2025-06-27 588 if (!offset) {
823fd4b4a8bd1f Andy Shevchenko 2025-06-27 589 dev_err(&pdev->dev, "Wrong EXT_CAP_ID value\n");
34d1dc17ce978a Anatolij Gustschin 2017-06-14 590 return -ENODEV;
34d1dc17ce978a Anatolij Gustschin 2017-06-14 591 }
34d1dc17ce978a Anatolij Gustschin 2017-06-14 592
eb12511f0d47b4 Thor Thayer 2019-08-19 593 pci_read_config_dword(pdev, offset + VSE_CVP_STATUS, ®val);
68f60538daa4bc Andreas Puhm 2018-11-07 594 if (!(regval & VSE_CVP_STATUS_CVP_EN)) {
68f60538daa4bc Andreas Puhm 2018-11-07 595 dev_err(&pdev->dev,
68f60538daa4bc Andreas Puhm 2018-11-07 596 "CVP is disabled for this device: CVP_STATUS Reg 0x%x\n",
68f60538daa4bc Andreas Puhm 2018-11-07 597 regval);
68f60538daa4bc Andreas Puhm 2018-11-07 598 return -ENODEV;
68f60538daa4bc Andreas Puhm 2018-11-07 599 }
68f60538daa4bc Andreas Puhm 2018-11-07 600
34d1dc17ce978a Anatolij Gustschin 2017-06-14 601 conf = devm_kzalloc(&pdev->dev, sizeof(*conf), GFP_KERNEL);
34d1dc17ce978a Anatolij Gustschin 2017-06-14 602 if (!conf)
34d1dc17ce978a Anatolij Gustschin 2017-06-14 603 return -ENOMEM;
34d1dc17ce978a Anatolij Gustschin 2017-06-14 604
eb12511f0d47b4 Thor Thayer 2019-08-19 605 conf->vsec_offset = offset;
eb12511f0d47b4 Thor Thayer 2019-08-19 606
34d1dc17ce978a Anatolij Gustschin 2017-06-14 607 /*
34d1dc17ce978a Anatolij Gustschin 2017-06-14 608 * Enable memory BAR access. We cannot use pci_enable_device() here
34d1dc17ce978a Anatolij Gustschin 2017-06-14 609 * because it will make the driver unusable with FPGA devices that
34d1dc17ce978a Anatolij Gustschin 2017-06-14 610 * have additional big IOMEM resources (e.g. 4GiB BARs) on 32-bit
34d1dc17ce978a Anatolij Gustschin 2017-06-14 611 * platform. Such BARs will not have an assigned address range and
34d1dc17ce978a Anatolij Gustschin 2017-06-14 612 * pci_enable_device() will fail, complaining about not claimed BAR,
34d1dc17ce978a Anatolij Gustschin 2017-06-14 613 * even if the concerned BAR is not needed for FPGA configuration
34d1dc17ce978a Anatolij Gustschin 2017-06-14 614 * at all. Thus, enable the device via PCI config space command.
34d1dc17ce978a Anatolij Gustschin 2017-06-14 615 */
34d1dc17ce978a Anatolij Gustschin 2017-06-14 616 pci_read_config_word(pdev, PCI_COMMAND, &cmd);
34d1dc17ce978a Anatolij Gustschin 2017-06-14 617 if (!(cmd & PCI_COMMAND_MEMORY)) {
34d1dc17ce978a Anatolij Gustschin 2017-06-14 618 cmd |= PCI_COMMAND_MEMORY;
34d1dc17ce978a Anatolij Gustschin 2017-06-14 619 pci_write_config_word(pdev, PCI_COMMAND, cmd);
34d1dc17ce978a Anatolij Gustschin 2017-06-14 620 }
34d1dc17ce978a Anatolij Gustschin 2017-06-14 621
34d1dc17ce978a Anatolij Gustschin 2017-06-14 622 ret = pci_request_region(pdev, CVP_BAR, "CVP");
34d1dc17ce978a Anatolij Gustschin 2017-06-14 623 if (ret) {
34d1dc17ce978a Anatolij Gustschin 2017-06-14 624 dev_err(&pdev->dev, "Requesting CVP BAR region failed\n");
34d1dc17ce978a Anatolij Gustschin 2017-06-14 625 goto err_disable;
34d1dc17ce978a Anatolij Gustschin 2017-06-14 626 }
34d1dc17ce978a Anatolij Gustschin 2017-06-14 627
34d1dc17ce978a Anatolij Gustschin 2017-06-14 628 conf->pci_dev = pdev;
34d1dc17ce978a Anatolij Gustschin 2017-06-14 629 conf->write_data = altera_cvp_write_data_iomem;
34d1dc17ce978a Anatolij Gustschin 2017-06-14 630
e58915179f3f4a Thor Thayer 2019-08-19 631 if (conf->vsec_offset == V1_VSEC_OFFSET)
e58915179f3f4a Thor Thayer 2019-08-19 632 conf->priv = &cvp_priv_v1;
e58915179f3f4a Thor Thayer 2019-08-19 633 else
e58915179f3f4a Thor Thayer 2019-08-19 634 conf->priv = &cvp_priv_v2;
e58915179f3f4a Thor Thayer 2019-08-19 635
34d1dc17ce978a Anatolij Gustschin 2017-06-14 636 conf->map = pci_iomap(pdev, CVP_BAR, 0);
34d1dc17ce978a Anatolij Gustschin 2017-06-14 637 if (!conf->map) {
34d1dc17ce978a Anatolij Gustschin 2017-06-14 638 dev_warn(&pdev->dev, "Mapping CVP BAR failed\n");
34d1dc17ce978a Anatolij Gustschin 2017-06-14 639 conf->write_data = altera_cvp_write_data_config;
34d1dc17ce978a Anatolij Gustschin 2017-06-14 640 }
34d1dc17ce978a Anatolij Gustschin 2017-06-14 641
34d1dc17ce978a Anatolij Gustschin 2017-06-14 642 snprintf(conf->mgr_name, sizeof(conf->mgr_name), "%s @%s",
34d1dc17ce978a Anatolij Gustschin 2017-06-14 643 ALTERA_CVP_MGR_NAME, pci_name(pdev));
34d1dc17ce978a Anatolij Gustschin 2017-06-14 644
4ba0b2c294fe69 Russ Weight 2021-11-18 645 mgr = fpga_mgr_register(&pdev->dev, conf->mgr_name,
34d1dc17ce978a Anatolij Gustschin 2017-06-14 646 &altera_cvp_ops, conf);
4ba0b2c294fe69 Russ Weight 2021-11-18 647 if (IS_ERR(mgr)) {
4ba0b2c294fe69 Russ Weight 2021-11-18 648 ret = PTR_ERR(mgr);
122c5770cff2c1 Christophe Jaillet 2018-06-27 649 goto err_unmap;
122c5770cff2c1 Christophe Jaillet 2018-06-27 650 }
7085e2a94f7df5 Alan Tull 2018-05-16 651
7085e2a94f7df5 Alan Tull 2018-05-16 652 pci_set_drvdata(pdev, mgr);
7085e2a94f7df5 Alan Tull 2018-05-16 653
34d1dc17ce978a Anatolij Gustschin 2017-06-14 654 return 0;
34d1dc17ce978a Anatolij Gustschin 2017-06-14 655
34d1dc17ce978a Anatolij Gustschin 2017-06-14 656 err_unmap:
187fade88ca0ff Anatolij Gustschin 2018-11-07 657 if (conf->map)
34d1dc17ce978a Anatolij Gustschin 2017-06-14 658 pci_iounmap(pdev, conf->map);
34d1dc17ce978a Anatolij Gustschin 2017-06-14 659 pci_release_region(pdev, CVP_BAR);
34d1dc17ce978a Anatolij Gustschin 2017-06-14 660 err_disable:
34d1dc17ce978a Anatolij Gustschin 2017-06-14 661 cmd &= ~PCI_COMMAND_MEMORY;
34d1dc17ce978a Anatolij Gustschin 2017-06-14 662 pci_write_config_word(pdev, PCI_COMMAND, cmd);
34d1dc17ce978a Anatolij Gustschin 2017-06-14 663 return ret;
34d1dc17ce978a Anatolij Gustschin 2017-06-14 664 }
34d1dc17ce978a Anatolij Gustschin 2017-06-14 665
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-06-27 10:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-27 6:14 [PATCH v1 1/1] fpga: altera-cvp: Use pci_find_vsec_capability() when probing FPGA device Andy Shevchenko
2025-06-27 10:06 ` kernel test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).