OSDN Git Service

sagit-ice-cold/kernel_xiaomi_msm8998.git
4 years agoarm64: sysreg: replace open-coded mrs_s/msr_s with {read,write}_sysreg_s
Will Deacon [Tue, 6 Sep 2016 13:04:45 +0000 (14:04 +0100)]
arm64: sysreg: replace open-coded mrs_s/msr_s with {read,write}_sysreg_s

Similar to our {read,write}_sysreg accessors for architected, named
system registers, this patch introduces {read,write}_sysreg_s variants
that can take arbitrary sys_reg output and therefore access IMPDEF
registers or registers that unsupported by binutils.

Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: kdrag0n <dragon@khronodragon.com>
Signed-off-by: celtare21 <celtare21@gmail.com>
4 years agoinit: ensure initcall ordering with LTO
Sami Tolvanen [Fri, 8 Dec 2017 23:49:24 +0000 (15:49 -0800)]
init: ensure initcall ordering with LTO

With LTO, the compiler doesn't necessarily obey link order for
initcalls, and the initcall variable needs to be globally unique
to avoid naming collisions.

In order to preserve the correct order, we add each variable
into its own section and generate a linker script (in
scripts/link-vmlinux.sh) to ensure the order remains correct.  We
also add a __COUNTER__ prefix to the name, so we can retain the
order of initcalls within each compilation unit, and __LINE__ to
make the names more unique.

Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
[wight554: backport to 4.4]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agoFROMLIST: efi/libstub: disable LTO
Sami Tolvanen [Mon, 1 May 2017 18:08:05 +0000 (11:08 -0700)]
FROMLIST: efi/libstub: disable LTO

With CONFIG_LTO_CLANG, we produce LLVM IR instead of object files. Since LTO
is not really needed here and the Makefile assumes we produce an object file,
disable LTO for libstub.

Bug: 62093296
Bug: 67506682
Change-Id: Ieaa3d7e2c694655788f480f4351bf7c4d3fce090
(am from https://patchwork.kernel.org/patch/10060309/)
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
4 years agoFROMLIST: scripts/mod: disable LTO for empty.c
Sami Tolvanen [Mon, 10 Apr 2017 19:32:24 +0000 (12:32 -0700)]
FROMLIST: scripts/mod: disable LTO for empty.c

With CONFIG_LTO_CLANG, clang generates LLVM IR instead of ELF object
files. As empty.o is used for probing target properties, disable LTO
for it to produce an object file instead.

Bug: 62093296
Bug: 67506682
Change-Id: I0c7ac7ee0134465cac4a8c3a9c7e8b6347076a2b
(am from https://patchwork.kernel.org/patch/10060317/)
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
4 years agoANDROID: kbuild: disable LTO_CLANG with KASAN
Sami Tolvanen [Fri, 14 Sep 2018 16:17:55 +0000 (09:17 -0700)]
ANDROID: kbuild: disable LTO_CLANG with KASAN

Using LTO with KASAN currently results in "inlinable function call
in a function with debug info must have a !dbg location" errors for
memset and several of the __asan_report_* functions.

As combining these options doesn't provide significant benefits,
this change disables LTO_CLANG when KASAN is selected.

Bug: 113246877
Change-Id: I06cd27d1e9ab74627de4771548453abe3593fcb5
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
4 years agoFROMLIST: BACKPORT: kbuild: fix dynamic ftrace with clang LTO
Sami Tolvanen [Fri, 16 Jun 2017 19:52:57 +0000 (12:52 -0700)]
FROMLIST: BACKPORT: kbuild: fix dynamic ftrace with clang LTO

With CONFIG_LTO_CLANG enabled, LLVM IR won't be compiled into object
files until modpost_link. This change postpones calls to recordmcount
until after this step.

In order to exclude ftrace_process_locs from inspection, we add a new
code section .text..ftrace, which we tell recordmcount to ignore, and
a __norecordmcount attribute for moving functions to this section.

Bug: 62093296
Bug: 67506682
Change-Id: Iba2c053968206acf533fadab1eb34a743b5088ee
(am from https://patchwork.kernel.org/patch/10060327/)
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
4 years agoANDROID: kbuild: add support for clang LTO
Sami Tolvanen [Tue, 28 Nov 2017 16:48:49 +0000 (08:48 -0800)]
ANDROID: kbuild: add support for clang LTO

This change adds the configuration option CONFIG_LTO_CLANG, and
build system support for clang's Link Time Optimization (LTO). In
preparation for LTO support for other compilers, potentially common
parts of the changes are gated behind CONFIG_LTO instead.

With -flto, instead of object files, clang produces LLVM bitcode,
which is compiled into a native object at link time, allowing the
final binary to be optimized globally. For more details, see:

  https://llvm.org/docs/LinkTimeOptimization.html

While the kernel normally uses GNU ld for linking, LLVM supports LTO
only with lld or GNU gold linkers. This patch set assumes lld will
be used.

Bug: 62093296
Bug: 67506682
Bug: 133186739
Change-Id: Ibcd9fc7ec501b4f30b43b4877897615645f8655f
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
[kenny3fcb: Add LLD linking support from commit: https://github.com/kdrag0n/proton_bluecross/commit/aba52591410b75e6d21df015d1c3ebba051677e3,
substitute CC_IS_CLANG with clang-ifversion check taken from kernel 4.9 version of this commit,
add ld-name macro from https://github.com/aosp-mirror/kernel_common/commit/552777bdc1d775bee1ffde43c23ab0b2c4501f35, replace gold with lld referring the above kdrag0n's commit,
substitute LD_IS_LLD with ld-name check,
add back lto-flags check from kernel 4.9 version of this commit]
Signed-off-by: Subhajeet Muhuri <kenny3fcb@gmail.com>
[wight554: add ThinLTO support from upstream version of commit,
check for clang 8.0 instead of 5.0 for LD=ld.lld compatibility]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agokbuild: clean up link rule of composite modules
Masahiro Yamada [Mon, 19 Mar 2018 11:26:13 +0000 (20:26 +0900)]
kbuild: clean up link rule of composite modules

cmd_link_multi-link is used only for cmd_link_multi-m.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: improve linker compatibility with lib-ksyms.o build
Nicholas Piggin [Wed, 23 Nov 2016 16:41:40 +0000 (03:41 +1100)]
kbuild: improve linker compatibility with lib-ksyms.o build

lib-ksyms.o is created by linking an empty input file with a linker
script containing the interesting bits. Currently the empty input file
is an archive containing nothing, however this causes the gold linker
to segfault.

I have opened a bug against gold

  https://sourceware.org/bugzilla/show_bug.cgi?id=20767

However this can be worked around by assembling an empty file to link
with instead. The resulting lib-ksyms.o is slightly larger (seemingly
due to empty .text, .data, .bss setions added), but final linked
output should not be changed.

Reported-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
4 years agokbuild: remove CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
Masahiro Yamada [Wed, 9 May 2018 07:23:50 +0000 (16:23 +0900)]
kbuild: remove CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX

CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX was selected by BLACKFIN, METAG.
They were removed by commit 4ba66a976072 ("arch: remove blackfin port"),
commit bb6fb6dfcc17 ("metag: Remove arch/metag/"), respectively.

No more architecture enables CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX.
Clean up the rest of scripts, and remove the Kconfig entry.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
4 years agokbuild: cmd_export_list: tighten the sed script
Nicolas Pitre [Thu, 17 Nov 2016 00:28:39 +0000 (19:28 -0500)]
kbuild: cmd_export_list: tighten the sed script

When LTO is used, some ___ksymtab_string sections are seen by this sed
script, creating lines containing a single ) such as:

EXPORT(foo)
)
)
EXPORT(bar)

Let's make it so the + character is also required for any line to be
printed.

Signed-off-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Michal Marek <mmarek@suse.com>
4 years ago{chiron,sagit}_defconfig: Enable CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
Subhajeet Muhuri [Mon, 17 Dec 2018 07:54:46 +0000 (13:24 +0530)]
{chiron,sagit}_defconfig: Enable CONFIG_LD_DEAD_CODE_DATA_ELIMINATION

Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agokbuild: reword help of LD_DEAD_CODE_DATA_ELIMINATION
Masahiro Yamada [Sat, 23 Jun 2018 16:41:51 +0000 (01:41 +0900)]
kbuild: reword help of LD_DEAD_CODE_DATA_ELIMINATION

Since commit 5d20ee3192a5 ("kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION
to be selectable if enabled"), HAVE_LD_DEAD_CODE_DATA_ELIMINATION is
supposed to be selected by architectures that are capable of this
functionality.  LD_DEAD_CODE_DATA_ELIMINATION is now users' selection.
Update the help message.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agoarm64: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected
Subhajeet Muhuri [Mon, 17 Dec 2018 07:50:22 +0000 (13:20 +0530)]
arm64: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selected

Referring: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=4c1d9bb0b5d3c0b3468ac8e68a05972eb957630f

After enabling LD_DEAD_CODE_DATA_ELIMINATION from defconfig,
resulting kernel is almost 200kB smaller

Before LD_DEAD_CODE_DATA_ELIMINATION:

   text    data     bss     dec     hex filename
18067341 7279769 3927748 29274858 1beb2ea vmlinux
22190806 2251638 3927748 28370192 1b0e510 vmlinux.o

After LD_DEAD_CODE_DATA_ELIMINATION:

   text    data     bss     dec     hex filename
17690697 7189217 3900064 28779978 1b725ca vmlinux
22176305 2245781 3920524 28342610 1b07952 vmlinux.o

Signed-off-by: Subhajeet Muhuri <kenny3fcb@gmail.com>
4 years agokbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if enabled
Nicholas Piggin [Wed, 9 May 2018 13:00:00 +0000 (23:00 +1000)]
kbuild: Allow LD_DEAD_CODE_DATA_ELIMINATION to be selectable if enabled

Architectures that are capable can select
HAVE_LD_DEAD_CODE_DATA_ELIMINATION to enable selection of that
option (as an EXPERT kernel option).

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: LD_DEAD_CODE_DATA_ELIMINATION no -ffunction-sections/-fdata-sections for...
Nicholas Piggin [Wed, 9 May 2018 12:59:59 +0000 (22:59 +1000)]
kbuild: LD_DEAD_CODE_DATA_ELIMINATION no -ffunction-sections/-fdata-sections for module build

Modules do not tend to cope with -ffunction-sections, even though they
do not link with -gc-sections. It may be possible for unused symbols to
be trimmed from modules, but in general that would take much more work
in architecture module linker scripts.

For now, enable these only for kernel build.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: Fix asm-generic/vmlinux.lds.h for LD_DEAD_CODE_DATA_ELIMINATION
Nicholas Piggin [Wed, 9 May 2018 12:59:58 +0000 (22:59 +1000)]
kbuild: Fix asm-generic/vmlinux.lds.h for LD_DEAD_CODE_DATA_ELIMINATION

KEEP more tables, and add the function/data section wildcard to more
section selections.

This is a little ad-hoc at the moment, but kernel code should be moved
to consistently use .text..x (note: double dots) for explicit sections
and all references to it in the linker script can be made with
TEXT_MAIN, and similarly for other sections.

For now, let's see if major architectures move to enabling this option
then we can do some refactoring passes. Otherwise if it remains unused
or superseded by LTO, this may not be required.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agoFROMLIST: BACKPORT: arm64: keep .altinstructions and .altinstr_replacement
Sami Tolvanen [Tue, 10 Oct 2017 17:56:17 +0000 (10:56 -0700)]
FROMLIST: BACKPORT: arm64: keep .altinstructions and .altinstr_replacement

Make sure the linker doesn't remove .altinstructions or
.altinstr_replacement when CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is
enabled.

Bug: 62093296
Bug: 67506682
Change-Id: I73f8a96679083909ec6865ee87519163ac7dcbe3
(am from https://patchwork.kernel.org/patch/10085799/)
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
4 years agoarm64: fix LD_DEAD_CODE_DATA_ELIMINATION
Sami Tolvanen [Tue, 13 Feb 2018 22:00:14 +0000 (14:00 -0800)]
arm64: fix LD_DEAD_CODE_DATA_ELIMINATION

Keep .entry.tramp.text to avoid the "Entry trampoline text too big"
error while linking.

Bug: 62093296
Bug: 67506682
Change-Id: Idab3216244bd2f8537bb2a5bb47e25e8588394da
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
4 years agoFROMLIST: kbuild: fix LD_DEAD_CODE_DATA_ELIMINATION
Sami Tolvanen [Tue, 10 Oct 2017 17:58:53 +0000 (10:58 -0700)]
FROMLIST: kbuild: fix LD_DEAD_CODE_DATA_ELIMINATION

Don't remove .head.text or .exitcall.exit when linking with --gc-sections,
and include .init.text.* in .init.text and .init.rodata.* in .init.rodata.

Bug: 62093296
Bug: 67506682
Change-Id: Ia0f9e735d04c2322dcc8bcfc94241f0551b149c4
(am from https://patchwork.kernel.org/patch/10085773/)
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
4 years agokbuild: linker script do not match C names unless LD_DEAD_CODE_DATA_ELIMINATION is...
Nicholas Piggin [Wed, 26 Jul 2017 12:46:27 +0000 (22:46 +1000)]
kbuild: linker script do not match C names unless LD_DEAD_CODE_DATA_ELIMINATION is configured

The .data and .bss sections were modified in the generic linker script to
pull in sections named .data.<C identifier>, which are generated by gcc with
-ffunction-sections and -fdata-sections options.

The problem with this pattern is it can also match section names that Linux
defines explicitly, e.g., .data.unlikely. This can cause Linux sections to
get moved into the wrong place.

The way to avoid this is to use ".." separators for explicit section names
(the dot character is valid in a section name but not a C identifier).
However currently there are sections which don't follow this rule, so for
now just disable the wild card by default.

Example: http://marc.info/?l=linux-arm-kernel&m=150106824024221&w=2

Cc: <stable@vger.kernel.org> # 4.9
Fixes: b67067f1176df ("kbuild: allow archs to select link dead code/data elimination")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: keep data tables through dead code elimination
Nicholas Piggin [Wed, 23 Nov 2016 16:41:41 +0000 (03:41 +1100)]
kbuild: keep data tables through dead code elimination

When CONFIG_LD_DEAD_CODE_DATA_ELIMINATION is enabled we must ensure
that we still keep various programatically-accessed tables.

[npiggin: Fold Paul's patches into one, and add a few more tables.
 diff symbol tables of allyesconfig with/without -gc-sections shows up
 lost tables quite easily.]

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
4 years agokbuild: avoid conflict between -ffunction-sections and -pg on gcc-4.7
Masahiro Yamada [Fri, 14 Apr 2017 06:17:26 +0000 (15:17 +0900)]
kbuild: avoid conflict between -ffunction-sections and -pg on gcc-4.7

Arnd Bergmann reported:
  "When ftrace is enabled and we build with gcc-4.7 or older, we
  get a warning for each file on architectures that select
  CONFIG_LD_DEAD_CODE_DATA_ELIMINATION:

  warning: -ffunction-sections disabled; it makes profiling impossible [enabled by default]
  "

Since commit c3f0d0bc5b01 ("kbuild, LLVMLinux: Add -Werror to
cc-option to support clang"), warnings are treated as errors in
cc-option checks.  CC_FLAGS_FTRACE is blindly added to KBUILD_CFLAGS,
so $(call cc-option,-ffunction-sections,) should be moved below it
in order to detect the conflict between the two options.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: -ffunction-sections fix for archs with conflicting sections
Nicholas Piggin [Wed, 14 Sep 2016 02:24:03 +0000 (12:24 +1000)]
kbuild: -ffunction-sections fix for archs with conflicting sections

Enabling -ffunction-sections modified the generic linker script to
pull .text.* sections into regular TEXT_TEXT section, conflicting
with some architectures. Revert that change and require archs that
enable the option to ensure they have no conflicting section names,
and do the appropriate merging.

Reported-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Fixes: b67067f1176d ("kbuild: allow archs to select link dead code/data elimination")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
4 years agokbuild: allow archs to select link dead code/data elimination
Nicholas Piggin [Wed, 24 Aug 2016 12:29:20 +0000 (22:29 +1000)]
kbuild: allow archs to select link dead code/data elimination

Introduce LD_DEAD_CODE_DATA_ELIMINATION option for architectures to
select to build with -ffunction-sections, -fdata-sections, and link
with --gc-sections. It requires some work (documented) to ensure all
unreferenced entrypoints are live, and requires toolchain and build
verification, so it is made a per-arch option for now.

On a random powerpc64le build, this yelds a significant size saving,
it boots and runs fine, but there is a lot I haven't tested as yet, so
these savings may be reduced if there are bugs in the link.

    text      data        bss        dec   filename
11169741   1180744    1923176 14273661   vmlinux
10445269   1004127    1919707 13369103   vmlinux.dce

~700K text, ~170K data, 6% removed from kernel image size.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
Signed-off-by: Subhajeet Muhuri <kenny3fcb@gmail.com>
4 years agokbuild: clean up archive rule of built-in.a
Masahiro Yamada [Mon, 19 Mar 2018 11:26:12 +0000 (20:26 +0900)]
kbuild: clean up archive rule of built-in.a

With the incremental linking entirely dropped, we can simplify
the Makefile.

While I am here, I renamed cmd_link_o_target to cmd_ar_builtin.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: remove partial section mismatch detection for built-in.a
Masahiro Yamada [Mon, 19 Mar 2018 11:26:11 +0000 (20:26 +0900)]
kbuild: remove partial section mismatch detection for built-in.a

When built-in.o was incrementally linked with 'ld -r', the section
mismatch analysis for the individual built-in.o was possible when
CONFIG_DEBUG_SECTION_MISMATCH was enabled.

With the migration to the thin archive, built-in.a (former, built-in.o)
is no longer an ELF file.  So, the modpost does nothing useful.
scripts/mod/modpost.c just checks the header to bail out, as follows:

        /* Is this a valid ELF file? */
        if ((hdr->e_ident[EI_MAG0] != ELFMAG0) ||
            (hdr->e_ident[EI_MAG1] != ELFMAG1) ||
            (hdr->e_ident[EI_MAG2] != ELFMAG2) ||
            (hdr->e_ident[EI_MAG3] != ELFMAG3)) {
                /* Not an ELF file - silently ignore it */
                return 0;
        }

We have the full analysis in the final link stage anyway, so we would
not miss the section mismatching.

I do not see a good reason to require extra linking only for the
purpose of the per-directory analysis.  Just get rid of this part.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: link $(real-obj-y) instead of $(obj-y) into built-in.a
Masahiro Yamada [Mon, 19 Mar 2018 11:26:08 +0000 (20:26 +0900)]
kbuild: link $(real-obj-y) instead of $(obj-y) into built-in.a

In Kbuild, Makefiles can add the same object to obj-y multiple
times.  So,

   obj-y += foo.o
   obj-y += foo.o

is fine.

However, this is not true when the same object is added multiple
times via composite objects.  For example,

   obj-y    += foo.o bar.o
   foo-objs := foo-bar-common.o foo-only.o
   bar-objs := foo-bar-common.o bar-only.o

causes build error because two instances of foo-bar-common.o are
linked into the vmlinux.

Makefiles tend to invent ugly work-around, for example
  - lib/zstd/Makefile
  - drivers/net/ethernet/cavium/liquidio/Makefile

The technique used in Kbuild to avoid the multiple definition error
is to use $(filter $(obj-y), $^).  Here, $^ lists the names of all
the prerequisites with duplicated names removed.

By replacing it with $(filter $(real-obj-y), $^) we can do likewise
for composite objects.  For built-in objects, we do not need to keep
the composite object structure.  We can simply expand them, and link
$(real-obj-y) to built-in.a.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years ago[kbuild] handle exports in lib-y objects reliably
Al Viro [Fri, 15 Jan 2016 19:01:22 +0000 (14:01 -0500)]
[kbuild] handle exports in lib-y objects reliably

Collect the symbols exported by anything that goes into lib.a and
add an empty object (lib-exports.o) with explicit undefs for each
of those to obj-y.

That allows to relax the rules regarding the use of exports in
lib-* objects - right now an object with export can be in lib-*
only if we are guaranteed that there always will be users in
built-in parts of the tree, otherwise it needs to be in obj-*.
As the result, we have an unholy mix of lib- and obj- in lib/Makefile
and (especially) in arch/*/lib/Makefile.  Moreover, a change in
generic part of the kernel can lead to mysteriously missing exports
on some configs.  With this change we don't have to worry about
that anymore.

One side effect is that built-in.o now pulls everything with exports
from the corresponding lib.a (if such exists).  That's exactly what
we want for linking vmlinux and fortunately it's almost the only thing
built-in.o is used in.  arch/ia64/hp/sim/boot/bootloader is the only
exception and it's easy to get rid of now - just turn everything in
arch/ia64/lib into lib-* and don't bother with arch/ia64/lib/built-in.o
anymore.

[AV: stylistic fix from Michal folded in]

Acked-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
4 years agokbuild: rename real-objs-y/m to real-obj-y/m
Masahiro Yamada [Mon, 19 Mar 2018 11:26:07 +0000 (20:26 +0900)]
kbuild: rename real-objs-y/m to real-obj-y/m

When I was refactoring Makefiles, I stupidly mistook 'real-obj-y' for
'real-objs-y' over and over again.  Finally, I decide to rename it to
'real-obj-y'.  This is consistent with 'obj-y', 'subdir-obj-y'.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: drop $(extra-y) from real-objs-y
Masahiro Yamada [Thu, 23 Nov 2017 14:25:26 +0000 (23:25 +0900)]
kbuild: drop $(extra-y) from real-objs-y

$(real-objs-y) in only used in scripts/Makefile.build to form
"targets", but $(extra-y) is added to "targets" in another line.
We do not need to add $(extra-y) twice.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: Allow to specify composite modules with modname-m
Michal Marek [Tue, 27 Oct 2015 13:02:24 +0000 (14:02 +0100)]
kbuild: Allow to specify composite modules with modname-m

This allows to write

  drm-$(CONFIG_AGP) += drm_agpsupport.o

without having to handle CONFIG_AGP=y vs. CONFIG_AGP=m. Only support
this syntax for modules, since built-in code depending on something
modular cannot work and init/Makefile actually relies on the current
semantics. There are a few drivers which adapted to the current
semantics out of necessity; these are fixed to also work when the
respective subsystem is modular.

Acked-by: Peter Chen <peter.chen@freescale.com> [chipidea]
Signed-off-by: Michal Marek <mmarek@suse.com>
4 years agokbuild: create built-in.o automatically if parent directory wants it
Masahiro Yamada [Tue, 7 Nov 2017 16:31:46 +0000 (01:31 +0900)]
kbuild: create built-in.o automatically if parent directory wants it

"obj-y += foo/" syntax requires Kbuild to visit the "foo" subdirectory
and link built-in.o from that directory.  This means foo/Makefile is
responsible for creating built-in.o even if there is no object to
link (in this case, built-in.o is an empty archive).

We have had several fixups like commit 4b024242e8a4 ("kbuild: Fix
linking error built-in.o no such file or directory"), then ended up
with a complex condition as follows:

  ifneq ($(strip $(obj-y) $(obj-m) $(obj-) $(subdir-m) $(lib-target)),)
  builtin-target := $(obj)/built-in.o
  endif

We still have more cases not covered by the above, so we need to add
  obj- := dummy.o
in several places just for creating empty built-in.o.

A key point is, the parent Makefile knows whether built-in.o is needed
or not.  If a subdirectory needs to create built-in.o, its parent can
tell the fact when descending.

If non-empty $(need-builtin) flag is passed from the parent, built-in.o
should be created.  $(obj-y) should be still checked to support the
single target "%/".  All of ugly tricks will go away.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Sam Ravnborg <sam@ravnborg.org>
4 years agokbuild: rename built-in.o to built-in.a
Nicholas Piggin [Sat, 10 Feb 2018 14:25:04 +0000 (00:25 +1000)]
kbuild: rename built-in.o to built-in.a

Incremental linking is gone, so rename built-in.o to built-in.a, which
is the usual extension for archive files.

This patch does two things, first is a simple search/replace:

git grep -l 'built-in\.o' | xargs sed -i 's/built-in\.o/built-in\.a/g'

The second is to invert nesting of nested text manipulations to avoid
filtering built-in.a out from libs-y2:

-libs-y2 := $(filter-out %.a, $(patsubst %/, %/built-in.a, $(libs-y)))
+libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y)))

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: remove incremental linking option
Nicholas Piggin [Sat, 10 Feb 2018 14:25:03 +0000 (00:25 +1000)]
kbuild: remove incremental linking option

This removes the old `ld -r` incremental link option, which has not
been selected by any architecture since June 2017.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: handle libs-y archives separately from built-in.o archives
Nicholas Piggin [Mon, 19 Jun 2017 15:52:05 +0000 (01:52 +1000)]
kbuild: handle libs-y archives separately from built-in.o archives

The thin archives build currently puts all lib.a and built-in.o
files together and links them with --whole-archive.

This works because thin archives can recursively refer to thin
archives. However some architectures include libgcc.a, which may
not be a thin archive, or it may not be constructed with the "P"
option, in which case its contents do not get linked correctly.

So don't pull .a libs into the root built-in.o archive. These
libs should already have symbol tables and indexes built, so they
can be direct linker inputs. Move them out of the --whole-archive
option, which restore the conditional linking behaviour of lib.a
to thin archives builds.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: thin archives make default for all archs
Nicholas Piggin [Fri, 9 Jun 2017 05:24:17 +0000 (15:24 +1000)]
kbuild: thin archives make default for all archs

Make thin archives build the default, but keep the config option
to allow exemptions if any breakage can't be quickly solved.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Subhajeet Muhuri <kenny3fcb@gmail.com>
4 years agokbuild: thin archives use P option to ar
Nicholas Piggin [Fri, 9 Jun 2017 05:24:14 +0000 (15:24 +1000)]
kbuild: thin archives use P option to ar

The P option makes ar do full path name matching and can prevent ar
from discarding files with duplicate names in some cases of creating
thin archives from thin archives. The sh architecture in particular
loses some object files from its kernel/cpu/sh*/ directories without
this option.

This could be a bug in binutils ar, but the P option should not cause
any negative effects so it is safe to use to work around this with.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: thin archives for multi-y targets
Nicholas Piggin [Wed, 23 Nov 2016 16:41:38 +0000 (03:41 +1100)]
kbuild: thin archives for multi-y targets

THIN_ARCHIVES builds archives for built-in.o targets, have it build
multi-y targets as archives as well.

This saves another ~15% of the size of intermediate artifacts in the
build tree. After this patch, the linker is only used in final link,
and special cases like vdsos.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
4 years agokbuild: thin archives final link close --whole-archives option
Nicholas Piggin [Fri, 9 Jun 2017 05:24:13 +0000 (15:24 +1000)]
kbuild: thin archives final link close --whole-archives option

Close the --whole-archives option with --no-whole-archive. Some
architectures end up including additional .o and files multiple
times after this, and they get duplicate symbols when they are
brought under the --whole-archives option.

This matches more closely with the incremental final link.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agokbuild: minor improvement for thin archives build
Nicholas Piggin [Wed, 23 Nov 2016 16:41:43 +0000 (03:41 +1100)]
kbuild: minor improvement for thin archives build

The root built-in.o archive is currently generated before all object
files are built for the final link, due to final build of init/ after
version update. In practice it seems like it doesn't matter because
the archive symbol table does not change, but it is more logical to
create the final archive as the last step.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
4 years agokbuild: allow architectures to use thin archives instead of ld -r
Stephen Rothwell [Wed, 24 Aug 2016 12:29:19 +0000 (22:29 +1000)]
kbuild: allow architectures to use thin archives instead of ld -r

ld -r is an incremental link used to create built-in.o files in build
subdirectories. It produces relocatable object files containing all
its input files, and these are are then pulled together and relocated
in the final link. Aside from the bloat, this constrains the final
link relocations, which has bitten large powerpc builds with
unresolvable relocations in the final link.

Alan Modra has recommended the kernel use thin archives for linking.
This is an alternative and means that the linker has more information
available to it when it links the kernel.

This patch enables a config option architectures can select, which
causes all built-in.o files to be built as thin archives. built-in.o
files in subdirectories do not get symbol table or index attached,
which improves speed and size. The final link pass creates a
built-in.o archive in the root output directory which includes the
symbol table and index. The linker then uses takes this file to link.

The --whole-archive linker option is required, because the linker now
has visibility to every individual object file, and it will otherwise
just completely avoid including those without external references
(consider a file with EXPORT_SYMBOL or initcall or hardware exceptions
as its only entry points). The traditional built works "by luck" as
built-in.o files are large enough that they're going to get external
references. However this optimisation is unpredictable for the kernel
(due to above external references), ineffective at culling unused, and
costly because the .o files have to be searched for references.
Superior alternatives for link-time culling should be used instead.

Build characteristics for inclink vs thinarc, on a small powerpc64le
pseries VM with a modest .config:

                                  inclink       thinarc
sizes
vmlinux                        15 618 680    15 625 028
sum of all built-in.o          56 091 808     1 054 334
sum excluding root built-in.o                   151 430

find -name built-in.o | xargs rm ; time make vmlinux
real                              22.772s       21.143s
user                              13.280s       13.430s
sys                                4.310s        2.750s

- Final kernel pulled in only about 6K more, which shows how
  ineffective the object file culling is.
- Build performance looks improved due to less pagecache activity.
  On IO constrained systems it could be a bigger win.
- Build size saving is significant.

Side note, the toochain understands archives, so there's some tricks,
$ ar t built-in.o          # list all files you linked with
$ size built-in.o          # and their sizes
$ objdump -d built-in.o    # disassembly (unrelocated) with filenames

Implementation by sfr, minor tweaks by npiggin.

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
4 years agomsm: mdss: dsi: Fix missing display state api for maple
0ranko0P [Mon, 28 Oct 2019 16:02:02 +0000 (00:02 +0800)]
msm: mdss: dsi: Fix missing display state api for maple

4 years agoblock: Add Maple IO scheduler
0ranko0P [Mon, 28 Oct 2019 15:32:52 +0000 (23:32 +0800)]
block: Add Maple IO scheduler

4 years agoblock: Add Zen IO scheduler
0ranko0P [Mon, 28 Oct 2019 15:12:21 +0000 (23:12 +0800)]
block: Add Zen IO scheduler

4 years agomsm: qpnp-haptic: Fix missing cmhw implementation after merge xiaomi
0ranko0P [Mon, 28 Oct 2019 11:39:40 +0000 (19:39 +0800)]
msm: qpnp-haptic: Fix missing cmhw implementation after merge xiaomi
changes

4 years agoqpnp-haptic: expose vibrate function
flar2 [Wed, 14 Jun 2017 02:14:35 +0000 (22:14 -0400)]
qpnp-haptic: expose vibrate function

Change-Id: I91604f6b946940c7a2681720c683010538b222e8
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
4 years agotreewide: Kill more warnings about debugfs failure if disabled
Volodymyr Zhdanov [Tue, 2 Jul 2019 10:30:43 +0000 (13:30 +0300)]
treewide: Kill more warnings about debugfs failure if disabled

4 years agotreewide: Don't warn about debugfs failure if disabled
0ctobot [Sun, 16 Jun 2019 20:08:51 +0000 (16:08 -0400)]
treewide: Don't warn about debugfs failure if disabled

Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
[wight554: backport to 4.4]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agowakeup: Enable debugfs usage for Android even when debugfs is disabled
Sultan Alsawaf [Sat, 20 Jul 2019 17:10:24 +0000 (10:10 -0700)]
wakeup: Enable debugfs usage for Android even when debugfs is disabled

Android userspace needs this driver's debugfs entry, so enable it.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agomsm: vidc: Fix broken debugfs creation error checks and error paths
Sultan Alsawaf [Fri, 1 Jun 2018 00:03:33 +0000 (17:03 -0700)]
msm: vidc: Fix broken debugfs creation error checks and error paths

The debugfs helper functions do not always return NULL when they fail;
instead, they can return an error number casted as a pointer, so that their
users have the option to determine the exact cause of failure.

Use the IS_ERR_OR_NULL() helper when checking for debugfs errors to fix the
error checks.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agodefconfig: Disable profiling subsystem
Julian Liu [Fri, 16 Aug 2019 09:28:41 +0000 (17:28 +0800)]
defconfig: Disable profiling subsystem

4 years agodefconfig: Enable IP_NF_TARGET_TTL
Julian Liu [Tue, 3 Sep 2019 02:55:58 +0000 (10:55 +0800)]
defconfig: Enable IP_NF_TARGET_TTL

* regen

4 years agoscripts: Don't append "+" to localversion
Sultan Alsawaf [Mon, 14 May 2018 05:35:12 +0000 (22:35 -0700)]
scripts: Don't append "+" to localversion

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agodebugfs: Always compile core debugfs driver for Android kernels
Sultan Alsawaf [Mon, 13 Aug 2018 08:11:34 +0000 (01:11 -0700)]
debugfs: Always compile core debugfs driver for Android kernels

Unfortunately, Android userspace is very dependent on debugfs for several
unrelated things; however, it definitely doesn't require *everything*
that is included in the kernel when CONFIG_DEBUG_FS is enabled.

Therefore, in order to be able to selectively whitelist drivers that
Android needs debugfs for (by adding a #define CONFIG_DEBUG_FS to the top
of every .c file that's desired to be whitelisted), always compile the
core debugfs drivers even when CONFIG_DEBUG_FS is disabled so that
debugfs can still be used where it's necessary.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agoarm64: kernel: Don't build perf_debug.o when debugfs is disabled
Sultan Alsawaf [Thu, 17 May 2018 02:58:59 +0000 (19:58 -0700)]
arm64: kernel: Don't build perf_debug.o when debugfs is disabled

perf_debug.o depends on debugfs, so there's no reason to build it when
debugfs is disabled.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
[wight554: fix caf tree conflict]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agomsm: thermal: Fix compile errors when debugfs is disabled
Sultan Alsawaf [Mon, 15 Apr 2019 00:50:14 +0000 (17:50 -0700)]
msm: thermal: Fix compile errors when debugfs is disabled

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agomsm: mdss: Fix compile errors when debugfs is disabled
Sultan Alsawaf [Mon, 15 Apr 2019 00:48:26 +0000 (17:48 -0700)]
msm: mdss: Fix compile errors when debugfs is disabled

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
[wight554: fix conflict in drivers/video/fbdev/msm/mdss_dsi.h]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agoscsi: ufs: Fix compile errors when debugfs is disabled
Sultan Alsawaf [Mon, 15 Apr 2019 00:46:55 +0000 (17:46 -0700)]
scsi: ufs: Fix compile errors when debugfs is disabled

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agomsm: sps: Fix compile errors when debugfs is disabled
Sultan Alsawaf [Mon, 15 Apr 2019 00:46:16 +0000 (17:46 -0700)]
msm: sps: Fix compile errors when debugfs is disabled

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agomsm: ipa: Fix compile errors when debugfs is disabled
Sultan Alsawaf [Mon, 15 Apr 2019 00:44:19 +0000 (17:44 -0700)]
msm: ipa: Fix compile errors when debugfs is disabled

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agoASoC: msm: qdsp6v2: Fix compile errors when debugfs is disabled
Sultan Alsawaf [Mon, 15 Apr 2019 00:42:31 +0000 (17:42 -0700)]
ASoC: msm: qdsp6v2: Fix compile errors when debugfs is disabled

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
[wight554: fix conflict in sound/soc/msm/qdsp6v2/q6asm.c]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agomsm: sde: Fix compile errors when debugfs is disabled
Sultan Alsawaf [Mon, 15 Apr 2019 00:41:22 +0000 (17:41 -0700)]
msm: sde: Fix compile errors when debugfs is disabled

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agoclk: msm: Fix compile errors when debugfs is disabled
Sultan Alsawaf [Mon, 15 Apr 2019 00:40:01 +0000 (17:40 -0700)]
clk: msm: Fix compile errors when debugfs is disabled

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agofirmware: qcom: Remove debugfs dependency from tz-log driver
Sultan Alsawaf [Sat, 20 Aug 2016 10:25:40 +0000 (03:25 -0700)]
firmware: qcom: Remove debugfs dependency from tz-log driver

Without this driver (specifically, its probe routines), the device crashes
frequently, so it is needed even when debugfs is disabled.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agocrypto: msm: Don't bail out when debugfs creation fails
Sultan Alsawaf [Sat, 20 Aug 2016 06:22:10 +0000 (23:22 -0700)]
crypto: msm: Don't bail out when debugfs creation fails

Debugfs creation failure is a non-fatal error. Don't kill crypto when
this happens.

Skip debugfs creation entirely when CONFIG_DEBUG_FS is disabled.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years ago{chiron,sagit}_defconfig: Disable SMACK and Integrity security suites
Sultan Alsawaf [Mon, 1 Jul 2019 20:16:24 +0000 (13:16 -0700)]
{chiron,sagit}_defconfig: Disable SMACK and Integrity security suites

We don't use these.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
[wight554: apply wahoo change on chiron and sagit]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agokernel: Use the stock CAF config for /proc/config.gz
Sultan Alsawaf [Sun, 12 Aug 2018 01:18:50 +0000 (18:18 -0700)]
kernel: Use the stock CAF config for /proc/config.gz

Userspace reads /proc/config.gz and spits out an error message after boot
finishes when it doesn't like the kernel's configuration. In order to
preserve our freedom to customize the kernel however we'd like, show
userspace the stock CAF config so that it never complains about our
kernel configuration.

Change-Id: I0965a9ec7db3b7f2c48df92f246ac6ad4c111219
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
[wight554: use caf defconfig instead of wahoo stock]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agoadreno: fix build without trace
Julian Liu [Tue, 17 Sep 2019 18:52:33 +0000 (02:52 +0800)]
adreno: fix build without trace

4 years ago{chiron,sagit}_defconfig: Overhaul and optimize
Sultan Alsawaf [Sat, 20 Jul 2019 17:27:46 +0000 (10:27 -0700)]
{chiron,sagit}_defconfig: Overhaul and optimize

This also configures the devfreq boost driver.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
[wight554: apply wahoo change on chiron and sagit,
strip and squash some further fixups]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agoinit: Kconfig: Don't force DEBUG_KERNEL when EXPERT is enabled
Sultan Alsawaf [Sun, 13 May 2018 20:02:33 +0000 (13:02 -0700)]
init: Kconfig: Don't force DEBUG_KERNEL when EXPERT is enabled

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agoais, camera_v2: Makefile: Remove CAF's inclusion of GCC_VERSION variables
Albert I [Sat, 29 Jun 2019 08:13:03 +0000 (16:13 +0800)]
ais, camera_v2: Makefile: Remove CAF's inclusion of GCC_VERSION variables

Should have already been handled by the kernel build system itself, so
remove them to avoid unecessary warnings spam if we're using standalone
Binutils in place of GCC.

Signed-off-by: Albert I <kras@raphielgang.org>
4 years ago{chiron,sagit}_defconfig: Disable audit support
Sultan Alsawaf [Thu, 18 Apr 2019 01:02:50 +0000 (18:02 -0700)]
{chiron,sagit}_defconfig: Disable audit support

Auditing comes with a measurably significant amount of overhead. Kill
it.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
[wight554: apply wahoo change on chiron and sagit]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agoselinux: Remove audit dependency
Sultan Alsawaf [Thu, 18 Apr 2019 01:02:18 +0000 (18:02 -0700)]
selinux: Remove audit dependency

Auditing comes with a lot of overhead due to string assembly via
vsnprintf. It isn't actually needed to make SELinux work, so remove
SELinux's artificial dependency on it to make it possible to use SELinux
without the unneeded overhead.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years ago{chiron,sagit}_defconfig: Enable Energy Aware Scheduling by default
Josh Choo [Sat, 29 Dec 2018 07:26:03 +0000 (14:26 +0700)]
{chiron,sagit}_defconfig: Enable Energy Aware Scheduling by default

[wight554: apply on chiron and sagit]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agoRevert "leds: qpnp-wled: Cap the lower limit of brightness level"
Julian Liu [Wed, 31 Jul 2019 21:25:59 +0000 (05:25 +0800)]
Revert "leds: qpnp-wled: Cap the lower limit of brightness level"

* Xiaomi reverted this in sagit-p-oss

This reverts commit 07b04723a609ec3a62acf1a5ba694c3d625c8354.

4 years agoANDROID: mm: add config for default readahead size
Wei Wang [Wed, 28 Feb 2018 21:34:22 +0000 (13:34 -0800)]
ANDROID: mm: add config for default readahead size

Change the VM_MAX_READAHED value from the default 128KB to a
configurable value. This will allow the readahead window to grow to a
maximum size bigger than 128KB, which greatly benefits to sequential
read throughput and thus boot performance.

Bug: 62413151
Test: boot walleye 100ms faster
Change-Id: Iad448cf1198056de46654dcb409466802b3b908d
Signed-off-by: Wei Wang <wvw@google.com>
4 years agocamera_v2: fix code issues
wloot [Fri, 28 Jun 2019 06:18:43 +0000 (14:18 +0800)]
camera_v2: fix code issues

4 years agofirmware: Only ship the panel fw which we need
wloot [Sat, 12 Jan 2019 22:34:42 +0000 (06:34 +0800)]
firmware: Only ship the panel fw which we need

4 years agomsm: mdss: Fix uninitialized variable
Julian Liu [Sat, 20 Jul 2019 10:11:58 +0000 (18:11 +0800)]
msm: mdss: Fix uninitialized variable

Clang warns:
drivers/video/fbdev/msm/mdss_mdp_intf_cmd.c:1381:28: error:
      variable 'vsync_time' is uninitialized when used here
      [-Werror,-Wuninitialized]
                        tmp->vsync_handler(ctl, vsync_time);
                                                ^~~~~~~~~~
drivers/video/fbdev/msm/mdss_mdp_intf_cmd.c:1367:2: note: variable
      'vsync_time' is declared here
        ktime_t vsync_time;
        ^
1 error generated.

4 years agoqcacld-3.0: Fix uninitialized variable
Julian Liu [Sat, 20 Jul 2019 09:39:09 +0000 (17:39 +0800)]
qcacld-3.0: Fix uninitialized variable

Clang warns:
drivers/staging/qcacld-3.0/core/hdd/src/wlan_hdd_wext.c:7185:6: error:
      variable 'sme_config' is used uninitialized whenever 'if' condition is
      false [-Werror,-Wsometimes-uninitialized]
        if (phymode != -EIO) {
            ^~~~~~~~~~~~~~~
drivers/staging/qcacld-3.0/core/hdd/src/wlan_hdd_wext.c:7263:6: note:
      uninitialized use occurs here
        if (sme_config)
            ^~~~~~~~~~
drivers/staging/qcacld-3.0/core/hdd/src/wlan_hdd_wext.c:7185:2: note:
      remove the 'if' if its condition is always true
        if (phymode != -EIO) {
        ^~~~~~~~~~~~~~~~~~~~~
drivers/staging/qcacld-3.0/core/hdd/src/wlan_hdd_wext.c:6981:30: note:
      initialize the variable 'sme_config' to silence this warning
        tSmeConfigParams *sme_config;
                                    ^
                                     = NULL
1 error generated.

4 years agomsm: sps: move a result processing statement into correct place
Julian Liu [Sat, 20 Jul 2019 09:28:45 +0000 (17:28 +0800)]
msm: sps: move a result processing statement into correct place

4 years agosynaptics_dsx_force: Fix uninitialized variable
Julian Liu [Sat, 20 Jul 2019 08:48:49 +0000 (16:48 +0800)]
synaptics_dsx_force: Fix uninitialized variable

Clang warns:
drivers/input/touchscreen/synaptics_dsx_force/synaptics_dsx_i2c.c:766:19: error:
      variable 'retval' is used uninitialized whenever 'for' loop exits
      because its condition is false [-Werror,-Wsometimes-uninitialized]
                for (retry = 0; retry < SYN_I2C_RETRY_TIMES; retry++) {
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/input/touchscreen/synaptics_dsx_force/synaptics_dsx_i2c.c:788:9: note:
      uninitialized use occurs here
        return retval;
               ^~~~~~
drivers/input/touchscreen/synaptics_dsx_force/synaptics_dsx_i2c.c:766:19: note:
      remove the condition if it is always true
                for (retry = 0; retry < SYN_I2C_RETRY_TIMES; retry++) {
                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/input/touchscreen/synaptics_dsx_force/synaptics_dsx_i2c.c:749:12: note:
      initialize the variable 'retval' to silence this warning
        int retval;
                  ^
                   = 0
1 error generated

4 years agoinput: vl53L0: Fix uninitialized variables
Julian Liu [Sat, 20 Jul 2019 08:36:28 +0000 (16:36 +0800)]
input: vl53L0: Fix uninitialized variables

Clang warns:
drivers/input/misc/vl53L0/src/vl53l010_api.c:1425:3: error:
      variable 'Temp8' is used uninitialized whenever 'if' condition is false      [-Werror,-Wsometimes-uninitialized]
                VL53L010_GETARRAYPARAMETERFIELD(Dev, LimitChecksEnable,
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/input/misc/vl53L0/src/vl53l010_api.c:87:7: note: expanded
      from macro 'VL53L010_GETARRAYPARAMETERFIELD'
                if (Status == VL53L0_ERROR_NONE) { \
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/input/misc/vl53L0/src/vl53l010_api.c:1427:24: note:
      uninitialized use occurs here
                *pLimitCheckEnable = Temp8;
                                     ^~~~~
drivers/input/misc/vl53L0/src/vl53l010_api.c:1425:3: note: remove
      the 'if' if its condition is always true
                VL53L010_GETARRAYPARAMETERFIELD(Dev, LimitChecksEnable,
                ^
drivers/input/misc/vl53L0/src/vl53l010_api.c:87:3: note: expanded
      from macro 'VL53L010_GETARRAYPARAMETERFIELD'
                if (Status == VL53L0_ERROR_NONE) { \
                ^
drivers/input/misc/vl53L0/src/vl53l010_api.c:1418:15: note:
      initialize the variable 'Temp8' to silence this warning
        uint8_t Temp8;
                     ^
                      = '\0'
drivers/input/misc/vl53L0/src/vl53l010_api.c:3875:2: error:
      variable 'xTalkCompRate_mcps' is used uninitialized whenever 'if'
      condition is false [-Werror,-Wsometimes-uninitialized]
        VL53L010_GETPARAMETERFIELD(Dev, XTalkCompensationRateMegaCps,
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/input/misc/vl53L0/src/vl53l010_api.c:78:7: note: expanded
      from macro 'VL53L010_GETPARAMETERFIELD'
                if (Status == VL53L0_ERROR_NONE) { \
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/input/misc/vl53L0/src/vl53l010_api.c:3882:23: note:
      uninitialized use occurs here
        xTalkCompRate_kcps = xTalkCompRate_mcps * 1000;
                             ^~~~~~~~~~~~~~~~~~
drivers/input/misc/vl53L0/src/vl53l010_api.c:3875:2: note: remove
      the 'if' if its condition is always true
        VL53L010_GETPARAMETERFIELD(Dev, XTalkCompensationRateMegaCps,
        ^
drivers/input/misc/vl53L0/src/vl53l010_api.c:78:3: note: expanded
      from macro 'VL53L010_GETPARAMETERFIELD'
                if (Status == VL53L0_ERROR_NONE) { \
                ^
drivers/input/misc/vl53L0/src/vl53l010_api.c:3844:35: note:
      initialize the variable 'xTalkCompRate_mcps' to silence this warning
        FixPoint1616_t xTalkCompRate_mcps;
                                         ^
                                          = 0
2 errors generated.

4 years agosched/completion: Avoid unnecessary stack allocation for COMPLETION_INITIALIZER_ONSTACK()
Boqun Feng [Wed, 23 Aug 2017 15:25:38 +0000 (23:25 +0800)]
sched/completion: Avoid unnecessary stack allocation for COMPLETION_INITIALIZER_ONSTACK()

In theory, COMPLETION_INITIALIZER_ONSTACK() should never affect the
stack allocation of the caller. However, on some compilers, a temporary
structure was allocated for the return value of
COMPLETION_INITIALIZER_ONSTACK().

For example in write_journal() with LOCKDEP_COMPLETIONS=y (GCC is 7.1.1):

io_comp.comp = COMPLETION_INITIALIZER_ONSTACK(io_comp.comp);
    2462:       e8 00 00 00 00          callq  2467 <write_journal+0x47>
    2467:       48 8d 85 80 fd ff ff    lea    -0x280(%rbp),%rax
    246e:       48 c7 c6 00 00 00 00    mov    $0x0,%rsi
    2475:       48 c7 c2 00 00 00 00    mov    $0x0,%rdx
x->done = 0;
    247c:       c7 85 90 fd ff ff 00    movl   $0x0,-0x270(%rbp)
    2483:       00 00 00
init_waitqueue_head(&x->wait);
    2486:       48 8d 78 18             lea    0x18(%rax),%rdi
    248a:       e8 00 00 00 00          callq  248f <write_journal+0x6f>
if (commit_start + commit_sections <= ic->journal_sections) {
    248f:       41 8b 87 a8 00 00 00    mov    0xa8(%r15),%eax
io_comp.comp = COMPLETION_INITIALIZER_ONSTACK(io_comp.comp);
    2496:       48 8d bd e8 f9 ff ff    lea    -0x618(%rbp),%rdi
    249d:       48 8d b5 90 fd ff ff    lea    -0x270(%rbp),%rsi
    24a4:       b9 17 00 00 00          mov    $0x17,%ecx
    24a9:       f3 48 a5                rep movsq %ds:(%rsi),%es:(%rdi)
if (commit_start + commit_sections <= ic->journal_sections) {
    24ac:       41 39 c6                cmp    %eax,%r14d
io_comp.comp = COMPLETION_INITIALIZER_ONSTACK(io_comp.comp);
    24af:       48 8d bd 90 fd ff ff    lea    -0x270(%rbp),%rdi
    24b6:       48 8d b5 e8 f9 ff ff    lea    -0x618(%rbp),%rsi
    24bd:       b9 17 00 00 00          mov    $0x17,%ecx
    24c2:       f3 48 a5                rep movsq %ds:(%rsi),%es:(%rdi)

We can obviously see the temporary structure allocated, and the compiler
also does two meaningless memcpy with "rep movsq".

And according to:

https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html#Statement-Exprs

The return value of a statement expression is returned by value, so the
temporary variable is created in COMPLETION_INITIALIZER_ONSTACK(), and
that's why the temporary structures are allocted.

To fix this, make the brace block in COMPLETION_INITIALIZER_ONSTACK()
return a pointer and dereference it outside the block rather than return
the whole structure, in this way, we are able to teach the compiler not
to do the unnecessary stack allocation.

This could also reduce the stack size even if !LOCKDEP, for example in
write_journal(), compiled with gcc 7.1.1, the result of command:

 objdump -d drivers/md/dm-integrity.o | ./scripts/checkstack.pl x86

before:

0x0000246a write_journal [dm-integrity.o]:              696

after:

0x00002b7a write_journal [dm-integrity.o]:              296

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Byungchul Park <byungchul.park@lge.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: walken@google.com
Cc: willy@infradead.org
Link: http://lkml.kernel.org/r/20170823152542.5150-3-boqun.feng@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Julian Liu <wlootlxt123@gmail.com>
[@wloot: backport to k4.4]

4 years agoarm64: arch_timer: Handle unexpected cases
Julian Liu [Sat, 20 Jul 2019 07:43:33 +0000 (15:43 +0800)]
arm64: arch_timer: Handle unexpected cases

4 years agokbuild: Enable -Wuninitialized
Nathan Chancellor [Fri, 14 Jun 2019 16:52:42 +0000 (09:52 -0700)]
kbuild: Enable -Wuninitialized

This helps fine very dodgy behavior through both -Wuninitialized
(warning that a variable is always uninitialized) and
-Wsometimes-uninitialized (warning that a variable is sometimes
uninitialized, like GCC's -Wmaybe-uninitialized). These warnings
catch things that GCC doesn't such as:

https://lore.kernel.org/lkml/86649ee4-9794-77a3-502c-f4cd10019c36@lca.pw/

We very much want to catch these so turn this warning on so that CI is
aware of it.

Link: https://github.com/ClangBuiltLinux/linux/issues/381
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
4 years agoarm64: Don't unconditionally add -Wno-psabi to KBUILD_CFLAGS
Nathan Chancellor [Tue, 11 Jun 2019 17:19:32 +0000 (10:19 -0700)]
arm64: Don't unconditionally add -Wno-psabi to KBUILD_CFLAGS

This is a GCC only option, which warns about ABI changes within GCC, so
unconditionally adding it breaks Clang with tons of:

warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]

and link time failures:

ld.lld: error: undefined symbol: __efistub___stack_chk_guard
>>> referenced by arm-stub.c:73
(/home/nathan/cbl/linux/drivers/firmware/efi/libstub/arm-stub.c:73)
>>>               arm-stub.stub.o:(__efistub_install_memreserve_table)
in archive ./drivers/firmware/efi/libstub/lib.a

These failures come from the lack of -fno-stack-protector, which is
added via cc-option in drivers/firmware/efi/libstub/Makefile. When an
unknown flag is added to KBUILD_CFLAGS, clang will noisily warn that it
is ignoring the option like above, unlike gcc, who will just error.

$ echo "int main() { return 0; }" > tmp.c

$ clang -Wno-psabi tmp.c; echo $?
warning: unknown warning option '-Wno-psabi' [-Wunknown-warning-option]
1 warning generated.
0

$ gcc -Wsometimes-uninitialized tmp.c; echo $?
gcc: error: unrecognized command line option
‘-Wsometimes-uninitialized’; did you mean ‘-Wmaybe-uninitialized’?
1

For cc-option to work properly with clang and behave like gcc, -Werror
is needed, which was done in commit c3f0d0bc5b01 ("kbuild, LLVMLinux:
Add -Werror to cc-option to support clang").

$ clang -Werror -Wno-psabi tmp.c; echo $?
error: unknown warning option '-Wno-psabi'
[-Werror,-Wunknown-warning-option]
1

As a consequence of this, when an unknown flag is unconditionally added
to KBUILD_CFLAGS, it will cause cc-option to always fail and those flags
will never get added:

$ clang -Werror -Wno-psabi -fno-stack-protector tmp.c; echo $?
error: unknown warning option '-Wno-psabi'
[-Werror,-Wunknown-warning-option]
1

This can be seen when compiling the whole kernel as some warnings that
are normally disabled (see below) show up. The full list of flags
missing from drivers/firmware/efi/libstub are the following (gathered
from diffing .arm64-stub.o.cmd):

-fno-delete-null-pointer-checks
-Wno-address-of-packed-member
-Wframe-larger-than=2048
-Wno-unused-const-variable
-fno-strict-overflow
-fno-merge-all-constants
-fno-stack-check
-Werror=date-time
-Werror=incompatible-pointer-types
-ffreestanding
-fno-stack-protector

Use cc-disable-warning so that it gets disabled for GCC and does nothing
for Clang.

Fixes: ebcc5928c5d9 ("arm64: Silence gcc warnings about arch ABI drift")
Link: https://github.com/ClangBuiltLinux/linux/issues/511
Reported-by: Qian Cai <cai@lca.pw>
Acked-by: Dave Martin <Dave.Martin@arm.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
[wight554: fix conflict]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agoarm64: Silence gcc warnings about arch ABI drift
Dave Martin [Thu, 6 Jun 2019 10:33:43 +0000 (11:33 +0100)]
arm64: Silence gcc warnings about arch ABI drift

Since GCC 9, the compiler warns about evolution of the
platform-specific ABI, in particular relating for the marshaling of
certain structures involving bitfields.

The kernel is a standalone binary, and of course nobody would be
so stupid as to expose structs containing bitfields as function
arguments in ABI.  (Passing a pointer to such a struct, however
inadvisable, should be unaffected by this change.  perf and various
drivers rely on that.)

So these warnings do more harm than good: turn them off.

We may miss warnings about future ABI drift, but that's too bad.
Future ABI breaks of this class will have to be debugged and fixed
the traditional way unless the compiler evolves finer-grained
diagnostics.

Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
[wight554: fix conflict]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agonet: socket: Use convoluted tricks to silence a GCC 9 error
Sultan Alsawaf [Thu, 27 Jun 2019 00:45:57 +0000 (17:45 -0700)]
net: socket: Use convoluted tricks to silence a GCC 9 error

GCC 9 is unhappy that we copy three struct's worth of data to a pointer
for a single struct. And it is rightfully unhappy, but net devs are
crazy and know better. Expand the pointer arithmetic bothering GCC to
make it shut up.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
4 years agomsm: mdss: Fix -Wmaybe-uninitialized warning
Yaroslav Furman [Fri, 24 Aug 2018 08:35:25 +0000 (11:35 +0300)]
msm: mdss: Fix -Wmaybe-uninitialized warning

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
4 years agodrivers: Fix more -Wmaybe-uninitialized warnings
Yaroslav Furman [Wed, 5 Sep 2018 07:45:00 +0000 (10:45 +0300)]
drivers: Fix more -Wmaybe-uninitialized warnings

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
4 years agoPM / devfreq: memlat: Fix -Wmaybe-uninitialized warning
Adam W. Willis [Sat, 15 Dec 2018 06:41:09 +0000 (01:41 -0500)]
PM / devfreq: memlat: Fix -Wmaybe-uninitialized warning

../drivers/devfreq/governor_memlat.c: In function 'devfreq_memlat_get_freq':
../drivers/devfreq/governor_memlat.c:258:20: warning: 'lat_dev' may be used uninitialized in this function [-Wmaybe-uninitialized]
      hw->core_stats[lat_dev].id,

Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
4 years agoqdsp6v2: fix -Wmaybe-uninitialized warning
Volodymyr Zhdanov [Sun, 16 Jun 2019 08:44:34 +0000 (11:44 +0300)]
qdsp6v2: fix -Wmaybe-uninitialized warning

4 years agoASoC: tas2559: Fix -Wmaybe-uninitialized warning
Volodymyr Zhdanov [Sun, 16 Jun 2019 08:35:13 +0000 (11:35 +0300)]
ASoC: tas2559: Fix -Wmaybe-uninitialized warning

4 years agoelliptic: fix -Wmaybe-uninitialized warning
Volodymyr Zhdanov [Sun, 16 Jun 2019 08:39:36 +0000 (11:39 +0300)]
elliptic: fix -Wmaybe-uninitialized warning

4 years agocamera_v2: ois: Fix -Wmaybe-uninitialized warning
Volodymyr Zhdanov [Sun, 16 Jun 2019 08:55:37 +0000 (11:55 +0300)]
camera_v2: ois: Fix -Wmaybe-uninitialized warning

4 years agosynaptics_dsx_force: Fix -Wmaybe-uninitialized warning
Volodymyr Zhdanov [Sun, 16 Jun 2019 08:47:31 +0000 (11:47 +0300)]
synaptics_dsx_force: Fix -Wmaybe-uninitialized warning

4 years agoANDROID: fix uninitilized variable
Wei Wang [Fri, 6 Jan 2017 23:30:33 +0000 (15:30 -0800)]
ANDROID: fix uninitilized variable

Currently we set CONFIG_CC_OPTIMIZE_FOR_SIZE which suppressed the compiler
warning of unused variables which can lead undefined behavior e.g. memory
corruption and panic. See https://lkml.org/lkml/2013/3/25/347.

This patch fixes all the uninitilized variables in kernel

Bug: 33353384
Test: On device
Signed-off-by: Wei Wang <wvw@google.com>
Change-Id: I0ae1082f447b435d71156d471878ba71aa16c378
[wight554: strip to apply over caf version]
Signed-off-by: Volodymyr Zhdanov <wight554@gmail.com>
4 years agocamera_v2: fix strlcpy-strlcat-size warnings
Vol Zhdanov [Sat, 30 Jun 2018 01:28:27 +0000 (01:28 +0000)]
camera_v2: fix strlcpy-strlcat-size warnings

Change-Id: I614817742966ce2161bd2a22ec174d023cada3cd