From patchwork Mon Nov 13 17:42:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baruch Siach X-Patchwork-Id: 13454274 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 C69D2224EA for ; Mon, 13 Nov 2023 17:49:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=tkos.co.il header.i=@tkos.co.il header.b="h4Svy6gl" Received: from mail.tkos.co.il (mail.tkos.co.il [84.110.109.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4AA410EC for ; Mon, 13 Nov 2023 09:49:32 -0800 (PST) Received: from tarshish.tkos.co.il (unknown [10.0.8.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.tkos.co.il (Postfix) with ESMTPS id 3F44D4406F7; Mon, 13 Nov 2023 19:41:53 +0200 (IST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tkos.co.il; s=default; t=1699897313; bh=rsN6ONrmXmjveXdLExCyq9Ko3XW2Kuct8gTVNvQv1Sc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h4Svy6glaao3UeOsYqVpyLldJOjSdH3PiiA6BWKQlLbUUZ6QfeHGq9JIVid+XiCAu e0xbf4ANGF7eIVh2Z7mJXMS7iixqqw/aJVe10ujnrZInqs1HiUXiL2FP4B1ucdtBPA 24eAAhEV6KYK+GM+ZXF6275IQ9xkgOa2YZg1hNXINedEd47HzKHzZC/sfxM6X775x2 imG1rES1nT4oCO+uZ+W6VFRlL/2Uiobgpnf9ZCgCWfZaVeApbruxl4j7uDNWGVfSlQ 1PjlVoG8mw32T7Og1DOCdxR1xJAK9V1tln4TTanlc1bDU3DH5zxt3XjnB/TWsD8u1J sID0eyUC7VKTQ== From: Baruch Siach To: Alexandre Torgue , Jose Abreu Cc: netdev@vger.kernel.org, Baruch Siach Subject: [PATCH net 2/2] net: stmmac: avoid rx queue overrun Date: Mon, 13 Nov 2023 19:42:50 +0200 Message-ID: X-Mailer: git-send-email 2.42.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org dma_rx_size can be set as low as 64. Rx budget might be higher than that. Make sure to not overrun allocated rx buffers when budget is larger. Leave one descriptor unused to avoid wrap around of 'dirty_rx' vs 'cur_rx'. Signed-off-by: Baruch Siach Reviewed-by: Serge Semin --- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index f28838c8cdb3..2afb2bd25977 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -5293,6 +5293,7 @@ static int stmmac_rx(struct stmmac_priv *priv, int limit, u32 queue) dma_dir = page_pool_get_dma_dir(rx_q->page_pool); buf_sz = DIV_ROUND_UP(priv->dma_conf.dma_buf_sz, PAGE_SIZE) * PAGE_SIZE; + limit = min(priv->dma_conf.dma_rx_size - 1, (unsigned int)limit); if (netif_msg_rx_status(priv)) { void *rx_head;