From nobody Sun Nov 24 13:06:41 2024 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (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 F091F1AA79A; Tue, 12 Nov 2024 07:35:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731396907; cv=none; b=l5AqGeOdwlajkdYP6Vx6Wuyx9PLfjFJv7FQiucpJPBtNeEO/10RKomVI/8M1h50ECsM/TDMXTqLoBR06iidNi4dYu/GzLtzuTYWilINTYK1Qk4ZU4dSJVtNpQ6/lq0Jr2DgTvDcAjinWj5UZuj3WFxvkgZysPRLsLXov069tSyM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731396907; c=relaxed/simple; bh=89zysdWO9QHwVicNvFBVQwWlrUkig269PlzLhTNYCVU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O0bpVNiBpqHkkmWdvsu1zjF4CxO08vjVe6dtaNg0WeFI5z6eMbq9e+iooJTf17SKwRVuNlEv2YA8Osr6ss5pRzgXkjdoca7qz7J+nQe7i/WxrdaOmKiF3DgrjwQ3xHx/5ZBtv7T5oXC9zUkfThXOxfkk3x5lIR0QF83yAVsZg7g= 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.188 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.162.254]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XndS53k8QzpZNW; Tue, 12 Nov 2024 15:33:09 +0800 (CST) Received: from dggemv704-chm.china.huawei.com (unknown [10.3.19.47]) by mail.maildlp.com (Postfix) with ESMTPS id 77D49180104; Tue, 12 Nov 2024 15:35:02 +0800 (CST) Received: from kwepemn100017.china.huawei.com (7.202.194.122) by dggemv704-chm.china.huawei.com (10.3.19.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Tue, 12 Nov 2024 15:35:02 +0800 Received: from huawei.com (10.50.165.33) by kwepemn100017.china.huawei.com (7.202.194.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Tue, 12 Nov 2024 15:35:01 +0800 From: Longfang Liu To: , , , CC: , , , Subject: [PATCH v15 2/4] hisi_acc_vfio_pci: create subfunction for data reading Date: Tue, 12 Nov 2024 15:33:20 +0800 Message-ID: <20241112073322.54550-3-liulongfang@huawei.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20241112073322.54550-1-liulongfang@huawei.com> References: <20241112073322.54550-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 kwepemn100017.china.huawei.com (7.202.194.122) Content-Type: text/plain; charset="utf-8" This patch generates the code for the operation of reading data from the device into a sub-function. Then, it can be called during the device status data saving phase of the live migration process and the device status data reading function in debugfs. Thereby reducing the redundant code of the driver. Signed-off-by: Longfang Liu Reviewed-by: Shameer Kolothum --- .../vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 54 +++++++++++-------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c b/drivers/vfio/= pci/hisilicon/hisi_acc_vfio_pci.c index 45351be8e270..a8c53952d82e 100644 --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c @@ -486,31 +486,11 @@ static int vf_qm_load_data(struct hisi_acc_vf_core_de= vice *hisi_acc_vdev, return 0; } =20 -static int vf_qm_state_save(struct hisi_acc_vf_core_device *hisi_acc_vdev, - struct hisi_acc_vf_migration_file *migf) +static int vf_qm_read_data(struct hisi_qm *vf_qm, struct acc_vf_data *vf_d= ata) { - 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))) { - /* Update state and return with match data */ - vf_data->vf_qm_state =3D QM_NOT_READY; - hisi_acc_vdev->vf_qm_state =3D vf_data->vf_qm_state; - migf->total_length =3D QM_MATCH_SIZE; - return 0; - } - - vf_data->vf_qm_state =3D QM_READY; - hisi_acc_vdev->vf_qm_state =3D vf_data->vf_qm_state; - - ret =3D vf_qm_cache_wb(vf_qm); - if (ret) { - dev_err(dev, "failed to writeback QM Cache!\n"); - return ret; - } - ret =3D qm_get_regs(vf_qm, vf_data); if (ret) return -EINVAL; @@ -536,6 +516,38 @@ static int vf_qm_state_save(struct hisi_acc_vf_core_de= vice *hisi_acc_vdev, return -EINVAL; } =20 + return 0; +} + +static int vf_qm_state_save(struct hisi_acc_vf_core_device *hisi_acc_vdev, + struct hisi_acc_vf_migration_file *migf) +{ + 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; + + if (unlikely(qm_wait_dev_not_ready(vf_qm))) { + /* Update state and return with match data */ + vf_data->vf_qm_state =3D QM_NOT_READY; + hisi_acc_vdev->vf_qm_state =3D vf_data->vf_qm_state; + migf->total_length =3D QM_MATCH_SIZE; + return 0; + } + + vf_data->vf_qm_state =3D QM_READY; + hisi_acc_vdev->vf_qm_state =3D vf_data->vf_qm_state; + + 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; + migf->total_length =3D sizeof(struct acc_vf_data); return 0; } --=20 2.24.0