[RFC PATCH 02/11] PCI/MSI: Use new MSI type macro instead of PCI MSI flags

2014-07-25 Thread Yijing Wang
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, >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);
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);
 

[RFC PATCH 02/11] PCI/MSI: Use new MSI type macro instead of PCI MSI flags

2014-07-25 Thread Yijing Wang
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 wangyij...@huawei.com
---
 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