kernel: bump 5.15 to 5.15.80
[openwrt/staging/dedeckeh.git] / target / linux / generic / backport-5.15 / 703-15-v5.18-net-phy-phylink-fix-DSA-mac_select_pcs-introduction.patch
1 From 1054457006d4a14de4ae4132030e33d7eedaeba1 Mon Sep 17 00:00:00 2001
2 From: "Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>
3 Date: Mon, 21 Feb 2022 17:10:52 +0000
4 Subject: [PATCH] net: phy: phylink: fix DSA mac_select_pcs() introduction
5
6 Vladimir Oltean reports that probing on DSA drivers that aren't yet
7 populating supported_interfaces now fails. Fix this by allowing
8 phylink to detect whether DSA actually provides an underlying
9 mac_select_pcs() implementation.
10
11 Reported-by: Vladimir Oltean <olteanv@gmail.com>
12 Fixes: bde018222c6b ("net: dsa: add support for phylink mac_select_pcs()")
13 Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
14 Tested-by: Vladimir Oltean <olteanv@gmail.com>
15 Link: https://lore.kernel.org/r/E1nMCD6-00A0wC-FG@rmk-PC.armlinux.org.uk
16 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
17 ---
18 drivers/net/phy/phylink.c | 14 +++++++++++---
19 net/dsa/port.c | 2 +-
20 2 files changed, 12 insertions(+), 4 deletions(-)
21
22 --- a/drivers/net/phy/phylink.c
23 +++ b/drivers/net/phy/phylink.c
24 @@ -74,6 +74,7 @@ struct phylink {
25 struct work_struct resolve;
26
27 bool mac_link_dropped;
28 + bool using_mac_select_pcs;
29
30 struct sfp_bus *sfp_bus;
31 bool sfp_may_have_phy;
32 @@ -163,7 +164,7 @@ static int phylink_validate_mac_and_pcs(
33 int ret;
34
35 /* Get the PCS for this interface mode */
36 - if (pl->mac_ops->mac_select_pcs) {
37 + if (pl->using_mac_select_pcs) {
38 pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface);
39 if (IS_ERR(pcs))
40 return PTR_ERR(pcs);
41 @@ -790,7 +791,7 @@ static void phylink_major_config(struct
42
43 phylink_dbg(pl, "major config %s\n", phy_modes(state->interface));
44
45 - if (pl->mac_ops->mac_select_pcs) {
46 + if (pl->using_mac_select_pcs) {
47 pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface);
48 if (IS_ERR(pcs)) {
49 phylink_err(pl,
50 @@ -1192,11 +1193,17 @@ struct phylink *phylink_create(struct ph
51 phy_interface_t iface,
52 const struct phylink_mac_ops *mac_ops)
53 {
54 + bool using_mac_select_pcs = false;
55 struct phylink *pl;
56 int ret;
57
58 - /* Validate the supplied configuration */
59 if (mac_ops->mac_select_pcs &&
60 + mac_ops->mac_select_pcs(config, PHY_INTERFACE_MODE_NA) !=
61 + ERR_PTR(-EOPNOTSUPP))
62 + using_mac_select_pcs = true;
63 +
64 + /* Validate the supplied configuration */
65 + if (using_mac_select_pcs &&
66 phy_interface_empty(config->supported_interfaces)) {
67 dev_err(config->dev,
68 "phylink: error: empty supported_interfaces but mac_select_pcs() method present\n");
69 @@ -1220,6 +1227,7 @@ struct phylink *phylink_create(struct ph
70 return ERR_PTR(-EINVAL);
71 }
72
73 + pl->using_mac_select_pcs = using_mac_select_pcs;
74 pl->phy_state.interface = iface;
75 pl->link_interface = iface;
76 if (iface == PHY_INTERFACE_MODE_MOCA)
77 --- a/net/dsa/port.c
78 +++ b/net/dsa/port.c
79 @@ -1033,8 +1033,8 @@ dsa_port_phylink_mac_select_pcs(struct p
80 phy_interface_t interface)
81 {
82 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config);
83 + struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP);
84 struct dsa_switch *ds = dp->ds;
85 - struct phylink_pcs *pcs = NULL;
86
87 if (ds->ops->phylink_mac_select_pcs)
88 pcs = ds->ops->phylink_mac_select_pcs(ds, dp->index, interface);