Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7063042rwr; Tue, 25 Apr 2023 07:38:31 -0700 (PDT) X-Google-Smtp-Source: AKy350aOOR3xbYRhk0SGOXEyOkX2yvclHsdb2+oRQ4f56USA7V3kCMidFgwWALMUAJMptWB+B2ou X-Received: by 2002:a05:6a20:6a1b:b0:f0:2d4a:8855 with SMTP id p27-20020a056a206a1b00b000f02d4a8855mr21486025pzk.8.1682433511427; Tue, 25 Apr 2023 07:38:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682433511; cv=none; d=google.com; s=arc-20160816; b=L/ACaXsCKAo7MCDFTg3v/x2P2dqC1+G/NrWjIx7RxxF6kFA+InBy4fCRo6volkFnp7 Fh0+azaNkUsk14gzmoF6cvBl17ZBYiz34T9baB0+w9SQuecfGX+reeRovoh2p0WqlSfM 7Rz6mtPxgXzFXQ7v+AT6WD1k7kc75ve+VNep7p+9SMHOoXbZfC+kZaXhB9+IaOLPp6TA AuCqWMC/l8p2dNbCh0u6RktSLfHydVOmLq1wilZR6KsqIdkzp+i8g9iwl09xClg0Az9Z PNuynIicTZ3jspfY8URYSsflYKPpuXCddEfYPaLrGjs2WLDthf8yaHS3buXR6PNG+DVu DACw== 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=mHIQEidZgEWUQsd5J70kAmb6OyHzVRLqJ8oNLEN9W5k=; b=r7Zv5O4EgBd6IbvlyHIqrRAplk7/eeBEbJdWjujX2UkwEAACnw63NgKLioVKYVQKsp DlyNMKpiDRQlxZC5hF7txdcghe5ezIrojlkweCmhBHo4VmurXsgJ7VLIP/2mdPSvlYR8 X0vv8Ry94Y4tBfdwFcvwj0Tuc4FcN/fy3x9Of5ch63jOg3jPQVtEYrxtdMZ81e26k096 ZvfATxLZI3KrTV8hRSeTnFEF2K60N0GcU/ZAdFvM2HnL0jM02vI6CC6sqPgVcB1OEy2D KlNoqI1RuI9Uet+1LqMGI4v9FlUt1Vs+gXmPr+Ug19d9pTlvI376xncC9s0BK/y+8M7b l8Pw== 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 x24-20020a63db58000000b0050beb800603si11045269pgi.39.2023.04.25.07.38.17; Tue, 25 Apr 2023 07:38:31 -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 S234167AbjDYOgY (ORCPT + 99 others); Tue, 25 Apr 2023 10:36:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233893AbjDYOgT (ORCPT ); Tue, 25 Apr 2023 10:36:19 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 2FB82BB8D for ; Tue, 25 Apr 2023 07:36:18 -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 E715FC14; Tue, 25 Apr 2023 07:37:01 -0700 (PDT) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 616723F587; Tue, 25 Apr 2023 07:36:16 -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 , Leo Yan , Alexander Shishkin , Greg Kroah-Hartman , Mathieu Poirier , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 01/13] coresight: Fix loss of connection info when a module is unloaded Date: Tue, 25 Apr 2023 15:35:28 +0100 Message-Id: <20230425143542.2305069-2-james.clark@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230425143542.2305069-1-james.clark@arm.com> References: <20230425143542.2305069-1-james.clark@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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 Reviewed-by: Mike Leach 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