Message ID | 20210527204528.3490126-1-olteanv@gmail.com (mailing list archive) |
---|---|
Headers | show |
Series | Convert xpcs to phylink_pcs_ops | expand |
On Thu, May 27, 2021 at 11:45:20PM +0300, Vladimir Oltean wrote: > From: Vladimir Oltean <vladimir.oltean@nxp.com> > > This patch series is COMPLETELY UNTESTED (I don't have stmmac hardware > with the xpcs) hence the RFC tag. If people from Intel could test this > it would be great. > > Background: the sja1105 DSA driver currently drives a Designware XPCS > for SGMII and 2500base-X, and it would be nice to reuse some code with > the xpcs module. This would also help consolidate the phylink_pcs_ops, > since the only user of that, currently, is the lynx_pcs. > > Therefore, this series makes the xpcs expose the same kind of API that > the lynx_pcs module does. > > Note: this patch series must be applied on top of: > https://patchwork.kernel.org/project/netdevbpf/patch/20210527155959.3270478-1-olteanv@gmail.com/ > > Vladimir Oltean (8): > net: pcs: xpcs: delete shim definition for mdio_xpcs_get_ops() > net: pcs: xpcs: check for supported PHY interface modes in > phylink_validate > net: pcs: xpcs: export xpcs_validate > net: pcs: export xpcs_config_eee > net: pcs: xpcs: export xpcs_probe > net: pcs: xpcs: convert to phylink_pcs_ops > net: pcs: xpcs: use mdiobus_c45_addr in xpcs_{read,write} > net: pcs: xpcs: convert to mdio_device > > drivers/net/ethernet/stmicro/stmmac/common.h | 3 +- > drivers/net/ethernet/stmicro/stmmac/hwif.h | 14 -- > .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 5 +- > .../net/ethernet/stmicro/stmmac/stmmac_main.c | 41 +--- > .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 41 ++-- > drivers/net/pcs/pcs-xpcs.c | 199 +++++++++++------- > include/linux/pcs/pcs-xpcs.h | 35 +-- > 7 files changed, 162 insertions(+), 176 deletions(-) I got the following kernel panic after applying [1], and followed by this patch series. [1] https://patchwork.kernel.org/project/netdevbpf/patch/20210527155959.3270478-1-olteanv@gmail.com/ [ 10.742057] libphy: stmmac: probed [ 10.750396] mdio_bus stmmac-1:01: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-1:01, irq=POLL) [ 10.818222] intel-eth-pci 0000:00:1e.4 (unnamed net_device) (uninitialized): failed to validate link configuration for in-band status [ 10.830348] intel-eth-pci 0000:00:1e.4 (unnamed net_device) (uninitialized): failed to setup phy (-22) [ 10.879931] ish-hid {33AECD58-B679-4E54-9BD9-A04D34F0C226}: [hid-ish]: enum_devices_done OK, num_hid_devices=6 [ 10.901311] hid-generic 001F:8087:0AC2.0001: device has no listeners, quitting [ 10.922498] hid-generic 001F:8087:0AC2.0002: device has no listeners, quitting [ 10.940073] hid-generic 001F:8087:0AC2.0003: device has no listeners, quitting [ 10.951878] hid-generic 001F:8087:0AC2.0004: device has no listeners, quitting [ 10.958230] atkbd serio0: Failed to enable keyboard on isa0060/serio0 [ 10.965799] input: AT Translated Set 2 keyboard as /devices/platform/i8042/serio0/input/input5 [ 10.978620] ------------[ cut here ]------------ [ 10.983295] stmmac-0000:00:1e.4 already disabled [ 10.987973] WARNING: CPU: 3 PID: 2588 at drivers/clk/clk.c:952 clk_core_disable+0x96/0x1b0 [ 10.989541] hid-generic 001F:8087:0AC3.0005: device has no listeners, quitting [ 10.996322] Modules linked in: intel_ishtp_hid(+) ax88179_178a dwmac_intel(+) usbnet x86_pkg_temp_thermal stmmac mii kvm_intel dwc3 atkbd mei_wdt udc_core pcs_xpcs libps2 mei_hdcp kvm phylink libphy irqbypass spi_pxa2xx_platform i915(+) wdat_wdt dw_dmac mei_me dw_dmac_core i2c_i801 intel_ish_ipc intel_rapl_msr intel_ishtp pcspkr i2c_smbus mei dwc3_pci thermal tpm_crb tpm_tis tpm_tis_core parport_pc parport tpm i8042 intel_pmc_core sch_fq_codel uhid fuse configfs snd_hda_intel snd_intel_dspcfg snd_intel_sdw_acpi snd_hda_codec snd_hda_core snd_pcm snd_timer snd soundcore [ 11.006487] hid-generic 001F:8087:0AC3.0006: device has no listeners, quitting [ 11.054376] CPU: 3 PID: 2588 Comm: systemd-udevd Tainted: G U 5.13.0-rc3-intel-lts #68 [ 11.054378] Hardware name: Intel Corporation Tiger Lake Client Platform/TigerLake U DDR4 SODIMM RVP, BIOS TGLIFUI1.R00.3373.AF0.2009230546 09/23/2020 [ 11.084467] RIP: 0010:clk_core_disable+0x96/0x1b0 [ 11.089221] Code: 00 8b 05 45 96 17 01 85 c0 7f 24 48 8b 5b 30 48 85 db 74 a5 8b 43 7c 85 c0 75 93 48 8b 33 48 c7 c7 6e 32 0c 8d e8 b2 5d 52 00 <0f> 0b 5b 5d c3 65 8b 05 76 31 d8 73 89 c0 48 0f a3 05 bc 92 1a 01 [ 11.108121] RSP: 0018:ffffacc50038baa0 EFLAGS: 00010086 [ 11.113400] RAX: 0000000000000000 RBX: ffff9702895e3800 RCX: 0000000000000000 [ 11.120594] RDX: 0000000000000002 RSI: ffffffff8d062d5f RDI: 00000000ffffffff [ 11.127794] RBP: 0000000000000283 R08: 0000000000000000 R09: ffffacc50038b8d0 [ 11.134995] R10: 0000000000000001 R11: 0000000000000001 R12: ffff9702895e3800 [ 11.142189] R13: 0000000000000006 R14: ffff970282a960c8 R15: ffffacc50038bad0 [ 11.149382] FS: 00007fe7654f6780(0000) GS:ffff970417f80000(0000) knlGS:0000000000000000 [ 11.157536] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 11.163337] CR2: 00007f5e93783000 CR3: 0000000108ca0001 CR4: 0000000000770ee0 [ 11.170530] PKRU: 55555554 [ 11.173275] Call Trace: [ 11.175755] clk_core_disable_lock+0x1b/0x30 [ 11.180075] intel_eth_pci_probe.cold+0x11d/0x136 [dwmac_intel] [ 11.186055] pci_device_probe+0xcf/0x150 [ 11.190021] really_probe+0xf5/0x3e0 [ 11.193646] driver_probe_device+0x64/0x150 [ 11.197874] device_driver_attach+0x53/0x60 [ 11.202103] __driver_attach+0x9f/0x150 [ 11.205984] ? device_driver_attach+0x60/0x60 [ 11.210387] ? device_driver_attach+0x60/0x60 [ 11.214789] bus_for_each_dev+0x77/0xc0 [ 11.218670] bus_add_driver+0x184/0x1f0 [ 11.222550] driver_register+0x6c/0xc0 [ 11.226347] ? 0xffffffffc0641000 [ 11.229705] do_one_initcall+0x4a/0x210 [ 11.233585] ? kmem_cache_alloc_trace+0x305/0x4e0 [ 11.238337] do_init_module+0x5c/0x230 [ 11.242127] load_module+0x2894/0x2b70 [ 11.245919] ? __do_sys_finit_module+0xb5/0x120 [ 11.250496] __do_sys_finit_module+0xb5/0x120 [ 11.254899] do_syscall_64+0x42/0x80 [ 11.258517] entry_SYSCALL_64_after_hwframe+0x44/0xae [ 11.263624] RIP: 0033:0x7fe76579bd4d [ 11.267247] Code: 00 c3 66 2e 0f 1f 84 00 00 00 00 00 90 f3 0f 1e fa 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d 03 31 0c 00 f7 d8 64 89 01 48 [ 11.286138] RSP: 002b:00007ffd7aaa2e08 EFLAGS: 00000246 ORIG_RAX: 0000000000000139 [ 11.293772] RAX: ffffffffffffffda RBX: 00005649a8ea6990 RCX: 00007fe76579bd4d [ 11.300964] RDX: 0000000000000000 RSI: 00007fe76592f1e3 RDI: 0000000000000012 [ 11.308158] RBP: 0000000000020000 R08: 0000000000000000 R09: 0000000000000000 [ 11.315351] R10: 0000000000000012 R11: 0000000000000246 R12: 00007fe76592f1e3 [ 11.322544] R13: 0000000000000000 R14: 0000000000000000 R15: 00007ffd7aaa2fc8 [ 11.329739] ---[ end trace 2cfbe6d1617011ac ]--- [ 11.334825] ------------[ cut here ]------------ HTH, VK
Hi VK, On Fri, May 28, 2021 at 10:15:21AM +0800, Wong Vee Khee wrote: > I got the following kernel panic after applying [1], and followed by > this patch series. > > [1] https://patchwork.kernel.org/project/netdevbpf/patch/20210527155959.3270478-1-olteanv@gmail.com/ > > [ 10.742057] libphy: stmmac: probed > [ 10.750396] mdio_bus stmmac-1:01: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-1:01, irq=POLL) > [ 10.818222] intel-eth-pci 0000:00:1e.4 (unnamed net_device) (uninitialized): failed to validate link configuration for in-band status > [ 10.830348] intel-eth-pci 0000:00:1e.4 (unnamed net_device) (uninitialized): failed to setup phy (-22) Thanks a lot for testing. Sadly I can't figure out what is the mistake. Could you please add this debugging patch on top and let me know what it prints? -----------------------------[ cut here ]----------------------------- >From 1d745a51b53b38df432a33849632a1b553d3f90a Mon Sep 17 00:00:00 2001 From: Vladimir Oltean <vladimir.oltean@nxp.com> Date: Fri, 28 May 2021 12:00:17 +0300 Subject: [PATCH] xpcs debug Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> --- drivers/net/pcs/pcs-xpcs.c | 44 +++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/drivers/net/pcs/pcs-xpcs.c b/drivers/net/pcs/pcs-xpcs.c index 194b79da547b..4268b8bb8db0 100644 --- a/drivers/net/pcs/pcs-xpcs.c +++ b/drivers/net/pcs/pcs-xpcs.c @@ -675,30 +675,39 @@ static void xpcs_resolve_pma(struct mdio_xpcs_args *xpcs, void xpcs_validate(struct mdio_xpcs_args *xpcs, unsigned long *supported, struct phylink_link_state *state) { - bool valid_interface; - - if (state->interface == PHY_INTERFACE_MODE_NA) { - valid_interface = true; - } else { + if (state->interface != PHY_INTERFACE_MODE_NA) { struct xpcs_id *id = xpcs->id; + bool valid_interface = false; int i; - valid_interface = false; - for (i = 0; id->interface[i] != PHY_INTERFACE_MODE_MAX; i++) { - if (id->interface[i] != state->interface) + if (id->interface[i] != state->interface) { + dev_err(&xpcs->mdiodev->dev, + "%s: provided interface %s does not match supported interface %d (%s)\n", + __func__, phy_modes(state->interface), + i, phy_modes(id->interface[i])); continue; + } valid_interface = true; break; } - } - if (!valid_interface) { - bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); - return; + if (!valid_interface) { + dev_err(&xpcs->mdiodev->dev, + "%s: provided interface %s does not match any supported interface\n", + __func__, phy_modes(state->interface)); + bitmap_zero(supported, __ETHTOOL_LINK_MODE_MASK_NBITS); + return; + } } + dev_err(&xpcs->mdiodev->dev, + "%s: supported mask for interface %s is %*pb, received supported mask is %*pb\n", + __func__, phy_modes(state->interface), + __ETHTOOL_LINK_MODE_MASK_NBITS, xpcs->supported, + __ETHTOOL_LINK_MODE_MASK_NBITS, supported); + linkmode_and(supported, supported, xpcs->supported); linkmode_and(state->advertising, state->advertising, xpcs->supported); } @@ -987,8 +996,17 @@ struct mdio_xpcs_args *xpcs_create(struct mdio_device *mdiodev) if ((xpcs_id & entry->mask) != entry->id) continue; - for (i = 0; entry->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) + dev_err(&mdiodev->dev, "%s: xpcs_id %x matched on entry %d\n", + __func__, xpcs_id, i); + + for (i = 0; entry->supported[i] != __ETHTOOL_LINK_MODE_MASK_NBITS; i++) { + dev_err(&mdiodev->dev, "%s: setting entry->supported bit %d\n", + __func__, entry->supported[i]); set_bit(entry->supported[i], xpcs->supported); + } + + dev_err(&mdiodev->dev, "%s: xpcs->supported %*pb\n", __func__, + __ETHTOOL_LINK_MODE_MASK_NBITS, xpcs->supported); xpcs->id = entry; xpcs->an_mode = entry->an_mode; -----------------------------[ cut here ]-----------------------------
On Fri, May 28, 2021 at 12:12:30PM +0300, Vladimir Oltean wrote: > Hi VK, > > On Fri, May 28, 2021 at 10:15:21AM +0800, Wong Vee Khee wrote: > > I got the following kernel panic after applying [1], and followed by > > this patch series. > > > > [1] https://patchwork.kernel.org/project/netdevbpf/patch/20210527155959.3270478-1-olteanv@gmail.com/ > > > > [ 10.742057] libphy: stmmac: probed > > [ 10.750396] mdio_bus stmmac-1:01: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-1:01, irq=POLL) > > [ 10.818222] intel-eth-pci 0000:00:1e.4 (unnamed net_device) (uninitialized): failed to validate link configuration for in-band status > > [ 10.830348] intel-eth-pci 0000:00:1e.4 (unnamed net_device) (uninitialized): failed to setup phy (-22) > > Thanks a lot for testing. Sadly I can't figure out what is the mistake. > Could you please add this debugging patch on top and let me know what it > prints? > Sorry for the late response. Here the debug log: [ 11.474302] mdio_bus stmmac-1:01: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-1:01, irq=POLL) [ 11.495564] mdio_bus stmmac-1:16: xpcs_create: xpcs_id 7996ced0 matched on entry 0 [ 11.503154] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 13 [ 11.510377] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 14 [ 11.517590] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 6 [ 11.524725] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 17 [ 11.531946] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 18 [ 11.539278] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 19 [ 11.541316] ish-hid {33AECD58-B679-4E54-9BD9-A04D34F0C226}: [hid-ish]: enum_devices_done OK, num_hid_devices=6 [ 11.546487] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 15 [ 11.546489] mdio_bus stmmac-1:16: xpcs_create: xpcs->supported 0000000,00000000,000ee040 [ 11.584687] hid-generic 001F:8087:0AC2.0001: device has no listeners, quitting [ 11.599461] mdio_bus stmmac-1:16: xpcs_validate: provided interface sgmii does not match supported interface 0 (usxgmii) [ 11.606538] hid-generic 001F:8087:0AC2.0002: device has no listeners, quitting [ 11.610306] mdio_bus stmmac-1:16: xpcs_validate: provided interface sgmii does not match any supported interface [ 11.610309] mdio_bus stmmac-1:16: xpcs_validate: provided interface sgmii does not match supported interface 0 (usxgmii) [ 11.626259] hid-generic 001F:8087:0AC2.0003: device has no listeners, quitting [ 11.627675] mdio_bus stmmac-1:16: xpcs_validate: provided interface sgmii does not match any supported interface [ 11.627677] intel-eth-pci 0000:00:1e.4 (unnamed net_device) (uninitialized): failed to validate link configuration for in-band status [ 11.641996] hid-generic 001F:8087:0AC2.0004: device has no listeners, quitting [ 11.645729] intel-eth-pci 0000:00:1e.4 (unnamed net_device) (uninitialized): failed to setup phy (-22) Regards, VK
Hi VK, On Mon, May 31, 2021 at 10:30:19AM +0800, Wong Vee Khee wrote: > On Fri, May 28, 2021 at 12:12:30PM +0300, Vladimir Oltean wrote: > > Hi VK, > > > > On Fri, May 28, 2021 at 10:15:21AM +0800, Wong Vee Khee wrote: > > > I got the following kernel panic after applying [1], and followed by > > > this patch series. > > > > > > [1] https://patchwork.kernel.org/project/netdevbpf/patch/20210527155959.3270478-1-olteanv@gmail.com/ > > > > > > [ 10.742057] libphy: stmmac: probed > > > [ 10.750396] mdio_bus stmmac-1:01: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-1:01, irq=POLL) > > > [ 10.818222] intel-eth-pci 0000:00:1e.4 (unnamed net_device) (uninitialized): failed to validate link configuration for in-band status > > > [ 10.830348] intel-eth-pci 0000:00:1e.4 (unnamed net_device) (uninitialized): failed to setup phy (-22) > > > > Thanks a lot for testing. Sadly I can't figure out what is the mistake. > > Could you please add this debugging patch on top and let me know what it > > prints? > > > > Sorry for the late response. Here the debug log: > > [ 11.474302] mdio_bus stmmac-1:01: attached PHY driver [unbound] (mii_bus:phy_addr=stmmac-1:01, irq=POLL) > [ 11.495564] mdio_bus stmmac-1:16: xpcs_create: xpcs_id 7996ced0 matched on entry 0 > [ 11.503154] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 13 > [ 11.510377] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 14 > [ 11.517590] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 6 > [ 11.524725] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 17 > [ 11.531946] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 18 > [ 11.539278] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 19 > [ 11.541316] ish-hid {33AECD58-B679-4E54-9BD9-A04D34F0C226}: [hid-ish]: enum_devices_done OK, num_hid_devices=6 > [ 11.546487] mdio_bus stmmac-1:16: xpcs_create: setting entry->supported bit 15 > [ 11.546489] mdio_bus stmmac-1:16: xpcs_create: xpcs->supported 0000000,00000000,000ee040 > [ 11.584687] hid-generic 001F:8087:0AC2.0001: device has no listeners, quitting > [ 11.599461] mdio_bus stmmac-1:16: xpcs_validate: provided interface sgmii does not match supported interface 0 (usxgmii) > [ 11.606538] hid-generic 001F:8087:0AC2.0002: device has no listeners, quitting > [ 11.610306] mdio_bus stmmac-1:16: xpcs_validate: provided interface sgmii does not match any supported interface > [ 11.610309] mdio_bus stmmac-1:16: xpcs_validate: provided interface sgmii does not match supported interface 0 (usxgmii) > [ 11.626259] hid-generic 001F:8087:0AC2.0003: device has no listeners, quitting > [ 11.627675] mdio_bus stmmac-1:16: xpcs_validate: provided interface sgmii does not match any supported interface > [ 11.627677] intel-eth-pci 0000:00:1e.4 (unnamed net_device) (uninitialized): failed to validate link configuration for in-band status > [ 11.641996] hid-generic 001F:8087:0AC2.0004: device has no listeners, quitting > [ 11.645729] intel-eth-pci 0000:00:1e.4 (unnamed net_device) (uninitialized): failed to setup phy (-22) Ha ha, this works as expected, but I was led into error due to the code structure. See, everything in pcs-xpcs.c is laid out as if there are different PHY IDs for SGMII, USXGMII etc. But if you pay close attention, they are all equal to 0x7996ced0: #define SYNOPSYS_XPCS_USXGMII_ID 0x7996ced0 #define SYNOPSYS_XPCS_10GKR_ID 0x7996ced0 #define SYNOPSYS_XPCS_XLGMII_ID 0x7996ced0 #define SYNOPSYS_XPCS_SGMII_ID 0x7996ced0 #define SYNOPSYS_XPCS_MASK 0xffffffff With the old code, it works because the probing code gets a nudge from the caller of xpcs_probe by being told what is the expected phy_interface_t. The xpcs then uses the phy_interface_t _as_part_of_ the PHY ID matching sequence. So.. yeah. I got the information I needed. I will come back with a way for the same PCS PHY ID to support multiple PHY interface types. Thanks again for testing.
From: Vladimir Oltean <vladimir.oltean@nxp.com> This patch series is COMPLETELY UNTESTED (I don't have stmmac hardware with the xpcs) hence the RFC tag. If people from Intel could test this it would be great. Background: the sja1105 DSA driver currently drives a Designware XPCS for SGMII and 2500base-X, and it would be nice to reuse some code with the xpcs module. This would also help consolidate the phylink_pcs_ops, since the only user of that, currently, is the lynx_pcs. Therefore, this series makes the xpcs expose the same kind of API that the lynx_pcs module does. Note: this patch series must be applied on top of: https://patchwork.kernel.org/project/netdevbpf/patch/20210527155959.3270478-1-olteanv@gmail.com/ Vladimir Oltean (8): net: pcs: xpcs: delete shim definition for mdio_xpcs_get_ops() net: pcs: xpcs: check for supported PHY interface modes in phylink_validate net: pcs: xpcs: export xpcs_validate net: pcs: export xpcs_config_eee net: pcs: xpcs: export xpcs_probe net: pcs: xpcs: convert to phylink_pcs_ops net: pcs: xpcs: use mdiobus_c45_addr in xpcs_{read,write} net: pcs: xpcs: convert to mdio_device drivers/net/ethernet/stmicro/stmmac/common.h | 3 +- drivers/net/ethernet/stmicro/stmmac/hwif.h | 14 -- .../ethernet/stmicro/stmmac/stmmac_ethtool.c | 5 +- .../net/ethernet/stmicro/stmmac/stmmac_main.c | 41 +--- .../net/ethernet/stmicro/stmmac/stmmac_mdio.c | 41 ++-- drivers/net/pcs/pcs-xpcs.c | 199 +++++++++++------- include/linux/pcs/pcs-xpcs.h | 35 +-- 7 files changed, 162 insertions(+), 176 deletions(-)