Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp283547lqd; Wed, 24 Apr 2024 02:04:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXKUQMox5KzR+8IMroCZ6F02LxzEIoxrEcFa/Fs+N3ty+tVm6pl1PhapxLV3Bh/I22d/ZW87fiodINvc6ujlJJPUKs4nfeXlFSlcW7m4A== X-Google-Smtp-Source: AGHT+IGX0T4HLHkGRGHHKugXb54SkgLhTvr+RgT01P1OM2LF3y2giLM/w+rvyxshj9IPOgEWitJ4 X-Received: by 2002:a05:6122:7cd:b0:4d3:34b1:7211 with SMTP id l13-20020a05612207cd00b004d334b17211mr2110464vkr.3.1713949456931; Wed, 24 Apr 2024 02:04:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713949456; cv=pass; d=google.com; s=arc-20160816; b=BBLm6spcf0rOyF31ud1/pHxInY7dZvj5tHMqc19YEWZGtcRrma0i8gD3bQAyf5kDlI 0Ej8OKgFPQTRnHXxTl9zknTLR/sPcr2hPw9O+KLC9CnEmbOzkotTIgSEJt5WAmlMsBDI AEBq3ZhBY+XYKNz/fTm0K/x6fdWzI6avYxBTZUKHI0QPZtO82eAnuu8KYU+p/qs7ltwK u68ML/SH2Gn+tFIp/iQBkgBxjsikPrOu81GsHkHcuoEUYfrO1SMdR4dUEEt2pbuUHqej re2vUcRr1xQ+5AM2B6SrmEwn6GF84woOa/flM7ZihnlJ/NfGB93dnXwVf3JGsZd9LTNI MW0w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Gb7j2tAhFIKBx28LIb8rpJlKJu0LKIoFLq28kQIba/M=; fh=lW6MHi1ma+bdiE1he+iHyx9lPKntUb1s0946rN3rfJM=; b=wKHHsbuW1WPw+D/IhsMxgJz3RaUXQjRx0b64AVXYyFsT3stsmGVI9kG7EY4w0RVqRL jjiRo6XgQV+ftFpHeCL74JaquGDsVauOVznLBS6LJ80UdJ30JPGG6l+o8TbQkELJEMG4 K9HxDI3rvDyNEru9r8PhWXUiEmtFdv2MquNf09JCx0I9c2jeHOAsReQmK7QnfwAYS/OZ s/x7TPdXSmRz5AyKSPu1xm/UfGyRjOzTlgHPU1VX61QaTyFwZ9cGC9SRJBH3gBfof/8C aNybc+sIRw0wSkNs41O7OdXfpeW8qeiQCyE1u+2iJzUssrQbpS42GSuzPKJMOKaNr96a jKYA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-156590-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156590-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y20-20020a05620a09d400b00790667bbfbesi9155451qky.493.2024.04.24.02.04.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 02:04:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-156590-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-156590-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-156590-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A49991C23169 for ; Wed, 24 Apr 2024 09:04:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 41D77158D98; Wed, 24 Apr 2024 09:04:09 +0000 (UTC) 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 EC73E158D7D; Wed, 24 Apr 2024 09:04:02 +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=1713949446; cv=none; b=rf4dlvYuz/j7a5dUZi4TTbFaTXcYhaE11db8NSL3hbqsVGrO6UMZoB6c3d19TM4prK4Run7l4MnDYlYbvY63uaidyAtgtj8JS/1IZuLXvowiwkdYTiFv9syQZDBiK6g94WJMEK2izSF0sBFJwVp7tDGjyTVGqB0t8wr8dfSXDrE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713949446; c=relaxed/simple; bh=8brYhM2FfPKIlVI/StWeG/lz5kWQo4DD8rJE5sLABAw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=sXyBuMfzwXPodTX3VNyXngKfzOcUBpOSW8hnU/rm76IDQV4RR11kn0ptTlZgwlZw1rDYjD+JLN+smK5BZ9UIYGO4cM9COFc250wO0FUE3Vi3GoirLbP5C1SZIYh5iznenxnyE5/luP/rAYjy2N9CSiOraxuyQXsR15XtO8tmydc= 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.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4VPY0p13tbzcb2F; Wed, 24 Apr 2024 17:02:50 +0800 (CST) Received: from kwepemm600005.china.huawei.com (unknown [7.193.23.191]) by mail.maildlp.com (Postfix) with ESMTPS id B03D314040D; Wed, 24 Apr 2024 17:03:54 +0800 (CST) Received: from huawei.com (10.50.165.33) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 24 Apr 2024 17:03:54 +0800 From: Longfang Liu To: , , , CC: , , , Subject: [PATCH v5 3/5] hisi_acc_vfio_pci: create subfunction for data reading Date: Wed, 24 Apr 2024 16:57:19 +0800 Message-ID: <20240424085721.12760-4-liulongfang@huawei.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20240424085721.12760-1-liulongfang@huawei.com> References: <20240424085721.12760-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: 8bit Content-Type: text/plain X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600005.china.huawei.com (7.193.23.191) During the live migration process. It needs to obtain various status data of drivers and devices. In order to facilitate calling it in the debugfs function. For all operations that read data from device registers, the driver creates a subfunction. Also fixed the location of address data. Signed-off-by: Longfang Liu --- .../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 0c7e31076ff4..bf358ba94b5d 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_device *hisi_acc_vdev, return 0; } -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_data) { - struct acc_vf_data *vf_data = &migf->vf_data; - struct hisi_qm *vf_qm = &hisi_acc_vdev->vf_qm; struct device *dev = &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 = QM_NOT_READY; - hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state; - migf->total_length = QM_MATCH_SIZE; - return 0; - } - - vf_data->vf_qm_state = QM_READY; - hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state; - - ret = vf_qm_cache_wb(vf_qm); - if (ret) { - dev_err(dev, "failed to writeback QM Cache!\n"); - return ret; - } - ret = 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_device *hisi_acc_vdev, return -EINVAL; } + 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 = &migf->vf_data; + struct hisi_qm *vf_qm = &hisi_acc_vdev->vf_qm; + struct device *dev = &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 = QM_NOT_READY; + hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state; + migf->total_length = QM_MATCH_SIZE; + return 0; + } + + vf_data->vf_qm_state = QM_READY; + hisi_acc_vdev->vf_qm_state = vf_data->vf_qm_state; + + ret = vf_qm_cache_wb(vf_qm); + if (ret) { + dev_err(dev, "failed to writeback QM Cache!\n"); + return ret; + } + + ret = vf_qm_read_data(vf_qm, vf_data); + if (ret) + return -EINVAL; + migf->total_length = sizeof(struct acc_vf_data); return 0; } -- 2.24.0