Re: [PATCH 25/29] drm/amdgpu: resume for each vcn instance

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 24, 2024 at 10:48 PM <boyuan.zhang@xxxxxxx> wrote:
>
> From: Boyuan Zhang <boyuan.zhang@xxxxxxx>
>
> Pass instance parameter to amdgpu_vcn_resume(), and perform
> resume ONLY for the given vcn instance, instead of for all
> vcn instances. Modify each vcn generation accordingly.
>
> Signed-off-by: Boyuan Zhang <boyuan.zhang@xxxxxxx>

Reviewed-by: Alex Deucher <alexander.deucher@xxxxxxx>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c | 60 ++++++++++++-------------
>  drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h |  2 +-
>  drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c   |  4 +-
>  drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c   |  4 +-
>  drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c   |  4 +-
>  drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c   |  4 +-
>  drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c   |  4 +-
>  drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c |  4 +-
>  drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c |  4 +-
>  drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c |  4 +-
>  10 files changed, 47 insertions(+), 47 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
> index 50047c636904..c4e1283aa9a4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.c
> @@ -335,47 +335,47 @@ int amdgpu_vcn_suspend(struct amdgpu_device *adev, int inst)
>         return amdgpu_vcn_save_vcpu_bo(adev, inst);
>  }
>
> -int amdgpu_vcn_resume(struct amdgpu_device *adev)
> +int amdgpu_vcn_resume(struct amdgpu_device *adev, int inst)
>  {
>         unsigned int size;
>         void *ptr;
> -       int i, idx;
> +       int idx;
> +
> +       if (adev->vcn.harvest_config & (1 << inst))
> +               return 0;
>
> -       for (i = 0; i < adev->vcn.num_vcn_inst; ++i) {
> -               if (adev->vcn.harvest_config & (1 << i))
> -                       continue;
> -               if (adev->vcn.inst[i].vcpu_bo == NULL)
> -                       return -EINVAL;
> +       if (adev->vcn.inst[inst].vcpu_bo == NULL)
> +               return -EINVAL;
> +
> +       size = amdgpu_bo_size(adev->vcn.inst[inst].vcpu_bo);
> +       ptr = adev->vcn.inst[inst].cpu_addr;
>
> -               size = amdgpu_bo_size(adev->vcn.inst[i].vcpu_bo);
> -               ptr = adev->vcn.inst[i].cpu_addr;
> +       if (adev->vcn.inst[inst].saved_bo != NULL) {
> +               if (drm_dev_enter(adev_to_drm(adev), &idx)) {
> +                       memcpy_toio(ptr, adev->vcn.inst[inst].saved_bo, size);
> +                       drm_dev_exit(idx);
> +               }
> +               kvfree(adev->vcn.inst[inst].saved_bo);
> +               adev->vcn.inst[inst].saved_bo = NULL;
> +       } else {
> +               const struct common_firmware_header *hdr;
> +               unsigned int offset;
>
> -               if (adev->vcn.inst[i].saved_bo != NULL) {
> +               hdr = (const struct common_firmware_header *)adev->vcn.inst[inst].fw->data;
> +               if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) {
> +                       offset = le32_to_cpu(hdr->ucode_array_offset_bytes);
>                         if (drm_dev_enter(adev_to_drm(adev), &idx)) {
> -                               memcpy_toio(ptr, adev->vcn.inst[i].saved_bo, size);
> +                               memcpy_toio(adev->vcn.inst[inst].cpu_addr,
> +                                               adev->vcn.inst[inst].fw->data + offset,
> +                                               le32_to_cpu(hdr->ucode_size_bytes));
>                                 drm_dev_exit(idx);
>                         }
> -                       kvfree(adev->vcn.inst[i].saved_bo);
> -                       adev->vcn.inst[i].saved_bo = NULL;
> -               } else {
> -                       const struct common_firmware_header *hdr;
> -                       unsigned int offset;
> -
> -                       hdr = (const struct common_firmware_header *)adev->vcn.inst[i].fw->data;
> -                       if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) {
> -                               offset = le32_to_cpu(hdr->ucode_array_offset_bytes);
> -                               if (drm_dev_enter(adev_to_drm(adev), &idx)) {
> -                                       memcpy_toio(adev->vcn.inst[i].cpu_addr,
> -                                                   adev->vcn.inst[i].fw->data + offset,
> -                                                   le32_to_cpu(hdr->ucode_size_bytes));
> -                                       drm_dev_exit(idx);
> -                               }
> -                               size -= le32_to_cpu(hdr->ucode_size_bytes);
> -                               ptr += le32_to_cpu(hdr->ucode_size_bytes);
> -                       }
> -                       memset_io(ptr, 0, size);
> +                       size -= le32_to_cpu(hdr->ucode_size_bytes);
> +                       ptr += le32_to_cpu(hdr->ucode_size_bytes);
>                 }
> +               memset_io(ptr, 0, size);
>         }
> +
>         return 0;
>  }
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
> index be681bcab184..75cfdb770672 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vcn.h
> @@ -487,7 +487,7 @@ int amdgpu_vcn_early_init(struct amdgpu_device *adev, int inst);
>  int amdgpu_vcn_sw_init(struct amdgpu_device *adev, int inst);
>  int amdgpu_vcn_sw_fini(struct amdgpu_device *adev, int inst);
>  int amdgpu_vcn_suspend(struct amdgpu_device *adev, int inst);
> -int amdgpu_vcn_resume(struct amdgpu_device *adev);
> +int amdgpu_vcn_resume(struct amdgpu_device *adev, int inst);
>  void amdgpu_vcn_ring_begin_use(struct amdgpu_ring *ring);
>  void amdgpu_vcn_ring_end_use(struct amdgpu_ring *ring);
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
> index a3845e7747b0..77f9f34eaca8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v1_0.c
> @@ -156,7 +156,7 @@ static int vcn_v1_0_sw_init(struct amdgpu_ip_block *ip_block)
>
>         amdgpu_vcn_setup_ucode(adev);
>
> -       r = amdgpu_vcn_resume(adev);
> +       r = amdgpu_vcn_resume(adev, inst);
>         if (r)
>                 return r;
>
> @@ -331,7 +331,7 @@ static int vcn_v1_0_resume(struct amdgpu_ip_block *ip_block)
>  {
>         int r;
>
> -       r = amdgpu_vcn_resume(ip_block->adev);
> +       r = amdgpu_vcn_resume(ip_block->adev, ip_block->instance);
>         if (r)
>                 return r;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
> index 8e943d1fae17..87293bb777d4 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_0.c
> @@ -161,7 +161,7 @@ static int vcn_v2_0_sw_init(struct amdgpu_ip_block *ip_block)
>
>         amdgpu_vcn_setup_ucode(adev);
>
> -       r = amdgpu_vcn_resume(adev);
> +       r = amdgpu_vcn_resume(adev, inst);
>         if (r)
>                 return r;
>
> @@ -359,7 +359,7 @@ static int vcn_v2_0_resume(struct amdgpu_ip_block *ip_block)
>  {
>         int r;
>
> -       r = amdgpu_vcn_resume(ip_block->adev);
> +       r = amdgpu_vcn_resume(ip_block->adev, ip_block->instance);
>         if (r)
>                 return r;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
> index 9ca07e56b052..62266db72531 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v2_5.c
> @@ -191,7 +191,7 @@ static int vcn_v2_5_sw_init(struct amdgpu_ip_block *ip_block)
>
>         amdgpu_vcn_setup_ucode(adev);
>
> -       r = amdgpu_vcn_resume(adev);
> +       r = amdgpu_vcn_resume(adev, inst);
>         if (r)
>                 return r;
>
> @@ -436,7 +436,7 @@ static int vcn_v2_5_resume(struct amdgpu_ip_block *ip_block)
>  {
>         int r;
>
> -       r = amdgpu_vcn_resume(ip_block->adev);
> +       r = amdgpu_vcn_resume(ip_block->adev, ip_block->instance);
>         if (r)
>                 return r;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
> index a25d2b9784be..d29c49d061d7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v3_0.c
> @@ -174,7 +174,7 @@ static int vcn_v3_0_sw_init(struct amdgpu_ip_block *ip_block)
>
>         amdgpu_vcn_setup_ucode(adev);
>
> -       r = amdgpu_vcn_resume(adev);
> +       r = amdgpu_vcn_resume(adev, inst);
>         if (r)
>                 return r;
>
> @@ -468,7 +468,7 @@ static int vcn_v3_0_resume(struct amdgpu_ip_block *ip_block)
>  {
>         int r;
>
> -       r = amdgpu_vcn_resume(ip_block->adev);
> +       r = amdgpu_vcn_resume(ip_block->adev, ip_block->instance);
>         if (r)
>                 return r;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
> index fcf7b23cca90..509dc6b5f43b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0.c
> @@ -182,7 +182,7 @@ static int vcn_v4_0_sw_init(struct amdgpu_ip_block *ip_block)
>
>         amdgpu_vcn_setup_ucode(adev);
>
> -       r = amdgpu_vcn_resume(adev);
> +       r = amdgpu_vcn_resume(adev, inst);
>         if (r)
>                 return r;
>
> @@ -396,7 +396,7 @@ static int vcn_v4_0_resume(struct amdgpu_ip_block *ip_block)
>  {
>         int r;
>
> -       r = amdgpu_vcn_resume(ip_block->adev);
> +       r = amdgpu_vcn_resume(ip_block->adev, ip_block->instance);
>         if (r)
>                 return r;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
> index ece9b1df2743..070cf516f365 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_3.c
> @@ -139,7 +139,7 @@ static int vcn_v4_0_3_sw_init(struct amdgpu_ip_block *ip_block)
>
>         amdgpu_vcn_setup_ucode(adev);
>
> -       r = amdgpu_vcn_resume(adev);
> +       r = amdgpu_vcn_resume(adev, inst);
>         if (r)
>                 return r;
>
> @@ -355,7 +355,7 @@ static int vcn_v4_0_3_resume(struct amdgpu_ip_block *ip_block)
>  {
>         int r;
>
> -       r = amdgpu_vcn_resume(ip_block->adev);
> +       r = amdgpu_vcn_resume(ip_block->adev, ip_block->instance);
>         if (r)
>                 return r;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
> index f1ec632a9eb8..ad9e67d9134d 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v4_0_5.c
> @@ -144,7 +144,7 @@ static int vcn_v4_0_5_sw_init(struct amdgpu_ip_block *ip_block)
>
>         amdgpu_vcn_setup_ucode(adev);
>
> -       r = amdgpu_vcn_resume(adev);
> +       r = amdgpu_vcn_resume(adev, inst);
>         if (r)
>                 return r;
>
> @@ -347,7 +347,7 @@ static int vcn_v4_0_5_resume(struct amdgpu_ip_block *ip_block)
>  {
>         int r;
>
> -       r = amdgpu_vcn_resume(ip_block->adev);
> +       r = amdgpu_vcn_resume(ip_block->adev, ip_block->instance);
>         if (r)
>                 return r;
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
> index fdfb3084d54e..9999c8094920 100644
> --- a/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
> +++ b/drivers/gpu/drm/amd/amdgpu/vcn_v5_0_0.c
> @@ -128,7 +128,7 @@ static int vcn_v5_0_0_sw_init(struct amdgpu_ip_block *ip_block)
>
>         amdgpu_vcn_setup_ucode(adev);
>
> -       r = amdgpu_vcn_resume(adev);
> +       r = amdgpu_vcn_resume(adev, inst);
>         if (r)
>                 return r;
>
> @@ -311,7 +311,7 @@ static int vcn_v5_0_0_resume(struct amdgpu_ip_block *ip_block)
>  {
>         int r;
>
> -       r = amdgpu_vcn_resume(ip_block->adev);
> +       r = amdgpu_vcn_resume(ip_block->adev, ip_block->instance);
>         if (r)
>                 return r;
>
> --
> 2.34.1
>




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux