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-enetc-improve-the-interface-for-obtaining-phc_index'

Wei Fang says:

====================
net: enetc: improve the interface for obtaining phc_index

The first patch is to fix the issue that a sleeping function is called
in the context of rcu_read_lock(). The second patch is to use the generic
API instead of the custom API to get phc_index. In addition, the second
patch depends on the first patch to work.

v1: https://lore.kernel.org/20250918074454.1742328-1-wei.fang@nxp.com
====================

Link: https://patch.msgid.link/20250919084509.1846513-1-wei.fang@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+12 -25
-3
drivers/net/ethernet/freescale/enetc/enetc.h
··· 493 493 494 494 #define ENETC_CBDR_TIMEOUT 1000 /* usecs */ 495 495 496 - /* PTP driver exports */ 497 - extern int enetc_phc_index; 498 - 499 496 /* SI common */ 500 497 u32 enetc_port_mac_rd(struct enetc_si *si, u32 reg); 501 498 void enetc_port_mac_wr(struct enetc_si *si, u32 reg, u32 val);
+12 -17
drivers/net/ethernet/freescale/enetc/enetc_ethtool.c
··· 880 880 return 0; 881 881 } 882 882 883 - static int enetc4_get_phc_index_by_pdev(struct enetc_si *si) 883 + static int enetc_get_phc_index_by_pdev(struct enetc_si *si) 884 884 { 885 885 struct pci_bus *bus = si->pdev->bus; 886 886 struct pci_dev *timer_pdev; ··· 888 888 int phc_index; 889 889 890 890 switch (si->revision) { 891 + case ENETC_REV_1_0: 892 + devfn = PCI_DEVFN(0, 4); 893 + break; 891 894 case ENETC_REV_4_1: 892 895 devfn = PCI_DEVFN(24, 0); 893 896 break; ··· 898 895 return -1; 899 896 } 900 897 901 - timer_pdev = pci_get_slot(bus, devfn); 898 + timer_pdev = pci_get_domain_bus_and_slot(pci_domain_nr(bus), 899 + bus->number, devfn); 902 900 if (!timer_pdev) 903 901 return -1; 904 902 ··· 909 905 return phc_index; 910 906 } 911 907 912 - static int enetc4_get_phc_index(struct enetc_si *si) 908 + static int enetc_get_phc_index(struct enetc_si *si) 913 909 { 914 910 struct device_node *np = si->pdev->dev.of_node; 915 911 struct device_node *timer_np; 916 912 int phc_index; 917 913 918 914 if (!np) 919 - return enetc4_get_phc_index_by_pdev(si); 915 + return enetc_get_phc_index_by_pdev(si); 920 916 921 917 timer_np = of_parse_phandle(np, "ptp-timer", 0); 922 918 if (!timer_np) 923 - return enetc4_get_phc_index_by_pdev(si); 919 + return enetc_get_phc_index_by_pdev(si); 924 920 925 921 phc_index = ptp_clock_index_by_of_node(timer_np); 926 922 of_node_put(timer_np); ··· 953 949 { 954 950 struct enetc_ndev_priv *priv = netdev_priv(ndev); 955 951 struct enetc_si *si = priv->si; 956 - int *phc_idx; 957 952 958 953 if (!enetc_ptp_clock_is_enabled(si)) 959 954 goto timestamp_tx_sw; 960 955 961 - if (is_enetc_rev1(si)) { 962 - phc_idx = symbol_get(enetc_phc_index); 963 - if (phc_idx) { 964 - info->phc_index = *phc_idx; 965 - symbol_put(enetc_phc_index); 966 - } 967 - } else { 968 - info->phc_index = enetc4_get_phc_index(si); 969 - if (info->phc_index < 0) 970 - goto timestamp_tx_sw; 971 - } 956 + info->phc_index = enetc_get_phc_index(si); 957 + if (info->phc_index < 0) 958 + goto timestamp_tx_sw; 972 959 973 960 enetc_get_ts_generic_info(ndev, info); 974 961
-5
drivers/net/ethernet/freescale/enetc/enetc_ptp.c
··· 7 7 8 8 #include "enetc.h" 9 9 10 - int enetc_phc_index = -1; 11 - EXPORT_SYMBOL_GPL(enetc_phc_index); 12 - 13 10 static struct ptp_clock_info enetc_ptp_caps = { 14 11 .owner = THIS_MODULE, 15 12 .name = "ENETC PTP clock", ··· 89 92 if (err) 90 93 goto err_no_clock; 91 94 92 - enetc_phc_index = ptp_qoriq->phc_index; 93 95 pci_set_drvdata(pdev, ptp_qoriq); 94 96 95 97 return 0; ··· 114 118 { 115 119 struct ptp_qoriq *ptp_qoriq = pci_get_drvdata(pdev); 116 120 117 - enetc_phc_index = -1; 118 121 ptp_qoriq_free(ptp_qoriq); 119 122 pci_free_irq_vectors(pdev); 120 123 kfree(ptp_qoriq);