Message ID | 20191126011056.67928-2-gurchetansingh@chromium.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [1/5] udmabuf: use cache_sgt_mapping option | expand |
Hi, > diff --git a/include/uapi/linux/udmabuf.h b/include/uapi/linux/udmabuf.h > index 46b6532ed855..f90831f2bb0d 100644 > --- a/include/uapi/linux/udmabuf.h > +++ b/include/uapi/linux/udmabuf.h > @@ -6,6 +6,8 @@ > #include <linux/ioctl.h> > > #define UDMABUF_FLAGS_CLOEXEC 0x01 > +#define UDMABUF_FLAGS_WC 0x02 > +#define UDMABUF_FLAGS_NONCACHED 0x04 > > struct udmabuf_create { > __u32 memfd; This is a uapi change and should go to a separate patch, clearly flagging that in $subject. (new policy by airlied for the drm tree). Otherwise the series looks good to me. cheers, Gerd
On Thu, Nov 28, 2019 at 3:48 AM Gerd Hoffmann <kraxel@redhat.com> wrote: > > Hi, > > > diff --git a/include/uapi/linux/udmabuf.h b/include/uapi/linux/udmabuf.h > > index 46b6532ed855..f90831f2bb0d 100644 > > --- a/include/uapi/linux/udmabuf.h > > +++ b/include/uapi/linux/udmabuf.h > > @@ -6,6 +6,8 @@ > > #include <linux/ioctl.h> > > > > #define UDMABUF_FLAGS_CLOEXEC 0x01 > > +#define UDMABUF_FLAGS_WC 0x02 > > +#define UDMABUF_FLAGS_NONCACHED 0x04 > > > > struct udmabuf_create { > > __u32 memfd; > > This is a uapi change and should go to a separate patch, > clearly flagging that in $subject. > > (new policy by airlied for the drm tree). The new policy requires a non-toy userspace[1], which may take a while. Removed the UAPI changes in the latest patch series. [1] https://01.org/linuxgraphics/gfx-docs/drm/gpu/drm-uapi.html#open-source-userspace-requirements > > Otherwise the series looks good to me. > > cheers, > Gerd >
diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c index b345e91d831a..ce9caaaa9e4b 100644 --- a/drivers/dma-buf/udmabuf.c +++ b/drivers/dma-buf/udmabuf.c @@ -16,6 +16,7 @@ static const u32 list_limit = 1024; /* udmabuf_create_list->count limit */ static const size_t size_limit_mb = 64; /* total dmabuf size, in megabytes */ struct udmabuf { + u32 flags; pgoff_t pagecount; struct page **pages; }; @@ -37,6 +38,12 @@ static const struct vm_operations_struct udmabuf_vm_ops = { static int mmap_udmabuf(struct dma_buf *buf, struct vm_area_struct *vma) { struct udmabuf *ubuf = buf->priv; + pgprot_t pgprot = vm_get_page_prot(vma->vm_flags); + + if (ubuf->flags & UDMABUF_FLAGS_WC) + vma->vm_page_prot = pgprot_writecombine(pgprot); + else if (ubuf->flags & UDMABUF_FLAGS_NONCACHED) + vma->vm_page_prot = pgprot_noncached(pgprot); if ((vma->vm_flags & (VM_SHARED | VM_MAYSHARE)) == 0) return -EINVAL; @@ -132,6 +139,10 @@ static long udmabuf_create(const struct udmabuf_create_list *head, int seals, ret = -EINVAL; u32 i, flags; + if ((head->flags & UDMABUF_FLAGS_NONCACHED) && + (head->flags & UDMABUF_FLAGS_WC)) + return -EINVAL; + ubuf = kzalloc(sizeof(*ubuf), GFP_KERNEL); if (!ubuf) return -ENOMEM; @@ -188,6 +199,7 @@ static long udmabuf_create(const struct udmabuf_create_list *head, exp_info.priv = ubuf; exp_info.flags = O_RDWR; + ubuf->flags = head->flags; buf = dma_buf_export(&exp_info); if (IS_ERR(buf)) { ret = PTR_ERR(buf); diff --git a/include/uapi/linux/udmabuf.h b/include/uapi/linux/udmabuf.h index 46b6532ed855..f90831f2bb0d 100644 --- a/include/uapi/linux/udmabuf.h +++ b/include/uapi/linux/udmabuf.h @@ -6,6 +6,8 @@ #include <linux/ioctl.h> #define UDMABUF_FLAGS_CLOEXEC 0x01 +#define UDMABUF_FLAGS_WC 0x02 +#define UDMABUF_FLAGS_NONCACHED 0x04 struct udmabuf_create { __u32 memfd;