From patchwork Mon Apr 10 11:58:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 748971 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3w1pm721bwz9sD5 for ; Mon, 10 Apr 2017 22:05:27 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EEihzPLA"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3w1pm70xLhzDqKB for ; Mon, 10 Apr 2017 22:05:27 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EEihzPLA"; dkim-atps=neutral X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3w1pgd6YVDzDqFn for ; Mon, 10 Apr 2017 22:01:33 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="EEihzPLA"; dkim-atps=neutral Received: by mail-pg0-x244.google.com with SMTP id 79so25504515pgf.0 for ; Mon, 10 Apr 2017 05:01:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pu3ECqgAylE7ud1soLBgT+hqo6tjnzDRrEmDwV02muU=; b=EEihzPLAxkKBrCnHHpBRo51VTXERxCKheW4wDHvPp7m5GeSVMcN2/VgV9Ti83XhgeO O1LQrh2TzteiDXWtt1hxjEgh2LhZsu+IvNPIncEv5l6Wi2SwOuCgpsfz4ephMjCKFMl+ pRpnnGKGEcSa9pEZ8vcdMJEhDqrWMRl7jOr4nytbkr4dLVnDt1apIMhr/vTSKIXh/8Mw M7dxhgme8hPQwbb2gwat2yzYq+85CySstRfkKAUpp2c8Gn/DWSmGYRTrWv+d+DjUhPzk szIOxnyNmjULf+lJAdtMjSYK6PUWbVG3aJM92jwxPNzCW8oUXIIsAy9sGC+RpYiauCpn VXjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pu3ECqgAylE7ud1soLBgT+hqo6tjnzDRrEmDwV02muU=; b=bItIbv4DmGjm6moE/nKWNH8vrSvXlv8kWNbNwGj5IU9SK4Bih2olLSdjWIcbl3NYgv gJcJXsjEkwLaYjQUJBdn5NsIIQv7bTngcQYGW1QvpPcEMno3DfJgUBlJGF6Scs4ZJ5UX v2X4Y/zWTwd43ui3t0NSJsRP0jwEL81nowAxeKc9kdzL+4y4qajuXUknSkEJ3LGqOCc9 VGeUYMBgoxwl91cCHBx47dbUIz1RwudoN9e8NuWFOuqHq+jZiqKB7ycqNyRLnC0Pb2vB 7MIVCCev1vM76/wdxY7x6jqrh/GrOObu+WKWJY/Ofyvcdt57WYz5oER29t5YTSxhvgWo XORQ== X-Gm-Message-State: AFeK/H2XvbzwUfRuQlJz/39bAWvuENDMZRdAVHAIrdmJrM1o23YVgctBAqSC0M5MVgB5zQ== X-Received: by 10.99.9.66 with SMTP id 63mr56320946pgj.22.1491825691884; Mon, 10 Apr 2017 05:01:31 -0700 (PDT) Received: from localhost ([116.247.112.152]) by smtp.gmail.com with ESMTPSA id h71sm24481917pfj.65.2017.04.10.05.01.31 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 10 Apr 2017 05:01:31 -0700 (PDT) From: Yongji Xie To: bhelgaas@google.com Subject: [PATCH v10 2/4] PCI: Add pcibios_default_alignment() for arch-specific alignment control Date: Mon, 10 Apr 2017 19:58:12 +0800 Message-Id: <1491825494-19331-3-git-send-email-elohimes@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1491825494-19331-1-git-send-email-elohimes@gmail.com> References: <1491825494-19331-1-git-send-email-elohimes@gmail.com> X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: zhong@linux.vnet.ibm.com, aik@ozlabs.ru, linux-pci@vger.kernel.org, gwshan@linux.vnet.ibm.com, alex.williamson@redhat.com, paulus@samba.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" When VFIO passes through a PCI device to a guest, it does not allow the guest to mmap BARs that are smaller than PAGE_SIZE unless it can reserve the rest of the page (see vfio_pci_probe_mmaps()). This is because a page might contain several small BARs for unrelated devices and a guest should not be able to access all of them. VFIO emulates guest accesses to non-mappable BARs, which is functional but slow. On systems with large page sizes, e.g., PowerNV with 64K pages, BARs are more likely to share a page and performance is more likely to be a problem. Add a weak function to set default alignment for all PCI devices. An arch can override it to force the PCI core to place memory BARs on their own pages. Signed-off-by: Yongji Xie --- drivers/pci/pci.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 7904d02..02f1255 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4947,6 +4947,11 @@ void pci_ignore_hotplug(struct pci_dev *dev) } EXPORT_SYMBOL_GPL(pci_ignore_hotplug); +resource_size_t __weak pcibios_default_alignment(struct pci_dev *dev) +{ + return 0; +} + #define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0}; static DEFINE_SPINLOCK(resource_alignment_lock); @@ -4962,14 +4967,15 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev) { int seg, bus, slot, func, align_order, count; unsigned short vendor, device, subsystem_vendor, subsystem_device; - resource_size_t align = 0; + resource_size_t align = pcibios_default_alignment(dev); char *p; spin_lock(&resource_alignment_lock); p = resource_alignment_param; - if (!*p) + if (!*p && !align) goto out; if (pci_has_flag(PCI_PROBE_ONLY)) { + align = 0; pr_info_once("PCI: Ignoring requested alignments (PCI_PROBE_ONLY)\n"); goto out; }