Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp974101rdf; Sat, 4 Nov 2023 01:35:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2EgkUEWNDtj4npE+FMiJl0GIPG7Pb5N7BFRCOcCeyngqAhRLRfgSTyKoGjIIwE3F6RMm8 X-Received: by 2002:a05:6870:700e:b0:1e9:9469:a858 with SMTP id u14-20020a056870700e00b001e99469a858mr27465468oae.39.1699086934506; Sat, 04 Nov 2023 01:35:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699086934; cv=none; d=google.com; s=arc-20160816; b=F1tzxCkhGYY0pksHF4ATcxd1GB1BWy7/5LHPINJxSuRwrP3KWFE71X19VZjXznMb7A 2QJhZJq35cEjjCDbVt2+AP/OsWCg7K4MzgvB2a/TmX5AlDJ+CmjCr9wydHHW2pyLfpeg 5YFnJgPz/9kbazVGnCHtiP2/1hRweOIQ9MyWTwGcjhiSkMgfaA08WLL0s9TChjq6XOYH I1nQGgX6PoBO43iZf07k/41ORcEVXfSXnlfNh7+zz2b2COUnhnIYKgH0+/E0/5kuic0B 5zgOy+7pwSj4a5oU8b7h9nLD4pflMppq8YR0VzyBn7uj8Tk2M+qWvhu9speCT11P1i0z lLRA== 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:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=iizMqJ8oz7FLaa8uGRDiRCCs5ootGPJzd3jk97tV/1Q=; fh=271EdO0v1AxDFB0O5fiZlDK4y2rUYD7RvptMflX3SwQ=; b=XC88Me2g0n4yYmYnGsUrqyLJ9DDhy6a4L4qDqTFIHyDY2R7auVLNsSATQ4J2C/s6dL ayQ6WwtOiTDsnUw7wjVLwsuzF1pdH2+wkzvtpg/zBsjLvu0zAiyQ/0latr+iBUiGs1P8 I6SA1o7tczKlLblt7mvoigP+FYn/sKNiOW3KQREwSrKuPs30pFzS8hiC7ufQy2Z6UfAN rC5mSVoa21Vsz1fdp8FCsAquXPwjZcif05YB6VFJaNSJQf2LwVpSvUuC/EB30Agi1fgb ff4hV/op9kqHWdVmXRxgqNWV3KuD1twku7N4J0zg/GdgJl/G70CZEcwHy0F1wb3vKlYj sw9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=IuiZ53PV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id q23-20020a63cc57000000b005b3d703ca05si3352217pgi.780.2023.11.04.01.35.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Nov 2023 01:35:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=IuiZ53PV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=wanadoo.fr Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 6ACD6810F0EB; Sat, 4 Nov 2023 01:35:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231414AbjKDIfU (ORCPT + 99 others); Sat, 4 Nov 2023 04:35:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229509AbjKDIfT (ORCPT ); Sat, 4 Nov 2023 04:35:19 -0400 Received: from smtp.smtpout.orange.fr (smtp-22.smtpout.orange.fr [80.12.242.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CCC61BD for ; Sat, 4 Nov 2023 01:35:16 -0700 (PDT) Received: from [192.168.1.18] ([86.243.2.178]) by smtp.orange.fr with ESMTPA id zC7cqEzJb8IN3zC7cqc9pn; Sat, 04 Nov 2023 09:35:14 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1699086914; bh=iizMqJ8oz7FLaa8uGRDiRCCs5ootGPJzd3jk97tV/1Q=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=IuiZ53PV05ZLqhqQxasa7wAPc1vFjl6sXrwjac8Zu1RQmHvjYfeme3h6hV6zzfY8O aG8Zi2ghZyBltTnTL/GqYrgqfWXpm9KYlJVNZUqBjFpqwM1PvMYUnjZt2qu4L8zHl4 RLZjTNRS9tw+vZdAUGNBfmKpdF8YN6wy7G4jnf1Ja6767lg+FwN/hB4jqOmVqNznZj IjS1XiiK2la9DHSeCqyRKWl8+KawTg9cyKWhBEcz/ejD0FCAt3s5yoZyVIJ5ZMiCI8 0ugQDb+TftQsdiWhV6LHNJrmSQz9djHMxZi5Fl+2u1BGd8N8ACilFwUqzWmBwNkkYR I/jCGuqzdu/lw== X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Sat, 04 Nov 2023 09:35:14 +0100 X-ME-IP: 86.243.2.178 Message-ID: <7ad737c4-1f61-488a-a8f9-32e80ad8f817@wanadoo.fr> Date: Sat, 4 Nov 2023 09:35:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: RE: RE: [PATCH v6 1/2] usb: dwc3: add Realtek DHC RTD SoC dwc3 glue layer driver To: =?UTF-8?B?U3RhbmxleSBDaGFuZ1vmmIzogrLlvrdd?= Cc: "Thinh.Nguyen@synopsys.com" , "conor+dt@kernel.org" , "devicetree@vger.kernel.org" , "gregkh@linuxfoundation.org" , "krzysztof.kozlowski+dt@linaro.org" , "linux-kernel@vger.kernel.org" , "linux-usb@vger.kernel.org" , "robh+dt@kernel.org" References: <20230826031028.1892-1-stanley_chang@realtek.com> <202310301424.39UEOShlC2187546@rtits1.realtek.com.tw> <202311011453.3A1ErwKI3829148@rtits1.realtek.com.tw> Content-Language: fr From: Christophe JAILLET In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sat, 04 Nov 2023 01:35:31 -0700 (PDT) Le 03/11/2023 à 11:54, Stanley Chang[昌育德] a écrit : > Hi Christophe, > >> Le 01/11/2023 à 07:27, Stanley Chang[昌育德] a écrit : >>> Hi CJ, >>> >>> I think these functions are not needed in remove function. >>> >>> In dwc3_rtk_probe_dwc3_core, >>> I have used >>> dwc3_node = of_get_compatible_child(node, "snps,dwc3"); and dwc3_pdev >>> = of_find_device_by_node(dwc3_node); >>> >>> So, I call these put functions. >>> platform_device_put(dwc3_pdev); >>> of_node_put(dwc3_node); >> >> Yes, but you call it only in the error handling path of the function. >> >> I wonder if they should also be called in the remove function in order to >> decrement the ref-counted reference. >> >> >> Same in __get_dwc3_maximum_speed(), the reference taken by: >> dwc3_np = of_get_compatible_child(np, "snps,dwc3"); is never released. >> >> >> See the comment at [1] to see what I mean. >> >> >> [1]: https://elixir.bootlin.com/linux/v6.6/source/drivers/of/base.c#L681 > > You are right! > For dwc3_pdev, dwc3_np or dwc3_node, I should add of_node_put to release them when the function exits. > https://elixir.bootlin.com/linux/v6.5.10/source/drivers/usb/dwc3/dwc3-meson-g12a.c#L567 > > I will add a patch to fix this. > > For example, > diff --git a/drivers/usb/dwc3/dwc3-rtk.c b/drivers/usb/dwc3/dwc3-rtk.c > index 590028e8fdcb..9d6f2a8bd6ce 100644 > --- a/drivers/usb/dwc3/dwc3-rtk.c > +++ b/drivers/usb/dwc3/dwc3-rtk.c > @@ -187,6 +187,7 @@ static enum usb_device_speed __get_dwc3_maximum_speed(struct device_node *np) > > ret = match_string(speed_names, ARRAY_SIZE(speed_names), maximum_speed); > > + of_node_put(dwc3_np); > return (ret < 0) ? USB_SPEED_UNKNOWN : ret; > } > > @@ -339,6 +340,8 @@ static int dwc3_rtk_probe_dwc3_core(struct dwc3_rtk *rtk) > > switch_usb2_role(rtk, rtk->cur_role); > > + platform_device_put(dwc3_pdev); > + of_node_put(dwc3_node); > return 0; > > err_pdev_put: > LGTM. CJ > > Thanks, > Stanley > >> CJ >>> >>> Thanks, >>> Stanley >>> >>>> Hi, >>>> >>>> Is something like >>>> platform_device_put(dwc3_pdev); >>>> of_node_put(dwc3_node); >>>> needed in the remove function? >>>> >>>> (as done in the error handling path of dwc3_rtk_probe_dwc3_core()) >>>> >>>> Or should it be added at the end of dwc3_rtk_probe_dwc3_core() if the >>>> reference are nor needed anymore when we leave the function? >>>> >>>> CJ >>>> >>>>> + of_platform_depopulate(rtk->dev); } >>>>> + >>>> >>>> ... >>> >