Skip to content

Commit 5aec7c0

Browse files
james-c-linaroSuzuki K Poulose
authored andcommitted
coresight: Drop atomics in connection refcounts
These belong to the device being enabled or disabled and are only ever used inside the device's spinlock. Remove the atomics to not imply that there are any other concurrent accesses. If atomics were necessary I don't think they would have been enough anyway. There would be nothing to prevent an enable or disable running concurrently if not for the spinlock. Signed-off-by: James Clark <[email protected]> Reviewed-by: Yeoreum Yun <[email protected]> Signed-off-by: Suzuki K Poulose <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent c8ea5f4 commit 5aec7c0

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

drivers/hwtracing/coresight/coresight-funnel.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,14 @@ static int funnel_enable(struct coresight_device *csdev,
8686
bool first_enable = false;
8787

8888
spin_lock_irqsave(&drvdata->spinlock, flags);
89-
if (atomic_read(&in->dest_refcnt) == 0) {
89+
if (in->dest_refcnt == 0) {
9090
if (drvdata->base)
9191
rc = dynamic_funnel_enable_hw(drvdata, in->dest_port);
9292
if (!rc)
9393
first_enable = true;
9494
}
9595
if (!rc)
96-
atomic_inc(&in->dest_refcnt);
96+
in->dest_refcnt++;
9797
spin_unlock_irqrestore(&drvdata->spinlock, flags);
9898

9999
if (first_enable)
@@ -130,7 +130,7 @@ static void funnel_disable(struct coresight_device *csdev,
130130
bool last_disable = false;
131131

132132
spin_lock_irqsave(&drvdata->spinlock, flags);
133-
if (atomic_dec_return(&in->dest_refcnt) == 0) {
133+
if (--in->dest_refcnt == 0) {
134134
if (drvdata->base)
135135
dynamic_funnel_disable_hw(drvdata, in->dest_port);
136136
last_disable = true;

drivers/hwtracing/coresight/coresight-replicator.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ static int replicator_enable(struct coresight_device *csdev,
126126
bool first_enable = false;
127127

128128
spin_lock_irqsave(&drvdata->spinlock, flags);
129-
if (atomic_read(&out->src_refcnt) == 0) {
129+
if (out->src_refcnt == 0) {
130130
if (drvdata->base)
131131
rc = dynamic_replicator_enable(drvdata, in->dest_port,
132132
out->src_port);
133133
if (!rc)
134134
first_enable = true;
135135
}
136136
if (!rc)
137-
atomic_inc(&out->src_refcnt);
137+
out->src_refcnt++;
138138
spin_unlock_irqrestore(&drvdata->spinlock, flags);
139139

140140
if (first_enable)
@@ -180,7 +180,7 @@ static void replicator_disable(struct coresight_device *csdev,
180180
bool last_disable = false;
181181

182182
spin_lock_irqsave(&drvdata->spinlock, flags);
183-
if (atomic_dec_return(&out->src_refcnt) == 0) {
183+
if (--out->src_refcnt == 0) {
184184
if (drvdata->base)
185185
dynamic_replicator_disable(drvdata, in->dest_port,
186186
out->src_port);

drivers/hwtracing/coresight/coresight-tpda.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,10 @@ static int tpda_enable(struct coresight_device *csdev,
190190
int ret = 0;
191191

192192
spin_lock(&drvdata->spinlock);
193-
if (atomic_read(&in->dest_refcnt) == 0) {
193+
if (in->dest_refcnt == 0) {
194194
ret = __tpda_enable(drvdata, in->dest_port);
195195
if (!ret) {
196-
atomic_inc(&in->dest_refcnt);
196+
in->dest_refcnt++;
197197
csdev->refcnt++;
198198
dev_dbg(drvdata->dev, "TPDA inport %d enabled.\n", in->dest_port);
199199
}
@@ -223,7 +223,7 @@ static void tpda_disable(struct coresight_device *csdev,
223223
struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
224224

225225
spin_lock(&drvdata->spinlock);
226-
if (atomic_dec_return(&in->dest_refcnt) == 0) {
226+
if (--in->dest_refcnt == 0) {
227227
__tpda_disable(drvdata, in->dest_port);
228228
csdev->refcnt--;
229229
}

include/linux/coresight.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ struct coresight_connection {
200200
struct coresight_device *dest_dev;
201201
struct coresight_sysfs_link *link;
202202
struct coresight_device *src_dev;
203-
atomic_t src_refcnt;
204-
atomic_t dest_refcnt;
203+
int src_refcnt;
204+
int dest_refcnt;
205205
};
206206

207207
/**

0 commit comments

Comments
 (0)