All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: Re: [RFC PATCH 3/5] drm/ttm: Use drm_memcpy_from_wc for TTM bo moves
Date: Fri, 21 May 2021 10:10:37 +0200	[thread overview]
Message-ID: <f917a62f-0552-e9e2-17d3-8f16c713fa8c@amd.com> (raw)
In-Reply-To: <20210520150947.803891-4-thomas.hellstrom@linux.intel.com>

Am 20.05.21 um 17:09 schrieb Thomas Hellström:
> Use fast wc memcpy for reading out of wc memory for TTM bo moves.
>
> Cc: Dave Airlie <airlied@gmail.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>

Oh, yes I really wanted to have that in TTM for quite some time.

But I'm wondering if we shouldn't fix the memremap stuff first.

Christian.

> ---
>   drivers/gpu/drm/ttm/ttm_bo_util.c | 18 +++++++++++++++++-
>   1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index bad9b16e96ba..919ee03f7eb3 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -31,6 +31,7 @@
>   
>   #include <drm/ttm/ttm_bo_driver.h>
>   #include <drm/ttm/ttm_placement.h>
> +#include <drm/drm_memcpy.h>
>   #include <drm/drm_vma_manager.h>
>   #include <linux/dma-buf-map.h>
>   #include <linux/io.h>
> @@ -185,6 +186,7 @@ void ttm_move_memcpy(struct ttm_buffer_object *bo,
>   	struct ttm_resource *old_mem = &bo->mem;
>   	struct ttm_resource_manager *old_man = ttm_manager_type(bdev, old_mem->mem_type);
>   	struct dma_buf_map old_map, new_map;
> +	bool wc_memcpy;
>   	pgoff_t i;
>   
>   	/* Single TTM move. NOP */
> @@ -208,11 +210,25 @@ void ttm_move_memcpy(struct ttm_buffer_object *bo,
>   		return;
>   	}
>   
> +	wc_memcpy = ((!old_man->use_tt || bo->ttm->caching != ttm_cached) &&
> +		     drm_has_memcpy_from_wc());
> +
> +	/*
> +	 * We use some nasty aliasing for drm_memcpy_from_wc, but assuming
> +	 * that we can move to memremapping in the not too distant future,
> +	 * reduce the fragility for now with a build assert.
> +	 */
> +	BUILD_BUG_ON(offsetof(typeof(old_map), vaddr) !=
> +		     offsetof(typeof(old_map), vaddr_iomem));
> +
>   	for (i = 0; i < new_mem->num_pages; ++i) {
>   		new_iter->ops->kmap_local(new_iter, &new_map, i);
>   		old_iter->ops->kmap_local(old_iter, &old_map, i);
>   
> -		if (!old_map.is_iomem && !new_map.is_iomem) {
> +		if (wc_memcpy) {
> +			drm_memcpy_from_wc(new_map.vaddr, old_map.vaddr,
> +					   PAGE_SIZE);
> +		} else if (!old_map.is_iomem && !new_map.is_iomem) {
>   			memcpy(new_map.vaddr, old_map.vaddr, PAGE_SIZE);
>   		} else if (!old_map.is_iomem) {
>   			dma_buf_map_memcpy_to(&new_map, old_map.vaddr,


WARNING: multiple messages have this Message-ID (diff)
From: "Christian König" <christian.koenig@amd.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
	intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: Re: [Intel-gfx] [RFC PATCH 3/5] drm/ttm: Use drm_memcpy_from_wc for TTM bo moves
Date: Fri, 21 May 2021 10:10:37 +0200	[thread overview]
Message-ID: <f917a62f-0552-e9e2-17d3-8f16c713fa8c@amd.com> (raw)
In-Reply-To: <20210520150947.803891-4-thomas.hellstrom@linux.intel.com>

Am 20.05.21 um 17:09 schrieb Thomas Hellström:
> Use fast wc memcpy for reading out of wc memory for TTM bo moves.
>
> Cc: Dave Airlie <airlied@gmail.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>

Oh, yes I really wanted to have that in TTM for quite some time.

But I'm wondering if we shouldn't fix the memremap stuff first.

Christian.

> ---
>   drivers/gpu/drm/ttm/ttm_bo_util.c | 18 +++++++++++++++++-
>   1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
> index bad9b16e96ba..919ee03f7eb3 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo_util.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
> @@ -31,6 +31,7 @@
>   
>   #include <drm/ttm/ttm_bo_driver.h>
>   #include <drm/ttm/ttm_placement.h>
> +#include <drm/drm_memcpy.h>
>   #include <drm/drm_vma_manager.h>
>   #include <linux/dma-buf-map.h>
>   #include <linux/io.h>
> @@ -185,6 +186,7 @@ void ttm_move_memcpy(struct ttm_buffer_object *bo,
>   	struct ttm_resource *old_mem = &bo->mem;
>   	struct ttm_resource_manager *old_man = ttm_manager_type(bdev, old_mem->mem_type);
>   	struct dma_buf_map old_map, new_map;
> +	bool wc_memcpy;
>   	pgoff_t i;
>   
>   	/* Single TTM move. NOP */
> @@ -208,11 +210,25 @@ void ttm_move_memcpy(struct ttm_buffer_object *bo,
>   		return;
>   	}
>   
> +	wc_memcpy = ((!old_man->use_tt || bo->ttm->caching != ttm_cached) &&
> +		     drm_has_memcpy_from_wc());
> +
> +	/*
> +	 * We use some nasty aliasing for drm_memcpy_from_wc, but assuming
> +	 * that we can move to memremapping in the not too distant future,
> +	 * reduce the fragility for now with a build assert.
> +	 */
> +	BUILD_BUG_ON(offsetof(typeof(old_map), vaddr) !=
> +		     offsetof(typeof(old_map), vaddr_iomem));
> +
>   	for (i = 0; i < new_mem->num_pages; ++i) {
>   		new_iter->ops->kmap_local(new_iter, &new_map, i);
>   		old_iter->ops->kmap_local(old_iter, &old_map, i);
>   
> -		if (!old_map.is_iomem && !new_map.is_iomem) {
> +		if (wc_memcpy) {
> +			drm_memcpy_from_wc(new_map.vaddr, old_map.vaddr,
> +					   PAGE_SIZE);
> +		} else if (!old_map.is_iomem && !new_map.is_iomem) {
>   			memcpy(new_map.vaddr, old_map.vaddr, PAGE_SIZE);
>   		} else if (!old_map.is_iomem) {
>   			dma_buf_map_memcpy_to(&new_map, old_map.vaddr,

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2021-05-21  8:10 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-20 15:09 [RFC PATCH 0/5] Core TTM changes for i915 TTM enabling Thomas Hellström
2021-05-20 15:09 ` [Intel-gfx] " Thomas Hellström
2021-05-20 15:09 ` [RFC PATCH 1/5] drm/ttm: Add a generic TTM memcpy move for page-based iomem Thomas Hellström
2021-05-20 15:09   ` [Intel-gfx] " Thomas Hellström
2021-05-21  8:08   ` Christian König
2021-05-21  8:08     ` [Intel-gfx] " Christian König
2021-05-27  5:07   ` [drm/ttm] 0c13ca6d7f: WARNING:at_drivers/gpu/drm/drm_fb_helper.c:#drm_fb_helper_damage_work kernel test robot
2021-05-27  5:07     ` kernel test robot
2021-05-27  5:07     ` [Intel-gfx] " kernel test robot
2021-05-27  5:07     ` kernel test robot
2021-05-20 15:09 ` [RFC PATCH 2/5] drm, drm/i915: Move the memcpy_from_wc functionality to core drm Thomas Hellström
2021-05-20 15:09   ` [Intel-gfx] " Thomas Hellström
2021-05-20 15:09 ` [RFC PATCH 3/5] drm/ttm: Use drm_memcpy_from_wc for TTM bo moves Thomas Hellström
2021-05-20 15:09   ` [Intel-gfx] " Thomas Hellström
2021-05-21  8:10   ` Christian König [this message]
2021-05-21  8:10     ` Christian König
2021-05-21  8:30     ` Thomas Hellström
2021-05-21  8:30       ` [Intel-gfx] " Thomas Hellström
2021-05-20 15:09 ` [RFC PATCH 4/5] drm/ttm: Document and optimize ttm_bo_pipeline_gutting() Thomas Hellström
2021-05-20 15:09   ` [Intel-gfx] " Thomas Hellström
2021-05-21  8:21   ` Christian König
2021-05-21  8:21     ` [Intel-gfx] " Christian König
2021-05-21  8:43     ` Thomas Hellström
2021-05-21  8:43       ` [Intel-gfx] " Thomas Hellström
2021-05-20 15:09 ` [RFC PATCH 5/5] drm/ttm, drm/amdgpu: Allow the driver some control over swapping Thomas Hellström
2021-05-20 15:09   ` [Intel-gfx] " Thomas Hellström
2021-05-20 15:17   ` Thomas Hellström
2021-05-20 15:17     ` [Intel-gfx] " Thomas Hellström
2021-05-20 15:20 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for Core TTM changes for i915 TTM enabling Patchwork
2021-05-20 15:21 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2021-05-20 15:51 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2021-05-21 23:14 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

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=f917a62f-0552-e9e2-17d3-8f16c713fa8c@amd.com \
    --to=christian.koenig@amd.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=thomas.hellstrom@linux.intel.com \
    /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.