Skip to contentSkip to conversation

mfd: lpc_sch - tolerate f/w disabled WDT

PATCH In review Jean-François Dagenais 2 participants 3 messages May 11, 2012 – May 14, 2012 Multifunction devices (MFD)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mfd: lpc_sch - tolerate f/w disabled WDT

(Observed while running on Kontron nano-TT module.)

Certain BIOS/boot firmware may disable the tunnelcreek watchdog. Perhaps because the mainboard or module provides it's own watchdog mechanism. In these cases, lpc_sch should just go on and still provide the rest of the cells it declares (GPIO and SMBus). The same logic could be applied to the other resources, but I'll leave it to others to decide that.

This change makes the probe function tolerate the I/O range being disabled, but not if the base address inside the register is not configured.

Cc Alexander Stein <[email protected]>
Cc Denis Turischev <[email protected]>
---
 drivers/mfd/lpc_sch.c |   39 ++++++++++++++++++++-------------------
 1 files changed, 20 insertions(+), 19 deletions(-)
drivers/mfd/lpc_sch.c +20 -19
index ea1169b..6621cd3 100644
@@ -127,26 +127,27 @@ static int __devinit lpc_sch_probe(struct pci_dev *dev,
 
 	if (id->device == PCI_DEVICE_ID_INTEL_ITC_LPC) {
 		pci_read_config_dword(dev, WDTBASE, &base_addr_cfg);
-		if (!(base_addr_cfg & (1 << 31))) {
-			dev_err(&dev->dev, "Decode of the WDT I/O range disabled\n");
-			ret = -ENODEV;
-			goto out_dev;
+		if (base_addr_cfg & (1 << 31)) {
+			base_addr = (unsigned short)base_addr_cfg;
+			if (base_addr == 0) {
+				dev_err(&dev->dev,
+					"I/O space for WDT uninitialized\n");
+				ret = -ENODEV;
+				goto out_dev;
+			}
+
+			wdt_sch_resource.start = base_addr;
+			wdt_sch_resource.end = base_addr + WDT_IO_SIZE - 1;
+
+			for (i = 0; i < ARRAY_SIZE(tunnelcreek_cells); i++)
+				tunnelcreek_cells[i].id = id->device;
+
+			ret = mfd_add_devices(&dev->dev, 0, tunnelcreek_cells,
+				ARRAY_SIZE(tunnelcreek_cells), NULL, 0);
+		} else {
+			dev_warn(&dev->dev, "Decode of the WDT I/O range disabled, tunnelcreek watchdog timer maybe disabled by firmware or BIOS");
+			return 0;
 		}
-		base_addr = (unsigned short)base_addr_cfg;
-		if (base_addr == 0) {
-			dev_err(&dev->dev, "I/O space for WDT uninitialized\n");
-			ret = -ENODEV;
-			goto out_dev;
-		}
-
-		wdt_sch_resource.start = base_addr;
-		wdt_sch_resource.end = base_addr + WDT_IO_SIZE - 1;
-
-		for (i = 0; i < ARRAY_SIZE(tunnelcreek_cells); i++)
-			tunnelcreek_cells[i].id = id->device;
-
-		ret = mfd_add_devices(&dev->dev, 0, tunnelcreek_cells,
-			ARRAY_SIZE(tunnelcreek_cells), NULL, 0);
 	}
 
 	return ret;
Signature · 1 line
1.7.9
Acked-by on v1 1/1
#1 lore raw
Quoted 40 lines · Jean-François Dagenais

(Observed while running on Kontron nano-TT module.)

Certain BIOS/boot firmware may disable the tunnelcreek watchdog. Perhaps because the mainboard or module provides it's own watchdog mechanism. In these cases, lpc_sch should just go on and still provide the rest of the cells it declares (GPIO and SMBus). The same logic could be applied to the other resources, but I'll leave it to others to decide that.

This change makes the probe function tolerate the I/O range being disabled, but not if the base address inside the register is not configured.

Cc Alexander Stein <[email protected]>
Cc Denis Turischev <[email protected]>
---
 drivers/mfd/lpc_sch.c |   39 ++++++++++++++++++++-------------------
 1 files changed, 20 insertions(+), 19 deletions(-)
drivers/mfd/lpc_sch.c +10 -4
index ea1169b..6621cd3 100644
@@ -127,26 +127,27 @@ static int __devinit lpc_sch_probe(struct pci_dev *dev,
 
 	if (id->device == PCI_DEVICE_ID_INTEL_ITC_LPC) {
 		pci_read_config_dword(dev, WDTBASE, &base_addr_cfg);
-		if (!(base_addr_cfg & (1 << 31))) {
-			dev_err(&dev->dev, "Decode of the WDT I/O range disabled\n");
-			ret = -ENODEV;
-			goto out_dev;
+		if (base_addr_cfg & (1 << 31)) {
+			base_addr = (unsigned short)base_addr_cfg;
+			if (base_addr == 0) {
+				dev_err(&dev->dev,
+					"I/O space for WDT uninitialized\n");
+				ret = -ENODEV;
+				goto out_dev;
+			}
+
+			wdt_sch_resource.start = base_addr;

drivers/mfd/lpc_sch.c static int __devinit lpc_sch_probe(struct pci_dev *dev, · line 149

Quoted 10 lines
drivers/mfd/lpc_sch.c +10 -0
+			wdt_sch_resource.end = base_addr + WDT_IO_SIZE - 1;
+
+			for (i = 0; i < ARRAY_SIZE(tunnelcreek_cells); i++)
+				tunnelcreek_cells[i].id = id->device;
+
+			ret = mfd_add_devices(&dev->dev, 0, tunnelcreek_cells,
+				ARRAY_SIZE(tunnelcreek_cells), NULL, 0);
+		} else {
+			dev_warn(&dev->dev, "Decode of the WDT I/O range disabled, tunnelcreek watchdog timer maybe disabled by firmware or BIOS");
+			return 0;

Are you sure this is return is correct? I think as long as the watchdog is the last device in this probe it should be fine. But not if any other device is added below later.

Quoted 10 lines
drivers/mfd/lpc_sch.c +0 -8
 		}
-		base_addr = (unsigned short)base_addr_cfg;
-		if (base_addr == 0) {
-			dev_err(&dev->dev, "I/O space for WDT uninitialized\n");
-			ret = -ENODEV;
-			goto out_dev;
-		}
-
-		wdt_sch_resource.start = base_addr;

drivers/mfd/lpc_sch.c static int __devinit lpc_sch_probe(struct pci_dev *dev, · line 153

Quoted 10 lines
drivers/mfd/lpc_sch.c +0 -7
-		wdt_sch_resource.end = base_addr + WDT_IO_SIZE - 1;
-
-		for (i = 0; i < ARRAY_SIZE(tunnelcreek_cells); i++)
-			tunnelcreek_cells[i].id = id->device;
-
-		ret = mfd_add_devices(&dev->dev, 0, tunnelcreek_cells,
-			ARRAY_SIZE(tunnelcreek_cells), NULL, 0);
 	}
 
 	return ret;

Despite that:

Regards,
Alexander

Signature · 12 lines
Dipl.-Inf. Alexander Stein

SYS TEC electronic GmbH
August-Bebel-Str. 29
D-07973 Greiz

Tel: +49-3661-6279-0, Fax: +49-3661-6279-99
eMail:    [email protected]
Internet: http://www.systec-electronic.com

Managing Director: Dipl.-Phys. Siegmar Schmidt
Commercial registry: Amtsgericht Jena, HRB 205563
#2 lore raw
Quoted 46 lines · Alexander Stein
Quoted 45 lines · Jean-François Dagenais

(Observed while running on Kontron nano-TT module.)

Certain BIOS/boot firmware may disable the tunnelcreek watchdog. Perhaps because the mainboard or module provides it's own watchdog mechanism. In these cases, lpc_sch should just go on and still provide the rest of the cells it declares (GPIO and SMBus). The same logic could be applied to the other resources, but I'll leave it to others to decide that.

This change makes the probe function tolerate the I/O range being disabled, but not if the base address inside the register is not configured.

Cc Alexander Stein <[email protected]>
Cc Denis Turischev <[email protected]>

---
drivers/mfd/lpc_sch.c | 39 ++++++++++++++++++++-------------------

1 files changed, 20 insertions(+), 19 deletions(-)
drivers/mfd/lpc_sch.c +15 -4
index ea1169b..6621cd3 100644
@@ -127,26 +127,27 @@ static int __devinit lpc_sch_probe(struct pci_dev *dev,
 
 	if (id->device == PCI_DEVICE_ID_INTEL_ITC_LPC) {
 		pci_read_config_dword(dev, WDTBASE, &base_addr_cfg);
-		if (!(base_addr_cfg & (1 << 31))) {
-			dev_err(&dev->dev, "Decode of the WDT I/O range disabled\n");
-			ret = -ENODEV;
-			goto out_dev;
+		if (base_addr_cfg & (1 << 31)) {
+			base_addr = (unsigned short)base_addr_cfg;
+			if (base_addr == 0) {
+				dev_err(&dev->dev,
+					"I/O space for WDT uninitialized\n");
+				ret = -ENODEV;
+				goto out_dev;
+			}
+
+			wdt_sch_resource.start = base_addr;
+			wdt_sch_resource.end = base_addr + WDT_IO_SIZE - 1;
+
+			for (i = 0; i < ARRAY_SIZE(tunnelcreek_cells); i++)
+				tunnelcreek_cells[i].id = id->device;
+
Quoted 8 lines

drivers/mfd/lpc_sch.c static int __devinit lpc_sch_probe(struct pci_dev *dev, · line 149

Quoted 5 lines
drivers/mfd/lpc_sch.c +5 -0
+			ret = mfd_add_devices(&dev->dev, 0, tunnelcreek_cells,
+				ARRAY_SIZE(tunnelcreek_cells), NULL, 0);
+		} else {
+			dev_warn(&dev->dev, "Decode of the WDT I/O range disabled, tunnelcreek watchdog timer maybe disabled by firmware or BIOS");
+			return 0;

Are you sure this is return is correct? I think as long as the watchdog is the last device in this probe it should be fine. But not if any other device is added below later.

It is the last one, and yes, the next developers will have to keep it that way, or change the behaviour accordingly.

Quoted 19 lines
Quoted 19 lines
drivers/mfd/lpc_sch.c +0 -15
 		}
-		base_addr = (unsigned short)base_addr_cfg;
-		if (base_addr == 0) {
-			dev_err(&dev->dev, "I/O space for WDT uninitialized\n");
-			ret = -ENODEV;
-			goto out_dev;
-		}
-
-		wdt_sch_resource.start = base_addr;
-		wdt_sch_resource.end = base_addr + WDT_IO_SIZE - 1;
-
-		for (i = 0; i < ARRAY_SIZE(tunnelcreek_cells); i++)
-			tunnelcreek_cells[i].id = id->device;
-
-		ret = mfd_add_devices(&dev->dev, 0, tunnelcreek_cells,
-			ARRAY_SIZE(tunnelcreek_cells), NULL, 0);
 	}
 
Quoted 5 lines

drivers/mfd/lpc_sch.c static int __devinit lpc_sch_probe(struct pci_dev *dev, · line 153

Quoted 2 lines
drivers/mfd/lpc_sch.c +0 -0
 	return ret;

Despite that:

Thanks.

Quoted 16 lines

Regards,
Alexander

Signature · 12 lines
Dipl.-Inf. Alexander Stein

SYS TEC electronic GmbH
August-Bebel-Str. 29
D-07973 Greiz

Tel: +49-3661-6279-0, Fax: +49-3661-6279-99
eMail:    [email protected]
Internet: http://www.systec-electronic.com

Managing Director: Dipl.-Phys. Siegmar Schmidt
Commercial registry: Amtsgericht Jena, HRB 205563