mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Randy Dunlap <rdunlap@infradead.org>
To: Arnd Bergmann <arnd@kernel.org>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
	"David Airlie" <airlied@gmail.com>,
	"Daniel Vetter" <daniel@ffwll.ch>,
	"Arunpravin Paneer Selvam" <Arunpravin.PaneerSelvam@amd.com>,
	"Christian König" <christian.koenig@amd.com>,
	"David Gow" <davidgow@google.com>,
	"Maíra Canal" <mcanal@igalia.com>,
	"Matthew Auld" <matthew.auld@intel.com>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/tests/drm_buddy: avoid 64-bit calculation
Date: Fri, 16 Feb 2024 17:31:03 -0800	[thread overview]
Message-ID: <745e156e-c3ec-427f-98ad-bfc7d3cfd846@infradead.org> (raw)
In-Reply-To: <20240216202442.2493031-1-arnd@kernel.org>



On 2/16/24 12:24, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> The newly added drm_test_buddy_alloc_contiguous() test fails to link on
> 32-bit targets because of inadvertent 64-bit calculations:
> 
> ERROR: modpost: "__aeabi_uldivmod" [drivers/gpu/drm/tests/drm_buddy_test.ko] undefined!
> ERROR: modpost: "__aeabi_ldivmod" [drivers/gpu/drm/tests/drm_buddy_test.ko] undefined!
> 
>>From what I can tell, the numbers cannot possibly overflow a 32-bit size,
> so use different types for these.
> 
> I noticed that the function has another possible flaw in that is mixes
> what it calls pages with 4KB units. This is a big confusing at best,
> or possibly broken when built on machines with larger pages.
> 
> Fixes: a64056bb5a32 ("drm/tests/drm_buddy: add alloc_contiguous test")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Tested-by: Randy Dunlap <rdunlap@infradead.org>

Thanks.

> ---
>  drivers/gpu/drm/tests/drm_buddy_test.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c
> index fee6bec757d1..50a5f98cd5bd 100644
> --- a/drivers/gpu/drm/tests/drm_buddy_test.c
> +++ b/drivers/gpu/drm/tests/drm_buddy_test.c
> @@ -21,7 +21,8 @@ static inline u64 get_size(int order, u64 chunk_size)
>  
>  static void drm_test_buddy_alloc_contiguous(struct kunit *test)
>  {
> -	u64 mm_size, ps = SZ_4K, i, n_pages, total;
> +	u64 mm_size, total;
> +	u32 i, ps = SZ_4K, n_pages;
>  	struct drm_buddy_block *block;
>  	struct drm_buddy mm;
>  	LIST_HEAD(left);
> @@ -29,7 +30,8 @@ static void drm_test_buddy_alloc_contiguous(struct kunit *test)
>  	LIST_HEAD(right);
>  	LIST_HEAD(allocated);
>  
> -	mm_size = 16 * 3 * SZ_4K;
> +	n_pages = 16 * 3;
> +	mm_size = n_pages * SZ_4K;
>  
>  	KUNIT_EXPECT_FALSE(test, drm_buddy_init(&mm, mm_size, ps));
>  
> @@ -42,7 +44,6 @@ static void drm_test_buddy_alloc_contiguous(struct kunit *test)
>  	 */
>  
>  	i = 0;
> -	n_pages = mm_size / ps;
>  	do {
>  		struct list_head *list;
>  		int slot = i % 3;

-- 
#Randy

  reply	other threads:[~2024-02-17  1:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-16 20:24 Arnd Bergmann
2024-02-17  1:31 ` Randy Dunlap [this message]
2024-02-19 11:22   ` Christian König
2024-02-19 11:29     ` Arnd Bergmann
2024-02-19 11:41       ` Christian König
2024-02-19 11:49         ` Matthew Auld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=745e156e-c3ec-427f-98ad-bfc7d3cfd846@infradead.org \
    --to=rdunlap@infradead.org \
    --cc=Arunpravin.PaneerSelvam@amd.com \
    --cc=airlied@gmail.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=christian.koenig@amd.com \
    --cc=daniel@ffwll.ch \
    --cc=davidgow@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthew.auld@intel.com \
    --cc=mcanal@igalia.com \
    --cc=mripard@kernel.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®