Re: [PATCH] drm/i915/uc: use io memcpy functions for device memory copy

2022-04-27 Thread Siva Mullati
LGTM

Acked-by: Siva Mullati 

On 06/04/22 14:48, Vivekanandan, Balasubramani wrote:
> 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 
> 
> ---
>  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) {


Re: [PATCH v3 2/3] drm/i915: Fix header test for !CONFIG_X86

2022-02-01 Thread Siva Mullati
Reviewed-by: Siva Mullati 

On 31/01/22 10:29 pm, Lucas De Marchi wrote:
> Architectures others than x86 have a stub implementation calling
> WARN_ON_ONCE(). The appropriate headers need to be included, otherwise
> the header-test target will fail with:
>
>   HDRTEST drivers/gpu/drm/i915/i915_mm.h
> In file included from :
> ./drivers/gpu/drm/i915/i915_mm.h: In function ‘remap_io_mapping’:
> ./drivers/gpu/drm/i915/i915_mm.h:26:2: error: implicit declaration of 
> function ‘WARN_ON_ONCE’ [-Werror=implicit-function-declaration]
>26 |  WARN_ON_ONCE(1);
>   |  ^~~~
>
> v2: Do not include  since call to pr_err() has been
> removed
>
> Fixes: 67c430bbaae1 ("drm/i915: Skip remap_io_mapping() for non-x86 
> platforms")
> Cc: Siva Mullati 
> Signed-off-by: Lucas De Marchi 
> ---
>
> v3: No changes from previous version, just submitting to the right
> mailing list
>
>  drivers/gpu/drm/i915/i915_mm.h | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_mm.h b/drivers/gpu/drm/i915/i915_mm.h
> index 76f1d53bdf34..3ad22bbe80eb 100644
> --- a/drivers/gpu/drm/i915/i915_mm.h
> +++ b/drivers/gpu/drm/i915/i915_mm.h
> @@ -6,6 +6,7 @@
>  #ifndef __I915_MM_H__
>  #define __I915_MM_H__
>  
> +#include 
>  #include 
>  
>  struct vm_area_struct;