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: 207546 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3047475dyb; Tue, 27 Feb 2024 16:22:15 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVf25l2tFeoVnRgcPuilUIhlFjJYtsb723TWi0B5K+UXrmIfhDK77BT4D5fzxDsFiPcPZXDYRrt0ZDDAhg4UippYzARcw== X-Google-Smtp-Source: AGHT+IEK4TV4f/adLMdj2sOR4EMerf2/A2/2EQ4HSfbO9n/ue7hEdeXAAC4XYok1H68QoljLNnKe X-Received: by 2002:aa7:d4c3:0:b0:565:ed50:81dc with SMTP id t3-20020aa7d4c3000000b00565ed5081dcmr4728333edr.28.1709079735390; Tue, 27 Feb 2024 16:22:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709079735; cv=pass; d=google.com; s=arc-20160816; b=UIWv33W62LUMpsbiXWrb0kFpaIj6r8/cpZJPi+SBk2/SUmkNlyTT0+4EHl+c9/liMT JA/jKOttOlaQV5Xvm92P7CkJBoTeo2FntPbKjDuZxVGSSqY1u/fIK2epVpxPXKpW4P7o VTj7e44mSEqKgkDp5BI+xszwyuKUhj8umkdlZd+uFVzxAEo7pPRUNu4yY/Tws9ypBz/e 1ab6pyDZJL+ltblVjr4biyWDYJ1gXySD/oMomU+Jy74L5HIW+V7TO230JHJpeUvFP5nF U6d+4s8SiImh4ubCtLGBhUEJp7jfLVNUEkOMNKK5myA8zo1uIIaS1hbN43crYhDYHxXI jEng== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=UaF5Tpv8En48yxR6HUAnI0ilxqIK3GzCF/CKG3bbzfQ=; fh=A/+cE8mRavbBxAMA83lbQTK/lv1tO7bftPJDFpz6pGM=; b=fspUpDLHiHnis4Mrws7aUqgIwVimpcfbrqv3Vuw/vhDHhHThgmGuoffJruJtlLm2Xu BPXlL5encec5LubvXHoDpiuylknhdjVzHImAuMzpO/Yb6V+lyzK9/ptkKMY9MCYA3L68 ZxVCgWVPU7jsoi0jDGH5KYtsoVurZUBfneXdTTJhVWsIVlldUUoROKzpHzhkhyaUBEwt QkuTPX1fjIFINbbhRatIHDNt0Eik4PSRuJRfJYi8DHXv7YJouEcGMHfZuKR5aYt/jBNm FtLK++4aWbSjZ3SkMiEKqO9v0zkZj7FqaPvMPDt27DcThZymm/4aN0ynjcJBIdmL+dJ9 YEaw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=efU9Xx1x; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-83871-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83871-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y7-20020a50eb07000000b005664ebf6a46si559742edp.612.2024.02.27.16.22.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 16:22:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-83871-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=efU9Xx1x; arc=pass (i=1 dkim=pass dkdomain=broadcom.com dmarc=pass fromdomain=broadcom.com); spf=pass (google.com: domain of linux-kernel+bounces-83871-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-83871-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 153EC1F2DDC0 for ; Tue, 27 Feb 2024 18:57:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3FA9751C5C; Tue, 27 Feb 2024 18:55:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="efU9Xx1x" Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (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 7FD5314AD2E for ; Tue, 27 Feb 2024 18:55:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709060112; cv=none; b=hX75HsWLd/KHAbdeR6lmF4XqUYEjrRdV13pzmSkThOL4PsBXq7Iz/XwkpaP1tpcCu/JFT6X847H0i9O/X2ROshtXW3voslbThCpzIQkK7OZTdYydf1cOln97YKPLPw2+fYtYAWp0E4KRVmOAOALtNIXy6MWaWqM02IRO7chEmTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709060112; c=relaxed/simple; bh=0TtnxrLLsiiu3SIY1wjXNv8ElJg3zLabGEWPjVqIoHk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=HgR7hQ9QS0qNRtrLsRbAtWN/t2c3wZlU3AWdKcPUXAB57SZs7qvWn0NeB9QgDfGWgH/oM3+SgqOipTiV9ka8ts/L7/Y5i0KLqYis/7U2vTRhVSBGk0mcV9rIw4IOP3vU0l/B+/XxaMyjwsmA2um/siPUeUjNlWFspgGISFYlUDs= 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=efU9Xx1x; arc=none smtp.client-ip=209.85.210.173 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 Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6e53f76898fso1215296b3a.0 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=UaF5Tpv8En48yxR6HUAnI0ilxqIK3GzCF/CKG3bbzfQ=; b=efU9Xx1xTciZtO3+M3IL+VF6v0mGCJOD+lRSzzLf5ofnc2TzwIuPL55KjeJa9Uv9Zv 5ejLL5mEGzQ6RtgUEsGNNKzCghz1LaczQDx+jKm9JbZUpufZyrIGfNvYBiZjs7S/lD6F PsSeaJQX3ICt1xihkc8s1g8hvOGFSddIoPZPM= 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=UaF5Tpv8En48yxR6HUAnI0ilxqIK3GzCF/CKG3bbzfQ=; b=mInQd+niC7jDTTLjRIDbOl+tSAvK5Ihldga2WDxWYiie8RW3NOh3iHazjt+aOciwcS 4Y5wUZG39W0z4GqvC8ektdcEDfavhOZyul2jXfrd16ATsg/cbIjUK8H8WEYzAkx9IdNw hfqUNoDthXNp9mrpdZU981ENrA0R84+oHH+04pwjecbY9sHt4yqp7ukflPsv98SmjkRX eKVXnAsamlBZGCeD3hx4rAjk8zBnCOhH/MjQutn2sKTmcgW6BG65ocsYlri41v8UslgM FiC6IXeNx4RyTOTuc/tZQ6eCAxs/VVGrWCWOnqMFypPaeeXBmDEQcjaadJGsnLoGNMsK q1BQ== X-Forwarded-Encrypted: i=1; AJvYcCVfRX/bbizSTpPSl9spe7QKiSw2HnAJZC0nMOaCx3KHm56AnHeiHP4wTEO3GlNT/AD/896K5tUDQJs1HOCFGNMmdCsu10AeCkN6pUat X-Gm-Message-State: AOJu0Yz53iM9AjSGqjpqEO9MHQ/4N2gty+BsCDiju7M39Z4mGiZ8iXFJ IRd5epi77FvaO/E1o0MBkockY0wIHWTVCtXYsTbZOobJfoM+XKpjj1QMATn+2g== 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: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792099992712742526 X-GMAIL-MSGID: 1792099992712742526 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) {