aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--module/scmi/include/mod_scmi.h14
-rwxr-xr-xmodule/scmi/src/mod_scmi.c90
-rw-r--r--product/juno/scp_ramfw/config_scmi.c3
-rw-r--r--product/rcar/scp_ramfw/config_scmi.c5
-rw-r--r--product/rdn1e1/scp_ramfw/config_scmi.c3
-rw-r--r--product/sgi575/scp_ramfw/config_scmi.c3
-rw-r--r--product/sgm775/scp_ramfw/config_scmi.c3
-rw-r--r--product/sgm776/scp_ramfw/config_scmi.c3
-rw-r--r--product/tc0/scp_ramfw/config_scmi.c3
9 files changed, 124 insertions, 3 deletions
diff --git a/module/scmi/include/mod_scmi.h b/module/scmi/include/mod_scmi.h
index 510846cb..4d88b553 100644
--- a/module/scmi/include/mod_scmi.h
+++ b/module/scmi/include/mod_scmi.h
@@ -73,6 +73,20 @@ struct mod_scmi_config {
*/
unsigned int protocol_count_max;
+#ifndef BUILD_HAS_RESOURCE_PERMISSIONS
+ /*!
+ * \brief Number of the disabled SCMI protocols for the PSCI agent.
+ * If set to zero then all protocols are allowed for a PSCI agent.
+ */
+ unsigned int dis_protocol_count_psci;
+
+ /*!
+ * \brief list protocols disabled for the PSCI agent , limited
+ * by protocol_count_psci
+ */
+ const uint32_t *dis_protocol_list_psci;
+#endif
+
/*!
* \brief Number of agents in the system. Must be smaller than or equal to
* SCMI_AGENT_ID_MAX.
diff --git a/module/scmi/src/mod_scmi.c b/module/scmi/src/mod_scmi.c
index dfefdb84..d27fff14 100755
--- a/module/scmi/src/mod_scmi.c
+++ b/module/scmi/src/mod_scmi.c
@@ -691,18 +691,23 @@ static int scmi_base_protocol_attributes_handler(fwk_id_t service_id,
const uint32_t *payload)
{
size_t protocol_count;
-#ifdef BUILD_HAS_RESOURCE_PERMISSIONS
int status;
+ unsigned int agent_id;
+
+#ifdef BUILD_HAS_RESOURCE_PERMISSIONS
size_t global_protocol_count;
enum mod_res_perms_permissions perms;
- unsigned int agent_id;
uint8_t protocol_id;
unsigned int index;
+#else
+ enum scmi_agent_type agent_type;
+#endif
status = get_agent_id(service_id, &agent_id);
if (status != FWK_SUCCESS)
return status;
+#ifdef BUILD_HAS_RESOURCE_PERMISSIONS
for (index = 0, protocol_count = 0, global_protocol_count = 0;
(index < FWK_ARRAY_SIZE(scmi_ctx.scmi_protocol_id_to_idx)) &&
(global_protocol_count < scmi_ctx.protocol_count);
@@ -725,7 +730,21 @@ static int scmi_base_protocol_attributes_handler(fwk_id_t service_id,
global_protocol_count++;
}
#else
- protocol_count = scmi_ctx.protocol_count;
+ status = get_agent_type(agent_id, &agent_type);
+ if (status != FWK_SUCCESS)
+ return status;
+
+ /*
+ * PSCI agents are only allowed access to certain protocols defined
+ * for the platform.
+ */
+ if (agent_type == SCMI_AGENT_TYPE_PSCI) {
+ fwk_assert(
+ scmi_ctx.protocol_count > scmi_ctx.config->dis_protocol_count_psci);
+ protocol_count =
+ scmi_ctx.protocol_count - scmi_ctx.config->dis_protocol_count_psci;
+ } else
+ protocol_count = scmi_ctx.protocol_count;
#endif
struct scmi_protocol_attributes_p2a return_values = {
@@ -848,11 +867,21 @@ static int scmi_base_discover_list_protocols_handler(fwk_id_t service_id,
uint8_t protocol_id;
#ifdef BUILD_HAS_RESOURCE_PERMISSIONS
enum mod_res_perms_permissions perms;
+#else
+ unsigned int dis_protocol_list_psci_index;
+ unsigned int protocol_count_psci;
+ enum scmi_agent_type agent_type;
+#endif
unsigned int agent_id;
status = get_agent_id(service_id, &agent_id);
if (status != FWK_SUCCESS)
goto error;
+
+#ifndef BUILD_HAS_RESOURCE_PERMISSIONS
+ status = get_agent_type(agent_id, &agent_type);
+ if (status != FWK_SUCCESS)
+ goto error;
#endif
status = get_max_payload_size(service_id, &max_payload_size);
@@ -872,8 +901,26 @@ static int scmi_base_discover_list_protocols_handler(fwk_id_t service_id,
parameters = (const struct scmi_base_discover_list_protocols_a2p *)payload;
skip = parameters->skip;
+#ifdef BUILD_HAS_RESOURCE_PERMISSIONS
protocol_count_max = (scmi_ctx.protocol_count < (skip + entry_count)) ?
scmi_ctx.protocol_count : (skip + entry_count);
+#else
+
+ if (agent_type == SCMI_AGENT_TYPE_PSCI) {
+ fwk_assert(
+ scmi_ctx.protocol_count > scmi_ctx.config->dis_protocol_count_psci);
+
+ protocol_count_psci =
+ scmi_ctx.protocol_count - scmi_ctx.config->dis_protocol_count_psci;
+
+ protocol_count_max = (protocol_count_psci < (skip + entry_count)) ?
+ protocol_count_psci :
+ (skip + entry_count);
+ } else
+ protocol_count_max = (scmi_ctx.protocol_count < (skip + entry_count)) ?
+ scmi_ctx.protocol_count :
+ (skip + entry_count);
+#endif
for (index = 0,
protocol_count = 0,
@@ -897,6 +944,43 @@ static int scmi_base_discover_list_protocols_handler(fwk_id_t service_id,
if (perms == MOD_RES_PERMS_ACCESS_DENIED) {
continue;
}
+#else
+ /*
+ * PSCI agents are only allowed access certain protocols defined
+ * for the platform.
+ */
+ if (agent_type == SCMI_AGENT_TYPE_PSCI) {
+ /*
+ * assert if a valid list of disabled protocols is supplied in case
+ * the number of the disabled protocols is not zero. In case the
+ * number of the disabled protocols is zero , then no list needs to
+ * be supplied
+ */
+ fwk_assert(
+ (scmi_ctx.config->dis_protocol_list_psci != NULL) ||
+ (scmi_ctx.config->dis_protocol_count_psci == 0));
+
+ /*
+ * check if the current protocol is within the disabled protocols
+ * list.
+ */
+ for (dis_protocol_list_psci_index = 0;
+ dis_protocol_list_psci_index <
+ scmi_ctx.config->dis_protocol_count_psci;
+ dis_protocol_list_psci_index++) {
+ if (protocol_id ==
+ scmi_ctx.config
+ ->dis_protocol_list_psci[dis_protocol_list_psci_index])
+ break;
+ }
+
+ /*
+ * don't include the protocol in case it is in the disabled list
+ */
+ if (dis_protocol_list_psci_index !=
+ scmi_ctx.config->dis_protocol_count_psci)
+ continue;
+ }
#endif
protocol_count++;
diff --git a/product/juno/scp_ramfw/config_scmi.c b/product/juno/scp_ramfw/config_scmi.c
index 8a22c6b0..4dda33e2 100644
--- a/product/juno/scp_ramfw/config_scmi.c
+++ b/product/juno/scp_ramfw/config_scmi.c
@@ -122,6 +122,9 @@ struct fwk_module_config config_scmi = {
.data =
&(struct mod_scmi_config){
.protocol_count_max = 6,
+#ifndef BUILD_HAS_RESOURCE_PERMISSIONS
+# error "Please configure the disabled protocols for PSCI agents"
+#endif
.agent_count = FWK_ARRAY_SIZE(agent_table) - 1,
.agent_table = agent_table,
.vendor_identifier = "arm",
diff --git a/product/rcar/scp_ramfw/config_scmi.c b/product/rcar/scp_ramfw/config_scmi.c
index a2de8fe3..7ab679b0 100644
--- a/product/rcar/scp_ramfw/config_scmi.c
+++ b/product/rcar/scp_ramfw/config_scmi.c
@@ -90,6 +90,11 @@ struct fwk_module_config config_scmi = {
.elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_element_table),
.data = &((struct mod_scmi_config){
.protocol_count_max = 9,
+#ifndef BUILD_HAS_RESOURCE_PERMISSIONS
+ /* No protocols are disabled for PSCI agents */
+ .dis_protocol_count_psci = 0,
+ .dis_protocol_list_psci = NULL,
+#endif
.agent_count = FWK_ARRAY_SIZE(agent_table) - 1,
.agent_table = agent_table,
.vendor_identifier = "arm",
diff --git a/product/rdn1e1/scp_ramfw/config_scmi.c b/product/rdn1e1/scp_ramfw/config_scmi.c
index c1e2e2f2..4b041a0f 100644
--- a/product/rdn1e1/scp_ramfw/config_scmi.c
+++ b/product/rdn1e1/scp_ramfw/config_scmi.c
@@ -72,6 +72,9 @@ const struct fwk_module_config config_scmi = {
.data =
&(struct mod_scmi_config){
.protocol_count_max = 9,
+#ifndef BUILD_HAS_RESOURCE_PERMISSIONS
+# error "Please configure the disabled protocols for PSCI agents"
+#endif
.agent_count = FWK_ARRAY_SIZE(agent_table) - 1,
.agent_table = agent_table,
.vendor_identifier = "arm",
diff --git a/product/sgi575/scp_ramfw/config_scmi.c b/product/sgi575/scp_ramfw/config_scmi.c
index 005c7f50..43b345a6 100644
--- a/product/sgi575/scp_ramfw/config_scmi.c
+++ b/product/sgi575/scp_ramfw/config_scmi.c
@@ -71,6 +71,9 @@ static struct mod_scmi_agent agent_table[] = {
const struct fwk_module_config config_scmi = {
.data = &((struct mod_scmi_config){
.protocol_count_max = 9,
+#ifndef BUILD_HAS_RESOURCE_PERMISSIONS
+# error "Please configure the disabled protocols for PSCI agents"
+#endif
.agent_count = FWK_ARRAY_SIZE(agent_table) - 1,
.agent_table = agent_table,
.vendor_identifier = "arm",
diff --git a/product/sgm775/scp_ramfw/config_scmi.c b/product/sgm775/scp_ramfw/config_scmi.c
index 1b7db3ea..f0255b4a 100644
--- a/product/sgm775/scp_ramfw/config_scmi.c
+++ b/product/sgm775/scp_ramfw/config_scmi.c
@@ -81,6 +81,9 @@ static const struct mod_scmi_agent agent_table[] = {
struct fwk_module_config config_scmi = {
.data = &((struct mod_scmi_config){
.protocol_count_max = 9,
+#ifndef BUILD_HAS_RESOURCE_PERMISSIONS
+# error "Please configure the disabled protocols for PSCI agents"
+#endif
.agent_count = FWK_ARRAY_SIZE(agent_table) - 1,
.agent_table = agent_table,
.vendor_identifier = "arm",
diff --git a/product/sgm776/scp_ramfw/config_scmi.c b/product/sgm776/scp_ramfw/config_scmi.c
index 7ca1ba84..fb7f77e9 100644
--- a/product/sgm776/scp_ramfw/config_scmi.c
+++ b/product/sgm776/scp_ramfw/config_scmi.c
@@ -82,6 +82,9 @@ struct fwk_module_config config_scmi = {
.data =
&(struct mod_scmi_config){
.protocol_count_max = 9,
+#ifndef BUILD_HAS_RESOURCE_PERMISSIONS
+# error "Please configure the disabled protocols for PSCI agents"
+#endif
.agent_count = FWK_ARRAY_SIZE(agent_table) - 1,
.agent_table = agent_table,
.vendor_identifier = "arm",
diff --git a/product/tc0/scp_ramfw/config_scmi.c b/product/tc0/scp_ramfw/config_scmi.c
index 75f405fd..90b7764f 100644
--- a/product/tc0/scp_ramfw/config_scmi.c
+++ b/product/tc0/scp_ramfw/config_scmi.c
@@ -87,6 +87,9 @@ const struct fwk_module_config config_scmi = {
.elements = FWK_MODULE_DYNAMIC_ELEMENTS(get_service_table),
.data = &((struct mod_scmi_config){
.protocol_count_max = 9,
+#ifndef BUILD_HAS_RESOURCE_PERMISSIONS
+# error "Please configure the disabled protocols for PSCI agents"
+#endif
.agent_count = FWK_ARRAY_SIZE(agent_table),
.agent_table = agent_table,
.vendor_identifier = "arm",