hc
2023-11-06 e3e12f52b214121840b44c91de5b3e5af5d3eb84
kernel/drivers/net/ethernet/stmicro/stmmac/stmmac_hwtstamp.c
....@@ -159,15 +159,20 @@
159159
160160 static void get_systime(void __iomem *ioaddr, u64 *systime)
161161 {
162
- u64 ns;
162
+ u64 ns, sec0, sec1;
163163
164
- /* Get the TSSS value */
165
- ns = readl(ioaddr + PTP_STNSR);
166
- /* Get the TSS and convert sec time value to nanosecond */
167
- ns += readl(ioaddr + PTP_STSR) * 1000000000ULL;
164
+ /* Get the TSS value */
165
+ sec1 = readl_relaxed(ioaddr + PTP_STSR);
166
+ do {
167
+ sec0 = sec1;
168
+ /* Get the TSSS value */
169
+ ns = readl_relaxed(ioaddr + PTP_STNSR);
170
+ /* Get the TSS value */
171
+ sec1 = readl_relaxed(ioaddr + PTP_STSR);
172
+ } while (sec0 != sec1);
168173
169174 if (systime)
170
- *systime = ns;
175
+ *systime = ns + (sec1 * 1000000000ULL);
171176 }
172177
173178 const struct stmmac_hwtimestamp stmmac_ptp = {