From patchwork Tue Nov 11 15:48:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 40582 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1B861241C9 for ; Tue, 11 Nov 2014 15:48:58 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id c41sf7009372eek.8 for ; Tue, 11 Nov 2014 07:48:57 -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=axWSaWXc7Sic060o8coxuTUOGeEMW7uJNJ5EiaWHyyE=; b=AF9hduNni30pcFkqGSi/mRXdsbMlI64Aq4TmmkxvAERs4vfQtPdxTSC+OsyKsNxWz0 inqDQpKFJYqHvAd1BNx99esctn9jfb4FMX2BlZib4ibnUB2BlQYfj5cGSPKvprPYraSW PFD7sM2xs4H3u1khZlOcbz4UXifCIt0MqZvlCAosQRlNH8Wj7Py71ZBCB7uhN9rnykxX /jn1WC4CiFDS+F3dBZ1nkOobkTYkuz33yOpZ9pqeXORVsZP15CdbkxH/nMn7g88sd0I+ bkRBy8hgiZRmFx0fladbsrG8THt+vilnLrxi3sYfbaQ6tvT7EzpdZit/xSeawQH/C4R2 5WDQ== X-Gm-Message-State: ALoCoQlkEX1psISkD99iuJhD6peVC9gu8iyw1VlUy0t1nTSURn4Pk+Y28ZqY3+SGmdmqWpDp4aHp X-Received: by 10.152.6.4 with SMTP id w4mr559229law.7.1415720937272; Tue, 11 Nov 2014 07:48:57 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.37.103 with SMTP id x7ls512638laj.37.gmail; Tue, 11 Nov 2014 07:48:56 -0800 (PST) X-Received: by 10.152.87.100 with SMTP id w4mr36301183laz.27.1415720936903; Tue, 11 Nov 2014 07:48:56 -0800 (PST) Received: from mail-la0-f47.google.com (mail-la0-f47.google.com. [209.85.215.47]) by mx.google.com with ESMTPS id l8si31952006lah.23.2014.11.11.07.48.56 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Nov 2014 07:48:56 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 as permitted sender) client-ip=209.85.215.47; Received: by mail-la0-f47.google.com with SMTP id gd6so9830505lab.34 for ; Tue, 11 Nov 2014 07:48:56 -0800 (PST) X-Received: by 10.152.6.228 with SMTP id e4mr36845945laa.71.1415720936806; Tue, 11 Nov 2014 07:48:56 -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 ew9csp277252lbc; Tue, 11 Nov 2014 07:48:55 -0800 (PST) X-Received: by 10.70.119.2 with SMTP id kq2mr41456449pdb.54.1415720935144; Tue, 11 Nov 2014 07:48:55 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cf17si18763750pdb.137.2014.11.11.07.48.51 for ; Tue, 11 Nov 2014 07:48:55 -0800 (PST) Received-SPF: none (google.com: linux-kernel-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 S1751537AbaKKPs1 (ORCPT + 25 others); Tue, 11 Nov 2014 10:48:27 -0500 Received: from foss-mx-na.foss.arm.com ([217.140.108.86]:56164 "EHLO foss-mx-na.foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751460AbaKKPs0 (ORCPT ); Tue, 11 Nov 2014 10:48:26 -0500 Received: from foss-smtp-na-1.foss.arm.com (unknown [10.80.61.8]) by foss-mx-na.foss.arm.com (Postfix) with ESMTP id E4B434E4; Tue, 11 Nov 2014 09:48:21 -0600 (CST) Received: from collaborate-mta1.arm.com (highbank-bc01-b06.austin.arm.com [10.112.81.134]) by foss-smtp-na-1.foss.arm.com (Postfix) with ESMTP id B342A5FAD8; Tue, 11 Nov 2014 09:48:19 -0600 (CST) Received: from e102391-lin.cambridge.arm.com (e102391-lin.cambridge.arm.com [10.1.209.143]) by collaborate-mta1.arm.com (Postfix) with ESMTP id 67CC413F78C; Tue, 11 Nov 2014 09:48:18 -0600 (CST) From: Marc Zyngier To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jiang Liu , Thomas Gleixner Cc: Bjorn Helgaas , Yingjoe Chen , Will Deacon , Catalin marinas , Mark Rutland Subject: [PATCH 03/15] arm64: MSI: Add support for stacked MSI domain Date: Tue, 11 Nov 2014 15:48:01 +0000 Message-Id: <1415720893-13371-4-git-send-email-marc.zyngier@arm.com> X-Mailer: git-send-email 2.0.4 In-Reply-To: <1415720893-13371-1-git-send-email-marc.zyngier@arm.com> References: <1415720893-13371-1-git-send-email-marc.zyngier@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: marc.zyngier@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.47 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: , In the spirit of the new x86 support for stacked domains and MSI, add the minimum backend to support this feature on arm64. Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/msi.h | 26 ++++++++++++++ arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/msi.c | 80 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+) create mode 100644 arch/arm64/include/asm/msi.h create mode 100644 arch/arm64/kernel/msi.c diff --git a/arch/arm64/include/asm/msi.h b/arch/arm64/include/asm/msi.h new file mode 100644 index 0000000..d07dab7 --- /dev/null +++ b/arch/arm64/include/asm/msi.h @@ -0,0 +1,26 @@ +/* + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __ARM64_MSI_H__ +#define __ARM64_MSI_H__ + +struct arm64_msi_info { + struct pci_dev *pdev; + irq_hw_number_t msi_hwirq; + int nvec; +}; + +void arm64_init_msi_domain(struct irq_domain *parent, irq_flow_handler_t handle); + +#endif /* __ARM64_MSI_H__ */ diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 5bd029b..33283b8 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -31,6 +31,7 @@ arm64-obj-$(CONFIG_JUMP_LABEL) += jump_label.o 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_PCI_MSI_IRQ_DOMAIN) += msi.o obj-y += $(arm64-obj-y) vdso/ obj-m += $(arm64-obj-m) diff --git a/arch/arm64/kernel/msi.c b/arch/arm64/kernel/msi.c new file mode 100644 index 0000000..82f6162 --- /dev/null +++ b/arch/arm64/kernel/msi.c @@ -0,0 +1,80 @@ +/* + * 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. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +#include + +static struct irq_domain *msi_default_domain; +static irq_flow_handler_t msi_flow_handler; + +irq_hw_number_t arch_msi_irq_domain_get_hwirq(void *arg) +{ + struct arm64_msi_info *info = arg; + + return info->msi_hwirq; +} + +void arch_msi_irq_domain_set_hwirq(void *arg, irq_hw_number_t msi_hwirq) +{ + struct arm64_msi_info *info = arg; + + info->msi_hwirq = msi_hwirq; +} + +void arch_msi_irq_set_handler(unsigned int virq) +{ + __irq_set_handler(virq, msi_flow_handler, 0, NULL); +} + +static void arm64_mask_msi_irq(struct irq_data *d) +{ + mask_msi_irq(d); + irq_chip_mask_parent(d); +} + +static void arm64_unmask_msi_irq(struct irq_data *d) +{ + unmask_msi_irq(d); + irq_chip_unmask_parent(d); +} + +static struct irq_chip msi_irq_chip = { + .name = "PCI-MSI", + .irq_unmask = arm64_unmask_msi_irq, + .irq_mask = arm64_mask_msi_irq, + .irq_eoi = irq_chip_eoi_parent, + .irq_set_affinity = irq_chip_set_affinity_parent, +}; + +int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) +{ + struct arm64_msi_info info; + + info.pdev = pdev; + info.nvec = nvec; + + return msi_irq_domain_alloc_irqs(msi_default_domain, type, pdev, &info); +} + +void arm64_init_msi_domain(struct irq_domain *parent, irq_flow_handler_t handle) +{ + WARN_ON(msi_default_domain); + WARN_ON(msi_flow_handler); + msi_flow_handler = handle; + msi_default_domain = msi_create_irq_domain(NULL, &msi_irq_chip, parent); + if (!msi_default_domain) + pr_warn("failed to initialize irqdomain for MSI/MSI-x.\n"); +}