Re: [PATCH v2 1/2] drm: allow limiting the scatter list size.

2020-09-07 Thread Daniel Vetter
On Mon, Sep 7, 2020 at 8:39 AM Gerd Hoffmann  wrote:
>
> > > +   /**
> > > +* @max_segment:
> > > +*
> > > +* Max size for scatter list segments.  When unset the default
> > > +* (SCATTERLIST_MAX_SEGMENT) is used.
> > > +*/
> > > +   size_t max_segment;
> >
> > Is there no better place for this then "at the bottom"? drm_device is a
> > huge structure, piling stuff up randomly doesn't make it better :-)
>
> Moved next to the other gem fields for now (v3 posted).
>
> > I think ideally we'd have a gem substruct like we have on the modeset side
> > at least.
>
> Phew, that'll be quite some churn in the tree.  And there aren't that many
> gem-related fields in struct drm_device.
>
> So you are looking for something like below (header changes only)?

Hm yeah it's a lot less than I thought. And yes I think that would be neat.
-Daniel

>
> take care,
>   Gerd
>
> diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
> index c455ef404ca6..950167ede98a 100644
> --- a/include/drm/drm_device.h
> +++ b/include/drm/drm_device.h
> @@ -299,22 +299,8 @@ struct drm_device {
> /** @mode_config: Current mode config */
> struct drm_mode_config mode_config;
>
> -   /** @object_name_lock: GEM information */
> -   struct mutex object_name_lock;
> -
> -   /** @object_name_idr: GEM information */
> -   struct idr object_name_idr;
> -
> -   /** @vma_offset_manager: GEM information */
> -   struct drm_vma_offset_manager *vma_offset_manager;
> -
> -   /**
> -* @max_segment:
> -*
> -* Max size for scatter list segments for GEM objects.  When
> -* unset the default (SCATTERLIST_MAX_SEGMENT) is used.
> -*/
> -   size_t max_segment;
> +   /** @gem_config: Current GEM config */
> +   struct drm_gem_config gem_config;
>
> /** @vram_mm: VRAM MM memory manager */
> struct drm_vram_mm *vram_mm;
> diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
> index 337a48321705..74129fb29fb8 100644
> --- a/include/drm/drm_gem.h
> +++ b/include/drm/drm_gem.h
> @@ -39,6 +39,25 @@
>
>  #include 
>
> +struct drm_gem_config {
> +   /** @object_name_lock: GEM information */
> +   struct mutex object_name_lock;
> +
> +   /** @object_name_idr: GEM information */
> +   struct idr object_name_idr;
> +
> +   /** @vma_offset_manager: GEM information */
> +   struct drm_vma_offset_manager *vma_offset_manager;
> +
> +   /**
> +* @max_segment:
> +*
> +* Max size for scatter list segments for GEM objects.  When
> +* unset the default (SCATTERLIST_MAX_SEGMENT) is used.
> +*/
> +   size_t max_segment;
> +};
> +
>  struct drm_gem_object;
>
>  /**
>
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel



-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 1/2] drm: allow limiting the scatter list size.

2020-09-07 Thread Gerd Hoffmann
> > +   /**
> > +* @max_segment:
> > +*
> > +* Max size for scatter list segments.  When unset the default
> > +* (SCATTERLIST_MAX_SEGMENT) is used.
> > +*/
> > +   size_t max_segment;
> 
> Is there no better place for this then "at the bottom"? drm_device is a
> huge structure, piling stuff up randomly doesn't make it better :-)

Moved next to the other gem fields for now (v3 posted).

> I think ideally we'd have a gem substruct like we have on the modeset side
> at least.

Phew, that'll be quite some churn in the tree.  And there aren't that many
gem-related fields in struct drm_device.

So you are looking for something like below (header changes only)?

take care,
  Gerd

diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
index c455ef404ca6..950167ede98a 100644
--- a/include/drm/drm_device.h
+++ b/include/drm/drm_device.h
@@ -299,22 +299,8 @@ struct drm_device {
/** @mode_config: Current mode config */
struct drm_mode_config mode_config;
 
-   /** @object_name_lock: GEM information */
-   struct mutex object_name_lock;
-
-   /** @object_name_idr: GEM information */
-   struct idr object_name_idr;
-
-   /** @vma_offset_manager: GEM information */
-   struct drm_vma_offset_manager *vma_offset_manager;
-
-   /**
-* @max_segment:
-*
-* Max size for scatter list segments for GEM objects.  When
-* unset the default (SCATTERLIST_MAX_SEGMENT) is used.
-*/
-   size_t max_segment;
+   /** @gem_config: Current GEM config */
+   struct drm_gem_config gem_config;
 
/** @vram_mm: VRAM MM memory manager */
struct drm_vram_mm *vram_mm;
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 337a48321705..74129fb29fb8 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -39,6 +39,25 @@
 
 #include 
 
+struct drm_gem_config {
+   /** @object_name_lock: GEM information */
+   struct mutex object_name_lock;
+
+   /** @object_name_idr: GEM information */
+   struct idr object_name_idr;
+
+   /** @vma_offset_manager: GEM information */
+   struct drm_vma_offset_manager *vma_offset_manager;
+
+   /**
+* @max_segment:
+*
+* Max size for scatter list segments for GEM objects.  When
+* unset the default (SCATTERLIST_MAX_SEGMENT) is used.
+*/
+   size_t max_segment;
+};
+
 struct drm_gem_object;
 
 /**

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 1/2] drm: allow limiting the scatter list size.

2020-09-01 Thread Daniel Vetter
On Tue, Aug 18, 2020 at 11:20:16AM +0200, Gerd Hoffmann wrote:
> Add max_segment argument to drm_prime_pages_to_sg().  When set pass it
> through to the __sg_alloc_table_from_pages() call, otherwise use
> SCATTERLIST_MAX_SEGMENT.
> 
> Also add max_segment field to drm driver and pass it to
> drm_prime_pages_to_sg() calls in drivers and helpers.
> 
> v2: place max_segment in drm driver not gem object.
> 
> Signed-off-by: Gerd Hoffmann 
> ---
>  include/drm/drm_device.h|  8 
>  include/drm/drm_prime.h |  3 ++-
>  drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c |  3 ++-
>  drivers/gpu/drm/drm_gem_shmem_helper.c  |  3 ++-
>  drivers/gpu/drm/drm_prime.c | 10 +++---
>  drivers/gpu/drm/etnaviv/etnaviv_gem.c   |  3 ++-
>  drivers/gpu/drm/etnaviv/etnaviv_gem_prime.c |  3 ++-
>  drivers/gpu/drm/msm/msm_gem.c   |  3 ++-
>  drivers/gpu/drm/msm/msm_gem_prime.c |  3 ++-
>  drivers/gpu/drm/nouveau/nouveau_prime.c |  3 ++-
>  drivers/gpu/drm/radeon/radeon_prime.c   |  3 ++-
>  drivers/gpu/drm/rockchip/rockchip_drm_gem.c |  6 --
>  drivers/gpu/drm/tegra/gem.c |  3 ++-
>  drivers/gpu/drm/vgem/vgem_drv.c |  3 ++-
>  drivers/gpu/drm/xen/xen_drm_front_gem.c |  3 ++-
>  15 files changed, 43 insertions(+), 17 deletions(-)
> 
> diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h
> index 0988351d743c..47cb547a8115 100644
> --- a/include/drm/drm_device.h
> +++ b/include/drm/drm_device.h
> @@ -329,6 +329,14 @@ struct drm_device {
>*/
>   struct drm_fb_helper *fb_helper;
>  
> + /**
> +  * @max_segment:
> +  *
> +  * Max size for scatter list segments.  When unset the default
> +  * (SCATTERLIST_MAX_SEGMENT) is used.
> +  */
> + size_t max_segment;

Is there no better place for this then "at the bottom"? drm_device is a
huge structure, piling stuff up randomly doesn't make it better :-)

I think ideally we'd have a gem substruct like we have on the modeset side
at least.
-Daniel

> +
>   /* Everything below here is for legacy driver, never use! */
>   /* private: */
>  #if IS_ENABLED(CONFIG_DRM_LEGACY)
> diff --git a/include/drm/drm_prime.h b/include/drm/drm_prime.h
> index 9af7422b44cf..2c3689435cb4 100644
> --- a/include/drm/drm_prime.h
> +++ b/include/drm/drm_prime.h
> @@ -88,7 +88,8 @@ void drm_gem_dmabuf_vunmap(struct dma_buf *dma_buf, void 
> *vaddr);
>  int drm_gem_prime_mmap(struct drm_gem_object *obj, struct vm_area_struct 
> *vma);
>  int drm_gem_dmabuf_mmap(struct dma_buf *dma_buf, struct vm_area_struct *vma);
>  
> -struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int 
> nr_pages);
> +struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int 
> nr_pages,
> +size_t max_segment);
>  struct dma_buf *drm_gem_prime_export(struct drm_gem_object *obj,
>int flags);
>  
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> index 519ce4427fce..8f6a647757e7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dma_buf.c
> @@ -303,7 +303,8 @@ static struct sg_table *amdgpu_dma_buf_map(struct 
> dma_buf_attachment *attach,
>   switch (bo->tbo.mem.mem_type) {
>   case TTM_PL_TT:
>   sgt = drm_prime_pages_to_sg(bo->tbo.ttm->pages,
> - bo->tbo.num_pages);
> + bo->tbo.num_pages,
> + obj->dev->max_segment);
>   if (IS_ERR(sgt))
>   return sgt;
>  
> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c 
> b/drivers/gpu/drm/drm_gem_shmem_helper.c
> index 4b7cfbac4daa..8f47b41b0b2f 100644
> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c
> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c
> @@ -656,7 +656,8 @@ struct sg_table *drm_gem_shmem_get_sg_table(struct 
> drm_gem_object *obj)
>  
>   WARN_ON(shmem->base.import_attach);
>  
> - return drm_prime_pages_to_sg(shmem->pages, obj->size >> PAGE_SHIFT);
> + return drm_prime_pages_to_sg(shmem->pages, obj->size >> PAGE_SHIFT,
> +  obj->dev->max_segment);
>  }
>  EXPORT_SYMBOL_GPL(drm_gem_shmem_get_sg_table);
>  
> diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
> index 1693aa7c14b5..27c783fd6633 100644
> --- a/drivers/gpu/drm/drm_prime.c
> +++ b/drivers/gpu/drm/drm_prime.c
> @@ -802,7 +802,8 @@ static const struct dma_buf_ops drm_gem_prime_dmabuf_ops 
> =  {
>   *
>   * This is useful for implementing _gem_object_funcs.get_sg_table.
>   */
> -struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int 
> nr_pages)
> +struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int 
> nr_pages,
> +size_t