[PATCH v3 22/31] coresight: cti: Make spin lock usage consistent

Leo Yan leo.yan at arm.com
Mon Sep 15 03:33:45 PDT 2025


The spin lock is currently acquired sometimes with IRQs disabled and
sometimes without. This leads to inconsistent semantics: the lock can be
either HARDIRQ-safe or HARDIRQ-unsafe, which may trigger lockdep
complaints.

Make the spin lock usage consistent by always without disabling IRQ.

Note: the CTI driver currently has a flaw that it does not use SMP call
for CPU-bound devices. Once the SMP call is supported in the CTI driver,
the locking scheme should consider to disable IRQs when taking the lock.

Signed-off-by: Leo Yan <leo.yan at arm.com>
---
 drivers/hwtracing/coresight/coresight-cti-core.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-cti-core.c b/drivers/hwtracing/coresight/coresight-cti-core.c
index 206a46fd4efd05165c56567289928295c5e35d4f..081b645987c7c7276361609bdf437949f62b5964 100644
--- a/drivers/hwtracing/coresight/coresight-cti-core.c
+++ b/drivers/hwtracing/coresight/coresight-cti-core.c
@@ -91,10 +91,9 @@ static int cti_enable_hw(struct cti_drvdata *drvdata, enum cs_mode mode)
 {
 	struct cti_config *config = &drvdata->config;
 	struct coresight_device	*csdev = drvdata->csdev;
-	unsigned long flags;
 	int rc = 0;
 
-	raw_spin_lock_irqsave(&drvdata->spinlock, flags);
+	raw_spin_lock(&drvdata->spinlock);
 
 	if (!drvdata->config.enable_req_count) {
 		coresight_set_mode(csdev, mode);
@@ -119,7 +118,7 @@ static int cti_enable_hw(struct cti_drvdata *drvdata, enum cs_mode mode)
 
 	config->hw_enabled = true;
 	drvdata->config.enable_req_count++;
-	raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
+	raw_spin_unlock(&drvdata->spinlock);
 	return rc;
 
 cti_state_unchanged:
@@ -129,7 +128,7 @@ static int cti_enable_hw(struct cti_drvdata *drvdata, enum cs_mode mode)
 cti_err_not_enabled:
 	if (!drvdata->config.enable_req_count)
 		coresight_set_mode(csdev, CS_MODE_DISABLED);
-	raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
+	raw_spin_unlock(&drvdata->spinlock);
 	return rc;
 }
 

-- 
2.34.1




More information about the linux-arm-kernel mailing list