Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp487129rwl; Wed, 29 Mar 2023 04:59:18 -0700 (PDT) X-Google-Smtp-Source: AKy350YWEeLHr/Fuzli2XI6l3+Lea6c3xSiIrqoRzVKZtID4NPcA7KNpw4l0pudJe+6/eZ+WO/YY X-Received: by 2002:a17:906:3148:b0:930:fa8e:9597 with SMTP id e8-20020a170906314800b00930fa8e9597mr19182146eje.42.1680091158605; Wed, 29 Mar 2023 04:59:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680091158; cv=none; d=google.com; s=arc-20160816; b=rYK7Zb/Kh8/lClVqIZU7B/7ogmA6Tr7q6TWiYr7rrDhq2pzISsr0MHSkFx3nU10NNJ eAa7JyqXmWvP8GGiRoPnsr1Nr4WHHSBSw9jUap6XAMxBhbY5CEciO18GFo2IypLLTI5b RKzrOkhk/W7i1syZfly9xATFMohw70isvwdiBEvibSJb10S61npGDKFFyKTnOZiFLHvE j+Edip+FsDVXZu2JY3qd292D6nU+FLz3UQvfND7fDzflYa6xGuOZzHYSNW+vR0qFT5C2 Bh4/pHf3e367Hu+EBXxL7kJnMCXhLhBx4Qu5QtJ7NGg8KQLnhSLiS/zoQHP4A2WqUkO2 EY9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gVOpOAvsYihvsANhNdrTvN1Jh+7R3BneJAQMMFlWhyI=; b=OqHEIfnOy7ySOWE3jWHlfTPG5jQxT6nPVi5cmRwKKUM6hPDfTHis89m3PJb/CY9bsC Qb9THgQI/T3CNOp3ROANALB19N/ZqoSlNL5bwRBXQbaN7wp2duZV92fXtQCqIDWm6K+3 g4Se6XwSzw5bhzKQMdg1p4ApjTJjCKXOyoWNginJnuCXu17K5uOBrkdfyiI+pVaDnYus sAI2X3OQ04IeebhO83Ded7YuawEETXlgfWIRbwxLhJe7wgNCV1xR8YjxPn5besy4TTUc piA7fAisTaQtp5NQbLFZ1S59nKpoqkgzKWmHulwj2ffyQEoeK/gaHUqO/Jr8mXbytBw0 BKXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oz18-20020a1709077d9200b0093a35d77d78si24463915ejc.843.2023.03.29.04.58.54; Wed, 29 Mar 2023 04:59:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229963AbjC2Lyo (ORCPT + 99 others); Wed, 29 Mar 2023 07:54:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229984AbjC2Lye (ORCPT ); Wed, 29 Mar 2023 07:54:34 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BABDC4C09 for ; Wed, 29 Mar 2023 04:54:15 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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); -- 2.34.1