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.

net: dsa: microchip: Do not execute PTP driver code for unsupported switches

The PTP driver code only works for certain KSZ switches like KSZ9477,
KSZ9567, LAN937X and their varieties. This code is enabled by kernel
configuration CONFIG_NET_DSA_MICROCHIP_KSZ_PTP. As the DSA driver is
common to work with all KSZ switches this PTP code is not appropriate
for other unsupported switches. The ptp_capable indication is added to
the chip data structure to signal whether to execute those code.

Signed-off-by: Tristram Ha <tristram.ha@microchip.com>
Link: https://patch.msgid.link/20241218020240.70601-1-Tristram.Ha@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Tristram Ha and committed by
Jakub Kicinski
6ed34721 32720407

+30 -11
+29 -11
drivers/net/dsa/microchip/ksz_common.c
··· 1339 1339 .supports_rgmii = {false, false, true}, 1340 1340 .internal_phy = {true, true, false}, 1341 1341 .gbit_capable = {false, false, true}, 1342 + .ptp_capable = true, 1342 1343 .wr_table = &ksz8563_register_set, 1343 1344 .rd_table = &ksz8563_register_set, 1344 1345 }, ··· 1551 1550 .internal_phy = {true, true, true, true, 1552 1551 true, false, false}, 1553 1552 .gbit_capable = {true, true, true, true, true, true, true}, 1553 + .ptp_capable = true, 1554 1554 .wr_table = &ksz9477_register_set, 1555 1555 .rd_table = &ksz9477_register_set, 1556 1556 }, ··· 1679 1677 .supports_rgmii = {false, false, true}, 1680 1678 .internal_phy = {true, true, false}, 1681 1679 .gbit_capable = {true, true, true}, 1680 + .ptp_capable = true, 1682 1681 }, 1683 1682 1684 1683 [KSZ8567] = { ··· 1715 1712 true, false, false}, 1716 1713 .gbit_capable = {false, false, false, false, false, 1717 1714 true, true}, 1715 + .ptp_capable = true, 1718 1716 }, 1719 1717 1720 1718 [KSZ9567] = { ··· 1748 1744 .internal_phy = {true, true, true, true, 1749 1745 true, false, false}, 1750 1746 .gbit_capable = {true, true, true, true, true, true, true}, 1747 + .ptp_capable = true, 1751 1748 }, 1752 1749 1753 1750 [LAN9370] = { ··· 1778 1773 .supports_rmii = {false, false, false, false, true}, 1779 1774 .supports_rgmii = {false, false, false, false, true}, 1780 1775 .internal_phy = {true, true, true, true, false}, 1776 + .ptp_capable = true, 1781 1777 }, 1782 1778 1783 1779 [LAN9371] = { ··· 1808 1802 .supports_rmii = {false, false, false, false, true, true}, 1809 1803 .supports_rgmii = {false, false, false, false, true, true}, 1810 1804 .internal_phy = {true, true, true, true, false, false}, 1805 + .ptp_capable = true, 1811 1806 }, 1812 1807 1813 1808 [LAN9372] = { ··· 1842 1835 true, true, false, false}, 1843 1836 .internal_phy = {true, true, true, true, 1844 1837 false, false, true, true}, 1838 + .ptp_capable = true, 1845 1839 }, 1846 1840 1847 1841 [LAN9373] = { ··· 1876 1868 true, true, false, false}, 1877 1869 .internal_phy = {true, true, true, false, 1878 1870 false, false, true, true}, 1871 + .ptp_capable = true, 1879 1872 }, 1880 1873 1881 1874 [LAN9374] = { ··· 1910 1901 true, true, false, false}, 1911 1902 .internal_phy = {true, true, true, true, 1912 1903 false, false, true, true}, 1904 + .ptp_capable = true, 1913 1905 }, 1914 1906 1915 1907 [LAN9646] = { ··· 2819 2809 if (ret) 2820 2810 goto out_girq; 2821 2811 2822 - ret = ksz_ptp_irq_setup(ds, dp->index); 2823 - if (ret) 2824 - goto out_pirq; 2812 + if (dev->info->ptp_capable) { 2813 + ret = ksz_ptp_irq_setup(ds, dp->index); 2814 + if (ret) 2815 + goto out_pirq; 2816 + } 2825 2817 } 2826 2818 } 2827 2819 2828 - ret = ksz_ptp_clock_register(ds); 2829 - if (ret) { 2830 - dev_err(dev->dev, "Failed to register PTP clock: %d\n", ret); 2831 - goto out_ptpirq; 2820 + if (dev->info->ptp_capable) { 2821 + ret = ksz_ptp_clock_register(ds); 2822 + if (ret) { 2823 + dev_err(dev->dev, "Failed to register PTP clock: %d\n", 2824 + ret); 2825 + goto out_ptpirq; 2826 + } 2832 2827 } 2833 2828 2834 2829 ret = ksz_mdio_register(dev); ··· 2853 2838 return 0; 2854 2839 2855 2840 out_ptp_clock_unregister: 2856 - ksz_ptp_clock_unregister(ds); 2841 + if (dev->info->ptp_capable) 2842 + ksz_ptp_clock_unregister(ds); 2857 2843 out_ptpirq: 2858 - if (dev->irq > 0) 2844 + if (dev->irq > 0 && dev->info->ptp_capable) 2859 2845 dsa_switch_for_each_user_port(dp, dev->ds) 2860 2846 ksz_ptp_irq_free(ds, dp->index); 2861 2847 out_pirq: ··· 2875 2859 struct ksz_device *dev = ds->priv; 2876 2860 struct dsa_port *dp; 2877 2861 2878 - ksz_ptp_clock_unregister(ds); 2862 + if (dev->info->ptp_capable) 2863 + ksz_ptp_clock_unregister(ds); 2879 2864 2880 2865 if (dev->irq > 0) { 2881 2866 dsa_switch_for_each_user_port(dp, dev->ds) { 2882 - ksz_ptp_irq_free(ds, dp->index); 2867 + if (dev->info->ptp_capable) 2868 + ksz_ptp_irq_free(ds, dp->index); 2883 2869 2884 2870 ksz_irq_free(&dev->ports[dp->index].pirq); 2885 2871 }
+1
drivers/net/dsa/microchip/ksz_common.h
··· 92 92 bool supports_rgmii[KSZ_MAX_NUM_PORTS]; 93 93 bool internal_phy[KSZ_MAX_NUM_PORTS]; 94 94 bool gbit_capable[KSZ_MAX_NUM_PORTS]; 95 + bool ptp_capable; 95 96 const struct regmap_access_table *wr_table; 96 97 const struct regmap_access_table *rd_table; 97 98 };