Skip to content

Commit 2cd5fe2

Browse files
Lyudealexdeucher
authored andcommitted
drm/amdgpu: Make struct amdgpu_atif private to amdgpu_acpi.c
Currently, there is nothing in amdgpu that actually uses these structs other than amdgpu_acpi.c. Additionally, since we're about to start saving the correct ACPI handle to use for calling ATIF in this struct this saves us from having to handle making sure that the acpi_handle (and by proxy, the type definition for acpi_handle and all of the other acpi headers) doesn't need to be included within the amdgpu_drv struct itself. This follows the example set by amdgpu_atpx_handler.c. Signed-off-by: Lyude Paul <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected]
1 parent 1513b1c commit 2cd5fe2

File tree

2 files changed

+53
-41
lines changed

2 files changed

+53
-41
lines changed

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

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ struct amdgpu_job;
190190
struct amdgpu_irq_src;
191191
struct amdgpu_fpriv;
192192
struct amdgpu_bo_va_mapping;
193+
struct amdgpu_atif;
193194

194195
enum amdgpu_cp_irq {
195196
AMDGPU_CP_IRQ_GFX_EOP = 0,
@@ -1269,43 +1270,6 @@ struct amdgpu_vram_scratch {
12691270
/*
12701271
* ACPI
12711272
*/
1272-
struct amdgpu_atif_notification_cfg {
1273-
bool enabled;
1274-
int command_code;
1275-
};
1276-
1277-
struct amdgpu_atif_notifications {
1278-
bool display_switch;
1279-
bool expansion_mode_change;
1280-
bool thermal_state;
1281-
bool forced_power_state;
1282-
bool system_power_state;
1283-
bool display_conf_change;
1284-
bool px_gfx_switch;
1285-
bool brightness_change;
1286-
bool dgpu_display_event;
1287-
};
1288-
1289-
struct amdgpu_atif_functions {
1290-
bool system_params;
1291-
bool sbios_requests;
1292-
bool select_active_disp;
1293-
bool lid_state;
1294-
bool get_tv_standard;
1295-
bool set_tv_standard;
1296-
bool get_panel_expansion_mode;
1297-
bool set_panel_expansion_mode;
1298-
bool temperature_change;
1299-
bool graphics_device_types;
1300-
};
1301-
1302-
struct amdgpu_atif {
1303-
struct amdgpu_atif_notifications notifications;
1304-
struct amdgpu_atif_functions functions;
1305-
struct amdgpu_atif_notification_cfg notification_cfg;
1306-
struct amdgpu_encoder *encoder_for_bl;
1307-
};
1308-
13091273
struct amdgpu_atcs_functions {
13101274
bool get_ext_state;
13111275
bool pcie_perf_req;
@@ -1466,7 +1430,7 @@ struct amdgpu_device {
14661430
#if defined(CONFIG_DEBUG_FS)
14671431
struct dentry *debugfs_regs[AMDGPU_DEBUGFS_MAX_COMPONENTS];
14681432
#endif
1469-
struct amdgpu_atif atif;
1433+
struct amdgpu_atif *atif;
14701434
struct amdgpu_atcs atcs;
14711435
struct mutex srbm_mutex;
14721436
/* GRBM index mutex. Protects concurrent access to GRBM index */

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

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,43 @@
3434
#include "amd_acpi.h"
3535
#include "atom.h"
3636

37+
struct amdgpu_atif_notification_cfg {
38+
bool enabled;
39+
int command_code;
40+
};
41+
42+
struct amdgpu_atif_notifications {
43+
bool display_switch;
44+
bool expansion_mode_change;
45+
bool thermal_state;
46+
bool forced_power_state;
47+
bool system_power_state;
48+
bool display_conf_change;
49+
bool px_gfx_switch;
50+
bool brightness_change;
51+
bool dgpu_display_event;
52+
};
53+
54+
struct amdgpu_atif_functions {
55+
bool system_params;
56+
bool sbios_requests;
57+
bool select_active_disp;
58+
bool lid_state;
59+
bool get_tv_standard;
60+
bool set_tv_standard;
61+
bool get_panel_expansion_mode;
62+
bool set_panel_expansion_mode;
63+
bool temperature_change;
64+
bool graphics_device_types;
65+
};
66+
67+
struct amdgpu_atif {
68+
struct amdgpu_atif_notifications notifications;
69+
struct amdgpu_atif_functions functions;
70+
struct amdgpu_atif_notification_cfg notification_cfg;
71+
struct amdgpu_encoder *encoder_for_bl;
72+
};
73+
3774
/* Call the ATIF method
3875
*/
3976
/**
@@ -292,7 +329,7 @@ static int amdgpu_atif_get_sbios_requests(acpi_handle handle,
292329
static int amdgpu_atif_handler(struct amdgpu_device *adev,
293330
struct acpi_bus_event *event)
294331
{
295-
struct amdgpu_atif *atif = &adev->atif;
332+
struct amdgpu_atif *atif = adev->atif;
296333
struct atif_sbios_requests req;
297334
acpi_handle handle;
298335
int count;
@@ -303,7 +340,8 @@ static int amdgpu_atif_handler(struct amdgpu_device *adev,
303340
if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0)
304341
return NOTIFY_DONE;
305342

306-
if (!atif->notification_cfg.enabled ||
343+
if (!atif ||
344+
!atif->notification_cfg.enabled ||
307345
event->type != atif->notification_cfg.command_code)
308346
/* Not our event */
309347
return NOTIFY_DONE;
@@ -642,7 +680,7 @@ static int amdgpu_acpi_event(struct notifier_block *nb,
642680
int amdgpu_acpi_init(struct amdgpu_device *adev)
643681
{
644682
acpi_handle handle;
645-
struct amdgpu_atif *atif = &adev->atif;
683+
struct amdgpu_atif *atif;
646684
struct amdgpu_atcs *atcs = &adev->atcs;
647685
int ret;
648686

@@ -659,11 +697,19 @@ int amdgpu_acpi_init(struct amdgpu_device *adev)
659697
}
660698

661699
/* Call the ATIF method */
700+
atif = kzalloc(sizeof(*atif), GFP_KERNEL);
701+
if (!atif) {
702+
DRM_WARN("Not enough memory to initialize ATIF\n");
703+
goto out;
704+
}
705+
662706
ret = amdgpu_atif_verify_interface(handle, atif);
663707
if (ret) {
664708
DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret);
709+
kfree(atif);
665710
goto out;
666711
}
712+
adev->atif = atif;
667713

668714
if (atif->notifications.brightness_change) {
669715
struct drm_encoder *tmp;
@@ -720,4 +766,6 @@ int amdgpu_acpi_init(struct amdgpu_device *adev)
720766
void amdgpu_acpi_fini(struct amdgpu_device *adev)
721767
{
722768
unregister_acpi_notifier(&adev->acpi_nb);
769+
if (adev->atif)
770+
kfree(adev->atif);
723771
}

0 commit comments

Comments
 (0)