Skip to content

Commit 982d0a0

Browse files
LeviYeoReumSuzuki K Poulose
authored andcommitted
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
1 parent 56eb02f commit 982d0a0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/hwtracing/coresight/coresight-replicator.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ struct replicator_drvdata {
4141
struct clk *atclk;
4242
struct clk *pclk;
4343
struct coresight_device *csdev;
44-
spinlock_t spinlock;
44+
raw_spinlock_t spinlock;
4545
bool check_idfilter_val;
4646
};
4747

@@ -125,7 +125,7 @@ static int replicator_enable(struct coresight_device *csdev,
125125
unsigned long flags;
126126
bool first_enable = false;
127127

128-
spin_lock_irqsave(&drvdata->spinlock, flags);
128+
raw_spin_lock_irqsave(&drvdata->spinlock, flags);
129129
if (out->src_refcnt == 0) {
130130
if (drvdata->base)
131131
rc = dynamic_replicator_enable(drvdata, in->dest_port,
@@ -135,7 +135,7 @@ static int replicator_enable(struct coresight_device *csdev,
135135
}
136136
if (!rc)
137137
out->src_refcnt++;
138-
spin_unlock_irqrestore(&drvdata->spinlock, flags);
138+
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
139139

140140
if (first_enable)
141141
dev_dbg(&csdev->dev, "REPLICATOR enabled\n");
@@ -179,14 +179,14 @@ static void replicator_disable(struct coresight_device *csdev,
179179
unsigned long flags;
180180
bool last_disable = false;
181181

182-
spin_lock_irqsave(&drvdata->spinlock, flags);
182+
raw_spin_lock_irqsave(&drvdata->spinlock, flags);
183183
if (--out->src_refcnt == 0) {
184184
if (drvdata->base)
185185
dynamic_replicator_disable(drvdata, in->dest_port,
186186
out->src_port);
187187
last_disable = true;
188188
}
189-
spin_unlock_irqrestore(&drvdata->spinlock, flags);
189+
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
190190

191191
if (last_disable)
192192
dev_dbg(&csdev->dev, "REPLICATOR disabled\n");
@@ -277,7 +277,7 @@ static int replicator_probe(struct device *dev, struct resource *res)
277277
}
278278
dev->platform_data = pdata;
279279

280-
spin_lock_init(&drvdata->spinlock);
280+
raw_spin_lock_init(&drvdata->spinlock);
281281
desc.type = CORESIGHT_DEV_TYPE_LINK;
282282
desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT;
283283
desc.ops = &replicator_cs_ops;

0 commit comments

Comments
 (0)