Skip to content

Commit 16d9981

Browse files
Mitko Haralanovrolandd
authored andcommitted
IB/qib: Fix issue with link states and QSFP cables
Fix an issue where the link would come up after replugging a cable even if it has been DISABLED manually. Signed-off-by: Mitko Haralanov <mitko@qlogic.com> Signed-off-by: Mike Marciniszyn <mike.marciniszyn@qlogic.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
1 parent dde05cb commit 16d9981

2 files changed

Lines changed: 21 additions & 10 deletions

File tree

‎drivers/infiniband/hw/qib/qib_iba7322.c‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2310,12 +2310,15 @@ static int qib_7322_bringup_serdes(struct qib_pportdata *ppd)
23102310
val = ppd->cpspec->ibcctrl_a | (QLOGIC_IB_IBCC_LINKINITCMD_DISABLE <<
23112311
QLOGIC_IB_IBCC_LINKINITCMD_SHIFT);
23122312

2313+
ppd->cpspec->ibcctrl_a = val;
23132314
/*
23142315
* Reset the PCS interface to the serdes (and also ibc, which is still
23152316
* in reset from above). Writes new value of ibcctrl_a as last step.
23162317
*/
23172318
qib_7322_mini_pcs_reset(ppd);
23182319
qib_write_kreg(dd, kr_scratch, 0ULL);
2320+
/* clear the linkinit cmds */
2321+
ppd->cpspec->ibcctrl_a &= ~SYM_MASK(IBCCtrlA_0, LinkInitCmd);
23192322

23202323
if (!ppd->cpspec->ibcctrl_b) {
23212324
unsigned lse = ppd->link_speed_enabled;
@@ -2381,11 +2384,6 @@ static int qib_7322_bringup_serdes(struct qib_pportdata *ppd)
23812384
ppd->cpspec->ibcctrl_a |= SYM_MASK(IBCCtrlA_0, IBLinkEn);
23822385
set_vls(ppd);
23832386

2384-
/* Hold the link state machine for mezz boards */
2385-
qib_set_ib_7322_lstate(ppd, 0,
2386-
QLOGIC_IB_IBCC_LINKINITCMD_DISABLE);
2387-
2388-
23892387
/* be paranoid against later code motion, etc. */
23902388
spin_lock_irqsave(&dd->cspec->rcvmod_lock, flags);
23912389
ppd->p_rcvctrl |= SYM_MASK(RcvCtrl_0, RcvIBPortEnable);
@@ -5594,6 +5592,7 @@ static void qsfp_7322_event(struct work_struct *work)
55945592
struct qib_qsfp_data *qd;
55955593
struct qib_pportdata *ppd;
55965594
u64 pwrup;
5595+
unsigned long flags;
55975596
int ret;
55985597
u32 le2;
55995598

@@ -5605,11 +5604,15 @@ static void qsfp_7322_event(struct work_struct *work)
56055604
/* Delay for 20 msecs to allow ModPrs resistor to setup */
56065605
mdelay(QSFP_MODPRS_LAG_MSEC);
56075606

5608-
if (!qib_qsfp_mod_present(ppd))
5607+
if (!qib_qsfp_mod_present(ppd)) {
5608+
ppd->cpspec->qsfp_data.modpresent = 0;
56095609
/* Set the physical link to disabled */
56105610
qib_set_ib_7322_lstate(ppd, 0,
56115611
QLOGIC_IB_IBCC_LINKINITCMD_DISABLE);
5612-
else {
5612+
spin_lock_irqsave(&ppd->lflags_lock, flags);
5613+
ppd->lflags &= ~QIBL_LINKV;
5614+
spin_unlock_irqrestore(&ppd->lflags_lock, flags);
5615+
} else {
56135616
/*
56145617
* Some QSFP's not only do not respond until the full power-up
56155618
* time, but may behave badly if we try. So hold off responding
@@ -5649,11 +5652,18 @@ static void qsfp_7322_event(struct work_struct *work)
56495652
*/
56505653
init_txdds_table(ppd, 0);
56515654
/* The physical link is being re-enabled only when the
5652-
previous state was DISABLED. This should only happen when
5653-
the cable has been physically pulled. */
5654-
if (ppd->lflags & QIBL_IB_LINK_DISABLED)
5655+
* previous state was DISABLED and the VALID bit is not
5656+
* set. This should only happen when the cable has been
5657+
* physically pulled. */
5658+
if (!ppd->cpspec->qsfp_data.modpresent &&
5659+
(ppd->lflags & (QIBL_LINKV | QIBL_IB_LINK_DISABLED))) {
5660+
ppd->cpspec->qsfp_data.modpresent = 1;
56555661
qib_set_ib_7322_lstate(ppd, 0,
56565662
QLOGIC_IB_IBCC_LINKINITCMD_SLEEP);
5663+
spin_lock_irqsave(&ppd->lflags_lock, flags);
5664+
ppd->lflags |= QIBL_LINKV;
5665+
spin_unlock_irqrestore(&ppd->lflags_lock, flags);
5666+
}
56575667
}
56585668
}
56595669

‎drivers/infiniband/hw/qib/qib_qsfp.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ struct qib_qsfp_data {
178178
struct work_struct work;
179179
struct qib_qsfp_cache cache;
180180
u64 t_insert;
181+
u8 modpresent;
181182
};
182183

183184
extern int qib_refresh_qsfp_cache(struct qib_pportdata *ppd,

0 commit comments

Comments
 (0)