Skip to content

Commit 10bc877

Browse files
yangbolu1991davem330
authored andcommitted
ptp_qoriq: check valid status before reading extts fifo
For PTP timer supporting external trigger timestamp FIFO, there is a valid bit in TMR_STAT register indicating the timestamp is available. For PTP timer without FIFO, there is not TMR_STAT register. This patch is to check the valid bit for the FIFO before reading timestamp, and to avoid operating TMR_STAT register for PTP timer without the FIFO. Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 0e62719 commit 10bc877

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎drivers/ptp/ptp_qoriq.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index,
8181
struct ptp_clock_event event;
8282
void __iomem *reg_etts_l;
8383
void __iomem *reg_etts_h;
84-
u32 valid, stat, lo, hi;
84+
u32 valid, lo, hi;
8585

8686
switch (index) {
8787
case 0:
@@ -101,6 +101,10 @@ static int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index,
101101
event.type = PTP_CLOCK_EXTTS;
102102
event.index = index;
103103

104+
if (ptp_qoriq->extts_fifo_support)
105+
if (!(ptp_qoriq->read(&regs->ctrl_regs->tmr_stat) & valid))
106+
return 0;
107+
104108
do {
105109
lo = ptp_qoriq->read(reg_etts_l);
106110
hi = ptp_qoriq->read(reg_etts_h);
@@ -111,8 +115,9 @@ static int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index,
111115
ptp_clock_event(ptp_qoriq->clock, &event);
112116
}
113117

114-
stat = ptp_qoriq->read(&regs->ctrl_regs->tmr_stat);
115-
} while (ptp_qoriq->extts_fifo_support && (stat & valid));
118+
if (!ptp_qoriq->extts_fifo_support)
119+
break;
120+
} while (ptp_qoriq->read(&regs->ctrl_regs->tmr_stat) & valid);
116121

117122
return 0;
118123
}

0 commit comments

Comments
 (0)