diff mbox series

drm/i915: use READ_ONCE() to read vma->iomap in concurrent environment

Message ID tencent_1A51A82501181FD23618C68685EBC405990A@qq.com (mailing list archive)
State New, archived
Headers show
Series drm/i915: use READ_ONCE() to read vma->iomap in concurrent environment | expand

Commit Message

linke li Jan. 29, 2024, 4:34 a.m. UTC
In function i915_vma_pin_iomap(), vma->iomap is read using READ_ONCE()
in line 562

562    ptr = READ_ONCE(vma->iomap);

while read directly in line 597

592    if (unlikely(cmpxchg(&vma->iomap, NULL, ptr))) {
593        if (page_unmask_bits(ptr))
594            __i915_gem_object_release_map(vma->obj);
595        else
596            io_mapping_unmap(ptr);
597        ptr = vma->iomap;

There is patch similar to this. https://github.com/torvalds/linux/commit/c1c0ce31b2420d5c173228a2132a492ede03d81f
This patch find two read of same variable while one is protected, another
is not. And READ_ONCE() is added to protect.

Signed-off-by: linke li <lilinke99@qq.com>
---
 drivers/gpu/drm/i915/i915_vma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

linke li March 21, 2024, 9:49 a.m. UTC | #1
Hi, I want to confirm the status of this patch and whether need any
additional information.
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index d09aad34ba37..9fcc11db0505 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -594,7 +594,7 @@  void __iomem *i915_vma_pin_iomap(struct i915_vma *vma)
 				__i915_gem_object_release_map(vma->obj);
 			else
 				io_mapping_unmap(ptr);
-			ptr = vma->iomap;
+			ptr = READ_ONCE(vma->iomap);
 		}
 	}