Skip to content

Commit

Permalink
[review] core: interrupt: itr_chip may not require configure handler
Browse files Browse the repository at this point in the history
Add an itr_chip_dt_only_init() helper function for interrupt
controllers which consumers only use the DT to configure their
interrupt, that is such controllers do not need a configure handler.

itr_chip_is_valid() is not called outside interrupt.c where it is
used in itr_chip_init() so make it a local function.

NOTE: I'll add this commit after itr_chip handler renaming
      s/add/configure commit.

Signed-off-by: Etienne Carriere <[email protected]>
  • Loading branch information
etienne-lms committed Feb 7, 2025
1 parent 68c295e commit 9193995
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
13 changes: 3 additions & 10 deletions core/include/kernel/interrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,10 @@ struct itr_handler {
})

/*
* Return true only if interrupt chip provides required handlers
* @chip: Interrupt controller reference
* Initialise an interrupt controller handle to be used only with the DT
* @chip Interrupt controller
*/
static inline bool itr_chip_is_valid(struct itr_chip *chip)
{
return chip && is_unpaged(chip) && chip->ops &&
is_unpaged((void *)chip->ops) &&
chip->ops->mask && is_unpaged(chip->ops->mask) &&
chip->ops->unmask && is_unpaged(chip->ops->unmask) &&
chip->ops->enable && chip->ops->disable;
}
TEE_Result itr_chip_dt_only_init(struct itr_chip *chip);

/*
* Initialise an interrupt controller handle
Expand Down
37 changes: 29 additions & 8 deletions core/kernel/interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,46 @@

static struct itr_chip *itr_main_chip __nex_bss;

static bool itr_chip_is_valid(struct itr_chip *chip)
{
return chip && is_unpaged(chip) && chip->ops &&
is_unpaged((void *)chip->ops) &&
chip->ops->mask && is_unpaged(chip->ops->mask) &&
chip->ops->unmask && is_unpaged(chip->ops->unmask) &&
chip->ops->enable && chip->ops->disable;
}

static void __itr_chip_init(struct itr_chip *chip)
{
SLIST_INIT(&chip->handlers);
}

TEE_Result itr_chip_init(struct itr_chip *chip)
{
/*
* Interrupt chips not using only the DT to configure
* consumers interrupts require configure handler.
*/
if (!itr_chip_is_valid(chip) || !chip->ops->configure)
return TEE_ERROR_BAD_PARAMETERS;

__itr_chip_init(chip);

return TEE_SUCCESS;
}

TEE_Result itr_chip_dt_only_init(struct itr_chip *chip)
{
if (!itr_chip_is_valid(chip))
return TEE_ERROR_BAD_PARAMETERS;

SLIST_INIT(&chip->handlers);
__itr_chip_init(chip);

return TEE_SUCCESS;
}

void interrupt_main_init(struct itr_chip *chip)
{
/*
* Require main chip to provide a configure handler since
* consumer may not rely on a DT to configure consumed
* interrupt.
*/
assert(chip->ops->configure);

if (itr_chip_init(chip))
panic();

Expand Down

0 comments on commit 9193995

Please sign in to comment.