IB/qib: Eliminate 64-bit jiffies use
[cascardo/linux.git] / drivers / infiniband / hw / qib / qib_iba7322.c
index 5bd2162..abd218d 100644 (file)
@@ -615,8 +615,8 @@ struct qib_chippport_specific {
        u64 ibmalfsnap;
        u64 ibcctrl_a; /* krp_ibcctrl_a shadow */
        u64 ibcctrl_b; /* krp_ibcctrl_b shadow */
-       u64 qdr_dfe_time;
-       u64 chase_end;
+       unsigned long qdr_dfe_time;
+       unsigned long chase_end;
        u32 autoneg_tries;
        u32 recovery_init;
        u32 qdr_dfe_on;
@@ -1672,7 +1672,8 @@ static void reenable_chase(unsigned long opaque)
                QLOGIC_IB_IBCC_LINKINITCMD_POLL);
 }
 
-static void disable_chase(struct qib_pportdata *ppd, u64 tnow, u8 ibclt)
+static void disable_chase(struct qib_pportdata *ppd, unsigned long tnow,
+               u8 ibclt)
 {
        ppd->cpspec->chase_end = 0;
 
@@ -1688,7 +1689,7 @@ static void disable_chase(struct qib_pportdata *ppd, u64 tnow, u8 ibclt)
 static void handle_serdes_issues(struct qib_pportdata *ppd, u64 ibcst)
 {
        u8 ibclt;
-       u64 tnow;
+       unsigned long tnow;
 
        ibclt = (u8)SYM_FIELD(ibcst, IBCStatusA_0, LinkTrainingState);
 
@@ -1703,9 +1704,9 @@ static void handle_serdes_issues(struct qib_pportdata *ppd, u64 ibcst)
        case IB_7322_LT_STATE_CFGWAITRMT:
        case IB_7322_LT_STATE_TXREVLANES:
        case IB_7322_LT_STATE_CFGENH:
-               tnow = get_jiffies_64();
+               tnow = jiffies;
                if (ppd->cpspec->chase_end &&
-                    time_after64(tnow, ppd->cpspec->chase_end))
+                    time_after(tnow, ppd->cpspec->chase_end))
                        disable_chase(ppd, tnow, ibclt);
                else if (!ppd->cpspec->chase_end)
                        ppd->cpspec->chase_end = tnow + QIB_CHASE_TIME;
@@ -2307,19 +2308,11 @@ static int qib_7322_bringup_serdes(struct qib_pportdata *ppd)
                SYM_LSB(IBCCtrlA_0, MaxPktLen);
        ppd->cpspec->ibcctrl_a = ibc; /* without linkcmd or linkinitcmd! */
 
-       /* initially come up waiting for TS1, without sending anything. */
-       val = ppd->cpspec->ibcctrl_a | (QLOGIC_IB_IBCC_LINKINITCMD_DISABLE <<
-               QLOGIC_IB_IBCC_LINKINITCMD_SHIFT);
-
-       ppd->cpspec->ibcctrl_a = val;
        /*
         * Reset the PCS interface to the serdes (and also ibc, which is still
         * in reset from above).  Writes new value of ibcctrl_a as last step.
         */
        qib_7322_mini_pcs_reset(ppd);
-       qib_write_kreg(dd, kr_scratch, 0ULL);
-       /* clear the linkinit cmds */
-       ppd->cpspec->ibcctrl_a &= ~SYM_MASK(IBCCtrlA_0, LinkInitCmd);
 
        if (!ppd->cpspec->ibcctrl_b) {
                unsigned lse = ppd->link_speed_enabled;
@@ -2385,6 +2378,14 @@ static int qib_7322_bringup_serdes(struct qib_pportdata *ppd)
        ppd->cpspec->ibcctrl_a |= SYM_MASK(IBCCtrlA_0, IBLinkEn);
        set_vls(ppd);
 
+       /* initially come up DISABLED, without sending anything. */
+       val = ppd->cpspec->ibcctrl_a | (QLOGIC_IB_IBCC_LINKINITCMD_DISABLE <<
+                                       QLOGIC_IB_IBCC_LINKINITCMD_SHIFT);
+       qib_write_kreg_port(ppd, krp_ibcctrl_a, val);
+       qib_write_kreg(dd, kr_scratch, 0ULL);
+       /* clear the linkinit cmds */
+       ppd->cpspec->ibcctrl_a = val & ~SYM_MASK(IBCCtrlA_0, LinkInitCmd);
+
        /* be paranoid against later code motion, etc. */
        spin_lock_irqsave(&dd->cspec->rcvmod_lock, flags);
        ppd->p_rcvctrl |= SYM_MASK(RcvCtrl_0, RcvIBPortEnable);
@@ -2714,7 +2715,7 @@ static noinline void unknown_7322_gpio_intr(struct qib_devdata *dd)
                        pins >>= SYM_LSB(EXTStatus, GPIOIn);
                        if (!(pins & mask)) {
                                ++handled;
-                               qd->t_insert = get_jiffies_64();
+                               qd->t_insert = jiffies;
                                queue_work(ib_wq, &qd->work);
                        }
                }
@@ -4794,7 +4795,7 @@ static void qib_get_7322_faststats(unsigned long opaque)
                    (ppd->lflags & (QIBL_LINKINIT | QIBL_LINKARMED |
                                    QIBL_LINKACTIVE)) &&
                    ppd->cpspec->qdr_dfe_time &&
-                   time_after64(get_jiffies_64(), ppd->cpspec->qdr_dfe_time)) {
+                   time_is_before_jiffies(ppd->cpspec->qdr_dfe_time)) {
                        ppd->cpspec->qdr_dfe_on = 0;
 
                        qib_write_kreg_port(ppd, krp_static_adapt_dis(2),
@@ -5240,8 +5241,8 @@ static int qib_7322_ib_updown(struct qib_pportdata *ppd, int ibup, u64 ibcs)
                        /* schedule the qsfp refresh which should turn the link
                           off */
                        if (ppd->dd->flags & QIB_HAS_QSFP) {
-                               qd->t_insert = get_jiffies_64();
-                               schedule_work(&qd->work);
+                               qd->t_insert = jiffies;
+                               queue_work(ib_wq, &qd->work);
                        }
                        spin_lock_irqsave(&ppd->sdma_lock, flags);
                        if (__qib_sdma_running(ppd))
@@ -5592,7 +5593,7 @@ static void qsfp_7322_event(struct work_struct *work)
 {
        struct qib_qsfp_data *qd;
        struct qib_pportdata *ppd;
-       u64 pwrup;
+       unsigned long pwrup;
        unsigned long flags;
        int ret;
        u32 le2;
@@ -5620,8 +5621,7 @@ static void qsfp_7322_event(struct work_struct *work)
                 * to insertion.
                 */
                while (1) {
-                       u64 now = get_jiffies_64();
-                       if (time_after64(now, pwrup))
+                       if (time_is_before_jiffies(pwrup))
                                break;
                        msleep(20);
                }
@@ -7506,7 +7506,7 @@ static int serdes_7322_init_old(struct qib_pportdata *ppd)
 
 static int serdes_7322_init_new(struct qib_pportdata *ppd)
 {
-       u64 tstart;
+       unsigned long tend;
        u32 le_val, rxcaldone;
        int chan, chan_done = (1 << SERDES_CHANS) - 1;
 
@@ -7611,10 +7611,8 @@ static int serdes_7322_init_new(struct qib_pportdata *ppd)
        msleep(20);
        /*       Start Calibration */
        ibsd_wr_allchans(ppd, 4, (1 << 10), BMASK(10, 10));
-       tstart = get_jiffies_64();
-       while (chan_done &&
-              !time_after64(get_jiffies_64(),
-                       tstart + msecs_to_jiffies(500))) {
+       tend = jiffies + msecs_to_jiffies(500);
+       while (chan_done && !time_is_before_jiffies(tend)) {
                msleep(20);
                for (chan = 0; chan < SERDES_CHANS; ++chan) {
                        rxcaldone = ahb_mod(ppd->dd, IBSD(ppd->hw_pidx),