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 55204391855 for ; Mon, 18 May 2026 19:08:22 +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=1779131304; cv=none; b=MsdXDmNdMhl2v/d9cutx9u6RJkAOFsyJnYoS1awDtZRPSuf9yN/w+2+YcoMdBQi3kiIV4tw/tPM7DX4qSKn1W4xuv87TYQAxF854Tik9sJTPah6/gE2RAGzAFlSPQM+2LC7EntJ5x47+/83OMYWKUEW1abtn/y3NNpMXO72gl+c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779131304; c=relaxed/simple; bh=KLqRNWMiv1tFIGsviuSyaJygsw/Xhbs5/vugY6rjZSw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FkQv4qvbtLBchWzCVtABfCWNHqWYlGvEkrYyVnHe/9QcNKPzUHOk2+dFTVhvoIxp4YOWNvxqUCSDOxe88t5VrHqFxhqlMwsiKFok4c3tqUNbdcBbJqLCPq1dVrKgCXc+AVMq8YVRqtI8RP1/jQDaL9rjppm5a27KLt37wdTcTqs= 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=AJZkPGKG; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=RHAfgxl+; 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="AJZkPGKG"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="RHAfgxl+" 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 64II0Zln2083066 for ; Mon, 18 May 2026 19:08:21 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=tpSYknoSjgu xLp2PhcNLzFD+hJIyTtn62dCNb7J3rZw=; b=AJZkPGKGiC8DJki6mgucSqNhEId RzGSP8+nUyNVlJprxIPm6Sez9DJRUFxtp+ltFxJ9q6V0U+TyE/VA1hcxpUpP+oF/ jh1LN+LyYrTos6yxJFztAmWA24Cu3Gfi7mdPftcbdpVyo5+22wdhYpLLnTfz+Ykm GWIBJATj/Mw2Is2bR2Iwi8EEewidWqqhVdIf9AmRudwhqQGRN3gacW8Y5n60ixcm D0gWkQf678LxT+JfwSKFVM/Wm0WMH3LJoHVGcqO98LEzSHqECkeTL277A8Vsg3xv lNz0YBesEdPnyT8Zp8GCKSvn10av6b7/0/nGWuR8P29HKkixIVUrpcpPpbg== 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 4e81ch9xbn-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 18 May 2026 19:08:21 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2bdaf8567f3so16174285ad.1 for ; Mon, 18 May 2026 12:08:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1779131300; x=1779736100; 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=tpSYknoSjguxLp2PhcNLzFD+hJIyTtn62dCNb7J3rZw=; b=RHAfgxl+hkTTP42u+6gz2Jg/WaJlsjpnW2P/d8EK58LQFbb3vqFasfIvAuKxnyacwV DDUCbO6vFaaYQpxAYhtCljJRXA74F6yIgCX9UcqPvPyEGQ6nUqTqrV35BzKpkr5CEld7 oAu44CMNvfIfzX0iuyqEUYdf+1AIb6fNr/qK3/2r/MZ2LG1Bel7+6RQ6XJkmJ+zkVrTT FE0rmB5n3sPIq4saSpc6YbuVjEYyyqtWr1F9hNhLbV6q18WKQpllN7tQXUm9HwTNqIAx R/Er5fBdixXYU+eCgMdKvq4Fj5Ap99mnNfZ60j0aOuT4M5i+fdEnBR11JOoPXDFunBRX QIsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1779131300; x=1779736100; 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=tpSYknoSjguxLp2PhcNLzFD+hJIyTtn62dCNb7J3rZw=; b=F1WUY/0CCpvVLUSza5XB9XXLBUkaOJOK4ec0JSa45teoI5ARLa8hu/m29YaGK8azWa /2GnWt9EkUUrjnPuMSU9zPbonfD1uT6rQierWj3aqCZEJmPWvSddw29461ptURbIaHRM 8uiDCjYyP+sNFXQ8tEWFVGyZm4Hi3cnrstofDpO65zcyqrGxSS0kGSCx0N8uSuaZqUiU kg8N+J54JsQmA6h2Tcsrh6DZbTxSxWillvXUxwnwfMlj6h9wxkp1Q3LMGPmjaDnp7PWi qTN0D3w7yW7VtJD7JX5tCFevPl5o/tjU0Mw36FRUeNIWUImvj76yszQ9/WYFN4Q9GkaB UQOQ== X-Forwarded-Encrypted: i=1; AFNElJ/qtivhz+CI248NaybuC3CMRj7VMB4WzzSjtauDBq/RnvxmNbRYazMqo3du74QuE1sf30BLWa+9l1wqiyI=@vger.kernel.org X-Gm-Message-State: AOJu0YwO5r6B6ZIYTjIWD67E0YL1aqna8NxsNu8denrsCQrQ/+SsEld5 KUD/9ovjXYuzd5dW7gHWOpXhC+b3xrsHzqoRMGnB5PVtOVbkumn63LsatHxgR0N8b5CTXx4gkdm s0FPf9OOJTLwRizs5SJPcHzYI3n1P1nKVJMmcjSOfmX+dSovWfCOBVdOGm6RPKnBC1Z4= X-Gm-Gg: Acq92OHPIyvQzfX0usuxQshHruyRp/4oEnCFUNLxIkR2tD5A7uD7EfVd+a46Ss+2+OJ Zbspb6b/Yil5bvDg+3DU0NafUC8MzoIjQxwCz2myUZrphD2eTEmomuLoMJPLnYCKkHTwLDXf13v C4BcOZMlcTMGX0XrZcNOMpLIitJhGnHkTr3M6B3QRAQl1RCuOCGGudcpIMQHcn3UVIxeHAq66l3 v4fXLH5Pn6w1NRF4KoTb66R1D8pfBt3KjYFkiDd9TvLRHSmm2LcP74ulJRv/K0bOSKPPIMP0Yrs J0knksaxJIhuj+cBUUzsJVoSMjQYD/oEpYKuwx9ifWd2n864MQDVZ+A1ssrD0OdUPhqFOr8u2Rc dHiN7v1/IaOE3S5Bj+qB8hzrPaBKNIOx3 X-Received: by 2002:a17:903:1109:b0:2bd:d6f1:3388 with SMTP id d9443c01a7336-2bdd6f13874mr51444165ad.28.1779131300205; Mon, 18 May 2026 12:08:20 -0700 (PDT) X-Received: by 2002:a17:903:1109:b0:2bd:d6f1:3388 with SMTP id d9443c01a7336-2bdd6f13874mr51443945ad.28.1779131299706; Mon, 18 May 2026 12:08:19 -0700 (PDT) Received: from localhost ([2601:1c0:5000:d5c:4ec8:83f5:8254:6891]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c82bb08d06csm14312968a12.14.2026.05.18.12.08.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2026 12:08:19 -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 , 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 v7 09/16] drm/msm: Add per-context perfcntr state Date: Mon, 18 May 2026 12:06:36 -0700 Message-ID: <20260518190735.16236-10-robin.clark@oss.qualcomm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260518190735.16236-1-robin.clark@oss.qualcomm.com> References: <20260518190735.16236-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=a4MAM0SF c=1 sm=1 tr=0 ts=6a0b63a5 cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==: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=OtV_UDYxk2hhjaRdRjwA:9 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNTE4MDE4OCBTYWx0ZWRfX5V18PmC+bxh1 Hc0iUgRyTgNq7ClNZQO4kYFnU+9/XqDEuPj+oVsnc8KorhYvC3XOk39xpCpEHdbnk7b/Xg9oZmy RoJ0ATReHcXU2eBbVyvYPfNpsevMISWIqkXE/VX9STHOAa1RulSzY907YuEzPmwJvDk5OlmcLNh qvk+Mic3wsAbbx6a8zDFnX7w9pR7fhpCMkh3c4NdzSKSwK0iclh8VKgoEpV6lBgTXWtKpZWiiNL 38fyXrfkcY7tP6AMVQKAMw7oHC4dzilo7hBr7fYbao5kauJ/abDKPsfx8K78os8DxuX3ii7eZvS 1uUwW69FmPDBACxurtCmcKdsn3t4Haz1veNCB2mr1ws2A0IMyTUPg1BfTQ3b4VbYhCIqfwcl84K UGCbJqxrwTCIs7BG7TdAfHjk3CWwtpb5/UEN9XG17pBC2mkwPVqF07QUSVvea9RUaYYYm6jNSMZ WdYWkB3hFHF/PLU2EOg== X-Proofpoint-ORIG-GUID: vlGgAnED_nTmEB8aIiDjVeTqso5qrXPO X-Proofpoint-GUID: vlGgAnED_nTmEB8aIiDjVeTqso5qrXPO 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-18_03,2026-05-18_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 bulkscore=0 adultscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 suspectscore=0 spamscore=0 phishscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2605130000 definitions=main-2605180188 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 Reviewed-by: Dmitry Baryshkov Reviewed-by: Anna Maniscalco --- 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