From mboxrd@z Thu Jan 1 00:00:00 1970 From: Claude Code Review Bot To: dri-devel-reviews@example.com Subject: Claude review: drm/buddy: Move internal helpers to buddy.c Date: Wed, 11 Feb 2026 16:07:52 +1000 Message-ID: In-Reply-To: <20260211053123.260037-6-sanjay.kumar.yadav@intel.com> References: <20260211053123.260037-4-sanjay.kumar.yadav@intel.com> <20260211053123.260037-6-sanjay.kumar.yadav@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Mailer: Claude Code Patch Reviewer Patch Review **Overall Assessment:** This patch appropriately hides implementation details by moving unused-externally functions from the header to the source file. The claim of "no functional changes" appears accurate. **Detailed Comments:** #### Functions Being Made Static ```c +static unsigned int +gpu_buddy_block_state(struct gpu_buddy_block *block) +{ + return block->header & GPU_BUDDY_HEADER_STATE; +} ``` **Good:** Reasonable to make static if only used internally. **Code style:** Kernel style typically puts return type on same line as function name for static functions, though this appears consistent with existing code style in this file. ```c +static bool +gpu_buddy_block_is_allocated(struct gpu_buddy_block *block) +{ + return gpu_buddy_block_state(block) == GPU_BUDDY_ALLOCATED; +} + +static bool +gpu_buddy_block_is_split(struct gpu_buddy_block *block) +{ + return gpu_buddy_block_state(block) == GPU_BUDDY_SPLIT; +} ``` **Good:** These are simple wrappers that were unused externally. #### Function Being Removed ```c -/** - * gpu_get_buddy - get buddy address - * - * @block: GPU buddy block - * - * Returns the corresponding buddy block for @block, or NULL - * if this is a root block and can't be merged further. - * Requires some kind of locking to protect against - * any concurrent allocate and free operations. - */ -struct gpu_buddy_block * -gpu_get_buddy(struct gpu_buddy_block *block) -{ - return __get_buddy(block); -} -EXPORT_SYMBOL(gpu_get_buddy); ``` **Critical Question:** This removes an EXPORT_SYMBOL(). Was this symbol truly unused? A simple wrapper removal seems fine, but removing an exported symbol requires verification: 1. Was this checked with `git grep gpu_get_buddy` across the entire kernel tree? 2. Are there any out-of-tree drivers that might use this? 3. Should there be a deprecation period? **If truly unused:** Removing unused exports is good hygiene. **If potentially used:** This would break external modules and needs coordination. #### Function Being Kept ```c static inline bool -gpu_buddy_block_is_allocated(struct gpu_buddy_block *block) +gpu_buddy_block_is_free(struct gpu_buddy_block *block) { - return gpu_buddy_block_state(block) == GPU_BUDDY_ALLOCATED; + return (block->header & GPU_BUDDY_HEADER_STATE) == GPU_BUDDY_FREE; } ``` **From v2 changelog:** "Keep gpu_buddy_block_is_free() in header since it's now used by drm_buddy.c" **Good:** The commit message explains why this stays in the header. **Code change:** The implementation changed from calling `gpu_buddy_block_state()` to directly accessing the header. This is necessary since `gpu_buddy_block_state()` is now static. **Question:** Since this is inlined and used externally, is there any performance impact from the more complex expression `(block->header & GPU_BUDDY_HEADER_STATE) == GPU_BUDDY_FREE` vs the old two-step approach? Probably not, the compiler should optimize identically. #### Header Declaration Removal ```c -struct gpu_buddy_block * -gpu_get_buddy(struct gpu_buddy_block *block); ``` **Good:** Correctly removes the declaration matching the removed export. **Summary for Patch 2:** - The internal API cleanup is sound - Moving internal functions to .c file is appropriate - **Critical concern:** Need confirmation that `gpu_get_buddy()` removal won't break anything - The `gpu_buddy_block_is_free()` handling is well-explained - Code changes match commit message --- ## FINAL RECOMMENDATIONS **Patch 1:** 1. Clarify what was "corrected" regarding tree index values 2. Document unused header bits 8:6 explicitly 3. Consider revising "physically contiguous" terminology 4. Minor: Clarify what "cleared/zeroed" means in GPU context **Patch 2:** 1. **Critical:** Confirm `gpu_get_buddy()` has no users (in-tree or out-of-tree considerations) 2. Consider whether ABI compatibility concerns exist **Series:** - Generally well-executed cleanup - Documentation is a valuable addition - Code movement is appropriate - Version 2 changes address reviewer feedback appropriately --- Generated by Claude Code Patch Reviewer