drm/amdgpu: move program_aspm to amdgpu_nbio
authorGabriel Almeida <gabrielsousa230@gmail.com>
Fri, 24 Apr 2026 00:49:09 +0000 (21:49 -0300)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 28 Apr 2026 18:28:52 +0000 (14:28 -0400)
The program_aspm helper is duplicated across multiple files with
identical logic.

Move it to amdgpu_nbio.c as amdgpu_nbio_program_aspm and update
all users accordingly.

Signed-off-by: Gabriel Almeida <gabrielsousa230@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.c
drivers/gpu/drm/amd/amdgpu/amdgpu_nbio.h
drivers/gpu/drm/amd/amdgpu/nv.c
drivers/gpu/drm/amd/amdgpu/soc15.c
drivers/gpu/drm/amd/amdgpu/soc21.c

index a974265..e4c8e98 100644 (file)
@@ -84,3 +84,13 @@ late_fini:
        amdgpu_ras_block_late_fini(adev, ras_block);
        return r;
 }
+
+
+void amdgpu_nbio_program_aspm(struct amdgpu_device *adev)
+{
+       if (!amdgpu_device_should_use_aspm(adev))
+               return;
+
+       if (adev->nbio.funcs->program_aspm)
+               adev->nbio.funcs->program_aspm(adev);
+}
index b528de6..a61f3a6 100644 (file)
@@ -121,4 +121,6 @@ u64 amdgpu_nbio_get_pcie_replay_count(struct amdgpu_device *adev);
 
 bool amdgpu_nbio_is_replay_cnt_supported(struct amdgpu_device *adev);
 
+void amdgpu_nbio_program_aspm(struct amdgpu_device *adev);
+
 #endif
index 7ce1a1b..030d806 100644 (file)
@@ -511,16 +511,6 @@ static int nv_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk)
        return 0;
 }
 
-static void nv_program_aspm(struct amdgpu_device *adev)
-{
-       if (!amdgpu_device_should_use_aspm(adev))
-               return;
-
-       if (adev->nbio.funcs->program_aspm)
-               adev->nbio.funcs->program_aspm(adev);
-
-}
-
 const struct amdgpu_ip_block_version nv_common_ip_block = {
        .type = AMD_IP_BLOCK_TYPE_COMMON,
        .major = 1,
@@ -984,7 +974,7 @@ static int nv_common_hw_init(struct amdgpu_ip_block *ip_block)
                adev->nbio.funcs->apply_l1_link_width_reconfig_wa(adev);
 
        /* enable aspm */
-       nv_program_aspm(adev);
+       amdgpu_nbio_program_aspm(adev);
        /* setup nbio registers */
        adev->nbio.funcs->init_registers(adev);
        /* remap HDP registers to a hole in mmio space,
index b456e45..27bcbba 100644 (file)
@@ -695,15 +695,6 @@ static int soc15_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk
        return 0;
 }
 
-static void soc15_program_aspm(struct amdgpu_device *adev)
-{
-       if (!amdgpu_device_should_use_aspm(adev))
-               return;
-
-       if (adev->nbio.funcs->program_aspm)
-               adev->nbio.funcs->program_aspm(adev);
-}
-
 const struct amdgpu_ip_block_version vega10_common_ip_block =
 {
        .type = AMD_IP_BLOCK_TYPE_COMMON,
@@ -1284,7 +1275,7 @@ static int soc15_common_hw_init(struct amdgpu_ip_block *ip_block)
        struct amdgpu_device *adev = ip_block->adev;
 
        /* enable aspm */
-       soc15_program_aspm(adev);
+       amdgpu_nbio_program_aspm(adev);
        /* setup nbio registers */
        adev->nbio.funcs->init_registers(adev);
        /* remap HDP registers to a hole in mmio space,
index fbd1d97..7e4353d 100644 (file)
@@ -470,15 +470,6 @@ static int soc21_set_vce_clocks(struct amdgpu_device *adev, u32 evclk, u32 ecclk
        return 0;
 }
 
-static void soc21_program_aspm(struct amdgpu_device *adev)
-{
-       if (!amdgpu_device_should_use_aspm(adev))
-               return;
-
-       if (adev->nbio.funcs->program_aspm)
-               adev->nbio.funcs->program_aspm(adev);
-}
-
 const struct amdgpu_ip_block_version soc21_common_ip_block = {
        .type = AMD_IP_BLOCK_TYPE_COMMON,
        .major = 1,
@@ -925,7 +916,7 @@ static int soc21_common_hw_init(struct amdgpu_ip_block *ip_block)
        struct amdgpu_device *adev = ip_block->adev;
 
        /* enable aspm */
-       soc21_program_aspm(adev);
+       amdgpu_nbio_program_aspm(adev);
        /* setup nbio registers */
        adev->nbio.funcs->init_registers(adev);
        /* remap HDP registers to a hole in mmio space,