From patchwork Wed Mar 29 11:53:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Clark X-Patchwork-Id: 13192329 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 85DFFC6FD18 for ; Wed, 29 Mar 2023 11:55:44 +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=wxFbNUpobAUfDYzPy6eNz3mOnS3iM6aKOmYonBke0Fk=; b=R4kZUJwmTaqrA+ Taip/J1RCKbqIJfl6GpR6trrZVI55FWYrK9AjsXOz6z4pZgBSMTi0EY0Ho0ymHxsHDCONtCqISso0 c5Z+iS0P492wRfRvVMC6WREwGEhTSzvVTELytnHWCEdgcQcOdekxdja9EpWwrNZoTfYzQsd9mjr+I ZXdkCUVahqW2fa1YKchH8oHIFc6keSPpkMIVys0Fs84zHzI7XQMrWzvP9ecd7+86I+fGkMneeMVHL fRurgI6O5wWIBpzscG7FcSVIzi/rwr+GcZG24Yrmz7cPqg+NvGaUvcTdgw4zAVht0sQ7rUPAoIR9K ydH2pkBlGoTwYrrJW+2w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1phUOB-0004JF-0u; Wed, 29 Mar 2023 11:54:51 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1phUNd-00043s-1X for linux-arm-kernel@lists.infradead.org; Wed, 29 Mar 2023 11:54:19 +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 76E411570; Wed, 29 Mar 2023 04:54:59 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 5E0A73F6C4; Wed, 29 Mar 2023 04:54:13 -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 , Maxime Coquelin , Alexandre Torgue , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com Subject: [PATCH v3 06/13] coresight: Fix loss of connection info when a module is unloaded Date: Wed, 29 Mar 2023 12:53:19 +0100 Message-Id: <20230329115329.2747724-7-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230329115329.2747724-1-james.clark@arm.com> References: <20230329115329.2747724-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-20230329_045417_564460_428C0E77 X-CRM114-Status: GOOD ( 15.72 ) 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. Signed-off-by: James Clark --- drivers/hwtracing/coresight/coresight-core.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c index bfe1b93aca4e..12cbb68e8e1c 100644 --- a/drivers/hwtracing/coresight/coresight-core.c +++ b/drivers/hwtracing/coresight/coresight-core.c @@ -1414,13 +1414,8 @@ static int coresight_remove_match(struct device *dev, void *data) if (csdev->dev.fwnode == conn->dest_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->dest_fwnode); - conn->dest_fwnode = NULL; + + conn->dest_dev = NULL; /* No need to continue */ break; } @@ -1553,7 +1548,6 @@ void coresight_release_platform_data(struct coresight_device *csdev, * is going away */ fwnode_handle_put(conns[i].dest_fwnode); - pdata->out_conns[i].dest_fwnode = NULL; } if (csdev) coresight_remove_conns_sysfs_group(csdev);