mirror of
https://github.com/genodelabs/genode.git
synced 2025-05-22 02:07:47 +00:00
platform_drv: check quota before dma allocations (taken from legacy)
'_env_ram' allocations can lead to 'Expanding_pd_session_client::try_alloc' quota upgrades, which in turn may lead to a resource request by the platform driver. Therefore, we check the available quota within the platform driver before allocations. This is not an optimal solution. issue #4667 related issue #3767
This commit is contained in:
parent
03a142174f
commit
1b66b1bd7c
@ -176,6 +176,19 @@ Session_component::alloc_dma_buffer(size_t const size, Cache cache)
|
|||||||
{
|
{
|
||||||
Ram_dataspace_capability ram_cap { };
|
Ram_dataspace_capability ram_cap { };
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ram_cap = _env_ram.alloc(size, cache);
|
ram_cap = _env_ram.alloc(size, cache);
|
||||||
} catch (Ram_allocator::Denied) { }
|
} catch (Ram_allocator::Denied) { }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user