From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 65E6D3F58D9 for ; Wed, 23 Sep 2026 14:34:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790174069; cv=none; b=ouzwxR5aIrxTcQeipwq9npGI5fnXlq3o28ewgO4FRgzcXbDgKlIL4NREPZfSJnNzUJJKG/r3xMnyR5gchVROKzKBaYQqZFEBwXWtfu8ap90Mpt1j4WmrlDzOY4DazJaofzDn2CE2vCIkDV2w5KUnkpUld/vExeM04JTkKKkxAHs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790174069; c=relaxed/simple; bh=Y4khVXeemjG7U5RyghQFLtmJRcCeMF3ra/N19Lc+vfw=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Ca8RD+ykl0Jzxtq2j7aHahKP/4RQW7wfR0ZOmi3OOEm3TWoPqEv+8HPyQ2MB19w31MQPPtD7ePihReSpLJg2hCKydspPU072U15lqMY9TI32do8CaugYqucYUuaA/DGMXndr7y3/DVlrTjtNzKfYs05lB/lDkerv43/28TYpRoM= 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=EnLAcB3h; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=i/v8zAuh; arc=none smtp.client-ip=205.220.168.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="EnLAcB3h"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="i/v8zAuh" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68NBbU2V3295545 for ; Wed, 23 Sep 2026 14:34:26 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=2enLtWPV8EY1gFb2HT3py+uGngZNotcbsn1 pLWbCTGs=; b=EnLAcB3hE6S3oNWlSnjjQxlYSSjanomQaW7Dw+J9nmw4HtdG3Vu vHeaWxq7b3AKwTwwmxDPLoqtMiIbM1BeFPN1J83PSK0+hG6Z1ALak/2boXjsqHMm /iulsq4qSdJvOtYtRQvLhzRHziv/eXC0yt2WPi2ba6fjKJNM4gwgJtwCgnoAlARj I97n/e3phQLEcCpWLPjMD2b4T9Uw9gJPuZnoTasm3/rgsVXhsOkDDcNb2vA9yugu fvGhFAPEfOBAhwgNNOJCwsi7R55z/qzFTfc79OlFRvd/Nnqzo4fnPnFzBYizie9S 5hlnOkbmv1Gej+QlaylleRur7AydK8HkQbg== Received: from mail-ua1-f70.google.com (mail-ua1-f70.google.com [209.85.222.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4gvbwm9ay2-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 23 Sep 2026 14:34:26 +0000 (GMT) Received: by mail-ua1-f70.google.com with SMTP id a1e0cc1a2514c-97cc46a7765so190624241.2 for ; Wed, 23 Sep 2026 07:34:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1790174065; x=1790778865; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=2enLtWPV8EY1gFb2HT3py+uGngZNotcbsn1pLWbCTGs=; b=i/v8zAuhSUUoyWbGjtLiE71e396dh7cjtS7WgOi59DRBLwNy71FhHcGg6m4Ar9UL5u kXWTVP6Ws7HCN2zHeaW0Q1iDuQmbh4djf2luucbnmmYiomGF5xRkOMzWzaej5N5LkOKo pWpDZ8dQwoaRQwr5I1C50Y+ati2z5uheDBBG+IAta84DTRQZfb/Gs2gqS1x9Vd/0sDGK nGVbW6Gq+oGhuvwzPNir0Ep19ReUN26KnDFpczla8zmSw6W8DqRkIASJDKR4K8qJZFXT p2dr/V5N4V2pUpLped+TB+48IDG6/BVDBXqYWgq3UGxOojKQt981H+hFecpXxqsYc8tM WdKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790174065; x=1790778865; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=2enLtWPV8EY1gFb2HT3py+uGngZNotcbsn1pLWbCTGs=; b=oAVMHjf4WfmrQDhgcILjp1izpbKeG69jfPJhv7cYqTqtgH9zKbC/ScBD47AnCsRcIa xB4KaJhPHe/qx/GU4c4pBTuCMruVcW3zhahLw+igZfUsPJ88asKAG6OFobEBGBSdzlVn f7VANcfSHejbsHBWTH7hdHtK8QJ6p/ybKEDlS9Sxxnc5ERkg2QkzqjtHcvvZGLpjkD/b SE2O2pqs/BzlzQNehYe77FoTV5UPwe/KgTcO0z5qbGmD5Dce5A8TuPcfzI+tWtoW4qoP 9eI0fT+1EgsqcVuYI/Q27AJ9cnoxqC5qLO9Iea8hxRWgX0h2UwS4CWzebOY6wTHXfll/ MQDQ== X-Forwarded-Encrypted: i=1; AKwUvBwKjQk0vpHLzLrj99ixoEtS7lEJ2s94YsC5zetI/VqvYSuVLFujR0Kj2DRAG3hemdpYYU5vmggJi4V15QRzbJg=@vger.kernel.org X-Gm-Message-State: AFuF++kR9AdDJ8xXjY4EY40ck4IT46tTLU/HUec6hdH+6BNXpnIn/fDI Uqj7uo4tjtHavumTeGIOm8h8jReCEpwyU7/2ZR4WsbKZwCPP1A6fjRJJCTmUAQqenDK/NAwmqeV 1FUTkv2wQHeaMsD4VR9VhuaMsg14OQQm3r4FOxAer5fu6mapdOZFXqaCuDxaeF/53cCy2cgh3jk vXA8g= X-Gm-Gg: AYBFou1TCPqZTopVeRSMXwTkOnx+crsgeFwZXDOLrL9Vr28utGb6/JGKG91szJSN4Oj Il5XSHqqoKeFK9arJ9Mu0PyLmlvqQEyvWLWaHrnpN9J9pQ/n6KVocqtxrq/KfT51O9Rh8HwWbnG Q0E2wNYvs1iXRbgbb1k1HNSU+IJCRk9fAT6khSQqod/K5FNxu1rqVsz7ErNdHbZCSQvsbIsK5O+ IRnJGU5cfSlYMqC03EQ/xThj1c4F1pq4I7YSFvQ5VwaKAQBRbnvkQGd/X5lupxqFhVJxnDIpm6b LA7sUwhk7OpT6uTtD8kSvwqyxL+wPfJ9mQqdhmRe3E1uPUlGOqM6WfDk4Gdtx460uCXqZepO7T2 MDH2CAxonpiLeIaSrb0kijznGZTQ= X-Received: by 2002:a05:6102:3ec3:b0:7a1:f7d2:e839 with SMTP id ada2fe7eead31-7ac1da2381bmr2472939137.25.1790174065319; Wed, 23 Sep 2026 07:34:25 -0700 (PDT) X-Received: by 2002:a05:6102:3ec3:b0:7a1:f7d2:e839 with SMTP id ada2fe7eead31-7ac1da2381bmr2472909137.25.1790174064665; Wed, 23 Sep 2026 07:34:24 -0700 (PDT) Received: from mai.box.freepro.com ([2a05:6e02:1041:c10:a913:ba43:96d7:743c]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49fdf158147sm58213905e9.0.2026.09.23.07.34.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2026 07:34:23 -0700 (PDT) From: Daniel Lezcano To: rafael@kernel.org Cc: linux-pm@vger.kernel.org, shuah@kernel.org, linux-kselftest@vger.kernel.org, manaf.pallikunhi@oss.qualcomm.com Subject: [PATCH v2 0/6] powercap: Add generic hierarchy support and convert DTPM Date: Wed, 23 Sep 2026 16:34:10 +0200 Message-ID: <20260923143416.3713485-1-daniel.lezcano@oss.qualcomm.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Info: AW1haW4tMjYwOTIzMDA1OCBTYWx0ZWRfX6DPhsZKUcJ6f RrNfM1AVacimVxe7/H2rNIKtU7bVBr0eRfM9LnGLjAznl/vKdCUKU8Yigj2iu6iFdvSyRP5yTVQ FWnKnrjxtKC4MxfZiczOzjLeGMJSbeY= X-Authority-Analysis: v=2.4 cv=R/6WitRX c=1 sm=1 tr=0 ts=6ab3e372 cx=c_pps a=R6oCqFB+Yf/t2GF8e0/dFg==:117 a=xqWC_Br6kY4A:10 a=VdqzKS8jKosA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=_Mu-bpVJhHz6Wm8h43cA:9 a=TD8TdBvy0hsOASGTdmB-:22 X-Proofpoint-GUID: VopZAyuiie4TJ-2SXeBJ1DRdY08_shFy X-Proofpoint-ORIG-GUID: VopZAyuiie4TJ-2SXeBJ1DRdY08_shFy X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTIzMDA1OCBTYWx0ZWRfX9g0FYhMcYpke c14lxey3GUFMEi1mBv6ov1vO1A1zyvCQ1g7aRw9PfI4VMOhckBhVBGQYpQJZ4aghEBKZLSDcXdm g9277PWWnweJXZLd2Ulsm+FXAbSyF/OVvbcUXFL98lGFh72zSJ/irs6HCp3QISXY5PvNS26a3xP mllqD+cgMibjhHZ1C4GIXae3OwONKfVFbmUlQZUy7gsua9MNk388AmPSZ9g1Hhr3jk9EGoF2KTW oHmUunIn/vSoycnyUlLTTjV0Vxhq1foogTmUMPMoYTYzkEcawEXh8YkQ00vUVyo8MA2zzb/DUV/ +6St7EEXUZ44K9mBqy7WShyQPdSAMp3AlNNhSVb562oKL8ulOCd7KP68hwm7tw9x1+fV6CfnIw2 WX1fXaKG7VVnTiqQT9bANZSppiaSOam70982On1QJ5boCMx4C4Z3TSP85EUpn4nFvS9wcozKAp/ U804tQCbgL+TECq5fvw== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-23_04,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 malwarescore=0 impostorscore=0 priorityscore=1501 lowpriorityscore=0 spamscore=0 suspectscore=0 phishscore=0 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609230058 Powercap controllers frequently expose a hierarchy of power zones, for example packages, clusters and CPUs. Until now, each driver had to implement its own hierarchy traversal, parent lookup, error handling and teardown logic. This series introduces a generic hierarchy description and helper functions allowing a powercap controller to instantiate and destroy an entire hierarchy from a static description. The powercap core takes care of duplicating the hierarchy description, rebasing parent pointers, creating zones in dependency order, and performing the appropriate rollback and cleanup on errors. The API was primarily motivated by the recently posted SPEL series and also provides a migration path for DTPM to use the same generic infrastructure instead of maintaining its own hierarchy handling. Link: SPEL cover letter https://lore.kernel.org/lkml/20260702-qcom_spel_driver_upstream-v3-0-434d50f0c5b0@oss.qualcomm.com/ A kselftest is added to exercise the new API. It creates a synthetic hierarchy, validates the resulting sysfs hierarchy and attributes, and checks that all resources are correctly released when the hierarchy is destroyed. DTPM currently implements its own hierarchy creation logic to walk a platform-provided description, create the corresponding DTPM zones and tear them down. With the generic powercap hierarchy infrastructure in place, this logic can instead be shared at the powercap core level. The series therefore converts DTPM to use the generic powercap hierarchy helpers. The platform hierarchy is duplicated before use, while powercap_hierarchy_create() and powercap_hierarchy_destroy() handle its lifetime and traversal. DTPM only provides the callbacks responsible for creating and destroying the DTPM instance associated with each powercap node. The CPU and devfreq backends are adjusted accordingly. As part of this conversion, the existing RK3399 description is simplified. The CPU backend creates one DTPM zone per cpufreq policy, so describing every CPU belonging to the same policy results in duplicate zones. The RK3399 hierarchy is therefore reduced to one CPU node per cpufreq policy. The Rockchip virtual node descriptor is also made SoC-independent so it can be reused by other Rockchip platforms. Finally, an RK3588 hierarchy is added. The RK3588 exposes three cpufreq policies, represented by cpu@0, cpu@400 and cpu@600. These three CPU domains are grouped below a virtual package node: rk3588 `-- package |-- cpu0-cpufreq |-- cpu4-cpufreq `-- cpu6-cpufreq Daniel Lezcano (6): powercap: Add generic zone hierarchy creation helpers selftests/powercap: Add powercap hierarchy creation API tests powercap: dtpm: Remove duplicate RK3399 CPU hierarchy nodes powercap: dtpm: Use generic powercap hierarchy helpers powercap: dtpm: Rename Rockchip virtual node descriptor powercap: dtpm: Add RK3588 hierarchy drivers/powercap/dtpm.c | 165 ++++++------ drivers/powercap/dtpm_cpu.c | 22 +- drivers/powercap/dtpm_devfreq.c | 22 +- drivers/powercap/powercap_sys.c | 148 +++++++++++ drivers/soc/rockchip/dtpm.c | 127 ++++++--- include/linux/dtpm.h | 5 +- include/linux/powercap.h | 178 +++++++++++++ tools/testing/selftests/Makefile | 1 + tools/testing/selftests/powercap/Kbuild | 3 + tools/testing/selftests/powercap/Makefile | 17 ++ .../selftests/powercap/powercap_hierarchy.c | 246 ++++++++++++++++++ .../selftests/powercap/powercap_hierarchy.sh | 118 +++++++++ 12 files changed, 906 insertions(+), 146 deletions(-) create mode 100644 tools/testing/selftests/powercap/Kbuild create mode 100644 tools/testing/selftests/powercap/Makefile create mode 100644 tools/testing/selftests/powercap/powercap_hierarchy.c create mode 100755 tools/testing/selftests/powercap/powercap_hierarchy.sh -- 2.43.0