From patchwork Thu Dec 20 18:46:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chia-I Wu X-Patchwork-Id: 10739339 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 9BA4C13B5 for ; Thu, 20 Dec 2018 18:46:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B7C828BCC for ; Thu, 20 Dec 2018 18:46:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E5BA28C11; Thu, 20 Dec 2018 18:46:54 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4837728BCC for ; Thu, 20 Dec 2018 18:46:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B35566F4B4; Thu, 20 Dec 2018 18:46:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id B3E2B6E495; Thu, 20 Dec 2018 18:46:49 +0000 (UTC) Received: by mail-pg1-x541.google.com with SMTP id w7so1270726pgp.13; Thu, 20 Dec 2018 10:46:49 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=qpm0OeEV51GRFkZHOOPKEwN/puBWg+iHYfSt/aZQ6Rk=; b=YZPgutCjkFCAYsRxAGnLZc89WVsaayXFFQH5KX349tTQXnDKFAOvDAcRy3cUnYL5si SC7DRbLyOxMYKBGWCy262hbSdzG7qU8RMeTZ4gWM6/17vx7pTWkL5nZKdPLDl4sxhOFx uqR5Loc14JUFXbC7W5rpigx2Sw+oasSNXg8mMmk0r3LjyGxBsM81BEKFsS7rS+NzYQPg e43MELhY9BT9dANP9E3ijFyl4ap1Khij/Y+72vjZE4ioWasfOMk3nUNocQ1nS9ioQg7h t4X+1eU1ZYjN/h4ADewCYDb+JFo962qXxj0tj5jd20+dfJ6qbKN2vZBOsJDCtrNZAoAr tEFA== X-Gm-Message-State: AA+aEWZc43r27UEYuM9ZMMoobX+GVsKfS/zsiR37yVydeDzGiSHswy1Y 1PziAHKYfBfeBNJX/doQLM3SXoZzyPo= X-Google-Smtp-Source: AFSGD/Xe1vRAJzZ2R9eHvzVvEHY2xFQXuBcrIN21QGqyJu0TXsR1ctNBNTvXmnvugVhIaveVyJO9gg== X-Received: by 2002:a63:ef47:: with SMTP id c7mr11737901pgk.386.1545331608549; Thu, 20 Dec 2018 10:46:48 -0800 (PST) Received: from olv0.mtv.corp.google.com ([2620:15c:202:201:9649:82d6:f889:b307]) by smtp.gmail.com with ESMTPSA id 5sm32966426pfz.149.2018.12.20.10.46.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 20 Dec 2018 10:46:47 -0800 (PST) From: Chia-I Wu To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/msm/a6xx: add a6xx_gpu_state_get Date: Thu, 20 Dec 2018 10:46:45 -0800 Message-Id: <20181220184645.102974-1-olvaffe@gmail.com> X-Mailer: git-send-email 2.20.1.415.g653613c723-goog MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: freedreno@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP It gets the generic states from the adreno core. This also adds a missing NULL check in msm_gpu_open. Signed-off-by: Chia-I Wu --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 44 +++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_debugfs.c | 2 +- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index 631257c297fd..dff3367aa432 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -778,6 +778,48 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu) return (unsigned long)busy_time; } +struct a6xx_gpu_state { + struct msm_gpu_state base; +}; + +static struct msm_gpu_state *a6xx_gpu_state_get(struct msm_gpu *gpu) +{ + struct a6xx_gpu_state *a6xx_state = kzalloc(sizeof(*a6xx_state), + GFP_KERNEL); + + if (!a6xx_state) + return ERR_PTR(-ENOMEM); + + /* Temporarily disable hardware clock gating before reading the hw */ + a6xx_set_hwcg(gpu, false); + + /* get the generic state from the adreno core */ + adreno_gpu_state_get(gpu, &(a6xx_state->base)); + + a6xx_set_hwcg(gpu, true); + + return &a6xx_state->base; +} + +static void a6xx_gpu_state_destroy(struct kref *kref) +{ + struct msm_gpu_state *state = container_of(kref, + struct msm_gpu_state, ref); + struct a6xx_gpu_state *a6xx_state = container_of(state, + struct a6xx_gpu_state, base); + + adreno_gpu_state_destroy(state); + kfree(a6xx_state); +} + +static int a6xx_gpu_state_put(struct msm_gpu_state *state) +{ + if (IS_ERR_OR_NULL(state)) + return 1; + + return kref_put(&state->ref, a6xx_gpu_state_destroy); +} + static const struct adreno_gpu_funcs funcs = { .base = { .get_param = adreno_get_param, @@ -794,6 +836,8 @@ static const struct adreno_gpu_funcs funcs = { .show = a6xx_show, #endif .gpu_busy = a6xx_gpu_busy, + .gpu_state_get = a6xx_gpu_state_get, + .gpu_state_put = a6xx_gpu_state_put, .gpu_get_freq = a6xx_gmu_get_freq, .gpu_set_freq = a6xx_gmu_set_freq, }, diff --git a/drivers/gpu/drm/msm/msm_debugfs.c b/drivers/gpu/drm/msm/msm_debugfs.c index f0da0d3c8a80..ee80856c4476 100644 --- a/drivers/gpu/drm/msm/msm_debugfs.c +++ b/drivers/gpu/drm/msm/msm_debugfs.c @@ -75,7 +75,7 @@ static int msm_gpu_open(struct inode *inode, struct file *file) struct msm_gpu_show_priv *show_priv; int ret; - if (!gpu) + if (!gpu || !gpu->funcs->gpu_state_get) return -ENODEV; show_priv = kmalloc(sizeof(*show_priv), GFP_KERNEL);