All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: amd-gfx@lists.freedesktop.org, airlied@linux.ie,
	maarten.lankhorst@linux.intel.com, mripard@kernel.org,
	dri-devel@lists.freedesktop.org, daniel@ffwll.ch,
	alexander.deucher@amd.com, christian.koenig@amd.com
Subject: Re: [PATCH 2/6] drm: Implement drm_need_swiotlb() in drm_cache.c
Date: Tue, 12 Jan 2021 10:01:30 +0100	[thread overview]
Message-ID: <X/1laqvIEeBKhOHw@phenom.ffwll.local> (raw)
In-Reply-To: <20210112081035.6882-3-tzimmermann@suse.de>

On Tue, Jan 12, 2021 at 09:10:31AM +0100, Thomas Zimmermann wrote:
> The function is declared in drm_cache.h. I also removed the curly
> braces from the for loop to adhere to kernel coding style.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>

s/implement in/move to/ in the subject. Also would be nice to add
kerneldoc while moving (there's not kerneldoc for drm_memory) to avoid the
new warning. With that fixed:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

It's mildly confusing, but in a way drm_cache.c is our "hack around
dma-api layering issues" pile, so fits :-) Maybe we should even make this
the official DOC: kerneldoc intro section for this file ...

Cheers, Daniel

> ---
>  drivers/gpu/drm/drm_cache.c  | 32 ++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/drm_memory.c | 33 ---------------------------------
>  2 files changed, 32 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
> index 0fe3c496002a..49551a7fa22f 100644
> --- a/drivers/gpu/drm/drm_cache.c
> +++ b/drivers/gpu/drm/drm_cache.c
> @@ -30,6 +30,7 @@
>  
>  #include <linux/export.h>
>  #include <linux/highmem.h>
> +#include <xen/xen.h>
>  
>  #include <drm/drm_cache.h>
>  
> @@ -176,3 +177,34 @@ drm_clflush_virt_range(void *addr, unsigned long length)
>  #endif
>  }
>  EXPORT_SYMBOL(drm_clflush_virt_range);
> +
> +bool drm_need_swiotlb(int dma_bits)
> +{
> +	struct resource *tmp;
> +	resource_size_t max_iomem = 0;
> +
> +	/*
> +	 * Xen paravirtual hosts require swiotlb regardless of requested dma
> +	 * transfer size.
> +	 *
> +	 * NOTE: Really, what it requires is use of the dma_alloc_coherent
> +	 *       allocator used in ttm_dma_populate() instead of
> +	 *       ttm_populate_and_map_pages(), which bounce buffers so much in
> +	 *       Xen it leads to swiotlb buffer exhaustion.
> +	 */
> +	if (xen_pv_domain())
> +		return true;
> +
> +	/*
> +	 * Enforce dma_alloc_coherent when memory encryption is active as well
> +	 * for the same reasons as for Xen paravirtual hosts.
> +	 */
> +	if (mem_encrypt_active())
> +		return true;
> +
> +	for (tmp = iomem_resource.child; tmp; tmp = tmp->sibling)
> +		max_iomem = max(max_iomem,  tmp->end);
> +
> +	return max_iomem > ((u64)1 << dma_bits);
> +}
> +EXPORT_SYMBOL(drm_need_swiotlb);
> diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
> index f4f2bffdd5bd..e4f20a2eb6e7 100644
> --- a/drivers/gpu/drm/drm_memory.c
> +++ b/drivers/gpu/drm/drm_memory.c
> @@ -37,7 +37,6 @@
>  #include <linux/highmem.h>
>  #include <linux/pci.h>
>  #include <linux/vmalloc.h>
> -#include <xen/xen.h>
>  
>  #include <drm/drm_agpsupport.h>
>  #include <drm/drm_cache.h>
> @@ -138,35 +137,3 @@ void drm_legacy_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
>  		iounmap(map->handle);
>  }
>  EXPORT_SYMBOL(drm_legacy_ioremapfree);
> -
> -bool drm_need_swiotlb(int dma_bits)
> -{
> -	struct resource *tmp;
> -	resource_size_t max_iomem = 0;
> -
> -	/*
> -	 * Xen paravirtual hosts require swiotlb regardless of requested dma
> -	 * transfer size.
> -	 *
> -	 * NOTE: Really, what it requires is use of the dma_alloc_coherent
> -	 *       allocator used in ttm_dma_populate() instead of
> -	 *       ttm_populate_and_map_pages(), which bounce buffers so much in
> -	 *       Xen it leads to swiotlb buffer exhaustion.
> -	 */
> -	if (xen_pv_domain())
> -		return true;
> -
> -	/*
> -	 * Enforce dma_alloc_coherent when memory encryption is active as well
> -	 * for the same reasons as for Xen paravirtual hosts.
> -	 */
> -	if (mem_encrypt_active())
> -		return true;
> -
> -	for (tmp = iomem_resource.child; tmp; tmp = tmp->sibling) {
> -		max_iomem = max(max_iomem,  tmp->end);
> -	}
> -
> -	return max_iomem > ((u64)1 << dma_bits);
> -}
> -EXPORT_SYMBOL(drm_need_swiotlb);
> -- 
> 2.29.2
> 

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

WARNING: multiple messages have this Message-ID (diff)
From: Daniel Vetter <daniel@ffwll.ch>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: amd-gfx@lists.freedesktop.org, airlied@linux.ie,
	dri-devel@lists.freedesktop.org, alexander.deucher@amd.com,
	christian.koenig@amd.com
Subject: Re: [PATCH 2/6] drm: Implement drm_need_swiotlb() in drm_cache.c
Date: Tue, 12 Jan 2021 10:01:30 +0100	[thread overview]
Message-ID: <X/1laqvIEeBKhOHw@phenom.ffwll.local> (raw)
In-Reply-To: <20210112081035.6882-3-tzimmermann@suse.de>

On Tue, Jan 12, 2021 at 09:10:31AM +0100, Thomas Zimmermann wrote:
> The function is declared in drm_cache.h. I also removed the curly
> braces from the for loop to adhere to kernel coding style.
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>

s/implement in/move to/ in the subject. Also would be nice to add
kerneldoc while moving (there's not kerneldoc for drm_memory) to avoid the
new warning. With that fixed:

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

It's mildly confusing, but in a way drm_cache.c is our "hack around
dma-api layering issues" pile, so fits :-) Maybe we should even make this
the official DOC: kerneldoc intro section for this file ...

Cheers, Daniel

> ---
>  drivers/gpu/drm/drm_cache.c  | 32 ++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/drm_memory.c | 33 ---------------------------------
>  2 files changed, 32 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
> index 0fe3c496002a..49551a7fa22f 100644
> --- a/drivers/gpu/drm/drm_cache.c
> +++ b/drivers/gpu/drm/drm_cache.c
> @@ -30,6 +30,7 @@
>  
>  #include <linux/export.h>
>  #include <linux/highmem.h>
> +#include <xen/xen.h>
>  
>  #include <drm/drm_cache.h>
>  
> @@ -176,3 +177,34 @@ drm_clflush_virt_range(void *addr, unsigned long length)
>  #endif
>  }
>  EXPORT_SYMBOL(drm_clflush_virt_range);
> +
> +bool drm_need_swiotlb(int dma_bits)
> +{
> +	struct resource *tmp;
> +	resource_size_t max_iomem = 0;
> +
> +	/*
> +	 * Xen paravirtual hosts require swiotlb regardless of requested dma
> +	 * transfer size.
> +	 *
> +	 * NOTE: Really, what it requires is use of the dma_alloc_coherent
> +	 *       allocator used in ttm_dma_populate() instead of
> +	 *       ttm_populate_and_map_pages(), which bounce buffers so much in
> +	 *       Xen it leads to swiotlb buffer exhaustion.
> +	 */
> +	if (xen_pv_domain())
> +		return true;
> +
> +	/*
> +	 * Enforce dma_alloc_coherent when memory encryption is active as well
> +	 * for the same reasons as for Xen paravirtual hosts.
> +	 */
> +	if (mem_encrypt_active())
> +		return true;
> +
> +	for (tmp = iomem_resource.child; tmp; tmp = tmp->sibling)
> +		max_iomem = max(max_iomem,  tmp->end);
> +
> +	return max_iomem > ((u64)1 << dma_bits);
> +}
> +EXPORT_SYMBOL(drm_need_swiotlb);
> diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
> index f4f2bffdd5bd..e4f20a2eb6e7 100644
> --- a/drivers/gpu/drm/drm_memory.c
> +++ b/drivers/gpu/drm/drm_memory.c
> @@ -37,7 +37,6 @@
>  #include <linux/highmem.h>
>  #include <linux/pci.h>
>  #include <linux/vmalloc.h>
> -#include <xen/xen.h>
>  
>  #include <drm/drm_agpsupport.h>
>  #include <drm/drm_cache.h>
> @@ -138,35 +137,3 @@ void drm_legacy_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
>  		iounmap(map->handle);
>  }
>  EXPORT_SYMBOL(drm_legacy_ioremapfree);
> -
> -bool drm_need_swiotlb(int dma_bits)
> -{
> -	struct resource *tmp;
> -	resource_size_t max_iomem = 0;
> -
> -	/*
> -	 * Xen paravirtual hosts require swiotlb regardless of requested dma
> -	 * transfer size.
> -	 *
> -	 * NOTE: Really, what it requires is use of the dma_alloc_coherent
> -	 *       allocator used in ttm_dma_populate() instead of
> -	 *       ttm_populate_and_map_pages(), which bounce buffers so much in
> -	 *       Xen it leads to swiotlb buffer exhaustion.
> -	 */
> -	if (xen_pv_domain())
> -		return true;
> -
> -	/*
> -	 * Enforce dma_alloc_coherent when memory encryption is active as well
> -	 * for the same reasons as for Xen paravirtual hosts.
> -	 */
> -	if (mem_encrypt_active())
> -		return true;
> -
> -	for (tmp = iomem_resource.child; tmp; tmp = tmp->sibling) {
> -		max_iomem = max(max_iomem,  tmp->end);
> -	}
> -
> -	return max_iomem > ((u64)1 << dma_bits);
> -}
> -EXPORT_SYMBOL(drm_need_swiotlb);
> -- 
> 2.29.2
> 

-- 
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

  reply	other threads:[~2021-01-12  9:01 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12  8:10 [PATCH 0/6] Move struct drm_device.hose to legacy section Thomas Zimmermann
2021-01-12  8:10 ` Thomas Zimmermann
2021-01-12  8:10 ` [PATCH 1/6] drm: Inline AGP wrappers into their only callers Thomas Zimmermann
2021-01-12  8:10   ` Thomas Zimmermann
2021-01-12  8:59   ` Daniel Vetter
2021-01-12  8:59     ` Daniel Vetter
2021-01-12  9:56     ` Thomas Zimmermann
2021-01-12  9:56       ` Thomas Zimmermann
2021-01-12 14:01       ` Daniel Vetter
2021-01-12 14:01         ` Daniel Vetter
2021-01-12  8:10 ` [PATCH 2/6] drm: Implement drm_need_swiotlb() in drm_cache.c Thomas Zimmermann
2021-01-12  8:10   ` Thomas Zimmermann
2021-01-12  9:01   ` Daniel Vetter [this message]
2021-01-12  9:01     ` Daniel Vetter
2021-01-12  8:10 ` [PATCH 3/6] drm: Build drm_memory.o only for legacy drivers Thomas Zimmermann
2021-01-12  8:10   ` Thomas Zimmermann
2021-01-12  9:02   ` Daniel Vetter
2021-01-12  9:02     ` Daniel Vetter
2021-01-12  8:10 ` [PATCH 4/6] drm: Merge CONFIG_DRM_VM into CONFIG_DRM_LEGACY Thomas Zimmermann
2021-01-12  8:10   ` Thomas Zimmermann
2021-01-12  9:04   ` Daniel Vetter
2021-01-12  9:04     ` Daniel Vetter
2021-01-12  8:10 ` [PATCH 5/6] drm/radeon: Store PCI controller in struct radeon_device.hose Thomas Zimmermann
2021-01-12  8:10   ` Thomas Zimmermann
2021-01-12  8:10 ` [PATCH 6/6] drm: Move struct drm_device.hose to legacy section Thomas Zimmermann
2021-01-12  8:10   ` Thomas Zimmermann
2021-01-12  8:16 ` [PATCH 0/6] " Christian König
2021-01-12  8:16   ` Christian König

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=X/1laqvIEeBKhOHw@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=airlied@linux.ie \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.