mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Radu Pirea (OSS)" <radu-nicolae.pirea@oss.nxp.com>
To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk,
	davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Radu Pirea (OSS)" <radu-nicolae.pirea@oss.nxp.com>,
	stable@vger.kernel.org
Subject: [PATCH net] net: phy: nxp-c45-tja11xx: disable port and global interrupts
Date: Thu,  6 Apr 2023 12:55:46 +0300	[thread overview]
Message-ID: <20230406095546.74351-1-radu-nicolae.pirea@oss.nxp.com> (raw)

Disabling only the link event irq is not enough to disable the
interrupts. PTP will still be able to generate interrupts.

The interrupts are organised in a tree on the C45 TJA11XX PHYs. To
completely disable the interrupts, they are disable from the top of the
interrupt tree.

Fixes: 514def5dd339 ("phy: nxp-c45-tja11xx: add timestamping support")
CC: stable@vger.kernel.org # 5.15+
Signed-off-by: Radu Pirea (OSS) <radu-nicolae.pirea@oss.nxp.com>
---
 drivers/net/phy/nxp-c45-tja11xx.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/net/phy/nxp-c45-tja11xx.c b/drivers/net/phy/nxp-c45-tja11xx.c
index 029875a59ff8..ce718a5865a4 100644
--- a/drivers/net/phy/nxp-c45-tja11xx.c
+++ b/drivers/net/phy/nxp-c45-tja11xx.c
@@ -31,6 +31,10 @@
 #define DEVICE_CONTROL_CONFIG_GLOBAL_EN	BIT(14)
 #define DEVICE_CONTROL_CONFIG_ALL_EN	BIT(13)
 
+#define VEND1_PORT_IRQ_ENABLES		0x0072
+#define PORT1_IRQ			BIT(1)
+#define GLOBAL_IRQ			BIT(0)
+
 #define VEND1_PHY_IRQ_ACK		0x80A0
 #define VEND1_PHY_IRQ_EN		0x80A1
 #define VEND1_PHY_IRQ_STATUS		0x80A2
@@ -235,7 +239,7 @@ struct nxp_c45_phy_stats {
 	u16		mask;
 };
 
-static bool nxp_c45_poll_txts(struct phy_device *phydev)
+static bool nxp_c45_poll(struct phy_device *phydev)
 {
 	return phydev->irq <= 0;
 }
@@ -448,7 +452,7 @@ static void nxp_c45_process_txts(struct nxp_c45_phy *priv,
 static long nxp_c45_do_aux_work(struct ptp_clock_info *ptp)
 {
 	struct nxp_c45_phy *priv = container_of(ptp, struct nxp_c45_phy, caps);
-	bool poll_txts = nxp_c45_poll_txts(priv->phydev);
+	bool poll_txts = nxp_c45_poll(priv->phydev);
 	struct skb_shared_hwtstamps *shhwtstamps_rx;
 	struct ptp_clock_event event;
 	struct nxp_c45_hwts hwts;
@@ -699,7 +703,7 @@ static void nxp_c45_txtstamp(struct mii_timestamper *mii_ts,
 		NXP_C45_SKB_CB(skb)->header = ptp_parse_header(skb, type);
 		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
 		skb_queue_tail(&priv->tx_queue, skb);
-		if (nxp_c45_poll_txts(priv->phydev))
+		if (nxp_c45_poll(priv->phydev))
 			ptp_schedule_worker(priv->ptp_clock, 0);
 		break;
 	case HWTSTAMP_TX_OFF:
@@ -772,7 +776,7 @@ static int nxp_c45_hwtstamp(struct mii_timestamper *mii_ts,
 				 PORT_PTP_CONTROL_BYPASS);
 	}
 
-	if (nxp_c45_poll_txts(priv->phydev))
+	if (nxp_c45_poll(priv->phydev))
 		goto nxp_c45_no_ptp_irq;
 
 	if (priv->hwts_tx)
@@ -892,10 +896,12 @@ static int nxp_c45_config_intr(struct phy_device *phydev)
 {
 	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
 		return phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
-					VEND1_PHY_IRQ_EN, PHY_IRQ_LINK_EVENT);
+					VEND1_PORT_IRQ_ENABLES,
+					PORT1_IRQ | GLOBAL_IRQ);
 	else
 		return phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
-					  VEND1_PHY_IRQ_EN, PHY_IRQ_LINK_EVENT);
+					  VEND1_PORT_IRQ_ENABLES,
+					  PORT1_IRQ | GLOBAL_IRQ);
 }
 
 static irqreturn_t nxp_c45_handle_interrupt(struct phy_device *phydev)
@@ -1290,6 +1296,10 @@ static int nxp_c45_config_init(struct phy_device *phydev)
 	phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PORT_FUNC_ENABLES,
 			 PTP_ENABLE);
 
+	if (!nxp_c45_poll(phydev))
+		phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
+				 VEND1_PHY_IRQ_EN, PHY_IRQ_LINK_EVENT);
+
 	return nxp_c45_start_op(phydev);
 }
 
-- 
2.34.1


             reply	other threads:[~2023-04-06  9:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-06  9:55 Radu Pirea (OSS) [this message]
2023-04-07 14:14 ` Andrew Lunn
2023-04-07 15:24   ` Radu Pirea (OSS)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230406095546.74351-1-radu-nicolae.pirea@oss.nxp.com \
    --to=radu-nicolae.pirea@oss.nxp.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=hkallweit1@gmail.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®