]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net: lan743x: Restore SGMII CTRL register on resume
authorThangaraj Samynathan <thangaraj.s@microchip.com>
Fri, 16 May 2025 03:57:19 +0000 (09:27 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Jun 2025 12:40:19 +0000 (14:40 +0200)
[ Upstream commit 293e38ff4e4c2ba53f3fd47d8a4a9f0f0414a7a6 ]

SGMII_CTRL register, which specifies the active interface, was not
properly restored when resuming from suspend. This led to incorrect
interface selection after resume particularly in scenarios involving
the FPGA.

To fix this:
- Move the SGMII_CTRL setup out of the probe function.
- Initialize the register in the hardware initialization helper function,
which is called during both device initialization and resume.

This ensures the interface configuration is consistently restored after
suspend/resume cycles.

Fixes: a46d9d37c4f4f ("net: lan743x: Add support for SGMII interface")
Signed-off-by: Thangaraj Samynathan <thangaraj.s@microchip.com>
Link: https://patch.msgid.link/20250516035719.117960-1-thangaraj.s@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/microchip/lan743x_main.c

index 2e69ba0143b15b2e138a1043b026e173ceba8989..fd3555419179336f4cd01611aa6ecaeff296ade3 100644 (file)
@@ -3253,6 +3253,7 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
                                 struct pci_dev *pdev)
 {
        struct lan743x_tx *tx;
+       u32 sgmii_ctl;
        int index;
        int ret;
 
@@ -3265,6 +3266,15 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
                spin_lock_init(&adapter->eth_syslock_spinlock);
                mutex_init(&adapter->sgmii_rw_lock);
                pci11x1x_set_rfe_rd_fifo_threshold(adapter);
+               sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL);
+               if (adapter->is_sgmii_en) {
+                       sgmii_ctl |= SGMII_CTL_SGMII_ENABLE_;
+                       sgmii_ctl &= ~SGMII_CTL_SGMII_POWER_DN_;
+               } else {
+                       sgmii_ctl &= ~SGMII_CTL_SGMII_ENABLE_;
+                       sgmii_ctl |= SGMII_CTL_SGMII_POWER_DN_;
+               }
+               lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl);
        } else {
                adapter->max_tx_channels = LAN743X_MAX_TX_CHANNELS;
                adapter->used_tx_channels = LAN743X_USED_TX_CHANNELS;
@@ -3313,7 +3323,6 @@ static int lan743x_hardware_init(struct lan743x_adapter *adapter,
 
 static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)
 {
-       u32 sgmii_ctl;
        int ret;
 
        adapter->mdiobus = devm_mdiobus_alloc(&adapter->pdev->dev);
@@ -3325,10 +3334,6 @@ static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)
        adapter->mdiobus->priv = (void *)adapter;
        if (adapter->is_pci11x1x) {
                if (adapter->is_sgmii_en) {
-                       sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL);
-                       sgmii_ctl |= SGMII_CTL_SGMII_ENABLE_;
-                       sgmii_ctl &= ~SGMII_CTL_SGMII_POWER_DN_;
-                       lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl);
                        netif_dbg(adapter, drv, adapter->netdev,
                                  "SGMII operation\n");
                        adapter->mdiobus->probe_capabilities = MDIOBUS_C22_C45;
@@ -3338,10 +3343,6 @@ static int lan743x_mdiobus_init(struct lan743x_adapter *adapter)
                        netif_dbg(adapter, drv, adapter->netdev,
                                  "lan743x-mdiobus-c45\n");
                } else {
-                       sgmii_ctl = lan743x_csr_read(adapter, SGMII_CTL);
-                       sgmii_ctl &= ~SGMII_CTL_SGMII_ENABLE_;
-                       sgmii_ctl |= SGMII_CTL_SGMII_POWER_DN_;
-                       lan743x_csr_write(adapter, SGMII_CTL, sgmii_ctl);
                        netif_dbg(adapter, drv, adapter->netdev,
                                  "RGMII operation\n");
                        // Only C22 support when RGMII I/F