Skip to content

Commit a08000d

Browse files
committed
Merge tag 'qcom-drivers-for-6.5' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux into soc/drivers
Qualcomm driver updates for v6.5 Konrad Dybcio is promoted, from reviewer, to co-maintainer. The mdt_loader gets a fix to the detection of split binaries, where the previous logic sometimes concluded that the first segments was not split, in a split image. The unconditional calling of scm_pas_mem_setup() turns out to cause a regression and is reverted. The altmode subfunction of pmic_glink is enabled for SM8450. A new driver for exposing power statistics from the RPM, for debugging purposes, is introduced. OCMEM gets a debug prints of the hardware version, QMI helpers are transitioned to alloc_ordered_workqueue() and an error message in ramp_controller is improved. An API is introduced to the SMEM driver to allow other drivers to query the SoC id, rather than open-coding the parsing of the relevant SMEM item. This is then used to clean up the Qualcomm NVMEM-based cpufreq driver. Socinfo is extended with knowledge about IPQ5018, IPQ5312 and IPQ5302. * tag 'qcom-drivers-for-6.5' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux: (23 commits) soc: qcom: ocmem: Add OCMEM hardware version print cpufreq: qcom-nvmem: use helper to get SMEM SoC ID cpufreq: qcom-nvmem: use SoC ID-s from bindings soc: qcom: smem: introduce qcom_smem_get_soc_id() soc: qcom: smem: Switch to EXPORT_SYMBOL_GPL() soc: qcom: socinfo: move SMEM item struct and defines to a header soc: qcom: mdt_loader: Fix unconditional call to scm_pas_mem_setup MAINTAINERS: Add Konrad Dybcio as linux-arm-msm co-maintainer dt-bindings: sram: qcom,imem: Document MSM8226 soc: qcom: socinfo: Add Soc ID for IPQ5312 and IPQ5302 dt-bindings: arm: qcom,ids: add SoC ID for IPQ5312 and IPQ5302 soc: qcom: socinfo: Add IDs for IPQ5018 family dt-bindings: arm: qcom,ids: Add IDs for IPQ5018 family soc: qcom: Introduce RPM master stats driver dt-bindings: soc: qcom: Add RPM Master stats soc: qcom: qmi: Use alloc_ordered_workqueue() to create ordered workqueues soc: qcom: ramp_controller: Improve error message for failure in .remove() dt-bindings: soc: qcom: smd-rpm: allow MSM8226 over SMD soc: qcom: rpmpd: use correct __le32 type dt-bindings: soc: qcom: eud: Fix compatible string in the example ... Link: https://lore.kernel.org/r/20230611010044.2481875-1-andersson@kernel.org Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents 09f4406 + e81a16e commit a08000d

21 files changed

Lines changed: 442 additions & 140 deletions

File tree

Documentation/devicetree/bindings/soc/qcom/qcom,aoss-qmp.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ properties:
2626
items:
2727
- enum:
2828
- qcom,qdu1000-aoss-qmp
29+
- qcom,sa8775p-aoss-qmp
2930
- qcom,sc7180-aoss-qmp
3031
- qcom,sc7280-aoss-qmp
3132
- qcom,sc8180x-aoss-qmp

Documentation/devicetree/bindings/soc/qcom/qcom,eud.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ additionalProperties: false
5555
examples:
5656
- |
5757
eud@88e0000 {
58-
compatible = "qcom,sc7280-eud","qcom,eud";
58+
compatible = "qcom,sc7280-eud", "qcom,eud";
5959
reg = <0x88e0000 0x2000>,
6060
<0x88e2000 0x1000>;
61+
6162
ports {
6263
#address-cells = <1>;
6364
#size-cells = <0>;
@@ -67,6 +68,7 @@ examples:
6768
remote-endpoint = <&usb2_role_switch>;
6869
};
6970
};
71+
7072
port@1 {
7173
reg = <1>;
7274
eud_con: endpoint {
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/soc/qcom/qcom,rpm-master-stats.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Qualcomm Technologies, Inc. (QTI) RPM Master Stats
8+
9+
maintainers:
10+
- Konrad Dybcio <konrad.dybcio@linaro.org>
11+
12+
description: |
13+
The Qualcomm RPM (Resource Power Manager) architecture includes a concept
14+
of "RPM Masters". They can be thought of as "the local gang leaders", usually
15+
spanning a single subsystem (e.g. APSS, ADSP, CDSP). All of the RPM decisions
16+
(particularly around entering hardware-driven low power modes: XO shutdown
17+
and total system-wide power collapse) are first made at Master-level, and
18+
only then aggregated for the entire system.
19+
20+
The Master Stats provide a few useful bits that can be used to assess whether
21+
our device has entered the desired low-power mode, how long it took to do so,
22+
the duration of that residence, how long it took to come back online,
23+
how many times a given sleep state was entered and which cores are actively
24+
voting for staying awake.
25+
26+
This scheme has been used on various SoCs in the 2013-2023 era, with some
27+
newer or higher-end designs providing this information through an SMEM query.
28+
29+
properties:
30+
compatible:
31+
const: qcom,rpm-master-stats
32+
33+
qcom,rpm-msg-ram:
34+
$ref: /schemas/types.yaml#/definitions/phandle-array
35+
description: Phandle to an RPM MSG RAM slice containing the master stats
36+
minItems: 1
37+
maxItems: 5
38+
39+
qcom,master-names:
40+
$ref: /schemas/types.yaml#/definitions/string-array
41+
description:
42+
The name of the RPM Master which owns the MSG RAM slice where this
43+
instance of Master Stats resides
44+
minItems: 1
45+
maxItems: 5
46+
47+
required:
48+
- compatible
49+
- qcom,rpm-msg-ram
50+
- qcom,master-names
51+
52+
additionalProperties: false
53+
54+
examples:
55+
- |
56+
stats {
57+
compatible = "qcom,rpm-master-stats";
58+
qcom,rpm-msg-ram = <&apss_master_stats>,
59+
<&mpss_master_stats>,
60+
<&adsp_master_stats>,
61+
<&cdsp_master_stats>,
62+
<&tz_master_stats>;
63+
qcom,master-names = "APSS",
64+
"MPSS",
65+
"ADSP",
66+
"CDSP",
67+
"TZ";
68+
};
69+
...

Documentation/devicetree/bindings/soc/qcom/qcom,smd-rpm.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ if:
8181
contains:
8282
enum:
8383
- qcom,rpm-apq8084
84+
- qcom,rpm-msm8226
8485
- qcom,rpm-msm8916
8586
- qcom,rpm-msm8936
8687
- qcom,rpm-msm8974

Documentation/devicetree/bindings/sram/qcom,imem.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ properties:
1818
items:
1919
- enum:
2020
- qcom,apq8064-imem
21+
- qcom,msm8226-imem
2122
- qcom,msm8974-imem
2223
- qcom,qcs404-imem
2324
- qcom,sc7180-imem

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2566,7 +2566,7 @@ F: arch/arm64/boot/dts/qcom/sdm845-cheza*
25662566
ARM/QUALCOMM SUPPORT
25672567
M: Andy Gross <agross@kernel.org>
25682568
M: Bjorn Andersson <andersson@kernel.org>
2569-
R: Konrad Dybcio <konrad.dybcio@linaro.org>
2569+
M: Konrad Dybcio <konrad.dybcio@linaro.org>
25702570
L: linux-arm-msm@vger.kernel.org
25712571
S: Maintained
25722572
T: git git://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux.git

drivers/cpufreq/qcom-cpufreq-nvmem.c

Lines changed: 11 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,7 @@
2929
#include <linux/slab.h>
3030
#include <linux/soc/qcom/smem.h>
3131

32-
#define MSM_ID_SMEM 137
33-
34-
enum _msm_id {
35-
MSM8996V3 = 0xF6ul,
36-
APQ8096V3 = 0x123ul,
37-
MSM8996SG = 0x131ul,
38-
APQ8096SG = 0x138ul,
39-
};
40-
41-
enum _msm8996_version {
42-
MSM8996_V3,
43-
MSM8996_SG,
44-
NUM_OF_MSM8996_VERSIONS,
45-
};
32+
#include <dt-bindings/arm/qcom,ids.h>
4633

4734
struct qcom_cpufreq_drv;
4835

@@ -140,60 +127,32 @@ static void get_krait_bin_format_b(struct device *cpu_dev,
140127
dev_dbg(cpu_dev, "PVS version: %d\n", *pvs_ver);
141128
}
142129

143-
static enum _msm8996_version qcom_cpufreq_get_msm_id(void)
144-
{
145-
size_t len;
146-
u32 *msm_id;
147-
enum _msm8996_version version;
148-
149-
msm_id = qcom_smem_get(QCOM_SMEM_HOST_ANY, MSM_ID_SMEM, &len);
150-
if (IS_ERR(msm_id))
151-
return NUM_OF_MSM8996_VERSIONS;
152-
153-
/* The first 4 bytes are format, next to them is the actual msm-id */
154-
msm_id++;
155-
156-
switch ((enum _msm_id)*msm_id) {
157-
case MSM8996V3:
158-
case APQ8096V3:
159-
version = MSM8996_V3;
160-
break;
161-
case MSM8996SG:
162-
case APQ8096SG:
163-
version = MSM8996_SG;
164-
break;
165-
default:
166-
version = NUM_OF_MSM8996_VERSIONS;
167-
}
168-
169-
return version;
170-
}
171-
172130
static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
173131
struct nvmem_cell *speedbin_nvmem,
174132
char **pvs_name,
175133
struct qcom_cpufreq_drv *drv)
176134
{
177135
size_t len;
136+
u32 msm_id;
178137
u8 *speedbin;
179-
enum _msm8996_version msm8996_version;
138+
int ret;
180139
*pvs_name = NULL;
181140

182-
msm8996_version = qcom_cpufreq_get_msm_id();
183-
if (NUM_OF_MSM8996_VERSIONS == msm8996_version) {
184-
dev_err(cpu_dev, "Not Snapdragon 820/821!");
185-
return -ENODEV;
186-
}
141+
ret = qcom_smem_get_soc_id(&msm_id);
142+
if (ret)
143+
return ret;
187144

188145
speedbin = nvmem_cell_read(speedbin_nvmem, &len);
189146
if (IS_ERR(speedbin))
190147
return PTR_ERR(speedbin);
191148

192-
switch (msm8996_version) {
193-
case MSM8996_V3:
149+
switch (msm_id) {
150+
case QCOM_ID_MSM8996:
151+
case QCOM_ID_APQ8096:
194152
drv->versions = 1 << (unsigned int)(*speedbin);
195153
break;
196-
case MSM8996_SG:
154+
case QCOM_ID_MSM8996SG:
155+
case QCOM_ID_APQ8096SG:
197156
drv->versions = 1 << ((unsigned int)(*speedbin) + 4);
198157
break;
199158
default:

drivers/soc/qcom/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,17 @@ config QCOM_RMTFS_MEM
135135

136136
Say y here if you intend to boot the modem remoteproc.
137137

138+
config QCOM_RPM_MASTER_STATS
139+
tristate "Qualcomm RPM Master stats"
140+
depends on ARCH_QCOM || COMPILE_TEST
141+
help
142+
The RPM Master sleep stats driver provides detailed per-subsystem
143+
sleep/wake data, read from the RPM message RAM. It can be used to
144+
assess whether all the low-power modes available are entered as
145+
expected or to check which part of the SoC prevents it from sleeping.
146+
147+
Say y here if you intend to debug or monitor platform sleep.
148+
138149
config QCOM_RPMH
139150
tristate "Qualcomm RPM-Hardened (RPMH) Communication"
140151
depends on ARCH_QCOM || COMPILE_TEST

drivers/soc/qcom/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ obj-$(CONFIG_QCOM_QMI_HELPERS) += qmi_helpers.o
1414
qmi_helpers-y += qmi_encdec.o qmi_interface.o
1515
obj-$(CONFIG_QCOM_RAMP_CTRL) += ramp_controller.o
1616
obj-$(CONFIG_QCOM_RMTFS_MEM) += rmtfs_mem.o
17+
obj-$(CONFIG_QCOM_RPM_MASTER_STATS) += rpm_master_stats.o
1718
obj-$(CONFIG_QCOM_RPMH) += qcom_rpmh.o
1819
qcom_rpmh-y += rpmh-rsc.o
1920
qcom_rpmh-y += rpmh.o

drivers/soc/qcom/mdt_loader.c

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ int qcom_mdt_pas_init(struct device *dev, const struct firmware *fw,
210210
const struct elf32_hdr *ehdr;
211211
phys_addr_t min_addr = PHYS_ADDR_MAX;
212212
phys_addr_t max_addr = 0;
213+
bool relocate = false;
213214
size_t metadata_len;
214215
void *metadata;
215216
int ret;
@@ -224,6 +225,9 @@ int qcom_mdt_pas_init(struct device *dev, const struct firmware *fw,
224225
if (!mdt_phdr_valid(phdr))
225226
continue;
226227

228+
if (phdr->p_flags & QCOM_MDT_RELOCATABLE)
229+
relocate = true;
230+
227231
if (phdr->p_paddr < min_addr)
228232
min_addr = phdr->p_paddr;
229233

@@ -246,18 +250,40 @@ int qcom_mdt_pas_init(struct device *dev, const struct firmware *fw,
246250
goto out;
247251
}
248252

249-
ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr);
250-
if (ret) {
251-
/* Unable to set up relocation */
252-
dev_err(dev, "error %d setting up firmware %s\n", ret, fw_name);
253-
goto out;
253+
if (relocate) {
254+
ret = qcom_scm_pas_mem_setup(pas_id, mem_phys, max_addr - min_addr);
255+
if (ret) {
256+
/* Unable to set up relocation */
257+
dev_err(dev, "error %d setting up firmware %s\n", ret, fw_name);
258+
goto out;
259+
}
254260
}
255261

256262
out:
257263
return ret;
258264
}
259265
EXPORT_SYMBOL_GPL(qcom_mdt_pas_init);
260266

267+
static bool qcom_mdt_bins_are_split(const struct firmware *fw, const char *fw_name)
268+
{
269+
const struct elf32_phdr *phdrs;
270+
const struct elf32_hdr *ehdr;
271+
uint64_t seg_start, seg_end;
272+
int i;
273+
274+
ehdr = (struct elf32_hdr *)fw->data;
275+
phdrs = (struct elf32_phdr *)(ehdr + 1);
276+
277+
for (i = 0; i < ehdr->e_phnum; i++) {
278+
seg_start = phdrs[i].p_offset;
279+
seg_end = phdrs[i].p_offset + phdrs[i].p_filesz;
280+
if (seg_start > fw->size || seg_end > fw->size)
281+
return true;
282+
}
283+
284+
return false;
285+
}
286+
261287
static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
262288
const char *fw_name, int pas_id, void *mem_region,
263289
phys_addr_t mem_phys, size_t mem_size,
@@ -270,13 +296,15 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
270296
phys_addr_t min_addr = PHYS_ADDR_MAX;
271297
ssize_t offset;
272298
bool relocate = false;
299+
bool is_split;
273300
void *ptr;
274301
int ret = 0;
275302
int i;
276303

277304
if (!fw || !mem_region || !mem_phys || !mem_size)
278305
return -EINVAL;
279306

307+
is_split = qcom_mdt_bins_are_split(fw, fw_name);
280308
ehdr = (struct elf32_hdr *)fw->data;
281309
phdrs = (struct elf32_phdr *)(ehdr + 1);
282310

@@ -330,8 +358,7 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
330358

331359
ptr = mem_region + offset;
332360

333-
if (phdr->p_filesz && phdr->p_offset < fw->size &&
334-
phdr->p_offset + phdr->p_filesz <= fw->size) {
361+
if (phdr->p_filesz && !is_split) {
335362
/* Firmware is large enough to be non-split */
336363
if (phdr->p_offset + phdr->p_filesz > fw->size) {
337364
dev_err(dev, "file %s segment %d would be truncated\n",

0 commit comments

Comments
 (0)