Re: [PATCH net-next v2 1/1] net: stmmac: Add support for external trigger timestamping
From: Wong Vee Khee
Date: Sat Apr 10 2021 - 09:16:20 EST
On Fri, Apr 09, 2021 at 05:50:04PM -0700, Jakub Kicinski wrote:
> Other than the minor nit below LGTM. Let's give Richard one more day.
>
> On Thu, 8 Apr 2021 01:04:42 +0800 Wong Vee Khee wrote:
> > +static void timestamp_interrupt(struct stmmac_priv *priv)
> > +{
> > + struct ptp_clock_event event;
> > + unsigned long flags;
> > + u32 num_snapshot;
> > + u32 ts_status;
> > + u32 tsync_int;
> > + u64 ptp_time;
> > + int i;
> > +
> > + tsync_int = readl(priv->ioaddr + GMAC_INT_STATUS) & GMAC_INT_TSIE;
> > +
> > + if (!tsync_int)
> > + return;
> > +
> > + /* Read timestamp status to clear interrupt from either external
> > + * timestamp or start/end of PPS.
> > + */
> > + ts_status = readl(priv->ioaddr + GMAC_TIMESTAMP_STATUS);
> > +
> > + if (priv->plat->ext_snapshot_en) {
>
> Are you intending to add more code after this if? Otherwise you could
> flip the condition and return early instead of having the extra level
> of indentation.
>
Thanks fo the suggestion.
There's no plan to add more code after this as per STMMAC features that
required this interrupt. I will flip the condition.
> > + num_snapshot = (ts_status & GMAC_TIMESTAMP_ATSNS_MASK) >>
> > + GMAC_TIMESTAMP_ATSNS_SHIFT;
> > +
> > + for (i = 0; i < num_snapshot; i++) {
> > + spin_lock_irqsave(&priv->ptp_lock, flags);
> > + get_ptptime(priv->ptpaddr, &ptp_time);
> > + spin_unlock_irqrestore(&priv->ptp_lock, flags);
> > + event.type = PTP_CLOCK_EXTTS;
> > + event.index = 0;
> > + event.timestamp = ptp_time;
> > + ptp_clock_event(priv->ptp_clock, &event);
> > + }
> > + }
> > +}
>
> Not really related to this patch but how does stmmac set IRQF_SHARED
> and yet not track if it indeed generated the interrupt? Isn't that
> against the rules?
>
Good point! Thanks for pointing that out. I looked at how STMMAC
interrupt handlers are coded, and indeed there are no tracking. Will
work on that and send as a seperate patch in near future.