Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1075635iob; Fri, 13 May 2022 22:09:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwn4MvLiHW8/5+3tHM4Q4xIgsSsZQ5cbh6XK+39HjFl6YPwL38ostduc65sA961HxXeRBm7 X-Received: by 2002:a5d:6da1:0:b0:20c:6969:b26a with SMTP id u1-20020a5d6da1000000b0020c6969b26amr6296725wrs.103.1652504969381; Fri, 13 May 2022 22:09:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652504969; cv=none; d=google.com; s=arc-20160816; b=FesshCqcH6qbPuAu2qObIjyQjTQHORGIRt2Jagiy0qIo4odjQhzl1HvARLuhC5L92L 2q7pN6QbQV4li4QGN7eX1Pqqo85qABv4zoft1LYtYrsLb+w1lQZpV3k57H7JOqyqaqSi xG54+qwhlSYiI70BkX83pisdq33kCQ1/Jd8/d7ooRuOEGT+csDe9QbYJsPpBQf8Dt9N6 mzRnf9BCxd5Kca4U06kR9b3G2VCv4A7fOejfH4r89VFcLxQRT2SlI/gsfwCyWh2V5CJP 0GwSDP2xVatRDz4lDD5QKfnnyUkzVS91WIq/kg6NrVkfI+NBP/Pj65mntqMdwKriSND3 xlBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=GlgtfqIsCtTv5Jauk4wjOqDSq6O7AkKJ3RvfO9y7TuY=; b=QOrtK7rhmh5TF6ss6eu7RGKU3ciZK40uSFP2OfLJOpOk7iK1OFY0N0SiGvQDkL66ik v/VJ9Wu84yVHwUd2GnaXkjn1Q2mS6rquxfSuvFY6wMu9z8fU0OmQSkPqghmS/qdEVLLS L/ag91mlI7dXurc2zE6gDGpDqx6c5k9HlH0HKzwW8MeuwFhiryZpHJwJ0dxI+a6GBDZD l8CTUAPbz4INKRpv95/ZyqrcgVAsuS9+dKb5hBJ0C1Eieguum7sfQFtWspWLUZlGRzjU iuV1HvZISlEdCSvd15Ste2NiA8d5J0lZyhigU7OXRDDODPcAysGFNelfLysl/PznbaeP obDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Hd3y72OZ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id 11-20020a056000156b00b0020ad81791aesi3866725wrz.179.2022.05.13.22.09.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 22:09:29 -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; dkim=pass header.i=@google.com header.s=20210112 header.b=Hd3y72OZ; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 94873106366; Fri, 13 May 2022 20:47:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231657AbiENDrl (ORCPT + 99 others); Fri, 13 May 2022 23:47:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231639AbiENDri (ORCPT ); Fri, 13 May 2022 23:47:38 -0400 Received: from mail-yw1-x1136.google.com (mail-yw1-x1136.google.com [IPv6:2607:f8b0:4864:20::1136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23968D118 for ; Fri, 13 May 2022 20:47:35 -0700 (PDT) Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-2f7bb893309so107433747b3.12 for ; Fri, 13 May 2022 20:47:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GlgtfqIsCtTv5Jauk4wjOqDSq6O7AkKJ3RvfO9y7TuY=; b=Hd3y72OZxm4CV6vW7TxvqAtmoAy+5gV6r8Hf73b2YVQhbZh/HnO/aOE8OjMotWtJsU pgzFZb7Pbdo2z3gPi9huhyKqFUGMLw3qTCbrVpuaAWUIFHWGbwySJWLcSD3x2HJrwRq3 9fXf4FixKmDUChFhx096IeeNMt3xcPz0/4o2aTvkQVRfQbAJc5UhQHyWxXSkV4gFPg33 SGpNyqOFMnggv210P+5AB5hDnM0fJ36oi+VoIRbJ9v2IN0RWG2s14SDXdE2Oc2HrLKAY bja30YKLL/ESaJrKPVW74HGSsPp2CsdjFg4HM+oVywqUe7/hTlwWz89KB+xAYsV0Z17x OmUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GlgtfqIsCtTv5Jauk4wjOqDSq6O7AkKJ3RvfO9y7TuY=; b=hpHKNQl5Qtw4uYx9n+fum41h15DA4QBOv2JE3uYv50K3rOl4fqSSRT6ZFtIoHNfUA8 gUNZCndOYDViAUVtiI6dESOTxgAF/1UOp7TBQAp86iuQ0SnoVj27lTRn8uSGDozbM+T3 Lw8YgVjdksYuG265TLcJJ1RCFTwK6KikiJD7WxgyUG8ZuTIW7OMib3lvQLoDvKMnd3S5 IaLIG0xisRR4kpfQTM96I9rEjgLSEpcpvIUCQOCAg/ShYy9CiUKjes/1fl3stQRdUcsz cXCo2fwv5HBKVy75wiXZ2H+7SFT+z97UZiTY2LewOVCbC8L3kGaxPmQG76mISCAeRa1T iiOw== X-Gm-Message-State: AOAM531kt7REblX06dmYqV8rVMPpXJNFaBHHwJ73pd6tr9UGGlwVvQYh ms3emODaZfya/DTGrdfRPAv/+bcG+/7SHUfjMw9C9w== X-Received: by 2002:a0d:cfc5:0:b0:2dc:48db:dda1 with SMTP id r188-20020a0dcfc5000000b002dc48dbdda1mr9063293ywd.83.1652500054045; Fri, 13 May 2022 20:47:34 -0700 (PDT) MIME-Version: 1.0 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> In-Reply-To: <615718f9-151e-20fb-fcb0-56063ae61ca6@lucaceresoli.net> From: Saravana Kannan Date: Fri, 13 May 2022 20:46:57 -0700 Message-ID: Subject: Re: [PATCH 1/2] PCI: dra7xx: Fix link removal on probe error To: Luca Ceresoli 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no 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 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. -Saravana > > -- > Luca