From patchwork Fri Aug 2 05:17:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akihiko Odaki X-Patchwork-Id: 1968131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=daynix-com.20230601.gappssmtp.com header.i=@daynix-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=C66AhT+H; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WZvKw12N4z1ybX for ; Fri, 2 Aug 2024 15:20:20 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZkhL-0006vy-RE; Fri, 02 Aug 2024 01:19:27 -0400 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 1sZkhK-0006qV-O6 for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:26 -0400 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZkhJ-0006zH-5p for qemu-devel@nongnu.org; Fri, 02 Aug 2024 01:19:26 -0400 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1fd90c2fc68so61387515ad.1 for ; Thu, 01 Aug 2024 22:19:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1722575964; x=1723180764; darn=nongnu.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=QvhT8BOO7ycm9PXUc+0g8ECZRNCUjwgD+8aN9b1a3cI=; b=C66AhT+HuiTGGvtth1hraTv8ag+EQldzAelktYLkr7NoZaR7xV3X8RshLpf3o0IGt0 0aiO56hjCovt/EILeAxdd30gdZ28O/ZLuafFyXdwyVeVm3gJS0a0BdkIcDALMUufHzCc uCkKhVmXGD4iju2v3m6FWeCBvTWu0I1LLAsFXbMAvuXXc7w9oh1dWSvqy/Axn8KT9Wri PhdAYI5vAw66N14LTtERTTn0ZMAd5j0htWgNK375HYzc/o5PSOlK4b4FhK3sOLFMG7o8 CNPTGtQ0yWJbk9EyVwJdoLSzfXflPURoarcT00qPI75DIgYaudK8SrJucoFE0C7XFN74 VM4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722575964; x=1723180764; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QvhT8BOO7ycm9PXUc+0g8ECZRNCUjwgD+8aN9b1a3cI=; b=XzFXiWxFDWrbUIGafaXGXvSdYt77hzIGCoPc+m3e3nQw2zA/zZR6/ae2BWtkmSY+iP cbtdxabUgRvO46kQydxCmT782DrHCUlloou02EATJCaJ9RubV+h14tgzlgITx/awZjVk EJ11Oakm9oL6Sm3ElHuimj7BqhC6co48wYvg3vdto5pCB0z/hxJyJybzsGDYRRDpY005 hpmqbtkxpr0xkFEqwikiLdSQr8kKsjsB7pz2BCyAQvYhQ6TWCdy/eV1fvqmXxt5OT0uo q7AML0Jo3LIQ/E83ERGkJpnj/6j0rmJRSbo17Rw5XepqjkJh77ItaH0ouQqA44AuAUA2 yRVA== X-Gm-Message-State: AOJu0YxOca+cXuaRBabafcDdeH6F9Q9R264DEYu1uLBiNPSnkb2IoZOu llb7G+/gqWjb1/hjhSlETr+K2UhtCl/8laDKlUEOGAcUhsvHUWSNTifLLFP6jwM= X-Google-Smtp-Source: AGHT+IGfatLAPXN+tl/yGTckKb1+Qt6L/Z89kMZ1QxC828hwl8mwfpNTAw3d9tTQ+xRihz/TG/iepg== X-Received: by 2002:a17:902:f551:b0:1fb:389b:1054 with SMTP id d9443c01a7336-1ff5745b7e6mr29754905ad.52.1722575964002; Thu, 01 Aug 2024 22:19:24 -0700 (PDT) Received: from localhost ([157.82.201.15]) by smtp.gmail.com with UTF8SMTPSA id d9443c01a7336-1ff625da1d5sm527955ad.218.2024.08.01.22.19.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Aug 2024 22:19:23 -0700 (PDT) From: Akihiko Odaki Date: Fri, 02 Aug 2024 14:17:59 +0900 Subject: [PATCH for-9.2 v11 09/11] pcie_sriov: Register VFs after migration MIME-Version: 1.0 Message-Id: <20240802-reuse-v11-9-fb83bb8c19fb@daynix.com> References: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> In-Reply-To: <20240802-reuse-v11-0-fb83bb8c19fb@daynix.com> To: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S. Tsirkin" , Marcel Apfelbaum , Alex Williamson , =?utf-8?q?C=C3=A9dric_Le_Goa?= =?utf-8?q?ter?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen , Markus Armbruster Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.14-dev-fd6e3 Received-SPF: none client-ip=2607:f8b0:4864:20::632; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x632.google.com 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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org pcie_sriov doesn't have code to restore its state after migration, but igb, which uses pcie_sriov, naively claimed its migration capability. Add code to register VFs after migration and fix igb migration. Fixes: 3a977deebe6b ("Intrdocue igb device emulation") Signed-off-by: Akihiko Odaki --- include/hw/pci/pcie_sriov.h | 2 ++ hw/pci/pci.c | 7 +++++++ hw/pci/pcie_sriov.c | 7 +++++++ 3 files changed, 16 insertions(+) diff --git a/include/hw/pci/pcie_sriov.h b/include/hw/pci/pcie_sriov.h index 5148c5b77dd1..c5d2d318d330 100644 --- a/include/hw/pci/pcie_sriov.h +++ b/include/hw/pci/pcie_sriov.h @@ -57,6 +57,8 @@ void pcie_sriov_pf_add_sup_pgsize(PCIDevice *dev, uint16_t opt_sup_pgsize); void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, uint32_t val, int len); +void pcie_sriov_pf_post_load(PCIDevice *dev); + /* Reset SR/IOV */ void pcie_sriov_pf_reset(PCIDevice *dev); diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 5c0050e1786a..4c7be5295110 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -733,10 +733,17 @@ static bool migrate_is_not_pcie(void *opaque, int version_id) return !pci_is_express((PCIDevice *)opaque); } +static int pci_post_load(void *opaque, int version_id) +{ + pcie_sriov_pf_post_load(opaque); + return 0; +} + const VMStateDescription vmstate_pci_device = { .name = "PCIDevice", .version_id = 2, .minimum_version_id = 1, + .post_load = pci_post_load, .fields = (const VMStateField[]) { VMSTATE_INT32_POSITIVE_LE(version_id, PCIDevice), VMSTATE_BUFFER_UNSAFE_INFO_TEST(config, PCIDevice, diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c index fae6acea4acb..56523ab4e833 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -252,6 +252,13 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t address, } } +void pcie_sriov_pf_post_load(PCIDevice *dev) +{ + if (dev->exp.sriov_cap) { + register_vfs(dev); + } +} + /* Reset SR/IOV */ void pcie_sriov_pf_reset(PCIDevice *dev)