Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3688166pxb; Mon, 24 Jan 2022 15:24:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJyhROkkjLt1hbfm/bh9i38F/LGwMfENMeP5zMh1oy8dCY6s1xDnoyqSC1C8cKBTTOATij0g X-Received: by 2002:a17:903:31c8:b0:149:a463:ad38 with SMTP id v8-20020a17090331c800b00149a463ad38mr16028720ple.76.1643066649003; Mon, 24 Jan 2022 15:24:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643066648; cv=none; d=google.com; s=arc-20160816; b=O4RLMJJvYF8h5GYpj6cs8YcYvXyXlF9sTttjfwWG+vQagXSvVV9Af27ubjiRQEbhhl BRqyV2z31HBaQ5xhEKGhIXNtlFMG5tWxFNIxp+LNCxc18EiGcAlWj0Ir4jg+Fuu7rq/z zWjYHXQU7GNCAXXiJSjP514hFCIHN6VfUDJ0uPWfkRwb7/8x1NjTfJ8hxgofGspkt5zs rRks3QknFe8s8kbdvG4xQdmoRgu9XLPFmsK4K4f5bCfBdBU4G0UiX+uJY7LEIx9nsefb PKg0f/W7VzNI03g2MTsdGuAZveJePv1vJi3iB4QUCSQur2mEYJQhNs5sX80lhtg4XZ44 KeEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9Ny1L5TPHtq3pPkxCMg10pHmCoPGvUaINm81jprxyyk=; b=lXUWZ3QMOjaYuE+NYSrbNVoSdC/vKTyGfPLmaLNOb03Zu7PmuWEiiwaMBodvY8v7FZ lYpxA7fhwejL+HUlspN5bIWONjjY+/2NCL2wC9N8Pjn8RBiK/TqmNcnQPb79becQU8GG 0MeiJo2Qb5vOGuav8Ov5JIsZ0AwhHwYO/o7Kz8LP9YjbIn1/qR2fTN+doQeQ9wpJuteG MsHHY9Amxt3VzMtS6cSCJLXnbX/xUD3g9OtASoRsmAi6og54SNL42UVYdLnpEt3/lL60 hO8gugrDhDpEaLnem8MRHLsuMwrXqMJxBU99t8rm/hhbS4x/uLyJrvQ1mdF5Haj45Zg6 sqRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XvFxXD9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x11si595165pjl.57.2022.01.24.15.23.48; Mon, 24 Jan 2022 15:24:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XvFxXD9J; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1847569AbiAXXUC (ORCPT + 99 others); Mon, 24 Jan 2022 18:20:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1584631AbiAXWVa (ORCPT ); Mon, 24 Jan 2022 17:21:30 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D3DBC0424F4; Mon, 24 Jan 2022 12:52:28 -0800 (PST) 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 0AB7160B21; Mon, 24 Jan 2022 20:52:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DA219C340E5; Mon, 24 Jan 2022 20:52:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057547; bh=157YON3ewFpZewgxjqxaCDDdcCeplABo9eTS1EJvvBU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XvFxXD9JdrQP9uWWyvfouhRX8KQoFIySvq/MpMMxvKOqYptCdtzqKwThWX1K60vTa Ynsw89uI/ecCz9cuam3Ls69Arviet31Xi+58qV9wf7sPwFzTJknhTOW8rzRFeif0oK ykj58tszmPkb2saeoOqiLDqHxS8n3tGP5bemI3XY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Matthias Kaehlcke , Alex Elder , "David S. Miller" Subject: [PATCH 5.15 827/846] net: ipa: fix atomic update in ipa_endpoint_replenish() Date: Mon, 24 Jan 2022 19:45:44 +0100 Message-Id: <20220124184129.435103470@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184100.867127425@linuxfoundation.org> References: <20220124184100.867127425@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alex Elder commit 6c0e3b5ce94947b311348c367db9e11dcb2ccc93 upstream. In ipa_endpoint_replenish(), if an error occurs when attempting to replenish a receive buffer, we just quit and try again later. In that case we increment the backlog count to reflect that the attempt was unsuccessful. Then, if the add_one flag was true we increment the backlog again. This second increment is not included in the backlog local variable though, and its value determines whether delayed work should be scheduled. This is a bug. Fix this by determining whether 1 or 2 should be added to the backlog before adding it in a atomic_add_return() call. Reviewed-by: Matthias Kaehlcke Fixes: 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints") Signed-off-by: Alex Elder Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- drivers/net/ipa/ipa_endpoint.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1067,6 +1067,7 @@ static void ipa_endpoint_replenish(struc { struct gsi *gsi; u32 backlog; + int delta; if (!endpoint->replenish_enabled) { if (add_one) @@ -1084,10 +1085,8 @@ static void ipa_endpoint_replenish(struc try_again_later: /* The last one didn't succeed, so fix the backlog */ - backlog = atomic_inc_return(&endpoint->replenish_backlog); - - if (add_one) - atomic_inc(&endpoint->replenish_backlog); + delta = add_one ? 2 : 1; + backlog = atomic_add_return(delta, &endpoint->replenish_backlog); /* Whenever a receive buffer transaction completes we'll try to * replenish again. It's unlikely, but if we fail to supply even