[ Upstream commit 1aa1329a67cc214c3b7bd2a14d1301a795760b07 ]
state->xtal_hz can be up to 16M, so it can overflow a 32 bit integer
when multiplied by pll_mfactor.
Create a new 64 bit variable to hold the calculations.
Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-25-3c4865f5a4b0@chromium.org
Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 8167e4d7dc086d4f7ca7897dcff3827e4d22c99a)
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[ Upstream commit 6cff72f6bcee89228a662435b7c47e21a391c8d0 ]
Use an API that resembles more the actual use of num_channels.
Found by cocci:
drivers/media/usb/s2255/s2255drv.c:2362:5-24: WARNING: atomic_dec_and_test variation before object free at line 2363.
drivers/media/usb/s2255/s2255drv.c:1557:5-24: WARNING: atomic_dec_and_test variation before object free at line 1558.
Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-11-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 32f2f5385eefa73aaebefda419147ac8599ba9e6)
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[ Upstream commit e9a844632630e18ed0671a7e3467431bd719952e ]
do_div() divides 64 bits by 32. We were adding a casting to the divider
to 64 bits, for a number that fits perfectly in 32 bits. Remove it.
Found by cocci:
drivers/media/dvb-frontends/tda18271c2dd.c:355:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
drivers/media/dvb-frontends/tda18271c2dd.c:331:1-7: WARNING: do_div() does a 64-by-32 division, please consider using div64_u64 instead.
Link: https://lore.kernel.org/linux-media/20240429-fix-cocci-v3-8-3c4865f5a4b0@chromium.org
Signed-off-by: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 2401cbc0f5d4bd1e327d247548cc6ee57bc76c53)
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[ Upstream commit 4c7f3950a9fd53a62b156c0fe7c3a2c43b0ba19b ]
Since commit a3c53be55c95 ("net: dsa: mv88e6xxx: Support multiple MDIO
busses") mv88e6xxx_default_mdio_bus() has checked that the
return value of list_first_entry() is non-NULL.
This appears to be intended to guard against the list chip->mdios being
empty. However, it is not the correct check as the implementation of
list_first_entry is not designed to return NULL for empty lists.
Instead, use list_first_entry_or_null() which does return NULL if the
list is empty.
Flagged by Smatch.
Compile tested only.
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20240430-mv88e6xx-list_empty-v3-1-c35c69d88d2e@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 47d28dde172696031c880c5778633cdca30394ee)
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[ Upstream commit a08b8f8557ad88ffdff8905e5da972afe52e3307 ]
This is an effort to get rid of all multiplications from allocation
functions in order to prevent integer overflows [1][2].
As the "ff" variable is a pointer to "struct ff_device" and this
structure ends in a flexible array:
struct ff_device {
[...]
struct file *effect_owners[] __counted_by(max_effects);
};
the preferred way in the kernel is to use the struct_size() helper to
do the arithmetic instead of the calculation "size + count * size" in
the kzalloc() function.
The struct_size() helper returns SIZE_MAX on overflow. So, refactor
the comparison to take advantage of this.
This way, the code is more readable and safer.
This code was detected with the help of Coccinelle, and audited and
modified manually.
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1]
Link: https://github.com/KSPP/linux/issues/160 [2]
Signed-off-by: Erick Archer <erick.archer@outlook.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/AS8PR02MB72371E646714BAE2E51A6A378B152@AS8PR02MB7237.eurprd02.prod.outlook.com
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit e52cfcf68df0b52565be68106e9f65ab8077b48a)
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[ Upstream commit 0ef11f604503b1862a21597436283f158114d77e ]
If a DMI table entry is shorter than 4 bytes, it is invalid. Due to
how DMI table parsing works, it is impossible to safely recover from
such an error, so we have to stop decoding the table.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Link: https://lore.kernel.org/linux-kernel/Zh2K3-HLXOesT_vZ@liuwe-devbox-debian-v2/T/
Reviewed-by: Michael Kelley <mhklinux@outlook.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit c2a350a3fa622a174e3704691d05989cdfde4d51)
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
[ Upstream commit e5c5f3596de224422561d48eba6ece5210d967b3 ]
This is an effort to get rid of all multiplications from allocation
functions in order to prevent integer overflows [1][2].
As the "ids" variable is a pointer to "struct sctp_assoc_ids" and this
structure ends in a flexible array:
struct sctp_assoc_ids {
[...]
sctp_assoc_t gaids_assoc_id[];
};
the preferred way in the kernel is to use the struct_size() helper to
do the arithmetic instead of the calculation "size + size * count" in
the kmalloc() function.
Also, refactor the code adding the "ids_size" variable to avoid sizing
twice.
This way, the code is more readable and safer.
This code was detected with the help of Coccinelle, and audited and
modified manually.
Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments [1]
Link: https://github.com/KSPP/linux/issues/160 [2]
Signed-off-by: Erick Archer <erick.archer@outlook.com>
Acked-by: Xin Long <lucien.xin@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/PAXPR02MB724871DB78375AB06B5171C88B152@PAXPR02MB7248.eurprd02.prod.outlook.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 03f37e56305156bd25c5c237d1cc7f5c75495ef2)
[Vegard: add #include that was pulled in through some other unknown
header on 4.19.y]
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Extracted from Huawei's kernel source drop, this patch adds ARM64 optimizations for LZ4 decompression:
- Adds ARM64 acceleration support.
- Introduces new ARM64-specific files and updates the Makefile.
- Enhances __LZ4_decompress_generic for partial decompression.
- Adds bounds checks for safer decompression.
Originally intended as optimizations for Huawei's EROFS driver.
Change-Id: I438b79e43bbacd08a047d037a1eeac8ff89b4aff
Signed-off-by: Dark-Matter7232 <me@const.eu.org>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
As per Sony, 1KB of memory size for LZ4 is enough as we only
use LZ4 for zRAM and so our blocks are 4KB in size.
Therefore, reduce the LZ4 memory usage to 1KB. This can enhance
the speed of LZ4.
Change-Id: Iafead09b28c5989c9991163fcc1ce17cb06ba0fc
Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This fixes the following warnings by sparse:
../lib/lz4/lz4_compress.c:838:5: warning: symbol 'LZ4_compress_fast_extState' was not declared. Should it be static?
../lib/lz4/lz4_decompress.c:141:8: warning: symbol 'read_long_length_no_check' was not declared. Should it be static?
../lib/lz4/lz4_decompress.c:904:5: warning: symbol 'LZ4_decompress_fast' was not declared. Should it be static?
../lib/lz4/lz4_decompress.c:1052:5: warning: symbol 'LZ4_decompress_fast_continue' was not declared. Should it be static?
../lib/lz4/lz4_decompress.c:1099:5: warning: symbol 'LZ4_decompress_safe_usingDict' was not declared. Should it be static?
../lib/lz4/lz4_decompress.c:1118:5: warning: symbol 'LZ4_decompress_fast_usingDict' was not declared. Should it be static?
Since some of the functions have been marked as static now, there is no
need to export them. Remove the redundant export symbols as well.
Change-Id: Idf1e7a83ceba9f582e22df51ebe687585334abec
Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
To help mitigate data loss potential in the event of an unclean
shutdown. The small performance hit is worth the trade-off for improved
data integrity, especially since custom kernels are more susceptible to
unclean shutdowns (panics) during development.
Change-Id: I4d114ba632faaeb82ea1fdf8f354b0a2f46d8407
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
MIUI-1728660
This patch enhances the performance of fsync.
Doing checkpoint every time when setting xattr for dir can seriously
affect the performance of fsync. By adding the inode to the tracking
list when setting up xattr, we can avoid doing checkpoint when xattr
of the parent directory is not set.
Change-Id: I0ccf34212f77fb686dd86b705b78554c29bd38f8
Signed-off-by: liuchao12 <liuchao12@xiaomi.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This reverts commit d5afaaf78fc6335662448dcc3202c0b6f5917000.
Change-Id: Ifca9223a0b308bd3abe6628f3b34335d26313a99
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This reverts commit 9a96accad1fc2d228f2c3a7f527694fe42da7405.
Change-Id: I55d5c4034c19cc2d63e97611e2f7cd1d88188f13
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This reverts commit 89746abced305c81c70bb594445632743504b02c.
Change-Id: I903ace5520e79975fc3ad73822e193b2abaadaed
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
In recent Linux v5.7 release this option has been removed as its real
performance impact is doubtful.
What's more, disabling it can save memory.
Change-Id: Ie2f77ee5bd9e3e7fa7e0e22a2196cd2fc3e81a89
Signed-off-by: Andrzej Perczak <linux@andrzejperczak.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
Change-Id: I481c891b8e853d272cfbe2b6b912dc767f74c710
Signed-off-by: Panchajanya1999 <panchajanya@azure-dev.live>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
Android figures out if charging is "rapid" by checking
POWER_SUPPLY_PROP_CURRENT_MAX and when the proprietary charger tech
Xiaomi's using is active that value isn't always reported correctly.
Work around that by reporting an arbitrary value that's high enough to
qualify as "rapid" when a proprietary charger is attached and fully
authenticated (by checking smblib_get_fastcharge_mode() which is a
custom utility function added by Xiaomi). Other charger types (HVDCP/PD)
still use standard smblib_get_prop_input_current_max().
Test: original 33W charger is reported as "rapid" immediately after
plugging it in, a slow charger is still detected as "slow".
Change-Id: If9247081f2eae8132857be44487f83ba36b4c129
Signed-off-by: Kuba Wojciechowski <nullbytepl@gmail.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This reverts commit 462ce2c18d19552736842483f1c3ce1c7554ccba.
Change-Id: Ied28218b62fe2240483dfbb9a5193a586b76839e
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
Change-Id: Ic534adc173689d96fd22b557822dee8844f46451
Signed-off-by: Kazuki Hashimoto <kaz205@tuta.io>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
Giving userspace intimate control over CPU latency requirements is
nonsense. Userspace can't even stop itself from being preempted, so
there's no reason for it to have access to a mechanism primarily used to
eliminate CPU delays on the order of microseconds.
Remove userspace's ability to send pm_qos requests so that it can't hurt
power consumption.
Change-Id: Ie505ac3647258c375387875199bb831a8c208e4f
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
Kernel-based CPU boosting is used now, so stop userspace from messing with
it by turning scaling_min_freq into a no-op. Note that this is done instead
of making scaling_min_freq read-only so that userspace doesn't spit out
error messages when it can't do its boosting.
Change-Id: I7c8f07cfc02ba719bfc883c9ecd2954f9cbda76f
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
It seems that the black-box GPU frequency selection algorithm is unaware
of high refresh rates, and assumes a refresh rate of 60 Hz for its
target frequencies. This results in frequencies that are too low being
selected when a higher refresh rate, such as 90 Hz, is used.
To remedy this, multiply the GPU's busy time by a ratio of the current
refresh rate to 60 Hz. This makes msm-adreno-tz select the right
frequencies needed to avoid stuttering.
[ghostrider-reborn]
- Actually make it work with real-time dynamic refresh rate
Change-Id: Idb8e033bbbd1e6e6ebf1a47d4f9bd618df812658
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Adithya R <gh0strider.2k18.reborn@gmail.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
Revert "adreno_tz: Adjust GPU target frequency calculation"
This reverts commit e13ea7323c674fa9a6b70b82c89e94bfb0008ae4.
Revert "adreno_tz: Util inflation improvements"
This reverts commit b2125a41832d2c94cf2b3c6b88d8c7b981eb1c2f.
Revert "devfreq/adreno_tz: make high refresh multiplier configurable"
This reverts commit 863f6821522d3ffbb1a598b75396ee357500614b.
Revert "adreno_tz: Fix GPU target frequency calculation for high refresh rates"
This reverts commit 9b7169dba8a882ad3a7584da337a2fb875e31174.
Change-Id: Idd139250e21efebead872ecbbdebc2529aec22b5
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
Change-Id: Icfd93f36cdf96fefa22d908eda899f13c1bf39b1
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
BFQ is already doing a similar thing in its .pd_offline_fn() method
implementation.
While it seems that after commit 4c6994806f70
("blk-throttle: fix race between blkcg_bio_issue_check() and cgroup_rmdir()")
was reverted leaving these pointers intact no longer causes crashes
clearing them is still a sensible thing to do to make the code more robust.
Change-Id: I132ed621e2fbd6c61aae0564b1756202c7d944b2
Signed-off-by: Maciej S. Szmigiero <mail@maciej.szmigiero.name>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
cfq have some internal fields that use sched_clock() which can
trivially use ktime_get_ns() instead. Their timestamp fields in struct
request can also use ktime_get_ns(), which resolves the 8 year old
comment added by commit 28f4197e5d47 ("block: disable preemption before
using sched_clock()").
Change-Id: Iaf49272c124fda5a070ac25ca9698d5cb32e6689
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
It's been observed that a panic could occur due to a race with
a MSM_DRM_BLANK_POWERDOWN handler and a driver removal function
upon shutdown while the screen is on.
Since this shouldn't happen, send DRM events only when the system is running.
This doesn't seem to be easy to detect as the events are sent after the
userspace drm process terminates, which is before init binary notifies
the kernel about the shutdown.
Workaround this by detecting shutdown upon sysrq kill-all-tasks(i),
sent from the init binary.
Change-Id: Ibb79bda42af633c957e1f5ec436355d5bfdec21e
Signed-off-by: Park Ju Hyung <qkrwngud825@gmail.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
Since we know an interrupt will be arriving soon when a frame is
committed, we can anticipate it and prevent the CPU servicing that
interrupt from entering deep idle states. This reduces display rendering
latency.
Change-Id: Ic6fc1c041a5f0903216e98f1a552ec388c6f3517
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
In order to complete a commit, we must first wait for the previous
commit to finish up. This is done by sleeping, during which time the CPU
can enter a deep idle state and take a while to finish processing the
commit after the wait is over. We can alleviate this by optimistically
assuming that the kthread this commit worker is running on won't migrate
to another CPU partway through. We only do this for the non-blocking
case where the commit completion is done in an asynchronous worker
because the generic DRM code already does this for atomic ioctls.
Change-Id: I57728e83cada5bbc1d28ae2f201bcf9cf47e97c7
Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This reverts commit 1978d9314a699d25dbb3cfef1eea4117743f7a87.
Change-Id: I83b9f7257d16941cc73034437ab2c781881c1535
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This reverts commit 5459eb8901f47d52ac9a0d8c294f6814edd0a8f2.
Change-Id: I46c4643d4055e28153b5ff9e2207ce3166e1bd5e
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This reverts commit 8b8c91fe51a285c51bd2453566c8ff6e9ea262b9.
Change-Id: Ibc59d482cb458df1dd8c393b2a0efe1fcc8ef6fa
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This reverts commit 53e8303ec661701961bcecb1b487f9ce91da7af3.
Change-Id: Ia1c0aa8c9a8065ebff407421d4ea59c13fc892cc
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
* 'linux-4.14.y' of https://github.com/openela/kernel-lts: (133 commits)
LTS: Update to 4.14.350
SUNRPC: Fix RPC client cleaned up the freed pipefs dentries
arm64: dts: rockchip: Add sound-dai-cells for RK3368
tcp: Fix data races around icsk->icsk_af_ops.
ipv6: Fix data races around sk->sk_prot.
ipv6: annotate some data-races around sk->sk_prot
pwm: stm32: Refuse too small period requests
ftruncate: pass a signed offset
batman-adv: Don't accept TT entries for out-of-spec VIDs
batman-adv: include gfp.h for GFP_* defines
drm/nouveau/dispnv04: fix null pointer dereference in nv17_tv_get_hd_modes
drm/nouveau/dispnv04: fix null pointer dereference in nv17_tv_get_ld_modes
hexagon: fix fadvise64_64 calling conventions
tty: mcf: MCF54418 has 10 UARTS
usb: atm: cxacru: fix endpoint checking in cxacru_bind()
usb: musb: da8xx: fix a resource leak in probe()
usb: gadget: printer: SS+ support
net: usb: ax88179_178a: improve link status logs
iio: adc: ad7266: Fix variable checking bug
mmc: sdhci-pci: Convert PCIBIOS_* return codes to errnos
...
Change-Id: I0ab862e0932a48f13c64657e5456f3034b766445
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>