Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[linda] Wait up to 20us for link state to update
Some subnet managers expect the GetResponse from a SetPortInfo MAD to
contain the new link state.  The transition is not immediate, so we
often end up returning the previous link state.  This can cause the SM
to fail to activate the port.

Fix by waiting for up to 20us for the link state transition to take
effect.
  • Loading branch information
Michael Brown committed Nov 16, 2009
1 parent c2c7737 commit 7467cf5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/drivers/infiniband/linda.c
Expand Up @@ -238,6 +238,32 @@ static void linda_link_state_changed ( struct ib_device *ibdev ) {
ib_link_state_changed ( ibdev );
}

/**
* Wait for link state change to take effect
*
* @v linda Linda device
* @v new_link_state Expected link state
* @ret rc Return status code
*/
static int linda_link_state_check ( struct linda *linda,
unsigned int new_link_state ) {
struct QIB_7220_IBCStatus ibcstatus;
unsigned int link_state;
unsigned int i;

for ( i = 0 ; i < LINDA_LINK_STATE_MAX_WAIT_US ; i++ ) {
linda_readq ( linda, &ibcstatus, QIB_7220_IBCStatus_offset );
link_state = BIT_GET ( &ibcstatus, LinkState );
if ( link_state == new_link_state )
return 0;
udelay ( 1 );
}

DBGC ( linda, "Linda %p timed out waiting for link state %s\n",
linda, linda_link_state_text ( link_state ) );
return -ETIMEDOUT;
}

/**
* Set port information
*
Expand All @@ -260,6 +286,12 @@ static int linda_set_port_info ( struct ib_device *ibdev, union ib_mad *mad ) {
linda_readq ( linda, &ibcctrl, QIB_7220_IBCCtrl_offset );
BIT_SET ( &ibcctrl, LinkCmd, link_state );
linda_writeq ( linda, &ibcctrl, QIB_7220_IBCCtrl_offset );

/* Wait for link state change to take effect. Ignore
* errors; the current link state will be returned via
* the GetResponse MAD.
*/
linda_link_state_check ( linda, link_state );
}

/* Detect and report link state change */
Expand Down
3 changes: 3 additions & 0 deletions src/drivers/infiniband/linda.h
Expand Up @@ -270,4 +270,7 @@ enum linda_link_state {
LINDA_LINK_STATE_ACT_DEFER = 4,
};

/** Maximum time to wait for link state changes, in us */
#define LINDA_LINK_STATE_MAX_WAIT_US 20

#endif /* _LINDA_H */

0 comments on commit 7467cf5

Please sign in to comment.