Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp324329lqo; Wed, 8 May 2024 00:19:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW7aUkOUo1pQ+TWmAhICBUvoDS4/T0HVCGrlVgujLic8dK7t2R5l8COxki0MSBmHEf273l91xldK+ZrCLpYY3i/M9vxQTsVR1ZMEaCMyg== X-Google-Smtp-Source: AGHT+IEwiiWVVyQQapdaWOb8YdKYKPN6KVIx+Fm+mFB4j03m17GWnzJKuTXKCaP1Wo9WH7/iLvLs X-Received: by 2002:a19:645a:0:b0:51f:9549:9c0d with SMTP id 2adb3069b0e04-5217cd49593mr1457975e87.48.1715152754831; Wed, 08 May 2024 00:19:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715152754; cv=pass; d=google.com; s=arc-20160816; b=k3McwG8ODc0nviAseylXC2Df1mtBYXvodXdTHaaSeq6sF8i1fRl96mtqL+gxfYA7uR 0b0+VdAW/c0KanIK3czH+y0YrZHRDyTs+suyC0iGwCnSWG0O5itH+xNCj+OjuXhWNb/T R8ZF5+jS8VwPxk1AUhAS4PHkvvDRcGsZn9AUrp4g3+19uS2S4PB59uXNNqByLQDpD+oQ Vlfad4KaGybcEH5ADrqiZvkYt35gH3iByt51VZt4Sov0WOjNmo2uS8NC+MLzfGppSexV AQTr0aMfDzOoobOzNFB1YJTV3tAxGUaDf25VrMncAO14b9CrDriAa2qYZTY4Xiz0Yz2s vvEQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:date:message-id:from :references:cc:to:subject; bh=TgK2+bUxwJ+yMihOMNgxUTidcBH4DdLON2ARkrwRAyE=; fh=j2DBCy+F7b21/EhQD3A0FSndaTG1JVdK5yaTvlFBiic=; b=kCkQiy40857JrCLjZMPaMO75MwuHSwFTG4iZ/kl4lHThORsM5we4RsvFdBk/sQ8Q5W YHfT+KMcC2CKXhqT98GLVRMi/5EcY1G2s/ZLjj5tpm598pM80WZY4RZfQy+UWByCG9zr 50J6552W7PoECUJuCsDHNXSGyvdHkblntjp1hMIkfxhat2FEuD78dp7RSBthOgFOUJQo he/OMSGWQOlbLrJcHz5iZfZr3fl+u2oEcKJhcrCRbn243TOiIQdouG7+epbdib0LWj84 1saHa9PdaN9AEj9tjcOzxr8fUqYZ3yqMfP3ufrM77ZjUq+U4t3If7Ls9I5OpKM3imYeP q98Q==; 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-172792-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172792-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id xb7-20020a170907070700b00a55b10cc51fsi7404518ejb.1038.2024.05.08.00.19.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 May 2024 00:19:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-172792-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; 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-172792-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-172792-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 649C81F24A2C for ; Wed, 8 May 2024 07:19:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C817328DC0; Wed, 8 May 2024 07:19: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 07BC41F937; Wed, 8 May 2024 07:18: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=1715152742; cv=none; b=XHHGr4YGpBW5+7wHxZ6xQKAxfg2jQLsLKtm547wpuFE6vYzjoIHQ8f01Cs+ZcXwYIuxdYZA2WodeG2txvYWQ6j9NzPj5Rpmskl6MUQiv8MJIXUPHOR8v2YQfNS7bMeFj0ROmWFNThF/4FX6797StXxeWOhQnAcfK1gcT4PkMTVU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715152742; c=relaxed/simple; bh=sxJMZNGTsOPQkxugWPcno0X/RFph40IOC7d7sbtLQvI=; h=Subject:To:CC:References:From:Message-ID:Date:MIME-Version: In-Reply-To:Content-Type; b=c5FqwdG34tmpBTrCYnQ+LQ94tW3pTFqB5IHltpfW2j7Y+/x5gCGCTMAjHXm0f7NahmHr6s7dXV97JldRaGrjrlPXVsRdOjyXtPq6Q9BAzEH1n73MZV8bqlE0xsDhzuvx5sXqA30brjlQkE/Xyg0Ez1aOjsbQvf3WI3oYEJ3Czzw= 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.48]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VZ5yV3JL5ztSnC; Wed, 8 May 2024 15:15:30 +0800 (CST) Received: from kwepemm600005.china.huawei.com (unknown [7.193.23.191]) by mail.maildlp.com (Postfix) with ESMTPS id 65B8B180065; Wed, 8 May 2024 15:18:56 +0800 (CST) Received: from [10.67.121.110] (10.67.121.110) 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, 8 May 2024 15:18:55 +0800 Subject: Re: [PATCH v6 2/5] hisi_acc_vfio_pci: modify the register location of the XQC address To: Alex Williamson CC: , , , , , References: <20240425132322.12041-1-liulongfang@huawei.com> <20240425132322.12041-3-liulongfang@huawei.com> <20240503101138.7921401f.alex.williamson@redhat.com> <20240507063552.705cb1b6.alex.williamson@redhat.com> From: liulongfang Message-ID: <3911fd96-a872-c352-b0ab-0eb2ae982037@huawei.com> Date: Wed, 8 May 2024 15:18:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In-Reply-To: <20240507063552.705cb1b6.alex.williamson@redhat.com> Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm600005.china.huawei.com (7.193.23.191) On 2024/5/7 20:35, Alex Williamson wrote: > On Tue, 7 May 2024 16:29:05 +0800 > liulongfang wrote: > >> On 2024/5/4 0:11, Alex Williamson wrote: >>> On Thu, 25 Apr 2024 21:23:19 +0800 >>> Longfang Liu wrote: >>> >>>> According to the latest hardware register specification. The DMA >>>> addresses of EQE and AEQE are not at the front of their respective >>>> register groups, but start from the second. >>>> So, previously fetching the value starting from the first register >>>> would result in an incorrect address. >>>> >>>> Therefore, the register location from which the address is obtained >>>> needs to be modified. >>> >>> How does this affect migration? Has it ever worked? Does this make >> >> The general HiSilicon accelerator task will only use SQE and CQE. >> EQE is only used when user running kernel mode task and uses interrupt mode. >> AEQE is only used when user running task exceptions occur and software reset >> is required. >> >> The DMA addresses of these four queues are written to the device by the device >> driver through the mailbox command during driver initialization. >> The DMA addresses of EQE and AEQE are migrated through the device register. >> >> EQE and AEQE are not used in general task, after the live migration is completed, >> this DMA address error will not be found. until we added a new kernel-mode test case >> that we discovered that this address was abnormal. >> >>> the migration data incompatible? >>> >> >> This address only affects the kernel mode interrupt mode task function and device >> exception recovery function. >> They do not affect live migration functionality > > Then why are we migrating them? Especially EQE, if it is only used by > kernel mode drivers then why does the migration protocol have any > business transferring the value from the source device? It seems the > fix should be not to apply the value from the source and mark these as > reserved fields in the migration data stream. Thanks, > HiSilicon accelerator equipment can perform general services after completing live migration. This kind of business is executed through the user mode driver and only needs to use SQE and CQE. At the same time, this device can also perform kernel-mode services in the VM through the crypto subsystem. This kind of service requires the use of EQE. Finally, if the device is abnormal, the driver needs to perform a device reset, and AEQE needs to be used in this case. Therefore, a complete device live migration function needs to ensure that device functions are normal in all these scenarios. Therefore, this data still needs to be migrated. Thanks, Longfang. > Alex > > >>> Fixes: ??? >>> >> >> OK! >> >> Thanks. >> Longfang. >>>> Signed-off-by: Longfang Liu >>>> --- >>>> drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c | 8 ++++---- >>>> drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h | 3 +++ >>>> 2 files changed, 7 insertions(+), 4 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..0c7e31076ff4 100644 >>>> --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c >>>> +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.c >>>> @@ -516,12 +516,12 @@ static int vf_qm_state_save(struct hisi_acc_vf_core_device *hisi_acc_vdev, >>>> return -EINVAL; >>>> >>>> /* Every reg is 32 bit, the dma address is 64 bit. */ >>>> - vf_data->eqe_dma = vf_data->qm_eqc_dw[1]; >>>> + vf_data->eqe_dma = vf_data->qm_eqc_dw[QM_XQC_ADDR_HIGH]; >>>> vf_data->eqe_dma <<= QM_XQC_ADDR_OFFSET; >>>> - vf_data->eqe_dma |= vf_data->qm_eqc_dw[0]; >>>> - vf_data->aeqe_dma = vf_data->qm_aeqc_dw[1]; >>>> + vf_data->eqe_dma |= vf_data->qm_eqc_dw[QM_XQC_ADDR_LOW]; >>>> + vf_data->aeqe_dma = vf_data->qm_aeqc_dw[QM_XQC_ADDR_HIGH]; >>>> vf_data->aeqe_dma <<= QM_XQC_ADDR_OFFSET; >>>> - vf_data->aeqe_dma |= vf_data->qm_aeqc_dw[0]; >>>> + vf_data->aeqe_dma |= vf_data->qm_aeqc_dw[QM_XQC_ADDR_LOW]; >>>> >>>> /* Through SQC_BT/CQC_BT to get sqc and cqc address */ >>>> ret = qm_get_sqc(vf_qm, &vf_data->sqc_dma); >>>> diff --git a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h >>>> index 5bab46602fad..f887ab98581c 100644 >>>> --- a/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h >>>> +++ b/drivers/vfio/pci/hisilicon/hisi_acc_vfio_pci.h >>>> @@ -38,6 +38,9 @@ >>>> #define QM_REG_ADDR_OFFSET 0x0004 >>>> >>>> #define QM_XQC_ADDR_OFFSET 32U >>>> +#define QM_XQC_ADDR_LOW 0x1 >>>> +#define QM_XQC_ADDR_HIGH 0x2 >>>> + >>>> #define QM_VF_AEQ_INT_MASK 0x0004 >>>> #define QM_VF_EQ_INT_MASK 0x000c >>>> #define QM_IFC_INT_SOURCE_V 0x0020 >>> >>> . >>> >> > > . >