All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] net: ipa: prevent concurrent replenish" failed to apply to 5.16-stable tree
@ 2022-01-24 13:37 gregkh
  2022-01-31 23:39 ` Alex Elder
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2022-01-24 13:37 UTC (permalink / raw)
  To: elder, davem; +Cc: stable


The patch below does not apply to the 5.16-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 998c0bd2b3715244da7639cc4e6a2062cb79c3f4 Mon Sep 17 00:00:00 2001
From: Alex Elder <elder@linaro.org>
Date: Wed, 12 Jan 2022 07:30:12 -0600
Subject: [PATCH] net: ipa: prevent concurrent replenish

We have seen cases where an endpoint RX completion interrupt arrives
while replenishing for the endpoint is underway.  This causes another
instance of replenishing to begin as part of completing the receive
transaction.  If this occurs it can lead to transaction corruption.

Use a new flag to ensure only one replenish instance for an endpoint
executes at a time.

Fixes: 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints")
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c
index cddddcedaf72..68291a3efd04 100644
--- a/drivers/net/ipa/ipa_endpoint.c
+++ b/drivers/net/ipa/ipa_endpoint.c
@@ -1088,15 +1088,27 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, bool add_one)
 		return;
 	}
 
+	/* If already active, just update the backlog */
+	if (test_and_set_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags)) {
+		if (add_one)
+			atomic_inc(&endpoint->replenish_backlog);
+		return;
+	}
+
 	while (atomic_dec_not_zero(&endpoint->replenish_backlog))
 		if (ipa_endpoint_replenish_one(endpoint))
 			goto try_again_later;
+
+	clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags);
+
 	if (add_one)
 		atomic_inc(&endpoint->replenish_backlog);
 
 	return;
 
 try_again_later:
+	clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags);
+
 	/* The last one didn't succeed, so fix the backlog */
 	delta = add_one ? 2 : 1;
 	backlog = atomic_add_return(delta, &endpoint->replenish_backlog);
@@ -1691,6 +1703,7 @@ static void ipa_endpoint_setup_one(struct ipa_endpoint *endpoint)
 		 * backlog is the same as the maximum outstanding TREs.
 		 */
 		clear_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags);
+		clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags);
 		atomic_set(&endpoint->replenish_saved,
 			   gsi_channel_tre_max(gsi, endpoint->channel_id));
 		atomic_set(&endpoint->replenish_backlog, 0);
diff --git a/drivers/net/ipa/ipa_endpoint.h b/drivers/net/ipa/ipa_endpoint.h
index 07d5c20e5f00..0313cdc607de 100644
--- a/drivers/net/ipa/ipa_endpoint.h
+++ b/drivers/net/ipa/ipa_endpoint.h
@@ -44,10 +44,12 @@ enum ipa_endpoint_name {
  * enum ipa_replenish_flag:	RX buffer replenish flags
  *
  * @IPA_REPLENISH_ENABLED:	Whether receive buffer replenishing is enabled
+ * @IPA_REPLENISH_ACTIVE:	Whether replenishing is underway
  * @IPA_REPLENISH_COUNT:	Number of defined replenish flags
  */
 enum ipa_replenish_flag {
 	IPA_REPLENISH_ENABLED,
+	IPA_REPLENISH_ACTIVE,
 	IPA_REPLENISH_COUNT,	/* Number of flags (must be last) */
 };
 


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

* Re: FAILED: patch "[PATCH] net: ipa: prevent concurrent replenish" failed to apply to 5.16-stable tree
  2022-01-24 13:37 FAILED: patch "[PATCH] net: ipa: prevent concurrent replenish" failed to apply to 5.16-stable tree gregkh
@ 2022-01-31 23:39 ` Alex Elder
  2022-02-03 16:58   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Alex Elder @ 2022-01-31 23:39 UTC (permalink / raw)
  To: gregkh, davem; +Cc: stable

On 1/24/22 7:37 AM, gregkh@linuxfoundation.org wrote:
> 
> The patch below does not apply to the 5.16-stable tree.
> If someone wants it applied there, or to any other stable or longterm
> tree, then please email the backport, including the original git commit
> id to <stable@vger.kernel.org>.

Sorry about that.

Unfortunately, the commit in question:

   998c0bd2b3715 net: ipa: prevent concurrent replenish


has one predecessor commit as a prerequisite:

   c1aaa01dbf4ce net: ipa: use a bitmap for endpoint replenish_enabled


I find that I can cleanly cherry-pick the two commits on top of
tag "v5.16.4" cleanly.  I.e.:

   git reset --hard v5.16.4
   git cherry-pick -x c1aaa01dbf4ce 998c0bd2b3715


Is that an adequate solution?  If not, I can supply patches that
do essentially that.

This works on tag "v5.15.18" as well.

Doing this does *not* work on v5.10.95, and I'm working on a
resolution for that and one other back-port that failed.

Thanks.

					-Alex



> 
> thanks,
> 
> greg k-h
> 
> ------------------ original commit in Linus's tree ------------------
> 
>  From 998c0bd2b3715244da7639cc4e6a2062cb79c3f4 Mon Sep 17 00:00:00 2001
> From: Alex Elder <elder@linaro.org>
> Date: Wed, 12 Jan 2022 07:30:12 -0600
> Subject: [PATCH] net: ipa: prevent concurrent replenish
> 
> We have seen cases where an endpoint RX completion interrupt arrives
> while replenishing for the endpoint is underway.  This causes another
> instance of replenishing to begin as part of completing the receive
> transaction.  If this occurs it can lead to transaction corruption.
> 
> Use a new flag to ensure only one replenish instance for an endpoint
> executes at a time.
> 
> Fixes: 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints")
> Signed-off-by: Alex Elder <elder@linaro.org>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> 
> diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c
> index cddddcedaf72..68291a3efd04 100644
> --- a/drivers/net/ipa/ipa_endpoint.c
> +++ b/drivers/net/ipa/ipa_endpoint.c
> @@ -1088,15 +1088,27 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, bool add_one)
>   		return;
>   	}
>   
> +	/* If already active, just update the backlog */
> +	if (test_and_set_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags)) {
> +		if (add_one)
> +			atomic_inc(&endpoint->replenish_backlog);
> +		return;
> +	}
> +
>   	while (atomic_dec_not_zero(&endpoint->replenish_backlog))
>   		if (ipa_endpoint_replenish_one(endpoint))
>   			goto try_again_later;
> +
> +	clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags);
> +
>   	if (add_one)
>   		atomic_inc(&endpoint->replenish_backlog);
>   
>   	return;
>   
>   try_again_later:
> +	clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags);
> +
>   	/* The last one didn't succeed, so fix the backlog */
>   	delta = add_one ? 2 : 1;
>   	backlog = atomic_add_return(delta, &endpoint->replenish_backlog);
> @@ -1691,6 +1703,7 @@ static void ipa_endpoint_setup_one(struct ipa_endpoint *endpoint)
>   		 * backlog is the same as the maximum outstanding TREs.
>   		 */
>   		clear_bit(IPA_REPLENISH_ENABLED, endpoint->replenish_flags);
> +		clear_bit(IPA_REPLENISH_ACTIVE, endpoint->replenish_flags);
>   		atomic_set(&endpoint->replenish_saved,
>   			   gsi_channel_tre_max(gsi, endpoint->channel_id));
>   		atomic_set(&endpoint->replenish_backlog, 0);
> diff --git a/drivers/net/ipa/ipa_endpoint.h b/drivers/net/ipa/ipa_endpoint.h
> index 07d5c20e5f00..0313cdc607de 100644
> --- a/drivers/net/ipa/ipa_endpoint.h
> +++ b/drivers/net/ipa/ipa_endpoint.h
> @@ -44,10 +44,12 @@ enum ipa_endpoint_name {
>    * enum ipa_replenish_flag:	RX buffer replenish flags
>    *
>    * @IPA_REPLENISH_ENABLED:	Whether receive buffer replenishing is enabled
> + * @IPA_REPLENISH_ACTIVE:	Whether replenishing is underway
>    * @IPA_REPLENISH_COUNT:	Number of defined replenish flags
>    */
>   enum ipa_replenish_flag {
>   	IPA_REPLENISH_ENABLED,
> +	IPA_REPLENISH_ACTIVE,
>   	IPA_REPLENISH_COUNT,	/* Number of flags (must be last) */
>   };
>   
> 


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

* Re: FAILED: patch "[PATCH] net: ipa: prevent concurrent replenish" failed to apply to 5.16-stable tree
  2022-01-31 23:39 ` Alex Elder
@ 2022-02-03 16:58   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2022-02-03 16:58 UTC (permalink / raw)
  To: Alex Elder; +Cc: davem, stable

On Mon, Jan 31, 2022 at 05:39:08PM -0600, Alex Elder wrote:
> On 1/24/22 7:37 AM, gregkh@linuxfoundation.org wrote:
> > 
> > The patch below does not apply to the 5.16-stable tree.
> > If someone wants it applied there, or to any other stable or longterm
> > tree, then please email the backport, including the original git commit
> > id to <stable@vger.kernel.org>.
> 
> Sorry about that.
> 
> Unfortunately, the commit in question:
> 
>   998c0bd2b3715 net: ipa: prevent concurrent replenish
> 
> 
> has one predecessor commit as a prerequisite:
> 
>   c1aaa01dbf4ce net: ipa: use a bitmap for endpoint replenish_enabled
> 
> 
> I find that I can cleanly cherry-pick the two commits on top of
> tag "v5.16.4" cleanly.  I.e.:
> 
>   git reset --hard v5.16.4
>   git cherry-pick -x c1aaa01dbf4ce 998c0bd2b3715
> 
> 
> Is that an adequate solution?  If not, I can supply patches that
> do essentially that.
> 
> This works on tag "v5.15.18" as well.

Great, now queued up.

thanks,

greg k-h

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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-24 13:37 FAILED: patch "[PATCH] net: ipa: prevent concurrent replenish" failed to apply to 5.16-stable tree gregkh
2022-01-31 23:39 ` 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.