diff options
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_iba6110.c')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_iba6110.c | 117 |
1 files changed, 49 insertions, 68 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_iba6110.c b/drivers/infiniband/hw/ipath/ipath_iba6110.c index 9e4e8d4c6e20..e57c7a351cb5 100644 --- a/drivers/infiniband/hw/ipath/ipath_iba6110.c +++ b/drivers/infiniband/hw/ipath/ipath_iba6110.c | |||
@@ -38,6 +38,7 @@ | |||
38 | 38 | ||
39 | #include <linux/pci.h> | 39 | #include <linux/pci.h> |
40 | #include <linux/delay.h> | 40 | #include <linux/delay.h> |
41 | #include <linux/htirq.h> | ||
41 | 42 | ||
42 | #include "ipath_kernel.h" | 43 | #include "ipath_kernel.h" |
43 | #include "ipath_registers.h" | 44 | #include "ipath_registers.h" |
@@ -913,49 +914,40 @@ static void slave_or_pri_blk(struct ipath_devdata *dd, struct pci_dev *pdev, | |||
913 | } | 914 | } |
914 | } | 915 | } |
915 | 916 | ||
916 | static int set_int_handler(struct ipath_devdata *dd, struct pci_dev *pdev, | 917 | static int ipath_ht_intconfig(struct ipath_devdata *dd) |
917 | int pos) | ||
918 | { | 918 | { |
919 | u32 int_handler_addr_lower; | 919 | int ret; |
920 | u32 int_handler_addr_upper; | ||
921 | u64 ihandler; | ||
922 | u32 intvec; | ||
923 | 920 | ||
924 | /* use indirection register to get the intr handler */ | 921 | if (dd->ipath_intconfig) { |
925 | pci_write_config_byte(pdev, pos + HT_INTR_REG_INDEX, 0x10); | 922 | ipath_write_kreg(dd, dd->ipath_kregs->kr_interruptconfig, |
926 | pci_read_config_dword(pdev, pos + 4, &int_handler_addr_lower); | 923 | dd->ipath_intconfig); /* interrupt address */ |
927 | pci_write_config_byte(pdev, pos + HT_INTR_REG_INDEX, 0x11); | 924 | ret = 0; |
928 | pci_read_config_dword(pdev, pos + 4, &int_handler_addr_upper); | 925 | } else { |
926 | ipath_dev_err(dd, "No interrupts enabled, couldn't setup " | ||
927 | "interrupt address\n"); | ||
928 | ret = -EINVAL; | ||
929 | } | ||
929 | 930 | ||
930 | ihandler = (u64) int_handler_addr_lower | | 931 | return ret; |
931 | ((u64) int_handler_addr_upper << 32); | 932 | } |
933 | |||
934 | static void ipath_ht_irq_update(struct pci_dev *dev, int irq, | ||
935 | struct ht_irq_msg *msg) | ||
936 | { | ||
937 | struct ipath_devdata *dd = pci_get_drvdata(dev); | ||
938 | u64 prev_intconfig = dd->ipath_intconfig; | ||
939 | |||
940 | dd->ipath_intconfig = msg->address_lo; | ||
941 | dd->ipath_intconfig |= ((u64) msg->address_hi) << 32; | ||
932 | 942 | ||
933 | /* | 943 | /* |
934 | * kernels with CONFIG_PCI_MSI set the vector in the irq field of | 944 | * If the previous value of dd->ipath_intconfig is zero, we're |
935 | * struct pci_device, so we use that to program the internal | 945 | * getting configured for the first time, and must not program the |
936 | * interrupt register (not config space) with that value. The BIOS | 946 | * intconfig register here (it will be programmed later, when the |
937 | * must still have done the basic MSI setup. | 947 | * hardware is ready). Otherwise, we should. |
938 | */ | ||
939 | intvec = pdev->irq; | ||
940 | /* | ||
941 | * clear any vector bits there; normally not set but we'll overload | ||
942 | * this for some debug purposes (setting the HTC debug register | ||
943 | * value from software, rather than GPIOs), so it might be set on a | ||
944 | * driver reload. | ||
945 | */ | 948 | */ |
946 | ihandler &= ~0xff0000; | 949 | if (prev_intconfig) |
947 | /* x86 vector goes in intrinfo[23:16] */ | 950 | ipath_ht_intconfig(dd); |
948 | ihandler |= intvec << 16; | ||
949 | ipath_cdbg(VERBOSE, "ihandler lower %x, upper %x, intvec %x, " | ||
950 | "interruptconfig %llx\n", int_handler_addr_lower, | ||
951 | int_handler_addr_upper, intvec, | ||
952 | (unsigned long long) ihandler); | ||
953 | |||
954 | /* can't program yet, so save for interrupt setup */ | ||
955 | dd->ipath_intconfig = ihandler; | ||
956 | /* keep going, so we find link control stuff also */ | ||
957 | |||
958 | return ihandler != 0; | ||
959 | } | 951 | } |
960 | 952 | ||
961 | /** | 953 | /** |
@@ -971,12 +963,19 @@ static int set_int_handler(struct ipath_devdata *dd, struct pci_dev *pdev, | |||
971 | static int ipath_setup_ht_config(struct ipath_devdata *dd, | 963 | static int ipath_setup_ht_config(struct ipath_devdata *dd, |
972 | struct pci_dev *pdev) | 964 | struct pci_dev *pdev) |
973 | { | 965 | { |
974 | int pos, ret = 0; | 966 | int pos, ret; |
975 | int ihandler = 0; | 967 | |
968 | ret = __ht_create_irq(pdev, 0, ipath_ht_irq_update); | ||
969 | if (ret < 0) { | ||
970 | ipath_dev_err(dd, "Couldn't create interrupt handler: " | ||
971 | "err %d\n", ret); | ||
972 | goto bail; | ||
973 | } | ||
974 | dd->ipath_irq = ret; | ||
975 | ret = 0; | ||
976 | 976 | ||
977 | /* | 977 | /* |
978 | * Read the capability info to find the interrupt info, and also | 978 | * Handle clearing CRC errors in linkctrl register if necessary. We |
979 | * handle clearing CRC errors in linkctrl register if necessary. We | ||
980 | * do this early, before we ever enable errors or hardware errors, | 979 | * do this early, before we ever enable errors or hardware errors, |
981 | * mostly to avoid causing the chip to enter freeze mode. | 980 | * mostly to avoid causing the chip to enter freeze mode. |
982 | */ | 981 | */ |
@@ -1000,17 +999,9 @@ static int ipath_setup_ht_config(struct ipath_devdata *dd, | |||
1000 | } | 999 | } |
1001 | if (!(cap_type & 0xE0)) | 1000 | if (!(cap_type & 0xE0)) |
1002 | slave_or_pri_blk(dd, pdev, pos, cap_type); | 1001 | slave_or_pri_blk(dd, pdev, pos, cap_type); |
1003 | else if (cap_type == HT_INTR_DISC_CONFIG) | ||
1004 | ihandler = set_int_handler(dd, pdev, pos); | ||
1005 | } while ((pos = pci_find_next_capability(pdev, pos, | 1002 | } while ((pos = pci_find_next_capability(pdev, pos, |
1006 | PCI_CAP_ID_HT))); | 1003 | PCI_CAP_ID_HT))); |
1007 | 1004 | ||
1008 | if (!ihandler) { | ||
1009 | ipath_dev_err(dd, "Couldn't find interrupt handler in " | ||
1010 | "config space\n"); | ||
1011 | ret = -ENODEV; | ||
1012 | } | ||
1013 | |||
1014 | bail: | 1005 | bail: |
1015 | return ret; | 1006 | return ret; |
1016 | } | 1007 | } |
@@ -1360,25 +1351,6 @@ static void ipath_ht_quiet_serdes(struct ipath_devdata *dd) | |||
1360 | ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val); | 1351 | ipath_write_kreg(dd, dd->ipath_kregs->kr_serdesconfig0, val); |
1361 | } | 1352 | } |
1362 | 1353 | ||
1363 | static int ipath_ht_intconfig(struct ipath_devdata *dd) | ||
1364 | { | ||
1365 | int ret; | ||
1366 | |||
1367 | if (!dd->ipath_intconfig) { | ||
1368 | ipath_dev_err(dd, "No interrupts enabled, couldn't setup " | ||
1369 | "interrupt address\n"); | ||
1370 | ret = 1; | ||
1371 | goto bail; | ||
1372 | } | ||
1373 | |||
1374 | ipath_write_kreg(dd, dd->ipath_kregs->kr_interruptconfig, | ||
1375 | dd->ipath_intconfig); /* interrupt address */ | ||
1376 | ret = 0; | ||
1377 | |||
1378 | bail: | ||
1379 | return ret; | ||
1380 | } | ||
1381 | |||
1382 | /** | 1354 | /** |
1383 | * ipath_pe_put_tid - write a TID in chip | 1355 | * ipath_pe_put_tid - write a TID in chip |
1384 | * @dd: the infinipath device | 1356 | * @dd: the infinipath device |
@@ -1575,6 +1547,14 @@ static int ipath_ht_get_base_info(struct ipath_portdata *pd, void *kbase) | |||
1575 | return 0; | 1547 | return 0; |
1576 | } | 1548 | } |
1577 | 1549 | ||
1550 | static void ipath_ht_free_irq(struct ipath_devdata *dd) | ||
1551 | { | ||
1552 | free_irq(dd->ipath_irq, dd); | ||
1553 | ht_destroy_irq(dd->ipath_irq); | ||
1554 | dd->ipath_irq = 0; | ||
1555 | dd->ipath_intconfig = 0; | ||
1556 | } | ||
1557 | |||
1578 | /** | 1558 | /** |
1579 | * ipath_init_iba6110_funcs - set up the chip-specific function pointers | 1559 | * ipath_init_iba6110_funcs - set up the chip-specific function pointers |
1580 | * @dd: the infinipath device | 1560 | * @dd: the infinipath device |
@@ -1598,6 +1578,7 @@ void ipath_init_iba6110_funcs(struct ipath_devdata *dd) | |||
1598 | dd->ipath_f_cleanup = ipath_setup_ht_cleanup; | 1578 | dd->ipath_f_cleanup = ipath_setup_ht_cleanup; |
1599 | dd->ipath_f_setextled = ipath_setup_ht_setextled; | 1579 | dd->ipath_f_setextled = ipath_setup_ht_setextled; |
1600 | dd->ipath_f_get_base_info = ipath_ht_get_base_info; | 1580 | dd->ipath_f_get_base_info = ipath_ht_get_base_info; |
1581 | dd->ipath_f_free_irq = ipath_ht_free_irq; | ||
1601 | 1582 | ||
1602 | /* | 1583 | /* |
1603 | * initialize chip-specific variables | 1584 | * initialize chip-specific variables |