platform/kernel/linux-rpi.git
4 months agomm/memcg: warning on !memcg after readahead page charged
Alex Shi [Fri, 18 Dec 2020 22:01:31 +0000 (14:01 -0800)]
mm/memcg: warning on !memcg after readahead page charged

Add VM_WARN_ON_ONCE_PAGE() macro.

Since readahead page is charged on memcg too, in theory we don't have to
check this exception now.  Before safely remove them all, add a warning
for the unexpected !memcg.

Link: https://lkml.kernel.org/r/1604283436-18880-3-git-send-email-alex.shi@linux.alibaba.com
Change-Id: I0de058b8c4fd406c7d02ab837388d77c93ef778a
Signed-off-by: Alex Shi <alex.shi@linux.alibaba.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>
[backport of the commit a4055888629bc0467d12d912cd7c90acdf3d9b12 from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: use self-explanatory macros rather than "2"
Yu Zhao [Fri, 16 Oct 2020 03:09:55 +0000 (20:09 -0700)]
mm: use self-explanatory macros rather than "2"

Change-Id: Ia0efe80fa2c62163b0d58a382aef1e0881cba15b
Signed-off-by: Yu Zhao <yuzhao@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Alex Shi <alex.shi@linux.alibaba.com>
Link: http://lkml.kernel.org/r/20200831175042.3527153-2-yuzhao@google.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit ed0173733dd468883198c3136284394320b8fad6 from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm/vma: make vma_is_accessible() available for general use
Anshuman Khandual [Tue, 7 Apr 2020 03:03:47 +0000 (20:03 -0700)]
mm/vma: make vma_is_accessible() available for general use

Lets move vma_is_accessible() helper to include/linux/mm.h which makes it
available for general use.  While here, this replaces all remaining open
encodings for VMA access check with vma_is_accessible().

Change-Id: I475ac8df7e31c848d3c84688f7fb9e3f27c832f5
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>
Acked-by: Guo Ren <guoren@kernel.org>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Guo Ren <guoren@kernel.org>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Paul Burton <paulburton@kernel.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Cc: Rich Felker <dalias@libc.org>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Nick Piggin <npiggin@gmail.com>
Cc: Paul Mackerras <paulus@ozlabs.org>
Cc: Will Deacon <will@kernel.org>
Link: http://lkml.kernel.org/r/1582520593-30704-3-git-send-email-anshuman.khandual@arm.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit 3122e80efc0faf4a2accba7a46c7ed795edbfded from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm/vmscan.c: clean code by removing unnecessary assignment
Mateusz Nosek [Thu, 2 Apr 2020 04:10:15 +0000 (21:10 -0700)]
mm/vmscan.c: clean code by removing unnecessary assignment

Previously 0 was assigned to variable 'lruvec_size', but the variable was
never read later.  So the assignment can be removed.

Fixes: f87bccde6a7d ("mm/vmscan: remove unused lru_pages argument")
Change-Id: Iddd0982d271ee9ab9387195b87a4f608850cadc7
Signed-off-by: Mateusz Nosek <mateusznosek0@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Wei Yang <richard.weiyang@gmail.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Link: http://lkml.kernel.org/r/20200229214022.11853-1-mateusznosek0@gmail.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit e072bff60a29c82b1536d78c412f009d1a1de4cf from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: pagewalk: add p4d_entry() and pgd_entry()
Steven Price [Tue, 4 Feb 2020 01:35:45 +0000 (17:35 -0800)]
mm: pagewalk: add p4d_entry() and pgd_entry()

pgd_entry() and pud_entry() were removed by commit 0b1fbfe50006c410
("mm/pagewalk: remove pgd_entry() and pud_entry()") because there were no
users.  We're about to add users so reintroduce them, along with
p4d_entry() as we now have 5 levels of tables.

Note that commit a00cc7d9dd93d66a ("mm, x86: add support for PUD-sized
transparent hugepages") already re-added pud_entry() but with different
semantics to the other callbacks.  This commit reverts the semantics back
to match the other callbacks.

To support hmm.c which now uses the new semantics of pud_entry() a new
member ('action') of struct mm_walk is added which allows the callbacks to
either descend (ACTION_SUBTREE, the default), skip (ACTION_CONTINUE) or
repeat the callback (ACTION_AGAIN).  hmm.c is then updated to call
pud_trans_huge_lock() itself and make use of the splitting/retry logic of
the core code.

After this change pud_entry() is called for all entries, not just
transparent huge pages.

[arnd@arndb.de: fix unused variable warning]
Link: http://lkml.kernel.org/r/20200107204607.1533842-1-arnd@arndb.de
Link: http://lkml.kernel.org/r/20191218162402.45610-12-steven.price@arm.com
Change-Id: Iefcf3d5f987b2fcc64262da127543ae11207086c
Signed-off-by: Steven Price <steven.price@arm.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Hogan <jhogan@kernel.org>
Cc: James Morse <james.morse@arm.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: "Liang, Kan" <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Burton <paul.burton@mips.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Will Deacon <will@kernel.org>
Cc: Zong Li <zong.li@sifive.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit 3afc423632a194d7d6afef34e4bb98f804cd071d from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: add generic p?d_leaf() macros
Steven Price [Tue, 4 Feb 2020 01:35:01 +0000 (17:35 -0800)]
mm: add generic p?d_leaf() macros

Patch series "Generic page walk and ptdump", v17.

Many architectures current have a debugfs file for dumping the kernel page
tables.  Currently each architecture has to implement custom functions for
this because the details of walking the page tables used by the kernel are
different between architectures.

This series extends the capabilities of walk_page_range() so that it can
deal with the page tables of the kernel (which have no VMAs and can
contain larger huge pages than exist for user space).  A generic PTDUMP
implementation is the implemented making use of the new functionality of
walk_page_range() and finally arm64 and x86 are switch to using it,
removing the custom table walkers.

To enable a generic page table walker to walk the unusual mappings of the
kernel we need to implement a set of functions which let us know when the
walker has reached the leaf entry.  After a suggestion from Will Deacon
I've chosen the name p?d_leaf() as this (hopefully) describes the purpose
(and is a new name so has no historic baggage).  Some architectures have
p?d_large macros but this is easily confused with "large pages".

This series ends with a generic PTDUMP implemention for arm64 and x86.

Mostly this is a clean up and there should be very little functional
change.  The exceptions are:

* arm64 PTDUMP debugfs now displays pages which aren't present (patch 22).

* arm64 has the ability to efficiently process KASAN pages (which
  previously only x86 implemented).  This means that the combination of
  KASAN and DEBUG_WX is now useable.

This patch (of 23):

Exposing the pud/pgd levels of the page tables to walk_page_range() means
we may come across the exotic large mappings that come with large areas of
contiguous memory (such as the kernel's linear map).

For architectures that don't provide all p?d_leaf() macros, provide
generic do nothing default that are suitable where there cannot be leaf
pages at that level.  Futher patches will add implementations for
individual architectures.

The name p?d_leaf() is chosen to minimize the confusion with existing uses
of "large" pages and "huge" pages which do not necessary mean that the
entry is a leaf (for example it may be a set of contiguous entries that
only take 1 TLB slot).  For the purpose of walking the page tables we
don't need to know how it will be represented in the TLB, but we do need
to know for sure if it is a leaf of the tree.

Link: http://lkml.kernel.org/r/20191218162402.45610-2-steven.price@arm.com
Change-Id: Id0b9ea4602b9694a0354f056992ce74ab91d3758
Signed-off-by: Steven Price <steven.price@arm.com>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Morse <james.morse@arm.com>
Cc: Jerome Glisse <jglisse@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: "Liang, Kan" <kan.liang@linux.intel.com>
Cc: Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: James Hogan <jhogan@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Burton <paul.burton@mips.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Paul Walmsley <paul.walmsley@sifive.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Zong Li <zong.li@sifive.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit 93fab1b22ef7c4abcbc760ce4432762b02e7f3d1 from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: vmscan: enforce inactive:active ratio at the reclaim root
Johannes Weiner [Sun, 1 Dec 2019 01:56:02 +0000 (17:56 -0800)]
mm: vmscan: enforce inactive:active ratio at the reclaim root

We split the LRU lists into inactive and an active parts to maximize
workingset protection while allowing just enough inactive cache space to
faciltate readahead and writeback for one-off file accesses (e.g.  a
linear scan through a file, or logging); or just enough inactive anon to
maintain recent reference information when reclaim needs to swap.

With cgroups and their nested LRU lists, we currently don't do this
correctly.  While recursive cgroup reclaim establishes a relative LRU
order among the pages of all involved cgroups, inactive:active size
decisions are done on a per-cgroup level.  As a result, we'll reclaim a
cgroup's workingset when it doesn't have cold pages, even when one of its
siblings has plenty of it that should be reclaimed first.

For example: workload A has 50M worth of hot cache but doesn't do any
one-off file accesses; meanwhile, parallel workload B scans files and
rarely accesses the same page twice.

If these workloads were to run in an uncgrouped system, A would be
protected from the high rate of cache faults from B.  But if they were put
in parallel cgroups for memory accounting purposes, B's fast cache fault
rate would push out the hot cache pages of A.  This is unexpected and
undesirable - the "scan resistance" of the page cache is broken.

This patch moves inactive:active size balancing decisions to the root of
reclaim - the same level where the LRU order is established.

It does this by looking at the recursive size of the inactive and the
active file sets of the cgroup subtree at the beginning of the reclaim
cycle, and then making a decision - scan or skip active pages - that
applies throughout the entire run and to every cgroup involved.

With that in place, in the test above, the VM will recognize that there
are plenty of inactive pages in the combined cache set of workloads A and
B and prefer the one-off cache in B over the hot pages in A.  The scan
resistance of the cache is restored.

[cai@lca.pw: fix some -Wenum-conversion warnings]
Link: http://lkml.kernel.org/r/1573848697-29262-1-git-send-email-cai@lca.pw
Link: http://lkml.kernel.org/r/20191107205334.158354-4-hannes@cmpxchg.org
Change-Id: If5fb00a0b06f616e0c096e95a21513bfa8a58e1b
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit b91ac374346ba206cfd568bb0ab830af6b205cfd from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: vmscan: detect file thrashing at the reclaim root
Johannes Weiner [Sun, 1 Dec 2019 01:55:59 +0000 (17:55 -0800)]
mm: vmscan: detect file thrashing at the reclaim root

We use refault information to determine whether the cache workingset is
stable or transitioning, and dynamically adjust the inactive:active file
LRU ratio so as to maximize protection from one-off cache during stable
periods, and minimize IO during transitions.

With cgroups and their nested LRU lists, we currently don't do this
correctly.  While recursive cgroup reclaim establishes a relative LRU
order among the pages of all involved cgroups, refaults only affect the
local LRU order in the cgroup in which they are occuring.  As a result,
cache transitions can take longer in a cgrouped system as the active pages
of sibling cgroups aren't challenged when they should be.

[ Right now, this is somewhat theoretical, because the siblings, under
  continued regular reclaim pressure, should eventually run out of
  inactive pages - and since inactive:active *size* balancing is also
  done on a cgroup-local level, we will challenge the active pages
  eventually in most cases. But the next patch will move that relative
  size enforcement to the reclaim root as well, and then this patch
  here will be necessary to propagate refault pressure to siblings. ]

This patch moves refault detection to the root of reclaim.  Instead of
remembering the cgroup owner of an evicted page, remember the cgroup that
caused the reclaim to happen.  When refaults later occur, they'll
correctly influence the cross-cgroup LRU order that reclaim follows.

I.e.  if global reclaim kicked out pages in some subgroup A/B/C, the
refault of those pages will challenge the global LRU order, and not just
the local order down inside C.

[hannes@cmpxchg.org:  use page_memcg() instead of another lookup]
Link: http://lkml.kernel.org/r/20191115160722.GA309754@cmpxchg.org
Link: http://lkml.kernel.org/r/20191107205334.158354-3-hannes@cmpxchg.org
Change-Id: Ib68cb4395227a8f49e8cf0893208a9b3a415f7c5
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Rik van Riel <riel@surriel.com>
Cc: Shakeel Butt <shakeelb@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit b910718a948a9120d90faf632b33ed23c70e266a from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: vmscan: move file exhaustion detection to the node level
Johannes Weiner [Sun, 1 Dec 2019 01:55:56 +0000 (17:55 -0800)]
mm: vmscan: move file exhaustion detection to the node level

Patch series "mm: fix page aging across multiple cgroups".

When applications are put into unconfigured cgroups for memory accounting
purposes, the cgrouping itself should not change the behavior of the page
reclaim code.  We expect the VM to reclaim the coldest pages in the
system.  But right now the VM can reclaim hot pages in one cgroup while
there is eligible cold cache in others.

This is because one part of the reclaim algorithm isn't truly cgroup
hierarchy aware: the inactive/active list balancing.  That is the part
that is supposed to protect hot cache data from one-off streaming IO.

The recursive cgroup reclaim scheme will scan and rotate the physical LRU
lists of each eligible cgroup at the same rate in a round-robin fashion,
thereby establishing a relative order among the pages of all those
cgroups.  However, the inactive/active balancing decisions are made
locally within each cgroup, so when a cgroup is running low on cold pages,
its hot pages will get reclaimed - even when sibling cgroups have plenty
of cold cache eligible in the same reclaim run.

For example:

   [root@ham ~]# head -n1 /proc/meminfo
   MemTotal:        1016336 kB

   [root@ham ~]# ./reclaimtest2.sh
   Establishing 50M active files in cgroup A...
   Hot pages cached: 12800/12800 workingset-a
   Linearly scanning through 18G of file data in cgroup B:
   real    0m4.269s
   user    0m0.051s
   sys     0m4.182s
   Hot pages cached: 134/12800 workingset-a

The streaming IO in B, which doesn't benefit from caching at all, pushes
out most of the workingset in A.

Solution

This series fixes the problem by elevating inactive/active balancing
decisions to the toplevel of the reclaim run.  This is either a cgroup
that hit its limit, or straight-up global reclaim if there is physical
memory pressure.  From there, it takes a recursive view of the cgroup
subtree to decide whether page deactivation is necessary.

In the test above, the VM will then recognize that cgroup B has plenty of
eligible cold cache, and that the hot pages in A can be spared:

   [root@ham ~]# ./reclaimtest2.sh
   Establishing 50M active files in cgroup A...
   Hot pages cached: 12800/12800 workingset-a
   Linearly scanning through 18G of file data in cgroup B:
   real    0m4.244s
   user    0m0.064s
   sys     0m4.177s
   Hot pages cached: 12800/12800 workingset-a

Implementation

Whether active pages can be deactivated or not is influenced by two
factors: the inactive list dropping below a minimum size relative to the
active list, and the occurence of refaults.

This patch series first moves refault detection to the reclaim root, then
enforces the minimum inactive size based on a recursive view of the cgroup
tree's LRUs.

History

Note that this actually never worked correctly in Linux cgroups.  In the
past it worked for global reclaim and leaf limit reclaim only (we used to
have two physical LRU linkages per page), but it never worked for
intermediate limit reclaim over multiple leaf cgroups.

We're noticing this now because 1) we're putting everything into cgroups
for accounting, not just the things we want to control and 2) we're moving
away from leaf limits that invoke reclaim on individual cgroups, toward
large tree reclaim, triggered by high-level limits, or physical memory
pressure that is influenced by local protections such as memory.low and
memory.min instead.

This patch (of 3):

When file pages are lower than the watermark on a node, we try to force
scan anonymous pages to counter-act the balancing algorithms preference
for new file pages when they are likely thrashing.  This is a node-level
decision, but it's currently made each time we look at an lruvec.  This is
unnecessarily expensive and also a layering violation that makes the code
harder to understand.

Clean this up by making the check once per node and setting a flag in the
scan_control.

Link: http://lkml.kernel.org/r/20191107205334.158354-2-hannes@cmpxchg.org
Change-Id: Ia0cf370aad8c58e865fae6c0e8235e06b760aca1
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Reviewed-by: Suren Baghdasaryan <surenb@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Rik van Riel <riel@surriel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit 53138cea7f398d2cdd0fa22adeec7e16093e1ebd from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: vmscan: harmonize writeback congestion tracking for nodes & memcgs
Johannes Weiner [Sun, 1 Dec 2019 01:55:52 +0000 (17:55 -0800)]
mm: vmscan: harmonize writeback congestion tracking for nodes & memcgs

The current writeback congestion tracking has separate flags for kswapd
reclaim (node level) and cgroup limit reclaim (memcg-node level).  This is
unnecessarily complicated: the lruvec is an existing abstraction layer for
that node-memcg intersection.

Introduce lruvec->flags and LRUVEC_CONGESTED.  Then track that at the
reclaim root level, which is either the NUMA node for global reclaim, or
the cgroup-node intersection for cgroup reclaim.

Link: http://lkml.kernel.org/r/20191022144803.302233-9-hannes@cmpxchg.org
Change-Id: Iaa10ac1d8ee7de5c6f2563ac5ff36ae9bae876a2
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Roman Gushchin <guro@fb.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit 1b05117df78e035afb5f66ef50bf8750d976ef08 from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: vmscan: split shrink_node() into node part and memcgs part
Johannes Weiner [Sun, 1 Dec 2019 01:55:49 +0000 (17:55 -0800)]
mm: vmscan: split shrink_node() into node part and memcgs part

This function is getting long and unwieldy, split out the memcg bits.

The updated shrink_node() handles the generic (node) reclaim aspects:
  - global vmpressure notifications
  - writeback and congestion throttling
  - reclaim/compaction management
  - kswapd giving up on unreclaimable nodes

It then calls a new shrink_node_memcgs() which handles cgroup specifics:
  - the cgroup tree traversal
  - memory.low considerations
  - per-cgroup slab shrinking callbacks
  - per-cgroup vmpressure notifications

[hannes@cmpxchg.org: rename "root" to "target_memcg", per Roman]
Link: http://lkml.kernel.org/r/20191025143640.GA386981@cmpxchg.org
Link: http://lkml.kernel.org/r/20191022144803.302233-8-hannes@cmpxchg.org
Change-Id: Ibef223d4f49740dc2ab2e86f2b7c1e529a9643e2
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Roman Gushchin <guro@fb.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit 0f6a5cff43d3bcd6aa54c9af267737249d02aa21 from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: vmscan: turn shrink_node_memcg() into shrink_lruvec()
Johannes Weiner [Sun, 1 Dec 2019 01:55:46 +0000 (17:55 -0800)]
mm: vmscan: turn shrink_node_memcg() into shrink_lruvec()

An lruvec holds LRU pages owned by a certain NUMA node and cgroup.
Instead of awkwardly passing around a combination of a pgdat and a memcg
pointer, pass down the lruvec as soon as we can look it up.

Nested callers that need to access node or cgroup properties can look them
them up if necessary, but there are only a few cases.

Link: http://lkml.kernel.org/r/20191022144803.302233-7-hannes@cmpxchg.org
Change-Id: Ice444a0c2c1812301d836c9a0d38532988362ea3
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Roman Gushchin <guro@fb.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit afaf07a65ddbdd70871cc3b81463f2a8f3884b6f from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: vmscan: replace shrink_node() loop with a retry jump
Johannes Weiner [Sun, 1 Dec 2019 01:55:43 +0000 (17:55 -0800)]
mm: vmscan: replace shrink_node() loop with a retry jump

Most of the function body is inside a loop, which imposes an additional
indentation and scoping level that makes the code a bit hard to follow and
modify.

The looping only happens in case of reclaim-compaction, which isn't the
common case.  So rather than adding yet another function level to the
reclaim path and have every reclaim invocation go through a level that
only exists for one specific cornercase, use a retry goto.

Link: http://lkml.kernel.org/r/20191022144803.302233-6-hannes@cmpxchg.org
Change-Id: Iab1ead6005f957bd8bbb3fcfa48e63d0ae3592a3
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Roman Gushchin <guro@fb.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit d2af339706be318dadcbe14c8935426ff401d7b1 from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: vmscan: naming fixes: global_reclaim() and sane_reclaim()
Johannes Weiner [Sun, 1 Dec 2019 01:55:40 +0000 (17:55 -0800)]
mm: vmscan: naming fixes: global_reclaim() and sane_reclaim()

Seven years after introducing the global_reclaim() function, I still have
to double take when reading a callsite.  I don't know how others do it,
this is a terrible name.

Invert the meaning and rename it to cgroup_reclaim().

[ After all, "global reclaim" is just regular reclaim invoked from the
  page allocator. It's reclaim on behalf of a cgroup limit that is a
  special case of reclaim, and should be explicit - not the reverse. ]

sane_reclaim() isn't very descriptive either: it tests whether we can use
the regular writeback throttling - available during regular page reclaim
or cgroup2 limit reclaim - or need to use the broken
wait_on_page_writeback() method.  Use "writeback_throttling_sane()".

Link: http://lkml.kernel.org/r/20191022144803.302233-5-hannes@cmpxchg.org
Change-Id: Ie173107736712471293c47ee9692c3a98b4ca7da
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Roman Gushchin <guro@fb.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit b5ead35e7e1d3434ce436dfcb2af32820ce54589 from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: vmscan: move inactive_list_is_low() swap check to the caller
Johannes Weiner [Sun, 1 Dec 2019 01:55:37 +0000 (17:55 -0800)]
mm: vmscan: move inactive_list_is_low() swap check to the caller

inactive_list_is_low() should be about one thing: checking the ratio
between inactive and active list.  Kitchensink checks like the one for
swap space makes the function hard to use and modify its callsites.
Luckly, most callers already have an understanding of the swap situation,
so it's easy to clean up.

get_scan_count() has its own, memcg-aware swap check, and doesn't even get
to the inactive_list_is_low() check on the anon list when there is no swap
space available.

shrink_list() is called on the results of get_scan_count(), so that check
is redundant too.

age_active_anon() has its own totalswap_pages check right before it checks
the list proportions.

The shrink_node_memcg() site is the only one that doesn't do its own swap
check.  Add it there.

Then delete the swap check from inactive_list_is_low().

Link: http://lkml.kernel.org/r/20191022144803.302233-4-hannes@cmpxchg.org
Change-Id: I16e03de6f88291d52fa3d6be5a999d9a4bd4f450
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Roman Gushchin <guro@fb.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit a108629149cc63cfb6fd446184e3e578e04bcfd1 from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: clean up and clarify lruvec lookup procedure
Johannes Weiner [Sun, 1 Dec 2019 01:55:34 +0000 (17:55 -0800)]
mm: clean up and clarify lruvec lookup procedure

There is a per-memcg lruvec and a NUMA node lruvec.  Which one is being
used is somewhat confusing right now, and it's easy to make mistakes -
especially when it comes to global reclaim.

How it works: when memory cgroups are enabled, we always use the
root_mem_cgroup's per-node lruvecs.  When memory cgroups are not compiled
in or disabled at runtime, we use pgdat->lruvec.

Document that in a comment.

Due to the way the reclaim code is generalized, all lookups use the
mem_cgroup_lruvec() helper function, and nobody should have to find the
right lruvec manually right now.  But to avoid future mistakes, rename the
pgdat->lruvec member to pgdat->__lruvec and delete the convenience wrapper
that suggests it's a commonly accessed member.

While in this area, swap the mem_cgroup_lruvec() argument order.  The name
suggests a memcg operation, yet it takes a pgdat first and a memcg second.
I have to double take every time I call this.  Fix that.

Link: http://lkml.kernel.org/r/20191022144803.302233-3-hannes@cmpxchg.org
Change-Id: Ibe111f47294a8067dbc57683a84583a33477847b
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Cc: Roman Gushchin <guro@fb.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit 2230dc207a325970d54c3ca1efe896a57ea82499 from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm: vmscan: simplify lruvec_lru_size()
Johannes Weiner [Sun, 1 Dec 2019 01:55:31 +0000 (17:55 -0800)]
mm: vmscan: simplify lruvec_lru_size()

Patch series "mm: vmscan: cgroup-related cleanups".

Here are 8 patches that clean up the reclaim code's interaction with
cgroups a bit. They're not supposed to change any behavior, just make
the implementation easier to understand and work with.

This patch (of 8):

This function currently takes the node or lruvec size and subtracts the
zones that are excluded by the classzone index of the allocation.  It uses
four different types of counters to do this.

Just add up the eligible zones.

[cai@lca.pw: fix an undefined behavior for zone id]
Link: http://lkml.kernel.org/r/20191108204407.1435-1-cai@lca.pw
[akpm@linux-foundation.org: deal with the MAX_NR_ZONES special case. per Qian Cai]
Link: http://lkml.kernel.org/r/64E60F6F-7582-427B-8DD5-EF97B1656F5A@lca.pw
Link: http://lkml.kernel.org/r/20191022144803.302233-2-hannes@cmpxchg.org
Change-Id: I2d00ef6cd83336d904ac58cea129404c6ba5451c
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reviewed-by: Roman Gushchin <guro@fb.com>
Reviewed-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit 78a3ee9c29c881feeb716fe70218c4fd2a7c342c from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
4 months agomm/vmscan: remove unused lru_pages argument
Andrey Ryabinin [Sun, 1 Dec 2019 01:55:24 +0000 (17:55 -0800)]
mm/vmscan: remove unused lru_pages argument

Since 9092c71bb724 ("mm: use sc->priority for slab shrink targets") the
argument 'unsigned long *lru_pages' passed around with no purpose.  Remove
it.

Link: http://lkml.kernel.org/r/20190228083329.31892-4-aryabinin@virtuozzo.com
Change-Id: I8a61dd9dab063e9db2d58aafe71f5a6238a3a525
Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Mel Gorman <mgorman@techsingularity.net>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Rik van Riel <riel@surriel.com>
Cc: William Kucharski <william.kucharski@oracle.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[backport of the commit c42875e38b6fb9546f665a397b66e3a4cc2e5041 from mainline]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
3 years agoARM64: tizen_bcm2711_defconfig: Enable USB_PRINTER config 09/255809/1 old/tizen_20210330 accepted/tizen/unified/20210330.084808 submit/tizen/20210329.080334
Chanwoo Choi [Wed, 24 Mar 2021 03:45:52 +0000 (12:45 +0900)]
ARM64: tizen_bcm2711_defconfig: Enable USB_PRINTER config

Enable USB_PRINTER config to suppot USB printer device.

Change-Id: I2068a283928c8f3c85d5f31b25a13300cdc52783
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agoARM: tizen_bcm2711_defconfig: Enable USB_PRINTER config 08/255808/1
Chanwoo Choi [Wed, 24 Mar 2021 03:44:24 +0000 (12:44 +0900)]
ARM: tizen_bcm2711_defconfig: Enable USB_PRINTER config

Enable USB_PRINTER config to suppot USB printer device.

Change-Id: Ic63797d93520e4bc50175c53c7e7328b55a0f724
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agoARM64: tizen_bcm2711_defconfig: Enable CONFIG_CFG80211_CRDA_SUPPORT 69/255669/1
Jaehoon Chung [Mon, 22 Mar 2021 08:06:33 +0000 (17:06 +0900)]
ARM64: tizen_bcm2711_defconfig: Enable CONFIG_CFG80211_CRDA_SUPPORT

Enable CONFIG_CFG80211_CRDA_SUPPORT.

Change-Id: If60cab97a05ca8bc01633255ede56279fcc599a8
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agoRevert "ARM: configs: tizen_bcm2711_defconfig: Disable CONFIG_CFG80211_CRDA_SUPPORT" 68/255668/1
Jaehoon Chung [Mon, 22 Mar 2021 07:56:08 +0000 (16:56 +0900)]
Revert "ARM: configs: tizen_bcm2711_defconfig: Disable CONFIG_CFG80211_CRDA_SUPPORT"

This reverts commit 6485924bd76b70c8ed6ba334ef9b5045f4a3686d.
- Enable CONFIG_CFG80211_CRDA_SUPPORT to use country code.

Change-Id: I951b32c86611b6240991e9bb8b362c98bb56b72c
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agomedia: uvcvideo: Add a probe quirk to Jieli Technology USB PHY 2.0 (1224:2a25) 72/254272/1 accepted/tizen/unified/20210303.130703 submit/tizen/20210303.050006
Seung-Woo Kim [Thu, 25 Feb 2021 08:17:12 +0000 (17:17 +0900)]
media: uvcvideo: Add a probe quirk to Jieli Technology USB PHY 2.0 (1224:2a25)

Repeated video request on Jieli Technology USB PHY 2.0 (1224:2a25)
device causes data stall with below error until reconnection:
  uvcvideo: Failed to set UVC probe control : -32 (exp. 26).

To resolve the wrong state, add PROBE quirk bits.

Change-Id: I5efba6ac26d5eea70e2227f9ff9801dd5d8d4790
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agoARM/ARM64: defconfig: disable SECURITY_SMACK_NETFILTER config 09/253709/1 accepted/tizen/unified/20210217.120458 submit/tizen/20210217.042922
Jaehoon Chung [Wed, 17 Feb 2021 01:02:48 +0000 (10:02 +0900)]
ARM/ARM64: defconfig: disable SECURITY_SMACK_NETFILTER config

Disable SECURITY_SMACK_NETFILTER configuration.

Change-Id: Id95847392ac2bf53b92dae5ee2c0d4b5c1e41ece
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agoARM: tizen_bcm2711_defconfig: Enable OVERLAY_FS 78/252178/1 accepted/tizen/unified/20210126.141628 submit/tizen/20210125.080748
Seung-Woo Kim [Mon, 25 Jan 2021 07:24:54 +0000 (16:24 +0900)]
ARM: tizen_bcm2711_defconfig: Enable OVERLAY_FS

Enable CONFIG_OVERLAY_FS for tizen application space.

Change-Id: I46b011effa26e1f7ef9acf5f18d52bc7b54452c5
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agoARM64: tizen_bcm2711_defconfig: Enable OVERLAY_FS 77/252177/1
Seung-Woo Kim [Mon, 25 Jan 2021 07:24:03 +0000 (16:24 +0900)]
ARM64: tizen_bcm2711_defconfig: Enable OVERLAY_FS

Enable CONFIG_OVERLAY_FS for tizen application space.

Change-Id: I1b2aafaeea24b6ef6b07d3c57d542dce13c53b8f
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agousb: gadget: f_fs: Fix use-after-free for unbind with remaining io 37/252037/1 accepted/tizen/unified/20210122.123002 submit/tizen/20210122.073514
Dongwoo Lee [Fri, 22 Jan 2021 03:40:18 +0000 (12:40 +0900)]
usb: gadget: f_fs: Fix use-after-free for unbind with remaining io

If usb has stall, then there can be remaining submitted io and
unbinding f_fs with the remaining io, there is use-after-free.
Fix the use-after-free by checking endpoint after wait.

This fixes following kasan warning:
   BUG: KASAN: use-after-free in ffs_epfile_io+0x654/0xb58
   Read of size 4 at addr ffffffc0a44e65dc by task mtp-responder/5117
   ...
   [<ffffff900a037794>] ffs_epfile_io+0x654/0xb58
   [<ffffff900a03818c>] ffs_epfile_read_iter+0x1ac/0x3e0
   ...

   Allocated by task 3869:
   ...
    __kmalloc+0x234/0x760
    _ffs_func_bind+0x264/0x7c8
    ffs_func_bind+0xe8/0x650
    usb_add_function+0x13c/0x378
   ...
   Freed by task 3869:
   ...
    kfree+0xa4/0x750
    ffs_func_unbind+0x150/0x248
    purge_configs_funcs+0x1a0/0x310
   ...

Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
[dwoo08.lee: cherry-picked from linux-amlogic commit 5dd3ffecd46f to prevent use-after-free when f_fs is unbound before all requests are over]
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
Change-Id: Idf2391c53ca0f90fc9484d725304b88fc57fa8a6

3 years agokdbus: build and package kdbus-tests 13/251413/5 accepted/tizen/unified/20210119.130216 submit/tizen/20210119.051826
Łukasz Stelmach [Tue, 22 Dec 2020 11:56:00 +0000 (12:56 +0100)]
kdbus: build and package kdbus-tests

Change-Id: Ie5a32cb744a28b242aac1f43e879306a43795bb5
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
3 years agokdbus: test suite changed to common format 12/251412/5
Konrad Lipinski [Wed, 11 Sep 2019 13:42:10 +0000 (15:42 +0200)]
kdbus: test suite changed to common format

This commit adapts the kdbus test suite to use with
dbus-integration-tests.

Change-Id: Ifee21253f4e3c732b27517a0c566d4b9a569d5af
Signed-off-by: Adrian Szyndela <adrian.s@samsung.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
3 years agoARM/ARM64: tizen_bcm2711_defconfig: Enable KDBUS 76/251476/3
Łukasz Stelmach [Thu, 14 Jan 2021 06:02:02 +0000 (15:02 +0900)]
ARM/ARM64: tizen_bcm2711_defconfig: Enable KDBUS

Change-Id: I3f40022fa9bbb04a0cbcca1fde45a569ca2c4538
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agokdbus: porting to to 5.4 11/251411/4
Łukasz Stelmach [Mon, 21 Dec 2020 15:34:08 +0000 (16:34 +0100)]
kdbus: porting to to 5.4

The following changes were made to adapt kdbus driver to 5.4 kernel

- use KERNEL_DS instead of get_ds()
- remove ITER_KVEC flag
- remove 'type' argument from access_ok()
- use memfd_fcntl() instead of shmem_get_seals()
- use uapi/linux/mount.h

Fixes: 736706bee329 ("get rid of legacy 'get_ds()' function")
Fixes: aa563d7bca6e ("iov_iter: Separate type from direction and use accessor functions")
Fixes: 96d4f267e40f ("Remove 'type' argument from access_ok() function")
Fixes: 5aadc431a593 ("shmem: rename functions that are memfd-related")
Fixes: 5d752600a8c3 ("mm: restructure memfd code")
Fixes: e262e32d6bde ("vfs: Suppress MS_* flag defs within the kernel unless explicitly enabled")
Change-Id: I8d2b3db1c83bb21114554ba9eb38e5e439f5c141
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
3 years agokdbus: Revert "fs: unexport poll_schedule_timeout" 10/251410/4
Łukasz Stelmach [Mon, 21 Dec 2020 11:40:27 +0000 (12:40 +0100)]
kdbus: Revert "fs: unexport poll_schedule_timeout"

This reverts commit 8f546ae1fc5ce8396827d4868c7eee1f1cc6947a.

Change-Id: I5429471eeb092c55a50e37c0b642d50d69daebc7
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
3 years agokdbus: porting to 4.14 09/251409/4
Adrian Szyndela [Wed, 11 Sep 2019 13:34:33 +0000 (15:34 +0200)]
kdbus: porting to 4.14

This commit makes kdbus driver working with kernel 4.14.
It also enabled compilation of the driver if enabled in config.

The list of changes needed to make it compile with kernel 4.14:
- Add missing includes for <linux/cred.h>
- put inode_lock()/inode_unlock() in place of explicit mutex locking
- replace CURRENT_TIME with proper call to current_time()
- replace PAGE_CACHE_* with PAGE_*
- replace GFP_TEMPORARY with GFP_KERNEL
- use kvecs for kernel memory, iovec for user memory instead of only iovec
  for both
- fix usage of task_cgroup_path()
- replace GROUP_AT usage with 'gid' field dereference
- add 0 as an argument to init_name_hash
- add 0 as flags as an argument to vfs_iter_write
- replace __vfs_read with kernel_read to allow compilation into module

Change-Id: I3dd066ab531d0d3f7082556e4d38381961998015
Signed-off-by: Adrian Szyndela <adrian.s@samsung.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
3 years agokdbus: the driver, original and non-working 08/251408/4
Adrian Szyndela [Fri, 9 Sep 2016 11:35:49 +0000 (13:35 +0200)]
kdbus: the driver, original and non-working

[based on commit 216823ac83c0ab89348e2ed6f66179f53626586e]

Introduce the kdbus driver again. This driver worked previously
on kernel 4.1. This is the source code taken from the working driver.
It is non-working and disabled. It is a base for porting.

The documentation is moved from Documentation to ipc/kdbus/Documentation.

The references to kdbus source code are commented out or removed in Makefiles.

Original authors of the files are those from commit 216823ac83c0ab8934.

Cherry-picked from 4.14 commit 970070c4f68f113284f86cf7b6fbd23d6b35b511.

Change-Id: Id60af5faf794fc4ae7122976621076f1021f6c38
Signed-off-by: Adrian Szyndela <adrian.s@samsung.com>
Signed-off-by: Hyotaek Shim <hyotaek.shim@samsung.com>
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
3 years agospec: set CONFIG_LOCALVERSION 07/251407/4
Łukasz Stelmach [Mon, 4 Jan 2021 19:23:41 +0000 (20:23 +0100)]
spec: set CONFIG_LOCALVERSION

Set CONFIG_LOCALVERSION insetad of EXTRAVERSION in Makefile to carry
information about the platform variant.

Change-Id: If1650692162832ea86988e4adb610ce0148edde3
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
3 years agospec: support gbs(1) incremental builds 06/251406/4
Łukasz Stelmach [Mon, 4 Jan 2021 13:41:58 +0000 (14:41 +0100)]
spec: support gbs(1) incremental builds

gbs(1) enable incremental builds that are significantly faster, hoewever,
spec files need some adjustments.

+ You can't use -n <name> with %setup
+ There is no point in making mrproper
+ use rsync(1) instead of cp(1)+find(1) to copy devel files

Other changes are:
+ use make headers_install to install headers in the buildroot
+ add _smp_mflags to make(1) things faster

Change-Id: Ia14fbe7acab8b83683f9e07757b4f62a7657b2a5
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
3 years agoscript: adjust ccache support 05/251405/2
Łukasz Stelmach [Mon, 21 Dec 2020 12:46:37 +0000 (13:46 +0100)]
script: adjust ccache support

Change-Id: I735295fc21cf7caa29b84548a8f21449ed97800e
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
3 years agoscript: increase the number of concurrent compilers 04/251404/1
Łukasz Stelmach [Wed, 13 Jan 2021 10:24:40 +0000 (11:24 +0100)]
script: increase the number of concurrent compilers

It is safe to run as many compilation processes as twice the number of
CPUs. This is the default settings of RPM building process in Tizen.

Change-Id: Id68d9d31bc54da11c8732689645408241a517887
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
3 years agoscript: use $NCPUS for arm64 builds too 03/251403/1
Łukasz Stelmach [Wed, 13 Jan 2021 10:12:04 +0000 (11:12 +0100)]
script: use $NCPUS for arm64 builds too

Fixes: b371be68152e ("script: Fix to use NCPUS dynamically")
Change-Id: I32b5c08f4b00ca24032a2f9355d308f3df825fbd
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
3 years agoARM: mm: Free memblock from free_initrd_mem() 95/251095/1 accepted/tizen/unified/20210111.125453 submit/tizen/20210111.031323
Seung-Woo Kim [Thu, 7 Jan 2021 09:09:20 +0000 (18:09 +0900)]
ARM: mm: Free memblock from free_initrd_mem()

Even after free_initrd_mem(), memblock for initrd remains. Free
memblock for initrd from free_initrd_mem().

Reported-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
[sw0312.kim: port mainline posted patch to 5.4.y]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I42a7461558868cdfdc559959112c81bc4c8b10c5

3 years agoARM: dts: bcm2711-rpi-4-b: Adjust CMA size due to the OOM issue 27/251027/2 accepted/tizen/unified/20210107.123346 submit/tizen/20210107.044235
Sung-hun Kim [Thu, 7 Jan 2021 04:01:01 +0000 (13:01 +0900)]
ARM: dts: bcm2711-rpi-4-b: Adjust CMA size due to the OOM issue

Since 32-bit kernel has a limitation in the lowmem size, big CMA size
severely affect on available memory for kernel. Because of that, some test
cases make OOM kills due to the exhaustion in kernel available memory that
was reported by Jaehoon Chung (jh80.chung@samsung.com).

To handle this, I adjusted CMA size to 400MB while it meets the requirement
for UHD resolution.

Change-Id: I189699d4ce5f2866c01edf68c8138e9278679188
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
3 years agomm, page_alloc: fix core hung in free_pcppages_bulk() 24/250724/1
Charan Teja Reddy [Fri, 21 Aug 2020 00:42:27 +0000 (17:42 -0700)]
mm, page_alloc: fix core hung in free_pcppages_bulk()

commit 88e8ac11d2ea3acc003cf01bb5a38c8aa76c3cfd upstream.

The following race is observed with the repeated online, offline and a
delay between two successive online of memory blocks of movable zone.

P1 P2

Online the first memory block in
the movable zone. The pcp struct
values are initialized to default
values,i.e., pcp->high = 0 &
pcp->batch = 1.

Allocate the pages from the
movable zone.

Try to Online the second memory
block in the movable zone thus it
entered the online_pages() but yet
to call zone_pcp_update().
This process is entered into
the exit path thus it tries
to release the order-0 pages
to pcp lists through
free_unref_page_commit().
As pcp->high = 0, pcp->count = 1
proceed to call the function
free_pcppages_bulk().
Update the pcp values thus the
new pcp values are like, say,
pcp->high = 378, pcp->batch = 63.
Read the pcp's batch value using
READ_ONCE() and pass the same to
free_pcppages_bulk(), pcp values
passed here are, batch = 63,
count = 1.

Since num of pages in the pcp
lists are less than ->batch,
then it will stuck in
while(list_empty(list)) loop
with interrupts disabled thus
a core hung.

Avoid this by ensuring free_pcppages_bulk() is called with proper count of
pcp list pages.

The mentioned race is some what easily reproducible without [1] because
pcp's are not updated for the first memory block online and thus there is
a enough race window for P2 between alloc+free and pcp struct values
update through onlining of second memory block.

With [1], the race still exists but it is very narrow as we update the pcp
struct values for the first memory block online itself.

This is not limited to the movable zone, it could also happen in cases
with the normal zone (e.g., hotplug to a node that only has DMA memory, or
no other memory yet).

[1]: https://patchwork.kernel.org/patch/11696389/

Fixes: 5f8dcc21211a ("page-allocator: split per-cpu list into one-list-per-migrate-type")
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand <david@redhat.com>
Acked-by: David Rientjes <rientjes@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: Vinayak Menon <vinmenon@codeaurora.org>
Cc: <stable@vger.kernel.org> [2.6+]
Link: http://lkml.kernel.org/r/1597150703-19003-1-git-send-email-charante@codeaurora.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[sw0312.kim: cherry-pick linux-5.4.y commit 0cfb9320d00c to resolved too larget cma issue]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I55f884f9950a35c8d75affebe426d176cd91702b

3 years agomm: include CMA pages in lowmem_reserve at boot 23/250723/1
Doug Berger [Fri, 21 Aug 2020 00:42:24 +0000 (17:42 -0700)]
mm: include CMA pages in lowmem_reserve at boot

commit e08d3fdfe2dafa0331843f70ce1ff6c1c4900bf4 upstream.

The lowmem_reserve arrays provide a means of applying pressure against
allocations from lower zones that were targeted at higher zones.  Its
values are a function of the number of pages managed by higher zones and
are assigned by a call to the setup_per_zone_lowmem_reserve() function.

The function is initially called at boot time by the function
init_per_zone_wmark_min() and may be called later by accesses of the
/proc/sys/vm/lowmem_reserve_ratio sysctl file.

The function init_per_zone_wmark_min() was moved up from a module_init to
a core_initcall to resolve a sequencing issue with khugepaged.
Unfortunately this created a sequencing issue with CMA page accounting.

The CMA pages are added to the managed page count of a zone when
cma_init_reserved_areas() is called at boot also as a core_initcall.  This
makes it uncertain whether the CMA pages will be added to the managed page
counts of their zones before or after the call to
init_per_zone_wmark_min() as it becomes dependent on link order.  With the
current link order the pages are added to the managed count after the
lowmem_reserve arrays are initialized at boot.

This means the lowmem_reserve values at boot may be lower than the values
used later if /proc/sys/vm/lowmem_reserve_ratio is accessed even if the
ratio values are unchanged.

In many cases the difference is not significant, but for example
an ARM platform with 1GB of memory and the following memory layout

  cma: Reserved 256 MiB at 0x0000000030000000
  Zone ranges:
    DMA      [mem 0x0000000000000000-0x000000002fffffff]
    Normal   empty
    HighMem  [mem 0x0000000030000000-0x000000003fffffff]

would result in 0 lowmem_reserve for the DMA zone.  This would allow
userspace to deplete the DMA zone easily.

Funnily enough

  $ cat /proc/sys/vm/lowmem_reserve_ratio

would fix up the situation because as a side effect it forces
setup_per_zone_lowmem_reserve.

This commit breaks the link order dependency by invoking
init_per_zone_wmark_min() as a postcore_initcall so that the CMA pages
have the chance to be properly accounted in their zone(s) and allowing
the lowmem_reserve arrays to receive consistent values.

Fixes: bc22af74f271 ("mm: update min_free_kbytes from khugepaged after core initialization")
Signed-off-by: Doug Berger <opendmb@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Jason Baron <jbaron@akamai.com>
Cc: David Rientjes <rientjes@google.com>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Cc: <stable@vger.kernel.org>
Link: http://lkml.kernel.org/r/1597423766-27849-1-git-send-email-opendmb@gmail.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[sw0312.kim: cherry-pick linux-5.4.y commit 5663159e2930 to resolve too larget cma issue]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I59cbe93ed28f09d08dced520667b32e2fb030c21

3 years agoARM: dts: bcm2711-rpi-4-b: Fix CMA size to 512M 27/250127/1 accepted/tizen/unified/20201222.122545 submit/tizen/20201222.024625
Hoegeun Kwon [Mon, 21 Dec 2020 04:54:55 +0000 (13:54 +0900)]
ARM: dts: bcm2711-rpi-4-b: Fix CMA size to 512M

Increase cma size to 512 for use 4k GL on tizen platform.

When using RPI4 1GB model + 4k UHD, reclaim occurs a lot and it is slow.

Change-Id: Iac60a9fa0d5f76085e60cbf3db9a90585597de57
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
3 years agoRevert "ALSA: usb-audio: Improve frames size computation" 27/249927/1 accepted/tizen/6.0/unified/20210121.212556 accepted/tizen/6.0/unified/hotfix/20210121.101657 accepted/tizen/unified/20201218.124446 submit/tizen/20201218.004559 submit/tizen_6.0/20210121.055004 submit/tizen_6.0_hotfix/20210121.065852
Greg Kroah-Hartman [Tue, 7 Jul 2020 12:42:38 +0000 (14:42 +0200)]
Revert "ALSA: usb-audio: Improve frames size computation"

This reverts commit aba41867dd66939d336fdf604e4d73b805d8039f which is
commit f0bd62b64016508938df9babe47f65c2c727d25c upstream.

It causes a number of reported issues and a fix for it has not hit
Linus's tree yet.  Revert this to resolve those problems.

Cc: Alexander Tsoy <alexander@tsoy.me>
Cc: Takashi Iwai <tiwai@suse.de>
Cc: Sasha Levin <sashal@kernel.org>
Cc: Hans de Goede <jwrdegoede@fedoraproject.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[sw0312.kim: cherry-pick linux-5.4.y commit e0ed5a36fb3a to fix specific usb-audio distortion issue]
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I9e7ca39dddc28d8c29bf0488419c1fbdbddfb61a

3 years agoscript: Fix to use NCPUS dynamically 28/249728/1
Hoegeun Kwon [Mon, 14 Dec 2020 14:24:34 +0000 (23:24 +0900)]
script: Fix to use NCPUS dynamically

It uses NCPUS dynamically.

Change-Id: Ib7b1229f387b9c91f4eb2b29cc8f3bfe207fcaaa
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@gmail.com>
3 years agostaging: vc04_services: codec: Fix component enable/disable 09/249309/1 accepted/tizen/unified/20201211.124322 submit/tizen/20201211.031336
Dave Stevenson [Thu, 13 Aug 2020 16:04:53 +0000 (17:04 +0100)]
staging: vc04_services: codec: Fix component enable/disable

start_streaming enabled the VPU component if ctx->component_enabled
was not set.
stop_streaming disabled the VPU component if both ports were
disabled. It didn't clear ctx->component_enabled.

If seeking, this meant that the component never got re-enabled,
and buffers never got processed afterwards.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
[sw0312.kim: cherry-pick rpi-5.4.y commit to fix video decoding seek issue]
Ref: https://github.com/raspberrypi/linux/pull/3790
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: Ibf27e3ed2dc3d98d64a78b10878d6339d77f8a33

3 years agostaging: vc04_service: codec: Allow start_streaming to update the buffernum 08/249308/1
Dave Stevenson [Thu, 13 Aug 2020 16:01:27 +0000 (17:01 +0100)]
staging: vc04_service: codec: Allow start_streaming to update the buffernum

start_streaming passes a count of how many buffers have been queued
to videobuf2.

Allow this value to update the number of buffers the VPU allocates
on a port to avoid buffer recycling issues.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
[sw0312.kim: cherry-pick rpi-5.4.y commit to fix video decoding seek issue]
Ref: https://github.com/raspberrypi/linux/pull/3790
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: Iaf37f57df95789cc8987b268feab1f0fa7377849

3 years agostaging: vc04_services: codec: Fix incorrect buffer cleanup 07/249307/1
Dave Stevenson [Thu, 13 Aug 2020 15:58:18 +0000 (16:58 +0100)]
staging: vc04_services: codec: Fix incorrect buffer cleanup

The allocated input and output buffers are initialised in
buf_init and should only be cleared up in buf_cleanup.
stop_streaming was (incorrectly) cleaning up the buffers to
avoid an issue in videobuf2 that had been fixed by the orphaned
buffer support.

Remove the erroneous cleanup.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
[sw0312.kim: cherry-pick rpi-5.4.y commit to fix video decoding seek issue]
Ref: https://github.com/raspberrypi/linux/pull/3790
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
Change-Id: I38e3a257a941753b02e448d6d5dd1c8486b648f1

3 years agoARM: tizen_bcm2711_defconfig: Fix console loglevel for logo display 44/247244/2
Hoegeun Kwon [Mon, 9 Nov 2020 07:44:46 +0000 (16:44 +0900)]
ARM: tizen_bcm2711_defconfig: Fix console loglevel for logo display

Modifiy CONSOLE_LOGLEVEL_QUIET defconfig to 3 for logo display.

Change-Id: Idae234c40304fbe8fd5f02941e53505a6bd189fa
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
3 years agoarm64: tizen_bcm2711_defconfig: Fix console loglevel for logo display 25/247225/2
Hoegeun Kwon [Mon, 9 Nov 2020 07:03:59 +0000 (16:03 +0900)]
arm64: tizen_bcm2711_defconfig: Fix console loglevel for logo display

Modifiy CONSOLE_LOGLEVEL_QUIET defconfig to 3 for logo display.

Change-Id: I5112d85dedd1e116a75af0d07c09d77182ff4f5a
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
3 years agorpi4: boot: config: Enable hdmi_force_hotplug 07/246707/1 accepted/tizen/unified/20201105.124359 submit/tizen/20201104.114006
Hoegeun Kwon [Tue, 3 Nov 2020 08:09:20 +0000 (17:09 +0900)]
rpi4: boot: config: Enable hdmi_force_hotplug

There is a problem that the booting stops when booting without connecting
HDMI. To fix it we need to enable hdmi_force_hotplug.

Change-Id: I44e960a04f75c999ab69a75ad72d67311f8b70c1
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
3 years agodrm/vc4: kms: Don't disable the muxing of an active CRTC 06/246706/1
Maxime Ripard [Tue, 3 Nov 2020 08:09:17 +0000 (17:09 +0900)]
drm/vc4: kms: Don't disable the muxing of an active CRTC

The current HVS muxing code will consider the CRTCs in a given state to
setup their muxing in the HVS, and disable the other CRTCs muxes.

However, it's valid to only update a single CRTC with a state, and in this
situation we would mux out a CRTC that was enabled but left untouched by
the new state.

Fix this by setting a flag on the CRTC state when the muxing has been
changed, and only change the muxing configuration when that flag is there.

Fixes: 87ebcd42fb7b ("drm/vc4: crtc: Assign output to channel automatically")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
[hoegeun.kwon: Needed to fix page flip issue of dual hdmi and for enable
force hotplug configure. ]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: I5c9fb79c9ad07caa8fe77ea724f35c955df6edcf

3 years agodrm/vc4: kms: Store the unassigned channel list in the state 05/246705/1
Maxime Ripard [Tue, 3 Nov 2020 08:09:14 +0000 (17:09 +0900)]
drm/vc4: kms: Store the unassigned channel list in the state

If a CRTC is enabled but not active, and that we're then doing a page
flip on another CRTC, drm_atomic_get_crtc_state will bring the first
CRTC state into the global state, and will make us wait for its vblank
as well, even though that might never occur.

Instead of creating the list of the free channels each time atomic_check
is called, and calling drm_atomic_get_crtc_state to retrieve the
allocated channels, let's create a private state object in the main
atomic state, and use it to store the available channels.

Fixes: 87ebcd42fb7b ("drm/vc4: crtc: Assign output to channel automatically")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
[hoegeun.kwon: Needed to fix page flip issue of dual hdmi and for enable
force hotplug configure. fix to unsigned long unassigned_channels instead
of integer to fix build errors.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: Ic8bf07502f614595070e21ecc7912e671a193b09

3 years agodrm/vc4: kms: Add functions to create the state objects 04/246704/1
Maxime Ripard [Tue, 3 Nov 2020 08:09:12 +0000 (17:09 +0900)]
drm/vc4: kms: Add functions to create the state objects

We're going to add a new private state, so let's move the previous state
function creation to some functions to make further additions easier.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
[hoegeun.kwon: Needed to fix page flip issue of dual hdmi and for enable
force hotplug configure.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: Ice57c56dfbdfbb81f486cba7626512cfbb12b905

3 years agodrm/vc4: kms: Rename NUM_CHANNELS 03/246703/1
Maxime Ripard [Tue, 3 Nov 2020 08:09:01 +0000 (17:09 +0900)]
drm/vc4: kms: Rename NUM_CHANNELS

The NUM_CHANNELS define has a pretty generic name and was right before the
function using it. Let's move to something that makes the hardware-specific
nature more obvious, and to a more appropriate place.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
[hoegeun.kwon: Needed to fix page flip issue of dual hdmi and for enable
force hotplug configure.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: Ib94c2b3ffbc7e5c95f2c3a965919e523c68f8a12

3 years agodrm/vc4: kms: Remove useless define 02/246702/1
Maxime Ripard [Tue, 3 Nov 2020 08:08:59 +0000 (17:08 +0900)]
drm/vc4: kms: Remove useless define

NUM_OUTPUTS isn't used anymore, let's remove it.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
[hoegeun.kwon: Needed to fix page flip issue of dual hdmi and for enable
force hotplug configure.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: I20b47a2da045094a06cef9e9a924f46c4dd1d4a9

3 years agoRevert "drm/vc4: kms: Don't disable the muxing of an active CRTC" 01/246701/1
Hoegeun Kwon [Tue, 3 Nov 2020 08:08:57 +0000 (17:08 +0900)]
Revert "drm/vc4: kms: Don't disable the muxing of an active CRTC"

This reverts commit 5d2fec61a25bacc49ee8e84b3c19aee1522f7289.

Revert this patch for apply patch version 2.

Change-Id: Ib7ff9b242dc3f208cf58f7d8f0741321b725c657
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
3 years agoRevert "drm/vc4: kms: Fix VBLANK reporting on a disabled CRTC" 00/246700/1
Hoegeun Kwon [Tue, 3 Nov 2020 08:08:54 +0000 (17:08 +0900)]
Revert "drm/vc4: kms: Fix VBLANK reporting on a disabled CRTC"

This reverts commit e805316d5d44b1f1f080fd8ae8a34b69329d940c.

Revert this patch for apply patch version 2.

Change-Id: If9525aaa3835ab80b8ca83271dc584f68254018a
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
3 years agomm: LKSM: bug fix for KASAN out-of-bound access error on accessing a filter 44/246344/3 accepted/tizen/unified/20201102.124307 submit/tizen/20201030.062213
Sung-hun Kim [Wed, 28 Oct 2020 10:26:31 +0000 (19:26 +0900)]
mm: LKSM: bug fix for KASAN out-of-bound access error on accessing a filter

KASAN reports out-of-bound accesses (reported by Jaehoon Chung)
on slab which is performed for obtaining a next filtered
address to find a sharable page.

LKSM exploits bitmap-based filters to find sharable pages in
an efficient way. A buggy code is a kind of miscalculation for
boundary of the allocated bitmap. This patch takes care of it.

Change-Id: If45c5ce175db067523b60f11e69e12d2bc798659
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
3 years agomm: LKSM: bug fix for kernel memory leak 43/246343/2
Sung-hun Kim [Tue, 27 Oct 2020 11:48:36 +0000 (20:48 +0900)]
mm: LKSM: bug fix for kernel memory leak

For efficiency, LKSM cleans exited processes in a batched manner when it
finishes a scanning iteration. When it finds exited process while it is in
the scanning iteration, it just pends the mm_slot of the exited process to
the internal list.

On the other hend, when KSM daemon cleans mm_slots of exited processes, it
should care regions of exited processes to remove unreferenced lksm_region
objects.

Previously, most regions are maintained properly but only regions in "head"
of the exited process list does not be cleaned due to the buggy implementation.
At last, uncleaned objects are remained as unreferenced garbages.

Follow message is detected by kmemleak (reported by Suengwoo Kim):
=========================================================================
unreferenced object 0xffffff80c7083600 (size 128):
  comm "ksm_crawld", pid 41, jiffies 4294918362 (age 95.632s)
  hex dump (first 32 bytes):
    00 37 08 c7 80 ff ff ff 60 82 19 bd 80 ff ff ff  .7......`.......
    00 35 08 c7 80 ff ff ff 00 00 00 00 00 00 00 00  .5..............
  backtrace:
    [<0000000048313958>] kmem_cache_alloc_trace+0x1e0/0x348
    [<00000000fd246822>] lksm_region_ref_append+0x48/0xf8
    [<00000000c5a818a0>] ksm_join+0x3a0/0x498
    [<00000000b2c3f36a>] lksm_prepare_full_scan+0xe8/0x390
    [<00000000013943b5>] lksm_crawl_thread+0x214/0xbf8
    [<00000000b4ce0593>] kthread+0x1b0/0x1b8
    [<000000002a3f7216>] ret_from_fork+0x10/0x18
unreferenced object 0xffffff80c7083700 (size 128):
  comm "ksm_crawld", pid 41, jiffies 4294918362 (age 95.632s)
  hex dump (first 32 bytes):
    00 39 08 c7 80 ff ff ff 00 36 08 c7 80 ff ff ff  .9.......6......
    00 35 08 c7 80 ff ff ff 00 00 00 00 00 00 00 00  .5..............
  backtrace:
    [<0000000048313958>] kmem_cache_alloc_trace+0x1e0/0x348
    [<00000000fd246822>] lksm_region_ref_append+0x48/0xf8
    [<00000000c5a818a0>] ksm_join+0x3a0/0x498
    [<00000000b2c3f36a>] lksm_prepare_full_scan+0xe8/0x390
    [<00000000013943b5>] lksm_crawl_thread+0x214/0xbf8
    [<00000000b4ce0593>] kthread+0x1b0/0x1b8
    [<000000002a3f7216>] ret_from_fork+0x10/0x18
...
=========================================================================

This patch takes care of such possible kernel memory leak problem.

Change-Id: Ifb4963773b8803da239a1d3108c5b2690d22d531
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
3 years agobrcmfmac: Fix memory leak for unpaired brcmf_{alloc/free} 63/246263/1
Seung-Woo Kim [Tue, 27 Oct 2020 10:23:56 +0000 (19:23 +0900)]
brcmfmac: Fix memory leak for unpaired brcmf_{alloc/free}

There are missig brcmf_free() for brcmf_alloc(). Fix memory leak
by adding missed brcmf_free().

Change-Id: I050398a7b828b0fb2aadbe491f353b3d3c47bdd6
Reported-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agodrm/vc4: drv: Add error handding for bind 86/246186/2 accepted/tizen/unified/20201028.123938 submit/tizen/20201027.005200
Hoegeun Kwon [Mon, 26 Oct 2020 11:47:31 +0000 (20:47 +0900)]
drm/vc4: drv: Add error handding for bind

There is a problem that if vc4_drm bind fails, a memory leak occurs on
the drm_property_create side. Add error handding for drm_mode_config.

Change-Id: If23c0dabf01b85368871981f0cba427982922615
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
3 years agostaging: mmal-vchiq: Fix memory leak for vchi_instance 65/246165/1
Seung-Woo Kim [Mon, 26 Oct 2020 07:37:19 +0000 (16:37 +0900)]
staging: mmal-vchiq: Fix memory leak for vchi_instance

The vchi_instance is allocated with vchiq_initialise() but never
handled properly. Fix memory leak for the vchi_instance.

This fixes below kmemleak report:
    [<000000002312557f>] kmem_cache_alloc_trace+0x1e0/0x348
    [<000000002ee5d470>] vchiq_initialise+0xd0/0x258
    [<000000009b51d8f4>] vchi_initialise+0x84/0xc8
    [<00000000a58f68c5>] vchiq_mmal_init+0xb0/0x2f0
    [<000000006c68d7bf>] bcm2835_mmal_probe+0x90/0x660
    ...

Change-Id: Ib10f194aa4058b3e39ec0a250fa36fd00daf9feb
Reported-by: Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agodrm/vc4: kms: Fix VBLANK reporting on a disabled CRTC 42/245642/1
Maxime Ripard [Mon, 12 Oct 2020 03:44:25 +0000 (12:44 +0900)]
drm/vc4: kms: Fix VBLANK reporting on a disabled CRTC

If a CRTC is enabled but not active, and that we're then doing a page flip
on another CRTC, drm_atomic_get_crtc_state will bring the first CRTC state
into the global state, and will make us wait for its vblank as well, even
though that might never occur.

Fix this by considering all the enabled CRTCs by either using their new
state in the global state, or using their current state if they aren't part
of the new state being checked, to remove their assigned channel from the
pool before started to assign channels to CRTCs enabled by the state.

Fixes: 87ebcd42fb7b ("drm/vc4: crtc: Assign output to channel automatically")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
[hoegeun.kwon: Needed to fix page flip issue of dual hdmi.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: Ic8b8083a652df142a17ec0d50f6c2572494ba3c0

3 years agodrm/vc4: kms: Don't disable the muxing of an active CRTC 41/245641/1
Maxime Ripard [Thu, 8 Oct 2020 11:25:18 +0000 (13:25 +0200)]
drm/vc4: kms: Don't disable the muxing of an active CRTC

The current HVS muxing code will consider the CRTCs in a given state to
setup their muxing in the HVS, and disable the other CRTCs muxes.

However, it's valid to only update a single CRTC with a state, and in this
situation we would mux out a CRTC that was enabled but left untouched by
the new state.

Fix this by considering all the CRTCs in the state and the ones with a
state and active.

Fixes: 87ebcd42fb7b ("drm/vc4: crtc: Assign output to channel automatically")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
[hoegeun.kwon: Needed to fix page flip issue of dual hdmi.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: Idb6e79214f52e470e9fcf5a0579873402c631eb2

3 years agodrm/vc4: kms: Fix to split vc4 and vc5 hvs pv muxing commit 40/245640/1
Hoegeun Kwon [Mon, 12 Oct 2020 12:10:58 +0000 (21:10 +0900)]
drm/vc4: kms: Fix to split vc4 and vc5 hvs pv muxing commit

In order to use dual HDMI normally, vc4 and vc5 should be separated.
Split vc4 hvs pv muxing commit and vc5 referring to patch[1].

[1] drm/vc4: crtc: Assign output to channel automatically
    https://cgit.freedesktop.org/drm/drm-misc/commit/?id=87ebcd42fb7b8d1d3269007a621e41ae96a0077e

Change-Id: I5427cfd885c4643f764f8f84bed0f017c5d2a562
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
3 years agodrm/vc4: kms: Document the muxing corner cases 39/245639/1
Maxime Ripard [Thu, 8 Oct 2020 11:25:17 +0000 (13:25 +0200)]
drm/vc4: kms: Document the muxing corner cases

We've had a number of muxing corner-cases with specific ways to reproduce
them, so let's document them to make sure they aren't lost and introduce
regressions later on.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
[hoegeun.kwon: Needed to fix page flip issue of dual hdmi.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: Icc4f82cd0c22f7b0b7e3c33be37d2e9d287638e4

3 years agodrm/vc4: kms: Split the HVS muxing check in a separate function 38/245638/1
Maxime Ripard [Mon, 12 Oct 2020 07:55:43 +0000 (16:55 +0900)]
drm/vc4: kms: Split the HVS muxing check in a separate function

The code that assigns HVS channels during atomic_check is starting to grow
a bit big, let's move it into a separate function.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
[hoegeun.kwon: Needed to fix page flip issue of dual hdmi.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: Icf636a846282981d21ad3e6652a3ec51f14993a4

3 years agodrm/vc4: crtc: Keep the previously assigned HVS FIFO 37/245637/1
Maxime Ripard [Mon, 12 Oct 2020 07:44:43 +0000 (16:44 +0900)]
drm/vc4: crtc: Keep the previously assigned HVS FIFO

The HVS FIFOs are currently assigned each time we have an atomic_check
for all the enabled CRTCs.

However, if we are running multiple outputs in parallel and we happen to
disable the first (by index) CRTC, we end up changing the assigned FIFO
of the second CRTC without disabling and reenabling the pixelvalve which
ends up in a stall and eventually a VBLANK timeout.

In order to fix this, we can create a special value for our assigned
channel to mark it as disabled, and if our CRTC already had an assigned
channel in its previous state, we keep on using it.

Fixes: 87ebcd42fb7b ("drm/vc4: crtc: Assign output to channel automatically")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
[hoegeun.kwon: Needed to fix page flip issue of dual hdmi.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: I70e0d6b563d5c7f22a1a7e1527a401ac42395b78

3 years agodrm/vc4: kms: Assign a FIFO to enabled CRTCs instead of active 36/245636/1
Maxime Ripard [Mon, 12 Oct 2020 04:26:40 +0000 (13:26 +0900)]
drm/vc4: kms: Assign a FIFO to enabled CRTCs instead of active

The HVS has three FIFOs that can be assigned to a number of PixelValves
through a mux.

However, changing that FIFO requires that we disable and then enable the
pixelvalve, so we want to assign FIFOs to all the enabled CRTCs, and not
just the active ones.

Fixes: 87ebcd42fb7b ("drm/vc4: crtc: Assign output to channel automatically")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
[hoegeun.kwon: Needed to fix page flip issue of dual hdmi.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: Id418d321e3cfc9b992bd1868e8084d9f8694a46e

3 years agobrcmfmac: change from brcmf_dbg to brcmf_info 18/245218/1 accepted/tizen/6.0/unified/20201030.104454 accepted/tizen/6.0/unified/hotfix/20201102.235212 accepted/tizen/unified/20201006.080059 submit/tizen/20201006.033113 submit/tizen_6.0/20201029.205501 submit/tizen_6.0_hotfix/20201102.192901 submit/tizen_6.0_hotfix/20201103.115101 tizen_6.0.m2_release
Jaehoon Chung [Mon, 5 Oct 2020 11:39:01 +0000 (20:39 +0900)]
brcmfmac: change from brcmf_dbg to brcmf_info

Change from brcmf_dbg to brcmf_info.
This patch is workaround to check debug message on Testhub.

Change-Id: I7fef8f64fc38e43b6544fab3e9474e7f1829cc60
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agodrm/vc4: hvs: Pull the state of all the CRTCs prior to PV muxing 24/244524/2 accepted/tizen/unified/20200922.053406 submit/tizen/20200922.014449
Maxime Ripard [Thu, 17 Sep 2020 12:16:23 +0000 (14:16 +0200)]
drm/vc4: hvs: Pull the state of all the CRTCs prior to PV muxing

The vc4 display engine has a first controller called the HVS that will
perform the composition of the planes. That HVS has 3 FIFOs and can
therefore compose planes for up to three outputs. The timings part is
generated through a component called the Pixel Valve, and the BCM2711 has 6
of them.

Thus, the HVS has some bits to control which FIFO gets output to which
Pixel Valve. The current code supports that muxing by looking at all the
CRTCs in a new DRM atomic state in atomic_check, and given the set of
constraints that we have, assigns FIFOs to CRTCs or reject the mode
entirely. The actual muxing will occur during atomic_commit.

However, that doesn't work if only a fraction of the CRTCs' state is
updated in that state, since it will ignore the CRTCs that are kept running
unmodified, and will thus unassign its associated FIFO, and later disable
it.

In order to make the code work as expected, let's pull the CRTC state of
all the enabled CRTC in our atomic_check so that we can operate on all the
running CRTCs, no matter whether they are affected by the new state or not.

Fixes: 87ebcd42fb7b ("drm/vc4: crtc: Assign output to channel automatically")
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Tested-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Reviewed-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200917121623.42023-1-maxime@cerno.tech
[hoegeun.kwon: Fix dual hdmi issue]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: I750e253c7415b09e546beb2608445d581c441efe

3 years agodrm/vc4: crtc: Add null pointer error handling 02/244402/1
Hoegeun Kwon [Fri, 18 Sep 2020 06:54:43 +0000 (15:54 +0900)]
drm/vc4: crtc: Add null pointer error handling

Crash occurs when vc4_encoder is null. Add null error handling

  Unable to handle kernel NULL pointer dereference at virtual address 0000000000000090
  Mem abort info:
    ESR = 0x96000005
    EC = 0x25: DABT (current EL), IL = 32 bits
    SET = 0, FnV = 0
    EA = 0, S1PTW = 0
  Data abort info:
    ISV = 0, ISS = 0x00000005
    CM = 0, WnR = 0
  user pgtable: 4k pages, 39-bit VAs, pgdp=00000000f2a96000
  [0000000000000090] pgd=0000000000000000, pud=0000000000000000
  Internal error: Oops: 96000005 [#1] PREEMPT SMP
  Modules linked in: brcmfmac joydev brcmutil rpivid_mem
  CPU: 0 PID: 32 Comm: kworker/0:1 Not tainted 5.4.50-v8+ #414
  Hardware name: Raspberry Pi 4 Model B (DT)
  Workqueue: events output_poll_execute
  pstate: 80000005 (Nzcv daif -PAN -UAO)
  pc : vc4_crtc_atomic_disable+0x150/0x2e8
  lr : vc4_crtc_atomic_disable+0x50/0x2e8
  ...
  Call trace:
   vc4_crtc_atomic_disable+0x150/0x2e8
   drm_atomic_helper_commit_modeset_disables+0x344/0x410
   vc4_atomic_complete_commit+0xd4/0x530
   vc4_atomic_commit+0xf4/0x190
   drm_atomic_commit+0x54/0x60
   ...

Change-Id: Ib3271bb3c8318079fe5815711f89a217e835adc6
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
3 years agoscripts: mkbootimg_rpi4.sh: use compress image 65/244165/1
Seung-Woo Kim [Tue, 15 Sep 2020 09:48:22 +0000 (18:48 +0900)]
scripts: mkbootimg_rpi4.sh: use compress image

Use compressed image for less size.

Change-Id: I9ec8b7e5e35bfa8ae6ac2832d52d4748e9a79668
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agodrm/vc4: hvs: Boost the core clock during modeset 75/244075/3
Hoegeun Kwon [Tue, 15 Sep 2020 00:32:49 +0000 (09:32 +0900)]
drm/vc4: hvs: Boost the core clock during modeset

In order to prevent timeouts and stalls in the pipeline, the core clock
needs to be maxed at 500MHz during a modeset on the BCM2711.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Link: https://patchwork.freedesktop.org/patch/msgid/37ed9e0124c5cce005ddc8dafe821d8b0da036ff.1599120059.git-series.maxime@cerno.tech
[hoegeun.kwon: A screen cracking problem occurs in FHD(1920x1080). The
cause is that the clock should be kept at 500MHz, but it occurred when
the clock fell to 200MHz, so apply a patch.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: Ie0d4880966c1644bfdf56bb49dbb82559978538c

3 years agodrm/vc4: hdmi: Fix to use clk_set_min_rate 74/244074/1
Hoegeun Kwon [Fri, 11 Sep 2020 04:39:40 +0000 (13:39 +0900)]
drm/vc4: hdmi: Fix to use clk_set_min_rate

There is a problem that rpi_firmware_transaction fails while setting
the clock rate. Add the missing code applied to the mainline.

Change-Id: I56bcb00037fc85bb01f8a876ccd26798b4bddb39
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/d757ddd6549da140f178563e5fd2bf1d129913fd.1599120059.git-series.maxime@cerno.tech
3 years agodrm/vc4: hdmi: Switch to blank pixels when disabled 89/243889/1
Maxime Ripard [Tue, 25 Aug 2020 09:44:04 +0000 (18:44 +0900)]
drm/vc4: hdmi: Switch to blank pixels when disabled

In order to avoid pixels getting stuck in an unflushable FIFO, we need when
we disable the HDMI controller to switch away from getting our pixels from
the pixelvalve and instead use blank pixels, and switch back to the
pixelvalve when we enable the HDMI controller.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/fde3efb1ad79f4476a73d310cbba3ec07dc6dabe.1599120059.git-series.maxime@cerno.tech
[hoegeun.kwon: Needed to troubleshoot page flip timed out issue.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: I497f96e6d9b535d9d173d486fe1829c30093d88f

3 years agodrm/vc4: hdmi: Do the VID_CTL configuration at once 88/243888/1
Maxime Ripard [Tue, 25 Aug 2020 09:39:06 +0000 (18:39 +0900)]
drm/vc4: hdmi: Do the VID_CTL configuration at once

The VID_CTL setup is done in several places in the driver even though it's
not really required. Let's simplify it a bit to do the configuration in one
go.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/08e7ebb605a560fcc149b69b4af52753a7870b2f.1599120059.git-series.maxime@cerno.tech
[cw00.choi: Apply it to both vc4_hdmi_set_timings and vc5_hdmi_set_timings,
needed to troubleshoot page flip timed out issue.]
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: I3b12049c9bfb69d5d21c7186b677e8e32d756959

3 years agodrm/vc4: hdmi: Implement finer-grained hooks 87/243887/1
Maxime Ripard [Tue, 25 Aug 2020 09:26:58 +0000 (18:26 +0900)]
drm/vc4: hdmi: Implement finer-grained hooks

In order to prevent some pixels getting stuck in an unflushable FIFO on
bcm2711, we need to enable the HVS, the pixelvalve (the CRTC) and the HDMI
controller (the encoder) in an intertwined way, and with tight delays.

However, the atomic callbacks don't really provide a way to work with
either constraints, so we need to roll our own callbacks so that we can
provide those guarantees.

Since those callbacks have been implemented and called in the CRTC code, we
can just implement them in the HDMI driver now.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/2e9226d971117065f3b97e597f04f7fe2f0c134c.1599120059.git-series.maxime@cerno.tech
[hoegeun.kwon: Needed to troubleshoot page flip timed out issue.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: Ice9a866f353d8e478e8f24c66b6e2e836e474817

3 years agodrm/vc4: hdmi: Always recenter the HDMI FIFO 86/243886/1
Maxime Ripard [Tue, 25 Aug 2020 09:21:50 +0000 (18:21 +0900)]
drm/vc4: hdmi: Always recenter the HDMI FIFO

In order to avoid a pixel getting stuck in an unflushable FIFO, we need to
recenter the FIFO every time we're doing a modeset and not only if we're
connected to an HDMI monitor.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/b3faaf05ac6c4d3c364d28fa441571eb85903269.1599120059.git-series.maxime@cerno.tech
[hoegeun.kwon: Needed to troubleshoot page flip timed out issue.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: Ife295f612fb32ef2a02e1494c3a4b532735c989e

3 years agodrm/vc4: hdmi: Remove register dumps in enable 85/243885/1
Maxime Ripard [Tue, 25 Aug 2020 09:18:19 +0000 (18:18 +0900)]
drm/vc4: hdmi: Remove register dumps in enable

The current code has some logic, disabled by default, to dump the register
setup in the HDMI controller.

However, since we're going to split those functions in multiple, shorter,
functions that only make sense where they are called in sequence, keeping
the register dump makes little sense.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/c8c8d388f2d32fc3536336be36d003a862487eb7.1599120059.git-series.maxime@cerno.tech
[hoegeun.kwon: Remove hdmi reg dumps, needed to troubleshoot page flip
timed out issue.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: I8048f58783639cf790c8bb691007099943733a71

3 years agodrm/vc4: hdmi: Use clk_set_min_rate instead 84/243884/1
Maxime Ripard [Tue, 25 Aug 2020 09:07:16 +0000 (18:07 +0900)]
drm/vc4: hdmi: Use clk_set_min_rate instead

The HSM clock needs to be running at 101% the pixel clock of the HDMI
controller, however it's shared between the two HDMI controllers, which
means that if the resolutions are different between the two HDMI
controllers, and the lowest resolution is on the second (in enable order)
controller, the first HDMI controller will end up with a smaller than
expected clock rate.

Since we don't really need an exact frequency there, we can simply change
the minimum rate we expect instead.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/821992209cc0d7a83254bf26fe2bf507ef0994d2.1599120059.git-series.maxime@cerno.tech
[hoegeun.kwon: Needed to troubleshoot page flip timed out issue.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: I5666bf89beb6bada919b279846e5c204fabd0ffc

3 years agodrm/vc4: hdmi: Adjust HSM clock rate depending on pixel rate 83/243883/1
Maxime Ripard [Tue, 25 Aug 2020 08:31:56 +0000 (17:31 +0900)]
drm/vc4: hdmi: Adjust HSM clock rate depending on pixel rate

The HSM clock needs to be setup at around 101% of the pixel rate. This
was done previously by setting the clock rate to 163.7MHz at probe time and
only check in mode_valid whether the mode pixel clock was under the pixel
clock +1% or not.

However, with 4k we need to change that frequency to a higher frequency
than 163.7MHz, and yet want to have the lowest clock as possible to have a
decent power saving.

Let's change that logic a bit by setting the clock rate of the HSM clock
to the pixel rate at encoder_enable time. This would work for the
BCM2711 that support 4k resolutions and has a clock that can provide it,
but we still have to take care of a 4k panel plugged on a BCM283x SoCs
that wouldn't be able to use those modes, so let's define the limit in
the variant.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/7e692ddc231d33dd671e70ea04dd1dcf56c1ecb3.1599120059.git-series.maxime@cerno.tech
[hoegeun.kwon: Applied missing code, needed to troubleshoot page flip
timed out issue.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: I43328575d59a0bbccac8d4153ac5ed54f029550b

3 years agodrm/vc4: hdmi: Add reset callback 82/243882/1
Maxime Ripard [Tue, 25 Aug 2020 06:53:28 +0000 (15:53 +0900)]
drm/vc4: hdmi: Add reset callback

The BCM2711 and BCM283x HDMI controllers use a slightly different reset
sequence, so let's add a callback to reset the controller.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/a34bcb493da07eae58ed704f65e72ce0748e8952.1599120059.git-series.maxime@cerno.tech
[hoegeun.kwon: Apply the missing code, needed to troubleshoot page flip
timed out issue.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: If0383cb9b5f8ba5d3f309bfeab3e3c74272d8723

3 years agodrm/vc4: encoder: Add finer-grained encoder callbacks 81/243881/1
Maxime Ripard [Mon, 24 Aug 2020 10:56:15 +0000 (19:56 +0900)]
drm/vc4: encoder: Add finer-grained encoder callbacks

In the BCM2711, the setup of the HVS, pixelvalve and HDMI controller
requires very precise ordering and timing that the regular atomic callbacks
don't provide. Let's add new callbacks on top of the regular ones to be
able to split the configuration as needed.

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Tested-by: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.com>
Reviewed-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1dd78efe8f29add73c97d0148cfd4ec8e34aaf22.1599120059.git-series.maxime@cerno.tech
[hoegeun.kwon: For use encoder callback, needed to troubleshoot page
flip timed out issue.]
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
Change-Id: I16a1a59ad753d7c4e211c24a3563a607faa03a5c

3 years agoARM64: tizen_bcm2711_defconfig: Enable VIDEO_CODEC_BCM2835 76/243776/1 accepted/tizen/unified/20200911.043201 submit/tizen/20200910.072016
Seung-Woo Kim [Thu, 10 Sep 2020 04:28:11 +0000 (13:28 +0900)]
ARM64: tizen_bcm2711_defconfig: Enable VIDEO_CODEC_BCM2835

To support v4l2 codec device, enable VIDEO_CODEC_BCM2835 and
to meet dependency, enable MEDIA_CONTROLLER.

Change-Id: Id473825163c409ceaab5d4b618cf8bddd6af0f68
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agoARM: configs: tizen_bcm2711_defconfig: Enable VIDEO_CODEC_BCM2835 75/243775/1
Seung-Woo Kim [Thu, 10 Sep 2020 04:25:20 +0000 (13:25 +0900)]
ARM: configs: tizen_bcm2711_defconfig: Enable VIDEO_CODEC_BCM2835

To support v4l2 codec device, enable VIDEO_CODEC_BCM2835.

Change-Id: I7f7147901b77b3ff01afc1a7c3c7f0ab9cc20701
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agoRevert "block: zram: Add support for dynamic compressor switch" 35/242135/1 accepted/tizen/unified/20200825.142845 submit/tizen/20200825.023546
Dongwoo Lee [Fri, 21 Aug 2020 11:53:46 +0000 (20:53 +0900)]
Revert "block: zram: Add support for dynamic compressor switch"

Since dynamic compress switch increases memory usage of meta data along
with the size of zram, in order to saving memory, this reverts commit
'2aab8469d74f ("block: zram Add support for dynamic compressor switch")'

Change-Id: Idd6e1f6f938ca2ebb24ba3e8c65a838bf8fc84d4
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agoARM64: tizen_bcm2711_defconfig: Enable RTL8192CU config as module 65/242065/2 accepted/tizen/unified/20200825.033245 submit/tizen/20200824.091314
Jaehoon Chung [Mon, 24 Aug 2020 02:34:08 +0000 (11:34 +0900)]
ARM64: tizen_bcm2711_defconfig: Enable RTL8192CU config as module

Enable RTL8192CU configuration as module.

Change-Id: I4597976b08b9e1e98d61f42da674c28c5e476f10
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agoARM: tizen_bcm2711_defconfig: Enable RTL8192CU config as module 64/242064/2
Jaehoon Chung [Mon, 24 Aug 2020 02:33:04 +0000 (11:33 +0900)]
ARM: tizen_bcm2711_defconfig: Enable RTL8192CU config as module

Enable RTL8192CU configuration as module.

Change-Id: Ibe38cc889d5e2973028b28615a2210f87056763f
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
3 years agomm: memcontrol: Add force_reclaim to reclaim tasks' memory in memcg 36/242036/1
Dongwoo Lee [Mon, 3 Aug 2020 05:44:43 +0000 (14:44 +0900)]
mm: memcontrol: Add force_reclaim to reclaim tasks' memory in memcg

These days, platforms tend to manage memory on low memory state
like andloid's lowmemory killer. These platforms might want to
reclaim memory from background tasks as well as kill victims
to guarantee free memory at use space level. This patch provides
an interface to reclaim a given memcg. After platform's low memory
handler moves tasks that the platform wants to reclaim to
a memcg and decides how many pages should be reclaimed, it can
reclaim the pages from the tasks by writing the number of pages
at memory.force_reclaim.

Signed-off-by: Hyunhee Kim <hyunhee.kim@xxxxxxxxxxx>
Signed-off-by: Kyungmin Park <kyungmin.park@xxxxxxxxxxx>
[dwoo08.lee: ported from mailing list https://www.spinics.net/lists/cgroups/msg07874.html]

Change-Id: I40b1322dfe2628ca306690a15958881b3026606f
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
3 years agoRevert "WORKAROUND: security: smack: Allow ptracing even processes in onlycap set" 16/241916/1 accepted/tizen/unified/20200824.030012 submit/tizen/20200820.145124
Seung-Woo Kim [Fri, 21 Aug 2020 01:08:34 +0000 (10:08 +0900)]
Revert "WORKAROUND: security: smack: Allow ptracing even processes in onlycap set"

This reverts commit 38b1ae4b960c310b02d7d6935b97d289f0326800.

Now crash-worker has System::Privileged privilege, so not anymore
ptrace related workaround is necessary. So revert the workaround.

Change-Id: I42b535e4152eb742df011a5a08324764b49f989a
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agoscripts: mkbootimg_rpi4.sh: Fix module image size to 32MB 27/241427/1
Hoegeun Kwon [Thu, 20 Aug 2020 05:24:51 +0000 (14:24 +0900)]
scripts: mkbootimg_rpi4.sh: Fix module image size to 32MB

The partition module size has been modified to 32MB.

Change-Id: I467fd7618d345a25d87af62985a1c2f8f47ad0eb
Signed-off-by: Hoegeun Kwon <hoegeun.kwon@samsung.com>
3 years agoARM: dts: bcm2711-rpi-4-b: Enable uart2 node 68/241068/1 accepted/tizen/unified/20200819.035952 submit/tizen/20200818.094753
Seung-Woo Kim [Fri, 14 Aug 2020 07:47:15 +0000 (16:47 +0900)]
ARM: dts: bcm2711-rpi-4-b: Enable uart2 node

Enable uart2 to support '/dev/ttyAMA1'. The node setting is from
arch/arm/boot/dts/overlays/uart2-overlay.dts, without cts, rts.
Tx pin is gpio 0, pin 27, and Rx pin is gpio 1, pin 28.

Ref: https://www.raspberrypi.org/forums/viewtopic.php?t=244827

Change-Id: Ib6c460f6c8e46f3ef7d2d40ab23b3524e438c6c9
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agorpi4: boot: config: disable eeprom i2c hat auto detect 67/241067/1
Seung-Woo Kim [Fri, 14 Aug 2020 07:24:24 +0000 (16:24 +0900)]
rpi4: boot: config: disable eeprom i2c hat auto detect

From raspberry pi gpio pins, ID_SC and ID_SD are reserved by
firmware to detect HAT with i2c, but in Tizen, auto-detection
and dynamical setting dt with overlay is not supported.
To use the pins for uart2, explictly disable eeprom i2c hat
auto detect.

Ref: https://www.raspberrypi.org/documentation/configuration/config-txt/boot.md

Change-Id: Id5cf016b09e7661317529e1174842915165955bc
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agoARM64: configs: tizen_bcm2711_defconfig: enable I2C_STUB as module 77/240977/1 accepted/tizen/unified/20200814.123119 submit/tizen/20200813.100152
Seung-Woo Kim [Thu, 13 Aug 2020 09:57:09 +0000 (18:57 +0900)]
ARM64: configs: tizen_bcm2711_defconfig: enable I2C_STUB as module

Tizen peripheral-io tct requires i2c_stub module to test i2c
functionality. Enable I2C_STUB as module.

Change-Id: I93ea159349dd5bcfea7ceabd04af239c7f2a1b96
Signed-off-by: Seung-Woo Kim <sw0312.kim@samsung.com>
3 years agomm: LKSM: remove unnecessary debug messages 59/240959/2
Sung-hun Kim [Thu, 13 Aug 2020 06:46:36 +0000 (15:46 +0900)]
mm: LKSM: remove unnecessary debug messages

In order to get scanning candidates, LKSM hooks fork and exit calls even though
LKSM does not run. Previous patches include debugging messages when LKSM hooks
exit calls, and it can flush old kernel logs. To handle this, this patch removes
unnecessary debugging messages.

Change-Id: If475a880ee931668b6bebf53322622ba2a042c89
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>
3 years agomm: Change fault_around_bytes default value from 65536 to 4096 28/239728/3 accepted/tizen/unified/20200812.143848 submit/tizen/20200812.081439
Chanwoo Choi [Wed, 29 Jul 2020 07:52:52 +0000 (16:52 +0900)]
mm: Change fault_around_bytes default value from 65536 to 4096

To apply the 4K value for falut_around_bytes at the early booting step,
change fault_around_bytes default value from 65536 to 4096.

Change-Id: Id97650a035b524d7132bca6164581c8e15096354
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
3 years agoARM64: configs: tizen_bcm2711_defconfig: enable CONFIG_LKSM_FILTER 99/239599/15
Sung-hun Kim [Thu, 16 Jul 2020 07:00:07 +0000 (16:00 +0900)]
ARM64: configs: tizen_bcm2711_defconfig: enable CONFIG_LKSM_FILTER

Change-Id: I54bbb1ee0a5e3923ebdb4b62038c3ba999e38dab
Signed-off-by: Sung-hun Kim <sfoon.kim@samsung.com>