<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body>
    <br>
    <br>
    <div class="moz-cite-prefix">On 5/28/2025 1:13 AM, Natalie Vock
      wrote:<br>
    </div>
    <blockquote type="cite" cite="mid:20250527194353.8023-2-natalie.vock@gmx.de">
      <pre wrap="" class="moz-quote-pre">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: <a class="moz-txt-link-abbreviated" href="mailto:stable@vger.kernel.org">stable@vger.kernel.org</a>

Signed-off-by: Natalie Vock <a class="moz-txt-link-rfc2396E" href="mailto:natalie.vock@gmx.de"><natalie.vock@gmx.de></a>
---
 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;</pre>
    </blockquote>
    <br>
    <p style="font-size: 16px" data-pm-slice="1 1 []">The users should
      not modify this DRM_BUDDY_HEADER_CLEAR flag directly; instead,
      please use the DRM_BUDDY_CLEARED flag in the driver.</p>
    <p style="font-size: 16px" data-pm-slice="1 1 []">The buddy manager
      will take care of this DRM_BUDDY_HEADER_CLEAR flag.</p>
    <blockquote type="cite" cite="mid:20250527194353.8023-2-natalie.vock@gmx.de">
      <pre wrap="" class="moz-quote-pre">
+}
+
 int drm_buddy_init(struct drm_buddy *mm, u64 size, u64 chunk_size);
 
 void drm_buddy_fini(struct drm_buddy *mm);
</pre>
    </blockquote>
    <br>
  </body>
</html>