From a3976f04686ca58d2423ea6a6ee212b2b2d5def6 Mon Sep 17 00:00:00 2001 From: Sebastian Sumpf Date: Thu, 13 Jan 2022 17:51:25 +0100 Subject: [PATCH] vfs_gpu: offer 'vfs_gpu_env' call * retrieve Genode::Env from plugin, this way no mesa applications need to be changed. * add 'vfs_gpu' api * remove when all required functionality is implemented within the plugin. issue #4380 --- repos/gems/lib/import/import-vfs_gpu.mk | 1 + repos/gems/lib/symbols/vfs_gpu | 3 +++ repos/gems/recipes/api/vfs_gpu/content.mk | 13 ++++++++++ repos/gems/recipes/api/vfs_gpu/hash | 1 + repos/gems/recipes/src/vfs_gpu/api | 1 + repos/gems/src/lib/vfs/gpu/vfs.cc | 22 +++++++++++++---- repos/gems/src/lib/vfs/gpu/vfs_gpu.h | 29 +++++++++++++++++++++++ 7 files changed, 65 insertions(+), 5 deletions(-) create mode 100644 repos/gems/lib/import/import-vfs_gpu.mk create mode 100644 repos/gems/lib/symbols/vfs_gpu create mode 100644 repos/gems/recipes/api/vfs_gpu/content.mk create mode 100644 repos/gems/recipes/api/vfs_gpu/hash create mode 100644 repos/gems/recipes/src/vfs_gpu/api create mode 100644 repos/gems/src/lib/vfs/gpu/vfs_gpu.h diff --git a/repos/gems/lib/import/import-vfs_gpu.mk b/repos/gems/lib/import/import-vfs_gpu.mk new file mode 100644 index 0000000000..af6c9746d3 --- /dev/null +++ b/repos/gems/lib/import/import-vfs_gpu.mk @@ -0,0 +1 @@ +REP_INC_DIR += src/lib/vfs/gpu diff --git a/repos/gems/lib/symbols/vfs_gpu b/repos/gems/lib/symbols/vfs_gpu new file mode 100644 index 0000000000..d3880995d9 --- /dev/null +++ b/repos/gems/lib/symbols/vfs_gpu @@ -0,0 +1,3 @@ +_Z11vfs_gpu_envv T +_Z18vfs_gpu_connectionm T +vfs_file_system_factory T diff --git a/repos/gems/recipes/api/vfs_gpu/content.mk b/repos/gems/recipes/api/vfs_gpu/content.mk new file mode 100644 index 0000000000..c794b783ea --- /dev/null +++ b/repos/gems/recipes/api/vfs_gpu/content.mk @@ -0,0 +1,13 @@ +MIRROR_FROM_REP_DIR := \ + src/lib/vfs/gpu/vfs_gpu.h \ + lib/import/import-vfs_gpu.mk \ + lib/symbols/vfs_gpu + +content: $(MIRROR_FROM_REP_DIR) + +$(MIRROR_FROM_REP_DIR): + $(mirror_from_rep_dir) + +LICENSE: + cp $(GENODE_DIR)/LICENSE $@ + diff --git a/repos/gems/recipes/api/vfs_gpu/hash b/repos/gems/recipes/api/vfs_gpu/hash new file mode 100644 index 0000000000..754412a2f1 --- /dev/null +++ b/repos/gems/recipes/api/vfs_gpu/hash @@ -0,0 +1 @@ +2022-01-14-b 717f2b436a763c3ac1a752ae3fa9b194c786f1a9 diff --git a/repos/gems/recipes/src/vfs_gpu/api b/repos/gems/recipes/src/vfs_gpu/api new file mode 100644 index 0000000000..daf943cdf0 --- /dev/null +++ b/repos/gems/recipes/src/vfs_gpu/api @@ -0,0 +1 @@ +vfs_gpu diff --git a/repos/gems/src/lib/vfs/gpu/vfs.cc b/repos/gems/src/lib/vfs/gpu/vfs.cc index 918d5f03ed..94e2c17024 100644 --- a/repos/gems/src/lib/vfs/gpu/vfs.cc +++ b/repos/gems/src/lib/vfs/gpu/vfs.cc @@ -21,6 +21,8 @@ #include #include +#include "vfs_gpu.h" + namespace Vfs_gpu { using namespace Vfs; @@ -135,10 +137,9 @@ struct Vfs_gpu::File_system : Single_file_system static Vfs_gpu::File_system *_fs { nullptr }; - /** * XXX: return GPU session for given ID, retrieved by 'stat->inode'. - * This function is used, for example, by libdrm via (dlopen/dlsym). + * This function is used, for example, by libdrm */ Gpu::Connection *vfs_gpu_connection(unsigned long id) { @@ -149,15 +150,25 @@ Gpu::Connection *vfs_gpu_connection(unsigned long id) try { return _fs->_handle_space.apply( - Id_space::Id { .value = id }, - [] (Gpu_vfs_handle &handle) { - return &handle._gpu_session; }); + Id_space::Id { .value = id }, + [] (Gpu_vfs_handle &handle) + { + return &handle._gpu_session; + } + ); } catch (...) { } return nullptr; } +static Vfs::Env *_env { nullptr }; + +Genode::Env *vfs_gpu_env() +{ + return _env ? &_env->env() : nullptr; +} + /************************** ** VFS plugin interface ** **************************/ @@ -169,6 +180,7 @@ extern "C" Vfs::File_system_factory *vfs_file_system_factory(void) Vfs::File_system *create(Vfs::Env &vfs_env, Genode::Xml_node node) override { + _env = &vfs_env; try { _fs = new (vfs_env.alloc()) Vfs_gpu::File_system(vfs_env, node); return _fs; diff --git a/repos/gems/src/lib/vfs/gpu/vfs_gpu.h b/repos/gems/src/lib/vfs/gpu/vfs_gpu.h new file mode 100644 index 0000000000..657a78df92 --- /dev/null +++ b/repos/gems/src/lib/vfs/gpu/vfs_gpu.h @@ -0,0 +1,29 @@ +/* + * \brief Public interface for libdrm + * \author Sebastian Sumpf + * \date 2022-01-14 + * + * This is a interim solution becaues libdrm currently needs access to the + * GPU::Connection and Genode::Env. Once all the necessary features are provided + * by this plugin this interface is removed. + */ + +/* + * Copyright (C) 2022 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU Affero General Public License version 3. + */ + +#ifndef _VFS_GPU_H_ +#define _VFS_GPU_H_ + +namespace Gpu { class Connection; } + +Gpu::Connection *vfs_gpu_connection(unsigned long); + +namespace Genode { class Env; } + +Genode::Env *vfs_gpu_env(); + +#endif /* _VFS_GPU_H_ */