]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
coresight: Drop atomics in connection refcounts
authorJames Clark <james.clark@linaro.org>
Thu, 28 Nov 2024 12:14:14 +0000 (12:14 +0000)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Wed, 11 Dec 2024 10:15:25 +0000 (10:15 +0000)
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 <james.clark@linaro.org>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20241128121414.2425119-1-james.clark@linaro.org
drivers/hwtracing/coresight/coresight-funnel.c
drivers/hwtracing/coresight/coresight-replicator.c
drivers/hwtracing/coresight/coresight-tpda.c
include/linux/coresight.h

index 33efe1acbef754caf521ab94f1282103b9ea1744..8faf51469bb8ce6cc1b739d62fd5b3fc8484659a 100644 (file)
@@ -86,14 +86,14 @@ static int funnel_enable(struct coresight_device *csdev,
        bool first_enable = false;
 
        spin_lock_irqsave(&drvdata->spinlock, flags);
-       if (atomic_read(&in->dest_refcnt) == 0) {
+       if (in->dest_refcnt == 0) {
                if (drvdata->base)
                        rc = dynamic_funnel_enable_hw(drvdata, in->dest_port);
                if (!rc)
                        first_enable = true;
        }
        if (!rc)
-               atomic_inc(&in->dest_refcnt);
+               in->dest_refcnt++;
        spin_unlock_irqrestore(&drvdata->spinlock, flags);
 
        if (first_enable)
@@ -130,7 +130,7 @@ static void funnel_disable(struct coresight_device *csdev,
        bool last_disable = false;
 
        spin_lock_irqsave(&drvdata->spinlock, flags);
-       if (atomic_dec_return(&in->dest_refcnt) == 0) {
+       if (--in->dest_refcnt == 0) {
                if (drvdata->base)
                        dynamic_funnel_disable_hw(drvdata, in->dest_port);
                last_disable = true;
index 0fba87de6d1af3a42a16c973ffcc82cdb7d43094..a1181c9048c08e580d6a14db5c4b72d0d924c49f 100644 (file)
@@ -126,7 +126,7 @@ static int replicator_enable(struct coresight_device *csdev,
        bool first_enable = false;
 
        spin_lock_irqsave(&drvdata->spinlock, flags);
-       if (atomic_read(&out->src_refcnt) == 0) {
+       if (out->src_refcnt == 0) {
                if (drvdata->base)
                        rc = dynamic_replicator_enable(drvdata, in->dest_port,
                                                       out->src_port);
@@ -134,7 +134,7 @@ static int replicator_enable(struct coresight_device *csdev,
                        first_enable = true;
        }
        if (!rc)
-               atomic_inc(&out->src_refcnt);
+               out->src_refcnt++;
        spin_unlock_irqrestore(&drvdata->spinlock, flags);
 
        if (first_enable)
@@ -180,7 +180,7 @@ static void replicator_disable(struct coresight_device *csdev,
        bool last_disable = false;
 
        spin_lock_irqsave(&drvdata->spinlock, flags);
-       if (atomic_dec_return(&out->src_refcnt) == 0) {
+       if (--out->src_refcnt == 0) {
                if (drvdata->base)
                        dynamic_replicator_disable(drvdata, in->dest_port,
                                                   out->src_port);
index bfca103f9f84763836297d07c2e523c1583e9446..4ec676bea1ceadabe6ca6cf3da8548e2f232062f 100644 (file)
@@ -190,10 +190,10 @@ static int tpda_enable(struct coresight_device *csdev,
        int ret = 0;
 
        spin_lock(&drvdata->spinlock);
-       if (atomic_read(&in->dest_refcnt) == 0) {
+       if (in->dest_refcnt == 0) {
                ret = __tpda_enable(drvdata, in->dest_port);
                if (!ret) {
-                       atomic_inc(&in->dest_refcnt);
+                       in->dest_refcnt++;
                        csdev->refcnt++;
                        dev_dbg(drvdata->dev, "TPDA inport %d enabled.\n", in->dest_port);
                }
@@ -223,7 +223,7 @@ static void tpda_disable(struct coresight_device *csdev,
        struct tpda_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
 
        spin_lock(&drvdata->spinlock);
-       if (atomic_dec_return(&in->dest_refcnt) == 0) {
+       if (--in->dest_refcnt == 0) {
                __tpda_disable(drvdata, in->dest_port);
                csdev->refcnt--;
        }
index c1334259427850173ccc5872a6ced550a99f8e1c..834029cb9ba2c6fc9c8a47c7cc401c5fe0dc63a2 100644 (file)
@@ -200,8 +200,8 @@ struct coresight_connection {
        struct coresight_device *dest_dev;
        struct coresight_sysfs_link *link;
        struct coresight_device *src_dev;
-       atomic_t src_refcnt;
-       atomic_t dest_refcnt;
+       int src_refcnt;
+       int dest_refcnt;
 };
 
 /**