coresight: etm4x: Improve usability of sysfs - CID and VMID masks.
authorMike Leach <mike.leach@linaro.org>
Mon, 4 Nov 2019 18:12:46 +0000 (11:12 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 4 Nov 2019 20:57:55 +0000 (21:57 +0100)
Context ID and VM ID masks required 2 value inputs, even when the
second value is ignored as insufficient CID / VMID comparators are
implemented.

Permit a single value to be used if that is sufficient to cover all
implemented comparators.

Signed-off-by: Mike Leach <mike.leach@linaro.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Link: https://lore.kernel.org/r/20191104181251.26732-10-mathieu.poirier@linaro.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c

index 8c056dd1a55ee2e2a3d61f00d1572cc5b125add7..1cfbddda0b4db60e0db6636e466360411371c336 100644 (file)
@@ -1794,6 +1794,7 @@ static ssize_t ctxid_masks_store(struct device *dev,
        unsigned long val1, val2, mask;
        struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
        struct etmv4_config *config = &drvdata->config;
+       int nr_inputs;
 
        /*
         * Don't use contextID tracing if coming from a PID namespace.  See
@@ -1809,7 +1810,9 @@ static ssize_t ctxid_masks_store(struct device *dev,
         */
        if (!drvdata->ctxid_size || !drvdata->numcidc)
                return -EINVAL;
-       if (sscanf(buf, "%lx %lx", &val1, &val2) != 2)
+       /* one mask if <= 4 comparators, two for up to 8 */
+       nr_inputs = sscanf(buf, "%lx %lx", &val1, &val2);
+       if ((drvdata->numcidc > 4) && (nr_inputs != 2))
                return -EINVAL;
 
        spin_lock(&drvdata->spinlock);
@@ -1983,6 +1986,7 @@ static ssize_t vmid_masks_store(struct device *dev,
        unsigned long val1, val2, mask;
        struct etmv4_drvdata *drvdata = dev_get_drvdata(dev->parent);
        struct etmv4_config *config = &drvdata->config;
+       int nr_inputs;
 
        /*
         * only implemented when vmid tracing is enabled, i.e. at least one
@@ -1990,7 +1994,9 @@ static ssize_t vmid_masks_store(struct device *dev,
         */
        if (!drvdata->vmid_size || !drvdata->numvmidc)
                return -EINVAL;
-       if (sscanf(buf, "%lx %lx", &val1, &val2) != 2)
+       /* one mask if <= 4 comparators, two for up to 8 */
+       nr_inputs = sscanf(buf, "%lx %lx", &val1, &val2);
+       if ((drvdata->numvmidc > 4) && (nr_inputs != 2))
                return -EINVAL;
 
        spin_lock(&drvdata->spinlock);