Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1698247rwr; Thu, 20 Apr 2023 20:44:51 -0700 (PDT) X-Google-Smtp-Source: AKy350bwJ5gsKfNSrXazUVq+Rv1FXRd0s3rrLnz3ui1+1sCZkeqI33teSCZORpEnsoN5XvQfm9LP X-Received: by 2002:a17:90b:3685:b0:23f:abfc:5acb with SMTP id mj5-20020a17090b368500b0023fabfc5acbmr3577098pjb.18.1682048691631; Thu, 20 Apr 2023 20:44:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682048691; cv=none; d=google.com; s=arc-20160816; b=S8rHptUzUNYbN+TTT8JtPErsnQqWa5cCrMzyiXeCrxfDQeMHNFi/RprfiIw/Xc1Wxd rBYZ+ejHT2DVKLKs1iwFKpq0dwxPVwCaucMngAdJ41xVzVB9kTmewns61Zncz+hN0SU3 WqJlkHMbkDgsVwhBlx+d0Z+LqkCDaHPpC5YpXTMclm26lL94jLHezfrQwW8R5lIlwz8t ROmNqwUR41GSTE7wtMbCdPzgkm3vrsM7nBOJcrN22TZkKs/KT80riMjz/4MhtatxX4tv Gp+130ISwHd+hjJQM5J+Qq9ClNDDFpwI80suTQmuwkk9PtKcLJhomabI5pBnOv89M1GQ 2s/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:references:cc:to:from :subject; bh=Lhe+nc+0jjgxMT67mEmHxAIuD0Vbpnw8o0jRbL/1noE=; b=wgcmCftgea4mgInTvb0Z5UujYXOpiJBYYIRf3i7byVTOtODAXOWBmUYKFT97WpPmMT 32AOBV8GOKToc2YbxVMi8p++UfyquUCglyfl/Sw8epUQuZWhTW1CFLlnRolql0KKgJLs 8DTl0aeoFnCspBV5FczDF4zVloSnOGozUY9hq3fN43NzVlWTeN4ktZ7FEglU5A3+ci4X jiKmrEMnATZaZr+wR5+f9Ave10HybJ9HZUWrld7BV/ZbxQN20VP8fZg5CGlFN3WiAmZy kJ+LSyeHwSuDEAjP7jvt3V8EEGufvJLaFo83ewkwOd7lwO5gb5LqbIq044I7qXMxS9OK bgdQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id oj17-20020a17090b4d9100b002372f2c4d9dsi594890pjb.44.2023.04.20.20.44.37; Thu, 20 Apr 2023 20:44:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232932AbjDUDdC (ORCPT + 99 others); Thu, 20 Apr 2023 23:33:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233498AbjDUDcz (ORCPT ); Thu, 20 Apr 2023 23:32:55 -0400 Received: from szxga08-in.huawei.com (szxga08-in.huawei.com [45.249.212.255]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E005F2712 for ; Thu, 20 Apr 2023 20:32:49 -0700 (PDT) Received: from kwepemm600005.china.huawei.com (unknown [172.30.72.53]) by szxga08-in.huawei.com (SkyGuard) with ESMTP id 4Q2g3y4GmVz17WMn; Fri, 21 Apr 2023 11:29:02 +0800 (CST) Received: from [10.67.103.158] (10.67.103.158) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.23; Fri, 21 Apr 2023 11:32:47 +0800 Subject: Re: [PATCH v10 3/5] hisi_acc_vfio_pci: register debugfs for hisilicon migration driver From: liulongfang To: Jason Gunthorpe CC: , , , , , References: <20230408074224.62608-1-liulongfang@huawei.com> <20230408074224.62608-4-liulongfang@huawei.com> Message-ID: <81e11acf-0ede-d515-bb5a-3964c302f384@huawei.com> Date: Fri, 21 Apr 2023 11:32:47 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.103.158] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600005.china.huawei.com (7.193.23.191) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023/4/21 11:27, liulongfang wrote: > On 2023/4/14 20:24, Jason Gunthorpe wrote: >> On Sat, Apr 08, 2023 at 03:42:22PM +0800, Longfang Liu wrote: >>> +static int hisi_acc_vf_debug_restore(struct seq_file *seq, void *data) >>> +{ >>> + struct device *vf_dev = seq->private; >>> + struct vfio_pci_core_device *core_device = dev_get_drvdata(vf_dev); >>> + struct vfio_device *vdev = &core_device->vdev; >>> + struct hisi_acc_vf_core_device *hisi_acc_vdev = hisi_acc_get_vf_dev(vdev); >>> + struct hisi_acc_vf_migration_file *migf = hisi_acc_vdev->debug_migf; >>> + int ret; >>> + >>> + ret = hisi_acc_vf_debug_check(seq, vdev); >>> + if (ret) >>> + goto restore_err; >>> + >>> + ret = vf_qm_state_save(hisi_acc_vdev, migf); >>> + if (ret) { >>> + seq_printf(seq, "%s\n", "failed to save device data!"); >>> + goto restore_err; >>> + } >>> + >>> + ret = vf_qm_check_match(hisi_acc_vdev, migf); >>> + if (ret) { >>> + seq_printf(seq, "%s\n", "failed to match the VF!"); >>> + goto restore_err; >>> + } >>> + >>> + ret = vf_qm_load_data(hisi_acc_vdev, migf); >>> + if (ret) { >>> + seq_printf(seq, "%s\n", "failed to recover the VF!"); >>> + goto restore_err; >>> + } >>> + >>> + vf_qm_fun_reset(&hisi_acc_vdev->vf_qm); >>> + seq_printf(seq, "%s\n", "successful to resume device data!"); >>> + >>> +restore_err: >>> + return 0; >>> +} >> >> This is basically an in-kernel self test, it should be protected with >> some kind of VFIO selftest kconfig. >> > As a debugfs function, its usage will be more flexible for users. > >> Though, I wonder why we need it??? > After a live migration error occurs. Through this debugfs function, > you can perform separate functional tests on the source and destination > to locate the cause of the error. > > Can't you write a trivial userspace >> program under tools/testing to do this sequence with the ioctls? >> > Sorry, I still wish this feature was a simple debugfs feature. > If you want the userspace testing tool you mentioned, > you can try it on mlx5. > > Thanks, > Longfang. >>> +static int hisi_acc_vf_debug_save(struct seq_file *seq, void *data) >>> +{ >>> + struct device *vf_dev = seq->private; >>> + struct vfio_pci_core_device *core_device = dev_get_drvdata(vf_dev); >>> + struct vfio_device *vdev = &core_device->vdev; >>> + struct hisi_acc_vf_core_device *hisi_acc_vdev = hisi_acc_get_vf_dev(vdev); >>> + struct hisi_acc_vf_migration_file *migf = hisi_acc_vdev->debug_migf; >>> + int ret; >>> + >>> + ret = hisi_acc_vf_debug_check(seq, vdev); >>> + if (ret) >>> + goto save_err; >>> + >>> + ret = vf_qm_state_save(hisi_acc_vdev, migf); >>> + if (ret) { >>> + seq_printf(seq, "%s\n", "failed to save device data!"); >>> + goto save_err; >>> + } >>> + seq_printf(seq, "%s\n", "successful to save device data!"); >>> + >>> +save_err: >>> + return 0; >>> +} >> >> Same kind of commen there, this is a selftest, why does it need a >> special kernel interface? >> >> .. and so on.. >> >> I thought the non-selftesty bits were OK, maybe split the patch to >> match progress >> Thank you for your suggestion, but the current debugfs method can already meet the functional requirements of verification testing and problem location. Thanks, Longfang. >> Jason >> . >>