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-increase-clk_ptp_ref-rate'

Andrew Halaney says:

====================
net: stmmac: Increase clk_ptp_ref rate

This series aims to increase the clk_ptp_ref rate to get the best
possible PTP timestamping resolution possible. Some modified disclosure
about my development/testing process from the RFC/RFT v1 follows.

Disclosure: I don't know much about PTP beyond what you can google in an
afternoon, don't have access to documentation about the stmmac IP,
and have only tested that (based on code comments and git commit
history) the programming of the subsecond register (and the clock rate)
makes more sense with these changes. Qualcomm has tested a similar
change offlist, verifying PTP more formally as I understand it.

The last version was an RFC/RFT, but I didn't get a lot of confirmation
that doing patch 3 in that series (essentially setting clk_ptp_ref to
whatever its max value is) for the whole stmmac ecosystem was a safe
idea. So I am erring on the side of caution and doing this for the
Qualcomm platform only. See v1 for an approach that would apply to
all stmmac platform drivers with clk_ptp_ref.

v1: https://lore.kernel.org/netdev/20230711205732.364954-1-ahalaney@redhat.com/
====================

Link: https://lore.kernel.org/r/20230725211853.895832-2-ahalaney@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+22 -3
+1 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-intel.c
··· 257 257 /* Program PTP Clock Frequency for different variant of 258 258 * Intel mGBE that has slightly different GPO mapping 259 259 */ 260 - static void intel_mgbe_ptp_clk_freq_config(void *npriv) 260 + static void intel_mgbe_ptp_clk_freq_config(struct stmmac_priv *priv) 261 261 { 262 - struct stmmac_priv *priv = (struct stmmac_priv *)npriv; 263 262 struct intel_priv_data *intel_priv; 264 263 u32 gpio_value; 265 264
+18
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
··· 694 694 ethqos_clks_config(data, false); 695 695 } 696 696 697 + static void ethqos_ptp_clk_freq_config(struct stmmac_priv *priv) 698 + { 699 + struct plat_stmmacenet_data *plat_dat = priv->plat; 700 + int err; 701 + 702 + if (!plat_dat->clk_ptp_ref) 703 + return; 704 + 705 + /* Max the PTP ref clock out to get the best resolution possible */ 706 + err = clk_set_rate(plat_dat->clk_ptp_ref, ULONG_MAX); 707 + if (err) 708 + netdev_err(priv->dev, "Failed to max out clk_ptp_ref: %d\n", err); 709 + plat_dat->clk_ptp_rate = clk_get_rate(plat_dat->clk_ptp_ref); 710 + 711 + netdev_dbg(priv->dev, "PTP rate %d\n", plat_dat->clk_ptp_rate); 712 + } 713 + 697 714 static int qcom_ethqos_probe(struct platform_device *pdev) 698 715 { 699 716 struct device_node *np = pdev->dev.of_node; ··· 796 779 plat_dat->bsp_priv = ethqos; 797 780 plat_dat->fix_mac_speed = ethqos_fix_mac_speed; 798 781 plat_dat->dump_debug_regs = rgmii_dump; 782 + plat_dat->ptp_clk_freq_config = ethqos_ptp_clk_freq_config; 799 783 plat_dat->has_gmac4 = 1; 800 784 if (ethqos->has_emac_ge_3) 801 785 plat_dat->dwmac4_addrs = &data->dwmac4_addrs;
+3 -1
include/linux/stmmac.h
··· 76 76 | DMA_AXI_BLEN_32 | DMA_AXI_BLEN_64 \ 77 77 | DMA_AXI_BLEN_128 | DMA_AXI_BLEN_256) 78 78 79 + struct stmmac_priv; 80 + 79 81 /* Platfrom data for platform device structure's platform_data field */ 80 82 81 83 struct stmmac_mdio_bus_data { ··· 260 258 int (*serdes_powerup)(struct net_device *ndev, void *priv); 261 259 void (*serdes_powerdown)(struct net_device *ndev, void *priv); 262 260 void (*speed_mode_2500)(struct net_device *ndev, void *priv); 263 - void (*ptp_clk_freq_config)(void *priv); 261 + void (*ptp_clk_freq_config)(struct stmmac_priv *priv); 264 262 int (*init)(struct platform_device *pdev, void *priv); 265 263 void (*exit)(struct platform_device *pdev, void *priv); 266 264 struct mac_device_info *(*setup)(void *priv);