Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3298013imw; Mon, 11 Jul 2022 06:06:31 -0700 (PDT) X-Google-Smtp-Source: AGRyM1syNlF8Bb1cslnWJbqyvBRTwx86HkC539EUXE4SEVX2VBa5Vza8D/YGZkf8iNTJUNN/un6u X-Received: by 2002:a65:6b8a:0:b0:3db:7dc5:fec2 with SMTP id d10-20020a656b8a000000b003db7dc5fec2mr15691947pgw.223.1657544790614; Mon, 11 Jul 2022 06:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657544790; cv=none; d=google.com; s=arc-20160816; b=qKvoMPV4C0LyPo2UXJCoJKlGACq43tOECQJebEhNd7MmN/tPmFAaqCtQKb0G4HUZ1a n3K9SAbfCxLZCrFUd1vGiBrHvZmYLIpsBYp6wZY2GiF0tYNvpJvzQwmZZegNnHobRMn4 Pb70Rs68oGJv+AZdZd8knnUZn5RPmS6vrNOhAWeEZCFHkQc6RlO/Hnizuyyly2xiR0r1 WTD7sR7w8jeugG/YQsFS3eS1MDgcjDkJfZhqwRagfMp+I/4wfAKZ+b2KtKJI/ThJYnGg jK8QoTM0+EZQER/xKXoCiILhI2clAc66frhQNZJqzWaVpXfOSoTtYFeNXSHyZ7fj2hgN jK8w== 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 :mime-version:user-agent:date:message-id:from:references:to:subject :cc; bh=yLSVAJ6yEiQSU+CIyndD/YSekCZHE6Ekmx2aBs+/F6I=; b=km0cH8MkAIR1pG0AFZLI+skYNVeQqPu5cWq3Xh73wGONSndnRZrNPcCQep1fsnWF8c mm3svgrj8XzmZFQdazSb5Fwkv6RaVxKIDN2lBvC+McDDIQZX+0iXNErOZzAslYuqS06Q lZ7TEq0+vMhSU+KfPhhdDp+nCK9WT1CWANmFKA72VbZOuAAbkkZ9kBKJLYkYvel0kyXf Tei3t9oEPZs9lwVRA8g+7Z6MCRrBhD1k9VRNFw+Zw2PzFAd5km612jGOX+Bd9Y9Pkyij qY0kSL35QjfDZQzklHkvVejQ+Ce7ZUS/ukFGnrr0DoUdkUeO7lhVNackVujAQPQ464PE Cd5g== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y125-20020a633283000000b004160f2456bbsi3032092pgy.246.2022.07.11.06.06.18; Mon, 11 Jul 2022 06:06:30 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbiGKNFH (ORCPT + 99 others); Mon, 11 Jul 2022 09:05:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229902AbiGKNE4 (ORCPT ); Mon, 11 Jul 2022 09:04:56 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D15112F01C; Mon, 11 Jul 2022 06:04:52 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LhPDV1dqczhYyb; Mon, 11 Jul 2022 21:02:18 +0800 (CST) Received: from [10.67.102.169] (10.67.102.169) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 11 Jul 2022 21:04:50 +0800 CC: , "Rafael J . Wysocki" , Mika Westerberg , "Rafael J . Wysocki" , Yicong Yang Subject: Re: [PATCH v6] PCI: Make sure the bus bridge powered on when scanning bus To: , References: <20220606130003.54603-1-yangyicong@hisilicon.com> From: Yicong Yang Message-ID: Date: Mon, 11 Jul 2022 21:04:50 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: <20220606130003.54603-1-yangyicong@hisilicon.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.169] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,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 Hi, a gentle ping...will it be considered for this window? Thanks. On 2022/6/6 21:00, Yicong Yang wrote: > A bridge in a non-D0 power state does not forward config accesses to > its secondary side (PCIe r6.0, sec 5.3.1). Make sure the bridge is > in D0 while we enumerate devices below it. > > The case can be produced when the bridge is runtime-suspended (either > in D3hot or D3cold) like below: > > $ echo 1 > /sys/bus/pci/devices/0000:80:00.0/0000:81:00.1/remove > $ echo 1 > /sys/bus/pci/devices/0000:80:00.0/pci_bus/0000:81/rescan > > 0000:80:00.0 is a Root Port and it is runtime-suspended, so the > configuration space of 0000:81:00.1 is unreachable in rescan > and the device cannot be enumerated. > > Power up the bridge when scanning the child bus and allow it to > suspend again by adding pm_runtime_get_sync()/pm_runtime_put() > in pci_scan_child_bus_extend(). > > Cc: Rafael J. Wysocki > Cc: Mika Westerberg > Cc: Bjorn Helgaas > Signed-off-by: Yicong Yang > Reviewed-by: Rafael J. Wysocki > --- > Change since v5: > - Tweak the commit message suggested by Bjorn > Link: https://lore.kernel.org/linux-pci/20220525141930.GA290827@bhelgaas/ > > Change since v4: > - rephrase the commit suggested by Rafael > Link: https://lore.kernel.org/lkml/20220422080404.27724-1-yangyicong@hisilicon.com/ > > Change since v3: > - retain the pm_runtime_*() calls in pci_scan_bridge_extend() as Rafael points > out that it's necessary when the brigde is in D3cold > Link: https://lore.kernel.org/linux-pci/20220414123736.34150-1-yangyicong@hisilicon.com/ > > Change since v2: > - just rebase it on v5.18-rc2 > Link: https://lore.kernel.org/linux-pci/1601029386-4928-1-git-send-email-yangyicong@hisilicon.com/ > > Change since v1: > - use an intermediate variable *bridge as suggested > - remove the pm_runtime_*() calls in pci_scan_bridge_extend() > Link: https://lore.kernel.org/linux-pci/1596022223-4765-1-git-send-email-yangyicong@hisilicon.com/ > > drivers/pci/probe.c | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c > index 17a969942d37..b108e72b6586 100644 > --- a/drivers/pci/probe.c > +++ b/drivers/pci/probe.c > @@ -2859,11 +2859,20 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, > unsigned int used_buses, normal_bridges = 0, hotplug_bridges = 0; > unsigned int start = bus->busn_res.start; > unsigned int devfn, fn, cmax, max = start; > + struct pci_dev *bridge = bus->self; > struct pci_dev *dev; > int nr_devs; > > dev_dbg(&bus->dev, "scanning bus\n"); > > + /* > + * Make sure the bus bridge is powered on, otherwise we may not be > + * able to scan the devices as we may fail to access the configuration > + * space of subordinates. > + */ > + if (bridge) > + pm_runtime_get_sync(&bridge->dev); > + > /* Go find them, Rover! */ > for (devfn = 0; devfn < 256; devfn += 8) { > nr_devs = pci_scan_slot(bus, devfn); > @@ -2976,6 +2985,9 @@ static unsigned int pci_scan_child_bus_extend(struct pci_bus *bus, > } > } > > + if (bridge) > + pm_runtime_put(&bridge->dev); > + > /* > * We've scanned the bus and so we know all about what's on > * the other side of any bridges that may be on this bus plus >