[PATCH net-next v2 1/1] net: stmmac: Add support for external trigger timestamping

Jakub Kicinski kuba at kernel.org
Sat Apr 10 01:50:04 BST 2021


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.

> +		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?




More information about the linux-arm-kernel mailing list