From patchwork Mon Jun 6 06:53:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Koehrer Mathias (ETAS/ESW5)" X-Patchwork-Id: 630656 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rNQQp3jCzz9snm for ; Mon, 6 Jun 2016 16:53:54 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751744AbcFFGxd (ORCPT ); Mon, 6 Jun 2016 02:53:33 -0400 Received: from smtp6-v.fe.bosch.de ([139.15.237.11]:55647 "EHLO smtp6-v.fe.bosch.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751039AbcFFGxb convert rfc822-to-8bit (ORCPT ); Mon, 6 Jun 2016 02:53:31 -0400 Received: from vsmta12.fe.internet.bosch.com (unknown [10.4.98.52]) by imta24.fe.bosch.de (Postfix) with ESMTP id C345BD801D7; Mon, 6 Jun 2016 08:53:29 +0200 (CEST) Received: from FE-MBX1012.de.bosch.com (vsgw24.fe.internet.bosch.com [10.4.98.24]) by vsmta12.fe.internet.bosch.com (Postfix) with ESMTP id A38661B806DE; Mon, 6 Jun 2016 08:53:29 +0200 (CEST) Received: from FE-MBX1012.de.bosch.com (10.3.230.70) by FE-MBX1012.de.bosch.com (10.3.230.70) with Microsoft SMTP Server (TLS) id 15.0.1178.4; Mon, 6 Jun 2016 08:53:29 +0200 Received: from FE-MBX1012.de.bosch.com ([fe80::310c:6b49:1d6e:47a]) by FE-MBX1012.de.bosch.com ([fe80::310c:6b49:1d6e:47a%18]) with mapi id 15.00.1178.000; Mon, 6 Jun 2016 08:53:29 +0200 From: "Koehrer Mathias (ETAS/ESW5)" To: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: "bhelgaas@google.com" , "hjk@hansjkoch.de" , "gregkh@linuxfoundation.org" Subject: [PATCH] Introducing kernel option to force all PCI memory resources to be page aligned. Fixes issues with uio based drivers. Thread-Topic: [PATCH] Introducing kernel option to force all PCI memory resources to be page aligned. Fixes issues with uio based drivers. Thread-Index: AdG/vxcwon8NFu60QvmxaucWzFSFpg== Date: Mon, 6 Jun 2016 06:53:28 +0000 Message-ID: Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.5.145.185] MIME-Version: 1.0 X-TM-AS-MML: disable X-TM-AS-Product-Ver: IMSS-7.1.0.1679-8.0.0.1202-22372.006 X-TMASE-MatchedRID: dmf/uHTIU0NFsw2Lp+kSuFu4M/xm4KZeO1IfDKON40lBL//DKiVcziLW R2TcjmIxv2B1Wiv+bnvem5jmylDk/URvFRsK8dbLsyw+ZJnFumSRrTsCYpUmUbC5w3HgF8UisCK oklRICMawWkXct5vEVxXnQhAagEV77c0is1Jg1FcOSj4RiINDEREpExiqy5VQwvQ8Ryq55PKLXz LbvRX261kPjJjN68LnRCeQ7M6ArNw6d8weoeLiaaOuVibdZNTvuP9+fQUL2ag5Ppb5c37FpyTIQ EaaFXm/4vM1YF6AJbY65tgsJWcFUSAHAopEd76vqkLntvHv2XgW6yi9I82LFh+Ed9iFHXR+n1NI +BBFiNHJf+4xm27BXQ== Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Some uio based PCI drivers (e.g. uio_cif) do not work if the assigned PCI memory resources are not page aligned. By using the kernel option "pci=resource_alignment" it is possible to force single PCI boards to use page alignment for their memory resources. However, this is fairly cumbersome if multiple of these cards are in use. This patch adds another kernel option "pci=resources_page_aligned" that allows to set the default alignment of PCI memory resources to be page aligned. Overwriting of this default alignment via "pci=resource_alignment" is still possible. Signed-off-by: Mathias Koehrer --- Documentation/kernel-parameters.txt | 1 + drivers/pci/pci.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: linux-4.7-rc1/Documentation/kernel-parameters.txt =================================================================== --- linux-4.7-rc1.orig/Documentation/kernel-parameters.txt +++ linux-4.7-rc1/Documentation/kernel-parameters.txt @@ -3004,6 +3004,7 @@ bytes respectively. Such letter suffixes PAGE_SIZE is used as alignment. PCI-PCI bridge can be specified, if resource windows need to be expanded. + resources_page_aligned Force all memory resources to be page aligned. ecrc= Enable/disable PCIe ECRC (transaction layer end-to-end CRC checking). bios: Use BIOS/firmware settings. This is the Index: linux-4.7-rc1/drivers/pci/pci.c =================================================================== --- linux-4.7-rc1.orig/drivers/pci/pci.c +++ linux-4.7-rc1/drivers/pci/pci.c @@ -4744,7 +4744,7 @@ EXPORT_SYMBOL_GPL(pci_ignore_hotplug); #define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0}; static DEFINE_SPINLOCK(resource_alignment_lock); - +static resource_size_t pci_default_resource_alignment = 0; /** * pci_specified_resource_alignment - get resource alignment specified by user. * @dev: the PCI device to get @@ -4755,7 +4755,7 @@ static DEFINE_SPINLOCK(resource_alignmen static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev) { int seg, bus, slot, func, align_order, count; - resource_size_t align = 0; + resource_size_t align = pci_default_resource_alignment; char *p; spin_lock(&resource_alignment_lock); @@ -5015,6 +5015,8 @@ static int __init pci_setup(char *str) } else if (!strncmp(str, "resource_alignment=", 19)) { pci_set_resource_alignment_param(str + 19, strlen(str + 19)); + } else if (!strncmp(str, "resources_page_aligned", 22)) { + pci_default_resource_alignment = PAGE_SIZE; } else if (!strncmp(str, "ecrc=", 5)) { pcie_ecrc_get_policy(str + 5); } else if (!strncmp(str, "hpiosize=", 9)) {