* [PATCH] [v2] iommu/io-pgtable-arm: dynamically allocate selftest device struct
@ 2025-04-23 16:48 Arnd Bergmann
2025-04-23 17:02 ` Robin Murphy
2025-04-28 11:21 ` Joerg Roedel
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2025-04-23 16:48 UTC (permalink / raw)
To: Will Deacon, Joerg Roedel, Robin Murphy
Cc: Arnd Bergmann, Mostafa Saleh, Jason Gunthorpe, Lu Baolu,
Rob Clark, Kunkun Jiang, Ashish Mhetre, Shameer Kolothum,
linux-arm-kernel, iommu, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
In general a 'struct device' is way too large to be put on the kernel
stack. Apparently something just caused it to grow a slightly larger,
which pushed the arm_lpae_do_selftests() function over the warning
limit in some configurations:
drivers/iommu/io-pgtable-arm.c:1423:19: error: stack frame size (1032) exceeds limit (1024) in 'arm_lpae_do_selftests' [-Werror,-Wframe-larger-than]
1423 | static int __init arm_lpae_do_selftests(void)
| ^
Change the function to use a dynamically allocated faux_device
instead of the on-stack device structure.
Fixes: ca25ec247aad ("iommu/io-pgtable-arm: Remove iommu_dev==NULL special case")
Link: https://lore.kernel.org/all/ab75a444-22a1-47f5-b3c0-253660395b5a@arm.com/
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
v2: use faux device instead of platform_device, as Robin suggested.
The faux device is more appropriate here since the is no actual physical
device, though on the other hand the v1 patch had the advantage of not
actually needing to register the device.
---
drivers/iommu/io-pgtable-arm.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
index 545229cf62d2..bbd42323c029 100644
--- a/drivers/iommu/io-pgtable-arm.c
+++ b/drivers/iommu/io-pgtable-arm.c
@@ -13,6 +13,7 @@
#include <linux/bitops.h>
#include <linux/io-pgtable.h>
#include <linux/kernel.h>
+#include <linux/device/faux.h>
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/types.h>
@@ -1437,15 +1438,17 @@ static int __init arm_lpae_do_selftests(void)
};
int i, j, k, pass = 0, fail = 0;
- struct device dev;
+ struct faux_device *dev;
struct io_pgtable_cfg cfg = {
.tlb = &dummy_tlb_ops,
.coherent_walk = true,
- .iommu_dev = &dev,
};
- /* __arm_lpae_alloc_pages() merely needs dev_to_node() to work */
- set_dev_node(&dev, NUMA_NO_NODE);
+ dev = faux_device_create("io-pgtable-test", NULL, 0);
+ if (!dev)
+ return -ENOMEM;
+
+ cfg.iommu_dev = &dev->dev;
for (i = 0; i < ARRAY_SIZE(pgsize); ++i) {
for (j = 0; j < ARRAY_SIZE(address_size); ++j) {
@@ -1465,6 +1468,8 @@ static int __init arm_lpae_do_selftests(void)
}
pr_info("selftest: completed with %d PASS %d FAIL\n", pass, fail);
+ faux_device_destroy(dev);
+
return fail ? -EFAULT : 0;
}
subsys_initcall(arm_lpae_do_selftests);
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] [v2] iommu/io-pgtable-arm: dynamically allocate selftest device struct
2025-04-23 16:48 [PATCH] [v2] iommu/io-pgtable-arm: dynamically allocate selftest device struct Arnd Bergmann
@ 2025-04-23 17:02 ` Robin Murphy
2025-04-28 11:21 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Robin Murphy @ 2025-04-23 17:02 UTC (permalink / raw)
To: Arnd Bergmann, Will Deacon, Joerg Roedel
Cc: Arnd Bergmann, Mostafa Saleh, Jason Gunthorpe, Lu Baolu,
Rob Clark, Kunkun Jiang, Ashish Mhetre, Shameer Kolothum,
linux-arm-kernel, iommu, linux-kernel
On 2025-04-23 5:48 pm, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> In general a 'struct device' is way too large to be put on the kernel
> stack. Apparently something just caused it to grow a slightly larger,
> which pushed the arm_lpae_do_selftests() function over the warning
> limit in some configurations:
>
> drivers/iommu/io-pgtable-arm.c:1423:19: error: stack frame size (1032) exceeds limit (1024) in 'arm_lpae_do_selftests' [-Werror,-Wframe-larger-than]
> 1423 | static int __init arm_lpae_do_selftests(void)
> | ^
>
> Change the function to use a dynamically allocated faux_device
> instead of the on-stack device structure.
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
> Fixes: ca25ec247aad ("iommu/io-pgtable-arm: Remove iommu_dev==NULL special case")
> Link: https://lore.kernel.org/all/ab75a444-22a1-47f5-b3c0-253660395b5a@arm.com/
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2: use faux device instead of platform_device, as Robin suggested.
> The faux device is more appropriate here since the is no actual physical
> device, though on the other hand the v1 patch had the advantage of not
> actually needing to register the device.
> ---
> drivers/iommu/io-pgtable-arm.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c
> index 545229cf62d2..bbd42323c029 100644
> --- a/drivers/iommu/io-pgtable-arm.c
> +++ b/drivers/iommu/io-pgtable-arm.c
> @@ -13,6 +13,7 @@
> #include <linux/bitops.h>
> #include <linux/io-pgtable.h>
> #include <linux/kernel.h>
> +#include <linux/device/faux.h>
> #include <linux/sizes.h>
> #include <linux/slab.h>
> #include <linux/types.h>
> @@ -1437,15 +1438,17 @@ static int __init arm_lpae_do_selftests(void)
> };
>
> int i, j, k, pass = 0, fail = 0;
> - struct device dev;
> + struct faux_device *dev;
> struct io_pgtable_cfg cfg = {
> .tlb = &dummy_tlb_ops,
> .coherent_walk = true,
> - .iommu_dev = &dev,
> };
>
> - /* __arm_lpae_alloc_pages() merely needs dev_to_node() to work */
> - set_dev_node(&dev, NUMA_NO_NODE);
> + dev = faux_device_create("io-pgtable-test", NULL, 0);
> + if (!dev)
> + return -ENOMEM;
> +
> + cfg.iommu_dev = &dev->dev;
>
> for (i = 0; i < ARRAY_SIZE(pgsize); ++i) {
> for (j = 0; j < ARRAY_SIZE(address_size); ++j) {
> @@ -1465,6 +1468,8 @@ static int __init arm_lpae_do_selftests(void)
> }
>
> pr_info("selftest: completed with %d PASS %d FAIL\n", pass, fail);
> + faux_device_destroy(dev);
> +
> return fail ? -EFAULT : 0;
> }
> subsys_initcall(arm_lpae_do_selftests);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] [v2] iommu/io-pgtable-arm: dynamically allocate selftest device struct
2025-04-23 16:48 [PATCH] [v2] iommu/io-pgtable-arm: dynamically allocate selftest device struct Arnd Bergmann
2025-04-23 17:02 ` Robin Murphy
@ 2025-04-28 11:21 ` Joerg Roedel
1 sibling, 0 replies; 3+ messages in thread
From: Joerg Roedel @ 2025-04-28 11:21 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Will Deacon, Robin Murphy, Arnd Bergmann, Mostafa Saleh,
Jason Gunthorpe, Lu Baolu, Rob Clark, Kunkun Jiang, Ashish Mhetre,
Shameer Kolothum, linux-arm-kernel, iommu, linux-kernel
On Wed, Apr 23, 2025 at 06:48:16PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> In general a 'struct device' is way too large to be put on the kernel
> stack. Apparently something just caused it to grow a slightly larger,
> which pushed the arm_lpae_do_selftests() function over the warning
> limit in some configurations:
>
> drivers/iommu/io-pgtable-arm.c:1423:19: error: stack frame size (1032) exceeds limit (1024) in 'arm_lpae_do_selftests' [-Werror,-Wframe-larger-than]
> 1423 | static int __init arm_lpae_do_selftests(void)
> | ^
>
> Change the function to use a dynamically allocated faux_device
> instead of the on-stack device structure.
>
> Fixes: ca25ec247aad ("iommu/io-pgtable-arm: Remove iommu_dev==NULL special case")
> Link: https://lore.kernel.org/all/ab75a444-22a1-47f5-b3c0-253660395b5a@arm.com/
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> v2: use faux device instead of platform_device, as Robin suggested.
> The faux device is more appropriate here since the is no actual physical
> device, though on the other hand the v1 patch had the advantage of not
> actually needing to register the device.
> ---
> drivers/iommu/io-pgtable-arm.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-28 11:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-23 16:48 [PATCH] [v2] iommu/io-pgtable-arm: dynamically allocate selftest device struct Arnd Bergmann
2025-04-23 17:02 ` Robin Murphy
2025-04-28 11:21 ` Joerg Roedel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox