Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: pm: add unregister_pm_cb() + stm32mp257f-ev1 GPIO and console support #7014

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

GseoC
Copy link
Contributor

@GseoC GseoC commented Aug 28, 2024

This P-R implements:

  • The mean to unregister a PM callback
  • GPIO and console support for stm32mp257f-ev1 platform

Copy link
Contributor

@jforissier jforissier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • For "drivers: stm32_rif: tag unused parameters as __unused":
    Reviewed-by: Jerome Forissier <[email protected]>
  • For "core: pm: add unregister_pm_cb()":
    One comment, then:
    Acked-by: Jerome Forissier <[email protected]>

static inline void unregister_pm_core_service_cb(pm_callback callback,
void *handle)
{
enum pm_callback_order order = PM_CB_ORDER_CORE_SERVICE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Local variable not needed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was to keep alignment with parentheses without exceeding the character per lign limit. Do you suggest I change it nevertheless?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK then it's fine as it is. In fact PM_CALLBACK_HANDLE_INITIALIZER is too long, it should have been called PM_CB_HANDLE_INITIALIZER.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, we could also shorten struct pm_callback_handle to struct pm_cb_handle :)

core/drivers/stm32_gpio.c Show resolved Hide resolved
core/drivers/stm32_gpio.c Show resolved Hide resolved
core/drivers/stm32_gpio.c Outdated Show resolved Hide resolved
core/drivers/stm32_gpio.c Outdated Show resolved Hide resolved
core/include/kernel/pm.h Outdated Show resolved Hide resolved
core/include/kernel/pm.h Outdated Show resolved Hide resolved
core/drivers/stm32_gpio.c Outdated Show resolved Hide resolved
core/drivers/stm32_gpio.c Show resolved Hide resolved
core/drivers/stm32_gpio.c Outdated Show resolved Hide resolved
static inline void unregister_pm_core_service_cb(pm_callback callback,
void *handle)
{
enum pm_callback_order order = PM_CB_ORDER_CORE_SERVICE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, we could also shorten struct pm_callback_handle to struct pm_cb_handle :)

@GseoC
Copy link
Contributor Author

GseoC commented Sep 2, 2024

Updated with comments applied, I will add all tags at the end of the review

core/drivers/stm32_gpio.c Show resolved Hide resolved
core/drivers/stm32_gpio.c Show resolved Hide resolved
core/drivers/stm32_gpio.c Outdated Show resolved Hide resolved
core/drivers/stm32_gpio.c Outdated Show resolved Hide resolved
@GseoC
Copy link
Contributor Author

GseoC commented Sep 2, 2024

Comments addressed

Copy link
Contributor

@etienne-lms etienne-lms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some late comments.
I'm fine you fix and squash all fixup commits. I'll make a last review run afterward.

core/drivers/stm32_gpio.c Outdated Show resolved Hide resolved
/**
* Compatibility information of supported banks
*
* @gpioz: True if bank is a GPIOZ bank
* @secure_control: Identify GPIO security bank capability.
* @secure_control: Identify RIF presence.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: s/secure_control/secure_extended/

res = stm32_rif_acquire_semaphore(bank->base + GPIO_SEMCR(i),
GPIO_MAX_CID_SUPPORTED);
if (res) {
EMSG("Could not acquire semaphore for pin %u", i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: print also the GPIO bank ID to ease debugging. Eg.
E.g. replace for pin %u", i)
with for pin %C%u", 'A' + bank->bank_id, i)

This comment applies also to lines 797 and 806.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with few other occurences as well

panic();

nb_rif_conf = MIN((unsigned int)(lenp / sizeof(uint32_t)),
bank->ngpios);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If think we should rather report an error if lenp / sizeof(uint32_t) > bank->ngpios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put an assert but let me know if an error case handling feels better to you

core/drivers/stm32_gpio.c Show resolved Hide resolved
When CFG_STM32_RIF is not set, inclusion of this header file causes
warnings because of function parameters not being tagged as unused.
Tag them properly.

Signed-off-by: Gatien Chevallier <[email protected]>
Fixes: 1506f47 ("drivers: firewall: add stm32_rif driver for common RIF features")
Add support for stm32mp25x platforms by adding RIF support to the driver.
GPIO banks are RIF-aware peripherals, meaning that they are responsible
for setting their own RIF configuration.

While there, remove the use of set_bank_gpio_non_secure() as it is of no
use since a pin not configured as secured in the device tree will already
result being non-secure.

Signed-off-by: Gatien Chevallier <[email protected]>
Add unregister_pm_cb() API function and its helper variants to
allow unregistering a PM callback entry. This can be needed for
example in the GPIO framework where gpio_put() can release a GPIO
that a driver no more consumed. In case a PM callback was previously
registered for such a GPIO, consumer driver needs mean to unregister
it.

This change implies that the PM callbacks list is protected from
concurrent accesses hence add a lock for that purpose.

Signed-off-by: Gatien Chevallier <[email protected]>
Save and restore during PM suspend/resume sequences the state of the
consumed GPIOs.

Consumers are expected to get their GPIOs using the DT resources hence
register a PM handle when the GPIO is requested (stm32_gpio_get_dt()) so
that the dependency order established during drivers initialization is
satisfied during PM suspend and resume sequences. PM handle is
unregistered when consumer releases the GPIO which requires the handles
to be referenced in a list so that we can find it back.

Signed-off-by: Gatien Chevallier <[email protected]>
Populate USART2 node and enable console support on USART2 on
stm32mp257f-ev1 board.

Signed-off-by: Gatien Chevallier <[email protected]>
Add initial RIF GPIO configuration for stm32mp257f-ev1 board.

Signed-off-by: Gatien Chevallier <[email protected]>
@GseoC
Copy link
Contributor Author

GseoC commented Sep 3, 2024

Comments addressed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants