799768 Commits

Author SHA1 Message Date
celtare21
5d75b91d25
kgsl: Fix Dec merge
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:44 +07:00
Harshitha Sai Neelati
6e236e4609
msm: kgsl: Don't wait for room in context queue when context is invalidated
In a condition where there is no room in the drawcontext queue and the
context is invalidated while sleeping in wait_event_interruptible_timeout,
we are now polling for room after wake up. This would lead to infinite
looping.

Hence, do not wait for room in context queue if context is invalidated.

Bug: 167124402
Change-Id: I12c80e71630da2f3316838bee37f13cfa3b8e7d9
Signed-off-by: Harshitha Sai Neelati <hsaine@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:44 +07:00
Sultan Alsawaf
0cf2c7c8a8
msm: adreno: Relax CPU latency requirements to save power
Relaxing the CPU latency requirement by about 500 us won't significantly
hurt graphics performance. On the flip side, most SoCs have many idle
levels just below 1000 us in latency, with deeper idle levels having
latencies in excess of 2000 us. Changing the latency requirement to
1000 us allows most SoCs to use their deepest sub-1000-us idle state
while the GPU is active.

Additionally, since the lpm driver has been updated to allow power
levels with latencies equal to target latencies, change the wakeup
latency from 101 to 100 for clarity.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:44 +07:00
Pankaj Gupta
36789198af
msm: kgsl: Do not clear dispatcher fault when adreno reset fails
When adreno_reset fails, BUG_ON gets triggered to collect ram dump.
Do not clear dispatcher fault bits in such case to get correct fault
information from ram dump. Clear dispatcher fault when adreno_reset
returns success.

Change-Id: I6f54d48201d5e4ea5e3358b18d2f09ec7b285624
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:44 +07:00
Puranam V G Tejaswi
a6fda30bba
msm: kgsl: set vm_pgoff of vma to zero
kgsl gets the entry id or the gpu address through vm_pgoff. It is used
during mmap and never needed again. But this pgoff has different meaning
at other parts of kernel. Not setting to zero will let way for wrong
assumption when tried to unmap a page from the vma.

Change-Id: Ia81c64a77456caf168c6bd23bdf5755c3f3ee31c
Signed-off-by: Puranam V G Tejaswi <pvgtejas@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:43 +07:00
Urvashi Agrawal
7fc7ab69b9
msm: kgsl: Do not allow uncached buffers to be marked iocoherent
Add a check to allow only cached buffers to be marked iocoherent.
We can't enable io-coherency for uncached buffers because of
situations where hardware might snoop the cpu caches which can
have stale data. This happens primarily due to the limitations
of dma caching APIs available on arm64.

Change-Id: Iafad086d38559139cb45f6a290071ec6d58ad3a3
Signed-off-by: Urvashi Agrawal <urvaagra@codeaurora.org>
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:43 +07:00
Harshdeep Dhatt
dd94e2d3a4
msm: kgsl: Set gmu fault inside gmu_snapshot
The two always happen together. So set the gmu_fault
inside the gmu_snapshot function. Also, if we have
already recorded a gmu fault, then do not send nmi
or try to snapshot a gmu which is already in nmi.

Change-Id: I403a9c2c3cb7a1330a7931c41a23b4b4a2b66998
Signed-off-by: Harshdeep Dhatt <hdhatt@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:43 +07:00
Harshdeep Dhatt
3c72539663
msm: kgsl: Correctly handle gmu fault interrupts
Send NMI to gmu so that we don't lose critical gmu state.
We do not want to trigger dispatcher because we don't know
whether the gpu was active or not. The best course of action
is to wait for the next kgsl -> GMU interaction to timeout
thus triggering GMU snapshot and appropriate recovery steps
based on whether gpu was active or not.

Change-Id: I17b4245f4e0113bfc902d7dae46bb24d0bc2b65d
Signed-off-by: Harshdeep Dhatt <hdhatt@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:43 +07:00
Akhil P Oommen
111a9e45a7
msm: kgsl: Use milliseconds in Snapshot OS data
Use milliseconds instead of jiffies in the snapshot OS section.

Change-Id: I14519234b6ccac21e25401b41732abc5eaf13f38
Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:43 +07:00
Akhil P Oommen
90ae1422ff
msm: kgsl: Fix skipping aperture programming
During the first adreno_start(), we initialize the global PT and
make an scm call to program the aperture related registers. This
programing is skipped when scm_is_call_available() call fails.
Skipping aperture programing can make CP get stuck during a
context switch. To fix this, avoid scm_is_call_available() call
and force aperture programing from secure world for all a6xx GPUs.

Change-Id: I13923afbece0be12b1a9336b7d20c3039164a6b6
Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:42 +07:00
Puranam V G Tejaswi
9f7c0fbb67
msm: kgsl: use correct load bit value for rbbm perf counter
The load bit value used for RBBM_PERFCTR_RBBM_0 is incorrect.
Correct the load bit so that the saved value is loaded into the
desired counter.

Change-Id: Id0c8cb65061ce061ae342f62576ea020553e0f80
Signed-off-by: Puranam V G Tejaswi <pvgtejas@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:42 +07:00
Puranam V G Tejaswi
918f2dd648
msm: kgsl: do not set private flag for secure allocations
The intention to set page private flag was to avoid
importing secure buffers as non secure buffers. This would
result in secure buffers being incorrectly mapped to a non
secure context bank. This problem can arise when importing
ion buffers, but never with a secure allocation from kgsl.
There is no means to import a secure kgsl buffer as
non secure buffer. So setting page private for secure
allocations done by kgsl can be safely removed.

Change-Id: I9ea879ec36f945a0f1fd57055dc7d4fa3bfe8905
Signed-off-by: Puranam V G Tejaswi <pvgtejas@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:42 +07:00
Pankaj Gupta
b42257f4be
msm: kgsl: Clear halt before gmu boot
During hard reset if we are not able to toggle the CX
gdsc, the halt will remain asserted at the time of next
GMU boot. This causes GMU boot to fail and lead to NoC
errors. So clear the halt bit before attempting GMU boot.

Change-Id: Id214e0a9261c1f14de13864c715cf1a9d415e1e7
Signed-off-by: Harshdeep Dhatt <hdhatt@codeaurora.org>
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:42 +07:00
Akhil P Oommen
92028ba7fd
msm: kgsl: Fix gdsc disable timeout during reset
Smmu driver takes a vote on CX gdsc before calling the kgsl pagefault
handler. If there is contention for device mutex in this path and the
dispatcher fault handler is holding this lock, trying to turn off CX
gdsc will fail during the reset. So to avoid blocking here, try to lock
device mutex and return if it fails.

Since we are modifying here, keep the pagefault header for UCHE block
short.

Change-Id: Idf1726960071d66b9112f6b4abdf19a49afacefd
Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:41 +07:00
Pankaj Gupta
2b1f803da2
msm: kgsl: Signal dump_gate only when worker finishes work
Currently we are accessing snapshot structure after signaling
dump_gate. In corner cases this worker can get preempted
before driver reads this variable, and eventually client
dumps the snapshot and snapshot object gets released.
When worker gets back in execution it will read freed memory
and will case kernel panic.

To fix this race, do completion for dump_gate after finishing
work in worker kgsl_snapshot_save_frozen_objs.

Change-Id: Iaf3c9f9e75a6e3e19653d2d166e2da624796ec98
Signed-off-by: Pankaj Gupta <gpankaj@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:41 +07:00
Pranav Patel
1a521dea78
msm: kgsl: clear fault to avoid race between timeout and hard fault
Observed race between timeout fault (long IB detection) and
MISC hang (hard fault). MISC hang can be set while in recovery from
timeout fault. If fault flag is set in start path CP init fails.
Clear gpu fault to avoid such race.

Change-Id: Id99dcefd0ef3438bc95c6c3c84e2eadce214cf77
Signed-off-by: Pranav Patel <pranavp@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:41 +07:00
Deepak Kumar
b074df3b66
msm: kgsl: Offload mementry destroy work to separate thread
Any memory free ioctl doesn't need to be blocked till the
corresponding mementry is destroyed. This change defers
the mementry put to unblock all memory free ioctls immediately.
This is done to reduce the time spent by user applications in
waiting for memory to be freed.

Change-Id: If081fec0c34549071a61639249fe86924745eb9c
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:41 +07:00
Yaroslav Furman
ea753c9393
kgsl: mark worker thread as perf critical
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:40 +07:00
Tim Murray
3bec1c629f
kgsl: add low_prio_worker thread
Adds a new CFS thread for freeing GPU memory. Improves performance
when tearing down processes (eg, via LMK) and not blocking currently
running UI from submitting work to the GPU.

Test: boots, works
Bug: 137140296
Bug: 137927078

Change-Id: I47b42691862b01501a77bce0965d8be7538c1d26
Signed-off-by: Tim Murray <timmurray@google.com>
Signed-off-by: Sean Callanan <spyffe@google.com>
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:39 +07:00
Yaroslav Furman
32ac7d9a70
Revert "msm: kgsl: Use event workqueue for event work instead of RT Kthread worker"
This reverts commit a3fdf9b3115aab6f6c63b02ceaae91043c61cf37.

Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:39 +07:00
Danny Lin
ea9ce4d947
msm: kgsl: Convert from nr_indirectly_reclaimable_bytes to nr_kernel_misc_reclaimable
Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:38 +07:00
Sultan Alsawaf
ca569cc0de
msm: kgsl: Don't busy wait for fenced GMU writes when possible
The most frequent user of fenced GMU writes, adreno_ringbuffer_submit(),
performs a fenced GMU write under a spin lock, and since fenced GMU
writes use udelay(), a lot of CPU cycles are burned here. Not only is
the spin lock held for longer than necessary (because the write doesn't
need to be inside the spin lock), but also a lot of CPU time is wasted
in udelay() for tens of microseconds when usleep_range() can be used
instead.

Move the locked fenced GMU writes to outside their spin locks and make
adreno_gmu_fenced_write() use usleep_range() when not in atomic/IRQ
context, to save power and improve performance. Fenced GMU writes are
found to take an average of 28 microseconds on the Snapdragon 855, so a
usleep range of 10 to 30 microseconds is optimal.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: Yaroslav Furman <yaro330@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:38 +07:00
Sandeep Singh
4a4d0890bd
icnss: Clear driver ops during driver unload
As part of wlan driver unload wlan driver is freeing driver
ops memory on its side. ICNSS driver doesn't call wlan driver
remove if it is not probed. So, In some cases when wlan driver
has not been probed and driver unload comes,icnss driver doesn't
clears driver ops on its side which leads of freed memory
access on its side. This change clears wlan driver ops during
driver unload if wlan driver is not probed.

Change-Id: Idb03725b2c0b1bf68337badc82e40b1633bfcaa5
Signed-off-by: Sandeep Singh <sandsing@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:38 +07:00
Sandeep Singh
047a4aad6b
icnss: Avoid wlan driver unload if driver is not probed
Avoid wlan host driver unload if wlan host driver is not
probed.

Change-Id: I60b5486654b42e0b4431c8fc96d956aa749c44b3
Signed-off-by: Sandeep Singh <sandsing@codeaurora.org>
Signed-off-by: celtare21 <celtare21@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:38 +07:00
Arun Prakash
7ab48cdec7
soc: qcom: smp2p: keeping inbound entry on freeze
Avoiding inbound entry release during freeze callback
to keep the irq domain as it is.Resetting inbound
last value.

Change-Id: Ic5374fa8094d0f4de914076cef348469158b4012
Signed-off-by: Arun Prakash <app@codeaurora.org>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:37 +07:00
Chris Lew
03bbcd6aa1
soc: qcom: smp2p_sleepstate: Add suspend delay
Add delay in smp2p_sleepstate suspend path to prevent wakeup loop with
non wakeup streaming from sensors. This delay should be the maximum
time for sensors samples in flight to be drained.

Change-Id: I79f944caa2ccdd65dc1649aef8d6359f44612479
Signed-off-by: Chris Lew <clew@codeaurora.org>
Signed-off-by: Ananth Raghavan Subramanian <sananth@codeaurora.org>
Signed-off-by: Kelly Rossmoyer <krossmo@google.com>
Bug: 123377615
Bug: 131260677
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:37 +07:00
Sultan Alsawaf
5983124431
msm: msm_bus: Don't enable QoS clocks when none are present
There's no point in enabling QoS clocks when are none of them for certain
clients.

Signed-off-by: Sultan Alsawaf <sultan@kerneltoast.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:37 +07:00
Danny Lin
bfdabe5b77
sched/energy: Check out to Android 4.14 common kernel
To fix CAF's breakage.

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:37 +07:00
azrim
22100de399
configs: surya: Regenerate full defconfig
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:36 +07:00
Danny Lin
dc40b2c53d
Merge branch 'qspinlock'
Fast and efficient queued spinlocks backported from mainline v5.3.

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:36 +07:00
azrim
67275beaaf
configs: surya: Regenerate full defconfig
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:36 +07:00
Luis Chamberlain
04b5ef8233
BACKPORT: zram: use ATTRIBUTE_GROUPS
Embrace ATTRIBUTE_GROUPS to avoid boiler plate code.  This should not
introduce any functional changes.

Link: https://lkml.kernel.org/r/20211028203600.2157356-1-mcgrof@kernel.org
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:35 +07:00
Jens Axboe
2711c30639
BACKPORT: zram: only make zram_wb_devops for CONFIG_ZRAM_WRITEBACK
If writeback isn't configured, then we get the following warning when
compiling zram:

drivers/block/zram/zram_drv.c:1824:45: warning: unused variable 'zram_wb_devops' [-Wunused-const-variable]

Make sure we only define the block_device_operations if that option is
enabled.

Link: https://lore.kernel.org/lkml/202111261614.gCJMqcyh-lkp@intel.com/
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:35 +07:00
Cyber Knight
7cc661c45d
Revert "BACKPORT: block: add blk_alloc_disk and blk_cleanup_disk APIs"
subsequent to 5f08088de385{"zram: Fix kernel panic revolving around `zram_free_page()`"}

This reverts commit 594d359bd0b9027d6cf143646e45ec38ad8b4b9c.

Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:35 +07:00
Cyber Knight
615a3c653a
zram: Fix kernel panic revolving around zram_free_page()
[1] causes a kernel panic at init with the following logs

<1>[    0.401821] Unable to handle kernel paging request at virtual address 08000008
<1>[    0.401828] Mem abort info:
<1>[    0.401832]   Exception class = DABT (current EL), IL = 32 bits
<1>[    0.401834]   SET = 0, FnV = 0
<1>[    0.401836]   EA = 0, S1PTW = 0
<1>[    0.401840]   FSC = 5
<1>[    0.401841] Data abort info:
<1>[    0.401844]   ISV = 0, ISS = 0x00000005
<1>[    0.401847]   CM = 0, WnR = 0
<1>[    0.401850] [0000000008000008] user address but active_mm is swapper
<0>[    0.401854] Internal error: Oops: 96000005 [#1] PREEMPT SMP
<0>[    0.401859] Process swapper/0 (pid: 1, stack limit = 0x        (ptrval))
<4>[    0.401864] CPU: 6 PID: 1 Comm: swapper/0 Tainted: G S              4.14.255StormBreaker-X10 #1
<4>[    0.401868] Hardware name: Qualcomm Technologies, Inc. SDMMAGPIE PM6150 IDP (DT)
<4>[    0.401873] task:         (ptrval) task.stack:         (ptrval)
<4>[    0.401887] pc : zram_free_page+0x28/0x1d0
<4>[    0.401891] lr : zram_add+0x94/0x170
<4>[    0.401893] sp : ffffff801005bc00 pstate : 80800045
<4>[    0.401896] x29: ffffff801005bc10 x28: 0000000000000000
<4>[    0.401899] x27: 0000000000000000 x26: 0000000000000000
<4>[    0.401903] x25: 0000000000000000 x24: ffffff94a02d1ae0
<4>[    0.401906] x23: ffffff94a0705000 x22: 0000000000000000
<4>[    0.401909] x21: ffffff94a047c000 x20: 0000000000000000
<4>[    0.401911] x19: ffffff94a047c180 x18: 0000000000000000
<4>[    0.401914] x17: 0000000000000000 x16: 00000000000000e4
<4>[    0.401917] x15: ffffff949fa318d4 x14: 0000000000000000
<4>[    0.401919] x13: 00b0406fdcffffff x12: 00000047dc60b000
<4>[    0.401922] x11: 0000000000000000 x10: 0000000008000000
<4>[    0.401924] x9 : 0000000008000000 x8 : 0000000008000000
<4>[    0.401927] x7 : 0000000000000000 x6 : 000000000000003f
<4>[    0.401929] x5 : 0000000000000000 x4 : 0000000000000000
<4>[    0.401931] x3 : ffffffdc6fb1f800 x2 : ffffff94a047c188
<4>[    0.401934] x1 : 0000000000000000 x0 : ffffff94a047c180
<4>[    0.401938]
<4>[    0.401938] PC: 0xffffff949ebf6f88:
<4>[    0.401940] 6f88  f9001a7f b9004a7f f9001e68 f9002268 f9002a7f b9004e7f d10103ff f9400008
<4>[    0.401947] 6fa8  a9034ff4 aa0103f4 a90257f6 aa0003f3 92407c36 8b34510a a9017bfd 910043fd
<4>[    0.401953] 6fc8  f8408d49 37e80289 d37ceed5 37e00329 8b16110a 9100214a 37d00489 37c807a9
<4>[    0.401959] 6fe8  f8756901 b4000a81 f9400660 97e18683 f9400268 9101a261 8b161108 f9400508
<4>[    0.401965]
<4>[    0.401965] LR: 0xffffff949ebf6e84:
<4>[    0.401968] 6e84  910023e1 72a02802 12b00003 a900ffff 9438d8af aa0003f4 b140041f 54000448
<4>[    0.401974] 6ea4  d000c420 f94013e1 91060000 aa1403e2 aa1303e3 aa1f03e4 aa1f03e5 9438d440
<4>[    0.401979] 6ec4  f94013e8 b4000248 b9400be9 1200152a 52800029 53067d4b 9aca212a 8b2b4d0b
<4>[    0.401985] 6ee4  f941156c ea0c015f 540001c0 9108a16b 8a2a018a f900016a f941150a b500012a
<4>[    0.401991]
<4>[    0.401991] SP: 0xffffff801005bbc0:
<4>[    0.401993] bbc0  9ebf6fc8 ffffff94 80800045 00000000 00000000 014002c0 7547d700 ffffffdc
<4>[    0.401998] bbe0  ffffffff ffffffff 9ebf6e98 ffffff94 1005bc10 ffffff80 9ebf6fc8 ffffff94
<4>[    0.402004] bc00  00000000 00000000 00000000 00000000 1005bc70 ffffff80 9ebf6ec4 ffffff94
<4>[    0.402009] bc20  7547d700 ffffffdc a047c000 ffffff94 00000000 00000000 6fb1f800 ffffffdc
<4>[    0.402014]
<4>[    0.402017] Call trace:
<4>[    0.402020]  zram_free_page+0x28/0x1d0
<4>[    0.402023]  zram_add+0x94/0x170
<4>[    0.402028]  zram_init+0x11c/0x3a0
<4>[    0.402032]  do_one_initcall+0x1c0/0x210
<4>[    0.402035]  kernel_init_freeable+0x5cc/0x710
<4>[    0.402038]  kernel_init+0x10/0x280
<4>[    0.402044]  ret_from_fork+0x10/0x18
<0>[    0.402047] Code: 92407c36 8b34510a a9017bfd 910043fd (f8408d49)
<4>[    0.402050] ---[ end trace 4d61b66acb6a904c ]---
<0>[    0.403950] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
<0>[    0.403950]
<2>[    0.403957] SMP: stopping secondary CPUs
<3>[    1.004015] ipa ipa3_active_clients_panic_notifier:293
<3>[    1.004015] ---- Active Clients Table ----
<3>[    1.004015]
<3>[    1.004015] Total active clients count: 0
<3>[    1.004015]
<0>[    1.004020] Kernel Offset: 0x148e200000 from 0xffffff8010000000
<0>[    1.004024] CPU features: 0x11002228
<0>[    1.004026] Memory Limit: none

Tracing back zram_free_page() and zram_add() with GDB reveals that [1]{"BACKPORT: zram: convert to blk_alloc_disk/blk_cleanup_disk"} caused the panic.

[1]: 753eb019a7

Test: Reverted [1], compiled and it booted with Clang 14.0.0
Co-authored-by: Forenche <prahul2003@gmail.com>
Suggested-by: Jebaitedneko <Jebaitedneko@gmail.com>
Signed-off-by: Forenche <prahul2003@gmail.com>
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:35 +07:00
Brian Geffon
83edc9f553
BACKPORT: zram: introduce an aged idle interface
This change introduces an aged idle interface to the existing idle sysfs
file for zram.

When CONFIG_ZRAM_MEMORY_TRACKING is enabled the idle file now also
accepts an integer argument.  This integer is the age (in seconds) of
pages to mark as idle.  The idle file still supports 'all' as it always
has.  This new approach allows for much more control over which pages
get marked as idle.

[bgeffon@google.com: use IS_ENABLED and cleanup comment]
  Link: https://lkml.kernel.org/r/20210924161128.1508015-1-bgeffon@google.com
[bgeffon@google.com: Sergey's cleanup suggestions]
  Link: https://lkml.kernel.org/r/20210929143056.13067-1-bgeffon@google.com

Link: https://lkml.kernel.org/r/20210923130115.1344361-1-bgeffon@google.com
Signed-off-by: Brian Geffon <bgeffon@google.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Suleiman Souhlal <suleiman@google.com>
Cc: Jesse Barnes <jsbarnes@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:35 +07:00
Dan Carpenter
8bbf3a8965
BACKPORT: zram: off by one in read_block_state()
snprintf() returns the number of bytes it would have printed if there
were space.  But it does not count the NUL terminator.  So that means
that if "count == copied" then this has already overflowed by one
character.

This bug likely isn't super harmful in real life.

Link: https://lkml.kernel.org/r/20210916130404.GA25094@kili
Fixes: c0265342bff4 ("zram: introduce zram memory tracking")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:34 +07:00
Jaewon Kim
7cadaaa602
BACKPORT: zram_drv: allow reclaim on bio_alloc
The read_from_bdev_async is not called on atomic context.  So GFP_NOIO
is available rather than GFP_ATOMIC.  If there were reclaimable pages
with GFP_NOIO, we can avoid allocation failure and page fault failure.

Link: https://lkml.kernel.org/r/20210908005241.28062-1-jaewon31.kim@samsung.com
Signed-off-by: Jaewon Kim <jaewon31.kim@samsung.com>
Reported-by: Yong-Taek Lee <ytk.lee@samsung.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:34 +07:00
Ming Lei
e9fe1a19b2
BACKPORT: zram: replace fsync_bdev with sync_blockdev
When calling fsync_bdev(), zram driver guarantees that the bdev won't be
opened by anyone, then there can't be one active fs/superblock over the
zram bdev, so replace fsync_bdev with sync_blockdev.

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Link: https://lore.kernel.org/r/20211025025426.2815424-5-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:34 +07:00
Ming Lei
1ebc642c24
BACKPORT: zram: avoid race between zram_remove and disksize_store
After resetting device in zram_remove(), disksize_store still may come and
allocate resources again before deleting gendisk, fix the race by resetting
zram after del_gendisk() returns. At that time, disksize_store can't come
any more.

Reported-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Link: https://lore.kernel.org/r/20211025025426.2815424-4-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:34 +07:00
Ming Lei
ccde300db7
BACKPORT: zram: don't fail to remove zram during unloading module
When the zram module is being unloaded, no one should be using the
zram disks. However even while being unloaded the zram module's
sysfs attributes might be poked at to re-configure zram devices.
This is expected, and kernfs ensures that these operations complete
before device_del() completes.

But reset_store() may set ->claim which will fail zram_remove(), when
this happens, zram_reset_device() is bypassed, and zram->comp can't
be destroyed, so the warning of 'Error: Removing state 63 which has
instances left.' is triggered during unloading module, together with
memory leak and sort of thing.

Fixes the issue by not failing zram_remove() if ->claim is set, and
we actually need to do nothing in case that zram_reset() is running
since del_gendisk() will wait until zram_reset() is done.

Reported-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Link: https://lore.kernel.org/r/20211025025426.2815424-3-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:34 +07:00
Ming Lei
5267d9952f
BACKPORT: zram: fix race between zram_reset_device() and disksize_store()
When the ->init_lock is released in zram_reset_device(), disksize_store()
can come in and try to allocate meta, but zram_reset_device() is freeing
free meta, so cause races.

Link: https://lore.kernel.org/linux-block/20210927163805.808907-1-mcgrof@kernel.org/T/#mc617f865a3fa2778e40f317ddf48f6447c20c073
Reported-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Link: https://lore.kernel.org/r/20211025025426.2815424-2-ming.lei@redhat.com
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:33 +07:00
Yue Hu
435db2550f
BACKPORT: zram: move backing_dev under macro CONFIG_ZRAM_WRITEBACK
backing_dev is never used when not enable CONFIG_ZRAM_WRITEBACK and it's
introduced from writeback feature.  So it's needless also affect
readability in that case.

Link: https://lkml.kernel.org/r/20210521060544.2385-1-zbestahu@gmail.com
Signed-off-by: Yue Hu <huyue2@yulong.com>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:33 +07:00
Christoph Hellwig
fbd4a6aafd
BACKPORT: zram: convert to blk_alloc_disk/blk_cleanup_disk
Convert the zram driver to use the blk_alloc_disk and blk_cleanup_disk
helpers to simplify gendisk and request_queue allocation.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20210521055116.1053587-11-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:33 +07:00
Minchan Kim
3c0337ffb7
BACKPORT: zram: fix broken page writeback
commit 0d83596 ("zram: support page writeback") introduced two
problems.  It overwrites writeback_store's return value as kstrtol's
return value, which makes return value zero so user could see zero as
return value of write syscall even though it wrote data successfully.

It also breaks index value in the loop in that it doesn't increase the
index any longer.  It means it can write only first starting block index
so user couldn't write all idle pages in the zram so lose memory saving
chance.

This patch fixes those issues.

Link: https://lkml.kernel.org/r/20210312173949.2197662-2-minchan@kernel.org
Fixes: 0d83596("zram: support page writeback")
Signed-off-by: Minchan Kim <minchan@kernel.org>
Reported-by: Amos Bianchi <amosbianchi@google.com>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: John Dias <joaodias@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:33 +07:00
Minchan Kim
9a6ad6a93c
BACKPORT: zram: fix return value on writeback_store
writeback_store's return value is overwritten by submit_bio_wait's return
value.  Thus, writeback_store will return zero since there was no IO
error.  In the end, write syscall from userspace will see the zero as
return value, which could make the process stall to keep trying the write
until it will succeed.

Link: https://lkml.kernel.org/r/20210312173949.2197662-1-minchan@kernel.org
Fixes: 3b82a051c101("drivers/block/zram/zram_drv.c: fix error return codes not being returned in writeback_store")
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Colin Ian King <colin.king@canonical.com>
Cc: John Dias <joaodias@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:32 +07:00
Tian Tao
bc8f219e32
BACKPORT: zram: fix NULL check before some freeing functions is not needed
fixed the below warning:
/drivers/block/zram/zram_drv.c:534:2-8: WARNING: NULL check
before some freeing functions is not needed.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:32 +07:00
kingbri
fc0b75fbad
zram: Expose compression algorithms to userspace
This makes it easier to debug/edit zram compression algorithms for the user.
The user can change from the default algorithm to something else

File in sysfs: "/sys/module/zram/parameters/default_compressor"

Signed-off-by: kingbri <bdashore3@gmail.com>
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:32 +07:00
Rui Salvaterra
464473141b
BACKPORT: zram: break the strict dependency from lzo
From the beginning, the zram block device always enabled CRYPTO_LZO,
since lzo is hardcoded as the fallback compression algorithm.  As a
consequence, on systems where another compression algorithm is chosen
(e.g.  CRYPTO_ZSTD), the lzo kernel module becomes unused, while still
having to be built/loaded.

This patch removes the hardcoded lzo dependency and allows the user
to select the default compression algorithm for zram at build time.  The
previous behaviour is kept, as the default algorithm is still lzo.
Link: https://lkml.kernel.org/r/20201207121245.50529-1-rsalvaterra@gmail.com
Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
Suggested-by: Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com>
Suggested-by: Minchan Kim <minchan@kernel.org>
Acked-by: Minchan Kim <minchan@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:32 +07:00
Minchan Kim
3955d8636b
BACKPORT: zram: add stat to gather incompressible pages since zram set up
Currently, zram supports the stat via /sys/block/zram/mm_stat to represent
how many of incompressible pages are stored at the moment but it couldn't
show how many times incompressible pages were wrote down since zram set
up.  It's also good indication to see how zram is effective in the system.

Link: https://lkml.kernel.org/r/20201130201907.1284910-1-minchan@kernel.org
Signed-off-by: Minchan Kim <minchan@kernel.org>
Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[cyberknight777: backport to 4.14]
Signed-off-by: Cyber Knight <cyberknight755@gmail.com>
Signed-off-by: azrim <mirzaspc@gmail.com>
2022-04-06 13:20:31 +07:00