All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Kannebley Tavares <lucaskt@linux.vnet.ibm.com>
To: dri-devel@lists.freedesktop.org
Cc: David Airlie <airlied@linux.ie>,
	Bjorn Helgaas <bhelgaas@google.com>,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	Brian King <brking@linux.vnet.ibm.com>,
	Benjamin Herrenschmidt <benh@au1.ibm.com>,
	Nishanth Aravamudan <nacc@linux.vnet.ibm.com>
Subject: radeon: RFC speed cap detection on ppc64
Date: Fri, 19 Oct 2012 14:43:28 -0300	[thread overview]
Message-ID: <50819140.8030806@linux.vnet.ibm.com> (raw)

The radeon driver does speed cap detection on the root PCI device for 
the maximum speed with which the adapter can communicate. On ppc64 
systems, however, the root device belongs to the Hypervisor, so the 
current code would case a null pointer dereference.

I propose to look for the outmost bus with a parent node and get speed 
caps from it, though I suppose the cleaner way would be to inspect all 
devices along the way and choose the smallest speed cap.

Does anyone have suggestions for this?

Thanks

--
--- 
/home/lucaskt/work/devdrivers/kernel/linux/drivers/gpu/drm/drm_pci.c 
2012-09-26 10:06:00.280549928 -0300
+++ drm_pci.c	2012-09-26 15:38:51.121786353 -0300
@@ -466,6 +466,19 @@
  }
  EXPORT_SYMBOL(drm_pci_exit);

+static struct pci_dev *drm_get_pcie_root_dev(struct pci_dev *dev)
+{
+	// Go up through all possible busses to get the info for the outmost bus
+	while (!pci_is_root_bus(dev->bus))
+		dev = dev->bus->parent->self;
+	
+	// In POWER architectures there's no PCI root device, so it should 
just read
+	// the caps from the device itself
+	if (dev->bus->self != NULL)
+		return dev->bus->self;
+	else
+		return dev;
+}
+
  int drm_pcie_get_speed_cap_mask(struct drm_device *dev, u32 *mask)
  {
  	struct pci_dev *root;
@@ -479,7 +492,7 @@
  	if (!pci_is_pcie(dev->pdev))
  		return -EINVAL;

-	root = dev->pdev->bus->self;
+	root = drm_get_pcie_root_dev(dev->pdev);

  	pos = pci_pcie_cap(root);
  	if (!pos)


-- 
Lucas Kannebley Tavares
Software Engineer
IBM Linux Technology Center


             reply	other threads:[~2012-10-19 17:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-19 17:43 Lucas Kannebley Tavares [this message]
2012-10-22 15:27 ` radeon: RFC speed cap detection on ppc64 Adam Jackson
2012-10-22 15:44   ` Alan Cox
2012-10-22 16:59     ` Bjorn Helgaas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50819140.8030806@linux.vnet.ibm.com \
    --to=lucaskt@linux.vnet.ibm.com \
    --cc=airlied@linux.ie \
    --cc=benh@au1.ibm.com \
    --cc=bhelgaas@google.com \
    --cc=brking@linux.vnet.ibm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=nacc@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.