[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID:
<PAXPR04MB8510602580EC63ABF4837149882E2@PAXPR04MB8510.eurprd04.prod.outlook.com>
Date: Mon, 25 Nov 2024 01:55:41 +0000
From: Wei Fang <wei.fang@....com>
To: Sasha Levin <sashal@...nel.org>, "linux-kernel@...r.kernel.org"
<linux-kernel@...r.kernel.org>, "stable@...r.kernel.org"
<stable@...r.kernel.org>
CC: Vladimir Oltean <vladimir.oltean@....com>, "David S . Miller"
<davem@...emloft.net>, Claudiu Manoil <claudiu.manoil@....com>, Clark Wang
<xiaoning.wang@....com>, "andrew+netdev@...n.ch" <andrew+netdev@...n.ch>,
"edumazet@...gle.com" <edumazet@...gle.com>, "kuba@...nel.org"
<kuba@...nel.org>, "pabeni@...hat.com" <pabeni@...hat.com>,
"imx@...ts.linux.dev" <imx@...ts.linux.dev>, "netdev@...r.kernel.org"
<netdev@...r.kernel.org>
Subject: RE: [PATCH AUTOSEL 6.1 35/48] net: enetc: remove ERR050089 workaround
for i.MX95
> From: Vladimir Oltean <vladimir.oltean@....com>
>
> [ Upstream commit 86831a3f4cd4c924dd78cf0d6e4d73acacfe1b11 ]
>
> The ERR050089 workaround causes performance degradation and potential
> functional issues (e.g., RCU stalls) under certain workloads. Since new SoCs like
> i.MX95 do not require this workaround, use a static key to compile out
> enetc_lock_mdio() and enetc_unlock_mdio() at runtime, improving
> performance and avoiding unnecessary logic.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@....com>
> Signed-off-by: Wei Fang <wei.fang@....com>
> Signed-off-by: David S. Miller <davem@...emloft.net>
> Signed-off-by: Sasha Levin <sashal@...nel.org>
> ---
> .../net/ethernet/freescale/enetc/enetc_hw.h | 34 +++++++++++++------
> .../ethernet/freescale/enetc/enetc_pci_mdio.c | 28 +++++++++++++++
> 2 files changed, 52 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h
> b/drivers/net/ethernet/freescale/enetc/enetc_hw.h
> index 18ca1f42b1f75..a5e38804e2811 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h
> @@ -372,18 +372,22 @@ struct enetc_hw {
> */
> extern rwlock_t enetc_mdio_lock;
>
> +DECLARE_STATIC_KEY_FALSE(enetc_has_err050089);
> +
> /* use this locking primitive only on the fast datapath to
> * group together multiple non-MDIO register accesses to
> * minimize the overhead of the lock
> */
> static inline void enetc_lock_mdio(void) {
> - read_lock(&enetc_mdio_lock);
> + if (static_branch_unlikely(&enetc_has_err050089))
> + read_lock(&enetc_mdio_lock);
> }
>
> static inline void enetc_unlock_mdio(void) {
> - read_unlock(&enetc_mdio_lock);
> + if (static_branch_unlikely(&enetc_has_err050089))
> + read_unlock(&enetc_mdio_lock);
> }
>
> /* use these accessors only on the fast datapath under @@ -392,14 +396,16
> @@ static inline void enetc_unlock_mdio(void)
> */
> static inline u32 enetc_rd_reg_hot(void __iomem *reg) {
> - lockdep_assert_held(&enetc_mdio_lock);
> + if (static_branch_unlikely(&enetc_has_err050089))
> + lockdep_assert_held(&enetc_mdio_lock);
>
> return ioread32(reg);
> }
>
> static inline void enetc_wr_reg_hot(void __iomem *reg, u32 val) {
> - lockdep_assert_held(&enetc_mdio_lock);
> + if (static_branch_unlikely(&enetc_has_err050089))
> + lockdep_assert_held(&enetc_mdio_lock);
>
> iowrite32(val, reg);
> }
> @@ -428,9 +434,13 @@ static inline u32 _enetc_rd_mdio_reg_wa(void
> __iomem *reg)
> unsigned long flags;
> u32 val;
>
> - write_lock_irqsave(&enetc_mdio_lock, flags);
> - val = ioread32(reg);
> - write_unlock_irqrestore(&enetc_mdio_lock, flags);
> + if (static_branch_unlikely(&enetc_has_err050089)) {
> + write_lock_irqsave(&enetc_mdio_lock, flags);
> + val = ioread32(reg);
> + write_unlock_irqrestore(&enetc_mdio_lock, flags);
> + } else {
> + val = ioread32(reg);
> + }
>
> return val;
> }
> @@ -439,9 +449,13 @@ static inline void _enetc_wr_mdio_reg_wa(void
> __iomem *reg, u32 val) {
> unsigned long flags;
>
> - write_lock_irqsave(&enetc_mdio_lock, flags);
> - iowrite32(val, reg);
> - write_unlock_irqrestore(&enetc_mdio_lock, flags);
> + if (static_branch_unlikely(&enetc_has_err050089)) {
> + write_lock_irqsave(&enetc_mdio_lock, flags);
> + iowrite32(val, reg);
> + write_unlock_irqrestore(&enetc_mdio_lock, flags);
> + } else {
> + iowrite32(val, reg);
> + }
> }
>
> #ifdef ioread64
> diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pci_mdio.c
> b/drivers/net/ethernet/freescale/enetc/enetc_pci_mdio.c
> index dafb26f81f95f..d3248881a9b7e 100644
> --- a/drivers/net/ethernet/freescale/enetc/enetc_pci_mdio.c
> +++ b/drivers/net/ethernet/freescale/enetc/enetc_pci_mdio.c
> @@ -9,6 +9,28 @@
> #define ENETC_MDIO_BUS_NAME ENETC_MDIO_DEV_NAME " Bus"
> #define ENETC_MDIO_DRV_NAME ENETC_MDIO_DEV_NAME " driver"
>
> +DEFINE_STATIC_KEY_FALSE(enetc_has_err050089);
> +EXPORT_SYMBOL_GPL(enetc_has_err050089);
> +
> +static void enetc_emdio_enable_err050089(struct pci_dev *pdev) {
> + if (pdev->vendor == PCI_VENDOR_ID_FREESCALE &&
> + pdev->device == ENETC_MDIO_DEV_ID) {
> + static_branch_inc(&enetc_has_err050089);
> + dev_info(&pdev->dev, "Enabled ERR050089 workaround\n");
> + }
> +}
> +
> +static void enetc_emdio_disable_err050089(struct pci_dev *pdev) {
> + if (pdev->vendor == PCI_VENDOR_ID_FREESCALE &&
> + pdev->device == ENETC_MDIO_DEV_ID) {
> + static_branch_dec(&enetc_has_err050089);
> + if (!static_key_enabled(&enetc_has_err050089.key))
> + dev_info(&pdev->dev, "Disabled ERR050089 workaround\n");
> + }
> +}
> +
> static int enetc_pci_mdio_probe(struct pci_dev *pdev,
> const struct pci_device_id *ent)
> {
> @@ -60,6 +82,8 @@ static int enetc_pci_mdio_probe(struct pci_dev *pdev,
> goto err_pci_mem_reg;
> }
>
> + enetc_emdio_enable_err050089(pdev);
> +
> err = of_mdiobus_register(bus, dev->of_node);
> if (err)
> goto err_mdiobus_reg;
> @@ -69,6 +93,7 @@ static int enetc_pci_mdio_probe(struct pci_dev *pdev,
> return 0;
>
> err_mdiobus_reg:
> + enetc_emdio_disable_err050089(pdev);
> pci_release_region(pdev, 0);
> err_pci_mem_reg:
> pci_disable_device(pdev);
> @@ -86,6 +111,9 @@ static void enetc_pci_mdio_remove(struct pci_dev
> *pdev)
> struct enetc_mdio_priv *mdio_priv;
>
> mdiobus_unregister(bus);
> +
> + enetc_emdio_disable_err050089(pdev);
> +
> mdio_priv = bus->priv;
> iounmap(mdio_priv->hw->port);
> pci_release_region(pdev, 0);
> --
> 2.43.0
Hi Sasha,
This patch does not need to be backported, because i.MX95 NETC is only
supported in the latest kernel (should be 6.13, Linus tree). For the old
kernel, only LS1028A NETC is supported, so this problem does not exist.
Powered by blists - more mailing lists