Skip to content

Commit a4cd184

Browse files
author
David S. Miller
committed
[SPARC64]: Handle reset events in vio_link_state_change().
Signed-off-by: David S. Miller <[email protected]>
1 parent 8a2950c commit a4cd184

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

arch/sparc64/kernel/viohs.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,23 @@ static int start_handshake(struct vio_driver_state *vio)
7878
return 0;
7979
}
8080

81+
static void flush_rx_dring(struct vio_driver_state *vio)
82+
{
83+
struct vio_dring_state *dr;
84+
u64 ident;
85+
86+
BUG_ON(!(vio->dr_state & VIO_DR_STATE_RXREG));
87+
88+
dr = &vio->drings[VIO_DRIVER_RX_RING];
89+
ident = dr->ident;
90+
91+
BUG_ON(!vio->desc_buf);
92+
kfree(vio->desc_buf);
93+
94+
memset(dr, 0, sizeof(*dr));
95+
dr->ident = ident;
96+
}
97+
8198
void vio_link_state_change(struct vio_driver_state *vio, int event)
8299
{
83100
if (event == LDC_EVENT_UP) {
@@ -98,6 +115,16 @@ void vio_link_state_change(struct vio_driver_state *vio, int event)
98115
break;
99116
}
100117
start_handshake(vio);
118+
} else if (event == LDC_EVENT_RESET) {
119+
vio->hs_state = VIO_HS_INVALID;
120+
121+
if (vio->dr_state & VIO_DR_STATE_RXREG)
122+
flush_rx_dring(vio);
123+
124+
vio->dr_state = 0x00;
125+
memset(&vio->ver, 0, sizeof(vio->ver));
126+
127+
ldc_disconnect(vio->lp);
101128
}
102129
}
103130
EXPORT_SYMBOL(vio_link_state_change);
@@ -396,6 +423,8 @@ static int process_dreg_info(struct vio_driver_state *vio,
396423
if (vio->dr_state & VIO_DR_STATE_RXREG)
397424
goto send_nack;
398425

426+
BUG_ON(vio->desc_buf);
427+
399428
vio->desc_buf = kzalloc(pkt->descr_size, GFP_ATOMIC);
400429
if (!vio->desc_buf)
401430
goto send_nack;

0 commit comments

Comments
 (0)