[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241125094816.365472-8-yeoreum.yun@arm.com>
Date: Mon, 25 Nov 2024 09:48:14 +0000
From: Yeoreum Yun <yeoreum.yun@....com>
To: suzuki.poulose@....com,
mike.leach@...aro.org,
james.clark@...aro.org,
alexander.shishkin@...ux.intel.com,
bigeasy@...utronix.de,
clrkwllms@...nel.org,
rostedt@...dmis.org
Cc: coresight@...ts.linaro.org,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org,
linux-rt-devel@...ts.linux.dev,
nd@....com,
Levi Yun <yeoreum.yun@....com>
Subject: [PATCH 7/9] coresight-replicator: change replicator_drvdata spinlock's type to raw_spinlock_t
From: Levi Yun <yeoreum.yun@....com>
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.
Signed-off-by: Yeoreum Yun <yeoreum.yun@....com>
---
.../coresight/coresight-replicator.c | 36 +++++++++----------
1 file changed, 17 insertions(+), 19 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-replicator.c b/drivers/hwtracing/coresight/coresight-replicator.c
index 3e55be9c8418..7ff08fb70758 100644
--- a/drivers/hwtracing/coresight/coresight-replicator.c
+++ b/drivers/hwtracing/coresight/coresight-replicator.c
@@ -41,7 +41,7 @@ struct replicator_drvdata {
struct clk *atclk;
struct clk *pclk;
struct coresight_device *csdev;
- spinlock_t spinlock;
+ raw_spinlock_t spinlock;
bool check_idfilter_val;
};
@@ -122,20 +122,19 @@ static int replicator_enable(struct coresight_device *csdev,
{
int rc = 0;
struct replicator_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
- unsigned long flags;
bool first_enable = false;
- spin_lock_irqsave(&drvdata->spinlock, flags);
+ scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock) {
if (atomic_read(&out->src_refcnt) == 0) {
- if (drvdata->base)
- rc = dynamic_replicator_enable(drvdata, in->dest_port,
- out->src_port);
+ if (drvdata->base)
+ rc = dynamic_replicator_enable(drvdata, in->dest_port,
+ out->src_port);
+ if (!rc)
+ first_enable = true;
+ }
if (!rc)
- first_enable = true;
+ atomic_inc(&out->src_refcnt);
}
- if (!rc)
- atomic_inc(&out->src_refcnt);
- spin_unlock_irqrestore(&drvdata->spinlock, flags);
if (first_enable)
dev_dbg(&csdev->dev, "REPLICATOR enabled\n");
@@ -176,17 +175,16 @@ static void replicator_disable(struct coresight_device *csdev,
struct coresight_connection *out)
{
struct replicator_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
- unsigned long flags;
bool last_disable = false;
- spin_lock_irqsave(&drvdata->spinlock, flags);
- if (atomic_dec_return(&out->src_refcnt) == 0) {
- if (drvdata->base)
- dynamic_replicator_disable(drvdata, in->dest_port,
- out->src_port);
- last_disable = true;
+ scoped_guard(raw_spinlock_irqsave, &drvdata->spinlock) {
+ if (atomic_dec_return(&out->src_refcnt) == 0) {
+ if (drvdata->base)
+ dynamic_replicator_disable(drvdata, in->dest_port,
+ out->src_port);
+ last_disable = true;
+ }
}
- spin_unlock_irqrestore(&drvdata->spinlock, flags);
if (last_disable)
dev_dbg(&csdev->dev, "REPLICATOR disabled\n");
@@ -277,7 +275,7 @@ static int replicator_probe(struct device *dev, struct resource *res)
}
dev->platform_data = pdata;
- spin_lock_init(&drvdata->spinlock);
+ raw_spin_lock_init(&drvdata->spinlock);
desc.type = CORESIGHT_DEV_TYPE_LINK;
desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_SPLIT;
desc.ops = &replicator_cs_ops;
--
LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}
Powered by blists - more mailing lists