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 3B38E4ADD89 for ; Wed, 6 May 2026 17:12:09 +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=1778087537; cv=none; b=nhgPVSmA87xqyQRc/HuVHzH8n7csT/yrsQNfbRETxXsBeX2AaGUwQi8kF4E1BcSS++chORzSFjddGEH6l2elzYFgBnyBLszW/Rng4HsFfbM97rSHhd2uuKvb1BdJkKkU6cDj3dY8HsUzy9BB67XQm+/3cW8JEILBgTUwQSmvHu8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778087537; c=relaxed/simple; bh=XZmlmpKq9dT2OjVxZaCDZBHXjS0SdHaDhZM+xjSaQsI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EbdMtFR8L0d6NrzmftAHlyhgz87RKCHV94RuA/39TGc4m9wZIq/a2M9EiKEl1W3BPbScQVjvaqFGLz6o8FLjw6Dy2lAyFwJYwK/DtWyboyp6Owz0Yi0uOx6bJy+8EE9jh3RUKsNCdAHMRORVcS0KbKA5PlSlhpATCB4aO0DWS80= 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=fGYgwlgH; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=H6e3Qhrj; 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="fGYgwlgH"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="H6e3Qhrj" 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 646FcEkR443091 for ; Wed, 6 May 2026 17:12:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=Z+T7DF6d3yj uRFH4Z9NZjry6qzE7sW/NwEF2nzuN/uA=; b=fGYgwlgHu8M6zy37qKRjo7HNpRk aHr4OyhlJBEgpMbEvAZG2O3D9ECWnIhJ5LOgQBhcde3MFYtrV6VcpNPnyjnedE6Z F721tO1VaaF4aUHASVSmuZ+c8FaJ1CEaaiIG+mbI0gCsWQey+C/nprsfpsncJs6m 9tUjp7FpJWwpQGTlN7ByoW4KxQgwxg0ersdqdPwboe4wS06KBlXWW4B4J7ebVrPY AHij2hWX6EWhw+77jrmYhXdCTwopMJO0MEdaVTc6YDC8/UZ97GdgvoxF1lTv2oeU OZDJ66bxwu2+8DogI3sMrX1uvLRXz7i8Vq6LSC+xNh+glRaPhf0ABnQ9TVA== Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4e0299hxfw-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 06 May 2026 17:12:04 +0000 (GMT) Received: by mail-pg1-f197.google.com with SMTP id 41be03b00d2f7-c81086bf930so622988a12.1 for ; Wed, 06 May 2026 10:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1778087523; x=1778692323; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Z+T7DF6d3yjuRFH4Z9NZjry6qzE7sW/NwEF2nzuN/uA=; b=H6e3QhrjQXvBQo9Q0ghSz3kL68N0zn5vaS4lYHJk6I9anrA93VtW90rFrIQ0C/IoDx fwz3KfSPm2X97IUh31K5OE9EF62sW8fLgrwitzVa314prdI7865I1vF8hISN3Lnyso2G zbAHZwmwxubeFAOW6YVCWLk5CVnuLPEVCN95KxRi5eZHWGDHuQomdE/rLi5TASMinB0d MhXeEo0PskYcpT0Qfg6wbDp9bZIfUVFe45dBI0xzJuPQHBferjwPZGhfXi5Bf9sKe88N zbOp4n5MPJWR3pMUw/20s9u4x5tP3cpKXP/l8xKP4IDNvZ1M8w0FLtpvf7YKDia+zWVg ITmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778087523; x=1778692323; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Z+T7DF6d3yjuRFH4Z9NZjry6qzE7sW/NwEF2nzuN/uA=; b=GL1NBIn2EVCxjCYSlRTVeWDAoRyjvmqBrd4Bh4Ctn2agkDnFWriB0kONebs4/uxaE8 P912M4mHJk4aVil+szBvRDlBJbnho3mvTGsy/i5hqszm55l37vllHvudCwd/d+lt91mU uwW3Onlxin4v5Q6Da51GFYr+rWDYDzzYfY3eTlL5ZIDvh5wbAJz6yj9zhIYw3v2ImU1L bwKkPPKbgH0lCkhIhuca3QmuGEffEIERP2TXL6F4r6DcEZVfTIyoRpY/o0r/pnupOpBY dlAt5aoh+Biceka3p2ekV22mGL8Ez6sPufQyQuib+uhG5KvvOqbnppWGX2SnzKaknzC8 r6bg== X-Forwarded-Encrypted: i=1; AFNElJ8Rt5sd13dZ4o+qcyl7YgtHSbqBdgJEJd0VYXQeWwMEXOfVkC30d0qonM0T5o315AQC3EdwLE4FkWdyHrU=@vger.kernel.org X-Gm-Message-State: AOJu0YwZ0qNnEg10US1LkGqDAtOUHtCdz7MvpL8NeVpQi2viCQH/n/08 g55E103JoVSXrPh1GZQ08EFmWs2sbLFMksM8rHjYipaO++6C0kZ4yK+pp4nFS0ELr9MVxKqZRqs V+DzfYDgZfSqveyLh+noawErQJwR43D2Q7FZa0KWucC8FG46jVO+sWYAOAzDhqUe4v3ZZbVqQfq w= X-Gm-Gg: AeBDieu57QCGuXLp+4zOeguOjzBgUd1at858ExaCFnAZTY3Atn18i6HQ57nIUjOFCBB iPMcHpOrbjXwxLnv5xCpvz5bXgzb8VY+Qu9OM6iP6fWYO/aaKLA5xX4RUz1XEvgKAN0mkq8pD5y P0ZSdGJqfSjO9IEUEANXPX1TNbbSqRR1QrRXQqr0tpCpuLf5RSW2BsH9x+ApTeT6LQCKaBMGayI UTX7oyg3yaJrqpDMBopDj5KLSIrtTS3itsf1Ao4uo8XOtNf9sulo+CPcaBMbc6rimQkIlzMg2I+ VZiE4OMxeuhkfV3dZl5S6sf9nFW9bdqVzf3uJ9iSGFfxNPPE67F4/yepREPJoxaEavtYIFff91E g1yWO40g/qjHG+BzR4ko3xPTZ5ti0Ul1kGF2UtZSHJXw= X-Received: by 2002:a05:6a20:2588:b0:3a2:e26b:295c with SMTP id adf61e73a8af0-3aa5a1eef35mr3888826637.18.1778087523232; Wed, 06 May 2026 10:12:03 -0700 (PDT) X-Received: by 2002:a05:6a20:2588:b0:3a2:e26b:295c with SMTP id adf61e73a8af0-3aa5a1eef35mr3888795637.18.1778087522709; Wed, 06 May 2026 10:12:02 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8396563f11csm7592511b3a.3.2026.05.06.10.12.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 May 2026 10: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 , 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 v4 09/16] drm/msm: Add per-context perfcntr state Date: Wed, 6 May 2026 10:10:33 -0700 Message-ID: <20260506171127.133572-10-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260506171127.133572-1-robin.clark@oss.qualcomm.com> References: <20260506171127.133572-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-Authority-Analysis: v=2.4 cv=fMMJG5ae c=1 sm=1 tr=0 ts=69fb7664 cx=c_pps a=rz3CxIlbcmazkYymdCej/Q==:117 a=xqWC_Br6kY4A:10 a=NGcC8JguVDcA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=OtV_UDYxk2hhjaRdRjwA:9 a=bFCP_H2QrGi7Okbo017w:22 X-Proofpoint-ORIG-GUID: Wjwt6IdPdes0Bi4oDlYy9EKPBOS7BBsM X-Proofpoint-GUID: Wjwt6IdPdes0Bi4oDlYy9EKPBOS7BBsM X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTA2MDE2OCBTYWx0ZWRfX2WW8VpOGI8c4 jotTO+Iu14mpki5ST5THkCixHXhSxrwwziXVeX1VsSwkoDG7YU4Z4jqBjdKpfquALKT2RgIt2zw lQ9swZpT3qj+H9MhOuy4/9kKs1BpCwomhxOLaEW3U8LpOj/KyjV2uUoM82VDAljpvp7+frUZRZ5 3jQS5ybxaOXrdQdloK9RoiXnHiKoNT2940dNKTnRA+xYCW3BEL+MzxB8cIo4e9ygyXwrcZRWlEz XXcAJYJLFK3bTGCcJNxL7yxMr7KwyYacyxixW5bd6oUIVJrDujyoMibGpej8IUt9CyHKRbZGJJy rk588i0pNnNociK//gpdriYvVMNskORddUhrqOnDa1YN22PqCzp1aDogHN/gFatMaBbghd7qt9W yri2ZPm/gS5CjVAZkAF962/XCU48CSbRoLrep5d6kCO0OfOdQd7FKkob7cqbQkNkAcBdZDlVyzq 5oNYR0v84Orm5ZZFpYQ== 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-06_01,2026-05-06_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 phishscore=0 priorityscore=1501 suspectscore=0 lowpriorityscore=0 bulkscore=0 impostorscore=0 spamscore=0 malwarescore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2605060168 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; }; struct drm_gpuvm *msm_context_vm(struct drm_device *dev, struct msm_context *ctx); diff --git a/drivers/gpu/drm/msm/msm_perfcntr.h b/drivers/gpu/drm/msm/msm_perfcntr.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; }; +/** + * 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; diff --git a/drivers/gpu/drm/msm/msm_submitqueue.c b/drivers/gpu/drm/msm/msm_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); } -- 2.54.0