[Mesa-dev] [PATCH 1/1] radeonsi: Use libdrm to get chipset name

Nicolai Hähnle nhaehnle at gmail.com
Thu May 4 11:12:10 UTC 2017


On 03.05.2017 18:59, Li, Samuel wrote:
> Thanks for the comments. I was thinking probably marketing names only make sense for amdgpu, but I am OK to add a pointer to radeon_winsys. Will send a v2 later.

We won't have marketing names when using radeon. The point is that the 
code still needs to work correctly: only call amdgpu functions when 
amdgpu is really used.

Thanks,
Nicolai


>
> Sam
>
>
> -----Original Message-----
> From: Nicolai Hähnle [mailto:nhaehnle at gmail.com]
> Sent: Wednesday, May 03, 2017 12:17 PM
> To: Li, Samuel <Samuel.Li at amd.com>; mesa-dev at lists.freedesktop.org
> Subject: Re: [Mesa-dev] [PATCH 1/1] radeonsi: Use libdrm to get chipset name
>
> Hi Sam,
>
> Please use git send-email in the future, it doesn't mess up the formatting :)
>
> This is generally not how we do winsys things, because radeon needs to be supported in addition to amdgpu. The usual approach is to add a new callback function pointer to struct radeon_winsys, in this case get_chip_name. This pointer can be set to amdgpu_get_chip_name in the amdgpu winsys.
>
> r600_get_chip_name then calls that function, with a check to make sure that the function pointer is non-NULL (which will happen for the radeon winsys).
>
> Cheers,
> Nicolai
>
>
>
> On 02.05.2017 23:51, Li, Samuel wrote:
>> From f097509a17a6ddf6a0f40fb1b73f289227a9539a Mon Sep 17 00:00:00 2001
>>
>> From: Samuel Li <Samuel.Li at amd.com>
>>
>> Date: Thu, 27 Apr 2017 13:45:24 -0400
>>
>> Subject: [PATCH 1/1] radeonsi: Use libdrm to get chipset name
>>
>>
>>
>> Change-Id: I614ea71424f9e5c97e4ae68654315d28c89eaa5f
>>
>> Signed-off-by: Samuel Li <Samuel.Li at amd.com>
>>
>> ---
>>
>> src/gallium/drivers/radeon/r600_pipe_common.c | 10 +++++++++-
>>
>> src/gallium/winsys/amdgpu/drm/amdgpu_public.h |  1 +
>>
>> src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c |  7 +++++++
>>
>> 3 files changed, 17 insertions(+), 1 deletion(-)
>>
>>
>>
>> diff --git a/src/gallium/drivers/radeon/r600_pipe_common.c
>> b/src/gallium/drivers/radeon/r600_pipe_common.c
>>
>> index ce84139..b4f9beb 100644
>>
>> --- a/src/gallium/drivers/radeon/r600_pipe_common.c
>>
>> +++ b/src/gallium/drivers/radeon/r600_pipe_common.c
>>
>> @@ -36,6 +36,7 @@
>>
>> #include "vl/vl_decoder.h"
>>
>> #include "vl/vl_video_buffer.h"
>>
>> #include "radeon/radeon_video.h"
>>
>> +#include "gallium/winsys/amdgpu/drm/amdgpu_public.h"
>>
>> #include <inttypes.h>
>>
>> #include <sys/utsname.h>
>>
>> @@ -788,6 +789,13 @@ static const char* r600_get_device_vendor(struct
>> pipe_screen* pscreen)
>>
>>  static const char* r600_get_chip_name(struct r600_common_screen
>> *rscreen)
>>
>> {
>>
>> +             const char *mname = amdgpu_get_chip_name(rscreen->ws);
>>
>> +
>>
>> +             if (mname != NULL) {
>>
>> +                             return mname;
>>
>> +             }
>>
>> +
>>
>> +             /* fall back to family names*/
>>
>>                switch (rscreen->info.family) {
>>
>>                case CHIP_R600: return "AMD R600";
>>
>>                case CHIP_RV610: return "AMD RV610";
>>
>> @@ -1314,6 +1322,7 @@ bool r600_common_screen_init(struct
>> r600_common_screen *rscreen,
>>
>>                struct utsname uname_data;
>>
>>                 ws->query_info(ws, &rscreen->info);
>>
>> +             rscreen->ws = ws;
>>
>>                 if (uname(&uname_data) == 0)
>>
>>                                snprintf(kernel_version,
>> sizeof(kernel_version),
>>
>> @@ -1355,7 +1364,6 @@ bool r600_common_screen_init(struct
>> r600_common_screen *rscreen,
>>
>>                r600_init_screen_texture_functions(rscreen);
>>
>>                r600_init_screen_query_functions(rscreen);
>>
>> -              rscreen->ws = ws;
>>
>>                rscreen->family = rscreen->info.family;
>>
>>                rscreen->chip_class = rscreen->info.chip_class;
>>
>>                rscreen->debug_flags =
>> debug_get_flags_option("R600_DEBUG", common_debug_options, 0);
>>
>> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_public.h
>> b/src/gallium/winsys/amdgpu/drm/amdgpu_public.h
>>
>> index ad133b2..8a50c4d 100644
>>
>> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_public.h
>>
>> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_public.h
>>
>> @@ -34,6 +34,7 @@ struct pipe_screen;
>>
>>  typedef struct pipe_screen *(*radeon_screen_create_t)(struct
>> radeon_winsys *);
>>
>> +const char* amdgpu_get_chip_name(struct radeon_winsys *ws);
>>
>> struct radeon_winsys *
>>
>> amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create);
>>
>> diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
>> b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
>>
>> index f3a0c95..0c8c329 100644
>>
>> --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
>>
>> +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
>>
>> @@ -532,6 +532,13 @@ static bool amdgpu_winsys_unref(struct
>> radeon_winsys *rws)
>>
>>     return destroy;
>>
>> }
>>
>> +const char* amdgpu_get_chip_name(struct radeon_winsys *ws)
>>
>> +{
>>
>> +             amdgpu_device_handle dev = ((struct amdgpu_winsys
>> + *)ws)->dev;
>>
>> +             return amdgpu_get_marketing_name(dev);
>>
>> +}
>>
>> +
>>
>> +
>>
>> PUBLIC struct radeon_winsys *
>>
>> amdgpu_winsys_create(int fd, radeon_screen_create_t screen_create)
>>
>> {
>>
>> --
>>
>> 2.7.4
>>
>>
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>>
>
>
> --
> Lerne, wie die Welt wirklich ist,
> Aber vergiss niemals, wie sie sein sollte.
>


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list