Skip to content

Commit 25d97dd

Browse files
Vennila Megavannangregkh
authored andcommitted
staging/rdma/hfi1: Prevent host software lock up
If packets stop egressing the hardware link, software can lock up. Implement a timeout for send context halt recovery. This patch increases the timeout for packet egress to 500 us and timer resets to zero if the packet occupancy changes. Also we bounce the link on time out. Reviewed-by: Dean Luick <dean.luick@intel.com> Signed-off-by: Vennila Megavannan <vennila.megavannan@intel.com> Signed-off-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent dc06024 commit 25d97dd

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

‎drivers/staging/rdma/hfi1/pio.c‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -922,10 +922,12 @@ void sc_disable(struct send_context *sc)
922922
static void sc_wait_for_packet_egress(struct send_context *sc, int pause)
923923
{
924924
struct hfi1_devdata *dd = sc->dd;
925-
u64 reg;
925+
u64 reg = 0;
926+
u64 reg_prev;
926927
u32 loop = 0;
927928

928929
while (1) {
930+
reg_prev = reg;
929931
reg = read_csr(dd, sc->hw_context * 8 +
930932
SEND_EGRESS_CTXT_STATUS);
931933
/* done if egress is stopped */
@@ -934,11 +936,17 @@ static void sc_wait_for_packet_egress(struct send_context *sc, int pause)
934936
reg = packet_occupancy(reg);
935937
if (reg == 0)
936938
break;
937-
if (loop > 100) {
939+
/* counter is reset if occupancy count changes */
940+
if (reg != reg_prev)
941+
loop = 0;
942+
if (loop > 500) {
943+
/* timed out - bounce the link */
938944
dd_dev_err(dd,
939-
"%s: context %u(%u) timeout waiting for packets to egress, remaining count %u\n",
945+
"%s: context %u(%u) timeout waiting for packets to egress, remaining count %u, bouncing link\n",
940946
__func__, sc->sw_index,
941947
sc->hw_context, (u32)reg);
948+
queue_work(dd->pport->hfi1_wq,
949+
&dd->pport->link_bounce_work);
942950
break;
943951
}
944952
loop++;

‎drivers/staging/rdma/hfi1/sdma.c‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,17 +303,26 @@ static void sdma_wait_for_packet_egress(struct sdma_engine *sde,
303303
u64 off = 8 * sde->this_idx;
304304
struct hfi1_devdata *dd = sde->dd;
305305
int lcnt = 0;
306+
u64 reg_prev;
307+
u64 reg = 0;
306308

307309
while (1) {
308-
u64 reg = read_csr(dd, off + SEND_EGRESS_SEND_DMA_STATUS);
310+
reg_prev = reg;
311+
reg = read_csr(dd, off + SEND_EGRESS_SEND_DMA_STATUS);
309312

310313
reg &= SDMA_EGRESS_PACKET_OCCUPANCY_SMASK;
311314
reg >>= SDMA_EGRESS_PACKET_OCCUPANCY_SHIFT;
312315
if (reg == 0)
313316
break;
314-
if (lcnt++ > 100) {
315-
dd_dev_err(dd, "%s: engine %u timeout waiting for packets to egress, remaining count %u\n",
317+
/* counter is reest if accupancy count changes */
318+
if (reg != reg_prev)
319+
lcnt = 0;
320+
if (lcnt++ > 500) {
321+
/* timed out - bounce the link */
322+
dd_dev_err(dd, "%s: engine %u timeout waiting for packets to egress, remaining count %u, bouncing link\n",
316323
__func__, sde->this_idx, (u32)reg);
324+
queue_work(dd->pport->hfi1_wq,
325+
&dd->pport->link_bounce_work);
317326
break;
318327
}
319328
udelay(1);

0 commit comments

Comments
 (0)