@@ -411,19 +411,16 @@ static const struct attribute_group amdgpu_board_attrs_group = {
411411
412412static void amdgpu_device_get_pcie_info (struct amdgpu_device * adev );
413413
414-
415414/**
416415 * amdgpu_device_supports_px - Is the device a dGPU with ATPX power control
417416 *
418- * @dev: drm_device pointer
417+ * @adev: amdgpu device pointer
419418 *
420419 * Returns true if the device is a dGPU with ATPX power control,
421420 * otherwise return false.
422421 */
423- bool amdgpu_device_supports_px (struct drm_device * dev )
422+ bool amdgpu_device_supports_px (struct amdgpu_device * adev )
424423{
425- struct amdgpu_device * adev = drm_to_adev (dev );
426-
427424 if ((adev -> flags & AMD_IS_PX ) && !amdgpu_is_atpx_hybrid ())
428425 return true;
429426 return false;
@@ -432,15 +429,13 @@ bool amdgpu_device_supports_px(struct drm_device *dev)
432429/**
433430 * amdgpu_device_supports_boco - Is the device a dGPU with ACPI power resources
434431 *
435- * @dev: drm_device pointer
432+ * @adev: amdgpu device pointer
436433 *
437434 * Returns true if the device is a dGPU with ACPI power control,
438435 * otherwise return false.
439436 */
440- bool amdgpu_device_supports_boco (struct drm_device * dev )
437+ bool amdgpu_device_supports_boco (struct amdgpu_device * adev )
441438{
442- struct amdgpu_device * adev = drm_to_adev (dev );
443-
444439 if (!IS_ENABLED (CONFIG_HOTPLUG_PCI_PCIE ))
445440 return false;
446441
@@ -453,29 +448,24 @@ bool amdgpu_device_supports_boco(struct drm_device *dev)
453448/**
454449 * amdgpu_device_supports_baco - Does the device support BACO
455450 *
456- * @dev: drm_device pointer
451+ * @adev: amdgpu device pointer
457452 *
458453 * Return:
459454 * 1 if the device supports BACO;
460455 * 3 if the device supports MACO (only works if BACO is supported)
461456 * otherwise return 0.
462457 */
463- int amdgpu_device_supports_baco (struct drm_device * dev )
458+ int amdgpu_device_supports_baco (struct amdgpu_device * adev )
464459{
465- struct amdgpu_device * adev = drm_to_adev (dev );
466-
467460 return amdgpu_asic_supports_baco (adev );
468461}
469462
470463void amdgpu_device_detect_runtime_pm_mode (struct amdgpu_device * adev )
471464{
472- struct drm_device * dev ;
473465 int bamaco_support ;
474466
475- dev = adev_to_drm (adev );
476-
477467 adev -> pm .rpm_mode = AMDGPU_RUNPM_NONE ;
478- bamaco_support = amdgpu_device_supports_baco (dev );
468+ bamaco_support = amdgpu_device_supports_baco (adev );
479469
480470 switch (amdgpu_runtime_pm ) {
481471 case 2 :
@@ -495,10 +485,12 @@ void amdgpu_device_detect_runtime_pm_mode(struct amdgpu_device *adev)
495485 break ;
496486 case -1 :
497487 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 */
499490 adev -> pm .rpm_mode = AMDGPU_RUNPM_PX ;
500491 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 */
502494 adev -> pm .rpm_mode = AMDGPU_RUNPM_BOCO ;
503495 dev_info (adev -> dev , "Using BOCO for runtime pm\n" );
504496 } else {
@@ -547,14 +539,14 @@ void amdgpu_device_detect_runtime_pm_mode(struct amdgpu_device *adev)
547539 * amdgpu_device_supports_smart_shift - Is the device dGPU with
548540 * smart shift support
549541 *
550- * @dev: drm_device pointer
542+ * @adev: amdgpu device pointer
551543 *
552544 * Returns true if the device is a dGPU with Smart Shift support,
553545 * otherwise returns false.
554546 */
555- bool amdgpu_device_supports_smart_shift (struct drm_device * dev )
547+ bool amdgpu_device_supports_smart_shift (struct amdgpu_device * adev )
556548{
557- return (amdgpu_device_supports_boco (dev ) &&
549+ return (amdgpu_device_supports_boco (adev ) &&
558550 amdgpu_acpi_is_power_shift_control_supported ());
559551}
560552
@@ -2200,7 +2192,8 @@ static void amdgpu_switcheroo_set_state(struct pci_dev *pdev,
22002192 struct drm_device * dev = pci_get_drvdata (pdev );
22012193 int r ;
22022194
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 )
22042197 return ;
22052198
22062199 if (state == VGA_SWITCHEROO_ON ) {
@@ -4192,13 +4185,13 @@ static void amdgpu_device_xgmi_reset_func(struct work_struct *__work)
41924185 if (amdgpu_asic_reset_method (adev ) == AMD_RESET_METHOD_BACO ) {
41934186
41944187 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 );
41964189
41974190 if (adev -> asic_reset_res )
41984191 goto fail ;
41994192
42004193 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 );
42024195
42034196 if (adev -> asic_reset_res )
42044197 goto fail ;
@@ -4353,7 +4346,6 @@ static void amdgpu_device_set_mcbp(struct amdgpu_device *adev)
43534346int amdgpu_device_init (struct amdgpu_device * adev ,
43544347 uint32_t flags )
43554348{
4356- struct drm_device * ddev = adev_to_drm (adev );
43574349 struct pci_dev * pdev = adev -> pdev ;
43584350 int r , i ;
43594351 bool px = false;
@@ -4814,7 +4806,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
48144806 if ((adev -> pdev -> class >> 8 ) == PCI_CLASS_DISPLAY_VGA )
48154807 vga_client_register (adev -> pdev , amdgpu_device_vga_set_decode );
48164808
4817- px = amdgpu_device_supports_px (ddev );
4809+ px = amdgpu_device_supports_px (adev );
48184810
48194811 if (px || (!dev_is_removable (& adev -> pdev -> dev ) &&
48204812 apple_gmux_detect (NULL , NULL )))
@@ -4980,7 +4972,7 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
49804972 kfree (adev -> xcp_mgr );
49814973 adev -> xcp_mgr = NULL ;
49824974
4983- px = amdgpu_device_supports_px (adev_to_drm ( adev ) );
4975+ px = amdgpu_device_supports_px (adev );
49844976
49854977 if (px || (!dev_is_removable (& adev -> pdev -> dev ) &&
49864978 apple_gmux_detect (NULL , NULL )))
@@ -5152,7 +5144,7 @@ int amdgpu_device_suspend(struct drm_device *dev, bool notify_clients)
51525144 return r ;
51535145 }
51545146
5155- if (amdgpu_acpi_smart_shift_update (dev , AMDGPU_SS_DEV_D3 ))
5147+ if (amdgpu_acpi_smart_shift_update (adev , AMDGPU_SS_DEV_D3 ))
51565148 dev_warn (adev -> dev , "smart shift update failed\n" );
51575149
51585150 if (notify_clients )
@@ -5321,7 +5313,7 @@ int amdgpu_device_resume(struct drm_device *dev, bool notify_clients)
53215313 }
53225314 adev -> in_suspend = false;
53235315
5324- if (amdgpu_acpi_smart_shift_update (dev , AMDGPU_SS_DEV_D0 ))
5316+ if (amdgpu_acpi_smart_shift_update (adev , AMDGPU_SS_DEV_D0 ))
53255317 dev_warn (adev -> dev , "smart shift update failed\n" );
53265318
53275319 return 0 ;
@@ -6365,7 +6357,8 @@ static int amdgpu_device_sched_resume(struct list_head *device_list,
63656357 amdgpu_vf_error_put (tmp_adev , AMDGIM_ERROR_VF_GPU_RESET_FAIL , 0 , r );
63666358 } else {
63676359 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 ))
63696362 dev_warn (tmp_adev -> dev ,
63706363 "smart shift update failed\n" );
63716364 }
@@ -6839,12 +6832,11 @@ bool amdgpu_device_is_peer_accessible(struct amdgpu_device *adev,
68396832#endif
68406833}
68416834
6842- int amdgpu_device_baco_enter (struct drm_device * dev )
6835+ int amdgpu_device_baco_enter (struct amdgpu_device * adev )
68436836{
6844- struct amdgpu_device * adev = drm_to_adev (dev );
68456837 struct amdgpu_ras * ras = amdgpu_ras_get_context (adev );
68466838
6847- if (!amdgpu_device_supports_baco (dev ))
6839+ if (!amdgpu_device_supports_baco (adev ))
68486840 return - ENOTSUPP ;
68496841
68506842 if (ras && adev -> ras_enabled &&
@@ -6854,13 +6846,12 @@ int amdgpu_device_baco_enter(struct drm_device *dev)
68546846 return amdgpu_dpm_baco_enter (adev );
68556847}
68566848
6857- int amdgpu_device_baco_exit (struct drm_device * dev )
6849+ int amdgpu_device_baco_exit (struct amdgpu_device * adev )
68586850{
6859- struct amdgpu_device * adev = drm_to_adev (dev );
68606851 struct amdgpu_ras * ras = amdgpu_ras_get_context (adev );
68616852 int ret = 0 ;
68626853
6863- if (!amdgpu_device_supports_baco (dev ))
6854+ if (!amdgpu_device_supports_baco (adev ))
68646855 return - ENOTSUPP ;
68656856
68666857 ret = amdgpu_dpm_baco_exit (adev );
0 commit comments