Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp218172lqe; Fri, 5 Apr 2024 20:23:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUYKFk1hNNh1hvrQDILPOWY2zXmWYdjR4FFWrXC7+A1SrzdZYgzuU4vL7JCglLViudyJ3HWwNFpZjYCG1rfeJBa64utA7IMXnLYXS6/MA== X-Google-Smtp-Source: AGHT+IHmIHYNrszTBN6sleqcfkGgPjranMgmNoPfHbniLLGy8oP8Qbc7R8V0Jmxtr3ypwkZo6h1q X-Received: by 2002:a05:6a21:7794:b0:1a7:1b6e:4da with SMTP id bd20-20020a056a21779400b001a71b6e04damr3246995pzc.27.1712373839254; Fri, 05 Apr 2024 20:23:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712373839; cv=pass; d=google.com; s=arc-20160816; b=ZBCGuePcsPN61kj3aCxtY4U5ImbsiIwdDOdrNiUwLZIR9GnKkztQLRqIRNyi//m5H2 MaxHdgOFU7+JT9R0nbLwpzgQWnzMXxdRE+r/w5BPi9xAOQQ1TDTQGUmRzq58PsaWBeJE HHzlDQWi5PtB5/Yyf0nkHvxv9eMQr/H0R6YixO0ScAVOSeCJPeHgYXM3sXVo3/LX/8yV tSJqeAMVQlILFJXgr2Q89mJ5Po7s/RnBS/it8i/9xIEb+gMIpM7YDR6fmVqkf1+SN3PT J0NdEWPpwImGYk6kaS15t7ctouTJvV3wHZlvhBXNg/160jMDHEmmwTPt2GlGZoyftz/G /ERg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=9UUjkB/gspbJc6rWQEtn8QgHPmoLmxjTAN2ZpK5QagM=; fh=ZQlCKRmj3oi2PqNPDKZyAsOgt+DD4oOb1CLnpc2lk1M=; b=sEF1/uj/9+Bj3OPbLM1yJu+Pl6Fm2dfqvLtakudezVeNH37t0XB+S+Ykwrm9sNxVWc TOh3MzZweCMDKKs8J2VKacPjCvQyHTMUPqXRQEC++r9cGV8BR3a5ha17ValPq3JXFiBL Pqa0kIPXUTrwO+pCGG/u004uJpesNwr285h+b/3lqxY4PT1SuiuOpIIv7+hUofVHZVIl VM6CfL3CyzEjkTGaZGlVusfcoYS3g38sNmg91D39Nk0ufvVErpjWixUkRNtuvJw6GO7x TsDkHKaTESRJvNfZjbrmwYgvKJaRDKHO9y78Fb8/z0fhMvh1TwzG/nOFU1ER744wKiDN W8vQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F3heiz5A; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-133784-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133784-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id g15-20020a17090a128f00b002a08101bc61si2382046pja.188.2024.04.05.20.23.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 20:23:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133784-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=F3heiz5A; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-133784-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133784-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id AF554B23584 for ; Sat, 6 Apr 2024 03:23:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 00A3B17BB5; Sat, 6 Apr 2024 03:23:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="F3heiz5A" Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E39E614273 for ; Sat, 6 Apr 2024 03:23:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712373822; cv=none; b=QXyTa4JeNpU6HtIF5hT5kA3mf87AneOU1QJI+crockAgBNnJ42MoGgot3yzlgufQPws9zJRbwtd5INfH21UPSZ5pTqbMHc8ccIkuJdssI64kBaYDNtdyN3aX6ara/m84cuc+9thBKsw7llJOj7fGhhRuw3rdttwd1ZqXTorBKvU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712373822; c=relaxed/simple; bh=qNr3cxZaaRKvS35D5tSEN7XYCbn71PlNi1XD5sm24jE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=TunkbHuUru80dQYBep7DKB7qd4fmgo0XGS+eFeSt7xUSeL3Gp7d26S4oGQCzHhb7op2fsshsaYg/PU6Y09TVn06oquZ6ermeDG7GOhsQjtNBfusBqPQmORM74XEe+LNryhY2HElTEXc4fWvtgZdrYsUPuyrnI7X21hvefSTmaPk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=F3heiz5A; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2d476d7972aso36109131fa.1 for ; Fri, 05 Apr 2024 20:23:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712373819; x=1712978619; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=9UUjkB/gspbJc6rWQEtn8QgHPmoLmxjTAN2ZpK5QagM=; b=F3heiz5APcLe/Wlr4I6iN0k2NszMLly5utvcAS/Tfk2srOFo9854Ob5qxTZPhYY7xt 1mjJ5fOFNxuwqiziG+rvN4Pz9gQnR4AQND8nljUETV67Bk2QGoiRpTEC5PKX9yVzkKv8 PNIFDC6mn8kE8VlRhiqgoK4WU2zn1/XXYppjrOR9X7Zjq5kkiFkN+iglF5gC16+WHz3h OkY3DH/if3oBR0UldRI2a3UKP2ToOiIc03+FitZu6Axhts8AGAp1D+Gqj+Kd072drtDD 4uISCtj6GY+RmU92N6kYEISy+g5VNqaZiar+SvXK6Ugi5tJutpBFK0MTK8ChHLkCGoBx Su8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712373819; x=1712978619; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=9UUjkB/gspbJc6rWQEtn8QgHPmoLmxjTAN2ZpK5QagM=; b=vdL0j5fCUASPRF6P4uXw9V31iszpBh3KSQdLkGrf5m6T8x5ov9VTYQQeouxySjdbLK ZqXRYvZEWXzrlgdAJLgnXf9RuKD/9rseKM39Q66l9GlBo+HBmLNRi6A67kAQZzmn1zzD o4qPOxCvnGSyBGk//YSZQIr//Y7bR4LwbhVd07j2y6VRkFHaWRZPpXEPta1Ni+CL6Yu6 4PlGJabpL7NnDJk0Qz15dHO8Ff/FNPQ7WTgicpuLAcf2VaxNrzfWofMRw66s8b0pUpx/ Fhxmb7dCGZZn5aYOgSTiOtMeYPvoaW5ZQnkcPwe/OcQN8WPM5Xw+2q3PWDXIifdvH75f 4dfw== X-Forwarded-Encrypted: i=1; AJvYcCXGo+x3zuZuNbiMNjoWQYA+Efi8C3I55hFJMhOuojihUtSA5stPy4roac3nJZs6N4+uv2eR1862A0vZpj2/GtF2AyaX5yBcevAtu3As X-Gm-Message-State: AOJu0YwTemKZE+E6yiwqxa7Gimk7K112Erq59eMQX8aGoWDUF7XvJp5J U1Z6vavXBnZhKGg9x3eHmLmoadgqd6tyETF5FUgwfogu1WwmQogIO1ilrKyhY3o= X-Received: by 2002:a05:6512:44b:b0:513:cf5e:f2ad with SMTP id y11-20020a056512044b00b00513cf5ef2admr2506909lfk.60.1712373818728; Fri, 05 Apr 2024 20:23:38 -0700 (PDT) Received: from eriador.lumag.spb.ru (dzyjmhyyyyyyyyyyyykxt-3.rev.dnainternet.fi. [2001:14ba:a00e:a300::227]) by smtp.gmail.com with ESMTPSA id b21-20020ac24115000000b00513c253696csm359141lfi.187.2024.04.05.20.23.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 20:23:38 -0700 (PDT) Date: Sat, 6 Apr 2024 06:23:36 +0300 From: Dmitry Baryshkov To: Konrad Dybcio Cc: Bjorn Andersson , Rob Clark , Abhinav Kumar , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, devicetree@vger.kernel.org, Neil Armstrong Subject: Re: [PATCH 4/6] drm/msm/adreno: Implement SMEM-based speed bin Message-ID: References: <20240405-topic-smem_speedbin-v1-0-ce2b864251b1@linaro.org> <20240405-topic-smem_speedbin-v1-4-ce2b864251b1@linaro.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240405-topic-smem_speedbin-v1-4-ce2b864251b1@linaro.org> On Fri, Apr 05, 2024 at 10:41:32AM +0200, Konrad Dybcio wrote: > On recent (SM8550+) Snapdragon platforms, the GPU speed bin data is > abstracted through SMEM, instead of being directly available in a fuse. > > Add support for SMEM-based speed binning, which includes getting > "feature code" and "product code" from said source and parsing them > to form something that lets us match OPPs against. > > Signed-off-by: Konrad Dybcio > --- > drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 8 +++--- > drivers/gpu/drm/msm/adreno/adreno_device.c | 2 ++ > drivers/gpu/drm/msm/adreno/adreno_gpu.c | 39 +++++++++++++++++++++++++++--- > drivers/gpu/drm/msm/adreno/adreno_gpu.h | 12 ++++++--- > 4 files changed, 51 insertions(+), 10 deletions(-) > > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > index 4cbdfabbcee5..6776fd80f7a6 100644 > --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > @@ -2890,13 +2890,15 @@ static u32 fuse_to_supp_hw(const struct adreno_info *info, u32 fuse) > return UINT_MAX; > } > > -static int a6xx_set_supported_hw(struct device *dev, const struct adreno_info *info) > +static int a6xx_set_supported_hw(struct adreno_gpu *adreno_gpu, > + struct device *dev, > + const struct adreno_info *info) > { > u32 supp_hw; > u32 speedbin; > int ret; > > - ret = adreno_read_speedbin(dev, &speedbin); > + ret = adreno_read_speedbin(adreno_gpu, dev, &speedbin); > /* > * -ENOENT means that the platform doesn't support speedbin which is > * fine > @@ -3056,7 +3058,7 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) > > a6xx_llc_slices_init(pdev, a6xx_gpu, is_a7xx); > > - ret = a6xx_set_supported_hw(&pdev->dev, config->info); > + ret = a6xx_set_supported_hw(adreno_gpu, &pdev->dev, config->info); > if (ret) { > a6xx_destroy(&(a6xx_gpu->base.base)); > return ERR_PTR(ret); > diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c > index c3703a51287b..901ef767e491 100644 > --- a/drivers/gpu/drm/msm/adreno/adreno_device.c > +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c > @@ -6,6 +6,8 @@ > * Copyright (c) 2014,2017 The Linux Foundation. All rights reserved. > */ > > +#include > + > #include "adreno_gpu.h" > > bool hang_debug = false; > diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c > index 074fb498706f..0e4ff532ac3c 100644 > --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c > +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c > @@ -21,6 +21,9 @@ > #include "msm_gem.h" > #include "msm_mmu.h" > > +#include > +#include > + > static u64 address_space_size = 0; > MODULE_PARM_DESC(address_space_size, "Override for size of processes private GPU address space"); > module_param(address_space_size, ullong, 0600); > @@ -1057,9 +1060,37 @@ void adreno_gpu_ocmem_cleanup(struct adreno_ocmem *adreno_ocmem) > adreno_ocmem->hdl); > } > > -int adreno_read_speedbin(struct device *dev, u32 *speedbin) > +int adreno_read_speedbin(struct adreno_gpu *adreno_gpu, > + struct device *dev, u32 *speedbin) > { > - return nvmem_cell_read_variable_le_u32(dev, "speed_bin", speedbin); > + u32 fcode, pcode; > + int ret; > + > + /* Try reading the speedbin via a nvmem cell first */ > + ret = nvmem_cell_read_variable_le_u32(dev, "speed_bin", speedbin); > + if (!ret && ret != -EINVAL) This is always false. > + return ret; > + > + ret = qcom_smem_get_feature_code(&fcode); > + if (ret) { > + dev_err(dev, "Couldn't get feature code from SMEM!\n"); > + return ret; This brings in QCOM_SMEM dependency (which is not mentioned in the Kconfig). Please keep iMX5 hardware in mind, so the dependency should be optional. Respective functions should be stubbed in the header. > + } > + > + ret = qcom_smem_get_product_code(&pcode); > + if (ret) { > + dev_err(dev, "Couldn't get product code from SMEM!\n"); > + return ret; > + } > + > + /* Don't consider fcode for external feature codes */ > + if (fcode <= SOCINFO_FC_EXT_RESERVE) > + fcode = SOCINFO_FC_UNKNOWN; > + > + *speedbin = FIELD_PREP(ADRENO_SKU_ID_PCODE, pcode) | > + FIELD_PREP(ADRENO_SKU_ID_FCODE, fcode); What about just asking the qcom_smem for the 'gpu_bin' and hiding gory details there? It almost feels that handling raw PCODE / FCODE here is too low-level and a subject to change depending on the socinfo format. > + > + return ret; > } > > int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, > @@ -1098,9 +1129,9 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, > devm_pm_opp_set_clkname(dev, "core"); > } > > - if (adreno_read_speedbin(dev, &speedbin) || !speedbin) > + if (adreno_read_speedbin(adreno_gpu, dev, &speedbin) || !speedbin) > speedbin = 0xffff; > - adreno_gpu->speedbin = (uint16_t) (0xffff & speedbin); the &= 0xffff should probably go to the adreno_read_speedbin / nvmem case. WDYT? > + adreno_gpu->speedbin = speedbin; > > gpu_name = devm_kasprintf(dev, GFP_KERNEL, "%"ADRENO_CHIPID_FMT, > ADRENO_CHIPID_ARGS(config->chip_id)); > diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h > index 460b399be37b..1770a9e20484 100644 > --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h > +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h > @@ -81,7 +81,12 @@ extern const struct adreno_reglist a612_hwcg[], a615_hwcg[], a630_hwcg[], a640_h > extern const struct adreno_reglist a660_hwcg[], a690_hwcg[], a702_hwcg[], a730_hwcg[], a740_hwcg[]; > > struct adreno_speedbin { > - uint16_t fuse; > + /* <= 16-bit for NVMEM fuses, 32b for SOCID values */ > + uint32_t fuse; > +#define ADRENO_SKU_ID_PCODE GENMASK(31, 16) > +#define ADRENO_SKU_ID_FCODE GENMASK(15, 0) > +#define ADRENO_SKU_ID(pcode, fcode) (pcode << 16 | fcode) > + > uint16_t speedbin; > }; > > @@ -137,7 +142,7 @@ struct adreno_gpu { > struct msm_gpu base; > const struct adreno_info *info; > uint32_t chip_id; > - uint16_t speedbin; > + uint32_t speedbin; > const struct adreno_gpu_funcs *funcs; > > /* interesting register offsets to dump: */ > @@ -520,7 +525,8 @@ int adreno_fault_handler(struct msm_gpu *gpu, unsigned long iova, int flags, > struct adreno_smmu_fault_info *info, const char *block, > u32 scratch[4]); > > -int adreno_read_speedbin(struct device *dev, u32 *speedbin); > +int adreno_read_speedbin(struct adreno_gpu *adreno_gpu, > + struct device *dev, u32 *speedbin); > > /* > * For a5xx and a6xx targets load the zap shader that is used to pull the GPU > > -- > 2.40.1 > -- With best wishes Dmitry