From patchwork Fri May 13 18:48:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Deucher X-Patchwork-Id: 9093061 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 79E42BF29F for ; Fri, 13 May 2016 18:49:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A6C8920154 for ; Fri, 13 May 2016 18:49:23 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 164702025A for ; Fri, 13 May 2016 18:49:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8EEEF6EAFA; Fri, 13 May 2016 18:49:20 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ig0-x242.google.com (mail-ig0-x242.google.com [IPv6:2607:f8b0:4001:c05::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 17E296EAF6 for ; Fri, 13 May 2016 18:49:09 +0000 (UTC) Received: by mail-ig0-x242.google.com with SMTP id rc4so2219669igc.0 for ; Fri, 13 May 2016 11:49:09 -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:in-reply-to:references; bh=zTcYYQaSwhj9hT4otWY8HvZUTOVtT4RpfROgAQgHBiA=; b=fLs2isZboNFgn7c7IDypmCx8gKnlV2187QZPjzLPGv6eHxzV6WJprmSeW05WL4/VZ7 iIx/fAPHDtbCAiHgOTrPuOhzPTmzKiAa5eIzhY3YL/oml9PQOiwnroa8rEL1o0ql/B1s 6RW2PFLGhjZsKlNFVqHjzkYLtFEM4X88CAVmR8uxtHroyV0yRg4tYwRPKmBZMjyYQtgx eRGqx3tAUGDaxk7D7Cnr6mxA89jS7WuTNGWiFDO7TKdYsh+M4/MxLwLd/xyYosVZ4tAd DnjHU0nkB9ysRNqPXiaxEQ69CsKKFcn0q9lXzXEOwLJuZBxLyXTLdKA9hnCWkRD4dlJw Ck8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zTcYYQaSwhj9hT4otWY8HvZUTOVtT4RpfROgAQgHBiA=; b=PLz6t15FiPvR4h4GmSF78ZVoiHJpslJsi3PdEpCVrvZQD3Oc7P4lHvvvp3AfSZ+8ZM 3CF1YA8cAfeyjxA3U4ysKKJdEarQMI4NxlfjoEfVUxdM0it/Ht96vL8kLbaPfQ4CArx6 U06RI6MgWy4B5Reor6/L8aSX6I1ci8i6oVlYwyEGuZqdeQsxWSnbtvqBsXxsSHu5HoTB E6b5IZwoGQfrCd4ci9WGI9L+wTtp719twfCfvB3Ap020rgHdZY3Uh2BE0VFhTn+neZ5O KJhLUlr/JA7sAzZEpNLWs+UQ3lK02XPLUdUJBFvAdRltSdIJlnoQBGEJk9sZDI0PAdsR BrcQ== X-Gm-Message-State: AOPr4FWa/yv2hYWdpCmitn4pnGsan04zgvPR/alKNu+A8JyAIDQWULzZ7XuMImE896YaFw== X-Received: by 10.50.65.42 with SMTP id u10mr1766467igs.13.1463165348412; Fri, 13 May 2016 11:49:08 -0700 (PDT) Received: from cm.amd.com ([165.204.55.251]) by smtp.gmail.com with ESMTPSA id u67sm1365954itd.1.2016.05.13.11.49.07 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 May 2016 11:49:08 -0700 (PDT) From: Alex Deucher X-Google-Original-From: Alex Deucher To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/6] drm/amd/powerplay: add sclk OD support on Tonga Date: Fri, 13 May 2016 14:48:55 -0400 Message-Id: <1463165336-14878-6-git-send-email-alexander.deucher@amd.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1463165336-14878-1-git-send-email-alexander.deucher@amd.com> References: <1463165336-14878-1-git-send-email-alexander.deucher@amd.com> Cc: Eric Huang , Alex Deucher X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_WEB, 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: Eric Huang This implements sclk overdrive(OD) overclocking support for Tonga, and the maximum overdrive percentage is 20. Reviewed-by: Alex Deucher Signed-off-by: Eric Huang Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c | 44 +++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c index cb28335..cf1fca4 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/tonga_hwmgr.c @@ -6194,6 +6194,48 @@ static int tonga_print_clock_levels(struct pp_hwmgr *hwmgr, return size; } +static int tonga_get_sclk_od(struct pp_hwmgr *hwmgr) +{ + struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend); + struct tonga_single_dpm_table *sclk_table = &(data->dpm_table.sclk_table); + struct tonga_single_dpm_table *golden_sclk_table = + &(data->golden_dpm_table.sclk_table); + int value; + + value = (sclk_table->dpm_levels[sclk_table->count - 1].value - + golden_sclk_table->dpm_levels[golden_sclk_table->count - 1].value) * + 100 / + golden_sclk_table->dpm_levels[golden_sclk_table->count - 1].value; + + return value; +} + +static int tonga_set_sclk_od(struct pp_hwmgr *hwmgr, uint32_t value) +{ + struct tonga_hwmgr *data = (struct tonga_hwmgr *)(hwmgr->backend); + struct tonga_single_dpm_table *golden_sclk_table = + &(data->golden_dpm_table.sclk_table); + struct pp_power_state *ps; + struct tonga_power_state *tonga_ps; + + if (value > 20) + value = 20; + + ps = hwmgr->request_ps; + + if (ps == NULL) + return -EINVAL; + + tonga_ps = cast_phw_tonga_power_state(&ps->hardware); + + tonga_ps->performance_levels[tonga_ps->performance_level_count - 1].engine_clock = + golden_sclk_table->dpm_levels[golden_sclk_table->count - 1].value * + value / 100 + + golden_sclk_table->dpm_levels[golden_sclk_table->count - 1].value; + + return 0; +} + static const struct pp_hwmgr_func tonga_hwmgr_funcs = { .backend_init = &tonga_hwmgr_backend_init, .backend_fini = &tonga_hwmgr_backend_fini, @@ -6236,6 +6278,8 @@ static const struct pp_hwmgr_func tonga_hwmgr_funcs = { .set_pp_table = tonga_set_pp_table, .force_clock_level = tonga_force_clock_level, .print_clock_levels = tonga_print_clock_levels, + .get_sclk_od = tonga_get_sclk_od, + .set_sclk_od = tonga_set_sclk_od, }; int tonga_hwmgr_init(struct pp_hwmgr *hwmgr)