Skip to content

Commit 6b80c0a

Browse files
LeviYeoReumSuzuki K Poulose
authored andcommitted
coresight-etb10: change etb_drvdata spinlock's type to raw_spinlock_t
In coresight-etb10 drivers, etb_drvdata->spinlock can be held during __schedule() by perf_event_task_sched_out()/in(). Since etb_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 etb_drvdata->spinlock in coresight-etb10 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-6-yeoreum.yun@arm.com
1 parent e304406 commit 6b80c0a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

drivers/hwtracing/coresight/coresight-etb10.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ struct etb_drvdata {
8484
struct clk *atclk;
8585
struct coresight_device *csdev;
8686
struct miscdevice miscdev;
87-
spinlock_t spinlock;
87+
raw_spinlock_t spinlock;
8888
local_t reading;
8989
pid_t pid;
9090
u8 *buf;
@@ -145,7 +145,7 @@ static int etb_enable_sysfs(struct coresight_device *csdev)
145145
unsigned long flags;
146146
struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
147147

148-
spin_lock_irqsave(&drvdata->spinlock, flags);
148+
raw_spin_lock_irqsave(&drvdata->spinlock, flags);
149149

150150
/* Don't messup with perf sessions. */
151151
if (coresight_get_mode(csdev) == CS_MODE_PERF) {
@@ -163,7 +163,7 @@ static int etb_enable_sysfs(struct coresight_device *csdev)
163163

164164
csdev->refcnt++;
165165
out:
166-
spin_unlock_irqrestore(&drvdata->spinlock, flags);
166+
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
167167
return ret;
168168
}
169169

@@ -176,7 +176,7 @@ static int etb_enable_perf(struct coresight_device *csdev, void *data)
176176
struct perf_output_handle *handle = data;
177177
struct cs_buffers *buf = etm_perf_sink_config(handle);
178178

179-
spin_lock_irqsave(&drvdata->spinlock, flags);
179+
raw_spin_lock_irqsave(&drvdata->spinlock, flags);
180180

181181
/* No need to continue if the component is already in used by sysFS. */
182182
if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS) {
@@ -219,7 +219,7 @@ static int etb_enable_perf(struct coresight_device *csdev, void *data)
219219
}
220220

221221
out:
222-
spin_unlock_irqrestore(&drvdata->spinlock, flags);
222+
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
223223
return ret;
224224
}
225225

@@ -352,11 +352,11 @@ static int etb_disable(struct coresight_device *csdev)
352352
struct etb_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
353353
unsigned long flags;
354354

355-
spin_lock_irqsave(&drvdata->spinlock, flags);
355+
raw_spin_lock_irqsave(&drvdata->spinlock, flags);
356356

357357
csdev->refcnt--;
358358
if (csdev->refcnt) {
359-
spin_unlock_irqrestore(&drvdata->spinlock, flags);
359+
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
360360
return -EBUSY;
361361
}
362362

@@ -366,7 +366,7 @@ static int etb_disable(struct coresight_device *csdev)
366366
/* Dissociate from monitored process. */
367367
drvdata->pid = -1;
368368
coresight_set_mode(csdev, CS_MODE_DISABLED);
369-
spin_unlock_irqrestore(&drvdata->spinlock, flags);
369+
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
370370

371371
dev_dbg(&csdev->dev, "ETB disabled\n");
372372
return 0;
@@ -443,7 +443,7 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev,
443443

444444
capacity = drvdata->buffer_depth * ETB_FRAME_SIZE_WORDS;
445445

446-
spin_lock_irqsave(&drvdata->spinlock, flags);
446+
raw_spin_lock_irqsave(&drvdata->spinlock, flags);
447447

448448
/* Don't do anything if another tracer is using this sink */
449449
if (csdev->refcnt != 1)
@@ -566,7 +566,7 @@ static unsigned long etb_update_buffer(struct coresight_device *csdev,
566566
__etb_enable_hw(drvdata);
567567
CS_LOCK(drvdata->base);
568568
out:
569-
spin_unlock_irqrestore(&drvdata->spinlock, flags);
569+
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
570570

571571
return to_read;
572572
}
@@ -587,13 +587,13 @@ static void etb_dump(struct etb_drvdata *drvdata)
587587
{
588588
unsigned long flags;
589589

590-
spin_lock_irqsave(&drvdata->spinlock, flags);
590+
raw_spin_lock_irqsave(&drvdata->spinlock, flags);
591591
if (coresight_get_mode(drvdata->csdev) == CS_MODE_SYSFS) {
592592
__etb_disable_hw(drvdata);
593593
etb_dump_hw(drvdata);
594594
__etb_enable_hw(drvdata);
595595
}
596-
spin_unlock_irqrestore(&drvdata->spinlock, flags);
596+
raw_spin_unlock_irqrestore(&drvdata->spinlock, flags);
597597

598598
dev_dbg(&drvdata->csdev->dev, "ETB dumped\n");
599599
}
@@ -746,7 +746,7 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id)
746746
drvdata->base = base;
747747
desc.access = CSDEV_ACCESS_IOMEM(base);
748748

749-
spin_lock_init(&drvdata->spinlock);
749+
raw_spin_lock_init(&drvdata->spinlock);
750750

751751
drvdata->buffer_depth = etb_get_buffer_depth(drvdata);
752752

0 commit comments

Comments
 (0)