From patchwork Tue Apr 4 13:53:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13200196 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BCA76C761AF for ; Tue, 4 Apr 2023 13:56:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=5o9w3sOr+04KArf7Uk7m4v4j+CxO7439/TxtJYgVh4E=; b=X84TxzjJo38cNP OttnUoA38aiZEy3W42jGJ95WVBoyvfEai188CbbF6kE69FEXUbS5z9HS/srYwVlq8qlJlhy3vapw5 6t6/uye81AM54U92WKtX0tLqDqDM5R0tiF8HxOhikl77e8JEXRz666qvR+Iqi8dh/EcJuyBDTQkao qyN6X8DyLlp8ERGlylAulsy3r0joGBKyz6+1bKFXE5mYiPByXrUnpn1E0vxU1ofbOxZJKrniyaUFJ VaPuXLaHT5bOR89ByjhNUkEdJPnig62MzQFk+JcNnEryt2KuPnwR3CpqIpymzqmvE6R6Wm52E1q61 86cHT3GE1G8ye06CmyUg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjh7t-001cas-2t; Tue, 04 Apr 2023 13:55:09 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pjh7r-001cYW-21 for linux-arm-kernel@bombadil.infradead.org; Tue, 04 Apr 2023 13:55:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=h+UGS4AX0UF7+z9/iaToLwiU7PtVMuMKa5mCK4214r0=; b=TLiMcSfEN2Kiqv1/QcA0vG8NmL j7z/L3mzZN46YTIkrndn8uXxWh+TqMWqPo29rPO/HAK5Cave77t3tXYmxTdtXq5SKl1IEnKBsX8C3 Yqrr1TW5PEoCX4CtZNT0IXsgWYBx2RaznkNtQZDCkZ9DlGZwEIz1k3fVPekrOMVL8quAPbb04L1Q8 rRxIky1kxObcAGnvzcsNVBWNOHM4pOikdoSawvGphTZlPaMoK0ADBMswmIJJplHhICl4vJJrJcGOj 1WJmo3E2W2Bxgk89FNvkjDEEejc240gBZSff8W4R5/Fbz0a3gx1D6l5BgM85scjNzNx/ihpbsTJNC xXzzpiDA==; Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pjh7n-009HOj-28 for linux-arm-kernel@lists.infradead.org; Tue, 04 Apr 2023 13:55:06 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 144ECFEC; Tue, 4 Apr 2023 06:55:44 -0700 (PDT) Received: from e127643.broadband (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id EA5483F762; Tue, 4 Apr 2023 06:54:57 -0700 (PDT) From: James Clark To: coresight@lists.linaro.org, quic_jinlmao@quicinc.com, mike.leach@linaro.org, suzuki.poulose@arm.com Cc: James Clark , Mathieu Poirier , Leo Yan , Alexander Shishkin , Greg Kroah-Hartman , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 01/13] coresight: Fix loss of connection info when a module is unloaded Date: Tue, 4 Apr 2023 14:53:47 +0100 Message-Id: <20230404135401.1728919-2-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230404135401.1728919-1-james.clark@arm.com> References: <20230404135401.1728919-1-james.clark@arm.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230404_145504_034280_3F8BC644 X-CRM114-Status: GOOD ( 15.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org child_fwnode should be a read only property based on the DT. 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") Signed-off-by: James Clark Tested-by: Suzuki K Poulose --- 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; }