[dpdk-stable] [PATCH 18.11 1/4] kni: fix gcc 10 ethtool build error

Kevin Traynor ktraynor at redhat.com
Tue Jun 16 15:51:34 CEST 2020


gcc 10 is smart enough to see that the usec_interval passed into
e1000_phy_has_link_generic() is sometimes a large constant (100000)
and under some conditions it may be passed directly into udelay().

udelay generates an error when it gets these large values by inserting
an undefined function:

if (__builtin_constant_p(n)) {                          \
        if ((n) / 20000 >= 1)                           \
                 __bad_udelay();                        \

And hence we see the error in the form of:
ERROR: "__bad_udelay"
[/root/dpdk/build/kernel/linux/kni/rte_kni.ko] undefined!

Fix this by using similar code to elsewhere in the function whereby
msec_delay_irq() is used when usec value >= 1000.

Signed-off-by: Kevin Traynor <ktraynor at redhat.com>
---
 kernel/linux/kni/ethtool/igb/e1000_phy.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/kernel/linux/kni/ethtool/igb/e1000_phy.c b/kernel/linux/kni/ethtool/igb/e1000_phy.c
index 5257b9141e..b4d363ba28 100644
--- a/kernel/linux/kni/ethtool/igb/e1000_phy.c
+++ b/kernel/linux/kni/ethtool/igb/e1000_phy.c
@@ -2257,10 +2257,14 @@ s32 e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
 		 */
 		ret_val = hw->phy.ops.read_reg(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.
 			 */
-			usec_delay(usec_interval);
+			if (usec_interval >= 1000)
+				msec_delay_irq(usec_interval/1000);
+			else
+				usec_delay(usec_interval);
+		}
 		ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status);
 		if (ret_val)
-- 
2.21.3



More information about the stable mailing list