From mboxrd@z Thu Jan 1 00:00:00 1970 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 392163644AF for ; Fri, 22 May 2026 17:34:59 +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=1779471301; cv=none; b=DWmWBFXOFzKbifpwovNDfXs7cUkSmhn5MKJ1dLytMSrMr4ga+T1fAy3eWgzR1A8efgAk293vzNg47ZRSw3e5qa9peFEb2k9V3Pm564O39X9kKueOV+Bm8chzwYueeGCa4wPfADDIX7KBimk4/yQETZkz1+niefCUxuTvri2521I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779471301; c=relaxed/simple; bh=cH/vi4c8e9fDOBqvI7+SV2PjOZw924CqDzv5Ovri42Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oH8SlBuyduV3B3Ju1MJklZJgj6fOc1AZfiCdjYc5qAELGv1bHfQdroB0fOGQWW0iJWLNFRnOjSlZS5w2xilVzdM+S84L4v61cu4f5LWc0JNoRFGyTYLIeIdPdbcqW4ZuLyDCYFlRuG7+RKI7+RlmIXN4JVadbBaUwOuy9/oPbbg= 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=GonL8aot; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=jmcEZnXQ; 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="GonL8aot"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="jmcEZnXQ" 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 64MC8kbW778735 for ; Fri, 22 May 2026 17:34:58 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=7DkVqoNUSYo eBkjLEkY9jVmN2ecujeJJRqwKEcFSezk=; b=GonL8aotiu22+EUFgM42vZ2GtwE IAaBnUG3JiROkT3W51up7M7JratwBqsl4uUQ3MkUXbqQx30m0RAIvUylfqLHe4vH TXEIP1cIuTWLBy48Qw1KvvT6AUMm8GwK81T4tCWvvt5488VxWLaTmpfmC1q5fO8x oZvKEZHvU4RkpZtcmAVJWhNZsd4L1++fIrWef+aLBvo2oxBCzs71nsdhVF+fHyDR LbWCnIDrnBbTkic/COLjAW3dBkU+P/xZkDO9O4vPLgC9aGI72oZXE3tBm5k+zi0T ayZARX1UCCkQ6EI73JKbo1Sgty2AO29uIe12b9DCZtjZMVub2WTiIP3rCSA== 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 4eac7auy1b-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 22 May 2026 17:34:58 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-36629e48023so7196435a91.2 for ; Fri, 22 May 2026 10:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779471297; x=1780076097; 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=7DkVqoNUSYoeBkjLEkY9jVmN2ecujeJJRqwKEcFSezk=; b=jmcEZnXQheRoBbip+C9BhpJtwiSpkeqVBhneNoneIiBpZ/3oiVF6B4Qb6gWGseXN4S Hg70i2edHq2Tlr5ehrGXHjIH39MX4iI5xNtKQZVwA/iDAzWYZS6Bw0bVNye012g5VOBL ThtsFaqgcVrxi1GdvdC7Q1j1E1G4Q1r+6NfC02DePnBg2rQRMKjV2/ELWvrNvM7JT+kn cmt5Z58z1ms++T9YmnyfV5QcJfshb3JAJjo6k1iHatDggkh3B4ObYXw9q8NZbDSjeVaX De5NkjEgf9X1/0rKek61myTLqTVHxfTA1eWlLX0OSQA20eb7egSDy0OGFH+k6xjIjtpW pdDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779471297; x=1780076097; 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=7DkVqoNUSYoeBkjLEkY9jVmN2ecujeJJRqwKEcFSezk=; b=gcVJNw5vvefLPHWbnu0cChteyyc11tOC0joTZeq9essbF+7PuOc8L5rcuv7U+uqLYu 3GjdM/gxvD54wJMz4MqkFj+kQWD8wGx6ByUP50Nj9eSga89L6gKEnDcyrDgAsn87zZnV yt2eHNbxDCrHtsBPcmhbzPk1XQ7dyyOj0QayQHJhJo3GK3TP4Dsxat+lgHy9GDCwrJlG VAOMohu7iTArUivouboE3029u0kXJKpLTqBYJFBnJypI7LtFIOyP/p9eBWhBKT2yQSE6 mX3yysF2TBfW1Q5SrTVQvaY1orcgLFfVXSBwOPYFJPtM040izidnaQUn/g6x0N4TPv9c MLNg== X-Forwarded-Encrypted: i=1; AFNElJ9cdazMR/XNXjQ+bp9eXEPwF8MLCWbRdIcKxL5vAsw43gSUqnIXg4S8fjyHGKFhLepVpEVA2j2v40BfFNM=@vger.kernel.org X-Gm-Message-State: AOJu0YyvKShWBYqGNyZzi2NhwGrUfcda/1M2snCDOTAY6NsJmRbe9wAX F8YsAsy4p2zW3nvUQk+HNGoBJEeOQfsSbZ83+pgX3HViLDSnoOm1nE+2qEhaEIT3i2vFdpBjpFg C23PjP12DkW9iBo6cHwKvYXJqsK5G3yYTZAPgCBI1p9TFMn90OgRgx7wVM3EDINmliaA= X-Gm-Gg: Acq92OHmnPtLZ8CMmF6U4ITnUuxUo2Edcj+Vxf4y76+G1zBpLFbr0VKjb+otgNqfTVZ anzDslFPPqji0t9if9pBGe/shoZx2iosVRyVGaHYaELt347TMgyBx3SzUEMKa9M5qfF8Uz6TJhy MmETMi9GCuGKrQreNBdnS6NyC541QKxoTvBbOr4Dy7KFn1Ly1k6lu0QEwYeWnsAt2pYgRY8PS9B ZQheollDEaH8+W9umZdDJvvtW4PiOKmcjSW/QhxcIZdjCsIqekXbwSIYqLFygikvX8q1DHqSLqn Mb6wEIFkU8DKoEk0WIYQ0U2UdvqxHsC97Z5PG+J1h86iQ5RPCf9DF1WFH5Qr4QWLcavt/tUuMeR p1vOUlk0gvGHeusl0bSHUz5O6F8LY1OaW X-Received: by 2002:a17:90b:5208:b0:35d:a5cb:95c1 with SMTP id 98e67ed59e1d1-36a676287b9mr4361139a91.23.1779471297061; Fri, 22 May 2026 10:34:57 -0700 (PDT) X-Received: by 2002:a17:90b:5208:b0:35d:a5cb:95c1 with SMTP id 98e67ed59e1d1-36a676287b9mr4361108a91.23.1779471296574; Fri, 22 May 2026 10:34:56 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-36a721c7b92sm2318481a91.12.2026.05.22.10.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 10:34:56 -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 , Anna Maniscalco , 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 v9 11/16] drm/msm/a6xx+: Add support to configure perfcntrs Date: Fri, 22 May 2026 10:32:57 -0700 Message-ID: <20260522173349.55491-12-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260522173349.55491-1-robin.clark@oss.qualcomm.com> References: <20260522173349.55491-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: 8bit X-Proofpoint-ORIG-GUID: CwlOquJn0FiehhM0wiTvB5wZQ7ErbGoH X-Authority-Analysis: v=2.4 cv=JrbBas4C c=1 sm=1 tr=0 ts=6a1093c2 cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=rJkE3RaqiGZ5pbrm-msn:22 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=F-OJb-hlSlUoWALVX24A:9 a=rl5im9kqc5Lf4LNbBjHf:22 X-Proofpoint-GUID: CwlOquJn0FiehhM0wiTvB5wZQ7ErbGoH X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIyMDE3NSBTYWx0ZWRfX9SHA9cdLf5DP VDSNZ1UDchq8AMoZyOVz/AswVqH1G53ZhsvZUVEVUx+PcbRdOk1Up0okWTRwZe6tNymIIDXRN8T NV9iRQRZJ5SD4GpEBEVpYzVhav5a1rw4mlwL+AcoolDk+zUkX6wNiSo3Jhht603IdXf7jEWFQP1 uYOR99zFeXpS3wnpKcnODBapJvWul8yJqFw+VXw2IMC7UXtVozfKbMNdfseL/jduZAvY7pJ0JW3 qKPLdpSpJWj8NHHp83qrh1f4ycvF60UtGiv89a66+sxaN6SV5KMOmSQuUUbGGiGACT0aGx2mE7g i+vsyar3Ewb65KG5bN7J6JrLSMYcjB0C3waduv6WrBCPn+XeSXMqvoTDDIT9VZPnFGx3KtWQ9p5 G0Ri4jHXDgcUDHuMBnYg2n7KXizyVqmkfHQKbUUM6g15QlyDTG5oTfANwYIvBJ/8su91tt6GVC7 ZkIBxKA7OhPqGSrl/yA== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-05-22_04,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 impostorscore=0 suspectscore=0 clxscore=1015 adultscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 phishscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605220175 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 Reviewed-by: Anna Maniscalco Reviewed-by: Akhil P Oommen --- 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/adreno/a6xx_gpu.c index 415902f6e5d7..30df9bfa9ef8 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -2535,6 +2535,71 @@ static bool a6xx_progress(struct msm_gpu *gpu, struct msm_ringbuffer *ring) return progress; } +static void +a6xx_perfcntr_configure(struct msm_gpu *gpu, struct msm_ringbuffer *ring, + const struct msm_perfcntr_stream *stream) +{ + enum adreno_pipe pipe = PIPE_NONE; + + for (unsigned i = 0; i < stream->nr_groups; i++) { + unsigned group_idx = msm_perfcntr_group_idx(stream, i); + unsigned base = msm_perfcntr_counter_base(stream, group_idx); + + const struct msm_perfcntr_group *group = + &gpu->perfcntr_groups[group_idx]; + + struct msm_perfcntr_group_state *group_state = + gpu->perfcntrs->groups[group_idx]; + + if (group->pipe != pipe) { + pipe = group->pipe; + + OUT_PKT7(ring, CP_THREAD_CONTROL, 1); + + if (pipe == PIPE_BR) { + OUT_RING(ring, CP_SET_THREAD_BR); + } else if (pipe == PIPE_BV) { + OUT_RING(ring, CP_SET_THREAD_BV); + } else { + OUT_RING(ring, CP_SET_THREAD_BOTH); + } + } + + const struct msm_perfcntr_counter *counter = &group->counters[base]; + unsigned nr = group_state->allocated_counters; + OUT_PKT4(ring, counter->select_reg, nr); + for (unsigned c = 0; c < nr; c++) + OUT_RING(ring, group_state->countables[c]); + + for (unsigned s = 0; s < ARRAY_SIZE(counter->slice_select_regs); s++) { + if (!counter->slice_select_regs[s]) + break; + + OUT_PKT4(ring, counter->slice_select_regs[s], nr); + for (unsigned c = 0; c < nr; c++) + OUT_RING(ring, group_state->countables[c]); + } + } + + if (pipe != 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 = { .get_rptr = a6xx_get_rptr, .progress = a6xx_progress, .sysprof_setup = a6xx_gmu_sysprof_setup, + .perfcntr_configure = a6xx_perfcntr_configure, }, .init = a6xx_gpu_init, .get_timestamp = a6xx_gmu_get_timestamp, @@ -2786,6 +2852,7 @@ const struct adreno_gpu_funcs a6xx_gmuwrapper_funcs = { .create_private_vm = a6xx_create_private_vm, .get_rptr = a6xx_get_rptr, .progress = a6xx_progress, + .perfcntr_configure = a6xx_perfcntr_configure, }, .init = a6xx_gpu_init, .get_timestamp = a6xx_get_timestamp, @@ -2822,6 +2889,7 @@ const struct adreno_gpu_funcs a7xx_gpu_funcs = { .get_rptr = a6xx_get_rptr, .progress = a6xx_progress, .sysprof_setup = a6xx_gmu_sysprof_setup, + .perfcntr_configure = a6xx_perfcntr_configure, }, .init = a6xx_gpu_init, .get_timestamp = a6xx_gmu_get_timestamp, @@ -2852,6 +2920,7 @@ const struct adreno_gpu_funcs a8xx_gpu_funcs = { .get_rptr = a6xx_get_rptr, .progress = a8xx_progress, .sysprof_setup = a6xx_gmu_sysprof_setup, + .perfcntr_configure = a6xx_perfcntr_configure, }, .init = a6xx_gpu_init, .get_timestamp = a8xx_gmu_get_timestamp, diff --git a/drivers/gpu/drm/msm/msm_perfcntr.h b/drivers/gpu/drm/msm/msm_perfcntr.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; + /** @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; }; struct msm_cp_state { -- 2.54.0