Re: [Xen-devel] [PATCH] drm/xen-front: Remove CMA support

2018-04-18 Thread Oleksandr Andrushchenko

On 04/17/2018 12:08 PM, Oleksandr Andrushchenko wrote:

On 04/17/2018 12:04 PM, Daniel Vetter wrote:

On Tue, Apr 17, 2018 at 10:40:12AM +0300, Oleksandr Andrushchenko wrote:

From: Oleksandr Andrushchenko 

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:

ok, if you don't mind then I'll use your commit message entirely

 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 
 Date:   Fri Nov 10 13:33:10 2017 +
  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:

Acked-by: Daniel Vetter 

Thank you,
I'll wait for a day and apply to drm-misc-next if this is ok

applied to drm-misc-next


Signed-off-by: Oleksandr Andrushchenko 


Suggested-by: Daniel Vetter 
---
  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

diff --git a/Documentation/gpu/xen-front.rst 
b/Documentation/gpu/xen-front.rst

index 009d942386c5..d988da7d1983 100644
--- a/Documentation/gpu/xen-front.rst
+++ b/Documentation/gpu/xen-front.rst
@@ -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
  
  diff --git a/drivers/gpu/drm/xen/Kconfig 
b/drivers/gpu/drm/xen/Kconfig

index 4f4abc91f3b6..4cca160782ab 100644
--- a/drivers/gpu/drm/xen/Kconfig
+++ b/drivers/gpu/drm/xen/Kconfig
@@ -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.
diff --git a/drivers/gpu/drm/xen/Makefile 
b/drivers/gpu/drm/xen/Makefile

index 352730dc6c13..712afff5ffc3 100644
--- a/drivers/gpu/drm/xen/Makefile
+++ b/drivers/gpu/drm/xen/Makefile
@@ -5,12 +5,7 @@ drm_xen_front-objs := xen_drm_front.o \
    xen_drm_front_conn.o \
    xen_drm_front_evtchnl.o \
    

Re: [Xen-devel] [PATCH] drm/xen-front: Remove CMA support

2018-04-17 Thread Oleksandr Andrushchenko

On 04/17/2018 12:04 PM, Daniel Vetter wrote:

On Tue, Apr 17, 2018 at 10:40:12AM +0300, Oleksandr Andrushchenko wrote:

From: Oleksandr Andrushchenko 

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:

ok, if you don't mind then I'll use your commit message entirely

 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 
 Date:   Fri Nov 10 13:33:10 2017 +
 
 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:

Acked-by: Daniel Vetter 

Thank you,
I'll wait for a day and apply to drm-misc-next if this is ok



Signed-off-by: Oleksandr Andrushchenko 
Suggested-by: Daniel Vetter 
---
  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

diff --git a/Documentation/gpu/xen-front.rst b/Documentation/gpu/xen-front.rst
index 009d942386c5..d988da7d1983 100644
--- a/Documentation/gpu/xen-front.rst
+++ b/Documentation/gpu/xen-front.rst
@@ -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
  
  
diff --git a/drivers/gpu/drm/xen/Kconfig b/drivers/gpu/drm/xen/Kconfig

index 4f4abc91f3b6..4cca160782ab 100644
--- a/drivers/gpu/drm/xen/Kconfig
+++ b/drivers/gpu/drm/xen/Kconfig
@@ -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.
diff --git a/drivers/gpu/drm/xen/Makefile b/drivers/gpu/drm/xen/Makefile
index 352730dc6c13..712afff5ffc3 100644
--- a/drivers/gpu/drm/xen/Makefile
+++ b/drivers/gpu/drm/xen/Makefile
@@ -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 \
- 

Re: [Xen-devel] [PATCH] drm/xen-front: Remove CMA support

2018-04-17 Thread Daniel Vetter
On Tue, Apr 17, 2018 at 10:40:12AM +0300, Oleksandr Andrushchenko wrote:
> From: Oleksandr Andrushchenko 
> 
> 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 
Date:   Fri Nov 10 13:33:10 2017 +

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:

Acked-by: Daniel Vetter 


> 
> Signed-off-by: Oleksandr Andrushchenko 
> Suggested-by: Daniel Vetter 
> ---
>  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
> 
> diff --git a/Documentation/gpu/xen-front.rst b/Documentation/gpu/xen-front.rst
> index 009d942386c5..d988da7d1983 100644
> --- a/Documentation/gpu/xen-front.rst
> +++ b/Documentation/gpu/xen-front.rst
> @@ -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
>  
>  
> diff --git a/drivers/gpu/drm/xen/Kconfig b/drivers/gpu/drm/xen/Kconfig
> index 4f4abc91f3b6..4cca160782ab 100644
> --- a/drivers/gpu/drm/xen/Kconfig
> +++ b/drivers/gpu/drm/xen/Kconfig
> @@ -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.
> diff --git a/drivers/gpu/drm/xen/Makefile b/drivers/gpu/drm/xen/Makefile
> index 352730dc6c13..712afff5ffc3 100644
> --- a/drivers/gpu/drm/xen/Makefile
> +++ b/drivers/gpu/drm/xen/Makefile
> @@ -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
> 

[Xen-devel] [PATCH] drm/xen-front: Remove CMA support

2018-04-17 Thread Oleksandr Andrushchenko
From: Oleksandr Andrushchenko 

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.

Signed-off-by: Oleksandr Andrushchenko 
Suggested-by: Daniel Vetter 
---
 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

diff --git a/Documentation/gpu/xen-front.rst b/Documentation/gpu/xen-front.rst
index 009d942386c5..d988da7d1983 100644
--- a/Documentation/gpu/xen-front.rst
+++ b/Documentation/gpu/xen-front.rst
@@ -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
 
 
diff --git a/drivers/gpu/drm/xen/Kconfig b/drivers/gpu/drm/xen/Kconfig
index 4f4abc91f3b6..4cca160782ab 100644
--- a/drivers/gpu/drm/xen/Kconfig
+++ b/drivers/gpu/drm/xen/Kconfig
@@ -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.
diff --git a/drivers/gpu/drm/xen/Makefile b/drivers/gpu/drm/xen/Makefile
index 352730dc6c13..712afff5ffc3 100644
--- a/drivers/gpu/drm/xen/Makefile
+++ b/drivers/gpu/drm/xen/Makefile
@@ -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
diff --git a/drivers/gpu/drm/xen/xen_drm_front.c 
b/drivers/gpu/drm/xen/xen_drm_front.c
index 4a08b77f1c9e..1b0ea9ac330e 100644
--- a/drivers/gpu/drm/xen/xen_drm_front.c
+++ b/drivers/gpu/drm/xen/xen_drm_front.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #include 
 
@@ -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(_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