Merge Official Source

Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
Tianling Shen
2023-06-09 12:44:19 +08:00
17 changed files with 475 additions and 362 deletions

View File

@@ -0,0 +1,49 @@
From 78391fb5b1b5318900725c72f1db25b2ae92894f Mon Sep 17 00:00:00 2001
From: Christophe Leroy <christophe.leroy@csgroup.eu>
Date: Wed, 7 Jun 2023 09:50:52 +0200
Subject: [PATCH] powerpc/vdso: link with -z noexecstack
With recent binutils, the following warning appears:
VDSO32L arch/powerpc/kernel/vdso/vdso32.so.dbg
/opt/gcc-12.2.0-nolibc/powerpc64-linux/bin/../lib/gcc/powerpc64-linux/12.2.0/../../../../powerpc64-linux/bin/ld: warning: arch/powerpc/kernel/vdso/getcpu-32.o: missing .note.GNU-stack section implies executable stack
/opt/gcc-12.2.0-nolibc/powerpc64-linux/bin/../lib/gcc/powerpc64-linux/12.2.0/../../../../powerpc64-linux/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
To avoid that, explicitly tell the linker we don't want executable
stack.
For more explanations, see commit ffcf9c5700e4 ("x86: link vdso
and boot with -z noexecstack --no-warn-rwx-segments")
Commit was adapted for 5.15 as VDSO32 and VDSO64 were merged later so it
does not directly apply.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/b95f2e3216a574837dd61208444e9515c3423da4.1662132312.git.christophe.leroy@csgroup.eu
Signed-off-by: Robert Marko <robimarko@gmail.com>
[Adapt to 5.15 as it has VDSO split for 32 and 64bit]
---
arch/powerpc/kernel/vdso32/Makefile | 2 +-
arch/powerpc/kernel/vdso64/Makefile | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
--- a/arch/powerpc/kernel/vdso32/Makefile
+++ b/arch/powerpc/kernel/vdso32/Makefile
@@ -66,7 +66,7 @@ include/generated/vdso32-offsets.h: $(ob
# actual build commands
quiet_cmd_vdso32ld_and_check = VDSO32L $@
- cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) ; $(cmd_vdso_check)
+ cmd_vdso32ld_and_check = $(VDSOCC) $(c_flags) $(CC32FLAGS) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)
quiet_cmd_vdso32as = VDSO32A $@
cmd_vdso32as = $(VDSOCC) $(a_flags) $(CC32FLAGS) -c -o $@ $<
quiet_cmd_vdso32cc = VDSO32C $@
--- a/arch/powerpc/kernel/vdso64/Makefile
+++ b/arch/powerpc/kernel/vdso64/Makefile
@@ -53,4 +53,4 @@ include/generated/vdso64-offsets.h: $(ob
# actual build commands
quiet_cmd_vdso64ld_and_check = VDSO64L $@
- cmd_vdso64ld_and_check = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^); $(cmd_vdso_check)
+ cmd_vdso64ld_and_check = $(CC) $(c_flags) -o $@ -Wl,-T$(filter %.lds,$^) $(filter %.o,$^) -z noexecstack ; $(cmd_vdso_check)

View File

@@ -1,4 +1,4 @@
From 97505f4c049fa2e8c86a53411a9e599033898533 Mon Sep 17 00:00:00 2001
From 7cbff3c3f867ff3b24de674f44ca03f54e416a37 Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Sat, 31 Dec 2022 00:27:42 +0100
Subject: [PATCH] soc: qcom: socinfo: move SMEM item struct and defines to a
@@ -9,6 +9,9 @@ to reuse them in the Qualcomm NVMEM CPUFreq driver instead of duplicating
them.
Signed-off-by: Robert Marko <robimarko@gmail.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20230526204802.3081168-1-robimarko@gmail.com
---
drivers/soc/qcom/socinfo.c | 58 +--------------------------
include/linux/soc/qcom/socinfo.h | 67 ++++++++++++++++++++++++++++++++

View File

@@ -0,0 +1,55 @@
From 9f1bbff157a69db7684f5da2f73b2325c638a90e Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Fri, 26 May 2023 22:47:59 +0200
Subject: [PATCH] soc: qcom: smem: Switch to EXPORT_SYMBOL_GPL()
SMEM has been GPL licensed from the start, and there is no reason to use
EXPORT_SYMBOL() so switch to the GPL version.
Signed-off-by: Robert Marko <robimarko@gmail.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Trilok Soni <quic_tsoni@quicinc.com>
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20230526204802.3081168-2-robimarko@gmail.com
---
drivers/soc/qcom/smem.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--- a/drivers/soc/qcom/smem.c
+++ b/drivers/soc/qcom/smem.c
@@ -500,7 +500,7 @@ int qcom_smem_alloc(unsigned host, unsig
return ret;
}
-EXPORT_SYMBOL(qcom_smem_alloc);
+EXPORT_SYMBOL_GPL(qcom_smem_alloc);
static void *qcom_smem_get_global(struct qcom_smem *smem,
unsigned item,
@@ -674,7 +674,7 @@ void *qcom_smem_get(unsigned host, unsig
return ptr;
}
-EXPORT_SYMBOL(qcom_smem_get);
+EXPORT_SYMBOL_GPL(qcom_smem_get);
/**
* qcom_smem_get_free_space() - retrieve amount of free space in a partition
@@ -719,7 +719,7 @@ int qcom_smem_get_free_space(unsigned ho
return ret;
}
-EXPORT_SYMBOL(qcom_smem_get_free_space);
+EXPORT_SYMBOL_GPL(qcom_smem_get_free_space);
static bool addr_in_range(void __iomem *base, size_t size, void *addr)
{
@@ -770,7 +770,7 @@ phys_addr_t qcom_smem_virt_to_phys(void
return 0;
}
-EXPORT_SYMBOL(qcom_smem_virt_to_phys);
+EXPORT_SYMBOL_GPL(qcom_smem_virt_to_phys);
static int qcom_smem_get_sbl_version(struct qcom_smem *smem)
{

View File

@@ -0,0 +1,70 @@
From c3ecf2602a32d9b9e5fc997076c0d2836495c085 Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Fri, 26 May 2023 22:48:00 +0200
Subject: [PATCH] soc: qcom: smem: introduce qcom_smem_get_soc_id()
Introduce a helper to return the SoC SMEM ID, which is used to identify the
exact SoC model as there may be differences in the same SoC family.
Currently, cpufreq-nvmem does this completely in the driver and there has
been more interest expresed for other drivers to use this information so
lets expose a common helper to prevent redoing it in individual drivers
since this field is present on every SMEM table version.
Signed-off-by: Robert Marko <robimarko@gmail.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20230526204802.3081168-3-robimarko@gmail.com
---
drivers/soc/qcom/smem.c | 23 +++++++++++++++++++++++
include/linux/soc/qcom/smem.h | 2 ++
2 files changed, 25 insertions(+)
--- a/drivers/soc/qcom/smem.c
+++ b/drivers/soc/qcom/smem.c
@@ -14,6 +14,7 @@
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/soc/qcom/smem.h>
+#include <linux/soc/qcom/socinfo.h>
/*
* The Qualcomm shared memory system is a allocate only heap structure that
@@ -772,6 +773,28 @@ phys_addr_t qcom_smem_virt_to_phys(void
}
EXPORT_SYMBOL_GPL(qcom_smem_virt_to_phys);
+/**
+ * qcom_smem_get_soc_id() - return the SoC ID
+ * @id: On success, we return the SoC ID here.
+ *
+ * Look up SoC ID from HW/SW build ID and return it.
+ *
+ * Return: 0 on success, negative errno on failure.
+ */
+int qcom_smem_get_soc_id(u32 *id)
+{
+ struct socinfo *info;
+
+ info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, NULL);
+ if (IS_ERR(info))
+ return PTR_ERR(info);
+
+ *id = __le32_to_cpu(info->id);
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(qcom_smem_get_soc_id);
+
static int qcom_smem_get_sbl_version(struct qcom_smem *smem)
{
struct smem_header *header;
--- a/include/linux/soc/qcom/smem.h
+++ b/include/linux/soc/qcom/smem.h
@@ -11,4 +11,6 @@ int qcom_smem_get_free_space(unsigned ho
phys_addr_t qcom_smem_virt_to_phys(void *p);
+int qcom_smem_get_soc_id(u32 *id);
+
#endif

View File

@@ -1,21 +1,26 @@
From 132b2f15b8ae3f848b3e6f2962f409cfab0ca759 Mon Sep 17 00:00:00 2001
From 2b8634d1468ff498cc91b6adf993c27ae6fa079d Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Fri, 30 Dec 2022 23:33:47 +0100
Date: Fri, 26 May 2023 22:48:01 +0200
Subject: [PATCH] cpufreq: qcom-nvmem: use SoC ID-s from bindings
SMEM SoC ID-s are now stored in DT bindings so lets use those instead of
defining them in the driver again.
Signed-off-by: Robert Marko <robimarko@gmail.com>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20230526204802.3081168-4-robimarko@gmail.com
---
drivers/cpufreq/qcom-cpufreq-nvmem.c | 15 +++++----------
1 file changed, 5 insertions(+), 10 deletions(-)
--- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
+++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
@@ -30,12 +30,7 @@
#include <linux/soc/qcom/smem.h>
#include <linux/soc/qcom/socinfo.h>
@@ -31,12 +31,7 @@
#define MSM_ID_SMEM 137
-enum _msm_id {
- MSM8996V3 = 0xF6ul,
@@ -27,10 +32,10 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
enum _msm8996_version {
MSM8996_V3,
@@ -150,12 +145,12 @@ static enum _msm8996_version qcom_cpufre
return NUM_OF_MSM8996_VERSIONS;
@@ -154,12 +149,12 @@ static enum _msm8996_version qcom_cpufre
msm_id++;
switch (info->id) {
switch ((enum _msm_id)*msm_id) {
- case MSM8996V3:
- case APQ8096V3:
+ case QCOM_ID_MSM8996:

View File

@@ -1,29 +1,30 @@
From 85bf71b130ab0e939f53ec9cf1131d67d148bc9a Mon Sep 17 00:00:00 2001
From e7992615acacc27baeec310197108143afc77337 Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Sat, 31 Dec 2022 12:45:31 +0100
Subject: [PATCH] cpufreq: qcom-nvmem: make qcom_cpufreq_get_msm_id() return
the SoC ID
Date: Fri, 26 May 2023 22:48:02 +0200
Subject: [PATCH] cpufreq: qcom-nvmem: use helper to get SMEM SoC ID
Currently, qcom_cpufreq_get_msm_id() does not simply return the SoC ID
after getting it via SMEM call but instead uses an enum to encode the
matched SMEM ID to 2 variants of MSM8996 which are then used in
qcom_cpufreq_kryo_name_version() to set the supported version.
This prevents qcom_cpufreq_get_msm_id() from being universal and its doing
more than its name suggests, so lets make it just return the SoC ID
directly which allows matching directly on the SoC ID and removes the need
for msm8996_version enum which simplifies the driver.
It also allows reusing the qcom_cpufreq_get_msm_id() for new SoC-s.
Now that SMEM exports a helper to get the SMEM SoC ID lets utilize it.
Currently qcom_cpufreq_get_msm_id() is encoding the returned SMEM SoC ID
into an enum, however there is no reason to do so and we can just match
directly on the SMEM SoC ID as returned by qcom_smem_get_soc_id().
Signed-off-by: Robert Marko <robimarko@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Link: https://lore.kernel.org/r/20230526204802.3081168-5-robimarko@gmail.com
---
drivers/cpufreq/qcom-cpufreq-nvmem.c | 44 ++++++++--------------------
1 file changed, 12 insertions(+), 32 deletions(-)
drivers/cpufreq/qcom-cpufreq-nvmem.c | 56 +++++-----------------------
1 file changed, 10 insertions(+), 46 deletions(-)
--- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
+++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
@@ -32,12 +32,6 @@
@@ -29,16 +29,8 @@
#include <linux/slab.h>
#include <linux/soc/qcom/smem.h>
-#define MSM_ID_SMEM 137
-
#include <dt-bindings/arm/qcom,ids.h>
-enum _msm8996_version {
@@ -35,22 +36,24 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
struct qcom_cpufreq_drv;
struct qcom_cpufreq_match_data {
@@ -134,30 +128,16 @@ static void get_krait_bin_format_b(struc
@@ -135,60 +127,32 @@ static void get_krait_bin_format_b(struc
dev_dbg(cpu_dev, "PVS version: %d\n", *pvs_ver);
}
-static enum _msm8996_version qcom_cpufreq_get_msm_id(void)
+static int qcom_cpufreq_get_msm_id(void)
{
size_t len;
struct socinfo *info;
-{
- size_t len;
- u32 *msm_id;
- enum _msm8996_version version;
info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, &len);
if (IS_ERR(info))
-
- msm_id = qcom_smem_get(QCOM_SMEM_HOST_ANY, MSM_ID_SMEM, &len);
- if (IS_ERR(msm_id))
- return NUM_OF_MSM8996_VERSIONS;
-
- switch (info->id) {
- /* The first 4 bytes are format, next to them is the actual msm-id */
- msm_id++;
-
- switch ((enum _msm_id)*msm_id) {
- case QCOM_ID_MSM8996:
- case QCOM_ID_APQ8096:
- version = MSM8996_V3;
@@ -62,20 +65,20 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
- default:
- version = NUM_OF_MSM8996_VERSIONS;
- }
+ return PTR_ERR(info);
-
- return version;
+ return info->id;
}
-}
-
static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev,
@@ -166,25 +146,25 @@ static int qcom_cpufreq_kryo_name_versio
struct nvmem_cell *speedbin_nvmem,
char **pvs_name,
struct qcom_cpufreq_drv *drv)
{
size_t len;
+ int msm_id;
+ u32 msm_id;
u8 *speedbin;
- enum _msm8996_version msm8996_version;
+ int ret;
*pvs_name = NULL;
- msm8996_version = qcom_cpufreq_get_msm_id();
@@ -83,9 +86,9 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
- dev_err(cpu_dev, "Not Snapdragon 820/821!");
- return -ENODEV;
- }
+ msm_id = qcom_cpufreq_get_msm_id();
+ if (msm_id < 0)
+ return msm_id;
+ ret = qcom_smem_get_soc_id(&msm_id);
+ if (ret)
+ return ret;
speedbin = nvmem_cell_read(speedbin_nvmem, &len);
if (IS_ERR(speedbin))

View File

@@ -60,11 +60,13 @@ struct psb6970_priv {
struct mutex reg_mutex;
/* all fields below are cleared on reset */
bool vlan;
u16 vlan_id[PSB6970_MAX_VLANS];
u8 vlan_table[PSB6970_MAX_VLANS];
u8 vlan_tagged;
u16 pvid[PSB6970_NUM_PORTS];
struct_group(psb6970_priv_volatile,
bool vlan;
u16 vlan_id[PSB6970_MAX_VLANS];
u8 vlan_table[PSB6970_MAX_VLANS];
u8 vlan_tagged;
u16 pvid[PSB6970_NUM_PORTS];
);
};
#define to_psb6970(_dev) container_of(_dev, struct psb6970_priv, dev)
@@ -272,8 +274,8 @@ static int psb6970_reset_switch(struct switch_dev *dev)
mutex_lock(&priv->reg_mutex);
memset(&priv->vlan, 0, sizeof(struct psb6970_priv) -
offsetof(struct psb6970_priv, vlan));
memset(&priv->psb6970_priv_volatile, 0,
sizeof(priv->psb6970_priv_volatile));
for (i = 0; i < PSB6970_MAX_VLANS; i++)
priv->vlan_id[i] = i;

View File

@@ -1,94 +0,0 @@
From ca71e00839fcdd26f122fb6d9e97903c9fe198f7 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sat, 6 May 2023 08:08:35 +0200
Subject: [PATCH] binfmt_elf: dynamically allocate note.data in
parse_elf_properties
Dynamically allocate note.data in parse_elf_properties to fix
compilation warning on some arch.
On some arch note.data exceet the stack limit for a single function and
this cause the following compilation warning:
fs/binfmt_elf.c: In function 'parse_elf_properties.isra':
fs/binfmt_elf.c:821:1: error: the frame size of 1040 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
821 | }
| ^
cc1: all warnings being treated as errors
Fix this by dynamically allocating the array.
Fixes: 00e19ceec80b ("ELF: Add ELF program property parsing support")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Cc: stable@vger.kernel.org # v5.8+
---
fs/binfmt_elf.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -768,7 +768,7 @@ static int parse_elf_properties(struct f
{
union {
struct elf_note nhdr;
- char data[NOTE_DATA_SZ];
+ char *data;
} note;
loff_t pos;
ssize_t n;
@@ -788,26 +788,38 @@ static int parse_elf_properties(struct f
if (phdr->p_filesz > sizeof(note))
return -ENOEXEC;
+ note.data = kcalloc(NOTE_DATA_SZ, sizeof(*note.data), GFP_KERNEL);
+ if (!note.data)
+ return -ENOMEM;
+
pos = phdr->p_offset;
n = kernel_read(f, &note, phdr->p_filesz, &pos);
BUILD_BUG_ON(sizeof(note) < sizeof(note.nhdr) + NOTE_NAME_SZ);
- if (n < 0 || n < sizeof(note.nhdr) + NOTE_NAME_SZ)
- return -EIO;
+ if (n < 0 || n < sizeof(note.nhdr) + NOTE_NAME_SZ) {
+ ret = -EIO;
+ goto exit;
+ }
if (note.nhdr.n_type != NT_GNU_PROPERTY_TYPE_0 ||
note.nhdr.n_namesz != NOTE_NAME_SZ ||
strncmp(note.data + sizeof(note.nhdr),
- GNU_PROPERTY_TYPE_0_NAME, n - sizeof(note.nhdr)))
- return -ENOEXEC;
+ GNU_PROPERTY_TYPE_0_NAME, n - sizeof(note.nhdr))) {
+ ret = -ENOEXEC;
+ goto exit;
+ }
off = round_up(sizeof(note.nhdr) + NOTE_NAME_SZ,
ELF_GNU_PROPERTY_ALIGN);
- if (off > n)
- return -ENOEXEC;
-
- if (note.nhdr.n_descsz > n - off)
- return -ENOEXEC;
+ if (off > n) {
+ ret = -ENOEXEC;
+ goto exit;
+ }
+
+ if (note.nhdr.n_descsz > n - off) {
+ ret = -ENOEXEC;
+ goto exit;
+ }
datasz = off + note.nhdr.n_descsz;
have_prev_type = false;
@@ -817,6 +829,8 @@ static int parse_elf_properties(struct f
have_prev_type = true;
} while (!ret);
+exit:
+ kfree(note.data);
return ret == -ENOENT ? 0 : ret;
}

View File

@@ -1,94 +0,0 @@
From ca71e00839fcdd26f122fb6d9e97903c9fe198f7 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sat, 6 May 2023 08:08:35 +0200
Subject: [PATCH] binfmt_elf: dynamically allocate note.data in
parse_elf_properties
Dynamically allocate note.data in parse_elf_properties to fix
compilation warning on some arch.
On some arch note.data exceet the stack limit for a single function and
this cause the following compilation warning:
fs/binfmt_elf.c: In function 'parse_elf_properties.isra':
fs/binfmt_elf.c:821:1: error: the frame size of 1040 bytes is larger than 1024 bytes [-Werror=frame-larger-than=]
821 | }
| ^
cc1: all warnings being treated as errors
Fix this by dynamically allocating the array.
Fixes: 00e19ceec80b ("ELF: Add ELF program property parsing support")
Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
Cc: stable@vger.kernel.org # v5.8+
---
fs/binfmt_elf.c | 32 +++++++++++++++++++++++---------
1 file changed, 23 insertions(+), 9 deletions(-)
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -769,7 +769,7 @@ static int parse_elf_properties(struct f
{
union {
struct elf_note nhdr;
- char data[NOTE_DATA_SZ];
+ char *data;
} note;
loff_t pos;
ssize_t n;
@@ -789,26 +789,38 @@ static int parse_elf_properties(struct f
if (phdr->p_filesz > sizeof(note))
return -ENOEXEC;
+ note.data = kcalloc(NOTE_DATA_SZ, sizeof(*note.data), GFP_KERNEL);
+ if (!note.data)
+ return -ENOMEM;
+
pos = phdr->p_offset;
n = kernel_read(f, &note, phdr->p_filesz, &pos);
BUILD_BUG_ON(sizeof(note) < sizeof(note.nhdr) + NOTE_NAME_SZ);
- if (n < 0 || n < sizeof(note.nhdr) + NOTE_NAME_SZ)
- return -EIO;
+ if (n < 0 || n < sizeof(note.nhdr) + NOTE_NAME_SZ) {
+ ret = -EIO;
+ goto exit;
+ }
if (note.nhdr.n_type != NT_GNU_PROPERTY_TYPE_0 ||
note.nhdr.n_namesz != NOTE_NAME_SZ ||
strncmp(note.data + sizeof(note.nhdr),
- GNU_PROPERTY_TYPE_0_NAME, n - sizeof(note.nhdr)))
- return -ENOEXEC;
+ GNU_PROPERTY_TYPE_0_NAME, n - sizeof(note.nhdr))) {
+ ret = -ENOEXEC;
+ goto exit;
+ }
off = round_up(sizeof(note.nhdr) + NOTE_NAME_SZ,
ELF_GNU_PROPERTY_ALIGN);
- if (off > n)
- return -ENOEXEC;
-
- if (note.nhdr.n_descsz > n - off)
- return -ENOEXEC;
+ if (off > n) {
+ ret = -ENOEXEC;
+ goto exit;
+ }
+
+ if (note.nhdr.n_descsz > n - off) {
+ ret = -ENOEXEC;
+ goto exit;
+ }
datasz = off + note.nhdr.n_descsz;
have_prev_type = false;
@@ -818,6 +830,8 @@ static int parse_elf_properties(struct f
have_prev_type = true;
} while (!ret);
+exit:
+ kfree(note.data);
return ret == -ENOENT ? 0 : ret;
}

View File

@@ -29,12 +29,6 @@
hysteresis = <2000>;
type = "passive";
};
cpu0_crit: cpu_crit {
temperature = <110000>;
hysteresis = <1000>;
type = "critical";
};
};
cooling-maps {
@@ -55,12 +49,6 @@
hysteresis = <2000>;
type = "passive";
};
cpu1_crit: cpu_crit {
temperature = <110000>;
hysteresis = <1000>;
type = "critical";
};
};
cooling-maps {
@@ -81,12 +69,6 @@
hysteresis = <2000>;
type = "passive";
};
cpu2_crit: cpu_crit {
temperature = <110000>;
hysteresis = <1000>;
type = "critical";
};
};
cooling-maps {
@@ -107,12 +89,6 @@
hysteresis = <2000>;
type = "passive";
};
cpu3_crit: cpu_crit {
temperature = <110000>;
hysteresis = <1000>;
type = "critical";
};
};
cooling-maps {
@@ -133,12 +109,6 @@
hysteresis = <2000>;
type = "passive";
};
cluster_crit: cluster_crit {
temperature = <110000>;
hysteresis = <1000>;
type = "critical";
};
};
cooling-maps {

View File

@@ -35,12 +35,6 @@
hysteresis = <2000>;
type = "passive";
};
cpu0_crit: cpu_crit {
temperature = <110000>;
hysteresis = <1000>;
type = "critical";
};
};
cooling-maps {
@@ -74,12 +68,6 @@
hysteresis = <2000>;
type = "passive";
};
cpu1_crit: cpu_crit {
temperature = <110000>;
hysteresis = <1000>;
type = "critical";
};
};
cooling-maps {
@@ -113,12 +101,6 @@
hysteresis = <2000>;
type = "passive";
};
cpu2_crit: cpu_crit {
temperature = <110000>;
hysteresis = <1000>;
type = "critical";
};
};
cooling-maps {
@@ -152,12 +134,6 @@
hysteresis = <2000>;
type = "passive";
};
cpu3_crit: cpu_crit {
temperature = <110000>;
hysteresis = <1000>;
type = "critical";
};
};
cooling-maps {
@@ -191,12 +167,6 @@
hysteresis = <2000>;
type = "passive";
};
cluster_crit: cluster_crit {
temperature = <110000>;
hysteresis = <1000>;
type = "critical";
};
};
cooling-maps {

View File

@@ -1,50 +0,0 @@
From b7b7ea3a0cab42d4f1d4c9ae9eb7c7a3d03e7982 Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Fri, 30 Dec 2022 22:51:47 +0100
Subject: [PATCH] cpufreq: qcom-nvmem: reuse socinfo SMEM item struct
Now that socinfo SMEM item struct and defines have been moved to a header
so we can utilize that instead.
Now the SMEM value can be accesed directly, there is no need for defining
the ID for the SMEM request as well.
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
drivers/cpufreq/qcom-cpufreq-nvmem.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
--- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
+++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
@@ -28,8 +28,7 @@
#include <linux/pm_opp.h>
#include <linux/slab.h>
#include <linux/soc/qcom/smem.h>
-
-#define MSM_ID_SMEM 137
+#include <linux/soc/qcom/socinfo.h>
enum _msm_id {
MSM8996V3 = 0xF6ul,
@@ -143,17 +142,14 @@ static void get_krait_bin_format_b(struc
static enum _msm8996_version qcom_cpufreq_get_msm_id(void)
{
size_t len;
- u32 *msm_id;
+ struct socinfo *info;
enum _msm8996_version version;
- msm_id = qcom_smem_get(QCOM_SMEM_HOST_ANY, MSM_ID_SMEM, &len);
- if (IS_ERR(msm_id))
+ info = qcom_smem_get(QCOM_SMEM_HOST_ANY, SMEM_HW_SW_BUILD_ID, &len);
+ if (IS_ERR(info))
return NUM_OF_MSM8996_VERSIONS;
- /* The first 4 bytes are format, next to them is the actual msm-id */
- msm_id++;
-
- switch ((enum _msm_id)*msm_id) {
+ switch (info->id) {
case MSM8996V3:
case APQ8096V3:
version = MSM8996_V3;

View File

@@ -1,4 +1,4 @@
From 813f2b5ad002e691b92154037f154b4444eedd54 Mon Sep 17 00:00:00 2001
From 11592aa862e67f4477dee7e94d5c8244d893de1b Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Sat, 31 Dec 2022 13:03:41 +0100
Subject: [PATCH] cpufreq: qcom-nvmem: add support for IPQ8074
@@ -14,10 +14,14 @@ IPQ8074 compatible is blacklisted from DT platdev as the cpufreq device
will get created by NVMEM CPUFreq driver.
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
Changes in v2:
* Print an error if SMEM ID is not part of the IPQ8074 family
and restrict the speed to Acorn variant (1.4GHz)
---
drivers/cpufreq/cpufreq-dt-platdev.c | 1 +
drivers/cpufreq/qcom-cpufreq-nvmem.c | 39 ++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
drivers/cpufreq/qcom-cpufreq-nvmem.c | 43 ++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
--- a/drivers/cpufreq/cpufreq-dt-platdev.c
+++ b/drivers/cpufreq/cpufreq-dt-platdev.c
@@ -31,7 +35,7 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
{ .compatible = "qcom,msm8960", },
--- a/drivers/cpufreq/qcom-cpufreq-nvmem.c
+++ b/drivers/cpufreq/qcom-cpufreq-nvmem.c
@@ -32,6 +32,9 @@
@@ -31,6 +31,9 @@
#include <dt-bindings/arm/qcom,ids.h>
@@ -41,7 +45,7 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
struct qcom_cpufreq_drv;
struct qcom_cpufreq_match_data {
@@ -216,6 +219,37 @@ len_error:
@@ -204,6 +207,41 @@ len_error:
return ret;
}
@@ -50,12 +54,13 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
+ char **pvs_name,
+ struct qcom_cpufreq_drv *drv)
+{
+ int msm_id;
+ u32 msm_id;
+ int ret;
+ *pvs_name = NULL;
+
+ msm_id = qcom_cpufreq_get_msm_id();
+ if (msm_id < 0)
+ return msm_id;
+ ret = qcom_smem_get_soc_id(&msm_id);
+ if (ret)
+ return ret;
+
+ switch (msm_id) {
+ case QCOM_ID_IPQ8070A:
@@ -69,7 +74,10 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
+ drv->versions = IPQ8074_HAWKEYE_VERSION;
+ break;
+ default:
+ BUG();
+ dev_err(cpu_dev,
+ "SoC ID %u is not part of IPQ8074 family, limiting to 1.4GHz!\n",
+ msm_id);
+ drv->versions = IPQ8074_ACORN_VERSION;
+ break;
+ }
+
@@ -79,7 +87,7 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
static const struct qcom_cpufreq_match_data match_data_kryo = {
.get_version = qcom_cpufreq_kryo_name_version,
};
@@ -230,6 +264,10 @@ static const struct qcom_cpufreq_match_d
@@ -218,6 +256,10 @@ static const struct qcom_cpufreq_match_d
.genpd_names = qcs404_genpd_names,
};
@@ -90,7 +98,7 @@ Signed-off-by: Robert Marko <robimarko@gmail.com>
static int qcom_cpufreq_probe(struct platform_device *pdev)
{
struct qcom_cpufreq_drv *drv;
@@ -375,6 +413,7 @@ static const struct of_device_id qcom_cp
@@ -363,6 +405,7 @@ static const struct of_device_id qcom_cp
{ .compatible = "qcom,msm8996", .data = &match_data_kryo },
{ .compatible = "qcom,qcs404", .data = &match_data_qcs404 },
{ .compatible = "qcom,ipq8064", .data = &match_data_krait },

View File

@@ -0,0 +1,197 @@
From 145bbf2b88990ef3ff00ee541bb7662008683c16 Mon Sep 17 00:00:00 2001
From: Robert Marko <robimarko@gmail.com>
Date: Wed, 7 Jun 2023 20:26:26 +0200
Subject: [PATCH] arm64: dts: qcom: ipq8074: add critical thermal trips
According to bindings, thermal zones must have associated trips as well.
Since we currently dont have CPUFreq support and thus no passive cooling
lets start by defining critical trips to protect the devices against
severe overheating.
Signed-off-by: Robert Marko <robimarko@gmail.com>
---
arch/arm64/boot/dts/qcom/ipq8074.dtsi | 96 +++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
--- a/arch/arm64/boot/dts/qcom/ipq8074.dtsi
+++ b/arch/arm64/boot/dts/qcom/ipq8074.dtsi
@@ -1293,6 +1293,14 @@
polling-delay = <1000>;
thermal-sensors = <&tsens 4>;
+
+ trips {
+ nss-top-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
};
nss0-thermal {
@@ -1300,6 +1308,14 @@
polling-delay = <1000>;
thermal-sensors = <&tsens 5>;
+
+ trips {
+ nss-0-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
};
nss1-thermal {
@@ -1307,6 +1323,14 @@
polling-delay = <1000>;
thermal-sensors = <&tsens 6>;
+
+ trips {
+ nss-1-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
};
wcss-phya0-thermal {
@@ -1314,6 +1338,14 @@
polling-delay = <1000>;
thermal-sensors = <&tsens 7>;
+
+ trips {
+ wcss-phya0-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
};
wcss-phya1-thermal {
@@ -1321,6 +1353,14 @@
polling-delay = <1000>;
thermal-sensors = <&tsens 8>;
+
+ trips {
+ wcss-phya1-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
};
cpu0_thermal: cpu0-thermal {
@@ -1328,6 +1368,14 @@
polling-delay = <1000>;
thermal-sensors = <&tsens 9>;
+
+ trips {
+ cpu0-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
};
cpu1_thermal: cpu1-thermal {
@@ -1335,6 +1383,14 @@
polling-delay = <1000>;
thermal-sensors = <&tsens 10>;
+
+ trips {
+ cpu1-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
};
cpu2_thermal: cpu2-thermal {
@@ -1342,6 +1398,14 @@
polling-delay = <1000>;
thermal-sensors = <&tsens 11>;
+
+ trips {
+ cpu2-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
};
cpu3_thermal: cpu3-thermal {
@@ -1349,6 +1413,14 @@
polling-delay = <1000>;
thermal-sensors = <&tsens 12>;
+
+ trips {
+ cpu3-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
};
cluster_thermal: cluster-thermal {
@@ -1356,6 +1428,14 @@
polling-delay = <1000>;
thermal-sensors = <&tsens 13>;
+
+ trips {
+ cluster-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
};
wcss-phyb0-thermal {
@@ -1363,6 +1443,14 @@
polling-delay = <1000>;
thermal-sensors = <&tsens 14>;
+
+ trips {
+ wcss-phyb0-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
};
wcss-phyb1-thermal {
@@ -1370,6 +1458,14 @@
polling-delay = <1000>;
thermal-sensors = <&tsens 15>;
+
+ trips {
+ wcss-phyb1-crit {
+ temperature = <110000>;
+ hysteresis = <1000>;
+ type = "critical";
+ };
+ };
};
};
};

View File

@@ -77,6 +77,7 @@ CONFIG_CRC16=y
CONFIG_CRC32_SLICEBY8=y
CONFIG_CROSS_MEMORY_ATTACH=y
CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y
CONFIG_CRYPTO_LZ4=y
CONFIG_CRYPTO_RNG2=y
CONFIG_DEBUG_ALIGN_RODATA=y
CONFIG_DEBUG_BUGVERBOSE=y
@@ -165,6 +166,7 @@ CONFIG_LEDS_TRIGGER_ONESHOT=y
CONFIG_LIBFDT=y
CONFIG_LOCALVERSION_AUTO=y
CONFIG_LOCK_DEBUGGING_SUPPORT=y
CONFIG_LZ4_COMPRESS=y
CONFIG_LZ4_DECOMPRESS=y
CONFIG_LZO_DECOMPRESS=y
# CONFIG_MACH_OX810SE is not set
@@ -242,6 +244,7 @@ CONFIG_SERIAL_OF_PLATFORM=y
CONFIG_SERIO=y
CONFIG_SERIO_LIBPS2=y
CONFIG_SERIO_SERPORT=y
CONFIG_SGL_ALLOC=y
CONFIG_SLUB_DEBUG=y
CONFIG_SOCK_DIAG=y
CONFIG_SPARSE_IRQ=y

View File

@@ -0,0 +1,16 @@
#!/bin/sh
[[ "${ACTION}" = "released" ]] || exit 0
. /lib/functions.sh
case "$(board_name)" in
tplink,ec330-g5u-v1)
led_light="/sys/class/gpio/led-light/value"
echo "$((!$(cat $led_light)))" > "$led_light"
;;
*)
;;
esac
return 0