[PATCH xf86-video-ati] ati: Support loading the amdgpu driver from the ati wrapper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 18, 2017 at 5:08 AM, Michel Dänzer <michel at daenzer.net> wrote:
> From: Michel Dänzer <michel.daenzer at amd.com>
>
> If .../share/X11/xorg.conf.d/10-amdgpu.conf doesn't exist, but the ati
> wrapper is loaded, it will otherwise try to use the radeon driver even
> for GPUs driven by the amdgpu kernel driver. This can only fail,
> potentially in bad ways.
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>

Reviewed-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  src/ati.c | 40 ++++++++++++++++++++++++++++++++++++----
>  1 file changed, 36 insertions(+), 4 deletions(-)
>
> diff --git a/src/ati.c b/src/ati.c
> index 227665e73..d5294df09 100644
> --- a/src/ati.c
> +++ b/src/ati.c
> @@ -58,6 +58,7 @@
>  #endif
>
>  #include <pciaccess.h>
> +#include <xf86drm.h>
>  #include "atipcirename.h"
>
>  #include "ati.h"
> @@ -68,6 +69,7 @@
>  #define MACH64_DRIVER_NAME  "mach64"
>  #define R128_DRIVER_NAME    "r128"
>  #define RADEON_DRIVER_NAME  "radeon"
> +#define AMDGPU_DRIVER_NAME  "amdgpu"
>
>  enum
>  {
> @@ -140,9 +142,9 @@ ati_device_get_indexed(int index)
>  void
>  ati_gdev_subdriver(pointer options)
>  {
> -    int      nATIGDev, nMach64GDev, nR128GDev, nRadeonGDev;
> +    int      nATIGDev, nMach64GDev, nR128GDev, nRadeonGDev, nAmdgpuGDev;
>      GDevPtr *ATIGDevs;
> -    Bool     load_mach64 = FALSE, load_r128 = FALSE, load_radeon = FALSE;
> +    Bool     load_mach64 = FALSE, load_r128 = FALSE, load_radeon = FALSE, load_amdgpu = FALSE;
>      int      i;
>
>      /* let the subdrivers configure for themselves */
> @@ -154,6 +156,7 @@ ati_gdev_subdriver(pointer options)
>      nMach64GDev = xf86MatchDevice(MACH64_DRIVER_NAME, NULL);
>      nR128GDev = xf86MatchDevice(R128_DRIVER_NAME, NULL);
>      nRadeonGDev = xf86MatchDevice(RADEON_DRIVER_NAME, NULL);
> +    nAmdgpuGDev = xf86MatchDevice(AMDGPU_DRIVER_NAME, NULL);
>
>      for (i = 0; i < nATIGDev; i++) {
>          GDevPtr     ati_gdev = ATIGDevs[i];
> @@ -200,8 +203,34 @@ ati_gdev_subdriver(pointer options)
>          }
>
>          if (chip_family == ATI_CHIP_FAMILY_Radeon) {
> -            ati_gdev->driver = RADEON_DRIVER_NAME;
> -            load_radeon = TRUE;
> +           char *busid;
> +
> +           XNFasprintf(&busid, "pci:%04x:%02x:%02x.%d",
> +                       device->domain, device->bus, device->dev,
> +                       device->func);
> +
> +           if (busid) {
> +               int fd = drmOpen(NULL, busid);
> +
> +               if (fd >= 0) {
> +                   drmVersionPtr version = drmGetVersion(fd);
> +
> +                   if (version->version_major == 3) {
> +                       ati_gdev->driver = AMDGPU_DRIVER_NAME;
> +                       load_amdgpu = TRUE;
> +                   }
> +
> +                   free(version);
> +                   drmClose(fd);
> +               }
> +
> +               free(busid);
> +           }
> +
> +           if (strcmp(ati_gdev->driver, AMDGPU_DRIVER_NAME) != 0) {
> +               ati_gdev->driver = RADEON_DRIVER_NAME;
> +               load_radeon = TRUE;
> +           }
>          }
>      }
>
> @@ -219,6 +248,9 @@ ati_gdev_subdriver(pointer options)
>
>      if (load_radeon && (nRadeonGDev == 0))
>           xf86LoadOneModule(RADEON_DRIVER_NAME, options);
> +
> +    if (load_amdgpu && (nAmdgpuGDev == 0))
> +         xf86LoadOneModule(AMDGPU_DRIVER_NAME, options);
>  }
>
>  /*
> --
> 2.11.0
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx


[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux