~ubuntu-branches/ubuntu/vivid/xorg-server/vivid

« back to all changes in this revision

Viewing changes to debian/patches/drm_device_keep_trying.patch

  • Committer: Package Import Robot
  • Author(s): Maarten Lankhorst, Bryce Harrington
  • Date: 2013-04-08 11:40:26 UTC
  • Revision ID: package-import@ubuntu.com-20130408114026-sg2eictamq5pv9c6
Tags: 2:1.13.3-0ubuntu5
[ Bryce Harrington ]
* Add no-nv.patch:  Don't autoprobe -nv on linux.
* Refresh drm_device_keep_trying.patch (LP: #1161981)
  - Set empty busid for usb devices
  - Parse pci path more strictly.
  - Make platform devices work correctly, try to obtain busid from
    path if possible.
  - Fallback if not possible (tegra).

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 hw/xfree86/os-support/linux/lnx_platform.c |   29 +++++++++++++++++++++++++---
17
17
 1 file changed, 26 insertions(+), 3 deletions(-)
18
18
 
19
 
diff --git a/config/udev.c b/config/udev.c
20
 
index 454838f..af133d2 100644
21
19
--- a/config/udev.c
22
20
+++ b/config/udev.c
23
 
@@ -98,7 +98,7 @@ device_added(struct udev_device *udev_device)
 
21
@@ -98,7 +98,7 @@
24
22
         if (strncmp(sysname, "card", 4) != 0)
25
23
             return;
26
24
 
29
27
 
30
28
         config_udev_odev_setup_attribs(path, syspath, NewGPUDeviceRequest);
31
29
         return;
32
 
@@ -267,7 +267,7 @@ device_removed(struct udev_device *device)
 
30
@@ -267,7 +267,7 @@
33
31
 
34
32
         if (strncmp(sysname,"card", 4) != 0)
35
33
             return;
38
36
         if (!path)
39
37
             return;
40
38
 
41
 
@@ -437,6 +437,16 @@ config_udev_odev_setup_attribs(const char *path, const char *syspath,
 
39
@@ -420,11 +420,23 @@
 
40
 #ifdef CONFIG_UDEV_KMS
 
41
 
 
42
 static Bool
 
43
+get_pci_busid(const char *in, char *pci_str)
 
44
+{
 
45
+    int ret, domain, bus, dev, func;
 
46
+    ret = sscanf(in, "/%04x:%02x:%02x.%d/drm/card%*d", &domain, &bus, &dev, &func);
 
47
+    if (ret != 4)
 
48
+        return FALSE;
 
49
+    sprintf(pci_str, "pci:%04x:%02x:%02x.%d", domain, bus, dev, func);
 
50
+    return TRUE;
 
51
+}
 
52
+
 
53
+static Bool
 
54
 config_udev_odev_setup_attribs(const char *path, const char *syspath,
 
55
                                config_odev_probe_proc_ptr probe_callback)
 
56
 {
 
57
     struct OdevAttributes *attribs = config_odev_allocate_attribute_list();
 
58
     int ret;
 
59
+    const char *platform;
 
60
 
 
61
     if (!attribs)
 
62
         return FALSE;
 
63
@@ -437,6 +449,32 @@
42
64
     if (ret == FALSE)
43
65
         goto fail;
44
66
 
45
67
+    if (strstr(syspath, "/devices/pci")) {
 
68
+        char pci_str[17];
46
69
+        const char *end = strstr(syspath, "/drm/card");
47
 
+        if (end && end - 12 > syspath) {
48
 
+            char pci_str[17] = "pci:";
49
 
+
50
 
+            strncpy(pci_str + 4, end - 12, 12);
 
70
+        if (strstr(syspath, "/usb"))
 
71
+            ret = config_odev_add_attribute(attribs, ODEV_ATTRIB_BUSID, "");
 
72
+        else if (get_pci_busid(end - 13, pci_str))
51
73
+            ret = config_odev_add_attribute(attribs, ODEV_ATTRIB_BUSID, pci_str);
 
74
+    } else if ((platform = strstr(syspath, "/devices/platform/"))) {
 
75
+        const char *end;
 
76
+        platform += 18;
 
77
+        end = strchr(platform, '.');
 
78
+        if (end) {
 
79
+            char *busid;
 
80
+            ret = asprintf(&busid, "platform:%.*s:%02li",
 
81
+                           (int)(end - platform), platform, strtol(end + 1, NULL, 10));
 
82
+            if (ret >= 0) {
 
83
+                ret = config_odev_add_attribute(attribs, ODEV_ATTRIB_BUSID, busid);
 
84
+                free(busid);
 
85
+            }
 
86
+            else
 
87
+                ret = TRUE;
52
88
+        }
53
89
+    }
 
90
+    if (ret == FALSE)
 
91
+        goto fail;
54
92
+
55
93
     /* ownership of attribs is passed to probe layer */
56
94
     probe_callback(attribs);
57
95
     return TRUE;
58
 
diff --git a/hw/xfree86/os-support/linux/lnx_platform.c b/hw/xfree86/os-support/linux/lnx_platform.c
59
 
index 76f5583..11bb9fc 100644
60
96
--- a/hw/xfree86/os-support/linux/lnx_platform.c
61
97
+++ b/hw/xfree86/os-support/linux/lnx_platform.c
62
 
@@ -17,36 +17,6 @@
 
98
@@ -17,8 +17,8 @@
63
99
 
64
100
 #include "hotplug.h"
65
101
 
66
102
-static Bool
67
103
-get_drm_info(struct OdevAttributes *attribs, char *path)
68
 
-{
69
 
-    drmSetVersion sv;
70
 
-    char *buf;
71
 
-    int fd;
72
 
-
73
 
-    fd = open(path, O_RDWR, O_CLOEXEC);
74
 
-    if (fd == -1)
 
104
+static void
 
105
+set_drm_info(const char *path)
 
106
 {
 
107
     drmSetVersion sv;
 
108
     char *buf;
 
109
@@ -26,25 +26,23 @@
 
110
 
 
111
     fd = open(path, O_RDWR, O_CLOEXEC);
 
112
     if (fd == -1)
75
113
-        return FALSE;
76
 
-
77
 
-    sv.drm_di_major = 1;
78
 
-    sv.drm_di_minor = 4;
79
 
-    sv.drm_dd_major = -1;       /* Don't care */
80
 
-    sv.drm_dd_minor = -1;       /* Don't care */
81
 
-    if (drmSetInterfaceVersion(fd, &sv)) {
 
114
+        return;
 
115
 
 
116
     sv.drm_di_major = 1;
 
117
     sv.drm_di_minor = 4;
 
118
     sv.drm_dd_major = -1;       /* Don't care */
 
119
     sv.drm_dd_minor = -1;       /* Don't care */
 
120
     if (drmSetInterfaceVersion(fd, &sv)) {
82
121
-        ErrorF("setversion 1.4 failed\n");
83
122
-        return FALSE;
84
 
-    }
85
 
-
 
123
+        ErrorF("setversion 1.4 failed on %s: %m\n", path);
 
124
+        close(fd);
 
125
+        return;
 
126
     }
 
127
 
86
128
-    xf86_add_platform_device(attribs);
87
129
-
88
 
-    buf = drmGetBusid(fd);
89
 
-    xf86_add_platform_device_attrib(xf86_num_platform_devices - 1,
90
 
-                                    ODEV_ATTRIB_BUSID, buf);
91
 
-    drmFreeBusid(buf);
 
130
     buf = drmGetBusid(fd);
 
131
+    close(fd);
 
132
     xf86_add_platform_device_attrib(xf86_num_platform_devices - 1,
 
133
                                     ODEV_ATTRIB_BUSID, buf);
 
134
     drmFreeBusid(buf);
92
135
-    close(fd);
93
136
-    return TRUE;
94
 
-}
95
 
-
 
137
 }
 
138
 
96
139
 Bool
97
 
 xf86PlatformDeviceCheckBusID(struct xf86_platform_device *device, const char *busid)
 
140
@@ -93,14 +91,15 @@
98
141
 {
99
 
@@ -119,10 +89,7 @@ xf86PlatformDeviceProbe(struct OdevAttributes *attribs)
 
142
     struct OdevAttribute *attrib;
 
143
     int i;
 
144
-    char *path = NULL;
 
145
-    Bool ret;
 
146
+    const char *path = NULL, *busid = NULL, *syspath = NULL;
 
147
 
 
148
     xorg_list_for_each_entry(attrib, &attribs->list, member) {
 
149
-        if (attrib->attrib_id == ODEV_ATTRIB_PATH) {
 
150
+        if (attrib->attrib_id == ODEV_ATTRIB_PATH)
 
151
             path = attrib->attrib_name;
 
152
-            break;
 
153
-        }
 
154
+        else if (attrib->attrib_id == ODEV_ATTRIB_SYSPATH)
 
155
+            syspath = attrib->attrib_name;
 
156
+        else if (attrib->attrib_id == ODEV_ATTRIB_BUSID)
 
157
+            busid = attrib->attrib_name;
 
158
     }
 
159
     if (!path)
 
160
         goto out_free;
 
161
@@ -119,10 +118,11 @@
100
162
     LogMessage(X_INFO, "config/udev: Adding drm device (%s)\n",
101
163
                path);
102
164
 
103
 
+    xf86_add_platform_device(attribs);
104
165
-    ret = get_drm_info(attribs, path);
105
166
-    if (ret == FALSE)
106
167
-        goto out_free;
107
168
-
 
169
+    xf86_add_platform_device(attribs);
 
170
+    if (!busid) {
 
171
+        LogMessage(X_WARNING, "Could not extract busid from syspath %s, attempting drm probe\n", syspath);
 
172
+        set_drm_info(path);
 
173
+    }
108
174
     return;
109
175
 
110
176
 out_free: