mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: James Clark <james.clark@arm.com>
To: coresight@lists.linaro.org, quic_jinlmao@quicinc.com,
	mike.leach@linaro.org, suzuki.poulose@arm.com
Cc: James Clark <james.clark@arm.com>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Leo Yan <leo.yan@linaro.org>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v5 01/13] coresight: Fix loss of connection info when a module is unloaded
Date: Tue,  4 Apr 2023 16:51:07 +0100	[thread overview]
Message-ID: <20230404155121.1824126-2-james.clark@arm.com> (raw)
In-Reply-To: <20230404155121.1824126-1-james.clark@arm.com>

child_fwnode should be a read only property based on the DT or ACPI. If
it's cleared on the parent device when a child is unloaded, then when
the child is loaded again the connection won't be remade.

child_dev should be cleared instead which signifies that the connection
should be remade when the child_fwnode registers a new coresight_device.

Similarly the reference count shouldn't be decremented as long as the
parent device exists. The correct place to drop the reference is in
coresight_release_platform_data() which is already done.

Reproducible on Juno with the following steps:

  # load all coresight modules.
  $ cd /sys/bus/coresight/devices/
  $ echo 1 > tmc_etr0/enable_sink
  $ echo 1 > etm0/enable_source
  # Works fine ^

  $ echo 0 > etm0/enable_source
  $ rmmod coresight-funnel
  $ modprobe coresight-funnel
  $ echo 1 > etm0/enable_source
  -bash: echo: write error: Invalid argument

Fixes: 37ea1ffddffa ("coresight: Use fwnode handle instead of device names")
Fixes: 2af89ebacf29 ("coresight: Clear the connection field properly")
Tested-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: James Clark <james.clark@arm.com>
---
 drivers/hwtracing/coresight/coresight-core.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index d3bf82c0de1d..5733294ce5cd 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -1419,13 +1419,8 @@ static int coresight_remove_match(struct device *dev, void *data)
 		if (csdev->dev.fwnode == conn->child_fwnode) {
 			iterator->orphan = true;
 			coresight_remove_links(iterator, conn);
-			/*
-			 * Drop the reference to the handle for the remote
-			 * device acquired in parsing the connections from
-			 * platform data.
-			 */
-			fwnode_handle_put(conn->child_fwnode);
-			conn->child_fwnode = NULL;
+
+			conn->child_dev = NULL;
 			/* No need to continue */
 			break;
 		}
-- 
2.34.1


  reply	other threads:[~2023-04-04 15:52 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-04 15:51 [PATCH v5 00/13] coresight: Fix CTI module refcount leak by making it a helper device James Clark
2023-04-04 15:51 ` James Clark [this message]
2023-04-12 13:12   ` [PATCH v5 01/13] coresight: Fix loss of connection info when a module is unloaded Mike Leach
2023-04-04 15:51 ` [PATCH v5 02/13] coresight: Use enum type for cs_mode wherever possible James Clark
2023-04-04 15:51 ` [PATCH v5 03/13] coresight: Change name of pdata->conns James Clark
2023-04-04 15:51 ` [PATCH v5 04/13] coresight: Rename nr_outports to nr_outconns James Clark
2023-04-04 15:51 ` [PATCH v5 05/13] coresight: Rename connection members to make the direction explicit James Clark
2023-04-12 13:32   ` Mike Leach
2023-04-04 15:51 ` [PATCH v5 06/13] coresight: Dynamically add connections James Clark
2023-04-12 14:35   ` Mike Leach
2023-04-04 15:51 ` [PATCH v5 07/13] coresight: Store pointers to connections rather than an array of them James Clark
2023-04-12 14:49   ` Mike Leach
2023-04-04 15:51 ` [PATCH v5 08/13] coresight: Simplify connection fixup mechanism James Clark
2023-04-12 14:55   ` Mike Leach
2023-04-04 15:51 ` [PATCH v5 09/13] coresight: Store in-connections as well as out-connections James Clark
2023-04-12 15:17   ` Mike Leach
2023-04-04 15:51 ` [PATCH v5 10/13] coresight: Make refcount a property of the connection James Clark
2023-04-12 15:57   ` Mike Leach
2023-04-04 15:51 ` [PATCH v5 11/13] coresight: Refactor out buffer allocation function for ETR James Clark
2023-04-12 16:06   ` Mike Leach
2023-04-04 15:51 ` [PATCH v5 12/13] coresight: Enable and disable helper devices adjacent to the path James Clark
2023-04-17 12:00   ` Mike Leach
2023-04-04 15:51 ` [PATCH v5 13/13] coresight: Fix CTI module refcount leak by making it a helper device James Clark
2023-04-17 13:36   ` Mike Leach
2023-04-24 10:43   ` Suzuki K Poulose
2023-04-24 11:09     ` James Clark
2023-04-24 13:22       ` Suzuki K Poulose
2023-04-25 14:41         ` James Clark

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=20230404155121.1824126-2-james.clark@arm.com \
    --to=james.clark@arm.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=coresight@lists.linaro.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=leo.yan@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=mike.leach@linaro.org \
    --cc=quic_jinlmao@quicinc.com \
    --cc=suzuki.poulose@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®