userspace: fix k_mem_domain_destroy()
This deprecated API won't be removed for one more release, ensure it doesn't put the kernel into a bad state as it currently sets all the member thread domain assignment to NULL which is not what we want. Have it reassign all member threads to the default domain. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
c3e285acea
commit
9f87deafd2
2 changed files with 32 additions and 25 deletions
|
@ -127,7 +127,12 @@ extern void k_mem_domain_init(struct k_mem_domain *domain, uint8_t num_parts,
|
||||||
/**
|
/**
|
||||||
* @brief Destroy a memory domain.
|
* @brief Destroy a memory domain.
|
||||||
*
|
*
|
||||||
* Destroy a memory domain.
|
* Destroy a memory domain. All member threads will be re-assigned to the
|
||||||
|
* default memory domain.
|
||||||
|
*
|
||||||
|
* The default memory domain may not be destroyed.
|
||||||
|
*
|
||||||
|
* This API is deprecated and will be removed in Zephyr 2.5.
|
||||||
*
|
*
|
||||||
* @param domain The memory domain to be destroyed.
|
* @param domain The memory domain to be destroyed.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -137,30 +137,6 @@ void k_mem_domain_init(struct k_mem_domain *domain, uint8_t num_parts,
|
||||||
k_spin_unlock(&lock, key);
|
k_spin_unlock(&lock, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void k_mem_domain_destroy(struct k_mem_domain *domain)
|
|
||||||
{
|
|
||||||
k_spinlock_key_t key;
|
|
||||||
sys_dnode_t *node, *next_node;
|
|
||||||
|
|
||||||
__ASSERT_NO_MSG(domain != NULL);
|
|
||||||
|
|
||||||
key = k_spin_lock(&lock);
|
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_MEM_DOMAIN_SYNCHRONOUS_API
|
|
||||||
arch_mem_domain_destroy(domain);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
SYS_DLIST_FOR_EACH_NODE_SAFE(&domain->mem_domain_q, node, next_node) {
|
|
||||||
struct k_thread *thread =
|
|
||||||
CONTAINER_OF(node, struct k_thread, mem_domain_info);
|
|
||||||
|
|
||||||
sys_dlist_remove(&thread->mem_domain_info.mem_domain_q_node);
|
|
||||||
thread->mem_domain_info.mem_domain = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
k_spin_unlock(&lock, key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void k_mem_domain_add_partition(struct k_mem_domain *domain,
|
void k_mem_domain_add_partition(struct k_mem_domain *domain,
|
||||||
struct k_mem_partition *part)
|
struct k_mem_partition *part)
|
||||||
{
|
{
|
||||||
|
@ -295,6 +271,32 @@ void k_mem_domain_remove_thread(k_tid_t thread)
|
||||||
k_mem_domain_add_thread(&k_mem_domain_default, thread);
|
k_mem_domain_add_thread(&k_mem_domain_default, thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void k_mem_domain_destroy(struct k_mem_domain *domain)
|
||||||
|
{
|
||||||
|
k_spinlock_key_t key;
|
||||||
|
sys_dnode_t *node, *next_node;
|
||||||
|
|
||||||
|
__ASSERT_NO_MSG(domain != NULL);
|
||||||
|
__ASSERT(domain != &k_mem_domain_default,
|
||||||
|
"cannot destroy default domain");
|
||||||
|
|
||||||
|
key = k_spin_lock(&lock);
|
||||||
|
|
||||||
|
#ifdef CONFIG_ARCH_MEM_DOMAIN_SYNCHRONOUS_API
|
||||||
|
arch_mem_domain_destroy(domain);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SYS_DLIST_FOR_EACH_NODE_SAFE(&domain->mem_domain_q, node, next_node) {
|
||||||
|
struct k_thread *thread =
|
||||||
|
CONTAINER_OF(node, struct k_thread, mem_domain_info);
|
||||||
|
|
||||||
|
remove_thread_locked(thread);
|
||||||
|
add_thread_locked(&k_mem_domain_default, thread);
|
||||||
|
}
|
||||||
|
|
||||||
|
k_spin_unlock(&lock, key);
|
||||||
|
}
|
||||||
|
|
||||||
static int init_mem_domain_module(const struct device *arg)
|
static int init_mem_domain_module(const struct device *arg)
|
||||||
{
|
{
|
||||||
ARG_UNUSED(arg);
|
ARG_UNUSED(arg);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue