Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755987AbdCTXxB (ORCPT ); Mon, 20 Mar 2017 19:53:01 -0400 Received: from mail-db5eur01on0063.outbound.protection.outlook.com ([104.47.2.63]:3344 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753819AbdCTXww (ORCPT ); Mon, 20 Mar 2017 19:52:52 -0400 Authentication-Results: mellanox.com; dkim=none (message not signed) header.d=none;mellanox.com; dmarc=none action=none header.from=mellanox.com; Subject: Re: [PATCH] pci/sriov: Add an option to probe VFs or not before enabling SR-IOV To: Gavin Shan References: <1490022874-54718-1-git-send-email-bodong@mellanox.com> <20170320230706.GA12252@gwshan> CC: , , , , Eli Cohen From: Bodong Wang Message-ID: <7bfcfdcd-e0a8-f1e9-f112-fa35fdb845d7@mellanox.com> Date: Mon, 20 Mar 2017 18:34:23 -0500 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170320230706.GA12252@gwshan> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [172.87.190.14] X-ClientProxiedBy: CY4PR02CA0009.namprd02.prod.outlook.com (10.169.188.19) To DB6PR0502MB3061.eurprd05.prod.outlook.com (10.172.245.135) X-MS-Office365-Filtering-Correlation-Id: 173f04fd-8d79-4cc5-c63a-08d46fe9abb8 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(48565401081);SRVR:DB6PR0502MB3061; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0502MB3061;3:+8PFLsgmNRhiJcE4lAkOK3AGRbx5PeoDt7orfaLbVaUTRV3DglslQNWKYzFFpgRlspiD7tTHzNB9Bp7O94BO95Pea6HnpexrEuChBzZZgB0EMtVnD9XM+Vu2fQ8+3ilS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370zQCDi5ibtvFwlD3XF4LWob8A3kfv1ZQ6iFGJr5t0WwUrn6P3DEXYQNQoZ8csQDjhZQU4APr9nM9/4+WBXkAVDVM15PeiZBQkokX3+Dtp/oaNCM2fFhh5SOgl3G7KLDMbcXX4Z5F5K+bA470mcmcf5ezDvXls+8HTKRPwsxHCZp2zg8gY4/yaD/n6ncy4jkYh+f7vcN+msQbKzFcyZB9sk7FQcufBYUa663uXd9KdRMZfshw5qJZZ2auWF9RhE/3yUQABug5MMXfvN8OoAD7purqa5dEpL3HJa0tEuSR1lytxR4I18VkrsGfmdZ7l0uEtQg7is66BIYZqC/C5Zft1EHA1C/Rl8OA9ddS7WlL7s X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(20161123564025)(20161123558025)(20161123555025)(20161123560025)(6072148);SRVR:DB6PR0502MB3061;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0502MB3061; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0502MB3061;4:1xLy65zgr7Kgne9yahA1BFebeTQ5eDi/K+KUeOPWBPGgYdKgzhMptYPkNIz1Me/0mFuf5MUg4RkAtFG5UqtB81Luc1dL7+c2zJ68/v3l89DYOiSj79c3rmOKPZ4N+6rMji1cZlyutrpTHVLxmlIccvAceSOjUi9UY1J7/ysrGOUEfEJxi2xuiFPefOhllPCp3cRqSIgVUriuhdoM6VDVveOH/VxICyWHYYMaof7nqst8WX+1+iypVtu074DNdpxQl7zb0wbvi+x0kHhxGWxcF3FHWzm9wMe3f/BLxHTxL+bBAHEQFXR3ZDDLc2i5x/DTGZfW4xQYVuMCj5viYWiaHeuRujCakozApOMV3JSc+zihKuDtUeoJ/NKFvOyumiZtTSdZENUKKPb4OjvNCGlADh9+YhEkcvmocIi2Cjydy3abDN43HKgIVZ6Eimcvu8izEXRC2kZt/tMerajLZ3HX7wJSp/o2wpGBsShb8d1CthN4G/kOF7tBFL3pCPgPJJp3cbrpa0eRh+1euvj/x3Z+PHK4NehjBQa37Se1NeiiqwHuraJT/QO020+nU9wKOW61n6Qucy7mHOq2WJcNDD2bAefE7nXPcXmSZHeUIEfiTgdhxUaDoHsj7jPdfUU2gPBC X-Forefront-PRVS: 02524402D6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6049001)(6009001)(39860400002)(39840400002)(39410400002)(39850400002)(39450400003)(51914003)(24454002)(377454003)(33646002)(83506001)(86362001)(53936002)(54906002)(189998001)(305945005)(2906002)(47776003)(7736002)(77096006)(4326008)(6246003)(229853002)(6486002)(90366009)(6916009)(65956001)(4001350100001)(2950100002)(6666003)(107886003)(50986999)(5660300001)(31686004)(6116002)(31696002)(3846002)(8676002)(76176999)(36756003)(50466002)(54356999)(110136004)(38730400002)(42186005)(66066001)(81166006)(53546009);DIR:OUT;SFP:1101;SCL:1;SRVR:DB6PR0502MB3061;H:[10.12.146.137];FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1;DB6PR0502MB3061;23:35owkTaJmKO8RB7ORNKtgKNkner8R7f0n0l?= =?Windows-1252?Q?cGypB39VMEc4kyR99P7+ZXXYenF704i7+AY5h6sReFttdBqRnagDgrIR?= =?Windows-1252?Q?y4lC4DZ7qRItlrWxs3PoguC2wT/gZcsniHBTqmSUapsL1LFPpU7DuGlO?= =?Windows-1252?Q?tg9sXQWOts+aUzZyqns6tys+UtVAhGu2qwhs+zq5VVb2EbtvoMpU0Hds?= =?Windows-1252?Q?rHhgx33o/ZZMtqfG3TmR6f6YiIAwLV58WOpFvbYm2wxj6kAJSL9YmIyI?= =?Windows-1252?Q?Yg1gvQw2yYFRcE2C9W/vWF663vhsz67XND05sKRbpyMENOi8s9FNGC+N?= =?Windows-1252?Q?UYSwy+vwpCawatTGbwL9618lSxjrhLZi1fKZm1pn81X8JR+njdq9Iuh6?= =?Windows-1252?Q?8heAxw2yMyT4EtF6dRb3L/koh8LMC0ehN36AHVVoyCIENfkleqxkVnnL?= =?Windows-1252?Q?+UG8LseZKajjmHD+l6C3x5+SkFr/H7WPVnThTL0tdy6FUW1QkUSvlFIU?= =?Windows-1252?Q?lIeZwK5jtrajpkkh3p7pp1KLuDUk5E2zSJxZpgczQZGMEXNBSoLGbH3u?= =?Windows-1252?Q?0bcav2Nc2ZtTXwHtFF/OWeG4uuMqs+ku6lDtnSv+G4KiHSUyvgH/SwIU?= =?Windows-1252?Q?8GryJmO3cSTsFcOcfBLb2zCqhH/H/b4h1gC3Zw7N89xvlAUtVT9s+/7L?= =?Windows-1252?Q?RngROchPvSMLB9/AR4JndBz/GQOvM1aE0Re08NWD0iYXbggy28B/NJkM?= =?Windows-1252?Q?YExlooG1tKaPYWlsjU3gTRQ0oL+01+RUQwAXFCht11xB7pzXU07+dfQ6?= =?Windows-1252?Q?XJQ82RJrmrnylN5v8k5LuvNnjk5tSjVCAR9Ie+Oz8ndKh5+MuAuTfuDJ?= =?Windows-1252?Q?4x4tHW6+okv2BzBEDYKI0FSDOLSuuSoDezB8hLMF6iB9RgfsBugq6Mje?= =?Windows-1252?Q?Wk0AQG3Kl4Ejpk8Pfj9DxEGNkBKdRZ1aSfSFuZveR9wl9gClFdRWmXqz?= =?Windows-1252?Q?Ur34t8FwCEn9cr3fwcPeBz0nEkbvopVxWsnsXY/tbVZ9NigcDH64jNFE?= =?Windows-1252?Q?5eqsuW+0oejYwWiRQCXWeTE7YxolDWw+vuqPJbZ24ukXxba94IsHNiRU?= =?Windows-1252?Q?sQ59EWyqsgyvcL0rolLZrOwZBHj0wdH/lM9tqHWoAgoAdj8nh2lvNBT8?= =?Windows-1252?Q?KTTFGtp2g7HtQ6dia3Kyw3oup2pvvsW3ww052JGzXsOQjwm/bHF/JL2T?= =?Windows-1252?Q?sLT8H/h5nyWTqD3rCCqJ2jt6JF0l+mYqvxv23Pckt+/gnaXOxdRmJEP0?= =?Windows-1252?Q?zMlwdGK+zXO7WFH9kvb+eJtkeZn1BzI/gm38SgjJQYroF3fg=3D?= X-Microsoft-Exchange-Diagnostics: 1;DB6PR0502MB3061;6:qsucSOZmDHHEAVu2QBKl7dy/eXs/L/QcPzdjht7kfvUikkz6rm+xQMEpVJmSYyk7q+34PzDMRtCL2nsLpRiMzCIHTtj3OcjY3oa7a1b+6m225pthPUqIZRiBvg92PbHmH2h+bYukW+dwMA+bChtyAwiyFdu4MN7J5t7tItby7YW44KlgrhAQbfMlOnG2oIwxh3x4AgCYx9uP496GPIWM1eHNmB9pquvKXOiB5KFAHZ8aQUR+OneHOSReGrBps7svX7FFcE7fB7Nu6vihJeimDCbX6CP62TGjda3CkPW6Yc1hYet1v9w5hOQ2NSebyTwhD0aQRrI/kysaz4cCaemXaLY1yo1veawNUK+CpUVxH/h3RTeL0SqQW5xjlsKUGq0RfhDWqR5JtOxHKac5pYOpky7WQ/lRpZqvZ2iSfqxH2hk=;5:vj1Xs+OQty8pK0mlwDoInGV5osCmqtQZKgFlS4HeWFi6XQleGRrjlCCCY/kWrvvMIDkLAALFTBRc8PPbIV3eVCQP9EkW73lc7i5TuK1C+2kRMnETJwAllD95VdTrZI/PNmKlA9zlMJUGQn4fY1bwcg==;24:fdYmcbuz3bAlKG+SVjlKcj+bVH/ehNflSgFsohxdr5LRx1k206gBxYwDt3pIefF5FC8COdpgzMnrez7HgyK90pSnur8QekNTNHyRDoSbT9Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR0502MB3061;7:/L8f22zROFiLnJeNM1+UweKqcnIEOh8CbTNgUlQyYUkBI5cB6SrM4EYliQx6MUFWZ2nCWfIB9YPyWuGIckyDHXBv7bv3YptCjbkugMolutx+6CwwWVTaZDEECXf8rnOq9sMcXkJPixbeeMSBE8U5od7n70RbbOI1IaLXdhgjGtC7RSCLvyAwWsbvA1RuboWI66wkRSDTxUMmy9di00cD9ymJLz/APhaD/CmTt2oB+x89lZh7j63ABYIkyTlIBzlHjRm8cNdBCXldQNL5d4JTYUtD3fjdfH6Cw/pMOI2N2a+o/fvPmWZDgouKXTdRC9Ka3AcZ0oMHocEPOPRpUglkRQ== X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2017 23:34:35.1237 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0502MB3061 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2278 Lines: 64 On 3/20/2017 6:07 PM, Gavin Shan wrote: > On Mon, Mar 20, 2017 at 05:14:34PM +0200, bodong@mellanox.com wrote: >> From: Bodong Wang >> >> Sometimes it is not desirable to probe the virtual functions after >> SRIOV is enabled. This can save host side resource usage by VF >> instances which would be eventually probed to VMs. >> >> Added a new PCI sysfs interface "sriov_probe_vfs" to control that > >from PF, all current callers still retain the same functionality. >> To modify it, echo 0/n/N (disable probe) or 1/y/Y (enable probe) to >> >> /sys/bus/pci/devices//sriov_probe_vfs >> >> Note that, the choice must be made before enabling VFs. The change >> will not take effect if VFs are already enabled. Simply, one can set >> sriov_numvfs to 0, choose whether to probe or not, and then resume >> sriov_numvfs. >> > Bodong, I'm not sure if there is a requirement to load driver for the > specified number of VFs? That indicates no driver will be loaded for > other VFs. If so, this interface might serve the purpose as well. Gavin, thanks for the review. That is indeed an interesting suggestion. Theoretically, we can change that probe_vfs from boolean to integer. And use it as a counter to probe the first N VFs(if N < total_vfs). Let's see if there are any objections. > > > +#ifdef CONFIG_PCI_IOV > + if (!pci_dev->is_virtfn || > + (pci_dev->is_virtfn && pci_dev->physfn->sriov->probe_vfs)) { > +#endif > + error = __pci_device_probe(drv, pci_dev); > + if (error) { > + pcibios_free_irq(pci_dev); > + pci_dev_put(pci_dev); > + } > +#ifdef CONFIG_PCI_IOV > } > +#endif > > I think it's reasonable to have a inline function for this check: It's doable, but what's the benefit? > > #ifdef CONFIG_PCI_IOV > static inline bool pci_device_can_probe(struct pci_dev *pdev) > { > return (!pdev->is_virtfn || pdev->physfn->sriov->probe_vfs); should be return (!pdev->is_virtfn || (pci_dev->is_virtfn && pci_dev->physfn->sriov->probe_vfs)); We want to probe that device if 1) it's a PF 2) it'a VF and probe_vfs is set > } > #else > static inline bool pci_device_can_probe(struct pci_dev *pdev) > { > return true; > } This function will be a waste if CONFIG_PCI_IOV is not defined. > #endif > Thanks, > Gavin >