aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/phy
AgeCommit message (Collapse)Author
2022-07-29Merge branch 'v5.15/base' into v5.15/standard/nxp-sdk-5.15/nxp-socBruce Ashfield
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> # Conflicts: # arch/arm/mm/mmu.c
2022-07-21net: sfp: fix memory leak in sfp_probe()Jianglei Nie
[ Upstream commit 0a18d802d65cf662644fd1d369c86d84a5630652 ] sfp_probe() allocates a memory chunk from sfp with sfp_alloc(). When devm_add_action() fails, sfp is not freed, which leads to a memory leak. We should use devm_add_action_or_reset() instead of devm_add_action(). Signed-off-by: Jianglei Nie <niejianglei2021@163.com> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Link: https://lore.kernel.org/r/20220629075550.2152003-1-niejianglei2021@163.com Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-07-13Merge branch 'v5.15/standard/base' into v5.15/standard/nxp-sdk-5.15/nxp-socBruce Ashfield
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> # Conflicts: # arch/arm64/boot/dts/freescale/imx8mp-evk.dts
2022-07-07net: phy: ax88772a: fix lost pause advertisement configurationOleksij Rempel
commit fa152f626b24ec2ca3489100d8c5c0a0bce4e2ef upstream. In case of asix_ax88772a_link_change_notify() workaround, we run soft reset which will automatically clear MII_ADVERTISE configuration. The PHYlib framework do not know about changed configuration state of the PHY, so we need use phy_init_hw() to reinit PHY configuration. Fixes: dde258469257 ("net: usb/phy: asix: add support for ax88772A/C PHYs") Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20220628114349.3929928-1-o.rempel@pengutronix.de Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-07net: dp83822: disable rx error interruptEnguerrand de Ribaucourt
commit 0e597e2affb90d6ea48df6890d882924acf71e19 upstream. Some RX errors, notably when disconnecting the cable, increase the RCSR register. Once half full (0x7fff), an interrupt flood is generated. I measured ~3k/s interrupts even after the RX errors transfer was stopped. Since we don't read and clear the RCSR register, we should disable this interrupt. Fixes: 87461f7a58ab ("net: phy: DP83822 initial driver submission") Signed-off-by: Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-07net: dp83822: disable false carrier interruptEnguerrand de Ribaucourt
commit c96614eeab663646f57f67aa591e015abd8bd0ba upstream. When unplugging an Ethernet cable, false carrier events were produced by the PHY at a very high rate. Once the false carrier counter full, an interrupt was triggered every few clock cycles until the cable was replugged. This resulted in approximately 10k/s interrupts. Since the false carrier counter (FCSCR) is never used, we can safely disable this interrupt. In addition to improving performance, this also solved MDIO read timeouts I was randomly encountering with an i.MX8 fec MAC because of the interrupt flood. The interrupt count and MDIO timeout fix were tested on a v5.4.110 kernel. Fixes: 87461f7a58ab ("net: phy: DP83822 initial driver submission") Signed-off-by: Enguerrand de Ribaucourt <enguerrand.de-ribaucourt@savoirfairelinux.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-07net: phy: Don't trigger state machine while in suspendLukas Wunner
commit 1758bde2e4aa5ff188d53e7d9d388bbb7e12eebb upstream. Upon system sleep, mdio_bus_phy_suspend() stops the phy_state_machine(), but subsequent interrupts may retrigger it: They may have been left enabled to facilitate wakeup and are not quiesced until the ->suspend_noirq() phase. Unwanted interrupts may hence occur between mdio_bus_phy_suspend() and dpm_suspend_noirq(), as well as between dpm_resume_noirq() and mdio_bus_phy_resume(). Retriggering the phy_state_machine() through an interrupt is not only undesirable for the reason given in mdio_bus_phy_suspend() (freezing it midway with phydev->lock held), but also because the PHY may be inaccessible after it's suspended: Accesses to USB-attached PHYs are blocked once usb_suspend_both() clears the can_submit flag and PHYs on PCI network cards may become inaccessible upon suspend as well. Amend phy_interrupt() to avoid triggering the state machine if the PHY is suspended. Signal wakeup instead if the attached net_device or its parent has been configured as a wakeup source. (Those conditions are identical to mdio_bus_phy_may_suspend().) Postpone handling of the interrupt until the PHY has resumed. Before stopping the phy_state_machine() in mdio_bus_phy_suspend(), wait for a concurrent phy_interrupt() to run to completion. That is necessary because phy_interrupt() may have checked the PHY's suspend status before the system sleep transition commenced and it may thus retrigger the state machine after it was stopped. Likewise, after re-enabling interrupt handling in mdio_bus_phy_resume(), wait for a concurrent phy_interrupt() to complete to ensure that interrupts which it postponed are properly rerun. The issue was exposed by commit 1ce8b37241ed ("usbnet: smsc95xx: Forward PHY interrupts to PHY driver to avoid polling"), but has existed since forever. Fixes: 541cd3ee00a4 ("phylib: Fix deadlock on resume") Link: https://lore.kernel.org/netdev/a5315a8a-32c2-962f-f696-de9a26d30091@samsung.com/ Reported-by: Marek Szyprowski <m.szyprowski@samsung.com> Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> Signed-off-by: Lukas Wunner <lukas@wunner.de> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Cc: stable@vger.kernel.org # v2.6.33+ Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/b7f386d04e9b5b0e2738f0125743e30676f309ef.1656410895.git.lukas@wunner.de Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-07-05Merge branch 'v5.15/standard/base' into v5.15/standard/nxp-sdk-5.15/nxp-socBruce Ashfield
2022-06-29phy: aquantia: Fix AN when higher speeds than 1G are not advertisedClaudiu Manoil
[ Upstream commit 9b7fd1670a94a57d974795acebde843a5c1a354e ] Even when the eth port is resticted to work with speeds not higher than 1G, and so the eth driver is requesting the phy (via phylink) to advertise up to 1000BASET support, the aquantia phy device is still advertising for 2.5G and 5G speeds. Clear these advertising defaults when requested. Cc: Ondrej Spacek <ondrej.spacek@nxp.com> Fixes: 09c4c57f7bc41 ("net: phy: aquantia: add support for auto-negotiation configuration") Signed-off-by: Claudiu Manoil <claudiu.manoil@nxp.com> Link: https://lore.kernel.org/r/20220610084037.7625-1-claudiu.manoil@nxp.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-21Merge branch 'v5.15/standard/base' into v5.15/standard/nxp-sdk-5.15/nxp-socBruce Ashfield
2022-06-14net: phy: dp83867: retrigger SGMII AN when link changeTan Tee Min
commit c76acfb7e19dcc3a0964e0563770b1d11b8d4540 upstream. There is a limitation in TI DP83867 PHY device where SGMII AN is only triggered once after the device is booted up. Even after the PHY TPI is down and up again, SGMII AN is not triggered and hence no new in-band message from PHY to MAC side SGMII. This could cause an issue during power up, when PHY is up prior to MAC. At this condition, once MAC side SGMII is up, MAC side SGMII wouldn`t receive new in-band message from TI PHY with correct link status, speed and duplex info. As suggested by TI, implemented a SW solution here to retrigger SGMII Auto-Neg whenever there is a link change. v2: Add Fixes tag in commit message. Fixes: 2a10154abcb7 ("net: phy: dp83867: Add TI dp83867 phy") Cc: <stable@vger.kernel.org> # 5.4.x Signed-off-by: Sit, Michael Wei Hong <michael.wei.hong.sit@intel.com> Reviewed-by: Voon Weifeng <weifeng.voon@intel.com> Signed-off-by: Tan Tee Min <tee.min.tan@linux.intel.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20220526090347.128742-1-tee.min.tan@linux.intel.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-14net: mdio: unexport __init-annotated mdio_bus_init()Masahiro Yamada
[ Upstream commit 35b42dce619701f1300fb8498dae82c9bb1f0263 ] EXPORT_SYMBOL and __init is a bad combination because the .init.text section is freed up after the initialization. Hence, modules cannot use symbols annotated __init. The access to a freed symbol may end up with kernel panic. modpost used to detect it, but it has been broken for a decade. Recently, I fixed modpost so it started to warn it again, then this showed up in linux-next builds. There are two ways to fix it: - Remove __init - Remove EXPORT_SYMBOL I chose the latter for this case because the only in-tree call-site, drivers/net/phy/phy_device.c is never compiled as modular. (CONFIG_PHYLIB is boolean) Fixes: 90eff9096c01 ("net: phy: Allow splitting MDIO bus/device support from PHYs") Reported-by: Stephen Rothwell <sfr@canb.auug.org.au> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-14Merge branch 'v5.15/standard/base' into v5.15/standard/nxp-sdk-5.15/nxp-socBruce Ashfield
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> # Conflicts: # drivers/pci/controller/dwc/pci-imx6.c # drivers/spi/spi-fsl-qspi.c
2022-06-09net: phy: micrel: Allow probing without .driver_dataFabio Estevam
[ Upstream commit f2ef6f7539c68c6bd6c32323d8845ee102b7c450 ] Currently, if the .probe element is present in the phy_driver structure and the .driver_data is not, a NULL pointer dereference happens. Allow passing .probe without .driver_data by inserting NULL checks for priv->type. Signed-off-by: Fabio Estevam <festevam@denx.de> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20220513114613.762810-1-festevam@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-05-25Merge branch 'v5.15/standard/base' into v5.15/standard/nxp-sdk-5.15/nxp-socBruce Ashfield
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> # Conflicts: # drivers/tty/serial/fsl_lpuart.c
2022-05-18net: phy: micrel: Pass .probe for KS8737Fabio Estevam
commit 15f03ffe4bb951e982457f44b6cf6b06ef4cbb93 upstream. Since commit f1131b9c23fb ("net: phy: micrel: use kszphy_suspend()/kszphy_resume for irq aware devices") the kszphy_suspend/ resume hooks are used. These functions require the probe function to be called so that priv can be allocated. Otherwise, a NULL pointer dereference happens inside kszphy_config_reset(). Cc: stable@vger.kernel.org Fixes: f1131b9c23fb ("net: phy: micrel: use kszphy_suspend()/kszphy_resume for irq aware devices") Reported-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: Fabio Estevam <festevam@denx.de> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20220504143104.1286960-2-festevam@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-05-18net: phy: micrel: Do not use kszphy_suspend/resume for KSZ8061Fabio Estevam
commit e333eed63a091a09bd0db191b7710c594c6e995b upstream. Since commit f1131b9c23fb ("net: phy: micrel: use kszphy_suspend()/kszphy_resume for irq aware devices") the following NULL pointer dereference is observed on a board with KSZ8061: # udhcpc -i eth0 udhcpc: started, v1.35.0 8<--- cut here --- Unable to handle kernel NULL pointer dereference at virtual address 00000008 pgd = f73cef4e [00000008] *pgd=00000000 Internal error: Oops: 5 [#1] SMP ARM Modules linked in: CPU: 0 PID: 196 Comm: ifconfig Not tainted 5.15.37-dirty #94 Hardware name: Freescale i.MX6 SoloX (Device Tree) PC is at kszphy_config_reset+0x10/0x114 LR is at kszphy_resume+0x24/0x64 ... The KSZ8061 phy_driver structure does not have the .probe/..driver_data fields, which means that priv is not allocated. This causes the NULL pointer dereference inside kszphy_config_reset(). Fix the problem by using the generic suspend/resume functions as before. Another alternative would be to provide the .probe and .driver_data information into the structure, but to be on the safe side, let's just restore Ethernet functionality by using the generic suspend/resume. Cc: stable@vger.kernel.org Fixes: f1131b9c23fb ("net: phy: micrel: use kszphy_suspend()/kszphy_resume for irq aware devices") Signed-off-by: Fabio Estevam <festevam@denx.de> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20220504143104.1286960-1-festevam@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-05-18net: phy: Fix race condition on link status changeFrancesco Dolcini
commit 91a7cda1f4b8bdf770000a3b60640576dafe0cec upstream. This fixes the following error caused by a race condition between phydev->adjust_link() and a MDIO transaction in the phy interrupt handler. The issue was reproduced with the ethernet FEC driver and a micrel KSZ9031 phy. [ 146.195696] fec 2188000.ethernet eth0: MDIO read timeout [ 146.201779] ------------[ cut here ]------------ [ 146.206671] WARNING: CPU: 0 PID: 571 at drivers/net/phy/phy.c:942 phy_error+0x24/0x6c [ 146.214744] Modules linked in: bnep imx_vdoa imx_sdma evbug [ 146.220640] CPU: 0 PID: 571 Comm: irq/128-2188000 Not tainted 5.18.0-rc3-00080-gd569e86915b7 #9 [ 146.229563] Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) [ 146.236257] unwind_backtrace from show_stack+0x10/0x14 [ 146.241640] show_stack from dump_stack_lvl+0x58/0x70 [ 146.246841] dump_stack_lvl from __warn+0xb4/0x24c [ 146.251772] __warn from warn_slowpath_fmt+0x5c/0xd4 [ 146.256873] warn_slowpath_fmt from phy_error+0x24/0x6c [ 146.262249] phy_error from kszphy_handle_interrupt+0x40/0x48 [ 146.268159] kszphy_handle_interrupt from irq_thread_fn+0x1c/0x78 [ 146.274417] irq_thread_fn from irq_thread+0xf0/0x1dc [ 146.279605] irq_thread from kthread+0xe4/0x104 [ 146.284267] kthread from ret_from_fork+0x14/0x28 [ 146.289164] Exception stack(0xe6fa1fb0 to 0xe6fa1ff8) [ 146.294448] 1fa0: 00000000 00000000 00000000 00000000 [ 146.302842] 1fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000 [ 146.311281] 1fe0: 00000000 00000000 00000000 00000000 00000013 00000000 [ 146.318262] irq event stamp: 12325 [ 146.321780] hardirqs last enabled at (12333): [<c01984c4>] __up_console_sem+0x50/0x60 [ 146.330013] hardirqs last disabled at (12342): [<c01984b0>] __up_console_sem+0x3c/0x60 [ 146.338259] softirqs last enabled at (12324): [<c01017f0>] __do_softirq+0x2c0/0x624 [ 146.346311] softirqs last disabled at (12319): [<c01300ac>] __irq_exit_rcu+0x138/0x178 [ 146.354447] ---[ end trace 0000000000000000 ]--- With the FEC driver phydev->adjust_link() calls fec_enet_adjust_link() calls fec_stop()/fec_restart() and both these function reset and temporary disable the FEC disrupting any MII transaction that could be happening at the same time. fec_enet_adjust_link() and phy_read() can be running at the same time when we have one additional interrupt before the phy_state_machine() is able to terminate. Thread 1 (phylib WQ) | Thread 2 (phy interrupt) | | phy_interrupt() <-- PHY IRQ | handle_interrupt() | phy_read() | phy_trigger_machine() | --> schedule phylib WQ | | phy_state_machine() | phy_check_link_status() | phy_link_change() | phydev->adjust_link() | fec_enet_adjust_link() | --> FEC reset | phy_interrupt() <-- PHY IRQ | phy_read() | Fix this by acquiring the phydev lock in phy_interrupt(). Link: https://lore.kernel.org/all/20220422152612.GA510015@francesco-nb.int.toradex.com/ Fixes: c974bdbc3e77 ("net: phy: Use threaded IRQ, to allow IRQ from sleeping devices") cc: <stable@vger.kernel.org> Signed-off-by: Francesco Dolcini <francesco.dolcini@toradex.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20220506060815.327382-1-francesco.dolcini@toradex.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-05-18net: sfp: Add tx-fault workaround for Huawei MA5671A SFP ONTMatthew Hagan
[ Upstream commit 2069624dac19d62c558bb6468fe03678553ab01d ] As noted elsewhere, various GPON SFP modules exhibit non-standard TX-fault behaviour. In the tested case, the Huawei MA5671A, when used in combination with a Marvell mv88e6085 switch, was found to persistently assert TX-fault, resulting in the module being disabled. This patch adds a quirk to ignore the SFP_F_TX_FAULT state, allowing the module to function. Change from v1: removal of erroneous return statment (Andrew Lunn) Signed-off-by: Matthew Hagan <mnhagan88@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20220502223315.1973376-1-mnhagan88@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-05-09Merge branch 'v5.15/standard/base' into v5.15/standard/nxp-sdk-5.15/nxp-socBruce Ashfield
2022-05-09net: phy: marvell10g: fix return value on errorBaruch Siach
[ Upstream commit 0ed9704b660b259b54743cad8a84a11148f60f0a ] Return back the error value that we get from phy_read_mmd(). Fixes: c84786fa8f91 ("net: phy: marvell10g: read copper results from CSSR1") Signed-off-by: Baruch Siach <baruch.siach@siklu.com> Reviewed-by: Marek Behún <kabel@kernel.org> Reviewed-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk> Link: https://lore.kernel.org/r/f47cb031aeae873bb008ba35001607304a171a20.1650868058.git.baruch@tkos.co.il Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-04-20Merge branch 'v5.15/standard/base' into v5.15/standard/nxp-sdk-5.15/nxp-socBruce Ashfield
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com> # Conflicts: # drivers/gpu/drm/bridge/nwl-dsi.c
2022-04-14net: phylink: fix in-band autoneg getting disabled with Generic PHY driverVladimir Oltean
commit 9e552b42a2a63adb2c2be409e74659e4a6152a39 from https://source.codeaurora.org/external/imx/linux-imx PHY devices without a specific driver have a NULL phydev->drv up until the point when phy_attach_direct() runs and manually binds the genphy driver to it. The downstream phy_validate_inband_autoneg() function returns -EIO for the case where phydev->drv is NULL, but none of the callers checks for negative error codes. One caller of phy_validate_inband_autoneg() is phylink_fixup_inband_aneg(), which is in fact called from phylink_connect_phy() and phylink_fwnode_connect_phy(). Lower in each of these functions is a (direct or indirect) call to phy_attach_direct(), so we always have a NULL phydev->drv pointer at that point. The effect of phy_validate_inband_autoneg() returning -EIO is as follows: - The first check, ret == PHY_INBAND_ANEG_UNKNOWN, does not pass. This allows the code flow to unexpectedly continue. - The second check, phylink_autoneg_inband(mode) && !(ret & PHY_INBAND_ANEG_ON), passes. This is because -EIO (-5) does not have bit PHY_INBAND_ANEG_ON (2) set. - As a result of passing the second check, phylink prints, and does, the following: Requested in-band autoneg but driver does not support this, disabling it. with the end result that the link breaks, if the PHY was pre-configured by U-Boot to enable in-band autoneg, and in-band autoneg is described in the device tree. The expected behavior was for phy_validate_inband_autoneg() to return PHY_INBAND_ANEG_UNKNOWN (because it _is_ unknown when using the Generic PHY driver), and for phylink to leave the setting alone and hope for the best. We repair the problem by eliminating the possibility of phy_validate_inband_autoneg() to return negative error codes, since they have not proven to be useful, it is awkward to check for them, and they introduce subtle bugs too. This patch should be squashed into the blamed commit below if the series is ever to be resent upstream. Fixes: 67a4afb856c8 ("net: phylink: introduce a generic method for querying PHY in-band autoneg capability") Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14MLK-25746 net: phy: tja11xx: fix -Wimplicit-fallthrough build warningJoakim Zhang
commit ff46675e60bf540895fcc9aac1160a40ed89509f from https://source.codeaurora.org/external/imx/linux-imx In linux-nxp repo, -Wimplicit-fallthrough is set to 5, so it causes warning for /* fall through */ in switch case statement. So the patch is used to fix it Reviewed-by: Jun Li <jun.li@nxp.com> Signed-off-by: Joakim Zhang <qiangqing.zhang@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14net: phy: mscc: configure in-band auto-negotiation for VSC8514Vladimir Oltean
commit 4bc08d1921a4a5ccdafa61a1e560f47467ff1411 from https://source.codeaurora.org/external/imx/linux-imx Add the in-band configuration knob for the VSC8514 quad PHY. Tested with QSGMII in-band AN both on and off on NXP LS1028A-RDB and T1040-RDB. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14net: phylink: explicitly configure in-band autoneg for PHYs that support itVladimir Oltean
commit 4bc08d1921a4a5ccdafa61a1e560f47467ff1411 from https://source.codeaurora.org/external/imx/linux-imx Currently Linux has no control over whether a MAC-to-PHY interface uses in-band signaling or not, even though phylink has the managed = "in-band-status"; property which denotes that the MAC expects in-band signaling to be used. The problem is really that if the in-band signaling is configurable in both the PHY and the MAC, there is a risk that they are out of sync unless phylink manages them both. Most if not all in-band autoneg state machines follow IEEE 802.3 clause 37, which means that they will not change the operating mode of the SERDES lane from control to data mode unless in-band AN completed successfully. Therefore traffic will not work. It is particularly unpleasant that currently, we assume that PHYs which have configurable in-band AN come pre-configured from a prior boot stage such as U-Boot, because once the bootloader changes, all bets are off. Let's introduce a new PHY driver method for configuring in-band autoneg, and make phylink be its first user. The main PHY library does not call phy_config_inband_autoneg, because it does not know what to configure it to. Presumably, non-phylink drivers can also call phy_config_inband_autoneg individually. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14net: phy: bcm84881: move the in-band capability check where it belongsVladimir Oltean
commit 4bc08d1921a4a5ccdafa61a1e560f47467ff1411 from https://source.codeaurora.org/external/imx/linux-imx Now that there is a generic interface through which phylink can query PHY drivers whether they support various forms of in-band autoneg, use that and delete the special case from phylink.c. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14net: phylink: introduce a generic method for querying PHY in-band autoneg ↵Vladimir Oltean
capability commit 9e552b42a2a63adb2c2be409e74659e4a6152a39 from https://source.codeaurora.org/external/imx/linux-imx Phylink parses the firmware node for 'managed = "in-band-status"' and populates the initial pl->cfg_link_an_mode to MLO_AN_PHY or MLO_AN_INBAND accordingly, but sometimes things do not really work out at runtime, and the pl->cur_link_an_mode may change. The most notable case is when an SFP module with a PHY that has broken in-band autoneg is attached. Phylink currently open-codes a check for the BCM84881 PHY ID and updates pl->cur_link_an_mode from MLO_AN_INBAND to MLO_AN_PHY. There is an additional degree of freedom I would like to add. This has to do with the on-board PHY case (not on SFP). Sometimes, a PHY can only operate with in-band autoneg enabled, but the MAC driver does not declare 'managed = "in-band-status"' in the firmware node (say it was recently converted from phylib to phylink). If the MAC driver is strict in its phylink ops implementation, it will disable in-band autoneg and thus the connection to the PHY will be broken. The firmware can (and should) be updated, but if the PHY driver is patched to report that it only supports in-band autoneg, then the pl->cur_link_an_mode can be fixed up to request in-band autoneg from the MAC driver, even if the firmware node does not. While I do not expect production systems to rely on this feature, it seems sensible to have it as long as it is not difficult to implement (the PHY driver should be updated with a small .validate_inband_aneg method), and it can even ease the transition from phylib to phylink. There is also the reverse case: the firmware node reports MLO_AN_INBAND but the on-board PHY doesn't support that. That sounds like a serious bug, so while we still do attempt to fix it up (it seems within our reach to handle it, and worth it), we print to the kernel log on a more severe tone and not just at the debug level. So if the 3 code paths: - phylink_sfp_config - phylink_connect_phy - phylink_fwnode_phy_connect do more or less the same thing (adapt pl->cur_link_an_mode based on the capability reported by the PHY), the intention is different. With SFP modules this behavior is absolutely to be expected, and pl->cfg_link_an_mode only denotes the initial operating mode. On the other hand, when the PHY is on-board, the initial link AN mode should ideally also be the final one. So the implementations for the three are different. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14net: phylink: pass the phy argument to phylink_sfp_configVladimir Oltean
commit 4bc08d1921a4a5ccdafa61a1e560f47467ff1411 from https://source.codeaurora.org/external/imx/linux-imx Problem statement: I would like to move the phy_no_inband() check inside phylink_sfp_config(), right _after_ the PHY mode was determined by sfp_select_interface(). But phylink_sfp_config() does not take the "phy" as argument, only one of its callers (phylink_sfp_connect_phy) does. phylink_sfp_config is called from: - phylink_sfp_module_insert, if we know that the SFP module may not have a PHY - phylink_sfp_module_start, if the SFP module may have a PHY but it is not available here (otherwise the "if (pl->phydev)" check right above would have triggered) - phylink_sfp_connect_phy, which by definition has a PHY So of all 3 callers, 2 are certain there is no PHY at that particular moment, and 1 is certain there is one. After further analysis, the "mode" is assumed to be MLO_AN_INBAND unless there is a PHY, and that PHY has broken inband capabilities. So if we pass the PHY pointer (be it NULL), we can drop the "mode" argument and deduce it locally. To avoid a forward-declaration, this change also moves phylink_phy_no_inband above phylink_sfp_config. Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14net: phy: inphi: add a remove functionIoana Ciornei
commit ff46675e60bf540895fcc9aac1160a40ed89509f from https://source.codeaurora.org/external/imx/linux-imx The workqueue run by the Inphi driver can impact networking performance testing on other interfaces. Make sure that on the remove path the work is canceled and the workqueue is destroyed. Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14MLK-24174-03 net: phy: tja11xx: add refclk source selection supportFugang Duan
commit ff46675e60bf540895fcc9aac1160a40ed89509f from https://source.codeaurora.org/external/imx/linux-imx Add below features support for both TJA1100 and TJA1101 cards: - Add MII and RMII mode support. - Add refclk in/out support for RMII. Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com> Signed-off-by: Fugang Duan <fugang.duan@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14LF-538 net: phy: tja11xx: add user interface to enable slave modeFugang Duan
commit ff46675e60bf540895fcc9aac1160a40ed89509f from https://source.codeaurora.org/external/imx/linux-imx Current phy driver only support master mode. Add sysfs interface for user to danimiacally configure the phy mode to master or slave. Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com> Signed-off-by: Fugang Duan <fugang.duan@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14drivers: net: phy: aquantia: enable USX AN for USXGMII protocolAlex Marginean
commit ff46675e60bf540895fcc9aac1160a40ed89509f from https://source.codeaurora.org/external/imx/linux-imx Depending on FW defaults USX AN in AQR PHY must be explicitly enabled when using USXGMII. Enable it based on interface type. Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14drivers: net: phy: aquantia: fix system side protocol misconfigurationAlex Marginean
commit 25f5637053722ad6b39bef28cc195d379f9ae15d from https://source.codeaurora.org/external/imx/linux-imx Do not set up protocols for speeds that are not supported by FW. Enabling these protocols leads to link issues on system side. Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14drivers: net: phy: aquantia: enable AQR112 and AQR412Alex Marginean
commit 3d5b3adaaef1eebf7cf726a6c57e983e87d0b0bd from https://source.codeaurora.org/external/imx/linux-imx Adds support for AQR112 and AQR412 which is mostly based on existing code with the addition of code configuring the protocol on system side. This allows changing the system side protocol without having to deploy a different firmware on the PHY. Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14net/phy: Inphi IN112525_s03 retimer updatesFlorin Chiculita
commit f83eb62405d4d6ac75ae6f26cf9c3d6035f6482d from https://source.codeaurora.org/external/imx/linux-imx The retimer doesn't get probed in linux due to the fact that it's a non-standard clause-45 device. Hardcoding the phyid in device-tree and adding custom routines for registry read/write operations solves the issue. Signed-off-by: Florin Chiculita <florinlaurentiu.chiculita@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14net/phy: Inphi IN112525_s03 retimer supportFlorin Chiculita
commit 50eb34ef3cd08a69bf7a773a7d991f81f58c1e12 from https://source.codeaurora.org/external/imx/linux-imx Software controller for IN112525_s03 retimer Signed-off-by: Florin Chiculita <florinlaurentiu.chiculita@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14net: phy: add 10G fixed-link supportCamelia Groza
commit 8d0a7385e5c854e3f6d786a6971d8b4244a578dd from https://source.codeaurora.org/external/imx/linux-imx Signed-off-by: Camelia Groza <camelia.groza@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14MLK-11051 net: phy: mdio_bus: don't call .phy_suspendi() when netdev is NULLFugang Duan
commit 23172ac2741db6123f1d9acd346759aa2a57e41f from https://source.codeaurora.org/external/imx/linux-imx In .mdio_bus_phy_may_suspend(), there check netdev is NULL to judge to set phy to suspend status. netdev is NULL has three cases: - phy is not found - phy is found, match to general phy driver - phy is found, match to specifical phy driver Case 1: phy is not found, cannot communicate by MDIO bus. Case 2: phy is found: if phy dev driver probe/bind err, netdev is not __open__ status, mdio bus is unregistered. if phy is detached, phy had entered suspended status. Case 3: phy is found, phy is detached, phy had entered suspended status. So, in here, it shouldn't set phy to suspend by calling mdio bus. In i.MX6UL evk/arm2 board, if down the ethx interface and do suspend/resume, system will hang. Because after ethx down all clocks are gated off, for general phy driver, unbind the phy device, for specifical phy driver, no unbind the device, and the original driver call mdio bus to set phy to suspend during system suspend, so system will hang since there have mdio register access. The patch can fix it. Signed-off-by: Fugang Duan <B38611@freescale.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-14LF-3469: net: phy: at803x: Disable PHY hibernation during initShenwei Wang
commit c437d2b50ad467e82c754a0cc2016f86dde09677 from https://source.codeaurora.org/external/imx/linux-imx The Atheros 803x PHY will go to hibernate mode after 10 seconds if no activity on the link. When in hibernation, it will not provide any clock to the MAC. This caused issue when trying to bring up the interface when no cable was connected: MAC driver would timeout, and the PHY power domain would stay on. It is also possible that this caused issues with EEE capable remote PHY. Disabling this feature during initialization to avoid potential side effects. Signed-off-by: Seb Haezebrouck <sebastien.haezebrouck@nxp.com> Reviewed-by: Shenwei Wang <shenwei.wang@nxp.com> Signed-off-by: Xiaolei Wang <xiaolei.wang@windriver.com>
2022-04-13net: sfp: add 2500base-X quirk for Lantech SFP moduleMichael Walle
[ Upstream commit 00eec9fe4f3b9588b4bfa8ef9dd0aae96407d5d7 ] The Lantech 8330-262D-E module is 2500base-X capable, but it reports the nominal bitrate as 2500MBd instead of 3125MBd. Add a quirk for the module. The following in an EEPROM dump of such a SFP with the serial number redacted: 00: 03 04 07 00 00 00 01 20 40 0c 05 01 19 00 00 00 ???...? @????... 10: 1e 0f 00 00 4c 61 6e 74 65 63 68 20 20 20 20 20 ??..Lantech 20: 20 20 20 20 00 00 00 00 38 33 33 30 2d 32 36 32 ....8330-262 30: 44 2d 45 20 20 20 20 20 56 31 2e 30 03 52 00 cb D-E V1.0?R.? 40: 00 1a 00 00 46 43 XX XX XX XX XX XX XX XX XX XX .?..FCXXXXXXXXXX 50: 20 20 20 20 32 32 30 32 31 34 20 20 68 b0 01 98 220214 h??? 60: 45 58 54 52 45 4d 45 4c 59 20 43 4f 4d 50 41 54 EXTREMELY COMPAT 70: 49 42 4c 45 20 20 20 20 20 20 20 20 20 20 20 20 IBLE Signed-off-by: Michael Walle <michael@walle.cc> Link: https://lore.kernel.org/r/20220312205014.4154907-1-michael@walle.cc Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-04-08net: phy: broadcom: Fix brcm_fet_config_init()Florian Fainelli
[ Upstream commit bf8bfc4336f7a34e48b3bbd19b1542bf085bdc3d ] A Broadcom AC201 PHY (same entry as 5241) would be flagged by the Broadcom UniMAC MDIO controller as not completing the turn around properly since the PHY expects 65 MDC clock cycles to complete a write cycle, and the MDIO controller was only sending 64 MDC clock cycles as determined by looking at a scope shot. This would make the subsequent read fail with the UniMAC MDIO controller command field having MDIO_READ_FAIL set and we would abort the brcm_fet_config_init() function and thus not probe the PHY at all. After issuing a software reset, wait for at least 1ms which is well above the 1us reset delay advertised by the datasheet and issue a dummy read to let the PHY turn around the line properly. This read specifically ignores -EIO which would be returned by MDIO controllers checking for the line being turned around. If we have a genuine reaad failure, the next read of the interrupt status register would pick it up anyway. Fixes: d7a2ed9248a3 ("broadcom: Add AC131 phy support") Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Link: https://lore.kernel.org/r/20220324232438.1156812-1-f.fainelli@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-04-08net: phy: at803x: move page selection fix to config_initRobert Hancock
[ Upstream commit 4f3a00c7f5b2cfe4e127fd3fe49b55e1b318c01f ] The fix to select the copper page on AR8031 was being done in the probe function rather than config_init, so it would not be redone after resume from suspend. Move this to config_init so it is always redone when needed. Fixes: c329e5afb42f ("net: phy: at803x: select correct page on config init") Signed-off-by: Robert Hancock <robert.hancock@calian.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-03-23net: phy: mscc: Add MODULE_FIRMWARE macrosJuerg Haefliger
[ Upstream commit f1858c277ba40172005b76a31e6bb931bfc19d9c ] The driver requires firmware so define MODULE_FIRMWARE so that modinfo provides the details. Fixes: fa164e40c53b ("net: phy: mscc: split the driver into separate files") Signed-off-by: Juerg Haefliger <juergh@canonical.com> Link: https://lore.kernel.org/r/20220316151835.88765-1-juergh@canonical.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-03-23net: phy: marvell: Fix invalid comparison in the resume and suspend functionsKurt Cancemi
[ Upstream commit 837d9e49402eaf030db55a49f96fc51d73b4b441 ] This bug resulted in only the current mode being resumed and suspended when the PHY supported both fiber and copper modes and when the PHY only supported copper mode the fiber mode would incorrectly be attempted to be resumed and suspended. Fixes: 3758be3dc162 ("Marvell phy: add functions to suspend and resume both interfaces: fiber and copper links.") Signed-off-by: Kurt Cancemi <kurt@x64architecture.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Link: https://lore.kernel.org/r/20220312201512.326047-1-kurt@x64architecture.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-03-16net: phy: meson-gxl: improve link-up behaviorHeiner Kallweit
[ Upstream commit 2c87c6f9fbddc5b84d67b2fa3f432fcac6d99d93 ] Sometimes the link comes up but no data flows. This patch fixes this behavior. It's not clear what's the root cause of the issue. According to the tests one other link-up issue remains. In very rare cases the link isn't even reported as up. Fixes: 84c8f773d2dc ("net: phy: meson-gxl: remove the use of .ack_callback()") Tested-by: Erico Nunes <nunes.erico@gmail.com> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Link: https://lore.kernel.org/r/e3473452-a1f9-efcf-5fdd-02b6f44c3fcd@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-03-16net: phy: DP83822: clear MISR2 register to disable interruptsClément Léger
[ Upstream commit 37c9d66c95564c85a001d8a035354f0220a1e1c3 ] MISR1 was cleared twice but the original author intention was probably to clear MISR1 & MISR2 to completely disable interrupts. Fix it to clear MISR2. Fixes: 87461f7a58ab ("net: phy: DP83822 initial driver submission") Signed-off-by: Clément Léger <clement.leger@bootlin.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Link: https://lore.kernel.org/r/20220309142228.761153-1-clement.leger@bootlin.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-03-16net: phy: meson-gxl: fix interrupt handling in forced modeHeiner Kallweit
[ Upstream commit a502a8f04097e038c3daa16c5202a9538116d563 ] This PHY doesn't support a link-up interrupt source. If aneg is enabled we use the "aneg complete" interrupt for this purpose, but if aneg is disabled link-up isn't signaled currently. According to a vendor driver there's an additional "energy detect" interrupt source that can be used to signal link-up if aneg is disabled. We can safely ignore this interrupt source if aneg is enabled. This patch was tested on a TX3 Mini TV box with S905W (even though boot message says it's a S905D). This issue has been existing longer, but due to changes in phylib and the driver the patch applies only from the commit marked as fixed. Fixes: 84c8f773d2dc ("net: phy: meson-gxl: remove the use of .ack_callback()") Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Link: https://lore.kernel.org/r/04cac530-ea1b-850e-6cfa-144a55c4d75d@gmail.com Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-02-23net: phy: mediatek: remove PHY mode check on MT7531DENG Qingfang
commit 525b108e6d95b643eccbd84fb10aa9aa101b18dd upstream. The function mt7531_phy_mode_supported in the DSA driver set supported mode to PHY_INTERFACE_MODE_GMII instead of PHY_INTERFACE_MODE_INTERNAL for the internal PHY, so this check breaks the PHY initialization: mt7530 mdio-bus:00 wan (uninitialized): failed to connect to PHY: -EINVAL Remove the check to make it work again. Reported-by: Hauke Mehrtens <hauke@hauke-m.de> Fixes: e40d2cca0189 ("net: phy: add MediaTek Gigabit Ethernet PHY driver") Signed-off-by: DENG Qingfang <dqfext@gmail.com> Acked-by: Arınç ÜNAL <arinc.unal@arinc9.com> Tested-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-02-16net: phy: marvell: Fix MDI-x polarity setting in 88e1118-compatible PHYsPavel Parkhomenko
commit aec12836e7196e4d360b2cbf20cf7aa5139ad2ec upstream. When setting up autonegotiation for 88E1118R and compatible PHYs, a software reset of PHY is issued before setting up polarity. This is incorrect as changes of MDI Crossover Mode bits are disruptive to the normal operation and must be followed by a software reset to take effect. Let's patch m88e1118_config_aneg() to fix the issue mentioned before by invoking software reset of the PHY just after setting up MDI-x polarity. Fixes: 605f196efbf8 ("phy: Add support for Marvell 88E1118 PHY") Signed-off-by: Pavel Parkhomenko <Pavel.Parkhomenko@baikalelectronics.ru> Reviewed-by: Serge Semin <fancer.lancer@gmail.com> Suggested-by: Andrew Lunn <andrew@lunn.ch> Cc: stable@vger.kernel.org Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>