[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3] arm: platform: qcom: add basic support SA8155P SoC


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Date: Fri, 29 Mar 2024 00:08:57 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=MH1butYk+sVQ3P+oDpW9nG8CNGBCKGfZjsvyXmRUE3A=; b=co+NxXayP95jU+gfpouspVixkc+2fQ9nHQ87swqs9PssV7+NK6bLhOtKevMtr63b+AyJRtX+2eDrK3l/8q+YzS01FNtARRZr0pF4kN+kxCTqQ9TOOxflitvARLb5kU56XtbFzilHZGyY9tU10E60VrTYVgKRaGB1YnpMklGaXlVPdr6jLHIapZrBiI0ehj1HVXmsfalUZji8sQTqOy7ym6/nQWqS5zTBTZGQ5p620PFkYftQStf5WASqA1zqA6tmtva0IUln/kOZYWkWJfA/Z3OE1+qzhwVRXn51PcRDTD190bcBnJtvAPcUTjwyEXUQJgPv+4GANetQYIWCFx3Xdw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D97MIawLmQwsTLx66x1lIxjGCayzR1FGCIk9IFmaNQ48WCJfORvgC9p6h7SzJVFndTvsmzRkdnb8IqDZV4lZC2gfYyvQtB+V7SDtl75plLh1awRnNMWc/q/LNA4x+HzbjBtj8MJ7jwfZ+RHq6fc449wKnFJj0wkWwELIpqbBhCBkyxl4iT//typWK7AVwihIRV4uGA4lf0CuZvePk76YSJ32LUMKxUDsJYcCYl2l08Cq9hGF39YBt7Au9F/kjwsh9B4s0JjkrPAR58RZsDKQo/eA5V8OkWuethJZ0FOpNVCmfl9w6N09esHpdiImBD2W/YpvhDdzkT+RJzXUwoM1FA==
  • Cc: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Fri, 29 Mar 2024 00:09:31 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHagW1LlGLM/ZuGTEiUoHPlQw1VXw==
  • Thread-topic: [PATCH 3/3] arm: platform: qcom: add basic support SA8155P SoC

Qualcomm SA8155P is the automotive variant of SM8150 aka Snapdragon
855.

This patch adds very basic support for the platform. We need to handle
Qualcomm-specific SMC to workaround quirk in the QCOM SCM driver in
the Linux kernel. Basically the driver tries multiple different SMCs
to determine which calling convention is supported by a SoC. If all
calls fail it decides that the SoC uses "legacy SMC" and tries to
communicate with SCM by issuing SMC with funcid = 1. Problem is that
Xen has own understanding on how such SMC should be handled. It
interprets this SMC as legacy PSCI_cpu_off and happily turns of Linux
boot CPU.

To workaround this, we pretend that we support
QCOM_SCM_INFO_IS_CALL_AVAIL, this will make the driver use the latest
calling convention. All subsequent calls will fail anyways and the
driver will terminate self gracefully. This is not a big deal, because
right now (with Linux 6.8) even on baremetal setup the driver fails
anyways, because it does not know how to work with this SoC.

Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
---
 xen/arch/arm/platforms/Makefile |  1 +
 xen/arch/arm/platforms/qcom.c   | 77 +++++++++++++++++++++++++++++++++
 2 files changed, 78 insertions(+)
 create mode 100644 xen/arch/arm/platforms/qcom.c

diff --git a/xen/arch/arm/platforms/Makefile b/xen/arch/arm/platforms/Makefile
index 8632f4115f..6873735ef0 100644
--- a/xen/arch/arm/platforms/Makefile
+++ b/xen/arch/arm/platforms/Makefile
@@ -9,5 +9,6 @@ obj-$(CONFIG_ALL_PLAT)   += sunxi.o
 obj-$(CONFIG_ALL64_PLAT) += thunderx.o
 obj-$(CONFIG_ALL64_PLAT) += xgene-storm.o
 obj-$(CONFIG_ALL64_PLAT) += brcm-raspberry-pi.o
+obj-$(CONFIG_ALL64_PLAT) += qcom.o
 obj-$(CONFIG_MPSOC_PLATFORM)  += xilinx-zynqmp.o
 obj-$(CONFIG_MPSOC_PLATFORM)  += xilinx-zynqmp-eemi.o
diff --git a/xen/arch/arm/platforms/qcom.c b/xen/arch/arm/platforms/qcom.c
new file mode 100644
index 0000000000..77e9c58649
--- /dev/null
+++ b/xen/arch/arm/platforms/qcom.c
@@ -0,0 +1,77 @@
+/*
+ * xen/arch/arm/platforms/qcom.c
+ *
+ * Qualcomm SoCs specific code
+ *
+ * Volodymyr Babchuk <volodymyr_babchuk@xxxxxxxx>
+ *
+ * Copyright (c) 2024 EPAM Systems.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <asm/platform.h>
+#include <public/arch-arm/smccc.h>
+#include <asm/smccc.h>
+
+#define SCM_SMC_FNID(s, c)     ((((s) & 0xFF) << 8) | ((c) & 0xFF))
+#define QCOM_SCM_SVC_INFO              0x06
+#define QCOM_SCM_INFO_IS_CALL_AVAIL    0x01
+
+#define ARM_SMCCC_SIP_QCOM_SCM_IS_CALL_AVAIL                            \
+    ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL,                             \
+                       ARM_SMCCC_CONV_64,                               \
+                       ARM_SMCCC_OWNER_SIP,                             \
+                       SCM_SMC_FNID(QCOM_SCM_SVC_INFO,                  \
+                                    QCOM_SCM_INFO_IS_CALL_AVAIL))
+
+static const char * const sa8155p_dt_compat[] __initconst =
+{
+    "qcom,sa8155p",
+    NULL
+};
+
+static bool sa8155p_smc(struct cpu_user_regs *regs)
+{
+    uint32_t funcid = get_user_reg(regs, 0);
+
+    switch ( funcid ) {
+    case ARM_SMCCC_SIP_QCOM_SCM_IS_CALL_AVAIL:
+        /*
+         * We need to implement this specific call only to make Linux
+         * counterpart happy: QCOM SCM driver in Linux tries to
+         * determine calling convention by issuing this particular
+         * SMC. If it receives an error it assumes that platform uses
+         * legacy calling convention and tries to issue SMC with
+         * funcid = 1. Xen interprets this as PSCI_cpu_off and turns
+         * off Linux boot vCPU.
+         */
+        set_user_reg(regs, 0, ARM_SMCCC_SUCCESS);
+        set_user_reg(regs, 1, 1);
+        return true;
+    default:
+        return false;
+    }
+}
+
+PLATFORM_START(sa8155p, "Qualcomm SA8155P")
+    .compatible = sa8155p_dt_compat,
+    .smc = sa8155p_smc
+PLATFORM_END
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
-- 
2.43.0



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.