aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt2010-08-05 22:55:11 -0500
committerAdam Jackson2010-08-06 08:38:43 -0500
commitb04515c5d6c95f573457a94267b855cceb639105 (patch)
tree47b2d6b9874bdb680417ae47703c32b6f3caa239 /xf86drm.c
parent431f7f00db844534dbcf9a63da0d2832a3d91bff (diff)
downloadexternal-libgbm-b04515c5d6c95f573457a94267b855cceb639105.tar.gz
external-libgbm-b04515c5d6c95f573457a94267b855cceb639105.tar.xz
external-libgbm-b04515c5d6c95f573457a94267b855cceb639105.zip
libdrm: Fix PCI domain domain support
This works in conjunction with newer kernels. If we succeed in requesting interface 1.4, the we know the kernel provides proper domain numbers. If not, ignore the domain number as it's bogus (except on Alpha). Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Adam Jackson <ajax@redhat.com>
Diffstat (limited to 'xf86drm.c')
-rw-r--r--xf86drm.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/xf86drm.c b/xf86drm.c
index 220aaa16..e48b9c99 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -229,7 +229,7 @@ drmHashEntry *drmGetEntry(int fd)
229 * PCI:b:d:f format and the newer pci:oooo:bb:dd.f format. In the format, o is 229 * PCI:b:d:f format and the newer pci:oooo:bb:dd.f format. In the format, o is
230 * domain, b is bus, d is device, f is function. 230 * domain, b is bus, d is device, f is function.
231 */ 231 */
232static int drmMatchBusID(const char *id1, const char *id2) 232static int drmMatchBusID(const char *id1, const char *id2, int pci_domain_ok)
233{ 233{
234 /* First, check if the IDs are exactly the same */ 234 /* First, check if the IDs are exactly the same */
235 if (strcasecmp(id1, id2) == 0) 235 if (strcasecmp(id1, id2) == 0)
@@ -257,6 +257,13 @@ static int drmMatchBusID(const char *id1, const char *id2)
257 return 0; 257 return 0;
258 } 258 }
259 259
260 /* If domains aren't properly supported by the kernel interface,
261 * just ignore them, which sucks less than picking a totally random
262 * card with "open by name"
263 */
264 if (!pci_domain_ok)
265 o1 = o2 = 0;
266
260 if ((o1 != o2) || (b1 != b2) || (d1 != d2) || (f1 != f2)) 267 if ((o1 != o2) || (b1 != b2) || (d1 != d2) || (f1 != f2))
261 return 0; 268 return 0;
262 else 269 else
@@ -482,7 +489,7 @@ int drmAvailable(void)
482 */ 489 */
483static int drmOpenByBusid(const char *busid) 490static int drmOpenByBusid(const char *busid)
484{ 491{
485 int i; 492 int i, pci_domain_ok = 1;
486 int fd; 493 int fd;
487 const char *buf; 494 const char *buf;
488 drmSetVersion sv; 495 drmSetVersion sv;
@@ -492,14 +499,27 @@ static int drmOpenByBusid(const char *busid)
492 fd = drmOpenMinor(i, 1, DRM_NODE_RENDER); 499 fd = drmOpenMinor(i, 1, DRM_NODE_RENDER);
493 drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd); 500 drmMsg("drmOpenByBusid: drmOpenMinor returns %d\n", fd);
494 if (fd >= 0) { 501 if (fd >= 0) {
502 /* We need to try for 1.4 first for proper PCI domain support
503 * and if that fails, we know the kernel is busted
504 */
495 sv.drm_di_major = 1; 505 sv.drm_di_major = 1;
496 sv.drm_di_minor = 1; 506 sv.drm_di_minor = 4;
497 sv.drm_dd_major = -1; /* Don't care */ 507 sv.drm_dd_major = -1; /* Don't care */
498 sv.drm_dd_minor = -1; /* Don't care */ 508 sv.drm_dd_minor = -1; /* Don't care */
499 drmSetInterfaceVersion(fd, &sv); 509 if (drmSetInterfaceVersion(fd, &sv)) {
510#ifndef __alpha__
511 pci_domain_ok = 0;
512#endif
513 sv.drm_di_major = 1;
514 sv.drm_di_minor = 1;
515 sv.drm_dd_major = -1; /* Don't care */
516 sv.drm_dd_minor = -1; /* Don't care */
517 drmMsg("drmOpenByBusid: Interface 1.4 failed, trying 1.1\n",fd);
518 drmSetInterfaceVersion(fd, &sv);
519 }
500 buf = drmGetBusid(fd); 520 buf = drmGetBusid(fd);
501 drmMsg("drmOpenByBusid: drmGetBusid reports %s\n", buf); 521 drmMsg("drmOpenByBusid: drmGetBusid reports %s\n", buf);
502 if (buf && drmMatchBusID(buf, busid)) { 522 if (buf && drmMatchBusID(buf, busid, pci_domain_ok)) {
503 drmFreeBusid(buf); 523 drmFreeBusid(buf);
504 return fd; 524 return fd;
505 } 525 }