]> git.itanic.dy.fi Git - linux-stable/commitdiff
net: ipa: support more endpoints
authorAlex Elder <elder@linaro.org>
Mon, 30 Jan 2023 21:01:51 +0000 (15:01 -0600)
committerJakub Kicinski <kuba@kernel.org>
Wed, 1 Feb 2023 05:45:51 +0000 (21:45 -0800)
Increase the number of endpoints supported by the driver to 36,
which IPA v5.0 supports.  This makes it impossible to check at build
time whether the supported number is too big to fit within the
(5-bit) PACKET_INIT destination endpoint field.  Instead, convert
the build time check to compare against what fits in 8 bits.

Add a check in ipa_endpoint_config() to also ensure the hardware
reports an endpoint count that's in the expected range.  Just
open-code 32 as the limit (the PACKET_INIT field mask is not
available where we'd want to use it).

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ipa/ipa_cmd.c
drivers/net/ipa/ipa_endpoint.c
drivers/net/ipa/ipa_endpoint.h

index bb3dfa9a2bc81564c6e527302343c541e130b3d0..aa2b594ca5067ff0972882786ae741b3efe814b0 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 
 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
- * Copyright (C) 2019-2022 Linaro Ltd.
+ * Copyright (C) 2019-2023 Linaro Ltd.
  */
 
 #include <linux/types.h>
@@ -157,9 +157,14 @@ static void ipa_cmd_validate_build(void)
        BUILD_BUG_ON(field_max(IP_FLTRT_FLAGS_HASH_ADDR_FMASK) !=
                     field_max(IP_FLTRT_FLAGS_NHASH_ADDR_FMASK));
 
-       /* Valid endpoint numbers must fit in the IP packet init command */
-       BUILD_BUG_ON(field_max(IPA_PACKET_INIT_DEST_ENDPOINT_FMASK) <
-                    IPA_ENDPOINT_MAX - 1);
+       /* Prior to IPA v5.0, we supported no more than 32 endpoints,
+        * and this was reflected in some 5-bit fields that held
+        * endpoint numbers.  Starting with IPA v5.0, the widths of
+        * these fields were extended to 8 bits, meaning up to 256
+        * endpoints.  If the driver claims to support more than
+        * that it's an error.
+        */
+       BUILD_BUG_ON(IPA_ENDPOINT_MAX - 1 > U8_MAX);
 }
 
 /* Validate a memory region holding a table */
index ce7f2d6e447ed2a25703f1bcb995673b110095c2..8909ba8bfd0e902680d209763d8bd944644cb518 100644 (file)
@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0
 
 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
- * Copyright (C) 2019-2022 Linaro Ltd.
+ * Copyright (C) 2019-2023 Linaro Ltd.
  */
 
 #include <linux/types.h>
@@ -1986,6 +1986,7 @@ int ipa_endpoint_config(struct ipa *ipa)
        struct device *dev = &ipa->pdev->dev;
        const struct ipa_reg *reg;
        u32 endpoint_id;
+       u32 hw_limit;
        u32 tx_count;
        u32 rx_count;
        u32 rx_base;
@@ -2031,6 +2032,14 @@ int ipa_endpoint_config(struct ipa *ipa)
                return -EINVAL;
        }
 
+       /* Until IPA v5.0, the max endpoint ID was 32 */
+       hw_limit = ipa->version < IPA_VERSION_5_0 ? 32 : U8_MAX + 1;
+       if (limit > hw_limit) {
+               dev_err(dev, "unexpected endpoint count, %u > %u\n",
+                       limit, hw_limit);
+               return -EINVAL;
+       }
+
        /* Allocate and initialize the available endpoint bitmap */
        ipa->available = bitmap_zalloc(limit, GFP_KERNEL);
        if (!ipa->available)
index 4a5c3bc549df5dac290a7412f223647276b4dcda..3ad2e802040aaaade4fb4517d61d2cd965279dc4 100644 (file)
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 
 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
- * Copyright (C) 2019-2022 Linaro Ltd.
+ * Copyright (C) 2019-2023 Linaro Ltd.
  */
 #ifndef _IPA_ENDPOINT_H_
 #define _IPA_ENDPOINT_H_
@@ -38,7 +38,7 @@ enum ipa_endpoint_name {
        IPA_ENDPOINT_COUNT,     /* Number of names (not an index) */
 };
 
-#define IPA_ENDPOINT_MAX               32      /* Max supported by driver */
+#define IPA_ENDPOINT_MAX               36      /* Max supported by driver */
 
 /**
  * struct ipa_endpoint_tx - Endpoint configuration for TX endpoints