From nobody Mon Sep 15 07:38:23 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5E7FC3DA78 for ; Sat, 14 Jan 2023 09:31:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230139AbjANJbi (ORCPT ); Sat, 14 Jan 2023 04:31:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52386 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbjANJbG (ORCPT ); Sat, 14 Jan 2023 04:31:06 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09CBD6582 for ; Sat, 14 Jan 2023 01:29:23 -0800 (PST) Received: from kwepemm600005.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4NvCcv661kzJrP1; Sat, 14 Jan 2023 17:27:59 +0800 (CST) Received: from huawei.com (10.50.163.32) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Sat, 14 Jan 2023 17:29:19 +0800 From: Longfang Liu To: , , , CC: , , , Subject: [PATCH v6 5/5] vfio: update live migration device status Date: Sat, 14 Jan 2023 17:26:15 +0800 Message-ID: <20230114092615.51841-6-liulongfang@huawei.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20230114092615.51841-1-liulongfang@huawei.com> References: <20230114092615.51841-1-liulongfang@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600005.china.huawei.com (7.193.23.191) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" migration debugfs needs to perform debug operations based on the status of the current device. If the device is not loaded or has stopped, debugfs does not allow operations. so, after the live migration function is executed and the device is turned off, the device no longer needs to be accessed. At this time, the status of the device needs to be set to stop. Signed-off-by: Longfang Liu --- drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 3 +++ drivers/vfio/pci/mlx5/main.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/= pci/hisilicon/hisi_acc_vfio_pci.c index 96e2a021a956..bdb9043f88f1 100644 --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c @@ -1607,6 +1607,9 @@ static void hisi_acc_vfio_pci_close_device(struct vfi= o_device *core_vdev) struct hisi_acc_vf_core_device *hisi_acc_vdev =3D hisi_acc_get_vf_dev(cor= e_vdev); struct hisi_qm *vf_qm =3D &hisi_acc_vdev->vf_qm; =20 + if (core_vdev->mig_ops) + hisi_acc_vdev->mig_state =3D VFIO_DEVICE_STATE_STOP; + iounmap(vf_qm->io_base); vfio_pci_core_close_device(core_vdev); } diff --git a/drivers/vfio/pci/mlx5/main.c b/drivers/vfio/pci/mlx5/main.c index 031ac8cc215d..64b2fe58355a 100644 --- a/drivers/vfio/pci/mlx5/main.c +++ b/drivers/vfio/pci/mlx5/main.c @@ -1092,6 +1092,9 @@ static void mlx5vf_pci_close_device(struct vfio_devic= e *core_vdev) struct mlx5vf_pci_core_device *mvdev =3D container_of( core_vdev, struct mlx5vf_pci_core_device, core_device.vdev); =20 + if (mvdev->migrate_cap) + mvdev->mig_state =3D VFIO_DEVICE_STATE_STOP; + mlx5vf_cmd_close_migratable(mvdev); vfio_pci_core_close_device(core_vdev); } --=20 2.24.0