Skip to contentSkip to conversation

Fix undefined __bad_udelay() in e1000e driver

PATCH In review Matúš Olekšák 2 participants 2 messages Mar 16, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix undefined __bad_udelay() in e1000e driver

udelay() should not be used with values over 20 000. But the first calling of udelay() in e1000e_phy_has_link_generic(), does not check delay value. It causes compile-time trap __bad_udelay() to occur. Bug is present on all Xenomai versions since commit 106ffba7b55d506143966ff16158ee79b0007336.

---
 kernel/drivers/net/drivers/e1000e/phy.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/drivers/net/drivers/e1000e/phy.c +6 -2
index 66ae3891a..9ec7835bc 100644
@@ -1787,13 +1787,17 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
 		 * it across the board.
 		 */
 		ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
-		if (ret_val)
+		if (ret_val) {
 			/*
 			 * If the first read fails, another entity may have
 			 * ownership of the resources, wait and try again to
 			 * see if they have relinquished the resources yet.
 			 */
-			udelay(usec_interval);
+			if (usec_interval >= 1000)
+				mdelay(usec_interval/1000);
+			else
+				udelay(usec_interval);
+		}
 		ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
 		if (ret_val)
 			break;
Signature · 1 line
2.30.2
#1 lore raw
Quoted 1 line · Matúš Olekšák via Xenomai

udelay() should not be used with values over 20 000. But the first calling of udelay() in e1000e_phy_has_link_generic(), does not check delay value. It causes compile-time trap __bad_udelay() to occur. Bug is present on all Xenomai versions since commit 106ffba7b55d506143966ff16158ee79b0007336.

Already merged into next, see
https://source.denx.de/Xenomai/xenomai/-/commit/7857a1b154c327d68c5a5e5deedd908f6e0095a1

I'll push that to stable branches as well.

Thanks nevertheless!
Jan

Quoted 31 lines
---
 kernel/drivers/net/drivers/e1000e/phy.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
kernel/drivers/net/drivers/e1000e/phy.c +6 -2
index 66ae3891a..9ec7835bc 100644
@@ -1787,13 +1787,17 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
 		 * it across the board.
 		 */
 		ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
-		if (ret_val)
+		if (ret_val) {
 			/*
 			 * If the first read fails, another entity may have
 			 * ownership of the resources, wait and try again to
 			 * see if they have relinquished the resources yet.
 			 */
-			udelay(usec_interval);
+			if (usec_interval >= 1000)
+				mdelay(usec_interval/1000);
+			else
+				udelay(usec_interval);
+		}
 		ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status);
 		if (ret_val)
 			break;
Signature · 2 lines
Siemens AG, T RDA IOT
Corporate Competence Center Embedded Linux