coresight: configuring ETF in FIFO mode when acting as link
authorMathieu Poirier <mathieu.poirier@linaro.org>
Tue, 3 May 2016 17:34:00 +0000 (11:34 -0600)
committerMathieu Poirier <mathieu.poirier@linaro.org>
Wed, 1 Jun 2016 21:46:43 +0000 (15:46 -0600)
When part of a path but not identified as a sink, the EFT has to
be configured as a link and placed in HW FIFO mode.  As such when
enabling a path, call the right configuration function based on
the role the ETF if playing in this trace run.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit dc2c4ef141c5c14cb8d968ba16c74b4f3c373e2c)

drivers/hwtracing/coresight/coresight.c

index 0995df8f85bc543f260138f7ab3cf4bf5ef59025..5443d03a1eec4b09feedd4be794d7ef5d2c2dca4 100644 (file)
@@ -265,15 +265,27 @@ static void coresight_disable_source(struct coresight_device *csdev)
 
 void coresight_disable_path(struct list_head *path)
 {
+       u32 type;
        struct coresight_node *nd;
        struct coresight_device *csdev, *parent, *child;
 
        list_for_each_entry(nd, path, link) {
                csdev = nd->csdev;
+               type = csdev->type;
 
-               switch (csdev->type) {
+               /*
+                * ETF devices are tricky... They can be a link or a sink,
+                * depending on how they are configured.  If an ETF has been
+                * "activated" it will be configured as a sink, otherwise
+                * go ahead with the link configuration.
+                */
+               if (type == CORESIGHT_DEV_TYPE_LINKSINK)
+                       type = (csdev == coresight_get_sink(path)) ?
+                                               CORESIGHT_DEV_TYPE_SINK :
+                                               CORESIGHT_DEV_TYPE_LINK;
+
+               switch (type) {
                case CORESIGHT_DEV_TYPE_SINK:
-               case CORESIGHT_DEV_TYPE_LINKSINK:
                        coresight_disable_sink(csdev);
                        break;
                case CORESIGHT_DEV_TYPE_SOURCE:
@@ -294,15 +306,27 @@ int coresight_enable_path(struct list_head *path, u32 mode)
 {
 
        int ret = 0;
+       u32 type;
        struct coresight_node *nd;
        struct coresight_device *csdev, *parent, *child;
 
        list_for_each_entry_reverse(nd, path, link) {
                csdev = nd->csdev;
+               type = csdev->type;
+
+               /*
+                * ETF devices are tricky... They can be a link or a sink,
+                * depending on how they are configured.  If an ETF has been
+                * "activated" it will be configured as a sink, otherwise
+                * go ahead with the link configuration.
+                */
+               if (type == CORESIGHT_DEV_TYPE_LINKSINK)
+                       type = (csdev == coresight_get_sink(path)) ?
+                                               CORESIGHT_DEV_TYPE_SINK :
+                                               CORESIGHT_DEV_TYPE_LINK;
 
-               switch (csdev->type) {
+               switch (type) {
                case CORESIGHT_DEV_TYPE_SINK:
-               case CORESIGHT_DEV_TYPE_LINKSINK:
                        ret = coresight_enable_sink(csdev, mode);
                        if (ret)
                                goto err;