From nobody Sat Feb 7 21:14:50 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2159FC433F5 for ; Mon, 23 May 2022 17:20:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240247AbiEWRUg (ORCPT ); Mon, 23 May 2022 13:20:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240930AbiEWRQt (ORCPT ); Mon, 23 May 2022 13:16:49 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CB9C6B642; Mon, 23 May 2022 10:16:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AF525614CC; Mon, 23 May 2022 17:13:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D6B4C34116; Mon, 23 May 2022 17:13:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1653325999; bh=eGrDYHXmFsVRcikTzncgPsM+vtr5k2y/DS+DjMqwsuQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xZuBSwddFeUd5Q30VC71nv+s/PdcigPKbPZIS/ENIu8fNd1WokqM+Zoxp88ekqINe TGbzAlMrPyYHNu24WFQXsUk4qQ1AUbJE4x/Q95YEZBgidh5uhzrLnGuA5Enn5pGGzq ajEORzZjz3MkLysfyVFdlhtq8wkZflEyJRExx+5s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Harini Katakam , Michal Simek , Radhey Shyam Pandey , Claudiu Beznea , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.4 36/68] net: macb: Increment rx bd head after allocating skb and buffer Date: Mon, 23 May 2022 19:05:03 +0200 Message-Id: <20220523165808.545233035@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220523165802.500642349@linuxfoundation.org> References: <20220523165802.500642349@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Harini Katakam [ Upstream commit 9500acc631dbb8b73166e25700e656b11f6007b6 ] In gem_rx_refill rx_prepared_head is incremented at the beginning of the while loop preparing the skb and data buffers. If the skb or data buffer allocation fails, this BD will be unusable BDs until the head loops back to the same BD (and obviously buffer allocation succeeds). In the unlikely event that there's a string of allocation failures, there will be an equal number of unusable BDs and an inconsistent RX BD chain. Hence increment the head at the end of the while loop to be clean. Fixes: 4df95131ea80 ("net/macb: change RX path for GEM") Signed-off-by: Harini Katakam Signed-off-by: Michal Simek Signed-off-by: Radhey Shyam Pandey Reviewed-by: Claudiu Beznea Link: https://lore.kernel.org/r/20220512171900.32593-1-harini.katakam@xilin= x.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/cadence/macb_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/etherne= t/cadence/macb_main.c index 002a374f197b..78219a9943a7 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -927,7 +927,6 @@ static void gem_rx_refill(struct macb_queue *queue) /* Make hw descriptor updates visible to CPU */ rmb(); =20 - queue->rx_prepared_head++; desc =3D macb_rx_desc(queue, entry); =20 if (!queue->rx_skbuff[entry]) { @@ -966,6 +965,7 @@ static void gem_rx_refill(struct macb_queue *queue) dma_wmb(); desc->addr &=3D ~MACB_BIT(RX_USED); } + queue->rx_prepared_head++; } =20 /* Make descriptor updates visible to hardware */ --=20 2.35.1