From patchwork Tue Sep 3 18:00:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13789187 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47CF8CD37AA for ; Tue, 3 Sep 2024 18:02:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=4UrUsvRPk7SD8RHsYmK0LmFLnoRhb3Lw1NzhdFWeQiI=; b=2LW6gTDupfxhA1/xd+zH0Sfz1x oyZ1VOQggTOpMWNucnfHlLe0oZPkRZX7tDQx8JQpng+iYeEgjKN48OLr6ZDm3G0t1l+ZRTenDzg08 RRZfSA7ygPlOaCGAzY+C3Yrd69VuMG3G9XmLfKt1nHPXmBfuAKHB5MpMg0/C7UP5wFKF2RXtMzHgs lAH5IhQocZfMM/GFXCSP99PURygyRriLyLvWTxb1qYvqEUpJlF5lvI6OUMOu5agQeSCzetknmYEkN ikSey+L4dKt9nBQm7XDprn2tuZAFVL8OkQfyYPgVO7W7Is/tLmDsKg+Tytl17zhQS79SkXZoHMj2h s3Gi1RWA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slXqw-00000001Ou2-3dSj; Tue, 03 Sep 2024 18:02:07 +0000 Received: from out-175.mta1.migadu.com ([95.215.58.175]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slXq1-00000001OlA-3Ul6 for linux-arm-kernel@lists.infradead.org; Tue, 03 Sep 2024 18:01:11 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1725386467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=4UrUsvRPk7SD8RHsYmK0LmFLnoRhb3Lw1NzhdFWeQiI=; b=t2C4phJdAOId0vLOoHlL+usNLJegUscDYiCzD1lfotVr45sXlovabJjB7vVeh93eTm6TZe h+bEg8efdEXfJNOcnaD++iroqPo82OwZDPjTfgGQ9lEQRjj+R/fV5FlXiNSC8pIG1YUFnW W0ief0g9Do1X+IC0iNykxURDvSOca+g= From: Sean Anderson To: Radhey Shyam Pandey , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Michal Simek , linux-arm-kernel@lists.infradead.org, Ariane Keller , linux-kernel@vger.kernel.org, Daniel Borkmann , Andy Chiu , Sean Anderson Subject: [PATCH net] net: xilinx: axienet: Fix IRQ coalescing packet count overflow Date: Tue, 3 Sep 2024 14:00:59 -0400 Message-Id: <20240903180059.4134461-1-sean.anderson@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240903_110110_044895_73E23320 X-CRM114-Status: UNSURE ( 9.32 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If coalesce_count is greater than 255 it will not fit in the register and will overflow. Clamp it to 255 for more-predictable results. Signed-off-by: Sean Anderson Fixes: 8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver") --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 9aeb7b9f3ae4..5f27fc1c4375 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -252,7 +252,8 @@ static u32 axienet_usec_to_timer(struct axienet_local *lp, u32 coalesce_usec) static void axienet_dma_start(struct axienet_local *lp) { /* Start updating the Rx channel control register */ - lp->rx_dma_cr = (lp->coalesce_count_rx << XAXIDMA_COALESCE_SHIFT) | + lp->rx_dma_cr = (min(lp->coalesce_count_rx, 255) << + XAXIDMA_COALESCE_SHIFT) | XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_ERROR_MASK; /* Only set interrupt delay timer if not generating an interrupt on * the first RX packet. Otherwise leave at 0 to disable delay interrupt. @@ -264,7 +265,8 @@ static void axienet_dma_start(struct axienet_local *lp) axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, lp->rx_dma_cr); /* Start updating the Tx channel control register */ - lp->tx_dma_cr = (lp->coalesce_count_tx << XAXIDMA_COALESCE_SHIFT) | + lp->tx_dma_cr = (min(lp->coalesce_count_tx, 255) << + XAXIDMA_COALESCE_SHIFT) | XAXIDMA_IRQ_IOC_MASK | XAXIDMA_IRQ_ERROR_MASK; /* Only set interrupt delay timer if not generating an interrupt on * the first TX packet. Otherwise leave at 0 to disable delay interrupt.