From patchwork Wed Jun 26 13:22:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 2786491 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 83A3C9F245 for ; Wed, 26 Jun 2013 15:19:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A4AB920504 for ; Wed, 26 Jun 2013 15:19:33 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 4E881204EB for ; Wed, 26 Jun 2013 15:19:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 41FBDE637A for ; Wed, 26 Jun 2013 08:19:32 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qa0-f53.google.com (mail-qa0-f53.google.com [209.85.216.53]) by gabe.freedesktop.org (Postfix) with ESMTP id 0B788E6373 for ; Wed, 26 Jun 2013 06:25:23 -0700 (PDT) Received: by mail-qa0-f53.google.com with SMTP id g10so1500097qah.5 for ; Wed, 26 Jun 2013 06:25:23 -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=qBb6GKTUfEfIv34MOpU1Iu8rqoYVtJJK2CiLD99k0a8=; b=kr8BiaX1lLxEqxoPB6wcJ8ThnwrGmYiV8Ks0l/QGPKNwyQrnF16ZlUWU7AuuioQX/v SRZtmSQof3yLuk9R6WqEfz6pP+0cSR/GZom5JKquc89O6Q52CYDCF9mEoP4b8o3NnIjA J01H09FYo3RZOgZ9ZrVw1qfByBzv+Y18aH1n8w3tSxOI+taZ7RSzyGeK7jAnPP7YBrEc K6TNDzgz8ISSxHEOTbp/p5WztFZpF620UphvC0sR8yHbFZ0xahaAizD7H6hs3Cl2YcB/ veofvh29dkZEcyoRSSVSQriziEhZENS5rPM5rJBAxwTCKJjn85omcVslWrT/qifWk5q0 JO2Q== X-Received: by 10.49.12.145 with SMTP id y17mr4688803qeb.7.1372253123329; Wed, 26 Jun 2013 06:25:23 -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.22 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 26 Jun 2013 06:25:22 -0700 (PDT) From: alexdeucher@gmail.com To: dri-devel@lists.freedesktop.org Subject: [PATCH 099/165] drm/radeon/dpm/btc: restructure code Date: Wed, 26 Jun 2013 09:22:59 -0400 Message-Id: <1372253045-17042-100-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 | 30 +++++++++++++++--------------- drivers/gpu/drm/radeon/btc_dpm.h | 3 ++- drivers/gpu/drm/radeon/ni_dpm.c | 3 ++- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/drm/radeon/btc_dpm.c b/drivers/gpu/drm/radeon/btc_dpm.c index 73a0ba3..30aed00 100644 --- a/drivers/gpu/drm/radeon/btc_dpm.c +++ b/drivers/gpu/drm/radeon/btc_dpm.c @@ -1604,11 +1604,11 @@ bool btc_dpm_enabled(struct radeon_device *rdev) return false; } -static int btc_init_smc_table(struct radeon_device *rdev) +static int btc_init_smc_table(struct radeon_device *rdev, + struct radeon_ps *radeon_boot_state) { struct rv7xx_power_info *pi = rv770_get_pi(rdev); struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); - struct radeon_ps *radeon_boot_state = rdev->pm.dpm.boot_ps; RV770_SMC_STATETABLE *table = &pi->smc_statetable; int ret; @@ -1668,11 +1668,11 @@ static int btc_init_smc_table(struct radeon_device *rdev) pi->sram_end); } -static void btc_set_at_for_uvd(struct radeon_device *rdev) +static void btc_set_at_for_uvd(struct radeon_device *rdev, + struct radeon_ps *radeon_new_state) { struct rv7xx_power_info *pi = rv770_get_pi(rdev); struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); - struct radeon_ps *radeon_new_state = rdev->pm.dpm.requested_ps; int idx = 0; if (r600_is_uvd_state(radeon_new_state->class, radeon_new_state->class2)) @@ -1692,9 +1692,9 @@ static void btc_set_at_for_uvd(struct radeon_device *rdev) } -void btc_notify_uvd_to_smc(struct radeon_device *rdev) +void btc_notify_uvd_to_smc(struct radeon_device *rdev, + struct radeon_ps *radeon_new_state) { - struct radeon_ps *radeon_new_state = rdev->pm.dpm.requested_ps; struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); if (r600_is_uvd_state(radeon_new_state->class, radeon_new_state->class2)) { @@ -1814,11 +1814,11 @@ static int btc_enable_ulv(struct radeon_device *rdev) return 0; } -static int btc_set_power_state_conditionally_enable_ulv(struct radeon_device *rdev) +static int btc_set_power_state_conditionally_enable_ulv(struct radeon_device *rdev, + struct radeon_ps *radeon_new_state) { int ret = 0; struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); - struct radeon_ps *radeon_new_state = rdev->pm.dpm.requested_ps; if (eg_pi->ulv.supported) { if (btc_is_state_ulv_compatible(rdev, radeon_new_state)) { @@ -2059,10 +2059,10 @@ static void btc_init_stutter_mode(struct radeon_device *rdev) } } -static void btc_apply_state_adjust_rules(struct radeon_device *rdev) +static void btc_apply_state_adjust_rules(struct radeon_device *rdev, + struct radeon_ps *rps) { struct evergreen_power_info *eg_pi = evergreen_get_pi(rdev); - struct radeon_ps *rps = rdev->pm.dpm.requested_ps; struct rv7xx_ps *ps = rv770_get_ps(rps); struct radeon_clock_and_voltage_limits *max_limits; bool disable_mclk_switching; @@ -2236,7 +2236,7 @@ int btc_dpm_set_power_state(struct radeon_device *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); + btc_apply_state_adjust_rules(rdev, new_ps); btc_disable_ulv(rdev); btc_set_boot_state_timing(rdev); @@ -2247,9 +2247,9 @@ int btc_dpm_set_power_state(struct radeon_device *rdev) rv770_set_uvd_clock_before_set_eng_clock(rdev, new_ps, old_ps); rv770_halt_smc(rdev); - btc_set_at_for_uvd(rdev); + btc_set_at_for_uvd(rdev, new_ps); if (eg_pi->smu_uvd_hs) - btc_notify_uvd_to_smc(rdev); + btc_notify_uvd_to_smc(rdev, new_ps); cypress_upload_sw_state(rdev, new_ps); if (eg_pi->dynamic_ac_timing) @@ -2264,7 +2264,7 @@ int btc_dpm_set_power_state(struct radeon_device *rdev) if (eg_pi->pcie_performance_request) cypress_notify_link_speed_change_after_state_change(rdev, new_ps, old_ps); - btc_set_power_state_conditionally_enable_ulv(rdev); + btc_set_power_state_conditionally_enable_ulv(rdev, new_ps); return 0; } @@ -2323,7 +2323,7 @@ int btc_dpm_enable(struct radeon_device *rdev) return -EINVAL; cypress_get_table_locations(rdev); - btc_init_smc_table(rdev); + btc_init_smc_table(rdev, boot_ps); if (eg_pi->dynamic_ac_timing) cypress_populate_mc_reg_table(rdev, boot_ps); diff --git a/drivers/gpu/drm/radeon/btc_dpm.h b/drivers/gpu/drm/radeon/btc_dpm.h index c22d39f..1a15e0e 100644 --- a/drivers/gpu/drm/radeon/btc_dpm.h +++ b/drivers/gpu/drm/radeon/btc_dpm.h @@ -51,6 +51,7 @@ void btc_apply_voltage_delta_rules(struct radeon_device *rdev, u16 *vddc, u16 *vddci); bool btc_dpm_enabled(struct radeon_device *rdev); int btc_reset_to_default(struct radeon_device *rdev); -void btc_notify_uvd_to_smc(struct radeon_device *rdev); +void btc_notify_uvd_to_smc(struct radeon_device *rdev, + struct radeon_ps *radeon_new_state); #endif diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c index 44016f2..9f68115 100644 --- a/drivers/gpu/drm/radeon/ni_dpm.c +++ b/drivers/gpu/drm/radeon/ni_dpm.c @@ -3628,6 +3628,7 @@ int ni_power_control_set_level(struct radeon_device *rdev) int ni_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; int ret; ni_apply_state_adjust_rules(rdev); @@ -3637,7 +3638,7 @@ int ni_dpm_set_power_state(struct radeon_device *rdev) ni_enable_smc_cac(rdev, false); rv770_halt_smc(rdev); if (eg_pi->smu_uvd_hs) - btc_notify_uvd_to_smc(rdev); + btc_notify_uvd_to_smc(rdev, new_ps); ni_upload_sw_state(rdev); if (eg_pi->dynamic_ac_timing) ni_upload_mc_reg_table(rdev);