Re: [PATCH] Add pci=sriov=[0|1] to enable or disable SRIOV.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 10/10/2011 12:00 PM, Bjorn Helgaas wrote:
> On Mon, Oct 10, 2011 at 9:17 AM, Prarit Bhargava <prarit@xxxxxxxxxx> wrote:
>>
>>>
>>> what is the point sriov=1? are you going to enable sriov forcefully?
>>>
>>> pci=nosriov
>>
>> Hi Yinghai,
>>
>> I'm looking at this from a distribution's point-of-view.
>>
>> SRIOV is built-in but purposely disabled by the distro for a particular system via an SMBIOS check so that pci_sriov_enabled = 0.
>>
>> In that case, when the system was functional, through a FW update, I will want to turn it on without having to rebuild the kernel.  ie) specifying pci=sriov=1 makes sense to test or debug in that case.
>>
>> If that isn't acceptable to upstream, I would have no objection to pci=nosriov.
> 
> What about
> 
>   pci=sriov
>   pci=nosriov
> 
> The existing PCI options that use "=" are mostly things that require
> an entire value (bitmask, size, etc.) rather than just a boolean, and
> there's some precedent for using "OPTION and noOPTION" for boolean
> things (bios/nobios, rom/norom, bfsort/nobfsort).

Sure ... I can do that.  But Yinghai is requesting just "pci=nosriov"
which I'll implement.

> 
> Would you mind mentioning "PCI" in the printk message along with
> "SRIOV" just to help dmesg readers put it in context?

Done.

> 
> Would it be overkill to mention either in
> Documentation/kernel-parameters.txt or in the dmesg that if you needed
> to use this option, you should report a bug?  I've been disappointed
> by how many times I've found reports on the web saying "pci=use_crs"
> is the final fix, when it's really only a band-aid that we should fix
> properly in the kernel.  I don't think end-users should ever have to
> know about options like this, but sometimes they become part of the
> folklore of random things that people try, which reflects poorly on
> Linux.

I completely agree with this Bjorn but ...
I'm clueless about asking an end-user to report a bug
because the question becomes where/which company or group
do they report the bug to?

To lkml?  linux-pci?  bugzilla.kernel.org?  The distribution's bug 
reporting tool?  The hardware vendor?

Either way, I have put

"Please report a bug if you use this kernel parameter."

On 10/10/2011 02:58 PM, Yinghai Lu wrote:
> pci=nosriov should be good enough.

Okay.

P.


[PATCH] Add pci=nosriov to disable SRIOV.

To help debugging, add a kernel parameter, pci=nosriov which disables SRIOV.

Signed-off-by: Prarit Bhargava <prarit@xxxxxxxxxx>
Cc: ddutile@xxxxxxxxxx
Cc: bhelgaas@xxxxxxxxxx
---
 Documentation/kernel-parameters.txt |    3 +++
 drivers/pci/iov.c                   |   19 ++++++++++++++++++-
 drivers/pci/pci.c                   |    2 ++
 drivers/pci/pci.h                   |    3 +++
 4 files changed, 26 insertions(+), 1 deletions(-)

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index 854ed5c..429c7e6 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -2032,6 +2032,9 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 				on: Turn ECRC on.
 		realloc		reallocate PCI resources if allocations done by BIOS
 				are erroneous.
+		nosriov=	[HW]
+				Disable SRIOV support in kernel.
+				Please report a bug if you use this parameter.
 
 	pcie_aspm=	[PCIE] Forcibly enable or disable PCIe Active State Power
 			Management.
diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 42fae47..260c94d 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -408,6 +408,8 @@ static void sriov_disable(struct pci_dev *dev)
 	iov->nr_virtfn = 0;
 }
 
+unsigned int pci_sriov_enabled = 1;
+
 static int sriov_init(struct pci_dev *dev, int pos)
 {
 	int i;
@@ -419,6 +421,12 @@ static int sriov_init(struct pci_dev *dev, int pos)
 	struct resource *res;
 	struct pci_dev *pdev;
 
+	if (!pci_sriov_enabled) {
+		rc = -EPERM;
+		/* in theory no flags should have been set ... */
+		goto failed;
+	}
+
 	if (dev->pcie_type != PCI_EXP_TYPE_RC_END &&
 	    dev->pcie_type != PCI_EXP_TYPE_ENDPOINT)
 		return -ENODEV;
@@ -614,7 +622,10 @@ resource_size_t pci_sriov_resource_alignment(struct pci_dev *dev, int resno)
 	struct resource tmp;
 	enum pci_bar_type type;
 	int reg = pci_iov_resource_bar(dev, resno, &type);
-	
+
+	if (!pci_sriov_enabled)
+		return 0;
+
 	if (!reg)
 		return 0;
 
@@ -667,6 +678,9 @@ int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn)
 {
 	might_sleep();
 
+	if (!pci_sriov_enabled)
+		return -EPERM;
+
 	if (!dev->is_physfn)
 		return -ENODEV;
 
@@ -682,6 +696,9 @@ void pci_disable_sriov(struct pci_dev *dev)
 {
 	might_sleep();
 
+	if (!pci_sriov_enabled)
+		return;
+
 	if (!dev->is_physfn)
 		return;
 
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index e9651f0..11175cb 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -3576,6 +3576,8 @@ static int __init pci_setup(char *str)
 				pcie_bus_config = PCIE_BUS_PERFORMANCE;
 			} else if (!strncmp(str, "pcie_bus_peer2peer", 18)) {
 				pcie_bus_config = PCIE_BUS_PEER2PEER;
+			} else if (!strncmp(str, "nosriov", 7)) {
+				pci_sriov_enabled = 0;
 			} else {
 				printk(KERN_ERR "PCI: Unknown option `%s'\n",
 						str);
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index b74084e..9eeb56d 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -229,6 +229,9 @@ resource_size_t pci_specified_resource_alignment(struct pci_dev *dev);
 extern void pci_disable_bridge_window(struct pci_dev *dev);
 #endif
 
+/* Use "pci=nosriov" to disable SRIOV */
+extern unsigned int pci_sriov_enabled;
+
 /* Single Root I/O Virtualization */
 struct pci_sriov {
 	int pos;		/* capability position */
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux