From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6E9271EFFBB for ; Wed, 23 Apr 2025 17:02:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745427764; cv=none; b=lOc8VrHbWDLwHtN/atktTbtQKBl36EToD9I91sdLO7VJgHxyLUqB3+aC4E+aYgOI/D/hP6cxhRIvxZNK94hiudzpNjgIVu1Eeqr3yc0m5nlV8niMFtJktU24OQSbrnUAh7t/RsWRpiEnMJB4KxyM4xy4A4hZDa17ATL1DUbzpYc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745427764; c=relaxed/simple; bh=jnhX8vAIa9TceWzwRkr/EyM2QB8Y09yqhl5U1I5KLTY=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Ak5R3uQA2QNkLPH4YffnXQcErj6y8uD3UQuZJAXidpDPtmCbn6IH5agLrrjyOIlfoTaypPTfEscwI2DCgsgIIJ0MhKES3quF/epC8l4g4BR5TSweCssRUKv9pER+bcavGQhi5g4FMq6Qt4BGsAtCr//JKkU24GqZzLNcmFA2JcA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E46921063; Wed, 23 Apr 2025 10:02:35 -0700 (PDT) Received: from [10.57.74.63] (unknown [10.57.74.63]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 50AC23F66E; Wed, 23 Apr 2025 10:02:38 -0700 (PDT) Message-ID: <4af7c59e-bb1b-4b9e-a61d-90d911df430b@arm.com> Date: Wed, 23 Apr 2025 18:02:36 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] [v2] iommu/io-pgtable-arm: dynamically allocate selftest device struct 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@lists.infradead.org, iommu@lists.linux.dev, linux-kernel@vger.kernel.org References: <20250423164826.2931382-1-arnd@kernel.org> From: Robin Murphy Content-Language: en-GB In-Reply-To: <20250423164826.2931382-1-arnd@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2025-04-23 5:48 pm, Arnd Bergmann wrote: > From: Arnd Bergmann > > 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 > 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 > --- > 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 > #include > #include > +#include > #include > #include > #include > @@ -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);