From nobody Fri Jun 19 09:06:01 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 052B02874F5 for ; Fri, 24 Apr 2026 15:11:51 +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=1777043514; cv=none; b=nJa9DEZWhZ/dcJisZdVROPJ6pfgNubL1aBLvpYMV4CmdaTYbqRvFVVuEX83vyVTO0LmTV2dPeFBEZblokLi4zULLR0hcZ5nGeigr4wZ1sXy78jy/vJLw0doU78doss29jUwY8psS0L1WEUY0IpZhiFp9f2hlZsmVZ88b+jkru18= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043514; c=relaxed/simple; bh=l7fX7qgLWU2nysk8C7pTczMLM8qHV6Lu9EcZ4n7sqcQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Db6Hk0mRhVg4bsJLi6wsqN56kPSlfgKklfHU6T9pD3yep/NAw0QAXoLkwOJo4+rHIrhIlNSQi7q24LlrsZmYsoP4JghIF0evsJucXAj3ChJJ8VmGjdwKXX1pM6MVQK4u0AQgfFNAIlwCcDsAnDR3LK63WbF92rjAMhWq92hV6RQ= 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=gNA+Ua8N; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=GANDRc71; 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="gNA+Ua8N"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="GANDRc71" 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 63O9HuY5756696 for ; Fri, 24 Apr 2026 15:11: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=pE9fXChIGEo 8FDw5QRdTqq3iuM4LcbmSNoC6ukdSKZg=; b=gNA+Ua8N9fmX/lHnCx/gwfY3O+E M12Tid6KV4hqwHsjy1lWH8ta2ktrc1H5fm29PIYxBiN2GdNM5lGbA6HnrnkdxNCF F4wKEcHWrqI6eyarPGCTyw8Allusg3bOOiWr4JK41ArRdAZA3JEAn9RQcJbeUBaX 7lMK0TE7hSqxebjv9WG5XYZgEmWMYl64b0v/VmvgaI67JrN8FcIV21mpob7Yu3G7 EQhhP89oYVrCxIp9IJjze3TlIBG/PAjOcjoS1fcbaZdXGeoSdCoR39NzovYpLik3 PZBb04ZBK0BjDgAUjOE8CgzTioFGxomcaxFOvR8iNMstEjYDK45xPtfxoZQ== Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dqr4bmn0c-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:11:50 +0000 (GMT) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-82f6610a6c8so4201398b3a.2 for ; Fri, 24 Apr 2026 08:11:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043510; x=1777648310; 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=pE9fXChIGEo8FDw5QRdTqq3iuM4LcbmSNoC6ukdSKZg=; b=GANDRc71wJUJr6bY8uZlUa1+t7VFG6WGAIE2cxOmLCuIaPUO2px0WJ03N9Jbren1IU o8ZrOhv/96Dt7Jbi89cNgbCB9Qd/UNox5ELifaOwbnQI0lR8IzdIohdB4DdLxpcIXI2Z Jj87277FcdkT6BI1ggyZh1B4QARff1aBfWKFPlTkBo8xHG0+sxnnFDrClGGKDr70EjLU ULDKcdiUvSca58pVPLiWjZmgK6ylAurNpfDHstIwcN/309gpGoh6JXXMuWG3HzxAdu6w iyj9mQ3dwW7vAlz7kXrRyZy/CbdSa6vXDzTdB8GS850QHqig09vFig1eFSnWZgS7Qi/n U8Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043510; x=1777648310; 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=pE9fXChIGEo8FDw5QRdTqq3iuM4LcbmSNoC6ukdSKZg=; b=Tua2HGxL8+jtBq2ZjnO8z+axciNPxOgI/O8B9HzFJJS1JAEeH4YfS8vwukB2NZmF2F i0KrHqg9rUkWYHLG6Ui33Sd49BhTqmZtHxLOzoh+YTSX4J36CXQUOUf4es33Z/hcSNiZ f52BjVth5d3tNyYKJcrTjGoY986lfXWuuKZDtpoIT/Tcm4Ev640QbGDyYTWWtvFikZkB iFQRfsF7ajgF0hctnypBQPLiqyM9VCwn7yn1gdvA4cYevp+cJl2lHyETUNa/iqEFPfZI T4v/rOw8Tl7t5rKm8LeLgLqXZq/NW9nY3DuNF3Jqf/ZGzWxadiehX2h3BgrGvunsDCgy B6lw== X-Forwarded-Encrypted: i=1; AFNElJ8Z1OUIUyJ8oWZSbbTXRdz/Q1nYOqQYsV2hV0gNKmAd4ahY077P1AJUoiyMhg64bOlFuz6RNRKjBYkLDKg=@vger.kernel.org X-Gm-Message-State: AOJu0YzrB3MElYGN3M0GO5a66msuRqD5kgJvzy67iWLIxriVN4BH91nx CqQZbh98xaRN4k5efZffsKLyRJPL8iTs/aKJXzhHUczlpX+NhKocz9ws3ZePBx96dxTf+pzwyIR xoRGpf2KvAPRZLv8LTPWeXrWzLu6nvpV33Z4yB+H6E0TwD2LG42lwL88Q9WXsKiP9WL4= X-Gm-Gg: AeBDietbLu2pgWsXL35Qx2XvMOruJV5p58DR3VsL3ThsG5fSjcsp++pBQvghEFb/+hs dPOr2L0dPp0qxnthdBPaiSPggSAbzBo9pBCfAMAn/eQpn5sc7VRPXj69IwfP6Cyy4Rz5NdtU1oP 6rdB3biFlFfCo3c/i3ci25JCiqB5lMqQWO0dWhn/EuV9NwgM8IP81U6MaG9oTteKFwCIcqij0Dk aiWt8jAKrtcMbLUyZR7k18jeHiEOjOUehQRPUfJpCXfgpDlhuOiiGy0v/Hz0i7nnI/DVTQN7Gjh Y0PP38F12V4WbdN6+Dw+eKhXZGpbzF3nOzy79UVvmrhoJlvD4YfNkXML+rqxyvu5hNqA58VUmdA rBqZJW0sF1ns0wyzbCUlOo6ox1u0D2pi1T2ww3aK4ReE= X-Received: by 2002:a05:6a00:420e:b0:82f:6e7:1527 with SMTP id d2e1a72fcca58-82f8c8beeb9mr34752539b3a.23.1777043509413; Fri, 24 Apr 2026 08:11:49 -0700 (PDT) X-Received: by 2002:a05:6a00:420e:b0:82f:6e7:1527 with SMTP id d2e1a72fcca58-82f8c8beeb9mr34752508b3a.23.1777043508701; Fri, 24 Apr 2026 08:11:48 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8e981992sm28965049b3a.7.2026.04.24.08.11.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:11:48 -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 v2 01/16] drm/msm: Remove obsolete perf infrastructure Date: Fri, 24 Apr 2026 08:10:36 -0700 Message-ID: <20260424151140.104093-2-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX6XiL85cvMoJf u4amrM2MHwJeW1rC+R6nQLWHrTvGbLUhSzS1bRUNgtbvML6kjIgtj2jWC6FjiBQrO612clwnWYB wFMJgG8BIKN5o7iVrljyIimH5Ir79+iiPNENDVhUZS8czsWHVAezRMHxWlchENQPDAvLZSfv21Z 0S7KldgiY1vk6ziqpqEMFO+W96HljDWTvMRGIQuExbZWp1r3HdY0/4EHcTRwieJkZrSmnlJFyW0 +SY6nfgV2pix/Vfy4at60eLlypl8vWx+Qr8vPZqrY3wQQqBXLWiEuy108U8Vf/SPs5VBECm2V+A tCAJZUEUzUyBa05TfiEYnR7GwN+Zpgg21Kc12iWTwRzj5nfKL5HEsn0NM2L8iZnhxB6S7n/kCCw 0fcGqz3YXO+L1J/ZWzL1JjIy1CovWS1rtnesk9kmZ6TcQ90t6wIH2Dd7ebEl4c0u+BJbzmy5Lch ACUrnf7t2Ox2imhmojA== X-Authority-Analysis: v=2.4 cv=TtnWQjXh c=1 sm=1 tr=0 ts=69eb8836 cx=c_pps a=WW5sKcV1LcKqjgzy2JUPuA==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=istQItjhLDCz62CzcYoA:9 a=OpyuDcXvxspvyRM73sMx:22 X-Proofpoint-ORIG-GUID: ZFOUUUnOMYdnI3ExGb5cxXGWoo1afAMV X-Proofpoint-GUID: ZFOUUUnOMYdnI3ExGb5cxXGWoo1afAMV 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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 --- 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.53.0 From nobody Fri Jun 19 09:06:01 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 32CFB26C385 for ; Fri, 24 Apr 2026 15:11:52 +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=1777043513; cv=none; b=KD+DfBQJYjcG614WNLDQTGG74aDlkoj7IZTJq3WOy0poybQaN6WTGyzm0wkqFYNc3zKdI64iBU1CSuDUPHq9KxUTRA/iM+MJSDUm24tfXI7GJA9EeFpDbg3OxilghU6PVwjLqrMMohM2c/1JEYwJZf9Og+m1zjLojbPpQSXFG+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043513; c=relaxed/simple; bh=RMCacskoFmZ9/Ng6hAjRi+I45M638ggU0L3+USVXwaM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sakKu/mgnXhgPdEKeBnSH5dXuaoZlk1tX/QbmR0FDQtJoD2VRYbTR5NjB6Yko7HeX/tBFxqPRZnfpiK4fsEwtScjLMCIKNioE6k0kYljdgi226Z/I3bOvbLrk6WQxcVhvc8oV39GosMuEINFLZg6UL4B7vslXoyv58WHl/fgr/w= 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=gPgu5Hdw; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=EwEArBRq; 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="gPgu5Hdw"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="EwEArBRq" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63OAeSR31959571 for ; Fri, 24 Apr 2026 15:11: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=lcPhu9r6gLN Un/M0FOO+8vu6c2tQ6RhDeBZbp1avftg=; b=gPgu5HdwyKtcYYBAr726GWrr65T FSrHH2sMTX9yA6xeW18FV+hz+y3yvdmRgAO/0D9HC4X0JDvcwKSeTtzkVBNdMF+u Xul+dd6YUjOZpzee2xookpDRdKlQpjoOBOp4qt62sCyp0tXEjDsLNyphU8p9r6fV qSgwCdYsn/emo2yobQTl46FRbKL3k/+1ftc4jLP6PieXmhM8+KGyfRisbRqbEMrG Wr6EvLE3XvoXkQlrczTX5uUnUDEVJGAjs0bWLWtCNdYB1ocZbrIHuTcPtiSLSfgH 3TLAfuAcrq2CpGbwsQtCDGFQz+llD9WBffsHUd8iqsefSDTo9AfEiqSiMdw== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dr2nrjcqa-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:11:51 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2b79f4b35b7so20233685ad.0 for ; Fri, 24 Apr 2026 08:11:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043511; x=1777648311; 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=lcPhu9r6gLNUn/M0FOO+8vu6c2tQ6RhDeBZbp1avftg=; b=EwEArBRqwbx28JSlE3/amzKiYdmKbCwYDWuLMLfT/19zP6D1uh8qBDYQFhcHbiE10t rGujB91vtq6XQQgQqNXXmg0KI/5/AjEiUlrxYJFY7mTpRxvv0IPk05mv0DDJrMVH0hU1 uygvy4fcpuzwmlfTqqFKYUMl5kZJpAODYCeJodPBk5kRbIODatUr6IbzjNHRG86aOoFg NAPMsu2BFBee009VYA+v0epMAI5md3DJ9lX2AybRsbLqLR3t0Ny/7VaN03AQhECkJEdG zqd6xDGjZ90oJquXSmj8FPyXcuoZwXTRykNRqExXCbqdRBBTRHVTe4WwHM9eaWBzAfQX 6uCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043511; x=1777648311; 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=lcPhu9r6gLNUn/M0FOO+8vu6c2tQ6RhDeBZbp1avftg=; b=XMZr/4bNoeDNQuKh49DnADUaURHpSmPninfi1nkK7SQDGWo52bJV9ZiolIzxmKrFtA TPGcAOoJLh45krOm3Fpk76QTkJKeug0m2eDin4OSOuQYKuEvFyPiTYnVctFhIW1ZTwwj Sw73WL15lOTKcunyy1cipXeDCKuMivJaP6R6fZV7HTYP2/jJbSp0+T/aDEtL9YsFF7xX D6CaatiB8FxwbimaryzywYKof9fwGew0g4NNbs9Hj5YjnjA2TFM1i4qN8Fiu/ITc7RPh hsc/3vRoW8E6XYQ2VeM+IJx3drIar5Zgn8+hFDVJmiY/gdfSM2UWjjb5Vvek2lzBkfBr mKyw== X-Forwarded-Encrypted: i=1; AFNElJ8Fj2gzmhOzzG04ima7m64fJPkz+1kmtmwYNUi0+T3g2OLvxr/o7rdJxcfBhFLwGaaQBhkIj6J+CL5+wHA=@vger.kernel.org X-Gm-Message-State: AOJu0YypQxaD7S02gX3ltSCRcZS0oS62LPUOoGHi1aZumm5LBebYuSbB G5kVTZ2fEulRegAFV0jWUJUXfGa2bktt88HtiqZcnq8YQCvlZ7Id73kDsMEBOm80r8L2DkTikm1 Xzdnq8T5qN+P3aKzOZjuZ5xO01r/zhIPUAKloQzmVdg6q+nkAZGODxHJWEIe//wHcsOA= X-Gm-Gg: AeBDiesR1Bw/xAH5uZObETQYjP7IaTPfZ0IOGJLAC6/R2ri+9N6Bl+bhY9bUSw9F3cy HufPBK3U/DaitqUJ++6H7FJrV16gNN/XJIISxp6IRjfs00Twf0Sq7Xfzd7oaNmVU5XjEJTUcXhn aLr+pvKPCfv6RFDgZc5DwNNYOURZ0INvF9lwbV4uCqy0GyGxiVOTxTAAzZ95hNSKgGtmBPwe3GK 3+7wJv90nMSA3/XYsc7N9YYJ1kJz5i12lOVBeNMuQNoT+qsIJUjfliy2tXIC4SM6jG0TFqjsBKl y2ZA8f7mKdDa0Os8N9+LuXUZ2pMdcSdLD0GlVnTrbbkya2wbTXiRJl6tmdAHS3PBVbIbX949dqG XoWsdYy0dcYeuLnKVlW4Ju8jsWG7G4CK/ackHvzH1QpY= X-Received: by 2002:a17:902:bd8c:b0:2b2:50f6:cdd9 with SMTP id d9443c01a7336-2b5f9ecb818mr216666915ad.8.1777043510603; Fri, 24 Apr 2026 08:11:50 -0700 (PDT) X-Received: by 2002:a17:902:bd8c:b0:2b2:50f6:cdd9 with SMTP id d9443c01a7336-2b5f9ecb818mr216666745ad.8.1777043510082; Fri, 24 Apr 2026 08:11:50 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b5fab0caa9sm225689865ad.40.2026.04.24.08.11.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:11: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 v2 02/16] drm/msm: Allow CAP_PERFMON for setting SYSPROF Date: Fri, 24 Apr 2026 08:10:37 -0700 Message-ID: <20260424151140.104093-3-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfXyQaN3tJTTssP 92FG2alL4rzISsWbjKbxuy4kQz60JiAcCDhy23xDLXKQcSLFewHLH4GSE7ekZ3a89yYizQTJVk6 JNOI4CK06QcK02VjqQw7YgA4JCbROh3b3Vh4+hJHDxlBl8FE4OKP+J0x9lLmU4a6zsFEKXFComQ 0X94mE3hwO4RlKLdlZWxT+V7hh3PxRleltCEKKWuDp3GecnwcPGIMvjqzQUk30rGQOQ80+4UUIF +hapwXsVe5rk6aCIPyWVBAUzrFXh1AMlHphPI0vS9tvMfS3FiPm29YOag0flW6XpgG8zlHpFY+K k3i8vCLic1NNxl68kK4CHDhAmw8RKckeZWmH/1G0aHw+2LuB1mKbSL8l7RERUH/Rh1E4QyU/fob tdtzy8D7xI7zY2nrmeS+7OflyTLRyloxfENhk4uo/qGazk+Nc3QELvhjpT5MJFyWKZ3lQwFN50g yaU905b2DzTxUo3Z5HA== X-Authority-Analysis: v=2.4 cv=UqpT8ewB c=1 sm=1 tr=0 ts=69eb8837 cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=ZRXlmS4ShPoOlOK7p90A:9 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-ORIG-GUID: Dipct_fFtA4JTgxhDNK4yRZ44bJvlvlO X-Proofpoint-GUID: Dipct_fFtA4JTgxhDNK4yRZ44bJvlvlO 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 clxscore=1015 bulkscore=0 lowpriorityscore=0 impostorscore=0 phishscore=0 adultscore=0 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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 --- 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.53.0 From nobody Fri Jun 19 09:06:01 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 9E91629D288 for ; Fri, 24 Apr 2026 15:12:01 +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=1777043535; cv=none; b=BOysTynfgmr2mJ+M+EefJmnZ0uD7L2OQAxDvCwvy/wcX/OFmjpn9dBUj8ya7f9PoMZAsFKu7fCZBJpPbY5UKZ1k6Q3kvWK1r9EOYoamnjbnE8hYm18AneVjDUfM+89UOen+kYjHLVfdz0ffwtyRQSfYFs1nTpEp+bGxjeb9tcCw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043535; c=relaxed/simple; bh=ellkL+88Qjtr4mQ4gbWIkkCODJSh7ZpSTSpguXorIzU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mnUjEs6UW2uJJ1ApWXa8dwwOasaHST0mzrl+k7lnMfEkCgAGcKa99WK7r60tsUl7TAyjxzpWuT0gw4nvyaFHdli5Mm6LfA+p0D3NRnrqu1RTTsY1UE/GGK5XMEZWAklfJ3RD2L6g/BEca2hoXKdmc3oxahZF+tAMCh7GzT+NxRQ= 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+KbAfzI; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Vw2Oot0j; 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+KbAfzI"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Vw2Oot0j" 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 63O9AdEN1532371 for ; Fri, 24 Apr 2026 15:12:00 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=YBMNNwjkmrc l5YYqO4Z2jkhlpSzPBwO2d9QQK0QCxPs=; b=b+KbAfzIwtThmlbYjqBMqi6TXii g68QSWzCJ8kLUcKmTYTsg4FwzlBfO1KpKXnf6kc4+Z5+bYhXJWO1r98zkZ3a6E+9 YtpMgU0omqt5iRxRHS7IQZYDBvvIlK3SXchHZCnVJj252C+ajYBx7nDsbJGXceQe VLueiP033Q8nkAnaXy3xxP3aZMy/8sjkXmlGvhqOwPJQFA+m9MghTJgCQEf0sxMN paoGkjrId1rJ6VZ9zJtZt4nkzn5He8DD+tvNQpvwpMZCZl7akIt+LDcToMFk/tkJ PdJHqG3rPjbFuEdxuNs7pSN2Ilw2LsUMTwlzTmpw4+10gnhe39o/HA/PVcg== 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 4dqr26mpcu-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:11:59 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-35d9f68d00fso8127675a91.2 for ; Fri, 24 Apr 2026 08:11:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043518; x=1777648318; 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=YBMNNwjkmrcl5YYqO4Z2jkhlpSzPBwO2d9QQK0QCxPs=; b=Vw2Oot0jPmgU3zjRHKEjFEkL5aa4fksZXdGVnyu9jZgD0Xbk8jwSS8xl6Qy0eXrTtv HsDyu1ww3kx0lJ30+9RQLQvZJz1+kHy73AikLSTRDDkz2xeN86Lr73cFtF7dTGrar1G+ 5RkzgAJ+8WbChhRRZEfoI2Ya+Mdck/5KLI36krWVhAJgAswWQgflvT8ZBiuAYm21xKw5 WggKI6c/OffmSSgLUCNoZmkp7CdEQbDtbqLfJBdxdEE0n7ZNoQ8gJwePveJQ4R6go58Y DG6AVz1eWpRdDQhPgsMn8K74Zr0Ezs9vB7BXuF6XWUMwQy1f17wsM9zyjPPcsfdbIGH3 BiBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043518; x=1777648318; 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=YBMNNwjkmrcl5YYqO4Z2jkhlpSzPBwO2d9QQK0QCxPs=; b=a17DZ+qTFcJ8ABVQZmkrM+lcA7encGXyXVQhM5+JpEd81tawpqnuv2iRHpiNA3WSjv mZFri3PbE2vWKxQ2TWR4Y4zihvBMN19WVP54Lzx/RysZ0ZJUfE1rzCD36ZWDGB/gnZb3 6B4hM5olxGy9aEbGmJabSTtqTvzTCM4h0tohc0Tnxdo+qIutp2yDYUnwaW2ZKK2c9Pk+ NTF6XDpFoxEh6VSeZrh8Pg59wQMukg5P1iSwawAKqydVc+3HD36WbYJ40gtTH8KIJ4Rj NslefLW1XiymVcXrzX8p64ovfx3krGqFtr9LYrtzfc4MtGwDRSO05jbSAL7BSB8+V2VI XFqA== X-Forwarded-Encrypted: i=1; AFNElJ+wk7VyBoe7b1udzBvH9m3r1LX5EsPG2Ul+j5xjJ48pAuomTBb+4FBl4qh9kNU+iyFfyX/Mqb6iXUfSIkA=@vger.kernel.org X-Gm-Message-State: AOJu0YwboRNa1LLWtyN7J2ei4kJ0RnFDCs8OSByZNNjsyi4b7iMEMQr3 c0rg2hyI5150thflUbBKn443QheLNz6kcsEqOOxT44qiGS9FXZlw2V7cUutBehkuOf5ZnMUSTHp j2GJLq4s4E6uwYHESLwnPKxtOF1VglVDQsWzKAJ+QSXCe7yBsTuCI5mvNAVakC+8Cg6g= X-Gm-Gg: AeBDiet5eC51voDs43QveME/MnxrUu6qc/bV9udptxk0obQeLM0sCfHbVzEnEDluWls 6MfX1D2f4kBr/EXKIF8ZRWn7czWBiXMkNhb780ED0wXC50WshvKqsnviubajp8iJmPspkhOODrN BVLAznfR6VAzMM1m2Jcglvt2BFU7zq6sHSQbQs75TsEDgtZcmeTf57X2GjSpHqo9G/erapPMksA ilkxAm3GygnWW4kzhsSK9Awa2Ul79i5+KkOKXjlKT2kYL7rfhCz+SpTv8PWLk/panjVqj+fTtY/ 5EEqkwSXRf3jTZwi7HZNy8XQ3iI0NnfM3+OfwiFRXNZn2xUrHQaSoMO2yTCvUBOyHF/w/L4sBI+ 0AP4EygBWNerpi+GrY9uopFpm45w62nXz27h+5J6lLa0= X-Received: by 2002:a05:6a20:7fa8:b0:39b:8ed1:eb4f with SMTP id adf61e73a8af0-3a08d7a2695mr35676911637.24.1777043516725; Fri, 24 Apr 2026 08:11:56 -0700 (PDT) X-Received: by 2002:a05:6a20:7fa8:b0:39b:8ed1:eb4f with SMTP id adf61e73a8af0-3a08d7a2695mr35676829637.24.1777043515663; Fri, 24 Apr 2026 08:11:55 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7976f8f4e8sm18112720a12.1.2026.04.24.08.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:11:54 -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 v2 03/16] drm/msm/adreno: Sync registers from mesa Date: Fri, 24 Apr 2026 08:10:38 -0700 Message-ID: <20260424151140.104093-4-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: uU6LVEw93_mRRvjevAkRZbGZ9mh1vKY6 X-Authority-Analysis: v=2.4 cv=QLhYgALL c=1 sm=1 tr=0 ts=69eb883f cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=ZpdpYltYx_vBUK5n70dp:22 a=e5mUnYsNAAAA:8 a=SSmOFEACAAAA:8 a=EUspDBNiAAAA:8 a=vMjXctBndKc6M4jOp94A:9 a=-YkrfQbNLgtqXKMw:21 a=mQ_c8vxmzFEMiUWkPHU9:22 a=Vxmtnl_E_bksehYqCbjh:22 X-Proofpoint-GUID: uU6LVEw93_mRRvjevAkRZbGZ9mh1vKY6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX78W2f1rLANVz OKmfTwpdS02868PO0sSGrp1lL/9J1IZ7YnVg3dmaR1IDw9ZesfmjB+YdT6WrlNTYRcoF9SbKqBQ TrJXNZ5ir9v7lnedG4z56fOn1KyO1ExU4QazRGysXOLQUvF1dU4vad9CiH4QFGU1WZ9Lz5JBWLj z/7EbEWPbvRolYBMkcAmNr4BNpXB9Ap4rvQNrWahmCCSY3lvXYNiUYr1Wzv3No7kb+ZayxEA40/ bP+RQw1VI8sSkqH4N0H+KRDUS3fv6lA6iimJ+ZSCaWLBvXtY8kulBHnidZdzB2jtpikR3bi1bV7 lv0Dp7gBlNUsnq2D0epeP+v6ZJmOOf9Wb9eWV+FUjD8raP/mDcaOdotiUVujA9B6EaN/WNoOTHl XrpMzdc16oP6GpujHm9AQyOe53di5+aDsUje3bpXAvp2egdTp8tFxyy1FFZ3dRYsCj2xVaZOnor huKQ6z2YcbmXh+j4r+A== 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 spamscore=0 suspectscore=0 phishscore=0 bulkscore=0 lowpriorityscore=0 malwarescore=0 adultscore=0 clxscore=1015 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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 --- 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.53.0 From nobody Fri Jun 19 09:06:01 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 718BA2BE05A for ; Fri, 24 Apr 2026 15:12:03 +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=1777043527; cv=none; b=JKcni2R2a5z7jsFAQGr/YpmgN8HJl/ap6AL6nDb2G9qm+a/kF2Gl+b9jwczxjqg9MqJ0G6UV4mfjtsad4FKmaBEJFNINoH2EmRvm5M3/hn5CPlr1iApnEy6RuuPYBBbO1hPEbUueTr3yQgbfeLmYTTG4etygDes/YTUR5rCaFbo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043527; c=relaxed/simple; bh=aTyuH8U0kUhFdvlD8ol6e/2cl7QCQMztiuoC3PGNSnA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RGXMBSi6a9o08IBVY4JCXZAzdc749eXDmubXLL3EaHQxTs3imEP0fzxl3/+9211iQolsAv9MuuyUEbV2qXnF35mBgohRKvozlCChXdu/BI/puE3HqbEUvJ20P2YLincAatdmEqWcuqjZiha5cdObCtDxEGU4MQuLyyW305SBksA= 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=hWeQ9PKq; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=KYaMj5sT; 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="hWeQ9PKq"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="KYaMj5sT" 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 63O988e3756616 for ; Fri, 24 Apr 2026 15:12:02 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=QI16Fs2h2zd v8SE9AtXc7UhwYE6xxqWsAVah4Xwkwrc=; b=hWeQ9PKqG854XDq8YtpydEQrjxB raCFmvtcRrek2OaCs8EC1+K4B4mwnjqvrbfW5oWD8L2eHJ7KFRuvgDWhlYd1Kypn l0VapCfFmuz8b2YRBAj7Q2KPCMp6ZsW0UpWk+diFnNVPBlaAHL8IQc5V4TeP7kUf rZ9uhJ8BdBRTz8BYSh5ZoKcOlF0XOr+SxrStXd6BXPzCGJqOyxJSDMcRnULK2Fzl uKoXkHYUX4ncLZPlpKYkoXYxNSVr3jceNypRzlMLkrMpK/LHIRFYO3MG90bb+7TX EK148USmM/ZNAJtjpNF61DAClqu/l2Ih4ue8GhSG6KFtpn7NrdqNW1fpDCw== 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 4dqr4bmn1e-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:02 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2b2e06219cbso99758695ad.3 for ; Fri, 24 Apr 2026 08:12:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043521; x=1777648321; 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=QI16Fs2h2zdv8SE9AtXc7UhwYE6xxqWsAVah4Xwkwrc=; b=KYaMj5sT54NQ5P6L7xhWbWqx7i/QtUBDP7nVRdlso5Vr7r41OoF7Eki4J8rusnPXMH GWB6u5BJ1yht0ZisSW6KZrPhpCfPmPba+EWWVlHZelPcodIwEOhnPtjU9tglaMYpaGIG vqF6gPXPL2g0NHk6s6nZ/Qb3DzNeYR6m6PcJsWGUj2iDafYxKjjHerYf9K2Rw8St1gIG /NAZp861RK8rP7ff+IkwcXMaBiNn1YHHAbmORPDut4oEYR8rM7b9JYsX6E2e28CAGc7W oONbpnspC5gY73KGR0bCOBIORoZXXBZfTX404jpjXXSXSJBzFmRjqhD7a3tkcEVLbHEA xU0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043521; x=1777648321; 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=QI16Fs2h2zdv8SE9AtXc7UhwYE6xxqWsAVah4Xwkwrc=; b=cbwGBWsGa+I2N4zhTJV6aqr60517NlJeAY/Cy/4dDjtrlYn+lrnMR9WTP8T2oR/h3A KDnvHcnhoMNZ23X92MFPC9HU4txLwfRBvHMEfietk1xPlfPnjlgTcmY+6IYrR8Cy63TF 52YQaX2LdFladyKGVLdhobEj4TvnzkRIqpRChhpx+bwqXNz1xBv3BU/d2s23njPwdx2c 2PPNEEZb0ckWkLYEL5qZ8ANFSHao24VwXWEIAORONsiipx/U0kico09hA4/szCE5d/LW sBmNcdUBb7KHLN+7/1L7iPveUj9AeyWfjmnPKn+uzkNYzYbiGh70+lkMyPdwI+v1zTWt IFmA== X-Forwarded-Encrypted: i=1; AFNElJ+ENZZlMmVPeZFgmLMzaZFW2rF2sCpk/dEZ0O/ro+xya6ZemZvxeDublecj66kmWBxtfYTGiN+PGswTl1Q=@vger.kernel.org X-Gm-Message-State: AOJu0YxQTrvaL9IFsGOe/zlTZFIlXcF0ibLHXRUjadGYrb/3qRKU6R/y 4PbqHVfLdr6LGMqULPD02e2vYEOry+JMWHEWBsZ0MVzKZztRB/mwJ2VzKN+/NZUV3IvjSiVzXzJ gCH7NRaP6Rm51sCCEmtJP/e8VY+pYld9wZ5f6hlz1buGOF+wmkYcGl7C7YBSfTTQqZlE= X-Gm-Gg: AeBDievXxsmqTe+RaAXVVoBykxk3BoKsCr96Olzh4q2oiicUWQuydV10tk5OlhvdqdE MR3vlRP2wcFYEtWY9WXCk8PMM6S7jU6obpZ/JqLBs4qGkYVXKoxmrO6IwSMlsDXv3HV92dv0Dbs Nba/poYZJgM/wxFFZj3hOE4Vi1tNNW5ng2hWxAekQYHe7skFac9al8MihKPt3l1lG+czKYovfJ6 llr6DUh2BXviOEFFvR79F5jTkC+Y5WZCkb0SOWZfrZCjP9W02S0PhKzWBzjOOwi9OziWQwqTwY3 OpU/djNhuXfhNWXmCZB53lrtdOUFwsamoOymYfax9hWKnJSlTc+60HA8u21B9hkCWE6TUyI553+ 42zPm3RwJ766ItFGeGCrr/7PRm8r5m7CgIRz22bW6RJM= X-Received: by 2002:a17:902:f78d:b0:2b2:67ca:5ff9 with SMTP id d9443c01a7336-2b5f9d888e8mr321960615ad.0.1777043520180; Fri, 24 Apr 2026 08:12:00 -0700 (PDT) X-Received: by 2002:a17:902:f78d:b0:2b2:67ca:5ff9 with SMTP id d9443c01a7336-2b5f9d888e8mr321960025ad.0.1777043519274; Fri, 24 Apr 2026 08:11:59 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b5fab0cc9asm227771505ad.39.2026.04.24.08.11.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:11:58 -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 , 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 v2 04/16] drm/msm/registers: Sync gen_header.py from mesa Date: Fri, 24 Apr 2026 08:10:39 -0700 Message-ID: <20260424151140.104093-5-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX9wNUxpthDF1K h8yeC2gmuY+onvNKDPvTLyi1G1R0iDUB7YLEYeouWV70DL9+aiINC/t4RNWeAh6p4V/iiko6AIy XQiXdJpKjCAJUz4TjWD67+DFZUyZzjy+JdVajqr0+MhToLoYS+yz+EwVJ5hJynfmV7SX+ejZjOM sXBbc0Me4JFOntGeGFa5T5qRpkMQEez72j1HZl0N9Nz1H1AwRty+y3kT5V0nMTdCcRf/dDkLyk0 qpL7SvQSznZFPsJ5VHOAbitw6FJp8ofEZKwo2wFWTw1xCAOcsHHqKm8QR8FHhHcKkBauEGnGIYg YQ5DRPBvJbmHX/866EqWsbbt+6hxaxBzGxOqgkxY0jFvuf8sVgFCkSwbtFVeIAaIPq4YRJJQiLR S10BL33pY8zw/yZvZQ2PKFRVVVN1rG9SKqprNE9iqVFo2vm45aG2yPwv95ENph2e3qBMLwAzS2/ ZLDdUvoSR9T7d6b4vqg== X-Authority-Analysis: v=2.4 cv=TtnWQjXh c=1 sm=1 tr=0 ts=69eb8842 cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=e5mUnYsNAAAA:8 a=EUspDBNiAAAA:8 a=upIMGkliACeFOg2EZ_0A:9 a=3o6Nrjf1o8nA2Q1M:21 a=1OuFwYUASf3TG4hYMiVC:22 a=Vxmtnl_E_bksehYqCbjh:22 X-Proofpoint-ORIG-GUID: vfoYO9IrT08uCtGeLWyM-Ct59mGcTe5Z X-Proofpoint-GUID: vfoYO9IrT08uCtGeLWyM-Ct59mGcTe5Z 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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 --- 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.53.0 From nobody Fri Jun 19 09:06:01 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 F031F2BEC43 for ; Fri, 24 Apr 2026 15:12:06 +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=1777043530; cv=none; b=haP81R2QHmZ1QOU8jydfTB+m4HKXBLMqd4Sp6cuIZ8aEZ9EJuk/GsulutDgNH51yYkiUPecakjgPJ66F01dUQXn59tV5G7fYC2qEtXyFP7lOgEZoFBP1mOPn+vbiFjUQJ092tVBBP40hL1X6IDi+T+bOgq+GK7qUOj0kY7dqxRo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043530; c=relaxed/simple; bh=41l/6CMoO2ooY0jmNZ/l23DDUUv3lGyjB0P25sETab8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=F+wK6RE3moA6g6+5vBTZ2bvSoyHSBm+e/nicgsg2VeVBhhR6fDUUC2wWdr1ErgnmcvKoe6s48CO+hN5aWjvG0rDNB0V+t5QmQKa/vhenSnPMa5OXwS5aYq9Yw2b+Y1oC1ITj+Gu/V6WMb0AlDCmagxzi+Xubevm7naP59YnXqR0= 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=lX7D+dZr; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=iT03GxfR; 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="lX7D+dZr"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="iT03GxfR" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63O8iYPj4012181 for ; Fri, 24 Apr 2026 15:12:06 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=dKmYUalofmr 0GyHfj8Gf8J7ybgVBQT50xXXqmA77ZJU=; b=lX7D+dZrtoNnOexfJfFF4iL3X6W v6DG2FjQdXU/gfyQfURpVHaS3qbLIvkGFNXfD5Qgn3rsJ6UV4JAYg1eVtojc4vix fThaPGZFrrBAS9EoOla9zAcvNGYzeXQNaaUhmMs67GHsEGMNFeis8S301WVcjmcL mLykM4wrx7vBfIPwNr+Vot8vkrbJOI4QllKpJ4+BC2O1jCkRuKfUEdGp5VGQYIee 3eEQJYKpiKYmm4K/613QTvm+T+iUGuSaenEVniHuAdPFJ/G4uOqFovLDO1ZNlAGp +cJzriNKT2GXesC0T+B4PSUkPHe8KSSoFHWTR2Is8XtiMzED4xBpHNikl3g== 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 4dqpq9w027-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:05 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-358df8fbd1cso10528205a91.0 for ; Fri, 24 Apr 2026 08:12:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043525; x=1777648325; 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=dKmYUalofmr0GyHfj8Gf8J7ybgVBQT50xXXqmA77ZJU=; b=iT03GxfREyRJDHIkSOT7/mc1C6wBgwb8chIs5kU5a04OSClHLuM+VOmPg/cFgT7DNk G3VSEK5mi84cIw8fXV5azG8DPF3k37n4emM5vfn0Ti7HEAVCUjC2YqPPKTSE13FxMFul q7uytukr5ntQs8IuX2wqcoLxos4BRl5inCm0Hbr210HEUJUncnip26kJe0rLBu8TY3i5 PmhGsGPCrKPJ0DBUgpUvda8Gjsq6X8EUrekyh5nWG2ZdRYdPFaVXpbWzCC5sYKsE86X9 2H4mkCZHliCYWnz4Qa/7mvyD1z+9DbLK3Q2J5X1ayM1YK4rV6DMucnU85ztFkyEe5q8f VOQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043525; x=1777648325; 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=dKmYUalofmr0GyHfj8Gf8J7ybgVBQT50xXXqmA77ZJU=; b=J8T+EwtEXTV9mNRIYdP5Rvma+mVpWYliaGCkmmq4t+xzk2ywkYaD/C5s92kTjetyxl G0mYagiww3YcXmQi1lqXrwAJWPAA6dq+eOGMj29yN2Lucq/2ijB/L8aKkTNn/pjNnRy4 zApAAb72U1WhMDMz2jj54AqepWzDcBC8WEXWtKpBUJ8wQ9iYGYCyElTDrw/N1xlfSM5F UAflPfpJ99MG0DekmocR2MEfbi+dw7mzL1sp4vJmYjjNLCMT92lpfuqJ28jEbPQXNNik hLsnoLaslhzpahIyjbczI7I3aHQbc1EqPQHGzlRx8OGShNSprgPn0i+HUgTJ9cqWYgj5 8FVw== X-Forwarded-Encrypted: i=1; AFNElJ8Dp0lIiujMM+ZObN96Un7XXslJUklwYnrtQyz7mpz2eCFIIWRKVz7Bz1Ix4irjbkmmJFgnoVlr670vT7Y=@vger.kernel.org X-Gm-Message-State: AOJu0YxtmR65yRhuOuQiSZYjUAuIikdtkoXfKfvNvp1KoOxoI9Wtm1G+ HhR16OEuV3BZfBnb96Y6RZULUxlKWIHwV0MDuov9whAosGkcD1ABFyPhGi4nbf9yhKaHy8Z5bxh m9b7pyBThG37y9PFtRGlGmciFGdVG9Tv5nE/y2EwLhmEdfzjii96inkh3H3onYT6wVHc= X-Gm-Gg: AeBDiesPS6z9ZKvvij86xAyNWG/0LYJ/deu7Trw4MD5tn0jH8jw4BCgVIKXtutxO7D+ vs1o7/YZlfNJZAGGtCt27XdKUDA3a2VUY1YTggtPS7nMOt/q2cH5K1I/9nRX/WZ98x281mvjl1y qVMntA3FpTwA/GNdvupxLSejVT0CjvBV861Xt4CmPjeshwfmmV2/9zh4YG9YhD+3BAldVFcDY2X n3quWPiNXW4gPJFNkqpNvAUMkHdHvVf0clFJU+CR7NRC2L+puj08blQB3SU5bN4St1l7IV3M9lm zf6xYXwbiiV+x+07sAXDup3hzfVWDLnW8SUhHPrECSZDvKeycZGkZGb6sYaavNA/2zx4vy2OTwX pE2xYOO/rgfAAQz4y7i1IGpfInWwGapPX8lq5v9z5n+k= X-Received: by 2002:a17:90b:37cb:b0:35f:d56d:1c45 with SMTP id 98e67ed59e1d1-3614041bc7cmr29304430a91.12.1777043524184; Fri, 24 Apr 2026 08:12:04 -0700 (PDT) X-Received: by 2002:a17:90b:37cb:b0:35f:d56d:1c45 with SMTP id 98e67ed59e1d1-3614041bc7cmr29304358a91.12.1777043523353; Fri, 24 Apr 2026 08:12:03 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3614872174esm13764865a91.2.2026.04.24.08.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12:02 -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 v2 05/16] drm/msm/registers: Add perfcntr json Date: Fri, 24 Apr 2026 08:10:40 -0700 Message-ID: <20260424151140.104093-6-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX5/+21Wj7sG/8 sisq/n9/D8fBUF1fmbd2rFaVkN2JmjNphgAqU7eXYpv6RDwSfEG5jEbavNqvHQfyMxG5klcjEnB b+UO5U6QF7+hqnnfg/bwnKiNEUKmBV6Jo4PxZpE+0Ds4LgOppjtgB8REsY06liGCB5uajd59onS he1FLgNqUefoNFTtdQiBsFpu2d9Um7ciSdyXJzUM8xkVhJgelAhWlUCE58oosL3Kid0YvInV8FR ZCARMfK47l3zjIWMzu8EQc+tohWEaGAhecAzlGq2ft314LFUxJT/krdhrrklvSuxCCuTsFKgJul zIjwL51sjGQQO/0+9VIJej9p5yYReeh27HTe9AY35UNa9UJs9U/IetASVO8rZuxF2yoYbpHXqgM bugemyULp/6IwOLvDBhjAtoAz6yNC8L4XYxnJ2en7J9LTs6ucfI/nchrQDK27H6bx+IJdKDtZTE i0+U5LL/2YXS0X5aEhg== X-Authority-Analysis: v=2.4 cv=FPMrAeos c=1 sm=1 tr=0 ts=69eb8845 cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=e5mUnYsNAAAA:8 a=EUspDBNiAAAA:8 a=U2HPg71ik5UQ_0Zuz_MA:9 a=PDmnkIS-fa9zh8kb:21 a=mQ_c8vxmzFEMiUWkPHU9:22 a=Vxmtnl_E_bksehYqCbjh:22 X-Proofpoint-GUID: pG3InAIl8YM0ICEy7i7J2izNRkeMrNj6 X-Proofpoint-ORIG-GUID: pG3InAIl8YM0ICEy7i7J2izNRkeMrNj6 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 priorityscore=1501 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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.53.0 From nobody Fri Jun 19 09:06:01 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 885B72BDC13 for ; Fri, 24 Apr 2026 15:12:08 +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=1777043531; cv=none; b=bTyPHGUbCvXYuoZfsu7Bp+IsgdiHe73ub/A5AXXhEt+g+hKZig72QgZG6r9VW6IM+am5X9Hf5py0p0sMTu55D3Wb1DpteXDQOtF0sJLjmPPdVR6FZjLp0ZSKMOfPr8+HNcNzJV98RXKA+CygBEKmHVvmSg5/rB9hCv9+ZF9zZBc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043531; c=relaxed/simple; bh=UzSwe7nNkzpB+wS6zyIpQUgsfG1m2PPOjvq+pqnFQbk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EIJpyWTsNefyPtezk7wVWR5uAaWPI+bF9Ql3OiipMXXgdzP7nGK4/4sl9PqUkfPdJTGcuXRFkopqWmhVUx1/jEwItYccNlvboHFnqMl/5YcXS9nsifHSiLP2utoJQIz/6GFbz++aubHLbYg8gVVDLGn3D2w+gxoLq0bwH9OPhYA= 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=Lcsx29i6; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=YkFWq7m5; 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="Lcsx29i6"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="YkFWq7m5" 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 63OAPKhw2972227 for ; Fri, 24 Apr 2026 15:12:07 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=hqrgam/FCMU 6TRDYGic4FvNbNNuPhpsx7Cb0DIkY9Rw=; b=Lcsx29i6XWCGLkBzXoFywk57VYU CgWI1XgAfl7h6ESMlUXBOHPZH9N1NuzHYK1PybY3TbegLNfKd5ZDYZVJrwZLHB+e qx/R2rkP0z6bhyiqD00UydYh+eoXtBITE5HcJHGuaKZPswdv/NMG99BFXz9tUQXv 9RLwT3lszlGusRwv5I1doqk/xe8+ucW2Apm9mppDy6OGl3pcLsufYrB3DQD7ID1K UpGMTOflUk4y1fGV2Zz2HYj73Vfl2fVNwsBHPVn9WZM6/Wz6WiCYGbncCMdEL1aB 4IBEdLfo5S6R1p6picxGotbZiMGNsRjrKP20KJJAJjgFmtCgHdLVoj67Jag== 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 4dr6rk94an-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:07 +0000 (GMT) Received: by mail-pg1-f200.google.com with SMTP id 41be03b00d2f7-c76cb2dce57so4927422a12.1 for ; Fri, 24 Apr 2026 08:12:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043526; x=1777648326; 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=hqrgam/FCMU6TRDYGic4FvNbNNuPhpsx7Cb0DIkY9Rw=; b=YkFWq7m5ZvlPjCFG9bh2Q08Aw/JuC7yms0z6yb2mtFia8ik+ZvVFCU37mEaCKSpI+H srevZ5acjYKlsUTW3Iw+56VqravJfI4Jojw+zwRjmJtuD9/U+KZTiIcpWJnVmlIBg9MD F6BwDv6iBLn12HhUJDCvpv3TxbgmmeeaZLXq/MKehmhEhv8pb/RtvHuhOfnAuWnmWhLb RdWuluOhnXjTdqFH5cXO43+OCuhjZyTaX/RP83wP2qNXh4bCZ7Kz+0SujM+tPH/ouD+h r8TgespqgugF/hvN/BCruCW20BwJDsQ0JjjS1QaxnBcL0sfm1VzXfuGmHVxtu/UqYAxX dLEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043526; x=1777648326; 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=hqrgam/FCMU6TRDYGic4FvNbNNuPhpsx7Cb0DIkY9Rw=; b=emxOkz9HYSH9CIZ6qaqOQVmGAXGUBLj86qlOUChZ6QfnBAwYftrZYZh1nF0TpGhguG BE6auvTIk3k5yHV0DGh94ufvuNLHgR98/1BqzmHccP5SRAPELBA9+A4T/qciYiEHC25f anScdmlj3eeo/WOv6LFPr0z4TI0qrUJTNCerTwQPs9LrNx2wcQ5LnRvE2lHa+0kAmZoW M5BzAFyAOEn65EQD2ITcYV/zZfw1I0sJiVZKVa4azZZh328PbF2X/6Z+t3LTTEpoQwB4 U8ft+ZDzBy4yjnmFZKebQ6UhgYYlKJp2qdSrPHhvShMW5NbJNfwHf9DK9aoBZYxp339o pv2Q== X-Forwarded-Encrypted: i=1; AFNElJ8KwzhnVRcU+E0KA0BKizX/eEk4dwJE+chDv7AqrGUypy9x6gWt70xhg/c5e1rI3S8lP4hGSrTbW+CwWCs=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/UbN9cvBpBp6d6qk9A6IeD8H6/1q+W1KqoxmWAy7qc9tN91vG JrMirO0rArUljDKAa4UqoAAgOq2PsIhW9ErCQVCWGpmzHaVI6VeMOKba9Ad6jMN8wrRhlsaZdsD 0DDwWnpTpnHLLRt26d3lGfMq+hsTBks0HYxhfpzz3223VEdGX38+UnbQ5BHYb9JHMYp0= X-Gm-Gg: AeBDievcBQRCA9TollJ/86+cQdUrSIQP5tUfNnl7ICFzq/yqy1uRGLAzEjfqAZL4WDX j9vH8MmunrVvH3j2FGZO4i8mBxKltIw3WZvq6DhfJwL333fSwdhgz573lpJtjxdImDa5j2QbnBF 1B0I+ETiMdvQdnhoGG0/eX863p5VQDy2+LF4fT3e3pYLoecHvl72jn6pdC+56q2A4sM/wyTCO8B Pe+N5NjLraduQ3iQVDKmaqeSHjh1S/V9IrQoSf2Z/fxH0DCfdVK8LSM+ISndlyRZ6RfEaSnAL7I ckecExjNaShTzfF0zQA+hv2IpazEPIyWEsH5AFSe4bUOTt4p2iQh4U5HgNdnGyplJPLcqLLEG6L C9eAbkty3Hu+0i429Uo3NgD0vDyEscJKxIrBMug41k88= X-Received: by 2002:a05:6a20:7fa5:b0:398:a76e:4ad4 with SMTP id adf61e73a8af0-3a08d76d92fmr36814971637.21.1777043526273; Fri, 24 Apr 2026 08:12:06 -0700 (PDT) X-Received: by 2002:a05:6a20:7fa5:b0:398:a76e:4ad4 with SMTP id adf61e73a8af0-3a08d76d92fmr36814927637.21.1777043525796; Fri, 24 Apr 2026 08:12:05 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c797702faaesm17883136a12.23.2026.04.24.08.12.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12:05 -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 v2 06/16] drm/msm: Add a6xx+ perfcntr tables Date: Fri, 24 Apr 2026 08:10:41 -0700 Message-ID: <20260424151140.104093-7-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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=AfWB2XXG c=1 sm=1 tr=0 ts=69eb8847 cx=c_pps a=oF/VQ+ItUULfLr/lQ2/icg==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yx91gb_oNiZeI1HMLzn7:22 a=EUspDBNiAAAA:8 a=UuwE4gOO9k-hs8zF27AA:9 a=3WC7DwWrALyhR5TkjVHa:22 X-Proofpoint-ORIG-GUID: 3x_hL5RUN29iRSPkbd2ZRN_x-62YBJ5f X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX5KUV9rSUMu5c yA0M7r0PPCex/p0rjn5Ib12smAJqilHbmg/1i74yafzt126nvzmG8VuUw6kipapSwNdJKE79E3E qcyInLU5DTRzxKw3IVsgsolfCx+yL92kca9PQB7AFyqACOGlRNEK29rv41G5/7zfEhDRsMTszk7 YS9Bzh8/WJZleL9OPeiht1TaQhlnMTdEVfG+/nPiL3QocwZ/z2LL2mVGVNBdf7GHjHhS4QoMCfu Av9lzv347QvXpxY+tguXwhW/r+Bg9kzoyDzIK2BDBULhQxRhFO/XGIwnA1HeU8ejztYoJDi2Gwa IIQRYgKIVI+AJ+T+xwncdYWjHak9uH+B5hPqk2saY1DF3Rmb5pr4Q9ECgjUOCtbLr3vPd+PajLo rUrs6IM+vTASYtebEGbumxwS3Nd91K6+SK0mp/2be22owNHQxrGj0gW93/TMGyZaQHU3EjeKnZg SkxlwOQIyiVvlEQFVcg== X-Proofpoint-GUID: 3x_hL5RUN29iRSPkbd2ZRN_x-62YBJ5f 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 priorityscore=1501 clxscore=1015 spamscore=0 adultscore=0 suspectscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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.53.0 From nobody Fri Jun 19 09:06:01 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 6A77E2D0622 for ; Fri, 24 Apr 2026 15:12:10 +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=1777043532; cv=none; b=sG6VuzYwkjmyQN2RG/lWY8vaU2MuoobOyp8nGV9SHBmba9qsU59NsefsAtnrjfVo0JxJCUI2ma4sYYvL8AQqISQiuQM8L/Y5cUrbU08Sv9OSEZFC4RGJc7LUJmu7gFY4fBilmhf8fGhWOnL6EwaepE4sjGdf+uF92Nz7KfslEGw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043532; c=relaxed/simple; bh=zYOgVLyZNeidj4aaYpoO3VeqCvvcIoZVOtE0oKhwRBY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=T6CHY0F+XfyPak2w2oUGtBrvYZUERYyDSUYucGYvFoOwTCoCtKoXHZcwTJ6xP8HOHBm3eL2wkAwMp04B0+Xcvm0AgW46KKxY/5Boe2kkagZtLLhQ1s/1v5lmSHYl2wLruPN3cGunKnpRRUKGWP8YRZBG/bJn2qcIqg6QRHgrGW0= 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=iVI7UgBA; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=On+RODZR; 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="iVI7UgBA"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="On+RODZR" 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 63O9K26G2710298 for ; Fri, 24 Apr 2026 15:12:09 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=cFtUg4FJvx5 MF1DaQQ57KRHQULyf4GIu8b9MO2ARFjM=; b=iVI7UgBAK3aMEMV4Xjsh7tZEE5I uZcJ0XXcoiOXIzgliX/B/QG/jwXlIvZcJn+s7AmOA3HaCyagKNVVXS5dqYC1JXp8 V0HF7g41PMgoB+qIcCiZRvXyBeq9KErsKo/ohnkiNIwDuHVFqKg/MEKW10NFfaHu maeB5osyUCmuKTKq4dHRj9nK1Zvr3Ajb6nkic51pCcTIAwVHm6gqWhtFRPJTiwHb WkjXOnlWHS0NZGelTOA8+2zCplbHhSDIf9+n4yzXFgi9NdcGiPP6hnRMhYV7Di5m ccgKPvVSiIuH9VXNR1AAxmVqpq0rQFAgoIvOy7rWEiusJ/4kSrYhv/ygcSQ== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dqqu9vr8b-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:09 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2b24af7ca99so107545315ad.1 for ; Fri, 24 Apr 2026 08:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043528; x=1777648328; 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=cFtUg4FJvx5MF1DaQQ57KRHQULyf4GIu8b9MO2ARFjM=; b=On+RODZR194kH/P5XDP+UY2UfOJr6Wiw7u3aYw9YMiaexJD3CYrsP9C3g6egP7eLpF udFjryZFRKUs9uEKHDcqZjNLKH1C85tTB0wlTMP/Q0vfbaadIw3seAyFyPvJlsYy6y5m 7/6AJ1YTvMEvaa6awfpbyzDFokG/ljAmPeoVrafC6LTl3JUMnNhyH/H5OnulCJRRCloO UEjEB0IMekCW/jFZru0o/Cy7wAf9gvyJHYUw+UwzQWLOmk3FM9doX2frX6WsMWz5dHSS ouvpOcTE60erK9NnUlZXSuwbbEswTvRX0SKDal0ip+VT8DG3nJCsfoZ2UDqLqKn2JMdK K7bQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043528; x=1777648328; 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=cFtUg4FJvx5MF1DaQQ57KRHQULyf4GIu8b9MO2ARFjM=; b=RpEkqB5IkJ2zQ/ydzbEoijkUxVIR8MrmGpjQ16pUnd7WOCbuB1ZNlJlECyFxqWmCfz 8ZMc/ONEiKDgm0UMHd0cgJ+em5T6GpGGRpPWA9wMNnCYTz8jWsYe6/ba0G8/8iGa91eT VVAmbk//I4r1fdgLQXKBx7Q2ndA+mGS9iDwWgeuDmbQdQeVQJgMAWrhEGYd37pJGGxRJ UWD25yCnx+UmuqjkxvEpnMcosfhisn78vuCOw+cpJhXJEAnu05o7Pg6pT+0NE4/KkRJ9 eHFe0BxGIMVDPtYYoqTlwzWLbNSNvnNTtMeDJWGyra8mw7YK2N1ZeMNHOYLUGH4vZdyI ghFw== X-Forwarded-Encrypted: i=1; AFNElJ+WsPs1bWqq5M87t6lSc5Lp1krt8qlm51nNFrEFVTpUMZc9pLCcTzDxJ0N/TakwlfI7ELKCJeip7+cbbS0=@vger.kernel.org X-Gm-Message-State: AOJu0YwHc1kYPp2fKezBTtNlyQpZqpCAIQ8R8YmOfgNm/3kt/zAQ2hTH 0f+MqetLqkTPJL8M3UhmZlZFHV79Yn467YQBEU6opvgNy8lQc2xsPVkQsu0D4iHQEa9E1wHz/LB OEDMPT7V8OJyCxAMKLtSvgOVAnyckm3kjE1FEPzXvtVRUCL/sygbe2y4M+rcYPzKtfqA= X-Gm-Gg: AeBDieuO5GooCamyn1uIaUbquFGR3flDq9hZm8n8tNayXNt8LeXo9RWNA35rH7ckk3I Paq/3EnePd2DBJiByiUK8x6gVrIvVp4iv0dTvrVV+PAIlbaW5oKMBfmR9Ayy+8m/YXFaC7lYzjz ftI7PMlgukQ3lC7Iqinj1JhW+S2tIEbF0oYSt8QINeDHJ869p1/8/NKkzB61c0z3s/8yzVBwiph d2uaZ3m963cuGYAXeWeHDhjwrh5nTe2CapEJ8uiUpYYHKJ8l8v3h6y7h/B2B9rTJdcPu++iZL3P gFRyhqP3zN+MtgA1aHfWyc/xQU/YBDVSWaQyUjsfQG7/mRokhgsb2LGbXVhY6IvFfvl62nFW8TJ kGPMshEBYW5ft/HqC4PH97lq7+/Rrro2Tmgv4W9bBlxc= X-Received: by 2002:a17:902:8649:b0:2b4:65ab:57cd with SMTP id d9443c01a7336-2b5f9fbdd39mr245951195ad.36.1777043528199; Fri, 24 Apr 2026 08:12:08 -0700 (PDT) X-Received: by 2002:a17:902:8649:b0:2b4:65ab:57cd with SMTP id d9443c01a7336-2b5f9fbdd39mr245950785ad.36.1777043527613; Fri, 24 Apr 2026 08:12:07 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b5fab29398sm233545215ad.66.2026.04.24.08.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12:07 -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 v2 07/16] drm/msm: Add sysprof accessors Date: Fri, 24 Apr 2026 08:10:42 -0700 Message-ID: <20260424151140.104093-8-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: 1eCI8_Kx8RH9xmXmKfiJ1XiYCBw0tPGJ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX4uxCTPdY+Uqo b52183yMl71+KjFC9PSLUtkQHLfrbnY4hAmOl6P2ItTY0tVYz4sZXWFFnxWLqLsO6gyk+L2W2q2 2TR/yBZKwCB1kXqLwfPLW7I9GOqd/hsANRcXjXLL7Bzk6oAohhYDIz24XR0SxEHUA8zW46wogy7 gYZzotyogFIwxfq3mCmGrX+7BFziHXTYTlK7aH9rSTfgCKDyTO+XcK6eeu4702SRMEhKIYT16SF 3oJVVKehwDpfxS50p6iOH4orGBuhDUG/iA9tvlKxFYNae1TbsQWRtV4XcJMUZ3FA/W2jYYUePJy IxjBB3T5leCvJtmbezsLNKMH1k0y8wZZUDUA0c3twcZZKPKoFIBKg/NM4U1a4V1OBqHNXNCyECq mnaKKPRnG8hFApQY+3IhLei+LqL3LNxWj5g+2X9ZcIS1cIIBNLU7uiVc6F45rW0QqzrJXjodoli WOp3eH5Hqc/+lMWTAFg== X-Proofpoint-ORIG-GUID: 1eCI8_Kx8RH9xmXmKfiJ1XiYCBw0tPGJ X-Authority-Analysis: v=2.4 cv=QJNYgALL c=1 sm=1 tr=0 ts=69eb8849 cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=v4b4B-quZFKF0PxyZCUA:9 a=GvdueXVYPmCkWapjIL-Q: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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 impostorscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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.53.0 From nobody Fri Jun 19 09:06:01 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 801832BDC23 for ; Fri, 24 Apr 2026 15:12:12 +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=1777043535; cv=none; b=fDYT2nOWlAoJRcZ/0wl6t7Gw+ePkjLqC/N2PybF1WMp0XBEUbOPv0cxnTFbKoDgCTiaKZT/AbNMQCwsQsFKIi0JtgZdh83p7pE2rofsgGPxLQdh6XyTstjgFG9yMoVtQVA+a+6KueXBiCURVAcdSePFhZ0S6sbFKS9VuqxV+UMk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043535; c=relaxed/simple; bh=bzzQ4aYxL3tMOEhcG6/I3PaERyeEXMJI+pElefAVGOk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HsU10euYCf6ipXAe5tJJH61WIWZ6/tYW6LDGHusSl4UOGrNNvRq6eMgVgeOT6+d8wyLeyiENvHv8egx+d0QJ0jLX1Mca+SpLKY/3kN+asUbbuN3/tlCCFXbK7A/kf1CZZMqr5OQFTo1X4XSAuzhn/SkKtE+wj9g9Uh4m9su8NYY= 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=H+fP8P0P; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=D82IxtfR; 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="H+fP8P0P"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="D82IxtfR" 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 63O9OUVk756892 for ; Fri, 24 Apr 2026 15:12:11 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=2tbDv2EIvIT EuQGnte4mfjJJTKVcwabfjQz6jqcfywA=; b=H+fP8P0PCGkZ4VKvQsiyXXH6pAI PWMDUQg3mPbCCkxLd61NwCxbx4AHOx2blz5ZOWB7nZL9kmcNzjLJ1EtXk7wxL3hN c/pVYbREtelpiif/vSuyvc3hWu29jtW+ji7JwmWvceHTyqU8FTm5+ygj7yBbSh0/ UVbYsYHNZ7ydvndsRtR/rNTzkHF/u/jzhya32hZK+B943SZGE3ogTLILjQnq1FSx DvOcyGccc5XrbE3qGDieMdBjBijYPnefESJko51p7N/OVaO/6ZJQkZxsbTiwaahx aMNdJqJzTchKpF8kvO7pesYac8whsR7WwLFLkxy9QnxUBwnfVL1GENTaZ3w== 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 4dqr4bmn2r-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:11 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-3594620fe97so17314531a91.1 for ; Fri, 24 Apr 2026 08:12:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043530; x=1777648330; 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=2tbDv2EIvITEuQGnte4mfjJJTKVcwabfjQz6jqcfywA=; b=D82IxtfRSvYFqGYLRcu65Ll8DZKNyfJ/QAwdIa0/tLrZU9h/nnferfKmb/kSMCQWFU MrXA9oW4vQ7mvWdbWQaWTSEKTEHrynCNdsYObTZt5GxWYEvg1LLZmPuhs+hLqTICTi5k wsBaJtrm8Ya7pXNJgAeWXiJMq3XXzh0Aq/diakzVg0kR/dstOJMS11SvFMBtWx4w1yCM ayOkemA5QG6gJ+OlY6OUY59GEWuiozLgFpFBXzkCvsabRTLxWQZ8wrqrnBxPnR6O1Stc CcwKXxEgqrr5BqnYGmIByS7jWNYU0MzUalvifL4l9LE1Scm6l0BOmWTmMP/E912cTJIp dabg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043530; x=1777648330; 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=2tbDv2EIvITEuQGnte4mfjJJTKVcwabfjQz6jqcfywA=; b=T5Qwg+enoTcVQH5b3FWgxlTb4XkDzeNq4c225/Q2fjB9BQp+aL0bx782YyTwKTaIoE iduCHSEUuVUZpx2IrC0639CeVd/euA+uRvB7n2FwGqLYPVP61QWueTZTdFyK0OxWFh/8 c1zKf2ftwCwEQTQCZ1gwxSYwErzsw2wphoJb2nZ0ERgNwETZxe9LZRnGg1fwseELcmyp bgRoAb/QM+zyABv6eZAx5lT9OUjT9mUdo/mJq6v4AZN1B02qWTS+IVs3tQJ3jurlPKJ/ mP+0Uh6tMxU4P6Ou3kPXUiD7mMRlvenYClgjSVGHC/+2rBiLXr+I1TrBUPDHy2HLaOK5 /s5g== X-Forwarded-Encrypted: i=1; AFNElJ+LVcS0bPhqmAKNol12jOQyiCKBhsFC15d5G662wFons0El7hO0Ytuq9yJzAO67D/4te52z4Y1iTKN/kjs=@vger.kernel.org X-Gm-Message-State: AOJu0YwbhtJ8JhDr11VaiKA2xoWFzPg6rQhvMkW9y1VbZnNpPmc+M265 tp2pq4wW4cIlX5Yo6/QQ+tUyKrOqHzcfn0BAsI4fd7hWzx3TOnMbM6CphCn2/mK19l2X+cromqY HtmlDq9uyTkJw96OFkXuKSLcyBxnoWsw8YGvFmwXqTALpnwtWc0K2bVThygtrUOPbUJM= X-Gm-Gg: AeBDietlLJbnVzh3l1XkKBS2WM+yuyh5EDeiOZgJ5pnIXx3cOrz8ibZ3SPTUYxnxYji MXboauHuTJs9Bw+c9fLl5U2FsIiLcTknSY5gf3WKV/tQDXrQGOqv+OM/izkfEaVIlxs7sGvcjQI uFOGLVi9HKMxILU/FzgYXcLDPHAUCmmSkQPUOdL0Dl2agODHUViPC8aJ8DjSdaUHM29LGQc8NB5 T0RUg7mKFJJ+qeYp2/FAthVjd3gjtm2KjPOa04WDxz0MHocivvgpKs6Uw1u3YsjWY1TxOgwudDh JHDbKGlCO/Co4uXR3QAHkk/7s+vYludOjrGNurVXGnik+W9W3BZwok9Em8R902OqpMb0LajvFks ZhC/oHvlM++GSZEFS+s0xstopTZ5R0w7keHQnfCuDrDA= X-Received: by 2002:a17:90b:1fc4:b0:359:8de8:1229 with SMTP id 98e67ed59e1d1-36140490bf8mr36783560a91.21.1777043530250; Fri, 24 Apr 2026 08:12:10 -0700 (PDT) X-Received: by 2002:a17:90b:1fc4:b0:359:8de8:1229 with SMTP id 98e67ed59e1d1-36140490bf8mr36783527a91.21.1777043529584; Fri, 24 Apr 2026 08:12:09 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b5fab20c4fsm285138165ad.59.2026.04.24.08.12.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12:08 -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 v2 08/16] drm/msm/a6xx: Add yield & flush helper Date: Fri, 24 Apr 2026 08:10:43 -0700 Message-ID: <20260424151140.104093-9-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX2+tlI9nbdAuV Sb5WRd54sGbrfk2p3n917QI41BbqLRxU4HiMJqsbgbTdS2gKBDCfT2W7PiaZjrVKcPwpAAIHtyH wsoK6+kcei/B5L9xhk/dYg6DfojUPj2epYzKOKA2UgtYGGcG56qnbnFw2yw5a5ls0wB4IcYQ2hy MNM1wP13d18va3p+WCXMa/7GZ04SMwUQXUzJSOKiMwFiGMMXRXJ2fg+qyCVNkZjC/IsqNxuQAeB bGMIpp/sk/xbLURmWiYAqkOeUhcUEV6M6ZiopyWGycUuUJdCUh3XoSgBav66dlo1Mjz2bIUNRje pBj7KUgXyeZHoUSEBKzn2VgZtdDorpfONz6tDtGF5rF22ZPTWINod+/qAIg2xfOawgT0/VJt/Fa XRl/iXjPajFm1iRMJ0au4iTiwRD1GwWccjmsW9cYOMJrNKt+DSMtNIrX3IFKGJ8QIVn+Ld2L8aI hsFQRG1u0OaGo71+hKw== X-Authority-Analysis: v=2.4 cv=TtnWQjXh c=1 sm=1 tr=0 ts=69eb884b cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=7a4_7rcHm0II5uOVc2AA:9 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-ORIG-GUID: tsfDa7nkCPP2p6M2vRs3O6tFYUvVQV1K X-Proofpoint-GUID: tsfDa7nkCPP2p6M2vRs3O6tFYUvVQV1K 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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.53.0 From nobody Fri Jun 19 09:06:01 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 709A1318ED9 for ; Fri, 24 Apr 2026 15:12:14 +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=1777043536; cv=none; b=d6tsfoEL4nts8/mzXqeXsWnDDsxtsOdFiof5PNSEXrvr0vQDXFgNeJsu6ad0LT2NP/WJMd6/HMOF1tjMGZnUOjA54Y3n0GmX+UxO84PDQWtwAcxaO8yBMBmSEbI3ycTaJxyOWZ6YXuwqmn2//JTGQGGUQ5AODgdh/Ca7M35yrTA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043536; c=relaxed/simple; bh=yPWb66bAIoSeoVbGKbJy3czH0fsxgSHyCkFJ/vJx4nc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mb/nA9/iYmJaMnhV+icBuNNi9dfUk60AvoEtwMnXYE9WUKT2XP8tXwpEwXMH2nvw67xHY3KrORANTPG0nNotXGXfr0rn2h/f5IucQtL3rTw5Gkd9D5IdOfkFu6/l/y6aRh6ffqzX5ukyHa+BmM8rxIxoV+LSmVshCrf136pEI7c= 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=KNiqVHra; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Rzpc1jdw; 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="KNiqVHra"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Rzpc1jdw" 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 63O9CEcT756669 for ; Fri, 24 Apr 2026 15:12:13 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=38TAuDgn/y0 0OaDm7XX1LoDb33XqmHE1sUyo3NaO6Eg=; b=KNiqVHravKN1HO/jXLQ6E76BAbV YA+dtQR6blNm12Rr9GsvLlpYxjTzFpc22GutPwxOicW+phU46TMN6mV9fjChGKUh cHnM6tQVToQanytQXfh8WXtHODdqxAXEFPrQQI4iyv2NAbVwcXzfqERTVrV4XvDO HwIDw1mJiE+R1eJDZPE8qNvhLuvUOm0lrge0UtxYgTyWDDtQVASg0QjOCofO9uuX Gv67123NdqLdjyyy2UavK1PO0nkS5UvB3wW37UnwE2yx3FkYRs5O6rUCF5nNyWJ5 53eKkftEAV4lgZeHliQ308bg/B7vxI1intVmstiOpgQoLXNl4QniYIfJ9Nw== Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dqr4bmn31-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:13 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-b630b4d8d52so4710655a12.3 for ; Fri, 24 Apr 2026 08:12:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043532; x=1777648332; 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=38TAuDgn/y00OaDm7XX1LoDb33XqmHE1sUyo3NaO6Eg=; b=Rzpc1jdwjc5mALDuzD5eq7JrBwt4J7dxRhU0uoy/MSzaemahuMyisUsSjXklL1NdFL GGtEyO/e1PZpeXHwpI+ljZ93bXvpv7lx7TVfcVtsRXFoq5wQnVIAXz9HFOWugLqIK7IB jBRNdddINJ8GrnYHfxOXnGUetmUAvZV/iCNzgeVdvlOw77wgvfoGDVxVmQI6DxKydK31 ljbKH44dw32UdTXQBIxzdz1Y5SjutyL7VgmIlIR1hu1pIf5geLtT9QuGl2Vq4pCWZGDt p96gFGok29ME+XVAsU4Z918z0DSHCxWjaVsCnqvX42Kn/tkNK4myiF7+F2MRu95YbeAg ccTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043532; x=1777648332; 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=38TAuDgn/y00OaDm7XX1LoDb33XqmHE1sUyo3NaO6Eg=; b=HeFWur9e8cpEo5EUTVP3pDScGhxjK4/RLGQ+01sBCcmVVfMjwCODUH4zWFds2qkPMd UY2hq1EiXkZW4Xy3QrEYHRv9iYbEa+kiiRVj0CWN4eluwsXr+qcySdgMmRlbuioDpetQ YOmnUkR4pJzxC9nJdU7ehvh55B7ac5Js5OZdhpTdvJeqp3Uy5LqiUrPfsv5z32axCPAQ OLCOIf6E3ffeJk0JjOa+KVRHWlrRZ6B3DIZAWEUNVPXB3fQOmofOzXKI440cgijscxie W8880MZi1Te5XzxPLXuoosg/YF9mFLIC7jl0ouvSxedV3LuXCqi7Sj8XHT1n43i2XJHe /YCw== X-Forwarded-Encrypted: i=1; AFNElJ9FmGK9WXD2ykzYhf2VMLrpHsax53QbdKA1jEwQWENQskBSif2KwaIIVUIGU8GtxyVOjogjO3BLePvcfWk=@vger.kernel.org X-Gm-Message-State: AOJu0YzUxZHW561YhbLbuJxM9cRrdxTGrba2vez6tp+2unZ2bADm3Iw2 utxg34zw02hyW8iAgjKQRgNxkae1YRZl1dV73YZsPH0ft8n0y6SrYj3aOS7b8I82HWczynL4v8/ fe9lCiYPjHQbJ/9eWNaIllREeGm1N/PHxO/rdiQ6zsUXkFakYkgahGhu1nfuy/AjZ/TI= X-Gm-Gg: AeBDiet3GyHj+8iTeN+LmwG6lGA6wXnVXSRlsKlgaFT/q/mxcB1fW7M30O78LFflWpK 98NT7KLksB3aS+U9sXBlrrd3yFKXO+5dGlqArDabsXXYrii1qwT7sOwrycgIA07CgbfoK1hriPp x7CeZb2GpXSpcs1PUa30g6QSciBTR23TWM8cB7MtYJvDHre1mYnNeUjR+hThnGEwmvr9irtO/Sk 0ZKoINNH4744nx/S285K1bobKpW9hPplqi4FcmENuy0RgZiyYDiW+mBNQO5x3mEEORM84gPNh45 W4S+9qorN20rls6bVZ1D8X9EAg/rCn+Y596yzeXuZs28EI51O4AULZVB6lHi+jE4biqMx34mNXB +DvddheHhHohGHPMeKIlDPxTY0VtnYsqOD9qWonz1c/Y= X-Received: by 2002:a05:6a20:7d9c:b0:39b:f026:6f8d with SMTP id adf61e73a8af0-3a08d8e27f9mr36956106637.43.1777043531898; Fri, 24 Apr 2026 08:12:11 -0700 (PDT) X-Received: by 2002:a05:6a20:7d9c:b0:39b:f026:6f8d with SMTP id adf61e73a8af0-3a08d8e27f9mr36956061637.43.1777043531369; Fri, 24 Apr 2026 08:12:11 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7976f8f356sm18521903a12.4.2026.04.24.08.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12:10 -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 v2 09/16] drm/msm: Add per-context perfcntr state Date: Fri, 24 Apr 2026 08:10:44 -0700 Message-ID: <20260424151140.104093-10-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX9rL8COIto+5J QmG/yFF5hpLeltPiq3rhthI/RJ2Xw+b7AjNT+leOehbSi0Hs/2hk3mGbXNX+7sOMllgxFjWy6G4 AkksMPUk151YnSkU6keeq6hFwyKFNPLpDiZPK4TKScMnq88FaoZviJvpjAw5kZliHYVjEU4aH2M 3V5t0ptua3TtRPuoQot7YSZkZUvlNZ59cR/clh3csy59w4T6VI7ouVSzs0Cyv6NciXkKGiVqmPZ 0RCCvAvD/Ph9xD9THm2AxmrGT0+7ZjjDb419lhqK8Fau5tLw9IVy9HOwpDURO+b4wp7UzUZ95o0 soMffCkoBolRHY5Kge2cVAdRDbewG39izsrgPkStt8QpKCI18WsmOpceZauCgCuPqb2V4Aie8Kc lh+et+H47x5Pk2EHCW1EWH3Psmfs3VeVlK/o7cC50HWWpe5PSYKzZNpatuRVFpaVzQKvEzFoc4r 6S/S1xbqPB6afBqA3mA== X-Authority-Analysis: v=2.4 cv=TtnWQjXh c=1 sm=1 tr=0 ts=69eb884d cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=OtV_UDYxk2hhjaRdRjwA:9 a=x9snwWr2DeNwDh03kgHS:22 X-Proofpoint-ORIG-GUID: hk1EazWoHwvJl89imJ2llIkOkg5Iqc29 X-Proofpoint-GUID: hk1EazWoHwvJl89imJ2llIkOkg5Iqc29 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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.53.0 From nobody Fri Jun 19 09:06:01 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 59FF33DD50D for ; Fri, 24 Apr 2026 15:12: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=1777043540; cv=none; b=Np6hKK+zrAK6XlCIejm3NFl7zOK1FhMFMGv32mvcyFewmfYmlW78GMOdIyVWJiyk9EflG5rT7nhmgixLo9YYIKjxEvvz8cywLcNQQuYKEqzVsscpDoEanwvKXS9Ilc+AxnnCEvECZ0/nn0FcizzlVc3MhLZerNckwRV4cStQ+sI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043540; c=relaxed/simple; bh=iMpvB9xD3zxkJ01VhN86llBOmBT6/YxBTsHYv5TEP9A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N9EC7kvhwv7yqqs1SIbcimOQgj8NPdfcN71FwNXNPOQ1487Z4zQ0voGpPhR0FZoYFo6Y5IJ/ttHkwMAlN+xG+PJq+UYWlWLS1bAa5Y2PRuApxtQz8opCsTj3eRCMfDwR31Tm3mwVOGOniK43yT8TIMbRd/08rKdEvZNul2z8zAA= 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=P94NYQLe; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=UU6OvJhB; 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="P94NYQLe"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="UU6OvJhB" 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 63O9OUVo756892 for ; Fri, 24 Apr 2026 15:12: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=kaF9LLylFo7 0xLMN3TzrFec0ifchkp6UTBct2Ao7W+8=; b=P94NYQLeDTy5W+AbMflWD0d0J/s VkqHZRRuzHchi8qqOWR+WTBLq5i0LZRYTA0ed8KzgdO1rJbcUskGoLZubbK41jhw uRbiTMqiKCJJxUA1VzwR05k6dMuZfDG8gduzpg8yu03KYGrKp+MBO1RabJ/rLTio Fs5JAQKwT/Zv11o6oLu4NUSrqzCbO16q2uxwEry7mcE7jCCiVnBAR3thzHiphPKB 1buX+BRmUAS4ATVbqoWAY3+IrcIHrc4ndQUGR8bbYKOlLYo80HSaxsGSSvyPx8pD RAMA0C8FmucSugaFHJztBJzJcvR0YWdvhC+0tV7iotZFdBd6cR+cjXEXHzg== 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 4dqr4bmn3u-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:17 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-35da99b90f6so9841071a91.1 for ; Fri, 24 Apr 2026 08:12:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043536; x=1777648336; 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=kaF9LLylFo70xLMN3TzrFec0ifchkp6UTBct2Ao7W+8=; b=UU6OvJhBMQmcxp0XxPNe9nNM+tzkhSy3/EIk78nLmvxnFOMYKEI5NK6fFrxduh59SN vlStvfZHs+EpNDvyyq70pokQFMhKjWFvXJ9OFR97cY8wFvyWvzPerQO5z1f88cVDANJ8 L+3y9k59jaBHw4xC5oQ8r479gPAzQZETMpC5H8kgSDPk/VwtSWJIvg3QWOsAHEC1qeuO Hbx5MVNO6KwZneKb5/pgCAa7t2r2+Ig4a0+nOFdDdQaUX5K8efIOzv+jKgQrdVdkF2C+ mW/tcZfViY23+csfCB30ncjpBLhUswBVUBsgqk+oB5uXt5Tmb0sBvF/Wvxpinx9ybMBh mXlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043536; x=1777648336; 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=kaF9LLylFo70xLMN3TzrFec0ifchkp6UTBct2Ao7W+8=; b=FkjH2ZNkDv1hiMouhi05P2ozidvo98Zl9x4XpVSH4HqsvCc7ZlOe4OWP7eIGoIaWgm oTgbdVSI4Je+21Ig3BvCYfi1edd+SkrjpRoNRs/5c4ycG/kmQBxal4jepiK/9pilsgUc //qcchMB3rpgFsBLizYo/YJqci0WRuUhi4l4VXFtJrMDPScZDWHyD9n7flJiNsqJasgQ qMtwTKeRXXotmJER4gA2ucaHN2GHBaimVQmpLgeUmhR1qM2f5P9Dmyxn7OFYpgu02Qr1 dRV5vZR+NYYbTvtYEvDRcyAN1ufVdnH5BSQjIKoMmk30rxiin3YsDGuly1OBLmL63tFp e4lw== X-Forwarded-Encrypted: i=1; AFNElJ8NI+jeKKdEzqxSzWEedUHFxqwIBprh6MBkoIiVi7zaGhs1ATOIz0lWuVvkGk1sBjD5SQ3q2fQosousflY=@vger.kernel.org X-Gm-Message-State: AOJu0YyIhNdAuj4QAMJHNHZvQoLo1pO1/le29jI1+NohNc7vYa05E8iq YAZPYB3CuDOOx7VirNlGLpuZLPyfFG8Oei9b2gHuHnl8MuqkebS8xB2yxwJ9+KnC7sZVNhWmHUN dyV9qsikVL0hqbeWR08XHahYSv5b2SyVNXFxUsnz+Q/me0pNTkUlcgAwPQJt+acIq3gY= X-Gm-Gg: AeBDiet/ZARMDxjie1rLWieqA8YapW/4oXJpAUpIWnkeUc2By5TQ/jvmufSIlGeSWWY 8T9baIoqcoWHNDymvg7CzyC66rHGpjGYZBGhvoUTXkag2C2oRDF2Qo/0NLrzFZaQyh1VfLLBXCL rfJUkBt425Idl2tPqA2LXPu9kHYhGMW5X20mNIticSagbSw8Nn5IP9Ud2iDs/IXSj63ndunF0my weX5vXeCOeivxnyRSMs1pTX1iLFg9yOR3q/pBHUnUF0ig0umnENyAsYuatdXfSC4nAkMuGdum1B tCujyTW65kuS1QnpZTnYSM8I9Oav74MmSiubBYXL2rUA5fxr4UWUipuqhn6xzcqY+ANIKVl1ok0 ZscBXdjLHsb5+7c+44r5U7gv6jrZsXkauvuMvWiKfiVs= X-Received: by 2002:a17:90b:1d8a:b0:35f:b4c1:91f6 with SMTP id 98e67ed59e1d1-361403f2807mr33727831a91.10.1777043536119; Fri, 24 Apr 2026 08:12:16 -0700 (PDT) X-Received: by 2002:a17:90b:1d8a:b0:35f:b4c1:91f6 with SMTP id 98e67ed59e1d1-361403f2807mr33727785a91.10.1777043535395; Fri, 24 Apr 2026 08:12:15 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-362bc4f9360sm8421495a91.1.2026.04.24.08.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12: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 , Abhinav Kumar , Jessica Zhang , Sean Paul , Marijn Suijten , David Airlie , Simona Vetter , Konrad Dybcio , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2 10/16] drm/msm: Add basic perfcntr infrastructure Date: Fri, 24 Apr 2026 08:10:45 -0700 Message-ID: <20260424151140.104093-11-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX7/DgeYqYrHR7 C/bFTfX9nqZhb6edtqG9y3KsJ2Ne8KHNcLHQaIu7bJVAecSYwQLc2p1tdBqZxLrGp9dbdoU60WZ bSf/Kmj/qHhh4Tef2HSbu0Z5xGKF4XDPNd6IKKBh80ELM87LcMTT73zMtju9z62R/k7avotwD15 S0zg1X2O5safNryK/1m4qpXPIu887u2y5V86k8/D/3evmGEfexIIYFYSWSJJGEJOyApcpyv0bwg aL+M+YFApelBHWHVIIhiR5UiJs3+GiNVJ4lLWUNyRXpEP4lPvLKMj2goedBaIO+2qwBF1/Hspc1 qRbzMiGj8VF6Cyt2xId0PUKW7DpVEogBCnNpaz8/ojSMOHonowAAaBtyrlvKPiK7dpLVZOUwomt SsShFHxdFBQeTDosoB8L16BkdZUHXKJCVLPUbK+FoR0UERaSiOmcARFQGzG+Ar42iC3pbmH/3aM lo6uIOxBrLfu2trhwHQ== X-Authority-Analysis: v=2.4 cv=TtnWQjXh c=1 sm=1 tr=0 ts=69eb8851 cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=hddbS_E73Iye693R-v0A:9 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-ORIG-GUID: dXYlxeDukGsGr3R99HQU_TJdEKlx3wFj X-Proofpoint-GUID: dXYlxeDukGsGr3R99HQU_TJdEKlx3wFj 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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.53.0 From nobody Fri Jun 19 09:06:01 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 41D2B2BEC27 for ; Fri, 24 Apr 2026 15:12:20 +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=1777043542; cv=none; b=HDJ+sZWIWFpMbCggE78bhfulqzZPx6umguzQX+NJdbfElnwjwLjPbgL5+seZoGmFmQv97X1GwNpy7jRyUN9aXw3iK0i8w41+WYXSJHjKHvVzwO+z/BM/E+KrgkCQqiRcnhmyzaUenvVkoDgRhAGFiy/URsGRmm1/6x1zUN3j74U= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043542; c=relaxed/simple; bh=UhGTl+fUgRdmXb/zs6mAnMmKieTngsW7QFo91Q5/D4I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b0Qd9nGBgV+rDX+nJDX9MimVB/v38JlSeLf7/f5ZO5v+9MfBmpKWhlvqQ215UXwsP9Zjx2l2JCymclxOm+NZUR99qL3VnBEAqnm/kMoXFJrd1308NIYfZsLHdQ+YwgWiDyhAU1tf6tOoyTsgYXX+5MC7P2/n6CjDbigVs0btRSk= 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=L8hwhr6L; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=WCbu6jnC; 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="L8hwhr6L"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="WCbu6jnC" 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 63O8ue0X2710093 for ; Fri, 24 Apr 2026 15:12:19 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=6gpiGKD6NOz XykXwNxb4bW/bNZG0eBfs5NrEf4+DquQ=; b=L8hwhr6LpCNIVlaWJwEeB/PkxcX zA6SD+xpM4BoQUanP5kBS2YwljfJ1l+/LcwUUI+cDhhfzNobEq2kLCA9t6sU0PkK u2MsbYhHZ25pZ47LrThPOY6ACfUdZIvPtJzJ47qpcQV2yJirFLZCNEdY4ajxxqH+ H73RoH8MvLJYy3TctjpMMObA4cF3Wt0GZVl21F03qKBWkZjA81Qm1TaN76T1JDas /53SXYS9sLzQqU1qRsnGTDyD7k0yyvpuR1czw7YBRsMDyrXi+N7UtNuvUdWxvo9b pnCiM0xt94mhg1hjEWCCaTNqDCxQZySv0erHI3Q1VpH+d1+q0cnslk30mxw== Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dqqu9vra8-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:19 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-b630753cc38so10427525a12.1 for ; Fri, 24 Apr 2026 08:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043538; x=1777648338; 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=6gpiGKD6NOzXykXwNxb4bW/bNZG0eBfs5NrEf4+DquQ=; b=WCbu6jnC/ponedzeTNNMj6QdTh6frarRKhgHCAp6D/D1GzvzvXtYwb60Dd+6Uvhv7H OGrXoKgr2iDXBznfxZtfx++alm0ZUXJa1lSNWjDkJ/PChsxjRJOovInkQaR02sQaZRim 0WKTRLJR7cuPx0Nf0HGJb4oIHu4qrs2pvIbTA7zasdF073egsNZcp/2ddlv3qAqD5qET xavt7ereUF+2htkh1nnSnJc1zkG9UTy5XBnfBqLLLYUkfYOsoSbHcq+g4Sprl4zMVZao spWc378qqRlrmiVyRUMM0OQVEbj6GH8XF0ZMji29MZSGZz20hQRtfkRHV8tfr65EoQec Ff6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043538; x=1777648338; 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=6gpiGKD6NOzXykXwNxb4bW/bNZG0eBfs5NrEf4+DquQ=; b=U/m3S1fcpo9Lhb7Oz9TGN5zcfkWKN1p8AZWIm9MejvVuTXlZsTSdw5rvF89/hrKFOL d/2mF/67UTbojRYOesJFb7oM+YacFyT8MI4sesgFPtDHoIhVSz+PHTwZZfwPlGDldCZX np4wHQm3N0dFVwbkHeajDiX8Ug9h0L0YatxYteOiEDj1sJcvdJ4mEh0fsUyJLaZDPbwP x/fyIAzV50bI7McrbZcF6ZjsMyXg+yXUSX7d3GC6IssFpOSfomC1SleJYcqQr/s+gKRa e2LlcNl1OvkKzswGgdd8pYqPexM1EYbAy15cn/QnO6rzwuTh2nYBsYRBBsiC7dpOo3ds wpfQ== X-Forwarded-Encrypted: i=1; AFNElJ/GtQ1KKiGgWBPMZW9pu/WbqcLqZF+IGg7uQFhmSqgVA8O9kCwybyqC3UYc7a+qq2ARnBcOWkMiy/cit7s=@vger.kernel.org X-Gm-Message-State: AOJu0YzXhK9yB/ESV/OhYPe2afIfyzuQ0UpEbe3A0S2y6kNHqpDqKkMx /WBxq9EcvQFtDXvgKFzlz16R8Ifg5vd52jtucAV7JMM48KJO3iUCph4ogIMB29e+12Fz18HFYdu uJmujK4ggpjeoQP3pOFY92xI+p3xnnl/ZUFhyxtevbHnvrI68m1Zw+j+QKlFTqU8JX7Y= X-Gm-Gg: AeBDievY+Qgrqukrao54F0fmIFt4GMsSTRhvK23n0THb+tvKCE+qB3but2YSUVonsfX Ku2DQoQB7tgVMpX4DA5ff9ubg3y1Qz0oC6or0L5rc8nsBGcpGCP4HajNkUJSl7xjPGWc2jqEfdI syFzuGTaN9rvuej46sCe2azcIaqiBkRstX6hr6NUq1TxtjrcTpcMNQ4l7WJV92Y1hJ+WLgSabxo RE+d+0zZmmnZihh5bPqlXJGj7BkLm6vpTAEg155SBe/8IaXohNl+u7EtKJwin6CPWXrFbOJHkNP nI4HirsYQSMdHvg8q4Xp9y5giM0nhaHmgmJB+0c+vI8j2NfTs7Te4N1f5eg/m77fF8QKqlkX54v wxpW0AQLvawyOh2imSdG22FwLu7oViCwz4vp2wlqBWFw= X-Received: by 2002:a05:6a20:e211:b0:3a0:cc67:39e with SMTP id adf61e73a8af0-3a0cc672136mr28254926637.41.1777043537922; Fri, 24 Apr 2026 08:12:17 -0700 (PDT) X-Received: by 2002:a05:6a20:e211:b0:3a0:cc67:39e with SMTP id adf61e73a8af0-3a0cc672136mr28254868637.41.1777043537326; Fri, 24 Apr 2026 08:12:17 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c7976f9db0esm17494595a12.10.2026.04.24.08.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12: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 , 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 v2 11/16] drm/msm/a6xx+: Add support to configure perfcntrs Date: Fri, 24 Apr 2026 08:10:46 -0700 Message-ID: <20260424151140.104093-12-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: TubVfRMjf4krP_pOkamtUBldkGAtegGl X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX2vDHZkSuC9l2 n6NXK2ppUYxEWLCTsMmBltMpKd2IY3nO6mXfCNgi956tqwsy8VsXJVkcr8Q1eWVsEm/2HEuEEXO UsyB2+E+rUcpLFDgz6L/RdzlYgw+yKv1WXCrpb6z6ZdhY8X3M09462o/y9MfflWjyjd1pvO3SxH 5nmhrd03g/9Gc6wxyR224xnp0LFxZzTg+vtUb6UGYHjMhPDvrh2e0qGMbnhX7B6onXSHDSBN97S rRE4cJNBwhciDTLc1lrWp/l1ON6cWrURihuIlalr6RlMWYM+ifvKsfS8jjo1NVGhEntvPFOJE8m +lKqORKH+u3TiPwElyoakpoYhqT5msdtm5+DTxrtNU772It8nO1ePft2EqGhbywZfppzcFSAWv+ Gk2pmiQ374FZcDgwYFLU5d+6jUbE4/k562bceZSxrt8pmtqdnG84EK83ujhAgkeCdDVrFSOsCsg eEK3aiRI8801IyqUpQQ== X-Proofpoint-ORIG-GUID: TubVfRMjf4krP_pOkamtUBldkGAtegGl X-Authority-Analysis: v=2.4 cv=QJNYgALL c=1 sm=1 tr=0 ts=69eb8853 cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=oWecmCczN8450n14xlQA:9 a=_Vgx9l1VpLgwpw_dHYaR: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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 impostorscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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..8b9dcca8e051 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; i < 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.53.0 From nobody Fri Jun 19 09:06:01 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 B6B383DEAF9 for ; Fri, 24 Apr 2026 15:12:21 +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=1777043543; cv=none; b=miizDTCtDd7IrvuCMS56HTqEoTXtfA4q91kMGOymT6HSWWmd1Qx2wjkma2of58MN4JXYL9z0mXQW5g6iz0DKUcGuaaMekWMGNlMoO8GOjxfqmXgabMHbImC324uJ5SEOiD0SG+0ssJOio4DSN+1s7SQYUQHBN9KZwFC9Y11DiUY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043543; c=relaxed/simple; bh=Hqdosxn2gqR1QwnvKc8ZMveHrCnVn+VGyhBa0TF4nNk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Sw15ruld/HgfACv23W31eQjZCZWL5Gwye1Rzd1+tHCKkCRdlrDggDi+MnPytBkqGp8nkAmWPkTSHcPbUK+kMFpJZizM22xGbBZl7i6HF7KWdBtos0ibmBgkm7wabADSIlDo4zIg/M1M539PvFfLVixNEFenKANcLiIN1gL8Xfx8= 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=Z58PEK1x; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=CvPdxiCA; 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="Z58PEK1x"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="CvPdxiCA" 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 63O9Dim9756701 for ; Fri, 24 Apr 2026 15:12:20 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=GWYw+eRhUpl ftgFXTQLL3PdOcEwv5KNZZwwyE3cFoUk=; b=Z58PEK1xvg23g4xh7+k/b0Hqbfh lY04erevh8XD1vtoSvLsP1SHQuxtc7wBcdhN1H6kTS55RCzs6ZxkOHGUvusaM5BF MKxoljmZPnfd/4eLS+wRJMcqXNw9T6O4Vk7a3v3HbTUg6qtD//0RmRBv4b2tLu0/ m9FwYGE3CHK9Gn62As/aX1MRcMHMTXDDS7w1fgOezub8G2EyvggK+07WqZ98AJAv dsnB5rfOcUsAZUySRBUo9OUoj5sa9lvX3MkZVCg4dgXUz5JthFNDoCqTsUhdZr+J cB2wjyC7qiX+7wrFhlNlH9Pq9keyjjDkNs7Fbv2n87B8ige5+NHpCv3rx2Q== Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dqr4bmn4e-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:20 +0000 (GMT) Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-82f6a5b4f88so10763966b3a.2 for ; Fri, 24 Apr 2026 08:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043540; x=1777648340; 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=GWYw+eRhUplftgFXTQLL3PdOcEwv5KNZZwwyE3cFoUk=; b=CvPdxiCAr+kkfWEZ0wIxD1GP9Nc686AEYQ01aUh5t0DZqtLu/aasqRU+HUPB+i4BEE 3Qj0j0PwBQp23Fg0qx1xoKXD1/aA4wNzITI48Vg+o+mukKUKi2aHKQaKavAtK7zZY8n7 OxSlp/rCeMnq5zaj1fxTKCKfsQrgysRRljzkA9dODrN05A2iLtx9g11onC2r2+uaAOYp +uAsRNg2XLQzT7S58bcX+siWiuulFmKzhvlBZ8d5BB+OpSs2Nvlb4UEs3H7KL6IzzPGH RkVBY9bO0sASGkPgfsYcAYkFruxK/CRN7kDl/gD3IIbN4N4ITaXxDi3sQ7KzVrBqJtXC aXRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043540; x=1777648340; 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=GWYw+eRhUplftgFXTQLL3PdOcEwv5KNZZwwyE3cFoUk=; b=e4Qxa+zMhfk0iKOiNQ64fbwIcdg/dX6GgM5d+9JRTVbMxOZbuHPslKZJSjtJ6qR4em F4xt0sNNMubC0O4g31roZTLuLL7oTEnxIUBzrzo8uXmWXSLYe2N1cYhE5AYbmyS4FMb0 s7oEiLAmlN99PKcUBDcWdw453YYNsmeK3am1+w3+Ch7gRpJC/0Xu6009UzdKQTSeWkBC kcNMKZo7YFlt6t/h6YM5HmQCpOBHZNQIgE10a2demloOu4Z43M8dhlXky86f5GJtKp9k 1g/+z7IuX19FH7ZmXGRw+GGbOvaeePk/bIfsdeypd+xJclkvPmkbxnoONhDwqR2RTJLR vz+A== X-Forwarded-Encrypted: i=1; AFNElJ/39k7iUqymlwNxXK+Z3ydcFbFPfesa5YIlrK6mKU3uWccj1i0qPRVQSVhSiNiwCpkzitsV78GAvu1sddM=@vger.kernel.org X-Gm-Message-State: AOJu0YxTu8zAzLw6YD7JJ4xOy829fQd8ep6Qh4Yc6mtyG4CCDDItHJDD auJDwQSpqGtYIdv1UZ0SpKqNYHWq/pNAchNX8E4U62Y/Wf3zxgjEqjsrsz6BGTFr5qNpaOBsTGp sm2VG2V91BQbdkRSUBF9+978QDXrVH4H6uHAg4G4Y+9Ahb+rgYu+NxD8rd/V6l8RESQc= X-Gm-Gg: AeBDiev6MojmHlcljhyGBf4xnCCMa4jwjvwtqTFJ0IeuVzrRu0VcQJLW9lnB4enrw+V 1eKXswvcNj+/YPZoK1sZ8/gSYDH4ad3EfpRlavho0WFONl684SxZK4w+vEveSOO5DNxHTCARyFS jyvsL2JCrzoBHwt5vXC9IWI5Te+SwxCM9ulWi+TKbxtz+GFvmSMJD9kK8a9X1haShiBhbWKRvH4 GuSX2dtIFL2s+45b97IXsHpuEpzp1xHg2z2omPu9p0kFSkLB9+ChZxgRp9OchR+vWyyV6QUlDWL OsqmOhytXxcPILHGxRdE/cmEyQi/hX5dY0L2XNItRZsYIPT3ezke0nvNDKbwSTK91s3mZKWhgEh C6+BVCPGPGXkJrCxiJk5BypcuhgdYpB1j/z75CtvfWOg= X-Received: by 2002:a05:6a00:116:b0:82f:9d21:d352 with SMTP id d2e1a72fcca58-82f9d21d516mr22394124b3a.9.1777043539496; Fri, 24 Apr 2026 08:12:19 -0700 (PDT) X-Received: by 2002:a05:6a00:116:b0:82f:9d21:d352 with SMTP id d2e1a72fcca58-82f9d21d516mr22394074b3a.9.1777043538897; Fri, 24 Apr 2026 08:12:18 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8ebe68ebsm26965701b3a.47.2026.04.24.08.12.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12:18 -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 v2 12/16] drm/msm/a8xx: Add perfcntr flush sequence Date: Fri, 24 Apr 2026 08:10:47 -0700 Message-ID: <20260424151140.104093-13-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX4DeTl9YAPl5Y 8pWxrycI8JeWb+/dpMqIfHyO4DRBTu0r3LphpoFW8tdjb9mcuUVMAZgbJ0ESvE3v3qoV/DHSwpQ ZGXAZCHMvFBiNuJa2HHOqSDcNVY53RdD0K67OGnXbmysTibAE43AlkGIFfV+SHGMLlQVZAUf6RY s/R8ptBsRKn72SArz4vDKDlT38nljkWuY2rpdJxTfoPwZQcGYFLvUwNJfUX+xxsXoP7x2tqDPL5 NqUbWeoqKHztJVQzSnaKETG1ynbujb0oBpMU5HgtMbIApLlsh3bdICxqWjOu1LUdAT4g1WrDe/R yXRdS2uP/aCt/A6fxct4vj/30OEa6MlyKvJDl1bvY3/99xAfchcogoPE/4VIX7HUQ7euYlgIUuq xLA88jlSuvyQ/P2lDQiOo0pSJNobZp1Knu7tS421+q1dwbeq7Rw5JI24rN8vC1BBL7ihOa95tZl X/fIrk/ONhL/8jITpVA== X-Authority-Analysis: v=2.4 cv=TtnWQjXh c=1 sm=1 tr=0 ts=69eb8854 cx=c_pps a=m5Vt/hrsBiPMCU0y4gIsQw==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=W-43u8CF5Pkpiqpb4b0A:9 a=IoOABgeZipijB_acs4fv:22 X-Proofpoint-ORIG-GUID: -OddVHODQKolJGjOW4zhbuBwh1Vdvtzl X-Proofpoint-GUID: -OddVHODQKolJGjOW4zhbuBwh1Vdvtzl 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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 8b9dcca8e051..6d0f8dcbe9b4 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.53.0 From nobody Fri Jun 19 09:06:01 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 80A1B3E1234 for ; Fri, 24 Apr 2026 15:12:24 +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=1777043547; cv=none; b=FECSwyUElYUdKrl6MGMloK3IF/reols4673V64O+qYHYHo+ScNlZ0ZA2Haon/IB5gAGT5tVyq1OL8aCALIHijEjYVx8veP6uTyACTjGo2sfX+4kQCmZ6o2wXJqbvZ9yIYI7tunsOLTCTpjxF1EDHXWWusVEd8Ab+uuCxqt6gUxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043547; c=relaxed/simple; bh=ndfTZKFCyNOWfBOIxVF4GZJcU2VUHqTJCaxPvrd6QhE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=at/RGv0gpUJGYPryosXWa6UqR7N68stbtH+2/pB6fTSel1mVWNGkl1Ge0HnsTojedfSF95HS6hh66/eUJnwqZic/8vCIodnj+JJZa1RBFasvCWz3UwHDSgo1IaoJx2vVSWnINiVn+mM7cD90sk2uQt7q4gIXcz5UZtaBZWmSf0Y= 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=if0sWx61; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=QaUfL5at; 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="if0sWx61"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="QaUfL5at" 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 63ODbbqb1888415 for ; Fri, 24 Apr 2026 15:12:23 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=pnACiEC5u+r wJ95fUtKdVtxmcmGXSStCml5Ieu4gVO0=; b=if0sWx61l+APW+Ov7dFnvaY3bgZ gMWff5Og9EgKpmNQI94XTivxsC6z1TNOodTvaqJEL2T0XZ2UhB/dIuDlcZKmc5o2 NI8Sq9eOy5I9bFqyCewYb4hitJ8Xhn7Fm/DedlyjyKW6/7OkWGOruvFd0rpw2Fx3 zVE8ZbkuNAYWJXiOkzRrQkFaAccEDGfw+YRRYaNP0Pur/ZrttU1q1Hw24UebttZ/ 6lrDZN4+x1kEcmf0HDWMfwg1YQuUV00dtNxW/2nsvaj8RTIR8iDEFuPQVvMGyVQE M154BnAoW7SDZI8+Xjm+hcHv9RZbbjwnddtGOHZ9V78dW6FfL405yf55ujA== Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dqp9dw7qb-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:23 +0000 (GMT) Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-8230d6d54a5so6468184b3a.1 for ; Fri, 24 Apr 2026 08:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043542; x=1777648342; 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=pnACiEC5u+rwJ95fUtKdVtxmcmGXSStCml5Ieu4gVO0=; b=QaUfL5ata1kYcoH5OdcOuanGariPCQ4WgKgW29kvNm27diBlSRFyW9tEl2FePTAG89 +Tupe39FlbCJi21+81tdTLs5AnudwIv3XTPBQGd8uyA4OJ2IWMscSw3KcqWd/se5Me4b e6wm4Xek4idSLX+0u6N1lba+j+23+PKSdYxMHzDhn3vXwOXdmT9HlB/t9K+SHl0SUfba 8AATAHtBdivxd4aCMKC0HeEQaPy9MRvwTiNBoxMoAA4lfnLC4fDuToCv4mBZG4u6p5km JC0O76dehL5WxPBcz1rdz7uAphPLYLqRm1AEBzr2LAoOlE17GmweB2NHSMkOkJh8zMaX JC6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043542; x=1777648342; 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=pnACiEC5u+rwJ95fUtKdVtxmcmGXSStCml5Ieu4gVO0=; b=UptZhCizpcslVO9Ws8ofAF2YBXCeeovmWvctK2Din0tg9XOceKJS9W77+CycZcdcNC XddULQXi4lS3VEDj4MC/O19R3L5fiVbQRRZdRpSOzsXaCDftfD/F8xadYBySwhbCEqIl vcBtd/tyLDlGb/XuruBdp0lpRhsOQb4CZ0yfE225pcuuzN/AAd78Qi8WymGjR5CQjw6w sm0h36gvRxkTRJ+RhkIcaByj6LUq4OaHdk9Qhhuk+pVH7FKAxerqGhhDMKa71loaUxls rdacUC8BtrH5nujiR/zCVLsLGJrc8EjHD4Qof2ytbBbpxArit/cpdc4cwRKjZz7ufHCR vs7w== X-Forwarded-Encrypted: i=1; AFNElJ8RKS8JADuxFj3ypPQUsRzwmZvDxIoOw5cSi6k/fIPfckt6MFRrf2ZED9mr7tcuH0cpmn10LIWYQ1U93dQ=@vger.kernel.org X-Gm-Message-State: AOJu0YySK+k9l4VJCExd2TqlPwRtISVkIbKkJxayeDZRwrdLDNL8cOEb JP6WrEIRZnKBly1f0Spv//yLSKxx+aoELPq60Hn1lhL1VboqFGI1KRi6SYGd9oKfebp7oqNkHSL caPK5jf+W2yKR+XX3863uJUuBfaE5ED7D2opLT2Z3AT9L6L0DMr5oLi0qUFxZlhTgE3Y= X-Gm-Gg: AeBDiesqezvusZ3IACHiotaZSli3qj+PUH6oVal51SUBXR/aF2aJ+h54C5G8zuVo4tx 1dNDpjP+TK9uYZah/RMVwUODQsAO4jvr4nhbcgKU/YlijTtX680cYaZYQPHmRVU8qcYDmvhdDdk 8ffAvngFpoQqyd5hEC+QKyMchN+iLYN3XjMdOiQHszhf5JhXuM1YtbyqbzuQ+sDihhbp5wpjFq3 6ts0WPpz7O9cgUOBQZmK7fg6hE+Hwx0q1fV4YWq0lbUf7uFtuYTvYpi3I03R0uxp0sB+seJpB7j 5fJKQd1ANC7foyxLiQxpOKMMb4BpApMu4WZYPJsBpRCT0aEjmunQheBo2ICyR6CyBombZFqppkN oUjm/7BRFLi9ZFEoW/auBO7IOUu7mjsvs2p6ecYebrXs= X-Received: by 2002:a05:6a00:a16:b0:82f:6640:7221 with SMTP id d2e1a72fcca58-82f8b50774cmr25025707b3a.22.1777043541912; Fri, 24 Apr 2026 08:12:21 -0700 (PDT) X-Received: by 2002:a05:6a00:a16:b0:82f:6640:7221 with SMTP id d2e1a72fcca58-82f8b50774cmr25025672b3a.22.1777043541288; Fri, 24 Apr 2026 08:12:21 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8e9d9a1csm25558723b3a.20.2026.04.24.08.12.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12:20 -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 v2 13/16] drm/msm: Add PERFCNTR_CONFIG ioctl Date: Fri, 24 Apr 2026 08:10:48 -0700 Message-ID: <20260424151140.104093-14-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: o-4AhPrLhDoQicshIqf4Hr_vPr_MgBWi X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX6LljTfI/t4ly 6CTqSffh0My2QK9SXiYILAVJp909CbJX+YYbmMsVcZSaj9PdL0wGG6QE0V7gbrzMnfUtIWyJc5/ 19ELQ2BCgM7EyevqSHPzNjnW9Z3vl9wzLnQSUZLhC0InsU2Clix1GxwinboP7+N/arTR/QwbzHI 2Y1DOaqFAPbPi7Qvc6/LUJcW2wBH6Yr19uTQQ+4zu00nQfjXbiUF7hMBTlRMcXrp/t+bKpESPYT I8JlAjel6+6xMydBAth1UiBz5sDIkDZbT9GWDp47pOJi2Qtf8LEMY9O6OhrYX92vjrWmCImU7An SsjksEiHAkYwO81or2363nOqRr2c9wT1azY9+P9ndMnOJ8Bl3b55/vRt8M/uVx9h+sA0KqJDzzH QN+4CH0LB5N52Xn5rX/9UeU0QU9UI9EjSh/QTWnDvoqaQ+XzgVObSAIJ+eC+iW8i6YYb3Ku++ha OXfg3W/NfZz2aEK6Z3Q== X-Authority-Analysis: v=2.4 cv=fP4JG5ae c=1 sm=1 tr=0 ts=69eb8857 cx=c_pps a=m5Vt/hrsBiPMCU0y4gIsQw==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=xHXCb7tURZJUc_s-I9AA:9 a=IoOABgeZipijB_acs4fv:22 X-Proofpoint-GUID: o-4AhPrLhDoQicshIqf4Hr_vPr_MgBWi 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 clxscore=1015 priorityscore=1501 adultscore=0 suspectscore=0 impostorscore=0 bulkscore=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-2604240147 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 | 492 +++++++++++++++++++++++++++++ drivers/gpu/drm/msm/msm_perfcntr.h | 51 +++ include/uapi/drm/msm_drm.h | 41 +++ 6 files changed, 590 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..8dd919c004a2 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,451 @@ 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->groups) + return UERR(EINVAL, dev, "no 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"); + } + + /* + * 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: */ + + 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); + } + + if (g.nr_countables > get_available_counters(gpu, idx, args->flags)) + return UERR(EBUSY, dev, "groups[%d]: too few counters available", i); + + 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 (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..4d734fbfd491 100644 --- a/include/uapi/drm/msm_drm.h +++ b/include/uapi/drm/msm_drm.h @@ -491,6 +491,45 @@ struct drm_msm_submitqueue_query { __u32 pad; }; =20 +#define MSM_PERFCNTR_STREAM 0x00000001 +#define MSM_PERFCNTR_FLAGS ( \ + MSM_PERFCNTR_STREAM | \ + 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. + * + * 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<; Fri, 24 Apr 2026 15:12:25 +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=1777043548; cv=none; b=klwarThf87ih3735i3GB2uvDBRZYMeCeYq9IOOVSHmYiRHLzdyI6neB2yCIVd0eM83aynETcAMsWz6iM+oiiEcozC5vLOLNN02Nl85yrM+YXQP8+hLXJETwMzK29VSyqeqJIJ2kqOtTWLzULE1TSLm68R4r3xQzZPGj83sHOeQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043548; c=relaxed/simple; bh=6eDx26EG998hscLosra1fWHiRyCYOylVPDbJtrjnZo4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fy8X23oLFSAiSzqCJj96PAdPrYCtSe4EHPjrVaEwxY/iBhrpGulmjuVJ49BBcfW9ZOfI/L726E+2VksbjdGQfYZB44DisULZr9kxRmUnsKJUnsvQPXVgdj+DJnPFdfe2C6+jTZColkMnKb1u86BZ0cPJt5Qto0RZeksGhcCktrE= 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=JRJN+Mqd; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=IhYguw9s; 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="JRJN+Mqd"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="IhYguw9s" 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 63O9CEcd756669 for ; Fri, 24 Apr 2026 15:12:24 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=KywJ9hcCP0V e4Q/2h24NGhAJMgZTF4FNw76RvtNMYhk=; b=JRJN+MqddyEDO5gYUdhUGuwzto/ PpfCNdi9dD7KhQUWOgRuBWVZd+GWjYZItIGWRSmi8WbD2oxwye/wYAex6ciW6FQV 0MuCI5GebYWW9bpM2/E4xPPW2NPVfhaYzGw/ACW97+vuSMGKTsGgrTksuHPGv7XZ DZOeOEkF6cPaFh3de1KNCQ2t1MKKALOob6vgavBRfMG6DVi3vyILaFhoqBFRkDCr trkNjLosenQjGUrFfcBRpo52xBdfzYmV9XRKdWACKJTBt90RvNOxd3eyVWrrPAiY ByLLhKs7vdedJSumfXFYlgo3AyE5ySoBa5RCTZ/fyKrGk4lkvPMszxbHGPw== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dqr4bmn50-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:24 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2b2d83e7461so135883395ad.3 for ; Fri, 24 Apr 2026 08:12:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043543; x=1777648343; 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=KywJ9hcCP0Ve4Q/2h24NGhAJMgZTF4FNw76RvtNMYhk=; b=IhYguw9sTU8j00Y6r1HwAZ2vgu8Okx9EWFAihWTpaD3+/cOWuU3KjLY52ZQUXYJ4bt acaLxztCuLP7g4b91lR/+iofBkQ7P2oyYOR60s2Q/A+7dFqFRKCa5jQ0R1Pa9gwNkj9u g28pQgFq9Ozp378RfX/ERqlLosvR/nQ2A8jGvTF8NV4mM3/0JXyoU4fE8KVnUFmhzChZ o9+58kUszHAo41OhniO7e6tkEz1qag7alAu5wiAd+iIKiud2guqH8omdAyPMfox1W+xc Ez1GIvMjpXRfaMs9H+T8g/hCl+5FnUtxoOtlmpn8QsP+p1XuTF03WW7DNKwuuo6PiBqL e5/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043543; x=1777648343; 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=KywJ9hcCP0Ve4Q/2h24NGhAJMgZTF4FNw76RvtNMYhk=; b=YJYr4WOF3RQ5g+Rorw7k0E6MQdQ/Otiw2rEiMW8sefzV/A5WVwePCbhhG0OCMOjcf7 jUeQeM0A5hwY1uaBUh1BJ1t9PFbzDMN5bSUUUsGvpUVPqiXTpdsPwRFBKGTX2Q6v2UZd ZBifnp8kL/Nhzsil+fhDxhG4i5f2DA1Rcc4nqrzBxc1X7GEdm5IhcOoANWg7LVq3lVLC fypEXjPdKle5b2jwFzOH7Sf7mQN98JLSqXijsSbzHV7j8UXmg/f0qTuZFl6aBOMzt/IW 877aRvSkyWYeHtANbs5bT/kaU5GCvyP09+jOtxRdRI7qDYPFWjtlk410Ox9I9/KNx+sy GEJg== X-Forwarded-Encrypted: i=1; AFNElJ+CyViytSFzrkBLdgvXkXg7LGiv3y2QLIUEckjeigzHlZK+yGcR/nfYWGDQ41XqSd80d25tpcZLuQgQuPU=@vger.kernel.org X-Gm-Message-State: AOJu0YzkoF8p7txRQa1FQEsDoRTmZsediDgWuHkqY5qK7BYZhBFAsTkC OtE+KHhwNHN/ZB9IhCXFv9IGQdjJjyYZ7rr6slICvM6zGSX7b3qihHW1or6kP2OXNzOotP+4Ble TCwrR0IbQz9NbNbUZmynt3LQ2l5PBh4UKvAqoRMLO3FNnBiZu5C9umjOgu65YF6fQBjyCd3HGou 4= X-Gm-Gg: AeBDievXPV0I6REWdhCtJVoH5Gs6dSeowZT9+PPiBDtwKhV0s/5/wJieu5HEvGdOigH IsMEP7YFF5oEojMntEsNviK8qqUAScqfDev52UzdUL3iWz5XYy9faE0NSjqZnZhbUazLuYJuX8D DAQVWJ/1CCtc2o1O2zFBsX0HUexK5HiR6Pymbzo5PU+Rxd2/6TE61p0Z1Dm4VkX00xJa6PW24yM t1jUNZrYSAuMy11wQJkXh1nitYTXlma5h+8BSg3l7WdRc1GDkPcuwdrKhrlJJXWxDSJ1RvEwAPZ UxbAjh4fFu3nkBtFiyIQeVVATVMF6IRQb/LAaytJIHDENDOmbcUnxcRIjVeucXoAtQy8e5iKMau hWC3IzffsBd9y2mFFUF/LCN3q9BR0gWjF8+vtJJ90/d4= X-Received: by 2002:a17:902:f70e:b0:2b5:ef7f:a47b with SMTP id d9443c01a7336-2b5f9f4e150mr365608875ad.21.1777043543114; Fri, 24 Apr 2026 08:12:23 -0700 (PDT) X-Received: by 2002:a17:902:f70e:b0:2b5:ef7f:a47b with SMTP id d9443c01a7336-2b5f9f4e150mr365608555ad.21.1777043542633; Fri, 24 Apr 2026 08:12:22 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b5fab4049bsm209805085ad.77.2026.04.24.08.12.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12:22 -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 v2 14/16] drm/msm/a6xx: Increase pwrup_reglist size Date: Fri, 24 Apr 2026 08:10:49 -0700 Message-ID: <20260424151140.104093-15-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX+XSejqfV9C11 voKch1P3T0I4hnD5ejjzibKOpFE3hiRwVFJEalDdbE+swzZt8zB+bZl48R78U6y4OGdaR5lYlYX E/dUqSyS34AroObrPn/XGJxdUq+CaOj0PDhml5HYJExvK4Xgu3rhjmheqt8qkBe8DVYF3/AWLWt BlslNKvczmxyza3xp6A0jYzSAXzQsHv2LNe0pgyCSGFEkYHdfK/+UQ9Jpt0YZ+mm7PwH8bro6eu ZUV7YL9mX2ihrJH8Vg0bAPRo/1yq/RLs7IOtImW2R1Yhh5Yii5pBrWGdSLHdiRJUB0A8yjvAaYp BwwxKPQYwb+CSi9IFxRM8S/6ZjU8V8uIaomXDzs3kGVETy5PS28KG5EkHdDvuEXmHlrrhu2pQIi ydWj2AuKwZ2ScVEu1sQ9G1E+SxJxxPH4RWYtmrqMLXjOL9oMWKy6hL5fPsdXtwq6INvhBXSgin9 Vq255v2gRfhI1zUDfAQ== X-Authority-Analysis: v=2.4 cv=TtnWQjXh c=1 sm=1 tr=0 ts=69eb8858 cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=8lTVeMJbxB4f0FvlbnAA:9 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-ORIG-GUID: qi9JyslzfCWpkrifsBVVzLXzRbqGDRiw X-Proofpoint-GUID: qi9JyslzfCWpkrifsBVVzLXzRbqGDRiw 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 malwarescore=0 clxscore=1015 adultscore=0 spamscore=0 bulkscore=0 suspectscore=0 phishscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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 6d0f8dcbe9b4..04a6335ac5f4 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.53.0 From nobody Fri Jun 19 09:06:01 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 734243E2757 for ; Fri, 24 Apr 2026 15:12: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=1777043549; cv=none; b=GqaNimcJUlpYxwN5Fn/w5oIwD/HJgU7iDN3T3JqUkre2AJ1ek0dUp0b7Po6XhDUtAO2l5fUrcjYHajO2IubirElE/iYp4PcM9VErYfScADhFW0iQfdueX0WwjlxZvnlfNQCK8DaBEdekBJDLzK4cxpBp6xaqK8BfZA9nnKFNViQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043549; c=relaxed/simple; bh=gJZPWBYc0+/WOvdak/85qdP6aNnAQ7WPayOG0QcvzXs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X5P/wI9dRAK2PK+US8qMIVGYm5cUdamRXaluDehZtEUDbdXZlP6QgNTLFy+1gsV6I8grEvHecJxz3A08lOCI9k1FW7XNHJCHf8MJCsER+LaKN95aiCExfsiXt/lWmAG/jUrSutnhOBk0JAarSL2CALMrIgUKNYfnm2wsAgNvqCQ= 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=CmnA3vt5; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=EpoNe5a+; 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="CmnA3vt5"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="EpoNe5a+" Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63OF0T9J4012381 for ; Fri, 24 Apr 2026 15:12: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=PSZvuLL+r9s fCfccBd2ob0WPVN+nCe6j9d//PM4k63k=; b=CmnA3vt55xpV8+HzhjvomPbH4/a bED7Ez48WbrzrbFSeQs0MkheZNscjbCezTyq/S8srV0bLo/m3YiQXAp7IOxgODgW aw/Ib7KHoZvNDXUWkHVhFf2TEaS0HJfTFqdlsKNPs6HLTZeP7ScJGtToMpi87eBK /56sY0HXoCwMo1V1RS7Ct78bZAvou0mHxNOJ852BFJYrLz9mt2F+zNwGDFGZpCFu rIm7CpdRDToUdOJ6olyUIp2WmPw1f5xn11qtzRzL4etOW6ulujiLeko6avWXk0a5 Ub87ZLPrFccUjbQXPsQ3DeurgnptoBsX256fhz1ZncKbX7d82ax4w8y7TxQ== Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dqpq9w05k-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:26 +0000 (GMT) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-82f9f49e4beso4140089b3a.0 for ; Fri, 24 Apr 2026 08:12:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043545; x=1777648345; 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=PSZvuLL+r9sfCfccBd2ob0WPVN+nCe6j9d//PM4k63k=; b=EpoNe5a+r90YT11kYHOoYUsu2LweFnoGyrxpQ0X7UNjUzJ3VTlUJPmBmU3Cu0YRs6B 01mBBKD8tzvfrTD1sM26qga2YL3n1BloGg48RpZXALRGtGEMYZ5Q0QV7hwXX5GbmN/t2 gjyU4rM4y9Y4oYrrMYek5cx1/4mFSh4CzqBuH7tPh3HzcKyJft97V1KbjJDOfMbcpU+s vUKmrdeOgLZFHKJCWzclIhYfWmfm1YVo6wMZVdjNnH1410EsK7Gty9aBqD94DHnbWHu9 Z3Z6Yib6yx9d0noKrZNzNyj9P0nYAg/ioSs231smtIvJpUkE1acrZS1KoV1q7CDafNP0 yBpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043545; x=1777648345; 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=PSZvuLL+r9sfCfccBd2ob0WPVN+nCe6j9d//PM4k63k=; b=tB32l+MJjzrGP6WYlc5JMWMS09FAaudehpJfa5AJkpt6PCW4ad4SJplG7n0es0SrUz RkRlvSIWPTQlknSwK995nafUVIMv7MMN3mJsMkk87K2RxPWpEw6teEIMhXSA10Bc6hdX 4JC3KkO7nPkVtKzd9P1qLL8gmNDtJdhdrNEFFK90O2k4vjzsfGEwRD530qeKTNxRRqub H/RrbtbcU30SecoxxJrCMXv6F7YgEhxM0r5EC5aTQDzagMxwLdoNzqBajxinECUDnOgf cuJZr/3zSITJ1p50r+uGOWCVKA+ESNbZsRErvuL8mVpcjStfObFVyHJqbPH/1Z57VgFV 8G2g== X-Forwarded-Encrypted: i=1; AFNElJ8pd7fAbddmCsQ4tah4r/OiZZBZfd0m5F61W0y2IIdrP3qqd/8rawAFPek1NJu7KzV4KNJ6vcN6owIs52c=@vger.kernel.org X-Gm-Message-State: AOJu0YwlNV83XkHHzagZsQKoJH+D+Dqk8/jo0weV0AD/+qlollEQ36Dv 8psXHojEZ7LsySk94Cj58+wQa9t48TUr6eZF+VmO+9+z/4fLMtNO9WSBsg1LKFo8z5qEJkSPSmd K8W8nDOMRviV5fwIFYHwuqIcLz+C5BPk3tiYacwS3O7enXxedftj/h7zCf1RhfSmstHc= X-Gm-Gg: AeBDiev2P8iHXUdGXnE6D3cWtNBnGcR0tK4GYadNaGDNi8G+mIhp3FDmpvUHqXAB57l TxiILhd1amkUCQHfCBuwGHKlCF3uYN30nbmUXFa90PjqU/tIbce5Oj6R1gJ+TYxvkdl2PPvV0AB rXgIW63HZUECmuMhzp5fheuG51bLkxWEJHtevwtmd8tUqom40qJeuBQkLdpoH4ZuxpRBTWQQCZv EWxSfdv8K4HFDBU+BZpe4lcPh7ZnRKpGveHyDFcLIS7Nwb8O0ZiyznZsLng2sLGJcLzWDgArh4w RiNraLgtlb1wfNfozOvG0WIFXN6vx1eR7Dj9Rxy0gLi86dwIGuA2ag70F8h1+chDt6PqS7TtS6X CcXa4i+tvw5wqh389jmnyFpv3vmKjbkQNo67mcY0cn3M= X-Received: by 2002:a05:6a00:bc90:b0:82f:1e5d:db62 with SMTP id d2e1a72fcca58-82f8c885af2mr34624376b3a.12.1777043545043; Fri, 24 Apr 2026 08:12:25 -0700 (PDT) X-Received: by 2002:a05:6a00:bc90:b0:82f:1e5d:db62 with SMTP id d2e1a72fcca58-82f8c885af2mr34624325b3a.12.1777043544374; Fri, 24 Apr 2026 08:12:24 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f97eb5ce8sm21767932b3a.61.2026.04.24.08.12.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12:23 -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 v2 15/16] drm/msm/a6xx: Append SEL regs to dyn pwrup reglist Date: Fri, 24 Apr 2026 08:10:50 -0700 Message-ID: <20260424151140.104093-16-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfXywar0eB94iY2 HuMKK602BjGhPPEGINb+erOdg7wEtQ7abKVQKfdre6rmZl+cujhxkzPx1DnVGrdokFhTg+b5QqH F+bNkV6wheeFB9A9v2pThW7+oPLBoJfZlSGSHjS36my4qEEVmvdXElTHGGcGf4HQQ+o+jv4dzzB pqWMwbxPP0n71ZwHtNWxBEO6ZT+lWXQzHlpHAndtbSNieQW2BMVjfSoaG/sRI83rXNkrkq8YJ59 Lj7tvypMabcBm5yYF3jyI5ZsH+Vbazp0hAs4MXj6G8vG327KcD/UGpdHTidw3LHvlKfG1Q5abIn 1Ptjj3FKc5Q8Dq9YwiijxPnfodB4uClEYASUoA8QK0jHDtlFNS3mp3RF/fzTZYOXXk1+AlukcDq kTg3WSMmlx0tqDHKXCEyJfiCGCU16nCqp+yOu4Zw3vqOdQD9hvDDVLauj+ChMgdtEW6ERI0nVEW vSB92+tEFRioaPHUn4g== X-Authority-Analysis: v=2.4 cv=FPMrAeos c=1 sm=1 tr=0 ts=69eb885a cx=c_pps a=mDZGXZTwRPZaeRUbqKGCBw==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=pU0-7o-2YXwa03qK1oEA:9 a=zc0IvFSfCIW2DFIPzwfm:22 X-Proofpoint-GUID: jDSBfpNzK2N3kIuQacegO09p8wqu5vD0 X-Proofpoint-ORIG-GUID: jDSBfpNzK2N3kIuQacegO09p8wqu5vD0 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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 priorityscore=1501 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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 | 70 ++++++++++++++++++++++++--- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 11 ++++- drivers/gpu/drm/msm/adreno/a8xx_gpu.c | 1 + 3 files changed, 75 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 04a6335ac5f4..c3305d18b87c 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,54 @@ 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: */ + WRITE_ONCE(lock->dynamic_list_len, a6xx_gpu->dynamic_sel_reglist_offset); + } =20 for (unsigned i =3D 0; i < stream->nr_groups; i++) { unsigned group_idx =3D msm_perfcntr_group_idx(stream, i); @@ -2567,17 +2611,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; i < 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 +2633,22 @@ 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; + + /* Update dynamic reglist len to include new SEL reg programming: */ + WRITE_ONCE(lock->dynamic_list_len, a6xx_gpu->dynamic_sel_reglist_offset = + nr_regs); + } + 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.53.0 From nobody Fri Jun 19 09:06:01 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 BF23E3DEAF9 for ; Fri, 24 Apr 2026 15:12:28 +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=1777043550; cv=none; b=preVQSklZjLpGae7ykTb8lkn4j0l0D4QLffzcAG3aCq/za9HH9y97MdQk7QpxG2qU+cpLDzZj8PxIea5pGaM2PflI6F1/M5v+B0JdZy5u3SMXMHM7YcRE1a0VuhJslHrvPefzHVgIONk3bdVwb52uqupPQuBgT2vq+gVkWi5NTs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043550; c=relaxed/simple; bh=SQyIN2lvht2yWROU012olknUSmPQZ8vHuGc5ANUQgvY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GSp/bhcn2CoQjhTRieN+HUktlI2f8340B82oyZUce40XWVhhI4G6TpdAwEcNDHmUnyYZhK1DxgClpwnpRUpD3A/4hSQnKJXlTN8An4W8cR18haMa1qZunWfUHcgRK6hpywyoVquOiYdKdguaHe/VijUZv5n3ZOmYn5pJpq+0e4k= 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=Idw+3XcZ; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Qob6OPr9; 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="Idw+3XcZ"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Qob6OPr9" 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 63OF5lIr2710485 for ; Fri, 24 Apr 2026 15:12:28 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=HLnAwFPOk/J Qm30uB0uKT2zj47gE1NdrqCSNluQVCr4=; b=Idw+3XcZ9HglK+Fam3941GQrCWS RuPu/UMx3L0XxJT8R+rWo3GQWcVa8gehHnZaFvaJhledjNRYHjwmuaLxNf7PG/As hRDSfBGSZqvbOW6BGb216aLfPO0bIsUY0UI7OoFaVuBoRq98O4TQKyj4sZ6ujpm7 Cl1tAMHLGlxtN7KS3kEduj0aWkhPkJczqFxP0JsEp7YFPnitCmtEb5hE3Grj7Z1h t+cbb4yn+9TSKvEgFPHNtZQukl+nJdkLkie0TZHhcKgM5zK6YxSvPClLVk2Su2sF dyGYijVwav1R0gpH3hBCv4VuPAwjZoWg+EVnV38rOoqLYFNb91SOjLXye/Q== Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dqqu9vrb4-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 24 Apr 2026 15:12:27 +0000 (GMT) Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-82f896eb6faso8406560b3a.3 for ; Fri, 24 Apr 2026 08:12:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1777043547; x=1777648347; 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=HLnAwFPOk/JQm30uB0uKT2zj47gE1NdrqCSNluQVCr4=; b=Qob6OPr9byecUbVImT2hnnReA1GK0Ix95+9ilUz94OyAnsAoomMrcoFMmoQEAHyzpw xzodLBjnk8Ox2hLv7sScwlozbWQuIkRLvmSX4/Co2JXwywAaEoX6rBWMwoegsePghIzt ezvrsWXfN+Naoxz1etT4ysRBH+URm3b8RKo9rUSBbmGcfgI4EclAmER5uObCd77M9g7Y ef913nW0HWaEjumjBHjgDba6eGX52i/SDAnUNCkFh+Rr9Y4Xe5G637L8zmpedX/+1dTM CnExVc4v1CJ08tyACmzwoFJUrSUCf9O2BIbUdb2wLGXvA9MNeUjUkHAqZe33gOxrqlHZ sbCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777043547; x=1777648347; 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=HLnAwFPOk/JQm30uB0uKT2zj47gE1NdrqCSNluQVCr4=; b=OLGPS3NLEmA2yB0176zr2/OkOAv1pAuXkx1Z2wqkH4d+6lhtAQE/8jPv57P0pyObiB WeRkM0P1HO575qNJSeiN/HiFoGQ6KPqdfplk7EbOBDS0pIpzWLbHNru5yLCYKT4pu1ro bBdpMsGDwkE85eC7VZBd5qy5P0CedrVD0un+p0PI6oOzv8EAIGCMybBdikdk7tlhc2At YsnJVZ+Be/9FvB+RP1m5Cs1XMxWkIiRuht5BOk6wSuoWPOlNIQKm85p685X87mdnOWDw JFUBM7cAEKzDi88zDTPUwbL/DFxuut9XxblujTy0vO9WXfvWKpzFoQ6ybezh8NsRIGzo tHRQ== X-Forwarded-Encrypted: i=1; AFNElJ+B1n+Ojf/XNxQuOePagR3fN4Y1HXGDts8U83dOdhxP7IXyx1Nj5spC6QyY5cAKqdQ34KpWUu5TBnmx0ek=@vger.kernel.org X-Gm-Message-State: AOJu0YwBuKBM/QpHFwsatYWG0Bllpn6UcuYSjkbNygNzfySJzXtIdOvK kVw/0Phd5OrCWDCdlNcCuypgDAxfRkAeN11bQCK0jw3k5vRAiclSNtqFPG8bUZX/iZxdjhKf1LA mZ4okbR5FM3nMKSX7BvftAqfKqWCN7sLuys9lPvIKuVgYBFtJRVRcXHZ4ddCUwaRm6xU= X-Gm-Gg: AeBDietuWvbP0477NRF7IZr/t0nMEDref/18DwZOWMv6ClRG27rZ6tN9S/NM4g9byN+ hDjOT9y+rE9QB+VZ9so/espV9A+sXOM6seedAqyBZwXEx50TfD4WAYEDOmcFe4pd/u+2dnDSlgc 1tiiky2GhwMucYEeSnji8EomfTyklEksMeLTwV5AP1Ll6CHjV4Buzui7VOUxddhji222vOimcjq W7PnzPT1wajCvSF2inxqhUBkQbZ2CT6I1yNEWaE0tjx3OL2oIG4qeVWuB/JjZ3w45K3q2AvTH7o 8ODb2KxO29TZhsZtetQkgZBxQX0r21i14kAdFo5pS6WKUvdR6bOOW8igz7OtC0KzCvFN1BX7sUz nF5SK/q19oBhsT1PodokfnjXolOWGzNe15Eg3ChPqXws= X-Received: by 2002:a05:6a00:8011:b0:81e:12f1:d8a with SMTP id d2e1a72fcca58-82f8c90497bmr34751497b3a.34.1777043546756; Fri, 24 Apr 2026 08:12:26 -0700 (PDT) X-Received: by 2002:a05:6a00:8011:b0:81e:12f1:d8a with SMTP id d2e1a72fcca58-82f8c90497bmr34751449b3a.34.1777043546148; Fri, 24 Apr 2026 08:12:26 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8ebe40e5sm22200402b3a.42.2026.04.24.08.12.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Apr 2026 08:12: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 , 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 v2 16/16] drm/msm/a6xx: Allow IFPC with perfcntr stream Date: Fri, 24 Apr 2026 08:10:51 -0700 Message-ID: <20260424151140.104093-17-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260424151140.104093-1-robin.clark@oss.qualcomm.com> References: <20260424151140.104093-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: EJCTjwtGUdXwlOEg32aTOguPKZ28pray X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDI0MDE0NyBTYWx0ZWRfX1u2PZCCYlNOX 3jCFxxYbBM9Cmf/s1D86H1xT/Je7vwNyFKwDMI8enNVNgNz7rGRQcnAUPG3orZ/2hPB49oy5Sjy 2pILF9bf+5/uPyHwackoDFFjuennUhhPxuiUn/7ulGGA3j+nR7qsFTh3mZ4kPgZVaT/ektIzRSX dKg92PX+yC6isdBYFA49faZfh+L9Spi6ksehC/aBZUtXF2q6EQTqHbw6/9lIyH8V4ZCnT3lj3M+ O7bXpzf6i4sVTKm71d3C++J4rpGWh8N2e5a+TG1Gz8sVVvKgqIu63u4jYEQ9J50iCEJ3GiRmKPw fJtT3wgU4eCqg8Z9Gg/WgB21Co8BVYqYxpdRuLtF26whtk2ou5Ak2usHmPqRYdWp9PkW8L2P5sN prt7pfYUB73FSgPUhcXl77sckQh22Z47Y+M6lvTFnAoH2cL3mK2EhVR+PMq2oaihhQhFpbl7zSq dnhiHOkoN3TCxXVHTIw== X-Proofpoint-ORIG-GUID: EJCTjwtGUdXwlOEg32aTOguPKZ28pray X-Authority-Analysis: v=2.4 cv=QJNYgALL c=1 sm=1 tr=0 ts=69eb885b cx=c_pps a=m5Vt/hrsBiPMCU0y4gIsQw==:117 a=xqWC_Br6kY4A:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=5obZvuzjGUYrwyXX1KsA:9 a=IoOABgeZipijB_acs4fv: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-04-24_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 bulkscore=0 malwarescore=0 adultscore=0 impostorscore=0 priorityscore=1501 spamscore=0 lowpriorityscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604240147 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 8dd919c004a2..891c21be6158 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.53.0