From patchwork Wed Sep 11 21:27:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Chevallier X-Patchwork-Id: 13801128 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 56A3CEE57D7 for ; Wed, 11 Sep 2024 21:28:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=SuxJgxEerzFtn5NODnwFgah+RUsv6TT5UGmu+5Xa848=; b=qFPZztqZox9pVV+jsjOJ0BmuS9 QJqUGbJAZsOl93Q/B4RQQg/G8pvuM10bDU2DeSSnBEtW9CI6dDTR6i6x0x+CFVtGlcyMZnWwgWFFl NbEDjRJgHBP9s0C9CShymMOTVfUf+NDaOKGEDIlYE5ZwbZxV6prXQV+RGOHc3tf9jF5w2yU12U49h w5vfgs1ye6YGCL8EG9N4+uOJ0JvNJF/TcDKdDzolm8MZwzZP4AQ248M8qfSDnABMN6Vqa5aelYxBh T8b4pwTTOCb5+a023reIzQ5wdZq85KKR/e3uVSYekpnVss7vseFtd+JFeGZXoJdYntiuV/dYpZQyI 2POlrA1g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1soUt1-0000000B3RK-0Sgc; Wed, 11 Sep 2024 21:28:27 +0000 Received: from relay5-d.mail.gandi.net ([2001:4b98:dc4:8::225]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1soUrw-0000000B3Bc-2Yx0 for linux-arm-kernel@lists.infradead.org; Wed, 11 Sep 2024 21:27:22 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 3E6FA1C0003; Wed, 11 Sep 2024 21:27:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1726090039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SuxJgxEerzFtn5NODnwFgah+RUsv6TT5UGmu+5Xa848=; b=GdEnD/oidgYXzEkLwRFvbhcxVFoZiSIOA1TQ4oS8U2KzVlFicJreHBfWq2WAV3fY2CdpxN C+Nk/8lslx6XnDQfAI/IiNxgSAUz5r08L/MTgjRqZ1AYj6yYeTs67p1exeeD0djLrKtfcs auwKoj04AtDh+SUnmD1mulryVQWauaIuIBsxVV+y5sSgGdwoKV5Mdfsz0Ig4KnpC5gLFUf g4GK1es0TuLVv/WpAaP2JNM6yhgV3sQnRce4paI5LClQ3X8qzPnQ7NIiSQAoIwcw+i1ApH 3KK+FXDy+dUnV+3omhXocAxmuQjLQ7nbRZHGz+emld+txPGkl0YFllUdstx7gg== From: Maxime Chevallier To: davem@davemloft.net Cc: Maxime Chevallier , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, Andrew Lunn , Jakub Kicinski , Eric Dumazet , Paolo Abeni , Russell King , linux-arm-kernel@lists.infradead.org, Christophe Leroy , Herve Codina , Florian Fainelli , Heiner Kallweit , Vladimir Oltean , =?utf-8?q?Marek_Beh=C3=BAn?= , =?utf-8?q?K=C3=B6ry_Maince?= =?utf-8?q?nt?= , Oleksij Rempel Subject: [PATCH net-next 2/7] net: phy: Allow flagging PHY devices that can't isolate their MII Date: Wed, 11 Sep 2024 23:27:06 +0200 Message-ID: <20240911212713.2178943-3-maxime.chevallier@bootlin.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911212713.2178943-1-maxime.chevallier@bootlin.com> References: <20240911212713.2178943-1-maxime.chevallier@bootlin.com> MIME-Version: 1.0 X-GND-Sasl: maxime.chevallier@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240911_142720_877288_FDFAB816 X-CRM114-Status: UNSURE ( 8.90 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Some PHYs have malfunctionning isolation modes, where the MII lines aren't correctly set in high-impedance, potentially interfering with the MII bus in unexpected ways. Some other PHYs simply don't support it. Allow flagging these PHYs, and prevent isolating them altogether. Assume the PHY can isolate by default. Signed-off-by: Maxime Chevallier --- drivers/net/phy/phy_device.c | 11 +++++++++++ include/linux/phy.h | 1 + 2 files changed, 12 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index c468e72bef4b..2a3db1043626 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2127,6 +2127,14 @@ int phy_loopback(struct phy_device *phydev, bool enable) } EXPORT_SYMBOL(phy_loopback); +static bool phy_can_isolate(struct phy_device *phydev) +{ + if (phydev->drv) + return !(phydev->drv->flags & PHY_NO_ISOLATE); + + return true; +} + int phy_isolate(struct phy_device *phydev, bool enable) { int ret = 0; @@ -2134,6 +2142,9 @@ int phy_isolate(struct phy_device *phydev, bool enable) if (!phydev->drv) return -EIO; + if (!phy_can_isolate(phydev)) + return -EOPNOTSUPP; + mutex_lock(&phydev->lock); if (enable && phydev->isolated) { diff --git a/include/linux/phy.h b/include/linux/phy.h index ae33919aa0f5..f0a8a5459fbe 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -90,6 +90,7 @@ extern const int phy_10gbit_features_array[1]; #define PHY_RST_AFTER_CLK_EN 0x00000002 #define PHY_POLL_CABLE_TEST 0x00000004 #define PHY_ALWAYS_CALL_SUSPEND 0x00000008 +#define PHY_NO_ISOLATE 0x00000010 #define MDIO_DEVICE_IS_PHY 0x80000000 /**