Skip to content

Commit 7f0bc8f

Browse files
triha2workgregkh
authored andcommitted
net: dsa: microchip: Do not execute PTP driver code for unsupported switches
[ Upstream commit 6ed3472 ] 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 <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Stable-dep-of: 0f80e21 ("net: dsa: microchip: Free previously initialized ports on init failures") Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 482330f commit 7f0bc8f

File tree

2 files changed

+30
-11
lines changed

2 files changed

+30
-11
lines changed

drivers/net/dsa/microchip/ksz_common.c

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,6 +1342,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
13421342
.supports_rgmii = {false, false, true},
13431343
.internal_phy = {true, true, false},
13441344
.gbit_capable = {false, false, true},
1345+
.ptp_capable = true,
13451346
.wr_table = &ksz8563_register_set,
13461347
.rd_table = &ksz8563_register_set,
13471348
},
@@ -1553,6 +1554,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
15531554
.internal_phy = {true, true, true, true,
15541555
true, false, false},
15551556
.gbit_capable = {true, true, true, true, true, true, true},
1557+
.ptp_capable = true,
15561558
.wr_table = &ksz9477_register_set,
15571559
.rd_table = &ksz9477_register_set,
15581560
},
@@ -1680,6 +1682,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
16801682
.supports_rgmii = {false, false, true},
16811683
.internal_phy = {true, true, false},
16821684
.gbit_capable = {true, true, true},
1685+
.ptp_capable = true,
16831686
},
16841687

16851688
[KSZ8567] = {
@@ -1715,6 +1718,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
17151718
true, false, false},
17161719
.gbit_capable = {false, false, false, false, false,
17171720
true, true},
1721+
.ptp_capable = true,
17181722
},
17191723

17201724
[KSZ9567] = {
@@ -1747,6 +1751,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
17471751
.internal_phy = {true, true, true, true,
17481752
true, false, false},
17491753
.gbit_capable = {true, true, true, true, true, true, true},
1754+
.ptp_capable = true,
17501755
},
17511756

17521757
[LAN9370] = {
@@ -1775,6 +1780,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
17751780
.supports_rmii = {false, false, false, false, true},
17761781
.supports_rgmii = {false, false, false, false, true},
17771782
.internal_phy = {true, true, true, true, false},
1783+
.ptp_capable = true,
17781784
},
17791785

17801786
[LAN9371] = {
@@ -1803,6 +1809,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
18031809
.supports_rmii = {false, false, false, false, true, true},
18041810
.supports_rgmii = {false, false, false, false, true, true},
18051811
.internal_phy = {true, true, true, true, false, false},
1812+
.ptp_capable = true,
18061813
},
18071814

18081815
[LAN9372] = {
@@ -1835,6 +1842,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
18351842
true, true, false, false},
18361843
.internal_phy = {true, true, true, true,
18371844
false, false, true, true},
1845+
.ptp_capable = true,
18381846
},
18391847

18401848
[LAN9373] = {
@@ -1867,6 +1875,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
18671875
true, true, false, false},
18681876
.internal_phy = {true, true, true, false,
18691877
false, false, true, true},
1878+
.ptp_capable = true,
18701879
},
18711880

18721881
[LAN9374] = {
@@ -1899,6 +1908,7 @@ const struct ksz_chip_data ksz_switch_chips[] = {
18991908
true, true, false, false},
19001909
.internal_phy = {true, true, true, true,
19011910
false, false, true, true},
1911+
.ptp_capable = true,
19021912
},
19031913
};
19041914
EXPORT_SYMBOL_GPL(ksz_switch_chips);
@@ -2556,16 +2566,21 @@ static int ksz_setup(struct dsa_switch *ds)
25562566
if (ret)
25572567
goto out_girq;
25582568

2559-
ret = ksz_ptp_irq_setup(ds, dp->index);
2560-
if (ret)
2561-
goto out_pirq;
2569+
if (dev->info->ptp_capable) {
2570+
ret = ksz_ptp_irq_setup(ds, dp->index);
2571+
if (ret)
2572+
goto out_pirq;
2573+
}
25622574
}
25632575
}
25642576

2565-
ret = ksz_ptp_clock_register(ds);
2566-
if (ret) {
2567-
dev_err(dev->dev, "Failed to register PTP clock: %d\n", ret);
2568-
goto out_ptpirq;
2577+
if (dev->info->ptp_capable) {
2578+
ret = ksz_ptp_clock_register(ds);
2579+
if (ret) {
2580+
dev_err(dev->dev, "Failed to register PTP clock: %d\n",
2581+
ret);
2582+
goto out_ptpirq;
2583+
}
25692584
}
25702585

25712586
ret = ksz_mdio_register(dev);
@@ -2585,9 +2600,10 @@ static int ksz_setup(struct dsa_switch *ds)
25852600
return 0;
25862601

25872602
out_ptp_clock_unregister:
2588-
ksz_ptp_clock_unregister(ds);
2603+
if (dev->info->ptp_capable)
2604+
ksz_ptp_clock_unregister(ds);
25892605
out_ptpirq:
2590-
if (dev->irq > 0)
2606+
if (dev->irq > 0 && dev->info->ptp_capable)
25912607
dsa_switch_for_each_user_port(dp, dev->ds)
25922608
ksz_ptp_irq_free(ds, dp->index);
25932609
out_pirq:
@@ -2606,11 +2622,13 @@ static void ksz_teardown(struct dsa_switch *ds)
26062622
struct ksz_device *dev = ds->priv;
26072623
struct dsa_port *dp;
26082624

2609-
ksz_ptp_clock_unregister(ds);
2625+
if (dev->info->ptp_capable)
2626+
ksz_ptp_clock_unregister(ds);
26102627

26112628
if (dev->irq > 0) {
26122629
dsa_switch_for_each_user_port(dp, dev->ds) {
2613-
ksz_ptp_irq_free(ds, dp->index);
2630+
if (dev->info->ptp_capable)
2631+
ksz_ptp_irq_free(ds, dp->index);
26142632

26152633
ksz_irq_free(&dev->ports[dp->index].pirq);
26162634
}

drivers/net/dsa/microchip/ksz_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ struct ksz_chip_data {
8686
bool supports_rgmii[KSZ_MAX_NUM_PORTS];
8787
bool internal_phy[KSZ_MAX_NUM_PORTS];
8888
bool gbit_capable[KSZ_MAX_NUM_PORTS];
89+
bool ptp_capable;
8990
const struct regmap_access_table *wr_table;
9091
const struct regmap_access_table *rd_table;
9192
};

0 commit comments

Comments
 (0)