From: Lucas De Marchi <lucas.demarchi@intel.com> To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: "Matthew Brost" <matthew.brost@intel.com>, "Thomas Hellström" <thomas.hellstrom@linux.intel.com>, "Tvrtko Ursulin" <tvrtko.ursulin@linux.intel.com>, "David Airlie" <airlied@linux.ie>, "Lucas De Marchi" <lucas.demarchi@intel.com>, "Daniele Ceraolo Spurio" <daniele.ceraolospurio@intel.com>, "Matthew Auld" <matthew.auld@intel.com>, "Thomas Zimmermann" <tzimmermann@suse.de>, "Christian König" <christian.koenig@amd.com>, "John Harrison" <John.C.Harrison@Intel.com> Subject: [PATCH 04/19] drm/i915/gt: Add helper for shmem copy to iosys_map Date: Fri, 4 Feb 2022 09:44:21 -0800 [thread overview] Message-ID: <20220204174436.830121-5-lucas.demarchi@intel.com> (raw) In-Reply-To: <20220204174436.830121-1-lucas.demarchi@intel.com> Add a variant of shmem_read() that takes a iosys_map pointer rather than a plain pointer as argument. It's mostly a copy __shmem_rw() but adapting the api and removing the write support since there's currently only need to use iosys_map as destination. Reworking __shmem_rw() to share the implementation was tempting, but finding a good balance between reuse and clarity pushed towards a little code duplication. Since the function is small, just add the similar function with a copy/paste/adapt approach. Cc: Matt Roper <matthew.d.roper@intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Matthew Auld <matthew.auld@intel.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> --- drivers/gpu/drm/i915/gt/shmem_utils.c | 33 +++++++++++++++++++++++++++ drivers/gpu/drm/i915/gt/shmem_utils.h | 3 +++ 2 files changed, 36 insertions(+) diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c index 0683b27a3890..764adefdb4be 100644 --- a/drivers/gpu/drm/i915/gt/shmem_utils.c +++ b/drivers/gpu/drm/i915/gt/shmem_utils.c @@ -3,6 +3,7 @@ * Copyright © 2020 Intel Corporation */ +#include <linux/iosys-map.h> #include <linux/mm.h> #include <linux/pagemap.h> #include <linux/shmem_fs.h> @@ -123,6 +124,38 @@ static int __shmem_rw(struct file *file, loff_t off, return 0; } +int shmem_read_to_iosys_map(struct file *file, loff_t off, + struct iosys_map *map, size_t len) +{ + struct iosys_map map_iter = *map; + unsigned long pfn; + + for (pfn = off >> PAGE_SHIFT; len; pfn++) { + unsigned int this = + min_t(size_t, PAGE_SIZE - offset_in_page(off), len); + struct page *page; + void *vaddr; + + page = shmem_read_mapping_page_gfp(file->f_mapping, pfn, + GFP_KERNEL); + if (IS_ERR(page)) + return PTR_ERR(page); + + vaddr = kmap(page); + iosys_map_memcpy_to(&map_iter, 0, vaddr + offset_in_page(off), + this); + mark_page_accessed(page); + kunmap(page); + put_page(page); + + len -= this; + iosys_map_incr(&map_iter, this); + off = 0; + } + + return 0; +} + int shmem_read(struct file *file, loff_t off, void *dst, size_t len) { return __shmem_rw(file, off, dst, len, false); diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.h b/drivers/gpu/drm/i915/gt/shmem_utils.h index c1669170c351..e1784999faee 100644 --- a/drivers/gpu/drm/i915/gt/shmem_utils.h +++ b/drivers/gpu/drm/i915/gt/shmem_utils.h @@ -8,6 +8,7 @@ #include <linux/types.h> +struct iosys_map; struct drm_i915_gem_object; struct file; @@ -17,6 +18,8 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj); void *shmem_pin_map(struct file *file); void shmem_unpin_map(struct file *file, void *ptr); +int shmem_read_to_iosys_map(struct file *file, loff_t off, + struct iosys_map *map, size_t len); int shmem_read(struct file *file, loff_t off, void *dst, size_t len); int shmem_write(struct file *file, loff_t off, void *src, size_t len); -- 2.35.1
WARNING: multiple messages have this Message-ID (diff)
From: Lucas De Marchi <lucas.demarchi@intel.com> To: intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>, "David Airlie" <airlied@linux.ie>, "Lucas De Marchi" <lucas.demarchi@intel.com>, "Sumit Semwal" <sumit.semwal@linaro.org>, "Matthew Auld" <matthew.auld@intel.com>, "Thomas Zimmermann" <tzimmermann@suse.de>, "Christian König" <christian.koenig@amd.com> Subject: [Intel-gfx] [PATCH 04/19] drm/i915/gt: Add helper for shmem copy to iosys_map Date: Fri, 4 Feb 2022 09:44:21 -0800 [thread overview] Message-ID: <20220204174436.830121-5-lucas.demarchi@intel.com> (raw) In-Reply-To: <20220204174436.830121-1-lucas.demarchi@intel.com> Add a variant of shmem_read() that takes a iosys_map pointer rather than a plain pointer as argument. It's mostly a copy __shmem_rw() but adapting the api and removing the write support since there's currently only need to use iosys_map as destination. Reworking __shmem_rw() to share the implementation was tempting, but finding a good balance between reuse and clarity pushed towards a little code duplication. Since the function is small, just add the similar function with a copy/paste/adapt approach. Cc: Matt Roper <matthew.d.roper@intel.com> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Cc: David Airlie <airlied@linux.ie> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: Matthew Auld <matthew.auld@intel.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> --- drivers/gpu/drm/i915/gt/shmem_utils.c | 33 +++++++++++++++++++++++++++ drivers/gpu/drm/i915/gt/shmem_utils.h | 3 +++ 2 files changed, 36 insertions(+) diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.c b/drivers/gpu/drm/i915/gt/shmem_utils.c index 0683b27a3890..764adefdb4be 100644 --- a/drivers/gpu/drm/i915/gt/shmem_utils.c +++ b/drivers/gpu/drm/i915/gt/shmem_utils.c @@ -3,6 +3,7 @@ * Copyright © 2020 Intel Corporation */ +#include <linux/iosys-map.h> #include <linux/mm.h> #include <linux/pagemap.h> #include <linux/shmem_fs.h> @@ -123,6 +124,38 @@ static int __shmem_rw(struct file *file, loff_t off, return 0; } +int shmem_read_to_iosys_map(struct file *file, loff_t off, + struct iosys_map *map, size_t len) +{ + struct iosys_map map_iter = *map; + unsigned long pfn; + + for (pfn = off >> PAGE_SHIFT; len; pfn++) { + unsigned int this = + min_t(size_t, PAGE_SIZE - offset_in_page(off), len); + struct page *page; + void *vaddr; + + page = shmem_read_mapping_page_gfp(file->f_mapping, pfn, + GFP_KERNEL); + if (IS_ERR(page)) + return PTR_ERR(page); + + vaddr = kmap(page); + iosys_map_memcpy_to(&map_iter, 0, vaddr + offset_in_page(off), + this); + mark_page_accessed(page); + kunmap(page); + put_page(page); + + len -= this; + iosys_map_incr(&map_iter, this); + off = 0; + } + + return 0; +} + int shmem_read(struct file *file, loff_t off, void *dst, size_t len) { return __shmem_rw(file, off, dst, len, false); diff --git a/drivers/gpu/drm/i915/gt/shmem_utils.h b/drivers/gpu/drm/i915/gt/shmem_utils.h index c1669170c351..e1784999faee 100644 --- a/drivers/gpu/drm/i915/gt/shmem_utils.h +++ b/drivers/gpu/drm/i915/gt/shmem_utils.h @@ -8,6 +8,7 @@ #include <linux/types.h> +struct iosys_map; struct drm_i915_gem_object; struct file; @@ -17,6 +18,8 @@ struct file *shmem_create_from_object(struct drm_i915_gem_object *obj); void *shmem_pin_map(struct file *file); void shmem_unpin_map(struct file *file, void *ptr); +int shmem_read_to_iosys_map(struct file *file, loff_t off, + struct iosys_map *map, size_t len); int shmem_read(struct file *file, loff_t off, void *dst, size_t len); int shmem_write(struct file *file, loff_t off, void *src, size_t len); -- 2.35.1
next prev parent reply other threads:[~2022-02-04 17:45 UTC|newest] Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-04 17:44 [PATCH 00/19] drm/i915/guc: Refactor ADS access to use iosys_map Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 01/19] dma-buf-map: Rename to iosys-map Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 02/19] iosys-map: Add offset to iosys_map_memcpy_to() Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` Lucas De Marchi 2022-02-04 18:35 ` Christian König 2022-02-04 18:35 ` [Intel-gfx] " Christian König 2022-02-04 18:35 ` Christian König 2022-02-04 18:48 ` Thomas Zimmermann 2022-02-04 18:48 ` [Intel-gfx] " Thomas Zimmermann 2022-02-04 19:28 ` Lucas De Marchi 2022-02-04 19:28 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 19:28 ` Lucas De Marchi 2022-02-04 17:44 ` [PATCH 03/19] iosys-map: Add a few more helpers Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` Lucas De Marchi 2022-02-04 19:05 ` Thomas Zimmermann 2022-02-04 19:05 ` [Intel-gfx] " Thomas Zimmermann 2022-02-04 19:05 ` Thomas Zimmermann 2022-02-04 19:44 ` Lucas De Marchi 2022-02-04 19:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 19:44 ` Lucas De Marchi 2022-02-07 8:36 ` Thomas Zimmermann 2022-02-07 8:36 ` [Intel-gfx] " Thomas Zimmermann 2022-02-04 17:44 ` Lucas De Marchi [this message] 2022-02-04 17:44 ` [Intel-gfx] [PATCH 04/19] drm/i915/gt: Add helper for shmem copy to iosys_map Lucas De Marchi 2022-02-04 19:15 ` Thomas Zimmermann 2022-02-04 19:15 ` [Intel-gfx] " Thomas Zimmermann 2022-02-07 20:35 ` Lucas De Marchi 2022-02-07 20:35 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 05/19] drm/i915/guc: Keep iosys_map of ads_blob around Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 06/19] drm/i915/guc: Add read/write helpers for ADS blob Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 07/19] drm/i915/guc: Convert golden context init to iosys_map Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 19:19 ` Thomas Zimmermann 2022-02-04 19:19 ` [Intel-gfx] " Thomas Zimmermann 2022-02-04 17:44 ` [PATCH 08/19] drm/i915/guc: Convert policies update " Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] [PATCH 09/19] drm/i915/guc: Convert engine record " Lucas De Marchi 2022-02-04 17:44 ` Lucas De Marchi 2022-02-04 19:23 ` Thomas Zimmermann 2022-02-04 19:23 ` [Intel-gfx] " Thomas Zimmermann 2022-02-04 17:44 ` [Intel-gfx] [PATCH 10/19] drm/i915/guc: Convert guc_ads_private_data_reset " Lucas De Marchi 2022-02-04 17:44 ` Lucas De Marchi 2022-02-04 17:44 ` [PATCH 11/19] drm/i915/guc: Convert golden context prep " Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 12/19] drm/i915/guc: Replace check for golden context size Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 13/19] drm/i915/guc: Convert mapping table to iosys_map Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 14/19] drm/i915/guc: Convert capture list " Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 15/19] drm/i915/guc: Prepare for error propagation Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 16/19] drm/i915/guc: Use a single pass to calculate regset Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 17/19] drm/i915/guc: Convert guc_mmio_reg_state_init to iosys_map Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 18/19] drm/i915/guc: Convert __guc_ads_init " Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 17:44 ` [PATCH 19/19] drm/i915/guc: Remove plain ads_blob pointer Lucas De Marchi 2022-02-04 17:44 ` [Intel-gfx] " Lucas De Marchi 2022-02-04 18:38 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for drm/i915/guc: Refactor ADS access to use iosys_map Patchwork 2022-02-04 18:40 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork 2022-02-04 19:12 ` [Intel-gfx] ✗ Fi.CI.BAT: failure " 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=20220204174436.830121-5-lucas.demarchi@intel.com \ --to=lucas.demarchi@intel.com \ --cc=John.C.Harrison@Intel.com \ --cc=airlied@linux.ie \ --cc=christian.koenig@amd.com \ --cc=daniele.ceraolospurio@intel.com \ --cc=dri-devel@lists.freedesktop.org \ --cc=intel-gfx@lists.freedesktop.org \ --cc=matthew.auld@intel.com \ --cc=matthew.brost@intel.com \ --cc=thomas.hellstrom@linux.intel.com \ --cc=tvrtko.ursulin@linux.intel.com \ --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: linkBe 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.