[PATCH 4.14 022/205] fpga: altera-cvp: Fix registration for CvP incapable devices

From: Greg Kroah-Hartman
Date: Mon Feb 11 2019 - 10:30:23 EST


4.14-stable review patch. If anyone has any objections, please let me know.

------------------

[ Upstream commit 68f60538daa4bc3da5d0764d46f391916fba20fd ]

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")
Signed-off-by: Andreas Puhm <puhm@xxxxxxxxxx>
Signed-off-by: Anatolij Gustschin <agust@xxxxxxx>
Reviewed-by: Moritz Fischer <mdf@xxxxxxxxxx>
Acked-by: Alan Tull <atull@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/fpga/altera-cvp.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/fpga/altera-cvp.c b/drivers/fpga/altera-cvp.c
index 00e73d28077c..b7558acd1a66 100644
--- a/drivers/fpga/altera-cvp.c
+++ b/drivers/fpga/altera-cvp.c
@@ -404,6 +404,7 @@ static int altera_cvp_probe(struct pci_dev *pdev,
{
struct altera_cvp_conf *conf;
u16 cmd, val;
+ u32 regval;
int ret;

/*
@@ -417,6 +418,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;
--
2.19.1