From: Arunpravin Paneer Selvam <arunpravin.paneerselvam@amd.com>
To: "Upadhyay, Tejas" <tejas.upadhyay@intel.com>,
"Auld, Matthew" <matthew.auld@intel.com>,
"intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH V4 2/2] gpu/tests/gpu_buddy: Add KUnit test for gpu_buddy_allocated_addr_to_block
Date: Thu, 6 Aug 2026 17:02:15 +0530 [thread overview]
Message-ID: <843f7781-d75c-4f01-a977-04cf74ceb724@amd.com> (raw)
In-Reply-To: <DS0PR11MB8718001019A9FCB196EC1AD081D22@DS0PR11MB8718.namprd11.prod.outlook.com>
On 8/6/2026 4:48 PM, Upadhyay, Tejas wrote:
>
>> -----Original Message-----
>> From: Arunpravin Paneer Selvam <arunpravin.paneerselvam@amd.com>
>> Sent: 06 August 2026 16:43
>> To: Auld, Matthew <matthew.auld@intel.com>; Upadhyay, Tejas
>> <tejas.upadhyay@intel.com>; intel-xe@lists.freedesktop.org; dri-
>> devel@lists.freedesktop.org
>> Subject: Re: [PATCH V4 2/2] gpu/tests/gpu_buddy: Add KUnit test for
>> gpu_buddy_allocated_addr_to_block
>>
>>
>>
>> On 8/6/2026 3:49 PM, Matthew Auld wrote:
>>> On 06/08/2026 10:46, Upadhyay, Tejas wrote:
>>>>
>>>>> -----Original Message-----
>>>>> From: Auld, Matthew <matthew.auld@intel.com>
>>>>> Sent: 06 August 2026 14:31
>>>>> To: Upadhyay, Tejas <tejas.upadhyay@intel.com>; intel-
>>>>> xe@lists.freedesktop.org; dri-devel@lists.freedesktop.org
>>>>> Cc: arunpravin.paneerselvam@amd.com
>>>>> Subject: Re: [PATCH V4 2/2] gpu/tests/gpu_buddy: Add KUnit test for
>>>>> gpu_buddy_allocated_addr_to_block
>>>>>
>>>>> On 06/08/2026 06:36, Tejas Upadhyay wrote:
>>>>>> Add a new KUnit test gpu_test_buddy_addr_to_block() that validates
>>>>>> the
>>>>>> gpu_buddy_allocated_addr_to_block() helper which traces a address
>>>>>> back to its allocated buddy block.
>>>>>>
>>>>>> The test covers:
>>>>>> - Exact address matching returns the correct allocated block
>>>>>> - An unallocated address inside the manager should return NULL
>>>>>> - An address outside the manager should return -ENXIO
>>>>>>
>>>>>> v4(MattA):
>>>>>> - Add test for unaligned address
>>>>>> v3(Sashiko):
>>>>>> - remove unused target_addr variable
>>>>>> v2(Sashiko):
>>>>>> - Drop the mutex and lockdep annotation; standalone KUnit tests do
>>>>>> not register a driver lock.
>>>>>>
>>>>>> Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
>>>>> Reviewed-by: Matthew Auld <matthew.auld@intel.com>
>>>> Hi Matt,
>>>>
>>>> Thanks for review. Since I don’t have merge rights on drm-tip, Would
>>>> you please help merging this series.
>>> I think Arun normally merges these. Arun, any objections? We need this
>>> for an upcoming driver feature (patches on the list), so wanted to
>>> land this API ahead of time. I don't think this will conflict much
>>> with the big rework you were doing.
>> No objections. Do you want me to merge the series below into drm-misc-
>> next?
>>
>> https://patchwork.freedesktop.org/series/171145/
> Thanks. Yes, you pointed to the right series.
Done. Merged into drm-misc-next.
>
> Tejas
>> Regards,
>> Arun.
>>>> Tejas
>>>>>> ---
>>>>>> drivers/gpu/tests/gpu_buddy_test.c | 45
>>>>> ++++++++++++++++++++++++++++++
>>>>>> 1 file changed, 45 insertions(+)
>>>>>>
>>>>>> diff --git a/drivers/gpu/tests/gpu_buddy_test.c
>>>>>> b/drivers/gpu/tests/gpu_buddy_test.c
>>>>>> index 7df5c2ae83bb..04e425eb8bdd 100644
>>>>>> --- a/drivers/gpu/tests/gpu_buddy_test.c
>>>>>> +++ b/drivers/gpu/tests/gpu_buddy_test.c
>>>>>> @@ -1381,6 +1381,50 @@ static void
>>>>> gpu_test_buddy_alloc_exceeds_max_order(struct kunit *test)
>>>>>> gpu_buddy_fini(&mm);
>>>>>> }
>>>>>>
>>>>>> +static void gpu_test_buddy_addr_to_block(struct kunit *test) {
>>>>>> + struct gpu_buddy_block *allocated_block, *found_block;
>>>>>> + LIST_HEAD(allocated_list);
>>>>>> + const u64 test_size = SZ_4M + SZ_2M;
>>>>>> + const u64 alloc_start = SZ_4M;
>>>>>> + const u64 alloc_size = SZ_4K;
>>>>>> + const u64 chunk_size = SZ_4K;
>>>>>> + struct gpu_buddy mm;
>>>>>> +
>>>>>> + KUNIT_ASSERT_FALSE_MSG(test, gpu_buddy_init(&mm, test_size,
>>>>> chunk_size),
>>>>>> + "buddy_init failed\n");
>>>>>> +
>>>>>> + KUNIT_ASSERT_FALSE_MSG(test, gpu_buddy_alloc_blocks(&mm,
>>>>> alloc_start,
>>>>>> + alloc_start +
>>>>> alloc_size,
>>>>>> + alloc_size,
>>>>> chunk_size,
>>>>>> + &allocated_list, 0),
>>>>>> + "buddy_alloc failed\n");
>>>>>> +
>>>>>> + allocated_block = list_first_entry(&allocated_list, struct
>>>>> gpu_buddy_block, link);
>>>>>> + KUNIT_EXPECT_EQ(test, gpu_buddy_block_offset(allocated_block),
>>>>> alloc_start);
>>>>>> + KUNIT_EXPECT_EQ(test, gpu_buddy_block_size(&mm,
>>>>> allocated_block),
>>>>>> +alloc_size);
>>>>>> +
>>>>>> + found_block = gpu_buddy_allocated_addr_to_block(&mm,
>>>>> alloc_start);
>>>>>> + KUNIT_EXPECT_PTR_EQ(test, found_block, allocated_block);
>>>>>> +
>>>>>> + /* Unaligned address inside the allocated block (should
>>>>>> resolve to the
>>>>> same block) */
>>>>>> + found_block = gpu_buddy_allocated_addr_to_block(&mm,
>>>>>> +alloc_start
>>>>> + 16);
>>>>>> + KUNIT_EXPECT_PTR_EQ(test, found_block, allocated_block);
>>>>>> +
>>>>>> + /* An unallocated address inside the manager should return
>>>>>> NULL. */
>>>>>> + found_block = gpu_buddy_allocated_addr_to_block(&mm,
>>>>>> + alloc_start -
>>>>> chunk_size);
>>>>>> + KUNIT_EXPECT_NULL(test, found_block);
>>>>>> +
>>>>>> + /* An address outside the manager should return -ENXIO. */
>>>>>> + found_block = gpu_buddy_allocated_addr_to_block(&mm,
>>>>>> +test_size);
>>>>>> + KUNIT_EXPECT_EQ(test, PTR_ERR(found_block), -ENXIO);
>>>>>> +
>>>>>> + /* 3. Standard inline cleanup flow */
>>>>>> + gpu_buddy_free_list(&mm, &allocated_list, 0);
>>>>>> + gpu_buddy_fini(&mm);
>>>>>> +}
>>>>>> +
>>>>>> static int gpu_buddy_suite_init(struct kunit_suite *suite)
>>>>>> {
>>>>>> while (!random_seed)
>>>>>> @@ -1405,6 +1449,7 @@ static struct kunit_case gpu_buddy_tests[] =
>>>>>> {
>>>>>> KUNIT_CASE(gpu_test_buddy_alloc_exceeds_max_order),
>>>>>> KUNIT_CASE(gpu_test_buddy_offset_aligned_allocation),
>>>>>> KUNIT_CASE(gpu_test_buddy_subtree_offset_alignment_stress),
>>>>>> + KUNIT_CASE(gpu_test_buddy_addr_to_block),
>>>>>> {}
>>>>>> };
>>>>>>
next prev parent reply other threads:[~2026-08-06 11:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-06 5:36 [PATCH V4 0/2] Add gpu_buddy_allocated_addr_to_block helper and its Kunit tests Tejas Upadhyay
2026-08-06 5:36 ` [PATCH V4 1/2] drm/gpu: Add gpu_buddy_allocated_addr_to_block helper Tejas Upadhyay
2026-08-06 5:36 ` [PATCH V4 2/2] gpu/tests/gpu_buddy: Add KUnit test for gpu_buddy_allocated_addr_to_block Tejas Upadhyay
2026-08-06 9:00 ` Matthew Auld
2026-08-06 9:46 ` Upadhyay, Tejas
2026-08-06 10:19 ` Matthew Auld
2026-08-06 11:12 ` Arunpravin Paneer Selvam
2026-08-06 11:18 ` Upadhyay, Tejas
2026-08-06 11:32 ` Arunpravin Paneer Selvam [this message]
2026-08-06 5:43 ` ✓ CI.KUnit: success for Add gpu_buddy_allocated_addr_to_block helper and its Kunit tests (rev4) Patchwork
2026-08-06 6:20 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-06 15:15 ` ✗ Xe.CI.FULL: failure " Patchwork
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=843f7781-d75c-4f01-a977-04cf74ceb724@amd.com \
--to=arunpravin.paneerselvam@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=matthew.auld@intel.com \
--cc=tejas.upadhyay@intel.com \
/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