Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

coresight-replicator: change replicator_drvdata spinlock's type to raw_spinlock_t

In coresight-replicator drivers, replicator_drvdata->spinlock can be held
during __schedule() by perf_event_task_sched_out()/in().

Since replicator_drvdata->spinlock type is spinlock_t and
perf_event_task_sched_out()/in() is called after acquiring rq_lock,
which is raw_spinlock_t (an unsleepable lock),
this poses an issue in PREEMPT_RT kernel where spinlock_t is sleepable.

To address this, change type replicator_drvdata->spinlock in
coresight-replicator drivers, which can be called
by perf_event_task_sched_out()/in(), from spinlock_t to raw_spinlock_t.

Reviewed-by: James Clark <james.clark@linaro.org>
Reviewed-by: Mike Leach <mike.leach@linaro.org>
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20250306121110.1647948-8-yeoreum.yun@arm.com

authored by

Yeoreum Yun and committed by
Suzuki K Poulose
982d0a0e 56eb02f0

+6 -6
+6 -6
drivers/hwtracing/coresight/coresight-replicator.c
··· 41 41 struct clk *atclk; 42 42 struct clk *pclk; 43 43 struct coresight_device *csdev; 44 - spinlock_t spinlock; 44 + raw_spinlock_t spinlock; 45 45 bool check_idfilter_val; 46 46 }; 47 47 ··· 125 125 unsigned long flags; 126 126 bool first_enable = false; 127 127 128 - spin_lock_irqsave(&drvdata->spinlock, flags); 128 + raw_spin_lock_irqsave(&drvdata->spinlock, flags); 129 129 if (out->src_refcnt == 0) { 130 130 if (drvdata->base) 131 131 rc = dynamic_replicator_enable(drvdata, in->dest_port, ··· 135 135 } 136 136 if (!rc) 137 137 out->src_refcnt++; 138 - spin_unlock_irqrestore(&drvdata->spinlock, flags); 138 + raw_spin_unlock_irqrestore(&drvdata->spinlock, flags); 139 139 140 140 if (first_enable) 141 141 dev_dbg(&csdev->dev, "REPLICATOR enabled\n"); ··· 179 179 unsigned long flags; 180 180 bool last_disable = false; 181 181 182 - spin_lock_irqsave(&drvdata->spinlock, flags); 182 + raw_spin_lock_irqsave(&drvdata->spinlock, flags); 183 183 if (--out->src_refcnt == 0) { 184 184 if (drvdata->base) 185 185 dynamic_replicator_disable(drvdata, in->dest_port, 186 186 out->src_port); 187 187 last_disable = true; 188 188 } 189 - spin_unlock_irqrestore(&drvdata->spinlock, flags); 189 + raw_spin_unlock_irqrestore(&drvdata->spinlock, flags); 190 190 191 191 if (last_disable) 192 192 dev_dbg(&csdev->dev, "REPLICATOR disabled\n"); ··· 277 277 } 278 278 dev->platform_data = pdata; 279 279 280 - spin_lock_init(&drvdata->spinlock); 280 + raw_spin_lock_init(&drvdata->spinlock); 281 281 desc.type = CORESIGHT_DEV_TYPE_LINK; 282 282 desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT; 283 283 desc.ops = &replicator_cs_ops;