Skip to content

Commit

Permalink
ptp_qoriq: check valid status before reading extts fifo
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Yangbo Lu authored and David S. Miller committed Dec 16, 2019
1 parent 0e62719 commit 10bc877
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/ptp/ptp_qoriq.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ static int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index,
struct ptp_clock_event event;
void __iomem *reg_etts_l;
void __iomem *reg_etts_h;
u32 valid, stat, lo, hi;
u32 valid, lo, hi;

switch (index) {
case 0:
Expand All @@ -101,6 +101,10 @@ static int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index,
event.type = PTP_CLOCK_EXTTS;
event.index = index;

if (ptp_qoriq->extts_fifo_support)
if (!(ptp_qoriq->read(&regs->ctrl_regs->tmr_stat) & valid))
return 0;

do {
lo = ptp_qoriq->read(reg_etts_l);
hi = ptp_qoriq->read(reg_etts_h);
Expand All @@ -111,8 +115,9 @@ static int extts_clean_up(struct ptp_qoriq *ptp_qoriq, int index,
ptp_clock_event(ptp_qoriq->clock, &event);
}

stat = ptp_qoriq->read(&regs->ctrl_regs->tmr_stat);
} while (ptp_qoriq->extts_fifo_support && (stat & valid));
if (!ptp_qoriq->extts_fifo_support)
break;
} while (ptp_qoriq->read(&regs->ctrl_regs->tmr_stat) & valid);

return 0;
}
Expand Down

0 comments on commit 10bc877

Please sign in to comment.