From patchwork Thu Feb 22 20:56:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Chen X-Patchwork-Id: 13568127 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8CE2312D1E8 for ; Thu, 22 Feb 2024 20:57:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708635429; cv=none; b=ml1WnPX5TCWCpW/ShP5P489BkCuf1N1TapBiqcjTgo49/wu/Jb4qn+5ho/i1BrPZ2Ew3cblrPmbjppCbBynhCM+1gNYACp4OsAXW1Xt/o7JqXsw4+j0kFJXNggV/sT8ZSRlqgc8dBoXtMOHdsxCfs5BlBDt62ED981527Zqq8ns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708635429; c=relaxed/simple; bh=cCaL2mu5GzoT4dxqj+iHQV4fDBuGRe3vdGV97rb3lqs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=F/nhfAubrh+oKmxUQaqFWxzksbKdC+jIQtBB6oVGTQ2Gk893mZpvzn8qglYlZmZHwWyvolvKSZpPdDdZUFHOq63W6Gr/E2b3U+ZVNFcfeZbXUWNqjTWJgffc5KFXaSK5m6g0JvNBNpcXAvOJnbLuwFaedHGiHHdbyEyz+VL+Aqs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=X26vXH5q; arc=none smtp.client-ip=209.85.160.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="X26vXH5q" Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-42a029c8e62so290781cf.1 for ; Thu, 22 Feb 2024 12:57:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1708635426; x=1709240226; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=FIpO513eJAVxgtG71VSIHb3UzfyMfcLBwIpnZp5qVFw=; b=X26vXH5qJJlIuRjsAZGUzqMWGR5Z+OaTEA0HHbYS/Z3PPwLUy/7kkcFJyXGq910i9T Pzk0R5uznfNoOWNLc2WhBchOSbgLQ8cIpIzbfnGfNCs3iS6gr/1x7VuPYq1D60FePNnD PqpWykIAwpTofNTEI9ExIKyNE0ChTBovWXXJs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708635426; x=1709240226; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FIpO513eJAVxgtG71VSIHb3UzfyMfcLBwIpnZp5qVFw=; b=wRf8AwiU7BgIQRtSuEGoDs/FsBZiPmsfBN6hpiK1W8v+00dTvpp0IBqMJpTbyjrEJQ wd3pWK5zePVa+aiKuz1zZn9cread9xricfqjPN98RAIDg6YfbfMoy8vIsZMN5V61uXSi ZZKAxAa71TpXdAZeKvVG/OkrWMn9sdzzOuUUVOGMzn2fYCSBozHhoewlSDHPOQ41+tXA +PkDYB+v4FsN/SNrtOXrvKBsTjUSts12doFJVsF2ZkwFeeI6669TleEECPtju9alWNrZ 9Ou++CmSc/Asw3nqPcaSdIWf6svS0ggP4MB9SwcK1FoXc4/XAWQ/HZ5/3yCesIsytVT1 l0Og== X-Gm-Message-State: AOJu0YzmBXz3Vqz/Wt3g30fsSVjBoVSa7qQjladS6MkNr689RMp08r4Q S+mJT8/y3Sn+ngZJB8GE65Oh4dMMQaGsNpgKFKQWQEqlc+bV5/lA7qCaTrKt85shwjX2zUiaye6 TPuQqlkdnFSbDfYzJKT/hH2nPUkJfDIPKdvskz6nTupc4B59Y7Klnw5U4pyiOl0+DtbSVZM5oyn CsNKVF3NEVbdxreQPJl1Wmtgfa1w7EKAQtBhbtd4hPjg== X-Google-Smtp-Source: AGHT+IGy1qCsgNT10YtMAC/kdQLI1fRjJLjgcT6oS9zQPWJAPnC9qWxQa2z//70gk63Ktr6q0jtE3Q== X-Received: by 2002:a05:622a:1745:b0:42e:2b6:8b52 with SMTP id l5-20020a05622a174500b0042e02b68b52mr370785qtk.14.1708635426039; Thu, 22 Feb 2024 12:57:06 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id jr11-20020a05622a800b00b0042e224098eesm3159370qtb.27.2024.02.22.12.57.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 12:57:05 -0800 (PST) From: Justin Chen To: netdev@vger.kernel.org Cc: bcm-kernel-feedback-list@broadcom.com, florian.fainelli@broadcom.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, opendmb@gmail.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, rafal@milecki.pl, devicetree@vger.kernel.org, Justin Chen Subject: [PATCH net-next 6/6] net: bcmasp: Add support for PHY interrupts Date: Thu, 22 Feb 2024 12:56:44 -0800 Message-Id: <20240222205644.707326-7-justin.chen@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240222205644.707326-1-justin.chen@broadcom.com> References: <20240222205644.707326-1-justin.chen@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Hook up the phy interrupts for internal phys to reduce mdio traffic and improve responsiveness of link changes. Signed-off-by: Justin Chen Acked-by: Florian Fainelli --- drivers/net/ethernet/broadcom/asp2/bcmasp.c | 17 +++++++++++++++++ drivers/net/ethernet/broadcom/asp2/bcmasp.h | 4 ++++ .../net/ethernet/broadcom/asp2/bcmasp_intf.c | 5 +++++ 3 files changed, 26 insertions(+) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.c b/drivers/net/ethernet/broadcom/asp2/bcmasp.c index 3086b0b9b784..a2627c2a6e45 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.c @@ -31,6 +31,20 @@ static void _intr2_mask_set(struct bcmasp_priv *priv, u32 mask) priv->irq_mask |= mask; } +void bcmasp_enable_phy_irq(struct bcmasp_intf *intf, int en) +{ + struct bcmasp_priv *priv = intf->parent; + + /* Only supported with internal phys */ + if (!intf->internal_phy) + return; + + if (en) + _intr2_mask_clear(priv, ASP_INTR2_PHY_EVENT(intf->channel)); + else + _intr2_mask_set(priv, ASP_INTR2_PHY_EVENT(intf->channel)); +} + void bcmasp_enable_tx_irq(struct bcmasp_intf *intf, int en) { struct bcmasp_priv *priv = intf->parent; @@ -79,6 +93,9 @@ static void bcmasp_intr2_handling(struct bcmasp_intf *intf, u32 status) __napi_schedule_irqoff(&intf->tx_napi); } } + + if (status & ASP_INTR2_PHY_EVENT(intf->channel)) + phy_mac_interrupt(intf->ndev->phydev); } static irqreturn_t bcmasp_isr(int irq, void *data) diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp.h b/drivers/net/ethernet/broadcom/asp2/bcmasp.h index 127a5340625e..f93cb3da44b0 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp.h +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp.h @@ -19,6 +19,8 @@ #define ASP_INTR2_TX_DESC(intr) BIT((intr) + 14) #define ASP_INTR2_UMC0_WAKE BIT(22) #define ASP_INTR2_UMC1_WAKE BIT(28) +#define ASP_INTR2_PHY_EVENT(intr) ((intr) ? BIT(30) | BIT(31) : \ + BIT(24) | BIT(25)) #define ASP_WAKEUP_INTR2_OFFSET 0x1200 #define ASP_WAKEUP_INTR2_STATUS 0x0 @@ -556,6 +558,8 @@ void bcmasp_enable_tx_irq(struct bcmasp_intf *intf, int en); void bcmasp_enable_rx_irq(struct bcmasp_intf *intf, int en); +void bcmasp_enable_phy_irq(struct bcmasp_intf *intf, int en); + void bcmasp_flush_rx_port(struct bcmasp_intf *intf); extern const struct ethtool_ops bcmasp_ethtool_ops; diff --git a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c index 1aed28b06309..a2fa8dcbe387 100644 --- a/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c +++ b/drivers/net/ethernet/broadcom/asp2/bcmasp_intf.c @@ -382,6 +382,7 @@ static void bcmasp_netif_start(struct net_device *dev) bcmasp_enable_rx_irq(intf, 1); bcmasp_enable_tx_irq(intf, 1); + bcmasp_enable_phy_irq(intf, 1); phy_start(dev->phydev); } @@ -890,6 +891,7 @@ static void bcmasp_netif_deinit(struct net_device *dev) /* Disable interrupts */ bcmasp_enable_tx_irq(intf, 0); bcmasp_enable_rx_irq(intf, 0); + bcmasp_enable_phy_irq(intf, 0); netif_napi_del(&intf->tx_napi); netif_napi_del(&intf->rx_napi); @@ -1027,6 +1029,9 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect) netdev_err(dev, "could not attach to PHY\n"); goto err_phy_disable; } + + if (intf->internal_phy) + dev->phydev->irq = PHY_MAC_INTERRUPT; } else if (!intf->wolopts) { ret = phy_resume(dev->phydev); if (ret)