forked from Mirrors/opensbi
lib: sbi_sse: Cache the event's target hart index
This avoids needing to map the target hartid to a hart index when enabling or disabling an event, and provides a net code size reduction. Signed-off-by: Samuel Holland <samuel.holland@sifive.com> Reviewed-by: Anup Patel <anup@brainfault.org>
This commit is contained in:

committed by
Anup Patel

parent
15c4e285db
commit
d73a4c741c
@@ -108,6 +108,7 @@ assert_field_offset(interrupted.a7, SBI_SSE_ATTR_INTERRUPTED_A7);
|
|||||||
struct sbi_sse_event {
|
struct sbi_sse_event {
|
||||||
struct sbi_sse_event_attrs attrs;
|
struct sbi_sse_event_attrs attrs;
|
||||||
uint32_t event_id;
|
uint32_t event_id;
|
||||||
|
u32 hartindex;
|
||||||
const struct sbi_sse_cb_ops *cb_ops;
|
const struct sbi_sse_cb_ops *cb_ops;
|
||||||
struct sbi_dlist node;
|
struct sbi_dlist node;
|
||||||
};
|
};
|
||||||
@@ -197,7 +198,7 @@ static bool sse_event_is_local(struct sbi_sse_event *e)
|
|||||||
*/
|
*/
|
||||||
static struct sse_hart_state *sse_get_hart_state(struct sbi_sse_event *e)
|
static struct sse_hart_state *sse_get_hart_state(struct sbi_sse_event *e)
|
||||||
{
|
{
|
||||||
struct sbi_scratch *s = sbi_hartid_to_scratch(e->attrs.hartid);
|
struct sbi_scratch *s = sbi_hartindex_to_scratch(e->hartindex);
|
||||||
|
|
||||||
return sse_get_hart_state_ptr(s);
|
return sse_get_hart_state_ptr(s);
|
||||||
}
|
}
|
||||||
@@ -392,6 +393,7 @@ static void sse_event_set_attr(struct sbi_sse_event *e, uint32_t attr_id,
|
|||||||
break;
|
break;
|
||||||
case SBI_SSE_ATTR_PREFERRED_HART:
|
case SBI_SSE_ATTR_PREFERRED_HART:
|
||||||
e->attrs.hartid = val;
|
e->attrs.hartid = val;
|
||||||
|
e->hartindex = sbi_hartid_to_hartindex(val);
|
||||||
sse_event_invoke_cb(e, set_hartid_cb, val);
|
sse_event_invoke_cb(e, set_hartid_cb, val);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -1017,6 +1019,7 @@ int sbi_sse_unregister(uint32_t event_id)
|
|||||||
static void sse_event_init(struct sbi_sse_event *e, uint32_t event_id)
|
static void sse_event_init(struct sbi_sse_event *e, uint32_t event_id)
|
||||||
{
|
{
|
||||||
e->event_id = event_id;
|
e->event_id = event_id;
|
||||||
|
e->hartindex = current_hartindex();
|
||||||
e->attrs.hartid = current_hartid();
|
e->attrs.hartid = current_hartid();
|
||||||
/* Declare all events as injectable */
|
/* Declare all events as injectable */
|
||||||
e->attrs.status |= BIT(SBI_SSE_ATTR_STATUS_INJECT_OFFSET);
|
e->attrs.status |= BIT(SBI_SSE_ATTR_STATUS_INJECT_OFFSET);
|
||||||
|
Reference in New Issue
Block a user