drm/xe: Convert memory device refcount to s32
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Mon, 23 Jan 2023 14:41:58 +0000 (15:41 +0100)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Tue, 19 Dec 2023 23:27:44 +0000 (18:27 -0500)
The comparison with < 0 suggests that the memory device access
should be signed to handle underflow. This makes it work more reliably.

As a result, the max refcount is now S32_MAX instead.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
drivers/gpu/drm/xe/xe_device.c
drivers/gpu/drm/xe/xe_device_types.h

index 9881b591bfdd3b16f5c704441eb1e36afb65142b..98f08cd9d4b015ab254471c4bf9e5505f8db7065 100644 (file)
@@ -351,7 +351,7 @@ void xe_device_mem_access_get(struct xe_device *xe)
        if (resumed)
                xe_pm_runtime_put(xe);
 
-       XE_WARN_ON(xe->mem_access.ref == U32_MAX);
+       XE_WARN_ON(xe->mem_access.ref == S32_MAX);
 }
 
 void xe_device_mem_access_put(struct xe_device *xe)
index d62ee85bfcbe0b021c09decbbffe874d301c4aa5..81bc293fb240c3edf71c389acf6bde589e43dfcb 100644 (file)
@@ -173,7 +173,7 @@ struct xe_device {
                /** @lock: protect the ref count */
                struct mutex lock;
                /** @ref: ref count of memory accesses */
-               u32 ref;
+               s32 ref;
                /** @hold_rpm: need to put rpm ref back at the end */
                bool hold_rpm;
        } mem_access;