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 9888123BCED for ; Fri, 10 Jul 2026 01:15:25 +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=1783646132; cv=none; b=N2RVvlPmQmAgxo7+czt4rthxxudhVSuhxfFXeYThOmBt8kfra6xqsODVc67xJF3FOwFflBW37CtkaBHz4+S8bco3c8Yrh94tdirUg9cvinkKQvXSOylFrxvHWTe4Gndx1QoW7LJFkj/iEziqu86d5C28TNUKsaxQ3GNGbjW9WEM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783646132; c=relaxed/simple; bh=zgpWTKXkYjMR3KQnvwavCbiRuaPSJpMbJdyDurbvDAY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sjdxSlxWq3TorA62VFyAmUmUablQEiLWi3WGrQDj61B5uJnsuOIJ0lUiWoe8IupyViI2mZ4piObz8h/IZpyXuPlRs0KcLhT1KrPmwud7AKz0wYbtu4/oSacBfDsxQItp827vaLr94OHzeP4u+xRy+6OvIfXlz/eCLLlrnelr48E= 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=k5qf5ez9; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=eVGd+yzU; 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="k5qf5ez9"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="eVGd+yzU" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 669HXdmg2473867 for ; Fri, 10 Jul 2026 01:15:23 GMT 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= G1wqDBsI3yCT2sfldRRfx2gkru7XASPgr4zytRr1nM0=; b=k5qf5ez9Yeo9+Ix/ lr5RbW2d7gVVZ95E/fpmLKVdreoGXqKAm+4B+nVE6cgC5c/eqI3pCuCvpi4ztC2E DIhx4aSYMhx9lmV/L2mnDLrO5cYPT4d2xw2kcbeE31RHI04xlP2tzvXAFi/Q4342 UbtEh+y/Prm44t67mdYGqDZ4uOCNurMIv3tTYFtBZrQ+zAbzg3E9YbwBzRhSknI2 SbXRnl2Wpz7obqBqpYOVjlXsukrv7ZbCkp7p53W3oYlSccNoGnGni8vZ8N00TgW8 cZTI4KsRRxkQDv6IGQ+mv/zByRR4u5GY+NAUny1VRWBckb6fvfXDm1N1nedmnSeY GKVYGw== Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4facqpjp5e-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 10 Jul 2026 01:15:23 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2cc5faecf01so6744195ad.1 for ; Thu, 09 Jul 2026 18:15:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1783646123; x=1784250923; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=G1wqDBsI3yCT2sfldRRfx2gkru7XASPgr4zytRr1nM0=; b=eVGd+yzUF726PQdj1fBcFjJ1AgWG2akAilFTAGDv8q4x5E3P0yM+k1SGSsy25hdciR AX+iyR3OVEbGNJlESDMhGC7gJspxOr5eKmyq6ec5VSH1qA0BO1qlYCRuY6jJ55peGTyz E/c4RSSQ5QtmaaBqkUO8kbKa1Vfy9wp2UVGkAHb4t9MMCY9lsSyIiUHriEsAAWZqfmNs mjCziXSXGAex171EBN+KwuYDZghGAEfsIJlh9lvYBR7/DowbXzKVQaeVW+PYvckgGzE+ JqxlPTKHIqTW0vuNwq17hsZn/t5gVrXPzEhDxtU5XcZJ2uNHbQoaSjWcDLquq5ImAZRF alOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783646123; x=1784250923; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=G1wqDBsI3yCT2sfldRRfx2gkru7XASPgr4zytRr1nM0=; b=Of6TcpsErxwjtiNzepdLKfK3Z4FXZ9YDdDY/Kb1CvI0XKNwZpR17X7+vaa+xPEvbNW 2R2SWdpUYso+D0KDqHJRutSrTLDaB+ezlMKsWnESQuQ548DzEYWlguVUlwadgfD2Fi+m ONqErejQYPOb1FAgYArTOsLR4e2vXIvdrfdTcUUP6Y7m7Ynle+b84XCpMwORQF7tDP0B XBX9b4rUrTPD6QGdcPedsgip7XwgvYNGHNY5JyLfdlMdCruVKagGRndWVbJHO5sihTnX 6OtArJXPcnwNSTceW665Uhddkf8vPGcFLnCylhj2BniAWL2KYXkYodcfnp4bd/BeSX9k L3lw== X-Forwarded-Encrypted: i=1; AHgh+RpzwdpgTxAkxl9DWbo0a4c+uKlPVohwoLRb6MWMV0PQDkldMrqI87lbhUO9EydgTwC1a/1lChmhZ0Ytz0o=@vger.kernel.org X-Gm-Message-State: AOJu0Yz5aF2gAOVCdpAvOPvDs05vrSYGsxrw3ahGbkC4IlQJvCAqx6uk X9zwLuu52UQKFRkMuxRdOhB+sTAWnqZjBL0YKFgqx76kBUwkPcKYWK6igIpFBO6BFSX3o2kGTGe iEf3o1qkveknQ5FUiHLpJMNcepE9VedWBr2RPwgjogA+0h8IGJOAL0co1spL3BtC39wE= X-Gm-Gg: AfdE7ckS7Z1bH7J2xF4fA4jWzG6l8I5CNWRQsZK1kZSQIvYeFJnmVV1HJbainCq+aTl dNbbQ1MxALUbmBoj8WKEV8ixAbrFegptS/HE8Ep3lqiyaKbyYvMxhz2Zq8NwbqTObzRn6dEPYfe 9Bc851uhZDlbMKNF5qdiAwgYd3qs4Gp3qkNPaK1PtiXJ4Nv0KBU6Z0eOwViMhCvC5czQWO8MOkU giQiPPcdo2/IZaVFnhu5oHCLI1ZJWxzc60xKhWppcwMeEkS6IhykW1tOtMK4DnRSR6qirsxYZes DrbIkaRIPqxZZYJtdnu9h6BNOe0SaBcTgNa+uTT2EdxT9Q/sW787UwxtJT4oLGAr397I7IGd4GB YriP/bVBKtgFRoBBbzg9Oyf/zYZ5uBQgA3kxVitUKCnMhjtyyJ6uzoVhbWK25T+e5a7d0l9Km/w == X-Received: by 2002:a05:6a21:682:b0:3bf:b50f:71bb with SMTP id adf61e73a8af0-3c0bc9acb33mr10934183637.27.1783646122625; Thu, 09 Jul 2026 18:15:22 -0700 (PDT) X-Received: by 2002:a05:6a21:682:b0:3bf:b50f:71bb with SMTP id adf61e73a8af0-3c0bc9acb33mr10934141637.27.1783646122195; Thu, 09 Jul 2026 18:15:22 -0700 (PDT) Received: from jiegan-gv.ap.qualcomm.com (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ca5b31628c1sm4431251a12.19.2026.07.09.18.15.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Jul 2026 18:15:21 -0700 (PDT) From: Jie Gan Date: Fri, 10 Jul 2026 09:14:48 +0800 Subject: [PATCH v3 2/2] coresight: tnoc: Fix clock refcount imbalance on platform remove Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260710-fix-clock-refcount-unbalance-v3-2-a37a1fb17981@oss.qualcomm.com> References: <20260710-fix-clock-refcount-unbalance-v3-0-a37a1fb17981@oss.qualcomm.com> In-Reply-To: <20260710-fix-clock-refcount-unbalance-v3-0-a37a1fb17981@oss.qualcomm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Leo Yan , Alexander Shishkin , Anshuman Khandual , Yeoreum Yun , Yuanfang Zhang , Maxime Coquelin , Alexandre Torgue , Tingwei Zhang Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Jie Gan X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1783646108; l=2017; i=jie.gan@oss.qualcomm.com; s=20250909; h=from:subject:message-id; bh=zgpWTKXkYjMR3KQnvwavCbiRuaPSJpMbJdyDurbvDAY=; b=NAXkJc33uJVwLgYrVrmkafvT+Ldln/C52l3qKRuXu/BorYNKmlaYr0W9YEkPolki/ROMN11hg 3D50TwOMEsqAa7LRtLjnBPZw2Tn22TpO/4pFo3vq0w3rk2wQfqdf/Ix X-Developer-Key: i=jie.gan@oss.qualcomm.com; a=ed25519; pk=3LxxUZRPCNkvPDlWOvXfJNqNO4SfGdy3eghMb8puHuk= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzEwMDAwOSBTYWx0ZWRfX/J176VsGIOAY itReDMHayjKBi/3dM1M9987O4mpKR7CYSBEals6B44Y8zVQe9hNeRroZQio5aqfqicZeeJMiuOR tncpqv5/dN03VA7axx6EsDBnr+g2Ao766QFgf0zpMPAZ5m7JwTHjtaPKZNi43D60BCiwhKE2xQJ 31VGjuZ9fyoPBiwU5yfRdCI9/iVP/69rEopXOVj3BO6Ve4nmooOR0v4Q0IKAWNAFClBF22lOEZb PnUlOdpJHZFmrpqch4I/c3rtWUMgZBMxecSueiCdf1VzklRqWtRmowjpYMjgwifbUS5qd6JvuRA gO83XMKaFwQler7S0kehgxpVQJWnma8diteypXz3mFb+3oCRPlUSbgq23/XeKL3fdiYtyHM/DJm Ueix/ltxv3IYx79YfUDgAdLM9/+TJodZunaaKx73uit+kwN9snvIOpzy/oTR1+psMYFbsG9Uqyv 0j1Vpy+AsoCiMJrM7eA== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzEwMDAwOSBTYWx0ZWRfX7gl6p0VnlIWI 97CCOProyKIiVwb6NYlIewLOOCLv2CGXUTV7fOSUSPIUaVPSY9ciff88V65zOGUc6S20bhzoMJE a/GGZkR6yzYuyJpH8xE2XMOBDFoz4/0= X-Proofpoint-GUID: sCnevyz1bh_jjy1Jw5YB2hvndgiv9miv X-Proofpoint-ORIG-GUID: sCnevyz1bh_jjy1Jw5YB2hvndgiv9miv X-Authority-Analysis: v=2.4 cv=GJ441ONK c=1 sm=1 tr=0 ts=6a5047ab cx=c_pps a=JL+w9abYAAE89/QcEU+0QA==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=7CQSdrXTAAAA:8 a=EUspDBNiAAAA:8 a=pvfjB89pdnN9FuMUozkA:9 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R:22 a=a-qgeE7W1pNrGK8U0ZQC:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-09_04,2026-07-09_04,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 lowpriorityscore=0 bulkscore=0 priorityscore=1501 clxscore=1015 suspectscore=0 spamscore=0 phishscore=0 adultscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607100009 coresight_get_enable_clocks() enables the programming clock through devm_clk_get_optional_enabled(), which also registers a devm action to call clk_disable_unprepare() when the driver detaches. After probe, pm_runtime_put() allows the device to suspend and the runtime suspend callback disables the clock. During remove the device is left runtime suspended, so pm_runtime_disable() freezes it with the clock already disabled. The devm cleanup that runs afterwards calls clk_disable_unprepare() a second time, underflowing the clock enable refcount. Resume the device with pm_runtime_get_sync() before tearing it down so the clock is enabled again and balances the devm-managed disable. Then pm_runtime_set_suspended() and pm_runtime_put_noidle() leave the device in a coherent runtime PM state (suspended, usage count balanced) once the devm action has disabled the clock. Fixes: 1abc1b212eff ("coresight: Appropriately disable programming clocks") Reviewed-by: Leo Yan Signed-off-by: Jie Gan --- drivers/hwtracing/coresight/coresight-tnoc.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/hwtracing/coresight/coresight-tnoc.c b/drivers/hwtracing/coresight/coresight-tnoc.c index 9e8de4323d28..eddfdcbaa3ec 100644 --- a/drivers/hwtracing/coresight/coresight-tnoc.c +++ b/drivers/hwtracing/coresight/coresight-tnoc.c @@ -299,8 +299,16 @@ static void itnoc_remove(struct platform_device *pdev) { struct trace_noc_drvdata *drvdata = platform_get_drvdata(pdev); + /* + * Resume the device so its clocks are enabled again, balancing the + * clk_disable_unprepare() that devm runs when the driver detaches. + * Then mark it suspended and drop the usage count taken here. + */ + pm_runtime_get_sync(&pdev->dev); coresight_unregister(drvdata->csdev); pm_runtime_disable(&pdev->dev); + pm_runtime_set_suspended(&pdev->dev); + pm_runtime_put_noidle(&pdev->dev); } #ifdef CONFIG_PM -- 2.34.1