From patchwork Fri Dec 11 08:53:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yongji Xie X-Patchwork-Id: 7827381 Return-Path: X-Original-To: patchwork-kvm@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 552CF9F1C2 for ; Fri, 11 Dec 2015 08:56:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 67096204AF for ; Fri, 11 Dec 2015 08:56:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7922E20498 for ; Fri, 11 Dec 2015 08:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754295AbbLKIzw (ORCPT ); Fri, 11 Dec 2015 03:55:52 -0500 Received: from e23smtp01.au.ibm.com ([202.81.31.143]:35407 "EHLO e23smtp01.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752706AbbLKIzv (ORCPT ); Fri, 11 Dec 2015 03:55:51 -0500 Received: from localhost by e23smtp01.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 Dec 2015 18:55:48 +1000 Received: from d23dlp01.au.ibm.com (202.81.31.203) by e23smtp01.au.ibm.com (202.81.31.207) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 11 Dec 2015 18:55:47 +1000 X-IBM-Helo: d23dlp01.au.ibm.com X-IBM-MailFrom: xyjxie@linux.vnet.ibm.com X-IBM-RcptTo: kvm@vger.kernel.org; linux-api@vger.kernel.org; linux-kernel@vger.kernel.org Received: from d23relay10.au.ibm.com (d23relay10.au.ibm.com [9.190.26.77]) by d23dlp01.au.ibm.com (Postfix) with ESMTP id 0CBFD2CE8054; Fri, 11 Dec 2015 19:55:46 +1100 (EST) Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay10.au.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tBB8tc7d52822054; Fri, 11 Dec 2015 19:55:46 +1100 Received: from d23av01.au.ibm.com (localhost [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tBB8tCj0016733; Fri, 11 Dec 2015 19:55:13 +1100 Received: from localhost (commit.cn.ibm.com [9.123.229.41]) by d23av01.au.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tBB8tBAu016210; Fri, 11 Dec 2015 19:55:12 +1100 From: Yongji Xie To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Cc: aik@ozlabs.ru, alex.williamson@redhat.com, benh@kernel.crashing.org, paulus@samba.org, mpe@ellerman.id.au, warrier@linux.vnet.ibm.com, zhong@linux.vnet.ibm.com, nikunj@linux.vnet.ibm.com, Yongji Xie Subject: [RFC PATCH 1/3] powerpc/pci: Enforce all MMIO BARs to be page aligned Date: Fri, 11 Dec 2015 16:53:12 +0800 Message-Id: <1449823994-3356-2-git-send-email-xyjxie@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1449823994-3356-1-git-send-email-xyjxie@linux.vnet.ibm.com> References: <1449823994-3356-1-git-send-email-xyjxie@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15121108-1618-0000-0000-000003466D2C Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 PAGE_SIZE is 64KB by default on PPC64 platform. When vfio passthrough a pci device of which MMIO BARs are smaller than 64KB(PAGE_SIZE), guest would not handle the mmio accesses to the BARs which leads to mmio emulations in host. This is because vfio would not allow to passthrough one BAR's mmio page which may be shared with other BARs. To solve this performance issue, this patch enforces the alignment of all MMIO BARs allocations to be at least PAGE_SIZE on PPC64 platform because we have enough address space, so that one BAR's mmio page would not be shared with other BARs. Signed-off-by: Yongji Xie --- arch/powerpc/kernel/pci-common.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index 0f7a60f..6989e0f 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -1074,6 +1074,11 @@ static int skip_isa_ioresource_align(struct pci_dev *dev) * bits, so it's ok to allocate at, say, 0x2800-0x28ff, * but we want to try to avoid allocating at 0x2900-0x2bff * which might have be mirrored at 0x0100-0x03ff.. + * + * And for PPC64, we enforce the alignment of all MMIO BARs + * allocations to be at least PAGE_SIZE(64KB). This would be + * helpful to improve performance when we passthrough + * a PCI device of which BARs are smaller than PAGE_SIZE */ resource_size_t pcibios_align_resource(void *data, const struct resource *res, resource_size_t size, resource_size_t align) @@ -1087,7 +1092,10 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res, if (start & 0x300) start = (start + 0x3ff) & ~0x3ff; } - +#ifdef CONFIG_PPC64 + if (res->flags & IORESOURCE_MEM) + start = PAGE_ALIGN(start); +#endif return start; } EXPORT_SYMBOL(pcibios_align_resource);