Skip to content

Commit ba7ca97

Browse files
committed
Merge branch 'drm-next-4.19' of git://people.freedesktop.org/~agd5f/linux into drm-next
More features for 4.19: - Use core pcie functionality rather than duplicating our own for pcie gens and lanes - Scheduler function naming cleanups - More documentation - Reworked DC/Powerplay interfaces to improve power savings - Initial stutter mode support for RV (power feature) - Vega12 powerplay updates - GFXOFF fixes - Misc fixes Signed-off-by: Dave Airlie <airlied@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180705221447.2807-1-alexander.deucher@amd.com
2 parents 61a3a9d + 43911fb commit ba7ca97

137 files changed

Lines changed: 4229 additions & 2873 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/gpu/amdgpu.rst‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
The drm/amdgpu driver supports all AMD Radeon GPUs based on the Graphics Core
66
Next (GCN) architecture.
77

8+
Module Parameters
9+
=================
10+
11+
The amdgpu driver supports the following module parameters:
12+
13+
.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
14+
815
Core Driver Infrastructure
916
==========================
1017

@@ -115,3 +122,8 @@ pp_power_profile_mode
115122
.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
116123
:doc: pp_power_profile_mode
117124

125+
busy_percent
126+
~~~~~~~~~~~~
127+
128+
.. kernel-doc:: drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
129+
:doc: busy_percent

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

Lines changed: 16 additions & 39 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,
@@ -683,8 +684,8 @@ int amdgpu_ctx_ioctl(struct drm_device *dev, void *data,
683684
int amdgpu_ctx_wait_prev_fence(struct amdgpu_ctx *ctx, unsigned ring_id);
684685

685686
void amdgpu_ctx_mgr_init(struct amdgpu_ctx_mgr *mgr);
686-
void amdgpu_ctx_mgr_entity_cleanup(struct amdgpu_ctx_mgr *mgr);
687687
void amdgpu_ctx_mgr_entity_fini(struct amdgpu_ctx_mgr *mgr);
688+
void amdgpu_ctx_mgr_entity_flush(struct amdgpu_ctx_mgr *mgr);
688689
void amdgpu_ctx_mgr_fini(struct amdgpu_ctx_mgr *mgr);
689690

690691

@@ -930,6 +931,11 @@ struct amdgpu_ngg {
930931
bool init;
931932
};
932933

934+
struct sq_work {
935+
struct work_struct work;
936+
unsigned ih_data;
937+
};
938+
933939
struct amdgpu_gfx {
934940
struct mutex gpu_clock_mutex;
935941
struct amdgpu_gfx_config config;
@@ -970,6 +976,8 @@ struct amdgpu_gfx {
970976
struct amdgpu_irq_src priv_inst_irq;
971977
struct amdgpu_irq_src cp_ecc_error_irq;
972978
struct amdgpu_irq_src sq_irq;
979+
struct sq_work sq_work;
980+
973981
/* gfx status */
974982
uint32_t gfx_current_status;
975983
/* ce ram size*/
@@ -1271,43 +1279,6 @@ struct amdgpu_vram_scratch {
12711279
/*
12721280
* ACPI
12731281
*/
1274-
struct amdgpu_atif_notification_cfg {
1275-
bool enabled;
1276-
int command_code;
1277-
};
1278-
1279-
struct amdgpu_atif_notifications {
1280-
bool display_switch;
1281-
bool expansion_mode_change;
1282-
bool thermal_state;
1283-
bool forced_power_state;
1284-
bool system_power_state;
1285-
bool display_conf_change;
1286-
bool px_gfx_switch;
1287-
bool brightness_change;
1288-
bool dgpu_display_event;
1289-
};
1290-
1291-
struct amdgpu_atif_functions {
1292-
bool system_params;
1293-
bool sbios_requests;
1294-
bool select_active_disp;
1295-
bool lid_state;
1296-
bool get_tv_standard;
1297-
bool set_tv_standard;
1298-
bool get_panel_expansion_mode;
1299-
bool set_panel_expansion_mode;
1300-
bool temperature_change;
1301-
bool graphics_device_types;
1302-
};
1303-
1304-
struct amdgpu_atif {
1305-
struct amdgpu_atif_notifications notifications;
1306-
struct amdgpu_atif_functions functions;
1307-
struct amdgpu_atif_notification_cfg notification_cfg;
1308-
struct amdgpu_encoder *encoder_for_bl;
1309-
};
1310-
13111282
struct amdgpu_atcs_functions {
13121283
bool get_ext_state;
13131284
bool pcie_perf_req;
@@ -1468,7 +1439,7 @@ struct amdgpu_device {
14681439
#if defined(CONFIG_DEBUG_FS)
14691440
struct dentry *debugfs_regs[AMDGPU_DEBUGFS_MAX_COMPONENTS];
14701441
#endif
1471-
struct amdgpu_atif atif;
1442+
struct amdgpu_atif *atif;
14721443
struct amdgpu_atcs atcs;
14731444
struct mutex srbm_mutex;
14741445
/* GRBM index mutex. Protects concurrent access to GRBM index */
@@ -1896,6 +1867,12 @@ static inline bool amdgpu_atpx_dgpu_req_power_for_displays(void) { return false;
18961867
static inline bool amdgpu_has_atpx(void) { return false; }
18971868
#endif
18981869

1870+
#if defined(CONFIG_VGA_SWITCHEROO) && defined(CONFIG_ACPI)
1871+
void *amdgpu_atpx_get_dhandle(void);
1872+
#else
1873+
static inline void *amdgpu_atpx_get_dhandle(void) { return NULL; }
1874+
#endif
1875+
18991876
/*
19001877
* KMS
19011878
*/

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

Lines changed: 108 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,45 @@
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+
acpi_handle handle;
69+
70+
struct amdgpu_atif_notifications notifications;
71+
struct amdgpu_atif_functions functions;
72+
struct amdgpu_atif_notification_cfg notification_cfg;
73+
struct amdgpu_encoder *encoder_for_bl;
74+
};
75+
3776
/* Call the ATIF method
3877
*/
3978
/**
@@ -46,8 +85,9 @@
4685
* Executes the requested ATIF function (all asics).
4786
* Returns a pointer to the acpi output buffer.
4887
*/
49-
static union acpi_object *amdgpu_atif_call(acpi_handle handle, int function,
50-
struct acpi_buffer *params)
88+
static union acpi_object *amdgpu_atif_call(struct amdgpu_atif *atif,
89+
int function,
90+
struct acpi_buffer *params)
5191
{
5292
acpi_status status;
5393
union acpi_object atif_arg_elements[2];
@@ -70,7 +110,8 @@ static union acpi_object *amdgpu_atif_call(acpi_handle handle, int function,
70110
atif_arg_elements[1].integer.value = 0;
71111
}
72112

73-
status = acpi_evaluate_object(handle, "ATIF", &atif_arg, &buffer);
113+
status = acpi_evaluate_object(atif->handle, NULL, &atif_arg,
114+
&buffer);
74115

75116
/* Fail only if calling the method fails and ATIF is supported */
76117
if (ACPI_FAILURE(status) && status != AE_NOT_FOUND) {
@@ -141,15 +182,14 @@ static void amdgpu_atif_parse_functions(struct amdgpu_atif_functions *f, u32 mas
141182
* (all asics).
142183
* returns 0 on success, error on failure.
143184
*/
144-
static int amdgpu_atif_verify_interface(acpi_handle handle,
145-
struct amdgpu_atif *atif)
185+
static int amdgpu_atif_verify_interface(struct amdgpu_atif *atif)
146186
{
147187
union acpi_object *info;
148188
struct atif_verify_interface output;
149189
size_t size;
150190
int err = 0;
151191

152-
info = amdgpu_atif_call(handle, ATIF_FUNCTION_VERIFY_INTERFACE, NULL);
192+
info = amdgpu_atif_call(atif, ATIF_FUNCTION_VERIFY_INTERFACE, NULL);
153193
if (!info)
154194
return -EIO;
155195

@@ -176,6 +216,35 @@ static int amdgpu_atif_verify_interface(acpi_handle handle,
176216
return err;
177217
}
178218

219+
static acpi_handle amdgpu_atif_probe_handle(acpi_handle dhandle)
220+
{
221+
acpi_handle handle = NULL;
222+
char acpi_method_name[255] = { 0 };
223+
struct acpi_buffer buffer = { sizeof(acpi_method_name), acpi_method_name };
224+
acpi_status status;
225+
226+
/* For PX/HG systems, ATIF and ATPX are in the iGPU's namespace, on dGPU only
227+
* systems, ATIF is in the dGPU's namespace.
228+
*/
229+
status = acpi_get_handle(dhandle, "ATIF", &handle);
230+
if (ACPI_SUCCESS(status))
231+
goto out;
232+
233+
if (amdgpu_has_atpx()) {
234+
status = acpi_get_handle(amdgpu_atpx_get_dhandle(), "ATIF",
235+
&handle);
236+
if (ACPI_SUCCESS(status))
237+
goto out;
238+
}
239+
240+
DRM_DEBUG_DRIVER("No ATIF handle found\n");
241+
return NULL;
242+
out:
243+
acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
244+
DRM_DEBUG_DRIVER("Found ATIF handle %s\n", acpi_method_name);
245+
return handle;
246+
}
247+
179248
/**
180249
* amdgpu_atif_get_notification_params - determine notify configuration
181250
*
@@ -188,15 +257,16 @@ static int amdgpu_atif_verify_interface(acpi_handle handle,
188257
* where n is specified in the result if a notifier is used.
189258
* Returns 0 on success, error on failure.
190259
*/
191-
static int amdgpu_atif_get_notification_params(acpi_handle handle,
192-
struct amdgpu_atif_notification_cfg *n)
260+
static int amdgpu_atif_get_notification_params(struct amdgpu_atif *atif)
193261
{
194262
union acpi_object *info;
263+
struct amdgpu_atif_notification_cfg *n = &atif->notification_cfg;
195264
struct atif_system_params params;
196265
size_t size;
197266
int err = 0;
198267

199-
info = amdgpu_atif_call(handle, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS, NULL);
268+
info = amdgpu_atif_call(atif, ATIF_FUNCTION_GET_SYSTEM_PARAMETERS,
269+
NULL);
200270
if (!info) {
201271
err = -EIO;
202272
goto out;
@@ -250,14 +320,15 @@ static int amdgpu_atif_get_notification_params(acpi_handle handle,
250320
* (all asics).
251321
* Returns 0 on success, error on failure.
252322
*/
253-
static int amdgpu_atif_get_sbios_requests(acpi_handle handle,
254-
struct atif_sbios_requests *req)
323+
static int amdgpu_atif_get_sbios_requests(struct amdgpu_atif *atif,
324+
struct atif_sbios_requests *req)
255325
{
256326
union acpi_object *info;
257327
size_t size;
258328
int count = 0;
259329

260-
info = amdgpu_atif_call(handle, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS, NULL);
330+
info = amdgpu_atif_call(atif, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS,
331+
NULL);
261332
if (!info)
262333
return -EIO;
263334

@@ -290,11 +361,10 @@ static int amdgpu_atif_get_sbios_requests(acpi_handle handle,
290361
* Returns NOTIFY code
291362
*/
292363
static int amdgpu_atif_handler(struct amdgpu_device *adev,
293-
struct acpi_bus_event *event)
364+
struct acpi_bus_event *event)
294365
{
295-
struct amdgpu_atif *atif = &adev->atif;
366+
struct amdgpu_atif *atif = adev->atif;
296367
struct atif_sbios_requests req;
297-
acpi_handle handle;
298368
int count;
299369

300370
DRM_DEBUG_DRIVER("event, device_class = %s, type = %#x\n",
@@ -303,14 +373,14 @@ static int amdgpu_atif_handler(struct amdgpu_device *adev,
303373
if (strcmp(event->device_class, ACPI_VIDEO_CLASS) != 0)
304374
return NOTIFY_DONE;
305375

306-
if (!atif->notification_cfg.enabled ||
376+
if (!atif ||
377+
!atif->notification_cfg.enabled ||
307378
event->type != atif->notification_cfg.command_code)
308379
/* Not our event */
309380
return NOTIFY_DONE;
310381

311382
/* Check pending SBIOS requests */
312-
handle = ACPI_HANDLE(&adev->pdev->dev);
313-
count = amdgpu_atif_get_sbios_requests(handle, &req);
383+
count = amdgpu_atif_get_sbios_requests(atif, &req);
314384

315385
if (count <= 0)
316386
return NOTIFY_DONE;
@@ -641,8 +711,8 @@ static int amdgpu_acpi_event(struct notifier_block *nb,
641711
*/
642712
int amdgpu_acpi_init(struct amdgpu_device *adev)
643713
{
644-
acpi_handle handle;
645-
struct amdgpu_atif *atif = &adev->atif;
714+
acpi_handle handle, atif_handle;
715+
struct amdgpu_atif *atif;
646716
struct amdgpu_atcs *atcs = &adev->atcs;
647717
int ret;
648718

@@ -658,12 +728,26 @@ int amdgpu_acpi_init(struct amdgpu_device *adev)
658728
DRM_DEBUG_DRIVER("Call to ATCS verify_interface failed: %d\n", ret);
659729
}
660730

731+
/* Probe for ATIF, and initialize it if found */
732+
atif_handle = amdgpu_atif_probe_handle(handle);
733+
if (!atif_handle)
734+
goto out;
735+
736+
atif = kzalloc(sizeof(*atif), GFP_KERNEL);
737+
if (!atif) {
738+
DRM_WARN("Not enough memory to initialize ATIF\n");
739+
goto out;
740+
}
741+
atif->handle = atif_handle;
742+
661743
/* Call the ATIF method */
662-
ret = amdgpu_atif_verify_interface(handle, atif);
744+
ret = amdgpu_atif_verify_interface(atif);
663745
if (ret) {
664746
DRM_DEBUG_DRIVER("Call to ATIF verify_interface failed: %d\n", ret);
747+
kfree(atif);
665748
goto out;
666749
}
750+
adev->atif = atif;
667751

668752
if (atif->notifications.brightness_change) {
669753
struct drm_encoder *tmp;
@@ -693,8 +777,7 @@ int amdgpu_acpi_init(struct amdgpu_device *adev)
693777
}
694778

695779
if (atif->functions.system_params) {
696-
ret = amdgpu_atif_get_notification_params(handle,
697-
&atif->notification_cfg);
780+
ret = amdgpu_atif_get_notification_params(atif);
698781
if (ret) {
699782
DRM_DEBUG_DRIVER("Call to GET_SYSTEM_PARAMS failed: %d\n",
700783
ret);
@@ -720,4 +803,6 @@ int amdgpu_acpi_init(struct amdgpu_device *adev)
720803
void amdgpu_acpi_fini(struct amdgpu_device *adev)
721804
{
722805
unregister_acpi_notifier(&adev->acpi_nb);
806+
if (adev->atif)
807+
kfree(adev->atif);
723808
}

0 commit comments

Comments
 (0)