* [PATCH] kunit: drm: make DRM buddy test compatible with other pages sizes
@ 2023-04-18 17:15 Nico Pache
2023-04-19 8:27 ` David Gow
2023-04-19 8:30 ` Christian König
0 siblings, 2 replies; 4+ messages in thread
From: Nico Pache @ 2023-04-18 17:15 UTC (permalink / raw)
To: linux-kernel, dri-devel
Cc: matthew.auld, arunpravin.paneerselvam, arthurgrillo, davidgow,
javierm, christian.koenig, mairacanal, daniel, airlied, ddutile,
kunit-dev
The DRM buddy test uses a fixed 12 bit shift to covert from pages to
bytes. This number is then used to confirm that (chunk_size < PAGE_SIZE)
which can lead to a failing drm_buddy_init on systems with PAGE_SIZE > 4k.
Fixes: 92937f170d3f ("drm/selftests: add drm buddy alloc range testcase")
Signed-off-by: Nico Pache <npache@redhat.com>
---
drivers/gpu/drm/tests/drm_buddy_test.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c
index 09ee6f6af896..a62b2690d3c2 100644
--- a/drivers/gpu/drm/tests/drm_buddy_test.c
+++ b/drivers/gpu/drm/tests/drm_buddy_test.c
@@ -318,8 +318,8 @@ static void mm_config(u64 *size, u64 *chunk_size)
s &= -ms;
/* Convert from pages to bytes */
- *chunk_size = (u64)ms << 12;
- *size = (u64)s << 12;
+ *chunk_size = (u64)ms << PAGE_SHIFT;
+ *size = (u64)s << PAGE_SHIFT;
}
static void drm_test_buddy_alloc_pathological(struct kunit *test)
--
2.39.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kunit: drm: make DRM buddy test compatible with other pages sizes
2023-04-18 17:15 [PATCH] kunit: drm: make DRM buddy test compatible with other pages sizes Nico Pache
@ 2023-04-19 8:27 ` David Gow
2023-04-19 8:30 ` Christian König
1 sibling, 0 replies; 4+ messages in thread
From: David Gow @ 2023-04-19 8:27 UTC (permalink / raw)
To: Nico Pache
Cc: linux-kernel, dri-devel, matthew.auld, arunpravin.paneerselvam,
arthurgrillo, javierm, christian.koenig, mairacanal, daniel,
airlied, ddutile, kunit-dev
[-- Attachment #1: Type: text/plain, Size: 1323 bytes --]
On Wed, 19 Apr 2023 at 01:15, Nico Pache <npache@redhat.com> wrote:
>
> The DRM buddy test uses a fixed 12 bit shift to covert from pages to
> bytes. This number is then used to confirm that (chunk_size < PAGE_SIZE)
> which can lead to a failing drm_buddy_init on systems with PAGE_SIZE > 4k.
>
> Fixes: 92937f170d3f ("drm/selftests: add drm buddy alloc range testcase")
> Signed-off-by: Nico Pache <npache@redhat.com>
> ---
Nice catch! This makes sense to me (and doesn't regress anything on my
various 4k-page machines, at least).
Reviewed-by: David Gow <davidgow@google.com>
Cheers,
-- David
> drivers/gpu/drm/tests/drm_buddy_test.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c
> index 09ee6f6af896..a62b2690d3c2 100644
> --- a/drivers/gpu/drm/tests/drm_buddy_test.c
> +++ b/drivers/gpu/drm/tests/drm_buddy_test.c
> @@ -318,8 +318,8 @@ static void mm_config(u64 *size, u64 *chunk_size)
> s &= -ms;
>
> /* Convert from pages to bytes */
> - *chunk_size = (u64)ms << 12;
> - *size = (u64)s << 12;
> + *chunk_size = (u64)ms << PAGE_SHIFT;
> + *size = (u64)s << PAGE_SHIFT;
> }
>
> static void drm_test_buddy_alloc_pathological(struct kunit *test)
> --
> 2.39.2
>
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4003 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kunit: drm: make DRM buddy test compatible with other pages sizes
2023-04-18 17:15 [PATCH] kunit: drm: make DRM buddy test compatible with other pages sizes Nico Pache
2023-04-19 8:27 ` David Gow
@ 2023-04-19 8:30 ` Christian König
2023-06-26 15:27 ` Nico Pache
1 sibling, 1 reply; 4+ messages in thread
From: Christian König @ 2023-04-19 8:30 UTC (permalink / raw)
To: Nico Pache, linux-kernel, dri-devel
Cc: matthew.auld, arunpravin.paneerselvam, arthurgrillo, davidgow,
javierm, mairacanal, daniel, airlied, ddutile, kunit-dev
Am 18.04.23 um 19:15 schrieb Nico Pache:
> The DRM buddy test uses a fixed 12 bit shift to covert from pages to
> bytes. This number is then used to confirm that (chunk_size < PAGE_SIZE)
> which can lead to a failing drm_buddy_init on systems with PAGE_SIZE > 4k.
Since the buddy allocator is used for resources which are independent of
the CPU PAGE size the later check is actually the broken one.
E.g. neither in the buddy allocator nor in it's test cases we should
have any of PAGE_SHIFT or PAGE_SIZE.
Otherwise the allocator wouldn't work correctly on systems with a
PAGE_SIZE different than 4k.
Regards,
Christian.
>
> Fixes: 92937f170d3f ("drm/selftests: add drm buddy alloc range testcase")
> Signed-off-by: Nico Pache <npache@redhat.com>
> ---
> drivers/gpu/drm/tests/drm_buddy_test.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c
> index 09ee6f6af896..a62b2690d3c2 100644
> --- a/drivers/gpu/drm/tests/drm_buddy_test.c
> +++ b/drivers/gpu/drm/tests/drm_buddy_test.c
> @@ -318,8 +318,8 @@ static void mm_config(u64 *size, u64 *chunk_size)
> s &= -ms;
>
> /* Convert from pages to bytes */
> - *chunk_size = (u64)ms << 12;
> - *size = (u64)s << 12;
> + *chunk_size = (u64)ms << PAGE_SHIFT;
> + *size = (u64)s << PAGE_SHIFT;
> }
>
> static void drm_test_buddy_alloc_pathological(struct kunit *test)
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] kunit: drm: make DRM buddy test compatible with other pages sizes
2023-04-19 8:30 ` Christian König
@ 2023-06-26 15:27 ` Nico Pache
0 siblings, 0 replies; 4+ messages in thread
From: Nico Pache @ 2023-06-26 15:27 UTC (permalink / raw)
To: Christian König, davidgow
Cc: linux-kernel, dri-devel, ddutile, kunit-dev
Hi Christian,
Thanks for the information! I am not very familiar with the inner
workings of DRM, so I'm not really in a position to make any large or
systematic changes to the test regarding the points you made. I am
mainly trying to allow the tests to be run on more diverse hardware.
From the looks of it this test has been adapted from an older test, so
perhaps this rule was set in place in the past.
Either way, I dont think my changes are going to break anything, so
for the time being I think this small change is the best approach.
Please let me know if you think otherwise.
David, do you still have this on your radar? We've been carrying this
as a RHEL-only since I originally posted it and have not noticed any
issues due to it.
Cheers,
-- Nico
On Wed, Apr 19, 2023 at 4:30 AM Christian König
<christian.koenig@amd.com> wrote:
>
> Am 18.04.23 um 19:15 schrieb Nico Pache:
> > The DRM buddy test uses a fixed 12 bit shift to covert from pages to
> > bytes. This number is then used to confirm that (chunk_size < PAGE_SIZE)
> > which can lead to a failing drm_buddy_init on systems with PAGE_SIZE > 4k.
>
> Since the buddy allocator is used for resources which are independent of
> the CPU PAGE size the later check is actually the broken one.
>
> E.g. neither in the buddy allocator nor in it's test cases we should
> have any of PAGE_SHIFT or PAGE_SIZE.
>
> Otherwise the allocator wouldn't work correctly on systems with a
> PAGE_SIZE different than 4k.
>
> Regards,
> Christian.
>
> >
> > Fixes: 92937f170d3f ("drm/selftests: add drm buddy alloc range testcase")
> > Signed-off-by: Nico Pache <npache@redhat.com>
> > ---
> > drivers/gpu/drm/tests/drm_buddy_test.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/tests/drm_buddy_test.c b/drivers/gpu/drm/tests/drm_buddy_test.c
> > index 09ee6f6af896..a62b2690d3c2 100644
> > --- a/drivers/gpu/drm/tests/drm_buddy_test.c
> > +++ b/drivers/gpu/drm/tests/drm_buddy_test.c
> > @@ -318,8 +318,8 @@ static void mm_config(u64 *size, u64 *chunk_size)
> > s &= -ms;
> >
> > /* Convert from pages to bytes */
> > - *chunk_size = (u64)ms << 12;
> > - *size = (u64)s << 12;
> > + *chunk_size = (u64)ms << PAGE_SHIFT;
> > + *size = (u64)s << PAGE_SHIFT;
> > }
> >
> > static void drm_test_buddy_alloc_pathological(struct kunit *test)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-06-26 15:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-18 17:15 [PATCH] kunit: drm: make DRM buddy test compatible with other pages sizes Nico Pache
2023-04-19 8:27 ` David Gow
2023-04-19 8:30 ` Christian König
2023-06-26 15:27 ` Nico Pache
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®