Commit Graph

1166636 Commits

Author SHA1 Message Date
Yosry Ahmed
4b27ab0c6b UPSTREAM: memcg: calculate root usage from global state
Currently, we approximate the root usage by adding the memcg stats for
anon, file, and conditionally swap (for memsw).  To read the memcg stats
we need to invoke an rstat flush.  rstat flushes can be expensive, they
scale with the number of cpus and cgroups on the system.

mem_cgroup_usage() is called by memcg_events()->mem_cgroup_threshold()
with irqs disabled, so such an expensive operation with irqs disabled can
cause problems.

Instead, approximate the root usage from global state.  This is not 100%
accurate, but the root usage has always been ill-defined anyway.

Link: https://lkml.kernel.org/r/20230421174020.2994750-4-yosryahmed@google.com
Change-Id: Ifbc895f45fc119f3079c17fd8f5e3d87267428c4
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Reviewed-by: Michal Koutný <mkoutny@suse.com>
Acked-by: Shakeel Butt <shakeelb@google.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit f82a7a86db)
Bug: 322544714
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2025-01-08 19:30:25 +00:00
Yosry Ahmed
0ef8d00e37 UPSTREAM: memcg: flush stats non-atomically in mem_cgroup_wb_stats()
The previous patch moved the wb_over_bg_thresh()->mem_cgroup_wb_stats()
code path in wb_writeback() outside the lock section.  We no longer need
to flush the stats atomically.  Flush the stats non-atomically.

Link: https://lkml.kernel.org/r/20230421174020.2994750-3-yosryahmed@google.com
Change-Id: Ibbb2dd41fac7c26f1e18d0a984d7197b45294f6f
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Reviewed-by: Michal Koutný <mkoutny@suse.com>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 190409caaf)
Bug: 322544714
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2025-01-08 19:30:25 +00:00
Yosry Ahmed
c0d8df37a0 UPSTREAM: writeback: move wb_over_bg_thresh() call outside lock section
Patch series "cgroup: eliminate atomic rstat flushing", v5.

A previous patch series [1] changed most atomic rstat flushing contexts to
become non-atomic.  This was done to avoid an expensive operation that
scales with # cgroups and # cpus to happen with irqs disabled and
scheduling not permitted.  There were two remaining atomic flushing
contexts after that series.  This series tries to eliminate them as well,
eliminating atomic rstat flushing completely.

The two remaining atomic flushing contexts are:
(a) wb_over_bg_thresh()->mem_cgroup_wb_stats()
(b) mem_cgroup_threshold()->mem_cgroup_usage()

For (a), flushing needs to be atomic as wb_writeback() calls
wb_over_bg_thresh() with a spinlock held.  However, it seems like the call
to wb_over_bg_thresh() doesn't need to be protected by that spinlock, so
this series proposes a refactoring that moves the call outside the lock
criticial section and makes the stats flushing in mem_cgroup_wb_stats()
non-atomic.

For (b), flushing needs to be atomic as mem_cgroup_threshold() is called
with irqs disabled.  We only flush the stats when calculating the root
usage, as it is approximated as the sum of some memcg stats (file, anon,
and optionally swap) instead of the conventional page counter.  This
series proposes changing this calculation to use the global stats instead,
eliminating the need for a memcg stat flush.

After these 2 contexts are eliminated, we no longer need
mem_cgroup_flush_stats_atomic() or cgroup_rstat_flush_atomic().  We can
remove them and simplify the code.

[1] https://lore.kernel.org/linux-mm/20230330191801.1967435-1-yosryahmed@google.com/

This patch (of 5):

wb_over_bg_thresh() calls mem_cgroup_wb_stats() which invokes an rstat
flush, which can be expensive on large systems. Currently,
wb_writeback() calls wb_over_bg_thresh() within a lock section, so we
have to do the rstat flush atomically. On systems with a lot of
cpus and/or cgroups, this can cause us to disable irqs for a long time,
potentially causing problems.

Move the call to wb_over_bg_thresh() outside the lock section in
preparation to make the rstat flush in mem_cgroup_wb_stats() non-atomic.
The list_empty(&wb->work_list) check should be okay outside the lock
section of wb->list_lock as it is protected by a separate lock
(wb->work_lock), and wb_over_bg_thresh() doesn't seem like it is
modifying any of wb->b_* lists the wb->list_lock is protecting.
Also, the loop seems to be already releasing and reacquring the
lock, so this refactoring looks safe.

Link: https://lkml.kernel.org/r/20230421174020.2994750-1-yosryahmed@google.com
Link: https://lkml.kernel.org/r/20230421174020.2994750-2-yosryahmed@google.com
Change-Id: Id9dbfad96cfd32f1381d7640e1e2cf62c0a56189
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Reviewed-by: Michal Koutný <mkoutny@suse.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Tejun Heo <tj@kernel.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christian Brauner <brauner@kernel.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <songmuchun@bytedance.com>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 2816ea2abf)
Bug: 322544714
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2025-01-08 19:30:25 +00:00
Yosry Ahmed
681efac6a1 UPSTREAM: memcg: do not modify rstat tree for zero updates
In some situations, we may end up calling memcg_rstat_updated() with a
value of 0, which means the stat was not actually updated.  An example is
if we fail to reclaim any pages in shrink_folio_list().

Do not add the cgroup to the rstat updated tree in this case, to avoid
unnecessarily flushing it.

Link: https://lkml.kernel.org/r/20230330191801.1967435-9-yosryahmed@google.com
Change-Id: I8142aa6c2962e5af590a5e93f89fbf2313d4b741
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Reviewed-by: Michal Koutný <mkoutny@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vasily Averin <vasily.averin@linux.dev>
Cc: Zefan Li <lizefan.x@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit f9d911ca49)
Bug: 322544714
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2025-01-08 19:30:25 +00:00
Yosry Ahmed
5795558d86 UPSTREAM: vmscan: memcg: sleep when flushing stats during reclaim
Memory reclaim is a sleepable context.  Flushing is an expensive operaiton
that scales with the number of cpus and the number of cgroups in the
system, so avoid doing it atomically unnecessarily.  This can slow down
reclaim code if flushing stats is taking too long, but there is already
multiple cond_resched()'s in reclaim code.

Link: https://lkml.kernel.org/r/20230330191801.1967435-8-yosryahmed@google.com
Change-Id: Ia0f0d42131e67a060dc7c9b868ef5247d78e05c8
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vasily Averin <vasily.averin@linux.dev>
Cc: Zefan Li <lizefan.x@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 0d856cfedd)
Bug: 322544714
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2025-01-08 19:30:24 +00:00
Yosry Ahmed
e3e3beed82 UPSTREAM: workingset: memcg: sleep when flushing stats in workingset_refault()
In workingset_refault(), we call
mem_cgroup_flush_stats_atomic_ratelimited() to read accurate stats within
an RCU read section and with sleeping disallowed.  Move the call above the
RCU read section to make it non-atomic.

Flushing is an expensive operation that scales with the number of cpus and
the number of cgroups in the system, so avoid doing it atomically where
possible.

Since workingset_refault() is the only caller of
mem_cgroup_flush_stats_atomic_ratelimited(), just make it non-atomic, and
rename it to mem_cgroup_flush_stats_ratelimited().

Link: https://lkml.kernel.org/r/20230330191801.1967435-7-yosryahmed@google.com
Change-Id: Ia073b9bcef12dfced053ebea7a5da96ce942596c
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vasily Averin <vasily.averin@linux.dev>
Cc: Zefan Li <lizefan.x@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 4009b2f188)
Bug: 322544714
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2025-01-08 19:30:24 +00:00
Yosry Ahmed
0448f92c8d UPSTREAM: memcg: sleep during flushing stats in safe contexts
Currently, all contexts that flush memcg stats do so with sleeping not
allowed.  Some of these contexts are perfectly safe to sleep in, such as
reading cgroup files from userspace or the background periodic flusher.
Flushing is an expensive operation that scales with the number of cpus and
the number of cgroups in the system, so avoid doing it atomically where
possible.

Refactor the code to make mem_cgroup_flush_stats() non-atomic (aka
sleepable), and provide a separate atomic version.  The atomic version is
used in reclaim, refault, writeback, and in mem_cgroup_usage().  All other
code paths are left to use the non-atomic version.  This includes
callbacks for userspace reads and the periodic flusher.

Since refault is the only caller of mem_cgroup_flush_stats_ratelimited(),
change it to mem_cgroup_flush_stats_atomic_ratelimited().  Reclaim and
refault code paths are modified to do non-atomic flushing in separate
later patches -- so it will eventually be changed back to
mem_cgroup_flush_stats_ratelimited().

Link: https://lkml.kernel.org/r/20230330191801.1967435-6-yosryahmed@google.com
Change-Id: I9c28e852e1a37202fbd3ee419c72acf667d63404
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vasily Averin <vasily.averin@linux.dev>
Cc: Zefan Li <lizefan.x@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 9fad9aee1f)
Bug: 322544714
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2025-01-08 19:30:24 +00:00
Yosry Ahmed
c47c4c0966 UPSTREAM: memcg: replace stats_flush_lock with an atomic
As Johannes notes in [1], stats_flush_lock is currently used to:
(a) Protect updated to stats_flush_threshold.
(b) Protect updates to flush_next_time.
(c) Serializes calls to cgroup_rstat_flush() based on those ratelimits.

However:

1. stats_flush_threshold is already an atomic

2. flush_next_time is not atomic. The writer is locked, but the reader
   is lockless. If the reader races with a flush, you could see this:

                                        if (time_after(jiffies, flush_next_time))
        spin_trylock()
        flush_next_time = now + delay
        flush()
        spin_unlock()
                                        spin_trylock()
                                        flush_next_time = now + delay
                                        flush()
                                        spin_unlock()

   which means we already can get flushes at a higher frequency than
   FLUSH_TIME during races. But it isn't really a problem.

   The reader could also see garbled partial updates if the compiler
   decides to split the write, so it needs at least READ_ONCE and
   WRITE_ONCE protection.

3. Serializing cgroup_rstat_flush() calls against the ratelimit
   factors is currently broken because of the race in 2. But the race
   is actually harmless, all we might get is the occasional earlier
   flush. If there is no delta, the flush won't do much. And if there
   is, the flush is justified.

So the lock can be removed all together. However, the lock also served
the purpose of preventing a thundering herd problem for concurrent
flushers, see [2]. Use an atomic instead to serve the purpose of
unifying concurrent flushers.

[1]https://lore.kernel.org/lkml/20230323172732.GE739026@cmpxchg.org/
[2]https://lore.kernel.org/lkml/20210716212137.1391164-2-shakeelb@google.com/

Link: https://lkml.kernel.org/r/20230330191801.1967435-5-yosryahmed@google.com
Change-Id: I98e8344b440486162426186c4abdf21e02eebd43
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vasily Averin <vasily.averin@linux.dev>
Cc: Zefan Li <lizefan.x@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 3cd9992b93)
Bug: 322544714
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2025-01-08 19:30:24 +00:00
Yosry Ahmed
86ff69608f UPSTREAM: memcg: do not flush stats in irq context
Currently, the only context in which we can invoke an rstat flush from irq
context is through mem_cgroup_usage() on the root memcg when called from
memcg_check_events().  An rstat flush is an expensive operation that
should not be done in irq context, so do not flush stats and use the stale
stats in this case.

Arguably, usage threshold events are not reliable on the root memcg anyway
since its usage is ill-defined.

Link: https://lkml.kernel.org/r/20230330191801.1967435-4-yosryahmed@google.com
Change-Id: If230311168f126e3741afaeab1f20cb1949190f0
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Suggested-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vasily Averin <vasily.averin@linux.dev>
Cc: Zefan Li <lizefan.x@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit a2174e95cc)
Bug: 322544714
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2025-01-08 19:30:24 +00:00
Yosry Ahmed
a77a4ca4f4 UPSTREAM: memcg: rename mem_cgroup_flush_stats_"delayed" to "ratelimited"
mem_cgroup_flush_stats_delayed() suggests his is using a delayed_work, but
this is actually sometimes flushing directly from the callsite.

What it's doing is ratelimited calls.  A better name would be
mem_cgroup_flush_stats_ratelimited().

Link: https://lkml.kernel.org/r/20230330191801.1967435-3-yosryahmed@google.com
Change-Id: Ib418ae17599d10c520b766f0c0e4396a43906256
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Michal Hocko <mhocko@suse.com>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vasily Averin <vasily.averin@linux.dev>
Cc: Zefan Li <lizefan.x@bytedance.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 92fbbc7202)
Bug: 322544714
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2025-01-08 19:30:23 +00:00
Yosry Ahmed
978adc3d3a UPSTREAM: cgroup: rename cgroup_rstat_flush_"irqsafe" to "atomic"
Patch series "memcg: avoid flushing stats atomically where possible", v3.

rstat flushing is an expensive operation that scales with the number of
cpus and the number of cgroups in the system.  The purpose of this series
is to minimize the contexts where we flush stats atomically.

Patches 1 and 2 are cleanups requested during reviews of prior versions of
this series.

Patch 3 makes sure we never try to flush from within an irq context.

Patches 4 to 7 introduce separate variants of mem_cgroup_flush_stats() for
atomic and non-atomic flushing, and make sure we only flush the stats
atomically when necessary.

Patch 8 is a slightly tangential optimization that limits the work done by
rstat flushing in some scenarios.

This patch (of 8):

cgroup_rstat_flush_irqsafe() can be a confusing name.  It may read as
"irqs are disabled throughout", which is what the current implementation
does (currently under discussion [1]), but is not the intention.  The
intention is that this function is safe to call from atomic contexts.
Name it as such.

Link: https://lkml.kernel.org/r/20230330191801.1967435-1-yosryahmed@google.com
Link: https://lkml.kernel.org/r/20230330191801.1967435-2-yosryahmed@google.com
Change-Id: I7a030bc657b330ce700a29ded19f995e26f3aec1
Signed-off-by: Yosry Ahmed <yosryahmed@google.com>
Suggested-by: Johannes Weiner <hannes@cmpxchg.org>
Acked-by: Shakeel Butt <shakeelb@google.com>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Josef Bacik <josef@toxicpanda.com>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Michal Koutný <mkoutny@suse.com>
Cc: Muchun Song <muchun.song@linux.dev>
Cc: Roman Gushchin <roman.gushchin@linux.dev>
Cc: Tejun Heo <tj@kernel.org>
Cc: Vasily Averin <vasily.averin@linux.dev>
Cc: Zefan Li <lizefan.x@bytedance.com>
Cc: Michal Hocko <mhocko@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
(cherry picked from commit 8bff9a04ca)
Bug: 322544714
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2025-01-08 19:30:20 +00:00
Xuewen Yan
616d7c64fd BACKPORT: epoll: Add synchronous wakeup support for ep_poll_callback
Now, the epoll only use wake_up() interface to wake up task.
However, sometimes, there are epoll users which want to use
the synchronous wakeup flag to hint the scheduler, such as
Android binder driver.
So add a wake_up_sync() define, and use the wake_up_sync()
when the sync is true in ep_poll_callback().

Bug: 388205332
Co-developed-by: Jing Xia <jing.xia@unisoc.com>
Signed-off-by: Jing Xia <jing.xia@unisoc.com>
Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
Link: https://lore.kernel.org/r/20240426080548.8203-1-xuewen.yan@unisoc.com
Tested-by: Brian Geffon <bgeffon@google.com>
Reviewed-by: Brian Geffon <bgeffon@google.com>
Reported-by: Benoit Lize <lizeb@google.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
(cherry picked from commit 900bbaae67e980945dec74d36f8afe0de7556d5a)
[wait.h: wake_up_sync() already defined in android, keep new identical
upstream definition]
Signed-off-by: Qais Yousef <qyousef@google.com>
Change-Id: Icb977e494bba925e281fb5836e5f7f2f334d5616
2025-01-07 12:08:26 +00:00
Eduard Zingerman
66ae563a65 UPSTREAM: bpf: sync_linked_regs() must preserve subreg_def
commit e9bd9c498cb0f5843996dbe5cbce7a1836a83c70 upstream.

Range propagation must not affect subreg_def marks, otherwise the
following example is rewritten by verifier incorrectly when
BPF_F_TEST_RND_HI32 flag is set:

  0: call bpf_ktime_get_ns                   call bpf_ktime_get_ns
  1: r0 &= 0x7fffffff       after verifier   r0 &= 0x7fffffff
  2: w1 = w0                rewrites         w1 = w0
  3: if w0 < 10 goto +0     -------------->  r11 = 0x2f5674a6     (r)
  4: r1 >>= 32                               r11 <<= 32           (r)
  5: r0 = r1                                 r1 |= r11            (r)
  6: exit;                                   if w0 < 0xa goto pc+0
                                             r1 >>= 32
                                             r0 = r1
                                             exit

(or zero extension of w1 at (2) is missing for architectures that
 require zero extension for upper register half).

The following happens w/o this patch:
- r0 is marked as not a subreg at (0);
- w1 is marked as subreg at (2);
- w1 subreg_def is overridden at (3) by copy_register_state();
- w1 is read at (5) but mark_insn_zext() does not mark (2)
  for zero extension, because w1 subreg_def is not set;
- because of BPF_F_TEST_RND_HI32 flag verifier inserts random
  value for hi32 bits of (2) (marked (r));
- this random value is read at (5).

Bug: 376430403
Fixes: 75748837b7 ("bpf: Propagate scalar ranges through register assignments.")
Reported-by: Lonial Con <kongln9170@gmail.com>
Signed-off-by: Lonial Con <kongln9170@gmail.com>
Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Closes: https://lore.kernel.org/bpf/7e2aa30a62d740db182c170fdd8f81c596df280d.camel@gmail.com
Link: https://lore.kernel.org/bpf/20240924210844.1758441-1-eddyz87@gmail.com
[ shung-hsi.yu: sync_linked_regs() was called find_equal_scalars() before commit
  4bf79f9be434 ("bpf: Track equal scalars history on per-instruction level"), and
  modification is done because there is only a single call to
  copy_register_state() before commit 98d7ca374ba4 ("bpf: Track delta between
  "linked" registers."). ]
Signed-off-by: Shung-Hsi Yu <shung-hsi.yu@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit bfe9446ea1)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I1e6c5b53e5ebfcae5300e7a1c692c7a6448e200c
2025-01-07 02:16:26 -08:00
Dan Carpenter
eeccb29218 UPSTREAM: ALSA: usb-audio: Fix a DMA to stack memory bug
commit f7d306b47a24367302bd4fe846854e07752ffcd9 upstream.

The usb_get_descriptor() function does DMA so we're not allowed
to use a stack buffer for that.  Doing DMA to the stack is not portable
all architectures.  Move the "new_device_descriptor" from being stored
on the stack and allocate it with kmalloc() instead.

Bug: 382243530
Fixes: b909df18ce2a ("ALSA: usb-audio: Fix potential out-of-bound accesses for Extigy and Mbox devices")
Cc: stable@kernel.org
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/60e3aa09-039d-46d2-934c-6f123026c2eb@stanley.mountain
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Benoît Sevens <bsevens@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 44a7b0419d)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I469212aa538584e3d8cc5b0087b68c99acf43f64
2025-01-03 15:18:26 +00:00
liulu.liu@honor.corp-partner.google.com
e2b9748880 ANDROID: ABI: update symbol list for honor
4 function symbol(s) added
  'int __traceiter_rpm_idle(void*, struct device *dev, int flags)'
  'int __traceiter_rpm_suspend(void*, struct device *dev, int flags)'
  'int __traceiter_rpm_resume(void*, struct device *dev, int flags)'
  'int __traceiter_rpm_return_int(void*, struct device *dev, unsigned long ip, int ret)'

4 variable symbol(s) added
  'struct tracepoint __tracepoint_rpm_idle'
  'struct tracepoint __tracepoint_rpm_suspend'
  'struct tracepoint __tracepoint_rpm_resume'
  'struct tracepoint __tracepoint_rpm_return_int'

Bug: 384649917
Change-Id: I4f5defc1e915aafb67f0cb1588774cbf9e466ff2
Signed-off-by: liulu liu <liulu.liu@honor.corp-partner.google.com>
2024-12-30 15:34:44 +08:00
Roy Luo
3f924195e2 FROMGIT: usb: dwc3: gadget: Fix incorrect UDC state after manual deconfiguration
The UDC state in sysfs (/sys/class/udc/<udc>/state) should accurately
reflect the current state of the USB Device Controller.

Currently, the UDC state is not handled consistently during gadget
disconnection. While the disconnect interrupt path correctly sets the
state to "not-attached", manual deconfiguration leaves the state in
"configured", misrepresenting the actual situation.

This commit ensures consistent UDC state handling by setting the state to
"not-attached" after manual deconfiguration. This accurately reflects the
UDC's state and provides a consistent behavior regardless of the
disconnection method.

Signed-off-by: Roy Luo <royluo@google.com>
Reviewed-by: André Draszik <andre.draszik@linaro.org>
Tested-by: André Draszik <andre.draszik@linaro.org>
Link: https://lore.kernel.org/r/20241223042536.1465299-1-royluo@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 339241080
(cherry picked from commit 1ff24d40b3c3c673d833c546f898133b80dffc39
 git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
 usb-next)
Change-Id: I6840073addbcbd2acd0145363e4e5aac2f7422ee
Signed-off-by: Roy Luo <royluo@google.com>
2024-12-27 19:27:44 +00:00
Yifeng Zhao
c141a306c4 ANDROID: scsi: sd: Fix unexpect removal code on Merge commit
The merge change is incorrect and cause issue at device resume:

[   78.858757][ T2143] sd 0:0:0:0: [sda] Starting disk
[   78.858852][ T2143] sd 0:0:0:0: [sda] Start/Stop Unit failed: Result: hostbyte=DID_OK driverbyte=DRIVER_OK
[   78.858868][ T2143] sd 0:0:0:0: [sda] Sense Key : Unit Attention [current]
[   78.858881][ T2143] sd 0:0:0:0: [sda] Add. Sense: Power on, reset, or bus device reset occurred
[   78.858898][ T2143] sd 0:0:0:0: PM: dpm_run_callback(): scsi_bus_resume+0x0/0x84 returns -5

Bug: 369929235
Fixes: 2b530e8f5d ("Merge 6.1.84 into android14-6.1-lts")
Change-Id: Id96ca2a3c8183f8f9b86cfd9ce173c4acdaaab2c
Signed-off-by: Yifeng Zhao <yifeng.zhao@rock-chips.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2024-12-26 16:56:13 +08:00
zhangpeng
4c2d86d81f ANDROID: GKI: Update oplus symbol list
1 function symbol(s) added
  'void tcp_cong_avoid_ai(struct tcp_sock *tp, u32 w, u32 acked)'

Bug: 383007920
Change-Id: I6975f6a61fb5b01cde75ae96779ff6f570663e1c
Signed-off-by: zhangpeng <zhangpeng9@oppo.com>
2024-12-23 15:41:21 -08:00
Chao Yu
3e3f2b9e9f BACKPORT: f2fs: fix to account dirty data in __get_secs_required()
It will trigger system panic w/ testcase in [1]:

------------[ cut here ]------------
kernel BUG at fs/f2fs/segment.c:2752!
RIP: 0010:new_curseg+0xc81/0x2110
Call Trace:
 f2fs_allocate_data_block+0x1c91/0x4540
 do_write_page+0x163/0xdf0
 f2fs_outplace_write_data+0x1aa/0x340
 f2fs_do_write_data_page+0x797/0x2280
 f2fs_write_single_data_page+0x16cd/0x2190
 f2fs_write_cache_pages+0x994/0x1c80
 f2fs_write_data_pages+0x9cc/0xea0
 do_writepages+0x194/0x7a0
 filemap_fdatawrite_wbc+0x12b/0x1a0
 __filemap_fdatawrite_range+0xbb/0xf0
 file_write_and_wait_range+0xa1/0x110
 f2fs_do_sync_file+0x26f/0x1c50
 f2fs_sync_file+0x12b/0x1d0
 vfs_fsync_range+0xfa/0x230
 do_fsync+0x3d/0x80
 __x64_sys_fsync+0x37/0x50
 x64_sys_call+0x1e88/0x20d0
 do_syscall_64+0x4b/0x110
 entry_SYSCALL_64_after_hwframe+0x76/0x7e

The root cause is if checkpoint_disabling and lfs_mode are both on,
it will trigger OPU for all overwritten data, it may cost more free
segment than expected, so f2fs must account those data correctly to
calculate cosumed free segments later, and return ENOSPC earlier to
avoid run out of free segment during block allocation.

[1] https://lore.kernel.org/fstests/20241015025106.3203676-1-chao@kernel.org/

Bug: 384588553
Change-Id: Iad815129b50eaf8087a85c9fae0de2b97483a4c7
Fixes: 4354994f09 ("f2fs: checkpoint disabling")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Daniel Rosenberg <drosen@google.com>
(cherry picked from commit 1acd73edbbfef2c3c5b43cba4006a7797eca7050)
2024-12-19 13:53:19 -08:00
Akash Kumar
e50cf165f4 BACKPORT: usb: gadget: uvc: configfs: Add frame-based frame format support
Add support for frame-based frame format, which can be used to support
multiple formats like H264 or H265, in addition to MJPEG and YUV frames.

The frame-based format is set to H264 by default, but it can be updated
to other formats by modifying the GUID through the guid configfs
attribute. Different structures are used for all three formats, as
H264 has a different structure compared to MJPEG and uncompressed
formats. These structures will be passed to the frame make function
based on the active format, using a common frame structure with
additional parameters needed only for frame-based formats. These
parameters are handled at runtime in the UVC driver.

Signed-off-by: Akash Kumar <quic_akakum@quicinc.com>
Link: https://lore.kernel.org/r/20240927152138.31416-1-quic_akakum@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Change-Id: I71eee274a29d5ed27ac46baa9535ccc501e3704d

Bug: 384630325
(cherry picked from commit 7b5a58952fc3b51905c2963647485565df1e5e26)
[Akash: Resolved minor conflict drivers/usb/gadget/function/uvc_configfs.h ]
[Akash: Resolved minor conflict drivers/usb/gadget/function/uvc_v4l2.c ]

Change-Id: I6be6be3ed3cba248679332cc50aee88b4c8411fb
Signed-off-by: Akash Kumar <quic_akakum@quicinc.com>
2024-12-18 12:45:06 +05:30
Paul Lawrence
4bcafa4d00 ANDROID: dm-bow: Fix empty else blocks
drivers/md/dm-bow.c:1149:51: error: suggest braces around empty body
in an ‘else’ statement [-Werror=empty-body]
drivers/md/dm-bow.c:1142:51: error: suggest braces around empty body
in an ‘else’ statement [-Werror=empty-body]

Link to kernelci result:
https://linux.kernelci.org/build/android/branch/android-mainline/kernel/v6.11-rc6-6389-g1cf1608b4abd8/

Build log: https://storage.kernelci.org/android/android-mainline/v6.11-rc6-6389-g1cf1608b4abd8/x86_64/allmodconfig/gcc-12/logs/kernel.log

Bug: 366029436
Bug: 379587919
Test: compiles
Change-Id: I685754e895ef1cdfd7ab1ae323b36b4ae310a45d
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2024-12-17 12:51:08 -08:00
Paul Lawrence
d5dfee96ac ANDROID: dm-bow: Pass through zero sized requests
Zero sized requests appeared in 5.15, and break validation logic in user
space. Simply pass through, as there is no reason to handle.

aosp/3238494 enables checkpoints on ext4 in cuttlefish, get this too

With all the patches in place, run:

launch_cvd \
  -userdata_format="ext4" \
  --data_policy=always_create --blank_data_image_mb=16000

then run

atest vts_kernel_checkpoint_test

Test: atest vts_kernel_checkpoint_test passes
Bug: 210958368
Bug: 379587919
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: I3bc8037dc53e02f10c3f41de2f1176e774482815
2024-12-17 12:51:08 -08:00
Paul Lawrence
1149e6d6fc ANDROID: dm-bow: Fix 5.15 compatibility issue
Patch

https://patchwork.kernel.org/project/linux-block/patch/20210804094147.459763-8-hch@lst.de/

delays registering the gendisk, so move creating our sysfs nodes until
resume.

Test: runs
Bug: 210958368
Bug: 379587919
Change-Id: If671893d50434bb39ea37babb0bea05cebae6f54
Signed-off-by: Paul Lawrence <paullawrence@google.com>
(cherry picked from commit 88e27b17aab604fb2d486e538b2ef55cd967a430)
2024-12-17 12:51:08 -08:00
Paul Lawrence
1f8f8e5cd9 ANDROID: dm-bow: Fix up revert remove dm-bow
The revert does not compile. This patch corrects compilation issues.

It does not fix issues that prevent dm-bow from initializing

Test: Can build kernel with dm-bow enabled

Bug: 210958368
Bug: 379587919
Signed-off-by: Paul Lawrence <paullawrence@google.com>
Change-Id: If65a7ce4f7648329607c11054bc542eb2b735081
2024-12-17 12:51:08 -08:00
Paul Lawrence
e8944a38b4 Revert "ANDROID: dm-bow: remove dm-bow"
This reverts commit dc855f8bdf.

Support for ext4 for userdata has been restored, so we must also restore
dm-bow

Note that since it was deprecated, a few things have changed at the dm
layer, so there are follow-on patches to fix up all the issues

aosp/3238494 enables checkpoints on ext4 in cuttlefish, get this too

With all the patches in place, run:

launch_cvd \
  -userdata_format="ext4" \
  --data_policy=always_create --blank_data_image_mb=16000

then run

atest vts_kernel_checkpoint_test

Test: atest vts_kernel_checkpoint_test passes
Bug: 210958368
Bug: 379587919
Change-Id: I06ad3c7870b67080dfd6d72917751b20193a4fd6
Signed-off-by: Paul Lawrence <paullawrence@google.com>
2024-12-17 12:51:08 -08:00
Takashi Iwai
d0e1b23b5d UPSTREAM: ALSA: usb-audio: Fix out of bounds reads when finding clock sources
commit a3dd4d63eeb452cfb064a13862fb376ab108f6a6 upstream.

The current USB-audio driver code doesn't check bLength of each
descriptor at traversing for clock descriptors.  That is, when a
device provides a bogus descriptor with a shorter bLength, the driver
might hit out-of-bounds reads.

For addressing it, this patch adds sanity checks to the validator
functions for the clock descriptor traversal.  When the descriptor
length is shorter than expected, it's skipped in the loop.

For the clock source and clock multiplier descriptors, we can just
check bLength against the sizeof() of each descriptor type.
OTOH, the clock selector descriptor of UAC2 and UAC3 has an array
of bNrInPins elements and two more fields at its tail, hence those
have to be checked in addition to the sizeof() check.

Bug: 382239029
Reported-by: Benoît Sevens <bsevens@google.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/20241121140613.3651-1-bsevens@google.com
Link: https://patch.msgid.link/20241125144629.20757-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 74cb86e100)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I13e916ffd46fce6fd08f7b9f96cea82bb4bc475d
2024-12-17 12:06:22 +00:00
Kever Yang
e93c64d683 ANDROID: GKI: Update symbols need by rockchip drm
INFO: 2 function symbol(s) added
  'int drm_atomic_bridge_chain_check(struct drm_bridge*, struct drm_crtc_state*, struct drm_connector_state*)'
  'struct drm_bridge_state* drm_atomic_get_bridge_state(struct drm_atomic_state*, struct drm_bridge*)'

Bug: 300024866
Change-Id: Ib0ec45e0cfc664d8ca9adac68f7bdaac80c4c2f7
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2024-12-16 11:55:28 -08:00
Benoît Sevens
a84242054b UPSTREAM: ALSA: usb-audio: Fix potential out-of-bound accesses for Extigy and Mbox devices
commit b909df18ce2a998afef81d58bbd1a05dc0788c40 upstream.

A bogus device can provide a bNumConfigurations value that exceeds the
initial value used in usb_get_configuration for allocating dev->config.

This can lead to out-of-bounds accesses later, e.g. in
usb_destroy_configuration.

Bug: 382243530
Signed-off-by: Benoît Sevens <bsevens@google.com>
Fixes: 1da177e4c3 ("Linux-2.6.12-rc2")
Cc: stable@kernel.org
Link: https://patch.msgid.link/20241120124144.3814457-1-bsevens@google.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit b8f8b81dab)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I1aa1a442a5c87116200dcab02f84e1bd48f86bb5
2024-12-16 08:24:16 -08:00
Hyunwoo Kim
204945a2da UPSTREAM: vsock/virtio: Initialization of the dangling pointer occurring in vsk->trans
commit 6ca575374dd9a507cdd16dfa0e78c2e9e20bd05f upstream.

During loopback communication, a dangling pointer can be created in
vsk->trans, potentially leading to a Use-After-Free condition.  This
issue is resolved by initializing vsk->trans to NULL.

Bug: 378870958
Cc: stable <stable@kernel.org>
Fixes: 06a8fc7836 ("VSOCK: Introduce virtio_vsock_common.ko")
Signed-off-by: Hyunwoo Kim <v4bel@theori.io>
Signed-off-by: Wongi Lee <qwerty@theori.io>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Message-Id: <2024102245-strive-crib-c8d3@gregkh>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit b110196fec)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I5eb7b5ccf7f0d96644cc4313548c0114e8836149
2024-12-16 07:31:08 -08:00
Greg Kroah-Hartman
367540fdf9 Merge tag 'android14-6.1.118_r00' into android14-6.1
This merges up to the 6.1.118 LTS release into the android14-6.1 branch.
Changes included in here are:

*   2f2512ac10 Merge 6.1.118 into android14-6.1-lts
|\
| * b67dc5c9ad Linux 6.1.118
| * 6a8d39ee34 9p: fix slab cache name creation for real
| * 509c1c6b49 fs/ntfs3: Fix general protection fault in run_is_mapped_full
| * ba0b09a2f3 platform/x86: x86-android-tablets: Fix use after free on platform_device_register() errors
| * 486aeb5f18 mm: krealloc: Fix MTE false alarm in __do_krealloc
| * b22346eec4 Bluetooth: L2CAP: Fix uaf in l2cap_connect
| * cf3196e5e2 ext4: fix timer use-after-free on failed mount
| * e7831613cb drm/amdkfd: amdkfd_free_gtt_mem clear the correct pointer
| * 0dc3ad9ad2 uprobe: avoid out-of-bounds memory access of fetching args
| * 02079f0922 uprobes: encapsulate preparation of uprobe args buffer
| * fdacd09f2d io_uring: fix possible deadlock in io_register_iowq_max_workers()
| * 9478355c63 md/raid10: improve code of mrdev in raid10_sync_request
| * d4b003f720 net: usb: qmi_wwan: add Fibocom FG132 0x0112 composition
| * 8118551b4f LoongArch: Use "Exception return address" to comment ERA
| * 807692abc6 HID: lenovo: Add support for Thinkpad X1 Tablet Gen 3 keyboard
| * 5622881cf0 HID: multitouch: Add quirk for Logitech Bolt receiver w/ Casa touchpad
| * 5a72b0d349 fs: Fix uninitialized value issue in from_kuid and from_kgid
| * cdd28621bb bpf: Fix mismatched RCU unlock flavour in bpf_out_neigh_v6
| * 32c982b520 vDPA/ifcvf: Fix pci_read_config_byte() return code handling
| * afa2294653 nvme: make keep-alive synchronous operation
| * ffdebf3da1 powerpc/powernv: Free name on error in opal_event_init()
| * 60de2e03f9 nvme-multipath: defer partition scanning
| * f17c880a47 drm/vmwgfx: Limit display layout ioctl array size to VMWGFX_NUM_DISPLAY_UNITS
| * b8d1f4d383 sound: Make CONFIG_SND depend on INDIRECT_IOMEM instead of UML
| * 75a1b35dcc crypto: marvell/cesa - Disable hash algorithms
| * 1bc59a7c07 crypto: api - Fix liveliness check in crypto_alg_tested
| * 911c9bc048 bpf: use kvzmalloc to allocate BPF verifier environment
| * ccf7d31481 nvme: disable CC.CRIME (NVME_CC_CRIME)
| * eb6751a26a HID: multitouch: Add quirk for HONOR MagicBook Art 14 touchpad
| * c2242ebafd HID: multitouch: Add support for B2402FVA track point
| * 77b0a8b062 block: Fix elevator_get_default() checking for NULL q->tag_set
| * 4f946479b3 nvme: tcp: avoid race between queue_lock lock and destroy
| * 94a4d966f7 irqchip/ocelot: Fix trigger register address
| * af39f19c71 9p: Avoid creating multiple slab caches with the same name
| * 903227b616 Revert "Bluetooth: hci_conn: Consolidate code for aborting connections"
| * 4c69abb4d4 Revert "Bluetooth: hci_core: Fix possible buffer overflow"
* | 27e7205cf2 Merge 0625d7c240 ("Revert "Bluetooth: af_bluetooth: Fix deadlock"") into android14-6.1-lts
|\|
| * 0625d7c240 Revert "Bluetooth: af_bluetooth: Fix deadlock"
| * 0337fb0928 Revert "Bluetooth: hci_sync: Fix overwriting request callback"
| * 21b39fa205 Revert "Bluetooth: fix use-after-free in accessing skb after sending it"
* | bb58b1f9bf Merge 6.1.117 into android14-6.1-lts
|\|
| * 59d7b1a710 Linux 6.1.117
| * 178379985e media: amphion: Fix VPU core alias name
| * 44d29897ea vsock/virtio: Initialization of the dangling pointer occurring in vsk->trans
| * 98d8dde923 hv_sock: Initializing vsk->trans to NULL to prevent a dangling pointer
| * b911fa9e92 net: sched: use RCU read-side critical section in taprio_dump()
| * 7f6c3c7f8d ASoC: amd: yc: fix internal mic on Xiaomi Book Pro 14 2022
| * 7bce2c7ac8 ucounts: fix counter leak in inc_rlimit_get_ucounts()
| * 86dd0e8d42 ocfs2: remove entry once instead of null-ptr-dereference in ocfs2_xa_remove()
| * 8525160ea2 irqchip/gic-v3: Force propagation of the active state with a read-back
| * ded5200f83 USB: serial: option: add Quectel RG650V
| * 9b298c819a USB: serial: option: add Fibocom FG132 0x0112 composition
| * 5a4a73a6e6 USB: serial: qcserial: add support for Sierra Wireless EM86xx
| * 275258c30b USB: serial: io_edgeport: fix use after free in debug printk
| * 604314ecd6 usb: typec: fix potential out of bounds in ucsi_ccg_update_set_new_cam_cmd()
| * 562804b156 usb: dwc3: fix fault at system suspend if device was already runtime suspended
| * ccd811c304 usb: musb: sunxi: Fix accessing an released usb phy
| * 012f4d5d25 signal: restore the override_rlimit logic
| * 190911cebd fs/proc: fix compile warning about variable 'vmcore_mmap_ops'
| * 26530b757c filemap: Fix bounds checking in filemap_read()
| * beced2cb09 media: uvcvideo: Skip parsing frames of type UVC_VS_UNDEFINED in uvc_parse_format
| * c8ec4e437a kselftest/arm64: Initialise current at build time in signal tests
| * a60db84f77 net: do not delay dst_entries_add() in dst_release()
| * 5cf45281a6 Revert "wifi: mac80211: fix RCU list iterations"
| * 84d2f29152 bnxt_re: avoid shift undefined behavior in bnxt_qplib_alloc_init_hwq
| * 10ffafb456 riscv/purgatory: align riscv_kernel_entry
| * 2cb1a73d1d btrfs: reinitialize delayed ref list after deleting it from the list
| * ba884534f1 arm64: Kconfig: Make SME depend on BROKEN for now
| * aa3e68bd45 mptcp: use sock_kfree_s instead of kfree
| * 2cf0e77f5a net: vertexcom: mse102x: Fix possible double free of TX skb
| * 424c4acb33 net: wwan: t7xx: Fix off-by-one error in t7xx_dpmaif_rx_buf_alloc()
| * f6b2b2b981 nfs: Fix KMSAN warning in decode_getfattr_attrs()
| * d3bcf4069d posix-cpu-timers: Clear TICK_DEP_BIT_POSIX_TIMER on clone
| * 1ced986a37 ALSA: hda/realtek: Fix headset mic on TUXEDO Gemini 17 Gen3
| * 4fee0ad11a ALSA: usb-audio: Add quirk for HP 320 FHD Webcam
| * 80342c5876 dm-unstriped: cast an operand to sector_t to prevent potential uint32_t overflow
| * c52ec00cb2 dm cache: fix potential out-of-bounds access on the first resume
| * 011450c2f9 dm cache: optimize dirty bit checking with find_next_bit when resizing
| * 56507203e1 dm cache: fix out-of-bounds access to the dirty bitset when resizing
| * 5a754d3c77 dm cache: fix flushing uninitialized delayed_work on cache_ctr error
| * ffaf0f6eab dm cache: correct the number of origin blocks to match the target length
| * 66ada34425 thermal/drivers/qcom/lmh: Remove false lockdep backtrace
| * 1a9f55ed5b drm/amdgpu: prevent NULL pointer dereference if ATIF is not supported
| * 25d7e84343 drm/amdgpu: add missing size check in amdgpu_debugfs_gprwave_read()
| * 91139f33b0 drm/amdgpu: Adjust debugfs eviction and IB access permissions
| * 284e213f0e pwm: imx-tpm: Use correct MODULO value for EPWM mode
| * f7557bbca4 ksmbd: fix slab-use-after-free in smb3_preauth_hash_rsp
| * d8664ce789 ksmbd: Fix the missing xa_store error check
| * f56446ba53 ksmbd: fix slab-use-after-free in ksmbd_smb2_session_create
| * 49500cfd14 can: mcp251xfd: mcp251xfd_ring_alloc(): fix coalescing configuration when switching CAN modes
| * 4ee68cf530 can: mcp251xfd: mcp251xfd_get_tef_len(): fix length calculation
| * f7503fd2d7 media: v4l2-ctrls-api: fix error handling for v4l2_g_ctrl()
| * c63c30c9d9 media: v4l2-tpg: prevent the risk of a division by zero
| * 4b132a464f media: pulse8-cec: fix data timestamp at pulse8_setup()
| * fbefe31e45 media: cx24116: prevent overflows on SNR calculus
| * c85db2d443 media: s5p-jpeg: prevent buffer overflows
| * 5e1523076a media: ar0521: don't overflow when checking PLL values
| * 4f1d74f747 ASoC: stm32: spdifrx: fix dma channel release in stm32_spdifrx_remove
| * 2e9a53eef2 thermal/of: support thermal zones w/o trips subnode
| * 648e7f59e8 tools/lib/thermal: Fix sampling handler context ptr
| * 42a26e971e ALSA: firewire-lib: fix return value on fail in amdtp_tscm_init()
| * 3b4f6966d7 scsi: sd_zbc: Use kvzalloc() to allocate REPORT ZONES buffer
| * d98c63c00c media: adv7604: prevent underflow condition when reporting colorspace
| * fd6d84b8ee media: dvb_frontend: don't play tricks with underflow values
| * b751a96025 media: dvbdev: prevent the risk of out of memory access
| * d6386b279d media: stb0899_algo: initialize cfr before using it
| * 3f8f470f31 Revert "ALSA: hda/conexant: Mute speakers at suspend / shutdown"
| * 98ffd58530 net: arc: rockchip: fix emac mdio node support
| * fd4e062fbc net: arc: fix the device for dma_map_single/dma_unmap_single
| * f3401e3c8d virtio_net: Add hash_key_length check
| * 2af6499260 net: stmmac: Fix unbalanced IRQ wake disable warning on single irq case
| * 7efd9a10b8 net: phy: ti: add PHY_RST_AFTER_CLK_EN flag
| * 76b155e14d net: hns3: fix kernel crash when uninstalling driver
| * 7ad3fb3bfd i40e: fix race condition by adding filter's intermediate sync state
| * 64aa077114 ice: change q_index variable type to s16 to store -1 value
| * dac989c2a3 can: c_can: fix {rx,tx}_errors statistics
| * bf9bff1322 sctp: properly validate chunk size in sctp_sf_ootb()
| * 12a3977538 net: enetc: set MAC address to the VF net_device
| * bbad2d5b6c security/keys: fix slab-out-of-bounds in key_task_permission
| * 99659d2345 nfs: avoid i_lock contention in nfs_clear_invalid_mapping
| * ba5634feb2 NFSv3: handle out-of-order write replies.
| * 9a65be8111 NFSv3: only use NFS timeout for MOUNT when protocols are compatible
| * f22232160e sunrpc: handle -ENOTCONN in xs_tcp_setup_socket()
| * a50863dd1f platform/x86/amd/pmc: Detect when STB is not available
| * 1884ab3d22 HID: core: zero-initialize the report buffer
| * 5d739ad16c ARM: dts: rockchip: Fix the realtek audio codec on rk3036-kylin
| * 89e601bd73 ARM: dts: rockchip: Fix the spi controller on rk3036
| * 44c3b97a1c ARM: dts: rockchip: drop grf reference from rk3036 hdmi
| * f7539956d7 ARM: dts: rockchip: fix rk3036 acodec node
| * a45a7930f4 arm64: dts: imx8mp: correct sdhc ipg clk
| * 65af08b542 arm64: dts: imx8-ss-vpu: Fix imx8qm VPU IRQs
| * 272abcefdb arm64: dts: imx8qxp: Add VPU subsystem file
| * ed5268f3e8 arm64: dts: imx8qm: Fix VPU core alias name
| * 7219ff9791 arm64: dts: rockchip: Fix LED triggers on rk3308-roc-cc
| * 3746e8b25a arm64: dts: rockchip: Remove #cooling-cells from fan on Theobroma lion
| * 72b96b794d arm64: dts: rockchip: Fix bluetooth properties on Rock960 boards
| * d6477a9858 arm64: dts: rockchip: Fix wakeup prop names on PineNote BT node
| * 8db0adaefe arm64: dts: rockchip: Remove hdmi's 2nd interrupt on rk3328
| * 89b30d16db arm64: dts: rockchip: Fix rt5651 compatible value on rk3399-sapphire-excavator
| * d7b0f08fd6 arm64: dts: rockchip: Fix rt5651 compatible value on rk3399-eaidk-610
* | 98a32bd6ec Merge 6.1.116 into android14-6.1-lts
|\|
| * d7039b844a Linux 6.1.116
| * 7dcd620416 migrate_pages_batch: fix statistics for longterm pin retry
| * b3660228db mm: avoid gcc complaint about pointer casting
| * 23c4cb8a56 vt: prevent kernel-infoleak in con_font_get()
| * 87de0a741e drm/amd/display: Skip on writeback when it's not applicable
| * 5e84eda48f drm/amd/display: Add null checks for 'stream' and 'plane' before dereferencing
| * a207af9bfe mtd: spi-nor: winbond: fix w25q128 regression
| * 1c2f04ce02 LoongArch: Fix build errors due to backported TIMENS
| * 82cae1e30b mm: shmem: fix data-race in shmem_getattr()
| * cde8a7eb5c wifi: iwlwifi: mvm: fix 6 GHz scan construction
| * cd0cdb51b1 nilfs2: fix kernel bug due to missing clearing of checked flag
| * 0acaf4a502 wifi: mac80211: fix NULL dereference at band check in starting tx ba session
| * 38c5fe74f3 x86/bugs: Use code segment selector for VERW operand
| * 9f5a834715 io_uring: always lock __io_cqring_overflow_flush
| * 79a727a9b8 vmscan,migrate: fix page count imbalance on node stats when demoting pages
| * 8ca5f0ea52 migrate_pages: split unmap_and_move() to _unmap() and _move()
| * f9e9725daf migrate_pages: restrict number of pages to migrate in batch
| * 1145493ce5 migrate_pages: separate hugetlb folios migration
| * 6058d02a81 migrate_pages: organize stats with struct migrate_pages_stats
| * de0a1554a4 mm/migrate.c: stop using 0 as NULL pointer
| * 2a4b092d91 migrate: convert migrate_pages() to use folios
| * b0030b8699 migrate: convert unmap_and_move() to use folios
| * 01a0c92883 mm: migrate: try again if THP split is failed due to page refcnt
| * 9e8debb8e5 io_uring/rw: fix missing NOWAIT check for O_DIRECT start write
| * 0ed78d3a29 io_uring: use kiocb_{start,end}_write() helpers
| * 6d42982ad0 fs: create kiocb_{start,end}_write() helpers
| * 45676b8299 io_uring: rename kiocb_end_write() local helper
| * 8f6a0b1f41 kasan: remove vmalloc_percpu test
| * c94e965f76 nvmet-auth: assign dh_key to NULL after kfree_sensitive
| * 618d193924 ALSA: hda/realtek: Fix headset mic on TUXEDO Stellaris 16 Gen6 mb1
| * 4707893315 mctp i2c: handle NULL header address
| * 2fe5d62e12 ocfs2: pass u64 to ocfs2_truncate_inline maybe overflow
| * 189b954469 mm/page_alloc: let GFP_ATOMIC order-0 allocs access highatomic reserves
| * bb414b7f41 mm/page_alloc: explicitly define how __GFP_HIGH non-blocking allocations accesses reserves
| * 1cf970483e mm/page_alloc: explicitly define what alloc flags deplete min reserves
* | 64e5459c98 Merge 7468bd2c6e ("mm/page_alloc: explicitly record high-order atomic allocations in alloc_flags") into android14-6.1-lts
|/
* 7468bd2c6e mm/page_alloc: explicitly record high-order atomic allocations in alloc_flags

Change-Id: I7e9c61362ad083dba825e399db297a3d91328d31
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2024-12-16 02:51:02 -08:00
Rui Chen
22b7ded8b5 ANDROID: ABI: update symbol list for honor
1 function symbol(s) added
  'int __traceiter_android_vh_io_statistics(void*, struct address_space*, unsigned int, unsigned int, bool, bool)'

1 variable symbol(s) added
  'struct tracepoint __tracepoint_android_vh_io_statistics'

Bug: 380502059
Change-Id: I1d8c086fc718bf2a9d993b8202c2642833a8ba5b
Signed-off-by: Rui Chen <chenrui9@honor.com>
2024-12-12 13:12:30 -08:00
Rui Chen
dbb9fda3cf ANDROID: fs: add vendor hook to collect IO statistics
Add vendor hook to get metainfo of direct/buffered read and write.
Determine hot files in each performance-sensitive user scenario.

Bug: 380502059
Change-Id: Ie7604852df637d6664afd72e87bd6d4b14bbc2a2
Signed-off-by: Rui Chen <chenrui9@honor.com>
2024-12-12 13:12:30 -08:00
Udipto Goswami
b9ba16d91d UPSTREAM: usb: xhci: Implement xhci_handshake_check_state() helper
In some situations where xhci removal happens parallel to xhci_handshake,
we encounter a scenario where the xhci_handshake can't succeed, and it
polls until timeout.

If xhci_handshake runs until timeout it can on some platforms result in
a long wait which might lead to a watchdog timeout.

Add a helper that checks xhci status during the handshake, and exits if
set state is entered. Use this helper in places where xhci_handshake is
called unlocked and has a long timeout. For example  xhci command timeout
and xhci reset.

[commit message and code comment rewording -Mathias]

Signed-off-by: Udipto Goswami <quic_ugoswami@quicinc.com>
Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Link: https://lore.kernel.org/r/20231019102924.2797346-18-mathias.nyman@linux.intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 383443034
Change-Id: Iec54af32dcf6b07075e3f084dba914fc43635ee6
(cherry picked from commit 6ccb83d6c4972ebe6ae49de5eba051de3638362c)
Signed-off-by: Faisal Hassan <quic_faisalh@quicinc.com>
2024-12-11 12:49:35 -08:00
Todd Kjos
191acd0d6a Revert "UPSTREAM: unicode: Don't special case ignorable code points"
This reverts commit 62bbb08add179b68e2ce0ede59f3c4b37d6c92a8.

Reason for revert: b/382800956

Bug: 382800956
Change-Id: Ic7a0cdbb060c12c1628a5859d795e78cd6b9341d
Signed-off-by: Todd Kjos <tkjos@google.com>
(cherry picked from commit c376628415656f16d398aad95c218a06805038bd)
Signed-off-by: Lee Jones <joneslee@google.com>
2024-12-11 18:44:17 +00:00
Todd Kjos
0a310649d8 Reapply "UPSTREAM: unicode: Don't special case ignorable code points"
This reverts commit e1ba90026d98e53f5736131f3363424e83315f00.

Reapplying only to re-revert with the correct Change-Id

Bug: 382800956
Signed-off-by: Todd Kjos <tkjos@google.com>
Change-Id: Icdd08040f04ed7e85d31b7f8551ee2ef1d0b95b0
2024-12-11 18:21:53 +00:00
meixie
e318dc4c06 ANDROID: abi_gki_aarch64_qcom: Update symbols list for Qcom
Update symbols list for Qcom

Symbols added:
   default_qdisc_ops
   dev_activate
   dev_deactivate
   dev_graft_qdisc
   gnet_stats_add_basic
   gnet_stats_add_queue
   gnet_stats_basic_sync_init
   gnet_stats_copy_basic
   gnet_stats_copy_queue
   mq_change_real_num_tx
   netdev_txq_to_tc
   noop_qdisc
   pfifo_fast_ops
   pfifo_qdisc_ops
   qdisc_create_dflt
   qdisc_hash_add
   qdisc_put
   qdisc_reset
   qdisc_tree_reduce_backlog
   qdisc_watchdog_cancel
   qdisc_watchdog_init
   qdisc_watchdog_init_clockid
   qdisc_watchdog_schedule_range_ns
   rtnl_kfree_skbs
   sock_queue_err_skb

Bug: 369460491

Change-Id: I1d0b22f03250d3c33d6fd23cf02f6d014444a2b4
Signed-off-by: meixie <quic_meixie@quicinc.com>
2024-12-11 08:08:21 -08:00
Todd Kjos
904ebc320c Revert "UPSTREAM: unicode: Don't special case ignorable code points"
This reverts commit 8097478ae8.

Reason for revert: b/382800956

Change-Id: Ie03821befee269e6dac987900364d48a95d6d65b
Signed-off-by: Todd Kjos <tkjos@google.com>
2024-12-11 01:17:34 +00:00
Vincent Donnefort
0f332d7edc ANDROID: KVM: arm64: Fix missing mutex init for hyp trace readers
Prevent the kernel from crashing when using the hypervisor tracing.
While bringing locking for the nVHE hyp tracing readers, init has been
omitted. This resulted in a stack trace with the following signature
when tracing was enabled:

[   85.897294][ T6772] Call trace:
[   85.900420][ T6772]  __list_add_valid+0x78/0xbc
[   85.904937][ T6772]  __mutex_add_waiter+0x54/0x138
[   85.909711][ T6772]  __mutex_lock+0x344/0xdac
[   85.914054][ T6772]  __mutex_lock_slowpath+0x14/0x24
[   85.919003][ T6772]  mutex_lock+0x40/0xec
[   85.922998][ T6772]  hyp_trace_pipe_read+0x37c/0x418
[   85.927948][ T6772]  vfs_read+0x100/0x2c0
[   85.931942][ T6772]  ksys_read+0x78/0xe8
[   85.935850][ T6772]  __arm64_sys_read+0x1c/0x2c
[   85.940367][ T6772]  invoke_syscall+0x58/0x11c
[   85.944794][ T6772]  el0_svc_common+0xb4/0xf4
[   85.949137][ T6772]  do_el0_svc+0x2c/0xb0
[   85.953132][ T6772]  el0_svc+0x2c/0x90
[   85.956865][ T6772]  el0t_64_sync_handler+0x68/0xb4
[   85.961728][ T6772]  el0t_64_sync+0x1a4/0x1a8
[   85.966072][ T6772] Code: d4210000 d0007080 91271c00 9423d9aa

Bug: 229972309
Bug: 380818540
Test: enable hypervisor tracing per-cpu and fetch hyp events
Fixes: 34305ad4b1 ("ANDROID: KVM: arm64: Add host support for the nVHE hyp tracing")
Change-Id: I5269e030f0744bdff8ca8c71260e41c74b20f21b
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
Signed-off-by: Sebastian Ene <sebastianene@google.com>
2024-12-10 13:41:18 +00:00
yipeng xiang
affd0c0263 ANDROID: mm: EXPORT_SYMBOL_GPL(reclaim_pages) position adjustment
EXPORT_SYMBOL_GPL(reclaim_pages) should follow reclaim_pages, not __reclaim_pages.

Bug: 365902592
Change-Id: Ieb1b991e40c8893af679fc3c3d711cd0ae049c9c
Signed-off-by: yipeng xiang <yipengxiang@honor.corp-partner.google.com>
2024-12-09 23:59:03 +00:00
Seiya Wang
d8ccecb7c2 ANDROID: GKI: Update symbol list for mtk
1 function symbol(s) added
  'unsigned int tty_buffer_space_avail(struct tty_port*)'

Bug: 383039133
Change-Id: Ic92096ecc482c120b8cda325a7f2ae44f99e8527
Signed-off-by: Seiya Wang <seiya.wang@mediatek.com>
2024-12-09 17:28:05 +00:00
Jiri Kosina
853ec04e2d UPSTREAM: HID: core: zero-initialize the report buffer
[ Upstream commit 177f25d1292c7e16e1199b39c85480f7f8815552 ]

Since the report buffer is used by all kinds of drivers in various ways, let's
zero-initialize it during allocation to make sure that it can't be ever used
to leak kernel memory via specially-crafted report.

Bug: 380395346
Fixes: 27ce405039 ("HID: fix data access in implement()")
Reported-by: Benoît Sevens <bsevens@google.com>
Acked-by: Benjamin Tissoires <bentiss@kernel.org>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 9d9f5c75c0)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I31f64f2745347137bbc415eb35b7fab5761867f3
2024-12-09 12:10:24 +00:00
Seiya Wang
c276c53965 ANDROID: GKI: Update symbol list for mtk
1 function symbol(s) added
  'int snd_pcm_format_set_silence(snd_pcm_format_t, void*, unsigned int)'

Bug: 382303912
Signed-off-by: Seiya Wang <seiya.wang@mediatek.com>
Change-Id: I7de7c367b52114b9770697cf3eaeb47008a0e52b
2024-12-06 13:04:12 +00:00
Saravana Kannan
fddf80a6ac UPSTREAM: of: property: fw_devlink: Add support for "post-init-providers" property
Add support for this property so that dependency cycles can be broken and
fw_devlink can do better probe/suspend/resume ordering between devices in a
dependency cycle.

Signed-off-by: Saravana Kannan <saravanak@google.com>
Acked-by: "Rafael J. Wysocki" <rafael@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20240305050458.1400667-4-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 135116f3d01402b610e00dd54f3b059a3faf35de)
Change-Id: I49e29a38ebc5b0a663d8d336512be1b56ca607c7
Bug: 347344057
2024-12-06 01:31:16 +00:00
Saravana Kannan
b865d3ed06 UPSTREAM: driver core: Add FWLINK_FLAG_IGNORE to completely ignore a fwnode link
A fwnode link between specific supplier-consumer fwnodes can be added
multiple times for multiple reasons. If that dependency doesn't exist,
deleting the fwnode link once doesn't guarantee that it won't get created
again.

So, add FWLINK_FLAG_IGNORE flag to mark a fwnode link as one that needs to
be completely ignored. Since a fwnode link's flags is an OR of all the
flags passed to all the fwnode_link_add() calls to create that specific
fwnode link, the FWLINK_FLAG_IGNORE flag is preserved and can be used to
mark a fwnode link as on that need to be completely ignored until it is
deleted.

Signed-off-by: Saravana Kannan <saravanak@google.com>
Acked-by: "Rafael J. Wysocki" <rafael@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20240305050458.1400667-3-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit b7e1241d8f77ed64404a5e4450f43a319310fc91)
Change-Id: If9cbc4adf796816a6c04de049d57d7a5d0858e27
Bug: 347344057
2024-12-06 01:31:16 +00:00
Saravana Kannan
0a05df9c8a UPSTREAM: driver core: Adds flags param to fwnode_link_add()
Allow the callers to set fwnode link flags when adding fwnode links.

Signed-off-by: Saravana Kannan <saravanak@google.com>
Acked-by: "Rafael J. Wysocki" <rafael@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Link: https://lore.kernel.org/r/20240305050458.1400667-2-saravanak@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 75cde56a5b504d07a64ce0e3f8c7410df70308a3)
Change-Id: Idb03ec39da06d58052cd8080d39c2efe0ad9d3af
Bug: 347344057
2024-12-06 01:31:16 +00:00
Qi Han
182b090f35 UPSTREAM: f2fs: modify f2fs_is_checkpoint_ready logic to allow more data to be written with the CP disable
When the free segment is used up during CP disable, many write or
ioctl operations will get ENOSPC error codes, even if there are
still many blocks available. We can reproduce it in the following
steps:

dd if=/dev/zero of=f2fs.img bs=1M count=65
mkfs.f2fs -f f2fs.img
mount f2fs.img f2fs_dir -o checkpoint=disable:10%
cd f2fs_dir
i=1 ; while [[ $i -lt 50 ]] ; do (file_name=./2M_file$i ; dd \
if=/dev/random of=$file_name bs=1M count=2); i=$((i+1)); done
sync
i=1 ; while [[ $i -lt 50 ]] ; do (file_name=./2M_file$i ; truncate \
-s 1K $file_name); i=$((i+1)); done
sync
dd if=/dev/zero of=./file bs=1M count=20

In f2fs_need_SSR() function, it is allowed to use SSR to allocate
blocks when CP is disabled, so in f2fs_is_checkpoint_ready function,
can we judge the number of invalid blocks when free segment is not
enough, and return ENOSPC only if the number of invalid blocks is
also not enough.

Signed-off-by: Qi Han <hanqi@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 84b5bb8bf0f6a78c232a20c2eecdbb8112ac2703)
Signed-off-by: Daniel Rosenberg <drosen@google.com>
(cherry picked from https://android-review.googlesource.com/q/commit:225caf3bdf7a4977ae50ba9b5c5470a16d480100)
Merged-In: I41ad315f603cd764d0e9b8ef984447e7116b1514
Change-Id: I41ad315f603cd764d0e9b8ef984447e7116b1514
2024-12-05 01:19:03 +00:00
Chao Yu
38149d5303 BACKPORT: f2fs: introduce get_available_block_count() for cleanup
There are very similar codes in inc_valid_block_count() and
inc_valid_node_count() which is used for available user block
count calculation.

This patch introduces a new helper get_available_block_count()
to include those common codes, and used it to clean up codes.

Change-Id: Ie2ce55bdac091bc4880478eeba2a76e1608726e3
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 0f1c6ede6da9f7c5dd7380b74a64850298279168)
[Added line for F2FS_IO_ALIGNED, which was removed in later kernels]
Signed-off-by: Daniel Rosenberg <drosen@google.com>
2024-12-05 01:18:53 +00:00
Mukesh Ojha
997d1e6f69 FROMGIT: pinmux: Use sequential access to access desc->pinmux data
When two client of the same gpio call pinctrl_select_state() for the
same functionality, we are seeing NULL pointer issue while accessing
desc->mux_owner.

Let's say two processes A, B executing in pin_request() for the same pin
and process A updates the desc->mux_usecount but not yet updated the
desc->mux_owner while process B see the desc->mux_usecount which got
updated by A path and further executes strcmp and while accessing
desc->mux_owner it crashes with NULL pointer.

Serialize the access to mux related setting with a mutex lock.

	cpu0 (process A)			cpu1(process B)

pinctrl_select_state() {		  pinctrl_select_state() {
  pin_request() {				pin_request() {
  ...
						 ....
    } else {
         desc->mux_usecount++;
    						desc->mux_usecount && strcmp(desc->mux_owner, owner)) {

         if (desc->mux_usecount > 1)
               return 0;
         desc->mux_owner = owner;

  }						}

Bug: 376023321
Bug: 381832937
Link: https://lore.kernel.org/lkml/20241014192930.1539673-1-quic_mojha@quicinc.com/
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
(cherry picked from commit 5a3e85c3c397c781393ea5fb2f45b1f60f8a4e6e
 git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git for-next)
Change-Id: Ib417544f0dcc5174d6f9b01d0243c19162f82fff
Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
Signed-off-by: Srinivasarao Pathipati <quic_c_spathi@quicinc.com>
2024-12-02 22:09:46 +00:00
Florian Fainelli
fa34bcaf9e BACKPORT: firmware: arm_scmi: Support 'reg-io-width' property for shared memory
Some shared memory areas might only support a certain access width,
such as 32-bit, which memcpy_{from,to}_io() does not adhere to at least
on ARM64 by making both 8-bit and 64-bit accesses to such memory.

Update the shmem layer to support reading from and writing to such
shared memory area using the specified I/O width in the Device Tree. The
various transport layers making use of the shmem.c code are updated
accordingly to pass the I/O accessors that they store.

Bug: 369085303
Change-Id: I97d80dd4027fe8290781ad7fc3859c2bdaf34522
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Message-Id: <20240827182450.3608307-3-florian.fainelli@broadcom.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
(cherry picked from commit 2cd7f3db25feeb7c204e36df9f1bb13bea3a3a20)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
Signed-off-by: Pierre Couillaud <pierre@broadcom.com>
2024-12-02 20:18:26 +00:00
Florian Fainelli
c9e7fc262f UPSTREAM: dt-bindings: sram: Document reg-io-width property
Some SRAMs need to be accessed with a specific access width, define
the 'reg-io-width' property specifying such access sizes.

Bug: 369085303
Change-Id: I8848088221053fbd462d4f7310fffab861944879
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
Message-Id: <20240827182450.3608307-2-florian.fainelli@broadcom.com>
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
(cherry picked from commit 14b2157a9c14481c3b967d8d1a95972bf885fb88)
Signed-off-by: Danesh Petigara <danesh.petigara@broadcom.com>
Signed-off-by: Pierre Couillaud <pierre@broadcom.com>
2024-12-02 20:18:26 +00:00