public inbox for linux-fpga@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 1/1] fpga: altera-cvp: Use pci_find_vsec_capability() when probing FPGA device
@ 2025-11-09 20:16 Andy Shevchenko
  2025-11-10  7:03 ` Xu Yilun
  0 siblings, 1 reply; 2+ messages in thread
From: Andy Shevchenko @ 2025-11-09 20:16 UTC (permalink / raw)
  To: Xu Yilun, Andy Shevchenko, linux-fpga, linux-kernel
  Cc: Moritz Fischer, Tom Rix

Currently altera_cvp_probe() open-codes pci_find_vsec_capability().
Refactor the former to use the latter.

With that done:
- use the VSEC ID as per datasheet [1]
- update the error message accordingly

Link: https://www.intel.com/content/www/us/en/docs/programmable/683763/23-1/vendor-specific-header-register.html [1]
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---

v3: used VSEC ID per datasheet (Xu), updated commit message (Xu)

 drivers/fpga/altera-cvp.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c
index 5af0bd33890c..44badfd11e1b 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,18 @@ 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 cmd, 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, 0x1172);
+	if (!offset) {
+		dev_err(&pdev->dev, "Wrong VSEC ID value\n");
 		return -ENODEV;
 	}
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3 1/1] fpga: altera-cvp: Use pci_find_vsec_capability() when probing FPGA device
  2025-11-09 20:16 [PATCH v3 1/1] fpga: altera-cvp: Use pci_find_vsec_capability() when probing FPGA device Andy Shevchenko
@ 2025-11-10  7:03 ` Xu Yilun
  0 siblings, 0 replies; 2+ messages in thread
From: Xu Yilun @ 2025-11-10  7:03 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Xu Yilun, linux-fpga, linux-kernel, Moritz Fischer, Tom Rix

On Sun, Nov 09, 2025 at 09:16:37PM +0100, Andy Shevchenko wrote:
> Currently altera_cvp_probe() open-codes pci_find_vsec_capability().
> Refactor the former to use the latter.
> 
> With that done:
> - use the VSEC ID as per datasheet [1]
> - update the error message accordingly
> 
> Link: https://www.intel.com/content/www/us/en/docs/programmable/683763/23-1/vendor-specific-header-register.html [1]

Thanks for the Doc. It's clear now.

Reviewed-by: Xu Yilun <yilun.xu@intel.com>

Applied to for-next

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-11-10  7:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-09 20:16 [PATCH v3 1/1] fpga: altera-cvp: Use pci_find_vsec_capability() when probing FPGA device Andy Shevchenko
2025-11-10  7:03 ` Xu Yilun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox