Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1927872ioo; Mon, 23 May 2022 06:29:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz2TnylnpuzYV78X0V59kC3+53NN3Fv+Nw28VgSohV9pgTMYxqP7H19Z2SbIgxCGx1uTo2I X-Received: by 2002:a17:90b:390b:b0:1df:b3dc:514a with SMTP id ob11-20020a17090b390b00b001dfb3dc514amr26926349pjb.25.1653312574264; Mon, 23 May 2022 06:29:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653312574; cv=none; d=google.com; s=arc-20160816; b=iYDm/kRR+kcUYvqggqK9lbhzfm5hvhhZZ/amgQWvH8p6mqyhumFVLxFtZNGn9M+YkU s+VYDy+NWvm7pjOi9WkcYScXREgTIlTUuVoeDg91wrkLdJdEBeGkQC+TpEi0D6/wwDFr Bl3aVhDtFU4ywauckn314UdvgOMFqe3nZ6MQiTzc3mcBz9ssDuN5/2++OOYr8y67PP0W ccoeyxM5Ai+EyM2V0ftAiZa3zqSeo2khdxM83fOxhklnCDHBJ3GNkPknMfXGpLmwM1FL NuD8HlAlEoY8kLEo5qIVj+NKW0pkOIrcG22hK01jgHnESCVDX38mAJEe+Ekus3dQ8QyW BXqw== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=iX45nfplllw+FW8fFoVh2HvDIItg6ttXTKoZCS3Evsg=; b=px21fPrX+q7fiJeJFcGp3q31FQF+ebMDLxMbNGSf23gt/mX54yNQd+0CscM7hd975c 72dAJreNnUivjCsbR0aJ1NQRnd9uydSzH/LPwy7njSf2PyDe8l83TdMtE/PTRdRyLPZr gx9ccOpUsa5gw1unFI7TWYBNcmNVVMPX1cULmSgsNRN2UjjcMdxoUZG2M54rKJJcZ1Vo LJr/pp6PhRqsEXzXEsLsnCFo9s8wEERIn4C+4u8qz2IveY49WXArwDYiIluOABP4YwGn 45Yuh8qUZo1Ookf/jwrLCoJMz3uOhJqfS8628QtzBAfrcSJW1dwk2IPVVtuX0CQHj5rs JVNQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id qe13-20020a17090b4f8d00b001cb7af1047esi15482130pjb.100.2022.05.23.06.29.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 06:29:34 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AC3CAE60; Mon, 23 May 2022 06:28:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236391AbiEWN2p (ORCPT + 99 others); Mon, 23 May 2022 09:28:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36110 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236373AbiEWN2Z (ORCPT ); Mon, 23 May 2022 09:28:25 -0400 Received: from hostingweb31-40.netsons.net (hostingweb31-40.netsons.net [89.40.174.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A60D53DA5C; Mon, 23 May 2022 06:28:15 -0700 (PDT) Received: from [77.244.183.192] (port=63488 helo=[192.168.178.75]) by hostingweb31.netsons.net with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1nt86W-0004R3-V3; Mon, 23 May 2022 15:28:13 +0200 Message-ID: <30b9a2fe-7f9e-bc85-8ecb-d2137c243c36@lucaceresoli.net> Date: Mon, 23 May 2022 15:28:09 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH 1/2] PCI: dra7xx: Fix link removal on probe error Content-Language: it-IT To: Saravana Kannan Cc: Lorenzo Pieralisi , Rob Herring , PCI , Dan Carpenter , linux-omap , linux-arm-kernel , "linux-kernel@vger.kernel.org" , Kishon Vijay Abraham I , =?UTF-8?Q?Krzysztof_Wilczy=c5=84ski?= , Bjorn Helgaas , Sekhar Nori , Android Kernel Team References: <20211214221450.589884-1-luca@lucaceresoli.net> <59a23c89-0810-eb28-acd9-7051ac34d438@lucaceresoli.net> <4579940c-27dc-733e-4022-ebea4671c839@lucaceresoli.net> <615718f9-151e-20fb-fcb0-56063ae61ca6@lucaceresoli.net> From: Luca Ceresoli In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - hostingweb31.netsons.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lucaceresoli.net X-Get-Message-Sender-Via: hostingweb31.netsons.net: authenticated_id: luca@lucaceresoli.net X-Authenticated-Sender: hostingweb31.netsons.net: luca@lucaceresoli.net X-Source: X-Source-Args: X-Source-Dir: X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE 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 Hi Saravana, On 19/05/22 22:25, Saravana Kannan wrote: > On Tue, May 17, 2022 at 12:32 AM Luca Ceresoli wrote: >> >> Hi Saravana, >> >> On 14/05/22 05:46, Saravana Kannan wrote: >>> On Thu, May 12, 2022 at 7:07 AM Luca Ceresoli wrote: >>>> >>>> Hi Lorenzo, >>>> >>>> On 11/05/22 18:41, Lorenzo Pieralisi wrote: >>>>> On Sat, Jan 15, 2022 at 10:02:00AM -0600, Rob Herring wrote: >>>>>> +Saravana >>>>>> >>>>>> On Tue, Jan 11, 2022 at 4:35 AM Luca Ceresoli wrote: >>>>>>> >>>>>>> Hi Rob, >>>>>>> >>>>>>> On 16/12/21 10:08, Luca Ceresoli wrote: >>>>>>>> Hi Rob, >>>>>>>> >>>>>>>> thanks for the quick feedback! >>>>>>>> >>>>>>>> On 14/12/21 23:42, Rob Herring wrote: >>>>>>>>> On Tue, Dec 14, 2021 at 4:15 PM Luca Ceresoli wrote: >>>>>>>>>> >>>>>>>>>> If a devm_phy_get() calls fails with phy_count==N (N > 0), then N links >>>>>>>>>> have already been added by device_link_add() and won't be deleted by >>>>>>>>>> device_link_del() because the code calls 'return' and not 'goto err_link'. >>>>>>>>>> >>>>>>>>>> Fix in a very simple way by doing all the devm_phy_get() calls before all >>>>>>>>>> the device_link_add() calls. >>>>>>>>>> >>>>>>>>>> Fixes: 7a4db656a635 ("PCI: dra7xx: Create functional dependency between PCIe and PHY") >>>>>>>>>> Signed-off-by: Luca Ceresoli >>>>>>>>>> --- >>>>>>>>>> drivers/pci/controller/dwc/pci-dra7xx.c | 2 ++ >>>>>>>>>> 1 file changed, 2 insertions(+) >>>>>>>>>> >>>>>>>>>> diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c >>>>>>>>>> index f7f1490e7beb..2ccc53869e13 100644 >>>>>>>>>> --- a/drivers/pci/controller/dwc/pci-dra7xx.c >>>>>>>>>> +++ b/drivers/pci/controller/dwc/pci-dra7xx.c >>>>>>>>>> @@ -757,7 +757,9 @@ static int dra7xx_pcie_probe(struct platform_device *pdev) >>>>>>>>>> phy[i] = devm_phy_get(dev, name); >>>>>>>>>> if (IS_ERR(phy[i])) >>>>>>>>>> return PTR_ERR(phy[i]); >>>>>>>>>> + } >>>>>>>>>> >>>>>>>>>> + for (i = 0; i < phy_count; i++) { >>>>>>>>>> link[i] = device_link_add(dev, &phy[i]->dev, DL_FLAG_STATELESS); >>>>>>>>> >>>>>>>>> I think this should happen automatically now with fw_devlink being >>>>>>>>> enabled by default. Can you try? >>>>>>>> >>>>>>>> Do you mean removal should be done automatically? I think they are not >>>>>>>> due to the DL_FLAG_STATELESS flag. >>>>>>> >>>>>>> I would love to have feedback because, as said, I think my patch is >>>>>>> correct, but if I'm wrong (which might well be) I have to drop patch 1 >>>>>>> and rewrite patch 2 in a slightly more complex form. >>>>>> >>>>>> I mean that why do you need explicit dependency tracking here when >>>>>> dependencies on a PHY should happen automatically now. IOW, what is >>>>>> special about this driver and dependency? >>>>> >>>>> Any update on this patch ? I think patch 2 can be merged, please >>>>> let me know if this one can be dropped. >>>> >>>> Thanks for the feedback! You would say yes, you can merge patch 2, >>>> except it probably does not even apply as it is written in a way that is >>>> based on the changes in patch 1. >>>> >>>> I could rewrite patch 2 to not depend on patch 1 of course, but it >>>> wouldn't make code simpler, perhaps more complex. And moreover the >>>> hardware that I used to have access to has phy_count==1 so I could never >>>> test the failing case, and sadly now I have no access to that hardware. >>> >>> Hi Luca, >>> >>> The fw_devlink code to create device links from consumers to "phys" >>> suppliers is pretty well exercised. Most/all Android devices running >>> 5.10+ kernels (including Pixel 6) use fw_devlink=on to be able to boot >>> properly. >>> >>> So I'd be pretty confident in deleting the device_link_add/del() code >>> in drivers/pci/controller/dwc/pci-dra7xx.c. The device links should >>> already be there before the probe is even called. >>> >>> Also, if you want to check if the device links (even the 1 phy one you >>> have) are being created, you can look at /sys/class/devlink to see the >>> list of all device links that are currently present. You can delete >>> the code and then use this to check too. >> >> Thank you for your feedback. Unfortunately as I said I have no access to >> the hardware, and won't have anymore. I don't think it is a good idea to >> send a patch that I cannot test on real hardware, especially since it is >> for a generic hardware that thus might affect others. But I would be >> glad to review any such patch that might be sent, FWIW. > > Just to make sure I'm on the same page. I thought you at least had a > device where phy_count = 1. But looks like you are saying you don't? I used to have access to a hardware with phy_count = 1 on a former job, but I don't have it anymore and won't have it since I left that job position. > If all you want to check is "phys" have device links created for them > for whatever random DT device that has a "phys" property, then I can > test and confirm that for you on whatever platform I have. But if you > want a test specifically for the device that corresponds to the driver > you were fixing, then I can't. Let me know. Honestly, I'm afraid I don't have much time to invest in trying to recollect all the details and motivations for this patchset. Likely I spotted this by code inspection while debugging other issues (I had a non-working PCIe device, but it was not the host fault). If you think there is little value in these patches, I'm OK in dropping them. -- Luca