Skip to contentSkip to conversation

fpga: altera-cvp: Fix registration for CvP incapable devices

PATCH In review Anatolij Gustschin 3 participants 3 messages Oct 29, 2018 – Nov 1, 2018 FPGA manager framework

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 fpga: altera-cvp: Fix registration for CvP incapable devices

From: Andreas Puhm <[email protected]>

The probe function needs to verify the CvP enable bit in order to properly determine if FPGA Manager functionality can be safely enabled.

Fixes 34d1dc17ce97 ("fpga manager: Add Altera CvP driver")

---
Changes in v2:
- improve Fixes tag
- wrap lines in commit description

 drivers/fpga/altera-cvp.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/fpga/altera-cvp.c +9 -0
index 3998d4f0e5e7..196d52558990 100644
@@ -403,6 +403,7 @@ static int altera_cvp_probe(struct pci_dev *pdev,
 	struct altera_cvp_conf *conf;
 	struct fpga_manager *mgr;
 	u16 cmd, val;
+	u32 regval;
 	int ret;
 
 	/*
@@ -419,6 +420,14 @@ static int altera_cvp_probe(struct pci_dev *pdev,
 		return -ENODEV;
 	}
 
+	pci_read_config_dword(pdev, VSE_CVP_STATUS, &regval);
+	if (!(regval & VSE_CVP_STATUS_CVP_EN)) {
+		dev_err(&pdev->dev,
+			"CVP is disabled for this device: CVP_STATUS Reg 0x%x\n",
+			regval);
+		return -ENODEV;
+	}
+
 	conf = devm_kzalloc(&pdev->dev, sizeof(*conf), GFP_KERNEL);
 	if (!conf)
 		return -ENOMEM;
Signature · 1 line
2.17.1
maintainer Reviewed-by on v2 1/1
#1 lore raw

Hi Anatolij, Andreas,

Quoted 9 lines · Anatolij Gustschin

From: Andreas Puhm <[email protected]>

The probe function needs to verify the CvP enable bit in order to properly determine if FPGA Manager functionality can be safely enabled.

Fixes 34d1dc17ce97 ("fpga manager: Add Altera CvP driver")
Quoted 38 lines

---
Changes in v2:
- improve Fixes tag
- wrap lines in commit description

 drivers/fpga/altera-cvp.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/fpga/altera-cvp.c +9 -0
index 3998d4f0e5e7..196d52558990 100644
@@ -403,6 +403,7 @@ static int altera_cvp_probe(struct pci_dev *pdev,
 	struct altera_cvp_conf *conf;
 	struct fpga_manager *mgr;
 	u16 cmd, val;
+	u32 regval;
 	int ret;
 
 	/*
@@ -419,6 +420,14 @@ static int altera_cvp_probe(struct pci_dev *pdev,
 		return -ENODEV;
 	}
 
+	pci_read_config_dword(pdev, VSE_CVP_STATUS, &regval);
+	if (!(regval & VSE_CVP_STATUS_CVP_EN)) {
+		dev_err(&pdev->dev,
+			"CVP is disabled for this device: CVP_STATUS Reg 0x%x\n",
+			regval);
+		return -ENODEV;
+	}
+
 	conf = devm_kzalloc(&pdev->dev, sizeof(*conf), GFP_KERNEL);
 	if (!conf)
 		return -ENOMEM;
Signature · 1 line
2.17.1

Thanks,
Moritz

Acked-by
#2 lore raw
Quoted 10 lines · Moritz Fischer

Hi Anatolij, Andreas,

Quoted 6 lines · Anatolij Gustschin

From: Andreas Puhm <[email protected]>

The probe function needs to verify the CvP enable bit in order to properly determine if FPGA Manager functionality can be safely enabled.

Quoted 5 lines
Quoted 3 lines
Fixes 34d1dc17ce97 ("fpga manager: Add Altera CvP driver")

Thanks!

Alan

Quoted 41 lines
Quoted 36 lines

---
Changes in v2:
- improve Fixes tag
- wrap lines in commit description

 drivers/fpga/altera-cvp.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/fpga/altera-cvp.c +9 -1
index 3998d4f0e5e7..196d52558990 100644
@@ -403,6 +403,7 @@ static int altera_cvp_probe(struct pci_dev *pdev,
      struct altera_cvp_conf *conf;
      struct fpga_manager *mgr;
      u16 cmd, val;
+     u32 regval;
      int ret;
 
      /*
@@ -419,6 +420,14 @@ static int altera_cvp_probe(struct pci_dev *pdev,
              return -ENODEV;
      }
 
+     pci_read_config_dword(pdev, VSE_CVP_STATUS, &regval);
+     if (!(regval & VSE_CVP_STATUS_CVP_EN)) {
+             dev_err(&pdev->dev,
+                     "CVP is disabled for this device: CVP_STATUS Reg 0x%x\n",
+                     regval);
+             return -ENODEV;
+     }
+
      conf = devm_kzalloc(&pdev->dev, sizeof(*conf), GFP_KERNEL);
      if (!conf)
              return -ENOMEM;
--
Quoted 2 lines

2.17.1

Thanks,
Moritz