From mboxrd@z Thu Jan 1 00:00:00 1970 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 374D7CD4857 for ; Wed, 4 Sep 2024 16:07:22 +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:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Kp2irAs+4Y9PJmRam/X7pQ4tEAOyc7gPOYT5jwon1c8=; b=wtvmWR6W2waYGzL+6Z5OnJ/9PS RIMLhOuRhIcGj3TK7A4aWHUbfZQnMUZVCHv3QuO8FGoVYuER1HWzX6dhYdVwFIOnUdoXDlUrp/EnH 6mwyjB3gcsDBxYD2/0iWEM9J/rVcVnM3tZcGS2qjPDnfMkpnY0nlV3xnIzgEIz6LK541GgkUiKMYd 7iRstS8ldUkaKRXouQIgAykqIVrrL8TRbqZfoSVShAXxuVLI5pYEG5YCjApjQ4OU8DdY59Ci05GBF tXJo/5Xj0bXJKOw3dHmfSh8/03NsGszFRPqzLRqvPs0zs3QtiXcXZc7R/ZGjJtWiqTlIkZqAfIqr0 pEFQ9+9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1slsXK-00000005AvN-0i4O; Wed, 04 Sep 2024 16:07:14 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1slsQf-000000058mn-3GBV for linux-arm-kernel@lists.infradead.org; Wed, 04 Sep 2024 16:00:24 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 37D555C5718; Wed, 4 Sep 2024 16:00:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 67112C4CEC2; Wed, 4 Sep 2024 16:00:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725465618; bh=+3ODXSLmDXmWE0Ypt5vkmq+M5qRPpQx/U46X36rcq6I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jLBJkvHUdvFupnyBSORH/jGNmc8W9/8wB3/moIQx4AafTtbF9vBgYDvRZ+eMEua5/ 2wOa+vKlqq3glynWxmtkmAFye0YHfbWiKiHeSDz8yROklkX8N7+iJcOGXckG00khqb 4a+wEGPx3MtcVXvvAJeixpSJHx6mlM/huyZH5Vyn5rLkBS77N7E5z45ZV/54SzRVhZ fD+OSxaLKffk62PNnko/OXcPCWPNOBNq5eHl1HrmhckZvQYSgLtCk1nNj7yjmHJOzY 2l8nQRrZzfQuz7fZjUECUwTwT2BEFQTA2KUpP9tnK3djhjvzPpN1jF6lPESD7B5Cyi KMpOq3DDvIOkQ== Date: Wed, 4 Sep 2024 17:00:13 +0100 From: Simon Horman To: Sean Anderson Cc: Radhey Shyam Pandey , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, Michal Simek , linux-arm-kernel@lists.infradead.org, Ariane Keller , linux-kernel@vger.kernel.org, Daniel Borkmann , Andy Chiu Subject: Re: [PATCH net] net: xilinx: axienet: Fix IRQ coalescing packet count overflow Message-ID: <20240904160013.GX4792@kernel.org> References: <20240903180059.4134461-1-sean.anderson@linux.dev> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240903180059.4134461-1-sean.anderson@linux.dev> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240904_090021_923247_2C9EDED8 X-CRM114-Status: GOOD ( 19.98 ) 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 On Tue, Sep 03, 2024 at 02:00:59PM -0400, Sean Anderson wrote: > 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. Hi Sean, Can this occur in practice? > > Signed-off-by: Sean Anderson > Fixes: 8a3b7a252dca ("drivers/net/ethernet/xilinx: added Xilinx AXI Ethernet driver") nit: I think it is usual for the order of these tags to be reversed. > --- > > 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; nit: it would be nice to avoid using a naked 255 here. Perhaps: #define XAXIDMA_COALESCE_MAX 0xff > /* 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. > -- > 2.35.1.1320.gc452695387.dirty > >