Skip to content

Commit d11eb31

Browse files
LeviYeoReumSuzuki K Poulose
authored andcommitted
coresight/ultrasoc: change smb_drv_data spinlock's type to raw_spinlock_t
In ultrasoc-smb drivers, smb_drv_data->spinlock can be held during __schedule() by perf_event_task_sched_out()/in(). Since smb__drv_data->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 smb_drv_data->spinlock in ultrasoc-smb drivers, which can be called by perf_event_task_sched_out()/in(), from spinlock_t to raw_spinlock_t. Reviewed-by: James Clark <[email protected]> Signed-off-by: Yeoreum Yun <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent db11f75 commit d11eb31

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

drivers/hwtracing/coresight/ultrasoc-smb.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ static int smb_open(struct inode *inode, struct file *file)
9898
struct smb_drv_data *drvdata = container_of(file->private_data,
9999
struct smb_drv_data, miscdev);
100100

101-
guard(spinlock)(&drvdata->spinlock);
101+
guard(raw_spinlock)(&drvdata->spinlock);
102102

103103
if (drvdata->reading)
104104
return -EBUSY;
@@ -152,7 +152,7 @@ static int smb_release(struct inode *inode, struct file *file)
152152
struct smb_drv_data *drvdata = container_of(file->private_data,
153153
struct smb_drv_data, miscdev);
154154

155-
guard(spinlock)(&drvdata->spinlock);
155+
guard(raw_spinlock)(&drvdata->spinlock);
156156
drvdata->reading = false;
157157

158158
return 0;
@@ -245,7 +245,7 @@ static int smb_enable(struct coresight_device *csdev, enum cs_mode mode,
245245
struct smb_drv_data *drvdata = dev_get_drvdata(csdev->dev.parent);
246246
int ret = 0;
247247

248-
guard(spinlock)(&drvdata->spinlock);
248+
guard(raw_spinlock)(&drvdata->spinlock);
249249

250250
/* Do nothing, the trace data is reading by other interface now */
251251
if (drvdata->reading)
@@ -280,7 +280,7 @@ static int smb_disable(struct coresight_device *csdev)
280280
{
281281
struct smb_drv_data *drvdata = dev_get_drvdata(csdev->dev.parent);
282282

283-
guard(spinlock)(&drvdata->spinlock);
283+
guard(raw_spinlock)(&drvdata->spinlock);
284284

285285
if (drvdata->reading)
286286
return -EBUSY;
@@ -378,7 +378,7 @@ static unsigned long smb_update_buffer(struct coresight_device *csdev,
378378
if (!buf)
379379
return 0;
380380

381-
guard(spinlock)(&drvdata->spinlock);
381+
guard(raw_spinlock)(&drvdata->spinlock);
382382

383383
/* Don't do anything if another tracer is using this sink. */
384384
if (csdev->refcnt != 1)
@@ -563,7 +563,7 @@ static int smb_probe(struct platform_device *pdev)
563563

564564
smb_reset_buffer(drvdata);
565565
platform_set_drvdata(pdev, drvdata);
566-
spin_lock_init(&drvdata->spinlock);
566+
raw_spin_lock_init(&drvdata->spinlock);
567567
drvdata->pid = -1;
568568

569569
ret = smb_register_sink(pdev, drvdata);

drivers/hwtracing/coresight/ultrasoc-smb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct smb_drv_data {
115115
struct coresight_device *csdev;
116116
struct smb_data_buffer sdb;
117117
struct miscdevice miscdev;
118-
spinlock_t spinlock;
118+
raw_spinlock_t spinlock;
119119
bool reading;
120120
pid_t pid;
121121
};

0 commit comments

Comments
 (0)