diff options
author | David S. Miller <davem@sunset.davemloft.net> | 2007-08-31 01:27:28 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-08-31 02:06:51 -0400 |
commit | 5f92c329364c0bf2d3a356da5e8759fbe349f9d1 (patch) | |
tree | 2bf27d77009229a26c371102655c5f81c7e68d1e /arch/sparc64/kernel/pci_sun4v.c | |
parent | 6e69d6068cc2aa545544189a1ee4d2e1a32ad591 (diff) |
[SPARC64]: Fix several bugs in MSI handling.
1) sun4{u,v}_build_msi() have improper return value handling.
We should always return negative error codes, instead of
using the magic value "0" which could in fact be a valid
MSI number.
2) sun4{u,v}_build_msi() should return -ENOMEM instead of
calling prom_prom() halt with kzalloc() of the interrupt
data fails.
3) We 'remembered' the MSI number using a singleton in the
struct device archdata area, this doesn't work for MSI-X
which can cause multiple MSIs assosciated with one device.
Delete that archdata member, and instead store the MSI
number in the IRQ chip data area.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/sparc64/kernel/pci_sun4v.c')
-rw-r--r-- | arch/sparc64/kernel/pci_sun4v.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/arch/sparc64/kernel/pci_sun4v.c b/arch/sparc64/kernel/pci_sun4v.c index 466f4aa8fc82..da724b13e89e 100644 --- a/arch/sparc64/kernel/pci_sun4v.c +++ b/arch/sparc64/kernel/pci_sun4v.c | |||
@@ -940,13 +940,13 @@ static int pci_sun4v_setup_msi_irq(unsigned int *virt_irq_p, | |||
940 | if (msi_num < 0) | 940 | if (msi_num < 0) |
941 | return msi_num; | 941 | return msi_num; |
942 | 942 | ||
943 | devino = sun4v_build_msi(pbm->devhandle, virt_irq_p, | 943 | err = sun4v_build_msi(pbm->devhandle, virt_irq_p, |
944 | pbm->msiq_first_devino, | 944 | pbm->msiq_first_devino, |
945 | (pbm->msiq_first_devino + | 945 | (pbm->msiq_first_devino + |
946 | pbm->msiq_num)); | 946 | pbm->msiq_num)); |
947 | err = -ENOMEM; | 947 | if (err < 0) |
948 | if (!devino) | ||
949 | goto out_err; | 948 | goto out_err; |
949 | devino = err; | ||
950 | 950 | ||
951 | msiqid = ((devino - pbm->msiq_first_devino) + | 951 | msiqid = ((devino - pbm->msiq_first_devino) + |
952 | pbm->msiq_first); | 952 | pbm->msiq_first); |
@@ -971,7 +971,7 @@ static int pci_sun4v_setup_msi_irq(unsigned int *virt_irq_p, | |||
971 | if (pci_sun4v_msi_setvalid(pbm->devhandle, msi_num, HV_MSIVALID_VALID)) | 971 | if (pci_sun4v_msi_setvalid(pbm->devhandle, msi_num, HV_MSIVALID_VALID)) |
972 | goto out_err; | 972 | goto out_err; |
973 | 973 | ||
974 | pdev->dev.archdata.msi_num = msi_num; | 974 | sparc64_set_msi(*virt_irq_p, msi_num); |
975 | 975 | ||
976 | if (entry->msi_attrib.is_64) { | 976 | if (entry->msi_attrib.is_64) { |
977 | msg.address_hi = pbm->msi64_start >> 32; | 977 | msg.address_hi = pbm->msi64_start >> 32; |
@@ -993,8 +993,6 @@ static int pci_sun4v_setup_msi_irq(unsigned int *virt_irq_p, | |||
993 | 993 | ||
994 | out_err: | 994 | out_err: |
995 | free_msi(pbm, msi_num); | 995 | free_msi(pbm, msi_num); |
996 | sun4v_destroy_msi(*virt_irq_p); | ||
997 | *virt_irq_p = 0; | ||
998 | return err; | 996 | return err; |
999 | 997 | ||
1000 | } | 998 | } |
@@ -1006,7 +1004,7 @@ static void pci_sun4v_teardown_msi_irq(unsigned int virt_irq, | |||
1006 | unsigned long msiqid, err; | 1004 | unsigned long msiqid, err; |
1007 | unsigned int msi_num; | 1005 | unsigned int msi_num; |
1008 | 1006 | ||
1009 | msi_num = pdev->dev.archdata.msi_num; | 1007 | msi_num = sparc64_get_msi(virt_irq); |
1010 | err = pci_sun4v_msi_getmsiq(pbm->devhandle, msi_num, &msiqid); | 1008 | err = pci_sun4v_msi_getmsiq(pbm->devhandle, msi_num, &msiqid); |
1011 | if (err) { | 1009 | if (err) { |
1012 | printk(KERN_ERR "%s: getmsiq gives error %lu\n", | 1010 | printk(KERN_ERR "%s: getmsiq gives error %lu\n", |