]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/vmwgfx: clamp dirty-page range with min, not max
authorZack Rusin <zack.rusin@broadcom.com>
Tue, 5 May 2026 22:22:24 +0000 (18:22 -0400)
committerZack Rusin <zack.rusin@broadcom.com>
Mon, 27 Jul 2026 15:29:24 +0000 (11:29 -0400)
vmw_bo_dirty_transfer_to_res() and vmw_bo_dirty_clear() compute the
intersection of a resource's page range with the BO's tracked dirty
range, but clamp res_end against dirty->end with max() instead of
min().  When dirty->end exceeds the resource end, the loop walks past
the resource's pages, calls vmw_resource_dirty_update() for ranges
owned by other resources sharing the same backing MOB and clears
their pending dirty bits via bitmap_clear().  The result is silent
loss of writeback for unrelated resources whenever two resources
share a MOB.

Use min() in both functions so the loop is bounded to the
intersection of the resource and dirty ranges.

Fixes: b7468b15d271 ("drm/vmwgfx: Implement an infrastructure for write-coherent resources")
Fixes: 965544150d1c ("drm/vmwgfx: Refactor cursor handling")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4.7
Signed-off-by: Zack Rusin <zack.rusin@broadcom.com>
Reviewed-by: Ian Forbes <ian.forbes@broadcom.com>
Link: https://patch.msgid.link/20260505222728.519626-4-zack.rusin@broadcom.com
drivers/gpu/drm/vmwgfx/vmwgfx_page_dirty.c

index 45561bc1c9effe68d7676fd5678f458791728a02..8ab88f3886525eb10b63ad4fb5d81e187d2448cd 100644 (file)
@@ -311,7 +311,7 @@ void vmw_bo_dirty_transfer_to_res(struct vmw_resource *res)
                return;
 
        cur = max(res_start, dirty->start);
-       res_end = max(res_end, dirty->end);
+       res_end = min(res_end, dirty->end);
        while (cur < res_end) {
                unsigned long num;
 
@@ -347,7 +347,7 @@ void vmw_bo_dirty_clear(struct vmw_bo *vbo)
                return;
 
        cur = max(res_start, dirty->start);
-       res_end = max(res_end, dirty->end);
+       res_end = min(res_end, dirty->end);
        while (cur < res_end) {
                unsigned long num;