From 1fd735989fbac3d0294c7ba5e5f5da369792a1a1 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Tue, 30 Jan 2024 17:55:25 +0100 Subject: [PATCH] base-nova: Adapted PD session to the change of NOVA's API for cell management. --- .../base-nova/src/core/pd_session_support.cc | 53 ++++++++++++++----- repos/base/include/pd_session/client.h | 9 +--- repos/base/include/pd_session/pd_session.h | 9 ++-- 3 files changed, 46 insertions(+), 25 deletions(-) diff --git a/repos/base-nova/src/core/pd_session_support.cc b/repos/base-nova/src/core/pd_session_support.cc index 0dab7c66d7..5ac8f2ce88 100644 --- a/repos/base-nova/src/core/pd_session_support.cc +++ b/repos/base-nova/src/core/pd_session_support.cc @@ -106,27 +106,56 @@ void Pd_session_component::map(addr_t virt, addr_t size) } } +void _calculate_mask_for_location(Nova::mword_t *core_mask, const Affinity::Location &loc) +{ + for (unsigned y = loc.ypos(); y < loc.ypos() + loc.height(); y++) + { + for (unsigned x = loc.xpos(); x < loc.xpos()+loc.width(); x++) + { + unsigned kernel_cpu = platform_specific().kernel_cpu_id(Affinity::Location(x, y, loc.width(), loc.height())); + unsigned i = kernel_cpu / (sizeof(Nova::mword_t) * 8); + unsigned b = kernel_cpu % (sizeof(Nova::mword_t) * 8); + core_mask[i] |= (1UL << b); + + Genode::log("core_mask[", i, "]=", core_mask[i], " i=", i, "b=", b, "kernel_cpu=", kernel_cpu); + } + } +} + + void Pd_session_component::create_cell(long prioritiy, const Affinity::Location &loc) { Nova::uint8_t err = Nova::NOVA_OK; - if ((err = Nova::create_cell(_pd->pd_sel(), prioritiy, loc.xpos(), loc.xpos()+loc.width())) != Nova::NOVA_OK) { - error("Could not create new cell: ", err); + unsigned num_cpus = platform_specific().MAX_SUPPORTED_CPUS; + unsigned num_vect = num_cpus / (sizeof(Nova::mword_t) * 8); + Nova::mword_t core_mask[num_vect]; + + Genode::memset(core_mask, 0, sizeof(core_mask)); + + _calculate_mask_for_location(core_mask, loc); + + log("Requested to create new cell for <", this->label(), "> of priority ", prioritiy, " at ", loc); + for (unsigned i = 0; i < num_vect; i++) { + if ((err = Nova::create_cell(_pd->pd_sel(), prioritiy, core_mask[i], i, 1) != Nova::NOVA_OK)) + { + error("Could not create new cell: ", err); + } } } -void Pd_session_component::grow_cell(const Affinity::Location &loc) +void Pd_session_component::update_cell(const Affinity::Location &loc) { Nova::uint8_t err = Nova::NOVA_OK; - if ((err = Nova::grow_cell(_pd->pd_sel(), loc.xpos(), loc.xpos()+loc.width())) != Nova::NOVA_OK) { - error("Could not enlarge cell: ", err); - } -} + unsigned num_cpus = platform_specific().affinity_space().total(); + unsigned num_vect = num_cpus / (sizeof(Nova::mword_t) * 8); + Nova::mword_t core_mask[num_vect]; -void Pd_session_component::shrink_cell(const Affinity::Location &loc) -{ - Nova::uint8_t err = Nova::NOVA_OK; - if ((err = Nova::shrink_cell(_pd->pd_sel(), loc.xpos(), loc.xpos()+loc.width())) != Nova::NOVA_OK) { - error("Could not shrink down cell: ", err); + _calculate_mask_for_location(core_mask, loc); + + for (unsigned i = 0; i < num_vect; i++) { + if ((err = Nova::update_cell(_pd->pd_sel(), core_mask[i], i))) { + error("Failed to update cell <", label(), ">: ", err); + } } } diff --git a/repos/base/include/pd_session/client.h b/repos/base/include/pd_session/client.h index 7327c84563..3f57871641 100644 --- a/repos/base/include/pd_session/client.h +++ b/repos/base/include/pd_session/client.h @@ -111,14 +111,9 @@ struct Genode::Pd_session_client : Rpc_client call(prioritiy, loc); } - void grow_cell(const Affinity::Location &loc) override + void update_cell(const Affinity::Location &loc) override { - call(loc); - } - - void shrink_cell(const Affinity::Location &loc) override - { - call(loc); + call(loc); } }; diff --git a/repos/base/include/pd_session/pd_session.h b/repos/base/include/pd_session/pd_session.h index ccc75d5488..6378833592 100644 --- a/repos/base/include/pd_session/pd_session.h +++ b/repos/base/include/pd_session/pd_session.h @@ -351,9 +351,7 @@ struct Genode::Pd_session : Session, Ram_allocator */ virtual void create_cell(long prioritiy, const Affinity::Location &loc) = 0; - virtual void shrink_cell(const Affinity::Location &loc) = 0; - - virtual void grow_cell(const Affinity::Location &loc) = 0; + virtual void update_cell(const Affinity::Location &loc) = 0; /********************* ** RPC declaration ** @@ -411,8 +409,7 @@ struct Genode::Pd_session : Session, Ram_allocator GENODE_RPC(Rpc_create_cell, void, create_cell, long, Affinity::Location const &); - GENODE_RPC(Rpc_shrink_cell, void, shrink_cell, Affinity::Location const &); - GENODE_RPC(Rpc_grow_cell, void, grow_cell, Affinity::Location const &); + GENODE_RPC(Rpc_update_cell, void, update_cell, Affinity::Location const &); GENODE_RPC_INTERFACE(Rpc_assign_parent, Rpc_assign_pci, Rpc_map, Rpc_alloc_signal_source, Rpc_free_signal_source, @@ -424,7 +421,7 @@ struct Genode::Pd_session : Session, Ram_allocator Rpc_transfer_ram_quota, Rpc_ram_quota, Rpc_used_ram, Rpc_native_pd, Rpc_managing_system, Rpc_dma_addr, Rpc_attach_dma, - Rpc_create_cell, Rpc_grow_cell, Rpc_shrink_cell); + Rpc_create_cell, Rpc_update_cell); }; #endif /* _INCLUDE__PD_SESSION__PD_SESSION_H_ */