Skip to content

Commit 9018ff5

Browse files
tlendackydavem330
authored andcommitted
amd-xgbe: Prevent looping forever if timestamp update fails
Just to be on the safe side, should the update of the timestamp registers not complete, issue a warning rather than looping forever waiting for the update to complete. Signed-off-by: Tom Lendacky <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 93845d5 commit 9018ff5

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/net/ethernet/amd/xgbe/xgbe-dev.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,26 +1497,37 @@ static void xgbe_rx_desc_init(struct xgbe_channel *channel)
14971497
static void xgbe_update_tstamp_addend(struct xgbe_prv_data *pdata,
14981498
unsigned int addend)
14991499
{
1500+
unsigned int count = 10000;
1501+
15001502
/* Set the addend register value and tell the device */
15011503
XGMAC_IOWRITE(pdata, MAC_TSAR, addend);
15021504
XGMAC_IOWRITE_BITS(pdata, MAC_TSCR, TSADDREG, 1);
15031505

15041506
/* Wait for addend update to complete */
1505-
while (XGMAC_IOREAD_BITS(pdata, MAC_TSCR, TSADDREG))
1507+
while (--count && XGMAC_IOREAD_BITS(pdata, MAC_TSCR, TSADDREG))
15061508
udelay(5);
1509+
1510+
if (!count)
1511+
netdev_err(pdata->netdev,
1512+
"timed out updating timestamp addend register\n");
15071513
}
15081514

15091515
static void xgbe_set_tstamp_time(struct xgbe_prv_data *pdata, unsigned int sec,
15101516
unsigned int nsec)
15111517
{
1518+
unsigned int count = 10000;
1519+
15121520
/* Set the time values and tell the device */
15131521
XGMAC_IOWRITE(pdata, MAC_STSUR, sec);
15141522
XGMAC_IOWRITE(pdata, MAC_STNUR, nsec);
15151523
XGMAC_IOWRITE_BITS(pdata, MAC_TSCR, TSINIT, 1);
15161524

15171525
/* Wait for time update to complete */
1518-
while (XGMAC_IOREAD_BITS(pdata, MAC_TSCR, TSINIT))
1526+
while (--count && XGMAC_IOREAD_BITS(pdata, MAC_TSCR, TSINIT))
15191527
udelay(5);
1528+
1529+
if (!count)
1530+
netdev_err(pdata->netdev, "timed out initializing timestamp\n");
15201531
}
15211532

15221533
static u64 xgbe_get_tstamp_time(struct xgbe_prv_data *pdata)

0 commit comments

Comments
 (0)