Skip to content

Commit 1963546

Browse files
kwachowssgruszka
authored andcommitted
accel/ivpu: Add set_pages_array_wc/uc for internal buffers
Buffers mapped with pgprot_writecombined() are not correctly flushed. This triggers issues on VPU access using random memory content such as MMU translation faults, invalid context descriptors being fetched and can lead to VPU FW crashes. Fixes: 647371a ("accel/ivpu: Add GEM buffer object management") Cc: stable@vger.kernel.org # 6.3+ Signed-off-by: Karol Wachowski <karol.wachowski@linux.intel.com> Reviewed-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com> Signed-off-by: Stanislaw Gruszka <stanislaw.gruszka@linux.intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230802063735.3005291-1-stanislaw.gruszka@linux.intel.com
1 parent d5712cd commit 1963546

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/accel/ivpu/ivpu_gem.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ static void internal_free_pages_locked(struct ivpu_bo *bo)
173173
{
174174
unsigned int i, npages = bo->base.size >> PAGE_SHIFT;
175175

176+
if (ivpu_bo_cache_mode(bo) != DRM_IVPU_BO_CACHED)
177+
set_pages_array_wb(bo->pages, bo->base.size >> PAGE_SHIFT);
178+
176179
for (i = 0; i < npages; i++)
177180
put_page(bo->pages[i]);
178181

@@ -587,6 +590,11 @@ ivpu_bo_alloc_internal(struct ivpu_device *vdev, u64 vpu_addr, u64 size, u32 fla
587590
if (ivpu_bo_cache_mode(bo) != DRM_IVPU_BO_CACHED)
588591
drm_clflush_pages(bo->pages, bo->base.size >> PAGE_SHIFT);
589592

593+
if (bo->flags & DRM_IVPU_BO_WC)
594+
set_pages_array_wc(bo->pages, bo->base.size >> PAGE_SHIFT);
595+
else if (bo->flags & DRM_IVPU_BO_UNCACHED)
596+
set_pages_array_uc(bo->pages, bo->base.size >> PAGE_SHIFT);
597+
590598
prot = ivpu_bo_pgprot(bo, PAGE_KERNEL);
591599
bo->kvaddr = vmap(bo->pages, bo->base.size >> PAGE_SHIFT, VM_MAP, prot);
592600
if (!bo->kvaddr) {

0 commit comments

Comments
 (0)