From patchwork Tue Feb 27 18:54:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Justin Chen X-Patchwork-Id: 13574320 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 D80F814A086 for ; Tue, 27 Feb 2024 18:55:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709060112; cv=none; b=Pf2tHls5EsoVprT9kVEY8+kzj97qZ3P2cam8i2jXU6xaHzwYEfFF2FTWwstJkTm98vMs0+QsirRDADjQP9oNyCSloYpH9u+p2ptEkgxYn47V/VpjR9UQYsznj/DgSAh0pQFmyZ1ecO9xZdDnUhMoXag6cgw38G8rbyngA4Tfchk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709060112; c=relaxed/simple; bh=CSsygOuFaYPkRvAPlVtAXAWX78lycA/mwJCyHzTH1jQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=lT0MjIJzY3IWxLMfyq6J1HTxYP0ET5VMv02HFuE4V/inUa7HYAD0JDnMOHC9oDhtR/TVx+MO1bjSWwXIS3o2jit1AfrnQlGPadDsxaZkuf6O4B7OESCYggBf1MY9yh1f0z5SuHN0+zjRvXT8V1zxgkTf60V6JmP7IjgETWeDnPY= 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=iGI9i6/8; arc=none smtp.client-ip=209.85.210.177 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="iGI9i6/8" Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6e46dcd8feaso1650407b3a.2 for ; Tue, 27 Feb 2024 10:55:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1709060110; x=1709664910; 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=6G2cb+b7ZxTdec35kwMlk2lZ/+wp3B97BS0yDDfoehE=; b=iGI9i6/8Q6u9rSuVyje8VcLQ7tW4SrqGEh7msuHr8/+Ai9lQJHVgj5wj+K8x1dJnOv chAAzO/Dsh9G6pfU/OYcO/U50ssrIDkbnq23zqJasfsjyTy7Nofb8R+SOH4niurF+BSv 8U5VRklfxOmbR7MKeJsPKjUrfKGdgCtFUy3lo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709060110; x=1709664910; 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=6G2cb+b7ZxTdec35kwMlk2lZ/+wp3B97BS0yDDfoehE=; b=gb3HyVI3ZCjCQfu/wGEPgWTk7qE3sQtP3/oBQcF87GWQKKNXj8tLmsYEePrOb7y89B 0D2GPFcJgmool5CqwgZYsUnjpMfowXyUw3Lu3Wvzrnxqq3X/yR1ltpdLRINfZzxI70Zi OyXY03jg7XIZ/I3CR5AVEYv2XD3JvdM29ydmkvsvMrWjgEK/JBFEAtX7qASZjNxk9IV7 SW4/Jz8UuoRMaQUfyU8ORezAYWfhKaBaeR/lGaWNTshBhRi0H4/iFG18ypchsgIVk2x0 zmSAS2AgHy7TJMlyCc6MemUqr3S95lLVw+kYDMfdXCPONElY2j/izfUX2FPG3eX9rPv/ SNkw== X-Gm-Message-State: AOJu0YzDzUd1e4/HTc9iGyaBV53K/Kw2oXNi5MfkwzSvmYM14o4/D/nh VbiRZOR9HtmM9vXD7Wg4FFpty5Dd3Z8DDRJ6wolIZ/cRNxpMce8QhfJu0uagaDp/O73lkv00e3h Inis43CutAyMf2vfgKvL3/xyDG4wTODdJE1oaS1jAdNrG8YdHMMl6CL1EYEwt8yRk8lzEUEQ0Q9 dRpvz2sk5D1ro9Ie1usBFjvKc3C4lS18YWAfQfb2FzaihK X-Google-Smtp-Source: AGHT+IG6+amgoqxQKHjGq6XjXVCP0fU7/gBclv8pHu2hAOCpHmPldwnoy9Bh81RxGTjV8HVEVg9JGQ== X-Received: by 2002:a05:6a00:6c99:b0:6e5:54b5:f16c with SMTP id jc25-20020a056a006c9900b006e554b5f16cmr1952800pfb.0.1709060109803; Tue, 27 Feb 2024 10:55:09 -0800 (PST) Received: from stbirv-lnx-1.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id r6-20020aa79886000000b006e466369645sm6236898pfl.132.2024.02.27.10.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 10:55:09 -0800 (PST) From: Justin Chen To: netdev@vger.kernel.org Cc: 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, bcm-kernel-feedback-list@broadcom.com, andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, rafal@milecki.pl, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Justin Chen Subject: [PATCH net-next v2 6/6] net: bcmasp: Add support for PHY interrupts Date: Tue, 27 Feb 2024 10:54:54 -0800 Message-Id: <20240227185454.2767610-7-justin.chen@broadcom.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227185454.2767610-1-justin.chen@broadcom.com> References: <20240227185454.2767610-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 100c69f3307a..a806dadc4196 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 0b378a6d43e7..8fbeb506abb9 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); @@ -1028,6 +1030,9 @@ static int bcmasp_netif_init(struct net_device *dev, bool phy_connect) goto err_phy_disable; } + if (intf->internal_phy) + dev->phydev->irq = PHY_MAC_INTERRUPT; + /* Indicate that the MAC is responsible for PHY PM */ phydev->mac_managed_pm = true; } else if (!intf->wolopts) {