Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [Low] Unused-but-set variable `target_addr` triggers compiler warning and indicates untested dynamic address. --
--- Patch [2]: [PATCH V2 2/2] gpu/tests/gpu_buddy: Add KUnit test for gpu_buddy_allocated_addr_to_block --- commit 6c61f24067cbdd29a5bf648a9a91a04477bc909c Author: Tejas Upadhyay <[email protected]> gpu/tests/gpu_buddy: Add KUnit test for gpu_buddy_allocated_addr_to_block This commit adds a new KUnit test gpu_test_buddy_addr_to_block() to validate the gpu_buddy_allocated_addr_to_block() helper. The test verifies exact address matching, unallocated addresses, and out-of-bounds addresses. > diff --git a/drivers/gpu/tests/gpu_buddy_test.c > b/drivers/gpu/tests/gpu_buddy_test.c > index 89698563c61b2..826a309697ed3 100644 > --- a/drivers/gpu/tests/gpu_buddy_test.c > +++ b/drivers/gpu/tests/gpu_buddy_test.c [ ... ] > @@ -1422,6 +1422,48 @@ 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; > + u64 target_addr; > + > + 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); > + target_addr = gpu_buddy_block_offset(allocated_block); > + > + found_block = gpu_buddy_allocated_addr_to_block(&mm, alloc_start); [Severity: Low] Is target_addr intentionally left unused here? It is assigned the offset of the allocated block, but alloc_start is passed directly to gpu_buddy_allocated_addr_to_block() instead. This might trigger a compiler warning for an unused-but-set variable and suggests the test could be bypassing the dynamic address it intended to validate. > + KUNIT_EXPECT_PTR_EQ(test, found_block, allocated_block); -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=2
