From patchwork Tue Jul 9 10:45:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 811535 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 0CC71156F27 for ; Tue, 9 Jul 2024 10:45:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720521939; cv=none; b=cp8OcPUlko+6Hy2t3AHl4IHkkN5l5bj4dfGO7etTnBC2RX82oG+9GX3SzeP/mrSk30iFFdBrFbxEJqhb+zGMYYaD/Izdmkbsia3D5E53S+i6wYdeIjdN54TeGCGV0xCu8/URteXuTYOFYWSmB2rcj4LpLpisT+LEBnlKPGAUJiU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720521939; c=relaxed/simple; bh=EZnPsbf895Nk5+GhF8GX16MJZewwBwjtmiFmsqKVj/E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kM9G2Yv1K0b9EGqmI9gPlyAXz8NEx+j6STbYbWO2lnogfMtWhFhKFhJlNAPeugpm/1dCcJ0I/G/zqrG9CNExNrffvla5k7XCzti+q83XIUegKwBUJFE9xmT3SEZqu3CXn02wjHmg3fUT8upt6/+zO/jKmFyP2V2e81uJ/Tn52uM= 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=cBCQ+FJr; arc=none smtp.client-ip=209.85.218.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cBCQ+FJr" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a77c7d3e8bcso492623466b.1 for ; Tue, 09 Jul 2024 03:45:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720521934; x=1721126734; 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=IGu0LuUjGKiWzipHAvenbBISpRzy/JWKn/Q0VCWcD/s=; b=cBCQ+FJroi7uwFFrEt1ZHftg+FWQMxfhMlsgBHlNqcMYO6An9UF7Y0ly8aaq8/BJuH 7fOQgd1Lx1oR09Vh0+1+v2TyJcfBHxYcOceoUzcPoEQ2KUWm9XixFZos3dFa3zus9CVo PaDXlhGx0KSE2QBmhH4AqADsdNycNbpwpDwLs1YIg5fezutwhvZCSU1gzeXnbakp0Rw6 ++t3uJln3XC7SvYASRUzlnUV+wDlY3u8fG4lmqcqfP2cznrzSnzvmpWtkoU6LhIHs6jF qvCA6hIxE/lVLEZZ7xEp/5kWZiC2PsEsBFmHgNrirrC2Rc6JqElLuWxdpTh0RBMDDUsV 5nng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720521934; x=1721126734; 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=IGu0LuUjGKiWzipHAvenbBISpRzy/JWKn/Q0VCWcD/s=; b=rhJV96Eaa5vzyofkT5uTFrs/uVfslLNwq8qIVEOQrbBNmGc1z1NYRWPzP7wIYqe8cZ pqC3DtruB5GIGvAsIfZmtFMnIVKjxBlqAy6386nTxvzMvL6DorV4yykoJ707y8Q5BkHI dKaOIuCbU+4GPdOG5YxLQIedEaYqF7tAgQlg0yLbsr5s5bFNaNhMhR3G5i/mTmQVwMD0 xaBE8DT/orTzFhPRHg5HTESnCN2bFRkcRSGwCu046V7nh3xIPNFVHVdaeQ/U0FnXilW7 LzybIwqIbvv0MW5rEqsTwrK1lb20GJ1pzJvsJ1CocX1TacRfh6865OfzxCtzuGh8RR5R ronw== X-Forwarded-Encrypted: i=1; AJvYcCUswTS6gJ0MBxUsZ+OPsDine2BRE3xmRm2tMn/TmBpxnhheY0iusBByuSsbQ/SW0I8IWxqAuMI9GheycK51rHwzAQ3PUzdfLB94+MMq5w== X-Gm-Message-State: AOJu0Ywo6O+HVkZU+/iA25Fsw8ULPpjkrPaS54B1QJWw97DcA/f3SOV9 iAfpNqV6dsspGPHGuOHDltntNuXOFgxJuGrW/suUkO9b3b0sietk2D67R9STfNE= X-Google-Smtp-Source: AGHT+IFojiSJMtNFkbwjsZN8NaRCsi8T66KA4mNJvMJYW4MrWNwyi3ZVaOA3AheA7mNLL9bhT2f25w== X-Received: by 2002:a17:907:720c:b0:a77:c5a5:f662 with SMTP id a640c23a62f3a-a780b68a9camr184732266b.12.1720521934301; Tue, 09 Jul 2024 03:45:34 -0700 (PDT) Received: from [192.168.105.194] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a780a7ff038sm66295466b.115.2024.07.09.03.45.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 03:45:33 -0700 (PDT) From: Konrad Dybcio Date: Tue, 09 Jul 2024 12:45:29 +0200 Subject: [PATCH v5 1/5] drm/msm/adreno: Implement SMEM-based speed bin Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240709-topic-smem_speedbin-v5-1-e2146be0c96f@linaro.org> References: <20240709-topic-smem_speedbin-v5-0-e2146be0c96f@linaro.org> In-Reply-To: <20240709-topic-smem_speedbin-v5-0-e2146be0c96f@linaro.org> To: Rob Clark , Sean Paul , Abhinav Kumar , Dmitry Baryshkov , David Airlie , Daniel Vetter , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720521930; l=6084; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=EZnPsbf895Nk5+GhF8GX16MJZewwBwjtmiFmsqKVj/E=; b=ofzGt665lRV73DHN1FYY/bCFj4utkgtRqb78xzJO4AhiNNAaX88SPIUrJ7rZTp+qwl8D+dgx/ Qjtzuwfx42BCGsI3SBnFhMjoYrnCMLAynqXFghKGFuzriKzoFSYGeJk 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 | 14 +++++----- drivers/gpu/drm/msm/adreno/adreno_device.c | 2 ++ drivers/gpu/drm/msm/adreno/adreno_gpu.c | 42 +++++++++++++++++++++++++++--- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 7 ++++- 4 files changed, 54 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index bcaec86ac67a..0d8682c28ba4 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -2117,18 +2117,20 @@ 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 + * -ENOENT/EOPNOTSUPP means that the platform doesn't support speedbin + * which is fine */ - if (ret == -ENOENT) { + if (ret == -ENOENT || ret == -EOPNOTSUPP) { return 0; } else if (ret) { dev_err_probe(dev, ret, @@ -2283,7 +2285,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 cfc74a9e2646..0842ea76e616 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 1c6626747b98..cf6652c4439d 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); @@ -1061,9 +1064,40 @@ 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); + 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 + u32 fcode; + + /* + * 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 ret; } int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, @@ -1102,9 +1136,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 1ab523a163a0..0d629343ebb4 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h @@ -79,6 +79,10 @@ struct adreno_reglist { struct adreno_speedbin { uint16_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) (fcode) + uint16_t speedbin; }; @@ -555,7 +559,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 From patchwork Tue Jul 9 10:45:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 811878 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (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 8865D15747B for ; Tue, 9 Jul 2024 10:45:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720521939; cv=none; b=Aas0oywUyqNALu9h0mUp6M+Dcp6ItfPgNA3OTVUp8K892tE0Xn1a8gznqtbKnMa0ZYUQ678AfiS7hM1xX0l+G1vcbJyAO1OxrxjxQJAk8xZBL1VlYQgOsPog8dQlCMD9XoEp0ZTrpyaL+WmiJD7Gkb3FQF7jOlaIZhVAL1aJRyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720521939; c=relaxed/simple; bh=qLAOTrSFtuBecm3+EwggXg43xqGrGY4RLrmT8vpNaLU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=L/fOkTX9jrs95FsrpMmck+Tgb0VTTV2PDFTXmGTpNPU8uI4I7tp5+wBtouu25Y+PhjTXgtQ8lYlsVVoePwgitNuOPntu4zGxXSsbjgiIsODdGYVbZ2rT6TtIaBPD5Pc6wYUs0MvC3pFOEf61LsOpJrEGdULrc2Z92oKFQyqLLJg= 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=ZgwN+YdB; arc=none smtp.client-ip=209.85.218.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZgwN+YdB" Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-a77c4309fc8so533808166b.3 for ; Tue, 09 Jul 2024 03:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720521936; x=1721126736; 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=gToTLptM86w4DbSg4pVJQrRVwG35LsSkyYQCCt7KVjw=; b=ZgwN+YdBgQhN2MBnsLSfOTUs5jUXRluiwgVocgzZ4IXvyRcqwS399wdLz4MeE+hfog L03SL55zD7D09DZbX328SIZPZOiV+BSgW1kVG4ddH2pQ2UGacvLvdfBWY43NoX0MieBN CKTxJY20tmsM2ju/qo4zoxsqYO9Q4/rYUKp7gEYWYTfpZMOyVmWjOWI/i988vdjo1NpU PhrKGO+vt9rKoYiXzntjrm3jBpGfbauJg+kMKj3wq/uyyvepPBjCAjPZxzknI/bEX7ic d83SK4S2YvDwrLCVpzLdOkOPFcHugWLCS7I4QFD2T786Tk5SnocH0lHcRf/ilZIrdlGi JhTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720521936; x=1721126736; 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=gToTLptM86w4DbSg4pVJQrRVwG35LsSkyYQCCt7KVjw=; b=BilNStnUjSxEvD2bssNQ+cj/D7nhupevDYmAHSFDqOlg0QUfu23ImmzjrIgmXsK1nu CArhTrZtZyDFzSof9+KRipBcrLp2o7J6eRJWnH5hHjyGREnWvnSXGGtGBdNKcdhX7QqH E4NGFMgJiaNK/Jsg+hcR6r0sMPEPQQVnKkIUOfMvQvHKTexErYb/HOSyNa/blyip5oKq eNZjV4xaTSz+t5Mn6TB/UGr3jqoNSBAd/e5m6uMciJwIu77cTXRAuMMlA07V/StDDviT DAlBYZNELW5Fz3I0jdJRRTatNPteT9eXRkepDpGHz4IQzi0XYXszE4eGnfY+74Q3fiv0 zXTQ== X-Forwarded-Encrypted: i=1; AJvYcCUWydFHSZflArrA9v0SjJkZX0mFrMvzL73E6p9lkMm82vA4UU/LStbbktMglVzbwThh6+hqGuXLrNc2QDvyVW5mHGsvs3vx2A8m+6EQEw== X-Gm-Message-State: AOJu0YwC+yP0JnoQjglSqKDO+xg6yfuA8Nk4G66NwjSpZpRHL/OpGG4M R4jbVE3dwz+VgxKRMJaTlYjXgo6RJcDotwb5AicCDmFN+BaeGJXK+LF5A9mnsDs= X-Google-Smtp-Source: AGHT+IFW3cXCBLhl8y6tH7WGUVEU2s6NXfrAid4cgw+rlJCWH5RBeVmuYYGgJqUJYlZ0TQecK8lYqw== X-Received: by 2002:a17:906:81d2:b0:a77:b052:877e with SMTP id a640c23a62f3a-a780b6b3605mr146799266b.19.1720521935892; Tue, 09 Jul 2024 03:45:35 -0700 (PDT) Received: from [192.168.105.194] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a780a7ff038sm66295466b.115.2024.07.09.03.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 03:45:35 -0700 (PDT) From: Konrad Dybcio Date: Tue, 09 Jul 2024 12:45:30 +0200 Subject: [PATCH v5 2/5] drm/msm/adreno: Add speedbin data for SM8550 / A740 Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240709-topic-smem_speedbin-v5-2-e2146be0c96f@linaro.org> References: <20240709-topic-smem_speedbin-v5-0-e2146be0c96f@linaro.org> In-Reply-To: <20240709-topic-smem_speedbin-v5-0-e2146be0c96f@linaro.org> To: Rob Clark , Sean Paul , Abhinav Kumar , Dmitry Baryshkov , David Airlie , Daniel Vetter , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720521930; l=1480; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=qLAOTrSFtuBecm3+EwggXg43xqGrGY4RLrmT8vpNaLU=; b=felzT5CFkBH3CSD4+amuMEw8IiUfz80JoigCu+pRFOy5BlFTjJygWaDDjwtuKGHNKBhm30wZg NBUe1/jVPMZBLTAjuLJBMe6dl3+f4IGUf2f654Aut78+wx/zTfxZ3ug X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Add speebin data for A740, as found on SM8550 and derivative SoCs. For non-development SoCs it seems that "everything except FC_AC, FC_AF should be speedbin 1", but what the values are for said "everything" are not known, so that's an exercise left to the user.. Reviewed-by: Dmitry Baryshkov Signed-off-by: Konrad Dybcio --- drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_catalog.c b/drivers/gpu/drm/msm/adreno/a6xx_catalog.c index 68ba9aed5506..e3322f6aec13 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_catalog.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_catalog.c @@ -11,6 +11,9 @@ #include "a6xx.xml.h" #include "a6xx_gmu.xml.h" +#include +#include + static const struct adreno_reglist a612_hwcg[] = { {REG_A6XX_RBBM_CLOCK_CNTL_SP0, 0x22222222}, {REG_A6XX_RBBM_CLOCK_CNTL2_SP0, 0x02222220}, @@ -1209,6 +1212,11 @@ static const struct adreno_info a7xx_gpus[] = { .gmu_chipid = 0x7020100, }, .address_space_size = SZ_16G, + .speedbins = ADRENO_SPEEDBINS( + { ADRENO_SKU_ID(SOCINFO_FC_AC), 0 }, + { ADRENO_SKU_ID(SOCINFO_FC_AF), 0 }, + /* Other feature codes (on prod SoCs) should match to speedbin 1 */ + ), }, { .chip_ids = ADRENO_CHIP_IDS(0x43050c01), /* "C512v2" */ .family = ADRENO_7XX_GEN2, From patchwork Tue Jul 9 10:45:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 811534 Received: from mail-ej1-f44.google.com (mail-ej1-f44.google.com [209.85.218.44]) (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 2916C14290 for ; Tue, 9 Jul 2024 10:45:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720521958; cv=none; b=kJU9OnDpJSYGkifF8MjoythtgbmPIZpPH4aDfsRC0288/d3CsoJdk220o89K6Hzi+TKYIPiEeFrqaxImRIpCNt/y0norp4Dg4iF8gZrdzJ7RdaOH7IXOiyu3LeV90PBKkgAs5TH5qks+JSZZBKhX7rdbkNbilLduaiiJI1/1F1A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720521958; c=relaxed/simple; bh=4D54MBq6zoAcYkfe7iD2ltE1UzYmVaRiFpw+gSQkiFQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eKcPHjeqBKK5W5OoBYD5qZ71eePDj6A++3dqgmUhMPjH2hPnnlR/3rUtZ4AYoMeeVdmvZxfG3cquT0FITb3n/8IysfDZRlLjVcyODMJysIuS4dHg84e0ZsadqqjQAHO54Tvzhf8K/IiRmUNYg2WEdu4+Q1OzXxESODxfqGEgb/U= 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=fEr11I1O; arc=none smtp.client-ip=209.85.218.44 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fEr11I1O" Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a77c9c5d68bso468912566b.2 for ; Tue, 09 Jul 2024 03:45:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720521955; x=1721126755; 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=OCdrWwyibH7SidMAd8gXxhcbnOnPffTnyQEY5fVW104=; b=fEr11I1OzCK500TytfuuvEz3wC0K2XALleau/t3ifocJ0lwCwxzl2l9IuGb0zU0rQa s0NlR23kSP1maB7UScBAGUBhYReO41YonPZyH1tlHl4FyDg5ROjZqpx4LAgtj0wo2q72 r8DG4MZRLyGabkIy5T/RZifzfSCYZQV/tGgIKiq8bw402idly2Eu4bJMlSBu7BAdRrx9 QnED4bmAkEcuBjZZwjaPXSiawiDWt6HgthIffaaHRmoa92QPzgz/rTzjCFfgzNUiGBZ8 i8NE6+Az5V+iNcO+muGzvsTJbhtHT9ssW+EKb4WptgSx8HoE7q28YFSUpylndLgJMZtm PqAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720521955; x=1721126755; 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=OCdrWwyibH7SidMAd8gXxhcbnOnPffTnyQEY5fVW104=; b=iDn7VrP/troJtsE7ZFTmxuFnpaiwpehhw2S3RNsCUyiZvuEPhcvyahuCnrq/e+GAX8 czpqK+axhmpHxn9rqGHzcYHdutCEI/Hlw+/KD4+IW0xfPo+9iNYkDAvk88DvyQDaHvwq Q0JyFeOc+36vgr5aT63U501krNzxzD3bFigjhKeuwAzQxtN7zDVFTZECLtrhV3JjwtQD 4rQJL6jfDF/Cfi17jL6WWK6IUi2mJVdHEJ8INxseSlmc+umJRSISkkP5HCHlkI7CSm/J rZ5WuBGTPh4KcQmHv5tKtW0DWEYtxx8DeV5h+INYn1yLOhwxLvDleWSwJD6jqXbpcHfs dYaA== X-Forwarded-Encrypted: i=1; AJvYcCUxC4KU96tyzITAEdzjSreRXWXsGzComdFT4Uz0Lsnp9+eGdUsqLsgqg7nefRdjfNKg0O4ZJPpWZMNGIgci0k77wSvMp9E8NcinymFggw== X-Gm-Message-State: AOJu0YyAyLwoN8sC1k+bNsx/rPous9RzNfaefKUrOqgWB1duP69M/J02 xiFC/fJg8i7S12ROr3tcK4SfKsE9/RFXqrarRHcutwMR+hjF+iqkUGE1ZP2aaqo= X-Google-Smtp-Source: AGHT+IEnddeAQttVIjPlE5QwA1Ejq9Sgylm5fg+WQ2PeIGDvlnpy6g/83mPoUVgnq4+Ux2PORfhdCA== X-Received: by 2002:a17:907:3f20:b0:a72:554d:82af with SMTP id a640c23a62f3a-a780df5e5fbmr146263266b.20.1720521938009; Tue, 09 Jul 2024 03:45:38 -0700 (PDT) Received: from [192.168.105.194] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a780a7ff038sm66295466b.115.2024.07.09.03.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 03:45:37 -0700 (PDT) From: Konrad Dybcio Date: Tue, 09 Jul 2024 12:45:31 +0200 Subject: [PATCH v5 3/5] drm/msm/adreno: Define A530 speed bins explicitly Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240709-topic-smem_speedbin-v5-3-e2146be0c96f@linaro.org> References: <20240709-topic-smem_speedbin-v5-0-e2146be0c96f@linaro.org> In-Reply-To: <20240709-topic-smem_speedbin-v5-0-e2146be0c96f@linaro.org> To: Rob Clark , Sean Paul , Abhinav Kumar , Dmitry Baryshkov , David Airlie , Daniel Vetter , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720521930; l=874; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=4D54MBq6zoAcYkfe7iD2ltE1UzYmVaRiFpw+gSQkiFQ=; b=WfLMIj4SCvcJlhKnPfLp36Ctyq2d6AHSfVTYR87sgyW+uMP6er36Q2p56z8XMiCz66+azs3NP ysIMX7TBRifDWp6wRSAsHAMRBbWj13kMAR33/CyVT8WKhZ6XMnbO7V7 X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= In preparation for commonizing the speedbin handling code. Reviewed-by: Dmitry Baryshkov Signed-off-by: Konrad Dybcio --- drivers/gpu/drm/msm/adreno/a5xx_catalog.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/gpu/drm/msm/adreno/a5xx_catalog.c b/drivers/gpu/drm/msm/adreno/a5xx_catalog.c index 633f31539162..105b3d14bd75 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_catalog.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_catalog.c @@ -129,6 +129,12 @@ static const struct adreno_info a5xx_gpus[] = { ADRENO_QUIRK_FAULT_DETECT_MASK, .init = a5xx_gpu_init, .zapfw = "a530_zap.mdt", + .speedbins = ADRENO_SPEEDBINS( + { 0, 0 }, + { 1, 1 }, + { 2, 2 }, + { 3, 3 }, + ), }, { .chip_ids = ADRENO_CHIP_IDS(0x05040001), .family = ADRENO_5XX, From patchwork Tue Jul 9 10:45:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 811877 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.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 D3899157A5C for ; Tue, 9 Jul 2024 10:45:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720521960; cv=none; b=ly6hjdxhXot2anah4G0RXjA9wNtzfgPSNYyAyyjGMpqaKN8RsPRU00v1QavX+AUXvVEHb3XBcX4q1Djmwe/VnuahZ+fryN/4Xh2m96wMc5lb9OTVgn770ZCOM+tTLq8lSDtqXfkGSfHf2m05SJVaDVsN+mW2i2ePf5zMtVv+SKw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720521960; c=relaxed/simple; bh=ZSzgpQ49WT7GffGNsAbL1pXn75NnMBX03jO7rZdfrlQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=eGQdCQbYo1o/rWyiZsmHiQC60DdBr8NOJyr0sKkFvoEi8Wh2mGWWPyvvIbEqcm45lvqxg8LIIuKkW2Qof4txh+dVv7jwYmmgSR0MADZxrrQnR8rBRlOiIGTKtlxmYSrHhCEKnq1AeXQwozCGsTxaZxIpAHqDO2heRaaX9yikxnU= 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=br9NbIhb; arc=none smtp.client-ip=209.85.208.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="br9NbIhb" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-58ba3e38027so6050166a12.1 for ; Tue, 09 Jul 2024 03:45:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720521957; x=1721126757; 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=+25nY/rYNm7YLajBTpZeCUf/L8baTplxhtXdEO1SETc=; b=br9NbIhbbNWT9Ql9ElwpSET5dJiysmyA/lARlYUo5/H3odh++Z2XCB6bzp2SMIi7Ab shadztK1tsBFReedT33Z3+J4ghyKfvgvSAQx5tJVxsqhqopMs2UahqPZCitI5XXo3jFY SeMLGgs24DCJsBctg1iAfkj10RJoYHeb34RN/yemW40tSoJ0hMrOLeDL6vEDPe5LOYW8 7hI+2aVRaEp2QA+CMrobYDqNCUTul7AYrTRYbOqKB8DXNfBbfyYcj71SK0fn1OdbeU7l 9cAv56GJ6PxHHG37G/od1WRZODbQPdbx2/TF0Qa8OUgLNj8RvE52tYpT+MbnRJb5K+Jl tftQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720521957; x=1721126757; 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=+25nY/rYNm7YLajBTpZeCUf/L8baTplxhtXdEO1SETc=; b=W3RKpLfO9Ldp2IPVE3bXuABM78rFHTdgvsxEeq1W7fIsf7A29H3vsAkmMucp20LD8V hJBJgB/PBcmhR0MLKLxF86gnspcsGl3HGMrMIbf6szexs0JmwYZsd7tyB1+TRoZBoow4 4Sd6HR9GCqaenfoVjaDMhTrTrHaRyzIP12/zqSPwFGiQ1hIIps8L7pVD3GD71WP3C4mm YNlZ6e2RP38GPp5cKfgerBkxFIZiIupI8dbIMcxpvOcVQ60n5YRLURid071XiNnGiwe/ n36VVbExX1dA1B46rFURLKRwSAdf66CePESs4C37hpGwe06g82W63gQxeWTNl0rfM9cq tW4Q== X-Forwarded-Encrypted: i=1; AJvYcCUHLVSxFmks5VqxPpLwqGFZLv/zWM9Zc1uzENcO/cFtrZNgH/GaTN8AWBSy41VcHzgKnYX9NxrEf/A9KIqWY/IOSMRQl9lPkUd5bvECjw== X-Gm-Message-State: AOJu0Yztg0ZrVImTOeMjdA7wgyqQvKvscvdpe/4pa5cQxhH+aqvVugFi ZAp5SWJQeKuKqEQZNlcCPLBn+FiSefwKGRlwAtETPkz6eAwMJBuYws0a423ObIg= X-Google-Smtp-Source: AGHT+IG5FoktpVWK5QM17btN/ecwjh50i59Wtdzqowaj+yV2WoSrncfLxmfmu2om6K3T1xTR5sEtYQ== X-Received: by 2002:a17:906:d9d1:b0:a77:ec9f:d9c1 with SMTP id a640c23a62f3a-a780b89d4bemr184412766b.70.1720521956898; Tue, 09 Jul 2024 03:45:56 -0700 (PDT) Received: from [192.168.105.194] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a780a7ff038sm66295466b.115.2024.07.09.03.45.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 03:45:56 -0700 (PDT) From: Konrad Dybcio Date: Tue, 09 Jul 2024 12:45:32 +0200 Subject: [PATCH v5 4/5] drm/msm/adreno: Redo the speedbin assignment Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240709-topic-smem_speedbin-v5-4-e2146be0c96f@linaro.org> References: <20240709-topic-smem_speedbin-v5-0-e2146be0c96f@linaro.org> In-Reply-To: <20240709-topic-smem_speedbin-v5-0-e2146be0c96f@linaro.org> To: Rob Clark , Sean Paul , Abhinav Kumar , Dmitry Baryshkov , David Airlie , Daniel Vetter , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720521930; l=7871; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=ZSzgpQ49WT7GffGNsAbL1pXn75NnMBX03jO7rZdfrlQ=; b=NDdA24B5tdof5NaIKHu2eEqkNTFs05sN8KmxuwUU4w3M0iDVaZvuPQaCX9QUrvaMXzWhZfbMo 0Fi5mtGdvHRD+RHdXNtusFL9vK44fnT9giovlszJqlvGOEca3vV5/C5 X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= There is no need to reinvent the wheel for simple read-match-set logic. Make speedbin discovery and assignment generation independent. This implicitly removes the bogus 0x80 / BIT(7) speed bin on A5xx, which has no representation in hardware whatshowever. Signed-off-by: Konrad Dybcio --- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 34 -------------------- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 56 --------------------------------- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 51 ++++++++++++++++++++++++++---- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 3 -- 4 files changed, 45 insertions(+), 99 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index c0b5373e90d7..d62b12efac57 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c @@ -1709,38 +1709,6 @@ static const struct adreno_gpu_funcs funcs = { .get_timestamp = a5xx_get_timestamp, }; -static void check_speed_bin(struct device *dev) -{ - struct nvmem_cell *cell; - u32 val; - - /* - * If the OPP table specifies a opp-supported-hw property then we have - * to set something with dev_pm_opp_set_supported_hw() or the table - * doesn't get populated so pick an arbitrary value that should - * ensure the default frequencies are selected but not conflict with any - * actual bins - */ - val = 0x80; - - cell = nvmem_cell_get(dev, "speed_bin"); - - if (!IS_ERR(cell)) { - void *buf = nvmem_cell_read(cell, NULL); - - if (!IS_ERR(buf)) { - u8 bin = *((u8 *) buf); - - val = (1 << bin); - kfree(buf); - } - - nvmem_cell_put(cell); - } - - devm_pm_opp_set_supported_hw(dev, &val, 1); -} - struct msm_gpu *a5xx_gpu_init(struct drm_device *dev) { struct msm_drm_private *priv = dev->dev_private; @@ -1768,8 +1736,6 @@ struct msm_gpu *a5xx_gpu_init(struct drm_device *dev) a5xx_gpu->lm_leakage = 0x4E001A; - check_speed_bin(&pdev->dev); - nr_rings = 4; if (config->info->revn == 510) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index 0d8682c28ba4..849a14fe2319 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -2105,55 +2105,6 @@ static bool a6xx_progress(struct msm_gpu *gpu, struct msm_ringbuffer *ring) return progress; } -static u32 fuse_to_supp_hw(const struct adreno_info *info, u32 fuse) -{ - if (!info->speedbins) - return UINT_MAX; - - for (int i = 0; info->speedbins[i].fuse != SHRT_MAX; i++) - if (info->speedbins[i].fuse == fuse) - return BIT(info->speedbins[i].speedbin); - - return UINT_MAX; -} - -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(adreno_gpu, dev, &speedbin); - /* - * -ENOENT/EOPNOTSUPP means that the platform doesn't support speedbin - * which is fine - */ - if (ret == -ENOENT || ret == -EOPNOTSUPP) { - return 0; - } else if (ret) { - dev_err_probe(dev, ret, - "failed to read speed-bin. Some OPPs may not be supported by hardware\n"); - return ret; - } - - supp_hw = fuse_to_supp_hw(info, speedbin); - - if (supp_hw == UINT_MAX) { - DRM_DEV_ERROR(dev, - "missing support for speed-bin: %u. Some OPPs may not be supported by hardware\n", - speedbin); - supp_hw = BIT(0); /* Default */ - } - - ret = devm_pm_opp_set_supported_hw(dev, &supp_hw, 1); - if (ret) - return ret; - - return 0; -} - static const struct adreno_gpu_funcs funcs = { .base = { .get_param = adreno_get_param, @@ -2285,13 +2236,6 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) a6xx_llc_slices_init(pdev, a6xx_gpu, is_a7xx); - ret = a6xx_set_supported_hw(adreno_gpu, &pdev->dev, config->info); - if (ret) { - a6xx_llc_slices_destroy(a6xx_gpu); - kfree(a6xx_gpu); - return ERR_PTR(ret); - } - if (is_a7xx) ret = adreno_gpu_init(dev, pdev, adreno_gpu, &funcs_a7xx, 1); else if (adreno_has_gmu_wrapper(adreno_gpu)) diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index cf6652c4439d..6d0397a0554e 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -1064,8 +1064,8 @@ void adreno_gpu_ocmem_cleanup(struct adreno_ocmem *adreno_ocmem) adreno_ocmem->hdl); } -int adreno_read_speedbin(struct adreno_gpu *adreno_gpu, - struct device *dev, u32 *fuse) +static int adreno_read_speedbin(struct adreno_gpu *adreno_gpu, + struct device *dev, u32 *fuse) { int ret; @@ -1100,6 +1100,46 @@ int adreno_read_speedbin(struct adreno_gpu *adreno_gpu, return ret; } +#define ADRENO_SPEEDBIN_FUSE_NODATA 0xFFFF /* Made-up large value, expected by mesa */ +static int adreno_set_speedbin(struct adreno_gpu *adreno_gpu, struct device *dev) +{ + const struct adreno_info *info = adreno_gpu->info; + u32 fuse = ADRENO_SPEEDBIN_FUSE_NODATA; + u32 supp_hw = UINT_MAX; + int ret; + + /* No speedbins defined for this GPU SKU => allow all defined OPPs */ + if (!info->speedbins) { + adreno_gpu->speedbin = ADRENO_SPEEDBIN_FUSE_NODATA; + return devm_pm_opp_set_supported_hw(dev, &supp_hw, 1); + } + + /* + * If a real error (not counting older devicetrees having no nvmem references) + * occurs when trying to get the fuse value, bail out. + */ + ret = adreno_read_speedbin(adreno_gpu, dev, &fuse); + if (ret) { + return ret; + } else if (fuse == ADRENO_SPEEDBIN_FUSE_NODATA) { + /* The info struct has speedbin data, but the DT doesn't => allow all OPPs */ + DRM_DEV_INFO(dev, "No GPU speed bin fuse, please update your device tree\n"); + return devm_pm_opp_set_supported_hw(dev, &supp_hw, 1); + } + + adreno_gpu->speedbin = fuse; + + /* Traverse the known speedbins */ + for (int i = 0; info->speedbins[i].fuse != SHRT_MAX; i++) { + if (info->speedbins[i].fuse == fuse) { + supp_hw = BIT(info->speedbins[i].speedbin); + return devm_pm_opp_set_supported_hw(dev, &supp_hw, 1); + } + } + + return dev_err_probe(dev, -EINVAL, "Unknown speed bin fuse value: 0x%x\n", fuse); +} + 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) @@ -1109,7 +1149,6 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, struct msm_gpu_config adreno_gpu_config = { 0 }; struct msm_gpu *gpu = &adreno_gpu->base; const char *gpu_name; - u32 speedbin; int ret; adreno_gpu->funcs = funcs; @@ -1136,9 +1175,9 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, devm_pm_opp_set_clkname(dev, "core"); } - if (adreno_read_speedbin(adreno_gpu, dev, &speedbin) || !speedbin) - speedbin = 0xffff; - adreno_gpu->speedbin = speedbin; + ret = adreno_set_speedbin(adreno_gpu, dev); + if (ret) + return ret; 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 0d629343ebb4..eef450dc3732 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h @@ -559,9 +559,6 @@ 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 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 * out of secure mode From patchwork Tue Jul 9 10:45:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Dybcio X-Patchwork-Id: 811533 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (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 7854F158D74 for ; Tue, 9 Jul 2024 10:46:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720521962; cv=none; b=mtQKg+qeDz/MTrAp+yOGlmjs9ht0bclA5WwDOHF8pb2wsnlHd37eLlP2CH7WD9otL54SukiCEdPrh/GaO+qpDxVjC5L/IEyUmJ/5UM7Nl153nBvVyQhiIgZ+BfPioIXqDSVKOnTv2wZLKzJvXDwUejhU2YQmM7B7MXhIHhvx0ZY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720521962; c=relaxed/simple; bh=Il2UvibnuII6pAMEt7ZcsOO48MoDeeFboVabC36fJtY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PmtOK+hUhoypNl9qYt+Aix45LoYVbFmTt23FR6IxL8LAKZu3sK60toTYnbCATv3TKNHqFSHPVtzzdPsbB9v00tA+IhrMbfIXUbfn0UTaZaXxhuiWf4kfqpMbVYgc4Gr2KlA9a4nFq1YzSL/8jkp0Sdz3hkumuYvF1jSAHAIOdcE= 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=MOpyRtCe; arc=none smtp.client-ip=209.85.218.52 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="MOpyRtCe" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a77c25beae1so526659166b.2 for ; Tue, 09 Jul 2024 03:46:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1720521959; x=1721126759; 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=OZxsbIBefCYoeKy9Cb25bQD5JKjjQqCGKHe9J4bV87I=; b=MOpyRtCe7jlTwghXztKAiZ3DAoc9a96SFsmOOToI8TOl80Cfc5kvWGQBTrKJZ2HO7p Vp3t8St9d+UCtXrDrMGPaTfBBhISlKxW6xK1wGLpgzf0iIx5nFbJCqPCpbBlIvJ9rFx+ nBEgXhWi0mOiARgS3nmw1quxwM2EOJG3oChhV0aK8Fch11ACnNk6UduEbkBLblb4OV5L gkoYALdFBNiGgUUw/wwV32RHGKO/jRYw4NUX2tRgsgjN4ilwKx3xrLb1ifbVAzJ/G1kg dzPW3kzQGTntBEbs+Lrs9JPhbcVkTJb/ojX1V0QkFQu8QYOV+5gBDLL2LgovVJzhqcWe saLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720521959; x=1721126759; 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=OZxsbIBefCYoeKy9Cb25bQD5JKjjQqCGKHe9J4bV87I=; b=ak2XVQJqSYFk/qIMR9StP4W23HVGQxYkwEWC9z8XFHSTmdipV0ws8HDzAL/95H2nLt HP9sodJ22w1FooqAGOwUcOmnT91pin9TNJqbWtQm/cJ1xnDE4z5XS8yEeaDYK2pU/0g4 GcnPGWYFN/SQ2s9SVyojjwxo4UaKrmLS4okpfkA/ZzwsBc9dMMrR2L7gCDOU8jNxSHXf PWjvlkbUBKLOlFy4qFVdpgbj6yZ+Q44cc3NhrJBd4a1o3atQ+cbYKFMau9jjnS5hw6su VJ8vkqIQonhBN4zagMn6CWlvaeSsthQFabV6ZM75jfWx0d6B2QdYIS0IzQ3JtnQ+8C8s 2rew== X-Forwarded-Encrypted: i=1; AJvYcCXOuvH7si/1yUDFe4BJx9v+gbfcin9rZsUp4GAEB/6Zu9TD5CY5Z5K2GJJeNR9sTnhGhwGRLhGvoCDzvzZQeWY79LYnYUgd/FcAQZ6y0Q== X-Gm-Message-State: AOJu0YyV/SUCnenO9PN6KC6kHFUsIbWuMjLdA5mq4e6QM3tlCX8zQTnH JIpVx1H9dq9HgCv60aFLwyd7pB3zgINHQ+9PqSFJdOnUAIOJQbXLqCeZ77LFpH8= X-Google-Smtp-Source: AGHT+IGvYcfPFQV+7DBEYzRD0HAnZlDvmx5BFJoXF/V4cTRfvWKAKQqrkJLnm9w0OQ8iV7jmOHjokw== X-Received: by 2002:a17:906:c309:b0:a77:e55a:9e91 with SMTP id a640c23a62f3a-a780b6b0e59mr135132566b.19.1720521958889; Tue, 09 Jul 2024 03:45:58 -0700 (PDT) Received: from [192.168.105.194] (078088045245.garwolin.vectranet.pl. [78.88.45.245]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a780a7ff038sm66295466b.115.2024.07.09.03.45.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jul 2024 03:45:58 -0700 (PDT) From: Konrad Dybcio Date: Tue, 09 Jul 2024 12:45:33 +0200 Subject: [PATCH v5 5/5] arm64: dts: qcom: sm8550: Wire up GPU speed bin & more OPPs Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240709-topic-smem_speedbin-v5-5-e2146be0c96f@linaro.org> References: <20240709-topic-smem_speedbin-v5-0-e2146be0c96f@linaro.org> In-Reply-To: <20240709-topic-smem_speedbin-v5-0-e2146be0c96f@linaro.org> To: Rob Clark , Sean Paul , Abhinav Kumar , Dmitry Baryshkov , David Airlie , Daniel Vetter , Bjorn Andersson , Rob Herring , Krzysztof Kozlowski , Conor Dooley Cc: Marijn Suijten , linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Konrad Dybcio X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1720521930; l=2474; i=konrad.dybcio@linaro.org; s=20230215; h=from:subject:message-id; bh=Il2UvibnuII6pAMEt7ZcsOO48MoDeeFboVabC36fJtY=; b=UbAw9OwhyAwE8k7rUjhzv7OltpusBA6x/6YgB89OJWD+ojTrhyLuMSRDX4HAiIBsrrG0jevUW UobpDIs2ywfBIgClNuK2w9UxluMiW7//vluUrY7DilgVsJMyXYkgv3/ X-Developer-Key: i=konrad.dybcio@linaro.org; a=ed25519; pk=iclgkYvtl2w05SSXO5EjjSYlhFKsJ+5OSZBjOkQuEms= Add the speedbin masks to ensure only the desired OPPs are available on chips of a given bin. Using this, add the binned 719 MHz OPP and the non-binned 124.8 MHz. Reviewed-by: Dmitry Baryshkov Signed-off-by: Konrad Dybcio --- arch/arm64/boot/dts/qcom/sm8550.dtsi | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/arch/arm64/boot/dts/qcom/sm8550.dtsi b/arch/arm64/boot/dts/qcom/sm8550.dtsi index 4c9820adcf52..c1e3cec1540a 100644 --- a/arch/arm64/boot/dts/qcom/sm8550.dtsi +++ b/arch/arm64/boot/dts/qcom/sm8550.dtsi @@ -2119,48 +2119,67 @@ zap-shader { memory-region = <&gpu_micro_code_mem>; }; - /* Speedbin needs more work on A740+, keep only lower freqs */ gpu_opp_table: opp-table { compatible = "operating-points-v2"; + opp-719000000 { + opp-hz = /bits/ 64 <719000000>; + opp-level = ; + opp-supported-hw = <0x1>; + }; + opp-680000000 { opp-hz = /bits/ 64 <680000000>; opp-level = ; + opp-supported-hw = <0x3>; }; opp-615000000 { opp-hz = /bits/ 64 <615000000>; opp-level = ; + opp-supported-hw = <0x3>; }; opp-550000000 { opp-hz = /bits/ 64 <550000000>; opp-level = ; + opp-supported-hw = <0x3>; }; opp-475000000 { opp-hz = /bits/ 64 <475000000>; opp-level = ; + opp-supported-hw = <0x3>; }; opp-401000000 { opp-hz = /bits/ 64 <401000000>; opp-level = ; + opp-supported-hw = <0x3>; }; opp-348000000 { opp-hz = /bits/ 64 <348000000>; opp-level = ; + opp-supported-hw = <0x3>; }; opp-295000000 { opp-hz = /bits/ 64 <295000000>; opp-level = ; + opp-supported-hw = <0x3>; }; opp-220000000 { opp-hz = /bits/ 64 <220000000>; opp-level = ; + opp-supported-hw = <0x3>; + }; + + opp-124800000 { + opp-hz = /bits/ 64 <124800000>; + opp-level = ; + opp-supported-hw = <0x3>; }; }; };