From patchwork Wed Jan 4 19:42:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Horatiu Vultur X-Patchwork-Id: 39071 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp5321550wrt; Wed, 4 Jan 2023 11:42:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXuBK6P47DN0DIDRPvOaFRVsHcz+QE8yhTWnBeHHVX4s+pvuIXtjbJ2PYdzAL+9QJ+PtceT4 X-Received: by 2002:a17:902:a601:b0:192:910e:6083 with SMTP id u1-20020a170902a60100b00192910e6083mr31455205plq.15.1672861335548; Wed, 04 Jan 2023 11:42:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672861335; cv=none; d=google.com; s=arc-20160816; b=MwVo4B75ntJbu2fHwVRBtAl5QS/9ULmxxrhCTLg7+C9kZtXP8xq8dcXRn4Sq4/9B9b nhSn6eHmOYjiURFG6O6gUQAvV/tH1lFwi/gGj79bF280esfj5bZu5/Qfdrv1wr5exFMP xLJTE1e/dHBZjaKAIB/o/nGSRyzrxdTuo9QzDNHRpA82pFuzcM8d/PrUgHFCMxEFTIMi k7ycyrksUi8K90RpwsIf3VDqjnehif0Zk+z93rq0Gjqa8lVJ33nxQ4Vmjxyu9Jp1WVMS yw4u0hGuFesRywp7jEVyEfmNnWP6awCXo0+fI6SBvNXhz28cXUfqSrs52juVoN2k9NgN YU+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=RmgCPT7QXxuQrWLKPiivnn4IKNWoLlWUooAfsaR/oQE=; b=dAWC6Y9N3KWmXtnZYBvtldfZK2hb6Wo2DnaQn16gX/dpUw0Xj8QVz8HBiZrSK4pQwA WiuFoRItOuPc4Zd4KRrr2sFtgRZvNsMeJMXzrTi/TJgukbtxDJTW6idmxKWLBuenA5Mr r32nN+uW0tUaMjB7wveEN0HCOT9uk4VGz5gu55sVhy+6W3nZbb/D2DLY3pKntfJkuZ/w zNiPRiIF522LC36nR08KSuFxmprOR3mtOuVRdWGECgWAI0sA9XCbYHqKzr38WDWz5LQ8 l3zSM0ta+UqzFTvITs4NxSnByby3hozs2L5ZbnqEPQKzO1nJOf2l0YPdw/Q9ECnMPWxF vkCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=AJz8jZBz; 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=microchip.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ja9-20020a170902efc900b00192a8dff11fsi15827936plb.41.2023.01.04.11.42.03; Wed, 04 Jan 2023 11:42:15 -0800 (PST) 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=@microchip.com header.s=mchp header.b=AJz8jZBz; 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=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240083AbjADThg (ORCPT + 99 others); Wed, 4 Jan 2023 14:37:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235173AbjADThe (ORCPT ); Wed, 4 Jan 2023 14:37:34 -0500 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6AC53F6; Wed, 4 Jan 2023 11:37:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1672861052; x=1704397052; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=FdK1P59eiaaPYotGf2Hn1FrUkMeoO0z3NBfLunufFTw=; b=AJz8jZBz/Wo1n73Ko4w75TTx7sDvuXb5NiYqUE5AXxtjP6OtRFoQGZHH 17J+0kGBxtARuWJcdy9YSz1GmDUL1bo4p2FeK8KhQZ++CFDj3mIM7YXPO OF/MzG4Lau6Fd/0l2LA/Erv3lE3xSZsd/zT/i3Ow1Cx0dy5dV9YTvlyCJ c7c2bPpqq5KRxzBrQA26dozuzaPrJcWoSkQcuDMPnwq+05ifsggy2wSXJ ZdjRP5kZO36jG467z/3Za/jYQ+I3jG+yp8YhT9ID5fh5dRwQDmVY2PFn3 BjYZV2q8V9pVYIsJvflUKn30ZJSqCorBMWKhsAXd5eldnVJehEXcfsKdK A==; X-IronPort-AV: E=Sophos;i="5.96,300,1665471600"; d="scan'208";a="194266433" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 04 Jan 2023 12:37:30 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.87.72) by chn-vm-ex02.mchp-main.com (10.10.87.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.16; Wed, 4 Jan 2023 12:37:28 -0700 Received: from soft-dev3-1.microsemi.net (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.2507.16 via Frontend Transport; Wed, 4 Jan 2023 12:37:26 -0700 From: Horatiu Vultur To: CC: , , , , , , , , , "Horatiu Vultur" Subject: [PATCH net-next] net: phy: micrel: Change handler interrupt for lan8814 Date: Wed, 4 Jan 2023 20:42:18 +0100 Message-ID: <20230104194218.3785229-1-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.38.0 MIME-Version: 1.0 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham 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?1754122247534636792?= X-GMAIL-MSGID: =?utf-8?q?1754122247534636792?= The lan8814 represents a package of 4 PHYs. All of them are sharing the same interrupt line. So when a link was going down/up or a frame was timestamped, then the interrupt handler of all the PHYs was called. Which is all fine and expected but the problem is the way the handler interrupt works. Basically if one of the PHYs timestamp a frame, then all the other 3 PHYs were polling the status of the interrupt until that PHY actually cleared the interrupt by reading the timestamp. The reason of polling was in case another PHY was also timestamping a frame at the same time, it could miss this interrupt. But this is not the right approach, because it is the interrupt controller who needs to call the interrupt handlers again if the interrupt line is still active. Therefore change this such when the interrupt handler is called check only if the interrupt is for itself, otherwise just exit. In this way save CPU usage. Signed-off-by: Horatiu Vultur --- drivers/net/phy/micrel.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 26ce0c5defcdd..2243ad1b88e70 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -2794,13 +2794,11 @@ static void lan8814_get_rx_ts(struct kszphy_ptp_priv *ptp_priv) } while (PTP_CAP_INFO_RX_TS_CNT_GET_(reg) > 0); } -static void lan8814_handle_ptp_interrupt(struct phy_device *phydev) +static void lan8814_handle_ptp_interrupt(struct phy_device *phydev, u16 status) { struct kszphy_priv *priv = phydev->priv; struct kszphy_ptp_priv *ptp_priv = &priv->ptp_priv; - u16 status; - status = lanphy_read_page_reg(phydev, 5, PTP_TSU_INT_STS); if (status & PTP_TSU_INT_STS_PTP_TX_TS_EN_) lan8814_get_tx_ts(ptp_priv); @@ -2899,8 +2897,8 @@ static int lan8804_config_intr(struct phy_device *phydev) static irqreturn_t lan8814_handle_interrupt(struct phy_device *phydev) { - int irq_status, tsu_irq_status; int ret = IRQ_NONE; + int irq_status; irq_status = phy_read(phydev, LAN8814_INTS); if (irq_status < 0) { @@ -2913,20 +2911,13 @@ static irqreturn_t lan8814_handle_interrupt(struct phy_device *phydev) ret = IRQ_HANDLED; } - while (1) { - tsu_irq_status = lanphy_read_page_reg(phydev, 4, - LAN8814_INTR_STS_REG); - - if (tsu_irq_status > 0 && - (tsu_irq_status & (LAN8814_INTR_STS_REG_1588_TSU0_ | - LAN8814_INTR_STS_REG_1588_TSU1_ | - LAN8814_INTR_STS_REG_1588_TSU2_ | - LAN8814_INTR_STS_REG_1588_TSU3_))) { - lan8814_handle_ptp_interrupt(phydev); - ret = IRQ_HANDLED; - } else { + while (true) { + irq_status = lanphy_read_page_reg(phydev, 5, PTP_TSU_INT_STS); + if (!irq_status) break; - } + + lan8814_handle_ptp_interrupt(phydev, irq_status); + ret = IRQ_HANDLED; } return ret;