Message ID | 20230815003526.631-5-gurchetansingh@chromium.org (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | gfxstream + rutabaga_gfx | expand |
Reviewed-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org> Tested-by: Emmanouil Pitsidianakis <manos.pitsidianakis@linaro.org> On Tue, 15 Aug 2023 03:35, Gurchetan Singh <gurchetansingh@chromium.org> wrote: >From: Antonio Caggiano <antonio.caggiano@collabora.com> > >This adds preparatory functions needed to: > > - decode blob cmds > - tracking iovecs > >Signed-off-by: Antonio Caggiano <antonio.caggiano@collabora.com> >Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> >Signed-off-by: Gurchetan Singh <gurchetansingh@chromium.org> >Tested-by: Alyssa Ross <hi@alyssa.is> >--- > hw/display/virtio-gpu.c | 10 +++------- > include/hw/virtio/virtio-gpu-bswap.h | 18 ++++++++++++++++++ > include/hw/virtio/virtio-gpu.h | 5 +++++ > 3 files changed, 26 insertions(+), 7 deletions(-) > >diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c >index 48ef0d9fad..3e658f1fef 100644 >--- a/hw/display/virtio-gpu.c >+++ b/hw/display/virtio-gpu.c >@@ -33,15 +33,11 @@ > > #define VIRTIO_GPU_VM_VERSION 1 > >-static struct virtio_gpu_simple_resource* >-virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); > static struct virtio_gpu_simple_resource * > virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t resource_id, > bool require_backing, > const char *caller, uint32_t *error); > >-static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, >- struct virtio_gpu_simple_resource *res); > static void virtio_gpu_reset_bh(void *opaque); > > void virtio_gpu_update_cursor_data(VirtIOGPU *g, >@@ -116,7 +112,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor) > cursor->resource_id ? 1 : 0); > } > >-static struct virtio_gpu_simple_resource * >+struct virtio_gpu_simple_resource * > virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id) > { > struct virtio_gpu_simple_resource *res; >@@ -904,8 +900,8 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, > g_free(iov); > } > >-static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, >- struct virtio_gpu_simple_resource *res) >+void virtio_gpu_cleanup_mapping(VirtIOGPU *g, >+ struct virtio_gpu_simple_resource *res) > { > virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); > res->iov = NULL; >diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virtio-gpu-bswap.h >index 9124108485..dd1975e2d4 100644 >--- a/include/hw/virtio/virtio-gpu-bswap.h >+++ b/include/hw/virtio/virtio-gpu-bswap.h >@@ -63,10 +63,28 @@ virtio_gpu_create_blob_bswap(struct virtio_gpu_resource_create_blob *cblob) > { > virtio_gpu_ctrl_hdr_bswap(&cblob->hdr); > le32_to_cpus(&cblob->resource_id); >+ le32_to_cpus(&cblob->blob_mem); > le32_to_cpus(&cblob->blob_flags); >+ le32_to_cpus(&cblob->nr_entries); >+ le64_to_cpus(&cblob->blob_id); > le64_to_cpus(&cblob->size); > } > >+static inline void >+virtio_gpu_map_blob_bswap(struct virtio_gpu_resource_map_blob *mblob) >+{ >+ virtio_gpu_ctrl_hdr_bswap(&mblob->hdr); >+ le32_to_cpus(&mblob->resource_id); >+ le64_to_cpus(&mblob->offset); >+} >+ >+static inline void >+virtio_gpu_unmap_blob_bswap(struct virtio_gpu_resource_unmap_blob *ublob) >+{ >+ virtio_gpu_ctrl_hdr_bswap(&ublob->hdr); >+ le32_to_cpus(&ublob->resource_id); >+} >+ > static inline void > virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob *ssb) > { >diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h >index de4f624e94..55973e112f 100644 >--- a/include/hw/virtio/virtio-gpu.h >+++ b/include/hw/virtio/virtio-gpu.h >@@ -257,6 +257,9 @@ void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, > void virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, > struct virtio_gpu_resp_edid *edid); > /* virtio-gpu.c */ >+struct virtio_gpu_simple_resource * >+virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); >+ > void virtio_gpu_ctrl_response(VirtIOGPU *g, > struct virtio_gpu_ctrl_command *cmd, > struct virtio_gpu_ctrl_hdr *resp, >@@ -275,6 +278,8 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, > uint32_t *niov); > void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, > struct iovec *iov, uint32_t count); >+void virtio_gpu_cleanup_mapping(VirtIOGPU *g, >+ struct virtio_gpu_simple_resource *res); > void virtio_gpu_process_cmdq(VirtIOGPU *g); > void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); > void virtio_gpu_reset(VirtIODevice *vdev); >-- >2.41.0.694.ge786442a9b-goog > >
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index 48ef0d9fad..3e658f1fef 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -33,15 +33,11 @@ #define VIRTIO_GPU_VM_VERSION 1 -static struct virtio_gpu_simple_resource* -virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); static struct virtio_gpu_simple_resource * virtio_gpu_find_check_resource(VirtIOGPU *g, uint32_t resource_id, bool require_backing, const char *caller, uint32_t *error); -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res); static void virtio_gpu_reset_bh(void *opaque); void virtio_gpu_update_cursor_data(VirtIOGPU *g, @@ -116,7 +112,7 @@ static void update_cursor(VirtIOGPU *g, struct virtio_gpu_update_cursor *cursor) cursor->resource_id ? 1 : 0); } -static struct virtio_gpu_simple_resource * +struct virtio_gpu_simple_resource * virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id) { struct virtio_gpu_simple_resource *res; @@ -904,8 +900,8 @@ void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, g_free(iov); } -static void virtio_gpu_cleanup_mapping(VirtIOGPU *g, - struct virtio_gpu_simple_resource *res) +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res) { virtio_gpu_cleanup_mapping_iov(g, res->iov, res->iov_cnt); res->iov = NULL; diff --git a/include/hw/virtio/virtio-gpu-bswap.h b/include/hw/virtio/virtio-gpu-bswap.h index 9124108485..dd1975e2d4 100644 --- a/include/hw/virtio/virtio-gpu-bswap.h +++ b/include/hw/virtio/virtio-gpu-bswap.h @@ -63,10 +63,28 @@ virtio_gpu_create_blob_bswap(struct virtio_gpu_resource_create_blob *cblob) { virtio_gpu_ctrl_hdr_bswap(&cblob->hdr); le32_to_cpus(&cblob->resource_id); + le32_to_cpus(&cblob->blob_mem); le32_to_cpus(&cblob->blob_flags); + le32_to_cpus(&cblob->nr_entries); + le64_to_cpus(&cblob->blob_id); le64_to_cpus(&cblob->size); } +static inline void +virtio_gpu_map_blob_bswap(struct virtio_gpu_resource_map_blob *mblob) +{ + virtio_gpu_ctrl_hdr_bswap(&mblob->hdr); + le32_to_cpus(&mblob->resource_id); + le64_to_cpus(&mblob->offset); +} + +static inline void +virtio_gpu_unmap_blob_bswap(struct virtio_gpu_resource_unmap_blob *ublob) +{ + virtio_gpu_ctrl_hdr_bswap(&ublob->hdr); + le32_to_cpus(&ublob->resource_id); +} + static inline void virtio_gpu_scanout_blob_bswap(struct virtio_gpu_set_scanout_blob *ssb) { diff --git a/include/hw/virtio/virtio-gpu.h b/include/hw/virtio/virtio-gpu.h index de4f624e94..55973e112f 100644 --- a/include/hw/virtio/virtio-gpu.h +++ b/include/hw/virtio/virtio-gpu.h @@ -257,6 +257,9 @@ void virtio_gpu_base_fill_display_info(VirtIOGPUBase *g, void virtio_gpu_base_generate_edid(VirtIOGPUBase *g, int scanout, struct virtio_gpu_resp_edid *edid); /* virtio-gpu.c */ +struct virtio_gpu_simple_resource * +virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id); + void virtio_gpu_ctrl_response(VirtIOGPU *g, struct virtio_gpu_ctrl_command *cmd, struct virtio_gpu_ctrl_hdr *resp, @@ -275,6 +278,8 @@ int virtio_gpu_create_mapping_iov(VirtIOGPU *g, uint32_t *niov); void virtio_gpu_cleanup_mapping_iov(VirtIOGPU *g, struct iovec *iov, uint32_t count); +void virtio_gpu_cleanup_mapping(VirtIOGPU *g, + struct virtio_gpu_simple_resource *res); void virtio_gpu_process_cmdq(VirtIOGPU *g); void virtio_gpu_device_realize(DeviceState *qdev, Error **errp); void virtio_gpu_reset(VirtIODevice *vdev);