freedreno: Device matching based on chip_id
Add support for device matching based on chip_id instead of gpu_id, to handle newer GPUs Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12159>
This commit is contained in:
@@ -39,7 +39,20 @@ struct fd_dev_rec {
|
|||||||
static bool
|
static bool
|
||||||
dev_id_compare(const struct fd_dev_id *a, const struct fd_dev_id *b)
|
dev_id_compare(const struct fd_dev_id *a, const struct fd_dev_id *b)
|
||||||
{
|
{
|
||||||
return a->gpu_id == b->gpu_id;
|
if (a->gpu_id && b->gpu_id) {
|
||||||
|
return a->gpu_id == b->gpu_id;
|
||||||
|
} else {
|
||||||
|
assert(a->chip_id && b->chip_id);
|
||||||
|
/* Match on either:
|
||||||
|
* (a) exact match
|
||||||
|
* (b) device table entry has 0xff wildcard patch_id and core/
|
||||||
|
* major/minor match
|
||||||
|
*/
|
||||||
|
return (a->chip_id == b->chip_id) ||
|
||||||
|
(((a->chip_id & 0xff) == 0xff) &&
|
||||||
|
((a->chip_id & UINT64_C(0xffffff00)) ==
|
||||||
|
(b->chip_id & UINT64_C(0xffffff00))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct fd_dev_info *
|
const struct fd_dev_info *
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#ifndef FREEDRENO_DEVICE_INFO_H
|
#ifndef FREEDRENO_DEVICE_INFO_H
|
||||||
#define FREEDRENO_DEVICE_INFO_H
|
#define FREEDRENO_DEVICE_INFO_H
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@@ -107,11 +108,25 @@ struct fd_dev_info {
|
|||||||
|
|
||||||
struct fd_dev_id {
|
struct fd_dev_id {
|
||||||
uint32_t gpu_id;
|
uint32_t gpu_id;
|
||||||
|
uint64_t chip_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Note that gpu-id should be considered deprecated. For newer a6xx, if
|
||||||
|
* there is no gpu-id, this attempts to generate one from the chip-id.
|
||||||
|
* But that may not work forever, so avoid depending on this for newer
|
||||||
|
* gens
|
||||||
|
*/
|
||||||
static inline uint32_t
|
static inline uint32_t
|
||||||
fd_dev_gpu_id(const struct fd_dev_id *id)
|
fd_dev_gpu_id(const struct fd_dev_id *id)
|
||||||
{
|
{
|
||||||
|
assert(id->gpu_id || id->chip_id);
|
||||||
|
if (!id->gpu_id) {
|
||||||
|
return ((id->chip_id >> 24) & 0xff) * 100 +
|
||||||
|
((id->chip_id >> 16) & 0xff) * 10 +
|
||||||
|
((id->chip_id >> 8) & 0xff);
|
||||||
|
|
||||||
|
}
|
||||||
return id->gpu_id;
|
return id->gpu_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,9 +52,22 @@ def add_gpus(ids, info):
|
|||||||
s.gpus[id] = info
|
s.gpus[id] = info
|
||||||
|
|
||||||
class GPUId(object):
|
class GPUId(object):
|
||||||
def __init__(self, gpu_id, name=None):
|
def __init__(self, gpu_id = None, chip_id = None, name=None):
|
||||||
|
if chip_id == None:
|
||||||
|
assert(gpu_id != None)
|
||||||
|
val = gpu_id
|
||||||
|
core = int(val / 100)
|
||||||
|
val -= (core * 100);
|
||||||
|
major = int(val / 10);
|
||||||
|
val -= (major * 10)
|
||||||
|
minor = val
|
||||||
|
chip_id = (core << 24) | (major << 16) | (minor << 8) | 0xff
|
||||||
|
self.chip_id = chip_id
|
||||||
|
if gpu_id == None:
|
||||||
|
gpu_id = 0
|
||||||
self.gpu_id = gpu_id
|
self.gpu_id = gpu_id
|
||||||
if name == None:
|
if name == None:
|
||||||
|
assert(gpu_id != 0)
|
||||||
name = "FD%d" % gpu_id
|
name = "FD%d" % gpu_id
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
||||||
@@ -272,7 +285,7 @@ add_gpus([
|
|||||||
))
|
))
|
||||||
|
|
||||||
add_gpus([
|
add_gpus([
|
||||||
GPUId(635, "Adreno 7c Gen 3"),
|
GPUId(chip_id=0x06030500, name="Adreno 7c Gen 3"),
|
||||||
], A6xxGPUInfo(
|
], A6xxGPUInfo(
|
||||||
a6xx_gen4,
|
a6xx_gen4,
|
||||||
num_sp_cores = 2,
|
num_sp_cores = 2,
|
||||||
@@ -328,7 +341,7 @@ static const struct fd_dev_info __info${s.info_index(info)} = ${str(info)};
|
|||||||
|
|
||||||
static const struct fd_dev_rec fd_dev_recs[] = {
|
static const struct fd_dev_rec fd_dev_recs[] = {
|
||||||
%for id, info in s.gpus.items():
|
%for id, info in s.gpus.items():
|
||||||
{ {${id.gpu_id}}, "${id.name}", &__info${s.info_index(info)} },
|
{ {${id.gpu_id}, ${hex(id.chip_id)}}, "${id.name}", &__info${s.info_index(info)} },
|
||||||
%endfor
|
%endfor
|
||||||
};
|
};
|
||||||
"""
|
"""
|
||||||
|
@@ -60,6 +60,9 @@ fd_pipe_new2(struct fd_device *dev, enum fd_pipe_id id, uint32_t prio)
|
|||||||
fd_pipe_get_param(pipe, FD_GPU_ID, &val);
|
fd_pipe_get_param(pipe, FD_GPU_ID, &val);
|
||||||
pipe->dev_id.gpu_id = val;
|
pipe->dev_id.gpu_id = val;
|
||||||
|
|
||||||
|
fd_pipe_get_param(pipe, FD_CHIP_ID, &val);
|
||||||
|
pipe->dev_id.chip_id = val;
|
||||||
|
|
||||||
pipe->control_mem = fd_bo_new(dev, sizeof(*pipe->control),
|
pipe->control_mem = fd_bo_new(dev, sizeof(*pipe->control),
|
||||||
0, "pipe-control");
|
0, "pipe-control");
|
||||||
pipe->control = fd_bo_map(pipe->control_mem);
|
pipe->control = fd_bo_map(pipe->control_mem);
|
||||||
|
@@ -245,7 +245,7 @@ msm_pipe_new(struct fd_device *dev, enum fd_pipe_id id, uint32_t prio)
|
|||||||
if (fd_device_version(pipe->dev) >= FD_VERSION_GMEM_BASE)
|
if (fd_device_version(pipe->dev) >= FD_VERSION_GMEM_BASE)
|
||||||
msm_pipe->gmem_base = get_param(pipe, MSM_PARAM_GMEM_BASE);
|
msm_pipe->gmem_base = get_param(pipe, MSM_PARAM_GMEM_BASE);
|
||||||
|
|
||||||
if (!msm_pipe->gpu_id)
|
if (!(msm_pipe->gpu_id || msm_pipe->chip_id))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
INFO_MSG("Pipe Info:");
|
INFO_MSG("Pipe Info:");
|
||||||
|
@@ -451,6 +451,12 @@ tu_drm_device_init(struct tu_physical_device *device,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tu_drm_get_param(device, MSM_PARAM_CHIP_ID, &device->dev_id.chip_id)) {
|
||||||
|
result = vk_startup_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||||
|
"could not get CHIP ID");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
if (tu_drm_get_gmem_size(device, &device->gmem_size)) {
|
if (tu_drm_get_gmem_size(device, &device->gmem_size)) {
|
||||||
result = vk_startup_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
|
result = vk_startup_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||||
"could not get GMEM size");
|
"could not get GMEM size");
|
||||||
|
@@ -243,6 +243,7 @@ tu_enumerate_devices(struct tu_instance *instance)
|
|||||||
((info.chip_id >> 24) & 0xff) * 100 +
|
((info.chip_id >> 24) & 0xff) * 100 +
|
||||||
((info.chip_id >> 16) & 0xff) * 10 +
|
((info.chip_id >> 16) & 0xff) * 10 +
|
||||||
((info.chip_id >> 8) & 0xff);
|
((info.chip_id >> 8) & 0xff);
|
||||||
|
device->dev_id.chip_id = info.chip_id;
|
||||||
device->gmem_size = info.gmem_sizebytes;
|
device->gmem_size = info.gmem_sizebytes;
|
||||||
device->gmem_base = gmem_iova;
|
device->gmem_base = gmem_iova;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user