linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: elder@linaro.org (Alex Elder)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 04/10] ARM: bcm: have bcm_kona_smc() return request result
Date: Thu, 17 Apr 2014 21:30:09 -0500	[thread overview]
Message-ID: <1397788215-20279-5-git-send-email-elder@linaro.org> (raw)
In-Reply-To: <1397788215-20279-1-git-send-email-elder@linaro.org>

Currently it is assumed that SEC_ROM_RET_OK is the only valid "good"
result of a secure monitor request.  However the values that can be
returned by a secure monitor request are dependent on which service
id was provided.

We therefore should handle the result in a request-dependent way.
The most natural way to do that is to have the initiator of the
request--where bcm_kona_smc() is called--handle the result in a way
appropriate to the request.

An "smc" operation must be performed only on core 0, while the
request can be initiated from any core.  To pass back the request
result, we add a new field to the bcm_kona_smc_data structure, and
have bcm_kona_smc() return that value rather than 0.

There's only one caller right now.  Move the existing check of the
result out of __bcm_kona_smc() and into the kona_l2_cache_init()
where the SSAPI_ENABLE_L2_CACHE request is initiated.

Signed-off-by: Alex Elder <elder@linaro.org>
Reviewed-by: Tim Kryger <tim.kryger@linaro.org>
Reviewed-by: Markus Mayer <markus.mayer@linaro.org>
Reviewed-by: Matt Porter <mporter@linaro.org>
---
 arch/arm/mach-bcm/bcm_kona_smc.c |   12 +++++-------
 arch/arm/mach-bcm/kona.c         |    8 +++++++-
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-bcm/bcm_kona_smc.c b/arch/arm/mach-bcm/bcm_kona_smc.c
index 0d2bfe2..47cf360 100644
--- a/arch/arm/mach-bcm/bcm_kona_smc.c
+++ b/arch/arm/mach-bcm/bcm_kona_smc.c
@@ -30,6 +30,7 @@ struct bcm_kona_smc_data {
 	unsigned arg1;
 	unsigned arg2;
 	unsigned arg3;
+	unsigned result;
 };
 
 static const struct of_device_id bcm_kona_smc_ids[] __initconst = {
@@ -80,7 +81,6 @@ static void __bcm_kona_smc(void *info)
 {
 	struct bcm_kona_smc_data *data = info;
 	u32 *args = bcm_smc_buffer;
-	int rc;
 
 	BUG_ON(smp_processor_id() != 0);
 	BUG_ON(!args);
@@ -94,11 +94,8 @@ static void __bcm_kona_smc(void *info)
 	/* Flush caches for input data passed to Secure Monitor */
 	flush_cache_all();
 
-	/* Trap into Secure Monitor */
-	rc = bcm_kona_smc_asm(data->service_id, bcm_smc_buffer_phys);
-
-	if (rc != SEC_ROM_RET_OK)
-		pr_err("Secure Monitor call failed (0x%x)!\n", rc);
+	/* Trap into Secure Monitor and record the request result */
+	data->result = bcm_kona_smc_asm(data->service_id, bcm_smc_buffer_phys);
 }
 
 unsigned bcm_kona_smc(unsigned service_id, unsigned arg0, unsigned arg1,
@@ -111,6 +108,7 @@ unsigned bcm_kona_smc(unsigned service_id, unsigned arg0, unsigned arg1,
 	data.arg1 = arg1;
 	data.arg2 = arg2;
 	data.arg3 = arg3;
+	data.result = 0;
 
 	/*
 	 * Due to a limitation of the secure monitor, we must use the SMP
@@ -123,5 +121,5 @@ unsigned bcm_kona_smc(unsigned service_id, unsigned arg0, unsigned arg1,
 
 	put_cpu();
 
-	return 0;
+	return data.result;
 }
diff --git a/arch/arm/mach-bcm/kona.c b/arch/arm/mach-bcm/kona.c
index 768bc28..ecdd713 100644
--- a/arch/arm/mach-bcm/kona.c
+++ b/arch/arm/mach-bcm/kona.c
@@ -19,6 +19,7 @@
 
 void __init kona_l2_cache_init(void)
 {
+	unsigned int result;
 	int ret;
 
 	if (!IS_ENABLED(CONFIG_CACHE_L2X0))
@@ -31,7 +32,12 @@ void __init kona_l2_cache_init(void)
 		return;
 	}
 
-	bcm_kona_smc(SSAPI_ENABLE_L2_CACHE, 0, 0, 0, 0);
+	result = bcm_kona_smc(SSAPI_ENABLE_L2_CACHE, 0, 0, 0, 0);
+	if (result != SEC_ROM_RET_OK) {
+		pr_err("Secure Monitor call failed (%u)! Skipping L2 init.\n",
+			result);
+		return;
+	}
 
 	/*
 	 * The aux_val and aux_mask have no effect since L2 cache is already
-- 
1.7.9.5

  parent reply	other threads:[~2014-04-18  2:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-18  2:30 [PATCH 00/10] ARM: bcm: SCM and L2 cache code cleanup Alex Elder
2014-04-18  2:30 ` [PATCH 01/10] ARM: bcm: use memory accessors for ioremapped area Alex Elder
2014-04-18  2:30 ` [PATCH 02/10] ARM: bcm: err, don't BUG() on SMC init failures Alex Elder
2014-04-18  2:30 ` [PATCH 03/10] ARM: bcm: clean up SMC code Alex Elder
2014-04-18  2:30 ` Alex Elder [this message]
2014-04-18  2:30 ` [PATCH 05/10] ARM: bcm: don't special-case CPU 0 in bcm_kona_smc() Alex Elder
2014-04-18  2:30 ` [PATCH 06/10] ARM: bcm: config option for l2 cache support Alex Elder
2014-04-18  2:30 ` [PATCH 07/10] ARM: bcm: tidy up a few includes Alex Elder
2014-04-18  8:29   ` Russell King - ARM Linux
2014-04-18 12:05     ` Alex Elder
2014-04-18  2:30 ` [PATCH 08/10] ARM: bcm: use inline assembly for "smc" request Alex Elder
2014-04-18  2:30 ` [PATCH 09/10] ARM: bcm: rewrite commentary for bcm_kona_do_smc() Alex Elder
2014-04-18  2:30 ` [PATCH 10/10] ARM: bcm: rename "kona.h" and "kona.c" Alex Elder

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1397788215-20279-5-git-send-email-elder@linaro.org \
    --to=elder@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).