From nobody Sun Jun 14 01:34:31 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 643493E3C4B for ; Mon, 4 May 2026 19:08:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921701; cv=none; b=RMMayKSZrt7CnsBVz/JSzyFj58J2P6NUnc/TyLG1hIBGPnV5YMIxdkx11EPwn4lz1cSnG1Ps9Eech85F3uLe8J5ZpAjfUAURvA0ymqDySAWJbPALVDcCKCItBDzvvVv914UHVC4syT0hcufZdVGxtwUGU7l8zxya+S/hZ8ce0xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921701; c=relaxed/simple; bh=/M+/a+r12QHfMgCf8JxpMAyb7h2f6oH3taybG+TRobU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Oq0Pfs99kDWZ6iC9GFragjW+3EYrVY1nA/SnHESzjRovso3jJf8ykP4gFmIfUVAVAIvoHkkdDkCUu5L1Ul4mJFQ0LDPQraDhpRfTe0S8ijB9OuhE19+t5cD1xgALHBbts012ZNZ8VpLbOFzE2i5cC81ub/pAXYvFeoc0JVof3Zg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=BakFECgk; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=CZV1wsVl; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="BakFECgk"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="CZV1wsVl" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644IqBTI636821 for ; Mon, 4 May 2026 19:08:17 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=nqMgdImuqVd SMyG9e22SagxNDTmMY+hSgwvw/8tybbo=; b=BakFECgkDFQ9rFJSItzVQNR/U2D 2nJWvK2YmeE7uUQmrkG6JJX1aTcM2qlZKYxq2jr/g3WE3RAIvtyUc6juSMtMjifO uRKhCkkUBRlKh1gC4k1SqJkuXmpPYncgbTdAyvxp6a4ROBRz80NnNnj98UZXj0DE kissbS3Yj56nmUoGUNYM2xu2ENAikVQerGS8Utb5A2PCOEIeX5HM67IOWuuNHmhr wXDQE2q+y+miIJt1tK4WVoemRFqRNXsloiw7a0EF0quvSt2wD3zy+pnIIG7py+Iv Ehfes/e0GdmFrPvJKXEAPnSz3ugX6S+nHgXapWpz8YT53oGogQgtrKr3iog== Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxsx49t35-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:17 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-82fa1c94b37so4225633b3a.0 for ; Mon, 04 May 2026 12:08:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921696; x=1778526496; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nqMgdImuqVdSMyG9e22SagxNDTmMY+hSgwvw/8tybbo=; b=CZV1wsVlyJskcUjgAhlXmsBOof8YN42h1juRvjfxuFRxyenl9KUY4yUfSRfwcIAki3 eZd1BK+obr7IFCmEvQL1kUebXfrQn/iJzVcFN+TXe82LNHLVsYrM5I48W8IO+fwg5fmo iWMGzg3xk5WRozoTPWib69KAexlOXbvUF6JD9ua2FnMYx9da3kuDtuE3iCe00J4uv8yh 0eLytZHhTYldNGncPIMiOCJKJddlIoao3lENJXHsvQXsf61Q1cL/u5N9uNEd0WSf0ITi edCNVEs3KPSWrspoeDFE9w5uMvn2UC1Dv4Onn303sN+lJWUzT1aDeBjlnYCWGKgcs6Sg 3hzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921696; x=1778526496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=nqMgdImuqVdSMyG9e22SagxNDTmMY+hSgwvw/8tybbo=; b=hnXv4u9wXMXQr1ctYRtG/U64EUgmN4pZcGviRnp8SjiGCqzq/NBUxKDRhmVkDgE87P rbOvI7WvaP0h8DU7x3k68IJPo10sTunXDWIVrnIPCSpY7Z8ZfrTe+ExQjDSPFFji/q4b VC7+CCEOYGPCwt32ULorALTkF4Z5qGRwBbaRBaeVIcIfy8LuE/q4ia8hH4j1C6Nl3+qc dskd25CCObXLpC+bKWlm+Uk1PpUJ0fAxGwWlFHxPePfy5XNGl/wA5bu/VV6RAS/kEZHU GokkJOSw7vX8hCDeqr5JhBBnLMn7WgOF/dJIHBR8p924wCWtCTyuMEIADMD79PocUWH3 /duw== X-Forwarded-Encrypted: i=1; AFNElJ/lCDqVX/GwjhgzpxLZ0duMhNVx8kqAtaBc95bLrEnn4oK1LFd3ON6Z5SD2akFKs9MXkw0h0Pee+YFX2UA=@vger.kernel.org X-Gm-Message-State: AOJu0YwdEGMObqSkUUcNbr+ge7frGdAcVXf+nt+XB89hF56WS2oPVoRq pH+IKqJCcpasOq/dYX5X849uhearzJz98wfUF7ByeQ0N3TQsztuepl/OS3z/E1tjOxrd4nwmTW3 IiPrHRD8z+V1a5UjOSjCmXquCdJFCMVy05wr8B1AKihsuGNDCrPFs70MykfwyUW55N2k= X-Gm-Gg: AeBDieuP0TpR1tMPpP2HZeUu+OknP00xxGYtcC2FjwKkHA0OokvyevxIgN3bl0sRUEl fF5QIWGixCwQIhrK+cNhGyTVeCh0ezm3gG81yyDfbgd4YjaFtFTuHl/l+Qz0DsEcg2QVDQf5Mxp eOdRdd6zkct6+06FEJZ40D5G3PxSRTXYOSFSC2y0/FVXcTIj/revgBVnP0aP/p/TtApRvywMF17 ShyfZRNuoy+ZzJpzH+o1R9Qv9ckIdVN0N7xDlUm/eaxwUANax265D6LYG1ilgV4tWYMeV9fdiAq 4WPGSbyzZBV+ozCt+bFGUAaYveSS1BHyzx7pNTmNNRny1b/S0ESOSBaFJlaPPGTBx22yvH/pkG1 r/jeJpoovaNqLgW0TpS8FtrCP+Kc3ZIq5anXHRziKVnM= X-Received: by 2002:a05:6a00:2e1e:b0:82f:3e9:7bec with SMTP id d2e1a72fcca58-838fd4c1b37mr635791b3a.12.1777921696026; Mon, 04 May 2026 12:08:16 -0700 (PDT) X-Received: by 2002:a05:6a00:2e1e:b0:82f:3e9:7bec with SMTP id d2e1a72fcca58-838fd4c1b37mr635746b3a.12.1777921695366; Mon, 04 May 2026 12:08:15 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8392e12372bsm11758b3a.49.2026.05.04.12.08.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:14 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Dmitry Baryshkov , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , David Airlie , Simona Vetter , Konrad Dybcio , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 01/16] drm/msm: Remove obsolete perf infrastructure Date: Mon, 4 May 2026 12:06:44 -0700 Message-ID: <20260504190751.61052-2-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfXyENchkQnpfA5 Pl6ns+FSJ/2TVChK/AerUR8J9M/2/dxiAaV3JNo9rlsLgTEZXl7NuiC7rfF47fsh9by8Kzqd0ry 0upRFYoeHP2XGMnj6gq+vs4GmyBERGtqKd5BbhULmIK59b/iOnzEXLTBedujnxMjzu+Y0KPwB4e nmsXaMWtxprUZtBQ/4i9GebvL7xRTEZL3n72pOZSraFTmlypm3NERAGu0F1Pvi9ZjXDFR4WTHF2 crgSCAOacHpDHH/8/h5RQxYAsH0G56H1n7NnoEeg4ss+/S9PTX2tM8MHip+BdssMaIm73Wl9/Vi rW7/0RmkXhNMXiyOEog6DwgHdV7vw3NHOYsp4XBtj6C+eCUu+ouBfERZ0V2p3RwW85Z3WMbad4x IWSikQNhRhsDFcfnQ365Q/iZdt9OXEojL6nHS8UyoCr495ddtfhOvmmUcTy3GfRhKeKj3l+yCcT SAF7NEe+Ydwi4cQMXnw== X-Proofpoint-ORIG-GUID: PLF3SUgHFBd2hHm1-GbqUdRb69BXZixP X-Proofpoint-GUID: PLF3SUgHFBd2hHm1-GbqUdRb69BXZixP X-Authority-Analysis: v=2.4 cv=LdIMLDfi c=1 sm=1 tr=0 ts=69f8eea1 cx=c_pps a=rEQLjTOiSrHUhVqRoksmgQ==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=istQItjhLDCz62CzcYoA:9 a=2VI0MkxyNR6bbpdq8BZq:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 suspectscore=0 impostorscore=0 malwarescore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" Outside of a3xx, this was never really used. And it low-key gets in the way of the new perfcntr support (or at least it is confusing to have two things called "perf"). So lets remove it. This drops the "perf" debugfs file. But these days, nvtop is a better option. (Plus perfetto for newer gens.) Signed-off-by: Rob Clark Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/Makefile | 1 - drivers/gpu/drm/msm/adreno/a2xx_gpu.c | 7 - drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 16 -- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 3 - drivers/gpu/drm/msm/msm_debugfs.c | 6 - drivers/gpu/drm/msm/msm_drv.c | 1 - drivers/gpu/drm/msm/msm_drv.h | 5 - drivers/gpu/drm/msm/msm_gpu.c | 107 ------------ drivers/gpu/drm/msm/msm_gpu.h | 31 ---- drivers/gpu/drm/msm/msm_perf.c | 235 -------------------------- 10 files changed, 412 deletions(-) delete mode 100644 drivers/gpu/drm/msm/msm_perf.c diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile index ba45e99be05b..ce00cfb0a875 100644 --- a/drivers/gpu/drm/msm/Makefile +++ b/drivers/gpu/drm/msm/Makefile @@ -122,7 +122,6 @@ msm-y +=3D \ msm_gpu_devfreq.o \ msm_io_utils.o \ msm_iommu.o \ - msm_perf.o \ msm_rd.o \ msm_ringbuffer.o \ msm_submitqueue.o \ diff --git a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a2xx_gpu.c index d5a5fa9e2cf8..df4cded9143f 100644 --- a/drivers/gpu/drm/msm/adreno/a2xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a2xx_gpu.c @@ -489,10 +489,6 @@ static u32 a2xx_get_rptr(struct msm_gpu *gpu, struct m= sm_ringbuffer *ring) return ring->memptrs->rptr; } =20 -static const struct msm_gpu_perfcntr perfcntrs[] =3D { -/* TODO */ -}; - static struct msm_gpu *a2xx_gpu_init(struct drm_device *dev) { struct a2xx_gpu *a2xx_gpu =3D NULL; @@ -518,9 +514,6 @@ static struct msm_gpu *a2xx_gpu_init(struct drm_device = *dev) adreno_gpu =3D &a2xx_gpu->base; gpu =3D &adreno_gpu->base; =20 - gpu->perfcntrs =3D perfcntrs; - gpu->num_perfcntrs =3D ARRAY_SIZE(perfcntrs); - ret =3D adreno_gpu_init(dev, pdev, adreno_gpu, config->info->funcs, 1); if (ret) goto fail; diff --git a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a3xx_gpu.c index 018183e0ac3f..c17e9777beae 100644 --- a/drivers/gpu/drm/msm/adreno/a3xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a3xx_gpu.c @@ -266,12 +266,6 @@ static int a3xx_hw_init(struct msm_gpu *gpu) /* Turn on performance counters: */ gpu_write(gpu, REG_A3XX_RBBM_PERFCTR_CTL, 0x01); =20 - /* Enable the perfcntrs that we use.. */ - for (i =3D 0; i < gpu->num_perfcntrs; i++) { - const struct msm_gpu_perfcntr *perfcntr =3D &gpu->perfcntrs[i]; - gpu_write(gpu, perfcntr->select_reg, perfcntr->select_val); - } - gpu_write(gpu, REG_A3XX_RBBM_INT_0_MASK, A3XX_INT0_MASK); =20 ret =3D adreno_hw_init(gpu); @@ -508,13 +502,6 @@ static u32 a3xx_get_rptr(struct msm_gpu *gpu, struct m= sm_ringbuffer *ring) return ring->memptrs->rptr; } =20 -static const struct msm_gpu_perfcntr perfcntrs[] =3D { - { REG_A3XX_SP_PERFCOUNTER6_SELECT, REG_A3XX_RBBM_PERFCTR_SP_6_LO, - SP_ALU_ACTIVE_CYCLES, "ALUACTIVE" }, - { REG_A3XX_SP_PERFCOUNTER7_SELECT, REG_A3XX_RBBM_PERFCTR_SP_7_LO, - SP_FS_FULL_ALU_INSTRUCTIONS, "ALUFULL" }, -}; - static struct msm_gpu *a3xx_gpu_init(struct drm_device *dev) { struct a3xx_gpu *a3xx_gpu =3D NULL; @@ -542,9 +529,6 @@ static struct msm_gpu *a3xx_gpu_init(struct drm_device = *dev) adreno_gpu =3D &a3xx_gpu->base; gpu =3D &adreno_gpu->base; =20 - gpu->perfcntrs =3D perfcntrs; - gpu->num_perfcntrs =3D ARRAY_SIZE(perfcntrs); - adreno_gpu->registers =3D a3xx_registers; =20 ret =3D adreno_gpu_init(dev, pdev, adreno_gpu, config->info->funcs, 1); diff --git a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a4xx_gpu.c index e6ab731f8e9a..6392126f48f2 100644 --- a/drivers/gpu/drm/msm/adreno/a4xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a4xx_gpu.c @@ -652,9 +652,6 @@ static struct msm_gpu *a4xx_gpu_init(struct drm_device = *dev) adreno_gpu =3D &a4xx_gpu->base; gpu =3D &adreno_gpu->base; =20 - gpu->perfcntrs =3D NULL; - gpu->num_perfcntrs =3D 0; - ret =3D adreno_gpu_init(dev, pdev, adreno_gpu, config->info->funcs, 1); if (ret) goto fail; diff --git a/drivers/gpu/drm/msm/msm_debugfs.c b/drivers/gpu/drm/msm/msm_de= bugfs.c index 1059a9b29d6a..f12701e286ec 100644 --- a/drivers/gpu/drm/msm/msm_debugfs.c +++ b/drivers/gpu/drm/msm/msm_debugfs.c @@ -344,12 +344,6 @@ static int late_init_minor(struct drm_minor *minor) return ret; } =20 - ret =3D msm_perf_debugfs_init(minor); - if (ret) { - DRM_DEV_ERROR(dev->dev, "could not install perf debugfs\n"); - return ret; - } - return 0; } =20 diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index edc3b4af14f4..3066547f319b 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -87,7 +87,6 @@ static int msm_drm_uninit(struct device *dev, const struc= t component_ops *gpu_op =20 msm_gem_shrinker_cleanup(ddev); =20 - msm_perf_debugfs_cleanup(priv); msm_rd_debugfs_cleanup(priv); =20 if (priv->kms) diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 6d847d593f1a..e53e4f220bed 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -45,7 +45,6 @@ struct msm_gpu; struct msm_mmu; struct msm_mdss; struct msm_rd_state; -struct msm_perf_state; struct msm_gem_submit; struct msm_fence_context; struct msm_disp_state; @@ -89,7 +88,6 @@ struct msm_drm_private { =20 struct msm_rd_state *rd; /* debugfs to dump all submits */ struct msm_rd_state *hangrd; /* debugfs to dump hanging submits */ - struct msm_perf_state *perf; =20 /** * total_mem: Total/global amount of memory backing GEM objects. @@ -442,8 +440,6 @@ void msm_rd_debugfs_cleanup(struct msm_drm_private *pri= v); __printf(3, 4) void msm_rd_dump_submit(struct msm_rd_state *rd, struct msm_gem_submit *su= bmit, const char *fmt, ...); -int msm_perf_debugfs_init(struct drm_minor *minor); -void msm_perf_debugfs_cleanup(struct msm_drm_private *priv); #else static inline int msm_debugfs_late_init(struct drm_device *dev) { return 0= ; } __printf(3, 4) @@ -451,7 +447,6 @@ static inline void msm_rd_dump_submit(struct msm_rd_sta= te *rd, struct msm_gem_submit *submit, const char *fmt, ...) {} static inline void msm_rd_debugfs_cleanup(struct msm_drm_private *priv) {} -static inline void msm_perf_debugfs_cleanup(struct msm_drm_private *priv) = {} #endif =20 struct clk *msm_clk_get(struct platform_device *pdev, const char *name); diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index cf244fd529aa..1bac70473f80 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -699,104 +699,6 @@ void msm_gpu_sysrq_kill(struct msm_gpu *gpu) } } =20 -/* - * Performance Counters: - */ - -/* called under perf_lock */ -static int update_hw_cntrs(struct msm_gpu *gpu, uint32_t ncntrs, uint32_t = *cntrs) -{ - uint32_t current_cntrs[ARRAY_SIZE(gpu->last_cntrs)]; - int i, n =3D min(ncntrs, gpu->num_perfcntrs); - - /* read current values: */ - for (i =3D 0; i < gpu->num_perfcntrs; i++) - current_cntrs[i] =3D gpu_read(gpu, gpu->perfcntrs[i].sample_reg); - - /* update cntrs: */ - for (i =3D 0; i < n; i++) - cntrs[i] =3D current_cntrs[i] - gpu->last_cntrs[i]; - - /* save current values: */ - for (i =3D 0; i < gpu->num_perfcntrs; i++) - gpu->last_cntrs[i] =3D current_cntrs[i]; - - return n; -} - -static void update_sw_cntrs(struct msm_gpu *gpu) -{ - ktime_t time; - uint32_t elapsed; - unsigned long flags; - - spin_lock_irqsave(&gpu->perf_lock, flags); - if (!gpu->perfcntr_active) - goto out; - - time =3D ktime_get(); - elapsed =3D ktime_to_us(ktime_sub(time, gpu->last_sample.time)); - - gpu->totaltime +=3D elapsed; - if (gpu->last_sample.active) - gpu->activetime +=3D elapsed; - - gpu->last_sample.active =3D msm_gpu_active(gpu); - gpu->last_sample.time =3D time; - -out: - spin_unlock_irqrestore(&gpu->perf_lock, flags); -} - -void msm_gpu_perfcntr_start(struct msm_gpu *gpu) -{ - unsigned long flags; - - pm_runtime_get_sync(&gpu->pdev->dev); - - spin_lock_irqsave(&gpu->perf_lock, flags); - /* we could dynamically enable/disable perfcntr registers too.. */ - gpu->last_sample.active =3D msm_gpu_active(gpu); - gpu->last_sample.time =3D ktime_get(); - gpu->activetime =3D gpu->totaltime =3D 0; - gpu->perfcntr_active =3D true; - update_hw_cntrs(gpu, 0, NULL); - spin_unlock_irqrestore(&gpu->perf_lock, flags); -} - -void msm_gpu_perfcntr_stop(struct msm_gpu *gpu) -{ - gpu->perfcntr_active =3D false; - pm_runtime_put_sync(&gpu->pdev->dev); -} - -/* returns -errno or # of cntrs sampled */ -int msm_gpu_perfcntr_sample(struct msm_gpu *gpu, uint32_t *activetime, - uint32_t *totaltime, uint32_t ncntrs, uint32_t *cntrs) -{ - unsigned long flags; - int ret; - - spin_lock_irqsave(&gpu->perf_lock, flags); - - if (!gpu->perfcntr_active) { - ret =3D -EINVAL; - goto out; - } - - *activetime =3D gpu->activetime; - *totaltime =3D gpu->totaltime; - - gpu->activetime =3D gpu->totaltime =3D 0; - - ret =3D update_hw_cntrs(gpu, ncntrs, cntrs); - -out: - spin_unlock_irqrestore(&gpu->perf_lock, flags); - - return ret; -} - /* * Cmdstream submission/retirement: */ @@ -899,7 +801,6 @@ void msm_gpu_retire(struct msm_gpu *gpu) msm_update_fence(gpu->rb[i]->fctx, gpu->rb[i]->memptrs->fence); =20 kthread_queue_work(gpu->worker, &gpu->retire_work); - update_sw_cntrs(gpu); } =20 /* add bo's to gpu's ring, and kick gpu: */ @@ -916,8 +817,6 @@ void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem= _submit *submit) =20 submit->seqno =3D submit->hw_fence->seqno; =20 - update_sw_cntrs(gpu); - /* * ring->submits holds a ref to the submit, to deal with the case * that a submit completes before msm_ioctl_gem_submit() returns. @@ -1009,9 +908,6 @@ int msm_gpu_init(struct drm_device *drm, struct platfo= rm_device *pdev, void *memptrs; uint64_t memptrs_iova; =20 - if (WARN_ON(gpu->num_perfcntrs > ARRAY_SIZE(gpu->last_cntrs))) - gpu->num_perfcntrs =3D ARRAY_SIZE(gpu->last_cntrs); - gpu->dev =3D drm; gpu->funcs =3D funcs; gpu->name =3D name; @@ -1043,9 +939,6 @@ int msm_gpu_init(struct drm_device *drm, struct platfo= rm_device *pdev, =20 timer_setup(&gpu->hangcheck_timer, hangcheck_handler, 0); =20 - spin_lock_init(&gpu->perf_lock); - - /* Map registers: */ gpu->mmio =3D msm_ioremap(pdev, config->ioname); if (IS_ERR(gpu->mmio)) { diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 07abbe33d992..78e1478669be 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -22,7 +22,6 @@ =20 struct msm_gem_submit; struct msm_gem_vm_log_entry; -struct msm_gpu_perfcntr; struct msm_gpu_state; struct msm_context; =20 @@ -168,18 +167,6 @@ struct msm_gpu { =20 struct adreno_smmu_priv adreno_smmu; =20 - /* performance counters (hw & sw): */ - spinlock_t perf_lock; - bool perfcntr_active; - struct { - bool active; - ktime_t time; - } last_sample; - uint32_t totaltime, activetime; /* sw counters */ - uint32_t last_cntrs[5]; /* hw counters */ - const struct msm_gpu_perfcntr *perfcntrs; - uint32_t num_perfcntrs; - struct msm_ringbuffer *rb[MSM_GPU_MAX_RINGS]; int nr_rings; =20 @@ -320,19 +307,6 @@ static inline bool msm_gpu_active(struct msm_gpu *gpu) return false; } =20 -/* Perf-Counters: - * The select_reg and select_val are just there for the benefit of the chi= ld - * class that actually enables the perf counter.. but msm_gpu base class - * will handle sampling/displaying the counters. - */ - -struct msm_gpu_perfcntr { - uint32_t select_reg; - uint32_t sample_reg; - uint32_t select_val; - const char *name; -}; - /* * The number of priority levels provided by drm gpu scheduler. The * DRM_SCHED_PRIORITY_KERNEL priority level is treated specially in some @@ -689,11 +663,6 @@ void msm_devfreq_idle(struct msm_gpu *gpu); =20 int msm_gpu_hw_init(struct msm_gpu *gpu); =20 -void msm_gpu_perfcntr_start(struct msm_gpu *gpu); -void msm_gpu_perfcntr_stop(struct msm_gpu *gpu); -int msm_gpu_perfcntr_sample(struct msm_gpu *gpu, uint32_t *activetime, - uint32_t *totaltime, uint32_t ncntrs, uint32_t *cntrs); - void msm_gpu_retire(struct msm_gpu *gpu); void msm_gpu_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit); void msm_gpu_sysrq_kill(struct msm_gpu *gpu); diff --git a/drivers/gpu/drm/msm/msm_perf.c b/drivers/gpu/drm/msm/msm_perf.c deleted file mode 100644 index 7768bde6745f..000000000000 --- a/drivers/gpu/drm/msm/msm_perf.c +++ /dev/null @@ -1,235 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only -/* - * Copyright (C) 2013 Red Hat - * Author: Rob Clark - */ - -/* For profiling, userspace can: - * - * tail -f /sys/kernel/debug/dri//gpu - * - * This will enable performance counters/profiling to track the busy time - * and any gpu specific performance counters that are supported. - */ - -#ifdef CONFIG_DEBUG_FS - -#include -#include - -#include - -#include "msm_drv.h" -#include "msm_gpu.h" - -struct msm_perf_state { - struct drm_device *dev; - - bool open; - int cnt; - struct mutex read_lock; - - char buf[256]; - int buftot, bufpos; - - unsigned long next_jiffies; -}; - -#define SAMPLE_TIME (HZ/4) - -/* wait for next sample time: */ -static int wait_sample(struct msm_perf_state *perf) -{ - unsigned long start_jiffies =3D jiffies; - - if (time_after(perf->next_jiffies, start_jiffies)) { - unsigned long remaining_jiffies =3D - perf->next_jiffies - start_jiffies; - int ret =3D schedule_timeout_interruptible(remaining_jiffies); - if (ret > 0) { - /* interrupted */ - return -ERESTARTSYS; - } - } - perf->next_jiffies +=3D SAMPLE_TIME; - return 0; -} - -static int refill_buf(struct msm_perf_state *perf) -{ - struct msm_drm_private *priv =3D perf->dev->dev_private; - struct msm_gpu *gpu =3D priv->gpu; - char *ptr =3D perf->buf; - int rem =3D sizeof(perf->buf); - int i, n; - - if ((perf->cnt++ % 32) =3D=3D 0) { - /* Header line: */ - n =3D scnprintf(ptr, rem, "%%BUSY"); - ptr +=3D n; - rem -=3D n; - - for (i =3D 0; i < gpu->num_perfcntrs; i++) { - const struct msm_gpu_perfcntr *perfcntr =3D &gpu->perfcntrs[i]; - n =3D scnprintf(ptr, rem, "\t%s", perfcntr->name); - ptr +=3D n; - rem -=3D n; - } - } else { - /* Sample line: */ - uint32_t activetime =3D 0, totaltime =3D 0; - uint32_t cntrs[5]; - uint32_t val; - int ret; - - /* sleep until next sample time: */ - ret =3D wait_sample(perf); - if (ret) - return ret; - - ret =3D msm_gpu_perfcntr_sample(gpu, &activetime, &totaltime, - ARRAY_SIZE(cntrs), cntrs); - if (ret < 0) - return ret; - - val =3D totaltime ? 1000 * activetime / totaltime : 0; - n =3D scnprintf(ptr, rem, "%3d.%d%%", val / 10, val % 10); - ptr +=3D n; - rem -=3D n; - - for (i =3D 0; i < ret; i++) { - /* cycle counters (I think).. convert to MHz.. */ - val =3D cntrs[i] / 10000; - n =3D scnprintf(ptr, rem, "\t%5d.%02d", - val / 100, val % 100); - ptr +=3D n; - rem -=3D n; - } - } - - n =3D scnprintf(ptr, rem, "\n"); - ptr +=3D n; - rem -=3D n; - - perf->bufpos =3D 0; - perf->buftot =3D ptr - perf->buf; - - return 0; -} - -static ssize_t perf_read(struct file *file, char __user *buf, - size_t sz, loff_t *ppos) -{ - struct msm_perf_state *perf =3D file->private_data; - int n =3D 0, ret =3D 0; - - mutex_lock(&perf->read_lock); - - if (perf->bufpos >=3D perf->buftot) { - ret =3D refill_buf(perf); - if (ret) - goto out; - } - - n =3D min((int)sz, perf->buftot - perf->bufpos); - if (copy_to_user(buf, &perf->buf[perf->bufpos], n)) { - ret =3D -EFAULT; - goto out; - } - - perf->bufpos +=3D n; - *ppos +=3D n; - -out: - mutex_unlock(&perf->read_lock); - if (ret) - return ret; - return n; -} - -static int perf_open(struct inode *inode, struct file *file) -{ - struct msm_perf_state *perf =3D inode->i_private; - struct drm_device *dev =3D perf->dev; - struct msm_drm_private *priv =3D dev->dev_private; - struct msm_gpu *gpu =3D priv->gpu; - int ret =3D 0; - - if (!gpu) - return -ENODEV; - - mutex_lock(&gpu->lock); - - if (perf->open) { - ret =3D -EBUSY; - goto out; - } - - file->private_data =3D perf; - perf->open =3D true; - perf->cnt =3D 0; - perf->buftot =3D 0; - perf->bufpos =3D 0; - msm_gpu_perfcntr_start(gpu); - perf->next_jiffies =3D jiffies + SAMPLE_TIME; - -out: - mutex_unlock(&gpu->lock); - return ret; -} - -static int perf_release(struct inode *inode, struct file *file) -{ - struct msm_perf_state *perf =3D inode->i_private; - struct msm_drm_private *priv =3D perf->dev->dev_private; - msm_gpu_perfcntr_stop(priv->gpu); - perf->open =3D false; - return 0; -} - - -static const struct file_operations perf_debugfs_fops =3D { - .owner =3D THIS_MODULE, - .open =3D perf_open, - .read =3D perf_read, - .release =3D perf_release, -}; - -int msm_perf_debugfs_init(struct drm_minor *minor) -{ - struct msm_drm_private *priv =3D minor->dev->dev_private; - struct msm_perf_state *perf; - - /* only create on first minor: */ - if (priv->perf) - return 0; - - perf =3D kzalloc_obj(*perf); - if (!perf) - return -ENOMEM; - - perf->dev =3D minor->dev; - - mutex_init(&perf->read_lock); - priv->perf =3D perf; - - debugfs_create_file("perf", S_IFREG | S_IRUGO, minor->debugfs_root, - perf, &perf_debugfs_fops); - return 0; -} - -void msm_perf_debugfs_cleanup(struct msm_drm_private *priv) -{ - struct msm_perf_state *perf =3D priv->perf; - - if (!perf) - return; - - priv->perf =3D NULL; - - mutex_destroy(&perf->read_lock); - - kfree(perf); -} - -#endif --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1D893DEAD3 for ; Mon, 4 May 2026 19:08:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921700; cv=none; b=Z2xH+wLyMCNTDHHbLADZrmcNL+kBSomB4EfEdR7estrBK5Mifh0ZB9kWq+H8ApJvo36vA2id28Vo6ep3OoGXBMkEtOtTkTygPZiLYgI/oEOjJRaFKlL60AsTaQ3XXjGRDnYIBqFVfdptlbhDQjiB1UOIHx7SGL3ecqQ6bTcgCb4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921700; c=relaxed/simple; bh=/NsgYCf/YJOjQfBrxIduQkHUSM4dKNrQiRj00JRK8V0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BtnuTZ2FGIfCyDhEWBWzqeGolWeiTS5qJMbsPd/N9MxysFMqnfB5E+TYdTTkK30A7Y9SxwHD8Ggx0e1JPzg/HEAFcwn8IBjwDhJ0h/UZLqr1U/s3h06T3SqNF2woRkFg2d5wj/bqyHni7JrLtVBp74Y3MGm/rnLlGWFrWsGY9WI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=WNJqRhap; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=f46l7Pr6; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="WNJqRhap"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="f46l7Pr6" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644Dwcxb3467673 for ; Mon, 4 May 2026 19:08:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=QpEOCCW2frO 5RjDS7yw8Uzvvr6ebtp3PdlAzKWnUJ/s=; b=WNJqRhapNaIGfUkgELB7bB9p/Sn wH5IACswdNeuv7ebxiGWk36eB5G2Ebvb1fl3KZSZXnXIjjij6ZXTLArrDA1f+fqY b9CV2qzT/9a0dVr2dZisqn3y/zx90Ct+9LFEpE8UiY2vZ/53eyNWJOhPqPwu1XYo ooqzIbpD30qd9g8tPgbFUrFjBeeGyrUzmZPpJ5/5kpGckMEADraHB+e36H0k/8hx z2ShEhfAc1aXG6mBggBJ5pb5aLikiCkrJ6KTA//Jtu+/+79OR33KPFRooYcNheeW NrIpOVrOtjLYlOeI/EQVS37JHXgSZvQqQ6PlscG/N/cEVKb0yoplV/DamLQ== Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxvtjs923-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:18 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-3651991d0bcso4131504a91.0 for ; Mon, 04 May 2026 12:08:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921697; x=1778526497; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QpEOCCW2frO5RjDS7yw8Uzvvr6ebtp3PdlAzKWnUJ/s=; b=f46l7Pr6uZ72xNa6q8fbt/ITqCjPFVVKTR2Mw1UM8dVqoAp+60fjIYGMiHHyoAQfm+ 3PNyRH+nUGlDXVHT8GJrmRsPcML+rBl6otkx4p5r5qW+ddhWtELBF59oIBkYDEqCwVKD P7HW+63QW7yOFwjZdLZ8Hs0Bhwq/lPtuoIPE0uLliUyzYN893T+Dpyuu7Wrfg1krBNVY MDiLrOKPBdySVozHmH0ukuvcu7aZLvctInwlimfIJEzrklcXuChKYJ8MUeCYr+Fl4WYK 8wl+bRRbGjrQ33NlZ+retQzD9juqWJRuCBSamgJtb2GkbkUEZM+Wnn0gQsqecpbr5rpl 888w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921697; x=1778526497; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=QpEOCCW2frO5RjDS7yw8Uzvvr6ebtp3PdlAzKWnUJ/s=; b=JgRnMatFKSMfmUN9mFgIMNwKjmi3GPpQ6kyXg5hliout5ojG3xQpkUEpa+zYmBizEZ gBxAfzmDsbe5Rq2xkVy7MqjJcL9CIwZvxW2d5kaQrZRA5kdelhduPkC7FiFM2/i+6lua dQ76OSZoOto/pLVS5mZ7enxOAL0hPrsgLPXTaauR7lrFGpfZa91j9aXIei/EFioKk0en +cSV8esGR63NgOFaiVIFJAXah5DOYDHlXFK0dJzqeSUiyKIdPOqW/e39ERW2i57MIFbR mNe256eL89GU88nfeqcqUdTrZyhxWxnS2DJKrcBcswJ3vJ3q/+POVETEz/Vo2oW+xAIg vUcw== X-Forwarded-Encrypted: i=1; AFNElJ84Qhp7q6YkthZ/s0Y6tZPnsxXMoiBBvKQ4we9X1RLfHm9YLKtLnZJ/Rfr0vyB1kasuHlKAGLOix1OQzL4=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6goevlw8qDiA+qremXJA79zFQGydIJukOgOuNXYDWhdOFlbcD RFLqg5iPbKqJiwkRykRl+TOOdKEtxy1rE80J+DcR1ruFhZ7lfDC1h5SAhmZE0tj3uQliuASmeva qWzY1Rhf68Dsgx7fJw+qKW7V0b5qwJQmt0/XncI04RjsgkLRfppgdghzjV4E2zj1hW1s= X-Gm-Gg: AeBDiesW9aPhqnZT6v6VlmnOl4y0K5WlKDSFZB3n4NmFsGdD1wvFJJAiZ0lIOzJJF1t USs91tNvqOLiaYpOf99phmioXx/xkIsA3ia/KpYDEazEJgk34HevKaDSiluB7PINZKxMGJLym2G D1V2dQwPoeoFyhM2o0Ncunp5qNcngHIm6ijafYP72lV6QasMAwJZigZW4CYdDM0T1soyy1jaiYo yE+5PL/T94D7V7FWgyQ2jbJuOCjK0L6YaE2PUq2YrQ0PI3vJV3DKW3x4qlz8CdfgSrUagdL9dCI OgHqichTvIYzOhp9/CYxD43M6anZsg3L1hPIVvDXhKVj3VoBO7jqsFPWAl1YBWDtl5S57KRJiIF rgBC+45V1FpelGVqnM6PjuEzS0fbwS6rcdBEBkIduZec= X-Received: by 2002:a17:90b:44:b0:35d:a90d:580e with SMTP id 98e67ed59e1d1-3650cef4475mr10744334a91.23.1777921697409; Mon, 04 May 2026 12:08:17 -0700 (PDT) X-Received: by 2002:a17:90b:44:b0:35d:a90d:580e with SMTP id 98e67ed59e1d1-3650cef4475mr10744305a91.23.1777921696879; Mon, 04 May 2026 12:08:16 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-364f48be507sm4609984a91.14.2026.05.04.12.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:16 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Dmitry Baryshkov , Sean Paul , Konrad Dybcio , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 02/16] drm/msm: Allow CAP_PERFMON for setting SYSPROF Date: Mon, 4 May 2026 12:06:45 -0700 Message-ID: <20260504190751.61052-3-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: nqROJ-MGHf5nj8sSZfv11x2TYNITnyiF X-Authority-Analysis: v=2.4 cv=KuN9H2WN c=1 sm=1 tr=0 ts=69f8eea2 cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=ZRXlmS4ShPoOlOK7p90A:9 a=mQ_c8vxmzFEMiUWkPHU9:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfXyMWgdFIYVI07 p+d/vj1FI7aJXFGkoe+I5iV/SXtJiqTDyIkK0BAFm7eY6gBeBRCkaVaHXrA5IVXWFsnyhkSZoQ5 FWZrfteJRNxxz0Kj4ki69IypcssPRhp9Mp+lrZ5qQx/pBTzBr0wHw+M3EO/JnCCImYubtpzjE3p al4OlCUYmelNmuDFKLAXjDX2kRdwNOlkSWImDeoeHsSzwOFu9syJXKhibNUCabjr93ZgE41RCa9 iBl32ImHG9GtIZOf7BmTlxHFePQsPEYjQHu/v1dgtULbaf3qmlTAjAfoYmszWhGxYqyWXiDFOCF HnHu8wSEKbIFMr1AkeoHScHwVQeCk1GekjbH/WbeRpwngkI3Z1s5aP8xooQMdpfPqGcqxwWuLEw aN+LzHP3dpLXrz1ol72WQxmmUZsNv/2jh/5IpKwfF12Q8Cw0vuGtZTKv9RER22Jow3fIqltxQ9m 3JJxvtx97G3ZWPXzORQ== X-Proofpoint-ORIG-GUID: nqROJ-MGHf5nj8sSZfv11x2TYNITnyiF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 adultscore=0 impostorscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" Use perfmon_capable() which checks both CAP_SYS_ADMIN and CAP_PERFMON. This matches what i915 and xe do, and seems more appropriate. Signed-off-by: Rob Clark Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/= adreno/adreno_gpu.c index 66f80f2d12f9..72b71e9e44f0 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -494,7 +494,7 @@ int adreno_set_param(struct msm_gpu *gpu, struct msm_co= ntext *ctx, return 0; } case MSM_PARAM_SYSPROF: - if (!capable(CAP_SYS_ADMIN)) + if (!perfmon_capable()) return UERR(EPERM, drm, "invalid permissions"); return msm_context_set_sysprof(ctx, gpu, value); case MSM_PARAM_EN_VM_BIND: --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FF073EE1CB for ; Mon, 4 May 2026 19:08:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921725; cv=none; b=KQmc7JwcgiNtybLUhMnUraPrJWlo6uDRVjf1b8tkBgcp4fjDHBy00oF7D2/Ofsi3hI2FN33+25L6Jro1vs6S9WDwDYd+2QwxtFUf75M7JrTqnZ18iXK4dem4hNLo5DLptiL1zsdsFvYTsWFece7Tn5gGzsdDmlFx0APYmpb0U7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921725; c=relaxed/simple; bh=ycDlQlWQ8iOrz2T5m3O8JexqUNxLfL5XHyZiHNxDhzg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PFxkU3pRWiCo+Z0G3ItGMoxApvTCM68QyxOEF/ZudVyiljzFJtqLE0zVH6X1BLfPoq/L2wwN14PkDTbtoVHWyw/1gRDUV7vyrMDRIi1OfFgMNhQS2NaqJUMo5YArUQmBCzF39VlZnPxDeMK5f7WFRGMST8nEo2x77vvCbA6oKaM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=Oj3DUypN; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=FjAd64dW; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="Oj3DUypN"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="FjAd64dW" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644FIWPp3409266 for ; Mon, 4 May 2026 19:08:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=ivA+mYR5uJV LPTj8dw+IqjKjANjH+HNlIBbzOd/ILvE=; b=Oj3DUypNWCUsKMU/wlop6yUK1mD fLqPnMtz2r8ha1KNv+GT+FzTkQiPYBkG8NlLOgudUMFKSU5Z/kxFCJ40tVXJSLEN 2/wQ4CJMkiJmWBloUXiN+NSdeTzC+pgoAmitu+gKbBO1GM8hwzQt5NWpotGW+jPQ m6R2jF9hPWSeALuM+rdEUWlx4qgxc82XYJWgk47Is6wxbHLxyuLXQhWGX49qI5Qh /Y0dPXuT4uSe4myhYkL/ppN8jazGfbIE9wJUrQTdnBE2Go1+XYgqdqtWDDFCIQ2b 9yjnFtj/3KSNpu+a8K7cB36qBSahlCo188lIU0m2MhwO58prY53TZWHOITg== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxx00rwsh-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:25 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-3651991d0bcso4131861a91.0 for ; Mon, 04 May 2026 12:08:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921705; x=1778526505; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ivA+mYR5uJVLPTj8dw+IqjKjANjH+HNlIBbzOd/ILvE=; b=FjAd64dWegNt0T7HAkGHyXkNp6CR3T1+Xc6nvKHdVHUMBttXC4Ys5f9YB6qPxnE0kk EFevsHlyS+WyStkMt7uWfSSft4C9q6nIjHCS1aB0OwNmSSCr5I9dLm5eAbhQ5torLArC S8H6WDwz67ROtmfT8RR3ri+5TD6xdNGISIc0/cOb1InkXX6SmUYAnwDWztPd5BvjTUBE Hl0TkE47FXcGUHCYkhUApnoTP4yIa9iKLs9O6astyXp0DRQzvq2fAPxcvQrkTiTVnTRh r3zrdCFkBaL+PId5dyse0OL3LYtarlyR1k3+JBcp/sE7IwwjD11bmRC02gZjEk8uAHUO Cbzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921705; x=1778526505; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ivA+mYR5uJVLPTj8dw+IqjKjANjH+HNlIBbzOd/ILvE=; b=jXgAoXPiwxsCchpFQ4Vs/zp3zqFZ3cpvtf5sgvA3cBH6zvRCPeqoe8YstIPlonXUOZ FUDGUG7plZqmsraFPAREXXZx5Gptst/DytWYXeOxAlqVtBA4GnHJ2xPDcdSV9i0k1k+7 ZbAhFOOncjXdYMxOUATzOTseljaqbMJN/Qs/JwTM2CgZcIXYkG6Xa+uyQgBYDXDdHYkF 6EQZYGBmO73cnDRTWhWCfJY76zObjPrQ5CBqvowIy5skyakhXyyOr/q14aaMZGMe11bJ annypXk1UsX7/bKGlN5HIQt36jHI5OR7aZDDDA4FZc0+rav9b/yGKW0edJ10EWBivnUS HYrQ== X-Forwarded-Encrypted: i=1; AFNElJ/L9eG0lXa0CiPxyyH3wfVPX0+FJbSXHjjfLUP0wjdwdzh7zjIiXxvn+z7meYKbpHKYeFCnGCChZFGaPqQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwOCw3DXS65vnLOAD/v5Jczzo6HD8y3Koc2+fA7UYR5vEw9xOoZ gA8/nbvGtRXqY2aagk6r02TAiZ0ve4Ww1K46l0XwoJTeFO5qYoB5zFmS/HaoFyr0ET1KIc76ANa +TaF2k6YcF5hdXDWNQAQZc8/6e9MMsOajf0LVpKRtg1fANEuAkKj4E5dcV/MW7mlpC5U= X-Gm-Gg: AeBDieslWcF7EpEycYh/vDtKQxRCQDI1H67hnR6G0GdRNJkzSOJhEcdsYaaHmEZafij Gcn9u42CbiXWmiAxvI3XCjNRox+YsSi9/OEuzg3tiaKxUq1Bqle1BNH3jElLUx4S+W8JHO1psft ZmnWgD3HNCqXaBAGOGNgE+ZcFV3iiozxDCsxf+qDpF8tsPZBx17Wu4G9FJ+sJ/EH5zz2uLttEs4 ybaow2liHyfyDmK0Viv5UIyToUNadL80ucH3E9uXvT+rVP/60x/dGqdWcbuN9Z+NG+xakXFgJRf J0YEKK4AqQBmHXZrNwf6U/ztB4ZZJGJHDgpiIEzk1zaHMDKeyQY/NQu/EaZyRfL8L70aYbEQiYV LGHKgGl6aLsFgEoObDQ/kkJStrgzKzcj/0d1bPvYzZGo= X-Received: by 2002:a17:90a:d444:b0:364:74c1:53b7 with SMTP id 98e67ed59e1d1-3650cda5d5dmr10633828a91.2.1777921703613; Mon, 04 May 2026 12:08:23 -0700 (PDT) X-Received: by 2002:a17:90a:d444:b0:364:74c1:53b7 with SMTP id 98e67ed59e1d1-3650cda5d5dmr10633740a91.2.1777921702190; Mon, 04 May 2026 12:08:22 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-364ec02ab2fsm12520021a91.14.2026.05.04.12.08.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:21 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Dmitry Baryshkov , Sean Paul , Konrad Dybcio , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 03/16] drm/msm/adreno: Sync registers from mesa Date: Mon, 4 May 2026 12:06:46 -0700 Message-ID: <20260504190751.61052-4-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=APflyhIR c=1 sm=1 tr=0 ts=69f8eeaa cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=e5mUnYsNAAAA:8 a=SSmOFEACAAAA:8 a=EUspDBNiAAAA:8 a=vMjXctBndKc6M4jOp94A:9 a=-YkrfQbNLgtqXKMw:21 a=uKXjsCUrEbL0IQVhDsJ9:22 a=Vxmtnl_E_bksehYqCbjh:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfX9I16CMcdj6DY MzLB9y/cVCO7I6YcNcwNi4h4MVTDbJmItszXFm9AXnKAyAqxVP5deiYqTMuyxxY85aa8cKySl0k StQMS4KUsHbVkwHEoZEh/Z+1zA/cHeYemMa3J0wksBN/gxHwlzLIYyg2uszx0JMv6c9Fqwzm8+w dMYr1mw4/WrASY5J9LnzwJmhx4WD19X7ovsjOFrF4BceTA7viDjXho9M73W3FSZ2zYhI2Wt7acL 1H0iGiwsa5J2VfG63OxQU/WB/wJUAOwF8j3nnP0Sl41FiKmoFdmk9ypuAuA/j5nReMuhHoVgGDW ovkynXWo5wXv00teGSsGZSYcRxXsCViTdg2/+/yhNms0IdMpTAv4C6P8U9xDF1qSOH/fUBSXYwX QnxDZbwxJajkQljCyIM//4bE8Cv9D5Qz7lDG5R0iBSGe5Ou0f+DQKpxCl6oVlmH12I3nHHk+GEv eLD4K/NcvE5bIUlECig== X-Proofpoint-GUID: pJfPO0qOQVPexhAYHS1ZXQWkqH71CFPo X-Proofpoint-ORIG-GUID: pJfPO0qOQVPexhAYHS1ZXQWkqH71CFPo X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 impostorscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 suspectscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" Most of the churn is just reworking the usage attribute on the mesa side. Sync from mesa commit 4d4a951ac622 ("fd: add a8xx perfcntr countables"). Signed-off-by: Rob Clark Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 16 +- drivers/gpu/drm/msm/registers/adreno/a3xx.xml | 8 +- drivers/gpu/drm/msm/registers/adreno/a5xx.xml | 141 +- drivers/gpu/drm/msm/registers/adreno/a6xx.xml | 1300 +++++------ .../msm/registers/adreno/a6xx_descriptors.xml | 71 +- .../drm/msm/registers/adreno/a6xx_enums.xml | 3 + .../msm/registers/adreno/a8xx_descriptors.xml | 96 +- .../msm/registers/adreno/a8xx_perfcntrs.xml | 1929 +++++++++++++++++ .../msm/registers/adreno/adreno_common.xml | 42 + .../drm/msm/registers/adreno/adreno_pm4.xml | 50 +- 10 files changed, 2846 insertions(+), 810 deletions(-) create mode 100644 drivers/gpu/drm/msm/registers/adreno/a8xx_perfcntrs.xml diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a5xx_gpu.c index 79acae11154a..9a03684288d3 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c @@ -752,17 +752,13 @@ static int a5xx_hw_init(struct msm_gpu *gpu) gpu_write(gpu, REG_A5XX_UCHE_CACHE_WAYS, 0x02); =20 /* Disable L2 bypass in the UCHE */ - gpu_write(gpu, REG_A5XX_UCHE_TRAP_BASE_LO, lower_32_bits(adreno_gpu->uche= _trap_base)); - gpu_write(gpu, REG_A5XX_UCHE_TRAP_BASE_HI, upper_32_bits(adreno_gpu->uche= _trap_base)); - gpu_write(gpu, REG_A5XX_UCHE_WRITE_THRU_BASE_LO, lower_32_bits(adreno_gpu= ->uche_trap_base)); - gpu_write(gpu, REG_A5XX_UCHE_WRITE_THRU_BASE_HI, upper_32_bits(adreno_gpu= ->uche_trap_base)); + gpu_write64(gpu, REG_A5XX_UCHE_TRAP_BASE, adreno_gpu->uche_trap_base); + gpu_write64(gpu, REG_A5XX_UCHE_WRITE_THRU_BASE, adreno_gpu->uche_trap_bas= e); =20 /* Set the GMEM VA range (0 to gpu->gmem) */ - gpu_write(gpu, REG_A5XX_UCHE_GMEM_RANGE_MIN_LO, 0x00100000); - gpu_write(gpu, REG_A5XX_UCHE_GMEM_RANGE_MIN_HI, 0x00000000); - gpu_write(gpu, REG_A5XX_UCHE_GMEM_RANGE_MAX_LO, + gpu_write64(gpu, REG_A5XX_UCHE_GMEM_RANGE_MIN, 0x00100000); + gpu_write64(gpu, REG_A5XX_UCHE_GMEM_RANGE_MAX, 0x00100000 + adreno_gpu->info->gmem - 1); - gpu_write(gpu, REG_A5XX_UCHE_GMEM_RANGE_MAX_HI, 0x00000000); =20 if (adreno_is_a505(adreno_gpu) || adreno_is_a506(adreno_gpu) || adreno_is_a508(adreno_gpu) || adreno_is_a510(adreno_gpu)) { @@ -1217,9 +1213,7 @@ static void a5xx_rbbm_err_irq(struct msm_gpu *gpu, u3= 2 status) =20 static void a5xx_uche_err_irq(struct msm_gpu *gpu) { - uint64_t addr =3D (uint64_t) gpu_read(gpu, REG_A5XX_UCHE_TRAP_LOG_HI); - - addr |=3D gpu_read(gpu, REG_A5XX_UCHE_TRAP_LOG_LO); + uint64_t addr =3D gpu_read64(gpu, REG_A5XX_UCHE_TRAP_LOG); =20 dev_err_ratelimited(gpu->dev->dev, "UCHE | Out of bounds access | addr=3D= 0x%llX\n", addr); diff --git a/drivers/gpu/drm/msm/registers/adreno/a3xx.xml b/drivers/gpu/dr= m/msm/registers/adreno/a3xx.xml index 6717abc0a897..09c9606fc3e1 100644 --- a/drivers/gpu/drm/msm/registers/adreno/a3xx.xml +++ b/drivers/gpu/drm/msm/registers/adreno/a3xx.xml @@ -1330,11 +1330,7 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org= /freedreno/ rules-fd.xsd"> - - + @@ -1420,7 +1416,7 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org/= freedreno/ rules-fd.xsd"> - + diff --git a/drivers/gpu/drm/msm/registers/adreno/a5xx.xml b/drivers/gpu/dr= m/msm/registers/adreno/a5xx.xml index bd8df5945166..4af76b3750f7 100644 --- a/drivers/gpu/drm/msm/registers/adreno/a5xx.xml +++ b/drivers/gpu/drm/msm/registers/adreno/a5xx.xml @@ -1418,8 +1418,7 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org/= freedreno/ rules-fd.xsd"> - - + @@ -1498,12 +1497,10 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.or= g/freedreno/ rules-fd.xsd"> - - + - - + @@ -1555,20 +1552,14 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.or= g/freedreno/ rules-fd.xsd"> - - - - - - - - + + + + - - - - + + @@ -1583,8 +1574,7 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org/= freedreno/ rules-fd.xsd"> - - + =20 @@ -1923,8 +1913,7 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org/= freedreno/ rules-fd.xsd"> invalidates the LRZ buffer? (Or just the covered positions? --> - - + @@ -1933,8 +1922,7 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org/= freedreno/ rules-fd.xsd"> is also divided by 8 (ie. covers 8x8 pixels) - - + =20 @@ -2035,8 +2023,7 @@ bit 7 for RECTLIST (clear) when z32s8 (used for clear= of depth32? not set --> - - + @@ -2089,8 +2076,7 @@ bit 7 for RECTLIST (clear) when z32s8 (used for clear= of depth32? not set - - + stride of depth/stencil buffer @@ -2119,8 +2105,7 @@ bit 7 for RECTLIST (clear) when z32s8 (used for clear= of depth32? not set - - + @@ -2163,8 +2148,7 @@ bit 7 for RECTLIST (clear) when z32s8 (used for clear= of depth32? not set also for gmem->mem preserving tiling --> - - + @@ -2235,25 +2219,22 @@ bit 7 for RECTLIST (clear) when z32s8 (used for cle= ar of depth32? not set =20 =20 - - + - + - - + =20 - - + =20 @@ -2357,13 +2338,11 @@ bit 7 for RECTLIST (clear) when z32s8 (used for cle= ar of depth32? not set - - + - - + =20 @@ -2423,8 +2402,7 @@ bit 7 for RECTLIST (clear) when z32s8 (used for clear= of depth32? not set - - + @@ -2475,7 +2453,7 @@ bit 7 for RECTLIST (clear) when z32s8 (used for clear= of depth32? not set - + @@ -2516,8 +2494,7 @@ bit 7 for RECTLIST (clear) when z32s8 (used for clear= of depth32? not set - - + =20 @@ -2538,8 +2515,7 @@ bit 7 for RECTLIST (clear) when z32s8 (used for clear= of depth32? not set - - + @@ -2577,8 +2553,7 @@ bit 7 for RECTLIST (clear) when z32s8 (used for clear= of depth32? not set - - + @@ -2587,22 +2562,19 @@ bit 7 for RECTLIST (clear) when z32s8 (used for cle= ar of depth32? not set =20 - - + - - + - - + @@ -2615,8 +2587,7 @@ bit 7 for RECTLIST (clear) when z32s8 (used for clear= of depth32? not set - - + =20 diff --git a/drivers/gpu/drm/msm/registers/adreno/a6xx.xml b/drivers/gpu/dr= m/msm/registers/adreno/a6xx.xml index 2309870f5031..3349c01646e1 100644 --- a/drivers/gpu/drm/msm/registers/adreno/a6xx.xml +++ b/drivers/gpu/drm/msm/registers/adreno/a6xx.xml @@ -10,19 +10,24 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org/fr= eedreno/ rules-fd.xsd"> + =20 @@ -1321,7 +1326,7 @@ by a particular renderpass/blit. =20 - + @@ -1331,13 +1336,13 @@ by a particular renderpass/blit. =20 - + - + - + Configures the mapping between VSC_PIPE buffer and @@ -1370,7 +1375,7 @@ by a particular renderpass/blit. =20 - + Seems to be a bitmap of which tiles mapped to the VSC pipe contain geometry. @@ -1381,7 +1386,7 @@ by a particular renderpass/blit. =20 - + Has the size of data written to corresponding VSC_PRIM_STRM buffer. @@ -1389,7 +1394,7 @@ by a particular renderpass/blit. =20 - + Has the size of data written to corresponding VSC pipe, ie. same thing that is written out to VSC_SIZE_BASE @@ -1397,7 +1402,7 @@ by a particular renderpass/blit. =20 - + =20 @@ -1428,29 +1433,22 @@ by a particular renderpass/blit. =20 - - + + =20 - - - - - - - - - - - - - - - - + + + + + + + + + =20 @@ -1465,16 +1463,16 @@ by a particular renderpass/blit. =20 - - + + =20 =20 - - + + =20 @@ -1499,33 +1497,48 @@ by a particular renderpass/blit. =20 - + + + =20 - + - + - + - + =20 + + + + + + + + + + + + + =20 - + @@ -1534,7 +1547,7 @@ by a particular renderpass/blit. =20 - + @@ -1543,16 +1556,16 @@ by a particular renderpass/blit. =20 - + - + =20 - + @@ -1572,17 +1585,18 @@ by a particular renderpass/blit. TODO: what about gen2 (a640)? --> - - - - - - - - + + + + + + + + + =20 @@ -1590,49 +1604,49 @@ by a particular renderpass/blit. =20 - - + + =20 - - + + =20 =20 - - + + =20 =20 - - + + =20 =20 - - + + =20 =20 - - + + =20 - - + + =20 - - + + =20 - - + + =20 @@ -1640,8 +1654,8 @@ by a particular renderpass/blit. =20 - - + + =20 @@ -1667,19 +1681,19 @@ by a particular renderpass/blit. - - - + + + =20 - - - + + + =20 =20 - + =20 @@ -1738,10 +1752,10 @@ by a particular renderpass/blit. =20 - + - + =20 @@ -1778,7 +1792,7 @@ by a particular renderpass/blit. =20 - + =20 @@ -1795,7 +1809,7 @@ by a particular renderpass/blit. =20 - + @@ -1808,16 +1822,16 @@ by a particular renderpass/blit. =20 - - + + =20 =20 - - + + =20 @@ -1835,15 +1849,15 @@ by a particular renderpass/blit. =20 - - - + + + =20 - - - - - + + + + + =20 @@ -1860,30 +1874,53 @@ by a particular renderpass/blit. =20 - + =20 - + =20 - + - + =20 - - + + + + + + + + + + + + + + + + + + + + + + =20 - - + + + + + =20 @@ -1893,45 +1930,59 @@ by a particular renderpass/blit. =20 - + + + + + + + + + =20 - - + + + + + =20 =20 - - + + + + + =20 =20 - - + + =20 - - + + =20 =20 - - + + =20 @@ -1966,24 +2017,23 @@ by a particular renderpass/blit. =20 - + - - + + =20 - + The total size of the LRZ image array (not including fast clear buffer), used as a stride for double buffering used with concurrent binning. - - - - + + + =20 @@ -1995,28 +2045,28 @@ by a particular renderpass/blit. =20 - - + + =20 =20 - - + + =20 - - + + =20 - + =20 - - + + =20 - + =20 - - + + =20 - + =20 @@ -2082,8 +2132,8 @@ by a particular renderpass/blit. =20 - - + + =20 LUT used to convert quality buffer values to HW shading rate values.= An array of 4-bit values. @@ -2128,32 +2178,32 @@ by a particular renderpass/blit. =20 - + - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + =20 @@ -2180,10 +2230,10 @@ by a particular renderpass/blit. --> =20 - - + + =20 - + @@ -2197,7 +2247,7 @@ by a particular renderpass/blit. - + @@ -2206,26 +2256,26 @@ by a particular renderpass/blit. =20 - + - + =20 - - - - - + + + + + - + @@ -2236,7 +2286,7 @@ by a particular renderpass/blit. - + @@ -2248,16 +2298,16 @@ by a particular renderpass/blit. =20 - + - + - + @@ -2277,7 +2327,7 @@ by a particular renderpass/blit. - + @@ -2289,11 +2339,11 @@ by a particular renderpass/blit. =20 - + - + @@ -2316,7 +2366,7 @@ by a particular renderpass/blit. =20 - + =20 @@ -2330,12 +2380,12 @@ by a particular renderpass/blit. =20 - + =20 - + @@ -2383,16 +2433,16 @@ by a particular renderpass/blit. =20 - - - - + + + + - + @@ -2401,12 +2451,12 @@ by a particular renderpass/blit. - + - + =20 - + @@ -2422,23 +2472,23 @@ by a particular renderpass/blit. =20 - + - + =20 - - - - + + + + =20 - - + + - + - + - + @@ -2498,41 +2548,41 @@ by a particular renderpass/blit. - - + + =20 - + - + =20 - + - - + + - + =20 - - - + + + =20 - - + + - + - + @@ -2541,23 +2591,23 @@ by a particular renderpass/blit. - - + + - - + + =20 =20 - + =20 - - - - + + + + =20 @@ -2567,7 +2617,7 @@ by a particular renderpass/blit. =20 - + @@ -2595,7 +2645,7 @@ by a particular renderpass/blit. - + =20 @@ -2637,17 +2687,17 @@ by a particular renderpass/blit. =20 - + =20 - + =20 - + @@ -2656,16 +2706,25 @@ by a particular renderpass/blit. + + + + + + + + + - - + + =20 - + @@ -2683,7 +2742,8 @@ by a particular renderpass/blit. =20 - + + =20 @@ -2693,13 +2753,13 @@ by a particular renderpass/blit. These show up in a6xx gen3+ but so far haven't found an example of blob writing non-zero: --> - - - - + + + + =20 - - + + =20 @@ -2731,28 +2791,28 @@ by a particular renderpass/blit. =20 - - - + + + - - - + + + =20 - - + + - - + + =20 - - - - + + + + =20 - + =20 =20 @@ -2821,7 +2881,7 @@ by a particular renderpass/blit. =20 - + =20 @@ -2847,7 +2907,7 @@ by a particular renderpass/blit. =20 =20 - + =20 @@ -2860,17 +2920,17 @@ by a particular renderpass/blit. - - - + + + =20 - - - + + + =20 - - - + + + =20 @@ -2878,17 +2938,17 @@ by a particular renderpass/blit. =20 - - - + + + =20 - - - + + + =20 - - - + + + =20 @@ -2897,19 +2957,19 @@ by a particular renderpass/blit. =20 - - - - + + + + =20 - + =20 - - + + @@ -2949,14 +3009,14 @@ by a particular renderpass/blit. =20 - - - - - - - - + + + + + + + + =20 @@ -2973,20 +3033,20 @@ by a particular renderpass/blit. =20 - + Packed array of a6xx_varying_interp_mode - + Packed array of a6xx_varying_ps_repl_mode =20 - + Packed array of a6xx_varying_interp_mode - + Packed array of a6xx_varying_ps_repl_mode @@ -2995,12 +3055,12 @@ by a particular renderpass/blit. =20 - + =20 - + @@ -3034,8 +3094,8 @@ by a particular renderpass/blit. =20 - - + + =20 @@ -3047,8 +3107,8 @@ by a particular renderpass/blit. =20 - - + + =20 @@ -3097,13 +3157,13 @@ by a particular renderpass/blit. =20 - - - + + + =20 - - - + + + =20 @@ -3124,8 +3184,8 @@ by a particular renderpass/blit. =20 - - + + =20 - - + + =20 @@ -3253,7 +3313,7 @@ by a particular renderpass/blit. =20 - + @@ -3287,9 +3347,12 @@ by a particular renderpass/blit. =20 =20 - - - + + + + + + =20 =20 - - + + =20 @@ -3324,31 +3387,31 @@ by a particular renderpass/blit. =20 - - - - + + + + =20 - - - - + + + + =20 - - + + =20 - + size in vec4s of per-primitive storage for gs. TODO: not actually in V= PC =20 - - + + - - + + @@ -3426,18 +3489,18 @@ by a particular renderpass/blit. =20 - + - + - + This is the ID of the current patch within the @@ -3450,20 +3513,20 @@ by a particular renderpass/blit. - + - - + + - + - + - + @@ -3474,7 +3537,7 @@ by a particular renderpass/blit. =20 - + @@ -3482,14 +3545,14 @@ by a particular renderpass/blit. =20 - - - + + + - + @@ -3502,14 +3565,14 @@ by a particular renderpass/blit. - + =20 - + =20 =20 @@ -3549,10 +3612,12 @@ by a particular renderpass/blit. --> - - - + + + + + =20 @@ -3580,7 +3645,7 @@ by a particular renderpass/blit. =20 - + - - + + @@ -3623,7 +3688,7 @@ by a particular renderpass/blit. an extra varying after, but with a lower OUTLOC position. If present, psize is last, preceded by position. --> - + @@ -3712,20 +3777,20 @@ by a particular renderpass/blit. =20 - - - - - - - - - + + + + + + + + + =20 - + @@ -3735,32 +3800,32 @@ by a particular renderpass/blit. the maximum size of local storage should be: 64 (wavesize) * 64 (SP_HS_CNTL_1) * 4 =3D 16k --> - - + + =20 - - - - - - - - - + + + + + + + + + =20 - + =20 - - + + @@ -3768,7 +3833,7 @@ by a particular renderpass/blit. - + @@ -3778,24 +3843,24 @@ by a particular renderpass/blit. =20 - - - - - - - - - + + + + + + + + + =20 - + - + Normally the size of the output of the last stage in dwords. It should be programmed as follows: @@ -3809,14 +3874,14 @@ by a particular renderpass/blit. doesn't matter in practice. - + =20 - + - + @@ -3825,7 +3890,7 @@ by a particular renderpass/blit. =20 - + @@ -3835,15 +3900,15 @@ by a particular renderpass/blit. =20 - - - - - - - - - + + + + + + + + + @@ -3859,7 +3924,7 @@ by a particular renderpass/blit. =20 =20 - + @@ -3878,16 +3943,15 @@ by a particular renderpass/blit. and so one pixel's value is always unused. - - - - - - + + + + + =20 @@ -3897,12 +3961,12 @@ by a particular renderpass/blit. =20 - - + + =20 - + @@ -3913,7 +3977,7 @@ by a particular renderpass/blit. - + @@ -3923,17 +3987,17 @@ by a particular renderpass/blit. - + - + =20 - + per MRT @@ -3941,7 +4005,7 @@ by a particular renderpass/blit. =20 - + @@ -3950,7 +4014,7 @@ by a particular renderpass/blit. =20 - + @@ -3967,7 +4031,7 @@ by a particular renderpass/blit. - + @@ -3981,7 +4045,7 @@ by a particular renderpass/blit. - + @@ -3993,21 +4057,21 @@ by a particular renderpass/blit. - + - + - + =20 =20 - + @@ -4025,7 +4089,7 @@ by a particular renderpass/blit. =20 - + If 0 - all 32k of shared storage is enabled, otherwise @@ -4045,29 +4109,29 @@ by a particular renderpass/blit. - - - - - - - - - - - - + + + + + + + + + + + + =20 - + - + @@ -4104,10 +4168,10 @@ by a particular renderpass/blit. =20 =20 - - - - + + + + =20 @@ -4118,13 +4182,13 @@ by a particular renderpass/blit. =20 - + - + @@ -4134,9 +4198,9 @@ by a particular renderpass/blit. - - - + + + =20 @@ -4192,7 +4256,7 @@ by a particular renderpass/blit. =20 - + - + =20 - + =20 - - + + =20 - + =20 - + - + @@ -4259,8 +4323,8 @@ by a particular renderpass/blit. =20 - - + + =20 @@ -4268,7 +4332,14 @@ by a particular renderpass/blit. - + + + When this bit is enabled, new waves may be unlocked once + all invocations have signaled they don't need local + memory anymore using (eolm)nop. + + + @@ -4333,7 +4404,7 @@ by a particular renderpass/blit. =20 - + =20 - - - - + + + + =20 - + =20 + =20 - =20 - + @@ -4387,6 +4458,11 @@ by a particular renderpass/blit. + + + + + =20 @@ -4395,24 +4471,26 @@ by a particular renderpass/blit. badly named or the functionality moved in a6xx. But downstream kernel calls this "a6xx_sp_ps_tp_2d_cluster" --> - - + + - - + + =20 - - + + - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + - - + + + =20 - - + + + - + + + - + - - - - - - + + + + + + - + - + - - - - + + + + =20 - + - + - + - + - + - + - + - + - - - + + + =20 - + - + - + - + - + - + - + - - - + + + =20 @@ -4690,7 +4774,7 @@ by a particular renderpass/blit. =20 - + @@ -4711,7 +4795,7 @@ by a particular renderpass/blit. =20 - + @@ -4723,7 +4807,7 @@ by a particular renderpass/blit. =20 - + @@ -4731,7 +4815,7 @@ by a particular renderpass/blit. =20 - + @@ -4750,7 +4834,7 @@ by a particular renderpass/blit. =20 - + This register clears pending loads queued up by CP_LOAD_STATE6. Each bit resets a particular kind(s) of @@ -4790,7 +4874,7 @@ by a particular renderpass/blit. =20 - + This register clears pending loads queued up by CP_LOAD_STATE6. Each bit resets a particular kind(s) of @@ -4813,7 +4897,7 @@ by a particular renderpass/blit. =20 - + This register clears pending loads queued up by CP_LOAD_STATE6. Each bit resets a particular kind(s) of @@ -4829,16 +4913,16 @@ by a particular renderpass/blit. =20 - - + + =20 - - + + =20 - - + + =20 - + Shared constants are intended to be used for Vulkan push constants. When enabled, 8 vec4's are reserved in the FS diff --git a/drivers/gpu/drm/msm/registers/adreno/a6xx_descriptors.xml b/dr= ivers/gpu/drm/msm/registers/adreno/a6xx_descriptors.xml index 56cfaff614a4..08bc37f29a6f 100644 --- a/drivers/gpu/drm/msm/registers/adreno/a6xx_descriptors.xml +++ b/drivers/gpu/drm/msm/registers/adreno/a6xx_descriptors.xml @@ -45,19 +45,21 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org/fr= eedreno/ rules-fd.xsd"> =20 - + Texture constant dwords - - - - - + + + + + + - - + + + probably for D3D structured UAVs, normally set to 1 - - + + =20 - + Pitch in bytes (so actually stride) - + @@ -94,15 +97,15 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org/fr= eedreno/ rules-fd.xsd"> layer size at the point that it stops being reduced moving to higher (smaller) mipmap levels --> - - + + - - + + - + - + + + + + - + + - + + + + - + + - + - - + + + + + diff --git a/drivers/gpu/drm/msm/registers/adreno/a6xx_enums.xml b/drivers/= gpu/drm/msm/registers/adreno/a6xx_enums.xml index 81538831dc19..b44946f36fae 100644 --- a/drivers/gpu/drm/msm/registers/adreno/a6xx_enums.xml +++ b/drivers/gpu/drm/msm/registers/adreno/a6xx_enums.xml @@ -328,6 +328,9 @@ to upconvert to 32b float internally? + + + =20 diff --git a/drivers/gpu/drm/msm/registers/adreno/a8xx_descriptors.xml b/dr= ivers/gpu/drm/msm/registers/adreno/a8xx_descriptors.xml index edcbdb3b6921..d119d021446c 100644 --- a/drivers/gpu/drm/msm/registers/adreno/a8xx_descriptors.xml +++ b/drivers/gpu/drm/msm/registers/adreno/a8xx_descriptors.xml @@ -39,76 +39,92 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org/fr= eedreno/ rules-fd.xsd"> =20 - + Texture memobj dwords - + + for type TEX_BUFFER + - + + - + + for type TEX_BUFFER, probably for D3D structured UAVs, normally se= t to 1 + - - - + + + + - - - - + + + + - - - - + + + + - + - + - + - - - - + + + + + + + + + + - = - - + + + - - - - - - + + + + + + - - + + + + + + - + - - + + - + - + - - + + diff --git a/drivers/gpu/drm/msm/registers/adreno/a8xx_perfcntrs.xml b/driv= ers/gpu/drm/msm/registers/adreno/a8xx_perfcntrs.xml new file mode 100644 index 000000000000..a5bb44f76956 --- /dev/null +++ b/drivers/gpu/drm/msm/registers/adreno/a8xx_perfcntrs.xml @@ -0,0 +1,1929 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/drivers/gpu/drm/msm/registers/adreno/adreno_common.xml b/drive= rs/gpu/drm/msm/registers/adreno/adreno_common.xml index 79d204f1e400..195cee078357 100644 --- a/drivers/gpu/drm/msm/registers/adreno/adreno_common.xml +++ b/drivers/gpu/drm/msm/registers/adreno/adreno_common.xml @@ -14,6 +14,27 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org/fre= edreno/ rules-fd.xsd"> =20 + + + + TEX_MEMOBJ descriptor types. These are used + to mark fields that only apply to certain + descriptor types, and potentially overlap + with fields in other types. + + + + + + + Additional descriptor types not part of + TEX_MEMOBJ. These are described by their + own toplevel domain. + + + + + @@ -409,4 +430,25 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org/f= reedreno/ rules-fd.xsd"> =20 + + + + + + + + + + + + + + + + diff --git a/drivers/gpu/drm/msm/registers/adreno/adreno_pm4.xml b/drivers/= gpu/drm/msm/registers/adreno/adreno_pm4.xml index 51e9c94f5e37..f185b541aa70 100644 --- a/drivers/gpu/drm/msm/registers/adreno/adreno_pm4.xml +++ b/drivers/gpu/drm/msm/registers/adreno/adreno_pm4.xml @@ -152,6 +152,8 @@ xsi:schemaLocation=3D"https://gitlab.freedesktop.org/fr= eedreno/ rules-fd.xsd"> + + @@ -1095,7 +1097,7 @@ opcode: CP_LOAD_STATE4 (30) (4 dwords) - + @@ -1275,8 +1277,15 @@ opcode: CP_LOAD_STATE4 (30) (4 dwords) - + + @@ -1469,6 +1478,7 @@ opcode: CP_LOAD_STATE4 (30) (4 dwords) + =20 @@ -1476,7 +1486,7 @@ opcode: CP_LOAD_STATE4 (30) (4 dwords) - + @@ -2055,28 +2065,20 @@ opcode: CP_LOAD_STATE4 (30) (4 dwords) =20 - Executes the following DWORDs of commands if the dword at = ADDR0 - is not equal to 0 and the dword at ADDR1 is less than REF - (signed comparison). + Executes the following DWORDs of commands if the dword + at BOOL_ADDR is not equal to 0 and the the timestamp + value ACTIVE_TIMESTAMP is ahead of the value fetched + from TIMESTAMP_ADDR. + + The timestamp comparision is an unsigned compare with + wraparound, ie: + + (ACTIVE_TIMESTAMP - *TIMESTAMP_ADDR) < 0x80000000 - - - - - - - - - - - - - - - - - - + + + + =20 --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9FD23E3C4B for ; Mon, 4 May 2026 19:08:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921713; cv=none; b=mkmld0iiozQs77oCDN3bDuxYqCo5N0VVLa7c9bGht6GfkOsS2Xk7+zTsrZu6w7uS9egaRB1MZhHWiXQmtKkWMWV8jbLc6R3BI/LBtz5xDLtVPjWRzg8Mje5ZIaMYLTcFjR14xYSWfDDR3MbfIS7uNzlordvylWHEgl9DE5ipP7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921713; c=relaxed/simple; bh=GXAlfXkocczupun207hzzustrrstWGtsUP49FLV+Wmk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gQbbnc1m/5O77598s7VaXJflusfj5Arxa8R2M3NknZbPDLqvZjCVqIa61uQbPGktMKc4IzfK5QdibgwEHcRGhJtdBahPMq1lH0vHqrvh7IuYzSGtBkSfK4l5yVWUeLw4DTMMMZWnWX7US0TqQCWIda7nOM8g25Rllv75PyjtZ5Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=AMpRlPpA; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=CdmME4Jl; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="AMpRlPpA"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="CdmME4Jl" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644Dwc443467670 for ; Mon, 4 May 2026 19:08:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=jxivV/xWxlo 46mmR/YBEGOMAPboyd6VOo1utqcb9wUo=; b=AMpRlPpAJaISf3WV7i+wRfvPPu5 FkdSu1vJcZ8yM41Md/zMhaivMNRX7hyw1aLN/bfk/rsejZr7BHbI308BASuOzqyu by6I8SzSvpAn9d7DIAHrCXcHWwOkIfiL8uYmO7ystYmL7sMIrW6/To3B5neawBoK FayF0cdHOBDBnmyeSWnH8I5DOl6T5fLHPX5RdXA/W8cvqjfUNSRuAyRTFI9g8Ok7 +Nwd42BaRvW9PqYZrbD18q5WukT1UD6kdbBz/6BDzABfafGrnOip066rjjuRV3KE mWqHymbW66OW8Vil0eC6asPHJEsdKseKGnz8LqNwFa7TKoUgwnjiEKgpzqQ== Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxvtjs93f-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:28 +0000 (GMT) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-b62da7602a0so2136222a12.2 for ; Mon, 04 May 2026 12:08:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921708; x=1778526508; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jxivV/xWxlo46mmR/YBEGOMAPboyd6VOo1utqcb9wUo=; b=CdmME4JlyEF3dVy76HMFXDKw8d+1RkXKbvGAceyzV0J7KAsFdX5CBzZMiIpFKu3zxn G5XBo+05oDtRUAfO1reos0HBlzAV5vEl3KAiFkE5PA/JlWHr7PcPmUJF+gAIXY4sra+H o31Ts5e6VhI8EtQr4Z6HVricsGKh6nx0E2lV1d/ok5C/YslRKEIPmNDrLZg8u73Fbe+e nibxiE6pZXdaHzhmLqg2+s/dm0OipmM5h3PFxtchDNmyv1qycQo2zCOcEU5LTHp+bvP+ SekNhNx4iqhELRMgjbRxkaVW99mt+LF5TEDm7ccvznn0qMDfoDlOBRzlVFahs0uoRNjS ZcEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921708; x=1778526508; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=jxivV/xWxlo46mmR/YBEGOMAPboyd6VOo1utqcb9wUo=; b=Yrxfs+Q2YQdOcn5zKP3iuzB85aAJIxe6lRSd3E6GC0e+6pc3Xs/hsPKg98BVdxJbFF pXrnw9o41c1m4mf1F4DbsgOagOf5OKMxElYLgcw0BElHAdUgl7ojfyzjRNkYL1saLrNs YgZLi/PRSvAbrbAah1cPRHvQSGTqRS5tw+K/qblPlcXGcNGp3iaUvmTPPjd5+Wy28qF3 WC+MiKquElzd2++J7SecSVv7NeMmnQ153ar89jSDI0wKL9UpLM94GZX0brTcQebs6lrz IK5oVgpA+EDJu58k0ch5lEO1i5SgSs5kMMIFn7KJ4R/S2R/cL1+JIhUPMlosiI6eOZFj oPRA== X-Forwarded-Encrypted: i=1; AFNElJ/XQonBFjAATek/AqWfh48BVDsJbDytCKKR7F9RV8XpaWGM5Xex7y6MPcxQRDaXAl9QeM7XXx1aBmuJUgU=@vger.kernel.org X-Gm-Message-State: AOJu0YxLIqI7Kt+ksyyuszVurXn8gymarUwlBS+pcOKMB76xjBuNT3UG A5AMbZuCdVYTipRQaT4pfuz/5sBDxG7PBAUNk0kw0V+DSohf51HJPzQqSp49xIswotUbx5NWlC3 tWnta1FLQOq+73+99ENQ8XYjFcn8wOhKfXN1Mgt2qkCPGVxKfbvKgklaG/TjcolcnEQs= X-Gm-Gg: AeBDietUDEObe9ASnY9NkaN/TaghhxGIVW6C50TvHeWAgPPcycRN+DJLS/jWr/CsRge ItSVFRhWZlWLYDhhjs8Cu2YT4BWMK+bvIvJVzBRYmj1uW0EUSsyiJSG+jwztWrMq86U/eayvFY7 y/KPFroRbwKwi3Pbhxtuqx3tOqlKwj1/Uja6V1qg+itVBfGda7dzhogZ31Fl/60mIQTZX1/xAhs bGPjgrCvqOJXnKx+uuOe0R+D19IZWBxBJlfwOLAEpPtIrdEBj9v5DLF3cl/PJIRBFzRf8K46MPG ZcylGKTbK0OpxCvBK9YK1iOjMWJOz81yP+vY1coayaEdrBSR2nDCwvuQz7SuoKndq4Nt770jaQt mx/vmPI2PuTTpaH1h3zGjTldqA8q/5Hpq5vLqbIWPEUM= X-Received: by 2002:a17:90b:578b:b0:35f:b572:ece9 with SMTP id 98e67ed59e1d1-3657736b828mr170178a91.5.1777921707154; Mon, 04 May 2026 12:08:27 -0700 (PDT) X-Received: by 2002:a17:90b:578b:b0:35f:b572:ece9 with SMTP id 98e67ed59e1d1-3657736b828mr170108a91.5.1777921705966; Mon, 04 May 2026 12:08:25 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-364ec02ab2fsm12520172a91.14.2026.05.04.12.08.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:25 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Dmitry Baryshkov , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , David Airlie , Simona Vetter , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , linux-kernel@vger.kernel.org (open list), llvm@lists.linux.dev (open list:CLANG/LLVM BUILD SUPPORT:Keyword:\b(?i:clang|llvm)\b) Subject: [PATCH v3 04/16] drm/msm/registers: Sync gen_header.py from mesa Date: Mon, 4 May 2026 12:06:47 -0700 Message-ID: <20260504190751.61052-5-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: whqonh1qQ5f1DrhYNqOXBu4iOJJZbeYM X-Authority-Analysis: v=2.4 cv=KuN9H2WN c=1 sm=1 tr=0 ts=69f8eead cx=c_pps a=rz3CxIlbcmazkYymdCej/Q==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=e5mUnYsNAAAA:8 a=EUspDBNiAAAA:8 a=upIMGkliACeFOg2EZ_0A:9 a=3o6Nrjf1o8nA2Q1M:21 a=bFCP_H2QrGi7Okbo017w:22 a=Vxmtnl_E_bksehYqCbjh:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfXxxeEPwT4wIkN 6Cu2fh+kBjtxFhqPzfisPqd7a4OgRKYdNP3ulO4HUcNBuKc5u937z3896P9gMh+xtQ+Ijk+NjFu zc8lnEAbGMPGRXAU64MIpvAFOzxEgrwim8Ere7VBYPLSsJ9vzEHUK/OuSiEdkFwQ0t+W4lrqit+ R//UMpj2mbzsfU3a2zpO45Pc4aANNJAu50iCHXjZFCZviV6gLB3wWyqWgovE1fy6MoUTVvo5zmv uguofHc+VZ2o0YsMVgRwKDoegpoQQDE4P7WKmm/9syi27wHN/EhGjj60IT7k7KtlDmGiqWbavQa 8ATNpWsNpPKDVa1tY8m6LU6/En1zGxhMS+y0r8A1csS8h8F8/yhHOb2WGqHpO0ayYngNVIMUalo PFJH70DCmyCscPeG8HBatJZog/sW+IypMKE7lsZNrWEiuEm7A9o8Ate858Fbww45rQCssqrDvT2 YjpQyvPH7lrAp8X4ZUg== X-Proofpoint-ORIG-GUID: whqonh1qQ5f1DrhYNqOXBu4iOJJZbeYM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 adultscore=0 impostorscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" Update gen_header.py to bring in support for generating perfcntr tables. Sync from https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40522 Signed-off-by: Rob Clark Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/msm/registers/gen_header.py | 2079 ++++++++++--------- 1 file changed, 1146 insertions(+), 933 deletions(-) diff --git a/drivers/gpu/drm/msm/registers/gen_header.py b/drivers/gpu/drm/= msm/registers/gen_header.py index 2acad951f1e2..07e6f0cb4e66 100644 --- a/drivers/gpu/drm/msm/registers/gen_header.py +++ b/drivers/gpu/drm/msm/registers/gen_header.py @@ -11,997 +11,1210 @@ import collections import argparse import time import datetime +import json + =20 class Error(Exception): - def __init__(self, message): - self.message =3D message + def __init__(self, message): + self.message =3D message + =20 class Enum(object): - def __init__(self, name): - self.name =3D name - self.values =3D [] - - def has_name(self, name): - for (n, value) in self.values: - if n =3D=3D name: - return True - return False - - def names(self): - return [n for (n, value) in self.values] - - def dump(self, is_deprecated): - use_hex =3D False - for (name, value) in self.values: - if value > 0x1000: - use_hex =3D True - - print("enum %s {" % self.name) - for (name, value) in self.values: - if use_hex: - print("\t%s =3D 0x%08x," % (name, value)) - else: - print("\t%s =3D %d," % (name, value)) - print("};\n") - - def dump_pack_struct(self, is_deprecated): - pass + def __init__(self, name): + self.name =3D name + self.values =3D [] + + def has_name(self, name): + for (n, value) in self.values: + if n =3D=3D name: + return True + return False + + def names(self): + return [n for (n, value) in self.values] + + def value(self, name): + for (n, v) in self.values: + if n =3D=3D name: + return v + + def dump(self, has_variants): + use_hex =3D False + for (name, value) in self.values: + if value > 0x1000: + use_hex =3D True + + print("enum %s {" % self.name) + for (name, value) in self.values: + if use_hex: + print("\t%s =3D 0x%08x," % (name, value)) + else: + print("\t%s =3D %d," % (name, value)) + print("};\n") + + def dump_pack_struct(self, has_variants): + pass + =20 class Field(object): - def __init__(self, name, low, high, shr, type, parser): - self.name =3D name - self.low =3D low - self.high =3D high - self.shr =3D shr - self.type =3D type - - builtin_types =3D [ None, "a3xx_regid", "boolean", "uint", "hex", "int",= "fixed", "ufixed", "float", "address", "waddress" ] - - maxpos =3D parser.current_bitsize - 1 - - if low < 0 or low > maxpos: - raise parser.error("low attribute out of range: %d" % low) - if high < 0 or high > maxpos: - raise parser.error("high attribute out of range: %d" % high) - if high < low: - raise parser.error("low is greater than high: low=3D%d, high=3D%d" % (l= ow, high)) - if self.type =3D=3D "boolean" and not low =3D=3D high: - raise parser.error("booleans should be 1 bit fields") - elif self.type =3D=3D "float" and not (high - low =3D=3D 31 or high - lo= w =3D=3D 15): - raise parser.error("floats should be 16 or 32 bit fields") - elif self.type not in builtin_types and self.type not in parser.enums: - raise parser.error("unknown type '%s'" % self.type) - - def ctype(self, var_name): - if self.type is None: - type =3D "uint32_t" - val =3D var_name - elif self.type =3D=3D "boolean": - type =3D "bool" - val =3D var_name - elif self.type =3D=3D "uint" or self.type =3D=3D "hex" or self.type =3D= =3D "a3xx_regid": - type =3D "uint32_t" - val =3D var_name - elif self.type =3D=3D "int": - type =3D "int32_t" - val =3D var_name - elif self.type =3D=3D "fixed": - type =3D "float" - val =3D "((int32_t)(%s * %d.0))" % (var_name, 1 << self.radix) - elif self.type =3D=3D "ufixed": - type =3D "float" - val =3D "((uint32_t)(%s * %d.0))" % (var_name, 1 << self.radix) - elif self.type =3D=3D "float" and self.high - self.low =3D=3D 31: - type =3D "float" - val =3D "fui(%s)" % var_name - elif self.type =3D=3D "float" and self.high - self.low =3D=3D 15: - type =3D "float" - val =3D "_mesa_float_to_half(%s)" % var_name - elif self.type in [ "address", "waddress" ]: - type =3D "uint64_t" - val =3D var_name - else: - type =3D "enum %s" % self.type - val =3D var_name - - if self.shr > 0: - val =3D "(%s >> %d)" % (val, self.shr) - - return (type, val) + def __init__(self, name, low, high, shr, type, parser): + self.name =3D name + self.low =3D low + self.high =3D high + self.shr =3D shr + self.type =3D type + + builtin_types =3D [None, "a3xx_regid", "boolean", "uint", "hex", + "int", "fixed", "ufixed", "float", "address", "wa= ddress"] + + maxpos =3D parser.current_bitsize - 1 + + if low < 0 or low > maxpos: + raise parser.error("low attribute out of range: %d" % low) + if high < 0 or high > maxpos: + raise parser.error("high attribute out of range: %d" % high) + if high < low: + raise parser.error( + "low is greater than high: low=3D%d, high=3D%d" % (low, hi= gh)) + if self.type =3D=3D "boolean" and not low =3D=3D high: + raise parser.error("booleans should be 1 bit fields") + elif self.type =3D=3D "float" and not (high - low =3D=3D 31 or hig= h - low =3D=3D 15): + raise parser.error("floats should be 16 or 32 bit fields") + elif self.type not in builtin_types and self.type not in parser.en= ums: + raise parser.error("unknown type '%s'" % self.type) + + def ctype(self, var_name): + if self.type is None: + type =3D "uint32_t" + val =3D var_name + elif self.type =3D=3D "boolean": + type =3D "bool" + val =3D var_name + elif self.type =3D=3D "uint" or self.type =3D=3D "hex" or self.typ= e =3D=3D "a3xx_regid": + type =3D "uint32_t" + val =3D var_name + elif self.type =3D=3D "int": + type =3D "int32_t" + val =3D var_name + elif self.type =3D=3D "fixed": + type =3D "float" + val =3D "(uint32_t)((int32_t)(%s * %d.0))" % (var_name, 1 << s= elf.radix) + elif self.type =3D=3D "ufixed": + type =3D "float" + val =3D "((uint32_t)(%s * %d.0))" % (var_name, 1 << self.radix) + elif self.type =3D=3D "float" and self.high - self.low =3D=3D 31: + type =3D "float" + val =3D "fui(%s)" % var_name + elif self.type =3D=3D "float" and self.high - self.low =3D=3D 15: + type =3D "float" + val =3D "_mesa_float_to_half(%s)" % var_name + elif self.type in ["address", "waddress"]: + type =3D "uint64_t" + val =3D var_name + else: + type =3D "enum %s" % self.type + val =3D var_name + + if self.shr > 0: + val =3D "(%s >> %d)" % (val, self.shr) + + return (type, val) + =20 def tab_to(name, value): - tab_count =3D (68 - (len(name) & ~7)) // 8 - if tab_count <=3D 0: - tab_count =3D 1 - print(name + ('\t' * tab_count) + value) + tab_count =3D (68 - (len(name) & ~7)) // 8 + if tab_count <=3D 0: + tab_count =3D 1 + print(name + ('\t' * tab_count) + value) + +def define_macro(name, value, has_variants): + if has_variants: + value =3D "__FD_DEPRECATED " + value + tab_to(name, value) =20 def mask(low, high): - return ((0xffffffffffffffff >> (64 - (high + 1 - low))) << low) + return ((0xffffffffffffffff >> (64 - (high + 1 - low))) << low) + =20 def field_name(reg, f): - if f.name: - name =3D f.name.lower() - else: - # We hit this path when a reg is defined with no bitset fields, ie. - # - name =3D reg.name.lower() + if f.name: + name =3D f.name.lower() + else: + # We hit this path when a reg is defined with no bitset fields, ie. + # + name =3D reg.name.lower() =20 - if (name in [ "double", "float", "int" ]) or not (name[0].isalpha()): - name =3D "_" + name + if (name in ["double", "float", "int"]) or not (name[0].isalpha()): + name =3D "_" + name =20 - return name + return name =20 # indices - array of (ctype, stride, __offsets_NAME) + + def indices_varlist(indices): - return ", ".join(["i%d" % i for i in range(len(indices))]) + return ", ".join(["i%d" % i for i in range(len(indices))]) + =20 def indices_prototype(indices): - return ", ".join(["%s i%d" % (ctype, idx) - for (idx, (ctype, stride, offset)) in enumerate(indices)]) + return ", ".join(["%s i%d" % (ctype, idx) + for (idx, (ctype, stride, offset)) in enumerate(indi= ces)]) + =20 def indices_strides(indices): - return " + ".join(["0x%x*i%d" % (stride, idx) - if stride else - "%s(i%d)" % (offset, idx) - for (idx, (ctype, stride, offset)) in enumerate(indices)]) + return " + ".join(["0x%x*i%d" % (stride, idx) + if stride else + "%s(i%d)" % (offset, idx) + for (idx, (ctype, stride, offset)) in enumerate(ind= ices)]) + =20 def is_number(str): - try: - int(str) - return True - except ValueError: - return False + try: + int(str) + return True + except ValueError: + return False + =20 def sanitize_variant(variant): - if variant and "-" in variant: - return variant[:variant.index("-")] - return variant + if variant and "-" in variant: + return variant[:variant.index("-")] + return variant + =20 class Bitset(object): - def __init__(self, name, template): - self.name =3D name - self.inline =3D False - self.reg =3D None - if template: - self.fields =3D template.fields[:] - else: - self.fields =3D [] - - # Get address field if there is one in the bitset, else return None: - def get_address_field(self): - for f in self.fields: - if f.type in [ "address", "waddress" ]: - return f - return None - - def dump_regpair_builder(self, reg): - print("#ifndef NDEBUG") - known_mask =3D 0 - for f in self.fields: - known_mask |=3D mask(f.low, f.high) - if f.type in [ "boolean", "address", "waddress" ]: - continue - type, val =3D f.ctype("fields.%s" % field_name(reg, f)) - print(" assert((%-40s & 0x%08x) =3D=3D 0);" % (val, 0xffffffff ^ mas= k(0 , f.high - f.low))) - print(" assert((%-40s & 0x%08x) =3D=3D 0);" % ("fields.unknown", know= n_mask)) - print("#endif\n") - - print(" return (struct fd_reg_pair) {") - print(" .reg =3D (uint32_t)%s," % reg.reg_offset()) - print(" .value =3D") - cast =3D "(uint64_t)" if reg.bit_size =3D=3D 64 else "" - for f in self.fields: - if f.type in [ "address", "waddress" ]: - continue - else: - type, val =3D f.ctype("fields.%s" % field_name(reg, f)) - print(" (%s%-40s << %2d) |" % (cast, val, f.low)) - value_name =3D "dword" - if reg.bit_size =3D=3D 64: - value_name =3D "qword" - print(" fields.unknown | fields.%s," % (value_name,)) - - address =3D self.get_address_field() - if address: - print(" .bo =3D fields.bo,") - print(" .is_address =3D true,") - if f.type =3D=3D "waddress": - print(" .bo_write =3D true,") - print(" .bo_offset =3D fields.bo_offset,") - print(" .bo_shift =3D %d," % address.shr) - print(" .bo_low =3D %d," % address.low) - - print(" };") - - def dump_pack_struct(self, is_deprecated, reg=3DNone): - if not reg: - return - - prefix =3D reg.full_name - - print("struct %s {" % prefix) - for f in self.fields: - if f.type in [ "address", "waddress" ]: - tab_to(" __bo_type", "bo;") - tab_to(" uint32_t", "bo_offset;") - continue - name =3D field_name(reg, f) - - type, val =3D f.ctype("var") - - tab_to(" %s" % type, "%s;" % name) - if reg.bit_size =3D=3D 64: - tab_to(" uint64_t", "unknown;") - tab_to(" uint64_t", "qword;") - else: - tab_to(" uint32_t", "unknown;") - tab_to(" uint32_t", "dword;") - print("};\n") - - depcrstr =3D "" - if is_deprecated: - depcrstr =3D " FD_DEPRECATED" - if reg.array: - print("static inline%s struct fd_reg_pair\npack_%s(uint32_t __i, struct= %s fields)\n{" % - (depcrstr, prefix, prefix)) - else: - print("static inline%s struct fd_reg_pair\npack_%s(struct %s fields)\n{= " % - (depcrstr, prefix, prefix)) - - self.dump_regpair_builder(reg) - - print("\n}\n") - - if self.get_address_field(): - skip =3D ", { .reg =3D 0 }" - else: - skip =3D "" - - if reg.array: - print("#define %s(__i, ...) pack_%s(__i, __struct_cast(%s) { __VA_ARGS_= _ })%s\n" % - (prefix, prefix, prefix, skip)) - else: - print("#define %s(...) pack_%s(__struct_cast(%s) { __VA_ARGS__ })%s\n" % - (prefix, prefix, prefix, skip)) - - - def dump(self, is_deprecated, prefix=3DNone, reg=3DNone): - if prefix is None: - prefix =3D self.name - reg64 =3D reg and self.reg and self.reg.bit_size =3D=3D 64 - if reg64: - print("static inline uint32_t %s_LO(uint32_t val)\n{" % prefix) - print("\treturn val;\n}") - print("static inline uint32_t %s_HI(uint32_t val)\n{" % prefix) - print("\treturn val;\n}") - for f in self.fields: - if f.name: - name =3D prefix + "_" + f.name - else: - name =3D prefix - - if not f.name and f.low =3D=3D 0 and f.shr =3D=3D 0 and f.type not in [= "float", "fixed", "ufixed"]: - pass - elif f.type =3D=3D "boolean" or (f.type is None and f.low =3D=3D f.high= ): - tab_to("#define %s" % name, "0x%08x" % (1 << f.low)) - else: - typespec =3D "ull" if reg64 else "u" - tab_to("#define %s__MASK" % name, "0x%08x%s" % (mask(f.low, f.high), t= ypespec)) - tab_to("#define %s__SHIFT" % name, "%d" % f.low) - type, val =3D f.ctype("val") - ret_type =3D "uint64_t" if reg64 else "uint32_t" - cast =3D "(uint64_t)" if reg64 else "" - - print("static inline %s %s(%s val)\n{" % (ret_type, name, type)) - if f.shr > 0: - print("\tassert(!(val & 0x%x));" % mask(0, f.shr - 1)) - print("\treturn (%s(%s) << %s__SHIFT) & %s__MASK;\n}" % (cast, val, na= me, name)) - print() + def __init__(self, name, template): + self.name =3D name + self.inline =3D False + self.reg =3D None + if template: + self.fields =3D template.fields[:] + else: + self.fields =3D [] + + # Get address field if there is one in the bitset, else return None: + def get_address_field(self): + for f in self.fields: + if f.type in ["address", "waddress"]: + return f + return None + + def dump_regpair_builder(self, reg): + print("#ifndef NDEBUG") + known_mask =3D 0 + for f in self.fields: + known_mask |=3D mask(f.low, f.high) + if f.type in ["boolean", "address", "waddress"]: + continue + type, val =3D f.ctype("fields.%s" % field_name(reg, f)) + print(" assert((%-40s & 0x%08x) =3D=3D 0);" % + (val, 0xffffffff ^ mask(0, f.high - f.low))) + print(" assert((%-40s & 0x%08x) =3D=3D 0);" % + ("fields.unknown", known_mask)) + print("#endif\n") + + print(" return (struct fd_reg_pair) {") + print(" .reg =3D (uint32_t)%s," % reg.reg_offset()) + print(" .value =3D") + cast =3D "(uint64_t)" if reg.bit_size =3D=3D 64 else "" + for f in self.fields: + if f.type in ["address", "waddress"]: + continue + else: + type, val =3D f.ctype("fields.%s" % field_name(reg, f)) + print(" (%s%-40s << %2d) |" % (cast, val, f.low= )) + value_name =3D "dword" + if reg.bit_size =3D=3D 64: + value_name =3D "qword" + print(" fields.unknown | fields.%s," % (value_name,)) + + address =3D self.get_address_field() + if address: + print("#ifndef TU_CS_H") + print(" .bo =3D fields.bo,") + print(" .is_address =3D true,") + print(" .bo_offset =3D fields.bo_offset,") + print(" .bo_shift =3D %d," % address.shr) + print(" .bo_low =3D %d," % address.low) + print("#else") + print(" .is_address =3D true,") + print("#endif") + + print(" };") + + def dump_pack_struct(self, has_variants, reg=3DNone): + if not reg: + return + + prefix =3D reg.full_name + + constexpr_mark =3D " CONSTEXPR" + + print("struct %s {" % prefix) + for f in self.fields: + if f.type in ["address", "waddress"]: + print("#ifndef TU_CS_H") + tab_to(" __bo_type", "bo;") + tab_to(" uint32_t", "bo_offset;") + print("#endif\n") + continue + name =3D field_name(reg, f) + + type, val =3D f.ctype("var") + + tab_to(" %s" % type, "%s;" % name) + + if f.type =3D=3D "float": + # Requires using `fui()` or `_mesa_float_to_half()` + constexpr_mark =3D "" + if reg.bit_size =3D=3D 64: + tab_to(" uint64_t", "qword;") + tab_to(" uint64_t", "unknown;") + else: + tab_to(" uint32_t", "dword;") + tab_to(" uint32_t", "unknown;") + print("};\n") + + if not has_variants: + print("static%s inline struct fd_reg_pair" % constexpr_mark) + if reg.array: + print("pack_%s(uint32_t __i, struct %s fields)\n{" % (pref= ix, prefix)) + else: + print("pack_%s(struct %s fields)\n{" % (prefix, prefix)) + + self.dump_regpair_builder(reg) + + print("\n}\n") + + if self.get_address_field(): + skip =3D ", { .reg =3D 0 }" + else: + skip =3D "" + + if reg.array: + print("#define %s(__i, ...) pack_%s(__i, __struct_cast(%s) { _= _VA_ARGS__ })%s\n" % + (prefix, prefix, prefix, skip)) + else: + print("#define %s(...) pack_%s(__struct_cast(%s) { __VA_ARGS__= })%s\n" % + (prefix, prefix, prefix, skip)) + + def dump(self, has_variants, prefix=3DNone, reg=3DNone): + if prefix is None: + prefix =3D self.name + suffix =3D "" + if self.reg and self.reg.bit_size =3D=3D 64: + print( + "static CONSTEXPR inline uint32_t %s_LO(uint32_t val)\n{" = % prefix) + print("\treturn val;\n}") + print( + "static CONSTEXPR inline uint32_t %s_HI(uint32_t val)\n{" = % prefix) + print("\treturn val;\n}") + suffix =3D "ull" + + for f in self.fields: + if f.name: + name =3D prefix + "_" + f.name + else: + name =3D prefix + + if not f.name and f.low =3D=3D 0 and f.shr =3D=3D 0 and f.type= not in ["float", "fixed", "ufixed"]: + pass + elif f.type =3D=3D "boolean" or (f.type is None and f.low =3D= =3D f.high): + tab_to("#define %s" % name, "0x%08x%s" % ((1 << f.low), su= ffix)) + else: + tab_to("#define %s__MASK" % + name, "0x%08x%s" % (mask(f.low, f.high), suffix)) + tab_to("#define %s__SHIFT" % name, "%d" % f.low) + type, val =3D f.ctype("val") + ret_type =3D "uint64_t" if reg and reg.bit_size =3D=3D 64 = else "uint32_t" + cast =3D "(uint64_t)" if reg and reg.bit_size =3D=3D 64 el= se "" + + constexpr_mark =3D "" if type =3D=3D "float" else " CONSTE= XPR" + print("static%s inline %s %s(%s val)\n{" % ( + constexpr_mark, ret_type, name, type)) + if f.shr > 0: + print("\tassert(!(val & 0x%x));" % mask(0, f.shr - 1)) + print("\treturn (%s(%s) << %s__SHIFT) & %s__MASK;\n}" % + (cast, val, name, name)) + print() + =20 class Array(object): - def __init__(self, attrs, domain, variant, parent, index_type): - if "name" in attrs: - self.local_name =3D attrs["name"] - else: - self.local_name =3D "" - self.domain =3D domain - self.variant =3D variant - self.parent =3D parent - self.children =3D [] - if self.parent: - self.name =3D self.parent.name + "_" + self.local_name - else: - self.name =3D self.local_name - if "offsets" in attrs: - self.offsets =3D map(lambda i: "0x%08x" % int(i, 0), attrs["offsets"].s= plit(",")) - self.fixed_offsets =3D True - elif "doffsets" in attrs: - self.offsets =3D map(lambda s: "(%s)" % s , attrs["doffsets"].split(","= )) - self.fixed_offsets =3D True - else: - self.offset =3D int(attrs["offset"], 0) - self.stride =3D int(attrs["stride"], 0) - self.fixed_offsets =3D False - if "index" in attrs: - self.index_type =3D index_type - else: - self.index_type =3D None - self.length =3D int(attrs["length"], 0) - if "usage" in attrs: - self.usages =3D attrs["usage"].split(',') - else: - self.usages =3D None - - def index_ctype(self): - if not self.index_type: - return "uint32_t" - else: - return "enum %s" % self.index_type.name - - # Generate array of (ctype, stride, __offsets_NAME) - def indices(self): - if self.parent: - indices =3D self.parent.indices() - else: - indices =3D [] - if self.length !=3D 1: - if self.fixed_offsets: - indices.append((self.index_ctype(), None, "__offset_%s" % self.local_n= ame)) - else: - indices.append((self.index_ctype(), self.stride, None)) - return indices - - def total_offset(self): - offset =3D 0 - if not self.fixed_offsets: - offset +=3D self.offset - if self.parent: - offset +=3D self.parent.total_offset() - return offset - - def dump(self, is_deprecated): - depcrstr =3D "" - if is_deprecated: - depcrstr =3D " FD_DEPRECATED" - proto =3D indices_varlist(self.indices()) - strides =3D indices_strides(self.indices()) - array_offset =3D self.total_offset() - if self.fixed_offsets: - print("static inline%s uint32_t __offset_%s(%s idx)" % (depcrstr, self.= local_name, self.index_ctype())) - print("{\n\tswitch (idx) {") - if self.index_type: - for val, offset in zip(self.index_type.names(), self.offsets): - print("\t\tcase %s: return %s;" % (val, offset)) - else: - for idx, offset in enumerate(self.offsets): - print("\t\tcase %d: return %s;" % (idx, offset)) - print("\t\tdefault: return INVALID_IDX(idx);") - print("\t}\n}") - if proto =3D=3D '': - tab_to("#define REG_%s_%s" % (self.domain, self.name), "0x%08x\n" % arr= ay_offset) - else: - tab_to("#define REG_%s_%s(%s)" % (self.domain, self.name, proto), "(0x%= 08x + %s )\n" % (array_offset, strides)) - - def dump_pack_struct(self, is_deprecated): - pass - - def dump_regpair_builder(self): - pass + def __init__(self, attrs, domain, variant, parent, index_type): + if "name" in attrs: + self.local_name =3D attrs["name"] + else: + self.local_name =3D "" + self.domain =3D domain + self.variant =3D variant + self.parent =3D parent + self.children =3D [] + if self.parent: + self.name =3D self.parent.name + "_" + self.local_name + else: + self.name =3D self.local_name + if "offsets" in attrs: + self.offsets =3D map(lambda i: "0x%08x" % + int(i, 0), attrs["offsets"].split(",")) + self.fixed_offsets =3D True + elif "doffsets" in attrs: + self.offsets =3D map(lambda s: "(%s)" % + s, attrs["doffsets"].split(",")) + self.fixed_offsets =3D True + else: + self.offset =3D int(attrs["offset"], 0) + self.stride =3D int(attrs["stride"], 0) + self.fixed_offsets =3D False + if "index" in attrs: + self.index_type =3D index_type + else: + self.index_type =3D None + self.length =3D int(attrs["length"], 0) + if "usage" in attrs: + self.usages =3D attrs["usage"].split(',') + else: + self.usages =3D None + + def index_ctype(self): + if not self.index_type: + return "uint32_t" + else: + return "enum %s" % self.index_type.name + + # Generate array of (ctype, stride, __offsets_NAME) + def indices(self): + if self.parent: + indices =3D self.parent.indices() + else: + indices =3D [] + if self.length !=3D 1: + if self.fixed_offsets: + indices.append((self.index_ctype(), None, + "__offset_%s" % self.local_name)) + else: + indices.append((self.index_ctype(), self.stride, None)) + return indices + + def total_offset(self): + offset =3D 0 + if not self.fixed_offsets: + offset +=3D self.offset + if self.parent: + offset +=3D self.parent.total_offset() + return offset + + def dump(self, has_variants): + proto =3D indices_varlist(self.indices()) + strides =3D indices_strides(self.indices()) + array_offset =3D self.total_offset() + if self.fixed_offsets and not has_variants: + print("static CONSTEXPR inline uint32_t __offset_%s(%s idx)" % + (self.local_name, self.index_ctype())) + print("{\n\tswitch (idx) {") + if self.index_type: + for val, offset in zip(self.index_type.names(), self.offse= ts): + print("\t\tcase %s: return %s;" % (val, offset)) + else: + for idx, offset in enumerate(self.offsets): + print("\t\tcase %d: return %s;" % (idx, offset)) + print("\t\tdefault: return INVALID_IDX(idx);") + print("\t}\n}") + if proto =3D=3D '': + define_macro("#define REG_%s_%s" % + (self.domain, self.name), "0x%08x\n" % array_offs= et, + has_variants) + else: + define_macro("#define REG_%s_%s(%s)" % (self.domain, self.name, + proto), "(0x%08x + %s )\n" % (array_offset, strid= es), + has_variants) + + def dump_pack_struct(self, has_variants): + pass + + def dump_regpair_builder(self): + pass + =20 class Reg(object): - def __init__(self, attrs, domain, array, bit_size): - self.name =3D attrs["name"] - self.domain =3D domain - self.array =3D array - self.offset =3D int(attrs["offset"], 0) - self.type =3D None - self.bit_size =3D bit_size - if array: - self.name =3D array.name + "_" + self.name - array.children.append(self) - self.full_name =3D self.domain + "_" + self.name - if "stride" in attrs: - self.stride =3D int(attrs["stride"], 0) - self.length =3D int(attrs["length"], 0) - else: - self.stride =3D None - self.length =3D None - - # Generate array of (ctype, stride, __offsets_NAME) - def indices(self): - if self.array: - indices =3D self.array.indices() - else: - indices =3D [] - if self.stride: - indices.append(("uint32_t", self.stride, None)) - return indices - - def total_offset(self): - if self.array: - return self.array.total_offset() + self.offset - else: - return self.offset - - def reg_offset(self): - if self.array: - offset =3D self.array.offset + self.offset - return "(0x%08x + 0x%x*__i)" % (offset, self.array.stride) - return "0x%08x" % self.offset - - def dump(self, is_deprecated): - depcrstr =3D "" - if is_deprecated: - depcrstr =3D " FD_DEPRECATED " - proto =3D indices_prototype(self.indices()) - strides =3D indices_strides(self.indices()) - offset =3D self.total_offset() - if proto =3D=3D '': - tab_to("#define REG_%s" % self.full_name, "0x%08x" % offset) - else: - print("static inline%s uint32_t REG_%s(%s) { return 0x%08x + %s; }" % (= depcrstr, self.full_name, proto, offset, strides)) - - if self.bitset.inline: - self.bitset.dump(is_deprecated, self.full_name, self) - print("") - - def dump_pack_struct(self, is_deprecated): - if self.bitset.inline: - self.bitset.dump_pack_struct(is_deprecated, self) - - def dump_regpair_builder(self): - self.bitset.dump_regpair_builder(self) - - def dump_py(self): - print("\tREG_%s =3D 0x%08x" % (self.full_name, self.offset)) + def __init__(self, attrs, domain, array, bit_size): + self.name =3D attrs["name"] + self.domain =3D domain + self.array =3D array + self.offset =3D int(attrs["offset"], 0) + self.type =3D None + self.bit_size =3D bit_size + if array: + self.name =3D array.name + "_" + self.name + array.children.append(self) + self.full_name =3D self.domain + "_" + self.name + if "stride" in attrs: + self.stride =3D int(attrs["stride"], 0) + self.length =3D int(attrs["length"], 0) + else: + self.stride =3D None + self.length =3D None + + # Generate array of (ctype, stride, __offsets_NAME) + def indices(self): + if self.array: + indices =3D self.array.indices() + else: + indices =3D [] + if self.stride: + indices.append(("uint32_t", self.stride, None)) + return indices + + def total_offset(self): + if self.array: + return self.array.total_offset() + self.offset + else: + return self.offset + + def reg_offset(self): + if self.array: + offset =3D self.array.offset + self.offset + return "(0x%08x + 0x%x*__i)" % (offset, self.array.stride) + return "0x%08x" % self.offset + + def dump(self, has_variants): + proto =3D indices_prototype(self.indices()) + strides =3D indices_strides(self.indices()) + offset =3D self.total_offset() + if proto =3D=3D '': + define_macro("#define REG_%s" % self.full_name, "0x%08x" % off= set, has_variants) + elif not has_variants: + depcrstr =3D "" + if has_variants: + depcrstr =3D " __FD_DEPRECATED " + print("static CONSTEXPR inline%s uint32_t REG_%s(%s) { return = 0x%08x + %s; }" % ( + depcrstr, self.full_name, proto, offset, strides)) + + if self.bitset.inline: + self.bitset.dump(has_variants, self.full_name, self) + print("") + + def dump_pack_struct(self, has_variants): + if self.bitset.inline: + self.bitset.dump_pack_struct(has_variants, self) + + def dump_regpair_builder(self): + self.bitset.dump_regpair_builder(self) + + def dump_py(self): + offset =3D self.offset + if self.array: + offset +=3D self.array.offset + print("\tREG_%s =3D 0x%08x" % (self.full_name, offset)) =20 =20 class Parser(object): - def __init__(self): - self.current_array =3D None - self.current_domain =3D None - self.current_prefix =3D None - self.current_prefix_type =3D None - self.current_stripe =3D None - self.current_bitset =3D None - self.current_bitsize =3D 32 - # The varset attribute on the domain specifies the enum which - # specifies all possible hw variants: - self.current_varset =3D None - # Regs that have multiple variants.. we only generated the C++ - # template based struct-packers for these - self.variant_regs =3D {} - # Information in which contexts regs are used, to be used in - # debug options - self.usage_regs =3D collections.defaultdict(list) - self.bitsets =3D {} - self.enums =3D {} - self.variants =3D set() - self.file =3D [] - self.xml_files =3D [] - - def error(self, message): - parser, filename =3D self.stack[-1] - return Error("%s:%d:%d: %s" % (filename, parser.CurrentLineNumber, parse= r.CurrentColumnNumber, message)) - - def prefix(self, variant=3DNone): - if self.current_prefix_type =3D=3D "variant" and variant: - return sanitize_variant(variant) - elif self.current_stripe: - return self.current_stripe + "_" + self.current_domain - elif self.current_prefix: - return self.current_prefix + "_" + self.current_domain - else: - return self.current_domain - - def parse_field(self, name, attrs): - try: - if "pos" in attrs: - high =3D low =3D int(attrs["pos"], 0) - elif "high" in attrs and "low" in attrs: - high =3D int(attrs["high"], 0) - low =3D int(attrs["low"], 0) - else: - low =3D 0 - high =3D self.current_bitsize - 1 - - if "type" in attrs: - type =3D attrs["type"] - else: - type =3D None - - if "shr" in attrs: - shr =3D int(attrs["shr"], 0) - else: - shr =3D 0 - - b =3D Field(name, low, high, shr, type, self) - - if type =3D=3D "fixed" or type =3D=3D "ufixed": - b.radix =3D int(attrs["radix"], 0) - - self.current_bitset.fields.append(b) - except ValueError as e: - raise self.error(e) - - def parse_varset(self, attrs): - # Inherit the varset from the enclosing domain if not overriden: - varset =3D self.current_varset - if "varset" in attrs: - varset =3D self.enums[attrs["varset"]] - return varset - - def parse_variants(self, attrs): - if "variants" not in attrs: - return None - - variant =3D attrs["variants"].split(",")[0] - varset =3D self.parse_varset(attrs) - - if "-" in variant: - # if we have a range, validate that both the start and end - # of the range are valid enums: - start =3D variant[:variant.index("-")] - end =3D variant[variant.index("-") + 1:] - assert varset.has_name(start) - if end !=3D "": - assert varset.has_name(end) - else: - assert varset.has_name(variant) - - return variant - - def add_all_variants(self, reg, attrs, parent_variant): - # TODO this should really handle *all* variants, including dealing - # with open ended ranges (ie. "A2XX,A4XX-") (we have the varset - # enum now to make that possible) - variant =3D self.parse_variants(attrs) - if not variant: - variant =3D parent_variant - - if reg.name not in self.variant_regs: - self.variant_regs[reg.name] =3D {} - else: - # All variants must be same size: - v =3D next(iter(self.variant_regs[reg.name])) - assert self.variant_regs[reg.name][v].bit_size =3D=3D reg.bit_size - - self.variant_regs[reg.name][variant] =3D reg - - def add_all_usages(self, reg, usages): - if not usages: - return - - for usage in usages: - self.usage_regs[usage].append(reg) - - self.variants.add(reg.domain) - - def do_validate(self, schemafile): - if not self.validate: - return - - try: - from lxml import etree - - parser, filename =3D self.stack[-1] - dirname =3D os.path.dirname(filename) - - # we expect this to look like schema.xsd.. I think - # technically it is supposed to be just a URL, but that doesn't - # quite match up to what we do.. Just skip over everything up to - # and including the first whitespace character: - schemafile =3D schemafile[schemafile.rindex(" ")+1:] - - # this is a bit cheezy, but the xml file to validate could be - # in a child director, ie. we don't really know where the schema - # file is, the way the rnn C code does. So if it doesn't exist - # just look one level up - if not os.path.exists(dirname + "/" + schemafile): - schemafile =3D "../" + schemafile - - if not os.path.exists(dirname + "/" + schemafile): - raise self.error("Cannot find schema for: " + filename) - - xmlschema_doc =3D etree.parse(dirname + "/" + schemafile) - xmlschema =3D etree.XMLSchema(xmlschema_doc) - - xml_doc =3D etree.parse(filename) - if not xmlschema.validate(xml_doc): - error_str =3D str(xmlschema.error_log.filter_from_errors()[0]) - raise self.error("Schema validation failed for: " + filename + "\n" + = error_str) - except ImportError as e: - print("lxml not found, skipping validation", file=3Dsys.stderr) - - def do_parse(self, filename): - filepath =3D os.path.abspath(filename) - if filepath in self.xml_files: - return - self.xml_files.append(filepath) - file =3D open(filename, "rb") - parser =3D xml.parsers.expat.ParserCreate() - self.stack.append((parser, filename)) - parser.StartElementHandler =3D self.start_element - parser.EndElementHandler =3D self.end_element - parser.CharacterDataHandler =3D self.character_data - parser.buffer_text =3D True - parser.ParseFile(file) - self.stack.pop() - file.close() - - def parse(self, rnn_path, filename, validate): - self.path =3D rnn_path - self.stack =3D [] - self.validate =3D validate - self.do_parse(filename) - - def parse_reg(self, attrs, bit_size): - self.current_bitsize =3D bit_size - if "type" in attrs and attrs["type"] in self.bitsets: - bitset =3D self.bitsets[attrs["type"]] - if bitset.inline: - self.current_bitset =3D Bitset(attrs["name"], bitset) - self.current_bitset.inline =3D True - else: - self.current_bitset =3D bitset - else: - self.current_bitset =3D Bitset(attrs["name"], None) - self.current_bitset.inline =3D True - if "type" in attrs: - self.parse_field(None, attrs) - - variant =3D self.parse_variants(attrs) - if not variant and self.current_array: - variant =3D self.current_array.variant - - self.current_reg =3D Reg(attrs, self.prefix(variant), self.current_array= , bit_size) - self.current_reg.bitset =3D self.current_bitset - self.current_bitset.reg =3D self.current_reg - - if len(self.stack) =3D=3D 1: - self.file.append(self.current_reg) - - if variant is not None: - self.add_all_variants(self.current_reg, attrs, variant) - - usages =3D None - if "usage" in attrs: - usages =3D attrs["usage"].split(',') - elif self.current_array: - usages =3D self.current_array.usages - - self.add_all_usages(self.current_reg, usages) - - def start_element(self, name, attrs): - self.cdata =3D "" - if name =3D=3D "import": - filename =3D attrs["file"] - self.do_parse(os.path.join(self.path, filename)) - elif name =3D=3D "domain": - self.current_domain =3D attrs["name"] - if "prefix" in attrs: - self.current_prefix =3D sanitize_variant(self.parse_variants(attrs)) - self.current_prefix_type =3D attrs["prefix"] - else: - self.current_prefix =3D None - self.current_prefix_type =3D None - if "varset" in attrs: - self.current_varset =3D self.enums[attrs["varset"]] - elif name =3D=3D "stripe": - self.current_stripe =3D sanitize_variant(self.parse_variants(attrs)) - elif name =3D=3D "enum": - self.current_enum_value =3D 0 - self.current_enum =3D Enum(attrs["name"]) - self.enums[attrs["name"]] =3D self.current_enum - if len(self.stack) =3D=3D 1: - self.file.append(self.current_enum) - elif name =3D=3D "value": - if "value" in attrs: - value =3D int(attrs["value"], 0) - else: - value =3D self.current_enum_value - self.current_enum.values.append((attrs["name"], value)) - elif name =3D=3D "reg32": - self.parse_reg(attrs, 32) - elif name =3D=3D "reg64": - self.parse_reg(attrs, 64) - elif name =3D=3D "array": - self.current_bitsize =3D 32 - variant =3D self.parse_variants(attrs) - index_type =3D self.enums[attrs["index"]] if "index" in attrs else None - self.current_array =3D Array(attrs, self.prefix(variant), variant, self= .current_array, index_type) - if len(self.stack) =3D=3D 1: - self.file.append(self.current_array) - elif name =3D=3D "bitset": - self.current_bitset =3D Bitset(attrs["name"], None) - if "inline" in attrs and attrs["inline"] =3D=3D "yes": - self.current_bitset.inline =3D True - self.bitsets[self.current_bitset.name] =3D self.current_bitset - if len(self.stack) =3D=3D 1 and not self.current_bitset.inline: - self.file.append(self.current_bitset) - elif name =3D=3D "bitfield" and self.current_bitset: - self.parse_field(attrs["name"], attrs) - elif name =3D=3D "database": - self.do_validate(attrs["xsi:schemaLocation"]) - - def end_element(self, name): - if name =3D=3D "domain": - self.current_domain =3D None - self.current_prefix =3D None - self.current_prefix_type =3D None - elif name =3D=3D "stripe": - self.current_stripe =3D None - elif name =3D=3D "bitset": - self.current_bitset =3D None - elif name =3D=3D "reg32": - self.current_reg =3D None - elif name =3D=3D "array": - # if the array has no Reg children, push an implicit reg32: - if len(self.current_array.children) =3D=3D 0: - attrs =3D { - "name": "REG", - "offset": "0", - } - self.parse_reg(attrs, 32) - self.current_array =3D self.current_array.parent - elif name =3D=3D "enum": - self.current_enum =3D None - - def character_data(self, data): - self.cdata +=3D data - - def dump_reg_usages(self): - d =3D collections.defaultdict(list) - for usage, regs in self.usage_regs.items(): - for reg in regs: - variants =3D self.variant_regs.get(reg.name) - if variants: - for variant, vreg in variants.items(): - if reg =3D=3D vreg: - d[(usage, sanitize_variant(variant))].append(reg) - else: - for variant in self.variants: - d[(usage, sanitize_variant(variant))].append(reg) - - print("#ifdef __cplusplus") - - for usage, regs in self.usage_regs.items(): - print("template constexpr inline uint16_t %s_REGS[] =3D {};"= % (usage.upper())) - - for (usage, variant), regs in d.items(): - offsets =3D [] - - for reg in regs: - if reg.array: - for i in range(reg.array.length): - offsets.append(reg.array.offset + reg.offset + i * reg.array.stride) - if reg.bit_size =3D=3D 64: - offsets.append(offsets[-1] + 1) - else: - offsets.append(reg.offset) - if reg.bit_size =3D=3D 64: - offsets.append(offsets[-1] + 1) - - offsets.sort() - - print("template<> constexpr inline uint16_t %s_REGS<%s>[] =3D {" % (usa= ge.upper(), variant)) - for offset in offsets: - print("\t%s," % hex(offset)) - print("};") - - print("#endif") - - def has_variants(self, reg): - return reg.name in self.variant_regs and not is_number(reg.name) and not= is_number(reg.name[1:]) - - def dump(self): - enums =3D [] - bitsets =3D [] - regs =3D [] - for e in self.file: - if isinstance(e, Enum): - enums.append(e) - elif isinstance(e, Bitset): - bitsets.append(e) - else: - regs.append(e) - - for e in enums + bitsets + regs: - e.dump(self.has_variants(e)) - - self.dump_reg_usages() - - - def dump_regs_py(self): - regs =3D [] - for e in self.file: - if isinstance(e, Reg): - regs.append(e) - - for e in regs: - e.dump_py() - - - def dump_reg_variants(self, regname, variants): - if is_number(regname) or is_number(regname[1:]): - return - print("#ifdef __cplusplus") - print("struct __%s {" % regname) - # TODO be more clever.. we should probably figure out which - # fields have the same type in all variants (in which they - # appear) and stuff everything else in a variant specific - # sub-structure. - seen_fields =3D [] - bit_size =3D 32 - array =3D False - address =3D None - for variant in variants.keys(): - print(" /* %s fields: */" % variant) - reg =3D variants[variant] - bit_size =3D reg.bit_size - array =3D reg.array - for f in reg.bitset.fields: - fld_name =3D field_name(reg, f) - if fld_name in seen_fields: - continue - seen_fields.append(fld_name) - name =3D fld_name.lower() - if f.type in [ "address", "waddress" ]: - if address: - continue - address =3D f - tab_to(" __bo_type", "bo;") - tab_to(" uint32_t", "bo_offset;") - continue - type, val =3D f.ctype("var") - tab_to(" %s" %type, "%s;" %name) - print(" /* fallback fields: */") - if bit_size =3D=3D 64: - tab_to(" uint64_t", "unknown;") - tab_to(" uint64_t", "qword;") - else: - tab_to(" uint32_t", "unknown;") - tab_to(" uint32_t", "dword;") - print("};") - # TODO don't hardcode the varset enum name - varenum =3D "chip" - print("template <%s %s>" % (varenum, varenum.upper())) - print("static inline struct fd_reg_pair") - xtra =3D "" - xtravar =3D "" - if array: - xtra =3D "int __i, " - xtravar =3D "__i, " - print("__%s(%sstruct __%s fields) {" % (regname, xtra, regname)) - for variant in variants.keys(): - if "-" in variant: - start =3D variant[:variant.index("-")] - end =3D variant[variant.index("-") + 1:] - if end !=3D "": - print(" if ((%s >=3D %s) && (%s <=3D %s)) {" % (varenum.upper(), sta= rt, varenum.upper(), end)) - else: - print(" if (%s >=3D %s) {" % (varenum.upper(), start)) - else: - print(" if (%s =3D=3D %s) {" % (varenum.upper(), variant)) - reg =3D variants[variant] - reg.dump_regpair_builder() - print(" } else") - print(" assert(!\"invalid variant\");") - print(" return (struct fd_reg_pair){};") - print("}") - - if bit_size =3D=3D 64: - skip =3D ", { .reg =3D 0 }" - else: - skip =3D "" - - print("#define %s(VARIANT, %s...) __%s(%s{__VA_ARGS__})%s" % (r= egname, xtravar, regname, xtravar, skip)) - print("#endif /* __cplusplus */") - - def dump_structs(self): - for e in self.file: - e.dump_pack_struct(self.has_variants(e)) - - for regname in self.variant_regs: - self.dump_reg_variants(regname, self.variant_regs[regname]) + def __init__(self): + self.current_array =3D None + self.current_domain =3D None + self.current_prefix =3D None + self.current_prefix_type =3D None + self.current_stripe =3D None + self.current_bitset =3D None + self.current_bitsize =3D 32 + # The varset attribute on the domain specifies the enum which + # specifies all possible hw variants: + self.current_varset =3D None + # Regs that have multiple variants.. we only generated the C++ + # template based struct-packers for these + self.variant_regs =3D {} + # Information in which contexts regs are used, to be used in + # debug options + self.usage_regs =3D collections.defaultdict(list) + self.bitsets =3D {} + self.enums =3D {} + self.variants =3D set() + self.file =3D [] + self.xml_files =3D [] + + def error(self, message): + parser, filename =3D self.stack[-1] + return Error("%s:%d:%d: %s" % (filename, parser.CurrentLineNumber,= parser.CurrentColumnNumber, message)) + + def prefix(self, variant=3DNone): + if self.current_prefix_type =3D=3D "variant" and variant: + return sanitize_variant(variant) + elif self.current_stripe: + return self.current_stripe + "_" + self.current_domain + elif self.current_prefix: + return self.current_prefix + "_" + self.current_domain + else: + return self.current_domain + + def parse_field(self, name, attrs): + try: + if "pos" in attrs: + high =3D low =3D int(attrs["pos"], 0) + elif "high" in attrs and "low" in attrs: + high =3D int(attrs["high"], 0) + low =3D int(attrs["low"], 0) + else: + low =3D 0 + high =3D self.current_bitsize - 1 + + if "type" in attrs: + type =3D attrs["type"] + else: + type =3D None + + if "shr" in attrs: + shr =3D int(attrs["shr"], 0) + else: + shr =3D 0 + + b =3D Field(name, low, high, shr, type, self) + + if type =3D=3D "fixed" or type =3D=3D "ufixed": + b.radix =3D int(attrs["radix"], 0) + + self.current_bitset.fields.append(b) + except ValueError as e: + raise self.error(e) + + def parse_varset(self, attrs): + # Inherit the varset from the enclosing domain if not overriden: + varset =3D self.current_varset + if "varset" in attrs: + varset =3D self.enums[attrs["varset"]] + return varset + + def parse_variants(self, attrs): + if "variants" not in attrs: + return None + + variant =3D attrs["variants"].split(",")[0] + varset =3D self.parse_varset(attrs) + + if "-" in variant: + # if we have a range, validate that both the start and end + # of the range are valid enums: + start =3D variant[:variant.index("-")] + end =3D variant[variant.index("-") + 1:] + assert varset.has_name(start) + if end !=3D "": + assert varset.has_name(end) + else: + assert varset.has_name(variant) + + return variant + + def add_all_variants(self, reg, attrs, parent_variant): + # TODO this should really handle *all* variants, including dealing + # with open ended ranges (ie. "A2XX,A4XX-") (we have the varset + # enum now to make that possible) + variant =3D self.parse_variants(attrs) + if not variant: + variant =3D parent_variant + + if reg.name not in self.variant_regs: + self.variant_regs[reg.name] =3D {} + else: + # All variants must be same size: + v =3D next(iter(self.variant_regs[reg.name])) + assert self.variant_regs[reg.name][v].bit_size =3D=3D reg.bit_= size + + self.variant_regs[reg.name][variant] =3D reg + + def add_all_usages(self, reg, usages): + if not usages: + return + + for usage in usages: + self.usage_regs[usage].append(reg) + + self.variants.add(reg.domain) + + def do_validate(self, schemafile): + if not self.validate: + return + + try: + from lxml import etree + + parser, filename =3D self.stack[-1] + dirname =3D os.path.dirname(filename) + + # we expect this to look like schema.xsd.. I t= hink + # technically it is supposed to be just a URL, but that doesn't + # quite match up to what we do.. Just skip over everything up = to + # and including the first whitespace character: + schemafile =3D schemafile[schemafile.rindex(" ")+1:] + + # this is a bit cheezy, but the xml file to validate could be + # in a child director, ie. we don't really know where the sche= ma + # file is, the way the rnn C code does. So if it doesn't exist + # just look one level up + if not os.path.exists(dirname + "/" + schemafile): + schemafile =3D "../" + schemafile + + if not os.path.exists(dirname + "/" + schemafile): + raise self.error("Cannot find schema for: " + filename) + + xmlschema_doc =3D etree.parse(dirname + "/" + schemafile) + xmlschema =3D etree.XMLSchema(xmlschema_doc) + + xml_doc =3D etree.parse(filename) + if not xmlschema.validate(xml_doc): + error_str =3D str(xmlschema.error_log.filter_from_errors()= [0]) + raise self.error( + "Schema validation failed for: " + filename + "\n" + e= rror_str) + except ImportError as e: + print("lxml not found, skipping validation", file=3Dsys.stderr) + + def do_parse(self, filename): + filepath =3D os.path.abspath(filename) + if filepath in self.xml_files: + return + self.xml_files.append(filepath) + file =3D open(filename, "rb") + parser =3D xml.parsers.expat.ParserCreate() + self.stack.append((parser, filename)) + parser.StartElementHandler =3D self.start_element + parser.EndElementHandler =3D self.end_element + parser.CharacterDataHandler =3D self.character_data + parser.buffer_text =3D True + parser.ParseFile(file) + self.stack.pop() + file.close() + + def parse(self, rnn_path, filename, validate): + self.path =3D rnn_path + self.stack =3D [] + self.validate =3D validate + self.do_parse(filename) + + def parse_reg(self, attrs, bit_size): + self.current_bitsize =3D bit_size + if "type" in attrs and attrs["type"] in self.bitsets: + bitset =3D self.bitsets[attrs["type"]] + if bitset.inline: + self.current_bitset =3D Bitset(attrs["name"], bitset) + self.current_bitset.inline =3D True + else: + self.current_bitset =3D bitset + else: + self.current_bitset =3D Bitset(attrs["name"], None) + self.current_bitset.inline =3D True + if "type" in attrs: + self.parse_field(None, attrs) + + variant =3D self.parse_variants(attrs) + if not variant and self.current_array: + variant =3D self.current_array.variant + + self.current_reg =3D Reg(attrs, self.prefix( + variant), self.current_array, bit_size) + self.current_reg.bitset =3D self.current_bitset + self.current_bitset.reg =3D self.current_reg + + if len(self.stack) =3D=3D 1: + self.file.append(self.current_reg) + + if variant is not None: + self.add_all_variants(self.current_reg, attrs, variant) + + usages =3D None + if "usage" in attrs: + usages =3D attrs["usage"].split(',') + elif self.current_array: + usages =3D self.current_array.usages + + self.add_all_usages(self.current_reg, usages) + + def start_element(self, name, attrs): + self.cdata =3D "" + if name =3D=3D "import": + filename =3D attrs["file"] + self.do_parse(os.path.join(self.path, filename)) + elif name =3D=3D "domain": + self.current_domain =3D attrs["name"] + if "prefix" in attrs: + self.current_prefix =3D sanitize_variant( + self.parse_variants(attrs)) + self.current_prefix_type =3D attrs["prefix"] + else: + self.current_prefix =3D None + self.current_prefix_type =3D None + if "varset" in attrs: + self.current_varset =3D self.enums[attrs["varset"]] + elif name =3D=3D "stripe": + self.current_stripe =3D sanitize_variant(self.parse_variants(a= ttrs)) + elif name =3D=3D "enum": + self.current_enum_value =3D 0 + self.current_enum =3D Enum(attrs["name"]) + self.enums[attrs["name"]] =3D self.current_enum + if len(self.stack) =3D=3D 1: + self.file.append(self.current_enum) + elif name =3D=3D "value": + if "value" in attrs: + value =3D int(attrs["value"], 0) + else: + value =3D self.current_enum_value + self.current_enum.values.append((attrs["name"], value)) + elif name =3D=3D "reg32": + self.parse_reg(attrs, 32) + elif name =3D=3D "reg64": + self.parse_reg(attrs, 64) + elif name =3D=3D "array": + self.current_bitsize =3D 32 + variant =3D self.parse_variants(attrs) + index_type =3D self.enums[attrs["index"] + ] if "index" in attrs else None + self.current_array =3D Array(attrs, self.prefix( + variant), variant, self.current_array, index_type) + if len(self.stack) =3D=3D 1: + self.file.append(self.current_array) + elif name =3D=3D "bitset": + self.current_bitset =3D Bitset(attrs["name"], None) + if "inline" in attrs and attrs["inline"] =3D=3D "yes": + self.current_bitset.inline =3D True + self.bitsets[self.current_bitset.name] =3D self.current_bitset + if len(self.stack) =3D=3D 1 and not self.current_bitset.inline: + self.file.append(self.current_bitset) + elif name =3D=3D "bitfield" and self.current_bitset: + self.parse_field(attrs["name"], attrs) + elif name =3D=3D "database": + self.do_validate(attrs["xsi:schemaLocation"]) + + def end_element(self, name): + if name =3D=3D "domain": + self.current_domain =3D None + self.current_prefix =3D None + self.current_prefix_type =3D None + elif name =3D=3D "stripe": + self.current_stripe =3D None + elif name =3D=3D "bitset": + self.current_bitset =3D None + elif name =3D=3D "reg32": + self.current_reg =3D None + elif name =3D=3D "array": + # if the array has no Reg children, push an implicit reg32: + if len(self.current_array.children) =3D=3D 0: + attrs =3D { + "name": "REG", + "offset": "0", + } + self.parse_reg(attrs, 32) + self.current_array =3D self.current_array.parent + elif name =3D=3D "enum": + self.current_enum =3D None + + def character_data(self, data): + self.cdata +=3D data + + def dump_reg_usages(self): + d =3D collections.defaultdict(list) + for usage, regs in self.usage_regs.items(): + for reg in regs: + variants =3D self.variant_regs.get(reg.name) + if variants: + for variant, vreg in variants.items(): + if reg =3D=3D vreg: + d[(usage, sanitize_variant(variant))].append(r= eg) + else: + for variant in self.variants: + d[(usage, sanitize_variant(variant))].append(reg) + + print("#ifdef __cplusplus") + + for usage, regs in self.usage_regs.items(): + print("template constexpr inline uint16_t %s_REGS[]= =3D {};" % ( + usage.upper())) + + for (usage, variant), regs in d.items(): + offsets =3D [] + + for reg in regs: + if reg.array: + for i in range(reg.array.length): + offsets.append(reg.array.offset + + reg.offset + i * reg.array.stride) + if reg.bit_size =3D=3D 64: + offsets.append(offsets[-1] + 1) + else: + offsets.append(reg.offset) + if reg.bit_size =3D=3D 64: + offsets.append(offsets[-1] + 1) + + offsets.sort() + + print("template<> constexpr inline uint16_t %s_REGS<%s>[] =3D = {" % ( + usage.upper(), variant)) + for offset in offsets: + print("\t%s," % hex(offset)) + print("};") + + print("#endif") + + def has_variants(self, reg): + return reg.name in self.variant_regs and not is_number(reg.name) a= nd not is_number(reg.name[1:]) + + def dump(self): + enums =3D [] + bitsets =3D [] + regs =3D [] + for e in self.file: + if isinstance(e, Enum): + enums.append(e) + elif isinstance(e, Bitset): + bitsets.append(e) + else: + regs.append(e) + + for e in enums + bitsets + regs: + e.dump(self.has_variants(e)) + + self.dump_reg_usages() + + def dump_regs_py(self): + regs =3D [] + for e in self.file: + if isinstance(e, Reg): + regs.append(e) + + for e in regs: + e.dump_py() + + def dump_reg_variants(self, regname, variants): + if is_number(regname) or is_number(regname[1:]): + return + print("#ifdef __cplusplus") + print("struct __%s {" % regname) + # TODO be more clever.. we should probably figure out which + # fields have the same type in all variants (in which they + # appear) and stuff everything else in a variant specific + # sub-structure. + seen_fields =3D [] + bit_size =3D 32 + array =3D False + address =3D None + constexpr_mark =3D " CONSTEXPR" + for variant in variants.keys(): + print(" /* %s fields: */" % variant) + reg =3D variants[variant] + bit_size =3D reg.bit_size + array =3D reg.array + for f in reg.bitset.fields: + fld_name =3D field_name(reg, f) + if fld_name in seen_fields: + continue + seen_fields.append(fld_name) + name =3D fld_name.lower() + if f.type in ["address", "waddress"]: + if address: + continue + address =3D f + print("#ifndef TU_CS_H") + tab_to(" __bo_type", "bo;") + tab_to(" uint32_t", "bo_offset;") + print("#endif") + continue + type, val =3D f.ctype("var") + tab_to(" %s" % type, "%s;" % name) + if f.type =3D=3D "float": + constexpr_mark =3D "" + print(" /* fallback fields: */") + if bit_size =3D=3D 64: + tab_to(" uint64_t", "unknown;") + tab_to(" uint64_t", "qword;") + else: + tab_to(" uint32_t", "unknown;") + tab_to(" uint32_t", "dword;") + print("};") + # TODO don't hardcode the varset enum name + varenum =3D "chip" + print("template <%s %s>" % (varenum, varenum.upper())) + print("static%s inline struct fd_reg_pair" % (constexpr_mark)) + xtra =3D "" + xtravar =3D "" + if array: + xtra =3D "int __i, " + xtravar =3D "__i, " + print("__%s(%sstruct __%s fields) {" % (regname, xtra, regname)) + for variant in variants.keys(): + if "-" in variant: + start =3D variant[:variant.index("-")] + end =3D variant[variant.index("-") + 1:] + if end !=3D "": + print(" if ((%s >=3D %s) && (%s <=3D %s)) {" % ( + varenum.upper(), start, varenum.upper(), end)) + else: + print(" if (%s >=3D %s) {" % (varenum.upper(), start)) + else: + print(" if (%s =3D=3D %s) {" % (varenum.upper(), variant)) + reg =3D variants[variant] + reg.dump_regpair_builder() + print(" } else") + print(" assert(!\"invalid variant\");") + print(" return (struct fd_reg_pair){};") + print("}") + + if bit_size =3D=3D 64: + skip =3D ", { .reg =3D 0 }" + else: + skip =3D "" + + print("#define %s(VARIANT, %s...) __%s(%s{__VA_ARGS__})%s= " % ( + regname, xtravar, regname, xtravar, skip)) + print("#endif /* __cplusplus */") + + def dump_structs(self): + for e in self.file: + e.dump_pack_struct(self.has_variants(e)) + + for regname in self.variant_regs: + self.dump_reg_variants(regname, self.variant_regs[regname]) =20 =20 def dump_c(args, guard, func): - p =3D Parser() - - try: - p.parse(args.rnn, args.xml, args.validate) - except Error as e: - print(e, file=3Dsys.stderr) - exit(1) - - print("#ifndef %s\n#define %s\n" % (guard, guard)) - - print("/* Autogenerated file, DO NOT EDIT manually! */") - - print() - print("#ifdef __KERNEL__") - print("#include ") - print("#define assert(x) BUG_ON(!(x))") - print("#else") - print("#include ") - print("#endif") - print() - - print("#ifdef __cplusplus") - print("#define __struct_cast(X)") - print("#else") - print("#define __struct_cast(X) (struct X)") - print("#endif") - print() - - print("#ifndef FD_NO_DEPRECATED_PACK") - print("#define FD_DEPRECATED __attribute__((deprecated))") - print("#else") - print("#define FD_DEPRECATED") - print("#endif") - print() - - func(p) - - print() - print("#undef FD_DEPRECATED") - print() - - print("#endif /* %s */" % guard) + p =3D Parser() + + try: + p.parse(args.rnn, args.xml, args.validate) + except Error as e: + print(e, file=3Dsys.stderr) + exit(1) + + print("#ifndef %s\n#define %s\n" % (guard, guard)) + + print("/* Autogenerated file, DO NOT EDIT manually! */") + + print() + print("#ifdef __KERNEL__") + print("#include ") + print("#define assert(x) BUG_ON(!(x))") + print("#else") + print("#include ") + print("#endif") + print() + + print("#ifdef __cplusplus") + print("#define __struct_cast(X)") + print("#define CONSTEXPR constexpr") + print("#else") + print("#define __struct_cast(X) (struct X)") + print("#define CONSTEXPR") + print("#endif") + print() + + # TODO figure out what to do about fd_reg_stomp_allowed() + # vs gcc.. for now only enable the warnings with clang: + print("#if defined(__clang__) && !defined(FD_NO_DEPRECATED_PACK)") + print("#define __FD_DEPRECATED _Pragma (\"GCC warning \\\"Deprecated r= eg builder\\\"\")") + print("#else") + print("#define __FD_DEPRECATED") + print("#endif") + print() + + func(p) + + print("#endif /* %s */" % guard) =20 =20 def dump_c_defines(args): - guard =3D str.replace(os.path.basename(args.xml), '.', '_').upper() - dump_c(args, guard, lambda p: p.dump()) + guard =3D str.replace(os.path.basename(args.xml), '.', '_').upper() + dump_c(args, guard, lambda p: p.dump()) =20 =20 def dump_c_pack_structs(args): - guard =3D str.replace(os.path.basename(args.xml), '.', '_').upper() + '_S= TRUCTS' - dump_c(args, guard, lambda p: p.dump_structs()) - + guard =3D str.replace(os.path.basename(args.xml), + '.', '_').upper() + '_STRUCTS' + dump_c(args, guard, lambda p: p.dump_structs()) + + +def dump_perfcntrs(args): + p =3D Parser() + + try: + p.parse(args.rnn, args.xml, args.validate) + except Error as e: + print(e, file=3Dsys.stderr) + exit(1) + + perfcntrs =3D json.load(open(args.json, "r", encoding=3D"utf-8")) + + chip_type =3D p.enums['chip'] + chip =3D perfcntrs['chip'] + if not chip_type.has_name(chip): + raise Error("Invalid chip: " + chip) + + groups =3D perfcntrs['groups'] + + guard =3D "__" + chip + "_PERFCNTRS_" + print("#ifndef %s\n#define %s\n" % (guard, guard)) + print("/* Autogenerated file, DO NOT EDIT manually! */") + print() + print("#ifdef __KERNEL__") + print("#include \"msm_perfcntr.h\"") + print("#endif") + print() + + def has_variant(variant): + if variant is None: + return True + if "-" in variant: + start =3D chip_type.value(variant[:variant.index("-")]) + end =3D chip_type.value(variant[variant.index("-") + 1:]) + chipn =3D chip_type.value(chip) + + return (start is None or chipn >=3D start) and (end is None or= chipn <=3D end) + return chip =3D=3D variant + + # Split out arrays and regs for later access: + arrays =3D {} + regs =3D {} + for e in p.file: + if isinstance(e, Array) and has_variant(e.variant): + arrays[e.local_name] =3D e + if isinstance(e, Reg): + regs[e.name] =3D e + + # For variant regs, overwrite 'regs' entries with correct variant: + for regname in p.variant_regs: + for (variant, reg) in p.variant_regs[regname].items(): + if has_variant(variant): + regs[regname] =3D reg + break + + for group in groups: + name =3D group['name'] + name_low =3D name.lower() + num =3D group['num'] + countable_type_name =3D group['countable_type'] + + if not countable_type_name in p.enums: + raise Error("Invalid type: " + countable_type_name) + + countable_type =3D p.enums[countable_type_name] + + print("#ifndef __KERNEL__") + print("static const struct fd_perfcntr_countable " + name_low + "_= countables[] =3D {") + for (name, value) in countable_type.values: + # if the countable is prefixed with the chip, strip that: + # (note: avoid py3.9 dependency for kernel) + if name.startswith(chip + "_"): + name =3D name[len(chip)+1:] + print(" { \"" + name + "\", " + str(value) + " },") + print("};") + print("#endif") + + print("static const struct fd_perfcntr_counter " + name_low + "_co= unters[] =3D {") + for i in range(0, num): + if "reserved" in group and i in group["reserved"]: + continue + def get_reg(name): + # if reg has {} pattern, expand that first: + name =3D name.format(i) + + if name in arrays: + arr =3D arrays[name] + return arr.offset + (i * arr.stride) + + if not name in regs: + raise Error("Invalid reg: " + name) + + reg =3D regs[name] + return reg.offset + + def get_counter(): + # if the counter is just a single "counter" value + # should be specified in the json, but for legacy separate + # hi/lo pairs "counter_lo" and "counter_hi" should + # be specified + if "counter" in group: + counter =3D get_reg(group["counter"]) + return [counter, counter+1] + counter_lo =3D get_reg(group["counter_lo"]) + counter_hi =3D get_reg(group["counter_hi"]) + return [counter_lo, counter_hi] + + (counter_lo, counter_hi) =3D get_counter() + select =3D get_reg(group['select']) + + select_offset =3D 0 + if "select_offset" in group: + select_offset =3D int(group["select_offset"]) + select =3D select + select_offset + + slice_select_str =3D "" + if "slice_select" in group: + slice_select =3D group["slice_select"] + for reg in slice_select: + val =3D get_reg(reg) + select_offset + slice_select_str +=3D "0x%04x, " % val + + # TODO add support for things that need enable/clear regs + + print(" { 0x%04x, {%s}, 0x%04x, 0x%04x }," % (select, slice_= select_str, counter_lo, counter_hi)) + print("};") + + print() + + print("const struct fd_perfcntr_group " + chip.lower() + "_perfcntr_gr= oups[] =3D {") + for group in groups: + name =3D group['name'] + name_low =3D name.lower() + pipe =3D 'NONE' + if 'pipe' in group: + pipe =3D group['pipe'] + + print(" GROUP(\"%s\", PIPE_%s, %s_counters, %s_countables)," % (= name, pipe, name_low, name_low)) + + print("};") + print("const unsigned " + chip.lower() + "_num_perfcntr_groups =3D ARR= AY_SIZE(" + chip.lower() + "_perfcntr_groups);") + + print() + print("#endif /* %s */" % guard) =20 def dump_py_defines(args): - p =3D Parser() + p =3D Parser() =20 - try: - p.parse(args.rnn, args.xml, args.validate) - except Error as e: - print(e, file=3Dsys.stderr) - exit(1) + try: + p.parse(args.rnn, args.xml, args.validate) + except Error as e: + print(e, file=3Dsys.stderr) + exit(1) =20 - file_name =3D os.path.splitext(os.path.basename(args.xml))[0] + file_name =3D os.path.splitext(os.path.basename(args.xml))[0] =20 - print("from enum import IntEnum") - print("class %sRegs(IntEnum):" % file_name.upper()) + print("from enum import IntEnum") + print("class %sRegs(IntEnum):" % file_name.upper()) =20 - os.path.basename(args.xml) + os.path.basename(args.xml) =20 - p.dump_regs_py() + p.dump_regs_py() =20 =20 def main(): - parser =3D argparse.ArgumentParser() - parser.add_argument('--rnn', type=3Dstr, required=3DTrue) - parser.add_argument('--xml', type=3Dstr, required=3DTrue) - parser.add_argument('--validate', default=3DFalse, action=3D'store_true') - parser.add_argument('--no-validate', dest=3D'validate', action=3D'store_f= alse') + parser =3D argparse.ArgumentParser() + parser.add_argument('--rnn', type=3Dstr, required=3DTrue) + parser.add_argument('--xml', type=3Dstr, required=3DTrue) + parser.add_argument('--validate', default=3DFalse, action=3D'store_tru= e') + parser.add_argument('--no-validate', dest=3D'validate', action=3D'stor= e_false') + + subparsers =3D parser.add_subparsers() + subparsers.required =3D True =20 - subparsers =3D parser.add_subparsers() - subparsers.required =3D True + parser_c_defines =3D subparsers.add_parser('c-defines') + parser_c_defines.set_defaults(func=3Ddump_c_defines) =20 - parser_c_defines =3D subparsers.add_parser('c-defines') - parser_c_defines.set_defaults(func=3Ddump_c_defines) + parser_c_pack_structs =3D subparsers.add_parser('c-pack-structs') + parser_c_pack_structs.set_defaults(func=3Ddump_c_pack_structs) =20 - parser_c_pack_structs =3D subparsers.add_parser('c-pack-structs') - parser_c_pack_structs.set_defaults(func=3Ddump_c_pack_structs) + parser_perfcntrs =3D subparsers.add_parser('perfcntrs') + parser_perfcntrs.add_argument('--json', type=3Dstr, required=3DTrue) + parser_perfcntrs.set_defaults(func=3Ddump_perfcntrs) =20 - parser_py_defines =3D subparsers.add_parser('py-defines') - parser_py_defines.set_defaults(func=3Ddump_py_defines) + parser_py_defines =3D subparsers.add_parser('py-defines') + parser_py_defines.set_defaults(func=3Ddump_py_defines) =20 - args =3D parser.parse_args() - args.func(args) + args =3D parser.parse_args() + args.func(args) =20 =20 if __name__ =3D=3D '__main__': - main() + main() --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E21B83EE1F2 for ; Mon, 4 May 2026 19:08:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921716; cv=none; b=hSRGYSIOiavvKpRYI8bvnr91mjidwRKZG/BYvmyG16rvFd1B3sirETO7d2eTBYzY/RfRqsf4IEh4WHzZ6uo5dTyk86QC7RU7+FTkFlsH+pqClMJY5Dq8QJcwS0jSyacSLGh2CZAacLbue1QDiV9valx+WBDHbXaQ4PrZ1prH0K8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921716; c=relaxed/simple; bh=uljmUnXA7Y0xQMcrcfleDyA3djTZ+ui1BGVJv3de5bU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o6H4NRaFhIljHmiIJdQISj5cx4JwdGHwSXf3l0Bmx31LGrEBNoPrHLXpaohPADhc8R7nIwAKoMqu8/GljJFoD9V05C+y1LyG9V4refpqB0AAskwcDoRyd91sgD7OagLsaFdgb6Yz40QoXWz1bPrYVjMhmQxTZN6okCmFYdZVGyU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=F4XtVlf3; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=jghC5cUz; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="F4XtVlf3"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="jghC5cUz" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644E2h0S1186892 for ; Mon, 4 May 2026 19:08:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=lyUVMZJ3Hcw ioD6qTZ9vD3HS80KOdNDj9nnD8qGJgTU=; b=F4XtVlf3UqaD4Gwx4V4hCW8EnLV rewi4TEtabH4LMa4AH1P21v4+CpJqmSFWwZJzxzPSaMsn2OzmBM9NLgYdYH/8PrQ mUV70DFIC+3jZFjEjy414kYXqjUw/WY8gjWJ1xioYY06Vi+a+bF5IXMEwZBSaRjR YKYOUu/K64ONwlhviiExnrbjgcDv0mJG7Yv8FC13++CVxi1RgSKTzDuWFWGUgtlD ls152VtmIXC5BCrr/zQIbZE38w7yeaHeo/L521JbaMvOHvD3IE1ekV4EO9b8DJcO gT1iIBmnmdIx71u83ELezDvHTxWFhh1ZY3+dVlQV6QbXQzieSxmdEf3AO4Q== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxvvg97e6-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:31 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2b9f5ac4e36so19685725ad.2 for ; Mon, 04 May 2026 12:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921711; x=1778526511; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lyUVMZJ3HcwioD6qTZ9vD3HS80KOdNDj9nnD8qGJgTU=; b=jghC5cUzi+tJDCyPdUyfai+zvkX5oPq2sPV/nNl4NrmjEvpMbpZGCZIby4aoCIcnlO DCMTr+hqlma4bTdL+bPETFtY1eagRnTppM4OLultS0N4w6BWu+JFiygGwJsEofFnfLQe +gi9IJQpQcpbPJ2KLstzT2ki9TqpegyhMkMVm6AWqcmCCGCsd3A/RRReYoaNiMh9hjkM q5Hkuod+kdPdnm3lxPiou+/+LPAWaPSWXS1Xg6RYNBZ423Ak9D9CzUzPnTO0J+9JmuFn 3skqqZpht7KwNQOe6u7QQqNwkmSAfetrz9yf9lr9xcg16HY7iGzQ/DL7yDiun4U3908P h96Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921711; x=1778526511; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lyUVMZJ3HcwioD6qTZ9vD3HS80KOdNDj9nnD8qGJgTU=; b=QB9xh254558VY1KZ0zKNFkfl27YU0wtE1LvyZHU2+Lg3pJaLeGRrUG0Xo6DRG8S0li tzzATDUYPB33KTzxIHniIfK9/ZRkfnuHy4eZg7W7pQueHJ0Ptss8DRbtH+Q8k71qbao9 nr8bkJm7oYYtpkoK9pXVvU4evk2ncz7PU7270yCogpkhjBxyEC54aT8kiiOLjN3IBEgU fAqecYTZZwSv/4oJXDorAx7wbP7B8UdTjmRK2vX5I87sc8AnDcdJ6VDto1JDNPKErHjX j9nZTrjZgDF5bQE9d/cyT1siIMY+6F8LKSSd67NkdF9sMT+p4hAkm2tNJpbfstrc6U6K QNzQ== X-Forwarded-Encrypted: i=1; AFNElJ8Wo1GqUPMpEyyc48PUSRaDrD0XNHZOTKZyL+GMC+Act0idSQ4jwbH3ZnVyitTY21G+/ZlAvOomUAVCJ3Y=@vger.kernel.org X-Gm-Message-State: AOJu0YxcykskrHwc8xXiuPKkOjHqAoveR3c250mQTtrdofc8xH/a9k76 GD7W8xmlcHr53Svdf17zGft8U228KOSQLcdTaWOIGU0flwvYjdW0Q16F0dcZXLKCttHUu9QXSlv rshN9ZyZkF/fDcWtpKsuJAITJWDeBMJLny1GX77kzNtcmcTPohsM32hXW8DYHrxEXHLk= X-Gm-Gg: AeBDies8HsaXYQ3cOKH6vnSI1AE7h0j8Y93fhnWbASQXGt6QFEyXWe64XmRVP11s5TU Q6D6TT5EgDeK3+VmxBazvuV9hXns/5BWEe4X+xUzPTZ934oiFg98SlKVr213L2AOFsSAmME2519 tsETbu+NGx8Pt35NlfUne6aRk8sgkO6L6nh0OXfZzzosbDb3QdJoMs+wZARpr+GmNQBH+UTjMqK vhZqdXxN/po4gYfvg9ewPzpXioRXlWYA4Nmowc+r1U7R+K2Ah6ZmUwrhW9IZZjZ+qM77UVDQyCe zo065u3zaBMga+caXc+QrNrFgOUVtgVHEpr9DSy0SuQV9KujByUc6my42rDEYs8qD2pIscC4iwS I29PXi++l39ljWukudX1C79xqciRz2wsz0c1x0mk5wsM= X-Received: by 2002:a17:90b:1844:b0:35f:be09:1a2b with SMTP id 98e67ed59e1d1-3650cd4ab28mr10974165a91.10.1777921710164; Mon, 04 May 2026 12:08:30 -0700 (PDT) X-Received: by 2002:a17:90b:1844:b0:35f:be09:1a2b with SMTP id 98e67ed59e1d1-3650cd4ab28mr10974121a91.10.1777921709441; Mon, 04 May 2026 12:08:29 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-364ec00a280sm12267571a91.10.2026.05.04.12.08.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:28 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , David Airlie , Simona Vetter , Konrad Dybcio , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 05/16] drm/msm/registers: Add perfcntr json Date: Mon, 4 May 2026 12:06:48 -0700 Message-ID: <20260504190751.61052-6-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: Q4SNNYF9-TWtyYyov9OtZj4CAUh9hLlk X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfX7P4rcAmHAPL1 ow0AXakAWvw6IvS98iHu1Afl3a/BdFXWqOy/sWj2v4v3z/rZYJaCY1vM5gwT3s/xXLh2MpZiwQp cCmrBT2OIN+qZvoEe3Sqy7v4DvofkQb21pjeixLDJnjtbe+lQMUoiHfM3csCtsbdJXMk6TDfLyB 8oe1w0iIIyUIJh++Mz4I3ixyUwO8kQBosO7FV7S4x98P0qf7qZxuwD94Xr8Dd+sVScnx0GsOgqx gOK9J9U+VG4/YNBwNYAzg5iPo+1bQ/v3qZ3ay7adJbJhHHnQfK77PcPZiPA28rc92iY2SzWGlM1 e6MEGc6FSNXKNMWPB1di7kqu+tvvdEf9mrPrQDjZHwDRfV2a3l9wnABwNulb49mA1NmLgiDtiaA cZAIaf7DHzCqC1959dpiP9Fs5RjZBFIj4H1y2UDobOniK1prpHqlNwPWjQM2bDc0bNAxkMWkB2+ MhJ5OTTtzZFzqPm+Vmw== X-Authority-Analysis: v=2.4 cv=K+AS2SWI c=1 sm=1 tr=0 ts=69f8eeaf cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=e5mUnYsNAAAA:8 a=EUspDBNiAAAA:8 a=U2HPg71ik5UQ_0Zuz_MA:9 a=PDmnkIS-fa9zh8kb:21 a=uG9DUKGECoFWVXl0Dc02:22 a=Vxmtnl_E_bksehYqCbjh:22 X-Proofpoint-GUID: Q4SNNYF9-TWtyYyov9OtZj4CAUh9hLlk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" Pull in perfcntr json and wire up generation of perfcntr tables. Sync from https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40522 Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/Makefile | 25 +- drivers/gpu/drm/msm/msm_perfcntr.h | 48 ++++ .../msm/registers/adreno/a2xx_perfcntrs.json | 109 ++++++++ .../msm/registers/adreno/a5xx_perfcntrs.json | 128 ++++++++++ .../msm/registers/adreno/a6xx_perfcntrs.json | 105 ++++++++ .../msm/registers/adreno/a7xx_perfcntrs.json | 228 +++++++++++++++++ .../msm/registers/adreno/a8xx_perfcntrs.json | 240 ++++++++++++++++++ 7 files changed, 882 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/drm/msm/msm_perfcntr.h create mode 100644 drivers/gpu/drm/msm/registers/adreno/a2xx_perfcntrs.json create mode 100644 drivers/gpu/drm/msm/registers/adreno/a5xx_perfcntrs.json create mode 100644 drivers/gpu/drm/msm/registers/adreno/a6xx_perfcntrs.json create mode 100644 drivers/gpu/drm/msm/registers/adreno/a7xx_perfcntrs.json create mode 100644 drivers/gpu/drm/msm/registers/adreno/a8xx_perfcntrs.json diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile index ce00cfb0a875..337634e7e247 100644 --- a/drivers/gpu/drm/msm/Makefile +++ b/drivers/gpu/drm/msm/Makefile @@ -176,6 +176,11 @@ quiet_cmd_headergen =3D GENHDR $@ cmd_headergen =3D mkdir -p $(obj)/generated && $(PYTHON3) $(src)/reg= isters/gen_header.py \ $(headergen-opts) --rnn $(src)/registers --xml $< c-defines > $@ =20 +# TODO how to do this for a2xx/a5xx which have different .xml arg? +quiet_cmd_headergen_json =3D GENHDRJSN $@ + cmd_headergen_json =3D mkdir -p $(obj)/generated && $(PYTHON3) $(src= )/registers/gen_header.py \ + $(headergen-opts) --rnn $(src)/registers --xml $(filter %.xml,$^) = perfcntrs --json $< > $@ + $(obj)/generated/%.xml.h: $(src)/registers/adreno/%.xml \ $(src)/registers/adreno/adreno_common.xml \ $(src)/registers/adreno/adreno_pm4.xml \ @@ -192,6 +197,24 @@ $(obj)/generated/%.xml.h: $(src)/registers/display/%.x= ml \ FORCE $(call if_changed,headergen) =20 +ADRENO_PERFCNTRS =3D + +define adreno_perfcntrs +ADRENO_PERFCNTRS +=3D generated/$(1)_perfcntrs.json.c +$$(obj)/generated/$(1)_perfcntrs.json.c: $$(src)/registers/adreno/$(1)_per= fcntrs.json \ + $$(src)/registers/adreno/$(2).xml \ + FORCE + $$(call if_changed,headergen_json) +endef + +$(eval $(call adreno_perfcntrs,a2xx,a2xx)) +$(eval $(call adreno_perfcntrs,a5xx,a5xx)) +$(eval $(call adreno_perfcntrs,a6xx,a6xx)) +$(eval $(call adreno_perfcntrs,a7xx,a6xx)) +$(eval $(call adreno_perfcntrs,a8xx,a6xx)) + +adreno-y +=3D $(ADRENO_PERFCNTRS:.c=3D.o) + ADRENO_HEADERS =3D \ generated/a2xx.xml.h \ generated/a3xx.xml.h \ @@ -226,4 +249,4 @@ DISPLAY_HEADERS =3D \ $(addprefix $(obj)/,$(adreno-y)): $(addprefix $(obj)/,$(ADRENO_HEADERS)) $(addprefix $(obj)/,$(msm-display-y)): $(addprefix $(obj)/,$(DISPLAY_HEADE= RS)) =20 -targets +=3D $(ADRENO_HEADERS) $(DISPLAY_HEADERS) +targets +=3D $(ADRENO_HEADERS) $(DISPLAY_HEADERS) $(ADRENO_PERFCNTRS) diff --git a/drivers/gpu/drm/msm/msm_perfcntr.h b/drivers/gpu/drm/msm/msm_p= erfcntr.h new file mode 100644 index 000000000000..305dcde15c5e --- /dev/null +++ b/drivers/gpu/drm/msm/msm_perfcntr.h @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + */ + +#ifndef __MSM_PERFCNTR_H__ +#define __MSM_PERFCNTR_H__ + +#include "linux/array_size.h" + +#include "adreno_common.xml.h" + +/* + * This is a subset of the tables used by mesa. We don't need to + * enumerate the countables on the kernel side. + */ + +/* Describes a single counter: */ +struct msm_perfcntr_counter { + /* offset of the SELect register to choose what to count: */ + unsigned select_reg; + /* additional SEL regs to enable slice counters (gen8+) */ + unsigned slice_select_regs[2]; + /* offset of the lo/hi 32b to read current counter value: */ + unsigned counter_reg_lo; + unsigned counter_reg_hi; + /* TODO some counters have enable/clear registers */ +}; + +/* Describes an entire counter group: */ +struct msm_perfcntr_group { + const char *name; + enum adreno_pipe pipe; + unsigned num_counters; + const struct msm_perfcntr_counter *counters; +}; + +#define GROUP(_name, _pipe, _counters, _countables) { = \ + .name =3D _name, = \ + .pipe =3D _pipe, = \ + .num_counters =3D ARRAY_SIZE(_counters), = \ + .counters =3D _counters, = \ + } + +#define fd_perfcntr_counter msm_perfcntr_counter +#define fd_perfcntr_group msm_perfcntr_group + +#endif /* __MSM_PERFCNTR_H__ */ diff --git a/drivers/gpu/drm/msm/registers/adreno/a2xx_perfcntrs.json b/dri= vers/gpu/drm/msm/registers/adreno/a2xx_perfcntrs.json new file mode 100644 index 000000000000..8095345ffd8e --- /dev/null +++ b/drivers/gpu/drm/msm/registers/adreno/a2xx_perfcntrs.json @@ -0,0 +1,109 @@ +{ + "chip": "A2XX", + "groups": [ + { + "name": "CP", + "num": 1, + "select": "CP_PERFCOUNTER_SELECT", + "counter_lo": "CP_PERFCOUNTER_LO", + "counter_hi": "CP_PERFCOUNTER_HI", + "countable_type": "a2xx_cp_perfcount_sel" + }, + { + "name": "PA_SU", + "num": 4, + "select": "PA_SU_PERFCOUNTER{}_SELECT", + "counter_lo": "PA_SU_PERFCOUNTER{}_LOW", + "counter_hi": "PA_SU_PERFCOUNTER{}_HI", + "countable_type": "a2xx_su_perfcnt_select" + }, + { + "name": "PA_SC", + "num": 1, + "select": "PA_SC_PERFCOUNTER{}_SELECT", + "counter_lo": "PA_SC_PERFCOUNTER{}_LOW", + "counter_hi": "PA_SC_PERFCOUNTER{}_HI", + "countable_type": "a2xx_sc_perfcnt_select" + }, + { + "name": "VGT", + "num": 4, + "select": "VGT_PERFCOUNTER{}_SELECT", + "counter_lo": "VGT_PERFCOUNTER{}_LOW", + "counter_hi": "VGT_PERFCOUNTER{}_HI", + "countable_type": "a2xx_vgt_perfcount_select" + }, + { + "name": "TCR", + "num": 2, + "select": "TCR_PERFCOUNTER{}_SELECT", + "counter_lo": "TCR_PERFCOUNTER{}_LOW", + "counter_hi": "TCR_PERFCOUNTER{}_HI", + "countable_type": "a2xx_tcr_perfcount_select" + }, + { + "name": "TP0", + "num": 2, + "select": "TP0_PERFCOUNTER{}_SELECT", + "counter_lo": "TP0_PERFCOUNTER{}_LOW", + "counter_hi": "TP0_PERFCOUNTER{}_HI", + "countable_type": "a2xx_tp_perfcount_select" + }, + { + "name": "TCM", + "num": 2, + "select": "TCM_PERFCOUNTER{}_SELECT", + "counter_lo": "TCM_PERFCOUNTER{}_LOW", + "counter_hi": "TCM_PERFCOUNTER{}_HI", + "countable_type": "a2xx_tcm_perfcount_select" + }, + { + "name": "TCF", + "num": 12, + "select": "TCF_PERFCOUNTER{}_SELECT", + "counter_lo": "TCF_PERFCOUNTER{}_LOW", + "counter_hi": "TCF_PERFCOUNTER{}_HI", + "countable_type": "a2xx_tcf_perfcount_select" + }, + { + "name": "SQ", + "num": 4, + "select": "SQ_PERFCOUNTER{}_SELECT", + "counter_lo": "SQ_PERFCOUNTER{}_LOW", + "counter_hi": "SQ_PERFCOUNTER{}_HI", + "countable_type": "a2xx_sq_perfcnt_select" + }, + { + "name": "SX", + "num": 1, + "select": "SX_PERFCOUNTER{}_SELECT", + "counter_lo": "SX_PERFCOUNTER{}_LOW", + "counter_hi": "SX_PERFCOUNTER{}_HI", + "countable_type": "a2xx_sx_perfcnt_select" + }, + { + "name": "MH", + "num": 2, + "select": "MH_PERFCOUNTER{}_SELECT", + "counter_lo": "MH_PERFCOUNTER{}_LOW", + "counter_hi": "MH_PERFCOUNTER{}_HI", + "countable_type": "a2xx_mh_perfcnt_select" + }, + { + "name": "RBBM", + "num": 2, + "select": "RBBM_PERFCOUNTER{}_SELECT", + "counter_lo": "RBBM_PERFCOUNTER{}_LO", + "counter_hi": "RBBM_PERFCOUNTER{}_HI", + "countable_type": "a2xx_rbbm_perfcount1_sel" + }, + { + "name": "RB", + "num": 4, + "select": "RB_PERFCOUNTER{}_SELECT", + "counter_lo": "RB_PERFCOUNTER{}_LOW", + "counter_hi": "RB_PERFCOUNTER{}_HI", + "countable_type": "a2xx_rb_perfcnt_select" + } + ] +} diff --git a/drivers/gpu/drm/msm/registers/adreno/a5xx_perfcntrs.json b/dri= vers/gpu/drm/msm/registers/adreno/a5xx_perfcntrs.json new file mode 100644 index 000000000000..d95503543f94 --- /dev/null +++ b/drivers/gpu/drm/msm/registers/adreno/a5xx_perfcntrs.json @@ -0,0 +1,128 @@ +{ + "chip": "A5XX", + "groups": [ + { + "name": "CP", + "num": 8, + "reserved": [ 0 ], + "select": "CP_PERFCTR_CP_SEL_{}", + "counter_lo": "RBBM_PERFCTR_CP_{}_LO", + "counter_hi": "RBBM_PERFCTR_CP_{}_HI", + "countable_type": "a5xx_cp_perfcounter_select" + }, + { + "name": "CCU", + "num": 4, + "select": "RB_PERFCTR_CCU_SEL_{}", + "counter_lo": "RBBM_PERFCTR_CCU_{}_LO", + "counter_hi": "RBBM_PERFCTR_CCU_{}_HI", + "countable_type": "a5xx_ccu_perfcounter_select" + }, + { + "name": "TSE", + "num": 4, + "select": "GRAS_PERFCTR_TSE_SEL_{}", + "counter_lo": "RBBM_PERFCTR_TSE_{}_LO", + "counter_hi": "RBBM_PERFCTR_TSE_{}_HI", + "countable_type": "a5xx_tse_perfcounter_select" + }, + { + "name": "RAS", + "num": 4, + "select": "GRAS_PERFCTR_RAS_SEL_{}", + "counter_lo": "RBBM_PERFCTR_RAS_{}_LO", + "counter_hi": "RBBM_PERFCTR_RAS_{}_HI", + "countable_type": "a5xx_ras_perfcounter_select" + }, + { + "name": "LRZ", + "num": 4, + "select": "GRAS_PERFCTR_LRZ_SEL_{}", + "counter_lo": "RBBM_PERFCTR_LRZ_{}_LO", + "counter_hi": "RBBM_PERFCTR_LRZ_{}_HI", + "countable_type": "a5xx_lrz_perfcounter_select" + }, + { + "name": "HLSQ", + "num": 8, + "select": "HLSQ_PERFCTR_HLSQ_SEL_{}", + "counter_lo": "RBBM_PERFCTR_HLSQ_{}_LO", + "counter_hi": "RBBM_PERFCTR_HLSQ_{}_HI", + "countable_type": "a5xx_hlsq_perfcounter_select" + }, + { + "name": "PC", + "num": 8, + "select": "PC_PERFCTR_PC_SEL_{}", + "counter_lo": "RBBM_PERFCTR_PC_{}_LO", + "counter_hi": "RBBM_PERFCTR_PC_{}_HI", + "countable_type": "a5xx_pc_perfcounter_select" + }, + { + "name": "RB", + "num": 8, + "select": "RB_PERFCTR_RB_SEL_{}", + "counter_lo": "RBBM_PERFCTR_RB_{}_LO", + "counter_hi": "RBBM_PERFCTR_RB_{}_HI", + "countable_type": "a5xx_rb_perfcounter_select" + }, + { + "name": "RBBM", + "num": 4, + "reserved": [ 0 ], + "select": "RBBM_PERFCTR_RBBM_SEL_{}", + "counter_lo": "RBBM_PERFCTR_RBBM_{}_LO", + "counter_hi": "RBBM_PERFCTR_RBBM_{}_HI", + "countable_type": "a5xx_rbbm_perfcounter_select" + }, + { + "name": "SP", + "num": 12, + "reserved": [ 0 ], + "select": "SP_PERFCTR_SP_SEL_{}", + "counter_lo": "RBBM_PERFCTR_SP_{}_LO", + "counter_hi": "RBBM_PERFCTR_SP_{}_HI", + "countable_type": "a5xx_sp_perfcounter_select" + }, + { + "name": "TP", + "num": 8, + "select": "TPL1_PERFCTR_TP_SEL_{}", + "counter_lo": "RBBM_PERFCTR_TP_{}_LO", + "counter_hi": "RBBM_PERFCTR_TP_{}_HI", + "countable_type": "a5xx_tp_perfcounter_select" + }, + { + "name": "UCHE", + "num": 8, + "select": "UCHE_PERFCTR_UCHE_SEL_{}", + "counter_lo": "RBBM_PERFCTR_UCHE_{}_LO", + "counter_hi": "RBBM_PERFCTR_UCHE_{}_HI", + "countable_type": "a5xx_uche_perfcounter_select" + }, + { + "name": "VFD", + "num": 8, + "select": "VFD_PERFCTR_VFD_SEL_{}", + "counter_lo": "RBBM_PERFCTR_VFD_{}_LO", + "counter_hi": "RBBM_PERFCTR_VFD_{}_HI", + "countable_type": "a5xx_vfd_perfcounter_select" + }, + { + "name": "VPC", + "num": 4, + "select": "VPC_PERFCTR_VPC_SEL_{}", + "counter_lo": "RBBM_PERFCTR_VPC_{}_LO", + "counter_hi": "RBBM_PERFCTR_VPC_{}_HI", + "countable_type": "a5xx_vpc_perfcounter_select" + }, + { + "name": "VSC", + "num": 2, + "select": "VSC_PERFCTR_VSC_SEL_{}", + "counter_lo": "RBBM_PERFCTR_VSC_{}_LO", + "counter_hi": "RBBM_PERFCTR_VSC_{}_HI", + "countable_type": "a5xx_vsc_perfcounter_select" + } + ] +} diff --git a/drivers/gpu/drm/msm/registers/adreno/a6xx_perfcntrs.json b/dri= vers/gpu/drm/msm/registers/adreno/a6xx_perfcntrs.json new file mode 100644 index 000000000000..8bb31820479e --- /dev/null +++ b/drivers/gpu/drm/msm/registers/adreno/a6xx_perfcntrs.json @@ -0,0 +1,105 @@ +{ + "chip": "A6XX", + "groups": [ + { + "name": "CP", + "num": 14, + "reserved": [ 0 ], + "select": "CP_PERFCTR_CP_SEL", + "counter": "RBBM_PERFCTR_CP", + "countable_type": "a6xx_cp_perfcounter_select" + }, + { + "name": "CCU", + "num": 5, + "select": "RB_PERFCTR_CCU_SEL", + "counter": "RBBM_PERFCTR_CCU", + "countable_type": "a6xx_ccu_perfcounter_select" + }, + { + "name": "TSE", + "num": 4, + "select": "GRAS_PERFCTR_TSE_SEL", + "counter": "RBBM_PERFCTR_TSE", + "countable_type": "a6xx_tse_perfcounter_select" + }, + { + "name": "RAS", + "num": 4, + "select": "GRAS_PERFCTR_RAS_SEL", + "counter": "RBBM_PERFCTR_RAS", + "countable_type": "a6xx_ras_perfcounter_select" + }, + { + "name": "LRZ", + "num": 4, + "select": "GRAS_PERFCTR_LRZ_SEL", + "counter": "RBBM_PERFCTR_LRZ", + "countable_type": "a6xx_lrz_perfcounter_select" + }, + { + "name": "HLSQ", + "num": 6, + "select": "HLSQ_PERFCTR_HLSQ_SEL", + "counter": "RBBM_PERFCTR_HLSQ", + "countable_type": "a6xx_hlsq_perfcounter_select" + }, + { + "name": "PC", + "num": 8, + "select": "PC_PERFCTR_PC_SEL", + "counter": "RBBM_PERFCTR_PC", + "countable_type": "a6xx_pc_perfcounter_select" + }, + { + "name": "RB", + "num": 8, + "select": "RB_PERFCTR_RB_SEL", + "counter": "RBBM_PERFCTR_RB", + "countable_type": "a6xx_rb_perfcounter_select" + }, + { + "name": "SP", + "num": 24, + "reserved": [ 0 ], + "select": "SP_PERFCTR_SP_SEL", + "counter": "RBBM_PERFCTR_SP", + "countable_type": "a6xx_sp_perfcounter_select" + }, + { + "name": "TP", + "num": 12, + "select": "TPL1_PERFCTR_TP_SEL", + "counter": "RBBM_PERFCTR_TP", + "countable_type": "a6xx_tp_perfcounter_select" + }, + { + "name": "UCHE", + "num": 12, + "select": "UCHE_PERFCTR_UCHE_SEL", + "counter": "RBBM_PERFCTR_UCHE", + "countable_type": "a6xx_uche_perfcounter_select" + }, + { + "name": "VFD", + "num": 8, + "select": "VFD_PERFCTR_VFD_SEL", + "counter": "RBBM_PERFCTR_VFD", + "countable_type": "a6xx_vfd_perfcounter_select" + }, + { + "name": "VPC", + "num": 6, + "select": "VPC_PERFCTR_VPC_SEL", + "counter": "RBBM_PERFCTR_VPC", + "countable_type": "a6xx_vpc_perfcounter_select" + }, + { + "name": "VSC", + "num": 2, + "select": "VSC_PERFCTR_VSC_SEL", + "counter": "RBBM_PERFCTR_VSC", + "countable_type": "a6xx_vsc_perfcounter_select" + } + ] +} diff --git a/drivers/gpu/drm/msm/registers/adreno/a7xx_perfcntrs.json b/dri= vers/gpu/drm/msm/registers/adreno/a7xx_perfcntrs.json new file mode 100644 index 000000000000..e60aab1862ec --- /dev/null +++ b/drivers/gpu/drm/msm/registers/adreno/a7xx_perfcntrs.json @@ -0,0 +1,228 @@ +{ + "chip": "A7XX", + "groups": [ + { + "name": "CP", + "num": 14, + "reserved": [ 0 ], + "select": "CP_PERFCTR_CP_SEL", + "counter": "RBBM_PERFCTR_CP", + "countable_type": "a7xx_cp_perfcounter_select" + }, + { + "name": "RBBM", + "num": 4, + "select": "RBBM_PERFCTR_RBBM_SEL", + "counter": "RBBM_PERFCTR_RBBM", + "countable_type": "a7xx_rbbm_perfcounter_select" + }, + { + "name": "PC", + "pipe": "BR", + "num": 8, + "select": "PC_PERFCTR_PC_SEL", + "counter": "RBBM_PERFCTR_PC", + "countable_type": "a7xx_pc_perfcounter_select" + }, + { + "name": "VFD", + "pipe": "BR", + "num": 8, + "select": "VFD_PERFCTR_VFD_SEL", + "counter": "RBBM_PERFCTR_VFD", + "countable_type": "a7xx_vfd_perfcounter_select" + }, + { + "name": "HLSQ", + "pipe": "BR", + "num": 6, + "select": "SP_PERFCTR_HLSQ_SEL", + "counter": "RBBM_PERFCTR_HLSQ", + "countable_type": "a7xx_hlsq_perfcounter_select" + }, + { + "name": "VPC", + "pipe": "BR", + "num": 6, + "select": "VPC_PERFCTR_VPC_SEL", + "counter": "RBBM_PERFCTR_VPC", + "countable_type": "a7xx_vpc_perfcounter_select" + }, + { + "name": "TSE", + "pipe": "BR", + "num": 4, + "select": "GRAS_PERFCTR_TSE_SEL", + "counter": "RBBM_PERFCTR_TSE", + "countable_type": "a7xx_tse_perfcounter_select" + }, + { + "name": "RAS", + "pipe": "BR", + "num": 4, + "select": "GRAS_PERFCTR_RAS_SEL", + "counter": "RBBM_PERFCTR_RAS", + "countable_type": "a7xx_ras_perfcounter_select" + }, + { + "name": "UCHE", + "num": 12, + "select": "UCHE_PERFCTR_UCHE_SEL", + "counter": "RBBM_PERFCTR_UCHE", + "countable_type": "a7xx_uche_perfcounter_select" + }, + { + "name": "TP", + "pipe": "BR", + "num": 12, + "select": "TPL1_PERFCTR_TP_SEL", + "counter": "RBBM_PERFCTR_TP", + "countable_type": "a7xx_tp_perfcounter_select" + }, + { + "name": "SP", + "pipe": "BR", + "num": 24, + "select": "SP_PERFCTR_SP_SEL", + "counter": "RBBM_PERFCTR_SP", + "countable_type": "a7xx_sp_perfcounter_select" + }, + { + "name": "RB", + "num": 8, + "select": "RB_PERFCTR_RB_SEL", + "counter": "RBBM_PERFCTR_RB", + "countable_type": "a7xx_rb_perfcounter_select" + }, + { + "name": "VSC", + "num": 2, + "select": "VSC_PERFCTR_VSC_SEL", + "counter": "RBBM_PERFCTR_VSC", + "countable_type": "a7xx_vsc_perfcounter_select" + }, + { + "name": "CCU", + "num": 5, + "select": "RB_PERFCTR_CCU_SEL", + "counter": "RBBM_PERFCTR_CCU", + "countable_type": "a7xx_ccu_perfcounter_select" + }, + { + "name": "LRZ", + "pipe": "BR", + "num": 4, + "select": "GRAS_PERFCTR_LRZ_SEL", + "counter": "RBBM_PERFCTR_LRZ", + "countable_type": "a7xx_lrz_perfcounter_select" + }, + { + "name": "CMP", + "num": 4, + "select": "RB_PERFCTR_CMP_SEL", + "counter": "RBBM_PERFCTR_CMP", + "countable_type": "a7xx_cmp_perfcounter_select" + }, + { + "name": "UFC", + "pipe": "BR", + "num": 4, + "select": "RB_PERFCTR_UFC_SEL", + "counter": "RBBM_PERFCTR_UFC", + "countable_type": "a7xx_ufc_perfcounter_select" + }, + { + "name": "BV_CP", + "num": 7, + "select": "CP_BV_PERFCTR_CP_SEL", + "counter": "RBBM_PERFCTR2_CP", + "countable_type": "a7xx_cp_perfcounter_select" + }, + { + "name": "BV_PC", + "pipe": "BV", + "num": 8, + "select_offset": 8, + "select": "PC_PERFCTR_PC_SEL", + "counter": "RBBM_PERFCTR_BV_PC", + "countable_type": "a7xx_pc_perfcounter_select" + }, + { + "name": "BV_VFD", + "pipe": "BV", + "num": 8, + "select_offset": 8, + "select": "VFD_PERFCTR_VFD_SEL", + "counter": "RBBM_PERFCTR_BV_VFD", + "countable_type": "a7xx_vfd_perfcounter_select" + }, + { + "name": "BV_VPC", + "pipe": "BV", + "num": 6, + "select_offset": 6, + "select": "VPC_PERFCTR_VPC_SEL", + "counter": "RBBM_PERFCTR_BV_VPC", + "countable_type": "a7xx_vpc_perfcounter_select" + }, + { + "name": "BV_TP", + "pipe": "BV", + "num": 6, + "select_offset": 12, + "select": "TPL1_PERFCTR_TP_SEL", + "counter": "RBBM_PERFCTR2_TP", + "countable_type": "a7xx_tp_perfcounter_select" + }, + { + "name": "BV_SP", + "pipe": "BV", + "num": 12, + "select_offset": 24, + "select": "SP_PERFCTR_SP_SEL", + "counter": "RBBM_PERFCTR2_SP", + "countable_type": "a7xx_sp_perfcounter_select" + }, + { + "name": "BV_UFC", + "pipe": "BV", + "num": 2, + "select_offset": 4, + "select": "RB_PERFCTR_UFC_SEL", + "counter": "RBBM_PERFCTR2_UFC", + "countable_type": "a7xx_ufc_perfcounter_select" + }, + { + "name": "BV_TSE", + "pipe": "BV", + "num": 4, + "select": "GRAS_PERFCTR_TSE_SEL", + "counter": "RBBM_PERFCTR_BV_TSE", + "countable_type": "a7xx_tse_perfcounter_select" + }, + { + "name": "BV_RAS", + "pipe": "BV", + "num": 4, + "select": "GRAS_PERFCTR_RAS_SEL", + "counter": "RBBM_PERFCTR_BV_RAS", + "countable_type": "a7xx_ras_perfcounter_select" + }, + { + "name": "BV_LRZ", + "pipe": "BV", + "num": 4, + "select": "GRAS_PERFCTR_LRZ_SEL", + "counter": "RBBM_PERFCTR_BV_LRZ", + "countable_type": "a7xx_lrz_perfcounter_select" + }, + { + "name": "BV_HLSQ", + "pipe": "BV", + "num": 6, + "select": "SP_PERFCTR_HLSQ_SEL", + "counter": "RBBM_PERFCTR2_HLSQ", + "countable_type": "a7xx_hlsq_perfcounter_select" + } + ] +} diff --git a/drivers/gpu/drm/msm/registers/adreno/a8xx_perfcntrs.json b/dri= vers/gpu/drm/msm/registers/adreno/a8xx_perfcntrs.json new file mode 100644 index 000000000000..503b113df397 --- /dev/null +++ b/drivers/gpu/drm/msm/registers/adreno/a8xx_perfcntrs.json @@ -0,0 +1,240 @@ +{ + "chip": "A8XX", + "groups": [ + { + "name": "CP", + "num": 14, + "reserved": [ 0 ], + "select": "CP_PERFCTR_CP_SEL", + "counter": "RBBM_PERFCTR_CP", + "countable_type": "a8xx_cp_perfcounter_select" + }, + { + "name": "RBBM", + "num": 4, + "select": "RBBM_PERFCTR_RBBM_SEL", + "slice_select": [ "RBBM_SLICE_PERFCTR_RBBM_SEL" ], + "counter": "RBBM_PERFCTR_RBBM", + "countable_type": "a8xx_rbbm_perfcounter_select" + }, + { + "name": "PC", + "pipe": "BR", + "num": 8, + "select": "PC_PERFCTR_PC_SEL", + "slice_select": [ "PC_SLICE_PERFCTR_PC_SEL" ], + "counter": "RBBM_PERFCTR_PC", + "countable_type": "a8xx_pc_perfcounter_select" + }, + { + "name": "VFD", + "pipe": "BR", + "num": 8, + "select": "VFD_PERFCTR_VFD_SEL", + "counter": "RBBM_PERFCTR_VFD", + "countable_type": "a8xx_vfd_perfcounter_select" + }, + { + "name": "HLSQ", + "pipe": "BR", + "num": 6, + "select": "SP_PERFCTR_HLSQ_SEL", + "slice_select": [ "SP_PERFCTR_HLSQ_SEL_2" ], + "counter": "RBBM_PERFCTR_HLSQ", + "countable_type": "a8xx_hlsq_perfcounter_select" + }, + { + "name": "VPC", + "pipe": "BR", + "num": 6, + "select": "VPC_PERFCTR_VPC_SEL", + "slice_select": [ "VPC_PERFCTR_VPC_SEL_1", "VPC_PERFCTR_VPC_SE= L_2" ], + "counter": "RBBM_PERFCTR_VPC", + "countable_type": "a8xx_vpc_perfcounter_select" + }, + { + "name": "TSE", + "pipe": "BR", + "num": 4, + "select": "GRAS_PERFCTR_TSE_SEL", + "slice_select": [ "GRAS_PERFCTR_TSEFE_SEL" ], + "counter": "RBBM_PERFCTR_TSE", + "countable_type": "a8xx_tse_perfcounter_select" + }, + { + "name": "RAS", + "pipe": "BR", + "num": 4, + "select": "GRAS_PERFCTR_RAS_SEL", + "counter": "RBBM_PERFCTR_RAS", + "countable_type": "a8xx_ras_perfcounter_select" + }, + { + "name": "UCHE", + "num": 12, + "select": "UCHE_PERFCTR_UCHE_SEL", + "counter": "RBBM_PERFCTR_UCHE", + "countable_type": "a8xx_uche_perfcounter_select" + }, + { + "name": "TP", + "pipe": "BR", + "num": 12, + "select": "TPL1_PERFCTR_TP_SEL", + "counter": "RBBM_PERFCTR_TP", + "countable_type": "a8xx_tp_perfcounter_select" + }, + { + "name": "SP", + "pipe": "BR", + "num": 24, + "select": "SP_PERFCTR_SP_SEL", + "counter": "RBBM_PERFCTR_SP", + "countable_type": "a8xx_sp_perfcounter_select" + }, + { + "name": "RB", + "pipe": "BR", + "num": 8, + "select": "RB_PERFCTR_RB_SEL", + "counter": "RBBM_PERFCTR_RB", + "countable_type": "a8xx_rb_perfcounter_select" + }, + { + "name": "VSC", + "num": 2, + "select": "VSC_PERFCTR_VSC_SEL", + "counter": "RBBM_PERFCTR_VSC", + "countable_type": "a8xx_vsc_perfcounter_select" + }, + { + "name": "CCU", + "pipe": "BR", + "num": 5, + "select": "RB_PERFCTR_CCU_SEL", + "counter": "RBBM_PERFCTR_CCU", + "countable_type": "a8xx_ccu_perfcounter_select" + }, + { + "name": "LRZ", + "pipe": "BR", + "num": 4, + "select": "GRAS_PERFCTR_LRZ_SEL", + "counter": "RBBM_PERFCTR_LRZ", + "countable_type": "a8xx_lrz_perfcounter_select" + }, + { + "name": "CMP", + "num": 4, + "select": "RB_PERFCTR_CMP_SEL", + "counter": "RBBM_PERFCTR_CMP", + "countable_type": "a8xx_cmp_perfcounter_select" + }, + { + "name": "UFC", + "pipe": "BR", + "num": 4, + "select": "RB_PERFCTR_UFC_SEL", + "counter": "RBBM_PERFCTR_UFC", + "countable_type": "a8xx_ufc_perfcounter_select" + }, + { + "name": "BV_CP", + "num": 7, + "select_offset": 14, + "select": "CP_PERFCTR_CP_SEL", + "counter": "RBBM_PERFCTR2_CP", + "countable_type": "a8xx_cp_perfcounter_select" + }, + { + "name": "BV_PC", + "pipe": "BV", + "num": 8, + "select_offset": 8, + "select": "PC_PERFCTR_PC_SEL", + "slice_select": [ "PC_SLICE_PERFCTR_PC_SEL" ], + "counter": "RBBM_PERFCTR_BV_PC", + "countable_type": "a8xx_pc_perfcounter_select" + }, + { + "name": "BV_VFD", + "pipe": "BV", + "num": 8, + "select_offset": 8, + "select": "VFD_PERFCTR_VFD_SEL", + "counter": "RBBM_PERFCTR_BV_VFD", + "countable_type": "a8xx_vfd_perfcounter_select" + }, + { + "name": "BV_VPC", + "pipe": "BV", + "num": 6, + "select_offset": 6, + "select": "VPC_PERFCTR_VPC_SEL", + "slice_select": [ "VPC_PERFCTR_VPC_SEL_1", "VPC_PERFCTR_VPC_SE= L_2" ], + "counter": "RBBM_PERFCTR_BV_VPC", + "countable_type": "a8xx_vpc_perfcounter_select" + }, + { + "name": "BV_TP", + "pipe": "BV", + "num": 8, + "select_offset": 12, + "select": "TPL1_PERFCTR_TP_SEL", + "counter": "RBBM_PERFCTR2_TP", + "countable_type": "a8xx_tp_perfcounter_select" + }, + { + "name": "BV_SP", + "pipe": "BV", + "num": 12, + "select_offset": 24, + "select": "SP_PERFCTR_SP_SEL", + "counter": "RBBM_PERFCTR2_SP", + "countable_type": "a8xx_sp_perfcounter_select" + }, + { + "name": "BV_UFC", + "pipe": "BV", + "num": 2, + "select_offset": 4, + "select": "RB_PERFCTR_UFC_SEL", + "counter": "RBBM_PERFCTR2_UFC", + "countable_type": "a8xx_ufc_perfcounter_select" + }, + { + "name": "BV_TSE", + "pipe": "BV", + "num": 4, + "select": "GRAS_PERFCTR_TSE_SEL", + "slice_select": [ "GRAS_PERFCTR_TSEFE_SEL" ], + "counter": "RBBM_PERFCTR_BV_TSE", + "countable_type": "a8xx_tse_perfcounter_select" + }, + { + "name": "BV_RAS", + "pipe": "BV", + "num": 4, + "select": "GRAS_PERFCTR_RAS_SEL", + "counter": "RBBM_PERFCTR_BV_RAS", + "countable_type": "a8xx_ras_perfcounter_select" + }, + { + "name": "BV_LRZ", + "pipe": "BV", + "num": 4, + "select": "GRAS_PERFCTR_LRZ_SEL", + "counter": "RBBM_PERFCTR_BV_LRZ", + "countable_type": "a8xx_lrz_perfcounter_select" + }, + { + "name": "BV_HLSQ", + "pipe": "BV", + "num": 6, + "select": "SP_PERFCTR_HLSQ_SEL", + "slice_select": [ "SP_PERFCTR_HLSQ_SEL_2" ], + "counter": "RBBM_PERFCTR2_HLSQ", + "countable_type": "a8xx_hlsq_perfcounter_select" + } + ] +} --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B9BAE3EF0D2 for ; Mon, 4 May 2026 19:08:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921715; cv=none; b=DyaJcLfSUvJp3fv2ejqhNyBAFpTI5Z5AOcvNdRbzFknVovzbk9JiJHL9GmhBL5t8wMq/+iS8N3oko9Id10gLBJbBxJNYRi03jvMmRGsnjnpAb04qlQUqL7ad79Zl7tNf0WGPrkJE+JtkWMbaNS6fgtzsiyY0mPRGRXAebjU2Gds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921715; c=relaxed/simple; bh=EM7ENbxlrlWP9nDeXhbulykziWmwjg0MWHFUydnf3Gg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Vurm7uvLj50WOcXQ8x2XRsaZgwgIsD5Riv+ctf85jvIOrI3UeQwD58F8EQ2Zp3zUID/CEHVx34E2/Ze1whnYuVRjRHqwaQOGNfLZI3sNM0WgOvPJQFC1ybXWSNElkzeE1KRT8IFU1s7aELSFCfiUbUCQ+fpCE2TV5bpkxb0PwSo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=AYBo1g/Y; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=RpW+Ytv9; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="AYBo1g/Y"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="RpW+Ytv9" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644E2hsA1186849 for ; Mon, 4 May 2026 19:08:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=nY8Zf16hfaV mHNExd3/Edt40koDFD/E4yWO1TVKH8HE=; b=AYBo1g/YCo07xifCZTxImkFEyIs 2CaoxM5v8ho7UJ80SVUJtQe3XnGk4Y/BnxMSAUDIW7OZMkz6wkNvWAAeIsSVrRtW C49FD3Mm18cWyeV15R+LTHzHFdv5VR9LXudxlxiv+3Tgu5ew0Jw/9rl3okv/ef/F THPKLSc4V99ZtapUriKLLjKMB7zni7Ag4tKLMTEONo0jaiNCu+VDAX/tZXwJBYCN SXPJ5EpJDki7IjqzNOWjzNNQ/6jDQ47VmsvyeSIZPe/gbxG77R8a02het5wrUIfQ KQCbPdKQzoNFCiTd9Jqf3NsPw5r7gBl/ySTiEaTGqXGXEvj2S9hO6sJNPVQ== Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxvvg97ec-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:32 +0000 (GMT) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-b630753cc38so5853284a12.1 for ; Mon, 04 May 2026 12:08:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921712; x=1778526512; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nY8Zf16hfaVmHNExd3/Edt40koDFD/E4yWO1TVKH8HE=; b=RpW+Ytv9BKJjhBWYG3/oyFm6Hq9A3W/r5d5Fwq3WRuni4L55pu1TqWsV21J+GohFl4 KQkYPMz+WayZXWHtDBr8UZPv7RCOxRPt+sEMuoFn+P8p6hfHlhf1hdOu4C9yWv/a90vh vEH9cRuvNrsJMWKV+AGcD7rVHKq4bPNn3BStEI3hfnI7k4j4TDtvluiDoX94K7KF2eSC 5oyBPPW4xOhzWZSSC3DTPoSeHWkOTmgN7nBi17eEVv4FHqNwx8UlPF4RQfZoiQEHN/6e T1NxlSKt8l9mXdMgCXVFzWKe6oEqxrKPJp9vlr54jk6kjpA/GS0T0+wIDxqeRG6Gk0m1 uw+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921712; x=1778526512; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=nY8Zf16hfaVmHNExd3/Edt40koDFD/E4yWO1TVKH8HE=; b=lYpPsMg/Y08k/HD0vzH1lUuDvHFqh1y1DYHJmpzns1hAii1ZkdICt9xn6ipiP22+qr i8MyzejQPkdXbs15lTad0z1uaiEkk/IyvtTmFJG6D+r/Qb7UfoV7EhKc8gTrHBVSHnLB XN+Jk9lYf++z0+Yx/ADr/6KofSXHookCfquQFvAn+pcPQkwoKBCUcIdbu0wHrALrm52/ T4f2sqmgqDd0XLowoIQeqoTnQkVNS+x9nzJq8nPfSbNWlUNwd6mvzWlK/PuXUj3ZeftR Cb45A3LF6tKk8uboFyg6j+66On2KxVnp/Bg/bBNzIBx9dnbtllTDMh+/VumqJzlaxGPI xShA== X-Forwarded-Encrypted: i=1; AFNElJ9sCu7BV9j3wBgZEKD1n1g2cxiDnuSY821tTsCNkMeWT6hmdZzb1V49Zyj8dwJWo2FqeltKctrSTy5H4jI=@vger.kernel.org X-Gm-Message-State: AOJu0Ywyxaqoi9XBc1ltxtP4U+9oJpK5CPWPt/E9AdMKTjFipH5XLCU3 V8k8wR6T8vKjjOn4DMK6NOCJHEfLCcYQSzNhAigB8C4Qx/Dk1X4ni6kGj7Ukevmg4/nNSSyls7J 4XZNdw+QbZqG0DaEhYysKGQsG/Y+UruVvuemHCByux6zvHswtJ/1AAkyYqXmwnsHPq0o= X-Gm-Gg: AeBDiesDeVxkzTo33jPLTjXn7cGC1Ir3niM5QWg/jKs2xkKEzK9jEPfIMturxH+L5uh 18D+xXN6L9f3ZgWNIKijzRRhQ8SMgmXL7+1EMLGoeQLzj/20SDLjvYUCvpFPyujZH3s6RcvtRFc MZSjAd0ic+yVU9f7mNwXj+NszhZ/B9ldA28xLZsrAvYxapxhnqGwgEGZzKgB5mc6ZtZ1RIVyfHZ mI0zoankgtWSvtLoUL3aQttDniKNce3laCA1J68d253UYMaK6adgXavhoya905UXhOv/K6uItco kY28ta4p3ASVTXvajGJROHuiDug4Qqi43xWV88jFC5JNNVrIwX9Gwg0IiTgRovHBl31MXTly993 sWrj/InlLkdL0SucCmgWy8hZa2yOjH8qzXo6ZbDUZTNo= X-Received: by 2002:a05:6a20:4326:b0:398:8870:b58f with SMTP id adf61e73a8af0-3a7f1ad133amr11856276637.14.1777921711539; Mon, 04 May 2026 12:08:31 -0700 (PDT) X-Received: by 2002:a05:6a20:4326:b0:398:8870:b58f with SMTP id adf61e73a8af0-3a7f1ad133amr11856247637.14.1777921711051; Mon, 04 May 2026 12:08:31 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7ffbc8ad8dsm10017506a12.23.2026.05.04.12.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:30 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Sean Paul , Konrad Dybcio , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 06/16] drm/msm: Add a6xx+ perfcntr tables Date: Mon, 4 May 2026 12:06:49 -0700 Message-ID: <20260504190751.61052-7-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: joNNJ_PWrgoyDQ8Xu_Vycvu2eb-RlnvU X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfX0i7+0Mz5wl25 W366usL6JS4yoFQ10TSJlKXK20fMOxt8flMop0GCLzVK8Aw8gW0BYeCa/jypSVpnT8bejz0ugtm 9AHvrfh6E4Tk2a/pAv/qgBtWJymBIGBfxNm8ObjfbA3cnmDoCLTFDOuzwgkAETQCos+KlM6QEBn DmydUN4C+xAbSVGW29uLX53lhnDifRYppy06L52+qbQ4IoxrcVXsGaw2g+NMQStNSgn078HKl15 SiXQbNNSnzWLOG6xeoe/5yMoMKcIsDYNK0/YCh+0i8+MwUNW0XY7hdPpagZTyEy4Aza3Y4NX2xm QtVx7ukCkZxv9SLbX9aPq+TT1ecKZoQj2kTjD37aAEfhAQTcb2yS0JZx2OmGdysL+/Y3YPcHs/Z zzOs7vLcuM2WU4gQNO+UwGMeTD1tu9PkpRsEmx7NYb2WWuVYjMIQ9itNLVSIr3SG4zzSmN/QEHv AM+PHLfkdYpDFKDLmBQ== X-Authority-Analysis: v=2.4 cv=K+AS2SWI c=1 sm=1 tr=0 ts=69f8eeb0 cx=c_pps a=oF/VQ+ItUULfLr/lQ2/icg==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=UuwE4gOO9k-hs8zF27AA:9 a=3WC7DwWrALyhR5TkjVHa:22 X-Proofpoint-GUID: joNNJ_PWrgoyDQ8Xu_Vycvu2eb-RlnvU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 spamscore=0 adultscore=0 clxscore=1015 priorityscore=1501 bulkscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" Wire up the generated perfcntr tables for a6xx+. The PERFCNTR_CONFIG ioctl will use this information to assign counters. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 15 +++++++++++++++ drivers/gpu/drm/msm/msm_gpu.h | 4 ++++ drivers/gpu/drm/msm/msm_perfcntr.h | 9 +++++++++ 3 files changed, 28 insertions(+) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a6xx_gpu.c index e578417a4949..727281fbef36 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -5,6 +5,7 @@ #include "msm_gem.h" #include "msm_mmu.h" #include "msm_gpu_trace.h" +#include "msm_perfcntr.h" #include "a6xx_gpu.h" #include "a6xx_gmu.xml.h" =20 @@ -2637,6 +2638,20 @@ static struct msm_gpu *a6xx_gpu_init(struct drm_devi= ce *dev) adreno_gpu =3D &a6xx_gpu->base; gpu =3D &adreno_gpu->base; =20 + if ((ADRENO_6XX_GEN1 <=3D config->info->family) && + (config->info->family <=3D ADRENO_6XX_GEN4)) { + gpu->perfcntr_groups =3D a6xx_perfcntr_groups; + gpu->num_perfcntr_groups =3D a6xx_num_perfcntr_groups; + } else if ((ADRENO_7XX_GEN1 <=3D config->info->family) && + (config->info->family <=3D ADRENO_7XX_GEN3)) { + gpu->perfcntr_groups =3D a7xx_perfcntr_groups; + gpu->num_perfcntr_groups =3D a7xx_num_perfcntr_groups; + } else if ((ADRENO_8XX_GEN1 <=3D config->info->family) && + (config->info->family <=3D ADRENO_8XX_GEN2)) { + gpu->perfcntr_groups =3D a8xx_perfcntr_groups; + gpu->num_perfcntr_groups =3D a8xx_num_perfcntr_groups; + } + mutex_init(&a6xx_gpu->gmu.lock); spin_lock_init(&a6xx_gpu->aperture_lock); =20 diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 78e1478669be..8c08dc065372 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -24,6 +24,7 @@ struct msm_gem_submit; struct msm_gem_vm_log_entry; struct msm_gpu_state; struct msm_context; +struct msm_perfcntr_group; =20 struct msm_gpu_config { const char *ioname; @@ -262,6 +263,9 @@ struct msm_gpu { bool allow_relocs; =20 struct thermal_cooling_device *cooling; + + const struct msm_perfcntr_group *perfcntr_groups; + unsigned num_perfcntr_groups; }; =20 static inline struct msm_gpu *dev_to_gpu(struct device *dev) diff --git a/drivers/gpu/drm/msm/msm_perfcntr.h b/drivers/gpu/drm/msm/msm_p= erfcntr.h index 305dcde15c5e..64a5d29feba1 100644 --- a/drivers/gpu/drm/msm/msm_perfcntr.h +++ b/drivers/gpu/drm/msm/msm_perfcntr.h @@ -35,6 +35,15 @@ struct msm_perfcntr_group { const struct msm_perfcntr_counter *counters; }; =20 +extern const struct msm_perfcntr_group a6xx_perfcntr_groups[]; +extern const unsigned a6xx_num_perfcntr_groups; + +extern const struct msm_perfcntr_group a7xx_perfcntr_groups[]; +extern const unsigned a7xx_num_perfcntr_groups; + +extern const struct msm_perfcntr_group a8xx_perfcntr_groups[]; +extern const unsigned a8xx_num_perfcntr_groups; + #define GROUP(_name, _pipe, _counters, _countables) { = \ .name =3D _name, = \ .pipe =3D _pipe, = \ --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAC9B3E866D for ; Mon, 4 May 2026 19:08:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921717; cv=none; b=NnP31OouZ0syozD+oQHvl1p/dNG0tTuo6gUqIYEl8mgehnQ4aP+dReDEOQktkYEnOWJsNG/6v1qMJfzETKROaT9VOZnYObyrjWBn4yzUL2NOxCEQmPYHoVcnekysCK0dMqN/UsbIYLHuwRcHhV97aiYpC8ercZeOMngrmebaXIo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921717; c=relaxed/simple; bh=KUeO+uGXifPyNRMjTlRkpbk+v6P6X9ZXisv7FWZ67XQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GmjDQTugCHdYrnMc4cBnu+Mv9dxD2Z6RD151SIXGCd2+iOtVYc81nm38HkLWAf7OqK7GPcUkFiOhbKo1WmXeK5g+Bx/GsNG8IBCoQFQIE43SsnLrxiaj1Wb9WhKLEDIaY/6vp6hREcsHiyYgeHNZ/EGQNbbozGx3a8G+tsNB8M4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=GTevab1G; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=KHmPpyEn; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="GTevab1G"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="KHmPpyEn" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644J21Hf636790 for ; Mon, 4 May 2026 19:08:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=Tj+4RQOx8Hh IQqlvFHx13oj7kr9BKUs7jNTjZUXWM+M=; b=GTevab1GvPoxNbPKUhnV3ic9vdc psPEynRV57ThMaWzYGy1fzi8YaFDBBa4/S2UwPA0vJiUoH3qaVRb2KGsGAHXZCp/ T7WwqJr02EJoAUN2ply3fYKbfNtRb/PMhvSX1UjhIQ4QgNcwtg4KZ2o6QJYGhGd0 +gQQtqo7q++LO2AdPU03RkPU4SGiUiXvS7tKZaR2mIa6ON/jW+s+x3oNjXnXqodY +Ichw9Q90SmRFVG7gOa1e+cx2j5MBLqHfwe3unLoPiB7hu6cB7SdB2hGYIUEgsHe /LXH49kgRNtmdHKcQM+bOIvL13yI98vXMQA8j9FT3L+Dh3zfV7WKcSmLgkw== Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxsx49t52-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:34 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-35fbb57764aso5813905a91.1 for ; Mon, 04 May 2026 12:08:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921714; x=1778526514; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Tj+4RQOx8HhIQqlvFHx13oj7kr9BKUs7jNTjZUXWM+M=; b=KHmPpyEnPT6mOwYgLbn/mK/1jfpR+JCJsrIAJzXHIYXVwnqG4GgekBm09K5rNAxsIm ahtxVnEfiJ9AVN2oucPSN+RaMsQoKHAa5XLG9iyD8Q6fXQVgVgQlX8+h9dcMJwpCaJkm dbMQmaRt9ot4PWbuoiQW6WHrgDaJOZeKTOQrcBQbZr82bLh2js/iPsDpn89SOZgcJjrS DqOeeQfHLcTZ1CG+V9HRZLS7E3XM7f+YJP9haHdILH1SyMRwt8O6YDbJ7jKBkOm6kIY8 TD0SByTTMr5XjifVel2gUwgdP8JeqSdpSr5bNSRZn31zUFe7MJB6VEROs8T11Axdk1yb RK7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921714; x=1778526514; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Tj+4RQOx8HhIQqlvFHx13oj7kr9BKUs7jNTjZUXWM+M=; b=gYcr5Y6WNC7Wr5FrSSDsv6Bp3rzpJavu762BCTEQ3vqmLjjawn+bIqEBMsISljuOUg LvUr0238eFnGB7phBdEFYH95ePf21mJ4ZS1JQ4mscY6ZFmo8007fTJPGqIjrR4uQRpNJ i6FvJPJ/hOjTx0qDgPb7AIf1l5ItJ6/mgtMlvj5gjonCuxsdH6iW7ZmldhWR1f+Ve3kT CpHY4SfmuU4Pa5qxbkbIvnNo4Orw7wn7RIK3cGz02RVnIprl95IJmn5lcztr3dbDxTA/ dRn88yiLIGYBbU25eHXUNWJwKA3UrsfLlxfZ5xPOU37dkW3l5WoU106/UR9qOkyzyZMc zvJg== X-Forwarded-Encrypted: i=1; AFNElJ+7fQlUdgvxZ69vTsKIFjB1qhuuF27sZBkeL+XOCAHzxDkLLG6HmhglTO0kUhyvXg2i3yfWJvI+zwofPso=@vger.kernel.org X-Gm-Message-State: AOJu0Yy/kfuMcNIvSZFwfXyrMgeAW63UbRvS9nw784idqsdoSXPirjDf yudLP0hqu1zv1rHTwXYy4LN4NTaKCFgIy9piA1lHCjMxcZqGca+B3OnmWBw07ZIuGJyBKx8dOjj ktewSZ+MrT1JCILNGSiZAq8QZlXXAA6vt6vyQ65xK6Lj5siEqVSVtRVAladOKL/493ZE= X-Gm-Gg: AeBDietkBx5fCz/I7WPji4hb+tEqwLtBZi5hKl/w6KaTkPrDJ4zEK2BdjF0eOVJ41Me sGWR9B3Sei6E7pLlq6265m5eyv7WaV/ck6KaE0eYUmq7/mABRe4l4thlI1NXsqreXN23AW8EgTs k0Hc1oRVtljAjVEeFMsQhV2iGBljQt2soHuKhp6lyNrk06V241+jyJDtym4E6+DrfhsSsHJY85/ QhioENaUGPfGBFSrgGy4yWxgqRZNftB+clNjQFL0EL/MXgKjroqloQZA9eW5wGVWSE0xl9pSTq5 b+0x8sHW8TG6JdgNvmZkTQk4eOVuNPfSxmgKo8q7wpcHnTeUu0CcCqKwTKkWXgFWtT+z0JHO9+D lS0KH7TJjNJf80FQxc1GcmeUP7Tv2yD+2D+jsBa/0e1U= X-Received: by 2002:a17:90b:3d4d:b0:35b:939c:e859 with SMTP id 98e67ed59e1d1-365727327fbmr583950a91.12.1777921713464; Mon, 04 May 2026 12:08:33 -0700 (PDT) X-Received: by 2002:a17:90b:3d4d:b0:35b:939c:e859 with SMTP id 98e67ed59e1d1-365727327fbmr583925a91.12.1777921712916; Mon, 04 May 2026 12:08:32 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-364be044f23sm15279848a91.17.2026.05.04.12.08.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:32 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Sean Paul , Konrad Dybcio , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 07/16] drm/msm: Add sysprof accessors Date: Mon, 4 May 2026 12:06:50 -0700 Message-ID: <20260504190751.61052-8-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfXz1jtG3UoBh8w JY7Tz4ISy3aZpZS0SkWok0rpbZwv18LNA2ZQDppYq+uy5UxgNUZYX4VPydRKsAuGbLk0afKxWCT byv8d/TQPXHMbuFx5WWkvC0R2nuEtktTruCQi39F8sbgI0q7K7aVuJf8sRGEFm2GSr3WPYTV/Te G154Ovcl87e1H8FOCy4lbnhiJCARBqRq939t9gPof+NIJ9qMRTJTDLVMkhBrO/OPytvAvi6EIkM N9ntiC7ppjicE4fy27dwXPJDVsW4HqP00GyKpL4cb9Qtv9JRdKcuhP9ACO9XyROti5PtVupUGsv 9eZj1u85ibko9F0sddUp2IhI3H4HKs2CajLAQrUf7F3zkAqmSgeWqUD1gDw9fLP6B4YwjOttV3S rAsjoLqKEKzyhH+IkXJ6cyyUL/lGhSG9coAOLkY8Ns1RChlhJc415+9InPS65wvFGHg0MV8CTcZ gAS1kf2PDleSUmtxfow== X-Proofpoint-ORIG-GUID: XDJ_tJNFQm1-HvBgqew1S2eBXXgTbwNX X-Proofpoint-GUID: XDJ_tJNFQm1-HvBgqew1S2eBXXgTbwNX X-Authority-Analysis: v=2.4 cv=LdIMLDfi c=1 sm=1 tr=0 ts=69f8eeb2 cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=v4b4B-quZFKF0PxyZCUA:9 a=mQ_c8vxmzFEMiUWkPHU9:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 suspectscore=0 impostorscore=0 malwarescore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" Currently the sysprof param serves two functions, (a) disabling perfcntr clearing on context switch/preemption, and (b) disabling IFPC. In the future, with kernel side global perfcntr collection/stream, the decision about disabling IFPC will change. To prepare for this, split out two helpers/accessors for the two different cases. For now, they are the same thing, but this will change. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 8 +++----- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 5 +++-- drivers/gpu/drm/msm/adreno/a6xx_preempt.c | 2 +- drivers/gpu/drm/msm/adreno/a8xx_gpu.c | 2 +- drivers/gpu/drm/msm/adreno/a8xx_preempt.c | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 18 ++++++++++++++++++ 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/ad= reno/a6xx_gmu.c index 1b44b9e21ad8..aba08fb76249 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -2036,10 +2036,10 @@ static int a6xx_gmu_get_irq(struct a6xx_gmu *gmu, s= truct platform_device *pdev, =20 void a6xx_gmu_sysprof_setup(struct msm_gpu *gpu) { + bool sysprof =3D msm_gpu_sysprof_no_ifpc(gpu); struct adreno_gpu *adreno_gpu =3D to_adreno_gpu(gpu); struct a6xx_gpu *a6xx_gpu =3D to_a6xx_gpu(adreno_gpu); struct a6xx_gmu *gmu =3D &a6xx_gpu->gmu; - unsigned int sysprof_active; =20 /* Nothing to do if GPU is suspended. We will handle this during GMU resu= me */ if (!pm_runtime_get_if_active(&gpu->pdev->dev)) @@ -2047,15 +2047,13 @@ void a6xx_gmu_sysprof_setup(struct msm_gpu *gpu) =20 mutex_lock(&gmu->lock); =20 - sysprof_active =3D refcount_read(&gpu->sysprof_active); - /* * 'Perfcounter select' register values are lost during IFPC collapse. To= avoid that, * use the currently unused perfcounter oob vote to block IFPC when syspr= of is active */ - if ((sysprof_active > 1) && !test_and_set_bit(GMU_STATUS_OOB_PERF_SET, &g= mu->status)) + if (sysprof && !test_and_set_bit(GMU_STATUS_OOB_PERF_SET, &gmu->status)) a6xx_gmu_set_oob(gmu, GMU_OOB_PERFCOUNTER_SET); - else if ((sysprof_active =3D=3D 1) && test_and_clear_bit(GMU_STATUS_OOB_P= ERF_SET, &gmu->status)) + else if (!sysprof && test_and_clear_bit(GMU_STATUS_OOB_PERF_SET, &gmu->st= atus)) a6xx_gmu_clear_oob(gmu, GMU_OOB_PERFCOUNTER_SET); =20 mutex_unlock(&gmu->lock); diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a6xx_gpu.c index 727281fbef36..71f54ab5425d 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -203,7 +203,7 @@ static void get_stats_counter(struct msm_ringbuffer *ri= ng, u32 counter, static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu, struct msm_ringbuffer *ring, struct msm_gem_submit *submit) { - bool sysprof =3D refcount_read(&a6xx_gpu->base.base.sysprof_active) > 1; + bool sysprof =3D msm_gpu_sysprof_no_perfcntr_zap(&a6xx_gpu->base.base); struct msm_context *ctx =3D submit->queue->ctx; struct drm_gpuvm *vm =3D msm_context_vm(submit->dev, ctx); struct adreno_gpu *adreno_gpu =3D &a6xx_gpu->base; @@ -1608,7 +1608,7 @@ static int hw_init(struct msm_gpu *gpu) a6xx_gmu_clear_oob(&a6xx_gpu->gmu, GMU_OOB_BOOT_SLUMBER); } =20 - if (!ret && (refcount_read(&gpu->sysprof_active) > 1)) { + if (!ret && msm_gpu_sysprof_no_ifpc(gpu)) { ret =3D a6xx_gmu_set_oob(gmu, GMU_OOB_PERFCOUNTER_SET); if (!ret) set_bit(GMU_STATUS_OOB_PERF_SET, &gmu->status); @@ -2854,6 +2854,7 @@ const struct adreno_gpu_funcs a8xx_gpu_funcs =3D { .create_private_vm =3D a6xx_create_private_vm, .get_rptr =3D a6xx_get_rptr, .progress =3D a8xx_progress, + .sysprof_setup =3D a6xx_gmu_sysprof_setup, }, .init =3D a6xx_gpu_init, .get_timestamp =3D a8xx_gmu_get_timestamp, diff --git a/drivers/gpu/drm/msm/adreno/a6xx_preempt.c b/drivers/gpu/drm/ms= m/adreno/a6xx_preempt.c index df4cbf42e9a4..1e599d4ddea1 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_preempt.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_preempt.c @@ -261,7 +261,7 @@ void a6xx_preempt_trigger(struct msm_gpu *gpu) mod_timer(&a6xx_gpu->preempt_timer, jiffies + msecs_to_jiffies(10000)); =20 /* Enable or disable postamble as needed */ - sysprof =3D refcount_read(&a6xx_gpu->base.base.sysprof_active) > 1; + sysprof =3D msm_gpu_sysprof_no_perfcntr_zap(gpu); =20 if (!sysprof && !a6xx_gpu->postamble_enabled) preempt_prepare_postamble(a6xx_gpu); diff --git a/drivers/gpu/drm/msm/adreno/a8xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a8xx_gpu.c index ccfccc45133f..e022c9a162a4 100644 --- a/drivers/gpu/drm/msm/adreno/a8xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a8xx_gpu.c @@ -849,7 +849,7 @@ static int hw_init(struct msm_gpu *gpu) */ a6xx_gmu_clear_oob(&a6xx_gpu->gmu, GMU_OOB_GPU_SET); =20 - if (!ret && (refcount_read(&gpu->sysprof_active) > 1)) { + if (!ret && msm_gpu_sysprof_no_perfcntr_zap(gpu)) { ret =3D a6xx_gmu_set_oob(gmu, GMU_OOB_PERFCOUNTER_SET); if (!ret) set_bit(GMU_STATUS_OOB_PERF_SET, &gmu->status); diff --git a/drivers/gpu/drm/msm/adreno/a8xx_preempt.c b/drivers/gpu/drm/ms= m/adreno/a8xx_preempt.c index 3d8c33ba722e..6cb53a071801 100644 --- a/drivers/gpu/drm/msm/adreno/a8xx_preempt.c +++ b/drivers/gpu/drm/msm/adreno/a8xx_preempt.c @@ -242,7 +242,7 @@ void a8xx_preempt_trigger(struct msm_gpu *gpu) mod_timer(&a6xx_gpu->preempt_timer, jiffies + msecs_to_jiffies(10000)); =20 /* Enable or disable postamble as needed */ - sysprof =3D refcount_read(&a6xx_gpu->base.base.sysprof_active) > 1; + sysprof =3D msm_gpu_sysprof_no_perfcntr_zap(gpu); =20 if (!sysprof && !a6xx_gpu->postamble_enabled) preempt_prepare_postamble(a6xx_gpu); diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 8c08dc065372..9e5c753437c2 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -311,6 +311,24 @@ static inline bool msm_gpu_active(struct msm_gpu *gpu) return false; } =20 +static inline bool +msm_gpu_sysprof_no_perfcntr_zap(struct msm_gpu *gpu) +{ + return refcount_read(&gpu->sysprof_active) > 1; +} + +static inline bool +msm_gpu_sysprof_no_ifpc(struct msm_gpu *gpu) +{ + /* + * For now, this is the same condition as disabling perfcntr clears + * on context switch. But once kernel perfcntr IFPC support is in + * place, we will only need to disable IFPC for legacy userspace + * setting SYSPROF param. + */ + return msm_gpu_sysprof_no_perfcntr_zap(gpu); +} + /* * The number of priority levels provided by drm gpu scheduler. The * DRM_SCHED_PRIORITY_KERNEL priority level is treated specially in some --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9880938C427 for ; Mon, 4 May 2026 19:08:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921721; cv=none; b=Nkao8+oMPxpNaLYxRZFviCfczUHZxBdipCR+edxQHLrmDVr2A/xxJpFPPStAmn71V3iM0JCxbGdomL86898ttCYq/U92axnqdOcTgymWRrwADC8EXxxjOzI2agXYWmrLT72BN+jmliPomiMxX7a8dMX+urjVWpKlHXS0oFTX1/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921721; c=relaxed/simple; bh=nf/AzQJzAwD5Wdqnd6VCCPR5ecVd2qygEvoiPvLJ7Vg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B5XS/piGF4mKkRleHWk/QNpOuhk1iCIGGAKtrQCOAz00aLHvSNciG8H74L9uNzb9NkPe9Owt23yrn7boeKDF9nvEE4P9hjB+yO8Z/zO2wZgYm1ZEoyvMgEk50LO0VyrM/aXaCEVVGhSpfMj24SkScx0DwGEZ7fQ1ZN7rToEnzC8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=cf2cM+FH; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=UWgjTxIf; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="cf2cM+FH"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="UWgjTxIf" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644IDtNY748896 for ; Mon, 4 May 2026 19:08:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=ZFtTLmOQAzj qHoC3Fafdx5s7yem/Cv9ClA1WpeTUDMw=; b=cf2cM+FH6ACHDWi0ShgqF+Lpf09 /By6SaAMHztFm2ApbaYtnaM15NdXB/euzLVNLIsKq2uH5WTxZeUrUyf4zipqYHW0 0x7wHXlyzvH9NWr3LuR6siIqrouAxjsLSCgkGuyOKRcBiLF2WuZfi3Ih+YgQQBm4 cD7UXceANKX9CQrXQBNlKb0+PA26eB0Va1U8nbQekbE4YmW39mXnpWTyzuPx8Fc3 4ZyC0iOLR0mzDLAyMSuG41W1kPCwQs6MPh0aDkQiy4nE5FkTxpysu5WrSKTb5w/H 6THLiqNr9OGWLUrZrBH0wuWH5pW70GJ6v3Vrr2BqgzYLfOcZ52Y+FRXrYfw== Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxscf1xe4-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:36 +0000 (GMT) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-c6e24ee93a6so2828283a12.0 for ; Mon, 04 May 2026 12:08:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921715; x=1778526515; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ZFtTLmOQAzjqHoC3Fafdx5s7yem/Cv9ClA1WpeTUDMw=; b=UWgjTxIfI4lpjAUTsW+H2prg1g3+0ZkasMwxy9s6836UUKvXpXh1YiDXTnitsBXP3K rZxZ68yuxe+v4qyZB0ot5lDI35aK0WKYY7H+D1aXxdHkbuIxRB55Eq+MdNdVQeDAGXFM KrJC+lSUmwmL/BF/ySP+ITIHKgbLJxjTwBQ0bgpP/oy8KoLq5YSx1D2qeMIIevRsPJK8 KGdn0Hc/swQj6ycp+1CUuA2o0gvnl1oIT+LvjOzFE8LhHPzQyv/xulCOiADok8nYcfOU Ik+d8f+2sGZUy0iSvm1KtStBBE8UzFs3sM5hSjyyCYh05jMIa9JT35mlXXK7G/UH99UL sgwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921715; x=1778526515; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=ZFtTLmOQAzjqHoC3Fafdx5s7yem/Cv9ClA1WpeTUDMw=; b=MpvpApAF9RAYxQE5DhwivA1FaWIVev8nIBPc5F8NsMFfvz8rBhKpoEYs91k87OH4is fSBLVZHLqweWaTd1RKjkoCC35Xp16Oi6I/PdGCC4T/Jc/Qsxto1mPiN2Hf0eQyA3tjNv +K7FSLx19MWg5AxXSZHU/lTx+cBgsrKCOBcWsO3hNfGgifFh38dHWowM3260rlC03j+v Z+SnuMySPhuM+C0G4RX4PtqYrMz1qqMlDVIUYcrVj5iy+1U5Z0s3pQC3sa/8hSos8oRl fjcwPrcy+T11nY3KqHiuwRzVshXQt27CNJ42MMZi9prwbXMKkFanWP2NJuoyZ6mk+dlg QzIA== X-Forwarded-Encrypted: i=1; AFNElJ8hZQzGZvDpawgJueL/QtueBfvW+oL1dnPTMc88Enb3KDKVtG2d02FG7txATHic3fGXp0Fg7LbYNElJzTc=@vger.kernel.org X-Gm-Message-State: AOJu0YxKhSmzfiRGFrIMdFZzQGrXILowq2g9fL47drjVMc61uqf9Url3 rCA5Lb66pADzjk8oB/ITRGKNG/RiUisFkyeTafRRS0oJKfbe5WxOLzBibEx7QwFhQkFP6alIt2T qzPsmi4dsBYNGe9eZrgIBfKA8cC1FEkGIxMUrCqJbKrPxTQfT0PbmZW3Et6fMTLO3VhM= X-Gm-Gg: AeBDiev0/ljI8lLsLgxlt7nrc9H8k6hpcNevsGf2IH+MvNy4pn4m94H77yLXZEmamv3 zhUaRWLVLLWsswI9+rEI/7EOXLROG5xW1VPk3BHtMi55Yx9hQzSSL/Ef/JwIQqMYiaI+CEsTfn/ cPtuUHNtt6KgNBs1OOwAMWJ80Ib2s1mzPz5XeB0htPzr5Q8BBj+UZ8avh6UHLBjnXwKvX0ClvBg CHeYVrOI3a1grBXy/C/rU0SIo7NjT4fMMoevctX1qNKqfD/eYYbyWs+iwyUsJqhcnJggWLlHM5+ jO8OFZfe/nAigzdSsonP+YVoyVHmDKRC8zE99+ukqykQ15/o/cv8MR+Rp+iCeZSL2uppmQf5HVT E2kf18tb0jCcWwF5c4XrLgLTPLqoQbdvtMQiO+yzblHs= X-Received: by 2002:a05:6a20:4305:b0:39b:ca34:96e3 with SMTP id adf61e73a8af0-3a9f77bd7a2mr567274637.37.1777921715031; Mon, 04 May 2026 12:08:35 -0700 (PDT) X-Received: by 2002:a05:6a20:4305:b0:39b:ca34:96e3 with SMTP id adf61e73a8af0-3a9f77bd7a2mr567242637.37.1777921714478; Mon, 04 May 2026 12:08:34 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7ffbb05798sm10380209a12.0.2026.05.04.12.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:34 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Sean Paul , Konrad Dybcio , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 08/16] drm/msm/a6xx: Add yield & flush helper Date: Mon, 4 May 2026 12:06:51 -0700 Message-ID: <20260504190751.61052-9-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=BcvoFLt2 c=1 sm=1 tr=0 ts=69f8eeb4 cx=c_pps a=oF/VQ+ItUULfLr/lQ2/icg==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=7a4_7rcHm0II5uOVc2AA:9 a=3WC7DwWrALyhR5TkjVHa:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfX6qbqVOupF7mH ktrsmqG3lSl9Ob+Ca9q/+gEJOkrAkrgOY+SEEpQzWwt7zZgjD57hXI62JZj3w4mkrzYGCocIZgJ 4lBQaYG6/Bjmadqik7CmtUK0GwxmxglyqFBWTdb2eHp0APdD2fmBqorEMyy1XOa/k7oA70AuhR9 hKXFPxc+J6lEGmK42OxOTOWvcd3ROP7ajkVWb3jhGz8oXwJGSGg1tZlsWRxn/E9twXXyTDd6M2Q u0N8XH+FsUd48PYrdfM2AK1ARlCgFdj17Qak0/w6eJTvV0uOTZ3XqstE8OXmo8h7jBNqTqDjESN DwmSOHedcW0cAKGvobBmiS3+zcCv+/0XIYUsiPgTI4Seg4YbLv363kaBKC1Q0koKY/oFtfCKWvr Ww2eVLH5jllNIIUETi6bBU5xd5Uo6Qbvb0WXvvLlrwYlIG1WNVIupsF3Lv5CPBsjF3VdGnuIzbo 4BhiGakaaoTryFDSmJg== X-Proofpoint-ORIG-GUID: 2-_Unh41lv1SQWTFlkLWZp-dFkx_qz9u X-Proofpoint-GUID: 2-_Unh41lv1SQWTFlkLWZp-dFkx_qz9u X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" It's a common pattern, needing to insert a yield packet before flushing the rb. And we'll need this once again for configuring perfcntr SEL regs. So add a helper. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 55 +++++++++++++-------------- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a8xx_gpu.c | 10 +---- 3 files changed, 28 insertions(+), 38 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a6xx_gpu.c index 71f54ab5425d..415902f6e5d7 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -189,6 +189,30 @@ void a6xx_flush(struct msm_gpu *gpu, struct msm_ringbu= ffer *ring) spin_unlock_irqrestore(&ring->preempt_lock, flags); } =20 +void +a6xx_flush_yield(struct msm_gpu *gpu, struct msm_ringbuffer *ring) +{ + /* If preemption is enabled */ + if (gpu->nr_rings > 1) { + /* Yield the floor on command completion */ + OUT_PKT7(ring, CP_CONTEXT_SWITCH_YIELD, 4); + + /* + * If dword[2:1] are non zero, they specify an address for + * the CP to write the value of dword[3] to on preemption + * complete. Write 0 to skip the write + */ + OUT_RING(ring, 0x00); + OUT_RING(ring, 0x00); + /* Data value - not used if the address above is 0 */ + OUT_RING(ring, 0x01); + /* generate interrupt on preemption completion */ + OUT_RING(ring, 0x00); + } + + a6xx_flush(gpu, ring); +} + static void get_stats_counter(struct msm_ringbuffer *ring, u32 counter, u64 iova) { @@ -597,28 +621,9 @@ static void a7xx_submit(struct msm_gpu *gpu, struct ms= m_gem_submit *submit) OUT_PKT7(ring, CP_SET_MARKER, 1); OUT_RING(ring, 0x100); /* IFPC enable */ =20 - /* If preemption is enabled */ - if (gpu->nr_rings > 1) { - /* Yield the floor on command completion */ - OUT_PKT7(ring, CP_CONTEXT_SWITCH_YIELD, 4); - - /* - * If dword[2:1] are non zero, they specify an address for - * the CP to write the value of dword[3] to on preemption - * complete. Write 0 to skip the write - */ - OUT_RING(ring, 0x00); - OUT_RING(ring, 0x00); - /* Data value - not used if the address above is 0 */ - OUT_RING(ring, 0x01); - /* generate interrupt on preemption completion */ - OUT_RING(ring, 0x00); - } - - trace_msm_gpu_submit_flush(submit, adreno_gpu->funcs->get_timestamp(gpu)); =20 - a6xx_flush(gpu, ring); + a6xx_flush_yield(gpu, ring); =20 /* Check to see if we need to start preemption */ if (adreno_is_a8xx(adreno_gpu)) @@ -958,15 +963,7 @@ static int a7xx_preempt_start(struct msm_gpu *gpu) =20 a6xx_emit_set_pseudo_reg(ring, a6xx_gpu, NULL); =20 - /* Yield the floor on command completion */ - OUT_PKT7(ring, CP_CONTEXT_SWITCH_YIELD, 4); - OUT_RING(ring, 0x00); - OUT_RING(ring, 0x00); - OUT_RING(ring, 0x00); - /* Generate interrupt on preemption completion */ - OUT_RING(ring, 0x00); - - a6xx_flush(gpu, ring); + a6xx_flush_yield(gpu, ring); =20 return a6xx_idle(gpu, ring) ? 0 : -EINVAL; } diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/ad= reno/a6xx_gpu.h index eb431e5e00b1..99c3e55f5ca8 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h @@ -317,6 +317,7 @@ void a6xx_bus_clear_pending_transactions(struct adreno_= gpu *adreno_gpu, bool gx_ void a6xx_gpu_sw_reset(struct msm_gpu *gpu, bool assert); int a6xx_fenced_write(struct a6xx_gpu *gpu, u32 offset, u64 value, u32 mas= k, bool is_64b); void a6xx_flush(struct msm_gpu *gpu, struct msm_ringbuffer *ring); +void a6xx_flush_yield(struct msm_gpu *gpu, struct msm_ringbuffer *ring); int a6xx_zap_shader_init(struct msm_gpu *gpu); =20 void a8xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu, bo= ol gx_off); diff --git a/drivers/gpu/drm/msm/adreno/a8xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a8xx_gpu.c index e022c9a162a4..124d315b2469 100644 --- a/drivers/gpu/drm/msm/adreno/a8xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a8xx_gpu.c @@ -488,15 +488,7 @@ static int a8xx_preempt_start(struct msm_gpu *gpu) =20 a6xx_emit_set_pseudo_reg(ring, a6xx_gpu, NULL); =20 - /* Yield the floor on command completion */ - OUT_PKT7(ring, CP_CONTEXT_SWITCH_YIELD, 4); - OUT_RING(ring, 0x00); - OUT_RING(ring, 0x00); - OUT_RING(ring, 0x00); - /* Generate interrupt on preemption completion */ - OUT_RING(ring, 0x00); - - a6xx_flush(gpu, ring); + a6xx_flush_yield(gpu, ring); =20 return a8xx_idle(gpu, ring) ? 0 : -EINVAL; } --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DADB3EFD24 for ; Mon, 4 May 2026 19:08:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921720; cv=none; b=V6ItHl6lHYsqQdRAUPJHE3Tv6YmBUBSEQSjHhpYv05VAlznRTK5WKldhHinZz/tU8J/TXsEwAwjdlaJem8VE/mm3/jxOomvb1yAI8+KDVWlBrZbCUwTfCl36Vh5Asx+9RdA02r5xwTR7ACu3Fdt7jlzdgP2k45mj8wC4RCFRH/Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921720; c=relaxed/simple; bh=XZmlmpKq9dT2OjVxZaCDZBHXjS0SdHaDhZM+xjSaQsI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Y+nS90JyOgsQq0CNbuDJNXFPTvr8b6jTySGXxMNvtHMp2cNtznlno4X4Bip/ZNNQbCNrb1wnfbuDlssu4SK/OssFaCRoQKzJRM1jlsFqC902+90Ua4fvTbQLTyXmB17lfI8xniTHmSIzk970xv0Xs3ZB1vqOufcZcARx4HSczjE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=QdjsyUX9; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ROXWmd5Z; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="QdjsyUX9"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ROXWmd5Z" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644FOpTP1346341 for ; Mon, 4 May 2026 19:08:37 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=Z+T7DF6d3yj uRFH4Z9NZjry6qzE7sW/NwEF2nzuN/uA=; b=QdjsyUX9GNUH6JmqK45M7BjYJ7i dNlw/I5Fi9YvkjszHEJtSu1cYtFk/P5MID8cZWnvmTQxGEsA0tc/XGVzebZH9zhS aTCD27siMCqhzIRZIt6hXJz8zP0N0BuNy9kGnVwkl4CH0vcAYvA+95x+X66IKIyP DVQlsPjcQ9PyCPVq4BAO4HadB+utUtir9aBQjZv1XVbSu+TE0B4XJgBGfFopbMop hh/awpWEJWMOYSIXY0GUNoUdx/bXO7hR59YTFC2BP0h6o4+Iu+HCS9oK8UWdAM6q vyxnn5++z5q4bXLP9iQn7WxVMUOcpQ7af9kk9DVTS7/w3jTTR59f/wPJFeQ== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxx2x8vhr-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:37 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-364edd430e6so4352102a91.2 for ; Mon, 04 May 2026 12:08:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921717; x=1778526517; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z+T7DF6d3yjuRFH4Z9NZjry6qzE7sW/NwEF2nzuN/uA=; b=ROXWmd5Z+FJang2QR02Ah1xlKz15TzJO0kLcHsgYXx1LGZyKaNIyI0f23x7e61VURB YAjF7ElHqhp9EozS3jiBSd9NSwbRM+ZZufFZ0/eYP8YZpTLfoQ+JY/t68+DcJXrzLEy+ CBp0gOMGrvjmmg6CkxQMY6OGXATW9tYObh7tEZMjZzs2g9YYaiUovqtfPVZwtyLEwHOO fd95q7NLfbD7FhtNbco/HOjXi4Vo8dp9rrV3XPDqNebuCGdcEatwkzT/Ix2sBf3m3Y30 H1Yp/9RZEVIK9Vr0JC4NU38TaqbEfnCNxC/nk/2h81WN/vhmRd/nbQ25KACW3DfQuvlr qBkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921717; x=1778526517; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Z+T7DF6d3yjuRFH4Z9NZjry6qzE7sW/NwEF2nzuN/uA=; b=GwQYi0spi7tp9rT/m+njLTq3HQyOck7XJhScc4ITXt3GijqAJwtclB0m4UAtdOHUmf 88QFceU5ff/pbiscrolOhM4CW2sapxjWqIoQMy/F57Y3T/2ndIemyLHO2lXXedPkvR8S G3Ethcc91O1vesSUCmJLyYc0HIjI9wDV2W7jLkiTMRJlJfLiSfIN02KLeJwoYWtmu8p8 ev1qmgKAfWevA9VZA68P0KYgtFefwlNy/ukL/brhYqjWG1/ITWRmkIINLPH4d89s6PNu XONO6i7WK9x0Ki4tth9S0t3q682dSEQ7qC1VrL+crwNSV+xDaLbmwg3qK0ZWlxi+kMG9 E1Bw== X-Forwarded-Encrypted: i=1; AFNElJ/cZc9ZlSut0wcWaDTTHKjlrFBhun8aBotjDjvrRQDl6xi/msKaID77C4NO+5DT0g30vu6qb3poPrx1nnI=@vger.kernel.org X-Gm-Message-State: AOJu0Yyc78kVsKjgoqMdaY8n97GdMVU6wqEn2hP7zfNJCl7vpkojHHot 1VK/rG0/fZQkpdqAIfXo3zRCmFE1AXmVfgOCJ+HdWqk9xqSPrOj2q8mRsIpzdL3vwCaYSZm8oks ofOc10UDedigzrKs/6nTWxDfaC72cLcYJOQlA8iqV3UlTs3nQjCj12jcsgHApL214h9EK6Uzis8 E= X-Gm-Gg: AeBDiet41c3NFhcbRCFwtL8jPlLt8EEJ8N1qWr9qdRpChtYB6CCUN/ny5FDDUt6resT U646m5PQIVCRIbx1YRZygsDPV1I95q3W3QKfGO+W3Aoe3M9E5z36jF1xRQCx7eq/60OFB8/BXjZ Dw1CQm/owrPcwMfmxcNEFD1xzc5mefj4plhw5KYhGMf4ZlM6VMR/+s8QcHr0+J0QijzL1EfSDU2 EH/JiBVXVv+B4EBdf9yeKIpZ0z1CoNS5MREkyBh28Quv051fjSZHh9mh8V3TnBLrIL6uJr9R/28 jhq9KIVZYCIO7JA5EPRvOyczGlalQ6VLRRYg/ywGPx0S+JXXkQAWRU0JAqd1tZIeVQPv7gzYIiK L5iOw0Nrs4q1Jun42DemDwSaUhZoO+tqDk1KQTpxL0QA= X-Received: by 2002:a17:90b:33ca:b0:35f:b1f3:ac12 with SMTP id 98e67ed59e1d1-3650cd08154mr10029722a91.4.1777921716645; Mon, 04 May 2026 12:08:36 -0700 (PDT) X-Received: by 2002:a17:90b:33ca:b0:35f:b1f3:ac12 with SMTP id 98e67ed59e1d1-3650cd08154mr10029689a91.4.1777921716094; Mon, 04 May 2026 12:08:36 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-364bdf2a71bsm15455932a91.1.2026.05.04.12.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:35 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Sean Paul , Konrad Dybcio , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 09/16] drm/msm: Add per-context perfcntr state Date: Mon, 4 May 2026 12:06:52 -0700 Message-ID: <20260504190751.61052-10-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=U9eiy+ru c=1 sm=1 tr=0 ts=69f8eeb5 cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=EUspDBNiAAAA:8 a=OtV_UDYxk2hhjaRdRjwA:9 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-ORIG-GUID: bkpiVGPEfxp9KMJVA5Bta61sBDS4lV2e X-Proofpoint-GUID: bkpiVGPEfxp9KMJVA5Bta61sBDS4lV2e X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfX5oVLbJa+LC3+ K9e9215GaPXV0yHnI85kP/Z6YzA53m/wMvQblubDV0hobgNjP2/pV2bx8d0fVZoYQL/ZDtR+MZh p4zl7/B1DR3gE/9/W0oiurzzF8gUrSOsP3hHYLMYYv2HxuaJMFtGPTpmETodh6S4i0qDvJmG4ps xOW61qgpo7PjK/Jfw5Cja+RDxQEMsI0M00hsrl/QEDovSTgMH6FZMilZA8pzXCZK8+f4QiZuuuK Dx69OQ8s6sPXhP2K/NVY0W1ACp0nwrL7XhxPoPcgiOArhckbflOUTFHmc7Txfj3SA9LlmZIkKTT w9yecWNPHFpsGOTalDIe5ir9v3pzssdAb3yEMEPUiMARW1ix5gCprpounPIvj0IUQdAHmS1hoVP UZEIiOWFD+BBpvemiEKBp9a88XaKyRhCJxWFNOVgA/pCTe8WULsud+pt5SLQL7DLR3Y53WETq6x KkzgSkBqj9eS6ZagPyQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 phishscore=0 spamscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" The upcoming PERFCNTR_CONFIG ioctl will allow for both global counter collection, and per-context counter reservation for local (ie. within a single GEM_SUBMIT ioctl) counter collection. Any number of contexts can reserve the same counters, but we will need to ensure that counters reserved for local counter collection do not conflict with counters used for global counter collection. So add tracking for per-context local counter reservations. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_gpu.h | 5 +++++ drivers/gpu/drm/msm/msm_perfcntr.h | 21 +++++++++++++++++++++ drivers/gpu/drm/msm/msm_submitqueue.c | 1 + 3 files changed, 27 insertions(+) diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 9e5c753437c2..19484774f369 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -434,6 +434,11 @@ struct msm_context { * this context. */ atomic64_t ctx_mem; + + /** + * @perfcntrs: Per-context reserved perfcntrs state + */ + struct msm_perfcntr_context_state *perfctx; }; =20 struct drm_gpuvm *msm_context_vm(struct drm_device *dev, struct msm_contex= t *ctx); diff --git a/drivers/gpu/drm/msm/msm_perfcntr.h b/drivers/gpu/drm/msm/msm_p= erfcntr.h index 64a5d29feba1..7f0654182496 100644 --- a/drivers/gpu/drm/msm/msm_perfcntr.h +++ b/drivers/gpu/drm/msm/msm_perfcntr.h @@ -35,6 +35,27 @@ struct msm_perfcntr_group { const struct msm_perfcntr_counter *counters; }; =20 +/** + * struct msm_perfcntr_context_state - per-msm_context counter state + * + * A given counter can either be unused, reserved for global counter + * collection exclusively, or reserved for local per-context counter + * collection inclusively. Multiple contexts can reserve the same + * counter, since SEL reg programming and counter begin/end sampling + * happen locally (within a single GEM_SUBMIT ioctl). + */ +struct msm_perfcntr_context_state { + /** @dummy: Some compilers dislike structs with only a flex array */ + unsigned dummy; + + /** + * @reserved_counters: + * + * The number of reserved counters indexed by perfcntr group. + */ + unsigned reserved_counters[]; +}; + extern const struct msm_perfcntr_group a6xx_perfcntr_groups[]; extern const unsigned a6xx_num_perfcntr_groups; =20 diff --git a/drivers/gpu/drm/msm/msm_submitqueue.c b/drivers/gpu/drm/msm/ms= m_submitqueue.c index 2598d674a99d..a58fe41602c6 100644 --- a/drivers/gpu/drm/msm/msm_submitqueue.c +++ b/drivers/gpu/drm/msm/msm_submitqueue.c @@ -66,6 +66,7 @@ void __msm_context_destroy(struct kref *kref) drm_gpuvm_put(ctx->vm); kfree(ctx->comm); kfree(ctx->cmdline); + kfree(ctx->perfctx); kfree(ctx); } =20 --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 091493F0748 for ; Mon, 4 May 2026 19:08:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921724; cv=none; b=JK4S5r/vPdMWiQpGO+uZOuZxZF4sQPTkACTNd5Wy7RorPVYe3IP63c9NlEEZ8tAN0IP0Y2XgMjE4Q9xFT8vuqACK100UPydoZrKTsTxxObHDlJ6rotFnnayZNVjCTplQDYolFCzGK9A57WnE5cmMWZ/sfZQXTJYZULPr3tyD3Rw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921724; c=relaxed/simple; bh=YfwF72A26xQIgnm636RdmNO/o1nQSq51T4AIXz8sygU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XsvTxr0DmmUUHTVgdDO5q6iFZQs+KkrF2drzt/4IXI5qBtEDMOHRFDusEnVRmjqDE7lDO/3L6cnSgI+CPBINMrMUQQz2yepQ0O4at7+eMg7hGm190J4eVsxfYCIsY+SHzwVWx0iQrwZ0ULyXU2u8zJsz3vo4NM6pMUVeNRLDpEA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=B/B9Mp5c; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=jvK/Oh6g; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="B/B9Mp5c"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="jvK/Oh6g" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644IDWot749422 for ; Mon, 4 May 2026 19:08:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=oXRxDAUX39B YpjgioMxBEHD8AgKubH5XAXMjQerhyrE=; b=B/B9Mp5cBtdGZdbvuJMAwazFEFw GKuIeZ96aNT+IMr9ijuUKw87gbS+bPmDfoyauTHDfyq/PBibRtU/Jjy0skMhxeOw hEi/gn0l1nGxHM2vUr64PiKsyqg1jNryuH1AC0WdikBk0pUzwX4lYe6oyC6ApRiP ZhkrSE44FFqWK9t74/0F+F9O7TvCGhAUoxXwA0dn5yj0vZDayIboKTL/c3DUZAmu XZg9GSDPW8vCJt6EaHH1tSIS7tIItKKfPVFe1YqkLxPhKNbPT1VtLThmGKxDjOAz rRQUeUIbmRORTSpRRYnV7VTE4AoBDqK4ZuhpJz8bBBjDbME0sw01rhgCCLA== Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxscf1xed-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:40 +0000 (GMT) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-c6e24ee93a6so2828335a12.0 for ; Mon, 04 May 2026 12:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921720; x=1778526520; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oXRxDAUX39BYpjgioMxBEHD8AgKubH5XAXMjQerhyrE=; b=jvK/Oh6gUEz0gKVsBzRUqUDKcS+exuCaMfE6g8/X9/HRriOTaMsCvR6CKCc7zpBGZW NIQZMj+Q0PA04Gxdv7bk/ad+q2lUpn3VTHYgN9XjttNGRciLTZUZ/JqJ7JZwTfJldJH6 WUUUgitKykKP4IsF3pmHH1F9vDymLPe3QUroRDMqvQaefvJAiwzrhUnVGQgpWrgjBhvn kHkOs5ZAIm2kMLWBdERDOePXiHp8Uuuncm/r55DpF0f9o01P7L+QTx+jMfovcnHNEofu UFhmJYiBBzVt6BHZ7thtgiAFUsH2kAVhV6XxsblL1n0RogLO2FgGaUajXIUB+0z2NPHj IRBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921720; x=1778526520; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=oXRxDAUX39BYpjgioMxBEHD8AgKubH5XAXMjQerhyrE=; b=E6nsWTG4bFvfjThgxVsdX4DGysbW5jJI7+BjfDQUtFVmxwjQwCadxNXWmJ09hkS9N0 gweYPgV/MQurPvf4SLXDknLkzKkuasjdsOz8ORevs0LOz5LTDBJw6spAAbG4oDlmcP6I Otu0va+dSQcughlyzsj0ttekGKC4jyY3vC5IfNcXft8fJbdvlS3lJ+UkY5Wx6ZqlfcrZ 3EP3Ug+OxF0nA1Xv3f/3UBLDK1Xt4ZOMwNdCV24UI5hOdzECC+EOf6tC5niKRivVMv9c L+hJ/vRkfBTEAWQQULxdC9Ng7iG6r8AgSLfIyDtgnowLNastzvw/5cfWardPTCAG8/Wc 5JLw== X-Forwarded-Encrypted: i=1; AFNElJ+57zCeWEG0gWJaqNzRhLuHhClwuHrWTM2F8tY/YwzFd4xnFtlmgDAQwMkCNdf6IlruZyYl5FLWKgb7xY8=@vger.kernel.org X-Gm-Message-State: AOJu0YygeRYuo+EZG8ayPN0JvgOh7zVi5KWqSR2WZ3utXZCD7dZtRanT sPi2uOYCMzftCrYrMYEWSShLPT8pdiY40HhSmGjFptOHPuE/wd/zymR6pIsL73AF6pvB4FeqJS6 kHn6rOOxWKa1XDFR/Eki8GxnKaCp1XHNKOeU8DsTNseXtWwAcbdNXcJtWuzOT+EoL/pc= X-Gm-Gg: AeBDiev9rMHg+X/0d2CC8kMHefLyPOHR4jCc3YWfJAJfRxYtAkkdgUz9lYRgZFujLgd wXiisv9X0+cvQ8JcBxyID4ZRdLctJwYq3Om2G6LIzN8Ib2vXAEYF8GRoFCpliss1Sh+CTMQaHhK VTbWOH0ay1Hm6e5l/sTcGBYr7lDF0peKIIPlhhdYBpCnl0ZjW3KacfTluVIuANosJthjVm3peQ7 XXeVHFz28ChvQ9i4t89Myd1njXG9m7UYxZZTr2maAlfQ1T1cjNNlwiISOyWUl5y0glGrpx55DRb WJcxXy2lEZ0TtdBIt+LbCnlcno/A8VCqJceDhX1klCU1oqs3ZpAlZL4pa9mPzrOQXrwLYnTcwkq hU/dLwg3i3GYcAIPlAHRwhWqkwEbpkV8JG/QUW8dWpKw= X-Received: by 2002:a05:6a20:7489:b0:3a0:b65a:5df5 with SMTP id adf61e73a8af0-3a9f771bb4cmr586617637.30.1777921719719; Mon, 04 May 2026 12:08:39 -0700 (PDT) X-Received: by 2002:a05:6a20:7489:b0:3a0:b65a:5df5 with SMTP id adf61e73a8af0-3a9f771bb4cmr586582637.30.1777921718997; Mon, 04 May 2026 12:08:38 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7ffbc6f042sm10654308a12.21.2026.05.04.12.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:38 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , David Airlie , Simona Vetter , Konrad Dybcio , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 10/16] drm/msm: Add basic perfcntr infrastructure Date: Mon, 4 May 2026 12:06:53 -0700 Message-ID: <20260504190751.61052-11-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=BcvoFLt2 c=1 sm=1 tr=0 ts=69f8eeb9 cx=c_pps a=rz3CxIlbcmazkYymdCej/Q==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=EUspDBNiAAAA:8 a=hddbS_E73Iye693R-v0A:9 a=bFCP_H2QrGi7Okbo017w:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfX9BwvBN4qn7Hc vMrQfhOe1ItiMV6TksIlUNU4YXbjZ5LZKhfk3STfoauuuUIRXtXymJsmMiJ7g808oza1EsgLwoQ PbwgsbPHVrwgBTtU4RG18ce0iIXOqRMyF8xZ5748S680XpkHjm6fbU3XW/mIy3XZCafztxxK/wD fMqaxs0BLUoNC2NK7Fn3jStJSSu8NiQBss7FHL3vec0J6ZSP8hDYK8x5JkDlGqMsOihtwcAZxrv EsUfgqbRuPuJDRp4RySheCflqwXZorpQPxYqUuqty/Ur9EHD0CVCzl2Q1uEp8bCOJokb0IeNNqU wxf4zKvas3xnZs/0lS56ucrvyNgO6yCDKSq9bY7LESQxzUDJqe5wBZsnxuWO6hQeFWgOH8Mr6du y5FvWQwShFi8FpPmtDMuyrJJgKLi4L/84nDib3m24AAIUmha46g0aFs11ughCrYY5hjnX5Jtbja y4eu4bCGqa5Zl8W3acA== X-Proofpoint-ORIG-GUID: Sl8ff-33hHAfwRl1Q8WIqZuT6r63Iav8 X-Proofpoint-GUID: Sl8ff-33hHAfwRl1Q8WIqZuT6r63Iav8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 suspectscore=0 spamscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 bulkscore=0 adultscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" Add the basic infrastructure for tracking assigned perfcntrs. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/Makefile | 1 + drivers/gpu/drm/msm/adreno/adreno_device.c | 8 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 5 +- drivers/gpu/drm/msm/msm_drv.h | 6 ++ drivers/gpu/drm/msm/msm_gpu.c | 12 +++ drivers/gpu/drm/msm/msm_gpu.h | 57 +++++++++- drivers/gpu/drm/msm/msm_perfcntr.c | 120 +++++++++++++++++++++ drivers/gpu/drm/msm/msm_perfcntr.h | 23 ++++ 8 files changed, 226 insertions(+), 6 deletions(-) create mode 100644 drivers/gpu/drm/msm/msm_perfcntr.c diff --git a/drivers/gpu/drm/msm/Makefile b/drivers/gpu/drm/msm/Makefile index 337634e7e247..2466cb32dac5 100644 --- a/drivers/gpu/drm/msm/Makefile +++ b/drivers/gpu/drm/msm/Makefile @@ -122,6 +122,7 @@ msm-y +=3D \ msm_gpu_devfreq.o \ msm_io_utils.o \ msm_iommu.o \ + msm_perfcntr.o \ msm_rd.o \ msm_ringbuffer.o \ msm_submitqueue.o \ diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/m= sm/adreno/adreno_device.c index fc38331ce640..7f20320ef66a 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_device.c +++ b/drivers/gpu/drm/msm/adreno/adreno_device.c @@ -307,8 +307,10 @@ MODULE_DEVICE_TABLE(of, dt_match); static int adreno_runtime_resume(struct device *dev) { struct msm_gpu *gpu =3D dev_to_gpu(dev); - - return gpu->funcs->pm_resume(gpu); + int ret =3D gpu->funcs->pm_resume(gpu); + if (!ret) + ret =3D msm_perfcntr_resume(gpu); + return ret; } =20 static int adreno_runtime_suspend(struct device *dev) @@ -322,6 +324,8 @@ static int adreno_runtime_suspend(struct device *dev) */ WARN_ON_ONCE(gpu->active_submits); =20 + msm_perfcntr_suspend(gpu); + return gpu->funcs->pm_suspend(gpu); } =20 diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/= adreno/adreno_gpu.c index 72b71e9e44f0..ee0bcf985934 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c @@ -702,11 +702,10 @@ void adreno_recover(struct msm_gpu *gpu) struct drm_device *dev =3D gpu->dev; int ret; =20 - // XXX pm-runtime?? we *need* the device to be off after this - // so maybe continuing to call ->pm_suspend/resume() is better? - + msm_perfcntr_suspend(gpu); gpu->funcs->pm_suspend(gpu); gpu->funcs->pm_resume(gpu); + msm_perfcntr_resume(gpu); =20 ret =3D msm_gpu_hw_init(gpu); if (ret) { diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index e53e4f220bed..f00b2e7aeb91 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -235,6 +235,12 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void = *data, int msm_ioctl_vm_bind(struct drm_device *dev, void *data, struct drm_file *file); =20 +int msm_perfcntr_resume(struct msm_gpu *gpu); +void msm_perfcntr_suspend(struct msm_gpu *gpu); + +struct msm_perfcntr_state * msm_perfcntr_init(struct msm_gpu *gpu); +void msm_perfcntr_cleanup(struct msm_gpu *gpu); + #ifdef CONFIG_DEBUG_FS unsigned long msm_gem_shrinker_shrink(struct drm_device *dev, unsigned lon= g nr_to_scan); #endif diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index 1bac70473f80..bf6845e5719e 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -1028,6 +1028,17 @@ int msm_gpu_init(struct drm_device *drm, struct plat= form_device *pdev, =20 refcount_set(&gpu->sysprof_active, 1); =20 + mutex_init(&gpu->perfcntr_lock); + + if (gpu->num_perfcntr_groups > 0) { + gpu->perfcntrs =3D msm_perfcntr_init(gpu); + if (IS_ERR(gpu->perfcntrs)) { + ret =3D PTR_ERR(gpu->perfcntrs); + gpu->perfcntrs =3D NULL; + goto fail; + } + } + return 0; =20 fail: @@ -1066,6 +1077,7 @@ void msm_gpu_cleanup(struct msm_gpu *gpu) } =20 msm_devfreq_cleanup(gpu); + msm_perfcntr_cleanup(gpu); =20 platform_set_drvdata(gpu->pdev, NULL); } diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 19484774f369..92710da5009b 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -25,6 +25,7 @@ struct msm_gem_vm_log_entry; struct msm_gpu_state; struct msm_context; struct msm_perfcntr_group; +struct msm_perfcntr_stream; =20 struct msm_gpu_config { const char *ioname; @@ -93,6 +94,13 @@ struct msm_gpu_funcs { */ bool (*progress)(struct msm_gpu *gpu, struct msm_ringbuffer *ring); void (*sysprof_setup)(struct msm_gpu *gpu); + + /* Configure perfcntr SELect regs: */ + void (*perfcntr_configure)(struct msm_gpu *gpu, struct msm_ringbuffer *ri= ng, + const struct msm_perfcntr_stream *stream); + + /* Flush perfcntrs before reading (optional): */ + void (*perfcntr_flush)(struct msm_gpu *gpu); }; =20 /* Additional state for iommu faults: */ @@ -266,6 +274,11 @@ struct msm_gpu { =20 const struct msm_perfcntr_group *perfcntr_groups; unsigned num_perfcntr_groups; + + struct msm_perfcntr_state *perfcntrs; + + /** @perfcntr_lock: protects perfcntr related state */ + struct mutex perfcntr_lock; }; =20 static inline struct msm_gpu *dev_to_gpu(struct device *dev) @@ -311,10 +324,52 @@ static inline bool msm_gpu_active(struct msm_gpu *gpu) return false; } =20 +/** + * struct msm_perfcntr_group_state - Tracking for the currently allocated = counter state + */ +struct msm_perfcntr_group_state { + /** + * @allocated_counters: + * + * allocated counters for global counter collection. The + * corresponding counters are allocated from highest to + * lowest, to minimize chance of conflict with old userspace + * allocating from lowest to highest. + */ + unsigned allocated_counters; + + /** + * @countables: + * + * The correspnding SELect reg values for the allocated counters + */ + uint32_t countables[]; +}; + +/** + * struct msm_perfcntr_state - overall global perfcntr state + */ +struct msm_perfcntr_state { + /** @stream: current global counter stream if active */ + struct msm_perfcntr_stream *stream; + + /** + * @groups: Global perfcntr stream group state. + * + * Conceptually this is part of msm_perfcntr_stream state, but is + * statically pre-allocated when the gpu is initialized to simplify + * error path cleanup in PERFCNTR_CONFIG ioctl. (__free(kfree) + * doesn't really help with variable length arrays of allocated + * pointers.) + */ + struct msm_perfcntr_group_state *groups[]; +}; + static inline bool msm_gpu_sysprof_no_perfcntr_zap(struct msm_gpu *gpu) { - return refcount_read(&gpu->sysprof_active) > 1; + return (refcount_read(&gpu->sysprof_active) > 1) || + READ_ONCE(gpu->perfcntrs->stream); } =20 static inline bool diff --git a/drivers/gpu/drm/msm/msm_perfcntr.c b/drivers/gpu/drm/msm/msm_p= erfcntr.c new file mode 100644 index 000000000000..09e6aa4b6620 --- /dev/null +++ b/drivers/gpu/drm/msm/msm_perfcntr.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + */ + +#include "msm_drv.h" +#include "msm_gpu.h" +#include "msm_perfcntr.h" + +static int +msm_perfcntr_resume_locked(struct msm_perfcntr_stream *stream) +{ + return 0; +} + +int +msm_perfcntr_resume(struct msm_gpu *gpu) +{ + guard(mutex)(&gpu->perfcntr_lock); + return msm_perfcntr_resume_locked(gpu->perfcntrs->stream); +} + +static void +msm_perfcntr_suspend_locked(struct msm_perfcntr_stream *stream) +{ +} + +void +msm_perfcntr_suspend(struct msm_gpu *gpu) +{ + guard(mutex)(&gpu->perfcntr_lock); + msm_perfcntr_suspend_locked(gpu->perfcntrs->stream); +} + +/** + * msm_perfcntr_group_idx - map idx of perfcntr group to group_idx + * @stream: The global perfcntr stream + * @n: The requested group_idx + * + * The PERFCNTR_CONFIG ioctl requested N counters/countables per perfcntr + * group, but the order of groups is not required to match the order they + * are defined in the perfcntr tables (which is not stable/UABI, only the + * group names are UABI). + * + * But the order samples are returned in the stream should match the + * order they are requested in the PERFCNTR_CONFIG ioctl. This helper + * handles the order remapping. + * + * Returns an index into gpu->perfcntr_groups[] and perfcntrs->groups[]. + */ +uint32_t +msm_perfcntr_group_idx(const struct msm_perfcntr_stream *stream, uint32_t = n) +{ + WARN_ON_ONCE(n > stream->nr_groups); + return stream->group_idx[n]; +} + +/** + * msm_perfcntr_counter_base - get idx of the first counter in group + * @stream: The global perfcntr stream + * @group_idx: the index of the counter group + * + * For global counter collection, counters are allocated from the end + * (last counter) to minimize the chance of conflict with an old UMD + * which predates PERFCNTR_CONFIG ioctl (since UMD assigned from 0..N-1). + * + * Returns the index of first counter to use. An index into + * msm_perfcntr_group::counters[]. + */ +uint32_t +msm_perfcntr_counter_base(const struct msm_perfcntr_stream *stream, uint32= _t group_idx) +{ + struct msm_gpu *gpu =3D stream->gpu; + struct msm_perfcntr_state *perfcntrs =3D gpu->perfcntrs; + unsigned num_counters =3D gpu->perfcntr_groups[group_idx].num_counters; + unsigned allocated_counters =3D perfcntrs->groups[group_idx]->allocated_c= ounters; + + return num_counters - allocated_counters; +} + +struct msm_perfcntr_state * +msm_perfcntr_init(struct msm_gpu *gpu) +{ + struct msm_perfcntr_state *perfcntrs; + struct device *dev =3D &gpu->pdev->dev; + size_t sz; + + sz =3D struct_size(perfcntrs, groups, gpu->num_perfcntr_groups); + perfcntrs =3D devm_kzalloc(dev, sz, GFP_KERNEL); + if (!perfcntrs) + return ERR_PTR(-ENOMEM); + + for (unsigned i =3D 0; i < gpu->num_perfcntr_groups; i++) { + const struct msm_perfcntr_group *group =3D + &gpu->perfcntr_groups[i]; + + sz =3D struct_size(perfcntrs->groups[i], countables, group->num_counters= ); + perfcntrs->groups[i] =3D devm_kzalloc(dev, sz, GFP_KERNEL); + if (!perfcntrs->groups[i]) { + msm_perfcntr_cleanup(gpu); + return ERR_PTR(-ENOMEM); + } + } + + return perfcntrs; +} + +void +msm_perfcntr_cleanup(struct msm_gpu *gpu) +{ + struct msm_perfcntr_state *perfcntrs =3D gpu->perfcntrs; + struct device *dev =3D &gpu->pdev->dev; + + gpu->perfcntrs =3D NULL; + + for (unsigned i =3D 0; i < gpu->num_perfcntr_groups; i++) + devm_kfree(dev, perfcntrs->groups[i]); + + devm_kfree(dev, perfcntrs); +} diff --git a/drivers/gpu/drm/msm/msm_perfcntr.h b/drivers/gpu/drm/msm/msm_p= erfcntr.h index 7f0654182496..bfda19e01535 100644 --- a/drivers/gpu/drm/msm/msm_perfcntr.h +++ b/drivers/gpu/drm/msm/msm_perfcntr.h @@ -35,6 +35,29 @@ struct msm_perfcntr_group { const struct msm_perfcntr_counter *counters; }; =20 +/** + * struct msm_perfcntr_stream - state for a single open stream fd + */ +struct msm_perfcntr_stream { + /** @gpu: Back-link to the GPU */ + struct msm_gpu *gpu; + + /** @nr_groups: # of counter groups with enabled counters */ + uint32_t nr_groups; + + /** + * @group_idx: array of nr_groups + * + * Maps the order of groups in PERFCNTR_CONFIG ioctl to group idx, + * so that results in the results stream can be ordered to match + * the ioctl call that setup the stream + */ + uint32_t *group_idx; +}; + +uint32_t msm_perfcntr_group_idx(const struct msm_perfcntr_stream *stream, = uint32_t n); +uint32_t msm_perfcntr_counter_base(const struct msm_perfcntr_stream *strea= m, uint32_t group_idx); + /** * struct msm_perfcntr_context_state - per-msm_context counter state * --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3ED03F0763 for ; Mon, 4 May 2026 19:08:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921726; cv=none; b=HalhQ8pWEwFjaASpKYxuAfcA0auvIBQcbHYW7A9d8LcrlzmskxqLj1f7Xu/soaP74z8YI8jOYfrOjs0JCMdra3ebxI+IEH6QPUyKdhTv/v095hJ96wPC5H6Q/Z1JP1KRetWduzvo6vbkWq+A4ofE7bGjWYweCBlukAIBPUcsPUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921726; c=relaxed/simple; bh=54SiiwIiDu5jCiPVBfargkA8Cq4AMd5thtK2yJft994=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Q1ZwSW7zbNJX8Rmt3w0ehVA67qRzRAQdN4Qq8l06XTOSquI14vdV6Ue2Em9vLsKzJOjxaXsGBbWNtEBcNL8T1QnpYpLb2xhksh2Elsk6cwX2KMV1G7S/QRyfrEYu44CRmi+O4pLWVVLapylOY8qXJJBqcW2tGFjHPWdl8C/bSq8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=Wn3GBvrJ; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=J2B5GD8q; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="Wn3GBvrJ"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="J2B5GD8q" Received: from pps.filterd (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644IEIDZ636667 for ; Mon, 4 May 2026 19:08:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=OJPIWHLYmtY h2vRJzlQwHbA8ExzYkFh40ePWlyvRs1s=; b=Wn3GBvrJzKSU9RwPkJUnX9CvYv4 LBGfMEj28DgRQPt+MQRkcO+OOqdA3DPaDEjXUzI8yo5qKovmxudQVpJQRMUaDZvB Bizim9nhsSpEPWg64aad8u4Rwd5veR7kkBsQroiTO3qn803U3Y8A2GIZ3w1UGMdD rMgDbipMc5XoOVlE0H3oe70SpFt3F5aFghXpL+yhoNOEs53949ByDth7wG3LM3Gr Oh3EWai9ZxDLKRN1oUkZZzhM8OA+v/Q8uQjAcTG1u+HmBCbz7YjzYXy8x711REnk b5n556S0nOLVzavKLLKL+HNoTP15w8ZwoAApLP5Lw3tD9O/fQeBz1twf77Q== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxsx49t5q-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:42 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2b7aba0af02so43403175ad.2 for ; Mon, 04 May 2026 12:08:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921722; x=1778526522; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OJPIWHLYmtYh2vRJzlQwHbA8ExzYkFh40ePWlyvRs1s=; b=J2B5GD8qiUKX6vnEcUzPEDBEzjQvMLHFlo82/BM04H1hDhT6Ha2uJDAi2MjjiqxVGQ qPdU51sl0YftBpdkO+W/Y7EFPKS8c4xBE0g8MAo4EqIM3nZflOSstfS687zQVW3h/zKL HRKcyl/Jd9QdgoKeVy/5Qzz4C9ZBhQxmXnU9h8HBjFIOn8TGI6YG4Irm+ECz+/XjNLrM o/kThbslip4JgxSMEvOqM5kaAcOWUGT0NiOSMcL6E4wKdgLb6V8WNYfVbtSZbmxCqC0Q 9yzvkjOJa9vN05OzJzu6lNr+DSfNOrNavHD6HPsWFqZ05zFg/DXQVyTpJu9sO5d8tskO GRjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921722; x=1778526522; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=OJPIWHLYmtYh2vRJzlQwHbA8ExzYkFh40ePWlyvRs1s=; b=giQFrmXtgqlINb3mPJhuc1FKd9Ftr6TiK5OeLQNpR1hEfDqFliIcvDnDX9Q0zHJjU2 uaEDfA1XzZAi9gbp7Jhm4loBNby2ckysJUX1gltxxfr9ceSpxBRWXd9etEmpHbXCtLPS 0U9fCCR3bGgezdDcW6Ue37KVbQFkg6sg1n7I/xkuoJNPA4SnEcofbBwdGXFSawfmKhgd iFkN0R9QMnPUBFWSWtrZdvZJYBeDagF4PNvgCFX60NTb2vs/E2jCsLzfuRQ3XE2UcFWk BlQ8Ha6YTJi+Rcqr5KPEHtaiB3YNFdsIZomGwMzCgyBzaBL4YjqxRi7PAL8woklR+Py5 hU0A== X-Forwarded-Encrypted: i=1; AFNElJ8zmUhHs866g3/aBmUGe+Fayq/X7qSMK2JZrXMXvUhmdeYZoHYO79ODpWkW1ENqzC8JuflEXWpud8dlDlM=@vger.kernel.org X-Gm-Message-State: AOJu0YxCSuDyASf3kpwTVC6AbjYnVCXGEPyADTzrd8ImLW+TemICA2P0 nuclc6UpAYpV8ueh9DwcgPgCOv23N9XOJU/nzhjbxAvXkNty4qygbxQvhR1ttjzZmu6S8LNpWIW RA6C+ogpRS8T7Y0ZBhlQXPJBcp26/D1aGR74GeutrPe0UF0PsRPKqPFIv/XxuE4BafKU= X-Gm-Gg: AeBDievkOXdtsm6buYdm282vmSmmgiREB5ZPektEpsAlloTO/pYDjPyPEbKeD/sCOPN gh6hgXsV0Q33Jb/hpP8kd0BxEBzBP5PMp05rUHg7uX1hwTU06RAKOtBGAzLBp+C/I4jB7jCxXn8 kwqcDuangefABzrXGpE4NZtI4wrlSEUv3HbHvgTcAqfnGpjuZ84Ks0Dz/bsvcFba+nI98Xki+bj ew4246p6TzjSYkF6bS6CIeizSPizOL4ImjWDO2thX3aGMy4IAhWy0gqEmbeBV1zHzZ6lNL6jyu7 p6a++KRZuP0Ameaz0JnKvPXlc3M//h6YXJZMbP04vvq0PckxwLc7hnXfZ8fhZYveRh98Qf6VoVq 7CI/zeP6S2ji/WixOtOKBYxoilWhwqODIBq3vZdrwztU= X-Received: by 2002:a05:6a20:2589:b0:3a3:90d8:fd7f with SMTP id adf61e73a8af0-3a7f1ad4c45mr11338467637.8.1777921721582; Mon, 04 May 2026 12:08:41 -0700 (PDT) X-Received: by 2002:a05:6a20:2589:b0:3a3:90d8:fd7f with SMTP id adf61e73a8af0-3a7f1ad4c45mr11338418637.8.1777921720906; Mon, 04 May 2026 12:08:40 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7ffbcaa477sm10418922a12.31.2026.05.04.12.08.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:40 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Sean Paul , Konrad Dybcio , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 11/16] drm/msm/a6xx+: Add support to configure perfcntrs Date: Mon, 4 May 2026 12:06:54 -0700 Message-ID: <20260504190751.61052-12-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfX16/6AH30yQJi QEhouSK5XWZdq71uWcL4rrWR0lIZ7BPJSwPhaG35L344xp0xlP5AfyETCCqEQomNpaUJGQn/s9K xJ6dg5HgOuboqlEHnMcAszTik5UzRD+awRjN/3Ofuejfmce4dstQ4JdoGE/8/9axxIX15A0kePd GmejM+1SUBmic2seWLsksZDxB9arOOq1S/LSV5m1VREv/wh7Ewn7a9Ie7jvcK0IJsRg+H83aFie xdb60wD3UA7Nlzxaje0NBNWxUGrvl9Jmg3tLitRlDijoiPJTU2n3Wo1c/WGdAFOSJjFkbsx/nNE A2o69Ye0+iO//hN6R3QPisEoThsOKHCMjG3+d/GyvDDM1sX8HHDrzI+g1Lug0tAHxo+GOziYAU2 tooVb4G1Q2oriAv6TE2teMrKzZs+aXkLUUQ9I1/XIkRNgIzIQJmadh+w7f5nbDw2WZKVof6OEsk r8ewDCQ07qPML+0SJgQ== X-Proofpoint-ORIG-GUID: v_6QK2g2PGJjQiTqwFyA9Yaa-sGl03eF X-Proofpoint-GUID: v_6QK2g2PGJjQiTqwFyA9Yaa-sGl03eF X-Authority-Analysis: v=2.4 cv=LdIMLDfi c=1 sm=1 tr=0 ts=69f8eeba cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=oWecmCczN8450n14xlQA:9 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 suspectscore=0 impostorscore=0 malwarescore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" Add support to configure counter SELect regs. In some cases the reg writes need to happen while the GPU is idle. And for a7xx+, in some cases SEL regs need to be configured from BV or BR aperture. The easiest way to deal with this is to configure from the RB. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 69 +++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_perfcntr.h | 3 ++ drivers/gpu/drm/msm/msm_ringbuffer.h | 2 + 3 files changed, 74 insertions(+) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a6xx_gpu.c index 415902f6e5d7..30df9bfa9ef8 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -2535,6 +2535,71 @@ static bool a6xx_progress(struct msm_gpu *gpu, struc= t msm_ringbuffer *ring) return progress; } =20 +static void +a6xx_perfcntr_configure(struct msm_gpu *gpu, struct msm_ringbuffer *ring, + const struct msm_perfcntr_stream *stream) +{ + enum adreno_pipe pipe =3D PIPE_NONE; + + for (unsigned i =3D 0; i < stream->nr_groups; i++) { + unsigned group_idx =3D msm_perfcntr_group_idx(stream, i); + unsigned base =3D msm_perfcntr_counter_base(stream, group_idx); + + const struct msm_perfcntr_group *group =3D + &gpu->perfcntr_groups[group_idx]; + + struct msm_perfcntr_group_state *group_state =3D + gpu->perfcntrs->groups[group_idx]; + + if (group->pipe !=3D pipe) { + pipe =3D group->pipe; + + OUT_PKT7(ring, CP_THREAD_CONTROL, 1); + + if (pipe =3D=3D PIPE_BR) { + OUT_RING(ring, CP_SET_THREAD_BR); + } else if (pipe =3D=3D PIPE_BV) { + OUT_RING(ring, CP_SET_THREAD_BV); + } else { + OUT_RING(ring, CP_SET_THREAD_BOTH); + } + } + + const struct msm_perfcntr_counter *counter =3D &group->counters[base]; + unsigned nr =3D group_state->allocated_counters; + OUT_PKT4(ring, counter->select_reg, nr); + for (unsigned c =3D 0; c < nr; c++) + OUT_RING(ring, group_state->countables[c]); + + for (unsigned s =3D 0; s < ARRAY_SIZE(counter->slice_select_regs); s++) { + if (!counter->slice_select_regs[s]) + break; + + OUT_PKT4(ring, counter->slice_select_regs[s], nr); + for (unsigned c =3D 0; c < nr; c++) + OUT_RING(ring, group_state->countables[c]); + } + } + + if (pipe !=3D PIPE_NONE) { + OUT_PKT7(ring, CP_THREAD_CONTROL, 1); + OUT_RING(ring, CP_SET_THREAD_BOTH); + } + + OUT_PKT7(ring, CP_MEM_WRITE, 3); + OUT_RING(ring, lower_32_bits(rbmemptr(ring, perfcntr_fence))); + OUT_RING(ring, upper_32_bits(rbmemptr(ring, perfcntr_fence))); + OUT_RING(ring, stream->sel_fence); + + a6xx_flush_yield(gpu, ring); + + /* Check to see if we need to start preemption */ + if (adreno_is_a8xx(to_adreno_gpu(gpu))) + a8xx_preempt_trigger(gpu); + else + a6xx_preempt_trigger(gpu); +} + static u32 fuse_to_supp_hw(const struct adreno_info *info, u32 fuse) { if (!info->speedbins) @@ -2753,6 +2818,7 @@ const struct adreno_gpu_funcs a6xx_gpu_funcs =3D { .get_rptr =3D a6xx_get_rptr, .progress =3D a6xx_progress, .sysprof_setup =3D a6xx_gmu_sysprof_setup, + .perfcntr_configure =3D a6xx_perfcntr_configure, }, .init =3D a6xx_gpu_init, .get_timestamp =3D a6xx_gmu_get_timestamp, @@ -2786,6 +2852,7 @@ const struct adreno_gpu_funcs a6xx_gmuwrapper_funcs = =3D { .create_private_vm =3D a6xx_create_private_vm, .get_rptr =3D a6xx_get_rptr, .progress =3D a6xx_progress, + .perfcntr_configure =3D a6xx_perfcntr_configure, }, .init =3D a6xx_gpu_init, .get_timestamp =3D a6xx_get_timestamp, @@ -2822,6 +2889,7 @@ const struct adreno_gpu_funcs a7xx_gpu_funcs =3D { .get_rptr =3D a6xx_get_rptr, .progress =3D a6xx_progress, .sysprof_setup =3D a6xx_gmu_sysprof_setup, + .perfcntr_configure =3D a6xx_perfcntr_configure, }, .init =3D a6xx_gpu_init, .get_timestamp =3D a6xx_gmu_get_timestamp, @@ -2852,6 +2920,7 @@ const struct adreno_gpu_funcs a8xx_gpu_funcs =3D { .get_rptr =3D a6xx_get_rptr, .progress =3D a8xx_progress, .sysprof_setup =3D a6xx_gmu_sysprof_setup, + .perfcntr_configure =3D a6xx_perfcntr_configure, }, .init =3D a6xx_gpu_init, .get_timestamp =3D a8xx_gmu_get_timestamp, diff --git a/drivers/gpu/drm/msm/msm_perfcntr.h b/drivers/gpu/drm/msm/msm_p= erfcntr.h index bfda19e01535..14506bc37d05 100644 --- a/drivers/gpu/drm/msm/msm_perfcntr.h +++ b/drivers/gpu/drm/msm/msm_perfcntr.h @@ -45,6 +45,9 @@ struct msm_perfcntr_stream { /** @nr_groups: # of counter groups with enabled counters */ uint32_t nr_groups; =20 + /** @sel_fence: Fence for SEL reg programming */ + uint32_t sel_fence; + /** * @group_idx: array of nr_groups * diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.h b/drivers/gpu/drm/msm/msm= _ringbuffer.h index d1e49f701c81..28ca8c9f7463 100644 --- a/drivers/gpu/drm/msm/msm_ringbuffer.h +++ b/drivers/gpu/drm/msm/msm_ringbuffer.h @@ -37,6 +37,8 @@ struct msm_rbmemptrs { volatile struct msm_gpu_submit_stats stats[MSM_GPU_SUBMIT_STATS_COUNT]; volatile u64 ttbr0; volatile u32 context_idr; + + volatile u32 perfcntr_fence; }; =20 struct msm_cp_state { --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 574A73F0A94 for ; Mon, 4 May 2026 19:08:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921727; cv=none; b=A6eacFAx2bHFA+jX3P0rrNiL7plZRN9GNbpEQ4cj04WJ0ddO5IByoI944Fs8BRidhvXbUTWCQE2j3tBOfCtP8LAWxaUDLC9M+3ZAY5irriLwqgg4ZId/tt/1IFGnRK/8AyQOQxQLbSkdMM05fQeWzFlTqfr2R1wcKHUsgRCRWkc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921727; c=relaxed/simple; bh=CjOeIMd7KHhgBlYgalqgDMr3CrElSHV/LHeYqaaaD9g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Hjl7rBBX0HrKZ+vqyn/RGF/yz8B0xpFE9DVGqoLHND+qSf8jRQfPPl61R8/c0EkK8pJsOL4EnTsJ0E0It71Wf7dSf4+bdbIMVEWlg98zTt5t0oMcXL2ZxzjdTBxbxbOuk2nM2Hwpf7FW2d7oB76PgGGI7SXred+LXqRpSZltVBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=VS92g3on; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=KTTi5yIb; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="VS92g3on"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="KTTi5yIb" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644FIVZo3409256 for ; Mon, 4 May 2026 19:08:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=zVhhihIWGcW DVKhVXioxlxo4w1o6vj94DNJvO2XJTbI=; b=VS92g3onfef2nfVAYVBljos5ZSe X+uND9pTg4qVUdPXXP9ZQaKQzZgKdEhoj0IYG1kWx5JcW2KKdnV3DoLU3oJnIDo+ D54RY+hvxrrfe3kc8dwVTigLN/oQ/LFloR/kyqFqgnMZrwIHVPPy/kIsgJuql0fc 4QaErOamzKIaV47WQndRnZIOoWL/yKUBw9/+t4OrTXFZ+jYe6vClypzFKvBgt9MF yz8mfx3fPZaL3k6oTpy1WVyuGRgnUJfxA3IFoFe3sPw/bBJp+BoswdkGklgz0jdY zYPw6T6R2LIolDSh9Yv1clC8M1WR5PMBbur9alzShPFaBbzCgW4FWAesY2w== Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxx00rwu0-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:44 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-364f007d1f3so1841439a91.1 for ; Mon, 04 May 2026 12:08:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921723; x=1778526523; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zVhhihIWGcWDVKhVXioxlxo4w1o6vj94DNJvO2XJTbI=; b=KTTi5yIbLHwbsd9KYjmsF+tPyxumj7dIsVEVPehbFIIybF+T/iRZW7u/J5idxNid09 HZDjMqhFt6BPYD9TWkFoElPapaI+qVILd5FXPaxbTgdRNlhfu00N3+pIlnncLjXXmFp/ A39EjcKcC/+GkJE9I3zLLW4D9amDm0UsCXsq142Fe8lf+NRYhHGg45HadvLnYRactb3o Tg6QUSY9QS6fe644UIW4Iu8jZLHX+xFDBpaY4SRjzY5OzVL+6Qvf8gvaIMOxouFBS0Xn wk2aHT/LGZxmC3ej2Fj8rJTTJoOS1xS8XChiPqmxMlGwhJ4wG+qtXOP+kv5UwOTuXntP bFnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921723; x=1778526523; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=zVhhihIWGcWDVKhVXioxlxo4w1o6vj94DNJvO2XJTbI=; b=UA35gouwP1BO1CblKtDD0ODzMV5L3RmY8pMlf9wI8lxGRueyPTiMAFvged0hDdWh1m niqRBn6pfANP9FYE7usQclJNOhe83qehxH/FBjF4ceigIlJd10WnHFk1eYox7NyTAjtW WReaiHAPmU472Hg0qOQK5nH6yxSXpKAW632/PSR608XuZcZPklKL4+hW68iDrc1GlP66 ZU36w/W3Zvt/YR88Ke0otGjM9fk2iew+qy7eP9CH+0/XPQ91qxhEqa4Zq1I7S3JJTfKG 2kblTEqs98eHI0iC2vTteK3qwyMLkYMVXcJjVpTuQ6YMditqjoa87YeSGs6aaiYJONyl 3c2g== X-Forwarded-Encrypted: i=1; AFNElJ8bU5AryTTDrCvLylYwQ+Rn6qYA0emNSCYJtLBD2Rz08ZV40ifAK5C523CmX18I05ZrNFLlWeXuXJKd7T8=@vger.kernel.org X-Gm-Message-State: AOJu0YxthmU5V6KvXS1xD5dEnx7bsguVIudDO6lXuI08ZcZ9cPkH6MnB 11F1dbdBdfXjldGf7J8jd5GQU3ZKuPocB4sIRihNhO+OAV+2jPGKXWUPh6ozDqQFjyrKc2M83w4 JHOIn+8afc2db6UNEKMhRzLBMNN4bvGsjBqWxefRUmPt/WptlvzNncHnUHN4T2/oDLOs= X-Gm-Gg: AeBDieuq6zj1g6Sy/ZwUTy4chMLqi2CRznjsgCYIomWiv/gdoCsuZab0Hc9Hw5LETF2 m0+44vPSTHVnXSSp0G1iN6B4VnPXzgAOum4APCgK1vwlOogRw16+eY3AkrCpkW+aHNqUT8j16JO gGutccm66yTxzmBkoTu8E2TRg0npHixtWwl+HzhGkbHQVgrfCi7RjfYsKmXiVuj5zOhD9viyEZK mOgS95Qlx5h3rtUyjn12u/OarBb7e632H8AZxbiAwZMstUTAc8ks81HjOZ01cKqt1sQAfjTC7hF 5EvgT0KbQeNxKiyA4eHxNysi4lHmAP7bgOnssoc6zTWxv7HMqVf8N0H/1tAG0Fidd0MjzQbtQGQ PE4mapGYfFjib1ds2GV6MNiZX7eVxsjnK/zBN/eLjpRg= X-Received: by 2002:a17:90a:d005:b0:35f:c1cc:fee0 with SMTP id 98e67ed59e1d1-365724c1a6emr559029a91.8.1777921723114; Mon, 04 May 2026 12:08:43 -0700 (PDT) X-Received: by 2002:a17:90a:d005:b0:35f:c1cc:fee0 with SMTP id 98e67ed59e1d1-365724c1a6emr558997a91.8.1777921722572; Mon, 04 May 2026 12:08:42 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-364ec00ad4dsm15850171a91.11.2026.05.04.12.08.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:42 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Sean Paul , Konrad Dybcio , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 12/16] drm/msm/a8xx: Add perfcntr flush sequence Date: Mon, 4 May 2026 12:06:55 -0700 Message-ID: <20260504190751.61052-13-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=APflyhIR c=1 sm=1 tr=0 ts=69f8eebc cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=W-43u8CF5Pkpiqpb4b0A:9 a=mQ_c8vxmzFEMiUWkPHU9:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfX+MQLi6rDCwPl OxXRK1Ec+u7yJKEtGvQ71LoV0jdE0eI0J4lD4yCXukonWXSp9nhX+UOsXYCWW+HpFY/gP0I6xP+ +uQfW1zs2s+PYsHURM5+waBznaiTTF8VZAN6/IKnSlTZgO07yNT8jtgTR4UED0sWzLe7cRRkO4H +qM3DFPGLhQQArikv4dO9TvUCutcLS4MfOsUC+xLBwN1DTb/eLCszr83X/qtqPsMOTPtsRB8SVW JReuaZkEqsQHaUKRnN0YTiZOWkhKSCgTEK8hcuMlCAQurfpK1iDkkMUyAamSmVhzx9QzQAZFhl3 +Qhhj1DHW+QEkeJ3awfDvakBFxlRdNu28la9Xoasgfo+8kWSFX2Hv57f1pk3X6yre6yo2Hfhr9M wghpM3NKMVmMqKeQYKj6Q+X/G52wJce0FY03RotjBTrvLJYvbLnRJ6MArp7VTyZZ6rLsTBU8gSQ UXpuu+ip9ej7rWGG3Jw== X-Proofpoint-GUID: R3FbBE586jUMKcWFLni_EAWUhBu23ZXq X-Proofpoint-ORIG-GUID: R3FbBE586jUMKcWFLni_EAWUhBu23ZXq X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 impostorscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 suspectscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" With the slice architecture, we need to flush the slice and unslice counters to perf RAM before reading counters. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 1 + drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/a8xx_gpu.c | 20 ++++++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a6xx_gpu.c index 30df9bfa9ef8..a329d20033d7 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -2921,6 +2921,7 @@ const struct adreno_gpu_funcs a8xx_gpu_funcs =3D { .progress =3D a8xx_progress, .sysprof_setup =3D a6xx_gmu_sysprof_setup, .perfcntr_configure =3D a6xx_perfcntr_configure, + .perfcntr_flush =3D a8xx_perfcntr_flush, }, .init =3D a6xx_gpu_init, .get_timestamp =3D a8xx_gmu_get_timestamp, diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/ad= reno/a6xx_gpu.h index 99c3e55f5ca8..3491a24a9320 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h @@ -334,5 +334,6 @@ void a8xx_preempt_hw_init(struct msm_gpu *gpu); void a8xx_preempt_trigger(struct msm_gpu *gpu); void a8xx_preempt_irq(struct msm_gpu *gpu); bool a8xx_progress(struct msm_gpu *gpu, struct msm_ringbuffer *ring); +void a8xx_perfcntr_flush(struct msm_gpu *gpu); void a8xx_recover(struct msm_gpu *gpu); #endif /* __A6XX_GPU_H__ */ diff --git a/drivers/gpu/drm/msm/adreno/a8xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a8xx_gpu.c index 124d315b2469..6c040f718176 100644 --- a/drivers/gpu/drm/msm/adreno/a8xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a8xx_gpu.c @@ -1345,3 +1345,23 @@ bool a8xx_progress(struct msm_gpu *gpu, struct msm_r= ingbuffer *ring) { return true; } + +void a8xx_perfcntr_flush(struct msm_gpu *gpu) +{ + u32 val; + + /* + * Flush delta counters (both perf counters and pipe stats) present in + * RBBM_S and RBBM_US to perf RAM logic to get the latest data. + */ + gpu_write(gpu, REG_A8XX_RBBM_PERFCTR_FLUSH_HOST_CMD, BIT(0)); + gpu_write(gpu, REG_A8XX_RBBM_SLICE_PERFCTR_FLUSH_HOST_CMD, BIT(0)); + + /* Ensure all writes are posted before polling status register */ + wmb(); + + if (gpu_poll_timeout(gpu, REG_A8XX_RBBM_PERFCTR_FLUSH_HOST_STATUS, val, + val & BIT(0), 100, 100 * 1000)) { + dev_err(&gpu->pdev->dev, "Perfcounter flush timed out: status=3D0x%08x\n= ", val); + } +} --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41D233EFD13 for ; Mon, 4 May 2026 19:08:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921731; cv=none; b=Kz4Cbqa372lUGwAYAalD6nXxNMPnKW0wzaxcuWIZ5iKa+8AHVKJ6z7PsLMmP2wyecA+HqtNfoVH05SpBVWOGFsBY1d3IdSV82tEU2qU/LsdAbpZwOI2eHGUO1Eu6b/2VGGfq3oHC13B80v4Af/yc6Ea4wnBzgqPVykprAiGctsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921731; c=relaxed/simple; bh=SugdMmP6HcOhxhCu8FE9ftD7uApl94fbcup6fqijOO4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RTh+OpXsBzavUMvgYxLV/5TvDJoop8jnYxaMB9el15mRlW03ejf1tEuk/COoqpufOtSGG4EzhJ92Bp3k30VBnILSrOk1sTmlx5+8qz2n+RDVggjlduvwCm3g5xqrJVEwrutL7Dek5b0dvk0XQrG5Uep7grMGebZBsXPcEeoEKPg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=JMCmXWFC; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=W++gdesg; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="JMCmXWFC"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="W++gdesg" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644IhquP4128842 for ; Mon, 4 May 2026 19:08:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=U7ptnwcb5GY LMAp9VK/C6htmabHNYQ8Z9XWYGNmuPaE=; b=JMCmXWFCdQpqdiDdnImo1B9wiXD R8RXamD9ccHd3hRwati6POc0iV55BdZGoUXI5onuug7v9Wm4NBl4FI8S+RqGMHvW Jtd1eU/GWaLFxRxMeDDdIrSxtah5rd5BjY3oczROeoPSgyHFGk1yZgkqCZ6ibCet tmtfo4dT4+1kVx3QUeKPsxOqaDkvx4CU/Bq5OO2O8lkv/hHxnXlBevyqw9VHNdIY B2XZ3DTFXulssrQion2Zq6VgMRMnzsQeql/ktbdV7MJH8AJyqnjOX4zx2Id5uwa1 GPmmcLny1k8UjUyNYC9O12ye/17FFE8kFG2x9PDtKUKk8kibQPC4g0eKKSQ== Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxsdw1x2b-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:47 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-35fc22424d9so10804727a91.2 for ; Mon, 04 May 2026 12:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921726; x=1778526526; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U7ptnwcb5GYLMAp9VK/C6htmabHNYQ8Z9XWYGNmuPaE=; b=W++gdesgelz1uABbUzDsX8vq1STAe7ZnAzL5DLqvWzZ8T0etrMeDT/TmoD+MxqKYd3 FK90T234S4WmkC6PVaw5Odd18TVzhTt5g4QowGg8vn4efQ3FqgYiu8V7KFBAOcsQp18L aoKgjnyESDTp7uH6LvdPwzxW183NRsPaDi5UaNrYThuWk8EDtTpC5XdC6uRkk6l84j1f XQ7bPfAFS5HytWTAQd6qN6cEHCXl6W2d/R9CUrgsHc76y2SzT5AXRT0pS3JmDem7sbBg M6u/wxUm79pU2elc9aWAnOvL54m5L0qAfkK8rpWq3fh/TKwJ9QZhplc47NaPUcH7ps9A wQWQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921726; x=1778526526; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=U7ptnwcb5GYLMAp9VK/C6htmabHNYQ8Z9XWYGNmuPaE=; b=mgoGpI4cT+eAgEAWB8DabAbD+ukJc5d4dx5bPCRSAJKL/rqzqmMlqSzViC+ctVLUNv L7EMUOV5bpc6WI67ygDmtaIX3CYsNB3zFfvDRgZmzgmktTR5xbb1ImrQUTswMyhqx8SD 99oYE2OMKZBnwOChfyxNESJq3ckVOLRdhMpDh5zqRg89jen1fM5ZyjJ0UqWc+N5OEP88 qgPym7qTmpzJp1b+9/0P27Xcu6r/5dLWXMFH/0pnC2/RAX2EAXfo/w07VWI0l0rCcjOP G4h1sIgn6g50A7XX01OzV/3eX3OUwZ01BjJpAXlacMBQoha7tiyM74ugbq6SVbfajWPY c2wA== X-Forwarded-Encrypted: i=1; AFNElJ+xQlLgeOWw+3iIWo999S3VP41N96++JtL2nzpBQZvCClR8gffMVBv1fXlDIAtKzFh5DsunGVPEk6yG1Bw=@vger.kernel.org X-Gm-Message-State: AOJu0Yw+Esrw4ex9xh56kpqpHev2YE6kQpMfwO6mc/bmgeumYnoOVEo9 Ouat18b3YMjqF1X9BuRak9/wVfwZ3qeYI9/3iWGsG8NeoaGc4fsZAvkG/fDNYRwfKJNlr5trLUo ukvCS/B0L5bS407GJcg05pNxt3QjW5jmGMZmhYLcfeBmvogApJzMxB+9L3oj/ifQW3k8= X-Gm-Gg: AeBDiessUz+XMQV5r8YYZXZ7rqyIFV5wltYYKDYyLd5buVR0epdIa+Qc1r5m0iEAETA K8MBJ2vAwHm1+4dZoPMN1rWNTkfGYBZeBCqIw06XBVbquWZT/IXdJQPFqqBbEue+hMxjADfdoO1 ZewXkIeCLvtGeTJXx33Zcz+W2ng9IAmmWtC9XCBfBMTlGcoc6LfW1xOif+81GW3Fg307hYzJP7o ndXS4vxEIUDUsexka7APRg1XLJ4vbP8QTQMb7CmCGGo+b4qbt+38xiin9QR2j9vz6EsEz61f9UJ Ww7+BF78XPwAJY7mEXEE5CP8OkDdN5jsW2C1TePJawx2/aPZWJYQtbUMqWeumnEdHF6JGRJndhH dMkb9/crfldlsNqoT6cHrU3TfFUUaGawjQRZE6BAYXuc= X-Received: by 2002:a17:90b:55c4:b0:35c:30a8:31f with SMTP id 98e67ed59e1d1-3657737bc90mr190713a91.2.1777921725538; Mon, 04 May 2026 12:08:45 -0700 (PDT) X-Received: by 2002:a17:90b:55c4:b0:35c:30a8:31f with SMTP id 98e67ed59e1d1-3657737bc90mr190668a91.2.1777921724762; Mon, 04 May 2026 12:08:44 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-364ec00a280sm12268083a91.10.2026.05.04.12.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:44 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , David Airlie , Simona Vetter , Konrad Dybcio , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 13/16] drm/msm: Add PERFCNTR_CONFIG ioctl Date: Mon, 4 May 2026 12:06:56 -0700 Message-ID: <20260504190751.61052-14-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=a7AAM0SF c=1 sm=1 tr=0 ts=69f8eebf cx=c_pps a=RP+M6JBNLl+fLTcSJhASfg==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=W4oHwWUT8aixCVaBVEUA:9 a=iS9zxrgQBfv6-_F4QbHw:22 X-Proofpoint-GUID: GaBit7rVpA_7fWG0nQEjzcVlLDfuUZZM X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfX4GC2mVysTdt0 YLkZc3IV8cmQUHZ1EEzTBClctXK+tU3ID4V+KkEW6gp7V/JuoXCjvyYpe7yKCWLWoGMyqxt3k6M pmL6bxR8C3PdSzslJD5LftfFP3C192Asyo7THXGAc30IqGDQJJWzOGrulITuemy1sYvuAuIow3G 9DTrFHgvzU/Y9M/wsWInAqttAUY5/rre7TQoY68J4UbgwjpwRZRJDtGR1T+7H2R/kakqn5tjuHE NIsJb/9jwQLGAUOyFgZ+JwGRu2ePV0EIYwb8k8y+NlBN4Z19kbpxbaUxPDX88eUGEVWCZXy/5We N7VtgLARThudPm2PKoFYbsGOootw8wwIQOnDID/H3vpGpENyRLS9lZxbDAC46Ab4LAtV1gzEPbD SWA8Y/0HR9wi4ypmyDnhGtMJdZcaCIEHnj90h9QOdxhHrZEkd5w8+0ZaVJzOiv+VOTqoY67YxjX WBVsmygr4mSNVk0JylQ== X-Proofpoint-ORIG-GUID: GaBit7rVpA_7fWG0nQEjzcVlLDfuUZZM X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 phishscore=0 spamscore=0 adultscore=0 clxscore=1015 suspectscore=0 priorityscore=1501 malwarescore=0 impostorscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" Add new UABI and implementation of PERFCNTR_CONFIG ioctl. A bit more work is required to configure the pwrup_reglist for the GMU to restore SELect regs on exist of IFPC, before we can stop disabling IFPC while global counter collection. This will follow in a later commit, but will be transparent to userspace. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/msm_drv.c | 1 + drivers/gpu/drm/msm/msm_drv.h | 2 + drivers/gpu/drm/msm/msm_gpu.h | 3 + drivers/gpu/drm/msm/msm_perfcntr.c | 510 +++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_perfcntr.h | 51 +++ include/uapi/drm/msm_drm.h | 48 +++ 6 files changed, 615 insertions(+) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 3066547f319b..0a7fc06113e0 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -801,6 +801,7 @@ static const struct drm_ioctl_desc msm_ioctls[] =3D { DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_CLOSE, msm_ioctl_submitqueue_close, DRM= _RENDER_ALLOW), DRM_IOCTL_DEF_DRV(MSM_SUBMITQUEUE_QUERY, msm_ioctl_submitqueue_query, DRM= _RENDER_ALLOW), DRM_IOCTL_DEF_DRV(MSM_VM_BIND, msm_ioctl_vm_bind, DRM_RENDER_AL= LOW), + DRM_IOCTL_DEF_DRV(MSM_PERFCNTR_CONFIG, msm_ioctl_perfcntr_config, DR= M_RENDER_ALLOW), }; =20 static void msm_show_fdinfo(struct drm_printer *p, struct drm_file *file) diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index f00b2e7aeb91..204e140ac8e9 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -237,6 +237,8 @@ int msm_ioctl_vm_bind(struct drm_device *dev, void *dat= a, =20 int msm_perfcntr_resume(struct msm_gpu *gpu); void msm_perfcntr_suspend(struct msm_gpu *gpu); +int msm_ioctl_perfcntr_config(struct drm_device *dev, void *data, + struct drm_file *file); =20 struct msm_perfcntr_state * msm_perfcntr_init(struct msm_gpu *gpu); void msm_perfcntr_cleanup(struct msm_gpu *gpu); diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 92710da5009b..67f1e84eb631 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -353,6 +353,9 @@ struct msm_perfcntr_state { /** @stream: current global counter stream if active */ struct msm_perfcntr_stream *stream; =20 + /** @sel_seqno: counter for sel_fence */ + uint32_t sel_seqno; + /** * @groups: Global perfcntr stream group state. * diff --git a/drivers/gpu/drm/msm/msm_perfcntr.c b/drivers/gpu/drm/msm/msm_p= erfcntr.c index 09e6aa4b6620..39bec201d5c9 100644 --- a/drivers/gpu/drm/msm/msm_perfcntr.c +++ b/drivers/gpu/drm/msm/msm_perfcntr.c @@ -3,13 +3,44 @@ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. */ =20 +#include "drm/drm_file.h" +#include "drm/msm_drm.h" + +#include "linux/anon_inodes.h" +#include "linux/gfp_types.h" +#include "linux/poll.h" +#include "linux/slab.h" + #include "msm_drv.h" #include "msm_gpu.h" #include "msm_perfcntr.h" =20 +#include "adreno/adreno_gpu.h" + +/* space used: */ +#define fifo_count(stream) \ + (CIRC_CNT((stream)->fifo.head, (stream)->fifo.tail, (stream)->fifo_size)) +#define fifo_count_to_end(stream) \ + (CIRC_CNT_TO_END((stream)->fifo.head, (stream)->fifo.tail, (stream)->fifo= _size)) +/* space available: */ +#define fifo_space(stream) \ + (CIRC_SPACE((stream)->fifo.head, (stream)->fifo.tail, (stream)->fifo_size= )) + static int msm_perfcntr_resume_locked(struct msm_perfcntr_stream *stream) { + if (!stream) + return 0; + + /* Reprogram SEL regs on highest priority rb: */ + struct msm_ringbuffer *ring =3D stream->gpu->rb[0]; + + queue_work(ring->sched.submit_wq, &stream->sel_work); + + hrtimer_start(&stream->sample_timer, + ns_to_ktime(stream->sample_period_ns), + HRTIMER_MODE_REL_PINNED); + return 0; } =20 @@ -23,6 +54,22 @@ msm_perfcntr_resume(struct msm_gpu *gpu) static void msm_perfcntr_suspend_locked(struct msm_perfcntr_stream *stream) { + if (!stream) + return; + + hrtimer_cancel(&stream->sample_timer); + kthread_cancel_work_sync(&stream->sample_work); + + /* + * We can't use cancel_work_sync() here, since sel_work acquires + * gpu->lock which (a) in suspend path can already be held, or + * (b) in release path would invert the order of gpu->lock and + * gpu->perfcntr_lock. Either would cause deadlock. + */ + cancel_work(&stream->sel_work); + + stream->sel_fence =3D ++stream->gpu->perfcntrs->sel_seqno; + stream->seqno =3D 0; } =20 void @@ -32,6 +79,469 @@ msm_perfcntr_suspend(struct msm_gpu *gpu) msm_perfcntr_suspend_locked(gpu->perfcntrs->stream); } =20 +static int +msm_perfcntrs_stream_release(struct inode *inode, struct file *file) +{ + struct msm_perfcntr_stream *stream =3D file->private_data; + struct msm_gpu *gpu =3D stream->gpu; + + scoped_guard (mutex, &gpu->perfcntr_lock) { + struct msm_perfcntr_state *perfcntrs =3D gpu->perfcntrs; + + msm_perfcntr_suspend_locked(stream); + perfcntrs->stream =3D NULL; + + /* release previously allocated counters: */ + for (unsigned i =3D 0; i < gpu->num_perfcntr_groups; i++) + perfcntrs->groups[i]->allocated_counters =3D 0; + } + + /* + * In the suspend path we use async cancel_work(), to avoid blocking + * on sel_work, which acquires gpu->lock (which could deadlock since + * other paths acquire gpu->lock before perfcntr_lock) or already + * hold gpu->lock. + * + * But since we are freeing the stream, after dropping perfcntr_lock + * we need to block until sel_work is done: + */ + cancel_work_sync(&stream->sel_work); + + kfree(stream->group_idx); + kfree(stream->fifo.buf); + kfree(stream); + + return 0; +} + +static __poll_t +msm_perfcntrs_stream_poll(struct file *file, poll_table *wait) +{ + struct msm_perfcntr_stream *stream =3D file->private_data; + __poll_t events =3D 0; + + poll_wait(file, &stream->poll_wq, wait); + + /* Are there samples to read? */ + if (fifo_count(stream) > 0) + events |=3D EPOLLIN; + + return events; +} + +static ssize_t +msm_perfcntrs_stream_read(struct file *file, char __user *buf, + size_t count, loff_t *ppos) +{ + struct msm_perfcntr_stream *stream =3D file->private_data; + int ret; + + if (!(file->f_flags & O_NONBLOCK)) { + ret =3D wait_event_interruptible(stream->poll_wq, + fifo_count(stream) > 0); + if (ret) + return ret; + } + + guard(mutex)(&stream->read_lock); + + struct circ_buf *fifo =3D &stream->fifo; + const char *fptr =3D &fifo->buf[fifo->tail]; + + /* + * Note that smp_load_acquire() is not strictly required + * as CIRC_CNT_TO_END() does not access the head more than + * once. + */ + count =3D min_t(size_t, count, fifo_count_to_end(stream)); + if (copy_to_user(buf, fptr, count)) + return -EFAULT; + + smp_store_release(&fifo->tail, (fifo->tail + count) & (stream->fifo_size = - 1)); + *ppos +=3D count; + + return count; +} + +static const struct file_operations stream_fops =3D { + .owner =3D THIS_MODULE, + .release =3D msm_perfcntrs_stream_release, + .poll =3D msm_perfcntrs_stream_poll, + .read =3D msm_perfcntrs_stream_read, +}; + +static void +sel_worker(struct work_struct *w) +{ + struct msm_perfcntr_stream *stream =3D + container_of(w, typeof(*stream), sel_work); + struct msm_gpu *gpu =3D stream->gpu; + /* Reprogram SEL regs on highest priority rb: */ + struct msm_ringbuffer *ring =3D stream->gpu->rb[0]; + + /* + * If in the process of resuming, wait for that. Otherwise sel_worker + * which is enqueued in the resume path can be scheduled before the + * resume completes. + */ + pm_runtime_barrier(&gpu->pdev->dev); + + /* + * sel_work could end up scheduled before suspend, but running + * after. See msm_perfcntr_suspend_locked() + * + * So if we end up running sel_work after the GPU is already + * suspended, just bail. It will be scheduled again after + * the GPU is resumed. + */ + if (!pm_runtime_get_if_active(&gpu->pdev->dev)) + return; + + scoped_guard (mutex, &gpu->lock) { + guard(mutex)(&gpu->perfcntr_lock); + if (stream !=3D gpu->perfcntrs->stream) + break; + msm_gpu_hw_init(gpu); + gpu->funcs->perfcntr_configure(gpu, ring, stream); + } + + pm_runtime_put_autosuspend(&gpu->pdev->dev); +} + +static void +sample_write(struct msm_perfcntr_stream *stream, int *head, const void *bu= f, size_t sz) +{ + /* + * FIFO size is power-of-two, and guaranteed to have enough space to + * fit what we are writing. So we should not hit the wrap-around + * point writing things that are power-of-two sized + */ + WARN_ON(CIRC_SPACE_TO_END(*head, stream->fifo.tail, stream->fifo_size) < = sz); + + memcpy(&stream->fifo.buf[*head], buf, sz); + + /* Advance head, wrapping around if necessary: */ + *head =3D (*head + sz) & (stream->fifo_size - 1); +} + +static void +sample_write_u32(struct msm_perfcntr_stream *stream, int *head, uint32_t v= al) +{ + sample_write(stream, head, &val, sizeof(val)); +} + +static void +sample_write_u64(struct msm_perfcntr_stream *stream, int *head, uint64_t v= al) +{ + sample_write(stream, head, &val, sizeof(val)); +} + +static void +sample_worker(struct kthread_work *work) +{ + struct msm_perfcntr_stream *stream =3D + container_of(work, typeof(*stream), sample_work); + struct msm_gpu *gpu =3D stream->gpu; + struct msm_rbmemptrs *memptrs =3D gpu->rb[0]->memptrs; + + if (memptrs->perfcntr_fence !=3D stream->sel_fence) + return; + + /* + * Ensure we have enough space to capture a sample period's + * worth of data: + */ + if (stream->period_size > fifo_space(stream)) { + stream->seqno =3D 0; + return; + } + + if (gpu->funcs->perfcntr_flush) + gpu->funcs->perfcntr_flush(gpu); + + /* Keep local copy of head to avoid updating fifo until the end: */ + int head =3D stream->fifo.head; + + /* + * We expect the GPU to be powered at this point, as the timer + * and kthread work are canceled/flushed in the suspend path: + */ + sample_write_u64(stream, &head, + to_adreno_gpu(gpu)->funcs->get_timestamp(gpu)); + sample_write_u32(stream, &head, stream->seqno++); + sample_write_u32(stream, &head, 0); + + for (unsigned i =3D 0; i < stream->nr_groups; i++) { + unsigned group_idx =3D msm_perfcntr_group_idx(stream, i); + unsigned base =3D msm_perfcntr_counter_base(stream, group_idx); + + const struct msm_perfcntr_group *group =3D + &gpu->perfcntr_groups[group_idx]; + + struct msm_perfcntr_group_state *group_state =3D + gpu->perfcntrs->groups[group_idx]; + + unsigned nr =3D group_state->allocated_counters; + for (unsigned j =3D 0; j < nr; j++) { + const struct msm_perfcntr_counter *counter =3D + &group->counters[j + base]; + uint64_t val =3D gpu_read64(gpu, counter->counter_reg_lo); + sample_write_u64(stream, &head, val); + } + } + + smp_store_release(&stream->fifo.head, head); + wake_up_all(&stream->poll_wq); +} + +static enum hrtimer_restart +sample_timer(struct hrtimer *hrtimer) +{ + struct msm_perfcntr_stream *stream =3D + container_of(hrtimer, typeof(*stream), sample_timer); + + kthread_queue_work(stream->gpu->worker, &stream->sample_work); + + hrtimer_forward_now(hrtimer, ns_to_ktime(stream->sample_period_ns)); + + return HRTIMER_RESTART; +} + +static int +get_group_idx(struct msm_gpu *gpu, const char *name, size_t len) +{ + for (unsigned i =3D 0; i < gpu->num_perfcntr_groups; i++) { + const struct msm_perfcntr_group *group =3D + &gpu->perfcntr_groups[i]; + if (!strncmp(group->name, name, len)) + return i; + } + + return -1; +} + +static int +get_available_counters(struct msm_gpu *gpu, int group_idx, uint32_t flags) +{ + struct msm_perfcntr_state *perfcntrs =3D gpu->perfcntrs; + + /* + * For local counter reservation, anything that is not used by + * global perfcntr stream is available: + */ + if (!(flags & MSM_PERFCNTR_STREAM)) { + return gpu->perfcntr_groups[group_idx].num_counters - + perfcntrs->groups[group_idx]->allocated_counters; + } + + /* + * For global counter collection, anything that is not reserved by + * one or more contexts is available: + */ + guard(mutex)(&gpu->dev->filelist_mutex); + + unsigned reserved_counters =3D 0; + struct drm_file *file; + + list_for_each_entry (file, &gpu->dev->filelist, lhead) { + struct msm_context *ctx =3D file->driver_priv; + + if (!ctx || !ctx->perfctx) + continue; + + unsigned n =3D ctx->perfctx->reserved_counters[group_idx]; + reserved_counters =3D max(reserved_counters, n); + } + + return gpu->perfcntr_groups[group_idx].num_counters - reserved_counters; +} + +int +msm_ioctl_perfcntr_config(struct drm_device *dev, void *data, struct drm_f= ile *file) +{ + struct msm_drm_private *priv =3D dev->dev_private; + const struct drm_msm_perfcntr_config *args =3D data; + struct msm_context *ctx =3D file->driver_priv; + struct msm_gpu *gpu =3D priv->gpu; + int stream_fd =3D 0; + + if (!gpu || !gpu->num_perfcntr_groups) + return -ENXIO; + + struct msm_perfcntr_state *perfcntrs =3D gpu->perfcntrs; + + /* + * Validate args that don't require locks/power first: + */ + + if (args->flags & ~MSM_PERFCNTR_FLAGS) + return UERR(EINVAL, dev, "invalid flags"); + + if (args->nr_groups && !args->group_stride) + return UERR(EINVAL, dev, "invalid group_stride"); + + if (args->flags & MSM_PERFCNTR_STREAM) { + if (!perfmon_capable()) + return UERR(EPERM, dev, "invalid permissions"); + if (!args->nr_groups) + return UERR(EINVAL, dev, "invalid nr_groups"); + if (!args->period) + return UERR(EINVAL, dev, "invalid sampling period"); + } else { + if (args->period) + return UERR(EINVAL, dev, "sampling period not allowed"); + if (args->bufsz_shift) + return UERR(EINVAL, dev, "sample buf size not allowed"); + } + + if (args->nr_groups && !args->groups) + return UERR(EINVAL, dev, "no groups"); + + /* + * To avoid iterating over the groups multiple times, allocate and setup + * both a ctx and global stream object. Only one of the two will be + * kept in the end. + */ + + struct msm_perfcntr_context_state *perfctx __free(kfree) =3D kzalloc( + struct_size(perfctx, reserved_counters, gpu->num_perfcntr_groups), + GFP_KERNEL); + if (!perfctx) + return -ENOMEM; + + struct msm_perfcntr_stream *stream __free(kfree) =3D + kzalloc(sizeof(*stream), GFP_KERNEL); + if (!stream) + return -ENOMEM; + + uint32_t *group_idx __free(kfree) =3D + kcalloc(args->nr_groups, sizeof(uint32_t), GFP_KERNEL); + if (!group_idx) + return -ENOMEM; + + stream->gpu =3D gpu; + stream->sample_period_ns =3D args->period; + stream->nr_groups =3D args->nr_groups; + stream->fifo_size =3D 1 << args->bufsz_shift; + + mutex_init(&stream->read_lock); + + guard(pm_runtime_active_auto)(&gpu->pdev->dev); + guard(mutex)(&gpu->perfcntr_lock); + + if (args->flags & MSM_PERFCNTR_STREAM) { + if (perfcntrs->stream) + return UERR(EBUSY, dev, "perfcntr stream already open"); + } + + size_t bufsz =3D 16; /* header size includes seqno and 64b timestamp: */ + int ret =3D 0; + + for (unsigned i =3D 0; i < args->nr_groups; i++) { + struct drm_msm_perfcntr_group g =3D {0}; + void __user *userptr =3D + u64_to_user_ptr(args->groups + (i * args->group_stride)); + + if (copy_from_user(&g, userptr, args->group_stride)) + return -EFAULT; + + if (g.pad) + return UERR(EINVAL, dev, "groups[%d]: invalid pad", i); + + int idx =3D get_group_idx(gpu, g.group_name, sizeof(g.group_name)); + + if (idx < 0) + return UERR(EINVAL, dev, "groups[%d]: unknown group", i); + + if (g.nr_countables > gpu->perfcntr_groups[idx].num_counters) + return UERR(EINVAL, dev, "groups[%d]: too many counters", i); + + if (args->flags & MSM_PERFCNTR_STREAM) { + if (g.nr_countables && !g.countables) + return UERR(EINVAL, dev, "groups[%d]: no countables", i); + } else { + if (g.countables) + return UERR(EINVAL, dev, "groups[%d]: countables should be NULL", i); + } + + int avail_counters =3D get_available_counters(gpu, idx, args->flags); + if (g.nr_countables > avail_counters) { + /* + * Defer error return until we process all groups, in + * case there are other E2BIG groups: + */ + ret =3D UERR(E2BIG, dev, "groups[%d]: too few counters available", i); + + if (args->flags & MSM_PERFCNTR_UPDATE) { + /* Let userspace know how many counters are actually avail: */ + g.nr_countables =3D avail_counters; + if (copy_to_user(userptr, &g, args->group_stride)) + return -EFAULT; + } + } + + group_idx[i] =3D idx; + perfctx->reserved_counters[idx] =3D g.nr_countables; + + if (args->flags & MSM_PERFCNTR_STREAM) { + perfcntrs->groups[idx]->allocated_counters =3D g.nr_countables; + + size_t sz =3D sizeof(uint32_t) * g.nr_countables; + void __user *userptr =3D u64_to_user_ptr(g.countables); + + if (copy_from_user(perfcntrs->groups[idx]->countables, userptr, sz)) + return -EFAULT; + + /* Samples are 64b per countable: */ + bufsz +=3D 2 * sz; + } + } + + if (ret) + return ret; + + if (args->flags & MSM_PERFCNTR_STREAM) { + /* + * Validate requested buffer size is large enough for at least + * a single sample period. + * + * Note the circ_buf implementation needs to be 1 byte larger + * than max it can hold (see CIRC_SPACE()). + */ + if (bufsz >=3D stream->fifo_size) + return UERR(ETOOSMALL, dev, "required buffer size: %zu", bufsz); + + stream->period_size =3D bufsz; + + void *buf __free(kfree) =3D + kmalloc(1 << args->bufsz_shift, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + stream_fd =3D anon_inode_getfd("[msm_perfcntrs]", &stream_fops, stream, = 0); + if (stream_fd < 0) + return stream_fd; + + INIT_WORK(&stream->sel_work, sel_worker); + kthread_init_work(&stream->sample_work, sample_worker); + init_waitqueue_head(&stream->poll_wq); + hrtimer_setup(&stream->sample_timer, sample_timer, + CLOCK_MONOTONIC, HRTIMER_MODE_REL); + + stream->sel_fence =3D ++perfcntrs->sel_seqno; + stream->group_idx =3D no_free_ptr(group_idx); + stream->fifo.buf =3D no_free_ptr(buf); + perfcntrs->stream =3D no_free_ptr(stream); + + msm_perfcntr_resume_locked(perfcntrs->stream); + } else { + kfree(ctx->perfctx); + ctx->perfctx =3D no_free_ptr(perfctx); + } + + return stream_fd; +} + /** * msm_perfcntr_group_idx - map idx of perfcntr group to group_idx * @stream: The global perfcntr stream diff --git a/drivers/gpu/drm/msm/msm_perfcntr.h b/drivers/gpu/drm/msm/msm_p= erfcntr.h index 14506bc37d05..198856b18445 100644 --- a/drivers/gpu/drm/msm/msm_perfcntr.h +++ b/drivers/gpu/drm/msm/msm_perfcntr.h @@ -7,6 +7,11 @@ #define __MSM_PERFCNTR_H__ =20 #include "linux/array_size.h" +#include "linux/circ_buf.h" +#include "linux/hrtimer.h" +#include "linux/kthread.h" +#include "linux/wait.h" +#include "linux/workqueue.h" =20 #include "adreno_common.xml.h" =20 @@ -42,12 +47,49 @@ struct msm_perfcntr_stream { /** @gpu: Back-link to the GPU */ struct msm_gpu *gpu; =20 + /** @sample_timer: Timer to sample counters */ + struct hrtimer sample_timer; + + /** @poll_wq: Wait queue for waiting for OA data to be available */ + wait_queue_head_t poll_wq; + + /** @sample_period_ns: Sampling period */ + uint64_t sample_period_ns; + /** @nr_groups: # of counter groups with enabled counters */ uint32_t nr_groups; =20 + /** @seqno: counter for collected samples */ + uint32_t seqno; + /** @sel_fence: Fence for SEL reg programming */ uint32_t sel_fence; =20 + /** + * @sel_work: Worker for SEL reg programming + * + * Initial SEL reg programming (as opposed to restoring the SEL + * regs on runpm resume) must run on the same ordered wq as is + * used by drm_sched, to serialize it with GEM_SUBMITs written + * into the same ringbuffer. + */ + struct work_struct sel_work; + + /** + * @sample_work: Worker for collecting samples + */ + struct kthread_work sample_work; + + /** + * @read_lock: + * + * Fifo access is synchronied on the producer side by virtue + * of there being a single timer collecting samples and writing + * into the fifo. It is protected on the consumer side by + * @read_lock. + */ + struct mutex read_lock; + /** * @group_idx: array of nr_groups * @@ -56,6 +98,15 @@ struct msm_perfcntr_stream { * the ioctl call that setup the stream */ uint32_t *group_idx; + + /** @fifo: circular buffer for samples */ + struct circ_buf fifo; + + /** @fifo_size: circular buffer size */ + size_t fifo_size; + + /** @period_size: size of data for single sampling period */ + size_t period_size; }; =20 uint32_t msm_perfcntr_group_idx(const struct msm_perfcntr_stream *stream, = uint32_t n); diff --git a/include/uapi/drm/msm_drm.h b/include/uapi/drm/msm_drm.h index b99098792371..289cf228b873 100644 --- a/include/uapi/drm/msm_drm.h +++ b/include/uapi/drm/msm_drm.h @@ -491,6 +491,52 @@ struct drm_msm_submitqueue_query { __u32 pad; }; =20 +#define MSM_PERFCNTR_STREAM 0x00000001 +#define MSM_PERFCNTR_UPDATE 0x00000002 +#define MSM_PERFCNTR_FLAGS ( \ + MSM_PERFCNTR_STREAM | \ + MSM_PERFCNTR_UPDATE | \ + 0) + +struct drm_msm_perfcntr_group { + char group_name[16]; + __u32 nr_countables; + __u32 pad; + __u64 countables; /* pointer to an array of nr_countables u32 */ +}; + +/* + * Note, for MSM_PERFCNTR_STREAM, the ioctl returns an fd to read recorded + * counters. This only works because the ioctl is DRM_IOW(), if we return= ed + * a out param in the ioctl struct the copy_to_user() (in drm_ioctl()) + * could fault, causing us to leak the fd. + * + * If the ioctl returns with error E2BIG, that means more counters/countab= les + * are requested than are currently available. If MSM_PERFCNTR_UPDATE flag + * is set, drm_msm_perfcntr_group::nr_countables will be updated to return + * the actual # of counters available. + * + * The data read from the has the following format for each sampling perio= d: + * + * uint64_t timestamp; // CP_ALWAYS_ON_COUNTER captured at sample time + * uint32_t seqno; // increments by 1 each period, reset to 0 on = discontinuity + * uint32_t mbz; // pad out counters to 64b + * struct { + * uint64_t counter[nr_countables]; + * } groups[nr_groups]; + * + * The ordering of groups and counters matches the order in PERFCNTR_CONFIG + * ioctl. + */ +struct drm_msm_perfcntr_config { + __u32 flags; /* bitmask of MSM_PERFCNTR_x */ + __u32 nr_groups; /* # of entries in groups array */ + __u64 groups; /* pointer to array of drm_msm_perfcntr_group */ + __u64 period; /* sampling period in ns */ + __u32 bufsz_shift; /* sample buffer size in bytes is 1<; Mon, 4 May 2026 19:08:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921729; cv=none; b=OHaOB3GndgzDrpQNH4UWPHxrcMJabeQ3R1QK806Ojvk+UMurwCYSa1V2UXi67biTDVgVk/oLykW/0jgRlC+mQbJ7c/bBuEcU/eVsG6jLZqn9oIxlPTebLR2VJCxg2oGWC9q/WGJ96M71KkUWr3TA2okhwlB/Lp+vbobYjCT090U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921729; c=relaxed/simple; bh=/luFySN9TuTwP132kmsdb3FQnU3x5xvt3hdARMrrktA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EPwwvDzPz0AMgRWY7hrQ39w92PFRqxQ+kS5stDEhkVqvOzNcV5eqfxx2J1iMOE9M2bJv5GAHZprIVmQdXUnQRC2TkKRiAngRB1pvqLzfsav8Iohx3n3AOOE4LhFI0HhutmVhu3UR5u5BU2ajGSg8cvSCDOPUXxjU/yrHD4/RYZ4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=aiF48jSk; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=O2uPFjEi; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="aiF48jSk"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="O2uPFjEi" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644DwbQK3467601 for ; Mon, 4 May 2026 19:08:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=V4uUYe1yUyG 7QRKd8WtYyuBLYfX08jPs1+jI/fe/6lw=; b=aiF48jSk2z03g5J0k6wGhitJjRW zZ5SzT322LLAPFpGhEccDuh5t9SlEZ7wUAHQWxejw+VO07LehrJpSvlKcYIMSYW6 nGGNPG7UddirNLOIYHauEpJO7lk0hx3ZLOSd1fRHoD1nJip3gXLKHXncrYeH1zV6 atpjM/MVSmkyLBoVoN4iTgK1j+EryclN5yjnDLPZ+hjj2ofveu3Kwk7gZ8SPcn97 cr5OqA3LGzI1K+GMYvveRiGmF9/Y/ypUjpl/zs+gdOHRpdyPfu+mdBy9wzP1N9HI FbNI2rf/hd2LKqQujhEtHOq1KwGGvgkxbjsN5jhyCEb3PeEO0wY8DHAYEiw== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxvtjs95b-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:47 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2b9b8137828so40605845ad.0 for ; Mon, 04 May 2026 12:08:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921727; x=1778526527; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=V4uUYe1yUyG7QRKd8WtYyuBLYfX08jPs1+jI/fe/6lw=; b=O2uPFjEiyr448AkxQBNHGpVQ+IREsuDWN9Gna67/8xDeBfUCRIUr6vJsL3u6T85V0D l4BbE6/cJddxPOhSAOo2tljy/TN4Jijls0/FqzJvhgTCvA5NZvGPBSiLBn37LswKC7ZI hXITERC8Gwqav1Prw4hj+uBU+JvTWSiOvlWg4KPPnJu1DGE49liNGyxsbLQxy1bErrFw 6s+IW9CwM7Los9q+3Pc92i6tTCkY4UVt806XeA7v3tltzgePUQbMaluuSEeV3hLqRGDD ofKCk5klRw0MZc7F1mkNdCcvcNnOn91YuPzzBa58B4fjlVP9yNlV1/3o5hXh2t1AGFy9 dHbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921727; x=1778526527; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=V4uUYe1yUyG7QRKd8WtYyuBLYfX08jPs1+jI/fe/6lw=; b=LRWhC1v54pESOUdYgL5gEq75bnDAYnH6V3B3ptSY5L5n3IDoHMfsof3U2mW3tHyjww A8lU1C4wlvJi1M/+6l8657uon32VvgYhZxR6jwNLRbMNEZdwD+aLYXQxy+QP3CZ3H+E3 QY9d3MNMd2yU14mEO8eEYUsa3p38nvmw2ei6fQENf+GUyR6iuM4hzsYhhRqSuRKNOEcV 6ggWsEiEZfe0FkipF8ssQmEq9yWsjcIb9GROrgN2uPgJLPp1CBafmH05RIOn/fLK8x2d Y1Op0J9Nmxy4T4cAOCBGHAdJdQpdA1Dg52yB1b8h95HeWEAASI+QumdhS52C4w1/4d9x Ygeg== X-Forwarded-Encrypted: i=1; AFNElJ/WQ7QVxjYn1D9xnIlpg+ajczaVzapCtjnfnKqZsqy+e1FiLLxZ8mYtil0pm1kV6gE3ePrmCdewAAptl7Y=@vger.kernel.org X-Gm-Message-State: AOJu0YxT1z3/Vzo3qfoJN79QgbxF7BUNkO7DkB2u0/zXbpSEnjTVT0qB tQG8N0yw9brbeq+H2xW85YDbbPHQgF7CpA11jK6sYgw22YbvbuDYnth0KlO0pdj/X1oIYm9Yqdu P98JJEWe0dDTYF4rUa4OahhmF6HNRR6ZISLFFHdZ5hv8VUQ8qHsbQato0dKpRQF2mpIA= X-Gm-Gg: AeBDieucdRl70gjoMA46zz9nnU46Fd570R5SJsd3IzQW703pLaIRfzBf5l6aHPt4jui 9QWEggQ8tPhjpNAOKf83PKaeCPjjGxIh+Y/viTRQK5TR2CR6mbYNOE9PJBdrR7Ibc6c2Nz4yY2+ 5R/Zu6VA1R+Lt4KiNvbBZcrcoG5fPewigla5/fWwpgeyCUEtcAJlA7XsSxLQi4RZ2YADbHdayAx QCMtZch6DOrDJQnRrzQwADj9t00G/CMDfC20dRae71bZv9EiznLvxfTP88QkEXfpsy+3Xc1AJCM HWt246TC+wQghO0q40NVLJ9IA6oF2pTpwvRtl3bFg/6tXEM9nx3aaMSI34wMNmwMWntbt/rC9bW IMXy+DD49CeLQD/8qGoFL1AuZeYHRuOPME+pZN2x+YcA= X-Received: by 2002:a17:902:9889:b0:2b4:5309:2c14 with SMTP id d9443c01a7336-2b9f260b785mr76828125ad.31.1777921726788; Mon, 04 May 2026 12:08:46 -0700 (PDT) X-Received: by 2002:a17:902:9889:b0:2b4:5309:2c14 with SMTP id d9443c01a7336-2b9f260b785mr76827835ad.31.1777921726207; Mon, 04 May 2026 12:08:46 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b9cae0f67esm117642825ad.51.2026.05.04.12.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:45 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Sean Paul , Konrad Dybcio , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 14/16] drm/msm/a6xx: Increase pwrup_reglist size Date: Mon, 4 May 2026 12:06:57 -0700 Message-ID: <20260504190751.61052-15-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: QNpr5XmF4EsPNo_mNY75Yofwu8U27mG8 X-Authority-Analysis: v=2.4 cv=KuN9H2WN c=1 sm=1 tr=0 ts=69f8eebf cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=8lTVeMJbxB4f0FvlbnAA:9 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfX6URu/ucwT/RL Kx6LYKJLpRIo+ke9tYS/VC63sAAkQsS3MtFMkxXpwLHEzLxbt40+Ril8saxk9MIIS2e4Vdnau+r KHyR8kNCF+U/G5SlrWOxpg41rqXxEu/qDkoZQt/FirgQxHufJa7l9t2tgUcV+IbJdIlqWq5/r/k JWVXwdJboGI0P0lpkTjQACobRb86OETfMSnGVipwxSQn9H/JX0xVfjxhsb8up/ecOsSkKQZdCYE 7OveYSz9zoIvACn/c4ECAGsd56c0Xukkm4w71QIfwYR3UYvlJikst2OTvt8KuUWm9VthVGZ0wd/ aN8oossOhRgd1hpRFIeEg/bS2oKMrNqaGbSdVL3w3nZHkZlXChtO5f+wWw1c7A1nDd7PfATqMlo Fcxk+KEVuf5iRObwawIbN788MK5MMuYikIFBMluRWFyzz8W/ar2sgK/W2j+jtasiFbGmJ0AjiR2 /911ZnSBviDMnU67h+g== X-Proofpoint-ORIG-GUID: QNpr5XmF4EsPNo_mNY75Yofwu8U27mG8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 adultscore=0 impostorscore=0 phishscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 priorityscore=1501 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" To make room for appending SEL reg programming. Without increasing the size, we would overflow the pwrup_reglist at ~190 counters on gen8. Or possibly fewer, considering that some gen8 counter groups also have separate slice vs unslice SELectors. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a6xx_gpu.c index a329d20033d7..61c6b0e781ce 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -1183,7 +1183,7 @@ static int a6xx_ucode_load(struct msm_gpu *gpu) msm_gem_object_set_name(a6xx_gpu->shadow_bo, "shadow"); } =20 - a6xx_gpu->pwrup_reglist_ptr =3D msm_gem_kernel_new(gpu->dev, PAGE_SIZE, + a6xx_gpu->pwrup_reglist_ptr =3D msm_gem_kernel_new(gpu->dev, 2 * PAGE_SIZ= E, MSM_BO_WC | MSM_BO_MAP_PRIV, gpu->vm, &a6xx_gpu->pwrup_reglist_bo, &a6xx_gpu->pwrup_reglist_iova); --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAE573F075C for ; Mon, 4 May 2026 19:08:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921733; cv=none; b=PtqFrqKYJQy4mg2L/co2SGLnltEwg7FsxM/uUFcOa3cT+W1xHNiWwhTX967YkR0Bm/hY3tDMqW++dNiZggRgFS64brHsafFv1iEzSrh/wJYsKVHUDYMS+2lDiQxaDPOCtj29vPxUjtZQOP8/8PKvonqx5VCOjN9BNkTDJLEyT68= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921733; c=relaxed/simple; bh=1HQi4O2c4EvJaQqUsnouhyUbcMf1PdNlzd3mEV28J8c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nAa2YtMqrafDIhCkFBN47PryTbEbMy7KzmaBpokmlqiBaisJp3KQn46ms8+9xPoTh9AE242ZqfcpcI4YYI/eLO3oN8Ra7w+6gu0gqAzGBOYY7oQMi7qYvc5eeBDdX+ak7nVTc5g+FZsYKWhGEsSzx2zlI6SrNzxCF3ONtYLrJRA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=aPs2TjY/; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=MzOvo92G; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="aPs2TjY/"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="MzOvo92G" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644FIf5Y3409777 for ; Mon, 4 May 2026 19:08:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=Z8lEzDrgE0f TV0/Bl+mAwrGTsTYAYegTQN4ZDI/6vu0=; b=aPs2TjY/rYPJTdi3pXmVJ1ePfa/ ANxYbErzlam8vmYB0u70GwkggRL3L7M4RB3dKhaFcEY4yLlPumtEHgcwNtdFbsDi UnTD7SGSLrmmDlq608+aoOdTa8UNkpMXIS7GU6FnV7NX9EAAG/nmzxCDWvz9Z91g 8k0cvd9O3nwPeHQB8EOunM/6vjv00JPVjfyYdOP7r6kkXEY4qhaSTTGTf6ZDKix8 OHitn/XV2xDNMOec8r/vQhEa8gDAYHms4eSFdU5d2NNLqCJ0GGc9FK5PZDTRXZFl Kx1fpXzoDfpr7Fftcha/hl1K0BK0FvYDRjt69HsFfjdzRcEoSS076VROWBA== Received: from mail-pj1-f71.google.com (mail-pj1-f71.google.com [209.85.216.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxx00rwuf-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:49 +0000 (GMT) Received: by mail-pj1-f71.google.com with SMTP id 98e67ed59e1d1-362eb03240bso5635925a91.3 for ; Mon, 04 May 2026 12:08:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921729; x=1778526529; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z8lEzDrgE0fTV0/Bl+mAwrGTsTYAYegTQN4ZDI/6vu0=; b=MzOvo92GoOhBkRG+NTxB41MQxsQy6ryaLlhVTwxnoeaklnSQ32CbB9oBGpwAWxPdKi QkkeDDeJiqtBzCTegWdjv3bGu8zYdPnk+B5L7q4Rte7xNLkY0Db786Ry56cV269yb4pF bJZZDFXOOSuRu6RHYGVZaH2sluz4nehG2e8ojXD8TzAVCS5L9zhszjIDhMwLUoPd/mQ9 yhkwZh5uo3DKMaabh0+ZwUs3XDPTEs8qjOYv1d/Ok/Lfj1t60eg4jjGJ/4kXSONsd9fk TS25xiZIB4hIbXcPjiUWixAnQUN4bpgAFF1wu/+LN0dF6XyzLz/AgQvqHkyMx4Fqb6O8 p5vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921729; x=1778526529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Z8lEzDrgE0fTV0/Bl+mAwrGTsTYAYegTQN4ZDI/6vu0=; b=Gw89221oarAsxzJ1BU64NwyO7ycMd6Ep1Nz+RFnfWQZkJvHhAPeMnhebrJ/x52Ozs3 Sq/2seAZMp7Xz5muwnLOdzIwpvMag02Sylx+GkLS1yKRLKL7GYtfF2wr9rt/7UkzIy6j W4hD41R73Gojj377uyuiVBivIYGkxLA601g8fcFYT7CGEr495kYqcYuXwI7eEqUcInVf HWQZ2la4+BTQ1+HyIPiVM5wOrVMjSR0Fzpc6RwQXyxQjJqV0JqbD4QsiCshlkES3rFGC M3G28UMO+MJO8pd85IvSWeV7SfwM4ROSmauRN7o/B7phTi7J0Jiy8DxUwHk0af1JCA7p qRtg== X-Forwarded-Encrypted: i=1; AFNElJ/WTeQ4ZxY6VT+IObQXI/aAG8PSlLWT2UIwQmmX7sGY1F+M4E8ganuM7yCpiKxKo3dB5/awgs5tTGrpKnQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yx/ZVOXCFAYETC7eIZ3hNy9igj8xGjjsGRVYjBX0qlkyutyK7N/ friR/Ms5ZpZ6E4PaeMpU5xwnNdipit2biaYT/wC4XlFAx9PneGahp2I4IvAPzSliJcbKPugNdI2 mvqUlhYlHMWAvvnlOPSYu201Dp6/QYreailo1dL3iNr+ngMrmWUOYZyTNgNT5h0s6Mbs= X-Gm-Gg: AeBDievEJxfg6yuS7jdtn545+ZgyuyFPlxbWr6cQkOnDejLzFyBacrkR9ioTGc22LuU ltWHyEvxZBeVBwvqylmUKJ4jMjHUiAFx+n1nC3j3Pfug0V6sC3m3qECspq5hZfzGm//J9y+s+5g +8jHxCZP4nzN4qWtNHE+OJ2/B0/npBgaSrVC14HSMhfjTxwxens8STj8i7w/+A2PHIW82N4Syde ri6FggIrW/TZETYXFJRyPYZOvaPqQsnCJON6MPVX/uVRzveb11M/AqYIL3Dei47CZXllF9Obuxq Mf7wHPmd4BF0eJLnmR5yGo250eVYVk6ozEBnQQK1RamwLD4IoOGT0TmDbdeVcSzmRRJEFX7RTvf zHxLoLkcYc2R60tVSkqe8zOJujDqJbS+DhTp1PXHK1dQ= X-Received: by 2002:a17:90b:2f03:b0:35e:30bc:804d with SMTP id 98e67ed59e1d1-3650cdffb46mr10418214a91.15.1777921728679; Mon, 04 May 2026 12:08:48 -0700 (PDT) X-Received: by 2002:a17:90b:2f03:b0:35e:30bc:804d with SMTP id 98e67ed59e1d1-3650cdffb46mr10418188a91.15.1777921728018; Mon, 04 May 2026 12:08:48 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36576332a4dsm88877a91.13.2026.05.04.12.08.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:47 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Sean Paul , Konrad Dybcio , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 15/16] drm/msm/a6xx: Append SEL regs to dyn pwrup reglist Date: Mon, 4 May 2026 12:06:58 -0700 Message-ID: <20260504190751.61052-16-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=APflyhIR c=1 sm=1 tr=0 ts=69f8eec1 cx=c_pps a=UNFcQwm+pnOIJct1K4W+Mw==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=gjKahejJLxXXi_JFjLAA:9 a=uKXjsCUrEbL0IQVhDsJ9:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfXxFH45YPgtxl/ vCwX8WWpoLAhLkAa9l2eVTtqKebthb500JVHXBSbDzKHUsAyebXO2xcOJG85/06KyrZg3O0Xipj qoxlxmiI3OruPg0lrD3twDR+Ru1KcsIhLiUIioKNMDmp69qHoyJmdPDcO3P54DBJbFyI27OiWFp tJnDoCv0Ndcs084S+42+4b7uZQUyl5Jfzj5A1sHB10ZBRj6YgU72jEMK6DtAMmmEB0EMLijMav0 Q1oYruw9ArNCE/HWdmPf85PcDW473RThGp/5KHnomokHBfCP9dkz4OksYW0/cYiXId8KtVtaCnZ WLGdI9K0zYi8UwSRFUfdphSQvAtyHaVbI4VNzoJx8peX8MrdtuN2+gqgvz26ArvN4NnZOsp1tB2 GcAA1uX/wOsLmcyC1EXXBVGTAfuhAWMmPFx7nBscgZB9+tYViv6Fb6Koph6I7vDGjPIx/7DXI2w zcTlIlMaeoPIO9vEqjg== X-Proofpoint-GUID: dTSS_d49V2_ciwUmvZQNBbadm7Bk7ESl X-Proofpoint-ORIG-GUID: dTSS_d49V2_ciwUmvZQNBbadm7Bk7ESl X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 impostorscore=0 spamscore=0 phishscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 suspectscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" This is needed so that SEL reg values are restored on exit from IFPC. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 82 +++++++++++++++++++++++++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 11 +++- drivers/gpu/drm/msm/adreno/a8xx_gpu.c | 1 + 3 files changed, 87 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a6xx_gpu.c index 61c6b0e781ce..e047ed550347 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -946,6 +946,7 @@ static void a7xx_patch_pwrup_reglist(struct msm_gpu *gp= u) A7XX_CP_APERTURE_CNTL_HOST_PIPE(PIPE_NONE)); } lock->dynamic_list_len =3D dyn_pwrup_reglist_count; + a6xx_gpu->dynamic_sel_reglist_offset =3D dyn_pwrup_reglist_count; } =20 static int a7xx_preempt_start(struct msm_gpu *gpu) @@ -2535,11 +2536,60 @@ static bool a6xx_progress(struct msm_gpu *gpu, stru= ct msm_ringbuffer *ring) return progress; } =20 +static void +perfcntr_select(struct msm_ringbuffer *ring, enum adreno_pipe pipe, + uint32_t regidx, uint32_t *countables, uint32_t nr, + uint32_t **reglist) +{ + OUT_PKT4(ring, regidx, nr); + for (unsigned i =3D 0; i < nr; i++) + OUT_RING(ring, countables[i]); + + if (!*reglist) + return; + + for (unsigned i =3D 0; i < nr; i++) { + /* + * Bitfield is in same position on a7xx, but only 2 bits.. + * which is sufficient for NONE/BR/BV: + */ + *(*reglist)++ =3D A8XX_CP_APERTURE_CNTL_HOST_PIPEID(pipe); + *(*reglist)++ =3D regidx + i; + *(*reglist)++ =3D countables[i]; + } +} + static void a6xx_perfcntr_configure(struct msm_gpu *gpu, struct msm_ringbuffer *ring, const struct msm_perfcntr_stream *stream) { + struct adreno_gpu *adreno_gpu =3D to_adreno_gpu(gpu); + struct a6xx_gpu *a6xx_gpu =3D to_a6xx_gpu(adreno_gpu); enum adreno_pipe pipe =3D PIPE_NONE; + uint32_t *reglist =3D NULL; + uint32_t *reglist_sel_start; + + if (to_adreno_gpu(gpu)->info->family >=3D ADRENO_7XX_GEN1) { + WARN_ON(!a6xx_gpu->pwrup_reglist_emitted); + + struct cpu_gpu_lock *lock =3D a6xx_gpu->pwrup_reglist_ptr; + int off =3D (2 * lock->ifpc_list_len) + + (2 * lock->preemption_list_len) + + (3 * a6xx_gpu->dynamic_sel_reglist_offset); + + reglist =3D (uint32_t *)&lock->regs[0]; + reglist +=3D off; + reglist_sel_start =3D reglist; + + /* Clear any previously configured SEL reg entries: */ + lock->dynamic_list_len =3D a6xx_gpu->dynamic_sel_reglist_offset; + + /* + * Ensure CP sees the dynamic_list_len update before we + * start modifying the SEL entries: + */ + wmb(); + } =20 for (unsigned i =3D 0; i < stream->nr_groups; i++) { unsigned group_idx =3D msm_perfcntr_group_idx(stream, i); @@ -2567,17 +2617,15 @@ a6xx_perfcntr_configure(struct msm_gpu *gpu, struct= msm_ringbuffer *ring, =20 const struct msm_perfcntr_counter *counter =3D &group->counters[base]; unsigned nr =3D group_state->allocated_counters; - OUT_PKT4(ring, counter->select_reg, nr); - for (unsigned c =3D 0; c < nr; c++) - OUT_RING(ring, group_state->countables[c]); + perfcntr_select(ring, pipe, counter->select_reg, + group_state->countables, nr, ®list); =20 for (unsigned s =3D 0; s < ARRAY_SIZE(counter->slice_select_regs); s++) { if (!counter->slice_select_regs[s]) break; =20 - OUT_PKT4(ring, counter->slice_select_regs[s], nr); - for (unsigned c =3D 0; c < nr; c++) - OUT_RING(ring, group_state->countables[c]); + perfcntr_select(ring, pipe, counter->slice_select_regs[s], + group_state->countables, nr, ®list); } } =20 @@ -2591,6 +2639,28 @@ a6xx_perfcntr_configure(struct msm_gpu *gpu, struct = msm_ringbuffer *ring, OUT_RING(ring, upper_32_bits(rbmemptr(ring, perfcntr_fence))); OUT_RING(ring, stream->sel_fence); =20 + /* + * Update the pwrup reglist size before flushing. Kgsl does a shared- + * memory spinlock dance with SQE to avoid racing with IFPC exit. But + * we can skip that since the ringbuffer programming will be executed + * by SQE after dynamic reglist size is updated. So even if we lose + * the race, the register programming in the rb will overwrite/correct + * the SEL regs restored by SQE on IFPC exit, before sampling begins. + */ + if (reglist) { + struct cpu_gpu_lock *lock =3D a6xx_gpu->pwrup_reglist_ptr; + unsigned nr_regs =3D (reglist_sel_start - reglist) / 3; + + /* + * Ensure CP sees updates to the pwrup_reglist before it + * sees the new (increased) length: + */ + wmb(); + + /* Update dynamic reglist len to include new SEL reg programming: */ + lock->dynamic_list_len =3D a6xx_gpu->dynamic_sel_reglist_offset + nr_reg= s; + } + a6xx_flush_yield(gpu, ring); =20 /* Check to see if we need to start preemption */ diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/ad= reno/a6xx_gpu.h index 3491a24a9320..f3cc9478b079 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h @@ -21,17 +21,19 @@ struct cpu_gpu_lock { uint32_t cpu_req; uint32_t turn; union { + /* a6xx: */ struct { uint16_t list_length; uint16_t list_offset; }; + /* a7xx+: */ struct { uint8_t ifpc_list_len; uint8_t preemption_list_len; uint16_t dynamic_list_len; }; }; - uint64_t regs[62]; + uint64_t regs[]; }; =20 /** @@ -100,6 +102,13 @@ struct a6xx_gpu { uint64_t pwrup_reglist_iova; bool pwrup_reglist_emitted; =20 + /* + * Offset of start of SEL regs appended to pwrup_reglist. This + * is equal to lock->dynamic_list_len if no SEL regs are appended + * to the end of the dynamic reglist. + */ + uint16_t dynamic_sel_reglist_offset; + bool has_whereami; =20 void __iomem *llc_mmio; diff --git a/drivers/gpu/drm/msm/adreno/a8xx_gpu.c b/drivers/gpu/drm/msm/ad= reno/a8xx_gpu.c index 6c040f718176..2ce7c6ac4521 100644 --- a/drivers/gpu/drm/msm/adreno/a8xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a8xx_gpu.c @@ -468,6 +468,7 @@ static void a8xx_patch_pwrup_reglist(struct msm_gpu *gp= u) } =20 lock->dynamic_list_len =3D dyn_pwrup_reglist_count; + a6xx_gpu->dynamic_sel_reglist_offset =3D dyn_pwrup_reglist_count; =20 done: a8xx_aperture_clear(gpu); --=20 2.54.0 From nobody Sun Jun 14 01:34:31 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 266CA3F20ED for ; Mon, 4 May 2026 19:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921734; cv=none; b=AETdIZ9OhnRODUkBolxjRtJvvDouyVn+cDGq0jQYPzQhYV6lH20/pBAUSn6e1nNpYJQqmhGoqjUOz5NNS/9GYt/NGReXV551jtkL+ckcmeL8XQ6KQKvLS+wHx6E5/oC9wUEoHxy7syltGZXtac7cAPapCE8RWsqZ7isdZohiwpo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777921734; c=relaxed/simple; bh=3ZK8+sf7TdzMV+59OQ6CIU6fiDFZ7LVgZ0ccGqZAxCE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FFYgvmbusOtrNrx+QY8LGIw0EQsOijXFq1DncV92JnX4qtFRrChNz2EMx1nEqtgDUQI4Udj9uaoC7GiLlZyNbgvtOxjpebjdJ2OeVF0CtpVCHATUK4vkE/rkwuH3QneK/a7E2Wjd6uh4H7wD2gelvCiEDQqBtQ9MQJYoMR0WgrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=PaFmOxjs; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=FBLxTBpV; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="PaFmOxjs"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="FBLxTBpV" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 644FOtfU1346410 for ; Mon, 4 May 2026 19:08:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=k0Z25Ri0qsZ f4kdu4iu99TPanG49TW6penprmyqGHx0=; b=PaFmOxjsXBrkd/tQKSEVFdcgL1C yyaky2OyHEiB6aT8wjuO0n7hFAKM+MOmWiCuxMQwxiVJ+j12kKKf7amX+0aJQCCb UGcy91PzYaZyP7oeyFEIEsaWVwFUDtW8EK5uokOp0+KnHFdCVwGxu4V8zetA1tXt 5ACrDsRZ6SaTg5C8ID5vZGu/ghIWmeGVOz6NqBC1oGpqu0JQlaPFkij8jQh1D4VD mqy0Oe1haBxSBJmxvADdDSIwNho5eZt26+548JeWKROPgui4AZ1mG44ef/VcoCyo RP2/GJbNt8c8mIErL4wwobLrJYY8mWNmmgRZSyvf/aE+GF/75y0qb44ZZhw== Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dxx2x8vk0-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 04 May 2026 19:08:51 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2b79f4b35b7so41207405ad.0 for ; Mon, 04 May 2026 12:08:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777921730; x=1778526530; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=k0Z25Ri0qsZf4kdu4iu99TPanG49TW6penprmyqGHx0=; b=FBLxTBpVBRRwJ+eb7tJ90KJEv0VPj6r6XIYMXzTW8K74VTV80QyB1l7mg+y7zjZfrV Q/JQN3PXpMn5IBOKSB/4/wAY6teauvsdv4ANl2RZmsUfMMxwWWWEUX0xZUZJkvmD61vR xa1qJZOetK/Le1VtA4MPWtdtjO5ABM3edSspkdokqbL7cGo3winTfWaghbpKZTkaqtS3 OIH7mRFmY+mTdt9xNu4VNRpNA7m3O6+cTduZjwXL3MUdobfjv3B47rJPrESqj1wPF2v9 73hPYB0WFN5akmWAmVk79yVS+kKfCmAwafcz8LywLxqtVRSjMGE5CFGIiJE3Iw70+I23 19kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777921730; x=1778526530; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=k0Z25Ri0qsZf4kdu4iu99TPanG49TW6penprmyqGHx0=; b=lwMSn7Dcp94sageEKaDSZszTNvnIDD1H/feO7OXX0Xj+KauseFw0JnKN/vwOJB4D58 eM39rd+PAouEQoJ2Pdp/OlxRRU64souE4y6EwYLytewSSkDI//qzT19fsGp9a8RRx5TS n0uh1AH+a8TozbdgAeiAhwF0+MSB/XaG01nBQDd21tbi37r5ygKBL+m4rYSd4na922Mr J9JnAVYQCljrHwdZ2wxA03LuH7latQeGrVNlE+jTVdR9uuFFsT5/7AKHZgSRU1wH4ogD qKsJcg6aBcPnrJetxmUHl62y1FOXbMjmfmG9EH5aQrX/Mwj9vsLx5mAY5Dk9+60Bu4Gu 5pNQ== X-Forwarded-Encrypted: i=1; AFNElJ9pycJ/sQfaQYqmeP2W6CdyRzIWDHXtn9Fobs6zJdW0wCRENnRhwHvlRpBJ2egJtJG14XpOlJEk086mr+w=@vger.kernel.org X-Gm-Message-State: AOJu0YyPXXRPtkVUxUMzXZ5j+ewoKlBUqq+1UV1EhK1+4OqIADSWItat h1QMY6yK2uvlEPNCYFHm4vdiB73Y1zyjdMP5FaYRC82DqFlt+dIuvZjAo4A2xd6g4rDNTZth7be i4zrQ2nfLc7lmK4V1K0EFetGayN+U7SK2FBHSQJkxVKPc9qscBPv1HY4jCoDSwjKlOPw= X-Gm-Gg: AeBDieuuEkqeRBZbkm9dGzkzbgmFlHFc6Urev4Ct8Oucq2Z3GJhVuc2x5HjkX+nbGnj ioxodeGjbpMJAoIPaX1SP/1QTahqMej80L6DKY0cwHmA8qfcIcJTPIeLHunw5l97PaOrchp+xSp WOOV9ArmHF8HPK8G/1DcMI6K2AsCb8bbXKnnIZL+2N/Qs9CEsz5MJ4os1yYEb0kOdUrIlo2R7Hi oMkyc4ijIdnaF1BtKI2tnampl8zsrRq8ey/aEqkFTEdabYNQrXvkiYutg+1E0ysplZ6A+i/7u4x 95p/UAdyBHwApt4GJMYru9f4K79NM46WGifYWd9LP2sjB/bah4F5ZXw78lWNpsMrq4Yb4aK45ib rmAIk27MWaBMMf092pwzWtC/rHnTt8SgihzzjA3I/uYY= X-Received: by 2002:a05:6a20:4321:b0:39b:8b8b:39ce with SMTP id adf61e73a8af0-3aa3b75d1d7mr67045637.28.1777921730358; Mon, 04 May 2026 12:08:50 -0700 (PDT) X-Received: by 2002:a05:6a20:4321:b0:39b:8b8b:39ce with SMTP id adf61e73a8af0-3aa3b75d1d7mr66994637.28.1777921729784; Mon, 04 May 2026 12:08:49 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7ffbc8ee1csm10487520a12.25.2026.05.04.12.08.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 May 2026 12:08:49 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , Sean Paul , Konrad Dybcio , Dmitry Baryshkov , Abhinav Kumar , Jessica Zhang , Marijn Suijten , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 16/16] drm/msm/a6xx: Allow IFPC with perfcntr stream Date: Mon, 4 May 2026 12:06:59 -0700 Message-ID: <20260504190751.61052-17-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> References: <20260504190751.61052-1-robin.clark@oss.qualcomm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=U9eiy+ru c=1 sm=1 tr=0 ts=69f8eec3 cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=EUspDBNiAAAA:8 a=5obZvuzjGUYrwyXX1KsA:9 a=1OuFwYUASf3TG4hYMiVC:22 X-Proofpoint-ORIG-GUID: CEKr1jgYcR64uhH0s1xtKDX81Ima4-Iy X-Proofpoint-GUID: CEKr1jgYcR64uhH0s1xtKDX81Ima4-Iy X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA0MDE3NSBTYWx0ZWRfX25NFF9DVh0c7 yvl9XkZwHKCFmkiVN0mlPYUKHkFujXeskk402oyX0YViPVMUPUC4eE7wfIO4hXR+MZSDKs9iGAI 1gYn038alglTYxYvBW3JzRGy3RIJJGtf9p0S2u6jzgV/AIQV6w86QESatrUn4Ii1ktKrgInPBH0 +AgAL2Jo1KBj+f/b2uxzRUChx+53mA9pSdHNJYHkhZe+t+7hTqB+g3LK0YRHUOO00QpjQoI3dQe s5JCeo2rT4laxsw4gCnnw7qw0iwrZLYrOd2HPbyw9V2rl+EhOkhMWC/agXEcwnWATA6N7yfhMhd iYatETgCMAqbpjisnE3nhqDGv3ZQbcTS0k+LfWi96118BLSSHsyoiYS7iH0BBfOEXU0LDcmhN1N aP81NIW8kOnqQLB6lPEQaLc3LRyHT4Fnjd7dz/+6xOtqAeHFkoMrjtxCk4YNamJ9WS/az7SWP0I 1iTc0DCZ6tsOls+Aw4g== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-04_05,2026-04-30_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 adultscore=0 phishscore=0 spamscore=0 bulkscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605040175 Content-Type: text/plain; charset="utf-8" Now that the dynamic pwrup reglist has SEL reg values to restore appended, so that SEL regs are restored on IFPC exit, we can stop completely disabling IFPC while global counter sampling is active. To accomplish this, we re-use sysprof_setup() with a force_on param to inhibit IFPC specifically while the counter regs are being read, while leaving IFPC enabled the rest of the time. Signed-off-by: Rob Clark --- drivers/gpu/drm/msm/adreno/a6xx_gmu.c | 4 ++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 2 +- drivers/gpu/drm/msm/msm_gpu.h | 10 ++-------- drivers/gpu/drm/msm/msm_perfcntr.c | 8 ++++++++ drivers/gpu/drm/msm/msm_submitqueue.c | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c b/drivers/gpu/drm/msm/ad= reno/a6xx_gmu.c index aba08fb76249..3fe0f1cda46a 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gmu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gmu.c @@ -2034,9 +2034,9 @@ static int a6xx_gmu_get_irq(struct a6xx_gmu *gmu, str= uct platform_device *pdev, return irq; } =20 -void a6xx_gmu_sysprof_setup(struct msm_gpu *gpu) +void a6xx_gmu_sysprof_setup(struct msm_gpu *gpu, bool force_on) { - bool sysprof =3D msm_gpu_sysprof_no_ifpc(gpu); + bool sysprof =3D msm_gpu_sysprof_no_ifpc(gpu) | force_on; struct adreno_gpu *adreno_gpu =3D to_adreno_gpu(gpu); struct a6xx_gpu *a6xx_gpu =3D to_a6xx_gpu(adreno_gpu); struct a6xx_gmu *gmu =3D &a6xx_gpu->gmu; diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/ad= reno/a6xx_gpu.h index f3cc9478b079..eecc71843bed 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h @@ -280,7 +280,7 @@ void a6xx_gmu_clear_oob(struct a6xx_gmu *gmu, enum a6xx= _gmu_oob_state state); int a6xx_gmu_init(struct a6xx_gpu *a6xx_gpu, struct device_node *node); int a6xx_gmu_wrapper_init(struct a6xx_gpu *a6xx_gpu, struct device_node *n= ode); void a6xx_gmu_remove(struct a6xx_gpu *a6xx_gpu); -void a6xx_gmu_sysprof_setup(struct msm_gpu *gpu); +void a6xx_gmu_sysprof_setup(struct msm_gpu *gpu, bool force_on); =20 void a6xx_preempt_init(struct msm_gpu *gpu); void a6xx_preempt_hw_init(struct msm_gpu *gpu); diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index 67f1e84eb631..93124c032dd4 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -93,7 +93,7 @@ struct msm_gpu_funcs { * for cmdstream that is buffered in this FIFO upstream of the CP fw. */ bool (*progress)(struct msm_gpu *gpu, struct msm_ringbuffer *ring); - void (*sysprof_setup)(struct msm_gpu *gpu); + void (*sysprof_setup)(struct msm_gpu *gpu, bool force_on); =20 /* Configure perfcntr SELect regs: */ void (*perfcntr_configure)(struct msm_gpu *gpu, struct msm_ringbuffer *ri= ng, @@ -378,13 +378,7 @@ msm_gpu_sysprof_no_perfcntr_zap(struct msm_gpu *gpu) static inline bool msm_gpu_sysprof_no_ifpc(struct msm_gpu *gpu) { - /* - * For now, this is the same condition as disabling perfcntr clears - * on context switch. But once kernel perfcntr IFPC support is in - * place, we will only need to disable IFPC for legacy userspace - * setting SYSPROF param. - */ - return msm_gpu_sysprof_no_perfcntr_zap(gpu); + return refcount_read(&gpu->sysprof_active) > 1; } =20 /* diff --git a/drivers/gpu/drm/msm/msm_perfcntr.c b/drivers/gpu/drm/msm/msm_p= erfcntr.c index 39bec201d5c9..d8ec65fa25f0 100644 --- a/drivers/gpu/drm/msm/msm_perfcntr.c +++ b/drivers/gpu/drm/msm/msm_perfcntr.c @@ -256,6 +256,10 @@ sample_worker(struct kthread_work *work) return; } =20 + /* Inhibit IFPC while accessing registers: */ + if (gpu->funcs->sysprof_setup) + gpu->funcs->sysprof_setup(gpu, true); + if (gpu->funcs->perfcntr_flush) gpu->funcs->perfcntr_flush(gpu); =20 @@ -290,6 +294,10 @@ sample_worker(struct kthread_work *work) } } =20 + /* Re-enable IFPC: */ + if (gpu->funcs->sysprof_setup) + gpu->funcs->sysprof_setup(gpu, false); + smp_store_release(&stream->fifo.head, head); wake_up_all(&stream->poll_wq); } diff --git a/drivers/gpu/drm/msm/msm_submitqueue.c b/drivers/gpu/drm/msm/ms= m_submitqueue.c index a58fe41602c6..1a5a77b28016 100644 --- a/drivers/gpu/drm/msm/msm_submitqueue.c +++ b/drivers/gpu/drm/msm/msm_submitqueue.c @@ -42,7 +42,7 @@ int msm_context_set_sysprof(struct msm_context *ctx, stru= ct msm_gpu *gpu, int sy =20 /* Some gpu families require additional setup for sysprof */ if (gpu->funcs->sysprof_setup) - gpu->funcs->sysprof_setup(gpu); + gpu->funcs->sysprof_setup(gpu, false); =20 ctx->sysprof =3D sysprof; =20 --=20 2.54.0