[PATCH 07/12] hotplug: Modify OdevAttributes for server-managed fd support

Peter Hutterer peter.hutterer at who-t.net
Mon Jan 27 22:50:43 PST 2014


On Wed, Jan 15, 2014 at 03:32:21PM +0100, Hans de Goede wrote:
> With systemd-logind support, the xserver, rather then the drivers will be

typo, "than"

> responsible for opening/closing the fd for drm nodes.
> 
> The initial open will happen on probe from config/udev.c, this commit adds
> a fd member to OdevAttributes to store the fd to pass it along to the driver.
> 
> The server_fd and paused flags are added to indicate wether server-
> managed fds are in use for this device, and if they are if the device is
> paused (no drm master rights) or not.
> 
> This commit also bumps the video ABI major, as this constitutes an ABI change.
> 
> systemd-logind tracks devices by their chardev major + minor numbers, since
> we are breaking ABI anyways also add major and minor fields for easy storage /
> retreival of these, as well as a utility function for getting a platform

typo, retrieval

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

Cheers,
   Peter

> device by devnum.
> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  config/config.c                     |  6 +++++-
>  hw/xfree86/common/xf86Module.h      |  2 +-
>  hw/xfree86/common/xf86platformBus.c | 13 +++++++++++++
>  include/hotplug.h                   |  9 +++++++++
>  4 files changed, 28 insertions(+), 2 deletions(-)
> 
> diff --git a/config/config.c b/config/config.c
> index 760cf19..07c90eb 100644
> --- a/config/config.c
> +++ b/config/config.c
> @@ -26,6 +26,7 @@
>  #ifdef HAVE_DIX_CONFIG_H
>  #include <dix-config.h>
>  #endif
> +#include <unistd.h>
>  
>  #include "os.h"
>  #include "inputstr.h"
> @@ -130,17 +131,20 @@ config_odev_allocate_attribute_list(void)
>  {
>      struct OdevAttributes *attriblist;
>  
> -    attriblist = malloc(sizeof(struct OdevAttributes));
> +    attriblist = calloc(sizeof(struct OdevAttributes), 1);
>      if (!attriblist)
>          return NULL;
>  
>      xorg_list_init(&attriblist->list);
> +    attriblist->fd = -1;
>      return attriblist;
>  }
>  
>  void
>  config_odev_free_attribute_list(struct OdevAttributes *attribs)
>  {
> +    if (attribs->server_fd)
> +        close(attribs->fd);
>      config_odev_free_attributes(attribs);
>      free(attribs);
>  }
> diff --git a/hw/xfree86/common/xf86Module.h b/hw/xfree86/common/xf86Module.h
> index 96ac3b0..e8c24f2 100644
> --- a/hw/xfree86/common/xf86Module.h
> +++ b/hw/xfree86/common/xf86Module.h
> @@ -80,7 +80,7 @@ typedef enum {
>   * mask is 0xFFFF0000.
>   */
>  #define ABI_ANSIC_VERSION	SET_ABI_VERSION(0, 4)
> -#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(15, 0)
> +#define ABI_VIDEODRV_VERSION	SET_ABI_VERSION(16, 0)
>  #define ABI_XINPUT_VERSION	SET_ABI_VERSION(21, 0)
>  #define ABI_EXTENSION_VERSION	SET_ABI_VERSION(8, 0)
>  #define ABI_FONT_VERSION	SET_ABI_VERSION(0, 6)
> diff --git a/hw/xfree86/common/xf86platformBus.c b/hw/xfree86/common/xf86platformBus.c
> index 5875a91..993d6a4 100644
> --- a/hw/xfree86/common/xf86platformBus.c
> +++ b/hw/xfree86/common/xf86platformBus.c
> @@ -120,6 +120,19 @@ xf86_get_platform_device_unowned(int index)
>      return xf86_platform_devices[index].attribs->unowned;
>  }
>  
> +struct xf86_platform_device *
> +xf86_find_platform_device_by_devnum(int major, int minor)
> +{
> +    int i;
> +
> +    for (i = 0; i < xf86_num_platform_devices; i++) {
> +        struct OdevAttributes *attr = xf86_platform_devices[i].attribs;
> +        if (attr->major == major && attr->minor == minor && attr->server_fd)
> +            return &xf86_platform_devices[i];
> +    }
> +    return NULL;
> +}
> +
>  /*
>   * xf86IsPrimaryPlatform() -- return TRUE if primary device
>   * is a platform device and it matches this one.
> diff --git a/include/hotplug.h b/include/hotplug.h
> index 29a22c4..567edfc 100644
> --- a/include/hotplug.h
> +++ b/include/hotplug.h
> @@ -40,7 +40,12 @@ struct OdevAttribute {
>  
>  struct OdevAttributes {
>      struct xorg_list list;
> +    int fd;
> +    int major;
> +    int minor;
>      Bool unowned;
> +    Bool paused;
> +    Bool server_fd;
>  };
>  
>  struct OdevAttributes *
> @@ -72,4 +77,8 @@ void DeleteGPUDeviceRequest(struct OdevAttributes *attribs);
>  #endif
>  
>  #define ServerIsNotSeat0() (SeatId && strcmp(SeatId, "seat0"))
> +
> +struct xf86_platform_device *
> +xf86_find_platform_device_by_devnum(int major, int minor);
> +
>  #endif                          /* HOTPLUG_H */
> -- 
> 1.8.4.2
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list