From patchwork Wed Oct 17 13:03:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sharat Masetty X-Patchwork-Id: 10645539 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EC05517D4 for ; Wed, 17 Oct 2018 13:04:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0A9E2851D for ; Wed, 17 Oct 2018 13:04:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D4B3E2AF4C; Wed, 17 Oct 2018 13:04:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B7AD2851D for ; Wed, 17 Oct 2018 13:04:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727217AbeJQU7v (ORCPT ); Wed, 17 Oct 2018 16:59:51 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:55538 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727000AbeJQU7v (ORCPT ); Wed, 17 Oct 2018 16:59:51 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6FD0F61325; Wed, 17 Oct 2018 13:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539781453; bh=PosYmVISeLglMOihmY3T8x4EJUJLsK3ohg7RdabA1uI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9vqyBOLUyUqUYt6NlcPWjQwz5L62pegFp4niyfQ25IeRIaNm2p81oC3BTDLW4fte 30ei/eGefwtpDY9lkfwTNjse/BwhicqjgKc2vQ0OWaaLYmSpvcXecpj3AJreohKBY2 r9QTt05vHMxCjQhU/yEKvtGPqrbw2wjxUktMa1ws= Received: from smasetty-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: smasetty@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 96FF760B1E; Wed, 17 Oct 2018 13:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1539781452; bh=PosYmVISeLglMOihmY3T8x4EJUJLsK3ohg7RdabA1uI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b2fcAKg4rTVvL5iZ0K/Vtu/yK1ar/Yu8X1xgONUcQxcishY30Md3yuYUEShQkngIX 9TJELglTnGHGkQecwq4QZb9zlA2fZMwc7cUrHvcj3pQqrkHHJYv+tg+QB0SIs7O3eA +ULc/PdCgeMpHkhtdoasKiX2qooNg24C/at7BAVs= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 96FF760B1E Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=smasetty@codeaurora.org From: Sharat Masetty To: freedreno@lists.freedesktop.org Cc: dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, jcrouse@codeaurora.org, Sharat Masetty Subject: [PATCH 1/3] drm/msm: Change gpu_busy() function Date: Wed, 17 Oct 2018 18:33:59 +0530 Message-Id: <1539781441-13076-2-git-send-email-smasetty@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1539781441-13076-1-git-send-email-smasetty@codeaurora.org> References: <1539781441-13076-1-git-send-email-smasetty@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The gpu_busy() function turns out is useful for performance profiling as well. So we change the input params to pass in the pointer to the previous busy cycles, this makes the function more generic and removes the dependency on the gpu devfreq. Signed-off-by: Sharat Masetty --- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 6 +++--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 6 +++--- drivers/gpu/drm/msm/msm_gpu.c | 3 ++- drivers/gpu/drm/msm/msm_gpu.h | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index 236a6ed..b5df80c 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c @@ -1428,7 +1428,7 @@ static struct msm_ringbuffer *a5xx_active_ring(struct msm_gpu *gpu) return a5xx_gpu->cur_ring; } -static unsigned long a5xx_gpu_busy(struct msm_gpu *gpu) +static unsigned long a5xx_gpu_busy(struct msm_gpu *gpu, u64 *prev_cycles) { u64 busy_cycles; unsigned long busy_time; @@ -1436,10 +1436,10 @@ static unsigned long a5xx_gpu_busy(struct msm_gpu *gpu) busy_cycles = gpu_read64(gpu, REG_A5XX_RBBM_PERFCTR_RBBM_0_LO, REG_A5XX_RBBM_PERFCTR_RBBM_0_HI); - busy_time = (busy_cycles - gpu->devfreq.busy_cycles) / + busy_time = (busy_cycles - *prev_cycles) / (clk_get_rate(gpu->core_clk) / 1000000); - gpu->devfreq.busy_cycles = busy_cycles; + *prev_cycles = busy_cycles; return busy_time; } diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index 07c3c3c..c0cd3ac 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -722,7 +722,7 @@ static void a6xx_destroy(struct msm_gpu *gpu) kfree(a6xx_gpu); } -static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu) +static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu, u64 *prev_cycles) { struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu); @@ -733,9 +733,9 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu) REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_L, REG_A6XX_GMU_CX_GMU_POWER_COUNTER_XOCLK_0_H); - busy_time = ((busy_cycles - gpu->devfreq.busy_cycles) * 10) / 192; + busy_time = ((busy_cycles - *prev_cycles) * 10) / 192; - gpu->devfreq.busy_cycles = busy_cycles; + *prev_cycles = busy_cycles; return busy_time; } diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index ca573f6..e9b5426 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -62,7 +62,8 @@ static int msm_devfreq_get_dev_status(struct device *dev, else status->current_frequency = clk_get_rate(gpu->core_clk); - status->busy_time = gpu->funcs->gpu_busy(gpu); + status->busy_time = gpu->funcs->gpu_busy(gpu, + &gpu->devfreq.busy_cycles); time = ktime_get(); status->total_time = ktime_us_delta(time, gpu->devfreq.time); diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 9df48e3..0ff23ca 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -71,7 +71,7 @@ struct msm_gpu_funcs { /* for generation specific debugfs: */ int (*debugfs_init)(struct msm_gpu *gpu, struct drm_minor *minor); #endif - unsigned long (*gpu_busy)(struct msm_gpu *gpu); + unsigned long (*gpu_busy)(struct msm_gpu *gpu, u64 *busy_cycles); struct msm_gpu_state *(*gpu_state_get)(struct msm_gpu *gpu); int (*gpu_state_put)(struct msm_gpu_state *state); unsigned long (*gpu_get_freq)(struct msm_gpu *gpu);