From patchwork Mon Oct 2 14:08:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13406266 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67471883E for ; Mon, 2 Oct 2023 14:08:35 +0000 (UTC) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CC059B; Mon, 2 Oct 2023 07:08:33 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-405361bb9f7so169895375e9.2; Mon, 02 Oct 2023 07:08:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1696255712; x=1696860512; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=cTarZETHcAW0O9gfgdeOmaYr0S0MXF7s2VIEeHUmcR4=; b=SJje1GeqxE8qTzdXRLfHvTodMBGbPVSReWgR1T910IUdNMUQQsMR71fugaZ3+N8q7/ x5A2O3bt2bx90rcM/Yhj3nkZgF41jGILmalbsJCiWLQEjOnlpdrzeIyF5Cnuc3y6XR6Z A0hP78El6h6XnKOj67c4NgXWNAhJdHo/Dd4A0KzYT1CPdGHMZiP9bbZ+kCg++Hc9frGw EwMuoovrjyWhUlpnYcQ6CJSvx1FGsuwwbJt6DwVAqmjdElHIckYAExfngPCu322skAH9 WSch4LylOqH4Lxu0IMHfLK9VaMYEtRtzTVENEIpu/ZGrePR/36/zyV+JZfD9iZjRlpOs Uqgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696255712; x=1696860512; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cTarZETHcAW0O9gfgdeOmaYr0S0MXF7s2VIEeHUmcR4=; b=D6qdVBYtq/hXzXPn2R+z3ZwdjBuDUYj/MIe3hECasXoWplGaOQD19/B6EEa1iIXCzK +mHMfT0+MyvFjJO/HFaE5bWXD9rYQ1WWtXyY9bg39fbSKcEXloRvjDxbNUVcAFXnRLqH QAshxzFchJkeSENeZ3m+JarQbK/jmoo2++b2o36ALAmcbpIvuIt2bIQfjcQetME2EqRe cr1YI4ZTtvFB13DJ5N+vPAqxjHnaywq1HKk/Z4qWHiqC77/LrYzBA4Y4p7pVuMUY8XnT msKULqj6SDws7d0px7R/2Y+EHlwChBfXpCHHvT5qZUbMg2xBSK7UAhKUJ8fBVYOqYg5P EI2w== X-Gm-Message-State: AOJu0Yw52gWk7d89Jg0QyOK7V+H9IYwWprfz9qm63dI7gtaY3qd+SXn9 n6Y9gQYdXbSQCyu5HxIfJ18= X-Google-Smtp-Source: AGHT+IHTjP7xN/k5l+ale+TeCr5ZaZiwPFG0fqsQfhW/XlK6NBRW1AXXmqSYhc7YJirO93LThQiL2A== X-Received: by 2002:a7b:ce09:0:b0:405:3dbc:8821 with SMTP id m9-20020a7bce09000000b004053dbc8821mr9371184wmc.22.1696255711367; Mon, 02 Oct 2023 07:08:31 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id d29-20020adfa41d000000b003197869bcd7sm23150227wra.13.2023.10.02.07.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 07:08:31 -0700 (PDT) From: Christian Marangi To: Felix Fietkau , John Crispin , Sean Wang , Mark Lee , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Matthias Brugger , AngeloGioacchino Del Regno , Michael Lee , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Cc: Christian Marangi , stable@vger.kernel.org Subject: [net PATCH] net: ethernet: mediatek: disable irq before schedule napi Date: Mon, 2 Oct 2023 16:08:05 +0200 Message-Id: <20231002140805.568-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,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 X-Patchwork-Delegate: kuba@kernel.org While searching for possible refactor of napi_schedule_prep and __napi_schedule it was notice that the mtk eth driver disable the interrupt for rx and tx AFTER napi is scheduled. While this is a very hard to repro case it might happen to have situation where the interrupt is disabled and never enabled again as the napi completes and the interrupt is enabled before. This is caused by the fact that a napi driven by interrupt expect a logic with: 1. interrupt received. napi prepared -> interrupt disabled -> napi scheduled 2. napi triggered. ring cleared -> interrupt enabled -> wait for new interrupt To prevent this case, disable the interrupt BEFORE the napi is scheduled. Fixes: 656e705243fd ("net-next: mediatek: add support for MT7623 ethernet") Cc: stable@vger.kernel.org Signed-off-by: Christian Marangi --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 82b51072aad8..7669b446915a 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -3172,8 +3172,8 @@ static irqreturn_t mtk_handle_irq_rx(int irq, void *_eth) eth->rx_events++; if (likely(napi_schedule_prep(ð->rx_napi))) { - __napi_schedule(ð->rx_napi); mtk_rx_irq_disable(eth, eth->soc->txrx.rx_irq_done_mask); + __napi_schedule(ð->rx_napi); } return IRQ_HANDLED; @@ -3185,8 +3185,8 @@ static irqreturn_t mtk_handle_irq_tx(int irq, void *_eth) eth->tx_events++; if (likely(napi_schedule_prep(ð->tx_napi))) { - __napi_schedule(ð->tx_napi); mtk_tx_irq_disable(eth, MTK_TX_DONE_INT); + __napi_schedule(ð->tx_napi); } return IRQ_HANDLED;