From patchwork Fri Jun 14 19:28:01 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 2723811 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 23F50C0AB1 for ; Fri, 14 Jun 2013 19:37:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3A07C20383 for ; Fri, 14 Jun 2013 19:37:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 36F4A2037F for ; Fri, 14 Jun 2013 19:37:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753677Ab3FNTgy (ORCPT ); Fri, 14 Jun 2013 15:36:54 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:57455 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753522Ab3FNTgw (ORCPT ); Fri, 14 Jun 2013 15:36:52 -0400 Received: by mail-pa0-f44.google.com with SMTP id lj1so956973pab.17 for ; Fri, 14 Jun 2013 12:36:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=UgVtngmYpepIs/SG9UNRMC3PGLz29jjhc7uUcOzBHwQ=; b=Im95v4B39b+aPQB4cvZIZWS7gMi42WR8AATdlG7L8egTaIZoM/u/WIueLjrwBcn0CG D3cgqDIkZZU3nudwGF8NZzABVVBGg7LPCwlHOvOkc0G62U2G89iSKFiZqkT59Ld0FoT0 rB/jWjGzsTX7vSj/OIMey+/J6J9u0PS3Fc3/C0nSJKDUehTyQCbthbZlBlw/VDlM3NAz pJUNZq6pQ56cidhLocfeKptudfeQooqAI3jAG6lDloKnu4lcTpx/jr3/sTOeKNA2Y6KG rCtMEA6AvqshAXmHU/iDxn+hEENRRZGNhKPyIOG6XTpr3OVWqy/TfjfMK3SqsAFSVm+p CdSA== X-Received: by 10.66.227.100 with SMTP id rz4mr3928783pac.47.1371238611429; Fri, 14 Jun 2013 12:36:51 -0700 (PDT) Received: from localhost.localdomain ([114.246.168.177]) by mx.google.com with ESMTPSA id tq8sm3276142pbc.30.2013.06.14.12.36.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 14 Jun 2013 12:36:50 -0700 (PDT) From: Jiang Liu To: "Rafael J . Wysocki" , Bjorn Helgaas , Yinghai Lu , "Alexander E . Patrakov" Cc: Jiang Liu , Greg Kroah-Hartman , Yijing Wang , linux-acpi@vger.kernel.org, Jiang Liu , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Subject: [BUGFIX v2 4/4] ACPIPHP: fix bug 56531 Sony VAIO VPCZ23A4R: can't assign mem/io after docking Date: Sat, 15 Jun 2013 03:28:01 +0800 Message-Id: <1371238081-32260-5-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1371238081-32260-1-git-send-email-jiang.liu@huawei.com> References: <1371238081-32260-1-git-send-email-jiang.liu@huawei.com> 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.1 required=5.0 tests=BAYES_00,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 Please refer to https://bugzilla.kernel.org/show_bug.cgi?id=56531 for more information. This issue is caused by differences in PCI resource assignment between boot time and runtime hotplug. On x86 platforms, OS respects PCI resource assignment from BIOS and only reassign resources for unassigned BARs at boot time. But with acpiphp, it ignores BIOS resource assignment and reassign all resources by itself. If we have enough resources, reassigning all PCI resources should work too, but it may fail if we are under resource constraints. On the other handle, current PCI MMIO alignment algorithm may waste huge MMIO address space if we have some PCI devices with huge MMIO BARs. On this Sony laptop, BIOS allocates limited MMIO resources for the dock station and the dock station has a gfx which has a 256MB MMIO BAR. So current acpiphp driver fails to allocate resources for most devices on the dock station. So change acpiphp driver to follow boot time behavior to respect BIOS resource assignment. Signed-off-by: Jiang Liu Reported-by: Alexander E. Patrakov Tested-by: Alexander E. Patrakov Cc: "Rafael J. Wysocki" Cc: linux-acpi@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Acked-by: Yinghai Lu --- drivers/pci/hotplug/acpiphp_glue.c | 7 +++++-- drivers/pci/pci.h | 5 +++++ drivers/pci/setup-bus.c | 8 ++++---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index a65203b..f4a53e9 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -687,6 +687,7 @@ static int __ref enable_device(struct acpiphp_slot *slot) struct pci_bus *bus = slot->bridge->pci_bus; struct acpiphp_func *func; int num, max, pass; + LIST_HEAD(add_list); if (slot->flags & SLOT_ENABLED) goto err_exit; @@ -711,13 +712,15 @@ static int __ref enable_device(struct acpiphp_slot *slot) max = pci_scan_bridge(bus, dev, max, pass); if (pass && dev->subordinate) { check_hotplug_bridge(slot, dev); - pci_bus_size_bridges(dev->subordinate); + pcibios_resource_survey_bus(dev->subordinate); + __pci_bus_size_bridges(dev->subordinate, + &add_list); } } } } - pci_bus_assign_resources(bus); + __pci_bus_assign_resources(bus, &add_list, NULL); acpiphp_sanitize_bus(bus); acpiphp_set_hpp_values(bus); acpiphp_set_acpi_region(slot); diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 68678ed..d1182c4 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -202,6 +202,11 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type, struct resource *res, unsigned int reg); int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type); void pci_configure_ari(struct pci_dev *dev); +void __ref __pci_bus_size_bridges(struct pci_bus *bus, + struct list_head *realloc_head); +void __ref __pci_bus_assign_resources(const struct pci_bus *bus, + struct list_head *realloc_head, + struct list_head *fail_head); /** * pci_ari_enabled - query ARI forwarding status diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index 16abaaa..d254e23 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c @@ -1044,7 +1044,7 @@ handle_done: ; } -static void __ref __pci_bus_size_bridges(struct pci_bus *bus, +void __ref __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head) { struct pci_dev *dev; @@ -1115,9 +1115,9 @@ void __ref pci_bus_size_bridges(struct pci_bus *bus) } EXPORT_SYMBOL(pci_bus_size_bridges); -static void __ref __pci_bus_assign_resources(const struct pci_bus *bus, - struct list_head *realloc_head, - struct list_head *fail_head) +void __ref __pci_bus_assign_resources(const struct pci_bus *bus, + struct list_head *realloc_head, + struct list_head *fail_head) { struct pci_bus *b; struct pci_dev *dev;