drivers/accel/amdxdna/amdxdna_ubuf.c | 29 ++-------------------------- 1 file changed, 2 insertions(+), 27 deletions(-)
This reverts commit f649e63d4a6423eda8eb208638849fd6396aedd7.
The read-only feature requires further consideration.
Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
---
drivers/accel/amdxdna/amdxdna_ubuf.c | 29 ++--------------------------
1 file changed, 2 insertions(+), 27 deletions(-)
diff --git a/drivers/accel/amdxdna/amdxdna_ubuf.c b/drivers/accel/amdxdna/amdxdna_ubuf.c
index 3769210c55cc..4c0647057759 100644
--- a/drivers/accel/amdxdna/amdxdna_ubuf.c
+++ b/drivers/accel/amdxdna/amdxdna_ubuf.c
@@ -125,26 +125,6 @@ static const struct dma_buf_ops amdxdna_ubuf_dmabuf_ops = {
.vunmap = amdxdna_ubuf_vunmap,
};
-static int readonly_va_entry(struct amdxdna_drm_va_entry *va_ent)
-{
- struct mm_struct *mm = current->mm;
- struct vm_area_struct *vma;
- int ret;
-
- mmap_read_lock(mm);
-
- vma = find_vma(mm, va_ent->vaddr);
- if (!vma ||
- vma->vm_start > va_ent->vaddr ||
- vma->vm_end - va_ent->vaddr < va_ent->len)
- ret = -ENOENT;
- else
- ret = vma->vm_flags & VM_WRITE ? 0 : 1;
-
- mmap_read_unlock(mm);
- return ret;
-}
-
struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
u32 num_entries, void __user *va_entries)
{
@@ -154,7 +134,6 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
struct amdxdna_ubuf_priv *ubuf;
u32 npages, start = 0;
struct dma_buf *dbuf;
- bool readonly = true;
int i, ret;
DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
@@ -193,10 +172,6 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
ret = -EINVAL;
goto free_ent;
}
-
- /* Pin pages as writable as long as not all entries are read-only. */
- if (readonly && readonly_va_entry(&va_ent[i]) != 1)
- readonly = false;
}
ubuf->nr_pages = exp_info.size >> PAGE_SHIFT;
@@ -219,7 +194,7 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
npages = va_ent[i].len >> PAGE_SHIFT;
ret = pin_user_pages_fast(va_ent[i].vaddr, npages,
- (readonly ? 0 : FOLL_WRITE) | FOLL_LONGTERM,
+ FOLL_WRITE | FOLL_LONGTERM,
&ubuf->pages[start]);
if (ret >= 0) {
start += ret;
@@ -236,7 +211,7 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
exp_info.ops = &amdxdna_ubuf_dmabuf_ops;
exp_info.priv = ubuf;
- exp_info.flags = (readonly ? O_RDONLY : O_RDWR) | O_CLOEXEC;
+ exp_info.flags = O_RDWR | O_CLOEXEC;
dbuf = dma_buf_export(&exp_info);
if (IS_ERR(dbuf)) {
--
2.34.1
On 5/21/26 18:29, Lizhi Hou wrote:
> This reverts commit f649e63d4a6423eda8eb208638849fd6396aedd7.
>
> The read-only feature requires further consideration.
>
> Signed-off-by: Lizhi Hou <lizhi.hou@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/accel/amdxdna/amdxdna_ubuf.c | 29 ++--------------------------
> 1 file changed, 2 insertions(+), 27 deletions(-)
>
> diff --git a/drivers/accel/amdxdna/amdxdna_ubuf.c b/drivers/accel/amdxdna/amdxdna_ubuf.c
> index 3769210c55cc..4c0647057759 100644
> --- a/drivers/accel/amdxdna/amdxdna_ubuf.c
> +++ b/drivers/accel/amdxdna/amdxdna_ubuf.c
> @@ -125,26 +125,6 @@ static const struct dma_buf_ops amdxdna_ubuf_dmabuf_ops = {
> .vunmap = amdxdna_ubuf_vunmap,
> };
>
> -static int readonly_va_entry(struct amdxdna_drm_va_entry *va_ent)
> -{
> - struct mm_struct *mm = current->mm;
> - struct vm_area_struct *vma;
> - int ret;
> -
> - mmap_read_lock(mm);
> -
> - vma = find_vma(mm, va_ent->vaddr);
> - if (!vma ||
> - vma->vm_start > va_ent->vaddr ||
> - vma->vm_end - va_ent->vaddr < va_ent->len)
> - ret = -ENOENT;
> - else
> - ret = vma->vm_flags & VM_WRITE ? 0 : 1;
> -
> - mmap_read_unlock(mm);
> - return ret;
> -}
> -
> struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
> u32 num_entries, void __user *va_entries)
> {
> @@ -154,7 +134,6 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
> struct amdxdna_ubuf_priv *ubuf;
> u32 npages, start = 0;
> struct dma_buf *dbuf;
> - bool readonly = true;
> int i, ret;
> DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
>
> @@ -193,10 +172,6 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
> ret = -EINVAL;
> goto free_ent;
> }
> -
> - /* Pin pages as writable as long as not all entries are read-only. */
> - if (readonly && readonly_va_entry(&va_ent[i]) != 1)
> - readonly = false;
> }
>
> ubuf->nr_pages = exp_info.size >> PAGE_SHIFT;
> @@ -219,7 +194,7 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
> npages = va_ent[i].len >> PAGE_SHIFT;
>
> ret = pin_user_pages_fast(va_ent[i].vaddr, npages,
> - (readonly ? 0 : FOLL_WRITE) | FOLL_LONGTERM,
> + FOLL_WRITE | FOLL_LONGTERM,
> &ubuf->pages[start]);
> if (ret >= 0) {
> start += ret;
> @@ -236,7 +211,7 @@ struct dma_buf *amdxdna_get_ubuf(struct drm_device *dev,
>
> exp_info.ops = &amdxdna_ubuf_dmabuf_ops;
> exp_info.priv = ubuf;
> - exp_info.flags = (readonly ? O_RDONLY : O_RDWR) | O_CLOEXEC;
> + exp_info.flags = O_RDWR | O_CLOEXEC;
>
> dbuf = dma_buf_export(&exp_info);
> if (IS_ERR(dbuf)) {
© 2016 - 2026 Red Hat, Inc.