Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp864830lqb; Wed, 17 Apr 2024 13:05:42 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUDp5Qif+CjVg4+MtUVBD/AiFxGEckALSK0ntuA3CjFU7TKVq/C2l9yvhBlpCnYO6Z46rl8y7QeMOjS4CRGhO6lK9ho7nhdyuP+FodC+A== X-Google-Smtp-Source: AGHT+IGWKpcas6Np7MioovBYcnq7H2lgXIPIPDd8lZRmJZwv+t0icN+fjrtlRVHa8Pcfya43fz2Z X-Received: by 2002:a17:902:f68b:b0:1e7:f944:b000 with SMTP id l11-20020a170902f68b00b001e7f944b000mr719284plg.24.1713384341558; Wed, 17 Apr 2024 13:05:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713384341; cv=pass; d=google.com; s=arc-20160816; b=EsaiVdFYxta3r5xP8CaaVvcGB9za8/IdEWD6k9HXPoe8z4QK9TD1Klc4eeS1dhAJJh 6WcN5LLelJba6nH4VQIxjckDxWpxI5V+1txV8wGOk1r1kQL1INe7/UMTtMqv4Of/qUZe DUgyzNZ2mMtvqt/+cXctFuh4+R6SqGVMMsZV4OS2gyAEbZhNRPmy2s1Z8eq3ckZm0+YV gh2KpZIL93FxduZ2mkAdNEi1qUj7LJ7J2jQwMjOA29LVkEIhDcfEnhdBBxy4IfZ2Pqfz J9kwwPdKWRWyDo6GW+MXMfNBrQdPG4OYIoXlGDuvC2c8xm2CKCwO9AGo8K3uvOCKpV1/ ZD7A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=NswjQ6W9E1I4DVVC+LdC7BYZUgvwz7xRLylojwPOzVM=; fh=SAUzzlofdNZ/ogfld0MFy0DtOzigdYfuIAWaS0BPogs=; b=0xmd29mA10bFrZ/D8g515A0sFPdJ+Xju9KVxDZkjfofL6IDwIT9zAA4ESRuXEoPc66 gq2kyH9YOr2wOrT09SkrK0P3NsUfM09bn5+yMKjwFrBus6ug2t0sClaFwSAfxEn+IH9G A+LcbXewjbGRVt3Dc2tfUkZdmKOThg6CGnLDwq7eyATvbz7ZZA76tDU2iCPcsYwN0reH i0uSbQXYb2PJ8MMko5edSSgofRQoE0NWrNLKeEC4/YUXropdVpKAIUnTl5efP/4KN8uk etpzRVcP9Z2KMyDTg8q3/OaKfaO3NrbJcy9Bi6+q91vl/fFpyaPSP/bOFXPb/OOix/mr VeWw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hORub3CC; 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-149155-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149155-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id im15-20020a170902bb0f00b001dcfaf5bfefsi18795plb.573.2024.04.17.13.05.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 13:05:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-149155-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hORub3CC; 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-149155-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-149155-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 21849285411 for ; Wed, 17 Apr 2024 20:05:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7085A172BCA; Wed, 17 Apr 2024 20:03:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hORub3CC" Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) (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 6CF115FEE4 for ; Wed, 17 Apr 2024 20:03:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713384195; cv=none; b=NRuuU4nrHXhIUnSeyEYLxPGpRZ3+4QQRH+B6xEoS10v02mPQoHcGax0EuRJqAenIxw7XA6YpmUgzYZEtdUzfugzY+TM7btZN+k9N2yBSlXr12Wgau0WUCW5aUW8D2U1ECTgPdO4b6G2LKQh6uFw+D5IrUrjGyeJQln9fRh3vs9o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713384195; c=relaxed/simple; bh=U+NHb0R2aY2AoDLFItO3sg266XV8A7zlHAZIod5ceWE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Zr57oP7t9XeUFZnmtSXnA5K4LIRcNUFaEUXWWsl1XlYQxvVaadVo0uM4iz+UisNeKD6DRzkz2dkHtj5c77QdpuPyE2T5LY7YV9pgF3WJ3EYX/EferfS4gwFcDW7S9JzQc1mkbjfj1UcAj2PPW7u6gcE6H0dgQH0H3kWS1j0yIsw= 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=hORub3CC; arc=none smtp.client-ip=209.85.167.41 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-lf1-f41.google.com with SMTP id 2adb3069b0e04-5194cebd6caso83351e87.0 for ; Wed, 17 Apr 2024 13:03:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713384191; x=1713988991; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=NswjQ6W9E1I4DVVC+LdC7BYZUgvwz7xRLylojwPOzVM=; b=hORub3CCm8MdKQ2hCh6RvJOwjrhpClIm+4BQHF+PhqPWfja7uVQPkt8EnFvmzJ2DYz MZPPq42VVPysF3FDq+QauuNROy8Cq+VQB+Q6YXzBcvdT2ry7XQWVxhcKeWDYrSPjAl/E Z1latH1ZALOj6IZSUCa4NncBOvjM+bLpHlkZbvFUNr6uMJxkEDQ4rurFsOcO0wVZyrIo dE2LfUwscvtds5SCes7IKcFGobcEkk+tnqCFffWag1QqnhAPgOcv/b3VJyK4pxBvyNzQ TWex09bqSTj4UdGVe4TslAjHwKq1MWMelFiUMfVAMclS402tkoAZHR/vo7K2PakaVRea afSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713384191; x=1713988991; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NswjQ6W9E1I4DVVC+LdC7BYZUgvwz7xRLylojwPOzVM=; b=ZeE80a5Ldf6l86Xh9u/krVw1I8RFHSn0g4Qd2m1UYNpmT8xKxdmW3EMqDVtZC01OoK o+rL4hAxtg6m/D8tv2x7zZppy/N5c1+ogpeI85gF94zT4d6QQGt04QuO6afify/XCv5V YWOQCIJ1MQSsGMJjy7siSZLxocgWu83kI604sh6mJcLxnbdkDFjMV/PuZzQ4ymaijyKr TMn5x0d1S80Wtn/rVU8VQzwIx5X2rBAwFBc1gUJEae+TzLmsKPSp193OLETt1C2r6Eqi 0coa3edgQdOO+MmZMlZ85XSTwIO8NOv9+K0pXOlwUZ+2TfOsA+97PuFCYmNxEDTAxo0H LbdQ== X-Forwarded-Encrypted: i=1; AJvYcCUwOOnTmnWIcP2IlGsWZgjybX1UN5MVZYhQMgp25w8NKS0rmzYTiiQZtpEgLU/2OR7mXYgC0Oe0rWT/tkWcdu8K+0jt04a3Y2bY3TW5 X-Gm-Message-State: AOJu0YyOH1Jwxt+oQOrjC9sBkDY6zskVDPBUDHe6oxKlz2EuQYpo0xky RC1TDN43WhCu0+NDP58uFjdYVX+K0yqBBWvy5h1NLGSZfxYh6zzs0yzzY4/UeRt0NFe4kZhvIjj 9 X-Received: by 2002:ac2:51b6:0:b0:513:2c56:f5e2 with SMTP id f22-20020ac251b6000000b005132c56f5e2mr170116lfk.60.1713384189619; Wed, 17 Apr 2024 13:03:09 -0700 (PDT) Received: from [192.168.45.55] (078088045141.garwolin.vectranet.pl. [78.88.45.141]) by smtp.gmail.com with ESMTPSA id xa4-20020a170906fd8400b00a5252e69c7dsm5905590ejb.160.2024.04.17.13.03.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 13:03:09 -0700 (PDT) From: Konrad Dybcio Date: Wed, 17 Apr 2024 22:02:55 +0200 Subject: [PATCH v2 3/7] drm/msm/adreno: Implement SMEM-based speed bin 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="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240404-topic-smem_speedbin-v2-3-c84f820b7e5b@linaro.org> References: <20240404-topic-smem_speedbin-v2-0-c84f820b7e5b@linaro.org> In-Reply-To: <20240404-topic-smem_speedbin-v2-0-c84f820b7e5b@linaro.org> To: Bjorn Andersson , Rob Clark , Abhinav Kumar , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: 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 , Konrad Dybcio X-Mailer: b4 0.12.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1713384181; l=6360; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=U+NHb0R2aY2AoDLFItO3sg266XV8A7zlHAZIod5ceWE=; b=jGcKJ7BlLpkzVaxLoUqHlpKYw6sYW4Rgjb/zEIanD3h6Pg77DixFZYeB8I6GEnjlZhVuV5ts0 sA/2ttmHxqzDmI9RhQ0yfKOcp5iLDjLi/5RNnf8KzuyYpdvKQ1p9/tD X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= 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. Due to the product code being ignored in the context of Adreno on production parts (as of SM8650), hardcode it to SOCINFO_PC_UNKNOWN. 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 | 41 +++++++++++++++++++++++++++--- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 12 ++++++--- 4 files changed, 53 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index d10323f15d40..60708c23ae4c 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_llc_slices_destroy(a6xx_gpu); kfree(a6xx_gpu); 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..58fd70140685 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,39 @@ 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 *fuse) { - return nvmem_cell_read_variable_le_u32(dev, "speed_bin", speedbin); + u32 fcode; + int ret; + + /* + * Try reading the speedbin via a nvmem cell first + * -ENOENT means "no nvmem-cells" and essentially means "old DT" or + * "nvmem fuse is irrelevant", simply assume it's fine. + */ + ret = nvmem_cell_read_variable_le_u32(dev, "speed_bin", fuse); + if (!ret) + return 0; + else if (ret != -ENOENT) + return dev_err_probe(dev, ret, "Couldn't read the speed bin fuse value\n"); + +#ifdef CONFIG_QCOM_SMEM + /* + * Only check the feature code - the product code only matters for + * proto SoCs unavailable outside Qualcomm labs, as far as GPU bin + * matching is concerned. + * + * Ignore EOPNOTSUPP, as not all SoCs expose this info through SMEM. + */ + ret = qcom_smem_get_feature_code(&fcode); + if (!ret) + *fuse = ADRENO_SKU_ID(fcode); + else if (ret != -EOPNOTSUPP) + return dev_err_probe(dev, ret, "Couldn't get feature code from SMEM\n"); +#endif + + return 0; } int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, @@ -1098,9 +1131,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); + 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 77526892eb8c..8f2b70eaf6ad 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; +/* As of SM8650, PCODE on production SoCs is meaningless wrt the GPU bin */ +#define ADRENO_SKU_ID_FCODE GENMASK(15, 0) +#define ADRENO_SKU_ID(fcode) (SOCINFO_PC_UNKNOWN << 16 | fcode) + uint16_t speedbin; }; @@ -136,7 +141,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: */ @@ -519,7 +524,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.44.0