Skip to content

Commit 57e06f8

Browse files
committed
Merge tag 'qcom-drivers-for-6.7' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux into soc/drivers
Qualcomm driver updates for v6.7 This introduces partial support for the Qualcomm Secure Execution Environment SCM interface, and uses this to implement EFI variable access on the Windows On Snapdragon devices (for now). The 32/64-bit calling convention detector of the SCM interface is updated to not choose 64-bit convention when Linux is 32-bit. The "extern" specifier is dropped from the interface include file. The LLCC driver gains support for carrying configuration for multiple different system/DDR configurations for a given platform, and selecting between them. Support for Q[DR]U1000 is added to the driver. All exported symbols are transitioned to EXPORT_SYMBOL_GPL(). The platform_drivers in the Qualcomm SoC are transitioned to the void-returning remove_new implementation. The rmtfs memory driver gains support for leaving guard pages around the used area, to avoid issues if the allocation happens to be placed adjacent to another protected memory region. The socinfo driver gains knowledge about IPQ8174, QCM6490, SM7150P and various PMICs used together with SM8550. * tag 'qcom-drivers-for-6.7' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux: (44 commits) soc: qcom: socinfo: Convert to platform remove callback returning void soc: qcom: smsm: Convert to platform remove callback returning void soc: qcom: smp2p: Convert to platform remove callback returning void soc: qcom: smem: Convert to platform remove callback returning void soc: qcom: rmtfs_mem: Convert to platform remove callback returning void soc: qcom: qcom_stats: Convert to platform remove callback returning void soc: qcom: qcom_gsbi: Convert to platform remove callback returning void soc: qcom: qcom_aoss: Convert to platform remove callback returning void soc: qcom: pmic_glink: Convert to platform remove callback returning void soc: qcom: ocmem: Convert to platform remove callback returning void soc: qcom: llcc-qcom: Convert to platform remove callback returning void soc: qcom: icc-bwmon: Convert to platform remove callback returning void firmware: qcom_scm: use 64-bit calling convention only when client is 64-bit soc: qcom: llcc: Handle a second device without data corruption soc: qcom: Switch to EXPORT_SYMBOL_GPL() soc: qcom: smem: Annotate struct qcom_smem with __counted_by soc: qcom: rmtfs: Support discarding guard pages dt-bindings: reserved-memory: rmtfs: Allow guard pages dt-bindings: firmware: qcom,scm: document IPQ5018 compatible firmware: qcom_scm: disable SDI if required ... Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 09427e1 + c0989f7 commit 57e06f8

40 files changed

+2090
-261
lines changed

Documentation/devicetree/bindings/cache/qcom,llcc.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ description: |
2020
properties:
2121
compatible:
2222
enum:
23+
- qcom,qdu1000-llcc
2324
- qcom,sc7180-llcc
2425
- qcom,sc7280-llcc
2526
- qcom,sc8180x-llcc
@@ -44,6 +45,14 @@ properties:
4445
interrupts:
4546
maxItems: 1
4647

48+
nvmem-cells:
49+
items:
50+
- description: Reference to an nvmem node for multi channel DDR
51+
52+
nvmem-cell-names:
53+
items:
54+
- const: multi-chan-ddr
55+
4756
required:
4857
- compatible
4958
- reg
@@ -92,6 +101,7 @@ allOf:
92101
compatible:
93102
contains:
94103
enum:
104+
- qcom,qdu1000-llcc
95105
- qcom,sc8180x-llcc
96106
- qcom,sc8280xp-llcc
97107
then:

Documentation/devicetree/bindings/firmware/qcom,scm.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ properties:
2424
- qcom,scm-apq8064
2525
- qcom,scm-apq8084
2626
- qcom,scm-ipq4019
27+
- qcom,scm-ipq5018
2728
- qcom,scm-ipq5332
2829
- qcom,scm-ipq6018
2930
- qcom,scm-ipq806x
@@ -56,6 +57,7 @@ properties:
5657
- qcom,scm-sm6125
5758
- qcom,scm-sm6350
5859
- qcom,scm-sm6375
60+
- qcom,scm-sm7150
5961
- qcom,scm-sm8150
6062
- qcom,scm-sm8250
6163
- qcom,scm-sm8350
@@ -89,6 +91,14 @@ properties:
8991
protocol to handle sleeping SCM calls.
9092
maxItems: 1
9193

94+
qcom,sdi-enabled:
95+
description:
96+
Indicates that the SDI (Secure Debug Image) has been enabled by TZ
97+
by default and it needs to be disabled.
98+
If not disabled WDT assertion or reboot will cause the board to hang
99+
in the debug mode.
100+
type: boolean
101+
92102
qcom,dload-mode:
93103
$ref: /schemas/types.yaml#/definitions/phandle-array
94104
items:

Documentation/devicetree/bindings/reserved-memory/qcom,rmtfs-mem.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@ properties:
2626
description: >
2727
identifier of the client to use this region for buffers
2828
29+
qcom,use-guard-pages:
30+
type: boolean
31+
description: >
32+
Indicates that the firmware, or hardware, does not gracefully handle
33+
memory protection of this region when placed adjacent to other protected
34+
memory regions, and that padding around the used portion of the memory
35+
region is necessary.
36+
37+
When this is set, the first and last page should be left unused, and the
38+
effective size of the region will thereby shrink with two pages.
39+
2940
qcom,vmid:
3041
$ref: /schemas/types.yaml#/definitions/uint32-array
3142
description: >

Documentation/devicetree/bindings/soc/qcom/qcom,geni-se.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ properties:
5252
iommus:
5353
maxItems: 1
5454

55+
dma-coherent: true
56+
5557
required:
5658
- compatible
5759
- reg

MAINTAINERS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17801,6 +17801,18 @@ S: Maintained
1780117801
F: Documentation/devicetree/bindings/mtd/qcom,nandc.yaml
1780217802
F: drivers/mtd/nand/raw/qcom_nandc.c
1780317803

17804+
QUALCOMM QSEECOM DRIVER
17805+
M: Maximilian Luz <[email protected]>
17806+
17807+
S: Maintained
17808+
F: drivers/firmware/qcom_qseecom.c
17809+
17810+
QUALCOMM QSEECOM UEFISECAPP DRIVER
17811+
M: Maximilian Luz <[email protected]>
17812+
17813+
S: Maintained
17814+
F: drivers/firmware/qcom_qseecom_uefisecapp.c
17815+
1780417816
QUALCOMM RMNET DRIVER
1780517817
M: Subash Abhinov Kasiviswanathan <[email protected]>
1780617818
M: Sean Tranchetti <[email protected]>

drivers/firmware/Kconfig

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,39 @@ config QCOM_SCM_DOWNLOAD_MODE_DEFAULT
226226

227227
Say Y here to enable "download mode" by default.
228228

229+
config QCOM_QSEECOM
230+
bool "Qualcomm QSEECOM interface driver"
231+
depends on QCOM_SCM=y
232+
select AUXILIARY_BUS
233+
help
234+
Various Qualcomm SoCs have a Secure Execution Environment (SEE) running
235+
in the Trust Zone. This module provides an interface to that via the
236+
QSEECOM mechanism, using SCM calls.
237+
238+
The QSEECOM interface allows, among other things, access to applications
239+
running in the SEE. An example of such an application is 'uefisecapp',
240+
which is required to access UEFI variables on certain systems. If
241+
selected, the interface will also attempt to detect and register client
242+
devices for supported applications.
243+
244+
Select Y here to enable the QSEECOM interface driver.
245+
246+
config QCOM_QSEECOM_UEFISECAPP
247+
bool "Qualcomm SEE UEFI Secure App client driver"
248+
depends on QCOM_QSEECOM
249+
depends on EFI
250+
help
251+
Various Qualcomm SoCs do not allow direct access to EFI variables.
252+
Instead, these need to be accessed via the UEFI Secure Application
253+
(uefisecapp), residing in the Secure Execution Environment (SEE).
254+
255+
This module provides a client driver for uefisecapp, installing efivar
256+
operations to allow the kernel accessing EFI variables, and via that also
257+
provide user-space with access to EFI variables via efivarfs.
258+
259+
Select Y here to provide access to EFI variables on the aforementioned
260+
platforms.
261+
229262
config SYSFB
230263
bool
231264
select BOOT_VESA_SUPPORT

drivers/firmware/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ obj-$(CONFIG_RASPBERRYPI_FIRMWARE) += raspberrypi.o
2020
obj-$(CONFIG_FW_CFG_SYSFS) += qemu_fw_cfg.o
2121
obj-$(CONFIG_QCOM_SCM) += qcom-scm.o
2222
qcom-scm-objs += qcom_scm.o qcom_scm-smc.o qcom_scm-legacy.o
23+
obj-$(CONFIG_QCOM_QSEECOM) += qcom_qseecom.o
24+
obj-$(CONFIG_QCOM_QSEECOM_UEFISECAPP) += qcom_qseecom_uefisecapp.o
2325
obj-$(CONFIG_SYSFB) += sysfb.o
2426
obj-$(CONFIG_SYSFB_SIMPLEFB) += sysfb_simplefb.o
2527
obj-$(CONFIG_TI_SCI_PROTOCOL) += ti_sci.o

drivers/firmware/qcom_qseecom.c

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* Driver for Qualcomm Secure Execution Environment (SEE) interface (QSEECOM).
4+
* Responsible for setting up and managing QSEECOM client devices.
5+
*
6+
* Copyright (C) 2023 Maximilian Luz <[email protected]>
7+
*/
8+
#include <linux/auxiliary_bus.h>
9+
#include <linux/module.h>
10+
#include <linux/platform_device.h>
11+
#include <linux/slab.h>
12+
#include <linux/types.h>
13+
14+
#include <linux/firmware/qcom/qcom_qseecom.h>
15+
#include <linux/firmware/qcom/qcom_scm.h>
16+
17+
struct qseecom_app_desc {
18+
const char *app_name;
19+
const char *dev_name;
20+
};
21+
22+
static void qseecom_client_release(struct device *dev)
23+
{
24+
struct qseecom_client *client;
25+
26+
client = container_of(dev, struct qseecom_client, aux_dev.dev);
27+
kfree(client);
28+
}
29+
30+
static void qseecom_client_remove(void *data)
31+
{
32+
struct qseecom_client *client = data;
33+
34+
auxiliary_device_delete(&client->aux_dev);
35+
auxiliary_device_uninit(&client->aux_dev);
36+
}
37+
38+
static int qseecom_client_register(struct platform_device *qseecom_dev,
39+
const struct qseecom_app_desc *desc)
40+
{
41+
struct qseecom_client *client;
42+
u32 app_id;
43+
int ret;
44+
45+
/* Try to find the app ID, skip device if not found */
46+
ret = qcom_scm_qseecom_app_get_id(desc->app_name, &app_id);
47+
if (ret)
48+
return ret == -ENOENT ? 0 : ret;
49+
50+
dev_info(&qseecom_dev->dev, "setting up client for %s\n", desc->app_name);
51+
52+
/* Allocate and set-up the client device */
53+
client = kzalloc(sizeof(*client), GFP_KERNEL);
54+
if (!client)
55+
return -ENOMEM;
56+
57+
client->aux_dev.name = desc->dev_name;
58+
client->aux_dev.dev.parent = &qseecom_dev->dev;
59+
client->aux_dev.dev.release = qseecom_client_release;
60+
client->app_id = app_id;
61+
62+
ret = auxiliary_device_init(&client->aux_dev);
63+
if (ret) {
64+
kfree(client);
65+
return ret;
66+
}
67+
68+
ret = auxiliary_device_add(&client->aux_dev);
69+
if (ret) {
70+
auxiliary_device_uninit(&client->aux_dev);
71+
return ret;
72+
}
73+
74+
ret = devm_add_action_or_reset(&qseecom_dev->dev, qseecom_client_remove, client);
75+
if (ret)
76+
return ret;
77+
78+
return 0;
79+
}
80+
81+
/*
82+
* List of supported applications. One client device will be created per entry,
83+
* assuming the app has already been loaded (usually by firmware bootloaders)
84+
* and its ID can be queried successfully.
85+
*/
86+
static const struct qseecom_app_desc qcom_qseecom_apps[] = {
87+
{ "qcom.tz.uefisecapp", "uefisecapp" },
88+
};
89+
90+
static int qcom_qseecom_probe(struct platform_device *qseecom_dev)
91+
{
92+
int ret;
93+
int i;
94+
95+
/* Set up client devices for each base application */
96+
for (i = 0; i < ARRAY_SIZE(qcom_qseecom_apps); i++) {
97+
ret = qseecom_client_register(qseecom_dev, &qcom_qseecom_apps[i]);
98+
if (ret)
99+
return ret;
100+
}
101+
102+
return 0;
103+
}
104+
105+
static struct platform_driver qcom_qseecom_driver = {
106+
.driver = {
107+
.name = "qcom_qseecom",
108+
},
109+
.probe = qcom_qseecom_probe,
110+
};
111+
112+
static int __init qcom_qseecom_init(void)
113+
{
114+
return platform_driver_register(&qcom_qseecom_driver);
115+
}
116+
subsys_initcall(qcom_qseecom_init);
117+
118+
MODULE_AUTHOR("Maximilian Luz <[email protected]>");
119+
MODULE_DESCRIPTION("Driver for the Qualcomm SEE (QSEECOM) interface");
120+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)