Commit Graph

979772 Commits

Author SHA1 Message Date
Greg Kroah-Hartman
b1a6760ddf Merge branch 'android12-5.10' into android12-5.10-lts
Sync up with android12-5.10 for the following commits:

dd139186ef ANDROID: usb: gadget: fix NULL pointer dereference in android_setup
07f65598af ANDROID: GKI: Disable kmem cgroup accounting
309aa7e7a2 FROMLIST: mm, memcg: inline swap-related functions to improve disabled memcg config
3ae8e2f183 BACKPORT: FROMLIST: mm, memcg: inline mem_cgroup_{charge/uncharge} to improve disabled memcg config
f73d029485 FROMLIST: mm, memcg: add mem_cgroup_disabled checks in vmpressure and swap-related functions
669df367a9 UPSTREAM: mm/memcg: bail early from swap accounting if memcg disabled
1f0c32a667 UPSTREAM: procfs/dmabuf: add inode number to /proc/*/fdinfo
0c8c125f57 UPSTREAM: procfs: allow reading fdinfo with PTRACE_MODE_READ
2e0476a465 Revert "FROMLIST: procfs: Allow reading fdinfo with PTRACE_MODE_READ"
5ded961aa2 Revert "FROMLIST: BACKPORT: procfs/dmabuf: Add inode number to /..."
3ee5565017 UPSTREAM: f2fs: initialize page->private when using for our internal use
dba79c3af3 ANDROID: mm: page_pinner: report test_page_isolation_failure
13362ab28e ANDROID: mm: page_pinner: add state of page_pinner
3254948484 ANDROID: mm: page_pinner: add more struct page fields
0445b67bee ANDROID: mm: page_pinner: change timestamp format
71da06728c ANDROID: mm: page_pinner: print_page_pinner refactoring
b83e564914 ANDROID: mm: page_pinner: remove shared_count
849f048050 ANDROID: mm: page_pinner: remove WARN_ON_ONCE
9a453100fc ANDROID: mm: page_pinner: fix typos
d012783a86 ANDROID: mm: page_pinner: reset migration failed page
470cce5085 ANDROID: mm: page_pinner: record every put_page
9f47e5fdda ANDROID: mm: page_pinner: change function names
a8385d61f2 ANDROID: Allow vendor module to reclaim a memcg
f41a95eadc ANDROID: Export memcg functions to allow module to add new files
46bf3b94e7 FROMGIT: dt-bindings: usb: dwc3: Update dwc3 TX fifo properties
b36b813e39 UPSTREAM: dt-bindings: usb: Convert DWC USB3 bindings to DT schema
9a80b7b728 FROMGIT: of: Add stub for of_add_property()
2742be5903 ANDROID: fips140: define fips_enabled to 1 to enable FIPS behavior
e886dd4c33 ANDROID: fips140: unregister existing DRBG algorithms
634445a640 ANDROID: fips140: fix deadlock in unregister_existing_fips140_algos()
0af06624ea ANDROID: fips140: check for errors from initcalls
92de53472e ANDROID: fips140: log already-live algorithms
0a7da21583 ANDROID: Update new mtk gki symbol
98085b5dd8 ANDROID: usb: Add vendor hook for usb suspend and resume
956db89e71 BACKPORT: FROMLIST: dma-heap: Let dma heap use dma_map_attrs to map & unmap iova
749d6e7f2c ANDROID: abi_gki_aarch64_qcom: Add vendor hook for shmem_alloc_page
b05bbe48be ANDROID: abi_gki_aarch64_qcom: Add reclaim_shmem_address_space
d80c70d7a8 ANDROID: android: export kernel function arch_mmap_rnd
25c7eb4932 ANDROID: mm: shmem: Fix build break with allnoconfig
1cdcf76b15 ANDROID: vendor_hooks: add hooks in mem_cgroup subsystem
726468dd4a ANDROID: GKI: add vendor padding variable in struct skb_shared_info
fc79c93657 FROMLIST: scsi: ufs: add quirk to enable host controller without interface configuration
2d5ae6b787 FROMLIST: scsi: ufs: add quirk to handle broken UIC command
38abaebab7 ANDROID: syscall_check: add vendor hook for bpf syscall
a7a3b31d58 ANDROID: syscall_check: add vendor hook for open syscall
a5543c9cd7 ANDROID: syscall_check: add vendor hook for mmap syscall
1f0769279f ANDROID: GKI: Add symbol to symbol list
2cff74e08c ANDROID: vendor_hooks: Add vendor hook to the net
25edba0d4d FROMLIST: scsi: ufs: Fix the SCSI abort handler
c0efdc4a5e ANDROID: android: export kernel function vm_unmapped_area
964220d080 ANDROID: shmem: vendor hook in shmem_alloc_page
bd2ca0ba5b FROMLIST: pstore/ram: Rework logic for detecting ramoops reserved memory region
daeabfe7fa ANDROID: mm: add reclaim_shmem_address_space() for faster reclaims
4c3dddf408 ANDROID: Update the generic ABI symbol list
4c4d8cbdef ANDROID: GKI: refresh ABI XML
01e4a037d8 ANDROID: GKI: turn on TIDY_ABI
edf973fd24 ANDROID: Update symbol list for VIVO
1702d2c8b7 FROMGIT: net: cdc_ncm: switch to eth%d interface naming
f4d6e8324c ANDROID: GKI: add allowed GKI symbol for Exynosauto SoC
444a0b7752 ANDROID: mm: add vendor hook for vmpressure
c799c6644b ANDROID: fips140: adjust some log messages
091338cb39 ANDROID: fips140: add missing static keyword to fips140_init()
70bfd6a7e0 ANDROID: GKI: update allowed list for exynosauto SoC
3e3147b280 UPSTREAM: scsi: ufs: ufshcd: Fix some function doc-rot
2c553e754f UPSTREAM: scsi: ufs: Adjust ufshcd_hold() during sending attribute requests
52ccdf90b9 FROMLIST: lockdep: Remove console_verbose when disable lock debugging
4458494476 ANDROID: ABI: qcom: Add symbols for 80211
5c51579fde ANDROID: fork: Export task_newtask tracepoint
e2a90797e8 ANDROID: Fix kernelci warnings for indentation in smp.c
bac33eaebf ANDROID: irqchip: gic-v3: Move struct gic_chip_data to header
bdac4418bf ANDROID: abi_gki_aarch64_qcom: Add android_vh_ufs_clock_scaling
65c1de0f06 ANDROID: Update symbol list for mtk
d4d02ab9b0 UPSTREAM: swiotlb: manipulate orig_addr when tlb_addr has offset
58aa0f2832 ANDROID: qcom: Add net related symbol
2f9f816445 ANDROID: Update the exynos symbol list
b2a9471239 ANDROID: Update symbol list for mtk
7c9599e204 FROMGIT: usb: dwc3: Create helper function getting MDWIDTH
0a24affb86 ANDROID: vendor_hooks: modify the function name
d686d5ffc6 ANDROID: GKI: Add some symbols to symbol list
bdfb11230b ANDROID: cpuidle: Allow for an early exit from cpuidle_enter_state()
f0b280c395 ANDROID: cpuidle: Update cpuidle_uninstall_idle_handler() to wakeup all online CPUs
14dd90ab37 ANDROID: scsi: ufs: Add hook to influence the UFS clock scaling policy
00aec39e2e FROMGIT: bpf: Support all gso types in bpf_skb_change_proto()

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I6e5be89f3f02c420237a549f4c6a08b5ed434581
2021-07-13 15:00:50 +02:00
Ray Chi
dd139186ef ANDROID: usb: gadget: fix NULL pointer dereference in android_setup
This is a possibility in android_setup when using cdev leading
to a NULL pointer dereference in spin_lock_irqsave. Using the
spinlock of gadget item to prevent the condition.

Bug: 189800931
Signed-off-by: Ray Chi <raychi@google.com>
Change-Id: Idc4cbcaed7dc6e1e35e8a63de84c1415fb83ef5e
2021-07-13 11:08:58 +00:00
Suren Baghdasaryan
07f65598af ANDROID: GKI: Disable kmem cgroup accounting
Disable cgroup kernel memory accounting to avoid unnecessary overhead.

Bug: 191223209
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I483aa83c707996bf1d363c0dfc56e7816a5d8e2f
2021-07-12 18:35:13 -07:00
Suren Baghdasaryan
309aa7e7a2 FROMLIST: mm, memcg: inline swap-related functions to improve disabled memcg config
Inline mem_cgroup_try_charge_swap, mem_cgroup_uncharge_swap and
cgroup_throttle_swaprate functions to perform mem_cgroup_disabled static
key check inline before calling the main body of the function. This
minimizes the memcg overhead in the pagefault and exit_mmap paths when
memcgs are disabled using cgroup_disable=memory command-line option.
This change results in ~1% overhead reduction when running PFT test [1]
comparing {CONFIG_MEMCG=n} against {CONFIG_MEMCG=y, cgroup_disable=memory}
configuration on an 8-core ARM64 Android device.

[1] https://lkml.org/lkml/2006/8/29/294 also used in mmtests suite

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>

Link: https://lore.kernel.org/patchwork/patch/1458908/
Bug: 191223209
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I18d59090ec908037b39324d1f1bb511d06e9c690
2021-07-12 18:34:30 -07:00
Suren Baghdasaryan
3ae8e2f183 BACKPORT: FROMLIST: mm, memcg: inline mem_cgroup_{charge/uncharge} to improve disabled memcg config
Inline mem_cgroup_{charge/uncharge} and mem_cgroup_uncharge_list functions
functions to perform mem_cgroup_disabled static key check inline before
calling the main body of the function. This minimizes the memcg overhead
in the pagefault and exit_mmap paths when memcgs are disabled using
cgroup_disable=memory command-line option.
This change results in ~0.4% overhead reduction when running PFT test [1]
comparing {CONFIG_MEMCG=n} against {CONFIG_MEMCG=y, cgroup_disable=memory}
configuration on an 8-core ARM64 Android device.

[1] https://lkml.org/lkml/2006/8/29/294 also used in mmtests suite

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>

Conflicts:
        include/linux/memcontrol.h
        mm/memcontrol.c

1. Trivial merge conflicts in memcontrol.h
2. Did not need to rename __mem_cgroup_charge into memcg_charge as in the
upstream version since in 5.10 __mem_cgroup_charge did not exist

Link: https://lore.kernel.org/patchwork/patch/1458907/
Bug: 191223209
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I9aad72aeabec2fe01f7218d629ec545c47b5d2c3
2021-07-12 18:32:52 -07:00
Suren Baghdasaryan
f73d029485 FROMLIST: mm, memcg: add mem_cgroup_disabled checks in vmpressure and swap-related functions
Add mem_cgroup_disabled check in vmpressure, mem_cgroup_uncharge_swap and
cgroup_throttle_swaprate functions. This minimizes the memcg overhead in
the pagefault and exit_mmap paths when memcgs are disabled using
cgroup_disable=memory command-line option.
This change results in ~2.1% overhead reduction when running PFT test [1]
comparing {CONFIG_MEMCG=n, CONFIG_MEMCG_SWAP=n} against {CONFIG_MEMCG=y,
CONFIG_MEMCG_SWAP=y, cgroup_disable=memory} configuration on an 8-core
ARM64 Android device.

[1] https://lkml.org/lkml/2006/8/29/294 also used in mmtests suite

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Muchun Song <songmuchun@bytedance.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>

Link: https://lore.kernel.org/patchwork/patch/1458906/
Bug: 191223209
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Ic1fc75eb1e4d7a9848cf641b9f232ad3262c490b
2021-07-12 18:26:15 -07:00
Alex Shi
669df367a9 UPSTREAM: mm/memcg: bail early from swap accounting if memcg disabled
Patch series "bail out early for memcg disable".

These 2 patches are indepenedent from per memcg lru lock, and may
encounter unexpected warning, so let's move out them from per memcg
lru locking patchset.

This patch (of 2):

We could bail out early when memcg wasn't enabled.

Link: https://lkml.kernel.org/r/1604283436-18880-1-git-send-email-alex.shi@linux.alibaba.com
Link: https://lkml.kernel.org/r/1604283436-18880-2-git-send-email-alex.shi@linux.alibaba.com
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.com>
Reviewed-by: Roman Gushchin <guro@fb.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Hugh Dickins <hughd@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Vladimir Davydov <vdavydov.dev@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

(cherry picked from commit 76358ab547)
Bug: 191223209
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Id3ea83d209cc4c98e3f1616b7d1044cfb1079c75
2021-07-12 18:04:48 -07:00
Kalesh Singh
1f0c32a667 UPSTREAM: procfs/dmabuf: add inode number to /proc/*/fdinfo
And 'ino' field to /proc/<pid>/fdinfo/<FD> and
/proc/<pid>/task/<tid>/fdinfo/<FD>.

The inode numbers can be used to uniquely identify DMA buffers in user
space and avoids a dependency on /proc/<pid>/fd/* when accounting
per-process DMA buffer sizes.

Link: https://lkml.kernel.org/r/20210308170651.919148-2-kaleshsingh@google.com
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Christian König <christian.koenig@amd.com>
Cc: Jann Horn <jannh@google.com>
Cc: Jeff Vander Stoep <jeffv@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Kalesh Singh <kaleshsingh@google.com>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Alexey Gladkov <gladkov.alexey@gmail.com>
Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: Bernd Edlinger <bernd.edlinger@hotmail.de>
Cc: Andrei Vagin <avagin@gmail.com>
Cc: Helge Deller <deller@gmx.de>
Cc: James Morris <jamorris@linux.microsoft.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 3845f256a8)

Bug: 159126739
Bug: 167141117
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Change-Id: Id07beac3edcc95c0b42805e24e5486965acbb46e
2021-07-12 22:38:22 +00:00
Kalesh Singh
0c8c125f57 UPSTREAM: procfs: allow reading fdinfo with PTRACE_MODE_READ
Android captures per-process system memory state when certain low memory
events (e.g a foreground app kill) occur, to identify potential memory
hoggers.  In order to measure how much memory a process actually consumes,
it is necessary to include the DMA buffer sizes for that process in the
memory accounting.  Since the handle to DMA buffers are raw FDs, it is
important to be able to identify which processes have FD references to a
DMA buffer.

Currently, DMA buffer FDs can be accounted using /proc/<pid>/fd/* and
/proc/<pid>/fdinfo -- both are only readable by the process owner, as
follows:

  1. Do a readlink on each FD.
  2. If the target path begins with "/dmabuf", then the FD is a dmabuf FD.
  3. stat the file to get the dmabuf inode number.
  4. Read/ proc/<pid>/fdinfo/<fd>, to get the DMA buffer size.

Accessing other processes' fdinfo requires root privileges.  This limits
the use of the interface to debugging environments and is not suitable for
production builds.  Granting root privileges even to a system process
increases the attack surface and is highly undesirable.

Since fdinfo doesn't permit reading process memory and manipulating
process state, allow accessing fdinfo under PTRACE_MODE_READ_FSCRED.

Link: https://lkml.kernel.org/r/20210308170651.919148-1-kaleshsingh@google.com
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Suggested-by: Jann Horn <jannh@google.com>
Acked-by: Christian König <christian.koenig@amd.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Alexey Dobriyan <adobriyan@gmail.com>
Cc: Alexey Gladkov <gladkov.alexey@gmail.com>
Cc: Andrei Vagin <avagin@gmail.com>
Cc: Bernd Edlinger <bernd.edlinger@hotmail.de>
Cc: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Eric W. Biederman <ebiederm@xmission.com>
Cc: Helge Deller <deller@gmx.de>
Cc: Hridya Valsaraju <hridya@google.com>
Cc: James Morris <jamorris@linux.microsoft.com>
Cc: Jeff Vander Stoep <jeffv@google.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Kees Cook <keescook@chromium.org>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Michel Lespinasse <walken@google.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Szabolcs Nagy <szabolcs.nagy@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 7bc3fa0172)

Bug: 159126739
Bug: 167141117
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Change-Id: I842b689670f731138592f45c7124ef446d9aa59a
2021-07-12 22:38:16 +00:00
Kalesh Singh
2e0476a465 Revert "FROMLIST: procfs: Allow reading fdinfo with PTRACE_MODE_READ"
Revert submission 1578844

Reason for revert: Will be replaced by upstream version
Reverted Changes:
Ic9c551998:FROMLIST: BACKPORT: procfs/dmabuf: Add inode numbe...
I41407760c:FROMLIST: procfs: Allow reading fdinfo with PTRACE...

Bug: 159126739
Bug: 167141117
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Change-Id: Iede4e9a65f87dad1ca0c6ecdeb42de47af4b37c8
2021-07-12 22:38:09 +00:00
Kalesh Singh
5ded961aa2 Revert "FROMLIST: BACKPORT: procfs/dmabuf: Add inode number to /..."
Revert submission 1578844

Reason for revert: Will be replaced by upstream version
Reverted Changes:
Ic9c551998:FROMLIST: BACKPORT: procfs/dmabuf: Add inode numbe...
I41407760c:FROMLIST: procfs: Allow reading fdinfo with PTRACE...

Bug: 159126739
Bug: 167141117
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
Change-Id: If02a6dc9a525193f286a138791de49085cd91972
2021-07-12 22:38:01 +00:00
Jaegeuk Kim
3ee5565017 UPSTREAM: f2fs: initialize page->private when using for our internal use
We need to guarantee it's initially zero. Otherwise, it'll hurt entire flag
operations.

Bug: 192173168
Fixes: b763f3bedc ("f2fs: restructure f2fs page.private layout")
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@google.com>
(cherry picked from commit c9ebd3df43 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master)
Change-Id: I02211d4bd2b1cb526e5fbcd55673043e3082d011
2021-07-12 21:01:34 +00:00
Minchan Kim
dba79c3af3 ANDROID: mm: page_pinner: report test_page_isolation_failure
Sometimes, alloc_contig_range fails at test_pages_isolated.
Report the failed page to page_pinner for tracking them to
be able to investigate it.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ifcb913faa87a131915efd72848e6ca59c15b75b4
2021-07-12 13:57:40 -07:00
Minchan Kim
13362ab28e ANDROID: mm: page_pinner: add state of page_pinner
To keep track of page migration failures, record the following
page states to capture natural state transitions of a page during
migration:

  * detected
  * put reference count
  * free

With such transition change, it was a lot easier to analyze page
migration failure issues. Since we already have annotation on the
put_page side, this patch adds the record in free path and page
migration failure path.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I18182d3fd62850c5580c9e89a5362bdae630f153
2021-07-12 13:57:40 -07:00
Minchan Kim
3254948484 ANDROID: mm: page_pinner: add more struct page fields
While I was investigating CMA allocation latency, adding fields below
were very useful to detect the CMA allocation latency issues.
This patch adds following fields of struct page.

for struct page:

  int count
  int mapcount
  struct address_space

This patch removes page_mt since it was not useful ever for me.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I312505901a227cd404555f845550d2a9c9ce89da
2021-07-12 13:57:40 -07:00
Minchan Kim
0445b67bee ANDROID: mm: page_pinner: change timestamp format
This patch changes timestamp format to align with trace event time format.
It was much easier to parse page_pinner event order by the time with
trace event.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ib0e81a47df588a2f6ebf842a5f3c5b298da4fe40
2021-07-12 13:57:40 -07:00
Minchan Kim
71da06728c ANDROID: mm: page_pinner: print_page_pinner refactoring
For print_page_pinner argument passing, use the one structure
parameter instead of several parameters with fields of the
structure.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I3816eb6154c6c56a66ee9079091880afda817914
2021-07-12 13:57:40 -07:00
Minchan Kim
b83e564914 ANDROID: mm: page_pinner: remove shared_count
Since we don't use it, remove it.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I04fe617f9203a6bbab5ebc424f7025df8f6d50ac
2021-07-12 13:57:40 -07:00
Minchan Kim
849f048050 ANDROID: mm: page_pinner: remove WARN_ON_ONCE
There are several path the WARN_ON_ONCE could be triggered but
it doesn't mean real bug since we intentionally allow it to make
code simple at this moment. So just remove the warnings	to prevent
folks confused it.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I7d14c8490db841f61b01fe7c16b406c9b1850c46
2021-07-12 13:57:39 -07:00
Minchan Kim
9a453100fc ANDROID: mm: page_pinner: fix typos
Fix typos.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: Ida3ae53f775b35e61e66703ed8409c0b6a1e04f0
2021-07-12 13:57:39 -07:00
Minchan Kim
d012783a86 ANDROID: mm: page_pinner: reset migration failed page
Currently, __reset_page_pinner reset only PAGE_EXT_GET page freeing,
not PAGE_EXT_PINNER_MIGRATION_FAILED page. It should handle both
cases to prevent wrong PAGE_EXT_PINNER_MIGRATION_FAILED setting.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I9b4124393ee432c7cb29cd12d160ecf2a1e34360
2021-07-12 13:57:39 -07:00
Minchan Kim
470cce5085 ANDROID: mm: page_pinner: record every put_page
There are some places using put_page_testzero instead of put_page.
Thus, move page_pinner_put_page into put_page_testzero to catch
all of put operations.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: If33b2a28ceb64e3ccab83990eac2c1cc291c3b08
2021-07-12 13:57:39 -07:00
Minchan Kim
9f47e5fdda ANDROID: mm: page_pinner: change function names
Make function name more clear to indicate what it's doing.

Bug: 192475091
Signed-off-by: Minchan Kim <minchan@google.com>
Change-Id: I6adabc0df6a54cf24d8287bf0f22cf7dcdc7ad03
2021-07-12 13:57:39 -07:00
Liujie Xie
a8385d61f2 ANDROID: Allow vendor module to reclaim a memcg
Export try_to_free_mem_cgroup_pages function to allow vendor modules to reclaim a memory cgroup.

Bug: 192052083

Signed-off-by: Liujie Xie <xieliujie@oppo.com>
Change-Id: Iec6ef50f5c71c62d0c9aa6de90e56a143dac61c1
2021-07-12 18:54:56 +00:00
Liujie Xie
f41a95eadc ANDROID: Export memcg functions to allow module to add new files
Export cgroup_add_legacy_cftypes and a helper function to allow vendor module to expose additional files in the memory cgroup hierarchy.

Bug: 192052083

Signed-off-by: Liujie Xie <xieliujie@oppo.com>
Change-Id: Ie2b936b3e77c7ab6d740d1bb6d70e03c70a326a7
2021-07-12 18:53:29 +00:00
Wesley Cheng
46bf3b94e7 FROMGIT: dt-bindings: usb: dwc3: Update dwc3 TX fifo properties
Update the tx-fifo-resize property with a better description, while
adding the tx-fifo-max-num, which is a new parameter allowing
adjustments for the maximum number of packets the txfifo resizing logic
can account for while resizing the endpoints.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
Link: https://lore.kernel.org/r/1625908395-5498-7-git-send-email-wcheng@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
cherry picked from commit 97db1b081e
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I02e712d37e1fc19634a41afc2ab679346a979b34
2021-07-12 17:11:12 +00:00
Serge Semin
b36b813e39 UPSTREAM: dt-bindings: usb: Convert DWC USB3 bindings to DT schema
DWC USB3 DT node is supposed to be compliant with the Generic xHCI
Controller schema, but with additional vendor-specific properties, the
controller-specific reference clocks and PHYs. So let's convert the
currently available legacy text-based DWC USB3 bindings to the DT schema
and make sure the DWC USB3 nodes are also validated against the
usb-xhci.yaml schema.

Note 1. we have to discard the nodename restriction of being prefixed with
"dwc3@" string, since in accordance with the usb-hcd.yaml schema USB nodes
are supposed to be named as "^usb(@.*)".

Note 2. The clock-related properties are marked as optional to match the
DWC USB3 driver expectation and to improve the bindings mainainability
so in case if there is a glue-node it would the responsible for the
clocks initialization.

Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Link: https://lore.kernel.org/r/20201210090944.16283-11-Sergey.Semin@baikalelectronics.ru
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 186724205
(cherry picked from commit 389d776588)

Change-Id: I898cfa402b56f1d8535425d76200f624e7a2ae27
Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2021-07-12 17:11:02 +00:00
Wesley Cheng
9a80b7b728 FROMGIT: of: Add stub for of_add_property()
If building with OF Kconfig disabled, this can lead to errors for
drivers utilizing of_add_property().  Add a stub for the add API, as
it exists for the remove variant as well, and to avoid compliation
issues.  Also, export this API so that it can be used by modules.

Signed-off-by: Wesley Cheng <wcheng@codeaurora.org>
Link: https://lore.kernel.org/r/1625908395-5498-5-git-send-email-wcheng@codeaurora.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit fe794e3954
 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I251e791f446a9f581cda0f1cd3a8f09b59617783
2021-07-12 17:10:22 +00:00
Eric Biggers
2742be5903 ANDROID: fips140: define fips_enabled to 1 to enable FIPS behavior
In fips140.ko, enable the behavior that the upstream fips_enabled flag
controls, such as the XTS weak key check which apparently is required.

Note that some of this behavior, such as the DRBG continuity check, is
allegedly not required.  But to ensure we don't miss anything that was
already handled upstream, it seems best to define fips_enabled to 1.  We
can still disable anything that turns out to be problematic.

Bug: 153614920
Bug: 188620248
Change-Id: Idcded9e69e7d7cdf7f2937009af209857b0c08e2
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-07-12 10:49:29 +00:00
Eric Biggers
e886dd4c33 ANDROID: fips140: unregister existing DRBG algorithms
fips140_algorithms[] is a list of cra_names rather than
cra_driver_names, so to specify that the existing DRBG algorithms need
to be unregistered it needs to contain "stdrng".

Bug: 153614920
Bug: 188620248
Change-Id: Id655e74858ca6bff4eedaf761d54c3ae54c2260f
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-07-12 10:49:29 +00:00
Eric Biggers
634445a640 ANDROID: fips140: fix deadlock in unregister_existing_fips140_algos()
crypto_remove_final() calls crypto_alg_put() which can take
crypto_alg_sem again, via a call stack like:

    down_write(&crypto_alg_sem)
    crypto_drop_spawn()
    crypto_ccm_free()
    crypto_aead_free_instance()
    crypto_destroy_instance()
    crypto_alg_put() (inlined)
    crypto_remove_final()
    unregister_existing_fips140_algos()

That causes a deadlock because unregister_existing_fips140_algos() is
already holding crypto_alg_sem.

Fix this by reducing the scope of crypto_alg_sem to the actual list
traversal and not the crypto_alg_put().

Bug: 153614920
Bug: 188620248
Change-Id: Ia724d8b13480233dad051c538dc504cb27be8777
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-07-12 10:49:29 +00:00
Eric Biggers
0af06624ea ANDROID: fips140: check for errors from initcalls
Check for errors when executing the initcalls so that we can't fail to
register some algorithms without noticing.

Bug: 153614920
Bug: 188620248
Change-Id: I8e55de3d7624c6700f161c92705d0f6f874476d8
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-07-12 10:49:28 +00:00
Eric Biggers
92de53472e ANDROID: fips140: log already-live algorithms
It may be helpful to know whether the "already-live algorithms" code
path is being executed or not, and if so, with which algorithms.  Add a
log message for it.

Bug: 153614920
Bug: 188620248
Change-Id: Ie3757794b1e43f630d5dc8f888c6ad33acacbc4c
Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-07-12 10:49:28 +00:00
Jing-Ting Wu
0a7da21583 ANDROID: Update new mtk gki symbol
Leaf changes summary: 6 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 3 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 3 Added variables

Added functions:

[A] 'function int __traceiter_android_vh_cgroup_attach(void*, cgroup_subsys*, cgroup_taskset*)'
[A] 'function int __traceiter_android_vh_is_fpsimd_save(void*, task_struct*, task_struct*)'
[A] 'function int __traceiter_task_newtask(void*, task_struct*, unsigned long int)'

3 Added variables:

[A] 'tracepoint __tracepoint_android_vh_cgroup_attach'
[A] 'tracepoint __tracepoint_android_vh_is_fpsimd_save'
[A] 'tracepoint __tracepoint_task_newtask'

Bug: 193159431
Signed-off-by: Jing-Ting Wu <Jing-Ting.Wu@mediatek.com>
Change-Id: I32b5b26b6f86463c5521a4b6cd7c43d195f6d672
2021-07-12 10:17:15 +00:00
Puma Hsu
98085b5dd8 ANDROID: usb: Add vendor hook for usb suspend and resume
Add the hook that vendor can design and bypass the suspend/resume.
When the bypass is set, skip the orignal suspend/resume methods.

In mobile, a co-processor can be used with USB audio, and ACPU may
be able to sleep in such condition to improve power consumption.
We will need vendor hook to support this.

Bug: 192774581
Signed-off-by: Puma Hsu <pumahsu@google.com>
Change-Id: Ic62a8a1e662bbe3fb0aa17af7491daace0b9f18a
2021-07-12 09:06:49 +00:00
Greg Kroah-Hartman
e722f1d83b Merge 5.10.49 into android12-5.10-lts
Changes in 5.10.49
	KVM: PPC: Book3S HV: Save and restore FSCR in the P9 path
	media: uvcvideo: Support devices that report an OT as an entity source
	Hexagon: fix build errors
	Hexagon: add target builtins to kernel
	Hexagon: change jumps to must-extend in futex_atomic_*
	xen/events: reset active flag for lateeoi events later
	Linux 5.10.49

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ieb1bda402419f08614fbb1b0208a83c6df0abf2d
2021-07-11 21:43:53 +02:00
Greg Kroah-Hartman
9c4e6d448c Merge 5.10.48 into android12-5.10-lts
Changes in 5.10.48
	scsi: sr: Return appropriate error code when disk is ejected
	gpio: mxc: Fix disabled interrupt wake-up support
	drm/nouveau: fix dma_address check for CPU/GPU sync
	gpio: AMD8111 and TQMX86 require HAS_IOPORT_MAP
	RDMA/mlx5: Block FDB rules when not in switchdev mode
	Revert "KVM: x86/mmu: Drop kvm_mmu_extended_role.cr4_la57 hack"
	Linux 5.10.48

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ie66f49fdd4e28b369b134dfb99aab7c0f0e3bd18
2021-07-11 21:42:51 +02:00
Greg Kroah-Hartman
904ad453ba Linux 5.10.49
Link: https://lore.kernel.org/r/20210709131537.035851348@linuxfoundation.org
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Fox Chen <foxhlchen@gmail.com>
Tested-by: Shuah Khan <skhan@linuxfoundation.org>
Tested-by: Hulk Robot <hulkrobot@huawei.com>
Tested-by: Linux Kernel Functional Testing <lkft@linaro.org>
Tested-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Pavel Machek (CIP) <pavel@denx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-11 12:53:32 +02:00
Juergen Gross
064b57a8da xen/events: reset active flag for lateeoi events later
commit 3de218ff39 upstream.

In order to avoid a race condition for user events when changing
cpu affinity reset the active flag only when EOI-ing the event.

This is working fine as all user events are lateeoi events. Note that
lateeoi_ack_mask_dynirq() is not modified as there is no explicit call
to xen_irq_lateeoi() expected later.

Cc: stable@vger.kernel.org
Reported-by: Julien Grall <julien@xen.org>
Fixes: b6622798bc ("xen/events: avoid handling the same event on two cpus at the same time")
Tested-by: Julien Grall <julien@xen.org>
Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Boris Ostrovsky <boris.ostrvsky@oracle.com>
Link: https://lore.kernel.org/r/20210623130913.9405-1-jgross@suse.com
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-11 12:53:31 +02:00
Sid Manning
a245f6842d Hexagon: change jumps to must-extend in futex_atomic_*
commit 6fff7410f6 upstream.

Cross-section jumps from .fixup section must be extended.

Signed-off-by: Sid Manning <sidneym@codeaurora.org>
Signed-off-by: Brian Cain <bcain@codeaurora.org>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-11 12:53:31 +02:00
Sid Manning
a7f51048c5 Hexagon: add target builtins to kernel
commit f1f99adf05 upstream.

Add the compiler-rt builtins like memcpy to the hexagon kernel.

Signed-off-by: Sid Manning <sidneym@codeaurora.org>
Add SYM_FUNC_START/END, ksyms exports
Signed-off-by: Brian Cain <bcain@codeaurora.org>
Cc: Guenter Roeck <linux@roeck-us.net>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-11 12:53:31 +02:00
Sid Manning
243f325ecc Hexagon: fix build errors
commit 788dcee030 upstream.

Fix type-o in ptrace.c.
Add missing include: asm/hexagon_vm.h
Remove superfluous cast.
Replace 'p3_0' with 'preds'.

Signed-off-by: Sid Manning <sidneym@codeaurora.org>
Add -mlong-calls to build flags.
Signed-off-by: Brian Cain <bcain@codeaurora.org>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-11 12:53:30 +02:00
Laurent Pinchart
8148665cb7 media: uvcvideo: Support devices that report an OT as an entity source
commit 4ca052b4ea upstream.

Some devices reference an output terminal as the source of extension
units. This is incorrect, as output terminals only have an input pin,
and thus can't be connected to any entity in the forward direction. The
resulting topology would cause issues when registering the media
controller graph. To avoid this problem, connect the extension unit to
the source of the output terminal instead.

While at it, and while no device has been reported to be affected by
this issue, also handle forward scans where two output terminals would
be connected together, and skip the terminals found through such an
invalid connection.

Reported-and-tested-by: John Nealy <jnealy3@yahoo.com>

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-11 12:53:30 +02:00
Fabiano Rosas
d5737410d2 KVM: PPC: Book3S HV: Save and restore FSCR in the P9 path
commit 25edcc50d7 upstream.

The Facility Status and Control Register is a privileged SPR that
defines the availability of some features in problem state. Since it
can be written by the guest, we must restore it to the previous host
value after guest exit.

This restoration is currently done by taking the value from
current->thread.fscr, which in the P9 path is not enough anymore
because the guest could context switch the QEMU thread, causing the
guest-current value to be saved into the thread struct.

The above situation manifested when running a QEMU linked against a
libc with System Call Vectored support, which causes scv
instructions to be run by QEMU early during the guest boot (during
SLOF), at which point the FSCR is 0 due to guest entry. After a few
scv calls (1 to a couple hundred), the context switching happens and
the QEMU thread runs with the guest value, resulting in a Facility
Unavailable interrupt.

This patch saves and restores the host value of FSCR in the inner
guest entry loop in a way independent of current->thread.fscr. The old
way of doing it is still kept in place because it works for the old
entry path.

Signed-off-by: Fabiano Rosas <farosas@linux.ibm.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
Cc: Georgy Yakovlev <gyakovlev@gentoo.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-11 12:53:30 +02:00
Guangming Cao
956db89e71 BACKPORT: FROMLIST: dma-heap: Let dma heap use dma_map_attrs to map & unmap iova
For dma-heap users, they can't bypass cache sync when map/unmap iova
with dma heap. But they can do it by adding DMA_ATTR_SKIP_CPU_SYNC
into dma_alloc_attrs.

To keep alignment, at dma_heap side, also use
dma_buf_attachment.dma_map_attrs to do iova map & unmap.

This patch is a little different with linux patch, because ACK
has cached heap, and linux doesn't have it

Bug: 189986159
Link: https://lore.kernel.org/patchwork/patch/1455032/
Change-Id: I324712644688c29e55c9197efcde9283bbbd813b
Signed-off-by: Guangming Cao <Guangming.Cao@mediatek.com>
2021-07-10 09:34:39 +00:00
Charan Teja Reddy
749d6e7f2c ANDROID: abi_gki_aarch64_qcom: Add vendor hook for shmem_alloc_page
The commit 964220d080 ("ANDROID: shmem: vendor hook in
shmem_alloc_page") adds a vendor hook related to getting the page from
driver maintained pool first for the shmem pages. It also requires
already exported __mod_node_page_state function. Add these symbols to
the list.

Leaf changes summary: 2 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added
function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 1 Added
variable

1 Added function:

  [A] 'function void __mod_node_page_state(pglist_data*, node_stat_item,
long int)'

1 Added variable:

  [A] 'tracepoint __tracepoint_android_vh_shmem_alloc_page'

Bug: 187798288
Change-Id: Id4859df62a401f9b10daf9388cdb91f4aec99b78
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
2021-07-09 22:48:23 +00:00
Charan Teja Reddy
b05bbe48be ANDROID: abi_gki_aarch64_qcom: Add reclaim_shmem_address_space
Add reclaim_shmem_address_space to symbol list. This gerrit also
contains the changes resulted from changing the number of params in
shmem_mark_page_lazyfree function.

Leaf changes summary: 2 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 1 Changed, 1 Added
function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added
variable

1 Added function:

  [A] 'function int reclaim_shmem_address_space(address_space*)'

1 function with some sub-type change:

  [C] 'function void shmem_mark_page_lazyfree(page*)' at shmem.c:4296:1
has some sub-type changes:
    CRC (modversions) changed from 0x81dbf5b0 to 0xd16d738a
    parameter 2 of type 'typedef bool' was added

Bug: 187798288
Change-Id: Ieebc6d0cb2211a80a126f39b46e3c7d3583dca60
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
2021-07-09 22:47:35 +00:00
xieliujie
d80c70d7a8 ANDROID: android: export kernel function arch_mmap_rnd
Vendor module needs arch_mmap_rnd() to generate new mm->mmap_base
when defining a custom mmap_layout.
More details in https://buganizer.corp.google.com/issues/191439466

Bug: 191439466
Signed-off-by: xieliujie <xieliujie@oppo.com>
Change-Id: I37644438b4e170732adc62810388450155c178a4
2021-07-09 20:51:14 +00:00
Charan Teja Reddy
25c7eb4932 ANDROID: mm: shmem: Fix build break with allnoconfig
With allnoconfig, build is breaking with below message, which is
introduced in commit daeabfe7fa ("ANDROID: mm: add
reclaim_shmem_address_space() for faster reclaims"). Fix it.

mm/shmem.c: In function ‘reclaim_shmem_address_space’:
mm/shmem.c:4321:7: error: implicit declaration of function
‘isolate_lru_page’ [-Werror=implicit-function-declaration]
   if (isolate_lru_page(page))

Bug: 187798288
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
Change-Id: I27494b329e9b667869e1f5264bd319d94b8d2dd6
2021-07-09 18:34:15 +00:00
Liujie Xie
1cdcf76b15 ANDROID: vendor_hooks: add hooks in mem_cgroup subsystem
Add hooks to tune memory policy based on mem_cgroup.

Bug: 192052083

Signed-off-by: Liujie Xie <xieliujie@oppo.com>
Change-Id: Ica1a5409eed86fbd466edd2c7557f94972a40175
2021-07-09 17:10:05 +00:00