From nobody Fri Apr 17 01:48:09 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87178366834 for ; Tue, 24 Feb 2026 10:56:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771930588; cv=none; b=I5iVJNgZqm2SSf+FFD8o6aQvbRktcHdMkk6YSXSRaGBOzwu/0ymKiSPydW/TPFKufrNCL28OIVlIYb5ty37/Wi4lAuGgsd7oIpxcuyMz5NkjqIjAAfkQnOTeNf74EJlb2jsAddwQiQ7ObCWIseHFaOd2NIJn1s1zEcRNGUGCnG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771930588; c=relaxed/simple; bh=x2UNo1Ahc2P9zL9ZXowIXwNJ1dEqdP4UyKQYNY7EWio=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=KH9FytbjxHavUVTD6j1QVXSSLsuvymoSAGepmjITYDjGWhuBOh0KtRCWS745KR7zyo3TflcD0nVvSMOT0jZOLluTNLWhz/5u2ynHCwOorSv0wi5dMFdEu1N9lP2D349lj2lUYKF48F4ngf12O7Asb5lp43hv5Jokx9tyHK80hh4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 69464339; Tue, 24 Feb 2026 02:56:19 -0800 (PST) Received: from e132581.arm.com (e132581.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6B6833F62B; Tue, 24 Feb 2026 02:56:24 -0800 (PST) From: Leo Yan Date: Tue, 24 Feb 2026 10:56:14 +0000 Subject: [PATCH] coresight: cti: Move resource release to cti_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: quoted-printable Message-Id: <20260224-arm_coresight_refactor_cti_resource_release-v1-1-ff1b2bca9176@arm.com> X-B4-Tracking: v=1; b=H4sIAM2DnWkC/x3N4QrCMAwE4FcZ+W1hy4qgryJSapptAV0lqSKMv fuC/+6D424DYxU2uHYbKH/FpK6O4dQBLXmdOUhxA/Z47hFjyPpKVJVN5qUl5SlTq5qoicPqR4k 9PDkbB4zl8igcp2Ek8MW31+X3f7vd9/0AULpV7n0AAAA= X-Change-ID: 20260224-arm_coresight_refactor_cti_resource_release-24d9bde4f13c To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Leo Yan X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1771930584; l=3982; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=x2UNo1Ahc2P9zL9ZXowIXwNJ1dEqdP4UyKQYNY7EWio=; b=dKgC6sGwk/M++VUvdXC1wOwe/HRJs3PEewEPQNcr3HNk9GWpOid0lJv7BKTu9U4q0G+4iqrrq ZgXAhnvNj0YBNH3rrsH7CXqZYjCpW1hYV1//6NxuhT06hrNllujDf4Y X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= Currently, CTI driver releases resource by deferring cti_device_release() to the device unregistration: cti_remove() `> coresight_unregister() `> cti_remove_assoc_from_csdev() `> device_unregister() `> cti_device_release() `> mutex_lock(&ect_mutex) `> release CTI resource `> mutex_unlock(&ect_mutex) In the above flow, two different CTI release callbacks are involved: cti_remove_assoc_from_csdev() and cti_device_release(). The former is used by a CoreSight device to unbind its associated CTI helper device, while the latter releases resources for the CTI device itself. Since there is no dependency between them, it is unnecessary to defer the CTI resource release until device unregistration. This commit releases the resources directly in cti_remove() and remove the injected release callback. Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-cti-core.c | 24 +++-----------------= ---- drivers/hwtracing/coresight/coresight-cti.h | 2 -- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwt= racing/coresight/coresight-cti-core.c index bfbc365bb2ef2744efab11c056b8450472957005..7a8f1ef6b94e8ab3363ea62db95= b0bc302292cd7 100644 --- a/drivers/hwtracing/coresight/coresight-cti-core.c +++ b/drivers/hwtracing/coresight/coresight-cti-core.c @@ -823,16 +823,13 @@ static const struct coresight_ops cti_ops =3D { .helper_ops =3D &cti_ops_ect, }; =20 -/* - * Free up CTI specific resources - * called by dev->release, need to call down to underlying csdev release. - */ -static void cti_device_release(struct device *dev) +static void cti_remove(struct amba_device *adev) { - struct cti_drvdata *drvdata =3D dev_get_drvdata(dev->parent); + struct cti_drvdata *drvdata =3D dev_get_drvdata(&adev->dev); struct cti_drvdata *ect_item, *ect_tmp; =20 mutex_lock(&ect_mutex); + cti_remove_conn_xrefs(drvdata); cti_pm_release(drvdata); =20 /* remove from the list */ @@ -844,17 +841,6 @@ static void cti_device_release(struct device *dev) } mutex_unlock(&ect_mutex); =20 - if (drvdata->csdev_release) - drvdata->csdev_release(dev); -} -static void cti_remove(struct amba_device *adev) -{ - struct cti_drvdata *drvdata =3D dev_get_drvdata(&adev->dev); - - mutex_lock(&ect_mutex); - cti_remove_conn_xrefs(drvdata); - mutex_unlock(&ect_mutex); - coresight_unregister(drvdata->csdev); } =20 @@ -947,10 +933,6 @@ static int cti_probe(struct amba_device *adev, const s= truct amba_id *id) cti_update_conn_xrefs(drvdata); mutex_unlock(&ect_mutex); =20 - /* set up release chain */ - drvdata->csdev_release =3D drvdata->csdev->dev.release; - drvdata->csdev->dev.release =3D cti_device_release; - /* all done - dec pm refcount */ pm_runtime_put(&adev->dev); dev_info(&drvdata->csdev->dev, "CTI initialized\n"); diff --git a/drivers/hwtracing/coresight/coresight-cti.h b/drivers/hwtracin= g/coresight/coresight-cti.h index 4f89091ee93f5fb046d93b97a4085051fca6b39d..daff9e32a6daca90f4d5f4726f1= 63fdd9106191c 100644 --- a/drivers/hwtracing/coresight/coresight-cti.h +++ b/drivers/hwtracing/coresight/coresight-cti.h @@ -170,7 +170,6 @@ struct cti_config { * @spinlock: Control data access to one at a time. * @config: Configuration data for this CTI device. * @node: List entry of this device in the list of CTI devices. - * @csdev_release: release function for underlying coresight_device. */ struct cti_drvdata { void __iomem *base; @@ -179,7 +178,6 @@ struct cti_drvdata { raw_spinlock_t spinlock; struct cti_config config; struct list_head node; - void (*csdev_release)(struct device *dev); }; =20 /* --- base-commit: 6de23f81a5e08be8fbf5e8d7e9febc72a5b5f27f change-id: 20260224-arm_coresight_refactor_cti_resource_release-24d9bde4f13c Best regards, --=20 Leo Yan