Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1421448rwb; Fri, 19 Aug 2022 03:30:29 -0700 (PDT) X-Google-Smtp-Source: AA6agR54BhUsloKxx+GrbCW9XmKtABeSGGu6bcRVbNczxj2a22jJhDwPobmEYggBvT0YrtQQL2Xz X-Received: by 2002:a05:6a00:a82:b0:530:2f3c:ec99 with SMTP id b2-20020a056a000a8200b005302f3cec99mr7214541pfl.53.1660905029591; Fri, 19 Aug 2022 03:30:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660905029; cv=none; d=google.com; s=arc-20160816; b=uygKZ5hkrVxh50Lxjwj5GgrqBqJgkDx9qWBU2roKZ2KRD3yKLwdJK4Ox5Jrjlne6/e goTV4exk5sNg7h7lu+EHuZRzfj0NnvTanMST4Pt2OpxqfJux+N/vvxhcTbdh7IXeR7i5 Z6c6qAMvSW5Eeu3scjy221UNpN7bz2eOCNhtnaMnCAot0zEBP4Np9S0nvcEOONgMcTAT aKiwWQWt9/LSsfJ6rFtUN+v9q1r7Qikv+Ro+5SNYK+W7JokR5BFrcBV8HcybZUAm4Vnz jo3OVWjv4hKBQceqtaU7ZTm8ltYDrtk1WlXfxyEjMUUlz7egH4urJWc2pN0EsTQFiF21 eRxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:date:message-id:subject:from:to:cc; bh=QqwvXW5mwlnQMkVjqh35wV2lgyKzZNwcNT7utlHMPiA=; b=ylZM1OJXlfESzFHgGuVBvUs0KSfVbjlCtIHdRvahtrpeyE8UPM32qupivmWH8EQzq0 LszB/WTOvpQlEhJwVbjc6moiycOb1waJCX0syMq31kTJJagZ0KPf2hWY5j2vL3guEOE0 6NX+SLsaR3BDAwAAfC23zYl9PbmGEZBaqIV2njOksW7pT6w6xqWigjrsitHh6HHXkL5p x+D8x70O9bG4DPHPnqB61230lxoNgFskGv1xSiBPFMfhUUKZzoUsvKWNyzoggLJ/suoG nZruOV+NY1Wk3wTf2Esp3av/m2f3ME8Baxgk94/HE94B1EaVrd8hP4H1S17ueUcHGqX3 xPZg== 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 w14-20020a637b0e000000b0041bf27ac6e2si3661919pgc.730.2022.08.19.03.30.14; Fri, 19 Aug 2022 03:30:29 -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 S1348345AbiHSKVy (ORCPT + 99 others); Fri, 19 Aug 2022 06:21:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346861AbiHSKVx (ORCPT ); Fri, 19 Aug 2022 06:21:53 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 053E6EF9EF; Fri, 19 Aug 2022 03:21:52 -0700 (PDT) Received: from canpemm500009.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4M8HlQ2BYBzkWMp; Fri, 19 Aug 2022 18:18:26 +0800 (CST) Received: from [10.67.102.169] (10.67.102.169) by canpemm500009.china.huawei.com (7.192.105.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 19 Aug 2022 18:21:49 +0800 CC: , , , "linux-kernel@vger.kernel.org" , , Linuxarm To: , From: Yicong Yang Subject: [ISSUE] Cannot enable VF after remove/rescan Message-ID: <9f37e68c-e960-5188-f52a-4761866c37ad@huawei.com> Date: Fri, 19 Aug 2022 18:21:49 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.5.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.169] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To canpemm500009.china.huawei.com (7.192.105.203) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, 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 Hi Ixgbe maintainers, We met an issue that the VF of 82599 cannot be enabled after remove and rescan the PF device. The PCI hierarchy on our platform is like: [...] +-[0000:80]-+-00.0-[81]-- | +-04.0-[82]-- | +-08.0-[83]--+-00.0 Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection | | \-00.1 Intel Corporation 82599ES 10-Gigabit SFI/SFP+ Network Connection | \-10.0-[84]-- [...] We operated like below: [root@localhost ~]# cat /sys/class/net/enp131s0f0/device/sriov_numvfs 0 [root@localhost ~]# echo 1 > /sys/class/net/enp131s0f0/device/sriov_numvfs # enable 1 VF [root@localhost ~]# echo 1 > /sys/bus/pci/devices/0000:83:00.0/remove # remove the PF [root@localhost ~]# echo 1 > /sys/bus/pci/rescan # rescan the PF [root@localhost ~]# cat /sys/class/net/enp131s0f0/device/sriov_numvfs 0 [root@localhost ~]# echo 1 > /sys/class/net/enp131s0f0/device/sriov_numvfs # attemp to enable the VF [ 433.568996] ixgbe 0000:83:00.0 enp131s0f0: SR-IOV enabled with 1 VFs [ 433.639027] ixgbe 0000:83:00.0: Multiqueue Enabled: Rx Queue count = 4, Tx Queue count = 4 XDP Queue count = 0 [ 433.652932] ixgbe 0000:83:00.0: can't enable 1 VFs (bus 84 out of range of [bus 83]) [ 433.661228] ixgbe 0000:83:00.0: Failed to enable PCI sriov: -12 -bash: echo: write error: Cannot allocate memory A further investigation shows that the SRIOV offset changed after the rescan, so we cannot find an available PCI bus (it's already occupied) for the VF device: Before the remove: [root@localhost ~]# lspci -vvs 83:00.0 Capabilities: [160 v1] Single Root I/O Virtualization (SR-IOV) IOVCap: Migration- 10BitTagReq- Interrupt Message Number: 000 IOVCtl: Enable- Migration- Interrupt- MSE- ARIHierarchy+ 10BitTagReq- IOVSta: Migration- Initial VFs: 64, Total VFs: 64, Number of VFs: 0, Function Dependency Link: 00 VF offset: 128, stride: 2, Device ID: 10ed Supported Page Size: 00000553, System Page Size: 00000001 Region 0: Memory at 0000280000804000 (64-bit, prefetchable) Region 3: Memory at 0000280000904000 (64-bit, prefetchable) VF Migration: offset: 00000000, BIR: 0 After the rescan: [root@localhost ~]# lspci -vvs 83:00.0 Capabilities: [160 v1] Single Root I/O Virtualization (SR-IOV) IOVCap: Migration- 10BitTagReq- Interrupt Message Number: 000 IOVCtl: Enable- Migration- Interrupt- MSE- ARIHierarchy- 10BitTagReq- IOVSta: Migration- Initial VFs: 64, Total VFs: 64, Number of VFs: 0, Function Dependency Link: 00 VF offset: 384, stride: 2, Device ID: 10ed ^^^^^^^^^^^^^^ offset has changed Supported Page Size: 00000553, System Page Size: 00000001 Region 0: Memory at 0000280000804000 (64-bit, prefetchable) Region 3: Memory at 0000280000904000 (64-bit, prefetchable) We don't know why the SRIOV offset and stride changed and is there anything wrong. Any help on how to illustrate or fix this is highly appreciated! Please let us know if more information is needed. Thanks, Yicong