mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-19 15:43:56 +00:00
gpu: introduce mapping attributes
The various mapping methods are modelled after the requirements of the Intel GPUs or rather the Mesa driver back end. With upcoming support for other driver back ends, we need to sequeeze their requirements in as well. For now hijack 'map_buffer' to provide for specifying the kind of attributes the client needs. For now all buffers mapped in the GGTT for Intel GPUs are treated as RW. Issue #4265.
This commit is contained in:
committed by
Norman Feske
parent
90e151e2c4
commit
cacb83b163
@ -340,7 +340,8 @@ class Drm_call
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
_gpu_session.upgrade_ram(4096);
|
_gpu_session.upgrade_ram(4096);
|
||||||
b.map_cap = _gpu_session.map_buffer(b.id(), true);
|
b.map_cap = _gpu_session.map_buffer(b.id(), true,
|
||||||
|
Gpu::Mapping_attributes::rw());
|
||||||
b.map_offset = static_cast<Offset>(_env.rm().attach(b.map_cap));
|
b.map_offset = static_cast<Offset>(_env.rm().attach(b.map_cap));
|
||||||
offset = b.map_offset;
|
offset = b.map_offset;
|
||||||
|
|
||||||
|
@ -57,8 +57,9 @@ class Gpu::Session_client : public Genode::Rpc_client<Session>
|
|||||||
call<Rpc_free_buffer>(id); }
|
call<Rpc_free_buffer>(id); }
|
||||||
|
|
||||||
Genode::Dataspace_capability map_buffer(Buffer_id id,
|
Genode::Dataspace_capability map_buffer(Buffer_id id,
|
||||||
bool aperture) override {
|
bool aperture,
|
||||||
return call<Rpc_map_buffer>(id, aperture); }
|
Mapping_attributes attrs) override {
|
||||||
|
return call<Rpc_map_buffer>(id, aperture, attrs); }
|
||||||
|
|
||||||
void unmap_buffer(Buffer_id id) override {
|
void unmap_buffer(Buffer_id id) override {
|
||||||
call<Rpc_unmap_buffer>(id); }
|
call<Rpc_unmap_buffer>(id); }
|
||||||
|
@ -24,6 +24,30 @@ namespace Gpu {
|
|||||||
struct Buffer;
|
struct Buffer;
|
||||||
using Buffer_id = Genode::Id_space<Buffer>::Id;
|
using Buffer_id = Genode::Id_space<Buffer>::Id;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Attributes for mapping a buffer
|
||||||
|
*/
|
||||||
|
struct Mapping_attributes
|
||||||
|
{
|
||||||
|
bool readable;
|
||||||
|
bool writeable;
|
||||||
|
|
||||||
|
static Mapping_attributes ro()
|
||||||
|
{
|
||||||
|
return { .readable = true, .writeable = false };
|
||||||
|
}
|
||||||
|
|
||||||
|
static Mapping_attributes rw()
|
||||||
|
{
|
||||||
|
return { .readable = true, .writeable = true };
|
||||||
|
}
|
||||||
|
|
||||||
|
static Mapping_attributes wo()
|
||||||
|
{
|
||||||
|
return { .readable = false, .writeable = true };
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
struct Sequence_number;
|
struct Sequence_number;
|
||||||
struct Session;
|
struct Session;
|
||||||
}
|
}
|
||||||
@ -118,11 +142,13 @@ struct Gpu::Session : public Genode::Session
|
|||||||
* \param id buffer id
|
* \param id buffer id
|
||||||
* \param aperture if true create CPU accessible mapping through
|
* \param aperture if true create CPU accessible mapping through
|
||||||
* GGTT window, otherwise create PPGTT mapping
|
* GGTT window, otherwise create PPGTT mapping
|
||||||
|
* \param attrs specify how the buffer is mapped
|
||||||
*
|
*
|
||||||
* \throw Mapping_buffer_failed
|
* \throw Mapping_buffer_failed
|
||||||
*/
|
*/
|
||||||
virtual Genode::Dataspace_capability map_buffer(Buffer_id id,
|
virtual Genode::Dataspace_capability map_buffer(Buffer_id id,
|
||||||
bool aperture) = 0;
|
bool aperture,
|
||||||
|
Mapping_attributes attrs) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unmap buffer
|
* Unmap buffer
|
||||||
@ -175,7 +201,7 @@ struct Gpu::Session : public Genode::Session
|
|||||||
GENODE_RPC(Rpc_free_buffer, void, free_buffer, Gpu::Buffer_id);
|
GENODE_RPC(Rpc_free_buffer, void, free_buffer, Gpu::Buffer_id);
|
||||||
GENODE_RPC_THROW(Rpc_map_buffer, Genode::Dataspace_capability, map_buffer,
|
GENODE_RPC_THROW(Rpc_map_buffer, Genode::Dataspace_capability, map_buffer,
|
||||||
GENODE_TYPE_LIST(Mapping_buffer_failed, Out_of_ram),
|
GENODE_TYPE_LIST(Mapping_buffer_failed, Out_of_ram),
|
||||||
Gpu::Buffer_id, bool);
|
Gpu::Buffer_id, bool, Gpu::Mapping_attributes);
|
||||||
GENODE_RPC(Rpc_unmap_buffer, void, unmap_buffer,
|
GENODE_RPC(Rpc_unmap_buffer, void, unmap_buffer,
|
||||||
Gpu::Buffer_id);
|
Gpu::Buffer_id);
|
||||||
GENODE_RPC_THROW(Rpc_map_buffer_ppgtt, bool, map_buffer_ppgtt,
|
GENODE_RPC_THROW(Rpc_map_buffer_ppgtt, bool, map_buffer_ppgtt,
|
||||||
|
@ -1676,8 +1676,13 @@ class Gpu::Session_component : public Genode::Session_object<Gpu::Session>
|
|||||||
}
|
}
|
||||||
|
|
||||||
Genode::Dataspace_capability map_buffer(Gpu::Buffer_id id,
|
Genode::Dataspace_capability map_buffer(Gpu::Buffer_id id,
|
||||||
bool aperture) override
|
bool aperture,
|
||||||
|
Gpu::Mapping_attributes attrs) override
|
||||||
{
|
{
|
||||||
|
/* treat GGTT mapped buffers as rw */
|
||||||
|
if (!(attrs.readable && attrs.writeable))
|
||||||
|
return Genode::Dataspace_capability();
|
||||||
|
|
||||||
Genode::Dataspace_capability map_cap;
|
Genode::Dataspace_capability map_cap;
|
||||||
|
|
||||||
auto lookup_and_map = [&] (Buffer &buffer) {
|
auto lookup_and_map = [&] (Buffer &buffer) {
|
||||||
|
Reference in New Issue
Block a user