From nobody Fri Dec 19 03:16:11 2025 Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (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 09E3C1FE462; Thu, 13 Mar 2025 07:21:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741850512; cv=none; b=fJCELSXR04lhabISWCN9kLqxvSjuhORaR5h/SoVcvVVXfsc1KhKiGEZFJxsMlq/15HPYfQ0dLXmkOAq5rtiPDpP44BW/g2+KDkd5SdAVin+JmdsmiTaNuzMP1EiDzw9Iv7gTKvhhdd5qT5jrVAbPTJX5805AOT7dRqde4vk0E/g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1741850512; c=relaxed/simple; bh=3IozYO/eR/kQuw7+sST29tdLq1X0HD/pbb+i53spYM0=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f51TJsNNKYhYOuVk36q+CrGX1heKqrsZKeMvCNinHAOkmbTEkWAP77w0lKvK1/7+cBICnv4n8EfjSZlHwLajO1xyxi6lVWd8FEax+PNzfgb+ThaaiKkkzOd+Jgs6UyCgyXcN42yZaIcEXxXYDb3yHr92FAZy5bt4bw51lAfcCHk= 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.191 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.163.17]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4ZCzR91NJJz1R6XK; Thu, 13 Mar 2025 15:20:05 +0800 (CST) Received: from kwepemg500006.china.huawei.com (unknown [7.202.181.43]) by mail.maildlp.com (Postfix) with ESMTPS id B27CE1A0188; Thu, 13 Mar 2025 15:21:46 +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; Thu, 13 Mar 2025 15:21:46 +0800 From: Longfang Liu To: , , , CC: , , , Subject: [PATCH v5 3/5] hisi_acc_vfio_pci: bugfix cache write-back issue Date: Thu, 13 Mar 2025 15:20:08 +0800 Message-ID: <20250313072010.57199-4-liulongfang@huawei.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20250313072010.57199-1-liulongfang@huawei.com> References: <20250313072010.57199-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" 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 80217aea5475..d96446f499ed 100644 --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c @@ -566,7 +566,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))) { @@ -580,12 +579,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; @@ -1012,6 +1005,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