From patchwork Wed May 8 02:41:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Anastasio X-Patchwork-Id: 1096682 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44zQVK52W6z9s6w for ; Wed, 8 May 2019 15:47:37 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=anastas.io Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=anastas.io header.i=@anastas.io header.b="OF63QBue"; 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 44zQVK3z9LzDqQq for ; Wed, 8 May 2019 15:47:37 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=anastas.io (client-ip=104.248.188.109; helo=alpha.anastas.io; envelope-from=shawn@anastas.io; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=anastas.io Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=anastas.io header.i=@anastas.io header.b="OF63QBue"; dkim-atps=neutral Received: from alpha.anastas.io (alpha.anastas.io [104.248.188.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44zQT54r8nzDqJX for ; Wed, 8 May 2019 15:46:33 +1000 (AEST) Received: from authenticated-user (alpha.anastas.io [104.248.188.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alpha.anastas.io (Postfix) with ESMTPSA id B77C17F8E4; Tue, 7 May 2019 21:41:55 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=anastas.io; s=mail; t=1557283316; bh=nf95epbdL+CZevupMmf9m+9w2BZaXHsLR33tgT+SYxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OF63QBueAqOwtfAoiXSBbjeG7B5TmhwbsNMnKCj1TKUYXr7GJV23+H9/Yb0/4aGUm pqWHa214o+SHJ9Wc9tp2zvAicAqM3LsBHOxpurwQmpwi5RQO3Zq2Iq28yX+58uf3Oo V4BOLqUQ4+bPfhRZ7MD5M5C0/xmxBCDmdNsF6N6DtmLNDwWhgJW2MNz5tMB3bjwRfJ inJ7Kfn8bsfU2pFx+l7F0Dj6BxG/95XTNed/b2GCD06Lt7ffhFdlb1ZtTiu/OKY7K6 ZGClKHNy0w0krc5h/eu0iHygkCfo1kzyouvMEwSLqocIL3jTz6a25c1hmN+7+35W0t 1RvK3UPtB7GVA== From: Shawn Anastasio To: bhelgaas@google.com Subject: [PATCH 1/3] PCI: Introduce pcibios_ignore_alignment_request Date: Tue, 7 May 2019 21:41:49 -0500 Message-Id: <20190508024151.5690-2-shawn@anastas.io> In-Reply-To: <20190508024151.5690-1-shawn@anastas.io> References: <20190508024151.5690-1-shawn@anastas.io> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sbobroff@linux.ibm.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, rppt@linux.ibm.com, xyjxie@linux.vnet.ibm.com, paulus@samba.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Introduce a new pcibios function pcibios_ignore_alignment_request which allows the PCI core to defer to platform-specific code to determine whether or not to ignore alignment requests for PCI resources. The existing behavior is to simply ignore alignment requests when PCI_PROBE_ONLY is set. This is behavior is maintained by the default implementation of pcibios_ignore_alignment_request. Signed-off-by: Shawn Anastasio --- drivers/pci/pci.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 766f5779db92..e7a925f2188e 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -5896,6 +5896,11 @@ resource_size_t __weak pcibios_default_alignment(void) return 0; } +int __weak pcibios_ignore_alignment_request(void) +{ + return pci_has_flag(PCI_PROBE_ONLY); +} + #define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0}; static DEFINE_SPINLOCK(resource_alignment_lock); @@ -5920,9 +5925,9 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev, p = resource_alignment_param; if (!*p && !align) goto out; - if (pci_has_flag(PCI_PROBE_ONLY)) { + if (pcibios_ignore_alignment_request()) { align = 0; - pr_info_once("PCI: Ignoring requested alignments (PCI_PROBE_ONLY)\n"); + pr_info_once("PCI: Ignoring requested alignments\n"); goto out; } From patchwork Wed May 8 02:41:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Anastasio X-Patchwork-Id: 1096775 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44zS2T3p8Qz9s55 for ; Wed, 8 May 2019 16:57:05 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=anastas.io Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=anastas.io header.i=@anastas.io header.b="nlDGly5X"; 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 44zS2T2bLlzDqNV for ; Wed, 8 May 2019 16:57:05 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=anastas.io (client-ip=104.248.188.109; helo=alpha.anastas.io; envelope-from=shawn@anastas.io; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=anastas.io Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=anastas.io header.i=@anastas.io header.b="nlDGly5X"; dkim-atps=neutral Received: from alpha.anastas.io (alpha.anastas.io [104.248.188.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44zS1J2MlqzDqC9 for ; Wed, 8 May 2019 16:56:04 +1000 (AEST) Received: from authenticated-user (alpha.anastas.io [104.248.188.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alpha.anastas.io (Postfix) with ESMTPSA id BA4827F8E7; Tue, 7 May 2019 21:41:56 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=anastas.io; s=mail; t=1557283317; bh=EGTrKlRnXu1zsiLLv/Fv7FG8sil5S0AhH+klcU6GwLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nlDGly5XpDrBjpNOi9Nf7fW+YeMrjdtv20gQQUn+rtuu5/tvQln3k5As3jyUWvgl/ HbQtmxPs8UXfoFVnO5Dq/k8um/OvYxaenLK3OCuMOf8pyW6Xqlm3BJlk21iSK8clGB GH5inQEprc53R4qVnZeIfbhG9S7mGlco0B7aFP5dCxko5NpyHJCFDT8ZK4th+osGEN 6BFtGnErEwRNn+E3qq25XiHQuopNJdAMYKgivrOSlAmlEoiYv3quLYH4IbhTbYnPTV +QPgONSh8FuZKvrPqCLdaXE8IB3gFL4hQHBGzqxKyHO4J7SdR6zs3MzyewG/QrDFP1 /UEm+XMDaPZFQ== From: Shawn Anastasio To: bhelgaas@google.com Subject: [PATCH 2/3] powerpc/64: Enable pcibios_after_init hook on ppc64 Date: Tue, 7 May 2019 21:41:50 -0500 Message-Id: <20190508024151.5690-3-shawn@anastas.io> In-Reply-To: <20190508024151.5690-1-shawn@anastas.io> References: <20190508024151.5690-1-shawn@anastas.io> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sbobroff@linux.ibm.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, rppt@linux.ibm.com, xyjxie@linux.vnet.ibm.com, paulus@samba.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" Enable the pcibios_after_init hook on all powerpc platforms. This hook is executed at the end of pcibios_init and was previously only available on CONFIG_PPC32. Since it is useful and not inherently limited to 32-bit mode, remove the limitation and allow it on all powerpc platforms. Signed-off-by: Shawn Anastasio --- arch/powerpc/include/asm/machdep.h | 3 +-- arch/powerpc/kernel/pci_64.c | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h index 2f0ca6560e47..2fbfaa9176ed 100644 --- a/arch/powerpc/include/asm/machdep.h +++ b/arch/powerpc/include/asm/machdep.h @@ -150,6 +150,7 @@ struct machdep_calls { void (*init)(void); void (*kgdb_map_scc)(void); +#endif /* CONFIG_PPC32 */ /* * optional PCI "hooks" @@ -157,8 +158,6 @@ struct machdep_calls { /* Called at then very end of pcibios_init() */ void (*pcibios_after_init)(void); -#endif /* CONFIG_PPC32 */ - /* Called in indirect_* to avoid touching devices */ int (*pci_exclude_device)(struct pci_controller *, unsigned char, unsigned char); diff --git a/arch/powerpc/kernel/pci_64.c b/arch/powerpc/kernel/pci_64.c index 9d8c10d55407..fba7fe6e4a50 100644 --- a/arch/powerpc/kernel/pci_64.c +++ b/arch/powerpc/kernel/pci_64.c @@ -68,6 +68,10 @@ static int __init pcibios_init(void) printk(KERN_DEBUG "PCI: Probing PCI hardware done\n"); + /* Call machine dependent post-init code */ + if (ppc_md.pcibios_after_init) + ppc_md.pcibios_after_init(); + return 0; } From patchwork Wed May 8 02:41:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Anastasio X-Patchwork-Id: 1096684 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44zQWk0D7lz9s55 for ; Wed, 8 May 2019 15:48:50 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=anastas.io Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=anastas.io header.i=@anastas.io header.b="fpJCAPjE"; 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 44zQWj6SlSzDqQZ for ; Wed, 8 May 2019 15:48:49 +1000 (AEST) X-Original-To: linuxppc-dev@lists.ozlabs.org Delivered-To: linuxppc-dev@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=anastas.io (client-ip=104.248.188.109; helo=alpha.anastas.io; envelope-from=shawn@anastas.io; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=anastas.io Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=anastas.io header.i=@anastas.io header.b="fpJCAPjE"; dkim-atps=neutral Received: from alpha.anastas.io (alpha.anastas.io [104.248.188.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 44zQT55sjrzDqLD for ; Wed, 8 May 2019 15:46:33 +1000 (AEST) Received: from authenticated-user (alpha.anastas.io [104.248.188.109]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alpha.anastas.io (Postfix) with ESMTPSA id C3C847F8E9; Tue, 7 May 2019 21:41:57 -0500 (CDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=anastas.io; s=mail; t=1557283318; bh=NkudzRVjZwK8lfclmmYkCIVdF6pby8ZJf/uHpomfJrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fpJCAPjErySQROJkqZpixSeWqaUVJJzawqjQyqdW7t39zeEH9PmmI9DB7EO13UtOq RpvXSPxHjEJeEsH9agvTKzb3vu+FfzKagl3JIES2Rx8u1gbWs7/AJVJUZ6G/QP4erB xJQzpp98YWWDkhSIK4jmBTeslTgrpnoAckWamK/wCE26uNAVuU8IKTpcWG+rKDL/Ae GKemB1UcGQNg16WVprwBOypaaEtBPHf4W6M4HzTiAggjAffYTMb4bvP57GPVWRg4hL D7vc4WwWMoKzIPJuoSFoLPkXBotjjy27GDfW2Jf5RYi/+YdZrg8+S1n19Nat3pvvLj ClEDTEjvulaaA== From: Shawn Anastasio To: bhelgaas@google.com Subject: [PATCH 3/3] powerpc/pseries: Allow user-specified PCI resource alignment after init Date: Tue, 7 May 2019 21:41:51 -0500 Message-Id: <20190508024151.5690-4-shawn@anastas.io> In-Reply-To: <20190508024151.5690-1-shawn@anastas.io> References: <20190508024151.5690-1-shawn@anastas.io> MIME-Version: 1.0 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: sbobroff@linux.ibm.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, rppt@linux.ibm.com, xyjxie@linux.vnet.ibm.com, paulus@samba.org, linuxppc-dev@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Sender: "Linuxppc-dev" On pseries, custom PCI resource alignment specified with the commandline argument pci=resource_alignment is disabled due to PCI resources being managed by the firmware. However, in the case of PCI hotplug the resources are managed by the kernel, so custom alignments should be honored in these cases. This is done by only honoring custom alignments after initial PCI initialization is done, to ensure that all devices managed by the firmware are excluded. Without this ability, sub-page BARs sometimes get mapped in between page boundaries for hotplugged devices and are therefore unusable with the VFIO framework. This change allows users to request page alignment for devices they wish to access via VFIO using the pci=resource_alignment commandline argument. In the future, this could be extended to provide page-aligned resources by default for hotplugged devices, similar to what is done on powernv by commit 382746376993 ("powerpc/powernv: Override pcibios_default_alignment() to force PCI devices to be page aligned") Signed-off-by: Shawn Anastasio --- arch/powerpc/include/asm/machdep.h | 3 +++ arch/powerpc/kernel/pci-common.c | 9 +++++++++ arch/powerpc/platforms/pseries/setup.c | 22 ++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h index 2fbfaa9176ed..46eb62c0954e 100644 --- a/arch/powerpc/include/asm/machdep.h +++ b/arch/powerpc/include/asm/machdep.h @@ -179,6 +179,9 @@ struct machdep_calls { resource_size_t (*pcibios_default_alignment)(void); + /* Called when determining PCI resource alignment */ + int (*pcibios_ignore_alignment_request)(void); + #ifdef CONFIG_PCI_IOV void (*pcibios_fixup_sriov)(struct pci_dev *pdev); resource_size_t (*pcibios_iov_resource_alignment)(struct pci_dev *, int resno); diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c index ff4b7539cbdf..1a6ded45a701 100644 --- a/arch/powerpc/kernel/pci-common.c +++ b/arch/powerpc/kernel/pci-common.c @@ -238,6 +238,15 @@ resource_size_t pcibios_default_alignment(void) return 0; } +resource_size_t pcibios_ignore_alignment_request(void) +{ + if (ppc_md.pcibios_ignore_alignment_request) + return ppc_md.pcibios_ignore_alignment_request(); + + /* Fall back to default method of checking PCI_PROBE_ONLY */ + return pci_has_flag(PCI_PROBE_ONLY); +} + #ifdef CONFIG_PCI_IOV resource_size_t pcibios_iov_resource_alignment(struct pci_dev *pdev, int resno) { diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c index e4f0dfd4ae33..c6af2ed8ee0f 100644 --- a/arch/powerpc/platforms/pseries/setup.c +++ b/arch/powerpc/platforms/pseries/setup.c @@ -82,6 +82,8 @@ EXPORT_SYMBOL(CMO_PageSize); int fwnmi_active; /* TRUE if an FWNMI handler is present */ +int initial_pci_init_done; /* TRUE if initial pcibios init has completed */ + static void pSeries_show_cpuinfo(struct seq_file *m) { struct device_node *root; @@ -749,6 +751,23 @@ static resource_size_t pseries_pci_iov_resource_alignment(struct pci_dev *pdev, } #endif +static void pseries_after_init(void) +{ + initial_pci_init_done = 1; +} + +static int pseries_ignore_alignment_request(void) +{ + if (initial_pci_init_done) + /* + * Allow custom alignments after init for things + * like PCI hotplugging. + */ + return 0; + + return pci_has_flag(PCI_PROBE_ONLY); +} + static void __init pSeries_setup_arch(void) { set_arch_panic_timeout(10, ARCH_PANIC_TIMEOUT); @@ -797,6 +816,9 @@ static void __init pSeries_setup_arch(void) } ppc_md.pcibios_root_bridge_prepare = pseries_root_bridge_prepare; + ppc_md.pcibios_after_init = pseries_after_init; + ppc_md.pcibios_ignore_alignment_request = + pseries_ignore_alignment_request; } static void pseries_panic(char *str)