Skip to contentSkip to conversation

fpga fr br: fix warning for unexpected version number

PATCH In review [email protected] 2 participants 4 messages Apr 5, 2017 – Apr 6, 2017 FPGA manager framework

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fpga fr br: fix warning for unexpected version number

From: Matthew Gerlach <[email protected]>

The value in the version register of the altera freeze bridge controller changed from the beta value of 2 to the value of 0xad000003 in the official release of the IP. This patch supports the old and new version numbers without printing an warning.

---
 drivers/fpga/altera-freeze-bridge.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/fpga/altera-freeze-bridge.c +6 -3
index 8dcd9fb..bdfd5eb 100644
@@ -28,6 +28,7 @@
 #define FREEZE_CSR_REG_VERSION			12
 
 #define FREEZE_CSR_SUPPORTED_VERSION		2
+#define FREEZE_CSR_OFFICIAL_VERSION		0xad000003
 
 #define FREEZE_CSR_STATUS_FREEZE_REQ_DONE	BIT(0)
 #define FREEZE_CSR_STATUS_UNFREEZE_REQ_DONE	BIT(1)
@@ -241,10 +242,12 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
 		priv->enable = 1;
 
 	revision = readl(priv->base_addr + FREEZE_CSR_REG_VERSION);
-	if (revision != FREEZE_CSR_SUPPORTED_VERSION)
+	if ((revision != FREEZE_CSR_SUPPORTED_VERSION) &&
+	    (revision != FREEZE_CSR_OFFICIAL_VERSION))
 		dev_warn(dev,
-			 "%s Freeze Controller unexpected revision %d != %d\n",
-			 __func__, revision, FREEZE_CSR_SUPPORTED_VERSION);
+			 "%s unexpected revision 0x%x != 0x%x != 0x%x\n",
+			 __func__, revision, FREEZE_CSR_SUPPORTED_VERSION,
+			 FREEZE_CSR_OFFICIAL_VERSION);
 
 	return fpga_bridge_register(dev, FREEZE_BRIDGE_NAME,
 				    &altera_freeze_br_br_ops, priv);
Signature · 1 line
2.7.4
maintainer
#1 lore raw

Hi Matthew,

Quoted 28 lines · On Wed, Apr 5, 2017 at 12:05 PM, <[email protected]> wrote:

From: Matthew Gerlach <[email protected]>

The value in the version register of the altera freeze bridge controller changed from the beta value of 2 to the value of 0xad000003 in the official release of the IP. This patch supports the old and new version numbers without printing an warning.

---
 drivers/fpga/altera-freeze-bridge.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/fpga/altera-freeze-bridge.c +1 -0
index 8dcd9fb..bdfd5eb 100644
@@ -28,6 +28,7 @@
 #define FREEZE_CSR_REG_VERSION                 12
 
 #define FREEZE_CSR_SUPPORTED_VERSION           2
+#define FREEZE_CSR_OFFICIAL_VERSION            0xad000003
 
 #define FREEZE_CSR_STATUS_FREEZE_REQ_DONE      BIT(0)
 #define FREEZE_CSR_STATUS_UNFREEZE_REQ_DONE    BIT(1)
@@ -241,10 +242,12 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
                priv->enable = 1;
 

drivers/fpga/altera-freeze-bridge.c static int altera_freeze_br_probe(struct platform_device *pdev) · line 250

Quoted 10 lines
drivers/fpga/altera-freeze-bridge.c +5 -3
        revision = readl(priv->base_addr + FREEZE_CSR_REG_VERSION);
-       if (revision != FREEZE_CSR_SUPPORTED_VERSION)
+       if ((revision != FREEZE_CSR_SUPPORTED_VERSION) &&
+           (revision != FREEZE_CSR_OFFICIAL_VERSION))
                dev_warn(dev,
-                        "%s Freeze Controller unexpected revision %d != %d\n",
-                        __func__, revision, FREEZE_CSR_SUPPORTED_VERSION);
+                        "%s unexpected revision 0x%x != 0x%x != 0x%x\n",
+                        __func__, revision, FREEZE_CSR_SUPPORTED_VERSION,
+                        FREEZE_CSR_OFFICIAL_VERSION);

Maybe you actually wanna bail out if you read a random other value instead of what you
expect instead of printing a warning.

Quoted 6 lines
drivers/fpga/altera-freeze-bridge.c +0 -1
        return fpga_bridge_register(dev, FREEZE_BRIDGE_NAME,
                                    &altera_freeze_br_br_ops, priv);
--

2.7.4

Cheers,

Moritz

#2 lore raw
Quoted 2 lines · Moritz Fischer

Hi Matthew,

Hi Moritz,

Quoted 29 lines · On Wed, Apr 5, 2017 at 12:05 PM, <[email protected]> wrote:
Quoted 28 lines

From: Matthew Gerlach <[email protected]>

The value in the version register of the altera freeze bridge controller changed from the beta value of 2 to the value of 0xad000003 in the official release of the IP. This patch supports the old and new version numbers without printing an warning.

---
 drivers/fpga/altera-freeze-bridge.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/fpga/altera-freeze-bridge.c +1 -0
index 8dcd9fb..bdfd5eb 100644
@@ -28,6 +28,7 @@
 #define FREEZE_CSR_REG_VERSION                 12
 
 #define FREEZE_CSR_SUPPORTED_VERSION           2
+#define FREEZE_CSR_OFFICIAL_VERSION            0xad000003
 
 #define FREEZE_CSR_STATUS_FREEZE_REQ_DONE      BIT(0)
 #define FREEZE_CSR_STATUS_UNFREEZE_REQ_DONE    BIT(1)
@@ -241,10 +242,12 @@ static int altera_freeze_br_probe(struct platform_device *pdev)
                priv->enable = 1;
 
Quoted 14 lines

drivers/fpga/altera-freeze-bridge.c static int altera_freeze_br_probe(struct platform_device *pdev) · line 250

Quoted 10 lines
drivers/fpga/altera-freeze-bridge.c +5 -3
        revision = readl(priv->base_addr + FREEZE_CSR_REG_VERSION);
-       if (revision != FREEZE_CSR_SUPPORTED_VERSION)
+       if ((revision != FREEZE_CSR_SUPPORTED_VERSION) &&
+           (revision != FREEZE_CSR_OFFICIAL_VERSION))
                dev_warn(dev,
-                        "%s Freeze Controller unexpected revision %d != %d\n",
-                        __func__, revision, FREEZE_CSR_SUPPORTED_VERSION);
+                        "%s unexpected revision 0x%x != 0x%x != 0x%x\n",
+                        __func__, revision, FREEZE_CSR_SUPPORTED_VERSION,
+                        FREEZE_CSR_OFFICIAL_VERSION);

Maybe you actually wanna bail out if you read a random other value instead of what you
expect instead of printing a warning.

I thought about making it an error if the version didn't match, but it was a dev_warn() before and that allowed folks to use the "old" driver with the new IP version.

Quoted 11 lines
Quoted 6 lines
drivers/fpga/altera-freeze-bridge.c +0 -1
        return fpga_bridge_register(dev, FREEZE_BRIDGE_NAME,
                                    &altera_freeze_br_br_ops, priv);
--

2.7.4

Cheers,

Moritz

maintainer
#3 lore raw

Hi Matthew,

Quoted 8 lines · On Wed, Apr 5, 2017 at 3:25 PM, <[email protected]> wrote:
Quoted 3 lines

Maybe you actually wanna bail out if you read a random other value instead of what you
expect instead of printing a warning.

I thought about making it an error if the version didn't match, but it was a dev_warn() before and that allowed folks to use the "old" driver with the new IP version.

Or some random other piece of logic in the FPGA that happens to be mapped to that address ;-)

I agree we should've probably caught this in the initial review, but maybe we should change it.

Cheers,

Moritz