From 7393ba39db45d261d718beca2c00e15436eace2e Mon Sep 17 00:00:00 2001 From: Pankaj Gupta Date: Wed, 11 Jan 2023 18:48:36 +0530 Subject: [PATCH 1/9] Revert "msm: kgsl: Call dma_buf_unmap_attachment() early" This reverts msm-5.10 commit b84bd97e37f8ac3a0f3194ebcbb1fa962e42cd73. Warnings for direct dma clients during cache operations are now being handled by dma-buf driver. Instead of doing dma_buf_unmap_attachment early if we do it in destroy path, it helps in saving cycles and improving performance during app launch. Change-Id: Ic66dd3b66136318abf59685f95fee17890377fd4 Signed-off-by: Pankaj Gupta Signed-off-by: Archana Sriram --- drivers/gpu/msm/kgsl.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/msm/kgsl.c b/drivers/gpu/msm/kgsl.c index 328ea61b46a8..99c3207530c5 100644 --- a/drivers/gpu/msm/kgsl.c +++ b/drivers/gpu/msm/kgsl.c @@ -349,6 +349,7 @@ static void kgsl_destroy_ion(struct kgsl_memdesc *memdesc) if (meta != NULL) { remove_dmabuf_list(meta); + dma_buf_unmap_attachment(meta->attach, memdesc->sgt, DMA_BIDIRECTIONAL); dma_buf_detach(meta->dmabuf, meta->attach); dma_buf_put(meta->dmabuf); kfree(meta); @@ -2996,7 +2997,7 @@ static int kgsl_setup_dma_buf(struct kgsl_device *device, { int ret = 0; struct scatterlist *s; - struct sg_table *sg_table; + struct sg_table *sg_table = NULL; struct dma_buf_attachment *attach = NULL; struct kgsl_dma_buf_meta *meta; @@ -3038,8 +3039,6 @@ static int kgsl_setup_dma_buf(struct kgsl_device *device, goto out; } - dma_buf_unmap_attachment(attach, sg_table, DMA_BIDIRECTIONAL); - meta->table = sg_table; entry->priv_data = meta; entry->memdesc.sgt = sg_table; @@ -3094,6 +3093,9 @@ skip_access_check: out: if (ret) { + if (!IS_ERR_OR_NULL(sg_table)) + dma_buf_unmap_attachment(attach, sg_table, DMA_BIDIRECTIONAL); + if (!IS_ERR_OR_NULL(attach)) dma_buf_detach(dmabuf, attach); From 55e0fe8b635316a58250df92f14ce0180ee3328d Mon Sep 17 00:00:00 2001 From: Srinivasarao Pathipati Date: Wed, 25 Jan 2023 23:10:14 +0530 Subject: [PATCH 2/9] BACKPORT: dma-buf: return success for cmo of dummy clients kgsl-3d0 is dummy device which don't need cmo return success along with suppressing warnings for dummy clients. Change-Id: I4ddcee898931cf017e21c8ecbfec863b4566d962 Signed-off-by: Srinivasarao Pathipati --- drivers/staging/android/ion/heaps/msm_ion_dma_buf.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/staging/android/ion/heaps/msm_ion_dma_buf.c b/drivers/staging/android/ion/heaps/msm_ion_dma_buf.c index 6bd9dd286057..7e9f518001e8 100644 --- a/drivers/staging/android/ion/heaps/msm_ion_dma_buf.c +++ b/drivers/staging/android/ion/heaps/msm_ion_dma_buf.c @@ -500,11 +500,12 @@ static int ion_sgl_sync_range(struct device *dev, struct scatterlist *sgl, break; if (i > 0) { - if (get_dma_ops(dev)) { - pr_warn_ratelimited("Partial cmo only supported with 1 segment\n" - "is dma_set_max_seg_size being set on dev:%s\n", - dev_name(dev)); - } + if (!get_dma_ops(dev)) + return 0; + + pr_warn_ratelimited("Partial cmo only supported with 1 segment\n" + "is dma_set_max_seg_size being set on dev:%s\n", + dev_name(dev)); return -EINVAL; } } From 312d0114215daa717ab504215324d4477b395627 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Tue, 13 Oct 2020 16:47:37 -0700 Subject: [PATCH 3/9] Revert "kbuild: disable clang's default use of -fmerge-all-constants" This reverts commit 87e0d4f0f37fb0c8c4aeeac46fff5e957738df79. -fno-merge-all-constants has been the default since clang-6; the minimum supported version of clang in the kernel is clang-10 (10.0.1). Suggested-by: Nathan Chancellor Signed-off-by: Nick Desaulniers Signed-off-by: Andrew Morton Tested-by: Sedat Dilek Reviewed-by: Fangrui Song Reviewed-by: Nathan Chancellor Reviewed-by: Sedat Dilek Reviewed-by: Kees Cook Cc: Andrey Konovalov Cc: Marco Elver Cc: Miguel Ojeda Cc: Alexei Starovoitov Cc: Daniel Borkmann Cc: Masahiro Yamada Cc: Vincenzo Frascino Cc: Will Deacon Link: https://lkml.kernel.org/r/20200902225911.209899-3-ndesaulniers@google.com Link: https://reviews.llvm.org/rL329300. Link: https://github.com/ClangBuiltLinux/linux/issues/9 Signed-off-by: Linus Torvalds Change-Id: Idf61fb41074a182131efff0acf5f7bd958a0a875 --- Makefile | 9 --------- 1 file changed, 9 deletions(-) diff --git a/Makefile b/Makefile index b42946eb1203..aba99d8401e4 100644 --- a/Makefile +++ b/Makefile @@ -1017,15 +1017,6 @@ KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) # disable invalid "can't wrap" optimizations for signed / pointers KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) -# clang sets -fmerge-all-constants by default as optimization, but this -# is non-conforming behavior for C and in fact breaks the kernel, so we -# need to disable it here generally. -KBUILD_CFLAGS += $(call cc-option,-fno-merge-all-constants) - -# for gcc -fno-merge-all-constants disables everything, but it is fine -# to have actual conforming behavior enabled. -KBUILD_CFLAGS += $(call cc-option,-fmerge-constants) - # Make sure -fstack-check isn't enabled (like gentoo apparently did) KBUILD_CFLAGS += $(call cc-option,-fno-stack-check,) From 823ac02460d51c882c848c1a08739a0c875e4040 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 11 Apr 2023 20:09:44 +0000 Subject: [PATCH 4/9] Makefile: use -z pack-relative-relocs Commit 27f2a4db76e8 ("Makefile: fix GDB warning with CONFIG_RELR") added --use-android-relr-tags to fix a GDB warning BFD: /android0/linux-next/vmlinux: unknown type [0x13] section `.relr.dyn' The GDB warning has been fixed in version 11.2. The DT_ANDROID_RELR tag was deprecated since DT_RELR was standardized. Thus, --use-android-relr-tags should be removed. While making the change, try -z pack-relative-relocs, which is supported since LLD 15. Keep supporting --pack-dyn-relocs=relr as well for older LLD versions. There is no indication of obsolescence for --pack-dyn-relocs=relr. As of today, GNU ld supports the latter option for x86 and powerpc64 ports and has no intention to support --pack-dyn-relocs=relr. In the absence of the glibc symbol version GLIBC_ABI_DT_RELR, --pack-dyn-relocs=relr and -z pack-relative-relocs are identical in ld.lld. GNU ld and newer versions of LLD report warnings (instead of errors) for unknown -z options. Only errors lead to non-zero exit codes. Therefore, we should test --pack-dyn-relocs=relr before testing -z pack-relative-relocs. Link: https://github.com/ClangBuiltLinux/linux/issues/1057 Link: https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=a619b58721f0a03fd91c27670d3e4c2fb0d88f1e Signed-off-by: Fangrui Song Reviewed-by: Nick Desaulniers Acked-by: Will Deacon Signed-off-by: Masahiro Yamada Change-Id: Ib4ca450ed863e16651a8725c721e7e0389c992ae --- Makefile | 3 ++- scripts/tools-support-relr.sh | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index aba99d8401e4..ae8a938c7300 100644 --- a/Makefile +++ b/Makefile @@ -1058,7 +1058,8 @@ LDFLAGS_vmlinux += $(call ld-option, -X,) endif ifeq ($(CONFIG_RELR),y) -LDFLAGS_vmlinux += --pack-dyn-relocs=relr --use-android-relr-tags +# ld.lld before 15 did not support -z pack-relative-relocs. +LDFLAGS_vmlinux += $(call ld-option,--pack-dyn-relocs=relr,-z pack-relative-relocs) endif # userspace programs are linked via the compiler, use the correct linker diff --git a/scripts/tools-support-relr.sh b/scripts/tools-support-relr.sh index cb55878bd5b8..4c121946e517 100755 --- a/scripts/tools-support-relr.sh +++ b/scripts/tools-support-relr.sh @@ -7,8 +7,12 @@ trap "rm -f $tmp_file.o $tmp_file $tmp_file.bin" EXIT cat << "END" | $CC -c -x c - -o $tmp_file.o >/dev/null 2>&1 void *p = &p; END -$LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr \ - --use-android-relr-tags -o $tmp_file + +# ld.lld before 15 did not support -z pack-relative-relocs. +if ! $LD $tmp_file.o -shared -Bsymbolic --pack-dyn-relocs=relr -o $tmp_file 2>/dev/null; then + $LD $tmp_file.o -shared -Bsymbolic -z pack-relative-relocs -o $tmp_file 2>&1 | + grep -q pack-relative-relocs && exit 1 +fi # Despite printing an error message, GNU nm still exits with exit code 0 if it # sees a relr section. So we need to check that nothing is printed to stderr. From 99876597c26977fdc64b2af13c122238288305cd Mon Sep 17 00:00:00 2001 From: Sami Tolvanen Date: Tue, 23 Feb 2021 13:59:52 -0800 Subject: [PATCH 5/9] kbuild: lto: force rebuilds when switching CONFIG_LTO When doing non-clean builds and switching between CONFIG_LTO=n and CONFIG_LTO=y, the build system (correctly) didn't notice that assembly and LTO-excluded C object files were rewritten in place by objtool (to add the .orc_unwind* sections), since their build command lines were the same between CONFIG_LTO=y and CONFIG_LTO=n. The objtool step would fail: vmlinux.o: warning: objtool: file already has .orc_unwind section, skipping make: *** [Makefile:1194: vmlinux] Error 255 Avoid this by making sure the build will see a difference between an LTO and non-LTO build (by including "-fno-lto" in KBUILD_*FLAGS). This will get ignored when CC_FLAGS_LTO is present, and will not be included at all when CONFIG_LTO=n. Change-Id: I7b6a3221d0972ad13db0d138c66f3789eec60062 Signed-off-by: Sami Tolvanen Signed-off-by: Kees Cook --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index ae8a938c7300..57c191c6d753 100644 --- a/Makefile +++ b/Makefile @@ -964,7 +964,8 @@ endif ifdef CONFIG_LTO CC_FLAGS_LTO := $(CC_FLAGS_LTO_CLANG) -KBUILD_CFLAGS += $(CC_FLAGS_LTO) +KBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO) +KBUILD_AFLAGS += -fno-lto export CC_FLAGS_LTO endif From ae1cc25c5a8a3e792696e672f9c714d7a3d354d5 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Wed, 1 May 2024 15:55:25 -0700 Subject: [PATCH 6/9] kbuild: Remove support for Clang's ThinLTO caching MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is an issue in clang's ThinLTO caching (enabled for the kernel via '--thinlto-cache-dir') with .incbin, which the kernel occasionally uses to include data within the kernel, such as the .config file for /proc/config.gz. For example, when changing the .config and rebuilding vmlinux, the copy of .config in vmlinux does not match the copy of .config in the build folder: $ echo 'CONFIG_LTO_NONE=n CONFIG_LTO_CLANG_THIN=y CONFIG_IKCONFIG=y CONFIG_HEADERS_INSTALL=y' >kernel/configs/repro.config $ make -skj"$(nproc)" ARCH=x86_64 LLVM=1 clean defconfig repro.config vmlinux ... $ grep CONFIG_HEADERS_INSTALL .config CONFIG_HEADERS_INSTALL=y $ scripts/extract-ikconfig vmlinux | grep CONFIG_HEADERS_INSTALL CONFIG_HEADERS_INSTALL=y $ scripts/config -d HEADERS_INSTALL $ make -kj"$(nproc)" ARCH=x86_64 LLVM=1 vmlinux ... UPD kernel/config_data GZIP kernel/config_data.gz CC kernel/configs.o ... LD vmlinux ... $ grep CONFIG_HEADERS_INSTALL .config # CONFIG_HEADERS_INSTALL is not set $ scripts/extract-ikconfig vmlinux | grep CONFIG_HEADERS_INSTALL CONFIG_HEADERS_INSTALL=y Without '--thinlto-cache-dir' or when using full LTO, this issue does not occur. Benchmarking incremental builds on a few different machines with and without the cache shows a 20% increase in incremental build time without the cache when measured by touching init/main.c and running 'make all'. ARCH=arm64 defconfig + CONFIG_LTO_CLANG_THIN=y on an arm64 host: Benchmark 1: With ThinLTO cache Time (mean ± σ): 56.347 s ± 0.163 s [User: 83.768 s, System: 24.661 s] Range (min … max): 56.109 s … 56.594 s 10 runs Benchmark 2: Without ThinLTO cache Time (mean ± σ): 67.740 s ± 0.479 s [User: 718.458 s, System: 31.797 s] Range (min … max): 67.059 s … 68.556 s 10 runs Summary With ThinLTO cache ran 1.20 ± 0.01 times faster than Without ThinLTO cache ARCH=x86_64 defconfig + CONFIG_LTO_CLANG_THIN=y on an x86_64 host: Benchmark 1: With ThinLTO cache Time (mean ± σ): 85.772 s ± 0.252 s [User: 91.505 s, System: 8.408 s] Range (min … max): 85.447 s … 86.244 s 10 runs Benchmark 2: Without ThinLTO cache Time (mean ± σ): 103.833 s ± 0.288 s [User: 232.058 s, System: 8.569 s] Range (min … max): 103.286 s … 104.124 s 10 runs Summary With ThinLTO cache ran 1.21 ± 0.00 times faster than Without ThinLTO cache While it is unfortunate to take this performance improvement off the table, correctness is more important. If/when this is fixed in LLVM, it can potentially be brought back in a conditional manner. Alternatively, a developer can just disable LTO if doing incremental compiles quickly is important, as a full compile cycle can still take over a minute even with the cache and it is unlikely that LTO will result in functional differences for a kernel change. Cc: stable@vger.kernel.org Fixes: dc5723b02e52 ("kbuild: add support for Clang LTO") Reported-by: Yifan Hong Closes: https://github.com/ClangBuiltLinux/linux/issues/2021 Reported-by: Masami Hiramatsu Closes: https://lore.kernel.org/r/20220327115526.cc4b0ff55fc53c97683c3e4d@kernel.org/ Signed-off-by: Nathan Chancellor Signed-off-by: Masahiro Yamada Change-Id: I5e416fd740e48f2e3920d9d6917a600f179e4885 --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 57c191c6d753..8fad00d03e52 100644 --- a/Makefile +++ b/Makefile @@ -947,7 +947,6 @@ endif ifdef CONFIG_LTO_CLANG ifdef CONFIG_THINLTO CC_FLAGS_LTO_CLANG := -flto=thin $(call cc-option, -fsplit-lto-unit) -KBUILD_LDFLAGS += --thinlto-cache-dir=.thinlto-cache else CC_FLAGS_LTO_CLANG := -flto endif From ce01923678c90d46c0fd73903e4f2a2fcb405255 Mon Sep 17 00:00:00 2001 From: Nolen Johnson Date: Wed, 24 Jun 2026 21:27:17 -0400 Subject: [PATCH 7/9] drivers: hwtracing: coresight: Fix sometimes-uninitialized errors Change-Id: Ia0a6242bec8ceaa27ef623a668e032a08e5fab0d --- drivers/hwtracing/coresight/coresight-byte-cntr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/hwtracing/coresight/coresight-byte-cntr.c b/drivers/hwtracing/coresight/coresight-byte-cntr.c index d85b769ea9ce..a58649c839dc 100644 --- a/drivers/hwtracing/coresight/coresight-byte-cntr.c +++ b/drivers/hwtracing/coresight/coresight-byte-cntr.c @@ -80,7 +80,7 @@ static ssize_t tmc_etr_byte_cntr_read(struct file *fp, char __user *data, size_t len, loff_t *ppos) { struct byte_cntr *byte_cntr_data = fp->private_data; - char *bufp; + char *bufp = NULL; int ret = 0; if (!data) return -EINVAL; From 33304e5fe03e97b2bd5a95255308c962f91cb12c Mon Sep 17 00:00:00 2001 From: Nolen Johnson Date: Wed, 24 Jun 2026 21:36:05 -0400 Subject: [PATCH 8/9] techpack: display: msm: sde: Fix uninitialized errors Change-Id: I481190f2a03bc49976241e4c0b60304ca634f89a --- techpack/display/msm/sde/sde_rm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/techpack/display/msm/sde/sde_rm.c b/techpack/display/msm/sde/sde_rm.c index 4367cf9d2055..0922d7818db0 100644 --- a/techpack/display/msm/sde/sde_rm.c +++ b/techpack/display/msm/sde/sde_rm.c @@ -987,7 +987,7 @@ static bool _sde_rm_check_lm_and_get_connected_blks( u32 conn_lm_mask) { const struct sde_lm_cfg *lm_cfg = to_sde_hw_mixer(lm->hw)->cap; - const struct sde_pingpong_cfg *pp_cfg; + const struct sde_pingpong_cfg *pp_cfg = NULL; bool ret, is_conn_primary, is_conn_secondary; u32 lm_primary_pref, lm_secondary_pref, cwb_pref; From 8d80a9da0f65b66bc7ad3099ceccd6bd1a882ed1 Mon Sep 17 00:00:00 2001 From: Nolen Johnson Date: Wed, 24 Jun 2026 21:36:33 -0400 Subject: [PATCH 9/9] drivers: staging: qca-wifi-host-cmn: Fix implicit-enum-enum-cast errors Change-Id: I2e72f2fe56aed7c42db7b5ad52937080acb20343 --- drivers/staging/qca-wifi-host-cmn/hif/src/ce/ce_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/qca-wifi-host-cmn/hif/src/ce/ce_main.c b/drivers/staging/qca-wifi-host-cmn/hif/src/ce/ce_main.c index 14f4f978fef5..895c1bd94f46 100644 --- a/drivers/staging/qca-wifi-host-cmn/hif/src/ce/ce_main.c +++ b/drivers/staging/qca-wifi-host-cmn/hif/src/ce/ce_main.c @@ -2227,7 +2227,7 @@ hif_send_head(struct hif_opaque_softc *hif_ctx, if (qdf_unlikely(!ce_hdl)) { hif_err("CE handle is null"); - return A_ERROR; + return QDF_STATUS_E_FAILURE; } QDF_NBUF_UPDATE_TX_PKT_COUNT(nbuf, QDF_NBUF_TX_PKT_HIF);