Skip to contentSkip to conversation

bcma: use udelay for short waits

PATCH In review Rafał Miłecki 2 participants 4 messages Sep 20, 2012 Broadcom specific amba driver (bcma)

lore
Share & tools
lore

Rafał Miłecki

author maintainer
#0 lore raw

PATCH 1/1 bcma: use udelay for short waits

msleep shouldn't be used for less than 20ms

---
 drivers/bcma/driver_pci.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/bcma/driver_pci.c +3 -3
index c32ebd5..e78e6a8 100644
@@ -51,7 +51,7 @@ static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
 		v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
 		if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
 			break;
-		msleep(1);
+		udelay(1000);
 	}
 }
 
@@ -92,7 +92,7 @@ static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address)
 			ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA);
 			break;
 		}
-		msleep(1);
+		udelay(1000);
 	}
 	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
 	return ret;
@@ -132,7 +132,7 @@ static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device,
 		v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
 		if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
 			break;
-		msleep(1);
+		udelay(1000);
 	}
 	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
 }
Signature · 1 line
1.7.7
#1 lore raw
Quoted 31 lines · Rafał Miłecki

msleep shouldn't be used for less than 20ms

---
 drivers/bcma/driver_pci.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/bcma/driver_pci.c +2 -2
index c32ebd5..e78e6a8 100644
@@ -51,7 +51,7 @@ static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
 		v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
 		if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
 			break;
-		msleep(1);
+		udelay(1000);
 	}
 }
 
@@ -92,7 +92,7 @@ static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address)
 			ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA);
 			break;
 		}
-		msleep(1);
+		udelay(1000);
 	}
 	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
 	return ret;

drivers/bcma/driver_pci.c static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device, · line 138

Quoted 8 lines
drivers/bcma/driver_pci.c +1 -1
@@ -132,7 +132,7 @@ static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device,
 		v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
 		if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
 			break;
-		msleep(1);
+		udelay(1000);
 	}
 	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
 }

Using msleep(1) here is not correct, but I do not know if udelay(1000) is better. The BCM4706 SoC or more the kernel code you are using seams to have problems with sleeping, at least that is my current assumption. when I add an msleep(1) somewhere into the code the exception stops there without an exception from the CPU.

According to Documentation/timers/timers-howto.txt we should use usleep_range for values from 10us to 20ms, but that also causes the same problem as msleep() on this SoC.

Hauke

#2 lore raw
Quoted 47 lines · Hauke Mehrtens
Quoted 31 lines · Rafał Miłecki

msleep shouldn't be used for less than 20ms

---
 drivers/bcma/driver_pci.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/bcma/driver_pci.c +2 -2
index c32ebd5..e78e6a8 100644
@@ -51,7 +51,7 @@ static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
 		v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
 		if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
 			break;
-		msleep(1);
+		udelay(1000);
 	}
 }
 
@@ -92,7 +92,7 @@ static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address)
 			ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA);
 			break;
 		}
-		msleep(1);
+		udelay(1000);
 	}
 	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
 	return ret;

drivers/bcma/driver_pci.c static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device, · line 138

Quoted 8 lines
drivers/bcma/driver_pci.c +1 -1
@@ -132,7 +132,7 @@ static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device,
 		v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
 		if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
 			break;
-		msleep(1);
+		udelay(1000);
 	}
 	pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
 }

Using msleep(1) here is not correct, but I do not know if udelay(1000) is better. The BCM4706 SoC or more the kernel code you are using seams to have problems with sleeping, at least that is my current assumption. when I add an msleep(1) somewhere into the code the exception stops there without an exception from the CPU.

Quoted 5 lines

According to Documentation/timers/timers-howto.txt we should use usleep_range for values from 10us to 20ms, but that also causes the same problem as msleep() on this SoC.

Hauke

The BCM4706 SoC has problems with the Mips wait instruction and that is not activated in the Broadcom SDK, but in the OpenWrt kernel. I deactivated it [0] in my kernel and now the device boots without this patch for bcma. The patch to deactivate the mips wait instruction can not be mainlined, like it is now.

Please drop this patch and use usleep_range(), that should work now.

Hauke

[0]:
https://dev.openwrt.org/browser/trunk/target/linux/brcm47xx/patches-3.3/170-fix-74k-cpu.patch?rev=33496

author maintainer
#3 lore raw

2012/9/20 Hauke Mehrtens <[email protected]>:

Quoted 54 lines · Hauke Mehrtens
Quoted 47 lines · Rafał Miłecki
Quoted 31 lines

msleep shouldn't be used for less than 20ms

---
 drivers/bcma/driver_pci.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/bcma/driver_pci.c +2 -2
index c32ebd5..e78e6a8 100644
@@ -51,7 +51,7 @@ static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
             v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
             if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
                     break;
-            msleep(1);
+            udelay(1000);
     }
 }
 
@@ -92,7 +92,7 @@ static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address)
                     ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA);
                     break;
             }
-            msleep(1);
+            udelay(1000);
     }
     pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
     return ret;

drivers/bcma/driver_pci.c static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device, · line 138

Quoted 8 lines
drivers/bcma/driver_pci.c +1 -1
@@ -132,7 +132,7 @@ static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device,
             v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
             if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
                     break;
-            msleep(1);
+            udelay(1000);
     }
     pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
 }

Using msleep(1) here is not correct, but I do not know if udelay(1000) is better. The BCM4706 SoC or more the kernel code you are using seams to have problems with sleeping, at least that is my current assumption. when I add an msleep(1) somewhere into the code the exception stops there without an exception from the CPU.

Quoted 5 lines

According to Documentation/timers/timers-howto.txt we should use usleep_range for values from 10us to 20ms, but that also causes the same problem as msleep() on this SoC.

Hauke

Quoted 7 lines

The BCM4706 SoC has problems with the Mips wait instruction and that is not activated in the Broadcom SDK, but in the OpenWrt kernel. I deactivated it [0] in my kernel and now the device boots without this patch for bcma. The patch to deactivate the mips wait instruction can not be mainlined, like it is now.

Please drop this patch and use usleep_range(), that should work now.

Any suggestion about values? 900, 1100? 1000, 1200? 1000, 1500?

Signature · 1 line
Rafał