Skip to content

Commit 26f060c

Browse files
LeviYeoReumSuzuki K Poulose
authored andcommitted
coresight: change coresight_device lock type to raw_spinlock_t
coresight_device->cscfg_csdev_lock can be held during __schedule() by perf_event_task_sched_out()/in(). Since coresight->cscfg_csdev_lock 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 of coresight_device->cscfg_csdev_lock 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-2-yeoreum.yun@arm.com
1 parent ab37128 commit 26f060c

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

drivers/hwtracing/coresight/coresight-syscfg.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ static int cscfg_add_csdev_cfg(struct coresight_device *csdev,
8989
}
9090
/* if matched features, add config to device.*/
9191
if (config_csdev) {
92-
spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
92+
raw_spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
9393
list_add(&config_csdev->node, &csdev->config_csdev_list);
94-
spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
94+
raw_spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
9595
}
9696

9797
return 0;
@@ -194,9 +194,9 @@ static int cscfg_load_feat_csdev(struct coresight_device *csdev,
194194

195195
/* add to internal csdev feature list & initialise using reset call */
196196
cscfg_reset_feat(feat_csdev);
197-
spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
197+
raw_spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
198198
list_add(&feat_csdev->node, &csdev->feature_csdev_list);
199-
spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
199+
raw_spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
200200

201201
return 0;
202202
}
@@ -765,7 +765,7 @@ static int cscfg_list_add_csdev(struct coresight_device *csdev,
765765

766766
INIT_LIST_HEAD(&csdev->feature_csdev_list);
767767
INIT_LIST_HEAD(&csdev->config_csdev_list);
768-
spin_lock_init(&csdev->cscfg_csdev_lock);
768+
raw_spin_lock_init(&csdev->cscfg_csdev_lock);
769769

770770
return 0;
771771
}
@@ -855,15 +855,15 @@ void cscfg_csdev_reset_feats(struct coresight_device *csdev)
855855
struct cscfg_feature_csdev *feat_csdev;
856856
unsigned long flags;
857857

858-
spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
858+
raw_spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
859859
if (list_empty(&csdev->feature_csdev_list))
860860
goto unlock_exit;
861861

862862
list_for_each_entry(feat_csdev, &csdev->feature_csdev_list, node)
863863
cscfg_reset_feat(feat_csdev);
864864

865865
unlock_exit:
866-
spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
866+
raw_spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
867867
}
868868
EXPORT_SYMBOL_GPL(cscfg_csdev_reset_feats);
869869

@@ -1059,7 +1059,7 @@ int cscfg_csdev_enable_active_config(struct coresight_device *csdev,
10591059
* Look for matching configuration - set the active configuration
10601060
* context if found.
10611061
*/
1062-
spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
1062+
raw_spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
10631063
list_for_each_entry(config_csdev_item, &csdev->config_csdev_list, node) {
10641064
config_desc = config_csdev_item->config_desc;
10651065
if ((atomic_read(&config_desc->active_cnt)) &&
@@ -1069,7 +1069,7 @@ int cscfg_csdev_enable_active_config(struct coresight_device *csdev,
10691069
break;
10701070
}
10711071
}
1072-
spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
1072+
raw_spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
10731073

10741074
/*
10751075
* If found, attempt to enable
@@ -1090,12 +1090,12 @@ int cscfg_csdev_enable_active_config(struct coresight_device *csdev,
10901090
*
10911091
* Set enabled if OK, err if not.
10921092
*/
1093-
spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
1093+
raw_spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
10941094
if (csdev->active_cscfg_ctxt)
10951095
config_csdev_active->enabled = true;
10961096
else
10971097
err = -EBUSY;
1098-
spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
1098+
raw_spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
10991099
}
11001100
}
11011101
return err;
@@ -1124,7 +1124,7 @@ void cscfg_csdev_disable_active_config(struct coresight_device *csdev)
11241124
* If it was not enabled, we have no work to do, otherwise mark as disabled.
11251125
* Clear the active config pointer.
11261126
*/
1127-
spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
1127+
raw_spin_lock_irqsave(&csdev->cscfg_csdev_lock, flags);
11281128
config_csdev = (struct cscfg_config_csdev *)csdev->active_cscfg_ctxt;
11291129
if (config_csdev) {
11301130
if (!config_csdev->enabled)
@@ -1133,7 +1133,7 @@ void cscfg_csdev_disable_active_config(struct coresight_device *csdev)
11331133
config_csdev->enabled = false;
11341134
}
11351135
csdev->active_cscfg_ctxt = NULL;
1136-
spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
1136+
raw_spin_unlock_irqrestore(&csdev->cscfg_csdev_lock, flags);
11371137

11381138
/* true if there was an enabled active config */
11391139
if (config_csdev)

include/linux/coresight.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ struct coresight_device {
302302
/* system configuration and feature lists */
303303
struct list_head feature_csdev_list;
304304
struct list_head config_csdev_list;
305-
spinlock_t cscfg_csdev_lock;
305+
raw_spinlock_t cscfg_csdev_lock;
306306
void *active_cscfg_ctxt;
307307
};
308308

0 commit comments

Comments
 (0)