Skip to contentSkip to conversation

qcom SCM updates

PATCH In review Stephen Boyd 6 participants 17 messages Aug 5, 2014 – Jan 23, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

cover qcom SCM updates

The SCM code in the mainline kernel is woefully out of data from what is in the downstream msm kernels. Update the code to be at least functionally correct and useful for features like cpuidle and suspend.

Olav Haugan (1):
msm: scm: Add logging of actual return code from scm call

Saravana Kannan (1):
msm: scm: Add API to query for service/command availability.

Stephen Boyd (5):
msm: scm: Fix incorrect cache invalidation
msm: scm: Get cacheline size from CTR
msm: scm: Add atomic SCM APIs
msm: scm: Add a feat version query API
msm: scm: Move the scm driver to drivers/soc/qcom

Vikram Mulukutla (1):
msm: scm: Flush the command buffer only instead of the entire cache

 arch/arm/mach-qcom/Kconfig                     |   3 -
 arch/arm/mach-qcom/Makefile                    |   4 +-
 arch/arm/mach-qcom/scm-boot.c                  |   2 +-
 drivers/soc/qcom/Kconfig                       |   2 +
 drivers/soc/qcom/Makefile                      |   2 +
 {arch/arm/mach-qcom => drivers/soc/qcom}/scm.c | 162 ++++++++++++++++++++++---
 {arch/arm/mach-qcom => include/soc/qcom}/scm.h |   8 +-
 7 files changed, 158 insertions(+), 25 deletions(-)
 rename {arch/arm/mach-qcom => drivers/soc/qcom}/scm.c (62%)
 rename {arch/arm/mach-qcom => include/soc/qcom}/scm.h (69%)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#1 lore raw

PATCH 1/8 msm: scm: Fix incorrect cache invalidation

The cache invalidation in scm_call() correctly rounds down the start address to invalidate the beginning of the cacheline but doesn't properly round up the 'end' address to make it aligned. The last chunk of the buffer won't be invalidated when 'end' is not cacheline size aligned so make sure to invalidate the last few bytes in such situations. It also doesn't do anything about outer caches so make sure to invalidate and flush those as well.

---
 arch/arm/mach-qcom/scm.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)
arch/arm/mach-qcom/scm.c +23 -8
index c536fd6bf827..820c72165e19 100644
@@ -22,6 +22,7 @@
 #include <linux/errno.h>
 #include <linux/err.h>
 
+#include <asm/outercache.h>
 #include <asm/cacheflush.h>
 
 #include "scm.h"
@@ -203,6 +204,7 @@ static int __scm_call(const struct scm_command *cmd)
 	 * side in the buffer.
 	 */
 	flush_cache_all();
+	outer_flush_all();
 	ret = smc(cmd_addr);
 	if (ret < 0)
 		ret = scm_remap_error(ret);
@@ -210,6 +212,20 @@ static int __scm_call(const struct scm_command *cmd)
 	return ret;
 }
 
+static void scm_inv_range(unsigned long start, unsigned long end)
+{
+	start = round_down(start, CACHELINESIZE);
+	end = round_up(end, CACHELINESIZE);
+	outer_inv_range(start, end);
+	while (start < end) {
+		asm ("mcr p15, 0, %0, c7, c6, 1" : : "r" (start)
+		     : "memory");
+		start += CACHELINESIZE;
+	}
+	dsb();
+	isb();
+}
+
 /**
  * scm_call() - Send an SCM command
  * @svc_id: service identifier
@@ -227,6 +243,7 @@ int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len,
 	int ret;
 	struct scm_command *cmd;
 	struct scm_response *rsp;
+	unsigned long start, end;
 
 	cmd = alloc_scm_command(cmd_len, resp_len);
 	if (!cmd)
@@ -243,17 +260,15 @@ int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len,
 		goto out;
 
 	rsp = scm_command_to_response(cmd);
+	start = (unsigned long)rsp;
+
 	do {
-		u32 start = (u32)rsp;
-		u32 end = (u32)scm_get_response_buffer(rsp) + resp_len;
-		start &= ~(CACHELINESIZE - 1);
-		while (start < end) {
-			asm ("mcr p15, 0, %0, c7, c6, 1" : : "r" (start)
-			     : "memory");
-			start += CACHELINESIZE;
-		}
+		scm_inv_range(start, start + sizeof(*rsp));
 	} while (!rsp->is_complete);
 
+	end = (unsigned long)scm_get_response_buffer(rsp) + resp_len;
+	scm_inv_range(start, end);
+
 	if (resp_buf)
 		memcpy(resp_buf, scm_get_response_buffer(rsp), resp_len);
 out:
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#2 lore raw

PATCH 2/8 msm: scm: Get cacheline size from CTR

In reply to Stephen Boyd

Instead of hardcoding the cacheline size as 32, get the cacheline size from the CTR register.

---
 arch/arm/mach-qcom/scm.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
arch/arm/mach-qcom/scm.c +8 -6
index 820c72165e19..c08786ebf116 100644
@@ -27,9 +27,6 @@
 
 #include "scm.h"
 
-/* Cache line size for msm8x60 */
-#define CACHELINESIZE 32
-
 #define SCM_ENOMEM		-5
 #define SCM_EOPNOTSUPP		-4
 #define SCM_EINVAL_ADDR		-3
@@ -214,13 +211,18 @@ static int __scm_call(const struct scm_command *cmd)
 
 static void scm_inv_range(unsigned long start, unsigned long end)
 {
-	start = round_down(start, CACHELINESIZE);
-	end = round_up(end, CACHELINESIZE);
+	u32 cacheline_size, ctr;
+
+	asm volatile("mrc p15, 0, %0, c0, c0, 1" : "=r" (ctr));
+	cacheline_size = 4 << ((ctr >> 16) & 0xf);
+
+	start = round_down(start, cacheline_size);
+	end = round_up(end, cacheline_size);
 	outer_inv_range(start, end);
 	while (start < end) {
 		asm ("mcr p15, 0, %0, c7, c6, 1" : : "r" (start)
 		     : "memory");
-		start += CACHELINESIZE;
+		start += cacheline_size;
 	}
 	dsb();
 	isb();
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#3 lore raw

PATCH 3/8 msm: scm: Flush the command buffer only instead of the entire cache

In reply to Stephen Boyd

From: Vikram Mulukutla <[email protected]>

scm_call flushes the entire cache before calling into the secure world. This is both a performance penalty as well as insufficient on SMP systems where the CPUs possess a write-back L1 cache. Flush only the command and response buffers instead, moving the responsibility of flushing any other cached buffer (being passed to the secure world) to callers.

---
 arch/arm/mach-qcom/scm.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
arch/arm/mach-qcom/scm.c +12 -5
index c08786ebf116..ec37b037e69c 100644
@@ -196,12 +196,12 @@ static int __scm_call(const struct scm_command *cmd)
 	u32 cmd_addr = virt_to_phys(cmd);
 
 	/*
-	 * Flush the entire cache here so callers don't have to remember
-	 * to flush the cache when passing physical addresses to the secure
-	 * side in the buffer.
+	 * Flush the command buffer so that the secure world sees
+	 * the correct data.
 	 */
-	flush_cache_all();
-	outer_flush_all();
+	__cpuc_flush_dcache_area((void *)cmd, cmd->len);
+	outer_flush_range(cmd_addr, cmd_addr + cmd->len);
+
 	ret = smc(cmd_addr);
 	if (ret < 0)
 		ret = scm_remap_error(ret);
@@ -238,6 +238,13 @@ static void scm_inv_range(unsigned long start, unsigned long end)
  * @resp_len: length of the response buffer
  *
  * Sends a command to the SCM and waits for the command to finish processing.
+ *
+ * A note on cache maintenance:
+ * Note that any buffers that are expected to be accessed by the secure world
+ * must be flushed before invoking scm_call and invalidated in the cache
+ * immediately after scm_call returns. Cache maintenance on the command and
+ * response buffers is taken care of by scm_call; however, callers are
+ * responsible for any other cached buffers passed over to the secure world.
  */
 int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len,
 		void *resp_buf, size_t resp_len)
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#4 lore raw

PATCH 4/8 msm: scm: Add atomic SCM APIs

In reply to Stephen Boyd

The atomic SCM APIs are useful for commands that are guaranteed by the secure side to be uninterruptable, atomic and SMP safe. The calling convention use registers for passing parameters and return values between the secure and non-secure side. Support this interface with scm_call_atomic[1-2]() functions corresponding to the number of arguments passed.

---
 arch/arm/mach-qcom/scm.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++
 arch/arm/mach-qcom/scm.h |  5 +++-
 2 files changed, 77 insertions(+), 1 deletion(-)
arch/arm/mach-qcom/scm.c +73 -0
index ec37b037e69c..a05cad3fa1c5 100644
@@ -286,6 +286,79 @@ out:
 }
 EXPORT_SYMBOL(scm_call);
 
+#define SCM_CLASS_REGISTER	(0x2 << 8)
+#define SCM_MASK_IRQS		BIT(5)
+#define SCM_ATOMIC(svc, cmd, n) (((((svc) << 10)|((cmd) & 0x3ff)) << 12) | \
+				SCM_CLASS_REGISTER | \
+				SCM_MASK_IRQS | \
+				(n & 0xf))
+
+/**
+ * scm_call_atomic1() - Send an atomic SCM command with one argument
+ * @svc_id: service identifier
+ * @cmd_id: command identifier
+ * @arg1: first argument
+ *
+ * This shall only be used with commands that are guaranteed to be
+ * uninterruptable, atomic and SMP safe.
+ */
+s32 scm_call_atomic1(u32 svc, u32 cmd, u32 arg1)
+{
+	int context_id;
+	register u32 r0 asm("r0") = SCM_ATOMIC(svc, cmd, 1);
+	register u32 r1 asm("r1") = (u32)&context_id;
+	register u32 r2 asm("r2") = arg1;
+
+	asm volatile(
+		__asmeq("%0", "r0")
+		__asmeq("%1", "r0")
+		__asmeq("%2", "r1")
+		__asmeq("%3", "r2")
+#ifdef REQUIRES_SEC
+			".arch_extension sec\n"
+#endif
+		"smc	#0	@ switch to secure world\n"
+		: "=r" (r0)
+		: "r" (r0), "r" (r1), "r" (r2)
+		: "r3");
+	return r0;
+}
+EXPORT_SYMBOL(scm_call_atomic1);
+
+/**
+ * scm_call_atomic2() - Send an atomic SCM command with two arguments
+ * @svc_id: service identifier
+ * @cmd_id: command identifier
+ * @arg1: first argument
+ * @arg2: second argument
+ *
+ * This shall only be used with commands that are guaranteed to be
+ * uninterruptable, atomic and SMP safe.
+ */
+s32 scm_call_atomic2(u32 svc, u32 cmd, u32 arg1, u32 arg2)
+{
+	int context_id;
+	register u32 r0 asm("r0") = SCM_ATOMIC(svc, cmd, 2);
+	register u32 r1 asm("r1") = (u32)&context_id;
+	register u32 r2 asm("r2") = arg1;
+	register u32 r3 asm("r3") = arg2;
+
+	asm volatile(
+		__asmeq("%0", "r0")
+		__asmeq("%1", "r0")
+		__asmeq("%2", "r1")
+		__asmeq("%3", "r2")
+		__asmeq("%4", "r3")
+#ifdef REQUIRES_SEC
+			".arch_extension sec\n"
+#endif
+		"smc	#0	@ switch to secure world\n"
+		: "=r" (r0)
+		: "r" (r0), "r" (r1), "r" (r2), "r" (r3));
+	return r0;
+}
+EXPORT_SYMBOL(scm_call_atomic2);
+
 u32 scm_get_version(void)
 {
 	int context_id;
arch/arm/mach-qcom/scm.h +4 -1
index 00b31ea58f29..1f0f0180e767 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -18,6 +18,9 @@
 extern int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len,
 		void *resp_buf, size_t resp_len);
 
+extern s32 scm_call_atomic1(u32 svc, u32 cmd, u32 arg1);
+extern s32 scm_call_atomic2(u32 svc, u32 cmd, u32 arg1, u32 arg2);
+
 #define SCM_VERSION(major, minor) (((major) << 16) | ((minor) & 0xFF))
 
 extern u32 scm_get_version(void);
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#5 lore raw

PATCH 5/8 msm: scm: Add API to query for service/command availability.

In reply to Stephen Boyd

From: Saravana Kannan <[email protected]>

Some drivers may need to query the secure environment about the availability of a particular service/command. Add support for this.

[sboyd at codeaurora.org: Add some commit text]
---
 arch/arm/mach-qcom/scm.c | 18 +++++++++++++++++-
 arch/arm/mach-qcom/scm.h |  2 ++
 2 files changed, 19 insertions(+), 1 deletion(-)
arch/arm/mach-qcom/scm.c +17 -1
index a05cad3fa1c5..e80571f57ca4 100644
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, Code Aurora Forum. All rights reserved.
+/* Copyright (c) 2010-2014, The Linux Foundation. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 and
@@ -394,3 +394,19 @@ u32 scm_get_version(void)
 	return version;
 }
 EXPORT_SYMBOL(scm_get_version);
+
+#define IS_CALL_AVAIL_CMD	1
+int scm_is_call_available(u32 svc_id, u32 cmd_id)
+{
+	int ret;
+	u32 svc_cmd = (svc_id << 10) | cmd_id;
+	u32 ret_val = 0;
+
+	ret = scm_call(SCM_SVC_INFO, IS_CALL_AVAIL_CMD, &svc_cmd,
+			sizeof(svc_cmd), &ret_val, sizeof(ret_val));
+	if (ret)
+		return ret;
+
+	return ret_val;
+}
+EXPORT_SYMBOL(scm_is_call_available);
arch/arm/mach-qcom/scm.h +2 -0
index 1f0f0180e767..f94c7279616a 100644
@@ -14,6 +14,7 @@
 
 #define SCM_SVC_BOOT			0x1
 #define SCM_SVC_PIL			0x2
+#define SCM_SVC_INFO			0x6
 
 extern int scm_call(u32 svc_id, u32 cmd_id, const void *cmd_buf, size_t cmd_len,
 		void *resp_buf, size_t resp_len);
@@ -24,5 +25,6 @@ extern s32 scm_call_atomic2(u32 svc, u32 cmd, u32 arg1, u32 arg2);
 #define SCM_VERSION(major, minor) (((major) << 16) | ((minor) & 0xFF))
 
 extern u32 scm_get_version(void);
+extern int scm_is_call_available(u32 svc_id, u32 cmd_id);
 
 #endif
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#6 lore raw

PATCH 6/8 msm: scm: Add a feat version query API

In reply to Stephen Boyd

Some users of SCM need to detect features and also detect if those features have certain versions available. Add this API.

---
 arch/arm/mach-qcom/scm.c | 13 +++++++++++++
 arch/arm/mach-qcom/scm.h |  1 +
 2 files changed, 14 insertions(+)
arch/arm/mach-qcom/scm.c +13 -0
index e80571f57ca4..7c62c03324f4 100644
@@ -410,3 +410,16 @@ int scm_is_call_available(u32 svc_id, u32 cmd_id)
 	return ret_val;
 }
 EXPORT_SYMBOL(scm_is_call_available);
+
+#define GET_FEAT_VERSION_CMD	3
+int scm_get_feat_version(u32 feat)
+{
+	if (scm_is_call_available(SCM_SVC_INFO, GET_FEAT_VERSION_CMD)) {
+		u32 version;
+		if (!scm_call(SCM_SVC_INFO, GET_FEAT_VERSION_CMD, &feat,
+				sizeof(feat), &version, sizeof(version)))
+			return version;
+	}
+	return 0;
+}
+EXPORT_SYMBOL(scm_get_feat_version);
arch/arm/mach-qcom/scm.h +1 -0
index f94c7279616a..6348b08524e7 100644
@@ -26,5 +26,6 @@ extern s32 scm_call_atomic2(u32 svc, u32 cmd, u32 arg1, u32 arg2);
 
 extern u32 scm_get_version(void);
 extern int scm_is_call_available(u32 svc_id, u32 cmd_id);
+extern int scm_get_feat_version(u32 feat);
 
 #endif
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#7 lore raw

PATCH 7/8 msm: scm: Add logging of actual return code from scm call

In reply to Stephen Boyd

From: Olav Haugan <[email protected]>

When an error occurs during an scm call the error returned is remapped so we lose the original error code. This means that when an error occurs we have no idea what actually failed within the secure environment.

Add a logging statement that will log the actual error code from scm call allowing us to easily determine what caused the error to occur.

---
 arch/arm/mach-qcom/scm.c | 1 +
 1 file changed, 1 insertion(+)
arch/arm/mach-qcom/scm.c +1 -0
index 7c62c03324f4..cfd4717aec78 100644
@@ -152,6 +152,7 @@ static inline void *scm_get_response_buffer(const struct scm_response *rsp)
 
 static int scm_remap_error(int err)
 {
+	pr_err("scm_call failed with error code %d\n", err);
 	switch (err) {
 	case SCM_ERROR:
 		return -EIO;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#8 lore raw

PATCH 8/8 msm: scm: Move the scm driver to drivers/soc/qcom

In reply to Stephen Boyd

Architectural changes in the ARM Linux kernel tree mandate the eventual removal of the mach-* directories. Move the scm driver to drivers/soc/qcom and the scm header to include/soc/qcom to support that removal.

---
 arch/arm/mach-qcom/Kconfig                     | 3 ---
 arch/arm/mach-qcom/Makefile                    | 4 +---
 arch/arm/mach-qcom/scm-boot.c                  | 2 +-
 drivers/soc/qcom/Kconfig                       | 2 ++
 drivers/soc/qcom/Makefile                      | 2 ++
 {arch/arm/mach-qcom => drivers/soc/qcom}/scm.c | 3 ++-
 {arch/arm/mach-qcom => include/soc/qcom}/scm.h | 0
 7 files changed, 8 insertions(+), 8 deletions(-)
 rename {arch/arm/mach-qcom => drivers/soc/qcom}/scm.c (99%)
 rename {arch/arm/mach-qcom => include/soc/qcom}/scm.h (100%)
arch/arm/mach-qcom/Kconfig +0 -3
index ee5697ba05bc..57d112d62018 100644
@@ -23,7 +23,4 @@ config ARCH_MSM8974
 	bool "Enable support for MSM8974"
 	select HAVE_ARM_ARCH_TIMER
 
-config QCOM_SCM
-	bool
-
 endif
arch/arm/mach-qcom/Makefile +1 -3
index 8f756ae1ae31..db41e8c27aec 100644
@@ -1,5 +1,3 @@
 obj-y			:= board.o
 obj-$(CONFIG_SMP)	+= platsmp.o
-obj-$(CONFIG_QCOM_SCM)	+= scm.o scm-boot.o
-
-CFLAGS_scm.o :=$(call as-instr,.arch_extension sec,-DREQUIRES_SEC=1)
+obj-$(CONFIG_QCOM_SCM)	+= scm-boot.o
arch/arm/mach-qcom/scm-boot.c +1 -1
index 45cee3e469a5..5add20e64d99 100644
@@ -17,8 +17,8 @@
 
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <soc/qcom/scm.h>
 
-#include "scm.h"
 #include "scm-boot.h"
 
 /*
drivers/soc/qcom/Kconfig +2 -0
index 7bd2c94f54a4..7dcd554496c7 100644
@@ -9,3 +9,5 @@ config QCOM_GSBI
           functions for connecting the underlying serial UART, SPI, and I2C
           devices to the output pins.
 
+config QCOM_SCM
+	bool
drivers/soc/qcom/Makefile +2 -0
index 438901257ac1..a39446d08ac6 100644
@@ -1 +1,3 @@
 obj-$(CONFIG_QCOM_GSBI)	+=	qcom_gsbi.o
+CFLAGS_scm.o :=$(call as-instr,.arch_extension sec,-DREQUIRES_SEC=1)
+obj-$(CONFIG_QCOM_SCM) += scm.o
drivers/soc/qcom/scm.c renamed from arch/arm/mach-qcom/scm.c +2 -1
similarity index 99%
rename from arch/arm/mach-qcom/scm.c
rename to drivers/soc/qcom/scm.c
index cfd4717aec78..2e98d80e2387 100644
@@ -22,10 +22,11 @@
 #include <linux/errno.h>
 #include <linux/err.h>
 
+#include <soc/qcom/scm.h>
+
 #include <asm/outercache.h>
 #include <asm/cacheflush.h>
 
-#include "scm.h"
 
 #define SCM_ENOMEM		-5
 #define SCM_EOPNOTSUPP		-4
include/soc/qcom/scm.h renamed from arch/arm/mach-qcom/scm.h +0 -0
similarity index 100%
rename from arch/arm/mach-qcom/scm.h
rename to include/soc/qcom/scm.h
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#9 lore raw

Re: [PATCH 8/8] msm: scm: Move the scm driver to drivers/soc/qcom

Quoted 10 lines · Stephen Boyd

Architectural changes in the ARM Linux kernel tree mandate the eventual removal of the mach-* directories. Move the scm driver to drivers/soc/qcom and the scm header to include/soc/qcom to support that removal.

---
 arch/arm/mach-qcom/Kconfig                     | 3 ---
 arch/arm/mach-qcom/Makefile                    | 4 +---
 arch/arm/mach-qcom/scm-boot.c                  | 2 +-

diff --git a/arch/arm/mach-qcom/scm.h b/include/soc/qcom/scm.h

Quoted 3 lines

similarity index 100%
rename from arch/arm/mach-qcom/scm.h
rename to include/soc/qcom/scm.h

Could we move scm-boot.c as well to drivers/soc/qcom and scm-boot.h to include/soc/qcom ?

#10 lore raw

Re: [PATCH 8/8] msm: scm: Move the scm driver to drivers/soc/qcom

Quoted 1 line · Lina Iyer

On Mon, 4 Aug 2014, Stephen Boyd wrote:

[...]

Quoted 1 line

Could we move scm-boot.c as well to drivers/soc/qcom and scm-boot.h to include/soc/qcom ?

Yes, we can do that.

But as of now we seem to only have one caller of this wrapper, so maybe we could move the functionality into platsmp.c and drop the file instead?

I looked at this a while back and was considering suggesting that we move the scm access behind firmware_ops, but then we should probably also extend the ops struct with all the needed ops related to firmware loading and other things; so I'm not sure if it's a beneficial move.

Regards,
Bjorn

#11 lore raw

Re: [PATCH 8/8] msm: scm: Move the scm driver to drivers/soc/qcom

Quoted 10 lines · Bjorn Andersson
Quoted 1 line · Lina Iyer

On Mon, 4 Aug 2014, Stephen Boyd wrote:

[...]

Quoted 1 line

Could we move scm-boot.c as well to drivers/soc/qcom and scm-boot.h to include/soc/qcom ?

Yes, we can do that.

But as of now we seem to only have one caller of this wrapper, so maybe we could move the functionality into platsmp.c and drop the file instead?

I am working on cpuidle drivers for QCOM targets and would very much like the scm-boot to be accessible from drivers/soc/qcom.

#12 lore raw

Re: [PATCH 8/8] msm: scm: Move the scm driver to drivers/soc/qcom

In reply to Stephen Boyd

I just saw this in the pull request from Kumar, so this is a bit late w.r.t. to the patch, but so was his merging of the code. :)

Quoted 4 lines · Stephen Boyd

Architectural changes in the ARM Linux kernel tree mandate the eventual removal of the mach-* directories. Move the scm driver to drivers/soc/qcom and the scm header to include/soc/qcom to support that removal.

The idea is not blindly move one dumping ground to a new place.

I see only two exported functions from scm.c:

scm_get_version: This is not used anywhere in the kernel and can just be removed
scm_call: This is used by scm-boot, and would be better to translate over to firmware_ops in the first place.

So, can you please rework this with the above in mind instead of just moving the files over? Thanks!

-Olof

#13 lore raw

Re: [PATCH 8/8] msm: scm: Move the scm driver to drivers/soc/qcom

On Wed, Jan 21, 2015 at 5:13 PM, Olof Johansson <[email protected]> wrote:
[..]

Quoted 6 lines · Stephen Boyd
Quoted 4 lines

Architectural changes in the ARM Linux kernel tree mandate the eventual removal of the mach-* directories. Move the scm driver to drivers/soc/qcom and the scm header to include/soc/qcom to support that removal.

Quoted 8 lines

The idea is not blindly move one dumping ground to a new place.

I see only two exported functions from scm.c:

scm_get_version: This is not used anywhere in the kernel and can just be removed
scm_call: This is used by scm-boot, and would be better to translate over to firmware_ops in the first place.

Hi Olof,

I started this a while ago, as it felt like the right thing to do <tm>.

The problem with this approach is that e.g. firmware loading is partially handled through this interface. So implementing a remoteproc driver for wifi etc required me to add 6 new ops to the struct, loading the modem looks like it requires one more. HDMI requires one.

Looking at the downstream branch there's a bunch more (20+), so we would explode the firmware_ops struct with Qualcomm "specific" ops. This is not necessarily a bad idea, but needs to be considered before we jump the gun.

I haven't looked at the arm64 stuff in detail, but it looks to be shared between the two platforms, so either way it seems like the right approach to have this moved out to drivers/soc/qcom.

Regards,
Bjorn

#14 lore raw

Re: [PATCH 8/8] msm: scm: Move the scm driver to drivers/soc/qcom

Quoted 32 lines · Bjorn Andersson

On Wed, Jan 21, 2015 at 5:13 PM, Olof Johansson <[email protected]> wrote:
[..]

Quoted 6 lines · Stephen Boyd
Quoted 4 lines

Architectural changes in the ARM Linux kernel tree mandate the eventual removal of the mach-* directories. Move the scm driver to drivers/soc/qcom and the scm header to include/soc/qcom to support that removal.

Quoted 8 lines

The idea is not blindly move one dumping ground to a new place.

I see only two exported functions from scm.c:

scm_get_version: This is not used anywhere in the kernel and can just be removed
scm_call: This is used by scm-boot, and would be better to translate over to firmware_ops in the first place.

Hi Olof,

I started this a while ago, as it felt like the right thing to do <tm>.

The problem with this approach is that e.g. firmware loading is partially handled through this interface. So implementing a remoteproc driver for wifi etc required me to add 6 new ops to the struct, loading the modem looks like it requires one more. HDMI requires one.

Looking at the downstream branch there's a bunch more (20+), so we would explode the firmware_ops struct with Qualcomm "specific" ops. This is not necessarily a bad idea, but needs to be considered before we jump the gun.

Quoted 3 lines

I haven't looked at the arm64 stuff in detail, but it looks to be shared between the two platforms, so either way it seems like the right approach to have this moved out to drivers/soc/qcom.

As Bjorn says the scm interface ends up having a number of qcom specific calls that I don?t think the firmware ops should be implementing. I don?t see any value in adding qcom specific function pointers to the ops struct just to create another level of indirection.

I?m fine with adding a firmware_ops implementation that uses scm for those things that firmware_ops has today. However, I?m not clear on what the view of extending firmware_ops to arm64 is. If we do this do we move the firmware_ops code into drivers/soc ?

- k

Signature · 3 lines
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#15 lore raw

Re: [PATCH 8/8] msm: scm: Move the scm driver to drivers/soc/qcom

In reply to Olof Johansson
Quoted 15 lines · Olof Johansson

I just saw this in the pull request from Kumar, so this is a bit late w.r.t. to the patch, but so was his merging of the code. :)

Quoted 4 lines · Stephen Boyd

Architectural changes in the ARM Linux kernel tree mandate the eventual removal of the mach-* directories. Move the scm driver to drivers/soc/qcom and the scm header to include/soc/qcom to support that removal.

The idea is not blindly move one dumping ground to a new place.

I see only two exported functions from scm.c:

Quoted 8 lines

scm_get_version: This is not used anywhere in the kernel and can just be removed
scm_call: This is used by scm-boot, and would be better to translate over to firmware_ops in the first place.

So, can you please rework this with the above in mind instead of just moving the files over? Thanks!

jfyi, we have some pending drm/msm patches blocked on this move

(not trying to comment one way or another on whether all or some should be moved.. just pointing out there would be more in-tree users of it if it was moved)

BR,
-R

Quoted 6 lines

-Olof
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#16 lore raw
In reply to Stephen Boyd
Quoted 29 lines · Stephen Boyd

The SCM code in the mainline kernel is woefully out of data from what is in the downstream msm kernels. Update the code to be at least functionally correct and useful for features like cpuidle and suspend.

Olav Haugan (1):
msm: scm: Add logging of actual return code from scm call

Saravana Kannan (1):
msm: scm: Add API to query for service/command availability.

Stephen Boyd (5):
msm: scm: Fix incorrect cache invalidation
msm: scm: Get cacheline size from CTR
msm: scm: Add atomic SCM APIs
msm: scm: Add a feat version query API
msm: scm: Move the scm driver to drivers/soc/qcom

Vikram Mulukutla (1):
msm: scm: Flush the command buffer only instead of the entire cache

arch/arm/mach-qcom/Kconfig                     |   3 -
arch/arm/mach-qcom/Makefile                    |   4 +-
arch/arm/mach-qcom/scm-boot.c                  |   2 +-
drivers/soc/qcom/Kconfig                       |   2 +
drivers/soc/qcom/Makefile                      |   2 +
{arch/arm/mach-qcom => drivers/soc/qcom}/scm.c | 162 ++++++++++++++++++++++---
{arch/arm/mach-qcom => include/soc/qcom}/scm.h |   8 +-
7 files changed, 158 insertions(+), 25 deletions(-)
Quoted 2 lines

rename {arch/arm/mach-qcom => drivers/soc/qcom}/scm.c (62%) rename {arch/arm/mach-qcom => include/soc/qcom}/scm.h (69%)

I took patches 1-4,7-8. There are no immediate users for 5-6 at this time.

- k

Signature · 2 lines
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation