From patchwork Fri Nov 7 13:27:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Nowicki X-Patchwork-Id: 5252701 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 80AAC9F3ED for ; Fri, 7 Nov 2014 13:35:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9F66620145 for ; Fri, 7 Nov 2014 13:35:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B817D20107 for ; Fri, 7 Nov 2014 13:35:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752490AbaKGNfm (ORCPT ); Fri, 7 Nov 2014 08:35:42 -0500 Received: from mail-wi0-f179.google.com ([209.85.212.179]:59225 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752474AbaKGNfl (ORCPT ); Fri, 7 Nov 2014 08:35:41 -0500 Received: by mail-wi0-f179.google.com with SMTP id h11so4572806wiw.12 for ; Fri, 07 Nov 2014 05:35:39 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7AXrXok6Q1kvmTjAYGj65Uw+4ZHkUGAq7bLI5H2ys70=; b=NDnUzpA4abmCOxFYPrgLoljdKJryqxSZ+SGnlEUVITwn6Gb37f9Vr5h7CB9BV604dG gGBrThy4HkykubfNcBIvNKx9oSixMKF1AiBGrDUBQLBnHIYVcYi9BlS1cixKPgDN2gbq HiAWrLeMuXrfaFLbb66N5ALa1WmaH92pRi7WV4g4aYzHexxmqRAZQyvRP+aB/iM9lZ5r bwkZTngH0q2IRU2V2nt9p2yzEuTW4+iHDVVGphmZDNyhxlfTfQLC6PNMFAVdY7fvB1sP 5314TsAyH9nlw2y4IJHPJUg245eFtYBZpEIZITxR0cIomqiNpfy2wIv0rM0QqLdZDmHn phoQ== X-Gm-Message-State: ALoCoQmu0bOOsAZqvYqq0sqRkwRkzMKCLW7rJFBcsdcZHf/KyNHRnynwTbuIaUvoQbyoSORylGrZ X-Received: by 10.194.60.198 with SMTP id j6mr16423254wjr.30.1415366898290; Fri, 07 Nov 2014 05:28:18 -0800 (PST) Received: from tn-HP-4.semihalf.com ([80.82.22.190]) by mx.google.com with ESMTPSA id ce1sm11833490wjc.2.2014.11.07.05.28.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 07 Nov 2014 05:28:17 -0800 (PST) From: Tomasz Nowicki To: catalin.marinas@arm.com, will.deacon@arm.com, bhelgaas@google.com, Liviu.Dudau@arm.com, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, rjw@rjwysocki.net Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, linaro-acpi@lists.linaro.org, Tomasz Nowicki Subject: [RFC PATCH 3/4] arm64, acpi, pci: Add arch specific functions for mmconfig driver. Date: Fri, 7 Nov 2014 14:27:55 +0100 Message-Id: <1415366876-30811-4-git-send-email-tomasz.nowicki@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1415366876-30811-1-git-send-email-tomasz.nowicki@linaro.org> References: <1415366876-30811-1-git-send-email-tomasz.nowicki@linaro.org> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 These calls allow to map/unmap PCI config space ranges (which are specified in MMCFG ACPI table). Signed-off-by: Tomasz Nowicki --- arch/arm64/Kconfig | 3 ++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/mmconfig.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 73 insertions(+) create mode 100644 arch/arm64/kernel/mmconfig.c diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index aee6a60..f2bcb58 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -186,6 +186,9 @@ config PCI_DOMAINS_GENERIC config PCI_SYSCALL def_bool PCI +config PCI_MMCONFIG + def_bool PCI && ACPI + source "drivers/pci/Kconfig" source "drivers/pci/pcie/Kconfig" source "drivers/pci/hotplug/Kconfig" diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index f48e3f7..ec576e6 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -32,6 +32,7 @@ arm64-obj-$(CONFIG_KGDB) += kgdb.o arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o arm64-obj-$(CONFIG_PCI) += pci.o arm64-obj-$(CONFIG_ACPI) += acpi.o +arm64-obj-$(CONFIG_PCI_MMCONFIG) += mmconfig.o obj-y += $(arm64-obj-y) vdso/ obj-m += $(arm64-obj-m) diff --git a/arch/arm64/kernel/mmconfig.c b/arch/arm64/kernel/mmconfig.c new file mode 100644 index 0000000..b0ca0ec --- /dev/null +++ b/arch/arm64/kernel/mmconfig.c @@ -0,0 +1,69 @@ +/* + * mmconfig.c - Low-level direct PCI config space access via MMCONFIG + * + * This is an ARM64 version that allows the mmconfig space to be mapped. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + * + */ + +#include + +#define PREFIX "PCI: " + +static void __iomem *mcfg_ioremap(struct pci_mmcfg_region *cfg) +{ + void __iomem *addr; + u64 start, size; + int num_buses; + + start = cfg->address + PCI_MMCFG_BUS_OFFSET(cfg->start_bus); + num_buses = cfg->end_bus - cfg->start_bus + 1; + size = PCI_MMCFG_BUS_OFFSET(num_buses); + addr = ioremap_nocache(start, size); + if (addr) + addr -= PCI_MMCFG_BUS_OFFSET(cfg->start_bus); + return addr; +} + +int __init pci_mmcfg_arch_init(void) +{ + struct pci_mmcfg_region *cfg; + + list_for_each_entry(cfg, &pci_mmcfg_list, list) + if (pci_mmcfg_arch_map(cfg)) { + pci_mmcfg_arch_free(); + return 0; + } + + return 1; +} + +void __init pci_mmcfg_arch_free(void) +{ + struct pci_mmcfg_region *cfg; + + list_for_each_entry(cfg, &pci_mmcfg_list, list) + pci_mmcfg_arch_unmap(cfg); +} + +int pci_mmcfg_arch_map(struct pci_mmcfg_region *cfg) +{ + cfg->virt = mcfg_ioremap(cfg); + if (!cfg->virt) { + pr_err(PREFIX "can't map MMCONFIG at %pR\n", &cfg->res); + return -ENOMEM; + } + + return 0; +} + +void pci_mmcfg_arch_unmap(struct pci_mmcfg_region *cfg) +{ + if (cfg && cfg->virt) { + iounmap(cfg->virt + PCI_MMCFG_BUS_OFFSET(cfg->start_bus)); + cfg->virt = NULL; + } +}