From patchwork Tue Jan 23 11:25:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13527278 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BE4D9C47258 for ; Tue, 23 Jan 2024 11:30:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSEzD-0006Wc-Ue; Tue, 23 Jan 2024 06:30:35 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSEz5-0006VJ-5p for qemu-devel@nongnu.org; Tue, 23 Jan 2024 06:30:28 -0500 Received: from mout.kundenserver.de ([212.227.126.134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSEz0-0007md-SS for qemu-devel@nongnu.org; Tue, 23 Jan 2024 06:30:26 -0500 Received: from lenovo-t14s.redhat.com ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MAchM-1rHDLr45we-00B5Ae; Tue, 23 Jan 2024 12:25:04 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Sriram Yagnaraman , Jason Wang , Dmitry Fleytman , Laurent Vivier Subject: [PATCH 1/2] igb: fix link state on resume Date: Tue, 23 Jan 2024 12:25:00 +0100 Message-ID: <20240123112501.305681-1-lvivier@redhat.com> X-Mailer: git-send-email 2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cvMKJMFQfxKw0dR8fCMboOxEri6g4Jt9i7BmgJyn1hyFnSv9eszip/W3A eAyVARREUQ3S2bFU8mS5u1GP+0TenLTAR6ILazDC0B9Cx9uaQFU81pnZkGr7axzGoY59Mifi4 rYoItb2hAIYDtYw== Received-SPF: permerror client-ip=212.227.126.134; envelope-from=lvivier@redhat.com; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_FAIL=0.001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On resume igb_vm_state_change() always calls igb_autoneg_resume() that sets link_down to false, and thus activates the link even if we have disabled it. The problem can be reproduced starting qemu in paused state (-S) and then set the link to down. When we resume the machine the link appears to be up. Reproducer: # qemu-system-x86_64 ... -device igb,netdev=netdev0,id=net0 -S {"execute": "qmp_capabilities" } {"execute": "set_link", "arguments": {"name": "net0", "up": false}} {"execute": "cont" } To fix the problem, merge the content of igb_vm_state_change() into igb_core_post_load() as e1000 does. Buglink: https://issues.redhat.com/browse/RHEL-21867 Suggested-by: Akihiko Odaki Signed-off-by: Laurent Vivier --- hw/net/igb_core.c | 47 +++-------------------------------------------- hw/net/igb_core.h | 2 -- 2 files changed, 3 insertions(+), 46 deletions(-) diff --git a/hw/net/igb_core.c b/hw/net/igb_core.c index 2a7a11aa9ed5..31ab959ab8ff 100644 --- a/hw/net/igb_core.c +++ b/hw/net/igb_core.c @@ -160,14 +160,6 @@ igb_intmgr_timer_resume(IGBIntrDelayTimer *timer) } } -static void -igb_intmgr_timer_pause(IGBIntrDelayTimer *timer) -{ - if (timer->running) { - timer_del(timer->timer); - } -} - static void igb_intrmgr_on_msix_throttling_timer(void *opaque) { @@ -212,16 +204,6 @@ igb_intrmgr_resume(IGBCore *core) } } -static void -igb_intrmgr_pause(IGBCore *core) -{ - int i; - - for (i = 0; i < IGB_INTR_NUM; i++) { - igb_intmgr_timer_pause(&core->eitr[i]); - } -} - static void igb_intrmgr_reset(IGBCore *core) { @@ -4290,12 +4272,6 @@ igb_core_read(IGBCore *core, hwaddr addr, unsigned size) return 0; } -static inline void -igb_autoneg_pause(IGBCore *core) -{ - timer_del(core->autoneg_timer); -} - static void igb_autoneg_resume(IGBCore *core) { @@ -4307,22 +4283,6 @@ igb_autoneg_resume(IGBCore *core) } } -static void -igb_vm_state_change(void *opaque, bool running, RunState state) -{ - IGBCore *core = opaque; - - if (running) { - trace_e1000e_vm_state_running(); - igb_intrmgr_resume(core); - igb_autoneg_resume(core); - } else { - trace_e1000e_vm_state_stopped(); - igb_autoneg_pause(core); - igb_intrmgr_pause(core); - } -} - void igb_core_pci_realize(IGBCore *core, const uint16_t *eeprom_templ, @@ -4335,8 +4295,6 @@ igb_core_pci_realize(IGBCore *core, igb_autoneg_timer, core); igb_intrmgr_pci_realize(core); - core->vmstate = qemu_add_vm_change_state_handler(igb_vm_state_change, core); - for (i = 0; i < IGB_NUM_QUEUES; i++) { net_tx_pkt_init(&core->tx[i].tx_pkt, E1000E_MAX_TX_FRAGS); } @@ -4360,8 +4318,6 @@ igb_core_pci_uninit(IGBCore *core) igb_intrmgr_pci_unint(core); - qemu_del_vm_change_state_handler(core->vmstate); - for (i = 0; i < IGB_NUM_QUEUES; i++) { net_tx_pkt_uninit(core->tx[i].tx_pkt); } @@ -4586,5 +4542,8 @@ igb_core_post_load(IGBCore *core) */ nc->link_down = (core->mac[STATUS] & E1000_STATUS_LU) == 0; + igb_intrmgr_resume(core); + igb_autoneg_resume(core); + return 0; } diff --git a/hw/net/igb_core.h b/hw/net/igb_core.h index bf8c46f26b51..d70b54e318f1 100644 --- a/hw/net/igb_core.h +++ b/hw/net/igb_core.h @@ -90,8 +90,6 @@ struct IGBCore { IGBIntrDelayTimer eitr[IGB_INTR_NUM]; - VMChangeStateEntry *vmstate; - uint32_t eitr_guest_value[IGB_INTR_NUM]; uint8_t permanent_mac[ETH_ALEN]; From patchwork Tue Jan 23 11:25:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 13527277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C073DC47DDB for ; Tue, 23 Jan 2024 11:30:54 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSEzF-0006XF-Av; Tue, 23 Jan 2024 06:30:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSEz5-0006VK-FT for qemu-devel@nongnu.org; Tue, 23 Jan 2024 06:30:28 -0500 Received: from mout.kundenserver.de ([212.227.126.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSEz0-0007mb-Qp for qemu-devel@nongnu.org; Tue, 23 Jan 2024 06:30:27 -0500 Received: from lenovo-t14s.redhat.com ([82.142.8.70]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N9L64-1r53mm2ikm-015Fgy; Tue, 23 Jan 2024 12:25:04 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Cc: Akihiko Odaki , Sriram Yagnaraman , Jason Wang , Dmitry Fleytman , Laurent Vivier Subject: [PATCH 2/2] e1000e: fix link state on resume Date: Tue, 23 Jan 2024 12:25:01 +0100 Message-ID: <20240123112501.305681-2-lvivier@redhat.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240123112501.305681-1-lvivier@redhat.com> References: <20240123112501.305681-1-lvivier@redhat.com> MIME-Version: 1.0 X-Provags-ID: V03:K1:CBm09x7yLOvR07L/zHYkVcOUg3/MHvjg1vQfqykGJ80DqOjsuS7 UIx6eYUZotqaqMmzkPq+V7UFwuCQX7vSJQMjw4eBOMig0PjHfUTPwblSdHsma1MdWOys114 9KcZKnppK1tBuoUjDSWPxnBIVwHb5Vg8bLGYmdCvjavKwWrmhbY9cqAX1FizQASHTCASQ3u 1RFBshkWNvRZnaby44FpA== UI-OutboundReport: notjunk:1;M01:P0:9TCk6udNkOk=;fA/tUQ5+i+gJAJiVryC/1pip9fx 0xL71FBVRpcNBxIoizi69yAcP/UFTYQRRkAfeViBTeML+TDj3csC7K5ekavbwVar+AjNr0beb zQPUE5ZKoB0HDqwsVblVOx1pNxZGse8sUSFdWN71vNa5jHwlISn7J+AFxbY1Zm3DP6NCac/li hVe69fUrAPx3LQMWdNj8lCTeFBrWEQScJcqcVlTN4aW9qysnN37VF3f9O518+tsGS8Nq3QBDE JjNVsIVaIFcR1278+yQpW35dAMfRlWfx6uwYKyajcGEsciT3xb2ca4rdwOdxJ2D7o5kjLQW4S iajs6BSFbK2XqPvup7AFZ6iTXozJX/3heS1YcODxLYLebYM6y75q2KjpVeUGNb9VpmQt0EcQ5 HwlmI3MRo2KQflE/aMZyyFE+HB2NXW87MrRi28IjC6aflwsYbSIFsOwmPU/n3enoAaZFaHzv6 zpzGYgh6N0Xl3mafQBEHnD+ibzlusjzZ0k8stSS9JSbSgTfHakyO+bmTQtRroEyr3sIwC1xXd YBZb2FVU8C+bw3PZ0qJH8YMWucPpBZlQiRZSRBeXXw+x7zUxWiMyz+vOc82CVrQENw4gW5X68 JXqImo7zQGMBlsNuOQ+sQE7cM2GkPEFPPJiwZ8Y2RzETz/vHEqLhhf0aNGirp/NMPyZ6ydLYM WVl8OKv/g+6MII0r4jcQF/DXi5NHIXOdj0fNT0z4wAe6fxgWQQRGbfuHJ/yYqIiEgBXY0T7Zb xhQ4HpQI3ZblDjS4T29HgPQ78VvMVETsPwBM7svbdpzFoUc2Kzw36iNchgCAHqcxp2Wssihg2 UxjLu1SgpedmtcIuygFmRN0I9Lm6RIpz9JRN/OfT339Dds4/CoYGdk6BLRkkDOXG0E9F5QHpP xOnItnkiDkLyxhQ== Received-SPF: permerror client-ip=212.227.126.130; envelope-from=lvivier@redhat.com; helo=mout.kundenserver.de X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_FAIL=0.001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org On resume e1000e_vm_state_change() always calls e1000e_autoneg_resume() that sets link_down to false, and thus activates the link even if we have disabled it. The problem can be reproduced starting qemu in paused state (-S) and then set the link to down. When we resume the machine the link appears to be up. Reproducer: # qemu-system-x86_64 ... -device e1000e,netdev=netdev0,id=net0 -S {"execute": "qmp_capabilities" } {"execute": "set_link", "arguments": {"name": "net0", "up": false}} {"execute": "cont" } To fix the problem, merge the content of e1000e_vm_state_change() into e1000e_core_post_load() as e1000 does. Buglink: https://issues.redhat.com/browse/RHEL-21867 Suggested-by: Akihiko Odaki Signed-off-by: Laurent Vivier --- hw/net/e1000e_core.c | 50 +++----------------------------------------- hw/net/e1000e_core.h | 2 -- 2 files changed, 3 insertions(+), 49 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index e324c02dd589..95311fd60530 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -123,14 +123,6 @@ e1000e_intmgr_timer_resume(E1000IntrDelayTimer *timer) } } -static void -e1000e_intmgr_timer_pause(E1000IntrDelayTimer *timer) -{ - if (timer->running) { - timer_del(timer->timer); - } -} - static inline void e1000e_intrmgr_stop_timer(E1000IntrDelayTimer *timer) { @@ -398,24 +390,6 @@ e1000e_intrmgr_resume(E1000ECore *core) } } -static void -e1000e_intrmgr_pause(E1000ECore *core) -{ - int i; - - e1000e_intmgr_timer_pause(&core->radv); - e1000e_intmgr_timer_pause(&core->rdtr); - e1000e_intmgr_timer_pause(&core->raid); - e1000e_intmgr_timer_pause(&core->tidv); - e1000e_intmgr_timer_pause(&core->tadv); - - e1000e_intmgr_timer_pause(&core->itr); - - for (i = 0; i < E1000E_MSIX_VEC_NUM; i++) { - e1000e_intmgr_timer_pause(&core->eitr[i]); - } -} - static void e1000e_intrmgr_reset(E1000ECore *core) { @@ -3351,22 +3325,6 @@ e1000e_autoneg_resume(E1000ECore *core) } } -static void -e1000e_vm_state_change(void *opaque, bool running, RunState state) -{ - E1000ECore *core = opaque; - - if (running) { - trace_e1000e_vm_state_running(); - e1000e_intrmgr_resume(core); - e1000e_autoneg_resume(core); - } else { - trace_e1000e_vm_state_stopped(); - e1000e_autoneg_pause(core); - e1000e_intrmgr_pause(core); - } -} - void e1000e_core_pci_realize(E1000ECore *core, const uint16_t *eeprom_templ, @@ -3379,9 +3337,6 @@ e1000e_core_pci_realize(E1000ECore *core, e1000e_autoneg_timer, core); e1000e_intrmgr_pci_realize(core); - core->vmstate = - qemu_add_vm_change_state_handler(e1000e_vm_state_change, core); - for (i = 0; i < E1000E_NUM_QUEUES; i++) { net_tx_pkt_init(&core->tx[i].tx_pkt, E1000E_MAX_TX_FRAGS); } @@ -3405,8 +3360,6 @@ e1000e_core_pci_uninit(E1000ECore *core) e1000e_intrmgr_pci_unint(core); - qemu_del_vm_change_state_handler(core->vmstate); - for (i = 0; i < E1000E_NUM_QUEUES; i++) { net_tx_pkt_uninit(core->tx[i].tx_pkt); } @@ -3576,5 +3529,8 @@ e1000e_core_post_load(E1000ECore *core) */ nc->link_down = (core->mac[STATUS] & E1000_STATUS_LU) == 0; + e1000e_intrmgr_resume(core); + e1000e_autoneg_resume(core); + return 0; } diff --git a/hw/net/e1000e_core.h b/hw/net/e1000e_core.h index 66b025cc43f1..01510ca78b47 100644 --- a/hw/net/e1000e_core.h +++ b/hw/net/e1000e_core.h @@ -98,8 +98,6 @@ struct E1000Core { E1000IntrDelayTimer eitr[E1000E_MSIX_VEC_NUM]; - VMChangeStateEntry *vmstate; - uint32_t itr_guest_value; uint32_t eitr_guest_value[E1000E_MSIX_VEC_NUM];