Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1113189lqd; Thu, 25 Apr 2024 06:31:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWO/eWpr3Qsf6dSXNdTE10HkmnbGNy0hQHaS4lhqmXxEsQJG3iUep8T6mMX7ZRCMD5qfplVt0BJMcDw1N8vp64XO8YYwdFdsRviFwkJjQ== X-Google-Smtp-Source: AGHT+IGRe/utWJsUWBcJ8UNcKabWqxPX1+G4e4XIOdbnHp85MMMcpbPAgiyzP+recEkepsnXHpP+ X-Received: by 2002:a17:906:c28f:b0:a55:b487:5676 with SMTP id r15-20020a170906c28f00b00a55b4875676mr4105867ejz.72.1714051862577; Thu, 25 Apr 2024 06:31:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714051862; cv=pass; d=google.com; s=arc-20160816; b=p505l/ntzXGt/MVCJ5ph4VUF9qDuIiX7YHxfBr45AFLt0qns2EdeETmagnAjT2+GLw p/zqsF5k6dkhRYqBb8HqyKhCSZD811LEDpCSgoGGLlX9av1+65qDe5N2NZvavBmhSSQ0 MffWKJ3yKqMcKoFMR/o0VL9n0+r3peb9UJ/qrmjRVxwbq2EhuzOJyjdDUWcMZCoqeCLk K9jElYABPu9VvbvV9AmzxJ9R+DFc+x1X1IkDo8Arq77vsxlNMqbdhuFUqehnJh4rQZK7 li2fbpLNd5i0K8hF73wk0+HBIgU4hZ3SFAIq4zC8gt1LTHOLKmqf6HiVhMCTMwsmvSRF bT1g== 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=PCVYdEFCM/cECDrkpGn2JPe9kYExBwYXtQo7Vxgh97n3EYxGQisL2OvwboScQ4pgsQ sZvqTFKeN8lhleephGSaG6ITqb3DiGsW7sgSbRt3DpuGaMXPeOCfgObGfTNQrySeR9N0 y3UzSQx3xLhj9IF0M4q4HNwfPmi759Y2znLiq8MmU+iS9n2RDgJ8WdtT1hh3PJOE9cBj coj9VzKyulXTc7Qepj/pku60g989FE/rsooYbq6FAIAioeGD3Lni7JWQQK7sKh8jZA0Y yNGY3Ym28QEPqQ708BFGu0aJio6K7i+KvcfyiYFkZ4I/xyQm+1ZyuGS4aT8lS3xA0pco CEeA==; 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-158600-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158600-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ot6-20020a170906ccc600b00a5888728369si2650280ejb.303.2024.04.25.06.31.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 06:31:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158600-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; 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-158600-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158600-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 3D13C1F21555 for ; Thu, 25 Apr 2024 13:31:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0885D149C7F; Thu, 25 Apr 2024 13:30:02 +0000 (UTC) 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 3FD57149C5E; Thu, 25 Apr 2024 13:29:58 +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=1714051801; cv=none; b=IGGlCRj4MB/cIjfttRqlGzQa53q5EfmSD7e1gE9K5S/GvJ1dJk3VphpUdAhRWcoFenKkzNfp+9AgKcAMt4fw5D8AZWEzXuSsNqMb8cy3SVptmP1kLKA3cszQgDY3oaGIYVROJMUubYjYeu3TDr79Rtf38VsqY1i4JDWsYkdiJug= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714051801; c=relaxed/simple; bh=8brYhM2FfPKIlVI/StWeG/lz5kWQo4DD8rJE5sLABAw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Hx1Nn6z377BCpLeHTFLBSBBCarNOUPtU669ClFUvv4PMm+2j8pB9Fahw/7leEnESMrZSjpT/sbEPlm2osB7YvxDKqhPHi8GbzgbXe47eEyPhdH/S1gOJ2KZBAcrOA/kBgLjOo+3d2jIICVWsAgUR37W4XzjiUtiY5NFJav5U2to= 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.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VQGq14D7VzvPty; Thu, 25 Apr 2024 21:26:53 +0800 (CST) Received: from kwepemm600005.china.huawei.com (unknown [7.193.23.191]) by mail.maildlp.com (Postfix) with ESMTPS id B30B7180A9C; Thu, 25 Apr 2024 21:29:56 +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; Thu, 25 Apr 2024 21:29:56 +0800 From: Longfang Liu To: , , , CC: , , , Subject: [PATCH v6 3/5] hisi_acc_vfio_pci: create subfunction for data reading Date: Thu, 25 Apr 2024 21:23:20 +0800 Message-ID: <20240425132322.12041-4-liulongfang@huawei.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20240425132322.12041-1-liulongfang@huawei.com> References: <20240425132322.12041-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: dggems705-chm.china.huawei.com (10.3.19.182) 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