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 A43B636728D for ; Fri, 22 May 2026 17:34: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=1779471293; cv=none; b=TqXyRI2A3Q0SZFG3BUacMTK8o6041rDhqJI1yp/PWaoCauMbXb3xx9OyrzIe/th6AMKgyAa15n2fRfylCkCFslC/Lbf2+jXgsy06dLILnmgpfHzu0VbItPmGmW1/OUt0FDDewRnqUSVgpcGMjLW19VNqzgsnLS5kuW7OewcKnWg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779471293; c=relaxed/simple; bh=xk7nfthZ3OSrcQx+cboj2SEN2wdIQMknWbj8sDW9T5M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=moLwUCC0cgaBvJydcfM3y/bp3+RNmhOWL6QUGydVRhBaYC/jSmhxpreUxf+1jHijO7MADQ6UfdjTG9aAPEShmzQeD8JrD3rMZoNKlzfaq4EKDx3Ir3bRC3AhZD+IvcpvxBxjE5k+tGHF88Lf4HUEfapGEz6EvNdYdoGUZb0zWrc= 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=Ygp1pBlg; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=azev32Dn; 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="Ygp1pBlg"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="azev32Dn" 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 64MAmGvD777111 for ; Fri, 22 May 2026 17:34:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=4tfvGKSXQFo neM9FUCAjiWpETYTjQZebXY53uh3TIBc=; b=Ygp1pBlglCbTY35OZ8HllI2EPpu GigFSCGaSdI+LKkVxtHskRLNvYLqpuaVacAJ1bTFJ/4rXqwPD7GYZ+C9WmelEGNf levumOqYgbvyLUkeAvMEgUQW2a/lilXTTXIWoXGfJvEnrl1xofZ/iAwK6bH6HJcs x/6a6NY9N3gIB+Tt1JX0kj4kXbpoY+GexDR9LLkk91aQ1s9E5wFue/Xw9gCh+5hT p0c0eKNuQyCgFG7zHE3cVV0nY5M8dBrQ1ush1cnDP3dyozGGAl7xNXM8a9hCwIiD gAwU7f74o4iTpDwRYw6Bp13W3EvuiPgN6HE11Qq8I941VhMU82XB8ByoB4Q== 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 4ea94h4nt5-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 22 May 2026 17:34:50 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-c8279604464so10525406a12.1 for ; Fri, 22 May 2026 10:34:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779471289; x=1780076089; 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=4tfvGKSXQFoneM9FUCAjiWpETYTjQZebXY53uh3TIBc=; b=azev32Dn1dGqfufgERlTvMJEKiV0rANcu3CaXqALjW2TdyaJKf7Ci8ARg6eXF0k8fl 8wxE5hOOJgOXS4GNAmwB6yCoxjJ75Dts8e0eUckNQHTQns/6RtlperGu5cVkwQOs1ncJ TWznBGN6/hNAaPC4HedUBcsWZJl0ZKRZCzRLiBIJdHFawXGq+ZNWgDv8H3C3gKL5UKFv k4HQL7oqukKSJsUE/yUhAkd01WZztUbMQKOb4D+gitaF6pofEbumvFGLHDqBA49GDt7P yaIfd02CYRUvtdLqCN1KZ0EFJdkzuCx4Nxq9h99KjG/zjgLNNFSJ9SQzbq2qZDm6X9C+ 6uNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779471289; x=1780076089; 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=4tfvGKSXQFoneM9FUCAjiWpETYTjQZebXY53uh3TIBc=; b=W4L0KW0NiKoUM6wVRsQWi6Z/Evas9Io3Ffl5gvYtEP7udWEcaGlI8pBr0xpfR9Iu56 WNR9nBbtT/JuIXbu4WTAzKty/pay3eaMql/26SLp+N2rwkcNcnQvzOkwxr/7mmq5+jgv y2bWVtxp/w9cQtFLFSTJU0GVYLRsH4wPOzvwOyXsMner61zNjtOLGFwtZqS5f3//OPbZ pT9N9B655naXaVc2PP9NG29GgKp6vrpakTDPpw33Q3OHrZl9D4iLzqGg3jDMmDfoHW5H xM76+T/6/eKY5e0k6epyqHgtmOn1KlWBvqdGqLD+WJLG+autR15hvwaq1IaZO/+oXfeP WbSw== X-Forwarded-Encrypted: i=1; AFNElJ9jTNT9SKyjzCCsGF6gkTH6rUHblgQ9vEdP5xCYdYbC3qHEJdaWADmycrMcF8kLLWcmBP37ZCITpIxxgYw=@vger.kernel.org X-Gm-Message-State: AOJu0YxbpF7k6kZYqHSUvUT8tu8Gj8GX57nuepN4z2qjNzREAydUr2a0 fz2o7CdAxu+lOrVCnjZ+L+djnjMLd52TpKUKgm/Re4mRaj9X6kRBZla3oikb+VSGI93hVM3Ko5X 7bT2JpUm7lJ694o/vOZeiR7Lc5trqUY61A7GW3WVBLK8kr+9C+o0wQhYcUomB4I0sCuc= X-Gm-Gg: Acq92OEze3AOhquyOYdQfOTkwigN2g1HT5OkVtgCmPVv6qQktnsgZq05FBq92SfAmyU /UW8kBVfMyJKNMi+KyhzP1Ksd5wKgvseGBxb2/0PeitR+Z8dtur8gGdlPMSsy3uweoXipAmUPhd BE0Nhi9wtQwlMdLHrLEkQKvjsuvXCGRry0cJsVeSWxWnq2eIIlRqQEKen5760aK5EdDQ47f4kc6 9egfwt7/AExSHJv1LT8c+zOO/FBTzjV8rELltJSDTVN7eymLmwiTZTfVeE8h1kh7NP3c5mvLgF7 w0FQtqOaKMOqiZkPZ2RGJHA008pdsMjk9R9VQsd+7F4hZKT8sdXu2avZohl076Ln5AGejumQJDB 8faS2I1GKeTCElpvw0Tp8FFqqW05jywUJ X-Received: by 2002:a05:6a00:f8a:b0:83a:4846:90bf with SMTP id d2e1a72fcca58-8415f3a13c9mr5033265b3a.43.1779471289305; Fri, 22 May 2026 10:34:49 -0700 (PDT) X-Received: by 2002:a05:6a00:f8a:b0:83a:4846:90bf with SMTP id d2e1a72fcca58-8415f3a13c9mr5033232b3a.43.1779471288673; Fri, 22 May 2026 10:34:48 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84164e9e7a5sm3238713b3a.33.2026.05.22.10.34.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2026 10:34:47 -0700 (PDT) From: Rob Clark To: dri-devel@lists.freedesktop.org Cc: linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, Akhil P Oommen , Rob Clark , 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 07/16] drm/msm: Add sysprof accessors Date: Fri, 22 May 2026 10:32:53 -0700 Message-ID: <20260522173349.55491-8-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-GUID: 7jnJ39UGRMIcEYYIcw-BCAi0RZDakZ_g X-Authority-Analysis: v=2.4 cv=QblWeMbv c=1 sm=1 tr=0 ts=6a1093ba cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=pGLkceISAAAA:8 a=v4b4B-quZFKF0PxyZCUA:9 a=x9snwWr2DeNwDh03kgHS:22 X-Proofpoint-ORIG-GUID: 7jnJ39UGRMIcEYYIcw-BCAi0RZDakZ_g X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTIyMDE3NSBTYWx0ZWRfX6o2XiJqm+eaR A2wLNL7hSdqB5dJrZNBHwUQsALyP14FbMgMiKiLjGuaNCoVhvo0gkBMOU14hYAUgFnNA9uT9OPg AyMGEd+hUGPY9D5ik6rSHursjXERqQYhtkIsL6F90Ll2h2bxi3zCw3o+PRuqN7spO0WpsyNEUMH 9L7Z/70+q/iUBKgr9FDznDY+TMOaC+NUZp0HxGF4j5G61NoaYST4dmvLiWxZoocFx3SlP8ydBNq JScU5XSS/voNPQKVfSTohhBKel5DVnhd2NnytJr5SKgK9VqGQaGQn6DPp1DZ75sIdwyf1ciub7X jiK5l5UAD0a1SBkfjDRr2TmRoPoR36eIGNo0iFYIeR3MxmhLc/7/jYv2NXRZ+wC/5dcd0p9G6PM DV/Dh6ml9LDAv8PfizwtjWNE5bpj+GcH0A5DRspu9gWLN/yldbNMOzEZNdsASk5jSMb48iRBjVG GIIm79VNUG2eAVdrzkQ== 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 bulkscore=0 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 suspectscore=0 adultscore=0 clxscore=1015 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605220175 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 Reviewed-by: Anna Maniscalco Reviewed-by: Akhil P Oommen --- 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/adreno/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, struct platform_device *pdev, void a6xx_gmu_sysprof_setup(struct msm_gpu *gpu) { + bool sysprof = msm_gpu_sysprof_no_ifpc(gpu); struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu); struct a6xx_gmu *gmu = &a6xx_gpu->gmu; - unsigned int sysprof_active; /* Nothing to do if GPU is suspended. We will handle this during GMU resume */ if (!pm_runtime_get_if_active(&gpu->pdev->dev)) @@ -2047,15 +2047,13 @@ void a6xx_gmu_sysprof_setup(struct msm_gpu *gpu) mutex_lock(&gmu->lock); - sysprof_active = 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 sysprof is active */ - if ((sysprof_active > 1) && !test_and_set_bit(GMU_STATUS_OOB_PERF_SET, &gmu->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 == 1) && test_and_clear_bit(GMU_STATUS_OOB_PERF_SET, &gmu->status)) + else if (!sysprof && test_and_clear_bit(GMU_STATUS_OOB_PERF_SET, &gmu->status)) a6xx_gmu_clear_oob(gmu, GMU_OOB_PERFCOUNTER_SET); mutex_unlock(&gmu->lock); diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/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 *ring, u32 counter, static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu, struct msm_ringbuffer *ring, struct msm_gem_submit *submit) { - bool sysprof = refcount_read(&a6xx_gpu->base.base.sysprof_active) > 1; + bool sysprof = msm_gpu_sysprof_no_perfcntr_zap(&a6xx_gpu->base.base); struct msm_context *ctx = submit->queue->ctx; struct drm_gpuvm *vm = msm_context_vm(submit->dev, ctx); struct adreno_gpu *adreno_gpu = &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); } - if (!ret && (refcount_read(&gpu->sysprof_active) > 1)) { + if (!ret && msm_gpu_sysprof_no_ifpc(gpu)) { ret = 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 = { .create_private_vm = a6xx_create_private_vm, .get_rptr = a6xx_get_rptr, .progress = a8xx_progress, + .sysprof_setup = a6xx_gmu_sysprof_setup, }, .init = a6xx_gpu_init, .get_timestamp = a8xx_gmu_get_timestamp, diff --git a/drivers/gpu/drm/msm/adreno/a6xx_preempt.c b/drivers/gpu/drm/msm/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)); /* Enable or disable postamble as needed */ - sysprof = refcount_read(&a6xx_gpu->base.base.sysprof_active) > 1; + sysprof = msm_gpu_sysprof_no_perfcntr_zap(gpu); 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/adreno/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); - if (!ret && (refcount_read(&gpu->sysprof_active) > 1)) { + if (!ret && msm_gpu_sysprof_no_perfcntr_zap(gpu)) { ret = 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/msm/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)); /* Enable or disable postamble as needed */ - sysprof = refcount_read(&a6xx_gpu->base.base.sysprof_active) > 1; + sysprof = msm_gpu_sysprof_no_perfcntr_zap(gpu); 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; } +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 -- 2.54.0