aboutsummaryrefslogtreecommitdiff
path: root/lib/sbi/sbi_domain.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sbi/sbi_domain.c')
-rw-r--r--lib/sbi/sbi_domain.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/lib/sbi/sbi_domain.c b/lib/sbi/sbi_domain.c
index 50749f1..374ac36 100644
--- a/lib/sbi/sbi_domain.c
+++ b/lib/sbi/sbi_domain.c
@@ -64,20 +64,34 @@ void sbi_update_hartindex_to_domain(u32 hartindex, struct sbi_domain *dom)
bool sbi_domain_is_assigned_hart(const struct sbi_domain *dom, u32 hartid)
{
- if (dom)
- return sbi_hartmask_test_hartid(hartid, &dom->assigned_harts);
+ bool ret;
+ struct sbi_domain *tdom = (struct sbi_domain *)dom;
- return false;
+ if (!dom)
+ return false;
+
+ spin_lock(&tdom->assigned_harts_lock);
+ ret = sbi_hartmask_test_hartid(hartid, &tdom->assigned_harts);
+ spin_unlock(&tdom->assigned_harts_lock);
+
+ return ret;
}
ulong sbi_domain_get_assigned_hartmask(const struct sbi_domain *dom,
ulong hbase)
{
ulong ret = 0;
+ struct sbi_domain *tdom = (struct sbi_domain *)dom;
+
+ if (!dom)
+ return 0;
+
+ spin_lock(&tdom->assigned_harts_lock);
for (int i = 0; i < 8 * sizeof(ret); i++) {
- if (sbi_domain_is_assigned_hart(dom, hbase + i))
+ if (sbi_hartmask_test_hartid(hbase + i, &tdom->assigned_harts))
ret |= 1UL << i;
}
+ spin_unlock(&tdom->assigned_harts_lock);
return ret;
}
@@ -555,6 +569,9 @@ int sbi_domain_register(struct sbi_domain *dom,
dom->index = domain_count++;
domidx_to_domain_table[dom->index] = dom;
+ /* Initialize spinlock for dom->assigned_harts */
+ SPIN_LOCK_INIT(dom->assigned_harts_lock);
+
/* Clear assigned HARTs of domain */
sbi_hartmask_clear_all(&dom->assigned_harts);
@@ -701,8 +718,14 @@ int sbi_domain_finalize(struct sbi_scratch *scratch, u32 cold_hartid)
continue;
/* Ignore if boot HART assigned different domain */
- if (sbi_hartindex_to_domain(dhart) != dom ||
- !sbi_hartmask_test_hartindex(dhart, &dom->assigned_harts))
+ if (sbi_hartindex_to_domain(dhart) != dom)
+ continue;
+
+ /* Ignore if boot HART is not part of the assigned HARTs */
+ spin_lock(&dom->assigned_harts_lock);
+ rc = sbi_hartmask_test_hartindex(dhart, &dom->assigned_harts);
+ spin_unlock(&dom->assigned_harts_lock);
+ if (!rc)
continue;
/* Startup boot HART of domain */