summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/radeon/ci_dpm.c
AgeCommit message (Collapse)Author
2019-02-18drm/radeon/ci_dpm: Mark expected switch fall-throughsGustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through. Warning level 3 was used: -Wimplicit-fallthrough=3 This patch is part of the ongoing efforts to enable -Wimplicit-fallthrough. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2019-01-25drm/radeon: check if device is root before getting pci speed capsAlex Deucher
Check if the device is root rather before attempting to see what speeds the pcie port supports. Fixes a crash with pci passthrough in a VM. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=109366 Reviewed-by: Evan Quan <evan.quan@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2018-07-05drm/radeon: use pcie functions for link widthAlex Deucher
This is the last user of drm_pcie_get_speed_cap_mask. Use the pci version so we can drop drm_pcie_get_speed_cap_mask. Acked-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2018-06-12treewide: kzalloc() -> kcalloc()Kees Cook
The kzalloc() function has a 2-factor argument form, kcalloc(). This patch replaces cases of: kzalloc(a * b, gfp) with: kcalloc(a * b, gfp) as well as handling cases of: kzalloc(a * b * c, gfp) with: kzalloc(array3_size(a, b, c), gfp) as it's slightly less ugly than: kzalloc_array(array_size(a, b), c, gfp) This does, however, attempt to ignore constant size factors like: kzalloc(4 * 1024, gfp) though any constants defined via macros get caught up in the conversion. Any factors with a sizeof() of "unsigned char", "char", and "u8" were dropped, since they're redundant. The Coccinelle script used for this was: // Fix redundant parens around sizeof(). @@ type TYPE; expression THING, E; @@ ( kzalloc( - (sizeof(TYPE)) * E + sizeof(TYPE) * E , ...) | kzalloc( - (sizeof(THING)) * E + sizeof(THING) * E , ...) ) // Drop single-byte sizes and redundant parens. @@ expression COUNT; typedef u8; typedef __u8; @@ ( kzalloc( - sizeof(u8) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(__u8) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(char) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(unsigned char) * (COUNT) + COUNT , ...) | kzalloc( - sizeof(u8) * COUNT + COUNT , ...) | kzalloc( - sizeof(__u8) * COUNT + COUNT , ...) | kzalloc( - sizeof(char) * COUNT + COUNT , ...) | kzalloc( - sizeof(unsigned char) * COUNT + COUNT , ...) ) // 2-factor product with sizeof(type/expression) and identifier or constant. @@ type TYPE; expression THING; identifier COUNT_ID; constant COUNT_CONST; @@ ( - kzalloc + kcalloc ( - sizeof(TYPE) * (COUNT_ID) + COUNT_ID, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * COUNT_ID + COUNT_ID, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * (COUNT_CONST) + COUNT_CONST, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * COUNT_CONST + COUNT_CONST, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * (COUNT_ID) + COUNT_ID, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * COUNT_ID + COUNT_ID, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * (COUNT_CONST) + COUNT_CONST, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * COUNT_CONST + COUNT_CONST, sizeof(THING) , ...) ) // 2-factor product, only identifiers. @@ identifier SIZE, COUNT; @@ - kzalloc + kcalloc ( - SIZE * COUNT + COUNT, SIZE , ...) // 3-factor product with 1 sizeof(type) or sizeof(expression), with // redundant parens removed. @@ expression THING; identifier STRIDE, COUNT; type TYPE; @@ ( kzalloc( - sizeof(TYPE) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(TYPE) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(TYPE) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(TYPE) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kzalloc( - sizeof(THING) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc( - sizeof(THING) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc( - sizeof(THING) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kzalloc( - sizeof(THING) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) ) // 3-factor product with 2 sizeof(variable), with redundant parens removed. @@ expression THING1, THING2; identifier COUNT; type TYPE1, TYPE2; @@ ( kzalloc( - sizeof(TYPE1) * sizeof(TYPE2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | kzalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | kzalloc( - sizeof(THING1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | kzalloc( - sizeof(THING1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | kzalloc( - sizeof(TYPE1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) | kzalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) ) // 3-factor product, only identifiers, with redundant parens removed. @@ identifier STRIDE, SIZE, COUNT; @@ ( kzalloc( - (COUNT) * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - (COUNT) * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - (COUNT) * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - (COUNT) * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kzalloc( - COUNT * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) ) // Any remaining multi-factor products, first at least 3-factor products, // when they're not all constants... @@ expression E1, E2, E3; constant C1, C2, C3; @@ ( kzalloc(C1 * C2 * C3, ...) | kzalloc( - (E1) * E2 * E3 + array3_size(E1, E2, E3) , ...) | kzalloc( - (E1) * (E2) * E3 + array3_size(E1, E2, E3) , ...) | kzalloc( - (E1) * (E2) * (E3) + array3_size(E1, E2, E3) , ...) | kzalloc( - E1 * E2 * E3 + array3_size(E1, E2, E3) , ...) ) // And then all remaining 2 factors products when they're not all constants, // keeping sizeof() as the second factor argument. @@ expression THING, E1, E2; type TYPE; constant C1, C2, C3; @@ ( kzalloc(sizeof(THING) * C2, ...) | kzalloc(sizeof(TYPE) * C2, ...) | kzalloc(C1 * C2 * C3, ...) | kzalloc(C1 * C2, ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * (E2) + E2, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(TYPE) * E2 + E2, sizeof(TYPE) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * (E2) + E2, sizeof(THING) , ...) | - kzalloc + kcalloc ( - sizeof(THING) * E2 + E2, sizeof(THING) , ...) | - kzalloc + kcalloc ( - (E1) * E2 + E1, E2 , ...) | - kzalloc + kcalloc ( - (E1) * (E2) + E1, E2 , ...) | - kzalloc + kcalloc ( - E1 * E2 + E1, E2 , ...) ) Signed-off-by: Kees Cook <keescook@chromium.org>
2017-10-08drm/radeon: move ci_send_msg_to_smc to where it's usedAlex Deucher
It's used in ci_dpm.c so move it there and make it static. Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-30Backmerge tag 'v4.12-rc3' into drm-nextDave Airlie
Linux 4.12-rc3 Daniel has requested this for some drm-intel-next work.
2017-05-24drm/radeon/ci: disable mclk switching for high refresh rates (v2)Alex Deucher
Even if the vblank period would allow it, it still seems to be problematic on some cards. v2: fix logic inversion (Nils) bug: https://bugs.freedesktop.org/show_bug.cgi?id=96868 Cc: stable@vger.kernel.org Acked-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2017-05-17drm/radeon: fix include notation and remove -Iinclude/drm flagMasahiro Yamada
Include <drm/*.h> instead of relative path from include/drm, then remove the -Iinclude/drm compiler flag. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/1493009447-31524-14-git-send-email-yamada.masahiro@socionext.com
2016-07-29drm/radeon/ci add comment to document intentionally unreachable codeNicholas Mc Guire
commit d967be9b80a5 ("drm/radeon/ci: disable needless sclk changes") introduces an unreachable if(C != C) conditional code section flagged by coccinelle script bad_conditional.cocci: Add a comment to make it clear that this is intentional. Fixes: d967be9b80a5 ("drm/radeon/ci: disable needless sclk changes") Signed-off-by: Nicholas Mc Guire <hofrat@osadl.org> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2016-03-16drm/radeon: fix indentation.Jérome Glisse
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>
2015-07-16drm/radeon/ci: silence a harmless PCC warningAlex Deucher
This has been a source of confusion. Make it debug only. Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
2015-03-19drm/radeon/ci: implement get_current_sclk/mclkAlex Deucher
Will be used for exposing current clocks via INFO ioctl. Tested-by: Marek Olšák <marek.olsak@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2015-01-22drm/radeon: comment out some currently unused ci dpm codeAlex Deucher
Keep it around for reference. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2015-01-22drm/radeon: bind fan control on CI cards to hwmon interface (v2)Oleg Chernovskiy
This adds a possibility to control fan on CI parts via exported hwmon variables. Note that automatic ucode fan management pauses if you choose to enable manual fan control. Use with caution! v2: agd5f: fix formatting, squash in: minor fix for pwm1_enable exposed value Track smc control in addition to fan mode This fixes pwm1_enable being constantly set to 1 because of enabled smc control also handle the case where smc fan control is disabled. Signed-off-by: Oleg Chernovskiy <algonkvel@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-12-03drm/radeon: enable smc fan control on CIAlex Deucher
This seems to work well on CI boards after fixing the last few bugs noticed by Chernovsky Oleg. On boards with a high default fan speed this should reduce fan noise. Manual fan control is not enabled yet. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-12-03drm/radeon: fix copy paste typos in fan control for si/ciAlex Deucher
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-20drm/radeon/ci: disable needless sclk changesAlex Deucher
The current code always reprogrammed the sclk levels, but we don't currently handle disp sclk requirements so just skip it. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-20drm/radeon/ci: force pcie level before sclk and mclkAlex Deucher
Preferred ordering. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-20drm/radeon/ci: use different smc command for pcie dpmAlex Deucher
Use unforce levels rather than enable mask instruction. This is the preferred method. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-20drm/radeon/ci: apply disp voltage changes before clk changesAlex Deucher
Apply voltage changes for displays before changing clocks. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-20drm/radeon: fix PCC debugging message for CI DPMAlex Deucher
Add missing newline and print the bad gpio shift. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-20drm/radeon/dpm: add thermal dpm support for CIAlex Deucher
Not currently used. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-20drm/radeon/dpm: add smc fan control for CI (v2)Alex Deucher
Enable smc fan control for CI boards. Should reduce the fan noise on systems with a higher default fan profile. v2: disable by default, add additional fan setup, rpm control bug: https://bugs.freedesktop.org/show_bug.cgi?id=73338 Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: set power control in ci dpm enableAlex Deucher
Necessary for poper operation. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: powertune fixes for hawaiiAlex Deucher
- bapm is not available on hawaii - update pt defaults Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: fix dpm mc init for certain hawaii boardsAlex Deucher
Needs special overrides for certain vram configurations. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: set bootup pcie level to max for ci dpmAlex Deucher
Avoids problems when re-loading the driver. Does not affect power saving when dpm is enabled. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: fix default dpm state setupAlex Deucher
Only enable the first levels for mclk and sclk. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: workaround a hw bug in bonaire pcie dpmAlex Deucher
Some boards get stuck in pcie x1 otherwise. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: fix mclk vddc configuration for cards for hawaiiAlex Deucher
Need to use vddc0 for vdcc1 for certain hawaii configurations. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: fix sclk DS enablementAlex Deucher
Only enable it for levels 0 and 1. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: fix activity settings for sclk and mclk for CIAlex Deucher
Only need to be enabled on the first level. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: improve mclk param calcuations for ci dpmAlex Deucher
Properly take into account the post divider. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: fix dram timing for certain hawaii boardsAlex Deucher
Certain memory configurations need a fix. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: switch force state commands for CIAlex Deucher
Use the preferred SMC commands for forcing state on CI. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon/ci: handle gpio controlled dpm features properlyAlex Deucher
Certain feature enablement depends on entries in the atom gpio pin table. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-11-12drm/radeon: fix typo in CI dpm disableAlex Deucher
Need to disable DS, not enable it when disabling dpm. Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
2014-11-12drm/radeon: rework CI dpm thermal setupAlex Deucher
In preparation for fan control. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-10-16drm/radeon: reduce sparse false positive warningsMichele Curti
include radeon_asic.h header file in the various xxx_dpm.c files to reduce sparse false positive warnings. Not so great patch in itself, but reducing warning count from 391 to 258 may help to see real problems.. Signed-off-by: Michele Curti <michele.curti@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-10-03drm/radeon/ci: add uvd/vce info to dpm debugfs outputAlex Deucher
Track whether UVD or VCE are enabled in debugfs. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-10-01drm/radeon/dpm: drop clk/voltage dependency filters for CIAlex Deucher
Not sure this was ever necessary for CI, was just done to be on the safe side. bug: https://bugs.freedesktop.org/show_bug.cgi?id=69721 Reviewed-by: Alexandre Demers <alexandre.f.demers@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-08-15drm/radeon: Add missing lines to ci_set_thermal_temperature_rangeOleg Chernovskiy
Properly set the thermal min and max temp on CI. Otherwise, we end up setting the thermal ranges to 0 on resume and end up in the lowest power state. Signed-off-by: Oleg Chernovskiy <algonkvel@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
2014-08-05drm/radeon/dpm: handle voltage info fetching on hawaiiAlex Deucher
Some hawaii cards use a different method to fetch the voltage info from the vbios. bug: https://bugs.freedesktop.org/show_bug.cgi?id=74250 Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
2014-07-10drm/radeon: fix typo in ci_stop_dpm()Alex Deucher
Need to use the RREG32_SMC() accessor since the register is an smc indirect index. Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
2014-04-17drm/radeon: re-enable mclk dpm on R7 260X asicsAlex Deucher
If the new mc ucode is available. Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
2014-04-17drm/radeon: update CI DPM powertune settingsAlex Deucher
As per internal recommendations. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-04-17drm/radeon: disable mclk dpm on R7 260XAlex Deucher
Setting higher mclks seems to cause stability issues on some R7 260X boards. Disable it for now for stability until we find a proper fix. bug: https://bugs.freedesktop.org/show_bug.cgi?id=75992 Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
2014-02-18drm/radeon/cik: enable/disable vce cg when encoding v2Alex Deucher
Some of the vce clocks are automatic, others need to be manually enabled. For ease, just disable cg when vce is active. v2: rebased Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-02-18drm/radeon: enable vce dpm on CIAlex Deucher
VCE dpm dynamically adjusts the uvd clocks on demand. Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2014-02-18drm/radeon: add vce dpm support for CIAlex Deucher
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>