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: wangyijing X-Patchwork-Id: 36798 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f198.google.com (mail-ie0-f198.google.com [209.85.223.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CCA9B202E4 for ; Fri, 5 Sep 2014 09:54:26 +0000 (UTC) Received: by mail-ie0-f198.google.com with SMTP id rd18sf204029iec.1 for ; Fri, 05 Sep 2014 02:54:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:cc:subject:precedence:list-id :list-unsubscribe:list-post:list-help:list-subscribe:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:list-archive:content-type:content-transfer-encoding; bh=K7nJjrcGBuJGkKjDTX9EbuomCBrXGlnZUvlQVOZQ+9s=; b=jrEDurIGx5u7dPM515WDtuKx3uCZHbfVu6oHeExv3ZejN0nQ/aHLUJatuFXqtTTA9Q 5CdIXefSJqHDG8timml+W4UwLdcT5qApVOsLgL3G7eFx6MXmxAEcHVSXAPo79BUWqXBn FaV4B/eZUVcsVP7LWVBYFDfEkbLvyzc6dQlZaMKLrFwwVo60U5E5/mRGelKQBdN0XdRU 2Dg16VqjbL4PufFOy5IK8XLlrF1TBl9fYNdB6H0NBNB6SnX/uzcvgv5+6LZFppGnDKkf f4BIl1d7iywdiehsraDT+UNVbyWoxGoV2p/M3o0mT3rfBm7VWeAJvT+x6VOeAigkqAST 63Ug== X-Gm-Message-State: ALoCoQlbr7uISMVbu38KN3CaJnC1hybbE898cALpWZUK6vZEsb+YFcmIAVU1jCzkoZZoHnY/ci5a X-Received: by 10.183.10.133 with SMTP id ea5mr6565289obd.24.1409910866392; Fri, 05 Sep 2014 02:54:26 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.101.210 with SMTP id u76ls685699qge.62.gmail; Fri, 05 Sep 2014 02:54:26 -0700 (PDT) X-Received: by 10.220.182.73 with SMTP id cb9mr9377616vcb.9.1409910866314; Fri, 05 Sep 2014 02:54:26 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id sz12si852611vdb.57.2014.09.05.02.54.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 05 Sep 2014 02:54:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so12077183vcb.37 for ; Fri, 05 Sep 2014 02:54:26 -0700 (PDT) X-Received: by 10.52.129.165 with SMTP id nx5mr6917108vdb.25.1409910866233; Fri, 05 Sep 2014 02:54:26 -0700 (PDT) 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.221.45.67 with SMTP id uj3csp57197vcb; Fri, 5 Sep 2014 02:54:25 -0700 (PDT) X-Received: by 10.140.108.200 with SMTP id j66mr16247229qgf.43.1409910865817; Fri, 05 Sep 2014 02:54:25 -0700 (PDT) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id 89si809409qgt.124.2014.09.05.02.54.25 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 05 Sep 2014 02:54:25 -0700 (PDT) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XPqCq-000747-5W; Fri, 05 Sep 2014 09:53:24 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XPqCo-00073N-Ph for xen-devel@lists.xenproject.org; Fri, 05 Sep 2014 09:53:22 +0000 Received: from [85.158.143.35:50347] by server-2.bemta-4.messagelabs.com id 03/7D-04525-21889045; Fri, 05 Sep 2014 09:53:22 +0000 X-Env-Sender: wangyijing@huawei.com X-Msg-Ref: server-6.tower-21.messagelabs.com!1409910798!11804013!1 X-Originating-IP: [119.145.14.64] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NCA9PiA4MDE5MQ==\n X-StarScan-Received: X-StarScan-Version: 6.11.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23963 invoked from network); 5 Sep 2014 09:53:21 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (119.145.14.64) by server-6.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 5 Sep 2014 09:53:21 -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 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 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 , 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" Subject: [Xen-devel] [PATCH v1 06/21] PCI/MSI: Refactor struct msi_chip to make it become more common X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: wangyijing@huawei.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.220.178 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-Archive: 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 */