From patchwork Mon Feb 9 15:22:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suravee Suthikulpanit X-Patchwork-Id: 5801621 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id DD2AFBF6C3 for ; Mon, 9 Feb 2015 15:23:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 158CD20117 for ; Mon, 9 Feb 2015 15:23:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1C35A2011E for ; Mon, 9 Feb 2015 15:23:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760689AbbBIPX2 (ORCPT ); Mon, 9 Feb 2015 10:23:28 -0500 Received: from mail-bn1on0135.outbound.protection.outlook.com ([157.56.110.135]:42644 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1760974AbbBIPX0 (ORCPT ); Mon, 9 Feb 2015 10:23:26 -0500 Received: from BY1PR0201CA0018.namprd02.prod.outlook.com (25.160.191.156) by BN1PR02MB197.namprd02.prod.outlook.com (10.242.214.146) with Microsoft SMTP Server (TLS) id 15.1.81.19; Mon, 9 Feb 2015 15:23:23 +0000 Received: from BY2FFO11FD045.protection.gbl (2a01:111:f400:7c0c::145) by BY1PR0201CA0018.outlook.office365.com (2a01:111:e400:4814::28) with Microsoft SMTP Server (TLS) id 15.1.81.19 via Frontend Transport; Mon, 9 Feb 2015 15:23:22 +0000 Received: from atltwp01.amd.com (165.204.84.221) by BY2FFO11FD045.mail.protection.outlook.com (10.1.15.177) with Microsoft SMTP Server id 15.1.87.10 via Frontend Transport; Mon, 9 Feb 2015 15:23:21 +0000 X-WSS-ID: 0NJIG2V-07-7LK-02 X-M-MSG: Received: from satlvexedge02.amd.com (satlvexedge02.amd.com [10.177.96.29]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 24FAFCAE61F; Mon, 9 Feb 2015 09:23:19 -0600 (CST) Received: from SATLEXDAG01.amd.com (10.181.40.3) by SATLVEXEDGE02.amd.com (10.177.96.29) with Microsoft SMTP Server (TLS) id 14.3.195.1; Mon, 9 Feb 2015 09:23:40 -0600 Received: from ssuthiku-fedora-lt.amd.com (10.180.168.240) by SATLEXDAG01.amd.com (10.181.40.3) with Microsoft SMTP Server id 14.3.195.1; Mon, 9 Feb 2015 10:23:18 -0500 From: Suravee Suthikulpanit To: Bjorn Helgaas , Arnd Bergmann , "Will Deacon" , Catalin Marinas CC: Marc Zyngier , Lorenzo Pieralisi , Liviu Dudau , , , , Suravee Suthikulpanit Subject: [PATCH 2/2] PCI: Do not call pci_enable_resource when specifying PCI_PROBE_ONLY Date: Mon, 9 Feb 2015 23:22:30 +0800 Message-ID: <1423495350-12295-3-git-send-email-Suravee.Suthikulpanit@amd.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1423495350-12295-1-git-send-email-Suravee.Suthikulpanit@amd.com> References: <1423495350-12295-1-git-send-email-Suravee.Suthikulpanit@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 Received-SPF: None (protection.outlook.com: amd.com does not designate permitted sender hosts) Authentication-Results: spf=none (sender IP is 165.204.84.221) smtp.mailfrom=Suravee.Suthikulpanit@amd.com; arm.com; dkim=none (message not signed) header.d=none; X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(428002)(19580405001)(46102003)(87936001)(53416004)(50226001)(19580395003)(105586002)(86362001)(229853001)(47776003)(92566002)(106466001)(2950100001)(48376002)(62966003)(77156002)(50986999)(50466002)(77096005)(101416001)(76176999)(36756003); DIR:OUT; SFP:1102; SCL:1; SRVR:BN1PR02MB197; H:atltwp01.amd.com; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Antispam: UriScan:; X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;SRVR:BN1PR02MB197; X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004); SRVR:BN1PR02MB197; X-Forefront-PRVS: 04825EA361 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:;SRVR:BN1PR02MB197; X-OriginatorOrg: amd4.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2015 15:23:21.6465 (UTC) X-MS-Exchange-CrossTenant-Id: fde4dada-be84-483f-92cc-e026cbee8e96 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fde4dada-be84-483f-92cc-e026cbee8e96; Ip=[165.204.84.221] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR02MB197 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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 When using PCI_PROBE_ONLY, Linux does not assign resource to PCI devices. This causes error when calling the pci_enable_resources function, and not allowing driver to set the PCI_COMMAND_IO and PCI_COMMAND_MEMORY flag in the config space of endpoint device since it checks if the resource parent is set. This patch adds the check in driver/pci/pci.c to avoid redundant arch-specific code. For example, it was in arch/arm/kernel/bios32.c and also needed in the arch/arm64/kernel/pci.c. This should not affect other architecture since most of them either override the weak version of pcibios_enable_device() or does not set PCI_PROBE_ONLY. Cc: Bjorn Helgaas Cc: Arnd Bergmann Cc: Will Deacon Cc: Marc Zyngier Cc: Lorenzo Pieralisi Cc: Catalin Marinas Cc: Liviu Dudau Signed-off-by: Suravee Suthikulpanit --- NOTE: Alpha seems to be the only arch that dooes not define pcibios_enable_device() and also set PCI_PROBE_ONLY flag. I am not sure if this would cause any issues. I might need help testing on Alpha. arch/arm/kernel/bios32.c | 12 ------------ drivers/pci/pci.c | 3 +++ 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c index a4effd6..091f508 100644 --- a/arch/arm/kernel/bios32.c +++ b/arch/arm/kernel/bios32.c @@ -607,18 +607,6 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res, return start; } -/** - * pcibios_enable_device - Enable I/O and memory. - * @dev: PCI device to be enabled - */ -int pcibios_enable_device(struct pci_dev *dev, int mask) -{ - if (pci_has_flag(PCI_PROBE_ONLY)) - return 0; - - return pci_enable_resources(dev, mask); -} - int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, enum pci_mmap_state mmap_state, int write_combine) { diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e9d4fd8..1748f95 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1187,6 +1187,9 @@ EXPORT_SYMBOL_GPL(pci_load_and_free_saved_state); int __weak pcibios_enable_device(struct pci_dev *dev, int bars) { + if (pci_has_flag(PCI_PROBE_ONLY)) + return 0; + return pci_enable_resources(dev, bars); }