Revisiting the issue of obtaining Xorg commit privilege

2018-07-06 Thread Kevin Brace
Hi,

I have not seen any movement in obtaining xorg/driver commit privilege.

https://bugs.freedesktop.org/show_bug.cgi?id=106605

Please note that several of my r128 DDX patches have been committed by Connor 
Behan.

Regards,

Kevin Brace
Brace Computer Laboratory blog
https://bracecomputerlab.com
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xf86-video-amdgpu 3/3] Add RandR leases with modesetting driver support [v7]

2018-07-06 Thread Keith Packard
This adds support for RandR CRTC/Output leases through the modesetting
driver, creating a lease using new kernel infrastructure and returning
that to a client through an fd which will have access to only those
resources.

v2: Restore CRTC mode when leases terminate

When a lease terminates for a crtc we have saved data for, go
ahead and restore the saved mode.

v3: Report RR_Rotate_0 rotations for leased crtcs.

Ignore leased CRTCs when selecting screen size.

Stop leasing encoders, the kernel doesn't do that anymore.

Turn off crtc->enabled while leased so that modesetting
ignores them.

Check lease status before calling any driver mode functions

When starting a lease, mark leased CRTCs as disabled and hide
their cursors. Also, check to see if there are other
non-leased CRTCs which are driving leased Outputs and mark
them as disabled as well. Sometimes an application will lease
an idle crtc instead of the one already associated with the
leased output.

When terminating a lease, reset any CRTCs which are driving
outputs that are no longer leased so that they start working
again.

This required splitting the DIX level lease termination code
into two pieces, one to remove the lease from the system
(RRLeaseTerminated) and a new function that frees the lease
data structure (RRLeaseFree).

v4: Report RR_Rotate_0 rotation for leased crtcs.

v5: Terminate all leases on server reset.

Leases hang around after the associated client exits so that
the client doesn't need to occupy an X server client slot and
consume a file descriptor once it has gotten the output
resources necessary.

Any leases still hanging around when the X server resets or
shuts down need to be cleaned up by calling the kernel to
terminate the lease and freeing any DIX structures.

Note that we cannot simply use the existing
drmmode_terminate_lease function on each lease as that wants
to also reset the video mode, and during server shut down that

   modesetting: Validate leases on VT enter

The kernel doesn't allow any master ioctls to run when another
VT is active, including simple things like listing the active
leases. To deal with that, we check the list of leases
whenever the X server VT is activated.

   xfree86: hide disabled cursors when resetting after lease termination

The lessee may well have played with cursors and left one
active on our screen. Just tell the kernel to turn it off.

v6: Add meson build infrastructure

v7:
Make it build on X server 1.13
Remove drmmode_terminate_leases

Signed-off-by: Keith Packard 
Reviewed-by: Adam Jackson 
---
 configure.ac  |  18 ++
 src/drmmode_display.c | 137 +-
 src/drmmode_display.h |   5 ++
 3 files changed, 159 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 378b5aa..d56e519 100644
--- a/configure.ac
+++ b/configure.ac
@@ -54,6 +54,14 @@ if test "x$GCC" = "xyes"; then
CPPFLAGS="$CPPFLAGS -Wall"
 fi
 
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include 
+#ifndef __GLIBC__
+#error not glibc
+#endif
+]], [])], [AC_DEFINE(_GNU_SOURCE, 1,
+   [ Enable GNU and other extensions to the C environment for glibc])])
+
 AH_TOP([#include "xorg-server.h"])
 
 # Define a configure option for an alternate module directory
@@ -170,6 +178,12 @@ AC_CHECK_DECL(RROutputSetNonDesktop,
  [#include 
   #include ])
 
+AC_CHECK_DECL(RRDeliverLeaseEvent,
+ [AC_DEFINE(HAVE_RRLEASE, 1,
+ [Have RandR lease support API])], [],
+ [#include 
+  #include ])
+
 AC_CHECK_DECL(fbGlyphs,
  [AC_DEFINE(HAVE_FBGLYPHS, 1, [Have fbGlyphs API])], [],
  [#include 
@@ -209,6 +223,8 @@ AC_CHECK_HEADERS([dri3.h], [], [],
 
 CPPFLAGS="$SAVE_CPPFLAGS"
 
+AC_CHECK_LIB([bsd], [arc4random_buf])
+
 # Checks for headers/macros for byte swapping
 # Known variants:
 #   bswap_16, bswap_32, bswap_64  (glibc)
@@ -219,6 +235,8 @@ CPPFLAGS="$SAVE_CPPFLAGS"
 # if  is found, assume it's the correct version
 AC_CHECK_HEADERS([byteswap.h])
 
+AC_REPLACE_FUNCS([reallocarray])
+
 # if  is found, have to check which version
 AC_CHECK_HEADER([sys/endian.h], [HAVE_SYS_ENDIAN_H="yes"], 
[HAVE_SYS_ENDIAN_H="no"])
 
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 914086d..84a355c 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2934,8 +2934,138 @@ fail:
return FALSE;
 }
 
+#ifdef HAVE_RRLEASE
+
+static void
+drmmode_validate_leases(ScrnInfoPtr scrn)
+{
+   ScreenPtr screen = scrn->pScreen;
+   rrScrPrivPtr scr_priv = rrGetScrPriv(screen);
+   AMDGPUEntPtr pAMDGPUEnt = AMDGPUEntPriv(scrn);
+   

[PATCH xf86-video-amdgpu 1/3] xf86-video-modesetting: Record non-desktop kernel property at PreInit time [v2]

2018-07-06 Thread Keith Packard
Save any value of the kernel non-desktop property in the xf86Output
structure to avoid non-desktop outputs in the default configuration.

v2: Support X server 1.13

Signed-off-by: Keith Packard 
Reviewed-by: Adam Jackson 
---
 configure.ac  |  6 ++
 src/drmmode_display.c | 15 ++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 2593f52..378b5aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -164,6 +164,12 @@ AC_CHECK_DECL(RegionDuplicate,
  [#include 
   #include ])
 
+AC_CHECK_DECL(RROutputSetNonDesktop,
+ [AC_DEFINE(HAVE_NONDESKTOP, 1,
+ [Have non-desktop property support API])], [],
+ [#include 
+  #include ])
+
 AC_CHECK_DECL(fbGlyphs,
  [AC_DEFINE(HAVE_FBGLYPHS, 1, [Have fbGlyphs API])], [],
  [#include 
diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 9364a88..92cb947 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2597,6 +2597,9 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr 
drmmode, drmModeResPtr mode_r
drmModePropertyBlobPtr path_blob = NULL;
char name[32];
int i;
+#ifdef HAVE_NONDESKTOP
+   Bool nonDesktop = FALSE;
+#endif
const char *s;
 
koutput =
@@ -2606,6 +2609,11 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr 
drmmode, drmModeResPtr mode_r
return 0;
 
path_blob = koutput_get_prop_blob(pAMDGPUEnt->fd, koutput, "PATH");
+#ifdef HAVE_NONDESKTOP
+   i = koutput_get_prop_idx(pAMDGPUEnt->fd, koutput, DRM_MODE_PROP_RANGE, 
RR_PROPERTY_NON_DESKTOP);
+   if (i >= 0)
+   nonDesktop = koutput->prop_values[i] != 0;
+#endif
 
kencoders = calloc(sizeof(drmModeEncoderPtr), koutput->count_encoders);
if (!kencoders) {
@@ -2638,6 +2646,9 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr 
drmmode, drmModeResPtr mode_r
drmmode_output = output->driver_private;
drmmode_output->output_id = mode_res->connectors[num];
drmmode_output->mode_output = koutput;
+#ifdef HAVE_NONDESKTOP
+   output->non_desktop = nonDesktop;
+#endif
for (i = 0; i < koutput->count_encoders; i++) {
drmModeFreeEncoder(kencoders[i]);
}
@@ -2681,7 +2692,9 @@ drmmode_output_init(ScrnInfoPtr pScrn, drmmode_ptr 
drmmode, drmModeResPtr mode_r
output->interlaceAllowed = TRUE;
output->doubleScanAllowed = TRUE;
output->driver_private = drmmode_output;
-
+#ifdef HAVE_NONDESKTOP
+   output->non_desktop = nonDesktop;
+#endif
output->possible_crtcs = 0x;
for (i = 0; i < koutput->count_encoders; i++) {
output->possible_crtcs &= kencoders[i]->possible_crtcs;
-- 
2.17.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xf86-video-amdgpu 0/3] Add RandR lease support [v2]

2018-07-06 Thread Keith Packard
When we last saw these patches, they required current X server bits to build,
while the project requires that the driver build back to X server 1.13. I've
added suitable checks and wrapped the new code in #ifdefs now.

If I don't hear any complaints in a few days (given that we're at the boundary
of a weekend), I'll go ahead and push these.

-keith


___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

[PATCH xf86-video-amdgpu 2/3] xf86-video-modesetting: Create CONNECTOR_ID properties for outputs [v2]

2018-07-06 Thread Keith Packard
This lets a DRM client map between X outputs and kernel connectors.

v2:
Change CONNECTOR_ID to enum -- Adam Jackson 

Signed-off-by: Keith Packard 
Reviewed-by: Adam Jackson 
---
 src/drmmode_display.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 92cb947..914086d 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -2229,6 +2229,29 @@ static void 
drmmode_output_create_resources(xf86OutputPtr output)
drmmode_output->tear_free = info->tear_free;
drmmode_output->num_props++;
 
+   /* Create CONNECTOR_ID property */
+   {
+   Atomname = MakeAtom("CONNECTOR_ID", 12, TRUE);
+   INT32   value = mode_output->connector_id;
+
+   if (name != BAD_RESOURCE) {
+   err = RRConfigureOutputProperty(output->randr_output, 
name,
+   FALSE, FALSE, TRUE,
+   1, );
+   if (err != 0) {
+   xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+  "RRConfigureOutputProperty error, 
%d\n", err);
+   }
+   err = RRChangeOutputProperty(output->randr_output, name,
+XA_INTEGER, 32, 
PropModeReplace, 1,
+, FALSE, FALSE);
+   if (err != 0) {
+   xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+  "RRChangeOutputProperty error, 
%d\n", err);
+   }
+   }
+   }
+
for (i = 0; i < drmmode_output->num_props; i++) {
drmmode_prop_ptr p = _output->props[i];
drmmode_prop = p->mode_prop;
-- 
2.17.1

___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCHv3] modesetting: Update fb_id from shadow allocate and destroy if not set

2018-07-06 Thread Tony Lindgren
* Michel Dänzer  [180706 07:48]:
> On 2018-07-05 05:42 PM, Tony Lindgren wrote:
> > Hi,
> > 
> > * Michel Dänzer  [180705 14:21]:
> >>
> >> This uses the same damage region for all framebuffers, which is
> >> generally not correct for drmmode_crtc->rotate_fb_id. The coordinate
> >> offset, rotation and reflection need to be taken into account for that.
> > 
> > Hmm OK. I thought we just need to refresh it we have
> > rotate_fb_id.
> > 
> > Unfortunately I have no idea what the check here might be
> > for the variables above.. Sounds like it might leave out
> > some pointless updates though :) Care to describe a bit
> > more or ideally even provide a patch to test?
> 
> The simplest solution is probably to use separate damage records
> attached to the per-CRTC rotation pixmaps.

Sorry but I still have no idea what needs to be checked
with rotate_fb_id and rotation pixmaps before updating
the display..

Regards,

Tony
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel

Re: [PATCHv3] modesetting: Update fb_id from shadow allocate and destroy if not set

2018-07-06 Thread Michel Dänzer
On 2018-07-05 05:42 PM, Tony Lindgren wrote:
> Hi,
> 
> * Michel Dänzer  [180705 14:21]:
>>
>> This uses the same damage region for all framebuffers, which is
>> generally not correct for drmmode_crtc->rotate_fb_id. The coordinate
>> offset, rotation and reflection need to be taken into account for that.
> 
> Hmm OK. I thought we just need to refresh it we have
> rotate_fb_id.
> 
> Unfortunately I have no idea what the check here might be
> for the variables above.. Sounds like it might leave out
> some pointless updates though :) Care to describe a bit
> more or ideally even provide a patch to test?

The simplest solution is probably to use separate damage records
attached to the per-CRTC rotation pixmaps.


-- 
Earthling Michel Dänzer   |   http://www.amd.com
Libre software enthusiast | Mesa and X developer
___
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: https://lists.x.org/mailman/listinfo/xorg-devel