Skip to content

Commit 047767d

Browse files
Lijo Lazaralexdeucher
authored andcommitted
drm/amdgpu: Group gfx sysfs functions
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]>
1 parent 12e5df8 commit 047767d

File tree

7 files changed

+40
-24
lines changed

7 files changed

+40
-24
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.c

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1602,7 +1602,7 @@ static DEVICE_ATTR(current_compute_partition, 0644,
16021602
static DEVICE_ATTR(available_compute_partition, 0444,
16031603
amdgpu_gfx_get_available_compute_partition, NULL);
16041604

1605-
int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev)
1605+
static int amdgpu_gfx_sysfs_xcp_init(struct amdgpu_device *adev)
16061606
{
16071607
struct amdgpu_xcp_mgr *xcp_mgr = adev->xcp_mgr;
16081608
bool xcp_switch_supported;
@@ -1629,7 +1629,7 @@ int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev)
16291629
return r;
16301630
}
16311631

1632-
void amdgpu_gfx_sysfs_fini(struct amdgpu_device *adev)
1632+
static void amdgpu_gfx_sysfs_xcp_fini(struct amdgpu_device *adev)
16331633
{
16341634
struct amdgpu_xcp_mgr *xcp_mgr = adev->xcp_mgr;
16351635
bool xcp_switch_supported;
@@ -1646,25 +1646,47 @@ void amdgpu_gfx_sysfs_fini(struct amdgpu_device *adev)
16461646
&dev_attr_available_compute_partition);
16471647
}
16481648

1649-
int amdgpu_gfx_sysfs_isolation_shader_init(struct amdgpu_device *adev)
1649+
static int amdgpu_gfx_sysfs_isolation_shader_init(struct amdgpu_device *adev)
16501650
{
16511651
int r;
16521652

16531653
r = device_create_file(adev->dev, &dev_attr_enforce_isolation);
16541654
if (r)
16551655
return r;
1656+
if (adev->gfx.enable_cleaner_shader)
1657+
r = device_create_file(adev->dev, &dev_attr_run_cleaner_shader);
16561658

1657-
r = device_create_file(adev->dev, &dev_attr_run_cleaner_shader);
1658-
if (r)
1659+
return r;
1660+
}
1661+
1662+
static void amdgpu_gfx_sysfs_isolation_shader_fini(struct amdgpu_device *adev)
1663+
{
1664+
device_remove_file(adev->dev, &dev_attr_enforce_isolation);
1665+
if (adev->gfx.enable_cleaner_shader)
1666+
device_remove_file(adev->dev, &dev_attr_run_cleaner_shader);
1667+
}
1668+
1669+
int amdgpu_gfx_sysfs_init(struct amdgpu_device *adev)
1670+
{
1671+
int r;
1672+
1673+
r = amdgpu_gfx_sysfs_xcp_init(adev);
1674+
if (r) {
1675+
dev_err(adev->dev, "failed to create xcp sysfs files");
16591676
return r;
1677+
}
16601678

1661-
return 0;
1679+
r = amdgpu_gfx_sysfs_isolation_shader_init(adev);
1680+
if (r)
1681+
dev_err(adev->dev, "failed to create isolation sysfs files");
1682+
1683+
return r;
16621684
}
16631685

1664-
void amdgpu_gfx_sysfs_isolation_shader_fini(struct amdgpu_device *adev)
1686+
void amdgpu_gfx_sysfs_fini(struct amdgpu_device *adev)
16651687
{
1666-
device_remove_file(adev->dev, &dev_attr_enforce_isolation);
1667-
device_remove_file(adev->dev, &dev_attr_run_cleaner_shader);
1688+
amdgpu_gfx_sysfs_xcp_fini(adev);
1689+
amdgpu_gfx_sysfs_isolation_shader_fini(adev);
16681690
}
16691691

16701692
int amdgpu_gfx_cleaner_shader_sw_init(struct amdgpu_device *adev,

drivers/gpu/drm/amd/amdgpu/amdgpu_gfx.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,6 @@ void amdgpu_gfx_cleaner_shader_sw_fini(struct amdgpu_device *adev);
579579
void amdgpu_gfx_cleaner_shader_init(struct amdgpu_device *adev,
580580
unsigned int cleaner_shader_size,
581581
const void *cleaner_shader_ptr);
582-
int amdgpu_gfx_sysfs_isolation_shader_init(struct amdgpu_device *adev);
583-
void amdgpu_gfx_sysfs_isolation_shader_fini(struct amdgpu_device *adev);
584582
void amdgpu_gfx_enforce_isolation_handler(struct work_struct *work);
585583
void amdgpu_gfx_enforce_isolation_ring_begin_use(struct amdgpu_ring *ring);
586584
void amdgpu_gfx_enforce_isolation_ring_end_use(struct amdgpu_ring *ring);

drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4853,9 +4853,10 @@ static int gfx_v10_0_sw_init(struct amdgpu_ip_block *ip_block)
48534853

48544854
gfx_v10_0_alloc_ip_dump(adev);
48554855

4856-
r = amdgpu_gfx_sysfs_isolation_shader_init(adev);
4856+
r = amdgpu_gfx_sysfs_init(adev);
48574857
if (r)
48584858
return r;
4859+
48594860
return 0;
48604861
}
48614862

@@ -4907,7 +4908,7 @@ static int gfx_v10_0_sw_fini(struct amdgpu_ip_block *ip_block)
49074908
gfx_v10_0_rlc_backdoor_autoload_buffer_fini(adev);
49084909

49094910
gfx_v10_0_free_microcode(adev);
4910-
amdgpu_gfx_sysfs_isolation_shader_fini(adev);
4911+
amdgpu_gfx_sysfs_fini(adev);
49114912

49124913
kfree(adev->gfx.ip_dump_core);
49134914
kfree(adev->gfx.ip_dump_compute_queues);

drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1708,7 +1708,7 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block *ip_block)
17081708

17091709
gfx_v11_0_alloc_ip_dump(adev);
17101710

1711-
r = amdgpu_gfx_sysfs_isolation_shader_init(adev);
1711+
r = amdgpu_gfx_sysfs_init(adev);
17121712
if (r)
17131713
return r;
17141714

@@ -1773,7 +1773,7 @@ static int gfx_v11_0_sw_fini(struct amdgpu_ip_block *ip_block)
17731773

17741774
gfx_v11_0_free_microcode(adev);
17751775

1776-
amdgpu_gfx_sysfs_isolation_shader_fini(adev);
1776+
amdgpu_gfx_sysfs_fini(adev);
17771777

17781778
kfree(adev->gfx.ip_dump_core);
17791779
kfree(adev->gfx.ip_dump_compute_queues);

drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1466,7 +1466,7 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block)
14661466

14671467
gfx_v12_0_alloc_ip_dump(adev);
14681468

1469-
r = amdgpu_gfx_sysfs_isolation_shader_init(adev);
1469+
r = amdgpu_gfx_sysfs_init(adev);
14701470
if (r)
14711471
return r;
14721472

@@ -1529,7 +1529,7 @@ static int gfx_v12_0_sw_fini(struct amdgpu_ip_block *ip_block)
15291529

15301530
gfx_v12_0_free_microcode(adev);
15311531

1532-
amdgpu_gfx_sysfs_isolation_shader_fini(adev);
1532+
amdgpu_gfx_sysfs_fini(adev);
15331533

15341534
kfree(adev->gfx.ip_dump_core);
15351535
kfree(adev->gfx.ip_dump_compute_queues);

drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2402,7 +2402,7 @@ static int gfx_v9_0_sw_init(struct amdgpu_ip_block *ip_block)
24022402

24032403
gfx_v9_0_alloc_ip_dump(adev);
24042404

2405-
r = amdgpu_gfx_sysfs_isolation_shader_init(adev);
2405+
r = amdgpu_gfx_sysfs_init(adev);
24062406
if (r)
24072407
return r;
24082408

@@ -2443,7 +2443,7 @@ static int gfx_v9_0_sw_fini(struct amdgpu_ip_block *ip_block)
24432443
}
24442444
gfx_v9_0_free_microcode(adev);
24452445

2446-
amdgpu_gfx_sysfs_isolation_shader_fini(adev);
2446+
amdgpu_gfx_sysfs_fini(adev);
24472447

24482448
kfree(adev->gfx.ip_dump_core);
24492449
kfree(adev->gfx.ip_dump_compute_queues);

drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,10 +1171,6 @@ static int gfx_v9_4_3_sw_init(struct amdgpu_ip_block *ip_block)
11711171

11721172
gfx_v9_4_3_alloc_ip_dump(adev);
11731173

1174-
r = amdgpu_gfx_sysfs_isolation_shader_init(adev);
1175-
if (r)
1176-
return r;
1177-
11781174
return 0;
11791175
}
11801176

@@ -1199,7 +1195,6 @@ static int gfx_v9_4_3_sw_fini(struct amdgpu_ip_block *ip_block)
11991195
amdgpu_bo_unref(&adev->gfx.rlc.clear_state_obj);
12001196
gfx_v9_4_3_free_microcode(adev);
12011197
amdgpu_gfx_sysfs_fini(adev);
1202-
amdgpu_gfx_sysfs_isolation_shader_fini(adev);
12031198

12041199
kfree(adev->gfx.ip_dump_core);
12051200
kfree(adev->gfx.ip_dump_compute_queues);

0 commit comments

Comments
 (0)