From nobody Thu Nov 14 18:11:58 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1708432028; cv=none; d=zohomail.com; s=zohoarc; b=GOYbrP34WtYESepRJlpmyd/NVDZklr8OAnMioTretfQ169ppsif8Ap0s0LjuwvvPrrtZjGy5YG8qH7OAsMNTPvWJBgLwaufEuXZuRQpCkJK+/h2n7C8cghqrYjYPbU9ylCUbivPbgAfgjXj3rFTxOMqV6y3xh9w6aJQIuDEoxG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708432028; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nx+YxyPM604jNXU1B1YXm0e5pQ0GXOm984QmGrq4zA4=; b=gFb+rBdT5tm4GlS1AbJVtWtgbCh7mqMMYa7BLAllXVhWpGhXa2x0LTnUtjGaeXw5NnLB+QTBjO6L125A2et614BBetvlGWtw08HHvQg+1U/RXvaHYlQV18YRgeqnKkG5fzIKe2gfyUMVc91/uGwswfWfdORb/OtTLv05yEpK+pA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708432028467205.06245619451352; Tue, 20 Feb 2024 04:27:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcPC2-0005Rv-Bv; Tue, 20 Feb 2024 07:25:50 -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 1rcPBv-00051M-1K for qemu-devel@nongnu.org; Tue, 20 Feb 2024 07:25:44 -0500 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rcPBr-0006DB-9I for qemu-devel@nongnu.org; Tue, 20 Feb 2024 07:25:42 -0500 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1d7232dcb3eso29456845ad.2 for ; Tue, 20 Feb 2024 04:25:37 -0800 (PST) Received: from localhost ([157.82.203.206]) by smtp.gmail.com with UTF8SMTPSA id a19-20020a170902ee9300b001dbb0348733sm4189838pld.67.2024.02.20.04.25.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 20 Feb 2024 04:25:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1708431937; x=1709036737; 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=nx+YxyPM604jNXU1B1YXm0e5pQ0GXOm984QmGrq4zA4=; b=vrDGGXjhM+D8r8XfT0gOkLmM41n2DfCBo9r+2/vu5373ZQpr9V1VZSCf+6eCPzR8TI 6aBDG6D+qdap+dDdBkhvzRm9CDoJ2pVBDixdfY08tDi4eG7ROaXBO+ipmDJeC9jys2L0 1vy3eNcrWEeutYXEGIeghviqki1IYT9SavlvoVfprG1eouqtYIXPAzoc4VdI07BvljaW ZTUqj70yUQV7i8UGnDU8rOGd7etfYXHGc8CaEZcuECh49Y7kwjW6pHLHnVJociEbNVCT nzjdkIR9CLIXHI3xsnwrVIWAvV4CKQ58jTUt8ILIKNxq6oWbM4xvA+ya16WKT4/jvc0n zZmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708431937; x=1709036737; 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=nx+YxyPM604jNXU1B1YXm0e5pQ0GXOm984QmGrq4zA4=; b=wZ2m4l4/0HOifxjfU8hNVbvlIgkfSgB4/6QWISpyTCII11pqlexb6ySe1EH0oDF1hs 35Heu6iHV9+YCoxj2tlZPra6ZTGnQUIgRD0SvHRUis2on/ikp7kJ5nYkY/ibvs1I7xye vA0XrelVrGPE6VnU5ny4WjDGmxcvS0OwqqdA+QEMm9hgO0budVYfvstazWexwHWDsos5 yu2ZpFEpcJ7FgA973BUKjfw3iVGkjdEEFIl6AcFxPnzWX1/y5ZOnyV1E47AvxDAYABm2 mxJXuziY0abc0xV19yiozQeM17PCbXI7/EA/ZY6i/bij1O38Ft9HZe0hijxV0vIIrbu8 JEPg== X-Gm-Message-State: AOJu0YwyTODbmpX0azGvV9AAVQeHjfzIFXGDXhXDASOupzEksuvwsmJV RqSMYTWcpOV35VD6OUgU8Jk61l7XNtXuR2dqRkWpCRxTQAzxGvNC8AlBcasYvjQ= X-Google-Smtp-Source: AGHT+IHSUBJqKNlHfy15uOM+naw0VZ4F7WiW5P5MZkC93YvKH+ccoZFAFP5IiNrar1vkH3oNmebOiQ== X-Received: by 2002:a17:902:dac6:b0:1db:916e:d77a with SMTP id q6-20020a170902dac600b001db916ed77amr16352732plx.2.1708431936816; Tue, 20 Feb 2024 04:25:36 -0800 (PST) From: Akihiko Odaki Date: Tue, 20 Feb 2024 21:24:46 +0900 Subject: [PATCH v6 11/15] pcie_sriov: Register VFs after migration MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240220-reuse-v6-11-2e42a28b0cf2@daynix.com> References: <20240220-reuse-v6-0-2e42a28b0cf2@daynix.com> In-Reply-To: <20240220-reuse-v6-0-2e42a28b0cf2@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_Goater?= , Paolo Bonzini , =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Eduardo Habkost , Sriram Yagnaraman , Jason Wang , Keith Busch , Klaus Jensen Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org, Akihiko Odaki X-Mailer: b4 0.12.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::631; envelope-from=akihiko.odaki@daynix.com; helo=mail-pl1-x631.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, T_SCC_BODY_TEXT_LINE=-0.01 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @daynix-com.20230601.gappssmtp.com) X-ZM-MESSAGEID: 1708432029887100002 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 793d03c5f12e..d576a8c6be19 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); =20 +void pcie_sriov_pf_post_load(PCIDevice *dev); + /* Reset SR/IOV */ void pcie_sriov_pf_reset(PCIDevice *dev); =20 diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 750c2ba696d1..54b375da2d26 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -733,10 +733,17 @@ static bool migrate_is_not_pcie(void *opaque, int ver= sion_id) return !pci_is_express((PCIDevice *)opaque); } =20 +static int pci_post_load(void *opaque, int version_id) +{ + pcie_sriov_pf_post_load(opaque); + return 0; +} + const VMStateDescription vmstate_pci_device =3D { .name =3D "PCIDevice", .version_id =3D 2, .minimum_version_id =3D 1, + .post_load =3D pci_post_load, .fields =3D (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 fb48c1a18c9a..09a53ed30027 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -239,6 +239,13 @@ void pcie_sriov_config_write(PCIDevice *dev, uint32_t = address, } } =20 +void pcie_sriov_pf_post_load(PCIDevice *dev) +{ + if (dev->exp.sriov_cap) { + register_vfs(dev); + } +} + =20 /* Reset SR/IOV */ void pcie_sriov_pf_reset(PCIDevice *dev) --=20 2.43.1