From patchwork Mon Aug 17 22:01:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rob Clark X-Patchwork-Id: 250638 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51DA7C433E5 for ; Mon, 17 Aug 2020 22:02:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2D2952078B for ; Mon, 17 Aug 2020 22:02:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PSiV58US" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729335AbgHQWCl (ORCPT ); Mon, 17 Aug 2020 18:02:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729311AbgHQWCf (ORCPT ); Mon, 17 Aug 2020 18:02:35 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6135C061346; Mon, 17 Aug 2020 15:02:34 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id 2so8454818pjx.5; Mon, 17 Aug 2020 15:02:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wvz5YKiT932AWU4GOoumP4PC6lpfTwxubtkW9TJEg2g=; b=PSiV58USy6C7h9g+3N7CkyKem7FFwM9Mj3+dcYPerZWcI1GQVjnBu1vlu5xI3SHctE etWYrHQomPdBIiVuCk5OPu/yUi+/uCXg9z4r3BfYBudEj4TXVx6AlwgHrxOn3Djkuh6I VId/SC3aj3Kh2LfNnB5eS8IxzkOkdzbVrCi2QlLDwSq4jdMX1TUukLoPbW9vEZCWO3Pg E3UO1M84JGXmykPB8O2fY0nAqKxWWJzru4tNF/2ClDXvuIzaVUhCZbtPeP2/dI9pdG2Q YCN/FgzAb3zhoks4dcm8MIL9XVc8GRI+rd8d9/xLbHacPd7eohpHB3DBwbsxuyAMUYs1 9oMw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=wvz5YKiT932AWU4GOoumP4PC6lpfTwxubtkW9TJEg2g=; b=PJYl6nCKsdxOTL6jAYjhcLOSt+d7k0mv/xKvbQ6PrpT62qIkUxJQaFjfGFNvQ3y93c 9PZfmT7+8VTVIyH2YMBzTU6oWOUUnGkyOK+cDgp/Pc5VghwhUPNLe6OtCJ1/hEiUrJIQ 2D6dMQER+iMx2VG3xBCBVML+qUqPuWcWckHl5JVtnbl7edLqhX6sbZUJOiP283J18FeK 3TvIzZcvTWpXgg8pHJoewpB8QFD0qqTlT/hO2ECRv7+DtkJec8+aWvRTceYEbEGTmvoN pAGkcaD696CUOg8p/x4y25yGOsjmPTsvufvdyclW/2J+LpzvQGcPNJacvuxURKk6zCwp teug== X-Gm-Message-State: AOAM530BJYwCB8mcVXS+XImeaynN6EHJ3uM/DJ8TcAE1eX5abOQ2rA0X BRzzn3iBv/soUA6hspLyRp8= X-Google-Smtp-Source: ABdhPJygcQQMG1n+yfZRF3rHKTdu4DvQo6yoXYPF3Kp0PgJGNgE8mv3gC7OazZ3tfaqONTYigjsxmw== X-Received: by 2002:a17:902:9693:: with SMTP id n19mr5444193plp.33.1597701754348; Mon, 17 Aug 2020 15:02:34 -0700 (PDT) Received: from localhost (c-73-25-156-94.hsd1.or.comcast.net. [73.25.156.94]) by smtp.gmail.com with ESMTPSA id 2sm19274989pjg.32.2020.08.17.15.02.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2020 15:02:32 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-arm-msm@vger.kernel.org Cc: Sai Prakash Ranjan , Will Deacon , freedreno@lists.freedesktop.org, Bjorn Andersson , Sibi Sankar , Vivek Gautam , Stephen Boyd , Robin Murphy , Joerg Roedel , Rob Clark , Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Jordan Crouse , Jonathan Marek , Shawn Guo , AngeloGioacchino Del Regno , Sharat Masetty , linux-kernel@vger.kernel.org (open list) Subject: [PATCH 06/20] drm/msm/gpu: add dev_to_gpu() helper Date: Mon, 17 Aug 2020 15:01:31 -0700 Message-Id: <20200817220238.603465-7-robdclark@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200817220238.603465-1-robdclark@gmail.com> References: <20200817220238.603465-1-robdclark@gmail.com> MIME-Version: 1.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Rob Clark In a later patch, the drvdata will not directly be 'struct msm_gpu *', so add a helper to reduce the churn. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/adreno/adreno_device.c | 10 ++++------ drivers/gpu/drm/msm/msm_gpu.c | 6 +++--- drivers/gpu/drm/msm/msm_gpu.h | 5 +++++ 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c index 9eeb46bf2a5d..26664e1b30c0 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -282,7 +282,7 @@ struct msm_gpu *adreno_load_gpu(struct drm_device *dev) int ret; if (pdev) - gpu = platform_get_drvdata(pdev); + gpu = dev_to_gpu(&pdev->dev); if (!gpu) { dev_err_once(dev->dev, "no GPU device was found\n"); @@ -425,7 +425,7 @@ static int adreno_bind(struct device *dev, struct device *master, void *data) static void adreno_unbind(struct device *dev, struct device *master, void *data) { - struct msm_gpu *gpu = dev_get_drvdata(dev); + struct msm_gpu *gpu = dev_to_gpu(dev); pm_runtime_force_suspend(dev); gpu->funcs->destroy(gpu); @@ -490,16 +490,14 @@ static const struct of_device_id dt_match[] = { #ifdef CONFIG_PM static int adreno_resume(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct msm_gpu *gpu = platform_get_drvdata(pdev); + struct msm_gpu *gpu = dev_to_gpu(dev); return gpu->funcs->pm_resume(gpu); } static int adreno_suspend(struct device *dev) { - struct platform_device *pdev = to_platform_device(dev); - struct msm_gpu *gpu = platform_get_drvdata(pdev); + struct msm_gpu *gpu = dev_to_gpu(dev); return gpu->funcs->pm_suspend(gpu); } diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index d5645472b25d..6aa9e04e52e7 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -24,7 +24,7 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq, u32 flags) { - struct msm_gpu *gpu = platform_get_drvdata(to_platform_device(dev)); + struct msm_gpu *gpu = dev_to_gpu(dev); struct dev_pm_opp *opp; opp = devfreq_recommended_opp(dev, freq, flags); @@ -45,7 +45,7 @@ static int msm_devfreq_target(struct device *dev, unsigned long *freq, static int msm_devfreq_get_dev_status(struct device *dev, struct devfreq_dev_status *status) { - struct msm_gpu *gpu = platform_get_drvdata(to_platform_device(dev)); + struct msm_gpu *gpu = dev_to_gpu(dev); ktime_t time; if (gpu->funcs->gpu_get_freq) @@ -64,7 +64,7 @@ static int msm_devfreq_get_dev_status(struct device *dev, static int msm_devfreq_get_cur_freq(struct device *dev, unsigned long *freq) { - struct msm_gpu *gpu = platform_get_drvdata(to_platform_device(dev)); + struct msm_gpu *gpu = dev_to_gpu(dev); if (gpu->funcs->gpu_get_freq) *freq = gpu->funcs->gpu_get_freq(gpu); diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 0db117a7339b..8bda7beaed4b 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -141,6 +141,11 @@ struct msm_gpu { struct msm_gpu_state *crashstate; }; +static inline struct msm_gpu *dev_to_gpu(struct device *dev) +{ + return dev_get_drvdata(dev); +} + /* It turns out that all targets use the same ringbuffer size */ #define MSM_GPU_RINGBUFFER_SZ SZ_32K #define MSM_GPU_RINGBUFFER_BLKSIZE 32