diff options
author | Dave Olson <dave.olson@qlogic.com> | 2008-05-07 14:00:15 -0400 |
---|---|---|
committer | Roland Dreier <rolandd@cisco.com> | 2008-05-07 14:00:15 -0400 |
commit | e2ab41cae418108f376ad1634d7507f56379f7a2 (patch) | |
tree | c14355ab189f36f02b56f1dd293d49f1fc056730 /drivers/infiniband/hw/ipath/ipath_init_chip.c | |
parent | 2889d1ef1240591fa4c72a6753e0a8d1c6e18140 (diff) |
IB/ipath: Need to always request and handle PIO avail interrupts
Now that we always use PIO for vl15 on 7220, we could get stuck forever
if we happened to run out of PIO buffers from the verbs code, because
the setup code wouldn't run; the interrupt was also ignored if SDMA was
supported. We also have to reduce the pio update threshold if we have
fewer kernel buffers than the existing threshold.
Clean up the initialization a bit to get ordering safer and more
sensible, and use the existing ipath_chg_kernavail call to do init,
rather than doing it separately.
Drop unnecessary clearing of pio buffer on pio parity error.
Drop incorrect updating of pioavailshadow when exitting freeze mode
(software state may not match chip state if buffer has been allocated
and not yet written).
If we couldn't get a kernel buffer for a while, make sure we are
in sync with hardware, mainly to handle the exitting freeze case.
Signed-off-by: Dave Olson <dave.olson@qlogic.com>
Signed-off-by: Roland Dreier <rolandd@cisco.com>
Diffstat (limited to 'drivers/infiniband/hw/ipath/ipath_init_chip.c')
-rw-r--r-- | drivers/infiniband/hw/ipath/ipath_init_chip.c | 95 |
1 files changed, 42 insertions, 53 deletions
diff --git a/drivers/infiniband/hw/ipath/ipath_init_chip.c b/drivers/infiniband/hw/ipath/ipath_init_chip.c index 27dd89476660..3e5baa43fc82 100644 --- a/drivers/infiniband/hw/ipath/ipath_init_chip.c +++ b/drivers/infiniband/hw/ipath/ipath_init_chip.c | |||
@@ -41,7 +41,7 @@ | |||
41 | /* | 41 | /* |
42 | * min buffers we want to have per port, after driver | 42 | * min buffers we want to have per port, after driver |
43 | */ | 43 | */ |
44 | #define IPATH_MIN_USER_PORT_BUFCNT 8 | 44 | #define IPATH_MIN_USER_PORT_BUFCNT 7 |
45 | 45 | ||
46 | /* | 46 | /* |
47 | * Number of ports we are configured to use (to allow for more pio | 47 | * Number of ports we are configured to use (to allow for more pio |
@@ -54,13 +54,9 @@ MODULE_PARM_DESC(cfgports, "Set max number of ports to use"); | |||
54 | 54 | ||
55 | /* | 55 | /* |
56 | * Number of buffers reserved for driver (verbs and layered drivers.) | 56 | * Number of buffers reserved for driver (verbs and layered drivers.) |
57 | * Reserved at end of buffer list. Initialized based on | 57 | * Initialized based on number of PIO buffers if not set via module interface. |
58 | * number of PIO buffers if not set via module interface. | ||
59 | * The problem with this is that it's global, but we'll use different | 58 | * The problem with this is that it's global, but we'll use different |
60 | * numbers for different chip types. So the default value is not | 59 | * numbers for different chip types. |
61 | * very useful. I've redefined it for the 1.3 release so that it's | ||
62 | * zero unless set by the user to something else, in which case we | ||
63 | * try to respect it. | ||
64 | */ | 60 | */ |
65 | static ushort ipath_kpiobufs; | 61 | static ushort ipath_kpiobufs; |
66 | 62 | ||
@@ -546,9 +542,12 @@ static void enable_chip(struct ipath_devdata *dd, int reinit) | |||
546 | pioavail = dd->ipath_pioavailregs_dma[i ^ 1]; | 542 | pioavail = dd->ipath_pioavailregs_dma[i ^ 1]; |
547 | else | 543 | else |
548 | pioavail = dd->ipath_pioavailregs_dma[i]; | 544 | pioavail = dd->ipath_pioavailregs_dma[i]; |
549 | dd->ipath_pioavailshadow[i] = le64_to_cpu(pioavail) | | 545 | /* |
550 | (~dd->ipath_pioavailkernel[i] << | 546 | * don't need to worry about ipath_pioavailkernel here |
551 | INFINIPATH_SENDPIOAVAIL_BUSY_SHIFT); | 547 | * because we will call ipath_chg_pioavailkernel() later |
548 | * in initialization, to busy out buffers as needed | ||
549 | */ | ||
550 | dd->ipath_pioavailshadow[i] = le64_to_cpu(pioavail); | ||
552 | } | 551 | } |
553 | /* can get counters, stats, etc. */ | 552 | /* can get counters, stats, etc. */ |
554 | dd->ipath_flags |= IPATH_PRESENT; | 553 | dd->ipath_flags |= IPATH_PRESENT; |
@@ -708,12 +707,11 @@ static void verify_interrupt(unsigned long opaque) | |||
708 | int ipath_init_chip(struct ipath_devdata *dd, int reinit) | 707 | int ipath_init_chip(struct ipath_devdata *dd, int reinit) |
709 | { | 708 | { |
710 | int ret = 0; | 709 | int ret = 0; |
711 | u32 val32, kpiobufs; | 710 | u32 kpiobufs, defkbufs; |
712 | u32 piobufs, uports; | 711 | u32 piobufs, uports; |
713 | u64 val; | 712 | u64 val; |
714 | struct ipath_portdata *pd; | 713 | struct ipath_portdata *pd; |
715 | gfp_t gfp_flags = GFP_USER | __GFP_COMP; | 714 | gfp_t gfp_flags = GFP_USER | __GFP_COMP; |
716 | unsigned long flags; | ||
717 | 715 | ||
718 | ret = init_housekeeping(dd, reinit); | 716 | ret = init_housekeeping(dd, reinit); |
719 | if (ret) | 717 | if (ret) |
@@ -753,56 +751,46 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit) | |||
753 | dd->ipath_pioavregs = ALIGN(piobufs, sizeof(u64) * BITS_PER_BYTE / 2) | 751 | dd->ipath_pioavregs = ALIGN(piobufs, sizeof(u64) * BITS_PER_BYTE / 2) |
754 | / (sizeof(u64) * BITS_PER_BYTE / 2); | 752 | / (sizeof(u64) * BITS_PER_BYTE / 2); |
755 | uports = dd->ipath_cfgports ? dd->ipath_cfgports - 1 : 0; | 753 | uports = dd->ipath_cfgports ? dd->ipath_cfgports - 1 : 0; |
756 | if (ipath_kpiobufs == 0) { | 754 | if (piobufs > 144) |
757 | /* not set by user (this is default) */ | 755 | defkbufs = 32 + dd->ipath_pioreserved; |
758 | if (piobufs > 144) | ||
759 | kpiobufs = 32; | ||
760 | else | ||
761 | kpiobufs = 16; | ||
762 | } | ||
763 | else | 756 | else |
764 | kpiobufs = ipath_kpiobufs; | 757 | defkbufs = 16 + dd->ipath_pioreserved; |
765 | 758 | ||
766 | if (kpiobufs + (uports * IPATH_MIN_USER_PORT_BUFCNT) > piobufs) { | 759 | if (ipath_kpiobufs && (ipath_kpiobufs + |
760 | (uports * IPATH_MIN_USER_PORT_BUFCNT)) > piobufs) { | ||
767 | int i = (int) piobufs - | 761 | int i = (int) piobufs - |
768 | (int) (uports * IPATH_MIN_USER_PORT_BUFCNT); | 762 | (int) (uports * IPATH_MIN_USER_PORT_BUFCNT); |
769 | if (i < 1) | 763 | if (i < 1) |
770 | i = 1; | 764 | i = 1; |
771 | dev_info(&dd->pcidev->dev, "Allocating %d PIO bufs of " | 765 | dev_info(&dd->pcidev->dev, "Allocating %d PIO bufs of " |
772 | "%d for kernel leaves too few for %d user ports " | 766 | "%d for kernel leaves too few for %d user ports " |
773 | "(%d each); using %u\n", kpiobufs, | 767 | "(%d each); using %u\n", ipath_kpiobufs, |
774 | piobufs, uports, IPATH_MIN_USER_PORT_BUFCNT, i); | 768 | piobufs, uports, IPATH_MIN_USER_PORT_BUFCNT, i); |
775 | /* | 769 | /* |
776 | * shouldn't change ipath_kpiobufs, because could be | 770 | * shouldn't change ipath_kpiobufs, because could be |
777 | * different for different devices... | 771 | * different for different devices... |
778 | */ | 772 | */ |
779 | kpiobufs = i; | 773 | kpiobufs = i; |
780 | } | 774 | } else if (ipath_kpiobufs) |
775 | kpiobufs = ipath_kpiobufs; | ||
776 | else | ||
777 | kpiobufs = defkbufs; | ||
781 | dd->ipath_lastport_piobuf = piobufs - kpiobufs; | 778 | dd->ipath_lastport_piobuf = piobufs - kpiobufs; |
782 | dd->ipath_pbufsport = | 779 | dd->ipath_pbufsport = |
783 | uports ? dd->ipath_lastport_piobuf / uports : 0; | 780 | uports ? dd->ipath_lastport_piobuf / uports : 0; |
784 | val32 = dd->ipath_lastport_piobuf - (dd->ipath_pbufsport * uports); | 781 | /* if not an even divisor, some user ports get extra buffers */ |
785 | if (val32 > 0) { | 782 | dd->ipath_ports_extrabuf = dd->ipath_lastport_piobuf - |
786 | ipath_dbg("allocating %u pbufs/port leaves %u unused, " | 783 | (dd->ipath_pbufsport * uports); |
787 | "add to kernel\n", dd->ipath_pbufsport, val32); | 784 | if (dd->ipath_ports_extrabuf) |
788 | dd->ipath_lastport_piobuf -= val32; | 785 | ipath_dbg("%u pbufs/port leaves some unused, add 1 buffer to " |
789 | kpiobufs += val32; | 786 | "ports <= %u\n", dd->ipath_pbufsport, |
790 | ipath_dbg("%u pbufs/port leaves %u unused, add to kernel\n", | 787 | dd->ipath_ports_extrabuf); |
791 | dd->ipath_pbufsport, val32); | ||
792 | } | ||
793 | dd->ipath_lastpioindex = 0; | 788 | dd->ipath_lastpioindex = 0; |
794 | dd->ipath_lastpioindexl = dd->ipath_piobcnt2k; | 789 | dd->ipath_lastpioindexl = dd->ipath_piobcnt2k; |
795 | ipath_chg_pioavailkernel(dd, 0, piobufs, 1); | 790 | /* ipath_pioavailshadow initialized earlier */ |
796 | ipath_cdbg(VERBOSE, "%d PIO bufs for kernel out of %d total %u " | 791 | ipath_cdbg(VERBOSE, "%d PIO bufs for kernel out of %d total %u " |
797 | "each for %u user ports\n", kpiobufs, | 792 | "each for %u user ports\n", kpiobufs, |
798 | piobufs, dd->ipath_pbufsport, uports); | 793 | piobufs, dd->ipath_pbufsport, uports); |
799 | if (dd->ipath_pioupd_thresh) { | ||
800 | if (dd->ipath_pbufsport < dd->ipath_pioupd_thresh) | ||
801 | dd->ipath_pioupd_thresh = dd->ipath_pbufsport; | ||
802 | if (kpiobufs < dd->ipath_pioupd_thresh) | ||
803 | dd->ipath_pioupd_thresh = kpiobufs; | ||
804 | } | ||
805 | |||
806 | ret = dd->ipath_f_early_init(dd); | 794 | ret = dd->ipath_f_early_init(dd); |
807 | if (ret) { | 795 | if (ret) { |
808 | ipath_dev_err(dd, "Early initialization failure\n"); | 796 | ipath_dev_err(dd, "Early initialization failure\n"); |
@@ -810,13 +798,6 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit) | |||
810 | } | 798 | } |
811 | 799 | ||
812 | /* | 800 | /* |
813 | * Cancel any possible active sends from early driver load. | ||
814 | * Follows early_init because some chips have to initialize | ||
815 | * PIO buffers in early_init to avoid false parity errors. | ||
816 | */ | ||
817 | ipath_cancel_sends(dd, 0); | ||
818 | |||
819 | /* | ||
820 | * Early_init sets rcvhdrentsize and rcvhdrsize, so this must be | 801 | * Early_init sets rcvhdrentsize and rcvhdrsize, so this must be |
821 | * done after early_init. | 802 | * done after early_init. |
822 | */ | 803 | */ |
@@ -836,6 +817,7 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit) | |||
836 | 817 | ||
837 | ipath_write_kreg(dd, dd->ipath_kregs->kr_sendpioavailaddr, | 818 | ipath_write_kreg(dd, dd->ipath_kregs->kr_sendpioavailaddr, |
838 | dd->ipath_pioavailregs_phys); | 819 | dd->ipath_pioavailregs_phys); |
820 | |||
839 | /* | 821 | /* |
840 | * this is to detect s/w errors, which the h/w works around by | 822 | * this is to detect s/w errors, which the h/w works around by |
841 | * ignoring the low 6 bits of address, if it wasn't aligned. | 823 | * ignoring the low 6 bits of address, if it wasn't aligned. |
@@ -862,12 +844,6 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit) | |||
862 | ~0ULL&~INFINIPATH_HWE_MEMBISTFAILED); | 844 | ~0ULL&~INFINIPATH_HWE_MEMBISTFAILED); |
863 | ipath_write_kreg(dd, dd->ipath_kregs->kr_control, 0ULL); | 845 | ipath_write_kreg(dd, dd->ipath_kregs->kr_control, 0ULL); |
864 | 846 | ||
865 | spin_lock_irqsave(&dd->ipath_sendctrl_lock, flags); | ||
866 | dd->ipath_sendctrl = INFINIPATH_S_PIOENABLE; | ||
867 | ipath_write_kreg(dd, dd->ipath_kregs->kr_sendctrl, dd->ipath_sendctrl); | ||
868 | ipath_read_kreg64(dd, dd->ipath_kregs->kr_scratch); | ||
869 | spin_unlock_irqrestore(&dd->ipath_sendctrl_lock, flags); | ||
870 | |||
871 | /* | 847 | /* |
872 | * before error clears, since we expect serdes pll errors during | 848 | * before error clears, since we expect serdes pll errors during |
873 | * this, the first time after reset | 849 | * this, the first time after reset |
@@ -940,6 +916,19 @@ int ipath_init_chip(struct ipath_devdata *dd, int reinit) | |||
940 | else | 916 | else |
941 | enable_chip(dd, reinit); | 917 | enable_chip(dd, reinit); |
942 | 918 | ||
919 | /* after enable_chip, so pioavailshadow setup */ | ||
920 | ipath_chg_pioavailkernel(dd, 0, piobufs, 1); | ||
921 | |||
922 | /* | ||
923 | * Cancel any possible active sends from early driver load. | ||
924 | * Follows early_init because some chips have to initialize | ||
925 | * PIO buffers in early_init to avoid false parity errors. | ||
926 | * After enable and ipath_chg_pioavailkernel so we can safely | ||
927 | * enable pioavail updates and PIOENABLE; packets are now | ||
928 | * ready to go out. | ||
929 | */ | ||
930 | ipath_cancel_sends(dd, 1); | ||
931 | |||
943 | if (!reinit) { | 932 | if (!reinit) { |
944 | /* | 933 | /* |
945 | * Used when we close a port, for DMA already in flight | 934 | * Used when we close a port, for DMA already in flight |