Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755172AbdCUAsq (ORCPT ); Mon, 20 Mar 2017 20:48:46 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:37444 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754218AbdCUAsp (ORCPT ); Mon, 20 Mar 2017 20:48:45 -0400 Date: Tue, 21 Mar 2017 11:24:45 +1100 From: Gavin Shan To: Bodong Wang Cc: Gavin Shan , bhelgaas@google.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, saeedm@mellanox.com, Eli Cohen Subject: Re: [PATCH] pci/sriov: Add an option to probe VFs or not before enabling SR-IOV Reply-To: Gavin Shan References: <1490022874-54718-1-git-send-email-bodong@mellanox.com> <20170320230706.GA12252@gwshan> <7bfcfdcd-e0a8-f1e9-f112-fa35fdb845d7@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7bfcfdcd-e0a8-f1e9-f112-fa35fdb845d7@mellanox.com> User-Agent: Mutt/1.5.24 (2015-08-30) X-TM-AS-MML: disable x-cbid: 17032100-1617-0000-0000-000001B90759 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17032100-1618-0000-0000-000047F547AD Message-Id: <20170321002445.GA24862@gwshan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-03-20_18:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=2 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703210001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2872 Lines: 77 On Mon, Mar 20, 2017 at 06:34:23PM -0500, Bodong Wang wrote: >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. Ok. >>+#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 It makes the code a bit clean. Nope, the proposed conditional expression is elaborate. Yeah, the purpose is exactly same as you said: probe driver for non-VF or VFs that were allowed. (!pdev->is_virtfn || pdev->physfn->sriov->probe_vfs); When pdev->is_virtfn is flase, "pdev->physfn->sriov->probe_vfs" doesn't take effect. Otherwise, it means pdev->is_virtfn is true indirectly and going to check "pdev->physfn->sriov->probe_vfs". So it needn't check pdev->is_virtfn explicitly in later case, but it isn't wrong :) Thanks, Gavin