Compare

c6c159fcdb4e9a678eda0831f971e4a3a488ec47..c5958c770b2a0ee492414e26b07da9164a0d1f5d

scsi: libiscsi: Validate the ITT reflected in a Reject PDU

A Reject PDU carries a copy of the header it rejects, and
iscsi_handle_reject() takes the ITT out of that copy to find the task to
clean up:

      memcpy(&rejected_pdu, data, sizeof(struct iscsi_hdr));
      ...
      task = iscsi_itt_to_task(conn, rejected_pdu.itt);

That value is whatever the target put there. iscsi_itt_to_task() bounds
the index against cmds_max and checks nothing else, so any task in the
pool can be named, and iscsi_nop_out_rsp() then completes it.

An index that has never been used gives a NULL task->conn: the pool is
zeroed at session setup and conn is assigned only when a task is
allocated. If the task was used and returned, iscsi_complete_task() hits
its WARN_ON_ONCE(task->state == ISCSI_TASK_FREE) and the refcount
underflows. An in-flight SCSI command is completed as successful - a 1
MiB read returned 1048576 with none of its buffer written and no
warning.

Validate the reflected ITT the way iscsi_itt_to_ctask() validates a
command ITT, and require the task to be in flight and not a SCSI
command.

[    6.248477] Oops: general protection fault, probably for non-canonical address 0xdffffc000000000c: 0000 [#1] SMP KASAN NOPTI
[    6.249357] KASAN: null-ptr-deref in range [0x0000000000000060-0x0000000000000067]
[    6.249951] CPU: 1 UID: 0 PID: 0 Comm: swapper/1 Not tainted 7.2.0-rc5-ISCSI1-gf5098b6bae76 #1 PREEMPT(lazy)
[    6.250718] Hardware name: QEMU Ubuntu 24.04 PC v2 (i440FX + PIIX, arch_caps fix, 1996), BIOS 1.16.3-debian-1.16.3-2 04/01/2014
[    6.251616] RIP: 0010:iscsi_nop_out_rsp.constprop.0+0x46/0x160
[    6.252043] Code: c1 ea 03 48 83 ec 08 80 3c 02 00 0f 85 f5 00 00 00 48 b8 00 00 00 00 00 fc ff df 48 8b 6b 58 48 8d 7d 60 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 c0 00 00 00 48 8b 45 60 48 39 c3 74 50 48 b8 00
[    6.252813] RSP: 0018:ffff88806c907b80 EFLAGS: 00010206
[    6.253042] RAX: dffffc0000000000 RBX: ffff88800607e000 RCX: ffffffff8d571a25
[    6.253345] RDX: 000000000000000c RSI: ffff88806c907c38 RDI: 0000000000000060
[    6.253642] RBP: 0000000000000000 R08: 0000000000000000 R09: fffffbfff235a504
[    6.253947] R10: 0000000000000003 R11: 7463656e6e6f6320 R12: 0000000000000000
[    6.254251] R13: 0000000000000000 R14: ffff88806c907c38 R15: 0000000000000000
[    6.254549] FS:  0000000000000000(0000) GS:ffff8880d95bc000(0000) knlGS:0000000000000000
[    6.254887] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[    6.255140] CR2: 00007fc393e8ffc0 CR3: 0000000005252006 CR4: 0000000000770ef0
[    6.255439] PKRU: 55555554
[    6.255564] Call Trace:
[    6.255674]  <IRQ>
[    6.255768]  __iscsi_complete_pdu+0x18bf/0x22a0
[    6.256733]  iscsi_complete_pdu+0x54/0xa0
[    6.256905]  iscsi_tcp_data_recv_done+0xf4/0x250
[    6.257103]  iscsi_tcp_recv_skb+0x31e/0xec0
[    6.257680]  iscsi_sw_tcp_recv+0x12f/0x390
[    6.258061]  __tcp_read_sock+0x1ab/0x810
[    6.258853]  iscsi_sw_tcp_data_ready+0x18b/0x510
[    6.259808]  tcp_data_queue+0x1f13/0x4cd0
[    6.260567]  tcp_rcv_established+0x8a5/0x3a00
[    6.261931]  tcp_v4_do_rcv+0x449/0x960
[    6.262269]  tcp_v4_rcv+0x2245/0x3bc0

Fixes: 8afa1439fcff ("[SCSI] libiscsi: handle immediate command rejections")
Cc: stable@vger.kernel.org
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Yehyeong Lee <yhlee@isslab.korea.ac.kr>
Link: https://patch.msgid.link/20261007015842.634893-3-yhlee@isslab.korea.ac.kr
Signed-off-by: Martin K. Petersen (Oracle) <mkp@kernel.org>

Yehyeong Lee <yhlee@isslab.korea.ac.kr> · 2026-10-07 01:58 UTC · committed by Martin K. Petersen (Oracle)

Browse files
747 files changed, +4067 −7047
modified .mailmap
@@ -19,8 +19,7 @@ Abhinav Kumar <quic_abhinavk@quicinc.com> <abhinavk@codeaurora.org>
19 19 Ahmad Masri <quic_amasri@quicinc.com> <amasri@codeaurora.org>
20 20 Adam Oldham <oldhamca@gmail.com>
21 21 Adam Radford <aradford@gmail.com>
22 - Aditya Garg <aditya.garg@linux.dev> <gargaditya08@live.com>
23 - Aditya Garg <aditya.garg@linux.dev> <gargaditya08@proton.me>
22 + Aditya Garg <gargaditya08@proton.me> <gargaditya08@live.com>
24 23 Adriana Reus <adi.reus@gmail.com> <adriana.reus@intel.com>
25 24 Adrian Bunk <bunk@stusta.de>
26 25 Ajay Kaher <ajay.kaher@broadcom.com> <akaher@vmware.com>
@@ -700,7 +699,6 @@ Oliver Hartkopp <socketcan@hartkopp.net> <oliver.hartkopp@volkswagen.de>
700 699 Oliver Hartkopp <socketcan@hartkopp.net> <oliver@hartkopp.net>
701 700 Oliver Upton <oupton@kernel.org> <oupton@google.com>
702 701 Oliver Upton <oupton@kernel.org> <oliver.upton@linux.dev>
703 - Ondrej Mosnáček <omosnacek@gmail.com> <omosnace@redhat.com>
704 702 Ondřej Jirman <megi@xff.cz> <megous@megous.com>
705 703 Oza Pawandeep <quic_poza@quicinc.com> <poza@codeaurora.org>
706 704 Pali Rohár <pali@kernel.org> <pali.rohar@gmail.com>
@@ -900,8 +898,7 @@ Thomas Graf <tgraf@suug.ch>
900 898 Thomas Gleixner <tglx@kernel.org> <tglx@linutronix.de>
901 899 Thomas Körper <socketcan@esd.eu> <thomas.koerper@esd.eu>
902 900 Thomas Pedersen <twp@codeaurora.org>
903 - Thorsten Blum <blum@kernel.org> <thorsten.blum@toblux.com>
904 - Thorsten Blum <blum@kernel.org> <thorsten.blum@linux.dev>
901 + Thorsten Blum <thorsten.blum@linux.dev> <thorsten.blum@toblux.com>
905 902 Tiezhu Yang <yangtiezhu@loongson.cn> <kernelpatch@126.com>
906 903 Tingwei Zhang <quic_tingwei@quicinc.com> <tingwei@codeaurora.org>
907 904 Tirupathi Reddy <quic_tirupath@quicinc.com> <tirupath@codeaurora.org>
modified CREDITS
@@ -1512,10 +1512,6 @@ N: Andy Gross
1512 1512 E: agross@kernel.org
1513 1513 D: Qualcomm SoC subsystem and drivers
1514 1514
1515 - N: Mark Gross
1516 - E: markgross@kernel.org
1517 - D: x86/mellanox platform maintenance and various x86 specific drivers
1518 -
1519 1515 N: Grant Grundler
1520 1516 E: grantgrundler@gmail.com
1521 1517 W: http://obmouse.sourceforge.net/
@@ -4309,10 +4305,6 @@ N: Juergen Weigert
4309 4305 E: jnweiger@immd4.informatik.uni-erlangen.de
4310 4306 D: The Linux Support Team Erlangen
4311 4307
4312 - N: Russ Weight
4313 - E: russ.weight@gmail.com
4314 - D: Added support for Firmware Upload to the Firmware Loader
4315 -
4316 4308 N: David Weinehall
4317 4309 E: tao@acc.umu.se
4318 4310 P: 1024D/DC47CA16 7ACE 0FB0 7A74 F994 9B36 E1D1 D14E 8526 DC47 CA16
modified Documentation/ABI/testing/ima_policy
@@ -108,9 +108,6 @@ Description:
108 108 # NSFS_MAGIC
109 109 dont_measure fsmagic=0x6e736673
110 110 dont_appraise fsmagic=0x6e736673
111 - # CONFIGFS_MAGIC
112 - dont_measure fsmagic=0x62656570
113 - dont_appraise fsmagic=0x62656570
114 111
115 112 measure func=BPRM_CHECK
116 113 measure func=FILE_MMAP mask=MAY_EXEC
modified Documentation/ABI/testing/sysfs-class-firmware
@@ -1,7 +1,7 @@
1 1 What: /sys/class/firmware/.../data
2 2 Date: July 2022
3 3 KernelVersion: 5.19
4 - Contact: driver-core@lists.linux.dev
4 + Contact: Russ Weight <russ.weight@linux.dev>
5 5 Description: The data sysfs file is used for firmware-fallback and for
6 6 firmware uploads. Cat a firmware image to this sysfs file
7 7 after you echo 1 to the loading sysfs file. When the firmware
@@ -13,7 +13,7 @@ Description: The data sysfs file is used for firmware-fallback and for
13 13 What: /sys/class/firmware/.../cancel
14 14 Date: July 2022
15 15 KernelVersion: 5.19
16 - Contact: driver-core@lists.linux.dev
16 + Contact: Russ Weight <russ.weight@linux.dev>
17 17 Description: Write-only. For firmware uploads, write a "1" to this file to
18 18 request that the transfer of firmware data to the lower-level
19 19 device be canceled. This request will be rejected (EBUSY) if
@@ -23,7 +23,7 @@ Description: Write-only. For firmware uploads, write a "1" to this file to
23 23 What: /sys/class/firmware/.../error
24 24 Date: July 2022
25 25 KernelVersion: 5.19
26 - Contact: driver-core@lists.linux.dev
26 + Contact: Russ Weight <russ.weight@linux.dev>
27 27 Description: Read-only. Returns a string describing a failed firmware
28 28 upload. This string will be in the form of <STATUS>:<ERROR>,
29 29 where <STATUS> will be one of the status strings described
@@ -37,7 +37,7 @@ Description: Read-only. Returns a string describing a failed firmware
37 37 What: /sys/class/firmware/.../loading
38 38 Date: July 2022
39 39 KernelVersion: 5.19
40 - Contact: driver-core@lists.linux.dev
40 + Contact: Russ Weight <russ.weight@linux.dev>
41 41 Description: The loading sysfs file is used for both firmware-fallback and
42 42 for firmware uploads. Echo 1 onto the loading file to indicate
43 43 you are writing a firmware file to the data sysfs node. Echo
@@ -49,7 +49,7 @@ Description: The loading sysfs file is used for both firmware-fallback and
49 49 What: /sys/class/firmware/.../remaining_size
50 50 Date: July 2022
51 51 KernelVersion: 5.19
52 - Contact: driver-core@lists.linux.dev
52 + Contact: Russ Weight <russ.weight@linux.dev>
53 53 Description: Read-only. For firmware upload, this file contains the size
54 54 of the firmware data that remains to be transferred to the
55 55 lower-level device driver. The size value is initialized to
@@ -62,7 +62,7 @@ Description: Read-only. For firmware upload, this file contains the size
62 62 What: /sys/class/firmware/.../status
63 63 Date: July 2022
64 64 KernelVersion: 5.19
65 - Contact: driver-core@lists.linux.dev
65 + Contact: Russ Weight <russ.weight@linux.dev>
66 66 Description: Read-only. Returns a string describing the current status of
67 67 a firmware upload. The string will be one of the following:
68 68 idle, "receiving", "preparing", "transferring", "programming".
@@ -70,7 +70,7 @@ Description: Read-only. Returns a string describing the current status of
70 70 What: /sys/class/firmware/.../timeout
71 71 Date: July 2022
72 72 KernelVersion: 5.19
73 - Contact: driver-core@lists.linux.dev
73 + Contact: Russ Weight <russ.weight@linux.dev>
74 74 Description: This file supports the timeout mechanism for firmware
75 75 fallback. This file has no affect on firmware uploads. For
76 76 more information on timeouts please see the documentation
modified Documentation/admin-guide/cgroup-v1/memory.rst
@@ -47,6 +47,7 @@ Features:
47 47 - pages are linked to per-memcg LRU exclusively, and there is no global LRU.
48 48 - optionally, memory+swap usage can be accounted and limited.
49 49 - hierarchical accounting
50 + - soft limit
50 51 - moving (recharging) account at moving a task is selectable.
51 52 - usage threshold notifier
52 53 - memory pressure notifier
@@ -75,9 +76,10 @@ Brief summary of control files.
75 76 memory.memsw.failcnt show the number of memory+Swap hits limits
76 77 memory.max_usage_in_bytes show max memory usage recorded
77 78 memory.memsw.max_usage_in_bytes show max memory+Swap usage recorded
78 - memory.soft_limit_in_bytes This knob is deprecated and has no effect.
79 - Writes are ignored and reads always
80 - return the maximum value.
79 + memory.soft_limit_in_bytes set/show soft limit of memory usage
80 + This knob is not available on CONFIG_PREEMPT_RT systems.
81 + This knob is deprecated and shouldn't be
82 + used.
81 83 memory.stat show various statistics
82 84 memory.use_hierarchy set/show hierarchical account enabled
83 85 This knob is deprecated and shouldn't be
@@ -338,6 +340,9 @@ memory.kmem.usage_in_bytes, or in a separate counter when it makes sense.
338 340 The main "kmem" counter is fed into the main counter, so kmem charges will
339 341 also be visible from the user counter.
340 342
343 + Currently no soft limit is implemented for kernel memory. It is future work
344 + to trigger slab reclaim when those limits are reached.
345 +
341 346 2.7.1 Current Kernel Memory resources accounted
342 347 -----------------------------------------------
343 348
@@ -705,10 +710,42 @@ For compatibility reasons writing 1 to memory.use_hierarchy will always pass::
705 710
706 711 THIS IS DEPRECATED!
707 712
708 - Writing to memory.soft_limit_in_bytes has no effect and reading it will
709 - always return the maximum value.
713 + Soft limits allow for greater sharing of memory. The idea behind soft limits
714 + is to allow control groups to use as much of the memory as needed, provided
715 +
716 + a. There is no memory contention
717 + b. They do not exceed their hard limit
718 +
719 + When the system detects memory contention or low memory, control groups
720 + are pushed back to their soft limits. If the soft limit of each control
721 + group is very high, they are pushed back as much as possible to make
722 + sure that one control group does not starve the others of memory.
723 +
724 + Please note that soft limits is a best-effort feature; it comes with
725 + no guarantees, but it does its best to make sure that when memory is
726 + heavily contended for, memory is allocated based on the soft limit
727 + hints/setup. Currently soft limit based reclaim is set up such that
728 + it gets invoked from balance_pgdat (kswapd).
729 +
730 + 7.1 Interface
731 + -------------
732 +
733 + Soft limits can be setup by using the following commands (in this example we
734 + assume a soft limit of 256 MiB)::
735 +
736 + # echo 256M > memory.soft_limit_in_bytes
737 +
738 + If we want to change this to 1G, we can at any time use::
710 739
711 - Use memory.low and memory.min in cgroup v2 instead.
740 + # echo 1G > memory.soft_limit_in_bytes
741 +
742 + .. note::
743 + Soft limits take effect over a long period of time, since they involve
744 + reclaiming memory for balancing between memory cgroups
745 +
746 + .. note::
747 + It is recommended to set the soft limit always below the hard limit,
748 + otherwise the hard limit will take precedence.
712 749
713 750 .. _cgroup-v1-memory-move-charges:
714 751
modified Documentation/admin-guide/cgroup-v2.rst
@@ -1130,9 +1130,9 @@ policy and the underlying scheduler. From the point of view of the cpu controlle
1130 1130 processes can be categorized as follows:
1131 1131
1132 1132 * Processes under the fair-class scheduler
1133 - * Processes under a BPF scheduler with the corresponding ``cgroup_set_*`` callback
1133 + * Processes under a BPF scheduler with the ``cgroup_set_weight`` callback
1134 1134 * Everything else: ``SCHED_{FIFO,RR,DEADLINE}`` and processes under a BPF scheduler
1135 - without the corresponding ``cgroup_set_*`` callback
1135 + without the ``cgroup_set_weight`` callback
1136 1136
1137 1137 For details on when a process is under the fair-class scheduler or a BPF scheduler,
1138 1138 check out :ref:`Documentation/scheduler/sched-ext.rst <sched-ext>`.
@@ -1223,9 +1223,7 @@ will be referred to. All time durations are in microseconds.
1223 1223 $PERIOD duration. "max" for $MAX indicates no limit. If only
1224 1224 one number is written, $MAX is updated.
1225 1225
1226 - This file affects only processes under the fair-class scheduler and a BPF
1227 - scheduler with the ``cgroup_set_bandwidth`` callback depending on what
1228 - the callback actually does.
1226 + This file affects only processes under the fair-class scheduler.
1229 1227
1230 1228 cpu.max.burst
1231 1229 A read-write single value file which exists on non-root
@@ -1233,9 +1231,7 @@ will be referred to. All time durations are in microseconds.
1233 1231
1234 1232 The burst in the range [0, $MAX].
1235 1233
1236 - This file affects only processes under the fair-class scheduler and a BPF
1237 - scheduler with the ``cgroup_set_bandwidth`` callback depending on what
1238 - the callback actually does.
1234 + This file affects only processes under the fair-class scheduler.
1239 1235
1240 1236 cpu.pressure
1241 1237 A read-write nested-keyed file.
@@ -1287,9 +1283,7 @@ will be referred to. All time durations are in microseconds.
1287 1283 own relative priorities, but the cgroup itself will be treated as
1288 1284 very low priority relative to its peers.
1289 1285
1290 - This file affects only processes under the fair-class scheduler and a BPF
1291 - scheduler with the ``cgroup_set_idle`` callback depending on what the
1292 - callback actually does.
1286 + This file affects only processes under the fair-class scheduler.
1293 1287
1294 1288 Memory
1295 1289 ------
@@ -3070,7 +3064,7 @@ resources (res_a and res_b) are registered then:
3070 3064 change in this file generates a file modified event. All fields in
3071 3065 this file are hierarchical.
3072 3066
3073 - <res>.max
3067 + max
3074 3068 The number of times the cgroup's resource usage was
3075 3069 about to go over the max boundary.
3076 3070
modified Documentation/devicetree/bindings/pinctrl/qcom,nord-tlmm.yaml
@@ -67,7 +67,7 @@ $defs:
67 67 Specify the alternative function to be configured for the specified
68 68 pins.
69 69
70 - enum: [ gpio, aoss_cti, atest_char, atest_usb20, atest_usb21,
70 + enum: [ aoss_cti, atest_char, atest_usb20, atest_usb21,
71 71 aud_intfc0_clk, aud_intfc0_data, aud_intfc0_ws,
72 72 aud_intfc10_clk, aud_intfc10_data, aud_intfc10_ws,
73 73 aud_intfc1_clk, aud_intfc1_data, aud_intfc1_ws,
@@ -98,10 +98,9 @@ $defs:
98 98 pcie3_clk_req_n, phase_flag, pll_bist_sync, pll_clk_aux,
99 99 prng_rosc0, prng_rosc1, pwrbrk_i_n, qdss, qdss_cti, qspi,
100 100 qup0_se0, qup0_se1, qup0_se2, qup0_se3, qup0_se4, qup0_se5,
101 - qup1_se0, qup1_se1, qup1_se2_01, qup1_se2_23, qup1_se3_01,
102 - qup1_se3_23, qup1_se4, qup1_se5,
101 + qup1_se0, qup1_se1, qup1_se3, qup1_se2, qup1_se4, qup1_se5,
103 102 qup1_se6, qup2_se0, qup2_se1, qup2_se2, qup2_se3, qup2_se4,
104 - qup2_se5, qup2_se6, qup3_se0_mira, qup3_se0_mirb,
103 + qup2_se5, qup2_se6,
105 104 sailss_ospi, sdc4_clk, sdc4_cmd, sdc4_data, smb_alert,
106 105 smb_alert_n, smb_clk, smb_dat, tb_trig_sdc4, tmess_prng0,
107 106 tmess_prng1, tsc_timer, tsense_pwm, usb0_hs,
modified Documentation/fault-injection/nvme-fault-injection.rst
@@ -176,68 +176,3 @@ Message from dmesg::
176 176 secondary_startup_64+0xa4/0xb0
177 177 nvme nvme0: Could not set queue count (16385)
178 178 nvme nvme0: IO queues not created
179 -
180 - Example 4: Inject an error into the first write command
181 - -------------------------------------------------------
182 -
183 - ::
184 -
185 - echo 0x01 > /sys/kernel/debug/nvme0n1/fault_inject/opcode
186 - echo 1 > /sys/kernel/debug/nvme0n1/fault_inject/times
187 - echo 100 > /sys/kernel/debug/nvme0n1/fault_inject/probability
188 - dd if=/dev/zero of=/dev/nvme0n1 oflag=direct bs=512 count=1
189 -
190 - Expected Result::
191 -
192 - The first write command sent to nvme0n1 fails
193 -
194 - Message from dmesg::
195 -
196 - FAULT_INJECTION: forcing a failure.
197 - name fault_inject, interval 1, probability 100, space 0, times 1
198 - CPU: 4 UID: 0 PID: 0 Comm: swapper/4 Not tainted 7.1.0+ #5 PREEMPT(full)
199 - Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.16.3-20240910_120124-localhost 04/01/2014
200 - Call Trace:
201 - <IRQ>
202 - dump_stack_lvl+0x6e/0xa0
203 - dump_stack+0x10/0x16
204 - should_fail_ex+0x461/0x510
205 - should_fail+0xb/0x20
206 - nvme_should_fail+0x11b/0x240 [nvme_core]
207 - nvme_poll_cq+0x6ad/0xb30 [nvme]
208 - nvme_irq+0x84/0xe0 [nvme]
209 - ? __pfx_nvme_irq+0x10/0x10 [nvme]
210 - ? rcu_core+0xa40/0xa90
211 - ? __pfx_sched_balance_softirq+0x10/0x10
212 - ? debug_smp_processor_id+0x17/0x20
213 - ? rcu_is_watching+0x13/0xa0
214 - __handle_irq_event_percpu+0x396/0x610
215 - handle_irq_event_percpu+0xf/0x90
216 - handle_irq_event+0xab/0x110
217 - handle_edge_irq+0x1a3/0x210
218 - __common_interrupt+0xff/0x170
219 - common_interrupt+0x90/0xc0
220 - </IRQ>
221 - <TASK>
222 - asm_common_interrupt+0x27/0x40
223 - RIP: 0010:pv_native_safe_halt+0x13/0x20
224 - Code: 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 8b 05 0a 2a 58 01 85 c0 7e 07 0f 00 2d ff cc 0d 00 fb f4 <c3> cc 0
225 - RSP: 0018:ffff888100a67e40 EFLAGS: 00000242
226 - RAX: 0000000000000001 RBX: ffff888100a49c40 RCX: ffffed102b6c645b
227 - RDX: ffffed102b6c645b RSI: ffffffff82a0d3c0 RDI: ffffffff81428b9b
228 - RBP: ffff888100a67e48 R08: ffffed102b6c645b R09: 0000000000000004
229 - R10: ffffed102b6c645a R11: 0000000000000001 R12: 0000000000000000
230 - R13: 0000000000000000 R14: ffffed1020149388 R15: dffffc0000000000
231 - ? do_idle+0x19b/0x2c0
232 - ? default_idle+0x9/0x20
233 - arch_cpu_idle+0x9/0x10
234 - default_idle_call+0x6b/0xa0
235 - do_idle+0x19b/0x2c0
236 - ? __pfx_do_idle+0x10/0x10
237 - ? complete_with_flags+0x63/0x70
238 - cpu_startup_entry+0x55/0x60
239 - start_secondary+0x1df/0x1e0
240 - common_startup_64+0x13e/0x158
241 - </TASK>
242 - nvme0n1: Write(0x1) @ LBA 0, 1 blocks, Invalid Command Opcode (sct 0x0 / sc 0x1) DNR
243 - operation not supported error, dev nvme0n1, sector 0 op 0x1:(WRITE) flags 0x8800 phys_seg 1 prio class 2
modified Documentation/netlink/specs/conntrack.yaml
@@ -360,17 +360,6 @@ attribute-sets:
360 360 name: tsoff
361 361 type: u32
362 362 byte-order: big-endian
363 - -
364 - name: filter-attrs
365 - attributes:
366 - -
367 - name: orig-flags
368 - type: u32
369 - doc: bitmask of tuple fields to filter on, original direction
370 - -
371 - name: reply-flags
372 - type: u32
373 - doc: bitmask of tuple fields to filter on, reply direction
374 363 -
375 364 name: conntrack-attrs
376 365 attributes:
@@ -477,7 +466,7 @@ attribute-sets:
477 466 -
478 467 name: filter
479 468 type: nest
480 - nested-attributes: filter-attrs
469 + nested-attributes: tuple-attrs
481 470 -
482 471 name: status-mask
483 472 type: u32
@@ -602,14 +591,10 @@ operations:
602 591 request:
603 592 value: 0x101
604 593 attributes:
605 - - tuple-orig
606 - - tuple-reply
607 - - status
608 594 - mark
609 - - zone
610 - - mark-mask
611 595 - filter
612 - - status-mask
596 + - status
597 + - zone
613 598 reply:
614 599 value: 0x100
615 600 attributes:
modified Documentation/scheduler/sched-ext.rst
@@ -230,7 +230,7 @@ optional. The following modified excerpt is from
230 230
231 231 void BPF_STRUCT_OPS(simple_exit, struct scx_exit_info *ei)
232 232 {
233 - exit_type = ei->kind;
233 + exit_type = ei->type;
234 234 }
235 235
236 236 SEC(".struct_ops")
@@ -242,21 +242,6 @@ optional. The following modified excerpt is from
242 242 .name = "simple",
243 243 };
244 244
245 - Scheduler-Dependent Knobs
246 - -------------------------
247 -
248 - The fair-class scheduler enforces CPU controller settings such as
249 - ``cpu.max``, ``cpu.weight`` and ``cpu.idle``. For sched_ext tasks, the
250 - scheduler core communicates these settings to the BPF scheduler
251 - through ``ops.cgroup_init()`` and reports subsequent changes through
252 - the corresponding ``ops.cgroup_set_*()`` callbacks. Similarly, per-task
253 - nice changes are converted to weights and reported through
254 - ``ops.set_weight()``.
255 -
256 - Each BPF scheduler is responsible for implementing the scheduling
257 - semantics of these settings and may choose to ignore them. Consult the
258 - loaded scheduler's documentation before relying on these controls.
259 -
260 245 Dispatch Queues
261 246 ---------------
262 247
modified Documentation/translations/zh_CN/core-api/irq/irq-domain.rst
@@ -90,6 +90,10 @@ irq_domain映射的类型
90 90 映射的优点是固定时间查找IRQ号,而且irq_descs只分配给在用的IRQ。 缺点是该表
91 91 必须尽可能大的hwirq号。
92 92
93 + irq_domain_add_linear()和irq_domain_create_linear()在功能上是等价的,
94 + 除了第一个参数不同--前者接受一个Open Firmware特定的 'struct device_node' 而
95 + 后者接受一个更通用的抽象 'struct fwnode_handle' 。
96 +
93 97 大多数驱动应该使用线性映射
94 98
95 99 树状映射
modified MAINTAINERS
@@ -5671,8 +5671,8 @@ W: http://bu3sch.de/btgpio.php
5671 5671 F: drivers/gpio/gpio-bt8xx.c
5672 5672
5673 5673 BTRFS FILE SYSTEM
5674 + M: Chris Mason <clm@fb.com>
5674 5675 M: David Sterba <dsterba@suse.com>
5675 - R: Chris Mason <mason@kernel.org>
5676 5676 L: linux-btrfs@vger.kernel.org
5677 5677 S: Maintained
5678 5678 W: https://btrfs.readthedocs.io
@@ -8039,7 +8039,7 @@ F: drivers/gpu/drm/sun4i/sun8i*
8039 8039
8040 8040 DRM DRIVER FOR APPLE TOUCH BARS
8041 8041 M: Aun-Ali Zaidi <admin@kodeit.net>
8042 - M: Aditya Garg <aditya.garg@linux.dev>
8042 + M: Aditya Garg <gargaditya08@proton.me>
8043 8043 L: dri-devel@lists.freedesktop.org
8044 8044 S: Maintained
8045 8045 T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
@@ -9387,8 +9387,9 @@ S: Maintained
9387 9387 F: drivers/edac/octeon_edac*
9388 9388
9389 9389 EDAC-CAVIUM THUNDERX
9390 + M: Robert Richter <rric@kernel.org>
9390 9391 L: linux-edac@vger.kernel.org
9391 - S: Orphan
9392 + S: Odd Fixes
9392 9393 F: drivers/edac/thunderx_edac*
9393 9394
9394 9395 EDAC-CORE
@@ -9415,8 +9416,9 @@ S: Supported
9415 9416 F: drivers/edac/dmc520_edac.c
9416 9417
9417 9418 EDAC-E752X
9419 + M: Mark Gross <markgross@kernel.org>
9418 9420 L: linux-edac@vger.kernel.org
9419 - S: Orphan
9421 + S: Maintained
9420 9422 F: drivers/edac/e752x_edac.c
9421 9423
9422 9424 EDAC-E7XXX
@@ -9491,8 +9493,9 @@ S: Maintained
9491 9493 F: drivers/edac/igen6_edac.c
9492 9494
9493 9495 EDAC-MPC85XX
9496 + M: Johannes Thumshirn <morbidrsa@gmail.com>
9494 9497 L: linux-edac@vger.kernel.org
9495 - S: Orphan
9498 + S: Maintained
9496 9499 F: drivers/edac/mpc85xx_edac.[ch]
9497 9500
9498 9501 EDAC-NPCM
@@ -10190,6 +10193,7 @@ F: include/linux/arm_ffa.h
10190 10193
10191 10194 FIRMWARE LOADER (request_firmware)
10192 10195 M: Luis Chamberlain <mcgrof@kernel.org>
10196 + M: Russ Weight <russ.weight@linux.dev>
10193 10197 M: Danilo Krummrich <dakr@kernel.org>
10194 10198 L: driver-core@lists.linux.dev
10195 10199 S: Maintained
@@ -12220,7 +12224,7 @@ F: drivers/tty/hvc/
12220 12224
12221 12225 HUNG TASK DETECTOR
12222 12226 M: Andrew Morton <akpm@linux-foundation.org>
12223 - M: Lance Yang <lance.yang@linux.dev>
12227 + R: Lance Yang <lance.yang@linux.dev>
12224 12228 R: Masami Hiramatsu <mhiramat@kernel.org>
12225 12229 R: Petr Mladek <pmladek@suse.com>
12226 12230 L: linux-kernel@vger.kernel.org
@@ -13279,6 +13283,7 @@ F: drivers/crypto/intel/keembay/ocs-aes.h
13279 13283
13280 13284 INTEL KEEM BAY OCS ECC CRYPTO DRIVER
13281 13285 M: Prabhjot Khurana <prabhjot.khurana@intel.com>
13286 + M: Mark Gross <mgross@linux.intel.com>
13282 13287 S: Maintained
13283 13288 F: Documentation/devicetree/bindings/crypto/intel,keembay-ocs-ecc.yaml
13284 13289 F: drivers/crypto/intel/keembay/Kconfig
@@ -14235,6 +14240,8 @@ F: tools/testing/selftests/
14235 14240 KERNEL SMB3 SERVER (KSMBD)
14236 14241 M: Namjae Jeon <linkinjeon@kernel.org>
14237 14242 M: Namjae Jeon <linkinjeon@samba.org>
14243 + M: Steve French <smfrench@gmail.com>
14244 + M: Steve French <sfrench@samba.org>
14238 14245 R: Sergey Senozhatsky <senozhatsky@chromium.org>
14239 14246 R: Tom Talpey <tom@talpey.com>
14240 14247 R: ChenXiaoSong <chenxiaosong@chenxiaosong.com>
@@ -17409,6 +17416,7 @@ F: mm/swapfile.c
17409 17416 MEMORY MANAGEMENT - THP (TRANSPARENT HUGE PAGE)
17410 17417 M: Andrew Morton <akpm@linux-foundation.org>
17411 17418 M: David Hildenbrand <david@kernel.org>
17419 + M: Lorenzo Stoakes <ljs@kernel.org>
17412 17420 R: Zi Yan <ziy@nvidia.com>
17413 17421 R: Baolin Wang <baolin.wang@linux.alibaba.com>
17414 17422 R: Liam R. Howlett <liam@infradead.org>
@@ -17418,7 +17426,6 @@ R: Dev Jain <dev.jain@arm.com>
17418 17426 R: Barry Song <baohua@kernel.org>
17419 17427 R: Lance Yang <lance.yang@linux.dev>
17420 17428 R: Usama Arif <usama.arif@linux.dev>
17421 - R: Kiryl Shutsemau <kas@kernel.org>
17422 17429 L: linux-mm@kvack.org
17423 17430 S: Maintained
17424 17431 W: http://www.linux-mm.org
@@ -17691,7 +17698,7 @@ F: Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml
17691 17698 F: drivers/spi/spi-at91-usart.c
17692 17699
17693 17700 MICROCHIP ATSHA204A DRIVER
17694 - M: Thorsten Blum <blum@kernel.org>
17701 + M: Thorsten Blum <thorsten.blum@linux.dev>
17695 17702 L: linux-crypto@vger.kernel.org
17696 17703 S: Maintained
17697 17704 F: drivers/crypto/atmel-sha204a.c
@@ -17715,7 +17722,7 @@ F: Documentation/devicetree/bindings/media/microchip,csi2dc.yaml
17715 17722 F: drivers/media/platform/microchip/microchip-csi2dc.c
17716 17723
17717 17724 MICROCHIP ECC DRIVER
17718 - M: Thorsten Blum <blum@kernel.org>
17725 + M: Thorsten Blum <thorsten.blum@linux.dev>
17719 17726 L: linux-crypto@vger.kernel.org
17720 17727 S: Maintained
17721 17728 F: drivers/crypto/atmel-ecc.c
@@ -19562,7 +19569,7 @@ F: include/linux/platform_data/x86/nvidia-wmi-ec-backlight.h
19562 19569
19563 19570 NVM EXPRESS DRIVER
19564 19571 M: Keith Busch <kbusch@kernel.org>
19565 - M: Jens Axboe <axboe@kernel.dk>
19572 + M: Jens Axboe <axboe@fb.com>
19566 19573 M: Christoph Hellwig <hch@lst.de>
19567 19574 M: Sagi Grimberg <sagi@grimberg.me>
19568 19575 L: linux-nvme@lists.infradead.org
@@ -24771,7 +24778,7 @@ K: \bsecurity_[a-z_0-9]\+\b
24771 24778 SELINUX SECURITY MODULE
24772 24779 M: Paul Moore <paul@paul-moore.com>
24773 24780 M: Stephen Smalley <stephen.smalley.work@gmail.com>
24774 - R: Ondrej Mosnáček <omosnacek@gmail.com>
24781 + R: Ondrej Mosnacek <omosnace@redhat.com>
24775 24782 L: selinux@vger.kernel.org
24776 24783 S: Supported
24777 24784 W: https://github.com/SELinuxProject
@@ -25229,9 +25236,10 @@ F: Documentation/admin-guide/LSM/Smack.rst
25229 25236 F: security/smack/
25230 25237
25231 25238 SMBDIRECT (RDMA Stream Transport with Read/Write-Offload, MS-SMBD)
25239 + M: Steve French <smfrench@gmail.com>
25240 + M: Steve French <sfrench@samba.org>
25232 25241 M: Namjae Jeon <linkinjeon@kernel.org>
25233 25242 M: Namjae Jeon <linkinjeon@samba.org>
25234 - M: Paulo Alcantara <pc@manguebit.org>
25235 25243 R: Stefan Metzmacher <metze@samba.org>
25236 25244 R: Tom Talpey <tom@talpey.com>
25237 25245 L: linux-cifs@vger.kernel.org
@@ -25402,7 +25410,7 @@ F: drivers/md/md*
25402 25410 F: drivers/md/raid*
25403 25411 F: include/linux/raid/
25404 25412 F: include/uapi/linux/raid/
25405 - F: lib/raid/
25413 + F: lib/raid/raid6/
25406 25414
25407 25415 SOLIDRUN CLEARFOG SUPPORT
25408 25416 M: Russell King <linux@armlinux.org.uk>
@@ -26946,7 +26954,8 @@ S: Maintained
26946 26954 F: drivers/net/ethernet/tehuti/tn40*
26947 26955
26948 26956 TELECOM CLOCK DRIVER FOR MCPL0010
26949 - S: Orphan
26957 + M: Mark Gross <markgross@kernel.org>
26958 + S: Supported
26950 26959 F: drivers/char/tlclk.c
26951 26960
26952 26961 TEMPO SEMICONDUCTOR DRIVERS
@@ -29928,14 +29937,12 @@ F: include/uapi/linux/xilinx-v4l2-controls.h
29928 29937 XILINX VERSAL EDAC DRIVER
29929 29938 M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
29930 29939 M: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
29931 - R: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
29932 29940 S: Maintained
29933 29941 F: Documentation/devicetree/bindings/memory-controllers/xlnx,versal-ddrmc-edac.yaml
29934 29942 F: drivers/edac/versal_edac.c
29935 29943
29936 29944 XILINX VERSALNET EDAC DRIVER
29937 29945 M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
29938 - R: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
29939 29946 S: Maintained
29940 29947 F: Documentation/devicetree/bindings/memory-controllers/xlnx,versal-net-ddrmc5.yaml
29941 29948 F: drivers/edac/versalnet_edac.c
@@ -29981,7 +29988,6 @@ F: include/dt-bindings/dma/xlnx-zynqmp-dpdma.h
29981 29988 XILINX ZYNQMP OCM EDAC DRIVER
29982 29989 M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
29983 29990 M: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
29984 - R: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
29985 29991 S: Maintained
29986 29992 F: Documentation/devicetree/bindings/memory-controllers/xlnx,zynqmp-ocmc-1.0.yaml
29987 29993 F: drivers/edac/zynqmp_edac.c
modified Makefile
@@ -2,7 +2,7 @@
2 2 VERSION = 7
3 3 PATCHLEVEL = 3
4 4 SUBLEVEL = 0
5 - EXTRAVERSION = -rc2
5 + EXTRAVERSION = -rc1
6 6 NAME = Baby Opossum Posse
7 7
8 8 # *DOCUMENTATION*
modified arch/arm64/crypto/aes-neonbs-glue.c
@@ -66,7 +66,7 @@ static int aesbs_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
66 66 struct crypto_aes_ctx *rk;
67 67 int err;
68 68
69 - rk = kmalloc_obj(*rk);
69 + rk = kmalloc(sizeof(*rk), GFP_KERNEL);
70 70 if (!rk)
71 71 return -ENOMEM;
72 72
@@ -128,7 +128,7 @@ static int aesbs_cbc_ctr_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
128 128 struct crypto_aes_ctx *rk;
129 129 int err;
130 130
131 - rk = kmalloc_obj(*rk);
131 + rk = kmalloc(sizeof(*rk), GFP_KERNEL);
132 132 if (!rk)
133 133 return -ENOMEM;
134 134
modified arch/arm64/include/asm/cpu.h
@@ -78,6 +78,5 @@ void __init cpuinfo_store_boot_cpu(void);
78 78 void __init init_cpu_features(struct cpuinfo_arm64 *info);
79 79 void update_cpu_features(int cpu, struct cpuinfo_arm64 *info,
80 80 struct cpuinfo_arm64 *boot);
81 - bool gmid_el1_accessible(const struct cpuinfo_arm64 *info);
82 81
83 82 #endif /* __ASM_CPU_H */
modified arch/arm64/include/asm/cpufeature.h
@@ -627,6 +627,13 @@ static inline bool id_aa64pfr1_mpamfrac(u64 pfr1)
627 627 return val > 0;
628 628 }
629 629
630 + static inline bool id_aa64pfr1_mte(u64 pfr1)
631 + {
632 + u32 val = cpuid_feature_extract_unsigned_field(pfr1, ID_AA64PFR1_EL1_MTE_SHIFT);
633 +
634 + return val >= ID_AA64PFR1_EL1_MTE_MTE2;
635 + }
636 +
630 637 void __init setup_boot_cpu_features(void);
631 638 void __init setup_system_features(void);
632 639 void __init setup_user_features(void);
modified arch/arm64/kernel/cpu_errata.c
@@ -82,7 +82,7 @@ is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope)
82 82
83 83 for (i = 0; i < target_impl_cpu_num; i++) {
84 84 if (__is_affected_midr_range(entry, target_impl_cpus[i].midr,
85 - target_impl_cpus[i].revidr))
85 + target_impl_cpus[i].midr))
86 86 return true;
87 87 }
88 88 return false;
modified arch/arm64/kernel/cpufeature.c
@@ -1178,33 +1178,6 @@ static bool detect_ftr_has_mpam(void)
1178 1178 return id_aa64pfr0_mpam(pfr0) || id_aa64pfr1_mpamfrac(pfr1);
1179 1179 }
1180 1180
1181 - bool gmid_el1_accessible(const struct cpuinfo_arm64 *info)
1182 - {
1183 - const struct arm64_ftr_bits *ftrp;
1184 - s64 mte, ovr;
1185 - u64 ftr_mask;
1186 -
1187 - /* No ID register reflects CONFIG_ARM64_MTE. */
1188 - if (!IS_ENABLED(CONFIG_ARM64_MTE))
1189 - return false;
1190 -
1191 - for (ftrp = ftr_id_aa64pfr1; ftrp->width; ftrp++) {
1192 - if (ftrp->shift == ID_AA64PFR1_EL1_MTE_SHIFT)
1193 - break;
1194 - }
1195 -
1196 - ftr_mask = arm64_ftr_mask(ftrp);
1197 - mte = arm64_ftr_value(ftrp, info->reg_id_aa64pfr1);
1198 -
1199 - /* The boot CPU runs before init_cpu_ftr_reg() strips unsafe overrides. */
1200 - if ((id_aa64pfr1_override.mask & ftr_mask) == ftr_mask) {
1201 - ovr = arm64_ftr_value(ftrp, id_aa64pfr1_override.val);
1202 - mte = arm64_ftr_safe_value(ftrp, ovr, mte);
1203 - }
1204 -
1205 - return mte >= ID_AA64PFR1_EL1_MTE_MTE2;
1206 - }
1207 -
1208 1181 void __init init_cpu_features(struct cpuinfo_arm64 *info)
1209 1182 {
1210 1183 /* Before we start using the tables, make sure it is sorted */
@@ -1257,7 +1230,7 @@ void __init init_cpu_features(struct cpuinfo_arm64 *info)
1257 1230 init_cpu_ftr_reg(SYS_MPAMIDR_EL1, info->reg_mpamidr);
1258 1231 }
1259 1232
1260 - if (gmid_el1_accessible(info))
1233 + if (id_aa64pfr1_mte(info->reg_id_aa64pfr1))
1261 1234 init_cpu_ftr_reg(SYS_GMID_EL1, info->reg_gmid);
1262 1235 }
1263 1236
@@ -1519,9 +1492,11 @@ void update_cpu_features(int cpu,
1519 1492 * they read/write depends on the GMID_EL1.BS field. Check that the
1520 1493 * value is the same on all CPUs.
1521 1494 */
1522 - if (gmid_el1_accessible(info))
1495 + if (IS_ENABLED(CONFIG_ARM64_MTE) &&
1496 + id_aa64pfr1_mte(info->reg_id_aa64pfr1)) {
1523 1497 taint |= check_update_ftr_reg(SYS_GMID_EL1, cpu,
1524 1498 info->reg_gmid, boot->reg_gmid);
1499 + }
1525 1500
1526 1501 /*
1527 1502 * If we don't have AArch32 at all then skip the checks entirely
modified arch/arm64/kernel/cpuinfo.c
@@ -502,7 +502,7 @@ static void __cpuinfo_store_cpu(struct cpuinfo_arm64 *info)
502 502 info->reg_id_aa64smfr0 = read_cpuid(ID_AA64SMFR0_EL1);
503 503 info->reg_id_aa64fpfr0 = read_cpuid(ID_AA64FPFR0_EL1);
504 504
505 - if (gmid_el1_accessible(info))
505 + if (id_aa64pfr1_mte(info->reg_id_aa64pfr1))
506 506 info->reg_gmid = read_cpuid(GMID_EL1);
507 507
508 508 if (id_aa64pfr0_32bit_el0(info->reg_id_aa64pfr0))
modified arch/arm64/kernel/machine_kexec.c
@@ -129,8 +129,7 @@ int machine_kexec_post_load(struct kimage *kimage)
129 129 }
130 130
131 131 /* Create a copy of the linear map */
132 - rc = trans_pgd_create_copy(&info, &trans_pgd,
133 - _PAGE_OFFSET(vabits_actual), PAGE_END);
132 + rc = trans_pgd_create_copy(&info, &trans_pgd, PAGE_OFFSET, PAGE_END);
134 133 if (rc)
135 134 return rc;
136 135 kimage->arch.ttbr1 = __pa(trans_pgd);
modified arch/arm64/kvm/nested.c
@@ -93,7 +93,7 @@ int kvm_vcpu_init_nested(struct kvm_vcpu *vcpu)
93 93 num_mmus = atomic_read(&kvm->online_vcpus) * S2_MMU_PER_VCPU;
94 94
95 95 if (num_mmus > kvm->arch.nested_mmus_size) {
96 - tmp = kvzalloc_objs(*tmp, num_mmus, GFP_KERNEL_ACCOUNT);
96 + tmp = kvcalloc(num_mmus, sizeof(*tmp), GFP_KERNEL_ACCOUNT);
97 97 if (!tmp)
98 98 return -ENOMEM;
99 99
modified arch/arm64/mm/fault.c
@@ -16,7 +16,6 @@
16 16 #include <linux/mm.h>
17 17 #include <linux/hardirq.h>
18 18 #include <linux/init.h>
19 - #include <linux/irqflags.h>
20 19 #include <linux/kasan.h>
21 20 #include <linux/kprobes.h>
22 21 #include <linux/uaccess.h>
@@ -155,9 +154,6 @@ static void show_pte(unsigned long addr)
155 154 pr_alert("%s pgtable: %luk pages, %llu-bit VAs, pgdp=%016lx\n",
156 155 mm == &init_mm ? "swapper" : "user", PAGE_SIZE / SZ_1K,
157 156 vabits_actual, mm_to_pgd_phys(mm));
158 -
159 - guard(irqsave)();
160 -
161 157 pgdp = pgd_offset(mm, addr);
162 158 pgd = READ_ONCE(*pgdp);
163 159 pr_alert("[%016lx] pgd=%016llx", addr, pgd_val(pgd));
@@ -171,25 +167,25 @@ static void show_pte(unsigned long addr)
171 167 if (pgd_none(pgd) || pgd_bad(pgd))
172 168 break;
173 169
174 - p4dp = p4d_offset_lockless(pgdp, pgd, addr);
170 + p4dp = p4d_offset(pgdp, addr);
175 171 p4d = READ_ONCE(*p4dp);
176 172 pr_cont(", p4d=%016llx", p4d_val(p4d));
177 173 if (p4d_none(p4d) || p4d_bad(p4d))
178 174 break;
179 175
180 - pudp = pud_offset_lockless(p4dp, p4d, addr);
176 + pudp = pud_offset(p4dp, addr);
181 177 pud = READ_ONCE(*pudp);
182 178 pr_cont(", pud=%016llx", pud_val(pud));
183 179 if (pud_none(pud) || pud_bad(pud))
184 180 break;
185 181
186 - pmdp = pmd_offset_lockless(pudp, pud, addr);
182 + pmdp = pmd_offset(pudp, addr);
187 183 pmd = READ_ONCE(*pmdp);
188 184 pr_cont(", pmd=%016llx", pmd_val(pmd));
189 185 if (pmd_none(pmd) || pmd_bad(pmd))
190 186 break;
191 187
192 - ptep = pte_offset_map(&pmd, addr);
188 + ptep = pte_offset_map(pmdp, addr);
193 189 if (!ptep)
194 190 break;
195 191
modified arch/loongarch/Kconfig
@@ -175,7 +175,7 @@ config LOONGARCH
175 175 select HAVE_RELIABLE_STACKTRACE if UNWINDER_ORC
176 176 select HAVE_RETHOOK
177 177 select HAVE_RSEQ
178 - select HAVE_RUST if !KASAN
178 + select HAVE_RUST
179 179 select HAVE_SAMPLE_FTRACE_DIRECT
180 180 select HAVE_SAMPLE_FTRACE_DIRECT_MULTI
181 181 select HAVE_SETUP_PER_CPU_AREA if NUMA
modified arch/loongarch/include/asm/kvm_dmsintc.h
@@ -20,7 +20,6 @@ struct dmsintc_state {
20 20 };
21 21
22 22 int kvm_loongarch_register_dmsintc_device(void);
23 - void kvm_loongarch_unregister_dmsintc_device(void);
24 23 void dmsintc_inject_irq(struct kvm_vcpu *vcpu);
25 24 int dmsintc_set_irq(struct kvm *kvm, u64 addr, int data, int level);
26 25 int dmsintc_deliver_msi_to_vcpu(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 vector, int level);
modified arch/loongarch/include/asm/kvm_eiointc.h
@@ -79,7 +79,6 @@ struct loongarch_eiointc {
79 79 };
80 80
81 81 int kvm_loongarch_register_eiointc_device(void);
82 - void kvm_loongarch_unregister_eiointc_device(void);
83 82 void eiointc_set_irq(struct loongarch_eiointc *s, int irq, int level);
84 83
85 84 #endif /* __ASM_KVM_EIOINTC_H */
modified arch/loongarch/include/asm/kvm_host.h
@@ -125,7 +125,6 @@ struct kvm_arch {
125 125 unsigned int pte_shifts[MAX_PGTABLE_LEVELS];
126 126 unsigned int root_level;
127 127 spinlock_t phyid_map_lock;
128 - spinlock_t pv_setting_lock;
129 128 struct kvm_phyid_map *phyid_map;
130 129 /* Enabled PV features */
131 130 unsigned long pv_features;
@@ -351,6 +350,7 @@ static inline void kvm_arch_vcpu_block_finish(struct kvm_vcpu *vcpu) {}
351 350 static inline void kvm_arch_free_memslot(struct kvm *kvm, struct kvm_memory_slot *slot) {}
352 351 void kvm_check_vpid(struct kvm_vcpu *vcpu);
353 352 enum hrtimer_restart kvm_swtimer_wakeup(struct hrtimer *timer);
353 + void kvm_arch_flush_remote_tlbs_memslot(struct kvm *kvm, const struct kvm_memory_slot *memslot);
354 354 void kvm_init_vmcs(struct kvm *kvm);
355 355 void kvm_exc_entry(void);
356 356 int kvm_enter_guest(struct kvm_run *run, struct kvm_vcpu *vcpu);
modified arch/loongarch/include/asm/kvm_ipi.h
@@ -41,6 +41,5 @@ struct ipi_state {
41 41 #define IOCSR_ANY_SEND 0x158
42 42
43 43 int kvm_loongarch_register_ipi_device(void);
44 - void kvm_loongarch_unregister_ipi_device(void);
45 44
46 45 #endif
modified arch/loongarch/include/asm/kvm_pch_pic.h
@@ -70,7 +70,6 @@ struct loongarch_pch_pic {
70 70
71 71 struct kvm_kernel_irq_routing_entry;
72 72 int kvm_loongarch_register_pch_pic_device(void);
73 - void kvm_loongarch_unregister_pch_pic_device(void);
74 73 void pch_pic_set_irq(struct loongarch_pch_pic *s, int irq, int level);
75 74 int pch_msi_set_irq(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e, int level);
76 75
modified arch/loongarch/kernel/kprobes.c
@@ -275,9 +275,6 @@ bool kprobe_singlestep_handler(struct pt_regs *regs)
275 275 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
276 276 unsigned long addr = instruction_pointer(regs);
277 277
278 - if (!cur)
279 - return false;
280 -
281 278 if (cur && (kcb->kprobe_status & (KPROBE_HIT_SS | KPROBE_REENTER)) &&
282 279 ((unsigned long)&cur->ainsn.insn[1] == addr)) {
283 280 restore_local_irqflag(kcb, regs);
modified arch/loongarch/kernel/rethook_trampoline.S
@@ -24,6 +24,7 @@
24 24 cfi_st t6, PT_R18
25 25 cfi_st t7, PT_R19
26 26 cfi_st t8, PT_R20
27 + cfi_st u0, PT_R21
27 28 cfi_st fp, PT_R22
28 29 cfi_st s0, PT_R23
29 30 cfi_st s1, PT_R24
@@ -58,6 +59,7 @@
58 59 cfi_ld t6, PT_R18
59 60 cfi_ld t7, PT_R19
60 61 cfi_ld t8, PT_R20
62 + cfi_ld u0, PT_R21
61 63 cfi_ld fp, PT_R22
62 64 cfi_ld s0, PT_R23
63 65 cfi_ld s1, PT_R24
modified arch/loongarch/kernel/smp.c
@@ -14,6 +14,7 @@
14 14 #include <linux/init.h>
15 15 #include <linux/interrupt.h>
16 16 #include <linux/irq_work.h>
17 + #include <linux/profile.h>
17 18 #include <linux/seq_file.h>
18 19 #include <linux/smp.h>
19 20 #include <linux/threads.h>
@@ -715,6 +716,13 @@ void smp_send_stop(void)
715 716 smp_call_function(stop_this_cpu, NULL, 0);
716 717 }
717 718
719 + #ifdef CONFIG_PROFILING
720 + int setup_profiling_timer(unsigned int multiplier)
721 + {
722 + return 0;
723 + }
724 + #endif
725 +
718 726 static void flush_tlb_all_ipi(void *info)
719 727 {
720 728 local_flush_tlb_all();
modified arch/loongarch/kernel/vmlinux.lds.S
@@ -23,7 +23,7 @@
23 23 #include "image-vars.h"
24 24
25 25 /*
26 - * Max available Page Size is 64K, so we set SectionAlignment
26 + * Max avaliable Page Size is 64K, so we set SectionAlignment
27 27 * field of EFI application to 64K.
28 28 */
29 29 PECOFF_FILE_ALIGN = 0x200;
modified arch/loongarch/kvm/intc/dmsintc.c
@@ -149,7 +149,7 @@ static int kvm_dmsintc_create(struct kvm_device *dev, u32 type)
149 149 return -EINVAL;
150 150 }
151 151
152 - s = kzalloc_obj(struct loongarch_dmsintc);
152 + s = kzalloc(sizeof(struct loongarch_dmsintc), GFP_KERNEL);
153 153 if (!s)
154 154 return -ENOMEM;
155 155
@@ -180,8 +180,3 @@ int kvm_loongarch_register_dmsintc_device(void)
180 180 {
181 181 return kvm_register_device_ops(&kvm_dmsintc_dev_ops, KVM_DEV_TYPE_LOONGARCH_DMSINTC);
182 182 }
183 -
184 - void kvm_loongarch_unregister_dmsintc_device(void)
185 - {
186 - kvm_unregister_device_ops(KVM_DEV_TYPE_LOONGARCH_DMSINTC);
187 - }
modified arch/loongarch/kvm/intc/eiointc.c
@@ -695,8 +695,3 @@ int kvm_loongarch_register_eiointc_device(void)
695 695 {
696 696 return kvm_register_device_ops(&kvm_eiointc_dev_ops, KVM_DEV_TYPE_LOONGARCH_EIOINTC);
697 697 }
698 -
699 - void kvm_loongarch_unregister_eiointc_device(void)
700 - {
701 - kvm_unregister_device_ops(KVM_DEV_TYPE_LOONGARCH_EIOINTC);
702 - }
modified arch/loongarch/kvm/intc/ipi.c
@@ -463,8 +463,3 @@ int kvm_loongarch_register_ipi_device(void)
463 463 {
464 464 return kvm_register_device_ops(&kvm_ipi_dev_ops, KVM_DEV_TYPE_LOONGARCH_IPI);
465 465 }
466 -
467 - void kvm_loongarch_unregister_ipi_device(void)
468 - {
469 - kvm_unregister_device_ops(KVM_DEV_TYPE_LOONGARCH_IPI);
470 - }
modified arch/loongarch/kvm/intc/pch_pic.c
@@ -78,9 +78,6 @@ int pch_msi_set_irq(struct kvm *kvm, struct kvm_kernel_irq_routing_entry *e, int
78 78 return dmsintc_set_irq(kvm, msg_addr, e->msi.data, level);
79 79 }
80 80
81 - if (e->msi.data >= EIOINTC_IRQS)
82 - return -EINVAL;
83 -
84 81 eiointc_set_irq(kvm->arch.eiointc, e->msi.data, level);
85 82
86 83 return 0;
@@ -503,8 +500,3 @@ int kvm_loongarch_register_pch_pic_device(void)
503 500 {
504 501 return kvm_register_device_ops(&kvm_pch_pic_dev_ops, KVM_DEV_TYPE_LOONGARCH_PCHPIC);
505 502 }
506 -
507 - void kvm_loongarch_unregister_pch_pic_device(void)
508 - {
509 - kvm_unregister_device_ops(KVM_DEV_TYPE_LOONGARCH_PCHPIC);
510 - }
modified arch/loongarch/kvm/main.c
@@ -385,52 +385,27 @@ static int kvm_loongarch_env_init(void)
385 385 /* Register LoongArch IPI interrupt controller interface. */
386 386 ret = kvm_loongarch_register_ipi_device();
387 387 if (ret)
388 - goto err_env;
388 + return ret;
389 389
390 390 /* Register LoongArch EIOINTC interrupt controller interface. */
391 391 ret = kvm_loongarch_register_eiointc_device();
392 392 if (ret)
393 - goto err_ipi;
393 + return ret;
394 394
395 395 /* Register LoongArch PCH-PIC interrupt controller interface. */
396 396 ret = kvm_loongarch_register_pch_pic_device();
397 397 if (ret)
398 - goto err_eiointc;
398 + return ret;
399 399
400 400 /* Register LoongArch DMSINTC interrupt contrroller interface */
401 - if (cpu_has_msgint) {
401 + if (cpu_has_msgint)
402 402 ret = kvm_loongarch_register_dmsintc_device();
403 - if (ret)
404 - goto err_pch_pic;
405 - }
406 -
407 - return 0;
408 -
409 - err_pch_pic:
410 - kvm_loongarch_unregister_pch_pic_device();
411 - err_eiointc:
412 - kvm_loongarch_unregister_eiointc_device();
413 - err_ipi:
414 - kvm_loongarch_unregister_ipi_device();
415 - err_env:
416 - kvm_unregister_perf_callbacks();
417 - kfree(kvm_loongarch_ops);
418 - kvm_loongarch_ops = NULL;
419 - free_percpu(vmcs);
420 - vmcs = NULL;
421 403
422 404 return ret;
423 405 }
424 406
425 407 static void kvm_loongarch_env_exit(void)
426 408 {
427 - if (cpu_has_msgint)
428 - kvm_loongarch_unregister_dmsintc_device();
429 -
430 - kvm_loongarch_unregister_pch_pic_device();
431 - kvm_loongarch_unregister_eiointc_device();
432 - kvm_loongarch_unregister_ipi_device();
433 -
434 409 if (vmcs)
435 410 free_percpu(vmcs);
436 411
@@ -453,11 +428,7 @@ static int kvm_loongarch_init(void)
453 428 if (r)
454 429 return r;
455 430
456 - r = kvm_init(sizeof(struct kvm_vcpu), 0, THIS_MODULE);
457 - if (r)
458 - kvm_loongarch_env_exit();
459 -
460 - return r;
431 + return kvm_init(sizeof(struct kvm_vcpu), 0, THIS_MODULE);
461 432 }
462 433
463 434 static void kvm_loongarch_exit(void)
modified arch/loongarch/kvm/mmu.c
@@ -383,16 +383,6 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, const struct kvm_memory_slot
383 383 hva_t hva_start;
384 384 size_t size, gpa_offset, hva_offset;
385 385
386 - /*
387 - * The generic code allocates a fresh, zeroed memslot for every change,
388 - * so the arch flags computed below must be carried over when only the
389 - * userspace flags change, e.g. when dirty logging is toggled.
390 - */
391 - if (change == KVM_MR_FLAGS_ONLY) {
392 - new->arch = old->arch;
393 - return 0;
394 - }
395 -
396 386 if ((change != KVM_MR_MOVE) && (change != KVM_MR_CREATE))
397 387 return 0;
398 388 /*
@@ -949,3 +939,9 @@ int kvm_handle_mm_fault(struct kvm_vcpu *vcpu, unsigned long gpa, bool write, in
949 939 void kvm_arch_sync_dirty_log(struct kvm *kvm, struct kvm_memory_slot *memslot)
950 940 {
951 941 }
942 +
943 + void kvm_arch_flush_remote_tlbs_memslot(struct kvm *kvm,
944 + const struct kvm_memory_slot *memslot)
945 + {
946 + kvm_flush_remote_tlbs(kvm);
947 + }
modified arch/loongarch/kvm/vcpu.c
@@ -1165,14 +1165,10 @@ static int kvm_loongarch_cpucfg_set_attr(struct kvm_vcpu *vcpu,
1165 1165 return -EINVAL;
1166 1166
1167 1167 /* All vCPUs need set the same PV features */
1168 - spin_lock(&kvm->arch.pv_setting_lock);
1169 1168 if ((kvm->arch.pv_features & LOONGARCH_PV_FEAT_UPDATED)
1170 - && ((kvm->arch.pv_features & valid) != val)) {
1171 - spin_unlock(&kvm->arch.pv_setting_lock);
1169 + && ((kvm->arch.pv_features & valid) != val))
1172 1170 return -EINVAL;
1173 - }
1174 1171 kvm->arch.pv_features = val | LOONGARCH_PV_FEAT_UPDATED;
1175 - spin_unlock(&kvm->arch.pv_setting_lock);
1176 1172 return 0;
1177 1173 default:
1178 1174 return -ENXIO;
modified arch/loongarch/kvm/vm.c
@@ -76,7 +76,6 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
76 76 return -ENOMEM;
77 77 }
78 78 spin_lock_init(&kvm->arch.phyid_map_lock);
79 - spin_lock_init(&kvm->arch.pv_setting_lock);
80 79
81 80 kvm_init_vmcs(kvm);
82 81 kvm_vm_init_features(kvm);
modified arch/loongarch/net/bpf_jit.c
@@ -717,7 +717,7 @@ static int build_insn(const struct bpf_insn *insn, struct jit_ctx *ctx, bool ext
717 717 move_reg(ctx, t1, src);
718 718 emit_zext_32(ctx, t1, true);
719 719 move_imm(ctx, dst, (ctx->user_vm_start >> 32) << 32, false);
720 - emit_insn(ctx, beq, t1, LOONGARCH_GPR_ZERO, 2);
720 + emit_insn(ctx, beq, t1, LOONGARCH_GPR_ZERO, 1);
721 721 emit_insn(ctx, or, t1, dst, t1);
722 722 move_reg(ctx, dst, t1);
723 723 break;
modified arch/mips/bcm47xx/buttons.c
@@ -523,24 +523,24 @@ bcm47xx_buttons_add(const struct bcm47xx_gpio_key *buttons, int nbuttons)
523 523
524 524 /* 1 node for gpio-keys device, 1 node for each button, 1 terminator */
525 525 const struct software_node **node_group __free(kfree) =
526 - kzalloc_objs(*node_group, 1 + nbuttons + 1);
526 + kcalloc(1 + nbuttons + 1, sizeof(*node_group), GFP_KERNEL);
527 527 if (!node_group)
528 528 return -ENOMEM;
529 529
530 530 /* 1 code property, 1 gpio property, 1 terminator */
531 531 struct property_entry *props __free(kfree) =
532 - kzalloc_objs(*props, nbuttons * 3);
532 + kcalloc(nbuttons * 3, sizeof(*props), GFP_KERNEL);
533 533 if (!props)
534 534 return -ENOMEM;
535 535
536 536 /* 1 node for gpio-keys device, 1 node for each button */
537 537 struct software_node *nodes __free(kfree) =
538 - kzalloc_objs(*nodes, 1 + nbuttons);
538 + kcalloc(1 + nbuttons, sizeof(*nodes), GFP_KERNEL);
539 539 if (!nodes)
540 540 return -ENOMEM;
541 541
542 542 struct software_node_ref_args *ref_args __free(kfree) =
543 - kzalloc_objs(*ref_args, nbuttons);
543 + kcalloc(nbuttons, sizeof(*ref_args), GFP_KERNEL);
544 544 if (!ref_args)
545 545 return -ENOMEM;
546 546
modified arch/powerpc/sysdev/xive/common.c
@@ -1134,7 +1134,7 @@ static int __init xive_init_ipis(void)
1134 1134 if (!ipi_domain)
1135 1135 goto out_free_fwnode;
1136 1136
1137 - xive_ipis = kzalloc_objs(*xive_ipis, nr_node_ids);
1137 + xive_ipis = kzalloc_objs(*xive_ipis, nr_node_ids, GFP_KERNEL);
1138 1138 if (!xive_ipis)
1139 1139 goto out_free_domain;
1140 1140
modified arch/riscv/kvm/vcpu_pmu.c
@@ -503,8 +503,8 @@ int kvm_riscv_vcpu_pmu_event_info(struct kvm_vcpu *vcpu, unsigned long saddr_low
503 503 }
504 504 }
505 505
506 - einfo = kvzalloc_objs(*einfo, num_events,
507 - GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
506 + einfo = kvcalloc(num_events, sizeof(*einfo),
507 + GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
508 508 if (!einfo) {
509 509 ret = SBI_ERR_FAILURE;
510 510 goto out;
modified arch/riscv/net/bpf_jit_comp64.c
@@ -2128,15 +2128,7 @@ bool bpf_jit_supports_ptr_xchg(void)
2128 2128
2129 2129 bool bpf_jit_supports_arena(void)
2130 2130 {
2131 - /*
2132 - * The arena range tree uses kmalloc_nolock(), which needs
2133 - * cmpxchg128, provided by ZACAS on riscv.
2134 - */
2135 - #ifdef system_has_cmpxchg128
2136 - return system_has_cmpxchg128();
2137 - #else
2138 - return false;
2139 - #endif
2131 + return true;
2140 2132 }
2141 2133
2142 2134 bool bpf_jit_supports_insn(struct bpf_insn *insn, bool in_arena)
modified arch/s390/boot/alternative.c
@@ -45,12 +45,11 @@ static void alt_debug_modify(int type, unsigned int nr, bool clear)
45 45
46 46 static char *alt_debug_parse(int type, char *str)
47 47 {
48 - unsigned long val, endval, limit;
48 + unsigned long val, endval;
49 49 char *endp;
50 50 bool clear;
51 51 int i;
52 52
53 - limit = type == ALT_TYPE_FACILITY ? MAX_FACILITY_BIT : MAX_MFEATURE_BIT;
54 53 if (*str == ':') {
55 54 str++;
56 55 } else {
@@ -74,7 +73,7 @@ static char *alt_debug_parse(int type, char *str)
74 73 if (str == endp)
75 74 break;
76 75 str = endp;
77 - while (val <= endval && val < limit) {
76 + while (val <= endval) {
78 77 alt_debug_modify(type, val, clear);
79 78 val++;
80 79 }
modified arch/s390/boot/ipl_parm.c
@@ -23,7 +23,6 @@ struct parmarea parmarea __section(".parmarea") = {
23 23 };
24 24
25 25 char __bootdata(early_command_line)[COMMAND_LINE_SIZE];
26 - static char command_line_buf[COMMAND_LINE_SIZE];
27 26
28 27 unsigned int __bootdata_preserved(zlib_dfltcc_support) = ZLIB_DFLTCC_FULL;
29 28 struct ipl_parameter_block __bootdata_preserved(ipl_block);
@@ -136,29 +135,31 @@ out:
136 135
137 136 static void append_ipl_block_parm(void)
138 137 {
139 - size_t len, extra = 0;
140 - char *delim;
138 + char *parm, *delim;
139 + size_t len, rc = 0;
141 140
142 141 len = strlen(early_command_line);
143 - delim = early_command_line + len; /* '\0' character position */
142 +
143 + delim = early_command_line + len; /* '\0' character position */
144 + parm = early_command_line + len + 1; /* append right after '\0' */
144 145
145 146 switch (ipl_block.pb0_hdr.pbt) {
146 147 case IPL_PBT_CCW:
147 - extra = ipl_block_get_ascii_vmparm(command_line_buf, sizeof(command_line_buf), &ipl_block);
148 + rc = ipl_block_get_ascii_vmparm(
149 + parm, COMMAND_LINE_SIZE - len - 1, &ipl_block);
148 150 break;
149 151 case IPL_PBT_FCP:
150 152 case IPL_PBT_NVME:
151 153 case IPL_PBT_ECKD:
152 - extra = ipl_block_get_ascii_scpdata(command_line_buf, sizeof(command_line_buf), &ipl_block);
154 + rc = ipl_block_get_ascii_scpdata(
155 + parm, COMMAND_LINE_SIZE - len - 1, &ipl_block);
153 156 break;
154 157 }
155 - if (extra) {
156 - if (command_line_buf[0] == '=') {
157 - memmove(early_command_line, command_line_buf + 1, extra);
158 - } else if (len < COMMAND_LINE_SIZE - 2) {
158 + if (rc) {
159 + if (*parm == '=')
160 + memmove(early_command_line, parm + 1, rc);
161 + else
159 162 *delim = ' '; /* replace '\0' with space */
160 - sized_strscpy(delim + 1, command_line_buf, COMMAND_LINE_SIZE - len - 1);
161 - }
162 163 }
163 164 }
164 165
@@ -230,7 +231,7 @@ static void modify_fac_list(char *str)
230 231 if (str == endp)
231 232 break;
232 233 str = endp;
233 - while (val <= endval && val < MAX_FACILITY_BIT) {
234 + while (val <= endval) {
234 235 modify_facility(val, clear);
235 236 val++;
236 237 }
@@ -244,6 +245,7 @@ static void modify_fac_list(char *str)
244 245 check_cleared_facilities();
245 246 }
246 247
248 + static char command_line_buf[COMMAND_LINE_SIZE];
247 249 void parse_boot_command_line(void)
248 250 {
249 251 char *param, *val;
modified arch/s390/boot/physmem_info.c
@@ -141,7 +141,7 @@ static int tprot(unsigned long addr)
141 141
142 142 static unsigned long search_mem_end(void)
143 143 {
144 - unsigned long range = 1UL << (MAX_PHYSMEM_BITS - 20); /* in 1MB blocks */
144 + unsigned long range = 1 << (MAX_PHYSMEM_BITS - 20); /* in 1MB blocks */
145 145 unsigned long offset = 0;
146 146 unsigned long pivot;
147 147
modified arch/s390/include/asm/cpacf.h
@@ -301,7 +301,6 @@ static __always_inline void __cpacf_query(unsigned int opcode,
301 301 cpacf_mask_t *mask)
302 302 {
303 303 __cpacf_query_insn(opcode, mask, CPACF_FC_QUERY);
304 - kmsan_unpoison_memory(mask, sizeof(*mask));
305 304 }
306 305
307 306 static __always_inline int __cpacf_check_opcode(unsigned int opcode)
@@ -371,7 +370,6 @@ static __always_inline int cpacf_query_func(unsigned int opcode,
371 370 static __always_inline void __cpacf_qai(unsigned int opcode, cpacf_qai_t *qai)
372 371 {
373 372 __cpacf_query_insn(opcode, qai, CPACF_FC_QUERY_AUTH_INFO);
374 - kmsan_unpoison_memory(qai, sizeof(*qai));
375 373 }
376 374
377 375 /**
@@ -424,7 +422,6 @@ static inline int cpacf_km(unsigned long func, void *param,
424 422 [opc] "i" (CPACF_KM)
425 423 : "cc", "memory", "0", "1");
426 424
427 - kmsan_unpoison_memory(dest, src_len - s.odd);
428 425 return src_len - s.odd;
429 426 }
430 427
@@ -457,7 +454,6 @@ static inline int cpacf_kmc(unsigned long func, void *param,
457 454 [opc] "i" (CPACF_KMC)
458 455 : "cc", "memory", "0", "1");
459 456
460 - kmsan_unpoison_memory(dest, src_len - s.odd);
461 457 return src_len - s.odd;
462 458 }
463 459
@@ -591,7 +587,6 @@ static inline int cpacf_kmctr(unsigned long func, void *param, u8 *dest,
591 587 [opc] "i" (CPACF_KMCTR)
592 588 : "cc", "memory", "0", "1");
593 589
594 - kmsan_unpoison_memory(dest, src_len - s.odd);
595 590 return src_len - s.odd;
596 591 }
597 592
@@ -624,7 +619,6 @@ static inline void cpacf_prno(unsigned long func, void *param,
624 619 : [fc] "d" (func), [pba] "d" ((unsigned long)param),
625 620 [seed] "d" (s.pair), [opc] "i" (CPACF_PRNO)
626 621 : "cc", "memory", "0", "1");
627 - kmsan_unpoison_memory(dest, dest_len);
628 622 }
629 623
630 624 /**
modified arch/s390/include/asm/processor.h
@@ -46,6 +46,7 @@ struct pcpu {
46 46 unsigned long ec_mask; /* bit mask for ec_xxx functions */
47 47 unsigned long ec_clk; /* sigp timestamp for ec_xxx */
48 48 unsigned long flags; /* per CPU flags */
49 + unsigned long capacity; /* cpu capacity for scheduler */
49 50 signed char state; /* physical cpu state */
50 51 signed char polarization; /* physical polarization */
51 52 u16 address; /* physical cpu address */
modified arch/s390/include/asm/smp.h
@@ -30,7 +30,7 @@ static __always_inline unsigned int raw_smp_processor_id(void)
30 30 return cpu;
31 31 }
32 32
33 - #define arch_scale_cpu_capacity topology_get_cpu_scale
33 + #define arch_scale_cpu_capacity smp_cpu_get_capacity
34 34
35 35 extern struct mutex smp_cpu_state_mutex;
36 36 extern unsigned int smp_cpu_mt_shift;
@@ -53,7 +53,9 @@ extern void smp_save_dump_secondary_cpus(void);
53 53 extern void smp_yield_cpu(int cpu);
54 54 extern void smp_cpu_set_polarization(int cpu, int val);
55 55 extern int smp_cpu_get_polarization(int cpu);
56 + extern void smp_cpu_set_capacity(int cpu, unsigned long val);
56 57 extern void smp_set_core_capacity(int cpu, unsigned long val);
58 + extern unsigned long smp_cpu_get_capacity(int cpu);
57 59 extern int smp_cpu_get_cpu_address(int cpu);
58 60 extern void smp_fill_possible_mask(void);
59 61 extern void smp_detect_cpus(void);
modified arch/s390/kernel/diag/diag324.c
@@ -182,7 +182,8 @@ long diag324_pibbuf(unsigned long arg)
182 182 goto out;
183 183 rc = copy_to_user((void __user *)address, data->pib, data->pib->len);
184 184 rc |= put_user(data->sequence, &udata->sequence);
185 - rc = rc ? -EFAULT : data->rc;
185 + if (rc)
186 + rc = -EFAULT;
186 187 out:
187 188 mutex_unlock(&pibmutex);
188 189 return rc;
modified arch/s390/kernel/ipl.c
@@ -1157,8 +1157,6 @@ static struct attribute_group reipl_nss_attr_group = {
1157 1157
1158 1158 void set_os_info_reipl_block(void)
1159 1159 {
1160 - if (!reipl_block_actual)
1161 - return;
1162 1160 os_info_entry_add_data(OS_INFO_REIPL_BLOCK, reipl_block_actual,
1163 1161 reipl_block_actual->hdr.len);
1164 1162 }
@@ -1929,8 +1927,7 @@ static struct shutdown_action __refdata dump_action = {
1929 1927 static void dump_reipl_run(struct shutdown_trigger *trigger)
1930 1928 {
1931 1929 struct lowcore *abs_lc;
1932 - unsigned long ipib = 0;
1933 - unsigned int csum = 0;
1930 + unsigned int csum;
1934 1931
1935 1932 /*
1936 1933 * Set REIPL_CLEAR flag in os_info flags entry indicating
@@ -1946,12 +1943,9 @@ static void dump_reipl_run(struct shutdown_trigger *trigger)
1946 1943 reipl_type == IPL_TYPE_UNKNOWN)
1947 1944 os_info_flags |= OS_INFO_FLAG_REIPL_CLEAR;
1948 1945 os_info_entry_add_data(OS_INFO_FLAGS_ENTRY, &os_info_flags, sizeof(os_info_flags));
1949 - if (reipl_block_actual) {
1950 - ipib = __pa(reipl_block_actual);
1951 - csum = (__force unsigned int)cksm(reipl_block_actual, reipl_block_actual->hdr.len, 0);
1952 - }
1946 + csum = (__force unsigned int)cksm(reipl_block_actual, reipl_block_actual->hdr.len, 0);
1953 1947 abs_lc = get_abs_lowcore();
1954 - abs_lc->ipib = ipib;
1948 + abs_lc->ipib = __pa(reipl_block_actual);
1955 1949 abs_lc->ipib_checksum = csum;
1956 1950 put_abs_lowcore(abs_lc);
1957 1951 dump_run(trigger);
modified arch/s390/kernel/perf_pai.c
@@ -464,7 +464,6 @@ static void pai_start(struct perf_event *event, int flags,
464 464 cpump->event = event;
465 465 }
466 466 }
467 - event->hw.state &= ~PERF_HES_STOPPED;
468 467 }
469 468
470 469 static void paicrypt_start(struct perf_event *event, int flags)
@@ -511,13 +510,6 @@ static void pai_stop(struct perf_event *event, int flags)
511 510 struct pai_mapptr *mp = this_cpu_ptr(pai_root[idx].mapptr);
512 511 struct pai_map *cpump = mp->mapptr;
513 512
514 - /* Cope with multiple invocations:
515 - * 1. perf_event_throttle() --> PMU->stop()
516 - * 2. task schedules out --> PMU->stop()
517 - * Check for event already stopped.
518 - */
519 - if (event->hw.state & PERF_HES_STOPPED)
520 - return;
521 513 if (!event->attr.sample_period) { /* Counting */
522 514 pai_pmu[idx].pmu->read(event);
523 515 } else { /* Sampling */
@@ -680,9 +672,9 @@ static void pai_have_samples(int idx)
680 672 {
681 673 struct pai_mapptr *mp = this_cpu_ptr(pai_root[idx].mapptr);
682 674 struct pai_map *cpump = mp->mapptr;
683 - struct perf_event *event, *e2;
675 + struct perf_event *event;
684 676
685 - list_for_each_entry_safe(event, e2, &cpump->syswide_list, hw.tp_list)
677 + list_for_each_entry(event, &cpump->syswide_list, hw.tp_list)
686 678 pai_have_sample(event, cpump);
687 679 }
688 680
@@ -699,17 +691,6 @@ static void paicrypt_sched_task(struct perf_event_pmu_context *pmu_ctx,
699 691 pai_have_samples(PAI_PMU_CRYPTO);
700 692 }
701 693
702 - /* Prevent ioctl(fd, PERF_EVENT_IOC_PERIOD, ...) call.
703 - * It sets perf_event::event_limit to a positive value and causes
704 - * perf_event_overflow() to invoke pai_stop() call back function when
705 - * perf_event::event_limit hits zero. This is not supported because the
706 - * sample events CRYPTO_ALL and NNPA_ALL are always taken at schedule out
707 - * of a task.
708 - */
709 - static int pai_check_period(struct perf_event *event, u64 value)
710 - {
711 - return -EINVAL;
712 - }
713 694 /* ============================= paiext ====================================*/
714 695
715 696 static void paiext_event_destroy(struct perf_event *event)
@@ -823,7 +804,6 @@ static struct pmu paicrypt = {
823 804 .stop = paicrypt_stop,
824 805 .read = paicrypt_read,
825 806 .sched_task = paicrypt_sched_task,
826 - .check_period = pai_check_period,
827 807 .attr_groups = paicrypt_attr_groups
828 808 };
829 809
@@ -1035,7 +1015,6 @@ static struct pmu paiext = {
1035 1015 .stop = paiext_stop,
1036 1016 .read = paiext_read,
1037 1017 .sched_task = paiext_sched_task,
1038 - .check_period = pai_check_period,
1039 1018 .attr_groups = paiext_attr_groups,
1040 1019 };
1041 1020
@@ -1242,7 +1221,7 @@ static int __init paipmu_setup(void)
1242 1221 static int __init pai_init(void)
1243 1222 {
1244 1223 /* Setup s390dbf facility */
1245 - paidbg = debug_register("pai", 1, 1, 128);
1224 + paidbg = debug_register("pai", 32, 256, 128);
1246 1225 if (!paidbg) {
1247 1226 pr_err("Registration of s390dbf pai failed\n");
1248 1227 return -ENOMEM;
modified arch/s390/kernel/smp.c
@@ -659,13 +659,23 @@ int smp_cpu_get_polarization(int cpu)
659 659 return per_cpu(pcpu_devices, cpu).polarization;
660 660 }
661 661
662 + void smp_cpu_set_capacity(int cpu, unsigned long val)
663 + {
664 + per_cpu(pcpu_devices, cpu).capacity = val;
665 + }
666 +
667 + unsigned long smp_cpu_get_capacity(int cpu)
668 + {
669 + return per_cpu(pcpu_devices, cpu).capacity;
670 + }
671 +
662 672 void smp_set_core_capacity(int cpu, unsigned long val)
663 673 {
664 674 int i;
665 675
666 676 cpu = smp_get_base_cpu(cpu);
667 677 for (i = cpu; (i <= cpu + smp_cpu_mtid) && (i < nr_cpu_ids); i++)
668 - topology_set_cpu_scale(i, val);
678 + smp_cpu_set_capacity(i, val);
669 679 }
670 680
671 681 int smp_cpu_get_cpu_address(int cpu)
@@ -717,7 +727,7 @@ static int smp_add_core(struct sclp_core_entry *core, cpumask_t *avail,
717 727 else
718 728 pcpu->state = CPU_STATE_STANDBY;
719 729 smp_cpu_set_polarization(cpu, POLARIZATION_UNKNOWN);
720 - topology_set_cpu_scale(cpu, CPU_CAPACITY_HIGH);
730 + smp_cpu_set_capacity(cpu, CPU_CAPACITY_HIGH);
721 731 set_cpu_present(cpu, true);
722 732 if (!early && arch_register_cpu(cpu))
723 733 set_cpu_present(cpu, false);
@@ -957,7 +967,7 @@ void __init smp_prepare_boot_cpu(void)
957 967 ipl_pcpu->state = CPU_STATE_CONFIGURED;
958 968 lc->pcpu = (unsigned long)ipl_pcpu;
959 969 smp_cpu_set_polarization(0, POLARIZATION_UNKNOWN);
960 - topology_set_cpu_scale(0, CPU_CAPACITY_HIGH);
970 + smp_cpu_set_capacity(0, CPU_CAPACITY_HIGH);
961 971 }
962 972
963 973 void __init smp_setup_processor_id(void)
modified arch/s390/kernel/topology.c
@@ -147,7 +147,7 @@ static void add_cpus_to_mask(struct topology_core *tl_core,
147 147 cpumask_set_cpu(cpu, &book->mask);
148 148 cpumask_set_cpu(cpu, &socket->mask);
149 149 smp_cpu_set_polarization(cpu, tl_core->pp);
150 - topology_set_cpu_scale(cpu, CPU_CAPACITY_HIGH);
150 + smp_cpu_set_capacity(cpu, CPU_CAPACITY_HIGH);
151 151 }
152 152 }
153 153 }
modified arch/s390/kernel/vtime.c
@@ -32,7 +32,7 @@ static atomic64_t virt_timer_elapsed;
32 32 DEFINE_PER_CPU(u64, mt_cycles[8]);
33 33 static DEFINE_PER_CPU(u64, mt_scaling_mult) = { 1 };
34 34 static DEFINE_PER_CPU(u64, mt_scaling_div) = { 1 };
35 - static DEFINE_PER_CPU(unsigned long, mt_scaling_jiffies);
35 + static DEFINE_PER_CPU(u64, mt_scaling_jiffies);
36 36
37 37 static inline void set_vtimer(u64 expires)
38 38 {
@@ -81,7 +81,7 @@ static void update_mt_scaling(void)
81 81 memcpy(cycles_old, cycles_new,
82 82 sizeof(u64) * (smp_cpu_mtid + 1));
83 83 }
84 - __this_cpu_write(mt_scaling_jiffies, jiffies);
84 + __this_cpu_write(mt_scaling_jiffies, jiffies_64);
85 85 }
86 86
87 87 static inline u64 update_tsk_timer(unsigned long *tsk_vtime, u64 new)
@@ -144,7 +144,7 @@ static int do_account_vtime(struct task_struct *tsk)
144 144 lc->system_timer += timer;
145 145
146 146 /* Update MT utilization calculation */
147 - if (smp_cpu_mtid && time_after(jiffies, __this_cpu_read(mt_scaling_jiffies)))
147 + if (smp_cpu_mtid && time_after64(jiffies_64, __this_cpu_read(mt_scaling_jiffies)))
148 148 update_mt_scaling();
149 149
150 150 /* Calculate cputime delta */
modified arch/s390/kvm/s390/s390.c
@@ -2168,7 +2168,7 @@ static int kvm_s390_get_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
2168 2168 if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX)
2169 2169 return -EINVAL;
2170 2170
2171 - keys = kvmalloc_objs(*keys, args->count, GFP_KERNEL_ACCOUNT);
2171 + keys = kvmalloc_array(args->count, sizeof(*keys), GFP_KERNEL_ACCOUNT);
2172 2172 if (!keys)
2173 2173 return -ENOMEM;
2174 2174
@@ -2205,7 +2205,7 @@ static int kvm_s390_set_skeys(struct kvm *kvm, struct kvm_s390_skeys *args)
2205 2205 if (args->count < 1 || args->count > KVM_S390_SKEYS_MAX)
2206 2206 return -EINVAL;
2207 2207
2208 - keys = kvmalloc_objs(*keys, args->count, GFP_KERNEL_ACCOUNT);
2208 + keys = kvmalloc_array(args->count, sizeof(*keys), GFP_KERNEL_ACCOUNT);
2209 2209 if (!keys)
2210 2210 return -ENOMEM;
2211 2211
modified arch/s390/mm/pgalloc.c
@@ -55,46 +55,63 @@ static void __crst_table_upgrade(void *arg)
55 55
56 56 int crst_table_upgrade(struct mm_struct *mm, unsigned long end)
57 57 {
58 - unsigned long *table, *pgd;
59 - int rc, notify;
58 + unsigned long *pgd = NULL, *p4d = NULL, *__pgd;
59 + unsigned long asce_limit = mm->context.asce_limit;
60 60
61 61 mmap_assert_write_locked(mm);
62 +
62 63 /* upgrade should only happen from 3 to 4, 3 to 5, or 4 to 5 levels */
63 - VM_BUG_ON(mm->context.asce_limit < _REGION2_SIZE);
64 - rc = 0;
65 - notify = 0;
66 - while (mm->context.asce_limit < end) {
67 - table = crst_table_alloc(mm);
68 - if (!table) {
69 - rc = -ENOMEM;
70 - break;
71 - }
72 - spin_lock_bh(&mm->page_table_lock);
73 - pgd = (unsigned long *)mm->pgd;
74 - if (mm->context.asce_limit == _REGION2_SIZE) {
75 - crst_table_init(table, _REGION2_ENTRY_EMPTY);
76 - p4d_populate(mm, (p4d_t *)table, (pud_t *)pgd);
77 - pagetable_p4d_ctor(virt_to_ptdesc(table));
78 - mm->pgd = (pgd_t *)table;
79 - mm->context.asce_limit = _REGION1_SIZE;
80 - mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH |
81 - _ASCE_USER_BITS | _ASCE_TYPE_REGION2;
82 - mm_inc_nr_puds(mm);
83 - } else {
84 - crst_table_init(table, _REGION1_ENTRY_EMPTY);
85 - pgd_populate(mm, (pgd_t *)table, (p4d_t *)pgd);
86 - pagetable_pgd_ctor(virt_to_ptdesc(table));
87 - mm->pgd = (pgd_t *)table;
88 - mm->context.asce_limit = TASK_SIZE_MAX;
89 - mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH |
90 - _ASCE_USER_BITS | _ASCE_TYPE_REGION1;
91 - }
92 - notify = 1;
93 - spin_unlock_bh(&mm->page_table_lock);
64 + VM_BUG_ON(asce_limit < _REGION2_SIZE);
65 +
66 + if (end <= asce_limit)
67 + return 0;
68 +
69 + if (asce_limit == _REGION2_SIZE) {
70 + p4d = crst_table_alloc(mm);
71 + if (unlikely(!p4d))
72 + goto err_p4d;
73 + crst_table_init(p4d, _REGION2_ENTRY_EMPTY);
74 + pagetable_p4d_ctor(virt_to_ptdesc(p4d));
75 + }
76 + if (end > _REGION1_SIZE) {
77 + pgd = crst_table_alloc(mm);
78 + if (unlikely(!pgd))
79 + goto err_pgd;
80 + crst_table_init(pgd, _REGION1_ENTRY_EMPTY);
81 + pagetable_pgd_ctor(virt_to_ptdesc(pgd));
82 + }
83 +
84 + spin_lock_bh(&mm->page_table_lock);
85 +
86 + if (p4d) {
87 + __pgd = (unsigned long *) mm->pgd;
88 + p4d_populate(mm, (p4d_t *) p4d, (pud_t *) __pgd);
89 + mm->pgd = (pgd_t *) p4d;
90 + mm->context.asce_limit = _REGION1_SIZE;
91 + mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH |
92 + _ASCE_USER_BITS | _ASCE_TYPE_REGION2;
93 + mm_inc_nr_puds(mm);
94 94 }
95 - if (notify)
96 - on_each_cpu(__crst_table_upgrade, mm, 0);
97 - return rc;
95 + if (pgd) {
96 + __pgd = (unsigned long *) mm->pgd;
97 + pgd_populate(mm, (pgd_t *) pgd, (p4d_t *) __pgd);
98 + mm->pgd = (pgd_t *) pgd;
99 + mm->context.asce_limit = TASK_SIZE_MAX;
100 + mm->context.asce = __pa(mm->pgd) | _ASCE_TABLE_LENGTH |
101 + _ASCE_USER_BITS | _ASCE_TYPE_REGION1;
102 + }
103 +
104 + spin_unlock_bh(&mm->page_table_lock);
105 +
106 + on_each_cpu(__crst_table_upgrade, mm, 0);
107 +
108 + return 0;
109 +
110 + err_pgd:
111 + pagetable_dtor(virt_to_ptdesc(p4d));
112 + crst_table_free(mm, p4d);
113 + err_p4d:
114 + return -ENOMEM;
98 115 }
99 116
100 117 unsigned long *page_table_alloc_noprof(struct mm_struct *mm)
modified arch/s390/pci/pci_sysfs.c
@@ -153,9 +153,6 @@ static ssize_t report_error_write(struct file *filp, struct kobject *kobj,
153 153 if (off || (count < sizeof(*report)))
154 154 return -EINVAL;
155 155
156 - if (count < (report->length + sizeof(*report)))
157 - return -EINVAL;
158 -
159 156 ret = sclp_pci_report(report, zdev->fh, zdev->fid);
160 157
161 158 return ret ? ret : count;
modified arch/x86/kernel/itmt.c
@@ -110,14 +110,18 @@ int sched_set_itmt_support(void)
110 110 arch_debugfs_dir,
111 111 &sysctl_sched_itmt_enabled,
112 112 &dfs_sched_itmt_fops);
113 - if (IS_ERR(dfs_sched_itmt))
113 + if (IS_ERR_OR_NULL(dfs_sched_itmt)) {
114 114 dfs_sched_itmt = NULL;
115 + return -ENOMEM;
116 + }
115 117
116 118 dfs_sched_core_prio = debugfs_create_file("sched_core_priority", 0644,
117 119 arch_debugfs_dir, NULL,
118 120 &sched_core_priority_fops);
119 - if (IS_ERR(dfs_sched_core_prio))
121 + if (IS_ERR_OR_NULL(dfs_sched_core_prio)) {
120 122 dfs_sched_core_prio = NULL;
123 + return -ENOMEM;
124 + }
121 125
122 126 sched_itmt_capable = true;
123 127
modified arch/x86/net/bpf_jit_comp.c
@@ -13,7 +13,6 @@
13 13 #include <linux/bpf_verifier.h>
14 14 #include <linux/memory.h>
15 15 #include <linux/sort.h>
16 - #include <linux/execmem.h>
17 16 #include <asm/extable.h>
18 17 #include <asm/ftrace.h>
19 18 #include <asm/set_memory.h>
@@ -3819,16 +3818,15 @@ int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags,
3819 3818 *
3820 3819 * We cannot use kvmalloc here, because we need image to be in
3821 3820 * module memory range.
3822 - * Since it must be writable use execmem_alloc(EXECMEM_MODULE_DATA)
3823 - * that returns writable memory in the module address space.
3821 + * Since it must be writable use bpf_jit_alloc_exec_rw().
3824 3822 */
3825 - image = execmem_alloc(EXECMEM_MODULE_DATA, PAGE_SIZE);
3823 + image = bpf_jit_alloc_exec_rw(PAGE_SIZE);
3826 3824 if (!image)
3827 3825 return -ENOMEM;
3828 3826
3829 3827 ret = __arch_prepare_bpf_trampoline(&im, image, image + PAGE_SIZE, image,
3830 3828 m, flags, tnodes, func_addr);
3831 - execmem_free(image);
3829 + bpf_jit_free_exec(image);
3832 3830 return ret;
3833 3831 }
3834 3832
modified block/bio.c
@@ -859,7 +859,6 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)
859 859 bio->bi_ioprio = bio_src->bi_ioprio;
860 860 bio->bi_write_hint = bio_src->bi_write_hint;
861 861 bio->bi_write_stream = bio_src->bi_write_stream;
862 - bio->bi_bvec_gap_bit = bio_src->bi_bvec_gap_bit;
863 862 bio->bi_iter = bio_src->bi_iter;
864 863 bio->bi_io_vec = bio_src->bi_io_vec;
865 864
@@ -1973,14 +1972,6 @@ struct bio *bio_split(struct bio *bio, int sectors,
1973 1972
1974 1973 bio_advance(bio, split->bi_iter.bi_size);
1975 1974
1976 - /*
1977 - * The gap bit is set when splitting to limits and only applies to the
1978 - * front bio that was split off. The remaining bio will calcualte its
1979 - * gap value when it is subsequently split to limits, so it is safe to
1980 - * re-initialize the value back to 0.
1981 - */
1982 - bio->bi_bvec_gap_bit = 0;
1983 -
1984 1975 if (bio_flagged(bio, BIO_TRACE_COMPLETION))
1985 1976 bio_set_flag(split, BIO_TRACE_COMPLETION);
1986 1977
modified block/blk-zoned.c
@@ -2018,12 +2018,17 @@ static int disk_revalidate_zone_resources(struct gendisk *disk,
2018 2018 struct blk_revalidate_zone_args *args)
2019 2019 {
2020 2020 struct queue_limits *lim = &disk->queue->limits;
2021 + unsigned long long nr_zones;
2021 2022 unsigned int pool_size;
2022 2023 int ret = 0;
2023 2024
2024 2025 args->disk = disk;
2025 - args->nr_zones =
2026 - DIV_ROUND_UP_ULL(get_capacity(disk), lim->chunk_sectors);
2026 + nr_zones = DIV_ROUND_UP_ULL(get_capacity(disk), lim->chunk_sectors);
2027 + if (nr_zones > UINT_MAX) {
2028 + pr_warn("%s: Too many zones (%llu)\n", disk->disk_name, nr_zones);
2029 + return -EINVAL;
2030 + }
2031 + args->nr_zones = nr_zones;
2027 2032
2028 2033 /* Cached zone conditions: 1 byte per zone */
2029 2034 args->zones_cond = kzalloc(args->nr_zones, GFP_NOIO);
@@ -2131,6 +2136,12 @@ static int blk_revalidate_zone_cond(struct blk_zone *zone, unsigned int idx,
2131 2136 {
2132 2137 enum blk_zone_cond cond = zone->cond;
2133 2138
2139 + if (idx >= args->nr_zones) {
2140 + pr_warn("%s: Zone report index %u exceeds zone count %u\n",
2141 + args->disk->disk_name, idx, args->nr_zones);
2142 + return -EINVAL;
2143 + }
2144 +
2134 2145 /* Check that the zone condition is consistent with the zone type. */
2135 2146 switch (cond) {
2136 2147 case BLK_ZONE_COND_NOT_WP:
modified block/genhd.c
@@ -447,13 +447,6 @@ static int __add_disk(struct device *parent, struct gendisk *disk,
447 447 bdev_set_flag(disk->part0, BD_HAS_SUBMIT_BIO);
448 448 }
449 449
450 - /*
451 - * We do not support partitions with zoned block devices, so do not try
452 - * to scan the partitions table.
453 - */
454 - if (blk_queue_is_zoned(disk->queue))
455 - disk->flags |= GENHD_FL_NO_PART;
456 -
457 450 /*
458 451 * If the driver provides an explicit major number it also must provide
459 452 * the number of minors numbers supported, and those will be used to
modified drivers/accel/amdxdna/aie2_message.c
@@ -994,7 +994,7 @@ int aie2_cmdlist_multi_execbuf(struct amdxdna_hwctx *hwctx,
994 994 }
995 995
996 996 ccnt = payload->command_count;
997 - if (!ccnt || payload_len < struct_size(payload, data, ccnt)) {
997 + if (payload_len < struct_size(payload, data, ccnt)) {
998 998 XDNA_DBG(xdna, "Invalid command count %d", ccnt);
999 999 return -EINVAL;
1000 1000 }
modified drivers/accel/amdxdna/amdxdna_ctx.c
@@ -183,10 +183,8 @@ int amdxdna_cmd_set_error(struct amdxdna_gem_obj *abo,
183 183 if (!abo)
184 184 return -EINVAL;
185 185 cmd = amdxdna_gem_vmap(abo);
186 - if (!cmd) {
187 - amdxdna_gem_put_obj(abo);
186 + if (!cmd)
188 187 return -ENOMEM;
189 - }
190 188 }
191 189
192 190 memset(cmd->data, 0xff, abo->mem.size - sizeof(*cmd));
modified drivers/accel/amdxdna/amdxdna_ctx.h
@@ -55,7 +55,7 @@ struct amdxdna_cmd_chain {
55 55 u32 submit_index;
56 56 u32 error_index;
57 57 u32 reserved[3];
58 - u64 data[];
58 + u64 data[] __counted_by(command_count);
59 59 };
60 60
61 61 /*
modified drivers/accel/amdxdna/amdxdna_gem.c
@@ -1246,9 +1246,6 @@ static int amdxdna_flush_bo(struct amdxdna_gem_obj *abo, u64 offset, u64 size)
1246 1246 {
1247 1247 u64 end;
1248 1248
1249 - if (is_import_bo(abo))
1250 - return -EOPNOTSUPP;
1251 -
1252 1249 if (offset >= abo->mem.size)
1253 1250 return -EINVAL;
1254 1251
@@ -1256,10 +1253,9 @@ static int amdxdna_flush_bo(struct amdxdna_gem_obj *abo, u64 offset, u64 size)
1256 1253 return -EINVAL;
1257 1254
1258 1255 size = min(abo->mem.size, end) - offset;
1259 - if (!size)
1260 - return 0;
1261 -
1262 - if (amdxdna_gem_vmap(abo))
1256 + if (is_import_bo(abo))
1257 + drm_clflush_sg(abo->base.sgt);
1258 + else if (amdxdna_gem_vmap(abo))
1263 1259 drm_clflush_virt_range(amdxdna_gem_vmap(abo) + offset, size);
1264 1260 else if (abo->base.pages)
1265 1261 drm_clflush_pages(abo->base.pages, abo->mem.size >> PAGE_SHIFT);
modified drivers/accel/ethosu/ethosu_drv.c
@@ -356,8 +356,6 @@ static int ethosu_probe(struct platform_device *pdev)
356 356 dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(40));
357 357
358 358 ethosudev->regs = devm_platform_ioremap_resource(pdev, 0);
359 - if (IS_ERR(ethosudev->regs))
360 - return PTR_ERR(ethosudev->regs);
361 359 ethosudev->pmu_regs = ethosudev->regs;
362 360
363 361 ethosudev->num_clks = devm_clk_bulk_get_all(&pdev->dev, &ethosudev->clks);
modified drivers/accel/ethosu/ethosu_gem.c
@@ -204,7 +204,7 @@ static u64 feat_matrix_length(struct ethosu_device *edev,
204 204 struct feat_matrix *fm,
205 205 u32 x, u32 y, u32 c, bool ofm)
206 206 {
207 - u32 element_size, storage = ethosu_is_u65(edev) ? 0 : fm->precision >> 14;
207 + u32 element_size, storage = fm->precision >> 14;
208 208 int tile = 0;
209 209 u64 addr;
210 210
modified drivers/accel/ethosu/ethosu_job.c
@@ -154,13 +154,6 @@ static void ethosu_job_err_cleanup(struct ethosu_job *job)
154 154
155 155 drm_gem_object_put(job->cmd_bo);
156 156
157 - if (job->done_fence) {
158 - if (dma_fence_was_initialized(job->done_fence))
159 - dma_fence_put(job->done_fence);
160 - else
161 - dma_fence_free(job->done_fence);
162 - }
163 -
164 157 kfree(job);
165 158 }
166 159
@@ -171,6 +164,7 @@ static void ethosu_job_cleanup(struct kref *ref)
171 164
172 165 pm_runtime_put_autosuspend(job->dev->base.dev);
173 166
167 + dma_fence_put(job->done_fence);
174 168 dma_fence_put(job->inference_done_fence);
175 169
176 170 ethosu_job_err_cleanup(job);
@@ -421,7 +415,7 @@ static int ethosu_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
421 415 ejob->done_fence = kzalloc_obj(*ejob->done_fence);
422 416 if (!ejob->done_fence) {
423 417 ret = -ENOMEM;
424 - goto out_put_job;
418 + goto out_cleanup_job;
425 419 }
426 420
427 421 ret = drm_sched_job_init(&ejob->base,
modified drivers/accel/qaic/qaic_control.c
@@ -963,13 +963,11 @@ static int decode_status(struct qaic_device *qdev, void *trans, struct manage_ms
963 963
964 964 static int decode_message(struct qaic_device *qdev, struct manage_msg *user_msg,
965 965 struct wire_msg *msg, struct ioctl_resources *resources,
966 - struct qaic_user *usr, bool orphaned_deactivate)
966 + struct qaic_user *usr)
967 967 {
968 - u32 msg_hdr_count = le32_to_cpu(msg->hdr.count);
969 968 u32 msg_hdr_len = le32_to_cpu(msg->hdr.len);
970 969 struct wire_trans_hdr *trans_hdr;
971 970 u32 msg_len = 0;
972 - int trans_type;
973 971 int ret;
974 972 int i;
975 973
@@ -977,12 +975,10 @@ static int decode_message(struct qaic_device *qdev, struct manage_msg *user_msg,
977 975 msg_hdr_len > QAIC_MANAGE_MAX_MSG_LENGTH)
978 976 return -EINVAL;
979 977
980 - if (user_msg) {
981 - user_msg->len = 0;
982 - user_msg->count = msg_hdr_count;
983 - }
978 + user_msg->len = 0;
979 + user_msg->count = le32_to_cpu(msg->hdr.count);
984 980
985 - for (i = 0; i < msg_hdr_count; ++i) {
981 + for (i = 0; i < user_msg->count; ++i) {
986 982 u32 hdr_len;
987 983
988 984 if (msg_len > msg_hdr_len - sizeof(*trans_hdr))
@@ -994,20 +990,7 @@ static int decode_message(struct qaic_device *qdev, struct manage_msg *user_msg,
994 990 size_add(msg_len, hdr_len) > msg_hdr_len)
995 991 return -EINVAL;
996 992
997 - trans_type = le32_to_cpu(trans_hdr->type);
998 - /*
999 - * orphaned_deactivate is the case where a deactivate response
1000 - * is received from the device after the user owning the DBC,
1001 - * and the message requesting deactivation, has gone away.
1002 - * In this case, only process QAIC_TRANS_DEACTIVATE_FROM_DEV
1003 - * transaction and skip the others.
1004 - */
1005 - if (orphaned_deactivate && trans_type != QAIC_TRANS_DEACTIVATE_FROM_DEV) {
1006 - msg_len += hdr_len;
1007 - continue;
1008 - }
1009 -
1010 - switch (trans_type) {
993 + switch (le32_to_cpu(trans_hdr->type)) {
1011 994 case QAIC_TRANS_PASSTHROUGH_FROM_DEV:
1012 995 ret = decode_passthrough(qdev, trans_hdr, user_msg, &msg_len);
1013 996 break;
@@ -1298,7 +1281,7 @@ dma_xfer_continue:
1298 1281 goto dma_cont_failed;
1299 1282 }
1300 1283
1301 - ret = decode_message(qdev, user_msg, rsp, &resources, usr, false);
1284 + ret = decode_message(qdev, user_msg, rsp, &resources, usr);
1302 1285
1303 1286 dma_cont_failed:
1304 1287 free_dbc_buf(qdev, &resources);
@@ -1463,7 +1446,22 @@ static void resp_worker(struct work_struct *work)
1463 1446 * response to the QAIC_TRANS_TERMINATE_TO_DEV transaction,
1464 1447 * otherwise, the user can issue an soc_reset to the device.
1465 1448 */
1466 - decode_message(qdev, NULL, msg, NULL, NULL, true);
1449 + u32 msg_count = le32_to_cpu(msg->hdr.count);
1450 + u32 msg_len = le32_to_cpu(msg->hdr.len);
1451 + u32 len = 0;
1452 + int j;
1453 +
1454 + for (j = 0; j < msg_count && len < msg_len; ++j) {
1455 + struct wire_trans_hdr *trans_hdr;
1456 +
1457 + trans_hdr = (struct wire_trans_hdr *)(msg->data + len);
1458 + if (le32_to_cpu(trans_hdr->type) == QAIC_TRANS_DEACTIVATE_FROM_DEV) {
1459 + if (decode_deactivate(qdev, trans_hdr, &len, NULL))
1460 + len += le32_to_cpu(trans_hdr->len);
1461 + } else {
1462 + len += le32_to_cpu(trans_hdr->len);
1463 + }
1464 + }
1467 1465 /* request must have timed out, drop packet */
1468 1466 kfree(msg);
1469 1467 }
modified drivers/accel/rocket/rocket_job.c
@@ -196,7 +196,7 @@ static int rocket_job_push(struct rocket_job *job)
196 196 if (check_add_overflow(job->in_bo_count, job->out_bo_count, &bo_count))
197 197 return -EINVAL;
198 198
199 - bos = kvmalloc_objs(*bos, bo_count);
199 + bos = kvmalloc_array(bo_count, sizeof(*bos), GFP_KERNEL);
200 200 if (!bos)
201 201 return -ENOMEM;
202 202 memcpy(bos, job->in_bos, job->in_bo_count * sizeof(void *));
modified drivers/acpi/irq.c
@@ -486,8 +486,7 @@ static u32 acpi_add_prt_dep(acpi_handle handle)
486 486 if (ACPI_FAILURE(status))
487 487 continue;
488 488 dep_devices.count = 1;
489 - dep_devices.handles = kzalloc_objs(*dep_devices.handles,
490 - 1);
489 + dep_devices.handles = kcalloc(1, sizeof(*dep_devices.handles), GFP_KERNEL);
491 490 if (!dep_devices.handles) {
492 491 acpi_handle_err(handle, "failed to allocate memory\n");
493 492 continue;
@@ -500,8 +499,7 @@ static u32 acpi_add_prt_dep(acpi_handle handle)
500 499 if (!gsi_handle)
501 500 continue;
502 501 dep_devices.count = 1;
503 - dep_devices.handles = kzalloc_objs(*dep_devices.handles,
504 - 1);
502 + dep_devices.handles = kcalloc(1, sizeof(*dep_devices.handles), GFP_KERNEL);
505 503 if (!dep_devices.handles) {
506 504 acpi_handle_err(handle, "failed to allocate memory\n");
507 505 continue;
@@ -528,7 +526,7 @@ static u32 acpi_add_irq_dep(acpi_handle handle)
528 526 continue;
529 527
530 528 dep_devices.count = 1;
531 - dep_devices.handles = kzalloc_objs(*dep_devices.handles, 1);
529 + dep_devices.handles = kcalloc(1, sizeof(*dep_devices.handles), GFP_KERNEL);
532 530 if (!dep_devices.handles) {
533 531 acpi_handle_err(handle, "failed to allocate memory\n");
534 532 continue;
modified drivers/acpi/scan.c
@@ -28,7 +28,9 @@
28 28 #include "internal.h"
29 29 #include "sleep.h"
30 30
31 + #define ACPI_BUS_CLASS "system_bus"
31 32 #define ACPI_BUS_HID "LNXSYBUS"
33 + #define ACPI_BUS_DEVICE_NAME "System Bus"
32 34
33 35 #define INVALID_ACPI_HANDLE ((acpi_handle)ZERO_PAGE(0))
34 36
@@ -1448,6 +1450,8 @@ static void acpi_set_pnp_ids(acpi_handle handle, struct acpi_device_pnp *pnp,
1448 1450 acpi_object_is_system_bus(handle)) {
1449 1451 /* \_SB, \_TZ, LNXSYBUS */
1450 1452 acpi_add_id(pnp, ACPI_BUS_HID);
1453 + strscpy(pnp->device_name, ACPI_BUS_DEVICE_NAME);
1454 + strscpy(pnp->device_class, ACPI_BUS_CLASS);
1451 1455 }
1452 1456
1453 1457 break;
modified drivers/ata/ahci.c
@@ -2614,51 +2614,6 @@ static irqreturn_t ahci_thunderx_irq_handler(int irq, void *dev_instance)
2614 2614 }
2615 2615 #endif
2616 2616
2617 - /*
2618 - * The Marvell 88SE6111/6121/6145 ("Thor") family stops reporting interrupts
2619 - * for a port when HOST_IRQ_STAT is cleared while PxIS still holds bits: PxIS
2620 - * keeps its content, HOST_IRQ_STAT reads back as 0, the port is never looked
2621 - * at again and the command in flight only ends in a timeout. On a 88SE6121
2622 - * this makes every SATA-2 or SATA-3 disk fail to IDENTIFY, while SATA-1 disks
2623 - * happen to win the race often enough to work.
2624 - *
2625 - * Clearing the host status before servicing the ports avoids it. Marvell's
2626 - * own driver for these chips does the same and says so ("clear global before
2627 - * channel"), and ahci_xgene handles its broken edge latch the same way. The
2628 - * price is at most one spurious interrupt per valid one, which is why this is
2629 - * not the generic behaviour - see AHCI 1.1 section 10.6.2.
2630 - *
2631 - * Link: https://bugzilla.kernel.org/show_bug.cgi?id=216094
2632 - */
2633 - static irqreturn_t ahci_mv_irq_handler(int irq, void *dev_instance)
2634 - {
2635 - struct ata_host *host = dev_instance;
2636 - struct ahci_host_priv *hpriv = host->private_data;
2637 - void __iomem *mmio = hpriv->mmio;
2638 - unsigned int rc;
2639 - u32 irq_stat, irq_masked;
2640 -
2641 - irq_stat = readl(mmio + HOST_IRQ_STAT);
2642 - if (!irq_stat)
2643 - return IRQ_NONE;
2644 -
2645 - irq_masked = irq_stat & hpriv->port_map;
2646 -
2647 - spin_lock(&host->lock);
2648 -
2649 - /*
2650 - * Use the unmasked value to clear the interrupt, as a spurious pending
2651 - * event on a dummy port might cause a screaming IRQ.
2652 - */
2653 - writel(irq_stat, mmio + HOST_IRQ_STAT);
2654 -
2655 - rc = ahci_handle_port_intr(host, irq_masked);
2656 -
2657 - spin_unlock(&host->lock);
2658 -
2659 - return IRQ_RETVAL(rc);
2660 - }
2661 -
2662 2617 static void ahci_remap_check(struct pci_dev *pdev, int bar,
2663 2618 struct ahci_host_priv *hpriv)
2664 2619 {
@@ -2962,10 +2917,6 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
2962 2917 return -ENOMEM;
2963 2918 hpriv->flags |= (unsigned long)pi.private_data;
2964 2919
2965 - /* the Marvell "Thor" family needs HOST_IRQ_STAT cleared first */
2966 - if (board_id == board_ahci_mv)
2967 - hpriv->irq_handler = ahci_mv_irq_handler;
2968 -
2969 2920 /* MCP65 revision A1 and A2 can't do MSI */
2970 2921 if (board_id == board_ahci_mcp65 &&
2971 2922 (pdev->revision == 0xa1 || pdev->revision == 0xa2))
modified drivers/ata/libata-scsi.c
@@ -4823,6 +4823,28 @@ ata_scsi_get_phys_element_status_xlat(struct ata_queued_cmd *qc)
4823 4823 return 0;
4824 4824 }
4825 4825
4826 + static void ata_scsi_depop_ua_cap_changed_complete(struct ata_queued_cmd *qc)
4827 + {
4828 + struct scsi_cmnd *scmd = qc->scsicmd;
4829 + u8 *cdb = scmd->cmnd;
4830 + bool is_ata_passthru = cdb[0] == ATA_16 || cdb[0] == ATA_12;
4831 + bool is_success = qc->err_mask == 0;
4832 +
4833 + /*
4834 + * For successful non-passthrough commands, raise a UNIT ATTENTION with
4835 + * the additional sense code set to CAPACITY DATA HAS CHANGED to be
4836 + * raised. Note that this should be done only if the capacity has
4837 + * actually changed, which may not be the case if the element that was
4838 + * specified for depopulation was already depopulated, or we did not
4839 + * restore any removed element. But a capacity change unit attention is
4840 + * harmless, so always raise the unit attention.
4841 + */
4842 + if (is_success && !is_ata_passthru)
4843 + ata_scsi_set_sense(qc->dev, scmd, UNIT_ATTENTION,
4844 + UA_CHANGED_ASC, CAPACITY_CHANGED_ASCQ);
4845 + ata_scsi_qc_complete(qc);
4846 + }
4847 +
4826 4848 static unsigned int
4827 4849 ata_scsi_remove_element_and_truncate_xlat(struct ata_queued_cmd *qc)
4828 4850 {
@@ -4862,6 +4884,7 @@ ata_scsi_remove_element_and_truncate_xlat(struct ata_queued_cmd *qc)
4862 4884 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48;
4863 4885
4864 4886 qc->flags |= ATA_QCFLAG_RESULT_TF;
4887 + qc->complete_fn = ata_scsi_depop_ua_cap_changed_complete;
4865 4888
4866 4889 return 0;
4867 4890 }
@@ -4914,6 +4937,7 @@ ata_scsi_restore_elements_and_rebuild_xlat(struct ata_queued_cmd *qc)
4914 4937 tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48;
4915 4938
4916 4939 qc->flags |= ATA_QCFLAG_RESULT_TF;
4940 + qc->complete_fn = ata_scsi_depop_ua_cap_changed_complete;
4917 4941
4918 4942 return 0;
4919 4943 }
modified drivers/base/property.c
@@ -526,7 +526,7 @@ int fwnode_property_match_string(const struct fwnode_handle *fwnode,
526 526 if (nval == 0)
527 527 return -ENODATA;
528 528
529 - const char **values __free(kfree) = kzalloc_objs(*values, nval);
529 + const char **values __free(kfree) = kcalloc(nval, sizeof(*values), GFP_KERNEL);
530 530 if (!values)
531 531 return -ENOMEM;
532 532
modified drivers/base/test/Kconfig
@@ -17,6 +17,7 @@ config DM_KUNIT_TEST
17 17 config DRIVER_PE_KUNIT_TEST
18 18 tristate "KUnit Tests for property entry API" if !KUNIT_ALL_TESTS
19 19 depends on KUNIT
20 + select OF
20 21 default KUNIT_ALL_TESTS
21 22
22 23 config DRIVER_SWNODE_KUNIT_TEST
modified drivers/base/test/property-entry-test.c
@@ -523,9 +523,6 @@ static void pe_test_child_iteration(struct kunit *test)
523 523 struct fwnode_handle *child;
524 524 int error, i, num;
525 525
526 - if (!IS_ENABLED(CONFIG_OF))
527 - kunit_skip(test, "requires CONFIG_OF");
528 -
529 526 static const struct software_node node = { .name = "sw" };
530 527 static const struct software_node node1 = { .name = "sw-1", .parent = &node};
531 528 static const struct software_node node2 = { .name = "sw-2", .parent = &node};
modified drivers/block/drbd/drbd_nl_gen.c
@@ -656,7 +656,7 @@ static int __drbd_cfg_context_from_attrs(struct drbd_cfg_context *s,
656 656 *ret_nested_attribute_table = NULL;
657 657 if (!tla)
658 658 return -ENOMSG;
659 - ntb = kzalloc_objs(*ntb, DRBD_A_DRBD_CFG_CONTEXT_CTX_PEER_ADDR + 1);
659 + ntb = kcalloc(DRBD_A_DRBD_CFG_CONTEXT_CTX_PEER_ADDR + 1, sizeof(*ntb), GFP_KERNEL);
660 660 if (!ntb)
661 661 return -ENOMEM;
662 662 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_drbd_cfg_context_nl_policy, NULL);
@@ -714,7 +714,7 @@ static int __disk_conf_from_attrs(struct disk_conf *s,
714 714 *ret_nested_attribute_table = NULL;
715 715 if (!tla)
716 716 return -ENOMSG;
717 - ntb = kzalloc_objs(*ntb, DRBD_A_DISK_CONF_DISABLE_WRITE_SAME + 1);
717 + ntb = kcalloc(DRBD_A_DISK_CONF_DISABLE_WRITE_SAME + 1, sizeof(*ntb), GFP_KERNEL);
718 718 if (!ntb)
719 719 return -ENOMEM;
720 720 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_disk_conf_nl_policy, NULL);
@@ -871,7 +871,7 @@ static int __res_opts_from_attrs(struct res_opts *s,
871 871 *ret_nested_attribute_table = NULL;
872 872 if (!tla)
873 873 return -ENOMSG;
874 - ntb = kzalloc_objs(*ntb, DRBD_A_RES_OPTS_ON_NO_DATA + 1);
874 + ntb = kcalloc(DRBD_A_RES_OPTS_ON_NO_DATA + 1, sizeof(*ntb), GFP_KERNEL);
875 875 if (!ntb)
876 876 return -ENOMEM;
877 877 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_res_opts_nl_policy, NULL);
@@ -921,7 +921,7 @@ static int __net_conf_from_attrs(struct net_conf *s,
921 921 *ret_nested_attribute_table = NULL;
922 922 if (!tla)
923 923 return -ENOMSG;
924 - ntb = kzalloc_objs(*ntb, DRBD_A_NET_CONF_SOCK_CHECK_TIMEO + 1);
924 + ntb = kcalloc(DRBD_A_NET_CONF_SOCK_CHECK_TIMEO + 1, sizeof(*ntb), GFP_KERNEL);
925 925 if (!ntb)
926 926 return -ENOMEM;
927 927 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_net_conf_nl_policy, NULL);
@@ -1087,7 +1087,7 @@ static int __set_role_parms_from_attrs(struct set_role_parms *s,
1087 1087 *ret_nested_attribute_table = NULL;
1088 1088 if (!tla)
1089 1089 return -ENOMSG;
1090 - ntb = kzalloc_objs(*ntb, DRBD_A_SET_ROLE_PARMS_ASSUME_UPTODATE + 1);
1090 + ntb = kcalloc(DRBD_A_SET_ROLE_PARMS_ASSUME_UPTODATE + 1, sizeof(*ntb), GFP_KERNEL);
1091 1091 if (!ntb)
1092 1092 return -ENOMEM;
1093 1093 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_set_role_parms_nl_policy, NULL);
@@ -1133,7 +1133,7 @@ static int __resize_parms_from_attrs(struct resize_parms *s,
1133 1133 *ret_nested_attribute_table = NULL;
1134 1134 if (!tla)
1135 1135 return -ENOMSG;
1136 - ntb = kzalloc_objs(*ntb, DRBD_A_RESIZE_PARMS_AL_STRIPE_SIZE + 1);
1136 + ntb = kcalloc(DRBD_A_RESIZE_PARMS_AL_STRIPE_SIZE + 1, sizeof(*ntb), GFP_KERNEL);
1137 1137 if (!ntb)
1138 1138 return -ENOMEM;
1139 1139 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_resize_parms_nl_policy, NULL);
@@ -1195,7 +1195,7 @@ static int __start_ov_parms_from_attrs(struct start_ov_parms *s,
1195 1195 *ret_nested_attribute_table = NULL;
1196 1196 if (!tla)
1197 1197 return -ENOMSG;
1198 - ntb = kzalloc_objs(*ntb, DRBD_A_START_OV_PARMS_OV_STOP_SECTOR + 1);
1198 + ntb = kcalloc(DRBD_A_START_OV_PARMS_OV_STOP_SECTOR + 1, sizeof(*ntb), GFP_KERNEL);
1199 1199 if (!ntb)
1200 1200 return -ENOMEM;
1201 1201 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_start_ov_parms_nl_policy, NULL);
@@ -1245,7 +1245,7 @@ static int __new_c_uuid_parms_from_attrs(struct new_c_uuid_parms *s,
1245 1245 *ret_nested_attribute_table = NULL;
1246 1246 if (!tla)
1247 1247 return -ENOMSG;
1248 - ntb = kzalloc_objs(*ntb, DRBD_A_NEW_C_UUID_PARMS_CLEAR_BM + 1);
1248 + ntb = kcalloc(DRBD_A_NEW_C_UUID_PARMS_CLEAR_BM + 1, sizeof(*ntb), GFP_KERNEL);
1249 1249 if (!ntb)
1250 1250 return -ENOMEM;
1251 1251 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_new_c_uuid_parms_nl_policy, NULL);
@@ -1291,7 +1291,7 @@ static int __disconnect_parms_from_attrs(struct disconnect_parms *s,
1291 1291 *ret_nested_attribute_table = NULL;
1292 1292 if (!tla)
1293 1293 return -ENOMSG;
1294 - ntb = kzalloc_objs(*ntb, DRBD_A_DISCONNECT_PARMS_FORCE_DISCONNECT + 1);
1294 + ntb = kcalloc(DRBD_A_DISCONNECT_PARMS_FORCE_DISCONNECT + 1, sizeof(*ntb), GFP_KERNEL);
1295 1295 if (!ntb)
1296 1296 return -ENOMEM;
1297 1297 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_disconnect_parms_nl_policy, NULL);
@@ -1337,7 +1337,7 @@ static int __detach_parms_from_attrs(struct detach_parms *s,
1337 1337 *ret_nested_attribute_table = NULL;
1338 1338 if (!tla)
1339 1339 return -ENOMSG;
1340 - ntb = kzalloc_objs(*ntb, DRBD_A_DETACH_PARMS_FORCE_DETACH + 1);
1340 + ntb = kcalloc(DRBD_A_DETACH_PARMS_FORCE_DETACH + 1, sizeof(*ntb), GFP_KERNEL);
1341 1341 if (!ntb)
1342 1342 return -ENOMEM;
1343 1343 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_detach_parms_nl_policy, NULL);
@@ -1383,7 +1383,7 @@ static int __resource_info_from_attrs(struct resource_info *s,
1383 1383 *ret_nested_attribute_table = NULL;
1384 1384 if (!tla)
1385 1385 return -ENOMSG;
1386 - ntb = kzalloc_objs(*ntb, DRBD_A_RESOURCE_INFO_RES_SUSP_FEN + 1);
1386 + ntb = kcalloc(DRBD_A_RESOURCE_INFO_RES_SUSP_FEN + 1, sizeof(*ntb), GFP_KERNEL);
1387 1387 if (!ntb)
1388 1388 return -ENOMEM;
1389 1389 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_resource_info_nl_policy, NULL);
@@ -1441,7 +1441,7 @@ static int __device_info_from_attrs(struct device_info *s,
1441 1441 *ret_nested_attribute_table = NULL;
1442 1442 if (!tla)
1443 1443 return -ENOMSG;
1444 - ntb = kzalloc_objs(*ntb, DRBD_A_DEVICE_INFO_DEV_DISK_STATE + 1);
1444 + ntb = kcalloc(DRBD_A_DEVICE_INFO_DEV_DISK_STATE + 1, sizeof(*ntb), GFP_KERNEL);
1445 1445 if (!ntb)
1446 1446 return -ENOMEM;
1447 1447 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_device_info_nl_policy, NULL);
@@ -1487,7 +1487,7 @@ static int __connection_info_from_attrs(struct connection_info *s,
1487 1487 *ret_nested_attribute_table = NULL;
1488 1488 if (!tla)
1489 1489 return -ENOMSG;
1490 - ntb = kzalloc_objs(*ntb, DRBD_A_CONNECTION_INFO_CONN_ROLE + 1);
1490 + ntb = kcalloc(DRBD_A_CONNECTION_INFO_CONN_ROLE + 1, sizeof(*ntb), GFP_KERNEL);
1491 1491 if (!ntb)
1492 1492 return -ENOMEM;
1493 1493 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_connection_info_nl_policy, NULL);
@@ -1537,8 +1537,7 @@ static int __peer_device_info_from_attrs(struct peer_device_info *s,
1537 1537 *ret_nested_attribute_table = NULL;
1538 1538 if (!tla)
1539 1539 return -ENOMSG;
1540 - ntb = kzalloc_objs(*ntb,
1541 - DRBD_A_PEER_DEVICE_INFO_PEER_RESYNC_SUSP_DEPENDENCY + 1);
1540 + ntb = kcalloc(DRBD_A_PEER_DEVICE_INFO_PEER_RESYNC_SUSP_DEPENDENCY + 1, sizeof(*ntb), GFP_KERNEL);
1542 1541 if (!ntb)
1543 1542 return -ENOMEM;
1544 1543 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_peer_device_info_nl_policy, NULL);
@@ -1600,8 +1599,7 @@ static int __resource_statistics_from_attrs(struct resource_statistics *s,
1600 1599 *ret_nested_attribute_table = NULL;
1601 1600 if (!tla)
1602 1601 return -ENOMSG;
1603 - ntb = kzalloc_objs(*ntb,
1604 - DRBD_A_RESOURCE_STATISTICS_RES_STAT_WRITE_ORDERING + 1);
1602 + ntb = kcalloc(DRBD_A_RESOURCE_STATISTICS_RES_STAT_WRITE_ORDERING + 1, sizeof(*ntb), GFP_KERNEL);
1605 1603 if (!ntb)
1606 1604 return -ENOMEM;
1607 1605 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_resource_statistics_nl_policy, NULL);
@@ -1647,7 +1645,7 @@ static int __device_statistics_from_attrs(struct device_statistics *s,
1647 1645 *ret_nested_attribute_table = NULL;
1648 1646 if (!tla)
1649 1647 return -ENOMSG;
1650 - ntb = kzalloc_objs(*ntb, DRBD_A_DEVICE_STATISTICS_HISTORY_UUIDS + 1);
1648 + ntb = kcalloc(DRBD_A_DEVICE_STATISTICS_HISTORY_UUIDS + 1, sizeof(*ntb), GFP_KERNEL);
1651 1649 if (!ntb)
1652 1650 return -ENOMEM;
1653 1651 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_device_statistics_nl_policy, NULL);
@@ -1745,8 +1743,7 @@ static int __connection_statistics_from_attrs(struct connection_statistics *s,
1745 1743 *ret_nested_attribute_table = NULL;
1746 1744 if (!tla)
1747 1745 return -ENOMSG;
1748 - ntb = kzalloc_objs(*ntb,
1749 - DRBD_A_CONNECTION_STATISTICS_CONN_CONGESTED + 1);
1746 + ntb = kcalloc(DRBD_A_CONNECTION_STATISTICS_CONN_CONGESTED + 1, sizeof(*ntb), GFP_KERNEL);
1750 1747 if (!ntb)
1751 1748 return -ENOMEM;
1752 1749 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_connection_statistics_nl_policy, NULL);
@@ -1792,8 +1789,7 @@ static int __peer_device_statistics_from_attrs(struct peer_device_statistics *s,
1792 1789 *ret_nested_attribute_table = NULL;
1793 1790 if (!tla)
1794 1791 return -ENOMSG;
1795 - ntb = kzalloc_objs(*ntb,
1796 - DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_FLAGS + 1);
1792 + ntb = kcalloc(DRBD_A_PEER_DEVICE_STATISTICS_PEER_DEV_FLAGS + 1, sizeof(*ntb), GFP_KERNEL);
1797 1793 if (!ntb)
1798 1794 return -ENOMEM;
1799 1795 err = nla_parse_nested_deprecated(ntb, maxtype, tla, drbd_peer_device_statistics_nl_policy, NULL);
modified drivers/block/loop.c
@@ -458,14 +458,12 @@ static void loop_update_dio_alignment(struct loop_device *lo)
458 458 * Use the dio alignment of the file system if provided. The incomoing
459 459 * request's bio_vec is forwarded to the backing file unchanged, so its
460 460 * required memory alignment becomes the device's dma_alignment when
461 - * used for direct-io. The file system reports zeroed alignments if the
462 - * file can't be used for direct-io at all, so fall back to the block
463 - * device limits in that case.
461 + * used for direct-io.
464 462 */
465 463 if (!vfs_getattr(&file->f_path, &st, STATX_DIOALIGN, 0) &&
466 - (st.result_mask & STATX_DIOALIGN) && st.dio_mem_align) {
464 + (st.result_mask & STATX_DIOALIGN)) {
467 465 lo->lo_min_dio_size = st.dio_offset_align;
468 - lo->lo_dio_mem_align = min(st.dio_mem_align - 1, PAGE_SIZE - 1);
466 + lo->lo_dio_mem_align = st.dio_mem_align - 1;
469 467 return;
470 468 }
471 469
modified drivers/block/ublk_drv.c
@@ -2653,12 +2653,6 @@ static int ublk_ch_mmap(struct file *filp, struct vm_area_struct *vma)
2653 2653 if (vma->vm_flags & VM_WRITE)
2654 2654 return -EPERM;
2655 2655
2656 - /*
2657 - * The per-queue command buffer is kernel-written ABI; prevent
2658 - * the daemon from upgrading to writable via mprotect().
2659 - */
2660 - vm_flags_clear(vma, VM_MAYWRITE);
2661 -
2662 2656 end = UBLKSRV_CMD_BUF_OFFSET + ub->dev_info.nr_hw_queues * max_sz;
2663 2657 if (phys_off < UBLKSRV_CMD_BUF_OFFSET || phys_off >= end)
2664 2658 return -EINVAL;
@@ -5396,7 +5390,7 @@ static int __ublk_ctrl_reg_buf(struct ublk_device *ub,
5396 5390 page_to_pfn(pages[i + 1]) == pfn + (i - start) + 1)
5397 5391 i++;
5398 5392
5399 - range = kzalloc_obj(*range);
5393 + range = kzalloc(sizeof(*range), GFP_KERNEL);
5400 5394 if (!range) {
5401 5395 ret = -ENOMEM;
5402 5396 goto unwind;
@@ -5459,7 +5453,7 @@ static int ublk_ctrl_reg_buf(struct ublk_device *ub,
5459 5453 nr_pages = buf_reg.len >> PAGE_SHIFT;
5460 5454
5461 5455 /* Pin pages before any locks (may sleep) */
5462 - pages = kvmalloc_objs(*pages, nr_pages);
5456 + pages = kvmalloc_array(nr_pages, sizeof(*pages), GFP_KERNEL);
5463 5457 if (!pages)
5464 5458 return -ENOMEM;
5465 5459
modified drivers/block/zloop.c
@@ -1042,14 +1042,12 @@ static int zloop_get_block_size(struct zloop_device *zlo,
1042 1042 * Use the dio alignment of the file system if provided. The incoming
1043 1043 * request's bio_vec is forwarded to the backing file unchanged, so its
1044 1044 * required memory alignment becomes the device's dma_alignment when
1045 - * used for direct-io. The file system reports zeroed alignments if the
1046 - * file can't be used for direct-io at all, so fall back to the block
1047 - * device limits in that case.
1045 + * used for direct-io.
1048 1046 */
1049 1047 if (!vfs_getattr(&zone->file->f_path, &st, STATX_DIOALIGN, 0) &&
1050 - (st.result_mask & STATX_DIOALIGN) && st.dio_mem_align) {
1048 + (st.result_mask & STATX_DIOALIGN)) {
1051 1049 zlo->block_size = st.dio_offset_align;
1052 - zlo->dio_mem_align = min(st.dio_mem_align - 1, PAGE_SIZE - 1);
1050 + zlo->dio_mem_align = st.dio_mem_align - 1;
1053 1051 } else if (sb_bdev) {
1054 1052 zlo->block_size = bdev_physical_block_size(sb_bdev);
1055 1053 zlo->dio_mem_align = bdev_dma_alignment(sb_bdev);
modified drivers/block/zram/backend_lz4.c
@@ -42,7 +42,7 @@ static int lz4_setup_params(struct zcomp_params *params)
42 42 if (!params->dict || !params->dict_sz)
43 43 return 0;
44 44
45 - dict_stream = kzalloc_obj(*dict_stream);
45 + dict_stream = kzalloc_obj(*dict_stream, GFP_KERNEL);
46 46 if (!dict_stream)
47 47 return -ENOMEM;
48 48
modified drivers/bluetooth/btintel.c
@@ -571,44 +571,12 @@ int btintel_version_info_tlv(struct hci_dev *hdev,
571 571 }
572 572 EXPORT_SYMBOL_GPL(btintel_version_info_tlv);
573 573
574 - static u8 btintel_version_tlv_min_len(u8 type)
575 - {
576 - switch (type) {
577 - case INTEL_TLV_CNVI_TOP:
578 - case INTEL_TLV_CNVR_TOP:
579 - case INTEL_TLV_CNVI_BT:
580 - case INTEL_TLV_CNVR_BT:
581 - case INTEL_TLV_BUILD_NUM:
582 - case INTEL_TLV_GIT_SHA1:
583 - return sizeof(u32);
584 - case INTEL_TLV_DEV_REV_ID:
585 - case INTEL_TLV_TIME_STAMP:
586 - return sizeof(u16);
587 - case INTEL_TLV_IMAGE_TYPE:
588 - case INTEL_TLV_BUILD_TYPE:
589 - case INTEL_TLV_SECURE_BOOT:
590 - case INTEL_TLV_OTP_LOCK:
591 - case INTEL_TLV_API_LOCK:
592 - case INTEL_TLV_DEBUG_LOCK:
593 - case INTEL_TLV_LIMITED_CCE:
594 - case INTEL_TLV_SBE_TYPE:
595 - return sizeof(u8);
596 - case INTEL_TLV_MIN_FW:
597 - return 3;
598 - case INTEL_TLV_OTP_BDADDR:
599 - return sizeof(bdaddr_t);
600 - default:
601 - return 0;
602 - }
603 - }
604 -
605 574 int btintel_parse_version_tlv(struct hci_dev *hdev,
606 575 struct intel_version_tlv *version,
607 576 struct sk_buff *skb)
608 577 {
609 578 /* Consume Command Complete Status field */
610 - if (!skb_pull(skb, 1))
611 - return -EINVAL;
579 + skb_pull(skb, 1);
612 580
613 581 /* Event parameters contain multiple TLVs. Read each of them
614 582 * and only keep the required data. Also, it use existing legacy
@@ -628,9 +596,6 @@ int btintel_parse_version_tlv(struct hci_dev *hdev,
628 596 if (skb->len < tlv->len + sizeof(*tlv))
629 597 return -EINVAL;
630 598
631 - if (tlv->len < btintel_version_tlv_min_len(tlv->type))
632 - return -EINVAL;
633 -
634 599 switch (tlv->type) {
635 600 case INTEL_TLV_CNVI_TOP:
636 601 version->cnvi_top = get_unaligned_le32(tlv->val);
@@ -702,7 +667,7 @@ int btintel_parse_version_tlv(struct hci_dev *hdev,
702 667 break;
703 668 case INTEL_TLV_FW_ID:
704 669 snprintf(version->fw_id, sizeof(version->fw_id),
705 - "%.*s", tlv->len, tlv->val);
670 + "%s", tlv->val);
706 671 break;
707 672 default:
708 673 /* Ignore rest of information */
@@ -721,7 +686,6 @@ static int btintel_read_version_tlv(struct hci_dev *hdev,
721 686 {
722 687 struct sk_buff *skb;
723 688 const u8 param[1] = { 0xFF };
724 - int err;
725 689
726 690 if (!version)
727 691 return -EINVAL;
@@ -740,10 +704,10 @@ static int btintel_read_version_tlv(struct hci_dev *hdev,
740 704 return -EIO;
741 705 }
742 706
743 - err = btintel_parse_version_tlv(hdev, version, skb);
707 + btintel_parse_version_tlv(hdev, version, skb);
744 708
745 709 kfree_skb(skb);
746 - return err;
710 + return 0;
747 711 }
748 712
749 713 /* ------- REGMAP IBT SUPPORT ------- */
modified drivers/bluetooth/btintel_pcie.c
@@ -1696,9 +1696,6 @@ static irqreturn_t btintel_pcie_irq_msix_handler(int irq, void *dev_id)
1696 1696
1697 1697 if (unlikely(!(intr_fh | intr_hw))) {
1698 1698 /* Ignore interrupt, inta == 0 */
1699 - bt_warn_ratelimited("Bluetooth: btintel_pcie: Received spurious interrupt\n");
1700 - btintel_pcie_wr_reg32(data, BTINTEL_PCIE_CSR_MSIX_AUTOMASK_ST,
1701 - BIT(entry->entry));
1702 1699 return IRQ_NONE;
1703 1700 }
1704 1701
modified drivers/bluetooth/hci_mrvl.c
@@ -307,8 +307,9 @@ static int mrvl_load_firmware(struct hci_dev *hdev, const char *name)
307 307 err = wait_on_bit_timeout(&mrvl->flags, STATE_FW_REQ_PENDING,
308 308 TASK_INTERRUPTIBLE,
309 309 msecs_to_jiffies(2000));
310 - if (err == -EINTR) {
310 + if (err == 1) {
311 311 bt_dev_err(hdev, "Firmware load interrupted");
312 + err = -EINTR;
312 313 break;
313 314 } else if (err) {
314 315 bt_dev_err(hdev, "Firmware request timeout");
modified drivers/char/virtio_console.c
@@ -426,7 +426,7 @@ static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size
426 426 * Allocate buffer and the sg list. The sg list array is allocated
427 427 * directly after the port_buffer struct.
428 428 */
429 - buf = kmalloc_flex(*buf, sg, pages, gfp);
429 + buf = kmalloc_flex(*buf, sg, pages);
430 430 if (!buf)
431 431 goto fail;
432 432
modified drivers/clk/ti/composite.c
@@ -248,7 +248,7 @@ int __init ti_clk_add_component(struct device_node *node, struct clk_hw *hw,
248 248 return -EINVAL;
249 249 }
250 250
251 - parent_data = kzalloc_objs(*parent_data, num_parents);
251 + parent_data = kcalloc(num_parents, sizeof(*parent_data), GFP_KERNEL);
252 252 if (!parent_data)
253 253 return -ENOMEM;
254 254
modified drivers/clk/ti/mux.c
@@ -181,7 +181,7 @@ static void of_mux_clk_setup(struct device_node *node)
181 181 pr_err("mux-clock %pOFn must have parents\n", node);
182 182 return;
183 183 }
184 - parent_data = kzalloc_objs(*parent_data, num_parents);
184 + parent_data = kcalloc(num_parents, sizeof(*parent_data), GFP_KERNEL);
185 185 if (!parent_data)
186 186 return;
187 187
modified drivers/cpufreq/amd-pstate.c
@@ -1624,7 +1624,7 @@ static struct freq_attr **get_freq_attrs(void)
1624 1624 /* amd_pstate_{max_freq, lowest_nonlinear_freq, highest_perf} should always be visible */
1625 1625 BUG_ON(!count);
1626 1626
1627 - attrs = kzalloc_objs(struct freq_attr *, count + 1);
1627 + attrs = kcalloc(count + 1, sizeof(struct freq_attr *), GFP_KERNEL);
1628 1628 if (!attrs)
1629 1629 return ERR_PTR(-ENOMEM);
1630 1630
modified drivers/cpuidle/cpuidle-psci.c
@@ -16,7 +16,7 @@
16 16 #include <linux/kernel.h>
17 17 #include <linux/module.h>
18 18 #include <linux/of.h>
19 - #include <linux/platform_device.h>
19 + #include <linux/device/faux.h>
20 20 #include <linux/psci.h>
21 21 #include <linux/pm_domain.h>
22 22 #include <linux/pm_runtime.h>
@@ -428,14 +428,14 @@ deinit:
428 428 * to register cpuidle driver then rollback to cancel all CPUs
429 429 * registration.
430 430 */
431 - static int psci_cpuidle_probe(struct platform_device *pdev)
431 + static int psci_cpuidle_probe(struct faux_device *fdev)
432 432 {
433 433 int cpu, ret;
434 434 struct cpuidle_driver *drv;
435 435 struct cpuidle_device *dev;
436 436
437 437 for_each_present_cpu(cpu) {
438 - ret = psci_idle_init_cpu(&pdev->dev, cpu);
438 + ret = psci_idle_init_cpu(&fdev->dev, cpu);
439 439 if (ret)
440 440 goto out_fail;
441 441 }
@@ -455,26 +455,36 @@ out_fail:
455 455 return ret;
456 456 }
457 457
458 - static struct platform_driver psci_cpuidle_driver = {
458 + static struct faux_device_ops psci_cpuidle_ops = {
459 459 .probe = psci_cpuidle_probe,
460 - .driver = {
461 - .name = "psci-cpuidle",
462 - },
463 460 };
464 461
462 + static bool __init dt_idle_state_present(void)
463 + {
464 + struct device_node *cpu_node __free(device_node) =
465 + of_cpu_device_node_get(cpumask_first(cpu_possible_mask));
466 + if (!cpu_node)
467 + return false;
468 +
469 + struct device_node *state_node __free(device_node) =
470 + of_get_cpu_state_node(cpu_node, 0);
471 + if (!state_node)
472 + return false;
473 +
474 + return !!of_match_node(psci_idle_state_match, state_node);
475 + }
476 +
465 477 static int __init psci_idle_init(void)
466 478 {
467 - struct platform_device *pdev;
468 - int ret;
479 + struct faux_device *fdev;
469 480
470 - ret = platform_driver_register(&psci_cpuidle_driver);
471 - if (ret)
472 - return ret;
481 + if (!dt_idle_state_present())
482 + return 0;
473 483
474 - pdev = platform_device_register_simple("psci-cpuidle", -1, NULL, 0);
475 - if (IS_ERR(pdev)) {
476 - platform_driver_unregister(&psci_cpuidle_driver);
477 - return PTR_ERR(pdev);
484 + fdev = faux_device_create("psci-cpuidle", NULL, &psci_cpuidle_ops);
485 + if (!fdev) {
486 + pr_err("Failed to create psci-cpuidle device\n");
487 + return -ENODEV;
478 488 }
479 489
480 490 return 0;
modified drivers/cpuidle/dt_idle_genpd.c
@@ -99,7 +99,7 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np,
99 99 if (!pd)
100 100 goto out;
101 101
102 - pd->name = kstrdup(kbasename(of_node_full_name(np)), GFP_KERNEL);
102 + pd->name = kasprintf(GFP_KERNEL, "%pOF", np);
103 103 if (!pd->name)
104 104 goto free_pd;
105 105
@@ -112,6 +112,7 @@ struct generic_pm_domain *dt_idle_pd_alloc(struct device_node *np,
112 112 goto free_name;
113 113
114 114 pd->free_states = pd_free_states;
115 + pd->name = kbasename(pd->name);
115 116 pd->states = states;
116 117 pd->state_count = state_count;
117 118
modified drivers/crypto/inside-secure/eip93/eip93-common.c
@@ -533,7 +533,7 @@ int eip93_send_req(struct crypto_async_request *async,
533 533
534 534 memcpy(iv, reqiv, rctx->ivsize);
535 535
536 - rctx->sa_state = kzalloc_obj(*rctx->sa_state);
536 + rctx->sa_state = kzalloc(sizeof(*rctx->sa_state), GFP_KERNEL);
537 537 if (!rctx->sa_state)
538 538 return -ENOMEM;
539 539
@@ -561,7 +561,8 @@ int eip93_send_req(struct crypto_async_request *async,
561 561 iv[3] = 0xffffffff;
562 562 crypto_inc((u8 *)iv, AES_BLOCK_SIZE);
563 563
564 - rctx->sa_state_ctr = kzalloc_obj(*rctx->sa_state_ctr);
564 + rctx->sa_state_ctr = kzalloc(sizeof(*rctx->sa_state_ctr),
565 + GFP_KERNEL);
565 566 if (!rctx->sa_state_ctr) {
566 567 err = -ENOMEM;
567 568 goto free_sa_state;
modified drivers/crypto/intel/qat/qat_common/qat_comp_algs.c
@@ -59,7 +59,8 @@ static void *qat_zstd_alloc_scratch(void)
59 59 if (!scratch->literals)
60 60 goto error;
61 61
62 - scratch->out_seqs = kvzalloc_objs(ZSTD_Sequence, QAT_MAX_SEQUENCES);
62 + scratch->out_seqs = kvcalloc(QAT_MAX_SEQUENCES, sizeof(ZSTD_Sequence),
63 + GFP_KERNEL);
63 64 if (!scratch->out_seqs)
64 65 goto error;
65 66
modified drivers/crypto/ti/dthev2-aes.c
@@ -387,7 +387,7 @@ static int dthe_aes_run(struct crypto_engine *engine, void *areq)
387 387 src_nents++;
388 388 dst_nents++;
389 389
390 - src = kmalloc_objs(*src, src_nents, GFP_ATOMIC);
390 + src = kmalloc_array(src_nents, sizeof(*src), GFP_ATOMIC);
391 391 if (!src) {
392 392 ret = -ENOMEM;
393 393 goto aes_ctr_src_alloc_err;
@@ -399,7 +399,7 @@ static int dthe_aes_run(struct crypto_engine *engine, void *areq)
399 399 sg_set_buf(sg, pad_buf, pad_size);
400 400
401 401 if (diff_dst) {
402 - dst = kmalloc_objs(*dst, dst_nents, GFP_ATOMIC);
402 + dst = kmalloc_array(dst_nents, sizeof(*dst), GFP_ATOMIC);
403 403 if (!dst) {
404 404 ret = -ENOMEM;
405 405 goto aes_ctr_dst_alloc_err;
@@ -624,7 +624,7 @@ static struct scatterlist *dthe_aead_prep_aad(struct scatterlist *sg,
624 624 if (assoclen % AES_BLOCK_SIZE)
625 625 aad_nents++;
626 626
627 - aad_sg = kmalloc_objs(struct scatterlist, aad_nents, GFP_ATOMIC);
627 + aad_sg = kmalloc_array(aad_nents, sizeof(struct scatterlist), GFP_ATOMIC);
628 628 if (!aad_sg)
629 629 return ERR_PTR(-ENOMEM);
630 630
@@ -680,7 +680,7 @@ static struct scatterlist *dthe_aead_prep_crypt(struct scatterlist *sg,
680 680 if (cryptlen % AES_BLOCK_SIZE)
681 681 crypt_nents++;
682 682
683 - crypt_sg = kmalloc_objs(struct scatterlist, crypt_nents, GFP_ATOMIC);
683 + crypt_sg = kmalloc_array(crypt_nents, sizeof(struct scatterlist), GFP_ATOMIC);
684 684 if (!crypt_sg) {
685 685 err = -ENOMEM;
686 686 goto dthe_aead_prep_crypt_mem_err;
modified drivers/devfreq/hisi_uncore_freq.c
@@ -474,7 +474,7 @@ static int hisi_uncore_mark_related_cpus(struct hisi_uncore_freq *uncore,
474 474 return -EINVAL;
475 475
476 476 len = rc;
477 - u32 *num __free(kfree) = kzalloc_objs(*num, len);
477 + u32 *num __free(kfree) = kcalloc(len, sizeof(*num), GFP_KERNEL);
478 478 if (!num)
479 479 return -ENOMEM;
480 480
modified drivers/dma-buf/dma-buf.c
@@ -803,26 +803,6 @@ int dma_buf_fd(struct dma_buf *dmabuf, int flags)
803 803 }
804 804 EXPORT_SYMBOL_NS_GPL(dma_buf_fd, "DMA_BUF");
805 805
806 - /**
807 - * dma_buf_fd_install - install a reserved fd for a dma-buf
808 - * @dmabuf: [in] pointer to dma_buf
809 - * @fd: [in] fd reserved with get_unused_fd_flags()
810 - *
811 - * Publishes a previously reserved fd into the caller's fd table.
812 - * Must only be called after all fallible work (e.g. copy_to_user)
813 - * has succeeded, as it cannot be undone safely once called.
814 - *
815 - * The caller is responsible for having emitted the trace event
816 - * (via dma_buf_fd() or get_unused_fd_flags() + this function)
817 - * before calling this.
818 - */
819 - void dma_buf_fd_install(struct dma_buf *dmabuf, int fd)
820 - {
821 - DMA_BUF_TRACE(trace_dma_buf_fd, dmabuf, fd);
822 - fd_install(fd, dmabuf->file);
823 - }
824 - EXPORT_SYMBOL_NS_GPL(dma_buf_fd_install, "DMA_BUF");
825 -
826 806 /**
827 807 * dma_buf_get - returns the struct dma_buf related to an fd
828 808 * @fd: [in] fd associated with the struct dma_buf to be returned
modified drivers/dma-buf/dma-heap.c
@@ -56,6 +56,33 @@ MODULE_PARM_DESC(mem_accounting,
56 56 "Enable cgroup-based memory accounting for dma-buf heap allocations (default=false).");
57 57 EXPORT_SYMBOL_NS_GPL(mem_accounting, "DMA_BUF_HEAP");
58 58
59 + static int dma_heap_buffer_alloc(struct dma_heap *heap, size_t len,
60 + u32 fd_flags,
61 + u64 heap_flags)
62 + {
63 + struct dma_buf *dmabuf;
64 + int fd;
65 +
66 + /*
67 + * Allocations from all heaps have to begin
68 + * and end on page boundaries.
69 + */
70 + len = PAGE_ALIGN(len);
71 + if (!len)
72 + return -EINVAL;
73 +
74 + dmabuf = heap->ops->allocate(heap, len, fd_flags, heap_flags);
75 + if (IS_ERR(dmabuf))
76 + return PTR_ERR(dmabuf);
77 +
78 + fd = dma_buf_fd(dmabuf, fd_flags);
79 + if (fd < 0) {
80 + dma_buf_put(dmabuf);
81 + /* just return, as put will call release and that will free */
82 + }
83 + return fd;
84 + }
85 +
59 86 static int dma_heap_open(struct inode *inode, struct file *file)
60 87 {
61 88 struct dma_heap *heap;
@@ -73,42 +100,30 @@ static int dma_heap_open(struct inode *inode, struct file *file)
73 100 return 0;
74 101 }
75 102
76 - static struct dma_buf *dma_heap_ioctl_allocate(struct file *file, void *data)
103 + static long dma_heap_ioctl_allocate(struct file *file, void *data)
77 104 {
78 105 struct dma_heap_allocation_data *heap_allocation = data;
79 106 struct dma_heap *heap = file->private_data;
80 - struct dma_buf *dmabuf;
81 107 int fd;
82 - size_t len;
83 108
84 109 if (heap_allocation->fd)
85 - return ERR_PTR(-EINVAL);
110 + return -EINVAL;
86 111
87 112 if (heap_allocation->fd_flags & ~DMA_HEAP_VALID_FD_FLAGS)
88 - return ERR_PTR(-EINVAL);
113 + return -EINVAL;
89 114
90 115 if (heap_allocation->heap_flags & ~DMA_HEAP_VALID_HEAP_FLAGS)
91 - return ERR_PTR(-EINVAL);
92 -
93 - len = PAGE_ALIGN(heap_allocation->len);
94 - if (!len)
95 - return ERR_PTR(-EINVAL);
96 -
97 - dmabuf = heap->ops->allocate(heap, len, heap_allocation->fd_flags,
98 - heap_allocation->heap_flags);
99 -
100 - if (IS_ERR(dmabuf))
101 - return dmabuf;
116 + return -EINVAL;
102 117
103 - fd = get_unused_fd_flags(heap_allocation->fd_flags);
104 - if (fd < 0) {
105 - dma_buf_put(dmabuf);
106 - return ERR_PTR(fd);
107 - }
118 + fd = dma_heap_buffer_alloc(heap, heap_allocation->len,
119 + heap_allocation->fd_flags,
120 + heap_allocation->heap_flags);
121 + if (fd < 0)
122 + return fd;
108 123
109 124 heap_allocation->fd = fd;
110 125
111 - return dmabuf;
126 + return 0;
112 127 }
113 128
114 129 static unsigned int dma_heap_ioctl_cmds[] = {
@@ -124,8 +139,6 @@ static long dma_heap_ioctl(struct file *file, unsigned int ucmd,
124 139 unsigned int in_size, out_size, drv_size, ksize;
125 140 int nr = _IOC_NR(ucmd);
126 141 int ret = 0;
127 - int fd;
128 - struct dma_buf *dmabuf;
129 142
130 143 if (nr >= ARRAY_SIZE(dma_heap_ioctl_cmds))
131 144 return -EINVAL;
@@ -162,28 +175,15 @@ static long dma_heap_ioctl(struct file *file, unsigned int ucmd,
162 175
163 176 switch (kcmd) {
164 177 case DMA_HEAP_IOCTL_ALLOC:
165 - dmabuf = dma_heap_ioctl_allocate(file, kdata);
166 -
167 - if (IS_ERR(dmabuf)) {
168 - ret = PTR_ERR(dmabuf);
169 - break;
170 - }
171 -
172 - fd = ((struct dma_heap_allocation_data *)kdata)->fd;
173 - if (copy_to_user((void __user *)arg, kdata, out_size) != 0) {
174 - put_unused_fd(fd);
175 - dma_buf_put(dmabuf);
176 - ret = -EFAULT;
177 - } else {
178 - dma_buf_fd_install(dmabuf, fd);
179 - }
180 -
178 + ret = dma_heap_ioctl_allocate(file, kdata);
181 179 break;
182 180 default:
183 181 ret = -ENOTTY;
184 182 goto err;
185 183 }
186 184
185 + if (copy_to_user((void __user *)arg, kdata, out_size) != 0)
186 + ret = -EFAULT;
187 187 err:
188 188 if (kdata != stack_kdata)
189 189 kfree(kdata);
modified drivers/dma-buf/st-dma-fence.c
@@ -27,7 +27,7 @@ static struct dma_fence *mock_fence(void)
27 27 {
28 28 struct dma_fence *f;
29 29
30 - f = kmalloc_obj(*f);
30 + f = kmalloc(sizeof(*f), GFP_KERNEL);
31 31 if (!f)
32 32 return NULL;
33 33
modified drivers/dma-buf/udmabuf.c
@@ -359,7 +359,7 @@ static long udmabuf_create(struct miscdevice *device,
359 359 long ret = -EINVAL;
360 360 u32 i, flags;
361 361
362 - ubuf = kzalloc_obj(*ubuf);
362 + ubuf = kzalloc(sizeof(*ubuf), GFP_KERNEL);
363 363 if (!ubuf)
364 364 return -ENOMEM;
365 365
@@ -387,7 +387,7 @@ static long udmabuf_create(struct miscdevice *device,
387 387 if (ret)
388 388 goto err;
389 389
390 - folios = kvmalloc_objs(*folios, max_nr_folios);
390 + folios = kvmalloc_array(max_nr_folios, sizeof(*folios), GFP_KERNEL);
391 391 if (!folios) {
392 392 ret = -ENOMEM;
393 393 goto err;
modified drivers/dma/switchtec_dma.c
@@ -1056,7 +1056,7 @@ static int switchtec_dma_chan_init(struct switchtec_dma_dev *swdma_dev,
1056 1056 int se_buf_len, irq, rc;
1057 1057 struct dma_chan *chan;
1058 1058
1059 - swdma_chan = kzalloc_obj(*swdma_chan);
1059 + swdma_chan = kzalloc_obj(*swdma_chan, GFP_KERNEL);
1060 1060 if (!swdma_chan)
1061 1061 return -ENOMEM;
1062 1062
@@ -1162,7 +1162,8 @@ static int switchtec_dma_chans_enumerate(struct switchtec_dma_dev *swdma_dev,
1162 1162 struct dma_device *dma = &swdma_dev->dma_dev;
1163 1163 int base, cnt, rc, i;
1164 1164
1165 - swdma_dev->swdma_chans = kzalloc_objs(*swdma_dev->swdma_chans, chan_cnt);
1165 + swdma_dev->swdma_chans = kcalloc(chan_cnt, sizeof(*swdma_dev->swdma_chans),
1166 + GFP_KERNEL);
1166 1167
1167 1168 if (!swdma_dev->swdma_chans)
1168 1169 return -ENOMEM;
@@ -1221,7 +1222,7 @@ static int switchtec_dma_create(struct pci_dev *pdev)
1221 1222 /*
1222 1223 * Create the switchtec dma device
1223 1224 */
1224 - swdma_dev = kzalloc_obj(*swdma_dev);
1225 + swdma_dev = kzalloc_obj(*swdma_dev, GFP_KERNEL);
1225 1226 if (!swdma_dev)
1226 1227 return -ENOMEM;
1227 1228
modified drivers/edac/al_mc_edac.c
@@ -302,8 +302,12 @@ static int al_mc_edac_probe(struct platform_device *pdev)
302 302 IRQF_SHARED,
303 303 pdev->name,
304 304 pdev);
305 - if (ret != 0)
305 + if (ret != 0) {
306 + dev_err(&pdev->dev,
307 + "failed to request UE IRQ %d (%d)\n",
308 + al_mc->irq_ue, ret);
306 309 return ret;
310 + }
307 311 }
308 312
309 313 if (al_mc->irq_ce > 0) {
@@ -313,8 +317,12 @@ static int al_mc_edac_probe(struct platform_device *pdev)
313 317 IRQF_SHARED,
314 318 pdev->name,
315 319 pdev);
316 - if (ret != 0)
320 + if (ret != 0) {
321 + dev_err(&pdev->dev,
322 + "failed to request CE IRQ %d (%d)\n",
323 + al_mc->irq_ce, ret);
317 324 return ret;
325 + }
318 326 }
319 327
320 328 return 0;
modified drivers/edac/altera_edac.c
@@ -1507,7 +1507,6 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
1507 1507 int edac_idx, rc;
1508 1508 struct device_node *np;
1509 1509 const struct edac_device_prv_data *prv = &a10_sdmmceccb_data;
1510 - bool is_s10 = device->edac->is_s10;
1511 1510
1512 1511 rc = altr_check_ecc_deps(device);
1513 1512 if (rc)
@@ -1549,14 +1548,15 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
1549 1548
1550 1549 /*
1551 1550 * Update the PortB IRQs - A10 has 4, S10 has 2, Index accordingly
1551 + *
1552 + * FIXME: Instead of ifdefs with different architectures the driver
1553 + * should properly use compatibles.
1552 1554 */
1553 -
1554 - /* Using compatibles to determine the IRQ Index */
1555 - if (is_s10)
1556 - altdev->sb_irq = irq_of_parse_and_map(np, 1);
1557 - else
1558 - altdev->sb_irq = irq_of_parse_and_map(np, 2);
1559 -
1555 + #ifdef CONFIG_64BIT
1556 + altdev->sb_irq = irq_of_parse_and_map(np, 1);
1557 + #else
1558 + altdev->sb_irq = irq_of_parse_and_map(np, 2);
1559 + #endif
1560 1560 if (!altdev->sb_irq) {
1561 1561 edac_printk(KERN_ERR, EDAC_DEVICE, "Error PortB SBIRQ alloc\n");
1562 1562 rc = -ENODEV;
@@ -1570,28 +1570,29 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
1570 1570 goto err_release_group_1;
1571 1571 }
1572 1572
1573 - if (is_s10) {
1574 - /* Use IRQ to determine SError origin instead of assigning IRQ */
1575 - rc = of_property_read_u32_index(np, "interrupts", 1, &altdev->db_irq);
1576 - if (rc) {
1577 - edac_printk(KERN_ERR, EDAC_DEVICE, "Error PortB DBIRQ alloc\n");
1578 - goto err_release_group_1;
1579 - }
1580 - } else {
1581 - altdev->db_irq = irq_of_parse_and_map(np, 3);
1582 - if (!altdev->db_irq) {
1583 - edac_printk(KERN_ERR, EDAC_DEVICE, "Error PortB DBIRQ alloc\n");
1584 - rc = -ENODEV;
1585 - goto err_release_group_1;
1586 - }
1587 - rc = devm_request_irq(&altdev->ddev, altdev->db_irq,
1588 - prv->ecc_irq_handler, IRQF_TRIGGER_HIGH,
1589 - ecc_name, altdev);
1590 - if (rc) {
1591 - edac_printk(KERN_ERR, EDAC_DEVICE, "PortB DBERR IRQ error\n");
1592 - goto err_release_group_1;
1593 - }
1573 + #ifdef CONFIG_64BIT
1574 + /* Use IRQ to determine SError origin instead of assigning IRQ */
1575 + rc = of_property_read_u32_index(np, "interrupts", 1, &altdev->db_irq);
1576 + if (rc) {
1577 + edac_printk(KERN_ERR, EDAC_DEVICE,
1578 + "Error PortB DBIRQ alloc\n");
1579 + goto err_release_group_1;
1594 1580 }
1581 + #else
1582 + altdev->db_irq = irq_of_parse_and_map(np, 3);
1583 + if (!altdev->db_irq) {
1584 + edac_printk(KERN_ERR, EDAC_DEVICE, "Error PortB DBIRQ alloc\n");
1585 + rc = -ENODEV;
1586 + goto err_release_group_1;
1587 + }
1588 + rc = devm_request_irq(&altdev->ddev, altdev->db_irq,
1589 + prv->ecc_irq_handler, IRQF_TRIGGER_HIGH,
1590 + ecc_name, altdev);
1591 + if (rc) {
1592 + edac_printk(KERN_ERR, EDAC_DEVICE, "PortB DBERR IRQ error\n");
1593 + goto err_release_group_1;
1594 + }
1595 + #endif
1595 1596
1596 1597 rc = edac_device_add_device(dci);
1597 1598 if (rc) {
@@ -1973,29 +1974,29 @@ static int altr_edac_a10_device_add(struct altr_arria10_edac *edac,
1973 1974 goto err_release_group1;
1974 1975 }
1975 1976
1976 - if (edac->is_s10) {
1977 - /* Use IRQ to determine SError origin instead of assigning IRQ */
1978 - rc = of_property_read_u32_index(np, "interrupts", 0, &altdev->db_irq);
1979 - if (rc) {
1980 - edac_printk(KERN_ERR, EDAC_DEVICE,
1981 - "Unable to parse DB IRQ index\n");
1982 - goto err_release_group1;
1983 - }
1984 - } else {
1985 - altdev->db_irq = irq_of_parse_and_map(np, 1);
1986 - if (!altdev->db_irq) {
1987 - edac_printk(KERN_ERR, EDAC_DEVICE, "Error allocating DBIRQ\n");
1988 - rc = -ENODEV;
1989 - goto err_release_group1;
1990 - }
1991 - rc = devm_request_irq(edac->dev, altdev->db_irq, prv->ecc_irq_handler,
1992 - IRQF_TRIGGER_HIGH,
1993 - ecc_name, altdev);
1994 - if (rc) {
1995 - edac_printk(KERN_ERR, EDAC_DEVICE, "No DBERR IRQ resource\n");
1996 - goto err_release_group1;
1997 - }
1977 + #ifdef CONFIG_64BIT
1978 + /* Use IRQ to determine SError origin instead of assigning IRQ */
1979 + rc = of_property_read_u32_index(np, "interrupts", 0, &altdev->db_irq);
1980 + if (rc) {
1981 + edac_printk(KERN_ERR, EDAC_DEVICE,
1982 + "Unable to parse DB IRQ index\n");
1983 + goto err_release_group1;
1984 + }
1985 + #else
1986 + altdev->db_irq = irq_of_parse_and_map(np, 1);
1987 + if (!altdev->db_irq) {
1988 + edac_printk(KERN_ERR, EDAC_DEVICE, "Error allocating DBIRQ\n");
1989 + rc = -ENODEV;
1990 + goto err_release_group1;
1998 1991 }
1992 + rc = devm_request_irq(edac->dev, altdev->db_irq, prv->ecc_irq_handler,
1993 + IRQF_TRIGGER_HIGH,
1994 + ecc_name, altdev);
1995 + if (rc) {
1996 + edac_printk(KERN_ERR, EDAC_DEVICE, "No DBERR IRQ resource\n");
1997 + goto err_release_group1;
1998 + }
1999 + #endif
1999 2000
2000 2001 rc = edac_device_add_device(dci);
2001 2002 if (rc) {
@@ -2058,6 +2059,7 @@ static const struct irq_domain_ops a10_eccmgr_ic_ops = {
2058 2059 /************** Stratix 10 EDAC Double Bit Error Handler ************/
2059 2060 #define to_a10edac(p, m) container_of(p, struct altr_arria10_edac, m)
2060 2061
2062 + #ifdef CONFIG_64BIT
2061 2063 /* panic routine issues reboot on non-zero panic_timeout */
2062 2064 extern int panic_timeout;
2063 2065
@@ -2104,6 +2106,7 @@ static int s10_edac_dberr_handler(struct notifier_block *this,
2104 2106
2105 2107 return NOTIFY_DONE;
2106 2108 }
2109 + #endif
2107 2110
2108 2111 /****************** Arria 10 EDAC Probe Function *********************/
2109 2112 static int altr_edac_a10_probe(struct platform_device *pdev)
@@ -2119,8 +2122,6 @@ static int altr_edac_a10_probe(struct platform_device *pdev)
2119 2122 platform_set_drvdata(pdev, edac);
2120 2123 INIT_LIST_HEAD(&edac->a10_ecc_devices);
2121 2124
2122 - edac->is_s10 = !!device_get_match_data(&pdev->dev);
2123 -
2124 2125 edac->ecc_mgr_map =
2125 2126 altr_sysmgr_regmap_lookup_by_phandle(pdev->dev.of_node,
2126 2127 "altr,sysmgr-syscon");
@@ -2152,7 +2153,8 @@ static int altr_edac_a10_probe(struct platform_device *pdev)
2152 2153 irq_set_chained_handler_and_data(edac->sb_irq,
2153 2154 altr_edac_a10_irq_handler,
2154 2155 edac);
2155 - if (edac->is_s10)
2156 +
2157 + #ifdef CONFIG_64BIT
2156 2158 {
2157 2159 int dberror, err_addr;
2158 2160
@@ -2175,14 +2177,15 @@ static int altr_edac_a10_probe(struct platform_device *pdev)
2175 2177 regmap_write(edac->ecc_mgr_map,
2176 2178 S10_SYSMGR_UE_ADDR_OFST, 0);
2177 2179 }
2178 - } else {
2179 - edac->db_irq = platform_get_irq(pdev, 1);
2180 - if (edac->db_irq < 0)
2181 - return edac->db_irq;
2182 -
2183 - irq_set_chained_handler_and_data(edac->db_irq,
2184 - altr_edac_a10_irq_handler, edac);
2185 2180 }
2181 + #else
2182 + edac->db_irq = platform_get_irq(pdev, 1);
2183 + if (edac->db_irq < 0)
2184 + return edac->db_irq;
2185 +
2186 + irq_set_chained_handler_and_data(edac->db_irq,
2187 + altr_edac_a10_irq_handler, edac);
2188 + #endif
2186 2189
2187 2190 for_each_child_of_node(pdev->dev.of_node, child) {
2188 2191 if (!of_device_is_available(child))
@@ -2204,7 +2207,7 @@ static int altr_edac_a10_probe(struct platform_device *pdev)
2204 2207
2205 2208 static const struct of_device_id altr_edac_a10_of_match[] = {
2206 2209 { .compatible = "altr,socfpga-a10-ecc-manager" },
2207 - { .compatible = "altr,socfpga-s10-ecc-manager", .data = (void *)1 },
2210 + { .compatible = "altr,socfpga-s10-ecc-manager" },
2208 2211 {},
2209 2212 };
2210 2213 MODULE_DEVICE_TABLE(of, altr_edac_a10_of_match);
modified drivers/edac/altera_edac.h
@@ -394,7 +394,6 @@ struct altr_arria10_edac {
394 394 struct irq_chip irq_chip;
395 395 struct list_head a10_ecc_devices;
396 396 struct notifier_block panic_notifier;
397 - bool is_s10;
398 397 };
399 398
400 399 #endif /* #ifndef _ALTERA_EDAC_H */
modified drivers/edac/amd64_edac.c
@@ -4173,8 +4173,6 @@ static int __init amd64_edac_init(void)
4173 4173 goto err_pci;
4174 4174 }
4175 4175
4176 - request_module_nowait("amd_atl");
4177 -
4178 4176 /* register stuff with EDAC MCE */
4179 4177 if (boot_cpu_data.x86 >= 0x17) {
4180 4178 amd_register_ecc_decoder(decode_umc_error);
modified drivers/edac/aspeed_edac.c
@@ -214,8 +214,10 @@ static int config_irq(void *ctx, struct platform_device *pdev)
214 214
215 215 rc = devm_request_irq(&pdev->dev, irq, mcr_isr, IRQF_TRIGGER_HIGH,
216 216 DRV_NAME, ctx);
217 - if (rc)
217 + if (rc) {
218 + dev_err(&pdev->dev, "unable to request irq %d\n", irq);
218 219 return rc;
220 + }
219 221
220 222 /* enable interrupts */
221 223 regmap_update_bits(aspeed_regmap, ASPEED_MCR_INTR_CTRL,
modified drivers/edac/debugfs.c
@@ -1,9 +1,50 @@
1 1 // SPDX-License-Identifier: GPL-2.0-only
2 2
3 + #include <linux/string_choices.h>
4 +
3 5 #include "edac_module.h"
4 6
5 7 static struct dentry *edac_debugfs;
6 8
9 + static ssize_t edac_fake_inject_write(struct file *file,
10 + const char __user *data,
11 + size_t count, loff_t *ppos)
12 + {
13 + struct device *dev = file->private_data;
14 + struct mem_ctl_info *mci = to_mci(dev);
15 + static enum hw_event_mc_err_type type;
16 + u16 errcount = mci->fake_inject_count;
17 +
18 + if (!errcount)
19 + errcount = 1;
20 +
21 + type = mci->fake_inject_ue ? HW_EVENT_ERR_UNCORRECTED
22 + : HW_EVENT_ERR_CORRECTED;
23 +
24 + printk(KERN_DEBUG
25 + "Generating %d %s fake error%s to %d.%d.%d to test core handling. NOTE: this won't test the driver-specific decoding logic.\n",
26 + errcount,
27 + (type == HW_EVENT_ERR_UNCORRECTED) ? "UE" : "CE",
28 + str_plural(errcount),
29 + mci->fake_inject_layer[0],
30 + mci->fake_inject_layer[1],
31 + mci->fake_inject_layer[2]
32 + );
33 + edac_mc_handle_error(type, mci, errcount, 0, 0, 0,
34 + mci->fake_inject_layer[0],
35 + mci->fake_inject_layer[1],
36 + mci->fake_inject_layer[2],
37 + "FAKE ERROR", "for EDAC testing only");
38 +
39 + return count;
40 + }
41 +
42 + static const struct file_operations debug_fake_inject_fops = {
43 + .open = simple_open,
44 + .write = edac_fake_inject_write,
45 + .llseek = generic_file_llseek,
46 + };
47 +
7 48 void __init edac_debugfs_init(void)
8 49 {
9 50 edac_debugfs = debugfs_create_dir("edac", NULL);
@@ -16,7 +57,29 @@ void edac_debugfs_exit(void)
16 57
17 58 void edac_create_debugfs_nodes(struct mem_ctl_info *mci)
18 59 {
19 - mci->debugfs = debugfs_create_dir(mci->dev.kobj.name, edac_debugfs);
60 + struct dentry *parent;
61 + char name[80];
62 + int i;
63 +
64 + parent = debugfs_create_dir(mci->dev.kobj.name, edac_debugfs);
65 +
66 + for (i = 0; i < mci->n_layers; i++) {
67 + sprintf(name, "fake_inject_%s",
68 + edac_layer_name[mci->layers[i].type]);
69 + debugfs_create_u8(name, S_IRUGO | S_IWUSR, parent,
70 + &mci->fake_inject_layer[i]);
71 + }
72 +
73 + debugfs_create_bool("fake_inject_ue", S_IRUGO | S_IWUSR, parent,
74 + &mci->fake_inject_ue);
75 +
76 + debugfs_create_u16("fake_inject_count", S_IRUGO | S_IWUSR, parent,
77 + &mci->fake_inject_count);
78 +
79 + debugfs_create_file("fake_inject", S_IWUSR, parent, &mci->dev,
80 + &debug_fake_inject_fops);
81 +
82 + mci->debugfs = parent;
20 83 }
21 84
22 85 /* Create a toplevel dir under EDAC's debugfs hierarchy */
modified drivers/edac/edac_device.c
@@ -342,10 +342,14 @@ static void edac_device_workq_teardown(struct edac_device_ctl_info *edac_dev)
342 342 }
343 343
344 344 /*
345 - * Stop any outstanding workq queued up at this time because sleep time will
346 - * be reset. Then restart the workq on the new delay.
345 + * edac_device_reset_delay_period
346 + *
347 + * need to stop any outstanding workq queued up at this time
348 + * because we will be resetting the sleep time.
349 + * Then restart the workq on the new delay
347 350 */
348 - void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev, unsigned int msec)
351 + void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
352 + unsigned long msec)
349 353 {
350 354 edac_dev->poll_msec = msec;
351 355 edac_dev->delay = msecs_to_jiffies(msec);
modified drivers/edac/edac_device_sysfs.c
@@ -84,23 +84,18 @@ static ssize_t edac_device_ctl_poll_msec_show(struct edac_device_ctl_info
84 84 return sprintf(data, "%u\n", ctl_info->poll_msec);
85 85 }
86 86
87 - static ssize_t edac_device_ctl_poll_msec_store(struct edac_device_ctl_info *ctl_info,
88 - const char *data, size_t count)
87 + static ssize_t edac_device_ctl_poll_msec_store(struct edac_device_ctl_info
88 + *ctl_info, const char *data,
89 + size_t count)
89 90 {
90 - unsigned int value;
91 - int ret;
91 + unsigned long value;
92 92
93 - /*
94 - * Get the value, make sure it is non-zero, must be at least one millisecond
95 - * for the delay period between scans.
93 + /* get the value and enforce that it is non-zero, must be at least
94 + * one millisecond for the delay period, between scans
95 + * Then cancel last outstanding delay for the work request
96 + * and set a new one.
96 97 */
97 - ret = kstrtouint(data, 0, &value);
98 - if (ret < 0)
99 - return ret;
100 -
101 - if (value < 1)
102 - return -EINVAL;
103 -
98 + value = simple_strtoul(data, NULL, 0);
104 99 edac_device_reset_delay_period(ctl_info, value);
105 100
106 101 return count;
modified drivers/edac/edac_mc_sysfs.c
@@ -129,7 +129,7 @@ static ssize_t dimmdev_location_show(struct device *dev,
129 129 ssize_t count;
130 130
131 131 count = edac_dimm_info_location(dimm, data, PAGE_SIZE);
132 - count += sysfs_emit_at(data, count, "\n");
132 + count += scnprintf(data + count, PAGE_SIZE - count, "\n");
133 133
134 134 return count;
135 135 }
modified drivers/edac/edac_module.h
@@ -52,7 +52,8 @@ bool edac_queue_work(struct delayed_work *work, unsigned long delay);
52 52 bool edac_stop_work(struct delayed_work *work);
53 53 bool edac_mod_work(struct delayed_work *work, unsigned long delay);
54 54
55 - extern void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev, unsigned int msec);
55 + extern void edac_device_reset_delay_period(struct edac_device_ctl_info
56 + *edac_dev, unsigned long msec);
56 57 extern void edac_mc_reset_delay_period(unsigned long value);
57 58
58 59 /*
modified drivers/edac/highbank_mc_edac.c
@@ -235,8 +235,10 @@ static int highbank_mc_probe(struct platform_device *pdev)
235 235 irq = platform_get_irq(pdev, 0);
236 236 res = devm_request_irq(&pdev->dev, irq, highbank_mc_err_handler,
237 237 0, dev_name(&pdev->dev), mci);
238 - if (res < 0)
238 + if (res < 0) {
239 + dev_err(&pdev->dev, "Unable to request irq %d\n", irq);
239 240 goto err2;
241 + }
240 242
241 243 devres_close_group(&pdev->dev, NULL);
242 244 return 0;
modified drivers/edac/ie31200_edac.c
@@ -416,23 +416,7 @@ static void populate_dimm_info(struct dimm_data *dd, u32 addr_decode, int dimm,
416 416 {
417 417 dd->size = field_get(cfg->reg_mad_dimm_size_mask[dimm], addr_decode) * cfg->reg_mad_dimm_size_granularity;
418 418 dd->ranks = field_get(cfg->reg_mad_dimm_rank_mask[dimm], addr_decode) + 1;
419 -
420 - switch (field_get(cfg->reg_mad_dimm_width_mask[dimm], addr_decode)) {
421 - case 0:
422 - dd->dtype = DEV_X8;
423 - break;
424 - case 1:
425 - dd->dtype = DEV_X16;
426 - break;
427 - case 2:
428 - dd->dtype = DEV_X32;
429 - break;
430 - case 3:
431 - dd->dtype = DEV_X64;
432 - break;
433 - default:
434 - dd->dtype = DEV_UNKNOWN;
435 - }
419 + dd->dtype = field_get(cfg->reg_mad_dimm_width_mask[dimm], addr_decode) + DEV_X8;
436 420 }
437 421
438 422 static void ie31200_get_dimm_config(struct mem_ctl_info *mci, void __iomem *window,
modified drivers/edac/igen6_edac.c
@@ -42,8 +42,7 @@
42 42
43 43 #define GET_BITFIELD(v, lo, hi) (((v) & GENMASK_ULL(hi, lo)) >> (lo))
44 44
45 - /* Probing upper bound, not a hardware capability limit. */
46 - #define MAX_IMC_TO_PROBE 8
45 + #define NUM_IMC 2 /* Max memory controllers */
47 46 #define NUM_CHANNELS 2 /* Max channels */
48 47 #define NUM_DIMMS 2 /* Max DIMMs per channel */
49 48
@@ -123,43 +122,6 @@
123 122 #define MEM_SLICE_HASH_MASK(v) (GET_BITFIELD(v, 6, 19) << 6)
124 123 #define MEM_SLICE_HASH_LSB_MASK_BIT(v) GET_BITFIELD(v, 24, 26)
125 124
126 - /*
127 - * A slice represents a portion of memory space participating in an
128 - * interleave relationship within the memory hierarchy.
129 - *
130 - * It can represent in different levels such as:
131 - *
132 - * - a pair of memory controllers
133 - * - a memory controller
134 - * - a memory channel
135 - * - a memory sub-channel / DIMM
136 - *
137 - * +--------+
138 - * | |
139 - * | Zone 1 |
140 - * | |
141 - * +--------+ +--------+
142 - * | | | |
143 - * | | | |
144 - * | Zone 0 | | Zone 0 |
145 - * | | | |
146 - * | | | |
147 - * +--------+ +--------+
148 - *
149 - * Slice L Slice S
150 - *
151 - * Memory space is divided into:
152 - *
153 - * - Zone 0 : Interleaved region
154 - * - Zone 1 : Non-interleaved region (upper part of the large slice).
155 - */
156 - struct slice {
157 - /* Slice address. */
158 - u64 addr;
159 - /* Slice that @addr belongs to. */
160 - int id;
161 - };
162 -
163 125 struct igen6_imc {
164 126 int mc;
165 127 struct mem_ctl_info *mci;
@@ -213,6 +175,8 @@ static struct res_config {
213 175 /* Set imc->dimm_{l_size,s_size,l_map}[chan]. */
214 176 void (*set_dimm_params)(struct igen6_imc *imc, int chan);
215 177 bool (*ibecc_available)(struct pci_dev *pdev);
178 + /* Extract error address logged in IBECC */
179 + u64 (*err_addr)(u64 ecclog);
216 180 /* Convert error address logged in IBECC to system physical address */
217 181 u64 (*err_addr_to_sys_addr)(u64 eaddr, int mc);
218 182 /* Convert error address logged in IBECC to integrated memory controller address */
@@ -220,11 +184,11 @@ static struct res_config {
220 184 } *res_cfg;
221 185
222 186 static struct igen6_pvt {
187 + struct igen6_imc imc[NUM_IMC];
223 188 void __iomem *memss_pma_cr;
224 189 u64 ms_hash;
225 190 u64 ms_s_size;
226 191 int ms_l_map;
227 - struct igen6_imc imc[];
228 192 } *igen6_pvt;
229 193
230 194 /* The top of low usable DRAM */
@@ -261,8 +225,7 @@ static char ecclog_buf[ECCLOG_POOL_SIZE];
261 225 static struct irq_work ecclog_irq_work;
262 226 static struct work_struct ecclog_work;
263 227
264 - /* SoC compute die IDs with IBECC capability. */
265 - /* Elkhart Lake */
228 + /* Compute die IDs for Elkhart Lake with IBECC */
266 229 #define DID_EHL_SKU5 0x4514
267 230 #define DID_EHL_SKU6 0x4528
268 231 #define DID_EHL_SKU7 0x452a
@@ -275,22 +238,22 @@ static struct work_struct ecclog_work;
275 238 #define DID_EHL_SKU14 0x4534
276 239 #define DID_EHL_SKU15 0x4536
277 240
278 - /* ICL-NNPI */
241 + /* Compute die IDs for ICL-NNPI with IBECC */
279 242 #define DID_ICL_SKU8 0x4581
280 243 #define DID_ICL_SKU10 0x4585
281 244 #define DID_ICL_SKU11 0x4589
282 245 #define DID_ICL_SKU12 0x458d
283 246
284 - /* Tiger Lake */
247 + /* Compute die IDs for Tiger Lake with IBECC */
285 248 #define DID_TGL_SKU 0x9a14
286 249
287 - /* Alder Lake */
250 + /* Compute die IDs for Alder Lake with IBECC */
288 251 #define DID_ADL_SKU1 0x4601
289 252 #define DID_ADL_SKU2 0x4602
290 253 #define DID_ADL_SKU3 0x4621
291 254 #define DID_ADL_SKU4 0x4641
292 255
293 - /* Alder Lake-N */
256 + /* Compute die IDs for Alder Lake-N with IBECC */
294 257 #define DID_ADL_N_SKU1 0x4614
295 258 #define DID_ADL_N_SKU2 0x4617
296 259 #define DID_ADL_N_SKU3 0x461b
@@ -304,38 +267,38 @@ static struct work_struct ecclog_work;
304 267 #define DID_ADL_N_SKU11 0x467c
305 268 #define DID_ADL_N_SKU12 0x4632
306 269
307 - /* Arizona Beach */
270 + /* Compute die IDs for Arizona Beach with IBECC */
308 271 #define DID_AZB_SKU1 0x4676
309 272
310 - /* Amston Lake */
273 + /* Compute did IDs for Amston Lake with IBECC */
311 274 #define DID_ASL_SKU1 0x464a
312 275 #define DID_ASL_SKU2 0x4646
313 276 #define DID_ASL_SKU3 0x4652
314 277
315 - /* Raptor Lake-P */
278 + /* Compute die IDs for Raptor Lake-P with IBECC */
316 279 #define DID_RPL_P_SKU1 0xa706
317 280 #define DID_RPL_P_SKU2 0xa707
318 281 #define DID_RPL_P_SKU3 0xa708
319 282 #define DID_RPL_P_SKU4 0xa716
320 283 #define DID_RPL_P_SKU5 0xa718
321 284
322 - /* Meteor Lake-PS */
285 + /* Compute die IDs for Meteor Lake-PS with IBECC */
323 286 #define DID_MTL_PS_SKU1 0x7d21
324 287 #define DID_MTL_PS_SKU2 0x7d22
325 288 #define DID_MTL_PS_SKU3 0x7d23
326 289 #define DID_MTL_PS_SKU4 0x7d24
327 290
328 - /* Meteor Lake-P */
291 + /* Compute die IDs for Meteor Lake-P with IBECC */
329 292 #define DID_MTL_P_SKU1 0x7d01
330 293 #define DID_MTL_P_SKU2 0x7d02
331 294 #define DID_MTL_P_SKU3 0x7d14
332 295
333 - /* Arrow Lake-UH */
296 + /* Compute die IDs for Arrow Lake-UH with IBECC */
334 297 #define DID_ARL_UH_SKU1 0x7d06
335 298 #define DID_ARL_UH_SKU2 0x7d20
336 299 #define DID_ARL_UH_SKU3 0x7d30
337 300
338 - /* Panther Lake-H */
301 + /* Compute die IDs for Panther Lake-H with IBECC */
339 302 #define DID_PTL_H_SKU1 0xb000
340 303 #define DID_PTL_H_SKU2 0xb001
341 304 #define DID_PTL_H_SKU3 0xb002
@@ -351,114 +314,15 @@ static struct work_struct ecclog_work;
351 314 #define DID_PTL_H_SKU13 0xb02a
352 315 #define DID_PTL_H_SKU14 0xb00a
353 316
354 - /* Starfire */
355 - #define DID_STF_SKU1 0xb02b
356 -
357 - /* Wildcat Lake */
317 + /* Compute die IDs for Wildcat Lake with IBECC */
358 318 #define DID_WCL_SKU1 0xfd00
359 319
360 - /* Nova Lake-H/HX */
320 + /* Compute die IDs for Nova Lake-H/HX with IBECC */
361 321 #define DID_NVL_H_SKU1 0xd701
362 322 #define DID_NVL_H_SKU2 0xd702
363 323 #define DID_NVL_H_SKU3 0xd704
364 324 #define DID_NVL_H_SKU4 0xd705
365 325
366 - /* Remove the interleave bit and shift upper part down to fill gap. */
367 - static u64 squeeze_addr(u64 addr, int intlv_bit)
368 - {
369 - u64 slice_addr;
370 -
371 - slice_addr = GET_BITFIELD(addr, intlv_bit + 1, 63) << intlv_bit;
372 - slice_addr |= GET_BITFIELD(addr, 0, intlv_bit - 1);
373 -
374 - return slice_addr;
375 - }
376 -
377 - /* Shift the upper bits up and insert a zero at the @intlv_bit bit position. */
378 - static u64 inflate_addr(u64 addr, int intlv_bit)
379 - {
380 - u64 inflated_addr;
381 -
382 - /* Insert a zero at @intlv_bit position. */
383 - inflated_addr = GET_BITFIELD(addr, intlv_bit, 63) << (intlv_bit + 1);
384 - inflated_addr |= GET_BITFIELD(addr, 0, intlv_bit - 1);
385 -
386 - return inflated_addr;
387 - }
388 -
389 - static u64 compute_hash(u64 addr, u64 hash_mask, u64 hash_base, int intlv_bit)
390 - {
391 - u64 hash_addr;
392 - int i;
393 -
394 - /*
395 - * In hash mode, @intlv_bit is the lowest selected bit of @addr
396 - * to be XORed. While @mask may or may not include this @intlv_bit,
397 - * we enforce that @mask includes @intlv_bit to ensure @intlv_bit is
398 - * XORed exactly once.
399 - */
400 - hash_mask |= BIT_ULL(intlv_bit);
401 - hash_addr = addr & hash_mask;
402 -
403 - for (i = 6; i < 20; i++)
404 - hash_base ^= (hash_addr >> i) & 1;
405 -
406 - return hash_base;
407 - }
408 -
409 - /*
410 - * Converts a higher-level address (system / IMC / channel) into a lower-level
411 - * slice address and identifier.
412 - */
413 - static void translate_to_lower_level(u64 addr, u64 hash_mask, u64 hash_base,
414 - int intlv_bit, u64 s_size, int l_map,
415 - struct slice *slice)
416 - {
417 - /* In non-interleave zone. */
418 - if (addr >= 2 * s_size) {
419 - slice->addr = addr - s_size;
420 - slice->id = l_map;
421 - return;
422 - }
423 -
424 - /* In interleave zone. */
425 - slice->addr = squeeze_addr(addr, intlv_bit);
426 -
427 - /* Non-hash mode. */
428 - if (!hash_mask) {
429 - slice->id = GET_BITFIELD(addr, intlv_bit, intlv_bit);
430 - return;
431 - }
432 -
433 - /* Hash mode. */
434 - slice->id = compute_hash(addr, hash_mask, hash_base, intlv_bit);
435 - }
436 -
437 - /* Reconstruct address for upper memory hierarchy level. */
438 - static u64 translate_to_upper_level(u64 addr, u64 hash_mask, u64 hash_base,
439 - int intlv_bit, u64 s_size)
440 - {
441 - u64 inflated_addr, hash_val;
442 -
443 - /* In non-interleave zone. */
444 - if (addr >= s_size)
445 - return addr + s_size;
446 -
447 - /*
448 - * In interleave zone.
449 - *
450 - * Insert a zero at @intlv_bit position.
451 - */
452 - inflated_addr = inflate_addr(addr, intlv_bit);
453 -
454 - /*
455 - * Reconstruct the removed interleave bit and use it to replace
456 - * the zero at @intlv_bit position.
457 - */
458 - hash_val = compute_hash(inflated_addr, hash_mask, hash_base, intlv_bit);
459 - return inflated_addr | (hash_val << intlv_bit);
460 - }
461 -
462 326 static int get_mchbar(struct pci_dev *pdev, u64 *mchbar)
463 327 {
464 328 union {
@@ -490,46 +354,6 @@ static int get_mchbar(struct pci_dev *pdev, u64 *mchbar)
490 354 return 0;
491 355 }
492 356
493 - /* Check whether the memory controller is absent. */
494 - static bool imc_absent(void __iomem *window)
495 - {
496 - return readl(window + MAD_INTER_CHANNEL_OFFSET) == ~0;
497 - }
498 -
499 - /* Return MMIO base address of the memory controller if it's present, otherwise return NULL. */
500 - static void __iomem *map_imc_window(u64 mchbar, int pmc)
501 - {
502 - void __iomem *window;
503 -
504 - window = ioremap(mchbar + pmc * MCHBAR_SIZE, MCHBAR_SIZE);
505 - if (!window)
506 - return NULL;
507 -
508 - if (imc_absent(window)) {
509 - iounmap(window);
510 - return NULL;
511 - }
512 -
513 - return window;
514 - }
515 -
516 - /* Return the number of present memory controllers. */
517 - static int get_imc_num(u64 mchbar)
518 - {
519 - void __iomem *window;
520 - int lmc, pmc;
521 -
522 - for (lmc = 0, pmc = 0; pmc < MAX_IMC_TO_PROBE; pmc++) {
523 - window = map_imc_window(mchbar, pmc);
524 - if (window) {
525 - iounmap(window);
526 - lmc++;
527 - }
528 - }
529 -
530 - return lmc;
531 - }
532 -
533 357 static bool ehl_ibecc_available(struct pci_dev *pdev)
534 358 {
535 359 u32 v;
@@ -626,9 +450,21 @@ static u64 mem_addr_to_sys_addr(u64 maddr)
626 450 return maddr;
627 451 }
628 452
453 + static u64 mem_slice_hash(u64 addr, u64 mask, u64 hash_init, int intlv_bit)
454 + {
455 + u64 hash_addr = addr & mask, hash = hash_init;
456 + u64 intlv = (addr >> intlv_bit) & 1;
457 + int i;
458 +
459 + for (i = 6; i < 20; i++)
460 + hash ^= (hash_addr >> i) & 1;
461 +
462 + return hash ^ intlv;
463 + }
464 +
629 465 static u64 tgl_err_addr_to_mem_addr(u64 eaddr, int mc)
630 466 {
631 - u64 mask, ms_s_size;
467 + u64 maddr, hash, mask, ms_s_size;
632 468 int intlv_bit;
633 469 u32 ms_hash;
634 470
@@ -641,7 +477,12 @@ static u64 tgl_err_addr_to_mem_addr(u64 eaddr, int mc)
641 477 mask = MEM_SLICE_HASH_MASK(ms_hash);
642 478 intlv_bit = MEM_SLICE_HASH_LSB_MASK_BIT(ms_hash) + 6;
643 479
644 - return translate_to_upper_level(eaddr, mask, mc, intlv_bit, ms_s_size);
480 + maddr = GET_BITFIELD(eaddr, intlv_bit, 63) << (intlv_bit + 1) |
481 + GET_BITFIELD(eaddr, 0, intlv_bit - 1);
482 +
483 + hash = mem_slice_hash(maddr, mask, mc, intlv_bit);
484 +
485 + return maddr | (hash << intlv_bit);
645 486 }
646 487
647 488 static u64 tgl_err_addr_to_sys_addr(u64 eaddr, int mc)
@@ -663,9 +504,8 @@ static u64 adl_err_addr_to_sys_addr(u64 eaddr, int mc)
663 504
664 505 static u64 adl_err_addr_to_imc_addr(u64 eaddr, int mc)
665 506 {
666 - u64 ms_s_size = igen6_pvt->ms_s_size;
507 + u64 imc_addr, ms_s_size = igen6_pvt->ms_s_size;
667 508 struct igen6_imc *imc = &igen6_pvt->imc[mc];
668 - struct slice slice;
669 509 int intlv_bit;
670 510 u32 mc_hash;
671 511
@@ -676,8 +516,15 @@ static u64 adl_err_addr_to_imc_addr(u64 eaddr, int mc)
676 516
677 517 intlv_bit = MAC_MC_HASH_LSB(mc_hash) + 6;
678 518
679 - translate_to_lower_level(eaddr, 0, 0, intlv_bit, ms_s_size, 0, &slice);
680 - return slice.addr;
519 + imc_addr = GET_BITFIELD(eaddr, intlv_bit + 1, 63) << intlv_bit |
520 + GET_BITFIELD(eaddr, 0, intlv_bit - 1);
521 +
522 + return imc_addr;
523 + }
524 +
525 + static u64 rpl_p_err_addr(u64 ecclog)
526 + {
527 + return field_get(res_cfg->reg_eccerrlog_addr_mask, ecclog);
681 528 }
682 529
683 530 static enum mem_type ptl_h_get_mem_type(struct igen6_imc *imc)
@@ -839,7 +686,6 @@ static struct res_config tgl_cfg = {
839 686 .err_addr_to_imc_addr = tgl_err_addr_to_imc_addr,
840 687 };
841 688
842 - /* Shared by Alder Lake, Alder Lake-N, Arizona Beach, Amston Lake, and Raptor Lake-P */
843 689 static struct res_config adl_cfg = {
844 690 .machine_check = true,
845 691 .num_imc = 2,
@@ -855,6 +701,37 @@ static struct res_config adl_cfg = {
855 701 .err_addr_to_imc_addr = adl_err_addr_to_imc_addr,
856 702 };
857 703
704 + static struct res_config adl_n_cfg = {
705 + .machine_check = true,
706 + .num_imc = 1,
707 + .reg_mchbar_mask = GENMASK_ULL(41, 17),
708 + .reg_tom_mask = GENMASK_ULL(41, 20),
709 + .reg_touud_mask = GENMASK_ULL(41, 20),
710 + .reg_eccerrlog_addr_mask = GENMASK_ULL(45, 5),
711 + .imc_base = 0xd800,
712 + .ibecc_base = 0xd400,
713 + .ibecc_error_log_offset = 0x68,
714 + .ibecc_available = tgl_ibecc_available,
715 + .err_addr_to_sys_addr = adl_err_addr_to_sys_addr,
716 + .err_addr_to_imc_addr = adl_err_addr_to_imc_addr,
717 + };
718 +
719 + static struct res_config rpl_p_cfg = {
720 + .machine_check = true,
721 + .num_imc = 2,
722 + .reg_mchbar_mask = GENMASK_ULL(41, 17),
723 + .reg_tom_mask = GENMASK_ULL(41, 20),
724 + .reg_touud_mask = GENMASK_ULL(41, 20),
725 + .reg_eccerrlog_addr_mask = GENMASK_ULL(45, 5),
726 + .imc_base = 0xd800,
727 + .ibecc_base = 0xd400,
728 + .ibecc_error_log_offset = 0x68,
729 + .ibecc_available = tgl_ibecc_available,
730 + .err_addr = rpl_p_err_addr,
731 + .err_addr_to_sys_addr = adl_err_addr_to_sys_addr,
732 + .err_addr_to_imc_addr = adl_err_addr_to_imc_addr,
733 + };
734 +
858 735 static struct res_config mtl_ps_cfg = {
859 736 .machine_check = true,
860 737 .num_imc = 2,
@@ -872,7 +749,6 @@ static struct res_config mtl_ps_cfg = {
872 749 .err_addr_to_imc_addr = adl_err_addr_to_imc_addr,
873 750 };
874 751
875 - /* Shared by Meteor Lake-P, Arrow Lake-UH, and Wildcat Lake */
876 752 static struct res_config mtl_p_cfg = {
877 753 .machine_check = true,
878 754 .num_imc = 2,
@@ -888,7 +764,6 @@ static struct res_config mtl_p_cfg = {
888 764 .err_addr_to_imc_addr = adl_err_addr_to_imc_addr,
889 765 };
890 766
891 - /* Shared by Panther Lake-H and Starfire */
892 767 static struct res_config ptl_h_cfg = {
893 768 .machine_check = true,
894 769 .num_imc = 2,
@@ -919,6 +794,21 @@ static struct res_config ptl_h_cfg = {
919 794 .err_addr_to_imc_addr = adl_err_addr_to_imc_addr,
920 795 };
921 796
797 + static struct res_config wcl_cfg = {
798 + .machine_check = true,
799 + .num_imc = 1,
800 + .reg_mchbar_mask = GENMASK_ULL(41, 17),
801 + .reg_tom_mask = GENMASK_ULL(41, 20),
802 + .reg_touud_mask = GENMASK_ULL(41, 20),
803 + .reg_eccerrlog_addr_mask = GENMASK_ULL(38, 5),
804 + .imc_base = 0xd800,
805 + .ibecc_base = 0xd400,
806 + .ibecc_error_log_offset = 0x170,
807 + .ibecc_available = mtl_p_ibecc_available,
808 + .err_addr_to_sys_addr = adl_err_addr_to_sys_addr,
809 + .err_addr_to_imc_addr = adl_err_addr_to_imc_addr,
810 + };
811 +
922 812 static struct res_config nvl_h_cfg = {
923 813 .machine_check = true,
924 814 .num_imc = 2,
@@ -971,27 +861,27 @@ static struct pci_device_id igen6_pci_tbl[] = {
971 861 { PCI_VDEVICE(INTEL, DID_ADL_SKU2), .driver_data = (kernel_ulong_t)&adl_cfg },
972 862 { PCI_VDEVICE(INTEL, DID_ADL_SKU3), .driver_data = (kernel_ulong_t)&adl_cfg },
973 863 { PCI_VDEVICE(INTEL, DID_ADL_SKU4), .driver_data = (kernel_ulong_t)&adl_cfg },
974 - { PCI_VDEVICE(INTEL, DID_ADL_N_SKU1), .driver_data = (kernel_ulong_t)&adl_cfg },
975 - { PCI_VDEVICE(INTEL, DID_ADL_N_SKU2), .driver_data = (kernel_ulong_t)&adl_cfg },
976 - { PCI_VDEVICE(INTEL, DID_ADL_N_SKU3), .driver_data = (kernel_ulong_t)&adl_cfg },
977 - { PCI_VDEVICE(INTEL, DID_ADL_N_SKU4), .driver_data = (kernel_ulong_t)&adl_cfg },
978 - { PCI_VDEVICE(INTEL, DID_ADL_N_SKU5), .driver_data = (kernel_ulong_t)&adl_cfg },
979 - { PCI_VDEVICE(INTEL, DID_ADL_N_SKU6), .driver_data = (kernel_ulong_t)&adl_cfg },
980 - { PCI_VDEVICE(INTEL, DID_ADL_N_SKU7), .driver_data = (kernel_ulong_t)&adl_cfg },
981 - { PCI_VDEVICE(INTEL, DID_ADL_N_SKU8), .driver_data = (kernel_ulong_t)&adl_cfg },
982 - { PCI_VDEVICE(INTEL, DID_ADL_N_SKU9), .driver_data = (kernel_ulong_t)&adl_cfg },
983 - { PCI_VDEVICE(INTEL, DID_ADL_N_SKU10), .driver_data = (kernel_ulong_t)&adl_cfg },
984 - { PCI_VDEVICE(INTEL, DID_ADL_N_SKU11), .driver_data = (kernel_ulong_t)&adl_cfg },
985 - { PCI_VDEVICE(INTEL, DID_ADL_N_SKU12), .driver_data = (kernel_ulong_t)&adl_cfg },
986 - { PCI_VDEVICE(INTEL, DID_AZB_SKU1), .driver_data = (kernel_ulong_t)&adl_cfg },
987 - { PCI_VDEVICE(INTEL, DID_ASL_SKU1), .driver_data = (kernel_ulong_t)&adl_cfg },
988 - { PCI_VDEVICE(INTEL, DID_ASL_SKU2), .driver_data = (kernel_ulong_t)&adl_cfg },
989 - { PCI_VDEVICE(INTEL, DID_ASL_SKU3), .driver_data = (kernel_ulong_t)&adl_cfg },
990 - { PCI_VDEVICE(INTEL, DID_RPL_P_SKU1), .driver_data = (kernel_ulong_t)&adl_cfg },
991 - { PCI_VDEVICE(INTEL, DID_RPL_P_SKU2), .driver_data = (kernel_ulong_t)&adl_cfg },
992 - { PCI_VDEVICE(INTEL, DID_RPL_P_SKU3), .driver_data = (kernel_ulong_t)&adl_cfg },
993 - { PCI_VDEVICE(INTEL, DID_RPL_P_SKU4), .driver_data = (kernel_ulong_t)&adl_cfg },
994 - { PCI_VDEVICE(INTEL, DID_RPL_P_SKU5), .driver_data = (kernel_ulong_t)&adl_cfg },
864 + { PCI_VDEVICE(INTEL, DID_ADL_N_SKU1), .driver_data = (kernel_ulong_t)&adl_n_cfg },
865 + { PCI_VDEVICE(INTEL, DID_ADL_N_SKU2), .driver_data = (kernel_ulong_t)&adl_n_cfg },
866 + { PCI_VDEVICE(INTEL, DID_ADL_N_SKU3), .driver_data = (kernel_ulong_t)&adl_n_cfg },
867 + { PCI_VDEVICE(INTEL, DID_ADL_N_SKU4), .driver_data = (kernel_ulong_t)&adl_n_cfg },
868 + { PCI_VDEVICE(INTEL, DID_ADL_N_SKU5), .driver_data = (kernel_ulong_t)&adl_n_cfg },
869 + { PCI_VDEVICE(INTEL, DID_ADL_N_SKU6), .driver_data = (kernel_ulong_t)&adl_n_cfg },
870 + { PCI_VDEVICE(INTEL, DID_ADL_N_SKU7), .driver_data = (kernel_ulong_t)&adl_n_cfg },
871 + { PCI_VDEVICE(INTEL, DID_ADL_N_SKU8), .driver_data = (kernel_ulong_t)&adl_n_cfg },
872 + { PCI_VDEVICE(INTEL, DID_ADL_N_SKU9), .driver_data = (kernel_ulong_t)&adl_n_cfg },
873 + { PCI_VDEVICE(INTEL, DID_ADL_N_SKU10), .driver_data = (kernel_ulong_t)&adl_n_cfg },
874 + { PCI_VDEVICE(INTEL, DID_ADL_N_SKU11), .driver_data = (kernel_ulong_t)&adl_n_cfg },
875 + { PCI_VDEVICE(INTEL, DID_ADL_N_SKU12), .driver_data = (kernel_ulong_t)&adl_n_cfg },
876 + { PCI_VDEVICE(INTEL, DID_AZB_SKU1), .driver_data = (kernel_ulong_t)&adl_n_cfg },
877 + { PCI_VDEVICE(INTEL, DID_ASL_SKU1), .driver_data = (kernel_ulong_t)&adl_n_cfg },
878 + { PCI_VDEVICE(INTEL, DID_ASL_SKU2), .driver_data = (kernel_ulong_t)&adl_n_cfg },
879 + { PCI_VDEVICE(INTEL, DID_ASL_SKU3), .driver_data = (kernel_ulong_t)&adl_n_cfg },
880 + { PCI_VDEVICE(INTEL, DID_RPL_P_SKU1), .driver_data = (kernel_ulong_t)&rpl_p_cfg },
881 + { PCI_VDEVICE(INTEL, DID_RPL_P_SKU2), .driver_data = (kernel_ulong_t)&rpl_p_cfg },
882 + { PCI_VDEVICE(INTEL, DID_RPL_P_SKU3), .driver_data = (kernel_ulong_t)&rpl_p_cfg },
883 + { PCI_VDEVICE(INTEL, DID_RPL_P_SKU4), .driver_data = (kernel_ulong_t)&rpl_p_cfg },
884 + { PCI_VDEVICE(INTEL, DID_RPL_P_SKU5), .driver_data = (kernel_ulong_t)&rpl_p_cfg },
995 885 { PCI_VDEVICE(INTEL, DID_MTL_PS_SKU1), .driver_data = (kernel_ulong_t)&mtl_ps_cfg },
996 886 { PCI_VDEVICE(INTEL, DID_MTL_PS_SKU2), .driver_data = (kernel_ulong_t)&mtl_ps_cfg },
997 887 { PCI_VDEVICE(INTEL, DID_MTL_PS_SKU3), .driver_data = (kernel_ulong_t)&mtl_ps_cfg },
@@ -1002,7 +892,6 @@ static struct pci_device_id igen6_pci_tbl[] = {
1002 892 { PCI_VDEVICE(INTEL, DID_ARL_UH_SKU1), .driver_data = (kernel_ulong_t)&mtl_p_cfg },
1003 893 { PCI_VDEVICE(INTEL, DID_ARL_UH_SKU2), .driver_data = (kernel_ulong_t)&mtl_p_cfg },
1004 894 { PCI_VDEVICE(INTEL, DID_ARL_UH_SKU3), .driver_data = (kernel_ulong_t)&mtl_p_cfg },
1005 - { PCI_VDEVICE(INTEL, DID_WCL_SKU1), .driver_data = (kernel_ulong_t)&mtl_p_cfg },
1006 895 { PCI_VDEVICE(INTEL, DID_PTL_H_SKU1), .driver_data = (kernel_ulong_t)&ptl_h_cfg },
1007 896 { PCI_VDEVICE(INTEL, DID_PTL_H_SKU2), .driver_data = (kernel_ulong_t)&ptl_h_cfg },
1008 897 { PCI_VDEVICE(INTEL, DID_PTL_H_SKU3), .driver_data = (kernel_ulong_t)&ptl_h_cfg },
@@ -1017,7 +906,7 @@ static struct pci_device_id igen6_pci_tbl[] = {
1017 906 { PCI_VDEVICE(INTEL, DID_PTL_H_SKU12), .driver_data = (kernel_ulong_t)&ptl_h_cfg },
1018 907 { PCI_VDEVICE(INTEL, DID_PTL_H_SKU13), .driver_data = (kernel_ulong_t)&ptl_h_cfg },
1019 908 { PCI_VDEVICE(INTEL, DID_PTL_H_SKU14), .driver_data = (kernel_ulong_t)&ptl_h_cfg },
1020 - { PCI_VDEVICE(INTEL, DID_STF_SKU1), .driver_data = (kernel_ulong_t)&ptl_h_cfg },
909 + { PCI_VDEVICE(INTEL, DID_WCL_SKU1), .driver_data = (kernel_ulong_t)&wcl_cfg },
1021 910 { PCI_VDEVICE(INTEL, DID_NVL_H_SKU1), .driver_data = (kernel_ulong_t)&nvl_h_cfg },
1022 911 { PCI_VDEVICE(INTEL, DID_NVL_H_SKU2), .driver_data = (kernel_ulong_t)&nvl_h_cfg },
1023 912 { PCI_VDEVICE(INTEL, DID_NVL_H_SKU3), .driver_data = (kernel_ulong_t)&nvl_h_cfg },
@@ -1118,13 +1007,55 @@ static void set_dimm_params(struct igen6_imc *imc, int chan)
1118 1007 imc->dimm_s_size[chan] = MAD_DIMM_CH_DIMM_S_SIZE(val);
1119 1008 }
1120 1009
1010 + static int decode_chan_idx(u64 addr, u64 mask, int intlv_bit)
1011 + {
1012 + u64 hash_addr = addr & mask, hash = 0;
1013 + u64 intlv = (addr >> intlv_bit) & 1;
1014 + int i;
1015 +
1016 + for (i = 6; i < 20; i++)
1017 + hash ^= (hash_addr >> i) & 1;
1018 +
1019 + return (int)hash ^ intlv;
1020 + }
1021 +
1022 + static u64 decode_channel_addr(u64 addr, int intlv_bit)
1023 + {
1024 + u64 channel_addr;
1025 +
1026 + /* Remove the interleave bit and shift upper part down to fill gap */
1027 + channel_addr = GET_BITFIELD(addr, intlv_bit + 1, 63) << intlv_bit;
1028 + channel_addr |= GET_BITFIELD(addr, 0, intlv_bit - 1);
1029 +
1030 + return channel_addr;
1031 + }
1032 +
1033 + static void decode_addr(u64 addr, u32 hash, u64 s_size, int l_map,
1034 + int *idx, u64 *sub_addr)
1035 + {
1036 + int intlv_bit = CHANNEL_HASH_LSB_MASK_BIT(hash) + 6;
1037 +
1038 + if (addr > 2 * s_size) {
1039 + *sub_addr = addr - s_size;
1040 + *idx = l_map;
1041 + return;
1042 + }
1043 +
1044 + if (CHANNEL_HASH_MODE(hash)) {
1045 + *sub_addr = decode_channel_addr(addr, intlv_bit);
1046 + *idx = decode_chan_idx(addr, CHANNEL_HASH_MASK(hash), intlv_bit);
1047 + } else {
1048 + *sub_addr = decode_channel_addr(addr, 6);
1049 + *idx = GET_BITFIELD(addr, 6, 6);
1050 + }
1051 + }
1052 +
1121 1053 static int igen6_decode(struct decoded_addr *res)
1122 1054 {
1123 1055 struct igen6_imc *imc = &igen6_pvt->imc[res->mc];
1124 - u64 addr = res->imc_addr, s_size;
1125 - int intlv_bit, l_map;
1126 - u32 hash, hash_mask;
1127 - struct slice slice;
1056 + u64 addr = res->imc_addr, sub_addr, s_size;
1057 + int idx, l_map;
1058 + u32 hash;
1128 1059
1129 1060 if (addr >= igen6_tom) {
1130 1061 edac_dbg(0, "Address 0x%llx out of range\n", addr);
@@ -1135,25 +1066,17 @@ static int igen6_decode(struct decoded_addr *res)
1135 1066 hash = readl(imc->window + CHANNEL_HASH_OFFSET);
1136 1067 s_size = imc->ch_s_size;
1137 1068 l_map = imc->ch_l_map;
1138 - hash_mask = CHANNEL_HASH_MODE(hash) ? CHANNEL_HASH_MASK(hash) : 0;
1139 - intlv_bit = CHANNEL_HASH_LSB_MASK_BIT(hash) + 6;
1140 -
1141 - translate_to_lower_level(addr, hash_mask, 0, intlv_bit, s_size, l_map, &slice);
1142 -
1143 - res->channel_idx = slice.id;
1144 - res->channel_addr = slice.addr;
1069 + decode_addr(addr, hash, s_size, l_map, &idx, &sub_addr);
1070 + res->channel_idx = idx;
1071 + res->channel_addr = sub_addr;
1145 1072
1146 1073 /* Decode sub-channel/DIMM */
1147 1074 hash = readl(imc->window + CHANNEL_EHASH_OFFSET);
1148 - s_size = imc->dimm_s_size[res->channel_idx];
1149 - l_map = imc->dimm_l_map[res->channel_idx];
1150 - hash_mask = CHANNEL_HASH_MODE(hash) ? CHANNEL_HASH_MASK(hash) : 0;
1151 - intlv_bit = CHANNEL_HASH_LSB_MASK_BIT(hash) + 6;
1152 -
1153 - translate_to_lower_level(res->channel_addr, hash_mask, 0, intlv_bit, s_size, l_map, &slice);
1154 -
1155 - res->sub_channel_idx = slice.id;
1156 - res->sub_channel_addr = slice.addr;
1075 + s_size = imc->dimm_s_size[idx];
1076 + l_map = imc->dimm_l_map[idx];
1077 + decode_addr(res->channel_addr, hash, s_size, l_map, &idx, &sub_addr);
1078 + res->sub_channel_idx = idx;
1079 + res->sub_channel_addr = sub_addr;
1157 1080
1158 1081 return 0;
1159 1082 }
@@ -1307,7 +1230,11 @@ static void ecclog_work_cb(struct work_struct *work)
1307 1230
1308 1231 llist_for_each_entry_safe(node, tmp, head, llnode) {
1309 1232 memset(&res, 0, sizeof(res));
1310 - eaddr = node->ecclog & res_cfg->reg_eccerrlog_addr_mask;
1233 + if (res_cfg->err_addr)
1234 + eaddr = res_cfg->err_addr(node->ecclog);
1235 + else
1236 + eaddr = node->ecclog & res_cfg->reg_eccerrlog_addr_mask;
1237 +
1311 1238 res.mc = node->mc;
1312 1239 res.sys_addr = res_cfg->err_addr_to_sys_addr(eaddr, res.mc);
1313 1240 res.imc_addr = res_cfg->err_addr_to_imc_addr(eaddr, res.mc);
@@ -1549,27 +1476,18 @@ static struct igen6_pvt *igen6_pvt_setup(struct pci_dev *pdev)
1549 1476 {
1550 1477 void __iomem *memss_pma_cr;
1551 1478 struct igen6_pvt *pvt;
1552 - int imc_num, rc;
1553 1479 u64 mchbar;
1480 + int rc;
1554 1481
1555 - rc = get_mchbar(pdev, &mchbar);
1556 - if (rc)
1482 + pvt = kzalloc_obj(*igen6_pvt);
1483 + if (!pvt)
1557 1484 return NULL;
1558 1485
1559 - imc_num = get_imc_num(mchbar);
1560 - if (!imc_num) {
1561 - igen6_printk(KERN_ERR, "No mc found.\n");
1486 + rc = get_mchbar(pdev, &mchbar);
1487 + if (rc) {
1488 + kfree(pvt);
1562 1489 return NULL;
1563 1490 }
1564 - edac_dbg(2, "%d mcs found.\n", imc_num);
1565 -
1566 - /* Use the runtime detected IMC count. */
1567 - if (res_cfg->num_imc != imc_num)
1568 - res_cfg->num_imc = imc_num;
1569 -
1570 - pvt = kzalloc_flex(*pvt, imc, imc_num);
1571 - if (!pvt)
1572 - return NULL;
1573 1491
1574 1492 memss_pma_cr = ioremap(mchbar, MCHBAR_SIZE * 2);
1575 1493 if (!memss_pma_cr) {
@@ -1654,6 +1572,12 @@ static void igen6_check(struct mem_ctl_info *mci)
1654 1572 irq_work_queue(&ecclog_irq_work);
1655 1573 }
1656 1574
1575 + /* Check whether the memory controller is absent. */
1576 + static bool igen6_imc_absent(void __iomem *window)
1577 + {
1578 + return readl(window + MAD_INTER_CHANNEL_OFFSET) == ~0;
1579 + }
1580 +
1657 1581 static void imc_release(struct device *dev)
1658 1582 {
1659 1583 /* Nothing to do, the 'imc' owns the 'dev' and will also release it. */
@@ -1765,15 +1689,26 @@ static int igen6_register_mcis(struct pci_dev *pdev, u64 mchbar)
1765 1689 {
1766 1690 void __iomem *window;
1767 1691 int lmc, pmc, rc;
1692 + u64 base;
1693 +
1694 + for (lmc = 0, pmc = 0; pmc < NUM_IMC; pmc++) {
1695 + base = mchbar + pmc * MCHBAR_SIZE;
1696 + window = ioremap(base, MCHBAR_SIZE);
1697 + if (!window) {
1698 + igen6_printk(KERN_ERR, "Failed to ioremap 0x%llx for mc%d\n", base, pmc);
1699 + rc = -ENOMEM;
1700 + goto out_unregister_mcis;
1701 + }
1768 1702
1769 - for (lmc = 0, pmc = 0; pmc < MAX_IMC_TO_PROBE; pmc++) {
1770 - window = map_imc_window(mchbar, pmc);
1771 - if (!window)
1703 + if (igen6_imc_absent(window)) {
1704 + iounmap(window);
1705 + edac_dbg(2, "Skip absent mc%d\n", pmc);
1772 1706 continue;
1707 + }
1773 1708
1774 1709 rc = igen6_register_mci(lmc, window, pdev);
1775 1710 if (rc)
1776 - goto err_unregister;
1711 + goto out_iounmap;
1777 1712
1778 1713 /* Done, if all present MCs are detected and registered. */
1779 1714 if (++lmc >= res_cfg->num_imc)
@@ -1793,8 +1728,10 @@ static int igen6_register_mcis(struct pci_dev *pdev, u64 mchbar)
1793 1728
1794 1729 return 0;
1795 1730
1796 - err_unregister:
1731 + out_iounmap:
1797 1732 iounmap(window);
1733 +
1734 + out_unregister_mcis:
1798 1735 igen6_unregister_mcis();
1799 1736
1800 1737 return rc;
modified drivers/edac/thunderx_edac.c
@@ -729,8 +729,10 @@ static int thunderx_lmc_probe(struct pci_dev *pdev,
729 729 thunderx_lmc_err_isr,
730 730 thunderx_lmc_threaded_isr, 0,
731 731 "[EDAC] ThunderX LMC", mci);
732 - if (ret)
732 + if (ret) {
733 + dev_err(&pdev->dev, "Cannot set ISR: %d\n", ret);
733 734 goto err_free;
735 + }
734 736
735 737 lmc->node = FIELD_GET(THUNDERX_NODE, pci_resource_start(pdev, 0));
736 738
modified drivers/edac/versalnet_edac.c
@@ -813,7 +813,7 @@ static int init_one_mc(struct mc_priv *priv, struct platform_device *pdev, int i
813 813 layers[1].is_virt_csrow = false;
814 814
815 815 rc = -ENOMEM;
816 - dev = kzalloc_obj(*dev);
816 + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
817 817 if (!dev)
818 818 return rc;
819 819
modified drivers/edac/xgene_edac.c
@@ -1924,8 +1924,11 @@ static int xgene_edac_probe(struct platform_device *pdev)
1924 1924 rc = devm_request_irq(&pdev->dev, irq,
1925 1925 xgene_edac_isr, IRQF_SHARED,
1926 1926 dev_name(&pdev->dev), edac);
1927 - if (rc)
1927 + if (rc) {
1928 + dev_err(&pdev->dev,
1929 + "Could not request IRQ %d\n", irq);
1928 1930 goto out_err;
1931 + }
1929 1932 }
1930 1933 }
1931 1934
modified drivers/firmware/arm_scmi/driver.c
@@ -1792,7 +1792,7 @@ static void *scmi_iterator_init(const struct scmi_protocol_handle *ph,
1792 1792 {
1793 1793 int ret;
1794 1794
1795 - struct scmi_iterator *i __free(kfree) = kzalloc_obj(*i);
1795 + struct scmi_iterator *i __free(kfree) = kzalloc(sizeof(*i), GFP_KERNEL);
1796 1796 if (!i)
1797 1797 return ERR_PTR(-ENOMEM);
1798 1798
modified drivers/firmware/qcom/qcom_tzmem.c
@@ -169,7 +169,7 @@ static int qcom_tzmem_init_area(struct qcom_tzmem_area *area)
169 169 {
170 170 int ret;
171 171
172 - u64 *handle __free(kfree) = kzalloc_obj(*handle);
172 + u64 *handle __free(kfree) = kzalloc(sizeof(*handle), GFP_KERNEL);
173 173 if (!handle)
174 174 return -ENOMEM;
175 175
@@ -197,7 +197,8 @@ static int qcom_tzmem_pool_add_memory(struct qcom_tzmem_pool *pool,
197 197 {
198 198 int ret;
199 199
200 - struct qcom_tzmem_area *area __free(kfree) = kzalloc_obj(*area, gfp);
200 + struct qcom_tzmem_area *area __free(kfree) = kzalloc(sizeof(*area),
201 + gfp);
201 202 if (!area)
202 203 return -ENOMEM;
203 204
@@ -414,7 +415,8 @@ void *qcom_tzmem_alloc(struct qcom_tzmem_pool *pool, size_t size, gfp_t gfp)
414 415
415 416 size = PAGE_ALIGN(size);
416 417
417 - struct qcom_tzmem_chunk *chunk __free(kfree) = kzalloc_obj(*chunk, gfp);
418 + struct qcom_tzmem_chunk *chunk __free(kfree) = kzalloc(sizeof(*chunk),
419 + gfp);
418 420 if (!chunk)
419 421 return NULL;
420 422
modified drivers/firmware/ti_sci.c
@@ -2386,7 +2386,7 @@ static int ti_sci_set_irq(const struct ti_sci_handle *handle, u32 valid_params,
2386 2386 if (ret || !(info->fw_caps & MSG_FLAG_CAPS_LPM_IRQ_CONTEXT_LOST))
2387 2387 goto end;
2388 2388
2389 - irq = kzalloc_obj(*irq);
2389 + irq = kzalloc_obj(*irq, GFP_KERNEL);
2390 2390 if (!irq) {
2391 2391 ti_sci_manage_irq(handle, valid_params, src_id, src_index,
2392 2392 dst_id, dst_host_irq, ia_id, vint,
modified drivers/fpga/dfl-afu-dma-region.c
@@ -316,7 +316,7 @@ int afu_dma_map_region(struct dfl_feature_dev_data *fdata,
316 316 if (user_addr + length < user_addr)
317 317 return -EINVAL;
318 318
319 - region = kzalloc_obj(*region);
319 + region = kzalloc(sizeof(*region), GFP_KERNEL);
320 320 if (!region)
321 321 return -ENOMEM;
322 322
modified drivers/gpio/gpio-aggregator.c
@@ -886,8 +886,8 @@ gpio_aggregator_make_device_sw_node(struct gpio_aggregator *aggr)
886 886 if (num_lines == 0)
887 887 return NULL;
888 888
889 - const char **line_names __free(kfree) = kzalloc_objs(*line_names,
890 - num_lines);
889 + const char **line_names __free(kfree) = kcalloc(
890 + num_lines, sizeof(*line_names), GFP_KERNEL);
891 891 if (!line_names)
892 892 return ERR_PTR(-ENOMEM);
893 893
modified drivers/gpio/gpio-mpsse.c
@@ -518,7 +518,7 @@ static void gpio_mpsse_irq_enable(struct irq_data *irqd)
518 518 * Can't be devm because it uses a non-raw spinlock (illegal in
519 519 * this context, where a raw spinlock is held by our caller)
520 520 */
521 - worker = kzalloc_obj(*worker, GFP_NOWAIT);
521 + worker = kzalloc(sizeof(*worker), GFP_NOWAIT);
522 522 if (!worker)
523 523 return;
524 524
modified drivers/gpio/gpio-sim.c
@@ -790,7 +790,8 @@ gpio_sim_make_bank_swnode(struct gpio_sim_bank *bank,
790 790
791 791 line_names_size = gpio_sim_get_line_names_size(bank);
792 792 if (line_names_size) {
793 - line_names = kzalloc_objs(*line_names, line_names_size);
793 + line_names = kcalloc(line_names_size, sizeof(*line_names),
794 + GFP_KERNEL);
794 795 if (!line_names)
795 796 return ERR_PTR(-ENOMEM);
796 797
modified drivers/gpio/gpio-virtuser.c
@@ -1429,7 +1429,8 @@ gpio_virtuser_make_device_swnode(struct gpio_virtuser_device *dev)
1429 1429 memset(properties, 0, sizeof(properties));
1430 1430
1431 1431 num_ids = list_count_nodes(&dev->lookup_list);
1432 - char **ids __free(kfree) = kzalloc_objs(*ids, num_ids + 1);
1432 + char **ids __free(kfree) = kcalloc(num_ids + 1, sizeof(*ids),
1433 + GFP_KERNEL);
1433 1434 if (!ids)
1434 1435 return ERR_PTR(-ENOMEM);
1435 1436
modified drivers/gpio/gpiolib-cdev.c
@@ -2653,7 +2653,7 @@ static int gpio_chrdev_open(struct inode *inode, struct file *file)
2653 2653 struct gpio_chardev_data *cdev;
2654 2654 int ret = -ENOMEM;
2655 2655
2656 - cdev = kzalloc_obj(*cdev);
2656 + cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
2657 2657 if (!cdev)
2658 2658 return -ENOMEM;
2659 2659
modified drivers/gpio/gpiolib.c
@@ -1178,7 +1178,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
1178 1178 int base = 0;
1179 1179 int ret;
1180 1180
1181 - gdev = kzalloc_obj(*gdev);
1181 + gdev = kzalloc(sizeof(*gdev), GFP_KERNEL);
1182 1182 if (!gdev)
1183 1183 return -ENOMEM;
1184 1184 gc->gpiodev = gdev;
@@ -1218,7 +1218,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
1218 1218 goto err_put_device;
1219 1219 gdev->ngpio = gc->ngpio;
1220 1220
1221 - gdev->descs = kzalloc_objs(*gdev->descs, gc->ngpio);
1221 + gdev->descs = kcalloc(gc->ngpio, sizeof(*gdev->descs), GFP_KERNEL);
1222 1222 if (!gdev->descs) {
1223 1223 ret = -ENOMEM;
1224 1224 goto err_put_device;
modified drivers/gpu/buddy.c
@@ -411,13 +411,16 @@ int gpu_buddy_init(struct gpu_buddy *mm, u64 size, u64 chunk_size)
411 411 if (!mm->used_scoreboard)
412 412 goto out_free_free_scoreboard;
413 413
414 - mm->free_trees = kmalloc_objs(*mm->free_trees, GPU_BUDDY_MAX_FREE_TREES);
414 + mm->free_trees = kmalloc_array(GPU_BUDDY_MAX_FREE_TREES,
415 + sizeof(*mm->free_trees),
416 + GFP_KERNEL);
415 417 if (!mm->free_trees)
416 418 goto out_free_used_scoreboard;
417 419
418 420 for_each_free_tree(i) {
419 - mm->free_trees[i] = kmalloc_objs(struct rb_root,
420 - mm->max_order + 1);
421 + mm->free_trees[i] = kmalloc_array(mm->max_order + 1,
422 + sizeof(struct rb_root),
423 + GFP_KERNEL);
421 424 if (!mm->free_trees[i])
422 425 goto out_free_tree;
423 426
@@ -427,7 +430,9 @@ int gpu_buddy_init(struct gpu_buddy *mm, u64 size, u64 chunk_size)
427 430
428 431 mm->n_roots = hweight64(size);
429 432
430 - mm->roots = kmalloc_objs(struct gpu_buddy_block *, mm->n_roots);
433 + mm->roots = kmalloc_array(mm->n_roots,
434 + sizeof(struct gpu_buddy_block *),
435 + GFP_KERNEL);
431 436 if (!mm->roots)
432 437 goto out_free_tree;
433 438
modified drivers/gpu/drm/amd/amdgpu/amdgpu_dev_coredump.c
@@ -299,10 +299,10 @@ amdgpu_devcoredump_print_ibs(struct drm_printer *p,
299 299 amdgpu_res_first(abo->tbo.resource, offset,
300 300 coredump->ibs[i].ib_size_dw * 4, &cursor);
301 301 while (cursor.remaining) {
302 - amdgpu_device_mm_access(adev, cursor.start,
303 - &ib_content[off], cursor.size,
302 + amdgpu_device_mm_access(adev, cursor.start / 4,
303 + &ib_content[off], cursor.size / 4,
304 304 false);
305 - off += cursor.size / 4;
305 + off += cursor.size;
306 306 amdgpu_res_next(&cursor, cursor.size);
307 307 }
308 308 emit_content = true;
@@ -603,8 +603,9 @@ void amdgpu_coredump(struct amdgpu_device *adev, bool skip_vram_check,
603 603 ring_count++;
604 604 }
605 605 if (ring_count)
606 - coredump->rings = kvzalloc_objs(struct amdgpu_coredump_ring,
607 - ring_count, GFP_NOWAIT);
606 + coredump->rings = kvcalloc(ring_count,
607 + sizeof(struct amdgpu_coredump_ring),
608 + GFP_NOWAIT);
608 609 if (coredump->rings) {
609 610 for (i = 0, idx = 0; i < adev->num_rings && idx < ring_count; i++) {
610 611 struct amdgpu_coredump_ring *cdump_ring;
modified drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -771,9 +771,6 @@ static int amdgpu_device_read_fb_via_bar0(struct amdgpu_device *adev,
771 771 if (!buf || !size)
772 772 return -EINVAL;
773 773
774 - if (!amdgpu_sriov_vf(adev))
775 - return -EINVAL;
776 -
777 774 flags = pci_resource_flags(adev->pdev, 0);
778 775 if ((flags & IORESOURCE_UNSET) || !(flags & IORESOURCE_MEM))
779 776 return -EINVAL;
modified drivers/gpu/drm/amd/amdgpu/amdgpu_discovery.c
@@ -1608,11 +1608,11 @@ int amdgpu_discovery_sysfs_early_init(struct amdgpu_device *adev, struct pci_dev
1608 1608
1609 1609 discovery_bin = adev->discovery.bin;
1610 1610
1611 - early_entry = kzalloc_obj(*early_entry);
1611 + early_entry = kzalloc(sizeof(*early_entry), GFP_KERNEL);
1612 1612 if (!early_entry)
1613 1613 return -ENOMEM;
1614 1614
1615 - ip_top = kzalloc_obj(*ip_top);
1615 + ip_top = kzalloc(sizeof(*ip_top), GFP_KERNEL);
1616 1616 if (!ip_top) {
1617 1617 kfree(early_entry);
1618 1618 return -ENOMEM;
modified drivers/gpu/drm/amd/amdgpu/amdgpu_lockdep.c
@@ -98,7 +98,7 @@ int amdgpu_lockdep_init(void)
98 98 struct amdgpu_lockdep_dummy_locks *locks;
99 99 unsigned long flags;
100 100
101 - locks = kzalloc_obj(*locks);
101 + locks = kzalloc(sizeof(*locks), GFP_KERNEL);
102 102 if (!locks)
103 103 return -ENOMEM;
104 104
modified drivers/gpu/drm/amd/amdgpu/amdgpu_mes.c
@@ -879,7 +879,7 @@ bool amdgpu_mes_queue_reset_by_mes_supported(struct amdgpu_device *adev)
879 879
880 880 return (ip_maj == 11 && mes_sched >= 0x8c) ||
881 881 ((ip_maj == 12 && ip_min == 0) && mes_sched >= 0x8d) ||
882 - ((ip_maj == 12 && ip_min == 1) && mes_sched >= 0x7b);
882 + ((ip_maj == 12 && ip_min == 1) && mes_sched >= 0x73);
883 883 }
884 884
885 885 /* Fix me -- node_id is used to identify the correct MES instances in the future */
modified drivers/gpu/drm/amd/amdgpu/amdgpu_psp.c
@@ -396,12 +396,6 @@ static bool psp_get_runtime_db_entry(struct amdgpu_device *adev,
396 396 bool ret = false;
397 397 int i;
398 398
399 - /*
400 - * Runtime DB is for dGPUs only.
401 - */
402 - if (adev->flags & AMD_IS_APU)
403 - return false;
404 -
405 399 if (amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(13, 0, 6) ||
406 400 amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(13, 0, 12) ||
407 401 amdgpu_ip_version(adev, MP0_HWIP, 0) == IP_VERSION(13, 0, 14) ||
modified drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c
@@ -1293,7 +1293,7 @@ amdgpu_ras_debugfs_table_read_uniras(struct amdgpu_device *adev,
1293 1293 return -ENOMEM;
1294 1294
1295 1295 if (num_recs) {
1296 - records = kvzalloc_objs(*records, num_recs);
1296 + records = kvcalloc(num_recs, sizeof(*records), GFP_KERNEL);
1297 1297 if (!records) {
1298 1298 res = -ENOMEM;
1299 1299 goto out;
modified drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2361,8 +2361,9 @@ void amdgpu_ttm_enable_buffer_funcs(struct amdgpu_device *adev)
2361 2361 num_clear_entities = MIN(adev->mman.num_buffer_funcs_scheds, TTM_NUM_MOVE_FENCES);
2362 2362 num_move_entities = MIN(adev->mman.num_buffer_funcs_scheds, TTM_NUM_MOVE_FENCES);
2363 2363
2364 - adev->mman.clear_entities = kzalloc_objs(struct amdgpu_ttm_buffer_entity,
2365 - num_clear_entities);
2364 + adev->mman.clear_entities = kcalloc(num_clear_entities,
2365 + sizeof(struct amdgpu_ttm_buffer_entity),
2366 + GFP_KERNEL);
2366 2367 atomic_set(&adev->mman.next_clear_entity, 0);
2367 2368 if (!adev->mman.clear_entities)
2368 2369 goto error_free_default_entity;
modified drivers/gpu/drm/amd/amdgpu/amdgpu_umc.c
@@ -159,8 +159,8 @@ void amdgpu_umc_handle_bad_pages(struct amdgpu_device *adev,
159 159 adev->umc.ras->ecc_info_query_ras_error_address &&
160 160 adev->umc.max_ras_err_cnt_per_query) {
161 161 err_data->err_addr =
162 - kzalloc_objs(struct eeprom_table_record,
163 - adev->umc.max_ras_err_cnt_per_query);
162 + kcalloc(adev->umc.max_ras_err_cnt_per_query,
163 + sizeof(struct eeprom_table_record), GFP_KERNEL);
164 164
165 165 /* still call query_ras_error_address to clear error status
166 166 * even NOMEM error is encountered
modified drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
@@ -1544,7 +1544,7 @@ int amdgpu_userq_post_reset(struct amdgpu_device *adev, bool vram_lost)
1544 1544 struct amdgpu_usermode_queue *queue;
1545 1545 const struct amdgpu_userq_funcs *userq_funcs;
1546 1546 unsigned long queue_id;
1547 - int ret = 0, r;
1547 + int r = 0;
1548 1548
1549 1549 xa_for_each(&adev->userq_doorbell_xa, queue_id, queue) {
1550 1550 if (queue->state == AMDGPU_USERQ_STATE_HUNG && !vram_lost) {
@@ -1555,7 +1555,6 @@ int amdgpu_userq_post_reset(struct amdgpu_device *adev, bool vram_lost)
1555 1555 r = userq_funcs->map(queue);
1556 1556 if (r) {
1557 1557 dev_err(adev->dev, "Failed to remap queue %ld\n", queue_id);
1558 - ret = r;
1559 1558 continue;
1560 1559 }
1561 1560 trace_amdgpu_userq_state_changed(queue, AMDGPU_USERQ_STATE_MAPPED);
@@ -1563,5 +1562,5 @@ int amdgpu_userq_post_reset(struct amdgpu_device *adev, bool vram_lost)
1563 1562 }
1564 1563 }
1565 1564
1566 - return ret;
1565 + return r;
1567 1566 }
modified drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
@@ -227,7 +227,7 @@ static int amdgpu_userq_fence_alloc(struct amdgpu_usermode_queue *userq,
227 227 struct amdgpu_userq_fence *userq_fence;
228 228 void *entry;
229 229
230 - userq_fence = kmalloc_obj(*userq_fence);
230 + userq_fence = kmalloc(sizeof(*userq_fence), GFP_KERNEL);
231 231 if (!userq_fence)
232 232 return -ENOMEM;
233 233
@@ -244,7 +244,9 @@ static int amdgpu_userq_fence_alloc(struct amdgpu_usermode_queue *userq,
244 244 } while (xas_retry(&xas, entry));
245 245 rcu_read_unlock();
246 246
247 - userq_fence->fence_drv_array = kvmalloc_objs(fence_drv, xas.xa_index);
247 + userq_fence->fence_drv_array = kvmalloc_array(xas.xa_index,
248 + sizeof(fence_drv),
249 + GFP_KERNEL);
248 250 if (!userq_fence->fence_drv_array) {
249 251 mutex_unlock(&userq->fence_drv_lock);
250 252 kfree(userq_fence);
modified drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -316,8 +316,8 @@ static int amdgpu_virt_ras_realloc_eh_data_space(struct amdgpu_device *adev,
316 316 if (align_space > AMDGPU_VIRT_RAS_BAD_PAGE_TABLE_MAX_CAPACITY)
317 317 return -ENOMEM;
318 318
319 - new_bps = kmalloc_objs(*data->bps, align_space);
320 - new_bo = kzalloc_objs(*data->bps_bo, align_space);
319 + new_bps = kmalloc_array(align_space, sizeof(*data->bps), GFP_KERNEL);
320 + new_bo = kcalloc(align_space, sizeof(*data->bps_bo), GFP_KERNEL);
321 321 if (!new_bps || !new_bo) {
322 322 kfree(new_bps);
323 323 kfree(new_bo);
@@ -355,7 +355,7 @@ static int amdgpu_virt_init_ras_err_handler_data(struct amdgpu_device *adev)
355 355 if (!bps)
356 356 goto bps_failure;
357 357
358 - bps_bo = kzalloc_objs(*(*data)->bps_bo, align_space);
358 + bps_bo = kcalloc(align_space, sizeof(*(*data)->bps_bo), GFP_KERNEL);
359 359 if (!bps_bo)
360 360 goto bps_bo_failure;
361 361
modified drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -2090,7 +2090,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev,
2090 2090 after->start = eaddr + 1;
2091 2091 after->last = tmp->last;
2092 2092 after->offset = tmp->offset;
2093 - after->offset += (after->start - tmp->start) << AMDGPU_GPU_PAGE_SHIFT;
2093 + after->offset += (after->start - tmp->start) << PAGE_SHIFT;
2094 2094 after->flags = tmp->flags;
2095 2095 after->bo_va = tmp->bo_va;
2096 2096 list_add(&after->list, &tmp->bo_va->invalids);
@@ -3122,7 +3122,7 @@ static void amdgpu_debugfs_vm_bo_status_info(struct seq_file *m,
3122 3122
3123 3123 id = 0;
3124 3124 seq_puts(m, "\tIdle BOs:\n");
3125 - list_for_each_entry(base, &lists->idle, vm_status) {
3125 + list_for_each_entry(base, &lists->needs_update, vm_status) {
3126 3126 if (!base->bo)
3127 3127 continue;
3128 3128
modified drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c
@@ -1651,10 +1651,10 @@ static int gfx_v11_0_sw_init(struct amdgpu_ip_block *ip_block)
1651 1651 case IP_VERSION(11, 0, 2):
1652 1652 case IP_VERSION(11, 0, 3):
1653 1653 if (!adev->gfx.disable_uq &&
1654 - adev->gfx.me_fw_version >= 3090 &&
1655 - adev->gfx.pfp_fw_version >= 3190 &&
1656 - adev->gfx.mec_fw_version >= 3450 &&
1657 - adev->mes.fw_version[0] >= 147) {
1654 + adev->gfx.me_fw_version >= 2420 &&
1655 + adev->gfx.pfp_fw_version >= 2580 &&
1656 + adev->gfx.mec_fw_version >= 2650 &&
1657 + adev->mes.fw_version[0] >= 120) {
1658 1658 adev->userq_funcs[AMDGPU_HW_IP_GFX] = &userq_mes_funcs;
1659 1659 adev->userq_funcs[AMDGPU_HW_IP_COMPUTE] = &userq_mes_funcs;
1660 1660 }
modified drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c
@@ -1436,10 +1436,10 @@ static int gfx_v12_0_sw_init(struct amdgpu_ip_block *ip_block)
1436 1436 case IP_VERSION(12, 0, 0):
1437 1437 case IP_VERSION(12, 0, 1):
1438 1438 if (!adev->gfx.disable_uq &&
1439 - adev->gfx.me_fw_version >= 3090 &&
1440 - adev->gfx.pfp_fw_version >= 3190 &&
1441 - adev->gfx.mec_fw_version >= 3450 &&
1442 - adev->mes.fw_version[0] >= 147) {
1439 + adev->gfx.me_fw_version >= 2780 &&
1440 + adev->gfx.pfp_fw_version >= 2840 &&
1441 + adev->gfx.mec_fw_version >= 3050 &&
1442 + adev->mes.fw_version[0] >= 123) {
1443 1443 adev->userq_funcs[AMDGPU_HW_IP_GFX] = &userq_mes_funcs;
1444 1444 adev->userq_funcs[AMDGPU_HW_IP_COMPUTE] = &userq_mes_funcs;
1445 1445 }
modified drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -4546,11 +4546,9 @@ static int gfx_v8_0_mqd_init(struct amdgpu_ring *ring)
4546 4546 /* set static priority for a queue/ring */
4547 4547 gfx_v8_0_mqd_set_priority(ring, mqd);
4548 4548 tmp = RREG32(mmCP_HQD_QUANTUM);
4549 - if (ring != &adev->gfx.kiq[0].ring) {
4550 - tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_EN, 1);
4551 - tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE, 1);
4552 - tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 10);
4553 - }
4549 + tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_EN, 1);
4550 + tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_SCALE, 1);
4551 + tmp = REG_SET_FIELD(tmp, CP_HQD_QUANTUM, QUANTUM_DURATION, 10);
4554 4552 mqd->cp_hqd_quantum = tmp;
4555 4553
4556 4554 /* map_queues packet doesn't need activate the queue,
modified drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
@@ -1921,13 +1921,13 @@ static int criu_checkpoint_devices(struct kfd_process *p,
1921 1921 struct kfd_criu_device_bucket *device_buckets = NULL;
1922 1922 int ret = 0, i;
1923 1923
1924 - device_buckets = kvzalloc_objs(*device_buckets, num_devices);
1924 + device_buckets = kvcalloc(num_devices, sizeof(*device_buckets), GFP_KERNEL);
1925 1925 if (!device_buckets) {
1926 1926 ret = -ENOMEM;
1927 1927 goto exit;
1928 1928 }
1929 1929
1930 - device_priv = kvzalloc_objs(*device_priv, num_devices);
1930 + device_priv = kvcalloc(num_devices, sizeof(*device_priv), GFP_KERNEL);
1931 1931 if (!device_priv) {
1932 1932 ret = -ENOMEM;
1933 1933 goto exit;
@@ -2047,17 +2047,17 @@ static int criu_checkpoint_bos(struct kfd_process *p,
2047 2047 int ret = 0, pdd_index, bo_index = 0, id;
2048 2048 void *mem;
2049 2049
2050 - bo_buckets = kvzalloc_objs(*bo_buckets, num_bos);
2050 + bo_buckets = kvcalloc(num_bos, sizeof(*bo_buckets), GFP_KERNEL);
2051 2051 if (!bo_buckets)
2052 2052 return -ENOMEM;
2053 2053
2054 - bo_privs = kvzalloc_objs(*bo_privs, num_bos);
2054 + bo_privs = kvcalloc(num_bos, sizeof(*bo_privs), GFP_KERNEL);
2055 2055 if (!bo_privs) {
2056 2056 ret = -ENOMEM;
2057 2057 goto exit;
2058 2058 }
2059 2059
2060 - files = kvzalloc_objs(struct file *, num_bos);
2060 + files = kvcalloc(num_bos, sizeof(struct file *), GFP_KERNEL);
2061 2061 if (!files) {
2062 2062 ret = -ENOMEM;
2063 2063 goto exit;
@@ -2588,7 +2588,7 @@ static int criu_restore_bos(struct kfd_process *p,
2588 2588 if (!bo_buckets)
2589 2589 return -ENOMEM;
2590 2590
2591 - files = kvzalloc_objs(struct file *, args->num_bos);
2591 + files = kvcalloc(args->num_bos, sizeof(struct file *), GFP_KERNEL);
2592 2592 if (!files) {
2593 2593 ret = -ENOMEM;
2594 2594 goto exit;
modified drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c
@@ -1455,14 +1455,6 @@ static int evict_process_queues_cpsch(struct device_queue_manager *dqm,
1455 1455 dqm_evict_mqd_bo(dqm, q);
1456 1456 }
1457 1457
1458 - /*
1459 - * Heavy-weight TLB flush after MES removes queues to ensure
1460 - * in-flight memory accesses complete before memory is freed/migrated.
1461 - * HWS does this automatically, MES does not.
1462 - */
1463 - if (dqm->dev->kfd->shared_resources.enable_mes)
1464 - kfd_flush_tlb(pdd);
1465 -
1466 1458 if (!dqm->dev->kfd->shared_resources.enable_mes) {
1467 1459 pdd->last_evict_timestamp = get_jiffies_64();
1468 1460 retval = execute_queues_cpsch(dqm,
@@ -3754,11 +3746,8 @@ int suspend_queues(struct kfd_process *p,
3754 3746 if (!per_device_suspended) {
3755 3747 dqm_unlock(dqm);
3756 3748 mutex_unlock(&p->event_mutex);
3757 - if (total_suspended) {
3749 + if (total_suspended)
3758 3750 amdgpu_amdkfd_debug_mem_fence(dqm->dev->adev);
3759 - /* Heavy-weight TLB flush after MES suspends queues */
3760 - kfd_flush_tlb(pdd);
3761 - }
3762 3751 continue;
3763 3752 }
3764 3753
modified drivers/gpu/drm/amd/amdkfd/kfd_process_queue_manager.c
@@ -1169,13 +1169,13 @@ int pqm_debugfs_mqds(struct seq_file *m, void *data)
1169 1169 mqd_mgr = q->device->dqm->mqd_mgrs[mqd_type];
1170 1170 size = mqd_mgr->mqd_stride(mqd_mgr,
1171 1171 &q->properties);
1172 + }
1172 1173
1173 - for (xcc = 0; xcc < num_xccs; xcc++) {
1174 - mqd = q->mqd + size * xcc;
1175 - r = mqd_mgr->debugfs_show_mqd(m, mqd);
1176 - if (r != 0)
1177 - break;
1178 - }
1174 + for (xcc = 0; xcc < num_xccs; xcc++) {
1175 + mqd = q->mqd + size * xcc;
1176 + r = mqd_mgr->debugfs_show_mqd(m, mqd);
1177 + if (r != 0)
1178 + break;
1179 1179 }
1180 1180 }
1181 1181
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3879,7 +3879,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_commit *state,
3879 3879 continue;
3880 3880
3881 3881 bundle->surface_updates[planes_count].surface = dc_plane;
3882 - if (new_pcrtc_state->color_mgmt_changed || new_plane_state->color_mgmt_changed) {
3882 + if (new_pcrtc_state->color_mgmt_changed) {
3883 3883 bundle->surface_updates[planes_count].gamma = &dc_plane->gamma_correction;
3884 3884 bundle->surface_updates[planes_count].in_transfer_func = &dc_plane->in_transfer_func;
3885 3885 bundle->surface_updates[planes_count].gamut_remap_matrix = &dc_plane->gamut_remap_matrix;
@@ -5698,10 +5698,6 @@ static bool should_reset_plane(struct drm_atomic_commit *state,
5698 5698 if (new_crtc_state->color_mgmt_changed)
5699 5699 return true;
5700 5700
5701 - /* Plane color pipeline or its colorop changes. */
5702 - if (new_plane_state->color_mgmt_changed)
5703 - return true;
5704 -
5705 5701 /*
5706 5702 * On zpos change, planes need to be reordered by removing and re-adding
5707 5703 * them one by one to the dc state, in order of descending zpos.
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_backlight.c
@@ -534,12 +534,8 @@ void amdgpu_dm_update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
534 534 else if (!IS_ERR_OR_NULL(panel_backlight_quirk) &&
535 535 panel_backlight_quirk->force_pwm)
536 536 caps->aux_support = false;
537 - if (caps->aux_support) {
538 - if (aconnector->dc_link->dpcd_caps.panel_luminance_control)
539 - aconnector->dc_link->backlight_control_type = BACKLIGHT_CONTROL_VESA_AUX;
540 - else
541 - aconnector->dc_link->backlight_control_type = BACKLIGHT_CONTROL_AMD_AUX;
542 - }
537 + if (caps->aux_support)
538 + aconnector->dc_link->backlight_control_type = BACKLIGHT_CONTROL_AMD_AUX;
543 539
544 540 luminance_range = &conn_base->display_info.luminance_range;
545 541
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
@@ -2208,41 +2208,16 @@ int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
2208 2208 if (res)
2209 2209 return res;
2210 2210
2211 - /* Blend mode support varies on DCE generations according to HW caps
2212 - * and number of planes per CRTC. However, as current driver
2213 - * implementation only creates one primary and one cursor plane per
2214 - * CRTC for DCE (overlay is only created if
2215 - * DC_PLANE_TYPE_DCN_UNIVERSAL), the primary plane blend mode is
2216 - * ignored across DCE versions. Keep PREMULTI to avoid uAPI
2217 - * regressions: it was the default/mandatory mode for many years and,
2218 - * with no overlay plane, primary composes on top of a black
2219 - * background, where PREMULTI and PIXEL_NONE are equivalent.
2220 - */
2221 - if (plane_cap && plane_cap->type != DC_PLANE_TYPE_DCN_UNIVERSAL) {
2222 - unsigned int blend_caps = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
2223 - BIT(DRM_MODE_BLEND_PREMULTI);
2224 -
2225 - drm_plane_create_blend_mode_property(plane, blend_caps);
2226 - } else if ((plane->type == DRM_PLANE_TYPE_OVERLAY ||
2227 - plane->type == DRM_PLANE_TYPE_PRIMARY) &&
2228 - plane_cap && plane_cap->per_pixel_alpha) {
2211 + if (plane->type == DRM_PLANE_TYPE_OVERLAY &&
2212 + plane_cap && plane_cap->per_pixel_alpha) {
2229 2213 unsigned int blend_caps = BIT(DRM_MODE_BLEND_PIXEL_NONE) |
2230 2214 BIT(DRM_MODE_BLEND_PREMULTI) |
2231 2215 BIT(DRM_MODE_BLEND_COVERAGE);
2232 2216
2217 + drm_plane_create_alpha_property(plane);
2233 2218 drm_plane_create_blend_mode_property(plane, blend_caps);
2234 -
2235 - if (plane->type == DRM_PLANE_TYPE_OVERLAY)
2236 - drm_plane_create_alpha_property(plane);
2237 2219 }
2238 2220
2239 - /* Cursor color format is set to CURSOR_MODE_COLOR_PRE_MULTIPLIED_ALPHA
2240 - * by default, so only advertise DRM_MODE_BLEND_PREMULTI blend mode for
2241 - * this type of plane.
2242 - */
2243 - if (plane->type == DRM_PLANE_TYPE_CURSOR)
2244 - drm_plane_create_blend_mode_property(plane, BIT(DRM_MODE_BLEND_PREMULTI));
2245 -
2246 2221 if (plane->type == DRM_PLANE_TYPE_PRIMARY) {
2247 2222 /*
2248 2223 * Allow OVERLAY planes to be used as underlays by assigning an
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c
@@ -4180,7 +4180,7 @@ dm_test_destroy_connector(struct kunit *test, struct drm_device *drm)
4180 4180 {
4181 4181 struct amdgpu_dm_connector *aconnector;
4182 4182
4183 - aconnector = kzalloc_obj(*aconnector);
4183 + aconnector = kzalloc(sizeof(*aconnector), GFP_KERNEL);
4184 4184 KUNIT_ASSERT_NOT_NULL(test, aconnector);
4185 4185
4186 4186 KUNIT_ASSERT_EQ(test,
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_crtc_test.c
@@ -1445,7 +1445,7 @@ static void dm_test_crtc_destroy_state_no_stream(struct kunit *test)
1445 1445 struct dm_crtc_state *dm_state;
1446 1446
1447 1447 /* destroy_state kfree()s the state, so use a plain (unmanaged) alloc. */
1448 - dm_state = kzalloc_obj(*dm_state);
1448 + dm_state = kzalloc_obj(*dm_state, GFP_KERNEL);
1449 1449 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dm_state);
1450 1450
1451 1451 amdgpu_dm_crtc_destroy_state(NULL, &dm_state->base);
@@ -1475,7 +1475,7 @@ static void dm_test_crtc_destroy_state_releases_stream(struct kunit *test)
1475 1475 kref_get(&stream->refcount);
1476 1476
1477 1477 /* destroy_state kfree()s the state, so use a plain (unmanaged) alloc. */
1478 - dm_state = kzalloc_obj(*dm_state);
1478 + dm_state = kzalloc_obj(*dm_state, GFP_KERNEL);
1479 1479 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dm_state);
1480 1480 dm_state->stream = stream;
1481 1481
@@ -1569,7 +1569,7 @@ static void dm_test_crtc_handle_vblank_completes_cursor_only(struct kunit *test)
1569 1569 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, acrtc);
1570 1570
1571 1571 /* drm_crtc_send_vblank_event() consumes (kfree()s) the event. */
1572 - event = kzalloc_obj(*event);
1572 + event = kzalloc_obj(*event, GFP_KERNEL);
1573 1573 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, event);
1574 1574
1575 1575 acrtc->base.dev = &adev->ddev;
@@ -1628,7 +1628,7 @@ dm_test_vblank_control_worker_setup(struct kunit *test, bool enable,
1628 1628 kref_get(&stream->refcount);
1629 1629
1630 1630 /* Worker kfree()s the work item, so it must be a plain allocation. */
1631 - work = kzalloc_obj(*work);
1631 + work = kzalloc_obj(*work, GFP_KERNEL);
1632 1632 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, work);
1633 1633 work->dm = &adev->dm;
1634 1634 work->acrtc = acrtc;
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_irq_test.c
@@ -103,7 +103,7 @@ static enum dc_status dm_test_dp_read_hpd_rx_irq_data_ok(struct dc_link *link,
103 103 */
104 104 static struct dc_sink *dm_test_sink_create(struct dc_link *link)
105 105 {
106 - struct dc_sink *sink = kzalloc_obj(*sink);
106 + struct dc_sink *sink = kzalloc(sizeof(*sink), GFP_KERNEL);
107 107
108 108 if (!sink)
109 109 return NULL;
@@ -2131,7 +2131,7 @@ static void dm_test_hpd_rx_offload_work_no_connector(struct kunit *test)
2131 2131 offload_wq = kunit_kzalloc(test, sizeof(*offload_wq), GFP_KERNEL);
2132 2132 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_wq);
2133 2133
2134 - offload_work = kzalloc_obj(*offload_work);
2134 + offload_work = kzalloc(sizeof(*offload_work), GFP_KERNEL);
2135 2135 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_work);
2136 2136 offload_work->offload_wq = offload_wq;
2137 2137 offload_work->adev = adev;
@@ -2177,7 +2177,7 @@ static void dm_test_hpd_rx_offload_work_no_connection(struct kunit *test)
2177 2177 link->dc = dc;
2178 2178 aconn->dc_link = link;
2179 2179
2180 - offload_work = kzalloc_obj(*offload_work);
2180 + offload_work = kzalloc(sizeof(*offload_work), GFP_KERNEL);
2181 2181 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_work);
2182 2182 offload_work->offload_wq = offload_wq;
2183 2183 offload_work->adev = adev;
@@ -2244,7 +2244,7 @@ static void dm_test_hpd_rx_offload_work_automated_test(struct kunit *test)
2244 2244 link->connector_signal = SIGNAL_TYPE_DISPLAY_PORT;
2245 2245 aconn->dc_link = link;
2246 2246
2247 - offload_work = kzalloc_obj(*offload_work);
2247 + offload_work = kzalloc(sizeof(*offload_work), GFP_KERNEL);
2248 2248 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_work);
2249 2249 offload_work->offload_wq = offload_wq;
2250 2250 offload_work->adev = adev;
@@ -2315,7 +2315,7 @@ static void dm_test_hpd_rx_offload_work_link_loss(struct kunit *test)
2315 2315 link->connector_signal = SIGNAL_TYPE_DISPLAY_PORT;
2316 2316 aconn->dc_link = link;
2317 2317
2318 - offload_work = kzalloc_obj(*offload_work);
2318 + offload_work = kzalloc(sizeof(*offload_work), GFP_KERNEL);
2319 2319 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, offload_work);
2320 2320 offload_work->offload_wq = offload_wq;
2321 2321 offload_work->adev = adev;
@@ -3452,9 +3452,9 @@ static void dm_test_handle_hpd_work_out_of_range(struct kunit *test)
3452 3452 struct amdgpu_device *adev;
3453 3453
3454 3454 adev = dm_kunit_alloc_adev(test);
3455 - hpd_work = kzalloc_obj(*hpd_work);
3455 + hpd_work = kzalloc(sizeof(*hpd_work), GFP_KERNEL);
3456 3456 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hpd_work);
3457 - hpd_work->dmub_notify = kzalloc_obj(*hpd_work->dmub_notify);
3457 + hpd_work->dmub_notify = kzalloc(sizeof(*hpd_work->dmub_notify), GFP_KERNEL);
3458 3458 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, hpd_work->dmub_notify);
3459 3459 hpd_work->dmub_notify->type =
3460 3460 (enum dmub_notification_type)ARRAY_SIZE(adev->dm.dmub_callback);
@@ -3899,9 +3899,9 @@ static void dm_test_handle_vmin_vmax_update(struct kunit *test)
3899 3899 kref_get(&stream->refcount);
3900 3900
3901 3901 /* The worker kfree()s both, so they must come from the slab. */
3902 - work = kzalloc_obj(*work);
3902 + work = kzalloc(sizeof(*work), GFP_KERNEL);
3903 3903 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, work);
3904 - adjust = kzalloc_obj(*adjust);
3904 + adjust = kzalloc(sizeof(*adjust), GFP_KERNEL);
3905 3905 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, adjust);
3906 3906
3907 3907 work->adev = adev;
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_plane_test.c
@@ -2945,7 +2945,7 @@ static void dm_test_plane_reset_initializes_state(struct kunit *test)
2945 2945 * destroy-existing-state path. The destroy hook frees this state, so it
2946 2946 * must be a plain (non-KUnit-managed) allocation.
2947 2947 */
2948 - old_state = kzalloc_obj(*old_state);
2948 + old_state = kzalloc(sizeof(*old_state), GFP_KERNEL);
2949 2949 KUNIT_ASSERT_NOT_NULL(test, old_state);
2950 2950 plane->funcs = &dm_test_plane_reset_funcs;
2951 2951 plane->state = &old_state->base;
@@ -3018,7 +3018,7 @@ static void dm_test_plane_destroy_state_minimal(struct kunit *test)
3018 3018 KUNIT_ASSERT_NOT_NULL(test, plane);
3019 3019
3020 3020 /* destroy_state frees the state itself, so use a plain allocation. */
3021 - dm_plane_state = kzalloc_obj(*dm_plane_state);
3021 + dm_plane_state = kzalloc(sizeof(*dm_plane_state), GFP_KERNEL);
3022 3022 KUNIT_ASSERT_NOT_NULL(test, dm_plane_state);
3023 3023
3024 3024 amdgpu_dm_plane_drm_plane_destroy_state(plane, &dm_plane_state->base);
modified drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_test.c
@@ -239,7 +239,7 @@ static void dm_test_atomic_destroy_state_no_context(struct kunit *test)
239 239 * Use kzalloc(), not kunit_kzalloc(): dm_atomic_destroy_state() frees
240 240 * the state itself, so KUnit-managed memory would be double-freed.
241 241 */
242 - dm_state = kzalloc_obj(*dm_state);
242 + dm_state = kzalloc(sizeof(*dm_state), GFP_KERNEL);
243 243 KUNIT_ASSERT_NOT_NULL(test, dm_state);
244 244
245 245 /* context == NULL: dc_state_release() is skipped and the state is freed. */
modified drivers/gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c
@@ -377,7 +377,7 @@ struct clk_mgr *dc_clk_mgr_create(struct dc_context *ctx, struct pp_smu_funcs *p
377 377 }
378 378 break;
379 379 case AMDGPU_FAMILY_GC_11_5_4: {
380 - struct clk_mgr_dcn42 *clk_mgr = kzalloc_obj(*clk_mgr);
380 + struct clk_mgr_dcn42 *clk_mgr = kzalloc(sizeof(*clk_mgr), GFP_KERNEL);
381 381
382 382 if (clk_mgr == NULL) {
383 383 BREAK_TO_DEBUGGER();
modified drivers/gpu/drm/amd/display/dc/clk_mgr/dcn60/dcn60_clk_mgr.c
@@ -1595,7 +1595,7 @@ struct clk_mgr_internal *dcn60_clk_mgr_construct(
1595 1595 struct dccg *dccg)
1596 1596 {
1597 1597 struct clk_log_info log_info = {0};
1598 - struct dcn60_clk_mgr *clk_mgr60 = kzalloc_obj(struct dcn60_clk_mgr);
1598 + struct dcn60_clk_mgr *clk_mgr60 = kzalloc(sizeof(struct dcn60_clk_mgr), GFP_KERNEL);
1599 1599 struct clk_mgr_internal *clk_mgr;
1600 1600
1601 1601 if (!clk_mgr60)
@@ -1644,7 +1644,7 @@ struct clk_mgr_internal *dcn60_clk_mgr_construct(
1644 1644
1645 1645 clk_mgr->smu_present = false;
1646 1646
1647 - clk_mgr->base.bw_params = kzalloc_obj(*clk_mgr->base.bw_params);
1647 + clk_mgr->base.bw_params = kzalloc(sizeof(*clk_mgr->base.bw_params), GFP_KERNEL);
1648 1648 if (!clk_mgr->base.bw_params)
1649 1649 goto fail;
1650 1650
modified drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -914,7 +914,8 @@ static bool dc_construct_update_scratch_pool(struct dc *dc)
914 914 unsigned int i;
915 915
916 916 for (i = 0; i < ARRAY_SIZE(dc->update_scratch_pool); i++) {
917 - dc->update_scratch_pool[i] = kzalloc_obj(struct dc_update_scratch_space);
917 + dc->update_scratch_pool[i] = kzalloc(
918 + sizeof(struct dc_update_scratch_space), GFP_KERNEL);
918 919 if (!dc->update_scratch_pool[i])
919 920 return false;
920 921 dc->update_scratch_in_use[i] = false;
modified drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -1797,11 +1797,7 @@ bool resource_can_pipe_disable_cursor(struct pipe_ctx *pipe_ctx)
1797 1797 * pipe-split, merge together per same height.
1798 1798 */
1799 1799 for (split_pipe = pipe_ctx->top_pipe; split_pipe;
1800 - split_pipe = split_pipe->top_pipe) {
1801 -
1802 - if (split_pipe == test_pipe)
1803 - continue;
1804 -
1800 + split_pipe = split_pipe->top_pipe)
1805 1801 if (split_pipe->plane_state->layer_index == test_pipe->plane_state->layer_index) {
1806 1802 struct rect r2_half;
1807 1803
@@ -1813,7 +1809,6 @@ bool resource_can_pipe_disable_cursor(struct pipe_ctx *pipe_ctx)
1813 1809 r2_bottom = min(r2_bottom, r2_half.y + r2_half.height);
1814 1810 break;
1815 1811 }
1816 - }
1817 1812
1818 1813 if (r1.x >= r2.x && r1.y >= r2.y && r1_right <= r2_right && r1_bottom <= r2_bottom)
1819 1814 return true;
modified drivers/gpu/drm/amd/display/dc/core/dc_surface.c
@@ -290,7 +290,7 @@ static void dc_plane_cm_free(struct kref *kref)
290 290
291 291 struct dc_plane_cm *dc_plane_cm_create(void)
292 292 {
293 - struct dc_plane_cm *cm = kvzalloc_obj(*cm);
293 + struct dc_plane_cm *cm = kvzalloc(sizeof(*cm), GFP_KERNEL);
294 294
295 295 if (cm == NULL)
296 296 goto alloc_fail;
modified drivers/gpu/drm/amd/display/dc/dccg/dcn42/dcn42_dccg.c
@@ -358,7 +358,7 @@ struct dccg *dccg42_create(
358 358 const struct dccg_shift *dccg_shift,
359 359 const struct dccg_mask *dccg_mask)
360 360 {
361 - struct dcn_dccg *dccg_dcn = kzalloc_obj(*dccg_dcn);
361 + struct dcn_dccg *dccg_dcn = kzalloc(sizeof(*dccg_dcn), GFP_KERNEL);
362 362 struct dccg *base;
363 363
364 364 if (dccg_dcn == NULL) {
modified drivers/gpu/drm/amd/display/dc/dccg/dcn60/dcn60_dccg.c
@@ -167,7 +167,7 @@ struct dccg *dccg60_create(
167 167 const struct dccg_shift *dccg_shift,
168 168 const struct dccg_mask *dccg_mask)
169 169 {
170 - struct dcn_dccg *dccg_dcn = kzalloc_obj(*dccg_dcn);
170 + struct dcn_dccg *dccg_dcn = kzalloc(sizeof(*dccg_dcn), GFP_KERNEL);
171 171 struct dccg *base;
172 172
173 173 if (dccg_dcn == NULL) {
modified drivers/gpu/drm/amd/display/dc/dcn30/dcn30_cm_common.c
@@ -320,8 +320,6 @@ static struct fixed31_32 interp_tf_pts(const struct fixed31_32 *output_tf_channe
320 320 return value;
321 321 }
322 322
323 - #define NUM_DEGAMMA_REGIONS 9
324 -
325 323 bool cm3_helper_translate_curve_to_degamma_hw_format(
326 324 const struct dc_transfer_func *output_tf,
327 325 struct pwl_params *lut_params)
@@ -345,15 +343,31 @@ bool cm3_helper_translate_curve_to_degamma_hw_format(
345 343 memset(lut_params, 0, sizeof(struct pwl_params));
346 344 memset(seg_distr, 0, sizeof(seg_distr));
347 345
348 - /* 9 segments
349 - * segments are from 2^-9 to 2^0
350 - */
351 - seg_distr[0] = 0; // Since we only have one point in darkest region
352 - for (k = 1; k < NUM_DEGAMMA_REGIONS; k++)
353 - seg_distr[k] = k - 1; // 2^(k-1) points per region; halves as k decreases
346 + if (output_tf->tf == TRANSFER_FUNCTION_PQ ||
347 + output_tf->tf == TRANSFER_FUNCTION_SRGB) {
348 + /* 9 segments
349 + * segments are from 2^-9 to 0
350 + */
351 + const uint8_t SEG_COUNT = 9;
352 + seg_distr[0] = 0; // Since we only have one point in darkest region
353 + for (k = 1; k < SEG_COUNT; k++)
354 + seg_distr[k] = k - 1; // 2^(k-1) points per region; halves as k decreases
355 +
356 + region_start = -SEG_COUNT;
357 + region_end = 0;
358 + } else {
359 + /* 12 segments
360 + * segments are from 2^-12 to 2^0
361 + * There are less than 256 points, for optimization
362 + */
363 + const uint8_t SEG_COUNT = 12;
354 364
355 - region_start = -NUM_DEGAMMA_REGIONS;
356 - region_end = 0;
365 + for (i = 0; i < SEG_COUNT; i++)
366 + seg_distr[i] = 4;
367 +
368 + region_start = -SEG_COUNT;
369 + region_end = 0;
370 + }
357 371
358 372 for (i = region_end - region_start; i < MAX_REGIONS_NUMBER ; i++)
359 373 seg_distr[i] = -1;
modified drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_dcn5_funcs_mode_programming.c
@@ -1128,8 +1128,8 @@ static bool dcn5_mode_programming(struct dml2_core_calcs_mode_programming_ex *in
1128 1128 CalculateWatermarks_params->USRRetrainingSupport = &mode_lib->mp.USRRetrainingSupport;
1129 1129 CalculateWatermarks_params->temp_read_or_ppt_support = mode_lib->mp.temp_read_or_ppt_support;
1130 1130 CalculateWatermarks_params->global_temp_read_or_ppt_supported = &mode_lib->mp.global_temp_read_or_ppt_supported;
1131 - CalculateWatermarks_params->VActiveLatencyHidingMargin = NULL;
1132 - CalculateWatermarks_params->VActiveLatencyHidingUs = NULL;
1131 + CalculateWatermarks_params->VActiveLatencyHidingMargin = 0;
1132 + CalculateWatermarks_params->VActiveLatencyHidingUs = 0;
1133 1133
1134 1134 dcn5_calculate_watermarks_and_dram_speed_change_support(&mode_lib->scratch, CalculateWatermarks_params);
1135 1135
modified drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_core/dml2_core_shared_types.h
@@ -1819,8 +1819,8 @@ struct dml2_core_calcs_CalculateWatermarksMALLUseAndDRAMSpeedChangeSupport_param
1819 1819 bool UnboundedRequestEnabled;
1820 1820 unsigned int CompressedBufferSizeInkByte;
1821 1821 bool max_outstanding_when_urgent_expected;
1822 - unsigned int max_outstanding_requests;
1823 - unsigned int max_request_size_bytes;
1822 + const unsigned int max_outstanding_requests;
1823 + const unsigned int max_request_size_bytes;
1824 1824 const unsigned int *meta_row_height_l;
1825 1825 const unsigned int *meta_row_height_c;
1826 1826 const enum dml2_pstate_method *uclk_pstate_switch_modes;
modified drivers/gpu/drm/amd/display/dc/dml2_0/dml21/src/dml2_pmo/dml2_pmo_dcn6_stage_optimizers.c
@@ -1414,7 +1414,7 @@ static bool find_shift_for_valid_cache_id_assignment(const int *mcache_boundarie
1414 1414 success = true;
1415 1415 for (pipe_index = 0; pipe_index < pipe_count; pipe_index++) {
1416 1416 if (!calculate_first_second_splitting(mcache_boundaries, num_boundaries, *shift,
1417 - pipe_vp_startx[pipe_index], pipe_vp_endx[pipe_index], NULL, NULL)) {
1417 + pipe_vp_startx[pipe_index], pipe_vp_endx[pipe_index], 0, 0)) {
1418 1418 success = false;
1419 1419 break;
1420 1420 }
modified drivers/gpu/drm/amd/display/dc/dml2_0/dml2_translation_helper.c
@@ -301,7 +301,6 @@ void dml2_init_socbb_params(struct dml2_context *dml2, const struct dc *in_dc, s
301 301 out->smn_latency_us = 2;
302 302 out->dispclk_dppclk_vco_speed_mhz = 3600;
303 303 out->pct_ideal_dram_bw_after_urgent_pixel_only = 65.0;
304 - out->gpuvm_min_page_size_kbytes = 4;
305 304 break;
306 305
307 306
modified drivers/gpu/drm/amd/display/dc/gpio/hw_ddc.c
@@ -542,7 +542,7 @@ void dal_hw_ddc_init_i3cpad(
542 542 *hw_ddc = NULL;
543 543 }
544 544
545 - *hw_ddc = kzalloc_obj(struct hw_ddc);
545 + *hw_ddc = kzalloc(sizeof(struct hw_ddc), GFP_KERNEL);
546 546 if (!*hw_ddc) {
547 547 ASSERT_CRITICAL(false);
548 548 return;
modified drivers/gpu/drm/amd/display/dc/irq/dcn42/irq_service_dcn42.c
@@ -405,7 +405,7 @@ static void dcn42_irq_construct(struct irq_service *irq_service,
405 405
406 406 struct irq_service *dal_irq_service_dcn42_create(struct irq_service_init_data *init_data)
407 407 {
408 - struct irq_service *irq_service = kzalloc_obj(*irq_service);
408 + struct irq_service *irq_service = kzalloc(sizeof(*irq_service), GFP_KERNEL);
409 409
410 410 if (!irq_service)
411 411 return NULL;
modified drivers/gpu/drm/amd/display/dc/irq/dcn60/irq_service_dcn60.c
@@ -406,7 +406,8 @@ static void dcn60_irq_construct(
406 406 struct irq_service *dal_irq_service_dcn60_create(
407 407 struct irq_service_init_data *init_data)
408 408 {
409 - struct irq_service *irq_service = kzalloc_obj(*irq_service);
409 + struct irq_service *irq_service = kzalloc(sizeof(*irq_service),
410 + GFP_KERNEL);
410 411
411 412 if (!irq_service)
412 413 return NULL;
modified drivers/gpu/drm/amd/display/dc/pg/dcn42/dcn42_pg_cntl.c
@@ -615,7 +615,7 @@ struct pg_cntl *pg_cntl42_create(
615 615 const struct pg_cntl_shift *pg_cntl_shift,
616 616 const struct pg_cntl_mask *pg_cntl_mask)
617 617 {
618 - struct dcn_pg_cntl *pg_cntl_dcn = kzalloc_obj(*pg_cntl_dcn);
618 + struct dcn_pg_cntl *pg_cntl_dcn = kzalloc(sizeof(*pg_cntl_dcn), GFP_KERNEL);
619 619 struct pg_cntl *base;
620 620
621 621 if (pg_cntl_dcn == NULL) {
modified drivers/gpu/drm/amd/display/dc/resource/dcn30/dcn30_resource.c
@@ -1135,7 +1135,7 @@ static struct hpo_frl_stream_encoder *dcn30_hpo_frl_stream_encoder_create(enum e
1135 1135 }
1136 1136
1137 1137 /* allocate HPO stream encoder and create VPG sub-block */
1138 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
1138 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
1139 1139 vpg = dcn30_vpg_create(ctx, vpg_inst);
1140 1140 afmt = dcn30_afmt_create(ctx, afmt_inst);
1141 1141
@@ -1166,7 +1166,7 @@ static struct hpo_frl_link_encoder *dcn30_hpo_frl_link_encoder_create(enum engin
1166 1166 ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
1167 1167
1168 1168 /* allocate HPO link encoder */
1169 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1169 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1170 1170 if (!hpo_enc3)
1171 1171 return NULL; /* out of memory */
1172 1172
modified drivers/gpu/drm/amd/display/dc/resource/dcn302/dcn302_resource.c
@@ -492,7 +492,7 @@ static struct hpo_frl_stream_encoder *dcn302_hpo_frl_stream_encoder_create(enum
492 492 return NULL;
493 493
494 494 /* allocate HPO stream encoder and create VPG sub-block */
495 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
495 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
496 496 vpg = dcn302_vpg_create(ctx, vpg_inst);
497 497 afmt = dcn302_afmt_create(ctx, afmt_inst);
498 498
@@ -531,7 +531,7 @@ static struct hpo_frl_link_encoder *dcn302_hpo_frl_link_encoder_create(enum engi
531 531 ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
532 532
533 533 /* allocate HPO link encoder */
534 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
534 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
535 535 if (!hpo_enc3)
536 536 return NULL; /* out of memory */
537 537
modified drivers/gpu/drm/amd/display/dc/resource/dcn303/dcn303_resource.c
@@ -479,7 +479,7 @@ static struct hpo_frl_stream_encoder *dcn303_hpo_frl_stream_encoder_create(enum
479 479 return NULL;
480 480
481 481 /* allocate HPO stream encoder and create VPG sub-block */
482 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
482 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
483 483 vpg = dcn303_vpg_create(ctx, vpg_inst);
484 484 afmt = dcn303_afmt_create(ctx, afmt_inst);
485 485
@@ -518,7 +518,7 @@ static struct hpo_frl_link_encoder *dcn303_hpo_frl_link_encoder_create(enum engi
518 518 ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
519 519
520 520 /* allocate HPO link encoder */
521 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
521 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
522 522 if (!hpo_enc3)
523 523 return NULL; /* out of memory */
524 524
modified drivers/gpu/drm/amd/display/dc/resource/dcn31/dcn31_resource.c
@@ -1346,7 +1346,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(enum e
1346 1346 }
1347 1347
1348 1348 /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
1349 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
1349 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
1350 1350 vpg = dcn31_vpg_create(ctx, vpg_inst);
1351 1351 afmt = dcn31_afmt_create(ctx, afmt_inst);
1352 1352
@@ -1377,7 +1377,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(enum engin
1377 1377 ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
1378 1378
1379 1379 /* allocate HPO link encoder */
1380 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1380 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1381 1381 if (!hpo_enc3)
1382 1382 return NULL; /* out of memory */
1383 1383
modified drivers/gpu/drm/amd/display/dc/resource/dcn314/dcn314_resource.c
@@ -1404,7 +1404,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(enum e
1404 1404 }
1405 1405
1406 1406 /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
1407 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
1407 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
1408 1408 vpg = dcn31_vpg_create(ctx, vpg_inst);
1409 1409 afmt = dcn31_afmt_create(ctx, afmt_inst);
1410 1410
@@ -1436,7 +1436,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(enum engin
1436 1436 ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
1437 1437
1438 1438 /* allocate HPO link encoder */
1439 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1439 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1440 1440 if (!hpo_enc3)
1441 1441 return NULL; /* out of memory */
1442 1442
modified drivers/gpu/drm/amd/display/dc/resource/dcn315/dcn315_resource.c
@@ -1347,7 +1347,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(enum e
1347 1347 }
1348 1348
1349 1349 /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
1350 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
1350 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
1351 1351 vpg = dcn31_vpg_create(ctx, vpg_inst);
1352 1352 afmt = dcn31_afmt_create(ctx, afmt_inst);
1353 1353
@@ -1379,7 +1379,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(enum engin
1379 1379 ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
1380 1380
1381 1381 /* allocate HPO link encoder */
1382 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1382 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1383 1383 if (!hpo_enc3)
1384 1384 return NULL; /* out of memory */
1385 1385
modified drivers/gpu/drm/amd/display/dc/resource/dcn316/dcn316_resource.c
@@ -1340,7 +1340,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(enum e
1340 1340 }
1341 1341
1342 1342 /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
1343 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
1343 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
1344 1344 vpg = dcn31_vpg_create(ctx, vpg_inst);
1345 1345 afmt = dcn31_afmt_create(ctx, afmt_inst);
1346 1346
@@ -1372,7 +1372,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(enum engin
1372 1372 ASSERT((eng_id == ENGINE_ID_HPO_0) || (eng_id == ENGINE_ID_HPO_1));
1373 1373
1374 1374 /* allocate HPO link encoder */
1375 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1375 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1376 1376 if (!hpo_enc3)
1377 1377 return NULL; /* out of memory */
1378 1378
modified drivers/gpu/drm/amd/display/dc/resource/dcn32/dcn32_resource.c
@@ -1339,7 +1339,7 @@ static struct hpo_frl_stream_encoder *dcn32_hpo_frl_stream_encoder_create(enum e
1339 1339 }
1340 1340
1341 1341 /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
1342 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
1342 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
1343 1343 vpg = dcn32_vpg_create(ctx, vpg_inst);
1344 1344 afmt = dcn32_afmt_create(ctx, afmt_inst);
1345 1345
@@ -1375,7 +1375,7 @@ static struct hpo_frl_link_encoder *dcn32_hpo_frl_link_encoder_create(enum engin
1375 1375 hpo_frl_link_encoder_reg_list(0);
1376 1376
1377 1377 /* allocate HPO link encoder */
1378 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1378 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1379 1379 if (!hpo_enc3)
1380 1380 return NULL; /* out of memory */
1381 1381
modified drivers/gpu/drm/amd/display/dc/resource/dcn321/dcn321_resource.c
@@ -1314,7 +1314,7 @@ static struct hpo_frl_stream_encoder *dcn321_hpo_frl_stream_encoder_create(enum
1314 1314 }
1315 1315
1316 1316 /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
1317 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
1317 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
1318 1318 vpg = dcn321_vpg_create(ctx, vpg_inst);
1319 1319 afmt = dcn321_afmt_create(ctx, afmt_inst);
1320 1320
@@ -1350,7 +1350,7 @@ static struct hpo_frl_link_encoder *dcn321_hpo_frl_link_encoder_create(enum engi
1350 1350 hpo_frl_link_encoder_reg_list(0);
1351 1351
1352 1352 /* allocate HPO link encoder */
1353 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1353 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1354 1354 if (!hpo_enc3)
1355 1355 return NULL; /* out of memory */
1356 1356
modified drivers/gpu/drm/amd/display/dc/resource/dcn35/dcn35_resource.c
@@ -1398,7 +1398,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(
1398 1398 return NULL;
1399 1399
1400 1400 /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
1401 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
1401 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
1402 1402 vpg = dcn31_vpg_create(ctx, vpg_inst);
1403 1403 afmt = dcn31_afmt_create(ctx, afmt_inst);
1404 1404
@@ -1430,7 +1430,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(
1430 1430 hpo_frl_link_encoder_reg_list(0);
1431 1431
1432 1432 /* allocate HPO link encoder */
1433 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1433 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1434 1434 if (!hpo_enc3)
1435 1435 return NULL; /* out of memory */
1436 1436
modified drivers/gpu/drm/amd/display/dc/resource/dcn351/dcn351_resource.c
@@ -1378,7 +1378,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(
1378 1378 return NULL;
1379 1379
1380 1380 /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
1381 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
1381 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
1382 1382 vpg = dcn31_vpg_create(ctx, vpg_inst);
1383 1383 afmt = dcn31_afmt_create(ctx, afmt_inst);
1384 1384
@@ -1410,7 +1410,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(
1410 1410 hpo_frl_link_encoder_reg_list(0);
1411 1411
1412 1412 /* allocate HPO link encoder */
1413 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1413 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1414 1414 if (!hpo_enc3)
1415 1415 return NULL; /* out of memory */
1416 1416
modified drivers/gpu/drm/amd/display/dc/resource/dcn36/dcn36_resource.c
@@ -1385,7 +1385,7 @@ static struct hpo_frl_stream_encoder *dcn31_hpo_frl_stream_encoder_create(
1385 1385 return NULL;
1386 1386
1387 1387 /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
1388 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_stream_encoder);
1388 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_stream_encoder), GFP_KERNEL);
1389 1389 vpg = dcn31_vpg_create(ctx, vpg_inst);
1390 1390 afmt = dcn31_afmt_create(ctx, afmt_inst);
1391 1391
@@ -1417,7 +1417,7 @@ static struct hpo_frl_link_encoder *dcn31_hpo_frl_link_encoder_create(
1417 1417 hpo_frl_link_encoder_reg_list(0);
1418 1418
1419 1419 /* allocate HPO link encoder */
1420 - hpo_enc3 = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1420 + hpo_enc3 = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1421 1421 if (!hpo_enc3)
1422 1422 return NULL; /* out of memory */
1423 1423
modified drivers/gpu/drm/amd/display/dc/resource/dcn401/dcn401_resource.c
@@ -1322,7 +1322,7 @@ static struct hpo_frl_stream_encoder *dcn401_hpo_frl_stream_encoder_create(
1322 1322 return NULL;
1323 1323
1324 1324 /* allocate HPO stream encoder and create VPG, AFMT sub-blocks */
1325 - hpo_enc401 = kzalloc_obj(struct dcn401_hpo_frl_stream_encoder);
1325 + hpo_enc401 = kzalloc(sizeof(struct dcn401_hpo_frl_stream_encoder), GFP_KERNEL);
1326 1326 vpg = dcn401_vpg_create(ctx, vpg_inst);
1327 1327 afmt = dcn401_afmt_create(ctx, afmt_inst);
1328 1328
@@ -1353,7 +1353,7 @@ static struct hpo_frl_link_encoder *dcn401_hpo_frl_link_encoder_create(
1353 1353 hpo_frl_link_encoder_reg_list(0);
1354 1354
1355 1355 /* allocate HPO link encoder */
1356 - hpo_link_enc = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1356 + hpo_link_enc = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1357 1357 if (!hpo_link_enc)
1358 1358 return NULL; /* out of memory */
1359 1359
modified drivers/gpu/drm/amd/display/dc/resource/dcn42/dcn42_resource.c
@@ -818,7 +818,7 @@ static struct dce_aux *dcn42_aux_engine_create(
818 818 uint32_t inst)
819 819 {
820 820 struct aux_engine_dce110 *aux_engine =
821 - kzalloc_obj(struct aux_engine_dce110);
821 + kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL);
822 822
823 823 if (!aux_engine)
824 824 return NULL;
@@ -884,7 +884,7 @@ static struct dce_i2c_hw *dcn42_i2c_hw_create(
884 884 uint32_t inst)
885 885 {
886 886 struct dce_i2c_hw *dce_i2c_hw =
887 - kzalloc_obj(struct dce_i2c_hw);
887 + kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL);
888 888
889 889 if (!dce_i2c_hw)
890 890 return NULL;
@@ -910,7 +910,7 @@ static struct clock_source *dcn42_clock_source_create(
910 910 bool dp_clk_src)
911 911 {
912 912 struct dce110_clk_src *clk_src =
913 - kzalloc_obj(struct dce110_clk_src);
913 + kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
914 914
915 915 if (!clk_src)
916 916 return NULL;
@@ -929,7 +929,8 @@ static struct hubbub *dcn42_hubbub_create(struct dc_context *ctx)
929 929 {
930 930 int i;
931 931
932 - struct dcn20_hubbub *hubbub3 = kzalloc_obj(struct dcn20_hubbub);
932 + struct dcn20_hubbub *hubbub3 = kzalloc(sizeof(struct dcn20_hubbub),
933 + GFP_KERNEL);
933 934
934 935 if (!hubbub3)
935 936 return NULL;
@@ -982,7 +983,7 @@ static struct hubp *dcn42_hubp_create(
982 983 uint32_t inst)
983 984 {
984 985 struct dcn20_hubp *hubp2 =
985 - kzalloc_obj(struct dcn20_hubp);
986 + kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL);
986 987
987 988 if (!hubp2)
988 989 return NULL;
@@ -1024,7 +1025,7 @@ static struct dpp *dcn42_dpp_create(
1024 1025 uint32_t inst)
1025 1026 {
1026 1027 struct dcn42_dpp *dpp42 =
1027 - kzalloc_obj(struct dcn42_dpp);
1028 + kzalloc(sizeof(struct dcn42_dpp), GFP_KERNEL);
1028 1029
1029 1030 if (!dpp42)
1030 1031 return NULL;
@@ -1050,7 +1051,8 @@ static struct mpc *dcn42_mpc_create(
1050 1051 int num_mpcc,
1051 1052 int num_rmu)
1052 1053 {
1053 - struct dcn42_mpc *mpc401 = kzalloc_obj(struct dcn42_mpc);
1054 + struct dcn42_mpc *mpc401 = kzalloc(sizeof(struct dcn42_mpc),
1055 + GFP_KERNEL);
1054 1056
1055 1057 if (!mpc401)
1056 1058 return NULL;
@@ -1073,7 +1075,7 @@ static struct output_pixel_processor *dcn42_opp_create(
1073 1075 struct dc_context *ctx, uint32_t inst)
1074 1076 {
1075 1077 struct dcn20_opp *opp4 =
1076 - kzalloc_obj(struct dcn20_opp);
1078 + kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL);
1077 1079
1078 1080 if (!opp4) {
1079 1081 BREAK_TO_DEBUGGER();
@@ -1096,7 +1098,7 @@ static struct timing_generator *dcn42_timing_generator_create(
1096 1098 uint32_t instance)
1097 1099 {
1098 1100 struct optc *tgn10 =
1099 - kzalloc_obj(struct optc);
1101 + kzalloc(sizeof(struct optc), GFP_KERNEL);
1100 1102
1101 1103 if (!tgn10)
1102 1104 return NULL;
@@ -1134,7 +1136,7 @@ static struct link_encoder *dcn42_link_encoder_create(
1134 1136 const struct encoder_init_data *enc_init_data)
1135 1137 {
1136 1138 struct dcn20_link_encoder *enc20 =
1137 - kzalloc_obj(struct dcn20_link_encoder);
1139 + kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
1138 1140
1139 1141 if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
1140 1142 return NULL;
@@ -1200,7 +1202,7 @@ static struct vpg *dcn42_vpg_create(
1200 1202 struct dc_context *ctx,
1201 1203 uint32_t inst)
1202 1204 {
1203 - struct dcn31_vpg *vpg4 = kzalloc_obj(struct dcn31_vpg);
1205 + struct dcn31_vpg *vpg4 = kzalloc(sizeof(struct dcn31_vpg), GFP_KERNEL);
1204 1206
1205 1207 if (!vpg4)
1206 1208 return NULL;
@@ -1229,7 +1231,7 @@ static struct apg *dcn42_apg_create(
1229 1231 struct dc_context *ctx,
1230 1232 uint32_t inst)
1231 1233 {
1232 - struct dcn31_apg *apg31 = kzalloc_obj(struct dcn31_apg);
1234 + struct dcn31_apg *apg31 = kzalloc(sizeof(struct dcn31_apg), GFP_KERNEL);
1233 1235
1234 1236 if (!apg31)
1235 1237 return NULL;
@@ -1273,7 +1275,7 @@ static struct stream_encoder *dcn42_stream_encoder_create(
1273 1275 } else
1274 1276 return NULL;
1275 1277
1276 - enc1 = kzalloc_obj(struct dcn10_stream_encoder);
1278 + enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
1277 1279 vpg = dcn42_vpg_create(ctx, vpg_inst);
1278 1280 apg = dcn42_apg_create(ctx, apg_inst);
1279 1281
@@ -1323,7 +1325,7 @@ static struct hpo_frl_stream_encoder *dcn42_hpo_frl_stream_encoder_create(
1323 1325 return NULL;
1324 1326
1325 1327 /* allocate HPO stream encoder and create VPG sub-block */
1326 - hpo_enc42 = kzalloc_obj(struct dcn42_hpo_frl_stream_encoder);
1328 + hpo_enc42 = kzalloc(sizeof(struct dcn42_hpo_frl_stream_encoder), GFP_KERNEL);
1327 1329 vpg = dcn42_vpg_create(ctx, vpg_inst);
1328 1330 apg = dcn42_apg_create(ctx, apg_inst);
1329 1331
@@ -1355,7 +1357,7 @@ static struct hpo_frl_link_encoder *dcn42_hpo_frl_link_encoder_create(
1355 1357 hpo_frl_link_encoder_reg_list(0);
1356 1358
1357 1359 /* allocate HPO link encoder */
1358 - hpo_link_enc = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1360 + hpo_link_enc = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1359 1361 if (!hpo_link_enc)
1360 1362 return NULL; /* out of memory */
1361 1363
@@ -1397,7 +1399,7 @@ static struct hpo_dp_stream_encoder *dcn42_hpo_dp_stream_encoder_create(
1397 1399 apg_inst = hpo_dp_inst + 5;
1398 1400
1399 1401 /* allocate HPO stream encoder and create VPG sub-block */
1400 - hpo_dp_enc31 = kzalloc_obj(struct dcn31_hpo_dp_stream_encoder);
1402 + hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_stream_encoder), GFP_KERNEL);
1401 1403 vpg = dcn42_vpg_create(ctx, vpg_inst);
1402 1404 apg = dcn42_apg_create(ctx, apg_inst);
1403 1405
@@ -1430,7 +1432,7 @@ static struct hpo_dp_link_encoder *dcn42_hpo_dp_link_encoder_create(
1430 1432 struct dcn31_hpo_dp_link_encoder *hpo_dp_enc31;
1431 1433
1432 1434 /* allocate HPO link encoder */
1433 - hpo_dp_enc31 = kzalloc_obj(struct dcn31_hpo_dp_link_encoder);
1435 + hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
1434 1436 if (!hpo_dp_enc31)
1435 1437 return NULL; /* out of memory */
1436 1438
@@ -1451,7 +1453,7 @@ static struct hpo_dp_link_encoder *dcn42_hpo_dp_link_encoder_create(
1451 1453 static struct dce_hwseq *dcn42_hwseq_create(
1452 1454 struct dc_context *ctx)
1453 1455 {
1454 - struct dce_hwseq *hws = kzalloc_obj(struct dce_hwseq);
1456 + struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
1455 1457
1456 1458 #undef REG_STRUCT
1457 1459 #define REG_STRUCT hwseq_reg
@@ -1725,7 +1727,8 @@ static bool dcn42_dwbc_create(struct dc_context *ctx, struct resource_pool *pool
1725 1727 uint32_t dwb_count = pool->res_cap->num_dwb;
1726 1728
1727 1729 for (i = 0; i < dwb_count; i++) {
1728 - struct dcn30_dwbc *dwbc42 = kzalloc_obj(struct dcn30_dwbc);
1730 + struct dcn30_dwbc *dwbc42 = kzalloc(sizeof(struct dcn30_dwbc),
1731 + GFP_KERNEL);
1729 1732
1730 1733 if (!dwbc42) {
1731 1734 dm_error("DC: failed to create dwbc42!\n");
@@ -1761,7 +1764,8 @@ static bool dcn42_mmhubbub_create(struct dc_context *ctx, struct resource_pool *
1761 1764 uint32_t pipe_count = pool->res_cap->num_dwb;
1762 1765
1763 1766 for (i = 0; i < pipe_count; i++) {
1764 - struct dcn30_mmhubbub *mcif_wb30 = kzalloc_obj(struct dcn30_mmhubbub);
1767 + struct dcn30_mmhubbub *mcif_wb30 = kzalloc(sizeof(struct dcn30_mmhubbub),
1768 + GFP_KERNEL);
1765 1769
1766 1770 if (!mcif_wb30) {
1767 1771 dm_error("DC: failed to create mcif_wb30!\n");
@@ -1789,7 +1793,7 @@ static struct display_stream_compressor *dcn42_dsc_create(
1789 1793 struct dc_context *ctx, uint32_t inst)
1790 1794 {
1791 1795 struct dcn401_dsc *dsc =
1792 - kzalloc_obj(struct dcn401_dsc);
1796 + kzalloc(sizeof(struct dcn401_dsc), GFP_KERNEL);
1793 1797
1794 1798 if (!dsc) {
1795 1799 BREAK_TO_DEBUGGER();
@@ -1886,7 +1890,7 @@ static struct link_encoder *dcn42_link_enc_create_minimal(
1886 1890 if ((unsigned int)(eng_id - ENGINE_ID_DIGA) >= ctx->dc->res_pool->res_cap->num_dig_link_enc)
1887 1891 return NULL;
1888 1892
1889 - enc20 = kzalloc_obj(struct dcn20_link_encoder);
1893 + enc20 = kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
1890 1894 if (!enc20)
1891 1895 return NULL;
1892 1896
@@ -2437,7 +2441,7 @@ struct resource_pool *dcn42_create_resource_pool(
2437 2441 struct dc *dc)
2438 2442 {
2439 2443 struct dcn42_resource_pool *pool =
2440 - kzalloc_obj(struct dcn42_resource_pool);
2444 + kzalloc(sizeof(struct dcn401_resource_pool), GFP_KERNEL);
2441 2445
2442 2446 if (!pool)
2443 2447 return NULL;
modified drivers/gpu/drm/amd/display/dc/resource/dcn42b/dcn42b_resource.c
@@ -870,7 +870,7 @@ static struct dce_aux *dcn42b_aux_engine_create(
870 870 uint32_t inst)
871 871 {
872 872 struct aux_engine_dce110 *aux_engine =
873 - kzalloc_obj(struct aux_engine_dce110);
873 + kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL);
874 874
875 875 if (!aux_engine)
876 876 return NULL;
@@ -940,7 +940,7 @@ static struct dce_i2c_hw *dcn42b_i2c_hw_create(
940 940 uint32_t inst)
941 941 {
942 942 struct dce_i2c_hw *dce_i2c_hw =
943 - kzalloc_obj(struct dce_i2c_hw);
943 + kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL);
944 944
945 945 if (!dce_i2c_hw)
946 946 return NULL;
@@ -968,7 +968,7 @@ static struct clock_source *dcn42b_clock_source_create(
968 968 bool dp_clk_src)
969 969 {
970 970 struct dce110_clk_src *clk_src =
971 - kzalloc_obj(struct dce110_clk_src);
971 + kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
972 972
973 973 if (!clk_src)
974 974 return NULL;
@@ -988,7 +988,8 @@ static struct hubbub *dcn42b_hubbub_create(struct dc_context *ctx)
988 988 {
989 989 int i;
990 990
991 - struct dcn20_hubbub *hubbub3 = kzalloc_obj(struct dcn20_hubbub);
991 + struct dcn20_hubbub *hubbub3 = kzalloc(sizeof(struct dcn20_hubbub),
992 + GFP_KERNEL);
992 993
993 994 if (!hubbub3)
994 995 return NULL;
@@ -1041,7 +1042,7 @@ static struct hubp *dcn42b_hubp_create(
1041 1042 uint32_t inst)
1042 1043 {
1043 1044 struct dcn20_hubp *hubp2 =
1044 - kzalloc_obj(struct dcn20_hubp);
1045 + kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL);
1045 1046
1046 1047 if (!hubp2)
1047 1048 return NULL;
@@ -1083,7 +1084,7 @@ static struct dpp *dcn42b_dpp_create(
1083 1084 uint32_t inst)
1084 1085 {
1085 1086 struct dcn42_dpp *dpp42b =
1086 - kzalloc_obj(struct dcn42_dpp);
1087 + kzalloc(sizeof(struct dcn42_dpp), GFP_KERNEL);
1087 1088
1088 1089 if (!dpp42b)
1089 1090 return NULL;
@@ -1109,7 +1110,8 @@ static struct mpc *dcn42b_mpc_create(
1109 1110 int num_mpcc,
1110 1111 int num_rmu)
1111 1112 {
1112 - struct dcn42_mpc *mpc42b = kzalloc_obj(struct dcn42_mpc);
1113 + struct dcn42_mpc *mpc42b = kzalloc(sizeof(struct dcn42_mpc),
1114 + GFP_KERNEL);
1113 1115
1114 1116 if (!mpc42b)
1115 1117 return NULL;
@@ -1132,7 +1134,7 @@ static struct output_pixel_processor *dcn42b_opp_create(
1132 1134 struct dc_context *ctx, uint32_t inst)
1133 1135 {
1134 1136 struct dcn20_opp *opp4 =
1135 - kzalloc_obj(struct dcn20_opp);
1137 + kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL);
1136 1138
1137 1139 if (!opp4) {
1138 1140 BREAK_TO_DEBUGGER();
@@ -1156,7 +1158,7 @@ static struct timing_generator *dcn42b_timing_generator_create(
1156 1158 uint32_t instance)
1157 1159 {
1158 1160 struct optc *tgn10 =
1159 - kzalloc_obj(struct optc);
1161 + kzalloc(sizeof(struct optc), GFP_KERNEL);
1160 1162
1161 1163 if (!tgn10)
1162 1164 return NULL;
@@ -1194,7 +1196,7 @@ static struct link_encoder *dcn42b_link_encoder_create(
1194 1196 const struct encoder_init_data *enc_init_data)
1195 1197 {
1196 1198 struct dcn20_link_encoder *enc20 =
1197 - kzalloc_obj(struct dcn20_link_encoder);
1199 + kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
1198 1200
1199 1201 if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs))
1200 1202 return NULL;
@@ -1269,7 +1271,7 @@ static struct vpg *dcn42b_vpg_create(
1269 1271 struct dc_context *ctx,
1270 1272 uint32_t inst)
1271 1273 {
1272 - struct dcn31_vpg *vpg4 = kzalloc_obj(struct dcn31_vpg);
1274 + struct dcn31_vpg *vpg4 = kzalloc(sizeof(struct dcn31_vpg), GFP_KERNEL);
1273 1275
1274 1276 if (!vpg4)
1275 1277 return NULL;
@@ -1298,7 +1300,7 @@ static struct apg *dcn42b_apg_create(
1298 1300 struct dc_context *ctx,
1299 1301 uint32_t inst)
1300 1302 {
1301 - struct dcn31_apg *apg31 = kzalloc_obj(struct dcn31_apg);
1303 + struct dcn31_apg *apg31 = kzalloc(sizeof(struct dcn31_apg), GFP_KERNEL);
1302 1304
1303 1305 if (!apg31)
1304 1306 return NULL;
@@ -1342,7 +1344,7 @@ static struct stream_encoder *dcn42b_stream_encoder_create(
1342 1344 } else
1343 1345 return NULL;
1344 1346
1345 - enc1 = kzalloc_obj(struct dcn10_stream_encoder);
1347 + enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
1346 1348 vpg = dcn42b_vpg_create(ctx, vpg_inst);
1347 1349 apg = dcn42b_apg_create(ctx, apg_inst);
1348 1350
@@ -1402,7 +1404,7 @@ static struct hpo_dp_stream_encoder *dcn42b_hpo_dp_stream_encoder_create(
1402 1404 apg_inst = hpo_dp_inst + 6;
1403 1405
1404 1406 /* allocate HPO stream encoder and create VPG sub-block */
1405 - hpo_dp_enc31 = kzalloc_obj(struct dcn31_hpo_dp_stream_encoder);
1407 + hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_stream_encoder), GFP_KERNEL);
1406 1408 vpg = dcn42b_vpg_create(ctx, vpg_inst);
1407 1409 apg = dcn42b_apg_create(ctx, apg_inst);
1408 1410
@@ -1435,7 +1437,7 @@ static struct hpo_dp_link_encoder *dcn42b_hpo_dp_link_encoder_create(
1435 1437 struct dcn31_hpo_dp_link_encoder *hpo_dp_enc31;
1436 1438
1437 1439 /* allocate HPO link encoder */
1438 - hpo_dp_enc31 = kzalloc_obj(struct dcn31_hpo_dp_link_encoder);
1440 + hpo_dp_enc31 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
1439 1441 if (!hpo_dp_enc31)
1440 1442 return NULL; /* out of memory */
1441 1443
@@ -1455,7 +1457,7 @@ static struct hpo_dp_link_encoder *dcn42b_hpo_dp_link_encoder_create(
1455 1457 static struct dce_hwseq *dcn42b_hwseq_create(
1456 1458 struct dc_context *ctx)
1457 1459 {
1458 - struct dce_hwseq *hws = kzalloc_obj(struct dce_hwseq);
1460 + struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
1459 1461
1460 1462 #undef REG_STRUCT
1461 1463 #define REG_STRUCT hwseq_reg
@@ -1714,7 +1716,8 @@ static bool dcn42b_dwbc_create(struct dc_context *ctx, struct resource_pool *poo
1714 1716 uint32_t dwb_count = pool->res_cap->num_dwb;
1715 1717
1716 1718 for (i = 0; i < dwb_count; i++) {
1717 - struct dcn30_dwbc *dwbc42 = kzalloc_obj(struct dcn30_dwbc);
1719 + struct dcn30_dwbc *dwbc42 = kzalloc(sizeof(struct dcn30_dwbc),
1720 + GFP_KERNEL);
1718 1721
1719 1722 if (!dwbc42) {
1720 1723 dm_error("DC: failed to create dwbc42!\n");
@@ -1750,7 +1753,8 @@ static bool dcn42b_mmhubbub_create(struct dc_context *ctx, struct resource_pool
1750 1753 uint32_t pipe_count = pool->res_cap->num_dwb;
1751 1754
1752 1755 for (i = 0; i < pipe_count; i++) {
1753 - struct dcn30_mmhubbub *mcif_wb30 = kzalloc_obj(struct dcn30_mmhubbub);
1756 + struct dcn30_mmhubbub *mcif_wb30 = kzalloc(sizeof(struct dcn30_mmhubbub),
1757 + GFP_KERNEL);
1754 1758
1755 1759 if (!mcif_wb30) {
1756 1760 dm_error("DC: failed to create mcif_wb30!\n");
@@ -1778,7 +1782,7 @@ static struct display_stream_compressor *dcn42b_dsc_create(
1778 1782 struct dc_context *ctx, uint32_t inst)
1779 1783 {
1780 1784 struct dcn401_dsc *dsc =
1781 - kzalloc_obj(struct dcn401_dsc);
1785 + kzalloc(sizeof(struct dcn401_dsc), GFP_KERNEL);
1782 1786
1783 1787 if (!dsc) {
1784 1788 BREAK_TO_DEBUGGER();
@@ -1871,7 +1875,7 @@ static struct link_encoder *dcn42b_link_enc_create_minimal(
1871 1875 if ((unsigned int)(eng_id - ENGINE_ID_DIGA) >= ctx->dc->res_pool->res_cap->num_dig_link_enc)
1872 1876 return NULL;
1873 1877
1874 - enc20 = kzalloc_obj(struct dcn20_link_encoder);
1878 + enc20 = kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
1875 1879 if (!enc20)
1876 1880 return NULL;
1877 1881
@@ -2435,7 +2439,7 @@ struct resource_pool *dcn42b_create_resource_pool(
2435 2439 struct dc *dc)
2436 2440 {
2437 2441 struct dcn42b_resource_pool *pool =
2438 - kzalloc_obj(struct dcn42b_resource_pool);
2442 + kzalloc(sizeof(struct dcn42b_resource_pool), GFP_KERNEL);
2439 2443
2440 2444 if (!pool)
2441 2445 return NULL;
modified drivers/gpu/drm/amd/display/dc/resource/dcn60/dcn60_resource.c
@@ -998,7 +998,7 @@ static struct dce_aux *dcn60_aux_engine_create(
998 998 uint32_t inst)
999 999 {
1000 1000 struct aux_engine_dce110 *aux_engine =
1001 - kzalloc_obj(struct aux_engine_dce110);
1001 + kzalloc(sizeof(struct aux_engine_dce110), GFP_KERNEL);
1002 1002
1003 1003 if (!aux_engine)
1004 1004 return NULL;
@@ -1037,7 +1037,7 @@ static struct dce_i2c_hw *dcn60_i2c_hw_create(
1037 1037 uint32_t inst)
1038 1038 {
1039 1039 struct dce_i2c_hw *dce_i2c_hw =
1040 - kzalloc_obj(struct dce_i2c_hw);
1040 + kzalloc(sizeof(struct dce_i2c_hw), GFP_KERNEL);
1041 1041
1042 1042 if (!dce_i2c_hw)
1043 1043 return NULL;
@@ -1061,7 +1061,7 @@ static struct clock_source *dcn60_clock_source_create(
1061 1061 bool dp_clk_src)
1062 1062 {
1063 1063 struct dce110_clk_src *clk_src =
1064 - kzalloc_obj(struct dce110_clk_src);
1064 + kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
1065 1065
1066 1066 if (!clk_src)
1067 1067 return NULL;
@@ -1081,7 +1081,8 @@ static struct hubbub *dcn60_hubbub_create(struct dc_context *ctx)
1081 1081 {
1082 1082 int i;
1083 1083
1084 - struct dcn20_hubbub *hubbub2 = kzalloc_obj(struct dcn20_hubbub);
1084 + struct dcn20_hubbub *hubbub2 = kzalloc(sizeof(struct dcn20_hubbub),
1085 + GFP_KERNEL);
1085 1086
1086 1087 if (!hubbub2)
1087 1088 return NULL;
@@ -1135,7 +1136,7 @@ static struct hubp *dcn60_hubp_create(
1135 1136 uint32_t inst)
1136 1137 {
1137 1138 struct dcn20_hubp *hubp2 =
1138 - kzalloc_obj(struct dcn20_hubp);
1139 + kzalloc(sizeof(struct dcn20_hubp), GFP_KERNEL);
1139 1140
1140 1141 if (!hubp2)
1141 1142 return NULL;
@@ -1167,7 +1168,7 @@ static struct dpp *dcn60_dpp_create(
1167 1168 uint32_t inst)
1168 1169 {
1169 1170 struct dcn60_dpp *dpp60 =
1170 - kzalloc_obj(struct dcn60_dpp);
1171 + kzalloc(sizeof(struct dcn60_dpp), GFP_KERNEL);
1171 1172
1172 1173 if (!dpp60)
1173 1174 return NULL;
@@ -1193,7 +1194,8 @@ static struct mpc *dcn60_mpc_create(
1193 1194 int num_mpcc,
1194 1195 int num_rmu)
1195 1196 {
1196 - struct dcn60_mpc *mpc60 = kzalloc_obj(struct dcn60_mpc);
1197 + struct dcn60_mpc *mpc60 = kzalloc(sizeof(struct dcn60_mpc),
1198 + GFP_KERNEL);
1197 1199
1198 1200 if (!mpc60)
1199 1201 return NULL;
@@ -1216,7 +1218,7 @@ static struct output_pixel_processor *dcn60_opp_create(
1216 1218 struct dc_context *ctx, uint32_t inst)
1217 1219 {
1218 1220 struct dcn20_opp *opp2 =
1219 - kzalloc_obj(struct dcn20_opp);
1221 + kzalloc(sizeof(struct dcn20_opp), GFP_KERNEL);
1220 1222
1221 1223 if (!opp2) {
1222 1224 BREAK_TO_DEBUGGER();
@@ -1240,7 +1242,7 @@ static struct timing_generator *dcn60_timing_generator_create(
1240 1242 uint32_t instance)
1241 1243 {
1242 1244 struct optc *tgn10 =
1243 - kzalloc_obj(struct optc);
1245 + kzalloc(sizeof(struct optc), GFP_KERNEL);
1244 1246
1245 1247 if (!tgn10)
1246 1248 return NULL;
@@ -1280,7 +1282,7 @@ static struct link_encoder *dcn60_link_encoder_create(
1280 1282 const struct encoder_init_data *enc_init_data)
1281 1283 {
1282 1284 struct dcn20_link_encoder *enc20 =
1283 - kzalloc_obj(struct dcn20_link_encoder);
1285 + kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL);
1284 1286
1285 1287 if (!enc20 || enc_init_data->hpd_source >= ARRAY_SIZE(link_enc_hpd_regs)) {
1286 1288 kfree(enc20);
@@ -1347,7 +1349,7 @@ static struct vpg *dcn60_vpg_create(
1347 1349 struct dc_context *ctx,
1348 1350 uint32_t inst)
1349 1351 {
1350 - struct dcn31_vpg *vpg6 = kzalloc_obj(struct dcn31_vpg);
1352 + struct dcn31_vpg *vpg6 = kzalloc(sizeof(struct dcn31_vpg), GFP_KERNEL);
1351 1353
1352 1354 if (!vpg6)
1353 1355 return NULL;
@@ -1376,7 +1378,7 @@ static struct apg *dcn60_apg_create(
1376 1378 struct dc_context *ctx,
1377 1379 uint32_t inst)
1378 1380 {
1379 - struct dcn31_apg *apg60 = kzalloc_obj(struct dcn31_apg);
1381 + struct dcn31_apg *apg60 = kzalloc(sizeof(struct dcn31_apg), GFP_KERNEL);
1380 1382
1381 1383 if (!apg60)
1382 1384 return NULL;
@@ -1413,7 +1415,7 @@ static struct stream_encoder *dcn60_stream_encoder_create(
1413 1415 } else
1414 1416 return NULL;
1415 1417
1416 - enc1 = kzalloc_obj(struct dcn10_stream_encoder);
1418 + enc1 = kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
1417 1419 vpg = dcn60_vpg_create(ctx, vpg_inst);
1418 1420 apg = dcn60_apg_create(ctx, apg_inst);
1419 1421
@@ -1460,7 +1462,7 @@ static struct hpo_frl_stream_encoder *dcn60_hpo_frl_stream_encoder_create(
1460 1462 return NULL;
1461 1463
1462 1464 /* allocate HPO stream encoder and create VPG, APG sub-blocks */
1463 - hpo_enc60 = kzalloc_obj(struct dcn401_hpo_frl_stream_encoder);
1465 + hpo_enc60 = kzalloc(sizeof(struct dcn401_hpo_frl_stream_encoder), GFP_KERNEL);
1464 1466 vpg = dcn60_vpg_create(ctx, vpg_inst);
1465 1467 apg = dcn60_apg_create(ctx, apg_inst);
1466 1468
@@ -1491,7 +1493,7 @@ static struct hpo_frl_link_encoder *dcn60_hpo_frl_link_encoder_create(
1491 1493 hpo_frl_link_encoder_reg_list(0);
1492 1494
1493 1495 /* allocate HPO link encoder */
1494 - hpo_link_enc = kzalloc_obj(struct dcn30_hpo_frl_link_encoder);
1496 + hpo_link_enc = kzalloc(sizeof(struct dcn30_hpo_frl_link_encoder), GFP_KERNEL);
1495 1497 if (!hpo_link_enc)
1496 1498 return NULL; /* out of memory */
1497 1499
@@ -1533,7 +1535,7 @@ static struct hpo_dp_stream_encoder *dcn60_hpo_dp_stream_encoder_create(
1533 1535 apg_inst = hpo_dp_inst;
1534 1536
1535 1537 /* allocate HPO stream encoder and create VPG sub-block */
1536 - hpo_dp_enc60 = kzalloc_obj(struct dcn31_hpo_dp_stream_encoder);
1538 + hpo_dp_enc60 = kzalloc(sizeof(struct dcn31_hpo_dp_stream_encoder), GFP_KERNEL);
1537 1539 vpg = dcn60_vpg_create(ctx, vpg_inst);
1538 1540 apg = dcn60_apg_create(ctx, apg_inst);
1539 1541
@@ -1566,7 +1568,7 @@ static struct hpo_dp_link_encoder *dcn60_hpo_dp_link_encoder_create(
1566 1568 struct dcn31_hpo_dp_link_encoder *hpo_dp_enc60;
1567 1569
1568 1570 /* allocate HPO link encoder */
1569 - hpo_dp_enc60 = kzalloc_obj(struct dcn31_hpo_dp_link_encoder);
1571 + hpo_dp_enc60 = kzalloc(sizeof(struct dcn31_hpo_dp_link_encoder), GFP_KERNEL);
1570 1572 if (!hpo_dp_enc60)
1571 1573 return NULL; /* out of memory */
1572 1574
@@ -1587,7 +1589,7 @@ static struct hpo_dp_link_encoder *dcn60_hpo_dp_link_encoder_create(
1587 1589 static struct dce_hwseq *dcn60_hwseq_create(
1588 1590 struct dc_context *ctx)
1589 1591 {
1590 - struct dce_hwseq *hws = kzalloc_obj(struct dce_hwseq);
1592 + struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
1591 1593
1592 1594 #undef REG_STRUCT
1593 1595 #define REG_STRUCT hwseq_reg
@@ -1782,7 +1784,7 @@ static struct display_stream_compressor *dcn60_dsc_create(
1782 1784 struct dc_context *ctx, uint32_t inst)
1783 1785 {
1784 1786 struct dcn60_dsc *dsc =
1785 - kzalloc_obj(struct dcn60_dsc);
1787 + kzalloc(sizeof(struct dcn60_dsc), GFP_KERNEL);
1786 1788
1787 1789 if (!dsc) {
1788 1790 BREAK_TO_DEBUGGER();
@@ -2361,7 +2363,7 @@ struct resource_pool *dcn60_create_resource_pool(
2361 2363 struct dc *dc)
2362 2364 {
2363 2365 struct dcn60_resource_pool *pool =
2364 - kzalloc_obj(struct dcn60_resource_pool);
2366 + kzalloc(sizeof(struct dcn60_resource_pool), GFP_KERNEL);
2365 2367
2366 2368 if (!pool)
2367 2369 return NULL;
modified drivers/gpu/drm/amd/display/modules/power/power.c
@@ -111,7 +111,7 @@ struct mod_power *mod_power_create(struct dc *dc,
111 111 if (dc == NULL)
112 112 goto fail_dc_null;
113 113
114 - core_power = kzalloc_obj(struct core_power);
114 + core_power = kzalloc(sizeof(struct core_power), GFP_KERNEL);
115 115
116 116 if (core_power == NULL)
117 117 goto fail_alloc_context;
@@ -129,7 +129,8 @@ struct mod_power *mod_power_create(struct dc *dc,
129 129
130 130 for (i = 0; i < MOD_POWER_MAX_CONCURRENT_STREAMS; i++) {
131 131 core_power->map[i].psr_context =
132 - kzalloc_obj(struct mod_power_psr_context);
132 + kzalloc(sizeof(struct mod_power_psr_context),
133 + GFP_KERNEL);
133 134 if (core_power->map[i].psr_context == NULL)
134 135 goto fail_construct;
135 136 }
modified drivers/gpu/drm/amd/display/modules/power/power_abm.c
@@ -705,7 +705,8 @@ void initialize_backlight_caps(struct core_power *core_power, unsigned int inst)
705 705 * (do not want to use 256 bytes on the stack)
706 706 */
707 707 ext_backlight_caps = (struct dm_acpi_atif_backlight_caps *)
708 - (kzalloc_obj(struct dm_acpi_atif_backlight_caps));
708 + (kzalloc(sizeof(struct dm_acpi_atif_backlight_caps),
709 + GFP_KERNEL));
709 710
710 711 if (ext_backlight_caps == NULL)
711 712 return;
modified drivers/gpu/drm/amd/pm/powerplay/hwmgr/smu7_hwmgr.c
@@ -2988,7 +2988,7 @@ static int smu7_init_voltage_dependency_on_display_clock_table(struct pp_hwmgr *
2988 2988 if (!amdgpu_device_ip_get_ip_block(hwmgr->adev, AMD_IP_BLOCK_TYPE_DCE))
2989 2989 return 0;
2990 2990
2991 - table = kzalloc_flex(*table, entries, 4);
2991 + table = kzalloc(struct_size(table, entries, 4), GFP_KERNEL);
2992 2992 if (!table)
2993 2993 return -ENOMEM;
2994 2994
modified drivers/gpu/drm/amd/pm/swsmu/smu15/smu_v15_0_8_ppt.c
@@ -222,7 +222,7 @@ static int smu_v15_0_8_tables_init(struct smu_context *smu)
222 222
223 223 smu_table->metrics_time = 0;
224 224
225 - driver_pptable = kzalloc_obj(PPTable_t);
225 + driver_pptable = kzalloc(sizeof(PPTable_t), GFP_KERNEL);
226 226 if (!driver_pptable)
227 227 return -ENOMEM;
228 228
@@ -1026,7 +1026,7 @@ static int smu_v15_0_8_fru_get_product_info(struct smu_context *smu,
1026 1026 struct amdgpu_device *adev = smu->adev;
1027 1027
1028 1028 if (!adev->fru_info) {
1029 - adev->fru_info = kzalloc_obj(*adev->fru_info);
1029 + adev->fru_info = kzalloc(sizeof(*adev->fru_info), GFP_KERNEL);
1030 1030 if (!adev->fru_info)
1031 1031 return -ENOMEM;
1032 1032 }
modified drivers/gpu/drm/amd/ras/core/cmd.c
@@ -222,7 +222,7 @@ static int ras_cmd_get_cper_records(struct ras_core_context *ras_core,
222 222 if (!buffer)
223 223 return RAS_CMD__ERROR_GENERIC;
224 224
225 - trace = kzalloc_objs(*trace, trace_count);
225 + trace = kcalloc(trace_count, sizeof(*trace), GFP_KERNEL);
226 226 if (!trace) {
227 227 ret = RAS_CMD__ERROR_GENERIC;
228 228 goto out;
@@ -316,7 +316,7 @@ static int ras_cmd_get_batch_trace_records(struct ras_core_context *ras_core,
316 316 (input_data->start_batch_id >= overview.last_batch_id))
317 317 return RAS_CMD__ERROR_INVALID_INPUT_SIZE;
318 318
319 - trace_arry = kzalloc_objs(*trace_arry, trace_count);
319 + trace_arry = kcalloc(trace_count, sizeof(*trace_arry), GFP_KERNEL);
320 320 if (!trace_arry)
321 321 return RAS_CMD__ERROR_GENERIC;
322 322
modified drivers/gpu/drm/drm_atomic_state_helper.c
@@ -278,14 +278,7 @@ void __drm_atomic_helper_plane_state_init(struct drm_plane_state *plane_state,
278 278 plane_state->rotation = DRM_MODE_ROTATE_0;
279 279
280 280 plane_state->alpha = DRM_BLEND_ALPHA_OPAQUE;
281 -
282 281 plane_state->pixel_blend_mode = DRM_MODE_BLEND_PREMULTI;
283 - if (plane->blend_mode_property) {
284 - if (!drm_object_property_get_default_value(&plane->base,
285 - plane->blend_mode_property,
286 - &val))
287 - plane_state->pixel_blend_mode = val;
288 - }
289 282
290 283 if (plane->color_encoding_property) {
291 284 if (!drm_object_property_get_default_value(&plane->base,
modified drivers/gpu/drm/drm_atomic_uapi.c
@@ -1449,6 +1449,9 @@ static int prepare_signaling(struct drm_device *dev,
1449 1449 if (arg->flags & DRM_MODE_PAGE_FLIP_EVENT) {
1450 1450 struct drm_pending_vblank_event *e = crtc_state->event;
1451 1451
1452 + if (!file_priv)
1453 + continue;
1454 +
1452 1455 ret = drm_event_reserve_init(dev, file_priv, &e->base,
1453 1456 &e->event.base);
1454 1457 if (ret) {
@@ -1564,8 +1567,6 @@ static void complete_signaling(struct drm_device *dev,
1564 1567 * to prevent a double free in drm_atomic_commit_clear.
1565 1568 */
1566 1569 if (event && (event->base.fence || event->base.file_priv)) {
1567 - if (crtc_state->commit && crtc_state->commit->abort_completion)
1568 - drm_crtc_commit_put(crtc_state->commit);
1569 1570 drm_event_cancel_free(dev, &event->base);
1570 1571 crtc_state->event = NULL;
1571 1572 }
modified drivers/gpu/drm/drm_exec.c
@@ -79,7 +79,7 @@ void drm_exec_init(struct drm_exec *exec, u32 flags, unsigned nr)
79 79 nr = PAGE_SIZE / sizeof(void *);
80 80
81 81 exec->flags = flags;
82 - exec->objects = kvmalloc_objs(*exec->objects, nr);
82 + exec->objects = kvmalloc_objs(*exec->objects, nr, GFP_KERNEL);
83 83
84 84 /* If allocation here fails, just delay that till the first use */
85 85 exec->max_objects = exec->objects ? nr : 0;
modified drivers/gpu/drm/drm_pagemap.c
@@ -383,58 +383,6 @@ next:
383 383 return 0;
384 384 }
385 385
386 - /**
387 - * drm_pagemap_migrate_populate_src_pages() - Populate the source page array
388 - * @pages: Array of source pages to populate
389 - * @src_mpfn: Source array of migrate PFNs
390 - * @dst_mpfn: Destination array of migrate PFNs
391 - * @npages: Number of pages in the arrays
392 - *
393 - * Populate @pages with the device pages the copy callback is to read from.
394 - *
395 - * Entries are normally only populated at the head of each source folio, with
396 - * the copy callback deriving the rest of the folio from the order recorded in
397 - * the corresponding drm_pagemap_addr. That does not work where
398 - * drm_pagemap_migrate_populate_ram_pfn() had to demote a higher-order source
399 - * folio to order-0 destination folios: the drm_pagemap_addr entries are then
400 - * per-page, and the copy callback needs a source page for each of them.
401 - * Populate every entry for those ranges.
402 - *
403 - * Note that the source folio itself is only split later, by
404 - * migrate_vma_pages() / migrate_device_pages(), so its order cannot be used to
405 - * detect the demotion - the destination has to be inspected instead.
406 - */
407 - static void drm_pagemap_migrate_populate_src_pages(struct page **pages,
408 - unsigned long *src_mpfn,
409 - unsigned long *dst_mpfn,
410 - unsigned long npages)
411 - {
412 - unsigned long i;
413 -
414 - for (i = 0; i < npages;) {
415 - struct page *page = migrate_pfn_to_page(src_mpfn[i]);
416 - unsigned int order = 0;
417 - unsigned long j, nr;
418 -
419 - if (!page) {
420 - i++;
421 - continue;
422 - }
423 -
424 - order = folio_order(page_folio(page));
425 - nr = NR_PAGES(order);
426 -
427 - if (order && !(dst_mpfn[i] & MIGRATE_PFN_COMPOUND)) {
428 - for (j = 0; j < nr && i + j < npages; j++)
429 - pages[i + j] = folio_page(page_folio(page), j);
430 - } else {
431 - pages[i] = page;
432 - }
433 -
434 - i += nr;
435 - }
436 - }
437 -
438 386 /**
439 387 * drm_pagemap_migrate_unmap_pages() - Unmap pages previously mapped for GPU SVM migration
440 388 * @dev: The device for which the pages were mapped
@@ -927,7 +875,6 @@ static int drm_pagemap_migrate_populate_ram_pfn(struct vm_area_struct *vas,
927 875 struct page *page = NULL, *src_page;
928 876 struct folio *folio;
929 877 unsigned int order = 0;
930 - gfp_t gfp = GFP_HIGHUSER;
931 878
932 879 if (!(src_mpfn[i] & MIGRATE_PFN_MIGRATE))
933 880 goto next;
@@ -944,51 +891,11 @@ static int drm_pagemap_migrate_populate_ram_pfn(struct vm_area_struct *vas,
944 891
945 892 order = folio_order(page_folio(src_page));
946 893
947 - /*
948 - * A large source folio is always collected whole, at its head
949 - * page, PMD aligned and flagged MIGRATE_PFN_COMPOUND: anything
950 - * else is split before it reaches us, either by
951 - * migrate_vma_collect_pmd() or, for the eviction path, by
952 - * migrate_device_pfns(). Both the order-0 fallback below and
953 - * drm_pagemap_migrate_populate_src_pages() rely on that, as
954 - * they index the folio from @i.
955 - */
956 - WARN_ON_ONCE(order &&
957 - (src_page != folio_page(page_folio(src_page), 0) ||
958 - !(src_mpfn[i] & MIGRATE_PFN_COMPOUND)));
959 -
960 - if (order)
961 - gfp |= __GFP_NOWARN;
962 -
894 + /* TODO: Support fallback to single pages if THP allocation fails */
963 895 if (vas)
964 - folio = vma_alloc_folio(gfp, order, vas, addr);
896 + folio = vma_alloc_folio(GFP_HIGHUSER, order, vas, addr);
965 897 else
966 - folio = folio_alloc(gfp, order);
967 -
968 - if (!folio && order) {
969 - /*
970 - * Higher-order allocation failed, fall back to
971 - * order-0 allocations for the entire range covered
972 - * by the original higher-order allocation, without
973 - * setting MIGRATE_PFN_COMPOUND, until we move past
974 - * that range.
975 - */
976 - unsigned long nr = NR_PAGES(order);
977 - unsigned long j;
978 -
979 - gfp &= ~__GFP_NOWARN;
980 - for (j = 0; j < nr && i < npages; j++, i++, addr += PAGE_SIZE) {
981 - folio = vas ?
982 - vma_alloc_folio(gfp, 0, vas, addr) :
983 - folio_alloc(gfp, 0);
984 - if (!folio)
985 - goto free_pages;
986 -
987 - page = folio_page(folio, 0);
988 - mpfn[i] = migrate_pfn(page_to_pfn(page));
989 - }
990 - continue;
991 - }
898 + folio = folio_alloc(GFP_HIGHUSER, order);
992 899
993 900 if (!folio)
994 901 goto free_pages;
@@ -1033,11 +940,11 @@ free_pages:
1033 940 if (!page)
1034 941 goto next_put;
1035 942
1036 - order = folio_order(page_folio(page));
1037 -
1038 943 put_page(page);
1039 944 mpfn[i] = 0;
1040 945
946 + order = folio_order(page_folio(page));
947 +
1041 948 next_put:
1042 949 i += NR_PAGES(order);
1043 950 }
@@ -1195,117 +1102,12 @@ void drm_pagemap_put(struct drm_pagemap *dpagemap)
1195 1102 }
1196 1103 EXPORT_SYMBOL(drm_pagemap_put);
1197 1104
1198 - /**
1199 - * drm_pagemap_page_get_flags() - Read flags from a device-private folio
1200 - * @page: Pointer to a page of the device-private folio
1201 - *
1202 - * Return: The DRM_PAGEMAP_ZDD_FLAG_* bits encoded in zone_device_data.
1203 - */
1204 - static unsigned long drm_pagemap_page_get_flags(struct page *page)
1205 - {
1206 - struct folio *folio = page_folio(page);
1207 -
1208 - return (unsigned long)folio_zone_device_data(folio) &
1209 - DRM_PAGEMAP_ZDD_FLAG_MASK;
1210 - }
1211 -
1212 - /**
1213 - * drm_pagemap_page_set_flags() - Set flags on a device-private folio
1214 - * @page: Pointer to a page of the device-private folio
1215 - * @flags: DRM_PAGEMAP_ZDD_FLAG_* bits to set
1216 - *
1217 - * Preserve any flags already encoded alongside the ZDD pointer.
1218 - */
1219 - static void drm_pagemap_page_set_flags(struct page *page,
1220 - unsigned long flags)
1221 - {
1222 - struct folio *folio = page_folio(page);
1223 - unsigned long old;
1224 -
1225 - if (WARN_ON_ONCE(flags & ~DRM_PAGEMAP_ZDD_FLAG_MASK))
1226 - return;
1227 -
1228 - old = (unsigned long)folio_zone_device_data(folio);
1229 - folio_set_zone_device_data(folio, (void *)(old | flags));
1230 - }
1231 -
1232 - /**
1233 - * drm_pagemap_retire_migrated_pages() - Record migrated device-private folios
1234 - * @src_pfns: source array after migrate_vma_pages() or migrate_device_pages()
1235 - * @npages: number of entries in @src_pfns
1236 - *
1237 - * Flag device-private folios successfully migrated to RAM before finalize
1238 - * unlocks the sources. The migrated state is stored in the physical folio, so
1239 - * it survives later folio splits and subsequent migrations can skip it.
1240 - */
1241 - static void drm_pagemap_retire_migrated_pages(unsigned long *src_pfns,
1242 - unsigned long npages)
1243 - {
1244 - unsigned long i = 0;
1245 -
1246 - while (i < npages) {
1247 - struct page *page = migrate_pfn_to_page(src_pfns[i]);
1248 - unsigned long nr = 1;
1249 -
1250 - if (!page) {
1251 - i++;
1252 - continue;
1253 - }
1254 -
1255 - if (src_pfns[i] & MIGRATE_PFN_COMPOUND)
1256 - nr = folio_nr_pages(page_folio(page));
1257 -
1258 - if ((src_pfns[i] & MIGRATE_PFN_MIGRATE) &&
1259 - is_device_private_page(page))
1260 - drm_pagemap_page_set_flags(page,
1261 - DRM_PAGEMAP_ZDD_FLAG_MIGRATED);
1262 -
1263 - i += nr;
1264 - }
1265 - }
1266 -
1267 - /**
1268 - * drm_pagemap_skip_retired_pages() - Skip retired device-private folios
1269 - * @src_pfns: MIGRATE_PFN-encoded source array
1270 - * @npages: number of entries in @src_pfns
1271 - *
1272 - * Skip source folios already migrated to RAM, identified by the migrated flag
1273 - * stored in the physical folio's zone_device_data.
1274 - */
1275 - static void drm_pagemap_skip_retired_pages(unsigned long *src_pfns,
1276 - unsigned long npages)
1277 - {
1278 - unsigned long i = 0;
1279 -
1280 - while (i < npages) {
1281 - struct page *page = migrate_pfn_to_page(src_pfns[i]);
1282 - unsigned long nr = 1;
1283 -
1284 - if (!page) {
1285 - i++;
1286 - continue;
1287 - }
1288 -
1289 - if (src_pfns[i] & MIGRATE_PFN_COMPOUND)
1290 - nr = folio_nr_pages(page_folio(page));
1291 -
1292 - if ((src_pfns[i] & MIGRATE_PFN_MIGRATE) &&
1293 - is_device_private_page(page) &&
1294 - (drm_pagemap_page_get_flags(page) &
1295 - DRM_PAGEMAP_ZDD_FLAG_MIGRATED))
1296 - src_pfns[i] &= ~MIGRATE_PFN_MIGRATE;
1297 -
1298 - i += nr;
1299 - }
1300 - }
1301 -
1302 1105 /**
1303 1106 * drm_pagemap_evict_to_ram() - Evict GPU SVM range to RAM
1304 1107 * @devmem_allocation: Pointer to the device memory allocation
1305 1108 *
1306 - * Similar to __drm_pagemap_migrate_to_ram(), but uses the
1307 - * migrate_device_* helpers and does not require the mmap lock.
1308 - * Device-private PFNs already migrated to RAM by either path are skipped.
1109 + * Similar to __drm_pagemap_migrate_to_ram but does not require mmap lock and
1110 + * migration done via migrate_device_* functions.
1309 1111 *
1310 1112 * Return: 0 on success, negative error code on failure.
1311 1113 */
@@ -1313,18 +1115,17 @@ int drm_pagemap_evict_to_ram(struct drm_pagemap_devmem *devmem_allocation)
1313 1115 {
1314 1116 const struct drm_pagemap_devmem_ops *ops = devmem_allocation->ops;
1315 1117 struct drm_pagemap_iova_state state = {};
1316 - unsigned long npages, mpages;
1118 + unsigned long npages, mpages = 0;
1317 1119 struct page **pages;
1318 1120 unsigned long *src, *dst;
1319 1121 struct drm_pagemap_addr *pagemap_addr;
1320 1122 void *buf;
1321 - int err = 0;
1123 + int i, err = 0;
1322 1124 unsigned int retry_count = 2;
1323 1125
1324 1126 npages = devmem_allocation->size >> PAGE_SHIFT;
1325 1127
1326 1128 retry:
1327 - mpages = 0;
1328 1129 if (!mmget_not_zero(devmem_allocation->mm))
1329 1130 return -EFAULT;
1330 1131
@@ -1347,8 +1148,6 @@ retry:
1347 1148 if (err)
1348 1149 goto err_free;
1349 1150
1350 - drm_pagemap_skip_retired_pages(src, npages);
1351 -
1352 1151 err = drm_pagemap_migrate_populate_ram_pfn(NULL, NULL, npages, &mpages,
1353 1152 src, dst, 0);
1354 1153 if (err || !mpages)
@@ -1361,20 +1160,27 @@ retry:
1361 1160 if (err)
1362 1161 goto err_finalize;
1363 1162
1364 - drm_pagemap_migrate_populate_src_pages(pages, src, dst, npages);
1163 + for (i = 0; i < npages;) {
1164 + unsigned int order = 0;
1165 +
1166 + pages[i] = migrate_pfn_to_page(src[i]);
1167 + if (pages[i])
1168 + order = folio_order(page_folio(pages[i]));
1169 +
1170 + i += NR_PAGES(order);
1171 + }
1365 1172
1366 1173 err = ops->copy_to_ram(pages, pagemap_addr, npages, NULL);
1367 1174 if (err)
1368 1175 goto err_finalize;
1369 1176
1370 1177 err_finalize:
1371 - drm_pagemap_migrate_unmap_pages(devmem_allocation->dev, pagemap_addr, dst, npages,
1372 - DMA_FROM_DEVICE, &state);
1373 1178 if (err)
1374 1179 drm_pagemap_migration_unlock_put_pages(npages, dst);
1375 1180 migrate_device_pages(src, dst, npages);
1376 - drm_pagemap_retire_migrated_pages(src, npages);
1377 1181 migrate_device_finalize(src, dst, npages);
1182 + drm_pagemap_migrate_unmap_pages(devmem_allocation->dev, pagemap_addr, dst, npages,
1183 + DMA_FROM_DEVICE, &state);
1378 1184
1379 1185 err_free:
1380 1186 kvfree(buf);
@@ -1429,7 +1235,7 @@ static int __drm_pagemap_migrate_to_ram(struct vm_area_struct *vas,
1429 1235 struct drm_pagemap_addr *pagemap_addr;
1430 1236 unsigned long start, end;
1431 1237 void *buf;
1432 - int err = 0;
1238 + int i, err = 0;
1433 1239
1434 1240 zdd = drm_pagemap_page_zone_device_data(page);
1435 1241 if (time_before64(get_jiffies_64(), zdd->devmem_allocation->timeslice_expiration))
@@ -1469,15 +1275,13 @@ static int __drm_pagemap_migrate_to_ram(struct vm_area_struct *vas,
1469 1275 if (!migrate.cpages)
1470 1276 goto err_free;
1471 1277
1472 - drm_pagemap_skip_retired_pages(migrate.src, npages);
1473 -
1474 1278 ops = zdd->devmem_allocation->ops;
1475 1279 dev = zdd->devmem_allocation->dev;
1476 1280
1477 1281 err = drm_pagemap_migrate_populate_ram_pfn(vas, page, npages, &mpages,
1478 1282 migrate.src, migrate.dst,
1479 1283 start);
1480 - if (err || !mpages)
1284 + if (err)
1481 1285 goto err_finalize;
1482 1286
1483 1287 err = drm_pagemap_migrate_map_system_pages(dev, pagemap_addr,
@@ -1486,23 +1290,29 @@ static int __drm_pagemap_migrate_to_ram(struct vm_area_struct *vas,
1486 1290 if (err)
1487 1291 goto err_finalize;
1488 1292
1489 - drm_pagemap_migrate_populate_src_pages(pages, migrate.src, migrate.dst,
1490 - npages);
1293 + for (i = 0; i < npages;) {
1294 + unsigned int order = 0;
1295 +
1296 + pages[i] = migrate_pfn_to_page(migrate.src[i]);
1297 + if (pages[i])
1298 + order = folio_order(page_folio(pages[i]));
1299 +
1300 + i += NR_PAGES(order);
1301 + }
1491 1302
1492 1303 err = ops->copy_to_ram(pages, pagemap_addr, npages, NULL);
1493 1304 if (err)
1494 1305 goto err_finalize;
1495 1306
1496 1307 err_finalize:
1497 - if (dev)
1498 - drm_pagemap_migrate_unmap_pages(dev, pagemap_addr, migrate.dst,
1499 - npages, DMA_FROM_DEVICE,
1500 - &state);
1501 1308 if (err)
1502 1309 drm_pagemap_migration_unlock_put_pages(npages, migrate.dst);
1503 1310 migrate_vma_pages(&migrate);
1504 - drm_pagemap_retire_migrated_pages(migrate.src, npages);
1505 1311 migrate_vma_finalize(&migrate);
1312 + if (dev)
1313 + drm_pagemap_migrate_unmap_pages(dev, pagemap_addr, migrate.dst,
1314 + npages, DMA_FROM_DEVICE,
1315 + &state);
1506 1316 err_free:
1507 1317 kvfree(buf);
1508 1318 err_out:
@@ -1550,19 +1360,13 @@ static vm_fault_t drm_pagemap_migrate_to_ram(struct vm_fault *vmf)
1550 1360 static void drm_pagemap_folio_split(struct folio *orig_folio, struct folio *new_folio)
1551 1361 {
1552 1362 struct drm_pagemap_zdd *zdd;
1553 - unsigned long orig_data, new_data;
1554 1363
1555 1364 if (!new_folio)
1556 1365 return;
1557 1366
1558 1367 new_folio->pgmap = orig_folio->pgmap;
1559 -
1560 - orig_data = (unsigned long)folio_zone_device_data(orig_folio);
1561 - zdd = (struct drm_pagemap_zdd *)(orig_data & ~DRM_PAGEMAP_ZDD_FLAG_MASK);
1562 -
1563 - new_data = (unsigned long)drm_pagemap_zdd_get(zdd);
1564 - new_data |= orig_data & DRM_PAGEMAP_ZDD_FLAG_MASK;
1565 - folio_set_zone_device_data(new_folio, (void *)new_data);
1368 + zdd = folio_zone_device_data(orig_folio);
1369 + folio_set_zone_device_data(new_folio, drm_pagemap_zdd_get(zdd));
1566 1370 }
1567 1371
1568 1372 static const struct dev_pagemap_ops drm_pagemap_pagemap_ops = {
modified drivers/gpu/drm/drm_prime.c
@@ -524,7 +524,7 @@ int drm_gem_prime_handle_to_fd(struct drm_device *dev,
524 524 return PTR_ERR(dmabuf);
525 525 }
526 526
527 - dma_buf_fd_install(dmabuf, fd);
527 + fd_install(fd, dmabuf->file);
528 528 *prime_fd = fd;
529 529 return 0;
530 530 }
modified drivers/gpu/drm/drm_syncobj.c
@@ -1619,7 +1619,7 @@ drm_syncobj_timeline_signal_ioctl(struct drm_device *dev, void *data,
1619 1619 goto err_points;
1620 1620 }
1621 1621
1622 - chains = kmalloc_objs(*chains, args->count_handles);
1622 + chains = kmalloc_objs(*chains, args->count_handles, GFP_KERNEL);
1623 1623 if (!chains) {
1624 1624 ret = -ENOMEM;
1625 1625 goto err_points;
modified drivers/gpu/drm/gud/gud_connector.c
@@ -396,16 +396,8 @@ static int gud_connector_add_tv_mode(struct gud_device *gdrm, struct drm_connect
396 396 }
397 397
398 398 num_modes = ret / GUD_CONNECTOR_TV_MODE_NAME_LEN;
399 - for (i = 0; i < num_modes; i++) {
400 - char *mode = &buf[i * GUD_CONNECTOR_TV_MODE_NAME_LEN];
401 -
402 - if (!memchr(mode, '\0', GUD_CONNECTOR_TV_MODE_NAME_LEN)) {
403 - ret = -EIO;
404 - goto free;
405 - }
406 -
407 - modes[i] = mode;
408 - }
399 + for (i = 0; i < num_modes; i++)
400 + modes[i] = &buf[i * GUD_CONNECTOR_TV_MODE_NAME_LEN];
409 401
410 402 ret = drm_mode_create_tv_properties_legacy(connector->dev, num_modes, modes);
411 403 free:
modified drivers/gpu/drm/gud/gud_drv.c
@@ -289,8 +289,6 @@ static int gud_plane_add_properties(struct gud_device *gdrm)
289 289 * but mask out any additions on future devices.
290 290 */
291 291 val &= GUD_ROTATION_MASK;
292 - if (!(val & GUD_ROTATION_0))
293 - continue;
294 292 ret = drm_plane_create_rotation_property(&gdrm->plane,
295 293 DRM_MODE_ROTATE_0, val);
296 294 break;
modified drivers/gpu/drm/i915/display/intel_cdclk.c
@@ -2381,10 +2381,8 @@ static void bxt_sanitize_cdclk(struct intel_display *display)
2381 2381 * dividers both syncing to an active pipe, or asynchronously
2382 2382 * (PIPE_NONE).
2383 2383 */
2384 - if (DISPLAY_VER(display) < 30) {
2385 - cdctl &= ~bxt_cdclk_cd2x_pipe_mask(display);
2386 - cdctl |= bxt_cdclk_cd2x_pipe(display, INVALID_PIPE);
2387 - }
2384 + cdctl &= ~bxt_cdclk_cd2x_pipe_mask(display);
2385 + cdctl |= bxt_cdclk_cd2x_pipe(display, INVALID_PIPE);
2388 2386
2389 2387 if (cdctl != expected) {
2390 2388 if (DISPLAY_VER(display) < 20) {
@@ -2715,8 +2713,8 @@ static void intel_set_cdclk(struct intel_display *display,
2715 2713 }
2716 2714 }
2717 2715
2718 - static int dg2_power_well_count(struct intel_display *display,
2719 - const struct intel_cdclk_state *cdclk_state)
2716 + static bool dg2_power_well_count(struct intel_display *display,
2717 + const struct intel_cdclk_state *cdclk_state)
2720 2718 {
2721 2719 return display->platform.dg2 ? hweight8(cdclk_state->active_pipes) : 0;
2722 2720 }
modified drivers/gpu/drm/i915/display/intel_cursor.c
@@ -530,18 +530,13 @@ static int i9xx_check_cursor(struct intel_crtc_state *crtc_state,
530 530 }
531 531
532 532 static void i9xx_cursor_disable_sel_fetch_arm(struct intel_dsb *dsb,
533 - struct intel_plane *plane)
533 + struct intel_plane *plane,
534 + const struct intel_crtc_state *crtc_state)
534 535 {
535 536 struct intel_display *display = to_intel_display(plane);
536 537 enum pipe pipe = plane->pipe;
537 538
538 - /*
539 - * Clear this whenever the hardware has selective fetch, not just when
540 - * the current state uses it. The cursor may have been enabled with
541 - * selective fetch earlier and had its enable bit orphaned when the
542 - * feature was switched off.
543 - */
544 - if (!HAS_PSR2_SEL_FETCH(display))
539 + if (!crtc_state->enable_psr2_sel_fetch)
545 540 return;
546 541
547 542 intel_de_write_dsb(display, dsb, SEL_FETCH_CUR_CTL(pipe), 0);
@@ -591,7 +586,7 @@ static void i9xx_cursor_update_sel_fetch_arm(struct intel_dsb *dsb,
591 586 if (crtc_state->enable_psr2_su_region_et)
592 587 wa_16021440873(dsb, plane, crtc_state, plane_state);
593 588 else
594 - i9xx_cursor_disable_sel_fetch_arm(dsb, plane);
589 + i9xx_cursor_disable_sel_fetch_arm(dsb, plane, crtc_state);
595 590 }
596 591 }
597 592
@@ -700,7 +695,7 @@ static void i9xx_cursor_update_arm(struct intel_dsb *dsb,
700 695 if (plane_state)
701 696 i9xx_cursor_update_sel_fetch_arm(dsb, plane, crtc_state, plane_state);
702 697 else
703 - i9xx_cursor_disable_sel_fetch_arm(dsb, plane);
698 + i9xx_cursor_disable_sel_fetch_arm(dsb, plane, crtc_state);
704 699
705 700 if (plane->cursor.base != base ||
706 701 plane->cursor.size != fbc_ctl ||
modified drivers/gpu/drm/i915/display/intel_cx0_phy.c
@@ -3233,8 +3233,7 @@ static void intel_cx0pll_enable(struct intel_encoder *encoder,
3233 3233 * 8. Program DDI_CLK_VALFREQ to match intended DDI
3234 3234 * clock frequency.
3235 3235 */
3236 - intel_de_write(display, DDI_CLK_VALFREQ(encoder->port),
3237 - intel_ddi_link_symbol_clock(encoder, port_clock));
3236 + intel_de_write(display, DDI_CLK_VALFREQ(encoder->port), port_clock);
3238 3237
3239 3238 /*
3240 3239 * 9. Set PORT_CLOCK_CTL register PCLK PLL Request
@@ -3407,7 +3406,7 @@ void intel_mtl_tbt_pll_enable_clock(struct intel_encoder *encoder, int port_cloc
3407 3406 * clock frequency.
3408 3407 */
3409 3408 intel_de_write(display, DDI_CLK_VALFREQ(encoder->port),
3410 - intel_ddi_link_symbol_clock(encoder, port_clock));
3409 + port_clock);
3411 3410 }
3412 3411
3413 3412 void intel_mtl_pll_enable(struct intel_encoder *encoder,
modified drivers/gpu/drm/i915/display/intel_ddi.c
@@ -1529,17 +1529,6 @@ int intel_ddi_level(struct intel_encoder *encoder,
1529 1529 return level;
1530 1530 }
1531 1531
1532 - int intel_ddi_link_symbol_clock(struct intel_encoder *encoder, int clock)
1533 - {
1534 - if (intel_encoder_is_dp(encoder))
1535 - return intel_dp_link_symbol_clock(clock);
1536 -
1537 - if (intel_hdmi_is_frl(clock))
1538 - return DIV_ROUND_CLOSEST(clock * 10, 18);
1539 -
1540 - return clock;
1541 - }
1542 -
1543 1532 static void
1544 1533 hsw_set_signal_levels(struct intel_encoder *encoder,
1545 1534 const struct intel_crtc_state *crtc_state)
modified drivers/gpu/drm/i915/display/intel_ddi.h
@@ -81,7 +81,6 @@ void intel_ddi_sanitize_encoder_pll_mapping(struct intel_encoder *encoder);
81 81 int intel_ddi_level(struct intel_encoder *encoder,
82 82 const struct intel_crtc_state *crtc_state,
83 83 int lane);
84 - int intel_ddi_link_symbol_clock(struct intel_encoder *encoder, int clock);
85 84 void intel_ddi_update_active_dpll(struct intel_atomic_state *state,
86 85 struct intel_encoder *encoder,
87 86 struct intel_crtc *crtc);
modified drivers/gpu/drm/i915/display/intel_dp_mst.c
@@ -761,6 +761,10 @@ static int mst_stream_compute_config(struct intel_atomic_state *state,
761 761 pipe_config->sink_format = INTEL_OUTPUT_FORMAT_RGB;
762 762 pipe_config->output_format = INTEL_OUTPUT_FORMAT_RGB;
763 763
764 + ret = intel_pfit_compute_config(pipe_config, conn_state);
765 + if (ret)
766 + return ret;
767 +
764 768 ret = intel_pfit_compute_config(pipe_config, conn_state);
765 769 if (ret)
766 770 return ret;
modified drivers/gpu/drm/i915/display/intel_lt_phy.c
@@ -1976,8 +1976,7 @@ void intel_lt_phy_pll_enable(struct intel_encoder *encoder,
1976 1976 * Change. We handle this step in bxt_set_cdclk().
1977 1977 */
1978 1978 /* 10. Program DDI_CLK_VALFREQ to match intended DDI clock frequency. */
1979 - intel_de_write(display, DDI_CLK_VALFREQ(encoder->port),
1980 - intel_ddi_link_symbol_clock(encoder, port_clock));
1979 + intel_de_write(display, DDI_CLK_VALFREQ(encoder->port), port_clock);
1981 1980
1982 1981 /* 11. Program PORT_CLOCK_CTL[PCLK PLL Request LN0] = 1. */
1983 1982 intel_de_rmw(display, XELPDP_PORT_CLOCK_CTL(display, port),
@@ -2024,8 +2023,7 @@ void intel_lt_phy_pll_enable(struct intel_encoder *encoder,
2024 2023 lane_phy_pulse_status,
2025 2024 lane_phy_pulse_status);
2026 2025 } else {
2027 - intel_de_write(display, DDI_CLK_VALFREQ(encoder->port),
2028 - intel_ddi_link_symbol_clock(encoder, port_clock));
2026 + intel_de_write(display, DDI_CLK_VALFREQ(encoder->port), port_clock);
2029 2027 }
2030 2028
2031 2029 /*
modified drivers/gpu/drm/i915/display/skl_universal_plane.c
@@ -879,18 +879,13 @@ skl_plane_disable_arm(struct intel_dsb *dsb,
879 879 }
880 880
881 881 static void icl_plane_disable_sel_fetch_arm(struct intel_dsb *dsb,
882 - struct intel_plane *plane)
882 + struct intel_plane *plane,
883 + const struct intel_crtc_state *crtc_state)
883 884 {
884 885 struct intel_display *display = to_intel_display(plane);
885 886 enum pipe pipe = plane->pipe;
886 887
887 - /*
888 - * Clear this whenever the hardware has selective fetch, not just when
889 - * the current state uses it. The plane may have been enabled with
890 - * selective fetch earlier and had its enable bit orphaned when the
891 - * feature was switched off.
892 - */
893 - if (!HAS_PSR2_SEL_FETCH(display))
888 + if (!crtc_state->enable_psr2_sel_fetch)
894 889 return;
895 890
896 891 intel_de_write_dsb(display, dsb, SEL_FETCH_PLANE_CTL(pipe, plane->id), 0);
@@ -926,7 +921,7 @@ icl_plane_disable_arm(struct intel_dsb *dsb,
926 921
927 922 skl_write_plane_wm(dsb, plane, crtc_state);
928 923
929 - icl_plane_disable_sel_fetch_arm(dsb, plane);
924 + icl_plane_disable_sel_fetch_arm(dsb, plane, crtc_state);
930 925
931 926 if (plane_has_normalizer(plane))
932 927 intel_de_write_dsb(display, dsb,
@@ -1646,7 +1641,7 @@ static void icl_plane_update_sel_fetch_arm(struct intel_dsb *dsb,
1646 1641 intel_de_write_dsb(display, dsb, SEL_FETCH_PLANE_CTL(pipe, plane->id),
1647 1642 SEL_FETCH_PLANE_CTL_ENABLE);
1648 1643 else
1649 - icl_plane_disable_sel_fetch_arm(dsb, plane);
1644 + icl_plane_disable_sel_fetch_arm(dsb, plane, crtc_state);
1650 1645 }
1651 1646
1652 1647 static void
modified drivers/gpu/drm/i915/i915_pci.c
@@ -958,9 +958,6 @@ static int i915_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
958 958 (struct intel_device_info *) ent->driver_data;
959 959 int err;
960 960
961 - if (!intel_info)
962 - return -ENODEV;
963 -
964 961 if (intel_info->require_force_probe && !id_forced(pdev->device)) {
965 962 dev_info(&pdev->dev,
966 963 "Your graphics device %04x is not properly supported by i915 in this\n"
modified drivers/gpu/drm/nouveau/include/nvkm/engine/disp.h
@@ -87,5 +87,4 @@ int gp102_disp_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct
87 87 int gv100_disp_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_disp **);
88 88 int tu102_disp_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_disp **);
89 89 int ga102_disp_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_disp **);
90 - int gb202_disp_new(struct nvkm_device *, enum nvkm_subdev_type, int inst, struct nvkm_disp **);
91 90 #endif
modified drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -90,14 +90,6 @@ nouveau_channel_del(struct nouveau_channel **pchan)
90 90 {
91 91 struct nouveau_channel *chan = *pchan;
92 92 if (chan) {
93 - /*
94 - * Drop the kill-event subscription first. Its handler
95 - * dereferences chan->fence, which the fence context teardown
96 - * below frees, so leaving it armed across the teardown leaves
97 - * a window for a use-after-free.
98 - */
99 - nvif_event_dtor(&chan->kill);
100 -
101 93 if (chan->fence)
102 94 nouveau_fence(chan->cli->drm)->context_del(chan);
103 95
@@ -108,6 +100,7 @@ nouveau_channel_del(struct nouveau_channel **pchan)
108 100 nvif_object_dtor(&chan->nvsw);
109 101 nvif_object_dtor(&chan->gart);
110 102 nvif_object_dtor(&chan->vram);
103 + nvif_event_dtor(&chan->kill);
111 104 nvif_object_dtor(&chan->user);
112 105 nvif_mem_dtor(&chan->mem_userd);
113 106 nouveau_vma_del(&chan->sema.vma);
modified drivers/gpu/drm/nouveau/nouveau_dmem.c
@@ -267,7 +267,7 @@ static vm_fault_t nouveau_dmem_migrate_to_ram(struct vm_fault *vmf)
267 267 nouveau_fence_new(&fence, dmem->migrate.chan);
268 268 migrate_vma_pages(&args);
269 269 nouveau_dmem_fence_done(&fence);
270 - dma_unmap_page(drm->dev->dev, dma_info.dma_addr, dma_info.size,
270 + dma_unmap_page(drm->dev->dev, dma_info.dma_addr, PAGE_SIZE,
271 271 DMA_BIDIRECTIONAL);
272 272 done:
273 273 migrate_vma_finalize(&args);
@@ -279,25 +279,11 @@ err:
279 279
280 280 static void nouveau_dmem_folio_split(struct folio *head, struct folio *tail)
281 281 {
282 - struct nouveau_dmem_chunk *chunk;
283 - struct nouveau_dmem *dmem;
284 -
285 282 if (tail == NULL)
286 283 return;
287 284 tail->pgmap = head->pgmap;
288 285 tail->mapping = head->mapping;
289 286 folio_set_zone_device_data(tail, folio_zone_device_data(head));
290 -
291 - /*
292 - * The split hands out a new independently-freeable folio that will
293 - * later be released via nouveau_dmem_folio_free(); account for it so
294 - * chunk->callocated stays balanced.
295 - */
296 - chunk = nouveau_page_to_chunk(&head->page);
297 - dmem = chunk->drm->dmem;
298 - spin_lock(&dmem->lock);
299 - chunk->callocated++;
300 - spin_unlock(&dmem->lock);
301 287 }
302 288
303 289 static const struct dev_pagemap_ops nouveau_dmem_pagemap_ops = {
@@ -786,7 +772,7 @@ static unsigned long nouveau_dmem_migrate_copy_one(struct nouveau_drm *drm,
786 772 return mpfn;
787 773
788 774 out_dma_unmap:
789 - dma_unmap_page(dev, dma_info->dma_addr, dma_info->size, DMA_BIDIRECTIONAL);
775 + dma_unmap_page(dev, dma_info->dma_addr, PAGE_SIZE, DMA_BIDIRECTIONAL);
790 776 out_free_page:
791 777 nouveau_dmem_page_free_locked(drm, dpage);
792 778 out:
modified drivers/gpu/drm/nouveau/nouveau_sgdma.c
@@ -72,7 +72,9 @@ nouveau_sgdma_create_ttm(struct ttm_buffer_object *bo, uint32_t page_flags)
72 72 struct nouveau_sgdma_be *nvbe;
73 73 enum ttm_caching caching;
74 74
75 - if (nvbo->force_coherent || drm->agp.bridge)
75 + if (nvbo->force_coherent)
76 + caching = ttm_uncached;
77 + else if (drm->agp.bridge)
76 78 caching = ttm_write_combined;
77 79 else
78 80 caching = ttm_cached;
modified drivers/gpu/drm/nouveau/nouveau_uvmm.c
@@ -1319,7 +1319,6 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job,
1319 1319 op->va.range);
1320 1320 if (!op->reg || op->reg->dirty) {
1321 1321 ret = -ENOENT;
1322 - op->reg = NULL;
1323 1322 goto unwind_continue;
1324 1323 }
1325 1324
@@ -1328,7 +1327,6 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job,
1328 1327 op->va.range);
1329 1328 if (IS_ERR(op->ops)) {
1330 1329 ret = PTR_ERR(op->ops);
1331 - op->reg = NULL;
1332 1330 goto unwind_continue;
1333 1331 }
1334 1332
@@ -1475,7 +1473,6 @@ unwind:
1475 1473 op->va.range);
1476 1474 break;
1477 1475 case OP_UNMAP_SPARSE:
1478 - op->reg->dirty = false;
1479 1476 __nouveau_uvma_region_insert(uvmm, op->reg);
1480 1477 nouveau_uvmm_sm_unmap_prepare_unwind(uvmm, &op->new,
1481 1478 op->ops);
@@ -1492,8 +1489,7 @@ unwind:
1492 1489 break;
1493 1490 }
1494 1491
1495 - if (!IS_ERR_OR_NULL(op->ops))
1496 - drm_gpuva_ops_free(&uvmm->base, op->ops);
1492 + drm_gpuva_ops_free(&uvmm->base, op->ops);
1497 1493 op->ops = NULL;
1498 1494 op->reg = NULL;
1499 1495 }
modified drivers/gpu/drm/nouveau/nvkm/engine/device/base.c
@@ -2846,7 +2846,7 @@ nv1b2_chipset = {
2846 2846 .pci = { 0x00000001, gh100_pci_new },
2847 2847 .timer = { 0x00000001, gk20a_timer_new },
2848 2848 .vfn = { 0x00000001, ga100_vfn_new },
2849 - .disp = { 0x00000001, gb202_disp_new },
2849 + .disp = { 0x00000001, ga102_disp_new },
2850 2850 .fifo = { 0x00000001, ga102_fifo_new },
2851 2851 };
2852 2852
@@ -2862,7 +2862,7 @@ nv1b3_chipset = {
2862 2862 .pci = { 0x00000001, gh100_pci_new },
2863 2863 .timer = { 0x00000001, gk20a_timer_new },
2864 2864 .vfn = { 0x00000001, ga100_vfn_new },
2865 - .disp = { 0x00000001, gb202_disp_new },
2865 + .disp = { 0x00000001, ga102_disp_new },
2866 2866 .fifo = { 0x00000001, ga102_fifo_new },
2867 2867 };
2868 2868
@@ -2878,7 +2878,7 @@ nv1b5_chipset = {
2878 2878 .pci = { 0x00000001, gh100_pci_new },
2879 2879 .timer = { 0x00000001, gk20a_timer_new },
2880 2880 .vfn = { 0x00000001, ga100_vfn_new },
2881 - .disp = { 0x00000001, gb202_disp_new },
2881 + .disp = { 0x00000001, ga102_disp_new },
2882 2882 .fifo = { 0x00000001, ga102_fifo_new },
2883 2883 };
2884 2884
@@ -2894,7 +2894,7 @@ nv1b6_chipset = {
2894 2894 .pci = { 0x00000001, gh100_pci_new },
2895 2895 .timer = { 0x00000001, gk20a_timer_new },
2896 2896 .vfn = { 0x00000001, ga100_vfn_new },
2897 - .disp = { 0x00000001, gb202_disp_new },
2897 + .disp = { 0x00000001, ga102_disp_new },
2898 2898 .fifo = { 0x00000001, ga102_fifo_new },
2899 2899 };
2900 2900
@@ -2910,7 +2910,7 @@ nv1b7_chipset = {
2910 2910 .pci = { 0x00000001, gh100_pci_new },
2911 2911 .timer = { 0x00000001, gk20a_timer_new },
2912 2912 .vfn = { 0x00000001, ga100_vfn_new },
2913 - .disp = { 0x00000001, gb202_disp_new },
2913 + .disp = { 0x00000001, ga102_disp_new },
2914 2914 .fifo = { 0x00000001, ga102_fifo_new },
2915 2915 };
2916 2916
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/Kbuild
@@ -27,7 +27,6 @@ nvkm-y += nvkm/engine/disp/gp102.o
27 27 nvkm-y += nvkm/engine/disp/gv100.o
28 28 nvkm-y += nvkm/engine/disp/tu102.o
29 29 nvkm-y += nvkm/engine/disp/ga102.o
30 - nvkm-y += nvkm/engine/disp/gb202.o
31 30
32 31 nvkm-y += nvkm/engine/disp/udisp.o
33 32 nvkm-y += nvkm/engine/disp/uconn.o
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/ga102.c
@@ -144,23 +144,12 @@ ga102_disp = {
144 144 },
145 145 };
146 146
147 - static const struct nvkm_disp_func
148 - ga102_gsp_disp = {
149 - .uevent = &gv100_disp_chan_uevent,
150 - .ramht_size = 0x2000,
151 - .gsp.intr = tu102_disp_intr,
152 - .gsp.head = &tu102_gsp_head,
153 - .gsp.hdmi_gcp = tu102_sor_hdmi_gcp,
154 - .gsp.hdmi_infoframe_avi = gv100_sor_hdmi_infoframe_avi,
155 - .gsp.hdmi_infoframe_vsi = gv100_sor_hdmi_infoframe_vsi,
156 - };
157 -
158 147 int
159 148 ga102_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
160 149 struct nvkm_disp **pdisp)
161 150 {
162 151 if (nvkm_gsp_rm(device->gsp))
163 - return r535_disp_new(&ga102_gsp_disp, device, type, inst, pdisp);
152 + return r535_disp_new(&ga102_disp, device, type, inst, pdisp);
164 153
165 154 return nvkm_disp_new_(&ga102_disp, device, type, inst, pdisp);
166 155 }
deleted drivers/gpu/drm/nouveau/nvkm/engine/disp/gb202.c mode 100644
@@ -1,191 +0,0 @@
1 - // SPDX-License-Identifier: MIT
2 - /*
3 - * Copyright 2026 Valve Corp.
4 - */
5 - #include "priv.h"
6 - #include "head.h"
7 - #include "ior.h"
8 -
9 - #include <subdev/timer.h>
10 -
11 - /* GB20x (NVD5.0) reorganised the SF HDMI packet units. The AVI unit is
12 - * unchanged from GV100, but the legacy VSI unit is gone. Vendor infoframes
13 - * are sent through the shared generic infoframe units instead. Register
14 - * layout per NVIDIA's clc971.h/clca71.h, programming sequence per
15 - * nvhdmipkt_C971.c:programAdvancedInfoframeC971().
16 - */
17 - static void
18 - gb202_sor_hdmi_infoframe_vsi(struct nvkm_ior *ior, int head, void *data, u32 size)
19 - {
20 - struct nvkm_device *device = ior->disp->engine.subdev.device;
21 - const u32 hoff = head * 0x400;
22 - /* Generic infoframe unit 1, the slot NVIDIA's driver uses for the VSI. */
23 - const u32 ctrl = 0x6f0138 + hoff;
24 - u8 buf[36] = {};
25 - int i;
26 -
27 - /* Disable the unit and wait for it to go idle. */
28 - nvkm_mask(device, ctrl, 0x00000001, 0x00000000);
29 - if (nvkm_msec(device, 2000,
30 - if (!(nvkm_rd32(device, ctrl) & 0x00400000))
31 - break;
32 - ) < 0)
33 - return;
34 -
35 - if (!size)
36 - return;
37 -
38 - /* Clear SENT status, and point the data port at unit 1's slot. */
39 - nvkm_mask(device, ctrl, 0x00800000, 0x00800000);
40 - nvkm_wr32(device, 0x6f03f0 + hoff, 0x00000001);
41 -
42 - /* The data port takes the raw packet, except that a zero is inserted
43 - * in HB3 after the three header bytes. A slot is 9 dwords (HB0-3 plus
44 - * up to 32 payload bytes). An HDMI infoframe carries at most PB0-27,
45 - * so the tail stays zero, and we always write the whole slot.
46 - */
47 - size = min_t(u32, size, 31);
48 - memcpy(buf, data, min_t(u32, size, 3));
49 - if (size > 3)
50 - memcpy(&buf[4], (u8 *)data + 3, size - 3);
51 -
52 - for (i = 0; i < 36; i += 4) {
53 - nvkm_wr32(device, 0x6f03f4 + hoff, buf[i + 0] | buf[i + 1] << 8 |
54 - buf[i + 2] << 16 |
55 - (u32)buf[i + 3] << 24);
56 - }
57 -
58 - /* No flip ID or scanline matching. */
59 - nvkm_wr32(device, 0x6f013c + hoff, 0x00000000);
60 -
61 - /* ENABLE | RUN_MODE=ALWAYS | LOC=VBLANK | OFFSET=1 | SIZE=0. */
62 - nvkm_wr32(device, ctrl, 0x00000041);
63 -
64 - /* Audio priority low (the init value). */
65 - nvkm_wr32(device, 0x6f03f8 + hoff, 0x00000002);
66 - }
67 -
68 - /* General Control Packet AVMute bracket. The GCP unit moved to slot 1 on
69 - * NVD5.0. Only SB0 (the AVMute bit) is ours to write so we must not do a
70 - * full write here: SB1 carries the deep-color CD/PP fields, and SB1_CTRL
71 - * (bit 24, new with clc871.h) controls where their generation happens (HW
72 - * or driver) on these chips, with the default being HW.
73 - */
74 - static void
75 - gb202_sor_hdmi_gcp(struct nvkm_ior *sor, int head, bool enable)
76 - {
77 - struct nvkm_device *device = sor->disp->engine.subdev.device;
78 - const u32 hdmi = head * 0x400;
79 -
80 - nvkm_mask(device, 0x6f0040 + hdmi, 0x00000001, 0x00000000);
81 - nvkm_mask(device, 0x6f004c + hdmi, 0x000000ff, !enable ? 0x00000001 :
82 - 0x00000010);
83 - nvkm_mask(device, 0x6f0040 + hdmi, 0x00000001, 0x00000001);
84 - }
85 -
86 - /* Same core-channel state mirror as gv100_head_state() (assembly at 0x680000,
87 - * armed at +0x8000, per-head method offsets unchanged), but NVD5.0 spaces
88 - * heads 0x800 apart (see NVCA7D_HEAD_SET_*(a) in clca7d.h).
89 - */
90 - static void
91 - gb202_head_state(struct nvkm_head *head, struct nvkm_head_state *state)
92 - {
93 - struct nvkm_device *device = head->disp->engine.subdev.device;
94 - const u32 hoff = (state == &head->arm) * 0x8000 + head->id * 0x800;
95 - u32 data;
96 -
97 - data = nvkm_rd32(device, 0x682064 + hoff);
98 - state->vtotal = (data & 0xffff0000) >> 16;
99 - state->htotal = (data & 0x0000ffff);
100 - data = nvkm_rd32(device, 0x682068 + hoff);
101 - state->vsynce = (data & 0xffff0000) >> 16;
102 - state->hsynce = (data & 0x0000ffff);
103 - data = nvkm_rd32(device, 0x68206c + hoff);
104 - state->vblanke = (data & 0xffff0000) >> 16;
105 - state->hblanke = (data & 0x0000ffff);
106 - data = nvkm_rd32(device, 0x682070 + hoff);
107 - state->vblanks = (data & 0xffff0000) >> 16;
108 - state->hblanks = (data & 0x0000ffff);
109 - /* Bit 31 is ADJ1000DIV1001, not a HERTZ bit. We don't have enough bits
110 - * to add the full clock in hz on Blackwell (35 bits), but state->hz
111 - * is unused and obsolete under GSP so this is fine.
112 - */
113 - state->hz = nvkm_rd32(device, 0x68200c + hoff) & 0x7fffffff;
114 -
115 - data = nvkm_rd32(device, 0x682004 + hoff);
116 - switch ((data & 0x000000f0) >> 4) {
117 - case 5: state->or.depth = 30; break;
118 - case 4: state->or.depth = 24; break;
119 - case 1: state->or.depth = 18; break;
120 - default:
121 - state->or.depth = 18;
122 - WARN_ON(1);
123 - break;
124 - }
125 - }
126 -
127 - /* NVD5.0 (GB20x and later) moved the RM head-timing interrupt enable to
128 - * the low-latency vector's EN1 block. The event latch is unchanged.
129 - */
130 - static void
131 - gb202_head_vblank_put(struct nvkm_head *head)
132 - {
133 - struct nvkm_device *device = head->disp->engine.subdev.device;
134 -
135 - nvkm_mask(device, 0x611ef0 + (head->id * 4), 0x00000002, 0x00000000);
136 - }
137 -
138 - static void
139 - gb202_head_vblank_get(struct nvkm_head *head)
140 - {
141 - struct nvkm_device *device = head->disp->engine.subdev.device;
142 -
143 - nvkm_wr32(device, 0x611800 + (head->id * 4), 0x00000002);
144 - nvkm_mask(device, 0x611ef0 + (head->id * 4), 0x00000002, 0x00000002);
145 - }
146 -
147 - static irqreturn_t
148 - gb202_disp_intr(struct nvkm_inth *inth)
149 - {
150 - struct nvkm_disp *disp = container_of(inth, typeof(*disp), engine.subdev.inth);
151 - irqreturn_t ret = tu102_disp_intr(inth);
152 -
153 - /* The FE interrupt vectors are message-based on NVD5.0. Re-arm the
154 - * low-latency vector so it fires again for any event that latched
155 - * while we were servicing.
156 - */
157 - nvkm_wr32(disp->engine.subdev.device, 0x611f34, 0x00000001);
158 - return ret;
159 - }
160 -
161 - static const struct nvkm_head_func
162 - gb202_gsp_head = {
163 - .state = gb202_head_state,
164 - .rgpos = gv100_head_rgpos,
165 - .vblank_get = gb202_head_vblank_get,
166 - .vblank_put = gb202_head_vblank_put,
167 - };
168 -
169 - /* GB20x is GSP-only. This table supplies the register programming the
170 - * GSP-RM display path needs from the chip.
171 - */
172 - static const struct nvkm_disp_func
173 - gb202_gsp_disp = {
174 - .uevent = &gv100_disp_chan_uevent,
175 - .ramht_size = 0x2000,
176 - /* Head timing arrives on the dedicated low-latency vector. */
177 - .gsp.intr = gb202_disp_intr,
178 - .gsp.intr_low_latency = true,
179 - .gsp.head = &gb202_gsp_head,
180 - .gsp.hdmi_gcp = gb202_sor_hdmi_gcp,
181 - /* The legacy AVI unit is unchanged on GB20x. */
182 - .gsp.hdmi_infoframe_avi = gv100_sor_hdmi_infoframe_avi,
183 - .gsp.hdmi_infoframe_vsi = gb202_sor_hdmi_infoframe_vsi,
184 - };
185 -
186 - int
187 - gb202_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
188 - struct nvkm_disp **pdisp)
189 - {
190 - return r535_disp_new(&gb202_gsp_disp, device, type, inst, pdisp);
191 - }
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/head.h
@@ -56,8 +56,6 @@ int gv100_head_new(struct nvkm_disp *, int id);
56 56 void gv100_head_state(struct nvkm_head *head, struct nvkm_head_state *state);
57 57 void gv100_head_rgpos(struct nvkm_head *head, u16 *hline, u16 *vline);
58 58
59 - extern const struct nvkm_head_func tu102_gsp_head;
60 -
61 59 #define HEAD_MSG(h,l,f,a...) do { \
62 60 struct nvkm_head *_h = (h); \
63 61 nvkm_##l(&_h->disp->engine.subdev, "head-%d: "f"\n", _h->id, ##a); \
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/ior.h
@@ -194,7 +194,6 @@ void gv100_sor_dp_audio_sym(struct nvkm_ior *, int, u16, u32);
194 194 void gv100_sor_dp_watermark(struct nvkm_ior *, int, u8);
195 195 extern const struct nvkm_ior_func_hda gv100_sor_hda;
196 196
197 - void tu102_sor_hdmi_gcp(struct nvkm_ior *, int, bool);
198 197 void tu102_sor_dp_vcpi(struct nvkm_ior *, int, u8, u8, u16, u16);
199 198
200 199 int nv50_pior_cnt(struct nvkm_disp *, unsigned long *);
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/priv.h
@@ -5,8 +5,6 @@
5 5 #include <engine/disp.h>
6 6 #include <core/enum.h>
7 7 struct nvkm_head;
8 - struct nvkm_head_func;
9 - struct nvkm_ior;
10 8 struct nvkm_outp;
11 9 struct dcb_output;
12 10
@@ -36,20 +34,6 @@ struct nvkm_disp_func {
36 34 int (*new)(struct nvkm_disp *, int id);
37 35 } wndw, head, dac, sor, pior;
38 36
39 - /* Register programming that the GSP-RM display path (rm/r535) needs from
40 - * the chip, everything else on that path goes through RM. The hooks are
41 - * called unconditionally and the head table is handed to nvkm_head_new_().
42 - */
43 - struct {
44 - irqreturn_t (*intr)(struct nvkm_inth *);
45 - /* Head-timing interrupts arrive on a second DISP vector. */
46 - bool intr_low_latency;
47 - const struct nvkm_head_func *head;
48 - void (*hdmi_gcp)(struct nvkm_ior *, int head, bool enable);
49 - void (*hdmi_infoframe_avi)(struct nvkm_ior *, int head, void *data, u32 size);
50 - void (*hdmi_infoframe_vsi)(struct nvkm_ior *, int head, void *data, u32 size);
51 - } gsp;
52 -
53 37 u16 ramht_size;
54 38
55 39 struct nvkm_sclass root;
@@ -88,7 +72,6 @@ int gv100_disp_wndw_cnt(struct nvkm_disp *, unsigned long *);
88 72 int gv100_disp_caps_new(const struct nvkm_oclass *, void *, u32, struct nvkm_object **);
89 73
90 74 int tu102_disp_init(struct nvkm_disp *);
91 - irqreturn_t tu102_disp_intr(struct nvkm_inth *);
92 75
93 76 void nv50_disp_dptmds_war_2(struct nvkm_disp *, struct dcb_output *);
94 77 void nv50_disp_dptmds_war_3(struct nvkm_disp *, struct dcb_output *);
modified drivers/gpu/drm/nouveau/nvkm/engine/disp/tu102.c
@@ -30,21 +30,6 @@
30 30
31 31 #include <nvif/class.h>
32 32
33 - /* General Control Packet: bracket an audio enable/disable with AVMute
34 - * through the legacy GCP SF unit. Used by the GSP-RM path, which sends the
35 - * equivalent packet via RM as well but keeps the direct write in sync.
36 - */
37 - void
38 - tu102_sor_hdmi_gcp(struct nvkm_ior *sor, int head, bool enable)
39 - {
40 - struct nvkm_device *device = sor->disp->engine.subdev.device;
41 - const u32 hdmi = head * 0x400;
42 -
43 - nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000000);
44 - nvkm_wr32(device, 0x6f00cc + hdmi, !enable ? 0x00000001 : 0x00000010);
45 - nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000001);
46 - }
47 -
48 33 void
49 34 tu102_sor_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, u16 aligned)
50 35 {
@@ -119,64 +104,6 @@ tu102_sor_new(struct nvkm_disp *disp, int id)
119 104 return nvkm_ior_new_(&tu102_sor, disp, SOR, id, hda & BIT(id));
120 105 }
121 106
122 - /* The GSP-RM display path leaves head-timing (vblank) interrupts and their
123 - * enables to us. These program the RM head-timing line (bit 1 of the
124 - * per-head enable, not the bit nvkm's own gv100 path uses).
125 - */
126 - static void
127 - tu102_head_vblank_put(struct nvkm_head *head)
128 - {
129 - struct nvkm_device *device = head->disp->engine.subdev.device;
130 -
131 - nvkm_mask(device, 0x611d80 + (head->id * 4), 0x00000002, 0x00000000);
132 - }
133 -
134 - static void
135 - tu102_head_vblank_get(struct nvkm_head *head)
136 - {
137 - struct nvkm_device *device = head->disp->engine.subdev.device;
138 -
139 - nvkm_wr32(device, 0x611800 + (head->id * 4), 0x00000002);
140 - nvkm_mask(device, 0x611d80 + (head->id * 4), 0x00000002, 0x00000002);
141 - }
142 -
143 - const struct nvkm_head_func
144 - tu102_gsp_head = {
145 - .state = gv100_head_state,
146 - .rgpos = gv100_head_rgpos,
147 - .vblank_get = tu102_head_vblank_get,
148 - .vblank_put = tu102_head_vblank_put,
149 - };
150 -
151 - static void
152 - tu102_disp_intr_head_timing(struct nvkm_disp *disp, int head)
153 - {
154 - struct nvkm_subdev *subdev = &disp->engine.subdev;
155 - struct nvkm_device *device = subdev->device;
156 - u32 stat = nvkm_rd32(device, 0x611c00 + (head * 0x04));
157 -
158 - if (stat & 0x00000002) {
159 - nvkm_disp_vblank(disp, head);
160 -
161 - nvkm_wr32(device, 0x611800 + (head * 0x04), 0x00000002);
162 - }
163 - }
164 -
165 - irqreturn_t
166 - tu102_disp_intr(struct nvkm_inth *inth)
167 - {
168 - struct nvkm_disp *disp = container_of(inth, typeof(*disp), engine.subdev.inth);
169 - struct nvkm_subdev *subdev = &disp->engine.subdev;
170 - struct nvkm_device *device = subdev->device;
171 - unsigned long mask = nvkm_rd32(device, 0x611ec0) & 0x000000ff;
172 - int head;
173 -
174 - for_each_set_bit(head, &mask, 8)
175 - tu102_disp_intr_head_timing(disp, head);
176 -
177 - return IRQ_HANDLED;
178 - }
179 -
180 107 int
181 108 tu102_disp_init(struct nvkm_disp *disp)
182 109 {
@@ -303,23 +230,12 @@ tu102_disp = {
303 230 },
304 231 };
305 232
306 - static const struct nvkm_disp_func
307 - tu102_gsp_disp = {
308 - .uevent = &gv100_disp_chan_uevent,
309 - .ramht_size = 0x2000,
310 - .gsp.intr = tu102_disp_intr,
311 - .gsp.head = &tu102_gsp_head,
312 - .gsp.hdmi_gcp = tu102_sor_hdmi_gcp,
313 - .gsp.hdmi_infoframe_avi = gv100_sor_hdmi_infoframe_avi,
314 - .gsp.hdmi_infoframe_vsi = gv100_sor_hdmi_infoframe_vsi,
315 - };
316 -
317 233 int
318 234 tu102_disp_new(struct nvkm_device *device, enum nvkm_subdev_type type, int inst,
319 235 struct nvkm_disp **pdisp)
320 236 {
321 237 if (nvkm_gsp_rm(device->gsp))
322 - return r535_disp_new(&tu102_gsp_disp, device, type, inst, pdisp);
238 + return r535_disp_new(&tu102_disp, device, type, inst, pdisp);
323 239
324 240 return nvkm_disp_new_(&tu102_disp, device, type, inst, pdisp);
325 241 }
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/disp.c
@@ -400,16 +400,16 @@ r535_sor_dp_audio(struct nvkm_ior *sor, int head, bool enable)
400 400 r535_sor_dp_audio_mute(sor, false);
401 401 }
402 402
403 - static int
404 - r535_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn)
403 + static void
404 + r535_sor_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn)
405 405 {
406 406 struct nvkm_disp *disp = sor->disp;
407 407 struct NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS *ctrl;
408 408
409 409 ctrl = nvkm_gsp_rm_ctrl_get(&disp->rm.objcom,
410 410 NV0073_CTRL_CMD_DP_CONFIG_STREAM, sizeof(*ctrl));
411 - if (IS_ERR(ctrl))
412 - return PTR_ERR(ctrl);
411 + if (WARN_ON(IS_ERR(ctrl)))
412 + return;
413 413
414 414 ctrl->subDeviceInstance = 0;
415 415 ctrl->head = head;
@@ -429,20 +429,12 @@ r535_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, u16 a
429 429 ctrl->MST.sendACT = 0;
430 430 ctrl->MST.singleHeadMSTPipeline = 0;
431 431 ctrl->MST.bEnableAudioOverRightPanel = 0;
432 - return nvkm_gsp_rm_ctrl_wr(&disp->rm.objcom, ctrl);
433 - }
434 -
435 - static void
436 - r535_sor_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn)
437 - {
438 - const struct nvkm_rm_api *rmapi = sor->disp->engine.subdev.device->gsp->rm->api;
439 -
440 - WARN_ON(rmapi->disp->dp.vcpi(sor, head, slot, slot_nr, pbn, aligned_pbn));
432 + WARN_ON(nvkm_gsp_rm_ctrl_wr(&disp->rm.objcom, ctrl));
441 433 }
442 434
443 435 static int
444 - r535_dp_sst(struct nvkm_ior *sor, int head, bool ef,
445 - u32 watermark, u32 hblanksym, u32 vblanksym)
436 + r535_sor_dp_sst(struct nvkm_ior *sor, int head, bool ef,
437 + u32 watermark, u32 hblanksym, u32 vblanksym)
446 438 {
447 439 struct nvkm_disp *disp = sor->disp;
448 440 struct NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS *ctrl;
@@ -469,15 +461,6 @@ r535_dp_sst(struct nvkm_ior *sor, int head, bool ef,
469 461 return nvkm_gsp_rm_ctrl_wr(&disp->rm.objcom, ctrl);
470 462 }
471 463
472 - static int
473 - r535_sor_dp_sst(struct nvkm_ior *sor, int head, bool ef,
474 - u32 watermark, u32 hblanksym, u32 vblanksym)
475 - {
476 - const struct nvkm_rm_api *rmapi = sor->disp->engine.subdev.device->gsp->rm->api;
477 -
478 - return rmapi->disp->dp.sst(sor, head, ef, watermark, hblanksym, vblanksym);
479 - }
480 -
481 464 static const struct nvkm_ior_func_dp
482 465 r535_sor_dp = {
483 466 .sst = r535_sor_dp_sst,
@@ -562,21 +545,16 @@ r535_sor_hdmi_ctrl_audio(struct nvkm_outp *outp, bool enable)
562 545 static void
563 546 r535_sor_hdmi_audio(struct nvkm_ior *sor, int head, bool enable)
564 547 {
548 + struct nvkm_device *device = sor->disp->engine.subdev.device;
549 + const u32 hdmi = head * 0x400;
550 +
565 551 r535_sor_hdmi_ctrl_audio(sor->asy.outp, enable);
566 552 r535_sor_hdmi_ctrl_audio_mute(sor->asy.outp, !enable);
567 - sor->disp->func->gsp.hdmi_gcp(sor, head, enable);
568 - }
569 -
570 - static void
571 - r535_sor_hdmi_infoframe_avi(struct nvkm_ior *sor, int head, void *data, u32 size)
572 - {
573 - sor->disp->func->gsp.hdmi_infoframe_avi(sor, head, data, size);
574 - }
575 553
576 - static void
577 - r535_sor_hdmi_infoframe_vsi(struct nvkm_ior *sor, int head, void *data, u32 size)
578 - {
579 - sor->disp->func->gsp.hdmi_infoframe_vsi(sor, head, data, size);
554 + /* General Control (GCP). */
555 + nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000000);
556 + nvkm_wr32(device, 0x6f00cc + hdmi, !enable ? 0x00000001 : 0x00000010);
557 + nvkm_mask(device, 0x6f00c0 + hdmi, 0x00000001, 0x00000001);
580 558 }
581 559
582 560 static void
@@ -604,8 +582,8 @@ r535_sor_hdmi = {
604 582 .ctrl = r535_sor_hdmi_ctrl,
605 583 .scdc = r535_sor_hdmi_scdc,
606 584 /*TODO: SF_USER -> KMS. */
607 - .infoframe_avi = r535_sor_hdmi_infoframe_avi,
608 - .infoframe_vsi = r535_sor_hdmi_infoframe_vsi,
585 + .infoframe_avi = gv100_sor_hdmi_infoframe_avi,
586 + .infoframe_vsi = gv100_sor_hdmi_infoframe_vsi,
609 587 .audio = r535_sor_hdmi_audio,
610 588 };
611 589
@@ -630,6 +608,31 @@ r535_sor_cnt(struct nvkm_disp *disp, unsigned long *pmask)
630 608 return 4;
631 609 }
632 610
611 + static void
612 + r535_head_vblank_put(struct nvkm_head *head)
613 + {
614 + struct nvkm_device *device = head->disp->engine.subdev.device;
615 +
616 + nvkm_mask(device, 0x611d80 + (head->id * 4), 0x00000002, 0x00000000);
617 + }
618 +
619 + static void
620 + r535_head_vblank_get(struct nvkm_head *head)
621 + {
622 + struct nvkm_device *device = head->disp->engine.subdev.device;
623 +
624 + nvkm_wr32(device, 0x611800 + (head->id * 4), 0x00000002);
625 + nvkm_mask(device, 0x611d80 + (head->id * 4), 0x00000002, 0x00000002);
626 + }
627 +
628 + static const struct nvkm_head_func
629 + r535_head = {
630 + .state = gv100_head_state,
631 + .rgpos = gv100_head_rgpos,
632 + .vblank_get = r535_head_vblank_get,
633 + .vblank_put = r535_head_vblank_put,
634 + };
635 +
633 636 static struct nvkm_conn *
634 637 r535_conn_new(struct nvkm_disp *disp, u32 id)
635 638 {
@@ -1401,6 +1404,35 @@ static const struct nvkm_event_func
1401 1404 r535_disp_event = {
1402 1405 };
1403 1406
1407 + static void
1408 + r535_disp_intr_head_timing(struct nvkm_disp *disp, int head)
1409 + {
1410 + struct nvkm_subdev *subdev = &disp->engine.subdev;
1411 + struct nvkm_device *device = subdev->device;
1412 + u32 stat = nvkm_rd32(device, 0x611c00 + (head * 0x04));
1413 +
1414 + if (stat & 0x00000002) {
1415 + nvkm_disp_vblank(disp, head);
1416 +
1417 + nvkm_wr32(device, 0x611800 + (head * 0x04), 0x00000002);
1418 + }
1419 + }
1420 +
1421 + static irqreturn_t
1422 + r535_disp_intr(struct nvkm_inth *inth)
1423 + {
1424 + struct nvkm_disp *disp = container_of(inth, typeof(*disp), engine.subdev.inth);
1425 + struct nvkm_subdev *subdev = &disp->engine.subdev;
1426 + struct nvkm_device *device = subdev->device;
1427 + unsigned long mask = nvkm_rd32(device, 0x611ec0) & 0x000000ff;
1428 + int head;
1429 +
1430 + for_each_set_bit(head, &mask, 8)
1431 + r535_disp_intr_head_timing(disp, head);
1432 +
1433 + return IRQ_HANDLED;
1434 + }
1435 +
1404 1436 static void
1405 1437 r535_disp_fini(struct nvkm_disp *disp, bool suspend)
1406 1438 {
@@ -1627,7 +1659,7 @@ r535_disp_oneinit(struct nvkm_disp *disp)
1627 1659 nvkm_gsp_rm_ctrl_done(&disp->rm.objcom, ctrl);
1628 1660
1629 1661 for_each_set_bit(i, &disp->head.mask, disp->head.nr) {
1630 - ret = nvkm_head_new_(disp->func->gsp.head, disp, i);
1662 + ret = nvkm_head_new_(&r535_head, disp, i);
1631 1663 if (ret)
1632 1664 return ret;
1633 1665 }
@@ -1671,20 +1703,12 @@ r535_disp_oneinit(struct nvkm_disp *disp)
1671 1703 if (ret)
1672 1704 return ret;
1673 1705
1674 - /* Chips that raise head-timing interrupts on a separate low-latency
1675 - * vector report it as a second DISP interrupt table entry, exposed
1676 - * as instance 1 by the RM engine-index translation (see
1677 - * r570_gsp_xlat_mc_engine_idx()). Their high-latency vector
1678 - * (instance 0) is left unhandled as no event nouveau enables is
1679 - * routed to it, and without a handler it stays masked.
1680 - */
1681 - ret = nvkm_gsp_intr_stall(gsp, disp->engine.subdev.type,
1682 - disp->func->gsp.intr_low_latency ? 1 : disp->engine.subdev.inst);
1706 + ret = nvkm_gsp_intr_stall(gsp, disp->engine.subdev.type, disp->engine.subdev.inst);
1683 1707 if (ret < 0)
1684 1708 return ret;
1685 1709
1686 1710 ret = nvkm_inth_add(&device->vfn->intr, ret, NVKM_INTR_PRIO_NORMAL, &disp->engine.subdev,
1687 - disp->func->gsp.intr, &disp->engine.subdev.inth);
1711 + r535_disp_intr, &disp->engine.subdev.inth);
1688 1712 if (ret)
1689 1713 return ret;
1690 1714
@@ -1717,7 +1741,6 @@ r535_disp_new(const struct nvkm_disp_func *hw, struct nvkm_device *device,
1717 1741 rm->uevent = hw->uevent;
1718 1742 rm->sor.cnt = r535_sor_cnt;
1719 1743 rm->sor.new = r535_sor_new;
1720 - rm->gsp = hw->gsp;
1721 1744 rm->ramht_size = hw->ramht_size;
1722 1745
1723 1746 rm->root.oclass = gpu->disp.class.root;
@@ -1759,8 +1782,6 @@ r535_disp = {
1759 1782 .dp = {
1760 1783 .get_caps = r535_dp_get_caps,
1761 1784 .set_indexed_link_rates = r535_dp_set_indexed_link_rates,
1762 - .sst = r535_dp_sst,
1763 - .vcpi = r535_dp_vcpi,
1764 1785 },
1765 1786 .chan = {
1766 1787 .set_pushbuf = r535_disp_chan_set_pushbuf,
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/disp.c
@@ -5,7 +5,6 @@
5 5 #include <rm/rm.h>
6 6
7 7 #include <engine/disp.h>
8 - #include <engine/disp/ior.h>
9 8 #include <engine/disp/outp.h>
10 9
11 10 #include "nvhw/drf.h"
@@ -75,67 +74,6 @@ r570_disp_chan_set_pushbuf(struct nvkm_disp *disp, s32 oclass, int inst, struct
75 74 return nvkm_gsp_rm_ctrl_wr(&gsp->internal.device.subdevice, ctrl);
76 75 }
77 76
78 - static int
79 - r570_dp_vcpi(struct nvkm_ior *sor, int head, u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn)
80 - {
81 - struct nvkm_disp *disp = sor->disp;
82 - NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS *ctrl;
83 -
84 - ctrl = nvkm_gsp_rm_ctrl_get(&disp->rm.objcom,
85 - NV0073_CTRL_CMD_DP_CONFIG_STREAM, sizeof(*ctrl));
86 - if (IS_ERR(ctrl))
87 - return PTR_ERR(ctrl);
88 -
89 - ctrl->subDeviceInstance = 0;
90 - ctrl->head = head;
91 - ctrl->sorIndex = sor->id;
92 - ctrl->dpLink = sor->asy.link == 2;
93 - ctrl->bEnableOverride = 1;
94 - ctrl->bMST = 1;
95 - ctrl->hBlankSym = 0;
96 - ctrl->vBlankSym = 0;
97 - ctrl->colorFormat = 0;
98 - ctrl->bEnableTwoHeadOneOr = 0;
99 - ctrl->singleHeadMultistreamMode = 0;
100 - ctrl->MST.slotStart = slot;
101 - ctrl->MST.slotEnd = slot + slot_nr - 1;
102 - ctrl->MST.PBN = pbn;
103 - ctrl->MST.Timeslice = aligned_pbn;
104 - ctrl->MST.sendACT = 0;
105 - ctrl->MST.singleHeadMSTPipeline = 0;
106 - ctrl->MST.bEnableAudioOverRightPanel = 0;
107 - return nvkm_gsp_rm_ctrl_wr(&disp->rm.objcom, ctrl);
108 - }
109 -
110 - static int
111 - r570_dp_sst(struct nvkm_ior *sor, int head, bool ef,
112 - u32 watermark, u32 hblanksym, u32 vblanksym)
113 - {
114 - struct nvkm_disp *disp = sor->disp;
115 - NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS *ctrl;
116 -
117 - ctrl = nvkm_gsp_rm_ctrl_get(&disp->rm.objcom,
118 - NV0073_CTRL_CMD_DP_CONFIG_STREAM, sizeof(*ctrl));
119 - if (IS_ERR(ctrl))
120 - return PTR_ERR(ctrl);
121 -
122 - ctrl->subDeviceInstance = 0;
123 - ctrl->head = head;
124 - ctrl->sorIndex = sor->id;
125 - ctrl->dpLink = sor->asy.link == 2;
126 - ctrl->bEnableOverride = 1;
127 - ctrl->bMST = 0;
128 - ctrl->hBlankSym = hblanksym;
129 - ctrl->vBlankSym = vblanksym;
130 - ctrl->colorFormat = 0;
131 - ctrl->bEnableTwoHeadOneOr = 0;
132 - ctrl->SST.bEnhancedFraming = ef;
133 - ctrl->SST.tuSize = 64;
134 - ctrl->SST.waterMark = watermark;
135 - ctrl->SST.bEnableAudioOverRightPanel = 0;
136 - return nvkm_gsp_rm_ctrl_wr(&disp->rm.objcom, ctrl);
137 - }
138 -
139 77 static int
140 78 r570_dp_set_indexed_link_rates(struct nvkm_outp *outp)
141 79 {
@@ -317,8 +255,6 @@ r570_disp = {
317 255 .dp = {
318 256 .get_caps = r570_dp_get_caps,
319 257 .set_indexed_link_rates = r570_dp_set_indexed_link_rates,
320 - .sst = r570_dp_sst,
321 - .vcpi = r570_dp_vcpi,
322 258 },
323 259 .chan = {
324 260 .set_pushbuf = r570_disp_chan_set_pushbuf,
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/gsp.c
@@ -44,15 +44,6 @@ r570_gsp_xlat_mc_engine_idx(u32 mc_engine_idx, enum nvkm_subdev_type *ptype, int
44 44 *ptype = NVKM_ENGINE_DISP;
45 45 *pinst = 0;
46 46 return true;
47 - case MC_ENGINE_IDX_DISP_LOW:
48 - /* GB20x+ report a separate low-latency display vector, used
49 - * for head-timing interrupts. Expose it as a second DISP
50 - * interrupt instance. r535_disp_oneinit() attaches the
51 - * handler to it when the chip's gsp.intr_low_latency is set.
52 - */
53 - *ptype = NVKM_ENGINE_DISP;
54 - *pinst = 1;
55 - return true;
56 47 case MC_ENGINE_IDX_CE0 ... MC_ENGINE_IDX_CE19:
57 48 *ptype = NVKM_ENGINE_CE;
58 49 *pinst = mc_engine_idx - MC_ENGINE_IDX_CE0;
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/disp.h
@@ -256,8 +256,6 @@ typedef struct NV0073_CTRL_DP_CTRL_PARAMS {
256 256 NvU32 eightLaneDpcdBaseAddr;
257 257 } NV0073_CTRL_DP_CTRL_PARAMS;
258 258
259 - #define NV0073_CTRL_CMD_DP_CONFIG_STREAM (0x731362U) /* finn: Evaluated from "(FINN_NV04_DISPLAY_COMMON_DP_INTERFACE_ID << 8) | NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS_MESSAGE_ID" */
260 -
261 259 typedef struct NV0073_CTRL_CMD_DP_CONFIG_STREAM_PARAMS {
262 260 NvU32 subDeviceInstance;
263 261 NvU32 head;
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/rm.h
@@ -6,7 +6,6 @@
6 6 #ifndef __NVKM_RM_H__
7 7 #define __NVKM_RM_H__
8 8 #include "handles.h"
9 - struct nvkm_ior;
10 9 struct nvkm_outp;
11 10 struct r535_gr;
12 11
@@ -94,10 +93,6 @@ struct nvkm_rm_api {
94 93 struct {
95 94 int (*get_caps)(struct nvkm_disp *, int *link_bw, bool *mst, bool *wm);
96 95 int (*set_indexed_link_rates)(struct nvkm_outp *);
97 - int (*sst)(struct nvkm_ior *, int head, bool ef,
98 - u32 watermark, u32 hblanksym, u32 vblanksym);
99 - int (*vcpi)(struct nvkm_ior *, int head,
100 - u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn);
101 96 } dp;
102 97
103 98 struct {
modified drivers/gpu/drm/nouveau/nvkm/subdev/instmem/nv50.c
@@ -195,9 +195,6 @@ check_io_mapping(struct nv50_instmem *imem)
195 195 {
196 196 struct nvkm_device *device = imem->base.subdev.device;
197 197
198 - if (imem->iomap.size)
199 - return true;
200 -
201 198 return io_mapping_init_wc(&imem->iomap,
202 199 device->func->resource_addr(device, NVKM_BAR2_INST),
203 200 device->func->resource_size(device, NVKM_BAR2_INST)) != NULL;
modified drivers/gpu/drm/qxl/qxl_display.c
@@ -981,7 +981,7 @@ static struct drm_plane *qxl_create_plane(struct qxl_device *qdev,
981 981 return ERR_PTR(-EINVAL);
982 982 }
983 983
984 - plane = kzalloc_obj(*plane);
984 + plane = kzalloc(sizeof(*plane), GFP_KERNEL);
985 985 if (!plane)
986 986 return ERR_PTR(-ENOMEM);
987 987
modified drivers/gpu/drm/sysfb/ofdrm.c
@@ -2,7 +2,6 @@
2 2
3 3 #include <linux/aperture.h>
4 4 #include <linux/of_address.h>
5 - #include <linux/overflow.h>
6 5 #include <linux/pci.h>
7 6 #include <linux/platform_device.h>
8 7 #include <linux/pm.h>
@@ -239,7 +238,7 @@ static bool is_avivo(u32 vendor, u32 device)
239 238 /* This will match most R5xx */
240 239 return (vendor == PCI_VENDOR_ID_ATI) &&
241 240 ((device >= PCI_VENDOR_ID_ATI_R520 && device < 0x7800) ||
242 - (device >= PCI_VENDOR_ID_ATI_R600));
241 + (PCI_VENDOR_ID_ATI_R600 >= 0x9400));
243 242 }
244 243
245 244 static enum ofdrm_model display_get_model_of(struct drm_device *dev, struct device_node *of_node)
@@ -914,10 +913,7 @@ static struct ofdrm_device *ofdrm_device_create(struct drm_driver *drv,
914 913 return ERR_PTR(-EINVAL);
915 914 }
916 915
917 - if (check_mul_overflow(linebytes, height, &fb_size)) {
918 - drm_err(dev, "framebuffer size exceeds maximum\n");
919 - return ERR_PTR(-EINVAL);
920 - }
916 + fb_size = linebytes * height;
921 917
922 918 /*
923 919 * Try to figure out the address of the framebuffer. Unfortunately, Open
modified drivers/gpu/drm/tegra/dc.c
@@ -904,7 +904,6 @@ static struct drm_plane *tegra_primary_plane_create(struct drm_device *drm,
904 904 struct tegra_dc *dc)
905 905 {
906 906 unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm);
907 - unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE);
908 907 enum drm_plane_type type = DRM_PLANE_TYPE_PRIMARY;
909 908 struct tegra_plane *plane;
910 909 unsigned int num_formats;
@@ -940,7 +939,6 @@ static struct drm_plane *tegra_primary_plane_create(struct drm_device *drm,
940 939 }
941 940
942 941 drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
943 - drm_plane_create_blend_mode_property(&plane->base, blend_caps);
944 942 drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255);
945 943
946 944 err = drm_plane_create_rotation_property(&plane->base,
@@ -1211,7 +1209,6 @@ static struct drm_plane *tegra_dc_cursor_plane_create(struct drm_device *drm,
1211 1209 struct tegra_dc *dc)
1212 1210 {
1213 1211 unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm);
1214 - unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE);
1215 1212 struct tegra_plane *plane;
1216 1213 unsigned int num_formats;
1217 1214 const u32 *formats;
@@ -1255,7 +1252,6 @@ static struct drm_plane *tegra_dc_cursor_plane_create(struct drm_device *drm,
1255 1252 }
1256 1253
1257 1254 drm_plane_helper_add(&plane->base, &tegra_cursor_plane_helper_funcs);
1258 - drm_plane_create_blend_mode_property(&plane->base, blend_caps);
1259 1255 drm_plane_create_zpos_immutable_property(&plane->base, 255);
1260 1256
1261 1257 return &plane->base;
@@ -1360,7 +1356,6 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm,
1360 1356 bool cursor)
1361 1357 {
1362 1358 unsigned long possible_crtcs = tegra_plane_get_possible_crtcs(drm);
1363 - unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE);
1364 1359 struct tegra_plane *plane;
1365 1360 unsigned int num_formats;
1366 1361 enum drm_plane_type type;
@@ -1399,7 +1394,6 @@ static struct drm_plane *tegra_dc_overlay_plane_create(struct drm_device *drm,
1399 1394 }
1400 1395
1401 1396 drm_plane_helper_add(&plane->base, &tegra_plane_helper_funcs);
1402 - drm_plane_create_blend_mode_property(&plane->base, blend_caps);
1403 1397 drm_plane_create_zpos_property(&plane->base, plane->index, 0, 255);
1404 1398
1405 1399 err = drm_plane_create_rotation_property(&plane->base,
modified drivers/gpu/drm/tegra/hub.c
@@ -759,7 +759,6 @@ struct drm_plane *tegra_shared_plane_create(struct drm_device *drm,
759 759 unsigned int index,
760 760 enum drm_plane_type type)
761 761 {
762 - unsigned int blend_caps = BIT(DRM_MODE_BLEND_COVERAGE);
763 762 struct tegra_drm *tegra = drm->dev_private;
764 763 struct tegra_display_hub *hub = tegra->hub;
765 764 struct tegra_shared_plane *plane;
@@ -798,7 +797,6 @@ struct drm_plane *tegra_shared_plane_create(struct drm_device *drm,
798 797 }
799 798
800 799 drm_plane_helper_add(p, &tegra_shared_plane_helper_funcs);
801 - drm_plane_create_blend_mode_property(p, blend_caps);
802 800 drm_plane_create_zpos_property(p, 0, 0, 255);
803 801
804 802 return p;
modified drivers/gpu/drm/tilcdc/tilcdc_panel_legacy.c
@@ -22,7 +22,7 @@ tilcdc_panel_update_prop(struct of_changeset *ocs, struct device_node *node,
22 22 {
23 23 struct property *prop;
24 24
25 - prop = kzalloc_obj(*prop);
25 + prop = kzalloc(sizeof(*prop), GFP_KERNEL);
26 26 if (!prop)
27 27 return -ENOMEM;
28 28
modified drivers/gpu/drm/tiny/cirrus-qemu.c
@@ -582,9 +582,6 @@ static int cirrus_pci_probe(struct pci_dev *pdev,
582 582 struct cirrus_device *cirrus;
583 583 int ret;
584 584
585 - if (pci_resource_len(pdev, 0) < CIRRUS_VRAM_SIZE)
586 - return -ENODEV;
587 -
588 585 ret = aperture_remove_conflicting_pci_devices(pdev, cirrus_driver.name);
589 586 if (ret)
590 587 return ret;
modified drivers/gpu/drm/verisilicon/vs_plane.c
@@ -136,7 +136,7 @@ struct drm_plane_state *vs_plane_duplicate_state(struct drm_plane *plane)
136 136
137 137 vs_state_old = to_vs_plane_state(plane->state);
138 138
139 - vs_state = kzalloc_obj(*vs_state);
139 + vs_state = kzalloc_obj(*vs_state, GFP_KERNEL);
140 140 if (!vs_state)
141 141 return NULL;
142 142
@@ -166,7 +166,7 @@ void vs_plane_reset(struct drm_plane *plane)
166 166 plane->state = NULL;
167 167 }
168 168
169 - vs_state = kzalloc_obj(*vs_state);
169 + vs_state = kzalloc_obj(*vs_state, GFP_KERNEL);
170 170 if (!vs_state)
171 171 return;
172 172
modified drivers/gpu/drm/virtio/virtgpu_display.c
@@ -344,7 +344,7 @@ virtio_gpu_user_framebuffer_create(struct drm_device *dev,
344 344 if (ret) {
345 345 kfree(virtio_gpu_fb);
346 346 drm_gem_object_put(obj);
347 - return ERR_PTR(ret);
347 + return NULL;
348 348 }
349 349
350 350 return &virtio_gpu_fb->base;
@@ -378,11 +378,8 @@ int virtio_gpu_modeset_init(struct virtio_gpu_device *vgdev)
378 378
379 379 vgdev->ddev->mode_config.fb_modifiers_not_supported = true;
380 380
381 - for (i = 0; i < vgdev->num_scanouts; ++i) {
382 - ret = vgdev_output_init(vgdev, i);
383 - if (ret)
384 - return ret;
385 - }
381 + for (i = 0 ; i < vgdev->num_scanouts; ++i)
382 + vgdev_output_init(vgdev, i);
386 383
387 384 ret = drm_vblank_init(vgdev->ddev, vgdev->num_scanouts);
388 385 if (ret)
modified drivers/gpu/drm/virtio/virtgpu_drv.h
@@ -43,8 +43,6 @@
43 43 #include <drm/drm_probe_helper.h>
44 44 #include <drm/virtgpu_drm.h>
45 45
46 - #include <xen/xen.h>
47 -
48 46 #define DRIVER_NAME "virtio_gpu"
49 47 #define DRIVER_DESC "virtio GPU"
50 48
@@ -62,24 +60,6 @@
62 60 /* See virtio_gpu_ctx_create. One additional character for NULL terminator. */
63 61 #define DEBUG_NAME_MAX_LEN 65
64 62
65 - /*
66 - * Whether the host must be told about resource backing pages by DMA address
67 - * rather than guest-physical address.
68 - *
69 - * This mirrors vring_use_map_api() in drivers/virtio/virtio_ring.c, including
70 - * its xen_domain() case.
71 - */
72 - static inline bool virtio_gpu_use_dma_api(const struct virtio_device *vdev)
73 - {
74 - if (!virtio_has_dma_quirk(vdev))
75 - return true;
76 -
77 - if (xen_domain())
78 - return true;
79 -
80 - return false;
81 - }
82 -
83 63 struct virtio_gpu_object_params {
84 64 unsigned long size;
85 65 bool dumb;
@@ -363,7 +343,6 @@ void virtio_gpu_array_put_free_work(struct work_struct *work);
363 343 /* virtgpu_vq.c */
364 344 int virtio_gpu_alloc_vbufs(struct virtio_gpu_device *vgdev);
365 345 void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev);
366 - void virtio_gpu_reclaim_vbufs(struct virtio_gpu_device *vgdev);
367 346 void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev,
368 347 struct virtio_gpu_object *bo,
369 348 struct virtio_gpu_object_params *params,
modified drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -352,7 +352,6 @@ void virtio_gpu_deinit(struct drm_device *dev)
352 352 flush_work(&vgdev->cursorq.dequeue_work);
353 353 flush_work(&vgdev->config_changed_work);
354 354 virtio_reset_device(vgdev->vdev);
355 - virtio_gpu_reclaim_vbufs(vgdev);
356 355 vgdev->vdev->config->del_vqs(vgdev->vdev);
357 356 mutex_destroy(&vgdev->obj_restore_lock);
358 357 }
modified drivers/gpu/drm/virtio/virtgpu_object.c
@@ -173,7 +173,7 @@ static int virtio_gpu_object_shmem_init(struct virtio_gpu_device *vgdev,
173 173 struct virtio_gpu_mem_entry **ents,
174 174 unsigned int *nents)
175 175 {
176 - bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev);
176 + bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
177 177 struct scatterlist *sg;
178 178 struct sg_table *pages;
179 179 int si;
modified drivers/gpu/drm/virtio/virtgpu_prime.c
@@ -293,7 +293,9 @@ int virtgpu_dma_buf_obj_resubmit(struct virtio_gpu_device *vgdev,
293 293 return -ENOMEM;
294 294 }
295 295
296 - ents = kvmalloc_objs(struct virtio_gpu_mem_entry, bo->sgt->nents);
296 + ents = kvmalloc_array(bo->sgt->nents,
297 + sizeof(struct virtio_gpu_mem_entry),
298 + GFP_KERNEL);
297 299 if (!ents) {
298 300 DRM_ERROR("failed to allocate ent list\n");
299 301 return -ENOMEM;
modified drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -208,21 +208,6 @@ static void free_vbuf(struct virtio_gpu_device *vgdev,
208 208 kmem_cache_free(vgdev->vbufs, vbuf);
209 209 }
210 210
211 - void virtio_gpu_reclaim_vbufs(struct virtio_gpu_device *vgdev)
212 - {
213 - struct virtio_gpu_vbuffer *vbuf;
214 -
215 - while ((vbuf = virtqueue_detach_unused_buf(vgdev->ctrlq.vq))) {
216 - if (vbuf->objs)
217 - virtio_gpu_array_put_free(vbuf->objs);
218 - if (vbuf->resp_cb_data)
219 - virtio_gpu_cleanup_object(vbuf->resp_cb_data);
220 - free_vbuf(vgdev, vbuf);
221 - }
222 - while ((vbuf = virtqueue_detach_unused_buf(vgdev->cursorq.vq)))
223 - free_vbuf(vgdev, vbuf);
224 - }
225 -
226 211 static void reclaim_vbufs(struct virtqueue *vq, struct list_head *reclaim_list)
227 212 {
228 213 struct virtio_gpu_vbuffer *vbuf;
@@ -779,7 +764,7 @@ int virtio_gpu_panic_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
779 764 struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
780 765 struct virtio_gpu_transfer_to_host_2d *cmd_p;
781 766 struct virtio_gpu_vbuffer *vbuf;
782 - bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev);
767 + bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
783 768
784 769 if (virtio_gpu_is_shmem(bo) && use_dma_api)
785 770 dma_sync_sgtable_for_device(vgdev->vdev->dev.parent,
@@ -810,7 +795,7 @@ void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
810 795 struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
811 796 struct virtio_gpu_transfer_to_host_2d *cmd_p;
812 797 struct virtio_gpu_vbuffer *vbuf;
813 - bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev);
798 + bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
814 799
815 800 if (virtio_gpu_is_shmem(bo) && use_dma_api)
816 801 dma_sync_sgtable_for_device(vgdev->vdev->dev.parent,
@@ -1243,7 +1228,7 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
1243 1228 struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
1244 1229 struct virtio_gpu_transfer_host_3d *cmd_p;
1245 1230 struct virtio_gpu_vbuffer *vbuf;
1246 - bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev);
1231 + bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
1247 1232
1248 1233 if (virtio_gpu_is_shmem(bo) && use_dma_api)
1249 1234 dma_sync_sgtable_for_device(vgdev->vdev->dev.parent,
modified drivers/gpu/drm/vkms/vkms_configfs.c
@@ -212,7 +212,7 @@ static struct config_group *make_crtc_group(struct config_group *group,
212 212 if (dev->enabled)
213 213 return ERR_PTR(-EBUSY);
214 214
215 - crtc = kzalloc_obj(*crtc);
215 + crtc = kzalloc(sizeof(*crtc), GFP_KERNEL);
216 216 if (!crtc)
217 217 return ERR_PTR(-ENOMEM);
218 218
@@ -368,7 +368,7 @@ static struct config_group *make_plane_group(struct config_group *group,
368 368 if (dev->enabled)
369 369 return ERR_PTR(-EBUSY);
370 370
371 - plane = kzalloc_obj(*plane);
371 + plane = kzalloc(sizeof(*plane), GFP_KERNEL);
372 372 if (!plane)
373 373 return ERR_PTR(-ENOMEM);
374 374
@@ -484,7 +484,7 @@ static struct config_group *make_encoder_group(struct config_group *group,
484 484 if (dev->enabled)
485 485 return ERR_PTR(-EBUSY);
486 486
487 - encoder = kzalloc_obj(*encoder);
487 + encoder = kzalloc(sizeof(*encoder), GFP_KERNEL);
488 488 if (!encoder)
489 489 return ERR_PTR(-ENOMEM);
490 490
@@ -651,7 +651,7 @@ static struct config_group *make_connector_group(struct config_group *group,
651 651 if (dev->enabled)
652 652 return ERR_PTR(-EBUSY);
653 653
654 - connector = kzalloc_obj(*connector);
654 + connector = kzalloc(sizeof(*connector), GFP_KERNEL);
655 655 if (!connector)
656 656 return ERR_PTR(-ENOMEM);
657 657
modified drivers/gpu/drm/xe/xe_amc.c
@@ -177,7 +177,7 @@ int xe_amc_init(struct xe_i2c *i2c)
177 177 {
178 178 struct xe_amc *amc;
179 179
180 - amc = kzalloc_obj(*amc);
180 + amc = kzalloc(sizeof(*amc), GFP_KERNEL);
181 181 if (!amc)
182 182 return -ENOMEM;
183 183
modified drivers/gpu/drm/xe/xe_oa.c
@@ -2435,9 +2435,9 @@ int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *fi
2435 2435
2436 2436 oa_config->id = idr_alloc(&oa->metrics_idr, oa_config, 1, 0, GFP_KERNEL);
2437 2437 if (oa_config->id < 0) {
2438 - drm_dbg(&oa->xe->drm, "Failed to allocate id for OA config\n");
2438 + drm_dbg(&oa->xe->drm, "Failed to create sysfs entry for OA config\n");
2439 2439 err = oa_config->id;
2440 - goto id_alloc_err;
2440 + goto sysfs_err;
2441 2441 }
2442 2442
2443 2443 id = oa_config->id;
@@ -2448,8 +2448,6 @@ int xe_oa_add_config_ioctl(struct drm_device *dev, u64 data, struct drm_file *fi
2448 2448
2449 2449 return id;
2450 2450
2451 - id_alloc_err:
2452 - sysfs_remove_group(oa->metrics_kobj, &oa_config->sysfs_metric);
2453 2451 sysfs_err:
2454 2452 mutex_unlock(&oa->metrics_lock);
2455 2453 reg_err:
modified drivers/gpu/drm/xe/xe_vm.c
@@ -4148,7 +4148,7 @@ static int fill_faults(struct xe_vm *vm,
4148 4148 entry_size = sizeof(struct xe_vm_fault);
4149 4149 count = args->size / entry_size;
4150 4150
4151 - fault_list = kzalloc_objs(struct xe_vm_fault, count);
4151 + fault_list = kcalloc(count, sizeof(struct xe_vm_fault), GFP_KERNEL);
4152 4152 if (!fault_list)
4153 4153 return -ENOMEM;
4154 4154
modified drivers/gpu/drm/xe/xe_vram.c
@@ -90,9 +90,6 @@ static int get_flat_ccs_offset(struct xe_gt *gt, u64 tile_size, u64 *poffset)
90 90 offset |= offset_lo << 6; /* HW view bits 31:6 */
91 91 offset *= num_enabled; /* convert to SW view */
92 92
93 - drm_info(&xe->drm, "FLAT_CCS base:%llx, aligned:%s\n", offset,
94 - str_yes_no(IS_ALIGNED(offset, SZ_128K)));
95 -
96 93 /*
97 94 * Everything below this offset is handed to the VRAM
98 95 * allocator, so it has to be the *first* address the
modified drivers/hid/Kconfig
@@ -1253,7 +1253,7 @@ config HID_HYPERV_MOUSE
1253 1253
1254 1254 config HID_HYPERV_MOUSE_KUNIT_TEST
1255 1255 bool "KUnit tests for Hyper-V mouse driver" if !KUNIT_ALL_TESTS
1256 - depends on KUNIT && (HID_HYPERV_MOUSE = KUNIT || KUNIT = y)
1256 + depends on KUNIT && HID_HYPERV_MOUSE
1257 1257 default KUNIT_ALL_TESTS
1258 1258 help
1259 1259 Builds unit tests for the Hyper-V synthetic HID driver.
modified drivers/hid/bpf/hid_bpf_struct_ops.c
@@ -62,10 +62,6 @@ struct hid_bpf_offset_write_range {
62 62 u32 end;
63 63 };
64 64
65 - struct hid_bpf_ctx__safe_trusted {
66 - struct hid_device *hid;
67 - };
68 -
69 65 static int hid_bpf_ops_btf_struct_access(struct bpf_verifier_log *log,
70 66 const struct bpf_reg_state *reg,
71 67 int off, int size)
@@ -90,8 +86,6 @@ static int hid_bpf_ops_btf_struct_access(struct bpf_verifier_log *log,
90 86 const char *cur = NULL;
91 87 int i;
92 88
93 - BTF_TYPE_EMIT(struct hid_bpf_ctx__safe_trusted);
94 -
95 89 t = btf_type_by_id(reg->btf, reg->btf_id);
96 90
97 91 for (i = 0; i < ARRAY_SIZE(write_ranges); i++) {
@@ -256,11 +250,6 @@ static void hid_bpf_unreg(void *kdata, struct bpf_link *link)
256 250
257 251 mutex_lock(&hdev->bpf.prog_list_lock);
258 252
259 - if (!ops->hdev) {
260 - mutex_unlock(&hdev->bpf.prog_list_lock);
261 - return;
262 - }
263 -
264 253 list_del_rcu(&ops->list);
265 254 synchronize_srcu(&hdev->bpf.srcu);
266 255 ops->hdev = NULL;
@@ -321,17 +310,13 @@ static struct bpf_struct_ops bpf_hid_bpf_ops = {
321 310 void __hid_bpf_ops_destroy_device(struct hid_device *hdev)
322 311 {
323 312 struct hid_bpf_ops *e;
324 - int count = 0;
325 313
326 - mutex_lock(&hdev->bpf.prog_list_lock);
327 - list_for_each_entry(e, &hdev->bpf.prog_list, list) {
314 + rcu_read_lock();
315 + list_for_each_entry_rcu(e, &hdev->bpf.prog_list, list) {
316 + hid_put_device(hdev);
328 317 e->hdev = NULL;
329 - count++;
330 318 }
331 - mutex_unlock(&hdev->bpf.prog_list_lock);
332 -
333 - while (count--)
334 - hid_put_device(hdev);
319 + rcu_read_unlock();
335 320 }
336 321
337 322 static int __init hid_bpf_struct_ops_init(void)
modified drivers/hid/hid-asus.c
@@ -406,7 +406,7 @@ static int asus_kbd_fn_lock_set(struct asus_drvdata *drvdata, bool enabled)
406 406 struct asus_work_action *action;
407 407 unsigned long flags;
408 408
409 - action = kzalloc_obj(struct asus_work_action, GFP_ATOMIC);
409 + action = kzalloc(sizeof(struct asus_work_action), GFP_ATOMIC);
410 410 if (!action)
411 411 return -ENOMEM;
412 412
@@ -433,7 +433,7 @@ static int asus_kbd_wmi_fan_send(struct asus_drvdata *drvdata, u8 *report_data,
433 433 return -EINVAL;
434 434 }
435 435
436 - action = kzalloc_obj(struct asus_work_action, GFP_NOWAIT);
436 + action = kzalloc(sizeof(struct asus_work_action), GFP_NOWAIT);
437 437 if (!action)
438 438 return -ENOMEM;
439 439
@@ -746,7 +746,7 @@ static void asus_kbd_backlight_set(struct asus_hid_listener *listener, int brigh
746 746
747 747 drvdata->kbd_backlight_brightness = brightness;
748 748
749 - action = kzalloc_obj(struct asus_work_action, GFP_NOWAIT);
749 + action = kzalloc(sizeof(struct asus_work_action), GFP_NOWAIT);
750 750 if (!action)
751 751 return;
752 752
modified drivers/hid/hid-hyperv.c
@@ -687,7 +687,7 @@ static void mousevsc_device_info_valid_descriptor(struct kunit *test)
687 687
688 688 info->hid_descriptor.bLength = sizeof(struct hid_descriptor);
689 689 info->hid_descriptor.rpt_desc.wDescriptorLength = cpu_to_le16(4);
690 - report = (u8 *)(info + 1);
690 + report = ((u8 *)&info->hid_descriptor) + info->hid_descriptor.bLength;
691 691 memset(report, 0x42, 4);
692 692
693 693 mousevsc_on_receive_device_info(input_dev, info, sizeof(*info) + 4);
@@ -713,7 +713,7 @@ static void mousevsc_device_info_report_desc_oob(struct kunit *test)
713 713
714 714 info->hid_descriptor.bLength = sizeof(struct hid_descriptor);
715 715 info->hid_descriptor.rpt_desc.wDescriptorLength = cpu_to_le16(64);
716 - report = (u8 *)(info + 1);
716 + report = ((u8 *)&info->hid_descriptor) + info->hid_descriptor.bLength;
717 717 memset(report, 0x42, 8);
718 718
719 719 mousevsc_on_receive_device_info(input_dev, info, sizeof(*info) + 8);
modified drivers/hid/hid-ids.h
@@ -338,7 +338,6 @@
338 338
339 339 #define I2C_VENDOR_ID_CIRQUE 0x0488
340 340 #define I2C_PRODUCT_ID_CIRQUE_1063 0x1063
341 - #define I2C_PRODUCT_ID_CIRQUE_D0C1 0xD0C1
342 341
343 342 #define USB_VENDOR_ID_CJTOUCH 0x24b8
344 343 #define USB_DEVICE_ID_CJTOUCH_MULTI_TOUCH_0020 0x0020
modified drivers/hid/hid-multitouch.c
@@ -1321,18 +1321,21 @@ static void mt_touch_report(struct hid_device *hid,
1321 1321 * Includes multi-packet support where subsequent
1322 1322 * packets are sent with zero contactcount.
1323 1323 */
1324 - if (contact_count > 0)
1325 - app->num_expected = contact_count;
1326 - else if (app->num_received == 0 && app->prev_scantime != scantime) {
1324 + if (contact_count >= 0) {
1327 1325 /*
1328 - * New multi-report frame:
1329 - *
1330 1326 * For Win8 PTPs the first packet (td->num_received == 0) may
1331 1327 * have a contactcount of 0 if there only is a button event.
1332 - *
1333 - * Some other devices use a sentinel frame with 0 to release all contacts
1328 + * We double check that this is not a continuation packet
1329 + * of a possible multi-packet frame be checking that the
1330 + * timestamp has changed.
1334 1331 */
1335 - app->num_expected = 0;
1332 + if ((app->quirks & MT_QUIRK_WIN8_PTP_BUTTONS) &&
1333 + app->num_received == 0 &&
1334 + app->prev_scantime != scantime)
1335 + app->num_expected = contact_count;
1336 + /* A non 0 contact count always indicates a first packet */
1337 + else if (contact_count)
1338 + app->num_expected = contact_count;
1336 1339 }
1337 1340 app->prev_scantime = scantime;
1338 1341
modified drivers/hid/hid-rmi.c
@@ -235,23 +235,7 @@ static int rmi_hid_read_block(struct rmi_transport_dev *xport, u16 addr,
235 235 break;
236 236 }
237 237
238 - read_input_count = min_t(int, data->readReport[1],
239 - data->input_report_size - 2);
240 - if (!read_input_count) {
241 - /*
242 - * A zero length reply advances neither
243 - * bytes_read nor bytes_needed, and because a
244 - * reply did arrive the wait above does not
245 - * time out either, so a device answering 0
246 - * forever would spin here indefinitely with
247 - * page_mutex held.
248 - */
249 - hid_warn(hdev, "%s: zero-length read reply\n",
250 - __func__);
251 - clear_bit(RMI_READ_DATA_PENDING, &data->flags);
252 - ret = -EIO;
253 - break;
254 - }
238 + read_input_count = data->readReport[1];
255 239 memcpy(buf + bytes_read, &data->readReport[2],
256 240 min(read_input_count, bytes_needed));
257 241
@@ -287,11 +271,6 @@ static int rmi_hid_write_block(struct rmi_transport_dev *xport, u16 addr,
287 271 goto exit;
288 272 }
289 273
290 - if (len + 4 > data->output_report_size) {
291 - ret = -EINVAL;
292 - goto exit;
293 - }
294 -
295 274 data->writeReport[0] = RMI_WRITE_REPORT_ID;
296 275 data->writeReport[1] = len;
297 276 data->writeReport[2] = addr & 0xFF;
@@ -687,16 +666,8 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id)
687 666 return ret;
688 667 }
689 668
690 - /*
691 - * RMI_DEVICE can only mean "this probe validated the RMI reports and
692 - * allocated writeReport": every bail-out to start below skips that
693 - * allocation, and device_flags left carrying RMI_DEVICE from
694 - * driver_data would send rmi_input_configured() into rmi_set_page()
695 - * with writeReport still NULL. A bind through the new_id sysfs
696 - * attribute can supply driver_data with the bit set, so do not let
697 - * driver_data grant it.
698 - */
699 - data->device_flags = id->driver_data & ~RMI_DEVICE;
669 + if (id->driver_data)
670 + data->device_flags = id->driver_data;
700 671
701 672 /*
702 673 * Check for the RMI specific report ids. If they are misisng
@@ -725,17 +696,6 @@ static int rmi_probe(struct hid_device *hdev, const struct hid_device_id *id)
725 696
726 697 data->output_report_size = hid_report_len(output_report);
727 698
728 - /*
729 - * The write reports built by this driver occupy 6 bytes and the read
730 - * handshake looks at the first 3 bytes of an input report, so refuse
731 - * to drive a device whose reports cannot hold them.
732 - */
733 - if (data->output_report_size < 6 || data->input_report_size < 3) {
734 - hid_err(hdev, "rmi reports too small (out=%u in=%u)\n",
735 - data->output_report_size, data->input_report_size);
736 - goto start;
737 - }
738 -
739 699 data->device_flags |= RMI_DEVICE;
740 700 alloc_size = data->output_report_size + data->input_report_size;
741 701
modified drivers/hid/hid-steam.c
@@ -759,7 +759,7 @@ static inline int steam_haptic_pulse(struct steam_device *steam, u8 pad,
759 759
760 760 if (steam->quirks & STEAM_QUIRK_IBEX) {
761 761 struct steam_ibex_output_report *report =
762 - kzalloc_obj(struct steam_ibex_output_report);
762 + kzalloc(sizeof(struct steam_ibex_output_report), GFP_KERNEL);
763 763
764 764 if (!report)
765 765 return -ENOMEM;
@@ -798,7 +798,7 @@ static inline int steam_haptic_rumble(struct steam_device *steam,
798 798
799 799 if (steam->quirks & STEAM_QUIRK_IBEX) {
800 800 struct steam_ibex_output_report *report =
801 - kzalloc_obj(struct steam_ibex_output_report);
801 + kzalloc(sizeof(struct steam_ibex_output_report), GFP_KERNEL);
802 802
803 803 if (!report)
804 804 return -ENOMEM;
modified drivers/hid/hid-steelseries-arctis.c
@@ -469,7 +469,7 @@ static int steelseries_arctis_probe(struct hid_device *hdev,
469 469 return hid_hw_start(hdev, HID_CONNECT_DEFAULT);
470 470
471 471 if (interface_num == info->sync_interface) {
472 - sd = kzalloc_obj(*sd);
472 + sd = kzalloc_obj(*sd, GFP_KERNEL);
473 473 if (!sd)
474 474 return -ENOMEM;
475 475
modified drivers/hid/i2c-hid/i2c-hid-core.c
@@ -136,8 +136,6 @@ static const struct i2c_hid_quirks {
136 136 I2C_HID_QUIRK_BAD_INPUT_SIZE },
137 137 { I2C_VENDOR_ID_CIRQUE, I2C_PRODUCT_ID_CIRQUE_1063,
138 138 I2C_HID_QUIRK_NO_SLEEP_ON_SUSPEND },
139 - { I2C_VENDOR_ID_CIRQUE, I2C_PRODUCT_ID_CIRQUE_D0C1,
140 - I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
141 139 /*
142 140 * Without additional power on command, at least some QTEC devices send garbage
143 141 */
modified drivers/hid/wacom_wac.c
@@ -1550,19 +1550,6 @@ static int wacom_intuos_pro2_bt_irq(struct wacom_wac *wacom, size_t len)
1550 1550 return 0;
1551 1551 }
1552 1552
1553 - if (wacom->features.type == INTUOSP2_BT ||
1554 - wacom->features.type == INTUOSP2S_BT) {
1555 - if (len < 286) {
1556 - dev_warn(wacom->pen_input->dev.parent,
1557 - "Pro2 BT report too short: %zu bytes\n", len);
1558 - return 0;
1559 - }
1560 - } else if (len < 46) {
1561 - dev_warn(wacom->pen_input->dev.parent,
1562 - "Pro2 BT report too short: %zu bytes\n", len);
1563 - return 0;
1564 - }
1565 -
1566 1553 wacom_intuos_pro2_bt_pen(wacom);
1567 1554 if (wacom->features.type == INTUOSP2_BT ||
1568 1555 wacom->features.type == INTUOSP2S_BT) {
modified drivers/hv/channel.c
@@ -694,11 +694,12 @@ void *vmbus_alloc_buffer(struct vmbus_channel *channel,
694 694 return vzalloc(nr_pages << PAGE_SHIFT);
695 695
696 696 /* Worst case: every chunk is a single page. */
697 - chunks = kvmalloc_objs(*chunks, nr_pages, GFP_KERNEL | __GFP_ZERO);
697 + chunks = kvmalloc_array(nr_pages, sizeof(*chunks),
698 + GFP_KERNEL | __GFP_ZERO);
698 699 if (!chunks)
699 700 goto err;
700 701
701 - pages = kvmalloc_objs(*pages, nr_pages);
702 + pages = kvmalloc_array(nr_pages, sizeof(*pages), GFP_KERNEL);
702 703 if (!pages)
703 704 goto err;
704 705
modified drivers/hv/hv_balloon.c
@@ -939,7 +939,7 @@ static unsigned long process_hot_add(unsigned long pg_start,
939 939 */
940 940
941 941 if (rg_size != 0) {
942 - ha_region = kzalloc_obj(struct hv_hotadd_state);
942 + ha_region = kzalloc(sizeof(struct hv_hotadd_state), GFP_KERNEL);
943 943 if (!ha_region)
944 944 return 0;
945 945
modified drivers/hwmon/applesmc.c
@@ -1476,9 +1476,9 @@ static int __init applesmc_init(void)
1476 1476 applesmc_fan_config[smcreg.fan_count] = 0;
1477 1477 applesmc_pwm_config[smcreg.fan_count] = 0;
1478 1478
1479 - applesmc_info_temp = kzalloc_obj(*applesmc_info_temp);
1480 - applesmc_info_fan = kzalloc_obj(*applesmc_info_fan);
1481 - applesmc_info_pwm = kzalloc_obj(*applesmc_info_pwm);
1479 + applesmc_info_temp = kzalloc_obj(*applesmc_info_temp, GFP_KERNEL);
1480 + applesmc_info_fan = kzalloc_obj(*applesmc_info_fan, GFP_KERNEL);
1481 + applesmc_info_pwm = kzalloc_obj(*applesmc_info_pwm, GFP_KERNEL);
1482 1482 if (!applesmc_info_temp || !applesmc_info_fan || !applesmc_info_pwm) {
1483 1483 ret = -ENOMEM;
1484 1484 goto out_info;
@@ -1493,7 +1493,7 @@ static int __init applesmc_init(void)
1493 1493 applesmc_info_pwm->type = hwmon_pwm;
1494 1494 applesmc_info_pwm->config = applesmc_pwm_config;
1495 1495
1496 - applesmc_info_arr = kzalloc_objs(*applesmc_info_arr, 4);
1496 + applesmc_info_arr = kcalloc(4, sizeof(*applesmc_info_arr), GFP_KERNEL);
1497 1497 if (!applesmc_info_arr) {
1498 1498 ret = -ENOMEM;
1499 1499 goto out_info;
@@ -1504,7 +1504,7 @@ static int __init applesmc_init(void)
1504 1504 applesmc_info_arr[2] = applesmc_info_pwm;
1505 1505 applesmc_info_arr[3] = NULL;
1506 1506
1507 - applesmc_chip = kzalloc_obj(*applesmc_chip);
1507 + applesmc_chip = kzalloc_obj(*applesmc_chip, GFP_KERNEL);
1508 1508 if (!applesmc_chip) {
1509 1509 ret = -ENOMEM;
1510 1510 goto out_info;
@@ -1514,9 +1514,10 @@ static int __init applesmc_init(void)
1514 1514 applesmc_chip->info = applesmc_info_arr;
1515 1515
1516 1516 /* Create non-standard fanX_safe attributes group */
1517 - fan_safe_attrs = kzalloc_objs(*fan_safe_attrs, smcreg.fan_count);
1518 - fan_safe_attr_list = kzalloc_objs(*fan_safe_attr_list,
1519 - smcreg.fan_count + 1);
1517 + fan_safe_attrs = kcalloc(smcreg.fan_count,
1518 + sizeof(*fan_safe_attrs), GFP_KERNEL);
1519 + fan_safe_attr_list = kcalloc(smcreg.fan_count + 1,
1520 + sizeof(*fan_safe_attr_list), GFP_KERNEL);
1520 1521 if (!fan_safe_attrs || !fan_safe_attr_list) {
1521 1522 ret = -ENOMEM;
1522 1523 goto out_info;
modified drivers/hwtracing/coresight/coresight-core.c
@@ -1679,7 +1679,7 @@ coresight_allocate_device_list(const char *prefix)
1679 1679 return list;
1680 1680 }
1681 1681
1682 - list = kzalloc_obj(*list);
1682 + list = kzalloc(sizeof(*list), GFP_KERNEL);
1683 1683 if (!list)
1684 1684 return NULL;
1685 1685
modified drivers/i2c/busses/i2c-gpio.c
@@ -418,7 +418,7 @@ static struct i2c_gpio_scl_data *i2c_gpio_create_scl(struct device *dev)
418 418 }
419 419 }
420 420
421 - scl = kzalloc_obj(*scl);
421 + scl = kzalloc(sizeof(*scl), GFP_KERNEL);
422 422 if (!scl) {
423 423 if (sharable)
424 424 fwnode_handle_put(args.fwnode);
modified drivers/i3c/master/amd-i3c-master.c
@@ -376,7 +376,7 @@ static struct xi3c_xfer *xi3c_master_alloc_xfer(unsigned int ncmds)
376 376 {
377 377 struct xi3c_xfer *xfer;
378 378
379 - xfer = kzalloc_flex(*xfer, cmds, ncmds);
379 + xfer = kzalloc_flex(*xfer, cmds, ncmds, GFP_KERNEL);
380 380 if (!xfer)
381 381 return NULL;
382 382
@@ -735,7 +735,7 @@ static int xi3c_master_send_bdcast_ccc_cmd(struct xi3c_master *master,
735 735 if (!xfer)
736 736 return -ENOMEM;
737 737
738 - buf = kmalloc_objs(*buf, xfer_len);
738 + buf = kmalloc_objs(*buf, xfer_len, GFP_KERNEL);
739 739 if (!buf)
740 740 return -ENOMEM;
741 741
modified drivers/iio/adc/ad7280a.c
@@ -796,8 +796,8 @@ static irqreturn_t ad7280_event_handler(int irq, void *private)
796 796 struct ad7280_state *st = iio_priv(indio_dev);
797 797 int i, ret;
798 798
799 - unsigned int *channels __free(kfree) = kzalloc_objs(*channels,
800 - st->scan_cnt);
799 + unsigned int *channels __free(kfree) = kcalloc(st->scan_cnt, sizeof(*channels),
800 + GFP_KERNEL);
801 801 if (!channels)
802 802 return IRQ_HANDLED;
803 803
modified drivers/iio/buffer/industrialio-buffer-dmaengine.c
@@ -109,7 +109,7 @@ static int iio_dmaengine_buffer_submit_block(struct iio_dma_buffer_queue *queue,
109 109 if (nents < 0)
110 110 return nents;
111 111
112 - vecs = kmalloc_objs(*vecs, nents, GFP_ATOMIC);
112 + vecs = kmalloc_array(nents, sizeof(*vecs), GFP_ATOMIC);
113 113 if (!vecs)
114 114 return -ENOMEM;
115 115
modified drivers/iio/inkern.c
@@ -345,7 +345,7 @@ static struct iio_channel *iio_channel_get_sys(const char *name,
345 345 return ERR_PTR(-ENODEV);
346 346
347 347 struct iio_channel *channel __free(kfree) =
348 - kzalloc_obj(*channel);
348 + kzalloc(sizeof(*channel), GFP_KERNEL);
349 349 if (!channel) {
350 350 err = -ENOMEM;
351 351 goto error_no_mem;
modified drivers/infiniband/core/nldev.c
@@ -2943,7 +2943,7 @@ static int nldev_frmr_pools_set_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
2943 2943 u32 aging_period;
2944 2944 int err;
2945 2945
2946 - tb = kzalloc_objs(*tb, RDMA_NLDEV_ATTR_MAX);
2946 + tb = kzalloc_objs(*tb, RDMA_NLDEV_ATTR_MAX, GFP_KERNEL);
2947 2947 if (!tb)
2948 2948 return -ENOMEM;
2949 2949
modified drivers/infiniband/hw/hns/hns_roce_debugfs.c
@@ -267,7 +267,8 @@ static int hns_roce_alloc_scc_param(struct hns_roce_dev *hr_dev)
267 267 struct hns_roce_scc_param *scc_param;
268 268 int i;
269 269
270 - scc_param = kvzalloc_objs(*scc_param, HNS_ROCE_SCC_ALGO_TOTAL);
270 + scc_param = kvcalloc(HNS_ROCE_SCC_ALGO_TOTAL, sizeof(*scc_param),
271 + GFP_KERNEL);
271 272 if (!scc_param)
272 273 return -ENOMEM;
273 274
modified drivers/input/input.c
@@ -2344,7 +2344,7 @@ static int input_device_tune_vals(struct input_dev *dev)
2344 2344 if (dev->max_vals >= max_vals)
2345 2345 return 0;
2346 2346
2347 - vals = kzalloc_objs(*vals, max_vals);
2347 + vals = kcalloc(max_vals, sizeof(*vals), GFP_KERNEL);
2348 2348 if (!vals)
2349 2349 return -ENOMEM;
2350 2350
modified drivers/input/keyboard/adp5585-keys.c
@@ -115,8 +115,8 @@ static int adp5585_keys_parse_fw(const struct adp5585_dev *adp5585,
115 115 "Too many keypad pins (%d) defined (max=%d)\n",
116 116 n_pins, adp5585->n_pins);
117 117
118 - unsigned int *keypad_pins __free(kfree) = kzalloc_objs(*keypad_pins,
119 - n_pins);
118 + unsigned int *keypad_pins __free(kfree) = kcalloc(n_pins, sizeof(*keypad_pins),
119 + GFP_KERNEL);
120 120 if (!keypad_pins)
121 121 return -ENOMEM;
122 122
modified drivers/input/keyboard/atkbd.c
@@ -1070,7 +1070,7 @@ static int atkbd_get_keymap_from_fwnode(struct atkbd *atkbd)
1070 1070 if (n <= 0 || n > ATKBD_KEYMAP_SIZE)
1071 1071 return -ENXIO;
1072 1072
1073 - u32 *ptr __free(kfree) = kzalloc_objs(*ptr, n);
1073 + u32 *ptr __free(kfree) = kcalloc(n, sizeof(*ptr), GFP_KERNEL);
1074 1074 if (!ptr)
1075 1075 return -ENOMEM;
1076 1076
modified drivers/input/misc/ims-pcu.c
@@ -1844,7 +1844,7 @@ static int ims_pcu_line_setup(struct ims_pcu *pcu)
1844 1844 {
1845 1845 struct usb_host_interface *interface = pcu->ctrl_intf->cur_altsetting;
1846 1846 struct usb_cdc_line_coding *line __free(kfree) =
1847 - kmalloc_obj(*line);
1847 + kmalloc(sizeof(*line), GFP_KERNEL);
1848 1848 int error;
1849 1849
1850 1850 if (!line)
modified drivers/input/mouse/psmouse-smbus.c
@@ -232,7 +232,7 @@ int psmouse_smbus_init(struct psmouse *psmouse,
232 232 struct psmouse_smbus_dev *smbdev;
233 233 int error;
234 234
235 - smbdev = kzalloc_obj(*smbdev);
235 + smbdev = kzalloc(sizeof(*smbdev), GFP_KERNEL);
236 236 if (!smbdev)
237 237 return -ENOMEM;
238 238
modified drivers/input/serio/serio_raw.c
@@ -84,7 +84,7 @@ static int serio_raw_open(struct inode *inode, struct file *file)
84 84 if (serio_raw->dead)
85 85 return -ENODEV;
86 86
87 - client = kzalloc_obj(*client);
87 + client = kzalloc(sizeof(*client), GFP_KERNEL);
88 88 if (!client)
89 89 return -ENOMEM;
90 90
modified drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
@@ -796,7 +796,7 @@ static inline struct arm_smmu_invs *arm_smmu_invs_alloc(size_t num_invs)
796 796 {
797 797 struct arm_smmu_invs *new_invs;
798 798
799 - new_invs = kzalloc_flex(*new_invs, inv, num_invs);
799 + new_invs = kzalloc(struct_size(new_invs, inv, num_invs), GFP_KERNEL);
800 800 if (!new_invs)
801 801 return NULL;
802 802 new_invs->max_invs = num_invs;
modified drivers/iommu/iommufd/device.c
@@ -76,7 +76,7 @@ static struct iommufd_group *iommufd_alloc_group(struct iommufd_ctx *ictx,
76 76 {
77 77 struct iommufd_group *new_igroup;
78 78
79 - new_igroup = kzalloc_obj(*new_igroup);
79 + new_igroup = kzalloc_obj(*new_igroup, GFP_KERNEL);
80 80 if (!new_igroup)
81 81 return ERR_PTR(-ENOMEM);
82 82
modified drivers/iommu/iommufd/driver.c
@@ -49,7 +49,7 @@ int _iommufd_alloc_mmap(struct iommufd_ctx *ictx, struct iommufd_object *owner,
49 49 if (!length || !PAGE_ALIGNED(length))
50 50 return -EINVAL;
51 51
52 - immap = kzalloc_obj(*immap);
52 + immap = kzalloc(sizeof(*immap), GFP_KERNEL);
53 53 if (!immap)
54 54 return -ENOMEM;
55 55 immap->owner = owner;
modified drivers/iommu/iommufd/hwpt_noiommu.c
@@ -54,7 +54,7 @@ noiommu_alloc_paging_flags(struct device *dev, u32 flags,
54 54 (BIT(PT_FEAT_DYNAMIC_TOP) | BIT(PT_FEAT_AMDV1_ENCRYPT_TABLES) |
55 55 BIT(PT_FEAT_AMDV1_FORCE_COHERENCE));
56 56
57 - dom = kzalloc_obj(*dom);
57 + dom = kzalloc(sizeof(*dom), GFP_KERNEL);
58 58 if (!dom)
59 59 return ERR_PTR(-ENOMEM);
60 60
modified drivers/iommu/vsi-iommu.c
@@ -231,7 +231,7 @@ static struct iommu_domain *vsi_iommu_domain_alloc_paging(struct device *dev)
231 231 struct vsi_iommu *iommu = dev_iommu_priv_get(dev);
232 232 struct vsi_iommu_domain *vsi_domain;
233 233
234 - vsi_domain = kzalloc_obj(*vsi_domain);
234 + vsi_domain = kzalloc(sizeof(*vsi_domain), GFP_KERNEL);
235 235 if (!vsi_domain)
236 236 return NULL;
237 237
modified drivers/irqchip/irq-gic-v5-irs.c
@@ -618,7 +618,7 @@ static int __init gicv5_irs_of_init_affinity(struct device_node *node,
618 618 if (niaffids != ncpus)
619 619 return -EINVAL;
620 620
621 - u16 *iaffids __free(kfree) = kzalloc_objs(*iaffids, niaffids);
621 + u16 *iaffids __free(kfree) = kcalloc(niaffids, sizeof(*iaffids), GFP_KERNEL);
622 622 if (!iaffids)
623 623 return -ENOMEM;
624 624
modified drivers/irqchip/irq-loongarch-ir.c
@@ -331,7 +331,7 @@ static int redirect_domain_alloc(struct irq_domain *domain, unsigned int virq,
331 331 struct irq_data *irq_data = irq_domain_get_irq_data(domain, virq + i);
332 332 struct redirect_item *item;
333 333
334 - item = kzalloc_obj(*item);
334 + item = kzalloc(sizeof(*item), GFP_KERNEL);
335 335 if (!item) {
336 336 pr_err("Alloc redirect descriptor failed\n");
337 337 goto out_free_resources;
modified drivers/irqchip/irq-mbigen.c
@@ -64,6 +64,20 @@ struct mbigen_device {
64 64 void __iomem *base;
65 65 };
66 66
67 + static inline unsigned int get_mbigen_node_offset(unsigned int nid)
68 + {
69 + unsigned int offset = nid * MBIGEN_NODE_OFFSET;
70 +
71 + /*
72 + * To avoid touched clear register in unexpected way, we need to directly
73 + * skip clear register when access to more than 10 mbigen nodes.
74 + */
75 + if (nid >= (REG_MBIGEN_CLEAR_OFFSET / MBIGEN_NODE_OFFSET))
76 + offset += MBIGEN_NODE_OFFSET;
77 +
78 + return offset;
79 + }
80 +
67 81 static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq)
68 82 {
69 83 unsigned int nid, pin;
@@ -72,8 +86,7 @@ static inline unsigned int get_mbigen_vec_reg(irq_hw_number_t hwirq)
72 86 nid = hwirq / IRQS_PER_MBIGEN_NODE + 1;
73 87 pin = hwirq % IRQS_PER_MBIGEN_NODE;
74 88
75 - return pin * 4 + nid * MBIGEN_NODE_OFFSET
76 - + REG_MBIGEN_VEC_OFFSET;
89 + return pin * 4 + get_mbigen_node_offset(nid) + REG_MBIGEN_VEC_OFFSET;
77 90 }
78 91
79 92 static inline void get_mbigen_type_reg(irq_hw_number_t hwirq,
@@ -88,8 +101,7 @@ static inline void get_mbigen_type_reg(irq_hw_number_t hwirq,
88 101 *mask = 1 << (irq_ofst % 32);
89 102 ofst = irq_ofst / 32 * 4;
90 103
91 - *addr = ofst + nid * MBIGEN_NODE_OFFSET
92 - + REG_MBIGEN_TYPE_OFFSET;
104 + *addr = ofst + get_mbigen_node_offset(nid) + REG_MBIGEN_TYPE_OFFSET;
93 105 }
94 106
95 107 static inline void get_mbigen_clear_reg(irq_hw_number_t hwirq,
modified drivers/irqchip/irq-realtek-rtl.c
@@ -188,7 +188,7 @@ static int __init realtek_setup_parents(struct device_node *node)
188 188 struct irq_domain *domain;
189 189
190 190 cnt = max(1, num_parents);
191 - output = kzalloc_objs(*output, cnt);
191 + output = kcalloc(cnt, sizeof(*output), GFP_KERNEL);
192 192 if (!output)
193 193 return -ENOMEM;
194 194
modified drivers/irqchip/irq-stm32mp-exti.c
@@ -22,7 +22,7 @@
22 22
23 23 #define IRQS_PER_BANK 32
24 24
25 - #define HWSPNLCK_TIMEOUT_MS 1
25 + #define HWSPNLCK_TIMEOUT 1000 /* usec */
26 26
27 27 #define EXTI_EnCIDCFGR(n) (0x180 + (n) * 4)
28 28 #define EXTI_HWCFGR1 0x3f0
@@ -376,7 +376,7 @@ static int stm32mp_exti_set_type(struct irq_data *d, unsigned int type)
376 376 raw_spin_lock(&chip_data->rlock);
377 377
378 378 if (hwlock) {
379 - err = hwspin_lock_timeout_in_atomic(hwlock, HWSPNLCK_TIMEOUT_MS);
379 + err = hwspin_lock_timeout_in_atomic(hwlock, HWSPNLCK_TIMEOUT);
380 380 if (err) {
381 381 pr_err("%s can't get hwspinlock (%d)\n", __func__, err);
382 382 goto unlock;
modified drivers/mailbox/riscv-sbi-mpxy-mbox.c
@@ -783,7 +783,7 @@ static int mpxy_mbox_populate_channels(struct mpxy_mbox *mbox)
783 783 return dev_err_probe(mbox->dev, -ENODEV, "no MPXY channels available\n");
784 784
785 785 /* Allocate and fetch all channel IDs */
786 - channel_ids = kzalloc_objs(*channel_ids, mbox->channel_count);
786 + channel_ids = kcalloc(mbox->channel_count, sizeof(*channel_ids), GFP_KERNEL);
787 787 if (!channel_ids)
788 788 return -ENOMEM;
789 789 rc = mpxy_get_channel_ids(mbox->channel_count, channel_ids);
modified drivers/md/dm-cache-target.c
@@ -340,6 +340,8 @@ struct cache {
340 340 struct list_head invalidation_requests;
341 341
342 342 sector_t migration_threshold;
343 + wait_queue_head_t migration_wait;
344 + atomic_t nr_allocated_migrations;
343 345
344 346 /*
345 347 * The number of in flight migrations that are performing
@@ -395,11 +397,7 @@ struct cache {
395 397 bool loaded_mappings:1;
396 398 bool loaded_discards:1;
397 399
398 - /* background work management */
399 - bool background_work_allowed;
400 - unsigned background_work_nr;
401 - spinlock_t background_work_lock;
402 - wait_queue_head_t background_work_wait;
400 + struct rw_semaphore background_work_lock;
403 401
404 402 struct batcher committer;
405 403 struct work_struct commit_ws;
@@ -490,13 +488,19 @@ static struct dm_cache_migration *alloc_migration(struct cache *cache)
490 488 memset(mg, 0, sizeof(*mg));
491 489
492 490 mg->cache = cache;
491 + atomic_inc(&cache->nr_allocated_migrations);
493 492
494 493 return mg;
495 494 }
496 495
497 496 static void free_migration(struct dm_cache_migration *mg)
498 497 {
499 - mempool_free(mg, &mg->cache->migration_pool);
498 + struct cache *cache = mg->cache;
499 +
500 + if (atomic_dec_and_test(&cache->nr_allocated_migrations))
501 + wake_up(&cache->migration_wait);
502 +
503 + mempool_free(mg, &cache->migration_pool);
500 504 }
501 505
502 506 /*----------------------------------------------------------------*/
@@ -1026,39 +1030,34 @@ static void calc_discard_block_range(struct cache *cache, struct bio *bio,
1026 1030
1027 1031 static void prevent_background_work(struct cache *cache)
1028 1032 {
1029 - spin_lock_irq(&cache->background_work_lock);
1030 - cache->background_work_allowed = false;
1031 - wait_event_lock_irq(cache->background_work_wait,
1032 - cache->background_work_nr == 0,
1033 - cache->background_work_lock);
1034 - spin_unlock_irq(&cache->background_work_lock);
1033 + lockdep_off();
1034 + down_write(&cache->background_work_lock);
1035 + lockdep_on();
1035 1036 }
1036 1037
1037 1038 static void allow_background_work(struct cache *cache)
1038 1039 {
1039 - spin_lock_irq(&cache->background_work_lock);
1040 - cache->background_work_allowed = true;
1041 - spin_unlock_irq(&cache->background_work_lock);
1040 + lockdep_off();
1041 + up_write(&cache->background_work_lock);
1042 + lockdep_on();
1042 1043 }
1043 1044
1044 1045 static bool background_work_begin(struct cache *cache)
1045 1046 {
1046 1047 bool r;
1047 1048
1048 - spin_lock_irq(&cache->background_work_lock);
1049 - r = cache->background_work_allowed;
1050 - if (r)
1051 - cache->background_work_nr++;
1052 - spin_unlock_irq(&cache->background_work_lock);
1049 + lockdep_off();
1050 + r = down_read_trylock(&cache->background_work_lock);
1051 + lockdep_on();
1052 +
1053 1053 return r;
1054 1054 }
1055 1055
1056 1056 static void background_work_end(struct cache *cache)
1057 1057 {
1058 - spin_lock_irq(&cache->background_work_lock);
1059 - if (--cache->background_work_nr == 0)
1060 - wake_up(&cache->background_work_wait);
1061 - spin_unlock_irq(&cache->background_work_lock);
1058 + lockdep_off();
1059 + up_read(&cache->background_work_lock);
1060 + lockdep_on();
1062 1061 }
1063 1062
1064 1063 /*----------------------------------------------------------------*/
@@ -1463,9 +1462,6 @@ static void invalidate_complete(struct dm_cache_migration *mg, bool success)
1463 1462 struct bio_list bios;
1464 1463 struct cache *cache = mg->cache;
1465 1464
1466 - if (success)
1467 - atomic_inc(&cache->stats.demotion);
1468 -
1469 1465 bio_list_init(&bios);
1470 1466 if (mg->cell) {
1471 1467 if (dm_cell_unlock_v2(cache->prison, mg->cell, &bios))
@@ -1737,6 +1733,7 @@ static int map_bio(struct cache *cache, struct bio *bio, dm_oblock_t block,
1737 1733 if (passthrough_mode(cache)) {
1738 1734 if (bio_data_dir(bio) == WRITE) {
1739 1735 bio_drop_shared_lock(cache, bio);
1736 + atomic_inc(&cache->stats.demotion);
1740 1737 invalidate_start(cache, cblock, block, bio);
1741 1738 return DM_MAPIO_SUBMITTED;
1742 1739 } else
@@ -2510,7 +2507,9 @@ static int cache_create(struct cache_args *ca, struct cache **result)
2510 2507
2511 2508 spin_lock_init(&cache->lock);
2512 2509 bio_list_init(&cache->deferred_bios);
2510 + atomic_set(&cache->nr_allocated_migrations, 0);
2513 2511 atomic_set(&cache->nr_io_migrations, 0);
2512 + init_waitqueue_head(&cache->migration_wait);
2514 2513
2515 2514 r = -ENOMEM;
2516 2515 atomic_set(&cache->nr_dirty, 0);
@@ -2593,10 +2592,8 @@ static int cache_create(struct cache_args *ca, struct cache **result)
2593 2592 issue_op, cache, cache->wq);
2594 2593 dm_iot_init(&cache->tracker);
2595 2594
2596 - init_waitqueue_head(&cache->background_work_wait);
2597 - spin_lock_init(&cache->background_work_lock);
2598 - cache->background_work_allowed = false;
2599 - cache->background_work_nr = 0;
2595 + init_rwsem(&cache->background_work_lock);
2596 + prevent_background_work(cache);
2600 2597
2601 2598 *result = cache;
2602 2599 return 0;
modified drivers/md/dm-crypt.c
@@ -1745,6 +1745,7 @@ static void crypt_dec_pending(struct dm_crypt_io *io)
1745 1745 {
1746 1746 struct crypt_config *cc = io->cc;
1747 1747 struct bio *base_bio = io->base_bio;
1748 + blk_status_t error = io->error;
1748 1749
1749 1750 if (!atomic_dec_and_test(&io->io_pending))
1750 1751 return;
@@ -1766,7 +1767,7 @@ static void crypt_dec_pending(struct dm_crypt_io *io)
1766 1767 else
1767 1768 kfree(io->integrity_metadata);
1768 1769
1769 - base_bio->bi_status = io->error;
1770 + base_bio->bi_status = error;
1770 1771
1771 1772 bio_endio(base_bio);
1772 1773 }
modified drivers/md/dm-ebs-target.c
@@ -265,7 +265,8 @@ static int ebs_ctr(struct dm_target *ti, unsigned int argc, char **argv)
265 265
266 266 r = -EINVAL;
267 267 if (sscanf(argv[1], "%llu%c", &tmp, &dummy) != 1 ||
268 - tmp != (sector_t)tmp) {
268 + tmp != (sector_t)tmp ||
269 + (sector_t)tmp >= ti->len) {
269 270 ti->error = "Invalid device offset sector";
270 271 goto bad;
271 272 }
modified drivers/md/dm-inlinecrypt.c
@@ -322,7 +322,7 @@ static int inlinecrypt_ctr(struct dm_target *ti, unsigned int argc, char **argv)
322 322 return -EINVAL;
323 323 }
324 324
325 - ctx = kzalloc_obj(*ctx);
325 + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
326 326 if (!ctx) {
327 327 ti->error = "Out of memory";
328 328 return -ENOMEM;
modified drivers/md/dm-integrity.c
@@ -1979,8 +1979,8 @@ static void integrity_metadata(struct work_struct *w)
1979 1979
1980 1980 if (unlikely(dio->op == REQ_OP_DISCARD)) {
1981 1981 unsigned int bi_size = dio->bio_details.bi_iter.bi_size;
1982 - unsigned int max_size = likely(checksums != checksums_onstack) ? PAGE_SIZE : sizeof(checksums_onstack);
1983 - unsigned int max_blocks = (max_size - extra_space) / ic->tag_size;
1982 + unsigned int max_size = likely(checksums != checksums_onstack) ? PAGE_SIZE : HASH_MAX_DIGESTSIZE;
1983 + unsigned int max_blocks = max_size / ic->tag_size;
1984 1984 sector_t sector = dio->range.logical_sector;
1985 1985
1986 1986 if (!ic->discard_keyed)
@@ -3875,10 +3875,6 @@ static void dm_integrity_resume(struct dm_target *ti)
3875 3875 r = sync_rw_sb(ic, REQ_OP_READ);
3876 3876 if (r)
3877 3877 dm_integrity_io_error(ic, "reading superblock", r);
3878 -
3879 - if (ic->mode == 'R')
3880 - goto skip_writes;
3881 -
3882 3878 if ((ic->sb->flags & flags) != flags) {
3883 3879 ic->sb->flags |= flags;
3884 3880 r = sync_rw_sb(ic, REQ_OP_WRITE | REQ_FUA);
@@ -3988,7 +3984,6 @@ static void dm_integrity_resume(struct dm_target *ti)
3988 3984 }
3989 3985 }
3990 3986
3991 - skip_writes:
3992 3987 ic->reboot_notifier.notifier_call = dm_integrity_reboot;
3993 3988 ic->reboot_notifier.next = NULL;
3994 3989 ic->reboot_notifier.priority = INT_MAX - 1; /* be notified after md and before hardware drivers */
@@ -4135,10 +4130,6 @@ static void dm_integrity_io_hints(struct dm_target *ti, struct queue_limits *lim
4135 4130 limits->dma_alignment = limits->logical_block_size - 1;
4136 4131 limits->discard_granularity = ic->sectors_per_block << SECTOR_SHIFT;
4137 4132
4138 - if (ic->internal_hash &&
4139 - (ic->mode == 'D' || ic->mode == 'B' || ic->mode == 'I'))
4140 - limits->features |= BLK_FEAT_STABLE_WRITES;
4141 -
4142 4133 if (!ic->internal_hash) {
4143 4134 struct blk_integrity *bi = &limits->integrity;
4144 4135
modified drivers/md/md-llbitmap.c
@@ -810,7 +810,7 @@ static int llbitmap_expand_pages(struct llbitmap *llbitmap,
810 810 if (nr_pages <= old_nr_pages)
811 811 return 0;
812 812
813 - pctl = kzalloc_objs(*pctl, nr_pages, GFP_NOIO);
813 + pctl = kcalloc(nr_pages, sizeof(*pctl), GFP_NOIO);
814 814 if (!pctl)
815 815 return -ENOMEM;
816 816
@@ -846,7 +846,7 @@ static int llbitmap_alloc_pages(struct llbitmap *llbitmap)
846 846 unsigned int nr_pages = max(used_pages, llbitmap_reserved_pages(llbitmap));
847 847 int i;
848 848
849 - llbitmap->pctl = kzalloc_objs(*llbitmap->pctl, nr_pages, GFP_NOIO);
849 + llbitmap->pctl = kcalloc(nr_pages, sizeof(*llbitmap->pctl), GFP_NOIO);
850 850 if (!llbitmap->pctl)
851 851 return -ENOMEM;
852 852
modified drivers/media/platform/allegro-dvt/allegro-core.c
@@ -3105,7 +3105,7 @@ static int allegro_open(struct file *file)
3105 3105 unsigned int cpb_size_max;
3106 3106 unsigned int cpb_size_def;
3107 3107
3108 - channel = kzalloc_obj(*channel);
3108 + channel = kzalloc(sizeof(*channel), GFP_KERNEL);
3109 3109 if (!channel)
3110 3110 return -ENOMEM;
3111 3111
modified drivers/media/platform/amd/isp4/isp4_interface.c
@@ -127,7 +127,7 @@ isp4if_gpu_mem_alloc(struct isp4_interface *ispif, u32 mem_size)
127 127 struct device *dev = ispif->dev;
128 128 int ret;
129 129
130 - mem_info = kmalloc_obj(*mem_info);
130 + mem_info = kmalloc_obj(*mem_info, GFP_KERNEL);
131 131 if (!mem_info)
132 132 return NULL;
133 133
@@ -368,7 +368,7 @@ static int isp4if_send_fw_cmd(struct isp4_interface *ispif, u32 cmd_id,
368 368
369 369 /* Allocate the sync command object early and outside of the lock */
370 370 if (sync) {
371 - ele = kmalloc_obj(*ele);
371 + ele = kmalloc_obj(*ele, GFP_KERNEL);
372 372 if (!ele)
373 373 return -ENOMEM;
374 374
@@ -738,7 +738,7 @@ isp4if_alloc_buffer_node(struct isp4if_img_buf_info *buf_info)
738 738 {
739 739 struct isp4if_img_buf_node *node;
740 740
741 - node = kmalloc_obj(*node);
741 + node = kmalloc_obj(*node, GFP_KERNEL);
742 742 if (node)
743 743 node->buf_info = *buf_info;
744 744
modified drivers/media/platform/renesas/rcar-isp/core.c
@@ -232,7 +232,7 @@ int risp_core_job_prepare(struct rcar_isp_core *core)
232 232 }
233 233
234 234 /* Memory is released when the job is consumed. */
235 - job = kzalloc_obj(*job);
235 + job = kzalloc(sizeof(*job), GFP_KERNEL);
236 236 if (!job)
237 237 return -ENOMEM;
238 238
modified drivers/media/rc/igorplugusb.c
@@ -164,7 +164,7 @@ static int igorplugusb_probe(struct usb_interface *intf,
164 164 if (!ir)
165 165 return -ENOMEM;
166 166
167 - ir->request = kzalloc_obj(*ir->request);
167 + ir->request = kzalloc_obj(*ir->request, GFP_KERNEL);
168 168 if (!ir->request)
169 169 goto fail;
170 170
modified drivers/mfd/mfd-core.c
@@ -135,7 +135,7 @@ static int mfd_match_of_node_to_dev(struct platform_device *pdev,
135 135 return -EAGAIN;
136 136
137 137 allocate_of_node:
138 - of_entry = kzalloc_obj(*of_entry);
138 + of_entry = kzalloc(sizeof(*of_entry), GFP_KERNEL);
139 139 if (!of_entry)
140 140 return -ENOMEM;
141 141
@@ -174,7 +174,7 @@ static int mfd_add_device(struct device *parent, int id,
174 174 if (!pdev->mfd_cell)
175 175 goto fail_device;
176 176
177 - res = kzalloc_objs(*res, cell->num_resources);
177 + res = kcalloc(cell->num_resources, sizeof(*res), GFP_KERNEL);
178 178 if (!res)
179 179 goto fail_device;
180 180
modified drivers/mfd/ucb1x00-assabet.c
@@ -96,7 +96,7 @@ static int ucb1x00_assabet_add(struct ucb1x00_dev *dev)
96 96
97 97 struct ucb1x00_assabet_priv *priv;
98 98
99 - priv = kzalloc_obj(*priv);
99 + priv = kzalloc_obj(*priv, GFP_KERNEL);
100 100 if (!priv)
101 101 return -ENOMEM;
102 102
modified drivers/misc/fastrpc.c
@@ -1822,20 +1822,24 @@ static int fastrpc_dmabuf_alloc(struct fastrpc_user *fl, char __user *argp)
1822 1822 return err;
1823 1823 }
1824 1824
1825 - bp.fd = get_unused_fd_flags(O_ACCMODE);
1825 + bp.fd = dma_buf_fd(buf->dmabuf, O_ACCMODE);
1826 1826 if (bp.fd < 0) {
1827 1827 dma_buf_put(buf->dmabuf);
1828 - return bp.fd;
1828 + return -EINVAL;
1829 1829 }
1830 1830
1831 1831 if (copy_to_user(argp, &bp, sizeof(bp))) {
1832 - put_unused_fd(bp.fd);
1833 - dma_buf_put(buf->dmabuf);
1832 + /*
1833 + * The usercopy failed, but we can't do much about it, as
1834 + * dma_buf_fd() already called fd_install() and made the
1835 + * file descriptor accessible for the current process. It
1836 + * might already be closed and dmabuf no longer valid when
1837 + * we reach this point. Therefore "leak" the fd and rely on
1838 + * the process exit path to do any required cleanup.
1839 + */
1834 1840 return -EFAULT;
1835 1841 }
1836 1842
1837 - dma_buf_fd_install(buf->dmabuf, bp.fd);
1838 -
1839 1843 return 0;
1840 1844 }
1841 1845
modified drivers/mtd/mtd_virt_concat.c
@@ -166,7 +166,7 @@ static int mtd_virt_concat_create_item(struct device_node *parts,
166 166 return 0;
167 167 }
168 168
169 - item = kzalloc_flex(*item, nodes, count);
169 + item = kzalloc_flex(*item, nodes, count, GFP_KERNEL);
170 170 if (!item)
171 171 return -ENOMEM;
172 172
@@ -182,7 +182,7 @@ static int mtd_virt_concat_create_item(struct device_node *parts,
182 182 for (i = 1; i < count; i++)
183 183 item->nodes[i] = of_parse_phandle(parts, CONCAT_PROP, (i - 1));
184 184
185 - concat = kzalloc_flex(*concat, subdev, count);
185 + concat = kzalloc_flex(*concat, subdev, count, GFP_KERNEL);
186 186 if (!concat) {
187 187 kfree(item);
188 188 return -ENOMEM;
modified drivers/mtd/mtdconcat.c
@@ -639,7 +639,7 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c
639 639 printk(KERN_NOTICE "into device \"%s\"\n", name);
640 640
641 641 /* allocate the device structure */
642 - concat = kzalloc_flex(*concat, subdev, num_devs);
642 + concat = kzalloc_flex(*concat, subdev, num_devs, GFP_KERNEL);
643 643 if (!concat) {
644 644 printk
645 645 ("memory allocation error while creating concatenated device \"%s\"\n",
modified drivers/net/bonding/bond_alb.c
@@ -875,7 +875,7 @@ static int rlb_initialize(struct bonding *bond)
875 875 spin_unlock_bh(&bond->mode_lock);
876 876
877 877 /* register to receive ARPs */
878 - WRITE_ONCE(bond->recv_probe, rlb_arp_recv);
878 + bond->recv_probe = rlb_arp_recv;
879 879
880 880 return 0;
881 881 }
@@ -1281,10 +1281,10 @@ unwind:
1281 1281 }
1282 1282
1283 1283 /* determine if the packet is NA or NS */
1284 - static bool alb_determine_nd(struct sk_buff *skb)
1284 + static bool alb_determine_nd(struct sk_buff *skb, struct bonding *bond)
1285 1285 {
1286 - const struct ipv6hdr *ip6hdr;
1287 - const struct icmp6hdr *hdr;
1286 + struct ipv6hdr *ip6hdr;
1287 + struct icmp6hdr *hdr;
1288 1288
1289 1289 if (!pskb_network_may_pull(skb, sizeof(*ip6hdr)))
1290 1290 return true;
@@ -1296,8 +1296,7 @@ static bool alb_determine_nd(struct sk_buff *skb)
1296 1296 if (!pskb_network_may_pull(skb, sizeof(*ip6hdr) + sizeof(*hdr)))
1297 1297 return true;
1298 1298
1299 - ip6hdr = ipv6_hdr(skb);
1300 - hdr = (const struct icmp6hdr *)(ip6hdr + 1);
1299 + hdr = icmp6_hdr(skb);
1301 1300 return hdr->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT ||
1302 1301 hdr->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION;
1303 1302 }
@@ -1382,7 +1381,7 @@ struct slave *bond_xmit_tlb_slave_get(struct bonding *bond,
1382 1381 if (!is_multicast_ether_addr(eth_data->h_dest)) {
1383 1382 switch (skb->protocol) {
1384 1383 case htons(ETH_P_IPV6):
1385 - if (alb_determine_nd(skb))
1384 + if (alb_determine_nd(skb, bond))
1386 1385 break;
1387 1386 fallthrough;
1388 1387 case htons(ETH_P_IP):
@@ -1468,7 +1467,7 @@ struct slave *bond_xmit_alb_slave_get(struct bonding *bond,
1468 1467 break;
1469 1468 }
1470 1469
1471 - if (alb_determine_nd(skb)) {
1470 + if (alb_determine_nd(skb, bond)) {
1472 1471 do_tx_balance = false;
1473 1472 break;
1474 1473 }
modified drivers/net/bonding/bond_main.c
@@ -1245,7 +1245,7 @@ static void bond_peer_notify_may_events(struct bonding *bond, bool force)
1245 1245 }
1246 1246
1247 1247 if (notified || force)
1248 - WRITE_ONCE(bond->send_peer_notif, bond->send_peer_notif - 1);
1248 + bond->send_peer_notif--;
1249 1249 }
1250 1250
1251 1251 /**
@@ -2284,7 +2284,7 @@ skip_mac_set:
2284 2284 }
2285 2285 }
2286 2286
2287 - WRITE_ONCE(bond->slave_cnt, bond->slave_cnt + 1);
2287 + bond->slave_cnt++;
2288 2288 netdev_compute_master_upper_features(bond->dev, true);
2289 2289 bond_set_carrier(bond);
2290 2290
@@ -2517,7 +2517,9 @@ static int __bond_release_one(struct net_device *bond_dev,
2517 2517 bond_alb_deinit_slave(bond, slave);
2518 2518 }
2519 2519
2520 - if (!all && oldcurrent == slave) {
2520 + if (all) {
2521 + RCU_INIT_POINTER(bond->curr_active_slave, NULL);
2522 + } else if (oldcurrent == slave) {
2521 2523 /* Note that we hold RTNL over this sequence, so there
2522 2524 * is no concern that another slave add/remove event
2523 2525 * will interfere.
@@ -2531,7 +2533,7 @@ static int __bond_release_one(struct net_device *bond_dev,
2531 2533
2532 2534 unblock_netpoll_tx();
2533 2535 synchronize_rcu();
2534 - WRITE_ONCE(bond->slave_cnt, bond->slave_cnt - 1);
2536 + bond->slave_cnt--;
2535 2537
2536 2538 if (!bond_has_slaves(bond)) {
2537 2539 call_netdevice_notifiers(NETDEV_CHANGEADDR, bond->dev);
@@ -4383,13 +4385,13 @@ static int bond_open(struct net_device *bond_dev)
4383 4385
4384 4386 if (bond->params.arp_interval) { /* arp interval, in milliseconds. */
4385 4387 queue_delayed_work(bond->wq, &bond->arp_work, 0);
4386 - WRITE_ONCE(bond->recv_probe, bond_rcv_validate);
4388 + bond->recv_probe = bond_rcv_validate;
4387 4389 }
4388 4390
4389 4391 if (BOND_MODE(bond) == BOND_MODE_8023AD) {
4390 4392 queue_delayed_work(bond->wq, &bond->ad_work, 0);
4391 4393 /* register to receive LACPDUs */
4392 - WRITE_ONCE(bond->recv_probe, bond_3ad_lacpdu_recv);
4394 + bond->recv_probe = bond_3ad_lacpdu_recv;
4393 4395 bond_3ad_initiate_agg_selection(bond, 1);
4394 4396
4395 4397 bond_for_each_slave(bond, slave, iter)
@@ -4411,7 +4413,7 @@ static int bond_close(struct net_device *bond_dev)
4411 4413 struct slave *slave;
4412 4414
4413 4415 bond_work_cancel_all(bond);
4414 - WRITE_ONCE(bond->send_peer_notif, 0);
4416 + bond->send_peer_notif = 0;
4415 4417 WRITE_ONCE(bond->recv_probe, NULL);
4416 4418
4417 4419 /* Wait for any in-flight RX handlers */
@@ -5116,7 +5118,7 @@ static void bond_skip_slave(struct bond_up_slave *slaves,
5116 5118 if (skipslave == slaves->arr[idx]) {
5117 5119 slaves->arr[idx] =
5118 5120 slaves->arr[slaves->count - 1];
5119 - WRITE_ONCE(slaves->count, slaves->count - 1);
5121 + slaves->count--;
5120 5122 break;
5121 5123 }
5122 5124 }
modified drivers/net/bonding/bond_options.c
@@ -1147,11 +1147,11 @@ static int bond_option_arp_interval_set(struct bonding *bond,
1147 1147 */
1148 1148 if (!newval->value) {
1149 1149 if (bond->params.arp_validate)
1150 - WRITE_ONCE(bond->recv_probe, NULL);
1150 + bond->recv_probe = NULL;
1151 1151 cancel_delayed_work_sync(&bond->arp_work);
1152 1152 } else {
1153 1153 /* arp_validate can be set only in active-backup mode */
1154 - WRITE_ONCE(bond->recv_probe, bond_rcv_validate);
1154 + bond->recv_probe = bond_rcv_validate;
1155 1155 cancel_delayed_work_sync(&bond->mii_work);
1156 1156 queue_delayed_work(bond->wq, &bond->arp_work, 0);
1157 1157 }
modified drivers/net/dsa/mv88e6xxx/tcflower.c
@@ -97,7 +97,7 @@ int mv88e6xxx_cls_flower_add(struct dsa_switch *ds, int port,
97 97 goto err_unlock;
98 98 }
99 99
100 - entry = kzalloc_obj(*entry);
100 + entry = kzalloc(sizeof(*entry), GFP_KERNEL);
101 101 if (!entry) {
102 102 err = -ENOMEM;
103 103 goto err_unlock;
modified drivers/net/ethernet/airoha/airoha_eth.h
@@ -538,7 +538,7 @@ struct airoha_wdma_info {
538 538
539 539 /* RX queue to IRQ mapping: BIT(q) in IRQ(n) */
540 540 #define RX_IRQ0_BANK_PIN_MASK 0x839f
541 - #define RX_IRQ1_BANK_PIN_MASK 0xffe00000
541 + #define RX_IRQ1_BANK_PIN_MASK 0x7fe00000
542 542 #define RX_IRQ2_BANK_PIN_MASK 0x20
543 543 #define RX_IRQ3_BANK_PIN_MASK 0x40
544 544 #define RX_IRQ_BANK_PIN_MASK(_n) \
modified drivers/net/ethernet/alibaba/eea/eea_adminq.c
@@ -439,7 +439,8 @@ int eea_adminq_dev_status(struct eea_net *enet,
439 439 q_num = enet->cfg.rx_ring_num + enet->cfg.tx_ring_num + 1;
440 440 io_num = enet->cfg.rx_ring_num + enet->cfg.tx_ring_num;
441 441
442 - req = kzalloc_objs(struct eea_aq_queue_drv_status, q_num);
442 + req = kcalloc(q_num, sizeof(struct eea_aq_queue_drv_status),
443 + GFP_KERNEL);
443 444 if (!req)
444 445 return -ENOMEM;
445 446
@@ -485,11 +486,11 @@ void eea_adminq_config_host_info(struct eea_net *enet)
485 486 struct eea_aq_host_info_rep *rep;
486 487 int rc = -ENOMEM;
487 488
488 - cfg = kzalloc_obj(*cfg);
489 + cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
489 490 if (!cfg)
490 491 return;
491 492
492 - rep = kzalloc_obj(*rep);
493 + rep = kzalloc(sizeof(*rep), GFP_KERNEL);
493 494 if (!rep)
494 495 goto err_free_cfg;
495 496
modified drivers/net/ethernet/alibaba/eea/eea_net.c
@@ -62,7 +62,7 @@ static int eea_alloc_irq_blks(struct eea_net *enet)
62 62
63 63 num = enet->edev->rx_num;
64 64
65 - irq_blks = kvzalloc_objs(*blk, num);
65 + irq_blks = kvcalloc(num, sizeof(*blk), GFP_KERNEL);
66 66 if (!irq_blks)
67 67 return -ENOMEM;
68 68
@@ -194,11 +194,11 @@ static int eea_alloc_rxtx_q_mem(struct eea_net_init_ctx *ctx)
194 194 struct eea_net_tx *tx;
195 195 int err, i;
196 196
197 - ctx->tx = kvzalloc_objs(*ctx->tx, ctx->cfg.tx_ring_num);
197 + ctx->tx = kvcalloc(ctx->cfg.tx_ring_num, sizeof(*ctx->tx), GFP_KERNEL);
198 198 if (!ctx->tx)
199 199 return -ENOMEM;
200 200
201 - ctx->rx = kvzalloc_objs(*ctx->rx, ctx->cfg.rx_ring_num);
201 + ctx->rx = kvcalloc(ctx->cfg.rx_ring_num, sizeof(*ctx->rx), GFP_KERNEL);
202 202 if (!ctx->rx)
203 203 goto err_free_tx;
204 204
@@ -601,7 +601,7 @@ static int eea_netdev_init_features(struct net_device *netdev,
601 601 int err;
602 602 u32 mtu;
603 603
604 - cfg = kzalloc_obj(*cfg);
604 + cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
605 605 if (!cfg)
606 606 return -ENOMEM;
607 607
modified drivers/net/ethernet/alibaba/eea/eea_pci.c
@@ -651,7 +651,7 @@ static int eea_pci_probe(struct pci_dev *pci_dev,
651 651 struct eea_device *edev;
652 652 int err;
653 653
654 - ep_dev = kzalloc_obj(*ep_dev);
654 + ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL);
655 655 if (!ep_dev)
656 656 return -ENOMEM;
657 657
modified drivers/net/ethernet/alibaba/eea/eea_ring.c
@@ -217,7 +217,7 @@ struct eea_ring *eea_ering_alloc(u32 index, u32 num, struct eea_device *edev,
217 217 if (!cq_desc_size || !is_power_of_2(cq_desc_size))
218 218 return NULL;
219 219
220 - ering = kzalloc_obj(*ering);
220 + ering = kzalloc(sizeof(*ering), GFP_KERNEL);
221 221 if (!ering)
222 222 return NULL;
223 223
modified drivers/net/ethernet/alibaba/eea/eea_rx.c
@@ -764,7 +764,7 @@ struct eea_net_rx *eea_alloc_rx(struct eea_net_init_ctx *ctx, u32 idx)
764 764 struct eea_net_rx *rx;
765 765 int err;
766 766
767 - rx = kzalloc_obj(*rx);
767 + rx = kzalloc(sizeof(*rx), GFP_KERNEL);
768 768 if (!rx)
769 769 return rx;
770 770
@@ -786,7 +786,8 @@ struct eea_net_rx *eea_alloc_rx(struct eea_net_init_ctx *ctx, u32 idx)
786 786 rx->dma_dev = ctx->edev->dma_dev;
787 787
788 788 /* meta */
789 - rx->meta = kvzalloc_objs(*rx->meta, ctx->cfg.rx_ring_depth);
789 + rx->meta = kvcalloc(ctx->cfg.rx_ring_depth,
790 + sizeof(*rx->meta), GFP_KERNEL);
790 791 if (!rx->meta)
791 792 goto err_free_rx;
792 793
modified drivers/net/ethernet/alibaba/eea/eea_tx.c
@@ -480,7 +480,8 @@ int eea_alloc_tx(struct eea_net_init_ctx *ctx, struct eea_net_tx *tx, u32 idx)
480 480 tx->dma_dev = ctx->edev->dma_dev;
481 481
482 482 /* meta */
483 - tx->meta = kvzalloc_objs(*tx->meta, ctx->cfg.tx_ring_depth);
483 + tx->meta = kvcalloc(ctx->cfg.tx_ring_depth,
484 + sizeof(*tx->meta), GFP_KERNEL);
484 485 if (!tx->meta)
485 486 goto err_free_tx;
486 487
modified drivers/net/ethernet/amd/pds_core/core.c
@@ -810,7 +810,8 @@ void pdsc_host_mem_add(struct pdsc *pdsc)
810 810 if (count == 0)
811 811 return;
812 812
813 - pdsc->host_mem_reqs = kzalloc_objs(*pdsc->host_mem_reqs, count);
813 + pdsc->host_mem_reqs = kzalloc_objs(*pdsc->host_mem_reqs, count,
814 + GFP_KERNEL);
814 815 if (!pdsc->host_mem_reqs) {
815 816 dev_err(pdsc->dev, "failed to alloc host_mem_reqs array\n");
816 817 return;
modified drivers/net/ethernet/amd/pds_core/fw.c
@@ -382,7 +382,7 @@ static int pdsc_send_package_data(struct pldmfw *context, const u8 *data,
382 382 if (!length)
383 383 return 0;
384 384
385 - deferred = kmalloc_obj(*deferred);
385 + deferred = kmalloc_obj(*deferred, GFP_KERNEL);
386 386 if (!deferred)
387 387 return -ENOMEM;
388 388
@@ -505,7 +505,7 @@ static int pdsc_send_component_table(struct pldmfw *context,
505 505 component->version_string, component->index,
506 506 component->component_size, transfer_flag);
507 507
508 - component_priv = kzalloc_obj(*component_priv);
508 + component_priv = kzalloc_obj(*component_priv, GFP_KERNEL);
509 509 if (!component_priv)
510 510 return -ENOMEM;
511 511
@@ -710,7 +710,7 @@ static int pdsc_flash_component_chunk(struct pdsc *pdsc, struct device *dev,
710 710 u8 *component_data;
711 711 int err;
712 712
713 - deferred = kmalloc_obj(*deferred);
713 + deferred = kmalloc_obj(*deferred, GFP_KERNEL);
714 714 if (!deferred)
715 715 return -ENOMEM;
716 716
modified drivers/net/ethernet/amd/xgbe/xgbe-dev.c
@@ -3400,7 +3400,7 @@ static void xgbe_enable_rx(struct xgbe_prv_data *pdata)
3400 3400 XGMAC_IOWRITE(pdata, MAC_RQC0R, reg_val);
3401 3401
3402 3402 /* Enable MAC Rx */
3403 - XGMAC_IOWRITE_BITS(pdata, MAC_RCR, DCRCC, 0);
3403 + XGMAC_IOWRITE_BITS(pdata, MAC_RCR, DCRCC, 1);
3404 3404 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, CST, 1);
3405 3405 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, ACS, 1);
3406 3406 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, RE, 1);
@@ -3411,6 +3411,7 @@ static void xgbe_disable_rx(struct xgbe_prv_data *pdata)
3411 3411 unsigned int i;
3412 3412
3413 3413 /* Disable MAC Rx */
3414 + XGMAC_IOWRITE_BITS(pdata, MAC_RCR, DCRCC, 0);
3414 3415 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, CST, 0);
3415 3416 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, ACS, 0);
3416 3417 XGMAC_IOWRITE_BITS(pdata, MAC_RCR, RE, 0);
modified drivers/net/ethernet/cadence/macb.h
@@ -968,8 +968,6 @@ struct macb_dma_desc_ptp {
968 968 * of the frame
969 969 * @mapping: DMA address of the skb's fragment buffer
970 970 * @size: size of the DMA mapped buffer
971 - * @fcs_len: FCS bytes appended in software, 0 or ETH_FCS_LEN, only
972 - * set for the last buffer of the frame
973 971 * @mapped_as_page: true when buffer was mapped with skb_frag_dma_map(),
974 972 * false when buffer was mapped with dma_map_single()
975 973 */
@@ -977,7 +975,6 @@ struct macb_tx_skb {
977 975 struct sk_buff *skb;
978 976 dma_addr_t mapping;
979 977 size_t size;
980 - u8 fcs_len;
981 978 bool mapped_as_page;
982 979 };
983 980
modified drivers/net/ethernet/cadence/macb_main.c
@@ -1322,8 +1322,8 @@ static void macb_tx_error_task(struct work_struct *work)
1322 1322 bp->netdev->stats.tx_packets++;
1323 1323 queue->stats.tx_packets++;
1324 1324 packets++;
1325 - bp->netdev->stats.tx_bytes += skb->len - tx_skb->fcs_len;
1326 - queue->stats.tx_bytes += skb->len - tx_skb->fcs_len;
1325 + bp->netdev->stats.tx_bytes += skb->len;
1326 + queue->stats.tx_bytes += skb->len;
1327 1327 bytes += skb->len;
1328 1328 }
1329 1329 } else {
@@ -1450,8 +1450,8 @@ static int macb_tx_complete(struct macb_queue *queue, int budget)
1450 1450 skb->data);
1451 1451 bp->netdev->stats.tx_packets++;
1452 1452 queue->stats.tx_packets++;
1453 - bp->netdev->stats.tx_bytes += skb->len - tx_skb->fcs_len;
1454 - queue->stats.tx_bytes += skb->len - tx_skb->fcs_len;
1453 + bp->netdev->stats.tx_bytes += skb->len;
1454 + queue->stats.tx_bytes += skb->len;
1455 1455 packets++;
1456 1456 bytes += skb->len;
1457 1457 }
@@ -2199,8 +2199,7 @@ static void macb_poll_controller(struct net_device *netdev)
2199 2199 static unsigned int macb_tx_map(struct macb *bp,
2200 2200 struct macb_queue *queue,
2201 2201 struct sk_buff *skb,
2202 - unsigned int hdrlen,
2203 - u8 fcs_len)
2202 + unsigned int hdrlen)
2204 2203 {
2205 2204 unsigned int f, nr_frags = skb_shinfo(skb)->nr_frags;
2206 2205 unsigned int len, i, tx_head = queue->tx_head;
@@ -2285,7 +2284,6 @@ static unsigned int macb_tx_map(struct macb *bp,
2285 2284
2286 2285 /* This is the last buffer of the frame: save socket buffer */
2287 2286 tx_skb->skb = skb;
2288 - tx_skb->fcs_len = fcs_len;
2289 2287
2290 2288 /* Update TX ring: update buffer descriptors in reverse order
2291 2289 * to avoid race condition
@@ -2419,7 +2417,6 @@ static inline int macb_clear_csum(struct sk_buff *skb)
2419 2417 return 0;
2420 2418 }
2421 2419
2422 - /* Returns a negative errno, or the FCS bytes appended (0 or ETH_FCS_LEN). */
2423 2420 static int macb_pad_and_fcs(struct sk_buff **skb, struct net_device *netdev)
2424 2421 {
2425 2422 bool cloned = skb_cloned(*skb) || skb_header_cloned(*skb) ||
@@ -2468,7 +2465,7 @@ add_fcs:
2468 2465 skb_put_u8(*skb, (fcs >> 16) & 0xff);
2469 2466 skb_put_u8(*skb, (fcs >> 24) & 0xff);
2470 2467
2471 - return ETH_FCS_LEN;
2468 + return 0;
2472 2469 }
2473 2470
2474 2471 static netdev_tx_t macb_start_xmit(struct sk_buff *skb,
@@ -2481,7 +2478,6 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb,
2481 2478 netdev_tx_t ret = NETDEV_TX_OK;
2482 2479 unsigned int hdrlen;
2483 2480 unsigned long flags;
2484 - int fcs_len;
2485 2481 bool is_lso;
2486 2482
2487 2483 if (macb_clear_csum(skb)) {
@@ -2489,8 +2485,7 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb,
2489 2485 return ret;
2490 2486 }
2491 2487
2492 - fcs_len = macb_pad_and_fcs(&skb, netdev);
2493 - if (fcs_len < 0) {
2488 + if (macb_pad_and_fcs(&skb, netdev)) {
2494 2489 dev_kfree_skb_any(skb);
2495 2490 return ret;
2496 2491 }
@@ -2553,7 +2548,7 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb,
2553 2548 }
2554 2549
2555 2550 /* Map socket buffer for DMA transfer */
2556 - if (macb_tx_map(bp, queue, skb, hdrlen, fcs_len)) {
2551 + if (macb_tx_map(bp, queue, skb, hdrlen)) {
2557 2552 dev_kfree_skb_any(skb);
2558 2553 goto unlock;
2559 2554 }
@@ -4334,7 +4329,7 @@ static int macb_taprio_setup_replace(struct net_device *netdev,
4334 4329 return -EINVAL;
4335 4330 }
4336 4331
4337 - enst_queue = kzalloc_objs(*enst_queue, conf->num_entries);
4332 + enst_queue = kcalloc(conf->num_entries, sizeof(*enst_queue), GFP_KERNEL);
4338 4333 if (unlikely(!enst_queue))
4339 4334 return -ENOMEM;
4340 4335
modified drivers/net/ethernet/cisco/enic/enic_admin.c
@@ -137,7 +137,7 @@ static void enic_admin_msg_enqueue(struct enic *enic, void *buf,
137 137 {
138 138 struct enic_admin_msg *msg;
139 139
140 - msg = kmalloc_flex(*msg, data, len);
140 + msg = kmalloc(struct_size(msg, data, len), GFP_KERNEL);
141 141 if (!msg)
142 142 return;
143 143
modified drivers/net/ethernet/cisco/enic/enic_main.c
@@ -2858,7 +2858,7 @@ enic_sriov_v2_enable(struct enic *enic, int num_vfs)
2858 2858 return -EOPNOTSUPP;
2859 2859 }
2860 2860
2861 - enic->vf_state = kzalloc_objs(*enic->vf_state, num_vfs);
2861 + enic->vf_state = kcalloc(num_vfs, sizeof(*enic->vf_state), GFP_KERNEL);
2862 2862 if (!enic->vf_state)
2863 2863 return -ENOMEM;
2864 2864
@@ -2946,7 +2946,7 @@ enic_sriov_configure(struct pci_dev *pdev, int num_vfs)
2946 2946 if (enic->vf_type == ENIC_VF_TYPE_V2)
2947 2947 return enic_sriov_v2_enable(enic, num_vfs);
2948 2948
2949 - pp = kzalloc_objs(*pp, num_vfs);
2949 + pp = kcalloc(num_vfs, sizeof(*pp), GFP_KERNEL);
2950 2950 if (!pp)
2951 2951 return -ENOMEM;
2952 2952
@@ -2971,7 +2971,7 @@ enic_sriov_configure(struct pci_dev *pdev, int num_vfs)
2971 2971 return 0;
2972 2972 }
2973 2973
2974 - pp = kzalloc_obj(*enic->pp);
2974 + pp = kzalloc_obj(*enic->pp, GFP_KERNEL);
2975 2975 if (!pp)
2976 2976 return -ENOMEM;
2977 2977
modified drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c
@@ -616,7 +616,7 @@ static int dpaa2_switch_lag_fdb_add(struct dpaa2_switch_lag *lag,
616 616 goto out;
617 617 }
618 618
619 - a = kzalloc_obj(*a);
619 + a = kzalloc(sizeof(*a), GFP_KERNEL);
620 620 if (!a) {
621 621 err = -ENOMEM;
622 622 goto out;
@@ -4131,7 +4131,8 @@ static int dpaa2_switch_probe(struct fsl_mc_device *sw_dev)
4131 4131 goto err_free_fdbs;
4132 4132 }
4133 4133
4134 - ethsw->lags = kzalloc_objs(*ethsw->lags, ethsw->sw_attr.num_ifs);
4134 + ethsw->lags = kcalloc(ethsw->sw_attr.num_ifs, sizeof(*ethsw->lags),
4135 + GFP_KERNEL);
4135 4136 if (!ethsw->lags) {
4136 4137 err = -ENOMEM;
4137 4138 goto err_free_filter;
modified drivers/net/ethernet/intel/libie/controlq.c
@@ -157,7 +157,8 @@ static void libie_ctlq_free_tx_msgs(struct libie_ctlq_info *ctlq,
157 157 */
158 158 static int libie_ctlq_alloc_tx_msgs(struct libie_ctlq_info *ctlq)
159 159 {
160 - ctlq->tx_msg = kvzalloc_objs(*ctlq->tx_msg, ctlq->ring_len);
160 + ctlq->tx_msg = kvzalloc_objs(*ctlq->tx_msg, ctlq->ring_len,
161 + GFP_KERNEL);
161 162 if (!ctlq->tx_msg)
162 163 return -ENOMEM;
163 164
modified drivers/net/ethernet/marvell/octeontx2/af/cn20k/npc.c
@@ -3647,7 +3647,7 @@ static int npc_defrag_add_2_show_list(struct rvu *rvu, u16 old_midx,
3647 3647 {
3648 3648 struct npc_defrag_show_node *node;
3649 3649
3650 - node = kzalloc_objs(*node, 1);
3650 + node = kcalloc(1, sizeof(*node), GFP_KERNEL);
3651 3651 if (!node)
3652 3652 return -ENOMEM;
3653 3653
@@ -4082,7 +4082,7 @@ int npc_cn20k_defrag(struct rvu *rvu)
4082 4082 INIT_LIST_HEAD(&x4lh);
4083 4083 INIT_LIST_HEAD(&x2lh);
4084 4084
4085 - node = kzalloc_objs(*node, npc_priv->num_subbanks);
4085 + node = kcalloc(npc_priv->num_subbanks, sizeof(*node), GFP_KERNEL);
4086 4086 if (!node)
4087 4087 return -ENOMEM;
4088 4088
@@ -4711,7 +4711,7 @@ static int npc_priv_init(struct rvu *rvu)
4711 4711 return -EINVAL;
4712 4712 }
4713 4713
4714 - npc_priv = kzalloc_objs(*npc_priv, 1);
4714 + npc_priv = kcalloc(1, sizeof(*npc_priv), GFP_KERNEL);
4715 4715 if (!npc_priv)
4716 4716 return -ENOMEM;
4717 4717
@@ -4729,7 +4729,8 @@ static int npc_priv_init(struct rvu *rvu)
4729 4729 num_banks, bank_depth, num_subbanks, subbank_depth,
4730 4730 npc_kw_name[npc_priv->kw]);
4731 4731
4732 - npc_priv->sb = kzalloc_objs(struct npc_subbank, num_subbanks);
4732 + npc_priv->sb = kcalloc(num_subbanks, sizeof(struct npc_subbank),
4733 + GFP_KERNEL);
4733 4734 if (!npc_priv->sb)
4734 4735 goto fail1;
4735 4736
@@ -4756,7 +4757,9 @@ static int npc_priv_init(struct rvu *rvu)
4756 4757
4757 4758 /* Get number of pcifuncs in the system */
4758 4759 npc_priv->pf_cnt = npc_pcifunc_map_create(rvu);
4759 - npc_priv->xa_pf2idx_map = kzalloc_objs(struct xarray, npc_priv->pf_cnt);
4760 + npc_priv->xa_pf2idx_map = kcalloc(npc_priv->pf_cnt,
4761 + sizeof(struct xarray),
4762 + GFP_KERNEL);
4760 4763 if (!npc_priv->xa_pf2idx_map) {
4761 4764 ret = -ENOMEM;
4762 4765 goto fail3;
modified drivers/net/ethernet/marvell/octeontx2/af/rvu.c
@@ -3468,8 +3468,6 @@ err:
3468 3468 return ret;
3469 3469 }
3470 3470
3471 - #define PCI_DEVID_OCTEONTX2_RVU_AFVF 0xA0F8
3472 -
3473 3471 static int rvu_enable_sriov(struct rvu *rvu)
3474 3472 {
3475 3473 struct pci_dev *pdev = rvu->pdev;
@@ -3488,27 +3486,24 @@ static int rvu_enable_sriov(struct rvu *rvu)
3488 3486 return 0;
3489 3487 pci_read_config_word(pdev, pos + PCI_SRIOV_VF_DID, &rvu->vf_devid);
3490 3488
3489 + chans = rvu_get_num_lbk_chans();
3490 + if (chans < 0)
3491 + return chans;
3492 +
3491 3493 vfs = pci_sriov_get_totalvfs(pdev);
3492 - if (!vfs)
3493 - return 0;
3494 3494
3495 - if (rvu->vf_devid == PCI_DEVID_OCTEONTX2_RVU_AFVF) {
3496 - chans = rvu_get_num_lbk_chans();
3497 - if (chans < 0)
3498 - return chans;
3495 + /* Limit VFs in case we have more VFs than LBK channels available. */
3496 + if (vfs > chans)
3497 + vfs = chans;
3499 3498
3500 - /* The last LBK channel is reserved for switching packets between
3501 - * CGX mapped VFs. Also, since LBK VFs work in pairs, limit VF
3502 - * count to available LBK channels minus 2.
3503 - */
3504 - vfs = min(vfs, chans - 2);
3499 + if (!vfs)
3500 + return 0;
3505 3501
3506 - if (vfs <= 0) {
3507 - dev_warn(&pdev->dev,
3508 - "Skipping SRIOV enablement, not enough LBK channels available\n");
3509 - return 0;
3510 - }
3511 - }
3502 + /* LBK channel number 63 is used for switching packets between
3503 + * CGX mapped VFs. Hence limit LBK pairs till 62 only.
3504 + */
3505 + if (vfs > 62)
3506 + vfs = 62;
3512 3507
3513 3508 /* Save VFs number for reference in VF interrupts handlers.
3514 3509 * Since interrupts might start arriving during SRIOV enablement
modified drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c
@@ -2957,9 +2957,10 @@ static void npc_mcam_free_all_entries(struct rvu *rvu, struct npc_mcam *mcam,
2957 2957 }
2958 2958 }
2959 2959
2960 + /* Disable the entry */
2961 + npc_enable_mcam_entry(rvu, mcam, blkaddr, index, false);
2962 +
2960 2963 if (!cn20k_dft_rl) {
2961 - /* Disable the entry */
2962 - npc_enable_mcam_entry(rvu, mcam, blkaddr, index, false);
2963 2964 mcam->entry2pfvf_map[index] = NPC_MCAM_INVALID_MAP;
2964 2965 /* Free the entry in bitmap */
2965 2966 npc_mcam_clear_bit(mcam, index);
modified drivers/net/ethernet/mellanox/mlx5/core/en/xsk/rx.c
@@ -3,7 +3,6 @@
3 3
4 4 #include "rx.h"
5 5 #include "en/xdp.h"
6 - #include <linux/bitmap.h>
7 6 #include <net/xdp_sock_drv.h>
8 7 #include <linux/filter.h>
9 8
@@ -157,7 +156,6 @@ err_reuse_batch:
157 156 xsk_buff_free(xsk_buffs[batch]);
158 157
159 158 err:
160 - bitmap_fill(wi->skip_release_bitmap, rq->mpwqe.pages_per_wqe);
161 159 rq->stats->buff_alloc_err++;
162 160 return -ENOMEM;
163 161 }
modified drivers/net/ethernet/mellanox/mlx5/core/en_rx.c
@@ -410,11 +410,8 @@ static inline void mlx5e_free_rx_wqe(struct mlx5e_rq *rq,
410 410
411 411 static void mlx5e_xsk_free_rx_wqe(struct mlx5e_wqe_frag_info *wi)
412 412 {
413 - if (wi->flags & BIT(MLX5E_WQE_FRAG_SKIP_RELEASE))
414 - return;
415 -
416 - xsk_buff_free(*wi->xskp);
417 - wi->flags |= BIT(MLX5E_WQE_FRAG_SKIP_RELEASE);
413 + if (!(wi->flags & BIT(MLX5E_WQE_FRAG_SKIP_RELEASE)))
414 + xsk_buff_free(*wi->xskp);
418 415 }
419 416
420 417 static void mlx5e_dealloc_rx_wqe(struct mlx5e_rq *rq, u16 ix)
modified drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -2288,7 +2288,8 @@ static int mlx5_esw_spfs_init(struct mlx5_eswitch *esw)
2288 2288 if (!num_entries)
2289 2289 goto out_free;
2290 2290
2291 - esw_funcs->spfs = kzalloc_objs(*esw_funcs->spfs, num_entries);
2291 + esw_funcs->spfs = kcalloc(num_entries, sizeof(*esw_funcs->spfs),
2292 + GFP_KERNEL);
2292 2293 if (!esw_funcs->spfs) {
2293 2294 err = -ENOMEM;
2294 2295 goto out_free;
modified drivers/net/ethernet/mellanox/mlx5/core/eswitch_offloads.c
@@ -1524,7 +1524,7 @@ struct mlx5_flow_handle *
1524 1524 mlx5_esw_lag_demux_rule_create(struct mlx5_eswitch *esw, u16 vport_num,
1525 1525 struct mlx5_flow_table *lag_ft)
1526 1526 {
1527 - struct mlx5_flow_spec *spec = kvzalloc_obj(*spec);
1527 + struct mlx5_flow_spec *spec = kvzalloc(sizeof(*spec), GFP_KERNEL);
1528 1528 struct mlx5_flow_destination dest = {};
1529 1529 struct mlx5_flow_act flow_act = {};
1530 1530 struct mlx5_flow_handle *ret;
modified drivers/net/ethernet/mellanox/mlx5/core/sf/hw_table.c
@@ -317,7 +317,7 @@ int mlx5_sf_hw_table_init(struct mlx5_core_dev *dev)
317 317
318 318 num_spfs = mlx5_esw_get_num_spfs(dev);
319 319 num_hwc = MLX5_SF_HWC_FIRST_SPF + num_spfs;
320 - table->hwc = kzalloc_objs(*table->hwc, num_hwc);
320 + table->hwc = kcalloc(num_hwc, sizeof(*table->hwc), GFP_KERNEL);
321 321 if (!table->hwc) {
322 322 err = -ENOMEM;
323 323 goto hwc_alloc_err;
modified drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_icm_pool.c
@@ -239,7 +239,7 @@ static int dr_icm_buddy_init_ste_cache(struct mlx5dr_icm_buddy_mem *buddy)
239 239 if (!buddy->hw_ste_arr)
240 240 goto free_ste_arr;
241 241
242 - buddy->miss_list = kvmalloc_objs(struct list_head, num_of_entries);
242 + buddy->miss_list = kvmalloc_array(num_of_entries, sizeof(struct list_head), GFP_KERNEL);
243 243 if (!buddy->miss_list)
244 244 goto free_hw_ste_arr;
245 245
modified drivers/net/ethernet/meta/fbnic/fbnic_irq.c
@@ -282,7 +282,7 @@ enum fbnic_msix_self_test_codes fbnic_msix_test(struct fbnic_dev *fbd)
282 282 int i;
283 283
284 284 /* Allocate bitmap and IRQ vector table */
285 - test_data = kzalloc_obj(*test_data);
285 + test_data = kzalloc_obj(*test_data, GFP_KERNEL);
286 286
287 287 /* memory allocation failure */
288 288 if (!test_data)
modified drivers/net/ethernet/microsoft/mana/gdma_main.c
@@ -429,11 +429,11 @@ int mana_gd_alloc_memory(struct gdma_context *gc, unsigned int length,
429 429 /* length is a power of 2 above PAGE_SIZE, so this divides exactly. */
430 430 npages = length / PAGE_SIZE;
431 431
432 - gmi->pages_va = kvzalloc_objs(*gmi->pages_va, npages);
432 + gmi->pages_va = kvcalloc(npages, sizeof(*gmi->pages_va), GFP_KERNEL);
433 433 if (!gmi->pages_va)
434 434 return -ENOMEM;
435 435
436 - gmi->pages_dma = kvzalloc_objs(*gmi->pages_dma, npages);
436 + gmi->pages_dma = kvcalloc(npages, sizeof(*gmi->pages_dma), GFP_KERNEL);
437 437 if (!gmi->pages_dma)
438 438 goto free_va;
439 439
@@ -825,7 +825,7 @@ int mana_schedule_serv_work(struct gdma_context *gc, enum gdma_eqe_type type)
825 825 return -ENODEV;
826 826 }
827 827
828 - mns_wk = kzalloc_obj(*mns_wk, GFP_ATOMIC);
828 + mns_wk = kzalloc(sizeof(*mns_wk), GFP_ATOMIC);
829 829 if (!mns_wk) {
830 830 module_put(THIS_MODULE);
831 831 clear_bit(GC_IN_SERVICE, &gc->flags);
@@ -1991,7 +1991,7 @@ struct gdma_irq_context *mana_gd_get_gic(struct gdma_context *gc,
1991 1991 *msi_requested = msi;
1992 1992 }
1993 1993
1994 - gic = kzalloc_obj(*gic);
1994 + gic = kzalloc(sizeof(*gic), GFP_KERNEL);
1995 1995 if (!gic) {
1996 1996 gic = ERR_PTR(-ENOMEM);
1997 1997 if (irq_map.virq)
modified drivers/net/ethernet/oa_tc6.c
@@ -83,7 +83,7 @@ struct oa_tc6 {
83 83 u16 spi_data_tx_buf_offset;
84 84 u16 tx_credits;
85 85 u8 rx_chunks_available;
86 - bool wait_until_start_valid;
86 + bool rx_buf_overflow;
87 87 bool int_flag;
88 88 bool disable_traffic;
89 89 bool prot_ctrl;
@@ -455,7 +455,7 @@ static int oa_tc6_mdiobus_read(struct mii_bus *bus, int addr, int regnum)
455 455 {
456 456 struct oa_tc6 *tc6 = bus->priv;
457 457 u32 regval;
458 - int ret;
458 + bool ret;
459 459
460 460 ret = oa_tc6_read_register(tc6, OA_TC6_PHY_STD_REG_ADDR_BASE |
461 461 (regnum & OA_TC6_PHY_STD_REG_ADDR_MASK),
@@ -693,26 +693,6 @@ static int oa_tc6_enable_data_transfer(struct oa_tc6 *tc6)
693 693 return oa_tc6_write_register(tc6, OA_TC6_REG_CONFIG0, value);
694 694 }
695 695
696 - /* Called when a frame that is meant to be transmitted, is dropped. */
697 - static void oa_tc6_drop_tx_skb(struct oa_tc6 *tc6, struct sk_buff *skb)
698 - {
699 - if (skb) {
700 - tc6->netdev->stats.tx_dropped++;
701 - dev_kfree_skb_any(skb);
702 - }
703 - }
704 -
705 - static struct sk_buff *oa_tc6_detach_waiting_tx_skb(struct oa_tc6 *tc6)
706 - {
707 - struct sk_buff *skb;
708 -
709 - lockdep_assert_held(&tc6->tx_skb_lock);
710 - skb = tc6->waiting_tx_skb;
711 - tc6->waiting_tx_skb = NULL;
712 -
713 - return skb;
714 - }
715 -
716 696 static void oa_tc6_cleanup_ongoing_rx_skb(struct oa_tc6 *tc6)
717 697 {
718 698 if (tc6->rx_skb) {
@@ -724,39 +704,29 @@ static void oa_tc6_cleanup_ongoing_rx_skb(struct oa_tc6 *tc6)
724 704
725 705 static void oa_tc6_cleanup_ongoing_tx_skb(struct oa_tc6 *tc6)
726 706 {
727 - oa_tc6_drop_tx_skb(tc6, tc6->ongoing_tx_skb);
728 - tc6->ongoing_tx_skb = NULL;
707 + if (tc6->ongoing_tx_skb) {
708 + tc6->netdev->stats.tx_dropped++;
709 + kfree_skb(tc6->ongoing_tx_skb);
710 + tc6->ongoing_tx_skb = NULL;
711 + }
729 712 }
730 713
731 714 static void oa_tc6_cleanup_waiting_tx_skb(struct oa_tc6 *tc6)
732 715 {
733 - struct sk_buff *skb;
734 -
735 - spin_lock_bh(&tc6->tx_skb_lock);
736 - skb = oa_tc6_detach_waiting_tx_skb(tc6);
737 - spin_unlock_bh(&tc6->tx_skb_lock);
738 -
739 - oa_tc6_drop_tx_skb(tc6, skb);
716 + if (tc6->waiting_tx_skb) {
717 + tc6->netdev->stats.tx_dropped++;
718 + kfree_skb(tc6->waiting_tx_skb);
719 + tc6->waiting_tx_skb = NULL;
720 + }
740 721 }
741 722
742 - static void oa_tc6_free_ongoing_skbs(struct oa_tc6 *tc6)
723 + static void oa_tc6_free_pending_skbs(struct oa_tc6 *tc6)
743 724 {
744 725 oa_tc6_cleanup_ongoing_tx_skb(tc6);
745 726 oa_tc6_cleanup_ongoing_rx_skb(tc6);
746 - }
747 -
748 - static void oa_tc6_free_pending_skbs(struct oa_tc6 *tc6)
749 - {
750 - oa_tc6_free_ongoing_skbs(tc6);
751 727 oa_tc6_cleanup_waiting_tx_skb(tc6);
752 728 }
753 729
754 - static void oa_tc6_look_for_new_frame(struct oa_tc6 *tc6)
755 - {
756 - tc6->wait_until_start_valid = true;
757 - oa_tc6_cleanup_ongoing_rx_skb(tc6);
758 - }
759 -
760 730 /* If the failure is at SPI interface level, masking and clearing
761 731 * the interrupt of the device won't work. Since SPI interrupt is
762 732 * disabled, it should stop the repeated interrupts.
@@ -764,19 +734,9 @@ static void oa_tc6_look_for_new_frame(struct oa_tc6 *tc6)
764 734 static void oa_tc6_disable_traffic(struct oa_tc6 *tc6)
765 735 {
766 736 u32 regval = OA_TC6_INT_MASK0_ALL_INTERRUPTS;
767 - struct sk_buff *skb;
768 737
769 - spin_lock_bh(&tc6->tx_skb_lock);
770 738 tc6->disable_traffic = true;
771 - skb = oa_tc6_detach_waiting_tx_skb(tc6);
772 - spin_unlock_bh(&tc6->tx_skb_lock);
773 -
774 - /* disable_traffic, when set, is a point of no return to
775 - * working state. Keeping the TX queues disabled.
776 - */
777 - netif_tx_disable(tc6->netdev);
778 - oa_tc6_drop_tx_skb(tc6, skb);
779 - oa_tc6_free_ongoing_skbs(tc6);
739 + oa_tc6_free_pending_skbs(tc6);
780 740 oa_tc6_write_register(tc6, OA_TC6_REG_INT_MASK0, regval);
781 741 oa_tc6_read_register(tc6, OA_TC6_REG_STATUS0, &regval);
782 742 oa_tc6_write_register(tc6, OA_TC6_REG_STATUS0, regval);
@@ -795,13 +755,6 @@ static int oa_tc6_process_extended_status(struct oa_tc6 *tc6)
795 755 return ret;
796 756 }
797 757
798 - /* This function is called for each chunk received in a given SPI
799 - * transaction. In case, extended status bit is set in more than
800 - * one chunk, skip the write, if status0 is already cleared.
801 - */
802 - if (!value)
803 - return 0;
804 -
805 758 /* Clear the error interrupts status */
806 759 ret = oa_tc6_write_register(tc6, OA_TC6_REG_STATUS0, value);
807 760 if (ret) {
@@ -811,7 +764,8 @@ static int oa_tc6_process_extended_status(struct oa_tc6 *tc6)
811 764 }
812 765
813 766 if (FIELD_GET(OA_TC6_STATUS0_RX_BUFFER_OVERFLOW_ERROR, value)) {
814 - oa_tc6_look_for_new_frame(tc6);
767 + tc6->rx_buf_overflow = true;
768 + oa_tc6_cleanup_ongoing_rx_skb(tc6);
815 769 net_err_ratelimited("%s: Receive buffer overflow error\n",
816 770 tc6->netdev->name);
817 771 return -EAGAIN;
@@ -837,8 +791,6 @@ static int oa_tc6_process_extended_status(struct oa_tc6 *tc6)
837 791
838 792 static int oa_tc6_process_rx_chunk_footer(struct oa_tc6 *tc6, u32 footer)
839 793 {
840 - int ret = 0;
841 -
842 794 /* Process rx chunk footer for the following,
843 795 * 1. tx credits
844 796 * 2. errors if any from MAC-PHY
@@ -849,11 +801,9 @@ static int oa_tc6_process_rx_chunk_footer(struct oa_tc6 *tc6, u32 footer)
849 801 footer);
850 802
851 803 if (FIELD_GET(OA_TC6_DATA_FOOTER_EXTENDED_STS, footer)) {
852 - ret = oa_tc6_process_extended_status(tc6);
853 - /* EAGAIN error is recoverable. Move on to check
854 - * HEADER and SYNC errors before returning.
855 - */
856 - if (ret && ret != -EAGAIN)
804 + int ret = oa_tc6_process_extended_status(tc6);
805 +
806 + if (ret)
857 807 return ret;
858 808 }
859 809
@@ -871,7 +821,7 @@ static int oa_tc6_process_rx_chunk_footer(struct oa_tc6 *tc6, u32 footer)
871 821 return -ENODEV;
872 822 }
873 823
874 - return ret;
824 + return 0;
875 825 }
876 826
877 827 static void oa_tc6_submit_rx_skb(struct oa_tc6 *tc6)
@@ -896,35 +846,13 @@ static void oa_tc6_submit_rx_skb(struct oa_tc6 *tc6)
896 846 tc6->rx_skb = NULL;
897 847 }
898 848
899 - /* On oversubscribed traffic condition, particularly with overwhelming rx
900 - * buffer overflow errors, there could be data chunk loss. If tail + length
901 - * goes beyond end pointer, that is an indication that the data chunk with
902 - * end_valid bit is lost. Time to look for a data chunk with start_valid bit.
903 - *
904 - * If rx_skb is NULL, it is time to start looking for data chunk with
905 - * start_bit.
906 - */
907 - static int oa_tc6_update_rx_skb(struct oa_tc6 *tc6, u8 *payload, u8 length)
849 + static void oa_tc6_update_rx_skb(struct oa_tc6 *tc6, u8 *payload, u8 length)
908 850 {
909 - if (!tc6->rx_skb ||
910 - skb_tailroom(tc6->rx_skb) < length) {
911 - oa_tc6_look_for_new_frame(tc6);
912 - return -EAGAIN;
913 - }
914 -
915 851 memcpy(skb_put(tc6->rx_skb, length), payload, length);
916 - return 0;
917 852 }
918 853
919 - /* On overwhelming rx buffer overflow errors, due to data chunk loss, it is
920 - * possible that we get two data chunks with start_valid bit set, without
921 - * end_valid bit set in between. In this case, rx_skb would have a valid
922 - * buffer pointer. We should release, if a valid pointer is found before
923 - * allocating a new one.
924 - */
925 854 static int oa_tc6_allocate_rx_skb(struct oa_tc6 *tc6)
926 855 {
927 - oa_tc6_cleanup_ongoing_rx_skb(tc6);
928 856 tc6->rx_skb = netdev_alloc_skb_ip_align(tc6->netdev, tc6->netdev->mtu +
929 857 ETH_HLEN + ETH_FCS_LEN);
930 858 if (!tc6->rx_skb) {
@@ -944,9 +872,7 @@ static int oa_tc6_prcs_complete_rx_frame(struct oa_tc6 *tc6, u8 *payload,
944 872 if (ret)
945 873 return ret;
946 874
947 - ret = oa_tc6_update_rx_skb(tc6, payload, size);
948 - if (ret)
949 - return ret;
875 + oa_tc6_update_rx_skb(tc6, payload, size);
950 876
951 877 oa_tc6_submit_rx_skb(tc6);
952 878
@@ -961,24 +887,22 @@ static int oa_tc6_prcs_rx_frame_start(struct oa_tc6 *tc6, u8 *payload, u16 size)
961 887 if (ret)
962 888 return ret;
963 889
964 - return oa_tc6_update_rx_skb(tc6, payload, size);
890 + oa_tc6_update_rx_skb(tc6, payload, size);
891 +
892 + return 0;
965 893 }
966 894
967 - static int oa_tc6_prcs_rx_frame_end(struct oa_tc6 *tc6, u8 *payload, u16 size)
895 + static void oa_tc6_prcs_rx_frame_end(struct oa_tc6 *tc6, u8 *payload, u16 size)
968 896 {
969 - int ret;
897 + oa_tc6_update_rx_skb(tc6, payload, size);
970 898
971 - ret = oa_tc6_update_rx_skb(tc6, payload, size);
972 - if (!ret)
973 - oa_tc6_submit_rx_skb(tc6);
974 - return ret;
899 + oa_tc6_submit_rx_skb(tc6);
975 900 }
976 901
977 - static int oa_tc6_prcs_ongoing_rx_frame(struct oa_tc6 *tc6, u8 *payload,
978 - u32 footer)
902 + static void oa_tc6_prcs_ongoing_rx_frame(struct oa_tc6 *tc6, u8 *payload,
903 + u32 footer)
979 904 {
980 - return oa_tc6_update_rx_skb(tc6, payload,
981 - OA_TC6_CHUNK_PAYLOAD_SIZE);
905 + oa_tc6_update_rx_skb(tc6, payload, OA_TC6_CHUNK_PAYLOAD_SIZE);
982 906 }
983 907
984 908 static int oa_tc6_prcs_rx_chunk_payload(struct oa_tc6 *tc6, u8 *data,
@@ -993,10 +917,10 @@ static int oa_tc6_prcs_rx_chunk_payload(struct oa_tc6 *tc6, u8 *data,
993 917 u16 size;
994 918
995 919 /* Restart the new rx frame after receiving rx buffer overflow error */
996 - if (start_valid && tc6->wait_until_start_valid)
997 - tc6->wait_until_start_valid = false;
920 + if (start_valid && tc6->rx_buf_overflow)
921 + tc6->rx_buf_overflow = false;
998 922
999 - if (tc6->wait_until_start_valid)
923 + if (tc6->rx_buf_overflow)
1000 924 return 0;
1001 925
1002 926 /* Process the chunk with complete rx frame */
@@ -1018,7 +942,8 @@ static int oa_tc6_prcs_rx_chunk_payload(struct oa_tc6 *tc6, u8 *data,
1018 942 /* Process the chunk with only rx frame end */
1019 943 if (end_valid && !start_valid) {
1020 944 size = end_byte_offset + 1;
1021 - return oa_tc6_prcs_rx_frame_end(tc6, data, size);
945 + oa_tc6_prcs_rx_frame_end(tc6, data, size);
946 + return 0;
1022 947 }
1023 948
1024 949 /* Process the chunk with previous rx frame end and next rx frame
@@ -1032,15 +957,6 @@ static int oa_tc6_prcs_rx_chunk_payload(struct oa_tc6 *tc6, u8 *data,
1032 957 if (tc6->rx_skb) {
1033 958 size = end_byte_offset + 1;
1034 959 oa_tc6_prcs_rx_frame_end(tc6, data, size);
1035 -
1036 - /* Return value from oa_tc6_prcs_rx_frame_end is not
1037 - * checked. If it returned an error, it is to make
1038 - * the code to look for new frame. At this stage,
1039 - * code below is going to process a new frame. So,
1040 - * error condition is set to false, in case it is
1041 - * set before proceeding.
1042 - */
1043 - tc6->wait_until_start_valid = false;
1044 960 }
1045 961 size = OA_TC6_CHUNK_PAYLOAD_SIZE - start_byte_offset;
1046 962 return oa_tc6_prcs_rx_frame_start(tc6,
@@ -1049,7 +965,9 @@ static int oa_tc6_prcs_rx_chunk_payload(struct oa_tc6 *tc6, u8 *data,
1049 965 }
1050 966
1051 967 /* Process the chunk with ongoing rx frame data */
1052 - return oa_tc6_prcs_ongoing_rx_frame(tc6, data, footer);
968 + oa_tc6_prcs_ongoing_rx_frame(tc6, data, footer);
969 +
970 + return 0;
1053 971 }
1054 972
1055 973 static u32 oa_tc6_get_rx_chunk_footer(struct oa_tc6 *tc6, u16 footer_offset)
@@ -1065,9 +983,8 @@ static u32 oa_tc6_get_rx_chunk_footer(struct oa_tc6 *tc6, u16 footer_offset)
1065 983 static int oa_tc6_process_spi_data_rx_buf(struct oa_tc6 *tc6, u16 length)
1066 984 {
1067 985 u16 no_of_rx_chunks = length / OA_TC6_CHUNK_SIZE;
1068 - bool retry = false;
1069 - int ret = 0;
1070 986 u32 footer;
987 + int ret;
1071 988
1072 989 /* All the rx chunks in the receive SPI data buffer are examined here */
1073 990 for (int i = 0; i < no_of_rx_chunks; i++) {
@@ -1076,11 +993,8 @@ static int oa_tc6_process_spi_data_rx_buf(struct oa_tc6 *tc6, u16 length)
1076 993 OA_TC6_CHUNK_PAYLOAD_SIZE);
1077 994
1078 995 ret = oa_tc6_process_rx_chunk_footer(tc6, footer);
1079 - if (ret) {
1080 - if (ret != -EAGAIN)
1081 - return ret;
1082 - retry = true;
1083 - }
996 + if (ret)
997 + return ret;
1084 998
1085 999 /* If there is a data valid chunks then process it for the
1086 1000 * information needed to determine the validity and the location
@@ -1092,35 +1006,12 @@ static int oa_tc6_process_spi_data_rx_buf(struct oa_tc6 *tc6, u16 length)
1092 1006
1093 1007 ret = oa_tc6_prcs_rx_chunk_payload(tc6, payload,
1094 1008 footer);
1095 - if (ret) {
1096 - if (ret != -ENOMEM && ret != -EAGAIN)
1097 - return ret;
1098 - retry = true;
1099 - }
1009 + if (ret)
1010 + return ret;
1100 1011 }
1101 1012 }
1102 1013
1103 - /* Not bailing out on recoverable error codes, -EAGAIN and
1104 - * -ENOMEM. If subsequent loop iterations, if any, succeeds,
1105 - * error code would be overwritten. retry flag helps to
1106 - * make the caller to continue and retry. Since recovery
1107 - * action for -ENOMEM and -EAGAIN are same, we are returning
1108 - * one of the error codes, that is -EAGAIN.
1109 - *
1110 - * Successful recovery depends on how small the frames are,
1111 - * how many chunks, among the received chunks triggered the
1112 - * error, whether data is intact even with error conditions.
1113 - * As a result, there is no single, best method to recover
1114 - * most data when error conditions hit. We do our best by
1115 - * processing all the chunks with good "footer header" and
1116 - * "data valid" bit set.
1117 - */
1118 - if (retry) {
1119 - ret = -EAGAIN;
1120 - oa_tc6_look_for_new_frame(tc6);
1121 - }
1122 -
1123 - return ret;
1014 + return 0;
1124 1015 }
1125 1016
1126 1017 static __be32 oa_tc6_prepare_data_header(bool data_valid, bool start_valid,
@@ -1282,9 +1173,12 @@ static int oa_tc6_try_spi_transfer(struct oa_tc6 *tc6)
1282 1173 }
1283 1174
1284 1175 ret = oa_tc6_process_spi_data_rx_buf(tc6, spi_len);
1176 + if (ret) {
1177 + if (ret == -EAGAIN)
1178 + continue;
1285 1179
1286 - if (ret && ret != -EAGAIN) {
1287 - oa_tc6_free_ongoing_skbs(tc6);
1180 + oa_tc6_cleanup_ongoing_tx_skb(tc6);
1181 + oa_tc6_cleanup_ongoing_rx_skb(tc6);
1288 1182 netdev_err(tc6->netdev, "Device error: %d\n", ret);
1289 1183 return ret;
1290 1184 }
@@ -1306,20 +1200,15 @@ static irqreturn_t oa_tc6_macphy_threaded_irq(int irq, void *data)
1306 1200 * no need to attempt spi transfer, once it fails. Pending skbs
1307 1201 * are already freed.
1308 1202 */
1309 - spin_lock_bh(&tc6->tx_skb_lock);
1310 - if (tc6->disable_traffic) {
1311 - spin_unlock_bh(&tc6->tx_skb_lock);
1312 - return IRQ_HANDLED;
1313 - }
1314 - spin_unlock_bh(&tc6->tx_skb_lock);
1315 -
1316 - while (tc6->int_flag ||
1317 - (tc6->waiting_tx_skb && tc6->tx_credits)) {
1318 - ret = oa_tc6_try_spi_transfer(tc6);
1319 - if (ret) {
1320 - disable_irq_nosync(tc6->spi->irq);
1321 - oa_tc6_disable_traffic(tc6);
1322 - break;
1203 + if (!tc6->disable_traffic) {
1204 + while (tc6->int_flag ||
1205 + (tc6->waiting_tx_skb && tc6->tx_credits)) {
1206 + ret = oa_tc6_try_spi_transfer(tc6);
1207 + if (ret) {
1208 + disable_irq_nosync(tc6->spi->irq);
1209 + oa_tc6_disable_traffic(tc6);
1210 + break;
1211 + }
1323 1212 }
1324 1213 }
1325 1214
@@ -1398,30 +1287,23 @@ EXPORT_SYMBOL_GPL(oa_tc6_zero_align_receive_frame_enable);
1398 1287 * @tc6: oa_tc6 struct.
1399 1288 * @skb: socket buffer in which the ethernet frame is stored.
1400 1289 *
1401 - * Return: NETDEV_TX_OK either on successful queueing of the packet for
1402 - * transmission, or on packet getting dropped. Packet can be dropped due to
1403 - * failure in linearizing the buffer or disable_traffic is set due to
1404 - * earlier fatal error. Returns NETDEV_TX_BUSY when there is no room
1405 - * to queue the packet.
1290 + * Return: NETDEV_TX_OK if the transmit ethernet frame skb added in the tx_skb_q
1291 + * otherwise returns NETDEV_TX_BUSY.
1406 1292 */
1407 1293 netdev_tx_t oa_tc6_start_xmit(struct oa_tc6 *tc6, struct sk_buff *skb)
1408 1294 {
1409 - if (skb_linearize(skb)) {
1410 - oa_tc6_drop_tx_skb(tc6, skb);
1411 - return NETDEV_TX_OK;
1412 - }
1413 -
1414 - spin_lock_bh(&tc6->tx_skb_lock);
1415 - if (tc6->waiting_tx_skb) {
1295 + if (tc6->disable_traffic || tc6->waiting_tx_skb) {
1416 1296 netif_stop_queue(tc6->netdev);
1417 - spin_unlock_bh(&tc6->tx_skb_lock);
1418 1297 return NETDEV_TX_BUSY;
1419 1298 }
1420 - if (tc6->disable_traffic) {
1421 - spin_unlock_bh(&tc6->tx_skb_lock);
1422 - oa_tc6_drop_tx_skb(tc6, skb);
1299 +
1300 + if (skb_linearize(skb)) {
1301 + dev_kfree_skb_any(skb);
1302 + tc6->netdev->stats.tx_dropped++;
1423 1303 return NETDEV_TX_OK;
1424 1304 }
1305 +
1306 + spin_lock_bh(&tc6->tx_skb_lock);
1425 1307 tc6->waiting_tx_skb = skb;
1426 1308 spin_unlock_bh(&tc6->tx_skb_lock);
1427 1309
@@ -1580,10 +1462,8 @@ EXPORT_SYMBOL_GPL(oa_tc6_init);
1580 1462 */
1581 1463 void oa_tc6_exit(struct oa_tc6 *tc6)
1582 1464 {
1583 - disable_irq(tc6->spi->irq);
1584 - spin_lock_bh(&tc6->tx_skb_lock);
1585 1465 tc6->disable_traffic = true;
1586 - spin_unlock_bh(&tc6->tx_skb_lock);
1466 + disable_irq(tc6->spi->irq);
1587 1467 oa_tc6_phy_exit(tc6);
1588 1468 oa_tc6_free_pending_skbs(tc6);
1589 1469 }
modified drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -3676,14 +3676,6 @@ static int stmmac_hw_setup(struct net_device *dev)
3676 3676 /* Initialize MTL*/
3677 3677 stmmac_mtl_configuration(priv);
3678 3678
3679 - /* Apply the RX packet parser table */
3680 - if (priv->tc_entries) {
3681 - ret = stmmac_rxp_config(priv, priv->hw->pcsr, priv->tc_entries,
3682 - priv->tc_entries_max);
3683 - if (ret)
3684 - return ret;
3685 - }
3686 -
3687 3679 /* Initialize Safety Features */
3688 3680 stmmac_safety_feat_configuration(priv);
3689 3681
@@ -4327,7 +4319,6 @@ static bool stmmac_vlan_insert(struct stmmac_priv *priv, struct sk_buff *skb,
4327 4319 /**
4328 4320 * stmmac_tso_allocator - close entry point of the driver
4329 4321 * @priv: driver private structure
4330 - * @entry: TX queue buffer index
4331 4322 * @des: buffer start address
4332 4323 * @total_len: total length to fill in descriptors
4333 4324 * @last_segment: condition for the last descriptor
@@ -4336,9 +4327,8 @@ static bool stmmac_vlan_insert(struct stmmac_priv *priv, struct sk_buff *skb,
4336 4327 * This function fills descriptor and request new descriptors according to
4337 4328 * buffer length to fill
4338 4329 */
4339 - static void stmmac_tso_allocator(struct stmmac_priv *priv, u32 *entry,
4340 - dma_addr_t des, int total_len,
4341 - bool last_segment, u32 queue)
4330 + static void stmmac_tso_allocator(struct stmmac_priv *priv, dma_addr_t des,
4331 + int total_len, bool last_segment, u32 queue)
4342 4332 {
4343 4333 struct stmmac_tx_queue *tx_q = &priv->dma_conf.tx_queue[queue];
4344 4334 struct dma_desc *desc;
@@ -4350,13 +4340,14 @@ static void stmmac_tso_allocator(struct stmmac_priv *priv, u32 *entry,
4350 4340 while (tmp_len > 0) {
4351 4341 dma_addr_t curr_addr;
4352 4342
4353 - *entry = STMMAC_NEXT_ENTRY(*entry, priv->dma_conf.dma_tx_size);
4354 - WARN_ON(tx_q->tx_skbuff[*entry]);
4343 + tx_q->cur_tx = STMMAC_NEXT_ENTRY(tx_q->cur_tx,
4344 + priv->dma_conf.dma_tx_size);
4345 + WARN_ON(tx_q->tx_skbuff[tx_q->cur_tx]);
4355 4346
4356 4347 if (tx_q->tbs & STMMAC_TBS_AVAIL)
4357 - desc = &tx_q->dma_entx[*entry].basic;
4348 + desc = &tx_q->dma_entx[tx_q->cur_tx].basic;
4358 4349 else
4359 - desc = &tx_q->dma_tx[*entry];
4350 + desc = &tx_q->dma_tx[tx_q->cur_tx];
4360 4351
4361 4352 curr_addr = des + (total_len - tmp_len);
4362 4353 stmmac_set_desc_addr(priv, desc, curr_addr);
@@ -4495,7 +4486,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
4495 4486 {
4496 4487 struct dma_desc *desc, *first, *mss_desc = NULL;
4497 4488 struct stmmac_priv *priv = netdev_priv(dev);
4498 - unsigned int first_entry, entry, tx_packets;
4489 + unsigned int first_entry, tx_packets;
4499 4490 struct stmmac_txq_stats *txq_stats;
4500 4491 struct stmmac_tx_queue *tx_q;
4501 4492 bool set_ic, is_last_segment;
@@ -4558,24 +4549,22 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
4558 4549 }
4559 4550
4560 4551 first_entry = tx_q->cur_tx;
4561 - entry = first_entry;
4562 -
4563 - WARN_ON(tx_q->tx_skbuff[entry]);
4552 + WARN_ON(tx_q->tx_skbuff[first_entry]);
4564 4553
4565 4554 if (tx_q->tbs & STMMAC_TBS_AVAIL)
4566 - desc = &tx_q->dma_entx[entry].basic;
4555 + desc = &tx_q->dma_entx[first_entry].basic;
4567 4556 else
4568 - desc = &tx_q->dma_tx[entry];
4557 + desc = &tx_q->dma_tx[first_entry];
4569 4558 first = desc;
4570 4559
4571 4560 /* first descriptor: fill Headers on Buf1 */
4572 4561 des = dma_map_single(priv->device, skb->data, skb_headlen(skb),
4573 4562 DMA_TO_DEVICE);
4574 4563 if (dma_mapping_error(priv->device, des))
4575 - goto error;
4564 + goto dma_map_err;
4576 4565
4577 4566 stmmac_set_desc_addr(priv, first, des);
4578 - stmmac_tso_allocator(priv, &entry, des + proto_hdr_len, pay_len,
4567 + stmmac_tso_allocator(priv, des + proto_hdr_len, pay_len,
4579 4568 (nfrags == 0), queue);
4580 4569
4581 4570 /* In case two or more DMA transmit descriptors are allocated for this
@@ -4590,7 +4579,8 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
4590 4579 * this DMA buffer right after the DMA engine completely finishes the
4591 4580 * full buffer transmission.
4592 4581 */
4593 - stmmac_set_tx_skb_dma_entry(tx_q, entry, des, skb_headlen(skb), false);
4582 + stmmac_set_tx_skb_dma_entry(tx_q, tx_q->cur_tx, des, skb_headlen(skb),
4583 + false);
4594 4584
4595 4585 /* Prepare fragments */
4596 4586 for (i = 0; i < nfrags; i++) {
@@ -4600,15 +4590,14 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
4600 4590 skb_frag_size(frag),
4601 4591 DMA_TO_DEVICE);
4602 4592 if (dma_mapping_error(priv->device, des))
4603 - goto error_dma_unmap;
4593 + goto dma_map_err;
4604 4594
4605 - stmmac_tso_allocator(priv, &entry, des, skb_frag_size(frag),
4595 + stmmac_tso_allocator(priv, des, skb_frag_size(frag),
4606 4596 (i == nfrags - 1), queue);
4607 4597
4608 - stmmac_set_tx_skb_dma_entry(tx_q, entry, des,
4598 + stmmac_set_tx_skb_dma_entry(tx_q, tx_q->cur_tx, des,
4609 4599 skb_frag_size(frag), true);
4610 4600 }
4611 - tx_q->cur_tx = entry;
4612 4601
4613 4602 stmmac_set_tx_dma_last_segment(tx_q, tx_q->cur_tx);
4614 4603
@@ -4713,19 +4702,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
4713 4702
4714 4703 return NETDEV_TX_OK;
4715 4704
4716 - error_dma_unmap:
4717 - for (;;) {
4718 - desc = stmmac_get_tx_desc(priv, tx_q, first_entry);
4719 - stmmac_release_tx_desc(priv, desc, priv->descriptor_mode);
4720 - stmmac_free_tx_buffer(priv, &priv->dma_conf, queue,
4721 - first_entry);
4722 - if (first_entry == entry)
4723 - break;
4724 -
4725 - first_entry = STMMAC_NEXT_ENTRY(first_entry,
4726 - priv->dma_conf.dma_tx_size);
4727 - }
4728 - error:
4705 + dma_map_err:
4729 4706 dev_err(priv->device, "Tx dma map failed\n");
4730 4707 dev_kfree_skb(skb);
4731 4708 priv->xstats.tx_dropped++;
modified drivers/net/gtp.c
@@ -318,11 +318,6 @@ static int gtp_inner_proto(struct sk_buff *skb, unsigned int hdrlen,
318 318 static int gtp_rx(struct pdp_ctx *pctx, struct sk_buff *skb,
319 319 unsigned int hdrlen, unsigned int role, __u16 inner_proto)
320 320 {
321 - if (skb_is_gso(skb)) {
322 - netdev_dbg(pctx->dev, "GSO is not supported in GTP\n");
323 - goto err;
324 - }
325 -
326 321 if (!gtp_check_ms(skb, pctx, hdrlen, role, inner_proto)) {
327 322 netdev_dbg(pctx->dev, "No PDP ctx for this MS\n");
328 323 return 1;
modified drivers/net/ipvlan/ipvlan_main.c
@@ -848,6 +848,7 @@ static int ipvlan_device_event(struct notifier_block *unused,
848 848 __ipvlan_link_delete(net, ipvlan->dev, &lst_kill);
849 849 }
850 850
851 + unregister_netdevice_many(&lst_kill);
851 852 break;
852 853 }
853 854 case NETDEV_FEAT_CHANGE:
@@ -898,9 +899,6 @@ static int ipvlan_device_event(struct notifier_block *unused,
898 899
899 900 mutex_unlock(&port->pnodes_lock);
900 901
901 - /* Avoid invoking nested netdevice notifiers under pnodes_lock. */
902 - unregister_netdevice_many(&lst_kill);
903 -
904 902 ipvlan_port_put(port);
905 903
906 904 return ret;
modified drivers/net/ntb_netdev.c
@@ -127,10 +127,8 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data,
127 127 {
128 128 struct ntb_netdev_queue *q = qp_data;
129 129 struct ntb_netdev *dev = q->ntdev;
130 - struct pcpu_sw_netstats *tstats;
131 130 struct sk_buff *skb, *new_skb;
132 131 struct net_device *ndev;
133 - unsigned long flags;
134 132 int rc;
135 133
136 134 ndev = dev->ndev;
@@ -141,20 +139,17 @@ static void ntb_netdev_rx_handler(struct ntb_transport_qp *qp, void *qp_data,
141 139 netdev_dbg(ndev, "%s: %d byte payload received\n", __func__, len);
142 140
143 141 if (len < 0) {
144 - DEV_STATS_INC(ndev, rx_errors);
145 - DEV_STATS_INC(ndev, rx_length_errors);
142 + ndev->stats.rx_errors++;
143 + ndev->stats.rx_length_errors++;
146 144 goto enqueue_again;
147 145 }
148 146
149 - tstats = this_cpu_ptr(ndev->tstats);
150 - flags = u64_stats_update_begin_irqsave(&tstats->syncp);
151 - u64_stats_inc(&tstats->rx_packets);
152 - u64_stats_add(&tstats->rx_bytes, len);
153 - u64_stats_update_end_irqrestore(&tstats->syncp, flags);
147 + ndev->stats.rx_packets++;
148 + ndev->stats.rx_bytes += len;
154 149
155 150 new_skb = netdev_alloc_skb(ndev, ndev->mtu + ETH_HLEN);
156 151 if (!new_skb) {
157 - DEV_STATS_INC(ndev, rx_dropped);
152 + ndev->stats.rx_dropped++;
158 153 goto enqueue_again;
159 154 }
160 155
@@ -171,8 +166,8 @@ enqueue_again:
171 166 rc = ntb_transport_rx_enqueue(qp, skb, skb->data, ndev->mtu + ETH_HLEN);
172 167 if (rc) {
173 168 dev_kfree_skb_any(skb);
174 - DEV_STATS_INC(ndev, rx_errors);
175 - DEV_STATS_INC(ndev, rx_fifo_errors);
169 + ndev->stats.rx_errors++;
170 + ndev->stats.rx_fifo_errors++;
176 171 }
177 172 }
178 173
@@ -215,39 +210,25 @@ static void ntb_netdev_tx_handler(struct ntb_transport_qp *qp, void *qp_data,
215 210 {
216 211 struct ntb_netdev_queue *q = qp_data;
217 212 struct ntb_netdev *dev = q->ntdev;
218 - struct pcpu_sw_netstats *tstats;
219 213 struct net_device *ndev;
220 214 struct sk_buff *skb;
221 - unsigned long flags;
222 - bool registered;
223 215
224 216 ndev = dev->ndev;
225 217 skb = data;
226 218 if (!skb || !ndev)
227 219 return;
228 220
229 - rcu_read_lock();
230 - registered = READ_ONCE(ndev->reg_state) == NETREG_REGISTERED;
231 - if (!registered)
232 - goto free_skb;
233 -
234 221 if (len > 0) {
235 - /* The memcpy kthread can migrate, so pin the per-CPU update. */
236 - tstats = get_cpu_ptr(ndev->tstats);
237 - flags = u64_stats_update_begin_irqsave(&tstats->syncp);
238 - u64_stats_inc(&tstats->tx_packets);
239 - u64_stats_add(&tstats->tx_bytes, skb->len);
240 - u64_stats_update_end_irqrestore(&tstats->syncp, flags);
241 - put_cpu_ptr(ndev->tstats);
222 + ndev->stats.tx_packets++;
223 + ndev->stats.tx_bytes += skb->len;
242 224 } else {
243 - DEV_STATS_INC(ndev, tx_errors);
244 - DEV_STATS_INC(ndev, tx_aborted_errors);
225 + ndev->stats.tx_errors++;
226 + ndev->stats.tx_aborted_errors++;
245 227 }
246 228
247 - free_skb:
248 229 dev_kfree_skb_any(skb);
249 230
250 - if (registered && ntb_transport_tx_free_entry(qp) >= tx_start) {
231 + if (ntb_transport_tx_free_entry(qp) >= tx_start) {
251 232 /* Make sure anybody stopping the queue after this sees the new
252 233 * value of ntb_transport_tx_free_entry()
253 234 */
@@ -256,7 +237,6 @@ free_skb:
256 237 ntb_transport_link_query(q->qp))
257 238 netif_wake_subqueue(ndev, q->qid);
258 239 }
259 - rcu_read_unlock();
260 240 }
261 241
262 242 static const struct ntb_queue_handlers ntb_netdev_handlers = {
@@ -297,7 +277,7 @@ static netdev_tx_t ntb_netdev_start_xmit(struct sk_buff *skb,
297 277
298 278 drop:
299 279 dev_kfree_skb_any(skb);
300 - DEV_STATS_INC(ndev, tx_dropped);
280 + ndev->stats.tx_dropped++;
301 281 return NETDEV_TX_OK;
302 282 }
303 283
@@ -659,14 +639,14 @@ static int ntb_netdev_probe(struct device *client_dev)
659 639 dev->client_dev = client_dev;
660 640 dev->num_queues = 0;
661 641
662 - dev->queues = kzalloc_objs(*dev->queues, NTB_NETDEV_MAX_QUEUES);
642 + dev->queues = kzalloc_objs(*dev->queues, NTB_NETDEV_MAX_QUEUES,
643 + GFP_KERNEL);
663 644 if (!dev->queues) {
664 645 rc = -ENOMEM;
665 646 goto err_free_netdev;
666 647 }
667 648
668 649 ndev->features = NETIF_F_HIGHDMA;
669 - ndev->pcpu_stat_type = NETDEV_PCPU_STAT_TSTATS;
670 650
671 651 ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
672 652
modified drivers/net/ppp/ppp_async.c
@@ -63,6 +63,8 @@ struct asyncppp {
63 63
64 64 struct tasklet_struct tsk;
65 65
66 + refcount_t refcnt;
67 + struct completion dead;
66 68 struct ppp_channel chan; /* interface to generic ppp layer */
67 69 unsigned char obuf[OBUFSIZE];
68 70 };
@@ -112,6 +114,38 @@ static const struct ppp_channel_ops async_ops = {
112 114 * Routines implementing the PPP line discipline.
113 115 */
114 116
117 + /*
118 + * We have a potential race on dereferencing tty->disc_data,
119 + * because the tty layer provides no locking at all - thus one
120 + * cpu could be running ppp_asynctty_receive while another
121 + * calls ppp_asynctty_close, which zeroes tty->disc_data and
122 + * frees the memory that ppp_asynctty_receive is using. The best
123 + * way to fix this is to use a rwlock in the tty struct, but for now
124 + * we use a single global rwlock for all ttys in ppp line discipline.
125 + *
126 + * FIXME: this is no longer true. The _close path for the ldisc is
127 + * now guaranteed to be sane.
128 + */
129 + static DEFINE_RWLOCK(disc_data_lock);
130 +
131 + static struct asyncppp *ap_get(struct tty_struct *tty)
132 + {
133 + struct asyncppp *ap;
134 +
135 + read_lock(&disc_data_lock);
136 + ap = tty->disc_data;
137 + if (ap != NULL)
138 + refcount_inc(&ap->refcnt);
139 + read_unlock(&disc_data_lock);
140 + return ap;
141 + }
142 +
143 + static void ap_put(struct asyncppp *ap)
144 + {
145 + if (refcount_dec_and_test(&ap->refcnt))
146 + complete(&ap->dead);
147 + }
148 +
115 149 /*
116 150 * Called when a tty is put into PPP line discipline. Called in process
117 151 * context.
@@ -146,6 +180,9 @@ ppp_asynctty_open(struct tty_struct *tty)
146 180 skb_queue_head_init(&ap->rqueue);
147 181 tasklet_setup(&ap->tsk, ppp_async_process);
148 182
183 + refcount_set(&ap->refcnt, 1);
184 + init_completion(&ap->dead);
185 +
149 186 ap->chan.private = ap;
150 187 ap->chan.ops = &async_ops;
151 188 ap->chan.mtu = PPP_MRU;
@@ -166,18 +203,34 @@ ppp_asynctty_open(struct tty_struct *tty)
166 203 }
167 204
168 205 /*
169 - * Called when the tty is put into another line discipline or it hangs up.
170 - * This call is serialized against other ldisc functions.
206 + * Called when the tty is put into another line discipline
207 + * or it hangs up. We have to wait for any cpu currently
208 + * executing in any of the other ppp_asynctty_* routines to
209 + * finish before we can call ppp_unregister_channel and free
210 + * the asyncppp struct. This routine must be called from
211 + * process context, not interrupt or softirq context.
171 212 */
172 213 static void
173 214 ppp_asynctty_close(struct tty_struct *tty)
174 215 {
175 - struct asyncppp *ap = tty->disc_data;
216 + struct asyncppp *ap;
176 217
218 + write_lock_irq(&disc_data_lock);
219 + ap = tty->disc_data;
220 + tty->disc_data = NULL;
221 + write_unlock_irq(&disc_data_lock);
177 222 if (!ap)
178 223 return;
179 224
180 - tty->disc_data = NULL;
225 + /*
226 + * We have now ensured that nobody can start using ap from now
227 + * on, but we have to wait for all existing users to finish.
228 + * Note that ppp_unregister_channel ensures that no calls to
229 + * our channel ops (i.e. ppp_async_send/ioctl) are in progress
230 + * by the time it returns.
231 + */
232 + if (!refcount_dec_and_test(&ap->refcnt))
233 + wait_for_completion(&ap->dead);
181 234 tasklet_kill(&ap->tsk);
182 235
183 236 ppp_unregister_channel(&ap->chan);
@@ -187,6 +240,17 @@ ppp_asynctty_close(struct tty_struct *tty)
187 240 kfree(ap);
188 241 }
189 242
243 + /*
244 + * Called on tty hangup in process context.
245 + *
246 + * Wait for I/O to driver to complete and unregister PPP channel.
247 + * This is already done by the close routine, so just call that.
248 + */
249 + static void ppp_asynctty_hangup(struct tty_struct *tty)
250 + {
251 + ppp_asynctty_close(tty);
252 + }
253 +
190 254 /*
191 255 * Read does nothing - no data is ever available this way.
192 256 * Pppd reads and writes packets via /dev/ppp instead.
@@ -217,7 +281,7 @@ ppp_asynctty_write(struct tty_struct *tty, struct file *file, const u8 *buf,
217 281 static int
218 282 ppp_asynctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
219 283 {
220 - struct asyncppp *ap = tty->disc_data;
284 + struct asyncppp *ap = ap_get(tty);
221 285 int err, val;
222 286 int __user *p = (int __user *)arg;
223 287
@@ -258,6 +322,7 @@ ppp_asynctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
258 322 err = tty_mode_ioctl(tty, cmd, arg);
259 323 }
260 324
325 + ap_put(ap);
261 326 return err;
262 327 }
263 328
@@ -266,7 +331,7 @@ static void
266 331 ppp_asynctty_receive(struct tty_struct *tty, const u8 *buf, const u8 *cflags,
267 332 size_t count)
268 333 {
269 - struct asyncppp *ap = tty->disc_data;
334 + struct asyncppp *ap = ap_get(tty);
270 335 unsigned long flags;
271 336
272 337 if (!ap)
@@ -276,19 +341,21 @@ ppp_asynctty_receive(struct tty_struct *tty, const u8 *buf, const u8 *cflags,
276 341 spin_unlock_irqrestore(&ap->recv_lock, flags);
277 342 if (!skb_queue_empty(&ap->rqueue))
278 343 tasklet_schedule(&ap->tsk);
344 + ap_put(ap);
279 345 tty_unthrottle(tty);
280 346 }
281 347
282 348 static void
283 349 ppp_asynctty_wakeup(struct tty_struct *tty)
284 350 {
285 - struct asyncppp *ap = tty->disc_data;
351 + struct asyncppp *ap = ap_get(tty);
286 352
287 353 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
288 354 if (!ap)
289 355 return;
290 356 set_bit(XMIT_WAKEUP, &ap->xmit_flags);
291 357 tasklet_schedule(&ap->tsk);
358 + ap_put(ap);
292 359 }
293 360
294 361
@@ -298,6 +365,7 @@ static struct tty_ldisc_ops ppp_ldisc = {
298 365 .name = "ppp",
299 366 .open = ppp_asynctty_open,
300 367 .close = ppp_asynctty_close,
368 + .hangup = ppp_asynctty_hangup,
301 369 .read = ppp_asynctty_read,
302 370 .write = ppp_asynctty_write,
303 371 .ioctl = ppp_asynctty_ioctl,
modified drivers/net/ppp/ppp_synctty.c
@@ -38,9 +38,11 @@
38 38 #include <linux/ppp-ioctl.h>
39 39 #include <linux/ppp_channel.h>
40 40 #include <linux/spinlock.h>
41 + #include <linux/completion.h>
41 42 #include <linux/init.h>
42 43 #include <linux/interrupt.h>
43 44 #include <linux/slab.h>
45 + #include <linux/refcount.h>
44 46 #include <linux/unaligned.h>
45 47 #include <linux/uaccess.h>
46 48
@@ -65,6 +67,8 @@ struct syncppp {
65 67
66 68 struct tasklet_struct tsk;
67 69
70 + refcount_t refcnt;
71 + struct completion dead_cmp;
68 72 struct ppp_channel chan; /* interface to generic ppp layer */
69 73 };
70 74
@@ -112,6 +116,37 @@ ppp_print_buffer (const char *name, const __u8 *buf, int count)
112 116 * Routines implementing the synchronous PPP line discipline.
113 117 */
114 118
119 + /*
120 + * We have a potential race on dereferencing tty->disc_data,
121 + * because the tty layer provides no locking at all - thus one
122 + * cpu could be running ppp_synctty_receive while another
123 + * calls ppp_synctty_close, which zeroes tty->disc_data and
124 + * frees the memory that ppp_synctty_receive is using. The best
125 + * way to fix this is to use a rwlock in the tty struct, but for now
126 + * we use a single global rwlock for all ttys in ppp line discipline.
127 + *
128 + * FIXME: Fixed in tty_io nowadays.
129 + */
130 + static DEFINE_RWLOCK(disc_data_lock);
131 +
132 + static struct syncppp *sp_get(struct tty_struct *tty)
133 + {
134 + struct syncppp *ap;
135 +
136 + read_lock(&disc_data_lock);
137 + ap = tty->disc_data;
138 + if (ap != NULL)
139 + refcount_inc(&ap->refcnt);
140 + read_unlock(&disc_data_lock);
141 + return ap;
142 + }
143 +
144 + static void sp_put(struct syncppp *ap)
145 + {
146 + if (refcount_dec_and_test(&ap->refcnt))
147 + complete(&ap->dead_cmp);
148 + }
149 +
115 150 /*
116 151 * Called when a tty is put into sync-PPP line discipline.
117 152 */
@@ -142,6 +177,9 @@ ppp_sync_open(struct tty_struct *tty)
142 177 skb_queue_head_init(&ap->rqueue);
143 178 tasklet_setup(&ap->tsk, ppp_sync_process);
144 179
180 + refcount_set(&ap->refcnt, 1);
181 + init_completion(&ap->dead_cmp);
182 +
145 183 ap->chan.private = ap;
146 184 ap->chan.ops = &sync_ops;
147 185 ap->chan.mtu = PPP_MRU;
@@ -163,18 +201,34 @@ ppp_sync_open(struct tty_struct *tty)
163 201 }
164 202
165 203 /*
166 - * Called when the tty is put into another line discipline or it hangs up.
167 - * This call is serialized against other ldisc functions.
204 + * Called when the tty is put into another line discipline
205 + * or it hangs up. We have to wait for any cpu currently
206 + * executing in any of the other ppp_synctty_* routines to
207 + * finish before we can call ppp_unregister_channel and free
208 + * the syncppp struct. This routine must be called from
209 + * process context, not interrupt or softirq context.
168 210 */
169 211 static void
170 212 ppp_sync_close(struct tty_struct *tty)
171 213 {
172 - struct syncppp *ap = tty->disc_data;
214 + struct syncppp *ap;
173 215
216 + write_lock_irq(&disc_data_lock);
217 + ap = tty->disc_data;
218 + tty->disc_data = NULL;
219 + write_unlock_irq(&disc_data_lock);
174 220 if (!ap)
175 221 return;
176 222
177 - tty->disc_data = NULL;
223 + /*
224 + * We have now ensured that nobody can start using ap from now
225 + * on, but we have to wait for all existing users to finish.
226 + * Note that ppp_unregister_channel ensures that no calls to
227 + * our channel ops (i.e. ppp_sync_send/ioctl) are in progress
228 + * by the time it returns.
229 + */
230 + if (!refcount_dec_and_test(&ap->refcnt))
231 + wait_for_completion(&ap->dead_cmp);
178 232 tasklet_kill(&ap->tsk);
179 233
180 234 ppp_unregister_channel(&ap->chan);
@@ -183,6 +237,17 @@ ppp_sync_close(struct tty_struct *tty)
183 237 kfree(ap);
184 238 }
185 239
240 + /*
241 + * Called on tty hangup in process context.
242 + *
243 + * Wait for I/O to driver to complete and unregister PPP channel.
244 + * This is already done by the close routine, so just call that.
245 + */
246 + static void ppp_sync_hangup(struct tty_struct *tty)
247 + {
248 + ppp_sync_close(tty);
249 + }
250 +
186 251 /*
187 252 * Read does nothing - no data is ever available this way.
188 253 * Pppd reads and writes packets via /dev/ppp instead.
@@ -208,7 +273,7 @@ ppp_sync_write(struct tty_struct *tty, struct file *file, const u8 *buf,
208 273 static int
209 274 ppp_synctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
210 275 {
211 - struct syncppp *ap = tty->disc_data;
276 + struct syncppp *ap = sp_get(tty);
212 277 int __user *p = (int __user *)arg;
213 278 int err, val;
214 279
@@ -249,6 +314,7 @@ ppp_synctty_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg)
249 314 break;
250 315 }
251 316
317 + sp_put(ap);
252 318 return err;
253 319 }
254 320
@@ -257,7 +323,7 @@ static void
257 323 ppp_sync_receive(struct tty_struct *tty, const u8 *buf, const u8 *cflags,
258 324 size_t count)
259 325 {
260 - struct syncppp *ap = tty->disc_data;
326 + struct syncppp *ap = sp_get(tty);
261 327 unsigned long flags;
262 328
263 329 if (!ap)
@@ -267,19 +333,21 @@ ppp_sync_receive(struct tty_struct *tty, const u8 *buf, const u8 *cflags,
267 333 spin_unlock_irqrestore(&ap->recv_lock, flags);
268 334 if (!skb_queue_empty(&ap->rqueue))
269 335 tasklet_schedule(&ap->tsk);
336 + sp_put(ap);
270 337 tty_unthrottle(tty);
271 338 }
272 339
273 340 static void
274 341 ppp_sync_wakeup(struct tty_struct *tty)
275 342 {
276 - struct syncppp *ap = tty->disc_data;
343 + struct syncppp *ap = sp_get(tty);
277 344
278 345 clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
279 346 if (!ap)
280 347 return;
281 348 set_bit(XMIT_WAKEUP, &ap->xmit_flags);
282 349 tasklet_schedule(&ap->tsk);
350 + sp_put(ap);
283 351 }
284 352
285 353
@@ -289,6 +357,7 @@ static struct tty_ldisc_ops ppp_sync_ldisc = {
289 357 .name = "pppsync",
290 358 .open = ppp_sync_open,
291 359 .close = ppp_sync_close,
360 + .hangup = ppp_sync_hangup,
292 361 .read = ppp_sync_read,
293 362 .write = ppp_sync_write,
294 363 .ioctl = ppp_synctty_ioctl,
modified drivers/net/usb/qmi_wwan.c
@@ -1446,7 +1446,6 @@ static const struct usb_device_id products[] = {
1446 1446 {QMI_QUIRK_SET_DTR(0x2c7c, 0x0316, 3)}, /* Quectel RG255C */
1447 1447 {QMI_QUIRK_SET_DTR(0x2cb7, 0x0104, 4)}, /* Fibocom NL678 series */
1448 1448 {QMI_QUIRK_SET_DTR(0x2cb7, 0x0112, 0)}, /* Fibocom FG132 */
1449 - {QMI_QUIRK_SET_DTR(0x04b7, 0x8217, 8)}, /* Compal EXM-G1x */
1450 1449 {QMI_FIXED_INTF(0x0489, 0xe0b4, 0)}, /* Foxconn T77W968 LTE */
1451 1450 {QMI_FIXED_INTF(0x0489, 0xe0b5, 0)}, /* Foxconn T77W968 LTE with eSIM support*/
1452 1451 {QMI_FIXED_INTF(0x2692, 0x9025, 4)}, /* Cellient MPL200 (rebranded Qualcomm 05c6:9025) */
modified drivers/net/vxlan/vxlan_mdb.c
@@ -354,10 +354,6 @@ static bool vxlan_mdb_is_valid_source(const struct nlattr *attr, __be16 proto,
354 354 NL_SET_ERR_MSG_MOD(extack, "IPv4 multicast source address is not allowed");
355 355 return false;
356 356 }
357 - if (ipv4_is_zeronet(nla_get_in_addr(attr))) {
358 - NL_SET_ERR_MSG_MOD(extack, "IPv4 all-zeros source address is not allowed");
359 - return false;
360 - }
361 357 break;
362 358 #if IS_ENABLED(CONFIG_IPV6)
363 359 case htons(ETH_P_IPV6): {
@@ -372,10 +368,6 @@ static bool vxlan_mdb_is_valid_source(const struct nlattr *attr, __be16 proto,
372 368 NL_SET_ERR_MSG_MOD(extack, "IPv6 multicast source address is not allowed");
373 369 return false;
374 370 }
375 - if (ipv6_addr_any(&src)) {
376 - NL_SET_ERR_MSG_MOD(extack, "IPv6 all-zeros source address is not allowed");
377 - return false;
378 - }
379 371 break;
380 372 }
381 373 #endif
modified drivers/net/wireless/ath/ath12k/ahb.c
@@ -870,7 +870,7 @@ static struct ath12k_ahb_rproc_info *ath12k_ahb_rproc_info_alloc(struct ath12k_b
870 870
871 871 lockdep_assert_held(&ath12k_rproc_info_lock);
872 872
873 - rproc_info = kzalloc_obj(*rproc_info);
873 + rproc_info = kzalloc_obj(*rproc_info, GFP_KERNEL);
874 874 if (!rproc_info)
875 875 return NULL;
876 876
modified drivers/net/wireless/intel/iwlwifi/mld/regulatory.c
@@ -514,7 +514,8 @@ void iwl_mld_init_ap_type_tables(struct iwl_mld *mld)
514 514 return;
515 515
516 516 if (iwl_fw_lookup_cmd_ver(mld->fw, cmd.id, 1) == 1) {
517 - struct iwl_mcc_allowed_ap_type_cmd_v1 *cmd_v1 = kzalloc_obj(*cmd_v1);
517 + struct iwl_mcc_allowed_ap_type_cmd_v1 *cmd_v1 =
518 + kzalloc(sizeof(*cmd_v1), GFP_KERNEL);
518 519
519 520 if (!cmd_v1)
520 521 return;
modified drivers/net/wireless/mediatek/mt76/mt7921/regd.c
@@ -289,7 +289,7 @@ int mt7921_regd_update(struct mt792x_phy *phy, char *alpha2)
289 289 goto err;
290 290 }
291 291
292 - regd = kzalloc_flex(*regd, reg_rules, num_of_rules);
292 + regd = kzalloc(struct_size(regd, reg_rules, num_of_rules), GFP_KERNEL);
293 293 if (!regd) {
294 294 ret = -ENOMEM;
295 295 goto err;
modified drivers/net/wireless/mediatek/mt76/mt7925/main.c
@@ -1105,7 +1105,7 @@ mt7925_mac_sta_add_links(struct mt792x_dev *dev, struct ieee80211_vif *vif,
1105 1105 mlink = &msta->deflink;
1106 1106 is_deflink = true;
1107 1107 } else {
1108 - mlink = kzalloc_obj(*mlink);
1108 + mlink = kzalloc(sizeof(*mlink), GFP_KERNEL);
1109 1109 if (!mlink) {
1110 1110 err = -ENOMEM;
1111 1111 break;
modified drivers/net/wireless/mediatek/mt76/mt7925/regd.c
@@ -336,7 +336,7 @@ int mt7925_regd_update(struct mt792x_phy *phy, char *alpha2)
336 336 goto err;
337 337 }
338 338
339 - regd = kzalloc_flex(*regd, reg_rules, num_of_rules);
339 + regd = kzalloc(struct_size(regd, reg_rules, num_of_rules), GFP_KERNEL);
340 340 if (!regd) {
341 341 ret = -ENOMEM;
342 342 goto err;
modified drivers/net/wireless/morsemicro/mm81x/mac.c
@@ -706,7 +706,8 @@ static int mm81x_hw_scan_h_init_chan_list(struct mm81x_hw_scan_params *params,
706 706
707 707 params->num_chans = 0;
708 708 params->allocated_chans = 0;
709 - params->channels = kzalloc_objs(*params->channels, chans_to_allocate);
709 + params->channels = kcalloc(chans_to_allocate, sizeof(*params->channels),
710 + GFP_KERNEL);
710 711 if (!params->channels)
711 712 return -ENOMEM;
712 713
@@ -727,8 +728,8 @@ static int mm81x_hw_scan_h_init_chan_list(struct mm81x_hw_scan_params *params,
727 728 }
728 729 }
729 730
730 - params->powers_qdbm = kmalloc_objs(*params->powers_qdbm,
731 - num_pwrs_coarse);
731 + params->powers_qdbm = kmalloc_array(
732 + num_pwrs_coarse, sizeof(*params->powers_qdbm), GFP_KERNEL);
732 733 if (!params->powers_qdbm)
733 734 return -ENOMEM;
734 735
@@ -821,7 +822,7 @@ __mm81x_hw_scan_h_init_params(struct mm81x *mors)
821 822 struct mm81x_hw_scan_params *params = mors->hw_scan.params;
822 823
823 824 if (!params) {
824 - params = kzalloc_obj(*params);
825 + params = kzalloc_obj(*params, GFP_KERNEL);
825 826 if (params)
826 827 mors->hw_scan.params = params;
827 828 } else {
modified drivers/net/wireless/morsemicro/mm81x/yaps.c
@@ -22,13 +22,15 @@
22 22
23 23 static int mm81x_yaps_alloc_pkt_buffers(struct mm81x_yaps *yaps)
24 24 {
25 - yaps->hw.to_chip_pkts = kzalloc_objs(*yaps->hw.to_chip_pkts,
26 - MAX_PKTS_PER_TX_TXN);
25 + yaps->hw.to_chip_pkts = kcalloc(MAX_PKTS_PER_TX_TXN,
26 + sizeof(*yaps->hw.to_chip_pkts),
27 + GFP_KERNEL);
27 28 if (!yaps->hw.to_chip_pkts)
28 29 return -ENOMEM;
29 30
30 - yaps->hw.from_chip_pkts = kzalloc_objs(*yaps->hw.from_chip_pkts,
31 - MAX_PKTS_PER_RX_TXN);
31 + yaps->hw.from_chip_pkts = kcalloc(MAX_PKTS_PER_RX_TXN,
32 + sizeof(*yaps->hw.from_chip_pkts),
33 + GFP_KERNEL);
32 34 if (!yaps->hw.from_chip_pkts) {
33 35 kfree(yaps->hw.to_chip_pkts);
34 36 yaps->hw.to_chip_pkts = NULL;
modified drivers/net/wireless/nxp/nxpwifi/cfg80211.c
@@ -641,7 +641,7 @@ nxpwifi_cfg80211_set_wiphy_params(struct wiphy *wiphy, int radio_idx, u32 change
641 641
642 642 switch (priv->bss_role) {
643 643 case NXPWIFI_BSS_ROLE_UAP:
644 - bss_cfg = kzalloc_obj(*bss_cfg);
644 + bss_cfg = kzalloc_obj(*bss_cfg, GFP_KERNEL);
645 645 if (!bss_cfg) {
646 646 ret = -ENOMEM;
647 647 break;
@@ -1713,7 +1713,7 @@ static int nxpwifi_cfg80211_start_ap(struct wiphy *wiphy,
1713 1713 if (!nxpwifi_is_channel_setting_allowable(priv, params->chandef.chan))
1714 1714 return -EOPNOTSUPP;
1715 1715
1716 - bss_cfg = kzalloc_obj(*bss_cfg);
1716 + bss_cfg = kzalloc_obj(*bss_cfg, GFP_KERNEL);
1717 1717 if (!bss_cfg)
1718 1718 return -ENOMEM;
1719 1719
@@ -1866,7 +1866,7 @@ nxpwifi_cfg80211_scan(struct wiphy *wiphy,
1866 1866 if (!nxpwifi_stop_bg_scan(priv))
1867 1867 cfg80211_sched_scan_stopped_locked(priv->wdev.wiphy, 0);
1868 1868
1869 - user_scan_cfg = kzalloc_obj(*user_scan_cfg);
1869 + user_scan_cfg = kzalloc_obj(*user_scan_cfg, GFP_KERNEL);
1870 1870 if (!user_scan_cfg)
1871 1871 return -ENOMEM;
1872 1872
@@ -1973,7 +1973,7 @@ nxpwifi_cfg80211_sched_scan_start(struct wiphy *wiphy,
1973 1973 request->n_channels, request->scan_plans->interval,
1974 1974 (int)request->ie_len);
1975 1975
1976 - bgscan_cfg = kzalloc_obj(*bgscan_cfg);
1976 + bgscan_cfg = kzalloc_obj(*bgscan_cfg, GFP_KERNEL);
1977 1977 if (!bgscan_cfg)
1978 1978 return -ENOMEM;
1979 1979
@@ -2304,7 +2304,7 @@ nxpwifi_setup_he_caps(struct nxpwifi_private *priv,
2304 2304 if (!hw_he_cap_len)
2305 2305 return;
2306 2306
2307 - iftype_data = kmalloc_obj(*iftype_data);
2307 + iftype_data = kmalloc_obj(*iftype_data, GFP_KERNEL);
2308 2308 if (!iftype_data)
2309 2309 return;
2310 2310 memset(iftype_data, 0, sizeof(*iftype_data));
@@ -2759,7 +2759,7 @@ static int nxpwifi_set_mef_filter(struct nxpwifi_private *priv,
2759 2759 if (wowlan->n_patterns || wowlan->magic_pkt)
2760 2760 num_entries++;
2761 2761
2762 - mef_entry = kzalloc_objs(*mef_entry, num_entries);
2762 + mef_entry = kzalloc_objs(*mef_entry, num_entries, GFP_KERNEL);
2763 2763 if (!mef_entry)
2764 2764 return -ENOMEM;
2765 2765
@@ -3227,7 +3227,7 @@ static int nxpwifi_tm_cmd(struct wiphy *wiphy, struct wireless_dev *wdev,
3227 3227 if (!tb[NXPWIFI_TM_ATTR_DATA])
3228 3228 return -EINVAL;
3229 3229
3230 - hostcmd = kzalloc_obj(*hostcmd);
3230 + hostcmd = kzalloc_obj(*hostcmd, GFP_KERNEL);
3231 3231 if (!hostcmd)
3232 3232 return -ENOMEM;
3233 3233
modified drivers/net/wireless/nxp/nxpwifi/cmdevt.c
@@ -302,7 +302,7 @@ int nxpwifi_alloc_cmd_buffer(struct nxpwifi_adapter *adapter)
302 302
303 303 /* Allocate and initialize struct cmd_ctrl_node */
304 304 cmd_array = kzalloc_objs(struct cmd_ctrl_node,
305 - NXPWIFI_NUM_OF_CMD_BUFFER);
305 + NXPWIFI_NUM_OF_CMD_BUFFER, GFP_KERNEL);
306 306 if (!cmd_array)
307 307 return -ENOMEM;
308 308
modified drivers/net/wireless/nxp/nxpwifi/ie.c
@@ -143,7 +143,7 @@ nxpwifi_update_uap_custom_ie(struct nxpwifi_private *priv,
143 143 u16 len;
144 144 int ret;
145 145
146 - ap_custom_ie = kzalloc_obj(*ap_custom_ie);
146 + ap_custom_ie = kzalloc_obj(*ap_custom_ie, GFP_KERNEL);
147 147 if (!ap_custom_ie)
148 148 return -ENOMEM;
149 149
@@ -209,7 +209,7 @@ static int nxpwifi_update_vs_ie(const u8 *ies, int ies_len,
209 209 vendor_ie = cfg80211_find_vendor_ie(oui, oui_type, ies, ies_len);
210 210 if (vendor_ie) {
211 211 if (!*ie_ptr) {
212 - *ie_ptr = kzalloc_obj(struct nxpwifi_ie);
212 + *ie_ptr = kzalloc_obj(struct nxpwifi_ie, GFP_KERNEL);
213 213 if (!*ie_ptr)
214 214 return -ENOMEM;
215 215 ie = *ie_ptr;
@@ -309,7 +309,7 @@ static int nxpwifi_uap_parse_tail_ies(struct nxpwifi_private *priv,
309 309 if (!info->tail || !info->tail_len)
310 310 return 0;
311 311
312 - gen_ie = kzalloc_obj(*gen_ie);
312 + gen_ie = kzalloc_obj(*gen_ie, GFP_KERNEL);
313 313 if (!gen_ie)
314 314 return -ENOMEM;
315 315
@@ -417,7 +417,7 @@ int nxpwifi_del_mgmt_ies(struct nxpwifi_private *priv)
417 417 int ret = 0;
418 418
419 419 if (priv->gen_idx != NXPWIFI_AUTO_IDX_MASK) {
420 - gen_ie = kmalloc_obj(*gen_ie);
420 + gen_ie = kmalloc_obj(*gen_ie, GFP_KERNEL);
421 421 if (!gen_ie)
422 422 return -ENOMEM;
423 423
@@ -434,7 +434,7 @@ int nxpwifi_del_mgmt_ies(struct nxpwifi_private *priv)
434 434 }
435 435
436 436 if (priv->beacon_idx != NXPWIFI_AUTO_IDX_MASK) {
437 - beacon_ie = kmalloc_obj(*beacon_ie);
437 + beacon_ie = kmalloc_obj(*beacon_ie, GFP_KERNEL);
438 438 if (!beacon_ie) {
439 439 ret = -ENOMEM;
440 440 goto done;
@@ -444,7 +444,7 @@ int nxpwifi_del_mgmt_ies(struct nxpwifi_private *priv)
444 444 beacon_ie->ie_length = 0;
445 445 }
446 446 if (priv->proberesp_idx != NXPWIFI_AUTO_IDX_MASK) {
447 - pr_ie = kmalloc_obj(*pr_ie);
447 + pr_ie = kmalloc_obj(*pr_ie, GFP_KERNEL);
448 448 if (!pr_ie) {
449 449 ret = -ENOMEM;
450 450 goto done;
@@ -454,7 +454,7 @@ int nxpwifi_del_mgmt_ies(struct nxpwifi_private *priv)
454 454 pr_ie->ie_length = 0;
455 455 }
456 456 if (priv->assocresp_idx != NXPWIFI_AUTO_IDX_MASK) {
457 - ar_ie = kmalloc_obj(*ar_ie);
457 + ar_ie = kmalloc_obj(*ar_ie, GFP_KERNEL);
458 458 if (!ar_ie) {
459 459 ret = -ENOMEM;
460 460 goto done;
modified drivers/net/wireless/nxp/nxpwifi/init.c
@@ -20,7 +20,7 @@ static int nxpwifi_add_bss_prio_tbl(struct nxpwifi_private *priv)
20 20 struct nxpwifi_bss_prio_node *bss_prio;
21 21 struct nxpwifi_bss_prio_tbl *tbl = adapter->bss_prio_tbl;
22 22
23 - bss_prio = kzalloc_obj(*bss_prio);
23 + bss_prio = kzalloc_obj(*bss_prio, GFP_KERNEL);
24 24 if (!bss_prio)
25 25 return -ENOMEM;
26 26
modified drivers/net/wireless/nxp/nxpwifi/main.c
@@ -32,7 +32,7 @@ static struct nxpwifi_adapter *nxpwifi_register(void *card, struct device *dev,
32 32 int ret = 0;
33 33 int i;
34 34
35 - adapter = kzalloc_obj(*adapter);
35 + adapter = kzalloc_obj(*adapter, GFP_KERNEL);
36 36 if (!adapter)
37 37 return ERR_PTR(-ENOMEM);
38 38
@@ -55,7 +55,7 @@ static struct nxpwifi_adapter *nxpwifi_register(void *card, struct device *dev,
55 55 for (i = 0; i < NXPWIFI_MAX_BSS_NUM; i++) {
56 56 /* Allocate memory for private structure */
57 57 adapter->priv[i] =
58 - kzalloc_obj(struct nxpwifi_private);
58 + kzalloc_obj(struct nxpwifi_private, GFP_KERNEL);
59 59 if (!adapter->priv[i]) {
60 60 ret = -ENOMEM;
61 61 goto error;
@@ -1106,7 +1106,7 @@ void nxpwifi_drv_info_dump(struct nxpwifi_adapter *adapter)
1106 1106 p += adapter->if_ops.reg_dump(adapter, p);
1107 1107 }
1108 1108 p += sprintf(p, "\n=== more debug information\n");
1109 - debug_info = kzalloc_obj(*debug_info);
1109 + debug_info = kzalloc_obj(*debug_info, GFP_KERNEL);
1110 1110 if (debug_info) {
1111 1111 for (i = 0; i < adapter->priv_num; i++) {
1112 1112 if (!adapter->priv[i]->netdev)
@@ -1242,7 +1242,7 @@ void nxpwifi_init_priv_params(struct nxpwifi_private *priv,
1242 1242
1243 1243 if (GET_BSS_ROLE(priv) == NXPWIFI_BSS_ROLE_STA ||
1244 1244 GET_BSS_ROLE(priv) == NXPWIFI_BSS_ROLE_UAP) {
1245 - priv->hist_data = kmalloc_obj(*priv->hist_data);
1245 + priv->hist_data = kmalloc_obj(*priv->hist_data, GFP_KERNEL);
1246 1246 if (priv->hist_data)
1247 1247 nxpwifi_hist_data_reset(priv);
1248 1248 }
modified drivers/net/wireless/nxp/nxpwifi/scan.c
@@ -1341,14 +1341,15 @@ int nxpwifi_scan_networks(struct nxpwifi_private *priv,
1341 1341 adapter->scan_processing = true;
1342 1342 spin_unlock_bh(&adapter->nxpwifi_cmd_lock);
1343 1343
1344 - scan_cfg_out = kzalloc_obj(union nxpwifi_scan_cmd_config_tlv);
1344 + scan_cfg_out = kzalloc_obj(union nxpwifi_scan_cmd_config_tlv,
1345 + GFP_KERNEL);
1345 1346 if (!scan_cfg_out) {
1346 1347 ret = -ENOMEM;
1347 1348 goto done;
1348 1349 }
1349 1350
1350 1351 scan_chan_list = kzalloc_objs(struct nxpwifi_chan_scan_param_set,
1351 - NXPWIFI_USER_SCAN_CHAN_MAX);
1352 + NXPWIFI_USER_SCAN_CHAN_MAX, GFP_KERNEL);
1352 1353 if (!scan_chan_list) {
1353 1354 kfree(scan_cfg_out);
1354 1355 ret = -ENOMEM;
@@ -1470,7 +1471,7 @@ static int nxpwifi_save_hidden_ssid_channels(struct nxpwifi_private *priv,
1470 1471 int chid;
1471 1472
1472 1473 /* Allocate and fill new bss descriptor */
1473 - bss_desc = kzalloc_obj(*bss_desc);
1474 + bss_desc = kzalloc_obj(*bss_desc, GFP_KERNEL);
1474 1475 if (!bss_desc)
1475 1476 return -ENOMEM;
1476 1477
@@ -1511,7 +1512,7 @@ static int nxpwifi_update_curr_bss_params(struct nxpwifi_private *priv,
1511 1512 int ret;
1512 1513
1513 1514 /* Allocate and fill new bss descriptor */
1514 - bss_desc = kzalloc_obj(*bss_desc);
1515 + bss_desc = kzalloc_obj(*bss_desc, GFP_KERNEL);
1515 1516 if (!bss_desc)
1516 1517 return -ENOMEM;
1517 1518
@@ -1750,7 +1751,7 @@ nxpwifi_active_scan_req_for_passive_chan(struct nxpwifi_private *priv)
1750 1751 nxpwifi_dbg(adapter, INFO, "No BSS with hidden SSID found on DFS channels\n");
1751 1752 return 0;
1752 1753 }
1753 - user_scan_cfg = kzalloc_obj(*user_scan_cfg);
1754 + user_scan_cfg = kzalloc_obj(*user_scan_cfg, GFP_KERNEL);
1754 1755
1755 1756 if (!user_scan_cfg)
1756 1757 return -ENOMEM;
@@ -2257,7 +2258,7 @@ int nxpwifi_stop_bg_scan(struct nxpwifi_private *priv)
2257 2258 return 0;
2258 2259 }
2259 2260
2260 - bgscan_cfg = kzalloc_obj(*bgscan_cfg);
2261 + bgscan_cfg = kzalloc_obj(*bgscan_cfg, GFP_KERNEL);
2261 2262 if (!bgscan_cfg)
2262 2263 return -ENOMEM;
2263 2264
modified drivers/net/wireless/nxp/nxpwifi/sta_cfg.c
@@ -245,7 +245,7 @@ int nxpwifi_bss_start(struct nxpwifi_private *priv, struct cfg80211_bss *bss,
245 245 return -EINVAL;
246 246
247 247 /* Allocate and fill new bss descriptor */
248 - bss_desc = kzalloc_obj(*bss_desc);
248 + bss_desc = kzalloc_obj(*bss_desc, GFP_KERNEL);
249 249 if (!bss_desc)
250 250 return -ENOMEM;
251 251
modified drivers/net/wireless/nxp/nxpwifi/sta_cmd.c
@@ -2822,7 +2822,7 @@ nxpwifi_create_custom_regdomain(struct nxpwifi_private *priv,
2822 2822 if (WARN_ON_ONCE(num_chan > NL80211_MAX_SUPP_REG_RULES))
2823 2823 return ERR_PTR(-EINVAL);
2824 2824
2825 - regd = kzalloc_flex(*regd, reg_rules, num_chan);
2825 + regd = kzalloc_flex(*regd, reg_rules, num_chan, GFP_KERNEL);
2826 2826 if (!regd)
2827 2827 return ERR_PTR(-ENOMEM);
2828 2828
modified drivers/net/wireless/nxp/nxpwifi/uap_event.c
@@ -88,7 +88,7 @@ nxpwifi_uap_event_sta_assoc(struct nxpwifi_private *priv)
88 88 struct nxpwifi_sta_node *node;
89 89 int len, i;
90 90
91 - sinfo = kzalloc_obj(*sinfo);
91 + sinfo = kzalloc_obj(*sinfo, GFP_KERNEL);
92 92 if (!sinfo)
93 93 return -ENOMEM;
94 94
modified drivers/nvdimm/region_devs.c
@@ -1002,7 +1002,8 @@ static struct nd_region *nd_region_create(struct nvdimm_bus *nvdimm_bus,
1002 1002 nd_region->num_lanes = ndr_desc->num_lanes;
1003 1003 if (!nd_region->num_lanes)
1004 1004 goto err_percpu;
1005 - nd_region->lane = kzalloc_objs(*nd_region->lane, nd_region->num_lanes);
1005 + nd_region->lane = kcalloc(nd_region->num_lanes,
1006 + sizeof(*nd_region->lane), GFP_KERNEL);
1006 1007 if (!nd_region->lane)
1007 1008 goto err_percpu;
1008 1009
modified drivers/nvme/host/core.c
@@ -155,6 +155,8 @@ static const struct class nvme_ns_chr_class = {
155 155 };
156 156
157 157 static void nvme_put_subsystem(struct nvme_subsystem *subsys);
158 + static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
159 + unsigned nsid);
158 160 static void nvme_update_keep_alive(struct nvme_ctrl *ctrl,
159 161 struct nvme_command *cmd);
160 162 static int nvme_get_log_lsi(struct nvme_ctrl *ctrl, u32 nsid, u8 log_page,
@@ -1610,7 +1612,7 @@ static int nvme_identify_ns_descs(struct nvme_ctrl *ctrl,
1610 1612 }
1611 1613
1612 1614 if (nvme_multi_css(ctrl) && !csi_seen) {
1613 - dev_warn(ctrl->device, "Command set not reported for nsid:%u\n",
1615 + dev_warn(ctrl->device, "Command set not reported for nsid:%d\n",
1614 1616 info->nsid);
1615 1617 status = -EINVAL;
1616 1618 }
@@ -2339,6 +2341,14 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info)
2339 2341 size_t size;
2340 2342 int i, ret;
2341 2343
2344 + /*
2345 + * The FDP configuration is static for the lifetime of the namespace,
2346 + * so return immediately if we've already registered this namespace's
2347 + * streams.
2348 + */
2349 + if (head->nr_plids)
2350 + return 0;
2351 +
2342 2352 ret = nvme_get_features(ctrl, NVME_FEAT_FDP, info->endgid, NULL, 0,
2343 2353 &fdp);
2344 2354 if (ret) {
@@ -2372,7 +2382,8 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info)
2372 2382 if (!head->nr_plids)
2373 2383 goto free;
2374 2384
2375 - head->plids = kzalloc_objs(*head->plids, head->nr_plids);
2385 + head->plids = kcalloc(head->nr_plids, sizeof(*head->plids),
2386 + GFP_KERNEL);
2376 2387 if (!head->plids) {
2377 2388 dev_warn(ctrl->device,
2378 2389 "failed to allocate %u FDP placement IDs\n",
@@ -2384,7 +2395,6 @@ static int nvme_query_fdp_info(struct nvme_ns *ns, struct nvme_ns_info *info)
2384 2395
2385 2396 for (i = 0; i < head->nr_plids; i++)
2386 2397 head->plids[i] = le16_to_cpu(ruhs->ruhsd[i].pid);
2387 - head->write_stream_granularity = min(info->runs, U32_MAX);
2388 2398 free:
2389 2399 kfree(ruhs);
2390 2400 return ret;
@@ -2432,6 +2442,12 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
2432 2442 goto out;
2433 2443 }
2434 2444
2445 + if (ns->ctrl->ctratt & NVME_CTRL_ATTR_FDPS) {
2446 + ret = nvme_query_fdp_info(ns, info);
2447 + if (ret < 0)
2448 + goto out;
2449 + }
2450 +
2435 2451 if (nvme_invalid_lba_sz(le64_to_cpu(id->nsze),
2436 2452 id->lbaf[lbaf].ds - SECTOR_SHIFT, &capacity)) {
2437 2453 dev_warn_once(ns->ctrl->device,
@@ -2452,26 +2468,9 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
2452 2468 if (!nvme_update_disk_info(ns, id, nvm, &lim))
2453 2469 capacity = 0;
2454 2470
2455 - /*
2456 - * A failed zone info query leaves zi zero-initialized, so skip the
2457 - * zoned limits update instead of configuring the queue from it.
2458 - * During a revalidation that keeps the zone geometry the queue was
2459 - * last validated with; on a first scan the namespace is registered
2460 - * without zoned limits, so that it is still available as a handle
2461 - * for admin commands.
2462 - */
2463 2471 if (IS_ENABLED(CONFIG_BLK_DEV_ZONED) &&
2464 - ns->head->ids.csi == NVME_CSI_ZNS) {
2465 - if (zi.zone_size)
2466 - nvme_update_zone_info(ns, &lim, &zi);
2467 - else
2468 - dev_warn(ns->ctrl->device,
2469 - "zone info query failed for nsid %u, %s\n",
2470 - ns->head->ns_id,
2471 - blk_queue_is_zoned(ns->disk->queue) ?
2472 - "keeping the previous zone limits" :
2473 - "not enabling zoned mode");
2474 - }
2472 + ns->head->ids.csi == NVME_CSI_ZNS)
2473 + nvme_update_zone_info(ns, &lim, &zi);
2475 2474
2476 2475 if ((ns->ctrl->vwc & NVME_CTRL_VWC_PRESENT) && !info->no_vwc)
2477 2476 lim.features |= BLK_FEAT_WRITE_CACHE | BLK_FEAT_FUA;
@@ -2491,7 +2490,10 @@ static int nvme_update_ns_info_block(struct nvme_ns *ns,
2491 2490 capacity = 0;
2492 2491
2493 2492 lim.max_write_streams = ns->head->nr_plids;
2494 - lim.write_stream_granularity = ns->head->write_stream_granularity;
2493 + if (lim.max_write_streams)
2494 + lim.write_stream_granularity = min(info->runs, U32_MAX);
2495 + else
2496 + lim.write_stream_granularity = 0;
2495 2497
2496 2498 /*
2497 2499 * Only set the DEAC bit if the device guarantees that reads from
@@ -3999,11 +4001,10 @@ static void nvme_add_ns_cdev(struct nvme_ns *ns)
3999 4001 set_bit(NVME_NS_CDEV_LIVE, &ns->flags);
4000 4002 }
4001 4003
4002 - static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ns *ns,
4004 + static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ctrl *ctrl,
4003 4005 struct nvme_ns_info *info)
4004 - __must_hold(&ns->ctrl->subsys->lock)
4006 + __must_hold(&ctrl->subsys->lock)
4005 4007 {
4006 - struct nvme_ctrl *ctrl = ns->ctrl;
4007 4008 struct nvme_ns_head *head;
4008 4009 size_t size = sizeof(*head);
4009 4010 int ret = -ENOMEM;
@@ -4031,7 +4032,6 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ns *ns,
4031 4032 ratelimit_state_init(&head->rs_nuse, 5 * HZ, 1);
4032 4033 ratelimit_set_flags(&head->rs_nuse, RATELIMIT_MSG_ON_RELEASE);
4033 4034 kref_init(&head->ref);
4034 - ns->head = head;
4035 4035
4036 4036 if (head->ids.csi) {
4037 4037 ret = nvme_get_effects_log(ctrl, head->ids.csi, &head->effects);
@@ -4040,30 +4040,21 @@ static struct nvme_ns_head *nvme_alloc_ns_head(struct nvme_ns *ns,
4040 4040 } else
4041 4041 head->effects = ctrl->effects;
4042 4042
4043 - if (ctrl->ctratt & NVME_CTRL_ATTR_FDPS) {
4044 - ret = nvme_query_fdp_info(ns, info);
4045 - if (ret < 0)
4046 - goto out_cleanup_srcu;
4047 - }
4048 -
4049 4043 ret = nvme_mpath_alloc_disk(ctrl, head);
4050 4044 if (ret)
4051 - goto out_cleanup_fdp;
4045 + goto out_cleanup_srcu;
4052 4046
4053 4047 list_add_tail(&head->entry, &ctrl->subsys->nsheads);
4054 4048
4055 4049 kref_get(&ctrl->subsys->ref);
4056 4050
4057 4051 return head;
4058 - out_cleanup_fdp:
4059 - kfree(head->plids);
4060 4052 out_cleanup_srcu:
4061 4053 cleanup_srcu_struct(&head->srcu);
4062 4054 out_ida_remove:
4063 4055 ida_free(&ctrl->subsys->ns_ida, head->instance);
4064 4056 out_free_head:
4065 4057 kfree(head);
4066 - ns->head = NULL;
4067 4058 out:
4068 4059 if (ret > 0)
4069 4060 ret = blk_status_to_errno(nvme_error_status(ret));
@@ -4125,13 +4116,13 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info)
4125 4116 ((ns->ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) &&
4126 4117 info->is_shared)) {
4127 4118 dev_err(ctrl->device,
4128 - "ignoring nsid %u because of duplicate IDs\n",
4119 + "ignoring nsid %d because of duplicate IDs\n",
4129 4120 info->nsid);
4130 4121 return ret;
4131 4122 }
4132 4123
4133 4124 dev_err(ctrl->device,
4134 - "clearing duplicate IDs for nsid %u\n", info->nsid);
4125 + "clearing duplicate IDs for nsid %d\n", info->nsid);
4135 4126 dev_err(ctrl->device,
4136 4127 "use of /dev/disk/by-id/ may cause data corruption\n");
4137 4128 memset(&info->ids.nguid, 0, sizeof(info->ids.nguid));
@@ -4146,11 +4137,11 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info)
4146 4137 ret = nvme_subsys_check_duplicate_ids(ctrl->subsys, &info->ids);
4147 4138 if (ret) {
4148 4139 dev_err(ctrl->device,
4149 - "duplicate IDs in subsystem for nsid %u\n",
4140 + "duplicate IDs in subsystem for nsid %d\n",
4150 4141 info->nsid);
4151 4142 goto out_unlock;
4152 4143 }
4153 - head = nvme_alloc_ns_head(ns, info);
4144 + head = nvme_alloc_ns_head(ctrl, info);
4154 4145 if (IS_ERR(head)) {
4155 4146 ret = PTR_ERR(head);
4156 4147 goto out_unlock;
@@ -4160,20 +4151,20 @@ static int nvme_init_ns_head(struct nvme_ns *ns, struct nvme_ns_info *info)
4160 4151 if ((!info->is_shared || !head->shared) &&
4161 4152 !list_empty(&head->list)) {
4162 4153 dev_err(ctrl->device,
4163 - "Duplicate unshared namespace %u\n",
4154 + "Duplicate unshared namespace %d\n",
4164 4155 info->nsid);
4165 4156 goto out_put_ns_head;
4166 4157 }
4167 4158 if (!nvme_ns_ids_equal(&head->ids, &info->ids)) {
4168 4159 dev_err(ctrl->device,
4169 - "IDs don't match for shared namespace %u\n",
4160 + "IDs don't match for shared namespace %d\n",
4170 4161 info->nsid);
4171 4162 goto out_put_ns_head;
4172 4163 }
4173 4164
4174 4165 if (!multipath) {
4175 4166 dev_warn(ctrl->device,
4176 - "Found shared namespace %u, but multipathing not supported.\n",
4167 + "Found shared namespace %d, but multipathing not supported.\n",
4177 4168 info->nsid);
4178 4169 dev_warn_once(ctrl->device,
4179 4170 "Shared namespace support requires core_nvme.multipath=Y.\n");
@@ -4342,9 +4333,6 @@ static void nvme_alloc_ns(struct nvme_ctrl *ctrl, struct nvme_ns_info *info)
4342 4333 last_path = true;
4343 4334 }
4344 4335 mutex_unlock(&ctrl->subsys->lock);
4345 -
4346 - /* guarantee not available in head->list */
4347 - synchronize_srcu(&ns->head->srcu);
4348 4336 if (last_path)
4349 4337 nvme_put_ns_head(ns->head);
4350 4338 nvme_put_ns_head(ns->head);
@@ -4422,7 +4410,7 @@ static void nvme_validate_ns(struct nvme_ns *ns, struct nvme_ns_info *info)
4422 4410
4423 4411 if (!nvme_ns_ids_equal(&ns->head->ids, &info->ids)) {
4424 4412 dev_err(ns->ctrl->device,
4425 - "identifiers changed for nsid %u\n", ns->head->ns_id);
4413 + "identifiers changed for nsid %d\n", ns->head->ns_id);
4426 4414 goto out;
4427 4415 }
4428 4416
@@ -4449,7 +4437,7 @@ static void nvme_scan_ns(struct nvme_ctrl *ctrl, unsigned nsid)
4449 4437
4450 4438 if (info.ids.csi != NVME_CSI_NVM && !nvme_multi_css(ctrl)) {
4451 4439 dev_warn(ctrl->device,
4452 - "command set not reported for nsid: %u\n", nsid);
4440 + "command set not reported for nsid: %d\n", nsid);
4453 4441 return;
4454 4442 }
4455 4443
@@ -4513,16 +4501,15 @@ static void nvme_scan_ns_async(void *data, async_cookie_t cookie)
4513 4501 nvme_scan_ns(scan_info->ctrl, nsid);
4514 4502 }
4515 4503
4516 - static void nvme_remove_nsid_range(struct nvme_ctrl *ctrl, u32 start, u32 end)
4504 + static void nvme_remove_invalid_namespaces(struct nvme_ctrl *ctrl,
4505 + unsigned nsid)
4517 4506 {
4518 4507 struct nvme_ns *ns, *next;
4519 4508 LIST_HEAD(rm_list);
4520 4509
4521 4510 mutex_lock(&ctrl->namespaces_lock);
4522 4511 list_for_each_entry_safe(ns, next, &ctrl->namespaces, list) {
4523 - if (ns->head->ns_id >= end)
4524 - break;
4525 - if (ns->head->ns_id > start) {
4512 + if (ns->head->ns_id > nsid) {
4526 4513 list_del_rcu(&ns->list);
4527 4514 synchronize_srcu(&ctrl->srcu);
4528 4515 list_add_tail_rcu(&ns->list, &rm_list);
@@ -4572,14 +4559,13 @@ static int nvme_scan_ns_list(struct nvme_ctrl *ctrl)
4572 4559 goto out;
4573 4560 async_schedule_domain(nvme_scan_ns_async, &scan_info,
4574 4561 &domain);
4575 - if (prev + 1 < nsid)
4576 - nvme_remove_nsid_range(ctrl, prev, nsid);
4577 - prev = max(prev + 1, nsid);
4562 + while (++prev < nsid)
4563 + nvme_ns_remove_by_nsid(ctrl, prev);
4578 4564 }
4579 4565 async_synchronize_full_domain(&domain);
4580 4566 }
4581 4567 out:
4582 - nvme_remove_nsid_range(ctrl, prev, UINT_MAX);
4568 + nvme_remove_invalid_namespaces(ctrl, prev);
4583 4569 free:
4584 4570 async_synchronize_full_domain(&domain);
4585 4571 kfree(ns_list);
@@ -4599,7 +4585,7 @@ static void nvme_scan_ns_sequential(struct nvme_ctrl *ctrl)
4599 4585 for (i = 1; i <= nn; i++)
4600 4586 nvme_scan_ns(ctrl, i);
4601 4587
4602 - nvme_remove_nsid_range(ctrl, nn, UINT_MAX);
4588 + nvme_remove_invalid_namespaces(ctrl, nn);
4603 4589 }
4604 4590
4605 4591 static void nvme_clear_changed_ns_log(struct nvme_ctrl *ctrl)
modified drivers/nvme/host/fabrics.c
@@ -1028,7 +1028,6 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
1028 1028 }
1029 1029 if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) {
1030 1030 pr_err("Invalid DH-CHAP secret %s\n", p);
1031 - kfree_sensitive(p);
1032 1031 ret = -EINVAL;
1033 1032 goto out;
1034 1033 }
@@ -1043,7 +1042,6 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts,
1043 1042 }
1044 1043 if (strlen(p) < 11 || strncmp(p, "DHHC-1:", 7)) {
1045 1044 pr_err("Invalid DH-CHAP secret %s\n", p);
1046 - kfree_sensitive(p);
1047 1045 ret = -EINVAL;
1048 1046 goto out;
1049 1047 }
modified drivers/nvme/host/fault_inject.c
@@ -42,11 +42,9 @@ void nvme_fault_inject_init(struct nvme_fault_inject *fault_inj,
42 42 }
43 43 fault_inj->parent = parent;
44 44
45 - /* create debugfs for opcode, status code, and dont_retry */
46 - fault_inj->opcode = 0xffff;
45 + /* create debugfs for status code and dont_retry */
47 46 fault_inj->status = NVME_SC_INVALID_OPCODE;
48 47 fault_inj->dont_retry = true;
49 - debugfs_create_x16("opcode", 0600, dir, &fault_inj->opcode);
50 48 debugfs_create_x16("status", 0600, dir, &fault_inj->status);
51 49 debugfs_create_bool("dont_retry", 0600, dir, &fault_inj->dont_retry);
52 50 }
@@ -61,7 +59,6 @@ void nvme_should_fail(struct request *req)
61 59 {
62 60 struct gendisk *disk = req->q->disk;
63 61 struct nvme_fault_inject *fault_inject = NULL;
64 - struct nvme_command *cmd = nvme_req(req)->cmd;
65 62 u16 status;
66 63
67 64 if (disk) {
@@ -75,14 +72,7 @@ void nvme_should_fail(struct request *req)
75 72 fault_inject = &nvme_req(req)->ctrl->fault_inject;
76 73 }
77 74
78 - if (!fault_inject)
79 - return;
80 -
81 - if (fault_inject->opcode <= 0xff &&
82 - fault_inject->opcode != cmd->common.opcode)
83 - return;
84 -
85 - if (should_fail(&fault_inject->attr, 1)) {
75 + if (fault_inject && should_fail(&fault_inject->attr, 1)) {
86 76 /* inject status code and DNR bit */
87 77 status = fault_inject->status;
88 78 if (fault_inject->dont_retry)
modified drivers/nvme/host/fc.c
@@ -2364,15 +2364,9 @@ nvme_fc_ctrl_free(struct kref *ref)
2364 2364 struct nvme_fc_ctrl *ctrl =
2365 2365 container_of(ref, struct nvme_fc_ctrl, ref);
2366 2366 unsigned long flags;
2367 - bool owns_opts;
2368 2367
2369 - /*
2370 - * Presence on the rport list means nvme_fc_init_ctrl() completed,
2371 - * and with it ownership of the fabrics options passed to it. If it
2372 - * failed instead, the options still belong to nvmf_create_ctrl().
2373 - */
2368 + /* remove from rport list */
2374 2369 spin_lock_irqsave(&ctrl->rport->lock, flags);
2375 - owns_opts = !list_empty(&ctrl->ctrl_list);
2376 2370 list_del(&ctrl->ctrl_list);
2377 2371 spin_unlock_irqrestore(&ctrl->rport->lock, flags);
2378 2372
@@ -2382,7 +2376,7 @@ nvme_fc_ctrl_free(struct kref *ref)
2382 2376 nvme_fc_rport_put(ctrl->rport);
2383 2377
2384 2378 ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum);
2385 - if (owns_opts)
2379 + if (ctrl->ctrl.opts)
2386 2380 nvmf_free_options(ctrl->ctrl.opts);
2387 2381 kfree(ctrl);
2388 2382 }
@@ -3581,14 +3575,14 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
3581 3575 if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) {
3582 3576 dev_err(ctrl->ctrl.device,
3583 3577 "NVME-FC{%d}: failed to init ctrl state\n", ctrl->cnum);
3584 - goto fail_unlist;
3578 + goto fail_ctrl;
3585 3579 }
3586 3580
3587 3581 if (!queue_delayed_work(nvme_wq, &ctrl->connect_work, 0)) {
3588 3582 dev_err(ctrl->ctrl.device,
3589 3583 "NVME-FC{%d}: failed to schedule initial connect\n",
3590 3584 ctrl->cnum);
3591 - goto fail_unlist;
3585 + goto fail_ctrl;
3592 3586 }
3593 3587
3594 3588 flush_delayed_work(&ctrl->connect_work);
@@ -3599,22 +3593,14 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts,
3599 3593
3600 3594 return &ctrl->ctrl;
3601 3595
3602 - fail_unlist:
3603 - /*
3604 - * Leaving the list hands the options back to nvmf_create_ctrl();
3605 - * see nvme_fc_ctrl_free(). Re-init so that list_empty() there
3606 - * reports the controller as unlisted.
3607 - */
3608 - spin_lock_irqsave(&rport->lock, flags);
3609 - list_del_init(&ctrl->ctrl_list);
3610 - spin_unlock_irqrestore(&rport->lock, flags);
3611 -
3612 3596 fail_ctrl:
3613 3597 nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING);
3614 3598 cancel_work_sync(&ctrl->ioerr_work);
3615 3599 cancel_work_sync(&ctrl->ctrl.reset_work);
3616 3600 cancel_delayed_work_sync(&ctrl->connect_work);
3617 3601
3602 + ctrl->ctrl.opts = NULL;
3603 +
3618 3604 if (ctrl->ctrl.admin_tagset)
3619 3605 nvme_remove_admin_tag_set(&ctrl->ctrl);
3620 3606 /* initiate nvme ctrl ref counting teardown */
modified drivers/nvme/host/nvme.h
@@ -323,7 +323,6 @@ struct nvme_fault_inject {
323 323 #ifdef CONFIG_FAULT_INJECTION_DEBUG_FS
324 324 struct fault_attr attr;
325 325 struct dentry *parent;
326 - u16 opcode;
327 326 bool dont_retry; /* DNR, do not retry */
328 327 u16 status; /* status code */
329 328 #endif
@@ -572,7 +571,6 @@ struct nvme_ns_head {
572 571
573 572 u16 nr_plids;
574 573 u16 *plids;
575 - u32 write_stream_granularity;
576 574 #ifdef CONFIG_NVME_MULTIPATH
577 575 struct bio_list requeue_list
578 576 __guarded_by(&requeue_lock);
modified drivers/nvme/host/pci.c
@@ -201,7 +201,7 @@ static int quirks_param_set(const char *value, const struct kernel_param *kp)
201 201 count++;
202 202 }
203 203
204 - qlist = kzalloc_objs(*qlist, count);
204 + qlist = kcalloc(count, sizeof(*qlist), GFP_KERNEL);
205 205 if (!qlist) {
206 206 err = -ENOMEM;
207 207 goto out_free_val;
modified drivers/nvme/host/rdma.c
@@ -2036,7 +2036,7 @@ static blk_status_t nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx,
2036 2036 struct ib_device *dev;
2037 2037 bool queue_ready = test_bit(NVME_RDMA_Q_LIVE, &queue->flags);
2038 2038 blk_status_t ret;
2039 - int err = 0;
2039 + int err;
2040 2040
2041 2041 WARN_ON_ONCE(rq->tag < 0);
2042 2042
@@ -2092,18 +2092,16 @@ static blk_status_t nvme_rdma_queue_rq(struct blk_mq_hw_ctx *hctx,
2092 2092 err_unmap:
2093 2093 nvme_rdma_unmap_data(queue, rq);
2094 2094 err:
2095 - if (err != -EIO) {
2096 - nvme_cleanup_cmd(rq);
2097 - if (err == -ENOMEM || err == -EAGAIN)
2098 - ret = BLK_STS_RESOURCE;
2099 - else
2100 - ret = BLK_STS_IOERR;
2101 - }
2095 + if (err == -EIO)
2096 + ret = nvme_host_path_error(rq);
2097 + else if (err == -ENOMEM || err == -EAGAIN)
2098 + ret = BLK_STS_RESOURCE;
2099 + else
2100 + ret = BLK_STS_IOERR;
2101 + nvme_cleanup_cmd(rq);
2102 2102 unmap_qe:
2103 2103 ib_dma_unmap_single(dev, req->sqe.dma, sizeof(struct nvme_command),
2104 2104 DMA_TO_DEVICE);
2105 - if (err == -EIO)
2106 - return nvme_host_path_error(rq);
2107 2105 return ret;
2108 2106 }
2109 2107
modified drivers/nvme/host/sysfs.c
@@ -166,7 +166,7 @@ static DEVICE_ATTR_RO(eui);
166 166 static ssize_t nsid_show(struct device *dev, struct device_attribute *attr,
167 167 char *buf)
168 168 {
169 - return sysfs_emit(buf, "%u\n", dev_to_ns_head(dev)->ns_id);
169 + return sysfs_emit(buf, "%d\n", dev_to_ns_head(dev)->ns_id);
170 170 }
171 171 static DEVICE_ATTR_RO(nsid);
172 172
modified drivers/nvme/host/tcp.c
@@ -413,13 +413,8 @@ static inline void nvme_tcp_queue_request(struct nvme_tcp_request *req,
413 413 * if we're the first on the send_list and we can try to send
414 414 * directly, otherwise queue io_work. Also, only do that if we
415 415 * are on the same cpu, so we don't introduce contention.
416 - *
417 - * TLS kTLS send takes ctx->tx_lock while blk_mq holds set->srcu.
418 - * lockdep reports circular locking via elevator_lock. Defer TLS
419 - * sends to the io workqueue instead of inline from this path.
420 416 */
421 417 if (queue->io_cpu == raw_smp_processor_id() &&
422 - !nvme_tcp_queue_tls(queue) &&
423 418 empty && mutex_trylock(&queue->send_mutex)) {
424 419 nvme_tcp_send_all(queue);
425 420 mutex_unlock(&queue->send_mutex);
@@ -689,13 +684,6 @@ static int nvme_tcp_handle_c2h_data(struct nvme_tcp_queue *queue,
689 684 return -ENOENT;
690 685 }
691 686
692 - if (rq_data_dir(rq) != READ) {
693 - dev_err(queue->ctrl->ctrl.device,
694 - "queue %d tag %#x unexpected data for a write\n",
695 - nvme_tcp_queue_id(queue), rq->tag);
696 - return -EPROTO;
697 - }
698 -
699 687 req = blk_mq_rq_to_pdu(rq);
700 688 if (!blk_rq_payload_bytes(rq) || !req->curr_bio || !req->data_len) {
701 689 dev_err(queue->ctrl->ctrl.device,
modified drivers/nvme/host/zns.c
@@ -48,12 +48,12 @@ int nvme_query_zone_info(struct nvme_ns *ns, unsigned lbaf,
48 48 NVME_CMD_EFFECTS_CSUPP)) {
49 49 if (test_and_clear_bit(NVME_NS_FORCE_RO, &ns->flags))
50 50 dev_warn(ns->ctrl->device,
51 - "Zone Append supported for zoned namespace:%u. Remove read-only mode\n",
51 + "Zone Append supported for zoned namespace:%d. Remove read-only mode\n",
52 52 ns->head->ns_id);
53 53 } else {
54 54 set_bit(NVME_NS_FORCE_RO, &ns->flags);
55 55 dev_warn(ns->ctrl->device,
56 - "Zone Append not supported for zoned namespace:%u. Forcing to read-only mode\n",
56 + "Zone Append not supported for zoned namespace:%d. Forcing to read-only mode\n",
57 57 ns->head->ns_id);
58 58 }
59 59
modified drivers/nvme/target/auth.c
@@ -238,12 +238,6 @@ void nvmet_auth_sq_free(struct nvmet_sq *sq)
238 238 sq->dhchap_skey = NULL;
239 239 }
240 240
241 - void nvmet_auth_sq_destroy(struct nvmet_sq *sq)
242 - {
243 - cancel_delayed_work_sync(&sq->auth_expired_work);
244 - nvmet_auth_sq_free(sq);
245 - }
246 -
247 241 void nvmet_destroy_auth(struct nvmet_ctrl *ctrl)
248 242 {
249 243 ctrl->shash_id = 0;
modified drivers/nvme/target/configfs.c
@@ -814,7 +814,7 @@ static ssize_t nvmet_ns_resv_enable_store(struct config_item *item,
814 814
815 815 mutex_lock(&ns->subsys->lock);
816 816 if (ns->enabled) {
817 - pr_err("the ns:%u is already enabled.\n", ns->nsid);
817 + pr_err("the ns:%d is already enabled.\n", ns->nsid);
818 818 mutex_unlock(&ns->subsys->lock);
819 819 return -EINVAL;
820 820 }
@@ -880,7 +880,7 @@ static struct config_group *nvmet_ns_make(struct config_group *group,
880 880 goto out;
881 881 config_group_init_type_name(&ns->group, name, &nvmet_ns_type);
882 882
883 - pr_info("adding nsid %u to subsystem %s\n", nsid, subsys->subsysnqn);
883 + pr_info("adding nsid %d to subsystem %s\n", nsid, subsys->subsysnqn);
884 884
885 885 return &ns->group;
886 886 out:
modified drivers/nvme/target/core.c
@@ -558,7 +558,7 @@ static void nvmet_p2pmem_ns_add_p2p(struct nvmet_ctrl *ctrl,
558 558 if (ret < 0)
559 559 pci_dev_put(p2p_dev);
560 560
561 - pr_info("using p2pmem on %s for nsid %u\n", pci_name(p2p_dev),
561 + pr_info("using p2pmem on %s for nsid %d\n", pci_name(p2p_dev),
562 562 ns->nsid);
563 563 }
564 564
@@ -591,11 +591,6 @@ int nvmet_ns_enable(struct nvmet_ns *ns)
591 591 if (ns->enabled)
592 592 goto out_unlock;
593 593
594 - if (!ns->device_path) {
595 - ret = -EINVAL;
596 - goto out_unlock;
597 - }
598 -
599 594 ret = nvmet_bdev_ns_enable(ns);
600 595 if (ret == -ENOTBLK)
601 596 ret = nvmet_file_ns_enable(ns);
@@ -985,7 +980,7 @@ void nvmet_sq_destroy(struct nvmet_sq *sq)
985 980 wait_for_completion(&sq->confirm_done);
986 981 wait_for_completion(&sq->free_done);
987 982 percpu_ref_exit(&sq->ref);
988 - nvmet_auth_sq_destroy(sq);
983 + nvmet_auth_sq_free(sq);
989 984 nvmet_cq_put(sq->cq);
990 985
991 986 /*
modified drivers/nvme/target/nvmet.h
@@ -924,7 +924,6 @@ u8 nvmet_setup_auth(struct nvmet_ctrl *ctrl, struct nvmet_sq *sq, bool reset);
924 924 void nvmet_auth_sq_init(struct nvmet_sq *sq);
925 925 void nvmet_destroy_auth(struct nvmet_ctrl *ctrl);
926 926 void nvmet_auth_sq_free(struct nvmet_sq *sq);
927 - void nvmet_auth_sq_destroy(struct nvmet_sq *sq);
928 927 int nvmet_setup_dhgroup(struct nvmet_ctrl *ctrl, u8 dhgroup_id);
929 928 bool nvmet_check_auth_status(struct nvmet_req *req);
930 929 int nvmet_auth_host_hash(struct nvmet_req *req, u8 *response,
@@ -951,7 +950,6 @@ static inline void nvmet_auth_sq_init(struct nvmet_sq *sq)
951 950 }
952 951 static inline void nvmet_destroy_auth(struct nvmet_ctrl *ctrl) {};
953 952 static inline void nvmet_auth_sq_free(struct nvmet_sq *sq) {};
954 - static inline void nvmet_auth_sq_destroy(struct nvmet_sq *sq) {};
955 953 static inline bool nvmet_check_auth_status(struct nvmet_req *req)
956 954 {
957 955 return true;
modified drivers/nvme/target/pr.c
@@ -145,7 +145,7 @@ static void nvmet_pr_add_resv_log(struct nvmet_ctrl *ctrl, u8 log_type,
145 145 log.nsid = cpu_to_le32(nsid);
146 146
147 147 if (!kfifo_put(&log_mgr->log_queue, log)) {
148 - pr_info("a reservation log lost, cntlid:%d, log_type:%d, nsid:%u\n",
148 + pr_info("a reservation log lost, cntlid:%d, log_type:%d, nsid:%d\n",
149 149 ctrl->cntlid, log_type, nsid);
150 150 log_mgr->lost_count++;
151 151 }
modified drivers/nvme/target/rdma.c
@@ -1631,13 +1631,19 @@ static int nvmet_rdma_queue_connect(struct rdma_cm_id *cm_id,
1631 1631 mutex_unlock(&nvmet_rdma_queue_mutex);
1632 1632 if (pending > NVMET_RDMA_BACKLOG) {
1633 1633 ret = NVME_SC_CONNECT_CTRL_BUSY;
1634 - goto free_queue;
1634 + goto put_device;
1635 1635 }
1636 1636 }
1637 1637
1638 1638 ret = nvmet_rdma_cm_accept(cm_id, queue, &event->param.conn);
1639 - if (ret)
1639 + if (ret) {
1640 + /*
1641 + * Don't destroy the cm_id in free path, as we implicitly
1642 + * destroy the cm_id here with non-zero ret code.
1643 + */
1644 + queue->cm_id = NULL;
1640 1645 goto free_queue;
1646 + }
1641 1647
1642 1648 mutex_lock(&nvmet_rdma_queue_mutex);
1643 1649 list_add_tail(&queue->queue_list, &nvmet_rdma_queue_list);
@@ -1646,11 +1652,6 @@ static int nvmet_rdma_queue_connect(struct rdma_cm_id *cm_id,
1646 1652 return 0;
1647 1653
1648 1654 free_queue:
1649 - /*
1650 - * Don't destroy the cm_id in free path, as we implicitly
1651 - * destroy the cm_id here with non-zero ret code.
1652 - */
1653 - queue->cm_id = NULL;
1654 1655 nvmet_rdma_free_queue(queue);
1655 1656 put_device:
1656 1657 kref_put(&ndev->ref, nvmet_rdma_free_dev);
modified drivers/nvme/target/tcp.c
@@ -103,7 +103,6 @@ enum nvmet_tcp_recv_state {
103 103
104 104 enum {
105 105 NVMET_TCP_F_INIT_FAILED = (1 << 0),
106 - NVMET_TCP_F_R2T_SENT = (1 << 1),
107 106 };
108 107
109 108 struct nvmet_tcp_cmd {
@@ -777,7 +776,6 @@ static int nvmet_try_send_r2t(struct nvmet_tcp_cmd *cmd, bool last_in_batch)
777 776 return -EAGAIN;
778 777
779 778 cmd->queue->snd_cmd = NULL;
780 - cmd->flags |= NVMET_TCP_F_R2T_SENT;
781 779 return 1;
782 780 }
783 781
@@ -1011,12 +1009,6 @@ static int nvmet_tcp_handle_h2c_data_pdu(struct nvmet_tcp_queue *queue)
1011 1009 cmd = &queue->connect;
1012 1010 }
1013 1011
1014 - if (unlikely(!(cmd->flags & NVMET_TCP_F_R2T_SENT))) {
1015 - pr_err("queue %d: unsolicited H2CData (ttag %u)\n",
1016 - queue->idx, data->ttag);
1017 - goto err_proto;
1018 - }
1019 -
1020 1012 if (le32_to_cpu(data->data_offset) != cmd->rbytes_done) {
1021 1013 pr_err("ttag %u unexpected data offset %u (expected %u)\n",
1022 1014 data->ttag, le32_to_cpu(data->data_offset),
@@ -1252,8 +1244,6 @@ recv:
1252 1244 }
1253 1245
1254 1246 queue->left = hdr->hlen - queue->offset + hdgst;
1255 - if (queue->left > sizeof(queue->pdu) - queue->offset)
1256 - return -EPROTO;
1257 1247 goto recv;
1258 1248 }
1259 1249
modified drivers/opp/core.c
@@ -348,7 +348,7 @@ unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev)
348 348
349 349 count = opp_table->regulator_count;
350 350
351 - uV = kmalloc_objs(*uV, count);
351 + uV = kmalloc_array(count, sizeof(*uV), GFP_KERNEL);
352 352 if (!uV)
353 353 return 0;
354 354
@@ -1505,7 +1505,7 @@ struct opp_device *_add_opp_dev(const struct device *dev,
1505 1505 {
1506 1506 struct opp_device *opp_dev;
1507 1507
1508 - opp_dev = kzalloc_obj(*opp_dev);
1508 + opp_dev = kzalloc(sizeof(*opp_dev), GFP_KERNEL);
1509 1509 if (!opp_dev)
1510 1510 return NULL;
1511 1511
modified drivers/pci/endpoint/pci-ep-msi.c
@@ -57,7 +57,7 @@ static int pci_epf_alloc_doorbell_embedded(struct pci_epf *epf, u16 num_db)
57 57 return -ENODEV;
58 58
59 59 struct pci_epc_aux_resource *res __free(kfree) =
60 - kzalloc_objs(*res, count);
60 + kcalloc(count, sizeof(*res), GFP_KERNEL);
61 61 if (!res)
62 62 return -ENOMEM;
63 63
@@ -98,7 +98,7 @@ static int pci_epf_alloc_doorbell_embedded(struct pci_epf *epf, u16 num_db)
98 98 addr = iova_base + off;
99 99 }
100 100
101 - msg = kzalloc_objs(*msg, num_db);
101 + msg = kcalloc(num_db, sizeof(*msg), GFP_KERNEL);
102 102 if (!msg) {
103 103 ret = -ENOMEM;
104 104 goto err_unmap;
modified drivers/pinctrl/qcom/pinctrl-hawi.c
@@ -47,7 +47,6 @@
47 47 .intr_wakeup_present_bit = 6, \
48 48 .intr_wakeup_enable_bit = 7, \
49 49 .intr_target_bit = 8, \
50 - .intr_target_width = 4, \
51 50 .intr_target_kpss_val = 3, \
52 51 .intr_raw_status_bit = 4, \
53 52 .intr_polarity_bit = 1, \
modified drivers/pinctrl/qcom/pinctrl-ipq5018.c
@@ -563,7 +563,7 @@ static const char * const qdss_cti_trig_out_b1_groups[] = {
563 563 };
564 564
565 565 static const char * const pwm3_groups[] = {
566 - "gpio45", "gpio13",
566 + "gpio45",
567 567 };
568 568
569 569 static const char * const qdss_cti_trig_in_b1_groups[] = {
@@ -689,7 +689,7 @@ static const struct msm_pingroup ipq5018_groups[] = {
689 689 PINGROUP(10, blsp0_spi, blsp1_uart0, led0, gcc_plltest, qdss_tracedata_a, _, _, _, _),
690 690 PINGROUP(11, blsp0_spi, blsp1_uart0, _, gcc_tlmm, qdss_tracedata_a, _, _, _, _),
691 691 PINGROUP(12, blsp0_spi, blsp0_i2c, blsp1_uart0, _, gcc_plltest, qdss_tracedata_a, _, _, _),
692 - PINGROUP(13, blsp0_spi, blsp0_i2c, blsp1_uart0, pwm3, qdss_tracedata_a, _, _, _, _),
692 + PINGROUP(13, blsp0_spi, blsp0_i2c, blsp1_uart0, _, qdss_tracedata_a, _, _, _, _),
693 693 PINGROUP(14, pcie0_clk, _, _, cri_trng0, qdss_tracedata_a, _, _, _, _),
694 694 PINGROUP(15, _, _, cri_trng1, qdss_tracedata_a, _, _, _, _, _),
695 695 PINGROUP(16, pcie0_wake, _, _, cri_trng, qdss_tracedata_a, _, _, _, _),
modified drivers/pinctrl/qcom/pinctrl-ipq5210.c
@@ -867,7 +867,6 @@ static const struct of_device_id ipq5210_tlmm_of_match[] = {
867 867 { .compatible = "qcom,ipq5210-tlmm", },
868 868 { },
869 869 };
870 - MODULE_DEVICE_TABLE(of, ipq5210_tlmm_of_match);
871 870
872 871 static int ipq5210_tlmm_probe(struct platform_device *pdev)
873 872 {
modified drivers/pinctrl/qcom/pinctrl-maili.c
@@ -47,7 +47,6 @@
47 47 .intr_wakeup_present_bit = 6, \
48 48 .intr_wakeup_enable_bit = 7, \
49 49 .intr_target_bit = 8, \
50 - .intr_target_width = 4, \
51 50 .intr_target_kpss_val = 3, \
52 51 .intr_raw_status_bit = 4, \
53 52 .intr_polarity_bit = 1, \
modified drivers/pinctrl/qcom/pinctrl-nord.c
@@ -32,7 +32,6 @@
32 32 .intr_wakeup_present_bit = 6, \
33 33 .intr_wakeup_enable_bit = 7, \
34 34 .intr_target_bit = 8, \
35 - .intr_target_width = 4, \
36 35 .intr_target_kpss_val = 3, \
37 36 .intr_raw_status_bit = 4, \
38 37 .intr_polarity_bit = 1, \
@@ -571,10 +570,8 @@ enum nord_functions {
571 570 msm_mux_qup0_se5,
572 571 msm_mux_qup1_se0,
573 572 msm_mux_qup1_se1,
574 - msm_mux_qup1_se2_01,
575 - msm_mux_qup1_se2_23,
576 - msm_mux_qup1_se3_01,
577 - msm_mux_qup1_se3_23,
573 + msm_mux_qup1_se2,
574 + msm_mux_qup1_se3,
578 575 msm_mux_qup1_se4,
579 576 msm_mux_qup1_se5,
580 577 msm_mux_qup1_se6,
@@ -1155,19 +1152,11 @@ static const char *const qup1_se1_groups[] = {
1155 1152 "gpio123", "gpio124", "gpio125", "gpio126",
1156 1153 };
1157 1154
1158 - static const char *const qup1_se2_01_groups[] = {
1159 - "gpio127", "gpio128",
1155 + static const char *const qup1_se2_groups[] = {
1156 + "gpio127", "gpio128", "gpio129", "gpio130",
1160 1157 };
1161 1158
1162 - static const char *const qup1_se2_23_groups[] = {
1163 - "gpio127", "gpio128",
1164 - };
1165 -
1166 - static const char *const qup1_se3_01_groups[] = {
1167 - "gpio129", "gpio130",
1168 - };
1169 -
1170 - static const char *const qup1_se3_23_groups[] = {
1159 + static const char *const qup1_se3_groups[] = {
1171 1160 "gpio129", "gpio130",
1172 1161 };
1173 1162
@@ -1439,10 +1428,8 @@ static const struct pinfunction nord_functions[] = {
1439 1428 MSM_PIN_FUNCTION(qup0_se5),
1440 1429 MSM_PIN_FUNCTION(qup1_se0),
1441 1430 MSM_PIN_FUNCTION(qup1_se1),
1442 - MSM_PIN_FUNCTION(qup1_se2_01),
1443 - MSM_PIN_FUNCTION(qup1_se2_23),
1444 - MSM_PIN_FUNCTION(qup1_se3_01),
1445 - MSM_PIN_FUNCTION(qup1_se3_23),
1431 + MSM_PIN_FUNCTION(qup1_se2),
1432 + MSM_PIN_FUNCTION(qup1_se3),
1446 1433 MSM_PIN_FUNCTION(qup1_se4),
1447 1434 MSM_PIN_FUNCTION(qup1_se5),
1448 1435 MSM_PIN_FUNCTION(qup1_se6),
@@ -1646,13 +1633,13 @@ static const struct msm_pingroup nord_groups[] = {
1646 1633 _, _, _, _, _, _, _),
1647 1634 [126] = PINGROUP(126, qup1_se1, qup1_se0, ccu_i2c_scl, mdp1_vsync_out,
1648 1635 _, atest_usb20, ddr_pxi, _, _, _, _),
1649 - [127] = PINGROUP(127, qup1_se2_23, qup1_se2_01, _, atest_usb21, ddr_pxi,
1636 + [127] = PINGROUP(127, qup1_se2, qup1_se2, _, atest_usb21, ddr_pxi,
1650 1637 _, _, _, _, _, _),
1651 - [128] = PINGROUP(128, qup1_se2_23, qup1_se2_01, _, atest_usb20, ddr_pxi,
1638 + [128] = PINGROUP(128, qup1_se2, qup1_se2, _, atest_usb20, ddr_pxi,
1652 1639 _, _, _, _, _, _),
1653 - [129] = PINGROUP(129, qup1_se3_23, qup1_se3_01, ccu_i2c_sda, mdp1_vsync_out,
1640 + [129] = PINGROUP(129, qup1_se3, qup1_se3, ccu_i2c_sda, mdp1_vsync_out,
1654 1641 _, atest_usb21, ddr_pxi, _, _, _, _),
1655 - [130] = PINGROUP(130, qup1_se3_23, qup1_se3_01, ccu_i2c_scl, mdp1_vsync_out,
1642 + [130] = PINGROUP(130, qup1_se3, qup1_se3, ccu_i2c_scl, mdp1_vsync_out,
1656 1643 _, atest_usb20, ddr_pxi, _, _, _, _),
1657 1644 [131] = PINGROUP(131, qup1_se4, qup1_se6, ccu_i2c_sda, mdp1_vsync_out,
1658 1645 _, atest_usb21, ddr_pxi, _, _, _, _),
modified drivers/pinctrl/qcom/pinctrl-qcs8300.c
@@ -45,7 +45,6 @@
45 45 .intr_enable_bit = 0, \
46 46 .intr_status_bit = 0, \
47 47 .intr_target_bit = 5, \
48 - .intr_target_width = 4, \
49 48 .intr_target_kpss_val = 3, \
50 49 .intr_raw_status_bit = 4, \
51 50 .intr_polarity_bit = 1, \
modified drivers/platform/x86/amd/hsmp/acpi.c
@@ -720,8 +720,9 @@ static int hsmp_acpi_probe(struct platform_device *pdev)
720 720 return -ENODEV;
721 721 }
722 722
723 - hsmp_pdev->sock = kzalloc_objs(*hsmp_pdev->sock,
724 - hsmp_pdev->num_sockets);
723 + hsmp_pdev->sock = kcalloc(hsmp_pdev->num_sockets,
724 + sizeof(*hsmp_pdev->sock),
725 + GFP_KERNEL);
725 726 if (!hsmp_pdev->sock)
726 727 return -ENOMEM;
727 728
modified drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c
@@ -96,8 +96,8 @@ int hp_alloc_enumeration_data(void)
96 96
97 97 if (!bioscfg_drv.enumeration_instances_count)
98 98 return -EINVAL;
99 - bioscfg_drv.enumeration_data = kvzalloc_objs(*bioscfg_drv.enumeration_data,
100 - bioscfg_drv.enumeration_instances_count);
99 + bioscfg_drv.enumeration_data = kvcalloc(bioscfg_drv.enumeration_instances_count,
100 + sizeof(*bioscfg_drv.enumeration_data), GFP_KERNEL);
101 101
102 102 if (!bioscfg_drv.enumeration_data) {
103 103 bioscfg_drv.enumeration_instances_count = 0;
modified drivers/platform/x86/intel/pmc/pwrm_telemetry.c
@@ -93,7 +93,8 @@ acpi_disc_t pmc_parse_telem_dsd(union acpi_object *obj,
93 93 if (header->num_entries != num_regions)
94 94 return ERR_PTR(-EINVAL);
95 95
96 - acpi_disc_t disc __free(kfree) = kmalloc_objs(*disc, num_regions);
96 + acpi_disc_t disc __free(kfree) = kmalloc_array(num_regions, sizeof(*disc),
97 + GFP_KERNEL);
97 98 if (!disc)
98 99 return ERR_PTR(-ENOMEM);
99 100
modified drivers/pmdomain/core.c
@@ -2962,7 +2962,7 @@ int of_genpd_add_child_ids(struct device_node *np,
2962 2962 return -EINVAL;
2963 2963
2964 2964 /* Allocate tracking array for error unwind (parent/child pairs) */
2965 - pairs = kmalloc_objs(*pairs, count * 2);
2965 + pairs = kmalloc_array(count * 2, sizeof(*pairs), GFP_KERNEL);
2966 2966 if (!pairs)
2967 2967 return -ENOMEM;
2968 2968
modified drivers/pmdomain/mediatek/Kconfig
@@ -43,12 +43,9 @@ config MTK_MFG_PM_DOMAIN
43 43 This driver is required for the Mali GPU to work at all on MT8196 and
44 44 MT6991.
45 45
46 - endmenu
47 -
48 46 config AIROHA_CPU_PM_DOMAIN
49 47 tristate "Airoha CPU power domain"
50 48 default ARCH_AIROHA
51 - depends on ARCH_AIROHA || COMPILE_TEST
52 49 depends on HAVE_ARM_SMCCC
53 50 depends on PM
54 51 select PM_GENERIC_DOMAINS
@@ -57,3 +54,5 @@ config AIROHA_CPU_PM_DOMAIN
57 54
58 55 CPU frequency and power is controlled by ATF with SMC command to
59 56 set performance states.
57 +
58 + endmenu
modified drivers/pmdomain/qcom/rpmhpd.c
@@ -241,9 +241,13 @@ static struct rpmhpd *eliza_rpmhpds[] = {
241 241 [RPMHPD_GFX] = &gfx,
242 242 [RPMHPD_LCX] = &lcx,
243 243 [RPMHPD_LMX] = &lmx,
244 + [RPMHPD_MMCX] = &mmcx,
245 + [RPMHPD_MMCX_AO] = &mmcx_ao,
244 246 [RPMHPD_MSS] = &mss,
245 247 [RPMHPD_MX] = &mx,
246 248 [RPMHPD_MX_AO] = &mx_ao,
249 + [RPMHPD_MXC] = &mxc,
250 + [RPMHPD_MXC_AO] = &mxc_ao,
247 251 [RPMHPD_NSP] = &nsp,
248 252 };
249 253
modified drivers/power/reset/reboot-mode.c
@@ -122,14 +122,14 @@ static int reboot_mode_create_device(struct reboot_mode_driver *reboot)
122 122 struct mode_info *info;
123 123 int ret;
124 124
125 - priv = kzalloc_obj(*priv);
125 + priv = kzalloc_obj(*priv, GFP_KERNEL);
126 126 if (!priv)
127 127 return -ENOMEM;
128 128
129 129 INIT_LIST_HEAD(&priv->head);
130 130
131 131 list_for_each_entry(info, &reboot->head, list) {
132 - sysfs_info = kzalloc_obj(*sysfs_info);
132 + sysfs_info = kzalloc_obj(*sysfs_info, GFP_KERNEL);
133 133 if (!sysfs_info) {
134 134 ret = -ENOMEM;
135 135 goto error;
@@ -188,7 +188,7 @@ int reboot_mode_register(struct reboot_mode_driver *reboot)
188 188 continue;
189 189 }
190 190
191 - info = kzalloc_obj(*info);
191 + info = kzalloc_obj(*info, GFP_KERNEL);
192 192 if (!info) {
193 193 ret = -ENOMEM;
194 194 goto error;
modified drivers/power/sequencing/core.c
@@ -480,7 +480,7 @@ pwrseq_device_register(const struct pwrseq_config *config)
480 480 !config->targets[0])
481 481 return ERR_PTR(-EINVAL);
482 482
483 - pwrseq = kzalloc_obj(*pwrseq);
483 + pwrseq = kzalloc(sizeof(*pwrseq), GFP_KERNEL);
484 484 if (!pwrseq)
485 485 return ERR_PTR(-ENOMEM);
486 486
modified drivers/power/sequencing/pwrseq-pcie-m2.c
@@ -291,7 +291,7 @@ static int pwrseq_pcie_m2_create_serdev_one(struct pwrseq_pcie_m2_ctx *ctx,
291 291 }
292 292 }
293 293
294 - pci_dev = kzalloc_obj(*pci_dev);
294 + pci_dev = kzalloc(sizeof(*pci_dev), GFP_KERNEL);
295 295 if (!pci_dev) {
296 296 ret = -ENOMEM;
297 297 goto err_put_ctrl;
modified drivers/power/supply/power_supply_core.c
@@ -904,7 +904,7 @@ int power_supply_get_battery_info(struct power_supply *psy,
904 904 goto out_put_node;
905 905 }
906 906
907 - u32 *propdata __free(kfree) = kzalloc_objs(*propdata, proplen);
907 + u32 *propdata __free(kfree) = kcalloc(proplen, sizeof(*propdata), GFP_KERNEL);
908 908 if (!propdata) {
909 909 power_supply_put_battery_info(psy, info);
910 910 err = -EINVAL;
@@ -944,7 +944,7 @@ int power_supply_get_battery_info(struct power_supply *psy,
944 944 goto out_put_node;
945 945 }
946 946
947 - propdata = kzalloc_objs(*propdata, proplen);
947 + propdata = kcalloc(proplen, sizeof(*propdata), GFP_KERNEL);
948 948 if (!propdata) {
949 949 power_supply_put_battery_info(psy, info);
950 950 err = -ENOMEM;
@@ -1726,7 +1726,7 @@ __power_supply_register(struct device *parent,
1726 1726 pr_warn("%s: Expected proper parent device for '%s'\n",
1727 1727 __func__, desc->name);
1728 1728
1729 - psy = kzalloc_obj(*psy);
1729 + psy = kzalloc(sizeof(*psy), GFP_KERNEL);
1730 1730 if (!psy)
1731 1731 return ERR_PTR(-ENOMEM);
1732 1732
modified drivers/ptp/ptp_chardev.c
@@ -136,7 +136,7 @@ int ptp_open(struct posix_clock_context *pccontext, fmode_t fmode)
136 136 struct timestamp_event_queue *queue;
137 137 char debugfsname[32];
138 138
139 - queue = kzalloc_obj(*queue);
139 + queue = kzalloc(sizeof(*queue), GFP_KERNEL);
140 140 if (!queue)
141 141 return -EINVAL;
142 142 queue->mask = bitmap_alloc(PTP_MAX_CHANNELS, GFP_KERNEL);
modified drivers/ras/amd/atl/core.c
@@ -190,6 +190,7 @@ static const struct x86_cpu_id amd_atl_cpuids[] = {
190 190 X86_MATCH_FEATURE(X86_FEATURE_ZEN, NULL),
191 191 { }
192 192 };
193 + MODULE_DEVICE_TABLE(x86cpu, amd_atl_cpuids);
193 194
194 195 static int __init amd_atl_init(void)
195 196 {
modified drivers/ras/amd/atl/map.c
@@ -771,5 +771,9 @@ int get_address_map(struct addr_ctx *ctx)
771 771
772 772 dump_address_map(&ctx->map);
773 773
774 - return validate_address_map(ctx);
774 + ret = validate_address_map(ctx);
775 + if (ret)
776 + return ret;
777 +
778 + return ret;
775 779 }
modified drivers/s390/block/dasd.c
@@ -87,7 +87,7 @@ struct dasd_device *dasd_alloc_device(void)
87 87 {
88 88 struct dasd_device *device;
89 89
90 - device = kzalloc_obj(struct dasd_device);
90 + device = kzalloc_obj(struct dasd_device, GFP_KERNEL);
91 91 if (!device)
92 92 return ERR_PTR(-ENOMEM);
93 93
modified drivers/s390/crypto/zcrypt_cca_key.h
@@ -219,7 +219,6 @@ static inline int zcrypt_type6_crt_key(struct ica_rsa_modexpo_crt *crt, void *p)
219 219 copy_from_user(key->key_parts + 2 * long_len + 2 * short_len,
220 220 crt->u_mult_inv, long_len))
221 221 return -EFAULT;
222 - memset(key->key_parts + 3 * long_len + 2 * short_len, 0, pad_len);
223 222 memset(key->key_parts + 3 * long_len + 2 * short_len + pad_len,
224 223 0xff, crt->inputdatalength);
225 224 pub = (struct cca_public_sec *)(key->key_parts + key_len);
modified drivers/s390/crypto/zcrypt_ccamisc.c
@@ -1158,21 +1158,8 @@ static int _ip_cprb_helper(u16 cardnr, u16 domain,
1158 1158
1159 1159 /* do not check the key here, it may be incomplete */
1160 1160
1161 - /*
1162 - * Copy the vlsc key token back.
1163 - * The available space in the destination (key_token) and the source
1164 - * (t) buffer is always larger as the valid range of prepparm->kb.len.
1165 - * Validate t->len by comparing it with the length information in the
1166 - * param block of the request (prepparm->kb.len)
1167 - * The value range of prepparm->kb.len has been checked above.
1168 - */
1161 + /* copy the vlsc key token back */
1169 1162 t = (struct cipherkeytoken *)prepparm->kb.tlv1.key_token;
1170 - if (t->len != prepparm->kb.len - 3 * sizeof(uint16_t)) {
1171 - ZCRYPT_DBF_ERR("%s reply with invalid key_token length %u\n",
1172 - __func__, t->len);
1173 - rc = -EIO;
1174 - goto out;
1175 - }
1176 1163 memcpy(key_token, t, t->len);
1177 1164 *key_token_size = t->len;
1178 1165
modified drivers/s390/net/ctcm_mpc.c
@@ -826,7 +826,7 @@ static void mpc_action_go_ready(fsm_instance *fsm, int event, void *arg)
826 826
827 827 fsm_deltimer(&grp->timer);
828 828
829 - if (priv->xid->xid2_flag2 == 0x40) {
829 + if (grp->saved_xid2->xid2_flag2 == 0x40) {
830 830 priv->xid->xid2_flag2 = 0x00;
831 831 if (grp->estconnfunc) {
832 832 grp->estconnfunc(grp->port_num, 1,
@@ -1636,6 +1636,7 @@ done:
1636 1636 "The XID used in the MPC protocol is not valid, "
1637 1637 "rc = %d\n", rc);
1638 1638 priv->xid->xid2_flag2 = 0x40;
1639 + grp->saved_xid2->xid2_flag2 = 0x40;
1639 1640 }
1640 1641
1641 1642 return rc;
modified drivers/scsi/Kconfig
@@ -753,6 +753,7 @@ config SCSI_IBMVFC
753 753 tristate "IBM Virtual FC support"
754 754 depends on PPC_PSERIES && SCSI
755 755 depends on SCSI_FC_ATTRS
756 + depends on NVME_FC || NVME_FC=n
756 757 help
757 758 This is the IBM POWER Virtual FC Client
758 759
modified drivers/scsi/ch.c
@@ -112,7 +112,6 @@ typedef struct {
112 112 int minor;
113 113 char name[8];
114 114 struct scsi_device *device;
115 - struct scsi_device **dt; /* ptrs to data transfer elements */
116 115 u_int firsts[CH_TYPES];
117 116 u_int counts[CH_TYPES];
118 117 u_int voltags;
@@ -363,15 +362,10 @@ ch_readconfig(scsi_changer *ch)
363 362 vendor_labels[i]);
364 363 }
365 364
366 - /* look up the devices of the data transfer elements */
367 - ch->dt = kzalloc_objs(*ch->dt, ch->counts[CHET_DT]);
368 -
369 - if (!ch->dt) {
370 - kfree(buffer);
371 - return -ENOMEM;
372 - }
373 -
365 + /* report the devices of the data transfer elements */
374 366 for (elem = 0; elem < ch->counts[CHET_DT]; elem++) {
367 + struct scsi_device *sdev;
368 +
375 369 id = -1;
376 370 lun = 0;
377 371 if (elem < CH_DT_MAX && -1 != dt_id[elem]) {
@@ -387,10 +381,8 @@ ch_readconfig(scsi_changer *ch)
387 381 VPRINTK(KERN_INFO, "dt 0x%x: ",elem+ch->firsts[CHET_DT]);
388 382 if (data[6] & 0x80) {
389 383 VPRINTK(KERN_CONT, "not this SCSI bus\n");
390 - ch->dt[elem] = NULL;
391 384 } else if (0 == (data[6] & 0x30)) {
392 385 VPRINTK(KERN_CONT, "ID/LUN unknown\n");
393 - ch->dt[elem] = NULL;
394 386 } else {
395 387 id = ch->device->id;
396 388 lun = 0;
@@ -400,18 +392,16 @@ ch_readconfig(scsi_changer *ch)
400 392 }
401 393 if (-1 != id) {
402 394 VPRINTK(KERN_CONT, "ID %i, LUN %i, ",id,lun);
403 - ch->dt[elem] =
404 - scsi_device_lookup(ch->device->host,
405 - ch->device->channel,
406 - id,lun);
407 - if (!ch->dt[elem]) {
395 + sdev = scsi_device_lookup(ch->device->host,
396 + ch->device->channel,
397 + id, lun);
398 + if (!sdev) {
408 399 /* should not happen */
409 400 VPRINTK(KERN_CONT, "Huh? device not found!\n");
410 401 } else {
411 402 VPRINTK(KERN_CONT, "name: %8.8s %16.16s %4.4s\n",
412 - ch->dt[elem]->vendor,
413 - ch->dt[elem]->model,
414 - ch->dt[elem]->rev);
403 + sdev->vendor, sdev->model, sdev->rev);
404 + scsi_device_put(sdev);
415 405 }
416 406 }
417 407 }
@@ -575,7 +565,6 @@ static void ch_destroy(struct kref *ref)
575 565 scsi_changer *ch = container_of(ref, scsi_changer, ref);
576 566
577 567 ch->device = NULL;
578 - kfree(ch->dt);
579 568 kfree(ch);
580 569 }
581 570
modified drivers/scsi/fnic/fnic.h
@@ -31,7 +31,7 @@
31 31
32 32 #define DRV_NAME "fnic"
33 33 #define DRV_DESCRIPTION "Cisco FCoE HBA Driver"
34 - #define DRV_VERSION "1.9.0.0"
34 + #define DRV_VERSION "1.9.0.1"
35 35 #define PFX DRV_NAME ": "
36 36 #define DFX DRV_NAME "%d: "
37 37
modified drivers/scsi/fnic/fnic_debugfs.c
@@ -767,7 +767,7 @@ static int fnic_nvmef_debugfs_open(struct inode *inode, struct file *file)
767 767 struct fnic_nvmef_info *info;
768 768 int buf_size = 2 * PAGE_SIZE;
769 769
770 - info = kzalloc_obj(struct fnic_nvmef_info);
770 + info = kzalloc_obj(struct fnic_nvmef_info, GFP_KERNEL);
771 771 if (!info)
772 772 return -ENOMEM;
773 773
modified drivers/scsi/fnic/fnic_isr.c
@@ -245,7 +245,14 @@ int fnic_set_intr_mode_msix(struct fnic *fnic)
245 245 unsigned int m = ARRAY_SIZE(fnic->wq);
246 246 unsigned int o = ARRAY_SIZE(fnic->hw_copy_wq);
247 247 unsigned int min_irqs = n + m + 1 + 1; /*rq, raw wq, wq, err*/
248 -
248 + /*
249 + * Make driver critical vectors unmanaged, or else it can get tied
250 + * to an offline CPU. This can happen when hyper-threading is off.
251 + */
252 + struct irq_affinity affd = {
253 + .pre_vectors = n + m + 1, /* rq, raw wq, 1 ioq */
254 + .post_vectors = 1, /* err */
255 + };
249 256 /*
250 257 * We need n RQs, m WQs, o Copy WQs, n+m+o CQs, and n+m+o+1 INTRs
251 258 * (last INTR is used for WQ/RQ errors and notification area)
@@ -263,8 +270,8 @@ int fnic_set_intr_mode_msix(struct fnic *fnic)
263 270 int vec_count = 0;
264 271 int vecs = fnic->rq_count + fnic->raw_wq_count + fnic->wq_copy_count + 1;
265 272
266 - vec_count = pci_alloc_irq_vectors(fnic->pdev, min_irqs, vecs,
267 - PCI_IRQ_MSIX | PCI_IRQ_AFFINITY);
273 + vec_count = pci_alloc_irq_vectors_affinity(fnic->pdev, min_irqs,
274 + vecs, PCI_IRQ_MSIX|PCI_IRQ_AFFINITY, &affd);
268 275 FNIC_ISR_DBG(KERN_INFO, fnic,
269 276 "allocated %d MSI-X vectors\n",
270 277 vec_count);
modified drivers/scsi/fnic/fnic_main.c
@@ -744,8 +744,19 @@ out_free_ioreq_tables:
744 744 return ret;
745 745 }
746 746
747 + static void fnic_mq_init_queue_map(struct fnic *fnic,
748 + struct blk_mq_queue_map *qmap)
749 + {
750 + unsigned int cpu;
751 +
752 + for_each_possible_cpu(cpu)
753 + qmap->mq_map[cpu] = 0;
754 + }
755 +
747 756 void fnic_mq_map_queues_cpus(struct Scsi_Host *host)
748 757 {
758 + const struct cpumask *mask;
759 + unsigned int queue, cpu;
749 760 struct fnic *fnic = *((struct fnic **) shost_priv(host));
750 761 struct pci_dev *l_pdev = fnic->pdev;
751 762 int intr_mode = fnic->config.intr_mode;
@@ -766,7 +777,35 @@ void fnic_mq_map_queues_cpus(struct Scsi_Host *host)
766 777 return;
767 778 }
768 779
769 - blk_mq_map_hw_queues(qmap, &l_pdev->dev, FNIC_PCI_OFFSET);
780 + fnic_mq_init_queue_map(fnic, qmap);
781 +
782 + /*
783 + * Setup CPU to Queue mapping for all managed MSI-X IRQs.
784 + * Q0 is driver critical and non-managed, hence start from Q1.
785 + */
786 + for (queue = 1; queue < qmap->nr_queues; queue++) {
787 + int irq_num = pci_irq_vector(fnic->pdev,
788 + queue + FNIC_PCI_OFFSET);
789 +
790 + if (irq_num < 0)
791 + continue;
792 +
793 + mask = pci_irq_get_affinity(fnic->pdev,
794 + queue + FNIC_PCI_OFFSET);
795 + if (!mask) {
796 + shost_printk(KERN_ERR, host,
797 + "failed to get irq_affinity map for queue:%d\n", irq_num);
798 + continue;
799 + }
800 + FNIC_MAIN_DBG(KERN_INFO, fnic,
801 + "got irq_affinity map for %d:\n", irq_num);
802 + for_each_cpu(cpu, mask) {
803 + qmap->mq_map[cpu] = qmap->queue_offset + queue;
804 + FNIC_MAIN_DBG(KERN_INFO, fnic,
805 + "[Q%d] cpu:%d <=> irq:%d\n",
806 + queue, cpu, irq_num);
807 + }
808 + }
770 809 }
771 810
772 811 static int fnic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
modified drivers/scsi/leapraid/leapraid_func.c
@@ -2984,7 +2984,8 @@ static void leapraid_fw_evt_put(struct leapraid_fw_evt_work *fw_work)
2984 2984
2985 2985 static struct leapraid_fw_evt_work *leapraid_alloc_fw_evt_work(void)
2986 2986 {
2987 - struct leapraid_fw_evt_work *fw_evt = kzalloc_obj(*fw_evt, GFP_ATOMIC);
2987 + struct leapraid_fw_evt_work *fw_evt =
2988 + kzalloc(sizeof(*fw_evt), GFP_ATOMIC);
2988 2989
2989 2990 if (fw_evt)
2990 2991 kref_init(&fw_evt->refcnt);
@@ -3643,7 +3644,8 @@ static void leapraid_sas_host_add(struct leapraid_adapter *adapter,
3643 3644 return;
3644 3645
3645 3646 adapter->dev_topo.card.card_phy =
3646 - kzalloc_objs(struct leapraid_card_phy, phys_num);
3647 + kcalloc(phys_num,
3648 + sizeof(struct leapraid_card_phy), GFP_KERNEL);
3647 3649 if (!adapter->dev_topo.card.card_phy)
3648 3650 return;
3649 3651
@@ -3761,7 +3763,8 @@ static int leapraid_internal_exp_add(struct leapraid_adapter *adapter,
3761 3763 }
3762 3764
3763 3765 topo_node_exp->card_phy =
3764 - kzalloc_objs(struct leapraid_card_phy, topo_node_exp->phys_num);
3766 + kcalloc(topo_node_exp->phys_num,
3767 + sizeof(struct leapraid_card_phy), GFP_KERNEL);
3765 3768 if (!topo_node_exp->card_phy) {
3766 3769 dev_err(&adapter->pdev->dev,
3767 3770 "%s: Failed to alloc expander phy array, count=%u\n",
@@ -4349,7 +4352,7 @@ static void leapraid_sas_volume_add(
4349 4352 return;
4350 4353 }
4351 4354
4352 - raid_volume = kzalloc_obj(*raid_volume);
4355 + raid_volume = kzalloc(sizeof(*raid_volume), GFP_KERNEL);
4353 4356 if (!raid_volume)
4354 4357 return;
4355 4358
@@ -6087,15 +6090,17 @@ static void leapraid_update_card_port_after_reset(
6087 6090
6088 6091 if (!adapter->dev_topo.card.card_phy) {
6089 6092 adapter->dev_topo.card.card_phy =
6090 - kzalloc_objs(struct leapraid_card_phy, nr_phys);
6093 + kcalloc(nr_phys, sizeof(struct leapraid_card_phy),
6094 + GFP_KERNEL);
6091 6095 if (!adapter->dev_topo.card.card_phy)
6092 6096 return;
6093 6097 }
6094 6098
6095 6099 adapter->dev_topo.card.phys_num = nr_phys;
6096 6100
6097 - new_card_port_table = kzalloc_objs(struct leapraid_card_port,
6098 - adapter->dev_topo.card.phys_num);
6101 + new_card_port_table = kcalloc(adapter->dev_topo.card.phys_num,
6102 + sizeof(struct leapraid_card_port),
6103 + GFP_KERNEL);
6099 6104 if (!new_card_port_table)
6100 6105 return;
6101 6106
@@ -7219,8 +7224,8 @@ static int leapraid_set_legacy_int(struct leapraid_adapter *adapter)
7219 7224 adapter->notification_desc.iopoll_qdex,
7220 7225 adapter->notification_desc.iopoll_qcnt);
7221 7226 adapter->notification_desc.int_rqs =
7222 - kzalloc_objs(struct leapraid_int_rq,
7223 - adapter->notification_desc.iopoll_qdex);
7227 + kcalloc(adapter->notification_desc.iopoll_qdex,
7228 + sizeof(struct leapraid_int_rq), GFP_KERNEL);
7224 7229 if (!adapter->notification_desc.int_rqs)
7225 7230 return -ENOMEM;
7226 7231
@@ -7263,8 +7268,9 @@ static int leapraid_set_msix(struct leapraid_adapter *adapter)
7263 7268 }
7264 7269 if (iopoll_qcnt) {
7265 7270 adapter->notification_desc.blk_mq_poll_rqs =
7266 - kzalloc_objs(struct leapraid_blk_mq_poll_rq,
7267 - iopoll_qcnt);
7271 + kcalloc(iopoll_qcnt,
7272 + sizeof(struct leapraid_blk_mq_poll_rq),
7273 + GFP_KERNEL);
7268 7274 if (!adapter->notification_desc.blk_mq_poll_rqs)
7269 7275 return -ENOMEM;
7270 7276 adapter->adapter_attr.rq_cnt =
@@ -7283,8 +7289,8 @@ static int leapraid_set_msix(struct leapraid_adapter *adapter)
7283 7289 adapter->notification_desc.iopoll_qcnt);
7284 7290
7285 7291 adapter->notification_desc.int_rqs =
7286 - kzalloc_objs(struct leapraid_int_rq,
7287 - adapter->notification_desc.iopoll_qdex);
7292 + kcalloc(adapter->notification_desc.iopoll_qdex,
7293 + sizeof(struct leapraid_int_rq), GFP_KERNEL);
7288 7294 if (!adapter->notification_desc.int_rqs)
7289 7295 return -ENOMEM;
7290 7296
@@ -7359,8 +7365,9 @@ static int leapraid_set_msi(struct leapraid_adapter *adapter)
7359 7365
7360 7366 if (iopoll_qcnt) {
7361 7367 adapter->notification_desc.blk_mq_poll_rqs =
7362 - kzalloc_objs(struct leapraid_blk_mq_poll_rq,
7363 - iopoll_qcnt);
7368 + kcalloc(iopoll_qcnt,
7369 + sizeof(struct leapraid_blk_mq_poll_rq),
7370 + GFP_KERNEL);
7364 7371 if (!adapter->notification_desc.blk_mq_poll_rqs)
7365 7372 return -ENOMEM;
7366 7373
@@ -7397,8 +7404,9 @@ static int leapraid_set_msi(struct leapraid_adapter *adapter)
7397 7404 adapter->notification_desc.iopoll_qcnt);
7398 7405
7399 7406 adapter->notification_desc.int_rqs =
7400 - kzalloc_objs(struct leapraid_int_rq,
7401 - adapter->notification_desc.iopoll_qdex);
7407 + kcalloc(adapter->notification_desc.iopoll_qdex,
7408 + sizeof(struct leapraid_int_rq),
7409 + GFP_KERNEL);
7402 7410 if (!adapter->notification_desc.int_rqs)
7403 7411 return -ENOMEM;
7404 7412
@@ -7950,16 +7958,18 @@ try_again:
7950 7958 DIV_ROUND_UP(adapter->adapter_attr.rq_cnt,
7951 7959 LEAPRAID_REP_DESC_CHUNK_SIZE);
7952 7960 adapter->mem_desc.rep_desc_seg_maint =
7953 - kzalloc_objs(struct leapraid_rep_desc_seg_maint,
7954 - adapter->adapter_attr.rep_desc_q_seg_cnt);
7961 + kcalloc(adapter->adapter_attr.rep_desc_q_seg_cnt,
7962 + sizeof(struct leapraid_rep_desc_seg_maint),
7963 + GFP_KERNEL);
7955 7964 if (!adapter->mem_desc.rep_desc_seg_maint)
7956 7965 return -ENOMEM;
7957 7966
7958 7967 rep_desc_q_cnt_allocated = 0;
7959 7968 for (i = 0; i < adapter->adapter_attr.rep_desc_q_seg_cnt; i++) {
7960 7969 adapter->mem_desc.rep_desc_seg_maint[i].rep_desc_maint =
7961 - kzalloc_objs(struct leapraid_rep_desc_maint,
7962 - LEAPRAID_REP_DESC_CHUNK_SIZE);
7970 + kcalloc(LEAPRAID_REP_DESC_CHUNK_SIZE,
7971 + sizeof(struct leapraid_rep_desc_maint),
7972 + GFP_KERNEL);
7963 7973 if (!adapter->mem_desc.rep_desc_seg_maint[i].rep_desc_maint)
7964 7974 return -ENOMEM;
7965 7975
modified drivers/scsi/leapraid/leapraid_func.h
@@ -554,7 +554,6 @@ struct leapraid_fw_evt_work {
554 554 /**
555 555 * struct leapraid_fw_evt_struct - Firmware event handling structure
556 556 *
557 - * @fw_evt_name: Name of the firmware event.
558 557 * @fw_evt_thread: Workqueue used for processing firmware events.
559 558 * @fw_evt_lock: Spinlock protecting access to the firmware event list.
560 559 * @fw_evt_list: Linked list of pending firmware events.
@@ -565,7 +564,6 @@ struct leapraid_fw_evt_work {
565 564 */
566 565 struct leapraid_fw_evt_struct {
567 566 u32 leapraid_evt_masks[4];
568 - char fw_evt_name[48];
569 567 struct workqueue_struct *fw_evt_thread;
570 568 spinlock_t fw_evt_lock; /* protects firmware event */
571 569 struct list_head fw_evt_list;
modified drivers/scsi/leapraid/leapraid_os.c
@@ -2054,12 +2054,10 @@ static int leapraid_probe(struct pci_dev *pdev, const struct pci_device_id *id)
2054 2054 shost->transportt = leapraid_transport_template;
2055 2055 shost->unique_id = adapter->adapter_attr.id;
2056 2056
2057 - snprintf(adapter->fw_evt_s.fw_evt_name,
2058 - sizeof(adapter->fw_evt_s.fw_evt_name),
2059 - "fw_event_%s%d", LEAPRAID_DRIVER_NAME,
2060 - adapter->adapter_attr.id);
2061 2057 adapter->fw_evt_s.fw_evt_thread =
2062 - alloc_ordered_workqueue(adapter->fw_evt_s.fw_evt_name, 0);
2058 + alloc_ordered_workqueue("fw_event_%s%d", 0,
2059 + LEAPRAID_DRIVER_NAME,
2060 + adapter->adapter_attr.id);
2063 2061 if (!adapter->fw_evt_s.fw_evt_thread) {
2064 2062 dev_err(&adapter->pdev->dev,
2065 2063 "%s: Failed to create fw event workqueue\n", __func__);
modified drivers/scsi/libiscsi.c
@@ -1142,13 +1142,15 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1142 1142 spin_unlock(&conn->session->frwd_lock);
1143 1143 spin_lock(&conn->session->back_lock);
1144 1144 } else {
1145 - struct iscsi_task *task;
1145 + struct iscsi_task *task = NULL;
1146 1146 /*
1147 1147 * Our nop as ping got dropped. We know the target
1148 1148 * and transport are ok so just clean up
1149 1149 */
1150 - task = iscsi_itt_to_task(conn, rejected_pdu.itt);
1151 - if (!task) {
1150 + if (!iscsi_verify_itt(conn, rejected_pdu.itt))
1151 + task = iscsi_itt_to_task(conn, rejected_pdu.itt);
1152 + if (!task || task->state == ISCSI_TASK_FREE ||
1153 + task->sc) {
1152 1154 iscsi_conn_printk(KERN_ERR, conn,
1153 1155 "Invalid pdu reject. Could "
1154 1156 "not lookup rejected task.\n");
@@ -1191,7 +1193,7 @@ struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt)
1191 1193 session->tt->parse_pdu_itt(conn, itt, &i, NULL);
1192 1194 else
1193 1195 i = get_itt(itt);
1194 - if (i >= session->cmds_max)
1196 + if (i < 0 || i >= session->cmds_max)
1195 1197 return NULL;
1196 1198
1197 1199 return session->cmds[i];
@@ -1384,7 +1386,7 @@ int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt)
1384 1386 return ISCSI_ERR_BAD_ITT;
1385 1387 }
1386 1388
1387 - if (i >= session->cmds_max) {
1389 + if (i < 0 || i >= session->cmds_max) {
1388 1390 iscsi_conn_printk(KERN_ERR, conn,
1389 1391 "received invalid itt index %u (max cmds "
1390 1392 "%u.\n", i, session->cmds_max);
modified drivers/scsi/libiscsi_tcp.c
@@ -480,6 +480,9 @@ static int iscsi_tcp_data_in(struct iscsi_conn *conn, struct iscsi_task *task)
480 480 int datasn = be32_to_cpu(rhdr->datasn);
481 481 unsigned total_in_length = task->sc->sdb.length;
482 482
483 + if (task->sc->sc_data_direction != DMA_FROM_DEVICE)
484 + return ISCSI_ERR_PROTO;
485 +
483 486 /*
484 487 * lib iscsi will update this in the completion handling if there
485 488 * is status.
modified drivers/scsi/megaraid/megaraid_sas_base.c
@@ -7886,7 +7886,9 @@ megasas_resume(struct device *dev)
7886 7886 goto fail_init_mfi;
7887 7887 }
7888 7888
7889 - if (megasas_get_ctrl_info(instance) != DCMD_SUCCESS)
7889 + scoped_guard(mutex, &instance->reset_mutex)
7890 + rval = megasas_get_ctrl_info(instance);
7891 + if (rval != DCMD_SUCCESS)
7890 7892 goto fail_init_mfi;
7891 7893
7892 7894 tasklet_init(&instance->isr_tasklet, instance->instancet->tasklet,
modified drivers/scsi/pm8001/pm8001_init.c
@@ -58,15 +58,15 @@ MODULE_PARM_DESC(link_rate, "Enable link rate.\n"
58 58
59 59 bool pm8001_use_msix = true;
60 60 module_param_named(use_msix, pm8001_use_msix, bool, 0444);
61 - MODULE_PARM_DESC(zoned, "Use MSIX interrupts. Default: true");
61 + MODULE_PARM_DESC(use_msix, "Use MSIX interrupts. Default: true");
62 62
63 63 static bool pm8001_use_tasklet = true;
64 64 module_param_named(use_tasklet, pm8001_use_tasklet, bool, 0444);
65 - MODULE_PARM_DESC(zoned, "Use MSIX interrupts. Default: true");
65 + MODULE_PARM_DESC(use_tasklet, "Use tasklets for interrupt handling. Default: true");
66 66
67 67 static bool pm8001_read_wwn = true;
68 68 module_param_named(read_wwn, pm8001_read_wwn, bool, 0444);
69 - MODULE_PARM_DESC(zoned, "Get WWN from the controller. Default: true");
69 + MODULE_PARM_DESC(read_wwn, "Get WWN from the controller. Default: true");
70 70
71 71 uint pcs_event_log_severity = 0x03;
72 72 module_param(pcs_event_log_severity, int, 0644);
modified drivers/scsi/qedi/qedi_main.c
@@ -2652,8 +2652,6 @@ retry_probe:
2652 2652 snprintf(host_buf, sizeof(host_buf), "host_%d", qedi->shost->host_no);
2653 2653 qedi_ops->common->set_name(qedi->cdev, host_buf);
2654 2654
2655 - qedi_ops->register_ops(qedi->cdev, &qedi_cb_ops, qedi);
2656 -
2657 2655 memset(&params, 0, sizeof(params));
2658 2656 params.mtu = DEF_PATH_MTU + IPV6_HDR_LEN + TCP_HDR_LEN;
2659 2657 qedi->ll2_mtu = DEF_PATH_MTU;
@@ -2670,6 +2668,7 @@ retry_probe:
2670 2668 spin_lock_init(&qedi->task_idx_lock);
2671 2669 mutex_init(&qedi->stats_lock);
2672 2670 }
2671 + qedi_ops->register_ops(qedi->cdev, &qedi_cb_ops, qedi);
2673 2672 qedi_ops->ll2->register_cb_ops(qedi->cdev, &qedi_ll2_cb_ops, qedi);
2674 2673 qedi_ops->ll2->start(qedi->cdev, &params);
2675 2674
modified drivers/scsi/qla2xxx/qla_os.c
@@ -352,7 +352,7 @@ MODULE_PARM_DESC(ql2xnvme_queues,
352 352
353 353 int ql2xfc2target = 1;
354 354 module_param(ql2xfc2target, int, 0444);
355 - MODULE_PARM_DESC(qla2xfc2target,
355 + MODULE_PARM_DESC(ql2xfc2target,
356 356 "Enables FC2 Target support. "
357 357 "0 - FC2 Target support is disabled. "
358 358 "1 - FC2 Target support is enabled (default).");
modified drivers/scsi/scsi.c
@@ -727,6 +727,7 @@ int scsi_cdl_enable(struct scsi_device *sdev, bool enable)
727 727 struct scsi_mode_data data;
728 728 struct scsi_sense_hdr sshdr;
729 729 char *buf_data;
730 + size_t avail, offset;
730 731 int len;
731 732
732 733 ret = scsi_mode_sense(sdev, 0x08, 0x0a, 0xf2, buf, sizeof(buf),
@@ -735,11 +736,24 @@ int scsi_cdl_enable(struct scsi_device *sdev, bool enable)
735 736 return -EINVAL;
736 737
737 738 /* Enable or disable CDL using the ATA feature page */
738 - len = min_t(size_t, sizeof(buf),
739 - data.length - data.header_length -
740 - data.block_descriptor_length);
741 - buf_data = buf + data.header_length +
742 - data.block_descriptor_length;
739 + avail = min_t(size_t, data.length, sizeof(buf));
740 + if (data.header_length > avail)
741 + return -EINVAL;
742 +
743 + offset = data.header_length;
744 + avail -= data.header_length;
745 +
746 + if (data.block_descriptor_length > avail)
747 + return -EINVAL;
748 +
749 + offset += data.block_descriptor_length;
750 + avail -= data.block_descriptor_length;
751 +
752 + if (avail < 5)
753 + return -EINVAL;
754 +
755 + buf_data = buf + offset;
756 + len = avail;
743 757
744 758 /*
745 759 * If we want to enable CDL and CDL is already enabled on the
modified drivers/scsi/scsi_devinfo.c
@@ -161,7 +161,7 @@ static struct {
161 161 {"DGC", "DISK", NULL, BLIST_SPARSELUN}, /* EMC CLARiiON, no storage on LUN 0 */
162 162 {"EMC", "Invista", "*", BLIST_SPARSELUN | BLIST_LARGELUN},
163 163 {"EMC", "SYMMETRIX", NULL, BLIST_SPARSELUN | BLIST_LARGELUN |
164 - BLIST_REPORTLUN2 | BLIST_RETRY_ITF},
164 + BLIST_REPORTLUN2 | BLIST_RETRY_ITF | BLIST_SKIP_IO_HINTS},
165 165 {"EMULEX", "MD21/S2 ESDI", NULL, BLIST_SINGLELUN},
166 166 {"easyRAID", "16P", NULL, BLIST_NOREPORTLUN},
167 167 {"easyRAID", "X6P", NULL, BLIST_NOREPORTLUN},
modified drivers/scsi/scsi_scan.c
@@ -158,7 +158,7 @@ int scsi_complete_async_scans(void)
158 158 * sleep a little. Even if we never get memory, the async
159 159 * scans will finish eventually.
160 160 */
161 - data = kmalloc_obj(*data);
161 + data = kmalloc(sizeof(*data), GFP_KERNEL);
162 162 if (!data)
163 163 msleep(1);
164 164 } while (!data);
modified drivers/scsi/sd_zbc.c
@@ -589,7 +589,7 @@ int sd_zbc_revalidate_zones(struct scsi_disk *sdkp)
589 589 int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim,
590 590 u8 buf[SD_BUF_SIZE])
591 591 {
592 - unsigned int nr_zones;
592 + u64 nr_zones;
593 593 u32 zone_blocks = 0;
594 594 int ret;
595 595
@@ -621,6 +621,12 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim,
621 621 goto err;
622 622
623 623 nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
624 + if (nr_zones > INT_MAX) {
625 + sd_printk(KERN_ERR, sdkp, "Too many zones (%llu)\n",
626 + nr_zones);
627 + ret = -EINVAL;
628 + goto err;
629 + }
624 630 sdkp->early_zone_info.nr_zones = nr_zones;
625 631 sdkp->early_zone_info.zone_blocks = zone_blocks;
626 632
modified drivers/scsi/st.c
@@ -3217,14 +3217,20 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
3217 3217 partition >= ST_NBR_PARTITIONS)
3218 3218 return (-EINVAL);
3219 3219 if (partition != STp->partition) {
3220 - if (get_location(STp, &blk, &p, 1))
3220 + /*
3221 + * Save the location for the partition the drive reports,
3222 + * not for STp->partition: after a reset STp->partition may
3223 + * not match the partition the drive is in.
3224 + */
3225 + if (get_location(STp, &blk, &p, 1) ||
3226 + p < 0 || p >= ST_NBR_PARTITIONS)
3221 3227 STps->last_block_valid = 0;
3222 3228 else {
3223 - STps->last_block_valid = 1;
3224 - STps->last_block_visited = blk;
3229 + STp->ps[p].last_block_valid = 1;
3230 + STp->ps[p].last_block_visited = blk;
3225 3231 DEBC_printk(STp, "Visited block %d for "
3226 3232 "partition %d saved.\n",
3227 - blk, STp->partition);
3233 + blk, p);
3228 3234 }
3229 3235 }
3230 3236
@@ -4509,11 +4515,11 @@ static void st_remove(struct scsi_device *SDp)
4509 4515 remove_cdevs(tpnt);
4510 4516
4511 4517 mutex_lock(&st_ref_mutex);
4512 - kref_put(&tpnt->kref, scsi_tape_release);
4513 - mutex_unlock(&st_ref_mutex);
4514 4518 spin_lock(&st_index_lock);
4515 4519 idr_remove(&st_index_idr, index);
4516 4520 spin_unlock(&st_index_lock);
4521 + kref_put(&tpnt->kref, scsi_tape_release);
4522 + mutex_unlock(&st_ref_mutex);
4517 4523 }
4518 4524
4519 4525 /**
modified drivers/scsi/xen-scsifront.c
@@ -367,6 +367,7 @@ static void scsifront_do_response(struct vscsifrnt_info *info,
367 367 struct vscsifrnt_shadow *shadow;
368 368
369 369 if (ring_rsp->rqid >= VSCSIIF_MAX_REQS ||
370 + !info->shadow[ring_rsp->rqid] ||
370 371 !info->shadow[ring_rsp->rqid]->inflight) {
371 372 scsifront_set_error(info, "illegal rqid returned by backend!");
372 373 return;
modified drivers/soc/bcm/brcmstb/common.c
@@ -65,7 +65,7 @@ static int __init brcmstb_soc_device_init(void)
65 65 goto out_put_node;
66 66 }
67 67
68 - soc_info = kzalloc_obj(*soc_info);
68 + soc_info = kzalloc(sizeof(*soc_info), GFP_KERNEL);
69 69 if (!soc_info) {
70 70 ret = -ENOMEM;
71 71 goto out_unmap;
modified drivers/spi/spi-offload.c
@@ -434,7 +434,7 @@ int devm_spi_offload_trigger_register(struct device *dev,
434 434 if (!info->fwnode || !info->ops || !info->ops->match)
435 435 return -EINVAL;
436 436
437 - trigger = kzalloc_obj(*trigger);
437 + trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
438 438 if (!trigger)
439 439 return -ENOMEM;
440 440
modified drivers/staging/fbtft/fbtft-core.c
@@ -298,15 +298,14 @@ static void fbtft_mkdirty(struct fb_info *info, int y, int height)
298 298 {
299 299 struct fbtft_par *par = info->par;
300 300 struct fb_deferred_io *fbdefio = info->fbdefio;
301 - unsigned long flags;
302 301
303 302 /* Mark display lines/area as dirty */
304 - spin_lock_irqsave(&par->dirty_lock, flags);
303 + spin_lock(&par->dirty_lock);
305 304 if (y < par->dirty_lines_start)
306 305 par->dirty_lines_start = y;
307 306 if (y + height - 1 > par->dirty_lines_end)
308 307 par->dirty_lines_end = y + height - 1;
309 - spin_unlock_irqrestore(&par->dirty_lock, flags);
308 + spin_unlock(&par->dirty_lock);
310 309
311 310 /* Schedule deferred_io to update display (no-op if already on queue)*/
312 311 schedule_delayed_work(&info->deferred_work, fbdefio->delay);
@@ -319,13 +318,13 @@ static void fbtft_deferred_io(struct fb_info *info, struct list_head *pagereflis
319 318 struct fb_deferred_io_pageref *pageref;
320 319 unsigned int y_low = 0, y_high = 0;
321 320
322 - spin_lock_irq(&par->dirty_lock);
321 + spin_lock(&par->dirty_lock);
323 322 dirty_lines_start = par->dirty_lines_start;
324 323 dirty_lines_end = par->dirty_lines_end;
325 324 /* set display line markers as clean */
326 325 par->dirty_lines_start = par->info->var.yres - 1;
327 326 par->dirty_lines_end = 0;
328 - spin_unlock_irq(&par->dirty_lock);
327 + spin_unlock(&par->dirty_lock);
329 328
330 329 /* Mark display lines as dirty */
331 330 list_for_each_entry(pageref, pagereflist, list) {
modified drivers/staging/greybus/raw.c
@@ -178,7 +178,7 @@ static int gb_raw_probe(struct gb_bundle *bundle,
178 178 if (minor < 0)
179 179 return minor;
180 180
181 - raw = kzalloc_obj(*raw);
181 + raw = kzalloc_obj(*raw, GFP_KERNEL);
182 182 if (!raw) {
183 183 ida_free(&minors, minor);
184 184 return -ENOMEM;
modified drivers/staging/media/atomisp/pci/sh_css.c
@@ -5820,31 +5820,36 @@ static int ia_css_pipe_create_cas_scaler_desc_single_output(
5820 5820 }
5821 5821
5822 5822 descr->in_info = kmalloc_objs(*descr->in_info,
5823 - descr->num_stage);
5823 + descr->num_stage,
5824 + GFP_KERNEL);
5824 5825 if (!descr->in_info) {
5825 5826 err = -ENOMEM;
5826 5827 goto ERR;
5827 5828 }
5828 5829 descr->internal_out_info = kmalloc_objs(*descr->internal_out_info,
5829 - descr->num_stage);
5830 + descr->num_stage,
5831 + GFP_KERNEL);
5830 5832 if (!descr->internal_out_info) {
5831 5833 err = -ENOMEM;
5832 5834 goto ERR;
5833 5835 }
5834 5836 descr->out_info = kmalloc_objs(*descr->out_info,
5835 - descr->num_stage);
5837 + descr->num_stage,
5838 + GFP_KERNEL);
5836 5839 if (!descr->out_info) {
5837 5840 err = -ENOMEM;
5838 5841 goto ERR;
5839 5842 }
5840 5843 descr->vf_info = kmalloc_objs(*descr->vf_info,
5841 - descr->num_stage);
5844 + descr->num_stage,
5845 + GFP_KERNEL);
5842 5846 if (!descr->vf_info) {
5843 5847 err = -ENOMEM;
5844 5848 goto ERR;
5845 5849 }
5846 5850 descr->is_output_stage = kmalloc_objs(*descr->is_output_stage,
5847 - descr->num_stage);
5851 + descr->num_stage,
5852 + GFP_KERNEL);
5848 5853 if (!descr->is_output_stage) {
5849 5854 err = -ENOMEM;
5850 5855 goto ERR;
@@ -5965,31 +5970,36 @@ ia_css_pipe_create_cas_scaler_desc(struct ia_css_pipe *pipe,
5965 5970 descr->num_stage = num_stages;
5966 5971
5967 5972 descr->in_info = kmalloc_objs(*descr->in_info,
5968 - descr->num_stage);
5973 + descr->num_stage,
5974 + GFP_KERNEL);
5969 5975 if (!descr->in_info) {
5970 5976 err = -ENOMEM;
5971 5977 goto ERR;
5972 5978 }
5973 5979 descr->internal_out_info = kmalloc_objs(*descr->internal_out_info,
5974 - descr->num_stage);
5980 + descr->num_stage,
5981 + GFP_KERNEL);
5975 5982 if (!descr->internal_out_info) {
5976 5983 err = -ENOMEM;
5977 5984 goto ERR;
5978 5985 }
5979 5986 descr->out_info = kmalloc_objs(*descr->out_info,
5980 - descr->num_stage);
5987 + descr->num_stage,
5988 + GFP_KERNEL);
5981 5989 if (!descr->out_info) {
5982 5990 err = -ENOMEM;
5983 5991 goto ERR;
5984 5992 }
5985 5993 descr->vf_info = kmalloc_objs(*descr->vf_info,
5986 - descr->num_stage);
5994 + descr->num_stage,
5995 + GFP_KERNEL);
5987 5996 if (!descr->vf_info) {
5988 5997 err = -ENOMEM;
5989 5998 goto ERR;
5990 5999 }
5991 6000 descr->is_output_stage = kmalloc_objs(*descr->is_output_stage,
5992 - descr->num_stage);
6001 + descr->num_stage,
6002 + GFP_KERNEL);
5993 6003 if (!descr->is_output_stage) {
5994 6004 err = -ENOMEM;
5995 6005 goto ERR;
modified drivers/staging/media/atomisp/pci/sh_css_firmware.c
@@ -254,8 +254,8 @@ sh_css_load_firmware(struct device *dev, const char *fw_data,
254 254 /* Only allocate memory for ISP blob info */
255 255 if (sh_css_num_binaries > NUM_OF_SPS) {
256 256 sh_css_blob_info =
257 - kmalloc_objs(*sh_css_blob_info,
258 - sh_css_num_binaries - NUM_OF_SPS);
257 + kmalloc_array(sh_css_num_binaries - NUM_OF_SPS,
258 + sizeof(*sh_css_blob_info), GFP_KERNEL);
259 259 if (!sh_css_blob_info)
260 260 return -ENOMEM;
261 261 } else {
modified drivers/staging/rtl8723bs/core/rtw_ieee80211.c
@@ -741,10 +741,6 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_att
741 741 u16 attr_data_len = get_unaligned_be16(attr_ptr + 2);
742 742 u16 attr_len = attr_data_len + 4;
743 743
744 - /* Reject attributes whose claimed length runs past the IE */
745 - if (attr_ptr + attr_len > wps_ie + wps_ielen)
746 - break;
747 -
748 744 if (attr_id == target_attr_id) {
749 745 target_attr_ptr = attr_ptr;
750 746
@@ -1153,9 +1149,6 @@ int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *act
1153 1149 u8 c;
1154 1150 u8 a = ACT_PUBLIC_MAX;
1155 1151
1156 - if (frame_len < sizeof(struct ieee80211_hdr_3addr) + 2)
1157 - return false;
1158 -
1159 1152 fc = le16_to_cpu(((struct ieee80211_hdr_3addr *)frame)->frame_control);
1160 1153
1161 1154 if ((fc & (IEEE80211_FCTL_FTYPE | IEEE80211_FCTL_STYPE)) !=
modified drivers/staging/rtl8723bs/core/rtw_mlme.c
@@ -1975,9 +1975,6 @@ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_
1975 1975 break;
1976 1976 }
1977 1977
1978 - if (i + 1 >= in_len)
1979 - break;
1980 -
1981 1978 i += (in_ie[i + 1] + 2); /* to the next IE element */
1982 1979 }
1983 1980
modified drivers/staging/sm750fb/sm750.c
@@ -252,7 +252,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info,
252 252 spin_lock(&sm750_dev->slock);
253 253
254 254 sm750_dev->accel.de_imageblit(&sm750_dev->accel,
255 - image->data, 0,
255 + image->data, image->width >> 3, 0,
256 256 base, pitch, bpp,
257 257 image->dx, image->dy,
258 258 image->width, image->height,
modified drivers/staging/sm750fb/sm750.h
@@ -64,7 +64,7 @@ struct lynx_accel {
64 64 u32 rop2);
65 65
66 66 int (*de_imageblit)(struct lynx_accel *accel, const char *p_srcbuf,
67 - u32 start_bit, u32 d_base, u32 d_pitch,
67 + u32 src_delta, u32 start_bit, u32 d_base, u32 d_pitch,
68 68 u32 byte_per_pixel, u32 dx, u32 dy, u32 width,
69 69 u32 height, u32 f_color, u32 b_color, u32 rop2);
70 70
modified drivers/staging/sm750fb/sm750_accel.c
@@ -288,6 +288,8 @@ static unsigned int de_get_transparency(struct lynx_accel *accel)
288 288 * sm750_hw_imageblit
289 289 * @accel: Acceleration device data
290 290 * @src_buf: pointer to start of source buffer in system memory
291 + * @src_delta: Pitch value (in bytes) of the source buffer, +ive means top down
292 + * and -ive mean button up
291 293 * @start_bit: Mono data can start at any bit in a byte, this value should be
292 294 * 0 to 7
293 295 * @dest_base: Address of destination: offset in frame buffer
@@ -302,7 +304,7 @@ static unsigned int de_get_transparency(struct lynx_accel *accel)
302 304 * @rop2: ROP value
303 305 */
304 306 int sm750_hw_imageblit(struct lynx_accel *accel, const char *src_buf,
305 - u32 start_bit, u32 dest_base, u32 dest_pitch,
307 + u32 src_delta, u32 start_bit, u32 dest_base, u32 dest_pitch,
306 308 u32 byte_per_pixel, u32 dx, u32 dy, u32 width,
307 309 u32 height, u32 fg_color, u32 bg_color, u32 rop2)
308 310 {
@@ -393,7 +395,7 @@ int sm750_hw_imageblit(struct lynx_accel *accel, const char *src_buf,
393 395 write_dp_port(accel, *(unsigned int *)remain);
394 396 }
395 397
396 - src_buf += bytes_per_scan;
398 + src_buf += src_delta;
397 399 }
398 400
399 401 return 0;
modified drivers/staging/sm750fb/sm750_accel.h
@@ -220,6 +220,8 @@ int sm750_hw_copyarea(struct lynx_accel *accel,
220 220 /**
221 221 * sm750_hw_imageblit
222 222 * @src_buf: pointer to start of source buffer in system memory
223 + * @src_delta: Pitch value (in bytes) of the source buffer, +ive means top down
224 + *>----- and -ive mean button up
223 225 * @start_bit: Mono data can start at any bit in a byte, this value should be
224 226 *>----- 0 to 7
225 227 * @dest_base: Address of destination: offset in frame buffer
@@ -234,7 +236,7 @@ int sm750_hw_copyarea(struct lynx_accel *accel,
234 236 * @rop2: ROP value
235 237 */
236 238 int sm750_hw_imageblit(struct lynx_accel *accel, const char *src_buf,
237 - u32 start_bit, u32 dest_base, u32 dest_pitch,
239 + u32 src_delta, u32 start_bit, u32 dest_base, u32 dest_pitch,
238 240 u32 byte_per_pixel, u32 dx, u32 dy, u32 width,
239 241 u32 height, u32 fg_color, u32 bg_color, u32 rop2);
240 242
modified drivers/target/iscsi/iscsi_target_configfs.c
@@ -1306,17 +1306,24 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
1306 1306 return -EINVAL;
1307 1307 }
1308 1308
1309 + if (iscsit_get_tpg(discovery_tpg) < 0)
1310 + return -EINVAL;
1311 +
1309 1312 param = iscsi_find_param_from_key(AUTHMETHOD,
1310 1313 discovery_tpg->param_list);
1311 - if (!param)
1312 - return -EINVAL;
1314 + if (!param) {
1315 + err = -EINVAL;
1316 + goto out;
1317 + }
1313 1318
1314 1319 if (op) {
1315 1320 /*
1316 1321 * Reset the AuthMethod key to CHAP.
1317 1322 */
1318 - if (iscsi_update_param_value(param, CHAP) < 0)
1319 - return -EINVAL;
1323 + if (iscsi_update_param_value(param, CHAP) < 0) {
1324 + err = -EINVAL;
1325 + goto out;
1326 + }
1320 1327
1321 1328 discovery_tpg->tpg_attrib.authentication = 1;
1322 1329 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
@@ -1327,8 +1334,10 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
1327 1334 /*
1328 1335 * Reset the AuthMethod key to CHAP,None
1329 1336 */
1330 - if (iscsi_update_param_value(param, "CHAP,None") < 0)
1331 - return -EINVAL;
1337 + if (iscsi_update_param_value(param, "CHAP,None") < 0) {
1338 + err = -EINVAL;
1339 + goto out;
1340 + }
1332 1341
1333 1342 discovery_tpg->tpg_attrib.authentication = 0;
1334 1343 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
@@ -1337,7 +1346,10 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
1337 1346 " Discovery TPG\n");
1338 1347 }
1339 1348
1340 - return count;
1349 + err = count;
1350 + out:
1351 + iscsit_put_tpg(discovery_tpg);
1352 + return err;
1341 1353 }
1342 1354
1343 1355 CONFIGFS_ATTR(iscsi_disc_, enforce_discovery_auth);
modified drivers/target/target_core_transport.c
@@ -2359,7 +2359,7 @@ void target_do_delayed_work(struct work_struct *work)
2359 2359 struct se_device *dev = container_of(work, struct se_device,
2360 2360 delayed_cmd_work);
2361 2361
2362 - spin_lock(&dev->delayed_cmd_lock);
2362 + spin_lock_irq(&dev->delayed_cmd_lock);
2363 2363 while (!dev->ordered_sync_in_progress) {
2364 2364 struct se_cmd *cmd;
2365 2365
@@ -2380,12 +2380,12 @@ void target_do_delayed_work(struct work_struct *work)
2380 2380 dev->ordered_sync_in_progress = true;
2381 2381
2382 2382 list_del(&cmd->se_delayed_node);
2383 - spin_unlock(&dev->delayed_cmd_lock);
2383 + spin_unlock_irq(&dev->delayed_cmd_lock);
2384 2384
2385 2385 __target_execute_cmd(cmd, true);
2386 - spin_lock(&dev->delayed_cmd_lock);
2386 + spin_lock_irq(&dev->delayed_cmd_lock);
2387 2387 }
2388 - spin_unlock(&dev->delayed_cmd_lock);
2388 + spin_unlock_irq(&dev->delayed_cmd_lock);
2389 2389 }
2390 2390
2391 2391 static void transport_complete_ordered_sync(struct se_cmd *cmd)
modified drivers/tee/qcomtee/user_obj.c
@@ -230,7 +230,8 @@ static int qcomtee_user_object_dispatch(struct qcomtee_object_invoke_ctx *oic,
230 230 struct qcomtee_context_data *ctxdata = uo->ctx->data;
231 231 int errno;
232 232
233 - struct qcomtee_ureq *ureq __free(kfree) = kzalloc_obj(*ureq);
233 + struct qcomtee_ureq *ureq __free(kfree) = kzalloc(sizeof(*ureq),
234 + GFP_KERNEL);
234 235 if (!ureq)
235 236 return -ENOMEM;
236 237
modified drivers/thunderbolt/stream.c
@@ -408,7 +408,8 @@ static int tbstream_dev_alloc_rx_buffers(struct tbstream_dev *sdev)
408 408 size_t ring_size = tb_ring_size(sdev->rx_ring.ring);
409 409 int i;
410 410
411 - sdev->rx_ring.frames = kzalloc_objs(struct tbstream_frame, ring_size);
411 + sdev->rx_ring.frames = kcalloc(ring_size, sizeof(struct tbstream_frame),
412 + GFP_KERNEL);
412 413 if (!sdev->rx_ring.frames)
413 414 return -ENOMEM;
414 415
@@ -462,7 +463,8 @@ static int tbstream_dev_alloc_tx_buffers(struct tbstream_dev *sdev)
462 463 size_t ring_size = tb_ring_size(sdev->tx_ring.ring);
463 464 int i;
464 465
465 - sdev->tx_ring.frames = kzalloc_objs(struct tbstream_frame, ring_size);
466 + sdev->tx_ring.frames = kcalloc(ring_size, sizeof(struct tbstream_frame),
467 + GFP_KERNEL);
466 468 if (!sdev->tx_ring.frames)
467 469 return -ENOMEM;
468 470
@@ -1496,7 +1498,7 @@ tbstream_dev_make_group(struct config_group *group, const char *name)
1496 1498 if (strlen(name) > TB_PROPERTY_KEY_SIZE)
1497 1499 return ERR_PTR(-ENAMETOOLONG);
1498 1500
1499 - sdev = kzalloc_obj(*sdev);
1501 + sdev = kzalloc_obj(*sdev, GFP_KERNEL);
1500 1502 if (!sdev)
1501 1503 return ERR_PTR(-ENOMEM);
1502 1504
@@ -1590,7 +1592,7 @@ tbstream_make_group(struct config_group *group, const char *name)
1590 1592 if (sscanf(name, "%u-%llx.%u", &domain, &route, &index) != 3)
1591 1593 return ERR_PTR(-EINVAL);
1592 1594
1593 - sg = kzalloc_obj(*sg);
1595 + sg = kzalloc_obj(*sg, GFP_KERNEL);
1594 1596 if (!sg)
1595 1597 return ERR_PTR(-ENOMEM);
1596 1598
@@ -1696,7 +1698,7 @@ static int tbstream_probe(struct tb_service *svc)
1696 1698 {
1697 1699 struct tbstream *stream;
1698 1700
1699 - stream = kzalloc_obj(*stream);
1701 + stream = kzalloc_obj(*stream, GFP_KERNEL);
1700 1702 if (!stream)
1701 1703 return -ENOMEM;
1702 1704
modified drivers/tty/moxa.c
@@ -954,7 +954,8 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev)
954 954 unsigned int i, first_idx;
955 955 int ret;
956 956
957 - brd->ports = kzalloc_objs(*brd->ports, MAX_PORTS_PER_BOARD);
957 + brd->ports = kcalloc(MAX_PORTS_PER_BOARD, sizeof(*brd->ports),
958 + GFP_KERNEL);
958 959 if (brd->ports == NULL) {
959 960 printk(KERN_ERR "cannot allocate memory for ports\n");
960 961 ret = -ENOMEM;
modified drivers/tty/vt/consolemap.c
@@ -776,8 +776,7 @@ int con_get_unimap(struct vc_data *vc, ushort ct, ushort __user *uct,
776 776 struct uni_pagedict *dict;
777 777 unsigned int d, r, g;
778 778
779 - struct unipair *unilist __free(kvfree) = kvmalloc_objs(*unilist, ct,
780 - GFP_KERNEL);
779 + struct unipair *unilist __free(kvfree) = kvmalloc_array(ct, sizeof(*unilist), GFP_KERNEL);
781 780 if (!unilist)
782 781 return -ENOMEM;
783 782
modified drivers/ufs/core/ufs-mcq.c
@@ -312,20 +312,24 @@ static int ufshcd_mcq_get_tag(struct ufs_hba *hba, struct cq_entry *cqe)
312 312 UFSHCD_NUM_RESERVED;
313 313 }
314 314
315 + static void ufshcd_mcq_compl_cqe(struct ufs_hba *hba, struct cq_entry *cqe)
316 + {
317 + int tag = ufshcd_mcq_get_tag(hba, cqe);
318 +
319 + ufshcd_compl_one_cqe(hba, tag, cqe);
320 + /* After processing the CQE, mark it as an empty (invalid) entry. */
321 + cqe->command_desc_base_addr = 0;
322 + }
323 +
315 324 static void ufshcd_mcq_process_cqe(struct ufs_hba *hba,
316 325 struct ufs_hw_queue *hwq)
317 326 {
318 327 struct cq_entry *cqe = ufshcd_mcq_cur_cqe(hwq);
319 328
320 - if (cqe->command_desc_base_addr) {
321 - int tag = ufshcd_mcq_get_tag(hba, cqe);
322 -
323 - ufshcd_compl_one_cqe(hba, tag, cqe);
324 - /* After processed the cqe, mark it empty (invalid) entry */
325 - cqe->command_desc_base_addr = 0;
326 - } else {
329 + if (cqe->command_desc_base_addr)
330 + ufshcd_mcq_compl_cqe(hba, cqe);
331 + else
327 332 dev_err(hba->dev, "Abnormal CQ entry!\n");
328 - }
329 333 }
330 334
331 335 /*
@@ -333,7 +337,7 @@ static void ufshcd_mcq_process_cqe(struct ufs_hba *hba,
333 337 * controller disabled (HCE = 0). Reading host controller registers, e.g. the
334 338 * CQ tail pointer (CQTPy), may not be safe with the host controller disabled.
335 339 * Hence, iterate over all completion queue entries. This won't result in
336 - * double completions because ufshcd_mcq_process_cqe() clears a CQE after it
340 + * double completions because ufshcd_mcq_compl_cqe() clears a CQE after it
337 341 * has been processed.
338 342 */
339 343 void ufshcd_mcq_compl_all_cqes_lock(struct ufs_hba *hba,
@@ -344,13 +348,13 @@ void ufshcd_mcq_compl_all_cqes_lock(struct ufs_hba *hba,
344 348
345 349 spin_lock_irqsave(&hwq->cq_lock, flags);
346 350 while (entries > 0) {
347 - ufshcd_mcq_process_cqe(hba, hwq);
351 + struct cq_entry *cqe = ufshcd_mcq_cur_cqe(hwq);
352 +
353 + if (cqe->command_desc_base_addr)
354 + ufshcd_mcq_compl_cqe(hba, cqe);
348 355 ufshcd_mcq_inc_cq_head_slot(hwq);
349 356 entries--;
350 357 }
351 -
352 - ufshcd_mcq_update_cq_tail_slot(hwq);
353 - hwq->cq_head_slot = hwq->cq_tail_slot;
354 358 spin_unlock_irqrestore(&hwq->cq_lock, flags);
355 359 }
356 360
modified drivers/ufs/core/ufs-txeq.c
@@ -1073,7 +1073,7 @@ static int __ufshcd_tx_eqtr(struct ufs_hba *hba,
1073 1073 struct ufs_pa_layer_attr *pwr_mode)
1074 1074 {
1075 1075 struct ufshcd_tx_eqtr_data *eqtr_data __free(kfree) =
1076 - kzalloc_obj(*eqtr_data);
1076 + kzalloc(sizeof(*eqtr_data), GFP_KERNEL);
1077 1077 struct tx_eqtr_iter h_iter = {};
1078 1078 struct tx_eqtr_iter d_iter = {};
1079 1079 u32 gear = pwr_mode->gear_tx;
modified drivers/ufs/core/ufshcd.c
@@ -6044,8 +6044,6 @@ static bool ufshcd_mcq_force_compl_one(struct request *rq, void *priv)
6044 6044 if (blk_mq_is_reserved_rq(rq) || !hwq)
6045 6045 return true;
6046 6046
6047 - ufshcd_mcq_compl_all_cqes_lock(hba, hwq);
6048 -
6049 6047 /*
6050 6048 * For those cmds of which the cqes are not present in the cq, complete
6051 6049 * them explicitly.
@@ -6061,19 +6059,6 @@ static bool ufshcd_mcq_force_compl_one(struct request *rq, void *priv)
6061 6059 return true;
6062 6060 }
6063 6061
6064 - static bool ufshcd_mcq_compl_one(struct request *rq, void *priv)
6065 - {
6066 - struct scsi_device *sdev = rq->q->queuedata;
6067 - struct Scsi_Host *shost = sdev->host;
6068 - struct ufs_hba *hba = shost_priv(shost);
6069 - struct ufs_hw_queue *hwq = ufshcd_mcq_req_to_hwq(hba, rq);
6070 -
6071 - if (!blk_mq_is_reserved_rq(rq) && hwq)
6072 - ufshcd_mcq_poll_cqe_lock(hba, hwq);
6073 -
6074 - return true;
6075 - }
6076 -
6077 6062 /**
6078 6063 * ufshcd_mcq_compl_pending_transfer - MCQ mode function. It is
6079 6064 * invoked from the error handler context or ufshcd_host_reset_and_restore()
@@ -6088,10 +6073,18 @@ static bool ufshcd_mcq_compl_one(struct request *rq, void *priv)
6088 6073 static void ufshcd_mcq_compl_pending_transfer(struct ufs_hba *hba,
6089 6074 bool force_compl)
6090 6075 {
6091 - blk_mq_tagset_busy_iter(&hba->host->tag_set,
6092 - force_compl ? ufshcd_mcq_force_compl_one :
6093 - ufshcd_mcq_compl_one,
6094 - NULL);
6076 + int i;
6077 +
6078 + for (i = 0; i < hba->nr_hw_queues; i++) {
6079 + if (force_compl)
6080 + ufshcd_mcq_compl_all_cqes_lock(hba, &hba->uhq[i]);
6081 + else
6082 + ufshcd_mcq_poll_cqe_lock(hba, &hba->uhq[i]);
6083 + }
6084 +
6085 + if (force_compl)
6086 + blk_mq_tagset_busy_iter(&hba->host->tag_set,
6087 + ufshcd_mcq_force_compl_one, NULL);
6095 6088 }
6096 6089
6097 6090 /**
@@ -6817,11 +6810,17 @@ static void ufshcd_err_handling_prepare(struct ufs_hba *hba)
6817 6810 }
6818 6811 /* Wait for ongoing ufshcd_queuecommand() calls to finish. */
6819 6812 blk_mq_quiesce_tagset(&hba->host->tag_set);
6813 + /*
6814 + * Internal commands are submitted on the pseudo SCSI device. Let them
6815 + * through so that the error handler can recover the link.
6816 + */
6817 + blk_mq_unquiesce_queue(hba->host->pseudo_sdev->request_queue);
6820 6818 cancel_work_sync(&hba->eeh_work);
6821 6819 }
6822 6820
6823 6821 static void ufshcd_err_handling_unprepare(struct ufs_hba *hba)
6824 6822 {
6823 + blk_mq_quiesce_queue_nowait(hba->host->pseudo_sdev->request_queue);
6825 6824 blk_mq_unquiesce_tagset(&hba->host->tag_set);
6826 6825 ufshcd_release(hba);
6827 6826 if (ufshcd_is_clkscaling_supported(hba))
@@ -9550,6 +9549,7 @@ static void ufshcd_async_scan(void *data, async_cookie_t cookie)
9550 9549 ret = ufshcd_add_lus(hba);
9551 9550
9552 9551 out:
9552 + ufshcd_release(hba);
9553 9553 pm_runtime_put_sync(hba->dev);
9554 9554
9555 9555 if (ret)
@@ -11272,6 +11272,9 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
11272 11272
11273 11273 ufshcd_init_clk_gating(hba);
11274 11274
11275 + /* Released by ufshcd_async_scan(), or by out_release on failure. */
11276 + ufshcd_hold(hba);
11277 +
11275 11278 ufshcd_init_clk_scaling(hba);
11276 11279
11277 11280 /*
@@ -11292,7 +11295,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
11292 11295 err = devm_request_irq(dev, irq, ufshcd_intr, IRQF_SHARED, UFSHCD, hba);
11293 11296 if (err) {
11294 11297 dev_err(hba->dev, "request irq failed\n");
11295 - goto out_disable;
11298 + goto out_release;
11296 11299 } else {
11297 11300 hba->is_irq_enabled = true;
11298 11301 }
@@ -11308,7 +11311,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
11308 11311 dev_err(hba->dev, "Host controller enable failed\n");
11309 11312 ufshcd_print_evt_hist(hba);
11310 11313 ufshcd_print_host_state(hba);
11311 - goto out_disable;
11314 + goto out_release;
11312 11315 }
11313 11316
11314 11317 INIT_DELAYED_WORK(&hba->rpm_dev_flush_recheck_work, ufshcd_rpm_dev_flush_recheck_work);
@@ -11322,7 +11325,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
11322 11325
11323 11326 err = ufshcd_add_scsi_host(hba);
11324 11327 if (err)
11325 - goto out_disable;
11328 + goto out_release;
11326 11329
11327 11330 /* Hold auto suspend until async scan completes */
11328 11331 pm_runtime_get_sync(dev);
@@ -11342,7 +11345,7 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
11342 11345
11343 11346 err = ufshcd_link_startup(hba);
11344 11347 if (err)
11345 - goto out_disable;
11348 + goto out_release;
11346 11349
11347 11350 if (hba->mcq_enabled)
11348 11351 ufshcd_config_mcq(hba);
@@ -11359,23 +11362,23 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
11359 11362 /* Verify device initialization by sending NOP OUT UPIU */
11360 11363 err = ufshcd_verify_dev_init(hba);
11361 11364 if (err)
11362 - goto out_disable;
11365 + goto out_release;
11363 11366
11364 11367 /* Initiate UFS initialization, and waiting until completion */
11365 11368 err = ufshcd_complete_dev_init(hba);
11366 11369 if (err)
11367 - goto out_disable;
11370 + goto out_release;
11368 11371
11369 11372 err = ufshcd_device_params_init(hba);
11370 11373 if (err)
11371 - goto out_disable;
11374 + goto out_release;
11372 11375
11373 11376 err = ufshcd_post_device_init(hba);
11374 11377
11375 11378 initialized:
11376 11379 ufshcd_process_probe_result(hba, probe_start, err);
11377 11380 if (err)
11378 - goto out_disable;
11381 + goto out_release;
11379 11382
11380 11383 ufs_sysfs_add_nodes(hba->dev);
11381 11384 hba->dme_qos_sysfs_handle = sysfs_get_dirent(hba->dev->kobj.sd,
@@ -11386,6 +11389,8 @@ initialized:
11386 11389 ufshcd_pm_qos_init(hba);
11387 11390 return 0;
11388 11391
11392 + out_release:
11393 + ufshcd_release(hba);
11389 11394 out_disable:
11390 11395 hba->is_irq_enabled = false;
11391 11396 ufshcd_hba_exit(hba);
modified drivers/ufs/host/ufs-mediatek.c
@@ -509,6 +509,7 @@ static int ufs_mtk_mphy_power_on(struct ufs_hba *hba, bool on)
509 509 struct ufs_mtk_host *host = ufshcd_get_variant(hba);
510 510 struct phy *mphy = host->mphy;
511 511 struct arm_smccc_res res;
512 + int err;
512 513 int ret = 0;
513 514
514 515 if (!mphy || !(on ^ host->mphy_powered_on))
@@ -523,7 +524,18 @@ static int ufs_mtk_mphy_power_on(struct ufs_hba *hba, bool on)
523 524 usleep_range(200, 210);
524 525 ufs_mtk_va09_pwr_ctrl(res, 1);
525 526 }
526 - phy_power_on(mphy);
527 + ret = phy_power_on(mphy);
528 + if (ret) {
529 + if (ufs_mtk_is_va09_supported(hba)) {
530 + ufs_mtk_va09_pwr_ctrl(res, 0);
531 + err = regulator_disable(host->reg_va09);
532 + if (err)
533 + dev_err(hba->dev,
534 + "failed to unwind va09: %d\n", err);
535 + }
536 + dev_err(hba->dev, "failed to enable mphy: %d\n", ret);
537 + return ret;
538 + }
527 539 } else {
528 540 phy_power_off(mphy);
529 541 if (ufs_mtk_is_va09_supported(hba)) {
@@ -1295,7 +1307,9 @@ static int ufs_mtk_init(struct ufs_hba *hba)
1295 1307 *
1296 1308 * Enable phy clocks specifically here.
1297 1309 */
1298 - ufs_mtk_mphy_power_on(hba, true);
1310 + err = ufs_mtk_mphy_power_on(hba, true);
1311 + if (err)
1312 + goto out_variant_clear;
1299 1313
1300 1314 if (ufs_mtk_is_rtff_mtcmos(hba)) {
1301 1315 /* First Restore here, to avoid backup unexpected value */
modified drivers/ufs/host/ufs-qcom.c
@@ -2770,7 +2770,7 @@ static int ufs_qcom_get_rx_fom(struct ufs_hba *hba,
2770 2770 struct tx_eqtr_iter *d_iter)
2771 2771 {
2772 2772 struct ufshcd_tx_eq_params *params __free(kfree) =
2773 - kzalloc_obj(*params);
2773 + kzalloc(sizeof(*params), GFP_KERNEL);
2774 2774 struct ufs_qcom_host *host = ufshcd_get_variant(hba);
2775 2775 struct ufs_pa_layer_attr old_pwr_info;
2776 2776 u32 fom[PA_MAXDATALANES] = { 0 };
modified drivers/ufs/host/ufshcd-pltfrm.c
@@ -206,7 +206,11 @@ static void ufshcd_init_lanes_per_dir(struct ufs_hba *hba)
206 206 dev_dbg(hba->dev,
207 207 "%s: failed to read lanes-per-direction, ret=%d\n",
208 208 __func__, ret);
209 - hba->lanes_per_direction = UFSHCD_DEFAULT_LANES_PER_DIRECTION;
209 + /* Old R-Car S4 DTBs lack "lanes-per-direction = <1>" */
210 + if (of_device_is_compatible(dev->of_node, "renesas,r8a779f0-ufs"))
211 + hba->lanes_per_direction = 1;
212 + else
213 + hba->lanes_per_direction = UFSHCD_DEFAULT_LANES_PER_DIRECTION;
210 214 }
211 215 }
212 216
modified drivers/usb/cdns3/cdnsp-gadget.c
@@ -1338,6 +1338,7 @@ static int cdnsp_run(struct cdnsp_device *pdev,
1338 1338
1339 1339 cdnsp_gadget_ep0_desc.wMaxPacketSize = cpu_to_le16(512);
1340 1340
1341 +
1341 1342 ret = cdnsp_start(pdev);
1342 1343 if (ret) {
1343 1344 ret = -ENODEV;
@@ -1836,82 +1837,6 @@ static void cdnsp_get_rev_cap(struct cdnsp_device *pdev)
1836 1837 readl(&pdev->rev_cap->tx_buff_size));
1837 1838 }
1838 1839
1839 - static void cdnsp_set_event_deq(struct cdnsp_device *pdev)
1840 - {
1841 - dma_addr_t deq;
1842 - u64 temp;
1843 -
1844 - deq = cdnsp_trb_virt_to_dma(pdev->event_ring->deq_seg,
1845 - pdev->event_ring->dequeue);
1846 -
1847 - /* Update controller event ring dequeue pointer */
1848 - temp = cdnsp_read_64(&pdev->ir_set->erst_dequeue);
1849 - temp &= ERST_PTR_MASK;
1850 -
1851 - /*
1852 - * Don't clear the EHB bit (which is RW1C) because
1853 - * there might be more events to service.
1854 - */
1855 - temp &= ~ERST_EHB;
1856 -
1857 - cdnsp_write_64(((u64)deq & (u64)~ERST_PTR_MASK) | temp,
1858 - &pdev->ir_set->erst_dequeue);
1859 - }
1860 -
1861 - static void cdnsp_add_interrupter(struct cdnsp_device *pdev)
1862 - {
1863 - u64 erst_base;
1864 - u32 erst_size;
1865 -
1866 - /* Set ERST count with the number of entries in the segment table. */
1867 - erst_size = readl(&pdev->ir_set->erst_size);
1868 - erst_size &= ERST_SIZE_MASK;
1869 - erst_size |= ERST_NUM_SEGS;
1870 - writel(erst_size, &pdev->ir_set->erst_size);
1871 -
1872 - /* Set the segment table base address. */
1873 - erst_base = cdnsp_read_64(&pdev->ir_set->erst_base);
1874 - erst_base &= ERST_PTR_MASK;
1875 - erst_base |= (pdev->erst.erst_dma_addr & (u64)~ERST_PTR_MASK);
1876 - cdnsp_write_64(erst_base, &pdev->ir_set->erst_base);
1877 -
1878 - /* Set the event ring dequeue address. */
1879 - cdnsp_set_event_deq(pdev);
1880 - }
1881 -
1882 - /* Set up basic CDNSP registers */
1883 - static void cdnsp_init(struct cdnsp_device *pdev)
1884 - {
1885 - unsigned int val;
1886 - u64 val_64;
1887 -
1888 - val = readl(&pdev->op_regs->config_reg);
1889 - val |= ((val & ~MAX_DEVS) | CDNSP_DEV_MAX_SLOTS) | CONFIG_U3E;
1890 - writel(val, &pdev->op_regs->config_reg);
1891 -
1892 - /* Initialize the Command ring */
1893 - cdnsp_ring_init(pdev, pdev->cmd_ring);
1894 -
1895 - /* Set the address in the Command Ring Control register */
1896 - val_64 = cdnsp_read_64(&pdev->op_regs->cmd_ring);
1897 - val_64 = (val_64 & (u64)CMD_RING_RSVD_BITS) |
1898 - (pdev->cmd_ring->first_seg->dma & (u64)~CMD_RING_RSVD_BITS) |
1899 - pdev->cmd_ring->cycle_state;
1900 - cdnsp_write_64(val_64, &pdev->op_regs->cmd_ring);
1901 -
1902 - /* Set Device Context Base Address Array pointer */
1903 - cdnsp_write_64(pdev->dcbaa->dma, &pdev->op_regs->dcbaa_ptr);
1904 -
1905 - /* Set Doorbell array pointer */
1906 - val = readl(&pdev->cap_regs->db_off);
1907 - val &= DBOFF_MASK;
1908 - pdev->dba = (void __iomem *)pdev->cap_regs + val;
1909 -
1910 - /* Initialize the Primary interrupter */
1911 - cdnsp_ring_init(pdev, pdev->event_ring);
1912 - cdnsp_add_interrupter(pdev);
1913 - }
1914 -
1915 1840 static int cdnsp_gen_setup(struct cdnsp_device *pdev)
1916 1841 {
1917 1842 int ret;
@@ -1977,8 +1902,6 @@ static int cdnsp_gen_setup(struct cdnsp_device *pdev)
1977 1902 if (ret)
1978 1903 return ret;
1979 1904
1980 - cdnsp_init(pdev);
1981 -
1982 1905 /*
1983 1906 * Software workaround for U1: after transition
1984 1907 * to U1 the controller starts gating clock, and in some cases,
@@ -2108,6 +2031,9 @@ static int cdnsp_gadget_suspend(struct cdns *cdns, bool do_wakeup)
2108 2031 struct cdnsp_device *pdev = cdns->gadget_dev;
2109 2032 unsigned long flags;
2110 2033
2034 + if (pdev->link_state == XDEV_U3)
2035 + return 0;
2036 +
2111 2037 spin_lock_irqsave(&pdev->lock, flags);
2112 2038 cdnsp_disconnect_gadget(pdev);
2113 2039 cdnsp_stop(pdev);
@@ -2121,38 +2047,12 @@ static int cdnsp_gadget_resume(struct cdns *cdns, bool lost_power)
2121 2047 struct cdnsp_device *pdev = cdns->gadget_dev;
2122 2048 enum usb_device_speed max_speed;
2123 2049 unsigned long flags;
2124 - bool context_lost;
2125 - u32 val;
2126 2050 int ret;
2127 2051
2128 2052 if (!pdev->gadget_driver)
2129 2053 return 0;
2130 2054
2131 2055 spin_lock_irqsave(&pdev->lock, flags);
2132 - val = readl(&pdev->port3x_regs->mode_2);
2133 - context_lost = !!(val & CFG_3XPORT_U1_PIPE_CLK_GATE_EN) || lost_power;
2134 -
2135 - if (context_lost) {
2136 - cdnsp_halt(pdev);
2137 - cdnsp_set_apb_timeout_value(pdev);
2138 -
2139 - /* Reset the internal controller memory state and registers. */
2140 - ret = cdnsp_reset(pdev);
2141 - if (ret)
2142 - goto unlock;
2143 -
2144 - val = readl(&pdev->port3x_regs->mode_2);
2145 - val &= ~CFG_3XPORT_U1_PIPE_CLK_GATE_EN;
2146 - writel(val, &pdev->port3x_regs->mode_2);
2147 -
2148 - cdnsp_clear_cmd_ring(pdev);
2149 -
2150 - memset(pdev->event_ring->first_seg->trbs, 0,
2151 - sizeof(union cdnsp_trb) * (TRBS_PER_SEGMENT));
2152 -
2153 - cdnsp_init(pdev);
2154 - }
2155 -
2156 2056 max_speed = pdev->gadget_driver->max_speed;
2157 2057
2158 2058 /* Limit speed if necessary. */
@@ -2160,10 +2060,9 @@ static int cdnsp_gadget_resume(struct cdns *cdns, bool lost_power)
2160 2060
2161 2061 ret = cdnsp_run(pdev, max_speed);
2162 2062
2163 - if (!context_lost && pdev->link_state == XDEV_U3)
2063 + if (pdev->link_state == XDEV_U3)
2164 2064 __cdnsp_gadget_wakeup(pdev);
2165 2065
2166 - unlock:
2167 2066 spin_unlock_irqrestore(&pdev->lock, flags);
2168 2067
2169 2068 return ret;
modified drivers/usb/cdns3/cdnsp-gadget.h
@@ -1510,7 +1510,6 @@ int cdnsp_endpoint_init(struct cdnsp_device *pdev,
1510 1510 int cdnsp_ring_expansion(struct cdnsp_device *pdev,
1511 1511 struct cdnsp_ring *ring,
1512 1512 unsigned int num_trbs, gfp_t flags);
1513 - void cdnsp_ring_init(struct cdnsp_device *pdev, struct cdnsp_ring *ring);
1514 1513 struct cdnsp_ring *cdnsp_dma_to_transfer_ring(struct cdnsp_ep *ep, u64 address);
1515 1514 int cdnsp_alloc_stream_info(struct cdnsp_device *pdev,
1516 1515 struct cdnsp_ep *pep,
modified drivers/usb/cdns3/cdnsp-mem.c
@@ -394,6 +394,13 @@ static struct cdnsp_ring *cdnsp_ring_alloc(struct cdnsp_device *pdev,
394 394 if (ret)
395 395 goto fail;
396 396
397 + /* Only event ring does not use link TRB. */
398 + if (type != TYPE_EVENT)
399 + ring->last_seg->trbs[TRBS_PER_SEGMENT - 1].link.control |=
400 + cpu_to_le32(LINK_TOGGLE);
401 +
402 + cdnsp_initialize_ring_info(ring);
403 + trace_cdnsp_ring_alloc(ring);
397 404 return ring;
398 405 fail:
399 406 kfree(ring);
@@ -596,7 +603,6 @@ int cdnsp_alloc_stream_info(struct cdnsp_device *pdev,
596 603 if (!cur_ring)
597 604 goto cleanup_rings;
598 605
599 - cdnsp_ring_init(pdev, cur_ring);
600 606 cur_ring->stream_id = cur_stream;
601 607 cur_ring->trb_address_map = &stream_info->trb_address_map;
602 608
@@ -692,8 +698,6 @@ static int cdnsp_alloc_priv_device(struct cdnsp_device *pdev)
692 698 if (!pdev->eps[0].ring)
693 699 goto fail;
694 700
695 - cdnsp_ring_init(pdev, pdev->eps[0].ring);
696 -
697 701 /* Point to output device context in dcbaa. */
698 702 pdev->dcbaa->dev_context_ptrs[1] = cpu_to_le64(pdev->out_ctx.dma);
699 703 pdev->cmd.in_ctx = &pdev->in_ctx;
@@ -987,8 +991,6 @@ int cdnsp_endpoint_init(struct cdnsp_device *pdev,
987 991 if (!pep->ring)
988 992 return -ENOMEM;
989 993
990 - cdnsp_ring_init(pdev, pep->ring);
991 -
992 994 pep->skip = false;
993 995
994 996 /* Fill the endpoint context */
@@ -1094,6 +1096,28 @@ void cdnsp_mem_cleanup(struct cdnsp_device *pdev)
1094 1096 pdev->active_port = NULL;
1095 1097 }
1096 1098
1099 + static void cdnsp_set_event_deq(struct cdnsp_device *pdev)
1100 + {
1101 + dma_addr_t deq;
1102 + u64 temp;
1103 +
1104 + deq = cdnsp_trb_virt_to_dma(pdev->event_ring->deq_seg,
1105 + pdev->event_ring->dequeue);
1106 +
1107 + /* Update controller event ring dequeue pointer */
1108 + temp = cdnsp_read_64(&pdev->ir_set->erst_dequeue);
1109 + temp &= ERST_PTR_MASK;
1110 +
1111 + /*
1112 + * Don't clear the EHB bit (which is RW1C) because
1113 + * there might be more events to service.
1114 + */
1115 + temp &= ~ERST_EHB;
1116 +
1117 + cdnsp_write_64(((u64)deq & (u64)~ERST_PTR_MASK) | temp,
1118 + &pdev->ir_set->erst_dequeue);
1119 + }
1120 +
1097 1121 static void cdnsp_add_in_port(struct cdnsp_device *pdev,
1098 1122 struct cdnsp_port *port,
1099 1123 __le32 __iomem *addr)
@@ -1202,36 +1226,6 @@ static int cdnsp_setup_port_arrays(struct cdnsp_device *pdev)
1202 1226 return 0;
1203 1227 }
1204 1228
1205 - static void cdnsp_initialize_ring_segments(struct cdnsp_device *pdev, struct cdnsp_ring *ring)
1206 - {
1207 - struct cdnsp_segment *seg;
1208 -
1209 - /* Only event ring does not use link TRB. */
1210 - if (ring->type == TYPE_EVENT)
1211 - return;
1212 -
1213 - seg = ring->first_seg;
1214 -
1215 - while (seg) {
1216 - struct cdnsp_segment *next = seg->next;
1217 -
1218 - cdnsp_link_segments(pdev, seg, next, ring->type);
1219 - if (next == ring->first_seg)
1220 - break;
1221 -
1222 - seg = next;
1223 - }
1224 -
1225 - ring->last_seg->trbs[TRBS_PER_SEGMENT - 1].link.control |= cpu_to_le32(LINK_TOGGLE);
1226 - }
1227 -
1228 - void cdnsp_ring_init(struct cdnsp_device *pdev, struct cdnsp_ring *ring)
1229 - {
1230 - cdnsp_initialize_ring_segments(pdev, ring);
1231 - cdnsp_initialize_ring_info(ring);
1232 - trace_cdnsp_ring_alloc(ring);
1233 - }
1234 -
1235 1229 /*
1236 1230 * Initialize memory for CDNSP (one-time init).
1237 1231 *
@@ -1243,8 +1237,10 @@ int cdnsp_mem_init(struct cdnsp_device *pdev)
1243 1237 {
1244 1238 struct device *dev = pdev->dev;
1245 1239 int ret = -ENOMEM;
1240 + unsigned int val;
1246 1241 dma_addr_t dma;
1247 1242 u32 page_size;
1243 + u64 val_64;
1248 1244
1249 1245 /*
1250 1246 * Use 4K pages, since that's common and the minimum the
@@ -1252,6 +1248,10 @@ int cdnsp_mem_init(struct cdnsp_device *pdev)
1252 1248 */
1253 1249 page_size = 1 << 12;
1254 1250
1251 + val = readl(&pdev->op_regs->config_reg);
1252 + val |= ((val & ~MAX_DEVS) | CDNSP_DEV_MAX_SLOTS) | CONFIG_U3E;
1253 + writel(val, &pdev->op_regs->config_reg);
1254 +
1255 1255 /*
1256 1256 * Doorbell array must be physically contiguous
1257 1257 * and 64-byte (cache line) aligned.
@@ -1263,6 +1263,8 @@ int cdnsp_mem_init(struct cdnsp_device *pdev)
1263 1263
1264 1264 pdev->dcbaa->dma = dma;
1265 1265
1266 + cdnsp_write_64(dma, &pdev->op_regs->dcbaa_ptr);
1267 +
1266 1268 /*
1267 1269 * Initialize the ring segment pool. The ring must be a contiguous
1268 1270 * structure comprised of TRBs. The TRBs must be 16 byte aligned,
@@ -1288,6 +1290,17 @@ int cdnsp_mem_init(struct cdnsp_device *pdev)
1288 1290 if (!pdev->cmd_ring)
1289 1291 goto destroy_device_pool;
1290 1292
1293 + /* Set the address in the Command Ring Control register */
1294 + val_64 = cdnsp_read_64(&pdev->op_regs->cmd_ring);
1295 + val_64 = (val_64 & (u64)CMD_RING_RSVD_BITS) |
1296 + (pdev->cmd_ring->first_seg->dma & (u64)~CMD_RING_RSVD_BITS) |
1297 + pdev->cmd_ring->cycle_state;
1298 + cdnsp_write_64(val_64, &pdev->op_regs->cmd_ring);
1299 +
1300 + val = readl(&pdev->cap_regs->db_off);
1301 + val &= DBOFF_MASK;
1302 + pdev->dba = (void __iomem *)pdev->cap_regs + val;
1303 +
1291 1304 /* Set ir_set to interrupt register set 0 */
1292 1305 pdev->ir_set = &pdev->run_regs->ir_set[0];
1293 1306
@@ -1304,6 +1317,21 @@ int cdnsp_mem_init(struct cdnsp_device *pdev)
1304 1317 if (ret)
1305 1318 goto free_event_ring;
1306 1319
1320 + /* Set ERST count with the number of entries in the segment table. */
1321 + val = readl(&pdev->ir_set->erst_size);
1322 + val &= ERST_SIZE_MASK;
1323 + val |= ERST_NUM_SEGS;
1324 + writel(val, &pdev->ir_set->erst_size);
1325 +
1326 + /* Set the segment table base address. */
1327 + val_64 = cdnsp_read_64(&pdev->ir_set->erst_base);
1328 + val_64 &= ERST_PTR_MASK;
1329 + val_64 |= (pdev->erst.erst_dma_addr & (u64)~ERST_PTR_MASK);
1330 + cdnsp_write_64(val_64, &pdev->ir_set->erst_base);
1331 +
1332 + /* Set the event ring dequeue address. */
1333 + cdnsp_set_event_deq(pdev);
1334 +
1307 1335 ret = cdnsp_setup_port_arrays(pdev);
1308 1336 if (ret)
1309 1337 goto free_erst;
modified drivers/usb/dwc3/dwc3-google.c
@@ -442,7 +442,6 @@ static int dwc3_google_probe(struct platform_device *pdev)
442 442 probe_data.dwc = &google->dwc;
443 443 probe_data.res = res;
444 444 probe_data.ignore_clocks_and_resets = true;
445 - probe_data.properties = DWC3_DEFAULT_PROPERTIES;
446 445 ret = dwc3_core_probe(&probe_data);
447 446 if (ret) {
448 447 ret = dev_err_probe(dev, ret, "failed to register DWC3 Core\n");
modified drivers/usb/dwc3/ep0.c
@@ -304,7 +304,7 @@ void dwc3_ep0_out_start(struct dwc3 *dwc)
304 304
305 305 dwc3_ep->flags &= ~DWC3_EP_DELAY_STOP;
306 306 if (dwc->connected)
307 - dwc3_stop_active_transfer(dwc3_ep, false, true);
307 + dwc3_stop_active_transfer(dwc3_ep, true, true);
308 308 else
309 309 dwc3_remove_requests(dwc, dwc3_ep, -ESHUTDOWN);
310 310 }
modified drivers/usb/dwc3/gadget.c
@@ -1004,7 +1004,7 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action)
1004 1004 * controller to generate an ERDY to initiate the
1005 1005 * stream.
1006 1006 */
1007 - dwc3_stop_active_transfer(dep, false, true);
1007 + dwc3_stop_active_transfer(dep, true, true);
1008 1008
1009 1009 /*
1010 1010 * All stream eps will reinitiate stream on NoStream
@@ -1032,7 +1032,7 @@ void dwc3_remove_requests(struct dwc3 *dwc, struct dwc3_ep *dep, int status)
1032 1032 {
1033 1033 struct dwc3_request *req;
1034 1034
1035 - dwc3_stop_active_transfer(dep, false, false);
1035 + dwc3_stop_active_transfer(dep, true, false);
1036 1036
1037 1037 /* If endxfer is delayed, avoid unmapping requests */
1038 1038 if (dep->flags & DWC3_EP_DELAY_STOP)
@@ -1720,7 +1720,7 @@ static int __dwc3_gadget_kick_transfer(struct dwc3_ep *dep)
1720 1720 if (ret == -EAGAIN)
1721 1721 return ret;
1722 1722
1723 - dwc3_stop_active_transfer(dep, false, true);
1723 + dwc3_stop_active_transfer(dep, true, true);
1724 1724
1725 1725 list_for_each_entry_safe(req, tmp, &dep->started_list, list)
1726 1726 dwc3_gadget_move_cancelled_request(req, DWC3_REQUEST_STATUS_DEQUEUED);
@@ -1757,11 +1757,6 @@ static int __dwc3_gadget_get_frame(struct dwc3 *dwc)
1757 1757 * the controller won't update the TRB progress on command
1758 1758 * completion. It also won't clear the HWO bit in the TRB.
1759 1759 * The command will also not complete immediately in that case.
1760 - *
1761 - * Older programming guide revisions recommended setting ForceRM to 1
1762 - * when ending a transfer. Newer programming guide revisions now
1763 - * recommend keeping ForceRM cleared, and TRBs are properly updated
1764 - * on command completion.
1765 1760 */
1766 1761 static int __dwc3_stop_active_transfer(struct dwc3_ep *dep, bool force, bool interrupt)
1767 1762 {
@@ -1887,7 +1882,7 @@ static int dwc3_gadget_start_isoc_quirk(struct dwc3_ep *dep)
1887 1882 * to wait for the next XferNotReady to test the command again
1888 1883 */
1889 1884 if (cmd_status == 0) {
1890 - dwc3_stop_active_transfer(dep, false, true);
1885 + dwc3_stop_active_transfer(dep, true, true);
1891 1886 return 0;
1892 1887 }
1893 1888 }
@@ -2170,7 +2165,7 @@ static int dwc3_gadget_ep_dequeue(struct usb_ep *ep,
2170 2165 struct dwc3_request *t;
2171 2166
2172 2167 /* wait until it is processed */
2173 - dwc3_stop_active_transfer(dep, false, true);
2168 + dwc3_stop_active_transfer(dep, true, true);
2174 2169
2175 2170 /*
2176 2171 * Remove any started request if the transfer is
@@ -2247,7 +2242,7 @@ int __dwc3_gadget_ep_set_halt(struct dwc3_ep *dep, int value, int protocol)
2247 2242 return 0;
2248 2243 }
2249 2244
2250 - dwc3_stop_active_transfer(dep, false, true);
2245 + dwc3_stop_active_transfer(dep, true, true);
2251 2246
2252 2247 list_for_each_entry_safe(req, tmp, &dep->started_list, list)
2253 2248 dwc3_gadget_move_cancelled_request(req, DWC3_REQUEST_STATUS_STALLED);
@@ -3373,7 +3368,7 @@ static void dwc3_nostream_work(struct work_struct *work)
3373 3368 dwc3_send_gadget_generic_command(dwc, cmd, dep->number);
3374 3369 } else {
3375 3370 dep->flags |= DWC3_EP_DELAY_START;
3376 - dwc3_stop_active_transfer(dep, false, true);
3371 + dwc3_stop_active_transfer(dep, true, true);
3377 3372 spin_unlock_irqrestore(&dwc->lock, flags);
3378 3373 return;
3379 3374 }
@@ -3731,7 +3726,7 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep,
3731 3726 if (usb_endpoint_xfer_isoc(dep->endpoint.desc) &&
3732 3727 list_empty(&dep->started_list) &&
3733 3728 (list_empty(&dep->pending_list) || status == -EXDEV))
3734 - dwc3_stop_active_transfer(dep, false, true);
3729 + dwc3_stop_active_transfer(dep, true, true);
3735 3730 else if (dwc3_gadget_ep_should_continue(dep))
3736 3731 if (__dwc3_gadget_kick_transfer(dep) == 0)
3737 3732 no_started_trb = false;
modified drivers/usb/gadget/function/f_mass_storage.c
@@ -2747,9 +2747,6 @@ int fsg_common_set_num_buffers(struct fsg_common *common, unsigned int n)
2747 2747 struct fsg_buffhd *bh, *buffhds;
2748 2748 int i;
2749 2749
2750 - if (n < 2)
2751 - return -EINVAL;
2752 -
2753 2750 buffhds = kzalloc_objs(*buffhds, n);
2754 2751 if (!buffhds)
2755 2752 return -ENOMEM;
@@ -2963,7 +2960,7 @@ EXPORT_SYMBOL_GPL(fsg_common_create_lun);
2963 2960
2964 2961 int fsg_common_create_luns(struct fsg_common *common, struct fsg_config *cfg)
2965 2962 {
2966 - char buf[14];
2963 + char buf[8]; /* enough for 100000000 different numbers, decimal */
2967 2964 int i, rc;
2968 2965
2969 2966 fsg_common_remove_luns(common);
modified drivers/usb/gadget/function/f_midi.c
@@ -879,6 +879,7 @@ static int f_midi_bind(struct usb_configuration *c, struct usb_function *f)
879 879 int status, n, jack = 1, i = 0, endpoint_descriptor_index = 0;
880 880
881 881 midi->gadget = cdev->gadget;
882 + INIT_WORK(&midi->work, f_midi_in_work);
882 883 status = f_midi_register_card(midi);
883 884 if (status < 0)
884 885 goto fail_register;
@@ -1376,7 +1377,6 @@ static struct usb_function *f_midi_alloc(struct usb_function_instance *fi)
1376 1377 status = -ENOMEM;
1377 1378 goto midi_free;
1378 1379 }
1379 - INIT_WORK(&midi->work, f_midi_in_work);
1380 1380 midi->out_ports = opts->out_ports;
1381 1381 midi->index = opts->index;
1382 1382 midi->buflen = opts->buflen;
modified drivers/usb/gadget/function/f_midi2.c
@@ -1145,7 +1145,7 @@ static int f_midi2_alloc_ep_reqs(struct f_midi2_usb_ep *usb_ep)
1145 1145 if (!usb_ep->reqs)
1146 1146 return -EINVAL;
1147 1147
1148 - for (i = 0; i < usb_ep->num_reqs; i++) {
1148 + for (i = 0; i < midi2->info.num_reqs; i++) {
1149 1149 if (usb_ep->reqs[i].req)
1150 1150 continue;
1151 1151 usb_ep->reqs[i].req = alloc_ep_req(usb_ep->usb_ep,
@@ -1160,9 +1160,10 @@ static int f_midi2_alloc_ep_reqs(struct f_midi2_usb_ep *usb_ep)
1160 1160 /* Free allocated requests */
1161 1161 static void f_midi2_free_ep_reqs(struct f_midi2_usb_ep *usb_ep)
1162 1162 {
1163 + struct f_midi2 *midi2 = usb_ep->card;
1163 1164 int i;
1164 1165
1165 - for (i = 0; i < usb_ep->num_reqs; i++) {
1166 + for (i = 0; i < midi2->info.num_reqs; i++) {
1166 1167 if (!usb_ep->reqs[i].req)
1167 1168 continue;
1168 1169 free_ep_req(usb_ep->usb_ep, usb_ep->reqs[i].req);
@@ -2177,13 +2178,13 @@ end:
2177 2178
2178 2179 /* generic show/store for string */
2179 2180 static ssize_t f_midi2_opts_str_show(struct f_midi2_opts *opts,
2180 - const char **strp, char *page)
2181 + const char *str, char *page)
2181 2182 {
2182 2183 int result = 0;
2183 2184
2184 2185 mutex_lock(&opts->lock);
2185 - if (*strp)
2186 - result = scnprintf(page, PAGE_SIZE, "%s\n", *strp);
2186 + if (str)
2187 + result = scnprintf(page, PAGE_SIZE, "%s\n", str);
2187 2188 mutex_unlock(&opts->lock);
2188 2189 return result;
2189 2190 }
@@ -2277,7 +2278,7 @@ static ssize_t f_midi2_block_opts_name_show(struct config_item *item,
2277 2278 {
2278 2279 struct f_midi2_block_opts *opts = to_f_midi2_block_opts(item);
2279 2280
2280 - return f_midi2_opts_str_show(opts->ep->opts, &opts->info.name, page);
2281 + return f_midi2_opts_str_show(opts->ep->opts, opts->info.name, page);
2281 2282 }
2282 2283
2283 2284 static ssize_t f_midi2_block_opts_name_store(struct config_item *item,
@@ -2434,7 +2435,7 @@ static ssize_t f_midi2_ep_opts_##name##_show(struct config_item *item, \
2434 2435 char *page) \
2435 2436 { \
2436 2437 struct f_midi2_ep_opts *opts = to_f_midi2_ep_opts(item); \
2437 - return f_midi2_opts_str_show(opts->opts, &opts->info.name, page);\
2438 + return f_midi2_opts_str_show(opts->opts, opts->info.name, page);\
2438 2439 } \
2439 2440 \
2440 2441 static ssize_t f_midi2_ep_opts_##name##_store(struct config_item *item, \
@@ -2589,7 +2590,7 @@ static ssize_t f_midi2_opts_iface_name_show(struct config_item *item,
2589 2590 {
2590 2591 struct f_midi2_opts *opts = to_f_midi2_opts(item);
2591 2592
2592 - return f_midi2_opts_str_show(opts, &opts->info.iface_name, page);
2593 + return f_midi2_opts_str_show(opts, opts->info.iface_name, page);
2593 2594 }
2594 2595
2595 2596 static ssize_t f_midi2_opts_iface_name_store(struct config_item *item,
modified drivers/usb/gadget/function/f_ncm.c
@@ -1766,7 +1766,7 @@ static struct usb_function *ncm_alloc(struct usb_function_instance *fi)
1766 1766 int status;
1767 1767
1768 1768 /* allocate and initialize one new instance */
1769 - ncm = kzalloc_obj(*ncm);
1769 + ncm = kzalloc(sizeof(*ncm), GFP_KERNEL);
1770 1770 if (!ncm)
1771 1771 return ERR_PTR(-ENOMEM);
1772 1772
modified drivers/usb/gadget/functions.c
@@ -70,7 +70,7 @@ void usb_put_function_instance(struct usb_function_instance *fi)
70 70 {
71 71 struct module *mod;
72 72
73 - if (!fi || !fi->fd)
73 + if (!fi)
74 74 return;
75 75
76 76 mod = fi->fd->mod;
modified drivers/usb/gadget/legacy/inode.c
@@ -1260,11 +1260,10 @@ out:
1260 1260 static long gadget_dev_ioctl (struct file *fd, unsigned code, unsigned long value)
1261 1261 {
1262 1262 struct dev_data *dev = fd->private_data;
1263 - struct usb_gadget *gadget;
1263 + struct usb_gadget *gadget = dev->gadget;
1264 1264 long ret = -ENOTTY;
1265 1265
1266 1266 spin_lock_irq(&dev->lock);
1267 - gadget = dev->gadget;
1268 1267 if (dev->state == STATE_DEV_OPENED ||
1269 1268 dev->state == STATE_DEV_UNBOUND) {
1270 1269 /* Not bound to a UDC */
modified drivers/usb/host/xhci-mem.c
@@ -2301,7 +2301,7 @@ xhci_alloc_interrupter(struct xhci_hcd *xhci, unsigned int segs, gfp_t flags)
2301 2301 if (!segs)
2302 2302 segs = ERST_DEFAULT_SEGS;
2303 2303
2304 - max_segs = BIT(FIELD_GET(HCS_ERST_MAX, xhci->hcs_params2));
2304 + max_segs = FIELD_GET(HCS_ERST_MAX, xhci->hcs_params2) << 2;
2305 2305 segs = min(segs, max_segs);
2306 2306
2307 2307 ir = kzalloc_node(sizeof(*ir), flags, dev_to_node(dev));
modified drivers/usb/host/xhci-ring.c
@@ -824,18 +824,21 @@ static void xhci_giveback_urb_in_irq(struct xhci_hcd *xhci,
824 824 usb_hcd_giveback_urb(hcd, urb, status);
825 825 }
826 826
827 - static void xhci_unmap_one_bounce_buffer(struct xhci_hcd *xhci,
828 - struct xhci_ring *ring, struct xhci_td *td,
829 - struct xhci_segment *seg)
827 + static void xhci_unmap_td_bounce_buffer(struct xhci_hcd *xhci,
828 + struct xhci_ring *ring, struct xhci_td *td)
830 829 {
831 830 struct device *dev = xhci_to_hcd(xhci)->self.sysdev;
831 + struct xhci_segment *seg = td->bounce_seg;
832 832 struct urb *urb = td->urb;
833 833 size_t len;
834 834
835 + if (!ring || !seg || !urb)
836 + return;
837 +
835 838 if (usb_urb_dir_out(urb)) {
836 839 dma_unmap_single(dev, seg->bounce_dma, ring->bounce_buf_len,
837 840 DMA_TO_DEVICE);
838 - goto done;
841 + return;
839 842 }
840 843
841 844 dma_unmap_single(dev, seg->bounce_dma, ring->bounce_buf_len,
@@ -851,29 +854,10 @@ static void xhci_unmap_one_bounce_buffer(struct xhci_hcd *xhci,
851 854 memcpy(urb->transfer_buffer + seg->bounce_offs, seg->bounce_buf,
852 855 seg->bounce_len);
853 856 }
854 - done:
855 857 seg->bounce_len = 0;
856 858 seg->bounce_offs = 0;
857 859 }
858 860
859 - static void xhci_unmap_td_bounce_buffer(struct xhci_hcd *xhci,
860 - struct xhci_ring *ring, struct xhci_td *td)
861 - {
862 - struct xhci_segment *seg;
863 - int i = 0;
864 -
865 - if (!td->bounce_seg || !ring || !td->urb)
866 - return;
867 -
868 - /* td->bounce_seg is the last one bounced, unmap them all */
869 - for (seg = td->start_seg; i++ < ring->num_segs; seg = seg->next) {
870 - if (seg->bounce_len)
871 - xhci_unmap_one_bounce_buffer(xhci, ring, td, seg);
872 - if (seg == td->bounce_seg)
873 - break;
874 - }
875 - }
876 -
877 861 static void xhci_td_cleanup(struct xhci_hcd *xhci, struct xhci_td *td,
878 862 struct xhci_ring *ep_ring, int status)
879 863 {
@@ -3701,7 +3685,7 @@ int xhci_queue_bulk_tx(struct xhci_hcd *xhci, gfp_t mem_flags,
3701 3685 &trb_buff_len,
3702 3686 ring->enq_seg)) {
3703 3687 send_addr = ring->enq_seg->bounce_dma;
3704 - /* TD bounced at least, and last on this seg */
3688 + /* assuming TD won't span 2 segs */
3705 3689 td->bounce_seg = ring->enq_seg;
3706 3690 }
3707 3691 }
@@ -4328,16 +4312,11 @@ int xhci_queue_isoc_tx_prepare(struct xhci_hcd *xhci, gfp_t mem_flags,
4328 4312 check_interval(urb, ep_ctx);
4329 4313
4330 4314 /*
4331 - * Schedule the URB discontiguously if all previous URBs have completed.
4332 - * XXX core can't tell if completions are pending but not running yet.
4315 + * Check if this starts the isoc data flow. Relies on hw setting ep ctx
4316 + * state after doorbell ring. Consider adding list_empty(td_list) check
4333 4317 */
4334 - if (list_empty(&ep_ring->td_list) &&
4335 - !hcd_periodic_completion_in_progress(xhci_to_hcd(xhci), urb->ep)) {
4336 - if (GET_EP_CTX_STATE(ep_ctx) == EP_STATE_RUNNING)
4337 - xhci_dbg(xhci, "Unexpected running ring at isoc stream start, uframe: %d\n",
4338 - xep->next_uframe);
4318 + if (GET_EP_CTX_STATE(ep_ctx) != EP_STATE_RUNNING)
4339 4319 xep->next_uframe = -1;
4340 - }
4341 4320
4342 4321 return xhci_queue_isoc_tx(xhci, mem_flags, urb, slot_id, ep_index);
4343 4322 }
modified drivers/usb/image/mdc800.c
@@ -1000,13 +1000,13 @@ static int __init usb_mdc800_init (void)
1000 1000 mdc800->downloaded = 0;
1001 1001 mdc800->written = 0;
1002 1002
1003 - mdc800->irq_urb_buffer=kzalloc (8, GFP_KERNEL);
1003 + mdc800->irq_urb_buffer=kmalloc (8, GFP_KERNEL);
1004 1004 if (!mdc800->irq_urb_buffer)
1005 1005 goto cleanup_on_fail;
1006 1006 mdc800->write_urb_buffer=kmalloc (8, GFP_KERNEL);
1007 1007 if (!mdc800->write_urb_buffer)
1008 1008 goto cleanup_on_fail;
1009 - mdc800->download_urb_buffer=kzalloc (64, GFP_KERNEL);
1009 + mdc800->download_urb_buffer=kmalloc (64, GFP_KERNEL);
1010 1010 if (!mdc800->download_urb_buffer)
1011 1011 goto cleanup_on_fail;
1012 1012
modified drivers/usb/storage/ene_ub6250.c
@@ -2357,9 +2357,7 @@ static int ene_ub6250_probe(struct usb_interface *intf,
2357 2357 return result;
2358 2358
2359 2359 /* probe card type */
2360 - mutex_lock(&us->dev_mutex);
2361 2360 result = ene_get_card_type(us, REG_CARD_STATUS, info->bbuf);
2362 - mutex_unlock(&us->dev_mutex);
2363 2361 if (result != USB_STOR_XFER_GOOD) {
2364 2362 usb_stor_disconnect(intf);
2365 2363 return USB_STOR_TRANSPORT_ERROR;
modified drivers/usb/storage/realtek_cr.c
@@ -916,6 +916,7 @@ static int realtek_cr_autosuspend_setup(struct us_data *us)
916 916 us->proto_handler = rts51x_invoke_transport;
917 917
918 918 chip->timer_expires = 0;
919 + timer_setup(&chip->rts51x_suspend_timer, rts51x_suspend_timer_fn, 0);
919 920 fw5895_init(us);
920 921
921 922 /* enable autosuspend function of the usb device */
@@ -933,7 +934,10 @@ static void realtek_cr_destructor(void *extra)
933 934 return;
934 935
935 936 #ifdef CONFIG_REALTEK_AUTOPM
936 - timer_shutdown_sync(&chip->rts51x_suspend_timer);
937 + if (ss_en) {
938 + timer_delete(&chip->rts51x_suspend_timer);
939 + chip->timer_expires = 0;
940 + }
937 941 #endif
938 942 kfree(chip->status);
939 943 }
@@ -978,9 +982,6 @@ static int init_realtek_cr(struct us_data *us)
978 982
979 983 us->extra = chip;
980 984 us->extra_destructor = realtek_cr_destructor;
981 - #ifdef CONFIG_REALTEK_AUTOPM
982 - timer_setup(&chip->rts51x_suspend_timer, rts51x_suspend_timer_fn, 0);
983 - #endif
984 985 us->max_lun = chip->max_lun = rts51x_get_max_lun(us);
985 986 chip->us = us;
986 987
modified drivers/usb/typec/hd3ss3220.c
@@ -62,7 +62,6 @@ struct hd3ss3220 {
62 62 int id_irq;
63 63
64 64 struct regulator *vbus;
65 - bool vbus_enabled;
66 65 };
67 66
68 67 static int hd3ss3220_set_power_opmode(struct hd3ss3220 *hd3ss3220, int power_opmode)
@@ -209,7 +208,7 @@ static void hd3ss3220_regulator_control(struct hd3ss3220 *hd3ss3220, bool on)
209 208 {
210 209 int ret;
211 210
212 - if (hd3ss3220->vbus_enabled == on)
211 + if (regulator_is_enabled(hd3ss3220->vbus) == on)
213 212 return;
214 213
215 214 if (on)
@@ -217,13 +216,9 @@ static void hd3ss3220_regulator_control(struct hd3ss3220 *hd3ss3220, bool on)
217 216 else
218 217 ret = regulator_disable(hd3ss3220->vbus);
219 218
220 - if (ret) {
219 + if (ret)
221 220 dev_err(hd3ss3220->dev,
222 221 "vbus regulator %s failed: %d\n", on ? "enable" : "disable", ret);
223 - return;
224 - }
225 -
226 - hd3ss3220->vbus_enabled = on;
227 222 }
228 223
229 224 static void hd3ss3220_set_role(struct hd3ss3220 *hd3ss3220)
modified drivers/usb/typec/mux.c
@@ -57,8 +57,6 @@ static void *typec_switch_match(const struct fwnode_handle *fwnode,
57 57 */
58 58 dev = class_find_device(&typec_mux_class, NULL, fwnode,
59 59 switch_fwnode_match);
60 - if (!dev)
61 - return ERR_PTR(-EPROBE_DEFER);
62 60
63 61 /* Skip duplicates */
64 62 for (i = 0; i < TYPEC_MUX_MAX_DEVS; i++)
@@ -67,7 +65,7 @@ static void *typec_switch_match(const struct fwnode_handle *fwnode,
67 65 return NULL;
68 66 }
69 67
70 - return to_typec_switch_dev(dev);
68 + return dev ? to_typec_switch_dev(dev) : ERR_PTR(-EPROBE_DEFER);
71 69 }
72 70
73 71 /**
@@ -277,9 +275,7 @@ static int mux_fwnode_match(struct device *dev, const void *fwnode)
277 275 static void *typec_mux_match(const struct fwnode_handle *fwnode,
278 276 const char *id, void *data)
279 277 {
280 - struct typec_mux_dev **mux_devs = data;
281 278 struct device *dev;
282 - int i;
283 279
284 280 /*
285 281 * Device graph (OF graph) does not give any means to identify the
@@ -294,18 +290,8 @@ static void *typec_mux_match(const struct fwnode_handle *fwnode,
294 290
295 291 dev = class_find_device(&typec_mux_class, NULL, fwnode,
296 292 mux_fwnode_match);
297 - if (!dev)
298 - return ERR_PTR(-EPROBE_DEFER);
299 293
300 - /* Skip duplicates */
301 - for (i = 0; i < TYPEC_MUX_MAX_DEVS; i++)
302 - if (to_typec_mux_dev(dev) == mux_devs[i]) {
303 - put_device(dev);
304 - return NULL;
305 - }
306 -
307 -
308 - return to_typec_mux_dev(dev);
294 + return dev ? to_typec_mux_dev(dev) : ERR_PTR(-EPROBE_DEFER);
309 295 }
310 296
311 297 /**
@@ -330,8 +316,7 @@ struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode)
330 316 return ERR_PTR(-ENOMEM);
331 317
332 318 count = fwnode_connection_find_matches(fwnode, "mode-switch",
333 - (void **)mux_devs,
334 - typec_mux_match,
319 + NULL, typec_mux_match,
335 320 (void **)mux_devs,
336 321 ARRAY_SIZE(mux_devs));
337 322 if (count <= 0) {
modified drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy.c
@@ -543,8 +543,6 @@ static void qcom_pmic_typec_pdphy_stop(struct pmic_typec *tcpm)
543 543 for (i = 0; i < pmic_typec_pdphy->nr_irqs; i++)
544 544 disable_irq(pmic_typec_pdphy->irq_data[i].irq);
545 545
546 - cancel_work_sync(&pmic_typec_pdphy->reset_work);
547 -
548 546 qcom_pmic_typec_pdphy_reset_on(pmic_typec_pdphy);
549 547
550 548 regulator_disable(pmic_typec_pdphy->vdd_pdphy);
modified drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_port.c
@@ -683,9 +683,6 @@ static int qcom_pmic_typec_port_start(struct pmic_typec *tcpm,
683 683 enable_irq(pmic_typec_port->irq_data[i].irq);
684 684
685 685 done:
686 - if (ret)
687 - disable_delayed_work_sync(&pmic_typec_port->cc_debounce_dwork);
688 -
689 686 return ret;
690 687 }
691 688
@@ -696,8 +693,6 @@ static void qcom_pmic_typec_port_stop(struct pmic_typec *tcpm)
696 693
697 694 for (i = 0; i < pmic_typec_port->nr_irqs; i++)
698 695 disable_irq(pmic_typec_port->irq_data[i].irq);
699 -
700 - disable_delayed_work_sync(&pmic_typec_port->cc_debounce_dwork);
701 696 }
702 697
703 698 int qcom_pmic_typec_port_probe(struct platform_device *pdev,
modified drivers/usb/typec/tcpm/tcpm.c
@@ -7119,32 +7119,16 @@ static void tcpm_pd_event_handler(struct kthread_work *work)
7119 7119 }
7120 7120 }
7121 7121 if (events & TCPM_SOURCING_VBUS) {
7122 + tcpm_log(port, "sourcing vbus");
7122 7123 /*
7123 7124 * In fast role swap case TCPC autonomously sources vbus. Set vbus_source
7124 - * true conditionally as TCPM wouldn't have called tcpm_set_vbus.
7125 - * If TCPM calls tcpm_set_vbus to source vbus, vbus_source would already
7126 - * be true.
7125 + * true as TCPM wouldn't have called tcpm_set_vbus.
7127 7126 *
7128 - * When TCPM_FRS_EVENT and TCPM_SOURCING_VBUS arrive simultaneously,
7129 - * handling TCPM_FRS_EVENT above transitions the state to AMS_START
7130 - * with upcoming_state FR_SWAP_SEND.
7127 + * When vbus is sourced on the command on TCPM i.e. TCPM called
7128 + * tcpm_set_vbus to source vbus, vbus_source would already be true.
7131 7129 */
7132 -
7133 - if (tcpm_port_is_source(port) ||
7134 - tcpm_port_is_debug_source(port) ||
7135 - (port->state == AMS_START && port->upcoming_state == FR_SWAP_SEND) ||
7136 - port->state == FR_SWAP_SEND ||
7137 - port->state == FR_SWAP_SEND_TIMEOUT ||
7138 - port->state == FR_SWAP_SNK_SRC_TRANSITION_TO_OFF ||
7139 - port->state == FR_SWAP_SNK_SRC_NEW_SINK_READY ||
7140 - port->state == FR_SWAP_SNK_SRC_SOURCE_VBUS_APPLIED) {
7141 - tcpm_log(port, "sourcing vbus");
7142 - port->vbus_source = true;
7143 - _tcpm_pd_vbus_on(port);
7144 - } else {
7145 - tcpm_log(port, "Discarding sourcing vbus! Invalid state %s",
7146 - tcpm_states[port->state]);
7147 - }
7130 + port->vbus_source = true;
7131 + _tcpm_pd_vbus_on(port);
7148 7132 }
7149 7133 if (events & TCPM_PORT_CLEAN) {
7150 7134 tcpm_log(port, "port clean");
modified drivers/usb/typec/tipd/core.c
@@ -114,6 +114,7 @@ struct tps6598x_intel_vid_status_reg {
114 114 __le32 attention_vdo;
115 115 __le16 enter_vdo;
116 116 __le16 device_mode;
117 + __le16 cable_mode;
117 118 } __packed;
118 119
119 120 /* Standard Task return codes */
@@ -730,19 +731,9 @@ static void cd321x_typec_update_mode(struct tps6598x *tps, struct cd321x_status
730 731 cd321x->state.mode == TYPEC_TBT_MODE)
731 732 return;
732 733
733 - tbt_data.cable_mode = TBT_MODE |
734 - TBT_SET_CABLE_SPEED(TPS_DATA_STATUS_TBT_CABLE_SPEED(st->data_status)) |
735 - TBT_SET_CABLE_ROUNDED(TPS_DATA_STATUS_TBT_CABLE_GEN(st->data_status));
736 - if (st->data_status & TPS_DATA_STATUS_OPTICAL_CABLE)
737 - tbt_data.cable_mode |= TBT_CABLE_OPTICAL;
738 - if (st->data_status & TPS_DATA_STATUS_ACTIVE_LINK_TRAIN)
739 - tbt_data.cable_mode |= TBT_CABLE_LINK_TRAINING;
740 - if (st->data_status & TPS_DATA_STATUS_ACTIVE_CABLE)
741 - tbt_data.cable_mode |= TBT_CABLE_ACTIVE_PASSIVE;
742 - tbt_data.device_mode = TBT_MODE |
743 - (u32)le16_to_cpu(st->intel_vid_status.device_mode) << 16;
744 - tbt_data.enter_vdo =
745 - (u32)le16_to_cpu(st->intel_vid_status.enter_vdo) << 16;
734 + tbt_data.cable_mode = le16_to_cpu(st->intel_vid_status.cable_mode);
735 + tbt_data.device_mode = le16_to_cpu(st->intel_vid_status.device_mode);
736 + tbt_data.enter_vdo = le16_to_cpu(st->intel_vid_status.enter_vdo);
746 737 cd321x->state.alt = cd321x->port_altmode_tbt;
747 738 cd321x->state.mode = TYPEC_TBT_MODE;
748 739 cd321x->state.data = &tbt_data;
modified drivers/usb/typec/tipd/tps6598x.h
@@ -210,10 +210,10 @@
210 210 #define TPS_DATA_STATUS_DP_PIN_ASSIGNMENT(x) \
211 211 TPS_FIELD_GET(TPS_DATA_STATUS_DP_PIN_ASSIGNMENT_MASK, (x))
212 212 #define TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK GENMASK(27, 25)
213 - #define TPS_DATA_STATUS_TBT_CABLE_SPEED(x) \
213 + #define TPS_DATA_STATUS_TBT_CABLE_SPEED \
214 214 TPS_FIELD_GET(TPS_DATA_STATUS_TBT_CABLE_SPEED_MASK, (x))
215 215 #define TPS_DATA_STATUS_TBT_CABLE_GEN_MASK GENMASK(29, 28)
216 - #define TPS_DATA_STATUS_TBT_CABLE_GEN(x) \
216 + #define TPS_DATA_STATUS_TBT_CABLE_GEN \
217 217 TPS_FIELD_GET(TPS_DATA_STATUS_TBT_CABLE_GEN_MASK, (x))
218 218
219 219 /* Map data status to DP spec assignments */
modified drivers/usb/typec/ucsi/displayport.c
@@ -74,7 +74,7 @@ static int ucsi_displayport_enter(struct typec_altmode *alt, u32 *vdo)
74 74 cur = 0xff;
75 75 }
76 76
77 - if (cur < UCSI_MAX_ALTMODES) {
77 + if (cur != 0xff) {
78 78 ret = dp->con->port_altmode[cur] == alt ? 0 : -EBUSY;
79 79 goto err_unlock;
80 80 }
modified drivers/usb/usbip/usbip_common.c
@@ -696,7 +696,7 @@ int usbip_recv_iso(struct usbip_device *ud, struct urb *urb)
696 696
697 697 size = np * sizeof(*iso);
698 698
699 - buff = kzalloc_objs(*iso, np);
699 + buff = kcalloc(np, sizeof(*iso), GFP_KERNEL);
700 700 if (!buff)
701 701 return -ENOMEM;
702 702
modified drivers/xen/grant-table.c
@@ -1478,7 +1478,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
1478 1478 /* No need for kzalloc as it is initialized in following hypercall
1479 1479 * GNTTABOP_setup_table.
1480 1480 */
1481 - frames = kmalloc_objs(*frames, nr_gframes, GFP_ATOMIC);
1481 + frames = kmalloc_array(nr_gframes, sizeof(*frames), GFP_ATOMIC);
1482 1482 if (!frames)
1483 1483 return -ENOMEM;
1484 1484
modified fs/9p/vfs_dentry.c
@@ -113,7 +113,8 @@ void v9fs_dentry_fid_remove(struct dentry *dentry)
113 113 */
114 114 static int v9fs_dentry_init(struct dentry *dentry)
115 115 {
116 - struct v9fs_dentry *v9fs_dentry = kzalloc_obj(*v9fs_dentry);
116 + struct v9fs_dentry *v9fs_dentry = kzalloc(sizeof(*v9fs_dentry),
117 + GFP_KERNEL);
117 118
118 119 if (!v9fs_dentry)
119 120 return -ENOMEM;
modified fs/afs/dir.c
@@ -1801,7 +1801,7 @@ static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
1801 1801 goto error;
1802 1802
1803 1803 ret = -ENOMEM;
1804 - symlink = kmalloc_flex(struct afs_symlink, content, clen + 1);
1804 + symlink = kmalloc_flex(struct afs_symlink, content, clen + 1, GFP_KERNEL);
1805 1805 if (!symlink)
1806 1806 goto error;
1807 1807 refcount_set(&symlink->ref, 1);
modified fs/afs/symlink.c
@@ -119,7 +119,8 @@ static ssize_t afs_do_read_symlink(struct afs_vnode *vnode)
119 119 vnode->directory_size = i_size;
120 120
121 121 /* Copy the symlink. */
122 - symlink = kmalloc_flex(struct afs_symlink, content, i_size + 1);
122 + symlink = kmalloc_flex(struct afs_symlink, content, i_size + 1,
123 + GFP_KERNEL);
123 124 if (!symlink)
124 125 return -ENOMEM;
125 126
modified fs/binfmt_misc.c
@@ -331,8 +331,8 @@ static int entry_attach_interpreter(struct binfmt_misc_entry *e,
331 331 return -ENOSPC;
332 332
333 333 /* One allocation, both strings in it, like the entry's own buffer. */
334 - interp = kmalloc_flex(*interp, name, nlen + plen + 2,
335 - GFP_KERNEL_ACCOUNT);
334 + interp = kmalloc(struct_size(interp, name, nlen + plen + 2),
335 + GFP_KERNEL_ACCOUNT);
336 336 if (!interp) {
337 337 dec_ucount(ucounts, UCOUNT_BINFMT_MISC_INTERPRETERS);
338 338 return -ENOMEM;
@@ -858,7 +858,8 @@ static struct binfmt_misc_entry *create_entry(const char __user *buffer,
858 858 if ((count < 11) || (count > MAX_REGISTER_LENGTH))
859 859 return ERR_PTR(-EINVAL);
860 860
861 - e = kmalloc_flex(*e, buf, count + MISC_DELIM_PAD, GFP_KERNEL_ACCOUNT);
861 + e = kmalloc(struct_size(e, buf, count + MISC_DELIM_PAD),
862 + GFP_KERNEL_ACCOUNT);
862 863 if (!e)
863 864 return ERR_PTR(-ENOMEM);
864 865
modified fs/btrfs/dev-replace.c
@@ -636,7 +636,7 @@ static int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info,
636 636
637 637 ret = mark_block_group_to_copy(fs_info, src_device);
638 638 if (ret)
639 - goto leave;
639 + return ret;
640 640
641 641 down_write(&dev_replace->rwsem);
642 642 dev_replace->replace_task = current;
modified fs/btrfs/inode.c
@@ -3436,9 +3436,6 @@ out:
3436 3436 */
3437 3437 btrfs_remove_ordered_extent(ordered_extent);
3438 3438
3439 - /* Cleanup any remaining biocs attached to the OE. */
3440 - btrfs_cleanup_ordered_bioc_list(ordered_extent);
3441 -
3442 3439 /* once for us */
3443 3440 btrfs_put_ordered_extent(ordered_extent);
3444 3441 /* once for the tree */
modified fs/btrfs/ioctl.c
@@ -384,7 +384,6 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
384 384 inode_flags &= ~BTRFS_INODE_COMPRESS;
385 385 inode_flags |= BTRFS_INODE_NOCOMPRESS;
386 386 } else if (fsflags & FS_COMPR_FL) {
387 - enum btrfs_compression_type comp_type;
388 387
389 388 if (IS_SWAPFILE(&inode->vfs_inode))
390 389 return -ETXTBSY;
@@ -392,23 +391,9 @@ int btrfs_fileattr_set(struct mnt_idmap *idmap,
392 391 inode_flags |= BTRFS_INODE_COMPRESS;
393 392 inode_flags &= ~BTRFS_INODE_NOCOMPRESS;
394 393
395 - /*
396 - * Keep the algorithm recorded in the compression property,
397 - * otherwise changing an unrelated attribute would reset it to
398 - * the mount default, since FS_IOC_SETFLAGS callers write back
399 - * the whole flag set they got from FS_IOC_GETFLAGS and that
400 - * includes FS_COMPR_FL for any inode carrying the property.
401 - *
402 - * Inodes with the compress flag set but no property keep using
403 - * the mount default, so they behave as before.
404 - */
405 - if (inode->prop_compress)
406 - comp_type = inode->prop_compress;
407 - else if (fs_info->compress_type)
408 - comp_type = fs_info->compress_type;
409 - else
410 - comp_type = BTRFS_COMPRESS_ZLIB;
411 - comp = btrfs_compress_type2str(comp_type);
394 + comp = btrfs_compress_type2str(fs_info->compress_type);
395 + if (!comp || comp[0] == 0)
396 + comp = btrfs_compress_type2str(BTRFS_COMPRESS_ZLIB);
412 397 } else {
413 398 inode_flags &= ~(BTRFS_INODE_COMPRESS | BTRFS_INODE_NOCOMPRESS);
414 399 }
modified fs/btrfs/raid-stripe-tree.c
@@ -310,10 +310,8 @@ static int update_raid_extent_item(struct btrfs_trans_handle *trans,
310 310
311 311 ret = btrfs_search_slot(trans, trans->fs_info->stripe_root, key, path,
312 312 0, 1);
313 - if (ret > 0)
314 - ret = -ENOENT;
315 - if (ret < 0)
316 - return ret;
313 + if (ret)
314 + return (ret == 1 ? ret : -EINVAL);
317 315
318 316 leaf = path->nodes[0];
319 317 slot = path->slots[0];
@@ -339,6 +337,7 @@ int btrfs_insert_one_raid_extent(struct btrfs_trans_handle *trans,
339 337 stripe_extent = kzalloc(item_size, GFP_NOFS);
340 338 if (unlikely(!stripe_extent)) {
341 339 btrfs_abort_transaction(trans, -ENOMEM);
340 + btrfs_end_transaction(trans);
342 341 return -ENOMEM;
343 342 }
344 343
@@ -375,7 +374,7 @@ int btrfs_insert_raid_extent(struct btrfs_trans_handle *trans,
375 374 struct btrfs_ordered_extent *ordered_extent)
376 375 {
377 376 struct btrfs_io_context *bioc;
378 - int ret = 0;
377 + int ret;
379 378
380 379 if (!btrfs_fs_incompat(trans->fs_info, RAID_STRIPE_TREE))
381 380 return 0;
@@ -383,23 +382,17 @@ int btrfs_insert_raid_extent(struct btrfs_trans_handle *trans,
383 382 list_for_each_entry(bioc, &ordered_extent->bioc_list, rst_ordered_entry) {
384 383 ret = btrfs_insert_one_raid_extent(trans, bioc);
385 384 if (ret)
386 - break;
385 + return ret;
387 386 }
388 387
389 - btrfs_cleanup_ordered_bioc_list(ordered_extent);
390 - return ret;
391 - }
392 -
393 - void btrfs_cleanup_ordered_bioc_list(struct btrfs_ordered_extent *ordered)
394 - {
395 - while (!list_empty(&ordered->bioc_list)) {
396 - struct btrfs_io_context *bioc;
397 -
398 - bioc = list_first_entry(&ordered->bioc_list,
388 + while (!list_empty(&ordered_extent->bioc_list)) {
389 + bioc = list_first_entry(&ordered_extent->bioc_list,
399 390 typeof(*bioc), rst_ordered_entry);
400 391 list_del(&bioc->rst_ordered_entry);
401 392 btrfs_put_bioc(bioc);
402 393 }
394 +
395 + return 0;
403 396 }
404 397
405 398 int btrfs_get_raid_extent_offset(struct btrfs_fs_info *fs_info,
modified fs/btrfs/raid-stripe-tree.h
@@ -28,7 +28,6 @@ int btrfs_get_raid_extent_offset(struct btrfs_fs_info *fs_info,
28 28 u32 stripe_index, struct btrfs_io_stripe *stripe);
29 29 int btrfs_insert_raid_extent(struct btrfs_trans_handle *trans,
30 30 struct btrfs_ordered_extent *ordered_extent);
31 - void btrfs_cleanup_ordered_bioc_list(struct btrfs_ordered_extent *ordered);
32 31
33 32 #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
34 33 int btrfs_insert_one_raid_extent(struct btrfs_trans_handle *trans,
modified fs/btrfs/scrub.c
@@ -1023,10 +1023,6 @@ static void scrub_stripe_report_errors(struct scrub_ctx *sctx,
1023 1023
1024 1024 skip:
1025 1025 for_each_set_bit(sector_nr, &extent_bitmap, stripe->nr_sectors) {
1026 - const u64 sector_logical = stripe->logical +
1027 - ((u64)sector_nr << fs_info->sectorsize_bits);
1028 - const u64 sector_physical = physical +
1029 - ((u64)sector_nr << fs_info->sectorsize_bits);
1030 1026 bool repaired = false;
1031 1027
1032 1028 if (scrub_bitmap_test_bit_is_metadata(stripe, sector_nr)) {
@@ -1055,12 +1051,12 @@ skip:
1055 1051 if (dev) {
1056 1052 btrfs_err_rl(fs_info,
1057 1053 "scrub: fixed up error at logical %llu on dev %s physical %llu",
1058 - sector_logical, btrfs_dev_name(dev),
1059 - sector_physical);
1054 + stripe->logical, btrfs_dev_name(dev),
1055 + physical);
1060 1056 } else {
1061 1057 btrfs_err_rl(fs_info,
1062 1058 "scrub: fixed up error at logical %llu on mirror %u",
1063 - sector_logical, stripe->mirror_num);
1059 + stripe->logical, stripe->mirror_num);
1064 1060 }
1065 1061 continue;
1066 1062 }
@@ -1069,30 +1065,30 @@ skip:
1069 1065 if (dev) {
1070 1066 btrfs_err_rl(fs_info,
1071 1067 "scrub: unable to fixup (regular) error at logical %llu on dev %s physical %llu",
1072 - sector_logical, btrfs_dev_name(dev),
1073 - sector_physical);
1068 + stripe->logical, btrfs_dev_name(dev),
1069 + physical);
1074 1070 } else {
1075 1071 btrfs_err_rl(fs_info,
1076 1072 "scrub: unable to fixup (regular) error at logical %llu on mirror %u",
1077 - sector_logical, stripe->mirror_num);
1073 + stripe->logical, stripe->mirror_num);
1078 1074 }
1079 1075
1080 1076 if (scrub_bitmap_test_bit_io_error(stripe, sector_nr))
1081 1077 if (__ratelimit(&rs) && dev)
1082 1078 scrub_print_common_warning("i/o error", dev, false,
1083 - sector_logical, sector_physical);
1079 + stripe->logical, physical);
1084 1080 if (scrub_bitmap_test_bit_csum_error(stripe, sector_nr))
1085 1081 if (__ratelimit(&rs) && dev)
1086 1082 scrub_print_common_warning("checksum error", dev, false,
1087 - sector_logical, sector_physical);
1083 + stripe->logical, physical);
1088 1084 if (scrub_bitmap_test_bit_meta_error(stripe, sector_nr))
1089 1085 if (__ratelimit(&rs) && dev)
1090 1086 scrub_print_common_warning("header error", dev, false,
1091 - sector_logical, sector_physical);
1087 + stripe->logical, physical);
1092 1088 if (scrub_bitmap_test_bit_meta_gen_error(stripe, sector_nr))
1093 1089 if (__ratelimit(&rs) && dev)
1094 1090 scrub_print_common_warning("generation error", dev, false,
1095 - sector_logical, sector_physical);
1091 + stripe->logical, physical);
1096 1092 }
1097 1093
1098 1094 /* Update the device stats. */
modified fs/btrfs/send.c
@@ -2065,7 +2065,7 @@ static int will_overwrite_ref(struct send_ctx *sctx, u64 dir, u64 dir_gen,
2065 2065
2066 2066 ret = is_inode_existent(sctx, dir, dir_gen, NULL, &parent_root_dir_gen);
2067 2067 if (ret <= 0)
2068 - return ret;
2068 + return 0;
2069 2069
2070 2070 /*
2071 2071 * If we have a parent root we need to verify that the parent dir was
@@ -6417,13 +6417,6 @@ static int process_extent(struct send_ctx *sctx,
6417 6417
6418 6418 if (S_ISLNK(sctx->cur_inode_mode))
6419 6419 return 0;
6420 - if (unlikely(!S_ISREG(sctx->cur_inode_mode))) {
6421 - btrfs_crit(sctx->send_root->fs_info,
6422 - "send: extent for non-regular inode %llu root %llu mode 0%llo",
6423 - key->objectid, btrfs_root_id(sctx->send_root),
6424 - sctx->cur_inode_mode & S_IFMT);
6425 - return -EUCLEAN;
6426 - }
6427 6420
6428 6421 if (sctx->parent_root && !sctx->cur_inode_new) {
6429 6422 ret = is_extent_unchanged(sctx, path, key);
modified fs/btrfs/tests/extent-io-tests.c
@@ -133,14 +133,14 @@ static int test_find_delalloc(u32 sectorsize, u32 nodesize)
133 133 if (IS_ERR(root)) {
134 134 test_std_err(TEST_ALLOC_ROOT);
135 135 ret = PTR_ERR(root);
136 - goto out_root_info;
136 + goto out;
137 137 }
138 138
139 139 inode = btrfs_new_test_inode();
140 140 if (!inode) {
141 141 test_std_err(TEST_ALLOC_INODE);
142 142 ret = -ENOMEM;
143 - goto out_root_info;
143 + goto out;
144 144 }
145 145 tmp = &BTRFS_I(inode)->io_tree;
146 146 BTRFS_I(inode)->root = root;
@@ -333,7 +333,6 @@ out:
333 333 process_page_range(inode, 0, total_dirty - 1,
334 334 PROCESS_UNLOCK | PROCESS_RELEASE);
335 335 iput(inode);
336 - out_root_info:
337 336 btrfs_free_dummy_root(root);
338 337 btrfs_free_dummy_fs_info(fs_info);
339 338 return ret;
modified fs/btrfs/transaction.c
@@ -458,19 +458,8 @@ static int record_root_in_trans(struct btrfs_trans_handle *trans,
458 458 * through btrfs_record_root_in_trans without having to take the
459 459 * lock. smp_wmb() makes sure that all the writes above are
460 460 * done before we pop in the zero below
461 - *
462 - * If @force is true, it means the call is from
463 - * qgroup_account_snapshot(), which only requires radix tree
464 - * tracking.
465 - * We should not force reloc root creation here, as the root
466 - * may have already been modified, and in that case
467 - * root->commit_root has already been dropped.
468 - *
469 - * Using that commit root will cause the reloc root to refer
470 - * to a deleted extent, causing extent tree corruption.
471 461 */
472 - if (!force)
473 - ret = btrfs_init_reloc_root(trans, root);
462 + ret = btrfs_init_reloc_root(trans, root);
474 463 smp_mb__before_atomic();
475 464 clear_bit(BTRFS_ROOT_IN_TRANS_SETUP, &root->state);
476 465 }
@@ -2594,12 +2583,6 @@ int btrfs_commit_transaction(struct btrfs_trans_handle *trans)
2594 2583 ret = btrfs_write_and_wait_transaction(trans);
2595 2584 if (unlikely(ret)) {
2596 2585 btrfs_err(fs_info, "error while writing out transaction: %pe", ERR_PTR(ret));
2597 - /*
2598 - * Abort before releasing tree_log_mutex, so a log sync waiting
2599 - * on it sees the fs error and skips writing super_for_commit
2600 - * for this failed transaction. See btrfs_sync_log().
2601 - */
2602 - btrfs_abort_transaction(trans, ret);
2603 2586 mutex_unlock(&fs_info->tree_log_mutex);
2604 2587 goto scrub_continue;
2605 2588 }
modified fs/btrfs/volumes.c
@@ -3117,11 +3117,7 @@ int btrfs_init_new_device(struct btrfs_fs_info *fs_info, const char *device_path
3117 3117 error_sysfs:
3118 3118 btrfs_sysfs_remove_device(device);
3119 3119 mutex_lock(&fs_info->fs_devices->device_list_mutex);
3120 - if (seeding_dev)
3121 - btrfs_assign_next_active_device(device, seed_devices->latest_dev);
3122 3120 mutex_lock(&fs_info->chunk_mutex);
3123 - if (!list_empty(&device->post_commit_list))
3124 - list_del_init(&device->post_commit_list);
3125 3121 list_del_rcu(&device->dev_list);
3126 3122 list_del(&device->dev_alloc_list);
3127 3123 fs_info->fs_devices->num_devices--;
modified fs/btrfs/zoned.c
@@ -2626,13 +2626,16 @@ static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ
2626 2626 down_read(&dev_replace->rwsem);
2627 2627 map = block_group->physical_map;
2628 2628 for (i = 0; i < map->num_stripes; i++) {
2629 +
2629 2630 ret = call_zone_finish(block_group, &map->stripes[i]);
2630 - if (ret)
2631 - break;
2631 + if (ret) {
2632 + up_read(&dev_replace->rwsem);
2633 + return ret;
2634 + }
2632 2635 }
2633 2636 up_read(&dev_replace->rwsem);
2634 2637
2635 - if (!ret && !fully_written)
2638 + if (!fully_written)
2636 2639 btrfs_dec_block_group_ro(block_group);
2637 2640
2638 2641 spin_lock(&fs_info->zone_active_bgs_lock);
@@ -2645,7 +2648,7 @@ static int do_zone_finish(struct btrfs_block_group *block_group, bool fully_writ
2645 2648
2646 2649 clear_and_wake_up_bit(BTRFS_FS_NEED_ZONE_FINISH, &fs_info->flags);
2647 2650
2648 - return ret;
2651 + return 0;
2649 2652 }
2650 2653
2651 2654 int btrfs_zone_finish(struct btrfs_block_group *block_group)
@@ -2710,7 +2713,6 @@ int btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 leng
2710 2713 {
2711 2714 struct btrfs_block_group *block_group;
2712 2715 u64 min_alloc_bytes;
2713 - int ret = 0;
2714 2716
2715 2717 if (!btrfs_is_zoned(fs_info))
2716 2718 return 0;
@@ -2730,11 +2732,11 @@ int btrfs_zone_finish_endio(struct btrfs_fs_info *fs_info, u64 logical, u64 leng
2730 2732 block_group->start + block_group->zone_capacity)
2731 2733 goto out;
2732 2734
2733 - ret = do_zone_finish(block_group, true);
2735 + do_zone_finish(block_group, true);
2734 2736
2735 2737 out:
2736 2738 btrfs_put_block_group(block_group);
2737 - return ret;
2739 + return 0;
2738 2740 }
2739 2741
2740 2742 static void btrfs_zone_finish_endio_workfn(struct work_struct *work)
modified fs/btrfs/zstd.c
@@ -307,17 +307,8 @@ again:
307 307 DEFINE_WAIT(wait);
308 308
309 309 prepare_to_wait(&zwsm->wait, &wait, TASK_UNINTERRUPTIBLE);
310 - /*
311 - * Re-check after being queued: zstd_put_workspace() only wakes
312 - * a queue that already has a sleeper, so a workspace returned
313 - * since the failed allocation woke nobody.
314 - */
315 - ws = zstd_find_workspace(fs_info, level);
316 - if (!ws)
317 - schedule();
310 + schedule();
318 311 finish_wait(&zwsm->wait, &wait);
319 - if (ws)
320 - return ws;
321 312
322 313 goto again;
323 314 }
modified fs/ceph/addr.c
@@ -2546,7 +2546,7 @@ static int __ceph_pool_perm_get(struct ceph_inode_info *ci,
2546 2546 }
2547 2547
2548 2548 pool_ns_len = pool_ns ? pool_ns->len : 0;
2549 - perm = kmalloc_flex(*perm, pool_ns, pool_ns_len + 1);
2549 + perm = kmalloc_flex(*perm, pool_ns, pool_ns_len + 1, GFP_KERNEL);
2550 2550 if (!perm) {
2551 2551 err = -ENOMEM;
2552 2552 goto out_unlock;
modified fs/ceph/mds_client.c
@@ -5492,7 +5492,7 @@ static void ceph_mdsc_reset_workfn(struct work_struct *work)
5492 5492 goto out_complete;
5493 5493 }
5494 5494
5495 - sessions = kzalloc_objs(*sessions, max_sessions);
5495 + sessions = kcalloc(max_sessions, sizeof(*sessions), GFP_KERNEL);
5496 5496 if (!sessions) {
5497 5497 mutex_unlock(&mdsc->mutex);
5498 5498 ret = -ENOMEM;
@@ -6600,13 +6600,11 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
6600 6600 doutc(cl, "tpath '%s', mask %d, caller_uid %d, caller_gid %d\n",
6601 6601 tpath, mask, caller_uid, caller_gid);
6602 6602
6603 - mutex_lock(&mdsc->mutex);
6604 6603 for (i = 0; i < mdsc->s_cap_auths_num; i++) {
6605 6604 struct ceph_mds_cap_auth *s = &mdsc->s_cap_auths[i];
6606 6605
6607 6606 err = ceph_mds_auth_match(mdsc, s, cred, tpath);
6608 6607 if (err < 0) {
6609 - mutex_unlock(&mdsc->mutex);
6610 6608 put_cred(cred);
6611 6609 return err;
6612 6610 } else if (err > 0) {
@@ -6628,7 +6626,6 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
6628 6626 doutc(cl, "root_squash_perms %d, rw_perms_s %p\n", root_squash_perms,
6629 6627 rw_perms_s);
6630 6628 if (root_squash_perms && rw_perms_s == NULL) {
6631 - mutex_unlock(&mdsc->mutex);
6632 6629 doutc(cl, "access allowed\n");
6633 6630 return 0;
6634 6631 }
@@ -6643,7 +6640,6 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
6643 6640 !!(mask & MAY_READ), !!(mask & MAY_WRITE));
6644 6641 }
6645 6642 doutc(cl, "access denied\n");
6646 - mutex_unlock(&mdsc->mutex);
6647 6643 return -EACCES;
6648 6644 }
6649 6645
modified fs/ceph/mds_client.h
@@ -604,7 +604,6 @@ struct ceph_mds_client {
604 604 struct rw_semaphore pool_perm_rwsem;
605 605 struct rb_root pool_perm_tree;
606 606
607 - /* protected by mutex */
608 607 u32 s_cap_auths_num;
609 608 struct ceph_mds_cap_auth *s_cap_auths;
610 609
modified fs/ceph/subvolume_metrics.c
@@ -245,7 +245,7 @@ int ceph_subvolume_metrics_snapshot(struct ceph_subvolume_metrics_tracker *track
245 245 return 0;
246 246 }
247 247
248 - snap = kzalloc_objs(*snap, count, GFP_NOFS);
248 + snap = kcalloc(count, sizeof(*snap), GFP_NOFS);
249 249 if (!snap) {
250 250 atomic64_inc(&tracker->snapshot_failures);
251 251 return -ENOMEM;
modified fs/ceph/super.c
@@ -1420,11 +1420,6 @@ static int ceph_reconfigure_fc(struct fs_context *fc)
1420 1420 else
1421 1421 ceph_clear_mount_opt(fsc, SPARSEREAD);
1422 1422
1423 - if (fsopt->flags & CEPH_MOUNT_OPT_NEARFULL_SYNC)
1424 - ceph_set_mount_opt(fsc, NEARFULL_SYNC);
1425 - else
1426 - ceph_clear_mount_opt(fsc, NEARFULL_SYNC);
1427 -
1428 1423 if (strcmp_null(fsc->mount_options->mon_addr, fsopt->mon_addr)) {
1429 1424 kfree(fsc->mount_options->mon_addr);
1430 1425 fsc->mount_options->mon_addr = fsopt->mon_addr;
modified fs/configfs/mount.c
@@ -9,7 +9,6 @@
9 9 */
10 10
11 11 #include <linux/fs.h>
12 - #include <linux/magic.h>
13 12 #include <linux/module.h>
14 13 #include <linux/mount.h>
15 14 #include <linux/fs_context.h>
@@ -20,6 +19,9 @@
20 19 #include <linux/configfs.h>
21 20 #include "configfs_internal.h"
22 21
22 + /* Random magic number */
23 + #define CONFIGFS_MAGIC 0x62656570
24 +
23 25 static struct vfsmount *configfs_mount = NULL;
24 26 struct kmem_cache *configfs_dir_cachep;
25 27 static int configfs_mnt_count = 0;
modified fs/coredump.c
@@ -1000,7 +1000,7 @@ static bool coredump_pipe(struct core_name *cn, struct coredump_params *cprm,
1000 1000 return false;
1001 1001 }
1002 1002
1003 - helper_argv = kmalloc_objs(*helper_argv, argc + 1);
1003 + helper_argv = kmalloc_array(argc + 1, sizeof(*helper_argv), GFP_KERNEL);
1004 1004 if (!helper_argv) {
1005 1005 coredump_report_failure("%s failed to allocate memory", __func__);
1006 1006 return false;
modified fs/ext4/fast_commit.c
@@ -1116,7 +1116,7 @@ static int ext4_fc_snapshot_inode(struct inode *inode,
1116 1116 else if (EXT4_INODE_SIZE(inode->i_sb) > EXT4_GOOD_OLD_INODE_SIZE)
1117 1117 inode_len += ei->i_extra_isize;
1118 1118
1119 - snap = kmalloc_flex(*snap, inode_buf, inode_len, GFP_NOFS);
1119 + snap = kmalloc(struct_size(snap, inode_buf, inode_len), GFP_NOFS);
1120 1120 if (!snap) {
1121 1121 atomic64_inc(&stats->snap_fail_nomem);
1122 1122 ext4_fc_set_snap_err(snap_err, EXT4_FC_SNAP_ERR_NOMEM);
@@ -1522,7 +1522,7 @@ static int ext4_fc_alloc_snapshot_inodes(struct super_block *sb,
1522 1522 if (nr_inodes > EXT4_FC_SNAPSHOT_MAX_INODES)
1523 1523 return -E2BIG;
1524 1524
1525 - inodes = kvzalloc_objs(*inodes, nr_inodes, GFP_NOFS);
1525 + inodes = kvcalloc(nr_inodes, sizeof(*inodes), GFP_NOFS);
1526 1526 if (!inodes)
1527 1527 return -ENOMEM;
1528 1528
modified fs/fuse/file.c
@@ -1597,7 +1597,8 @@ static int fuse_get_user_pages(struct fuse_args_pages *ap, struct iov_iter *ii,
1597 1597 * manually extract pages using iov_iter_extract_pages() and then
1598 1598 * copy that to a folios array.
1599 1599 */
1600 - struct page **pages = kzalloc_objs(struct page *, max_pages);
1600 + struct page **pages = kcalloc(max_pages, sizeof(struct page *),
1601 + GFP_KERNEL);
1601 1602 if (!pages) {
1602 1603 ret = -ENOMEM;
1603 1604 goto out;
modified fs/fuse/readdir.c
@@ -336,7 +336,7 @@ static int parse_dirplusfile(char *buf, size_t nbytes, struct file *file,
336 336 static struct page **fuse_readdir_alloc_buf(struct fuse_args_pages *ap, size_t *bufsize)
337 337 {
338 338 unsigned int i, nr_alloc, nr_pages = DIV_ROUND_UP(*bufsize, PAGE_SIZE);
339 - struct page **pages = kzalloc_objs(*pages, nr_pages);
339 + struct page **pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL);
340 340
341 341 if (!pages)
342 342 return NULL;
modified fs/hfs/bnode.c
@@ -312,7 +312,7 @@ static struct hfs_bnode *__hfs_bnode_create(struct hfs_btree *tree, u32 cnid)
312 312 return NULL;
313 313 }
314 314
315 - node = kzalloc_flex(*node, page, tree->pages_per_bnode);
315 + node = kzalloc_flex(*node, page, tree->pages_per_bnode, GFP_KERNEL);
316 316 if (!node)
317 317 return NULL;
318 318 node->tree = tree;
modified fs/kernfs/inode.c
@@ -142,8 +142,10 @@ ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size)
142 142 struct kernfs_iattrs *attrs;
143 143
144 144 attrs = kernfs_iattrs_noalloc(kn);
145 + if (!attrs)
146 + return 0;
145 147
146 - return simple_xattr_list(d_inode(dentry), attrs ? &attrs->xattrs : NULL, buf, size);
148 + return simple_xattr_list(d_inode(dentry), &attrs->xattrs, buf, size);
147 149 }
148 150
149 151 static inline void set_default_inode_attr(struct inode *inode, umode_t mode)
modified fs/namespace.c
@@ -5999,7 +5999,7 @@ SYSCALL_DEFINE4(statmount, const struct mnt_id_req __user *, req,
5999 5999 return -EPERM;
6000 6000 }
6001 6001
6002 - ks = kmalloc_obj(*ks, GFP_KERNEL_ACCOUNT);
6002 + ks = kmalloc(sizeof(*ks), GFP_KERNEL_ACCOUNT);
6003 6003 if (!ks)
6004 6004 return -ENOMEM;
6005 6005
modified fs/nfsd/export.c
@@ -358,7 +358,7 @@ int nfsd_nl_expkey_get_reqs_dumpit(struct sk_buff *skb,
358 358 goto out_unlock;
359 359 }
360 360
361 - items = kzalloc_objs(*items, cnt);
361 + items = kcalloc(cnt, sizeof(*items), GFP_KERNEL);
362 362 seqnos = kcalloc(cnt, sizeof(*seqnos), GFP_KERNEL);
363 363 if (!items || !seqnos) {
364 364 ret = -ENOMEM;
@@ -685,7 +685,7 @@ int nfsd_nl_svc_export_get_reqs_dumpit(struct sk_buff *skb,
685 685 goto out_unlock;
686 686 }
687 687
688 - items = kzalloc_objs(*items, cnt);
688 + items = kcalloc(cnt, sizeof(*items), GFP_KERNEL);
689 689 seqnos = kcalloc(cnt, sizeof(*seqnos), GFP_KERNEL);
690 690 pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
691 691 if (!items || !seqnos || !pathbuf) {
@@ -786,7 +786,8 @@ static int nfsd_nl_parse_fslocations(struct nlattr *attr,
786 786 if (!count)
787 787 return 0;
788 788
789 - fsloc->locations = kzalloc_objs(struct nfsd4_fs_location, count);
789 + fsloc->locations = kcalloc(count, sizeof(struct nfsd4_fs_location),
790 + GFP_KERNEL);
790 791 if (!fsloc->locations)
791 792 return -ENOMEM;
792 793
modified fs/nfsd/nfs4callback.c
@@ -1981,12 +1981,12 @@ int nfsd_net_cb_init(struct nfsd_net *nn)
1981 1981 {
1982 1982 struct nfsd_net_cb *cb;
1983 1983
1984 - cb = kzalloc_obj(*cb);
1984 + cb = kzalloc(sizeof(*cb), GFP_KERNEL);
1985 1985 if (!cb)
1986 1986 return -ENOMEM;
1987 1987
1988 1988 cb->version4.counts = kzalloc_objs(unsigned int,
1989 - ARRAY_SIZE(nfs4_cb_procedures));
1989 + ARRAY_SIZE(nfs4_cb_procedures), GFP_KERNEL);
1990 1990 if (!cb->version4.counts) {
1991 1991 kfree(cb);
1992 1992 return -ENOMEM;
modified fs/nfsd/nfs4state.c
@@ -1341,7 +1341,7 @@ alloc_init_dir_deleg(struct nfs4_client *clp, struct nfs4_file *fp)
1341 1341 return NULL;
1342 1342 }
1343 1343
1344 - ncn->ncn_nf = kzalloc_objs(*ncn->ncn_nf, NOTIFY4_EVENT_QUEUE_SIZE);
1344 + ncn->ncn_nf = kcalloc(NOTIFY4_EVENT_QUEUE_SIZE, sizeof(*ncn->ncn_nf), GFP_KERNEL);
1345 1345 if (!ncn->ncn_nf) {
1346 1346 nfs4_put_stid(&dp->dl_stid);
1347 1347 return NULL;
@@ -10419,9 +10419,8 @@ alloc_nfsd_notify_event(u32 mask, const struct qstr *q, struct dentry *dentry,
10419 10419 newnamelen = newname.name.len;
10420 10420 }
10421 10421
10422 - ne = kmalloc_flex(*ne, ne_name,
10423 - q->len + 1 + (newnamelen ? newnamelen + 1 : 0),
10424 - GFP_NOFS);
10422 + ne = kmalloc(struct_size(ne, ne_name, q->len + 1 +
10423 + (newnamelen ? newnamelen + 1 : 0)), GFP_NOFS);
10425 10424 if (!ne)
10426 10425 goto out;
10427 10426
modified fs/nfsd/nfsctl.c
@@ -1647,7 +1647,7 @@ static int nfsd_nl_fh_key_set(const struct nlattr *attr, struct nfsd_net *nn)
1647 1647 k1 = get_unaligned_le64(nla_data(attr) + 8);
1648 1648
1649 1649 if (!fh_key) {
1650 - fh_key = kmalloc_obj(siphash_key_t);
1650 + fh_key = kmalloc(sizeof(siphash_key_t), GFP_KERNEL);
1651 1651 if (!fh_key) {
1652 1652 trace_nfsd_ctl_fh_key_set(false, -ENOMEM);
1653 1653 return -ENOMEM;
modified fs/ntfs/attrib.c
@@ -1737,8 +1737,8 @@ static struct attr_def *ntfs_attr_find_in_attrdef(const struct ntfs_volume *vol,
1737 1737 struct attr_def *ad;
1738 1738
1739 1739 WARN_ON(!type);
1740 - for (ad = vol->attrdef; (u8 *)ad - (u8 *)vol->attrdef <=
1741 - vol->attrdef_size - (s32)sizeof(*ad) && ad->type; ++ad) {
1740 + for (ad = vol->attrdef; (u8 *)ad - (u8 *)vol->attrdef <
1741 + vol->attrdef_size && ad->type; ++ad) {
1742 1742 /* We have not found it yet, carry on searching. */
1743 1743 if (likely(le32_to_cpu(ad->type) < le32_to_cpu(type)))
1744 1744 continue;
@@ -2500,7 +2500,7 @@ int ntfs_resident_attr_record_add(struct ntfs_inode *ni, __le32 type,
2500 2500 return offset;
2501 2501 put_err_out:
2502 2502 ntfs_attr_put_search_ctx(ctx);
2503 - return err;
2503 + return -EIO;
2504 2504 }
2505 2505
2506 2506 /*
@@ -2639,7 +2639,7 @@ static int ntfs_non_resident_attr_record_add(struct ntfs_inode *ni, __le32 type,
2639 2639 return offset;
2640 2640 put_err_out:
2641 2641 ntfs_attr_put_search_ctx(ctx);
2642 - return err;
2642 + return -1;
2643 2643 }
2644 2644
2645 2645 /*
@@ -5704,12 +5704,12 @@ int ntfs_attr_fallocate(struct ntfs_inode *ni, loff_t start, loff_t byte_len, bo
5704 5704 lcn << vol->cluster_size_bits,
5705 5705 alloc_cnt <<
5706 5706 vol->cluster_size_bits);
5707 - if (err)
5707 + if (err > 0)
5708 5708 goto out;
5709 5709 }
5710 5710
5711 5711 if (signal_pending(current))
5712 - goto signal_out;
5712 + goto out;
5713 5713
5714 5714 vcn += alloc_cnt;
5715 5715 try_alloc_cnt -= alloc_cnt;
@@ -5730,7 +5730,7 @@ int ntfs_attr_fallocate(struct ntfs_inode *ni, loff_t start, loff_t byte_len, bo
5730 5730 up_write(&ni->runlist.lock);
5731 5731 mutex_unlock(&ni->mrec_lock);
5732 5732 if (err || signal_pending(current))
5733 - goto signal_out;
5733 + goto out;
5734 5734
5735 5735 vcn += alloc_cnt;
5736 5736 try_alloc_cnt -= alloc_cnt;
@@ -5756,8 +5756,4 @@ out_unmap:
5756 5756 mutex_unlock(&ni->mrec_lock);
5757 5757 out:
5758 5758 return err >= 0 ? 0 : err;
5759 - signal_out:
5760 - if (!err)
5761 - err = -EINTR;
5762 - goto out;
5763 5759 }
modified fs/ntfs/bdev-io.c
@@ -34,7 +34,7 @@ int ntfs_bdev_read(struct block_device *bdev, char *data, loff_t start, size_t s
34 34 int error;
35 35 struct bio *bio;
36 36 blk_opf_t op;
37 - sector_t sector = ntfs_bytes_to_bio_sector(start);
37 + sector_t sector = start >> SECTOR_SHIFT;
38 38
39 39 if (start & (SECTOR_SIZE - 1))
40 40 return -EINVAL;
modified fs/ntfs/bitmap.c
@@ -40,7 +40,7 @@ int ntfs_trim_fs(struct ntfs_volume *vol, struct fstrim_range *range)
40 40 end_cluster = vol->nr_clusters;
41 41 }
42 42
43 - ra = kzalloc_obj(*ra, GFP_NOFS);
43 + ra = kzalloc(sizeof(*ra), GFP_NOFS);
44 44 if (!ra)
45 45 return -ENOMEM;
46 46
@@ -64,7 +64,7 @@ int ntfs_trim_fs(struct ntfs_volume *vol, struct fstrim_range *range)
64 64
65 65 end = start_buf;
66 66 while (end < end_buf) {
67 - u64 aligned_start, aligned_end, aligned_count;
67 + u64 aligned_start, aligned_count;
68 68 u64 start = find_next_zero_bit(bitmap, end_buf - start_buf,
69 69 end - start_buf) + start_buf;
70 70 if (start >= end_buf)
@@ -74,10 +74,8 @@ int ntfs_trim_fs(struct ntfs_volume *vol, struct fstrim_range *range)
74 74 start - start_buf) + start_buf;
75 75
76 76 aligned_start = ALIGN(ntfs_cluster_to_bytes(vol, start), dq);
77 - aligned_end = ALIGN_DOWN(ntfs_cluster_to_bytes(vol, end), dq);
78 - if (aligned_start >= aligned_end)
79 - continue;
80 - aligned_count = aligned_end - aligned_start;
77 + aligned_count =
78 + ALIGN_DOWN(ntfs_cluster_to_bytes(vol, end - start), dq);
81 79 if (aligned_count >= range->minlen) {
82 80 ret = blkdev_issue_discard(vol->sb->s_bdev, aligned_start >> 9,
83 81 aligned_count >> 9, GFP_NOFS);
modified fs/ntfs/compress.c
@@ -514,8 +514,8 @@ int ntfs_read_compressed_block(struct folio *folio)
514 514 return -EIO;
515 515 }
516 516
517 - pages = kmalloc_objs(struct page *, nr_pages, GFP_NOFS);
518 - completed_pages = kmalloc_objs(int, nr_pages + 1, GFP_NOFS);
517 + pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_NOFS);
518 + completed_pages = kmalloc_array(nr_pages + 1, sizeof(int), GFP_NOFS);
519 519
520 520 if (unlikely(!pages || !completed_pages)) {
521 521 kfree(pages);
@@ -1262,7 +1262,7 @@ static int ntfs_compress_workspace_init(struct ntfs_inode *ni,
1262 1262 size = ni->itype.compressed.block_size + 2 *
1263 1263 (ni->itype.compressed.block_size / NTFS_SB_SIZE) + 2;
1264 1264 ws->nr_pages = DIV_ROUND_UP(size, PAGE_SIZE);
1265 - ws->pages = kzalloc_objs(*ws->pages, ws->nr_pages, GFP_NOFS);
1265 + ws->pages = kcalloc(ws->nr_pages, sizeof(*ws->pages), GFP_NOFS);
1266 1266 if (!ws->pages)
1267 1267 return -ENOMEM;
1268 1268
@@ -1414,7 +1414,7 @@ static int ntfs_write_cb(struct ntfs_inode *ni, loff_t pos, struct page **pages,
1414 1414 bio_pos = ntfs_cluster_to_bytes(vol, bio_lcn);
1415 1415 bio = bio_alloc(vol->sb->s_bdev, DIV_ROUND_UP(bio_size, PAGE_SIZE),
1416 1416 REQ_OP_WRITE, GFP_NOIO);
1417 - bio->bi_iter.bi_sector = ntfs_bytes_to_bio_sector(bio_pos);
1417 + bio->bi_iter.bi_sector = ntfs_bytes_to_sector(vol, bio_pos);
1418 1418
1419 1419 for (i = 0; bio_size; i++) {
1420 1420 unsigned int len = min_t(unsigned int, bio_size, PAGE_SIZE);
@@ -1483,7 +1483,7 @@ int ntfs_compress_write(struct ntfs_inode *ni, loff_t pos, size_t count,
1483 1483 pages_per_cb = DIV_ROUND_UP(offset_in_page(pos & ~(cb_size - 1)) +
1484 1484 cb_size, PAGE_SIZE);
1485 1485
1486 - pages = kmalloc_objs(struct page *, pages_per_cb, GFP_NOFS);
1486 + pages = kmalloc_array(pages_per_cb, sizeof(struct page *), GFP_NOFS);
1487 1487 if (!pages)
1488 1488 return -ENOMEM;
1489 1489 ctx = kvzalloc_obj(*ctx, GFP_NOFS);
modified fs/ntfs/dir.c
@@ -166,8 +166,8 @@ found_it:
166 166 */
167 167 if (ie->key.file_name.file_name_type == FILE_NAME_DOS) {
168 168 if (!name) {
169 - name = kmalloc_obj(struct ntfs_name,
170 - GFP_NOFS);
169 + name = kmalloc(sizeof(struct ntfs_name),
170 + GFP_NOFS);
171 171 if (!name) {
172 172 err = -ENOMEM;
173 173 goto err_out;
@@ -401,8 +401,8 @@ found_it2:
401 401 */
402 402 if (ie->key.file_name.file_name_type == FILE_NAME_DOS) {
403 403 if (!name) {
404 - name = kmalloc_obj(struct ntfs_name,
405 - GFP_NOFS);
404 + name = kmalloc(sizeof(struct ntfs_name),
405 + GFP_NOFS);
406 406 if (!name) {
407 407 err = -ENOMEM;
408 408 goto unm_err_out;
@@ -700,7 +700,7 @@ static int ntfs_ia_blocks_readahead(struct ntfs_inode *ia_ni, loff_t pos)
700 700 if (dir_start_index >= dir_end_index)
701 701 return 0;
702 702
703 - dir_ra = kzalloc_obj(*dir_ra, GFP_NOFS);
703 + dir_ra = kzalloc(sizeof(*dir_ra), GFP_NOFS);
704 704 if (!dir_ra)
705 705 return -ENOMEM;
706 706
@@ -777,7 +777,7 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
777 777 return -ENOMEM;
778 778 }
779 779
780 - ra = kzalloc_obj(struct file_ra_state, GFP_NOFS);
780 + ra = kzalloc(sizeof(struct file_ra_state), GFP_NOFS);
781 781 if (!ra) {
782 782 kfree(name);
783 783 ntfs_index_ctx_put(ictx);
@@ -813,7 +813,7 @@ static int ntfs_readdir(struct file *file, struct dir_context *actor)
813 813 goto out;
814 814 }
815 815 } else if (!private) {
816 - private = kzalloc_obj(struct ntfs_file_private);
816 + private = kzalloc(sizeof(struct ntfs_file_private), GFP_KERNEL);
817 817 if (!private) {
818 818 err = -ENOMEM;
819 819 goto out;
@@ -949,7 +949,7 @@ nextdir:
949 949 }
950 950
951 951 if (!nir) {
952 - nir = kzalloc_obj(struct ntfs_index_ra);
952 + nir = kzalloc(sizeof(struct ntfs_index_ra), GFP_KERNEL);
953 953 if (nir) {
954 954 nir->start_index = index;
955 955 nir->count = 1;
modified fs/ntfs/ea.c
@@ -235,7 +235,7 @@ static int ntfs_set_ea(struct inode *inode, const char *name, size_t name_len,
235 235 ea_info_qsize = le32_to_cpu(p_ea_info->ea_query_length);
236 236 } else {
237 237 create_ea_info:
238 - p_ea_info = kzalloc_obj(struct ea_information, GFP_NOFS);
238 + p_ea_info = kzalloc(sizeof(struct ea_information), GFP_NOFS);
239 239 if (!p_ea_info)
240 240 return -ENOMEM;
241 241
@@ -404,12 +404,10 @@ alloc_new_ea:
404 404 *packed_ea_size = p_ea_info->ea_length;
405 405 mark_mft_record_dirty(ni);
406 406 out:
407 - if (!err) {
408 - if (ea_info_qsize > 0)
409 - NInoSetHasEA(ni);
410 - else
411 - NInoClearHasEA(ni);
412 - }
407 + if (ea_info_qsize > 0)
408 + NInoSetHasEA(ni);
409 + else
410 + NInoClearHasEA(ni);
413 411
414 412 kvfree(ea_buf);
415 413 kvfree(old_ea_buf);
@@ -617,7 +615,7 @@ static int ntfs_getxattr(const struct xattr_handler *handler,
617 615 if (!buffer) {
618 616 err = sizeof(u8);
619 617 } else if (size < sizeof(u8)) {
620 - err = -ERANGE;
618 + err = -ENODATA;
621 619 } else {
622 620 err = sizeof(u8);
623 621 *(u8 *)buffer = (u8)(le32_to_cpu(ni->flags) & 0x3F);
@@ -630,7 +628,7 @@ static int ntfs_getxattr(const struct xattr_handler *handler,
630 628 if (!buffer) {
631 629 err = sizeof(u32);
632 630 } else if (size < sizeof(u32)) {
633 - err = -ERANGE;
631 + err = -ENODATA;
634 632 } else {
635 633 err = sizeof(u32);
636 634 *(u32 *)buffer = le32_to_cpu(ni->flags);
@@ -755,39 +753,18 @@ static int ntfs_new_attr_flags(struct ntfs_inode *ni, __le32 fattr)
755 753 old_arec_size = le32_to_cpu(a->length);
756 754
757 755 /*
758 - * Move payloads before shrinking the record. Otherwise resizing moves
756 + * Move payloads before shrinking the record. Otherwise resizing moves
759 757 * the following attribute over the old payload before it can be copied.
760 - *
761 - * When offsets increase, move mapping_pairs first to avoid name
762 - * overwriting the start of mapping_pairs.
763 758 */
764 759 if (arec_size < old_arec_size) {
765 - if (name_ofs > old_name_ofs) {
766 - /* Payload offsets increased: move mapping pairs first. */
767 - if (mp_ofs != old_mp_ofs)
768 - memmove((u8 *)a + mp_ofs,
769 - (u8 *)a + old_mp_ofs,
770 - mp_size);
771 - if (a->name_length && name_ofs != old_name_ofs)
772 - memmove((u8 *)a + name_ofs,
773 - (u8 *)a + old_name_ofs,
774 - a->name_length *
775 - sizeof(__le16));
776 - } else {
777 - /* Payload offsets decreased or unchanged: move name first. */
778 - if (a->name_length && name_ofs != old_name_ofs)
779 - memmove((u8 *)a + name_ofs,
780 - (u8 *)a + old_name_ofs,
781 - a->name_length *
782 - sizeof(__le16));
783 - if (mp_ofs != old_mp_ofs)
784 - memmove((u8 *)a + mp_ofs,
785 - (u8 *)a + old_mp_ofs,
786 - mp_size);
787 - }
760 + if (a->name_length && name_ofs != old_name_ofs)
761 + memmove((u8 *)a + name_ofs, (u8 *)a + old_name_ofs,
762 + a->name_length * sizeof(__le16));
763 + if (mp_ofs != old_mp_ofs)
764 + memmove((u8 *)a + mp_ofs, (u8 *)a + old_mp_ofs, mp_size);
788 765 }
789 766
790 - err = ntfs_attr_record_resize(ctx->mrec, a, arec_size);
767 + err = ntfs_attr_record_resize(m, a, arec_size);
791 768 if (unlikely(err))
792 769 goto err_out;
793 770
modified fs/ntfs/file.c
@@ -270,25 +270,18 @@ static int ntfs_setattr_size(struct inode *vi, struct iattr *attr)
270 270 return err;
271 271
272 272 inode_dio_wait(vi);
273 -
274 - /*
275 - * Serialize with page faults and pagecache instantiation so that
276 - * readers cannot observe the size change until the attribute
277 - * updates below have completed.
278 - */
279 - filemap_invalidate_lock(vi->i_mapping);
280 273 if (attr->ia_size > old_size) {
281 274 truncate_pagecache(vi, old_size);
282 275 i_size_write(vi, attr->ia_size);
283 276 pagecache_isize_extended(vi, old_size, attr->ia_size);
284 - } else {
277 + } else
285 278 truncate_setsize(vi, attr->ia_size);
286 - }
287 279
288 280 err = ntfs_truncate_vfs(vi, attr->ia_size, old_size);
289 - if (err)
281 + if (err) {
290 282 i_size_write(vi, old_size);
291 - filemap_invalidate_unlock(vi->i_mapping);
283 + return err;
284 + }
292 285
293 286 return err;
294 287 }
@@ -676,7 +669,6 @@ out_lock:
676 669 static vm_fault_t ntfs_filemap_page_mkwrite(struct vm_fault *vmf)
677 670 {
678 671 struct inode *inode = file_inode(vmf->vma->vm_file);
679 - struct address_space *mapping = inode->i_mapping;
680 672 vm_fault_t ret;
681 673
682 674 if (NInoWofCompressed(NTFS_I(inode)))
@@ -685,14 +677,7 @@ static vm_fault_t ntfs_filemap_page_mkwrite(struct vm_fault *vmf)
685 677 sb_start_pagefault(inode->i_sb);
686 678 file_update_time(vmf->vma->vm_file);
687 679
688 - /*
689 - * Serialize against truncate/fallocate which hold the lock
690 - * exclusively while invalidating pagecache and changing extents.
691 - */
692 - filemap_invalidate_lock_shared(mapping);
693 680 ret = iomap_page_mkwrite(vmf, &ntfs_page_mkwrite_iomap_ops, NULL);
694 - filemap_invalidate_unlock_shared(mapping);
695 -
696 681 sb_end_pagefault(inode->i_sb);
697 682 return ret;
698 683 }
@@ -1131,6 +1116,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t offset, loff_t le
1131 1116 struct ntfs_volume *vol = ni->vol;
1132 1117 int err = 0;
1133 1118 loff_t old_size;
1119 + bool map_locked = false;
1134 1120
1135 1121 if (mode & ~(NTFS_FALLOC_FL_SUPPORTED))
1136 1122 return -EOPNOTSUPP;
@@ -1162,13 +1148,16 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t offset, loff_t le
1162 1148
1163 1149 inode_lock(vi);
1164 1150 if (NInoCompressed(ni) || NInoEncrypted(ni) || NInoWofCompressed(ni)) {
1165 - inode_unlock(vi);
1166 - return -EOPNOTSUPP;
1151 + err = -EOPNOTSUPP;
1152 + goto out;
1167 1153 }
1168 1154
1169 1155 inode_dio_wait(vi);
1170 - /* Take invalidate_lock for all fallocate operations to prevent races */
1171 - filemap_invalidate_lock(vi->i_mapping);
1156 + if (mode & (FALLOC_FL_PUNCH_HOLE | FALLOC_FL_COLLAPSE_RANGE |
1157 + FALLOC_FL_INSERT_RANGE)) {
1158 + filemap_invalidate_lock(vi->i_mapping);
1159 + map_locked = true;
1160 + }
1172 1161
1173 1162 switch (mode & FALLOC_FL_MODE_MASK) {
1174 1163 case FALLOC_FL_ALLOCATE_RANGE:
@@ -1193,15 +1182,14 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t offset, loff_t le
1193 1182
1194 1183 err = file_modified(file);
1195 1184 out:
1196 - if (!err && mode == 0 && NInoNonResident(ni) &&
1197 - offset > old_size) {
1198 - truncate_pagecache(vi, old_size);
1199 - pagecache_isize_extended(vi, old_size, offset);
1200 - }
1201 -
1202 - filemap_invalidate_unlock(vi->i_mapping);
1203 -
1185 + if (map_locked)
1186 + filemap_invalidate_unlock(vi->i_mapping);
1204 1187 if (!err) {
1188 + if (mode == 0 && NInoNonResident(ni) &&
1189 + offset > old_size) {
1190 + truncate_pagecache(vi, old_size);
1191 + pagecache_isize_extended(vi, old_size, offset);
1192 + }
1205 1193 NInoSetFileNameDirty(ni);
1206 1194 inode_set_mtime_to_ts(vi, inode_set_ctime_current(vi));
1207 1195 mark_inode_dirty(vi);
modified fs/ntfs/index.c
@@ -1660,7 +1660,7 @@ resplit:
1660 1660 goto out;
1661 1661 }
1662 1662 } else {
1663 - si = kzalloc_obj(struct split_info, GFP_NOFS);
1663 + si = kzalloc(sizeof(struct split_info), GFP_NOFS);
1664 1664 if (!si) {
1665 1665 ntfs_ibm_clear(icx, new_vcn);
1666 1666 ret = -ENOMEM;
modified fs/ntfs/inode.c
@@ -1852,7 +1852,7 @@ int ntfs_read_inode_mount(struct inode *vi)
1852 1852 struct mft_record *m = NULL;
1853 1853 struct attr_record *a;
1854 1854 struct ntfs_attr_search_ctx *ctx;
1855 - unsigned int i;
1855 + unsigned int i, nr_blocks;
1856 1856 int err;
1857 1857 size_t new_rl_count;
1858 1858
@@ -1896,6 +1896,11 @@ int ntfs_read_inode_mount(struct inode *vi)
1896 1896 goto err_out;
1897 1897 }
1898 1898
1899 + /* Determine the first block of the $MFT/$DATA attribute. */
1900 + nr_blocks = ntfs_bytes_to_sector(vol, vol->mft_record_size);
1901 + if (!nr_blocks)
1902 + nr_blocks = 1;
1903 +
1899 1904 /* Load $MFT/$DATA's first mft record. */
1900 1905 err = ntfs_bdev_read(sb->s_bdev, (char *)m,
1901 1906 ntfs_cluster_to_bytes(vol, vol->mft_lcn), i);
@@ -3775,7 +3780,8 @@ static s64 __ntfs_inode_non_resident_attr_pwrite(struct inode *vi,
3775 3780 bio = bio_alloc(vol->sb->s_bdev, 1, REQ_OP_WRITE,
3776 3781 GFP_NOIO);
3777 3782 bio->bi_iter.bi_sector =
3778 - ntfs_bytes_to_bio_sector(ntfs_cluster_to_bytes(vol, lcn) +
3783 + ntfs_bytes_to_sector(vol,
3784 + ntfs_cluster_to_bytes(vol, lcn) +
3779 3785 lcn_folio_off);
3780 3786
3781 3787 length = min_t(unsigned long,
modified fs/ntfs/lcnalloc.c
@@ -53,10 +53,10 @@ int ntfs_cluster_free_from_rl_nolock(struct ntfs_volume *vol,
53 53 if (rl->lcn < 0)
54 54 continue;
55 55 err = ntfs_bitmap_clear_run(lcnbmp_vi, rl->lcn, rl->length);
56 - if (likely(!err))
57 - nr_freed += rl->length;
58 - else if (!ret || ret == -ENOMEM)
56 + if (unlikely(err && (!ret || ret == -ENOMEM) && ret != err))
59 57 ret = err;
58 + else
59 + nr_freed += rl->length;
60 60 }
61 61 ntfs_inc_free_clusters(vol, nr_freed);
62 62 ntfs_debug("Done.");
@@ -1045,9 +1045,8 @@ err_out:
1045 1045 "Failed to rollback (error %i). Leaving inconsistent metadata! Unmount and run chkdsk.",
1046 1046 (int)delta);
1047 1047 NVolSetErrors(vol);
1048 - } else {
1049 - ntfs_dec_free_clusters(vol, delta);
1050 1048 }
1049 + ntfs_dec_free_clusters(vol, delta);
1051 1050 up_write(&vol->lcnbmp_lock);
1052 1051 memalloc_nofs_restore(memalloc_flags);
1053 1052 ntfs_error(vol->sb, "Aborting (error %i).", err);
modified fs/ntfs/logfile.c
@@ -691,7 +691,7 @@ map_vcn:
691 691
692 692 memset(empty_buf, 0xff, vol->cluster_size);
693 693
694 - ra = kzalloc_obj(*ra, GFP_NOFS);
694 + ra = kzalloc(sizeof(*ra), GFP_NOFS);
695 695 if (!ra)
696 696 goto err;
697 697
modified fs/ntfs/mft.c
@@ -499,8 +499,8 @@ int ntfs_sync_mft_mirror(struct ntfs_volume *vol, const u64 mft_no,
499 499
500 500 bio = bio_alloc(vol->sb->s_bdev, 1, REQ_OP_WRITE, GFP_NOIO);
501 501 bio->bi_iter.bi_sector =
502 - ntfs_bytes_to_bio_sector(NTFS_CLU_TO_B(vol, vol->mftmirr_lcn) +
503 - lcn_folio_off + folio_ofs);
502 + NTFS_B_TO_SECTOR(vol, NTFS_CLU_TO_B(vol, vol->mftmirr_lcn) +
503 + lcn_folio_off + folio_ofs);
504 504
505 505 if (bio_add_folio(bio, folio, vol->mft_record_size, folio_ofs))
506 506 err = submit_bio_wait(bio);
@@ -580,7 +580,7 @@ int write_mft_record_nolock(struct ntfs_inode *ni, struct mft_record *m, int syn
580 580 err = pre_write_mst_fixup((struct ntfs_record *)fixup_m, vol->mft_record_size);
581 581 if (err) {
582 582 ntfs_error(vol->sb, "Failed to apply mst fixups!");
583 - goto unmap_err_out;
583 + goto err_out;
584 584 }
585 585
586 586 folio_size = vol->mft_record_size / ni->mft_lcn_count;
@@ -592,8 +592,8 @@ int write_mft_record_nolock(struct ntfs_inode *ni, struct mft_record *m, int syn
592 592
593 593 bio = bio_alloc(vol->sb->s_bdev, 1, REQ_OP_WRITE, GFP_NOIO);
594 594 bio->bi_iter.bi_sector =
595 - ntfs_bytes_to_bio_sector(NTFS_CLU_TO_B(vol, ni->mft_lcn[i]) +
596 - clu_off);
595 + NTFS_B_TO_SECTOR(vol, NTFS_CLU_TO_B(vol, ni->mft_lcn[i]) +
596 + clu_off);
597 597
598 598 if (!bio_add_folio(bio, folio, folio_size,
599 599 ni->folio_ofs + offset)) {
@@ -645,8 +645,6 @@ done:
645 645 return 0;
646 646 put_bio_out:
647 647 bio_put(bio);
648 - unmap_err_out:
649 - kunmap_local(kaddr);
650 648 err_out:
651 649 /*
652 650 * The caller should mark the base inode as bad so no more I/O
@@ -2635,13 +2633,11 @@ static int ntfs_write_mft_block(struct folio *folio, struct writeback_control *w
2635 2633 struct ntfs_inode *ni = NTFS_I(vi);
2636 2634 struct ntfs_volume *vol = ni->vol;
2637 2635 u8 *kaddr;
2638 - struct ntfs_inode **locked_nis __free(kfree) = kmalloc_objs(struct ntfs_inode *,
2639 - PAGE_SIZE / NTFS_BLOCK_SIZE,
2640 - GFP_NOFS);
2636 + struct ntfs_inode **locked_nis __free(kfree) = kmalloc_array(PAGE_SIZE / NTFS_BLOCK_SIZE,
2637 + sizeof(struct ntfs_inode *), GFP_NOFS);
2641 2638 int nr_locked_nis = 0, err = 0, mft_ofs, prev_mft_ofs;
2642 - struct inode **ref_inos __free(kfree) = kmalloc_objs(struct inode *,
2643 - PAGE_SIZE / NTFS_BLOCK_SIZE,
2644 - GFP_NOFS);
2639 + struct inode **ref_inos __free(kfree) = kmalloc_array(PAGE_SIZE / NTFS_BLOCK_SIZE,
2640 + sizeof(struct inode *), GFP_NOFS);
2645 2641 int nr_ref_inos = 0;
2646 2642 struct bio *bio = NULL;
2647 2643 u64 mft_no;
@@ -2744,8 +2740,8 @@ flush_bio:
2744 2740 bio = bio_alloc(vol->sb->s_bdev, 1, REQ_OP_WRITE,
2745 2741 GFP_NOIO);
2746 2742 bio->bi_iter.bi_sector =
2747 - ntfs_bytes_to_bio_sector(
2748 - ntfs_cluster_to_bytes(vol, lcn) + off);
2743 + ntfs_bytes_to_sector(vol,
2744 + ntfs_cluster_to_bytes(vol, lcn) + off);
2749 2745 }
2750 2746
2751 2747 if (vol->cluster_size == NTFS_BLOCK_SIZE &&
modified fs/ntfs/ntfs.h
@@ -19,7 +19,6 @@
19 19 #include <linux/nls.h>
20 20 #include <linux/smp.h>
21 21 #include <linux/pagemap.h>
22 - #include <linux/blk_types.h>
23 22 #include <linux/uidgid.h>
24 23
25 24 #include "volume.h"
@@ -72,6 +71,8 @@
72 71 #define NTFS_CLU_TO_POFS(vol, clu) (((u64)(clu) << (vol)->cluster_size_bits) & \
73 72 ~PAGE_MASK)
74 73
74 + #define NTFS_B_TO_SECTOR(vol, b) ((b) >> ((vol)->sb)->s_blocksize_bits)
75 +
75 76 enum {
76 77 NTFS_BLOCK_SIZE = 512,
77 78 NTFS_BLOCK_SIZE_BITS = 9,
@@ -153,10 +154,11 @@ static inline u64 ntfs_cluster_to_poff(const struct ntfs_volume *vol,
153 154 return (clu << vol->cluster_size_bits) & ~PAGE_MASK;
154 155 }
155 156
156 - /* Convert a byte offset on the volume to a bio sector number. */
157 - static inline sector_t ntfs_bytes_to_bio_sector(u64 bytes)
157 + /* Convert byte offset to sector (block) number. */
158 + static inline sector_t ntfs_bytes_to_sector(const struct ntfs_volume *vol,
159 + u64 bytes)
158 160 {
159 - return bytes >> SECTOR_SHIFT;
161 + return bytes >> vol->sb->s_blocksize_bits;
160 162 }
161 163
162 164 /* Global variables. */
modified fs/ntfs/reparse.c
@@ -405,7 +405,7 @@ unsigned int ntfs_reparse_tag_dt_types(struct ntfs_volume *vol, unsigned long mr
405 405
406 406 vi = ntfs_iget(vol->sb, mref);
407 407 if (IS_ERR(vi))
408 - return DT_UNKNOWN;
408 + return PTR_ERR(vi);
409 409
410 410 reparse_attr = (struct reparse_point *)ntfs_attr_readall(NTFS_I(vi),
411 411 AT_REPARSE_POINT, NULL, 0, &attr_size);
@@ -694,9 +694,8 @@ static int update_reparse_data(struct ntfs_inode *ni, struct ntfs_index_context
694 694 goto put_rp_inode;
695 695 }
696 696
697 - err = set_reparse_index(ni, xr,
698 - ((const struct reparse_point *)value)->reparse_tag);
699 - if (err && oldsize > 0) {
697 + if (set_reparse_index(ni, xr, ((const struct reparse_point *)value)->reparse_tag) &&
698 + oldsize > 0) {
700 699 /*
701 700 * If cannot index, try to remove the reparse
702 701 * data and log the error. There will be an
modified fs/ntfs/runlist.c
@@ -1804,7 +1804,7 @@ merge_src_rle:
1804 1804 new_2nd_cnt = src_cnt;
1805 1805 new_cnt = new_1st_cnt + new_2nd_cnt + new_3rd_cnt;
1806 1806 new_cnt += dst_rl_split.lcn >= LCN_HOLE ? 1 : 0;
1807 - new_rl = kvzalloc_objs(*new_rl, new_cnt, GFP_NOFS);
1807 + new_rl = kvcalloc(new_cnt, sizeof(*new_rl), GFP_NOFS);
1808 1808 if (!new_rl)
1809 1809 return ERR_PTR(-ENOMEM);
1810 1810
@@ -1888,13 +1888,13 @@ struct runlist_element *ntfs_rl_punch_hole(struct runlist_element *dst_rl, int d
1888 1888
1889 1889 punch_cnt = (int)(e_rl - s_rl) + 1;
1890 1890
1891 - *punch_rl = kvzalloc_objs(struct runlist_element, punch_cnt + 1,
1892 - GFP_NOFS);
1891 + *punch_rl = kvcalloc(punch_cnt + 1, sizeof(struct runlist_element),
1892 + GFP_NOFS);
1893 1893 if (!*punch_rl)
1894 1894 return ERR_PTR(-ENOMEM);
1895 1895
1896 1896 new_cnt = dst_cnt - (int)(e_rl - s_rl + 1) + 3;
1897 - new_rl = kvzalloc_objs(struct runlist_element, new_cnt, GFP_NOFS);
1897 + new_rl = kvcalloc(new_cnt, sizeof(struct runlist_element), GFP_NOFS);
1898 1898 if (!new_rl) {
1899 1899 kvfree(*punch_rl);
1900 1900 *punch_rl = NULL;
@@ -2038,13 +2038,13 @@ struct runlist_element *ntfs_rl_collapse_range(struct runlist_element *dst_rl, i
2038 2038 one_split_3 = e_rl == s_rl && begin_split && end_split;
2039 2039
2040 2040 punch_cnt = (int)(e_rl - s_rl) + 1;
2041 - *punch_rl = kvzalloc_objs(struct runlist_element, punch_cnt + 1,
2042 - GFP_NOFS);
2041 + *punch_rl = kvcalloc(punch_cnt + 1, sizeof(struct runlist_element),
2042 + GFP_NOFS);
2043 2043 if (!*punch_rl)
2044 2044 return ERR_PTR(-ENOMEM);
2045 2045
2046 2046 new_cnt = dst_cnt - (int)(e_rl - s_rl + 1) + 3;
2047 - new_rl = kvzalloc_objs(struct runlist_element, new_cnt, GFP_NOFS);
2047 + new_rl = kvcalloc(new_cnt, sizeof(struct runlist_element), GFP_NOFS);
2048 2048 if (!new_rl) {
2049 2049 kvfree(*punch_rl);
2050 2050 *punch_rl = NULL;
modified fs/ntfs/super.c
@@ -557,8 +557,8 @@ static bool is_boot_sector_ntfs(const struct super_block *sb,
557 557 * Check sectors per cluster value is valid and the cluster size
558 558 * is not above the maximum (2MB).
559 559 */
560 - if (b->bpb.sectors_per_cluster < 0xf4 &&
561 - !is_power_of_2(b->bpb.sectors_per_cluster))
560 + if (b->bpb.sectors_per_cluster > 0x80 &&
561 + b->bpb.sectors_per_cluster < 0xf4)
562 562 goto not_ntfs;
563 563
564 564 /* Check reserved/unused fields are really zero. */
@@ -695,7 +695,7 @@ static bool parse_ntfs_boot_sector(struct ntfs_volume *vol,
695 695 * = -log2(mft_record_size) bytes. mft_record_size normaly is
696 696 * 1024 bytes, which is encoded as 0xF6 (-10 in decimal).
697 697 */
698 - vol->mft_record_size = 1U << -clusters_per_mft_record;
698 + vol->mft_record_size = 1 << -clusters_per_mft_record;
699 699 vol->mft_record_size_mask = vol->mft_record_size - 1;
700 700 vol->mft_record_size_bits = ffs(vol->mft_record_size) - 1;
701 701 ntfs_debug("vol->mft_record_size = %i (0x%x)", vol->mft_record_size,
@@ -732,7 +732,7 @@ static bool parse_ntfs_boot_sector(struct ntfs_volume *vol,
732 732 * index_record_size normaly equals 4096 bytes, which is
733 733 * encoded as 0xF4 (-12 in decimal).
734 734 */
735 - vol->index_record_size = 1U << -clusters_per_index_record;
735 + vol->index_record_size = 1 << -clusters_per_index_record;
736 736 vol->index_record_size_mask = vol->index_record_size - 1;
737 737 vol->index_record_size_bits = ffs(vol->index_record_size) - 1;
738 738 ntfs_debug("vol->index_record_size = %i (0x%x)",
@@ -1241,9 +1241,9 @@ static bool load_and_init_attrdef(struct ntfs_volume *vol)
1241 1241 goto failed;
1242 1242 }
1243 1243 NInoSetSparseDisabled(NTFS_I(ino));
1244 - /* FILE_AttrDef must hold at least one entry and fit inside 31 bits. */
1244 + /* The size of FILE_AttrDef must be above 0 and fit inside 31 bits. */
1245 1245 i_size = i_size_read(ino);
1246 - if (i_size < (s64)sizeof(struct attr_def) || i_size > 0x7fffffff)
1246 + if (i_size <= 0 || i_size > 0x7fffffff)
1247 1247 goto iput_failed;
1248 1248 vol->attrdef = kvzalloc(i_size, GFP_NOFS);
1249 1249 if (!vol->attrdef)
@@ -1862,8 +1862,7 @@ static int ntfs_sync_fs(struct super_block *sb, int wait)
1862 1862 return 0;
1863 1863
1864 1864 /* If there are some dirty buffers in the bdev inode */
1865 - if (!NVolErrors(vol) &&
1866 - ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY)) {
1865 + if (ntfs_clear_volume_flags(vol, VOLUME_IS_DIRTY)) {
1867 1866 ntfs_warning(sb, "Failed to clear dirty bit in volume information flags. Run chkdsk.");
1868 1867 err = -EIO;
1869 1868 }
@@ -2539,7 +2538,7 @@ static int ntfs_init_fs_context(struct fs_context *fc)
2539 2538 struct ntfs_volume *vol;
2540 2539
2541 2540 /* Allocate a new struct ntfs_volume and place it in sb->s_fs_info. */
2542 - vol = kmalloc_obj(struct ntfs_volume, GFP_NOFS);
2541 + vol = kmalloc(sizeof(struct ntfs_volume), GFP_NOFS);
2543 2542 if (!vol)
2544 2543 return -ENOMEM;
2545 2544
modified fs/ntfs/wof.c
@@ -39,6 +39,8 @@ struct ntfs_wof_workspace {
39 39 struct mutex *lock;
40 40 const struct ntfs_codec_ops *codec;
41 41 u32 comp_unit;
42 + void *input;
43 + size_t input_size;
42 44 void *output;
43 45 void *scratch;
44 46 };
@@ -95,36 +97,30 @@ static struct ntfs_wof_workspace *ntfs_wof_workspace(u8 block_size_bits)
95 97 }
96 98 }
97 99
98 - /*
99 - * Size of the buffer a chunk is read into. A chunk is read straight off the
100 - * device, so the buffer has to hold @comp_unit bytes plus the leading partial
101 - * sector.
102 - */
103 - static size_t ntfs_wof_input_size(const struct ntfs_wof_workspace *ws)
104 - {
105 - return round_up((size_t)ws->comp_unit + 511, 512);
106 - }
107 -
108 100 static int ntfs_wof_workspace_prepare(struct ntfs_wof_workspace *ws)
109 101 {
110 - void *output, *scratch;
102 + void *input, *output, *scratch;
111 103 size_t scratch_size;
112 104
113 - if (ws->output)
105 + if (ws->input)
114 106 return 0;
115 107
108 + ws->input_size = round_up((size_t)ws->comp_unit + 511, 512);
116 109 scratch_size = ws->codec->scratch_size(ws->comp_unit);
117 110 if (!scratch_size)
118 111 return -EINVAL;
119 112
113 + input = kvmalloc(ws->input_size, GFP_NOFS);
120 114 output = kvmalloc(ws->comp_unit, GFP_NOFS);
121 115 scratch = kvzalloc(scratch_size, GFP_NOFS);
122 - if (!output || !scratch) {
116 + if (!input || !output || !scratch) {
117 + kvfree(input);
123 118 kvfree(output);
124 119 kvfree(scratch);
125 120 return -ENOMEM;
126 121 }
127 122
123 + ws->input = input;
128 124 ws->output = output;
129 125 ws->scratch = scratch;
130 126 return 0;
@@ -138,8 +134,10 @@ void ntfs_wof_free_workspaces(void)
138 134 struct ntfs_wof_workspace *ws = ntfs_wof_workspaces[i];
139 135
140 136 mutex_lock(ws->lock);
137 + kvfree(ws->input);
141 138 kvfree(ws->output);
142 139 kvfree(ws->scratch);
140 + ws->input = NULL;
143 141 ws->output = NULL;
144 142 ws->scratch = NULL;
145 143 mutex_unlock(ws->lock);
@@ -604,51 +602,6 @@ static int ntfs_wof_try_direct(struct ntfs_wof_workspace *ws,
604 602 chunk_end, src, src_len, dst_len);
605 603 }
606 604
607 - /*
608 - * Decompress one chunk into @folio. Only this step needs the workspace, so it
609 - * is the only step that takes the workspace lock.
610 - */
611 - static int ntfs_wof_decompress_chunk(struct ntfs_wof_workspace *ws,
612 - struct ntfs_volume *vol,
613 - struct address_space *mapping,
614 - struct folio *folio, loff_t folio_start,
615 - loff_t folio_end, u64 chunk_file_offset,
616 - char *chunk_mem, u32 chunk_size,
617 - u32 decomp_size)
618 - {
619 - loff_t chunk_end = chunk_file_offset + decomp_size;
620 - loff_t copy_start, copy_end;
621 - int err;
622 -
623 - mutex_lock(ws->lock);
624 - err = ntfs_wof_workspace_prepare(ws);
625 - if (err)
626 - goto out_unlock;
627 -
628 - err = ntfs_wof_try_direct(ws, mapping, folio, chunk_file_offset,
629 - chunk_end, chunk_mem, chunk_size,
630 - decomp_size);
631 - if (err != -EAGAIN)
632 - goto out_unlock;
633 -
634 - err = ntfs_wof_decode(ws, chunk_mem, chunk_size, ws->output,
635 - decomp_size);
636 - if (err) {
637 - ntfs_error(vol->sb, "Decompression failed: %d", err);
638 - err = -EINVAL;
639 - goto out_unlock;
640 - }
641 -
642 - copy_start = max_t(loff_t, folio_start, chunk_file_offset);
643 - copy_end = min_t(loff_t, folio_end, chunk_file_offset + decomp_size);
644 - memcpy_to_folio(folio, copy_start - folio_start,
645 - ws->output + copy_start - chunk_file_offset,
646 - copy_end - copy_start);
647 - out_unlock:
648 - mutex_unlock(ws->lock);
649 - return err;
650 - }
651 -
652 605 int ntfs_read_wof_compressed_block(struct folio *folio)
653 606 {
654 607 struct address_space *mapping = folio->mapping;
@@ -660,8 +613,6 @@ int ntfs_read_wof_compressed_block(struct folio *folio)
660 613 loff_t folio_start = folio_pos(folio);
661 614 loff_t folio_end = folio_next_pos(folio);
662 615 char *chunk_mem;
663 - void *input;
664 - size_t input_size;
665 616 u32 decomp_size;
666 617 u64 chunk_count, chunk_idx, last_chunk, chunk_offset;
667 618 int err = 0;
@@ -701,12 +652,10 @@ int ntfs_read_wof_compressed_block(struct folio *folio)
701 652 goto out_iput;
702 653 }
703 654
704 - input_size = ntfs_wof_input_size(ws);
705 - input = kvmalloc(input_size, GFP_NOFS);
706 - if (!input) {
707 - err = -ENOMEM;
708 - goto out_iput;
709 - }
655 + mutex_lock(ws->lock);
656 + err = ntfs_wof_workspace_prepare(ws);
657 + if (err)
658 + goto out_unlock_ws;
710 659
711 660 chunk_idx = div_u64(folio_start, ws->comp_unit);
712 661 last_chunk =
@@ -714,35 +663,55 @@ int ntfs_read_wof_compressed_block(struct folio *folio)
714 663 chunk_count = DIV_ROUND_UP_ULL(i_size, ws->comp_unit);
715 664 for (; chunk_idx <= last_chunk; chunk_idx++) {
716 665 u32 chunk_size;
666 + u64 chunk_file_offset;
667 + loff_t chunk_end, copy_start, copy_end;
717 668
718 669 decomp_size = chunk_idx + 1 == chunk_count ?
719 670 i_size - chunk_idx * ws->comp_unit :
720 671 ws->comp_unit;
721 672 err = parse_wof_chunk_table(ni, wof_ni, chunk_idx, chunk_count,
722 673 decomp_size, &chunk_offset,
723 - &chunk_size, input, input_size);
674 + &chunk_size, ws->input,
675 + ws->input_size);
724 676 if (err)
725 - goto out_free_input;
677 + goto out_unlock_ws;
726 678
727 679 err = ntfs_read_wof_chunk(vol, wof_ni, chunk_offset, chunk_size,
728 - input, input_size, &chunk_mem);
680 + ws->input, ws->input_size,
681 + &chunk_mem);
729 682 if (err)
730 - goto out_free_input;
683 + goto out_unlock_ws;
684 +
685 + chunk_file_offset = chunk_idx * ws->comp_unit;
686 + chunk_end = chunk_file_offset + decomp_size;
687 + err = ntfs_wof_try_direct(ws, mapping, folio, chunk_file_offset,
688 + chunk_end, chunk_mem, chunk_size,
689 + decomp_size);
690 + if (!err)
691 + continue;
692 + if (err != -EAGAIN)
693 + goto out_unlock_ws;
731 694
732 - err = ntfs_wof_decompress_chunk(ws, vol, mapping, folio,
733 - folio_start, folio_end,
734 - chunk_idx * ws->comp_unit,
735 - chunk_mem, chunk_size,
736 - decomp_size);
737 - if (err)
738 - goto out_free_input;
695 + err = ntfs_wof_decode(ws, chunk_mem, chunk_size, ws->output,
696 + decomp_size);
697 + if (err) {
698 + ntfs_error(vol->sb, "Decompression failed: %d", err);
699 + err = -EINVAL;
700 + goto out_unlock_ws;
701 + }
702 + copy_start = max_t(loff_t, folio_start, chunk_file_offset);
703 + copy_end = min_t(loff_t, folio_end,
704 + chunk_file_offset + decomp_size);
705 + memcpy_to_folio(folio, copy_start - folio_start,
706 + ws->output + copy_start - chunk_file_offset,
707 + copy_end - copy_start);
739 708 }
740 709
741 710 if (folio_end > i_size)
742 711 folio_zero_segment(folio, i_size - folio_start,
743 712 folio_size(folio));
744 - out_free_input:
745 - kvfree(input);
713 + out_unlock_ws:
714 + mutex_unlock(ws->lock);
746 715 out_iput:
747 716 iput(wof_inode);
748 717 out:
modified fs/overlayfs/readdir.c
@@ -1044,7 +1044,7 @@ static int ovl_dir_open(struct inode *inode, struct file *file)
1044 1044 struct ovl_dir_file *od;
1045 1045 enum ovl_path_type type;
1046 1046
1047 - od = kzalloc_obj(struct ovl_dir_file);
1047 + od = kzalloc(sizeof(struct ovl_dir_file), GFP_KERNEL);
1048 1048 if (!od)
1049 1049 return -ENOMEM;
1050 1050
modified fs/quota/dquot.c
@@ -1240,7 +1240,7 @@ static int ignore_hardlimit(struct dquot *dquot)
1240 1240 {
1241 1241 struct mem_dqinfo *info = &sb_dqopt(dquot->dq_sb)->info[dquot->dq_id.type];
1242 1242
1243 - return capable_noaudit(CAP_SYS_RESOURCE) &&
1243 + return capable(CAP_SYS_RESOURCE) &&
1244 1244 (info->dqi_format->qf_fmt_id != QFMT_VFS_OLD ||
1245 1245 !(info->dqi_flags & DQF_ROOT_SQUASH));
1246 1246 }
modified fs/smb/client/cifs_swn.c
@@ -443,7 +443,7 @@ static struct cifs_swn_reg *cifs_get_swn_reg(struct cifs_tcon *tcon)
443 443 goto unlock;
444 444 }
445 445
446 - reg = kmalloc_obj(struct cifs_swn_reg);
446 + reg = kmalloc_obj(struct cifs_swn_reg, GFP_KERNEL);
447 447 if (reg == NULL) {
448 448 ret = -ENOMEM;
449 449 goto fail_unlock;
modified fs/smb/client/cifssmb.c
@@ -3555,7 +3555,6 @@ int cifs_do_set_acl(const unsigned int xid, struct cifs_tcon *tcon,
3555 3555 int rc = 0;
3556 3556 int bytes_returned = 0;
3557 3557 __u16 params, byte_count, data_count, param_offset, offset;
3558 - size_t cifs_acl_size, bytes_available;
3559 3558
3560 3559 cifs_dbg(FYI, "In SetPosixACL (Unix) for path %s\n", fileName);
3561 3560 setAclRetry:
@@ -3575,7 +3574,8 @@ setAclRetry:
3575 3574 }
3576 3575 params = 6 + name_len;
3577 3576 pSMB->MaxParameterCount = cpu_to_le16(2);
3578 - pSMB->MaxDataCount = cpu_to_le16(min_t(unsigned int, CIFSMaxBufSize, USHRT_MAX));
3577 + /* BB find max SMB size from sess */
3578 + pSMB->MaxDataCount = cpu_to_le16(1000);
3579 3579 pSMB->MaxSetupCount = 0;
3580 3580 pSMB->Reserved = 0;
3581 3581 pSMB->Flags = 0;
@@ -3587,15 +3587,6 @@ setAclRetry:
3587 3587 parm_data = ((char *)pSMB) + offset;
3588 3588 pSMB->ParameterOffset = cpu_to_le16(param_offset);
3589 3589
3590 - /* make sure we can fit the larger cifs_posix_aces in the buffer */
3591 - cifs_acl_size = sizeof(struct cifs_posix_acl) +
3592 - (acl->a_count * sizeof(struct cifs_posix_ace));
3593 - bytes_available = (CIFSMaxBufSize + MAX_HEADER_SIZE(tcon->ses->server)) - offset;
3594 - if (cifs_acl_size > bytes_available || cifs_acl_size > USHRT_MAX) {
3595 - rc = -E2BIG;
3596 - goto setACLerrorExit;
3597 - }
3598 -
3599 3590 /* convert to on the wire format for POSIX ACL */
3600 3591 data_count = posix_acl_to_cifs(parm_data, acl, acl_type);
3601 3592
@@ -6334,10 +6325,8 @@ CIFSSMBSetEA(const unsigned int xid, struct cifs_tcon *tcon,
6334 6325 int name_len;
6335 6326 int rc = 0;
6336 6327 int bytes_returned = 0;
6337 - __u16 params, param_offset;
6338 - unsigned int byte_count, offset, count;
6328 + __u16 params, param_offset, byte_count, offset, count;
6339 6329 int remap = cifs_remap(cifs_sb);
6340 - unsigned int total_len;
6341 6330
6342 6331 cifs_dbg(FYI, "In SetEA\n");
6343 6332 SetEARetry:
@@ -6389,13 +6378,6 @@ SetEARetry:
6389 6378 pSMB->Reserved3 = 0;
6390 6379 pSMB->SubCommand = cpu_to_le16(TRANS2_SET_PATH_INFORMATION);
6391 6380 byte_count = 3 /* pad */ + params + count;
6392 - if (check_add_overflow(in_len, byte_count, &total_len) ||
6393 - byte_count > U16_MAX ||
6394 - total_len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE) {
6395 - cifs_dbg(VFS, "EA request too large: %u bytes\n", total_len);
6396 - cifs_buf_release(pSMB);
6397 - return -E2BIG;
6398 - }
6399 6381 pSMB->DataCount = cpu_to_le16(count);
6400 6382 parm_data->list_len = cpu_to_le32(count);
6401 6383 parm_data->list.EA_flags = 0;
modified fs/smb/client/connect.c
@@ -4189,25 +4189,14 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses,
4189 4189 return rc;
4190 4190 }
4191 4191
4192 - static int set_fs_context_auth(struct smb3_fs_context *ctx,
4193 - struct cifs_ses *ses)
4192 + static int
4193 + cifs_set_vol_auth(struct smb3_fs_context *ctx, struct cifs_ses *ses)
4194 4194 {
4195 4195 ctx->sectype = ses->sectype;
4196 4196
4197 - /*
4198 - * krb5 is special as we might need to pass username (passwordless) down
4199 - * to cifs.upcall(8) for keytab.
4200 - */
4201 - if (ctx->sectype == Kerberos) {
4202 - if (ses->user_name && ses->user_name[0]) {
4203 - ctx->username = kstrndup(ses->user_name,
4204 - CIFS_MAX_USERNAME_LEN,
4205 - GFP_KERNEL);
4206 - if (!ctx->username)
4207 - return -ENOMEM;
4208 - }
4197 + /* krb5 is special, since we don't need username or pw */
4198 + if (ctx->sectype == Kerberos)
4209 4199 return 0;
4210 - }
4211 4200
4212 4201 return cifs_set_cifscreds(ctx, ses);
4213 4202 }
@@ -4247,7 +4236,7 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, kuid_t fsuid)
4247 4236 ctx->dfs_root_ses = master_tcon->ses->dfs_root_ses;
4248 4237 ctx->unicode = master_tcon->ses->unicode;
4249 4238
4250 - rc = set_fs_context_auth(ctx, master_tcon->ses);
4239 + rc = cifs_set_vol_auth(ctx, master_tcon->ses);
4251 4240 if (rc) {
4252 4241 tcon = ERR_PTR(rc);
4253 4242 goto out;
modified fs/smb/client/dfs_cache.c
@@ -365,7 +365,7 @@ static struct cache_dfs_tgt *alloc_target(const char *name, int path_consumed)
365 365 {
366 366 struct cache_dfs_tgt *t;
367 367
368 - t = kmalloc_obj(*t);
368 + t = kmalloc_obj(*t, GFP_KERNEL);
369 369 if (!t)
370 370 return ERR_PTR(-ENOMEM);
371 371 t->name = kstrdup(name, GFP_KERNEL);
modified fs/smb/client/file.c
@@ -999,50 +999,26 @@ static int cifs_do_truncate(const unsigned int xid, struct dentry *dentry)
999 999 struct cifs_tcon *tcon;
1000 1000 int rc;
1001 1001
1002 - rc = inode_lock_killable(inode);
1003 - if (rc)
1004 - return -ERESTARTSYS;
1005 -
1006 - filemap_invalidate_lock(inode->i_mapping);
1007 -
1008 1002 rc = filemap_write_and_wait(inode->i_mapping);
1009 - if (is_interrupt_error(rc)) {
1010 - rc = -ERESTARTSYS;
1011 - goto out;
1012 - }
1003 + if (is_interrupt_error(rc))
1004 + return -ERESTARTSYS;
1013 1005 mapping_set_error(inode->i_mapping, rc);
1014 1006
1015 1007 cfile = find_writable_file(cinode, FIND_FSUID_ONLY);
1016 1008 rc = cifs_file_flush(xid, inode, cfile);
1017 1009 if (!rc) {
1018 1010 if (cfile) {
1019 - struct netfs_inode *ictx = netfs_inode(inode);
1020 -
1021 1011 tcon = tlink_tcon(cfile->tlink);
1022 1012 server = tcon->ses->server;
1023 - netfs_wb_begin(ictx, false);
1024 1013 rc = server->ops->set_file_size(xid, tcon,
1025 1014 cfile, 0, false);
1026 - if (!rc) {
1027 - netfs_resize_file(&cinode->netfs, 0, true);
1028 - cifs_setsize(inode, 0);
1029 - cifs_invalidate_cache(inode, 0);
1030 - }
1031 - netfs_wb_end(ictx);
1032 - } else {
1033 - /*
1034 - * No cached handle; evict stale pages so they can't
1035 - * be served after the file is later extended; let
1036 - * the server's O_TRUNC open response set the i_size
1037 - */
1038 - truncate_inode_pages(inode->i_mapping, 0);
1015 + }
1016 + if (!rc) {
1017 + netfs_resize_file(&cinode->netfs, 0, true);
1018 + cifs_setsize(inode, 0);
1039 1019 cifs_invalidate_cache(inode, 0);
1040 1020 }
1041 1021 }
1042 -
1043 - out:
1044 - filemap_invalidate_unlock(inode->i_mapping);
1045 - inode_unlock(inode);
1046 1022 if (cfile)
1047 1023 cifsFileInfo_put(cfile);
1048 1024 return rc;
modified fs/smb/client/smb2inode.c
@@ -237,7 +237,7 @@ replay_again:
237 237 num_rqst = 0;
238 238 server = cifs_pick_channel(ses);
239 239
240 - vars = kzalloc_obj(*vars);
240 + vars = kzalloc_obj(*vars, GFP_KERNEL);
241 241 if (vars == NULL) {
242 242 rc = -ENOMEM;
243 243 goto out;
modified fs/smb/client/smb2ops.c
@@ -1839,31 +1839,31 @@ free_vars:
1839 1839 *
1840 1840 * @tcon: destination file tcon
1841 1841 * @bytes_left: how many bytes are left to copy
1842 - * @chunk_size: maximum size of a single chunk
1843 1842 *
1844 1843 * Return: maximum number of chunks with which Chunks[] can be filled.
1845 1844 */
1846 1845 static inline u32
1847 - calc_chunk_count(struct cifs_tcon *tcon, u64 bytes_left, u32 chunk_size)
1846 + calc_chunk_count(struct cifs_tcon *tcon, u64 bytes_left)
1848 1847 {
1849 1848 u32 max_chunks = READ_ONCE(tcon->max_chunks);
1850 1849 u32 max_bytes_copy = READ_ONCE(tcon->max_bytes_copy);
1850 + u32 max_bytes_chunk = READ_ONCE(tcon->max_bytes_chunk);
1851 1851 u64 need;
1852 1852 u32 allowed;
1853 1853
1854 - if (!chunk_size || !max_bytes_copy || !max_chunks)
1854 + if (!max_bytes_chunk || !max_bytes_copy || !max_chunks)
1855 1855 return 0;
1856 1856
1857 1857 /* chunks needed for the remaining bytes */
1858 - need = DIV_ROUND_UP_ULL(bytes_left, chunk_size);
1858 + need = DIV_ROUND_UP_ULL(bytes_left, max_bytes_chunk);
1859 1859 /* chunks allowed per cc request */
1860 - allowed = DIV_ROUND_UP(max_bytes_copy, chunk_size);
1860 + allowed = DIV_ROUND_UP(max_bytes_copy, max_bytes_chunk);
1861 1861
1862 1862 return (u32)umin(need, umin(max_chunks, allowed));
1863 1863 }
1864 1864
1865 1865 /**
1866 - * __smb2_copychunk_range - server-side copy of data range
1866 + * smb2_copychunk_range - server-side copy of data range
1867 1867 *
1868 1868 * @xid: transaction id
1869 1869 * @src_file: source file
@@ -1875,15 +1875,15 @@ calc_chunk_count(struct cifs_tcon *tcon, u64 bytes_left, u32 chunk_size)
1875 1875 * Obtains a resume key for @src_file and issues FSCTL_SRV_COPYCHUNK_WRITE
1876 1876 * IOCTLs, splitting the request into chunks limited by tcon->max_*.
1877 1877 *
1878 - * Return: 0 on success; negative errno on failure.
1878 + * Return: @len on success; negative errno on failure.
1879 1879 */
1880 - static int
1881 - __smb2_copychunk_range(const unsigned int xid,
1882 - struct cifsFileInfo *src_file,
1883 - struct cifsFileInfo *dst_file,
1884 - u64 src_off,
1885 - u64 len,
1886 - u64 dst_off)
1880 + static ssize_t
1881 + smb2_copychunk_range(const unsigned int xid,
1882 + struct cifsFileInfo *src_file,
1883 + struct cifsFileInfo *dst_file,
1884 + u64 src_off,
1885 + u64 len,
1886 + u64 dst_off)
1887 1887 {
1888 1888 int rc = 0;
1889 1889 unsigned int ret_data_len = 0;
@@ -1891,14 +1891,12 @@ __smb2_copychunk_range(const unsigned int xid,
1891 1891 struct copychunk_ioctl_rsp *cc_rsp = NULL;
1892 1892 struct cifs_tcon *tcon;
1893 1893 struct srv_copychunk *chunk;
1894 - u32 chunks, chunk_count, chunk_bytes, chunk_size;
1894 + u32 chunks, chunk_count, chunk_bytes;
1895 1895 u32 copy_bytes, copy_bytes_left;
1896 1896 u32 chunks_written, bytes_written;
1897 1897 u64 total_bytes_left = len;
1898 1898 u64 src_off_prev, dst_off_prev;
1899 - u64 max_chunk = 0;
1900 1899 u32 retries = 0;
1901 - bool reverse = false;
1902 1900
1903 1901 tcon = tlink_tcon(dst_file->tlink);
1904 1902
@@ -1906,50 +1904,8 @@ __smb2_copychunk_range(const unsigned int xid,
1906 1904 dst_file->fid.volatile_fid, tcon->tid,
1907 1905 tcon->ses->Suid, src_off, dst_off, len);
1908 1906
1909 - /*
1910 - * Same-file left shifts are safe in forward order. For a right shift,
1911 - * let L be the copy length, delta the distance between the source and
1912 - * destination, and C the normal chunk size:
1913 - *
1914 - * delta >= L: copy forwards using C
1915 - * delta < L:
1916 - * delta >= C: copy backwards using C
1917 - * delta < C: copy backwards with chunks limited to delta
1918 - *
1919 - * Copying backwards prevents one chunk from overwriting data needed by
1920 - * a later chunk. Limiting the chunk size to delta prevents an individual
1921 - * chunk from overlapping itself.
1922 - * This limit can be removed once all supported servers handle overlapping
1923 - * descriptors safely.
1924 - *
1925 - * A small right shift over a large range may therefore require many
1926 - * chunks.
1927 - */
1928 - if (src_file == dst_file && dst_off > src_off) {
1929 - u64 delta = dst_off - src_off;
1930 -
1931 - if (delta < len) {
1932 - reverse = true;
1933 - max_chunk = delta;
1934 - }
1935 - }
1936 -
1937 - /*
1938 - * A backward copy walks the offsets down from the end of the range.
1939 - * Do this once, outside the retry loop, so a retry does not move the
1940 - * offsets again.
1941 - */
1942 - if (reverse) {
1943 - src_off += len;
1944 - dst_off += len;
1945 - }
1946 -
1947 1907 retry:
1948 - chunk_size = READ_ONCE(tcon->max_bytes_chunk);
1949 - if (max_chunk && max_chunk < chunk_size)
1950 - chunk_size = (u32)max_chunk;
1951 -
1952 - chunk_count = calc_chunk_count(tcon, total_bytes_left, chunk_size);
1908 + chunk_count = calc_chunk_count(tcon, total_bytes_left);
1953 1909 if (!chunk_count) {
1954 1910 rc = -EOPNOTSUPP;
1955 1911 goto out;
@@ -1990,21 +1946,16 @@ retry:
1990 1946 while (copy_bytes_left > 0 && chunks < chunk_count) {
1991 1947 chunk = &cc_req->Chunks[chunks++];
1992 1948
1993 - chunk_bytes = umin(copy_bytes_left, chunk_size);
1994 - if (reverse) {
1995 - src_off -= chunk_bytes;
1996 - dst_off -= chunk_bytes;
1997 - }
1998 -
1999 1949 chunk->SourceOffset = cpu_to_le64(src_off);
2000 1950 chunk->TargetOffset = cpu_to_le64(dst_off);
1951 +
1952 + chunk_bytes = umin(copy_bytes_left, tcon->max_bytes_chunk);
1953 +
2001 1954 chunk->Length = cpu_to_le32(chunk_bytes);
2002 1955 /* Buffer is zeroed, no need to set chunk->Reserved = 0 */
2003 1956
2004 - if (!reverse) {
2005 - src_off += chunk_bytes;
2006 - dst_off += chunk_bytes;
2007 - }
1957 + src_off += chunk_bytes;
1958 + dst_off += chunk_bytes;
2008 1959
2009 1960 copy_bytes_left -= chunk_bytes;
2010 1961 copy_bytes += chunk_bytes;
@@ -2052,18 +2003,6 @@ retry:
2052 2003 goto out;
2053 2004 }
2054 2005
2055 - /*
2056 - * A successful COPYCHUNK should copy every descriptor (MS-SMB2
2057 - * 3.3.5.15.6). Reject a short backward copy because the rewind
2058 - * below only supports forward copying.
2059 - */
2060 - if (unlikely(reverse && bytes_written < copy_bytes)) {
2061 - cifs_tcon_dbg(VFS, "Copychunk short write %u/%u (reverse)\n",
2062 - bytes_written, copy_bytes);
2063 - rc = -EIO;
2064 - goto out;
2065 - }
2066 -
2067 2006 /* Partial write: rewind */
2068 2007 if (bytes_written < copy_bytes) {
2069 2008 u32 delta = copy_bytes - bytes_written;
@@ -2125,27 +2064,10 @@ out:
2125 2064 trace_smb3_copychunk_done(xid, src_file->fid.volatile_fid,
2126 2065 dst_file->fid.volatile_fid, tcon->tid,
2127 2066 tcon->ses->Suid, src_off, dst_off, len);
2128 - return 0;
2067 + return len;
2129 2068 }
2130 2069 }
2131 2070
2132 - static ssize_t
2133 - smb2_copychunk_range(const unsigned int xid,
2134 - struct cifsFileInfo *src_file,
2135 - struct cifsFileInfo *dst_file,
2136 - u64 src_off,
2137 - u64 len,
2138 - u64 dst_off)
2139 - {
2140 - int rc;
2141 -
2142 - rc = __smb2_copychunk_range(xid, src_file, dst_file, src_off, len,
2143 - dst_off);
2144 - if (rc)
2145 - return rc;
2146 - return len;
2147 - }
2148 -
2149 2071 static int
2150 2072 smb2_flush_file(const unsigned int xid, struct cifs_tcon *tcon,
2151 2073 struct cifs_fid *fid)
@@ -2296,7 +2218,7 @@ smb2_duplicate_extents(const unsigned int xid,
2296 2218 trgtfile->fid.volatile_fid, tcon->tid,
2297 2219 tcon->ses->Suid, src_off, dest_off, len);
2298 2220 inode = d_inode(trgtfile->dentry);
2299 - if (i_size_read(inode) < dest_off + len) {
2221 + if (inode->i_size < dest_off + len) {
2300 2222 rc = smb2_set_file_size(xid, tcon, trgtfile, dest_off + len, false);
2301 2223 if (rc)
2302 2224 goto duplicate_extents_out;
@@ -2313,10 +2235,7 @@ smb2_duplicate_extents(const unsigned int xid,
2313 2235 if (ret_data_len > 0)
2314 2236 cifs_dbg(FYI, "Non-zero response length in duplicate extents\n");
2315 2237
2316 - if (rc) {
2317 - CIFS_I(inode)->time = 0; /* force reval */
2318 - cifs_invalidate_cache(inode, 0);
2319 - } else {
2238 + if (rc == 0) {
2320 2239 qrc = SMB2_query_info(xid, tcon, trgtfile->fid.persistent_fid,
2321 2240 trgtfile->fid.volatile_fid, &file_inf);
2322 2241 spin_lock(&inode->i_lock);
@@ -3522,13 +3441,6 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
3522 3441 trace_smb3_zero_enter(xid, cfile->fid.persistent_fid, tcon->tid,
3523 3442 ses->Suid, offset, len);
3524 3443
3525 - new_size = offset + len;
3526 - if (!keep_size && i_size_read(inode) < new_size) {
3527 - rc = inode_newsize_ok(inode, new_size);
3528 - if (rc)
3529 - goto out;
3530 - }
3531 -
3532 3444 filemap_invalidate_lock(inode->i_mapping);
3533 3445
3534 3446 netfs_read_sizes(inode, &i_size, &remote_i_size, &zero_point);
@@ -3552,9 +3464,6 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
3552 3464 if (keep_size == false && !CIFS_CACHE_READ(cifsi))
3553 3465 goto zero_range_exit;
3554 3466
3555 - fscache_invalidate(cifs_inode_cookie(inode), NULL,
3556 - i_size_read(inode), 0);
3557 -
3558 3467 rc = smb3_zero_data(file, tcon, offset, len, xid);
3559 3468 if (rc < 0)
3560 3469 goto zero_range_exit;
@@ -3562,6 +3471,7 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
3562 3471 /*
3563 3472 * do we also need to change the size of the file?
3564 3473 */
3474 + new_size = offset + len;
3565 3475 if (keep_size == false && (unsigned long long)i_size_read(inode) < new_size) {
3566 3476 rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
3567 3477 cfile->fid.volatile_fid, cfile->pid, new_size);
@@ -3578,7 +3488,6 @@ static long smb3_zero_range(struct file *file, struct cifs_tcon *tcon,
3578 3488
3579 3489 zero_range_exit:
3580 3490 filemap_invalidate_unlock(inode->i_mapping);
3581 - out:
3582 3491 free_xid(xid);
3583 3492 if (rc)
3584 3493 trace_smb3_zero_err(xid, cfile->fid.persistent_fid, tcon->tid,
@@ -3624,8 +3533,6 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon,
3624 3533 */
3625 3534 truncate_pagecache_range(inode, offset, offset + len - 1);
3626 3535 netfs_wait_for_outstanding_io(inode);
3627 - fscache_invalidate(cifs_inode_cookie(inode), NULL,
3628 - i_size_read(inode), 0);
3629 3536
3630 3537 cifs_dbg(FYI, "Offset %lld len %lld\n", offset, len);
3631 3538
@@ -4031,26 +3938,18 @@ static long smb3_collapse_range(struct file *file, struct cifs_tcon *tcon,
4031 3938 }
4032 3939
4033 3940 filemap_invalidate_lock(inode->i_mapping);
4034 - rc = filemap_write_and_wait_range(inode->i_mapping,
4035 - round_down(off, PAGE_SIZE),
4036 - old_eof - 1);
3941 + rc = filemap_write_and_wait_range(inode->i_mapping, off, old_eof - 1);
4037 3942 if (rc < 0)
4038 3943 goto out_2;
4039 3944
4040 - netfs_wait_for_outstanding_io(inode);
4041 - /*
4042 - * Invalidate cached folios from the page containing off to EOF before
4043 - * moving data on the server, so subsequent reads do not see stale data.
4044 - */
4045 - truncate_pagecache_range(inode, round_down(off, PAGE_SIZE), -1);
4046 - fscache_invalidate(cifs_inode_cookie(inode), NULL, old_eof, 0);
4047 -
3945 + truncate_pagecache_range(inode, off, old_eof);
4048 3946 spin_lock(&inode->i_lock);
4049 3947 netfs_write_zero_point(inode, old_eof);
4050 3948 spin_unlock(&inode->i_lock);
3949 + netfs_wait_for_outstanding_io(inode);
4051 3950
4052 - rc = __smb2_copychunk_range(xid, cfile, cfile, off + len,
4053 - old_eof - off - len, off);
3951 + rc = smb2_copychunk_range(xid, cfile, cfile, off + len,
3952 + old_eof - off - len, off);
4054 3953 if (rc < 0)
4055 3954 goto out_2;
4056 3955
@@ -4083,7 +3982,7 @@ static long smb3_insert_range(struct file *file, struct cifs_tcon *tcon,
4083 3982 struct cifsFileInfo *cfile = file->private_data;
4084 3983 struct inode *inode = file_inode(file);
4085 3984 struct cifsInodeInfo *cifsi = CIFS_I(inode);
4086 - loff_t old_eof, new_eof;
3985 + __u64 count, old_eof, new_eof;
4087 3986
4088 3987 xid = get_xid();
4089 3988
@@ -4093,32 +3992,15 @@ static long smb3_insert_range(struct file *file, struct cifs_tcon *tcon,
4093 3992 goto out;
4094 3993 }
4095 3994
4096 - if (check_add_overflow(old_eof, len, &new_eof)) {
4097 - rc = -EFBIG;
4098 - goto out;
4099 - }
4100 - rc = inode_newsize_ok(inode, new_eof);
4101 - if (rc)
4102 - goto out;
4103 -
4104 - /* SET_ZERO_DATA creates a hole only in a sparse file. */
4105 - rc = smb2_set_sparse(xid, tcon, cfile, inode, true);
4106 - if (rc)
4107 - goto out;
3995 + count = old_eof - off;
3996 + new_eof = old_eof + len;
4108 3997
4109 3998 filemap_invalidate_lock(inode->i_mapping);
4110 - rc = filemap_write_and_wait_range(inode->i_mapping,
4111 - round_down(off, PAGE_SIZE),
4112 - old_eof - 1);
3999 + rc = filemap_write_and_wait_range(inode->i_mapping, off, new_eof - 1);
4113 4000 if (rc < 0)
4114 4001 goto out_2;
4002 + truncate_pagecache_range(inode, off, old_eof);
4115 4003 netfs_wait_for_outstanding_io(inode);
4116 - /*
4117 - * Invalidate cached folios from the page containing off to EOF before
4118 - * moving data on the server, so subsequent reads do not see stale data.
4119 - */
4120 - truncate_pagecache_range(inode, round_down(off, PAGE_SIZE), -1);
4121 - fscache_invalidate(cifs_inode_cookie(inode), NULL, old_eof, 0);
4122 4004
4123 4005 rc = SMB2_set_eof(xid, tcon, cfile->fid.persistent_fid,
4124 4006 cfile->fid.volatile_fid, cfile->pid, new_eof);
@@ -4131,12 +4013,7 @@ static long smb3_insert_range(struct file *file, struct cifs_tcon *tcon,
4131 4013 spin_unlock(&inode->i_lock);
4132 4014 fscache_resize_cookie(cifs_inode_cookie(inode), i_size_read(inode));
4133 4015
4134 - /*
4135 - * Move [off, old_eof) right by len. The helper copies backwards if the
4136 - * source and destination ranges overlap.
4137 - */
4138 - rc = __smb2_copychunk_range(xid, cfile, cfile, off, old_eof - off,
4139 - off + len);
4016 + rc = smb2_copychunk_range(xid, cfile, cfile, off, count, off + len);
4140 4017 if (rc < 0)
4141 4018 goto out_2;
4142 4019 spin_lock(&inode->i_lock);
modified fs/smb/client/transport.c
@@ -101,11 +101,12 @@ void __release_mid(struct TCP_Server_Info *server, struct mid_q_entry *midEntry)
101 101 trace_smb3_slow_rsp(smb_cmd, midEntry->mid, midEntry->pid,
102 102 midEntry->when_sent, midEntry->when_received);
103 103 if (cifsFYI & CIFS_TIMER) {
104 - pr_debug("slow rsp: cmd %d mid %llu A: 0x%lx S: 0x%lx R: 0x%lx\n",
105 - midEntry->command, midEntry->mid,
106 - now - midEntry->when_alloc,
107 - now - midEntry->when_sent,
108 - now - midEntry->when_received);
104 + pr_debug("slow rsp: cmd %d mid %llu",
105 + midEntry->command, midEntry->mid);
106 + cifs_info("A: 0x%lx S: 0x%lx R: 0x%lx\n",
107 + now - midEntry->when_alloc,
108 + now - midEntry->when_sent,
109 + now - midEntry->when_received);
109 110 }
110 111 }
111 112 #endif
modified fs/smb/server/connection.c
@@ -13,7 +13,6 @@
13 13 #include "mgmt/ksmbd_ida.h"
14 14 #include "mgmt/user_session.h"
15 15 #include "connection.h"
16 - #include "vfs_cache.h"
17 16 #include "compress.h"
18 17 #include "transport_tcp.h"
19 18 #include "transport_rdma.h"
@@ -385,12 +384,12 @@ static void ksmbd_conn_cancel_async_requests(struct ksmbd_conn *conn)
385 384 spin_lock(&conn->request_lock);
386 385 list_for_each_entry_safe(work, tmp, &conn->async_requests,
387 386 async_request_entry) {
388 - if (cmpxchg(&work->state, KSMBD_WORK_ACTIVE,
389 - KSMBD_WORK_CANCELLED) != KSMBD_WORK_ACTIVE)
387 + if (work->state != KSMBD_WORK_ACTIVE)
390 388 continue;
391 389
392 390 ksmbd_debug(CONN, "Cancel async request id %d\n",
393 391 work->async_id);
392 + work->state = KSMBD_WORK_CANCELLED;
394 393 if (work->cancel_fn)
395 394 work->cancel_fn(work->cancel_argv);
396 395 }
@@ -474,9 +473,6 @@ retry_idle:
474 473 if (retry_count >= max_timeout)
475 474 return -EIO;
476 475
477 - /* A blocked byte-range lock cannot drain until teardown wakes it. */
478 - ksmbd_wake_session_blocked_works(sess);
479 -
480 476 down_read(&conn_list_lock);
481 477 hash_for_each(conn_list, bkt, conn, hlist) {
482 478 if (ksmbd_session_is_bound_to_conn(sess, conn)) {
modified fs/smb/server/ksmbd_work.c
@@ -30,7 +30,7 @@ static int ksmbd_reserve_iov(struct ksmbd_work *work, int need_iov_cnt)
30 30 } while (new_alloc_cnt < work->iov_cnt + need_iov_cnt);
31 31
32 32 if (work->iov == work->iov_inline) {
33 - new = kzalloc_objs(*new, new_alloc_cnt, KSMBD_DEFAULT_GFP);
33 + new = kcalloc(new_alloc_cnt, sizeof(*new), KSMBD_DEFAULT_GFP);
34 34 if (!new)
35 35 return -ENOMEM;
36 36
modified fs/smb/server/ksmbd_work.h
@@ -82,7 +82,7 @@ struct ksmbd_work {
82 82 /* Contiguous SMB2 compression transform owned by this work item. */
83 83 void *compress_buf;
84 84
85 - unsigned int state;
85 + unsigned char state;
86 86 /* No response for cancelled request */
87 87 bool send_no_response:1;
88 88 /* Request is encrypted */
modified fs/smb/server/mgmt/share_config.c
@@ -146,9 +146,9 @@ static struct ksmbd_share_config *__share_lookup(const char *name)
146 146
147 147 static int parse_veto_list(struct ksmbd_share_config *share,
148 148 char *veto_list,
149 - size_t veto_list_sz)
149 + int veto_list_sz)
150 150 {
151 - size_t sz;
151 + int sz = 0;
152 152
153 153 if (!veto_list_sz)
154 154 return 0;
@@ -156,7 +156,7 @@ static int parse_veto_list(struct ksmbd_share_config *share,
156 156 while (veto_list_sz > 0) {
157 157 struct ksmbd_veto_pattern *p;
158 158
159 - sz = strnlen(veto_list, veto_list_sz);
159 + sz = strlen(veto_list);
160 160 if (!sz)
161 161 break;
162 162
@@ -164,7 +164,7 @@ static int parse_veto_list(struct ksmbd_share_config *share,
164 164 if (!p)
165 165 return -ENOMEM;
166 166
167 - p->pattern = kstrndup(veto_list, sz, KSMBD_DEFAULT_GFP);
167 + p->pattern = kstrdup(veto_list, KSMBD_DEFAULT_GFP);
168 168 if (!p->pattern) {
169 169 kfree(p);
170 170 return -ENOMEM;
@@ -172,9 +172,6 @@ static int parse_veto_list(struct ksmbd_share_config *share,
172 172
173 173 list_add(&p->list, &share->veto_list);
174 174
175 - if (sz == veto_list_sz)
176 - break;
177 -
178 175 veto_list += sz + 1;
179 176 veto_list_sz -= (sz + 1);
180 177 }
@@ -227,28 +224,17 @@ static struct ksmbd_share_config *share_config_request(struct ksmbd_work *work,
227 224 }
228 225
229 226 if (!test_share_config_flag(share, KSMBD_SHARE_FLAG_PIPE)) {
230 - size_t path_len;
227 + int path_len = PATH_MAX;
231 228
232 - if (resp->payload_sz <= resp->veto_list_sz) {
233 - ret = -EINVAL;
234 - } else {
229 + if (resp->payload_sz)
235 230 path_len = resp->payload_sz - resp->veto_list_sz;
236 - if (resp->veto_list_sz)
237 - path_len--;
238 -
239 - if (!path_len) {
240 - ret = -EINVAL;
241 - } else {
242 - share->path = kstrndup(
243 - ksmbd_share_config_path(resp),
244 - path_len, KSMBD_DEFAULT_GFP);
245 - if (!share->path)
246 - ret = -ENOMEM;
247 - else
248 - ret = 0;
249 - }
250 - }
251 - if (share->path) {
231 +
232 + share->path = kstrndup(ksmbd_share_config_path(resp), path_len,
233 + KSMBD_DEFAULT_GFP);
234 + if (!share->path) {
235 + ret = -ENOMEM;
236 + } else {
237 + ret = 0;
252 238 share->path_sz = strlen(share->path);
253 239 while (share->path_sz > 1 &&
254 240 share->path[share->path_sz - 1] == '/')
modified fs/smb/server/mgmt/tree_connect.c
@@ -82,8 +82,6 @@ ksmbd_tree_conn_connect(struct ksmbd_work *work, const char *share_name)
82 82 down_write(&sess->tree_conns_lock);
83 83 ret = xa_err(xa_store(&sess->tree_conns, tree_conn->id, tree_conn,
84 84 KSMBD_DEFAULT_GFP));
85 - if (!ret)
86 - atomic_inc(&tree_conn->refcount);
87 85 up_write(&sess->tree_conns_lock);
88 86 if (ret) {
89 87 status.ret = -ENOMEM;
@@ -131,12 +129,6 @@ int ksmbd_tree_conn_disconnect(struct ksmbd_session *sess,
131 129 struct ksmbd_tree_connect *tree_conn)
132 130 {
133 131 down_write(&sess->tree_conns_lock);
134 - if (tree_conn->t_state == TREE_DISCONNECTED ||
135 - xa_load(&sess->tree_conns, tree_conn->id) != tree_conn) {
136 - up_write(&sess->tree_conns_lock);
137 - return -ENOENT;
138 - }
139 - tree_conn->t_state = TREE_DISCONNECTED;
140 132 xa_erase(&sess->tree_conns, tree_conn->id);
141 133 up_write(&sess->tree_conns_lock);
142 134
modified fs/smb/server/mgmt/user_session.c
@@ -666,21 +666,10 @@ void destroy_previous_session(struct ksmbd_conn *conn,
666 666 memcmp(user->passkey, prev_user->passkey, user->passkey_sz))
667 667 goto out;
668 668
669 - down_write(&prev_sess->chann_lock);
670 - if (prev_sess->tearing_down) {
671 - up_write(&prev_sess->chann_lock);
672 - goto out;
673 - }
674 - prev_sess->tearing_down = true;
675 - up_write(&prev_sess->chann_lock);
676 -
677 669 ksmbd_all_conn_set_status(prev_sess, KSMBD_SESS_NEED_RECONNECT);
678 670 err = ksmbd_conn_wait_idle_sess(conn, prev_sess);
679 671 if (err) {
680 - down_write(&prev_sess->chann_lock);
681 - prev_sess->tearing_down = false;
682 - up_write(&prev_sess->chann_lock);
683 - ksmbd_all_conn_set_status(prev_sess, KSMBD_SESS_GOOD);
672 + ksmbd_all_conn_set_status(prev_sess, KSMBD_SESS_NEED_SETUP);
684 673 goto out;
685 674 }
686 675
modified fs/smb/server/mgmt/user_session.h
@@ -42,7 +42,6 @@ struct ksmbd_session {
42 42
43 43 bool sign;
44 44 bool enc;
45 - bool tearing_down;
46 45
47 46 int state;
48 47 __u8 *Preauth_HashValue;
modified fs/smb/server/oplock.c
@@ -924,69 +924,31 @@ out:
924 924 ksmbd_conn_put(conn);
925 925 }
926 926
927 - /*
928 - * Select and pin the connection used for an oplock break before doing any
929 - * allocations which may sleep. The caller of oplock_break() holds a live
930 - * reference on ci (a file being opened, a file being operated on, or an
931 - * explicit ksmbd_inode_lookup_lock() reference in the parent lease break
932 - * paths), so the inode cannot be freed during the call and its lock is
933 - * reachable without dereferencing opinfo->o_fp, which is not pinned by
934 - * the oplock reference and may be freed by a concurrent close.
935 - *
936 - * opinfo->conn is cleared under ci->m_lock by session_fd_check() when the
937 - * durable handle owning the oplock is disconnected, reassigned by
938 - * ksmbd_reopen_durable_fd() under the same lock, and the last
939 - * ksmbd_conn_put() of the old connection frees it. Holding the read lock
940 - * excludes both writers, so the connection cannot be freed while it is
941 - * selected.
942 - */
943 - static struct ksmbd_conn *smb2_oplock_break_conn_get(struct oplock_info *opinfo,
944 - struct ksmbd_inode *ci)
945 - {
946 - struct ksmbd_conn *conn;
947 -
948 - down_read(&ci->m_lock);
949 - conn = READ_ONCE(opinfo->conn);
950 - if (conn && !ksmbd_conn_releasing(conn))
951 - conn = ksmbd_conn_get(conn);
952 - else
953 - conn = NULL;
954 - up_read(&ci->m_lock);
955 -
956 - return conn;
957 - }
958 -
959 927 /**
960 928 * smb2_oplock_break_noti() - send smb2 exclusive/batch to level2 oplock
961 929 * break command from server to client
962 930 * @opinfo: oplock info object
963 - * @ci: inode owning the break target's oplock list, pinned by
964 - * the caller
965 931 *
966 932 * Return: 0 on success, otherwise error
967 933 */
968 - static int smb2_oplock_break_noti(struct oplock_info *opinfo,
969 - struct ksmbd_inode *ci)
934 + static int smb2_oplock_break_noti(struct oplock_info *opinfo)
970 935 {
971 936 struct ksmbd_conn *conn;
972 937 struct oplock_break_info *br_info;
973 938 int ret = 0;
974 939 struct ksmbd_work *work;
975 940
976 - conn = smb2_oplock_break_conn_get(opinfo, ci);
941 + conn = READ_ONCE(opinfo->conn);
977 942 if (!conn)
978 943 return ksmbd_invalidate_durable_fd(opinfo->fid);
979 944
980 945 work = ksmbd_alloc_work_struct();
981 - if (!work) {
982 - ksmbd_conn_put(conn);
946 + if (!work)
983 947 return -ENOMEM;
984 - }
985 948
986 949 br_info = kmalloc_obj(struct oplock_break_info, KSMBD_DEFAULT_GFP);
987 950 if (!br_info) {
988 951 ksmbd_free_work_struct(work);
989 - ksmbd_conn_put(conn);
990 952 return -ENOMEM;
991 953 }
992 954
@@ -995,8 +957,7 @@ static int smb2_oplock_break_noti(struct oplock_info *opinfo,
995 957 br_info->open_trunc = opinfo->open_trunc;
996 958
997 959 work->request_buf = (char *)br_info;
998 - /* Transfer the reference acquired by smb2_oplock_break_conn_get(). */
999 - work->conn = conn;
960 + work->conn = ksmbd_conn_get(conn);
1000 961 work->sess = opinfo->sess;
1001 962
1002 963 ksmbd_conn_r_count_inc(conn);
@@ -1193,9 +1154,9 @@ static void wait_lease_breaking(struct oplock_info *opinfo)
1193 1154 }
1194 1155 }
1195 1156
1196 - static int oplock_break(struct oplock_info *brk_opinfo, struct ksmbd_inode *ci,
1197 - int req_op_level, struct ksmbd_work *in_work,
1198 - bool share_break, bool sync_lease_break)
1157 + static int oplock_break(struct oplock_info *brk_opinfo, int req_op_level,
1158 + struct ksmbd_work *in_work, bool share_break,
1159 + bool sync_lease_break)
1199 1160 {
1200 1161 int err = 0;
1201 1162 bool sent_interim = false;
@@ -1337,7 +1298,7 @@ again:
1337 1298 }
1338 1299 }
1339 1300
1340 - err = smb2_oplock_break_noti(brk_opinfo, ci);
1301 + err = smb2_oplock_break_noti(brk_opinfo);
1341 1302
1342 1303 ksmbd_debug(OPLOCK, "oplock granted = %d\n", brk_opinfo->level);
1343 1304 if (brk_opinfo->op_state == OPLOCK_CLOSING)
@@ -1365,14 +1326,13 @@ static int oplock_break_add(struct list_head *head, struct oplock_info *opinfo)
1365 1326 return 0;
1366 1327 }
1367 1328
1368 - static void oplock_break_drain_none(struct list_head *head,
1369 - struct ksmbd_inode *ci)
1329 + static void oplock_break_drain_none(struct list_head *head)
1370 1330 {
1371 1331 struct oplock_break_entry *ent, *tmp;
1372 1332
1373 1333 list_for_each_entry_safe(ent, tmp, head, list) {
1374 - oplock_break(ent->opinfo, ci, SMB2_OPLOCK_LEVEL_NONE, NULL,
1375 - false, false);
1334 + oplock_break(ent->opinfo, SMB2_OPLOCK_LEVEL_NONE, NULL, false,
1335 + false);
1376 1336 list_del(&ent->list);
1377 1337 opinfo_put(ent->opinfo);
1378 1338 kfree(ent);
@@ -1521,7 +1481,7 @@ void smb_send_parent_lease_break_noti(struct ksmbd_file *fp,
1521 1481 }
1522 1482 up_read(&p_ci->m_lock);
1523 1483
1524 - oplock_break_drain_none(&brk_list, p_ci);
1484 + oplock_break_drain_none(&brk_list);
1525 1485
1526 1486 ksmbd_inode_put(p_ci);
1527 1487 }
@@ -1565,7 +1525,7 @@ void smb_lazy_parent_lease_break_close(struct ksmbd_file *fp)
1565 1525 }
1566 1526 up_read(&p_ci->m_lock);
1567 1527
1568 - oplock_break_drain_none(&brk_list, p_ci);
1528 + oplock_break_drain_none(&brk_list);
1569 1529
1570 1530 ksmbd_inode_put(p_ci);
1571 1531 }
@@ -1705,7 +1665,7 @@ int smb_grant_oplock(struct ksmbd_work *work, int req_op_level, u64 pid,
1705 1665 prev_durable_detached = prev_op_snapshot.durable_detached;
1706 1666 prev_fid = prev_op_snapshot.fid;
1707 1667
1708 - err = oplock_break(prev_opinfo, ci, break_level, work,
1668 + err = oplock_break(prev_opinfo, break_level, work,
1709 1669 share_ret < 0 && prev_opinfo->is_lease, false);
1710 1670 if (prev_durable_detached || (prev_durable_open && err == -ENOENT))
1711 1671 ksmbd_invalidate_durable_fd(prev_fid);
@@ -1811,8 +1771,7 @@ static bool smb_break_all_write_oplock(struct ksmbd_work *work,
1811 1771 }
1812 1772
1813 1773 brk_opinfo->open_trunc = is_trunc;
1814 - oplock_break(brk_opinfo, fp->f_ci, SMB2_OPLOCK_LEVEL_II, work, false,
1815 - false);
1774 + oplock_break(brk_opinfo, SMB2_OPLOCK_LEVEL_II, work, false, false);
1816 1775 sent_break = true;
1817 1776 opinfo_put(brk_opinfo);
1818 1777
@@ -1904,7 +1863,7 @@ next:
1904 1863 brk_op->op_state = OPLOCK_STATE_NONE;
1905 1864 spin_unlock(&brk_op->state_lock);
1906 1865 } else {
1907 - oplock_break(brk_op, ci,
1866 + oplock_break(brk_op,
1908 1867 brk_op->is_lease && !is_trunc ?
1909 1868 SMB2_OPLOCK_LEVEL_II : SMB2_OPLOCK_LEVEL_NONE,
1910 1869 send_interim && !sent_interim ? work : NULL,
modified fs/smb/server/smb2pdu.c
@@ -97,11 +97,6 @@ static int register_session_channel(struct ksmbd_session *sess,
97 97 int rc = 0;
98 98
99 99 down_write(&sess->chann_lock);
100 - if (sess->tearing_down) {
101 - rc = -ESHUTDOWN;
102 - goto out;
103 - }
104 -
105 100 if (xa_load(&sess->ksmbd_chann_list, (long)conn))
106 101 goto out;
107 102
@@ -878,8 +873,7 @@ int smb2_allocate_rsp_buf(struct ksmbd_work *work)
878 873 req = smb_get_msg(work->request_buf);
879 874 if ((req->InfoType == SMB2_O_INFO_FILE &&
880 875 (req->FileInfoClass == FILE_FULL_EA_INFORMATION ||
881 - req->FileInfoClass == FILE_ALL_INFORMATION ||
882 - req->FileInfoClass == FILE_NORMALIZED_NAME_INFORMATION)) ||
876 + req->FileInfoClass == FILE_ALL_INFORMATION)) ||
883 877 req->InfoType == SMB2_O_INFO_SECURITY)
884 878 sz = large_sz;
885 879 }
@@ -2790,7 +2784,6 @@ int smb2_tree_connect(struct ksmbd_work *work)
2790 2784 struct ksmbd_session *sess = work->sess;
2791 2785 char *treename = NULL, *name = NULL;
2792 2786 struct ksmbd_tree_conn_status status;
2793 - struct ksmbd_tree_connect *tree_conn = NULL;
2794 2787 struct ksmbd_share_config *share = NULL;
2795 2788 int rc = -EINVAL;
2796 2789
@@ -2818,7 +2811,6 @@ int smb2_tree_connect(struct ksmbd_work *work)
2818 2811
2819 2812 status = ksmbd_tree_conn_connect(work, name);
2820 2813 if (status.ret == KSMBD_TREE_CONN_STATUS_OK) {
2821 - tree_conn = status.tree_conn;
2822 2814 rsp->hdr.Id.SyncId.TreeId = cpu_to_le32(status.tree_conn->id);
2823 2815 share = status.tree_conn->share_conf;
2824 2816
@@ -2862,15 +2854,8 @@ int smb2_tree_connect(struct ksmbd_work *work)
2862 2854 status.tree_conn->posix_extensions = true;
2863 2855
2864 2856 down_write(&sess->tree_conns_lock);
2865 - if (status.tree_conn->t_state == TREE_DISCONNECTED) {
2866 - status.ret = KSMBD_TREE_CONN_STATUS_ERROR;
2867 - share = NULL;
2868 - } else {
2869 - status.tree_conn->t_state = TREE_CONNECTED;
2870 - }
2857 + status.tree_conn->t_state = TREE_CONNECTED;
2871 2858 up_write(&sess->tree_conns_lock);
2872 - if (status.ret != KSMBD_TREE_CONN_STATUS_OK)
2873 - goto out_err1;
2874 2859 rsp->StructureSize = cpu_to_le16(16);
2875 2860 out_err1:
2876 2861 /*
@@ -2897,6 +2882,9 @@ out_err1:
2897 2882 rc = ksmbd_iov_pin_rsp(work, rsp, sizeof(struct smb2_tree_connect_rsp));
2898 2883 if (rc) {
2899 2884 if (status.ret == KSMBD_TREE_CONN_STATUS_OK) {
2885 + down_write(&sess->tree_conns_lock);
2886 + status.tree_conn->t_state = TREE_DISCONNECTED;
2887 + up_write(&sess->tree_conns_lock);
2900 2888 ksmbd_tree_conn_disconnect(sess, status.tree_conn);
2901 2889 status.tree_conn = NULL;
2902 2890 }
@@ -2937,9 +2925,6 @@ out_err1:
2937 2925 if (status.ret != KSMBD_TREE_CONN_STATUS_OK)
2938 2926 smb2_set_err_rsp(work);
2939 2927
2940 - if (tree_conn)
2941 - ksmbd_tree_connect_put(tree_conn);
2942 -
2943 2928 return rc;
2944 2929 }
2945 2930
@@ -3043,6 +3028,17 @@ int smb2_tree_disconnect(struct ksmbd_work *work)
3043 3028
3044 3029 ksmbd_close_tree_conn_fds(work);
3045 3030
3031 + down_write(&sess->tree_conns_lock);
3032 + if (tcon->t_state == TREE_DISCONNECTED) {
3033 + up_write(&sess->tree_conns_lock);
3034 + rsp->hdr.Status = STATUS_NETWORK_NAME_DELETED;
3035 + err = -ENOENT;
3036 + goto err_out;
3037 + }
3038 +
3039 + tcon->t_state = TREE_DISCONNECTED;
3040 + up_write(&sess->tree_conns_lock);
3041 +
3046 3042 err = ksmbd_tree_conn_disconnect(sess, tcon);
3047 3043 if (err) {
3048 3044 rsp->hdr.Status = STATUS_NETWORK_NAME_DELETED;
@@ -3090,41 +3086,17 @@ int smb2_session_logoff(struct ksmbd_work *work)
3090 3086 smb2_set_err_rsp(work);
3091 3087 return -ENOENT;
3092 3088 }
3093 -
3094 - down_write(&sess->chann_lock);
3095 - if (sess->tearing_down) {
3096 - up_write(&sess->chann_lock);
3097 - ksmbd_conn_unlock(conn);
3098 - rsp->hdr.Status = STATUS_USER_SESSION_DELETED;
3099 - smb2_set_err_rsp(work);
3100 - return -ENOENT;
3101 - }
3102 - sess->tearing_down = true;
3103 - up_write(&sess->chann_lock);
3104 -
3105 3089 ksmbd_all_conn_set_status(sess, KSMBD_SESS_NEED_RECONNECT);
3106 3090 ksmbd_conn_unlock(conn);
3107 3091
3108 - err = ksmbd_conn_wait_idle_sess(conn, sess);
3109 - if (err) {
3110 - down_write(&sess->chann_lock);
3111 - sess->tearing_down = false;
3112 - up_write(&sess->chann_lock);
3113 - ksmbd_all_conn_set_status(sess, KSMBD_SESS_GOOD);
3114 - rsp->hdr.Status = STATUS_UNEXPECTED_IO_ERROR;
3115 - smb2_set_err_rsp(work);
3116 - return err;
3117 - }
3118 -
3119 3092 ksmbd_close_session_fds(work);
3093 + ksmbd_conn_wait_idle(conn);
3120 3094
3121 3095 if (ksmbd_tree_conn_session_logoff(sess)) {
3122 3096 ksmbd_debug(SMB, "Invalid tid %d\n", req->hdr.Id.SyncId.TreeId);
3123 3097 rsp->hdr.Status = STATUS_NETWORK_NAME_DELETED;
3124 3098 smb2_set_err_rsp(work);
3125 - err = -ENOENT;
3126 - } else {
3127 - err = 0;
3099 + return -ENOENT;
3128 3100 }
3129 3101
3130 3102 down_write(&conn->session_lock);
@@ -3134,9 +3106,6 @@ int smb2_session_logoff(struct ksmbd_work *work)
3134 3106
3135 3107 ksmbd_all_conn_set_status(sess, KSMBD_SESS_NEED_SETUP);
3136 3108
3137 - if (err)
3138 - return err;
3139 -
3140 3109 rsp->StructureSize = cpu_to_le16(4);
3141 3110 err = ksmbd_iov_pin_rsp(work, rsp, sizeof(struct smb2_logoff_rsp));
3142 3111 if (err) {
@@ -6788,7 +6757,7 @@ static int get_file_normalized_name_info(struct ksmbd_work *work,
6788 6757 {
6789 6758 struct smb2_file_alt_name_info *file_info;
6790 6759 char *filename, *normalized, *stream_name;
6791 - int buf_free_len, conv_len, filename_len;
6760 + int conv_len, filename_len;
6792 6761
6793 6762 if (work->conn->dialect < SMB311_PROT_ID) {
6794 6763 rsp->hdr.Status = STATUS_NOT_SUPPORTED;
@@ -6812,14 +6781,6 @@ static int get_file_normalized_name_info(struct ksmbd_work *work,
6812 6781 return -ENOMEM;
6813 6782
6814 6783 filename_len = strlen(normalized);
6815 - buf_free_len = smb2_resp_buf_len(work, sizeof(*rsp) +
6816 - sizeof(*file_info));
6817 - if (buf_free_len < 0 ||
6818 - (size_t)buf_free_len < (filename_len + 1) * sizeof(__le16)) {
6819 - kfree(normalized);
6820 - return -EINVAL;
6821 - }
6822 -
6823 6784 file_info = (struct smb2_file_alt_name_info *)rsp->Buffer;
6824 6785 conv_len = smbConvertToUTF16((__le16 *)file_info->FileName,
6825 6786 normalized, filename_len,
@@ -7483,7 +7444,6 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
7483 7444 struct object_id_info *info;
7484 7445
7485 7446 info = (struct object_id_info *)(rsp->Buffer);
7486 - memset(info, 0, sizeof(*info));
7487 7447
7488 7448 if (path.mnt->mnt_sb->s_uuid_len == 16)
7489 7449 memcpy(info->objid, path.mnt->mnt_sb->s_uuid.b,
@@ -7539,7 +7499,6 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
7539 7499 info->FreeSpaceStopFiltering = 0;
7540 7500 info->DefaultQuotaThreshold = cpu_to_le64(SMB2_NO_FID);
7541 7501 info->DefaultQuotaLimit = cpu_to_le64(SMB2_NO_FID);
7542 - info->FileSystemControlFlags = 0;
7543 7502 info->Padding = 0;
7544 7503 rsp->OutputBufferLength = cpu_to_le32(48);
7545 7504 fixed_len = 48;
@@ -7562,9 +7521,6 @@ static int smb2_get_info_filesystem(struct ksmbd_work *work,
7562 7521 info->UserBlocksAvail = cpu_to_le64(stfs.f_bavail);
7563 7522 info->TotalFileNodes = cpu_to_le64(stfs.f_files);
7564 7523 info->FreeFileNodes = cpu_to_le64(stfs.f_ffree);
7565 - info->FileSysIdentifier =
7566 - cpu_to_le64((u64)(u32)stfs.f_fsid.val[1] << 32 |
7567 - (u32)stfs.f_fsid.val[0]);
7568 7524 rsp->OutputBufferLength = cpu_to_le32(56);
7569 7525 fixed_len = 56;
7570 7526 }
@@ -8664,18 +8620,13 @@ static noinline int smb2_read_pipe(struct ksmbd_work *work)
8664 8620 }
8665 8621
8666 8622 aux_payload_buf =
8667 - kvmalloc(ALIGN(rpc_resp->payload_sz, 8),
8668 - KSMBD_DEFAULT_GFP);
8623 + kvmalloc(rpc_resp->payload_sz, KSMBD_DEFAULT_GFP);
8669 8624 if (!aux_payload_buf) {
8670 8625 err = -ENOMEM;
8671 8626 goto out;
8672 8627 }
8673 8628
8674 8629 memcpy(aux_payload_buf, rpc_resp->payload, rpc_resp->payload_sz);
8675 - if (rpc_resp->payload_sz & 7)
8676 - memset(aux_payload_buf + rpc_resp->payload_sz, 0,
8677 - ALIGN(rpc_resp->payload_sz, 8) -
8678 - rpc_resp->payload_sz);
8679 8630
8680 8631 nbytes = rpc_resp->payload_sz;
8681 8632 err = ksmbd_iov_pin_rsp_read(work, (void *)rsp,
@@ -9729,14 +9680,14 @@ int smb2_cancel(struct ksmbd_work *work)
9729 9680 * still on conn->async_requests with a live cancel_fn
9730 9681 * pointing at the freed file_lock.
9731 9682 */
9732 - if (cmpxchg(&iter->state, KSMBD_WORK_ACTIVE,
9733 - KSMBD_WORK_CANCELLED) != KSMBD_WORK_ACTIVE)
9683 + if (iter->state != KSMBD_WORK_ACTIVE)
9734 9684 break;
9735 9685
9736 9686 ksmbd_debug(SMB,
9737 9687 "smb2 with AsyncId %llu cancelled command = 0x%x\n",
9738 9688 le64_to_cpu(hdr->Id.AsyncId),
9739 9689 le16_to_cpu(chdr->Command));
9690 + iter->state = KSMBD_WORK_CANCELLED;
9740 9691 if (iter->cancel_fn == smb2_notify_cancel_fn)
9741 9692 cancelled_notify =
9742 9693 smb2_notify_cancel_claim(iter->cancel_argv);
@@ -9765,16 +9716,11 @@ int smb2_cancel(struct ksmbd_work *work)
9765 9716 iter == work)
9766 9717 continue;
9767 9718
9768 - if (cmpxchg(&iter->state, KSMBD_WORK_ACTIVE,
9769 - KSMBD_WORK_CANCELLED) != KSMBD_WORK_ACTIVE)
9770 - break;
9771 -
9772 9719 ksmbd_debug(SMB,
9773 9720 "smb2 with mid %llu cancelled command = 0x%x\n",
9774 9721 le64_to_cpu(hdr->MessageId),
9775 9722 le16_to_cpu(chdr->Command));
9776 - if (iter->cancel_fn)
9777 - iter->cancel_fn(iter->cancel_argv);
9723 + iter->state = KSMBD_WORK_CANCELLED;
9778 9724 break;
9779 9725 }
9780 9726 spin_unlock(&conn->request_lock);
@@ -11820,7 +11766,7 @@ static void smb2_notify_cancel_fn(void **argv)
11820 11766 return;
11821 11767 conn = in_work->conn;
11822 11768
11823 - ctx = kmalloc_obj(*ctx, GFP_ATOMIC);
11769 + ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
11824 11770 if (!ctx) {
11825 11771 /* Can't defer the response -- free without sending one. */
11826 11772 list_del_init(&in_work->async_request_entry);
modified fs/smb/server/smbacl.c
@@ -383,10 +383,10 @@ void free_acl_state(struct posix_acl_state *state)
383 383 kfree(state->groups);
384 384 }
385 385
386 - static int parse_dacl(struct mnt_idmap *idmap,
387 - struct smb_acl *pdacl, char *end_of_acl,
388 - struct smb_sid *pownersid, struct smb_sid *pgrpsid,
389 - struct smb_fattr *fattr)
386 + static void parse_dacl(struct mnt_idmap *idmap,
387 + struct smb_acl *pdacl, char *end_of_acl,
388 + struct smb_sid *pownersid, struct smb_sid *pgrpsid,
389 + struct smb_fattr *fattr)
390 390 {
391 391 int i, ret;
392 392 u16 num_aces = 0;
@@ -400,13 +400,13 @@ static int parse_dacl(struct mnt_idmap *idmap,
400 400 bool owner_found = false, group_found = false, others_found = false;
401 401
402 402 if (!pdacl)
403 - return 0;
403 + return;
404 404
405 405 /* validate that we do not go past end of acl */
406 406 if (end_of_acl < (char *)pdacl + sizeof(struct smb_acl) ||
407 407 end_of_acl < (char *)pdacl + le16_to_cpu(pdacl->size)) {
408 408 pr_err("ACL too small to parse DACL\n");
409 - return -EINVAL;
409 + return;
410 410 }
411 411
412 412 ksmbd_debug(SMB, "DACL revision %d size %d num aces %d\n",
@@ -418,31 +418,31 @@ static int parse_dacl(struct mnt_idmap *idmap,
418 418
419 419 num_aces = le16_to_cpu(pdacl->num_aces);
420 420 if (num_aces <= 0)
421 - return 0;
421 + return;
422 422
423 423 dacl_size = le16_to_cpu(pdacl->size);
424 424 if (dacl_size < sizeof(struct smb_acl))
425 - return -EINVAL;
425 + return;
426 426
427 427 if (num_aces > (dacl_size - sizeof(struct smb_acl)) /
428 428 (offsetof(struct smb_ace, sid) +
429 429 offsetof(struct smb_sid, sub_auth) + sizeof(__le16)))
430 - return -EINVAL;
430 + return;
431 431
432 432 ret = init_acl_state(&acl_state, num_aces);
433 433 if (ret)
434 - return ret;
434 + return;
435 435 ret = init_acl_state(&default_acl_state, num_aces);
436 436 if (ret) {
437 437 free_acl_state(&acl_state);
438 - return ret;
438 + return;
439 439 }
440 440
441 441 ppace = kmalloc_objs(struct smb_ace *, num_aces, KSMBD_DEFAULT_GFP);
442 442 if (!ppace) {
443 443 free_acl_state(&default_acl_state);
444 444 free_acl_state(&acl_state);
445 - return -ENOMEM;
445 + return;
446 446 }
447 447
448 448 /*
@@ -451,10 +451,8 @@ static int parse_dacl(struct mnt_idmap *idmap,
451 451 * user/group/other have no permissions
452 452 */
453 453 for (i = 0; i < num_aces; ++i) {
454 - if (end_of_acl - acl_base < acl_size) {
455 - ret = -EINVAL;
456 - goto out;
457 - }
454 + if (end_of_acl - acl_base < acl_size)
455 + break;
458 456
459 457 ppace[i] = (struct smb_ace *)(acl_base + acl_size);
460 458 acl_base = (char *)ppace[i];
@@ -467,10 +465,8 @@ static int parse_dacl(struct mnt_idmap *idmap,
467 465 (end_of_acl - acl_base <
468 466 acl_size + sizeof(__le32) * ppace[i]->sid.num_subauth) ||
469 467 (le16_to_cpu(ppace[i]->size) <
470 - acl_size + sizeof(__le32) * ppace[i]->sid.num_subauth)) {
471 - ret = -EINVAL;
472 - goto out;
473 - }
468 + acl_size + sizeof(__le32) * ppace[i]->sid.num_subauth))
469 + break;
474 470
475 471 acl_size = le16_to_cpu(ppace[i]->size);
476 472 ppace[i]->access_req =
@@ -528,8 +524,8 @@ static int parse_dacl(struct mnt_idmap *idmap,
528 524 temp_fattr.cf_uid = INVALID_UID;
529 525 ret = sid_to_id(idmap, &ppace[i]->sid, SIDOWNER, &temp_fattr);
530 526 if (ret || uid_eq(temp_fattr.cf_uid, INVALID_UID)) {
531 - pr_err_ratelimited("%s: Error %d mapping Owner SID to uid\n",
532 - __func__, ret);
527 + pr_err("%s: Error %d mapping Owner SID to uid\n",
528 + __func__, ret);
533 529 continue;
534 530 }
535 531
@@ -545,6 +541,7 @@ static int parse_dacl(struct mnt_idmap *idmap,
545 541 ((acl_mode & 0700) >> 6) | 0004;
546 542 }
547 543 }
544 + kfree(ppace);
548 545
549 546 if (owner_found) {
550 547 /* The owner must be set to at least read-only. */
@@ -587,12 +584,10 @@ static int parse_dacl(struct mnt_idmap *idmap,
587 584 fattr->cf_acls =
588 585 posix_acl_alloc(acl_state.users->n +
589 586 acl_state.groups->n + 4, KSMBD_DEFAULT_GFP);
590 - if (!fattr->cf_acls) {
591 - ret = -ENOMEM;
592 - goto out;
587 + if (fattr->cf_acls) {
588 + cf_pace = fattr->cf_acls->a_entries;
589 + posix_state_to_acl(&acl_state, cf_pace);
593 590 }
594 - cf_pace = fattr->cf_acls->a_entries;
595 - posix_state_to_acl(&acl_state, cf_pace);
596 591 }
597 592 }
598 593
@@ -603,20 +598,14 @@ static int parse_dacl(struct mnt_idmap *idmap,
603 598 fattr->cf_dacls =
604 599 posix_acl_alloc(default_acl_state.users->n +
605 600 default_acl_state.groups->n + 4, KSMBD_DEFAULT_GFP);
606 - if (!fattr->cf_dacls) {
607 - ret = -ENOMEM;
608 - goto out;
601 + if (fattr->cf_dacls) {
602 + cf_pdace = fattr->cf_dacls->a_entries;
603 + posix_state_to_acl(&default_acl_state, cf_pdace);
609 604 }
610 - cf_pdace = fattr->cf_dacls->a_entries;
611 - posix_state_to_acl(&default_acl_state, cf_pdace);
612 605 }
613 606 }
614 - ret = 0;
615 - out:
616 - kfree(ppace);
617 607 free_acl_state(&acl_state);
618 608 free_acl_state(&default_acl_state);
619 - return ret;
620 609 }
621 610
622 611 static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap,
@@ -977,10 +966,8 @@ int parse_sec_desc(struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
977 966 if (dacloffset < sizeof(struct smb_ntsd))
978 967 return -EINVAL;
979 968
980 - rc = parse_dacl(idmap, dacl_ptr, end_of_acl,
981 - owner_sid_ptr, group_sid_ptr, fattr);
982 - if (rc)
983 - return rc;
969 + parse_dacl(idmap, dacl_ptr, end_of_acl,
970 + owner_sid_ptr, group_sid_ptr, fattr);
984 971 }
985 972
986 973 return 0;
modified fs/smb/server/transport_ipc.c
@@ -532,21 +532,14 @@ static int ipc_validate_msg(struct ipc_msg_table_entry *entry)
532 532 if (entry->msg_sz < sizeof(struct ksmbd_share_config_response))
533 533 return -EINVAL;
534 534
535 - if (strnlen(resp->share_name, sizeof(resp->share_name)) ==
536 - sizeof(resp->share_name))
537 - return -EINVAL;
538 -
539 - if (resp->veto_list_sz > resp->payload_sz)
540 - return -EINVAL;
541 -
542 - if (resp->flags != KSMBD_SHARE_FLAG_INVALID &&
543 - !(resp->flags & KSMBD_SHARE_FLAG_PIPE) &&
544 - resp->payload_sz <= resp->veto_list_sz)
545 - return -EINVAL;
535 + if (resp->payload_sz) {
536 + if (resp->payload_sz < resp->veto_list_sz)
537 + return -EINVAL;
546 538
547 - if (check_add_overflow(sizeof(struct ksmbd_share_config_response),
548 - resp->payload_sz, &msg_sz))
549 - return -EINVAL;
539 + if (check_add_overflow(sizeof(struct ksmbd_share_config_response),
540 + resp->payload_sz, &msg_sz))
541 + return -EINVAL;
542 + }
550 543 break;
551 544 }
552 545 case KSMBD_EVENT_LOGIN_REQUEST_EXT:
modified fs/smb/server/transport_tcp.c
@@ -39,7 +39,6 @@ struct tcp_transport {
39 39 static const struct ksmbd_transport_ops ksmbd_tcp_transport_ops;
40 40
41 41 static void tcp_stop_kthread(struct task_struct *kthread);
42 - static void ksmbd_tcp_stop_listener(struct interface *iface);
43 42 static struct interface *alloc_iface(char *ifname);
44 43 static void ksmbd_tcp_disconnect(struct ksmbd_transport *t);
45 44
@@ -322,20 +321,13 @@ static int ksmbd_tcp_run_kthread(struct interface *iface)
322 321 int rc;
323 322 struct task_struct *kthread;
324 323
325 - kthread = kthread_create(ksmbd_kthread_fn, (void *)iface, "ksmbd-%s",
326 - iface->name);
324 + kthread = kthread_run(ksmbd_kthread_fn, (void *)iface, "ksmbd-%s",
325 + iface->name);
327 326 if (IS_ERR(kthread)) {
328 327 rc = PTR_ERR(kthread);
329 328 return rc;
330 329 }
331 -
332 - /*
333 - * The listener can exit after its socket is shutdown, so keep the
334 - * task_struct alive until the caller has stopped it.
335 - */
336 - get_task_struct(kthread);
337 330 iface->ksmbd_kthread = kthread;
338 - wake_up_process(kthread);
339 331
340 332 return 0;
341 333 }
@@ -606,7 +598,12 @@ static int ksmbd_netdev_event(struct notifier_block *nb, unsigned long event,
606 598 if (iface && iface->state == IFACE_STATE_CONFIGURED) {
607 599 ksmbd_debug(CONN, "netdev-down event: netdev(%s) is going down\n",
608 600 iface->name);
609 - ksmbd_tcp_stop_listener(iface);
601 + kernel_sock_shutdown(iface->ksmbd_socket, SHUT_RDWR);
602 + tcp_stop_kthread(iface->ksmbd_kthread);
603 + iface->ksmbd_kthread = NULL;
604 + sock_release(iface->ksmbd_socket);
605 + iface->ksmbd_socket = NULL;
606 +
610 607 iface->state = IFACE_STATE_DOWN;
611 608 break;
612 609 }
@@ -634,25 +631,11 @@ static void tcp_stop_kthread(struct task_struct *kthread)
634 631 if (!kthread)
635 632 return;
636 633
637 - ret = kthread_stop_put(kthread);
634 + ret = kthread_stop(kthread);
638 635 if (ret)
639 636 pr_err("failed to stop forker thread\n");
640 637 }
641 638
642 - static void ksmbd_tcp_stop_listener(struct interface *iface)
643 - {
644 - if (iface->ksmbd_socket)
645 - kernel_sock_shutdown(iface->ksmbd_socket, SHUT_RDWR);
646 -
647 - tcp_stop_kthread(iface->ksmbd_kthread);
648 - iface->ksmbd_kthread = NULL;
649 -
650 - if (iface->ksmbd_socket) {
651 - sock_release(iface->ksmbd_socket);
652 - iface->ksmbd_socket = NULL;
653 - }
654 - }
655 -
656 639 void ksmbd_tcp_destroy(void)
657 640 {
658 641 struct interface *iface, *tmp;
@@ -660,7 +643,6 @@ void ksmbd_tcp_destroy(void)
660 643 unregister_netdevice_notifier(&ksmbd_netdev_notifier);
661 644
662 645 list_for_each_entry_safe(iface, tmp, &iface_list, entry) {
663 - ksmbd_tcp_stop_listener(iface);
664 646 list_del(&iface->entry);
665 647 kfree(iface->name);
666 648 kfree(iface);
modified fs/smb/server/vfs.c
@@ -2007,11 +2007,6 @@ out:
2007 2007 return ret;
2008 2008 }
2009 2009
2010 - static bool ksmbd_vfs_copy_range_valid(loff_t offset, size_t len)
2011 - {
2012 - return offset >= 0 && (loff_t)len <= MAX_LFS_FILESIZE - offset;
2013 - }
2014 -
2015 2010 int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
2016 2011 struct ksmbd_file *src_fp,
2017 2012 struct ksmbd_file *dst_fp,
@@ -2047,10 +2042,6 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
2047 2042 dst_off = le64_to_cpu(chunks[i].TargetOffset);
2048 2043 len = le32_to_cpu(chunks[i].Length);
2049 2044
2050 - if (!ksmbd_vfs_copy_range_valid(src_off, len) ||
2051 - !ksmbd_vfs_copy_range_valid(dst_off, len))
2052 - return -E2BIG;
2053 -
2054 2045 if (check_lock_range(src_fp->filp, src_off,
2055 2046 src_off + len - 1, READ))
2056 2047 return -EAGAIN;
@@ -2143,8 +2134,7 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
2143 2134 len = le32_to_cpu(chunks[i].Length);
2144 2135 copy_len = len;
2145 2136
2146 - if (!ksmbd_vfs_copy_range_valid(src_off, len) ||
2147 - !ksmbd_vfs_copy_range_valid(dst_off, len))
2137 + if (src_off < 0)
2148 2138 return -E2BIG;
2149 2139
2150 2140 if (src_off > src_file_size || len > src_file_size - src_off) {
modified fs/smb/server/vfs_cache.c
@@ -846,25 +846,12 @@ static void set_close_state_blocked_works(struct ksmbd_file *fp)
846 846 spin_lock(&fp->f_lock);
847 847 list_for_each_entry(cancel_work, &fp->blocked_works,
848 848 fp_entry) {
849 - if (xchg(&cancel_work->state, KSMBD_WORK_CLOSED) ==
850 - KSMBD_WORK_ACTIVE)
851 - cancel_work->cancel_fn(cancel_work->cancel_argv);
849 + cancel_work->state = KSMBD_WORK_CLOSED;
850 + cancel_work->cancel_fn(cancel_work->cancel_argv);
852 851 }
853 852 spin_unlock(&fp->f_lock);
854 853 }
855 854
856 - void ksmbd_wake_session_blocked_works(struct ksmbd_session *sess)
857 - {
858 - struct ksmbd_file_table *ft = &sess->file_table;
859 - struct ksmbd_file *fp;
860 - unsigned int id;
861 -
862 - read_lock(&ft->lock);
863 - idr_for_each_entry(ft->idr, fp, id)
864 - set_close_state_blocked_works(fp);
865 - read_unlock(&ft->lock);
866 - }
867 -
868 855 int ksmbd_close_fd(struct ksmbd_work *work, u64 id)
869 856 {
870 857 struct ksmbd_file *fp;
modified fs/smb/server/vfs_cache.h
@@ -226,7 +226,6 @@ void ksmbd_stop_durable_scavenger(void);
226 226 bool ksmbd_durable_scavenger_active(void);
227 227 void ksmbd_close_tree_conn_fds(struct ksmbd_work *work);
228 228 void ksmbd_close_session_fds(struct ksmbd_work *work);
229 - void ksmbd_wake_session_blocked_works(struct ksmbd_session *sess);
230 229 int ksmbd_close_inode_fds(struct ksmbd_work *work, struct inode *inode);
231 230 int ksmbd_init_global_file_table(void);
232 231 void ksmbd_free_global_file_table(void);
modified fs/xfs/Makefile
@@ -91,7 +91,6 @@ xfs-y += xfs_aops.o \
91 91 xfs_healthmon.o \
92 92 xfs_icache.o \
93 93 xfs_ioctl.o \
94 - xfs_ioend.o \
95 94 xfs_iomap.o \
96 95 xfs_iops.o \
97 96 xfs_inode.o \
modified fs/xfs/libxfs/xfs_da_btree.c
@@ -2746,8 +2746,8 @@ xfs_dabuf_map(
2746 2746 * larger one that needs to be free by the caller.
2747 2747 */
2748 2748 if (nirecs > 1) {
2749 - map = kzalloc_objs(struct xfs_buf_map, nirecs,
2750 - GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
2749 + map = kcalloc(nirecs, sizeof(struct xfs_buf_map),
2750 + GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_NOFAIL);
2751 2751 *mapp = map;
2752 2752 }
2753 2753
modified fs/xfs/libxfs/xfs_rtgroup.h
@@ -359,11 +359,7 @@ static inline int xfs_initialize_rtgroups(struct xfs_mount *mp,
359 359 # define xfs_rtgroup_unlock(rtg, gf) ((void)0)
360 360 # define xfs_rtgroup_trans_join(tp, rtg, gf) ((void)0)
361 361 # define xfs_update_rtsb(bp, sb_bp) ((void)0)
362 - static inline struct xfs_buf *xfs_log_rtsb(struct xfs_trans *tp,
363 - const struct xfs_buf *sb_bp)
364 - {
365 - return NULL;
366 - }
362 + # define xfs_log_rtsb(tp, sb_bp) (NULL)
367 363 # define xfs_rtgroup_get_geometry(rtg, rgeo) (-EOPNOTSUPP)
368 364 #endif /* CONFIG_XFS_RT */
369 365
modified fs/xfs/libxfs/xfs_sb.c
@@ -1470,33 +1470,36 @@ xfs_sync_sb_buf(
1470 1470 bool update_rtsb)
1471 1471 {
1472 1472 struct xfs_trans *tp;
1473 + struct xfs_buf *bp;
1474 + struct xfs_buf *rtsb_bp = NULL;
1473 1475 int error;
1474 1476
1475 1477 error = xfs_trans_alloc(mp, &M_RES(mp)->tr_sb, 0, 0, 0, &tp);
1476 1478 if (error)
1477 1479 return error;
1478 1480
1481 + bp = xfs_trans_getsb(tp);
1479 1482 xfs_log_sb(tp);
1480 - if (update_rtsb)
1481 - xfs_log_rtsb(tp, xfs_trans_getsb(tp));
1483 + xfs_trans_bhold(tp, bp);
1484 + if (update_rtsb) {
1485 + rtsb_bp = xfs_log_rtsb(tp, bp);
1486 + if (rtsb_bp)
1487 + xfs_trans_bhold(tp, rtsb_bp);
1488 + }
1482 1489 xfs_trans_set_sync(tp);
1483 1490 error = xfs_trans_commit(tp);
1484 1491 if (error)
1485 - return error;
1486 -
1487 - /* Re-acquire and write the sb and rtsb to disk. */
1488 - xfs_buf_lock(mp->m_sb_bp);
1489 - error = xfs_bwrite(mp->m_sb_bp);
1490 - xfs_buf_unlock(mp->m_sb_bp);
1491 - if (error)
1492 - return error;
1493 -
1494 - if (update_rtsb && mp->m_rtsb_bp) {
1495 - xfs_buf_lock(mp->m_rtsb_bp);
1496 - error = xfs_bwrite(mp->m_rtsb_bp);
1497 - xfs_buf_unlock(mp->m_rtsb_bp);
1498 - }
1499 -
1492 + goto out;
1493 + /*
1494 + * write out the sb buffer to get the changes to disk
1495 + */
1496 + error = xfs_bwrite(bp);
1497 + if (!error && rtsb_bp)
1498 + error = xfs_bwrite(rtsb_bp);
1499 + out:
1500 + if (rtsb_bp)
1501 + xfs_buf_relse(rtsb_bp);
1502 + xfs_buf_relse(bp);
1500 1503 return error;
1501 1504 }
1502 1505
modified fs/xfs/xfs_aops.c
@@ -20,7 +20,6 @@
20 20 #include "xfs_errortag.h"
21 21 #include "xfs_error.h"
22 22 #include "xfs_icache.h"
23 - #include "xfs_ioend.h"
24 23 #include "xfs_zone_alloc.h"
25 24 #include "xfs_rtgroup.h"
26 25 #include <linux/bio-integrity.h>
@@ -37,6 +36,15 @@ XFS_WPC(struct iomap_writepage_ctx *ctx)
37 36 return container_of(ctx, struct xfs_writepage_ctx, ctx);
38 37 }
39 38
39 + /*
40 + * Fast and loose check if this write could update the on-disk inode size.
41 + */
42 + static inline bool xfs_ioend_is_append(struct iomap_ioend *ioend)
43 + {
44 + return ioend->io_offset + ioend->io_size >
45 + XFS_I(ioend->io_inode)->i_disk_size;
46 + }
47 +
40 48 /*
41 49 * Update on-disk file size now that data has been written to disk.
42 50 */
@@ -72,6 +80,175 @@ xfs_setfilesize(
72 80 return xfs_trans_commit(tp);
73 81 }
74 82
83 + static void
84 + xfs_ioend_put_open_zones(
85 + struct iomap_ioend *ioend)
86 + {
87 + struct iomap_ioend *tmp;
88 +
89 + /*
90 + * Put the open zone for all ioends merged into this one (if any).
91 + */
92 + list_for_each_entry(tmp, &ioend->io_list, io_list)
93 + xfs_open_zone_put(tmp->io_private);
94 +
95 + /*
96 + * The main ioend might not have an open zone if the submission failed
97 + * before xfs_zone_alloc_and_submit got called.
98 + */
99 + if (ioend->io_private)
100 + xfs_open_zone_put(ioend->io_private);
101 + }
102 +
103 + /*
104 + * IO write completion.
105 + */
106 + STATIC void
107 + xfs_end_ioend_write(
108 + struct iomap_ioend *ioend)
109 + {
110 + struct xfs_inode *ip = XFS_I(ioend->io_inode);
111 + struct xfs_mount *mp = ip->i_mount;
112 + bool is_zoned = xfs_is_zoned_inode(ip);
113 + xfs_off_t offset = ioend->io_offset;
114 + size_t size = ioend->io_size;
115 + unsigned int nofs_flag;
116 + int error;
117 +
118 + /*
119 + * We can allocate memory here while doing writeback on behalf of
120 + * memory reclaim. To avoid memory allocation deadlocks set the
121 + * task-wide nofs context for the following operations.
122 + */
123 + nofs_flag = memalloc_nofs_save();
124 +
125 + /*
126 + * Just clean up the in-memory structures if the fs has been shut down.
127 + */
128 + if (xfs_is_shutdown(mp)) {
129 + error = -EIO;
130 + goto done;
131 + }
132 +
133 + /*
134 + * Clean up all COW blocks and underlying data fork delalloc blocks on
135 + * I/O error. The delalloc punch is required because this ioend was
136 + * mapped to blocks in the COW fork and the associated pages are no
137 + * longer dirty. If we don't remove delalloc blocks here, they become
138 + * stale and can corrupt free space accounting on unmount.
139 + */
140 + error = blk_status_to_errno(ioend->io_bio.bi_status);
141 + if (unlikely(error)) {
142 + /*
143 + * Zoned writes update the in-core open zone accounting before
144 + * I/O submission. A failed write leaves that state
145 + * inconsistent, so shut down the filesystem instead of letting
146 + * later writers wait forever for open zone space to become
147 + * available.
148 + */
149 + if (is_zoned) {
150 + xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR);
151 + goto done;
152 + }
153 + if (ioend->io_flags & IOMAP_IOEND_SHARED) {
154 + ASSERT(!is_zoned);
155 + xfs_reflink_cancel_cow_range(ip, offset, size, true);
156 + xfs_bmap_punch_delalloc_range(ip, XFS_DATA_FORK, offset,
157 + offset + size, NULL);
158 + }
159 + goto done;
160 + }
161 +
162 + /*
163 + * Success: commit the COW or unwritten blocks if needed.
164 + */
165 + if (is_zoned)
166 + error = xfs_zoned_end_io(ip, offset, size, ioend->io_sector,
167 + ioend->io_private, NULLFSBLOCK);
168 + else if (ioend->io_flags & IOMAP_IOEND_SHARED)
169 + error = xfs_reflink_end_cow(ip, offset, size);
170 + else if (ioend->io_flags & IOMAP_IOEND_UNWRITTEN)
171 + error = xfs_iomap_write_unwritten(ip, offset, size, false);
172 +
173 + if (!error &&
174 + !(ioend->io_flags & IOMAP_IOEND_DIRECT) &&
175 + xfs_ioend_is_append(ioend))
176 + error = xfs_setfilesize(ip, offset, size);
177 + done:
178 + if (is_zoned)
179 + xfs_ioend_put_open_zones(ioend);
180 + iomap_finish_ioends(ioend, error);
181 + memalloc_nofs_restore(nofs_flag);
182 + }
183 +
184 + /*
185 + * Finish all pending IO completions that require transactional modifications.
186 + *
187 + * We try to merge physical and logically contiguous ioends before completion to
188 + * minimise the number of transactions we need to perform during IO completion.
189 + * Both unwritten extent conversion and COW remapping need to iterate and modify
190 + * one physical extent at a time, so we gain nothing by merging physically
191 + * discontiguous extents here.
192 + *
193 + * The ioend chain length that we can be processing here is largely unbound in
194 + * length and we may have to perform significant amounts of work on each ioend
195 + * to complete it. Hence we have to be careful about holding the CPU for too
196 + * long in this loop.
197 + */
198 + void
199 + xfs_end_io(
200 + struct work_struct *work)
201 + {
202 + struct xfs_inode *ip =
203 + container_of(work, struct xfs_inode, i_ioend_work);
204 + struct iomap_ioend *ioend;
205 + struct list_head tmp;
206 + unsigned long flags;
207 +
208 + spin_lock_irqsave(&ip->i_ioend_lock, flags);
209 + list_replace_init(&ip->i_ioend_list, &tmp);
210 + spin_unlock_irqrestore(&ip->i_ioend_lock, flags);
211 +
212 + iomap_sort_ioends(&tmp);
213 + while ((ioend = list_first_entry_or_null(&tmp, struct iomap_ioend,
214 + io_list))) {
215 + list_del_init(&ioend->io_list);
216 + iomap_ioend_try_merge(ioend, &tmp);
217 + if (bio_op(&ioend->io_bio) == REQ_OP_READ)
218 + iomap_finish_ioends(ioend,
219 + blk_status_to_errno(ioend->io_bio.bi_status));
220 + else
221 + xfs_end_ioend_write(ioend);
222 + cond_resched();
223 + }
224 + }
225 +
226 + void
227 + xfs_end_bio(
228 + struct bio *bio)
229 + {
230 + struct iomap_ioend *ioend = iomap_ioend_from_bio(bio);
231 + struct xfs_inode *ip = XFS_I(ioend->io_inode);
232 + struct xfs_mount *mp = ip->i_mount;
233 + unsigned long flags;
234 +
235 + /*
236 + * For Appends record the actually written block number and set the
237 + * boundary flag if needed.
238 + */
239 + if (IS_ENABLED(CONFIG_XFS_RT) && bio_is_zone_append(bio)) {
240 + ioend->io_sector = bio->bi_iter.bi_sector;
241 + xfs_mark_rtg_boundary(ioend);
242 + }
243 +
244 + spin_lock_irqsave(&ip->i_ioend_lock, flags);
245 + if (list_empty(&ip->i_ioend_list))
246 + WARN_ON_ONCE(!queue_work(mp->m_unwritten_workqueue,
247 + &ip->i_ioend_work));
248 + list_add_tail(&ioend->io_list, &ip->i_ioend_list);
249 + spin_unlock_irqrestore(&ip->i_ioend_lock, flags);
250 + }
251 +
75 252 /*
76 253 * We cannot cancel the ioend directly on error. We may have already set other
77 254 * pages under writeback and hence we have to run I/O completion to mark the
@@ -454,8 +631,13 @@ xfs_zoned_map_blocks(
454 631 XFS_BMAPI_REMAP);
455 632 xfs_iunlock(ip, XFS_ILOCK_EXCL);
456 633
457 - xfs_iomap_set_anon_write(ip, &wpc->iomap, offset,
458 - XFS_FSB_TO_B(mp, count_fsb));
634 + wpc->iomap.type = IOMAP_MAPPED;
635 + wpc->iomap.flags = IOMAP_F_DIRTY;
636 + wpc->iomap.bdev = mp->m_rtdev_targp->bt_bdev;
637 + wpc->iomap.offset = offset;
638 + wpc->iomap.length = XFS_FSB_TO_B(mp, count_fsb);
639 + wpc->iomap.flags = IOMAP_F_ANON_WRITE;
640 +
459 641 trace_xfs_zoned_map_blocks(ip, offset, wpc->iomap.length);
460 642 return 0;
461 643 }
modified fs/xfs/xfs_aops.h
@@ -10,5 +10,6 @@ extern const struct address_space_operations xfs_address_space_operations;
10 10 extern const struct address_space_operations xfs_dax_aops;
11 11
12 12 int xfs_setfilesize(struct xfs_inode *ip, xfs_off_t offset, size_t size);
13 + void xfs_end_bio(struct bio *bio);
13 14
14 15 #endif /* __XFS_AOPS_H__ */
modified fs/xfs/xfs_file.c
@@ -25,7 +25,7 @@
25 25 #include "xfs_iomap.h"
26 26 #include "xfs_reflink.h"
27 27 #include "xfs_file.h"
28 - #include "xfs_ioend.h"
28 + #include "xfs_aops.h"
29 29 #include "xfs_zone_alloc.h"
30 30 #include "xfs_error.h"
31 31 #include "xfs_errortag.h"
modified fs/xfs/xfs_fsmap.c
@@ -1174,7 +1174,8 @@ xfs_getfsmap(
1174 1174 if (!xfs_getfsmap_check_keys(&head->fmh_keys[0], &head->fmh_keys[1]))
1175 1175 return -EINVAL;
1176 1176
1177 - use_rmap = xfs_has_rmapbt(mp) && capable_noaudit(CAP_SYS_ADMIN);
1177 + use_rmap = xfs_has_rmapbt(mp) &&
1178 + has_capability_noaudit(current, CAP_SYS_ADMIN);
1178 1179 head->fmh_entries = 0;
1179 1180
1180 1181 /* Set up our device handlers. */
modified fs/xfs/xfs_icache.c
@@ -82,20 +82,24 @@ static inline xa_mark_t ici_tag_to_mark(unsigned int tag)
82 82
83 83 /*
84 84 * Allocate and initialise an xfs_inode.
85 - *
86 - * This can happen in context of already dirtied transactions, so the memory
87 - * allocations must not fail.
88 85 */
89 86 struct xfs_inode *
90 87 xfs_inode_alloc(
91 88 struct xfs_mount *mp,
92 89 xfs_ino_t ino)
93 90 {
94 - gfp_t gfp = GFP_KERNEL | __GFP_NOFAIL;
95 91 struct xfs_inode *ip;
96 92
97 - ip = alloc_inode_sb(mp->m_super, xfs_inode_cache, gfp);
98 - inode_init_always_gfp(mp->m_super, VFS_I(ip), gfp);
93 + /*
94 + * XXX: If this didn't occur in transactions, we could drop GFP_NOFAIL
95 + * and return NULL here on ENOMEM.
96 + */
97 + ip = alloc_inode_sb(mp->m_super, xfs_inode_cache, GFP_KERNEL | __GFP_NOFAIL);
98 +
99 + if (inode_init_always(mp->m_super, VFS_I(ip))) {
100 + kmem_cache_free(xfs_inode_cache, ip);
101 + return NULL;
102 + }
99 103
100 104 VFS_I(ip)->i_ino = ino;
101 105 /* VFS doesn't initialise i_mode! */
modified fs/xfs/xfs_ioctl.c
@@ -647,7 +647,7 @@ xfs_ioctl_setattr_get_trans(
647 647 goto out_error;
648 648
649 649 error = xfs_trans_alloc_ichange(ip, NULL, NULL, pdqp,
650 - capable_noaudit(CAP_FOWNER), &tp);
650 + has_capability_noaudit(current, CAP_FOWNER), &tp);
651 651 if (error)
652 652 goto out_error;
653 653
deleted fs/xfs/xfs_ioend.c mode 100644
@@ -1,184 +0,0 @@
1 - // SPDX-License-Identifier: GPL-2.0
2 - /*
3 - * Copyright (c) 2016-2025 Christoph Hellwig.
4 - * All Rights Reserved.
5 - */
6 - #include "xfs_platform.h"
7 - #include "xfs_shared.h"
8 - #include "xfs_format.h"
9 - #include "xfs_log_format.h"
10 - #include "xfs_trans_resv.h"
11 - #include "xfs_mount.h"
12 - #include "xfs_inode.h"
13 - #include "xfs_iomap.h"
14 - #include "xfs_trace.h"
15 - #include "xfs_bmap_util.h"
16 - #include "xfs_reflink.h"
17 - #include "xfs_zone_alloc.h"
18 - #include "xfs_ioend.h"
19 -
20 - static void
21 - xfs_ioend_put_open_zones(
22 - struct iomap_ioend *ioend)
23 - {
24 - struct iomap_ioend *tmp;
25 -
26 - /*
27 - * Put the open zone for all ioends merged into this one (if any).
28 - */
29 - list_for_each_entry(tmp, &ioend->io_list, io_list)
30 - xfs_open_zone_put(tmp->io_private);
31 -
32 - /*
33 - * The main ioend might not have an open zone if the submission failed
34 - * before xfs_zone_alloc_and_submit got called.
35 - */
36 - if (ioend->io_private)
37 - xfs_open_zone_put(ioend->io_private);
38 - }
39 -
40 - static void
41 - xfs_end_ioend_write(
42 - struct iomap_ioend *ioend)
43 - {
44 - struct xfs_inode *ip = XFS_I(ioend->io_inode);
45 - struct xfs_mount *mp = ip->i_mount;
46 - bool is_zoned = xfs_is_zoned_inode(ip);
47 - xfs_off_t offset = ioend->io_offset;
48 - size_t size = ioend->io_size;
49 - unsigned int nofs_flag;
50 - int error;
51 -
52 - /*
53 - * We can allocate memory here while doing writeback on behalf of
54 - * memory reclaim. To avoid memory allocation deadlocks set the
55 - * task-wide nofs context for the following operations.
56 - */
57 - nofs_flag = memalloc_nofs_save();
58 -
59 - /*
60 - * Just clean up the in-memory structures if the fs has been shut down.
61 - */
62 - if (xfs_is_shutdown(mp)) {
63 - error = -EIO;
64 - goto done;
65 - }
66 -
67 - /*
68 - * Clean up all COW blocks and underlying data fork delalloc blocks on
69 - * I/O error. The delalloc punch is required because this ioend was
70 - * mapped to blocks in the COW fork and the associated pages are no
71 - * longer dirty. If we don't remove delalloc blocks here, they become
72 - * stale and can corrupt free space accounting on unmount.
73 - */
74 - error = blk_status_to_errno(ioend->io_bio.bi_status);
75 - if (unlikely(error)) {
76 - /*
77 - * Zoned writes update the in-core open zone accounting before
78 - * I/O submission. A failed write leaves that state
79 - * inconsistent, so shut down the filesystem instead of letting
80 - * later writers wait forever for open zone space to become
81 - * available.
82 - */
83 - if (is_zoned) {
84 - xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR);
85 - goto done;
86 - }
87 - if (ioend->io_flags & IOMAP_IOEND_SHARED) {
88 - ASSERT(!is_zoned);
89 - xfs_reflink_cancel_cow_range(ip, offset, size, true);
90 - xfs_bmap_punch_delalloc_range(ip, XFS_DATA_FORK, offset,
91 - offset + size, NULL);
92 - }
93 - goto done;
94 - }
95 -
96 - /*
97 - * Success: commit the COW or unwritten blocks if needed.
98 - */
99 - if (is_zoned)
100 - error = xfs_zoned_end_io(ip, offset, size, ioend->io_sector,
101 - ioend->io_private, NULLFSBLOCK);
102 - else if (ioend->io_flags & IOMAP_IOEND_SHARED)
103 - error = xfs_reflink_end_cow(ip, offset, size);
104 - else if (ioend->io_flags & IOMAP_IOEND_UNWRITTEN)
105 - error = xfs_iomap_write_unwritten(ip, offset, size, false);
106 -
107 - if (!error &&
108 - !(ioend->io_flags & IOMAP_IOEND_DIRECT) &&
109 - xfs_ioend_is_append(ioend))
110 - error = xfs_setfilesize(ip, offset, size);
111 - done:
112 - if (is_zoned)
113 - xfs_ioend_put_open_zones(ioend);
114 - iomap_finish_ioends(ioend, error);
115 - memalloc_nofs_restore(nofs_flag);
116 - }
117 -
118 - /*
119 - * Finish all pending IO completions that require transactional modifications.
120 - *
121 - * We try to merge physical and logically contiguous ioends before completion to
122 - * minimise the number of transactions we need to perform during IO completion.
123 - * Both unwritten extent conversion and COW remapping need to iterate and modify
124 - * one physical extent at a time, so we gain nothing by merging physically
125 - * discontiguous extents here.
126 - *
127 - * The ioend chain length that we can be processing here is largely unbound in
128 - * length and we may have to perform significant amounts of work on each ioend
129 - * to complete it. Hence we have to be careful about holding the CPU for too
130 - * long in this loop.
131 - */
132 - void
133 - xfs_end_io(
134 - struct work_struct *work)
135 - {
136 - struct xfs_inode *ip =
137 - container_of(work, struct xfs_inode, i_ioend_work);
138 - struct iomap_ioend *ioend;
139 - struct list_head tmp;
140 - unsigned long flags;
141 -
142 - spin_lock_irqsave(&ip->i_ioend_lock, flags);
143 - list_replace_init(&ip->i_ioend_list, &tmp);
144 - spin_unlock_irqrestore(&ip->i_ioend_lock, flags);
145 -
146 - iomap_sort_ioends(&tmp);
147 - while ((ioend = list_first_entry_or_null(&tmp, struct iomap_ioend,
148 - io_list))) {
149 - list_del_init(&ioend->io_list);
150 - iomap_ioend_try_merge(ioend, &tmp);
151 - if (bio_op(&ioend->io_bio) == REQ_OP_READ)
152 - iomap_finish_ioends(ioend,
153 - blk_status_to_errno(ioend->io_bio.bi_status));
154 - else
155 - xfs_end_ioend_write(ioend);
156 - cond_resched();
157 - }
158 - }
159 -
160 - void
161 - xfs_end_bio(
162 - struct bio *bio)
163 - {
164 - struct iomap_ioend *ioend = iomap_ioend_from_bio(bio);
165 - struct xfs_inode *ip = XFS_I(ioend->io_inode);
166 - struct xfs_mount *mp = ip->i_mount;
167 - unsigned long flags;
168 -
169 - /*
170 - * For Appends record the actually written block number and set the
171 - * boundary flag if needed.
172 - */
173 - if (IS_ENABLED(CONFIG_XFS_RT) && bio_is_zone_append(bio)) {
174 - ioend->io_sector = bio->bi_iter.bi_sector;
175 - xfs_mark_rtg_boundary(ioend);
176 - }
177 -
178 - spin_lock_irqsave(&ip->i_ioend_lock, flags);
179 - if (list_empty(&ip->i_ioend_list))
180 - WARN_ON_ONCE(!queue_work(mp->m_unwritten_workqueue,
181 - &ip->i_ioend_work));
182 - list_add_tail(&ioend->io_list, &ip->i_ioend_list);
183 - spin_unlock_irqrestore(&ip->i_ioend_lock, flags);
184 - }
deleted fs/xfs/xfs_ioend.h mode 100644
@@ -1,16 +0,0 @@
1 - /* SPDX-License-Identifier: GPL-2.0 */
2 - #ifndef __XFS_IOEND_H
3 - #define __XFS_IOEND_H
4 -
5 - /*
6 - * Fast and loose check if this write could update the on-disk inode size.
7 - */
8 - static inline bool xfs_ioend_is_append(struct iomap_ioend *ioend)
9 - {
10 - return ioend->io_offset + ioend->io_size >
11 - XFS_I(ioend->io_inode)->i_disk_size;
12 - }
13 -
14 - void xfs_end_bio(struct bio *bio);
15 -
16 - #endif /* __XFS_IOEND_H */
modified fs/xfs/xfs_iomap.c
@@ -1083,7 +1083,12 @@ xfs_zoned_direct_write_iomap_begin(
1083 1083 return error;
1084 1084 }
1085 1085
1086 - xfs_iomap_set_anon_write(ip, iomap, offset, length);
1086 + iomap->type = IOMAP_MAPPED;
1087 + iomap->flags = IOMAP_F_DIRTY;
1088 + iomap->bdev = ip->i_mount->m_rtdev_targp->bt_bdev;
1089 + iomap->offset = offset;
1090 + iomap->length = length;
1091 + iomap->flags = IOMAP_F_ANON_WRITE;
1087 1092 return 0;
1088 1093 }
1089 1094
modified fs/xfs/xfs_iomap.h
@@ -29,20 +29,6 @@ int xfs_zero_range(struct xfs_inode *ip, loff_t pos, loff_t len,
29 29 int xfs_truncate_page(struct xfs_inode *ip, loff_t pos,
30 30 struct xfs_zone_alloc_ctx *ac, bool *did_zero);
31 31
32 - static inline void
33 - xfs_iomap_set_anon_write(
34 - struct xfs_inode *ip,
35 - struct iomap *iomap,
36 - loff_t offset,
37 - loff_t length)
38 - {
39 - iomap->type = IOMAP_MAPPED;
40 - iomap->bdev = ip->i_mount->m_rtdev_targp->bt_bdev;
41 - iomap->offset = offset;
42 - iomap->length = length;
43 - iomap->flags = IOMAP_F_ANON_WRITE | IOMAP_F_DIRTY;
44 - }
45 -
46 32 static inline xfs_filblks_t
47 33 xfs_aligned_fsb_count(
48 34 xfs_fileoff_t offset_fsb,
modified fs/xfs/xfs_iops.c
@@ -834,7 +834,7 @@ xfs_setattr_nonsize(
834 834 }
835 835
836 836 error = xfs_trans_alloc_ichange(ip, udqp, gdqp, NULL,
837 - capable_noaudit(CAP_FOWNER), &tp);
837 + has_capability_noaudit(current, CAP_FOWNER), &tp);
838 838 if (error)
839 839 goto out_dqrele;
840 840
modified fs/xfs/xfs_platform.h
@@ -289,4 +289,15 @@ int xfs_rw_bdev(struct block_device *bdev, sector_t sector, unsigned int count,
289 289 # define PTR_FMT "%p"
290 290 #endif
291 291
292 + /*
293 + * Helper for IO routines to grab backing pages from allocated kernel memory.
294 + */
295 + static inline struct page *
296 + kmem_to_page(void *addr)
297 + {
298 + if (is_vmalloc_addr(addr))
299 + return vmalloc_to_page(addr);
300 + return virt_to_page(addr);
301 + }
302 +
292 303 #endif /* _XFS_PLATFORM_H */
modified fs/xfs/xfs_super.c
@@ -445,7 +445,7 @@ xfs_shutdown_devices(
445 445 blkdev_issue_flush(mp->m_logdev_targp->bt_bdev);
446 446 invalidate_bdev(mp->m_logdev_targp->bt_bdev);
447 447 }
448 - if (mp->m_rtdev_targp && mp->m_rtdev_targp != mp->m_ddev_targp) {
448 + if (mp->m_rtdev_targp) {
449 449 blkdev_issue_flush(mp->m_rtdev_targp->bt_bdev);
450 450 invalidate_bdev(mp->m_rtdev_targp->bt_bdev);
451 451 }
modified fs/xfs/xfs_trans_buf.c
@@ -521,8 +521,7 @@ xfs_trans_log_buf(
521 521 {
522 522 struct xfs_buf_log_item *bip = bp->b_log_item;
523 523
524 - ASSERT(first <= last);
525 - ASSERT(last < BBTOB(bp->b_length));
524 + ASSERT(first <= last && last < BBTOB(bp->b_length));
526 525 ASSERT(!(bip->bli_flags & XFS_BLI_ORDERED));
527 526
528 527 xfs_trans_dirty_buf(tp, bp);
modified fs/xfs/xfs_zone_alloc.c
@@ -793,35 +793,17 @@ xfs_get_cached_zone(
793 793
794 794 rcu_read_lock();
795 795 oz = VFS_I(ip)->i_private;
796 - if (!oz)
797 - goto out_unlock;
798 -
799 - /*
800 - * GC only steals open zones at mount time, so no GC zones should end up
801 - * in the cache.
802 - */
803 - ASSERT(!oz->oz_is_gc);
804 -
805 - /*
806 - * Drop the old cached open zone if it is full.
807 - */
808 - if (oz->oz_allocated == rtg_blocks(oz->oz_rtg)) {
809 - spin_lock(&ip->i_flags_lock);
810 - oz = VFS_I(ip)->i_private;
811 - if (oz && oz->oz_allocated == rtg_blocks(oz->oz_rtg)) {
812 - VFS_I(ip)->i_private = NULL;
813 - spin_unlock(&ip->i_flags_lock);
814 - xfs_open_zone_put(oz);
796 + if (oz) {
797 + /*
798 + * GC only steals open zones at mount time, so no GC zones
799 + * should end up in the cache.
800 + */
801 + ASSERT(!oz->oz_is_gc);
802 + if (!atomic_inc_not_zero(&oz->oz_ref))
815 803 oz = NULL;
816 - goto out_unlock;
817 - }
818 - spin_unlock(&ip->i_flags_lock);
819 804 }
820 -
821 - if (!atomic_inc_not_zero(&oz->oz_ref))
822 - oz = NULL;
823 - out_unlock:
824 805 rcu_read_unlock();
806 +
825 807 return oz;
826 808 }
827 809
@@ -836,41 +818,18 @@ out_unlock:
836 818 * that were every written to, but significantly simplifies the cached zone
837 819 * lookup. Because the open_zone is clearly marked as full when all data
838 820 * in the underlying RTG was written, the caching is always safe.
839 - *
840 - * Called with a reference on @oz held. And returns two references on the
841 - * returned zone: one for the caller and one for pinning the zone in
842 - * inode->i_private.
843 821 */
844 - static struct xfs_open_zone *
822 + static void
845 823 xfs_set_cached_zone(
846 824 struct xfs_inode *ip,
847 825 struct xfs_open_zone *oz)
848 826 {
849 827 struct xfs_open_zone *old_oz;
850 828
851 - /*
852 - * If the open zone cached in the inode still has free space, use that
853 - * instead of the new open zone just selected. This can happen when
854 - * multiple threads race to perform zone selection for an inode.
855 - * io_uring worker threads seem to be good way to trigger this.
856 - *
857 - * We need to grab an extra reference to this open zone as the caller
858 - * owns a reference in addition to the i_private pointer.
859 - */
860 - spin_lock(&ip->i_flags_lock);
861 - old_oz = VFS_I(ip)->i_private;
862 - if (old_oz && old_oz->oz_allocated < rtg_blocks(old_oz->oz_rtg) &&
863 - atomic_inc_not_zero(&old_oz->oz_ref)) {
864 - spin_unlock(&ip->i_flags_lock);
865 - xfs_open_zone_put(oz);
866 - return old_oz;
867 - }
868 - VFS_I(ip)->i_private = oz;
869 829 atomic_inc(&oz->oz_ref);
870 - spin_unlock(&ip->i_flags_lock);
830 + old_oz = xchg(&VFS_I(ip)->i_private, oz);
871 831 if (old_oz)
872 832 xfs_open_zone_put(old_oz);
873 - return oz;
874 833 }
875 834
876 835 static void
@@ -914,13 +873,14 @@ xfs_zone_alloc_and_submit(
914 873 * the inode is still associated with a zone and use that if so.
915 874 */
916 875 if (!*oz)
917 - select_zone:
918 876 *oz = xfs_get_cached_zone(ip);
877 +
919 878 if (!*oz) {
879 + select_zone:
920 880 *oz = xfs_select_zone(mp, write_hint, pack_tight);
921 881 if (!*oz)
922 882 goto out_error;
923 - *oz = xfs_set_cached_zone(ip, *oz);
883 + xfs_set_cached_zone(ip, *oz);
924 884 }
925 885
926 886 alloc_len = xfs_zone_alloc_blocks(*oz, XFS_B_TO_FSB(mp, ioend->io_size),
modified fs/xfs/xfs_zone_gc.c
@@ -869,11 +869,6 @@ xfs_zone_gc_write_chunk(
869 869 WRITE_ONCE(chunk->state, XFS_GC_BIO_NEW);
870 870 list_move_tail(&chunk->entry, &data->writing);
871 871
872 - /*
873 - * If we run on top of stacked block device, the read I/O might have
874 - * reset bi_bdev, restore it to the one we want.
875 - */
876 - bio_set_dev(&chunk->bio, mp->m_rtdev_targp->bt_bdev);
877 872 bio_reuse(&chunk->bio, REQ_OP_WRITE);
878 873 while ((split_chunk = xfs_zone_gc_split_write(data, chunk)))
879 874 xfs_zone_gc_submit_write(data, split_chunk);
modified include/acpi/acpi_bus.h
@@ -202,8 +202,12 @@ struct acpi_device_dir {
202 202
203 203 /* Plug and Play */
204 204
205 + #define MAX_ACPI_DEVICE_NAME_LEN 40
206 + #define MAX_ACPI_CLASS_NAME_LEN 20
205 207 typedef char acpi_bus_id[8];
206 208 typedef u64 acpi_bus_address;
209 + typedef char acpi_device_name[MAX_ACPI_DEVICE_NAME_LEN];
210 + typedef char acpi_device_class[MAX_ACPI_CLASS_NAME_LEN];
207 211
208 212 struct acpi_hardware_id {
209 213 struct list_head list;
@@ -225,12 +229,16 @@ struct acpi_device_pnp {
225 229 acpi_bus_address bus_address; /* _ADR */
226 230 char *unique_id; /* _UID */
227 231 struct list_head ids; /* _HID and _CIDs */
232 + acpi_device_name device_name; /* Driver-determined */
233 + acpi_device_class device_class; /* " */
228 234 };
229 235
230 236 #define acpi_device_bid(d) ((d)->pnp.bus_id)
231 237 #define acpi_device_adr(d) ((d)->pnp.bus_address)
232 238 const char *acpi_device_hid(struct acpi_device *device);
233 239 #define acpi_device_uid(d) ((d)->pnp.unique_id)
240 + #define acpi_device_name(d) ((d)->pnp.device_name)
241 + #define acpi_device_class(d) ((d)->pnp.device_class)
234 242
235 243 /* Power Management */
236 244
@@ -570,9 +578,6 @@ int acpi_dev_for_each_child_reverse(struct acpi_device *adev,
570 578 * ------
571 579 */
572 580
573 - #define MAX_ACPI_CLASS_NAME_LEN 20
574 - typedef char acpi_device_class[MAX_ACPI_CLASS_NAME_LEN];
575 -
576 581 struct acpi_bus_event {
577 582 struct list_head node;
578 583 acpi_device_class device_class;
modified include/drm/drm_pagemap.h
@@ -2,7 +2,6 @@
2 2 #ifndef _DRM_PAGEMAP_H_
3 3 #define _DRM_PAGEMAP_H_
4 4
5 - #include <linux/bits.h>
6 5 #include <linux/dma-direction.h>
7 6 #include <linux/hmm.h>
8 7 #include <linux/memremap.h>
@@ -340,9 +339,6 @@ struct drm_pagemap_migrate_details {
340 339
341 340 #if IS_ENABLED(CONFIG_ZONE_DEVICE)
342 341
343 - #define DRM_PAGEMAP_ZDD_FLAG_MIGRATED BIT(0)
344 - #define DRM_PAGEMAP_ZDD_FLAG_MASK DRM_PAGEMAP_ZDD_FLAG_MIGRATED
345 -
346 342 int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation,
347 343 struct mm_struct *mm,
348 344 unsigned long start, unsigned long end,
@@ -377,9 +373,7 @@ static inline struct drm_pagemap_zdd *drm_pagemap_page_zone_device_data(struct p
377 373 {
378 374 struct folio *folio = page_folio(page);
379 375
380 - return (struct drm_pagemap_zdd *)
381 - ((unsigned long)folio_zone_device_data(folio) &
382 - ~DRM_PAGEMAP_ZDD_FLAG_MASK);
376 + return folio_zone_device_data(folio);
383 377 }
384 378
385 379 #else
modified include/linux/bpf.h
@@ -894,7 +894,6 @@ enum bpf_arg_type {
894 894
895 895 ARG_PTR_TO_CTX, /* pointer to context */
896 896 ARG_ANYTHING, /* any (initialized) argument is ok */
897 - ARG_SCALAR, /* scalar argument */
898 897 ARG_PTR_TO_SPIN_LOCK, /* pointer to bpf_spin_lock */
899 898 ARG_PTR_TO_SOCK_COMMON, /* pointer to sock_common */
900 899 ARG_PTR_TO_SOCKET, /* pointer to bpf_sock (fullsock) */
@@ -4210,7 +4209,7 @@ static inline int bpf_map_check_op_flags(struct bpf_map *map, u64 flags, u64 all
4210 4209 return -EINVAL;
4211 4210
4212 4211 cpu = flags >> 32;
4213 - if ((flags & BPF_F_CPU) && (cpu >= nr_cpu_ids || !cpu_possible(cpu)))
4212 + if ((flags & BPF_F_CPU) && cpu >= num_possible_cpus())
4214 4213 return -ERANGE;
4215 4214 }
4216 4215
modified include/linux/bpf_verifier.h
@@ -706,8 +706,6 @@ struct bpf_insn_aux_data {
706 706 */
707 707 u32 calls_callback:1;
708 708 u32 indirect_target:1; /* if it is an indirect jump target */
709 - /* true if some jump or call instruction targets this instruction */
710 - u32 jump_target:1;
711 709 /*
712 710 * CFG strongly connected component this instruction belongs to,
713 711 * zero if it is a singleton SCC.
@@ -1144,16 +1142,6 @@ static inline void mark_jmp_point(struct bpf_verifier_env *env, int idx)
1144 1142 env->insn_aux_data[idx].jmp_point = true;
1145 1143 }
1146 1144
1147 - static inline void mark_jump_target(struct bpf_verifier_env *env, int idx)
1148 - {
1149 - env->insn_aux_data[idx].jump_target = true;
1150 - }
1151 -
1152 - static inline bool bpf_is_jump_target(struct bpf_verifier_env *env, int insn_idx)
1153 - {
1154 - return env->insn_aux_data[insn_idx].jump_target;
1155 - }
1156 -
1157 1145 static inline struct bpf_func_state *cur_func(struct bpf_verifier_env *env)
1158 1146 {
1159 1147 struct bpf_verifier_state *cur = env->cur_state;
@@ -1381,9 +1369,7 @@ static inline bool bpf_type_has_unsafe_modifiers(u32 type)
1381 1369
1382 1370 static inline bool type_is_ptr_alloc_obj(u32 type)
1383 1371 {
1384 - return base_type(type) == PTR_TO_BTF_ID &&
1385 - type_flag(type) & MEM_ALLOC &&
1386 - !(type_flag(type) & PTR_UNTRUSTED);
1372 + return base_type(type) == PTR_TO_BTF_ID && type_flag(type) & MEM_ALLOC;
1387 1373 }
1388 1374
1389 1375 static inline bool type_is_non_owning_ref(u32 type)
modified include/linux/capability.h
@@ -145,7 +145,6 @@ extern bool has_capability_noaudit(struct task_struct *t, int cap);
145 145 extern bool has_ns_capability_noaudit(struct task_struct *t,
146 146 struct user_namespace *ns, int cap);
147 147 extern bool capable(int cap);
148 - bool capable_noaudit(int cap);
149 148 extern bool ns_capable(struct user_namespace *ns, int cap);
150 149 extern bool ns_capable_noaudit(struct user_namespace *ns, int cap);
151 150 extern bool ns_capable_setid(struct user_namespace *ns, int cap);
@@ -168,10 +167,6 @@ static inline bool capable(int cap)
168 167 {
169 168 return true;
170 169 }
171 - static inline bool capable_noaudit(int cap)
172 - {
173 - return true;
174 - }
175 170 static inline bool ns_capable(struct user_namespace *ns, int cap)
176 171 {
177 172 return true;
modified include/linux/cgroup-defs.h
@@ -527,10 +527,7 @@ struct cgroup {
527 527
528 528 int nr_threaded_children; /* # of live threaded child cgroups */
529 529
530 - /*
531 - * Sequence number for cgroup.kill. Incremented with both cgroup_mutex
532 - * and css_set_lock held. Readers hold either one.
533 - */
530 + /* sequence number for cgroup.kill, serialized by css_set_lock. */
534 531 unsigned int kill_seq;
535 532
536 533 struct kernfs_node *kn; /* cgroup kernfs entry */
modified include/linux/device-id/ap.h
@@ -4,6 +4,7 @@
4 4
5 5 #ifdef __KERNEL__
6 6 #include <linux/types.h>
7 + typedef unsigned long kernel_ulong_t;
7 8 #endif
8 9
9 10 #define AP_DEVICE_ID_MATCH_CARD_TYPE 0x01
@@ -13,6 +14,7 @@
13 14 struct ap_device_id {
14 15 __u16 match_flags; /* which fields to match against */
15 16 __u8 dev_type; /* device type */
17 + kernel_ulong_t driver_info;
16 18 };
17 19
18 20 #endif /* ifndef LINUX_DEVICE_ID_AP_H */
modified include/linux/dma-buf.h
@@ -567,7 +567,6 @@ void dma_buf_unpin(struct dma_buf_attachment *attach);
567 567 struct dma_buf *dma_buf_export(const struct dma_buf_export_info *exp_info);
568 568
569 569 int dma_buf_fd(struct dma_buf *dmabuf, int flags);
570 - void dma_buf_fd_install(struct dma_buf *dmabuf, int fd);
571 570 struct dma_buf *dma_buf_get(int fd);
572 571 void dma_buf_put(struct dma_buf *dmabuf);
573 572
modified include/linux/dma-fence-array.h
@@ -28,6 +28,7 @@ struct dma_fence_array_cb {
28 28 /**
29 29 * struct dma_fence_array - fence to represent an array of fences
30 30 * @base: fence base class
31 + * @lock: spinlock for fence handling
31 32 * @num_fences: number of fences in the array
32 33 * @num_pending: fences in the array still pending
33 34 * @fences: array of the fences
modified include/linux/dma-fence-chain.h
@@ -20,6 +20,7 @@
20 20 * @prev: previous fence of the chain
21 21 * @prev_seqno: original previous seqno before garbage collection
22 22 * @fence: encapsulated fence
23 + * @lock: spinlock for fence handling
23 24 */
24 25 struct dma_fence_chain {
25 26 struct dma_fence base;
@@ -80,8 +81,9 @@ dma_fence_chain_contained(struct dma_fence *fence)
80 81 }
81 82
82 83 /**
83 - * dma_fence_chain_alloc - Returns a new &struct dma_fence_chain object or
84 - * %NULL on failure.
84 + * dma_fence_chain_alloc
85 + *
86 + * Returns a new struct dma_fence_chain object or NULL on failure.
85 87 *
86 88 * This specialized allocator has to be a macro for its allocations to be
87 89 * accounted separately (to have a separate alloc_tag). The typecast is
@@ -91,8 +93,7 @@ dma_fence_chain_contained(struct dma_fence *fence)
91 93 kmalloc_obj(struct dma_fence_chain)
92 94
93 95 /**
94 - * dma_fence_chain_free - Frees an allocated but not used
95 - * &struct dma_fence_chain object.
96 + * dma_fence_chain_free
96 97 * @chain: chain node to free
97 98 *
98 99 * Frees up an allocated but not used struct dma_fence_chain object. This
modified include/linux/edac.h
@@ -598,6 +598,9 @@ struct mem_ctl_info {
598 598 int op_state;
599 599
600 600 struct dentry *debugfs;
601 + u8 fake_inject_layer[EDAC_MAX_LAYERS];
602 + bool fake_inject_ue;
603 + u16 fake_inject_count;
601 604
602 605 /*
603 606 * Memory Controller hierarchy
modified include/linux/filter.h
@@ -1376,6 +1376,7 @@ bpf_jit_binary_alloc(unsigned int proglen, u8 **image_ptr,
1376 1376 void bpf_jit_binary_free(struct bpf_binary_header *hdr);
1377 1377 u64 bpf_jit_alloc_exec_limit(void);
1378 1378 void *bpf_jit_alloc_exec(unsigned long size);
1379 + void *bpf_jit_alloc_exec_rw(unsigned long size);
1379 1380 void bpf_jit_free_exec(void *addr);
1380 1381 void bpf_jit_free(struct bpf_prog *fp);
1381 1382 struct bpf_binary_header *
modified include/linux/ftrace.h
@@ -866,9 +866,8 @@ unsigned long ftrace_get_addr_new(struct dyn_ftrace *rec);
866 866 unsigned long ftrace_get_addr_curr(struct dyn_ftrace *rec);
867 867
868 868 extern ftrace_func_t ftrace_trace_function;
869 - struct trace_array;
870 869
871 - int ftrace_regex_open(struct trace_array *tr, struct ftrace_ops *ops, int flag,
870 + int ftrace_regex_open(struct ftrace_ops *ops, int flag,
872 871 struct inode *inode, struct file *file);
873 872 ssize_t ftrace_filter_write(struct file *file, const char __user *ubuf,
874 873 size_t cnt, loff_t *ppos);
@@ -1078,7 +1077,7 @@ static inline unsigned long ftrace_location(unsigned long ip)
1078 1077 * have them defined when ftrace is not enabled, but these
1079 1078 * functions may still be called. Use a macro instead of inline.
1080 1079 */
1081 - #define ftrace_regex_open(tr, ops, flag, inode, file) ({ -ENODEV; })
1080 + #define ftrace_regex_open(ops, flag, inod, file) ({ -ENODEV; })
1082 1081 #define ftrace_set_early_filter(ops, buf, enable) do { } while (0)
1083 1082 #define ftrace_set_filter_ip(ops, ip, remove, reset) ({ -ENODEV; })
1084 1083 #define ftrace_set_filter_ips(ops, ips, cnt, remove, reset) ({ -ENODEV; })
modified include/linux/igmp.h
@@ -57,21 +57,20 @@ struct ip_mc_socklist {
57 57 };
58 58
59 59 struct ip_sf_list {
60 - struct ip_sf_list __rcu *sf_next;
60 + struct ip_sf_list *sf_next;
61 61 unsigned long sf_count[2]; /* include/exclude counts */
62 62 __be32 sf_inaddr;
63 63 unsigned char sf_gsresp; /* include in g & s response? */
64 64 unsigned char sf_oldin; /* change state */
65 65 unsigned char sf_crcount; /* retrans. left to send */
66 - struct rcu_head rcu;
67 66 };
68 67
69 68 struct ip_mc_list {
70 69 struct in_device *interface;
71 70 __be32 multiaddr;
72 71 unsigned int sfmode;
73 - struct ip_sf_list __rcu *sources;
74 - struct ip_sf_list __rcu *tomb;
72 + struct ip_sf_list *sources;
73 + struct ip_sf_list *tomb;
75 74 unsigned long sfcount[2];
76 75 union {
77 76 struct ip_mc_list *next;
modified include/linux/interrupt_rc.h
@@ -20,8 +20,11 @@
20 20 /* Per-CPU interrupt disabling state for local_interrupt_{disable,enable}(). */
21 21 DECLARE_PER_CPU(unsigned long, local_interrupt_disable_state);
22 22
23 - static __always_inline void __local_interrupt_save_state(unsigned long flags)
23 + static __always_inline void __local_interrupt_disable(void)
24 24 {
25 + unsigned long flags;
26 +
27 + local_irq_save(flags);
25 28 raw_cpu_write(local_interrupt_disable_state, flags);
26 29 }
27 30
@@ -33,9 +36,9 @@ static __always_inline void __local_interrupt_enable(void)
33 36 }
34 37
35 38 #ifndef INSTANTIATE_EXPORTED_INTERRUPT_DISABLE
36 - static __always_inline void _local_interrupt_save_state(unsigned long flags)
39 + static __always_inline void _local_interrupt_disable(void)
37 40 {
38 - __local_interrupt_save_state(flags);
41 + __local_interrupt_disable();
39 42 }
40 43
41 44 static __always_inline void _local_interrupt_enable(void)
@@ -43,30 +46,27 @@ static __always_inline void _local_interrupt_enable(void)
43 46 __local_interrupt_enable();
44 47 }
45 48 #else
46 - extern void _local_interrupt_save_state(unsigned long flags);
49 + extern void _local_interrupt_disable(void);
47 50 extern void _local_interrupt_enable(void);
48 51 #endif
49 52
50 53 #else /* !MODULE */
51 - extern void _local_interrupt_save_state(unsigned long flags);
54 + extern void _local_interrupt_disable(void);
52 55 extern void _local_interrupt_enable(void);
53 56 #endif /* !MODULE */
54 57
55 - #define hardirq_disable_enter() __preempt_count_add_return(HARDIRQ_DISABLE_OFFSET)
56 - #define hardirq_disable_exit() __preempt_count_sub_return(HARDIRQ_DISABLE_OFFSET)
57 -
58 58 static inline void local_interrupt_disable(void)
59 59 {
60 60 int new_count;
61 - unsigned long flags;
62 61
63 62 WARN_ON_ONCE(in_nmi());
64 63
65 - local_irq_save(flags);
66 64 new_count = hardirq_disable_enter();
67 65
66 + /* Interrupts can happen here, but it's OK, see __irq_exit_rcu(). */
67 +
68 68 if ((new_count & HARDIRQ_DISABLE_MASK) == HARDIRQ_DISABLE_OFFSET)
69 - _local_interrupt_save_state(flags);
69 + _local_interrupt_disable();
70 70 }
71 71
72 72 static inline void local_interrupt_enable(void)
modified include/linux/irqdomain.h
@@ -752,6 +752,24 @@ static inline void msi_device_domain_free_wired(struct irq_domain *domain, unsig
752 752 }
753 753 #endif
754 754
755 + static inline struct irq_domain *irq_domain_add_linear(struct device_node *of_node,
756 + unsigned int size,
757 + const struct irq_domain_ops *ops,
758 + void *host_data)
759 + {
760 + struct irq_domain_info info = {
761 + .fwnode = of_fwnode_handle(of_node),
762 + .size = size,
763 + .hwirq_max = size,
764 + .ops = ops,
765 + .host_data = host_data,
766 + };
767 + struct irq_domain *d;
768 +
769 + d = irq_domain_instantiate(&info);
770 + return IS_ERR(d) ? NULL : d;
771 + }
772 +
755 773 #else /* CONFIG_IRQ_DOMAIN */
756 774 static inline void irq_dispose_mapping(unsigned int virq) { }
757 775 static inline struct irq_domain *irq_find_matching_fwnode(struct fwnode_handle *fwnode,
modified include/linux/kprobes.h
@@ -181,7 +181,6 @@ struct kprobe_blacklist_entry {
181 181 struct list_head list;
182 182 unsigned long start_addr;
183 183 unsigned long end_addr;
184 - struct rcu_head rcu;
185 184 };
186 185
187 186 #ifdef CONFIG_KPROBES
modified include/linux/nvme-tcp.h
@@ -77,7 +77,7 @@ struct nvme_tcp_hdr {
77 77 __le32 plen;
78 78 };
79 79
80 - /*
80 + /**
81 81 * struct nvme_tcp_icreq_pdu - nvme tcp initialize connection request pdu
82 82 *
83 83 * @hdr: pdu generic header
@@ -95,7 +95,7 @@ struct nvme_tcp_icreq_pdu {
95 95 __u8 rsvd2[112];
96 96 };
97 97
98 - /*
98 + /**
99 99 * struct nvme_tcp_icresp_pdu - nvme tcp initialize connection response pdu
100 100 *
101 101 * @hdr: pdu common header
@@ -113,13 +113,12 @@ struct nvme_tcp_icresp_pdu {
113 113 __u8 rsvd[112];
114 114 };
115 115
116 - /*
116 + /**
117 117 * struct nvme_tcp_term_pdu - nvme tcp terminate connection pdu
118 118 *
119 119 * @hdr: pdu common header
120 120 * @fes: fatal error status
121 - * @feil: fatal error information (low 16 bits)
122 - * @feih: fatal error information (high 16 bits)
121 + * @fei: fatal error information
123 122 */
124 123 struct nvme_tcp_term_pdu {
125 124 struct nvme_tcp_hdr hdr;
@@ -129,7 +128,7 @@ struct nvme_tcp_term_pdu {
129 128 __u8 rsvd[10];
130 129 };
131 130
132 - /*
131 + /**
133 132 * struct nvme_tcp_cmd_pdu - nvme tcp command capsule pdu
134 133 *
135 134 * @hdr: pdu common header
@@ -140,9 +139,10 @@ struct nvme_tcp_cmd_pdu {
140 139 struct nvme_command cmd;
141 140 };
142 141
143 - /*
142 + /**
144 143 * struct nvme_tcp_rsp_pdu - nvme tcp response capsule pdu
145 144 *
145 + * @hdr: pdu common header
146 146 * @hdr: nvme-tcp generic header
147 147 * @cqe: nvme completion queue entry
148 148 */
@@ -151,7 +151,7 @@ struct nvme_tcp_rsp_pdu {
151 151 struct nvme_completion cqe;
152 152 };
153 153
154 - /*
154 + /**
155 155 * struct nvme_tcp_r2t_pdu - nvme tcp ready-to-transfer pdu
156 156 *
157 157 * @hdr: pdu common header
@@ -169,7 +169,7 @@ struct nvme_tcp_r2t_pdu {
169 169 __u8 rsvd[4];
170 170 };
171 171
172 - /*
172 + /**
173 173 * struct nvme_tcp_data_pdu - nvme tcp data pdu
174 174 *
175 175 * @hdr: pdu common header
modified include/linux/preempt.h
@@ -168,6 +168,10 @@ static __always_inline unsigned char interrupt_context_level(void)
168 168 #define in_softirq() (softirq_count())
169 169 #define in_interrupt() (irq_count())
170 170
171 + #define hardirq_disable_count() ((preempt_count() & HARDIRQ_DISABLE_MASK) >> HARDIRQ_DISABLE_SHIFT)
172 + #define hardirq_disable_enter() __preempt_count_add_return(HARDIRQ_DISABLE_OFFSET)
173 + #define hardirq_disable_exit() __preempt_count_sub_return(HARDIRQ_DISABLE_OFFSET)
174 +
171 175 /*
172 176 * The preempt_count offset after preempt_disable();
173 177 */
modified include/linux/ring_buffer.h
@@ -218,15 +218,14 @@ bool ring_buffer_time_stamp_abs(struct trace_buffer *buffer);
218 218 size_t ring_buffer_nr_dirty_pages(struct trace_buffer *buffer, int cpu);
219 219
220 220 struct buffer_data_read_page;
221 - int ring_buffer_alloc_read_page(struct trace_buffer *buffer, int cpu,
222 - struct buffer_data_read_page **rpage);
221 + struct buffer_data_read_page *
222 + ring_buffer_alloc_read_page(struct trace_buffer *buffer, int cpu);
223 223 void ring_buffer_free_read_page(struct trace_buffer *buffer, int cpu,
224 224 struct buffer_data_read_page *page);
225 225 int ring_buffer_read_page(struct trace_buffer *buffer,
226 226 struct buffer_data_read_page *data_page,
227 227 size_t len, int cpu, int full);
228 228 void *ring_buffer_read_page_data(struct buffer_data_read_page *page);
229 - unsigned int ring_buffer_read_page_size(struct buffer_data_read_page *rpage);
230 229
231 230 struct trace_seq;
232 231
modified include/linux/sched/rt.h
@@ -52,10 +52,8 @@ static inline bool rt_or_dl_task_policy(struct task_struct *tsk)
52 52
53 53 #ifdef CONFIG_RT_MUTEXES
54 54 extern void rt_mutex_pre_schedule(void);
55 - extern void rt_mutex_futex_pre_schedule(void);
56 55 extern void rt_mutex_schedule(void);
57 56 extern void rt_mutex_post_schedule(void);
58 - extern void rt_mutex_futex_post_schedule(void);
59 57
60 58 /*
61 59 * Must hold either p->pi_lock or task_rq(p)->lock.
modified include/linux/sched/user.h
@@ -25,8 +25,7 @@ struct user_struct {
25 25
26 26 #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \
27 27 defined(CONFIG_NET) || defined(CONFIG_IO_URING) || \
28 - defined(CONFIG_VFIO_PCI_ZDEV_KVM) || IS_ENABLED(CONFIG_IOMMUFD) || \
29 - defined(CONFIG_SECRETMEM)
28 + defined(CONFIG_VFIO_PCI_ZDEV_KVM) || IS_ENABLED(CONFIG_IOMMUFD)
30 29 atomic_long_t locked_vm;
31 30 #endif
32 31 #ifdef CONFIG_WATCH_QUEUE
modified include/linux/skbuff.h
@@ -3082,11 +3082,6 @@ static inline bool skb_transport_header_was_set(const struct sk_buff *skb)
3082 3082 return skb->transport_header != (typeof(skb->transport_header))~0U;
3083 3083 }
3084 3084
3085 - static inline void skb_unset_transport_header(struct sk_buff *skb)
3086 - {
3087 - skb->transport_header = (typeof(skb->transport_header))~0U;
3088 - }
3089 -
3090 3085 static inline unsigned char *skb_transport_header(const struct sk_buff *skb)
3091 3086 {
3092 3087 DEBUG_NET_WARN_ON_ONCE(!skb_transport_header_was_set(skb));
modified include/net/af_vsock.h
@@ -229,9 +229,6 @@ struct sock *vsock_find_bound_socket_net(struct sockaddr_vm *addr,
229 229 struct sock *vsock_find_connected_socket_net(struct sockaddr_vm *src,
230 230 struct sockaddr_vm *dst,
231 231 struct net *net);
232 - bool vsock_check_source(const struct vsock_sock *vsk,
233 - const struct vsock_transport *transport,
234 - const struct sockaddr_vm *src);
235 232 void vsock_remove_sock(struct vsock_sock *vsk);
236 233 void vsock_for_each_connected_socket(struct vsock_transport *transport,
237 234 void (*fn)(struct sock *sk));
modified include/net/if_inet6.h
@@ -88,6 +88,8 @@ struct ip6_sf_socklist {
88 88 struct in6_addr sl_addr[] __counted_by(sl_max);
89 89 };
90 90
91 + #define IP6_SFBLOCK 10 /* allocate this many at once */
92 +
91 93 struct ipv6_mc_socklist {
92 94 struct in6_addr addr;
93 95 int ifindex;
modified include/net/ip.h
@@ -704,8 +704,7 @@ static inline void ip_ipgre_mc_map(__be32 naddr, const unsigned char *broadcast,
704 704
705 705 static __inline__ void inet_reset_saddr(struct sock *sk)
706 706 {
707 - inet_sk(sk)->inet_saddr = 0;
708 - WRITE_ONCE(inet_sk(sk)->inet_rcv_saddr, 0);
707 + inet_sk(sk)->inet_rcv_saddr = inet_sk(sk)->inet_saddr = 0;
709 708 #if IS_ENABLED(CONFIG_IPV6)
710 709 if (sk->sk_family == PF_INET6) {
711 710 struct ipv6_pinfo *np = inet6_sk(sk);
modified include/net/tcp.h
@@ -765,7 +765,8 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue,
765 765 void tcp_send_probe0(struct sock *);
766 766 int tcp_write_wakeup(struct sock *, int mib);
767 767 void tcp_send_fin(struct sock *sk);
768 - void tcp_send_active_reset(struct sock *sk, enum sk_rst_reason reason);
768 + void tcp_send_active_reset(struct sock *sk, gfp_t priority,
769 + enum sk_rst_reason reason);
769 770 int tcp_send_synack(struct sock *);
770 771 void tcp_push_one(struct sock *, unsigned int mss_now);
771 772 void __tcp_send_ack(struct sock *sk, u32 rcv_nxt, u16 flags);
modified include/trace/events/icmp.h
@@ -27,20 +27,17 @@ TRACE_EVENT(icmp_send,
27 27
28 28 TP_fast_assign(
29 29 struct iphdr *iph = ip_hdr(skb);
30 - struct udphdr _uh, *uh = NULL;
30 + struct udphdr *uh = udp_hdr(skb);
31 + int proto_4 = iph->protocol;
31 32 __be32 *p32;
32 33
33 34 __entry->skbaddr = skb;
34 35 __entry->type = type;
35 36 __entry->code = code;
36 37
37 - if (iph->protocol == IPPROTO_UDP)
38 - uh = skb_header_pointer(skb,
39 - skb_network_offset(skb) +
40 - (iph->ihl << 2),
41 - sizeof(_uh), &_uh);
42 -
43 - if (!uh) {
38 + if (proto_4 != IPPROTO_UDP || (u8 *)uh < skb->head ||
39 + (u8 *)uh + sizeof(struct udphdr)
40 + > skb_tail_pointer(skb)) {
44 41 __entry->sport = 0;
45 42 __entry->dport = 0;
46 43 __entry->ulen = 0;
modified include/uapi/drm/amdgpu_drm.h
@@ -1512,7 +1512,6 @@ struct drm_amdgpu_info_device {
1512 1512 __u64 high_va_max;
1513 1513 /* gfx10 pa_sc_tile_steering_override */
1514 1514 __u32 pa_sc_tile_steering_override;
1515 - __u32 pad;
1516 1515 /* disabled TCCs */
1517 1516 __u64 tcc_disabled_mask;
1518 1517 __u64 min_engine_clock;
@@ -1537,6 +1536,7 @@ struct drm_amdgpu_info_device {
1537 1536 __u32 csa_alignment;
1538 1537 /* Userq IP mask (1 << AMDGPU_HW_IP_*) */
1539 1538 __u32 userq_ip_mask;
1539 + __u32 pad;
1540 1540 };
1541 1541
1542 1542 struct drm_amdgpu_info_hw_ip {
modified include/uapi/linux/magic.h
@@ -8,7 +8,6 @@
8 8 #define AUTOFS_SUPER_MAGIC 0x0187
9 9 #define CEPH_SUPER_MAGIC 0x00c36400
10 10 #define CODA_SUPER_MAGIC 0x73757245
11 - #define CONFIGFS_MAGIC 0x62656570 /* some random number */
12 11 #define CRAMFS_MAGIC 0x28cd3d45 /* some random number */
13 12 #define CRAMFS_MAGIC_WEND 0x453dcd28 /* magic number with the wrong endianess */
14 13 #define DEBUGFS_MAGIC 0x64626720
modified init/initramfs_test.c
@@ -514,7 +514,7 @@ static void __init initramfs_test_hdr_hex(struct kunit *test)
514 514 char fdata[] = "this file data will not be unpacked";
515 515 struct initramfs_test_bufs {
516 516 char cpio_src[(CPIO_HDRLEN + PATH_MAX + 3 + sizeof(fdata)) * 2];
517 - } *tbufs = kzalloc_obj(struct initramfs_test_bufs);
517 + } *tbufs = kzalloc(sizeof(struct initramfs_test_bufs), GFP_KERNEL);
518 518 struct initramfs_test_cpio c[] = { {
519 519 .magic = "070701",
520 520 .ino = 1,
modified io_uring/napi.c
@@ -58,7 +58,7 @@ int __io_napi_add_id(struct io_ring_ctx *ctx, unsigned int napi_id,
58 58 }
59 59 }
60 60
61 - e = kmalloc_obj(*e, GFP_NOWAIT);
61 + e = kmalloc(sizeof(*e), GFP_NOWAIT);
62 62 if (!e)
63 63 return -ENOMEM;
64 64
modified io_uring/zcrx.c
@@ -483,8 +483,8 @@ static int io_zcrx_append_area(struct io_zcrx_ifq *ifq,
483 483 old_areas = ifq->areas;
484 484 old_nr = ifq->nr_areas;
485 485
486 - areas = kmalloc_objs(areas[0], old_nr + 1,
487 - GFP_KERNEL_ACCOUNT | __GFP_ZERO);
486 + areas = kmalloc_array(old_nr + 1, sizeof(areas[0]),
487 + GFP_KERNEL_ACCOUNT | __GFP_ZERO);
488 488 if (!areas)
489 489 return -ENOMEM;
490 490 if (old_areas)
modified kernel/bpf/arraymap.c
@@ -436,7 +436,7 @@ int bpf_percpu_array_update(struct bpf_map *map, void *key, void *value,
436 436 void __percpu *pptr;
437 437 void *ptr, *val;
438 438 u32 size;
439 - int cpu, off = 0;
439 + int cpu;
440 440
441 441 if (unlikely((map_flags & BPF_F_LOCK) || (u32)map_flags > BPF_F_ALL_CPUS))
442 442 /* unknown flags */
@@ -468,10 +468,9 @@ int bpf_percpu_array_update(struct bpf_map *map, void *key, void *value,
468 468 }
469 469 for_each_possible_cpu(cpu) {
470 470 ptr = per_cpu_ptr(pptr, cpu);
471 - val = (map_flags & BPF_F_ALL_CPUS) ? value : value + off;
471 + val = (map_flags & BPF_F_ALL_CPUS) ? value : value + size * cpu;
472 472 copy_map_value(map, ptr, val);
473 473 bpf_obj_cancel_fields(map, ptr);
474 - off += size;
475 474 }
476 475 unlock:
477 476 rcu_read_unlock();
modified kernel/bpf/backtrack.c
@@ -520,34 +520,37 @@ static int backtrack_insn(struct bpf_verifier_env *env, int idx, int subseq_idx,
520 520 return -EFAULT;
521 521 }
522 522 } else if (opcode == BPF_EXIT) {
523 - bool from_subprog_call, r0_precise;
524 -
525 - /* BPF_EXIT in subprog or callback always returns
526 - * right after the call instruction, so by checking
527 - * whether the instruction at subseq_idx-1 is subprog
528 - * call or not we can distinguish actual exit from
529 - * *subprog* from exit from *callback*. In the former
530 - * case, we need to propagate r0 precision, if
531 - * necessary. In the former we never do that.
532 - */
533 - from_subprog_call = subseq_idx - 1 >= 0 &&
534 - bpf_pseudo_call(&env->prog->insnsi[subseq_idx - 1]);
535 -
536 - r0_precise = from_subprog_call && bt_is_reg_set(bt, BPF_REG_0);
523 + bool r0_precise;
537 524
538 525 /* Backtracking to a nested function call, 'idx' is a part of
539 526 * the inner frame 'subseq_idx' is a part of the outer frame.
540 527 * In case of a regular function call, instructions giving
541 528 * precision to registers R1-R5 should have been found already.
542 - * In case of a callback from bpf_loop(), R{1,4} in the calling
543 - * frame would be set as precise and that is correct.
529 + * In case of a callback, it is ok to have R1-R5 marked for
530 + * backtracking, as these registers are set by the function
531 + * invoking callback.
544 532 */
545 - if (from_subprog_call && (bt_reg_mask(bt) & BPF_REGMASK_ARGS)) {
533 + if (subseq_idx >= 0 && bpf_calls_callback(env, subseq_idx))
534 + for (i = BPF_REG_1; i <= BPF_REG_5; i++)
535 + bt_clear_reg(bt, i);
536 + if (bt_reg_mask(bt) & BPF_REGMASK_ARGS) {
546 537 verifier_bug(env, "backtracking exit unexpected regs %x",
547 538 bt_reg_mask(bt));
548 539 return -EFAULT;
549 540 }
550 541
542 + /* BPF_EXIT in subprog or callback always returns
543 + * right after the call instruction, so by checking
544 + * whether the instruction at subseq_idx-1 is subprog
545 + * call or not we can distinguish actual exit from
546 + * *subprog* from exit from *callback*. In the former
547 + * case, we need to propagate r0 precision, if
548 + * necessary. In the former we never do that.
549 + */
550 + r0_precise = subseq_idx - 1 >= 0 &&
551 + bpf_pseudo_call(&env->prog->insnsi[subseq_idx - 1]) &&
552 + bt_is_reg_set(bt, BPF_REG_0);
553 +
551 554 bt_clear_reg(bt, BPF_REG_0);
552 555 if (bt_subprog_enter(bt))
553 556 return -EFAULT;
@@ -579,29 +582,16 @@ static int backtrack_insn(struct bpf_verifier_env *env, int idx, int subseq_idx,
579 582 */
580 583 }
581 584 } else if (class == BPF_LD) {
585 + if (!bt_is_reg_set(bt, dreg))
586 + return 0;
587 + bt_clear_reg(bt, dreg);
582 588 /* It's ld_imm64 or ld_abs or ld_ind.
583 589 * For ld_imm64 no further tracking of precision
584 590 * into parent is necessary
585 591 */
586 - if (mode == BPF_IMM) {
587 - bt_clear_reg(bt, dreg);
588 - return 0;
589 - }
590 - /*
591 - * BPF_{IND,ABS} are modelled as two branches:
592 - * - fallthrough;
593 - * - implicit subprogram exit.
594 - * It is necessary to switch current frame if
595 - * implicit subprogram exit branch is backtracked.
596 - */
597 - if (mode == BPF_IND || mode == BPF_ABS) {
598 - if (bt_is_reg_set(bt, dreg))
599 - return -ENOTSUPP;
600 - if (subseq_idx != idx + 1)
601 - if (bt_subprog_enter(bt))
602 - return -EFAULT;
603 - return 0;
604 - }
592 + if (mode == BPF_IND || mode == BPF_ABS)
593 + /* to be analyzed */
594 + return -ENOTSUPP;
605 595 }
606 596 /* Propagate precision marks to linked registers, to account for
607 597 * registers marked as precise in this function.
modified kernel/bpf/bpf_iter.c
@@ -754,7 +754,7 @@ const struct bpf_func_proto bpf_loop_proto = {
754 754 .func = bpf_loop,
755 755 .gpl_only = false,
756 756 .ret_type = RET_INTEGER,
757 - .arg1_type = ARG_SCALAR,
757 + .arg1_type = ARG_ANYTHING,
758 758 .arg2_type = ARG_PTR_TO_FUNC,
759 759 .arg3_type = ARG_PTR_TO_STACK_OR_NULL,
760 760 .arg4_type = ARG_ANYTHING,
modified kernel/bpf/btf.c
@@ -2911,29 +2911,14 @@ static void btf_modifier_show(const struct btf *btf,
2911 2911 else
2912 2912 t = btf_type_skip_modifiers(btf, type_id, NULL);
2913 2913
2914 - /*
2915 - * A modifier can resolve to void, which has no show op; print a
2916 - * placeholder rather than dereferencing NULL.
2917 - */
2918 - if (!btf_type_ops(t))
2919 - btf_df_show(btf, t, type_id, data, bits_offset, show);
2920 - else
2921 - btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show);
2914 + btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show);
2922 2915 }
2923 2916
2924 2917 static void btf_var_show(const struct btf *btf, const struct btf_type *t,
2925 2918 u32 type_id, void *data, u8 bits_offset,
2926 2919 struct btf_show *show)
2927 2920 {
2928 - /*
2929 - * btf_type_id_resolve() dereferences btf->resolved_ids, which is NULL
2930 - * for a base BTF (e.g. the vmlinux BTF that bpf_snprintf_btf() uses).
2931 - * Resolve the var's type directly in that case.
2932 - */
2933 - if (btf->resolved_ids)
2934 - t = btf_type_id_resolve(btf, &type_id);
2935 - else
2936 - t = btf_type_skip_modifiers(btf, t->type, &type_id);
2921 + t = btf_type_id_resolve(btf, &type_id);
2937 2922
2938 2923 btf_type_ops(t)->show(btf, t, type_id, data, bits_offset, show);
2939 2924 }
@@ -6672,10 +6657,6 @@ struct bpf_raw_tp_null_args {
6672 6657 static const struct bpf_raw_tp_null_args raw_tp_null_args[] = {
6673 6658 /* sched */
6674 6659 { "sched_pi_setprio", 0x10 },
6675 - /*
6676 - * do_wait() passes NULL for wait4(-1) and waitid(P_ALL).
6677 - */
6678 - { "sched_process_wait", 0x1 },
6679 6660 /* ... from sched_numa_pair_template event class */
6680 6661 { "sched_stick_numa", 0x100 },
6681 6662 { "sched_swap_numa", 0x100 },
@@ -6736,9 +6717,6 @@ static const struct bpf_raw_tp_null_args raw_tp_null_args[] = {
6736 6717 { "rxrpc_resend", 0x10 },
6737 6718 { "rxrpc_tq", 0x10 },
6738 6719 { "rxrpc_client", 0x1 },
6739 - /* signal */
6740 - { "signal_generate", 0x20 },
6741 - { "signal_deliver", 0x20 },
6742 6720 /* skb */
6743 6721 {"kfree_skb", 0x1000},
6744 6722 /* sunrpc */
@@ -8749,7 +8727,6 @@ BPF_CALL_4(bpf_btf_find_by_name_kind, char *, name, int, name_sz, u32, kind, int
8749 8727 const struct bpf_func_proto bpf_btf_find_by_name_kind_proto = {
8750 8728 .func = bpf_btf_find_by_name_kind,
8751 8729 .gpl_only = false,
8752 - .might_sleep = true,
8753 8730 .ret_type = RET_INTEGER,
8754 8731 .arg1_type = ARG_PTR_TO_MEM | MEM_RDONLY,
8755 8732 .arg2_type = ARG_MEM_SIZE,
modified kernel/bpf/cfg.c
@@ -125,7 +125,6 @@ static int push_insn(int t, int w, int e, struct bpf_verifier_env *env)
125 125 /* mark branch target for state pruning */
126 126 mark_prune_point(env, w);
127 127 mark_jmp_point(env, w);
128 - mark_jump_target(env, w);
129 128 }
130 129
131 130 if (insn_state[w] == 0) {
@@ -404,7 +403,6 @@ static int visit_gotox_insn(int t, struct bpf_verifier_env *env)
404 403 }
405 404
406 405 mark_jmp_point(env, w);
407 - mark_jump_target(env, w);
408 406
409 407 /* EXPLORED || DISCOVERED */
410 408 if (insn_state[w])
@@ -566,7 +564,6 @@ static int visit_insn(int t, struct bpf_verifier_env *env)
566 564
567 565 mark_prune_point(env, t + off + 1);
568 566 mark_jmp_point(env, t + off + 1);
569 - mark_jump_target(env, t + off + 1);
570 567
571 568 return ret;
572 569
modified kernel/bpf/core.c
@@ -1128,6 +1128,11 @@ void *bpf_jit_alloc_exec(unsigned long size)
1128 1128 return execmem_alloc(EXECMEM_BPF, size);
1129 1129 }
1130 1130
1131 + void *bpf_jit_alloc_exec_rw(unsigned long size)
1132 + {
1133 + return execmem_alloc_rw(EXECMEM_BPF, size);
1134 + }
1135 +
1131 1136 void bpf_jit_free_exec(void *addr)
1132 1137 {
1133 1138 execmem_free(addr);
modified kernel/bpf/diagnostics.c
@@ -266,7 +266,7 @@ static char *diag_fmt_alloc(struct bpf_verifier_env *env, size_t size)
266 266 }
267 267
268 268 capacity = max_t(size_t, BPF_DIAG_FMT_CHUNK_SIZE, size);
269 - chunk = kmalloc_flex(*chunk, data, capacity, GFP_KERNEL_ACCOUNT);
269 + chunk = kmalloc(struct_size(chunk, data, capacity), GFP_KERNEL_ACCOUNT);
270 270 if (!chunk)
271 271 return NULL;
272 272
modified kernel/bpf/disasm.c
@@ -7,9 +7,6 @@
7 7
8 8 #include "disasm.h"
9 9
10 - /* Only defined by the non-UAPI linux/filter.h, which this file cannot use. */
11 - #define BPF_PROBE_ATOMIC 0xe0
12 -
13 10 #define __BPF_FUNC_STR_FN(x) [BPF_FUNC_ ## x] = __stringify(bpf_ ## x)
14 11 static const char * const func_id_str[] = {
15 12 __BPF_FUNC_MAPPER(__BPF_FUNC_STR_FN)
@@ -229,57 +226,57 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs,
229 226 insn->imm);
230 227 }
231 228 } else if (class == BPF_STX) {
232 - const char *probe_pfx = BPF_MODE(insn->code) == BPF_PROBE_ATOMIC ? "probe " : "";
233 - bool atomic = BPF_MODE(insn->code) == BPF_ATOMIC ||
234 - BPF_MODE(insn->code) == BPF_PROBE_ATOMIC;
235 -
236 229 if (BPF_MODE(insn->code) == BPF_MEM)
237 230 verbose(cbs->private_data, "(%02x) *(%s *)(r%d %+d) = r%d",
238 231 insn->code,
239 232 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
240 233 insn->dst_reg,
241 234 insn->off, insn->src_reg);
242 - else if (atomic &&
235 + else if (BPF_MODE(insn->code) == BPF_ATOMIC &&
243 236 (insn->imm == BPF_ADD || insn->imm == BPF_AND ||
244 237 insn->imm == BPF_OR || insn->imm == BPF_XOR)) {
245 - verbose(cbs->private_data, "(%02x) %slock *(%s *)(r%d %+d) %s r%d",
246 - insn->code, probe_pfx,
238 + verbose(cbs->private_data, "(%02x) lock *(%s *)(r%d %+d) %s r%d",
239 + insn->code,
247 240 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
248 241 insn->dst_reg, insn->off,
249 242 bpf_alu_string[BPF_OP(insn->imm) >> 4],
250 243 insn->src_reg);
251 - } else if (atomic &&
244 + } else if (BPF_MODE(insn->code) == BPF_ATOMIC &&
252 245 (insn->imm == (BPF_ADD | BPF_FETCH) ||
253 246 insn->imm == (BPF_AND | BPF_FETCH) ||
254 247 insn->imm == (BPF_OR | BPF_FETCH) ||
255 248 insn->imm == (BPF_XOR | BPF_FETCH))) {
256 - verbose(cbs->private_data, "(%02x) %sr%d = atomic%s_fetch_%s((%s *)(r%d %+d), r%d)",
257 - insn->code, probe_pfx, insn->src_reg,
249 + verbose(cbs->private_data, "(%02x) r%d = atomic%s_fetch_%s((%s *)(r%d %+d), r%d)",
250 + insn->code, insn->src_reg,
258 251 BPF_SIZE(insn->code) == BPF_DW ? "64" : "",
259 252 bpf_atomic_alu_string[BPF_OP(insn->imm) >> 4],
260 253 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
261 254 insn->dst_reg, insn->off, insn->src_reg);
262 - } else if (atomic && insn->imm == BPF_CMPXCHG) {
263 - verbose(cbs->private_data, "(%02x) %sr0 = atomic%s_cmpxchg((%s *)(r%d %+d), r0, r%d)",
264 - insn->code, probe_pfx,
255 + } else if (BPF_MODE(insn->code) == BPF_ATOMIC &&
256 + insn->imm == BPF_CMPXCHG) {
257 + verbose(cbs->private_data, "(%02x) r0 = atomic%s_cmpxchg((%s *)(r%d %+d), r0, r%d)",
258 + insn->code,
265 259 BPF_SIZE(insn->code) == BPF_DW ? "64" : "",
266 260 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
267 261 insn->dst_reg, insn->off,
268 262 insn->src_reg);
269 - } else if (atomic && insn->imm == BPF_XCHG) {
270 - verbose(cbs->private_data, "(%02x) %sr%d = atomic%s_xchg((%s *)(r%d %+d), r%d)",
271 - insn->code, probe_pfx, insn->src_reg,
263 + } else if (BPF_MODE(insn->code) == BPF_ATOMIC &&
264 + insn->imm == BPF_XCHG) {
265 + verbose(cbs->private_data, "(%02x) r%d = atomic%s_xchg((%s *)(r%d %+d), r%d)",
266 + insn->code, insn->src_reg,
272 267 BPF_SIZE(insn->code) == BPF_DW ? "64" : "",
273 268 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
274 269 insn->dst_reg, insn->off, insn->src_reg);
275 - } else if (atomic && insn->imm == BPF_LOAD_ACQ) {
276 - verbose(cbs->private_data, "(%02x) %sr%d = load_acquire((%s *)(r%d %+d))",
277 - insn->code, probe_pfx, insn->dst_reg,
270 + } else if (BPF_MODE(insn->code) == BPF_ATOMIC &&
271 + insn->imm == BPF_LOAD_ACQ) {
272 + verbose(cbs->private_data, "(%02x) r%d = load_acquire((%s *)(r%d %+d))",
273 + insn->code, insn->dst_reg,
278 274 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
279 275 insn->src_reg, insn->off);
280 - } else if (atomic && insn->imm == BPF_STORE_REL) {
281 - verbose(cbs->private_data, "(%02x) %sstore_release((%s *)(r%d %+d), r%d)",
282 - insn->code, probe_pfx,
276 + } else if (BPF_MODE(insn->code) == BPF_ATOMIC &&
277 + insn->imm == BPF_STORE_REL) {
278 + verbose(cbs->private_data, "(%02x) store_release((%s *)(r%d %+d), r%d)",
279 + insn->code,
283 280 bpf_ldst_string[BPF_SIZE(insn->code) >> 3],
284 281 insn->dst_reg, insn->off, insn->src_reg);
285 282 } else {
@@ -298,8 +295,7 @@ void print_bpf_insn(const struct bpf_insn_cbs *cbs,
298 295 verbose(cbs->private_data, "BUG_st_%02x", insn->code);
299 296 }
300 297 } else if (class == BPF_LDX) {
301 - if ((BPF_MODE(insn->code) != BPF_MEM && BPF_MODE(insn->code) != BPF_MEMSX) ||
302 - (BPF_MODE(insn->code) == BPF_MEMSX && BPF_SIZE(insn->code) == BPF_DW)) {
298 + if (BPF_MODE(insn->code) != BPF_MEM && BPF_MODE(insn->code) != BPF_MEMSX) {
303 299 verbose(cbs->private_data, "BUG_ldx_%02x", insn->code);
304 300 return;
305 301 }
modified kernel/bpf/fixups.c
@@ -13,15 +13,10 @@
13 13
14 14 #define verbose(env, fmt, args...) bpf_verifier_log_write(env, fmt, ##args)
15 15
16 - /*
17 - * Matches BPF_PROBE_ATOMIC too: bpf_convert_ctx_accesses() rewrites arena
18 - * atomics before bpf_opt_subreg_zext_lo32_rnd_hi32() runs.
19 - */
20 16 static bool is_cmpxchg_insn(const struct bpf_insn *insn)
21 17 {
22 18 return BPF_CLASS(insn->code) == BPF_STX &&
23 - (BPF_MODE(insn->code) == BPF_ATOMIC ||
24 - BPF_MODE(insn->code) == BPF_PROBE_ATOMIC) &&
19 + BPF_MODE(insn->code) == BPF_ATOMIC &&
25 20 insn->imm == BPF_CMPXCHG;
26 21 }
27 22
modified kernel/bpf/hashtab.c
@@ -511,7 +511,7 @@ static int bpf_ma_set_dtor(struct bpf_map *map, struct bpf_mem_alloc *ma,
511 511 if (IS_ERR_OR_NULL(map->record))
512 512 return 0;
513 513
514 - hrec = kzalloc_obj(*hrec);
514 + hrec = kzalloc(sizeof(*hrec), GFP_KERNEL);
515 515 if (!hrec)
516 516 return -ENOMEM;
517 517 hrec->key_size = map->key_size;
@@ -530,9 +530,6 @@ static int htab_map_check_btf(struct bpf_map *map, const struct btf *btf,
530 530 {
531 531 struct bpf_htab *htab = container_of(map, struct bpf_htab, map);
532 532
533 - if (btf_type_is_void(key_type))
534 - return -EINVAL;
535 -
536 533 if (htab_is_prealloc(htab))
537 534 return 0;
538 535 /*
@@ -1028,7 +1025,7 @@ static void pcpu_copy_value(struct bpf_htab *htab, void __percpu *pptr,
1028 1025 } else {
1029 1026 u32 size = round_up(htab->map.value_size, 8);
1030 1027 void *val;
1031 - int cpu, off = 0;
1028 + int cpu;
1032 1029
1033 1030 if (map_flags & BPF_F_CPU) {
1034 1031 cpu = map_flags >> 32;
@@ -1040,10 +1037,9 @@ static void pcpu_copy_value(struct bpf_htab *htab, void __percpu *pptr,
1040 1037
1041 1038 for_each_possible_cpu(cpu) {
1042 1039 ptr = per_cpu_ptr(pptr, cpu);
1043 - val = (map_flags & BPF_F_ALL_CPUS) ? value : value + off;
1040 + val = (map_flags & BPF_F_ALL_CPUS) ? value : value + size * cpu;
1044 1041 copy_map_value(&htab->map, ptr, val);
1045 1042 bpf_obj_cancel_fields(&htab->map, ptr);
1046 - off += size;
1047 1043 }
1048 1044 }
1049 1045 }
@@ -2868,6 +2864,16 @@ static int rhtab_map_alloc_check(union bpf_attr *attr)
2868 2864 return htab_map_alloc_check(attr);
2869 2865 }
2870 2866
2867 + static void rhtab_check_and_free_fields(struct bpf_rhtab *rhtab,
2868 + struct rhtab_elem *elem)
2869 + {
2870 + if (IS_ERR_OR_NULL(rhtab->map.record))
2871 + return;
2872 +
2873 + bpf_obj_free_fields(rhtab->map.record,
2874 + rhtab_elem_value(elem, rhtab->map.key_size));
2875 + }
2876 +
2871 2877 static void rhtab_mem_dtor(void *obj, void *ctx)
2872 2878 {
2873 2879 struct htab_btf_record *hrec = ctx;
@@ -2957,8 +2963,8 @@ static int rhtab_delete_elem(struct bpf_rhtab *rhtab, struct rhtab_elem *elem, v
2957 2963 rhtab_read_elem_value(&rhtab->map, copy, elem, flags);
2958 2964 check_and_init_map_value(&rhtab->map, copy);
2959 2965 }
2960 - bpf_obj_cancel_fields(&rhtab->map,
2961 - rhtab_elem_value(elem, rhtab->map.key_size));
2966 + /* Release internal structs: kptr, bpf_timer, task_work, wq */
2967 + rhtab_check_and_free_fields(rhtab, elem);
2962 2968 bpf_mem_cache_free_rcu(&rhtab->ma, elem);
2963 2969 return 0;
2964 2970 }
@@ -2999,6 +3005,7 @@ static int rhtab_map_lookup_and_delete_elem(struct bpf_map *map, void *key, void
2999 3005 static long rhtab_map_update_existing(struct bpf_map *map, struct rhtab_elem *elem, void *value,
3000 3006 u64 map_flags)
3001 3007 {
3008 + struct bpf_rhtab *rhtab = container_of(map, struct bpf_rhtab, map);
3002 3009 void *old_val = rhtab_elem_value(elem, map->key_size);
3003 3010
3004 3011 if (map_flags & BPF_NOEXIST)
@@ -3018,7 +3025,7 @@ static long rhtab_map_update_existing(struct bpf_map *map, struct rhtab_elem *el
3018 3025 * kptrs/etc. still sit in the slot. Cancel them after the copy
3019 3026 * to match arraymap's update semantics.
3020 3027 */
3021 - bpf_obj_cancel_fields(map, old_val);
3028 + rhtab_check_and_free_fields(rhtab, elem);
3022 3029 return 0;
3023 3030 }
3024 3031
@@ -3059,6 +3066,7 @@ static long rhtab_map_update_elem(struct bpf_map *map, void *key, void *value, u
3059 3066
3060 3067 memcpy(elem->data, key, map->key_size);
3061 3068 copy_map_value(map, rhtab_elem_value(elem, map->key_size), value);
3069 + check_and_init_map_value(map, rhtab_elem_value(elem, map->key_size));
3062 3070
3063 3071 /* Prevent deadlock for NMI programs attempting to take bucket lock */
3064 3072 bpf_disable_instrumentation();
@@ -3102,9 +3110,6 @@ static int rhtab_map_check_btf(struct bpf_map *map, const struct btf *btf,
3102 3110 {
3103 3111 struct bpf_rhtab *rhtab = container_of(map, struct bpf_rhtab, map);
3104 3112
3105 - if (btf_type_is_void(key_type))
3106 - return -EINVAL;
3107 -
3108 3113 return bpf_ma_set_dtor(map, &rhtab->ma, rhtab_mem_dtor);
3109 3114 }
3110 3115
modified kernel/bpf/liveness.c
@@ -85,7 +85,7 @@ static struct func_instance *call_instance(struct bpf_verifier_env *env,
85 85 if (f)
86 86 return f;
87 87
88 - f = kvzalloc_obj(*f, GFP_KERNEL_ACCOUNT);
88 + f = kvzalloc(sizeof(*f), GFP_KERNEL_ACCOUNT);
89 89 if (!f)
90 90 return ERR_PTR(-ENOMEM);
91 91 f->callsite = lookup_key;
modified kernel/bpf/local_storage.c
@@ -220,7 +220,7 @@ int bpf_percpu_cgroup_storage_update(struct bpf_map *_map, void *key,
220 220 struct bpf_cgroup_storage *storage;
221 221 void *val;
222 222 u32 size;
223 - int cpu, off = 0;
223 + int cpu;
224 224
225 225 if ((u32)map_flags & ~(BPF_ANY | BPF_EXIST | BPF_F_CPU | BPF_F_ALL_CPUS))
226 226 return -EINVAL;
@@ -245,9 +245,8 @@ int bpf_percpu_cgroup_storage_update(struct bpf_map *_map, void *key,
245 245 }
246 246 size = round_up(_map->value_size, 8);
247 247 for_each_possible_cpu(cpu) {
248 - val = (map_flags & BPF_F_ALL_CPUS) ? value : value + off;
248 + val = (map_flags & BPF_F_ALL_CPUS) ? value : value + size * cpu;
249 249 copy_map_value(_map, per_cpu_ptr(storage->percpu_buf, cpu), val);
250 - off += size;
251 250 }
252 251 unlock:
253 252 rcu_read_unlock();
modified kernel/bpf/log.c
@@ -862,7 +862,7 @@ struct bpf_verifier_log *bpf_log_attr_create_vlog(struct bpf_log_attr *attr_log,
862 862 if (!size)
863 863 return NULL;
864 864
865 - log = kzalloc_obj(*log);
865 + log = kzalloc_obj(*log, GFP_KERNEL);
866 866 if (!log)
867 867 return ERR_PTR(-ENOMEM);
868 868
modified kernel/bpf/percpu_freelist.c
@@ -17,8 +17,6 @@ int pcpu_freelist_init(struct pcpu_freelist *s)
17 17 raw_res_spin_lock_init(&head->lock);
18 18 head->first = NULL;
19 19 }
20 - raw_res_spin_lock_init(&s->extralist.lock);
21 - s->extralist.first = NULL;
22 20 return 0;
23 21 }
24 22
@@ -48,28 +46,22 @@ void __pcpu_freelist_push(struct pcpu_freelist *s,
48 46 struct pcpu_freelist_node *node)
49 47 {
50 48 struct pcpu_freelist_head *head;
51 - int cpu, this_cpu;
49 + int cpu;
52 50
53 51 if (___pcpu_freelist_push(this_cpu_ptr(s->freelist), node))
54 52 return;
55 53
56 - this_cpu = raw_smp_processor_id();
57 54 while (true) {
58 - for_each_cpu_wrap(cpu, cpu_possible_mask, this_cpu) {
59 - if (cpu == this_cpu)
55 + for_each_cpu_wrap(cpu, cpu_possible_mask, raw_smp_processor_id()) {
56 + if (cpu == raw_smp_processor_id())
60 57 continue;
61 -
62 58 head = per_cpu_ptr(s->freelist, cpu);
63 - if (___pcpu_freelist_push(head, node))
64 - return;
65 - }
66 -
67 - /*
68 - * Push cannot fail. Use the extra list when none of the
69 - * per-CPU freelists can accept the node.
70 - */
71 - if (___pcpu_freelist_push(&s->extralist, node))
59 + if (raw_res_spin_lock(&head->lock))
60 + continue;
61 + pcpu_freelist_push_node(head, node);
62 + raw_res_spin_unlock(&head->lock);
72 63 return;
64 + }
73 65 }
74 66 }
75 67
@@ -125,17 +117,6 @@ static struct pcpu_freelist_node *___pcpu_freelist_pop(struct pcpu_freelist *s)
125 117 }
126 118 raw_res_spin_unlock(&head->lock);
127 119 }
128 -
129 - /* Per-CPU lists are empty or unavailable, try the extra list. */
130 - head = &s->extralist;
131 - if (!READ_ONCE(head->first))
132 - return NULL;
133 - if (raw_res_spin_lock(&head->lock))
134 - return NULL;
135 - node = head->first;
136 - if (node)
137 - WRITE_ONCE(head->first, node->next);
138 - raw_res_spin_unlock(&head->lock);
139 120 return node;
140 121 }
141 122
modified kernel/bpf/percpu_freelist.h
@@ -14,7 +14,6 @@ struct pcpu_freelist_head {
14 14
15 15 struct pcpu_freelist {
16 16 struct pcpu_freelist_head __percpu *freelist;
17 - struct pcpu_freelist_head extralist;
18 17 };
19 18
20 19 struct pcpu_freelist_node {
modified kernel/bpf/stackmap.c
@@ -875,7 +875,6 @@ BPF_CALL_4(bpf_get_stack_sleepable, struct pt_regs *, regs, void *, buf, u32, si
875 875 const struct bpf_func_proto bpf_get_stack_sleepable_proto = {
876 876 .func = bpf_get_stack_sleepable,
877 877 .gpl_only = true,
878 - .might_sleep = true,
879 878 .ret_type = RET_INTEGER,
880 879 .arg1_type = ARG_PTR_TO_CTX,
881 880 .arg2_type = ARG_PTR_TO_UNINIT_MEM,
@@ -929,7 +928,6 @@ BPF_CALL_4(bpf_get_task_stack_sleepable, struct task_struct *, task, void *, buf
929 928 const struct bpf_func_proto bpf_get_task_stack_sleepable_proto = {
930 929 .func = bpf_get_task_stack_sleepable,
931 930 .gpl_only = false,
932 - .might_sleep = true,
933 931 .ret_type = RET_INTEGER,
934 932 .arg1_type = ARG_PTR_TO_BTF_ID,
935 933 .arg1_btf_id = &btf_tracing_ids[BTF_TRACING_TYPE_TASK],
modified kernel/bpf/states.c
@@ -445,19 +445,22 @@ static void __clean_func_state(struct bpf_verifier_env *env,
445 445 struct bpf_reg_state *spill = &st->stack[i].spilled_ptr;
446 446
447 447 if (lo_live && stype == STACK_SPILL) {
448 + u8 val = STACK_MISC;
449 +
448 450 if (spill->type != SCALAR_VALUE)
449 451 continue;
452 +
450 453 /*
451 - * Can't replace with STACK_ZERO, because
452 - * that requires bpf_mark_chain_precision().
454 + * 8 byte spill of scalar 0 where half slot is dead
455 + * should become STACK_ZERO in lo 4 bytes.
453 456 */
454 457 if (bpf_register_is_null(spill))
455 - continue;
458 + val = STACK_ZERO;
456 459 for (j = 0; j < 4; j++) {
457 460 u8 *t = &st->stack[i].slot_type[j];
458 461
459 462 if (*t == STACK_SPILL)
460 - *t = STACK_MISC;
463 + *t = val;
461 464 }
462 465 }
463 466 bpf_mark_reg_not_init(env, spill);
modified kernel/bpf/syscall.c
@@ -6568,7 +6568,6 @@ EXPORT_SYMBOL_NS(kern_sys_bpf, "BPF_INTERNAL");
6568 6568 static const struct bpf_func_proto bpf_sys_bpf_proto = {
6569 6569 .func = bpf_sys_bpf,
6570 6570 .gpl_only = false,
6571 - .might_sleep = true,
6572 6571 .ret_type = RET_INTEGER,
6573 6572 .arg1_type = ARG_ANYTHING,
6574 6573 .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
@@ -6594,7 +6593,6 @@ BPF_CALL_1(bpf_sys_close, u32, fd)
6594 6593 static const struct bpf_func_proto bpf_sys_close_proto = {
6595 6594 .func = bpf_sys_close,
6596 6595 .gpl_only = false,
6597 - .might_sleep = true,
6598 6596 .ret_type = RET_INTEGER,
6599 6597 .arg1_type = ARG_ANYTHING,
6600 6598 };
modified kernel/bpf/verifier.c
@@ -352,18 +352,9 @@ static bool reg_not_null(struct bpf_verifier_env *env, const struct bpf_reg_stat
352 352 if (type_may_be_null(type))
353 353 return false;
354 354
355 - /*
356 - * The types below guarantee a non-NULL base, an unbounded offset can
357 - * still wrap base + offset to zero.
358 - */
359 - if (reg_smin(reg) <= -BPF_MAX_VAR_OFF || reg_smax(reg) >= BPF_MAX_VAR_OFF)
360 - return false;
361 -
362 355 type = base_type(type);
363 356 return type == PTR_TO_SOCKET ||
364 357 type == PTR_TO_TCP_SOCK ||
365 - type == PTR_TO_XDP_SOCK ||
366 - type == PTR_TO_BUF ||
367 358 type == PTR_TO_MAP_VALUE ||
368 359 type == PTR_TO_MAP_KEY ||
369 360 type == PTR_TO_SOCK_COMMON ||
@@ -4246,15 +4237,6 @@ static int mark_stack_arg_precision(struct bpf_verifier_env *env, int arg_idx)
4246 4237 return mark_chain_precision_batch(env, env->cur_state);
4247 4238 }
4248 4239
4249 - static int mark_arg_precision(struct bpf_verifier_env *env, argno_t argno)
4250 - {
4251 - int regno = reg_from_argno(argno);
4252 -
4253 - if (regno >= 0)
4254 - return mark_chain_precision(env, regno);
4255 - return mark_stack_arg_precision(env, arg_idx_from_argno(argno));
4256 - }
4257 -
4258 4240 static int check_outgoing_stack_args(struct bpf_verifier_env *env, struct bpf_func_state *caller,
4259 4241 int nargs, const char *callee_name, const struct btf *btf,
4260 4242 const struct btf_param *args)
@@ -4504,13 +4486,6 @@ static int map_kptr_match_type(struct bpf_verifier_env *env,
4504 4486 if (type_flag(reg->type) & ~perm_flags)
4505 4487 goto bad_type;
4506 4488
4507 - /*
4508 - * A BPF_KPTR_PERCPU field is read back as MEM_PERCPU, so the value
4509 - * stored in it must carry the same flag.
4510 - */
4511 - if ((kptr_field->type == BPF_KPTR_PERCPU) != !!(reg->type & MEM_PERCPU))
4512 - goto bad_type;
4513 -
4514 4489 /* We need to verify reg->type and reg->btf, before accessing reg->btf */
4515 4490 reg_name = btf_type_name(reg->btf, reg->btf_id);
4516 4491
@@ -4717,15 +4692,8 @@ static int check_map_kptr_access(struct bpf_verifier_env *env,
4717 4692 return ret;
4718 4693 } else if (class == BPF_STX) {
4719 4694 val_reg = reg_state(env, value_regno);
4720 - if (bpf_register_is_null(val_reg)) {
4721 - /*
4722 - * This store is valid only because the scalar is known to be
4723 - * zero. Mark it precise so another scalar cannot be pruned
4724 - * against this state.
4725 - */
4726 - return mark_chain_precision(env, value_regno);
4727 - }
4728 - if (map_kptr_match_type(env, kptr_field, val_reg, value_regno))
4695 + if (!bpf_register_is_null(val_reg) &&
4696 + map_kptr_match_type(env, kptr_field, val_reg, value_regno))
4729 4697 return -EACCES;
4730 4698 } else if (class == BPF_ST) {
4731 4699 if (insn->imm) {
@@ -5332,15 +5300,6 @@ static int check_max_stack_depth_subprog(struct bpf_verifier_env *env, int idx,
5332 5300 if (!priv_stack_supported)
5333 5301 subprog[idx].priv_stack_mode = NO_PRIV_STACK;
5334 5302 process_func:
5335 - if (subprog[idx].has_ld_abs) {
5336 - for (tmp = idx; tmp >= 0; tmp = dinfo[tmp].caller) {
5337 - if (subprog[tmp].is_cb) {
5338 - verbose(env, "cannot use BPF_LD_[ABS|IND] within callback\n");
5339 - return -EINVAL;
5340 - }
5341 - }
5342 - }
5343 -
5344 5303 /* protect against potential stack overflow that might happen when
5345 5304 * bpf2bpf calls get combined with tailcalls. Limit the caller's stack
5346 5305 * depth for such case down to 256 so that the worst case scenario
@@ -5524,7 +5483,7 @@ static int check_max_stack_depth(struct bpf_verifier_env *env)
5524 5483 bool priv_stack_supported;
5525 5484 int ret;
5526 5485
5527 - dinfo = kvzalloc_objs(*dinfo, env->subprog_cnt, GFP_KERNEL_ACCOUNT);
5486 + dinfo = kvcalloc(env->subprog_cnt, sizeof(*dinfo), GFP_KERNEL_ACCOUNT);
5528 5487 if (!dinfo)
5529 5488 return -ENOMEM;
5530 5489
@@ -6061,13 +6020,7 @@ static int check_ptr_to_btf_access(struct bpf_verifier_env *env,
6061 6020 return -EACCES;
6062 6021 }
6063 6022
6064 - /*
6065 - * A fault-prone allocated object may still be read through a
6066 - * BPF_PROBE_MEM load after its lifetime protection ends. Writes
6067 - * through such pointers were rejected above.
6068 - */
6069 - if (type_is_alloc(reg->type) && !bpf_may_fault_on_deref(reg->type) &&
6070 - !type_is_non_owning_ref(reg->type) &&
6023 + if (type_is_alloc(reg->type) && !type_is_non_owning_ref(reg->type) &&
6071 6024 !(reg->type & MEM_RCU) && !reg_is_referenced(env, reg)) {
6072 6025 verifier_bug(env, "allocated object must have a referenced id");
6073 6026 return -EFAULT;
@@ -7160,8 +7113,14 @@ static int check_mem_size_reg(struct bpf_verifier_env *env,
7160 7113 if (err && failure)
7161 7114 *failure = BPF_MEM_SIZE_FAIL_MEMORY;
7162 7115
7163 - if (!err)
7164 - err = mark_arg_precision(env, size_argno);
7116 + if (!err) {
7117 + int regno = reg_from_argno(size_argno);
7118 +
7119 + if (regno >= 0)
7120 + err = mark_chain_precision(env, regno);
7121 + else
7122 + err = mark_stack_arg_precision(env, arg_idx_from_argno(size_argno));
7123 + }
7165 7124
7166 7125 return err;
7167 7126
@@ -7178,7 +7137,7 @@ static int check_mem_reg(struct bpf_verifier_env *env, struct bpf_reg_state *reg
7178 7137 int size, err = 0;
7179 7138
7180 7139 if (bpf_register_is_null(reg))
7181 - return mark_arg_precision(env, argno);
7140 + return 0;
7182 7141 if (known_memory)
7183 7142 *known_memory = true;
7184 7143
@@ -7439,14 +7398,10 @@ static int process_spin_lock(struct bpf_verifier_env *env, struct bpf_reg_state
7439 7398 lock);
7440 7399 return -EINVAL;
7441 7400 }
7442 - /*
7443 - * Invalidate non-owning refs before RCU demotion clears their
7444 - * NON_OWN_REF flag.
7445 - */
7446 - invalidate_non_owning_refs(env);
7447 -
7448 7401 if (!in_rcu_cs(env))
7449 7402 invalidate_rcu_protected_refs(env);
7403 +
7404 + invalidate_non_owning_refs(env);
7450 7405 }
7451 7406 return 0;
7452 7407 }
@@ -8211,7 +8166,6 @@ static const struct bpf_reg_types *compatible_reg_types[__BPF_ARG_TYPE_MAX] = {
8211 8166 [ARG_MEM_SIZE] = &scalar_types,
8212 8167 [ARG_MEM_SIZE_OR_ZERO] = &scalar_types,
8213 8168 [ARG_CONST_ALLOC_SIZE_OR_ZERO] = &scalar_types,
8214 - [ARG_SCALAR] = &scalar_types,
8215 8169 [ARG_CONST_MAP_PTR] = &const_map_ptr_types,
8216 8170 [ARG_PTR_TO_CTX] = &context_types,
8217 8171 [ARG_PTR_TO_SOCK_COMMON] = &sock_types,
@@ -8763,15 +8717,11 @@ static int check_func_arg(struct bpf_verifier_env *env, u32 arg,
8763 8717 return err;
8764 8718 }
8765 8719
8766 - if (bpf_register_is_null(reg) && type_may_be_null(arg_type)) {
8720 + if (bpf_register_is_null(reg) && type_may_be_null(arg_type))
8767 8721 /* A NULL register has a SCALAR_VALUE type, so skip
8768 8722 * type checking.
8769 8723 */
8770 - err = mark_chain_precision(env, regno);
8771 - if (err)
8772 - return err;
8773 8724 goto skip_type_check;
8774 - }
8775 8725
8776 8726 /* arg_btf_id and arg_size are in a union. */
8777 8727 if (base_type(arg_type) == ARG_PTR_TO_BTF_ID ||
@@ -9551,7 +9501,7 @@ static void invalidate_rcu_protected_refs(struct bpf_verifier_env *env)
9551 9501 bpf_for_each_reg_in_vstate_mask(env->cur_state, state, reg, stack, clear_mask, ({
9552 9502 if (reg->type & MEM_RCU) {
9553 9503 bpf_diag_mod_begin(env, reg, NULL, BPF_DIAG_MOD_WRITE);
9554 - reg->type &= ~(MEM_RCU | PTR_MAYBE_NULL | NON_OWN_REF);
9504 + reg->type &= ~(MEM_RCU | PTR_MAYBE_NULL);
9555 9505 reg->type |= PTR_UNTRUSTED;
9556 9506 bpf_diag_mod_end(env);
9557 9507 }
@@ -9769,12 +9719,8 @@ static int btf_check_func_arg_match(struct bpf_verifier_env *env, int subprog,
9769 9719 struct bpf_call_arg_meta meta;
9770 9720 int err;
9771 9721
9772 - if (bpf_register_is_null(reg) && type_may_be_null(arg->arg_type)) {
9773 - err = mark_arg_precision(env, argno);
9774 - if (err)
9775 - return err;
9722 + if (bpf_register_is_null(reg) && type_may_be_null(arg->arg_type))
9776 9723 continue;
9777 - }
9778 9724
9779 9725 memset(&meta, 0, sizeof(meta)); /* leave func_id as zero */
9780 9726 err = check_reg_type(env, reg, argno, arg->arg_type, &arg->btf_id, &meta,
@@ -10030,12 +9976,10 @@ int map_set_for_each_callback_args(struct bpf_verifier_env *env,
10030 9976 callee->regs[BPF_REG_2].type = PTR_TO_MAP_KEY;
10031 9977 __mark_reg_known_zero(&callee->regs[BPF_REG_2]);
10032 9978 callee->regs[BPF_REG_2].map_ptr = caller->regs[BPF_REG_1].map_ptr;
10033 - callee->regs[BPF_REG_2].map_uid = caller->regs[BPF_REG_1].map_uid;
10034 9979
10035 9980 callee->regs[BPF_REG_3].type = PTR_TO_MAP_VALUE;
10036 9981 __mark_reg_known_zero(&callee->regs[BPF_REG_3]);
10037 9982 callee->regs[BPF_REG_3].map_ptr = caller->regs[BPF_REG_1].map_ptr;
10038 - callee->regs[BPF_REG_3].map_uid = caller->regs[BPF_REG_1].map_uid;
10039 9983
10040 9984 /* pointer to stack or null */
10041 9985 callee->regs[BPF_REG_4] = caller->regs[BPF_REG_3];
@@ -10113,7 +10057,6 @@ static int set_timer_callback_state(struct bpf_verifier_env *env,
10113 10057 int insn_idx)
10114 10058 {
10115 10059 struct bpf_map *map_ptr = caller->regs[BPF_REG_1].map_ptr;
10116 - u32 map_uid = caller->regs[BPF_REG_1].map_uid;
10117 10060
10118 10061 /* bpf_timer_set_callback(struct bpf_timer *timer, void *callback_fn);
10119 10062 * callback_fn(struct bpf_map *map, void *key, void *value);
@@ -10121,17 +10064,14 @@ static int set_timer_callback_state(struct bpf_verifier_env *env,
10121 10064 callee->regs[BPF_REG_1].type = CONST_PTR_TO_MAP;
10122 10065 __mark_reg_known_zero(&callee->regs[BPF_REG_1]);
10123 10066 callee->regs[BPF_REG_1].map_ptr = map_ptr;
10124 - callee->regs[BPF_REG_1].map_uid = map_uid;
10125 10067
10126 10068 callee->regs[BPF_REG_2].type = PTR_TO_MAP_KEY;
10127 10069 __mark_reg_known_zero(&callee->regs[BPF_REG_2]);
10128 10070 callee->regs[BPF_REG_2].map_ptr = map_ptr;
10129 - callee->regs[BPF_REG_2].map_uid = map_uid;
10130 10071
10131 10072 callee->regs[BPF_REG_3].type = PTR_TO_MAP_VALUE;
10132 10073 __mark_reg_known_zero(&callee->regs[BPF_REG_3]);
10133 10074 callee->regs[BPF_REG_3].map_ptr = map_ptr;
10134 - callee->regs[BPF_REG_3].map_uid = map_uid;
10135 10075
10136 10076 /* unused */
10137 10077 bpf_mark_reg_not_init(env, &callee->regs[BPF_REG_4]);
@@ -10231,7 +10171,6 @@ static int set_task_work_schedule_callback_state(struct bpf_verifier_env *env,
10231 10171 int insn_idx)
10232 10172 {
10233 10173 struct bpf_map *map_ptr = caller->regs[BPF_REG_3].map_ptr;
10234 - u32 map_uid = caller->regs[BPF_REG_3].map_uid;
10235 10174
10236 10175 /*
10237 10176 * callback_fn(struct bpf_map *map, void *key, void *value);
@@ -10239,17 +10178,14 @@ static int set_task_work_schedule_callback_state(struct bpf_verifier_env *env,
10239 10178 callee->regs[BPF_REG_1].type = CONST_PTR_TO_MAP;
10240 10179 __mark_reg_known_zero(&callee->regs[BPF_REG_1]);
10241 10180 callee->regs[BPF_REG_1].map_ptr = map_ptr;
10242 - callee->regs[BPF_REG_1].map_uid = map_uid;
10243 10181
10244 10182 callee->regs[BPF_REG_2].type = PTR_TO_MAP_KEY;
10245 10183 __mark_reg_known_zero(&callee->regs[BPF_REG_2]);
10246 10184 callee->regs[BPF_REG_2].map_ptr = map_ptr;
10247 - callee->regs[BPF_REG_2].map_uid = map_uid;
10248 10185
10249 10186 callee->regs[BPF_REG_3].type = PTR_TO_MAP_VALUE;
10250 10187 __mark_reg_known_zero(&callee->regs[BPF_REG_3]);
10251 10188 callee->regs[BPF_REG_3].map_ptr = map_ptr;
10252 - callee->regs[BPF_REG_3].map_uid = map_uid;
10253 10189
10254 10190 /* unused */
10255 10191 bpf_mark_reg_not_init(env, &callee->regs[BPF_REG_4]);
@@ -10297,10 +10233,9 @@ static void account_current_path(struct bpf_verifier_env *env)
10297 10233 frame ? state->frame[frame - 1] : NULL);
10298 10234 }
10299 10235
10300 - /*
10301 - * Are we currently verifying the callback for an rbtree kfunc that must
10302 - * be called with a lock held, or one of that callback's subprogs? If so,
10303 - * no need to complain about an unreleased lock.
10236 + /* Are we currently verifying the callback for a rbtree helper that must
10237 + * be called with lock held? If so, no need to complain about unreleased
10238 + * lock
10304 10239 */
10305 10240 static bool in_rbtree_lock_required_cb(struct bpf_verifier_env *env)
10306 10241 {
@@ -10308,19 +10243,17 @@ static bool in_rbtree_lock_required_cb(struct bpf_verifier_env *env)
10308 10243 struct bpf_insn *insn = env->prog->insnsi;
10309 10244 struct bpf_func_state *callee;
10310 10245 int kfunc_btf_id;
10311 - u32 frame;
10312 10246
10313 - for (frame = state->curframe; frame; frame--) {
10314 - callee = state->frame[frame];
10315 - if (!callee->in_callback_fn)
10316 - continue;
10247 + if (!state->curframe)
10248 + return false;
10317 10249
10318 - kfunc_btf_id = insn[callee->callsite].imm;
10319 - if (is_rbtree_lock_required_kfunc(kfunc_btf_id))
10320 - return true;
10321 - }
10250 + callee = state->frame[state->curframe];
10322 10251
10323 - return false;
10252 + if (!callee->in_callback_fn)
10253 + return false;
10254 +
10255 + kfunc_btf_id = insn[callee->callsite].imm;
10256 + return is_rbtree_lock_required_kfunc(kfunc_btf_id);
10324 10257 }
10325 10258
10326 10259 static bool retval_range_within(struct bpf_retval_range range, const struct bpf_reg_state *reg)
@@ -10697,45 +10630,33 @@ static struct bpf_insn_aux_data *cur_aux(const struct bpf_verifier_env *env)
10697 10630 return &env->insn_aux_data[env->insn_idx];
10698 10631 }
10699 10632
10700 - /* Returns 1 if R4 is a known zero, 0 if it is not, a negative errno on error. */
10701 - static int loop_flag_is_zero(struct bpf_verifier_env *env)
10633 + static bool loop_flag_is_zero(struct bpf_verifier_env *env)
10702 10634 {
10703 10635 struct bpf_reg_state *reg = reg_state(env, BPF_REG_4);
10704 - int err;
10636 + bool reg_is_null = bpf_register_is_null(reg);
10705 10637
10706 - if (!bpf_register_is_null(reg))
10707 - return 0;
10638 + if (reg_is_null)
10639 + mark_chain_precision(env, BPF_REG_4);
10708 10640
10709 - err = mark_chain_precision(env, BPF_REG_4);
10710 - if (err)
10711 - return err;
10712 - return 1;
10641 + return reg_is_null;
10713 10642 }
10714 10643
10715 - static int update_loop_inline_state(struct bpf_verifier_env *env, u32 subprogno)
10644 + static void update_loop_inline_state(struct bpf_verifier_env *env, u32 subprogno)
10716 10645 {
10717 10646 struct bpf_loop_inline_state *state = &cur_aux(env)->loop_inline_state;
10718 - int flag_is_zero;
10719 10647
10720 10648 if (!state->initialized) {
10721 - flag_is_zero = loop_flag_is_zero(env);
10722 - if (flag_is_zero < 0)
10723 - return flag_is_zero;
10724 10649 state->initialized = 1;
10725 - state->fit_for_inline = flag_is_zero;
10650 + state->fit_for_inline = loop_flag_is_zero(env);
10726 10651 state->callback_subprogno = subprogno;
10727 - return 0;
10652 + return;
10728 10653 }
10729 10654
10730 10655 if (!state->fit_for_inline)
10731 - return 0;
10656 + return;
10732 10657
10733 - flag_is_zero = loop_flag_is_zero(env);
10734 - if (flag_is_zero < 0)
10735 - return flag_is_zero;
10736 - state->fit_for_inline = (flag_is_zero &&
10658 + state->fit_for_inline = (loop_flag_is_zero(env) &&
10737 10659 state->callback_subprogno == subprogno);
10738 - return 0;
10739 10660 }
10740 10661
10741 10662 /* Returns whether or not the given map can potentially elide
@@ -10947,9 +10868,6 @@ static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn
10947 10868 verbose(env, "get_local_storage() doesn't support non-zero flags\n");
10948 10869 return -EINVAL;
10949 10870 }
10950 - err = mark_chain_precision(env, BPF_REG_2);
10951 - if (err)
10952 - return err;
10953 10871 break;
10954 10872 case BPF_FUNC_for_each_map_elem:
10955 10873 err = push_callback_call(env, insn, insn_idx, meta.subprogno,
@@ -10967,9 +10885,7 @@ static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn
10967 10885 err = check_bpf_snprintf_call(env, regs);
10968 10886 break;
10969 10887 case BPF_FUNC_loop:
10970 - err = update_loop_inline_state(env, meta.subprogno);
10971 - if (err)
10972 - return err;
10888 + update_loop_inline_state(env, meta.subprogno);
10973 10889 /* Verifier relies on R1 value to determine if bpf_loop() iteration
10974 10890 * is finished, thus mark it precise.
10975 10891 */
@@ -11310,17 +11226,6 @@ static int check_helper_call(struct bpf_verifier_env *env, struct bpf_insn *insn
11310 11226 if (env->cur_state->curframe) {
11311 11227 struct bpf_verifier_state *branch;
11312 11228
11313 - /*
11314 - * A taken tail call is modeled as a return from the current
11315 - * frame. A callback frame cannot be left that way because
11316 - * prepare_func_exit() would apply its return contract to the
11317 - * unknown R0 synthesized below. Stack-depth validation rejects
11318 - * this construct anyway.
11319 - */
11320 - if (cur_func(env)->in_callback_fn) {
11321 - verbose(env, "cannot tail call within callback\n");
11322 - return -EINVAL;
11323 - }
11324 11229 mark_reg_scratched(env, BPF_REG_0);
11325 11230 branch = push_stack(env, env->insn_idx + 1, env->insn_idx, false);
11326 11231 if (IS_ERR(branch))
@@ -12746,12 +12651,8 @@ static int check_kfunc_args(struct bpf_verifier_env *env, struct bpf_call_arg_me
12746 12651 if (reg_is_referenced(env, reg))
12747 12652 update_ref_obj(&meta->ref_obj, reg);
12748 12653
12749 - if (bpf_register_is_null(reg) && type_may_be_null(kf_arg_type)) {
12750 - ret = mark_arg_precision(env, argno);
12751 - if (ret)
12752 - return ret;
12654 + if (bpf_register_is_null(reg) && type_may_be_null(kf_arg_type))
12753 12655 continue;
12754 - }
12755 12656
12756 12657 if (is_kfunc_arg_map(btf, &args[i])) {
12757 12658 ref_id = *reg2btf_ids[CONST_PTR_TO_MAP];
@@ -13245,7 +13146,7 @@ check_ok:
13245 13146 bpf_diag_reg_type_plain(env, reg->type));
13246 13147 return -EINVAL;
13247 13148 }
13248 - if (!type_is_non_owning_ref(reg->type) && reg_is_referenced(env, reg))
13149 + if (!type_is_non_owning_ref(reg->type))
13249 13150 meta->arg_owning_ref = true;
13250 13151
13251 13152 rec = reg_btf_record(reg);
@@ -13327,11 +13228,6 @@ check_ok:
13327 13228 {
13328 13229 int flags = PROCESS_RES_LOCK;
13329 13230
13330 - if (in_rbtree_lock_required_cb(env)) {
13331 - verbose(env, "can't res_spin_{lock,unlock} in rbtree cb\n");
13332 - return -EACCES;
13333 - }
13334 -
13335 13231 if (reg->type != PTR_TO_MAP_VALUE && reg->type != (PTR_TO_BTF_ID | MEM_ALLOC)) {
13336 13232 verbose(env, "%s doesn't point to map value or allocated object\n",
13337 13233 reg_arg_name(env, argno));
@@ -14664,6 +14560,9 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, struct bpf_insn
14664 14560 return -EINVAL;
14665 14561 }
14666 14562
14563 + /* pointer types do not carry 32-bit bounds at the moment. */
14564 + __mark_reg32_unbounded(dst_reg);
14565 +
14667 14566 if (sanitize_needed(opcode)) {
14668 14567 ret = sanitize_ptr_alu(env, insn, ptr_reg, off_reg, dst_reg,
14669 14568 &info, false);
@@ -14671,14 +14570,6 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, struct bpf_insn
14671 14570 return sanitize_err(env, insn, ret);
14672 14571 }
14673 14572
14674 - /*
14675 - * Pointer types do not carry 32-bit bounds at the moment. Blank r32
14676 - * only after sanitize_ptr_alu() may have snapshotted dst_reg into a
14677 - * speculative path: otherwise reg_bounds_sanity_check() might hit some
14678 - * constraints violations.
14679 - */
14680 - __mark_reg32_unbounded(dst_reg);
14681 -
14682 14573 switch (opcode) {
14683 14574 case BPF_ADD:
14684 14575 /*
@@ -16404,13 +16295,6 @@ static int is_branch_taken(struct bpf_verifier_env *env, struct bpf_reg_state *r
16404 16295 if (__is_pointer_value(false, reg1) || __is_pointer_value(false, reg2)) {
16405 16296 u64 val;
16406 16297
16407 - /*
16408 - * The low 32 bits of a valid pointer may well be zero, hence
16409 - * nothing below applies to a 32-bit comparison.
16410 - */
16411 - if (is_jmp32)
16412 - return -1;
16413 -
16414 16298 /* arrange that reg2 is a scalar, and reg1 is a pointer */
16415 16299 if (!is_reg_const(reg2, is_jmp32)) {
16416 16300 opcode = flip_opcode(opcode);
@@ -16972,16 +16856,6 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env,
16972 16856 return err;
16973 16857 }
16974 16858
16975 - /*
16976 - * Collect the linked registers before env->{true,false}_reg{1,2} setup,
16977 - * otherwise ids dropped by collect_linked_regs() would be resurrected
16978 - * when env->{true,false}_reg{1,2} are copied back.
16979 - */
16980 - if (BPF_SRC(insn->code) == BPF_X && src_reg->type == SCALAR_VALUE && src_reg->id)
16981 - collect_linked_regs(env, this_branch, src_reg->id, &linked_regs);
16982 - if (dst_reg->type == SCALAR_VALUE && dst_reg->id)
16983 - collect_linked_regs(env, this_branch, dst_reg->id, &linked_regs);
16984 -
16985 16859 is_jmp32 = BPF_CLASS(insn->code) == BPF_JMP32;
16986 16860 env->false_reg1 = *dst_reg;
16987 16861 env->false_reg2 = *src_reg;
@@ -17036,6 +16910,10 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env,
17036 16910 * 'this_branch' and 'other_branch' share this history
17037 16911 * if parent state is created.
17038 16912 */
16913 + if (BPF_SRC(insn->code) == BPF_X && src_reg->type == SCALAR_VALUE && src_reg->id)
16914 + collect_linked_regs(env, this_branch, src_reg->id, &linked_regs);
16915 + if (dst_reg->type == SCALAR_VALUE && dst_reg->id)
16916 + collect_linked_regs(env, this_branch, dst_reg->id, &linked_regs);
17039 16917 if (linked_regs.cnt > 1) {
17040 16918 err = bpf_push_jmp_history(env, this_branch, 0, 0, 0, linked_regs_pack(&linked_regs));
17041 16919 if (err)
@@ -17085,6 +16963,7 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env,
17085 16963 */
17086 16964 if (!is_jmp32 && BPF_SRC(insn->code) == BPF_X &&
17087 16965 __is_pointer_value(false, src_reg) && __is_pointer_value(false, dst_reg) &&
16966 + type_may_be_null(src_reg->type) != type_may_be_null(dst_reg->type) &&
17088 16967 base_type(src_reg->type) != PTR_TO_BTF_ID &&
17089 16968 base_type(dst_reg->type) != PTR_TO_BTF_ID) {
17090 16969 eq_branch_regs = NULL;
@@ -17100,11 +16979,9 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env,
17100 16979 break;
17101 16980 }
17102 16981 if (eq_branch_regs) {
17103 - /* src == dst && dst != NULL => src != NULL */
17104 - if (reg_not_null(env, dst_reg) && type_may_be_null(src_reg->type))
16982 + if (type_may_be_null(src_reg->type))
17105 16983 mark_ptr_not_null_reg(&eq_branch_regs[insn->src_reg]);
17106 - /* src == dst && src != NULL => dst != NULL */
17107 - if (reg_not_null(env, src_reg) && type_may_be_null(dst_reg->type))
16984 + else
17108 16985 mark_ptr_not_null_reg(&eq_branch_regs[insn->dst_reg]);
17109 16986 }
17110 16987 }
@@ -17119,15 +16996,6 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env,
17119 16996 type_may_be_null(dst_reg->type) &&
17120 16997 ((BPF_SRC(insn->code) == BPF_K && insn->imm == 0) ||
17121 16998 (BPF_SRC(insn->code) == BPF_X && bpf_register_is_null(src_reg)))) {
17122 - /*
17123 - * For BPF_X the zero is a property of this execution path,
17124 - * hence src_reg has to be precise.
17125 - */
17126 - if (BPF_SRC(insn->code) == BPF_X) {
17127 - err = mark_chain_precision(env, insn->src_reg);
17128 - if (err)
17129 - return err;
17130 - }
17131 16999 /* Mark all identical registers in each branch as either
17132 17000 * safe or unknown depending R == 0 or R != 0 conditional.
17133 17001 */
@@ -17213,15 +17081,6 @@ static int check_ld_imm(struct bpf_verifier_env *env, struct bpf_insn *insn)
17213 17081 verbose(env, "callback function not static\n");
17214 17082 return -EINVAL;
17215 17083 }
17216 - /*
17217 - * When env->subprog_cnt == 1 this instruction won't be rewritten
17218 - * to hold a real function address. Assume that no usable program
17219 - * combines e.g. main and timer callback and just reject here.
17220 - */
17221 - if (subprogno == 0) {
17222 - verbose(env, "callback function cannot be the main program\n");
17223 - return -EINVAL;
17224 - }
17225 17084
17226 17085 dst_reg->type = PTR_TO_FUNC;
17227 17086 dst_reg->subprogno = subprogno;
@@ -17287,7 +17146,6 @@ static bool may_access_skb(enum bpf_prog_type type)
17287 17146 */
17288 17147 static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn)
17289 17148 {
17290 - struct bpf_verifier_state *state = env->cur_state;
17291 17149 struct bpf_reg_state *regs = cur_regs(env);
17292 17150 static const int ctx_reg = BPF_REG_6;
17293 17151 u8 mode = BPF_MODE(insn->code);
@@ -17298,13 +17156,6 @@ static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn)
17298 17156 return -EINVAL;
17299 17157 }
17300 17158
17301 - for (i = state->curframe; i; i--) {
17302 - if (state->frame[i]->in_callback_fn) {
17303 - verbose(env, "cannot use BPF_LD_[ABS|IND] within callback\n");
17304 - return -EINVAL;
17305 - }
17306 - }
17307 -
17308 17159 if (!env->ops->gen_ld_abs) {
17309 17160 verifier_bug(env, "gen_ld_abs is null");
17310 17161 return -EFAULT;
@@ -17772,10 +17623,6 @@ bool bpf_get_call_summary(struct bpf_verifier_env *env, struct bpf_insn *call,
17772 17623 * r0 = *(u64 *)(r10 - 8); r0 += r1;
17773 17624 * r0 += r1; exit;
17774 17625 * exit;
17775 - *
17776 - * Both uses of the marks assume that a pattern is entered at its first
17777 - * spill and thus executes as a unit, hence a pattern is not grown past
17778 - * an instruction targeted by a jump.
17779 17626 */
17780 17627 static void mark_fastcall_pattern_for_call(struct bpf_verifier_env *env,
17781 17628 struct bpf_subprog_info *subprog,
@@ -17814,10 +17661,6 @@ static void mark_fastcall_pattern_for_call(struct bpf_verifier_env *env,
17814 17661 for (i = 1, off = lowest_off; i <= ARRAY_SIZE(caller_saved); ++i, off += BPF_REG_SIZE) {
17815 17662 if (insn_idx - i < 0 || insn_idx + i >= env->prog->len)
17816 17663 break;
17817 - /* stx/ldx/call must not be a jump targets, a jump to the first stx is fine */
17818 - if (bpf_is_jump_target(env, insn_idx - i + 1) ||
17819 - bpf_is_jump_target(env, insn_idx + i))
17820 - break;
17821 17664 stx = &insns[insn_idx - i];
17822 17665 ldx = &insns[insn_idx + i];
17823 17666 /* must be a stack spill/fill pair */
@@ -20693,7 +20536,8 @@ static int process_fd_array_continuous(struct bpf_verifier_env *env,
20693 20536 return -E2BIG;
20694 20537 }
20695 20538
20696 - env->fd_array = kvzalloc_objs(*env->fd_array, cnt, GFP_KERNEL_ACCOUNT);
20539 + env->fd_array = kvcalloc(cnt, sizeof(*env->fd_array),
20540 + GFP_KERNEL_ACCOUNT);
20697 20541 if (!env->fd_array)
20698 20542 return -ENOMEM;
20699 20543 env->fd_array_cnt = cnt;
modified kernel/capability.c
@@ -326,6 +326,7 @@ bool has_capability_noaudit(struct task_struct *t, int cap)
326 326 {
327 327 return has_ns_capability_noaudit(t, &init_user_ns, cap);
328 328 }
329 + EXPORT_SYMBOL(has_capability_noaudit);
329 330
330 331 static bool ns_capable_common(struct user_namespace *ns,
331 332 int cap,
@@ -415,24 +416,6 @@ bool capable(int cap)
415 416 return ns_capable(&init_user_ns, cap);
416 417 }
417 418 EXPORT_SYMBOL(capable);
418 -
419 - /**
420 - * capable_noaudit - Determine if the current task has a superior
421 - * capability in effect by checking the process's effective
422 - * capabilities (unaudited).
423 - * @cap: The capability to be tested for
424 - *
425 - * This is the same as capable(), except it uses CAP_OPT_NOAUDIT as to prevent
426 - * issuing spurious audit messages.
427 - *
428 - * This sets PF_SUPERPRIV on the task if the capability is available on the
429 - * assumption that it's about to be used.
430 - */
431 - bool capable_noaudit(int cap)
432 - {
433 - return ns_capable_noaudit(&init_user_ns, cap);
434 - }
435 - EXPORT_SYMBOL(capable_noaudit);
436 419 #endif /* CONFIG_MULTIUSER */
437 420
438 421 /**
modified kernel/cgroup/cgroup.c
@@ -6873,7 +6873,10 @@ static int cgroup_css_set_fork(struct kernel_clone_args *kargs)
6873 6873 spin_lock_irq(&css_set_lock);
6874 6874 cset = task_css_set(current);
6875 6875 get_css_set(cset);
6876 - kargs->kill_seq = cset->dfl_cgrp->kill_seq;
6876 + if (kargs->cgrp)
6877 + kargs->kill_seq = kargs->cgrp->kill_seq;
6878 + else
6879 + kargs->kill_seq = cset->dfl_cgrp->kill_seq;
6877 6880 spin_unlock_irq(&css_set_lock);
6878 6881
6879 6882 if (!(kargs->flags & CLONE_INTO_CGROUP)) {
@@ -6937,7 +6940,6 @@ static int cgroup_css_set_fork(struct kernel_clone_args *kargs)
6937 6940
6938 6941 put_css_set(cset);
6939 6942 kargs->cgrp = dst_cgrp;
6940 - kargs->kill_seq = dst_cgrp->kill_seq;
6941 6943 return ret;
6942 6944
6943 6945 err:
modified kernel/cgroup/cpuset.c
@@ -1259,28 +1259,6 @@ static void reset_partition_data(struct cpuset *cs)
1259 1259 cpumask_copy(cs->effective_cpus, parent->effective_cpus);
1260 1260 }
1261 1261
1262 - /* Return true if isolated_cpus changes. */
1263 - static bool isolated_cpu_update(int new_prs, int cpu)
1264 - {
1265 - lockdep_assert_held(&callback_lock);
1266 - lockdep_assert_held(&cpuset_mutex);
1267 -
1268 - if (new_prs == PRS_ISOLATED) {
1269 - if (cpumask_test_cpu(cpu, isolated_cpus))
1270 - return false;
1271 - cpumask_set_cpu(cpu, isolated_cpus);
1272 - return true;
1273 - }
1274 -
1275 - /* CPUs isolated at boot must remain isolated. */
1276 - if (!cpumask_test_cpu(cpu,
1277 - housekeeping_cpumask(HK_TYPE_DOMAIN_BOOT)) ||
1278 - !cpumask_test_cpu(cpu, isolated_cpus))
1279 - return false;
1280 - cpumask_clear_cpu(cpu, isolated_cpus);
1281 - return true;
1282 - }
1283 -
1284 1262 /*
1285 1263 * isolated_cpus_update - Update the isolated_cpus mask
1286 1264 * @old_prs: old partition_root_state
@@ -1289,16 +1267,19 @@ static bool isolated_cpu_update(int new_prs, int cpu)
1289 1267 */
1290 1268 static void isolated_cpus_update(int old_prs, int new_prs, struct cpumask *xcpus)
1291 1269 {
1292 - bool updated = false;
1293 - int cpu;
1294 -
1295 1270 WARN_ON_ONCE(old_prs == new_prs);
1296 1271 lockdep_assert_held(&callback_lock);
1297 1272 lockdep_assert_held(&cpuset_mutex);
1298 - for_each_cpu(cpu, xcpus)
1299 - updated |= isolated_cpu_update(new_prs, cpu);
1300 - if (updated)
1301 - update_housekeeping = true;
1273 + if (new_prs == PRS_ISOLATED) {
1274 + if (cpumask_subset(xcpus, isolated_cpus))
1275 + return;
1276 + cpumask_or(isolated_cpus, isolated_cpus, xcpus);
1277 + } else {
1278 + if (!cpumask_intersects(xcpus, isolated_cpus))
1279 + return;
1280 + cpumask_andnot(isolated_cpus, isolated_cpus, xcpus);
1281 + }
1282 + update_housekeeping = true;
1302 1283 }
1303 1284
1304 1285 /*
modified kernel/dma/map_benchmark.c
@@ -51,7 +51,8 @@ struct dma_single_map_param {
51 51
52 52 static void *dma_single_map_benchmark_prepare(struct map_benchmark_data *map)
53 53 {
54 - struct dma_single_map_param *params __free(kfree) = kzalloc_obj(*params);
54 + struct dma_single_map_param *params __free(kfree) = kzalloc(sizeof(*params),
55 + GFP_KERNEL);
55 56 if (!params)
56 57 return NULL;
57 58
modified kernel/events/core.c
@@ -7029,6 +7029,7 @@ static void perf_mmap_close(struct vm_area_struct *vma)
7029 7029 mapped_f unmapped = get_mapped(event, event_unmapped);
7030 7030 struct perf_buffer *rb = ring_buffer_get(event);
7031 7031 struct user_struct *mmap_user = rb->mmap_user;
7032 + bool detach_rest = false;
7032 7033
7033 7034 /* FIXIES vs perf_pmu_unregister() */
7034 7035 if (unmapped)
@@ -7059,18 +7060,17 @@ static void perf_mmap_close(struct vm_area_struct *vma)
7059 7060 mutex_unlock(&rb->aux_mutex);
7060 7061 }
7061 7062
7062 - /*
7063 - * Drop references in reverse order of perf_mmap() to prevent
7064 - * rb revival after rb->mmap_count reaches zero.
7065 - */
7066 - if (refcount_dec_and_mutex_lock(&event->mmap_count,
7067 - &event->mmap_mutex)) {
7068 - ring_buffer_attach(event, NULL);
7069 - mutex_unlock(&event->mmap_mutex);
7070 - }
7063 + if (refcount_dec_and_test(&rb->mmap_count))
7064 + detach_rest = true;
7065 +
7066 + if (!refcount_dec_and_mutex_lock(&event->mmap_count, &event->mmap_mutex))
7067 + goto out_put;
7068 +
7069 + ring_buffer_attach(event, NULL);
7070 + mutex_unlock(&event->mmap_mutex);
7071 7071
7072 7072 /* If there's still other mmap()s of this buffer, we're done. */
7073 - if (!refcount_dec_and_test(&rb->mmap_count))
7073 + if (!detach_rest)
7074 7074 goto out_put;
7075 7075
7076 7076 /*
@@ -13558,8 +13558,9 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
13558 13558 return ERR_PTR(err);
13559 13559
13560 13560 if (has_addr_filter(event)) {
13561 - event->addr_filter_ranges = kzalloc_objs(struct perf_addr_filter_range,
13562 - pmu->nr_addr_filters);
13561 + event->addr_filter_ranges = kcalloc(pmu->nr_addr_filters,
13562 + sizeof(struct perf_addr_filter_range),
13563 + GFP_KERNEL);
13563 13564 if (!event->addr_filter_ranges)
13564 13565 return ERR_PTR(-ENOMEM);
13565 13566
modified kernel/events/ring_buffer.c
@@ -509,10 +509,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size)
509 509 /*
510 510 * Only send RECORD_AUX if we have something useful to communicate
511 511 *
512 - * PMU_FORMAT bits identify the PMU type rather than an AUX event
513 - * has occurred, so ignore them for zero-sized records.
514 - *
515 - * The OVERWRITE records by themselves are not considered
512 + * Note: the OVERWRITE records by themselves are not considered
516 513 * useful, as they don't communicate any *new* information,
517 514 * aside from the short-lived offset, that becomes history at
518 515 * the next event sched-in and therefore isn't useful.
@@ -521,9 +518,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size)
521 518 * offset. So, from now on we don't output AUX records that
522 519 * have *only* OVERWRITE flag set.
523 520 */
524 - if (size ||
525 - (handle->aux_flags & ~(u64)(PERF_AUX_FLAG_PMU_FORMAT_TYPE_MASK |
526 - PERF_AUX_FLAG_OVERWRITE)))
521 + if (size || (handle->aux_flags & ~(u64)PERF_AUX_FLAG_OVERWRITE))
527 522 perf_event_aux_event(handle->event, aux_head, size,
528 523 handle->aux_flags);
529 524
modified kernel/futex/core.c
@@ -1874,8 +1874,8 @@ static int futex_hash_allocate(unsigned int hash_slots, unsigned int flags)
1874 1874 free_percpu(ref);
1875 1875 }
1876 1876
1877 - fph = kvzalloc_flex(*fph, queues, hash_slots,
1878 - GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
1877 + fph = kvzalloc(struct_size(fph, queues, hash_slots),
1878 + GFP_KERNEL_ACCOUNT | __GFP_NOWARN);
1879 1879 if (!fph)
1880 1880 return -ENOMEM;
1881 1881
@@ -2103,7 +2103,7 @@ static int __init futex_init(void)
2103 2103 size = sizeof(struct futex_hash_bucket) * hashsize;
2104 2104 order = get_order(size);
2105 2105
2106 - __futex_queues = kzalloc_objs(*__futex_queues, nr_node_ids);
2106 + __futex_queues = kcalloc(nr_node_ids, sizeof(*__futex_queues), GFP_KERNEL);
2107 2107 kmemleak_not_leak(__futex_queues);
2108 2108
2109 2109 runtime_const_init(shift, __futex_shift);
modified kernel/futex/pi.c
@@ -1070,11 +1070,17 @@ retry_private:
1070 1070 * Caution; releasing @hb in-scope. The hb->lock is still locked
1071 1071 * while the reference is dropped. The reference can not be dropped
1072 1072 * after the unlock because if a user initiated resize is in progress
1073 - * then we might need to wake him. The hb will remain valid
1074 - * because the thread, performing resize, will block on
1075 - * hb->lock during the requeue.
1073 + * then we might need to wake him. This can not be done after the
1074 + * rt_mutex_pre_schedule() invocation. The hb will remain valid because
1075 + * the thread, performing resize, will block on hb->lock during
1076 + * the requeue.
1076 1077 */
1077 1078 futex_private_hash_put(no_free_ptr(hbr.fph));
1079 + /*
1080 + * Must be done before we enqueue the waiter, here is unfortunately
1081 + * under the hb lock, but that *should* work because it does nothing.
1082 + */
1083 + rt_mutex_pre_schedule();
1078 1084
1079 1085 rt_mutex_init_waiter(&rt_waiter);
1080 1086
@@ -1140,6 +1146,10 @@ cleanup:
1140 1146 * the
1141 1147 */
1142 1148 futex_q_lockptr_lock(&q);
1149 + /*
1150 + * Waiter is unqueued.
1151 + */
1152 + rt_mutex_post_schedule();
1143 1153 no_block:
1144 1154 /*
1145 1155 * Fixup the pi_state owner and possibly acquire the lock if we
modified kernel/futex/requeue.c
@@ -154,16 +154,8 @@ static inline void futex_requeue_pi_complete(struct futex_q *q, int locked)
154 154 } while (!atomic_try_cmpxchg(&q->requeue_state, &old, new));
155 155
156 156 #ifdef CONFIG_PREEMPT_RT
157 - /*
158 - * The waiter in futex_requeue_pi_wakeup_sync() can interleave with the
159 - * wake below: It will assign Q_REQUEUE_PI_IN_PROGRESS and here it will
160 - * be updated to Q_REQUEUE_PI_LOCKED (locked = 1). The rcuwait_wait_event()
161 - * will already read Q_REQUEUE_PI_LOCKED and skip the schedule() invocation,
162 - * leading to an access of futex_q::requeue_wait after the waiter returned.
163 - * In this case only we skip the wake here and rely on following wake in
164 - * requeue_pi_wake_futex() to perform the wake if needed.
165 - */
166 - if (unlikely(old == Q_REQUEUE_PI_WAIT) && new != Q_REQUEUE_PI_LOCKED)
157 + /* If the waiter interleaved with the requeue let it know */
158 + if (unlikely(old == Q_REQUEUE_PI_WAIT))
167 159 rcuwait_wake_up(&q->requeue_wait);
168 160 #endif
169 161 }
modified kernel/irq/manage.c
@@ -2306,7 +2306,7 @@ int request_nmi(unsigned int irq, irq_handler_t handler,
2306 2306 !irq_supports_nmi(desc))
2307 2307 return -EINVAL;
2308 2308
2309 - action = kzalloc_obj(struct irqaction);
2309 + action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
2310 2310 if (!action)
2311 2311 return -ENOMEM;
2312 2312
modified kernel/jump_label.c
@@ -726,11 +726,12 @@ static int jump_label_add_module(struct module *mod)
726 726 if (static_key_sealed(key))
727 727 goto do_poke;
728 728
729 - jlm = kzalloc_obj(struct static_key_mod);
729 + jlm = kzalloc(sizeof(struct static_key_mod), GFP_KERNEL);
730 730 if (!jlm)
731 731 return -ENOMEM;
732 732 if (!static_key_linked(key)) {
733 - jlm2 = kzalloc_obj(struct static_key_mod);
733 + jlm2 = kzalloc(sizeof(struct static_key_mod),
734 + GFP_KERNEL);
734 735 if (!jlm2) {
735 736 kfree(jlm);
736 737 return -ENOMEM;
modified kernel/kprobes.c
@@ -1447,14 +1447,8 @@ static bool __within_kprobe_blacklist(unsigned long addr)
1447 1447 /*
1448 1448 * If 'kprobe_blacklist' is defined, check the address and
1449 1449 * reject any probe registration in the prohibited area.
1450 - * Note: this can return true during transition period where
1451 - * (start_addr, end_addr) in the black list is shrinking
1452 - * but old entry has not been removed yet. This is acceptable
1453 - * because the worst case is that we reject more probes than
1454 - * we should.
1455 1450 */
1456 - guard(rcu)();
1457 - list_for_each_entry_rcu(ent, &kprobe_blacklist, list) {
1451 + list_for_each_entry(ent, &kprobe_blacklist, list) {
1458 1452 if (addr >= ent->start_addr && addr < ent->end_addr)
1459 1453 return true;
1460 1454 }
@@ -2515,7 +2509,7 @@ int kprobe_add_ksym_blacklist(unsigned long entry)
2515 2509 ent->start_addr = entry;
2516 2510 ent->end_addr = entry + size;
2517 2511 INIT_LIST_HEAD(&ent->list);
2518 - list_add_tail_rcu(&ent->list, &kprobe_blacklist);
2512 + list_add_tail(&ent->list, &kprobe_blacklist);
2519 2513
2520 2514 return (int)size;
2521 2515 }
@@ -2609,8 +2603,8 @@ static void kprobe_remove_area_blacklist(unsigned long start, unsigned long end)
2609 2603 list_for_each_entry_safe(ent, n, &kprobe_blacklist, list) {
2610 2604 if (ent->start_addr < start || ent->start_addr >= end)
2611 2605 continue;
2612 - list_del_rcu(&ent->list);
2613 - kfree_rcu(ent, rcu);
2606 + list_del(&ent->list);
2607 + kfree(ent);
2614 2608 }
2615 2609 }
2616 2610
modified kernel/kthread.c
@@ -852,7 +852,7 @@ int kthread_affine_preferred(struct task_struct *p, const struct cpumask *mask)
852 852 if (!zalloc_cpumask_var(&affinity, GFP_KERNEL))
853 853 return -ENOMEM;
854 854
855 - kthread->preferred_affinity = kzalloc_obj(struct cpumask);
855 + kthread->preferred_affinity = kzalloc(sizeof(struct cpumask), GFP_KERNEL);
856 856 if (!kthread->preferred_affinity) {
857 857 ret = -ENOMEM;
858 858 goto out;
modified kernel/locking/lockdep.c
@@ -963,34 +963,6 @@ look_up_lock_class(const struct lockdep_map *lock, unsigned int subclass)
963 963 return NULL;
964 964 }
965 965
966 - static __always_inline bool lock_class_cache_is_valid(const struct lockdep_map *lock,
967 - const struct lock_class *class,
968 - unsigned int subclass)
969 - {
970 - unsigned int class_subclass;
971 -
972 - if (!class)
973 - return false;
974 -
975 - if (unlikely(class < lock_classes || class >= lock_classes + MAX_LOCKDEP_KEYS))
976 - return false;
977 -
978 - if (unlikely(!arch_test_bit(class - lock_classes, lock_classes_in_use)))
979 - return false;
980 -
981 - if (unlikely(!lock->key))
982 - return false;
983 -
984 - class_subclass = subclass ? subclass : class->subclass;
985 - if (unlikely(class_subclass >= MAX_LOCKDEP_SUBCLASSES))
986 - return false;
987 -
988 - if (unlikely(READ_ONCE(class->key) != lock->key->subkeys + class_subclass))
989 - return false;
990 -
991 - return true;
992 - }
993 -
994 966 /*
995 967 * Static locks do not have their class-keys yet - for them the key is
996 968 * the lock object itself. If the lock is in the per cpu area, the
@@ -1423,9 +1395,9 @@ out_unlock_set:
1423 1395
1424 1396 out_set_class_cache:
1425 1397 if (!subclass || force)
1426 - WRITE_ONCE(lock->class_cache[0], class);
1398 + lock->class_cache[0] = class;
1427 1399 else if (subclass < NR_LOCKDEP_CACHING_CLASSES)
1428 - WRITE_ONCE(lock->class_cache[subclass], class);
1400 + lock->class_cache[subclass] = class;
1429 1401
1430 1402 /*
1431 1403 * Hash collision, did we smoke some? We found a class with a matching
@@ -4985,7 +4957,7 @@ void lockdep_init_map_type(struct lockdep_map *lock, const char *name,
4985 4957 int i;
4986 4958
4987 4959 for (i = 0; i < NR_LOCKDEP_CACHING_CLASSES; i++)
4988 - WRITE_ONCE(lock->class_cache[i], NULL);
4960 + lock->class_cache[i] = NULL;
4989 4961
4990 4962 #ifdef CONFIG_LOCK_STAT
4991 4963 lock->cpu = raw_smp_processor_id();
@@ -5050,15 +5022,12 @@ EXPORT_SYMBOL_GPL(__lockdep_no_track__);
5050 5022 void lockdep_set_lock_cmp_fn(struct lockdep_map *lock, lock_cmp_fn cmp_fn,
5051 5023 lock_print_fn print_fn)
5052 5024 {
5053 - struct lock_class *class = READ_ONCE(lock->class_cache[0]);
5025 + struct lock_class *class = lock->class_cache[0];
5054 5026 unsigned long flags;
5055 5027
5056 5028 raw_local_irq_save(flags);
5057 5029 lockdep_recursion_inc();
5058 5030
5059 - if (!lock_class_cache_is_valid(lock, class, 0))
5060 - class = NULL;
5061 -
5062 5031 if (!class)
5063 5032 class = register_lock_class(lock, 0, 0);
5064 5033
@@ -5150,11 +5119,8 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
5150 5119 if (DEBUG_LOCKS_WARN_ON(subclass >= MAX_LOCKDEP_SUBCLASSES))
5151 5120 return 0;
5152 5121
5153 - if (subclass < NR_LOCKDEP_CACHING_CLASSES) {
5154 - class = READ_ONCE(lock->class_cache[subclass]);
5155 - if (!lock_class_cache_is_valid(lock, class, subclass))
5156 - class = NULL;
5157 - }
5122 + if (subclass < NR_LOCKDEP_CACHING_CLASSES)
5123 + class = lock->class_cache[subclass];
5158 5124 /*
5159 5125 * Not cached?
5160 5126 */
@@ -5358,9 +5324,9 @@ static noinstr int match_held_lock(const struct held_lock *hlock,
5358 5324 return 1;
5359 5325
5360 5326 if (hlock->references) {
5361 - const struct lock_class *class = READ_ONCE(lock->class_cache[0]);
5327 + const struct lock_class *class = lock->class_cache[0];
5362 5328
5363 - if (!lock_class_cache_is_valid(lock, class, 0))
5329 + if (!class)
5364 5330 class = look_up_lock_class(lock, 0);
5365 5331
5366 5332 /*
modified kernel/locking/rtmutex_api.c
@@ -423,7 +423,6 @@ int __sched rt_mutex_wait_proxy_lock(struct rt_mutex_base *lock,
423 423 {
424 424 int ret;
425 425
426 - rt_mutex_futex_pre_schedule();
427 426 raw_spin_lock_irq(&lock->wait_lock);
428 427 /* sleep on the mutex */
429 428 set_current_state(TASK_INTERRUPTIBLE);
@@ -434,7 +433,6 @@ int __sched rt_mutex_wait_proxy_lock(struct rt_mutex_base *lock,
434 433 */
435 434 fixup_rt_mutex_waiters(lock, true);
436 435 raw_spin_unlock_irq(&lock->wait_lock);
437 - rt_mutex_futex_post_schedule();
438 436
439 437 return ret;
440 438 }
modified kernel/sched/core.c
@@ -3742,17 +3742,11 @@ static inline void ttwu_do_wakeup(struct task_struct *p)
3742 3742
3743 3743 void update_rq_avg_idle(struct rq *rq)
3744 3744 {
3745 - u64 idle_stamp = rq->idle_stamp;
3746 - u64 delta, max;
3747 -
3748 - if (!idle_stamp)
3749 - return;
3750 -
3751 - delta = rq_clock(rq) - idle_stamp;
3745 + u64 delta = rq_clock(rq) - rq->idle_stamp;
3746 + u64 max = 2*rq->max_idle_balance_cost;
3752 3747
3753 3748 update_avg(&rq->avg_idle, delta);
3754 3749
3755 - max = 2 * rq->max_idle_balance_cost;
3756 3750 if (rq->avg_idle > max)
3757 3751 rq->avg_idle = max;
3758 3752 rq->idle_stamp = 0;
@@ -7643,17 +7637,6 @@ void rt_mutex_pre_schedule(void)
7643 7637 sched_submit_work(current);
7644 7638 }
7645 7639
7646 - /*
7647 - * Used within the futex syscall context, skips sched_submit_work() because none
7648 - * its work will be done. Asserts ensure that it is indeed the case.
7649 - */
7650 - void rt_mutex_futex_pre_schedule(void)
7651 - {
7652 - lockdep_assert(!(current->flags & (PF_WQ_WORKER | PF_IO_WORKER)));
7653 - lockdep_assert(!current->plug);
7654 - lockdep_assert(!fetch_and_set(current->sched_rt_mutex, 1));
7655 - }
7656 -
7657 7640 void rt_mutex_schedule(void)
7658 7641 {
7659 7642 lockdep_assert(current->sched_rt_mutex);
@@ -7666,11 +7649,6 @@ void rt_mutex_post_schedule(void)
7666 7649 lockdep_assert(fetch_and_set(current->sched_rt_mutex, 0));
7667 7650 }
7668 7651
7669 - void rt_mutex_futex_post_schedule(void)
7670 - {
7671 - lockdep_assert(fetch_and_set(current->sched_rt_mutex, 0));
7672 - }
7673 -
7674 7652 /*
7675 7653 * rt_mutex_setprio - set the current priority of a task
7676 7654 * @p: task to boost
modified kernel/sched/deadline.c
@@ -3028,8 +3028,8 @@ static struct task_struct *pick_next_pushable_dl_task(struct rq *rq)
3028 3028 next_node = rb_first_cached(&rq->dl.pushable_dl_tasks_root);
3029 3029 while (next_node) {
3030 3030 i = __node_2_pdl(next_node);
3031 - /* skip tasks that cannot be migrated */
3032 - if (!task_on_cpu(rq, i) && !is_migration_disabled(i)) {
3031 + /* make sure task isn't on_cpu (possible with proxy-exec) */
3032 + if (!task_on_cpu(rq, i)) {
3033 3033 p = i;
3034 3034 break;
3035 3035 }
modified kernel/sched/ext/cid.c
@@ -98,16 +98,16 @@ static struct scx_cid_tables *scx_cid_alloc_tables(void)
98 98 u32 npossible = num_possible_cpus();
99 99 struct scx_cid_tables *tbls;
100 100
101 - tbls = kzalloc_obj(*tbls);
101 + tbls = kzalloc_obj(*tbls, GFP_KERNEL);
102 102 if (!tbls)
103 103 return NULL;
104 104
105 - tbls->cid_to_cpu = kvzalloc_objs(*tbls->cid_to_cpu, npossible);
106 - tbls->cpu_to_cid = kvzalloc_objs(*tbls->cpu_to_cid, nr_cpu_ids);
107 - tbls->cid_to_shard = kvzalloc_objs(*tbls->cid_to_shard, npossible);
108 - tbls->shard_node = kvzalloc_objs(*tbls->shard_node, npossible);
109 - tbls->shard_ranges = kvzalloc_objs(*tbls->shard_ranges, npossible);
110 - tbls->topo = kvzalloc_objs(*tbls->topo, npossible);
105 + tbls->cid_to_cpu = kvcalloc(npossible, sizeof(*tbls->cid_to_cpu), GFP_KERNEL);
106 + tbls->cpu_to_cid = kvcalloc(nr_cpu_ids, sizeof(*tbls->cpu_to_cid), GFP_KERNEL);
107 + tbls->cid_to_shard = kvcalloc(npossible, sizeof(*tbls->cid_to_shard), GFP_KERNEL);
108 + tbls->shard_node = kvcalloc(npossible, sizeof(*tbls->shard_node), GFP_KERNEL);
109 + tbls->shard_ranges = kvcalloc(npossible, sizeof(*tbls->shard_ranges), GFP_KERNEL);
110 + tbls->topo = kvcalloc(npossible, sizeof(*tbls->topo), GFP_KERNEL);
111 111
112 112 if (!tbls->cid_to_cpu || !tbls->cpu_to_cid || !tbls->cid_to_shard ||
113 113 !tbls->shard_node || !tbls->shard_ranges || !tbls->topo) {
@@ -490,7 +490,7 @@ __bpf_kfunc void scx_bpf_cid_override(const s32 *cpu_to_cid__arena, u32 cpu_to_c
490 490 * region that arena fault recovery covers.
491 491 */
492 492 alloced = zalloc_cpumask_var(&seen, GFP_KERNEL);
493 - node_counts = kzalloc_objs(*node_counts, nr_node_ids);
493 + node_counts = kcalloc(nr_node_ids, sizeof(*node_counts), GFP_KERNEL);
494 494 if (cpu_to_cid_cnt == nr_cpu_ids)
495 495 cpu_to_cid = kmemdup(cpu_to_cid__arena, cpu_to_cid_cnt * sizeof(s32),
496 496 GFP_KERNEL);
modified kernel/sched/ext/ext.c
@@ -876,9 +876,9 @@ struct task_struct *scx_task_iter_next_locked(struct scx_task_iter *iter)
876 876 * unloading. The init_tasks ("swappers") should be excluded
877 877 * from the iteration because:
878 878 *
879 - * - It's unsafe to use __setscheduler_class() on an init_task
880 - * to determine the sched_class to use as it won't preserve
881 - * its idle_sched_class.
879 + * - It's unsafe to use __setschduler_prio() on an init_task to
880 + * determine the sched_class to use as it won't preserve its
881 + * idle_sched_class.
882 882 *
883 883 * - ops.init/exit_task() can easily be confused if called with
884 884 * init_tasks as they, e.g., share PID 0.
@@ -2806,8 +2806,6 @@ static void dispatch_to_local_dsq(struct scx_sched *sch, struct rq *rq,
2806 2806 * @p: task to finish dispatching
2807 2807 * @qseq_at_dispatch: qseq when @p started getting dispatched
2808 2808 * @dsq_id: destination DSQ ID
2809 - * @slice: slice carried by the insert verdict, 0 keeps the current value
2810 - * @vtime: vtime carried by the insert verdict, committed on PRIQ inserts
2811 2809 * @enq_flags: %SCX_ENQ_*
2812 2810 *
2813 2811 * Dispatching to local DSQs may need to wait for queueing to complete or
@@ -5449,7 +5447,7 @@ static ssize_t scx_attr_caps_show(struct kobject *kobj,
5449 5447 struct scx_sched *sch = container_of(kobj, struct scx_sched, kobj);
5450 5448 u32 npossible = num_possible_cpus();
5451 5449 struct scx_cmask *agg __free(kfree) =
5452 - kzalloc_flex(*agg, bits, SCX_CMASK_NR_WORDS(npossible));
5450 + kzalloc(struct_size(agg, bits, SCX_CMASK_NR_WORDS(npossible)), GFP_KERNEL);
5453 5451 unsigned long *agg_bm __free(bitmap) = bitmap_zalloc(npossible, GFP_KERNEL);
5454 5452 ssize_t count = 0;
5455 5453 s32 cap, si;
@@ -5516,7 +5514,7 @@ static const struct kset_uevent_ops scx_uevent_ops = {
5516 5514 };
5517 5515
5518 5516 /*
5519 - * Used by sched_fork() and __setscheduler_class() to pick the matching
5517 + * Used by sched_fork() and __setscheduler_prio() to pick the matching
5520 5518 * sched_class. dl/rt are already handled.
5521 5519 */
5522 5520 bool task_should_scx(int policy)
@@ -7696,7 +7694,7 @@ static void scx_root_enable_workfn(struct kthread_work *work)
7696 7694 /*
7697 7695 * Enable ops for every task. Fork is excluded by scx_fork_rwsem
7698 7696 * preventing new tasks from being added. No need to exclude tasks
7699 - * leaving as sched_ext_dead() can handle both prepped and enabled
7697 + * leaving as sched_ext_free() can handle both prepped and enabled
7700 7698 * tasks. Prep all tasks first and then enable them with preemption
7701 7699 * disabled.
7702 7700 *
@@ -7788,7 +7786,7 @@ static void scx_root_enable_workfn(struct kthread_work *work)
7788 7786
7789 7787 /*
7790 7788 * We're fully committed and can't fail. The task READY -> ENABLED
7791 - * transitions here are synchronized against sched_ext_dead() through
7789 + * transitions here are synchronized against sched_ext_free() through
7792 7790 * scx_tasks_lock.
7793 7791 */
7794 7792 percpu_down_write(&scx_fork_rwsem);
@@ -8081,7 +8079,6 @@ static int bpf_scx_check_member(const struct btf_type *t,
8081 8079 case offsetof(struct sched_ext_ops, cgroup_init):
8082 8080 case offsetof(struct sched_ext_ops, cgroup_exit):
8083 8081 case offsetof(struct sched_ext_ops, cgroup_prep_move):
8084 - case offsetof(struct sched_ext_ops, cgroup_set_bandwidth):
8085 8082 #endif
8086 8083 case offsetof(struct sched_ext_ops, cpu_online):
8087 8084 case offsetof(struct sched_ext_ops, cpu_offline):
@@ -9006,6 +9003,12 @@ static bool scx_dsq_move(struct bpf_iter_scx_dsq_kern *kit,
9006 9003 if (unlikely(READ_ONCE(sch->aborting)))
9007 9004 return false;
9008 9005
9006 + if (unlikely(!scx_task_on_sched(sch, p))) {
9007 + scx_error(sch, "scx_bpf_dsq_move[_vtime]() on %s[%d] but the task belongs to a different scheduler",
9008 + p->comm, p->pid);
9009 + return false;
9010 + }
9011 +
9009 9012 /*
9010 9013 * Can be called from either ops.dispatch() holding the dispatched rq's
9011 9014 * lock or any context where no rq lock is held. If latter, lock @p's
@@ -9037,17 +9040,6 @@ static bool scx_dsq_move(struct bpf_iter_scx_dsq_kern *kit,
9037 9040 goto out;
9038 9041 }
9039 9042
9040 - /*
9041 - * @p has been on $src_dsq and can't move anymore. If @p is not on @sch,
9042 - * the caller didn't have authority over @p at the time of the call.
9043 - */
9044 - if (unlikely(!scx_task_on_sched(sch, p))) {
9045 - scx_error(sch, "scx_bpf_dsq_move[_vtime]() on %s[%d] but the task belongs to a different scheduler",
9046 - p->comm, p->pid);
9047 - raw_spin_unlock(&src_dsq->lock);
9048 - goto out;
9049 - }
9050 -
9051 9043 /* @p is still on $src_dsq and stable, determine the destination */
9052 9044 dst_dsq = find_dsq_for_dispatch(sch, locked_rq ?: this_rq(), dsq_id, task_cpu(p));
9053 9045
@@ -9773,7 +9765,7 @@ __bpf_kfunc struct task_struct *bpf_iter_scx_dsq_next(struct bpf_iter_scx_dsq *i
9773 9765 * bpf_iter_scx_dsq_destroy - Destroy a DSQ iterator
9774 9766 * @it: iterator to destroy
9775 9767 *
9776 - * Undo bpf_iter_scx_dsq_new().
9768 + * Undo scx_iter_scx_dsq_new().
9777 9769 */
9778 9770 __bpf_kfunc void bpf_iter_scx_dsq_destroy(struct bpf_iter_scx_dsq *it)
9779 9771 {
@@ -11049,16 +11041,3 @@ static int __init scx_init(void)
11049 11041 return 0;
11050 11042 }
11051 11043 __initcall(scx_init);
11052 -
11053 - /*
11054 - * Compatibility markers for userspace. Existence of a marker function
11055 - * represents that the kernel supports that sched-ext feature.
11056 - */
11057 -
11058 - /*
11059 - * scx_compat_marker_cgroup_set_bandwidth_may_sleep: advertises that
11060 - * ops.cgroup_set_bandwidth() may be implemented as a sleepable callback.
11061 - */
11062 - #ifdef CONFIG_EXT_GROUP_SCHED
11063 - DEFINE_SCX_COMPAT_MARKER(cgroup_set_bandwidth_may_sleep);
11064 - #endif /* CONFIG_EXT_GROUP_SCHED */
modified kernel/sched/ext/internal.h
@@ -442,7 +442,7 @@ struct sched_ext_ops {
442 442 *
443 443 * Note that this callback may be called from a CPU other than the
444 444 * one the task is going to run on. This can happen when a task
445 - * property is changed (i.e., affinity), since set_next_task_scx(),
445 + * property is changed (i.e., affinity), since scx_next_task_scx(),
446 446 * which triggers this callback, may run on a CPU different from
447 447 * the task's assigned CPU.
448 448 *
@@ -753,7 +753,7 @@ struct sched_ext_ops {
753 753 * @burst_us: bandwidth control burst
754 754 *
755 755 * Update @cgrp's bandwidth control parameters. This is from the cpu.max
756 - * cgroup interface. This operation may block.
756 + * cgroup interface.
757 757 *
758 758 * @quota_us / @period_us determines the CPU bandwidth @cgrp is entitled
759 759 * to. For example, if @period_us is 1_000_000 and @quota_us is
@@ -2001,27 +2001,6 @@ struct scx_bstr_buf {
2001 2001 char line[SCX_EXIT_MSG_LEN];
2002 2002 };
2003 2003
2004 - /* Internal helper for DEFINE_SCX_COMPAT_MARKER(). */
2005 - #define DECLARE_SCX_COMPAT_MARKER(func) \
2006 - extern void scx_compat_marker_##func(void)
2007 -
2008 - /**
2009 - * DEFINE_SCX_COMPAT_MARKER() - define a userspace capability marker
2010 - * @func: marker suffix; the defined symbol is scx_compat_marker_@func
2011 - *
2012 - * Emit an empty, callerless function that is retained in the kernel's BTF.
2013 - * Its presence is part of the kernel<->userspace contract: userspace probes
2014 - * scx_compat_marker_@func (e.g. via BTF) to detect that this kernel supports
2015 - * the corresponding feature.
2016 - *
2017 - * The leading declaration suppresses the missing-prototype warning; the
2018 - * trailing declaration consumes the semicolon at the use site.
2019 - */
2020 - #define DEFINE_SCX_COMPAT_MARKER(func) \
2021 - DECLARE_SCX_COMPAT_MARKER(func); \
2022 - __used __retain void scx_compat_marker_##func(void) {} \
2023 - DECLARE_SCX_COMPAT_MARKER(func)
2024 -
2025 2004 extern struct scx_sched __rcu *scx_root;
2026 2005 DECLARE_PER_CPU(struct rq *, scx_locked_rq_state);
2027 2006
modified kernel/sched/ext/sub.c
@@ -194,7 +194,7 @@ s32 scx_alloc_pshards(struct scx_sched *sch)
194 194 shard_node = rcu_dereference_protected(scx_shard_node,
195 195 lockdep_is_held(&scx_enable_mutex));
196 196
197 - pshard = kzalloc_objs(pshard[0], scx_nr_cid_shards);
197 + pshard = kzalloc_objs(pshard[0], scx_nr_cid_shards, GFP_KERNEL);
198 198 if (!pshard)
199 199 return -ENOMEM;
200 200
modified kernel/sched/fair.c
@@ -6978,14 +6978,14 @@ static int tg_throttle_down(struct task_group *tg, void *data)
6978 6978 static bool throttle_cfs_rq(struct cfs_rq *cfs_rq)
6979 6979 {
6980 6980 struct cfs_bandwidth *cfs_b = tg_cfs_bandwidth(cfs_rq->tg);
6981 - struct sched_entity *curr = cfs_rq->h_curr;
6981 + struct sched_entity *curr = cfs_rq->curr;
6982 6982 struct rq *rq = rq_of(cfs_rq);
6983 6983
6984 6984 scoped_guard(raw_spinlock, &cfs_b->lock) {
6985 6985 u64 target_runtime = 1;
6986 6986
6987 6987 /*
6988 - * If cfs_rq->h_curr is still runnable, we are here from an
6988 + * If cfs_rq->curr is still runnable, we are here from an
6989 6989 * update_curr(). Request sysctl_sched_cfs_bandwidth_slice
6990 6990 * worth of bandwidth to continue running.
6991 6991 *
@@ -7192,7 +7192,7 @@ static bool distribute_cfs_runtime(struct cfs_bandwidth *cfs_b)
7192 7192 if (!list_empty(&cfs_rq->throttled_csd_list))
7193 7193 continue;
7194 7194
7195 - if (cfs_rq->h_curr) {
7195 + if (cfs_rq->curr) {
7196 7196 update_rq_clock(rq);
7197 7197 update_curr(cfs_rq);
7198 7198 }
@@ -10057,7 +10057,7 @@ again:
10057 10057
10058 10058 /* Might not have done put_prev_entity() */
10059 10059 if (cfs_rq->curr && cfs_rq->curr->on_rq)
10060 - update_curr_eevdf(cfs_rq);
10060 + update_curr(cfs_rq);
10061 10061
10062 10062 se = pick_next_entity(rq, true);
10063 10063 if (!se)
@@ -10160,7 +10160,7 @@ static void yield_task_fair(struct rq *rq)
10160 10160 /*
10161 10161 * Update run-time statistics of the 'current'.
10162 10162 */
10163 - update_curr_eevdf(cfs_rq);
10163 + update_curr(cfs_rq);
10164 10164 /*
10165 10165 * Tell update_rq_clock() that we've just updated,
10166 10166 * so we don't do microscopic update in schedule()
@@ -10691,40 +10691,17 @@ static enum llc_mig can_migrate_llc(int src_cpu, int dst_cpu,
10691 10691 return mig_llc;
10692 10692 }
10693 10693
10694 - static inline bool task_misfits_asym_cpu(struct lb_env *env, struct task_struct *p)
10695 - {
10696 - /*
10697 - * On asymmetric CPU capacity domains, do not let cache-aware
10698 - * balancing pull the task onto a destination CPU that cannot
10699 - * accommodate it. Doing so would turn the task into a misfit on
10700 - * the destination, trading a cache-locality gain for a capacity
10701 - * loss. If the task already does not fit its source CPU, the move
10702 - * cannot make things worse, so let the LLC preference decide.
10703 - */
10704 - if ((env->sd->flags & SD_ASYM_CPUCAPACITY) && p &&
10705 - !task_fits_cpu(p, env->dst_cpu) &&
10706 - task_fits_cpu(p, env->src_cpu))
10707 - return true;
10708 -
10709 - return false;
10710 - }
10711 -
10712 10694 /*
10713 10695 * Check if task p can migrate from source LLC to
10714 10696 * destination LLC in terms of cache aware load balance.
10715 10697 */
10716 - static enum llc_mig can_migrate_llc_task(struct lb_env *env,
10698 + static enum llc_mig can_migrate_llc_task(int src_cpu, int dst_cpu,
10717 10699 struct task_struct *p)
10718 10700 {
10719 10701 struct mm_struct *mm;
10720 10702 bool to_pref;
10721 - int cpu, src_cpu, dst_cpu;
10722 -
10723 - if (task_misfits_asym_cpu(env, p))
10724 - return mig_forbid;
10703 + int cpu;
10725 10704
10726 - src_cpu = env->src_cpu;
10727 - dst_cpu = env->dst_cpu;
10728 10705 mm = p->mm;
10729 10706 if (!mm)
10730 10707 return mig_unrestricted;
@@ -10781,14 +10758,6 @@ alb_break_llc(struct lb_env *env)
10781 10758 unsigned long util = 0;
10782 10759 struct task_struct *cur;
10783 10760
10784 - /*
10785 - * Migrating misfit tasks from current CPU
10786 - * to CPU with a better fit.
10787 - * Prioritize that over LLC preference.
10788 - */
10789 - if (env->migration_type == migrate_misfit)
10790 - return false;
10791 -
10792 10761 if (env->src_rq->nr_running <= 1)
10793 10762 return true;
10794 10763
@@ -10796,8 +10765,7 @@ alb_break_llc(struct lb_env *env)
10796 10765 if (cur && cur->sched_class == &fair_sched_class)
10797 10766 util = task_util(cur);
10798 10767
10799 - if (task_misfits_asym_cpu(env, cur) ||
10800 - can_migrate_llc(env->src_cpu, env->dst_cpu,
10768 + if (can_migrate_llc(env->src_cpu, env->dst_cpu,
10801 10769 util, false) == mig_forbid)
10802 10770 return true;
10803 10771 }
@@ -10837,7 +10805,8 @@ static bool migrate_degrades_llc(struct task_struct *p, struct lb_env *env)
10837 10805 READ_ONCE(p->preferred_llc) != llc_id(env->dst_cpu))
10838 10806 return true;
10839 10807
10840 - if (can_migrate_llc_task(env, p) != mig_forbid)
10808 + if (can_migrate_llc_task(env->src_cpu,
10809 + env->dst_cpu, p) != mig_forbid)
10841 10810 return false;
10842 10811
10843 10812 return true;
@@ -11900,15 +11869,6 @@ static inline bool llc_balance(struct lb_env *env, struct sg_lb_stats *sgs,
11900 11869 if (env->sd->flags & SD_SHARE_LLC)
11901 11870 return false;
11902 11871
11903 - /*
11904 - * On asymmetric domains, group_misfit_task_load
11905 - * should be prioritized to move tasks to CPU that fit them
11906 - * over aggregating tasks to their preferred LLC.
11907 - */
11908 - if ((env->sd->flags & SD_ASYM_CPUCAPACITY) &&
11909 - sgs->group_misfit_task_load)
11910 - return false;
11911 -
11912 11872 /*
11913 11873 * Skip cache aware tagging if nr_balanced_failed is sufficiently high.
11914 11874 * Threshold of cache_nice_tries is set to 1 higher than nr_balance_failed
modified kernel/sched/rt.c
@@ -1872,8 +1872,8 @@ static struct task_struct *pick_next_pushable_task(struct rq *rq)
1872 1872 return NULL;
1873 1873
1874 1874 plist_for_each_entry(i, head, pushable_tasks) {
1875 - /* skip tasks that cannot be migrated */
1876 - if (!task_on_cpu(rq, i) && !is_migration_disabled(i)) {
1875 + /* make sure task isn't on_cpu (possible with proxy-exec) */
1876 + if (!task_on_cpu(rq, i)) {
1877 1877 p = i;
1878 1878 break;
1879 1879 }
modified kernel/softirq.c
@@ -91,11 +91,11 @@ EXPORT_PER_CPU_SYMBOL_GPL(hardirq_context);
91 91
92 92 DEFINE_PER_CPU(unsigned long, local_interrupt_disable_state);
93 93
94 - void _local_interrupt_save_state(unsigned long flags)
94 + void _local_interrupt_disable(void)
95 95 {
96 - __local_interrupt_save_state(flags);
96 + __local_interrupt_disable();
97 97 }
98 - EXPORT_SYMBOL(_local_interrupt_save_state);
98 + EXPORT_SYMBOL(_local_interrupt_disable);
99 99
100 100 void _local_interrupt_enable(void)
101 101 {
@@ -749,7 +749,16 @@ static inline void __irq_exit_rcu(void)
749 749 #endif
750 750 account_hardirq_exit(current);
751 751 preempt_count_sub(HARDIRQ_OFFSET);
752 - if (!in_interrupt() && local_softirq_pending()) {
752 + /*
753 + * Interrupts may happen between hardirq_disable_enter() and
754 + * local_irq_save() in local_interrupt_disable(), if irq_exit() invokes
755 + * softirq here, we may have a softirq handler calling
756 + * local_interrupt_disable() but it won't disable the IRQ because
757 + * hardirq disabling count is already 1, hence we need to prevent
758 + * invoking softirq when a local_interrupt_disable() is ongoing.
759 + */
760 + if (!in_interrupt() && !hardirq_disable_count() &&
761 + local_softirq_pending()) {
753 762 /*
754 763 * If we left hrtimers unarmed, make sure to arm them now,
755 764 * before enabling interrupts to run softirq.
modified kernel/trace/fprobe.c
@@ -945,7 +945,7 @@ int register_fprobe(struct fprobe *fp, const char *filter, const char *notfilter
945 945 if (num < 0)
946 946 return num;
947 947
948 - addrs = kzalloc_objs(*addrs, num);
948 + addrs = kcalloc(num, sizeof(*addrs), GFP_KERNEL);
949 949 if (!addrs)
950 950 return -ENOMEM;
951 951
modified kernel/trace/ftrace.c
@@ -75,8 +75,6 @@
75 75 .func_hash = &opsname.local_hash, \
76 76 .local_hash.regex_lock = __MUTEX_INITIALIZER(opsname.local_hash.regex_lock), \
77 77 .subop_list = LIST_HEAD_INIT(opsname.subop_list),
78 - /* Used only to synchronize the initialization of ftrace_ops */
79 - static DEFINE_MUTEX(ops_mutex);
80 78 #else
81 79 #define INIT_OPS_HASH(opsname)
82 80 #endif
@@ -161,18 +159,11 @@ const struct ftrace_ops ftrace_nop_ops = {
161 159 static inline void ftrace_ops_init(struct ftrace_ops *ops)
162 160 {
163 161 #ifdef CONFIG_DYNAMIC_FTRACE
164 - unsigned long flags = smp_load_acquire(&ops->flags);
165 -
166 - if (!(flags & FTRACE_OPS_FL_INITIALIZED)) {
167 - guard(mutex)(&ops_mutex);
168 - /* Could have been initialized before lock taken */
169 - if (unlikely(ops->flags & FTRACE_OPS_FL_INITIALIZED))
170 - return;
162 + if (!(ops->flags & FTRACE_OPS_FL_INITIALIZED)) {
171 163 mutex_init(&ops->local_hash.regex_lock);
172 164 INIT_LIST_HEAD(&ops->subop_list);
173 165 ops->func_hash = &ops->local_hash;
174 - flags = ops->flags | FTRACE_OPS_FL_INITIALIZED;
175 - smp_store_release(&ops->flags, flags);
166 + ops->flags |= FTRACE_OPS_FL_INITIALIZED;
176 167 }
177 168 #endif
178 169 }
@@ -4686,8 +4677,7 @@ ftrace_avail_addrs_open(struct inode *inode, struct file *file)
4686 4677
4687 4678 /**
4688 4679 * ftrace_regex_open - initialize function tracer filter files
4689 - * @tr: The trace_array that holds the ftrace_ops [optional]
4690 - * @ops: The ftrace_ops that hold the hash filters [optional]
4680 + * @ops: The ftrace_ops that hold the hash filters
4691 4681 * @flag: The type of filter to process
4692 4682 * @inode: The inode, usually passed in to your open routine
4693 4683 * @file: The file, usually passed in to your open routine
@@ -4701,45 +4691,26 @@ ftrace_avail_addrs_open(struct inode *inode, struct file *file)
4701 4691 * tracing_lseek() should be used as the lseek routine, and
4702 4692 * release must call ftrace_regex_release().
4703 4693 *
4704 - * Note, If @tr is not NULL, its reference has to be taken before
4705 - * @ops may be referenced.
4706 - * If @ops is NULL and @tr is not, then @tr->ops is used.
4707 - * If @tr is NULL and @ops is not then @ops->private is uesd for @tr.
4708 - * If both @tr and @ops are NULL, then the &global_ops is
4709 - * to be used, and @tr will be the global_ops.private pointer.
4710 - *
4711 4694 * Returns: 0 on success or a negative errno value on failure
4712 4695 */
4713 4696 int
4714 - ftrace_regex_open(struct trace_array *tr, struct ftrace_ops *ops, int flag,
4697 + ftrace_regex_open(struct ftrace_ops *ops, int flag,
4715 4698 struct inode *inode, struct file *file)
4716 4699 {
4717 - struct ftrace_iterator *iter = NULL;
4700 + struct ftrace_iterator *iter;
4718 4701 struct ftrace_hash *hash;
4719 4702 struct list_head *mod_head;
4720 - int ret = -ENODEV;
4703 + struct trace_array *tr = ops->private;
4704 + int ret = -ENOMEM;
4705 +
4706 + ftrace_ops_init(ops);
4721 4707
4722 4708 if (unlikely(ftrace_disabled))
4723 4709 return -ENODEV;
4724 4710
4725 - if (!tr) {
4726 - if (!ops)
4727 - ops = &global_ops;
4728 - tr = ops->private;
4729 - }
4730 -
4731 4711 if (tracing_check_open_get_tr(tr))
4732 4712 return -ENODEV;
4733 4713
4734 - if (!ops)
4735 - ops = tr->ops;
4736 -
4737 - if (WARN_ON_ONCE(!ops))
4738 - goto out;
4739 -
4740 - ftrace_ops_init(ops);
4741 -
4742 - ret = -ENOMEM;
4743 4714 iter = kzalloc_obj(*iter);
4744 4715 if (!iter)
4745 4716 goto out;
@@ -4817,19 +4788,21 @@ ftrace_regex_open(struct trace_array *tr, struct ftrace_ops *ops, int flag,
4817 4788 static int
4818 4789 ftrace_filter_open(struct inode *inode, struct file *file)
4819 4790 {
4820 - struct trace_array *tr = inode->i_private;
4791 + struct ftrace_ops *ops = inode->i_private;
4821 4792
4822 - return ftrace_regex_open(tr, NULL,
4823 - FTRACE_ITER_FILTER | FTRACE_ITER_DO_PROBES,
4824 - inode, file);
4793 + /* Checks for tracefs lockdown */
4794 + return ftrace_regex_open(ops,
4795 + FTRACE_ITER_FILTER | FTRACE_ITER_DO_PROBES,
4796 + inode, file);
4825 4797 }
4826 4798
4827 4799 static int
4828 4800 ftrace_notrace_open(struct inode *inode, struct file *file)
4829 4801 {
4830 - struct trace_array *tr = inode->i_private;
4802 + struct ftrace_ops *ops = inode->i_private;
4831 4803
4832 - return ftrace_regex_open(tr, NULL, FTRACE_ITER_NOTRACE,
4804 + /* Checks for tracefs lockdown */
4805 + return ftrace_regex_open(ops, FTRACE_ITER_NOTRACE,
4833 4806 inode, file);
4834 4807 }
4835 4808
@@ -7519,15 +7492,15 @@ static const struct file_operations ftrace_graph_notrace_fops = {
7519 7492 };
7520 7493 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
7521 7494
7522 - void ftrace_create_filter_files(struct trace_array *tr,
7495 + void ftrace_create_filter_files(struct ftrace_ops *ops,
7523 7496 struct dentry *parent)
7524 7497 {
7525 7498
7526 7499 trace_create_file("set_ftrace_filter", TRACE_MODE_WRITE, parent,
7527 - tr, &ftrace_filter_fops);
7500 + ops, &ftrace_filter_fops);
7528 7501
7529 7502 trace_create_file("set_ftrace_notrace", TRACE_MODE_WRITE, parent,
7530 - tr, &ftrace_notrace_fops);
7503 + ops, &ftrace_notrace_fops);
7531 7504 }
7532 7505
7533 7506 /*
@@ -7552,6 +7525,7 @@ void ftrace_destroy_filter_files(struct ftrace_ops *ops)
7552 7525
7553 7526 static __init int ftrace_init_dyn_tracefs(struct dentry *d_tracer)
7554 7527 {
7528 +
7555 7529 trace_create_file("available_filter_functions", TRACE_MODE_READ,
7556 7530 d_tracer, NULL, &ftrace_avail_fops);
7557 7531
@@ -7564,7 +7538,7 @@ static __init int ftrace_init_dyn_tracefs(struct dentry *d_tracer)
7564 7538 trace_create_file("touched_functions", TRACE_MODE_READ,
7565 7539 d_tracer, NULL, &ftrace_touched_fops);
7566 7540
7567 - ftrace_create_filter_files(NULL, d_tracer);
7541 + ftrace_create_filter_files(&global_ops, d_tracer);
7568 7542
7569 7543 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
7570 7544 trace_create_file("set_graph_function", TRACE_MODE_WRITE, d_tracer,
modified kernel/trace/ring_buffer.c
@@ -330,14 +330,6 @@ struct buffer_data_read_page {
330 330 struct buffer_data_page *data; /* actual data, stored in this page */
331 331 };
332 332
333 - static __always_inline unsigned int rb_read_page_capacity(struct buffer_data_read_page *rpage)
334 - {
335 - return (PAGE_SIZE << rpage->order) - BUF_PAGE_HDR_SIZE;
336 - }
337 -
338 - /* The number of bits for static buffer ids */
339 - #define RB_STATIC_BITS 30
340 -
341 333 /*
342 334 * Note, the buffer_page list must be first. The buffer pages
343 335 * are allocated in cache lines, which means that each buffer
@@ -353,7 +345,7 @@ struct buffer_page {
353 345 local_t entries; /* entries on this page */
354 346 unsigned long real_end; /* real end of data */
355 347 unsigned order; /* order of the page */
356 - u32 id:RB_STATIC_BITS; /* ID for external mapping */
348 + u32 id:30; /* ID for external mapping */
357 349 u32 range:1; /* Mapped via a range */
358 350 struct buffer_data_page *page; /* Actual data page */
359 351 };
@@ -660,15 +652,6 @@ static bool rb_is_static(struct ring_buffer_per_cpu *cpu_buffer)
660 652 return cpu_buffer->user_mapped || cpu_buffer->remote || cpu_buffer->ring_meta;
661 653 }
662 654
663 - static unsigned long rb_static_max_pages(void)
664 - {
665 - /*
666 - * Static ring buffers are using bpage::id and must account for the
667 - * reader page.
668 - */
669 - return (1UL << RB_STATIC_BITS) - 1;
670 - }
671 -
672 655 struct ring_buffer_iter {
673 656 struct ring_buffer_per_cpu *cpu_buffer;
674 657 unsigned long head;
@@ -1686,7 +1669,7 @@ out_locked:
1686 1669 * This is used to help find the next per cpu subbuffer within a mapped range.
1687 1670 */
1688 1671 static unsigned long
1689 - rb_range_align_subbuf(unsigned long addr, unsigned int subbuf_size, unsigned long nr_subbufs)
1672 + rb_range_align_subbuf(unsigned long addr, int subbuf_size, int nr_subbufs)
1690 1673 {
1691 1674 addr += sizeof(struct ring_buffer_cpu_meta) +
1692 1675 sizeof(int) * nr_subbufs;
@@ -1696,12 +1679,13 @@ rb_range_align_subbuf(unsigned long addr, unsigned int subbuf_size, unsigned lon
1696 1679 /*
1697 1680 * Return the ring_buffer_meta for a given @cpu.
1698 1681 */
1699 - static void *rb_range_meta(struct trace_buffer *buffer, unsigned long nr_pages, int cpu)
1682 + static void *rb_range_meta(struct trace_buffer *buffer, int nr_pages, int cpu)
1700 1683 {
1701 - unsigned int subbuf_size = rb_subbuf_size(buffer);
1684 + int subbuf_size = rb_subbuf_size(buffer);
1702 1685 struct ring_buffer_cpu_meta *meta;
1703 1686 struct ring_buffer_meta *bmeta;
1704 - unsigned long ptr, nr_subbufs;
1687 + unsigned long ptr;
1688 + int nr_subbufs;
1705 1689
1706 1690 bmeta = buffer->meta;
1707 1691 if (!bmeta)
@@ -1747,7 +1731,7 @@ static void *rb_range_meta(struct trace_buffer *buffer, unsigned long nr_pages,
1747 1731 /* Return the start of subbufs given the meta pointer */
1748 1732 static void *rb_subbufs_from_meta(struct ring_buffer_cpu_meta *meta)
1749 1733 {
1750 - unsigned int subbuf_size = meta->subbuf_size;
1734 + int subbuf_size = meta->subbuf_size;
1751 1735 unsigned long ptr;
1752 1736
1753 1737 ptr = (unsigned long)meta;
@@ -1759,11 +1743,11 @@ static void *rb_subbufs_from_meta(struct ring_buffer_cpu_meta *meta)
1759 1743 /*
1760 1744 * Return a specific sub-buffer for a given @cpu defined by @idx.
1761 1745 */
1762 - static void *rb_range_buffer(struct ring_buffer_per_cpu *cpu_buffer, unsigned long idx)
1746 + static void *rb_range_buffer(struct ring_buffer_per_cpu *cpu_buffer, int idx)
1763 1747 {
1764 1748 struct ring_buffer_cpu_meta *meta;
1765 - unsigned int subbuf_size;
1766 1749 unsigned long ptr;
1750 + int subbuf_size;
1767 1751
1768 1752 meta = rb_range_meta(cpu_buffer->buffer, 0, cpu_buffer->cpu);
1769 1753 if (!meta)
@@ -1779,7 +1763,7 @@ static void *rb_range_buffer(struct ring_buffer_per_cpu *cpu_buffer, unsigned lo
1779 1763
1780 1764 ptr = (unsigned long)rb_subbufs_from_meta(meta);
1781 1765
1782 - ptr += (unsigned long)subbuf_size * idx;
1766 + ptr += subbuf_size * idx;
1783 1767 if (ptr + subbuf_size > cpu_buffer->buffer->range_addr_end)
1784 1768 return NULL;
1785 1769
@@ -1856,12 +1840,13 @@ static bool rb_meta_init(struct trace_buffer *buffer, int scratch_size)
1856 1840 * must be the same.
1857 1841 */
1858 1842 static bool rb_cpu_meta_valid(struct ring_buffer_cpu_meta *meta, int cpu,
1859 - struct trace_buffer *buffer, unsigned long nr_pages,
1843 + struct trace_buffer *buffer, int nr_pages,
1860 1844 unsigned long *subbuf_mask)
1861 1845 {
1846 + int subbuf_size = PAGE_SIZE;
1862 1847 unsigned long buffers_start;
1863 1848 unsigned long buffers_end;
1864 - unsigned long i;
1849 + int i;
1865 1850
1866 1851 if (!subbuf_mask)
1867 1852 return false;
@@ -1871,13 +1856,8 @@ static bool rb_cpu_meta_valid(struct ring_buffer_cpu_meta *meta, int cpu,
1871 1856 return false;
1872 1857 }
1873 1858
1874 - if (meta->nr_subbufs != nr_pages + 1) {
1875 - pr_info("Ring buffer boot meta [%d] invalid nr_subbufs\n", cpu);
1876 - return false;
1877 - }
1878 -
1879 1859 buffers_start = meta->first_buffer;
1880 - buffers_end = meta->first_buffer + (meta->nr_subbufs * PAGE_SIZE);
1860 + buffers_end = meta->first_buffer + (subbuf_size * meta->nr_subbufs);
1881 1861
1882 1862 /* Is the head and commit buffers within the range of buffers? */
1883 1863 if (meta->head_buffer < buffers_start ||
@@ -2115,8 +2095,8 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)
2115 2095 struct buffer_page *head_page, *orig_head, *orig_reader;
2116 2096 struct rb_validation_state state = { 0 };
2117 2097 bool skip = false;
2118 - unsigned long i;
2119 2098 int ret;
2099 + int i;
2120 2100
2121 2101 if (!meta || !meta->head_buffer)
2122 2102 return;
@@ -2167,7 +2147,7 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)
2167 2147 rb_validate_buffer(head_page, cpu_buffer, meta, &state, 0, state.ts);
2168 2148 }
2169 2149 if (i)
2170 - pr_info("Ring buffer [%d] rewound %lu pages\n", cpu_buffer->cpu, i);
2150 + pr_info("Ring buffer [%d] rewound %d pages\n", cpu_buffer->cpu, i);
2171 2151
2172 2152 /* The last rewound page must be skipped. */
2173 2153 if (head_page != orig_head)
@@ -2251,8 +2231,7 @@ static void rb_meta_validate_events(struct ring_buffer_per_cpu *cpu_buffer)
2251 2231 }
2252 2232 }
2253 2233
2254 - static void rb_range_meta_init(struct trace_buffer *buffer, unsigned long nr_pages,
2255 - int scratch_size)
2234 + static void rb_range_meta_init(struct trace_buffer *buffer, int nr_pages, int scratch_size)
2256 2235 {
2257 2236 struct ring_buffer_cpu_meta *meta;
2258 2237 unsigned long *subbuf_mask;
@@ -2352,8 +2331,8 @@ static int rbm_show(struct seq_file *m, void *v)
2352 2331 rb_meta_subbuf_idx(meta, (void *)meta->head_buffer));
2353 2332 seq_printf(m, "commit_buffer: %d\n",
2354 2333 rb_meta_subbuf_idx(meta, (void *)meta->commit_buffer));
2355 - seq_printf(m, "subbuf_size: %u\n", meta->subbuf_size);
2356 - seq_printf(m, "nr_subbufs: %u\n", meta->nr_subbufs);
2334 + seq_printf(m, "subbuf_size: %d\n", meta->subbuf_size);
2335 + seq_printf(m, "nr_subbufs: %d\n", meta->nr_subbufs);
2357 2336 return 0;
2358 2337 }
2359 2338
@@ -2438,7 +2417,7 @@ static void *ring_buffer_desc_page(struct ring_buffer_desc *desc, unsigned int p
2438 2417 }
2439 2418
2440 2419 static int __rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer,
2441 - unsigned long nr_pages, struct list_head *pages)
2420 + long nr_pages, struct list_head *pages)
2442 2421 {
2443 2422 struct trace_buffer *buffer = cpu_buffer->buffer;
2444 2423 struct ring_buffer_cpu_meta *meta = NULL;
@@ -2566,7 +2545,7 @@ static int rb_allocate_pages(struct ring_buffer_per_cpu *cpu_buffer,
2566 2545 }
2567 2546
2568 2547 static struct ring_buffer_per_cpu *
2569 - rb_allocate_cpu_buffer(struct trace_buffer *buffer, unsigned long nr_pages, int cpu)
2548 + rb_allocate_cpu_buffer(struct trace_buffer *buffer, long nr_pages, int cpu)
2570 2549 {
2571 2550 struct ring_buffer_per_cpu *cpu_buffer __free(kfree) =
2572 2551 alloc_cpu_buffer(cpu);
@@ -2621,8 +2600,8 @@ rb_allocate_cpu_buffer(struct trace_buffer *buffer, unsigned long nr_pages, int
2621 2600 cpu_buffer->remote = buffer->remote;
2622 2601 cpu_buffer->meta_page = (struct trace_buffer_meta *)(void *)desc->meta_va;
2623 2602 cpu_buffer->nr_pages = nr_pages;
2624 - cpu_buffer->subbuf_ids = kzalloc_objs(*cpu_buffer->subbuf_ids,
2625 - cpu_buffer->nr_pages + 1);
2603 + cpu_buffer->subbuf_ids = kcalloc(cpu_buffer->nr_pages + 1,
2604 + sizeof(*cpu_buffer->subbuf_ids), GFP_KERNEL);
2626 2605 if (!cpu_buffer->subbuf_ids)
2627 2606 goto fail_free_reader;
2628 2607
@@ -2723,8 +2702,8 @@ static void rb_test_inject_invalid_pages(struct trace_buffer *buffer)
2723 2702 struct ring_buffer_cpu_meta *meta;
2724 2703 struct buffer_data_page *dpage;
2725 2704 unsigned long entry_bytes = 0;
2726 - unsigned int subbuf_size;
2727 2705 unsigned long ptr;
2706 + int subbuf_size;
2728 2707 int invalid = 0;
2729 2708 int cpu;
2730 2709 int i;
@@ -2794,8 +2773,8 @@ static struct trace_buffer *alloc_buffer(unsigned long size, unsigned flags,
2794 2773 struct ring_buffer_remote *remote)
2795 2774 {
2796 2775 struct trace_buffer *buffer __free(kfree) = NULL;
2797 - unsigned int subbuf_size;
2798 - unsigned long nr_pages;
2776 + long nr_pages;
2777 + int subbuf_size;
2799 2778 int bsize;
2800 2779 int cpu;
2801 2780 int ret;
@@ -2849,8 +2828,6 @@ static struct trace_buffer *alloc_buffer(unsigned long size, unsigned flags,
2849 2828 size = end - buffers_start;
2850 2829 size = size / nr_cpu_ids;
2851 2830
2852 - if (size < sizeof(struct ring_buffer_cpu_meta))
2853 - goto fail_free_buffers;
2854 2831 /*
2855 2832 * The number of sub-buffers (nr_pages) is determined by the
2856 2833 * total size allocated minus the meta data size.
@@ -2860,10 +2837,6 @@ static struct trace_buffer *alloc_buffer(unsigned long size, unsigned flags,
2860 2837 */
2861 2838 nr_pages = (size - sizeof(struct ring_buffer_cpu_meta)) /
2862 2839 (subbuf_size + sizeof(int));
2863 -
2864 - if (nr_pages > rb_static_max_pages())
2865 - goto fail_free_buffers;
2866 -
2867 2840 /* Need at least two pages plus the reader page */
2868 2841 if (nr_pages < 3)
2869 2842 goto fail_free_buffers;
@@ -2896,10 +2869,6 @@ static struct trace_buffer *alloc_buffer(unsigned long size, unsigned flags,
2896 2869 /* The writer is remote. This ring-buffer is read-only */
2897 2870 atomic_inc(&buffer->record_disabled);
2898 2871 nr_pages = desc->nr_page_va - 1;
2899 -
2900 - if (nr_pages > rb_static_max_pages())
2901 - goto fail_free_buffers;
2902 -
2903 2872 if (nr_pages < 2)
2904 2873 goto fail_free_buffers;
2905 2874 } else {
@@ -5884,12 +5853,12 @@ __rb_get_reader_page_from_remote(struct ring_buffer_per_cpu *cpu_buffer)
5884 5853 static struct buffer_page *
5885 5854 __rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
5886 5855 {
5887 - unsigned long max_loops = cpu_buffer->ring_meta ? cpu_buffer->nr_pages : 3;
5856 + int max_loops = cpu_buffer->ring_meta ? cpu_buffer->nr_pages : 3;
5888 5857 struct buffer_page *reader = NULL;
5889 - unsigned long nr_loops = 0;
5890 5858 unsigned long overwrite;
5891 5859 unsigned long flags;
5892 5860 int missed_events = 0;
5861 + int nr_loops = 0;
5893 5862 bool ret;
5894 5863
5895 5864 local_irq_save(flags);
@@ -6207,8 +6176,8 @@ rb_iter_peek(struct ring_buffer_iter *iter, u64 *ts)
6207 6176 struct trace_buffer *buffer;
6208 6177 struct ring_buffer_per_cpu *cpu_buffer;
6209 6178 struct ring_buffer_event *event;
6210 - unsigned long nr_loops = 0;
6211 - unsigned long max_loops;
6179 + int nr_loops = 0;
6180 + int max_loops;
6212 6181
6213 6182 if (ts)
6214 6183 *ts = 0;
@@ -7024,78 +6993,56 @@ EXPORT_SYMBOL_GPL(ring_buffer_swap_cpu);
7024 6993 * ring_buffer_alloc_read_page - allocate a page to read from buffer
7025 6994 * @buffer: the buffer to allocate for.
7026 6995 * @cpu: the cpu buffer to allocate.
7027 - * @rpage: pointer to pass in an already allocated page (can be NULL)
7028 - * and returns the allocated page.
7029 6996 *
7030 - * This function is used in conjunction with ring_buffer_read_page().
6997 + * This function is used in conjunction with ring_buffer_read_page.
7031 6998 * When reading a full page from the ring buffer, these functions
7032 6999 * can be used to speed up the process. The calling function should
7033 7000 * allocate a few pages first with this function. Then when it
7034 7001 * needs to get pages from the ring buffer, it passes the result
7035 - * of this function into ring_buffer_read_page(), which will swap
7002 + * of this function into ring_buffer_read_page, which will swap
7036 7003 * the page that was allocated, with the read page of the buffer.
7037 7004 *
7038 - * If @rpage is provided, and it has a different order than the current
7039 - * subbuffer order, its payload will be freed and re-allocated. If it
7040 - * already matches the order, it is simply returned.
7041 - *
7042 7005 * Returns:
7043 - * 0 on success, < 0 on error
7006 + * The page allocated, or ERR_PTR
7044 7007 */
7045 - int ring_buffer_alloc_read_page(struct trace_buffer *buffer, int cpu,
7046 - struct buffer_data_read_page **rpage)
7008 + struct buffer_data_read_page *
7009 + ring_buffer_alloc_read_page(struct trace_buffer *buffer, int cpu)
7047 7010 {
7048 7011 struct ring_buffer_per_cpu *cpu_buffer;
7012 + struct buffer_data_read_page *bpage = NULL;
7049 7013 unsigned long flags;
7050 - unsigned int order;
7051 7014
7052 7015 if (!cpumask_test_cpu(cpu, buffer->cpumask))
7053 - return -ENODEV;
7054 -
7055 - if (!rpage)
7056 - return -EINVAL;
7057 -
7058 - order = READ_ONCE(buffer->subbuf_order);
7059 -
7060 - if (*rpage) {
7061 - if ((*rpage)->order == order)
7062 - return 0;
7016 + return ERR_PTR(-ENODEV);
7063 7017
7064 - /* We can reuse rpage, but we discard the payload */
7065 - free_pages((unsigned long)(*rpage)->data, (*rpage)->order);
7066 - (*rpage)->data = NULL;
7067 - } else {
7068 - *rpage = kzalloc_obj(**rpage);
7069 - if (!*rpage)
7070 - return -ENOMEM;
7071 - }
7018 + bpage = kzalloc_obj(*bpage);
7019 + if (!bpage)
7020 + return ERR_PTR(-ENOMEM);
7072 7021
7073 - (*rpage)->order = order;
7022 + bpage->order = buffer->subbuf_order;
7074 7023 cpu_buffer = buffer->buffers[cpu];
7075 -
7076 7024 local_irq_save(flags);
7077 7025 arch_spin_lock(&cpu_buffer->lock);
7078 7026
7079 7027 if (cpu_buffer->free_page.data) {
7080 - **rpage = cpu_buffer->free_page;
7028 + *bpage = cpu_buffer->free_page;
7081 7029 cpu_buffer->free_page.data = NULL;
7082 7030 }
7083 7031
7084 7032 arch_spin_unlock(&cpu_buffer->lock);
7085 7033 local_irq_restore(flags);
7086 7034
7087 - if ((*rpage)->data) {
7088 - rb_init_data_page((*rpage)->data);
7035 + if (bpage->data) {
7036 + rb_init_data_page(bpage->data);
7089 7037 } else {
7090 - (*rpage)->data = alloc_cpu_data(cpu, (*rpage)->order);
7091 - if (!(*rpage)->data) {
7092 - kfree(*rpage);
7093 - *rpage = NULL;
7094 - return -ENOMEM;
7038 + bpage->data = alloc_cpu_data(cpu, bpage->order);
7039 + if (!bpage->data) {
7040 + kfree(bpage);
7041 + return ERR_PTR(-ENOMEM);
7095 7042 }
7096 7043 }
7097 7044
7098 - return 0;
7045 + return bpage;
7099 7046 }
7100 7047 EXPORT_SYMBOL_GPL(ring_buffer_alloc_read_page);
7101 7048
@@ -7103,30 +7050,21 @@ EXPORT_SYMBOL_GPL(ring_buffer_alloc_read_page);
7103 7050 * ring_buffer_free_read_page - free an allocated read page
7104 7051 * @buffer: the buffer the page was allocate for
7105 7052 * @cpu: the cpu buffer the page came from
7106 - * @rpage: the buffer_data_read_page to free
7053 + * @data_page: the page to free
7107 7054 *
7108 7055 * Free a page allocated from ring_buffer_alloc_read_page.
7109 7056 */
7110 7057 void ring_buffer_free_read_page(struct trace_buffer *buffer, int cpu,
7111 - struct buffer_data_read_page *rpage)
7058 + struct buffer_data_read_page *data_page)
7112 7059 {
7113 7060 struct ring_buffer_per_cpu *cpu_buffer;
7114 - struct buffer_data_page *dpage;
7061 + struct buffer_data_page *dpage = data_page->data;
7062 + struct page *page = virt_to_page(dpage);
7115 7063 unsigned long flags;
7116 - struct page *page;
7117 7064
7118 7065 if (!buffer || !buffer->buffers || !buffer->buffers[cpu])
7119 7066 return;
7120 7067
7121 - if (!rpage)
7122 - return;
7123 -
7124 - dpage = rpage->data;
7125 - if (!dpage)
7126 - goto out;
7127 -
7128 - page = virt_to_page(dpage);
7129 -
7130 7068 cpu_buffer = buffer->buffers[cpu];
7131 7069
7132 7070 /*
@@ -7134,14 +7072,14 @@ void ring_buffer_free_read_page(struct trace_buffer *buffer, int cpu,
7134 7072 * is different from the subbuffer order of the buffer -
7135 7073 * we can't reuse it
7136 7074 */
7137 - if (page_ref_count(page) > 1 || rpage->order != READ_ONCE(buffer->subbuf_order))
7075 + if (page_ref_count(page) > 1 || data_page->order != buffer->subbuf_order)
7138 7076 goto out;
7139 7077
7140 7078 local_irq_save(flags);
7141 7079 arch_spin_lock(&cpu_buffer->lock);
7142 7080
7143 7081 if (!cpu_buffer->free_page.data) {
7144 - cpu_buffer->free_page = *rpage;
7082 + cpu_buffer->free_page = *data_page;
7145 7083 dpage = NULL;
7146 7084 }
7147 7085
@@ -7149,8 +7087,8 @@ void ring_buffer_free_read_page(struct trace_buffer *buffer, int cpu,
7149 7087 local_irq_restore(flags);
7150 7088
7151 7089 out:
7152 - free_pages((unsigned long)dpage, rpage->order);
7153 - kfree(rpage);
7090 + free_pages((unsigned long)dpage, data_page->order);
7091 + kfree(data_page);
7154 7092 }
7155 7093 EXPORT_SYMBOL_GPL(ring_buffer_free_read_page);
7156 7094
@@ -7221,10 +7159,11 @@ int ring_buffer_read_page(struct trace_buffer *buffer,
7221 7159 if (!dpage)
7222 7160 return -1;
7223 7161
7224 - len = min_t(size_t, len, rb_read_page_capacity(data_page));
7225 -
7226 7162 guard(raw_spinlock_irqsave)(&cpu_buffer->reader_lock);
7227 7163
7164 + if (data_page->order != cpu_buffer->reader_page->order)
7165 + return -1;
7166 +
7228 7167 reader = rb_get_reader_page(cpu_buffer);
7229 7168 if (!reader)
7230 7169 return -1;
@@ -7238,26 +7177,31 @@ int ring_buffer_read_page(struct trace_buffer *buffer,
7238 7177 /* Check if any events were dropped */
7239 7178 missed_events = cpu_buffer->lost_events;
7240 7179
7241 - /*
7242 - * It is not possible to swap the reader page if:
7243 - * - It has been partially read
7244 - * - len is not big enough to read it entirely
7245 - * - A writer is still on it
7246 - * - The ring buffer is static
7247 - * - The order doesn't match
7248 - */
7180 + /*
7181 + * If this page has been partially read or
7182 + * if len is not big enough to read the rest of the page or
7183 + * a writer is still on the page, then
7184 + * we must copy the data from the page to the buffer.
7185 + * Otherwise, we can simply swap the page with the one passed in.
7186 + */
7249 7187 if (read || (len < (size - read)) ||
7250 7188 cpu_buffer->reader_page == cpu_buffer->commit_page ||
7251 - rb_is_static(cpu_buffer) ||
7252 - data_page->order != reader->order) {
7189 + rb_is_static(cpu_buffer)) {
7253 7190 struct buffer_data_page *rpage = cpu_buffer->reader_page->page;
7254 7191 unsigned int rpos = read;
7255 7192 unsigned int pos = 0;
7256 7193 unsigned int event_size;
7257 7194 unsigned int flags = 0;
7258 7195
7259 - /* If a full page is requested, it cannot be the commit page */
7260 - if (full && cpu_buffer->reader_page == cpu_buffer->commit_page)
7196 + /*
7197 + * If a full page is expected, this can still be returned
7198 + * if there's been a previous partial read and the
7199 + * rest of the page can be read and the commit page is off
7200 + * the reader page.
7201 + */
7202 + if (full &&
7203 + (!read || (len < (size - read)) ||
7204 + cpu_buffer->reader_page == cpu_buffer->commit_page))
7261 7205 return -1;
7262 7206
7263 7207 if (len > (size - read))
@@ -7343,7 +7287,7 @@ int ring_buffer_read_page(struct trace_buffer *buffer,
7343 7287 * missed events, then record it there.
7344 7288 */
7345 7289 if (missed_events > 0 &&
7346 - rb_read_page_capacity(data_page) - size >= sizeof(missed_events)) {
7290 + rb_page_capacity(reader) - size >= sizeof(missed_events)) {
7347 7291 memcpy(&dpage->data[size], &missed_events,
7348 7292 sizeof(missed_events));
7349 7293 local_add(RB_MISSED_STORED, &dpage->commit);
@@ -7363,8 +7307,8 @@ int ring_buffer_read_page(struct trace_buffer *buffer,
7363 7307 /*
7364 7308 * This page may be off to user land. Zero it out here.
7365 7309 */
7366 - if (size < rb_read_page_capacity(data_page))
7367 - memset(&dpage->data[size], 0, rb_read_page_capacity(data_page) - size);
7310 + if (size < rb_page_capacity(reader))
7311 + memset(&dpage->data[size], 0, rb_page_capacity(reader) - size);
7368 7312
7369 7313 return read;
7370 7314 }
@@ -7382,18 +7326,6 @@ void *ring_buffer_read_page_data(struct buffer_data_read_page *page)
7382 7326 }
7383 7327 EXPORT_SYMBOL_GPL(ring_buffer_read_page_data);
7384 7328
7385 - /**
7386 - * ring_buffer_read_page_size - get size of the read page.
7387 - * @page: the page to get the size from
7388 - *
7389 - * Returns size of the page in bytes.
7390 - */
7391 - unsigned int ring_buffer_read_page_size(struct buffer_data_read_page *rpage)
7392 - {
7393 - return rpage ? PAGE_SIZE << rpage->order : 0;
7394 - }
7395 - EXPORT_SYMBOL_GPL(ring_buffer_read_page_size);
7396 -
7397 7329 /**
7398 7330 * ring_buffer_subbuf_size_get - get size of the sub buffer.
7399 7331 * @buffer: the buffer to get the sub buffer size from
@@ -7448,8 +7380,8 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)
7448 7380 struct ring_buffer_per_cpu *cpu_buffer;
7449 7381 struct buffer_page *bpage, *tmp;
7450 7382 unsigned int old_capacity;
7451 - unsigned long nr_pages;
7452 7383 int old_order;
7384 + int nr_pages;
7453 7385 int psize;
7454 7386 int err;
7455 7387 int cpu;
@@ -7479,7 +7411,7 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)
7479 7411 /* Make sure all commits have finished */
7480 7412 synchronize_rcu();
7481 7413
7482 - WRITE_ONCE(buffer->subbuf_order, order);
7414 + buffer->subbuf_order = order;
7483 7415
7484 7416 /* Make sure all new buffers are allocated, before deleting the old ones */
7485 7417 for_each_buffer_cpu(buffer, cpu) {
@@ -7583,7 +7515,7 @@ int ring_buffer_subbuf_order_set(struct trace_buffer *buffer, int order)
7583 7515 return 0;
7584 7516
7585 7517 error:
7586 - WRITE_ONCE(buffer->subbuf_order, old_order);
7518 + buffer->subbuf_order = old_order;
7587 7519
7588 7520 atomic_dec(&buffer->record_disabled);
7589 7521
@@ -7631,10 +7563,10 @@ static void rb_setup_ids_meta_page(struct ring_buffer_per_cpu *cpu_buffer,
7631 7563 struct buffer_page **subbuf_ids)
7632 7564 {
7633 7565 struct trace_buffer_meta *meta = cpu_buffer->meta_page;
7634 - unsigned long nr_subbufs = cpu_buffer->nr_pages + 1;
7566 + unsigned int nr_subbufs = cpu_buffer->nr_pages + 1;
7635 7567 struct buffer_page *first_subbuf, *subbuf;
7636 - unsigned int cnt = 0;
7637 - unsigned int id = 0;
7568 + int cnt = 0;
7569 + int id = 0;
7638 7570
7639 7571 id = rb_page_id(cpu_buffer, cpu_buffer->reader_page, id);
7640 7572 subbuf_ids[id++] = cpu_buffer->reader_page;
@@ -7862,9 +7794,6 @@ int ring_buffer_map(struct trace_buffer *buffer, int cpu,
7862 7794 /* prevent another thread from changing buffer/sub-buffer sizes */
7863 7795 guard(mutex)(&buffer->mutex);
7864 7796
7865 - if (cpu_buffer->nr_pages > rb_static_max_pages())
7866 - return -E2BIG;
7867 -
7868 7797 err = rb_alloc_meta_page(cpu_buffer);
7869 7798 if (err)
7870 7799 return err;
modified kernel/trace/ring_buffer_benchmark.c
@@ -104,7 +104,7 @@ static enum event_status read_event(int cpu)
104 104
105 105 static enum event_status read_page(int cpu)
106 106 {
107 - struct buffer_data_read_page *bpage = NULL;
107 + struct buffer_data_read_page *bpage;
108 108 struct ring_buffer_event *event;
109 109 struct rb_page *rpage;
110 110 unsigned long commit;
@@ -114,8 +114,8 @@ static enum event_status read_page(int cpu)
114 114 int inc;
115 115 int i;
116 116
117 - ret = ring_buffer_alloc_read_page(buffer, cpu, &bpage);
118 - if (ret < 0)
117 + bpage = ring_buffer_alloc_read_page(buffer, cpu);
118 + if (IS_ERR(bpage))
119 119 return EVENT_DROPPED;
120 120
121 121 page_size = ring_buffer_subbuf_size_get(buffer);
modified kernel/trace/trace.c
@@ -7082,8 +7082,8 @@ ssize_t tracing_buffers_read(struct file *filp, char __user *ubuf,
7082 7082 {
7083 7083 struct ftrace_buffer_info *info = filp->private_data;
7084 7084 struct trace_iterator *iter = &info->iter;
7085 - unsigned int spare_size;
7086 7085 void *trace_data;
7086 + int page_size;
7087 7087 ssize_t ret = 0;
7088 7088 ssize_t size;
7089 7089
@@ -7093,22 +7093,36 @@ ssize_t tracing_buffers_read(struct file *filp, char __user *ubuf,
7093 7093 if (iter->snapshot && tracer_uses_snapshot(iter->tr->current_trace))
7094 7094 return -EBUSY;
7095 7095
7096 - spare_size = ring_buffer_read_page_size(info->spare);
7096 + page_size = ring_buffer_subbuf_size_get(iter->array_buffer->buffer);
7097 7097
7098 - again:
7099 - /* Do we have previous read data to read? */
7100 - if (info->read < spare_size)
7101 - goto read;
7098 + /* Make sure the spare matches the current sub buffer size */
7099 + if (info->spare) {
7100 + if (page_size != info->spare_size) {
7101 + ring_buffer_free_read_page(iter->array_buffer->buffer,
7102 + info->spare_cpu, info->spare);
7103 + info->spare = NULL;
7104 + }
7105 + }
7102 7106
7103 - ret = ring_buffer_alloc_read_page(iter->array_buffer->buffer, iter->cpu_file,
7104 - &info->spare);
7105 - if (ret)
7107 + if (!info->spare) {
7108 + info->spare = ring_buffer_alloc_read_page(iter->array_buffer->buffer,
7109 + iter->cpu_file);
7110 + if (IS_ERR(info->spare)) {
7111 + ret = PTR_ERR(info->spare);
7112 + info->spare = NULL;
7113 + } else {
7114 + info->spare_cpu = iter->cpu_file;
7115 + info->spare_size = page_size;
7116 + }
7117 + }
7118 + if (!info->spare)
7106 7119 return ret;
7107 7120
7108 - spare_size = ring_buffer_read_page_size(info->spare);
7109 - info->read = spare_size;
7110 - info->spare_cpu = iter->cpu_file;
7121 + /* Do we have previous read data to read? */
7122 + if (info->read < page_size)
7123 + goto read;
7111 7124
7125 + again:
7112 7126 trace_access_lock(iter->cpu_file);
7113 7127 ret = ring_buffer_read_page(iter->array_buffer->buffer,
7114 7128 info->spare,
@@ -7134,9 +7148,8 @@ again:
7134 7148 }
7135 7149
7136 7150 info->read = 0;
7137 -
7138 7151 read:
7139 - size = spare_size - info->read;
7152 + size = page_size - info->read;
7140 7153 if (size > count)
7141 7154 size = count;
7142 7155 trace_data = ring_buffer_read_page_data(info->spare);
@@ -7177,24 +7190,26 @@ int tracing_buffers_release(struct inode *inode, struct file *file)
7177 7190
7178 7191 __trace_array_put(iter->tr);
7179 7192
7180 - ring_buffer_free_read_page(iter->array_buffer->buffer, info->spare_cpu, info->spare);
7193 + if (info->spare)
7194 + ring_buffer_free_read_page(iter->array_buffer->buffer,
7195 + info->spare_cpu, info->spare);
7181 7196 kvfree(info);
7182 7197
7183 7198 return 0;
7184 7199 }
7185 7200
7186 7201 struct buffer_ref {
7187 - struct trace_buffer *buffer;
7188 - struct buffer_data_read_page *rpage;
7189 - int cpu;
7190 - refcount_t refcount;
7202 + struct trace_buffer *buffer;
7203 + void *page;
7204 + int cpu;
7205 + refcount_t refcount;
7191 7206 };
7192 7207
7193 7208 static void buffer_ref_release(struct buffer_ref *ref)
7194 7209 {
7195 7210 if (!refcount_dec_and_test(&ref->refcount))
7196 7211 return;
7197 - ring_buffer_free_read_page(ref->buffer, ref->cpu, ref->rpage);
7212 + ring_buffer_free_read_page(ref->buffer, ref->cpu, ref->page);
7198 7213 kfree(ref);
7199 7214 }
7200 7215
@@ -7253,15 +7268,25 @@ ssize_t tracing_buffers_splice_read(struct file *file, loff_t *ppos,
7253 7268 .ops = &buffer_pipe_buf_ops,
7254 7269 .spd_release = buffer_spd_release,
7255 7270 };
7256 - unsigned int page_size = 0;
7257 7271 struct buffer_ref *ref;
7258 7272 bool woken = false;
7273 + int page_size;
7259 7274 int entries, i;
7260 7275 ssize_t ret = 0;
7261 7276
7262 7277 if (iter->snapshot && tracer_uses_snapshot(iter->tr->current_trace))
7263 7278 return -EBUSY;
7264 7279
7280 + page_size = ring_buffer_subbuf_size_get(iter->array_buffer->buffer);
7281 + if (*ppos & (page_size - 1))
7282 + return -EINVAL;
7283 +
7284 + if (len & (page_size - 1)) {
7285 + if (len < page_size)
7286 + return -EINVAL;
7287 + len &= (~(page_size - 1));
7288 + }
7289 +
7265 7290 if (splice_grow_spd(pipe, &spd))
7266 7291 return -ENOMEM;
7267 7292
@@ -7281,39 +7306,25 @@ ssize_t tracing_buffers_splice_read(struct file *file, loff_t *ppos,
7281 7306
7282 7307 refcount_set(&ref->refcount, 1);
7283 7308 ref->buffer = iter->array_buffer->buffer;
7284 -
7285 - ret = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file, &ref->rpage);
7286 - if (ret) {
7309 + ref->page = ring_buffer_alloc_read_page(ref->buffer, iter->cpu_file);
7310 + if (IS_ERR(ref->page)) {
7311 + ret = PTR_ERR(ref->page);
7312 + ref->page = NULL;
7287 7313 kfree(ref);
7288 7314 break;
7289 7315 }
7290 7316 ref->cpu = iter->cpu_file;
7291 7317
7292 - page_size = ring_buffer_read_page_size(ref->rpage);
7293 -
7294 - r = -EINVAL;
7295 - if (IS_ALIGNED(*ppos, page_size) && len >= page_size) {
7296 - r = ring_buffer_read_page(ref->buffer, ref->rpage, len, iter->cpu_file, 1);
7297 - } else if (!i) {
7298 - /*
7299 - * If this fails to read on the first iteration, it
7300 - * means the length was too small and an error should
7301 - * be returned to user space. Otherwise, at least
7302 - * one sub-buffer was successfully read but this failed
7303 - * due to either the length was unaligned or the
7304 - * subbuf order changed. Either case, do not report
7305 - * an error.
7306 - */
7307 - ret = -EINVAL;
7308 - }
7309 -
7318 + r = ring_buffer_read_page(ref->buffer, ref->page,
7319 + len, iter->cpu_file, 1);
7310 7320 if (r < 0) {
7311 - ring_buffer_free_read_page(ref->buffer, ref->cpu, ref->rpage);
7321 + ring_buffer_free_read_page(ref->buffer, ref->cpu,
7322 + ref->page);
7312 7323 kfree(ref);
7313 7324 break;
7314 7325 }
7315 7326
7316 - page = virt_to_page(ring_buffer_read_page_data(ref->rpage));
7327 + page = virt_to_page(ring_buffer_read_page_data(ref->page));
7317 7328
7318 7329 spd.pages[i] = page;
7319 7330 spd.partial[i].len = page_size;
@@ -7831,70 +7842,11 @@ trace_options_core_write(struct file *filp, const char __user *ubuf, size_t cnt,
7831 7842 return cnt;
7832 7843 }
7833 7844
7834 - /*
7835 - * The tr_index is the address of a trace_array->trace_flags_index[]
7836 - * element that holds the index of the trace flag. But since the
7837 - * trace_array reference has not been taken yet, it cannot be referenced
7838 - * as it could have been freed by a rmdir of the instance the trace_array
7839 - * represents.
7840 - *
7841 - * Search the list of trace_arrays and compare the tr_index to the
7842 - * address of the entire trace_array trace_flags_index array for each
7843 - * trace_array in the list. If one is matched, then take the reference
7844 - * and return it. If not, the trace_array no longer exits.
7845 - */
7846 - static int trace_array_options_get(void *tr_index)
7847 - {
7848 - struct trace_array *tr;
7849 - int ret;
7850 -
7851 - ret = security_locked_down(LOCKDOWN_TRACEFS);
7852 - if (ret)
7853 - return ret;
7854 -
7855 - if (tracing_disabled)
7856 - return -ENODEV;
7857 -
7858 - guard(mutex)(&trace_types_lock);
7859 - list_for_each_entry(tr, &ftrace_trace_arrays, list) {
7860 - if (tr_index >= (void *)&tr->trace_flags_index[0] &&
7861 - tr_index < (void *)&tr->trace_flags_index[TRACE_FLAGS_MAX_SIZE])
7862 - return __trace_array_get(tr);
7863 - }
7864 - return -ENODEV;
7865 - }
7866 -
7867 - static int trace_options_open(struct inode *inode, struct file *filp)
7868 - {
7869 - void *tr_index = inode->i_private;
7870 -
7871 - if (trace_array_options_get(tr_index) < 0)
7872 - return -ENODEV;
7873 -
7874 - filp->private_data = tr_index;
7875 -
7876 - return 0;
7877 - }
7878 -
7879 - static int trace_options_release(struct inode *inode, struct file *filp)
7880 - {
7881 - void *tr_index = filp->private_data;
7882 - struct trace_array *tr;
7883 - unsigned int index;
7884 -
7885 - get_tr_index(tr_index, &tr, &index);
7886 -
7887 - trace_array_put(tr);
7888 -
7889 - return 0;
7890 - }
7891 -
7892 7845 static const struct file_operations trace_options_core_fops = {
7893 - .open = trace_options_open,
7894 - .read = trace_options_core_read,
7895 - .write = trace_options_core_write,
7896 - .llseek = generic_file_llseek,
7897 - .release = trace_options_release,
7846 + .open = tracing_open_generic,
7847 + .read = trace_options_core_read,
7848 + .write = trace_options_core_write,
7849 + .llseek = generic_file_llseek,
7898 7850 };
7899 7851
7900 7852 struct dentry *trace_create_file(const char *name,
@@ -9699,11 +9651,6 @@ __init static void enable_instances(void)
9699 9651 if (flag_delim)
9700 9652 *flag_delim++ = '\0';
9701 9653
9702 - if (trace_array_find(name)) {
9703 - pr_warn("Tracing: Instance %s already exists\n", name);
9704 - continue;
9705 - }
9706 -
9707 9654 if (backup) {
9708 9655 if (backup_instance_area(backup, &addr, &size) < 0)
9709 9656 continue;
modified kernel/trace/trace.h
@@ -745,10 +745,11 @@ static inline int tracing_get_cpu(struct inode *inode)
745 745 void tracing_reset_cpu(struct array_buffer *buf, int cpu);
746 746
747 747 struct ftrace_buffer_info {
748 - struct trace_iterator iter;
749 - struct buffer_data_read_page *spare;
750 - unsigned int spare_cpu;
751 - unsigned int read;
748 + struct trace_iterator iter;
749 + void *spare;
750 + unsigned int spare_cpu;
751 + unsigned int spare_size;
752 + unsigned int read;
752 753 };
753 754
754 755 /**
@@ -1339,7 +1340,7 @@ extern void clear_ftrace_function_probes(struct trace_array *tr);
1339 1340 int register_ftrace_command(struct ftrace_func_command *cmd);
1340 1341 int unregister_ftrace_command(struct ftrace_func_command *cmd);
1341 1342
1342 - void ftrace_create_filter_files(struct trace_array *tr,
1343 + void ftrace_create_filter_files(struct ftrace_ops *ops,
1343 1344 struct dentry *parent);
1344 1345 void ftrace_destroy_filter_files(struct ftrace_ops *ops);
1345 1346
@@ -1362,12 +1363,11 @@ static inline void clear_ftrace_function_probes(struct trace_array *tr)
1362 1363 {
1363 1364 }
1364 1365
1365 - static inline void ftrace_create_filter_files(struct trace_array *tr,
1366 - struct dentry *parent) { }
1367 1366 /*
1368 1367 * The ops parameter passed in is usually undefined.
1369 1368 * This must be a macro.
1370 1369 */
1370 + #define ftrace_create_filter_files(ops, parent) do { } while (0)
1371 1371 #define ftrace_destroy_filter_files(ops) do { } while (0)
1372 1372 #endif /* CONFIG_FUNCTION_TRACER && CONFIG_DYNAMIC_FTRACE */
1373 1373
modified kernel/trace/trace_btf.c
@@ -61,50 +61,47 @@ struct btf_anon_stack {
61 61
62 62 /*
63 63 * Find a member of data structure/union by name and return it.
64 - * Return NULL if not found, or ERR_PTR(-EINVAL) if parameter is invalid.
65 - * If the member is a member of an anonymous union/structure, the bit offset
66 - * of that anonymous union/structure is stored into @anon_offset.
67 - * If @member_type is non-NULL, the actual containing structure/union type
68 - * of the found member is stored into @member_type.
64 + * Return NULL if not found, or -EINVAL if parameter is invalid.
65 + * If the member is an member of anonymous union/structure, the offset
66 + * of that anonymous union/structure is stored into @anon_offset. Caller
67 + * can calculate the correct offset from the root data structure by
68 + * adding anon_offset to the member's offset.
69 69 */
70 70 const struct btf_member *btf_find_struct_member(struct btf *btf,
71 71 const struct btf_type *type,
72 72 const char *member_name,
73 - u32 *anon_offset,
74 - const struct btf_type **member_type)
73 + u32 *anon_offset)
75 74 {
76 75 struct btf_anon_stack *anon_stack;
77 76 const struct btf_member *member;
78 - const struct btf_type *mtype;
79 77 u32 tid, cur_offset = 0;
80 78 const char *name;
81 79 int i, top = 0;
82 80
83 - if (!btf_type_is_struct(type))
84 - return ERR_PTR(-EINVAL);
85 -
86 81 anon_stack = kzalloc_objs(*anon_stack, BTF_ANON_STACK_MAX);
87 82 if (!anon_stack)
88 83 return ERR_PTR(-ENOMEM);
89 84
90 85 retry:
86 + if (!btf_type_is_struct(type)) {
87 + member = ERR_PTR(-EINVAL);
88 + goto out;
89 + }
90 +
91 91 for_each_member(i, type, member) {
92 92 if (!member->name_off) {
93 93 /* Anonymous union/struct: push it for later use */
94 - mtype = btf_type_skip_modifiers(btf, member->type, &tid);
95 - if (mtype && btf_type_is_struct(mtype) &&
94 + if (btf_type_skip_modifiers(btf, member->type, &tid) &&
96 95 top < BTF_ANON_STACK_MAX) {
97 96 anon_stack[top].tid = tid;
98 - anon_stack[top++].offset = cur_offset +
99 - __btf_member_bit_offset(type, member);
97 + anon_stack[top++].offset =
98 + cur_offset + member->offset;
100 99 }
101 100 } else {
102 101 name = btf_name_by_offset(btf, member->name_off);
103 102 if (name && !strcmp(member_name, name)) {
104 103 if (anon_offset)
105 104 *anon_offset = cur_offset;
106 - if (member_type)
107 - *member_type = type;
108 105 goto out;
109 106 }
110 107 }
modified kernel/trace/trace_btf.h
@@ -8,5 +8,4 @@ const struct btf_param *btf_get_func_param(const struct btf_type *func_proto,
8 8 const struct btf_member *btf_find_struct_member(struct btf *btf,
9 9 const struct btf_type *type,
10 10 const char *member_name,
11 - u32 *anon_offset,
12 - const struct btf_type **member_type);
11 + u32 *anon_offset);
modified kernel/trace/trace_eprobe.c
@@ -930,7 +930,7 @@ static int __trace_eprobe_create(int argc, const char *argv[])
930 930 } else
931 931 ep->filter_str = NULL;
932 932
933 - ctx = kzalloc_obj(*ctx);
933 + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
934 934 if (!ctx)
935 935 return -ENOMEM;
936 936 ctx->event = ep->event;
modified kernel/trace/trace_events.c
@@ -2736,14 +2736,14 @@ static const struct file_operations ftrace_show_event_filters_fops = {
2736 2736 .open = ftrace_event_show_filters_open,
2737 2737 .read = seq_read,
2738 2738 .llseek = seq_lseek,
2739 - .release = ftrace_event_release,
2739 + .release = seq_release,
2740 2740 };
2741 2741
2742 2742 static const struct file_operations ftrace_show_event_triggers_fops = {
2743 2743 .open = ftrace_event_show_triggers_open,
2744 2744 .read = seq_read,
2745 2745 .llseek = seq_lseek,
2746 - .release = ftrace_event_release,
2746 + .release = seq_release,
2747 2747 };
2748 2748
2749 2749 static const struct file_operations ftrace_set_event_pid_fops = {
@@ -2908,17 +2908,7 @@ ftrace_event_set_open(struct inode *inode, struct file *file)
2908 2908 static int
2909 2909 ftrace_event_show_filters_open(struct inode *inode, struct file *file)
2910 2910 {
2911 - struct trace_array *tr = inode->i_private;
2912 - int ret;
2913 -
2914 - ret = tracing_check_open_get_tr(tr);
2915 - if (ret)
2916 - return ret;
2917 -
2918 - ret = ftrace_event_open(inode, file, &show_show_event_filters_seq_ops);
2919 - if (ret < 0)
2920 - trace_array_put(tr);
2921 - return ret;
2911 + return ftrace_event_open(inode, file, &show_show_event_filters_seq_ops);
2922 2912 }
2923 2913
2924 2914 /**
@@ -2932,17 +2922,7 @@ ftrace_event_show_filters_open(struct inode *inode, struct file *file)
2932 2922 static int
2933 2923 ftrace_event_show_triggers_open(struct inode *inode, struct file *file)
2934 2924 {
2935 - struct trace_array *tr = inode->i_private;
2936 - int ret;
2937 -
2938 - ret = tracing_check_open_get_tr(tr);
2939 - if (ret)
2940 - return ret;
2941 -
2942 - ret = ftrace_event_open(inode, file, &show_show_event_triggers_seq_ops);
2943 - if (ret < 0)
2944 - trace_array_put(tr);
2945 - return ret;
2925 + return ftrace_event_open(inode, file, &show_show_event_triggers_seq_ops);
2946 2926 }
2947 2927
2948 2928 static int
modified kernel/trace/trace_functions.c
@@ -101,7 +101,7 @@ int ftrace_create_function_files(struct trace_array *tr,
101 101 return ret;
102 102 }
103 103
104 - ftrace_create_filter_files(tr, parent);
104 + ftrace_create_filter_files(tr->ops, parent);
105 105
106 106 return 0;
107 107 }
modified kernel/trace/trace_probe.c
@@ -625,7 +625,6 @@ static int get_bitoffset_of_field(char **pfieldname, const struct btf_type **pty
625 625 {
626 626 const struct btf_type *type = *ptype;
627 627 const struct btf_member *field;
628 - const struct btf_type *mtype;
629 628 struct btf *btf = ctx_btf(ctx);
630 629 char *fieldname = *pfieldname;
631 630 int bitoffs = 0;
@@ -641,7 +640,7 @@ static int get_bitoffset_of_field(char **pfieldname, const struct btf_type **pty
641 640
642 641 anon_offs = 0;
643 642 field = btf_find_struct_member(btf, type, fieldname,
644 - &anon_offs, &mtype);
643 + &anon_offs);
645 644 if (IS_ERR(field)) {
646 645 trace_probe_log_err(ctx->offset, BAD_BTF_TID);
647 646 return PTR_ERR(field);
@@ -654,7 +653,7 @@ static int get_bitoffset_of_field(char **pfieldname, const struct btf_type **pty
654 653 bitoffs += anon_offs;
655 654
656 655 /* Accumulate the bit-offsets of the dot-connected fields */
657 - if (btf_type_kflag(mtype)) {
656 + if (btf_type_kflag(type)) {
658 657 bitoffs += BTF_MEMBER_BIT_OFFSET(field->offset);
659 658 ctx->last_bitsize = BTF_MEMBER_BITFIELD_SIZE(field->offset);
660 659 } else {
@@ -662,11 +661,11 @@ static int get_bitoffset_of_field(char **pfieldname, const struct btf_type **pty
662 661 ctx->last_bitsize = 0;
663 662 }
664 663
665 - type = btf_type_skip_modifiers(btf, field->type, NULL);
666 - if (!type) {
667 - trace_probe_log_err(ctx->offset, BAD_BTF_TID);
668 - return -EINVAL;
669 - }
664 + type = btf_type_skip_modifiers(btf, field->type, NULL);
665 + if (!type) {
666 + trace_probe_log_err(ctx->offset, BAD_BTF_TID);
667 + return -EINVAL;
668 + }
670 669
671 670 if (next)
672 671 ctx->offset += next - fieldname;
@@ -2553,60 +2552,19 @@ int traceprobe_set_print_fmt(struct trace_probe *tp, enum probe_print_type ptype
2553 2552 int traceprobe_define_arg_fields(struct trace_event_call *event_call,
2554 2553 size_t offset, struct trace_probe *tp)
2555 2554 {
2556 - struct trace_probe_event *tpe = trace_probe_event_from_call(event_call);
2557 2555 int ret, i;
2558 2556
2559 - /*
2560 - * A field created by trace_define_field() only stores the name and
2561 - * type pointers, it does not copy the strings. Here they point into
2562 - * the probe_arg of @tp, which is freed when @tp is removed. For an
2563 - * event with multiple probes attached, the field list is defined
2564 - * once by the first probe but kept alive by the surviving siblings,
2565 - * so removing that first probe would leave the fields referencing
2566 - * freed memory. Duplicate the strings and anchor the copies on the
2567 - * trace_probe_event, which lives as long as the field list itself.
2568 - *
2569 - * event_define_fields() ignores the return value of this hook, so
2570 - * if a previous attempt failed before creating any field, it may
2571 - * call here again. Release duplicates left behind by such an
2572 - * attempt before starting over.
2573 - */
2574 - for (i = 0; i < tpe->nr_field_strings; i++)
2575 - kfree(tpe->field_strings[i]);
2576 - kfree(tpe->field_strings);
2577 - tpe->field_strings = NULL;
2578 - tpe->nr_field_strings = 0;
2579 -
2580 - if (tp->nr_args) {
2581 - tpe->field_strings = kcalloc(tp->nr_args * 2, sizeof(char *),
2582 - GFP_KERNEL);
2583 - if (!tpe->field_strings)
2584 - return -ENOMEM;
2585 - }
2586 -
2587 2557 /* Set argument names as fields */
2588 2558 for (i = 0; i < tp->nr_args; i++) {
2589 2559 struct probe_arg *parg = &tp->args[i];
2590 2560 const char *fmt = parg->type->fmttype;
2591 2561 int size = parg->type->size;
2592 - char *name, *type;
2593 2562
2594 2563 if (parg->fmt)
2595 2564 fmt = parg->fmt;
2596 2565 if (parg->count)
2597 2566 size *= parg->count;
2598 -
2599 - name = kstrdup(parg->name, GFP_KERNEL);
2600 - type = kstrdup(fmt, GFP_KERNEL);
2601 - if (!name || !type) {
2602 - kfree(name);
2603 - kfree(type);
2604 - return -ENOMEM;
2605 - }
2606 - tpe->field_strings[tpe->nr_field_strings++] = name;
2607 - tpe->field_strings[tpe->nr_field_strings++] = type;
2608 -
2609 - ret = trace_define_field(event_call, type, name,
2567 + ret = trace_define_field(event_call, fmt, parg->name,
2610 2568 offset + parg->offset, size,
2611 2569 parg->type->is_signed,
2612 2570 FILTER_OTHER);
@@ -2618,11 +2576,6 @@ int traceprobe_define_arg_fields(struct trace_event_call *event_call,
2618 2576
2619 2577 static void trace_probe_event_free(struct trace_probe_event *tpe)
2620 2578 {
2621 - int i;
2622 -
2623 - for (i = 0; i < tpe->nr_field_strings; i++)
2624 - kfree(tpe->field_strings[i]);
2625 - kfree(tpe->field_strings);
2626 2579 kfree(tpe->class.system);
2627 2580 kfree(tpe->call.name);
2628 2581 kfree(tpe->call.print_fmt);
modified kernel/trace/trace_probe.h
@@ -264,8 +264,6 @@ struct trace_probe_event {
264 264 struct trace_event_call call;
265 265 struct list_head files;
266 266 struct list_head probes;
267 - char **field_strings;
268 - int nr_field_strings;
269 267 struct trace_uprobe_filter filter[];
270 268 };
271 269
modified kernel/trace/trace_remote.c
@@ -251,8 +251,8 @@ static int trace_remote_get(struct trace_remote *remote, int cpu)
251 251 if (cpu != RING_BUFFER_ALL_CPUS && !remote->pcpu_reader_locks) {
252 252 int lock_cpu;
253 253
254 - remote->pcpu_reader_locks = kzalloc_objs(*remote->pcpu_reader_locks,
255 - nr_cpu_ids);
254 + remote->pcpu_reader_locks = kcalloc(nr_cpu_ids, sizeof(*remote->pcpu_reader_locks),
255 + GFP_KERNEL);
256 256 if (!remote->pcpu_reader_locks) {
257 257 trace_remote_try_unload(remote);
258 258 return -ENOMEM;
@@ -324,7 +324,7 @@ static int __alloc_ring_buffer_iter(struct trace_remote_iterator *iter, int cpu)
324 324 return iter->rb_iter ? 0 : -ENOMEM;
325 325 }
326 326
327 - iter->rb_iters = kzalloc_objs(*iter->rb_iters, nr_cpu_ids);
327 + iter->rb_iters = kcalloc(nr_cpu_ids, sizeof(*iter->rb_iters), GFP_KERNEL);
328 328 if (!iter->rb_iters)
329 329 return -ENOMEM;
330 330
@@ -1204,7 +1204,7 @@ remote_events_dir_header_page_read(struct file *filp, char __user *ubuf, size_t
1204 1204 struct trace_seq *s;
1205 1205 int ret;
1206 1206
1207 - s = kmalloc_obj(*s);
1207 + s = kmalloc(sizeof(*s), GFP_KERNEL);
1208 1208 if (!s)
1209 1209 return -ENOMEM;
1210 1210
@@ -1227,7 +1227,7 @@ remote_events_dir_header_event_read(struct file *filp, char __user *ubuf, size_t
1227 1227 struct trace_seq *s;
1228 1228 int ret;
1229 1229
1230 - s = kmalloc_obj(*s);
1230 + s = kmalloc(sizeof(*s), GFP_KERNEL);
1231 1231 if (!s)
1232 1232 return -ENOMEM;
1233 1233
modified kernel/trace/trace_stack.c
@@ -499,7 +499,7 @@ stack_trace_filter_open(struct inode *inode, struct file *file)
499 499 struct ftrace_ops *ops = inode->i_private;
500 500
501 501 /* Checks for tracefs lockdown */
502 - return ftrace_regex_open(NULL, ops, FTRACE_ITER_FILTER,
502 + return ftrace_regex_open(ops, FTRACE_ITER_FILTER,
503 503 inode, file);
504 504 }
505 505
modified kernel/trace/trace_uprobe.c
@@ -368,7 +368,7 @@ error:
368 368
369 369 static void free_trace_uprobe(struct trace_uprobe *tu)
370 370 {
371 - if (IS_ERR_OR_NULL(tu))
371 + if (!tu)
372 372 return;
373 373
374 374 path_put(&tu->path);
@@ -533,7 +533,7 @@ static int register_trace_uprobe(struct trace_uprobe *tu)
533 533 return ret;
534 534 }
535 535
536 - DEFINE_FREE(free_trace_uprobe, struct trace_uprobe *, free_trace_uprobe(_T))
536 + DEFINE_FREE(free_trace_uprobe, struct trace_uprobe *, if (_T) free_trace_uprobe(_T))
537 537
538 538 /*
539 539 * Argument syntax:
modified kernel/workqueue.c
@@ -3197,16 +3197,7 @@ restart:
3197 3197 #ifdef CONFIG_PREEMPT_RT
3198 3198 static void worker_lock_callback(struct worker_pool *pool)
3199 3199 {
3200 - /*
3201 - * SINGLE_DEPTH_NESTING is for a dead pool's bh_worker() running from
3202 - * drain_dead_softirq_workfn() inside a live pool's bh_worker(). The
3203 - * unlocked read is stable: the flag is only set while @pool's CPU is
3204 - * dead, inside a serialized hotplug operation. data_race() as the value
3205 - * only affects the lockdep annotation and the read can be elided when
3206 - * lockdep is disabled.
3207 - */
3208 - spin_lock_nested(&pool->cb_lock,
3209 - data_race(pool->flags) & POOL_BH_DRAINING ? SINGLE_DEPTH_NESTING : 0);
3200 + spin_lock(&pool->cb_lock);
3210 3201 }
3211 3202
3212 3203 static void worker_unlock_callback(struct worker_pool *pool)
@@ -5294,6 +5285,12 @@ static void pwq_release_workfn(struct kthread_work *work)
5294 5285 mutex_unlock(&wq->mutex);
5295 5286 }
5296 5287
5288 + if (!is_percpu_pool(pool)) {
5289 + mutex_lock(&wq_pool_mutex);
5290 + put_unbound_pool(pool);
5291 + mutex_unlock(&wq_pool_mutex);
5292 + }
5293 +
5297 5294 if (!list_empty(&pwq->pending_node)) {
5298 5295 struct wq_node_nr_active *nna =
5299 5296 wq_node_nr_active(pwq->wq, pwq->pool->node);
@@ -5303,12 +5300,6 @@ static void pwq_release_workfn(struct kthread_work *work)
5303 5300 raw_spin_unlock_irq(&nna->lock);
5304 5301 }
5305 5302
5306 - if (!is_percpu_pool(pool)) {
5307 - mutex_lock(&wq_pool_mutex);
5308 - put_unbound_pool(pool);
5309 - mutex_unlock(&wq_pool_mutex);
5310 - }
5311 -
5312 5303 kfree_rcu(pwq, rcu);
5313 5304
5314 5305 /*
@@ -8059,9 +8050,6 @@ static int wq_watchdog_param_set_thresh(const char *val,
8059 8050 if (ret)
8060 8051 return ret;
8061 8052
8062 - if (thresh > MAX_JIFFY_OFFSET / HZ)
8063 - return -ERANGE;
8064 -
8065 8053 if (system_percpu_wq)
8066 8054 wq_watchdog_set_thresh(thresh);
8067 8055 else
@@ -8092,12 +8080,12 @@ static inline void wq_watchdog_init(void) { }
8092 8080
8093 8081 static void bh_pool_kick_normal(struct irq_work *irq_work)
8094 8082 {
8095 - raise_softirq(TASKLET_SOFTIRQ);
8083 + raise_softirq_irqoff(TASKLET_SOFTIRQ);
8096 8084 }
8097 8085
8098 8086 static void bh_pool_kick_highpri(struct irq_work *irq_work)
8099 8087 {
8100 - raise_softirq(HI_SOFTIRQ);
8088 + raise_softirq_irqoff(HI_SOFTIRQ);
8101 8089 }
8102 8090
8103 8091 static void __init restrict_unbound_cpumask(const char *name, const struct cpumask *mask)
modified lib/once.c
@@ -93,6 +93,6 @@ void __do_once_sleepable_done(bool *done, struct static_key_true *once_key,
93 93 {
94 94 *done = true;
95 95 mutex_unlock(&once_mutex);
96 - once_disable_jump(once_key, mod);
96 + static_branch_disable(once_key);
97 97 }
98 98 EXPORT_SYMBOL(__do_once_sleepable_done);
modified lib/test_rhashtable.c
@@ -696,7 +696,7 @@ static int __init test_rhashtable_next_key(void)
696 696 if (err)
697 697 return err;
698 698
699 - objs = kzalloc_objs(*objs, n);
699 + objs = kcalloc(n, sizeof(*objs), GFP_KERNEL);
700 700 if (!objs) {
701 701 rhashtable_destroy(&ht);
702 702 return -ENOMEM;
modified lib/test_workqueue.c
@@ -149,11 +149,11 @@ static int __init run_bench(int n_threads, const char *scope, const char *label)
149 149 if (ret)
150 150 return ret;
151 151
152 - ctxs = kzalloc_objs(*ctxs, n_threads);
152 + ctxs = kcalloc(n_threads, sizeof(*ctxs), GFP_KERNEL);
153 153 if (!ctxs)
154 154 return -ENOMEM;
155 155
156 - tasks = kzalloc_objs(*tasks, n_threads);
156 + tasks = kcalloc(n_threads, sizeof(*tasks), GFP_KERNEL);
157 157 if (!tasks) {
158 158 kfree(ctxs);
159 159 return -ENOMEM;
modified lib/tests/kunit_iov_iter.c
@@ -57,7 +57,7 @@ static void *__init iov_kunit_create_buffer(struct kunit *test,
57 57 void *buffer;
58 58 unsigned int i;
59 59
60 - pages = kzalloc_objs(struct page *, npages);
60 + pages = kzalloc_objs(struct page *, npages, GFP_KERNEL);
61 61 KUNIT_ASSERT_NOT_ERR_OR_NULL(test, pages);
62 62 *ppages = pages;
63 63
modified mm/damon/tests/vaddr-kunit.h
@@ -136,7 +136,7 @@ static void damon_do_test_apply_three_regions(struct kunit *test,
136 136 if (!t)
137 137 kunit_skip(test, "target alloc fail");
138 138
139 - ranges = kmalloc_objs(*ranges, nr_regions / 2);
139 + ranges = kmalloc_array(nr_regions / 2, sizeof(*ranges), GFP_KERNEL);
140 140 if (!ranges) {
141 141 damon_destroy_target(t, NULL);
142 142 kunit_skip(test, "ranges alloc fail");
modified mm/huge_memory.c
@@ -2449,8 +2449,6 @@ static void zap_huge_pmd_folio(struct mm_struct *mm, struct vm_area_struct *vma,
2449 2449 add_mm_counter(mm, mm_counter_file(folio),
2450 2450 -HPAGE_PMD_NR);
2451 2451
2452 - if (is_present && pmd_dirty(pmdval))
2453 - folio_mark_dirty(folio);
2454 2452 if (is_present && pmd_young(pmdval) &&
2455 2453 likely(vma_has_recency(vma)))
2456 2454 folio_mark_accessed(folio);
modified mm/hugetlb.c
@@ -1992,8 +1992,7 @@ retry:
1992 1992 if (h->surplus_huge_pages_node[folio_nid(folio)])
1993 1993 adjust_surplus = true;
1994 1994 remove_hugetlb_folio(h, folio, adjust_surplus);
1995 - if (!adjust_surplus)
1996 - h->max_huge_pages--;
1995 + h->max_huge_pages--;
1997 1996 spin_unlock_irq(&hugetlb_lock);
1998 1997
1999 1998 /*
@@ -2013,8 +2012,7 @@ retry:
2013 2012 if (rc) {
2014 2013 spin_lock_irq(&hugetlb_lock);
2015 2014 add_hugetlb_folio(h, folio, adjust_surplus);
2016 - if (!adjust_surplus)
2017 - h->max_huge_pages++;
2015 + h->max_huge_pages++;
2018 2016 goto out;
2019 2017 }
2020 2018 } else {
@@ -7332,14 +7330,14 @@ void move_hugetlb_state(struct folio *old_folio, struct folio *new_folio,
7332 7330 * There is no need to transfer the per-node surplus state
7333 7331 * when we do not cross the node.
7334 7332 */
7335 - if (new_nid != old_nid) {
7336 - spin_lock_irq(&hugetlb_lock);
7337 - if (h->surplus_huge_pages_node[old_nid]) {
7338 - h->surplus_huge_pages_node[old_nid]--;
7339 - h->surplus_huge_pages_node[new_nid]++;
7340 - }
7341 - spin_unlock_irq(&hugetlb_lock);
7333 + if (new_nid == old_nid)
7334 + return;
7335 + spin_lock_irq(&hugetlb_lock);
7336 + if (h->surplus_huge_pages_node[old_nid]) {
7337 + h->surplus_huge_pages_node[old_nid]--;
7338 + h->surplus_huge_pages_node[new_nid]++;
7342 7339 }
7340 + spin_unlock_irq(&hugetlb_lock);
7343 7341 }
7344 7342
7345 7343 /*
modified mm/hugetlb_cgroup.c
@@ -97,7 +97,6 @@ static void hugetlb_cgroup_init(struct hugetlb_cgroup *h_cgroup,
97 97 struct page_counter *fault, *fault_parent = NULL;
98 98 struct page_counter *rsvd, *rsvd_parent = NULL;
99 99 unsigned long limit;
100 - int ret;
101 100
102 101 if (parent_h_cgroup) {
103 102 fault_parent = hugetlb_cgroup_counter_from_cgroup(
@@ -119,10 +118,8 @@ static void hugetlb_cgroup_init(struct hugetlb_cgroup *h_cgroup,
119 118 limit = round_down(PAGE_COUNTER_MAX,
120 119 pages_per_huge_page(&hstates[idx]));
121 120
122 - ret = page_counter_set_max(fault, limit);
123 - VM_WARN_ON_ONCE(ret);
124 - ret = page_counter_set_max(rsvd, limit);
125 - VM_WARN_ON_ONCE(ret);
121 + VM_BUG_ON(page_counter_set_max(fault, limit));
122 + VM_BUG_ON(page_counter_set_max(rsvd, limit));
126 123 }
127 124 }
128 125
modified mm/hugetlb_cma.c
@@ -3,7 +3,6 @@
3 3 #include <linux/mm.h>
4 4 #include <linux/cma.h>
5 5 #include <linux/compiler.h>
6 - #include <linux/cpuset.h>
7 6 #include <linux/mm_inline.h>
8 7
9 8 #include <asm/page.h>
@@ -56,25 +55,15 @@ struct folio *hugetlb_cma_alloc_frozen_folio(int order, gfp_t gfp_mask,
56 55 int node;
57 56 struct folio *folio;
58 57 struct page *page = NULL;
59 - const nodemask_t *nmask;
60 - unsigned int cpuset_mems_cookie;
61 58
62 59 if (!hugetlb_cma_size)
63 60 return NULL;
64 61
65 - retry_cpuset:
66 - if (!nodemask) {
67 - cpuset_mems_cookie = read_mems_allowed_begin();
68 - nmask = &cpuset_current_mems_allowed;
69 - } else {
70 - nmask = nodemask;
71 - }
72 -
73 - if (hugetlb_cma[nid] && node_isset(nid, *nmask))
62 + if (hugetlb_cma[nid])
74 63 page = cma_alloc_frozen_compound(hugetlb_cma[nid], order);
75 64
76 65 if (!page && !(gfp_mask & __GFP_THISNODE)) {
77 - for_each_node_mask(node, *nmask) {
66 + for_each_node_mask(node, *nodemask) {
78 67 if (node == nid || !hugetlb_cma[node])
79 68 continue;
80 69
@@ -84,12 +73,8 @@ retry_cpuset:
84 73 }
85 74 }
86 75
87 - if (!page) {
88 - if (!nodemask &&
89 - unlikely(read_mems_allowed_retry(cpuset_mems_cookie)))
90 - goto retry_cpuset;
76 + if (!page)
91 77 return NULL;
92 - }
93 78
94 79 folio = page_folio(page);
95 80 folio_set_hugetlb_cma(folio);
modified mm/khugepaged.c
@@ -454,6 +454,12 @@ int hugepage_madvise(struct vm_area_struct *vma,
454 454 case MADV_HUGEPAGE:
455 455 *vm_flags &= ~VM_NOHUGEPAGE;
456 456 *vm_flags |= VM_HUGEPAGE;
457 + /*
458 + * If the vma become good for khugepaged to scan,
459 + * register it here without waiting a page fault that
460 + * may not happen any time soon.
461 + */
462 + khugepaged_enter_vma(vma, *vm_flags);
457 463 break;
458 464 case MADV_NOHUGEPAGE:
459 465 *vm_flags &= ~VM_HUGEPAGE;
modified mm/madvise.c
@@ -178,14 +178,6 @@ static int madvise_update_vma(vm_flags_t new_flags,
178 178 /* vm_flags is protected by the mmap_lock held in write mode. */
179 179 vma_start_write(vma);
180 180 vma->flags = new_vma_flags;
181 - /*
182 - * If the vma become good for khugepaged to scan,
183 - * register it here without waiting a page fault that
184 - * may not happen any time soon.
185 - */
186 - if (vma_flags_test(&new_vma_flags, VMA_HUGEPAGE_BIT))
187 - khugepaged_enter_vma(vma, vma_flags_to_legacy(new_vma_flags));
188 -
189 181 if (set_new_anon_name)
190 182 return replace_anon_vma_name(vma, anon_name);
191 183
modified mm/memcontrol-v1.c
@@ -96,6 +96,7 @@ enum {
96 96 RES_LIMIT,
97 97 RES_MAX_USAGE,
98 98 RES_FAILCNT,
99 + RES_SOFT_LIMIT,
99 100 };
100 101
101 102 #ifdef CONFIG_LOCKDEP
@@ -1887,30 +1888,6 @@ static int mem_cgroup_hierarchy_write(struct cgroup_subsys_state *css,
1887 1888 return -EINVAL;
1888 1889 }
1889 1890
1890 - static u64 mem_cgroup_soft_limit_read(struct cgroup_subsys_state *css,
1891 - struct cftype *cft)
1892 - {
1893 - return (u64)PAGE_COUNTER_MAX * PAGE_SIZE;
1894 - }
1895 -
1896 - static ssize_t mem_cgroup_soft_limit_write(struct kernfs_open_file *of,
1897 - char *buf, size_t nbytes, loff_t off)
1898 - {
1899 - unsigned long nr_pages;
1900 - int ret;
1901 -
1902 - ret = page_counter_memparse(strstrip(buf), "-1", &nr_pages);
1903 - if (ret)
1904 - return ret;
1905 -
1906 - pr_warn_once("soft_limit_in_bytes is deprecated and will be removed. "
1907 - "Writing any value to this file has no effect. "
1908 - "Please report your usecase to linux-mm@kvack.org if you "
1909 - "depend on this functionality.\n");
1910 -
1911 - return nbytes;
1912 - }
1913 -
1914 1891 static u64 mem_cgroup_read_u64(struct cgroup_subsys_state *css,
1915 1892 struct cftype *cft)
1916 1893 {
@@ -1947,6 +1924,8 @@ static u64 mem_cgroup_read_u64(struct cgroup_subsys_state *css,
1947 1924 return (u64)counter->watermark * PAGE_SIZE;
1948 1925 case RES_FAILCNT:
1949 1926 return counter->failcnt;
1927 + case RES_SOFT_LIMIT:
1928 + return (u64)READ_ONCE(memcg->soft_limit) * PAGE_SIZE;
1950 1929 default:
1951 1930 BUG();
1952 1931 }
@@ -2041,6 +2020,17 @@ static ssize_t mem_cgroup_write(struct kernfs_open_file *of,
2041 2020 break;
2042 2021 }
2043 2022 break;
2023 + case RES_SOFT_LIMIT:
2024 + if (IS_ENABLED(CONFIG_PREEMPT_RT)) {
2025 + ret = -EOPNOTSUPP;
2026 + } else {
2027 + pr_warn_once("soft_limit_in_bytes is deprecated and will be removed. "
2028 + "Please report your usecase to linux-mm@kvack.org if you "
2029 + "depend on this functionality.\n");
2030 + WRITE_ONCE(memcg->soft_limit, nr_pages);
2031 + ret = 0;
2032 + }
2033 + break;
2044 2034 }
2045 2035 return ret ?: nbytes;
2046 2036 }
@@ -2394,8 +2384,9 @@ struct cftype mem_cgroup_legacy_files[] = {
2394 2384 },
2395 2385 {
2396 2386 .name = "soft_limit_in_bytes",
2397 - .write = mem_cgroup_soft_limit_write,
2398 - .read_u64 = mem_cgroup_soft_limit_read,
2387 + .private = MEMFILE_PRIVATE(_MEM, RES_SOFT_LIMIT),
2388 + .write = mem_cgroup_write,
2389 + .read_u64 = mem_cgroup_read_u64,
2399 2390 },
2400 2391 {
2401 2392 .name = "failcnt",
modified mm/mempolicy.c
@@ -2679,7 +2679,7 @@ static unsigned long alloc_pages_bulk_weighted_interleave(gfp_t gfp,
2679 2679 prev_node = node;
2680 2680
2681 2681 /* create a local copy of node weights to operate on outside rcu */
2682 - weights = kmalloc(nr_node_ids, gfp & GFP_RECLAIM_MASK);
2682 + weights = kzalloc(nr_node_ids, GFP_KERNEL);
2683 2683 if (!weights)
2684 2684 return total_allocated;
2685 2685
modified mm/migrate_device.c
@@ -1423,15 +1423,6 @@ int migrate_device_range(unsigned long *src_pfns, unsigned long start,
1423 1423
1424 1424 src_pfns[i] = migrate_device_pfn_lock(pfn);
1425 1425 nr = folio_nr_pages(folio);
1426 - if (nr > npages - i) {
1427 - if (src_pfns[i] & MIGRATE_PFN_MIGRATE) {
1428 - folio_unlock(folio);
1429 - folio_put(folio);
1430 - }
1431 - memset(&src_pfns[i], 0,
1432 - (npages - i) * sizeof(*src_pfns));
1433 - break;
1434 - }
1435 1426 if (nr > 1) {
1436 1427 src_pfns[i] |= MIGRATE_PFN_COMPOUND;
1437 1428 for (j = 1; j < nr; j++)
@@ -1466,15 +1457,6 @@ int migrate_device_pfns(unsigned long *src_pfns, unsigned long npages)
1466 1457
1467 1458 src_pfns[i] = migrate_device_pfn_lock(src_pfns[i]);
1468 1459 nr = folio_nr_pages(folio);
1469 - if (nr > npages - i) {
1470 - if (src_pfns[i] & MIGRATE_PFN_MIGRATE) {
1471 - folio_unlock(folio);
1472 - folio_put(folio);
1473 - }
1474 - memset(&src_pfns[i], 0,
1475 - (npages - i) * sizeof(*src_pfns));
1476 - break;
1477 - }
1478 1460 if (nr > 1) {
1479 1461 src_pfns[i] |= MIGRATE_PFN_COMPOUND;
1480 1462 for (j = 1; j < nr; j++)
modified mm/mremap.c
@@ -1331,30 +1331,18 @@ static void dontunmap_complete(struct vma_remap_struct *vrm,
1331 1331 {
1332 1332 unsigned long start = vrm->addr;
1333 1333 unsigned long end = vrm->addr + vrm->old_len;
1334 - struct vm_area_struct *vma = vrm->vma;
1335 - unsigned long old_start = vma->vm_start;
1336 - unsigned long old_end = vma->vm_end;
1334 + unsigned long old_start = vrm->vma->vm_start;
1335 + unsigned long old_end = vrm->vma->vm_end;
1337 1336
1338 1337 /* We always clear VMA_LOCKED[ONFAULT]_BIT on the old VMA. */
1339 - vma_clear_flags_mask(vma, VMA_LOCKED_MASK);
1338 + vma_clear_flags_mask(vrm->vma, VMA_LOCKED_MASK);
1340 1339
1341 1340 /*
1342 1341 * anon_vma links of the old vma is no longer needed after its page
1343 1342 * table has been moved.
1344 1343 */
1345 - if (new_vma != vma && start == old_start && end == old_end) {
1346 - const pgoff_t pgoff_unfaulted = vma->vm_start >> PAGE_SHIFT;
1347 -
1348 - unlink_anon_vmas(vma);
1349 - /*
1350 - * The VMA is now unfaulted and it is an invariant that
1351 - * unfaulted anonymous VMAs have page offset equal to
1352 - * vma->vm_start >> PAGE_SHIFT.
1353 - */
1354 - vma_set_anon_pgoff(vma, pgoff_unfaulted);
1355 - if (vma_is_anonymous(vma) && !vma->vm_file)
1356 - vma_set_pgoff(vma, pgoff_unfaulted);
1357 - }
1344 + if (new_vma != vrm->vma && start == old_start && end == old_end)
1345 + unlink_anon_vmas(vrm->vma);
1358 1346
1359 1347 /* Because we won't unmap we don't need to touch locked_vm. */
1360 1348 }
modified mm/secretmem.c
@@ -18,8 +18,6 @@
18 18 #include <linux/secretmem.h>
19 19 #include <linux/set_memory.h>
20 20 #include <linux/sched/signal.h>
21 - #include <linux/sched/user.h>
22 - #include <linux/cred.h>
23 21
24 22 #include <uapi/linux/magic.h>
25 23
@@ -49,69 +47,10 @@ bool secretmem_active(void)
49 47 return !!atomic_read(&secretmem_users);
50 48 }
51 49
52 - struct secretmem_inode_state {
53 - struct user_struct *user;
54 - atomic_long_t nr_pages_accounted;
55 - };
56 -
57 - static bool __secretmem_account_pages(struct user_struct *user,
58 - unsigned long nr_pages)
59 - {
60 - unsigned long page_limit, cur_pages, new_pages;
61 -
62 - if (!nr_pages)
63 - return true;
64 -
65 - page_limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT;
66 -
67 - cur_pages = atomic_long_read(&user->locked_vm);
68 - do {
69 - new_pages = cur_pages + nr_pages;
70 - if (new_pages > page_limit)
71 - return false;
72 - } while (!atomic_long_try_cmpxchg(&user->locked_vm,
73 - &cur_pages, new_pages));
74 - return true;
75 - }
76 -
77 - static bool secretmem_account_folio(struct secretmem_inode_state *state,
78 - const struct folio *folio)
79 - {
80 - const unsigned long nr_pages = folio_nr_pages(folio);
81 -
82 - if (!__secretmem_account_pages(state->user, nr_pages))
83 - return false;
84 -
85 - atomic_long_add(nr_pages, &state->nr_pages_accounted);
86 - return true;
87 - }
88 -
89 - static void __secretmem_unaccount_pages(struct secretmem_inode_state *state,
90 - unsigned long nr_pages)
91 - {
92 - atomic_long_sub(nr_pages, &state->user->locked_vm);
93 - atomic_long_sub(nr_pages, &state->nr_pages_accounted);
94 - }
95 -
96 - static void secretmem_unaccount_folio(struct secretmem_inode_state *state,
97 - struct folio *folio)
98 - {
99 - __secretmem_unaccount_pages(state, folio_nr_pages(folio));
100 - }
101 -
102 - static void secretmem_unaccount_all_folios(struct secretmem_inode_state *state)
103 - {
104 - const unsigned long nr_pages_accounted =
105 - atomic_long_read(&state->nr_pages_accounted);
106 -
107 - __secretmem_unaccount_pages(state, nr_pages_accounted);
108 - }
109 -
110 50 static vm_fault_t secretmem_fault(struct vm_fault *vmf)
111 51 {
112 52 struct address_space *mapping = vmf->vma->vm_file->f_mapping;
113 53 struct inode *inode = file_inode(vmf->vma->vm_file);
114 - struct secretmem_inode_state *state = inode->i_private;
115 54 pgoff_t offset = vmf->pgoff;
116 55 gfp_t gfp = vmf->gfp_mask;
117 56 unsigned long addr;
@@ -133,15 +72,8 @@ retry:
133 72 goto out;
134 73 }
135 74
136 - if (!secretmem_account_folio(state, folio)) {
137 - folio_put(folio);
138 - ret = VM_FAULT_SIGBUS;
139 - goto out;
140 - }
141 -
142 75 err = set_direct_map_invalid_noflush(folio_page(folio, 0));
143 76 if (err) {
144 - secretmem_unaccount_folio(state, folio);
145 77 folio_put(folio);
146 78 ret = vmf_error(err);
147 79 goto out;
@@ -150,7 +82,6 @@ retry:
150 82 __folio_mark_uptodate(folio);
151 83 err = filemap_add_folio(mapping, folio, offset, gfp);
152 84 if (unlikely(err)) {
153 - secretmem_unaccount_folio(state, folio);
154 85 /*
155 86 * If a split of large page was required, it
156 87 * already happened when we marked the page invalid
@@ -181,30 +112,22 @@ static const struct vm_operations_struct secretmem_vm_ops = {
181 112 .fault = secretmem_fault,
182 113 };
183 114
184 - static void secretmem_destroy_inode_priv(struct inode *inode)
185 - {
186 - struct secretmem_inode_state *state = inode->i_private;
187 -
188 - secretmem_unaccount_all_folios(state);
189 - free_uid(state->user);
190 - kfree(state);
191 - inode->i_private = NULL;
192 - }
193 -
194 115 static int secretmem_release(struct inode *inode, struct file *file)
195 116 {
196 117 atomic_dec(&secretmem_users);
197 - secretmem_destroy_inode_priv(inode);
198 -
199 118 return 0;
200 119 }
201 120
202 121 static int secretmem_mmap_prepare(struct vm_area_desc *desc)
203 122 {
123 + const unsigned long len = vma_desc_size(desc);
124 +
204 125 if (!vma_desc_test_any(desc, VMA_SHARED_BIT, VMA_MAYSHARE_BIT))
205 126 return -EINVAL;
206 127
207 - vma_desc_set_flags(desc, VMA_DONTDUMP_BIT);
128 + vma_desc_set_flags(desc, VMA_LOCKED_BIT, VMA_DONTDUMP_BIT);
129 + if (!mlock_future_ok(desc->mm, /*is_vma_locked=*/ true, len))
130 + return -EAGAIN;
208 131 desc->vm_ops = &secretmem_vm_ops;
209 132
210 133 return 0;
@@ -264,40 +187,20 @@ static const struct inode_operations secretmem_iops = {
264 187
265 188 static struct vfsmount *secretmem_mnt;
266 189
267 - static int secretmem_init_inode_priv(struct inode *inode)
268 - {
269 - struct secretmem_inode_state *state;
270 -
271 - state = kzalloc_obj(*state);
272 - if (!state)
273 - return -ENOMEM;
274 -
275 - state->user = get_uid(current_user());
276 - inode->i_private = state;
277 - return 0;
278 - }
279 -
280 190 static struct file *secretmem_file_create(unsigned long flags)
281 191 {
282 192 struct file *file;
283 193 struct inode *inode;
284 194 const char *anon_name = "[secretmem]";
285 - int err;
286 195
287 196 inode = anon_inode_make_secure_inode(secretmem_mnt->mnt_sb, anon_name, NULL);
288 197 if (IS_ERR(inode))
289 198 return ERR_CAST(inode);
290 199
291 - err = secretmem_init_inode_priv(inode);
292 - if (err)
293 - goto err_free_inode;
294 -
295 200 file = alloc_file_pseudo(inode, secretmem_mnt, "secretmem",
296 201 O_RDWR | O_LARGEFILE, &secretmem_fops);
297 - if (IS_ERR(file)) {
298 - err = PTR_ERR(file);
299 - goto err_free_priv;
300 - }
202 + if (IS_ERR(file))
203 + goto err_free_inode;
301 204
302 205 mapping_set_gfp_mask(inode->i_mapping, GFP_USER);
303 206 mapping_set_unevictable(inode->i_mapping);
@@ -312,11 +215,10 @@ static struct file *secretmem_file_create(unsigned long flags)
312 215 atomic_inc(&secretmem_users);
313 216
314 217 return file;
315 - err_free_priv:
316 - secretmem_destroy_inode_priv(inode);
218 +
317 219 err_free_inode:
318 220 iput(inode);
319 - return ERR_PTR(err);
221 + return file;
320 222 }
321 223
322 224 SYSCALL_DEFINE1(memfd_secret, unsigned int, flags)
modified mm/userfaultfd.c
@@ -2171,10 +2171,8 @@ static ssize_t move_pages(struct userfaultfd_ctx *ctx, unsigned long dst_start,
2171 2171 }
2172 2172
2173 2173 if (err) {
2174 - if (err == -EAGAIN) {
2175 - err = 0;
2174 + if (err == -EAGAIN)
2176 2175 continue;
2177 - }
2178 2176 break;
2179 2177 }
2180 2178
modified net/batman-adv/hard-interface.c
@@ -981,7 +981,7 @@ batadv_wifi_net_device_insert(struct net_device *net_dev, u32 wifi_flags)
981 981
982 982 ASSERT_RTNL();
983 983
984 - device_state = kzalloc_obj(*device_state);
984 + device_state = kzalloc_obj(*device_state, GFP_KERNEL);
985 985 if (!device_state)
986 986 return -ENOMEM;
987 987
modified net/bluetooth/hci_core.c
@@ -2632,11 +2632,11 @@ int hci_register_dev(struct hci_dev *hdev)
2632 2632 if (error)
2633 2633 BT_WARN("register suspend notifier failed error:%d\n", error);
2634 2634
2635 + queue_work(hdev->req_workqueue, &hdev->power_on);
2636 +
2635 2637 idr_init(&hdev->adv_monitors_idr);
2636 2638 msft_register(hdev);
2637 2639
2638 - queue_work(hdev->req_workqueue, &hdev->power_on);
2639 -
2640 2640 return id;
2641 2641
2642 2642 err_wqueue:
modified net/bluetooth/hci_sync.c
@@ -6423,7 +6423,8 @@ static int hci_update_event_filter_sync(struct hci_dev *hdev)
6423 6423 goto update_scan;
6424 6424 }
6425 6425
6426 - accept_list = kmalloc_objs(*accept_list, num_entries);
6426 + accept_list = kmalloc_array(num_entries, sizeof(*accept_list),
6427 + GFP_KERNEL);
6427 6428 if (!accept_list) {
6428 6429 hci_dev_unlock(hdev);
6429 6430 return -ENOMEM;
modified net/bluetooth/l2cap_core.c
@@ -1337,7 +1337,7 @@ static void l2cap_le_connect(struct l2cap_chan *chan)
1337 1337 struct l2cap_ecred_conn_data {
1338 1338 struct {
1339 1339 struct l2cap_ecred_conn_req_hdr req;
1340 - __le16 scid[L2CAP_ECRED_CONN_SCID_MAX];
1340 + __le16 scid[5];
1341 1341 } __packed pdu;
1342 1342 struct l2cap_chan *chan;
1343 1343 struct pid *pid;
@@ -1352,7 +1352,7 @@ static void l2cap_ecred_defer_connect(struct l2cap_chan *chan, void *data)
1352 1352 if (chan == conn->chan)
1353 1353 return;
1354 1354
1355 - if (!test_bit(FLAG_DEFER_SETUP, &chan->flags))
1355 + if (!test_and_clear_bit(FLAG_DEFER_SETUP, &chan->flags))
1356 1356 return;
1357 1357
1358 1358 pid = chan->ops->get_peer_pid(chan);
@@ -1362,16 +1362,9 @@ static void l2cap_ecred_defer_connect(struct l2cap_chan *chan, void *data)
1362 1362 chan->mode != L2CAP_MODE_EXT_FLOWCTL || chan->state != BT_CONNECT)
1363 1363 return;
1364 1364
1365 - if (!test_and_clear_bit(FLAG_DEFER_SETUP, &chan->flags))
1366 - return;
1367 -
1368 1365 if (test_and_set_bit(FLAG_ECRED_CONN_REQ_SENT, &chan->flags))
1369 1366 return;
1370 1367
1371 - /* Unreachable, checked in l2cap_connect (+timer drops it if reached) */
1372 - if (WARN_ON_ONCE(conn->count >= ARRAY_SIZE(conn->pdu.scid)))
1373 - return;
1374 -
1375 1368 l2cap_ecred_init(chan, 0);
1376 1369
1377 1370 /* Set the same ident so we can match on the rsp */
@@ -3901,9 +3894,6 @@ static void l2cap_ecred_rsp_defer(struct l2cap_chan *chan, void *data)
3901 3894 struct l2cap_ecred_conn_rsp *rsp_flex =
3902 3895 container_of(&rsp->pdu.rsp, struct l2cap_ecred_conn_rsp, hdr);
3903 3896
3904 - if (chan->mode != L2CAP_MODE_EXT_FLOWCTL)
3905 - return;
3906 -
3907 3897 /* Check if channel for outgoing connection or if it wasn't deferred
3908 3898 * since in those cases it must be skipped.
3909 3899 */
@@ -3914,10 +3904,6 @@ static void l2cap_ecred_rsp_defer(struct l2cap_chan *chan, void *data)
3914 3904 /* Reset ident so only one response is sent */
3915 3905 chan->ident = 0;
3916 3906
3917 - /* Unreachable, check in l2cap_ecred_conn_req. If reached, drop rest */
3918 - if (WARN_ON_ONCE(rsp->count >= ARRAY_SIZE(rsp->pdu.scid)))
3919 - rsp->pdu.rsp.result = cpu_to_le16(L2CAP_CR_LE_NO_MEM);
3920 -
3921 3907 /* Include all channels pending with the same ident */
3922 3908 if (!rsp->pdu.rsp.result)
3923 3909 rsp_flex->dcid[rsp->count++] = cpu_to_le16(chan->scid);
@@ -5077,7 +5063,6 @@ static int l2cap_le_connect_req(struct l2cap_conn *conn,
5077 5063 __set_chan_timer(chan, chan->ops->get_sndtimeo(chan));
5078 5064
5079 5065 chan->ident = cmd->ident;
5080 - chan->mode = L2CAP_MODE_LE_FLOWCTL;
5081 5066
5082 5067 if (test_bit(FLAG_DEFER_SETUP, &chan->flags)) {
5083 5068 l2cap_state_change(chan, BT_CONNECT2);
@@ -7384,9 +7369,6 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
7384 7369 goto done;
7385 7370 }
7386 7371
7387 - mutex_lock(&conn->lock);
7388 - l2cap_chan_lock(chan);
7389 -
7390 7372 if (chan->mode == L2CAP_MODE_EXT_FLOWCTL) {
7391 7373 struct l2cap_chan_data data;
7392 7374
@@ -7394,20 +7376,19 @@ int l2cap_chan_connect(struct l2cap_chan *chan, __le16 psm, u16 cid,
7394 7376 data.pid = chan->ops->get_peer_pid(chan);
7395 7377 data.count = 1;
7396 7378
7397 - __l2cap_chan_list(conn, l2cap_chan_by_pid, &data);
7398 -
7399 - /* Leave room for non-deferred channel that ends the group. */
7400 - if (test_bit(FLAG_DEFER_SETUP, &chan->flags))
7401 - data.count += 1;
7379 + l2cap_chan_list(conn, l2cap_chan_by_pid, &data);
7402 7380
7403 7381 /* Check if there isn't too many channels being connected */
7404 7382 if (data.count > L2CAP_ECRED_CONN_SCID_MAX) {
7405 7383 hci_conn_drop(hcon);
7406 7384 err = -EPROTO;
7407 - goto chan_unlock;
7385 + goto done;
7408 7386 }
7409 7387 }
7410 7388
7389 + mutex_lock(&conn->lock);
7390 + l2cap_chan_lock(chan);
7391 +
7411 7392 if (cid && __l2cap_get_chan_by_dcid(conn, cid)) {
7412 7393 hci_conn_drop(hcon);
7413 7394 err = -EBUSY;
modified net/bluetooth/msft.c
@@ -769,8 +769,8 @@ void msft_register(struct hci_dev *hdev)
769 769
770 770 INIT_LIST_HEAD(&msft->handle_map);
771 771 INIT_LIST_HEAD(&msft->address_filters);
772 - mutex_init(&msft->filter_lock);
773 772 hdev->msft_data = msft;
773 + mutex_init(&msft->filter_lock);
774 774 }
775 775
776 776 void msft_release(struct hci_dev *hdev)
modified net/bridge/br_multicast.c
@@ -808,11 +808,7 @@ void br_multicast_del_pg(struct net_bridge_mdb_entry *mp,
808 808 struct hlist_node *tmp;
809 809
810 810 rcu_assign_pointer(*pp, pg->next);
811 - /* Keep ->next (held under multicast_lock, freed later by the GC work):
812 - * a port->mglist teardown walk may have latched this node as its next,
813 - * and deleting other groups of the same port must not truncate it.
814 - */
815 - hlist_del_init_rcu(&pg->mglist);
811 + hlist_del_init(&pg->mglist);
816 812 br_multicast_eht_clean_sets(pg);
817 813 hlist_for_each_entry_safe(ent, tmp, &pg->src_list, node)
818 814 br_multicast_del_group_src(ent, false);
@@ -839,13 +835,6 @@ static void br_multicast_find_del_pg(struct net_bridge *br,
839 835 struct net_bridge_mdb_entry *mp;
840 836 struct net_bridge_port_group *p;
841 837
842 - /* A teardown walk over port->mglist can reach a group that an earlier
843 - * iteration already deleted as a side effect. It is off mp->ports by
844 - * now, so skip it instead of falling through to the WARN_ON() below.
845 - */
846 - if (hlist_unhashed(&pg->mglist))
847 - return;
848 -
849 838 mp = br_mdb_ip_get(br, &pg->key.addr);
850 839 if (WARN_ON(!mp))
851 840 return;
modified net/ceph/messenger.c
@@ -1003,6 +1003,7 @@ static struct page *ceph_msg_data_iter_next(struct ceph_msg_data_cursor *cursor,
1003 1003 * we'll get an iov_iter_get_pages2 variant that doesn't take
1004 1004 * page refs. Until then, just put the page ref.
1005 1005 */
1006 + VM_BUG_ON_PAGE(!PageWriteback(page) && page_count(page) < 2, page);
1006 1007 put_page(page);
1007 1008
1008 1009 *length = min_t(size_t, len, cursor->resid);
modified net/core/dev.c
@@ -12703,7 +12703,7 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net,
12703 12703 const char *pat, int new_ifindex,
12704 12704 struct netlink_ext_ack *extack)
12705 12705 {
12706 - struct netdev_name_node *name_node, *tmp;
12706 + struct netdev_name_node *name_node;
12707 12707 struct net *net_old = dev_net(dev);
12708 12708 char new_name[IFNAMSIZ] = {};
12709 12709 int err, new_nsid;
@@ -12749,19 +12749,13 @@ int __dev_change_net_namespace(struct net_device *dev, struct net *net,
12749 12749 }
12750 12750 /* Check that none of the altnames conflicts. */
12751 12751 err = -EEXIST;
12752 - netdev_for_each_altname_safe(dev, name_node, tmp) {
12753 - if (!netdev_name_in_use(net, name_node->name))
12754 - continue;
12755 -
12756 - if (!check_net(net_old)) {
12757 - __netdev_name_node_alt_destroy(name_node);
12758 - continue;
12752 + netdev_for_each_altname(dev, name_node) {
12753 + if (netdev_name_in_use(net, name_node->name)) {
12754 + NL_SET_ERR_MSG_FMT(extack,
12755 + "An interface with the altname %s exists in the target netns",
12756 + name_node->name);
12757 + goto out;
12759 12758 }
12760 -
12761 - NL_SET_ERR_MSG_FMT(extack,
12762 - "An interface with the altname %s exists in the target netns",
12763 - name_node->name);
12764 - goto out;
12765 12759 }
12766 12760
12767 12761 /* Check that new_ifindex isn't used yet. */
@@ -13216,6 +13210,7 @@ static struct pernet_operations __net_initdata netdev_net_ops = {
13216 13210
13217 13211 static void __net_exit default_device_exit_net(struct net *net)
13218 13212 {
13213 + struct netdev_name_node *name_node, *tmp;
13219 13214 struct net_device *dev, *aux;
13220 13215 /*
13221 13216 * Push all migratable network devices back to the
@@ -13239,6 +13234,10 @@ static void __net_exit default_device_exit_net(struct net *net)
13239 13234 if (netdev_name_in_use(&init_net, fb_name))
13240 13235 snprintf(fb_name, IFNAMSIZ, "dev%%d");
13241 13236
13237 + netdev_for_each_altname_safe(dev, name_node, tmp)
13238 + if (netdev_name_in_use(&init_net, name_node->name))
13239 + __netdev_name_node_alt_destroy(name_node);
13240 +
13242 13241 err = dev_change_net_namespace(dev, &init_net, fb_name);
13243 13242 if (err) {
13244 13243 pr_emerg("%s: failed to move %s to init_net: %d\n",
modified net/core/gro_cells.c
@@ -22,8 +22,6 @@ int gro_cells_receive(struct gro_cells *gcells, struct sk_buff *skb)
22 22 if (unlikely(!(dev->flags & IFF_UP)))
23 23 goto drop;
24 24
25 - skb_unset_transport_header(skb);
26 -
27 25 if (!gcells->cells || skb_cloned(skb) || netif_elide_gro(dev)) {
28 26 res = netif_rx(skb);
29 27 goto unlock;
modified net/core/page_pool.c
@@ -1073,8 +1073,7 @@ netmem_ref page_pool_alloc_frag_netmem(struct page_pool *pool,
1073 1073 if (WARN_ON(size > max_size))
1074 1074 return 0;
1075 1075
1076 - size = ALIGN(size, max_t(unsigned int, dma_get_cache_alignment(),
1077 - __alignof__(struct skb_shared_info)));
1076 + size = ALIGN(size, dma_get_cache_alignment());
1078 1077 *offset = pool->frag_offset;
1079 1078
1080 1079 if (netmem && *offset + size > max_size) {
modified net/core/sock.c
@@ -2494,9 +2494,6 @@ struct sock *sk_clone(const struct sock *sk, const gfp_t priority,
2494 2494 #ifdef CONFIG_BPF_SYSCALL
2495 2495 RCU_INIT_POINTER(newsk->sk_bpf_storage, NULL);
2496 2496 #endif
2497 - #if IS_ENABLED(CONFIG_INET_PSP)
2498 - RCU_INIT_POINTER(newsk->psp_assoc, NULL);
2499 - #endif
2500 2497
2501 2498 /* SANITY */
2502 2499 if (likely(newsk->sk_net_refcnt)) {
modified net/devlink/netlink.c
@@ -251,7 +251,7 @@ devlink_get_parent_from_attrs_lock(struct net *net, struct nlattr **attrs)
251 251 if (!attrs[DEVLINK_ATTR_PARENT_DEV])
252 252 return ERR_PTR(-EINVAL);
253 253
254 - tb = kzalloc_objs(*tb, maxtype + 1);
254 + tb = kcalloc(maxtype + 1, sizeof(*tb), GFP_KERNEL);
255 255 if (!tb)
256 256 return ERR_PTR(-ENOMEM);
257 257
modified net/devlink/param.c
@@ -330,12 +330,13 @@ static int devlink_nl_param_fill(struct sk_buff *msg, struct devlink *devlink,
330 330 int err;
331 331 int i;
332 332
333 - default_value = kzalloc_objs(*default_value,
334 - DEVLINK_PARAM_CMODE_MAX + 1);
333 + default_value = kcalloc(DEVLINK_PARAM_CMODE_MAX + 1,
334 + sizeof(*default_value), GFP_KERNEL);
335 335 if (!default_value)
336 336 return -ENOMEM;
337 337
338 - param_value = kzalloc_objs(*param_value, DEVLINK_PARAM_CMODE_MAX + 1);
338 + param_value = kcalloc(DEVLINK_PARAM_CMODE_MAX + 1,
339 + sizeof(*param_value), GFP_KERNEL);
339 340 if (!param_value) {
340 341 kfree(default_value);
341 342 return -ENOMEM;
modified net/ipv4/fib_semantics.c
@@ -874,7 +874,7 @@ static void fib_rebalance(struct fib_info *fi)
874 874 change_nexthops(fi) {
875 875 int upper_bound;
876 876
877 - if (!total || nexthop_nh->fib_nh_flags & RTNH_F_DEAD) {
877 + if (nexthop_nh->fib_nh_flags & RTNH_F_DEAD) {
878 878 upper_bound = -1;
879 879 } else if (ip_ignore_linkdown(nexthop_nh->fib_nh_dev) &&
880 880 nexthop_nh->fib_nh_flags & RTNH_F_LINKDOWN) {
modified net/ipv4/igmp.c
@@ -188,10 +188,6 @@ static void ip_ma_put(struct ip_mc_list *im)
188 188 }
189 189 }
190 190
191 - #define pmc_dereference(e, pmc) \
192 - rcu_dereference_protected(e, lockdep_is_held(&(pmc)->lock) || \
193 - lockdep_is_held(&(pmc)->interface->mc_tomb_lock))
194 -
195 191 #define for_each_pmc_rcu(in_dev, pmc) \
196 192 for (pmc = rcu_dereference(in_dev->mc_list); \
197 193 pmc != NULL; \
@@ -202,28 +198,13 @@ static void ip_ma_put(struct ip_mc_list *im)
202 198 pmc != NULL; \
203 199 pmc = rtnl_dereference(pmc->next_rcu))
204 200
205 - #define for_each_psf_mclock(pmc, psf) \
206 - for (psf = pmc_dereference((pmc)->sources, pmc); \
207 - psf; \
208 - psf = pmc_dereference(psf->sf_next, pmc))
209 -
210 - #define for_each_psf_rcu(im, psf) \
211 - for (psf = rcu_dereference((im)->sources); \
212 - psf; \
213 - psf = rcu_dereference(psf->sf_next))
214 -
215 - #define for_each_psf_tomb(pmc, psf) \
216 - for (psf = pmc_dereference((pmc)->tomb, pmc); \
217 - psf; \
218 - psf = pmc_dereference(psf->sf_next, pmc))
219 -
220 201 static void ip_sf_list_clear_all(struct ip_sf_list *psf)
221 202 {
222 203 struct ip_sf_list *next;
223 204
224 205 while (psf) {
225 - next = rcu_dereference_protected(psf->sf_next, 1);
226 - kfree_rcu(psf, rcu);
206 + next = psf->sf_next;
207 + kfree(psf);
227 208 psf = next;
228 209 }
229 210 }
@@ -368,7 +349,7 @@ igmp_scount(struct ip_mc_list *pmc, int type, int gdeleted, int sdeleted)
368 349 struct ip_sf_list *psf;
369 350 int scount = 0;
370 351
371 - for_each_psf_mclock(pmc, psf) {
352 + for (psf = pmc->sources; psf; psf = psf->sf_next) {
372 353 if (!is_in(pmc, psf, type, gdeleted, sdeleted))
373 354 continue;
374 355 scount++;
@@ -513,8 +494,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
513 494 struct net *net = dev_net(dev);
514 495 struct igmpv3_report *pih;
515 496 struct igmpv3_grec *pgr = NULL;
516 - struct ip_sf_list *psf, *psf_next, *psf_prev;
517 - struct ip_sf_list __rcu **psf_list;
497 + struct ip_sf_list *psf, *psf_next, *psf_prev, **psf_list;
518 498 int scount, stotal, first, isquery, truncate;
519 499 unsigned int mtu;
520 500
@@ -537,7 +517,7 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
537 517
538 518 psf_list = sdeleted ? &pmc->tomb : &pmc->sources;
539 519
540 - if (!rcu_access_pointer(*psf_list))
520 + if (!*psf_list)
541 521 goto empty_source;
542 522
543 523 pih = skb ? igmpv3_report_hdr(skb) : NULL;
@@ -553,12 +533,10 @@ static struct sk_buff *add_grec(struct sk_buff *skb, struct ip_mc_list *pmc,
553 533 }
554 534 first = 1;
555 535 psf_prev = NULL;
556 - for (psf = pmc_dereference(*psf_list, pmc);
557 - psf;
558 - psf = psf_next) {
536 + for (psf = *psf_list; psf; psf = psf_next) {
559 537 __be32 *psrc;
560 538
561 - psf_next = pmc_dereference(psf->sf_next, pmc);
539 + psf_next = psf->sf_next;
562 540
563 541 if (!is_in(pmc, psf, type, gdeleted, sdeleted)) {
564 542 psf_prev = psf;
@@ -605,12 +583,10 @@ decrease_sf_crcount:
605 583 psf->sf_crcount--;
606 584 if ((sdeleted || gdeleted) && psf->sf_crcount == 0) {
607 585 if (psf_prev)
608 - rcu_assign_pointer(psf_prev->sf_next,
609 - psf_next);
586 + psf_prev->sf_next = psf->sf_next;
610 587 else
611 - rcu_assign_pointer(*psf_list,
612 - psf_next);
613 - kfree_rcu(psf, rcu);
588 + *psf_list = psf->sf_next;
589 + kfree(psf);
614 590 continue;
615 591 }
616 592 }
@@ -679,29 +655,28 @@ static int igmpv3_send_report(struct in_device *in_dev, struct ip_mc_list *pmc)
679 655 /*
680 656 * remove zero-count source records from a source filter list
681 657 */
682 - static void igmpv3_clear_zeros(struct ip_sf_list __rcu **ppsf)
658 + static void igmpv3_clear_zeros(struct ip_sf_list **ppsf)
683 659 {
684 660 struct ip_sf_list *psf_prev, *psf_next, *psf;
685 661
686 662 psf_prev = NULL;
687 - for (psf = rcu_dereference_protected(*ppsf, 1); psf; psf = psf_next) {
688 - psf_next = rcu_dereference_protected(psf->sf_next, 1);
663 + for (psf = *ppsf; psf; psf = psf_next) {
664 + psf_next = psf->sf_next;
689 665 if (psf->sf_crcount == 0) {
690 666 if (psf_prev)
691 - rcu_assign_pointer(psf_prev->sf_next, psf_next);
667 + psf_prev->sf_next = psf->sf_next;
692 668 else
693 - rcu_assign_pointer(*ppsf, psf_next);
694 - kfree_rcu(psf, rcu);
695 - } else {
669 + *ppsf = psf->sf_next;
670 + kfree(psf);
671 + } else
696 672 psf_prev = psf;
697 - }
698 673 }
699 674 }
700 675
701 676 static void kfree_pmc(struct ip_mc_list *pmc)
702 677 {
703 - ip_sf_list_clear_all(rcu_dereference_protected(pmc->sources, 1));
704 - ip_sf_list_clear_all(rcu_dereference_protected(pmc->tomb, 1));
678 + ip_sf_list_clear_all(pmc->sources);
679 + ip_sf_list_clear_all(pmc->tomb);
705 680 kfree(pmc);
706 681 }
707 682
@@ -735,8 +710,7 @@ static void igmpv3_send_cr(struct in_device *in_dev)
735 710 igmpv3_clear_zeros(&pmc->sources);
736 711 }
737 712 }
738 - if (pmc->crcount == 0 && !rcu_access_pointer(pmc->tomb) &&
739 - !rcu_access_pointer(pmc->sources)) {
713 + if (pmc->crcount == 0 && !pmc->tomb && !pmc->sources) {
740 714 if (pmc_prev)
741 715 pmc_prev->next = pmc_next;
742 716 else
@@ -922,7 +896,7 @@ static int igmp_xmarksources(struct ip_mc_list *pmc, int nsrcs, __be32 *srcs)
922 896 int i, scount;
923 897
924 898 scount = 0;
925 - for_each_psf_mclock(pmc, psf) {
899 + for (psf = pmc->sources; psf; psf = psf->sf_next) {
926 900 if (scount == nsrcs)
927 901 break;
928 902 for (i = 0; i < nsrcs; i++) {
@@ -953,7 +927,7 @@ static int igmp_marksources(struct ip_mc_list *pmc, int nsrcs, __be32 *srcs)
953 927
954 928 /* mark INCLUDE-mode sources */
955 929 scount = 0;
956 - for_each_psf_mclock(pmc, psf) {
930 + for (psf = pmc->sources; psf; psf = psf->sf_next) {
957 931 if (scount == nsrcs)
958 932 break;
959 933 for (i = 0; i < nsrcs; i++)
@@ -1254,12 +1228,11 @@ static void igmpv3_add_delrec(struct in_device *in_dev, struct ip_mc_list *im,
1254 1228 if (pmc->sfmode == MCAST_INCLUDE) {
1255 1229 struct ip_sf_list *psf;
1256 1230
1257 - for_each_psf_mclock(im, psf)
1258 - psf->sf_crcount = pmc->crcount;
1259 1231 pmc->tomb = im->tomb;
1260 1232 pmc->sources = im->sources;
1261 - RCU_INIT_POINTER(im->tomb, NULL);
1262 - RCU_INIT_POINTER(im->sources, NULL);
1233 + im->tomb = im->sources = NULL;
1234 + for (psf = pmc->sources; psf; psf = psf->sf_next)
1235 + psf->sf_crcount = pmc->crcount;
1263 1236 }
1264 1237 spin_unlock_bh(&im->lock);
1265 1238
@@ -1298,18 +1271,9 @@ static void igmpv3_del_delrec(struct in_device *in_dev, struct ip_mc_list *im)
1298 1271 if (pmc) {
1299 1272 im->interface = pmc->interface;
1300 1273 if (im->sfmode == MCAST_INCLUDE) {
1301 - struct ip_sf_list *sources, *tomb;
1302 -
1303 - tomb = rcu_replace_pointer(im->tomb,
1304 - rcu_dereference_protected(pmc->tomb, 1),
1305 - lockdep_is_held(&im->lock));
1306 - rcu_assign_pointer(pmc->tomb, tomb);
1307 -
1308 - sources = rcu_replace_pointer(im->sources,
1309 - rcu_dereference_protected(pmc->sources, 1),
1310 - lockdep_is_held(&im->lock));
1311 - rcu_assign_pointer(pmc->sources, sources);
1312 - for_each_psf_mclock(im, psf)
1274 + swap(im->tomb, pmc->tomb);
1275 + swap(im->sources, pmc->sources);
1276 + for (psf = im->sources; psf; psf = psf->sf_next)
1313 1277 psf->sf_crcount = in_dev->mr_qrv ?:
1314 1278 READ_ONCE(net->ipv4.sysctl_igmp_qrv);
1315 1279 } else {
@@ -1346,8 +1310,8 @@ static void igmpv3_clear_delrec(struct in_device *in_dev)
1346 1310 struct ip_sf_list *psf;
1347 1311
1348 1312 spin_lock_bh(&pmc->lock);
1349 - psf = pmc_dereference(pmc->tomb, pmc);
1350 - RCU_INIT_POINTER(pmc->tomb, NULL);
1313 + psf = pmc->tomb;
1314 + pmc->tomb = NULL;
1351 1315 spin_unlock_bh(&pmc->lock);
1352 1316 ip_sf_list_clear_all(psf);
1353 1317 }
@@ -2026,7 +1990,7 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode,
2026 1990 int rv = 0;
2027 1991
2028 1992 psf_prev = NULL;
2029 - for_each_psf_mclock(pmc, psf) {
1993 + for (psf = pmc->sources; psf; psf = psf->sf_next) {
2030 1994 if (psf->sf_inaddr == *psfsrc)
2031 1995 break;
2032 1996 psf_prev = psf;
@@ -2035,7 +1999,7 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode,
2035 1999 /* source filter not found, or count wrong => bug */
2036 2000 return -ESRCH;
2037 2001 }
2038 - WRITE_ONCE(psf->sf_count[sfmode], psf->sf_count[sfmode] - 1);
2002 + psf->sf_count[sfmode]--;
2039 2003 if (psf->sf_count[sfmode] == 0) {
2040 2004 ip_rt_multicast_event(pmc->interface);
2041 2005 }
@@ -2047,28 +2011,19 @@ static int ip_mc_del1_src(struct ip_mc_list *pmc, int sfmode,
2047 2011
2048 2012 /* no more filters for this source */
2049 2013 if (psf_prev)
2050 - rcu_assign_pointer(psf_prev->sf_next,
2051 - pmc_dereference(psf->sf_next, pmc));
2014 + psf_prev->sf_next = psf->sf_next;
2052 2015 else
2053 - rcu_assign_pointer(pmc->sources,
2054 - pmc_dereference(psf->sf_next, pmc));
2016 + pmc->sources = psf->sf_next;
2055 2017 #ifdef CONFIG_IP_MULTICAST
2056 2018 if (psf->sf_oldin &&
2057 2019 !IGMP_V1_SEEN(in_dev) && !IGMP_V2_SEEN(in_dev)) {
2058 - struct ip_sf_list *dpsf = kmalloc_obj(*dpsf, GFP_ATOMIC);
2059 -
2060 - if (dpsf) {
2061 - *dpsf = *psf;
2062 - dpsf->sf_crcount = in_dev->mr_qrv ?:
2063 - READ_ONCE(net->ipv4.sysctl_igmp_qrv);
2064 - rcu_assign_pointer(dpsf->sf_next,
2065 - pmc_dereference(pmc->tomb, pmc));
2066 - rcu_assign_pointer(pmc->tomb, dpsf);
2067 - rv = 1;
2068 - }
2069 - }
2020 + psf->sf_crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv);
2021 + psf->sf_next = pmc->tomb;
2022 + pmc->tomb = psf;
2023 + rv = 1;
2024 + } else
2070 2025 #endif
2071 - kfree_rcu(psf, rcu);
2026 + kfree(psf);
2072 2027 }
2073 2028 return rv;
2074 2029 }
@@ -2105,7 +2060,7 @@ static int ip_mc_del_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
2105 2060 err = -EINVAL;
2106 2061 if (!pmc->sfcount[sfmode])
2107 2062 goto out_unlock;
2108 - WRITE_ONCE(pmc->sfcount[sfmode], pmc->sfcount[sfmode] - 1);
2063 + pmc->sfcount[sfmode]--;
2109 2064 }
2110 2065 err = 0;
2111 2066 for (i = 0; i < sfcount; i++) {
@@ -2128,7 +2083,7 @@ static int ip_mc_del_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
2128 2083 #ifdef CONFIG_IP_MULTICAST
2129 2084 pmc->crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv);
2130 2085 WRITE_ONCE(in_dev->mr_ifc_count, pmc->crcount);
2131 - for_each_psf_mclock(pmc, psf)
2086 + for (psf = pmc->sources; psf; psf = psf->sf_next)
2132 2087 psf->sf_crcount = 0;
2133 2088 igmp_ifc_event(pmc->interface);
2134 2089 } else if (sf_setstate(pmc) || changerec) {
@@ -2149,7 +2104,7 @@ static int ip_mc_add1_src(struct ip_mc_list *pmc, int sfmode,
2149 2104 struct ip_sf_list *psf, *psf_prev;
2150 2105
2151 2106 psf_prev = NULL;
2152 - for_each_psf_mclock(pmc, psf) {
2107 + for (psf = pmc->sources; psf; psf = psf->sf_next) {
2153 2108 if (psf->sf_inaddr == *psfsrc)
2154 2109 break;
2155 2110 psf_prev = psf;
@@ -2159,12 +2114,12 @@ static int ip_mc_add1_src(struct ip_mc_list *pmc, int sfmode,
2159 2114 if (!psf)
2160 2115 return -ENOBUFS;
2161 2116 psf->sf_inaddr = *psfsrc;
2162 - if (psf_prev)
2163 - rcu_assign_pointer(psf_prev->sf_next, psf);
2164 - else
2165 - rcu_assign_pointer(pmc->sources, psf);
2117 + if (psf_prev) {
2118 + psf_prev->sf_next = psf;
2119 + } else
2120 + pmc->sources = psf;
2166 2121 }
2167 - WRITE_ONCE(psf->sf_count[sfmode], psf->sf_count[sfmode] + 1);
2122 + psf->sf_count[sfmode]++;
2168 2123 if (psf->sf_count[sfmode] == 1) {
2169 2124 ip_rt_multicast_event(pmc->interface);
2170 2125 }
@@ -2177,15 +2132,13 @@ static void sf_markstate(struct ip_mc_list *pmc)
2177 2132 struct ip_sf_list *psf;
2178 2133 int mca_xcount = pmc->sfcount[MCAST_EXCLUDE];
2179 2134
2180 - for_each_psf_mclock(pmc, psf) {
2135 + for (psf = pmc->sources; psf; psf = psf->sf_next)
2181 2136 if (pmc->sfcount[MCAST_EXCLUDE]) {
2182 2137 psf->sf_oldin = mca_xcount ==
2183 2138 psf->sf_count[MCAST_EXCLUDE] &&
2184 2139 !psf->sf_count[MCAST_INCLUDE];
2185 - } else {
2140 + } else
2186 2141 psf->sf_oldin = psf->sf_count[MCAST_INCLUDE] != 0;
2187 - }
2188 - }
2189 2142 }
2190 2143
2191 2144 static int sf_setstate(struct ip_mc_list *pmc)
@@ -2196,31 +2149,27 @@ static int sf_setstate(struct ip_mc_list *pmc)
2196 2149 int new_in, rv;
2197 2150
2198 2151 rv = 0;
2199 - for_each_psf_mclock(pmc, psf) {
2152 + for (psf = pmc->sources; psf; psf = psf->sf_next) {
2200 2153 if (pmc->sfcount[MCAST_EXCLUDE]) {
2201 2154 new_in = mca_xcount == psf->sf_count[MCAST_EXCLUDE] &&
2202 2155 !psf->sf_count[MCAST_INCLUDE];
2203 - } else {
2156 + } else
2204 2157 new_in = psf->sf_count[MCAST_INCLUDE] != 0;
2205 - }
2206 2158 if (new_in) {
2207 2159 if (!psf->sf_oldin) {
2208 2160 struct ip_sf_list *prev = NULL;
2209 2161
2210 - for_each_psf_tomb(pmc, dpsf) {
2162 + for (dpsf = pmc->tomb; dpsf; dpsf = dpsf->sf_next) {
2211 2163 if (dpsf->sf_inaddr == psf->sf_inaddr)
2212 2164 break;
2213 2165 prev = dpsf;
2214 2166 }
2215 2167 if (dpsf) {
2216 - struct ip_sf_list *dpsf_next;
2217 -
2218 - dpsf_next = pmc_dereference(dpsf->sf_next, pmc);
2219 2168 if (prev)
2220 - rcu_assign_pointer(prev->sf_next, dpsf_next);
2169 + prev->sf_next = dpsf->sf_next;
2221 2170 else
2222 - rcu_assign_pointer(pmc->tomb, dpsf_next);
2223 - kfree_rcu(dpsf, rcu);
2171 + pmc->tomb = dpsf->sf_next;
2172 + kfree(dpsf);
2224 2173 }
2225 2174 psf->sf_crcount = qrv;
2226 2175 rv++;
@@ -2232,19 +2181,17 @@ static int sf_setstate(struct ip_mc_list *pmc)
2232 2181 * add or update "delete" records if an active filter
2233 2182 * is now inactive
2234 2183 */
2235 - for_each_psf_tomb(pmc, dpsf) {
2184 + for (dpsf = pmc->tomb; dpsf; dpsf = dpsf->sf_next)
2236 2185 if (dpsf->sf_inaddr == psf->sf_inaddr)
2237 2186 break;
2238 - }
2239 2187 if (!dpsf) {
2240 2188 dpsf = kmalloc_obj(*dpsf, GFP_ATOMIC);
2241 2189 if (!dpsf)
2242 2190 continue;
2243 2191 *dpsf = *psf;
2244 2192 /* pmc->lock held by callers */
2245 - rcu_assign_pointer(dpsf->sf_next,
2246 - pmc_dereference(pmc->tomb, pmc));
2247 - rcu_assign_pointer(pmc->tomb, dpsf);
2193 + dpsf->sf_next = pmc->tomb;
2194 + pmc->tomb = dpsf;
2248 2195 }
2249 2196 dpsf->sf_crcount = qrv;
2250 2197 rv++;
@@ -2284,7 +2231,7 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
2284 2231 #endif
2285 2232 isexclude = pmc->sfmode == MCAST_EXCLUDE;
2286 2233 if (!delta)
2287 - WRITE_ONCE(pmc->sfcount[sfmode], pmc->sfcount[sfmode] + 1);
2234 + pmc->sfcount[sfmode]++;
2288 2235 err = 0;
2289 2236 for (i = 0; i < sfcount; i++) {
2290 2237 err = ip_mc_add1_src(pmc, sfmode, &psfsrc[i]);
@@ -2295,7 +2242,7 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
2295 2242 int j;
2296 2243
2297 2244 if (!delta)
2298 - WRITE_ONCE(pmc->sfcount[sfmode], pmc->sfcount[sfmode] - 1);
2245 + pmc->sfcount[sfmode]--;
2299 2246 for (j = 0; j < i; j++)
2300 2247 (void) ip_mc_del1_src(pmc, sfmode, &psfsrc[j]);
2301 2248 } else if (isexclude != (pmc->sfcount[MCAST_EXCLUDE] != 0)) {
@@ -2315,7 +2262,7 @@ static int ip_mc_add_src(struct in_device *in_dev, __be32 *pmca, int sfmode,
2315 2262
2316 2263 pmc->crcount = in_dev->mr_qrv ?: READ_ONCE(net->ipv4.sysctl_igmp_qrv);
2317 2264 WRITE_ONCE(in_dev->mr_ifc_count, pmc->crcount);
2318 - for_each_psf_mclock(pmc, psf)
2265 + for (psf = pmc->sources; psf; psf = psf->sf_next)
2319 2266 psf->sf_crcount = 0;
2320 2267 igmp_ifc_event(in_dev);
2321 2268 } else if (sf_setstate(pmc)) {
@@ -2331,13 +2278,13 @@ static void ip_mc_clear_src(struct ip_mc_list *pmc)
2331 2278 struct ip_sf_list *tomb, *sources;
2332 2279
2333 2280 spin_lock_bh(&pmc->lock);
2334 - tomb = pmc_dereference(pmc->tomb, pmc);
2335 - RCU_INIT_POINTER(pmc->tomb, NULL);
2336 - sources = pmc_dereference(pmc->sources, pmc);
2337 - RCU_INIT_POINTER(pmc->sources, NULL);
2281 + tomb = pmc->tomb;
2282 + pmc->tomb = NULL;
2283 + sources = pmc->sources;
2284 + pmc->sources = NULL;
2338 2285 pmc->sfmode = MCAST_EXCLUDE;
2339 - WRITE_ONCE(pmc->sfcount[MCAST_INCLUDE], 0);
2340 - WRITE_ONCE(pmc->sfcount[MCAST_EXCLUDE], 1);
2286 + pmc->sfcount[MCAST_INCLUDE] = 0;
2287 + pmc->sfcount[MCAST_EXCLUDE] = 1;
2341 2288 spin_unlock_bh(&pmc->lock);
2342 2289
2343 2290 ip_sf_list_clear_all(tomb);
@@ -2919,19 +2866,20 @@ int ip_check_mc_rcu(struct in_device *in_dev, __be32 mc_addr, __be32 src_addr, u
2919 2866 rv = 1;
2920 2867 } else if (im) {
2921 2868 if (src_addr) {
2922 - for_each_psf_rcu(im, psf) {
2869 + spin_lock_bh(&im->lock);
2870 + for (psf = im->sources; psf; psf = psf->sf_next) {
2923 2871 if (psf->sf_inaddr == src_addr)
2924 2872 break;
2925 2873 }
2926 2874 if (psf)
2927 - rv = READ_ONCE(psf->sf_count[MCAST_INCLUDE]) ||
2928 - READ_ONCE(psf->sf_count[MCAST_EXCLUDE]) !=
2929 - READ_ONCE(im->sfcount[MCAST_EXCLUDE]);
2875 + rv = psf->sf_count[MCAST_INCLUDE] ||
2876 + psf->sf_count[MCAST_EXCLUDE] !=
2877 + im->sfcount[MCAST_EXCLUDE];
2930 2878 else
2931 - rv = READ_ONCE(im->sfcount[MCAST_EXCLUDE]) != 0;
2932 - } else {
2879 + rv = im->sfcount[MCAST_EXCLUDE] != 0;
2880 + spin_unlock_bh(&im->lock);
2881 + } else
2933 2882 rv = 1; /* unspecified source; tentatively allow */
2934 - }
2935 2883 }
2936 2884 return rv;
2937 2885 }
@@ -3095,7 +3043,7 @@ static inline struct ip_sf_list *igmp_mcf_get_first(struct seq_file *seq)
3095 3043 im = rcu_dereference(idev->mc_list);
3096 3044 if (likely(im)) {
3097 3045 spin_lock_bh(&im->lock);
3098 - psf = pmc_dereference(im->sources, im);
3046 + psf = im->sources;
3099 3047 if (likely(psf)) {
3100 3048 state->im = im;
3101 3049 state->idev = idev;
@@ -3111,7 +3059,7 @@ static struct ip_sf_list *igmp_mcf_get_next(struct seq_file *seq, struct ip_sf_l
3111 3059 {
3112 3060 struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
3113 3061
3114 - psf = pmc_dereference(psf->sf_next, state->im);
3062 + psf = psf->sf_next;
3115 3063 while (!psf) {
3116 3064 spin_unlock_bh(&state->im->lock);
3117 3065 state->im = state->im->next;
@@ -3127,7 +3075,7 @@ static struct ip_sf_list *igmp_mcf_get_next(struct seq_file *seq, struct ip_sf_l
3127 3075 state->im = rcu_dereference(state->idev->mc_list);
3128 3076 }
3129 3077 spin_lock_bh(&state->im->lock);
3130 - psf = pmc_dereference(state->im->sources, state->im);
3078 + psf = state->im->sources;
3131 3079 }
3132 3080 out:
3133 3081 return psf;
modified net/ipv4/tcp.c
@@ -3182,7 +3182,8 @@ void __tcp_close(struct sock *sk, long timeout)
3182 3182 /* Unread data was tossed, zap the connection. */
3183 3183 NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONCLOSE);
3184 3184 tcp_set_state(sk, TCP_CLOSE);
3185 - tcp_send_active_reset(sk, SK_RST_REASON_TCP_ABORT_ON_CLOSE);
3185 + tcp_send_active_reset(sk, sk->sk_allocation,
3186 + SK_RST_REASON_TCP_ABORT_ON_CLOSE);
3186 3187 } else if (sock_flag(sk, SOCK_LINGER) && !sk->sk_lingertime) {
3187 3188 /* Check zero linger _after_ checking for unread data. */
3188 3189 sk->sk_prot->disconnect(sk, 0);
@@ -3256,7 +3257,7 @@ adjudge_to_death:
3256 3257 struct tcp_sock *tp = tcp_sk(sk);
3257 3258 if (READ_ONCE(tp->linger2) < 0) {
3258 3259 tcp_set_state(sk, TCP_CLOSE);
3259 - tcp_send_active_reset(sk,
3260 + tcp_send_active_reset(sk, GFP_ATOMIC,
3260 3261 SK_RST_REASON_TCP_ABORT_ON_LINGER);
3261 3262 __NET_INC_STATS(sock_net(sk),
3262 3263 LINUX_MIB_TCPABORTONLINGER);
@@ -3275,7 +3276,7 @@ adjudge_to_death:
3275 3276 if (sk->sk_state != TCP_CLOSE) {
3276 3277 if (tcp_check_oom(sk, 0)) {
3277 3278 tcp_set_state(sk, TCP_CLOSE);
3278 - tcp_send_active_reset(sk,
3279 + tcp_send_active_reset(sk, GFP_ATOMIC,
3279 3280 SK_RST_REASON_TCP_ABORT_ON_MEMORY);
3280 3281 __NET_INC_STATS(sock_net(sk),
3281 3282 LINUX_MIB_TCPABORTONMEMORY);
@@ -3376,14 +3377,14 @@ int tcp_disconnect(struct sock *sk, int flags)
3376 3377 } else if (unlikely(tp->repair)) {
3377 3378 WRITE_ONCE(sk->sk_err, ECONNABORTED);
3378 3379 } else if (tcp_need_reset(old_state)) {
3379 - tcp_send_active_reset(sk, SK_RST_REASON_TCP_STATE);
3380 + tcp_send_active_reset(sk, gfp_any(), SK_RST_REASON_TCP_STATE);
3380 3381 WRITE_ONCE(sk->sk_err, ECONNRESET);
3381 3382 } else if (tp->snd_nxt != tp->write_seq &&
3382 3383 (1 << old_state) & (TCPF_CLOSING | TCPF_LAST_ACK)) {
3383 3384 /* The last check adjusts for discrepancy of Linux wrt. RFC
3384 3385 * states
3385 3386 */
3386 - tcp_send_active_reset(sk,
3387 + tcp_send_active_reset(sk, gfp_any(),
3387 3388 SK_RST_REASON_TCP_DISCONNECT_WITH_DATA);
3388 3389 WRITE_ONCE(sk->sk_err, ECONNRESET);
3389 3390 } else if (old_state == TCP_SYN_SENT)
@@ -4561,11 +4562,9 @@ int do_tcp_getsockopt(struct sock *sk, int level,
4561 4562 if (copy_from_sockptr(&len, optlen, sizeof(int)))
4562 4563 return -EFAULT;
4563 4564
4564 - rcu_read_lock();
4565 - ca_ops = READ_ONCE(icsk->icsk_ca_ops);
4565 + ca_ops = icsk->icsk_ca_ops;
4566 4566 if (ca_ops && ca_ops->get_info)
4567 4567 sz = ca_ops->get_info(sk, ~0U, &attr, &info);
4568 - rcu_read_unlock();
4569 4568
4570 4569 len = min_t(unsigned int, len, sz);
4571 4570 if (copy_to_sockptr(optlen, &len, sizeof(int)))
@@ -4578,24 +4577,16 @@ int do_tcp_getsockopt(struct sock *sk, int level,
4578 4577 val = !inet_csk_in_pingpong_mode(sk);
4579 4578 break;
4580 4579
4581 - case TCP_CONGESTION: {
4582 - char ca_name[TCP_CA_NAME_MAX] = {};
4583 -
4580 + case TCP_CONGESTION:
4584 4581 if (copy_from_sockptr(&len, optlen, sizeof(int)))
4585 4582 return -EFAULT;
4586 4583 len = min_t(unsigned int, len, TCP_CA_NAME_MAX);
4587 4584 if (copy_to_sockptr(optlen, &len, sizeof(int)))
4588 4585 return -EFAULT;
4589 -
4590 - rcu_read_lock();
4591 - memcpy(ca_name, READ_ONCE(icsk->icsk_ca_ops)->name,
4592 - sizeof(ca_name));
4593 - rcu_read_unlock();
4594 -
4595 - if (copy_to_sockptr(optval, ca_name, len))
4586 + if (copy_to_sockptr(optval, icsk->icsk_ca_ops->name, len))
4596 4587 return -EFAULT;
4597 4588 return 0;
4598 - }
4589 +
4599 4590 case TCP_ULP:
4600 4591 if (copy_from_sockptr(&len, optlen, sizeof(int)))
4601 4592 return -EFAULT;
@@ -5156,7 +5147,8 @@ int tcp_abort(struct sock *sk, int err)
5156 5147 bh_lock_sock(sk);
5157 5148
5158 5149 if (tcp_need_reset(sk->sk_state))
5159 - tcp_send_active_reset(sk, SK_RST_REASON_TCP_STATE);
5150 + tcp_send_active_reset(sk, GFP_ATOMIC,
5151 + SK_RST_REASON_TCP_STATE);
5160 5152 tcp_done_with_error(sk, err);
5161 5153
5162 5154 bh_unlock_sock(sk);
modified net/ipv4/tcp_cong.c
@@ -223,7 +223,7 @@ void tcp_assign_congestion_control(struct sock *sk)
223 223 ca = rcu_dereference(net->ipv4.tcp_congestion_control);
224 224 if (unlikely(!bpf_try_module_get(ca, ca->owner)))
225 225 ca = &tcp_reno;
226 - WRITE_ONCE(icsk->icsk_ca_ops, ca);
226 + icsk->icsk_ca_ops = ca;
227 227 rcu_read_unlock();
228 228
229 229 memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv));
@@ -253,7 +253,7 @@ static void tcp_reinit_congestion_control(struct sock *sk,
253 253 struct inet_connection_sock *icsk = inet_csk(sk);
254 254
255 255 tcp_cleanup_congestion_control(sk);
256 - WRITE_ONCE(icsk->icsk_ca_ops, ca);
256 + icsk->icsk_ca_ops = ca;
257 257 icsk->icsk_ca_setsockopt = 1;
258 258 memset(icsk->icsk_ca_priv, 0, sizeof(icsk->icsk_ca_priv));
259 259
modified net/ipv4/tcp_dctcp.c
@@ -111,7 +111,7 @@ __bpf_kfunc static void dctcp_init(struct sock *sk)
111 111 /* No ECN support? Fall back to Reno. Also need to clear
112 112 * ECT from sk since it is set during 3WHS for DCTCP.
113 113 */
114 - WRITE_ONCE(inet_csk(sk)->icsk_ca_ops, &dctcp_reno);
114 + inet_csk(sk)->icsk_ca_ops = &dctcp_reno;
115 115 INET_ECN_dontxmit(sk);
116 116 }
117 117
@@ -228,7 +228,7 @@ static size_t dctcp_get_info(struct sock *sk, u32 ext, int *attr,
228 228 if (ext & (1 << (INET_DIAG_DCTCPINFO - 1)) ||
229 229 ext & (1 << (INET_DIAG_VEGASINFO - 1))) {
230 230 memset(&info->dctcp, 0, sizeof(info->dctcp));
231 - if (READ_ONCE(inet_csk(sk)->icsk_ca_ops) != &dctcp_reno) {
231 + if (inet_csk(sk)->icsk_ca_ops != &dctcp_reno) {
232 232 info->dctcp.dctcp_enabled = 1;
233 233 info->dctcp.dctcp_ce_state = (u16) ca->ce_state;
234 234 info->dctcp.dctcp_alpha = ca->dctcp_alpha;
modified net/ipv4/tcp_ipv4.c
@@ -2931,8 +2931,8 @@ static int bpf_iter_tcp_realloc_batch(struct bpf_tcp_iter_state *iter,
2931 2931 {
2932 2932 union bpf_tcp_iter_batch_item *new_batch;
2933 2933
2934 - new_batch = kvmalloc_objs(*new_batch, new_batch_sz,
2935 - flags | __GFP_NOWARN);
2934 + new_batch = kvmalloc_array(new_batch_sz, sizeof(*new_batch),
2935 + flags | __GFP_NOWARN);
2936 2936 if (!new_batch)
2937 2937 return -ENOMEM;
2938 2938
modified net/ipv4/tcp_minisocks.c
@@ -507,7 +507,7 @@ void tcp_ca_openreq_child(struct sock *sk, const struct dst_entry *dst)
507 507 ca = tcp_ca_find_key(ca_key);
508 508 if (likely(ca && bpf_try_module_get(ca, ca->owner))) {
509 509 icsk->icsk_ca_dst_locked = tcp_ca_dst_locked(dst);
510 - WRITE_ONCE(icsk->icsk_ca_ops, ca);
510 + icsk->icsk_ca_ops = ca;
511 511 ca_got_dst = true;
512 512 }
513 513 rcu_read_unlock();
modified net/ipv4/tcp_offload.c
@@ -332,7 +332,6 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb,
332 332 flush |= skb->ip_summed != p->ip_summed;
333 333 flush |= skb->csum_level != p->csum_level;
334 334 flush |= NAPI_GRO_CB(p)->count >= 64;
335 - flush |= NAPI_GRO_CB(p)->is_flist != NAPI_GRO_CB(skb)->is_flist;
336 335 skb_set_network_header(skb, skb_gro_receive_network_offset(skb));
337 336
338 337 if (flush || skb_gro_receive_list(p, skb))
@@ -396,20 +395,12 @@ static void tcp4_check_fraglist_gro(struct list_head *head, struct sk_buff *skb,
396 395 struct net *net;
397 396 int iif, sdif;
398 397
398 + if (likely(!(skb->dev->features & NETIF_F_GRO_FRAGLIST)))
399 + return;
400 +
399 401 p = tcp_gro_lookup(head, th);
400 402 if (p) {
401 - /* flist GRO applies to consecutive non-GSO skbs */
402 - if (!skb_is_gso(skb) || !NAPI_GRO_CB(p)->is_flist) {
403 - NAPI_GRO_CB(skb)->is_flist = NAPI_GRO_CB(p)->is_flist;
404 - return;
405 - }
406 -
407 - /* Fall back to the regular GRO path */
408 - if (NAPI_GRO_CB(p)->count == 1)
409 - NAPI_GRO_CB(p)->is_flist = 0;
410 -
411 - NAPI_GRO_CB(skb)->is_flist = 0;
412 -
403 + NAPI_GRO_CB(skb)->is_flist = NAPI_GRO_CB(p)->is_flist;
413 404 return;
414 405 }
415 406
@@ -419,7 +410,7 @@ static void tcp4_check_fraglist_gro(struct list_head *head, struct sk_buff *skb,
419 410 sk = __inet_lookup_established(net, iph->saddr, th->source,
420 411 iph->daddr, ntohs(th->dest),
421 412 iif, sdif);
422 - NAPI_GRO_CB(skb)->is_flist = !sk && !skb_is_gso(skb);
413 + NAPI_GRO_CB(skb)->is_flist = !sk;
423 414 if (sk)
424 415 sock_gen_put(sk);
425 416 }
@@ -439,8 +430,7 @@ struct sk_buff *tcp4_gro_receive(struct list_head *head, struct sk_buff *skb)
439 430 if (!th)
440 431 goto flush;
441 432
442 - if (unlikely(skb->dev->features & NETIF_F_GRO_FRAGLIST))
443 - tcp4_check_fraglist_gro(head, skb, th);
433 + tcp4_check_fraglist_gro(head, skb, th);
444 434
445 435 return tcp_gro_receive(head, skb, th);
446 436
modified net/ipv4/tcp_output.c
@@ -3849,9 +3849,9 @@ void tcp_send_fin(struct sock *sk)
3849 3849 * was unread data in the receive queue. This behavior is recommended
3850 3850 * by RFC 2525, section 2.17. -DaveM
3851 3851 */
3852 - void tcp_send_active_reset(struct sock *sk, enum sk_rst_reason reason)
3852 + void tcp_send_active_reset(struct sock *sk, gfp_t priority,
3853 + enum sk_rst_reason reason)
3853 3854 {
3854 - gfp_t priority = sk_gfp_mask(sk, GFP_ATOMIC | __GFP_NOWARN);
3855 3855 struct sk_buff *skb;
3856 3856
3857 3857 TCP_INC_STATS(sock_net(sk), TCP_MIB_OUTRSTS);
@@ -4092,7 +4092,7 @@ static void tcp_ca_dst_init(struct sock *sk, const struct dst_entry *dst)
4092 4092 if (likely(ca && bpf_try_module_get(ca, ca->owner))) {
4093 4093 bpf_module_put(icsk->icsk_ca_ops, icsk->icsk_ca_ops->owner);
4094 4094 icsk->icsk_ca_dst_locked = tcp_ca_dst_locked(dst);
4095 - WRITE_ONCE(icsk->icsk_ca_ops, ca);
4095 + icsk->icsk_ca_ops = ca;
4096 4096 }
4097 4097 rcu_read_unlock();
4098 4098 }
modified net/ipv4/tcp_timer.c
@@ -126,7 +126,7 @@ static int tcp_out_of_resources(struct sock *sk, bool do_reset)
126 126 (!tp->snd_wnd && !tp->packets_out))
127 127 do_reset = true;
128 128 if (do_reset)
129 - tcp_send_active_reset(sk,
129 + tcp_send_active_reset(sk, GFP_ATOMIC,
130 130 SK_RST_REASON_TCP_ABORT_ON_MEMORY);
131 131 tcp_done(sk);
132 132 __NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY);
@@ -809,7 +809,7 @@ static void tcp_keepalive_timer(struct timer_list *t)
809 809 goto out;
810 810 }
811 811 }
812 - tcp_send_active_reset(sk, SK_RST_REASON_TCP_STATE);
812 + tcp_send_active_reset(sk, GFP_ATOMIC, SK_RST_REASON_TCP_STATE);
813 813 goto death;
814 814 }
815 815
@@ -836,7 +836,7 @@ static void tcp_keepalive_timer(struct timer_list *t)
836 836 icsk->icsk_probes_out > 0) ||
837 837 (user_timeout == 0 &&
838 838 icsk->icsk_probes_out >= keepalive_probes(tp))) {
839 - tcp_send_active_reset(sk,
839 + tcp_send_active_reset(sk, GFP_ATOMIC,
840 840 SK_RST_REASON_TCP_KEEPALIVE_TIMEOUT);
841 841 tcp_write_err(sk);
842 842 goto out;
modified net/ipv4/udp.c
@@ -900,15 +900,6 @@ out:
900 900 return sk;
901 901 }
902 902
903 - static void udp_err_update_exception(struct net *net, struct sk_buff *skb,
904 - int type, int code, u32 info)
905 - {
906 - if (type == ICMP_DEST_UNREACH && code == ICMP_FRAG_NEEDED)
907 - ipv4_update_pmtu(skb, net, info, 0, IPPROTO_UDP);
908 - else if (type == ICMP_REDIRECT)
909 - ipv4_redirect(skb, net, 0, IPPROTO_UDP);
910 - }
911 -
912 903 /*
913 904 * This routine is called by the ICMP module when it gets some
914 905 * sort of error condition. If err < 0 then the socket should
@@ -932,8 +923,6 @@ int udp_err(struct sk_buff *skb, u32 info)
932 923 int harderr;
933 924 int err;
934 925
935 - udp_err_update_exception(net, skb, type, code, info);
936 -
937 926 uh = (struct udphdr *)(skb->data + (iph->ihl << 2));
938 927 sk = __udp4_lib_lookup(net, iph->daddr, uh->dest,
939 928 iph->saddr, uh->source, skb->dev->ifindex,
@@ -2177,10 +2166,10 @@ int __udp_disconnect(struct sock *sk, int flags)
2177 2166 */
2178 2167
2179 2168 sk->sk_state = TCP_CLOSE;
2180 - WRITE_ONCE(inet->inet_daddr, 0);
2169 + inet->inet_daddr = 0;
2181 2170 inet->inet_dport = 0;
2182 2171 sock_rps_reset_rxhash(sk);
2183 - WRITE_ONCE(sk->sk_bound_dev_if, 0);
2172 + sk->sk_bound_dev_if = 0;
2184 2173 if (!(sk->sk_userlocks & SOCK_BINDADDR_LOCK)) {
2185 2174 inet_reset_saddr(sk);
2186 2175 if (sk->sk_prot->rehash &&
modified net/ipv6/exthdrs.c
@@ -445,7 +445,7 @@ looped_back:
445 445 hdr->segments_left--;
446 446 addr = hdr->segments + hdr->segments_left;
447 447
448 - skb_push(skb, -skb_network_offset(skb));
448 + skb_push(skb, sizeof(struct ipv6hdr));
449 449
450 450 if (skb->ip_summed == CHECKSUM_COMPLETE)
451 451 seg6_update_csum(skb);
@@ -469,7 +469,7 @@ looped_back:
469 469 }
470 470 ipv6_hdr(skb)->hop_limit--;
471 471
472 - skb_pull(skb, skb_transport_offset(skb));
472 + skb_pull(skb, sizeof(struct ipv6hdr));
473 473 goto looped_back;
474 474 }
475 475
modified net/ipv6/ip6_gre.c
@@ -878,7 +878,6 @@ static int ip6gre_xmit_other(struct sk_buff *skb, struct net_device *dev)
878 878 static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
879 879 struct net_device *dev)
880 880 {
881 - struct ip_tunnel_info *tun_info = NULL;
882 881 struct ip6_tnl *t = netdev_priv(dev);
883 882 __be16 payload_protocol;
884 883 int ret;
@@ -889,9 +888,6 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
889 888 if (!ip6_tnl_xmit_ctl(t, &t->parms.laddr, &t->parms.raddr))
890 889 goto tx_err;
891 890
892 - if (t->parms.collect_md)
893 - tun_info = skb_tunnel_info_txcheck(skb);
894 -
895 891 payload_protocol = skb_protocol(skb, true);
896 892 switch (payload_protocol) {
897 893 case htons(ETH_P_IP):
@@ -911,7 +907,7 @@ static netdev_tx_t ip6gre_tunnel_xmit(struct sk_buff *skb,
911 907 return NETDEV_TX_OK;
912 908
913 909 tx_err:
914 - if (!IS_ERR(tun_info))
910 + if (!t->parms.collect_md || !IS_ERR(skb_tunnel_info_txcheck(skb)))
915 911 DEV_STATS_INC(dev, tx_errors);
916 912 DEV_STATS_INC(dev, tx_dropped);
917 913 kfree_skb(skb);
modified net/ipv6/mcast.c
@@ -240,8 +240,7 @@ static int __ipv6_sock_mc_join(struct sock *sk, int ifindex,
240 240 return err;
241 241 }
242 242
243 - rcu_assign_pointer(mc_lst->next,
244 - sock_dereference(np->ipv6_mc_list, sk));
243 + mc_lst->next = np->ipv6_mc_list;
245 244 rcu_assign_pointer(np->ipv6_mc_list, mc_lst);
246 245
247 246 return 0;
@@ -301,8 +300,7 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
301 300 lnk = &mc_lst->next) {
302 301 if ((ifindex == 0 || mc_lst->ifindex == ifindex) &&
303 302 ipv6_addr_equal(&mc_lst->addr, addr)) {
304 - rcu_assign_pointer(*lnk,
305 - sock_dereference(mc_lst->next, sk));
303 + *lnk = mc_lst->next;
306 304 __ipv6_sock_mc_drop(sk, mc_lst);
307 305 return 0;
308 306 }
@@ -335,8 +333,7 @@ void __ipv6_sock_mc_close(struct sock *sk)
335 333 struct ipv6_mc_socklist *mc_lst;
336 334
337 335 while ((mc_lst = sock_dereference(np->ipv6_mc_list, sk)) != NULL) {
338 - rcu_assign_pointer(np->ipv6_mc_list,
339 - sock_dereference(mc_lst->next, sk));
336 + np->ipv6_mc_list = mc_lst->next;
340 337 __ipv6_sock_mc_drop(sk, mc_lst);
341 338 }
342 339 }
@@ -358,12 +355,12 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
358 355 {
359 356 struct ipv6_pinfo *inet6 = inet6_sk(sk);
360 357 struct in6_addr *source, *group;
361 - struct ip6_sf_socklist *newpsl, *psl;
362 358 struct net *net = sock_net(sk);
363 359 struct ipv6_mc_socklist *pmc;
360 + struct ip6_sf_socklist *psl;
364 361 struct inet6_dev *idev;
365 362 int leavegroup = 0;
366 - int i, j;
363 + int i, j, rv;
367 364 int err;
368 365
369 366 source = &((struct sockaddr_in6 *)&pgsr->gsr_source)->sin6_addr;
@@ -412,11 +409,13 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
412 409 if (!add) {
413 410 if (!psl)
414 411 goto done; /* err = -EADDRNOTAVAIL */
412 + rv = !0;
415 413 for (i = 0; i < psl->sl_count; i++) {
416 - if (ipv6_addr_equal(&psl->sl_addr[i], source))
414 + rv = !ipv6_addr_equal(&psl->sl_addr[i], source);
415 + if (rv == 0)
417 416 break;
418 417 }
419 - if (i == psl->sl_count) /* source not found */
418 + if (rv) /* source not found */
420 419 goto done; /* err = -EADDRNOTAVAIL */
421 420
422 421 /* special case - (INCLUDE, empty) == LEAVE_GROUP */
@@ -425,74 +424,58 @@ int ip6_mc_source(int add, int omode, struct sock *sk,
425 424 goto done;
426 425 }
427 426
428 - atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
429 - &sk->sk_omem_alloc);
430 -
431 - if (psl->sl_count == 1) {
432 - newpsl = NULL;
433 - } else {
434 - newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr,
435 - psl->sl_count - 1),
436 - GFP_KERNEL);
437 - if (!newpsl) {
438 - atomic_add(struct_size(psl, sl_addr, psl->sl_max),
439 - &sk->sk_omem_alloc);
440 - err = -ENOBUFS;
441 - goto done;
442 - }
443 - newpsl->sl_max = psl->sl_count - 1;
444 - newpsl->sl_count = psl->sl_count - 1;
445 - for (j = 0; j < i; j++)
446 - newpsl->sl_addr[j] = psl->sl_addr[j];
447 - for (j = i + 1; j < psl->sl_count; j++)
448 - newpsl->sl_addr[j - 1] = psl->sl_addr[j];
449 - }
450 -
451 427 /* update the interface filter */
452 428 ip6_mc_del_src(idev, group, omode, 1, source, 1);
453 429
454 - rcu_assign_pointer(pmc->sflist, newpsl);
455 - kfree_rcu(psl, rcu);
430 + for (j = i+1; j < psl->sl_count; j++)
431 + psl->sl_addr[j-1] = psl->sl_addr[j];
432 + psl->sl_count--;
456 433 err = 0;
457 434 goto done;
458 435 }
459 436 /* else, add a new source to the filter */
460 437
461 - if (psl && psl->sl_count >= READ_ONCE(sysctl_mld_max_msf)) {
438 + if (psl && psl->sl_count >= sysctl_mld_max_msf) {
462 439 err = -ENOBUFS;
463 440 goto done;
464 441 }
465 - if (psl) {
466 - for (i = 0; i < psl->sl_count; i++) {
467 - if (ipv6_addr_equal(&psl->sl_addr[i], source))
468 - goto done; /* err = -EADDRNOTAVAIL */
469 - }
470 - }
442 + if (!psl || psl->sl_count == psl->sl_max) {
443 + struct ip6_sf_socklist *newpsl;
444 + int count = IP6_SFBLOCK;
471 445
472 - i = psl ? psl->sl_count + 1 : 1;
473 - newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr, i),
474 - GFP_KERNEL);
475 - if (!newpsl) {
476 - err = -ENOBUFS;
477 - goto done;
446 + if (psl)
447 + count += psl->sl_max;
448 + newpsl = sock_kmalloc(sk, struct_size(newpsl, sl_addr, count),
449 + GFP_KERNEL);
450 + if (!newpsl) {
451 + err = -ENOBUFS;
452 + goto done;
453 + }
454 + newpsl->sl_max = count;
455 + newpsl->sl_count = count - IP6_SFBLOCK;
456 + if (psl) {
457 + for (i = 0; i < psl->sl_count; i++)
458 + newpsl->sl_addr[i] = psl->sl_addr[i];
459 + atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
460 + &sk->sk_omem_alloc);
461 + }
462 + rcu_assign_pointer(pmc->sflist, newpsl);
463 + kfree_rcu(psl, rcu);
464 + psl = newpsl;
478 465 }
479 - newpsl->sl_max = i;
480 - newpsl->sl_count = i;
481 - if (psl) {
482 - for (j = 0; j < psl->sl_count; j++)
483 - newpsl->sl_addr[j] = psl->sl_addr[j];
466 + rv = 1; /* > 0 for insert logic below if sl_count is 0 */
467 + for (i = 0; i < psl->sl_count; i++) {
468 + rv = !ipv6_addr_equal(&psl->sl_addr[i], source);
469 + if (rv == 0) /* There is an error in the address. */
470 + goto done;
484 471 }
485 - newpsl->sl_addr[i - 1] = *source;
486 -
472 + for (j = psl->sl_count-1; j >= i; j--)
473 + psl->sl_addr[j+1] = psl->sl_addr[j];
474 + psl->sl_addr[i] = *source;
475 + psl->sl_count++;
476 + err = 0;
487 477 /* update the interface list */
488 478 ip6_mc_add_src(idev, group, omode, 1, source, 1);
489 -
490 - if (psl)
491 - atomic_sub(struct_size(psl, sl_addr, psl->sl_max),
492 - &sk->sk_omem_alloc);
493 - rcu_assign_pointer(pmc->sflist, newpsl);
494 - kfree_rcu(psl, rcu);
495 - err = 0;
496 479 done:
497 480 mutex_unlock(&idev->mc_lock);
498 481 in6_dev_put(idev);
@@ -801,11 +784,9 @@ static void mld_del_delrec(struct inet6_dev *idev, struct ifmcaddr6 *im)
801 784 if (!pmc)
802 785 return;
803 786 if (pmc_prev)
804 - rcu_assign_pointer(pmc_prev->next,
805 - mc_dereference(pmc->next, idev));
787 + rcu_assign_pointer(pmc_prev->next, pmc->next);
806 788 else
807 - rcu_assign_pointer(idev->mc_tomb,
808 - mc_dereference(pmc->next, idev));
789 + rcu_assign_pointer(idev->mc_tomb, pmc->next);
809 790
810 791 im->idev = pmc->idev;
811 792 if (im->mca_sfmode == MCAST_INCLUDE) {
@@ -985,7 +966,7 @@ static int __ipv6_dev_mc_inc(struct net_device *dev,
985 966 return -ENOMEM;
986 967 }
987 968
988 - rcu_assign_pointer(mc->next, mc_dereference(idev->mc_list, idev));
969 + rcu_assign_pointer(mc->next, idev->mc_list);
989 970 rcu_assign_pointer(idev->mc_list, mc);
990 971
991 972 mld_del_delrec(idev, mc);
@@ -1019,8 +1000,7 @@ int __ipv6_dev_mc_dec(struct inet6_dev *idev, const struct in6_addr *addr)
1019 1000
1020 1001 WRITE_ONCE(ma->mca_users, new_users);
1021 1002 if (new_users == 0) {
1022 - rcu_assign_pointer(*map,
1023 - mc_dereference(ma->next, idev));
1003 + *map = ma->next;
1024 1004
1025 1005 igmp6_group_dropped(ma);
1026 1006 inet6_ifmcaddr_notify(idev->dev, ma,
@@ -2371,18 +2351,14 @@ static int ip6_mc_del1_src(struct ifmcaddr6 *pmc, int sfmode,
2371 2351
2372 2352 if (psf->sf_oldin && !(pmc->mca_flags & MAF_NOREPORT) &&
2373 2353 !mld_in_v1_mode(idev)) {
2374 - struct ip6_sf_list *dpsf = kmalloc_obj(*dpsf);
2375 -
2376 - if (dpsf) {
2377 - *dpsf = *psf;
2378 - dpsf->sf_crcount = idev->mc_qrv;
2379 - rcu_assign_pointer(dpsf->sf_next,
2380 - mc_dereference(pmc->mca_tomb, idev));
2381 - rcu_assign_pointer(pmc->mca_tomb, dpsf);
2382 - rv = 1;
2383 - }
2354 + psf->sf_crcount = idev->mc_qrv;
2355 + rcu_assign_pointer(psf->sf_next,
2356 + mc_dereference(pmc->mca_tomb, idev));
2357 + rcu_assign_pointer(pmc->mca_tomb, psf);
2358 + rv = 1;
2359 + } else {
2360 + kfree_rcu(psf, rcu);
2384 2361 }
2385 - kfree_rcu(psf, rcu);
2386 2362 }
2387 2363 return rv;
2388 2364 }
@@ -2645,7 +2621,7 @@ static void ip6_mc_clear_src(struct ifmcaddr6 *pmc)
2645 2621
2646 2622 static void igmp6_join_group(struct ifmcaddr6 *ma)
2647 2623 {
2648 - unsigned long delay, interval;
2624 + unsigned long delay;
2649 2625
2650 2626 mc_assert_locked(ma->idev);
2651 2627
@@ -2654,17 +2630,13 @@ static void igmp6_join_group(struct ifmcaddr6 *ma)
2654 2630
2655 2631 igmp6_send(&ma->mca_addr, ma->idev->dev, ICMPV6_MGM_REPORT);
2656 2632
2657 - interval = unsolicited_report_interval(ma->idev);
2658 - delay = interval;
2633 + delay = get_random_u32_below(unsolicited_report_interval(ma->idev));
2659 2634
2660 2635 if (cancel_delayed_work(&ma->mca_work)) {
2661 2636 refcount_dec(&ma->mca_refcnt);
2662 2637 delay = ma->mca_work.timer.expires - jiffies;
2663 2638 }
2664 2639
2665 - if (delay >= interval)
2666 - delay = get_random_u32_below(interval);
2667 -
2668 2640 if (!mod_delayed_work(mld_wq, &ma->mca_work, delay))
2669 2641 refcount_inc(&ma->mca_refcnt);
2670 2642 WRITE_ONCE(ma->mca_flags, ma->mca_flags |
@@ -3029,7 +3001,7 @@ static int igmp6_mc_seq_show(struct seq_file *seq, void *v)
3029 3001 struct ifmcaddr6 *im = (struct ifmcaddr6 *)v;
3030 3002 struct igmp6_mc_iter_state *state = igmp6_mc_seq_private(seq);
3031 3003 unsigned int mca_flags = READ_ONCE(im->mca_flags);
3032 - long delta = READ_ONCE(im->mca_work.timer.expires) - jiffies;
3004 + unsigned long expires = READ_ONCE(im->mca_work.timer.expires);
3033 3005
3034 3006 seq_printf(seq,
3035 3007 "%-4d %-15s %pi6 %5d %08X %ld\n",
@@ -3037,7 +3009,7 @@ static int igmp6_mc_seq_show(struct seq_file *seq, void *v)
3037 3009 &im->mca_addr,
3038 3010 READ_ONCE(im->mca_users), mca_flags,
3039 3011 (mca_flags & MAF_TIMER_RUNNING) ?
3040 - jiffies_delta_to_clock_t(delta) : 0);
3012 + jiffies_to_clock_t(expires - jiffies) : 0);
3041 3013 return 0;
3042 3014 }
3043 3015
modified net/ipv6/route.c
@@ -3255,7 +3255,7 @@ void ip6_redirect_no_header(struct sk_buff *skb, struct net *net, int oif)
3255 3255
3256 3256 void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk)
3257 3257 {
3258 - ip6_redirect(skb, sock_net(sk), skb->dev->ifindex,
3258 + ip6_redirect(skb, sock_net(sk), sk->sk_bound_dev_if,
3259 3259 READ_ONCE(sk->sk_mark), sk_uid(sk));
3260 3260 }
3261 3261
modified net/ipv6/tcpv6_offload.c
@@ -26,18 +26,7 @@ static void tcp6_check_fraglist_gro(struct list_head *head, struct sk_buff *skb,
26 26
27 27 p = tcp_gro_lookup(head, th);
28 28 if (p) {
29 - /* flist GRO applies to consecutive non-GSO skbs */
30 - if (!skb_is_gso(skb) || !NAPI_GRO_CB(p)->is_flist) {
31 - NAPI_GRO_CB(skb)->is_flist = NAPI_GRO_CB(p)->is_flist;
32 - return;
33 - }
34 -
35 - /* Fall back to the regular GRO path */
36 - if (NAPI_GRO_CB(p)->count == 1)
37 - NAPI_GRO_CB(p)->is_flist = 0;
38 -
39 - NAPI_GRO_CB(skb)->is_flist = 0;
40 -
29 + NAPI_GRO_CB(skb)->is_flist = NAPI_GRO_CB(p)->is_flist;
41 30 return;
42 31 }
43 32
@@ -47,7 +36,7 @@ static void tcp6_check_fraglist_gro(struct list_head *head, struct sk_buff *skb,
47 36 sk = __inet6_lookup_established(net, &hdr->saddr, th->source,
48 37 &hdr->daddr, ntohs(th->dest),
49 38 iif, sdif);
50 - NAPI_GRO_CB(skb)->is_flist = !sk && !skb_is_gso(skb);
39 + NAPI_GRO_CB(skb)->is_flist = !sk;
51 40 if (sk)
52 41 sock_gen_put(sk);
53 42 #endif /* IS_ENABLED(CONFIG_IPV6) */
modified net/ipv6/udp.c
@@ -690,17 +690,6 @@ out:
690 690 return sk;
691 691 }
692 692
693 - static void udpv6_err_update_exception(struct net *net, struct sk_buff *skb,
694 - u8 type, __be32 info)
695 - {
696 - if (type == ICMPV6_PKT_TOOBIG)
697 - ip6_update_pmtu(skb, net, info, skb->dev->ifindex, 0,
698 - sock_net_uid(net, NULL));
699 - else if (type == NDISC_REDIRECT)
700 - ip6_redirect(skb, net, skb->dev->ifindex, 0,
701 - sock_net_uid(net, NULL));
702 - }
703 -
704 693 static int udpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
705 694 u8 type, u8 code, int offset, __be32 info)
706 695 {
@@ -714,8 +703,6 @@ static int udpv6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
714 703 int harderr;
715 704 int err;
716 705
717 - udpv6_err_update_exception(net, skb, type, info);
718 -
719 706 daddr = seg6_get_daddr(skb, opt) ? : &hdr->daddr;
720 707 saddr = &hdr->saddr;
721 708 sk = __udp6_lib_lookup(net, daddr, uh->dest, saddr, uh->source,
modified net/iucv/af_iucv.c
@@ -210,6 +210,12 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock,
210 210 phs_hdr->flags = flags;
211 211 if (flags == AF_IUCV_FLAG_SYN)
212 212 phs_hdr->window = iucv->msglimit;
213 + else if ((flags == AF_IUCV_FLAG_WIN) || !flags) {
214 + confirm_recv = atomic_read(&iucv->msg_recv);
215 + phs_hdr->window = confirm_recv;
216 + if (confirm_recv)
217 + phs_hdr->flags = phs_hdr->flags | AF_IUCV_FLAG_WIN;
218 + }
213 219 memcpy(phs_hdr->destUserID, iucv->dst_user_id, 8);
214 220 memcpy(phs_hdr->destAppName, iucv->dst_name, 8);
215 221 memcpy(phs_hdr->srcUserID, iucv->src_user_id, 8);
@@ -244,22 +250,13 @@ static int afiucv_hs_send(struct iucv_message *imsg, struct sock *sock,
244 250 }
245 251 skb->protocol = cpu_to_be16(ETH_P_AF_IUCV);
246 252
247 - /* Claim the receive credit here, not while building the header: every
248 - * way this frame can be dropped has now been ruled out, so the window
249 - * is zeroed only for as long as the transmit itself takes.
250 - */
251 - if (flags == AF_IUCV_FLAG_WIN || !flags) {
252 - confirm_recv = atomic_xchg(&iucv->msg_recv, 0);
253 - phs_hdr->window = confirm_recv;
254 - if (confirm_recv)
255 - phs_hdr->flags = phs_hdr->flags | AF_IUCV_FLAG_WIN;
256 - }
257 -
258 253 atomic_inc(&iucv->skbs_in_xmit);
259 254 err = dev_queue_xmit(skb);
260 255 if (net_xmit_eval(err)) {
261 256 atomic_dec(&iucv->skbs_in_xmit);
262 - atomic_add(confirm_recv, &iucv->msg_recv);
257 + } else {
258 + atomic_sub(confirm_recv, &iucv->msg_recv);
259 + WARN_ON(atomic_read(&iucv->msg_recv) < 0);
263 260 }
264 261 return net_xmit_eval(err);
265 262
@@ -1244,7 +1241,6 @@ static int iucv_sock_recvmsg(struct socket *sock, struct msghdr *msg,
1244 1241 struct iucv_sock *iucv = iucv_sk(sk);
1245 1242 unsigned int copied, rlen;
1246 1243 struct sk_buff *skb, *rskb, *cskb;
1247 - bool send_win = false;
1248 1244 int err = 0;
1249 1245 u32 offset;
1250 1246
@@ -1335,20 +1331,16 @@ static int iucv_sock_recvmsg(struct socket *sock, struct msghdr *msg,
1335 1331 if (skb_queue_empty(&iucv->backlog_skb_q)) {
1336 1332 if (!list_empty(&iucv->message_q.list))
1337 1333 iucv_process_message_q(sk);
1338 - if (iucv->transport == AF_IUCV_TRANS_HIPER &&
1339 - atomic_read(&iucv->msg_recv) >=
1340 - iucv->msglimit / 2)
1341 - send_win = true;
1342 - }
1343 - spin_unlock_bh(&iucv->message_q.lock);
1344 -
1345 - if (send_win) {
1346 - err = iucv_send_ctrl(sk, AF_IUCV_FLAG_WIN);
1347 - if (err) {
1348 - sk->sk_state = IUCV_DISCONN;
1349 - sk->sk_state_change(sk);
1334 + if (atomic_read(&iucv->msg_recv) >=
1335 + iucv->msglimit / 2) {
1336 + err = iucv_send_ctrl(sk, AF_IUCV_FLAG_WIN);
1337 + if (err) {
1338 + sk->sk_state = IUCV_DISCONN;
1339 + sk->sk_state_change(sk);
1340 + }
1350 1341 }
1351 1342 }
1343 + spin_unlock_bh(&iucv->message_q.lock);
1352 1344 }
1353 1345
1354 1346 done:
modified net/mac80211/nan.c
@@ -659,7 +659,8 @@ int ieee80211_nan_set_peer_sched(struct ieee80211_sub_if_data *sdata,
659 659 if (!sta)
660 660 return -ENOENT;
661 661
662 - new_sched = kzalloc_flex(*new_sched, channels, sched->n_channels);
662 + new_sched = kzalloc(struct_size(new_sched, channels, sched->n_channels),
663 + GFP_KERNEL);
663 664 if (!new_sched)
664 665 return -ENOMEM;
665 666
modified net/mac802154/ieee802154_i.h
@@ -76,12 +76,7 @@ struct ieee802154_local {
76 76 struct work_struct rx_mac_cmd_work;
77 77
78 78 /* Association */
79 - /* assoc_lock protects assoc_dev_extended_addr, assoc_addr,
80 - * assoc_status, the assoc_done reinit/complete pairing and the
81 - * IEEE802154_IS_ASSOCIATING bit in @ongoing.
82 - */
83 - spinlock_t assoc_lock;
84 - __le64 assoc_dev_extended_addr;
79 + struct ieee802154_pan_device *assoc_dev;
85 80 struct completion assoc_done;
86 81 __le16 assoc_addr;
87 82 u8 assoc_status;
modified net/mac802154/main.c
@@ -104,7 +104,6 @@ ieee802154_alloc_hw(size_t priv_data_len, const struct ieee802154_ops *ops)
104 104 INIT_WORK(&local->rx_mac_cmd_work, mac802154_rx_mac_cmd_worker);
105 105
106 106 init_completion(&local->assoc_done);
107 - spin_lock_init(&local->assoc_lock);
108 107
109 108 /* init supported flags with 802.15.4 default ranges */
110 109 phy->supported.max_minbe = 8;
modified net/mac802154/scan.c
@@ -536,9 +536,7 @@ int mac802154_perform_association(struct ieee802154_sub_if_data *sdata,
536 536 struct ieee802154_association_req_frame frame = {};
537 537 struct ieee802154_local *local = sdata->local;
538 538 struct wpan_dev *wpan_dev = &sdata->wpan_dev;
539 - __le16 resp_short_addr;
540 539 struct sk_buff *skb;
541 - u8 resp_status;
542 540 int ret;
543 541
544 542 frame.mhr.fc.type = IEEE802154_FC_TYPE_MAC_CMD;
@@ -580,11 +578,9 @@ int mac802154_perform_association(struct ieee802154_sub_if_data *sdata,
580 578 return ret;
581 579 }
582 580
583 - spin_lock(&local->assoc_lock);
581 + local->assoc_dev = coord;
584 582 reinit_completion(&local->assoc_done);
585 - local->assoc_dev_extended_addr = coord->extended_addr;
586 583 set_bit(IEEE802154_IS_ASSOCIATING, &local->ongoing);
587 - spin_unlock(&local->assoc_lock);
588 584
589 585 ret = ieee802154_mlme_tx_one_locked(local, sdata, skb);
590 586 if (ret) {
@@ -603,37 +599,25 @@ int mac802154_perform_association(struct ieee802154_sub_if_data *sdata,
603 599 goto clear_assoc;
604 600 }
605 601
606 - /* The association is complete: mac802154_process_association_resp()
607 - * cleared the associating bit before waking us, so a second (e.g.
608 - * malicious) ASSOC RESP can no longer pass the recheck and overwrite
609 - * the result. Snapshot assoc_status/assoc_addr under the lock.
610 - */
611 - spin_lock(&local->assoc_lock);
612 - resp_status = local->assoc_status;
613 - resp_short_addr = local->assoc_addr;
614 - spin_unlock(&local->assoc_lock);
615 -
616 - if (resp_status != IEEE802154_ASSOCIATION_SUCCESSFUL) {
617 - if (resp_status == IEEE802154_PAN_AT_CAPACITY)
602 + if (local->assoc_status != IEEE802154_ASSOCIATION_SUCCESSFUL) {
603 + if (local->assoc_status == IEEE802154_PAN_AT_CAPACITY)
618 604 ret = -ERANGE;
619 605 else
620 606 ret = -EPERM;
621 607
622 608 dev_warn(&sdata->dev->dev,
623 609 "Negative ASSOC RESP received from %8phC: %s\n", &ceaddr,
624 - resp_status == IEEE802154_PAN_AT_CAPACITY ?
610 + local->assoc_status == IEEE802154_PAN_AT_CAPACITY ?
625 611 "PAN at capacity" : "access denied");
626 - return ret;
612 + goto clear_assoc;
627 613 }
628 614
629 - *short_addr = resp_short_addr;
630 -
631 - return 0;
615 + ret = 0;
616 + *short_addr = local->assoc_addr;
632 617
633 618 clear_assoc:
634 - spin_lock(&local->assoc_lock);
635 619 clear_bit(IEEE802154_IS_ASSOCIATING, &local->ongoing);
636 - spin_unlock(&local->assoc_lock);
620 + local->assoc_dev = NULL;
637 621
638 622 return ret;
639 623 }
@@ -655,28 +639,19 @@ int mac802154_process_association_resp(struct ieee802154_sub_if_data *sdata,
655 639 dest->mode != IEEE802154_EXTENDED_ADDRESSING))
656 640 return -EINVAL;
657 641
658 - spin_lock(&local->assoc_lock);
659 - if (unlikely(!test_bit(IEEE802154_IS_ASSOCIATING, &local->ongoing) ||
660 - dest->extended_addr != wpan_dev->extended_addr ||
661 - src->extended_addr != local->assoc_dev_extended_addr)) {
662 - spin_unlock(&local->assoc_lock);
642 + if (unlikely(dest->extended_addr != wpan_dev->extended_addr ||
643 + src->extended_addr != local->assoc_dev->extended_addr))
663 644 return -ENODEV;
664 - }
665 645
666 646 memcpy(&resp_pl, skb->data, sizeof(resp_pl));
667 647 local->assoc_addr = resp_pl.short_addr;
668 648 local->assoc_status = resp_pl.status;
669 - /* Clear the associating bit before waking the waiter: once the result
670 - * is saved, any subsequent (e.g. malicious) ASSOC RESP must fail the
671 - * test_bit() recheck above and can no longer overwrite the result.
672 - */
673 - clear_bit(IEEE802154_IS_ASSOCIATING, &local->ongoing);
674 - complete(&local->assoc_done);
675 - spin_unlock(&local->assoc_lock);
676 649
677 650 dev_dbg(&skb->dev->dev,
678 651 "ASSOC RESP 0x%x received from %8phC, getting short address %04x\n",
679 - resp_pl.status, &deaddr, resp_pl.short_addr);
652 + local->assoc_status, &deaddr, local->assoc_addr);
653 +
654 + complete(&local->assoc_done);
680 655
681 656 return 0;
682 657 }
modified net/mctp/test/route-test.c
@@ -193,7 +193,7 @@ static void __mctp_route_test_init(struct kunit *test,
193 193 if (netid != MCTP_NET_ANY)
194 194 WRITE_ONCE(dev->mdev->net, netid);
195 195
196 - dev->mdev->addrs = kmalloc_objs(u8, 1);
196 + dev->mdev->addrs = kmalloc_objs(u8, 1, GFP_KERNEL);
197 197 dev->mdev->num_addrs = 1;
198 198 dev->mdev->addrs[0] = 8;
199 199
modified net/mctp/test/utils.c
@@ -88,7 +88,7 @@ struct mctp_test_dev *mctp_test_create_dev_with_addr(mctp_eid_t addr)
88 88 if (!dev)
89 89 return NULL;
90 90
91 - dev->mdev->addrs = kmalloc_objs(u8, 1);
91 + dev->mdev->addrs = kmalloc_objs(u8, 1, GFP_KERNEL);
92 92 if (!dev->mdev->addrs) {
93 93 mctp_test_destroy_dev(dev);
94 94 return NULL;
modified net/mptcp/protocol.c
@@ -3109,7 +3109,8 @@ static void mptcp_do_fastclose(struct sock *sk)
3109 3109 */
3110 3110 inet_csk(ssk)->icsk_ack.rcv_mss = TCP_MIN_MSS;
3111 3111
3112 - tcp_send_active_reset(ssk, SK_RST_REASON_TCP_ABORT_ON_CLOSE);
3112 + tcp_send_active_reset(ssk, ssk->sk_allocation,
3113 + SK_RST_REASON_TCP_ABORT_ON_CLOSE);
3113 3114 unlock:
3114 3115 release_sock(ssk);
3115 3116 }
modified net/mptcp/protocol.h
@@ -690,7 +690,7 @@ mptcp_send_active_reset_reason(struct sock *sk)
690 690 enum sk_rst_reason reason;
691 691
692 692 reason = sk_rst_convert_mptcp_reason(subflow->reset_reason);
693 - tcp_send_active_reset(sk, reason);
693 + tcp_send_active_reset(sk, GFP_ATOMIC, reason);
694 694 }
695 695
696 696 /* Made the fwd mem carried by the given skb available to the msk,
modified net/netfilter/nf_tables_api.c
@@ -3215,7 +3215,7 @@ static int nft_trans_delhook(struct nft_hook *hook,
3215 3215 {
3216 3216 struct nft_trans_hook *trans_hook;
3217 3217
3218 - trans_hook = kmalloc_obj(*trans_hook);
3218 + trans_hook = kmalloc_obj(*trans_hook, GFP_KERNEL);
3219 3219 if (!trans_hook)
3220 3220 return -ENOMEM;
3221 3221
modified net/packet/af_packet.c
@@ -2675,8 +2675,7 @@ static int tpacket_parse_header(struct packet_sock *po, void *frame,
2675 2675 int size_max, void **data)
2676 2676 {
2677 2677 union tpacket_uhdr ph;
2678 - u32 tp_len;
2679 - int off;
2678 + int tp_len, off;
2680 2679
2681 2680 ph.raw = frame;
2682 2681
@@ -2696,7 +2695,7 @@ static int tpacket_parse_header(struct packet_sock *po, void *frame,
2696 2695 break;
2697 2696 }
2698 2697 if (unlikely(tp_len > size_max)) {
2699 - pr_err("packet size is too long (%u > %d)\n", tp_len, size_max);
2698 + pr_err("packet size is too long (%d > %d)\n", tp_len, size_max);
2700 2699 return -EMSGSIZE;
2701 2700 }
2702 2701
modified net/qrtr/af_qrtr.c
@@ -9,7 +9,6 @@
9 9 #include <linux/termios.h> /* For TIOCINQ/OUTQ */
10 10 #include <linux/spinlock.h>
11 11 #include <linux/wait.h>
12 - #include <linux/workqueue.h>
13 12
14 13 #include <net/sock.h>
15 14
@@ -121,10 +120,8 @@ static DEFINE_XARRAY_ALLOC(qrtr_ports);
121 120 * @nid: node id
122 121 * @qrtr_tx_flow: xarray of qrtr_tx_flow, keyed by node << 32 | port
123 122 * @qrtr_tx_lock: lock for qrtr_tx_flow inserts
124 - * @hello_sent: hello packet send successful
125 123 * @rx_queue: receive queue
126 124 * @item: list item for broadcast list
127 - * @say_hello: delayed work for sending hello packet
128 125 */
129 126 struct qrtr_node {
130 127 struct mutex ep_lock;
@@ -135,11 +132,8 @@ struct qrtr_node {
135 132 struct xarray qrtr_tx_flow;
136 133 struct mutex qrtr_tx_lock; /* for qrtr_tx_flow */
137 134
138 - bool hello_sent;
139 -
140 135 struct sk_buff_head rx_queue;
141 136 struct list_head item;
142 - struct delayed_work say_hello;
143 137 };
144 138
145 139 /**
@@ -193,8 +187,6 @@ static void __qrtr_node_release(struct kref *kref)
193 187 list_del(&node->item);
194 188 mutex_unlock(&qrtr_node_lock);
195 189
196 - cancel_delayed_work_sync(&node->say_hello);
197 -
198 190 skb_queue_purge(&node->rx_queue);
199 191
200 192 /* Free tx flow counters */
@@ -349,14 +341,6 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb,
349 341 size_t len = skb->len;
350 342 int rc, confirm_rx;
351 343
352 - mutex_lock(&node->ep_lock);
353 - if (!node->hello_sent && type != QRTR_TYPE_HELLO) {
354 - mutex_unlock(&node->ep_lock);
355 - kfree_skb(skb);
356 - return -EAGAIN;
357 - }
358 - mutex_unlock(&node->ep_lock);
359 -
360 344 confirm_rx = qrtr_tx_wait(node, to->sq_node, to->sq_port, type);
361 345 if (confirm_rx < 0) {
362 346 kfree_skb(skb);
@@ -369,7 +353,7 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb,
369 353 hdr->src_node_id = cpu_to_le32(from->sq_node);
370 354 hdr->src_port_id = cpu_to_le32(from->sq_port);
371 355 if (to->sq_port == QRTR_PORT_CTRL) {
372 - hdr->dst_node_id = cpu_to_le32(READ_ONCE(node->nid));
356 + hdr->dst_node_id = cpu_to_le32(node->nid);
373 357 hdr->dst_port_id = cpu_to_le32(QRTR_PORT_CTRL);
374 358 } else {
375 359 hdr->dst_node_id = cpu_to_le32(to->sq_node);
@@ -388,8 +372,6 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb,
388 372 rc = node->ep->xmit(node->ep, skb);
389 373 else
390 374 kfree_skb(skb);
391 - if (!rc && type == QRTR_TYPE_HELLO)
392 - node->hello_sent = true;
393 375 mutex_unlock(&node->ep_lock);
394 376 }
395 377 /* Need to ensure that a subsequent message carries the otherwise lost
@@ -397,9 +379,6 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb,
397 379 if (rc && confirm_rx)
398 380 qrtr_tx_flow_failed(node, to->sq_node, to->sq_port);
399 381
400 - if (rc == -EAGAIN && type == QRTR_TYPE_HELLO)
401 - schedule_delayed_work(&node->say_hello, msecs_to_jiffies(100));
402 -
403 382 return rc;
404 383 }
405 384
@@ -437,7 +416,7 @@ static void qrtr_node_assign(struct qrtr_node *node, unsigned int nid)
437 416 spin_lock_irqsave(&qrtr_nodes_lock, flags);
438 417 radix_tree_insert(&qrtr_nodes, nid, node);
439 418 if (node->nid == QRTR_EP_NID_AUTO)
440 - WRITE_ONCE(node->nid, nid);
419 + node->nid = nid;
441 420 spin_unlock_irqrestore(&qrtr_nodes_lock, flags);
442 421 }
443 422
@@ -591,38 +570,6 @@ static struct sk_buff *qrtr_alloc_ctrl_packet(struct qrtr_ctrl_pkt **pkt,
591 570 return skb;
592 571 }
593 572
594 - static void qrtr_hello_work(struct work_struct *work)
595 - {
596 - struct sockaddr_qrtr from = {AF_QIPCRTR, 0, QRTR_PORT_CTRL};
597 - struct sockaddr_qrtr to = {AF_QIPCRTR, 0, QRTR_PORT_CTRL};
598 - struct qrtr_ctrl_pkt *pkt;
599 - struct qrtr_node *node;
600 - struct qrtr_sock *ctrl;
601 - struct sk_buff *skb;
602 -
603 - node = container_of(to_delayed_work(work), struct qrtr_node, say_hello);
604 -
605 - /* NS must be bound before we can send; retry with backoff if not ready */
606 - ctrl = qrtr_port_lookup(QRTR_PORT_CTRL);
607 - if (!ctrl) {
608 - schedule_delayed_work(&node->say_hello, msecs_to_jiffies(100));
609 - return;
610 - }
611 -
612 - skb = qrtr_alloc_ctrl_packet(&pkt, GFP_KERNEL);
613 - if (!skb) {
614 - qrtr_port_put(ctrl);
615 - schedule_delayed_work(&node->say_hello, msecs_to_jiffies(100));
616 - return;
617 - }
618 -
619 - pkt->cmd = cpu_to_le32(QRTR_TYPE_HELLO);
620 - from.sq_node = qrtr_local_nid;
621 - to.sq_node = node->nid;
622 - qrtr_node_enqueue(node, skb, QRTR_TYPE_HELLO, &from, &to);
623 - qrtr_port_put(ctrl);
624 - }
625 -
626 573 /**
627 574 * qrtr_endpoint_register() - register a new endpoint
628 575 * @ep: endpoint to register
@@ -648,9 +595,6 @@ int qrtr_endpoint_register(struct qrtr_endpoint *ep, unsigned int nid)
648 595 node->nid = QRTR_EP_NID_AUTO;
649 596 node->ep = ep;
650 597
651 - node->hello_sent = false;
652 - INIT_DELAYED_WORK(&node->say_hello, qrtr_hello_work);
653 -
654 598 xa_init(&node->qrtr_tx_flow);
655 599 mutex_init(&node->qrtr_tx_lock);
656 600
@@ -661,9 +605,6 @@ int qrtr_endpoint_register(struct qrtr_endpoint *ep, unsigned int nid)
661 605 mutex_unlock(&qrtr_node_lock);
662 606 ep->node = node;
663 607
664 - /* Initiate HELLO handshake from the core layer */
665 - schedule_delayed_work(&node->say_hello, 0);
666 -
667 608 return 0;
668 609 }
669 610 EXPORT_SYMBOL_GPL(qrtr_endpoint_register);
@@ -938,9 +879,6 @@ static int qrtr_bcast_enqueue(struct qrtr_node *node, struct sk_buff *skb,
938 879
939 880 mutex_lock(&qrtr_node_lock);
940 881 list_for_each_entry(node, &qrtr_all_nodes, item) {
941 - /* Skip nodes with no assigned node ID yet. */
942 - if (READ_ONCE(node->nid) == QRTR_EP_NID_AUTO)
943 - continue;
944 882 skbn = pskb_copy(skb, GFP_KERNEL);
945 883 if (!skbn)
946 884 break;
modified net/qrtr/ns.c
@@ -212,7 +212,6 @@ static void lookup_notify(struct sockaddr_qrtr *to, struct qrtr_server *srv,
212 212 pr_err("failed to send lookup notification\n");
213 213 }
214 214
215 - /* Announce the list of servers registered on the local node */
216 215 static int announce_servers(struct sockaddr_qrtr *sq)
217 216 {
218 217 struct qrtr_server *srv;
@@ -327,8 +326,38 @@ static int server_del(struct qrtr_node *node, unsigned int port, bool bcast)
327 326 return 0;
328 327 }
329 328
329 + static int say_hello(struct sockaddr_qrtr *dest)
330 + {
331 + struct qrtr_ctrl_pkt pkt;
332 + struct msghdr msg = { };
333 + struct kvec iv;
334 + int ret;
335 +
336 + iv.iov_base = &pkt;
337 + iv.iov_len = sizeof(pkt);
338 +
339 + memset(&pkt, 0, sizeof(pkt));
340 + pkt.cmd = cpu_to_le32(QRTR_TYPE_HELLO);
341 +
342 + msg.msg_name = (struct sockaddr *)dest;
343 + msg.msg_namelen = sizeof(*dest);
344 +
345 + ret = kernel_sendmsg(qrtr_ns.sock, &msg, &iv, 1, sizeof(pkt));
346 + if (ret < 0)
347 + pr_err("failed to send hello msg\n");
348 +
349 + return ret;
350 + }
351 +
352 + /* Announce the list of servers registered on the local node */
330 353 static int ctrl_cmd_hello(struct sockaddr_qrtr *sq)
331 354 {
355 + int ret;
356 +
357 + ret = say_hello(sq);
358 + if (ret < 0)
359 + return ret;
360 +
332 361 return announce_servers(sq);
333 362 }
334 363
@@ -745,6 +774,10 @@ int qrtr_ns_init(void)
745 774 qrtr_ns.bcast_sq.sq_node = QRTR_NODE_BCAST;
746 775 qrtr_ns.bcast_sq.sq_port = QRTR_PORT_CTRL;
747 776
777 + ret = say_hello(&qrtr_ns.bcast_sq);
778 + if (ret < 0)
779 + goto err_wq;
780 +
748 781 /* As the qrtr ns socket owner and creator is the same module, we have
749 782 * to decrease the qrtr module reference count to guarantee that it
750 783 * remains zero after the ns socket is created, otherwise, executing
modified net/rds/connection.c
@@ -106,12 +106,10 @@ static struct rds_connection *rds_conn_lookup(struct net *net,
106 106 }
107 107
108 108 /*
109 - * This is called by rds_conn_shutdown() once the transport has brought
110 - * a path down. It clears partial message state so that the transport
111 - * can start sending and receiving over this path again in the future.
112 - * The caller owns RDS_IN_XMIT and RDS_RECV_REFILL across this call,
113 - * which is what serializes it against the send and receive-refill
114 - * paths.
109 + * This is called by transports as they're bringing down a connection.
110 + * It clears partial message state so that the transport can start sending
111 + * and receiving over this connection again in the future. It is up to
112 + * the transport to have serialized this call with its send and recv.
115 113 */
116 114 static void rds_conn_path_reset(struct rds_conn_path *cp)
117 115 {
@@ -122,16 +120,7 @@ static void rds_conn_path_reset(struct rds_conn_path *cp)
122 120
123 121 rds_stats_inc(s_conn_reset);
124 122 rds_send_path_reset(cp);
125 -
126 - /* Clear the bits the reset is responsible for individually: a
127 - * blanket cp_flags = 0 is a plain store that can clobber a
128 - * concurrent atomic read-modify-write on the same word.
129 - * RDS_IN_XMIT and RDS_RECV_REFILL are held as locks by the
130 - * caller, rds_conn_shutdown(), which releases them once the
131 - * teardown is complete.
132 - */
133 - clear_bit(RDS_LL_SEND_FULL, &cp->cp_flags);
134 - clear_bit(RDS_RECONNECT_PENDING, &cp->cp_flags);
123 + cp->cp_flags = 0;
135 124
136 125 /* Do not clear next_rx_seq here, else we cannot distinguish
137 126 * retransmitted packets from new packets, and will hand all
@@ -417,70 +406,28 @@ void rds_conn_shutdown(struct rds_conn_path *cp)
417 406 }
418 407 mutex_unlock(&cp->cp_cm_lock);
419 408
420 - /* Quiesce the transmit and receive-refill paths by
421 - * acquiring their bit locks, not merely waiting for
422 - * them to be released: with a plain wait, either path
423 - * can re-take its lock the instant after we sample it
424 - * clear and then run concurrently with the transport
425 - * shutdown and the path reset below. Holding both
426 - * locks across the teardown makes that structurally
427 - * impossible.
428 - */
429 409 wait_event(cp->cp_waitq,
430 - !test_and_set_bit_lock(RDS_IN_XMIT, &cp->cp_flags));
410 + !test_bit(RDS_IN_XMIT, &cp->cp_flags));
431 411 wait_event(cp->cp_waitq,
432 - !test_and_set_bit(RDS_RECV_REFILL, &cp->cp_flags));
412 + !test_bit(RDS_RECV_REFILL, &cp->cp_flags));
433 413
434 414 conn->c_trans->conn_path_shutdown(cp);
435 415 rds_conn_path_reset(cp);
436 416
437 - /* Release the two locks and wake any waiter (e.g.
438 - * rds_tcp_reset_callbacks()) that blocked on them while
439 - * we held them. The unlock orders the transport's ring
440 - * re-initialization and the path reset above before
441 - * either bit is seen clear. rds_conn_path_reset() leaves
442 - * both bits alone: ownership ends here, not inside the
443 - * reset.
444 - */
445 - clear_bit_unlock(RDS_IN_XMIT, &cp->cp_flags);
446 - clear_bit_unlock(RDS_RECV_REFILL, &cp->cp_flags);
447 - wake_up_all(&cp->cp_waitq);
448 -
449 417 if (!rds_conn_path_transition(cp, RDS_CONN_DISCONNECTING,
418 + RDS_CONN_DOWN) &&
419 + !rds_conn_path_transition(cp, RDS_CONN_ERROR,
450 420 RDS_CONN_DOWN)) {
451 - /* The path was dropped again while we tore it
452 - * down: by a socket state-change callback in
453 - * irq context on receipt of a FIN, or by an
454 - * accept that claimed the path just before a
455 - * drop put it back to RDS_CONN_ERROR and then
456 - * installed a fresh socket on it. Unless a
457 - * pending destroy suppressed it, the drop also
458 - * queued another shutdown pass, and that pass
459 - * must run, because it is what tears down
460 - * whatever attached to the path after the
461 - * transport shutdown above sampled its state.
462 - * Consuming the RDS_CONN_ERROR here would turn
463 - * that pass into a no-op: leave the state
464 - * alone, and let the pass finish the job.
421 + /* This can happen - eg when we're in the middle of tearing
422 + * down the connection, and someone unloads the rds module.
423 + * Quite reproducible with loopback connections.
424 + * Mostly harmless.
465 425 *
466 - * Quiesce the reconnect timer before bailing
467 - * out, though. When a pending destroy did
468 - * suppress the queue, no later pass runs, and
469 - * rds_conn_path_destroy() is about to flush
470 - * cp_down_w and free the path: it must not
471 - * find cp_conn_w still armed. A successor
472 - * pass, when there is one, re-arms the
473 - * reconnect from its own tail.
474 - */
475 - cancel_delayed_work_sync(&cp->cp_conn_w);
476 - clear_bit(RDS_RECONNECT_PENDING, &cp->cp_flags);
477 -
478 - if (rds_conn_path_state(cp) == RDS_CONN_ERROR)
479 - return;
480 - /* No current cp_state writer leaves a
481 - * DISCONNECTING path in any state but
482 - * RDS_CONN_ERROR; report loudly if one ever
483 - * does.
426 + * Note that this also happens with rds-tcp because
427 + * we could have triggered rds_conn_path_drop in irq
428 + * mode from rds_tcp_state change on the receipt of
429 + * a FIN, thus we need to recheck for RDS_CONN_ERROR
430 + * here.
484 431 */
485 432 rds_conn_path_error(cp, "%s: failed to transition "
486 433 "to state DOWN, current state "
modified net/rds/ib_recv.c
@@ -363,14 +363,15 @@ static int acquire_refill(struct rds_connection *conn)
363 363
364 364 static void release_refill(struct rds_connection *conn)
365 365 {
366 - clear_bit_unlock(RDS_RECV_REFILL, &conn->c_flags);
366 + clear_bit(RDS_RECV_REFILL, &conn->c_flags);
367 + smp_mb__after_atomic();
367 368
368 369 /* We don't use wait_on_bit()/wake_up_bit() because our waking is in a
369 370 * hot path and finding waiters is very rare. We don't want to walk
370 371 * the system-wide hashed waitqueue buckets in the fast path only to
371 372 * almost never find waiters.
372 373 */
373 - if (wq_has_sleeper(&conn->c_waitq))
374 + if (waitqueue_active(&conn->c_waitq))
374 375 wake_up_all(&conn->c_waitq);
375 376 }
376 377
@@ -391,9 +392,7 @@ void rds_ib_recv_refill(struct rds_connection *conn, int prefill, gfp_t gfp)
391 392
392 393 /* the goal here is to just make sure that someone, somewhere
393 394 * is posting buffers. If we can't get the refill lock,
394 - * let them do their thing. The holder may also be
395 - * rds_conn_shutdown() tearing the path down, in which case
396 - * there is nothing to post.
395 + * let them do their thing
397 396 */
398 397 if (!acquire_refill(conn))
399 398 return;
modified net/rds/info.c
@@ -205,7 +205,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, sockopt_t *opt)
205 205 * iterator code to allocate and hand it back.
206 206 */
207 207 npages = iov_iter_npages(&opt->iter_out, INT_MAX);
208 - pages = kvmalloc_objs(*pages, npages);
208 + pages = kvmalloc_array(npages, sizeof(*pages), GFP_KERNEL);
209 209 if (!pages) {
210 210 ret = -ENOMEM;
211 211 goto out;
modified net/rds/send.c
@@ -114,13 +114,8 @@ static void release_in_xmit(struct rds_conn_path *cp)
114 114 * hot path and finding waiters is very rare. We don't want to walk
115 115 * the system-wide hashed waitqueue buckets in the fast path only to
116 116 * almost never find waiters.
117 - *
118 - * wq_has_sleeper() supplies the full barrier that orders the wait
119 - * queue read after the bit clear; clear_bit_unlock() alone is only
120 - * a release and would let this check read a stale empty queue,
121 - * losing the wake-up.
122 117 */
123 - if (wq_has_sleeper(&cp->cp_waitq))
118 + if (waitqueue_active(&cp->cp_waitq))
124 119 wake_up_all(&cp->cp_waitq);
125 120 }
126 121
@@ -244,11 +239,8 @@ restart:
244 239 WRITE_ONCE(cp->cp_send_gen, send_gen);
245 240
246 241 /*
247 - * rds_conn_shutdown() sets the conn state and then acquires
248 - * RDS_IN_XMIT; we take the lock first and then check the state.
249 - * Ownership is decided by the atomic RMW on the cp_flags word:
250 - * if the teardown won the bit we back off here, and if we won
251 - * it the teardown waits until we release it.
242 + * rds_conn_shutdown() sets the conn state and then tests RDS_IN_XMIT,
243 + * we do the opposite to avoid races.
252 244 */
253 245 if (!rds_conn_path_up(cp)) {
254 246 release_in_xmit(cp);
modified net/rds/tcp.c
@@ -115,90 +115,46 @@ void rds_tcp_restore_callbacks(struct socket *sock,
115 115 }
116 116
117 117 /*
118 - * rds_tcp_reset_callbacks() switches a path to a new socket and
119 - * releases the old one it finds in tc->t_sock, resolving a duelling
120 - * SYN.
118 + * rds_tcp_reset_callbacks() switches the to the new sock and
119 + * returns the existing tc->t_sock.
121 120 *
122 - * tc->t_sock is set by rds_tcp_set_callbacks() and cleared by
123 - * rds_tcp_restore_callbacks(). Four paths write it: the active
124 - * connect in rds_tcp_conn_path_connect(), which sets it and clears it
125 - * again on failure; the accept path in rds_tcp_accept_one(), which
126 - * sets it for a path with no socket yet; the teardown in
127 - * rds_tcp_conn_path_shutdown(), which clears it; and the swap done
128 - * here, which does both. The connect and accept paths are serialized
129 - * against each other by t_conn_path_lock. Send and receive trust
130 - * that it is set: the absence of RDS_CONN_UP protects those paths
131 - * from being called while it isn't, and the swap done here runs under
132 - * RDS_IN_XMIT so that it cannot interleave with a sender already
133 - * inside rds_send_xmit().
121 + * The only functions that set tc->t_sock are rds_tcp_set_callbacks
122 + * and rds_tcp_reset_callbacks. Send and receive trust that
123 + * it is set. The absence of RDS_CONN_UP bit protects those paths
124 + * from being called while it isn't set.
134 125 */
135 126 void rds_tcp_reset_callbacks(struct socket *sock,
136 127 struct rds_conn_path *cp)
137 128 {
138 129 struct rds_tcp_connection *tc = cp->cp_transport_data;
139 - struct socket *osock;
130 + struct socket *osock = tc->t_sock;
131 +
132 + if (!osock)
133 + goto newsock;
140 134
141 135 /* Need to resolve a duelling SYN between peers.
142 136 * We have an outstanding SYN to this peer, which may
143 137 * potentially have transitioned to the RDS_CONN_UP state,
144 138 * so we must quiesce any send threads before resetting
145 - * cp_transport_data. Setting cp_state to something other
146 - * than RDS_CONN_UP stops new senders, and owning RDS_IN_XMIT
147 - * excludes any thread already inside rds_send_xmit() - or a
148 - * teardown in rds_conn_shutdown(), which holds the same lock
149 - * for the duration of the transport shutdown - for the whole
150 - * socket swap and the rds_send_path_reset() below.
139 + * cp_transport_data. We quiesce these threads by setting
140 + * cp_state to something other than RDS_CONN_UP, and then
141 + * waiting for any existing threads in rds_send_xmit to
142 + * complete release_in_xmit(). (Subsequent threads entering
143 + * rds_send_xmit() will bail on !rds_conn_up().
151 144 *
152 - * An incoming syn-ack at this point would end up marking the
153 - * conn as RDS_CONN_UP, and would again permit rds_send_xmit()
154 - * threads through, so ideally we would synchronize on
155 - * RDS_CONN_UP after lock_sock(), but cannot do that: acquiring
156 - * RDS_IN_XMIT after lock_sock() may end up deadlocking with
157 - * tcp_sendmsg(), which takes the socket lock while holding
158 - * RDS_IN_XMIT. As a result, we set c_state to
159 - * RDS_CONN_RESETTING, to ensure that rds_tcp_state_change
160 - * cannot mark rds_conn_path_up() in the window before
161 - * lock_sock().
162 - *
163 - * Only make that transition if the path is still connecting
164 - * (or already resetting from an earlier duel). A path in any
165 - * other state - typically RDS_CONN_DISCONNECTING or
166 - * RDS_CONN_ERROR with a shutdown in flight - is dropped
167 - * instead. That still replaces its state, with RDS_CONN_ERROR,
168 - * and, unless a pending destroy is about to reap the whole
169 - * connection anyway, queues one more shutdown pass. A shutdown
170 - * already in flight leaves that RDS_CONN_ERROR alone when it
171 - * finishes; the queued pass then completes the transition to
172 - * RDS_CONN_DOWN and tears down anything that attached to the
173 - * path in the meantime.
174 - */
175 - if (!rds_conn_path_transition(cp, RDS_CONN_CONNECTING,
176 - RDS_CONN_RESETTING) &&
177 - !rds_conn_path_transition(cp, RDS_CONN_RESETTING,
178 - RDS_CONN_RESETTING))
179 - rds_conn_path_drop(cp, 0);
180 - wait_event(cp->cp_waitq,
181 - !test_and_set_bit_lock(RDS_IN_XMIT, &cp->cp_flags));
182 -
183 - /* Read t_sock only while owning RDS_IN_XMIT, never before the
184 - * wait: the teardown in rds_conn_shutdown() releases the old
185 - * socket and clears t_sock, so a pointer sampled earlier can
186 - * be stale by the time we wake up. The teardown holds the
187 - * same lock while it does so, so what we read here cannot
188 - * change under us until we release it.
189 - */
190 - osock = tc->t_sock;
191 - if (!osock)
192 - goto newsock;
193 -
194 - /* reset receive side state for rds_tcp_data_recv() for osock.
195 - *
196 - * The sync cancels while owning RDS_IN_XMIT rely on cp_wq
197 - * being ordered: a teardown blocked on the bit occupies
198 - * cp_wq's only execution slot, so cp_send_w and cp_recv_w are
199 - * pending at most and the cancels never flush. Nothing here
200 - * may flush or wait on cp_wq itself.
145 + * However an incoming syn-ack at this point would end up
146 + * marking the conn as RDS_CONN_UP, and would again permit
147 + * rds_send_xmi() threads through, so ideally we would
148 + * synchronize on RDS_CONN_UP after lock_sock(), but cannot
149 + * do that: waiting on !RDS_IN_XMIT after lock_sock() may
150 + * end up deadlocking with tcp_sendmsg(), and the RDS_IN_XMIT
151 + * would not get set. As a result, we set c_state to
152 + * RDS_CONN_RESETTTING, to ensure that rds_tcp_state_change
153 + * cannot mark rds_conn_path_up() in the window before lock_sock()
201 154 */
155 + atomic_set(&cp->cp_state, RDS_CONN_RESETTING);
156 + wait_event(cp->cp_waitq, !test_bit(RDS_IN_XMIT, &cp->cp_flags));
157 + /* reset receive side state for rds_tcp_data_recv() for osock */
202 158 cancel_delayed_work_sync(&cp->cp_send_w);
203 159 cancel_delayed_work_sync(&cp->cp_recv_w);
204 160 lock_sock(osock->sk);
@@ -216,9 +172,6 @@ newsock:
216 172 lock_sock(sock->sk);
217 173 rds_tcp_set_callbacks(sock, cp);
218 174 release_sock(sock->sk);
219 -
220 - clear_bit_unlock(RDS_IN_XMIT, &cp->cp_flags);
221 - wake_up_all(&cp->cp_waitq);
222 175 }
223 176
224 177 /* Add tc to rds_tcp_tc_list and set tc->t_sock. See comments
modified net/rds/tcp_listen.c
@@ -295,11 +295,7 @@ int rds_tcp_accept_one(struct rds_tcp_net *rtn)
295 295 if (rs_tcp->t_sock) {
296 296 /* Duelling SYN has been handled in rds_tcp_accept_one() */
297 297 rds_tcp_reset_callbacks(new_sock, cp);
298 - /* rds_connect_path_complete() marks RDS_CONN_UP, or,
299 - * if a concurrent shutdown won the duel, drops the
300 - * path again and the pass that drop queues reaps the
301 - * socket installed above.
302 - */
298 + /* rds_connect_path_complete() marks RDS_CONN_UP */
303 299 rds_connect_path_complete(cp, RDS_CONN_RESETTING);
304 300 } else {
305 301 rds_tcp_set_callbacks(new_sock, cp);
modified net/rxrpc/key.c
@@ -210,7 +210,7 @@ static int rxrpc_preparse_xdr_yfs_rxgk(struct key_preparsed_payload *prep,
210 210 if (!token)
211 211 goto nomem;
212 212
213 - token->rxgk = kzalloc_flex(struct rxgk_key, _key, raw_keylen);
213 + token->rxgk = kzalloc(struct_size_t(struct rxgk_key, _key, raw_keylen), GFP_KERNEL);
214 214 if (!token->rxgk)
215 215 goto nomem_token;
216 216
modified net/sched/act_api.c
@@ -443,21 +443,12 @@ static size_t tcf_action_shared_attrs_size(const struct tc_action *act)
443 443 + nla_total_size(IFNAMSIZ) /* TCA_ACT_KIND */
444 444 + cookie_len /* TCA_ACT_COOKIE */
445 445 + nla_total_size(sizeof(struct nla_bitfield32)) /* TCA_ACT_HW_STATS */
446 - /* TCA_ACT_USED_HW_STATS */
447 - + nla_total_size(sizeof(struct nla_bitfield32))
448 - + nla_total_size(sizeof(u32)) /* TCA_ACT_IN_HW_COUNT */
449 446 + nla_total_size(0) /* TCA_ACT_STATS nested */
450 447 + nla_total_size(sizeof(struct nla_bitfield32)) /* TCA_ACT_FLAGS */
451 448 /* TCA_STATS_BASIC */
452 449 + nla_total_size_64bit(sizeof(struct gnet_stats_basic))
453 - /* TCA_STATS_BASIC_HW */
454 - + nla_total_size_64bit(sizeof(struct gnet_stats_basic))
455 - /* TCA_STATS_PKT64, emitted by both of the basic copies above */
456 - + 2 * nla_total_size_64bit(sizeof(u64))
457 - /* TCA_STATS_RATE_EST */
458 - + nla_total_size_64bit(sizeof(struct gnet_stats_rate_est))
459 - /* TCA_STATS_RATE_EST64 */
460 - + nla_total_size_64bit(sizeof(struct gnet_stats_rate_est64))
450 + /* TCA_STATS_PKT64 */
451 + + nla_total_size_64bit(sizeof(u64))
461 452 /* TCA_STATS_QUEUE */
462 453 + nla_total_size_64bit(sizeof(struct gnet_stats_queue))
463 454 + nla_total_size(0) /* TCA_ACT_OPTIONS nested */
@@ -1697,12 +1688,12 @@ out_nlmsg_trim:
1697 1688
1698 1689 static int
1699 1690 tcf_get_notify(struct net *net, u32 portid, struct nlmsghdr *n,
1700 - struct tc_action *actions[], size_t attr_size, int event,
1691 + struct tc_action *actions[], int event,
1701 1692 struct netlink_ext_ack *extack)
1702 1693 {
1703 1694 struct sk_buff *skb;
1704 1695
1705 - skb = alloc_skb(max(attr_size, NLMSG_GOODSIZE), GFP_KERNEL);
1696 + skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
1706 1697 if (!skb)
1707 1698 return -ENOBUFS;
1708 1699 if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, 0, event,
@@ -1867,13 +1858,11 @@ static int tcf_action_delete(struct net *net, struct tc_action *actions[])
1867 1858 static struct sk_buff *tcf_reoffload_del_notify_msg(struct net *net,
1868 1859 struct tc_action *action)
1869 1860 {
1861 + size_t attr_size = tcf_action_fill_size(action);
1870 1862 struct tc_action *actions[TCA_ACT_MAX_PRIO] = {
1871 1863 [0] = action,
1872 1864 };
1873 1865 struct sk_buff *skb;
1874 - size_t attr_size;
1875 -
1876 - attr_size = tcf_action_full_attrs_size(tcf_action_fill_size(action));
1877 1866
1878 1867 skb = alloc_skb(max(attr_size, NLMSG_GOODSIZE), GFP_KERNEL);
1879 1868 if (!skb)
@@ -1890,18 +1879,15 @@ static struct sk_buff *tcf_reoffload_del_notify_msg(struct net *net,
1890 1879 static int tcf_reoffload_del_notify(struct net *net, struct tc_action *action)
1891 1880 {
1892 1881 const struct tc_action_ops *ops = action->ops;
1893 - struct sk_buff *skb = NULL;
1882 + struct sk_buff *skb;
1894 1883 int ret;
1895 1884
1896 - if (rtnl_notify_needed(net, 0, RTNLGRP_TC)) {
1885 + if (!rtnl_notify_needed(net, 0, RTNLGRP_TC)) {
1886 + skb = NULL;
1887 + } else {
1897 1888 skb = tcf_reoffload_del_notify_msg(net, action);
1898 - /* The action has already lost its hardware instance and is
1899 - * skip_sw, so it must be released whether or not the
1900 - * notification can be built. Drop the notification rather
1901 - * than leave an action behind that processes no packets.
1902 - */
1903 1889 if (IS_ERR(skb))
1904 - skb = NULL;
1890 + return PTR_ERR(skb);
1905 1891 }
1906 1892
1907 1893 ret = tcf_idr_release_unsafe(action);
@@ -2058,8 +2044,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,
2058 2044 attr_size = tcf_action_full_attrs_size(attr_size);
2059 2045
2060 2046 if (event == RTM_GETACTION)
2061 - ret = tcf_get_notify(net, portid, n, actions, attr_size, event,
2062 - extack);
2047 + ret = tcf_get_notify(net, portid, n, actions, event, extack);
2063 2048 else { /* delete */
2064 2049 ret = tcf_del_notify(net, n, actions, portid, attr_size, extack);
2065 2050 if (ret)
modified net/sched/act_gate.c
@@ -240,7 +240,7 @@ static int tcf_gate_copy_entries(struct tcf_gate_params *dst,
240 240 list_for_each_entry(entry, &src->entries, list) {
241 241 struct tcfg_gate_entry *new;
242 242
243 - new = kzalloc_obj(*new, GFP_ATOMIC);
243 + new = kzalloc(sizeof(*new), GFP_ATOMIC);
244 244 if (!new) {
245 245 NL_SET_ERR_MSG(extack, "Not enough memory for entry");
246 246 return -ENOMEM;
@@ -415,7 +415,7 @@ static int tcf_gate_init(struct net *net, struct nlattr *nla,
415 415 if (err < 0)
416 416 goto release_idr;
417 417
418 - p = kzalloc_obj(*p);
418 + p = kzalloc(sizeof(*p), GFP_KERNEL);
419 419 if (!p) {
420 420 err = -ENOMEM;
421 421 goto chain_put;
modified net/sched/act_tunnel_key.c
@@ -526,7 +526,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
526 526 }
527 527 t = to_tunnel_key(*a);
528 528
529 - params_new = kzalloc_obj(*params_new);
529 + params_new = kzalloc(sizeof(*params_new), GFP_KERNEL);
530 530 if (unlikely(!params_new)) {
531 531 NL_SET_ERR_MSG(extack, "Cannot allocate tunnel key parameters");
532 532 ret = -ENOMEM;
modified net/sched/cls_flower.c
@@ -1703,11 +1703,6 @@ static int fl_set_enc_opt(struct nlattr **tb, struct fl_flow_key *key,
1703 1703 return -EINVAL;
1704 1704 }
1705 1705 nla_opt_msk = nla_next(nla_opt_msk, &msk_depth);
1706 -
1707 - if (msk_depth && !nla_ok(nla_opt_msk, msk_depth)) {
1708 - NL_SET_ERR_MSG(extack, "A mask attribute is invalid");
1709 - return -EINVAL;
1710 - }
1711 1706 }
1712 1707
1713 1708 return 0;
modified net/sched/cls_u32.c
@@ -370,10 +370,6 @@ static int u32_init(struct tcf_proto *tp)
370 370
371 371 refcount_set(&root_ht->refcnt, 1);
372 372 root_ht->handle = tp_c ? gen_new_htid(tp_c, root_ht) : id2handle(0);
373 - if (root_ht->handle == 0) {
374 - kfree(root_ht);
375 - return -ENOMEM;
376 - }
377 373 root_ht->prio = tp->prio;
378 374 root_ht->is_root = true;
379 375 idr_init(&root_ht->handle_idr);
@@ -699,33 +695,21 @@ out:
699 695 return ret;
700 696 }
701 697
702 - static u32 gen_new_kid(struct tc_u_hnode *ht, u32 htid, int *err)
698 + static u32 gen_new_kid(struct tc_u_hnode *ht, u32 htid)
703 699 {
704 700 u32 index = htid | 0x800;
705 701 u32 max = htid | 0xFFF;
706 702
707 - *err = 0;
708 -
709 703 if (idr_alloc_u32(&ht->handle_idr, NULL, &index, max, GFP_KERNEL)) {
710 704 index = htid + 1;
711 - *err = idr_alloc_u32(&ht->handle_idr, NULL, &index, max,
712 - GFP_KERNEL);
713 - if (*err)
714 - return 0;
705 + if (idr_alloc_u32(&ht->handle_idr, NULL, &index, max,
706 + GFP_KERNEL))
707 + index = max;
715 708 }
716 709
717 710 return index;
718 711 }
719 712
720 - static int u32_kid_extack(int err, struct netlink_ext_ack *extack)
721 - {
722 - if (err == -ENOSPC)
723 - NL_SET_ERR_MSG_MOD(extack, "Hash table node ID pool exhausted");
724 - else
725 - NL_SET_ERR_MSG_MOD(extack, "Failed to allocate node ID");
726 - return err;
727 - }
728 -
729 713 static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = {
730 714 [TCA_U32_CLASSID] = { .type = NLA_U32 },
731 715 [TCA_U32_HASH] = { .type = NLA_U32 },
@@ -1095,9 +1079,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
1095 1079 * handle which is used to uniquely identify the match entry.
1096 1080 */
1097 1081 if (!TC_U32_NODE(handle)) {
1098 - handle = gen_new_kid(ht, htid, &err);
1099 - if (err)
1100 - return u32_kid_extack(err, extack);
1082 + handle = gen_new_kid(ht, htid);
1101 1083 } else {
1102 1084 handle = htid | TC_U32_NODE(handle);
1103 1085 err = idr_alloc_u32(&ht->handle_idr, NULL, &handle,
@@ -1109,9 +1091,7 @@ static int u32_change(struct net *net, struct sk_buff *in_skb,
1109 1091 /* The user did not give us a handle; lets just generate one
1110 1092 * from the table's pool of nodeids.
1111 1093 */
1112 - handle = gen_new_kid(ht, htid, &err);
1113 - if (err)
1114 - return u32_kid_extack(err, extack);
1094 + handle = gen_new_kid(ht, htid);
1115 1095 }
1116 1096
1117 1097 if (tb[TCA_U32_SEL] == NULL) {
modified net/sctp/inqueue.c
@@ -212,10 +212,8 @@ new_skb:
212 212 chunk->chunk_end = ((__u8 *)ch) + SCTP_PAD4(ntohs(ch->length));
213 213 skb_pull(chunk->skb, sizeof(*ch));
214 214 chunk->subh.v = NULL; /* Subheader is no longer valid. */
215 - if (unlikely(ntohs(ch->length) < sizeof(*ch))) {
216 - chunk->pdiscard = 1;
217 - } else if (chunk->chunk_end + sizeof(*ch) <=
218 - skb_tail_pointer(chunk->skb)) {
215 +
216 + if (chunk->chunk_end + sizeof(*ch) <= skb_tail_pointer(chunk->skb)) {
219 217 /* This is not a singleton */
220 218 chunk->singleton = 0;
221 219 } else if (chunk->chunk_end > skb_tail_pointer(chunk->skb)) {
modified net/sctp/sm_make_chunk.c
@@ -3215,9 +3215,6 @@ bool sctp_verify_asconf(const struct sctp_association *asoc,
3215 3215 *errp = param.p;
3216 3216 switch (param.p->type) {
3217 3217 case SCTP_PARAM_ERR_CAUSE:
3218 - if (length < sizeof(struct sctp_addip_param) +
3219 - sizeof(struct sctp_errhdr))
3220 - return false;
3221 3218 break;
3222 3219 case SCTP_PARAM_IPV4_ADDRESS:
3223 3220 if (length != sizeof(struct sctp_ipv4addr_param))
@@ -3451,15 +3448,20 @@ static __be16 sctp_get_asconf_response(struct sctp_chunk *asconf_ack,
3451 3448 case SCTP_PARAM_ERR_CAUSE:
3452 3449 length = sizeof(*asconf_ack_param);
3453 3450 err_param = (void *)asconf_ack_param + length;
3454 - return err_param->cause;
3451 + asconf_ack_len -= length;
3452 + if (asconf_ack_len > 0)
3453 + return err_param->cause;
3454 + else
3455 + return SCTP_ERROR_INV_PARAM;
3456 + break;
3455 3457 default:
3456 3458 return SCTP_ERROR_INV_PARAM;
3457 3459 }
3458 3460 }
3459 3461
3460 3462 length = ntohs(asconf_ack_param->param_hdr.length);
3461 - asconf_ack_param = (void *)asconf_ack_param + SCTP_PAD4(length);
3462 - asconf_ack_len -= SCTP_PAD4(length);
3463 + asconf_ack_param = (void *)asconf_ack_param + length;
3464 + asconf_ack_len -= length;
3463 3465 }
3464 3466
3465 3467 return err_code;
modified net/sctp/sm_sideeffect.c
@@ -1545,8 +1545,17 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type,
1545 1545 timeout = asoc->timeouts[cmd->obj.to];
1546 1546 BUG_ON(!timeout);
1547 1547
1548 - if (!timer_reduce(timer, jiffies + timeout))
1548 + /*
1549 + * SCTP has a hard time with timer starts. Because we process
1550 + * timer starts as side effects, it can be hard to tell if we
1551 + * have already started a timer or not, which leads to BUG
1552 + * halts when we call add_timer. So here, instead of just starting
1553 + * a timer, if the timer is already started, and just mod
1554 + * the timer with the shorter of the two expiration times
1555 + */
1556 + if (!timer_pending(timer))
1549 1557 sctp_association_hold(asoc);
1558 + timer_reduce(timer, jiffies + timeout);
1550 1559 break;
1551 1560
1552 1561 case SCTP_CMD_TIMER_RESTART:
modified net/sunrpc/auth_gss/gss_krb5_crypto.c
@@ -282,8 +282,9 @@ int gss_krb5_mic_build_sg(const struct xdr_buf *body,
282 282 unsigned int overflow_nents =
283 283 nsg - XDR_BUF_TO_SG_NENTS + 1;
284 284
285 - *sg_overflow = kmalloc_objs(**sg_overflow, overflow_nents,
286 - GFP_NOFS);
285 + *sg_overflow = kmalloc_array(overflow_nents,
286 + sizeof(**sg_overflow),
287 + GFP_NOFS);
287 288 if (!*sg_overflow)
288 289 return -ENOMEM;
289 290
modified net/sunrpc/svcauth_unix.c
@@ -625,7 +625,7 @@ int sunrpc_nl_unix_gid_get_reqs_dumpit(struct sk_buff *skb,
625 625 if (!cnt)
626 626 return 0;
627 627
628 - items = kzalloc_objs(*items, cnt);
628 + items = kcalloc(cnt, sizeof(*items), GFP_KERNEL);
629 629 seqnos = kcalloc(cnt, sizeof(*seqnos), GFP_KERNEL);
630 630 if (!items || !seqnos) {
631 631 ret = -ENOMEM;
@@ -1326,7 +1326,7 @@ int sunrpc_nl_ip_map_get_reqs_dumpit(struct sk_buff *skb,
1326 1326 if (!cnt)
1327 1327 return 0;
1328 1328
1329 - items = kzalloc_objs(*items, cnt);
1329 + items = kcalloc(cnt, sizeof(*items), GFP_KERNEL);
1330 1330 seqnos = kcalloc(cnt, sizeof(*seqnos), GFP_KERNEL);
1331 1331 if (!items || !seqnos) {
1332 1332 ret = -ENOMEM;
modified net/sunrpc/xdr.c
@@ -371,7 +371,8 @@ int xdr_buf_to_sg_alloc(const struct xdr_buf *buf, unsigned int offset,
371 371 unsigned int overflow_nents = nsg - sg_head_nents + 1;
372 372 struct scatterlist *overflow;
373 373
374 - overflow = kmalloc_objs(*overflow, overflow_nents, gfp);
374 + overflow = kmalloc_array(overflow_nents, sizeof(*overflow),
375 + gfp);
375 376 if (!overflow)
376 377 return -ENOMEM;
377 378
modified net/tipc/link.c
@@ -504,7 +504,7 @@ bool tipc_link_create(struct net *net, char *if_name, int bearer_id,
504 504 snprintf(l->name, sizeof(l->name), "%s:%s-%s:unknown",
505 505 self_str, if_name, peer_str);
506 506
507 - strscpy(l->if_name, if_name);
507 + strcpy(l->if_name, if_name);
508 508 l->addr = peer;
509 509 l->peer_caps = peer_caps;
510 510 l->net = net;
@@ -574,7 +574,7 @@ bool tipc_link_bc_create(struct net *net, u32 ownnode, u32 peer, u8 *peer_id,
574 574 snprintf(l->name, sizeof(l->name), "%s:%s", tipc_bclink_name,
575 575 peer_str);
576 576 } else {
577 - strscpy(l->name, tipc_bclink_name);
577 + strcpy(l->name, tipc_bclink_name);
578 578 }
579 579 trace_tipc_link_reset(l, TIPC_DUMP_ALL, "bclink created!");
580 580 tipc_link_reset(l);
@@ -1898,7 +1898,7 @@ static void tipc_link_build_proto_msg(struct tipc_link *l, int mtyp, bool probe,
1898 1898 msg_set_dest_session(hdr, l->peer_session);
1899 1899 }
1900 1900 msg_set_max_pkt(hdr, l->advertised_mtu);
1901 - memcpy(data, l->if_name, TIPC_MAX_IF_NAME);
1901 + strcpy(data, l->if_name);
1902 1902 msg_set_size(hdr, INT_H_SIZE + TIPC_MAX_IF_NAME);
1903 1903 skb_trim(skb, INT_H_SIZE + TIPC_MAX_IF_NAME);
1904 1904 }
modified net/tipc/name_table.c
@@ -763,40 +763,21 @@ struct publication *tipc_nametbl_publish(struct net *net, struct tipc_uaddr *ua,
763 763 struct tipc_socket_addr *sk, u32 key)
764 764 {
765 765 struct name_table *nt = tipc_name_table(net);
766 - u32 max_user_pub = TIPC_MAX_PUBL - 1;
767 766 struct tipc_net *tn = tipc_net(net);
768 767 struct publication *p = NULL;
769 768 struct sk_buff *skb = NULL;
770 - bool protocol_type = false;
771 769 u32 rc_dests;
772 770
773 - if (ua->sr.type == TIPC_NODE_STATE || ua->sr.type == TIPC_LINK_STATE ||
774 - ua->sr.type == TIPC_TOP_SRV)
775 - protocol_type = true;
776 -
777 771 spin_lock_bh(&tn->nametbl_lock);
778 - if (protocol_type)
779 - goto insert;
780 772
781 - /* Reserve one entry for node state service type because it has cluster
782 - * scope and it is distributed in bulk. So, the maximum number of user's
783 - * publications is (TIPC_MAX_PUBL - 1).
784 - */
785 - if (nt->local_publ_count >= max_user_pub) {
786 - pr_warn("Bind failed, max limit %u reached\n", max_user_pub);
773 + if (nt->local_publ_count >= TIPC_MAX_PUBL) {
774 + pr_warn("Bind failed, max limit %u reached\n", TIPC_MAX_PUBL);
787 775 goto exit;
788 776 }
789 777
790 - insert:
791 778 p = tipc_nametbl_insert_publ(net, ua, sk, key);
792 779 if (p) {
793 - /* Not count node state, link state and topology server types
794 - * so that maximum nt->local_publ_count does not prevent
795 - * protocol service types from being inserted into the name
796 - * table.
797 - */
798 - if (!protocol_type)
799 - nt->local_publ_count++;
780 + nt->local_publ_count++;
800 781 skb = tipc_named_publish(net, p);
801 782 }
802 783 rc_dests = nt->rc_dests;
@@ -829,10 +810,7 @@ void tipc_nametbl_withdraw(struct net *net, struct tipc_uaddr *ua,
829 810
830 811 p = tipc_nametbl_remove_publ(net, ua, sk, key);
831 812 if (p) {
832 - if (p->sr.type != TIPC_NODE_STATE &&
833 - p->sr.type != TIPC_LINK_STATE &&
834 - p->sr.type != TIPC_TOP_SRV)
835 - nt->local_publ_count--;
813 + nt->local_publ_count--;
836 814 skb = tipc_named_withdraw(net, p);
837 815 list_del_init(&p->binding_sock);
838 816 kfree_rcu(p, rcu);
modified net/tipc/node.c
@@ -1333,9 +1333,7 @@ static void tipc_node_reset_links(struct tipc_node *n)
1333 1333
1334 1334 pr_warn("Resetting all links to %x\n", n->addr);
1335 1335
1336 - tipc_node_write_lock(n);
1337 1336 trace_tipc_node_reset_links(n, true, " ");
1338 - tipc_node_write_unlock_fast(n);
1339 1337 for (i = 0; i < MAX_BEARERS; i++) {
1340 1338 tipc_node_link_down(n, i, false);
1341 1339 }
modified net/unix/af_unix.c
@@ -3667,8 +3667,8 @@ static int bpf_iter_unix_realloc_batch(struct bpf_unix_iter_state *iter,
3667 3667 {
3668 3668 struct sock **new_batch;
3669 3669
3670 - new_batch = kvmalloc_objs(*new_batch, new_batch_sz,
3671 - GFP_USER | __GFP_NOWARN);
3670 + new_batch = kvmalloc_array(new_batch_sz, sizeof(*new_batch),
3671 + GFP_USER | __GFP_NOWARN);
3672 3672 if (!new_batch)
3673 3673 return -ENOMEM;
3674 3674
modified net/vmw_vsock/af_vsock.c

No content changes.

This diff is too large to show in full - only the first part is shown.