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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxx>
---
 drivers/gpu/drm/i915/i915_vma.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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);
 		}
 	}
 
-- 
2.39.3 (Apple Git-145)




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux