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 2C2193D1712 for ; Mon, 20 Apr 2026 22:27: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=1776724049; cv=none; b=Wjdzo4zRM1PSIVWR07eomXFZxQ1WVHNha7gT07iibedHDnn2Jp7a8rJ2Hrntl+q5Hsq/BaJMOMmRIsOVk2etrBLMPRomghOFrrifNGPCWCTYnE6n4i3qzKNBp73+PYlTJCb8IWAoe1GVuEOVEdzHPbUCqd/4bd5z4hIMTeu53t4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776724049; c=relaxed/simple; bh=OU61gQcrvFhBpxR2VKmPdnQYmEtAs3K5eYLJAXFzXTg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=H7HLGao+b5nBbt+Bkz0sPoRHPjC81Q+soxnfT6B18X80Vwzy4r2fbzWd+EfNgbk7KeET8aK4xGygD992VCnMTFb9Bwu3Vp4mS+k0/vlozKuKNpyx+R+Kb4sqIHFRA726YuHyA6P+SKxb1TEbsEE5llDDaINo0EWPRxFTkgEO44w= 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=hyOAyhUB; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=RjAc8PPI; 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="hyOAyhUB"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="RjAc8PPI" 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 63KFdqTP1600322 for ; Mon, 20 Apr 2026 22:27:27 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=2/Y0xU0H+zu dioSG94bHnT6saitjlexOXZQ/Yt0BEtY=; b=hyOAyhUB2I5hIXIWDBpOrfwKeVM 3eZSwH7LZTTUJR5YGyr287ZCBRCKK1NuP5As0WbHvs2BcBEDANOnDeZG2Kpnz0ug QPPiR2dLeqceTK9JyfsU2PwnHJabvC65w7Sw0nMc9YSe0p7ysVbHapPpSemvAKjg 7L8yWedjpEBUKrBkCF4WkD+GHqiLBZdGSl6iXAtJE9ZI03wDlLEY3XijPlB3SsiY 6N8LXJ0rcjLEwe6cRgh8j3S7eeocmy2DFRSaRjWh2OuFdmzXe1J6mR2a6dlE1qDC /4zzGpVtHFWKWz6kdSDguKTrB8J0ROXlYAKTC/dUO/fBZgoG8ujlN8nL8PQ== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dnh89arnp-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 20 Apr 2026 22:27:26 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2b2d0c1ead1so69404275ad.0 for ; Mon, 20 Apr 2026 15:27:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1776724046; x=1777328846; 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=2/Y0xU0H+zudioSG94bHnT6saitjlexOXZQ/Yt0BEtY=; b=RjAc8PPIir1RjepbDEe5lHKlZGGCi9lOwYv8CK/ddooYlr1J78zo51cxmLUw/QH+hT YI9VG26S+NCfSTp+ay3UCkHlcRaJY6OLuK8g3hjgDLcQ+h9FUQ9Z4tIbEwjzwUQMrY7P bcAzfwjtfhs2ubFJB4BPj9c2Q7P1+caIASpQWZG2Q+MF93OlVyrqSnrJQQoFL7Dl7Wyy D+j2g4P2XpUcUl2NRddnaoB2xTJ5sx7FUhpNtEHj6ho+lw3eGJxcS7y+eA8a7eTlcbyd lftiMmZu2ayCrdh7PtFy5CMdG8/V2G9DRGeIzuQ2KSmQDn0i4mrpIkrcR/DaHpAOPlyi qN+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776724046; x=1777328846; 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=2/Y0xU0H+zudioSG94bHnT6saitjlexOXZQ/Yt0BEtY=; b=Q/fvxLuaWMDUOsY7vYcdRhEJxRm3goVC3gJD1e5QK8+o92AaXoaBCC3LVyvV/lPSIF NNByk1D0DZ+4GiTPNItYfzuW6ZSno5/lDgkREhRXnGfwgw0u7JfZExf8Kl3k/2LI8eBz +UR7Hq9MMwaSacvILctry1TuMR8Ob8s7qAMw9Onks7dij7nznRFl8jN60Dz5lLII+5Vj 6/s2m0jMPsE6QbInlXUlFHHLAhFUXgJXRifbq2Z4BiECL8qvLK2x4yXWwVlS8vrxYGf/ pAJQYCSVCRBra7AROb+Yz0lZ1lsWp16CuiH70GLdnvSKrzxOyq5SLgUbbTwITBd4YvAx EYIg== X-Forwarded-Encrypted: i=1; AFNElJ+cq2vg6+EWCYe5VzJtoRP25uW7VQ3q/+TNZAKXFijqZqM2HbXftnRijZyFdUz9JQ0tkGp6PZNNuhFCeNM=@vger.kernel.org X-Gm-Message-State: AOJu0Yz/nMJi31g81EjnnC1mYsmxJE3MYO2wDXmohEahcxJSYjMQR3Yz O2vKJ4TQv1bvm7xZrDBQN7m+e2KXv5F1xbB0wRclUoe+bVUq92c80GqrdkRZjAlnTgUCPHf5e7Y KwXJfrKv8rtppFw75wcOCSwzW0GaXCCPC8jxFlJtA9Lcm6i2bYN6qgZcxny6tJ69cKF0= X-Gm-Gg: AeBDieseCjAhLv+mMxnjqt+xkr95r4+tkfPMERMD2bdUHwqz7SakV1Qm5jbxOgl05xH sWsU5O5hfjfXxviuYJHO/Hb+e51s5eebmAi7szHqbmcpcXiHJA/ANl0j1FpSIUbq++v6GrWG1dT R6LrPJSj3OX0OVAdNgK75Vbju3YMpkIQ0JDSmrkO22WEg14zSUc3ZYq9iPizvC/ZS2jew0GGjpj Xj4Tf9h/HSd4TNE2X0kKPpDtVjmgAEHF0bas76zPyUdiTiv3ysbgfY0grJHS847aYGKRuh9wdpZ QwG1WdnctB4pOV3uwEtP7mg32rEpw3j4cuxC/j+cpXvMQaT+IiWOfGvfAz428afTXErPaSMKFeW optZvSJpJrX2scMnd3FHAWWTVEiunzC9W7Uv/kpGQxK0= X-Received: by 2002:a17:902:7c09:b0:2b2:81aa:f6ba with SMTP id d9443c01a7336-2b5f9f4e801mr119262585ad.26.1776724046030; Mon, 20 Apr 2026 15:27:26 -0700 (PDT) X-Received: by 2002:a17:902:7c09:b0:2b2:81aa:f6ba with SMTP id d9443c01a7336-2b5f9f4e801mr119262375ad.26.1776724045505; Mon, 20 Apr 2026 15:27:25 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b5fa9ff39csm115725225ad.4.2026.04.20.15.27.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2026 15:27:24 -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 11/13] drm/msm/a6xx+: Add support to configure perfcntrs Date: Mon, 20 Apr 2026 15:25:33 -0700 Message-ID: <20260420222621.417276-12-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260420222621.417276-1-robin.clark@oss.qualcomm.com> References: <20260420222621.417276-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-Spam-Details-Enc: AW1haW4tMjYwNDIwMDIyMCBTYWx0ZWRfXzdQibTCLw2in pCnyK9J+ldViKa2gp4BAZrgQZwbPwJsuhO//x52TJFCIkhtyAtipM3R0jHRqre/zz32wK/FidbX 7j+/lH1XGTaUQMrj8vcefG/Xq3qZwrbztYmLiN4bhYGrivZc6O562qRbh4QjUV1hbjs2xeytpSk Arbcg9PZt6HVrz4omZhuPO0bfFjYCm9EFo/lSPtjEvA/JnfS7AsM9lU/jJsEWcYRjbKhFMhkPHN ofM9BCEhL4E57n30zVj94eeeerdmJ8a7D0U//7cjh8h7lzFYA4q80GfTXobA7kHSKTYmUZLy7od I85OSXGROdftpVVZ1dVmAmwFf3OGLTRAEc8WBqS/D8QXZyKixA9wg/qZkzSOMJB1ZOYb8eJ07bP sYXFxG0aPJUXFTrtR/cNy20MlUNIhLhpG3C4sgXpK7bQfyT24TT+Ni2WN4be5Oa/DIWogq+9MiC 922jAkepVKUZhiwSe2A== X-Authority-Analysis: v=2.4 cv=D6B37PRj c=1 sm=1 tr=0 ts=69e6a84f cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==: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=cYDoD9QTrnOhnChb1ZIA:9 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-ORIG-GUID: gAHpb5G1giy6J6sIDVhT8bxUX9SjkOz7 X-Proofpoint-GUID: gAHpb5G1giy6J6sIDVhT8bxUX9SjkOz7 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-20_04,2026-04-20_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 malwarescore=0 suspectscore=0 priorityscore=1501 impostorscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604070000 definitions=main-2604200220 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 | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c index 415902f6e5d7..0149eba403e4 100644 --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c @@ -2535,6 +2535,68 @@ 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; 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 = 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); + } + + 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); + + a6xx_idle(gpu, ring); +} + static u32 fuse_to_supp_hw(const struct adreno_info *info, u32 fuse) { if (!info->speedbins) @@ -2753,6 +2815,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 +2849,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 +2886,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 +2917,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, -- 2.53.0