From patchwork Thu May 25 17:59:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 99159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp561188vqr; Thu, 25 May 2023 11:09:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7nVUEANpmKUUPgTZMDPuGIQJM+0ZDKqwnouoM7VP/qKkuzezAN7QCSCzs374V6Dy1xJwE3 X-Received: by 2002:a05:6a20:3c89:b0:10b:6e18:b698 with SMTP id b9-20020a056a203c8900b0010b6e18b698mr18077310pzj.49.1685038180210; Thu, 25 May 2023 11:09:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685038180; cv=none; d=google.com; s=arc-20160816; b=FIBcFXolGJv62uIYBhAeezlaoQIUZv2ARLOdxzwaAicgsctIwEFaAIuQO01K9Hze2X NDvPtPqFA2GXMTX+7FoUcCb1dApRWhH1afeWY7fp1aKMxGbdKO1g1m/pOttPxfOjbk42 FS3Xq6rRGzzCnKdSB3mfUK89X6tEVSPdUDM5NgH7wauYEtGS3cbnNyFUOWALqzGCb32P 7BO3ybLSDkH/xbloZ6G5WcY/kTKvtDte7Hgwnl2da7GReCie0oQl95mi80KmVCnYdi2p gO9moruwbeoVYSan8b8x+wbKe77Gadv/g/TEa+cv9TvroAopQxjg06Bt5ty8ropQtY2d P8Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=xICDDNJzTMlV+C/EWakClHRszr/QmvJchpBapNb+gXg=; b=ibVsfbhOv6F3DC3Trm8LKjWz5hysidDqzRoec1cZ3PaCzeFrIBXCovlrf2by5W/sVS 5Qp9RvN3fL9seAWBPfyJSw1R/swGH799B/w+YZrXkrKJbC6RSxXIvuCSaXV0KVBz2Hjv Si1SHNznwnfCHPtIMTRMtQEmuPfzGzMqVm2D8LTqCkZUVtXCCM4wQy2MqosB0DkDrZ1/ O80uBAab0LG0DzPzVkaOPgld8mTudZjVc2mJrVZByYYYL4tlZeO/lXWG2RzuF+ZuAc89 ac8pSIRjtan+4bKyNq8apIrliDOC4ZlHbkR4TL7cnH0Ixn8lhNAQn+W9pIX5cY9b2KH/ JeSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=ZtAAnBMT; 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=broadcom.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z22-20020a637e16000000b005348cc20de8si1634017pgc.846.2023.05.25.11.09.24; Thu, 25 May 2023 11:09:39 -0700 (PDT) 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=@broadcom.com header.s=google header.b=ZtAAnBMT; 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=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239626AbjEYR7Y (ORCPT + 99 others); Thu, 25 May 2023 13:59:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229663AbjEYR7X (ORCPT ); Thu, 25 May 2023 13:59:23 -0400 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54A1E97 for ; Thu, 25 May 2023 10:59:22 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id 6a1803df08f44-62382e86f81so120876d6.2 for ; Thu, 25 May 2023 10:59:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1685037561; x=1687629561; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=xICDDNJzTMlV+C/EWakClHRszr/QmvJchpBapNb+gXg=; b=ZtAAnBMTGJP2tWkUSP5xUaYDRcsCorb+brBvD5yulvtESeyck9fnJcZflYXGFaOG7q rN/jpZWDOzstrhdML+6txc1IMJzYUmDz+m9TkT5vwAglK79Hc62v3bCWj1Gt+WltZpfF fzPj0phTkncD8dyvZFVQzwbVUPeaSKn2qA+p0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685037561; x=1687629561; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=xICDDNJzTMlV+C/EWakClHRszr/QmvJchpBapNb+gXg=; b=UcPG207IxroidFtMr56oY/F3vacCA+UiR7fDWhOv4pnkpOY75XYz/Mikv2u/BFXbue B2wJsgiaUna4rliBZ2P8Rva2GT+HSjfEYBtHAi6zK4MaegnUUMLw01U0tmR53KBnMAkB RoBhiXpn+vQWa7UfoahNNcoySppgQioSYmCibs/fEO3j0Qwpc088Ia3ng4pC/0y2Ym4W DEZkaAwrzhrYKcsfVmAhcWN3jaUynj2j4ALIU61g+lqiLZi+dNy57UK9ybtepnt1yyhs dLX0+a+R8VkbnXBqPpqD31r9/Jq8zdPuEViszh42bxuSOMHX12Sw9zk8vUgE9DYYf96U UHTA== X-Gm-Message-State: AC+VfDzYArL0LEPL/QhscoyoPj5UXBKsV3vRVQdX7A7bVkHgGuAotKok LGvxMAL0HEZ1CXHr849CTNl85A== X-Received: by 2002:a05:6214:4014:b0:619:152a:b9a5 with SMTP id kd20-20020a056214401400b00619152ab9a5mr2212677qvb.10.1685037561084; Thu, 25 May 2023 10:59:21 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id q26-20020a05620a039a00b0075c97468f57sm554049qkm.82.2023.05.25.10.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 May 2023 10:59:20 -0700 (PDT) From: Florian Fainelli To: netdev@vger.kernel.org Cc: Florian Fainelli , Doug Berger , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v2] net: phy: broadcom: Register dummy IRQ handler Date: Thu, 25 May 2023 10:59:15 -0700 Message-Id: <20230525175916.3550997-1-florian.fainelli@broadcom.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MIME_NO_TEXT, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766890594819623664?= X-GMAIL-MSGID: =?utf-8?q?1766890594819623664?= In order to have our interrupt descriptor fully setup and in particular the action, ensure that we register a full fledged interrupt handler. This also allow us to set the interrupt polarity and flow through the same call. This is specifically necessary for kernel/irq/pm.c::suspend_device_irq to set the interrupt descriptor to the IRQD_WAKEUP_ARMED state and enable the interrupt for wake-up since it was still in a disabled state. Without an interrupt descriptor we would have ran into cases where the wake-up interrupt is not capable of waking up the system, specifically if we resumed the system ACPI S5 using the Ethernet PHY. In that case the Ethernet PHY interrupt would be pending by the time the kernel booted, which it would acknowledge but then we could never use it as a wake-up source again. Fixes: 8baddaa9d4ba ("net: phy: broadcom: Add support for Wake-on-LAN") Suggested-by: Doug Berger Debugged-by: Doug Berger Signed-off-by: Florian Fainelli Reviewed-by: Simon Horman --- Changes in v2: - provided more details about the mechanics of wake-up interrupts arming - added a Debugged-by tag for Doug since he really whispered the solution to my keyboard drivers/net/phy/bcm-phy-lib.c | 6 ++++++ drivers/net/phy/bcm-phy-lib.h | 2 ++ drivers/net/phy/broadcom.c | 9 ++++++++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c index 27c57f6ab211..5603d0a9ce96 100644 --- a/drivers/net/phy/bcm-phy-lib.c +++ b/drivers/net/phy/bcm-phy-lib.c @@ -1028,6 +1028,12 @@ void bcm_phy_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) } EXPORT_SYMBOL_GPL(bcm_phy_get_wol); +irqreturn_t bcm_phy_wol_isr(int irq, void *dev_id) +{ + return IRQ_HANDLED; +} +EXPORT_SYMBOL_GPL(bcm_phy_wol_isr); + MODULE_DESCRIPTION("Broadcom PHY Library"); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Broadcom Corporation"); diff --git a/drivers/net/phy/bcm-phy-lib.h b/drivers/net/phy/bcm-phy-lib.h index c6fed43ec913..2f30ce0cab0e 100644 --- a/drivers/net/phy/bcm-phy-lib.h +++ b/drivers/net/phy/bcm-phy-lib.h @@ -8,6 +8,7 @@ #include #include +#include struct ethtool_wolinfo; @@ -115,5 +116,6 @@ static inline void bcm_ptp_stop(struct bcm_ptp_private *priv) int bcm_phy_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol); void bcm_phy_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol); +irqreturn_t bcm_phy_wol_isr(int irq, void *dev_id); #endif /* _LINUX_BCM_PHY_LIB_H */ diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c index 418e6bc0e998..822c8b01dc53 100644 --- a/drivers/net/phy/broadcom.c +++ b/drivers/net/phy/broadcom.c @@ -927,7 +927,14 @@ static int bcm54xx_phy_probe(struct phy_device *phydev) if (!IS_ERR(wakeup_gpio)) { priv->wake_irq = gpiod_to_irq(wakeup_gpio); - ret = irq_set_irq_type(priv->wake_irq, IRQ_TYPE_LEVEL_LOW); + + /* Dummy interrupt handler which is not enabled but is provided + * in order for the interrupt descriptor to be fully set-up. + */ + ret = devm_request_irq(&phydev->mdio.dev, priv->wake_irq, + bcm_phy_wol_isr, + IRQF_TRIGGER_LOW | IRQF_NO_AUTOEN, + dev_name(&phydev->mdio.dev), phydev); if (ret) return ret; }