From nobody Sun Jul 26 14:10:18 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1781155865; cv=none; d=zohomail.com; s=zohoarc; b=T5J5PWhqKBJvn04xAHLfigbu1x8z5GOpvROBvKxNg/frQUaHzj9VugbWpurAw9Kj8Omeb6QQu/E5k8YHw+7PuXtGQBfP0eyq1BtBrOYXiSu5R82LSYwVakXyIHox/AGu6hIxI8qJerrvncT42TnE5YflHsjUO7e79hF5QrktlC0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781155865; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MzvUFKvc+sUpWvc2016FnOxj5PhtBZkyxIiMWx3S09s=; b=S4zslmvcDrGmhEQJYy69ByaL7iD9XQBgzRKQ+ittyQ8pd+Cqk39rRu3jVwaZvb7lsmaGR1b7dA3KCmVFU61aOR/4xMSEvHao3WjrZLTwgwulI3SeggRqdsssKt3WW68Q9GzE+c8oQBEfzsjyfH2hf9q3p/NQtlcQznwXaWdyufQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781155865747959.5441591845632; Wed, 10 Jun 2026 22:31:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXXzc-0008Fx-QR; Thu, 11 Jun 2026 01:30:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXXzQ-00083E-EI for qemu-devel@nongnu.org; Thu, 11 Jun 2026 01:30:05 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXXzO-00014P-Mv for qemu-devel@nongnu.org; Thu, 11 Jun 2026 01:30:04 -0400 Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65B5GH7T3815865 for ; Thu, 11 Jun 2026 05:29:51 GMT Received: from mail-dy1-f198.google.com (mail-dy1-f198.google.com [74.125.82.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4eqe6u1rs0-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 11 Jun 2026 05:29:51 +0000 (GMT) Received: by mail-dy1-f198.google.com with SMTP id 5a478bee46e88-307fd7138b1so985223eec.0 for ; Wed, 10 Jun 2026 22:29:51 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30806e8a402sm880475eec.17.2026.06.10.22.29.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 22:29:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= MzvUFKvc+sUpWvc2016FnOxj5PhtBZkyxIiMWx3S09s=; b=BwmI0pU3nKxnTOq3 p/d8ANY0pUDs3AmrAsH0A1oAxUJLws9/hUy+iG3dWReFvuZEMBJoPn+x5rG5zq9X Hxc2lt5VbASE9gSENefmA0kWUoIJFjRePrAUh/L1a4W0Jkhl0aXLm3T0C6ATkzF6 grrkuxNzagv+JjlUfsLaIFa5goB+ZF6x2vhqwUexK1bEomIbCIMaNO+demfemOO3 7BP8Le2/NR5LSvDM+xGbUUIQ9rED36U1V6LD4dsCAn3KeI/TR8budN/Put0Yh4Yf OjEEishrgLPT3Xdf9oBj/jq1s9WWw18hI6/Bj/USlRLGp6SINBXStVHtYbjvHw8P Zm5f8w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1781155791; x=1781760591; darn=nongnu.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=MzvUFKvc+sUpWvc2016FnOxj5PhtBZkyxIiMWx3S09s=; b=cJBlTCUAG23px/18+lTHEJ23aYOb651SevgXrmaSpVHv20IvSOi7moFhHhTcizqOtg 4Hl38jIMdX+avgXSo9MMKXGl0WwExT4V4wBGn3Q2qRz8xBRCItz5hWy3hq3VVn7VwRg3 G2fMZmcVYv9rhQW4x0tkwAO7u3Q4UAoMFqoyFrVjI6oqoZEAWMdwud2Mv50Hax5xxIhn IYkpdZ46BYDmEZ/F0lqFB9cJ8Gi0RXi8DSXQNNZTmitlGLcitiwFu8IHJSTCDmygtQFJ Py1BDjvRuqCQSM/cS79dS530GqagjyelJ1sjbCDF45Ay32btbT0kgv0sXLZUqsLRCSMB lGHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781155791; x=1781760591; 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:c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y2 npaH77 X-Received: by 2002:a05:7300:220f:b0:307:6e28:efcc with SMTP id 5a478bee46e88-308049a36f2mr1111984eec.21.1781155790667; Wed, 10 Jun 2026 22:29:50 -0700 (PDT) X-Received: by 2002:a05:7300:220f:b0:307:6e28:efcc with SMTP id 5a478bee46e88-308049a36f2mr1111950eec.21.1781155789946; Wed, 10 Jun 2026 22:29:49 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: brian.cain@oss.qualcomm.com, matheus.bernardino@oss.qualcomm.com, pierrick.bouvier@oss.qualcomm.com, ltaylorsimpson@gmail.com, philmd@mailo.org, philmd@oss.qualcomm.com Subject: [PATCH v8] target/hexagon: Add pcycle setting functionality Date: Wed, 10 Jun 2026 22:28:52 -0700 Message-Id: <20260611052857.3911981-32-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260611052857.3911981-1-brian.cain@oss.qualcomm.com> References: <20260611052857.3911981-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-GUID: HvCALiXL0i7JknjtJkiBowdEPhZfmYr5 X-Proofpoint-Spam-Info: AW1haW4tMjYwNjExMDA1MSBTYWx0ZWRfX3xhVGDYN2r1v W+BmtnAD2HiHCJhm1BpDD7bI2LwPjw5Xv1YaK66e9NLbUIeyXThck7LMSZuYughZBPl8Ta/Hk68 LqjDDfuWw9xuDkhy/itqDKtRfxCShmk= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjExMDA1MSBTYWx0ZWRfX9tFJg7q2Jfla RsyzyPYRVx2O5Ep+QF94YxX+SdgHlYZz7OLODGObDPBkNiQ3ZaolODse33f8E2QoJa4r/VGFZWi xymR8HO/vkHRVq2VJnOmds7mrzVfMMBLpif1bR7z36DDS6h/UTaY0+uOQKcboqu1RfsouFEhSr+ ccULEWM/U3z83Yyfu7pqD5SFPHqRqlREKBaM6cyQFJBtUhTYzepQ2H79cwCAg9W59AK1/NIXcxm C8bqi4Tbo8V1HSKqtmXw05duxUnxcB9FjtteVeVxXXsPCmgv3cYr+nEMlT6izEnsose1Y0Pn4ZW t5BHlZmr5bU5tdgduDMIy1DvqwVL7QiHYW0oqnXf8N/U93WLCVPcJzm+WcKSaRCWanVEjkOLj3G oLEzGtHa+bPIChwsR1XN4Zdl+PYilDnLiqob8/o1Oge0VlEAuIMnDiQcjc7jx/RSrfxjYwmEPKE tP+zoVR5r4/ktAUu0Lw== X-Authority-Analysis: v=2.4 cv=F5lnsKhN c=1 sm=1 tr=0 ts=6a2a47cf cx=c_pps a=wEP8DlPgTf/vqF+yE6f9lg==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=pGLkceISAAAA:8 a=EUspDBNiAAAA:8 a=OF6xqQKflNrgTLtdKXcA:9 a=QEXdDO2ut3YA:10 a=bBxd6f-gb0O0v-kibOvt:22 X-Proofpoint-ORIG-GUID: HvCALiXL0i7JknjtJkiBowdEPhZfmYr5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-11_01,2026-06-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 clxscore=1015 adultscore=0 bulkscore=0 suspectscore=0 impostorscore=0 priorityscore=1501 spamscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606040000 definitions=main-2606110051 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @qualcomm.com) X-ZM-MESSAGEID: 1781155866986158500 Replace pcycle set stubs with real implementations that distribute cycle count changes across all active threads. Reviewed-by: Taylor Simpson Signed-off-by: Brian Cain --- target/hexagon/cpu_helper.c | 43 ++++++++++++++++++++++++++++++++++--- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/target/hexagon/cpu_helper.c b/target/hexagon/cpu_helper.c index bb991a671e8..64c5746c6d9 100644 --- a/target/hexagon/cpu_helper.c +++ b/target/hexagon/cpu_helper.c @@ -56,17 +56,54 @@ uint32_t hexagon_get_sys_pcycle_count_low(CPUHexagonSta= te *env) =20 void hexagon_set_sys_pcycle_count_high(CPUHexagonState *env, uint32_t val) { - g_assert_not_reached(); + uint64_t old; + + g_assert(bql_locked()); + old =3D hexagon_get_sys_pcycle_count(env); + old =3D deposit64(old, 32, 32, val); + hexagon_set_sys_pcycle_count(env, old); } =20 void hexagon_set_sys_pcycle_count_low(CPUHexagonState *env, uint32_t val) { - g_assert_not_reached(); + uint64_t old; + + g_assert(bql_locked()); + old =3D hexagon_get_sys_pcycle_count(env); + old =3D deposit64(old, 0, 32, val); + hexagon_set_sys_pcycle_count(env, old); } =20 void hexagon_set_sys_pcycle_count(CPUHexagonState *env, uint64_t val) { - g_assert_not_reached(); + CPUState *cs; + uint64_t total; + int num_threads; + int64_t delta, per_thread, remainder; + + g_assert(bql_locked()); + total =3D hexagon_get_sys_pcycle_count(env); + + /* Count active threads */ + num_threads =3D 0; + CPU_FOREACH(cs) { + num_threads++; + } + g_assert(num_threads > 0); + + /* + * Distribute the delta evenly across all threads. + * Any remainder goes to the calling thread. + */ + delta =3D (int64_t)(val - total); + per_thread =3D delta / num_threads; + remainder =3D delta - per_thread * num_threads; + + CPU_FOREACH(cs) { + CPUHexagonState *thread_env =3D cpu_env(cs); + thread_env->t_cycle_count +=3D per_thread; + } + env->t_cycle_count +=3D remainder; } =20 static void hexagon_resume_thread(CPUHexagonState *env) --=20 2.34.1