From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2AF4833B95D for ; Mon, 26 Jan 2026 13:52:45 +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=1769435571; cv=none; b=quSRdxVaan0IBhipcMCJzXCfCiqOEClYEUmPvllZwm9Oxo3OLJUUoDkBH4Qn0IHbegnJvajaJ1aHClc0o/YcXBES09PcFgmUwTuRendTBz00wiOPeJZUJI/FwwX8x2R3nJ/m8+YSR62DfdOSyuJt76RgVQZye53b8EJ7hnY2kRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769435571; c=relaxed/simple; bh=NNtyAxNPwkV3k4xTpN3INAVKd2Yf9zKDsOUZfCQ+ZCw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kMipldz34EH9E/v/4R2vezH/fT+xgYT8t69RNNauZDLy5rqrg3ep4YKvgI+ITh2Ipq5bWHYqyImaknJY9FSRN69omw0Yvb6ubuqBhtsYQAbjTGCrtPIcsbkb3qAsFRt6Xe1XlBIR09ZxwjK1JXOAdmbqM6CoZ58IVBviK0nWJfk= 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 C39E5339; Mon, 26 Jan 2026 05:52:38 -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 8EA863F632; Mon, 26 Jan 2026 05:52:43 -0800 (PST) From: Leo Yan Date: Mon, 26 Jan 2026 13:52:03 +0000 Subject: [PATCH v2 3/8] coresight: Protect unregistration with mutex 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: <20260126-arm_coresight_refactor_dev_register-v2-3-b5a3c0441c15@arm.com> References: <20260126-arm_coresight_refactor_dev_register-v2-0-b5a3c0441c15@arm.com> In-Reply-To: <20260126-arm_coresight_refactor_dev_register-v2-0-b5a3c0441c15@arm.com> To: Suzuki K Poulose , Mike Leach , James Clark , Alexander Shishkin , Greg Kroah-Hartman , Mathieu Poirier , Mao Jinlong 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=1769435557; l=1601; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=NNtyAxNPwkV3k4xTpN3INAVKd2Yf9zKDsOUZfCQ+ZCw=; b=9jvQ1yfATrYjaMdrbvY+6WdiUxjP8y7iXWCIDITcXWLM3hGr4fi6D8ykgbmuHpUFiIfk+dUxX kdDKJ1UgN5AAWGlNNlMmSILp/T3rjJ9Ip2EZLgkkcckO6iby/BUq+tU X-Developer-Key: i=leo.yan@arm.com; a=ed25519; pk=k4BaDbvkCXzBFA7Nw184KHGP5thju8lKqJYIrOWxDhI= The device registration is protected by CoreSight mutex to ensure the atomic operations when adding a device onto bus. One the other hand, the locking is absent when unregister a device. Use mutex to ensure atomicity on device unregistration. During unregistration, unbinding the associated CTI device is not included in the locking region, as CTI has its own locking mechanism. Fixes: 8c1d3f79d9ca ("coresight: core: Fix coresight device probe failure issue") Signed-off-by: Leo Yan --- drivers/hwtracing/coresight/coresight-core.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index 6f21925a4913330a27db5d5836f34f13382339e7..b992ef5de8ddbd535e937c616bd7ab663f097f76 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1429,14 +1429,17 @@ EXPORT_SYMBOL_GPL(coresight_register); void coresight_unregister(struct coresight_device *csdev) { - etm_perf_del_symlink_sink(csdev); /* Remove references of that device in the topology */ if (cti_assoc_ops && cti_assoc_ops->remove) cti_assoc_ops->remove(csdev); + + mutex_lock(&coresight_mutex); + etm_perf_del_symlink_sink(csdev); coresight_remove_conns(csdev); coresight_clear_default_sink(csdev); coresight_release_platform_data(csdev, csdev->dev.parent, csdev->pdata); device_unregister(&csdev->dev); + mutex_unlock(&coresight_mutex); } EXPORT_SYMBOL_GPL(coresight_unregister); -- 2.34.1