From patchwork Wed Oct 9 23:25:02 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 3012551 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B86AFBF924 for ; Wed, 9 Oct 2013 23:25:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C946320255 for ; Wed, 9 Oct 2013 23:25:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id ADB9220272 for ; Wed, 9 Oct 2013 23:25:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754106Ab3JIXZI (ORCPT ); Wed, 9 Oct 2013 19:25:08 -0400 Received: from mail-ie0-f170.google.com ([209.85.223.170]:58026 "EHLO mail-ie0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753951Ab3JIXZH (ORCPT ); Wed, 9 Oct 2013 19:25:07 -0400 Received: by mail-ie0-f170.google.com with SMTP id x13so3572102ief.29 for ; Wed, 09 Oct 2013 16:25:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; bh=cbEoypVyMdqS1nO4DD4HAiBq34i+idVLIpZ7ZdFGsiQ=; b=gTXF3ci2HmMwZIcASssc/J7f0swDkHRBUcO3INZ76E/fQGDegvtzRiyHFBf7O/sxgR QbSXsbdJwpj5XsxeG3qUlsMXDqG7/mGLwCT0fR791hZL9DxCuGnTRVhVOhBHCPvEUbnJ KfBHHFdtolah2yHxFqUqJjcZ8DILWPpjTG/CVMrOFHcH9pHMREx5YOwcm4l1Kjay3FrN cAiD48nLUkoGj6sUK4Vo6eoL/DqgosI3jEQG3aeuPPR7mCPlAF3HPbm2tE9rvOH/ye66 T+Qx6PbnaAl3SxFcqr4R+D8to36HwCSbYsWaqBbBQfMoipcr6XfH8XBeSxi4J8Q62ZPP shgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=cbEoypVyMdqS1nO4DD4HAiBq34i+idVLIpZ7ZdFGsiQ=; b=NDl7Y1bQ8Yy5q4VEhSuG2E17+2IZPnztmuAamY9SEvRCQxubXF8nuB4HIOxe5nKa5K dBrzV/tad8I0GHoE3PxcJs8b9w9U212WeeBTQA/R+gHLbUwflVjOKkLLea2Jl+6L3apN uNZFzGeCZn/giNyCTGorvZKHSuMcICzDK3UUStAgqxcELARBg9zx8xgrQrtpVqcdgzdD 3MKmnw5sYEBH83wNxVELkiczNnq4HpVsroyTgnyY72/j/DLvJi1wnWzLGJlYplsW9JhW EJCSFBnNcqX3ek8yFFSPMh13wluwwRlhComzXoWbgXq4HNVog5CcCyjjU7wIQzsEUZyJ LPvg== X-Gm-Message-State: ALoCoQkiDgp4w3sUJAezZYArNrR8Bd37EaW/neqmevOIQ4c2Kuw9H2Gcb8S+pcasY5qOSQwVpaLwZ8iUWOvhddjmo5IZQeC0XNXxTEAcZ7An72KQaUjTAKgJJps07NWZrEm136izg9bI3ensR0FZBgSg6LjJfMQGBDasUMVNdcc+gb7NpCz3apfuf/i7qP6HFg3hfbGq0Jpq8lzHHIkSmCRqvxE5xnccCw== X-Received: by 10.43.151.12 with SMTP id kq12mr110777icc.55.1381361105783; Wed, 09 Oct 2013 16:25:05 -0700 (PDT) Received: from google.com ([172.16.55.100]) by mx.google.com with ESMTPSA id q6sm199844igi.0.2013.10.09.16.25.04 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 09 Oct 2013 16:25:05 -0700 (PDT) Date: Wed, 9 Oct 2013 17:25:02 -0600 From: Bjorn Helgaas To: Alexey Neyman Cc: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "Rafael J. Wysocki" , Feng Tang , Yijing Wang , x86@kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH] Fix coalescing host bridge windows in arch/x86/pci/acpi.c Message-ID: <20131009232502.GA3837@google.com> References: <6362938.J7ZtNEOFpc@mistral> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <6362938.J7ZtNEOFpc@mistral> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP [+cc linux-pci] On Sun, Sep 22, 2013 at 11:15:46PM -0700, Alexey Neyman wrote: > [Resending due to no response to the original message in a week] > > Hi all, > > I have a board with a BIOS bug that reports the following I/O port regions in > _CRS on one of the host bridges: > > 0x0000-0x03af // #0 > 0x03e0-0x0cf7 // #1 > 0x03b0-0x03bb // #2 > 0x03c0-0x03df // #3 > 0x0000-0xdfff // #4 > 0xf000-0xffff // #5 > > Obviously, region number #4 is erroneous as it overlaps with regions #0..3. > The code in coalesce_windows() in arch/x86/pci/acpi.c attempts to recover from > such kind of BIOS bugs by merging the overlapping regions. Current code > expands region #0 to 0x0000-0xdffff and makes region #4 ignored. As a result, > overlap of the expanded region #0 with regions #1..3 remains undetected (as > the inner loop already compared them with region #0). As a result, regions > #1..3 are inserted into the resource tree even though they overlap with > adjusted region #0 - which later results in resource conflicts for PCI devices > with IO ports in one of those regions (e.g., for an PCI IDE controller in > legacy mode - which has port 0x3f6). The kernel then refuses to initialize > these devices. > > The fix: instead of expanding res1 and ignoring res2, do the opposite. The > res2 window is yet to be compared against all windows between res1 and res2 > (regions #1..3 in the above example), so the resulting resource map will > include just the expanded region - and will ignore any overlapping ones. > > Signed-off-by: Alexey Neyman I added the bugzilla reference (thanks for that) and applied the following patch to my pci/misc branch for v3.13. Sorry this took so long; part of the reason was that it wasn't on linux-pci, so it didn't show up in the PCI patchwork. I also added a MAINTAINERS patch so in the future, get_maintainers.pl will include linux-pci and me as co-maintainer of arch/x86/pci/*. Also, it helps if you include the patch in-line rather than as an attachment because I have to manually combine the in-line changelog with the attached patch. Thanks for the fix and your persistence! Bjorn x86/PCI: Coalesce multiple overlapping host bridge windows From: Alexey Neyman Previously we coalesced windows by expanding the first overlapping one and making the second invalid. But we never look at the expanded first window again, so we fail to notice other windows that overlap it. For example, we coalesced these: [io 0x0000-0x03af] // #0 [io 0x03e0-0x0cf7] // #1 [io 0x0000-0xdfff] // #2 into these, which still overlap: [io 0x0000-0xdfff] // #0 [io 0x03e0-0x0cf7] // #1 The fix is to expand the *second* overlapping resource and ignore the first, so we get this instead with no overlaps: [io 0x0000-0xdfff] // #2 [bhelgaas: changelog] Reference: https://bugzilla.kernel.org/show_bug.cgi?id=62511 Signed-off-by: Alexey Neyman Signed-off-by: Bjorn Helgaas --- arch/x86/pci/acpi.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index b30e937..7fb24e5 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -354,12 +354,12 @@ static void coalesce_windows(struct pci_root_info *info, unsigned long type) * the kernel resource tree doesn't allow overlaps. */ if (resource_overlaps(res1, res2)) { - res1->start = min(res1->start, res2->start); - res1->end = max(res1->end, res2->end); + res2->start = min(res1->start, res2->start); + res2->end = max(res1->end, res2->end); dev_info(&info->bridge->dev, "host bridge window expanded to %pR; %pR ignored\n", - res1, res2); - res2->flags = 0; + res2, res1); + res1->flags = 0; } } }