All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] net: ipa: fix atomic update in ipa_endpoint_replenish()
@ 2022-02-01  1:26 Alex Elder
  2022-02-03 16:58 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Elder @ 2022-02-01  1:26 UTC (permalink / raw)
  To: stable; +Cc: davem, elder, Matthias Kaehlcke

    XXX 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.

Reference: https://lore.kernel.org/stable/164303143324018@kroah.com
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Fixes: 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints")
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
 drivers/net/ipa/ipa_endpoint.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c
index a37aae00e128f..397323f9e5d64 100644
--- a/drivers/net/ipa/ipa_endpoint.c
+++ b/drivers/net/ipa/ipa_endpoint.c
@@ -918,10 +918,7 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, u32 count)
 
 try_again_later:
 	/* The last one didn't succeed, so fix the backlog */
-	backlog = atomic_inc_return(&endpoint->replenish_backlog);
-
-	if (count)
-		atomic_add(count, &endpoint->replenish_backlog);
+	backlog = atomic_add_return(count + 1, &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
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 1/1] net: ipa: fix atomic update in ipa_endpoint_replenish()
  2022-02-01  1:26 [PATCH 1/1] net: ipa: fix atomic update in ipa_endpoint_replenish() Alex Elder
@ 2022-02-03 16:58 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2022-02-03 16:58 UTC (permalink / raw)
  To: Alex Elder; +Cc: stable, davem, elder, Matthias Kaehlcke

On Mon, Jan 31, 2022 at 07:26:36PM -0600, Alex Elder wrote:
>     XXX commit 6c0e3b5ce94947b311348c367db9e11dcb2ccc93 upstream.

The "XXX" is a bit odd, I've dropped that :)

Thanks for the backport, now queued up.

greg k-h

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-03 16:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-01  1:26 [PATCH 1/1] net: ipa: fix atomic update in ipa_endpoint_replenish() Alex Elder
2022-02-03 16:58 ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.