From patchwork Mon Feb 1 10:25:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 8177711 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 47EB69F4DD for ; Mon, 1 Feb 2016 10:24:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5AEDD20434 for ; Mon, 1 Feb 2016 10:24:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5308E20430 for ; Mon, 1 Feb 2016 10:24:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753680AbcBAKYM (ORCPT ); Mon, 1 Feb 2016 05:24:12 -0500 Received: from foss.arm.com ([217.140.101.70]:47076 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753684AbcBAKYJ (ORCPT ); Mon, 1 Feb 2016 05:24:09 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 3EBE049; Mon, 1 Feb 2016 02:23:25 -0800 (PST) Received: from red-moon.cambridge.arm.com (red-moon.cambridge.arm.com [10.1.203.137]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C3AD03F2E5; Mon, 1 Feb 2016 02:24:06 -0800 (PST) From: Lorenzo Pieralisi To: linux-pci@vger.kernel.org Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, Lorenzo Pieralisi , Bjorn Helgaas , Hanjun Guo , Jiang Liu , Tony Luck , Tomasz Nowicki , Mark Salter , "Rafael J. Wysocki" Subject: [PATCH] PCI: ACPI: IA64: fix IO port generic range check Date: Mon, 1 Feb 2016 10:25:57 +0000 Message-Id: <1454322357-10912-1-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 2.5.1 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.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 The [0 - 64k] ACPI PCI IO port resource boundary check in: acpi_dev_ioresource_flags() is currently applied blindly in the ACPI resource parsing to all architectures, but only x86 suffers from that IO space limitation. The check in generic ACPI code leaves other arches (ie IA64) IO space broken (ie kernel can't claim IO resources since the host bridge IO resource is disabled and discarded by ACPI core code, eg log on IA64): pci 0000:00:03.0: [1002:515e] type 00 class 0x030000 pci 0000:00:03.0: reg 0x10: [mem 0x80000000-0x87ffffff pref] pci 0000:00:03.0: reg 0x14: [io 0x1000-0x10ff] pci 0000:00:03.0: reg 0x18: [mem 0x88020000-0x8802ffff] pci 0000:00:03.0: reg 0x30: [mem 0x88000000-0x8801ffff pref] pci 0000:00:03.0: supports D1 D2 pci 0000:00:03.0: can't claim BAR 1 [io 0x1000-0x10ff]: no compatible bridge window For this reason, the IO port resources boundaries check in generic ACPI parsing code should be moved to x86 arch code so that more arches (ie ARM64) can benefit from the generic ACPI resources parsing interface without incurring in unexpected resource filtering, fixing at the same time current breakage on IA64. This patch moves the IO ports boundary [0 - 64k] check to x86 arch code code that validates the PCI host bridge resources. Fixes: 3772aea7d6f3 ("ia64/PCI/ACPI: Use common ACPI resource parsing interface for host bridge") Signed-off-by: Lorenzo Pieralisi Cc: Bjorn Helgaas Cc: Hanjun Guo Cc: Jiang Liu Cc: Tony Luck Cc: Tomasz Nowicki Cc: Mark Salter Cc: "Rafael J. Wysocki" Tested-by: Hanjun Guo --- arch/x86/pci/acpi.c | 18 +++++++++++++----- drivers/acpi/resource.c | 3 --- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/arch/x86/pci/acpi.c b/arch/x86/pci/acpi.c index 3cd6983..e20dbe5 100644 --- a/arch/x86/pci/acpi.c +++ b/arch/x86/pci/acpi.c @@ -275,11 +275,14 @@ static void pci_acpi_root_release_info(struct acpi_pci_root_info *ci) * to access PCI configuration space. * * So explicitly filter out PCI CFG IO ports[0xCF8-0xCFF]. + * + * Furthermore, IO ports address space is limited to 16k on x86, + * any IO resource exceeding the boundary must therefore be discarded. */ -static bool resource_is_pcicfg_ioport(struct resource *res) +static bool ioport_valid(struct resource *res) { - return (res->flags & IORESOURCE_IO) && - res->start == 0xCF8 && res->end == 0xCFF; + return !(res->start == 0xCF8 && res->end == 0xCFF) && + !(res->end >= 0x10003); } static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci) @@ -287,13 +290,18 @@ static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci) struct acpi_device *device = ci->bridge; int busnum = ci->root->secondary.start; struct resource_entry *entry, *tmp; + struct resource *res; int status; status = acpi_pci_probe_root_resources(ci); if (pci_use_crs) { - resource_list_for_each_entry_safe(entry, tmp, &ci->resources) - if (resource_is_pcicfg_ioport(entry->res)) + resource_list_for_each_entry_safe(entry, tmp, &ci->resources) { + res = entry->res; + + if (res->flags & IORESOURCE_IO && !ioport_valid(res)) resource_list_destroy_entry(entry); + } + return status; } diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c index d02fd53..c112e1d 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c @@ -127,9 +127,6 @@ static void acpi_dev_ioresource_flags(struct resource *res, u64 len, if (!acpi_dev_resource_len_valid(res->start, res->end, len, true)) res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET; - if (res->end >= 0x10003) - res->flags |= IORESOURCE_DISABLED | IORESOURCE_UNSET; - if (io_decode == ACPI_DECODE_16) res->flags |= IORESOURCE_IO_16BIT_ADDR; if (translation_type == ACPI_SPARSE_TRANSLATION)