From nobody Mon Feb 9 16:33:25 2026 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 9199E256C9A; Tue, 25 Feb 2025 06:29:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740464967; cv=none; b=a9Fo2hBdNv9p2+jzRvq+8KPNnmYHgolztqR6ApSwbWpWMegHjucerj9Q8jftC9APlgdcOVs707bj9LTSloV5hTOkswFb6GCYQjEojXqOGetYdyMx+N8Q+froo8JJyWlzMw/H8HlgAcAPKRfOyIeA0LQA/RnBE7qCop9vSaOoi24= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740464967; c=relaxed/simple; bh=pn5qt+qjSMOk2Lz6y1NpX3BN+oBw7D7B45eJPKSGXEg=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iTJN8znSylY0VRpgnx/KWduU/fL1Xgsau4mUKbRadVrpW9ieqxpHac4LV5GZJ3B2UW1P6j6/aYWOxsgL66IAw7QBRQ4QZHjZR3wOv9H8NF2bZ6ZyAvxtkfaLmUToOJNe/URESAw0UE1obeRZZsaj+yoYUjBvL8fmUI7LiK9kSOs= 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.187 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.194]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4Z26yb0LjyzdbB5; Tue, 25 Feb 2025 14:24:39 +0800 (CST) Received: from kwepemg500006.china.huawei.com (unknown [7.202.181.43]) by mail.maildlp.com (Postfix) with ESMTPS id E0B3C140203; Tue, 25 Feb 2025 14:29:22 +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:29:22 +0800 From: Longfang Liu To: , , , CC: , , , Subject: [PATCH v4 3/5] hisi_acc_vfio_pci: bugfix cache write-back issue Date: Tue, 25 Feb 2025 14:27:55 +0800 Message-ID: <20250225062757.19692-4-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: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemg500006.china.huawei.com (7.202.181.43) Content-Type: text/plain; charset="utf-8" At present, cache write-back is placed in the device data copy stage after stopping the device operation. Writing back to the cache at this stage will cause the data obtained by the cache to be written back to be empty. In order to ensure that the cache data is written back successfully, the data needs to be written back into the stop device stage. Fixes: b0eed085903e ("hisi_acc_vfio_pci: Add support for VFIO live migratio= n") Signed-off-by: Longfang Liu Reviewed-by: Shameer Kolothum --- drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/= pci/hisilicon/hisi_acc_vfio_pci.c index 235b584e7335..54c59c92df13 100644 --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c @@ -565,7 +565,6 @@ static int vf_qm_state_save(struct hisi_acc_vf_core_dev= ice *hisi_acc_vdev, { struct acc_vf_data *vf_data =3D &migf->vf_data; struct hisi_qm *vf_qm =3D &hisi_acc_vdev->vf_qm; - struct device *dev =3D &vf_qm->pdev->dev; int ret; =20 if (unlikely(qm_wait_dev_not_ready(vf_qm))) { @@ -579,12 +578,6 @@ static int vf_qm_state_save(struct hisi_acc_vf_core_de= vice *hisi_acc_vdev, vf_data->vf_qm_state =3D QM_READY; hisi_acc_vdev->vf_qm_state =3D vf_data->vf_qm_state; =20 - ret =3D vf_qm_cache_wb(vf_qm); - if (ret) { - dev_err(dev, "failed to writeback QM Cache!\n"); - return ret; - } - ret =3D vf_qm_read_data(vf_qm, vf_data); if (ret) return -EINVAL; @@ -1011,6 +1004,13 @@ static int hisi_acc_vf_stop_device(struct hisi_acc_v= f_core_device *hisi_acc_vdev dev_err(dev, "failed to check QM INT state!\n"); return ret; } + + ret =3D vf_qm_cache_wb(vf_qm); + if (ret) { + dev_err(dev, "failed to writeback QM cache!\n"); + return ret; + } + return 0; } =20 --=20 2.24.0