From patchwork Fri Dec 16 14:49:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enguerrand de Ribaucourt X-Patchwork-Id: 13075060 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D1B2C4332F for ; Fri, 16 Dec 2022 14:58:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231203AbiLPO6P (ORCPT ); Fri, 16 Dec 2022 09:58:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231156AbiLPO6N (ORCPT ); Fri, 16 Dec 2022 09:58:13 -0500 X-Greylist: delayed 495 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Fri, 16 Dec 2022 06:58:10 PST Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF3E75E088 for ; Fri, 16 Dec 2022 06:58:10 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 080309C06BB; Fri, 16 Dec 2022 09:49:53 -0500 (EST) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Bt7EKfj-ww65; Fri, 16 Dec 2022 09:49:52 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 66F469C085C; Fri, 16 Dec 2022 09:49:52 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 66F469C085C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1671202192; bh=OIf2oVc4shHaR4T3FvAtzOKGfSx4IePKhRdfrtWEdHo=; h=From:To:Date:Message-Id:MIME-Version; b=J1nl5YiD/ysBRngYjyrnJBupE0GagbFrDgOnY07/gCh7Tlb8Gt/v8O2k2Rjc5EtIE mrYCFiHNgi4i4fZSdq2QBbadQ0CHY8x/uc++un8pr2aWb317Rl8QpOplpv3RO6sf4J Wy5W3qAT2HPkHzAE7Wyxh77f8uXJPFZEPpCE7CSCTfJI4jU6lll7vFQFbGPW9EbPv0 o81+PCPAl1RBONUjFpx4XP5dMaVKJr2J5KRZC8W0XqtL8qp6EEOXXAZ2Fe3rZBuB4N aISlNwdly6+yUAJGOXhA/f8NBQRKDeXbWeS1u797dTbvjyOiPandTpENYziUk0ZKcu 2aczyKcDD3C5w== X-Virus-Scanned: amavisd-new at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id GKDH-SG6qK8f; Fri, 16 Dec 2022 09:49:52 -0500 (EST) Received: from sfl-deribaucourt.rennes.sfl (lmontsouris-657-1-69-118.w80-15.abo.wanadoo.fr [80.15.101.118]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 8F6729C06BB; Fri, 16 Dec 2022 09:49:51 -0500 (EST) From: Enguerrand de Ribaucourt To: netdev@vger.kernel.org Cc: woojung.huh@microchip.com, davem@davemloft.net, UNGLinuxDriver@microchip.com, Enguerrand de Ribaucourt Subject: [PATCH] net: lan78xx: isolate LAN88XX specific operations Date: Fri, 16 Dec 2022 15:49:11 +0100 Message-Id: <20221216144910.1416322-1-enguerrand.de-ribaucourt@savoirfairelinux.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <9235D6609DB808459E95D78E17F2E43D408987FF@CHN-SV-EXMX02.mchp-main.com> References: <9235D6609DB808459E95D78E17F2E43D408987FF@CHN-SV-EXMX02.mchp-main.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Some operations during the cable switch workaround modify the register LAN88XX_INT_MASK of the PHY. However, this register is specific to the LAN8835 PHY. For instance, if a DP8322I PHY is connected to the LAN7801, that register (0x19), corresponds to the LED and MAC address configuration, resulting in unapropriate behavior. Fixes: 14437e3fa284 ("lan78xx: workaround of forced 100 Full/Half duplex mode error") Signed-off-by: Enguerrand de Ribaucourt --- drivers/net/usb/lan78xx.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index f18ab8e220db..ea0a56e6cd40 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -2116,6 +2116,7 @@ static void lan78xx_link_status_change(struct net_device *net) { struct phy_device *phydev = net->phydev; int temp; + bool lan88_fixup; /* At forced 100 F/H mode, chip may fail to set mode correctly * when cable is switched between long(~50+m) and short one. @@ -2123,10 +2124,15 @@ static void lan78xx_link_status_change(struct net_device *net) * at forced 100 F/H mode. */ if (!phydev->autoneg && (phydev->speed == 100)) { - /* disable phy interrupt */ - temp = phy_read(phydev, LAN88XX_INT_MASK); - temp &= ~LAN88XX_INT_MASK_MDINTPIN_EN_; - phy_write(phydev, LAN88XX_INT_MASK, temp); + lan88_fixup = (PHY_LAN8835 & 0xfffffff0) == + (phydev->phy_id & 0xfffffff0); + + if(lan88_fixup) { + /* disable phy interrupt */ + temp = phy_read(phydev, LAN88XX_INT_MASK); + temp &= ~LAN88XX_INT_MASK_MDINTPIN_EN_; + phy_write(phydev, LAN88XX_INT_MASK, temp); + } temp = phy_read(phydev, MII_BMCR); temp &= ~(BMCR_SPEED100 | BMCR_SPEED1000); @@ -2134,13 +2140,15 @@ static void lan78xx_link_status_change(struct net_device *net) temp |= BMCR_SPEED100; phy_write(phydev, MII_BMCR, temp); /* set to 100 later */ - /* clear pending interrupt generated while workaround */ - temp = phy_read(phydev, LAN88XX_INT_STS); + if(lan88_fixup) { + /* clear pending interrupt generated while workaround */ + temp = phy_read(phydev, LAN88XX_INT_STS); - /* enable phy interrupt back */ - temp = phy_read(phydev, LAN88XX_INT_MASK); - temp |= LAN88XX_INT_MASK_MDINTPIN_EN_; - phy_write(phydev, LAN88XX_INT_MASK, temp); + /* enable phy interrupt back */ + temp = phy_read(phydev, LAN88XX_INT_MASK); + temp |= LAN88XX_INT_MASK_MDINTPIN_EN_; + phy_write(phydev, LAN88XX_INT_MASK, temp); + } } } From patchwork Tue Dec 20 13:19:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enguerrand de Ribaucourt X-Patchwork-Id: 13077873 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 18A89C4332F for ; Tue, 20 Dec 2022 13:20:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232097AbiLTNUG (ORCPT ); Tue, 20 Dec 2022 08:20:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229738AbiLTNT5 (ORCPT ); Tue, 20 Dec 2022 08:19:57 -0500 Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 321F712D2C for ; Tue, 20 Dec 2022 05:19:57 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 7DD0C9C088F; Tue, 20 Dec 2022 08:19:56 -0500 (EST) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 1mfUxQx6ywwF; Tue, 20 Dec 2022 08:19:56 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 028BC9C088E; Tue, 20 Dec 2022 08:19:56 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com 028BC9C088E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1671542396; bh=97D5Z7h3Lq5wflhCB8z4Yu12HSf/KW4FuyDiFN1xmns=; h=From:To:Date:Message-Id:MIME-Version; b=KW7EHJAkSaSQU35gTAcOYok51+FDbvtf7xu573DiHcq18fPgQSkA9G6Ndjd70HPE8 Tmeo2XfM2zfACkDR8ChLhjO0VBomBIE32K8xhNP9qTf5qKMiblDOJd6gNIm7+gz8GZ 32K02PgHKnheCNbPDnCs8CUudhFfeTOsnqW9wU4LFlQ7vsJDOW+XtbHuFedwLAwHhy c/kXzNGsoe+wwu+Uu1UkEA+34d9VNbLlxyvPH2JxfoLKqH+bG8ObRe0d3djLYVE06Z k1cddYv9y/oieRVXKlvL1ijuDSE0RMGZvvRKWwEvEwsf07ubdynE9zyAjw0mApR7Mk PTYvPLiJSy94Q== X-Virus-Scanned: amavisd-new at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id XyOt_dRSzLij; Tue, 20 Dec 2022 08:19:55 -0500 (EST) Received: from sfl-deribaucourt.rennes.sfl (mtl.savoirfairelinux.net [192.168.50.3]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 192FC9C088F; Tue, 20 Dec 2022 08:19:55 -0500 (EST) From: Enguerrand de Ribaucourt To: netdev@vger.kernel.org Cc: pabeni@redhat.com, woojung.huh@microchip.com, davem@davemloft.net, UNGLinuxDriver@microchip.com, Enguerrand de Ribaucourt Subject: [PATCH v3 2/3] net: phy: make phy_enable_interrupts() non-static Date: Tue, 20 Dec 2022 14:19:22 +0100 Message-Id: <20221220131921.806365-3-enguerrand.de-ribaucourt@savoirfairelinux.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <9235D6609DB808459E95D78E17F2E43D408987FF@CHN-SV-EXMX02.mchp-main.com> References: <9235D6609DB808459E95D78E17F2E43D408987FF@CHN-SV-EXMX02.mchp-main.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Currently, phy_disable_interrupts() allows to disable interrupts without freeing them. However, the only exported function to re-enable them is phy_request_interrupt(), which also requests them again. It should be possible to re-enable interrupts without re-allocating them. This is required for lan78xx.c where we want to enable/disable the phy interrupts during lan78xx_link_status_change(). Signed-off-by: Enguerrand de Ribaucourt --- drivers/net/phy/phy.c | 3 ++- include/linux/phy.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 33250da76466..4168cf54aa59 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1040,10 +1040,11 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat) * phy_enable_interrupts - Enable the interrupts from the PHY side * @phydev: target phy_device struct */ -static int phy_enable_interrupts(struct phy_device *phydev) +int phy_enable_interrupts(struct phy_device *phydev) { return phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED); } +EXPORT_SYMBOL(phy_enable_interrupts); /** * phy_request_interrupt - request and enable interrupt for a PHY device diff --git a/include/linux/phy.h b/include/linux/phy.h index 71eeb4e3b1fd..d2350f0dc566 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1715,6 +1715,7 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd); int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd); int phy_disable_interrupts(struct phy_device *phydev); +int phy_enable_interrupts(struct phy_device *phydev); void phy_request_interrupt(struct phy_device *phydev); void phy_free_interrupt(struct phy_device *phydev); void phy_print_status(struct phy_device *phydev); From patchwork Tue Dec 20 13:19:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Enguerrand de Ribaucourt X-Patchwork-Id: 13077872 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1772C4332F for ; Tue, 20 Dec 2022 13:20:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232283AbiLTNUE (ORCPT ); Tue, 20 Dec 2022 08:20:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230235AbiLTNT6 (ORCPT ); Tue, 20 Dec 2022 08:19:58 -0500 Received: from mail.savoirfairelinux.com (mail.savoirfairelinux.com [208.88.110.44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2311311A02 for ; Tue, 20 Dec 2022 05:19:58 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id 7AB419C0896; Tue, 20 Dec 2022 08:19:57 -0500 (EST) Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id YNQL6nAXMba7; Tue, 20 Dec 2022 08:19:57 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by mail.savoirfairelinux.com (Postfix) with ESMTP id F3F8A9C088E; Tue, 20 Dec 2022 08:19:56 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.savoirfairelinux.com F3F8A9C088E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=savoirfairelinux.com; s=DFC430D2-D198-11EC-948E-34200CB392D2; t=1671542397; bh=coGhhtpSMNtwpb5pSpFdVKVrvxeZic6SB0iZG2SHK04=; h=From:To:Date:Message-Id:MIME-Version; b=twZkbCIXkjlOhi+cy5dicecjQhvD/jf2s6ATsYi07VEI871TI7NMFz5n8xaS+ogyD XEHgQmQYI7T36attu8Cqi1+BZ/jwY7al/NlHlmTaY7WfmQPEQ+2mpbZfec/tHCMKXG c+SetbH2yoOltZWi3AgDTbM2o8DDg4fU9dnGZEgIlBzGuZtnQ4lS3A2TJhzQyQskWU rL+e3XBcfR/ubaSa8vSY+gZb+0NqvXMZQcZxu+0csvPqCpfXwQJg7heKpThsb+PwDA 7ACCHZ2AABiWZLP3/5IHNhGQQHuJEP2u/xRDiCvuSs0x5Bz/8/8CkehDpX0r/AyxR/ nUe8lRY7QBiow== X-Virus-Scanned: amavisd-new at mail.savoirfairelinux.com Received: from mail.savoirfairelinux.com ([127.0.0.1]) by localhost (mail.savoirfairelinux.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id JFeWIOsbG9xQ; Tue, 20 Dec 2022 08:19:56 -0500 (EST) Received: from sfl-deribaucourt.rennes.sfl (mtl.savoirfairelinux.net [192.168.50.3]) by mail.savoirfairelinux.com (Postfix) with ESMTPSA id 1909F9C0896; Tue, 20 Dec 2022 08:19:56 -0500 (EST) From: Enguerrand de Ribaucourt To: netdev@vger.kernel.org Cc: pabeni@redhat.com, woojung.huh@microchip.com, davem@davemloft.net, UNGLinuxDriver@microchip.com, Enguerrand de Ribaucourt Subject: [PATCH v3 3/3] net: lan78xx: prevent LAN88XX specific operations Date: Tue, 20 Dec 2022 14:19:23 +0100 Message-Id: <20221220131921.806365-4-enguerrand.de-ribaucourt@savoirfairelinux.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <9235D6609DB808459E95D78E17F2E43D408987FF@CHN-SV-EXMX02.mchp-main.com> References: <9235D6609DB808459E95D78E17F2E43D408987FF@CHN-SV-EXMX02.mchp-main.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Some operations during the cable switch workaround modify the register LAN88XX_INT_MASK of the PHY. However, this register is specific to the LAN8835 PHY. For instance, if a DP8322I PHY is connected to the LAN7801, that register (0x19), corresponds to the LED and MAC address configuration, resulting in unapropriate behavior. Use the generic phy interrupt functions instead. Fixes: 89b36fb5e532 ("lan78xx: Lan7801 Support for Fixed PHY") Signed-off-by: Enguerrand de Ribaucourt --- drivers/net/usb/lan78xx.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c index f18ab8e220db..0f279082b924 100644 --- a/drivers/net/usb/lan78xx.c +++ b/drivers/net/usb/lan78xx.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "lan78xx.h" #define DRIVER_AUTHOR "WOOJUNG HUH " @@ -2123,10 +2124,7 @@ static void lan78xx_link_status_change(struct net_device *net) * at forced 100 F/H mode. */ if (!phydev->autoneg && (phydev->speed == 100)) { - /* disable phy interrupt */ - temp = phy_read(phydev, LAN88XX_INT_MASK); - temp &= ~LAN88XX_INT_MASK_MDINTPIN_EN_; - phy_write(phydev, LAN88XX_INT_MASK, temp); + phy_disable_interrupts(phydev); temp = phy_read(phydev, MII_BMCR); temp &= ~(BMCR_SPEED100 | BMCR_SPEED1000); @@ -2134,13 +2132,7 @@ static void lan78xx_link_status_change(struct net_device *net) temp |= BMCR_SPEED100; phy_write(phydev, MII_BMCR, temp); /* set to 100 later */ - /* clear pending interrupt generated while workaround */ - temp = phy_read(phydev, LAN88XX_INT_STS); - - /* enable phy interrupt back */ - temp = phy_read(phydev, LAN88XX_INT_MASK); - temp |= LAN88XX_INT_MASK_MDINTPIN_EN_; - phy_write(phydev, LAN88XX_INT_MASK, temp); + phy_enable_interrupts(phydev); } }