Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2178608rwl; Thu, 30 Mar 2023 07:05:40 -0700 (PDT) X-Google-Smtp-Source: AKy350Zviib9ki7OuIxgmxbvJPkqDRMQk5u+nsfgd3Y9/Ak78PbdDdTwiN6x6a6xFhYCtPy3Y4D0 X-Received: by 2002:a05:6a20:9383:b0:cb:af96:9436 with SMTP id x3-20020a056a20938300b000cbaf969436mr2899286pzh.0.1680185140272; Thu, 30 Mar 2023 07:05:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680185140; cv=none; d=google.com; s=arc-20160816; b=itagKuDAp8fJ3UDRkQS/JP0cpuv25quRDz7TBKofCwrs9kI8fGaDODlWVsosFt4W1k iQfmjMYycbDy07mBbfTIn2rYghbxbYWMbCwDbDzLWpw6EI2YTGgLGshJQAAl2tFU8x3R z2VkAEp6EerQFYu6L5ZSaAi9HOFxCBBslHdDbSS6m+1wc2gh5kYQfly9e5x8iURt2b+W 0pAXVMKuoyNHxd6dri1wIFXxoiijO7gn1plh46+XcrQay+49jWycxQj8NLoZEMkD9YQ1 0TKnpBPIQh3u2qUPYayAo1Lk5woIvW5CJZErAU/Smfjb9fuCOigj7IngpLuwJ7addtz/ xOBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:subject:user-agent:mime-version:date:message-id; bh=0NU09UsNnU93q8RytzRmCO/CqAVqo0+fDlnKG2RVQ7M=; b=K3vmV37etXBKmKlR8VVi1HzomW9g+HbkgXSgKnp1XUdlubHWuLh2bIc3BaqV5JbswT EM7SXE6R43httOuxtG/4HF3YjP7LUqeobIxTsKfv9DCM0qAx78QQktlR23skG5HPk2at y5iFSoHm9Uvz+qGO4lAQX4ARX5CthkIwkIlaTAVVspvcQZSELPjknf9IwFnUMGP+29KW 7GVigKHk2GRtcLJO4F8WA2G1K38OCik9f+b2dazXeWsRBivUZr2I8ER3qJdaLHsHFDHl WEngW7ieDJrrr4QMnELuL1zoz6CvoEJM6unmOS87KBBQZcUDK7zC0UhEoFZ0rJNosGWl wNlQ== 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 s13-20020a056a0008cd00b0062578d18ba1si35190807pfu.54.2023.03.30.07.05.23; Thu, 30 Mar 2023 07:05:40 -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 S232231AbjC3OBN (ORCPT + 99 others); Thu, 30 Mar 2023 10:01:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230035AbjC3OBL (ORCPT ); Thu, 30 Mar 2023 10:01:11 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D99CE6EB8 for ; Thu, 30 Mar 2023 07:01:09 -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 CFE5F12FC; Thu, 30 Mar 2023 07:01:53 -0700 (PDT) Received: from [10.57.54.53] (unknown [10.57.54.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A35533F663; Thu, 30 Mar 2023 07:01:07 -0700 (PDT) Message-ID: Date: Thu, 30 Mar 2023 15:01:06 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.9.0 Subject: Re: [PATCH v3 06/13] coresight: Fix loss of connection info when a module is unloaded From: Suzuki K Poulose To: James Clark , coresight@lists.linaro.org, quic_jinlmao@quicinc.com, mike.leach@linaro.org Cc: 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 References: <20230329115329.2747724-1-james.clark@arm.com> <20230329115329.2747724-7-james.clark@arm.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.3 required=5.0 tests=NICE_REPLY_A, 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 On 30/03/2023 13:42, Suzuki K Poulose wrote: > Hi James > > On 29/03/2023 12:53, James Clark wrote: >> 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 > > This looks like a bug in the existing driver. Please could you keep this > at the beginning of the series, so that it is easier to backport for > stable ? > > Also, please add : > > Fixes: 37ea1ffddffa ("coresight: Use fwnode handle instead of device > names") > Fixes: 2af89ebacf29 ("coresight: Clear the connection field properly") > > >> --- >>   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; > > This change is not required, as we are freeing the pdata anyway. > Keeping this might be beneficial if someone else comes looking > for references while we are going out. I don't see how we could > hit that, but just to be safe. For reference, I could reproduce the problem by : On juno, 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 Suzuki > > Suzuki >