Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp6021426rwl; Tue, 4 Apr 2023 06:56:32 -0700 (PDT) X-Google-Smtp-Source: AKy350YxjZRgF0ejhsQrEZiRfre0eIJWL8QiHbGH6NvPH0KZ4Xkif1SsOf5OSsIujNus79IjpHu6 X-Received: by 2002:a17:907:20aa:b0:931:9cd2:c214 with SMTP id pw10-20020a17090720aa00b009319cd2c214mr2351539ejb.66.1680616592365; Tue, 04 Apr 2023 06:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680616592; cv=none; d=google.com; s=arc-20160816; b=jiumaELJ8FJLEzuRvdOqBxY+0VyA/Rr7PwEDkFZEp/V4cFsZlXTqkmuD1lHpSQKZ8g 5V1BqacYnV5mhwYR5pmNnKL/tcHeisIP+zywIwvkMiSrN0BhLjw953FruAiRJUvUMrif 84ek+8n1LiBOpcpEyw9Ny8mlkIuMoBmEqW+s6g+ZX5g1VeqVQ0XnQEogHOal/JExg/mO ELQZj8VTmhXn1hbjUaSTlltcixueOyBRDKp4q0ZBNUIxUt+bR5FhnZS+QY5vHsfIFE/f +4VBQF/NvJXqNP8QpwzNZiBVRP8FN2PyA83foh6jNq2q49mFcue8T3ppgxAA7M6sP1pE mJgQ== 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=h+UGS4AX0UF7+z9/iaToLwiU7PtVMuMKa5mCK4214r0=; b=v2jH4JBdo1nidHH0a9/HxWKD+tZSPkeFRtu3uHRZL835Xwdhkiit0xW1x0yxogY5WO fSNDEtBxGnoZrHchTWM0dMh+qfRBtlZvu/cPzoL21AwJET0gFx7z0GLGts4zoUdkRAEW jILy3hF+svRP4AJWyXMMdw1dKsIeZoK9QKXX7tx+2WuOiEIqIqJMdL0V/Rq3qFnvrj3e 9YnodA+ByZ47FYL/XCjTNaXZ5dxkmb/wvXeGcQs0gcLsw6q7TAHjeRs0hPpCqB4OtOB4 fQVAATbXHzh0TroIDnQtdjNT4/Hhw8RHy8el3IpvilsEW0h8JJDf0s4W3FIpTTTmr+Qn hQ0Q== 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 b23-20020a17090636d700b008cd6f50c059si6486826ejc.669.2023.04.04.06.56.08; Tue, 04 Apr 2023 06:56:32 -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 S235644AbjDDNzl (ORCPT + 99 others); Tue, 4 Apr 2023 09:55:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235574AbjDDNz2 (ORCPT ); Tue, 4 Apr 2023 09:55:28 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D09163AA8 for ; Tue, 4 Apr 2023 06:54:59 -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 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 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. 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 --- 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