Skip to content

Commit

Permalink
Add support the VM3 screen cast
Browse files Browse the repository at this point in the history
VM3 dgpu passthrough, after probe ivshm, gralloc
will deem it as QNX case.
Check if the first render node is dGPU and
first virtiogpu is ivshm, it is dgpu + ivshm case.

Tracked-On: OAM-124710
Signed-off-by: He, Yue <yue.he@intel.com>
  • Loading branch information
yhe39 committed Sep 27, 2024
1 parent 060e9fb commit 786dae2
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 18 deletions.
40 changes: 23 additions & 17 deletions cros_gralloc/cros_gralloc_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,6 @@ cros_gralloc_driver::cros_gralloc_driver()
drv_kms_ = drv_render_;
}

if (ivshm_node_idx != -1) {
if (!(drv_ivshmem_ = drv_create(node_fd[ivshm_node_idx]))) {
drv_loge("Failed to create driver for the ivshm device with card id %d\n",
ivshm_node_idx);
close(node_fd[ivshm_node_idx]);
}
}

// Init drv
DRV_INIT(drv_render_, gpu_grp_type_, renderer_idx)
if (video_idx != renderer_idx)
Expand All @@ -326,25 +318,39 @@ cros_gralloc_driver::cros_gralloc_driver()
DRV_INIT(drv_kms_, gpu_grp_type_, virtio_node_idx)
if (drv_kms_ && (virtio_node_idx != renderer_idx) && (drv_kms_ != drv_render_)) {
bool virtiopic_with_blob = drv_virtpci_with_blob(drv_kms_);
// The virtio pci device with blob feature could import buffers
// from i915, otherwise need use virtio to allocate scanout
// non-video buffers.
if (virtiopic_with_blob) {
//igpu SRIOV or dGPU SRIOV case
drv_logi("Virtio gpu device with blob\n");
if ((drv_kms_ != drv_render_) && drv_kms_)
DRV_DESTROY(drv_kms_)
drv_kms_ = drv_render_;
} else if (drv_is_dgpu(drv_video_) && drv_virtgpu_is_ivshm(drv_kms_)){
//is dgpu passthrough + ivshm case
drv_logi("dGPU with Virtio ivshm\n");
drv_ivshmem_ = drv_kms_;
drv_kms_ = drv_render_;
if (ivshm_node_idx != -1) {
close(node_fd[ivshm_node_idx]);
ivshm_node_idx = -1;
}
} else {
drv_logi("Virtio ivshmem device or no blob\n");
// is QNX or redhat case
drv_logi("Virtio ivshm or no blob\n");
}
}
if (ivshm_node_idx != -1) {
DRV_INIT(drv_ivshmem_, gpu_grp_type_, ivshm_node_idx)
if (drv_virtgpu_is_ivshm(drv_ivshmem_)) {
drv_logi("Node is virtio-ivishmem node");
if (!(drv_ivshmem_ = drv_create(node_fd[ivshm_node_idx]))) {
drv_loge("Failed to create driver for the ivshm device with card id %d\n",
ivshm_node_idx);
close(node_fd[ivshm_node_idx]);
} else {
drv_logi("Node is NOT virtio-ivishmem node");
DRV_DESTROY(drv_ivshmem_)
DRV_INIT(drv_ivshmem_, gpu_grp_type_, ivshm_node_idx)
if (drv_virtgpu_is_ivshm(drv_ivshmem_)) {
drv_logi("Node is virtio-ivishmem node");
} else {
drv_logi("Node is NOT virtio-ivishmem node");
DRV_DESTROY(drv_ivshmem_)
}
}
}
}
Expand Down
12 changes: 12 additions & 0 deletions drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -857,3 +857,15 @@ bool drv_virtgpu_is_ivshm(struct driver * drv)
}
return ret;
}

bool drv_is_dgpu(struct driver * drv)
{
bool ret = false;
assert(drv);
assert(drv->backend);

if (drv->backend->is_dgpu) {
ret = drv->backend->is_dgpu(drv);
}
return ret;
}
2 changes: 2 additions & 0 deletions drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ bool drv_virtpci_with_blob(struct driver * drv);

bool drv_virtgpu_is_ivshm(struct driver * drv);

bool drv_is_dgpu(struct driver * drv);

enum drv_log_level {
DRV_LOGV,
DRV_LOGD,
Expand Down
1 change: 1 addition & 0 deletions drv_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ struct backend {
uint32_t (*get_max_texture_2d_size)(struct driver *drv);
bool (*virtpci_with_blob)(struct driver *drv);
bool (*virtgpu_is_ivshm)(struct driver *drv);
bool (*is_dgpu)(struct driver *drv);
};

// clang-format off
Expand Down
7 changes: 7 additions & 0 deletions i915.c
Original file line number Diff line number Diff line change
Expand Up @@ -1429,6 +1429,12 @@ static int i915_bo_flush(struct bo *bo, struct mapping *mapping)
return 0;
}

static bool i915_is_dgpu(struct driver *drv)
{
struct i915_device *i915 = drv->priv;
return i915->has_local_mem;
}

const struct backend backend_i915 = {
.name = "i915",
.init = i915_init,
Expand All @@ -1443,6 +1449,7 @@ const struct backend backend_i915 = {
.bo_flush = i915_bo_flush,
.resolve_format_and_use_flags = drv_resolve_format_and_use_flags_helper,
.num_planes_from_modifier = i915_num_planes_from_modifier,
.is_dgpu = i915_is_dgpu,
};

#endif
2 changes: 1 addition & 1 deletion virtgpu_virgl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ static bool virgl_virtpci_with_blob(struct driver *drv) {

static bool virgl_drv_virtgpu_is_ivshm(struct driver *drv) {
struct virgl_priv *prv = (struct virgl_priv *)drv->priv;
return !(prv->dev_feature & VIRTGPU_PARAM_QUERY_DEV_BIT);
return (!(prv->dev_feature & VIRTGPU_PARAM_QUERY_DEV_BIT) && (prv->dev_feature & VIRTGPU_PARAM_RESOURCE_BLOB_BIT));
}

const struct backend virtgpu_virgl = { .name = "virtgpu_virgl",
Expand Down

0 comments on commit 786dae2

Please sign in to comment.