kernel: bump 5.4 to 5.4.109
[openwrt/openwrt.git] / target / linux / layerscape / patches-5.4 / 809-jailhouse-0018-ivshmem-net-Refactor-and-comment-ivshm_net_state_cha.patch
1 From 5192fa99f0d267eb7bd1c79e556430ea8911ae38 Mon Sep 17 00:00:00 2001
2 From: Jan Kiszka <jan.kiszka@siemens.com>
3 Date: Sun, 4 Mar 2018 13:50:24 +0100
4 Subject: [PATCH] ivshmem-net: Refactor and comment ivshm_net_state_change
5
6 This should make the state transitioning logic clearer. Also avoid the
7 harmless but redundant netif_carrier_on/ivshm_net_run in RUN state.
8
9 Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
10 (cherry picked from commit 8539efe70fbdf4a0bea75a97c1628fbb38b6590b)
11 ---
12 drivers/net/ivshmem-net.c | 23 ++++++++++++++++++++---
13 1 file changed, 20 insertions(+), 3 deletions(-)
14
15 --- a/drivers/net/ivshmem-net.c
16 +++ b/drivers/net/ivshmem-net.c
17 @@ -575,14 +575,21 @@ static void ivshm_net_state_change(struc
18 struct net_device *ndev = in->napi.dev;
19 u32 rstate = readl(&in->ivshm_regs->rstate);
20
21 -
22 switch (in->lstate) {
23 case IVSHM_NET_STATE_RESET:
24 + /*
25 + * Wait for the remote to leave READY/RUN before transitioning
26 + * to INIT.
27 + */
28 if (rstate < IVSHM_NET_STATE_READY)
29 ivshm_net_set_state(in, IVSHM_NET_STATE_INIT);
30 break;
31
32 case IVSHM_NET_STATE_INIT:
33 + /*
34 + * Wait for the remote to leave RESET before performing the
35 + * initialization and moving to READY.
36 + */
37 if (rstate > IVSHM_NET_STATE_RESET) {
38 ivshm_net_init_queues(ndev);
39 ivshm_net_set_state(in, IVSHM_NET_STATE_READY);
40 @@ -594,11 +601,21 @@ static void ivshm_net_state_change(struc
41 break;
42
43 case IVSHM_NET_STATE_READY:
44 - case IVSHM_NET_STATE_RUN:
45 + /*
46 + * Link is up and we are running once the remote is in READY or
47 + * RUN.
48 + */
49 if (rstate >= IVSHM_NET_STATE_READY) {
50 netif_carrier_on(ndev);
51 ivshm_net_run(ndev);
52 - } else if (rstate == IVSHM_NET_STATE_RESET) {
53 + break;
54 + }
55 + /* fall through */
56 + case IVSHM_NET_STATE_RUN:
57 + /*
58 + * If the remote goes to RESET, we need to follow immediately.
59 + */
60 + if (rstate == IVSHM_NET_STATE_RESET) {
61 netif_carrier_off(ndev);
62 ivshm_net_do_stop(ndev);
63 }