Re: [PATCH 3/6 v3] PCI: support ARI capability

Previous thread: [PATCH 2/6 v3] PCI: add new general functions by Zhao, Yu on Saturday, September 27, 2008 - 1:27 am. (3 messages)

Next thread: [PATCH 4/6 v3] PCI: support SR-IOV capability by Zhao, Yu on Saturday, September 27, 2008 - 1:28 am. (5 messages)
From: Zhao, Yu
Date: Saturday, September 27, 2008 - 1:28 am

Add Alternative Routing-ID Interpretation (ARI) support.

Cc: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: Randy Dunlap <randy.dunlap@oracle.com>
Cc: Grant Grundler <grundler@parisc-linux.org>
Cc: Alex Chiang <achiang@hp.com>
Cc: Matthew Wilcox <matthew@wil.cx>
Cc: Roland Dreier <rdreier@cisco.com>
Cc: Greg KH <greg@kroah.com>
Signed-off-by: Yu Zhao <yu.zhao@intel.com>

---
 drivers/pci/pci.c        |   31 +++++++++++++++++++++++++++++++
 drivers/pci/pci.h        |   12 ++++++++++++
 drivers/pci/probe.c      |    3 +++
 include/linux/pci.h      |    1 +
 include/linux/pci_regs.h |   14 ++++++++++++++
 5 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 400d3b3..fe9efc4 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -1260,6 +1260,37 @@ void pci_pm_init(struct pci_dev *dev)
        }
 }

+/**
+ * pci_ari_init - turn on ARI forwarding if it's supported
+ * @dev: the PCI device
+ */
+void pci_ari_init(struct pci_dev *dev)
+{
+       int pos;
+       u32 cap;
+       u16 ctrl;
+
+       if (!dev->is_pcie || (dev->pcie_type != PCI_EXP_TYPE_ROOT_PORT &&
+                               dev->pcie_type != PCI_EXP_TYPE_DOWNSTREAM))
+               return;
+
+       pos = pci_find_capability(dev, PCI_CAP_ID_EXP);
+       if (!pos)
+               return;
+
+       pci_read_config_dword(dev, pos + PCI_EXP_DEVCAP2, &cap);
+
+       if (!(cap & PCI_EXP_DEVCAP2_ARI))
+               return;
+
+       pci_read_config_word(dev, pos + PCI_EXP_DEVCTL2, &ctrl);
+       ctrl |= PCI_EXP_DEVCTL2_ARI;
+       pci_write_config_word(dev, pos + PCI_EXP_DEVCTL2, ctrl);
+
+       dev->ari_enabled = 1;
+       dev_info(&dev->dev, "ARI forwarding enabled.\n");
+}
+
 int
 pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
 {
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 9f0fa0e..593b415 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -165,5 +165,17 @@ extern struct pci_bus ...
From: Alex Chiang
Date: Tuesday, September 30, 2008 - 3:31 pm

This is user-visible, so my questions are:

	1) Does this really add value for the user? Or is this
	just more noise?

	2) Is this output string informative enough for the user?

Thanks.

/ac

--

From: Jesse Barnes
Date: Thursday, October 2, 2008 - 9:03 am

Maybe we should be consistent with the other APIs and call it pci_enable_ari 
(like we do for wake & msi).  Looks pretty good otherwise.

Jesse
--

From: Matthew Wilcox
Date: Thursday, October 2, 2008 - 9:17 am

Those APIs are for drivers ... this is internal.  I don't have any
objection of my own, though I agree with Alex's remark that the printk
is unnecessary and just adds clutter to the boot process.

-- 
Matthew Wilcox				Intel Open Source Technology Centre
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."
--

From: Zhao, Yu
Date: Tuesday, October 7, 2008 - 7:56 pm

Will rename the function to pci_enable_ari, and remove the printk.

--

Previous thread: [PATCH 2/6 v3] PCI: add new general functions by Zhao, Yu on Saturday, September 27, 2008 - 1:27 am. (3 messages)

Next thread: [PATCH 4/6 v3] PCI: support SR-IOV capability by Zhao, Yu on Saturday, September 27, 2008 - 1:28 am. (5 messages)