Skip to content

Commit 913cc67

Browse files
ssanchez11dledford
authored andcommitted
IB/hfi1: Always perform offline transition
Always initiate an offline transition request when a link down occurs. The firmware will use this request to confirm that the driver has seen the link down message. A host version is set to indicate this driver behavior to the firmware. Reviewed-by: Dean Luick <[email protected]> Signed-off-by: Sebastian Sanchez <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 626c077 commit 913cc67

File tree

3 files changed

+46
-33
lines changed

3 files changed

+46
-33
lines changed

drivers/infiniband/hw/hfi1/chip.c

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8832,6 +8832,20 @@ static void read_remote_device_id(struct hfi1_devdata *dd, u16 *device_id,
88328832
& REMOTE_DEVICE_REV_MASK;
88338833
}
88348834

8835+
int write_host_interface_version(struct hfi1_devdata *dd, u8 version)
8836+
{
8837+
u32 frame;
8838+
u32 mask;
8839+
8840+
mask = (HOST_INTERFACE_VERSION_MASK << HOST_INTERFACE_VERSION_SHIFT);
8841+
read_8051_config(dd, RESERVED_REGISTERS, GENERAL_CONFIG, &frame);
8842+
/* Clear, then set field */
8843+
frame &= ~mask;
8844+
frame |= ((u32)version << HOST_INTERFACE_VERSION_SHIFT);
8845+
return load_8051_config(dd, RESERVED_REGISTERS, GENERAL_CONFIG,
8846+
frame);
8847+
}
8848+
88358849
void read_misc_status(struct hfi1_devdata *dd, u8 *ver_major, u8 *ver_minor,
88368850
u8 *ver_patch)
88378851
{
@@ -10262,49 +10276,35 @@ static void force_logical_link_state_down(struct hfi1_pportdata *ppd)
1026210276
static int goto_offline(struct hfi1_pportdata *ppd, u8 rem_reason)
1026310277
{
1026410278
struct hfi1_devdata *dd = ppd->dd;
10265-
u32 pstate, previous_state;
10279+
u32 previous_state;
1026610280
int ret;
10267-
int do_transition;
10268-
int do_wait;
1026910281

1027010282
update_lcb_cache(dd);
1027110283

1027210284
previous_state = ppd->host_link_state;
1027310285
ppd->host_link_state = HLS_GOING_OFFLINE;
10274-
pstate = read_physical_state(dd);
10275-
if (pstate == PLS_OFFLINE) {
10276-
do_transition = 0; /* in right state */
10277-
do_wait = 0; /* ...no need to wait */
10278-
} else if ((pstate & 0xf0) == PLS_OFFLINE) {
10279-
do_transition = 0; /* in an offline transient state */
10280-
do_wait = 1; /* ...wait for it to settle */
10281-
} else {
10282-
do_transition = 1; /* need to move to offline */
10283-
do_wait = 1; /* ...will need to wait */
10284-
}
1028510286

10286-
if (do_transition) {
10287-
ret = set_physical_link_state(dd,
10288-
(rem_reason << 8) | PLS_OFFLINE);
10287+
/* start offline transition */
10288+
ret = set_physical_link_state(dd, (rem_reason << 8) | PLS_OFFLINE);
1028910289

10290-
if (ret != HCMD_SUCCESS) {
10291-
dd_dev_err(dd,
10292-
"Failed to transition to Offline link state, return %d\n",
10293-
ret);
10294-
return -EINVAL;
10295-
}
10296-
if (ppd->offline_disabled_reason ==
10297-
HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE))
10298-
ppd->offline_disabled_reason =
10299-
HFI1_ODR_MASK(OPA_LINKDOWN_REASON_TRANSIENT);
10290+
if (ret != HCMD_SUCCESS) {
10291+
dd_dev_err(dd,
10292+
"Failed to transition to Offline link state, return %d\n",
10293+
ret);
10294+
return -EINVAL;
1030010295
}
10296+
if (ppd->offline_disabled_reason ==
10297+
HFI1_ODR_MASK(OPA_LINKDOWN_REASON_NONE))
10298+
ppd->offline_disabled_reason =
10299+
HFI1_ODR_MASK(OPA_LINKDOWN_REASON_TRANSIENT);
1030110300

10302-
if (do_wait) {
10303-
/* it can take a while for the link to go down */
10304-
ret = wait_physical_linkstate(ppd, PLS_OFFLINE, 10000);
10305-
if (ret < 0)
10306-
return ret;
10307-
}
10301+
/*
10302+
* Wait for offline transition. It can take a while for
10303+
* the link to go down.
10304+
*/
10305+
ret = wait_physical_linkstate(ppd, PLS_OFFLINE, 10000);
10306+
if (ret < 0)
10307+
return ret;
1030810308

1030910309
/*
1031010310
* Now in charge of LCB - must be after the physical state is

drivers/infiniband/hw/hfi1/chip.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@
384384
#define VERIFY_CAP_LOCAL_FABRIC 0x08
385385
#define VERIFY_CAP_LOCAL_LINK_WIDTH 0x09
386386
#define LOCAL_DEVICE_ID 0x0a
387+
#define RESERVED_REGISTERS 0x0b
387388
#define LOCAL_LNI_INFO 0x0c
388389
#define REMOTE_LNI_INFO 0x0d
389390
#define MISC_STATUS 0x0e
@@ -506,6 +507,9 @@
506507
#define DOWN_REMOTE_REASON_SHIFT 16
507508
#define DOWN_REMOTE_REASON_MASK 0xff
508509

510+
#define HOST_INTERFACE_VERSION_SHIFT 16
511+
#define HOST_INTERFACE_VERSION_MASK 0xff
512+
509513
/* verify capability PHY power management bits */
510514
#define PWRM_BER_CONTROL 0x1
511515
#define PWRM_BANDWIDTH_CONTROL 0x2
@@ -704,6 +708,7 @@ int read_8051_data(struct hfi1_devdata *dd, u32 addr, u32 len, u64 *result);
704708
/* chip.c */
705709
void read_misc_status(struct hfi1_devdata *dd, u8 *ver_major, u8 *ver_minor,
706710
u8 *ver_patch);
711+
int write_host_interface_version(struct hfi1_devdata *dd, u8 version);
707712
void read_guid(struct hfi1_devdata *dd);
708713
int wait_fm_ready(struct hfi1_devdata *dd, u32 mstimeout);
709714
void set_link_down_reason(struct hfi1_pportdata *ppd, u8 lcl_reason,

drivers/infiniband/hw/hfi1/firmware.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
#define ALT_FW_FABRIC_NAME "hfi1_fabric_d.fw"
7070
#define ALT_FW_SBUS_NAME "hfi1_sbus_d.fw"
7171
#define ALT_FW_PCIE_NAME "hfi1_pcie_d.fw"
72+
#define HOST_INTERFACE_VERSION 1
7273

7374
static uint fw_8051_load = 1;
7475
static uint fw_fabric_serdes_load = 1;
@@ -1087,6 +1088,13 @@ static int load_8051_firmware(struct hfi1_devdata *dd,
10871088
dd_dev_info(dd, "8051 firmware version %d.%d.%d\n",
10881089
(int)ver_major, (int)ver_minor, (int)ver_patch);
10891090
dd->dc8051_ver = dc8051_ver(ver_major, ver_minor, ver_patch);
1091+
ret = write_host_interface_version(dd, HOST_INTERFACE_VERSION);
1092+
if (ret != HCMD_SUCCESS) {
1093+
dd_dev_err(dd,
1094+
"Failed to set host interface version, return 0x%x\n",
1095+
ret);
1096+
return -EIO;
1097+
}
10901098

10911099
return 0;
10921100
}

0 commit comments

Comments
 (0)