All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: ipa: only reset hashed tables when supported
@ 2023-07-24 22:41 Alex Elder
  2023-07-25  7:08 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Elder @ 2023-07-24 22:41 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni
  Cc: dianders, caleb.connolly, mka, evgreen, andersson, quic_cpratapa,
	quic_avuyyuru, quic_jponduru, quic_subashab, elder, netdev,
	linux-arm-msm, linux-kernel, stable

Last year, the code that manages GSI channel transactions switched
from using spinlock-protected linked lists to using indexes into the
ring buffer used for a channel.  Recently, Google reported seeing
transaction reference count underflows occasionally during shutdown.

Doug Anderson found a way to reproduce the issue reliably, and
bisected the issue to the commit that eliminated the linked lists
and the lock.  The root cause was ultimately determined to be
related to unused transactions being committed as part of the modem
shutdown cleanup activity.  Unused transactions are not normally
expected (except in error cases).

The modem uses some ranges of IPA-resident memory, and whenever it
shuts down we zero those ranges.  In ipa_filter_reset_table() a
transaction is allocated to zero modem filter table entries.  If
hashing is not supported, hashed table memory should not be zeroed.
But currently nothing prevents that, and the result is an unused
transaction.  Something similar occurs when we zero routing table
entries for the modem.

By preventing any attempt to clear hashed tables when hashing is not
supported, the reference count underflow is avoided in this case.

Note that there likely remains an issue with properly freeing unused
transactions (if they occur due to errors).  This patch addresses
only the underflows that Google originally reported.

Fixes: d338ae28d8a8 ("net: ipa: kill all other transaction lists")
Cc: <stable@vger.kernel.org>    # 6.1.x
Tested-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Alex Elder <elder@linaro.org>
---
 drivers/net/ipa/ipa_table.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c
index 510ff2dc8999a..cd81dd916c29e 100644
--- a/drivers/net/ipa/ipa_table.c
+++ b/drivers/net/ipa/ipa_table.c
@@ -311,16 +311,15 @@ static int ipa_filter_reset(struct ipa *ipa, bool modem)
 	if (ret)
 		return ret;
 
-	ret = ipa_filter_reset_table(ipa, IPA_MEM_V4_FILTER_HASHED, modem);
-	if (ret)
-		return ret;
-
 	ret = ipa_filter_reset_table(ipa, IPA_MEM_V6_FILTER, modem);
+	if (ret || !ipa_table_hash_support(ipa))
+		return ret;
+
+	ret = ipa_filter_reset_table(ipa, IPA_MEM_V4_FILTER_HASHED, modem);
 	if (ret)
 		return ret;
-	ret = ipa_filter_reset_table(ipa, IPA_MEM_V6_FILTER_HASHED, modem);
 
-	return ret;
+	return ipa_filter_reset_table(ipa, IPA_MEM_V6_FILTER_HASHED, modem);
 }
 
 /* The AP routes and modem routes are each contiguous within the
@@ -329,11 +328,12 @@ static int ipa_filter_reset(struct ipa *ipa, bool modem)
  * */
 static int ipa_route_reset(struct ipa *ipa, bool modem)
 {
+	bool hash_support = ipa_table_hash_support(ipa);
 	struct gsi_trans *trans;
 	u16 first;
 	u16 count;
 
-	trans = ipa_cmd_trans_alloc(ipa, 4);
+	trans = ipa_cmd_trans_alloc(ipa, hash_support ? 4 : 2);
 	if (!trans) {
 		dev_err(&ipa->pdev->dev,
 			"no transaction for %s route reset\n",
@@ -350,12 +350,14 @@ static int ipa_route_reset(struct ipa *ipa, bool modem)
 	}
 
 	ipa_table_reset_add(trans, false, first, count, IPA_MEM_V4_ROUTE);
-	ipa_table_reset_add(trans, false, first, count,
-			    IPA_MEM_V4_ROUTE_HASHED);
-
 	ipa_table_reset_add(trans, false, first, count, IPA_MEM_V6_ROUTE);
-	ipa_table_reset_add(trans, false, first, count,
-			    IPA_MEM_V6_ROUTE_HASHED);
+
+	if (hash_support) {
+		ipa_table_reset_add(trans, false, first, count,
+				    IPA_MEM_V4_ROUTE_HASHED);
+		ipa_table_reset_add(trans, false, first, count,
+				    IPA_MEM_V6_ROUTE_HASHED);
+	}
 
 	gsi_trans_commit_wait(trans);
 
-- 
2.34.1


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

* Re: [PATCH net] net: ipa: only reset hashed tables when supported
  2023-07-24 22:41 [PATCH net] net: ipa: only reset hashed tables when supported Alex Elder
@ 2023-07-25  7:08 ` Greg KH
  2023-07-25 12:31   ` Alex Elder
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2023-07-25  7:08 UTC (permalink / raw)
  To: Alex Elder
  Cc: davem, edumazet, kuba, pabeni, dianders, caleb.connolly, mka,
	evgreen, andersson, quic_cpratapa, quic_avuyyuru, quic_jponduru,
	quic_subashab, elder, netdev, linux-arm-msm, linux-kernel,
	stable

On Mon, Jul 24, 2023 at 05:41:06PM -0500, Alex Elder wrote:
> Last year, the code that manages GSI channel transactions switched
> from using spinlock-protected linked lists to using indexes into the
> ring buffer used for a channel.  Recently, Google reported seeing
> transaction reference count underflows occasionally during shutdown.
> 
> Doug Anderson found a way to reproduce the issue reliably, and
> bisected the issue to the commit that eliminated the linked lists
> and the lock.  The root cause was ultimately determined to be
> related to unused transactions being committed as part of the modem
> shutdown cleanup activity.  Unused transactions are not normally
> expected (except in error cases).
> 
> The modem uses some ranges of IPA-resident memory, and whenever it
> shuts down we zero those ranges.  In ipa_filter_reset_table() a
> transaction is allocated to zero modem filter table entries.  If
> hashing is not supported, hashed table memory should not be zeroed.
> But currently nothing prevents that, and the result is an unused
> transaction.  Something similar occurs when we zero routing table
> entries for the modem.
> 
> By preventing any attempt to clear hashed tables when hashing is not
> supported, the reference count underflow is avoided in this case.
> 
> Note that there likely remains an issue with properly freeing unused
> transactions (if they occur due to errors).  This patch addresses
> only the underflows that Google originally reported.
> 
> Fixes: d338ae28d8a8 ("net: ipa: kill all other transaction lists")
> Cc: <stable@vger.kernel.org>    # 6.1.x
> Tested-by: Douglas Anderson <dianders@chromium.org>
> Signed-off-by: Alex Elder <elder@linaro.org>
> ---
>  drivers/net/ipa/ipa_table.c | 26 ++++++++++++++------------
>  1 file changed, 14 insertions(+), 12 deletions(-)

You sent 2 different versions of this patch?  Which one is for what
tree?  Is this in Linus's tree already?  If so, what's the git id?

confused,

greg k-h

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

* Re: [PATCH net] net: ipa: only reset hashed tables when supported
  2023-07-25  7:08 ` Greg KH
@ 2023-07-25 12:31   ` Alex Elder
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Elder @ 2023-07-25 12:31 UTC (permalink / raw)
  To: Greg KH, Alex Elder
  Cc: davem, edumazet, kuba, pabeni, dianders, caleb.connolly, mka,
	evgreen, andersson, quic_cpratapa, quic_avuyyuru, quic_jponduru,
	quic_subashab, elder, netdev, linux-arm-msm, linux-kernel,
	stable

On 7/25/23 2:08 AM, Greg KH wrote:
> You sent 2 different versions of this patch?  Which one is for what
> tree?  Is this in Linus's tree already?  If so, what's the git id?

It was a mistake.  I reached out to the netdev maintainers
yesterday to explain and I'm sorry I didn't do the same for
you/stable.

One of those patches will be brought upstream the normal
netdev way.  Back-porting to 6.1 won't work cleanly--and
once it's upstream I'll provide the other one if required.

I'm really sorry to have caused the confusion.

					-Alex

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

* [PATCH net] net: ipa: only reset hashed tables when supported
@ 2023-07-24 22:40 Alex Elder
  0 siblings, 0 replies; 4+ messages in thread
From: Alex Elder @ 2023-07-24 22:40 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni
  Cc: dianders, caleb.connolly, mka, evgreen, andersson, quic_cpratapa,
	quic_avuyyuru, quic_jponduru, quic_subashab, elder, netdev,
	linux-arm-msm, linux-kernel, stable

Last year, the code that manages GSI channel transactions switched
from using spinlock-protected linked lists to using indexes into the
ring buffer used for a channel.  Recently, Google reported seeing
transaction reference count underflows occasionally during shutdown.

Doug Anderson found a way to reproduce the issue reliably, and
bisected the issue to the commit that eliminated the linked lists
and the lock.  The root cause was ultimately determined to be
related to unused transactions being committed as part of the modem
shutdown cleanup activity.  Unused transactions are not normally
expected (except in error cases).

The modem uses some ranges of IPA-resident memory, and whenever it
shuts down we zero those ranges.  In ipa_filter_reset_table() a
transaction is allocated to zero modem filter table entries.  If
hashing is not supported, hashed table memory should not be zeroed.
But currently nothing prevents that, and the result is an unused
transaction.  Something similar occurs when we zero routing table
entries for the modem.

By preventing any attempt to clear hashed tables when hashing is not
supported, the reference count underflow is avoided in this case.

Note that there likely remains an issue with properly freeing unused
transactions (if they occur due to errors).  This patch addresses
only the underflows that Google originally reported.

Fixes: d338ae28d8a8 ("net: ipa: kill all other transaction lists")
Cc: <stable@vger.kernel.org>	# 6.4.x
Tested-by: Douglas Anderson <dianders@chromium.org>
Signed-off-by: Alex Elder <elder@linaro.org>
---
 drivers/net/ipa/ipa_table.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c
index f0529c31d0b6e..7b637bb8b41c8 100644
--- a/drivers/net/ipa/ipa_table.c
+++ b/drivers/net/ipa/ipa_table.c
@@ -273,16 +273,15 @@ static int ipa_filter_reset(struct ipa *ipa, bool modem)
 	if (ret)
 		return ret;
 
-	ret = ipa_filter_reset_table(ipa, true, false, modem);
-	if (ret)
-		return ret;
-
 	ret = ipa_filter_reset_table(ipa, false, true, modem);
+	if (ret || !ipa_table_hash_support(ipa))
+		return ret;
+
+	ret = ipa_filter_reset_table(ipa, true, false, modem);
 	if (ret)
 		return ret;
-	ret = ipa_filter_reset_table(ipa, true, true, modem);
 
-	return ret;
+	return ipa_filter_reset_table(ipa, true, true, modem);
 }
 
 /* The AP routes and modem routes are each contiguous within the
@@ -291,12 +290,13 @@ static int ipa_filter_reset(struct ipa *ipa, bool modem)
  * */
 static int ipa_route_reset(struct ipa *ipa, bool modem)
 {
+	bool hash_support = ipa_table_hash_support(ipa);
 	u32 modem_route_count = ipa->modem_route_count;
 	struct gsi_trans *trans;
 	u16 first;
 	u16 count;
 
-	trans = ipa_cmd_trans_alloc(ipa, 4);
+	trans = ipa_cmd_trans_alloc(ipa, hash_support ? 4 : 2);
 	if (!trans) {
 		dev_err(&ipa->pdev->dev,
 			"no transaction for %s route reset\n",
@@ -313,10 +313,12 @@ static int ipa_route_reset(struct ipa *ipa, bool modem)
 	}
 
 	ipa_table_reset_add(trans, false, false, false, first, count);
-	ipa_table_reset_add(trans, false, true, false, first, count);
-
 	ipa_table_reset_add(trans, false, false, true, first, count);
-	ipa_table_reset_add(trans, false, true, true, first, count);
+
+	if (hash_support) {
+		ipa_table_reset_add(trans, false, true, false, first, count);
+		ipa_table_reset_add(trans, false, true, true, first, count);
+	}
 
 	gsi_trans_commit_wait(trans);
 
-- 
2.34.1


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

end of thread, other threads:[~2023-07-25 12:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-24 22:41 [PATCH net] net: ipa: only reset hashed tables when supported Alex Elder
2023-07-25  7:08 ` Greg KH
2023-07-25 12:31   ` Alex Elder
  -- strict thread matches above, loose matches on Subject: below --
2023-07-24 22:40 Alex Elder

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.