Commit 02a222c7 authored by Byczkowski, Jakub's avatar Byczkowski, Jakub Committed by Doug Ledford

IB/hfi1: Remove lstate from hfi1_pportdata

Do not track logical state separately from host_link_state. Deduce
logical state from host_link_state when required. Transitions in
set_link_state and goto_offline already make sure host_link_state
reflects hardware's logical state properly.
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarJakub Byczkowski <jakub.byczkowski@intel.com>
Signed-off-by: default avatarDennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
parent 16570d3d
...@@ -1065,6 +1065,7 @@ static int do_8051_command(struct hfi1_devdata *dd, u32 type, u64 in_data, ...@@ -1065,6 +1065,7 @@ static int do_8051_command(struct hfi1_devdata *dd, u32 type, u64 in_data,
static int read_idle_sma(struct hfi1_devdata *dd, u64 *data); static int read_idle_sma(struct hfi1_devdata *dd, u64 *data);
static int thermal_init(struct hfi1_devdata *dd); static int thermal_init(struct hfi1_devdata *dd);
static void update_statusp(struct hfi1_pportdata *ppd, u32 state);
static int wait_logical_linkstate(struct hfi1_pportdata *ppd, u32 state, static int wait_logical_linkstate(struct hfi1_pportdata *ppd, u32 state,
int msecs); int msecs);
static int wait_physical_linkstate(struct hfi1_pportdata *ppd, u32 state, static int wait_physical_linkstate(struct hfi1_pportdata *ppd, u32 state,
...@@ -10261,8 +10262,10 @@ static void force_logical_link_state_down(struct hfi1_pportdata *ppd) ...@@ -10261,8 +10262,10 @@ static void force_logical_link_state_down(struct hfi1_pportdata *ppd)
write_csr(dd, DC_LCB_CFG_ALLOW_LINK_UP, 0); write_csr(dd, DC_LCB_CFG_ALLOW_LINK_UP, 0);
write_csr(dd, DC_LCB_CFG_IGNORE_LOST_RCLK, 0); write_csr(dd, DC_LCB_CFG_IGNORE_LOST_RCLK, 0);
/* call again to adjust ppd->statusp, if needed */ /* adjust ppd->statusp, if needed */
get_logical_state(ppd); update_statusp(ppd, IB_PORT_DOWN);
dd_dev_info(ppd->dd, "logical state forced to LINK_DOWN\n");
} }
/* /*
...@@ -10458,11 +10461,11 @@ u32 driver_physical_state(struct hfi1_pportdata *ppd) ...@@ -10458,11 +10461,11 @@ u32 driver_physical_state(struct hfi1_pportdata *ppd)
} }
/* /*
* driver_logical_state - convert the driver's notion of a port's * driver_lstate - convert the driver's notion of a port's
* state (an HLS_*) into a logical state (a IB_PORT_*). Return -1 * state (an HLS_*) into a logical state (a IB_PORT_*). Return -1
* (converted to a u32) to indicate error. * (converted to a u32) to indicate error.
*/ */
u32 driver_logical_state(struct hfi1_pportdata *ppd) u32 driver_lstate(struct hfi1_pportdata *ppd)
{ {
if (ppd->host_link_state && (ppd->host_link_state & HLS_DOWN)) if (ppd->host_link_state && (ppd->host_link_state & HLS_DOWN))
return IB_PORT_DOWN; return IB_PORT_DOWN;
...@@ -12651,20 +12654,8 @@ const char *opa_pstate_name(u32 pstate) ...@@ -12651,20 +12654,8 @@ const char *opa_pstate_name(u32 pstate)
return "unknown"; return "unknown";
} }
/* static void update_statusp(struct hfi1_pportdata *ppd, u32 state)
* Read the hardware link state and set the driver's cached value of it.
* Return the (new) current value.
*/
u32 get_logical_state(struct hfi1_pportdata *ppd)
{ {
u32 new_state;
new_state = chip_to_opa_lstate(ppd->dd, read_logical_state(ppd->dd));
if (new_state != ppd->lstate) {
dd_dev_info(ppd->dd, "logical state changed to %s (0x%x)\n",
opa_lstate_name(new_state), new_state);
ppd->lstate = new_state;
}
/* /*
* Set port status flags in the page mapped into userspace * Set port status flags in the page mapped into userspace
* memory. Do it here to ensure a reliable state - this is * memory. Do it here to ensure a reliable state - this is
...@@ -12674,7 +12665,7 @@ u32 get_logical_state(struct hfi1_pportdata *ppd) ...@@ -12674,7 +12665,7 @@ u32 get_logical_state(struct hfi1_pportdata *ppd)
* function. * function.
*/ */
if (ppd->statusp) { if (ppd->statusp) {
switch (ppd->lstate) { switch (state) {
case IB_PORT_DOWN: case IB_PORT_DOWN:
case IB_PORT_INIT: case IB_PORT_INIT:
*ppd->statusp &= ~(HFI1_STATUS_IB_CONF | *ppd->statusp &= ~(HFI1_STATUS_IB_CONF |
...@@ -12688,10 +12679,9 @@ u32 get_logical_state(struct hfi1_pportdata *ppd) ...@@ -12688,10 +12679,9 @@ u32 get_logical_state(struct hfi1_pportdata *ppd)
break; break;
} }
} }
return ppd->lstate;
} }
/** /*
* wait_logical_linkstate - wait for an IB link state change to occur * wait_logical_linkstate - wait for an IB link state change to occur
* @ppd: port device * @ppd: port device
* @state: the state to wait for * @state: the state to wait for
...@@ -12705,18 +12695,29 @@ static int wait_logical_linkstate(struct hfi1_pportdata *ppd, u32 state, ...@@ -12705,18 +12695,29 @@ static int wait_logical_linkstate(struct hfi1_pportdata *ppd, u32 state,
int msecs) int msecs)
{ {
unsigned long timeout; unsigned long timeout;
u32 new_state;
timeout = jiffies + msecs_to_jiffies(msecs); timeout = jiffies + msecs_to_jiffies(msecs);
while (1) { while (1) {
if (get_logical_state(ppd) == state) new_state = chip_to_opa_lstate(ppd->dd,
return 0; read_logical_state(ppd->dd));
if (time_after(jiffies, timeout)) if (new_state == state)
break; break;
if (time_after(jiffies, timeout)) {
dd_dev_err(ppd->dd,
"timeout waiting for link state 0x%x\n",
state);
return -ETIMEDOUT;
}
msleep(20); msleep(20);
} }
dd_dev_err(ppd->dd, "timeout waiting for link state 0x%x\n", state);
return -ETIMEDOUT; update_statusp(ppd, state);
dd_dev_info(ppd->dd,
"logical state changed to %s (0x%x)\n",
opa_lstate_name(state),
state);
return 0;
} }
/* /*
...@@ -14855,7 +14856,6 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev, ...@@ -14855,7 +14856,6 @@ struct hfi1_devdata *hfi1_init_dd(struct pci_dev *pdev,
* Set the initial values to reasonable default, will be set * Set the initial values to reasonable default, will be set
* for real when link is up. * for real when link is up.
*/ */
ppd->lstate = IB_PORT_DOWN;
ppd->overrun_threshold = 0x4; ppd->overrun_threshold = 0x4;
ppd->phy_error_threshold = 0xf; ppd->phy_error_threshold = 0xf;
ppd->port_crc_mode_enabled = link_crc_mask; ppd->port_crc_mode_enabled = link_crc_mask;
......
...@@ -748,12 +748,11 @@ int is_ax(struct hfi1_devdata *dd); ...@@ -748,12 +748,11 @@ int is_ax(struct hfi1_devdata *dd);
int is_bx(struct hfi1_devdata *dd); int is_bx(struct hfi1_devdata *dd);
u32 read_physical_state(struct hfi1_devdata *dd); u32 read_physical_state(struct hfi1_devdata *dd);
u32 chip_to_opa_pstate(struct hfi1_devdata *dd, u32 chip_pstate); u32 chip_to_opa_pstate(struct hfi1_devdata *dd, u32 chip_pstate);
u32 get_logical_state(struct hfi1_pportdata *ppd);
void cache_physical_state(struct hfi1_pportdata *ppd); void cache_physical_state(struct hfi1_pportdata *ppd);
const char *opa_lstate_name(u32 lstate); const char *opa_lstate_name(u32 lstate);
const char *opa_pstate_name(u32 pstate); const char *opa_pstate_name(u32 pstate);
u32 driver_physical_state(struct hfi1_pportdata *ppd); u32 driver_physical_state(struct hfi1_pportdata *ppd);
u32 driver_logical_state(struct hfi1_pportdata *ppd); u32 driver_lstate(struct hfi1_pportdata *ppd);
int acquire_lcb_access(struct hfi1_devdata *dd, int sleep_ok); int acquire_lcb_access(struct hfi1_devdata *dd, int sleep_ok);
int release_lcb_access(struct hfi1_devdata *dd, int sleep_ok); int release_lcb_access(struct hfi1_devdata *dd, int sleep_ok);
......
...@@ -591,8 +591,6 @@ struct hfi1_pportdata { ...@@ -591,8 +591,6 @@ struct hfi1_pportdata {
struct mutex hls_lock; struct mutex hls_lock;
u32 host_link_state; u32 host_link_state;
u32 lstate; /* logical link state */
/* these are the "32 bit" regs */ /* these are the "32 bit" regs */
u32 ibmtu; /* The MTU programmed for this unit */ u32 ibmtu; /* The MTU programmed for this unit */
...@@ -1296,21 +1294,6 @@ static inline __le32 *get_rhf_addr(struct hfi1_ctxtdata *rcd) ...@@ -1296,21 +1294,6 @@ static inline __le32 *get_rhf_addr(struct hfi1_ctxtdata *rcd)
int hfi1_reset_device(int); int hfi1_reset_device(int);
/* return the driver's idea of the logical OPA port state */
static inline u32 driver_lstate(struct hfi1_pportdata *ppd)
{
/*
* The driver does some processing from the time the logical
* link state is at INIT to the time the SM can be notified
* as such. Return IB_PORT_DOWN until the software state
* is ready.
*/
if (ppd->lstate == IB_PORT_INIT && !(ppd->host_link_state & HLS_UP))
return IB_PORT_DOWN;
else
return ppd->lstate;
}
/* return the driver's idea of the physical OPA port state */ /* return the driver's idea of the physical OPA port state */
static inline u32 driver_pstate(struct hfi1_pportdata *ppd) static inline u32 driver_pstate(struct hfi1_pportdata *ppd)
{ {
......
...@@ -1117,7 +1117,7 @@ static int port_states_transition_allowed(struct hfi1_pportdata *ppd, ...@@ -1117,7 +1117,7 @@ static int port_states_transition_allowed(struct hfi1_pportdata *ppd,
u32 logical_new, u32 physical_new) u32 logical_new, u32 physical_new)
{ {
u32 physical_old = driver_physical_state(ppd); u32 physical_old = driver_physical_state(ppd);
u32 logical_old = driver_logical_state(ppd); u32 logical_old = driver_lstate(ppd);
int ret, logical_allowed, physical_allowed; int ret, logical_allowed, physical_allowed;
ret = logical_transition_allowed(logical_old, logical_new); ret = logical_transition_allowed(logical_old, logical_new);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment