]> Git Repo - linux.git/commitdiff
drm/amdgpu: Group gfx sysfs functions
authorLijo Lazar <[email protected]>
Tue, 29 Oct 2024 05:17:26 +0000 (10:47 +0530)
committerAlex Deucher <[email protected]>
Mon, 4 Nov 2024 17:06:23 +0000 (12:06 -0500)
Make amdgpu_gfx_sysfs_init/fini functions as common entry points for all
gfx related sysfs nodes.

Signed-off-by: Lijo Lazar <[email protected]>
Reviewed-by: Alex Deucher <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c
drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c

index 63f5fa736f3264274ee7b29edefc72f445784e1f..2f3f09dfb1fd20b89b3707d8cbe4ebc212c56a6f 100644 (file)
@@ -1602,7 +1602,7 @@ static DEVICE_ATTR(current_compute_partition, 0644,
 static DEVICE_ATTR(available_compute_partition, 0444,
                   amdgpu_gfx_get_available_compute_partition, NULL);
 
-int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev)
+static int amdgpu_gfx_sysfs_xcp_init(struct amdgpu_device *adev)
 {
        struct amdgpu_xcp_mgr *xcp_mgr = adev->xcp_mgr;
        bool xcp_switch_supported;
@@ -1629,7 +1629,7 @@ int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev)
        return r;
 }
 
-void amdgpu_gfx_sysfs_fini(struct amdgpu_device *adev)
+static void amdgpu_gfx_sysfs_xcp_fini(struct amdgpu_device *adev)
 {
        struct amdgpu_xcp_mgr *xcp_mgr = adev->xcp_mgr;
        bool xcp_switch_supported;
@@ -1646,25 +1646,47 @@ void amdgpu_gfx_sysfs_fini(struct amdgpu_device *adev)
                                   &dev_attr_available_compute_partition);
 }
 
-int amdgpu_gfx_sysfs_isolation_shader_init(struct amdgpu_device *adev)
+static int amdgpu_gfx_sysfs_isolation_shader_init(struct amdgpu_device *adev)
 {
        int r;
 
        r = device_create_file(adev->dev, &dev_attr_enforce_isolation);
        if (r)
                return r;
+       if (adev->gfx.enable_cleaner_shader)
+               r = device_create_file(adev->dev, &dev_attr_run_cleaner_shader);
 
-       r = device_create_file(adev->dev, &dev_attr_run_cleaner_shader);
-       if (r)
+       return r;
+}
+
+static void amdgpu_gfx_sysfs_isolation_shader_fini(struct amdgpu_device *adev)
+{
+       device_remove_file(adev->dev, &dev_attr_enforce_isolation);
+       if (adev->gfx.enable_cleaner_shader)
+               device_remove_file(adev->dev, &dev_attr_run_cleaner_shader);
+}
+
+int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev)
+{
+       int r;
+
+       r = amdgpu_gfx_sysfs_xcp_init(adev);
+       if (r) {
+               dev_err(adev->dev, "failed to create xcp sysfs files");
                return r;
+       }
 
-       return 0;
+       r = amdgpu_gfx_sysfs_isolation_shader_init(adev);
+       if (r)
+               dev_err(adev->dev, "failed to create isolation sysfs files");
+
+       return r;
 }
 
-void amdgpu_gfx_sysfs_isolation_shader_fini(struct amdgpu_device *adev)
+void amdgpu_gfx_sysfs_fini(struct amdgpu_device *adev)
 {
-       device_remove_file(adev->dev, &dev_attr_enforce_isolation);
-       device_remove_file(adev->dev, &dev_attr_run_cleaner_shader);
+       amdgpu_gfx_sysfs_xcp_fini(adev);
+       amdgpu_gfx_sysfs_isolation_shader_fini(adev);
 }
 
 int amdgpu_gfx_cleaner_shader_sw_init(struct amdgpu_device *adev,
index 7183831df0c396872d017fc00910243111177df6..fd73e527f44607c63c637a346b5b658b01696f59 100644 (file)
@@ -579,8 +579,6 @@ void amdgpu_gfx_cleaner_shader_sw_fini(struct amdgpu_device *adev);
 void amdgpu_gfx_cleaner_shader_init(struct amdgpu_device *adev,
                                    unsigned int cleaner_shader_size,
                                    const void *cleaner_shader_ptr);
-int amdgpu_gfx_sysfs_isolation_shader_init(struct amdgpu_device *adev);
-void amdgpu_gfx_sysfs_isolation_shader_fini(struct amdgpu_device *adev);
 void amdgpu_gfx_enforce_isolation_handler(struct work_struct *work);
 void amdgpu_gfx_enforce_isolation_ring_begin_use(struct amdgpu_ring *ring);
 void amdgpu_gfx_enforce_isolation_ring_end_use(struct amdgpu_ring *ring);
index 9da95b25e158446dab03203ff2e2b457f57917d2..d1a18ca584dd1863792c1b33b5b2bd4f73e2a246 100644 (file)
@@ -4853,9 +4853,10 @@ static int gfx_v10_0_sw_init(struct amdgpu_ip_block *ip_block)
 
        gfx_v10_0_alloc_ip_dump(adev);
 
-       r = amdgpu_gfx_sysfs_isolation_shader_init(adev);
+       r = amdgpu_gfx_sysfs_init(adev);
        if (r)
                return r;
+
        return 0;
 }
 
@@ -4907,7 +4908,7 @@ static int gfx_v10_0_sw_fini(struct amdgpu_ip_block *ip_block)
                gfx_v10_0_rlc_backdoor_autoload_buffer_fini(adev);
 
        gfx_v10_0_free_microcode(adev);
-       amdgpu_gfx_sysfs_isolation_shader_fini(adev);
+       amdgpu_gfx_sysfs_fini(adev);
 
        kfree(adev->gfx.ip_dump_core);
        kfree(adev->gfx.ip_dump_compute_queues);
index 894fc04201c3ab4173953b293e340886032c2623..cfe17a36b8ee4eadf399f14e0966d3f2ac9a2660 100644 (file)
@@ -1708,7 +1708,7 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block *ip_block)
 
        gfx_v11_0_alloc_ip_dump(adev);
 
-       r = amdgpu_gfx_sysfs_isolation_shader_init(adev);
+       r = amdgpu_gfx_sysfs_init(adev);
        if (r)
                return r;
 
@@ -1773,7 +1773,7 @@ static int gfx_v11_0_sw_fini(struct amdgpu_ip_block *ip_block)
 
        gfx_v11_0_free_microcode(adev);
 
-       amdgpu_gfx_sysfs_isolation_shader_fini(adev);
+       amdgpu_gfx_sysfs_fini(adev);
 
        kfree(adev->gfx.ip_dump_core);
        kfree(adev->gfx.ip_dump_compute_queues);
index 9fec28d8a5fcaf03b1f7c4421eb6d999b8c33bee..1b99f90cd19340b989c70c078adf1613a369449b 100644 (file)
@@ -1466,7 +1466,7 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block)
 
        gfx_v12_0_alloc_ip_dump(adev);
 
-       r = amdgpu_gfx_sysfs_isolation_shader_init(adev);
+       r = amdgpu_gfx_sysfs_init(adev);
        if (r)
                return r;
 
@@ -1529,7 +1529,7 @@ static int gfx_v12_0_sw_fini(struct amdgpu_ip_block *ip_block)
 
        gfx_v12_0_free_microcode(adev);
 
-       amdgpu_gfx_sysfs_isolation_shader_fini(adev);
+       amdgpu_gfx_sysfs_fini(adev);
 
        kfree(adev->gfx.ip_dump_core);
        kfree(adev->gfx.ip_dump_compute_queues);
index e9248a855ba7700c428b705a47f1c30ac46b8a6f..a880dce16ae2f7b39156d46423f1879a58e23a13 100644 (file)
@@ -2402,7 +2402,7 @@ static int gfx_v9_0_sw_init(struct amdgpu_ip_block *ip_block)
 
        gfx_v9_0_alloc_ip_dump(adev);
 
-       r = amdgpu_gfx_sysfs_isolation_shader_init(adev);
+       r = amdgpu_gfx_sysfs_init(adev);
        if (r)
                return r;
 
@@ -2443,7 +2443,7 @@ static int gfx_v9_0_sw_fini(struct amdgpu_ip_block *ip_block)
        }
        gfx_v9_0_free_microcode(adev);
 
-       amdgpu_gfx_sysfs_isolation_shader_fini(adev);
+       amdgpu_gfx_sysfs_fini(adev);
 
        kfree(adev->gfx.ip_dump_core);
        kfree(adev->gfx.ip_dump_compute_queues);
index 016290f005922d352662b8fcf98caef3d105d5a6..983088805c3a260362411d0de8175205c5ea10fa 100644 (file)
@@ -1171,10 +1171,6 @@ static int gfx_v9_4_3_sw_init(struct amdgpu_ip_block *ip_block)
 
        gfx_v9_4_3_alloc_ip_dump(adev);
 
-       r = amdgpu_gfx_sysfs_isolation_shader_init(adev);
-       if (r)
-               return r;
-
        return 0;
 }
 
@@ -1199,7 +1195,6 @@ static int gfx_v9_4_3_sw_fini(struct amdgpu_ip_block *ip_block)
        amdgpu_bo_unref(&adev->gfx.rlc.clear_state_obj);
        gfx_v9_4_3_free_microcode(adev);
        amdgpu_gfx_sysfs_fini(adev);
-       amdgpu_gfx_sysfs_isolation_shader_fini(adev);
 
        kfree(adev->gfx.ip_dump_core);
        kfree(adev->gfx.ip_dump_compute_queues);
This page took 0.071923 seconds and 4 git commands to generate.