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 2DECACD5BCA for ; Thu, 5 Sep 2024 14:35:43 +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: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=P7rbhxgQHH8FMAXCYEogfAFPlvDv513nAGuaFUXrBNY=; b=o/I9xdTYvnte1bjJgmTh+xeTm8 OmtINFeDAhL2UAiE0LD0CewPvtzC6Wkdh2XKe4ilZQbT6Ff+fVz3zkK3/08obK9w3Um2UIoAd7DDy 9k4FHWCgjDZgK6KVTiY5+HvvH/P4apprzkF14WTgKp/bSqxw/TQsS54TE9IvZ3t6VOx1bCzp63Fgb 4vQ4f6copDbPNJhFG8Kgxvj+5itLF0ZTj/OLvMdCBgJWfLVsHubh7vee5cpjc/TsBCbKSDAkw0zZ8 SpAzFOeaY27KLSg8bCRcRB3Lrx1MeR32tNOl3qm9ENmuJXwNqvztTWO+6OSRwGoP5kt5s/2g3xIpb 7U+i34mQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smDa6-00000008jwR-191q; Thu, 05 Sep 2024 14:35:30 +0000 Received: from out-179.mta1.migadu.com ([2001:41d0:203:375::b3]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smDZ7-00000008jig-3xAF for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 14:34:31 +0000 Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1725546867; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=P7rbhxgQHH8FMAXCYEogfAFPlvDv513nAGuaFUXrBNY=; b=PXEuWw9S0BYumid1/jVD3PdysZxv8u1KLegtebjFDKS2p1CXX7ZSeSyO/adNElmfF+I5MK LM6/5OXhNKdvGLltyWfUaXHAQUs6A4CO1ybibDyAgFUejesYumh90dqmMTwbbdKOwIDDfX ZwgfrB3XaJXhkT2gSd4Eie+qSb/l1NY= Date: Thu, 5 Sep 2024 10:34:15 -0400 MIME-Version: 1.0 Subject: Re: [PATCH net] net: xilinx: axienet: Fix IRQ coalescing packet count overflow To: Simon Horman 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 References: <20240903180059.4134461-1-sean.anderson@linux.dev> <20240904160013.GX4792@kernel.org> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Sean Anderson In-Reply-To: <20240904160013.GX4792@kernel.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240905_073430_159324_63302996 X-CRM114-Status: GOOD ( 20.24 ) 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 9/4/24 12:00, Simon Horman wrote: > 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? Yes. Simply do `ethtool -C ethX rx-frames 300` or something similar and you will end up with a limit of 44 instead. I ran into this with DIM and was wondering why the highest-throughput setting (256) was behaving so poorly... >> >> 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. OK >> --- >> >> 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 OK, but this is the same as the limit used in axienet_usec_to_timer. --Sean >> /* 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 >> >>