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

plat/synquacer: enable SCMI support #1856

Merged

Conversation

masahisak
Copy link
Contributor

Enable the SCMI protocol support in SynQuacer platform.
Aside from power domain, system power and apcore management protocol,
this commit adds the vendor specific protocol(0x80).
This vendor specific protocol is used to get the dram mapping information
from SCP.

This commit also exposes scmi_handle to outside of drivers/arm/css/scmi,
to issue the SCMI vendor specific procotol from platform dependent code.

Signed-off-by: Masahisa Kojima masahisa.kojima@linaro.org

@ssg-bot
Copy link

ssg-bot commented Mar 5, 2019

Can one of the admins verify this patch?

@arm-tf-bot
Copy link

This pull request modifies subsystem(s) maintained by @b49020. Can you please review the changes?

@ghost
Copy link

ghost commented Mar 5, 2019

IP Review +1

@ghost
Copy link

ghost commented Mar 5, 2019

jenkins: test this please

@ghost
Copy link

ghost commented Mar 5, 2019

The CI failure is due to a MISRA defect we can ignore.

#include <lib/mmio.h>

/* SCMI vendor specific protocol */
#define SCMI_SYS_VENDOR_EXT_PROTO_ID 0x80
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the only difference from scmi_private.h. Would suggest to add this to the scmi_private.h and remove this file.


#include <sq_common.h>

int scmi_get_draminfo(void *p, struct draminfo *info);
Copy link
Contributor

Choose a reason for hiding this comment

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

This can go at the end of scmi.h. Create a section for vendor extensions using code comments and add this there.

int status;
int reserved;
struct draminfo info;
};
Copy link
Contributor

Choose a reason for hiding this comment

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

This structure can go in scmi.h at the end where a section for "vendor-specific" extensions can be created.

Copy link
Contributor Author

@masahisak masahisak Mar 6, 2019

Choose a reason for hiding this comment

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

I have submitted updated commit.
I really hesitate to add this definitions into include/drivers/arm/css/scmi.h.
I also need to add very vendor specific "struct draminfo" definition here.

Instead of modifying scmi.h, I added drivers/arm/css/scmi/vendor/scmi_sq.h.
This file contains synquacer specific protocol definition.

If you prefer to modify scmi.h, I will do so.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, what you have done is fine.

/*
* API to set the SCMI vendor extension protocol
*/
int scmi_get_draminfo(void *p, struct draminfo *info)
Copy link
Contributor

Choose a reason for hiding this comment

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

This can go into a new file within the following folder drivers/arm/css/scmi/vendor/scmi_sq.c.

/* Local power state for retention. Valid only for CPU power domains */
#define ARM_LOCAL_STATE_RET U(1)
/* Local power state for OFF/power-down. Valid for CPU and cluster power domains */
#define ARM_LOCAL_STATE_OFF U(2)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is introducing ARM platform layer dependency which might be a maintenance overhead in future. Currently the Power management for SCMI goes through a css_pm_scmi which introduces this dependency. How about removing that dependancy by implementing the functionality in css_pm_scmi.c in synquancer which can then directly invoke SCMI driver ?

I think that would be clean solution.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like duplicating stuff. Shouldn't we try to make files under drivers/arm/css/scp/ generic for reuse in other platforms? Like renaming these macros to PLAT_* rather than ARM_* in common css_pm_scmi.c. Or else if they need to be platform specific then move them to plat/arm.

Copy link
Contributor

Choose a reason for hiding this comment

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

The css_scp layer will have platform implementation details like the power levels available on the platform , the mapping between PSCI power state to SCP power state which makes it difficult to make it generic. The SCMI driver is generic where as css-scp is ARM platform specific.

Or else if they need to be platform specific then move them to plat/arm.

Hmm, I see your point. It used to be within plat/arm previously and was not intended to be generic. But I agree atleast the scp folder should should be within platform directory. The scmi folder can go into drivers/ folder. I will create a task to do that internally.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good.

@@ -33,12 +35,16 @@ uintptr_t sq_sec_entrypoint;

int sq_pwr_domain_on(u_register_t mpidr)
{
#if SQ_USE_SCMI_DRIVER
css_scp_on(mpidr);
Copy link
Contributor

Choose a reason for hiding this comment

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

As stated in my previous comment, instead of calling this function, implement a synq_scmi_on() function. This function can directly call the required SCMI driver.

@masahisak masahisak force-pushed the synquacer-scmi-support branch from 5bf9729 to 18099e2 Compare March 6, 2019 06:24
Copy link
Contributor

@soby-mathew soby-mathew 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 all reference to CSS in macro names and functions can be removed. See my comments.


#include <sq_common.h>

const uint32_t plat_css_core_pos_to_scmi_dmn_id_map[PLATFORM_CORE_COUNT] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think all the contents of this file can move to sq_pm_scmi.c

This array can just be called sq_core_pos_to_scmi_dmn_id[]


static scmi_channel_plat_info_t sq_scmi_plat_info = {
.scmi_mbx_mem = SQ_SCMI_PAYLOAD_BASE,
.db_reg_addr = PLAT_CSS_MHU_BASE + MHU_CPU_INTR_S_SET_OFFSET,
Copy link
Contributor

Choose a reason for hiding this comment

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

I dont think you need to use any CSS macro anymore. This can be PLAT_SQ_MHU_BASE

Copy link
Contributor Author

Choose a reason for hiding this comment

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

PLAT_CSS_MHU_BASE is used in include/drivers/arm/css/css_mhu_doorbell.h, and I still need
this macro to use generic MHU driver.
So, I submit separate commit to rename PLAT_CSS_MHU_BASE to PLAT_MHUV2_BASE.
I think it is not the best solution, but it is minimal modification without modifying much under plat/arm.

.ring_doorbell = &mhu_ring_doorbell,
};

scmi_channel_plat_info_t *plat_css_get_scmi_info()
Copy link
Contributor

Choose a reason for hiding this comment

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

You dont need this wrapper function anymore.

void __init plat_arm_pwrc_setup(void)
	{
		channel.info = &sq_scmi_plat_info;
...

return &sq_scmi_plat_info;
}

void plat_arm_gic_cpuif_disable(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

This function is not needed anymore

return 0;
}

void __init plat_arm_pwrc_setup(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

This function can be plat_sq_pwrc_setup()

@@ -41,27 +41,27 @@ void mhu_secure_message_start(unsigned int slot_id)
bakery_lock_get(&sq_lock);

/* Make sure any previous command has finished */
while (mmio_read_32(PLAT_SQ_MHU_BASE + CPU_INTR_S_STAT) &
while (mmio_read_32(PLAT_CSS_MHU_BASE + CPU_INTR_S_STAT) &
Copy link
Contributor

Choose a reason for hiding this comment

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

This change is not required as per my comments below.

panic();
}
wfi();
ERROR("CSS set power state: operation not handled.\n");
Copy link
Contributor

Choose a reason for hiding this comment

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

remove CSS from print messages.

* The global handle for invoking the SCMI driver APIs after the driver
* has been initialized.
*/
void *sq_scmi_handle;
Copy link
Contributor

Choose a reason for hiding this comment

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

The handle can be static now.

#define PLAT_MAX_PWR_LVL U(1)
/* System power domain level */
#define CSS_SYSTEM_PWR_DMN_LVL SQ_PWR_LVL2
Copy link
Contributor

Choose a reason for hiding this comment

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

This macro is not required I think.

@@ -69,7 +81,7 @@

#define DRAMINFO_BASE 0x2E00FFC0

#define PLAT_SQ_MHU_BASE 0x45000000
#define PLAT_CSS_MHU_BASE 0x45000000
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to change the name of macro.

@arm-tf-bot
Copy link

This pull request modifies subsystem(s) maintained by @npoushin, @thomas-arm. Can you please review the changes?

@masahisak
Copy link
Contributor Author

Thank you for your comment.
Could you kindly review the new patches?

Copy link
Contributor

@npoushin npoushin left a comment

Choose a reason for hiding this comment

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

Build tested, looks ok for sgi575

Copy link
Contributor

@b49020 b49020 left a comment

Choose a reason for hiding this comment

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

Apart from few nitpicks, this patch-set looks good to me. So:
Acked-by: Sumit Garg <sumit.garg@linaro.org>

@@ -11,6 +11,8 @@

#include <arch_helpers.h>
#include <common/debug.h>
#include <drivers/arm/css/css_scp.h>
#include <drivers/arm/css/scmi.h>
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need these includes now?

-I$(PLAT_PATH)/drivers/mhu
-I$(PLAT_PATH)/drivers/mhu \
-Idrivers/arm/css/scmi \
-Idrivers/arm/css/scmi/vendor
Copy link
Contributor

Choose a reason for hiding this comment

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

Use tabs for indentation similar to other places.

#define SQ_CORE_PWR_STATE(state) (state)->pwr_domain_state[SQ_PWR_LVL0]
#define SQ_CLUSTER_PWR_STATE(state) (state)->pwr_domain_state[SQ_PWR_LVL1]
#define SQ_SYSTEM_PWR_STATE(state) ((PLAT_MAX_PWR_LVL > SQ_PWR_LVL1) ?\
(state)->pwr_domain_state[SQ_PWR_LVL2] : 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since these macros are defined here, we can remove their duplicate definition from sq_psci.c and rather include this header file.

Copy link
Contributor

@soby-mathew soby-mathew left a comment

Choose a reason for hiding this comment

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

The changes look fine. Please let us know if you intend to fix the nits mentioned by @b49020 .

@soby-mathew
Copy link
Contributor

jenkins: test this please

Masahisa Kojima added 2 commits March 13, 2019 09:54
Enable the SCMI protocol support in SynQuacer platform.
Aside from power domain, system power and apcore management protocol,
this commit adds the vendor specific protocol(0x80).
This vendor specific protocol is used to get the dram mapping information
from SCP.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
MHU doorbell driver requires arm platform specific
macro "PLAT_CSS_MHU_BASE".
Rename it to "PLAT_MHUV2_BASE", so that platforms other than arm
can use generic MHU doorbell driver.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
@masahisak masahisak force-pushed the synquacer-scmi-support branch from 287aab0 to cf6c30e Compare March 13, 2019 01:03
@masahisak
Copy link
Contributor Author

The changes look fine. Please let us know if you intend to fix the nits mentioned by @b49020 .

I addressed comments, please kindly check.

@soby-mathew soby-mathew merged commit eb9da9e into ARM-software:integration Mar 13, 2019
@masahisak masahisak deleted the synquacer-scmi-support branch March 13, 2019 23:49
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.

6 participants