All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/uc: use io memcpy functions for device memory copy
@ 2022-04-06  9:18 ` Balasubramani Vivekanandan
  0 siblings, 0 replies; 6+ messages in thread
From: Balasubramani Vivekanandan @ 2022-04-06  9:18 UTC (permalink / raw)
  To: intel-gfx, dri-devel
  Cc: Balasubramani Vivekanandan, lucas.demarchi, siva.mullati,
	daniele.ceraolospurio, John.C.Harrison, michal.wajdeczko

When copying RSA use io memcpy functions if the destination address
contains a GPU local memory address. Considering even the source
address can be on local memory, a bounce buffer is used to copy from io
to io.
The intention of this patch is to make i915 portable outside x86 mainly
on ARM64.

Signed-off-by: Balasubramani Vivekanandan <balasubramani.vivekanandan@intel.com>
---
 drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
index bb864655c495..06d30670e15c 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_uc_fw.c
@@ -589,7 +589,7 @@ static int uc_fw_rsa_data_create(struct intel_uc_fw *uc_fw)
 	struct intel_gt *gt = __uc_fw_to_gt(uc_fw);
 	struct i915_vma *vma;
 	size_t copied;
-	void *vaddr;
+	void *vaddr, *bounce;
 	int err;
 
 	err = i915_inject_probe_error(gt->i915, -ENXIO);
@@ -621,7 +621,26 @@ static int uc_fw_rsa_data_create(struct intel_uc_fw *uc_fw)
 		goto unpin_out;
 	}
 
-	copied = intel_uc_fw_copy_rsa(uc_fw, vaddr, vma->size);
+	if (i915_gem_object_is_lmem(vma->obj)) {
+		/* When vma is allocated from the GPU local memmory, it means
+		 * the destination address contains an io memory and we need to
+		 * use memcpy function for io memory for copying, to ensure
+		 * i915 portability outside x86. It is most likely the RSA will
+		 * also be on local memory and so the source of copy will also
+		 * be an io address. Since we cannot directly copy from io to
+		 * io, we use a bounce buffer to copy.
+		 */
+		copied = 0;
+		bounce = kmalloc(vma->size, GFP_KERNEL);
+		if (likely(bounce)) {
+			copied = intel_uc_fw_copy_rsa(uc_fw, bounce, vma->size);
+			memcpy_toio((void __iomem *)vaddr, bounce, copied);
+			kfree(bounce);
+		}
+	} else {
+		copied = intel_uc_fw_copy_rsa(uc_fw, vaddr, vma->size);
+	}
+
 	i915_gem_object_unpin_map(vma->obj);
 
 	if (copied < uc_fw->rsa_size) {
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-04-27 14:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-06  9:18 [PATCH] drm/i915/uc: use io memcpy functions for device memory copy Balasubramani Vivekanandan
2022-04-06  9:18 ` [Intel-gfx] " Balasubramani Vivekanandan
2022-04-06 10:37 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
2022-04-06 14:45 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2022-04-27 14:29 ` [PATCH] " Siva Mullati
2022-04-27 14:29   ` [Intel-gfx] " Siva Mullati

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.