Message ID | 20221228164008.1653348-2-michael@walle.cc |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1981797wrt; Wed, 28 Dec 2022 08:46:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXvH//jfrYz2OH1V/DleOzi0LA8NTAhO2nezgw7DrLgk4tj9bJQjhJNKs2asJ74TSMHXn1wP X-Received: by 2002:a17:907:d389:b0:7c1:5a37:825 with SMTP id vh9-20020a170907d38900b007c15a370825mr30010182ejc.34.1672245982140; Wed, 28 Dec 2022 08:46:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672245982; cv=none; d=google.com; s=arc-20160816; b=SK+Pm5SkAMpuQIdSz2kQmcVumEd+eKA+iJTKyBm5AIvmqa5i7De/K3Tc9DoHC3Y9tz 9FhXEz2ikIoXK36Fw4cmbMmt2y9C9XpFa28oZQ4ltWJczdlP5P/6aIMTdlMQiDl/fk4a UQY5vTB57+sIL2WI3O6RjzFtl7bAJnPOy+annBCxCQfHUaUUQ7jWzc1cxQ3brf+ycsNx SNqGr+Jz+udGGuJU9AJzYyjkUA4O5tA4eCelHpwKE2/iKBgzX0a3MxaP8g358KSxHKOu 7RvsqJLUz0K8bZZr84YIwF80lP4rAwUZgZlb0TE/cgjdrm7s6yhjXazpK2v2PZ8mF8LJ ZzAA== 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=fOtac2haGHAAUtssRyLivkuvpvDLBROt7UT90bRGM7w=; b=FIxzqsxAeDe3T5PGcqsZ1LiQ8XOlPa5hPcd1AKI+Qbc9jJVvBablAQG7AqA3Bp51Wj 8en4QImHL/EIqotviY6/93hQyIzPcH+m7LD9cSlocUOme0kBD4fK5WOF+bQTlgcjX6ID Sgo88U82Vd6szYxt4ycdnYLerQr6jLBYoZ48w8FJ+Ye1UtzTxQ543tntkfc1E5EwO7qy JYbXgnpnNVjw3gkO5FASJsF+6ULX2cqGU9T9d13217yFG3iV9obLX5KK2I8JfU936S64 FIRG+e2JkQ/32VptEDvmuKECFohvUOlTBUHdVA7zunCTLCusvDWQFv72i9nC2BZpaoOl u0ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@walle.cc header.s=mail2022082101 header.b=SkCJSnkO; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id uj42-20020a170907c9aa00b0084c3ce2f3e5si7417383ejc.321.2022.12.28.08.45.58; Wed, 28 Dec 2022 08:46:22 -0800 (PST) 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=pass header.i=@walle.cc header.s=mail2022082101 header.b=SkCJSnkO; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=walle.cc Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235078AbiL1QpI (ORCPT <rfc822;eddaouddi.ayoub@gmail.com> + 99 others); Wed, 28 Dec 2022 11:45:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233732AbiL1Qoe (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 28 Dec 2022 11:44:34 -0500 Received: from mail.3ffe.de (0001.3ffe.de [159.69.201.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F215B1CB1D; Wed, 28 Dec 2022 08:40:15 -0800 (PST) Received: from mwalle01.kontron.local. (unknown [213.135.10.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.3ffe.de (Postfix) with ESMTPSA id D7A46164F; Wed, 28 Dec 2022 17:40:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=walle.cc; s=mail2022082101; t=1672245614; 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=fOtac2haGHAAUtssRyLivkuvpvDLBROt7UT90bRGM7w=; b=SkCJSnkOQzbb51y62g2o9GTW7ibk+LHtcVZDiiZHcOAdYnK5DQaEImB0DZsscfYU1X2mwb kU9LU6+psIJjOpWlNu9zFNrs1AhFgaixgpqwoYfUppjaN8RJdu4E4DVl1oMlpZ2wWS5Kzh E1nsID//If9yDHArPYbIueNCIpcxMz2j0S2saiE3/09GwhEGmbNT/54jsg8A7C6mWUFnjo UzShh5ffQtfmiU8sIhmJavL0+e3Be7w/gTn9nld0T5Qw3+VIgTY3wgQR9JC8Wx29TS/RML lHf26yoenBQqHtFbCx8BdWX/+0FlI/X+qwAXwdYqcbXCn5TFeFmP766W+7KpZA== From: Michael Walle <michael@walle.cc> To: Xu Liang <lxu@maxlinear.com>, Andrew Lunn <andrew@lunn.ch>, Heiner Kallweit <hkallweit1@gmail.com>, Russell King <linux@armlinux.org.uk>, "David S . Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Michael Walle <michael@walle.cc> Subject: [PATCH RFC net-next v2 1/2] net: phy: allow a phy to opt-out of interrupt handling Date: Wed, 28 Dec 2022 17:40:07 +0100 Message-Id: <20221228164008.1653348-2-michael@walle.cc> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221228164008.1653348-1-michael@walle.cc> References: <20221228164008.1653348-1-michael@walle.cc> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753477002945246493?= X-GMAIL-MSGID: =?utf-8?q?1753477002945246493?= |
Series |
net: phy: mxl-gpy: broken interrupt fixes
|
|
Commit Message
Michael Walle
Dec. 28, 2022, 4:40 p.m. UTC
Until now, it is not possible for a PHY driver to disable interrupts
during runtime. If a driver offers the .config_intr() as well as the
.handle_interrupt() ops, it is eligible for interrupt handling.
Introduce a new flag for the dev_flags property of struct phy_device, which
can be set by PHY driver to skip interrupt setup and fall back to polling
mode.
At the moment, this is used for the MaxLinear PHY which has broken
interrupt handling and there is a need to disable interrupts in some
cases.
Signed-off-by: Michael Walle <michael@walle.cc>
---
drivers/net/phy/phy_device.c | 7 +++++++
include/linux/phy.h | 2 ++
2 files changed, 9 insertions(+)
Comments
On 12/28/2022 8:40 AM, Michael Walle wrote: > Until now, it is not possible for a PHY driver to disable interrupts > during runtime. If a driver offers the .config_intr() as well as the > .handle_interrupt() ops, it is eligible for interrupt handling. > Introduce a new flag for the dev_flags property of struct phy_device, which > can be set by PHY driver to skip interrupt setup and fall back to polling > mode. > > At the moment, this is used for the MaxLinear PHY which has broken > interrupt handling and there is a need to disable interrupts in some > cases. > > Signed-off-by: Michael Walle <michael@walle.cc> > --- > drivers/net/phy/phy_device.c | 7 +++++++ > include/linux/phy.h | 2 ++ > 2 files changed, 9 insertions(+) > > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > index 716870a4499c..e4562859ac00 100644 > --- a/drivers/net/phy/phy_device.c > +++ b/drivers/net/phy/phy_device.c > @@ -1487,6 +1487,13 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, > > phydev->interrupts = PHY_INTERRUPT_DISABLED; > > + /* PHYs can request to use poll mode even though they have an > + * associated interrupt line. This could be the case if they > + * detect a broken interrupt handling. > + */ > + if (phydev->dev_flags & PHY_F_NO_IRQ) > + phydev->irq = PHY_POLL; Cannot you achieve the same thing with the PHY driver mangling phydev->irq to a negative value, or is that too later already by the time your phy driver's probe function is running? > + > /* Port is set to PORT_TP by default and the actual PHY driver will set > * it to different value depending on the PHY configuration. If we have > * the generic PHY driver we can't figure it out, thus set the old > diff --git a/include/linux/phy.h b/include/linux/phy.h > index 71eeb4e3b1fd..f1566c7e47a8 100644 > --- a/include/linux/phy.h > +++ b/include/linux/phy.h > @@ -82,6 +82,8 @@ extern const int phy_10gbit_features_array[1]; > #define PHY_POLL_CABLE_TEST 0x00000004 > #define MDIO_DEVICE_IS_PHY 0x80000000 > > +#define PHY_F_NO_IRQ 0x80000000 Kudos for using the appropriate namespace for dev_flags :)
On Wed, Dec 28, 2022 at 08:49:35AM -0800, Florian Fainelli wrote: > > > On 12/28/2022 8:40 AM, Michael Walle wrote: > > Until now, it is not possible for a PHY driver to disable interrupts > > during runtime. If a driver offers the .config_intr() as well as the > > .handle_interrupt() ops, it is eligible for interrupt handling. > > Introduce a new flag for the dev_flags property of struct phy_device, which > > can be set by PHY driver to skip interrupt setup and fall back to polling > > mode. > > > > At the moment, this is used for the MaxLinear PHY which has broken > > interrupt handling and there is a need to disable interrupts in some > > cases. > > > > Signed-off-by: Michael Walle <michael@walle.cc> > > --- > > drivers/net/phy/phy_device.c | 7 +++++++ > > include/linux/phy.h | 2 ++ > > 2 files changed, 9 insertions(+) > > > > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > > index 716870a4499c..e4562859ac00 100644 > > --- a/drivers/net/phy/phy_device.c > > +++ b/drivers/net/phy/phy_device.c > > @@ -1487,6 +1487,13 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, > > phydev->interrupts = PHY_INTERRUPT_DISABLED; > > + /* PHYs can request to use poll mode even though they have an > > + * associated interrupt line. This could be the case if they > > + * detect a broken interrupt handling. > > + */ > > + if (phydev->dev_flags & PHY_F_NO_IRQ) > > + phydev->irq = PHY_POLL; > > Cannot you achieve the same thing with the PHY driver mangling phydev->irq > to a negative value, or is that too later already by the time your phy > driver's probe function is running? It is actually to early. The interrupt is requested when the MAC attaches the PHY. There are is at least one MAC driver which assigns the phydev->irq just before attaching the PHY, a long time after the PHY has probed. Andrew
On Wed, Dec 28, 2022 at 08:49:35AM -0800, Florian Fainelli wrote: > > > On 12/28/2022 8:40 AM, Michael Walle wrote: > > Until now, it is not possible for a PHY driver to disable interrupts > > during runtime. If a driver offers the .config_intr() as well as the > > .handle_interrupt() ops, it is eligible for interrupt handling. > > Introduce a new flag for the dev_flags property of struct phy_device, which > > can be set by PHY driver to skip interrupt setup and fall back to polling > > mode. > > > > At the moment, this is used for the MaxLinear PHY which has broken > > interrupt handling and there is a need to disable interrupts in some > > cases. > > > > Signed-off-by: Michael Walle <michael@walle.cc> > > --- > > drivers/net/phy/phy_device.c | 7 +++++++ > > include/linux/phy.h | 2 ++ > > 2 files changed, 9 insertions(+) > > > > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > > index 716870a4499c..e4562859ac00 100644 > > --- a/drivers/net/phy/phy_device.c > > +++ b/drivers/net/phy/phy_device.c > > @@ -1487,6 +1487,13 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, > > phydev->interrupts = PHY_INTERRUPT_DISABLED; > > + /* PHYs can request to use poll mode even though they have an > > + * associated interrupt line. This could be the case if they > > + * detect a broken interrupt handling. > > + */ > > + if (phydev->dev_flags & PHY_F_NO_IRQ) > > + phydev->irq = PHY_POLL; > > Cannot you achieve the same thing with the PHY driver mangling phydev->irq > to a negative value, or is that too later already by the time your phy > driver's probe function is running? > > > + > > /* Port is set to PORT_TP by default and the actual PHY driver will set > > * it to different value depending on the PHY configuration. If we have > > * the generic PHY driver we can't figure it out, thus set the old > > diff --git a/include/linux/phy.h b/include/linux/phy.h > > index 71eeb4e3b1fd..f1566c7e47a8 100644 > > --- a/include/linux/phy.h > > +++ b/include/linux/phy.h > > @@ -82,6 +82,8 @@ extern const int phy_10gbit_features_array[1]; > > #define PHY_POLL_CABLE_TEST 0x00000004 > > #define MDIO_DEVICE_IS_PHY 0x80000000 > > +#define PHY_F_NO_IRQ 0x80000000 > > Kudos for using the appropriate namespace for dev_flags :) But eww for placement. PHY_IS_INTERNAL, PHY_RST_AFTER_CLK_EN, PHY_POLL_CABLE_TEST and MDIO_DEVICE_IS_PHY are all used for the MDIO driver's flags member. This new flag is used for the .dev_flags of phy_device - I feel that it should be separated from the above definitions. I also think it could do with a comment, because it's not obvious for future changes that PHY_F_NO_IRQ is used with .dev_flags.
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 716870a4499c..e4562859ac00 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -1487,6 +1487,13 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, phydev->interrupts = PHY_INTERRUPT_DISABLED; + /* PHYs can request to use poll mode even though they have an + * associated interrupt line. This could be the case if they + * detect a broken interrupt handling. + */ + if (phydev->dev_flags & PHY_F_NO_IRQ) + phydev->irq = PHY_POLL; + /* Port is set to PORT_TP by default and the actual PHY driver will set * it to different value depending on the PHY configuration. If we have * the generic PHY driver we can't figure it out, thus set the old diff --git a/include/linux/phy.h b/include/linux/phy.h index 71eeb4e3b1fd..f1566c7e47a8 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -82,6 +82,8 @@ extern const int phy_10gbit_features_array[1]; #define PHY_POLL_CABLE_TEST 0x00000004 #define MDIO_DEVICE_IS_PHY 0x80000000 +#define PHY_F_NO_IRQ 0x80000000 + /** * enum phy_interface_t - Interface Mode definitions *