From mboxrd@z Thu Jan 1 00:00:00 1970 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 5467EC52D7C for ; Fri, 23 Aug 2024 05:03:02 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1shMQz-0007wN-KD; Fri, 23 Aug 2024 01:02:01 -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 1shMQY-0007Mv-4b for qemu-devel@nongnu.org; Fri, 23 Aug 2024 01:01:34 -0400 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1shMQV-0008W7-5q for qemu-devel@nongnu.org; Fri, 23 Aug 2024 01:01:33 -0400 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-7142448aaf9so1135462b3a.1 for ; Thu, 22 Aug 2024 22:01:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daynix-com.20230601.gappssmtp.com; s=20230601; t=1724389288; x=1724994088; 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=FImpPBK9Cgx1Gf66dh6YNz4HB2eDE7e40q5spQfStSw=; b=N8jyXcimXzl0pKzMN5Rok9iV7jGDV2kH3iNGa4eHSo79YmWCqQqLmLSgJjQjbzJqDX MJlfsVIPwffdYrX6nuA4OqmIW+QdZi//dmMQXQ52kveFYOvQp0RxneF6KDx6W6RlFvCJ EYwt+NDlzplK2H1WQzSiIeclUbCVXDdEDOXqrLuG2t78wo+xpGbU0005rZDfGrdnHkbG 7hS1vP8Kc6NxR4SvbxggawPdlKI9k5wbmg1+ur9HhnLEGNTWsm9WKJGfw2hf9lyAG9Yj EpsiZFhTkjPiqcFD0VDoGB3n6zip2uhf7dAezsLxbajoX6bvoMk3+vUQp4bbKpjgADB4 RXGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724389288; x=1724994088; 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=FImpPBK9Cgx1Gf66dh6YNz4HB2eDE7e40q5spQfStSw=; b=trTZin/TPFNyD54NbfZosl0+GGxP4F2OmReAt9GF7ad6HnKrVU/0dj/FHBb4duXDxS YKbm3+zW1W+kgSIe4kwv4lZ4eHgN2MklyP2ZGyC2Me9TcCHa80w3oJjW5R9oqGbSX97k uvSrMZo6PedTQoTGRdYcuR8yMncuAgjYnQ+q1hPePRbxhbzctvD0ENRBPyZLktdxmom+ q03zLPbH5GoNL03JNx/biUTuDW37hYiKws+h1+ysgCtoqCk7dDXrppGnjRE44+/wvyD3 ne6tDl9KrIyFRMta+PFfJaPZO/Iz1aFuqOkVcUV8jYKeEXz8YhM5yimnpHVBFFGRMIAq KZSA== X-Gm-Message-State: AOJu0YxWnZHuuPrmtW6EhOmk/MNr5CsfK3C1N9ClZFaUqH/4uYoLrbNH 6qXaWlVYguCbqxJG96932HqYc8ztWHbX6A41s+JhXJ6Kgp16nuVVLyf67KlHWbQ= X-Google-Smtp-Source: AGHT+IGgfg7PkX36U96p/bZXkPG9drSHrZF6ntBikbxEALkrMo8W186sZVnKtztmv6KA6AT7ZUc5Ew== X-Received: by 2002:a05:6a00:81c3:b0:714:2922:7c6d with SMTP id d2e1a72fcca58-714317d0c1amr7222104b3a.12.1724389288553; Thu, 22 Aug 2024 22:01:28 -0700 (PDT) Received: from localhost ([157.82.207.23]) by smtp.gmail.com with UTF8SMTPSA id d2e1a72fcca58-7143423136esm2196925b3a.7.2024.08.22.22.01.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 22 Aug 2024 22:01:28 -0700 (PDT) From: Akihiko Odaki Date: Fri, 23 Aug 2024 14:00:46 +0900 Subject: [PATCH for-9.2 v15 09/11] pcie_sriov: Register VFs after migration MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240823-reuse-v15-9-eddcb960e289@daynix.com> References: <20240823-reuse-v15-0-eddcb960e289@daynix.com> In-Reply-To: <20240823-reuse-v15-0-eddcb960e289@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 , 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::42b; envelope-from=akihiko.odaki@daynix.com; helo=mail-pf1-x42b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.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 47028e150eac..a1cb1214af27 100644 --- a/hw/pci/pcie_sriov.c +++ b/hw/pci/pcie_sriov.c @@ -242,6 +242,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) -- 2.46.0