* [PATCH V2 1/7] drm/i915: Replace kmap() with kmap_local_page()
2022-01-24 1:54 [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions ira.weiny
@ 2022-01-24 1:54 ` ira.weiny
2022-01-24 1:54 ` [PATCH V2 2/7] drm/amd: " ira.weiny
` (6 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: ira.weiny @ 2022-01-24 1:54 UTC (permalink / raw)
To: David Airlie, Daniel Vetter, Patrik Jakobsson, Rob Clark, Sean Paul
Cc: Ira Weiny, amd-gfx, dri-devel, linux-kernel, intel-gfx, linux-arm-msm
From: Ira Weiny <ira.weiny@intel.com>
kmap() is being deprecated and these usages are all local to the thread
so there is no reason kmap_local_page() can't be used.
Replace kmap() calls with kmap_local_page().
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
Changes for V2:
From Christoph Helwig
Prefer the use of memcpy_*_page() where appropriate.
---
drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 6 ++----
drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c | 8 ++++----
drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c | 4 ++--
drivers/gpu/drm/i915/gt/shmem_utils.c | 7 ++-----
drivers/gpu/drm/i915/i915_gem.c | 8 ++++----
drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++--
6 files changed, 16 insertions(+), 21 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
index cc9fe258fba7..8d6983312cda 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
@@ -619,7 +619,7 @@ i915_gem_object_create_shmem_from_data(struct drm_i915_private *dev_priv,
do {
unsigned int len = min_t(typeof(size), size, PAGE_SIZE);
struct page *page;
- void *pgdata, *vaddr;
+ void *pgdata;
err = pagecache_write_begin(file, file->f_mapping,
offset, len, 0,
@@ -627,9 +627,7 @@ i915_gem_object_create_shmem_from_data(struct drm_i915_private *dev_priv,
if (err < 0)
goto fail;
- vaddr = kmap(page);
- memcpy(vaddr, data, len);
- kunmap(page);
+ memcpy_to_page(page, 0, data, len);
err = pagecache_write_end(file, file->f_mapping,
offset, len, len,
diff --git a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c
index c6291429b00c..faf9f14e13eb 100644
--- a/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c
+++ b/drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c
@@ -145,7 +145,7 @@ static int check_partial_mapping(struct drm_i915_gem_object *obj,
intel_gt_flush_ggtt_writes(to_gt(i915));
p = i915_gem_object_get_page(obj, offset >> PAGE_SHIFT);
- cpu = kmap(p) + offset_in_page(offset);
+ cpu = kmap_local_page(p) + offset_in_page(offset);
drm_clflush_virt_range(cpu, sizeof(*cpu));
if (*cpu != (u32)page) {
pr_err("Partial view for %lu [%u] (offset=%llu, size=%u [%llu, row size %u], fence=%d, tiling=%d, stride=%d) misalignment, expected write to page (%llu + %u [0x%llx]) of 0x%x, found 0x%x\n",
@@ -163,7 +163,7 @@ static int check_partial_mapping(struct drm_i915_gem_object *obj,
}
*cpu = 0;
drm_clflush_virt_range(cpu, sizeof(*cpu));
- kunmap(p);
+ kunmap_local(cpu);
out:
__i915_vma_put(vma);
@@ -239,7 +239,7 @@ static int check_partial_mappings(struct drm_i915_gem_object *obj,
intel_gt_flush_ggtt_writes(to_gt(i915));
p = i915_gem_object_get_page(obj, offset >> PAGE_SHIFT);
- cpu = kmap(p) + offset_in_page(offset);
+ cpu = kmap_local_page(p) + offset_in_page(offset);
drm_clflush_virt_range(cpu, sizeof(*cpu));
if (*cpu != (u32)page) {
pr_err("Partial view for %lu [%u] (offset=%llu, size=%u [%llu, row size %u], fence=%d, tiling=%d, stride=%d) misalignment, expected write to page (%llu + %u [0x%llx]) of 0x%x, found 0x%x\n",
@@ -257,7 +257,7 @@ static int check_partial_mappings(struct drm_i915_gem_object *obj,
}
*cpu = 0;
drm_clflush_virt_range(cpu, sizeof(*cpu));
- kunmap(p);
+ kunmap_local(cpu);
if (err)
return err;
diff --git a/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c b/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
index f8948de72036..743a414f86f3 100644
--- a/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
+++ b/drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c
@@ -743,7 +743,7 @@ static void swizzle_page(struct page *page)
char *vaddr;
int i;
- vaddr = kmap(page);
+ vaddr = kmap_local_page(page);
for (i = 0; i < PAGE_SIZE; i += 128) {
memcpy(temp, &vaddr[i], 64);
@@ -751,7 +751,7 @@ static void swizzle_page(struct page *page)
memcpy(&vaddr[i + 64], temp, 64);
}
- kunmap(page);
+ kunmap_local(vaddr);
}
/**
diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c
index 0683b27a3890..d47f262d2f07 100644
--- a/drivers/gpu/drm/i915/gt/shmem_utils.c
+++ b/drivers/gpu/drm/i915/gt/shmem_utils.c
@@ -97,22 +97,19 @@ static int __shmem_rw(struct file *file, loff_t off,
unsigned int this =
min_t(size_t, PAGE_SIZE - offset_in_page(off), len);
struct page *page;
- void *vaddr;
page = shmem_read_mapping_page_gfp(file->f_mapping, pfn,
GFP_KERNEL);
if (IS_ERR(page))
return PTR_ERR(page);
- vaddr = kmap(page);
if (write) {
- memcpy(vaddr + offset_in_page(off), ptr, this);
+ memcpy_to_page(page, offset_in_page(off), ptr, this);
set_page_dirty(page);
} else {
- memcpy(ptr, vaddr + offset_in_page(off), this);
+ memcpy_from_page(ptr, page, offset_in_page(off), this);
}
mark_page_accessed(page);
- kunmap(page);
put_page(page);
len -= this;
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 915bf431f320..62ba61f31ad1 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -196,14 +196,14 @@ shmem_pread(struct page *page, int offset, int len, char __user *user_data,
char *vaddr;
int ret;
- vaddr = kmap(page);
+ vaddr = kmap_local_page(page);
if (needs_clflush)
drm_clflush_virt_range(vaddr + offset, len);
ret = __copy_to_user(user_data, vaddr + offset, len);
- kunmap(page);
+ kunmap_local(vaddr);
return ret ? -EFAULT : 0;
}
@@ -618,7 +618,7 @@ shmem_pwrite(struct page *page, int offset, int len, char __user *user_data,
char *vaddr;
int ret;
- vaddr = kmap(page);
+ vaddr = kmap_local_page(page);
if (needs_clflush_before)
drm_clflush_virt_range(vaddr + offset, len);
@@ -627,7 +627,7 @@ shmem_pwrite(struct page *page, int offset, int len, char __user *user_data,
if (!ret && needs_clflush_after)
drm_clflush_virt_range(vaddr + offset, len);
- kunmap(page);
+ kunmap_local(vaddr);
return ret ? -EFAULT : 0;
}
diff --git a/drivers/gpu/drm/i915/i915_gpu_error.c b/drivers/gpu/drm/i915/i915_gpu_error.c
index 5ae812d60abe..e83821914703 100644
--- a/drivers/gpu/drm/i915/i915_gpu_error.c
+++ b/drivers/gpu/drm/i915/i915_gpu_error.c
@@ -1093,9 +1093,9 @@ i915_vma_coredump_create(const struct intel_gt *gt,
drm_clflush_pages(&page, 1);
- s = kmap(page);
+ s = kmap_local_page(page);
ret = compress_page(compress, s, dst, false);
- kunmap(page);
+ kunmap_local(s);
drm_clflush_pages(&page, 1);
--
2.31.1
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH V2 2/7] drm/amd: Replace kmap() with kmap_local_page()
2022-01-24 1:54 [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions ira.weiny
2022-01-24 1:54 ` [PATCH V2 1/7] drm/i915: Replace kmap() with kmap_local_page() ira.weiny
@ 2022-01-24 1:54 ` ira.weiny
2022-01-24 1:54 ` [PATCH V2 3/7] drm/gma: Remove calls to kmap() ira.weiny
` (5 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: ira.weiny @ 2022-01-24 1:54 UTC (permalink / raw)
To: David Airlie, Daniel Vetter, Patrik Jakobsson, Rob Clark, Sean Paul
Cc: Ira Weiny, amd-gfx, dri-devel, linux-kernel, intel-gfx, linux-arm-msm
From: Ira Weiny <ira.weiny@intel.com>
kmap() is being deprecated. These maps are thread local and can be
replaced with kmap_local_page().
Replace kmap() with kmap_local_page()
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 5c3f24069f2a..54973824f8f9 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2272,9 +2272,9 @@ static ssize_t amdgpu_iomem_read(struct file *f, char __user *buf,
if (p->mapping != adev->mman.bdev.dev_mapping)
return -EPERM;
- ptr = kmap(p);
+ ptr = kmap_local_page(p);
r = copy_to_user(buf, ptr + off, bytes);
- kunmap(p);
+ kunmap_local(ptr);
if (r)
return -EFAULT;
@@ -2323,9 +2323,9 @@ static ssize_t amdgpu_iomem_write(struct file *f, const char __user *buf,
if (p->mapping != adev->mman.bdev.dev_mapping)
return -EPERM;
- ptr = kmap(p);
+ ptr = kmap_local_page(p);
r = copy_from_user(ptr + off, buf, bytes);
- kunmap(p);
+ kunmap_local(ptr);
if (r)
return -EFAULT;
--
2.31.1
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH V2 3/7] drm/gma: Remove calls to kmap()
2022-01-24 1:54 [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions ira.weiny
2022-01-24 1:54 ` [PATCH V2 1/7] drm/i915: Replace kmap() with kmap_local_page() ira.weiny
2022-01-24 1:54 ` [PATCH V2 2/7] drm/amd: " ira.weiny
@ 2022-01-24 1:54 ` ira.weiny
2022-01-24 16:03 ` Daniel Vetter
2022-01-24 1:54 ` [PATCH V2 4/7] drm/radeon: Replace kmap() with kmap_local_page() ira.weiny
` (4 subsequent siblings)
7 siblings, 1 reply; 11+ messages in thread
From: ira.weiny @ 2022-01-24 1:54 UTC (permalink / raw)
To: David Airlie, Daniel Vetter, Patrik Jakobsson, Rob Clark, Sean Paul
Cc: Ira Weiny, amd-gfx, dri-devel, linux-kernel, intel-gfx, linux-arm-msm
From: Ira Weiny <ira.weiny@intel.com>
kmap() is being deprecated and these instances are easy to convert to
kmap_local_page().
Furthermore, in gma_crtc_cursor_set() use the memcpy_from_page() helper
instead of an open coded use of kmap_local_page().
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
drivers/gpu/drm/gma500/gma_display.c | 6 ++----
drivers/gpu/drm/gma500/mmu.c | 8 ++++----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
index 99da3118131a..60ba7de59139 100644
--- a/drivers/gpu/drm/gma500/gma_display.c
+++ b/drivers/gpu/drm/gma500/gma_display.c
@@ -335,7 +335,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc,
struct psb_gem_object *pobj;
struct psb_gem_object *cursor_pobj = gma_crtc->cursor_pobj;
struct drm_gem_object *obj;
- void *tmp_dst, *tmp_src;
+ void *tmp_dst;
int ret = 0, i, cursor_pages;
/* If we didn't get a handle then turn the cursor off */
@@ -400,9 +400,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc,
/* Copy the cursor to cursor mem */
tmp_dst = dev_priv->vram_addr + cursor_pobj->offset;
for (i = 0; i < cursor_pages; i++) {
- tmp_src = kmap(pobj->pages[i]);
- memcpy(tmp_dst, tmp_src, PAGE_SIZE);
- kunmap(pobj->pages[i]);
+ memcpy_from_page(tmp_dst, pobj->pages[i], 0, PAGE_SIZE);
tmp_dst += PAGE_SIZE;
}
diff --git a/drivers/gpu/drm/gma500/mmu.c b/drivers/gpu/drm/gma500/mmu.c
index fe9ace2a7967..a70b01ccdf70 100644
--- a/drivers/gpu/drm/gma500/mmu.c
+++ b/drivers/gpu/drm/gma500/mmu.c
@@ -184,17 +184,17 @@ struct psb_mmu_pd *psb_mmu_alloc_pd(struct psb_mmu_driver *driver,
pd->invalid_pte = 0;
}
- v = kmap(pd->dummy_pt);
+ v = kmap_local_page(pd->dummy_pt);
for (i = 0; i < (PAGE_SIZE / sizeof(uint32_t)); ++i)
v[i] = pd->invalid_pte;
- kunmap(pd->dummy_pt);
+ kunmap_local(v);
- v = kmap(pd->p);
+ v = kmap_local_page(pd->p);
for (i = 0; i < (PAGE_SIZE / sizeof(uint32_t)); ++i)
v[i] = pd->invalid_pde;
- kunmap(pd->p);
+ kunmap_local(v);
clear_page(kmap(pd->dummy_page));
kunmap(pd->dummy_page);
--
2.31.1
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH V2 3/7] drm/gma: Remove calls to kmap()
2022-01-24 1:54 ` [PATCH V2 3/7] drm/gma: Remove calls to kmap() ira.weiny
@ 2022-01-24 16:03 ` Daniel Vetter
0 siblings, 0 replies; 11+ messages in thread
From: Daniel Vetter @ 2022-01-24 16:03 UTC (permalink / raw)
To: ira.weiny
Cc: David Airlie, Daniel Vetter, Patrik Jakobsson, Rob Clark,
Sean Paul, amd-gfx, dri-devel, linux-kernel, intel-gfx,
linux-arm-msm
On Sun, Jan 23, 2022 at 05:54:05PM -0800, ira.weiny@intel.com wrote:
> From: Ira Weiny <ira.weiny@intel.com>
>
> kmap() is being deprecated and these instances are easy to convert to
> kmap_local_page().
>
> Furthermore, in gma_crtc_cursor_set() use the memcpy_from_page() helper
> instead of an open coded use of kmap_local_page().
>
> Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Applied to drm-misc-next, the others should all have full time maintainers
to make sure the patches land. Pls holler if not.
Thanks, Daniel
> ---
> drivers/gpu/drm/gma500/gma_display.c | 6 ++----
> drivers/gpu/drm/gma500/mmu.c | 8 ++++----
> 2 files changed, 6 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/gma500/gma_display.c b/drivers/gpu/drm/gma500/gma_display.c
> index 99da3118131a..60ba7de59139 100644
> --- a/drivers/gpu/drm/gma500/gma_display.c
> +++ b/drivers/gpu/drm/gma500/gma_display.c
> @@ -335,7 +335,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc,
> struct psb_gem_object *pobj;
> struct psb_gem_object *cursor_pobj = gma_crtc->cursor_pobj;
> struct drm_gem_object *obj;
> - void *tmp_dst, *tmp_src;
> + void *tmp_dst;
> int ret = 0, i, cursor_pages;
>
> /* If we didn't get a handle then turn the cursor off */
> @@ -400,9 +400,7 @@ int gma_crtc_cursor_set(struct drm_crtc *crtc,
> /* Copy the cursor to cursor mem */
> tmp_dst = dev_priv->vram_addr + cursor_pobj->offset;
> for (i = 0; i < cursor_pages; i++) {
> - tmp_src = kmap(pobj->pages[i]);
> - memcpy(tmp_dst, tmp_src, PAGE_SIZE);
> - kunmap(pobj->pages[i]);
> + memcpy_from_page(tmp_dst, pobj->pages[i], 0, PAGE_SIZE);
> tmp_dst += PAGE_SIZE;
> }
>
> diff --git a/drivers/gpu/drm/gma500/mmu.c b/drivers/gpu/drm/gma500/mmu.c
> index fe9ace2a7967..a70b01ccdf70 100644
> --- a/drivers/gpu/drm/gma500/mmu.c
> +++ b/drivers/gpu/drm/gma500/mmu.c
> @@ -184,17 +184,17 @@ struct psb_mmu_pd *psb_mmu_alloc_pd(struct psb_mmu_driver *driver,
> pd->invalid_pte = 0;
> }
>
> - v = kmap(pd->dummy_pt);
> + v = kmap_local_page(pd->dummy_pt);
> for (i = 0; i < (PAGE_SIZE / sizeof(uint32_t)); ++i)
> v[i] = pd->invalid_pte;
>
> - kunmap(pd->dummy_pt);
> + kunmap_local(v);
>
> - v = kmap(pd->p);
> + v = kmap_local_page(pd->p);
> for (i = 0; i < (PAGE_SIZE / sizeof(uint32_t)); ++i)
> v[i] = pd->invalid_pde;
>
> - kunmap(pd->p);
> + kunmap_local(v);
>
> clear_page(kmap(pd->dummy_page));
> kunmap(pd->dummy_page);
> --
> 2.31.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH V2 4/7] drm/radeon: Replace kmap() with kmap_local_page()
2022-01-24 1:54 [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions ira.weiny
` (2 preceding siblings ...)
2022-01-24 1:54 ` [PATCH V2 3/7] drm/gma: Remove calls to kmap() ira.weiny
@ 2022-01-24 1:54 ` ira.weiny
2022-01-24 1:54 ` [PATCH V2 5/7] drm/msm: Alter comment to use kmap_local_page() ira.weiny
` (3 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: ira.weiny @ 2022-01-24 1:54 UTC (permalink / raw)
To: David Airlie, Daniel Vetter, Patrik Jakobsson, Rob Clark, Sean Paul
Cc: Ira Weiny, amd-gfx, dri-devel, linux-kernel, intel-gfx, linux-arm-msm
From: Ira Weiny <ira.weiny@intel.com>
kmap() is being deprecated and this usage is local to the thread. Use
kmap_local_page() instead.
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
index 11b21d605584..76d7906e1785 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -907,11 +907,11 @@ static ssize_t radeon_ttm_gtt_read(struct file *f, char __user *buf,
page = rdev->gart.pages[p];
if (page) {
- ptr = kmap(page);
+ ptr = kmap_local_page(page);
ptr += off;
r = copy_to_user(buf, ptr, cur_size);
- kunmap(rdev->gart.pages[p]);
+ kunmap_local(ptr);
} else
r = clear_user(buf, cur_size);
--
2.31.1
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH V2 5/7] drm/msm: Alter comment to use kmap_local_page()
2022-01-24 1:54 [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions ira.weiny
` (3 preceding siblings ...)
2022-01-24 1:54 ` [PATCH V2 4/7] drm/radeon: Replace kmap() with kmap_local_page() ira.weiny
@ 2022-01-24 1:54 ` ira.weiny
2022-01-24 1:54 ` [PATCH V2 6/7] drm/amdgpu: Ensure kunmap is called on error ira.weiny
` (2 subsequent siblings)
7 siblings, 0 replies; 11+ messages in thread
From: ira.weiny @ 2022-01-24 1:54 UTC (permalink / raw)
To: David Airlie, Daniel Vetter, Patrik Jakobsson, Rob Clark, Sean Paul
Cc: Ira Weiny, amd-gfx, dri-devel, linux-kernel, intel-gfx, linux-arm-msm
From: Ira Weiny <ira.weiny@intel.com>
kmap() is being deprecated. So this comment could be misleading in the
future.
Change this comment to point to using kmap_local_page(). While here
remove 'we' from the comment.
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
drivers/gpu/drm/msm/msm_gem_submit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/msm/msm_gem_submit.c b/drivers/gpu/drm/msm/msm_gem_submit.c
index 6cfa984dee6a..cc18d5d1fe5a 100644
--- a/drivers/gpu/drm/msm/msm_gem_submit.c
+++ b/drivers/gpu/drm/msm/msm_gem_submit.c
@@ -438,8 +438,8 @@ static int submit_reloc(struct msm_gem_submit *submit, struct msm_gem_object *ob
return -EINVAL;
}
- /* For now, just map the entire thing. Eventually we probably
- * to do it page-by-page, w/ kmap() if not vmap()d..
+ /* For now, just map the entire thing. Eventually it should probably
+ * be done page-by-page, w/ kmap_local_page() if not vmap()d..
*/
ptr = msm_gem_get_vaddr_locked(&obj->base);
--
2.31.1
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH V2 6/7] drm/amdgpu: Ensure kunmap is called on error
2022-01-24 1:54 [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions ira.weiny
` (4 preceding siblings ...)
2022-01-24 1:54 ` [PATCH V2 5/7] drm/msm: Alter comment to use kmap_local_page() ira.weiny
@ 2022-01-24 1:54 ` ira.weiny
2022-01-24 1:54 ` [PATCH V2 7/7] drm/radeon: " ira.weiny
2022-01-24 12:08 ` [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions Christian König
7 siblings, 0 replies; 11+ messages in thread
From: ira.weiny @ 2022-01-24 1:54 UTC (permalink / raw)
To: David Airlie, Daniel Vetter, Patrik Jakobsson, Rob Clark, Sean Paul
Cc: Ira Weiny, amd-gfx, dri-devel, linux-kernel, intel-gfx, linux-arm-msm
From: Ira Weiny <ira.weiny@intel.com>
The default case leaves the buffer object mapped in error.
Add amdgpu_bo_kunmap() to that case to ensure the mapping is cleaned up.
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
NOTE: It seems like this function could use a fair bit of refactoring
but this is the easiest way to fix the actual bug.
---
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
index 6f8de11a17f1..b3ffd0f6b35f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c
@@ -889,6 +889,7 @@ static int amdgpu_uvd_cs_msg(struct amdgpu_uvd_cs_ctx *ctx,
return 0;
default:
+ amdgpu_bo_kunmap(bo);
DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
}
--
2.31.1
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH V2 7/7] drm/radeon: Ensure kunmap is called on error
2022-01-24 1:54 [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions ira.weiny
` (5 preceding siblings ...)
2022-01-24 1:54 ` [PATCH V2 6/7] drm/amdgpu: Ensure kunmap is called on error ira.weiny
@ 2022-01-24 1:54 ` ira.weiny
2022-01-24 12:08 ` [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions Christian König
7 siblings, 0 replies; 11+ messages in thread
From: ira.weiny @ 2022-01-24 1:54 UTC (permalink / raw)
To: David Airlie, Daniel Vetter, Patrik Jakobsson, Rob Clark, Sean Paul
Cc: Ira Weiny, amd-gfx, dri-devel, linux-kernel, intel-gfx, linux-arm-msm
From: Ira Weiny <ira.weiny@intel.com>
The default case leaves the buffer object mapped in error.
Add radeon_bo_kunmap() to that case to ensure the mapping is cleaned up.
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
---
NOTE: It seems like this function could use a fair bit of refactoring
but this is the easiest way to fix the actual bug.
---
drivers/gpu/drm/radeon/radeon_uvd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
index 377f9cdb5b53..7cca283f6202 100644
--- a/drivers/gpu/drm/radeon/radeon_uvd.c
+++ b/drivers/gpu/drm/radeon/radeon_uvd.c
@@ -560,6 +560,7 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
default:
+ radeon_bo_kunmap(bo);
DRM_ERROR("Illegal UVD message type (%d)!\n", msg_type);
return -EINVAL;
}
--
2.31.1
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions
2022-01-24 1:54 [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions ira.weiny
` (6 preceding siblings ...)
2022-01-24 1:54 ` [PATCH V2 7/7] drm/radeon: " ira.weiny
@ 2022-01-24 12:08 ` Christian König
2022-01-24 18:27 ` Ira Weiny
7 siblings, 1 reply; 11+ messages in thread
From: Christian König @ 2022-01-24 12:08 UTC (permalink / raw)
To: ira.weiny, David Airlie, Daniel Vetter, Patrik Jakobsson,
Rob Clark, Sean Paul
Cc: linux-arm-msm, intel-gfx, linux-kernel, dri-devel, amd-gfx
Am 24.01.22 um 02:54 schrieb ira.weiny@intel.com:
> From: Ira Weiny <ira.weiny@intel.com>
>
> Changes from V1:
> Use memcpy_to_page() where appropriate
> Rebased to latest
>
> The kmap() call may cause issues with work being done with persistent memory.
> For this and other reasons it is being deprecated.
I'm really wondering how we should be able to implement the kernel
mapping without kmap in TTM.
> This series starts by converting the last easy kmap() uses in the drm tree to
> kmap_local_page().
>
> The final 2 patches fix bugs found while working on the ttm_bo_kmap_ttm()
> conversion. They are valid fixes but were found via code inspection not
> because of any actual bug so don't require a stable tag.[1]
>
> There is one more call to kmap() used in ttm_bo_kmap_ttm(). Unfortunately,
> fixing this is not straight forward so it is left to future work.[2]
Patches #2, #4, #6 and #7 are Reviewed-by: Christian König
<christian.koenig@amd.com>
How to you now want to push those upstream? I can pick them up for the
AMD tree like Daniel suggested or you can push them through something else.
Regards,
Christian.
>
> [1] https://lore.kernel.org/lkml/fb71af05-a889-8f6e-031b-426b58a64f00@amd.com/
> [2] https://lore.kernel.org/lkml/20211215210949.GW3538886@iweiny-DESK2.sc.intel.com/
>
>
> Ira Weiny (7):
> drm/i915: Replace kmap() with kmap_local_page()
> drm/amd: Replace kmap() with kmap_local_page()
> drm/gma: Remove calls to kmap()
> drm/radeon: Replace kmap() with kmap_local_page()
> drm/msm: Alter comment to use kmap_local_page()
> drm/amdgpu: Ensure kunmap is called on error
> drm/radeon: Ensure kunmap is called on error
>
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 ++++----
> drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 1 +
> drivers/gpu/drm/gma500/gma_display.c | 6 ++----
> drivers/gpu/drm/gma500/mmu.c | 8 ++++----
> drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 6 ++----
> drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c | 8 ++++----
> drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c | 4 ++--
> drivers/gpu/drm/i915/gt/shmem_utils.c | 7 ++-----
> drivers/gpu/drm/i915/i915_gem.c | 8 ++++----
> drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++--
> drivers/gpu/drm/msm/msm_gem_submit.c | 4 ++--
> drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++--
> drivers/gpu/drm/radeon/radeon_uvd.c | 1 +
> 13 files changed, 32 insertions(+), 37 deletions(-)
>
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 11+ messages in thread* Re: [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions
2022-01-24 12:08 ` [PATCH V2 0/7] DRM kmap() fixes and kmap_local_page() conversions Christian König
@ 2022-01-24 18:27 ` Ira Weiny
0 siblings, 0 replies; 11+ messages in thread
From: Ira Weiny @ 2022-01-24 18:27 UTC (permalink / raw)
To: Christian König
Cc: David Airlie, Daniel Vetter, Patrik Jakobsson, Rob Clark,
Sean Paul, linux-arm-msm, intel-gfx, linux-kernel, dri-devel,
amd-gfx
On Mon, Jan 24, 2022 at 01:08:26PM +0100, Christian König wrote:
> Am 24.01.22 um 02:54 schrieb ira.weiny@intel.com:
> > From: Ira Weiny <ira.weiny@intel.com>
> >
> > Changes from V1:
> > Use memcpy_to_page() where appropriate
> > Rebased to latest
> >
> > The kmap() call may cause issues with work being done with persistent memory.
> > For this and other reasons it is being deprecated.
>
> I'm really wondering how we should be able to implement the kernel mapping
> without kmap in TTM.
>
> > This series starts by converting the last easy kmap() uses in the drm tree to
> > kmap_local_page().
> >
> > The final 2 patches fix bugs found while working on the ttm_bo_kmap_ttm()
> > conversion. They are valid fixes but were found via code inspection not
> > because of any actual bug so don't require a stable tag.[1]
> >
> > There is one more call to kmap() used in ttm_bo_kmap_ttm(). Unfortunately,
> > fixing this is not straight forward so it is left to future work.[2]
>
> Patches #2, #4, #6 and #7 are Reviewed-by: Christian König
> <christian.koenig@amd.com>
Christian,
Would you prefer I send those 4 to you as a separate series?
>
> How to you now want to push those upstream? I can pick them up for the AMD
> tree like Daniel suggested or you can push them through something else.
You picking them up from this series is ok as well.
Daniel will you take #1, #3, and #5?
Thanks,
Ira
>
> Regards,
> Christian.
>
> >
> > [1] https://lore.kernel.org/lkml/fb71af05-a889-8f6e-031b-426b58a64f00@amd.com/
> > [2] https://lore.kernel.org/lkml/20211215210949.GW3538886@iweiny-DESK2.sc.intel.com/
> >
> >
> > Ira Weiny (7):
> > drm/i915: Replace kmap() with kmap_local_page()
> > drm/amd: Replace kmap() with kmap_local_page()
> > drm/gma: Remove calls to kmap()
> > drm/radeon: Replace kmap() with kmap_local_page()
> > drm/msm: Alter comment to use kmap_local_page()
> > drm/amdgpu: Ensure kunmap is called on error
> > drm/radeon: Ensure kunmap is called on error
> >
> > drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 8 ++++----
> > drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 1 +
> > drivers/gpu/drm/gma500/gma_display.c | 6 ++----
> > drivers/gpu/drm/gma500/mmu.c | 8 ++++----
> > drivers/gpu/drm/i915/gem/i915_gem_shmem.c | 6 ++----
> > drivers/gpu/drm/i915/gem/selftests/i915_gem_mman.c | 8 ++++----
> > drivers/gpu/drm/i915/gt/intel_ggtt_fencing.c | 4 ++--
> > drivers/gpu/drm/i915/gt/shmem_utils.c | 7 ++-----
> > drivers/gpu/drm/i915/i915_gem.c | 8 ++++----
> > drivers/gpu/drm/i915/i915_gpu_error.c | 4 ++--
> > drivers/gpu/drm/msm/msm_gem_submit.c | 4 ++--
> > drivers/gpu/drm/radeon/radeon_ttm.c | 4 ++--
> > drivers/gpu/drm/radeon/radeon_uvd.c | 1 +
> > 13 files changed, 32 insertions(+), 37 deletions(-)
> >
> > --
> > 2.31.1
> >
>
^ permalink raw reply [flat|nested] 11+ messages in thread