Commit Graph

991947 Commits

Author SHA1 Message Date
Jaegeuk Kim
073b997b02 BACKPORT: f2fs: initialize extent_cache parameter
This can avoid confusing tracepoint values.

Bug: 264453689
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit b5825de803e7cf56262f5b3a8bc692d61acfe653)
Change-Id: Ia43e2c1fd405a11fc4122b68f05f40c10f47f263
2023-01-10 18:49:35 +00:00
Jaegeuk Kim
aa064914fd BACKPORT: f2fs: add block_age-based extent cache
This patch introduces a runtime hot/cold data separation method
for f2fs, in order to improve the accuracy for data temperature
classification, reduce the garbage collection overhead after
long-term data updates.

Enhanced hot/cold data separation can record data block update
frequency as "age" of the extent per inode, and take use of the age
info to indicate better temperature type for data block allocation:
 - It records total data blocks allocated since mount;
 - When file extent has been updated, it calculate the count of data
blocks allocated since last update as the age of the extent;
 - Before the data block allocated, it searches for the age info and
chooses the suitable segment for allocation.

Test and result:
 - Prepare: create about 30000 files
  * 3% for cold files (with cold file extension like .apk, from 3M to 10M)
  * 50% for warm files (with random file extension like .FcDxq, from 1K
to 4M)
  * 47% for hot files (with hot file extension like .db, from 1K to 256K)
 - create(5%)/random update(90%)/delete(5%) the files
  * total write amount is about 70G
  * fsync will be called for .db files, and buffered write will be used
for other files

The storage of test device is large enough(128G) so that it will not
switch to SSR mode during the test.

Benefit: dirty segment count increment reduce about 14%
 - before: Dirty +21110
 - after:  Dirty +18286

Bug: 264453689
Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com>
Signed-off-by: xiongping1 <xiongping1@xiaomi.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 729055d7f1e665c57c1c90b093501cb3eb47a876)
Change-Id: I8a62846bd3d44f7243300fa9653dbb623b46a96c
2023-01-10 18:49:35 +00:00
Jaegeuk Kim
d6ba4dceab BACKPORT: f2fs: allocate the extent_cache by default
Let's allocate it to remove the runtime complexity.

Bug: 264453689
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 693658e0c0eca25087c1ffb318d85f8d392d6d27)
Change-Id: Ib46b6edd4f4a6232f3451498ee5c2f246dd37682
2023-01-10 18:49:35 +00:00
Jaegeuk Kim
72e9dd90cf BACKPORT: f2fs: refactor extent_cache to support for read and more
This patch prepares extent_cache to be ready for addition.

Bug: 264453689
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 7cf42d77c7242d23988215297bdd2d215e208b6f)
Change-Id: I5ca06c274529187b804ddd4b0834dc44fe6aa8ad
2023-01-10 18:49:35 +00:00
Jaegeuk Kim
561e9febb3 BACKPORT: f2fs: remove unnecessary __init_extent_tree
Added into the caller.

Bug: 264453689
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 0b461f459f0f53ff29b0ff98d4c18808b4248dcc)
Change-Id: Ic52ba22c00055bfe85bb789e6fd057d5fa84c00f
2023-01-10 18:49:35 +00:00
Jaegeuk Kim
bf3cafe7f1 BACKPORT: f2fs: move internal functions into extent_cache.c
No functional change.

Bug: 264453689
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit f458f39556cec5660a5508fbbeea4917bc46bc9c)
Change-Id: I6171ab293b214a2eeb3f420517216371ee29557e
2023-01-10 18:49:35 +00:00
Jaegeuk Kim
b29b3bd7e1 BACKPORT: f2fs: specify extent cache for read explicitly
Let's descrbie it's read extent cache.

Bug: 264453689
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 29539ed310a92b5eb1e6ce8906087536b6259d58)
Change-Id: I9cb258b7ee152ead1458ef8adb3e542532f152ce
2023-01-10 18:49:35 +00:00
Zhang Qilong
02cb04cb05 BACKPORT: f2fs: add "c_len" into trace_f2fs_update_extent_tree_range for compressed file
The trace_f2fs_update_extent_tree_range could not record compressed
block length in the cluster of compress file and we just add it.

Bug: 264453689
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit a95694e33ce998e808b3a72164e8df3b5e0faf87)
Change-Id: Ic3702b2735be27cf1eab34191313b162805a010a
2023-01-10 18:49:35 +00:00
Zhang Qilong
f6b4d18df0 BACKPORT: f2fs: fix race condition on setting FI_NO_EXTENT flag
The following scenarios exist.
process A:               process B:
->f2fs_drop_extent_tree  ->f2fs_update_extent_cache_range
                          ->f2fs_update_extent_tree_range
                           ->write_lock
 ->set_inode_flag
                           ->is_inode_flag_set
                           ->__free_extent_tree // Shouldn't
                                                // have been
                                                // cleaned up
                                                // here
  ->write_lock

In this case, the "FI_NO_EXTENT" flag is set between
f2fs_update_extent_tree_range and is_inode_flag_set
by other process. it leads to clearing the whole exten
tree which should not have happened. And we fix it by
move the setting it to the range of write_lock.

Bug: 264453689
Fixes: 5f281fab9b ("f2fs: disable extent_cache for fcollapse/finsert inodes")
Signed-off-by: Zhang Qilong <zhangqilong3@huawei.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit a597af3b5a967e810cc8155abaa49abf10d6c417)
Change-Id: If36c3556c9062d46509f704f0491a7e6ad652ae6
2023-01-10 18:49:35 +00:00
Chao Yu
3112d6f502 BACKPORT: f2fs: extent cache: support unaligned extent
Compressed inode may suffer read performance issue due to it can not
use extent cache, so I propose to add this unaligned extent support
to improve it.

Currently, it only works in readonly format f2fs image.

Unaligned extent: in one compressed cluster, physical block number
will be less than logical block number, so we add an extra physical
block length in extent info in order to indicate such extent status.

The idea is if one whole cluster blocks are contiguous physically,
once its mapping info was readed at first time, we will cache an
unaligned (or aligned) extent info entry in extent cache, it expects
that the mapping info will be hitted when rereading cluster.

Merge policy:
- Aligned extents can be merged.
- Aligned extent and unaligned extent can not be merged.

Bug: 264453689
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
(cherry picked from commit 627371ed31)
Change-Id: I106279145558f38dfa295c3e99fa03f6fcd306f4
2023-01-10 18:49:35 +00:00
Jens Axboe
25280f263d UPSTREAM: io_uring: kill goto error handling in io_sqpoll_wait_sq()
Hunk extracted from commit 70aacfe661
upstream.

If the sqpoll thread has died, the out condition doesn't remove the
waiting task from the waitqueue. The goto and check are not needed, just
make it a break condition after setting the error value. That ensures
that we always remove ourselves from sqo_sq_wait waitqueue.

Bug: 259534862
Reported-by: Xingyuan Mo <hdthky0@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 0f544353fe)
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I453c3e23a2f0c5ce6a8dd73dac020ec6f32994ca
2023-01-10 09:44:08 +00:00
Greg Kroah-Hartman
7c31ae524c ANDROID: allmodconfig: disable WERROR
-Werror still fails on some arm and arm64 code due to clang issues
(works on gcc!), so disable it when building allmodconfig builds for
now.

Hopefully the clang developers will work on this...

Bug: 199872592
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: I6ccc856773c40e3c0f541a1316b20e9ae3de4380
(cherry picked from commit eb57c31115)
Signed-off-by: Alistair Delva <adelva@google.com>
2023-01-09 19:34:08 +00:00
Linus Torvalds
824c55581d UPSTREAM: Enable '-Werror' by default for all kernel builds
... but make it a config option so that broken environments can disable
it when required.

We really should always have a clean build, and will disable specific
over-eager warnings as required, if we can't fix them.  But while I
fairly religiously enforce that in my own tree, it doesn't get enforced
by various build robots that don't necessarily report warnings.

So this just makes '-Werror' a default compiler flag, but allows people
to disable it for their configuration if they have some particular
issues.

Occasionally, new compiler versions end up enabling new warnings, and it
can take a while before we have them fixed (or the warnings disabled if
that is what it takes), so the config option allows for that situation.

Hopefully this will mean that I get fewer pull requests that have new
warnings that were not noticed by various automation we have in place.

Knock wood.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
(cherry picked from commit 3fe617ccaf)
Signed-off-by: Alistair Delva <adelva@google.com>
Change-Id: If981f26ebe668be7c727661fede10215c4ee5bc5
2023-01-09 19:34:08 +00:00
Wu Bo
447ba7ae75 ANDROID: GKI: VIVO: Add a symbol to symbol list
Add 'dentry_path_raw' symbol to support some monitoring tools.
This patch does not add or remove symbol from xml file.

Bug: 264831214
Change-Id: I2b5aaa2945c5fd0ebe4062915b53407251a6ab77
Signed-off-by: Wu Bo <bo.wu@vivo.com>
2023-01-09 10:56:55 +00:00
Eric Biggers
91e4675508 ANDROID: fips140: add crypto_memneq() back to the module
crypto_memneq() is one of the utility functions that was intentionally
included in the fips140 module, out of concerns that it would be seen as
"cryptographic" and thus would be required to be included the module for
the FIPS certification.  It should not have been removed from the
module, so add it back.

Bug: 188620248
Fixes: 18cd39b706 ("Merge tag 'android12-5.10.136_r00' into android12-5.10")
Change-Id: I8a19dfd73390f8c1348885f97fa42d900e47b82b
Signed-off-by: Eric Biggers <ebiggers@google.com>
2023-01-09 10:55:19 +00:00
Kever Yang
b460d3c09a ANDROID: GKI: rockchip: Update module fragment and symbol list
Add fragment need by rockchip platform and sync the symbol list to the
latest source code.
This patch does not add or remove symbol from xml file.

Bug: 239396464
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Change-Id: I54e37e865124cbc7f70646481ca798e27fcc4706
2023-01-07 02:53:56 +00:00
Kever Yang
91e760f1f2 ANDROID: GKI: rockchip: Enable symbols for HDMIRX
Leaf changes summary: 1 artifact changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

1 Added function:

  [A] 'function bool v4l2_find_dv_timings_cap(v4l2_dv_timings*, const v4l2_dv_timings_cap*, unsigned int, v4l2_check_dv_timings_fnc*, void*)'

Bug: 239396464
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Change-Id: I45009e2791f99b65476daafaff343df33af72433
2023-01-07 02:53:56 +00:00
Kever Yang
1960d4cfad ANDROID: GKI: rockchip: Enable symbols for Ethernet
Leaf changes summary: 28 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 28 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

28 Added functions:

  [A] 'function void ethtool_convert_legacy_u32_to_link_mode(unsigned long int*, u32)'
  [A] 'function bool ethtool_convert_link_mode_to_legacy_u32(unsigned int*, const unsigned long int*)'
  [A] 'function int flow_block_cb_setup_simple(flow_block_offload*, list_head*, flow_setup_cb_t*, void*, void*, bool)'
  [A] 'function void flow_rule_match_basic(const flow_rule*, flow_match_basic*)'
  [A] 'function void flow_rule_match_ipv4_addrs(const flow_rule*, flow_match_ipv4_addrs*)'
  [A] 'function void flow_rule_match_ports(const flow_rule*, flow_match_ports*)'
  [A] 'function void netdev_rss_key_fill(void*, size_t)'
  [A] 'function page* page_pool_alloc_pages(page_pool*, gfp_t)'
  [A] 'function page_pool* page_pool_create(const page_pool_params*)'
  [A] 'function void page_pool_destroy(page_pool*)'
  [A] 'function void page_pool_put_page(page_pool*, page*, unsigned int, bool)'
  [A] 'function void page_pool_release_page(page_pool*, page*)'
  [A] 'function void phylink_disconnect_phy(phylink*)'
  [A] 'function int phylink_ethtool_get_eee(phylink*, ethtool_eee*)'
  [A] 'function void phylink_ethtool_get_pauseparam(phylink*, ethtool_pauseparam*)'
  [A] 'function void phylink_ethtool_get_wol(phylink*, ethtool_wolinfo*)'
  [A] 'function int phylink_ethtool_ksettings_get(phylink*, ethtool_link_ksettings*)'
  [A] 'function int phylink_ethtool_ksettings_set(phylink*, const ethtool_link_ksettings*)'
  [A] 'function int phylink_ethtool_nway_reset(phylink*)'
  [A] 'function int phylink_ethtool_set_eee(phylink*, ethtool_eee*)'
  [A] 'function int phylink_ethtool_set_pauseparam(phylink*, ethtool_pauseparam*)'
  [A] 'function int phylink_ethtool_set_wol(phylink*, ethtool_wolinfo*)'
  [A] 'function int phylink_get_eee_err(phylink*)'
  [A] 'function void phylink_mac_change(phylink*, bool)'
  [A] 'function int phylink_mii_ioctl(phylink*, ifreq*, int)'
  [A] 'function int phylink_speed_down(phylink*, bool)'
  [A] 'function int phylink_speed_up(phylink*)'
  [A] 'function void phylink_stop(phylink*)'

Bug: 239396464
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Change-Id: I6adf45c9a7159ef07a1913222248128afc0dcccb
2023-01-07 02:53:56 +00:00
Kalesh Singh
529351c4c8 ANDROID: Re-enable fast mremap and fix UAF with SPF
SPF attempts page faults without taking the mmap lock, but takes the
PTL. If there is a concurrent fast mremap (at PMD/PUD level), this
can lead to a UAF as fast mremap will only take the PTL locks at the
PMD/PUD level. SPF cannot take the PTL locks at the larger subtree
granularity since this introduces much contention in the page fault
paths.

To address the race:
  1) Only try fast mremaps if there are no users of the VMA. Android
     is concerned with this optimization in the context of
     GC stop-the-world pause. So there are no other threads active
     and this should almost always succeed.
  2) Speculative faults detect ongoing fast mremaps and fallback
     to conventional fault handling (taking mmap read lock).

Bug: 263177905
Change-Id: I23917e493ddc8576de19883cac053dfde9982b7f
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-01-06 13:08:36 -08:00
Kalesh Singh
c67f268c84 Revert "ANDROID: Make SPF aware of fast mremaps"
This reverts commit 134c1aae43.

Reason for revert: vts_linux_kselftest_arm_64 timeout

Bug: 263479421
Bug: 263177905
Change-Id: I123c56741c982d1539ceebd8bfde2443871aa1de
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2023-01-06 13:07:18 -08:00
Wei Liu
1351459097 ANDROID: GKI: Update symbols to symbol list
Update symbols to symbol list externed by oppo network group.

1 Added function:

  [A] 'function int __rtnl_link_register(rtnl_link_ops*)'

Bug: 193384408

Signed-off-by: Wei Liu <liuwei.a@oppo.com>
Change-Id: Ibd8f74fa1f3b68047f6fed9b5c4154c51f23b821
2023-01-06 19:41:17 +00:00
Eric Biggers
fe60669d03 ANDROID: fips140: add dump_jitterentropy command to fips140_lab_util
For the entropy analysis, we must provide some output from the Jitter
RNG: a large amount of output from one instance, and a smaller amount of
output from each of a certain number of instances.

The original plan was to use a build of the userspace jitterentropy
library that matches the kernel's jitterentropy_rng as closely as
possible.  However, it's now being requested that the output be gotten
from the kernel instead.

Now that fips140_lab_util depends on AF_ALG anyway, it's straightforward
to dump output from jitterentropy_rng instances using AF_ALG.
Therefore, add a command dump_jitterentropy which supports this.

Bug: 188620248
Change-Id: I78eb26250e88f2fc28fc44aa201acbe5b84df8bb
Signed-off-by: Eric Biggers <ebiggers@google.com>
(cherry picked from commit dc01503266)
2023-01-06 19:08:16 +00:00
Bing-Jhong Billy Jheng
6d015667ce UPSTREAM: io_uring: add missing item types for splice request
Splice is like read/write and should grab current->nsproxy, denoted by
IO_WQ_WORK_FILES as it refers to current->files as well

Change-Id: I94a99fdef5764e7eda5da778b5b52a150b9fe5eb
Signed-off-by: Bing-Jhong Billy Jheng <billy@starlabs.sg>
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 75454b4bbf)
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2023-01-06 09:35:59 +00:00
xiaofeng
ad1f2eebad ANDROID: GKI: update xiaomi symbol list
Leaf changes summary: 6 artifacts changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 3 Added functions
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 3 Added variables

3 Added functions:

  [A] 'function int __traceiter_android_vh_alloc_pages_failure_bypass(void*, gfp_t, int, int, int, page**)'
  [A] 'function int __traceiter_android_vh_alloc_pages_reclaim_bypass(void*, gfp_t, int, int, int, page**)'
  [A] 'function int __traceiter_android_vh_mmput(void*, mm_struct*)'

3 Added variables:

  [A] 'tracepoint __tracepoint_android_vh_alloc_pages_failure_bypass'
  [A] 'tracepoint __tracepoint_android_vh_alloc_pages_reclaim_bypass'
  [A] 'tracepoint __tracepoint_android_vh_mmput'

Bug:262486564
Change-Id: I7c78cc3c5fde8a15c8a30073fcb1cb01708d9d37
Signed-off-by: xiaofeng <xiaofeng5@xiaomi.com>
2022-12-24 15:20:22 -08:00
Suren Baghdasaryan
f677efbea1 Revert "Revert "ANDROID: vendor_hooks:vendor hook for mmput""
This reverts commit 501063ce66.

Reason for revert: The vendor hook is actually needed by a partner

Bug: 238821038
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I1c19add348792967975369a10ec9cb41fa268236
2022-12-24 12:34:20 -08:00
Suren Baghdasaryan
a43cd1f2bb Revert "Revert "ANDROID: vendor_hooks:vendor hook for __alloc_pages_slowpath.""
This reverts commit cc51dcbc60.

Reason for revert: The vendor hooks were reverted but they are needed.

Bug: 243629905
Signed-off-by: xiaofeng <xiaofeng5@xiaomi.com>
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I4b2eab1a9bf3bbbb200f9d09f2c57fb4d9f2c143
2022-12-24 12:30:22 -08:00
Kever Yang
9e6fb5ac72 ANDROID: GKI: rockchip: Add symbol clk_hw_set_parent
Leaf changes summary: 1 artifact changed
Changed leaf types summary: 0 leaf type changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 1 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable

1 Added function:

  [A] 'function int clk_hw_set_parent(clk_hw*, clk_hw*)'

Bug: 239396464
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
Change-Id: Id24cdc739a6254f7676a1f60fd8ecbd0066ca4b0
2022-12-22 18:05:01 +00:00
Mayank Rana
7bc2b8c400 UPSTREAM: usb: dwc3: core: Add error log when core soft reset failed
DWC3 controller soft reset is important operation for USB functionality.
In case when it fails, currently there is no failure log. Hence add
error log when core soft reset failed.

Signed-off-by: Mayank Rana <quic_mrana@quicinc.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 235863377
(cherry picked from commit 859bdc3595)
Change-Id: I60500f66af47d93cf9d60bdecab32e6dc48d4b7c
Signed-off-by: Mayank Rana <quic_mrana@quicinc.com>
(cherry picked from commit d03bf01b43ff923e066938895a6867338778be7a)
2022-12-22 18:00:05 +00:00
Pradeep P V K
05a8f2c4d2 FROMLIST: fuse: give wakeup hints to the scheduler
The synchronous wakeup interface is available only for the
interruptible wakeup. Add it for normal wakeup and use this
synchronous wakeup interface to wakeup the userspace daemon.
Scheduler can make use of this hint to find a better CPU for
the waker task.

With this change the performance numbers for compress, decompress
and copy use-cases on /sdcard path has improved by ~30%.

Use-case details:
1. copy 10000 files of each 4k size into /sdcard path
2. use any File explorer application that has compress/decompress
support
3. start compress/decompress and capture the time.

-------------------------------------------------
| Default   | wakeup support | Improvement/Diff |
-------------------------------------------------
| 13.8 sec  | 9.9 sec        | 3.9 sec (28.26%) |
-------------------------------------------------

Co-developed-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
Signed-off-by: Pradeep P V K <quic_pragalla@quicinc.com>

Bug: 216261533
Link: https://lore.kernel.org/lkml/1638780405-38026-1-git-send-email-quic_pragalla@quicinc.com/
Change-Id: I9ac89064e34b1e0605064bf4d2d3a310679cb605
Signed-off-by: Pradeep P V K <quic_pragalla@quicinc.com>
Signed-off-by: Alessio Balsini <balsini@google.com>
(cherry picked from commit 30d72758db)
2022-12-21 19:06:10 +00:00
Kalesh Singh
134c1aae43 ANDROID: Make SPF aware of fast mremaps
SPF attempts page faults without taking the mmap lock, but takes the
PTL. If there is a concurrent fast mremap (at PMD/PUD level), this
can lead to a UAF as fast mremap will only take the PTL locks at the
PMD/PUD level. SPF cannot take the PTL locks at the larger subtree
granularity since this introduces much contention in the page fault
paths.

To address the race:
  1) Fast mremaps wait until there are no users of the VMA.
  2) Speculative faults detect ongoing fast mremaps and fallback
    to conventional fault handling (taking mmap read lock).

Since this race condition is very rare the performance impact is
negligible.

Bug: 263177905
Change-Id: If9755aa4261337fe180e3093a3cefaae8ac9ff1a
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
2022-12-20 17:19:30 -08:00
Farid Chahla
16c03440df ANDROID: GKI: enable mulitcolor-led
To enable newer version of DualSense driver, i.e. hid-playstation, we
need to set LEDS_CLASS_MULTICOLOR to "y".

Bug: 260685629
Change-Id: I52b0b1b6a061457e009b62a6bd6b66a91c8c37a2
Signed-off-by: Farid Chahla <farid.chahla@sony.com>
2022-12-20 19:25:39 +00:00
Roderick Colenbrander
4aa3cab588 UPSTREAM: HID: playstation: support updated DualSense rumble mode.
Newer DualSense firmware supports a revised classic rumble mode,
which feels more similar to rumble as supported on previous PlayStation
controllers. It has been made the default on PlayStation and non-PlayStation
devices now (e.g. iOS and Windows). Default to this new mode when
supported.

Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20221010212313.78275-4-roderick.colenbrander@sony.com

Bug: 260685629
(cherry picked from commit 9fecab247e)
Change-Id: Icd330111a4d1b1e76a04cd11c623d0982ce3d66f
Signed-off-by: Farid Chahla <farid.chahla@sony.com>
2022-12-20 19:25:39 +00:00
Roderick Colenbrander
63b2567f9d UPSTREAM: HID: playstation: add initial DualSense Edge controller support
Provide initial support for the DualSense Edge controller. The brings
support up to the level of the original DualSense, but won't yet provide
support for new features (e.g. reprogrammable buttons).

Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
CC: stable@vger.kernel.org
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20221010212313.78275-3-roderick.colenbrander@sony.com

Bug: 260685629
(cherry picked from commit b8a968efab)
Change-Id: I5b95de806e823085d1144f016d8cfd76e4a933ef
Signed-off-by: Farid Chahla <farid.chahla@sony.com>
2022-12-20 19:25:39 +00:00
Roderick Colenbrander
a3ea8fbc1f UPSTREAM: HID: playstation: stop DualSense output work on remove.
Ensure we don't schedule any new output work on removal and wait
for any existing work to complete. If we don't do this e.g. rumble
work can get queued during deletion and we trigger a kernel crash.

Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
CC: stable@vger.kernel.org
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20221010212313.78275-2-roderick.colenbrander@sony.com

Bug: 260685629
(cherry picked from commit 182934a1e9)
Change-Id: I40cadfde5765cdabf45def929860258d6019bf10
Signed-off-by: Farid Chahla <farid.chahla@sony.com>
2022-12-20 19:25:39 +00:00
Greg Kroah-Hartman
a301358cb5 UPSTREAM: HID: playstation: convert to use dev_groups
There is no need for a driver to individually add/create device groups,
the driver core will do it automatically for you.  Convert the
hid-playstation driver to use the dev_groups pointer instead of manually
calling the driver core to create the group and have it be cleaned up
later on by the devm core.

Cc: Roderick Colenbrander <roderick.colenbrander@sony.com>
Cc: Jiri Kosina <jikos@kernel.org>
Cc: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: linux-input@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Bug: 260685629
(cherry picked from commit b4a9af9be6)
Change-Id: I516a1b0ef7f4f8545e0c1b9485b49879dd7a3136
Signed-off-by: Farid Chahla <farid.chahla@sony.com>
2022-12-20 19:25:39 +00:00
Jiri Kosina
62964653b7 UPSTREAM: HID: playstation: fix return from dualsense_player_led_set_brightness()
brightness_set_blocking() callback expects function returning int. This fixes
the follwoing build failure:

drivers/hid/hid-playstation.c: In function ‘dualsense_player_led_set_brightness’:
drivers/hid/hid-playstation.c:885:1: error: no return statement in function returning non-void [-Werror=return-type]
 }
 ^

Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Bug: 260685629
(cherry picked from commit 3c92cb4cb6)
Change-Id: Id16b960826a26ac22c1a14572444f9af29689ed6
Signed-off-by: Farid Chahla <farid.chahla@sony.com>
2022-12-20 19:25:39 +00:00
Roderick Colenbrander
f7901b46a2 UPSTREAM: HID: playstation: expose DualSense player LEDs through LED class.
The DualSense player LEDs were so far not adjustable from user-space.
This patch exposes each LED individually through the LED class. Each
LED uses the new 'player' function resulting in a name like:
'inputX:white:player-1' for the first LED.

Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Bug: 260685629
(cherry picked from commit 8c0ab553b0)
Change-Id: I49c699a99b0b8a7bb7980560e3ea7a12faf646aa
Signed-off-by: Farid Chahla <farid.chahla@sony.com>
2022-12-20 19:25:39 +00:00
Roderick Colenbrander
a70e598cef UPSTREAM: leds: add new LED_FUNCTION_PLAYER for player LEDs for game controllers.
Player LEDs are commonly found on game controllers from Nintendo and Sony
to indicate a player ID across a number of LEDs. For example, "Player 2"
might be indicated as "-x--" on a device with 4 LEDs where "x" means on.

This patch introduces LED_FUNCTION_PLAYER1-5 defines to properly indicate
player LEDs from the kernel. Until now there was no good standard, which
resulted in inconsistent behavior across xpad, hid-sony, hid-wiimote and
other drivers. Moving forward new drivers should use LED_FUNCTION_PLAYERx.

Note: management of Player IDs is left to user space, though a kernel
driver may pick a default value.

Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Bug: 260685629
(cherry picked from commit 61177c088a)
Change-Id: Ie1de4d66304bb25fc2c9fcdb1ec9b7589ad9e7ac
Signed-off-by: Farid Chahla <farid.chahla@sony.com>
2022-12-20 19:25:39 +00:00
Roderick Colenbrander
e1cd3ffe47 UPSTREAM: HID: playstation: expose DualSense lightbar through a multi-color LED.
The DualSense lightbar has so far been supported, but it was not yet
adjustable from user space. This patch exposes it through a multi-color
LED.

Signed-off-by: Roderick Colenbrander <roderick.colenbrander@sony.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>

Bug: 260685629
(cherry picked from commit fc97b4d6a1)
Change-Id: I48204113da804b13ad5bed2f651a5826ab5a86f7
Signed-off-by: Farid Chahla <farid.chahla@sony.com>
2022-12-20 19:25:39 +00:00
Pavel Machek
65654da06d UPSTREAM: Documentation: leds: standartizing LED names
We have a list of valid functions, but LED names in sysfs are still
far from being consistent. Create list of "well known" LED names so we
nudge people towards using same LED names (except color) for same
functionality.

Signed-off-by: Pavel Machek <pavel@ucw.cz>

Bug: 260685629
(cherry picked from commit 09f1273064)
Change-Id: Iea12a9c230d6cd072b0f4fd4e0c616348173dd53
Signed-off-by: Farid Chahla <farid.chahla@sony.com>
2022-12-20 19:25:39 +00:00
Dan Vacura
d37e563bff ANDROID: usb: gadget: uvc: remove duplicate code in unbind
The uvc_function_unbind() was calling the same code two times,
increasing a timeout that may occur. The duplicate code looks to have
come in during the merge of 5.10.117. Remove the duplicate code.

Bug: 261895714
Change-Id: I8957048bfad4a9e01baea033de9b628362b2d991
Signed-off-by: Dan Vacura <w36195@motorola.com>
2022-12-14 23:18:13 +00:00
Pavankumar Kondeti
8ad88eae4b ANDROID: dma-buf: Fix build breakage with !CONFIG_DMABUF_SYSFS_STATS
The commit c5589c7eec ("ANDROID: dma-buf: Add vendor hook for
deferred dmabuf sysfs stats release") introduced a build breakage
on non-GKI targets which don't have CONFIG_DMABUF_SYSFS_STATS
enabled. It is due to invisibility of struct dma_buf_sysfs_entry
in the trace hook header file. We can get away with it by moving
the header inclusion from trace hook header to vendor hooks driver.

Bug: 261818075
Change-Id: Ibb79bd67c9f1b36fe2b5d569ab9369f376a78b77
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
2022-12-13 21:13:14 +00:00
Pavankumar Kondeti
ce18af9b5d ANDROID: dma-buf: don't re-purpose kobject as work_struct
The commit 5aec776ef8 ("BACKPORT: ANDROID: dma-buf: Move sysfs work
out of DMA-BUF export path) re-purposed kobject as work_struct temporarily
to create the sysfs entries asynchronously. The author knows what he is
doing and rightly added a build assert if kobject struct size is smaller than
the work_struct size. We are hitting this build assert on a non-GKI platform
where CONFIG_ANDROID_KABI_RESERVE is not set. Fix this problem by allocating
a new union with dma_buf_sysfs_entry structure and temporary structure as
members. We only end up allocating more memory (because of union) only when
kobject size is smaller than work_struct which the original patch any way
assumed would never be true.

Bug: 261818147
Change-Id: Ifb089bf80d8a3a44ece9f05fc0b99ee76cb11645
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
2022-12-13 21:11:56 +00:00
Lee Jones
eddb2f39cd UPSTREAM: drm/amdgpu: temporarily disable broken Clang builds due to blown stack-frame
commit 6f6cb17143 upstream.

Patch series "Fix a bunch of allmodconfig errors", v2.

Since b339ec9c22 ("kbuild: Only default to -Werror if COMPILE_TEST")
WERROR now defaults to COMPILE_TEST meaning that it's enabled for
allmodconfig builds.  This leads to some interesting build failures when
using Clang, each resolved in this set.

With this set applied, I am able to obtain a successful allmodconfig Arm
build.

This patch (of 2):

calculate_bandwidth() is presently broken on all !(X86_64 || SPARC64 ||
ARM64) architectures built with Clang (all released versions), whereby the
stack frame gets blown up to well over 5k.  This would cause an immediate
kernel panic on most architectures.  We'll revert this when the following
bug report has been resolved:
https://github.com/llvm/llvm-project/issues/41896.

Bug: 261962742
Link: https://lkml.kernel.org/r/20221125120750.3537134-1-lee@kernel.org
Link: https://lkml.kernel.org/r/20221125120750.3537134-2-lee@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@gmail.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Lee Jones <lee@kernel.org>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Tom Rix <trix@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: Iaa42b18cdcf9fe23d740c036371bd7950d431e14
Signed-off-by: Lee Jones <joneslee@google.com>
2022-12-09 12:14:58 +00:00
Lee Jones
e2a4080d04 BACKPORT: Kconfig.debug: provide a little extra FRAME_WARN leeway when KASAN is enabled
[ Upstream commit 152fe65f30 ]

When enabled, KASAN enlarges function's stack-frames.  Pushing quite a few
over the current threshold.  This can mainly be seen on 32-bit
architectures where the present limit (when !GCC) is a lowly 1024-Bytes.

Bug: 261962742
Link: https://lkml.kernel.org/r/20221125120750.3537134-3-lee@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Cc: Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: David Airlie <airlied@gmail.com>
Cc: Harry Wentland <harry.wentland@amd.com>
Cc: Leo Li <sunpeng.li@amd.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maxime Ripard <mripard@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Tom Rix <trix@redhat.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Change-Id: I505a5187220b426fe49c0f15bf1704198082f63d
Signed-off-by: Lee Jones <joneslee@google.com>
2022-12-09 12:14:48 +00:00
Lee Jones
98671fcc32 UPSTREAM: bpf: Ensure correct locking around vulnerable function find_vpid()
[ Upstream commit 83c10cc362 ]

The documentation for find_vpid() clearly states:

  "Must be called with the tasklist_lock or rcu_read_lock() held."

Presently we do neither for find_vpid() instance in bpf_task_fd_query().
Add proper rcu_read_lock/unlock() to fix the issue.

Bug: 232939090
Fixes: 41bdc4b40e ("bpf: introduce bpf subcommand BPF_TASK_FD_QUERY")
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20220912133855.1218900-1-lee@kernel.org
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I517b52d97a22b92be1a479279067ddb7b84efbba
2022-12-08 11:25:09 +00:00
Linyu Yuan
01b3d953ac BACKPORT: UPSTREAM: usb: typec: ucsi: Wait for the USB role switches
When role switch module probe late than ucsi module,
fwnode_usb_role_switch_get() will return -EPROBE_DEFER,
it is better to restart ucsi init work to find
it again every 100ms, total wait time is 10 second.

It also means change ucsi init work to delayed_work.

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
Signed-off-by: Linyu Yuan <quic_linyyuan@quicinc.com>
Link: https://lore.kernel.org/r/1650881886-25530-3-git-send-email-quic_linyyuan@quicinc.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

(cherry picked from commit 3c16251153
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git)

Bug: 260537721
[ugoswami: Fixed KMI breakage by moving the delayed_work & work_count
to a new parent structure]
Change-Id: Ia4e2521c40b9b0ffe8b6f13ec19990e7f3a60e7a
Signed-off-by: Udipto Goswami <quic_ugoswami@quicinc.com>
2022-12-07 11:26:19 +00:00
Hyunwoo Kim
37725ca62e UPSTREAM: HID: roccat: Fix use-after-free in roccat_read()
[ Upstream commit cacdb14b1c ]

roccat_report_event() is responsible for registering
roccat-related reports in struct roccat_device.

int roccat_report_event(int minor, u8 const *data)
{
	struct roccat_device *device;
	struct roccat_reader *reader;
	struct roccat_report *report;
	uint8_t *new_value;

	device = devices[minor];

	new_value = kmemdup(data, device->report_size, GFP_ATOMIC);
	if (!new_value)
		return -ENOMEM;

	report = &device->cbuf[device->cbuf_end];

	/* passing NULL is safe */
	kfree(report->value);
	...

The registered report is stored in the struct roccat_device member
"struct roccat_report cbuf[ROCCAT_CBUF_SIZE];".
If more reports are received than the "ROCCAT_CBUF_SIZE" value,
kfree() the saved report from cbuf[0] and allocates a new reprot.
Since there is no lock when this kfree() is performed,
kfree() can be performed even while reading the saved report.

static ssize_t roccat_read(struct file *file, char __user *buffer,
		size_t count, loff_t *ppos)
{
	struct roccat_reader *reader = file->private_data;
	struct roccat_device *device = reader->device;
	struct roccat_report *report;
	ssize_t retval = 0, len;
	DECLARE_WAITQUEUE(wait, current);

	mutex_lock(&device->cbuf_lock);

	...

	report = &device->cbuf[reader->cbuf_start];
	/*
	 * If report is larger than requested amount of data, rest of report
	 * is lost!
	 */
	len = device->report_size > count ? count : device->report_size;

	if (copy_to_user(buffer, report->value, len)) {
		retval = -EFAULT;
		goto exit_unlock;
	}
	...

The roccat_read() function receives the device->cbuf report and
delivers it to the user through copy_to_user().
If the N+ROCCAT_CBUF_SIZE th report is received while copying of
the Nth report->value is in progress, the pointer that copy_to_user()
is working on is kfree()ed and UAF read may occur. (race condition)

Since the device node of this driver does not set separate permissions,
this is not a security vulnerability, but because it is used for
requesting screen display of profile or dpi settings,
a user using the roccat device can apply udev to this device node or
There is a possibility to use it by giving.

Bug: 251067658
Signed-off-by: Hyunwoo Kim <imv4bel@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Lee Jones <joneslee@google.com>
Change-Id: I90b24df9216ab87a4fec0ab06fa52e7b1eb97fd1
2022-12-05 10:37:53 +00:00
Charan Teja Kalla
8f0752d06e ANDROID: arm64: mm: perform clean & invalidation in __dma_map_area
commit c50f11c619 ("arm64: mm: Don't invalidate FROM_DEVICE buffers at
start of DMA transfer") break assumptions of some device drivers about
invalidation that happens as part of __dma_map_area(DMA_FROM_DEVICE). An
example include drivers using dmabuf API dma_buf_begin_cpu_access() and
dma_buf_end_cpu_access() to achieve buffer invalidation. Fix this breakage
by replacing clean with clean and invalidation in __dma_map_area() for
DMA inbound case.

Bug: 260978220
Change-Id: Id1a2750c2036de693cd52e8f7316f1d820b5a262
Fixes: c50f11c619 ("arm64: mm: Don't invalidate FROM_DEVICE buffers at start of DMA transfer")
Signed-off-by: Charan Teja Kalla <quic_charante@quicinc.com>
Signed-off-by: Shiraz Hashim <quic_shashim@quicinc.com>
Signed-off-by: Prakash Gupta <quic_guptap@quicinc.com>
Signed-off-by: Pavankumar Kondeti <quic_pkondeti@quicinc.com>
2022-12-02 16:10:34 +05:30
T.J. Mercier
d55aeb4029 BACKPORT: ANDROID: dma-buf: heaps: replace mutex lock with spinlock
We should use spinlock to protect page pool's critical section as
1. The critical section is short, using spinlock is more efficient.
2. Spinlock could protect priority inversion. Ex. Low priority
   thread (dmabuf-deferred) hold the page lock but get scheduled
   out under heavy loading. Then the other high priority threads
   need to wait for dmabuf-deferred to release the lock. It causes
   long allocation latency and possible UI jank.

Also, we could move NR_KERNEL_MISC_RECLAIMABLE stat out of the
critical section to make it shorter as mod_node_page_state can
handle concurrent access cases.

Conflicts:
	drivers/dma-buf/heaps/page_pool.h
	drivers/dma-buf/heaps/page_pool.c

1. The android12-5.10 KMI is frozen, and the modification to struct
   dmabuf_page_pool in the original patch would break the KMI.
   Instead we wrap dmabuf_page_pool allocations in a struct
   dmabuf_page_pool_with_spinlock which also contains a spinlock
   replacement for dmabuf_page_pool's mutex.

   No callers should attempt to acquire dmabuf_page_pool's mutex on this
   branch, so it is locked immediately after initialization and never
   unlocked.

(cherry picked from commit 060e38dce1)
Bug: 245454030
Change-Id: I15f349f9e893621f71ca79f1de037de184c33edf
Signed-off-by: T.J. Mercier <tjmercier@google.com>
2022-12-01 18:05:29 +00:00