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

drivers: sam: add SCMI reset domain management protocol support #7136

Merged
merged 8 commits into from
Jan 9, 2025

Conversation

TonyHan11
Copy link
Contributor

No description provided.

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 minor comments

@@ -12,6 +12,7 @@
#include <tee_api_defines.h>
#include <tee_api_types.h>
#include <types_ext.h>
#include <drivers/rstctrl.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

sort in alphabetical order and add #include <sys/queue.h>

@@ -8,6 +8,12 @@
#include <compiler.h>
#include <stdbool.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

add #include <util.h>

Copy link
Contributor

Choose a reason for hiding this comment

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

Please address the above comment.
(commit "drivers: atmel_rstc: new data and functions to handle reset assert/deassert")

@@ -24,6 +24,11 @@

static vaddr_t rstc_base;

struct sam_reset_data {
bool rstc_always_secure;
Copy link
Contributor

Choose a reason for hiding this comment

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

add #include <stdbool.h>

Copy link
Contributor

Choose a reason for hiding this comment

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

Please address the above comment.
(commit "drivers: atmel_rstc: add functions to allocate/get reset controller/lines")

@@ -30,4 +30,6 @@ static inline void sam_rstc_usb_por(unsigned char id __unused,
bool enable __unused) {}
#endif

struct rstctrl *sam_get_rstctrl(unsigned int reset_id);
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe consider #if defined(CFG_ATMEL_RSTC) to declare/define this function?

@TonyHan11
Copy link
Contributor Author

@etienne-lms updated according to the comments, thank you very much.

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.

1 comment to address for commit
"drivers: atmel_rstc: new data and functions to handle reset assert/deassert".

Few comments to address for commit
"drivers: atmel_rstc: add functions to allocate/get reset controller/lines".

Acked-by: Etienne Carriere <[email protected]> for commit
"drivers: atmel_rstc: probe RSTC with reset controller and reset lines" and
"plat-sam: enable SCMI reset domain management protocol and rstctrl driver".

1 comment for "plat-sam: scmi_server: use SCMI reset to manage USB reset for sama7g5". If not applicable, you can add my Acked-by tag to that commit.

@@ -28,6 +30,7 @@ static inline bool atmel_rstc_available(void)
static inline void atmel_rstc_reset(void) {}
static inline void sam_rstc_usb_por(unsigned char id __unused,
bool enable __unused) {}
struct rstctrl *sam_get_rstctrl(unsigned int reset_id) { return NULL; }
Copy link
Contributor

Choose a reason for hiding this comment

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

static inline + __unused for the function argument.

#define RESET_ID_MASK GENMASK_32(31, 5)
#define RESET_ID_SHIFT U(5)
#define RESET_BIT_POS_MASK GENMASK_32(4, 0)
#define RESET_OFFSET(id) (((id) & RESET_ID_MASK) >> RESET_ID_SHIFT)

This comment was marked as resolved.


if (!rd)
return SCMI_NOT_FOUND;

Copy link
Contributor

Choose a reason for hiding this comment

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

if (!rd->rstctrl) return SCMI_DENIED ?
(to match rstctrl_get_exclusive() test at line 1141)

Copy link
Contributor

Choose a reason for hiding this comment

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

If reset controller access is not exclusive t line 1141 then rd->rstctrl is NULL and OP-TEE core will segfault at line 1094/1097.

@TonyHan11
Copy link
Contributor Author

@etienne-lms update according to your comments and add part of the review tags, thank you.

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.

Acked-by: Etienne Carriere <[email protected]> fro commit
"drivers: clk: sam: rename the sama7g5 UTMI clocks for USB PHY".

Few comments still to address.

@@ -8,6 +8,12 @@
#include <compiler.h>
#include <stdbool.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Please address the above comment.
(commit "drivers: atmel_rstc: new data and functions to handle reset assert/deassert")

@@ -24,6 +24,11 @@

static vaddr_t rstc_base;

struct sam_reset_data {
bool rstc_always_secure;
Copy link
Contributor

Choose a reason for hiding this comment

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

Please address the above comment.
(commit "drivers: atmel_rstc: add functions to allocate/get reset controller/lines")

@TonyHan11
Copy link
Contributor Author

#include <stdbool.h> already added in previous update: from ac07e4e to 9e05490

update with the following changes:

  • add Acked-byfor commit "drivers: clk: sam: rename the sama7g5 UTMI clocks for USB PHY".
  • add #include <util.h>

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.

There is a comment not address on commit "plat-sam: scmi_server: use SCMI reset to manage USB reset for sama7g5".
Could you rebase this P-R to fix the merge conflicts?


if (!rd)
return SCMI_NOT_FOUND;

Copy link
Contributor

Choose a reason for hiding this comment

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

If reset controller access is not exclusive t line 1141 then rd->rstctrl is NULL and OP-TEE core will segfault at line 1094/1097.

{
const struct channel_resources *resource = find_resource(channel_id);

if (resource && scmi_id < resource->rd_count)
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpicking: by the way:, remove the extra space char before scmi_id.

@TonyHan11
Copy link
Contributor Author

redundant space char before scmi_id removed and fixed the check for rd and rd->rstctrl, thank you.

@TonyHan11
Copy link
Contributor Author

rebased on the latest master branch with the merge conflict fixed.

@TonyHan11
Copy link
Contributor Author

Add a commit to fix the compile error caused by the wrong path of the header file included in core/drivers/microchip_pit.c.

@TonyHan11
Copy link
Contributor Author

Sorry for adding another fix for correcting the length used for comparing the clock names in core/drivers/microchip_pit.c.

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.

I think you should squash commits
"drivers: atmel_rstc: new data and functions to handle reset assert/deassert"
and "drivers: atmel_rstc: add functions to allocate/get reset controller/lines"
unless what to former likely triggers a build warning on unused sam_rst_list.

Acked-by: Etienne Carriere <[email protected]> for commits
"drivers: atmel_rstc: add functions to allocate/get reset controller/lines" (with malloc.h inclusion fixed)
and "plat-sam: scmi_server: use SCMI reset to manage USB reset for sama7g5".

For commit "drivers: microchip_pit: fix the path of "dt_driver.h" included", could you add a Fixes: tag to the commit message. With that addressed,
Acked-by: Etienne Carriere <[email protected]> for that commit.

if (sam_rstline)
return sam_rstline;

sam_rstline = calloc(1, sizeof(*sam_rstline));
Copy link
Contributor

Choose a reason for hiding this comment

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

#include <malloc.h>

The UTMI clocks for USB PHY are handled in OP-TEE due to they are
controlled by the registers from RSTC (reset controller) which is
always-secured.
SCMI "reset domain management protocol" makes it prossible to handle the
resets from the kernel running in normal world. So the code in kernel for
these clocks need to be enabled. Here renaming the clocks to avoid
registering them failed from the kernel.

Signed-off-by: Tony Han <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
@TonyHan11
Copy link
Contributor Author

Commits "drivers: atmel_rstc: new data and functions to handle reset assert/deassert"
and "drivers: atmel_rstc: add functions to allocate/get reset controller/lines" not
squashed. The definition of sam_rst_list is moved to the 2nd commit as it is not
used in the 1st commit. Acked-by added for the 2nd commit.

Acked-by added for commits
"drivers: atmel_rstc: add functions to allocate/get reset controller/lines" (#include <malloc.h> added)
and "plat-sam: scmi_server: use SCMI reset to manage USB reset for sama7g5".

Fixes added to the commit messages for the last 2 commits.
Acked-by added for commit "drivers: microchip_pit: fix the path of "dt_driver.h" included".

Thank you very much.

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.

Acked-by: Etienne Carriere <[email protected]> for commit
"drivers: microchip_pit: fix the length used for comparing the clock names".
I've added a comment for another potential debug inconvenience.

@@ -34,7 +34,8 @@ static TEE_Result microchip_pit_probe(const void *fdt, int node,

do {
parent = clk_get_parent_by_index(gclk, i++);
if (!memcmp("syspll", clk_get_name(parent), sizeof("syspll")))
if (!memcmp("syspll", clk_get_name(parent),
sizeof("syspll") - 1))
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency, i think you also should also test parent is not NULL (at least with assert()) to get a better trace message instead of a segfault from clk_get_name(). No strong issue here since anyway you expect a panic at line 42 but this line would never be reached.

@TonyHan11
Copy link
Contributor Author

Acked-by added and also moved the test of parent into the while loop to improve debug convenience.

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.

Acked-by: Etienne Carriere <[email protected]> for commit
"drivers: atmel_rstc: new data and functions to handle reset assert/deassert".

The whole series looks good to me.

…assert

Define new struct and functions for handling the reset controller, reset
lines and the reset operations (assert, deassert).

Signed-off-by: Tony Han <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
…ines

Define new functions for getting the reset controller, find or allocate
the reset lines.

Signed-off-by: Tony Han <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
Update the type of RSTC driver to DT_DRIVER_RSTCTRL and probe RSTC with
the concept of controller and lines.

Signed-off-by: Tony Han <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
Enable "reset domain management protocol", add reset domains to SCMI
channel and add functions for SCMI reset domain.

Signed-off-by: Tony Han <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
…iver

Enable CFG_SCMI_MSG_RESET_DOMAIN and CFG_DRIVERS_RSTCTRL.

Signed-off-by: Tony Han <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
change "#include <dt_driver.h>" to "#include <kernel/dt_driver.h>" due to
"dt_driver.h" is located at "core/include/kernel/" and the path is not in
the include paths which would cause compile errors.

Fixes: 8796ab4 ("drivers: microchip_pit: add driver for sama7g54's pit64b")
Signed-off-by: Tony Han <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
…ames

sizeof("syspll") equals to 7 with a character '\0' in count, adjust the
length used for the comparison to obtain the expected result.
Move the test of "parent" into the while loop to improve debug convenience.

Fixes: 8796ab4 ("drivers: microchip_pit: add driver for sama7g54's pit64b")
Signed-off-by: Tony Han <[email protected]>
Acked-by: Etienne Carriere <[email protected]>
@TonyHan11
Copy link
Contributor Author

@etienne-lms The review tag added, thanks a lot.

@jforissier jforissier merged commit 9145b71 into OP-TEE:master Jan 9, 2025
10 checks passed
@TonyHan11 TonyHan11 deleted the scmi_reset branch January 10, 2025 02:23
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