[PATCH 1/2] drm/buddy: Add public helper to dirty blocks

Paneer Selvam, Arunpravin arunpravin.paneerselvam at amd.com
Thu May 29 07:05:18 UTC 2025



On 5/28/2025 1:13 AM, Natalie Vock wrote:
> Cleared blocks that are handed out to users after allocation cannot be
> presumed to remain cleared. Thus, allocators using drm_buddy need to
> dirty all blocks on the allocation success path. Provide a helper for
> them to use.
>
> Fixes: 96950929eb232 ("drm/buddy: Implement tracking clear page feature")
> Cc:stable at vger.kernel.org
>
> Signed-off-by: Natalie Vock<natalie.vock at gmx.de>
> ---
>   include/drm/drm_buddy.h | 6 ++++++
>   1 file changed, 6 insertions(+)
>
> diff --git a/include/drm/drm_buddy.h b/include/drm/drm_buddy.h
> index 9689a7c5dd36..48628ff1c24f 100644
> --- a/include/drm/drm_buddy.h
> +++ b/include/drm/drm_buddy.h
> @@ -142,6 +142,12 @@ drm_buddy_block_size(struct drm_buddy *mm,
>   	return mm->chunk_size << drm_buddy_block_order(block);
>   }
>   
> +static inline void
> +drm_buddy_block_set_dirty(struct drm_buddy_block *block)
> +{
> +	block->header &= ~DRM_BUDDY_HEADER_CLEAR;

The users should not modify this DRM_BUDDY_HEADER_CLEAR flag directly; 
instead, please use the DRM_BUDDY_CLEARED flag in the driver.

The buddy manager will take care of this DRM_BUDDY_HEADER_CLEAR flag.

> +}
> +
>   int drm_buddy_init(struct drm_buddy *mm, u64 size, u64 chunk_size);
>   
>   void drm_buddy_fini(struct drm_buddy *mm);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/dri-devel/attachments/20250529/062cfa4f/attachment.htm>


More information about the dri-devel mailing list