From nobody Mon Feb 9 14:34:10 2026 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A403E25744F; Tue, 25 Feb 2025 06:30:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740465029; cv=none; b=C7uNkUllEdynnGUgS/SO+ZLO+BREQpYIoEYQ+KyBrCDAtpqOAaqx3c/Po/uFHDbOW8AVMAXYe98WIfKO8woWA70UFuYwKTMXDyYkO3EYor3hSG17tr0+Fj0eyoRVyITspYP1o18lRT2uNRR9FpL8HGG9/eYpRkc1mgEuQvgPIsM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740465029; c=relaxed/simple; bh=LYJLg5Jyt5Ks2wCf8HwrPZgFvnbCRrQVia1PUKQ5eZM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iZPcvcmxlKRMItgudQvMfqIH/ThMmkkeEmUlRuCK+vdk5BwjoFeHSNGaDleMD9L8gIo18wT5TzoXiF3QrKTuWxiYHCnrDyPAeXfFOS4REjIwLGFncfG7GDM3njPqBKzo7DvANkuDDo8IGZfJnmKCSx9wSVjBZ9rGIJ4ghMC7hyg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.189 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4Z271h4DqKz9w89; Tue, 25 Feb 2025 14:27:20 +0800 (CST) Received: from kwepemg500006.china.huawei.com (unknown [7.202.181.43]) by mail.maildlp.com (Postfix) with ESMTPS id E019F1402CA; Tue, 25 Feb 2025 14:30:24 +0800 (CST) Received: from huawei.com (10.50.165.33) by kwepemg500006.china.huawei.com (7.202.181.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 25 Feb 2025 14:30:24 +0800 From: Longfang Liu To: , , , CC: , , , Subject: [PATCH v4 5/5] hisi_acc_vfio_pci: bugfix live migration function without VF device driver Date: Tue, 25 Feb 2025 14:27:57 +0800 Message-ID: <20250225062757.19692-6-liulongfang@huawei.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20250225062757.19692-1-liulongfang@huawei.com> References: <20250225062757.19692-1-liulongfang@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemg500006.china.huawei.com (7.202.181.43) Content-Type: text/plain; charset="utf-8" If the driver of the VF device is not loaded in the Guest OS, then perform device data migration. The migrated data address will be NULL. The live migration recovery operation on the destination side will access a null address value, which will cause access errors. Therefore, live migration of VMs without added VF device drivers does not require device data migration. In addition, when the queue address data obtained by the destination is empty, device queue recovery processing will not be performed. Fixes: b0eed085903e ("hisi_acc_vfio_pci: Add support for VFIO live migratio= n") Signed-off-by: Longfang Liu --- drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/= pci/hisilicon/hisi_acc_vfio_pci.c index 3f0bcd855839..77872fc4cd34 100644 --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c @@ -440,6 +440,7 @@ static int vf_qm_get_match_data(struct hisi_acc_vf_core= _device *hisi_acc_vdev, struct acc_vf_data *vf_data) { struct hisi_qm *pf_qm =3D hisi_acc_vdev->pf_qm; + struct hisi_qm *vf_qm =3D &hisi_acc_vdev->vf_qm; struct device *dev =3D &pf_qm->pdev->dev; int vf_id =3D hisi_acc_vdev->vf_id; int ret; @@ -466,6 +467,13 @@ static int vf_qm_get_match_data(struct hisi_acc_vf_cor= e_device *hisi_acc_vdev, return ret; } =20 + /* Get VF driver insmod state */ + ret =3D qm_read_regs(vf_qm, QM_VF_STATE, &vf_data->vf_qm_state, 1); + if (ret) { + dev_err(dev, "failed to read QM_VF_STATE!\n"); + return ret; + } + return 0; } =20 @@ -505,6 +513,12 @@ static int vf_qm_load_data(struct hisi_acc_vf_core_dev= ice *hisi_acc_vdev, qm->qp_base =3D vf_data->qp_base; qm->qp_num =3D vf_data->qp_num; =20 + if (!vf_data->eqe_dma || !vf_data->aeqe_dma || + !vf_data->sqc_dma || !vf_data->cqc_dma) { + dev_err(dev, "resume dma addr is NULL!\n"); + return -EINVAL; + } + ret =3D qm_set_regs(qm, vf_data); if (ret) { dev_err(dev, "set VF regs failed\n"); @@ -727,6 +741,9 @@ static int hisi_acc_vf_load_state(struct hisi_acc_vf_co= re_device *hisi_acc_vdev) struct hisi_acc_vf_migration_file *migf =3D hisi_acc_vdev->resuming_migf; int ret; =20 + if (hisi_acc_vdev->vf_qm_state !=3D QM_READY) + return 0; + /* Recover data to VF */ ret =3D vf_qm_load_data(hisi_acc_vdev, migf); if (ret) { @@ -1530,6 +1547,7 @@ static int hisi_acc_vfio_pci_migrn_init_dev(struct vf= io_device *core_vdev) hisi_acc_vdev->vf_id =3D pci_iov_vf_id(pdev) + 1; hisi_acc_vdev->pf_qm =3D pf_qm; hisi_acc_vdev->vf_dev =3D pdev; + hisi_acc_vdev->vf_qm_state =3D QM_NOT_READY; mutex_init(&hisi_acc_vdev->state_mutex); mutex_init(&hisi_acc_vdev->open_mutex); =20 --=20 2.24.0