mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-19 21:57:55 +00:00
platform_drv: check quota before allocating buffer
The platform driver uses a 'Constrained_ram_allocator' to allocate meta-data on behave of a client. It uses the PD session as 'Ram_allocator' back end that in return is implemented via the 'Expanding_pd_session_client'. Whenever the PD client itselft comes into resource shortage it will ask its parent unconditionally. However, depending on the integration, such a request may be left unanswered. This commit introduces a check to prevent that situation from occurring. In case the platform driver notices the resource shortage it will reflect that back to the client. Issue #4284.
This commit is contained in:
parent
05b451c563
commit
27e55dab3e
@ -822,6 +822,19 @@ class Platform::Session_component : public Rpc_object<Session>
|
||||
|
||||
Ram_dataspace_capability alloc_dma_buffer(size_t const size, Cache cache) override
|
||||
{
|
||||
/*
|
||||
* Check available quota beforehand and reflect the state back
|
||||
* to the client because the 'Expanding_pd_session_client' will
|
||||
* ask its parent otherwise.
|
||||
*/
|
||||
enum { WATERMARK_CAP_QUOTA = 8, };
|
||||
if (_env.pd().avail_caps().value < WATERMARK_CAP_QUOTA)
|
||||
throw Out_of_caps();
|
||||
|
||||
enum { WATERMARK_RAM_QUOTA = 4096, };
|
||||
if (_env.pd().avail_ram().value < WATERMARK_RAM_QUOTA)
|
||||
throw Out_of_ram();
|
||||
|
||||
Ram_dataspace_capability ram_cap = _env_ram.alloc(size, cache);
|
||||
addr_t const dma_addr = Dataspace_client(ram_cap).phys_addr();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user