History log of /linux-master/drivers/gpu/drm/radeon/radeon_pm.c
Revision Date Author Comments
# 6d01359d 11-Jan-2024 XueBing Chen <chenxb_99091@126.com>

drm/radeon/kms: Clean up errors in radeon_pm.c

Fix the following errors reported by checkpatch:

ERROR: space required before the open parenthesis '('

Signed-off-by: XueBing Chen <chenxb_99091@126.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 6091ede9 16-May-2023 Su Hui <suhui@nfschina.com>

drm/radeon: Remove unnecessary (void*) conversions

No need cast (void*) to (struct radeon_device *)
or (struct radeon_ring *).

Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# cd3a8a59 18-Nov-2022 Christian König <christian.koenig@amd.com>

drm/ttm: remove ttm_bo_(un)lock_delayed_workqueue

Those functions never worked correctly since it is still perfectly
possible that a buffer object is released and the background worker
restarted even after calling them.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Arunpravin Paneer Selvam <Arunpravin.PaneerSelvam@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20221125102137.1801-2-christian.koenig@amd.com


# 2387e212 24-Aug-2022 Yu Zhe <yuzhe@nfschina.com>

drm/radeon: use time_after(a,b) to replace "a>b"

time_after() deals with timer wrapping correctly.

Signed-off-by: Yu Zhe <yuzhe@nfschina.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 69f0b547 31-Mar-2022 Guo Zhengkui <guozhengkui@vivo.com>

drm/radeon: simplify if-if to if-else

Replace `if (!ret)` with `else` for simplification.

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# d3116756 12-Apr-2021 Christian König <christian.koenig@amd.com>

drm/ttm: rename bo->mem and make it a pointer

When we want to decouble resource management from buffer management we need to
be able to handle resources separately.

Add a resource pointer and rename bo->mem so that all code needs to
change to access the pointer instead.

No functional change.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210430092508.60710-4-christian.koenig@amd.com


# 2bb5b5f6 29-Apr-2021 Kai-Heng Feng <kai.heng.feng@canonical.com>

drm/radeon/dpm: Disable sclk switching on Oland when two 4K 60Hz monitors are connected

Screen flickers rapidly when two 4K 60Hz monitors are in use. This issue
doesn't happen when one monitor is 4K 60Hz (pixelclock 594MHz) and
another one is 4K 30Hz (pixelclock 297MHz).

The issue is gone after setting "power_dpm_force_performance_level" to
"high". Following the indication, we found that the issue occurs when
sclk is too low.

So resolve the issue by disabling sclk switching when there are two
monitors requires high pixelclock (> 297MHz).

v2:
- Only apply the fix to Oland.
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 227545b9 29-Apr-2021 Kai-Heng Feng <kai.heng.feng@canonical.com>

drm/radeon/dpm: Disable sclk switching on Oland when two 4K 60Hz monitors are connected

Screen flickers rapidly when two 4K 60Hz monitors are in use. This issue
doesn't happen when one monitor is 4K 60Hz (pixelclock 594MHz) and
another one is 4K 30Hz (pixelclock 297MHz).

The issue is gone after setting "power_dpm_force_performance_level" to
"high". Following the indication, we found that the issue occurs when
sclk is too low.

So resolve the issue by disabling sclk switching when there are two
monitors requires high pixelclock (> 297MHz).

v2:
- Only apply the fix to Oland.
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 2b0e617a 24-Mar-2021 Tian Tao <tiantao6@hisilicon.com>

drm/radeon/radeon_pm: Convert sysfs sprintf/snprintf family to sysfs_emit

Fix the following coccicheck warning:
drivers/gpu//drm/radeon/radeon_pm.c:521:9-17: WARNING: use scnprintf or
sprintf
drivers/gpu//drm/radeon/radeon_pm.c:475:8-16: WARNING: use scnprintf or
sprintf
drivers/gpu//drm/radeon/radeon_pm.c:418:8-16: WARNING: use scnprintf or
sprintf
drivers/gpu//drm/radeon/radeon_pm.c:363:8-16: WARNING: use scnprintf or
sprintf
drivers/gpu//drm/radeon/radeon_pm.c:734:8-16: WARNING: use scnprintf or
sprintf
drivers/gpu//drm/radeon/radeon_pm.c:688:8-16: WARNING: use scnprintf or
sprintf
drivers/gpu//drm/radeon/radeon_pm.c:704:8-16: WARNING: use scnprintf or
sprintf
drivers/gpu//drm/radeon/radeon_pm.c:755:8-16: WARNING: use scnprintf or
sprintf

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 5b54d679 17-Feb-2021 Nirmoy Das <nirmoy.das@amd.com>

drm/radeon: do not use drm middle layer for debugfs (v2)

Use debugfs API directly instead of drm middle layer.

v2: squash in build fix (Alex)

Signed-off-by: Nirmoy Das <nirmoy.das@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# bb29f896 16-Nov-2020 Lee Jones <lee.jones@linaro.org>

drm/radeon/radeon_pm: Move 'radeon_pm_acpi_event_handler' prototype into shared header

Fixes the following W=1 kernel build warning(s):

drivers/gpu/drm/radeon/radeon_pm.c:74:6: warning: no previous prototype for ‘radeon_pm_acpi_event_handler’ [-Wmissing-prototypes]
74 | void radeon_pm_acpi_event_handler(struct radeon_device *rdev)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-media@vger.kernel.org
Cc: linaro-mm-sig@lists.linaro.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# fddc611c 09-Oct-2020 Sandeep Raghuraman <sandy.8925@gmail.com>

drm/radeon: Expose vddc through hwmon

Create hwmon attribute for vddc, that uses previously declared get_current_vddc() callback if there's an implementation available.

Also hides vddc, if there is no implementation for the current chipset (as per Alexander Deucher's suggestion).

Signed-off-by: Sandeep Raghuraman <sandy.8925@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 052813d9 09-Sep-2020 Sandeep Raghuraman <sandy.8925@gmail.com>

drm/radeon: Add sclk frequency as hwmon sensor

This patch adds support for reporting sclk values for Radeon GPUs, where supported.

Signed-off-by: Sandeep Raghuraman <sandy.8925@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# fbd62354 03-Jan-2020 Wambui Karuga <wambui.karugax@gmail.com>

drm/radeon: remove boolean checks in if statements.

Remove unnecessary variable comparisions to true/false in if statements
and check the value of the variable directly.

Signed-off-by: Wambui Karuga <wambui.karugax@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 2ef79416 03-Dec-2019 Thomas Zimmermann <tzimmermann@suse.de>

drm/radeon: Don't include <drm/drm_pci.h>

Including <drm/drm_pci.h> is unnecessary in most cases. Replace
these instances.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191203100406.9674-9-tzimmermann@suse.de


# f9183127 08-Jun-2019 Sam Ravnborg <sam@ravnborg.org>

drm/radeon: drop use of drmP.h (1/2)

Drop use of drmP.h in all .c files named radeon*c.
To ease review a little drmP.h removal was divided in two commits.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: "David (ChunMing) Zhou" <David1.Zhou@amd.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20190608080241.4958-7-sam@ravnborg.org


# 9aff8b2a 15-Feb-2018 Alex Deucher <alexander.deucher@amd.com>

Revert "drm/radeon/pm: autoswitch power state when in balanced mode"

This reverts commit 1c331f75aa6ccbf64ebcc5a019183e617c9d818a.

Breaks resume on some systems.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=100759
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 53bf277b 15-Feb-2018 Alex Deucher <alexander.deucher@amd.com>

Revert "drm/radeon/pm: autoswitch power state when in balanced mode"

This reverts commit 1c331f75aa6ccbf64ebcc5a019183e617c9d818a.

Breaks resume on some systems.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=100759
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 1c331f75 22-Oct-2016 Lucas Stach <dev@lynxeye.de>

drm/radeon/pm: autoswitch power state when in balanced mode

The current default of always using the performance power state leads
to increased power consumption of mobile devices, which have a dedicated
battery power state. Switch between the performance and battery power
state automatically, dpending on the current AC power status, when the
user asked for the balanced power state.

The user can still override this logic by asking for the performance
or battery power state explicitly.

Tested-by: Michel Dänzer <michel.daenzer@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# a782bca5 06-Jun-2016 Gustavo Padovan <gustavo.padovan@collabora.co.uk>

drm/radeon: use drm_crtc_vblank_{get,put}()

Replace the legacy drm_vblank_{get,put}() with the new helper functions.

Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1465224105-21485-13-git-send-email-gustavo@padovan.org


# 3cf8bb1a 15-Mar-2016 Jérome Glisse <jglisse@redhat.com>

drm/radeon: fix indentation.

I hate doing this but it hurts my eyes to go over code that does not
comply with indentation rules. Only thing that is not only space change
is in atom.c all other files are space indentation issues.

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# d74e766e 08-Mar-2016 Alex Deucher <alexander.deucher@amd.com>

Revert "drm/radeon/pm: adjust display configuration after powerstate"

This reverts commit 39d4275058baf53e89203407bf3841ff2c74fa32.

This caused a regression on some older hardware.

bug:
https://bugzilla.kernel.org/show_bug.cgi?id=113891

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 5e031d9f 24-Feb-2016 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/pm: update current crtc info after setting the powerstate

On CI, we need to see if the number of crtcs changes to determine
whether or not we need to upload the mclk table again. In practice
we don't currently upload the mclk table again after the initial load.
The only reason you would would be to add new states, e.g., for
arbitrary mclk setting which is not currently supported.

Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 39d42750 19-Feb-2016 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/pm: adjust display configuration after powerstate

set_power_state defaults to no displays, so we need to update
the display configuration after setting up the powerstate on the
first call. In most cases this is not an issue since ends up
getting called multiple times at any given modeset and the proper
order is achieved in the display changed handling at the top of
the function.

Reviewed-by: Christian König <christian.koenig@amd.com>
Acked-by: Jordan Lazare <Jordan.Lazare@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# e0b34e38 12-Feb-2016 Mario Kleiner <mario.kleiner.de@gmail.com>

drm/radeon/pm: Handle failure of drm_vblank_get.

Make sure that drm_vblank_get/put() stay balanced in
case drm_vblank_get fails, by skipping the corresponding
put.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: michel@daenzer.net
Cc: dri-devel@lists.freedesktop.org
Cc: alexander.deucher@amd.com
Cc: christian.koenig@amd.com
Signed-off-by: Dave Airlie <airlied@redhat.com>


# e3837b00 13-Jan-2016 Geliang Tang <geliangtang@163.com>

drm/radeon: use kobj_to_dev()

Use kobj_to_dev() instead of open-coding it.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# c55d21ea 25-Nov-2015 Mario Kleiner <mario.kleiner.de@gmail.com>

drm/radeon: Fixup hw vblank counter/ts for new drm_update_vblank_count() (v2)

commit 4dfd6486 "drm: Use vblank timestamps to guesstimate how many
vblanks were missed" introduced in Linux 4.4-rc1 makes the drm core
more fragile to drivers which don't update hw vblank counters and
vblank timestamps in sync with firing of the vblank irq and
essentially at leading edge of vblank.

This exposed a problem with radeon-kms/amdgpu-kms which do not
satisfy above requirements:

The vblank irq fires a few scanlines before start of vblank, but
programmed pageflips complete at start of vblank and
vblank timestamps update at start of vblank, whereas the
hw vblank counter increments only later, at start of vsync.

This leads to problems like off by one errors for vblank counter
updates, vblank counters apparently going backwards or vblank
timestamps apparently having time going backwards. The net result
is stuttering of graphics in games, or little hangs, as well as
total failure of timing sensitive applications.

See bug #93147 for an example of the regression on Linux 4.4-rc:

https://bugs.freedesktop.org/show_bug.cgi?id=93147

This patch tries to align all above events better from the
viewpoint of the drm core / of external callers to fix the problem:

1. The apparent start of vblank is shifted a few scanlines earlier,
so the vblank irq now always happens after start of this extended
vblank interval and thereby drm_update_vblank_count() always samples
the updated vblank count and timestamp of the new vblank interval.

To achieve this, the reporting of scanout positions by
radeon_get_crtc_scanoutpos() now operates as if the vblank starts
radeon_crtc->lb_vblank_lead_lines before the real start of the hw
vblank interval. This means that the vblank timestamps which are based
on these scanout positions will now update at this earlier start of
vblank.

2. The driver->get_vblank_counter() function will bump the returned
vblank count as read from the hw by +1 if the query happens after
the shifted earlier start of the vblank, but before the real hw increment
at start of vsync, so the counter appears to increment at start of vblank
in sync with the timestamp update.

3. Calls from vblank irq-context and regular non-irq calls are now
treated identical, always simulating the shifted vblank start, to
avoid inconsistent results for queries happening from vblank irq vs.
happening from drm_vblank_enable() or vblank_disable_fn().

4. The radeon_flip_work_func will delay mmio programming a pageflip until
the start of the real vblank iff it happens to execute inside the shifted
earlier start of the vblank, so pageflips now also appear to execute at
start of the shifted vblank, in sync with vblank counter and timestamp
updates. This to avoid some races between updates of vblank count and
timestamps that are used for swap scheduling and pageflip execution which
could cause pageflips to execute before the scheduled target vblank.

The lb_vblank_lead_lines "fudge" value is calculated as the size of
the display controllers line buffer in scanlines for the given video
mode: Vblank irq's are triggered by the line buffer logic when the line
buffer refill for a video frame ends, ie. when the line buffer source read
position enters the hw vblank. This means that a vblank irq could fire at
most as many scanlines before the current reported scanout position of the
crtc timing generator as the number of scanlines the line buffer can
maximally hold for a given video mode.

This patch has been successfully tested on a RV730 card with DCE-3 display
engine and on a evergreen card with DCE-4 display engine, in single-display
and dual-display configuration, with different video modes.

A similar patch is needed for amdgpu-kms to fix the same problem.

Limitations:

- Line buffer sizes in pixels are hard-coded on < DCE-4 to a value
i just guessed to be high enough to work ok, lacking info on the true
sizes atm.

Fixes: fdo#93147

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Michel Dänzer <michel.daenzer@amd.com>
Cc: Harry Wentland <Harry.Wentland@amd.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>

(v1) Tested-by: Dave Witbrodt <dawitbro@sbcglobal.net>

(v2) Refine radeon_flip_work_func() for better efficiency:

In radeon_flip_work_func, replace the busy waiting udelay(5)
with event lock held by a more performance and energy efficient
usleep_range() until at least predicted true start of hw vblank,
with some slack for scheduler happiness. Release the event lock
during waits to not delay other outputs in doing their stuff, as
the waiting can last up to 200 usecs in some cases.

Retested on DCE-3 and DCE-4 to verify it still works nicely.

(v2) Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 5b5561b3 25-Nov-2015 Mario Kleiner <mario.kleiner.de@gmail.com>

drm/radeon: Fixup hw vblank counter/ts for new drm_update_vblank_count() (v2)

commit 4dfd6486 "drm: Use vblank timestamps to guesstimate how many
vblanks were missed" introduced in Linux 4.4-rc1 makes the drm core
more fragile to drivers which don't update hw vblank counters and
vblank timestamps in sync with firing of the vblank irq and
essentially at leading edge of vblank.

This exposed a problem with radeon-kms/amdgpu-kms which do not
satisfy above requirements:

The vblank irq fires a few scanlines before start of vblank, but
programmed pageflips complete at start of vblank and
vblank timestamps update at start of vblank, whereas the
hw vblank counter increments only later, at start of vsync.

This leads to problems like off by one errors for vblank counter
updates, vblank counters apparently going backwards or vblank
timestamps apparently having time going backwards. The net result
is stuttering of graphics in games, or little hangs, as well as
total failure of timing sensitive applications.

See bug #93147 for an example of the regression on Linux 4.4-rc:

https://bugs.freedesktop.org/show_bug.cgi?id=93147

This patch tries to align all above events better from the
viewpoint of the drm core / of external callers to fix the problem:

1. The apparent start of vblank is shifted a few scanlines earlier,
so the vblank irq now always happens after start of this extended
vblank interval and thereby drm_update_vblank_count() always samples
the updated vblank count and timestamp of the new vblank interval.

To achieve this, the reporting of scanout positions by
radeon_get_crtc_scanoutpos() now operates as if the vblank starts
radeon_crtc->lb_vblank_lead_lines before the real start of the hw
vblank interval. This means that the vblank timestamps which are based
on these scanout positions will now update at this earlier start of
vblank.

2. The driver->get_vblank_counter() function will bump the returned
vblank count as read from the hw by +1 if the query happens after
the shifted earlier start of the vblank, but before the real hw increment
at start of vsync, so the counter appears to increment at start of vblank
in sync with the timestamp update.

3. Calls from vblank irq-context and regular non-irq calls are now
treated identical, always simulating the shifted vblank start, to
avoid inconsistent results for queries happening from vblank irq vs.
happening from drm_vblank_enable() or vblank_disable_fn().

4. The radeon_flip_work_func will delay mmio programming a pageflip until
the start of the real vblank iff it happens to execute inside the shifted
earlier start of the vblank, so pageflips now also appear to execute at
start of the shifted vblank, in sync with vblank counter and timestamp
updates. This to avoid some races between updates of vblank count and
timestamps that are used for swap scheduling and pageflip execution which
could cause pageflips to execute before the scheduled target vblank.

The lb_vblank_lead_lines "fudge" value is calculated as the size of
the display controllers line buffer in scanlines for the given video
mode: Vblank irq's are triggered by the line buffer logic when the line
buffer refill for a video frame ends, ie. when the line buffer source read
position enters the hw vblank. This means that a vblank irq could fire at
most as many scanlines before the current reported scanout position of the
crtc timing generator as the number of scanlines the line buffer can
maximally hold for a given video mode.

This patch has been successfully tested on a RV730 card with DCE-3 display
engine and on a evergreen card with DCE-4 display engine, in single-display
and dual-display configuration, with different video modes.

A similar patch is needed for amdgpu-kms to fix the same problem.

Limitations:

- Line buffer sizes in pixels are hard-coded on < DCE-4 to a value
i just guessed to be high enough to work ok, lacking info on the true
sizes atm.

Fixes: fdo#93147

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: Michel Dänzer <michel.daenzer@amd.com>
Cc: Harry Wentland <Harry.Wentland@amd.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>

(v1) Tested-by: Dave Witbrodt <dawitbro@sbcglobal.net>

(v2) Refine radeon_flip_work_func() for better efficiency:

In radeon_flip_work_func, replace the busy waiting udelay(5)
with event lock held by a more performance and energy efficient
usleep_range() until at least predicted true start of hw vblank,
with some slack for scheduler happiness. Release the event lock
during waits to not delay other outputs in doing their stuff, as
the waiting can last up to 200 usecs in some cases.

Retested on DCE-3 and DCE-4 to verify it still works nicely.

(v2) Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 24dd2f64 10-Nov-2015 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: unconditionally set sysfs_initialized

Avoids spew on resume for systems where sysfs may
fail even on init.

bug:
https://bugzilla.kernel.org/show_bug.cgi?id=106851

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 49abb266 23-Oct-2015 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: don't try to recreate sysfs entries on resume

Fixes a harmless error message caused by:
51a4726b04e880fdd9b4e0e58b13f70b0a68a7f5

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 2a7d44f4 19-Oct-2015 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: don't add pwm attributes if DPM is disabled

PWM fan control is only available with DPM. If DPM disabled,
don't expose the PWM fan controls to avoid a crash.

Bug:
https://bugs.freedesktop.org/show_bug.cgi?id=92524

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 51a4726b 30-Sep-2015 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: add pm sysfs files late

They were added relatively early in the driver init process
which meant that in some cases the driver was not finished
initializing before external tools tried to use them which
could result in a crash depending on the timing.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 3bb403bf 14-Sep-2015 Ville Syrjälä <ville.syrjala@linux.intel.com>

drm: Stop using linedur_ns and pixeldur_ns for vblank timestamps

linedur_ns, and especially pixeldur_ns are becoming rather inaccurate
to be used for the vblank timestamp correction. With 4k@60 the pixel
duration is already below 2ns, so the amount of error due to the
truncation to nanoseconds is introducing quite a bit of error.

We can avoid such problems if we instead calculate the timestamp
delta_ns directly from the dislay timings, avoiding the use of
these intermediate truncated values.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
[danvet: Squash in fixup from Thierry Reding for amdgpu.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>


# 34ddc3e9 09-Jul-2015 Daniel Vetter <daniel.vetter@ffwll.ch>

drm/radeon: Don't take dev->struct_mutex in pm functions

We already grab 2 device-global locks (write-sema rdev->pm.mclk_lock
and rdev->ring_lock), adding another global mutex won't serialize this
code more. And since there's really nothing interesting that gets
protected in radeon by dev->struct mutex (we only have the global z
buffer owners and it's still serializing gem bo destruction in the drm
core - which is irrelevant since radeon uses ttm anyway internally)
this doesn't add protection. Remove it.

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Reviewed-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 3899ca84 18-Mar-2015 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: fix 120hz handling harder

Need to expand the check to handle short circuiting
if the selected state is the same as current state.

bug:
https://bugs.freedesktop.org/show_bug.cgi?id=87796

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 951caa6a 17-Feb-2015 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: disable mclk switching with 120hz+ monitors

These tend to be problematic even if the vblank period is
long enough. This needs more investigation across a wider
range of displays. Disable for now.

bugs:
https://bugs.freedesktop.org/show_bug.cgi?id=87796
https://bugs.freedesktop.org/show_bug.cgi?id=89198

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 082452e1 04-Feb-2015 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: use 0-255 rather than 0-100 for pwm fan range

0-255 seems to be the preferred range for the pwm interface.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 99736703 07-Dec-2014 Oleg Chernovskiy <algonkvel@gmail.com>

drm/radeon: add hwmon interface for managing fan pwm (v2)

This adds percent-based fan control. Attributes (I hope) follow the
sysfs-interface specification:
* pwm1 - fan speed query/manage
* pwm1_max, pwm1_min - min/max values for fan pwm (constant)
* pwm1_enable - fan control query/manage (enable/disable)

(There is no rpm-based control for now)

v2: agd5f: fix formatting

Signed-off-by: Oleg Chernovskiy <algonkvel@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 4369a69e 08-Jan-2015 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: add a dpm quirk list

Disable dpm on certain problematic boards rather than
disabling dpm for the entire chip family since most
boards work fine.

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1386534
https://bugzilla.kernel.org/show_bug.cgi?id=83731

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 3d3cbd84 10-Sep-2014 Daniel Vetter <daniel.vetter@ffwll.ch>

drm: Clarify vblank ts/scanoutpos sampling #defines

I've read INVBL as "invalid backlight" and got mightly confused.
The #defines are already fairly long and we can afford to extend
them a bit more without resulting in ugly code all over.

I'm not sure how useful the complicated bitmask return value of these
functions really are since no one checks them. But for now let's keep
things as is.

Cc: Mario Kleiner <mario.kleiner.de@gmail.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>


# b07a657e 11-Aug-2014 Pali Rohár <pali@kernel.org>

drm/radeon: Add ability to get and change dpm state when radeon PX card is turned off

This fixing commit 4f2f203976964e267dc477de6648bdb3acd2b74b

bug:
https://bugzilla.kernel.org/show_bug.cgi?id=76321

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# c08abf11 13-Jul-2014 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: re-enable dpm by default on BTC

This patch depends on:
e07929810f0a19ddd756558290c7d72827cbfcd9
(drm/radeon/dpm: fix typo in vddci setup for eg/btc)

bugs:
https://bugs.freedesktop.org/show_bug.cgi?id=73053
https://bugzilla.kernel.org/show_bug.cgi?id=68571

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 8f500af4 07-Jul-2014 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: re-enable dpm by default on cayman

This patch depends on:
b0880e87c1fd038b84498944f52e52c3e86ebe59
(drm/radeon/dpm: fix vddci setup typo on cayman)

bug:
https://bugs.freedesktop.org/show_bug.cgi?id=69723

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 9c244878 04-Jul-2014 Fabian Frederick <fabf@skynet.be>

drm/radeon: remove null test before kfree

Fix checkpatch warning:
WARNING: kfree(NULL) is safe this check is probably not required

Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: David Airlie <airlied@linux.ie>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 96682956 18-Jun-2014 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: only apply bapm changes for AC power on ARUBA

Newer asics shouldn't need any manual adjustment.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 0690a229 07-Jun-2014 Alex Deucher <alexander.deucher@amd.com>

Revert "drm/radeon: use variable UVD clocks"

This caused reduced performance for some users with advanced post
processing enabled. We need a better method to pick the
UVD state based on the amount of post processing required or tune
the advanced post processing to fit within the lower power state
envelope.

This reverts commit 14a9579ddbf15dd1992a9481a4ec80b0b91656d5.
Cc: "3.15" <stable@vger.kernel.org>


# 3640da2f 29-May-2014 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/dpm: resume fixes for some systems

Setting the power state prior to restoring the display
hardware leads to blank screens on some systems. Drop
the power state set from dpm resume. The power state
will get set as part of the mode set sequence. Also
add an explicit power state set after mode set resume
to cover PX and headless systems.

bug:
https://bugzilla.kernel.org/show_bug.cgi?id=76761

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 4f2f2039 19-May-2014 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/pm: don't allow debugfs/sysfs access when PX card is off (v2)

When the PX card is off don't try and access it. Avoid hw access
to the card while it's off (e.g., reading back invalid temperature).

v2: be less strict

bug:
https://bugzilla.kernel.org/show_bug.cgi?id=76321

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
Signed-off-by: Christian König <christian.koenig@amd.com>


# 7d032a4b 30-Apr-2014 Samuel Li <samuel.li@amd.com>

drm/radeon: add Mullins dpm support.

Generic dpm support similar to Kabini. Mullins specific features
will be worked on later.

Signed-off-by: Samuel Li <samuel.li@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>


# 3ed9a335 14-Apr-2014 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/pm: don't walk the crtc list before it has been initialized (v2)

Avoids a crash in certain cases when thermal irqs are generated
before the display structures have been initialized.

v2: fix the vblank and vrefresh helpers as well

bug:
https://bugzilla.kernel.org/show_bug.cgi?id=73931

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# cb3e4e7c 14-Apr-2014 Alex Deucher <alexdeucher@gmail.com>

drm/radeon: properly unregister hwmon interface (v2)

Need to properly unregister the hwmon device on driver
unload.

v2: minor clean up

bug:
https://bugzilla.kernel.org/show_bug.cgi?id=73931

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 76e6dcec 18-Apr-2014 Alex Deucher <alexdeucher@gmail.com>

drm/radeon: disable dpm on rv770 by default

There seem to be stability issues on a number of cards.

bugs:
https://bugs.freedesktop.org/show_bug.cgi?id=76286
https://bugzilla.redhat.com/show_bug.cgi?id=1085785
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=741619

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: matthias.graf@st.ovqu.de
Cc: bp@alien8.de
Cc: stable@vger.kernel.org


# 14a9579d 21-Feb-2014 Alex Deucher <alexdeucher@gmail.com>

drm/radeon: use variable UVD clocks

Now that Christian fixed the performance problems with
the feedback buffer in mesa, we can enable variable UVD
clocks. There are multiple UVD power states associated
with different types and numbers of streams. This uses
the appropriate state based on that information rather
than always using the fastest UVD clocks which saves some
power. One possible downside is that this may adversely
affect decode benchmarks since these power states target
specific playback requirements rather than maximum
performance. If that becomes an issue, we can add a
sysfs attribute to force the max UVD state.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>


# 37615527 18-Feb-2014 Christian König <christian.koenig@amd.com>

drm/radeon: cleanup the fence ring locking code

We no longer need to take the ring lock while checking for
a gpu lockup, so just cleanup the code.

Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>


# 03afe6f6 23-Aug-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: enable dynamic vce state switching v2

enable vce states when vce is active. When vce is active,
it adjusts the currently selected state (performance, battery,
uvd, etc.)

v2: add code comments

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>


# b62d628b 20-Aug-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: fill in some initial vce infrastructure

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 919cf555 11-Jan-2014 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: disable dpm on BTC

Still unstable on some boards.

Bugs:
https://bugs.freedesktop.org/show_bug.cgi?id=73053
https://bugzilla.kernel.org/show_bug.cgi?id=68571

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: 3.13 <stable@vger.kernel.org> # 3.13


# 8158eb9e 10-Jan-2014 Christian König <christian.koenig@amd.com>

drm/radeon: don't power gate paused UVD streams

Signed-off-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# abca9e45 28-Oct-2013 Ville Syrjälä <ville.syrjala@linux.intel.com>

drm: Pass 'flags' from the caller to .get_scanout_position()

Preparation for moving the early vblank IRQ logic into
radeon_get_crtc_scanoutpos().

v2: Fix radeon_drv.c compile warning (Mario)

Reviewed-by: mario.kleiner.de@gmail.com
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>


# 37016951 07-Jan-2014 Michel Dänzer <michel.daenzer@amd.com>

radeon/pm: Guard access to rdev->pm.power_state array

It's never allocated on systems without an ATOMBIOS or COMBIOS ROM.

Should fix an oops I encountered while resetting the GPU after a lockup
on my PowerBook with an RV350.

Signed-off-by: Michel Dänzer <michel.daenzer@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# e308b1d3 19-Dec-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: enable dpm by default on CI APUs

Dynamic power mangement works reliably now, so
enable it by default.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 4f22dde3 19-Dec-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: enable dpm by default on CI dGPUs

Dynamic power mangement works reliably now, so
enable it by default.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 6c7bccea 18-Dec-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/pm: move pm handling into the asic specific code

We need more control over the ordering of dpm init with
respect to the rest of the asic. Specifically, the SMC
has to be initialized before the rlc and cg/pg. The pm
code currently initializes late in the driver, but we need
it to happen much earlier so move pm handling into the asic
specific callbacks.

This makes dpm more reliable and makes clockgating work
properly on CIK parts and should help on SI parts as well.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# e14cd2bb 19-Dec-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: switch on new late_enable callback

Right now it's called right after enable, but after
reworking the dpm init order, it will get called later
to accomodate loading the smc early, but enabling
thermal interrupts and block powergating later after
the ring tests are complete.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 914a8987 19-Dec-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: add a late enable callback

Certain features need to be enabled after ring tests
(e.g., powergating, etc.). Add a function pointer
to split out late enable features.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# bb5abf9f 18-Dec-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: remove unnecessary checks in dpm_init

No need to check rdev->pm.num_power_states; this is a vestige
of the old pm code.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# e4158f1b 12-Dec-2013 Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

radeon_pm: fix oops in hwmon_attributes_visible() and radeon_hwmon_show_temp_thresh()

Since commit ec39f64bba34 ("drm/radeon/dpm: Convert to use
devm_hwmon_register_with_groups") radeon_hwmon_init() is using
hwmon_device_register_with_groups(), which sets `rdev' as a device
private driver_data, while hwmon_attributes_visible() and
radeon_hwmon_show_temp_thresh() are still waiting for `drm_device'.

Fix them by using dev_get_drvdata(), in order to avoid this oops:

BUG: unable to handle kernel paging request at 0000000000001e28
IP: [<ffffffffa02ae8b4>] hwmon_attributes_visible+0x18/0x3d [radeon]
PGD 15057e067 PUD 151a8e067 PMD 0
Oops: 0000 [#1] PREEMPT SMP
Call Trace:
internal_create_group+0x114/0x1d9
sysfs_create_group+0xe/0x10
sysfs_create_groups+0x22/0x5f
device_add+0x34f/0x501
device_register+0x15/0x18
hwmon_device_register_with_groups+0xb5/0xed
radeon_hwmon_init+0x56/0x7c [radeon]
radeon_pm_init+0x134/0x7e5 [radeon]
radeon_modeset_init+0x75f/0x8ed [radeon]
radeon_driver_load_kms+0xc6/0x187 [radeon]
drm_dev_register+0xf9/0x1b4 [drm]
drm_get_pci_dev+0x98/0x129 [drm]
radeon_pci_probe+0xa3/0xac [radeon]
pci_device_probe+0x6e/0xcf
driver_probe_device+0x98/0x1c4
__driver_attach+0x5c/0x7e
bus_for_each_dev+0x7b/0x85
driver_attach+0x19/0x1b
bus_add_driver+0x104/0x1ce
driver_register+0x89/0xc5
__pci_register_driver+0x58/0x5b
drm_pci_init+0x86/0xea [drm]
radeon_init+0x97/0x1000 [radeon]
do_one_initcall+0x7f/0x117
load_module+0x1583/0x1bb4
SyS_init_module+0xa0/0xaf

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Alexander Deucher <Alexander.Deucher@amd.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>


# 1522f9c7 07-Dec-2013 Martin Andersson <g02maran@gmail.com>

drm/radeon/dpm: Fix hwmon crash

Commit ec39f64bba3421c2060fcbd1aeb6eec81fe0a42d (drm/radeon/dpm: Convert
to use devm_hwmon_register_with_groups) converted one usage of
dev_get_drvdata, but there were two more.

bug:
https://bugs.freedesktop.org/show_bug.cgi?id=72457

Signed-off-by: Martin Andersson <g02maran@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# ec39f64b 22-Nov-2013 Guenter Roeck <linux@roeck-us.net>

drm/radeon/dpm: Convert to use devm_hwmon_register_with_groups

Simplify the code and fix race condition seen because
attribute files were created after hwmon device registration.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 3a118989 14-Nov-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: enable DPM by default in TN asics

After adjusting the dpm parameters this seems to be
stable on most TN systems. DPM is important for APUs
since the boot clocks are generally pretty low.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 2d40038d 09-Aug-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: add hawaii dpm support

This updates the CI dpm (dynamic power management)
support for hawaii.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# d47abc58 29-Oct-2013 Mario Kleiner <mario.kleiner.de@gmail.com>

drm/radeon: Push get_scanout_position() timestamping into kms driver.

Move the ktime_get() clock readouts and potential preempt_disable()
calls from drm core into kms driver to make it compatible with the
api changes in the drm core.

This should not introduce any change in functionality or behaviour
in radeon-kms, just a reshuffling of code.

Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 14ac88af 23-Oct-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: retain user selected performance level across state changes

If the user has forced the state high or low, retain that preference
even when we switch power states.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=70654

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 0a17af37 23-Oct-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: disable force performance state when thermal state is active

If the thermal state is active, we are in the lowest performance level
to cool down the chip. Don't let the user force it higher.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# ab70b1dd 01-Nov-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: enable DPM by default on r7xx asics

Seems to be stable on them.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 59f7a2f2 01-Nov-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: enable DPM by default on evergreen asics

Seems to be stable on them. There are still some issues
with the performance states staying in the highest levels
on certain cards when multiple monitors are attached, but
being that the the cards are always in their highest power
state at boot up anyway, this doesn't really change anything
and improves things in all other cases.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 56684ec5 30-Oct-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: enable DPM by default on BTC asics

Seems to be stable on them.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 68bc7785 23-Oct-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: enable DPM by default on SI asics

Seems to be stable on them and improves peformance
as most SI asics have very low boot clocks.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 5a16f761 23-Oct-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: enable DPM by default on SUMO/PALM APUs

DPM seems to be stable on these asics and it drastically
improves performance depending on the boot clocks.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 033a37df 23-Oct-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: only print dpm debugging messages when radeon_dpm=1

Avoids spamming the system log for chips where dpm is enabled by
default, but prints then messages when users force it on for other
asics.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# dca5086a 30-Sep-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: disable multiple UVD states

Always use the regular UVD state for now. This fixes
a performance regression with UVD playback on certain APUs.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 36099186 21-Sep-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: don't set default clocks for SI when DPM is disabled

This is a partial revert of c6cf7777a32da874fabec4fd1c2a579f0ba4e4dd.

We need to take into account the clk voltage dependencies of the
board. Not doing so can lead to stability issues on certain
boards if the clks exceed the levels in the dep tables.

DPM already takes that into account, so for optimal performance,
use DPM.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 1cd8b21a 13-Sep-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: rework auto performance level enable

Calling force_performance_level() from set_power_state()
doesn't work on some asics because the current power
state pointer has not been properly updated at that point.
Move the calls to force_performance_level() out of the
asic specific set_power_state() functions and into
the main power state sequence.

Fixes dpm resume on SI.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 1c71bda0 09-Sep-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: add infrastructure to properly handle bapm

bapm is a pm feature for sharing the power budget between
the GPU and the CPU on APUs. It needs to be enabled or
disabled in certain circumstances. For now, disable it
when on battery and enable it when on AC power.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 6ea4e84d 10-Sep-2013 Jean Delvare <jdelvare@suse.de>

drm/radeon: expose DPM thermal thresholds through sysfs

The hwmon sysfs interface allows exposing temperature limits. The "max"
and "min" thresholds will be exposed as a critical high limit and its
hysteresis value, respectively. This gives the user a better idea of how
well cooling is doing and whether it is sufficient.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 3e4e2129 10-Sep-2013 Jean Delvare <jdelvare@suse.de>

drm/radeon: simplify driver data retrieval

You can get the driver data from struct device directly, there's no
need to get the PCI device first.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Cc: David Airlie <airlied@linux.ie>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 9e9d9762 31-Jul-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: add new callback for powergating UVD (v4)

Starting on CIK, multi-media blocks like UVD no longer
have special power state. Rather they have their own
DPM implementation which adjusts their clocks dynamically
when active. When they are not active, the blocks are
powergated to save power.

v2: add missing pm locks
v3: rebase on uvd state selection rework
v4: fix inverted logic typo noticed by Christian

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# cc8dbbb4 13-Aug-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: add dpm support for CI dGPUs (v2)

This adds dpm support for btc asics. This includes:
- dynamic engine clock scaling
- dynamic memory clock scaling
- dynamic voltage scaling
- dynamic pcie gen switching

Set radeon.dpm=1 to enable.

v2: remove unused radeon_atombios.c changes,
make missing smc ucode non-fatal

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 41a524ab 13-Aug-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add dpm support for KB/KV

This adds dpm support for KB/KV asics. This includes:
- dynamic engine clock scaling
- dynamic voltage scaling
- power containment
- shader power scaling

Set radeon.dpm=1 to enable.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 286d9cc6 21-Jun-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: add get_temperature() callbacks for CIK (v2)

This added support for the on-chip thermal sensors on
CIK asics.

v2: fix register offset.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# d4d3278c 11-Jun-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: use performance state if no UVD state

Newer asics don't have specific UVD states.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 60320347 24-Jul-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: rework thermal state handling

1. Handle the the thermal state directly in the work handler.
Remove the state selection function since nothing else uses it now.
2. On some asics there is no thermal state, so we just use a regular
state and force the low performance state.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# ce3537d5 23-Jul-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: use multiple UVD power states (v3)

Use the UVD handle information to determine which
which power states to select when using UVD. For
example, decoding a single SD stream requires much
lower clocks than multiple HD streams.

v2: switch to a cleaner dpm/uvd interface
v3: change the uvd power state while streams
are active if need be

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 8a53fa23 07-Aug-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: make missing smc ucode non-fatal

The smc ucode is required for dpm (dynamic power
management), but if it's missing just skip dpm setup
and don't disable acceleration.

Should fix:
https://bugs.freedesktop.org/show_bug.cgi?id=67876

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 761bfb99 06-Aug-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: require rlc for dpm

The rlc is required for dpm to work properly, so if
the rlc ucode is missing, don't enable dpm. Enabling
dpm without the rlc enabled can result in hangs.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 48783069 08-Jul-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: add checks against vblank time

If the vblank time is too short to adjust mclk,
assume multiple displays (no mclk adjustments).

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 7e1f3c04 08-Jul-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: remove stray line in old pm code

Looks like a remnant from an old rebase.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 70d01a5e 02-Jul-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: add infrastructure to force performance levels

This allows you to force specific power levels within a power
state. Due to hardware restrictions between generations, the
interface is limited to the following 3 selections:

auto: all levels enabled
low: forced to the lowest power level
high: forced to the highest power level

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# edcaa5b1 05-Jul-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: add support for 3d perf states on older asics

Certain older rv770 asics have both a performance and
a 3D performance state rather than just multiple performance
levels in the state power state. The current code would
select the performance state rather than the 3D performance
state when the "performance" profile was selected. This change
switches to the "balanced" profile by default which ends up being
the internal performance profile. When the user selects the
"performance" profile, it selects the internal 3D performance
state so the user can select the higher performance modes.

For most asics this changes nothing. For certain rv770 asics
with static performance and 3D performance states, this allows
you to select between then using by selecting the "balanced"
and "performance" dpm profiles.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# c6cf7777 05-Jul-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: set default clocks for SI when DPM is disabled

Fix patching of vddc values for SI and enable manually forcing
clocks to default levels as per NI.

This improves the out of the box performance with SI asics.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 71375929 02-Jul-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: clarify debugfs warning

For chips without debugfs dpm support say that it's not
implemented rather than not supported to avoid confusion
about DPM support in general.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 1316b792 28-Jun-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: add infrastructure to support debugfs info

This lays the frameworks to report realtime power level
feedback.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# a9e61410 25-Jun-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add dpm support for SI (v7)

This adds dpm support for SI asics. This includes:
- dynamic engine clock scaling
- dynamic memory clock scaling
- dynamic voltage scaling
- dynamic pcie gen1/gen2/gen3 switching
- power containment
- shader power scaling

Set radeon.dpm=1 to enable.

v2: enable hainan support, rebase
v3: guard acpi stuff
v4: fix 64 bit math
v5: fix 64 bit div harder
v6: fix thermal interrupt check noticed by Jerome
v7: attempt fix state enable

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 89c9bc56 16-Jan-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: remove broken dyn state remnants

Now that the proper fix has been implemented I can
remove the last remnants of the initial implementation.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 84dd1928 15-Jan-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: add new pre/post_set_power_state callbacks

Needed to properly handle dynamic state adjustment.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 69e0b57a 12-Apr-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add dpm support for cayman (v5)

This adds dpm support for cayman asics. This includes:
- clockgating
- dynamic engine clock scaling
- dynamic memory clock scaling
- dynamic voltage scaling
- dynamic pcie gen1/gen2 switching (requires additional acpi support)
- power containment
- shader power scaling

Set radeon.dpm=1 to enable.

v2: fold in tdp fix
v3: fix indentation
v4: fix 64 bit div
v5: attempt to fix state enable

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>


# d22b7e40 29-Nov-2012 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: fixup dynamic state adjust for btc (v2)

Use a dedicated copy of the current power state since
we may have to adjust it on the fly.

v2: fix up redundant state sets

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 7cf36de9 29-Nov-2012 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: fixup dynamic state adjust for sumo

Use a dedicated copy of the current power state since
we may have to adjust it on the fly.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 5ca302f7 30-Nov-2012 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dpm: track whether we are on AC or battery

Driver needs this information to validate power states.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 8a227555 21-Jun-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: enable UVD as needed (v9)

When using UVD, the driver must switch to a special UVD power
state. In the CS ioctl, switch to the power state and schedule
work to change the power state back, when the work comes up,
check if uvd is still busy and if not, switch back to the user
state, otherwise, reschedule the work.

Note: We really need some better way to decide when to
switch out of the uvd power state. Switching power states
while playback is active make uvd angry.

V2: fix locking.

V3: switch from timer to delayed work

V4: check fence driver for UVD jobs, reduce timeout to
1 second and rearm timeout on activity

v5: rebase on new dpm tree

v6: rebase on interim uvd on demand changes

v7: fix UVD when DPM is disabled

v8: unify non-DPM and DPM UVD handling

v9: remove leftover idle work struct

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christian König <deathsimple@vodafone.de>


# d70229f7 12-Apr-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add dpm support for trinity asics

This adds dpm support for trinity asics. This includes:
- clockgating
- powergating
- dynamic engine clock scaling
- dynamic voltage scaling

set radeon.dpm=1 to enable it.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 80ea2c12 12-Apr-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add dpm support for sumo asics (v2)

This adds dpm support for sumo asics. This includes:
- clockgating
- powergating
- dynamic engine clock scaling
- dynamic voltage scaling

set radeon.dpm=1 to enable it.

v2: fix indention

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>


# 6596afd4 25-Jun-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add dpm support for btc (v3)

This adds dpm support for btc asics. This includes:
- clockgating
- dynamic engine clock scaling
- dynamic memory clock scaling
- dynamic voltage scaling
- dynamic pcie gen1/gen2 switching (requires additional acpi support)

Set radeon.dpm=1 to enable.

v2: reduce stack usage
v3: attempt to fix state enable

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# dc50ba7f 25-Jun-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add dpm support for evergreen (v4)

This adds dpm support for evergreen asics. This includes:
- clockgating
- dynamic engine clock scaling
- dynamic memory clock scaling
- dynamic voltage scaling
- dynamic pcie gen1/gen2 switching (requires additional acpi support)

Set radeon.dpm=1 to enable.

v2: reduce stack usage, rename ulv struct
v3: fix thermal interrupt check notices by Jerome
v4: fix state enable

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 66229b20 25-Jun-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add dpm support for rv7xx (v4)

This adds dpm support for rv7xx asics. This includes:
- clockgating
- dynamic engine clock scaling
- dynamic memory clock scaling
- dynamic voltage scaling
- dynamic pcie gen1/gen2 switching

Set radeon.dpm=1 to enable.

v2: reduce stack usage
v3: fix 64 bit div
v4: fix state enable

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 4a6369e9 12-Apr-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add dpm support for rv6xx (v3)

This adds dpm support for rv6xx asics. This includes:
- clockgating
- dynamic engine clock scaling
- dynamic memory clock scaling
- dynamic voltage scaling
- dynamic pcie gen1/gen2 switching

Set radeon.dpm=1 to enable.

v2: remove duplicate line
v3: fix thermal interrupt check noticed by Jerome

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>


# 9d67006e 12-Apr-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add dpm support for rs780/rs880

This adds dpm support for rs780/rs880 asics. This includes:
- clockgating
- dynamic engine clock scaling
- dynamic voltage scaling

set radeon.dpm=1 to enable it.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# da321c8a 12-Apr-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add common dpm infrastructure

This adds the common dpm (dynamic power management)
infrastructure:
- dpm callbacks
- dpm init/fini/suspend/resume
- dpm power state selection

No device specific code is enabled yet.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 6bd1c385 21-Jun-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: make get_temperature functions a callback

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# bf05d998 18-Mar-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: don't use get_engine_clock() on APUs

It doesn't work reliably. Just report back the currently
selected engine clock.

Partially fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=62493

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 7ae764b1 11-Feb-2013 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: fix multi-head power profile stability on BTC+ asics

vddci needs to track mclk for multi-head.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 5f8f635e 17-Dec-2012 Jerome Glisse <jglisse@redhat.com>

drm/radeon: avoid deadlock in pm path when waiting for fence

radeon_fence_wait_empty_locked should not trigger GPU reset as no
place where it's call from would benefit from such thing and it
actually lead to a kernel deadlock in case the reset is triggered
from pm codepath. Instead force ring completion in place where it
makes sense or return early in others.

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# 760285e7 02-Oct-2012 David Howells <dhowells@redhat.com>

UAPI: (Scripted) Convert #include "..." to #include <path/...> in drivers/gpu/

Convert #include "..." to #include <path/...> in drivers/gpu/.

Signed-off-by: David Howells <dhowells@redhat.com>
Acked-by: Dave Airlie <airlied@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Acked-by: Dave Jones <davej@redhat.com>


# 27810fb2 01-Oct-2012 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/pm: fix multi-head profile handling on BTC+ (v2)

Starting on BTC, there are no longer separate states for
single head and multi-head, we just use the high mclk/voltage
for all states for multi-head.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=49981

v2: fix typo

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# eb2c27a0 01-Oct-2012 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: fix radeon power state debug output

Driver used to print "default" as the state type regardless
of whether it is the default state.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 2e3b3b10 14-Sep-2012 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: only adjust default clocks on NI GPUs

SI asics store voltage information differently so we
don't have a way to deal with it properly yet.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org


# c4917074 31-Jul-2012 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: re-organize the acpi notifier callback

Move it out of the radeon_pm.c and into radeon_acpi.c since
we use it for more than just pm now.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# fda4b25c 30-Jul-2012 Luca Tettamanti <kronos.it@gmail.com>

drm/radeon: implement handler for ACPI event

Set up an handler for ACPI events and respond to brightness change
requests from the system BIOS.
v2: fix notification when using device-specific command codes
(tested by Pali Rohár <pali.rohar@gmail.com>); cache the encoder
controlling the backlight during the initialization to avoid searching
it every time (suggested by Alex Deucher).
v3: whitespace fixes (Alex Deucher).

Signed-off-by: Luca Tettamanti <kronos.it@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# 95f5a3ac 10-Aug-2012 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/dynpm: wait for fences on all rings when reclocking

1. Drop gui idle stuff, it's not as reliable as fences and only
covers the 3D engine.
2. Wait for fences on all rings. This makes sure all rings are
idle when reclocking.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>


# fb98257a 16-May-2012 Christian Koenig <christian.koenig@amd.com>

drm/radeon: apply Murphy's law to the kms irq code v3

1. It is really dangerous to have more than one
spinlock protecting the same information.

2. radeon_irq_set sometimes wasn't called with lock
protection, so it can happen that more than one
CPU would tamper with the irq regs at the same
time.

3. The pm.gui_idle variable was assuming that the 3D
engine wasn't becoming idle between testing the
register and setting the variable. So just remove
it and test the register directly.

v2: Also handle the hpd irq code the same way.
v3: Rename hpd parameter for clarification.

Signed-off-by: Christian Koenig <christian.koenig@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>


# db7fce39 11-May-2012 Christian König <deathsimple@vodafone.de>

drm/radeon: replace vmram_mutex with mclk_lock v2

It is a rw_semaphore now and only write locked
while changing the clock. Also the lock is renamed
to better reflect what it is protecting.

v2: Keep the ttm_vm_ops on IGPs

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>


# 0ec0612a 14-Jun-2012 Alex Deucher <alexander.deucher@amd.com>

drm/radeon: fix regression in dynpm due to multi-ring rework

Not all asics have all rings, so make sure the ring is ready
before attempting to check it in the dynpm work handler.

Fixes:
https://bugzilla.kernel.org/show_bug.cgi?id=43367

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 8a47cc9e 09-May-2012 Christian König <deathsimple@vodafone.de>

drm/radeon: rework locking ring emission mutex in fence deadlock detection v2

Some callers illegal called fence_wait_next/empty
while holding the ring emission mutex. So don't
relock the mutex in that cases, and move the actual
locking into the fence code.

v2: Don't try to unlock the mutex if it isn't locked.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# d6999bc7 09-May-2012 Christian König <deathsimple@vodafone.de>

drm/radeon: replace the per ring mutex with a global one

A single global mutex for ring submissions seems sufficient.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 5d7486c7 20-Mar-2012 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: no support for internal thermal sensor on TN yet

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 1bd47d2e 20-Mar-2012 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add support for internal thermal sensor on SI

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 798bcf73 23-Feb-2012 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: move clock/pcie setting callbacks into pm struct

tidy up radeon_asic struct.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Christian König<christian.koenig@amd.com>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# e32eb50d 22-Oct-2011 Christian König <deathsimple@vodafone.de>

drm/radeon: rename struct radeon_cp to radeon_ring

That naming seems to make more sense, since we not
only want to run PM4 rings with it.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 47492a23 19-Oct-2011 Christian König <deathsimple@vodafone.de>

drm/radeon: add radeon_fence_count_emited function

Split counting of emited fences out of power
management into a seperate function.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# bf852799 13-Oct-2011 Christian König <deathsimple@vodafone.de>

drm/radeon: make cp variable an array

Replace cp, cp1 and cp2 members with just an array
of radeon_cp structs.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 7b1f2485 23-Sep-2011 Christian König <deathsimple@vodafone.de>

drm/radeon: make all functions work with multiple rings.

Give all asic and radeon_ring_* functions a
radeon_cp parameter, so they know the ring to work with.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 7465280c 25-Aug-2011 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add support for multiple fence queues v2

For supporting multiple CP ring buffers, async DMA
engines and UVD. We still need a way to synchronize
between engines.

v2 initialize unused fence driver ring to avoid issue in
suspend/unload

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 851a6bd9 24-Oct-2011 Christian König <deathsimple@vodafone.de>

drm/radeon: fix a spelling mistake

Better fix it before this obvious typo spreads even more.

Signed-off-by: Christian König <deathsimple@vodafone.de>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# a4c9e2ee 04-Nov-2011 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms/pm: add a proper pm profile init function for fusion

The new power tables need to be handled differently when setting
up the profiles.

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 4639dd21 25-Jul-2011 Alex Deucher <alexander.deucher@amd.com>

drm/radeon/kms: add missing vddci setting on NI+

Need to add vddci setting to pm init as well as
resume. Fixes hangs on load on some boards.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=38754

Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Cc: stable@kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 457558ed 25-May-2011 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: add missing case for cayman thermal sensor

The rest of the code is already in place.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 2feea49a 12-Apr-2011 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: properly program vddci on evergreen+

Change vddci as well as vddc when changing power modes
on evergreen/ni. Also, properly set vddci on boot up
for ni cards. The vbios only sets the limited clocks
and voltages on boot until the mc ucode is loaded. This
should fix stability problems on some btc cards.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 8a83ec5e 12-Apr-2011 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: add voltage type to atom set voltage function

This is needed for setting voltages other than vddc.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 1783e4bf 23-Mar-2011 Thomas Renninger <trenn@suse.de>

drm radeon: Return -EINVAL on wrong pm sysfs access

Throw an error if someone tries to fill this with
wrong data, instead of simply ignoring the input.
Now you get:

echo hello >/sys/../power_method
-bash: echo: write error: Invalid argument

Signed-off-by: Thomas Renninger <trenn@suse.de>
CC: Alexander.Deucher@amd.com
CC: dri-devel@lists.freedesktop.org
Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 0975b162 02-Feb-2011 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: dynamically allocate power state space

We previously used a static array, but some new systems
had more states then we had array space, so dynamically
allocate space based on the number of states in the vbios.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=33851

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Cc: stable@kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 20d391d7 01-Feb-2011 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: rv6xx+ thermal sensor fixes

Some fixes to the thermal sensor code:
- handle negative numbers
- properly handle temp calculation on different asics

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# ed18a360 06-Jan-2011 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/ni: load default sclk/mclk/vddc at pm init

The vbios only partially initializes the memory controller on
NI, so now we need to load the MC ucode in the driver and set
the default clocks once the ucode is loaded.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 9ace9f7b 06-Jan-2011 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: adjust default clock/vddc tracking for pm on DCE5

NI chips no longer load the MC ucode in the asic_init sequence so
the asic comes up in a basic mode with low engine/memory clocks and
a voltage. Once the MC ucode is loaded by the driver the card
can be programmed to it's proper default clocks and voltage. As such
the default clocks in the firmware info table as the post clocks, not
the default running clocks. Track the default post clocks and default
running clocks separately to handle this.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 4fddba1f 06-Jan-2011 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: handle NI thermal controller

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 32c87fca 03-Jan-2011 Tejun Heo <tj@kernel.org>

drm/radeon: use system_wq instead of dev_priv->wq

With cmwq, there's no reason for radeon to use a dedicated workqueue.
Drop dev_priv->wq and use system_wq instead.

Because radeon_driver_irq_uninstall_kms() may be called from
unsleepable context, the work items can't be flushed from there.
Instead, init and flush from radeon_irq_kms_init/fini().

While at it, simplify canceling/flushing of rdev->pm.dynpm_idle_work.
Always initialize and sync cancel instead of being unnecessarily smart
about it.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Alex Deucher <alexdeucher@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Dave Airlie <airlied@redhat.com>


# e33df25f 22-Nov-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: add thermal sensor support for fusion APUs

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# f5a80209 22-Oct-2010 Mario Kleiner <mario.kleiner@tuebingen.mpg.de>

drm/kms/radeon: Add support for precise vblank timestamping.

This patch adds new functions for use by the drm core:

.get_vblank_timestamp() provides a precise timestamp
for the end of the most recent (or current) vblank
interval of a given crtc, as needed for the DRI2
implementation of the OML_sync_control extension.

It is a thin wrapper around the drm function
drm_calc_vbltimestamp_from_scanoutpos() which does
almost all the work and is shared across drivers.

.get_scanout_position() provides the current horizontal
and vertical video scanout position and "in vblank"
status of a given crtc, as needed by the drm for use by
drm_calc_vbltimestamp_from_scanoutpos().

The function is also used by the dynamic gpu reclocking
code to determine when it is safe to reclock inside vblank.

For that purpose radeon_pm_in_vbl() is modified to
accomodate a small change in the function prototype of
the radeon_get_crtc_scanoutpos() which is hooked up to
.get_scanout_position().

This code has been tested on AVIVO hardware, a RV530
(ATI Mobility Radeon X1600) in a Intel Core-2 Duo MacBookPro
and some R600 variant (FireGL V7600) in a single cpu
AMD Athlon 64 PC.

Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 75fa0b08 05-Oct-2010 Mario Kleiner <mario.kleiner@tuebingen.mpg.de>

drm/radeon: Modify radeon_pm_in_vbl to use radeon_get_crtc_scanoutpos()

radeon_pm_in_vbl() didn't report in vblank status accurately. Make
it a wrapper around radeon_get_crtc_scanoutpos() which corrects for
biases, so it reports accurately.

radeon_pm_in_vbl() will only report in_vbl if all active crtc's
are currently inside vblank.

agd5f: use rdev->num_crtc rather than hardcoding the crtc count

Signed-off-by: Mario Kleiner <mario.kleiner@tuebingen.mpg.de>
Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 12acd90f 25-Aug-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: remove stray radeon_i2c_destroy

I missed this one in the i2c unification patch. This
is handled in the core radeon i2c code now.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 4e186b2d 13-Aug-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: bail early if nothing's changing

If we aren't changing the power state, no need to take
locks and schedule fences, etc.

There seem to be lock ordering issues in the CP and
fence code in some cases; see bug 29140 below.

Fixes:
https://bugs.freedesktop.org/show_bug.cgi?id=29140
Possibly also:
https://bugzilla.kernel.org/show_bug.cgi?id=16581

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Cc: stable@kernel.org
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 0d18abed 09-Aug-2010 Dan Carpenter <error27@gmail.com>

radeon: handle errors in radeon_hwmon_init()

Smatch complained that the ERR_PTR from hwmon_device_register() wasn't
handled.  I added some error handling in radeon_hwmon_init() to silence
the warning.

Unfortunately errors from radeon_pm_init() aren't handled so this
doesn't really make a difference beyond silencing the warning.

Also I changed DRM_ERROR() to dev_err() which is the new preferred
method.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# d9fdaafb 01-Aug-2010 Dave Airlie <airlied@redhat.com>

drm/radeon/kms: move a bunch of modesetting debug to correct debug usage.

This migrates a bunch of DRM_DEBUG->DRM_DEBUG_KMS so we can get more modesetting related info without all the other ioctl handling easily.

Also the PM code moves to DRM_DEBUG_DRIVER mostly.

Signed-off-by: Dave Airlie <airlied@redhat.com>


# 21a8122a 01-Jul-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: add support for internal thermal sensors (v3)

rv6xx/rv7xx/evergreen families supported; older asics did
not have an internal thermal sensor.

Note, not all oems use the internal thermal sensor, so it's
only exposed in cases where it is used.

Note also, that most laptops use an oem specific ACPI solution for
GPU thermal information rather than using the internal thermal
sensor directly.

v2: export millidegrees celsius, use hwmon device properly.
v3: fix Kconfig

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 12e27be8 27-Jul-2010 Daniel J Blueman <daniel.blueman@gmail.com>

drm/radeon/kms: fix radeon mid power profile reporting

Fix incorrectly reporting 'default' power profile, when it is set to 'mid'.

Signed-off-by: Daniel J Blueman <daniel.blueman@gmail.com>
Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 3f53eb6f 17-Jun-2010 Rafael J. Wysocki <rjw@rjwysocki.net>

DRM / radeon / KMS: Fix hibernation regression related to radeon PM (was: Re: [Regression, post-2.6.34] Hibernation broken on machines with radeon/KMS and r300)

There is a regression from 2.6.34 related to the recent radeon power
management changes, caused by attempting to cancel a delayed work
item that's never been scheduled. However, the code as is has some
other issues potentially leading to visible problems.

First, the mutex around cancel_delayed_work() in radeon_pm_suspend()
doesn't really serve any purpose, because cancel_delayed_work() only
tries to delete the work's timer. Moreover, it doesn't prevent the
work handler from running, so the handler can do some wrong things if
it wins the race and in that case it will rearm itself to do some
more wrong things going forward. So, I think it's better to wait for
the handler to return in case it's already been queued up for
execution. Also, it should be prevented from rearming itself in that
case.

Second, in radeon_set_pm_method() the cancel_delayed_work() is not
sufficient to prevent the work handler from running and queing up
itself for the next run (the failure scenario is that
cancel_delayed_work() returns 0, so the handler is run, it waits on
the mutex and then rearms itself after the mutex has been released),
so again the work handler should be prevented from rearming itself in
that case..

Finally, there's a potential deadlock in radeon_pm_fini(), because
cancel_delayed_work_sync() is called under rdev->pm.mutex, but the
work handler tries to acquire the same mutex (if it wins the race).

Fix the issues described above.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# f712d0c7 07-Jun-2010 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms/pm: resurrect printing power states

debug only

agd5f: rebased

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 0fcbe947 07-Jun-2010 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms: add trivial debugging for voltage

agd5f: rebased

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 4d60173f 07-Jun-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: track current voltage (v2)

track the current voltage level and avoid setting it
if the requested voltage is already set.

v2: check voltage type before checking current voltage

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# c9e75b21 02-Jun-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: add mid profile

This adds an additional profile, mid, to the pm profile
code which takes the place of the old low profile. The default
behavior remains the same, e.g., auto profile now selects between
mid and high profiles based on power source, however, you can now
manually force the low profile which was previously only available
as a dpms off state. Enabling the low profile when the displays
are on has been known to cause display corruption in some cases.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# f8ed8b4c 07-Jun-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: Misc fixes

- don't rest the power state in pm_init()
We already boot up to the default power state. Note this
patch relies on:
drm/radeon/kms/pm: patch default power state with default clocks/voltages on r6xx+
To make sure the default power state matches the boot up state.

- In the pm resume path asic init will have set the power state
back to the default so reset the tracking state values.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 9bad145e 06-Jun-2010 Dave Airlie <airlied@redhat.com>

drm/radeon: fix PM on non-vram cards.

PM attemps to unmap objects that aren't actually mapped into userspace ever,
so just don't bother unmapping them at this point, since all you are doing
is nothing. We should be making sure all access to these objects are locked in
kernel space instead. In theory the VRAM gart table is already done, and both
the shaders and stolen vga memory blocks are never accessed at runtime.

fixes: https://bugzilla.kernel.org/show_bug.cgi?id=16127

Reported-by: Jure Repnic <jlp.bugs@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 92645879 27-May-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: radeon_set_power_state fixes

- wait for vbl for both profile and dynpm
- unify profile and dynpm code paths more
- call pm_misc before of after clocks to make
sure voltage is changed in the proper order.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 26481fb1 18-May-2010 Dave Airlie <airlied@redhat.com>

drm/radeon/pm: fix device_create_file return value checks.

print an error if these fail.

Signed-off-by: Dave Airlie <airlied@redhat.com>


# ce8a3eb2 07-May-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: make pm spam debug only

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# ce8f5370 07-May-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: rework power management

- Separate dynpm and profile based power management methods. You can select the pm method
by echoing the selected method ("dynpm" or "profile") to power_method in sysfs.
- Expose basic 4 profile in profile method
"default" - default clocks
"auto" - select between low and high based on ac/dc state
"low" - DC, low power mode
"high" - AC, performance mode
The current base profile is "default", but it should switched to "auto" once we've tested
on more systems. Switching the state is a matter of echoing the requested profile to
power_profile in sysfs. The lowest power states are selected automatically when dpms turns
the monitors off in all states but default.
- Remove dynamic fence-based reclocking for the moment. We can revisit this later once we
have basic pm in.
- Move pm init/fini to modesetting path. pm is tightly coupled with display state. Make sure
display side is initialized before pm.
- Add pm suspend/resume functions to make sure pm state is properly reinitialized on resume.
- Remove dynpm module option. It's now selectable via sysfs.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# d7311171 02-May-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: add support for no display power states

The lowest power states often cause display problems, so only enable
them when all displays are off.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 01434b4b 30-Apr-2010 Matthew Garrett <mjg@redhat.com>

radeon: Use fences to gate entry to reclocking on <r600

GUI idle interrupts don't seem to work terribly well on r500 and earlier,
so let's use a fence instead.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 4f3218cb 29-Apr-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: re-enable gui idle interrupts on r6xx+

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 539d2418 28-Apr-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: more pm fixes

- disable gui idle interrupt use
Seems to hang some r5xx chips
- move vbl range check into
existing vbl check function in
radeon_pm.c
- disable crtc mc acccess for the
whole reclocking process

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# f81f2024 27-Apr-2010 Matthew Garrett <mjg@redhat.com>

radeon: Try harder to ensure we reclock in vblank

The vblank interrupt on r600 doesn't seem to be especially reliable, so
perform some sanity checks before the actual reclock.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 612e06ce 27-Apr-2010 Matthew Garrett <mjg@redhat.com>

radeon: Fix locking in power management paths

The ttm code could take vram_mutex followed by cp_mutex, while the
reclocking code would do the reverse. Hilarity could ensue.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# c37d230a 27-Apr-2010 Matthew Garrett <mjg@redhat.com>

radeon: Make sure that we determine the correct PM state before transition

We need to choose the correct PM state to transition into before starting
the actual change. Call radeon_get_power_state() at the top of the clock
setting to do so.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# d9932a32 26-Apr-2010 Matthew Garrett <mjg@redhat.com>

radeon: Stop the ttm workqueue while reclocking

The ttm bo workqueue may touch objects while we're reclocking, so make
sure it's blocked until we're done.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 8f5b5e63 26-Apr-2010 Matthew Garrett <mjg@redhat.com>

radeon: Take drm struct_mutex over reclocking

We need to block the drm core from doing anything that may touch our vram
during reclock, so take the drm mutex for the duration.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 5876dd24 26-Apr-2010 Matthew Garrett <mjg@redhat.com>

radeon: Unmap vram pages when reclocking

Touching vram while the card is reclocking can lead to lockups. Unmap
any pages that could be touched by the CPU and block any accesses to
vram until the reclocking is complete.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 2aba631c0 26-Apr-2010 Matthew Garrett <mjg@redhat.com>

radeon: Unify PM entry paths

There's a moderate amount of effort involved in setting the card up for
clock transitions, so unify the codepaths to make it easier to implement.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# a424816f 24-Apr-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: rework power management

Add two new sysfs attributes:
- dynpm
- power_state

Echoing 0/1 to dynpm disables/enables dynamic power management.
The driver scales the sclk dynamically based on the number of
queued fences. dynpm only scales sclk dynamically in single head
mode.

Echoing x.y to power_state selects a static power state (x) and clock
mode (y). This allows you to statically select a power state and clock
mode. Selecting a static clock mode will disable dynpm.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 58e21dff 22-Mar-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: restore default power state on exit

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 79daedc9 22-Apr-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: minor pm cleanups

- remove non_clock_info struct
- track power state misc flags

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# d91eeb78 05-Apr-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: clean power state printing

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 90c39059 24-Mar-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: don't enable pm if there is only on power state

Just adds overhead when the power state will never change.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# c00f53be 22-Mar-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: update display watermarks with power state changes

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# a48b9b4e 22-Apr-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: add asic specific callbacks for getting power state (v2)

This also simplifies the code and enables reclocking with multiple heads
active by tracking whether the power states are single or multi-head
capable.

Eventually, we will want to select a power state based on external
factors (AC/DC state, user selection, etc.).

(v2) Update for evergreen

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# bae6b562 22-Apr-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: add asic specific callbacks for setting power state (v2)

(v2) Add evergreen vbl checks

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 8a56df63 15-Mar-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: interate across crtcs for vblank

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# ef6e6cf5 17-Mar-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: wait for gpu idle before changing power mode

set proper wait condition as noted by Rafał Miłecki.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 2031f77c 21-Apr-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: add support for gui idle interrupts (v4)

Useful for certain power management operations. You
need to wait for the GUI engine (2D, 3D, CP, etc.) to be
idle before changing clocks or adjusting engine parameters.

(v2) Fix gui idle enable on pre-r6xx asics

(v3) The gui idle interrrupt status bit is permanently asserted
on pre-r6xx chips, but the interrrupt is still generated.
workaround it in the driver.

(v4) Add support for evergreen

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 57f50d70 14-Mar-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms/pm: fix segfault in clock code

Make sure we have a crtc assigned to the encoder
before dereferencing it.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>


# 29fb52ca 11-Mar-2010 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: expose thermal/fan i2c buses

Look up i2c bus in the power table and expose it.
You'll need to load a hwmon driver for any chips
on the bus, this patch just exposes the bus.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>


# d0d6cb81 02-Mar-2010 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms: prepare for more reclocking operations

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 839461d3 02-Mar-2010 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms: switch to condition waiting for reclocking

We tried to implement interruptible waiting with timeout (it was broken
anyway) which was not a good idea as explained by Andrew. It's possible
to avoid using additional variable but actually it inroduces using more
complex in-kernel tools. So simply add one variable for condition.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# aa5120d2 18-Feb-2010 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms: implement reading active PCIE lanes on R600+

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 08ff2a7a 21-Feb-2010 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms: for downclocking non-mobility check PERFORMANCE state

AtomBIOS tables on non-mobility GPU do not contain POWERSAVE/BATTERY.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 9038dfdf 20-Feb-2010 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms: simplify storing current and requested PM mode

We kept pointers to requested and current clock modes in every power state.
That was useless, more /global/ pointers in power struct are enough.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Reviewed-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# f735261b 17-Feb-2010 Dave Airlie <airlied@redhat.com>

[rfc] drm/radeon/kms: pm debugging check for vbl.

This patch adds a check on avivo chips to see if we are in the VBL
region for the active crtcs when we trigger the engine change.

I appear to have glitches locally on pm transistion (not sure all
fixes are in yet) and this at least seems to be correct here,
maybe others can test on systems with no glitches.


# bc4624ca 11-Feb-2010 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms: simplify picking power state

Signed-off-by: Dave Airlie <airlied@redhat.com>


# 73a6d3fc 07-Jan-2010 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms: use wait queue (events) for VBLANK sync

This already simplifies code significally and makes it maintaible
in case of adding memory reclocking plus voltage changing in future.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# a0eb38eb 23-Dec-2009 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms: get_power_state early, not when processing IRQ

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 530079a8 23-Dec-2009 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: use power states for dynamic reclocking

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 516d0e46 23-Dec-2009 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: add code to select power state

not hooked up yet.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 0ec0e74f 23-Dec-2009 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: add a power state type based on power state flags

The idea is to flag a power state with a certain type and use
that type to decide on what state to select. On r6xx+, we
select a state and then transition between clock modes in that
state. On pre-r6xx, we transition between states directly.

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 56278a8e 28-Dec-2009 Alex Deucher <alexdeucher@gmail.com>

drm/radeon/kms: pull power mode info from bios tables (v3)

The general idea is to validate the current hw state
against the set of power states and select a power
state based on that. This patch just pulls the power
states from the bios and prints the information. It
is not currently hooked up in the actual power management
code. Hooking it up will require reworking the the current
power state selection code and will be handled in a future
patch.

Additionally, we'd need to decide on some default lower
power states for cards without power tables.

v2 - increment state_index after checking for default state
v3 - fix typo in pm init on pre-atom cards, handle pre-atom
cards without x86 bioses

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# c913e23a 22-Dec-2009 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms: add dynamic engine reclocking (V9)

V2: reorganize functions, fix modesetting calls
V3: rebase patch, use radeon's workqueue
V4: enable on tested chipsets only, request VBLANK IRQs
V5: enable PM on older hardware (IRQs, mode_fixup, dpms)
V6: use separate dynpm module parameter
V7: drop RADEON_ prefix, set minimum mode for dpms off
V8: update legacy encoder call, fix order in rs600 IRQ
V9: update compute_clocks call in legacy, not only DPMS_OFF

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 6234077d 15-Dec-2009 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms: init pm on all chipsets

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# c142c3e5 06-Nov-2009 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms/pm: fix typos

Unit typo noticed by taiu on IRC

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>


# 7433874e 02-Nov-2009 Rafał Miłecki <zajec5@gmail.com>

drm/radeon/kms: add debugfs for power management for AtomBIOS devices

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>