From patchwork Thu Mar 16 07:45:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 70622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp344132wrt; Thu, 16 Mar 2023 01:00:16 -0700 (PDT) X-Google-Smtp-Source: AK7set90i9TNRBMhkaM+huxWhrS+OK9Lg+Maywvz609E8loSEZ7M+7m9onDLAVNfqdqHW4ExLnhg X-Received: by 2002:a05:6a20:672a:b0:d4:f108:d8d0 with SMTP id q42-20020a056a20672a00b000d4f108d8d0mr2811578pzh.36.1678953616336; Thu, 16 Mar 2023 01:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678953616; cv=none; d=google.com; s=arc-20160816; b=0A4+XDCk1UHBOAKMs4JDucu/G/uW4y9oo9PY2woJuFnmrxyfP2+KaN0Ra8uWDa26Ag QEx4H1bwQjNSlqdSrZHxnFXihA3al6xDL7WewSh8K1lVNsKWJ4iQURJifV4Mv8eqe6nR FyUNIDrLSaba3gySuwl0gfGv4TgiGcL4ZPuueFvmJd3B9H9duoGUM+O/uFAMF0GvJ1wB z9WT6io3EXr33Rsc/qUh42F2ZkVW8AcqxDHpt3qn8i1Lp7N5EpsvaoIQz6mi4LpO0R/S /+m6MAAsfTELD5ALl2pFlOlrDdcspY7pyhE+TNQS9WJh0VHHw4BP4d9nqRLG/1iRdUrE ntiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9j4b9UQqUh5Vb1YkYkzVJJwtv4Cza9dd7EEezfC0qC4=; b=yT5sI8dhAI03VQh2abARG8PrvZmWXVl55Vxr2cPw/ZDlONnTrFFbLqY44rav0WLv8w 12saC4x53/74laSgf+yB6t4FU/Ii81yuONp1/SCMfYgAtVXeA6+LRi+GkK9Gmk1/QhyZ j6kKb5ga+eJLs56dkwZz95N3tpds8jto0u9de0x/anzo1EPwN/+/datO3gz7i32SHZ1r HGcvjAkmS6qXjZ9MU7siKybUrEBgyiqIUA26oOmerlO/HZquRuFjpaOglYhadKBq1153 OsVDVIY2W8vv7VM7CcDepS/bYwU9/P2Npk9aQu2ZtxMeqvDecgFrgGESoMiliu8w4nqf eWig== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=DnI16kGJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l71-20020a63884a000000b0050bf747e913si448643pgd.224.2023.03.16.00.59.59; Thu, 16 Mar 2023 01:00:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=DnI16kGJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbjCPHqW (ORCPT + 99 others); Thu, 16 Mar 2023 03:46:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229866AbjCPHqQ (ORCPT ); Thu, 16 Mar 2023 03:46:16 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA6A0A4B01 for ; Thu, 16 Mar 2023 00:46:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=+IR8pE4hi1ZLE+ 2LyqKA5kfPq/hBxxEmeX0MnGUKI4c=; b=DnI16kGJNgx0M25sW+BCIGFKwh401d 5QyHNd7ALoXBfFpWQEsmiJWv7f2BwI7oQqgTVwYA5GmSS3wVbZYbGtcIa9QtXdh/ TmDQJL8MhOjnh2gCF6s/k+htUsVVeVzDW6TwrrzVQkmAwxrJuFXH52voGidWYp4S 3TxDslnkw9Qf0= Received: (qmail 3694226 invoked from network); 16 Mar 2023 08:46:09 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 16 Mar 2023 08:46:09 +0100 X-UD-Smtp-Session: l3s3148p1@ybFtp//2WJwujnvb From: Wolfram Sang To: netdev@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven , Florian Fainelli , Wolfram Sang , Steve Glendinning , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH 1/2] Revert "net: smsc911x: Make Runtime PM handling more fine-grained" Date: Thu, 16 Mar 2023 08:45:57 +0100 Message-Id: <20230316074558.15268-2-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230316074558.15268-1-wsa+renesas@sang-engineering.com> References: <20230316074558.15268-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760510466996041670?= X-GMAIL-MSGID: =?utf-8?q?1760510466996041670?= This reverts commit 1e30b8d755b81b0d1585cb22bc753e9f2124fe87. Running 'ifconfig' with the interface down BUGs. This is the culprit: smsc911x_get_stats from dev_get_stats+0xe4/0xf4 The above function is called with the clocks off, so register read fails. Enabling clocks in the above functions does not work, because it is called in atomic context. So, let's return to the simple and working PM we had before. Signed-off-by: Wolfram Sang --- drivers/net/ethernet/smsc/smsc911x.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index a2e511912e6a..9d12fd54281a 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -557,7 +557,6 @@ static int smsc911x_mii_read(struct mii_bus *bus, int phyaddr, int regidx) unsigned int addr; int i, reg; - pm_runtime_get_sync(bus->parent); spin_lock_irqsave(&pdata->mac_lock, flags); /* Confirm MII not busy */ @@ -583,7 +582,6 @@ static int smsc911x_mii_read(struct mii_bus *bus, int phyaddr, int regidx) out: spin_unlock_irqrestore(&pdata->mac_lock, flags); - pm_runtime_put(bus->parent); return reg; } @@ -596,7 +594,6 @@ static int smsc911x_mii_write(struct mii_bus *bus, int phyaddr, int regidx, unsigned int addr; int i, reg; - pm_runtime_get_sync(bus->parent); spin_lock_irqsave(&pdata->mac_lock, flags); /* Confirm MII not busy */ @@ -626,7 +623,6 @@ static int smsc911x_mii_write(struct mii_bus *bus, int phyaddr, int regidx, out: spin_unlock_irqrestore(&pdata->mac_lock, flags); - pm_runtime_put(bus->parent); return reg; } @@ -1595,8 +1591,6 @@ static int smsc911x_open(struct net_device *dev) int retval; int irq_flags; - pm_runtime_get_sync(dev->dev.parent); - /* find and start the given phy */ if (!dev->phydev) { retval = smsc911x_mii_probe(dev); @@ -1743,7 +1737,6 @@ static int smsc911x_open(struct net_device *dev) phy_disconnect(dev->phydev); dev->phydev = NULL; out: - pm_runtime_put(dev->dev.parent); return retval; } @@ -1775,7 +1768,6 @@ static int smsc911x_stop(struct net_device *dev) dev->phydev = NULL; } netif_carrier_off(dev); - pm_runtime_put(dev->dev.parent); SMSC_TRACE(pdata, ifdown, "Interface stopped"); return 0; @@ -2347,6 +2339,7 @@ static int smsc911x_drv_remove(struct platform_device *pdev) free_netdev(dev); + pm_runtime_put(&pdev->dev); pm_runtime_disable(&pdev->dev); return 0; @@ -2552,7 +2545,6 @@ static int smsc911x_drv_probe(struct platform_device *pdev) } spin_unlock_irq(&pdata->mac_lock); - pm_runtime_put(&pdev->dev); netdev_info(dev, "MAC Address: %pM\n", dev->dev_addr); From patchwork Thu Mar 16 07:45:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 70619 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp343107wrt; Thu, 16 Mar 2023 00:57:08 -0700 (PDT) X-Google-Smtp-Source: AK7set9HjQXLVPBjbTRq+rU6nE185FpsnRJ8BX25+6LrXUEYTaN7OS1dQ+4+0s4a2a8NpFXjGlGy X-Received: by 2002:a05:6a00:dd:b0:5df:9809:2e95 with SMTP id e29-20020a056a0000dd00b005df98092e95mr1912706pfj.11.1678953428411; Thu, 16 Mar 2023 00:57:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678953428; cv=none; d=google.com; s=arc-20160816; b=kcVhgnNpo8gjnONC4eYoP9t5lrLB7YugP6nakVGDRursEc0xXa3IPDR8h7qzPd0Z7V ek7gjLbCmYoC2U1RK3MtdrrVn1kySvv/NJX0+Kl1LIEk+kWdHgJ7kQtVx1zDAhdGxPwj 2rSuH/B57VelRrCuinByeLRA6NO8NExk9IUYtqL0iiojs5ReXsOp++nskaRBU5TbWU4E yIjGvbJQsHNrfMzF2jysqt/vPonK6M6XYkbkWa/VL3hZLIomuxIsWg4zvLX+i/5DnHdh En9EQ9rLjiEHnODirhd/rDqauyXrGsdMoGqD4oSWsWAEnHCEytV9o7CxEdmmernhq51G AHrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=771nLWRDMs3nABGkT4A3co6RSl7nxm+qAqFso0Qv/tM=; b=xpGdG2IA6u13F38cRwB8T0yqELoceHuXiLdwD8gsqFZy4WtGRFk7pFfwRWXf66V9DI oBkHH43r9KF7Za5WnbXfLpFWA94siQYsRwlouriC3pHyJ/CuFOe3mmLClrmk7XkKTmpX OTrPtREXD7XTijMGQhF0ZpUwKBJeCaV+cXdtVOTPoo9nkBMsL9PbeJfaslmKheo7exjj t3IQYzak2Ka0alcvPTfQRnqgZNZWZQ7571OVVdI9o4ZoAR61KgCRlZdv5KEkhU0lfkx0 L2eb0PqWShdiQF/gFBpWHvg1AIzjE363qlHrsP0PLz8hPPEKlCg7q7YquV7StkS7tI1e QwLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=MP4aeJnD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j28-20020a63551c000000b0050bc14fc7absi7083991pgb.106.2023.03.16.00.56.50; Thu, 16 Mar 2023 00:57:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@sang-engineering.com header.s=k1 header.b=MP4aeJnD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230105AbjCPHq0 (ORCPT + 99 others); Thu, 16 Mar 2023 03:46:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbjCPHqR (ORCPT ); Thu, 16 Mar 2023 03:46:17 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41915A2F0F for ; Thu, 16 Mar 2023 00:46:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=zl2jnjzDWpy3C4 fB7TuVFiW4MYKclvO6XP0vE27XA8A=; b=MP4aeJnDTqGMF504Tj7vAH+ymvPq6/ iwQaNrbgixzVmfBPrGf06njGKslRidfB0Ls7eDVDnht1EP0baYD/SsYBFbfQ4f7m 9qPkg9sFl0V39b3683Ri8LrF1JH0FqMNj0600pQwSGzarUnBD3DR0Afjc0EPQjZn jcb5oiiNBsm0g= Received: (qmail 3694275 invoked from network); 16 Mar 2023 08:46:10 +0100 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 16 Mar 2023 08:46:10 +0100 X-UD-Smtp-Session: l3s3148p1@Kbx3p//2XJwujnvb From: Wolfram Sang To: netdev@vger.kernel.org Cc: linux-renesas-soc@vger.kernel.org, Geert Uytterhoeven , Florian Fainelli , Wolfram Sang , Heiner Kallweit , Steve Glendinning , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org Subject: [PATCH 2/2] smsc911x: avoid PHY being resumed when interface is not up Date: Thu, 16 Mar 2023 08:45:58 +0100 Message-Id: <20230316074558.15268-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230316074558.15268-1-wsa+renesas@sang-engineering.com> References: <20230316074558.15268-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1760510269778039501?= X-GMAIL-MSGID: =?utf-8?q?1760510269778039501?= SMSC911x doesn't need mdiobus suspend/resume, that's why it sets 'mac_managed_pm'. However, setting it needs to be moved from init to probe, so mdiobus PM functions will really never be called (e.g. when the interface is not up yet during suspend/resume). The errno is changed because ENODEV has a special meaning when returned in probe(). Fixes: 3ce9f2bef755 ("net: smsc911x: Stop and start PHY during suspend and resume") Suggested-by: Heiner Kallweit Signed-off-by: Wolfram Sang --- drivers/net/ethernet/smsc/smsc911x.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc911x.c index 9d12fd54281a..4cc5b9833e8f 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -1015,12 +1015,7 @@ static int smsc911x_mii_probe(struct net_device *dev) struct phy_device *phydev = NULL; int ret; - /* find the first phy */ phydev = phy_find_first(pdata->mii_bus); - if (!phydev) { - netdev_err(dev, "no PHY found\n"); - return -ENODEV; - } SMSC_TRACE(pdata, probe, "PHY: addr %d, phy_id 0x%08X", phydev->mdio.addr, phydev->phy_id); @@ -1033,8 +1028,6 @@ static int smsc911x_mii_probe(struct net_device *dev) return ret; } - /* Indicate that the MAC is responsible for managing PHY PM */ - phydev->mac_managed_pm = true; phy_attached_info(phydev); phy_set_max_speed(phydev, SPEED_100); @@ -1062,6 +1055,7 @@ static int smsc911x_mii_init(struct platform_device *pdev, struct net_device *dev) { struct smsc911x_data *pdata = netdev_priv(dev); + struct phy_device *phydev; int err = -ENXIO; pdata->mii_bus = mdiobus_alloc(); @@ -1104,6 +1098,15 @@ static int smsc911x_mii_init(struct platform_device *pdev, goto err_out_free_bus_2; } + phydev = phy_find_first(pdata->mii_bus); + if (!phydev) { + netdev_err(dev, "no PHY found\n"); + err = -ENOENT; + goto err_out_free_bus_2; + } + + phydev->mac_managed_pm = true; + return 0; err_out_free_bus_2: