RE: [PATCH] drm/amdgpu: avoid dummy_read_page overlapping mappings

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

 



[AMD Official Use Only - AMD Internal Distribution Only]

Hold on to this patch for a while. I need to further investigate whether it requires allocating a separate page for the second VGA device.

Thanks,
Prike

> -----Original Message-----
> From: Liang, Prike <Prike.Liang@xxxxxxx>
> Sent: Tuesday, October 22, 2024 3:19 PM
> To: amd-gfx@xxxxxxxxxxxxxxxxxxxxx
> Cc: Deucher, Alexander <Alexander.Deucher@xxxxxxx>; Liang, Prike
> <Prike.Liang@xxxxxxx>
> Subject: [PATCH] drm/amdgpu: avoid dummy_read_page overlapping mappings
>
> In the A+A system, the dummy_read_page is mapped twice during the device
> graphics memory software initialization.
>
> To avoid page remapping, export the ttm_glob_use_count to the driver for checking
> whether the same page has already been mapped.
>
> Signed-off-by: Prike Liang <Prike.Liang@xxxxxxx>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | 3 ++-
>  drivers/gpu/drm/ttm/ttm_device.c         | 7 +++----
>  include/drm/ttm/ttm_device.h             | 5 +++++
>  3 files changed, 10 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> index 256b95232de5..81e567f63967 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> @@ -76,7 +76,8 @@ static int amdgpu_gart_dummy_page_init(struct
> amdgpu_device *adev)  {
>       struct page *dummy_page = ttm_glob.dummy_read_page;
>
> -     if (adev->dummy_page_addr)
> +     if (adev->dummy_page_addr ||
> +                             ttm_glob.ttm_glob_use_count > 1)
>               return 0;
>       adev->dummy_page_addr = dma_map_page(&adev->pdev->dev,
> dummy_page, 0,
>                                            PAGE_SIZE, DMA_BIDIRECTIONAL); diff -
> -git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c
> index 434cf0258000..d99ccfa94c67 100644
> --- a/drivers/gpu/drm/ttm/ttm_device.c
> +++ b/drivers/gpu/drm/ttm/ttm_device.c
> @@ -41,7 +41,6 @@
>   * ttm_global_mutex - protecting the global state
>   */
>  static DEFINE_MUTEX(ttm_global_mutex);
> -static unsigned ttm_glob_use_count;
>  struct ttm_global ttm_glob;
>  EXPORT_SYMBOL(ttm_glob);
>
> @@ -52,7 +51,7 @@ static void ttm_global_release(void)
>       struct ttm_global *glob = &ttm_glob;
>
>       mutex_lock(&ttm_global_mutex);
> -     if (--ttm_glob_use_count > 0)
> +     if (--glob->ttm_glob_use_count > 0)
>               goto out;
>
>       ttm_pool_mgr_fini();
> @@ -72,7 +71,7 @@ static int ttm_global_init(void)
>       int ret = 0;
>
>       mutex_lock(&ttm_global_mutex);
> -     if (++ttm_glob_use_count > 1)
> +     if (++glob->ttm_glob_use_count > 1)
>               goto out;
>
>       si_meminfo(&si);
> @@ -118,7 +117,7 @@ static int ttm_global_init(void)
>       if (ret && ttm_debugfs_root)
>               debugfs_remove(ttm_debugfs_root);
>       if (ret)
> -             --ttm_glob_use_count;
> +             --glob->ttm_glob_use_count;
>       mutex_unlock(&ttm_global_mutex);
>       return ret;
>  }
> diff --git a/include/drm/ttm/ttm_device.h b/include/drm/ttm/ttm_device.h index
> c22f30535c84..8afb380989e1 100644
> --- a/include/drm/ttm/ttm_device.h
> +++ b/include/drm/ttm/ttm_device.h
> @@ -56,6 +56,11 @@ extern struct ttm_global {
>        * @bo_count: Number of buffer objects allocated by devices.
>        */
>       atomic_t bo_count;
> +
> +     /**
> +      * @ttm_glob_use_count: Number of ttm glob object referenced by devices.
> +      */
> +     unsigned ttm_glob_use_count;
>  } ttm_glob;
>
>  struct ttm_device_funcs {
> --
> 2.34.1





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

  Powered by Linux