All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: ipa: compute proper aggregation limit
@ 2022-06-03 12:30 Alex Elder
  2022-06-03 12:30 ` Alex Elder
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alex Elder @ 2022-06-03 12:30 UTC (permalink / raw)
  To: stable; +Cc: David S . Miller

commit c5794097b269f15961ed78f7f27b50e51766dec9 upstream.

The aggregation byte limit for an endpoint is currently computed
based on the endpoint's receive buffer size.

However, some bytes at the front of each receive buffer are reserved
on the assumption that--as with SKBs--it might be useful to insert
data (such as headers) before what lands in the buffer.

The aggregation byte limit currently doesn't take into account that
reserved space, and as a result, aggregation could require space
past that which is available in the buffer.

Fix this by reducing the size used to compute the aggregation byte
limit by the NET_SKB_PAD offset reserved for each receive buffer.

Cc: <stable@vger.kernel.org>    # 5.10.x
Fixes: 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints");
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
The original commit doesn't cherry-pick cleanly to v5.10.119.  -Alex

 drivers/net/ipa/ipa_endpoint.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c
index 621648ce750b7..eb25a13042ea9 100644
--- a/drivers/net/ipa/ipa_endpoint.c
+++ b/drivers/net/ipa/ipa_endpoint.c
@@ -610,12 +610,14 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint *endpoint)
 
 	if (endpoint->data->aggregation) {
 		if (!endpoint->toward_ipa) {
+			u32 buffer_size;
 			u32 limit;
 
 			val |= u32_encode_bits(IPA_ENABLE_AGGR, AGGR_EN_FMASK);
 			val |= u32_encode_bits(IPA_GENERIC, AGGR_TYPE_FMASK);
 
-			limit = ipa_aggr_size_kb(IPA_RX_BUFFER_SIZE);
+			buffer_size = IPA_RX_BUFFER_SIZE - NET_SKB_PAD;
+			limit = ipa_aggr_size_kb(buffer_size);
 			val |= u32_encode_bits(limit, AGGR_BYTE_LIMIT_FMASK);
 
 			limit = IPA_AGGR_TIME_LIMIT_DEFAULT;
-- 
2.32.0


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

* [PATCH] net: ipa: compute proper aggregation limit
  2022-06-03 12:30 [PATCH] net: ipa: compute proper aggregation limit Alex Elder
@ 2022-06-03 12:30 ` Alex Elder
  2022-06-03 12:30 ` Alex Elder
  2022-06-03 14:30 ` Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Elder @ 2022-06-03 12:30 UTC (permalink / raw)
  To: stable; +Cc: David S . Miller

commit c5794097b269f15961ed78f7f27b50e51766dec9 upstream.

The aggregation byte limit for an endpoint is currently computed
based on the endpoint's receive buffer size.

However, some bytes at the front of each receive buffer are reserved
on the assumption that--as with SKBs--it might be useful to insert
data (such as headers) before what lands in the buffer.

The aggregation byte limit currently doesn't take into account that
reserved space, and as a result, aggregation could require space
past that which is available in the buffer.

Fix this by reducing the size used to compute the aggregation byte
limit by the NET_SKB_PAD offset reserved for each receive buffer.

Cc: <stable@vger.kernel.org>    # 5.15.x
Cc: <stable@vger.kernel.org>    # 5.17.x
Fixes: 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints");
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
The original commit doesn't cherry-pick cleanly to v5.15.44 or v5.17.12  -Alex

 drivers/net/ipa/ipa_endpoint.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c
index 87e42db1b61e6..477eb4051bed7 100644
--- a/drivers/net/ipa/ipa_endpoint.c
+++ b/drivers/net/ipa/ipa_endpoint.c
@@ -722,13 +722,15 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint *endpoint)
 
 	if (endpoint->data->aggregation) {
 		if (!endpoint->toward_ipa) {
+			u32 buffer_size;
 			bool close_eof;
 			u32 limit;
 
 			val |= u32_encode_bits(IPA_ENABLE_AGGR, AGGR_EN_FMASK);
 			val |= u32_encode_bits(IPA_GENERIC, AGGR_TYPE_FMASK);
 
-			limit = ipa_aggr_size_kb(IPA_RX_BUFFER_SIZE);
+			buffer_size = IPA_RX_BUFFER_SIZE - NET_SKB_PAD;
+			limit = ipa_aggr_size_kb(buffer_size);
 			val |= aggr_byte_limit_encoded(version, limit);
 
 			limit = IPA_AGGR_TIME_LIMIT;
-- 
2.32.0


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

* [PATCH] net: ipa: compute proper aggregation limit
  2022-06-03 12:30 [PATCH] net: ipa: compute proper aggregation limit Alex Elder
  2022-06-03 12:30 ` Alex Elder
@ 2022-06-03 12:30 ` Alex Elder
  2022-06-03 14:30 ` Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Alex Elder @ 2022-06-03 12:30 UTC (permalink / raw)
  To: stable; +Cc: davem

commit c5794097b269f15961ed78f7f27b50e51766dec9 upstream.

The aggregation byte limit for an endpoint is currently computed
based on the endpoint's receive buffer size.

However, some bytes at the front of each receive buffer are reserved
on the assumption that--as with SKBs--it might be useful to insert
data (such as headers) before what lands in the buffer.

The aggregation byte limit currently doesn't take into account that
reserved space, and as a result, aggregation could require space
past that which is available in the buffer.

Fix this by reducing the size used to compute the aggregation byte
limit by the NET_SKB_PAD offset reserved for each receive buffer.

Cc: <stable@vger.kernel.org>    # 5.18.x
Fixes: 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints");
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
---
The original commit *does* cleanly cherry-pick onto v5.18.1.  -Alex

 drivers/net/ipa/ipa_endpoint.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c
index cea7b2e2ce969..53764f3c0c7e4 100644
--- a/drivers/net/ipa/ipa_endpoint.c
+++ b/drivers/net/ipa/ipa_endpoint.c
@@ -130,9 +130,10 @@ static bool ipa_endpoint_data_valid_one(struct ipa *ipa, u32 count,
 		 */
 		if (data->endpoint.config.aggregation) {
 			limit += SZ_1K * aggr_byte_limit_max(ipa->version);
-			if (buffer_size > limit) {
+			if (buffer_size - NET_SKB_PAD > limit) {
 				dev_err(dev, "RX buffer size too large for aggregated RX endpoint %u (%u > %u)\n",
-					data->endpoint_id, buffer_size, limit);
+					data->endpoint_id,
+					buffer_size - NET_SKB_PAD, limit);
 
 				return false;
 			}
@@ -739,6 +740,7 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint *endpoint)
 	if (endpoint->data->aggregation) {
 		if (!endpoint->toward_ipa) {
 			const struct ipa_endpoint_rx_data *rx_data;
+			u32 buffer_size;
 			bool close_eof;
 			u32 limit;
 
@@ -746,7 +748,8 @@ static void ipa_endpoint_init_aggr(struct ipa_endpoint *endpoint)
 			val |= u32_encode_bits(IPA_ENABLE_AGGR, AGGR_EN_FMASK);
 			val |= u32_encode_bits(IPA_GENERIC, AGGR_TYPE_FMASK);
 
-			limit = ipa_aggr_size_kb(rx_data->buffer_size);
+			buffer_size = rx_data->buffer_size;
+			limit = ipa_aggr_size_kb(buffer_size - NET_SKB_PAD);
 			val |= aggr_byte_limit_encoded(version, limit);
 
 			limit = IPA_AGGR_TIME_LIMIT;
-- 
2.32.0


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

* Re: [PATCH] net: ipa: compute proper aggregation limit
  2022-06-03 12:30 [PATCH] net: ipa: compute proper aggregation limit Alex Elder
  2022-06-03 12:30 ` Alex Elder
  2022-06-03 12:30 ` Alex Elder
@ 2022-06-03 14:30 ` Greg KH
  2 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2022-06-03 14:30 UTC (permalink / raw)
  To: Alex Elder; +Cc: stable, David S . Miller

On Fri, Jun 03, 2022 at 07:30:22AM -0500, Alex Elder wrote:
> commit c5794097b269f15961ed78f7f27b50e51766dec9 upstream.
> 
> The aggregation byte limit for an endpoint is currently computed
> based on the endpoint's receive buffer size.
> 
> However, some bytes at the front of each receive buffer are reserved
> on the assumption that--as with SKBs--it might be useful to insert
> data (such as headers) before what lands in the buffer.
> 
> The aggregation byte limit currently doesn't take into account that
> reserved space, and as a result, aggregation could require space
> past that which is available in the buffer.
> 
> Fix this by reducing the size used to compute the aggregation byte
> limit by the NET_SKB_PAD offset reserved for each receive buffer.
> 
> Cc: <stable@vger.kernel.org>    # 5.10.x
> Fixes: 84f9bd12d46db ("soc: qcom: ipa: IPA endpoints");
> Signed-off-by: Alex Elder <elder@linaro.org>
> Signed-off-by: David S. Miller <davem@davemloft.net>
> ---
> The original commit doesn't cherry-pick cleanly to v5.10.119.  -Alex

All now queued up, thanks.

greg k-h

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

end of thread, other threads:[~2022-06-03 14:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-03 12:30 [PATCH] net: ipa: compute proper aggregation limit Alex Elder
2022-06-03 12:30 ` Alex Elder
2022-06-03 12:30 ` Alex Elder
2022-06-03 14:30 ` 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.