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: 40404 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7FE7524237 for ; Fri, 7 Nov 2014 13:28:59 +0000 (UTC) Received: by mail-lb0-f197.google.com with SMTP id w7sf1886835lbi.0 for ; Fri, 07 Nov 2014 05:28:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=wjIEL/6IKgZ5wpLeb3qoJDz7WTSMcGDtJeiYfVJDISo=; b=EfjnbdArd79XQFxzfHRPYO2J+DjFo8LERMIye1TxCI/9JmMhK6MnCSWJBdNYNrWXSL k6cdtL0SGlWpMIl0e5ywAkZYSgKgWhwhKIC/yv4qtBpJrbQkBqZY40WYVt2SLm6r2Qaz StNc6m8VVaPr1Ah/RDdPkjPRiARlRYk+cLamjLTpyotv1LAM5vKgX3/dIQ1mluSdnke8 EMWWJkYKiUG+fRlMWpekR4t7FFWBAZUNnWnN2v/dq/uhpKOkh0mligYT4/yLADmq/sYm YBhYDjNMFSiOH3alZMw/klus9hgmGm2YoZtFLye8A7tVjh2qh4OvonCYOYlOUA1+LKhW /Ujw== X-Gm-Message-State: ALoCoQmeLeD0mtRutqAx7SvUPzKdDQPdfUmhhkKm2Up/mOG4QcYHz8kPCxYKsqs/n6qPm0t22Q8Z X-Received: by 10.112.32.163 with SMTP id k3mr53752lbi.17.1415366938527; Fri, 07 Nov 2014 05:28:58 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.207.9 with SMTP id ls9ls200235lac.44.gmail; Fri, 07 Nov 2014 05:28:58 -0800 (PST) X-Received: by 10.112.146.37 with SMTP id sz5mr11207612lbb.27.1415366938197; Fri, 07 Nov 2014 05:28:58 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id o6si11954043laj.25.2014.11.07.05.28.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 07 Nov 2014 05:28:57 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id z12so2607680lbi.22 for ; Fri, 07 Nov 2014 05:28:57 -0800 (PST) X-Received: by 10.112.130.41 with SMTP id ob9mr11089311lbb.74.1415366937728; Fri, 07 Nov 2014 05:28:57 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.184.201 with SMTP id ew9csp196549lbc; Fri, 7 Nov 2014 05:28:56 -0800 (PST) X-Received: by 10.66.248.196 with SMTP id yo4mr12179912pac.60.1415366936118; Fri, 07 Nov 2014 05:28:56 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id iv3si9109466pbd.30.2014.11.07.05.28.54 for ; Fri, 07 Nov 2014 05:28:56 -0800 (PST) Received-SPF: none (google.com: linux-acpi-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752854AbaKGN2x (ORCPT + 6 others); Fri, 7 Nov 2014 08:28:53 -0500 Received: from mail-wg0-f45.google.com ([74.125.82.45]:36698 "EHLO mail-wg0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752775AbaKGN2T (ORCPT ); Fri, 7 Nov 2014 08:28:19 -0500 Received: by mail-wg0-f45.google.com with SMTP id x12so3718953wgg.4 for ; Fri, 07 Nov 2014 05:28:18 -0800 (PST) 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-acpi-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: tomasz.nowicki@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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; + } +}