]> Git Repo - linux.git/blobdiff - drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
Merge tag 'linux-kselftest-4.10-rc1-update' of git://git.kernel.org/pub/scm/linux...
[linux.git] / drivers / gpu / drm / amd / amdgpu / amdgpu_pm.c
index accc908bdc880b2bacdc5ba3486b624420a7e2f6..723ae682bf2597b90201fc92e94485eaf77c0f16 100644 (file)
@@ -737,6 +737,21 @@ static ssize_t amdgpu_hwmon_get_pwm1(struct device *dev,
        return sprintf(buf, "%i\n", speed);
 }
 
+static ssize_t amdgpu_hwmon_get_fan1_input(struct device *dev,
+                                          struct device_attribute *attr,
+                                          char *buf)
+{
+       struct amdgpu_device *adev = dev_get_drvdata(dev);
+       int err;
+       u32 speed;
+
+       err = amdgpu_dpm_get_fan_speed_rpm(adev, &speed);
+       if (err)
+               return err;
+
+       return sprintf(buf, "%i\n", speed);
+}
+
 static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, amdgpu_hwmon_show_temp, NULL, 0);
 static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 0);
 static SENSOR_DEVICE_ATTR(temp1_crit_hyst, S_IRUGO, amdgpu_hwmon_show_temp_thresh, NULL, 1);
@@ -744,6 +759,7 @@ static SENSOR_DEVICE_ATTR(pwm1, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1, amdgpu
 static SENSOR_DEVICE_ATTR(pwm1_enable, S_IRUGO | S_IWUSR, amdgpu_hwmon_get_pwm1_enable, amdgpu_hwmon_set_pwm1_enable, 0);
 static SENSOR_DEVICE_ATTR(pwm1_min, S_IRUGO, amdgpu_hwmon_get_pwm1_min, NULL, 0);
 static SENSOR_DEVICE_ATTR(pwm1_max, S_IRUGO, amdgpu_hwmon_get_pwm1_max, NULL, 0);
+static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, amdgpu_hwmon_get_fan1_input, NULL, 0);
 
 static struct attribute *hwmon_attributes[] = {
        &sensor_dev_attr_temp1_input.dev_attr.attr,
@@ -753,6 +769,7 @@ static struct attribute *hwmon_attributes[] = {
        &sensor_dev_attr_pwm1_enable.dev_attr.attr,
        &sensor_dev_attr_pwm1_min.dev_attr.attr,
        &sensor_dev_attr_pwm1_max.dev_attr.attr,
+       &sensor_dev_attr_fan1_input.dev_attr.attr,
        NULL
 };
 
@@ -804,6 +821,10 @@ static umode_t hwmon_attributes_visible(struct kobject *kobj,
             attr == &sensor_dev_attr_pwm1_min.dev_attr.attr))
                return 0;
 
+       /* requires powerplay */
+       if (attr == &sensor_dev_attr_fan1_input.dev_attr.attr)
+               return 0;
+
        return effective_mode;
 }
 
@@ -986,10 +1007,10 @@ restart_search:
 
 static void amdgpu_dpm_change_power_state_locked(struct amdgpu_device *adev)
 {
-       int i;
        struct amdgpu_ps *ps;
        enum amd_pm_state_type dpm_state;
        int ret;
+       bool equal;
 
        /* if dpm init failed */
        if (!adev->pm.dpm_enabled)
@@ -1009,46 +1030,6 @@ static void amdgpu_dpm_change_power_state_locked(struct amdgpu_device *adev)
        else
                return;
 
-       /* no need to reprogram if nothing changed unless we are on BTC+ */
-       if (adev->pm.dpm.current_ps == adev->pm.dpm.requested_ps) {
-               /* vce just modifies an existing state so force a change */
-               if (ps->vce_active != adev->pm.dpm.vce_active)
-                       goto force;
-               if (adev->flags & AMD_IS_APU) {
-                       /* for APUs if the num crtcs changed but state is the same,
-                        * all we need to do is update the display configuration.
-                        */
-                       if (adev->pm.dpm.new_active_crtcs != adev->pm.dpm.current_active_crtcs) {
-                               /* update display watermarks based on new power state */
-                               amdgpu_display_bandwidth_update(adev);
-                               /* update displays */
-                               amdgpu_dpm_display_configuration_changed(adev);
-                               adev->pm.dpm.current_active_crtcs = adev->pm.dpm.new_active_crtcs;
-                               adev->pm.dpm.current_active_crtc_count = adev->pm.dpm.new_active_crtc_count;
-                       }
-                       return;
-               } else {
-                       /* for BTC+ if the num crtcs hasn't changed and state is the same,
-                        * nothing to do, if the num crtcs is > 1 and state is the same,
-                        * update display configuration.
-                        */
-                       if (adev->pm.dpm.new_active_crtcs ==
-                           adev->pm.dpm.current_active_crtcs) {
-                               return;
-                       } else if ((adev->pm.dpm.current_active_crtc_count > 1) &&
-                                  (adev->pm.dpm.new_active_crtc_count > 1)) {
-                               /* update display watermarks based on new power state */
-                               amdgpu_display_bandwidth_update(adev);
-                               /* update displays */
-                               amdgpu_dpm_display_configuration_changed(adev);
-                               adev->pm.dpm.current_active_crtcs = adev->pm.dpm.new_active_crtcs;
-                               adev->pm.dpm.current_active_crtc_count = adev->pm.dpm.new_active_crtc_count;
-                               return;
-                       }
-               }
-       }
-
-force:
        if (amdgpu_dpm == 1) {
                printk("switching from power state:\n");
                amdgpu_dpm_print_power_state(adev, adev->pm.dpm.current_ps);
@@ -1059,31 +1040,21 @@ force:
        /* update whether vce is active */
        ps->vce_active = adev->pm.dpm.vce_active;
 
+       amdgpu_dpm_display_configuration_changed(adev);
+
        ret = amdgpu_dpm_pre_set_power_state(adev);
        if (ret)
                return;
 
-       /* update display watermarks based on new power state */
-       amdgpu_display_bandwidth_update(adev);
+       if ((0 != amgdpu_dpm_check_state_equal(adev, adev->pm.dpm.current_ps, adev->pm.dpm.requested_ps, &equal)))
+               equal = false;
 
-       /* wait for the rings to drain */
-       for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
-               struct amdgpu_ring *ring = adev->rings[i];
-               if (ring && ring->ready)
-                       amdgpu_fence_wait_empty(ring);
-       }
+       if (equal)
+               return;
 
-       /* program the new power state */
        amdgpu_dpm_set_power_state(adev);
-
-       /* update current power state */
-       adev->pm.dpm.current_ps = adev->pm.dpm.requested_ps;
-
        amdgpu_dpm_post_set_power_state(adev);
 
-       /* update displays */
-       amdgpu_dpm_display_configuration_changed(adev);
-
        adev->pm.dpm.current_active_crtcs = adev->pm.dpm.new_active_crtcs;
        adev->pm.dpm.current_active_crtc_count = adev->pm.dpm.new_active_crtc_count;
 
@@ -1135,7 +1106,7 @@ void amdgpu_dpm_enable_vce(struct amdgpu_device *adev, bool enable)
                        mutex_lock(&adev->pm.mutex);
                        adev->pm.dpm.vce_active = true;
                        /* XXX select vce level based on ring/task */
-                       adev->pm.dpm.vce_level = AMDGPU_VCE_LEVEL_AC_ALL;
+                       adev->pm.dpm.vce_level = AMD_VCE_LEVEL_AC_ALL;
                        mutex_unlock(&adev->pm.mutex);
                } else {
                        mutex_lock(&adev->pm.mutex);
@@ -1276,20 +1247,20 @@ void amdgpu_pm_compute_clocks(struct amdgpu_device *adev)
        struct drm_device *ddev = adev->ddev;
        struct drm_crtc *crtc;
        struct amdgpu_crtc *amdgpu_crtc;
+       int i = 0;
 
        if (!adev->pm.dpm_enabled)
                return;
 
-       if (adev->pp_enabled) {
-               int i = 0;
+       amdgpu_display_bandwidth_update(adev);
 
-               amdgpu_display_bandwidth_update(adev);
-               for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
-                       struct amdgpu_ring *ring = adev->rings[i];
-                       if (ring && ring->ready)
-                               amdgpu_fence_wait_empty(ring);
-               }
+       for (i = 0; i < AMDGPU_MAX_RINGS; i++) {
+               struct amdgpu_ring *ring = adev->rings[i];
+               if (ring && ring->ready)
+                       amdgpu_fence_wait_empty(ring);
+       }
 
+       if (adev->pp_enabled) {
                amdgpu_dpm_dispatch_task(adev, AMD_PP_EVENT_DISPLAY_CONFIG_CHANGE, NULL, NULL);
        } else {
                mutex_lock(&adev->pm.mutex);
This page took 0.040614 seconds and 4 git commands to generate.