From patchwork Sat Jul 26 03:08:39 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyijing X-Patchwork-Id: 34334 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f200.google.com (mail-pd0-f200.google.com [209.85.192.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5D8C3235AB for ; Sat, 26 Jul 2014 02:46:03 +0000 (UTC) Received: by mail-pd0-f200.google.com with SMTP id w10sf32398681pde.11 for ; Fri, 25 Jul 2014 19:46:02 -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:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=W9tFB1hyVOXOnB48k+hYPE9aTFUFXAd5M6SI+8mFXjA=; b=HS0U7uYjrHv7CCqiBQGM4zr0KbJu20zhdMl/bVXG+MNbaYDrYB5p0OaXjIcqfa+YA/ JnLGkF5b8AUx2hiLWmiklOeUmHH9V2t5M1cxScdz7waN4U8gJKl/p/tLXiw8AJTr+zF7 PqqwjHJvhp4nBxOD/7MPlgZALnDigLf2e7Z+uqRhY9uBO2xh+4hjKxRDk6jvbj4EpJ71 ieV6jS3K5PBMSOKONTjqc2OZn/XL1Nx02IvprIlRYsC0W8Z+hfDG6gR3gust7v0uetkT nMz26M22haM8KAKH98gIJuq1FD4x/Nmxx1kNKjilii1+N/eUv7d2hamN//lIKpiGgl2g lHoA== X-Gm-Message-State: ALoCoQk+DulglWHiigXivovspMnk5/ld1ichLL6ytZ2GM6xXX1bxChiSo0cmh6dw9RiPYsCatvzk X-Received: by 10.68.195.9 with SMTP id ia9mr9838114pbc.7.1406342762698; Fri, 25 Jul 2014 19:46:02 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.117 with SMTP id b108ls1408556qga.19.gmail; Fri, 25 Jul 2014 19:46:02 -0700 (PDT) X-Received: by 10.224.11.130 with SMTP id t2mr33501616qat.101.1406342762569; Fri, 25 Jul 2014 19:46:02 -0700 (PDT) Received: from mail-qg0-f43.google.com (mail-qg0-f43.google.com [209.85.192.43]) by mx.google.com with ESMTPS id u77si19282884qgu.44.2014.07.25.19.46.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Jul 2014 19:46:02 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.192.43 as permitted sender) client-ip=209.85.192.43; Received: by mail-qg0-f43.google.com with SMTP id a108so6059733qge.30 for ; Fri, 25 Jul 2014 19:46:02 -0700 (PDT) X-Received: by 10.224.2.70 with SMTP id 6mr34171947qai.18.1406342762471; Fri, 25 Jul 2014 19:46:02 -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.96.16.166 with SMTP id h6csp70414qdd; Fri, 25 Jul 2014 19:46:01 -0700 (PDT) X-Received: by 10.70.92.81 with SMTP id ck17mr22821880pdb.2.1406342761578; Fri, 25 Jul 2014 19:46:01 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bb15si5474045pdb.461.2014.07.25.19.46.00 for ; Fri, 25 Jul 2014 19:46:01 -0700 (PDT) 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 S1760929AbaGZCoL (ORCPT + 15 others); Fri, 25 Jul 2014 22:44:11 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:6659 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752524AbaGZCnu (ORCPT ); Fri, 25 Jul 2014 22:43:50 -0400 Received: from 172.24.2.119 (EHLO szxeml419-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BXE25888; Sat, 26 Jul 2014 10:43:42 +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; Sat, 26 Jul 2014 10:43:29 +0800 From: Yijing Wang To: CC: Xinwei Hu , Wuyun , "Bjorn Helgaas" , , , "James E.J. Bottomley" , "Marc Zyngier" , , Russell King , , , , Hanjun Guo , Yijing Wang Subject: [RFC PATCH 02/11] PCI/MSI: Use new MSI type macro instead of PCI MSI flags Date: Sat, 26 Jul 2014 11:08:39 +0800 Message-ID: <1406344128-27055-3-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1406344128-27055-1-git-send-email-wangyijing@huawei.com> References: <1406344128-27055-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected 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: 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.192.43 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: , Add new MSI type marco(MSI_TYPE and MSIX_TYPE) to support the future generic MSI driver. The coming generic MSI driver will be used by PCI and Non-PCI devices that have MSI capability. Signed-off-by: Yijing Wang --- arch/mips/pci/msi-octeon.c | 4 ++-- arch/powerpc/kernel/msi.c | 2 +- arch/powerpc/platforms/pseries/msi.c | 8 ++++---- arch/s390/pci/pci.c | 2 +- arch/x86/kernel/apic/io_apic.c | 2 +- arch/x86/pci/xen.c | 24 ++++++++++++------------ drivers/iommu/irq_remapping.c | 2 +- drivers/irqchip/irq-armada-370-xp.c | 2 +- drivers/pci/msi.c | 10 +++++----- include/linux/msi.h | 3 +++ 10 files changed, 31 insertions(+), 28 deletions(-) diff --git a/arch/mips/pci/msi-octeon.c b/arch/mips/pci/msi-octeon.c index 6a6a99f..8105610 100644 --- a/arch/mips/pci/msi-octeon.c +++ b/arch/mips/pci/msi-octeon.c @@ -192,14 +192,14 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) /* * MSI-X is not supported. */ - if (type == PCI_CAP_ID_MSIX) + if (type == MSIX_TYPE) return -EINVAL; /* * If an architecture wants to support multiple MSI, it needs to * override arch_setup_msi_irqs() */ - if (type == PCI_CAP_ID_MSI && nvec > 1) + if (type == MSI_TYPE && nvec > 1) return 1; list_for_each_entry(entry, &dev->msi_list, list) { diff --git a/arch/powerpc/kernel/msi.c b/arch/powerpc/kernel/msi.c index 8bbc12d..05b3133 100644 --- a/arch/powerpc/kernel/msi.c +++ b/arch/powerpc/kernel/msi.c @@ -21,7 +21,7 @@ int arch_msi_check_device(struct pci_dev* dev, int nvec, int type) } /* PowerPC doesn't support multiple MSI yet */ - if (type == PCI_CAP_ID_MSI && nvec > 1) + if (type == MSI_TYPE && nvec > 1) return 1; if (ppc_md.msi_check_device) { diff --git a/arch/powerpc/platforms/pseries/msi.c b/arch/powerpc/platforms/pseries/msi.c index 0c882e8..e2f27d6 100644 --- a/arch/powerpc/platforms/pseries/msi.c +++ b/arch/powerpc/platforms/pseries/msi.c @@ -339,7 +339,7 @@ static int rtas_msi_check_device(struct pci_dev *pdev, int nvec, int type) { int quota, rc; - if (type == PCI_CAP_ID_MSIX) + if (type == MSIX_TYPE) rc = check_req_msix(pdev, nvec); else rc = check_req_msi(pdev, nvec); @@ -406,14 +406,14 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type) if (!pdn) return -ENODEV; - if (type == PCI_CAP_ID_MSIX && check_msix_entries(pdev)) + if (type == MSIX_TYPE && check_msix_entries(pdev)) return -EINVAL; /* * Firmware currently refuse any non power of two allocation * so we round up if the quota will allow it. */ - if (type == PCI_CAP_ID_MSIX) { + if (type == MSIX_TYPE) { int m = roundup_pow_of_two(nvec); int quota = msi_quota_for_device(pdev, m); @@ -427,7 +427,7 @@ static int rtas_setup_msi_irqs(struct pci_dev *pdev, int nvec_in, int type) * return MSI-Xs. */ again: - if (type == PCI_CAP_ID_MSI) { + if (type == MSI_TYPE) { if (pdn->force_32bit_msi) { rc = rtas_change_msi(pdn, RTAS_CHANGE_32MSI_FN, nvec); if (rc < 0) { diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 9ddc51e..fe3a40c 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -407,7 +407,7 @@ int arch_setup_msi_irqs(struct pci_dev *pdev, int nvec, int type) struct msi_msg msg; int rc, irq; - if (type == PCI_CAP_ID_MSI && nvec > 1) + if (type == MSI_TYPE && nvec > 1) return 1; msi_vecs = min(nvec, ZPCI_MSI_VEC_MAX); msi_vecs = min_t(unsigned int, msi_vecs, CONFIG_PCI_NR_MSI); diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 81e08ef..b833042 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -3069,7 +3069,7 @@ int native_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) int node, ret; /* Multiple MSI vectors only supported with interrupt remapping */ - if (type == PCI_CAP_ID_MSI && nvec > 1) + if (type == MSI_TYPE && nvec > 1) return 1; node = dev_to_node(&dev->dev); diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c index 905956f..c19a8de 100644 --- a/arch/x86/pci/xen.c +++ b/arch/x86/pci/xen.c @@ -162,14 +162,14 @@ static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) struct msi_desc *msidesc; int *v; - if (type == PCI_CAP_ID_MSI && nvec > 1) + if (type == MSI_TYPE && nvec > 1) return 1; v = kzalloc(sizeof(int) * max(1, nvec), GFP_KERNEL); if (!v) return -ENOMEM; - if (type == PCI_CAP_ID_MSIX) + if (type == MSIX_TYPE) ret = xen_pci_frontend_enable_msix(dev, v, nvec); else ret = xen_pci_frontend_enable_msi(dev, v); @@ -178,8 +178,8 @@ static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) i = 0; list_for_each_entry(msidesc, &dev->msi_list, list) { irq = xen_bind_pirq_msi_to_irq(dev, msidesc, v[i], - (type == PCI_CAP_ID_MSI) ? nvec : 1, - (type == PCI_CAP_ID_MSIX) ? + (type == MSI_TYPE) ? nvec : 1, + (type == MSIX_TYPE) ? "pcifront-msi-x" : "pcifront-msi", DOMID_SELF); @@ -224,7 +224,7 @@ static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) struct msi_desc *msidesc; struct msi_msg msg; - if (type == PCI_CAP_ID_MSI && nvec > 1) + if (type == MSI_TYPE && nvec > 1) return 1; list_for_each_entry(msidesc, &dev->msi_list, list) { @@ -246,8 +246,8 @@ static int xen_hvm_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) "xen: msi already bound to pirq=%d\n", pirq); } irq = xen_bind_pirq_msi_to_irq(dev, msidesc, pirq, - (type == PCI_CAP_ID_MSI) ? nvec : 1, - (type == PCI_CAP_ID_MSIX) ? + (type == MSI_TYPE) ? nvec : 1, + (type == MSIX_TYPE) ? "msi-x" : "msi", DOMID_SELF); if (irq < 0) @@ -290,10 +290,10 @@ static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) (pci_domain_nr(dev->bus) << 16); map_irq.devfn = dev->devfn; - if (type == PCI_CAP_ID_MSI && nvec > 1) { + if (type == MSI_TYPE && nvec > 1) { map_irq.type = MAP_PIRQ_TYPE_MULTI_MSI; map_irq.entry_nr = nvec; - } else if (type == PCI_CAP_ID_MSIX) { + } else if (type == MSIX_TYPE) { int pos; u32 table_offset, bir; @@ -310,7 +310,7 @@ static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) if (pci_seg_supported) ret = HYPERVISOR_physdev_op(PHYSDEVOP_map_pirq, &map_irq); - if (type == PCI_CAP_ID_MSI && nvec > 1 && ret) { + if (type == MSI_TYPE && nvec > 1 && ret) { /* * If MAP_PIRQ_TYPE_MULTI_MSI is not available * there's nothing else we can do in this case. @@ -337,8 +337,8 @@ static int xen_initdom_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) } ret = xen_bind_pirq_msi_to_irq(dev, msidesc, map_irq.pirq, - (type == PCI_CAP_ID_MSI) ? nvec : 1, - (type == PCI_CAP_ID_MSIX) ? "msi-x" : "msi", + (type == MSI_TYPE) ? nvec : 1, + (type == MSIX_TYPE) ? "msi-x" : "msi", domid); if (ret < 0) goto out; diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c index 33c4395..a3b1805 100644 --- a/drivers/iommu/irq_remapping.c +++ b/drivers/iommu/irq_remapping.c @@ -142,7 +142,7 @@ error: static int irq_remapping_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) { - if (type == PCI_CAP_ID_MSI) + if (type == MSI_TYPE) return do_setup_msi_irqs(dev, nvec); else return do_setup_msix_irqs(dev, nvec); diff --git a/drivers/irqchip/irq-armada-370-xp.c b/drivers/irqchip/irq-armada-370-xp.c index c887e6e..249823b 100644 --- a/drivers/irqchip/irq-armada-370-xp.c +++ b/drivers/irqchip/irq-armada-370-xp.c @@ -170,7 +170,7 @@ static int armada_370_xp_check_msi_device(struct msi_chip *chip, struct pci_dev int nvec, int type) { /* We support MSI, but not MSI-X */ - if (type == PCI_CAP_ID_MSI) + if (type == MSI_TYPE) return 0; return -EINVAL; } diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index e67acd1..e416dc0 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -75,7 +75,7 @@ int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) * If an architecture wants to support multiple MSI, it needs to * override arch_setup_msi_irqs() */ - if (type == PCI_CAP_ID_MSI && nvec > 1) + if (type == MSI_TYPE && nvec > 1) return 1; list_for_each_entry(entry, &dev->msi_list, list) { @@ -639,7 +639,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec) list_add_tail(&entry->list, &dev->msi_list); /* Configure MSI capability structure */ - ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSI); + ret = arch_setup_msi_irqs(dev, nvec, MSI_TYPE); if (ret) { msi_mask_irq(entry, mask, ~mask); free_msi_irqs(dev); @@ -754,7 +754,7 @@ static int msix_capability_init(struct pci_dev *dev, if (ret) return ret; - ret = arch_setup_msi_irqs(dev, nvec, PCI_CAP_ID_MSIX); + ret = arch_setup_msi_irqs(dev, nvec, MSIX_TYPE); if (ret) goto out_avail; @@ -950,7 +950,7 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec) if (!entries || !dev->msix_cap || dev->current_state != PCI_D0) return -EINVAL; - status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSIX); + status = pci_msi_check_device(dev, nvec, MSIX_TYPE); if (status) return status; @@ -1084,7 +1084,7 @@ int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) nvec = maxvec; do { - rc = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI); + rc = pci_msi_check_device(dev, nvec, MSI_TYPE); if (rc < 0) { return rc; } else if (rc > 0) { diff --git a/include/linux/msi.h b/include/linux/msi.h index ce88c5b..3ad8416 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -67,6 +67,9 @@ void default_restore_msi_irqs(struct pci_dev *dev); u32 default_msi_mask_irq(struct msi_desc *desc, u32 mask, u32 flag); u32 default_msix_mask_irq(struct msi_desc *desc, u32 flag); +#define MSI_TYPE 0x01 +#define MSIX_TYPE 0x02 + struct msi_chip { struct module *owner; struct device *dev;