Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3724233pxv; Tue, 13 Jul 2021 02:10:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkjkwXBSiR7Y+FJCvi2G41VWIOPfw1yiAJi0m17fHL/PHIyy0sCbM75oms2+ZLWwfCYCb6 X-Received: by 2002:a17:906:3555:: with SMTP id s21mr4306191eja.394.1626167408764; Tue, 13 Jul 2021 02:10:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626167408; cv=none; d=google.com; s=arc-20160816; b=pivRCP3dMKvFRY0QtWuDYhMRzQoD04GRuZFhKPt5urJwXGBXEPQZZSwEIicaVf5q8h SESarSJv+8XMkxLggEZ83dZhNzB82VEtz5m3TcKh0WfW3R6Tl/s7gGFPRbxMp3QLN43i 3VhGA8s4LrAmF9GkFrlMhh0Qq56uqQd249P2JeWKDZVusoXQ35a94XHlTsXEkqiwseIt me7eDBfUJyOlTiwBar/eBh1exonIjsWkRuEQNcbA1ta+FjkdeGTwAqUdVSyr79QS5H1/ /dj9O1zHP7iLa0s2OLnmsSmEoGcGU7rGhyvI4XDAP2rLGDSMnbQ+S93b79PGGXCA4uFj XEnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:sender:dkim-signature; bh=9Au+qoSVHB4VwxC9iKkQR94HxlbBA0K+/1PBJPfppOc=; b=jAV7mBjRvRw+8UR7l8Ubnxg1TXSsFfCZGontW9kt0ownlk0UlaYB5XMRJHarNqcC/4 bYABlFtyomj1QP0Bsso1ZbgGQhl09RDs64jMskd7YGe6+mhRRJGRxcTVQdPtYG1U75Z3 Jh8lNc5Dv0mctI6QKzo3eZcTJl6g8yQNoioU2Y169J32uEsXUmGckJQsZHd3Vf2Wlo9q jB6HY9rZc50d4f+W+hDsWcPsVEapPUi/XmZoXpt/AYJMO478nGXe116cLie9EJpqKTWI xzAZByG4mZgYIn5nQQn6nkXX+yUCN6m5t3iQgn5SwXOwfpvd/sONVsIQLCC3Uwl6/w+V 66rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="sRYMdsr/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f23si17669669edy.460.2021.07.13.02.09.45; Tue, 13 Jul 2021 02:10:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="sRYMdsr/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234879AbhGMJJN (ORCPT + 99 others); Tue, 13 Jul 2021 05:09:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234121AbhGMJJM (ORCPT ); Tue, 13 Jul 2021 05:09:12 -0400 Received: from mail-ot1-x32e.google.com (mail-ot1-x32e.google.com [IPv6:2607:f8b0:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8D8EC0613DD; Tue, 13 Jul 2021 02:06:21 -0700 (PDT) Received: by mail-ot1-x32e.google.com with SMTP id 7-20020a9d0d070000b0290439abcef697so21797862oti.2; Tue, 13 Jul 2021 02:06:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=9Au+qoSVHB4VwxC9iKkQR94HxlbBA0K+/1PBJPfppOc=; b=sRYMdsr/MH/y7malyvLoVgJEWfqHdp6Vrj/XQeg2SbBGiWG8qXZ7/aHTDbXBzCS7n4 sv+elgQ/zCdr/MpVmtarAZT1UOwVihpuZ08f30ygdhm0DqshFFO3htSpvtPSt+5PX5Up fH0MBOXHKozqDZQlEXNqYmhkOhyK40NX5EndXwR0cIJZx1T4NIwTEpPKzY+EzCLdsCDe iAztvUSOQiWWnfwrPIW5gcgYRte7G+oIJuOfunmyLiLUaxPtnFR9tXVSECjDQzUYrPJU jnZhBNuIfORTaHmHTuqHNE5ayOt5U9qDAQrFuia3fLSFbWpVtIMvk/igf0IPoBHURvFI zo5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=9Au+qoSVHB4VwxC9iKkQR94HxlbBA0K+/1PBJPfppOc=; b=QOsg7kS/5gkIKaBLftb3uIS9v5VyoJTp3BD6D2C0i3+Yx5yhyjHTzn80LXP4hPQeAm 8m7muyIAKUCTm1SY5uJzsdapLjaoHEmpVn5wQ/liN1s7cFMys2a7KxFy+OLUnB5CYdON TOX1rcrg31THqSzLdgsy1MeZcdhZDFPVa6F4Q7E5cNSzU5FM9NOQl8MQvI/2djOht4ds 9FCq3r95jZluOqaMZ/wHd/MFI0/pmQQmfmlIJZzw1D4Zta53r4kSGLXNDyfsetyamPOu LGVcckx15d0vIBLDX0mCcWqULIVt9wSxpruwx4Ht+PamHiyA3FTnMRMnN2TdIhdQBEmw ww9Q== X-Gm-Message-State: AOAM531hz/bb7KSURgtBhSzJ3X0zNn0EGLq+RV4FKAV8DA5LwVIznnYq ke+LDKF9gKJRiuSxI3/WDYFFlnK8osU= X-Received: by 2002:a9d:1d7:: with SMTP id e81mr2707555ote.171.1626167180499; Tue, 13 Jul 2021 02:06:20 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id x30sm3762921ote.44.2021.07.13.02.06.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 13 Jul 2021 02:06:19 -0700 (PDT) Sender: Guenter Roeck Subject: Re: [PATCH 1/1] PCI: Coalesce host bridge contiguous apertures without sorting To: Kai-Heng Feng Cc: Bjorn Helgaas , "open list:PCI SUBSYSTEM" , open list References: <20210713075726.1232938-1-kai.heng.feng@canonical.com> From: Guenter Roeck Message-ID: <346ae622-de15-b81d-c129-24c9e77b59d4@roeck-us.net> Date: Tue, 13 Jul 2021 02:06:18 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/13/21 1:49 AM, Kai-Heng Feng wrote: > On Tue, Jul 13, 2021 at 4:45 PM Guenter Roeck wrote: >> >> On 7/13/21 12:57 AM, Kai-Heng Feng wrote: >>> Commit 65db04053efe ("PCI: Coalesce host bridge contiguous apertures") >>> sorts the resources by address so the resources can be swapped. >>> >>> Before: >>> PCI host bridge to bus 0002:00 >>> pci_bus 0002:00: root bus resource [io 0x0000-0xffff] >>> pci_bus 0002:00: root bus resource [mem 0xd80000000-0xdffffffff] (bus address [0x80000000-0xffffffff]) >>> pci_bus 0002:00: root bus resource [mem 0xc0ee00000-0xc0eefffff] (bus address [0x00000000-0x000fffff]) >>> >>> And after: >>> PCI host bridge to bus 0002:00 >>> pci_bus 0002:00: root bus resource [io 0x0000-0xffff] >>> pci_bus 0002:00: root bus resource [mem 0xc0ee00000-0xc0eefffff] (bus address [0x00000000-0x000fffff]) >>> pci_bus 0002:00: root bus resource [mem 0xd80000000-0xdffffffff] (bus address [0x80000000-0xffffffff]) >>> >>> However, the sorted resources make NVMe stops working on QEMU ppc:sam460ex. >>> >>> Resources in the original issue are already in ascending order: >>> pci_bus 0000:00: root bus resource [mem 0x10020200000-0x100303fffff window] >>> pci_bus 0000:00: root bus resource [mem 0x10030400000-0x100401fffff window] >>> >>> So remove the sorting part to resolve the issue. >>> >>> Reported-by: Guenter Roeck >>> Fixes: 65db04053efe ("PCI: Coalesce host bridge contiguous apertures") >>> Signed-off-by: Kai-Heng Feng >> >> I think the original commit message would make more sense here. This patch >> doesn't fix 65db04053efe, it replaces it. The commit message now misses >> the point, and the patch coalesces continuous apertures without explaining >> the reason. > > Because the message is already in the git log so I didn't think that's > necessary. Hmm, not my decision to make, but the original commit got reverted. The commit log associated with this patch should still reflect what the patch does. Guenter > Will send another one with the original message along with this one. > > Kai-Heng > >> >> Guenter >> >>> --- >>> drivers/pci/probe.c | 31 +++++++++++++++++++++++++++---- >>> 1 file changed, 27 insertions(+), 4 deletions(-) >>> >>> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c >>> index 79177ac37880..5de157600466 100644 >>> --- a/drivers/pci/probe.c >>> +++ b/drivers/pci/probe.c >>> @@ -877,11 +877,11 @@ static void pci_set_bus_msi_domain(struct pci_bus *bus) >>> static int pci_register_host_bridge(struct pci_host_bridge *bridge) >>> { >>> struct device *parent = bridge->dev.parent; >>> - struct resource_entry *window, *n; >>> + struct resource_entry *window, *next, *n; >>> struct pci_bus *bus, *b; >>> - resource_size_t offset; >>> + resource_size_t offset, next_offset; >>> LIST_HEAD(resources); >>> - struct resource *res; >>> + struct resource *res, *next_res; >>> char addr[64], *fmt; >>> const char *name; >>> int err; >>> @@ -961,11 +961,34 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge) >>> if (nr_node_ids > 1 && pcibus_to_node(bus) == NUMA_NO_NODE) >>> dev_warn(&bus->dev, "Unknown NUMA node; performance will be reduced\n"); >>> >>> + /* Coalesce contiguous windows */ >>> + resource_list_for_each_entry_safe(window, n, &resources) { >>> + if (list_is_last(&window->node, &resources)) >>> + break; >>> + >>> + next = list_next_entry(window, node); >>> + offset = window->offset; >>> + res = window->res; >>> + next_offset = next->offset; >>> + next_res = next->res; >>> + >>> + if (res->flags != next_res->flags || offset != next_offset) >>> + continue; >>> + >>> + if (res->end + 1 == next_res->start) { >>> + next_res->start = res->start; >>> + res->flags = res->start = res->end = 0; >>> + } >>> + } >>> + >>> /* Add initial resources to the bus */ >>> resource_list_for_each_entry_safe(window, n, &resources) { >>> - list_move_tail(&window->node, &bridge->windows); >>> offset = window->offset; >>> res = window->res; >>> + if (!res->end) >>> + continue; >>> + >>> + list_move_tail(&window->node, &bridge->windows); >>> >>> if (res->flags & IORESOURCE_BUS) >>> pci_bus_insert_busn_res(bus, bus->number, res->end); >>> >>