From patchwork Wed Jun 26 13:22:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 2786481 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B8E1DC0AB1 for ; Wed, 26 Jun 2013 15:18:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AD84120504 for ; Wed, 26 Jun 2013 15:18:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id DB4AC204EB for ; Wed, 26 Jun 2013 15:18:45 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CF91AE636F for ; Wed, 26 Jun 2013 08:18:45 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qc0-f169.google.com (mail-qc0-f169.google.com [209.85.216.169]) by gabe.freedesktop.org (Postfix) with ESMTP id 69DACE6370 for ; Wed, 26 Jun 2013 06:25:22 -0700 (PDT) Received: by mail-qc0-f169.google.com with SMTP id c10so8203376qcz.14 for ; Wed, 26 Jun 2013 06:25:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=MtNAGxO3NkeejBsnMxYGnNPXSuL/zanR4KlbYx0k+xQ=; b=LD4duh9Q9kuWZUIv3WnmV0Oa7R1dOIrAiid6swA/SsXh1jkY7BtdSivhxw7rE2YlDZ s6gwLq+zCZTLJ5ybvkaqhVa5/HdJFMtykcmuAShjMA4p9htHgte2OW2p3V5/64xsWsEU ThpeRfbaB+DNLdE11cuTJK5lK0ZotSGW5iNKpjnmtcXAAK9cZRVAKuQvxM2TZ5DSffEn qAj8oSgoqAE1M/V8lqKHns8ttt3lM0cYkkGmydmXENt3D28GzICauJpx7KYqhuhD3bHB LNk2fe4/5FT8nKwiWRLm8MxWBClcuqSWhFmRl2tcrxJyGa24Wga2l9uUB2EPjLXwkYmg qjeA== X-Received: by 10.224.190.137 with SMTP id di9mr5206618qab.95.1372253121973; Wed, 26 Jun 2013 06:25:21 -0700 (PDT) Received: from localhost.localdomain (static-74-96-105-49.washdc.fios.verizon.net. [74.96.105.49]) by mx.google.com with ESMTPSA id r10sm32665096qeu.4.2013.06.26.06.25.21 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 26 Jun 2013 06:25:21 -0700 (PDT) From: alexdeucher@gmail.com To: dri-devel@lists.freedesktop.org Subject: [PATCH 097/165] drm/radeon/dpm/rv7xx: restructure code Date: Wed, 26 Jun 2013 09:22:57 -0400 Message-Id: <1372253045-17042-98-git-send-email-alexdeucher@gmail.com> X-Mailer: git-send-email 1.7.7.5 In-Reply-To: <1372253045-17042-1-git-send-email-alexdeucher@gmail.com> References: <1372253045-17042-1-git-send-email-alexdeucher@gmail.com> Cc: Alex Deucher X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Alex Deucher Needed to properly handle dynamic state adjustment. Signed-off-by: Alex Deucher --- drivers/gpu/drm/radeon/btc_dpm.c | 6 ++- drivers/gpu/drm/radeon/cypress_dpm.c | 6 ++- drivers/gpu/drm/radeon/rv740_dpm.c | 1 - drivers/gpu/drm/radeon/rv770_dpm.c | 77 ++++++++++++++++++---------------- drivers/gpu/drm/radeon/rv770_dpm.h | 8 +++- 5 files changed, 55 insertions(+), 43 deletions(-) diff --git a/drivers/gpu/drm/radeon/btc_dpm.c b/drivers/gpu/drm/radeon/btc_dpm.c index 79f5ed4..3ae4de6 100644 --- a/drivers/gpu/drm/radeon/btc_dpm.c +++ b/drivers/gpu/drm/radeon/btc_dpm.c @@ -2233,6 +2233,8 @@ void btc_dpm_reset_asic(struct radeon_device *rdev) int btc_dpm_set_power_state(struct radeon_device *rdev) { struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); + struct radeon_ps *new_ps = rdev->pm.dpm.requested_ps; + struct radeon_ps *old_ps = rdev->pm.dpm.current_ps; btc_apply_state_adjust_rules(rdev); @@ -2243,7 +2245,7 @@ int btc_dpm_set_power_state(struct radeon_device *rdev) if (eg_pi->pcie_performance_request) cypress_notify_link_speed_change_before_state_change(rdev); - rv770_set_uvd_clock_before_set_eng_clock(rdev); + rv770_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps); rv770_halt_smc(rdev); btc_set_at_for_uvd(rdev); if (eg_pi->smu_uvd_hs) @@ -2257,7 +2259,7 @@ int btc_dpm_set_power_state(struct radeon_device *rdev) rv770_resume_smc(rdev); rv770_set_sw_state(rdev); - rv770_set_uvd_clock_after_set_eng_clock(rdev); + rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); if (eg_pi->pcie_performance_request) cypress_notify_link_speed_change_after_state_change(rdev); diff --git a/drivers/gpu/drm/radeon/cypress_dpm.c b/drivers/gpu/drm/radeon/cypress_dpm.c index 22297b1..c9026ed 100644 --- a/drivers/gpu/drm/radeon/cypress_dpm.c +++ b/drivers/gpu/drm/radeon/cypress_dpm.c @@ -1930,13 +1930,15 @@ void cypress_dpm_disable(struct radeon_device *rdev) int cypress_dpm_set_power_state(struct radeon_device *rdev) { struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); + struct radeon_ps *new_ps = rdev->pm.dpm.requested_ps; + struct radeon_ps *old_ps = rdev->pm.dpm.current_ps; rv770_restrict_performance_levels_before_switch(rdev); if (eg_pi->pcie_performance_request) cypress_notify_link_speed_change_before_state_change(rdev); - rv770_set_uvd_clock_before_set_eng_clock(rdev); + rv770_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps); rv770_halt_smc(rdev); cypress_upload_sw_state(rdev); @@ -1947,7 +1949,7 @@ int cypress_dpm_set_power_state(struct radeon_device *rdev) rv770_resume_smc(rdev); rv770_set_sw_state(rdev); - rv770_set_uvd_clock_after_set_eng_clock(rdev); + rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); if (eg_pi->pcie_performance_request) cypress_notify_link_speed_change_after_state_change(rdev); diff --git a/drivers/gpu/drm/radeon/rv740_dpm.c b/drivers/gpu/drm/radeon/rv740_dpm.c index d0d750e..7aa1608 100644 --- a/drivers/gpu/drm/radeon/rv740_dpm.c +++ b/drivers/gpu/drm/radeon/rv740_dpm.c @@ -29,7 +29,6 @@ #include "rv770_dpm.h" #include "atom.h" -struct rv7xx_ps *rv770_get_ps(struct radeon_ps *rps); struct rv7xx_power_info *rv770_get_pi(struct radeon_device *rdev); u32 rv740_get_decoded_reference_divider(u32 encoded_ref) diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c index f5efa4c..db1dfbc 100644 --- a/drivers/gpu/drm/radeon/rv770_dpm.c +++ b/drivers/gpu/drm/radeon/rv770_dpm.c @@ -1155,10 +1155,10 @@ static int rv770_populate_smc_mvdd_table(struct radeon_device *rdev, return 0; } -static int rv770_init_smc_table(struct radeon_device *rdev) +static int rv770_init_smc_table(struct radeon_device *rdev, + struct radeon_ps *radeon_boot_state) { struct rv7xx_power_info *pi = rv770_get_pi(rdev); - struct radeon_ps *radeon_boot_state = rdev->pm.dpm.boot_ps; struct rv7xx_ps *boot_state = rv770_get_ps(radeon_boot_state); RV770_SMC_STATETABLE *table = &pi->smc_statetable; int ret; @@ -1364,10 +1364,9 @@ static void rv770_enable_dynamic_pcie_gen2(struct radeon_device *rdev, WREG32_P(GENERAL_PWRMGT, 0, ~ENABLE_GEN2PCIE); } -static void r7xx_program_memory_timing_parameters(struct radeon_device *rdev) +static void r7xx_program_memory_timing_parameters(struct radeon_device *rdev, + struct radeon_ps *radeon_new_state) { - struct radeon_ps *radeon_new_state = rdev->pm.dpm.requested_ps; - if ((rdev->family == CHIP_RV730) || (rdev->family == CHIP_RV710) || (rdev->family == CHIP_RV740)) @@ -1376,10 +1375,10 @@ static void r7xx_program_memory_timing_parameters(struct radeon_device *rdev) rv770_program_memory_timing_parameters(rdev, radeon_new_state); } -static int rv770_upload_sw_state(struct radeon_device *rdev) +static int rv770_upload_sw_state(struct radeon_device *rdev, + struct radeon_ps *radeon_new_state) { struct rv7xx_power_info *pi = rv770_get_pi(rdev); - struct radeon_ps *radeon_new_state = rdev->pm.dpm.requested_ps; u16 address = pi->state_table_start + offsetof(RV770_SMC_STATETABLE, driverState); RV770_SMC_SWSTATE state = { 0 }; @@ -1426,36 +1425,38 @@ int rv770_set_boot_state(struct radeon_device *rdev) return 0; } -void rv770_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev) +void rv770_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev, + struct radeon_ps *new_ps, + struct radeon_ps *old_ps) { - struct rv7xx_ps *new_state = rv770_get_ps(rdev->pm.dpm.requested_ps); - struct rv7xx_ps *current_state = rv770_get_ps(rdev->pm.dpm.current_ps); + struct rv7xx_ps *new_state = rv770_get_ps(new_ps); + struct rv7xx_ps *current_state = rv770_get_ps(old_ps); - if ((rdev->pm.dpm.requested_ps->vclk == rdev->pm.dpm.current_ps->vclk) && - (rdev->pm.dpm.requested_ps->dclk == rdev->pm.dpm.current_ps->dclk)) + if ((new_ps->vclk == old_ps->vclk) && + (new_ps->dclk == old_ps->dclk)) return; if (new_state->high.sclk >= current_state->high.sclk) return; - radeon_set_uvd_clocks(rdev, rdev->pm.dpm.requested_ps->vclk, - rdev->pm.dpm.requested_ps->dclk); + radeon_set_uvd_clocks(rdev, new_ps->vclk, old_ps->dclk); } -void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev) +void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev, + struct radeon_ps *new_ps, + struct radeon_ps *old_ps) { - struct rv7xx_ps *new_state = rv770_get_ps(rdev->pm.dpm.requested_ps); - struct rv7xx_ps *current_state = rv770_get_ps(rdev->pm.dpm.current_ps); + struct rv7xx_ps *new_state = rv770_get_ps(new_ps); + struct rv7xx_ps *current_state = rv770_get_ps(old_ps); - if ((rdev->pm.dpm.requested_ps->vclk == rdev->pm.dpm.current_ps->vclk) && - (rdev->pm.dpm.requested_ps->dclk == rdev->pm.dpm.current_ps->dclk)) + if ((new_ps->vclk == old_ps->vclk) && + (new_ps->dclk == old_ps->dclk)) return; if (new_state->high.sclk < current_state->high.sclk) return; - radeon_set_uvd_clocks(rdev, rdev->pm.dpm.requested_ps->vclk, - rdev->pm.dpm.requested_ps->dclk); + radeon_set_uvd_clocks(rdev, new_ps->vclk, new_ps->dclk); } int rv770_restrict_performance_levels_before_switch(struct radeon_device *rdev) @@ -1709,11 +1710,11 @@ void rv770_program_response_times(struct radeon_device *rdev) #endif } -static void rv770_program_dcodt_before_state_switch(struct radeon_device *rdev) +static void rv770_program_dcodt_before_state_switch(struct radeon_device *rdev, + struct radeon_ps *radeon_new_state, + struct radeon_ps *radeon_current_state) { struct rv7xx_power_info *pi = rv770_get_pi(rdev); - struct radeon_ps *radeon_new_state = rdev->pm.dpm.requested_ps; - struct radeon_ps *radeon_current_state = rdev->pm.dpm.current_ps; struct rv7xx_ps *new_state = rv770_get_ps(radeon_new_state); struct rv7xx_ps *current_state = rv770_get_ps(radeon_current_state); bool current_use_dc = false; @@ -1738,11 +1739,11 @@ static void rv770_program_dcodt_before_state_switch(struct radeon_device *rdev) rv730_program_dcodt(rdev, new_use_dc); } -static void rv770_program_dcodt_after_state_switch(struct radeon_device *rdev) +static void rv770_program_dcodt_after_state_switch(struct radeon_device *rdev, + struct radeon_ps *radeon_new_state, + struct radeon_ps *radeon_current_state) { struct rv7xx_power_info *pi = rv770_get_pi(rdev); - struct radeon_ps *radeon_new_state = rdev->pm.dpm.requested_ps; - struct radeon_ps *radeon_current_state = rdev->pm.dpm.current_ps; struct rv7xx_ps *new_state = rv770_get_ps(radeon_new_state); struct rv7xx_ps *current_state = rv770_get_ps(radeon_current_state); bool current_use_dc = false; @@ -1862,6 +1863,7 @@ int rv770_set_thermal_temperature_range(struct radeon_device *rdev, int rv770_dpm_enable(struct radeon_device *rdev) { struct rv7xx_power_info *pi = rv770_get_pi(rdev); + struct radeon_ps *boot_ps = rdev->pm.dpm.boot_ps; if (pi->gfx_clock_gating) rv770_restore_cgcg(rdev); @@ -1904,7 +1906,7 @@ int rv770_dpm_enable(struct radeon_device *rdev) if (rv770_upload_firmware(rdev)) return -EINVAL; /* get ucode version ? */ - if (rv770_init_smc_table(rdev)) + if (rv770_init_smc_table(rdev, boot_ps)) return -EINVAL; rv770_program_response_times(rdev); r7xx_start_smc(rdev); @@ -1979,19 +1981,21 @@ void rv770_dpm_disable(struct radeon_device *rdev) int rv770_dpm_set_power_state(struct radeon_device *rdev) { struct rv7xx_power_info *pi = rv770_get_pi(rdev); + struct radeon_ps *new_ps = rdev->pm.dpm.requested_ps; + struct radeon_ps *old_ps = rdev->pm.dpm.current_ps; rv770_restrict_performance_levels_before_switch(rdev); - rv770_set_uvd_clock_before_set_eng_clock(rdev); + rv770_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps); rv770_halt_smc(rdev); - rv770_upload_sw_state(rdev); - r7xx_program_memory_timing_parameters(rdev); + rv770_upload_sw_state(rdev, new_ps); + r7xx_program_memory_timing_parameters(rdev, new_ps); if (pi->dcodt) - rv770_program_dcodt_before_state_switch(rdev); + rv770_program_dcodt_before_state_switch(rdev, new_ps, old_ps); rv770_resume_smc(rdev); rv770_set_sw_state(rdev); if (pi->dcodt) - rv770_program_dcodt_after_state_switch(rdev); - rv770_set_uvd_clock_after_set_eng_clock(rdev); + rv770_program_dcodt_after_state_switch(rdev, new_ps, old_ps); + rv770_set_uvd_clock_after_set_eng_clock(rdev, new_ps, old_ps); return 0; } @@ -1999,13 +2003,14 @@ int rv770_dpm_set_power_state(struct radeon_device *rdev) void rv770_dpm_reset_asic(struct radeon_device *rdev) { struct rv7xx_power_info *pi = rv770_get_pi(rdev); + struct radeon_ps *boot_ps = rdev->pm.dpm.boot_ps; rv770_restrict_performance_levels_before_switch(rdev); if (pi->dcodt) - rv770_program_dcodt_before_state_switch(rdev); + rv770_program_dcodt_before_state_switch(rdev, boot_ps, boot_ps); rv770_set_boot_state(rdev); if (pi->dcodt) - rv770_program_dcodt_after_state_switch(rdev); + rv770_program_dcodt_after_state_switch(rdev, boot_ps, boot_ps); } void rv770_dpm_setup_asic(struct radeon_device *rdev) diff --git a/drivers/gpu/drm/radeon/rv770_dpm.h b/drivers/gpu/drm/radeon/rv770_dpm.h index dfb133f..22586df 100644 --- a/drivers/gpu/drm/radeon/rv770_dpm.h +++ b/drivers/gpu/drm/radeon/rv770_dpm.h @@ -266,8 +266,12 @@ int rv770_resume_smc(struct radeon_device *rdev); int rv770_set_sw_state(struct radeon_device *rdev); int rv770_set_boot_state(struct radeon_device *rdev); int rv7xx_parse_power_table(struct radeon_device *rdev); -void rv770_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev); -void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev); +void rv770_set_uvd_clock_before_set_eng_clock(struct radeon_device *rdev, + struct radeon_ps *new_ps, + struct radeon_ps *old_ps); +void rv770_set_uvd_clock_after_set_eng_clock(struct radeon_device *rdev, + struct radeon_ps *new_ps, + struct radeon_ps *old_ps); /* smc */ int rv770_read_smc_soft_register(struct radeon_device *rdev,