All of lore.kernel.org
 help / color / mirror / Atom feed
From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org,
	coresight@lists.linaro.org, suzuki.poulose@arm.com,
	robert.walker@arm.com, al.grant@arm.com
Subject: [PATCH v2 11/14] coresight: funnel: Claim devices before use
Date: Thu,  6 Sep 2018 10:08:32 +0100	[thread overview]
Message-ID: <1536224915-31766-12-git-send-email-suzuki.poulose@arm.com> (raw)
In-Reply-To: <1536224915-31766-1-git-send-email-suzuki.poulose@arm.com>

Use the CLAIM protocol to grab the ownership of the component.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/hwtracing/coresight/coresight-funnel.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
index ee7a30b..9279251 100644
--- a/drivers/hwtracing/coresight/coresight-funnel.c
+++ b/drivers/hwtracing/coresight/coresight-funnel.c
@@ -25,6 +25,7 @@
 #define FUNNEL_HOLDTIME_MASK	0xf00
 #define FUNNEL_HOLDTIME_SHFT	0x8
 #define FUNNEL_HOLDTIME		(0x7 << FUNNEL_HOLDTIME_SHFT)
+#define FUNNEL_ENSx_MASK	0xff
 
 /**
  * struct funnel_drvdata - specifics associated to a funnel component
@@ -42,31 +43,42 @@ struct funnel_drvdata {
 	unsigned long		priority;
 };
 
-static void funnel_enable_hw(struct funnel_drvdata *drvdata, int port)
+static int funnel_enable_hw(struct funnel_drvdata *drvdata, int port)
 {
 	u32 functl;
+	int rc = 0;
 
 	CS_UNLOCK(drvdata->base);
 
 	functl = readl_relaxed(drvdata->base + FUNNEL_FUNCTL);
+	/* Claim the device only when we enable the first slave */
+	if (!(functl & FUNNEL_ENSx_MASK)) {
+		rc = coresight_claim_device_unlocked(drvdata->base);
+		if (rc)
+			goto done;
+	}
+
 	functl &= ~FUNNEL_HOLDTIME_MASK;
 	functl |= FUNNEL_HOLDTIME;
 	functl |= (1 << port);
 	writel_relaxed(functl, drvdata->base + FUNNEL_FUNCTL);
 	writel_relaxed(drvdata->priority, drvdata->base + FUNNEL_PRICTL);
-
+done:
 	CS_LOCK(drvdata->base);
+	return rc;
 }
 
 static int funnel_enable(struct coresight_device *csdev, int inport,
 			 int outport)
 {
+	int rc;
 	struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
 
-	funnel_enable_hw(drvdata, inport);
+	rc = funnel_enable_hw(drvdata, inport);
 
-	dev_dbg(drvdata->dev, "FUNNEL inport %d enabled\n", inport);
-	return 0;
+	if (!rc)
+		dev_dbg(drvdata->dev, "FUNNEL inport %d enabled\n", inport);
+	return rc;
 }
 
 static void funnel_disable_hw(struct funnel_drvdata *drvdata, int inport)
@@ -79,6 +91,10 @@ static void funnel_disable_hw(struct funnel_drvdata *drvdata, int inport)
 	functl &= ~(1 << inport);
 	writel_relaxed(functl, drvdata->base + FUNNEL_FUNCTL);
 
+	/* Disclaim the device if none of the slaves are now active */
+	if (!(functl & FUNNEL_ENSx_MASK))
+		coresight_disclaim_device_unlocked(drvdata->base);
+
 	CS_LOCK(drvdata->base);
 }
 
-- 
2.7.4


WARNING: multiple messages have this Message-ID (diff)
From: suzuki.poulose@arm.com (Suzuki K Poulose)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 11/14] coresight: funnel: Claim devices before use
Date: Thu,  6 Sep 2018 10:08:32 +0100	[thread overview]
Message-ID: <1536224915-31766-12-git-send-email-suzuki.poulose@arm.com> (raw)
In-Reply-To: <1536224915-31766-1-git-send-email-suzuki.poulose@arm.com>

Use the CLAIM protocol to grab the ownership of the component.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
---
 drivers/hwtracing/coresight/coresight-funnel.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-funnel.c b/drivers/hwtracing/coresight/coresight-funnel.c
index ee7a30b..9279251 100644
--- a/drivers/hwtracing/coresight/coresight-funnel.c
+++ b/drivers/hwtracing/coresight/coresight-funnel.c
@@ -25,6 +25,7 @@
 #define FUNNEL_HOLDTIME_MASK	0xf00
 #define FUNNEL_HOLDTIME_SHFT	0x8
 #define FUNNEL_HOLDTIME		(0x7 << FUNNEL_HOLDTIME_SHFT)
+#define FUNNEL_ENSx_MASK	0xff
 
 /**
  * struct funnel_drvdata - specifics associated to a funnel component
@@ -42,31 +43,42 @@ struct funnel_drvdata {
 	unsigned long		priority;
 };
 
-static void funnel_enable_hw(struct funnel_drvdata *drvdata, int port)
+static int funnel_enable_hw(struct funnel_drvdata *drvdata, int port)
 {
 	u32 functl;
+	int rc = 0;
 
 	CS_UNLOCK(drvdata->base);
 
 	functl = readl_relaxed(drvdata->base + FUNNEL_FUNCTL);
+	/* Claim the device only when we enable the first slave */
+	if (!(functl & FUNNEL_ENSx_MASK)) {
+		rc = coresight_claim_device_unlocked(drvdata->base);
+		if (rc)
+			goto done;
+	}
+
 	functl &= ~FUNNEL_HOLDTIME_MASK;
 	functl |= FUNNEL_HOLDTIME;
 	functl |= (1 << port);
 	writel_relaxed(functl, drvdata->base + FUNNEL_FUNCTL);
 	writel_relaxed(drvdata->priority, drvdata->base + FUNNEL_PRICTL);
-
+done:
 	CS_LOCK(drvdata->base);
+	return rc;
 }
 
 static int funnel_enable(struct coresight_device *csdev, int inport,
 			 int outport)
 {
+	int rc;
 	struct funnel_drvdata *drvdata = dev_get_drvdata(csdev->dev.parent);
 
-	funnel_enable_hw(drvdata, inport);
+	rc = funnel_enable_hw(drvdata, inport);
 
-	dev_dbg(drvdata->dev, "FUNNEL inport %d enabled\n", inport);
-	return 0;
+	if (!rc)
+		dev_dbg(drvdata->dev, "FUNNEL inport %d enabled\n", inport);
+	return rc;
 }
 
 static void funnel_disable_hw(struct funnel_drvdata *drvdata, int inport)
@@ -79,6 +91,10 @@ static void funnel_disable_hw(struct funnel_drvdata *drvdata, int inport)
 	functl &= ~(1 << inport);
 	writel_relaxed(functl, drvdata->base + FUNNEL_FUNCTL);
 
+	/* Disclaim the device if none of the slaves are now active */
+	if (!(functl & FUNNEL_ENSx_MASK))
+		coresight_disclaim_device_unlocked(drvdata->base);
+
 	CS_LOCK(drvdata->base);
 }
 
-- 
2.7.4

  parent reply	other threads:[~2018-09-06  9:09 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-06  9:08 [PATCH v2 00/14] coresight: Implement device claim protocol Suzuki K Poulose
2018-09-06  9:08 ` Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 01/14] coresight: Handle failures in enabling a trace path Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 02/14] coresight: tmc-etr: Refactor for handling errors Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 03/14] coresight: tmc-etr: Handle errors enabling CATU Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 04/14] coresight: tmc-etb/etf: Prepare to handle errors enabling Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 05/14] coresight: etm4x: Add support for handling errors Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 06/14] coresight: etm3: " Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 07/14] coresight: etb10: Handle errors enabling the device Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 08/14] coresight: dynamic-replicator: Handle multiple connections Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 09/14] coresight: Add support for CLAIM tag protocol Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 10/14] coresight: etmx: Claim devices before use Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-06  9:08 ` Suzuki K Poulose [this message]
2018-09-06  9:08   ` [PATCH v2 11/14] coresight: funnel: " Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 12/14] coresight: catu: Claim device " Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 13/14] coresight: dynamic-replicator: Claim device for use Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-06  9:08 ` [PATCH v2 14/14] coreisght: tmc: Claim device before use Suzuki K Poulose
2018-09-06  9:08   ` Suzuki K Poulose
2018-09-12 19:42 ` [PATCH v2 00/14] coresight: Implement device claim protocol Mathieu Poirier
2018-09-12 19:42   ` Mathieu Poirier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1536224915-31766-12-git-send-email-suzuki.poulose@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=al.grant@arm.com \
    --cc=coresight@lists.linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=robert.walker@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.