Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'net-stmmac-correctly-populate-ptp_clock_ops-getcrosststamp'

Russell King says:

====================
net: stmmac: correctly populate ptp_clock_ops.getcrosststamp

While reviewing code in the stmmac PTP driver, I noticed that the
getcrosststamp() method is always populated, irrespective of whether
it is implemented or not by the stmmac platform specific glue layer.

Where a platform specific glue layer does not implement it, the core
stmmac driver code returns -EOPNOTSUPP. However, the PTP clock core
code uses the presence of the method in ptp_clock_ops to determine
whether this facility should be advertised to userspace (see
ptp_clock_getcaps()).

Moreover, the only platform glue that implements this method is the
Intel glue, and for it not to return -EOPNOTSUPP, the CPU has to
support X86_FEATURE_ART.

This series updates the core stmmac code to only provide the
getcrosststamp() method in ptp_clock_ops when the platform glue code
provides an implementation, and then updates the Intel glue code to
only provide its implementation when the CPU has the necessary
X86_FEATURE_ART feature.
====================

Link: https://patch.msgid.link/aLhJ8Gzb0T2qpXBE@shell.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+7 -10
+3 -4
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
··· 371 371 u32 acr_value; 372 372 int i; 373 373 374 - if (!boot_cpu_has(X86_FEATURE_ART)) 375 - return -EOPNOTSUPP; 376 - 377 374 intel_priv = priv->plat->bsp_priv; 378 375 379 376 /* Both internal crosstimestamping and external triggered event ··· 752 755 753 756 plat->int_snapshot_num = AUX_SNAPSHOT1; 754 757 755 - plat->crosststamp = intel_crosststamp; 758 + if (boot_cpu_has(X86_FEATURE_ART)) 759 + plat->crosststamp = intel_crosststamp; 760 + 756 761 plat->flags &= ~STMMAC_FLAG_INT_SNAPSHOT_EN; 757 762 758 763 /* Setup MSI vector offset specific to Intel mGbE controller */
+4 -6
drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
··· 279 279 { 280 280 struct stmmac_priv *priv = (struct stmmac_priv *)ctx; 281 281 282 - if (priv->plat->crosststamp) 283 - return priv->plat->crosststamp(device, system, ctx); 284 - else 285 - return -EOPNOTSUPP; 282 + return priv->plat->crosststamp(device, system, ctx); 286 283 } 287 284 288 285 static int stmmac_getcrosststamp(struct ptp_clock_info *ptp, ··· 307 310 .gettime64 = stmmac_get_time, 308 311 .settime64 = stmmac_set_time, 309 312 .enable = stmmac_enable, 310 - .getcrosststamp = stmmac_getcrosststamp, 311 313 }; 312 314 313 315 /* structure describing a PTP hardware clock */ ··· 324 328 .gettime64 = stmmac_get_time, 325 329 .settime64 = stmmac_set_time, 326 330 .enable = dwmac1000_ptp_enable, 327 - .getcrosststamp = stmmac_getcrosststamp, 328 331 }; 329 332 330 333 /** ··· 358 363 359 364 if (priv->plat->ptp_max_adj) 360 365 priv->ptp_clock_ops.max_adj = priv->plat->ptp_max_adj; 366 + 367 + if (priv->plat->crosststamp) 368 + priv->ptp_clock_ops.getcrosststamp = stmmac_getcrosststamp; 361 369 362 370 rwlock_init(&priv->ptp_lock); 363 371 mutex_init(&priv->aux_ts_lock);