]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: ipa: fix atomic update in ipa_endpoint_replenish()
authorAlex Elder <elder@linaro.org>
Wed, 12 Jan 2022 13:30:10 +0000 (07:30 -0600)
committerPaolo Pisati <paolo.pisati@canonical.com>
Fri, 28 Jan 2022 10:03:35 +0000 (11:03 +0100)
BugLink: https://bugs.launchpad.net/bugs/1959376
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 <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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/net/ipa/ipa_endpoint.c

index 03a170993420878c2b8c5d68683e3870ec547e34..c8f90cb1ee8f3de794923edce5249971371deaaf 100644 (file)
@@ -1067,6 +1067,7 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, bool add_one)
 {
        struct gsi *gsi;
        u32 backlog;
+       int delta;
 
        if (!endpoint->replenish_enabled) {
                if (add_one)
@@ -1084,10 +1085,8 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, bool add_one)
 
 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