[Intel-gfx] [PATCH 2/7] drm: Add drm_memcpy_from_wc() variant which accepts destination address

Lucas De Marchi lucas.demarchi at intel.com
Tue Mar 1 07:55:24 UTC 2022


On Mon, Feb 28, 2022 at 11:48:58PM -0800, Lucas De Marchi wrote:
>On Tue, Feb 22, 2022 at 08:22:01PM +0530, Balasubramani Vivekanandan wrote:
>>Fast copy using non-temporal instructions for x86 currently exists at two
>>locations. One is implemented in i915 driver at i915/i915_memcpy.c and
>>another copy at drm_cache.c. The plan is to remove the duplicate
>>implementation in i915 driver and use the functions from drm_cache.c.
>>
>>A variant of drm_memcpy_from_wc() is added in drm_cache.c which accepts
>>address as argument instead of iosys_map for destination. It is a very
>>common scenario in i915 to copy from a WC memory type, which may be an
>>io memory or a system memory to a destination address pointing to system
>>memory. To avoid the overhead of creating iosys_map type for the
>>destination, new variant is created to accept the address directly.
>>
>>Also a new function is exported in drm_cache.c to find if the fast copy
>>is supported by the platform or not. It is required for i915.
>>
>>Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
>>Cc: Maxime Ripard <mripard at kernel.org>
>>Cc: Thomas Zimmermann <tzimmermann at suse.de>
>>Cc: David Airlie <airlied at linux.ie>
>>Cc: Daniel Vetter <daniel at ffwll.ch>
>>Cc: Thomas Hellstr_m <thomas.hellstrom at linux.intel.com>
>>
>>Signed-off-by: Balasubramani Vivekanandan <balasubramani.vivekanandan at intel.com>
>>---
>>drivers/gpu/drm/drm_cache.c | 54 +++++++++++++++++++++++++++++++++++++
>>include/drm/drm_cache.h     |  3 +++
>>2 files changed, 57 insertions(+)
>>
>>diff --git a/drivers/gpu/drm/drm_cache.c b/drivers/gpu/drm/drm_cache.c
>>index a21c1350eb09..eb0bcd33665e 100644
>>--- a/drivers/gpu/drm/drm_cache.c
>>+++ b/drivers/gpu/drm/drm_cache.c
>>@@ -358,6 +358,54 @@ void drm_memcpy_from_wc(struct iosys_map *dst,
>>}
>>EXPORT_SYMBOL(drm_memcpy_from_wc);
>>
>>+/**
>>+ * drm_memcpy_from_wc_vaddr - Perform the fastest available memcpy from a source
>>+ * that may be WC.
>
> .... to a destination in system memory.
>
>>+ * @dst: The destination pointer
>>+ * @src: The source pointer
>>+ * @len: The size of the area to transfer in bytes
>>+ *
>>+ * Same as drm_memcpy_from_wc except destination is accepted as system memory
>>+ * address. Useful in situations where passing destination address as iosys_map
>>+ * is simply an overhead and can be avoided.
>
>although one could do drm_memcpy_from_wc(IOSYS_MAP_INIT_VADDR(addr), ...

... Just making you don't take that as a suggestion, I was just thinking
out loud. And as is, it doesn't work as the function expects a
iosys_map *

Lucas De Marhci


More information about the dri-devel mailing list