From nobody Sun Nov 24 11:26:37 2024 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (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 B653B2E400; Wed, 6 Nov 2024 10:05:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730887552; cv=none; b=Goc0Yglk9vTy5E5Nw3YrzKDc3Ww5AU5TQOIp51P2X8sUPoH6NVUXl3urTqwqQipQptu2f5IrNL6hsQRc9PB1PkCQADMCjLbqJwMvLf50UW5hbK7N+qkhrQnXB1rroxRH8TbAH1ts2mGY6lw4kFS/V/tVX47YeM2h3ENFtqsQ2MU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730887552; c=relaxed/simple; bh=89zysdWO9QHwVicNvFBVQwWlrUkig269PlzLhTNYCVU=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iku4eW785jDAarpwlcjlQ3YLcUWNbPxXGZna52ot5aptxNLALWVKhSZh2peDIQgDtfx2xG7moZMPgOFRjmj8sojMClFwXgrYLzW6RNfD/Si9l+BDfGo4H9Yde0rzWtNRiUHY15Cq2zQUB663GIg6Tmnl+ImZC8aIHZPxXl7SdJA= 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.190 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 szxga04-in.huawei.com (SkyGuard) with ESMTP id 4Xk1571cVPz20smQ; Wed, 6 Nov 2024 18:04:11 +0800 (CST) Received: from dggemv703-chm.china.huawei.com (unknown [10.3.19.46]) by mail.maildlp.com (Postfix) with ESMTPS id 24D9B1A0188; Wed, 6 Nov 2024 18:05:18 +0800 (CST) Received: from kwepemn100017.china.huawei.com (7.202.194.122) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Wed, 6 Nov 2024 18:05:17 +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; Wed, 6 Nov 2024 18:05:17 +0800 From: Longfang Liu To: , , , CC: , , , Subject: [PATCH v13 2/4] hisi_acc_vfio_pci: create subfunction for data reading Date: Wed, 6 Nov 2024 18:03:41 +0800 Message-ID: <20241106100343.21593-3-liulongfang@huawei.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20241106100343.21593-1-liulongfang@huawei.com> References: <20241106100343.21593-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 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