@@ -411,19 +411,16 @@ static const struct attribute_group amdgpu_board_attrs_group = {
411
411
412
412
static void amdgpu_device_get_pcie_info (struct amdgpu_device * adev );
413
413
414
-
415
414
/**
416
415
* amdgpu_device_supports_px - Is the device a dGPU with ATPX power control
417
416
*
418
- * @dev: drm_device pointer
417
+ * @adev: amdgpu device pointer
419
418
*
420
419
* Returns true if the device is a dGPU with ATPX power control,
421
420
* otherwise return false.
422
421
*/
423
- bool amdgpu_device_supports_px (struct drm_device * dev )
422
+ bool amdgpu_device_supports_px (struct amdgpu_device * adev )
424
423
{
425
- struct amdgpu_device * adev = drm_to_adev (dev );
426
-
427
424
if ((adev -> flags & AMD_IS_PX ) && !amdgpu_is_atpx_hybrid ())
428
425
return true;
429
426
return false;
@@ -432,15 +429,13 @@ bool amdgpu_device_supports_px(struct drm_device *dev)
432
429
/**
433
430
* amdgpu_device_supports_boco - Is the device a dGPU with ACPI power resources
434
431
*
435
- * @dev: drm_device pointer
432
+ * @adev: amdgpu device pointer
436
433
*
437
434
* Returns true if the device is a dGPU with ACPI power control,
438
435
* otherwise return false.
439
436
*/
440
- bool amdgpu_device_supports_boco (struct drm_device * dev )
437
+ bool amdgpu_device_supports_boco (struct amdgpu_device * adev )
441
438
{
442
- struct amdgpu_device * adev = drm_to_adev (dev );
443
-
444
439
if (!IS_ENABLED (CONFIG_HOTPLUG_PCI_PCIE ))
445
440
return false;
446
441
@@ -453,29 +448,24 @@ bool amdgpu_device_supports_boco(struct drm_device *dev)
453
448
/**
454
449
* amdgpu_device_supports_baco - Does the device support BACO
455
450
*
456
- * @dev: drm_device pointer
451
+ * @adev: amdgpu device pointer
457
452
*
458
453
* Return:
459
454
* 1 if the device supports BACO;
460
455
* 3 if the device supports MACO (only works if BACO is supported)
461
456
* otherwise return 0.
462
457
*/
463
- int amdgpu_device_supports_baco (struct drm_device * dev )
458
+ int amdgpu_device_supports_baco (struct amdgpu_device * adev )
464
459
{
465
- struct amdgpu_device * adev = drm_to_adev (dev );
466
-
467
460
return amdgpu_asic_supports_baco (adev );
468
461
}
469
462
470
463
void amdgpu_device_detect_runtime_pm_mode (struct amdgpu_device * adev )
471
464
{
472
- struct drm_device * dev ;
473
465
int bamaco_support ;
474
466
475
- dev = adev_to_drm (adev );
476
-
477
467
adev -> pm .rpm_mode = AMDGPU_RUNPM_NONE ;
478
- bamaco_support = amdgpu_device_supports_baco (dev );
468
+ bamaco_support = amdgpu_device_supports_baco (adev );
479
469
480
470
switch (amdgpu_runtime_pm ) {
481
471
case 2 :
@@ -495,10 +485,12 @@ void amdgpu_device_detect_runtime_pm_mode(struct amdgpu_device *adev)
495
485
break ;
496
486
case -1 :
497
487
case -2 :
498
- if (amdgpu_device_supports_px (dev )) { /* enable PX as runtime mode */
488
+ if (amdgpu_device_supports_px (adev )) {
489
+ /* enable PX as runtime mode */
499
490
adev -> pm .rpm_mode = AMDGPU_RUNPM_PX ;
500
491
dev_info (adev -> dev , "Using ATPX for runtime pm\n" );
501
- } else if (amdgpu_device_supports_boco (dev )) { /* enable boco as runtime mode */
492
+ } else if (amdgpu_device_supports_boco (adev )) {
493
+ /* enable boco as runtime mode */
502
494
adev -> pm .rpm_mode = AMDGPU_RUNPM_BOCO ;
503
495
dev_info (adev -> dev , "Using BOCO for runtime pm\n" );
504
496
} else {
@@ -547,14 +539,14 @@ void amdgpu_device_detect_runtime_pm_mode(struct amdgpu_device *adev)
547
539
* amdgpu_device_supports_smart_shift - Is the device dGPU with
548
540
* smart shift support
549
541
*
550
- * @dev: drm_device pointer
542
+ * @adev: amdgpu device pointer
551
543
*
552
544
* Returns true if the device is a dGPU with Smart Shift support,
553
545
* otherwise returns false.
554
546
*/
555
- bool amdgpu_device_supports_smart_shift (struct drm_device * dev )
547
+ bool amdgpu_device_supports_smart_shift (struct amdgpu_device * adev )
556
548
{
557
- return (amdgpu_device_supports_boco (dev ) &&
549
+ return (amdgpu_device_supports_boco (adev ) &&
558
550
amdgpu_acpi_is_power_shift_control_supported ());
559
551
}
560
552
@@ -2200,7 +2192,8 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev,
2200
2192
struct drm_device * dev = pci_get_drvdata (pdev );
2201
2193
int r ;
2202
2194
2203
- if (amdgpu_device_supports_px (dev ) && state == VGA_SWITCHEROO_OFF )
2195
+ if (amdgpu_device_supports_px (drm_to_adev (dev )) &&
2196
+ state == VGA_SWITCHEROO_OFF )
2204
2197
return ;
2205
2198
2206
2199
if (state == VGA_SWITCHEROO_ON ) {
@@ -4192,13 +4185,13 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
4192
4185
if (amdgpu_asic_reset_method (adev ) == AMD_RESET_METHOD_BACO ) {
4193
4186
4194
4187
task_barrier_enter (& hive -> tb );
4195
- adev -> asic_reset_res = amdgpu_device_baco_enter (adev_to_drm ( adev ) );
4188
+ adev -> asic_reset_res = amdgpu_device_baco_enter (adev );
4196
4189
4197
4190
if (adev -> asic_reset_res )
4198
4191
goto fail ;
4199
4192
4200
4193
task_barrier_exit (& hive -> tb );
4201
- adev -> asic_reset_res = amdgpu_device_baco_exit (adev_to_drm ( adev ) );
4194
+ adev -> asic_reset_res = amdgpu_device_baco_exit (adev );
4202
4195
4203
4196
if (adev -> asic_reset_res )
4204
4197
goto fail ;
@@ -4353,7 +4346,6 @@ static void amdgpu_device_set_mcbp(struct amdgpu_device *adev)
4353
4346
int amdgpu_device_init (struct amdgpu_device * adev ,
4354
4347
uint32_t flags )
4355
4348
{
4356
- struct drm_device * ddev = adev_to_drm (adev );
4357
4349
struct pci_dev * pdev = adev -> pdev ;
4358
4350
int r , i ;
4359
4351
bool px = false;
@@ -4814,7 +4806,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
4814
4806
if ((adev -> pdev -> class >> 8 ) == PCI_CLASS_DISPLAY_VGA )
4815
4807
vga_client_register (adev -> pdev , amdgpu_device_vga_set_decode );
4816
4808
4817
- px = amdgpu_device_supports_px (ddev );
4809
+ px = amdgpu_device_supports_px (adev );
4818
4810
4819
4811
if (px || (!dev_is_removable (& adev -> pdev -> dev ) &&
4820
4812
apple_gmux_detect (NULL , NULL )))
@@ -4980,7 +4972,7 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
4980
4972
kfree (adev -> xcp_mgr );
4981
4973
adev -> xcp_mgr = NULL ;
4982
4974
4983
- px = amdgpu_device_supports_px (adev_to_drm ( adev ) );
4975
+ px = amdgpu_device_supports_px (adev );
4984
4976
4985
4977
if (px || (!dev_is_removable (& adev -> pdev -> dev ) &&
4986
4978
apple_gmux_detect (NULL , NULL )))
@@ -5152,7 +5144,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool notify_clients)
5152
5144
return r ;
5153
5145
}
5154
5146
5155
- if (amdgpu_acpi_smart_shift_update (dev , AMDGPU_SS_DEV_D3 ))
5147
+ if (amdgpu_acpi_smart_shift_update (adev , AMDGPU_SS_DEV_D3 ))
5156
5148
dev_warn (adev -> dev , "smart shift update failed\n" );
5157
5149
5158
5150
if (notify_clients )
@@ -5321,7 +5313,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool notify_clients)
5321
5313
}
5322
5314
adev -> in_suspend = false;
5323
5315
5324
- if (amdgpu_acpi_smart_shift_update (dev , AMDGPU_SS_DEV_D0 ))
5316
+ if (amdgpu_acpi_smart_shift_update (adev , AMDGPU_SS_DEV_D0 ))
5325
5317
dev_warn (adev -> dev , "smart shift update failed\n" );
5326
5318
5327
5319
return 0 ;
@@ -6365,7 +6357,8 @@ static int amdgpu_device_sched_resume(struct list_head *device_list,
6365
6357
amdgpu_vf_error_put (tmp_adev , AMDGIM_ERROR_VF_GPU_RESET_FAIL , 0 , r );
6366
6358
} else {
6367
6359
dev_info (tmp_adev -> dev , "GPU reset(%d) succeeded!\n" , atomic_read (& tmp_adev -> gpu_reset_counter ));
6368
- if (amdgpu_acpi_smart_shift_update (adev_to_drm (tmp_adev ), AMDGPU_SS_DEV_D0 ))
6360
+ if (amdgpu_acpi_smart_shift_update (tmp_adev ,
6361
+ AMDGPU_SS_DEV_D0 ))
6369
6362
dev_warn (tmp_adev -> dev ,
6370
6363
"smart shift update failed\n" );
6371
6364
}
@@ -6839,12 +6832,11 @@ bool amdgpu_device_is_peer_accessible(struct amdgpu_device *adev,
6839
6832
#endif
6840
6833
}
6841
6834
6842
- int amdgpu_device_baco_enter (struct drm_device * dev )
6835
+ int amdgpu_device_baco_enter (struct amdgpu_device * adev )
6843
6836
{
6844
- struct amdgpu_device * adev = drm_to_adev (dev );
6845
6837
struct amdgpu_ras * ras = amdgpu_ras_get_context (adev );
6846
6838
6847
- if (!amdgpu_device_supports_baco (dev ))
6839
+ if (!amdgpu_device_supports_baco (adev ))
6848
6840
return - ENOTSUPP ;
6849
6841
6850
6842
if (ras && adev -> ras_enabled &&
@@ -6854,13 +6846,12 @@ int amdgpu_device_baco_enter(struct drm_device *dev)
6854
6846
return amdgpu_dpm_baco_enter (adev );
6855
6847
}
6856
6848
6857
- int amdgpu_device_baco_exit (struct drm_device * dev )
6849
+ int amdgpu_device_baco_exit (struct amdgpu_device * adev )
6858
6850
{
6859
- struct amdgpu_device * adev = drm_to_adev (dev );
6860
6851
struct amdgpu_ras * ras = amdgpu_ras_get_context (adev );
6861
6852
int ret = 0 ;
6862
6853
6863
- if (!amdgpu_device_supports_baco (dev ))
6854
+ if (!amdgpu_device_supports_baco (adev ))
6864
6855
return - ENOTSUPP ;
6865
6856
6866
6857
ret = amdgpu_dpm_baco_exit (adev );
0 commit comments