Commit Graph

1059423 Commits

Author SHA1 Message Date
Yifan Hong
b8323be61d ANDROID: kleaf: Explicit list of ABI files.
In BUILD.bazel, explicitly list abi_definition,
kmi_symbol_list, and additional_kmi_symbol_lists.
This avoids using the glob expression which may
accidentally match editor backup files.

Bug: 246344503
Test: TH
Change-Id: I8fbad63bf744672ba5b76b51cc908926d7b10849
Signed-off-by: Yifan Hong <elsk@google.com>
2022-09-19 22:34:09 +00:00
Masahiro Yamada
c3154ba8a5 UPSTREAM: kbuild: rename cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22}
GZIP-compressed files end with 4 byte data that represents the size
of the original input. The decompressors (the self-extracting kernel)
exploit it to know the vmlinux size beforehand. To mimic the GZIP's
trailer, Kbuild provides cmd_{bzip2,lzma,lzo,lz4,xzkern,zstd22}.
Unfortunately these macros are used everywhere despite the appended
size data is only useful for the decompressors.

There is no guarantee that such hand-crafted trailers are safely ignored.
In fact, the kernel refuses compressed initramdfs with the garbage data.
That is why usr/Makefile overrides size_append to make it no-op.

To limit the use of such broken compressed files, this commit renames
the existing macros as follows:

  cmd_bzip2   --> cmd_bzip2_with_size
  cmd_lzma    --> cmd_lzma_with_size
  cmd_lzo     --> cmd_lzo_with_size
  cmd_lz4     --> cmd_lz4_with_size
  cmd_xzkern  --> cmd_xzkern_with_size
  cmd_zstd22  --> cmd_zstd22_with_size

To keep the decompressors working, I updated the following Makefiles
accordingly:

  arch/arm/boot/compressed/Makefile
  arch/h8300/boot/compressed/Makefile
  arch/mips/boot/compressed/Makefile
  arch/parisc/boot/compressed/Makefile
  arch/s390/boot/compressed/Makefile
  arch/sh/boot/compressed/Makefile
  arch/x86/boot/compressed/Makefile

I reused the current macro names for the normal usecases; they produce
the compressed data in the proper format.

I did not touch the following:

  arch/arc/boot/Makefile
  arch/arm64/boot/Makefile
  arch/csky/boot/Makefile
  arch/mips/boot/Makefile
  arch/riscv/boot/Makefile
  arch/sh/boot/Makefile
  kernel/Makefile

This means those Makefiles will stop appending the size data.

I dropped the 'override size_append' hack from usr/Makefile.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nicolas Schier <n.schier@avm.de>

Bug: 135791357
(cherry picked from commit 7ce7e984ab2b218d6e92d5165629022fe2daf9ee
 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master)
Signed-off-by: SzuWei Lin <szuweilin@google.com>
Change-Id: I3f0ebdf13b2edb00fd405afdfacfe94e0e5fbee7
2022-09-17 11:54:24 +00:00
Alistair Delva
f3fcce16af ANDROID: GKI: Enable CONFIG_NULL_TTY by default
Because GKI has various serial drivers built in (8250, pl031, samsung,
sprd, geni) for earlycon, if they succeed probes for full functionality,
(such as if they are specified in DT as UART devices), the kernel would
unconditionally set up the first console device as the default console,
which is not generally desirable for production.

Enable CONFIG_NULL_TTY and enable "console=ttynull" by default. This
causes the kernel to always be silent unless a kernel console device is
explicitly specified on the cmdline. This has no effect on earlycon
"boot console" devices, just normal "console" devices.

Bug: 223797063
Change-Id: Id4cd0615bad79462f39397427380302b1904e42b
Signed-off-by: Alistair Delva <adelva@google.com>
2022-09-16 18:25:25 +00:00
Todd Kjos
ed8d3d91b9 ANDROID: fix build warning found by 0-day
The 0-day test-bot found this warning:

include/trace/hooks/thermal.h:16:25: warning: 'struct cpufreq_policy'
declared inside parameter list will not be visible outside of this
definition or declaration

Fixed by this patch.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: b3efd2ad71 ("ANDROID: remove inclusions from hook definition headers")
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I27d178f5056ab417b24eb14ca8dcb95f0d20cac7
2022-09-15 21:27:38 +00:00
Jone Chou
b5eedeaba6 ANDROID: kernel: add scmversion for debug_kinfo
Backup CONFIG_MODULE_SCMVERSION and scmversion offset.

Bug: 241477257
Signed-off-by: Jone Chou <jonechou@google.com>
Change-Id: If98f5c6d5014326ad2e07306a08571d1640d2c37
2022-09-15 10:26:50 +00:00
Yifan Hong
b0f8873811 ANDROID: kleaf: convert fips140 to kleaf
As a result of this change:

- fips140 is no longer part of the GKI build but a
  separate module, so it is not signed
  (CONFIG_MODULE_SIG_ALL is not set)

- GKI images (e.g. system_dlkm image, boot images)
  etc. are no longer part of the build -- because
  they are unnecessary.

- The build config no longer inherits from build.config.gki.aarch64
  directly to avoid building unnecessary system_dklm, boot images,
  GKI artifacts, etc.

Test: BUILD_CONFIG=common/build.config.gki.aarch64.fips140 build/build.sh
Test: tools/bazel build //common:fips140_dist
Bug: 232083350

Change-Id: I2cb0ee0b55c2a5ea46e6d73ecad4aa97585c1989
Signed-off-by: Yifan Hong <elsk@google.com>
2022-09-13 15:48:16 -07:00
Todd Kjos
b3efd2ad71 ANDROID: remove inclusions from hook definition headers
To avoid changing the visibiliy of data types when including
hook definition headers remove header file inclusions from
the hook definition header files.

Instead, the hook definition headers should just have forward
declarations that don't require full definition.

To provide full definitions of the types for the KMI, the
headers that define the types should be included by the
source file that instantiates the hooks - normally
vendor_hooks.c.

Bug: 233047575
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: Iaaa1a6f45a356569c04ad2fea0b1514e0454f041
2022-09-08 23:24:37 +00:00
Todd Kjos
b6dace455e ANDROID: subsystem-specific vendor_hooks.c for sched
Change how vendor hooks are instantiated to promote
more complete structure definition in the ABI XML
description without complicating hook definition for
partners.

We don't want to force partners to include all
headers as part of the hook definition in include/trace/hooks/
since that causes extra headers to be included in
source files that runs the risk of changing visibility
resulting in CRC changes to KMI symbols. Instead continue
the practice of using forward declarations in the hook
header files.

Instead of instantiating all hook tracepoints globally in
drivers/android/vendor_hooks.c, use subsystem-specific
vendor_hooks.c if inclusion of subsystem-specific
header files is required. This avoids namespace collisions
between internal header files and limits the exposure
to the internal headers to the instantiation, not the
call sites.

In this patch, all of the scheduler related hooks are
instantiated in kernel/sched/vendor_hooks.c which can
cleanly include scheduler-related header files to
provide full type visibility.

Bug: 233047575
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: Ife5a66c2968de73e3f6d05840411310611e2e175
2022-09-08 23:24:37 +00:00
Todd Kjos
4bc072dd20 ANDROID: remove CONFIG_TRACEPOINTS from hook definition headers
Remove the obsolete use of CONFIG_TRACEPOINTS in hook definition
header files. The !CONFIG_TRACEPOINTS case is correctly handled
by the included trace header files.

Bug: 233047575
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I957649bcfef375284f2885cf732ff2960c303837
2022-09-08 23:24:37 +00:00
Todd Kjos
5fdf33a8be Revert "ANDROID: arm64: smp: fix Lockdep warning: RCU used illegally from idle CPU."
This reverts commit 4af50419db.

Causes a build break for kernel_microdroid_aarch64 builds

Change-Id: I385a8e56ae1245bccba4d1b641175e73807da88b
Signed-off-by: Todd Kjos <tkjos@google.com>
2022-09-08 23:24:37 +00:00
Sumit Semwal
b87251d01e Revert "BACKPORT: FROMLIST: ext4: implement speculative fault handling"
This reverts commit a21ca34904.

Enabling SPF for ext4 breaks RB5 and DB845c testing on androidX-5.15
branches, causing vts-ltp tests to fail intermittently.

While this is debugged, let's disable SPF for ext4 to enable testing
meanwhile.

Bug: 245389404
Fixes: a21ca34904 ("FROMLIST: ext4: implement speculative fault handling")
Signed-off-by: Sumit Semwal <sumit.semwal@linaro.org>
Change-Id: Id8cf6e1548aef1db59cdeffbc1ee0b60affd76ea
2022-09-08 19:41:17 +00:00
Nathan Huckleberry
cdc43d45ee ANDROID: GKI: Enable HCTR2
HCTR2 is a wide-block encryption mode intended to solve a pre-existing
cryptographic weakness due to IV reuse in filename encryption.

Bug: 233652475
Change-Id: Ie1bcff8d61579a6b3e14418f280b97483b2dd670
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
2022-09-07 06:51:23 +00:00
Nathan Huckleberry
29fe3aa438 UPSTREAM: fscrypt: Add HCTR2 support for filename encryption
HCTR2 is a tweakable, length-preserving encryption mode that is intended
for use on CPUs with dedicated crypto instructions.  HCTR2 has the
property that a bitflip in the plaintext changes the entire ciphertext.
This property fixes a known weakness with filename encryption: when two
filenames in the same directory share a prefix of >= 16 bytes, with
AES-CTS-CBC their encrypted filenames share a common substring, leaking
information.  HCTR2 does not have this problem.

More information on HCTR2 can be found here: "Length-preserving
encryption with HCTR2": https://eprint.iacr.org/2021/1441.pdf

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Bug: 233652475
Link: https://lore.kernel.org/linux-arm-kernel/20220520181501.2159644-4-nhuck@google.com/T/
(cherry picked from commit 6b2a51ff03bf0c54cbc699ee85a9a49eb203ebfc)
Change-Id: Ie94df666c40388d100485c9ec05a734dc8fc3c23
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
2022-09-07 06:51:23 +00:00
Nathan Huckleberry
0f95eb505d UPSTREAM: crypto: arm64/polyval - Add PMULL accelerated implementation of POLYVAL
Add hardware accelerated version of POLYVAL for ARM64 CPUs with
Crypto Extensions support.

This implementation is accelerated using PMULL instructions to perform
the finite field computations.  For added efficiency, 8 blocks of the
message are processed simultaneously by precomputing the first 8
powers of the key.

Karatsuba multiplication is used instead of Schoolbook multiplication
because it was found to be slightly faster on ARM64 CPUs.  Montgomery
reduction must be used instead of Barrett reduction due to the
difference in modulus between POLYVAL's field and other finite fields.

More information on POLYVAL can be found in the HCTR2 paper:
"Length-preserving encryption with HCTR2":
https://eprint.iacr.org/2021/1441.pdf

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Bug: 233652475
Link: https://lore.kernel.org/linux-arm-kernel/20220520181501.2159644-4-nhuck@google.com/T/
(cherry picked from commit 9d2c0b485c46c7c5f781067c60300def5d1365cb)
Change-Id: Ifd07a5703529844d4cb2f9d270e7c4b474ebcf7f
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
2022-09-07 06:51:23 +00:00
Nathan Huckleberry
92f23b71ab UPSTREAM: crypto: x86/polyval - Add PCLMULQDQ accelerated implementation of POLYVAL
Add hardware accelerated version of POLYVAL for x86-64 CPUs with
PCLMULQDQ support.

This implementation is accelerated using PCLMULQDQ instructions to
perform the finite field computations.  For added efficiency, 8 blocks
of the message are processed simultaneously by precomputing the first
8 powers of the key.

Schoolbook multiplication is used instead of Karatsuba multiplication
because it was found to be slightly faster on x86-64 machines.
Montgomery reduction must be used instead of Barrett reduction due to
the difference in modulus between POLYVAL's field and other finite
fields.

More information on POLYVAL can be found in the HCTR2 paper:
"Length-preserving encryption with HCTR2":
https://eprint.iacr.org/2021/1441.pdf

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Bug: 233652475
Link: https://lore.kernel.org/linux-arm-kernel/20220520181501.2159644-4-nhuck@google.com/T/
(cherry picked from commit 34f7f6c3011276313383099156be287ac745bcea)
Change-Id: I18a532b8338e62ca7c85d8106ef22eeeab7b3355
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
2022-09-07 06:51:23 +00:00
Nathan Huckleberry
6b8e5c3cc2 UPSTREAM: crypto: arm64/aes-xctr - Improve readability of XCTR and CTR modes
Added some clarifying comments, changed the register allocations to make
the code clearer, and added register aliases.

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Bug: 233652475
Link: https://lore.kernel.org/linux-arm-kernel/20220520181501.2159644-4-nhuck@google.com/T/
(cherry picked from commit c0eb7591c1ed9cbdb0ad796bb56aed13748b55fa)
Change-Id: I173a03b39591efa5337c4f2c0a79bf32205df9fa
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
2022-09-07 06:51:23 +00:00
Nathan Huckleberry
b24b06a118 UPSTREAM: crypto: arm64/aes-xctr - Add accelerated implementation of XCTR
Add hardware accelerated version of XCTR for ARM64 CPUs with ARMv8
Crypto Extension support.  This XCTR implementation is based on the CTR
implementation in aes-modes.S.

More information on XCTR can be found in
the HCTR2 paper: "Length-preserving encryption with HCTR2":
https://eprint.iacr.org/2021/1441.pdf

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Bug: 233652475
Link: https://lore.kernel.org/linux-arm-kernel/20220520181501.2159644-4-nhuck@google.com/T/
(cherry picked from commit 23a251cc1696e1bf68df1dbba569d2fe12469d22)
Change-Id: Ia4df14e4a764cc428ac1fb41d0ee108f212812bb
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
2022-09-07 06:51:23 +00:00
Nathan Huckleberry
37915fdb0d UPSTREAM: crypto: x86/aesni-xctr - Add accelerated implementation of XCTR
Add hardware accelerated version of XCTR for x86-64 CPUs with AESNI
support.

More information on XCTR can be found in the HCTR2 paper:
"Length-preserving encryption with HCTR2":
https://eprint.iacr.org/2021/1441.pdf

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Bug: 233652475
Link: https://lore.kernel.org/linux-arm-kernel/20220520181501.2159644-4-nhuck@google.com/T/
(cherry picked from commit fd94fcf09957a75e25941f7dbfc84d30a63817ac)
Change-Id: I04bcbe4b1f5f63fc98f634b44651e1a621e5656e
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
2022-09-07 06:51:23 +00:00
Nathan Huckleberry
d672bb9c20 UPSTREAM: crypto: hctr2 - Add HCTR2 support
Add support for HCTR2 as a template.  HCTR2 is a length-preserving
encryption mode that is efficient on processors with instructions to
accelerate AES and carryless multiplication, e.g. x86 processors with
AES-NI and CLMUL, and ARM processors with the ARMv8 Crypto Extensions.

As a length-preserving encryption mode, HCTR2 is suitable for
applications such as storage encryption where ciphertext expansion is
not possible, and thus authenticated encryption cannot be used.
Currently, such applications usually use XTS, or in some cases Adiantum.
XTS has the disadvantage that it is a narrow-block mode: a bitflip will
only change 16 bytes in the resulting ciphertext or plaintext.  This
reveals more information to an attacker than necessary.

HCTR2 is a wide-block mode, so it provides a stronger security property:
a bitflip will change the entire message.  HCTR2 is somewhat similar to
Adiantum, which is also a wide-block mode.  However, HCTR2 is designed
to take advantage of existing crypto instructions, while Adiantum
targets devices without such hardware support.  Adiantum is also
designed with longer messages in mind, while HCTR2 is designed to be
efficient even on short messages.

HCTR2 requires POLYVAL and XCTR as components.  More information on
HCTR2 can be found here: "Length-preserving encryption with HCTR2":
https://eprint.iacr.org/2021/1441.pdf

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Bug: 233652475
Link: https://lore.kernel.org/linux-arm-kernel/20220520181501.2159644-4-nhuck@google.com/T/
(cherry picked from commit 7ff554ced7c7d7cf77586e07474e8633e011e2d0)
Change-Id: Ia97eaf73d2fe8176f20cf41cadf658fb4238269c
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
2022-09-07 06:51:23 +00:00
Nathan Huckleberry
e3efa8253b UPSTREAM: crypto: polyval - Add POLYVAL support
Add support for POLYVAL, an ε-Δ-universal hash function similar to
GHASH.  This patch only uses POLYVAL as a component to implement HCTR2
mode.  It should be noted that POLYVAL was originally specified for use
in AES-GCM-SIV (RFC 8452), but the kernel does not currently support
this mode.

POLYVAL is implemented as an shash algorithm.  The implementation is
modified from ghash-generic.c.

For more information on POLYVAL see:
Length-preserving encryption with HCTR2:
  https://eprint.iacr.org/2021/1441.pdf
AES-GCM-SIV: Nonce Misuse-Resistant Authenticated Encryption:
  https://datatracker.ietf.org/doc/html/rfc8452

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Bug: 233652475
Link: https://lore.kernel.org/linux-arm-kernel/20220520181501.2159644-4-nhuck@google.com/T/
(cherry picked from commit f3c923a09c4c4f5861b1ed53cf75673992a6ba68)
Change-Id: I7a7e177ecddaa103421b3b4e2d2f072e30e0c934
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
2022-09-07 06:51:23 +00:00
Nathan Huckleberry
0035442093 UPSTREAM: crypto: xctr - Add XCTR support
Add a generic implementation of XCTR mode as a template.  XCTR is a
blockcipher mode similar to CTR mode.  XCTR uses XORs and little-endian
addition rather than big-endian arithmetic which has two advantages:  It
is slightly faster on little-endian CPUs and it is less likely to be
implemented incorrect since integer overflows are not possible on
practical input sizes.  XCTR is used as a component to implement HCTR2.

More information on XCTR mode can be found in the HCTR2 paper:
https://eprint.iacr.org/2021/1441.pdf

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Bug: 233652475
Link: https://lore.kernel.org/linux-arm-kernel/20220520181501.2159644-4-nhuck@google.com/T/
(cherry picked from commit 17fee07a2ac577da18b44dd658a9c3c864281c49)
Change-Id: Idb978c32cfbe646c22b35798e1dfb01f8e08e5fd
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
2022-09-07 06:51:23 +00:00
Mark Brown
577972f821 UPSTREAM: arm64: Add macro version of the BTI instruction
BTI is only available from v8.5 so we need to encode it using HINT in
generic code and for older toolchains. Add an assembler macro based on
one written by Mark Rutland which lets us use the mnemonic and update
the existing users.

Suggested-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Will Deacon <will@kernel.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20211214152714.2380849-2-broonie@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 233652475
Link: https://lore.kernel.org/all/20211214152714.2380849-1-broonie@kernel.org/
(cherry picked from commit 9be34be87cc8d1afe3c3bc2e645b4dee512d9eda)
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Change-Id: I961472f606d6eb34f49832b96f69e2156419da79
2022-09-07 06:51:23 +00:00
Ard Biesheuvel
83e85a9c35 UPSTREAM: crypto: arm64/aes-neon-ctr - improve handling of single tail block
Instead of falling back to C code to do a memcpy of the output of the
last block, handle this in the asm code directly if possible, which is
the case if the entire input is longer than 16 bytes.

Cc: Nathan Huckleberry <nhuck@google.com>
Cc: Eric Biggers <ebiggers@google.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Bug: 233652475
Link: https://lore.kernel.org/all/Yf39x1mHvRsM1jvi@gondor.apana.org.au/
(cherry picked from commit 8daa399edeed4cfa792ccea12beda50d445ab6a0)
Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Change-Id: I0e3410783af6ec18e1143d88bba379ce2fddd2d4
2022-09-07 06:51:23 +00:00
Ulises Mendez Martinez
b856e6cf38 ANDROID: Convert db845c to a mixed build.
* This means using GKI[0] artifacts as base for the kernel.

[0] https://source.android.com/docs/core/architecture/kernel/generic-kernel-image#fragmentation-fix-gki

* It was initially submitted as part of https://r.android.com/q/topic:db845c_mixed_build but then reverted in https://r.android.com/q/topic:revert-2188970-db845c_mixed_build-YESQWWKQCV

* https://android-review.googlesource.com/c/kernel/common/+/2203435 fixes the previous reason for reverting, making it safe to submit it again.

Bug: 233404531
Signed-off-by: Ulises Mendez Martinez <umendez@google.com>
Change-Id: I18813d34b4b7f9de54c334e47c6478ff235cf37f
2022-09-06 23:21:51 +00:00
Yifan Hong
b4201bbc98 ANDROID: kleaf: Do not include GKI modules in default output of //common:kernel_aarch64.
When a device kernel builds their own modules that
conflicts with the GKI modules (zram and zsmalloc
for android13-5.15), the dist target will produce a
warning about conflicting source files.

Hence, do not include zram and zsmalloc to the device
dist targets by default when they include //common:kernel_aarch64
only.

If they wish to include zram and zsmalloc in
the distribution on the android13-5.15 branch,
they may add the following to the
dist target:

  "//common:kernel_aarch64_modules",

or individual modules:

  "//common:kernel_aarch64/drivers/block/zram/zram.ko",
  "//common:kernel_aarch64/mm/zsmalloc.ko",

//common:kernel_aarch64_dist continues to include GKI
modules defined by the branch.

Bug: 244215515
Test: manual
Change-Id: Iae701d7d452e6ed3a849fdfd03550551ca2af17e
Signed-off-by: Yifan Hong <elsk@google.com>
2022-09-02 21:24:41 +00:00
Will McVicker
bac79d727a BACKPORT: FROMGIT: PCI: dwc: Add support for 64-bit MSI target address
Since not all devices require a 32-bit MSI address, add support to the
PCIe host driver to allow setting the DMA mask to 64-bits if the 32-bit
allocation fails. This allows kernels to disable ZONE_DMA32 and bounce
buffering (swiotlb) without risking not being able to get a 32-bit
address during DMA allocation.

Basically, in the slim chance that there are no 32-bit allocations
available, the current PCIe host driver will fail to allocate the
msi_msg page due to a DMA address overflow (seen in [1]). With this
patch, the PCIe host can retry the allocation with a 64-bit DMA mask if
the current PCIe device advertises 64-bit support via its MSI
capabilities.

[1] https://lore.kernel.org/all/Yo0soniFborDl7+C@google.com/

Bug: 241473543
Link: https://lore.kernel.org/r/20220825235404.4132818-3-willmcvicker@google.com
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
Change-Id: I8936717b26f3dec453b0a944b26a0bb891905100
(cherry picked from commit e99d8c5e803b9a9f0b5a84165dad3b8895446147 https://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/pci.git pci/dwc)
2022-08-30 16:43:20 +00:00
Will McVicker
c7d5479460 BACKPORT: FROMGIT: PCI: dwc: Drop dependency on ZONE_DMA32
Re-work the msi_msg DMA allocation logic to use dmam_alloc_coherent()
which uses the coherent DMA mask to try to return an allocation within
the DMA mask limits. With that, we now can drop the msi_page parameter
in struct dw_pcie_rp. This allows kernel configurations that disable
ZONE_DMA32 to continue supporting a 32-bit DMA mask. Without this patch,
the PCIe host device will fail to probe when ZONE_DMA32 is disabled.

Bug: 241473543
Link: https://lore.kernel.org/r/20220825235404.4132818-2-willmcvicker@google.com
Fixes: 35797e672ff0 ("PCI: dwc: Fix MSI msi_msg DMA mapping")
Reported-by: Isaac J. Manjarres <isaacmanjarres@google.com>
Signed-off-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
Change-Id: Ib76ffe9d90743a09c633e9f39428403aabd983e3
(cherry picked from commit 423511ec23e2a6fa7830ed76b0283268e795d09d https://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/pci.git pci/dwc)
2022-08-30 16:43:16 +00:00
Will McVicker
c126f1fdc0 UPSTREAM: PCI: dwc: Fix MSI msi_msg DMA mapping
As of 07940c369a ("PCI: dwc: Fix MSI page leakage in suspend/resume"),
the PCIe designware host driver has been using the driver data
allocation for the msi_msg DMA mapping which can result in
a DMA_MAPPING_ERROR due to the DMA overflow check in
dma_direct_map_page() when the address is greater than 32 bits (reported
in [1]). The commit was trying to address a memory leak on
suspend/resume by moving the MSI mapping to dw_pcie_host_init(), but
subsequently dropped the page allocation thinking it wasn't needed.

To fix the DMA mapping issue as well as make msi_msg DMA'able, switch
back to allocating a 32-bit page for the msi_msg. To avoid the
suspend/resume leak, allocate the page in dw_pcie_host_init() since that
shouldn't be called during suspend/resume.

[1] https://lore.kernel.org/all/Yo0soniFborDl7+C@google.com/

Signed-off-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Rob Herring <robh@kernel.org>
Change-Id: I48f48d069ff27a391cf0043bc23cfe4ac8c32593
(cherry picked from commit 35797e672ff0610224d80e3cc08393fef1032f9a)
2022-08-30 16:43:08 +00:00
Alistair Delva
374734b63a Revert "ANDROID: GCE: To build kernel image for gce cloud android."
This reverts commit d1d3f4a801.

Moving this into common-modules/virtual-device.

Bug: 195791462
Change-Id: Ia83e8d28a47f303044ff7102edc27eeb512e1dc4
Signed-off-by: Alistair Delva <adelva@google.com>
2022-08-25 16:39:04 +00:00
Youngmin Nam
5bd34b3c34 UPSTREAM: time: Correct the prototype of ns_to_kernel_old_timeval and ns_to_timespec64
In ns_to_kernel_old_timeval() definition, the function argument is defined
with const identifier in kernel/time/time.c, but the prototype in
include/linux/time32.h looks different.

- The function is defined in kernel/time/time.c as below:
  struct __kernel_old_timeval ns_to_kernel_old_timeval(const s64 nsec)

- The function is decalared in include/linux/time32.h as below:
  extern struct __kernel_old_timeval ns_to_kernel_old_timeval(s64 nsec);

Because the variable of arithmethic types isn't modified in the calling scope,
there's no need to mark arguments as const, which was already mentioned during
review (Link[1) of the original patch.

Likewise remove the "const" keyword in both definition and declaration of
ns_to_timespec64() as requested by Arnd (Link[2]).

Fixes: a84d116916 ("y2038: Introduce struct __kernel_old_timeval")
Signed-off-by: Youngmin Nam <youngmin.nam@samsung.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/all/20220712094715.2918823-1-youngmin.nam@samsung.com
Link[1]: https://lore.kernel.org/all/20180310081123.thin6wphgk7tongy@gmail.com/
Link[2]: https://lore.kernel.org/all/CAK8P3a3nknJgEDESGdJH91jMj6R_xydFqWASd8r5BbesdvMBgA@mail.gmail.com/
(cherry picked from commit 46dae32fe625a75f549c3a70edc77b778197bb05)
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: I223421667b583168d4ce95ec1af2f76fef9fcf3d
2022-08-24 14:01:38 -07:00
Will McVicker
f1dff22d6b ANDROID: Revert "perf/core: Use static_call to optimize perf_guest_info_callbacks"
This reverts commit 6590d00bbd. When
booting with the Pixel 6, I hit the below CFI failure. An email ([1])
was sent upstream to address this issue.

  Kernel panic - not syncing: CFI failure (target: __static_call_return0+0x0/0x8)
  CPU: 0 PID: 1625 Comm: batterystats-wo Tainted: G        W  OE     5.16.0-mainline #1$
  Hardware name: Raven EVT 1.1 (DT)$
  Call trace:$
   dump_backtrace+0xf0/0x130$
   show_stack+0x1c/0x2c$
   dump_stack_lvl+0x68/0x98$
   panic+0x168/0x420$
   __cfi_check_fail+0x58/0x5c$
   __cfi_slowpath_diag+0x150/0x1a4$
   perf_misc_flags+0x74/0xa4$
   perf_prepare_sample+0x50/0x44c$
   perf_event_output_forward+0x5c/0xcc$
   __perf_event_overflow+0xc8/0x188$
   perf_swevent_event+0x7c/0x10c$
   perf_tp_event+0x168/0x298$
   perf_trace_run_bpf_submit+0x8c/0xdc$
   perf_trace_sched_switch+0x180/0x1cc$
   __schedule+0x850/0x924$
   schedule+0x98/0xe0$
   binder_wait_for_work+0x158/0x368$
   binder_thread_read+0x278/0x243c$
   binder_ioctl_write_read+0x120/0x45c$
   binder_ioctl+0x1ac/0xc34$
   __arm64_sys_ioctl+0xa8/0x118$
   invoke_syscall+0x64/0x178$
   el0_svc_common+0x8c/0x100$
   do_el0_svc+0x28/0xa0$
   el0_svc+0x24/0x84$
   el0t_64_sync_handler+0x88/0xec$
   el0t_64_sync+0x1b4/0x1b8$

[1] https://lore.kernel.org/all/YfrQzoIWyv9lNljh@google.com/

Bug: 217583980
Bug: 233587962
Bug: 233588291
Signed-off-by: Will McVicker <willmcvicker@google.com>
Signed-off-by: Will Deacon <willdeacon@google.com>
Change-Id: I2951676ca4cce5e55461a71a670b35f9af41ba4e
(cherry picked from commit a82e2e9f9ab649b62693a3d4dae7b617ff2be3ee)
2022-08-24 08:36:45 +00:00
Ulises Mendez Martinez
cd68e142bc Revert "ANDROID: Convert db845c to a mixed build."
Revert "ANDROID: Convert db845c to a mixed build."

Revert submission 2188970-db845c_mixed_build

Reason for revert: It breaks android-mainline
Reverted Changes:
I6cfb1ef19:ANDROID: Convert db845c to a mixed build.
I6680cb8ef:kleaf: Convert db845c to a mixed build.
I6cfb1ef19:ANDROID: Convert db845c to a mixed build.

Signed-off-by: Ulises Mendez Martinez <umendez@google.com>
Change-Id: I0b7b411d2e5cf13aff257b5827479d20092f2b3b
2022-08-23 23:34:04 +00:00
Daniil Lunev
81358a88ed FROMGIT: scsi: ufs: core: Read device property for ref clock
UFS storage devices require bRefClkFreq attribute to be set to operate
correctly at high speed mode. The necessary value is determined by what the
SoC / board supports. The standard doesn't specify a method to query the
value, so the information needs to be fed in separately.

DT information feeds into setting up the clock framework, so platforms
using DT can get the UFS reference clock frequency from the clock
framework. A special node "ref_clk" from the clock array for the UFS
controller node is used as the source for the information.

On the platforms that do not use DT (e.g. Intel), the alternative mechanism
to feed the intended reference clock frequency is necessary. Specifying the
necessary information in DSD of the UFS controller ACPI node is an
alternative mechanism proposed in this patch. Those can be accessed via
firmware property facility in the kernel and in many ways simillar to
querying properties defined in DT.

This patch introduces a small helper function to query a predetermined ACPI
supplied property of the UFS controller, and uses it to attempt retrieving
reference clock value, unless that was already done by the clock
infrastructure.

Link: https://lore.kernel.org/r/20220715210230.1.I365d113d275117dee8fd055ce4fc7e6aebd0bce9@changeid
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Daniil Lunev <dlunev@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit ca452621b82916a81ea0f10f9f0158815f3365d0 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: Ifbc20404d72b7a1bbc49fe0652657f397418c055
2022-08-23 20:05:49 +00:00
Keoseong Park
c8ee23337d FROMGIT: scsi: ufs: core: Remove UIC_HIBERN8_ENTER_RETRIES
Commit 4db7a23605 ("scsi: ufs: Fix concurrency of error handler and other
error recovery paths") removed all callers of UIC_HIBERN8_ENTER_RETRIES.
Hence also remove the macro itself.

Link: https://lore.kernel.org/r/20220708052006epcms2p2d1129dbf95fd77f46906200ccb0a9ccd@epcms2p2
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Keoseong Park <keosung.park@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit c641ffdb5904df0dc249ef3f2d753e2a684779c6 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I130f65e1b6170b7e8ca0d02270bcf6fdbe4e0b0c
2022-08-23 20:05:49 +00:00
Chanho Park
60c7fdd92b FROMGIT: scsi: ufs: ufs-exynos: Change ufs phy control sequence
Since commit 1599069a62c6 ("phy: core: Warn when phy_power_on is called
before phy_init"), the following warning has been reported:

	phy_power_on was called before phy_init

To address this, we need to remove phy_power_on from exynos_ufs_phy_init()
and move it after phy_init. phy_power_off and phy_exit are also necessary
in exynos_ufs_remove().

Link: https://lore.kernel.org/r/20220706020255.151177-4-chanho61.park@samsung.com
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 3d73b200f9893d8f5ba5d105e8b69c8d16744fa2 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I4bbb4c05281e7a07ae8860b8a53a3dcca1e94d9d
2022-08-23 20:05:49 +00:00
Junwoo Lee
5272a9f259 FROMGIT: scsi: ufs: Skip last hci reset to get valid register values
Once the host link startup fails 3 times, all host registers are reset to
default values except in ufshcd_hba_enable().

The ufs host controller is disabled and enabled in ufshcd_hba_enable().
Consequently we need to skip last hci reset to get valid host register
values.

e.g.
[    1.898026] [2:  kworker/u16:2:  211] ufs: link startup failed 1
[    1.898133] [2:  kworker/u16:2:  211] host_regs: 00000000: 1383ff1f 00000000 00000300 00000000
[    1.898141] [2:  kworker/u16:2:  211] host_regs: 00000010: 00000106 000001ce 00000000 00000000
[    1.898148] [2:  kworker/u16:2:  211] host_regs: 00000020: 00000000 00000470 00000000 00000000
[    1.898155] [2:  kworker/u16:2:  211] host_regs: 00000030: 00000008 00000003 00000000 00000000
[    1.898163] [2:  kworker/u16:2:  211] host_regs: 00000040: 00000000 00000000 00000000 00000000
[    1.898171] [2:  kworker/u16:2:  211] host_regs: 00000050: 00000000 00000000 00000000 00000000
[    1.898177] [2:  kworker/u16:2:  211] host_regs: 00000060: 00000000 00000000 00000000 00000000
[    1.898186] [2:  kworker/u16:2:  211] host_regs: 00000070: 00000000 00000000 00000000 00000000
[    1.898194] [2:  kworker/u16:2:  211] host_regs: 00000080: 00000000 00000000 00000000 00000000
[    1.898201] [2:  kworker/u16:2:  211] host_regs: 00000090: 00000000 00000000 00000000 00000000

Link: https://lore.kernel.org/r/20220705083538.15143-1-sh043.lee@samsung.com
Reviewed-by: Avri Altman <avri.altman@wdc.com>
Signed-off-by: Junwoo Lee <junwoo80.lee@samsung.com>
Signed-off-by: Seunghui Lee <sh043.lee@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 174e909b5435d3f840067f36c4915a618d44b6bb git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I067a63c91abf8c952c4fc8a6d2bef458a4e76b35
2022-08-23 20:05:49 +00:00
Daniil Lunev
71c0524526 FROMGIT: scsi: ufs: ufs-pci: Enable WriteBooster capability on ADL
Sets the WriteBooster capability flag when ADL's UFS controller is used.

Link: https://lore.kernel.org/r/20220705165316.v2.1.Ib5ebec952d9a59f5c69c89b694777f517d22466d@changeid
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Daniil Lunev <dlunev@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 1466b3bc456a04c2eecb639d303b91ca8ef02c33 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I902487250d0828f1ae4ec1cc5acc074283d3a4c6
2022-08-23 20:05:49 +00:00
ChanWoo Lee
b90a73a401 FROMGIT: scsi: ufs: ufs-qcom: Remove unneeded code
Checks information about tx_lanes, but is not used.

Since commit 1e1e465c6d ("scsi/ufs: qcom: Remove ufs_qcom_phy_*() calls
from host"), tx_lanes is deprecated.

As a result, ufs_qcom_link_startup_notify -> POST_CHANGE action does
nothing.  If it is not going to be updated, it can be removed.

Link: https://lore.kernel.org/r/20220627235545.16943-1-cw9316.lee@samsung.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: ChanWoo Lee <cw9316.lee@samsung.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit bcec04b3cce4c498ef0d416a3a2aaf0369578151 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I5e0f2daf8506d4798f13091fd7e48976285fe023
2022-08-23 20:05:49 +00:00
Alice Chao
3d7f8111b8 FROMGIT: scsi: ufs: ufs-mediatek: Fix invalid access to vccqx
NULL pointer access issue was found for the regulator released
by ufs_mtk_vreg_fix_vccq(). Simply fix this issue by clearing
the released vreg pointer in ufs_hba struct.

Link: https://lore.kernel.org/r/20220623035052.18802-9-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Alice Chao <alice.chao@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit df1ea242e3d702342fd0c7c1a7b9ed6838645a05 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I572b4ff8a625c2309eb5d050e2c0b5bae882af7d
2022-08-23 20:05:49 +00:00
Peter Wang
946bad208c FROMGIT: scsi: ufs: ufs-mediatek: Support performance boosting
Add pm-qos request to support performance boosting in MediaTek UFS
platforms.

At the same time, adjust the order of function calls to be symmetric during
the low-power control flow.

Link: https://lore.kernel.org/r/20220623035052.18802-8-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit c64c487d953331df239cf866d178612796e59f93 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: Ia78b48922f6933a7c194fd2b13e059b72dd84a8c
2022-08-23 20:05:49 +00:00
Po-Wen Kao
0de9c3925b FROMGIT: scsi: ufs: ufs-mediatek: Support host power control
Add interfaces for controlling the host power to optimize the power
consumption in MediaTek UFS platforms.

Link: https://lore.kernel.org/r/20220623035052.18802-7-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 2cf5cb2bb13140ecc0f01ebc8844ee8b5203293f git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I2213ba03ead7852c0b35fa8dcdf6403861b9cd44
2022-08-23 20:05:49 +00:00
Po-Wen Kao
b208eb5f34 FROMGIT: scsi: ufs: ufs-mediatek: Disable reset confirm feature by UniPro
In MediaTek UFS platforms, UniPro will not return reset confirm if it is in
POWERDOWN state thus hang issue may happen while disabling UFSHCI. Simply
disable this feature before UniPro leaves POWERDOWN state.

Link: https://lore.kernel.org/r/20220623035052.18802-6-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Po-Wen Kao <powen.kao@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 4918694ccd6974f3ec8eeda3f34ace0ce480153e git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I071c730b557ca5daca39ecb8f314eb62cc21409d
2022-08-23 20:05:49 +00:00
Peter Wang
84b0ffaa5a FROMGIT: scsi: ufs: ufs-mediatek: Add stage information for ref-clk control
Add "PRE_CHANGE" and "POST_CHANGE" information for ref-clk control to
precisely configure the low-power state of the parent of ref-clk.

Link: https://lore.kernel.org/r/20220623035052.18802-5-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit f53f19135765780f93dd0c9506a138d1b27ffd0e git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I762d0faf603bc991eff89280909976e127c73b08
2022-08-23 20:05:49 +00:00
Peter Wang
7bf7b500bf FROMGIT: scsi: ufs: ufs-mediatek: Prevent host hang by setting CLK_CG early
Some UFSHCI hosts in MediaTek UFS platform need workaround to prevent host
hang issue by setting CLK_CG bit before host is enabled.

This operation shall have no side effect on those platforms which do not
support this bit.

Link: https://lore.kernel.org/r/20220623035052.18802-4-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 2bae03a6ac985fe80a7a228af3bcc2d5dbe43381 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I1250357f44930a75f9873ae064cbfdfbb365fe64
2022-08-23 20:05:49 +00:00
Peter Wang
ee2bbb6f58 FROMGIT: scsi: ufs: ufs-mediatek: Always add delays for VCC operations
MediaTek decides to always add delays before and after VCC is turned-off.

Link: https://lore.kernel.org/r/20220623035052.18802-3-stanley.chu@mediatek.com
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Peter Wang <peter.wang@mediatek.com>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 981b4ac04c2f7c24724d3b3a62c3d0c2fc9adcb7 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: Idef45e4929df7463fe390cc4cc6a5aaf6f740efa
2022-08-23 20:05:49 +00:00
Stanley Chu
51c5b779dd FROMGIT: scsi: ufs: ufs-mediatek: Fix build warnings
Fix build warnings:

1.
../drivers/ufs/host/ufs-mediatek.c:1375:5: error: no previous prototype for function 'ufs_mtk_system_suspend' [-Werror,-Wmissing-prototypes]
int ufs_mtk_system_suspend(struct device *dev)
    ^
../drivers/ufs/host/ufs-mediatek.c:1375:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
int ufs_mtk_system_suspend(struct device *dev)
^
static

2.
../drivers/ufs/host/ufs-mediatek.c:702:50: error: format specifies type 'unsigned long' but the argument has type 'int' [-Werror,-Wformat]
                snprintf(vcc_name, MAX_VCC_NAME, "vcc-ufs%lu", ver);
                                                         ~~~   ^~~
                                                         %d

Link: https://lore.kernel.org/r/20220623035052.18802-2-stanley.chu@mediatek.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit e7bf1d50063ce0dcae84ddbd27531a3ecec59e28 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: Id57c619219f48dde266be7fceaece0b0085d827d
2022-08-23 20:05:49 +00:00
Krzysztof Kozlowski
99c65150e2 FROMGIT: scsi: ufs: ufshcd: Constify pointed data
For code safety, constify arrays and pointers to data which is not
modified.

Link: https://lore.kernel.org/r/20220623102432.108059-4-krzysztof.kozlowski@linaro.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 35d11ec239e0996291b140a61a677210ff854f11 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
[ bvanassche: Extended this patch to the Android tracing statements ]
Change-Id: I457fc0998c1fc194834ae8095d897167a3e8ca94
Signed-off-by: Bart Van Assche <bvanassche@google.com>
2022-08-23 20:05:49 +00:00
Krzysztof Kozlowski
cd93a51c37 FROMGIT: scsi: ufs: ufshcd-pltfrm: Constify pointed data
For code safety, constify pointers to data which is not modified.

Link: https://lore.kernel.org/r/20220623102432.108059-3-krzysztof.kozlowski@linaro.org
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit a48aac5dfc1bab0ed601e05a9447f675b17db91c git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I989ce33ea43ab99f041e99fdbd62f0f95dd271df
2022-08-23 20:05:49 +00:00
Wolfram Sang
d48e6713fc FROMGIT: scsi: ufs: core: Fix typos in error messages
Should be "retries" instead of "retires".

Link: https://lore.kernel.org/r/20220621144653.62630-1-wsa+renesas@sang-engineering.com
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit 82ede9c19839079e7953a47895729852a440080c git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: Ib83197e3d13ae8d04f6d1c0e2ef105bbd9872257
2022-08-23 20:05:49 +00:00
Ren Zhijie
8a6f9e7bef FROMGIT: scsi: ufs: ufs-mediatek: Fix build error and type mismatch
If CONFIG_PM_SLEEP is not set.

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu-, will fail:

drivers/ufs/host/ufs-mediatek.c: In function ‘ufs_mtk_vreg_fix_vcc’:
drivers/ufs/host/ufs-mediatek.c:688:46: warning: format ‘%u’ expects argument of type ‘unsigned int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
    snprintf(vcc_name, MAX_VCC_NAME, "vcc-opt%u", res.a1);
                                             ~^   ~~~~~~
                                             %lu
drivers/ufs/host/ufs-mediatek.c: In function ‘ufs_mtk_system_suspend’:
drivers/ufs/host/ufs-mediatek.c:1371:8: error: implicit declaration of function ‘ufshcd_system_suspend’; did you mean ‘ufs_mtk_system_suspend’? [-Werror=implicit-function-declaration]
  ret = ufshcd_system_suspend(dev);
        ^~~~~~~~~~~~~~~~~~~~~
        ufs_mtk_system_suspend
drivers/ufs/host/ufs-mediatek.c: In function ‘ufs_mtk_system_resume’:
drivers/ufs/host/ufs-mediatek.c:1386:9: error: implicit declaration of function ‘ufshcd_system_resume’; did you mean ‘ufs_mtk_system_resume’? [-Werror=implicit-function-declaration]
  return ufshcd_system_resume(dev);
         ^~~~~~~~~~~~~~~~~~~~
         ufs_mtk_system_resume
cc1: some warnings being treated as errors

The declaration of func "ufshcd_system_suspend()" depends on
CONFIG_PM_SLEEP, so the function wrapper ufs_mtk_system_suspend() should
wrapped by CONFIG_PM_SLEEP too.

Link: https://lore.kernel.org/r/20220619115432.205504-1-renzhijie2@huawei.com
Fixes: 3fd23b8dfb54 ("scsi: ufs: ufs-mediatek: Fix the timing of configuring device regulators")
Reported-by: Hulk Robot <hulkci@huawei.com>
Reviewed-by: Stanley Chu <stanley.chu@mediatek.com>
Signed-off-by: Ren Zhijie <renzhijie2@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
(cherry picked from commit f54912b228a8df6c0133e31bc75628677bb8c6e5 git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next)
Bug: 239946304
Signed-off-by: Bart Van Assche <bvanassche@google.com>
Change-Id: I6fcd2d3c4f88bea6d103a2adfb3c6e9d2d27c64d
2022-08-23 20:05:49 +00:00