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 F3E4937754A for ; Mon, 9 Feb 2026 12:44:58 +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=1770641099; cv=none; b=moOTXSRHVNA5IKJRCvjLtNml0piOvNQ8Lmt74fV4rnlNq9EcJag29CaUmu4YG9rNW1/8Y5hca806F2fbQsZ+BUsq98bY8SxQlW2gE+itc3j2pmWudIFAtgsCODvhOHT/exYezbtuG3yxcskjCwB8NwV1MtI6NCgxx6VkUIcx4sQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770641099; c=relaxed/simple; bh=nrt2ZS0UrGrkdlIXQ4O1c0Y7/8zYrmAeVRWVzD3tCpY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ZR8emw8/6hZW/YGngP8wNlZ0yHZHFRj/b0RgcJh0LNzBORay5wRfzeZuAXlqqE8/V0cb8zZhf5HeBqE6Zm0WZd75bqS6IwbpuNGoDm1v74lUtAAb89oneRIv09BYJsPGzPmi9DekjsVBA0C7NuhwOzon/k7gV40USwjuKXUu/fc= 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 328891063; Mon, 9 Feb 2026 04:44:52 -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 C97793F63F; Mon, 9 Feb 2026 04:44:56 -0800 (PST) From: Leo Yan Date: Mon, 09 Feb 2026 12:44:35 +0000 Subject: [PATCH v4 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: <20260209-arm_coresight_refactor_dev_register-v4-3-62d6042f76f7@arm.com> References: <20260209-arm_coresight_refactor_dev_register-v4-0-62d6042f76f7@arm.com> In-Reply-To: <20260209-arm_coresight_refactor_dev_register-v4-0-62d6042f76f7@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=1770641090; l=1652; i=leo.yan@arm.com; s=20250604; h=from:subject:message-id; bh=nrt2ZS0UrGrkdlIXQ4O1c0Y7/8zYrmAeVRWVzD3tCpY=; b=HXJlDqDlNayFLDSU3MBGNUqAUK0yqzFwgtXTzZAm70RxvOBPA0MwvnRi5iulMP2ZUdZZkV46m o7+zlM93nHmB1F4eRTsDVr3/MDWYdd3TMSIDqSxVpSZLzU45LR7LeV6 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") Reviewed-by: James Clark 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 26e7ab4005413ab5c59f3ca663b92a681263b488..5aa178b4def336770ae2b7647372174345564776 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1432,14 +1432,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