Mir

Merge lp:~andreas-pokorny/mir/fix-1417581 into lp:mir

Proposed by Andreas Pokorny
Status: Merged
Approved by: Gerry Boland
Approved revision: no longer in the source branch.
Merged at revision: 2320
Proposed branch: lp:~andreas-pokorny/mir/fix-1417581
Merge into: lp:mir
Diff against target: 63 lines (+31/-3)
1 file modified
src/platforms/mesa/server/cursor.cpp (+31/-3)
To merge this branch: bzr merge lp:~andreas-pokorny/mir/fix-1417581
Reviewer Review Type Date Requested Status
Gerry Boland (community) functional Approve
PS Jenkins bot (community) continuous-integration Approve
Daniel van Vugt Approve
Alexandros Frantzis (community) Approve
Review via email: mp+249636@code.launchpad.net

Commit message

Fix corrupt AMD/radeon cursor again (LP: #1417581)

Include the omitted parts back into the bugfix

Back then when the cursor issue of radeons and kaveris was handled I omitted this check to simplify the fix. This part was necessary to make GBM return correct stride sizes. GBM seems to stick to the size provided on construction, and does not verify what buffer was returned by the driver. Yes this is broken in GBM, but we are currently not alone with this workaround.

Description of the change

Back when this bug first fixed we had two checks for the buffer sizes of cursors. In the process of the review I omitted one. But this check is essential, as it changes the size used in the request.

This MP adds the check again.

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

So, the assumption is that the cursor buffer returned by the driver has dimensions equal to DRM_CAP_CURSOR_WIDTH/HEIGHT; it seem reasonable although it's not clear if these dimensions represent the maximum, the preferred or the only acceptable cursor sizes.

> "Yes this is broken in GBM, but we are currently not alone with this workaround."

Looking at the GBM code, I would say that this is a problem with DRI apis. GBM is asking DRI for a WxH image and DRI is silently returning a differently sized image instead of failing? Not good API design.

review: Approve
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

Yes, I suggest we apply the fix for us, but keep the bug open for mesa.. Untill we entirely drop using this API and switch to the plane API..

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Happy to get a fix. Sad Mesa/GBM is still broken. I think I saw this same workaround in Weston. Sorry I made you remove it before; I didn't know just how broken Mesa is.

P.S. Can you make that comment point to the upstream Mesa bug URL? Create it if necessary.

P.P.S. Gerry needs to test this.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

Works!

review: Approve (functional)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/platforms/mesa/server/cursor.cpp'
2--- src/platforms/mesa/server/cursor.cpp 2015-01-22 09:00:14 +0000
3+++ src/platforms/mesa/server/cursor.cpp 2015-02-16 09:03:15 +0000
4@@ -24,6 +24,9 @@
5 #include "mir/geometry/rectangle.h"
6 #include "mir/graphics/cursor_image.h"
7
8+#include <xf86drm.h>
9+#include <drm/drm.h>
10+
11 #include <boost/exception/errinfo_errno.hpp>
12
13 #include <stdexcept>
14@@ -35,7 +38,7 @@
15
16 namespace
17 {
18-const uint64_t requested_cursor_size = 64;
19+const uint64_t fallback_cursor_size = 64;
20
21 // Transforms a relative position within the display bounds described by \a rect which is rotated with \a orientation
22 geom::Displacement transform(geom::Rectangle const& rect, geom::Displacement const& vector, MirOrientation orientation)
23@@ -53,13 +56,38 @@
24 return vector;
25 }
26 }
27+// support for older drm headers
28+#ifndef DRM_CAP_CURSOR_WIDTH
29+#define DRM_CAP_CURSOR_WIDTH 0x8
30+#define DRM_CAP_CURSOR_HEIGHT 0x9
31+#endif
32+
33+// In certain combinations of DRI backends and drivers GBM
34+// returns a stride size that matches the requested buffers size,
35+// instead of the underlying buffer:
36+// https://bugs.freedesktop.org/show_bug.cgi?id=89164
37+int get_drm_cursor_height(int fd)
38+{
39+ uint64_t height;
40+ if (drmGetCap(fd, DRM_CAP_CURSOR_HEIGHT, &height) < 0)
41+ height = fallback_cursor_size;
42+ return int(height);
43+}
44+
45+int get_drm_cursor_width(int fd)
46+{
47+ uint64_t width;
48+ if (drmGetCap(fd, DRM_CAP_CURSOR_WIDTH, &width) < 0)
49+ width = fallback_cursor_size;
50+ return int(width);
51+}
52 }
53
54 mgm::Cursor::GBMBOWrapper::GBMBOWrapper(gbm_device* gbm) :
55 buffer(gbm_bo_create(
56 gbm,
57- requested_cursor_size,
58- requested_cursor_size,
59+ get_drm_cursor_width(gbm_device_get_fd(gbm)),
60+ get_drm_cursor_height(gbm_device_get_fd(gbm)),
61 GBM_FORMAT_ARGB8888,
62 GBM_BO_USE_CURSOR | GBM_BO_USE_WRITE))
63 {

Subscribers

People subscribed via source and target branches