From patchwork Fri Sep 5 10:09:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 4851161 Return-Path: X-Original-To: patchwork-linux-arm@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 D03719F3AE for ; Fri, 5 Sep 2014 09:56:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4C3A7202BE for ; Fri, 5 Sep 2014 09:56:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6C70020266 for ; Fri, 5 Sep 2014 09:56:39 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XPqDE-0007iX-6k; Fri, 05 Sep 2014 09:53:48 +0000 Received: from szxga01-in.huawei.com ([119.145.14.64]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XPqCe-0006MR-B1 for linux-arm-kernel@lists.infradead.org; Fri, 05 Sep 2014 09:53:13 +0000 Received: from 172.24.2.119 (EHLO szxeml419-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CBG93431; Fri, 05 Sep 2014 17:45:49 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml419-hub.china.huawei.com (10.82.67.158) with Microsoft SMTP Server id 14.3.158.1; Fri, 5 Sep 2014 17:45:35 +0800 From: Yijing Wang To: Bjorn Helgaas Subject: [PATCH v1 06/21] PCI/MSI: Refactor struct msi_chip to make it become more common Date: Fri, 5 Sep 2014 18:09:51 +0800 Message-ID: <1409911806-10519-7-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1409911806-10519-1-git-send-email-wangyijing@huawei.com> References: <1409911806-10519-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140905_025312_761942_EEDF9864 X-CRM114-Status: GOOD ( 11.31 ) X-Spam-Score: -2.4 (--) Cc: linux-mips@linux-mips.org, linux-ia64@vger.kernel.org, linux-pci@vger.kernel.org, Bharat.Bhushan@freescale.com, Yijing Wang , sparclinux@vger.kernel.org, linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Russell King , Joerg Roedel , x86@kernel.org, Sebastian Ott , Benjamin Herrenschmidt , xen-devel@lists.xenproject.org, arnab.basu@freescale.com, Arnd Bergmann , Konrad Rzeszutek Wilk , Chris Metcalf , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, Xinwei Hu , Tony Luck , Ralf Baechle , iommu@lists.linux-foundation.org, Wuyun , linuxppc-dev@lists.ozlabs.org, "David S. Miller" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-3.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 Now there are a lot of __weak arch functions in MSI code. These functions make MSI driver complex. Thierry Reding Introduced a new MSI chip framework to configure MSI/MSI-X irq in ARM. Use the new MSI chip framework to refactor all other platform MSI arch code to eliminate weak arch MSI functions. This patch add .restore_irq() and .setup_irqs() to make it become more common. Signed-off-by: Yijing Wang Reviewed-by: Lucas Stach --- drivers/pci/msi.c | 15 +++++++++++++++ include/linux/msi.h | 3 +++ 2 files changed, 18 insertions(+), 0 deletions(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 539c11d..d78d637 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -63,6 +63,11 @@ int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) { struct msi_desc *entry; int ret; + struct msi_chip *chip; + + chip = arch_find_msi_chip(dev); + if (chip && chip->setup_irqs) + return chip->setup_irqs(dev, nvec, type); /* * If an architecture wants to support multiple MSI, it needs to @@ -105,6 +110,11 @@ void default_teardown_msi_irqs(struct pci_dev *dev) void __weak arch_teardown_msi_irqs(struct pci_dev *dev) { + struct msi_chip *chip = arch_find_msi_chip(dev); + + if (chip && chip->teardown_irqs) + return chip->teardown_irqs(dev); + return default_teardown_msi_irqs(dev); } @@ -128,6 +138,11 @@ static void default_restore_msi_irq(struct pci_dev *dev, int irq) void __weak arch_restore_msi_irqs(struct pci_dev *dev) { + struct msi_chip *chip = arch_find_msi_chip(dev); + + if (chip && chip->restore_irqs) + return chip->restore_irqs(dev); + return default_restore_msi_irqs(dev); } diff --git a/include/linux/msi.h b/include/linux/msi.h index 5650848..92a51e7 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -72,7 +72,10 @@ struct msi_chip { struct list_head list; int (*setup_irq)(struct pci_dev *dev, struct msi_desc *desc); + int (*setup_irqs)(struct pci_dev *dev, int nvec, int type); void (*teardown_irq)(unsigned int irq); + void (*teardown_irqs)(struct pci_dev *dev); + void (*restore_irqs)(struct pci_dev *dev); }; #endif /* LINUX_MSI_H */