drm/xen-front: Remove CMA support
Subsystems (4)
PATCH 1/1 drm/xen-front: Remove CMA support
From: Oleksandr Andrushchenko <[email protected]>
Even if xen-front allocates its buffers from contiguous memory those are still not contiguous in PA space, e.g. the buffer is only contiguous in IPA space.
The only use-case for this mode was if xen-front is used to allocate dumb buffers which later be used by some other driver requiring contiguous memory, but there is no currently such a use-case or it can be worked around with xen-front.
--- Documentation/gpu/xen-front.rst | 12 ---- drivers/gpu/drm/xen/Kconfig | 13 ---- drivers/gpu/drm/xen/Makefile | 9 +-- drivers/gpu/drm/xen/xen_drm_front.c | 62 +++------------- drivers/gpu/drm/xen/xen_drm_front.h | 42 ++--------- drivers/gpu/drm/xen/xen_drm_front_gem.c | 12 +--- drivers/gpu/drm/xen/xen_drm_front_gem.h | 3 - drivers/gpu/drm/xen/xen_drm_front_gem_cma.c | 79 --------------------- drivers/gpu/drm/xen/xen_drm_front_shbuf.c | 22 ------ drivers/gpu/drm/xen/xen_drm_front_shbuf.h | 8 --- 10 files changed, 21 insertions(+), 241 deletions(-) delete mode 100644 drivers/gpu/drm/xen/xen_drm_front_gem_cma.c
Documentation/gpu/xen-front.rst +0 -12
@@ -18,18 +18,6 @@ Buffers allocated by the frontend driver .. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h :doc: Buffers allocated by the frontend driver -With GEM CMA helpers -~~~~~~~~~~~~~~~~~~~~ - -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: With GEM CMA helpers - -Without GEM CMA helpers -~~~~~~~~~~~~~~~~~~~~~~~ - -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: Without GEM CMA helpers - Buffers allocated by the backend --------------------------------
drivers/gpu/drm/xen/Kconfig +0 -13
@@ -15,16 +15,3 @@ config DRM_XEN_FRONTEND help Choose this option if you want to enable a para-virtualized frontend DRM/KMS driver for Xen guest OSes. - -config DRM_XEN_FRONTEND_CMA - bool "Use DRM CMA to allocate dumb buffers" - depends on DRM_XEN_FRONTEND - select DRM_KMS_CMA_HELPER - select DRM_GEM_CMA_HELPER - help - Use DRM CMA helpers to allocate display buffers. - This is useful for the use-cases when guest driver needs to - share or export buffers to other drivers which only expect - contiguous buffers. - Note: in this mode driver cannot use buffers allocated - by the backend.
drivers/gpu/drm/xen/Makefile +2 -7
@@ -5,12 +5,7 @@ drm_xen_front-objs := xen_drm_front.o \ xen_drm_front_conn.o \ xen_drm_front_evtchnl.o \ xen_drm_front_shbuf.o \ - xen_drm_front_cfg.o - -ifeq ($(CONFIG_DRM_XEN_FRONTEND_CMA),y) - drm_xen_front-objs += xen_drm_front_gem_cma.o -else - drm_xen_front-objs += xen_drm_front_gem.o -endif + xen_drm_front_cfg.o \ + xen_drm_front_gem.o obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c +10 -52
112 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front.h +6 -36
59 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_gem.c +3 -9
@@ -210,15 +210,9 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev,if (ret <0 )return ERR_PTR (ret); -/* -* N.B. Although we have an API to create display buffer from sgt -* we use pages API, because we still need those for GEM handling, -* e.g. for mapping etc. -*/ - ret =xen_drm_front_dbuf_create_from_pages (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (&xen_obj->base), -0 ,0 ,0 , size, - xen_obj->pages); + ret =xen_drm_front_dbuf_create (drm_info->front_info, +xen_drm_front_dbuf_to_cookie (&xen_obj->base), +0 ,0 ,0 , size, xen_obj->pages);if (ret <0 )return ERR_PTR (ret);
drivers/gpu/drm/xen/xen_drm_front_gem.h +0 -3
@@ -27,8 +27,6 @@ struct page **xen_drm_front_gem_get_pages(struct drm_gem_object *obj);void xen_drm_front_gem_free_object_unlocked (struct drm_gem_object *gem_obj); -#ifndef CONFIG_DRM_XEN_FRONTEND_CMA -int xen_drm_front_gem_mmap (struct file *filp,struct vm_area_struct *vma);void *xen_drm_front_gem_prime_vmap (struct drm_gem_object *gem_obj);
@@ -38,6 +36,5 @@ void xen_drm_front_gem_prime_vunmap(struct drm_gem_object *gem_obj,int xen_drm_front_gem_prime_mmap (struct drm_gem_object *gem_obj,struct vm_area_struct *vma); -#endif #endif /* __XEN_DRM_FRONT_GEM_H */
drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0 -79
79 lines not on this page · raw message
drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0 -22
@@ -89,10 +89,6 @@ void xen_drm_front_shbuf_free(struct xen_drm_front_shbuf *buf) }kfree (buf->grefs);kfree (buf->directory); -if (buf->sgt) { -sg_free_table (buf->sgt); -kvfree (buf->pages); - }kfree (buf); }
@@ -350,17 +346,6 @@ static int grant_references(struct xen_drm_front_shbuf *buf)static int alloc_storage (struct xen_drm_front_shbuf *buf) { -if (buf->sgt) { - buf->pages =kvmalloc_array (buf->num_pages, -sizeof (struct page *),GFP_KERNEL ); -if (!buf->pages) -return -ENOMEM ; - -if (drm_prime_sg_to_page_addr_arrays (buf->sgt, buf->pages, -NULL , buf->num_pages) <0 ) -return -EINVAL ; - } - buf->grefs =kcalloc (buf->num_grefs,sizeof (*buf->grefs),GFP_KERNEL );if (!buf->grefs)return -ENOMEM ;
@@ -396,12 +381,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg)struct xen_drm_front_shbuf *buf;int ret; -/* either pages or sgt, not both */ -if (unlikely (cfg->pages && cfg->sgt)) { -DRM_ERROR ("Cannot handle buffer allocation with both pages and sg table provided\n" ); -return NULL ; - } - buf =kzalloc (sizeof (*buf),GFP_KERNEL );if (!buf)return NULL ;
@@ -413,7 +392,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg) buf->xb_dev = cfg->xb_dev; buf->num_pages =DIV_ROUND_UP (cfg->size,PAGE_SIZE ); - buf->sgt = cfg->sgt; buf->pages = cfg->pages; buf->ops->calc_num_grefs (buf);
drivers/gpu/drm/xen/xen_drm_front_shbuf.h +0 -8
@@ -29,16 +29,9 @@ struct xen_drm_front_shbuf {grant_ref_t *grefs;unsigned char *directory; -/* -* there are 2 ways to provide backing storage for this shared buffer: -* either pages or sgt. if buffer created from sgt then we own -* the pages and must free those ourselves on closure -*/ int num_pages;struct page **pages; -struct sg_table *sgt; -struct xenbus_device *xb_dev;/* these are the ops used internally depending on be_alloc mode */
@@ -52,7 +45,6 @@ struct xen_drm_front_shbuf_cfg {struct xenbus_device *xb_dev;size_t size;struct page **pages; -struct sg_table *sgt;bool be_alloc; };
Signature · 1 line
2.17.0
Quoted 9 lines · Oleksandr Andrushchenko
From: Oleksandr Andrushchenko <[email protected]>
Even if xen-front allocates its buffers from contiguous memory those are still not contiguous in PA space, e.g. the buffer is only contiguous in IPA space.
The only use-case for this mode was if xen-front is used to allocate dumb buffers which later be used by some other driver requiring contiguous memory, but there is no currently such a use-case or it can be worked around with xen-front.
Please also mention the nents confusion here, and the patch that fixes it. Or just outright take the commit message from my patch with all the details:
drm/xen: Dissable CMA support
It turns out this was only needed to paper over a bug in the CMA helpers, which was addressed in
commit 998fb1a0f478b83492220ff79583bf9ad538bdd8
Author: Liviu Dudau <[email protected]>
Date: Fri Nov 10 13:33:10 2017 +0000
drm: gem_cma_helper.c: Allow importing of contiguous scatterlists with nents > 1
Without this the following pipeline didn't work:
domU:
1. xen-front allocates a non-contig buffer
2. creates grants out of it
dom0:
3. converts the grants into a dma-buf. Since they're non-contig, the scatter-list is huge.
4. imports it into rcar-du, which requires dma-contig memory for scanout.
-> On this given platform there's an IOMMU, so in theory this should work. But in practice this failed, because of the huge number of sg entries, even though the IOMMU driver mapped it all into a dma-contig range.
With a guest-contig buffer allocated in step 1, this problem doesn't exist. But there's technically no reason to require guest-contig memory for xen buffer sharing using grants.
With the commit message improved:
Quoted 487 lines
Signed-off-by Oleksandr Andrushchenko <[email protected]>Suggested-by Daniel Vetter <[email protected]>--- Documentation/gpu/xen-front.rst | 12 ---- drivers/gpu/drm/xen/Kconfig | 13 ---- drivers/gpu/drm/xen/Makefile | 9 +-- drivers/gpu/drm/xen/xen_drm_front.c | 62 +++------------- drivers/gpu/drm/xen/xen_drm_front.h | 42 ++--------- drivers/gpu/drm/xen/xen_drm_front_gem.c | 12 +--- drivers/gpu/drm/xen/xen_drm_front_gem.h | 3 - drivers/gpu/drm/xen/xen_drm_front_gem_cma.c | 79 --------------------- drivers/gpu/drm/xen/xen_drm_front_shbuf.c | 22 ------ drivers/gpu/drm/xen/xen_drm_front_shbuf.h | 8 --- 10 files changed, 21 insertions(+), 241 deletions(-) delete mode 100644 drivers/gpu/drm/xen/xen_drm_front_gem_cma.cDocumentation/gpu/xen-front.rst +0
-12@@ -18,18 +18,6 @@ Buffers allocated by the frontend driver .. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h :doc: Buffers allocated by the frontend driver -With GEM CMA helpers -~~~~~~~~~~~~~~~~~~~~ - -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: With GEM CMA helpers - -Without GEM CMA helpers -~~~~~~~~~~~~~~~~~~~~~~~ - -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: Without GEM CMA helpers - Buffers allocated by the backend --------------------------------drivers/gpu/drm/xen/Kconfig +0
-13@@ -15,16 +15,3 @@ config DRM_XEN_FRONTEND help Choose this option if you want to enable a para-virtualized frontend DRM/KMS driver for Xen guest OSes. - -config DRM_XEN_FRONTEND_CMA - bool "Use DRM CMA to allocate dumb buffers" - depends on DRM_XEN_FRONTEND - select DRM_KMS_CMA_HELPER - select DRM_GEM_CMA_HELPER - help - Use DRM CMA helpers to allocate display buffers. - This is useful for the use-cases when guest driver needs to - share or export buffers to other drivers which only expect - contiguous buffers. - Note: in this mode driver cannot use buffers allocated - by the backend.drivers/gpu/drm/xen/Makefile +2
-7@@ -5,12 +5,7 @@ drm_xen_front-objs := xen_drm_front.o \ xen_drm_front_conn.o \ xen_drm_front_evtchnl.o \ xen_drm_front_shbuf.o \ - xen_drm_front_cfg.o - -ifeq ($(CONFIG_DRM_XEN_FRONTEND_CMA),y) - drm_xen_front-objs += xen_drm_front_gem_cma.o -else - drm_xen_front-objs += xen_drm_front_gem.o -endif + xen_drm_front_cfg.o \ + xen_drm_front_gem.o obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.odrivers/gpu/drm/xen/xen_drm_front.c +10
-52@@ -12,7 +12,6 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_gem.h> -#include <drm/drm_gem_cma_helper.h> #include <linux/of_device.h> @@ -167,10 +166,9 @@ int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline,return ret; } -static int be_dbuf_create_int (struct xen_drm_front_info *front_info, +int xen_drm_front_dbuf_create (struct xen_drm_front_info *front_info,u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct page **pages, -struct sg_table *sgt) +u32 bpp,u64 size,struct page **pages) {struct xen_drm_front_evtchnl *evtchnl;struct xen_drm_front_shbuf *shbuf;@@ -187,7 +185,6 @@ static int be_dbuf_create_int(struct xen_drm_front_info *front_info, buf_cfg.xb_dev = front_info->xb_dev; buf_cfg.pages = pages; buf_cfg.size = size; - buf_cfg.sgt = sgt; buf_cfg.be_alloc = front_info->cfg.be_alloc; shbuf =xen_drm_front_shbuf_alloc (&buf_cfg);@@ -237,22 +234,6 @@ static int be_dbuf_create_int(struct xen_drm_front_info *front_info,return ret; } -int xen_drm_front_dbuf_create_from_sgt (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct sg_table *sgt) -{ -return be_dbuf_create_int (front_info, dbuf_cookie, width, height, - bpp, size,NULL , sgt); -} - -int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct page **pages) -{ -return be_dbuf_create_int (front_info, dbuf_cookie, width, height, - bpp, size, pages,NULL ); -} -static int xen_drm_front_dbuf_destroy (struct xen_drm_front_info *front_info,u64 dbuf_cookie) {@@ -434,24 +415,11 @@ static int xen_drm_drv_dumb_create(struct drm_file *filp, goto fail; } -/* -* In case of CONFIG_DRM_XEN_FRONTEND_CMA gem_obj is constructed -* via DRM CMA helpers and doesn't have ->pages allocated -* (xendrm_gem_get_pages will return NULL), but instead can provide -* sg table -*/ -if (xen_drm_front_gem_get_pages (obj)) - ret =xen_drm_front_dbuf_create_from_pages (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (obj), - args->width, args->height, args->bpp, - args->size, -xen_drm_front_gem_get_pages (obj)); -else - ret =xen_drm_front_dbuf_create_from_sgt (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (obj), - args->width, args->height, args->bpp, - args->size, -xen_drm_front_gem_get_sg_table (obj)); + ret =xen_drm_front_dbuf_create (drm_info->front_info, +xen_drm_front_dbuf_to_cookie (obj), + args->width, args->height, args->bpp, + args->size, +xen_drm_front_gem_get_pages (obj));if (ret) goto fail_backend;@@ -523,11 +491,7 @@ static const struct file_operations xen_drm_dev_fops = { .poll = drm_poll, .read = drm_read, .llseek = no_llseek, -#ifdef CONFIG_DRM_XEN_FRONTEND_CMA - .mmap = drm_gem_cma_mmap, -#else .mmap = xen_drm_front_gem_mmap, -#endif };static const struct vm_operations_struct xen_drm_drv_vm_ops = {@@ -547,6 +511,9 @@ static struct drm_driver xen_drm_driver = { .gem_prime_export = drm_gem_prime_export, .gem_prime_import_sg_table = xen_drm_front_gem_import_sg_table, .gem_prime_get_sg_table = xen_drm_front_gem_get_sg_table, + .gem_prime_vmap = xen_drm_front_gem_prime_vmap, + .gem_prime_vunmap = xen_drm_front_gem_prime_vunmap, + .gem_prime_mmap = xen_drm_front_gem_prime_mmap, .dumb_create = xen_drm_drv_dumb_create, .fops = &xen_drm_dev_fops, .name = "xendrm-du",@@ -555,15 +522,6 @@ static struct drm_driver xen_drm_driver = { .major = 1, .minor = 0, -#ifdef CONFIG_DRM_XEN_FRONTEND_CMA - .gem_prime_vmap = drm_gem_cma_prime_vmap, - .gem_prime_vunmap = drm_gem_cma_prime_vunmap, - .gem_prime_mmap = drm_gem_cma_prime_mmap, -#else - .gem_prime_vmap = xen_drm_front_gem_prime_vmap, - .gem_prime_vunmap = xen_drm_front_gem_prime_vunmap, - .gem_prime_mmap = xen_drm_front_gem_prime_mmap, -#endif };static int xen_drm_drv_init (struct xen_drm_front_info *front_info)drivers/gpu/drm/xen/xen_drm_front.h +6
-36@@ -23,40 +23,14 @@* * Depending on the requirements for the para-virtualized environment, namely * requirements dictated by the accompanying DRM/(v)GPU drivers running in both -* host and guest environments, number of operating modes of para-virtualized -* display driver are supported: -* -* - display buffers can be allocated by either frontend driver or backend -* - display buffers can be allocated to be contiguous in memory or not -* -* Note! Frontend driver itself has no dependency on contiguous memory for -* its operation. +* host and guest environments, display buffers can be allocated by either +* frontend driver or backend. */ /** * DOC: Buffers allocated by the frontend driver * -* The below modes of operation are configured at compile-time via -* frontend driver's kernel configuration: -*/ - -/** -* DOC: With GEM CMA helpers -* -* This use-case is useful when used with accompanying DRM/vGPU driver in -* guest domain which was designed to only work with contiguous buffers, -* e.g. DRM driver based on GEM CMA helpers: such drivers can only import -* contiguous PRIME buffers, thus requiring frontend driver to provide -* such. In order to implement this mode of operation para-virtualized -* frontend driver can be configured to use GEM CMA helpers. -*/ - -/** -* DOC: Without GEM CMA helpers -* -* If accompanying drivers can cope with non-contiguous memory then, to -* lower pressure on CMA subsystem of the kernel, driver can allocate -* buffers from system memory. +* In this mode of operation driver allocates buffers from system memory. * * Note! If used with accompanying DRM/(v)GPU drivers this mode of operation * may require IOMMU support on the platform, so accompanying DRM/vGPU @@ -164,13 +138,9 @@ int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline, u32 x, u32 y, u32 width, u32 height, u32 bpp, u64 fb_cookie); -int xen_drm_front_dbuf_create_from_sgt (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct sg_table *sgt); - -int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct page **pages); +int xen_drm_front_dbuf_create (struct xen_drm_front_info *front_info, +u64 dbuf_cookie,u32 width,u32 height, +u32 bpp,u64 size,struct page **pages); int xen_drm_front_fb_attach(struct xen_drm_front_info *front_info, u64 dbuf_cookie, u64 fb_cookie, u32 width,drivers/gpu/drm/xen/xen_drm_front_gem.c +3
-9@@ -210,15 +210,9 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev,if (ret <0 )return ERR_PTR (ret); -/* -* N.B. Although we have an API to create display buffer from sgt -* we use pages API, because we still need those for GEM handling, -* e.g. for mapping etc. -*/ - ret =xen_drm_front_dbuf_create_from_pages (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (&xen_obj->base), -0 ,0 ,0 , size, - xen_obj->pages); + ret =xen_drm_front_dbuf_create (drm_info->front_info, +xen_drm_front_dbuf_to_cookie (&xen_obj->base), +0 ,0 ,0 , size, xen_obj->pages);if (ret <0 )return ERR_PTR (ret);drivers/gpu/drm/xen/xen_drm_front_gem.h +0
-3@@ -27,8 +27,6 @@ struct page **xen_drm_front_gem_get_pages(struct drm_gem_object *obj);void xen_drm_front_gem_free_object_unlocked (struct drm_gem_object *gem_obj); -#ifndef CONFIG_DRM_XEN_FRONTEND_CMA -int xen_drm_front_gem_mmap (struct file *filp,struct vm_area_struct *vma);void *xen_drm_front_gem_prime_vmap (struct drm_gem_object *gem_obj);@@ -38,6 +36,5 @@ void xen_drm_front_gem_prime_vunmap(struct drm_gem_object *gem_obj,int xen_drm_front_gem_prime_mmap (struct drm_gem_object *gem_obj,struct vm_area_struct *vma); -#endif #endif /* __XEN_DRM_FRONT_GEM_H */ drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-79@@ -1,79 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 OR MIT - -/* -* Xen para-virtual DRM device -* -* Copyright (C) 2016-2018 EPAM Systems Inc. -* -* Author: Oleksandr Andrushchenko <[email protected]> -*/ - -#include <drm/drmP.h> -#include <drm/drm_gem.h> -#include <drm/drm_fb_cma_helper.h> -#include <drm/drm_gem_cma_helper.h> - -#include "xen_drm_front.h" -#include "xen_drm_front_gem.h" - -struct drm_gem_object * -xen_drm_front_gem_import_sg_table (struct drm_device *dev, -struct dma_buf_attachment *attach, -struct sg_table *sgt) -{ -struct xen_drm_front_drm_info *drm_info = dev->dev_private; -struct drm_gem_object *gem_obj; -struct drm_gem_cma_object *cma_obj; -int ret; - - gem_obj =drm_gem_cma_prime_import_sg_table (dev, attach, sgt); -if (IS_ERR_OR_NULL (gem_obj)) -return gem_obj; - - cma_obj =to_drm_gem_cma_obj (gem_obj); - - ret =xen_drm_front_dbuf_create_from_sgt (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (gem_obj), -0 ,0 ,0 , gem_obj->size, -drm_gem_cma_prime_get_sg_table (gem_obj)); -if (ret <0 ) -return ERR_PTR (ret); - -DRM_DEBUG ("Imported CMA buffer of size %zu\n" , gem_obj->size); - -return gem_obj; -} - -struct sg_table *xen_drm_front_gem_get_sg_table (struct drm_gem_object *gem_obj) -{ -return drm_gem_cma_prime_get_sg_table (gem_obj); -} - -struct drm_gem_object *xen_drm_front_gem_create (struct drm_device *dev, -size_t size) -{ -struct xen_drm_front_drm_info *drm_info = dev->dev_private; -struct drm_gem_cma_object *cma_obj; - -if (drm_info->front_info->cfg.be_alloc) { -/* This use-case is not yet supported and probably won't be */ -DRM_ERROR ("Backend allocated buffers and CMA helpers are not supported at the same time\n" ); -return ERR_PTR (-EINVAL ); - } - - cma_obj =drm_gem_cma_create (dev, size); -if (IS_ERR_OR_NULL (cma_obj)) -return ERR_CAST (cma_obj); - -return &cma_obj->base; -} - -void xen_drm_front_gem_free_object_unlocked (struct drm_gem_object *gem_obj) -{ -drm_gem_cma_free_object (gem_obj); -} - -struct page **xen_drm_front_gem_get_pages (struct drm_gem_object *gem_obj) -{ -return NULL ; -}drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0
-22@@ -89,10 +89,6 @@ void xen_drm_front_shbuf_free(struct xen_drm_front_shbuf *buf) }kfree (buf->grefs);kfree (buf->directory); -if (buf->sgt) { -sg_free_table (buf->sgt); -kvfree (buf->pages); - }kfree (buf); }@@ -350,17 +346,6 @@ static int grant_references(struct xen_drm_front_shbuf *buf)static int alloc_storage (struct xen_drm_front_shbuf *buf) { -if (buf->sgt) { - buf->pages =kvmalloc_array (buf->num_pages, -sizeof (struct page *),GFP_KERNEL ); -if (!buf->pages) -return -ENOMEM ; - -if (drm_prime_sg_to_page_addr_arrays (buf->sgt, buf->pages, -NULL , buf->num_pages) <0 ) -return -EINVAL ; - } - buf->grefs =kcalloc (buf->num_grefs,sizeof (*buf->grefs),GFP_KERNEL );if (!buf->grefs)return -ENOMEM ;@@ -396,12 +381,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg)struct xen_drm_front_shbuf *buf;int ret; -/* either pages or sgt, not both */ -if (unlikely (cfg->pages && cfg->sgt)) { -DRM_ERROR ("Cannot handle buffer allocation with both pages and sg table provided\n" ); -return NULL ; - } - buf =kzalloc (sizeof (*buf),GFP_KERNEL );if (!buf)return NULL ;@@ -413,7 +392,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg) buf->xb_dev = cfg->xb_dev; buf->num_pages =DIV_ROUND_UP (cfg->size,PAGE_SIZE ); - buf->sgt = cfg->sgt; buf->pages = cfg->pages; buf->ops->calc_num_grefs (buf);drivers/gpu/drm/xen/xen_drm_front_shbuf.h +0
-8@@ -29,16 +29,9 @@ struct xen_drm_front_shbuf {grant_ref_t *grefs;unsigned char *directory; -/* -* there are 2 ways to provide backing storage for this shared buffer: -* either pages or sgt. if buffer created from sgt then we own -* the pages and must free those ourselves on closure -*/ int num_pages;struct page **pages; -struct sg_table *sgt; -struct xenbus_device *xb_dev;/* these are the ops used internally depending on be_alloc mode */ @@ -52,7 +45,6 @@ struct xen_drm_front_shbuf_cfg {struct xenbus_device *xb_dev;size_t size;struct page **pages; -struct sg_table *sgt;bool be_alloc; };Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Daniel Vetter
Quoted 9 lines · Oleksandr Andrushchenko
From: Oleksandr Andrushchenko <[email protected]>
Even if xen-front allocates its buffers from contiguous memory those are still not contiguous in PA space, e.g. the buffer is only contiguous in IPA space.
The only use-case for this mode was if xen-front is used to allocate dumb buffers which later be used by some other driver requiring contiguous memory, but there is no currently such a use-case or it can be worked around with xen-front.
Quoted 3 lines
Please also mention the nents confusion here, and the patch that fixes it. Or just outright take the commit message from my patch with all the details:
ok, if you don't mind then I'll use your commit message entirely
Quoted 28 lines
drm/xen: Dissable CMA support
It turns out this was only needed to paper over a bug in the CMA helpers, which was addressed in
commit
998fb1a0f478b83492220ff79583bf9ad538bdd8
Author: Liviu Dudau <[email protected]>
Date: Fri Nov 10 13:33:10 2017 +0000drm:
gem_cma_helper.c: Allow importing of contiguous scatterlists with nents > 1Without this the following pipeline didn't work:
domU:
1. xen-front allocates a non-contig buffer
2. creates grants out of itdom0:
3. converts the grants into a dma-buf. Since they're non-contig, the scatter-list is huge.
4. imports it into rcar-du, which requires dma-contig memory for scanout.-> On this given platform there's an IOMMU, so in theory this should work. But in practice this failed, because of the huge number of sg entries, even though the IOMMU driver mapped it all into a dma-contig range.
Quoted 7 lines
With a guest-contig buffer allocated in step 1, this problem doesn't exist. But there's technically no reason to require guest-contig memory for xen buffer sharing using grants.
With the commit message improved:
Acked-by Daniel Vetter <[email protected]>
Thank you,
I'll wait for a day and apply to drm-misc-next if this is ok
Quoted 487 lines
Quoted 487 lines
Signed-off-by Oleksandr Andrushchenko <[email protected]>Suggested-by Daniel Vetter <[email protected]>--- Documentation/gpu/xen-front.rst | 12 ---- drivers/gpu/drm/xen/Kconfig | 13 ---- drivers/gpu/drm/xen/Makefile | 9 +-- drivers/gpu/drm/xen/xen_drm_front.c | 62 +++------------- drivers/gpu/drm/xen/xen_drm_front.h | 42 ++--------- drivers/gpu/drm/xen/xen_drm_front_gem.c | 12 +--- drivers/gpu/drm/xen/xen_drm_front_gem.h | 3 - drivers/gpu/drm/xen/xen_drm_front_gem_cma.c | 79 --------------------- drivers/gpu/drm/xen/xen_drm_front_shbuf.c | 22 ------ drivers/gpu/drm/xen/xen_drm_front_shbuf.h | 8 --- 10 files changed, 21 insertions(+), 241 deletions(-)delete mode 100644
drivers/gpu/drm/xen/xen_drm_front_gem_cma.cDocumentation/gpu/xen-front.rst +0
-12@@ -18,18 +18,6 @@ Buffers allocated by the frontend driver .. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h :doc: Buffers allocated by the frontend driver -With GEM CMA helpers -~~~~~~~~~~~~~~~~~~~~ - -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: With GEM CMA helpers - -Without GEM CMA helpers -~~~~~~~~~~~~~~~~~~~~~~~ - -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: Without GEM CMA helpers - Buffers allocated by the backend --------------------------------drivers/gpu/drm/xen/Kconfig +0
-13@@ -15,16 +15,3 @@ config DRM_XEN_FRONTEND help Choose this option if you want to enable a para-virtualized frontend DRM/KMS driver for Xen guest OSes. - -config DRM_XEN_FRONTEND_CMA - bool "Use DRM CMA to allocate dumb buffers" - depends on DRM_XEN_FRONTEND - select DRM_KMS_CMA_HELPER - select DRM_GEM_CMA_HELPER - help - Use DRM CMA helpers to allocate display buffers. - This is useful for the use-cases when guest driver needs to - share or export buffers to other drivers which only expect - contiguous buffers. - Note: in this mode driver cannot use buffers allocated - by the backend.drivers/gpu/drm/xen/Makefile +2
-7@@ -5,12 +5,7 @@ drm_xen_front-objs := xen_drm_front.o \ xen_drm_front_conn.o \ xen_drm_front_evtchnl.o \ xen_drm_front_shbuf.o \ - xen_drm_front_cfg.o - -ifeq ($(CONFIG_DRM_XEN_FRONTEND_CMA),y) - drm_xen_front-objs += xen_drm_front_gem_cma.o -else - drm_xen_front-objs += xen_drm_front_gem.o -endif + xen_drm_front_cfg.o \ + xen_drm_front_gem.o obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.odrivers/gpu/drm/xen/xen_drm_front.c +10
-52@@ -12,7 +12,6 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_gem.h> -#include <drm/drm_gem_cma_helper.h> #include <linux/of_device.h> @@ -167,10 +166,9 @@ int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline,return ret; } -static int be_dbuf_create_int (struct xen_drm_front_info *front_info, +int xen_drm_front_dbuf_create (struct xen_drm_front_info *front_info,u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct page **pages, -struct sg_table *sgt) +u32 bpp,u64 size,struct page **pages) {struct xen_drm_front_evtchnl *evtchnl;struct xen_drm_front_shbuf *shbuf;@@ -187,7 +185,6 @@ static int be_dbuf_create_int(struct xen_drm_front_info *front_info, buf_cfg.xb_dev = front_info->xb_dev; buf_cfg.pages = pages; buf_cfg.size = size; - buf_cfg.sgt = sgt; buf_cfg.be_alloc = front_info->cfg.be_alloc; shbuf =xen_drm_front_shbuf_alloc (&buf_cfg);@@ -237,22 +234,6 @@ static int be_dbuf_create_int(struct xen_drm_front_info *front_info,return ret; } -int xen_drm_front_dbuf_create_from_sgt (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct sg_table *sgt) -{ -return be_dbuf_create_int (front_info, dbuf_cookie, width, height, - bpp, size,NULL , sgt); -} - -int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct page **pages) -{ -return be_dbuf_create_int (front_info, dbuf_cookie, width, height, - bpp, size, pages,NULL ); -} -static int xen_drm_front_dbuf_destroy (struct xen_drm_front_info *front_info,u64 dbuf_cookie) {@@ -434,24 +415,11 @@ static int xen_drm_drv_dumb_create(struct drm_file *filp, goto fail; } -/* -* In case of CONFIG_DRM_XEN_FRONTEND_CMA gem_obj is constructed -* via DRM CMA helpers and doesn't have ->pages allocated -* (xendrm_gem_get_pages will return NULL), but instead can provide -* sg table -*/ -if (xen_drm_front_gem_get_pages (obj)) - ret =xen_drm_front_dbuf_create_from_pages (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (obj), - args->width, args->height, args->bpp, - args->size, -xen_drm_front_gem_get_pages (obj)); -else - ret =xen_drm_front_dbuf_create_from_sgt (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (obj), - args->width, args->height, args->bpp, - args->size, -xen_drm_front_gem_get_sg_table (obj)); + ret =xen_drm_front_dbuf_create (drm_info->front_info, +xen_drm_front_dbuf_to_cookie (obj), + args->width, args->height, args->bpp, + args->size, +xen_drm_front_gem_get_pages (obj));if (ret) goto fail_backend;@@ -523,11 +491,7 @@ static const struct file_operations xen_drm_dev_fops = { .poll = drm_poll, .read = drm_read, .llseek = no_llseek, -#ifdef CONFIG_DRM_XEN_FRONTEND_CMA - .mmap = drm_gem_cma_mmap, -#else .mmap = xen_drm_front_gem_mmap, -#endif };static const struct vm_operations_struct xen_drm_drv_vm_ops = {@@ -547,6 +511,9 @@ static struct drm_driver xen_drm_driver = { .gem_prime_export = drm_gem_prime_export, .gem_prime_import_sg_table = xen_drm_front_gem_import_sg_table, .gem_prime_get_sg_table = xen_drm_front_gem_get_sg_table, + .gem_prime_vmap = xen_drm_front_gem_prime_vmap, + .gem_prime_vunmap = xen_drm_front_gem_prime_vunmap, + .gem_prime_mmap = xen_drm_front_gem_prime_mmap, .dumb_create = xen_drm_drv_dumb_create, .fops = &xen_drm_dev_fops, .name = "xendrm-du",@@ -555,15 +522,6 @@ static struct drm_driver xen_drm_driver = { .major = 1, .minor = 0, -#ifdef CONFIG_DRM_XEN_FRONTEND_CMA - .gem_prime_vmap = drm_gem_cma_prime_vmap, - .gem_prime_vunmap = drm_gem_cma_prime_vunmap, - .gem_prime_mmap = drm_gem_cma_prime_mmap, -#else - .gem_prime_vmap = xen_drm_front_gem_prime_vmap, - .gem_prime_vunmap = xen_drm_front_gem_prime_vunmap, - .gem_prime_mmap = xen_drm_front_gem_prime_mmap, -#endif };static int xen_drm_drv_init (struct xen_drm_front_info *front_info)drivers/gpu/drm/xen/xen_drm_front.h +6
-36@@ -23,40 +23,14 @@* * Depending on the requirements for the para-virtualized environment, namely * requirements dictated by the accompanying DRM/(v)GPU drivers running in both -* host and guest environments, number of operating modes of para-virtualized -* display driver are supported: -* -* - display buffers can be allocated by either frontend driver or backend -* - display buffers can be allocated to be contiguous in memory or not -* -* Note! Frontend driver itself has no dependency on contiguous memory for -* its operation. +* host and guest environments, display buffers can be allocated by either +* frontend driver or backend. */ /** * DOC: Buffers allocated by the frontend driver * -* The below modes of operation are configured at compile-time via -* frontend driver's kernel configuration: -*/ - -/** -* DOC: With GEM CMA helpers -* -* This use-case is useful when used with accompanying DRM/vGPU driver in -* guest domain which was designed to only work with contiguous buffers, -* e.g. DRM driver based on GEM CMA helpers: such drivers can only import -* contiguous PRIME buffers, thus requiring frontend driver to provide -* such. In order to implement this mode of operation para-virtualized -* frontend driver can be configured to use GEM CMA helpers. -*/ - -/** -* DOC: Without GEM CMA helpers -* -* If accompanying drivers can cope with non-contiguous memory then, to -* lower pressure on CMA subsystem of the kernel, driver can allocate -* buffers from system memory. +* In this mode of operation driver allocates buffers from system memory. * * Note! If used with accompanying DRM/(v)GPU drivers this mode of operation * may require IOMMU support on the platform, so accompanying DRM/vGPU @@ -164,13 +138,9 @@ int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline, u32 x, u32 y, u32 width, u32 height, u32 bpp, u64 fb_cookie); -int xen_drm_front_dbuf_create_from_sgt (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct sg_table *sgt); - -int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct page **pages); +int xen_drm_front_dbuf_create (struct xen_drm_front_info *front_info, +u64 dbuf_cookie,u32 width,u32 height, +u32 bpp,u64 size,struct page **pages); int xen_drm_front_fb_attach(struct xen_drm_front_info *front_info, u64 dbuf_cookie, u64 fb_cookie, u32 width,drivers/gpu/drm/xen/xen_drm_front_gem.c +3
-9@@ -210,15 +210,9 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev,if (ret <0 )return ERR_PTR (ret); -/* -* N.B. Although we have an API to create display buffer from sgt -* we use pages API, because we still need those for GEM handling, -* e.g. for mapping etc. -*/ - ret =xen_drm_front_dbuf_create_from_pages (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (&xen_obj->base), -0 ,0 ,0 , size, - xen_obj->pages); + ret =xen_drm_front_dbuf_create (drm_info->front_info, +xen_drm_front_dbuf_to_cookie (&xen_obj->base), +0 ,0 ,0 , size, xen_obj->pages);if (ret <0 )return ERR_PTR (ret);drivers/gpu/drm/xen/xen_drm_front_gem.h +0
-3@@ -27,8 +27,6 @@ struct page **xen_drm_front_gem_get_pages(struct drm_gem_object *obj);void xen_drm_front_gem_free_object_unlocked (struct drm_gem_object *gem_obj); -#ifndef CONFIG_DRM_XEN_FRONTEND_CMA -int xen_drm_front_gem_mmap (struct file *filp,struct vm_area_struct *vma);void *xen_drm_front_gem_prime_vmap (struct drm_gem_object *gem_obj);@@ -38,6 +36,5 @@ void xen_drm_front_gem_prime_vunmap(struct drm_gem_object *gem_obj,int xen_drm_front_gem_prime_mmap (struct drm_gem_object *gem_obj,struct vm_area_struct *vma); -#endif #endif /* __XEN_DRM_FRONT_GEM_H */ drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-79@@ -1,79 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 OR MIT - -/* -* Xen para-virtual DRM device -* -* Copyright (C) 2016-2018 EPAM Systems Inc. -* -* Author: Oleksandr Andrushchenko <[email protected]> -*/ - -#include <drm/drmP.h> -#include <drm/drm_gem.h> -#include <drm/drm_fb_cma_helper.h> -#include <drm/drm_gem_cma_helper.h> - -#include "xen_drm_front.h" -#include "xen_drm_front_gem.h" - -struct drm_gem_object * -xen_drm_front_gem_import_sg_table (struct drm_device *dev, -struct dma_buf_attachment *attach, -struct sg_table *sgt) -{ -struct xen_drm_front_drm_info *drm_info = dev->dev_private; -struct drm_gem_object *gem_obj; -struct drm_gem_cma_object *cma_obj; -int ret; - - gem_obj =drm_gem_cma_prime_import_sg_table (dev, attach, sgt); -if (IS_ERR_OR_NULL (gem_obj)) -return gem_obj; - - cma_obj =to_drm_gem_cma_obj (gem_obj); - - ret =xen_drm_front_dbuf_create_from_sgt (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (gem_obj), -0 ,0 ,0 , gem_obj->size, -drm_gem_cma_prime_get_sg_table (gem_obj)); -if (ret <0 ) -return ERR_PTR (ret); - -DRM_DEBUG ("Imported CMA buffer of size %zu\n" , gem_obj->size); - -return gem_obj; -} - -struct sg_table *xen_drm_front_gem_get_sg_table (struct drm_gem_object *gem_obj) -{ -return drm_gem_cma_prime_get_sg_table (gem_obj); -} - -struct drm_gem_object *xen_drm_front_gem_create (struct drm_device *dev, -size_t size) -{ -struct xen_drm_front_drm_info *drm_info = dev->dev_private; -struct drm_gem_cma_object *cma_obj; - -if (drm_info->front_info->cfg.be_alloc) { -/* This use-case is not yet supported and probably won't be */ -DRM_ERROR ("Backend allocated buffers and CMA helpers are not supported at the same time\n" ); -return ERR_PTR (-EINVAL ); - } - - cma_obj =drm_gem_cma_create (dev, size); -if (IS_ERR_OR_NULL (cma_obj)) -return ERR_CAST (cma_obj); - -return &cma_obj->base; -} - -void xen_drm_front_gem_free_object_unlocked (struct drm_gem_object *gem_obj) -{ -drm_gem_cma_free_object (gem_obj); -} - -struct page **xen_drm_front_gem_get_pages (struct drm_gem_object *gem_obj) -{ -return NULL ; -}drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0
-22@@ -89,10 +89,6 @@ void xen_drm_front_shbuf_free(struct xen_drm_front_shbuf *buf) }kfree (buf->grefs);kfree (buf->directory); -if (buf->sgt) { -sg_free_table (buf->sgt); -kvfree (buf->pages); - }kfree (buf); }@@ -350,17 +346,6 @@ static int grant_references(struct xen_drm_front_shbuf *buf)static int alloc_storage (struct xen_drm_front_shbuf *buf) { -if (buf->sgt) { - buf->pages =kvmalloc_array (buf->num_pages, -sizeof (struct page *),GFP_KERNEL ); -if (!buf->pages) -return -ENOMEM ; - -if (drm_prime_sg_to_page_addr_arrays (buf->sgt, buf->pages, -NULL , buf->num_pages) <0 ) -return -EINVAL ; - } - buf->grefs =kcalloc (buf->num_grefs,sizeof (*buf->grefs),GFP_KERNEL );if (!buf->grefs)return -ENOMEM ;@@ -396,12 +381,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg)struct xen_drm_front_shbuf *buf;int ret; -/* either pages or sgt, not both */ -if (unlikely (cfg->pages && cfg->sgt)) { -DRM_ERROR ("Cannot handle buffer allocation with both pages and sg table provided\n" ); -return NULL ; - } - buf =kzalloc (sizeof (*buf),GFP_KERNEL );if (!buf)return NULL ;@@ -413,7 +392,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg) buf->xb_dev = cfg->xb_dev; buf->num_pages =DIV_ROUND_UP (cfg->size,PAGE_SIZE ); - buf->sgt = cfg->sgt; buf->pages = cfg->pages; buf->ops->calc_num_grefs (buf);drivers/gpu/drm/xen/xen_drm_front_shbuf.h +0
-8@@ -29,16 +29,9 @@ struct xen_drm_front_shbuf {grant_ref_t *grefs;unsigned char *directory; -/* -* there are 2 ways to provide backing storage for this shared buffer: -* either pages or sgt. if buffer created from sgt then we own -* the pages and must free those ourselves on closure -*/ int num_pages;struct page **pages; -struct sg_table *sgt; -struct xenbus_device *xb_dev;/* these are the ops used internally depending on be_alloc mode */ @@ -52,7 +45,6 @@ struct xen_drm_front_shbuf_cfg {struct xenbus_device *xb_dev;size_t size;struct page **pages; -struct sg_table *sgt;bool be_alloc; };Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Oleksandr Andrushchenko
AppliedQuoted 39 lines · Oleksandr Andrushchenko
Quoted 10 lines · Daniel Vetter
Quoted 9 lines · Oleksandr Andrushchenko
From: Oleksandr Andrushchenko <[email protected]>
Even if xen-front allocates its buffers from contiguous memory those are still not contiguous in PA space, e.g. the buffer is only contiguous in IPA space.
The only use-case for this mode was if xen-front is used to allocate dumb buffers which later be used by some other driver requiring contiguous memory, but there is no currently such a use-case or it can be worked around with xen-front.Quoted 3 lines
Please also mention the nents confusion here, and the patch that fixes it. Or just outright take the commit message from my patch with all the details:
ok, if you don't mind then I'll use your commit message entirely
Quoted 24 lines
drm/xen: Dissable CMA support
It turns out this was only needed to paper over a bug in the CMA helpers, which was addressed in
commit998fb1a0f478b83492220ff79583bf9ad538bdd8
Author: Liviu Dudau <[email protected]>
Date: Fri Nov 10 13:33:10 2017 +0000
drm:gem_cma_helper.c: Allow importing of contiguous scatterlists with nents > 1 Without this the following pipeline didn't work:
domU:
1. xen-front allocates a non-contig buffer
2. creates grants out of it
dom0:
3. converts the grants into a dma-buf. Since they're non-contig, the scatter-list is huge.
4. imports it into rcar-du, which requires dma-contig memory for
scanout.
-> On this given platform there's an IOMMU, so in theory this should work. But in practice this failed, because of the huge number of sg entries, even though the IOMMU driver mapped it all into a dma-contig range.
With a guest-contig buffer allocated in step 1, this problem doesn't exist. But there's technically no reason to require guest-contig
memory for xen buffer sharing using grants.
Quoted 5 lines
Quoted 3 lines
With the commit message improved:
Acked-by Daniel Vetter <[email protected]>Thank you,
I'll wait for a day and apply to drm-misc-next if this is ok
applied to drm-misc-next
Quoted 483 lines
Quoted 483 lines
Quoted 483 lines
Signed-off-by Oleksandr Andrushchenko <[email protected]>Suggested-by Daniel Vetter <[email protected]>---
Documentation/gpu/xen-front.rst | 12 ---- drivers/gpu/drm/xen/Kconfig | 13 ---- drivers/gpu/drm/xen/Makefile | 9 +-- drivers/gpu/drm/xen/xen_drm_front.c | 62 +++------------- drivers/gpu/drm/xen/xen_drm_front.h | 42 ++--------- drivers/gpu/drm/xen/xen_drm_front_gem.c | 12 +--- drivers/gpu/drm/xen/xen_drm_front_gem.h | 3 -drivers/gpu/drm/xen/xen_drm_front_gem_cma.c| 79
---------------------
drivers/gpu/drm/xen/xen_drm_front_shbuf.c | 22 ------ drivers/gpu/drm/xen/xen_drm_front_shbuf.h | 8 ---10 files changed, 21 insertions(+), 241 deletions(-)delete mode 100644
drivers/gpu/drm/xen/xen_drm_front_gem_cma.cDocumentation/gpu/xen-front.rst +0
-0@@ -18,18 +18,6 @@ Buffers allocated by the frontend driver.. kernel-doc::
drivers/gpu/drm/xen/xen_drm_front.h:doc: Buffers allocated by the frontend driver -With GEM CMA helpers
-~~~~~~~~~~~~~~~~~~~~Documentation/gpu/xen-front.rst +0
-10- -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: With GEM CMA helpers - -Without GEM CMA helpers -~~~~~~~~~~~~~~~~~~~~~~~ - -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: Without GEM CMA helpers -Buffers allocated by the backend
--------------------------------
diff --git a/drivers/gpu/drm/xen/Kconfig b/drivers/gpu/drm/xen/Kconfig index4f4abc91f3b6..4cca160782ab100644drivers/gpu/drm/xen/Kconfig +0
-0@@ -15,16 +15,3 @@ config DRM_XEN_FRONTENDhelp
Choose this option if you want to enable a para-virtualized frontend DRM/KMS driver for Xen guest OSes.drivers/gpu/drm/xen/Kconfig +0
-13- -config DRM_XEN_FRONTEND_CMA - bool "Use DRM CMA to allocate dumb buffers" - depends on DRM_XEN_FRONTEND - select DRM_KMS_CMA_HELPER - select DRM_GEM_CMA_HELPER - help - Use DRM CMA helpers to allocate display buffers. - This is useful for the use-cases when guest driver needs to - share or export buffers to other drivers which only expect - contiguous buffers. - Note: in this mode driver cannot use buffers allocated - by the backend.drivers/gpu/drm/xen/Makefile +2
-7@@ -5,12 +5,7 @@ drm_xen_front-objs := xen_drm_front.o \ xen_drm_front_conn.o \ xen_drm_front_evtchnl.o \ xen_drm_front_shbuf.o \ - xen_drm_front_cfg.o - -ifeq ($(CONFIG_DRM_XEN_FRONTEND_CMA),y) - drm_xen_front-objs += xen_drm_front_gem_cma.o -else - drm_xen_front-objs += xen_drm_front_gem.o -endif + xen_drm_front_cfg.o \ + xen_drm_front_gem.oobj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c +0
-1@@ -12,7 +12,6 @@ #include <drm/drm_atomic_helper.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_gem.h> -#include <drm/drm_gem_cma_helper.h> #include <linux/of_device.h> @@ -167,10 +166,9 @@ int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline, return ret;}
-static int be_dbuf_create_int(structxen_drm_front_info*front_info, +int xen_drm_front_dbuf_create(structxen_drm_front_info*front_info, u64dbuf_cookie, u32 width, u32 height, - u32 bpp, u64 size, struct page **pages,
- structsg_table*sgt)
+ u32 bpp, u64 size, struct page **pages)
{
structxen_drm_front_evtchnl*evtchnl;
structxen_drm_front_shbuf*shbuf;drivers/gpu/drm/xen/xen_drm_front.c +0
-16@@ -187,7 +185,6 @@ static int be_dbuf_create_int(structxen_drm_front_info *front_info, buf_cfg.xb_dev = front_info->xb_dev; buf_cfg.pages = pages; buf_cfg.size = size; - buf_cfg.sgt = sgt; buf_cfg.be_alloc = front_info->cfg.be_alloc; shbuf = xen_drm_front_shbuf_alloc(&buf_cfg);@@ -237,22 +234,6 @@ static int be_dbuf_create_int(structxen_drm_front_info *front_info, return ret; } -int xen_drm_front_dbuf_create_from_sgt(struct xen_drm_front_info *front_info, - u64 dbuf_cookie, u32 width, u32 height, - u32 bpp, u64 size, struct sg_table *sgt) -{ - return be_dbuf_create_int(front_info, dbuf_cookie, width, height, - bpp, size, NULL, sgt); -} - -int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, - u64 dbuf_cookie, u32 width, u32 height, - u32 bpp, u64 size, struct page **pages) -{ - return be_dbuf_create_int(front_info, dbuf_cookie, width, height, - bpp, size, pages, NULL); -} - static int xen_drm_front_dbuf_destroy(struct xen_drm_front_info *front_info,u64
dbuf_cookie)
{drivers/gpu/drm/xen/xen_drm_front.c +0
-0@@ -434,24 +415,11 @@ static int xen_drm_drv_dumb_create(structdrm_file *filp, goto fail; }- /*
- * In case ofCONFIG_DRM_XEN_FRONTEND_CMAgem_objis constructed - * via DRM CMA helpers and doesn't have ->pages allocated
- * (xendrm_gem_get_pageswill return NULL), but instead can provide
- * sg table
- */
- if (xen_drm_front_gem_get_pages(obj))
- ret = xen_drm_front_dbuf_create_from_pages(drm_info->front_info,
-xen_drm_front_dbuf_to_cookie(obj),
-args->width,args->height,args->bpp,
-args->size,
-xen_drm_front_gem_get_pages(obj));
- else
- ret = xen_drm_front_dbuf_create_from_sgt(drm_info->front_info, -xen_drm_front_dbuf_to_cookie(obj),
-args->width,args->height,args->bpp,
-args->size,
-xen_drm_front_gem_get_sg_table(obj));
+ ret = xen_drm_front_dbuf_create(drm_info->front_info,
+xen_drm_front_dbuf_to_cookie(obj),
+args->width,args->height,args->bpp,
+args->size,
+xen_drm_front_gem_get_pages(obj));
if (ret)
gotofail_backend;
@@ -523,11 +491,7 @@ static const structfile_operationsxen_drm_dev_fops= { .poll =drm_poll,
.read =drm_read,
.llseek =no_llseek,drivers/gpu/drm/xen/xen_drm_front.c +0
-3-#ifdef CONFIG_DRM_XEN_FRONTEND_CMA - .mmap = drm_gem_cma_mmap, -#else .mmap =
xen_drm_front_gem_mmap,
-#endif
};
static const structvm_operations_structxen_drm_drv_vm_ops= {drivers/gpu/drm/xen/xen_drm_front.c +3
-0@@ -547,6 +511,9 @@ static struct drm_driver xen_drm_driver = { .gem_prime_export = drm_gem_prime_export, .gem_prime_import_sg_table = xen_drm_front_gem_import_sg_table, .gem_prime_get_sg_table = xen_drm_front_gem_get_sg_table, + .gem_prime_vmap = xen_drm_front_gem_prime_vmap, + .gem_prime_vunmap = xen_drm_front_gem_prime_vunmap, + .gem_prime_mmap = xen_drm_front_gem_prime_mmap, .dumb_create = xen_drm_drv_dumb_create, .fops = &xen_drm_dev_fops, .name = "xendrm-du",@@ -555,15 +522,6 @@ static struct drm_driver xen_drm_driver = { .major = 1, .minor = 0,-#ifdef
CONFIG_DRM_XEN_FRONTEND_CMA
- .gem_prime_vmap =drm_gem_cma_prime_vmap, - .gem_prime_vunmap =drm_gem_cma_prime_vunmap, - .gem_prime_mmap =drm_gem_cma_prime_mmap,drivers/gpu/drm/xen/xen_drm_front.c +0
-5-#else - .gem_prime_vmap = xen_drm_front_gem_prime_vmap, - .gem_prime_vunmap = xen_drm_front_gem_prime_vunmap, - .gem_prime_mmap = xen_drm_front_gem_prime_mmap, -#endif };
static intxen_drm_drv_init(struct xen_drm_front_info *front_info)drivers/gpu/drm/xen/xen_drm_front.h +0
-1@@ -23,40 +23,14 @@ * * Depending on the requirements for the para-virtualized environment, namely * requirements dictated by the accompanying DRM/(v)GPU drivers running in both - * host and guest environments, number of operating modes ofpara-virtualized
- * display driver are supported:
- *
- * - display buffers can be allocated by either frontend driver or backend
- * - display buffers can be allocated to be contiguous in memory or not
- *
- * Note! Frontend driver itself has no dependency on contiguous memory for
- * its operation.
+ * host and guest environments, display buffers can be allocated by either
+ * frontend driver or backend.
*/
/**
* DOC: Buffers allocated by the frontend driver
*
- * The below modes of operation are configured at compile-time via
- * frontend driver's kernel configuration:
- */drivers/gpu/drm/xen/xen_drm_front.h +0
-5- -/** -* DOC: With GEM CMA helpers -* -* This use-case is useful when used with accompanying DRM/vGPU driver in
- * guest domain which was designed to only work with contiguous buffers,
- * e.g. DRM driver based on GEM CMA helpers: such drivers can only import
- * contiguous PRIME buffers, thus requiring frontend driver to provide
- * such. In order to implement this mode of operation para-virtualized
- * frontend driver can be configured to use GEM CMA helpers.
- */drivers/gpu/drm/xen/xen_drm_front.h +0
-5- -/** -* DOC: Without GEM CMA helpers -* -* If accompanying drivers can cope with non-contiguous memory then, to
- * lower pressure on CMA subsystem of the kernel, driver can allocate
- * buffers from system memory.
+ * In this mode of operation driver allocates buffers from system memory.
*
* Note! If used with accompanying DRM/(v)GPU drivers this mode of operation
* may require IOMMU support on the platform, so accompanying DRM/vGPUdrivers/gpu/drm/xen/xen_drm_front.h +3
-6@@ -164,13 +138,9 @@ int xen_drm_front_mode_set(structxen_drm_front_drm_pipeline *pipeline, u32 x, u32 y, u32 width, u32 height, u32 bpp, u64 fb_cookie); -int xen_drm_front_dbuf_create_from_sgt(struct xen_drm_front_info *front_info, - u64 dbuf_cookie, u32 width, u32 height, - u32 bpp, u64 size, struct sg_table *sgt); - -int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, - u64 dbuf_cookie, u32 width, u32 height, - u32 bpp, u64 size, struct page **pages); +int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info, + u64 dbuf_cookie, u32 width, u32 height, + u32 bpp, u64 size, struct page **pages); int xen_drm_front_fb_attach(struct xen_drm_front_info *front_info,u64
dbuf_cookie, u64fb_cookie, u32 width,drivers/gpu/drm/xen/xen_drm_front_gem.c +0
-0@@ -210,15 +210,9 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev, if (ret < 0) return ERR_PTR(ret);- /*
- * N.B. Although we have an API to create display buffer from sgt
- * we use pages API, because we still need those for GEM handling,
- * e.g. for mapping etc.
- */
- ret = xen_drm_front_dbuf_create_from_pages(drm_info->front_info,
-xen_drm_front_dbuf_to_cookie(&xen_obj->base),
- 0, 0, 0, size,
-xen_obj->pages);
+ ret = xen_drm_front_dbuf_create(drm_info->front_info,
+xen_drm_front_dbuf_to_cookie(&xen_obj->base),
+ 0, 0, 0, size,xen_obj->pages);
if (ret < 0)
returnERR_PTR(ret);
diff --gita/drivers/gpu/drm/xen/xen_drm_front_gem.hb/drivers/gpu/drm/xen/xen_drm_front_gem.hindex55e531f5a763..d5ab734fdafe100644drivers/gpu/drm/xen/xen_drm_front_gem.h +0
-0@@ -27,8 +27,6 @@ struct page **xen_drm_front_gem_get_pages(struct drm_gem_object *obj); void xen_drm_front_gem_free_object_unlocked(struct drm_gem_object *gem_obj);-#ifndef
CONFIG_DRM_XEN_FRONTEND_CMA
-
intxen_drm_front_gem_mmap(struct file *filp, struct vm_area_struct *vma); void *xen_drm_front_gem_prime_vmap(structdrm_gem_object*gem_obj);drivers/gpu/drm/xen/xen_drm_front_gem.h +0
-1@@ -38,6 +36,5 @@ void xen_drm_front_gem_prime_vunmap(structdrm_gem_object *gem_obj, int xen_drm_front_gem_prime_mmap(struct drm_gem_object *gem_obj, struct vm_area_struct *vma); -#endif #endif /* __XEN_DRM_FRONT_GEM_H */drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-47@@ -1,79 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 OR MIT - -/* -* Xen para-virtual DRM device -* -* Copyright (C) 2016-2018 EPAM Systems Inc. -* -* Author: Oleksandr Andrushchenko <[email protected]> -*/ - -#include <drm/drmP.h> -#include <drm/drm_gem.h> -#include <drm/drm_fb_cma_helper.h> -#include <drm/drm_gem_cma_helper.h> - -#include "xen_drm_front.h" -#include "xen_drm_front_gem.h" - -struct drm_gem_object * -xen_drm_front_gem_import_sg_table (struct drm_device *dev, - struct dma_buf_attachment *attach, - struct sg_table *sgt) -{ - struct xen_drm_front_drm_info *drm_info = dev->dev_private; - struct drm_gem_object *gem_obj; - struct drm_gem_cma_object *cma_obj; - int ret; - - gem_obj = drm_gem_cma_prime_import_sg_table(dev, attach, sgt); - if (IS_ERR_OR_NULL(gem_obj)) - return gem_obj; - - cma_obj = to_drm_gem_cma_obj(gem_obj); - - ret = xen_drm_front_dbuf_create_from_sgt(drm_info->front_info, -xen_drm_front_dbuf_to_cookie (gem_obj), - 0, 0, 0, gem_obj->size, -drm_gem_cma_prime_get_sg_table (gem_obj)); - if (ret < 0) - return ERR_PTR(ret); - - DRM_DEBUG("Imported CMA buffer of size %zu\n", gem_obj->size); - - return gem_obj; -} - -struct sg_table *xen_drm_front_gem_get_sg_table(struct
drm_gem_object*gem_obj)drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-5-{ - return drm_gem_cma_prime_get_sg_table(gem_obj); -} - -struct drm_gem_object *xen_drm_front_gem_create(struct drm_device*dev,
-size_tsize)drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-7-{ - struct xen_drm_front_drm_info *drm_info = dev->dev_private; - struct drm_gem_cma_object *cma_obj; - - if (drm_info->front_info->cfg.be_alloc) { - /* This use-case is not yet supported and probably won't be */ - DRM_ERROR("Backend allocated buffers and CMA helpers arenot supported at the same time\n");
- returnERR_PTR(-EINVAL);
- }drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-9- - cma_obj = drm_gem_cma_create(dev, size); - if (IS_ERR_OR_NULL(cma_obj)) - return ERR_CAST(cma_obj); - - return &cma_obj->base; -} - -void xen_drm_front_gem_free_object_unlocked(struct drm_gem_object
*gem_obj)drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-5-{ - drm_gem_cma_free_object(gem_obj); -} - -struct page **xen_drm_front_gem_get_pages(struct drm_gem_object
*gem_obj)drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-3-{ - return NULL; -}drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0
-4@@ -89,10 +89,6 @@ void xen_drm_front_shbuf_free(struct xen_drm_front_shbuf *buf) } kfree(buf->grefs); kfree(buf->directory); - if (buf->sgt) { - sg_free_table(buf->sgt); - kvfree(buf->pages); - } kfree(buf); }@@ -350,17 +346,6 @@ static int
grant_references(struct xen_drm_front_shbuf *buf)static intalloc_storage(struct xen_drm_front_shbuf *buf)
{
- if (buf->sgt) {
-buf->pages= kvmalloc_array(buf->num_pages,
-sizeof(struct page *),GFP_KERNEL);
- if (!buf->pages)
- return-ENOMEM;drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0
-6- - if (drm_prime_sg_to_page_addr_arrays(buf->sgt, buf->pages, - NULL, buf->num_pages) < 0) - return -EINVAL; - } -
buf->grefs=kcalloc(buf->num_grefs, sizeof(*buf->grefs), GFP_KERNEL); if (!buf->grefs)
return-ENOMEM;drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0
-0@@ -396,12 +381,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg) struct xen_drm_front_shbuf *buf; int ret;- /* either pages or sgt, not both */
- if (unlikely(cfg->pages && cfg->sgt)) {
-DRM_ERROR("Cannot handle buffer allocation with both pages and sg table provided\n");
- return NULL;
- }
-
buf =kzalloc(sizeof(*buf), GFP_KERNEL);
if (!buf)
return NULL;drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0
-1@@ -413,7 +392,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg) buf->xb_dev = cfg->xb_dev; buf->num_pages = DIV_ROUND_UP(cfg->size, PAGE_SIZE); - buf->sgt = cfg->sgt; buf->pages = cfg->pages; buf->ops->calc_num_grefs(buf);drivers/gpu/drm/xen/xen_drm_front_shbuf.h +0
-0@@ -29,16 +29,9 @@ struct xen_drm_front_shbuf { grant_ref_t *grefs; unsigned char *directory;- /*
- * there are 2 ways to provide backing storage for this shared buffer:
- * either pages or sgt. if buffer created from sgt then we own - * the pages and must free those ourselves on closure
- */
intnum_pages;
struct page **pages;
- structsg_table*sgt;
-
structxenbus_device*xb_dev;
/* these are the ops used internally depending onbe_allocmode */drivers/gpu/drm/xen/xen_drm_front_shbuf.h +0
-1@@ -52,7 +45,6 @@ struct xen_drm_front_shbuf_cfg { struct xenbus_device *xb_dev; size_t size; struct page **pages; - struct sg_table *sgt; bool be_alloc; };--
2.17.0
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Oleksandr Andrushchenko
AppliedQuoted 39 lines · Oleksandr Andrushchenko
Quoted 10 lines · Daniel Vetter
Quoted 9 lines · Oleksandr Andrushchenko
From: Oleksandr Andrushchenko <[email protected]>
Even if xen-front allocates its buffers from contiguous memory those are still not contiguous in PA space, e.g. the buffer is only contiguous in IPA space.
The only use-case for this mode was if xen-front is used to allocate dumb buffers which later be used by some other driver requiring contiguous memory, but there is no currently such a use-case or it can be worked around with xen-front.Quoted 3 lines
Please also mention the nents confusion here, and the patch that fixes it. Or just outright take the commit message from my patch with all the details:
ok, if you don't mind then I'll use your commit message entirely
Quoted 24 lines
drm/xen: Dissable CMA support
It turns out this was only needed to paper over a bug in the CMA helpers, which was addressed in
commit998fb1a0f478b83492220ff79583bf9ad538bdd8
Author: Liviu Dudau <[email protected]>
Date: Fri Nov 10 13:33:10 2017 +0000
drm:gem_cma_helper.c: Allow importing of contiguous scatterlists with nents > 1 Without this the following pipeline didn't work:
domU:
1. xen-front allocates a non-contig buffer
2. creates grants out of it
dom0:
3. converts the grants into a dma-buf. Since they're non-contig, the scatter-list is huge.
4. imports it into rcar-du, which requires dma-contig memory for
scanout.
-> On this given platform there's an IOMMU, so in theory this should work. But in practice this failed, because of the huge number of sg entries, even though the IOMMU driver mapped it all into a dma-contig range.
With a guest-contig buffer allocated in step 1, this problem doesn't exist. But there's technically no reason to require guest-contig
memory for xen buffer sharing using grants.
Quoted 5 lines
Quoted 3 lines
With the commit message improved:
Acked-by Daniel Vetter <[email protected]>Thank you,
I'll wait for a day and apply to drm-misc-next if this is ok
applied to drm-misc-next
Quoted 483 lines
Quoted 483 lines
Quoted 483 lines
Signed-off-by Oleksandr Andrushchenko <[email protected]>Suggested-by Daniel Vetter <[email protected]>---
Documentation/gpu/xen-front.rst | 12 ---- drivers/gpu/drm/xen/Kconfig | 13 ---- drivers/gpu/drm/xen/Makefile | 9 +-- drivers/gpu/drm/xen/xen_drm_front.c | 62 +++------------- drivers/gpu/drm/xen/xen_drm_front.h | 42 ++--------- drivers/gpu/drm/xen/xen_drm_front_gem.c | 12 +--- drivers/gpu/drm/xen/xen_drm_front_gem.h | 3 -drivers/gpu/drm/xen/xen_drm_front_gem_cma.c| 79
---------------------
drivers/gpu/drm/xen/xen_drm_front_shbuf.c | 22 ------ drivers/gpu/drm/xen/xen_drm_front_shbuf.h | 8 ---10 files changed, 21 insertions(+), 241 deletions(-)delete mode 100644
drivers/gpu/drm/xen/xen_drm_front_gem_cma.cDocumentation/gpu/xen-front.rst +0
-0@@ -18,18 +18,6 @@ Buffers allocated by the frontend driver.. kernel-doc::
drivers/gpu/drm/xen/xen_drm_front.h:doc: Buffers allocated by the frontend driver -With GEM CMA helpers
-~~~~~~~~~~~~~~~~~~~~Documentation/gpu/xen-front.rst +0
-10- -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: With GEM CMA helpers - -Without GEM CMA helpers -~~~~~~~~~~~~~~~~~~~~~~~ - -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: Without GEM CMA helpers -Buffers allocated by the backend
--------------------------------
diff --git a/drivers/gpu/drm/xen/Kconfig b/drivers/gpu/drm/xen/Kconfig index4f4abc91f3b6..4cca160782ab100644drivers/gpu/drm/xen/Kconfig +0
-0@@ -15,16 +15,3 @@ config DRM_XEN_FRONTENDhelp
Choose this option if you want to enable a para-virtualized frontend DRM/KMS driver for Xen guest OSes.drivers/gpu/drm/xen/Kconfig +0
-13- -config DRM_XEN_FRONTEND_CMA - bool "Use DRM CMA to allocate dumb buffers" - depends on DRM_XEN_FRONTEND - select DRM_KMS_CMA_HELPER - select DRM_GEM_CMA_HELPER - help - Use DRM CMA helpers to allocate display buffers. - This is useful for the use-cases when guest driver needs to - share or export buffers to other drivers which only expect - contiguous buffers. - Note: in this mode driver cannot use buffers allocated - by the backend.drivers/gpu/drm/xen/Makefile +2
-7@@ -5,12 +5,7 @@ drm_xen_front-objs := xen_drm_front.o \ xen_drm_front_conn.o \ xen_drm_front_evtchnl.o \ xen_drm_front_shbuf.o \ - xen_drm_front_cfg.o - -ifeq ($(CONFIG_DRM_XEN_FRONTEND_CMA),y) - drm_xen_front-objs += xen_drm_front_gem_cma.o -else - drm_xen_front-objs += xen_drm_front_gem.o -endif + xen_drm_front_cfg.o \ + xen_drm_front_gem.oobj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.o
drivers/gpu/drm/xen/xen_drm_front.c +0
-1@@ -12,7 +12,6 @@ #include <drm/drm_atomic_helper.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_gem.h> -#include <drm/drm_gem_cma_helper.h> #include <linux/of_device.h> @@ -167,10 +166,9 @@ int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline, return ret;}
-static int be_dbuf_create_int(structxen_drm_front_info*front_info, +int xen_drm_front_dbuf_create(structxen_drm_front_info*front_info, u64dbuf_cookie, u32 width, u32 height, - u32 bpp, u64 size, struct page **pages,
- structsg_table*sgt)
+ u32 bpp, u64 size, struct page **pages)
{
structxen_drm_front_evtchnl*evtchnl;
structxen_drm_front_shbuf*shbuf;drivers/gpu/drm/xen/xen_drm_front.c +0
-16@@ -187,7 +185,6 @@ static int be_dbuf_create_int(structxen_drm_front_info *front_info, buf_cfg.xb_dev = front_info->xb_dev; buf_cfg.pages = pages; buf_cfg.size = size; - buf_cfg.sgt = sgt; buf_cfg.be_alloc = front_info->cfg.be_alloc; shbuf = xen_drm_front_shbuf_alloc(&buf_cfg);@@ -237,22 +234,6 @@ static int be_dbuf_create_int(structxen_drm_front_info *front_info, return ret; } -int xen_drm_front_dbuf_create_from_sgt(struct xen_drm_front_info *front_info, - u64 dbuf_cookie, u32 width, u32 height, - u32 bpp, u64 size, struct sg_table *sgt) -{ - return be_dbuf_create_int(front_info, dbuf_cookie, width, height, - bpp, size, NULL, sgt); -} - -int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, - u64 dbuf_cookie, u32 width, u32 height, - u32 bpp, u64 size, struct page **pages) -{ - return be_dbuf_create_int(front_info, dbuf_cookie, width, height, - bpp, size, pages, NULL); -} - static int xen_drm_front_dbuf_destroy(struct xen_drm_front_info *front_info,u64
dbuf_cookie)
{drivers/gpu/drm/xen/xen_drm_front.c +0
-0@@ -434,24 +415,11 @@ static int xen_drm_drv_dumb_create(structdrm_file *filp, goto fail; }- /*
- * In case ofCONFIG_DRM_XEN_FRONTEND_CMAgem_objis constructed - * via DRM CMA helpers and doesn't have ->pages allocated
- * (xendrm_gem_get_pageswill return NULL), but instead can provide
- * sg table
- */
- if (xen_drm_front_gem_get_pages(obj))
- ret = xen_drm_front_dbuf_create_from_pages(drm_info->front_info,
-xen_drm_front_dbuf_to_cookie(obj),
-args->width,args->height,args->bpp,
-args->size,
-xen_drm_front_gem_get_pages(obj));
- else
- ret = xen_drm_front_dbuf_create_from_sgt(drm_info->front_info, -xen_drm_front_dbuf_to_cookie(obj),
-args->width,args->height,args->bpp,
-args->size,
-xen_drm_front_gem_get_sg_table(obj));
+ ret = xen_drm_front_dbuf_create(drm_info->front_info,
+xen_drm_front_dbuf_to_cookie(obj),
+args->width,args->height,args->bpp,
+args->size,
+xen_drm_front_gem_get_pages(obj));
if (ret)
gotofail_backend;
@@ -523,11 +491,7 @@ static const structfile_operationsxen_drm_dev_fops= { .poll =drm_poll,
.read =drm_read,
.llseek =no_llseek,drivers/gpu/drm/xen/xen_drm_front.c +0
-3-#ifdef CONFIG_DRM_XEN_FRONTEND_CMA - .mmap = drm_gem_cma_mmap, -#else .mmap =
xen_drm_front_gem_mmap,
-#endif
};
static const structvm_operations_structxen_drm_drv_vm_ops= {drivers/gpu/drm/xen/xen_drm_front.c +3
-0@@ -547,6 +511,9 @@ static struct drm_driver xen_drm_driver = { .gem_prime_export = drm_gem_prime_export, .gem_prime_import_sg_table = xen_drm_front_gem_import_sg_table, .gem_prime_get_sg_table = xen_drm_front_gem_get_sg_table, + .gem_prime_vmap = xen_drm_front_gem_prime_vmap, + .gem_prime_vunmap = xen_drm_front_gem_prime_vunmap, + .gem_prime_mmap = xen_drm_front_gem_prime_mmap, .dumb_create = xen_drm_drv_dumb_create, .fops = &xen_drm_dev_fops, .name = "xendrm-du",@@ -555,15 +522,6 @@ static struct drm_driver xen_drm_driver = { .major = 1, .minor = 0,-#ifdef
CONFIG_DRM_XEN_FRONTEND_CMA
- .gem_prime_vmap =drm_gem_cma_prime_vmap, - .gem_prime_vunmap =drm_gem_cma_prime_vunmap, - .gem_prime_mmap =drm_gem_cma_prime_mmap,drivers/gpu/drm/xen/xen_drm_front.c +0
-5-#else - .gem_prime_vmap = xen_drm_front_gem_prime_vmap, - .gem_prime_vunmap = xen_drm_front_gem_prime_vunmap, - .gem_prime_mmap = xen_drm_front_gem_prime_mmap, -#endif };
static intxen_drm_drv_init(struct xen_drm_front_info *front_info)drivers/gpu/drm/xen/xen_drm_front.h +0
-1@@ -23,40 +23,14 @@ * * Depending on the requirements for the para-virtualized environment, namely * requirements dictated by the accompanying DRM/(v)GPU drivers running in both - * host and guest environments, number of operating modes ofpara-virtualized
- * display driver are supported:
- *
- * - display buffers can be allocated by either frontend driver or backend
- * - display buffers can be allocated to be contiguous in memory or not
- *
- * Note! Frontend driver itself has no dependency on contiguous memory for
- * its operation.
+ * host and guest environments, display buffers can be allocated by either
+ * frontend driver or backend.
*/
/**
* DOC: Buffers allocated by the frontend driver
*
- * The below modes of operation are configured at compile-time via
- * frontend driver's kernel configuration:
- */drivers/gpu/drm/xen/xen_drm_front.h +0
-5- -/** -* DOC: With GEM CMA helpers -* -* This use-case is useful when used with accompanying DRM/vGPU driver in
- * guest domain which was designed to only work with contiguous buffers,
- * e.g. DRM driver based on GEM CMA helpers: such drivers can only import
- * contiguous PRIME buffers, thus requiring frontend driver to provide
- * such. In order to implement this mode of operation para-virtualized
- * frontend driver can be configured to use GEM CMA helpers.
- */drivers/gpu/drm/xen/xen_drm_front.h +0
-5- -/** -* DOC: Without GEM CMA helpers -* -* If accompanying drivers can cope with non-contiguous memory then, to
- * lower pressure on CMA subsystem of the kernel, driver can allocate
- * buffers from system memory.
+ * In this mode of operation driver allocates buffers from system memory.
*
* Note! If used with accompanying DRM/(v)GPU drivers this mode of operation
* may require IOMMU support on the platform, so accompanying DRM/vGPUdrivers/gpu/drm/xen/xen_drm_front.h +3
-6@@ -164,13 +138,9 @@ int xen_drm_front_mode_set(structxen_drm_front_drm_pipeline *pipeline, u32 x, u32 y, u32 width, u32 height, u32 bpp, u64 fb_cookie); -int xen_drm_front_dbuf_create_from_sgt(struct xen_drm_front_info *front_info, - u64 dbuf_cookie, u32 width, u32 height, - u32 bpp, u64 size, struct sg_table *sgt); - -int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, - u64 dbuf_cookie, u32 width, u32 height, - u32 bpp, u64 size, struct page **pages); +int xen_drm_front_dbuf_create(struct xen_drm_front_info *front_info, + u64 dbuf_cookie, u32 width, u32 height, + u32 bpp, u64 size, struct page **pages); int xen_drm_front_fb_attach(struct xen_drm_front_info *front_info,u64
dbuf_cookie, u64fb_cookie, u32 width,drivers/gpu/drm/xen/xen_drm_front_gem.c +0
-0@@ -210,15 +210,9 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev, if (ret < 0) return ERR_PTR(ret);- /*
- * N.B. Although we have an API to create display buffer from sgt
- * we use pages API, because we still need those for GEM handling,
- * e.g. for mapping etc.
- */
- ret = xen_drm_front_dbuf_create_from_pages(drm_info->front_info,
-xen_drm_front_dbuf_to_cookie(&xen_obj->base),
- 0, 0, 0, size,
-xen_obj->pages);
+ ret = xen_drm_front_dbuf_create(drm_info->front_info,
+xen_drm_front_dbuf_to_cookie(&xen_obj->base),
+ 0, 0, 0, size,xen_obj->pages);
if (ret < 0)
returnERR_PTR(ret);
diff --gita/drivers/gpu/drm/xen/xen_drm_front_gem.hb/drivers/gpu/drm/xen/xen_drm_front_gem.hindex55e531f5a763..d5ab734fdafe100644drivers/gpu/drm/xen/xen_drm_front_gem.h +0
-0@@ -27,8 +27,6 @@ struct page **xen_drm_front_gem_get_pages(struct drm_gem_object *obj); void xen_drm_front_gem_free_object_unlocked(struct drm_gem_object *gem_obj);-#ifndef
CONFIG_DRM_XEN_FRONTEND_CMA
-
intxen_drm_front_gem_mmap(struct file *filp, struct vm_area_struct *vma); void *xen_drm_front_gem_prime_vmap(structdrm_gem_object*gem_obj);drivers/gpu/drm/xen/xen_drm_front_gem.h +0
-1@@ -38,6 +36,5 @@ void xen_drm_front_gem_prime_vunmap(structdrm_gem_object *gem_obj, int xen_drm_front_gem_prime_mmap(struct drm_gem_object *gem_obj, struct vm_area_struct *vma); -#endif #endif /* __XEN_DRM_FRONT_GEM_H */drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-47@@ -1,79 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 OR MIT - -/* -* Xen para-virtual DRM device -* -* Copyright (C) 2016-2018 EPAM Systems Inc. -* -* Author: Oleksandr Andrushchenko <[email protected]> -*/ - -#include <drm/drmP.h> -#include <drm/drm_gem.h> -#include <drm/drm_fb_cma_helper.h> -#include <drm/drm_gem_cma_helper.h> - -#include "xen_drm_front.h" -#include "xen_drm_front_gem.h" - -struct drm_gem_object * -xen_drm_front_gem_import_sg_table (struct drm_device *dev, - struct dma_buf_attachment *attach, - struct sg_table *sgt) -{ - struct xen_drm_front_drm_info *drm_info = dev->dev_private; - struct drm_gem_object *gem_obj; - struct drm_gem_cma_object *cma_obj; - int ret; - - gem_obj = drm_gem_cma_prime_import_sg_table(dev, attach, sgt); - if (IS_ERR_OR_NULL(gem_obj)) - return gem_obj; - - cma_obj = to_drm_gem_cma_obj(gem_obj); - - ret = xen_drm_front_dbuf_create_from_sgt(drm_info->front_info, -xen_drm_front_dbuf_to_cookie (gem_obj), - 0, 0, 0, gem_obj->size, -drm_gem_cma_prime_get_sg_table (gem_obj)); - if (ret < 0) - return ERR_PTR(ret); - - DRM_DEBUG("Imported CMA buffer of size %zu\n", gem_obj->size); - - return gem_obj; -} - -struct sg_table *xen_drm_front_gem_get_sg_table(struct
drm_gem_object*gem_obj)drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-5-{ - return drm_gem_cma_prime_get_sg_table(gem_obj); -} - -struct drm_gem_object *xen_drm_front_gem_create(struct drm_device*dev,
-size_tsize)drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-7-{ - struct xen_drm_front_drm_info *drm_info = dev->dev_private; - struct drm_gem_cma_object *cma_obj; - - if (drm_info->front_info->cfg.be_alloc) { - /* This use-case is not yet supported and probably won't be */ - DRM_ERROR("Backend allocated buffers and CMA helpers arenot supported at the same time\n");
- returnERR_PTR(-EINVAL);
- }drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-9- - cma_obj = drm_gem_cma_create(dev, size); - if (IS_ERR_OR_NULL(cma_obj)) - return ERR_CAST(cma_obj); - - return &cma_obj->base; -} - -void xen_drm_front_gem_free_object_unlocked(struct drm_gem_object
*gem_obj)drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-5-{ - drm_gem_cma_free_object(gem_obj); -} - -struct page **xen_drm_front_gem_get_pages(struct drm_gem_object
*gem_obj)drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-3-{ - return NULL; -}drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0
-4@@ -89,10 +89,6 @@ void xen_drm_front_shbuf_free(struct xen_drm_front_shbuf *buf) } kfree(buf->grefs); kfree(buf->directory); - if (buf->sgt) { - sg_free_table(buf->sgt); - kvfree(buf->pages); - } kfree(buf); }@@ -350,17 +346,6 @@ static int
grant_references(struct xen_drm_front_shbuf *buf)static intalloc_storage(struct xen_drm_front_shbuf *buf)
{
- if (buf->sgt) {
-buf->pages= kvmalloc_array(buf->num_pages,
-sizeof(struct page *),GFP_KERNEL);
- if (!buf->pages)
- return-ENOMEM;drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0
-6- - if (drm_prime_sg_to_page_addr_arrays(buf->sgt, buf->pages, - NULL, buf->num_pages) < 0) - return -EINVAL; - } -
buf->grefs=kcalloc(buf->num_grefs, sizeof(*buf->grefs), GFP_KERNEL); if (!buf->grefs)
return-ENOMEM;drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0
-0@@ -396,12 +381,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg) struct xen_drm_front_shbuf *buf; int ret;- /* either pages or sgt, not both */
- if (unlikely(cfg->pages && cfg->sgt)) {
-DRM_ERROR("Cannot handle buffer allocation with both pages and sg table provided\n");
- return NULL;
- }
-
buf =kzalloc(sizeof(*buf), GFP_KERNEL);
if (!buf)
return NULL;drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0
-1@@ -413,7 +392,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg) buf->xb_dev = cfg->xb_dev; buf->num_pages = DIV_ROUND_UP(cfg->size, PAGE_SIZE); - buf->sgt = cfg->sgt; buf->pages = cfg->pages; buf->ops->calc_num_grefs(buf);drivers/gpu/drm/xen/xen_drm_front_shbuf.h +0
-0@@ -29,16 +29,9 @@ struct xen_drm_front_shbuf { grant_ref_t *grefs; unsigned char *directory;- /*
- * there are 2 ways to provide backing storage for this shared buffer:
- * either pages or sgt. if buffer created from sgt then we own - * the pages and must free those ourselves on closure
- */
intnum_pages;
struct page **pages;
- structsg_table*sgt;
-
structxenbus_device*xb_dev;
/* these are the ops used internally depending onbe_allocmode */drivers/gpu/drm/xen/xen_drm_front_shbuf.h +0
-1@@ -52,7 +45,6 @@ struct xen_drm_front_shbuf_cfg { struct xenbus_device *xb_dev; size_t size; struct page **pages; - struct sg_table *sgt; bool be_alloc; };--
2.17.0
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 10 lines · Daniel Vetter
Quoted 9 lines · Oleksandr Andrushchenko
From: Oleksandr Andrushchenko <[email protected]>
Even if xen-front allocates its buffers from contiguous memory those are still not contiguous in PA space, e.g. the buffer is only contiguous in IPA space.
The only use-case for this mode was if xen-front is used to allocate dumb buffers which later be used by some other driver requiring contiguous memory, but there is no currently such a use-case or it can be worked around with xen-front.
Quoted 3 lines
Please also mention the nents confusion here, and the patch that fixes it. Or just outright take the commit message from my patch with all the details:
ok, if you don't mind then I'll use your commit message entirely
Quoted 28 lines
drm/xen: Dissable CMA support
It turns out this was only needed to paper over a bug in the CMA helpers, which was addressed in
commit
998fb1a0f478b83492220ff79583bf9ad538bdd8
Author: Liviu Dudau <[email protected]>
Date: Fri Nov 10 13:33:10 2017 +0000drm:
gem_cma_helper.c: Allow importing of contiguous scatterlists with nents > 1Without this the following pipeline didn't work:
domU:
1. xen-front allocates a non-contig buffer
2. creates grants out of itdom0:
3. converts the grants into a dma-buf. Since they're non-contig, the scatter-list is huge.
4. imports it into rcar-du, which requires dma-contig memory for scanout.-> On this given platform there's an IOMMU, so in theory this should work. But in practice this failed, because of the huge number of sg entries, even though the IOMMU driver mapped it all into a dma-contig range.
Quoted 7 lines
With a guest-contig buffer allocated in step 1, this problem doesn't exist. But there's technically no reason to require guest-contig memory for xen buffer sharing using grants.
With the commit message improved:
Acked-by Daniel Vetter <[email protected]>
Thank you,
I'll wait for a day and apply to drm-misc-next if this is ok
Quoted 480 lines
Quoted 480 lines
Signed-off-by Oleksandr Andrushchenko <[email protected]>Suggested-by Daniel Vetter <[email protected]>--- Documentation/gpu/xen-front.rst | 12 ---- drivers/gpu/drm/xen/Kconfig | 13 ---- drivers/gpu/drm/xen/Makefile | 9 +-- drivers/gpu/drm/xen/xen_drm_front.c | 62 +++------------- drivers/gpu/drm/xen/xen_drm_front.h | 42 ++--------- drivers/gpu/drm/xen/xen_drm_front_gem.c | 12 +--- drivers/gpu/drm/xen/xen_drm_front_gem.h | 3 - drivers/gpu/drm/xen/xen_drm_front_gem_cma.c | 79 --------------------- drivers/gpu/drm/xen/xen_drm_front_shbuf.c | 22 ------ drivers/gpu/drm/xen/xen_drm_front_shbuf.h | 8 --- 10 files changed, 21 insertions(+), 241 deletions(-)delete mode 100644
drivers/gpu/drm/xen/xen_drm_front_gem_cma.cDocumentation/gpu/xen-front.rst +0
-12@@ -18,18 +18,6 @@ Buffers allocated by the frontend driver .. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h :doc: Buffers allocated by the frontend driver -With GEM CMA helpers -~~~~~~~~~~~~~~~~~~~~ - -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: With GEM CMA helpers - -Without GEM CMA helpers -~~~~~~~~~~~~~~~~~~~~~~~ - -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: Without GEM CMA helpers - Buffers allocated by the backend --------------------------------drivers/gpu/drm/xen/Kconfig +0
-13@@ -15,16 +15,3 @@ config DRM_XEN_FRONTEND help Choose this option if you want to enable a para-virtualized frontend DRM/KMS driver for Xen guest OSes. - -config DRM_XEN_FRONTEND_CMA - bool "Use DRM CMA to allocate dumb buffers" - depends on DRM_XEN_FRONTEND - select DRM_KMS_CMA_HELPER - select DRM_GEM_CMA_HELPER - help - Use DRM CMA helpers to allocate display buffers. - This is useful for the use-cases when guest driver needs to - share or export buffers to other drivers which only expect - contiguous buffers. - Note: in this mode driver cannot use buffers allocated - by the backend.drivers/gpu/drm/xen/Makefile +2
-7@@ -5,12 +5,7 @@ drm_xen_front-objs := xen_drm_front.o \ xen_drm_front_conn.o \ xen_drm_front_evtchnl.o \ xen_drm_front_shbuf.o \ - xen_drm_front_cfg.o - -ifeq ($(CONFIG_DRM_XEN_FRONTEND_CMA),y) - drm_xen_front-objs += xen_drm_front_gem_cma.o -else - drm_xen_front-objs += xen_drm_front_gem.o -endif + xen_drm_front_cfg.o \ + xen_drm_front_gem.o obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.odrivers/gpu/drm/xen/xen_drm_front.c +10
-52@@ -12,7 +12,6 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_gem.h> -#include <drm/drm_gem_cma_helper.h> #include <linux/of_device.h> @@ -167,10 +166,9 @@ int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline,return ret; } -static int be_dbuf_create_int (struct xen_drm_front_info *front_info, +int xen_drm_front_dbuf_create (struct xen_drm_front_info *front_info,u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct page **pages, -struct sg_table *sgt) +u32 bpp,u64 size,struct page **pages) {struct xen_drm_front_evtchnl *evtchnl;struct xen_drm_front_shbuf *shbuf;@@ -187,7 +185,6 @@ static int be_dbuf_create_int(struct xen_drm_front_info *front_info, buf_cfg.xb_dev = front_info->xb_dev; buf_cfg.pages = pages; buf_cfg.size = size; - buf_cfg.sgt = sgt; buf_cfg.be_alloc = front_info->cfg.be_alloc; shbuf =xen_drm_front_shbuf_alloc (&buf_cfg);@@ -237,22 +234,6 @@ static int be_dbuf_create_int(struct xen_drm_front_info *front_info,return ret; } -int xen_drm_front_dbuf_create_from_sgt (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct sg_table *sgt) -{ -return be_dbuf_create_int (front_info, dbuf_cookie, width, height, - bpp, size,NULL , sgt); -} - -int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct page **pages) -{ -return be_dbuf_create_int (front_info, dbuf_cookie, width, height, - bpp, size, pages,NULL ); -} -static int xen_drm_front_dbuf_destroy (struct xen_drm_front_info *front_info,u64 dbuf_cookie) {@@ -434,24 +415,11 @@ static int xen_drm_drv_dumb_create(struct drm_file *filp, goto fail; } -/* -* In case of CONFIG_DRM_XEN_FRONTEND_CMA gem_obj is constructed -* via DRM CMA helpers and doesn't have ->pages allocated -* (xendrm_gem_get_pages will return NULL), but instead can provide -* sg table -*/ -if (xen_drm_front_gem_get_pages (obj)) - ret =xen_drm_front_dbuf_create_from_pages (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (obj), - args->width, args->height, args->bpp, - args->size, -xen_drm_front_gem_get_pages (obj)); -else - ret =xen_drm_front_dbuf_create_from_sgt (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (obj), - args->width, args->height, args->bpp, - args->size, -xen_drm_front_gem_get_sg_table (obj)); + ret =xen_drm_front_dbuf_create (drm_info->front_info, +xen_drm_front_dbuf_to_cookie (obj), + args->width, args->height, args->bpp, + args->size, +xen_drm_front_gem_get_pages (obj));if (ret) goto fail_backend;@@ -523,11 +491,7 @@ static const struct file_operations xen_drm_dev_fops = { .poll = drm_poll, .read = drm_read, .llseek = no_llseek, -#ifdef CONFIG_DRM_XEN_FRONTEND_CMA - .mmap = drm_gem_cma_mmap, -#else .mmap = xen_drm_front_gem_mmap, -#endif };static const struct vm_operations_struct xen_drm_drv_vm_ops = {@@ -547,6 +511,9 @@ static struct drm_driver xen_drm_driver = { .gem_prime_export = drm_gem_prime_export, .gem_prime_import_sg_table = xen_drm_front_gem_import_sg_table, .gem_prime_get_sg_table = xen_drm_front_gem_get_sg_table, + .gem_prime_vmap = xen_drm_front_gem_prime_vmap, + .gem_prime_vunmap = xen_drm_front_gem_prime_vunmap, + .gem_prime_mmap = xen_drm_front_gem_prime_mmap, .dumb_create = xen_drm_drv_dumb_create, .fops = &xen_drm_dev_fops, .name = "xendrm-du",@@ -555,15 +522,6 @@ static struct drm_driver xen_drm_driver = { .major = 1, .minor = 0, -#ifdef CONFIG_DRM_XEN_FRONTEND_CMA - .gem_prime_vmap = drm_gem_cma_prime_vmap, - .gem_prime_vunmap = drm_gem_cma_prime_vunmap, - .gem_prime_mmap = drm_gem_cma_prime_mmap, -#else - .gem_prime_vmap = xen_drm_front_gem_prime_vmap, - .gem_prime_vunmap = xen_drm_front_gem_prime_vunmap, - .gem_prime_mmap = xen_drm_front_gem_prime_mmap, -#endif };static int xen_drm_drv_init (struct xen_drm_front_info *front_info)drivers/gpu/drm/xen/xen_drm_front.h +6
-36@@ -23,40 +23,14 @@* * Depending on the requirements for the para-virtualized environment, namely * requirements dictated by the accompanying DRM/(v)GPU drivers running in both -* host and guest environments, number of operating modes of para-virtualized -* display driver are supported: -* -* - display buffers can be allocated by either frontend driver or backend -* - display buffers can be allocated to be contiguous in memory or not -* -* Note! Frontend driver itself has no dependency on contiguous memory for -* its operation. +* host and guest environments, display buffers can be allocated by either +* frontend driver or backend. */ /** * DOC: Buffers allocated by the frontend driver * -* The below modes of operation are configured at compile-time via -* frontend driver's kernel configuration: -*/ - -/** -* DOC: With GEM CMA helpers -* -* This use-case is useful when used with accompanying DRM/vGPU driver in -* guest domain which was designed to only work with contiguous buffers, -* e.g. DRM driver based on GEM CMA helpers: such drivers can only import -* contiguous PRIME buffers, thus requiring frontend driver to provide -* such. In order to implement this mode of operation para-virtualized -* frontend driver can be configured to use GEM CMA helpers. -*/ - -/** -* DOC: Without GEM CMA helpers -* -* If accompanying drivers can cope with non-contiguous memory then, to -* lower pressure on CMA subsystem of the kernel, driver can allocate -* buffers from system memory. +* In this mode of operation driver allocates buffers from system memory. * * Note! If used with accompanying DRM/(v)GPU drivers this mode of operation * may require IOMMU support on the platform, so accompanying DRM/vGPU @@ -164,13 +138,9 @@ int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline, u32 x, u32 y, u32 width, u32 height, u32 bpp, u64 fb_cookie); -int xen_drm_front_dbuf_create_from_sgt (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct sg_table *sgt); - -int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct page **pages); +int xen_drm_front_dbuf_create (struct xen_drm_front_info *front_info, +u64 dbuf_cookie,u32 width,u32 height, +u32 bpp,u64 size,struct page **pages); int xen_drm_front_fb_attach(struct xen_drm_front_info *front_info, u64 dbuf_cookie, u64 fb_cookie, u32 width,drivers/gpu/drm/xen/xen_drm_front_gem.c +3
-9@@ -210,15 +210,9 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev,if (ret <0 )return ERR_PTR (ret); -/* -* N.B. Although we have an API to create display buffer from sgt -* we use pages API, because we still need those for GEM handling, -* e.g. for mapping etc. -*/ - ret =xen_drm_front_dbuf_create_from_pages (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (&xen_obj->base), -0 ,0 ,0 , size, - xen_obj->pages); + ret =xen_drm_front_dbuf_create (drm_info->front_info, +xen_drm_front_dbuf_to_cookie (&xen_obj->base), +0 ,0 ,0 , size, xen_obj->pages);if (ret <0 )return ERR_PTR (ret);drivers/gpu/drm/xen/xen_drm_front_gem.h +0
-3@@ -27,8 +27,6 @@ struct page **xen_drm_front_gem_get_pages(struct drm_gem_object *obj);void xen_drm_front_gem_free_object_unlocked (struct drm_gem_object *gem_obj); -#ifndef CONFIG_DRM_XEN_FRONTEND_CMA -int xen_drm_front_gem_mmap (struct file *filp,struct vm_area_struct *vma);void *xen_drm_front_gem_prime_vmap (struct drm_gem_object *gem_obj);@@ -38,6 +36,5 @@ void xen_drm_front_gem_prime_vunmap(struct drm_gem_object *gem_obj,int xen_drm_front_gem_prime_mmap (struct drm_gem_object *gem_obj,struct vm_area_struct *vma); -#endif #endif /* __XEN_DRM_FRONT_GEM_H */ drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-79@@ -1,79 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 OR MIT - -/* -* Xen para-virtual DRM device -* -* Copyright (C) 2016-2018 EPAM Systems Inc. -* -* Author: Oleksandr Andrushchenko <[email protected]> -*/ - -#include <drm/drmP.h> -#include <drm/drm_gem.h> -#include <drm/drm_fb_cma_helper.h> -#include <drm/drm_gem_cma_helper.h> - -#include "xen_drm_front.h" -#include "xen_drm_front_gem.h" - -struct drm_gem_object * -xen_drm_front_gem_import_sg_table (struct drm_device *dev, -struct dma_buf_attachment *attach, -struct sg_table *sgt) -{ -struct xen_drm_front_drm_info *drm_info = dev->dev_private; -struct drm_gem_object *gem_obj; -struct drm_gem_cma_object *cma_obj; -int ret; - - gem_obj =drm_gem_cma_prime_import_sg_table (dev, attach, sgt); -if (IS_ERR_OR_NULL (gem_obj)) -return gem_obj; - - cma_obj =to_drm_gem_cma_obj (gem_obj); - - ret =xen_drm_front_dbuf_create_from_sgt (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (gem_obj), -0 ,0 ,0 , gem_obj->size, -drm_gem_cma_prime_get_sg_table (gem_obj)); -if (ret <0 ) -return ERR_PTR (ret); - -DRM_DEBUG ("Imported CMA buffer of size %zu\n" , gem_obj->size); - -return gem_obj; -} - -struct sg_table *xen_drm_front_gem_get_sg_table (struct drm_gem_object *gem_obj) -{ -return drm_gem_cma_prime_get_sg_table (gem_obj); -} - -struct drm_gem_object *xen_drm_front_gem_create (struct drm_device *dev, -size_t size) -{ -struct xen_drm_front_drm_info *drm_info = dev->dev_private; -struct drm_gem_cma_object *cma_obj; - -if (drm_info->front_info->cfg.be_alloc) { -/* This use-case is not yet supported and probably won't be */ -DRM_ERROR ("Backend allocated buffers and CMA helpers are not supported at the same time\n" ); -return ERR_PTR (-EINVAL ); - } - - cma_obj =drm_gem_cma_create (dev, size); -if (IS_ERR_OR_NULL (cma_obj)) -return ERR_CAST (cma_obj); - -return &cma_obj->base; -} - -void xen_drm_front_gem_free_object_unlocked (struct drm_gem_object *gem_obj) -{ -drm_gem_cma_free_object (gem_obj); -} - -struct page **xen_drm_front_gem_get_pages (struct drm_gem_object *gem_obj) -{ -return NULL ; -}drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0
-22@@ -89,10 +89,6 @@ void xen_drm_front_shbuf_free(struct xen_drm_front_shbuf *buf) }kfree (buf->grefs);kfree (buf->directory); -if (buf->sgt) { -sg_free_table (buf->sgt); -kvfree (buf->pages); - }kfree (buf); }@@ -350,17 +346,6 @@ static int grant_references(struct xen_drm_front_shbuf *buf)static int alloc_storage (struct xen_drm_front_shbuf *buf) { -if (buf->sgt) { - buf->pages =kvmalloc_array (buf->num_pages, -sizeof (struct page *),GFP_KERNEL ); -if (!buf->pages) -return -ENOMEM ; - -if (drm_prime_sg_to_page_addr_arrays (buf->sgt, buf->pages, -NULL , buf->num_pages) <0 ) -return -EINVAL ; - } - buf->grefs =kcalloc (buf->num_grefs,sizeof (*buf->grefs),GFP_KERNEL );if (!buf->grefs)return -ENOMEM ;@@ -396,12 +381,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg)struct xen_drm_front_shbuf *buf;int ret; -/* either pages or sgt, not both */ -if (unlikely (cfg->pages && cfg->sgt)) { -DRM_ERROR ("Cannot handle buffer allocation with both pages and sg table provided\n" ); -return NULL ; - } - buf =kzalloc (sizeof (*buf),GFP_KERNEL );if (!buf)return NULL ;@@ -413,7 +392,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg) buf->xb_dev = cfg->xb_dev; buf->num_pages =DIV_ROUND_UP (cfg->size,PAGE_SIZE ); - buf->sgt = cfg->sgt; buf->pages = cfg->pages; buf->ops->calc_num_grefs (buf);drivers/gpu/drm/xen/xen_drm_front_shbuf.h +0
-8@@ -29,16 +29,9 @@ struct xen_drm_front_shbuf {grant_ref_t *grefs;unsigned char *directory; -/* -* there are 2 ways to provide backing storage for this shared buffer: -* either pages or sgt. if buffer created from sgt then we own -* the pages and must free those ourselves on closure -*/ int num_pages;struct page **pages; -struct sg_table *sgt; -struct xenbus_device *xb_dev;/* these are the ops used internally depending on be_alloc mode */ @@ -52,7 +45,6 @@ struct xen_drm_front_shbuf_cfg {struct xenbus_device *xb_dev;size_t size;struct page **pages; -struct sg_table *sgt;bool be_alloc; };
Quoted 7 lines
Quoted 7 lines
Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 9 lines · Oleksandr Andrushchenko
From: Oleksandr Andrushchenko <[email protected]>
Even if xen-front allocates its buffers from contiguous memory those are still not contiguous in PA space, e.g. the buffer is only contiguous in IPA space.
The only use-case for this mode was if xen-front is used to allocate dumb buffers which later be used by some other driver requiring contiguous memory, but there is no currently such a use-case or it can be worked around with xen-front.
Please also mention the nents confusion here, and the patch that fixes it. Or just outright take the commit message from my patch with all the details:
drm/xen: Dissable CMA support
It turns out this was only needed to paper over a bug in the CMA helpers, which was addressed in
commit 998fb1a0f478b83492220ff79583bf9ad538bdd8
Author: Liviu Dudau <[email protected]>
Date: Fri Nov 10 13:33:10 2017 +0000
drm: gem_cma_helper.c: Allow importing of contiguous scatterlists with nents > 1
Without this the following pipeline didn't work:
domU:
1. xen-front allocates a non-contig buffer
2. creates grants out of it
dom0:
3. converts the grants into a dma-buf. Since they're non-contig, the scatter-list is huge.
4. imports it into rcar-du, which requires dma-contig memory for scanout.
-> On this given platform there's an IOMMU, so in theory this should work. But in practice this failed, because of the huge number of sg entries, even though the IOMMU driver mapped it all into a dma-contig range.
With a guest-contig buffer allocated in step 1, this problem doesn't exist. But there's technically no reason to require guest-contig memory for xen buffer sharing using grants.
With the commit message improved:
Quoted 487 lines
Signed-off-by Oleksandr Andrushchenko <[email protected]>Suggested-by Daniel Vetter <[email protected]>--- Documentation/gpu/xen-front.rst | 12 ---- drivers/gpu/drm/xen/Kconfig | 13 ---- drivers/gpu/drm/xen/Makefile | 9 +-- drivers/gpu/drm/xen/xen_drm_front.c | 62 +++------------- drivers/gpu/drm/xen/xen_drm_front.h | 42 ++--------- drivers/gpu/drm/xen/xen_drm_front_gem.c | 12 +--- drivers/gpu/drm/xen/xen_drm_front_gem.h | 3 - drivers/gpu/drm/xen/xen_drm_front_gem_cma.c | 79 --------------------- drivers/gpu/drm/xen/xen_drm_front_shbuf.c | 22 ------ drivers/gpu/drm/xen/xen_drm_front_shbuf.h | 8 --- 10 files changed, 21 insertions(+), 241 deletions(-) delete mode 100644 drivers/gpu/drm/xen/xen_drm_front_gem_cma.cDocumentation/gpu/xen-front.rst +0
-12@@ -18,18 +18,6 @@ Buffers allocated by the frontend driver .. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h :doc: Buffers allocated by the frontend driver -With GEM CMA helpers -~~~~~~~~~~~~~~~~~~~~ - -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: With GEM CMA helpers - -Without GEM CMA helpers -~~~~~~~~~~~~~~~~~~~~~~~ - -.. kernel-doc:: drivers/gpu/drm/xen/xen_drm_front.h - :doc: Without GEM CMA helpers - Buffers allocated by the backend --------------------------------drivers/gpu/drm/xen/Kconfig +0
-13@@ -15,16 +15,3 @@ config DRM_XEN_FRONTEND help Choose this option if you want to enable a para-virtualized frontend DRM/KMS driver for Xen guest OSes. - -config DRM_XEN_FRONTEND_CMA - bool "Use DRM CMA to allocate dumb buffers" - depends on DRM_XEN_FRONTEND - select DRM_KMS_CMA_HELPER - select DRM_GEM_CMA_HELPER - help - Use DRM CMA helpers to allocate display buffers. - This is useful for the use-cases when guest driver needs to - share or export buffers to other drivers which only expect - contiguous buffers. - Note: in this mode driver cannot use buffers allocated - by the backend.drivers/gpu/drm/xen/Makefile +2
-7@@ -5,12 +5,7 @@ drm_xen_front-objs := xen_drm_front.o \ xen_drm_front_conn.o \ xen_drm_front_evtchnl.o \ xen_drm_front_shbuf.o \ - xen_drm_front_cfg.o - -ifeq ($(CONFIG_DRM_XEN_FRONTEND_CMA),y) - drm_xen_front-objs += xen_drm_front_gem_cma.o -else - drm_xen_front-objs += xen_drm_front_gem.o -endif + xen_drm_front_cfg.o \ + xen_drm_front_gem.o obj-$(CONFIG_DRM_XEN_FRONTEND) += drm_xen_front.odrivers/gpu/drm/xen/xen_drm_front.c +10
-52@@ -12,7 +12,6 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_crtc_helper.h> #include <drm/drm_gem.h> -#include <drm/drm_gem_cma_helper.h> #include <linux/of_device.h> @@ -167,10 +166,9 @@ int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline,return ret; } -static int be_dbuf_create_int (struct xen_drm_front_info *front_info, +int xen_drm_front_dbuf_create (struct xen_drm_front_info *front_info,u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct page **pages, -struct sg_table *sgt) +u32 bpp,u64 size,struct page **pages) {struct xen_drm_front_evtchnl *evtchnl;struct xen_drm_front_shbuf *shbuf;@@ -187,7 +185,6 @@ static int be_dbuf_create_int(struct xen_drm_front_info *front_info, buf_cfg.xb_dev = front_info->xb_dev; buf_cfg.pages = pages; buf_cfg.size = size; - buf_cfg.sgt = sgt; buf_cfg.be_alloc = front_info->cfg.be_alloc; shbuf =xen_drm_front_shbuf_alloc (&buf_cfg);@@ -237,22 +234,6 @@ static int be_dbuf_create_int(struct xen_drm_front_info *front_info,return ret; } -int xen_drm_front_dbuf_create_from_sgt (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct sg_table *sgt) -{ -return be_dbuf_create_int (front_info, dbuf_cookie, width, height, - bpp, size,NULL , sgt); -} - -int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct page **pages) -{ -return be_dbuf_create_int (front_info, dbuf_cookie, width, height, - bpp, size, pages,NULL ); -} -static int xen_drm_front_dbuf_destroy (struct xen_drm_front_info *front_info,u64 dbuf_cookie) {@@ -434,24 +415,11 @@ static int xen_drm_drv_dumb_create(struct drm_file *filp, goto fail; } -/* -* In case of CONFIG_DRM_XEN_FRONTEND_CMA gem_obj is constructed -* via DRM CMA helpers and doesn't have ->pages allocated -* (xendrm_gem_get_pages will return NULL), but instead can provide -* sg table -*/ -if (xen_drm_front_gem_get_pages (obj)) - ret =xen_drm_front_dbuf_create_from_pages (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (obj), - args->width, args->height, args->bpp, - args->size, -xen_drm_front_gem_get_pages (obj)); -else - ret =xen_drm_front_dbuf_create_from_sgt (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (obj), - args->width, args->height, args->bpp, - args->size, -xen_drm_front_gem_get_sg_table (obj)); + ret =xen_drm_front_dbuf_create (drm_info->front_info, +xen_drm_front_dbuf_to_cookie (obj), + args->width, args->height, args->bpp, + args->size, +xen_drm_front_gem_get_pages (obj));if (ret) goto fail_backend;@@ -523,11 +491,7 @@ static const struct file_operations xen_drm_dev_fops = { .poll = drm_poll, .read = drm_read, .llseek = no_llseek, -#ifdef CONFIG_DRM_XEN_FRONTEND_CMA - .mmap = drm_gem_cma_mmap, -#else .mmap = xen_drm_front_gem_mmap, -#endif };static const struct vm_operations_struct xen_drm_drv_vm_ops = {@@ -547,6 +511,9 @@ static struct drm_driver xen_drm_driver = { .gem_prime_export = drm_gem_prime_export, .gem_prime_import_sg_table = xen_drm_front_gem_import_sg_table, .gem_prime_get_sg_table = xen_drm_front_gem_get_sg_table, + .gem_prime_vmap = xen_drm_front_gem_prime_vmap, + .gem_prime_vunmap = xen_drm_front_gem_prime_vunmap, + .gem_prime_mmap = xen_drm_front_gem_prime_mmap, .dumb_create = xen_drm_drv_dumb_create, .fops = &xen_drm_dev_fops, .name = "xendrm-du",@@ -555,15 +522,6 @@ static struct drm_driver xen_drm_driver = { .major = 1, .minor = 0, -#ifdef CONFIG_DRM_XEN_FRONTEND_CMA - .gem_prime_vmap = drm_gem_cma_prime_vmap, - .gem_prime_vunmap = drm_gem_cma_prime_vunmap, - .gem_prime_mmap = drm_gem_cma_prime_mmap, -#else - .gem_prime_vmap = xen_drm_front_gem_prime_vmap, - .gem_prime_vunmap = xen_drm_front_gem_prime_vunmap, - .gem_prime_mmap = xen_drm_front_gem_prime_mmap, -#endif };static int xen_drm_drv_init (struct xen_drm_front_info *front_info)drivers/gpu/drm/xen/xen_drm_front.h +6
-36@@ -23,40 +23,14 @@* * Depending on the requirements for the para-virtualized environment, namely * requirements dictated by the accompanying DRM/(v)GPU drivers running in both -* host and guest environments, number of operating modes of para-virtualized -* display driver are supported: -* -* - display buffers can be allocated by either frontend driver or backend -* - display buffers can be allocated to be contiguous in memory or not -* -* Note! Frontend driver itself has no dependency on contiguous memory for -* its operation. +* host and guest environments, display buffers can be allocated by either +* frontend driver or backend. */ /** * DOC: Buffers allocated by the frontend driver * -* The below modes of operation are configured at compile-time via -* frontend driver's kernel configuration: -*/ - -/** -* DOC: With GEM CMA helpers -* -* This use-case is useful when used with accompanying DRM/vGPU driver in -* guest domain which was designed to only work with contiguous buffers, -* e.g. DRM driver based on GEM CMA helpers: such drivers can only import -* contiguous PRIME buffers, thus requiring frontend driver to provide -* such. In order to implement this mode of operation para-virtualized -* frontend driver can be configured to use GEM CMA helpers. -*/ - -/** -* DOC: Without GEM CMA helpers -* -* If accompanying drivers can cope with non-contiguous memory then, to -* lower pressure on CMA subsystem of the kernel, driver can allocate -* buffers from system memory. +* In this mode of operation driver allocates buffers from system memory. * * Note! If used with accompanying DRM/(v)GPU drivers this mode of operation * may require IOMMU support on the platform, so accompanying DRM/vGPU @@ -164,13 +138,9 @@ int xen_drm_front_mode_set(struct xen_drm_front_drm_pipeline *pipeline, u32 x, u32 y, u32 width, u32 height, u32 bpp, u64 fb_cookie); -int xen_drm_front_dbuf_create_from_sgt (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct sg_table *sgt); - -int xen_drm_front_dbuf_create_from_pages (struct xen_drm_front_info *front_info, -u64 dbuf_cookie,u32 width,u32 height, -u32 bpp,u64 size,struct page **pages); +int xen_drm_front_dbuf_create (struct xen_drm_front_info *front_info, +u64 dbuf_cookie,u32 width,u32 height, +u32 bpp,u64 size,struct page **pages); int xen_drm_front_fb_attach(struct xen_drm_front_info *front_info, u64 dbuf_cookie, u64 fb_cookie, u32 width,drivers/gpu/drm/xen/xen_drm_front_gem.c +3
-9@@ -210,15 +210,9 @@ xen_drm_front_gem_import_sg_table(struct drm_device *dev,if (ret <0 )return ERR_PTR (ret); -/* -* N.B. Although we have an API to create display buffer from sgt -* we use pages API, because we still need those for GEM handling, -* e.g. for mapping etc. -*/ - ret =xen_drm_front_dbuf_create_from_pages (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (&xen_obj->base), -0 ,0 ,0 , size, - xen_obj->pages); + ret =xen_drm_front_dbuf_create (drm_info->front_info, +xen_drm_front_dbuf_to_cookie (&xen_obj->base), +0 ,0 ,0 , size, xen_obj->pages);if (ret <0 )return ERR_PTR (ret);drivers/gpu/drm/xen/xen_drm_front_gem.h +0
-3@@ -27,8 +27,6 @@ struct page **xen_drm_front_gem_get_pages(struct drm_gem_object *obj);void xen_drm_front_gem_free_object_unlocked (struct drm_gem_object *gem_obj); -#ifndef CONFIG_DRM_XEN_FRONTEND_CMA -int xen_drm_front_gem_mmap (struct file *filp,struct vm_area_struct *vma);void *xen_drm_front_gem_prime_vmap (struct drm_gem_object *gem_obj);@@ -38,6 +36,5 @@ void xen_drm_front_gem_prime_vunmap(struct drm_gem_object *gem_obj,int xen_drm_front_gem_prime_mmap (struct drm_gem_object *gem_obj,struct vm_area_struct *vma); -#endif #endif /* __XEN_DRM_FRONT_GEM_H */ drivers/gpu/drm/xen/xen_drm_front_gem_cma.c deleted +0
-79@@ -1,79 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 OR MIT - -/* -* Xen para-virtual DRM device -* -* Copyright (C) 2016-2018 EPAM Systems Inc. -* -* Author: Oleksandr Andrushchenko <[email protected]> -*/ - -#include <drm/drmP.h> -#include <drm/drm_gem.h> -#include <drm/drm_fb_cma_helper.h> -#include <drm/drm_gem_cma_helper.h> - -#include "xen_drm_front.h" -#include "xen_drm_front_gem.h" - -struct drm_gem_object * -xen_drm_front_gem_import_sg_table (struct drm_device *dev, -struct dma_buf_attachment *attach, -struct sg_table *sgt) -{ -struct xen_drm_front_drm_info *drm_info = dev->dev_private; -struct drm_gem_object *gem_obj; -struct drm_gem_cma_object *cma_obj; -int ret; - - gem_obj =drm_gem_cma_prime_import_sg_table (dev, attach, sgt); -if (IS_ERR_OR_NULL (gem_obj)) -return gem_obj; - - cma_obj =to_drm_gem_cma_obj (gem_obj); - - ret =xen_drm_front_dbuf_create_from_sgt (drm_info->front_info, -xen_drm_front_dbuf_to_cookie (gem_obj), -0 ,0 ,0 , gem_obj->size, -drm_gem_cma_prime_get_sg_table (gem_obj)); -if (ret <0 ) -return ERR_PTR (ret); - -DRM_DEBUG ("Imported CMA buffer of size %zu\n" , gem_obj->size); - -return gem_obj; -} - -struct sg_table *xen_drm_front_gem_get_sg_table (struct drm_gem_object *gem_obj) -{ -return drm_gem_cma_prime_get_sg_table (gem_obj); -} - -struct drm_gem_object *xen_drm_front_gem_create (struct drm_device *dev, -size_t size) -{ -struct xen_drm_front_drm_info *drm_info = dev->dev_private; -struct drm_gem_cma_object *cma_obj; - -if (drm_info->front_info->cfg.be_alloc) { -/* This use-case is not yet supported and probably won't be */ -DRM_ERROR ("Backend allocated buffers and CMA helpers are not supported at the same time\n" ); -return ERR_PTR (-EINVAL ); - } - - cma_obj =drm_gem_cma_create (dev, size); -if (IS_ERR_OR_NULL (cma_obj)) -return ERR_CAST (cma_obj); - -return &cma_obj->base; -} - -void xen_drm_front_gem_free_object_unlocked (struct drm_gem_object *gem_obj) -{ -drm_gem_cma_free_object (gem_obj); -} - -struct page **xen_drm_front_gem_get_pages (struct drm_gem_object *gem_obj) -{ -return NULL ; -}drivers/gpu/drm/xen/xen_drm_front_shbuf.c +0
-22@@ -89,10 +89,6 @@ void xen_drm_front_shbuf_free(struct xen_drm_front_shbuf *buf) }kfree (buf->grefs);kfree (buf->directory); -if (buf->sgt) { -sg_free_table (buf->sgt); -kvfree (buf->pages); - }kfree (buf); }@@ -350,17 +346,6 @@ static int grant_references(struct xen_drm_front_shbuf *buf)static int alloc_storage (struct xen_drm_front_shbuf *buf) { -if (buf->sgt) { - buf->pages =kvmalloc_array (buf->num_pages, -sizeof (struct page *),GFP_KERNEL ); -if (!buf->pages) -return -ENOMEM ; - -if (drm_prime_sg_to_page_addr_arrays (buf->sgt, buf->pages, -NULL , buf->num_pages) <0 ) -return -EINVAL ; - } - buf->grefs =kcalloc (buf->num_grefs,sizeof (*buf->grefs),GFP_KERNEL );if (!buf->grefs)return -ENOMEM ;@@ -396,12 +381,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg)struct xen_drm_front_shbuf *buf;int ret; -/* either pages or sgt, not both */ -if (unlikely (cfg->pages && cfg->sgt)) { -DRM_ERROR ("Cannot handle buffer allocation with both pages and sg table provided\n" ); -return NULL ; - } - buf =kzalloc (sizeof (*buf),GFP_KERNEL );if (!buf)return NULL ;@@ -413,7 +392,6 @@ xen_drm_front_shbuf_alloc(struct xen_drm_front_shbuf_cfg *cfg) buf->xb_dev = cfg->xb_dev; buf->num_pages =DIV_ROUND_UP (cfg->size,PAGE_SIZE ); - buf->sgt = cfg->sgt; buf->pages = cfg->pages; buf->ops->calc_num_grefs (buf);drivers/gpu/drm/xen/xen_drm_front_shbuf.h +0
-8@@ -29,16 +29,9 @@ struct xen_drm_front_shbuf {grant_ref_t *grefs;unsigned char *directory; -/* -* there are 2 ways to provide backing storage for this shared buffer: -* either pages or sgt. if buffer created from sgt then we own -* the pages and must free those ourselves on closure -*/ int num_pages;struct page **pages; -struct sg_table *sgt; -struct xenbus_device *xb_dev;/* these are the ops used internally depending on be_alloc mode */ @@ -52,7 +45,6 @@ struct xen_drm_front_shbuf_cfg {struct xenbus_device *xb_dev;size_t size;struct page **pages; -struct sg_table *sgt;bool be_alloc; };Signature · 6 lines
2.17.0 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 8 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel