Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp525432pxm; Fri, 25 Feb 2022 12:57:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcx6f10fbVr8gJpO4NqaKQUhJgHnQeyWscgaFmJ2lrVMIfbLo1ITV5voobrzSWINaCd/ib X-Received: by 2002:a17:902:f28b:b0:14f:dff5:929b with SMTP id k11-20020a170902f28b00b0014fdff5929bmr9221693plc.154.1645822633147; Fri, 25 Feb 2022 12:57:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645822633; cv=none; d=google.com; s=arc-20160816; b=sX5vh8WLK8u11VjKREcI2peY+10NGUXZtjbmJwFC87nR02idtxfSIz2QQjirY31QXS B1EIkbOY+k6WGTuH5LrnALUsxspJwy9/nC42ig5/FAWTo+vEmgMOVvyxISbdIy40FX6K 1VjUGqp5FCYghMIaw33ffTisvO3PDb8dG8vnECWv0Ds/qoOEIrgNGFiIB2JRHT3iiESo cDgaSJCb2clPmyAj2pGCM4Io2s1c4SN+ifkfCNyzoCD+QgnlDw99lWZukl6a1LC9T9zy S2TKzdjpAskL8sJPcHHGP6xrUUs3c7tYIvBGvh0qdZXW4uhrMeUTay+33Nuk7MaJABjp OffA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dmarc-filter:sender:dkim-signature; bh=zwUj2HrkpS+nK6ojajWXOkTTihq6951vwdHqmJ0CDco=; b=OYQ3HxKJiWeZpMdQ3OwSU0XbSuA+qvj1G8lecq+vjLdFuVLCo4xAq9opMYTd5JC38k /vYDEHNh5qE56zdvxgpyJlV3n7hQc7/2L6DjTCDCVU9HABM9aYD/+Uauzz+IJppMEq6I YGsvC2rx1+/a54oF52jjNzCRxU+d7ZoL2XPW089numfT0R8OZZNyfGHhjbQ+AsO/0kvI hVp7dB2AFamDgZj+WfrTyTLn81+0vlNK3XgdhfOAperF9xCmfnMEt9UGrS05ob+xVhdQ zcWQGI9KoVgHRQn8reIHAvJhjcloXhC4xwyPMmGzLzgoSKoA67oTVOWnuLCpPnvz5lLV iGeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=hmdDnWdZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y4-20020a170902700400b0014fe2d3e229si2579214plk.141.2022.02.25.12.56.57; Fri, 25 Feb 2022 12:57:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=hmdDnWdZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234411AbiBYTWw (ORCPT + 99 others); Fri, 25 Feb 2022 14:22:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234707AbiBYTWt (ORCPT ); Fri, 25 Feb 2022 14:22:49 -0500 Received: from m43-7.mailgun.net (m43-7.mailgun.net [69.72.43.7]) by lindbergh.monkeyblade.net (Postfix) with UTF8SMTPS id CA6B91D6C8F for ; Fri, 25 Feb 2022 11:22:14 -0800 (PST) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1645816936; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=zwUj2HrkpS+nK6ojajWXOkTTihq6951vwdHqmJ0CDco=; b=hmdDnWdZ2fjV04PmHrocDOF8ywJQrWYyicSHY8nHvR5CcMFy+zzo5EquPED26RV4HNzGuif7 EJPXhlQGugIqgayv7qk2h/rUB1HxRqNwJmBu4GnZ+8OTTuctYbY3cgopmTPuoN/hhVfePKxH 1m6JggCdAN3WRJmB2TUzlTekJp0= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-east-1.postgun.com with SMTP id 62192c6218892df15f9a999d (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 25 Feb 2022 19:22:10 GMT Sender: quic_akhilpo=quicinc.com@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id BFF02C4360D; Fri, 25 Feb 2022 19:22:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Spam-Level: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 Received: from hyd-lnxbld559.qualcomm.com (unknown [202.46.22.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: akhilpo) by smtp.codeaurora.org (Postfix) with ESMTPSA id 538AFC43617; Fri, 25 Feb 2022 19:22:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 538AFC43617 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=fail (p=none dis=none) header.from=quicinc.com Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=quicinc.com From: Akhil P Oommen To: freedreno , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, Rob Clark , OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS , Dmitry Baryshkov , Bjorn Andersson Cc: Abhinav Kumar , =?UTF-8?q?Christian=20K=C3=B6nig?= , Daniel Vetter , David Airlie , Douglas Anderson , Jonathan Marek , Jordan Crouse , Sean Paul , Stephen Boyd , Vladimir Lypak , Yangtao Li , linux-kernel@vger.kernel.org Subject: [PATCH v2 4/5] drm/msm/adreno: Expose speedbin to userspace Date: Sat, 26 Feb 2022 00:51:31 +0530 Message-Id: <20220226005021.v2.4.I86c32730e08cba9e5c83f02ec17885124d45fa56@changeid> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1645816893-22815-1-git-send-email-quic_akhilpo@quicinc.com> References: <1645816893-22815-1-git-send-email-quic_akhilpo@quicinc.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Expose speedbin through MSM_PARAM_CHIP_ID parameter to help userspace identify the sku. Signed-off-by: Akhil P Oommen --- (no changes since v1) drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 3 +-- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 21 +++++++++++++++++---- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 3 +++ 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index f308a3f..e2728be3 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -10,7 +10,6 @@ #include #include -#include #include #define GPU_PAS_ID 13 @@ -1774,7 +1773,7 @@ static int a6xx_set_supported_hw(struct device *dev, struct adreno_rev rev) u32 speedbin; int ret; - ret = nvmem_cell_read_variable_le_u32(dev, "speed_bin", &speedbin); + ret = adreno_read_speedbin(dev, &speedbin); /* * -ENOENT means that the platform doesn't support speedbin which is * fine diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index d9d0c13..c593d13 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include "adreno_gpu.h" #include "a6xx_gpu.h" @@ -242,10 +243,12 @@ int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value) *value = !adreno_is_a650_family(adreno_gpu) ? 0x100000 : 0; return 0; case MSM_PARAM_CHIP_ID: - *value = adreno_gpu->rev.patchid | - (adreno_gpu->rev.minor << 8) | - (adreno_gpu->rev.major << 16) | - (adreno_gpu->rev.core << 24); + *value = (uint64_t) adreno_gpu->rev.patchid | + (uint64_t) (adreno_gpu->rev.minor << 8) | + (uint64_t) (adreno_gpu->rev.major << 16) | + (uint64_t) (adreno_gpu->rev.core << 24); + if (!adreno_gpu->info->revn) + *value |= ((uint64_t) adreno_gpu->speedbin) << 32; return 0; case MSM_PARAM_MAX_FREQ: *value = adreno_gpu->base.fast_rate; @@ -921,6 +924,11 @@ void adreno_gpu_ocmem_cleanup(struct adreno_ocmem *adreno_ocmem) adreno_ocmem->hdl); } +int adreno_read_speedbin(struct device *dev, u32 *speedbin) +{ + return nvmem_cell_read_variable_le_u32(dev, "speed_bin", speedbin); +} + int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, struct adreno_gpu *adreno_gpu, const struct adreno_gpu_funcs *funcs, int nr_rings) @@ -931,6 +939,7 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, struct msm_gpu *gpu = &adreno_gpu->base; struct adreno_rev *rev = &config->rev; const char *gpu_name; + u32 speedbin; adreno_gpu->funcs = funcs; adreno_gpu->info = adreno_info(config->rev); @@ -938,6 +947,10 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, adreno_gpu->revn = adreno_gpu->info->revn; adreno_gpu->rev = *rev; + if (adreno_read_speedbin(dev, &speedbin) || !speedbin) + speedbin = 0xffff; + adreno_gpu->speedbin = (uint16_t) (0xffff & speedbin); + gpu_name = adreno_gpu->info->name; if (!gpu_name) { gpu_name = devm_kasprintf(dev, GFP_KERNEL, "%d.%d.%d.%d", diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h index cffabe7..e2a7150 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h @@ -80,6 +80,7 @@ struct adreno_gpu { const struct adreno_info *info; uint32_t gmem; /* actual gmem size */ uint32_t revn; /* numeric revision name */ + uint16_t speedbin; const struct adreno_gpu_funcs *funcs; /* interesting register offsets to dump: */ @@ -324,6 +325,8 @@ adreno_iommu_create_address_space(struct msm_gpu *gpu, void adreno_set_llc_attributes(struct iommu_domain *iommu); +int adreno_read_speedbin(struct device *dev, u32 *speedbin); + /* * For a5xx and a6xx targets load the zap shader that is used to pull the GPU * out of secure mode -- 2.7.4