Compare

89c2c777df17eb0201c8e22afabbf3691f2a28fe..2e42cade8ff1ff579e77976d9869db4df1feaf74

regmap: irq: Free the irqdomain we create

When domain support was added to regmap-irq it was not possible to
remove domains, this was added later by 8ee99ada293b (irqdomain: Support
removal of IRQ domains.).  We did update the main removal path to free
the domain but forgot the error unwinding case during creation that is
now in regmap_add_irq_chip_fwnode() after some code motion, meaning that
errors during instantiation result in an unused irqchip being left
hanging around.  Add the missing irq_remove_domain() call where the
comment says it should be.

Reported-by: Farhad Alemi <farhad.alemi@berkeley.edu>
Reported-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/20260901-regmap-irq-deallocate-domain-v1-1-4bfed4aff559@kernel.org
Signed-off-by: Mark Brown <broonie@kernel.org>

Mark Brown <broonie@kernel.org> · 2026-09-01 21:55 UTC

Browse files
714 files changed, +3636 −7009
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>
@@ -421,7 +420,6 @@ Jens Axboe <axboe@kernel.dk> <axboe@suse.de>
421 420 Jens Axboe <axboe@kernel.dk> <jens.axboe@oracle.com>
422 421 Jens Axboe <axboe@kernel.dk> <axboe@fb.com>
423 422 Jens Axboe <axboe@kernel.dk> <axboe@meta.com>
424 - Jens Axboe <axboe@kernel.dk> <axboe@anthropic.com>
425 423 Jens Osterkamp <Jens.Osterkamp@de.ibm.com>
426 424 Jens Wiklander <jenswi@kernel.org> <jens.wiklander@linaro.org>
427 425 Jernej Skrabec <jernej.skrabec@gmail.com> <jernej.skrabec@siol.net>
@@ -552,9 +550,6 @@ Li Yang <leoyang.li@nxp.com> <leo@zh-kernel.org>
552 550 Lior David <quic_liord@quicinc.com> <liord@codeaurora.org>
553 551 Loic Poulain <loic.poulain@oss.qualcomm.com> <loic.poulain@linaro.org>
554 552 Loic Poulain <loic.poulain@oss.qualcomm.com> <loic.poulain@intel.com>
555 - Lorenzo Bianconi <lorenzo@kernel.org> <lorenzo.bianconi@redhat.com>
556 - Lorenzo Bianconi <lorenzo@kernel.org> <lorenzo.bianconi@st.com>
557 - Lorenzo Bianconi <lorenzo@kernel.org> <lorenzo.bianconi83@gmail.com>
558 553 Lorenzo Pieralisi <lpieralisi@kernel.org> <lorenzo.pieralisi@arm.com>
559 554 Lorenzo Stoakes <ljs@kernel.org> <lstoakes@gmail.com>
560 555 Lorenzo Stoakes <ljs@kernel.org> <lorenzo.stoakes@oracle.com>
@@ -704,7 +699,6 @@ Oliver Hartkopp <socketcan@hartkopp.net> <oliver.hartkopp@volkswagen.de>
704 699 Oliver Hartkopp <socketcan@hartkopp.net> <oliver@hartkopp.net>
705 700 Oliver Upton <oupton@kernel.org> <oupton@google.com>
706 701 Oliver Upton <oupton@kernel.org> <oliver.upton@linux.dev>
707 - Ondrej Mosnáček <omosnacek@gmail.com> <omosnace@redhat.com>
708 702 Ondřej Jirman <megi@xff.cz> <megous@megous.com>
709 703 Oza Pawandeep <quic_poza@quicinc.com> <poza@codeaurora.org>
710 704 Pali Rohár <pali@kernel.org> <pali.rohar@gmail.com>
@@ -904,8 +898,7 @@ Thomas Graf <tgraf@suug.ch>
904 898 Thomas Gleixner <tglx@kernel.org> <tglx@linutronix.de>
905 899 Thomas Körper <socketcan@esd.eu> <thomas.koerper@esd.eu>
906 900 Thomas Pedersen <twp@codeaurora.org>
907 - Thorsten Blum <blum@kernel.org> <thorsten.blum@toblux.com>
908 - Thorsten Blum <blum@kernel.org> <thorsten.blum@linux.dev>
901 + Thorsten Blum <thorsten.blum@linux.dev> <thorsten.blum@toblux.com>
909 902 Tiezhu Yang <yangtiezhu@loongson.cn> <kernelpatch@126.com>
910 903 Tingwei Zhang <quic_tingwei@quicinc.com> <tingwei@codeaurora.org>
911 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/ABI/testing/sysfs-fs-erofs
@@ -5,7 +5,7 @@ Description: Shows all enabled kernel features.
5 5 Supported features:
6 6 compr_cfgs, big_pcluster, chunked_file, device_table,
7 7 compr_head2, sb_chksum, ztailpacking, dedupe, fragments,
8 - xattr_prefixes, 48bit, metabox.
8 + 48bit, metabox.
9 9
10 10 What: /sys/fs/erofs/<disk>/sync_decompress
11 11 Date: November 2021
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/admin-guide/kernel-parameters.txt
@@ -4987,6 +4987,18 @@ Kernel parameters
4987 4987 Set to non-zero if a chip is present that snoops speed
4988 4988 changes. Disabled by default.
4989 4989
4990 + pata_legacy.ht6560a= [HW,LIBATA]
4991 + Format: <int>
4992 + Set to 1, 2, or 3 for HT 6560A on the primary channel,
4993 + the secondary channel, or both channels respectively.
4994 + Disabled by default.
4995 +
4996 + pata_legacy.ht6560b= [HW,LIBATA]
4997 + Format: <int>
4998 + Set to 1, 2, or 3 for HT 6560B on the primary channel,
4999 + the secondary channel, or both channels respectively.
5000 + Disabled by default.
5001 +
4990 5002 pata_legacy.iordy_mask= [HW,LIBATA]
4991 5003 Format: <int>
4992 5004 IORDY enable mask. Set individual bits to allow IORDY
@@ -4999,6 +5011,18 @@ Kernel parameters
4999 5011 with the sequence. By default IORDY is allowed across
5000 5012 all channels.
5001 5013
5014 + pata_legacy.opti82c46x= [HW,LIBATA]
5015 + Format: <int>
5016 + Set to 1, 2, or 3 for Opti 82c611A on the primary
5017 + channel, the secondary channel, or both channels
5018 + respectively. Disabled by default.
5019 +
5020 + pata_legacy.opti82c611a= [HW,LIBATA]
5021 + Format: <int>
5022 + Set to 1, 2, or 3 for Opti 82c465MV on the primary
5023 + channel, the secondary channel, or both channels
5024 + respectively. Disabled by default.
5025 +
5002 5026 pata_legacy.pio_mask= [HW,LIBATA]
5003 5027 Format: <int>
5004 5028 PIO mode mask for autospeed devices. Set individual
@@ -5022,6 +5046,19 @@ Kernel parameters
5022 5046 the first port in the list above (0x1f0), and so on.
5023 5047 By default all supported ports are probed.
5024 5048
5049 + pata_legacy.qdi= [HW,LIBATA]
5050 + Format: <int>
5051 + Set to non-zero to probe QDI controllers. By default
5052 + set to 1 if CONFIG_PATA_QDI_MODULE, 0 otherwise.
5053 +
5054 + pata_legacy.winbond= [HW,LIBATA]
5055 + Format: <int>
5056 + Set to non-zero to probe Winbond controllers. Use
5057 + the standard I/O port (0x130) if 1, otherwise the
5058 + value given is the I/O port to use (typically 0x1b0).
5059 + By default set to 1 if CONFIG_PATA_WINBOND_VLB_MODULE,
5060 + 0 otherwise.
5061 +
5025 5062 pata_platform.pio_mask= [HW,LIBATA]
5026 5063 Format: <int>
5027 5064 Supported PIO mode mask. Set individual bits to allow
modified Documentation/admin-guide/sysctl/kernel.rst
@@ -1416,7 +1416,7 @@ Controls whether userspace may arm Syscall User Dispatch via
1416 1416 == ===================================================================
1417 1417
1418 1418 Only present when the kernel is built with ``CONFIG_SYSCALL_USER_DISPATCH``
1419 - and ``CONFIG_SYSCTL``.
1419 + and ``CONFIG_PROC_SYSCTL``.
1420 1420
1421 1421
1422 1422 sysctl_writes_strict
modified Documentation/arch/riscv/hwprobe.rst
@@ -155,8 +155,7 @@ The following keys are defined:
155 155 defined in version 1.0 of the RISC-V Cryptography Extensions Volume II.
156 156
157 157 * :c:macro:`RISCV_HWPROBE_EXT_ZFH`: The Zfh extension version 1.0 is supported
158 - as defined in the RISC-V ISA manual. Zfh is a superset of Zfhmin, so
159 - RISCV_HWPROBE_EXT_ZFHMIN is reported whenever RISCV_HWPROBE_EXT_ZFH is.
158 + as defined in the RISC-V ISA manual.
160 159
161 160 * :c:macro:`RISCV_HWPROBE_EXT_ZFHMIN`: The Zfhmin extension version 1.0 is
162 161 supported as defined in the RISC-V ISA manual.
@@ -165,9 +164,8 @@ The following keys are defined:
165 164 is supported as defined in the RISC-V ISA manual.
166 165
167 166 * :c:macro:`RISCV_HWPROBE_EXT_ZVFH`: The Zvfh extension is supported as
168 - defined in the RISC-V Vector manual starting from commit e2ccd0548d6c
169 - ("Remove draft warnings from Zvfh[min]"). Zvfh is a superset of Zvfhmin,
170 - so RISCV_HWPROBE_EXT_ZVFHMIN is reported whenever RISCV_HWPROBE_EXT_ZVFH is.
167 + defined in the RISC-V Vector manual starting from commit e2ccd0548d6c
168 + ("Remove draft warnings from Zvfh[min]").
171 169
172 170 * :c:macro:`RISCV_HWPROBE_EXT_ZVFHMIN`: The Zvfhmin extension is supported as
173 171 defined in the RISC-V Vector manual starting from commit e2ccd0548d6c
modified Documentation/devicetree/bindings/regulator/fcs,fan53555.yaml
@@ -23,7 +23,6 @@ properties:
23 23 - silergy,syr827
24 24 - silergy,syr828
25 25 - tcs,tcs4525
26 - - tcs,tcs4526
27 26 - items:
28 27 - const: rockchip,rk8601
29 28 - const: rockchip,rk8600
modified Documentation/devicetree/bindings/riscv/cpus.yaml
@@ -117,8 +117,8 @@ properties:
117 117 $ref: /schemas/types.yaml#/definitions/uint32
118 118 description:
119 119 VLEN/8, the vector register length in bytes. This property is required on
120 - thead systems where the vector register length is not identical on all
121 - harts, or the vlenb CSR is not available.
120 + thead systems where the vector register length is not identical on all harts, or
121 + the vlenb CSR is not available.
122 122
123 123 # RISC-V has multiple properties for cache op block sizes as the sizes
124 124 # differ between individual CBO extensions
@@ -151,8 +151,8 @@ anyOf:
151 151 - riscv,isa-base
152 152
153 153 dependencies:
154 - riscv,isa-base: ["riscv,isa-extensions"]
155 - riscv,isa-extensions: ["riscv,isa-base"]
154 + riscv,isa-base: [ "riscv,isa-extensions" ]
155 + riscv,isa-extensions: [ "riscv,isa-base" ]
156 156
157 157 required:
158 158 - interrupt-controller
modified Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.yaml
@@ -44,21 +44,6 @@ allOf:
44 44 else:
45 45 properties:
46 46 starfive,sfc-filter-syscon: false
47 - - if:
48 - properties:
49 - compatible:
50 - contains:
51 - const: ultrarisc,dp1000-spi
52 - then:
53 - properties:
54 - reg:
55 - maxItems: 1
56 - clocks:
57 - minItems: 2
58 - clock-names:
59 - minItems: 2
60 - required:
61 - - clock-names
62 47
63 48 properties:
64 49 compatible:
@@ -78,7 +63,6 @@ properties:
78 63 - mscc,jaguar2-spi
79 64 - sophgo,sg2042-spi
80 65 - thead,th1520-spi
81 - - ultrarisc,dp1000-spi
82 66 - const: snps,dw-apb-ssi
83 67 - description: Vendor controllers compatible with v1.01a
84 68 items:
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/hwmon/gpd-fan.rst
@@ -67,7 +67,7 @@ pwm1_enable
67 67 at full speed. Write "1" to set to manual, write "2" to let the EC control
68 68 decide fan speed. Read this attribute to see current status.
69 69
70 - NB: In consideration of the safety of the device, when setting to manual mode,
70 + NB:In consideration of the safety of the device, when setting to manual mode,
71 71 the pwm speed will be set to the maximum value (255) by default. You can set
72 72 a different value by writing pwm1 later.
73 73
modified Documentation/hwmon/hwmon-kernel-api.rst
@@ -42,9 +42,6 @@ register/unregister functions::
42 42
43 43 char *devm_hwmon_sanitize_name(struct device *dev, const char *name);
44 44
45 - int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type,
46 - u32 attr, int channel);
47 -
48 45 void hwmon_lock(struct device *dev);
49 46 void hwmon_unlock(struct device *dev);
50 47
@@ -93,18 +90,6 @@ implemented in the driver, or debugfs functions, hwmon_lock() and hwmon_unlock()
93 90 can be used to ensure that calls to those functions are serialized. Those
94 91 functions also support guard() and scoped_guard() variants.
95 92
96 - Drivers can call hwmon_notify_event() to notify userspace and the thermal
97 - subsystem when a hardware monitoring event (such as an alarm or a fault
98 - condition) occurs or clears. The parameters are the hwmon device, the sensor
99 - type, the attribute identifier associated with the event (such as
100 - hwmon_temp_max_alarm or hwmon_fan_fault), and the sensor channel number.
101 - hwmon_notify_event() generates a sysfs event (calling sysfs_notify()) and a
102 - udev event with the attribute name passed in the NAME environment property
103 - (e.g., "NAME=temp1_max_alarm"). If the event is for a temperature sensor and
104 - the sensor is attached to a thermal zone, it also notifies the thermal
105 - subsystem to update the thermal zone. hwmon_notify_event() returns 0 on
106 - success or a negative error code on failure.
107 -
108 93 Using devm_hwmon_device_register_with_info()
109 94 --------------------------------------------
110 95
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/netlink/specs/rt-link.yaml
@@ -898,8 +898,6 @@ attribute-sets:
898 898 -
899 899 name: txqlen
900 900 type: u32
901 - checks:
902 - max: 32767
903 901 -
904 902 name: map
905 903 type: binary
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/arch/riscv/patch-acceptance.rst
@@ -15,41 +15,19 @@ arch/riscv 开发者维护指南
15 15
16 16 概述
17 17 ----
18 - RISC-V 指令集体系结构是公开开发的:
18 + RISC-V指令集体系结构是公开开发的:
19 19 正在进行的草案可供所有人查看和测试实现。新模块或者扩展草案可能会在开发过程中发
20 - 生更改 --- 有时以不兼容的方式对以前的草案进行更改。这种灵活性可能会给 RISC-V
21 - Linux 维护者带来挑战。Linux 维护者不赞成频繁的变更,且 Linux 开发过程更喜欢经过
22 - 良好检查和测试的代码,而不是试验代码。我们希望推广同样的规则到即将被内核合并的
23 - RISC-V 相关代码。
24 -
25 - Patchwork
26 - ---------
27 -
28 - RISC-V 有一个 patchwork 实例,可以在那里查看补丁的状态:
29 -
30 - https://patchwork.kernel.org/project/linux-riscv/list/
31 -
32 - 如果你的补丁不在默认视图中出现,那么 RISC-V 维护者很有可能已要求修改,或者希望
33 - 将其应用到另一个代码树上。
34 -
35 - 自动化流程会在该 patchwork 实例上运行,在每个补丁到达时立刻对其进行构建/测试。
36 - 自动化流程会根据补丁是否被识别为修复,选用 RISC-V `for-next` 或 `fixes` 分支
37 - 当前的 HEAD;若上述均应用失败,则使用 RISC-V `master` 分支。补丁系列被应用到的具
38 - 体提交将标注在 patchwork 上。任何检查未通过的补丁通常不会被应用,并且在大多数情
39 - 况下将需要重新提交。
20 + 生更改---有时以不兼容的方式对以前的草案进行更改。这种灵活性可能会给RISC-V Linux
21 + 维护者带来挑战。Linux开发过程更喜欢经过良好检查和测试的代码,而不是试验代码。我
22 + 们希望推广同样的规则到即将被内核合并的RISC-V相关代码。
40 23
41 24 附加的提交检查单
42 25 ----------------
43 - 我们仅接受针对新模块或扩展的补丁,前提是这些模块或扩展的规范被列为未来不太可能发
44 - 生不兼容的变更。对于来自 RISC-V 基金会的规范,这意味着“已冻结”或“已批准”,对于
45 - UEFI 论坛的规范,这意味着已发布的 ECR。(开发者当然可以维护自己的 Linux 内核树,
46 - 其中包含他们所需的任何扩展草案的代码。)
47 -
48 - 此外,RISC-V 规范允许实现者创建自己的自定义扩展。这些自定义扩展不需要通过 RISC-V
49 - 基金会的任何审核或批准流程。为了避免因添加实现者特定的 RISC-V 扩展带来的维护复杂
50 - 性和对性能的潜在影响,我们将只考虑符合以下任一条件的扩展补丁:
51 -
52 - - 已由 RISC-V 基金会正式冻结或批准
53 - - 已按照标准 Linux 惯例,在广泛可用的硬件中实现
54 -
55 - (实现者当然可以维护自己的 Linux 内核树,其中包含他们所需的任何自定义扩展的代码。)
26 + 我们仅接受相关标准已经被RISC-V基金会标准为“已批准”或“已冻结”的扩展或模块的补丁。
27 + (开发者当然可以维护自己的Linux内核树,其中包含所需代码扩展草案的代码。)
28 +
29 + 此外,RISC-V规范允许爱好者创建自己的自定义扩展。这些自定义拓展不需要通过RISC-V
30 + 基金会的任何审核或批准。为了避免将爱好者一些特别的RISC-V拓展添加进内核代码带来
31 + 的维护复杂性和对性能的潜在影响,我们将只接受RISC-V基金会正式冻结或批准的的扩展
32 + 补丁。(开发者当然可以维护自己的Linux内核树,其中包含他们想要的任何自定义扩展
33 + 的代码。)
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
@@ -4512,7 +4512,7 @@ AYANEO PLATFORM EC DRIVER
4512 4512 M: Antheas Kapenekakis <lkml@antheas.dev>
4513 4513 L: platform-driver-x86@vger.kernel.org
4514 4514 S: Maintained
4515 - F: Documentation/ABI/testing/sysfs-platform-ayaneo-ec
4515 + F: Documentation/ABI/testing/sysfs-platform-ayaneo
4516 4516 F: drivers/platform/x86/ayaneo-ec.c
4517 4517
4518 4518 AZ6007 DVB DRIVER
@@ -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
@@ -8573,7 +8573,7 @@ F: Documentation/devicetree/bindings/display/panel/synaptics,r63353.yaml
8573 8573 F: drivers/gpu/drm/panel/panel-synaptics-r63353.c
8574 8574
8575 8575 DRM DRIVER FOR SYNOPSYS DESIGNWARE DISPLAYPORT BRIDGE
8576 - M: Andy Yan <andyshrk@163.com>
8576 + M: Andy Yan <andy.yan@rock-chips.com>
8577 8577 S: Maintained
8578 8578 T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
8579 8579 F: Documentation/devicetree/bindings/display/rockchip/rockchip,dw-dp.yaml
@@ -8926,7 +8926,7 @@ F: include/linux/platform_data/shmob_drm.h
8926 8926 DRM DRIVERS FOR ROCKCHIP
8927 8927 M: Sandy Huang <hjc@rock-chips.com>
8928 8928 M: Heiko Stübner <heiko@sntech.de>
8929 - M: Andy Yan <andyshrk@163.com>
8929 + M: Andy Yan <andy.yan@rock-chips.com>
8930 8930 L: dri-devel@lists.freedesktop.org
8931 8931 L: linux-rockchip@lists.infradead.org
8932 8932 S: Maintained
@@ -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
@@ -12880,7 +12884,7 @@ S: Maintained
12880 12884 F: drivers/power/supply/ip5xxx_power.c
12881 12885
12882 12886 INNOSILICON HDMI BRIDGE DRIVER
12883 - M: Andy Yan <andyshrk@163.com>
12887 + M: Andy Yan <andy.yan@rock-chips.com>
12884 12888 L: dri-devel@lists.freedesktop.org
12885 12889 S: Maintained
12886 12890 T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
@@ -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>
@@ -15020,8 +15027,6 @@ M: Madhavan Srinivasan <maddy@linux.ibm.com>
15020 15027 R: Michael Ellerman <mpe@ellerman.id.au>
15021 15028 R: Nicholas Piggin <npiggin@gmail.com>
15022 15029 R: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
15023 - R: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
15024 - R: Shrikanth Hegde <sshegde@linux.ibm.com>
15025 15030 L: linuxppc-dev@lists.ozlabs.org
15026 15031 S: Supported
15027 15032 W: https://github.com/linuxppc/wiki/wiki
@@ -17411,6 +17416,7 @@ F: mm/swapfile.c
17411 17416 MEMORY MANAGEMENT - THP (TRANSPARENT HUGE PAGE)
17412 17417 M: Andrew Morton <akpm@linux-foundation.org>
17413 17418 M: David Hildenbrand <david@kernel.org>
17419 + M: Lorenzo Stoakes <ljs@kernel.org>
17414 17420 R: Zi Yan <ziy@nvidia.com>
17415 17421 R: Baolin Wang <baolin.wang@linux.alibaba.com>
17416 17422 R: Liam R. Howlett <liam@infradead.org>
@@ -17420,7 +17426,6 @@ R: Dev Jain <dev.jain@arm.com>
17420 17426 R: Barry Song <baohua@kernel.org>
17421 17427 R: Lance Yang <lance.yang@linux.dev>
17422 17428 R: Usama Arif <usama.arif@linux.dev>
17423 - R: Kiryl Shutsemau <kas@kernel.org>
17424 17429 L: linux-mm@kvack.org
17425 17430 S: Maintained
17426 17431 W: http://www.linux-mm.org
@@ -17693,7 +17698,7 @@ F: Documentation/devicetree/bindings/serial/atmel,at91-usart.yaml
17693 17698 F: drivers/spi/spi-at91-usart.c
17694 17699
17695 17700 MICROCHIP ATSHA204A DRIVER
17696 - M: Thorsten Blum <blum@kernel.org>
17701 + M: Thorsten Blum <thorsten.blum@linux.dev>
17697 17702 L: linux-crypto@vger.kernel.org
17698 17703 S: Maintained
17699 17704 F: drivers/crypto/atmel-sha204a.c
@@ -17717,7 +17722,7 @@ F: Documentation/devicetree/bindings/media/microchip,csi2dc.yaml
17717 17722 F: drivers/media/platform/microchip/microchip-csi2dc.c
17718 17723
17719 17724 MICROCHIP ECC DRIVER
17720 - M: Thorsten Blum <blum@kernel.org>
17725 + M: Thorsten Blum <thorsten.blum@linux.dev>
17721 17726 L: linux-crypto@vger.kernel.org
17722 17727 S: Maintained
17723 17728 F: drivers/crypto/atmel-ecc.c
@@ -19564,7 +19569,7 @@ F: include/linux/platform_data/x86/nvidia-wmi-ec-backlight.h
19564 19569
19565 19570 NVM EXPRESS DRIVER
19566 19571 M: Keith Busch <kbusch@kernel.org>
19567 - M: Jens Axboe <axboe@kernel.dk>
19572 + M: Jens Axboe <axboe@fb.com>
19568 19573 M: Christoph Hellwig <hch@lst.de>
19569 19574 M: Sagi Grimberg <sagi@grimberg.me>
19570 19575 L: linux-nvme@lists.infradead.org
@@ -24773,7 +24778,7 @@ K: \bsecurity_[a-z_0-9]\+\b
24773 24778 SELINUX SECURITY MODULE
24774 24779 M: Paul Moore <paul@paul-moore.com>
24775 24780 M: Stephen Smalley <stephen.smalley.work@gmail.com>
24776 - R: Ondrej Mosnáček <omosnacek@gmail.com>
24781 + R: Ondrej Mosnacek <omosnace@redhat.com>
24777 24782 L: selinux@vger.kernel.org
24778 24783 S: Supported
24779 24784 W: https://github.com/SELinuxProject
@@ -25231,9 +25236,10 @@ F: Documentation/admin-guide/LSM/Smack.rst
25231 25236 F: security/smack/
25232 25237
25233 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>
25234 25241 M: Namjae Jeon <linkinjeon@kernel.org>
25235 25242 M: Namjae Jeon <linkinjeon@samba.org>
25236 - M: Paulo Alcantara <pc@manguebit.org>
25237 25243 R: Stefan Metzmacher <metze@samba.org>
25238 25244 R: Tom Talpey <tom@talpey.com>
25239 25245 L: linux-cifs@vger.kernel.org
@@ -25336,8 +25342,8 @@ F: Documentation/networking/timestamping.rst
25336 25342 F: include/linux/net_tstamp.h
25337 25343 F: include/uapi/linux/net_tstamp.h
25338 25344 F: tools/testing/selftests/bpf/*/net_timestamping*
25339 - F: tools/testing/selftests/drivers/net/so_txtime.*
25340 25345 F: tools/testing/selftests/net/*timestamp*
25346 + F: tools/testing/selftests/net/so_txtime.c
25341 25347
25342 25348 SOEKRIS NET48XX LED SUPPORT
25343 25349 M: Chris Boot <bootc@bootc.net>
@@ -25404,7 +25410,7 @@ F: drivers/md/md*
25404 25410 F: drivers/md/raid*
25405 25411 F: include/linux/raid/
25406 25412 F: include/uapi/linux/raid/
25407 - F: lib/raid/
25413 + F: lib/raid/raid6/
25408 25414
25409 25415 SOLIDRUN CLEARFOG SUPPORT
25410 25416 M: Russell King <linux@armlinux.org.uk>
@@ -26948,7 +26954,8 @@ S: Maintained
26948 26954 F: drivers/net/ethernet/tehuti/tn40*
26949 26955
26950 26956 TELECOM CLOCK DRIVER FOR MCPL0010
26951 - S: Orphan
26957 + M: Mark Gross <markgross@kernel.org>
26958 + S: Supported
26952 26959 F: drivers/char/tlclk.c
26953 26960
26954 26961 TEMPO SEMICONDUCTOR DRIVERS
@@ -28609,6 +28616,7 @@ L: iommu@lists.linux.dev
28609 28616 S: Maintained
28610 28617 F: Documentation/devicetree/bindings/iommu/verisilicon,iommu.yaml
28611 28618 F: drivers/iommu/vsi-iommu.c
28619 + F: include/linux/vsi-iommu.h
28612 28620
28613 28621 VF610 NAND DRIVER
28614 28622 M: Stefan Agner <stefan@agner.ch>
@@ -28868,8 +28876,8 @@ F: include/uapi/linux/virtio_console.h
28868 28876 VIRTIO CORE
28869 28877 M: "Michael S. Tsirkin" <mst@redhat.com>
28870 28878 M: Jason Wang <jasowangio@gmail.com>
28871 - M: Eugenio Pérez <eperezma@redhat.com>
28872 28879 R: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
28880 + R: Eugenio Pérez <eperezma@redhat.com>
28873 28881 L: virtualization@lists.linux.dev
28874 28882 S: Maintained
28875 28883 F: Documentation/ABI/testing/sysfs-bus-vdpa
@@ -28946,7 +28954,7 @@ F: include/uapi/linux/virtio_gpu.h
28946 28954 VIRTIO HOST (VHOST)
28947 28955 M: "Michael S. Tsirkin" <mst@redhat.com>
28948 28956 M: Jason Wang <jasowangio@gmail.com>
28949 - M: Eugenio Pérez <eperezma@redhat.com>
28957 + R: Eugenio Pérez <eperezma@redhat.com>
28950 28958 L: kvm@vger.kernel.org
28951 28959 L: virtualization@lists.linux.dev
28952 28960 L: netdev@vger.kernel.org
@@ -29001,8 +29009,8 @@ F: include/uapi/linux/virtio_mem.h
29001 29009 VIRTIO NET DRIVER
29002 29010 M: "Michael S. Tsirkin" <mst@redhat.com>
29003 29011 M: Jason Wang <jasowangio@gmail.com>
29004 - M: Eugenio Pérez <eperezma@redhat.com>
29005 29012 R: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
29013 + R: Eugenio Pérez <eperezma@redhat.com>
29006 29014 L: netdev@vger.kernel.org
29007 29015 L: virtualization@lists.linux.dev
29008 29016 S: Maintained
@@ -29018,13 +29026,6 @@ S: Maintained
29018 29026 F: drivers/nvdimm/nd_virtio.c
29019 29027 F: drivers/nvdimm/virtio_pmem.c
29020 29028
29021 - VIRTIO RNG DRIVER
29022 - M: Laurent Vivier <lvivier@redhat.com>
29023 - L: virtualization@lists.linux.dev
29024 - S: Maintained
29025 - F: drivers/char/hw_random/virtio-rng.c
29026 - F: include/uapi/linux/virtio_rng.h
29027 -
29028 29029 VIRTIO RTC DRIVER
29029 29030 M: Peter Hilber <peter.hilber@oss.qualcomm.com>
29030 29031 L: virtualization@lists.linux.dev
@@ -29356,7 +29357,7 @@ M: Guenter Roeck <linux@roeck-us.net>
29356 29357 L: linux-watchdog@vger.kernel.org
29357 29358 S: Maintained
29358 29359 W: http://www.linux-watchdog.org/
29359 - T: git git://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git
29360 + T: git git://www.linux-watchdog.org/linux-watchdog.git
29360 29361 F: Documentation/devicetree/bindings/watchdog/
29361 29362 F: Documentation/watchdog/
29362 29363 F: drivers/watchdog/
@@ -29936,14 +29937,12 @@ F: include/uapi/linux/xilinx-v4l2-controls.h
29936 29937 XILINX VERSAL EDAC DRIVER
29937 29938 M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
29938 29939 M: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
29939 - R: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
29940 29940 S: Maintained
29941 29941 F: Documentation/devicetree/bindings/memory-controllers/xlnx,versal-ddrmc-edac.yaml
29942 29942 F: drivers/edac/versal_edac.c
29943 29943
29944 29944 XILINX VERSALNET EDAC DRIVER
29945 29945 M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
29946 - R: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
29947 29946 S: Maintained
29948 29947 F: Documentation/devicetree/bindings/memory-controllers/xlnx,versal-net-ddrmc5.yaml
29949 29948 F: drivers/edac/versalnet_edac.c
@@ -29989,7 +29988,6 @@ F: include/dt-bindings/dma/xlnx-zynqmp-dpdma.h
29989 29988 XILINX ZYNQMP OCM EDAC DRIVER
29990 29989 M: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
29991 29990 M: Sai Krishna Potthuri <sai.krishna.potthuri@amd.com>
29992 - R: Radhey Shyam Pandey <radhey.shyam.pandey@amd.com>
29993 29991 S: Maintained
29994 29992 F: Documentation/devicetree/bindings/memory-controllers/xlnx,zynqmp-ocmc-1.0.yaml
29995 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 = -rc3
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/arm64/tools/sysreg
@@ -3761,9 +3761,7 @@ Sysreg ICC_CR0_EL1 3 1 12 0 1
3761 3761 Res0 63:39
3762 3762 Field 38 PID
3763 3763 Field 37:32 IPPT
3764 - Res0 31:3
3765 - Field 2 LINK_IDLE
3766 - Field 1 LINK
3764 + Res0 31:1
3767 3765 Field 0 EN
3768 3766 EndSysreg
3769 3767
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/include/asm/entry-common.h
@@ -222,6 +222,8 @@ static inline void arch_interrupt_enter_prepare(struct pt_regs *regs)
222 222
223 223 if (user_mode(regs)) {
224 224 kuap_lock();
225 + account_cpu_user_entry();
226 + account_stolen_time();
225 227 } else {
226 228 kuap_save_and_lock(regs);
227 229 /*
@@ -268,7 +270,7 @@ static inline void arch_interrupt_exit_prepare(struct pt_regs *regs)
268 270 }
269 271
270 272 /* irqentry_exit expects to be called with interrupts disabled */
271 - hard_irq_disable();
273 + local_irq_disable();
272 274 }
273 275
274 276 static inline void arch_interrupt_async_enter_prepare(struct pt_regs *regs)
@@ -513,14 +515,8 @@ static inline void arch_exit_to_user_mode_prepare(struct pt_regs *regs,
513 515 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
514 516 local_paca->tm_scratch = regs->msr;
515 517 #endif
516 - /*
517 - * Do not restore KUAP here. Generic entry might treat this as the last
518 - * arch step before userspace but PowerPC still has kernel work after
519 - * irqentry_exit()/syscall_exit_to_user_mode() i.e. in
520 - * interrupt_exit_user_prepare() / syscall_exit_prepare() may enable
521 - * IRQs and retry. Those functions restore KUAP immediately before rfi,
522 - * which is where it should belong.
523 - */
518 + /* Restore user access locks last */
519 + kuap_user_restore(regs);
524 520 }
525 521
526 522 #define arch_exit_to_user_mode_prepare arch_exit_to_user_mode_prepare
modified arch/powerpc/kernel/eeh_driver.c
@@ -533,7 +533,9 @@ static void eeh_rmv_device(struct eeh_dev *edev, void *userdata)
533 533 if (rmv_data)
534 534 list_add(&edev->rmv_entry, &rmv_data->removed_vf_list);
535 535 } else {
536 + pci_lock_rescan_remove();
536 537 pci_stop_and_remove_bus_device(dev);
538 + pci_unlock_rescan_remove();
537 539 }
538 540 }
539 541
modified arch/powerpc/kernel/interrupt.c
@@ -175,7 +175,7 @@ again:
175 175 current_thread_info()->exit_flags &= ~_TIF_RESTOREALL;
176 176 regs->exit_result |= ret;
177 177
178 - return regs->exit_result;
178 + return ret;
179 179 }
180 180 #endif
181 181
modified arch/powerpc/kernel/prom.c
@@ -824,6 +824,7 @@ void __init early_init_devtree(void *params)
824 824 fadump_append_bootargs();
825 825
826 826 /* Scan memory nodes and rebuild MEMBLOCKs */
827 + early_init_dt_scan_root();
827 828 early_init_dt_scan_memory_ppc();
828 829
829 830 /*
modified arch/powerpc/kernel/rtas_pci.c
@@ -54,10 +54,6 @@ int rtas_pci_dn_read_config(struct pci_dn *pdn, int where, int size, u32 *val)
54 54 if (!config_access_valid(pdn, where))
55 55 return PCIBIOS_BAD_REGISTER_NUMBER;
56 56 #ifdef CONFIG_EEH
57 - if (pdn->edev &&
58 - (pdn->edev->mode & EEH_DEV_REMOVED))
59 - return PCIBIOS_DEVICE_NOT_FOUND;
60 -
61 57 if (pdn->edev && pdn->edev->pe &&
62 58 (pdn->edev->pe->state & EEH_PE_CFG_BLOCKED))
63 59 return PCIBIOS_SET_FAILED;
@@ -109,10 +105,6 @@ int rtas_pci_dn_write_config(struct pci_dn *pdn, int where, int size, u32 val)
109 105 if (!config_access_valid(pdn, where))
110 106 return PCIBIOS_BAD_REGISTER_NUMBER;
111 107 #ifdef CONFIG_EEH
112 - if (pdn->edev &&
113 - (pdn->edev->mode & EEH_DEV_REMOVED))
114 - return PCIBIOS_DEVICE_NOT_FOUND;
115 -
116 108 if (pdn->edev && pdn->edev->pe &&
117 109 (pdn->edev->pe->state & EEH_PE_CFG_BLOCKED))
118 110 return PCIBIOS_SET_FAILED;
modified arch/powerpc/kernel/syscall.c
@@ -18,10 +18,8 @@ notrace long system_call_exception(struct pt_regs *regs, unsigned long r0)
18 18 long ret;
19 19 syscall_fn f;
20 20
21 - if (unlikely(!syscall_enter_from_user_mode_randomize_stack(regs, &r0))) {
22 - clear_thread_flag(TIF_SYSCALL_RET);
21 + if (unlikely(!syscall_enter_from_user_mode_randomize_stack(regs, &r0)))
23 22 return syscall_get_error(current, regs);
24 - }
25 23
26 24 if (unlikely(test_and_clear_thread_flag(TIF_SYSCALL_RET)))
27 25 return syscall_get_error(current, regs);
modified arch/powerpc/kexec/elf_64.c
@@ -94,8 +94,6 @@ static void *elf64_load(struct kimage *image, char *kernel_buf,
94 94 cmdline = modified_cmdline;
95 95 }
96 96
97 - kexec_dprintk("Command line: %s", cmdline ? cmdline : "");
98 -
99 97 if (initrd != NULL) {
100 98 kbuf.buffer = initrd;
101 99 kbuf.bufsz = kbuf.memsz = initrd_len;
modified arch/powerpc/kexec/file_load_64.c
@@ -57,7 +57,7 @@ int arch_check_excluded_range(struct kimage *image, unsigned long start,
57 57
58 58 emem = image->arch.exclude_ranges;
59 59 for (i = 0; i < emem->nr_ranges; i++)
60 - if (start <= emem->ranges[i].end && end >= emem->ranges[i].start)
60 + if (start < emem->ranges[i].end && end > emem->ranges[i].start)
61 61 return 1;
62 62
63 63 return 0;
@@ -113,7 +113,7 @@ static int add_usable_mem(struct umem_info *um_info, u64 base, u64 end)
113 113 loc_end = um_info->ranges[i].end;
114 114 if (loc_base >= base && loc_end <= end)
115 115 add = true;
116 - else if (base <= loc_end && end >= loc_base) {
116 + else if (base < loc_end && end > loc_base) {
117 117 if (loc_base < base)
118 118 loc_base = base;
119 119 if (loc_end > end)
@@ -377,12 +377,16 @@ static int load_backup_segment(struct kimage *image, struct kexec_buf *kbuf)
377 377 static unsigned int kdump_extra_elfcorehdr_size(struct crash_mem *cmem)
378 378 {
379 379 #if defined(CONFIG_CRASH_HOTPLUG) && defined(CONFIG_MEMORY_HOTPLUG)
380 + unsigned int extra_sz = 0;
381 +
380 382 if (CONFIG_CRASH_MAX_MEMORY_RANGES > (unsigned int)PN_XNUM)
381 383 pr_warn("Number of Phdrs %u exceeds max\n", CONFIG_CRASH_MAX_MEMORY_RANGES);
382 384 else if (cmem->nr_ranges >= CONFIG_CRASH_MAX_MEMORY_RANGES)
383 385 pr_warn("Configured crash mem ranges may not be enough\n");
384 386 else
385 - return (CONFIG_CRASH_MAX_MEMORY_RANGES - cmem->nr_ranges) * sizeof(Elf64_Phdr);
387 + extra_sz = (CONFIG_CRASH_MAX_MEMORY_RANGES - cmem->nr_ranges) * sizeof(Elf64_Phdr);
388 +
389 + return extra_sz;
386 390 #endif
387 391 return 0;
388 392 }
modified arch/powerpc/kvm/book3s_hv.c
@@ -6140,12 +6140,12 @@ static int kvmppc_irq_bypass_add_producer_hv(struct irq_bypass_consumer *cons,
6140 6140 struct kvm_kernel_irqfd *irqfd =
6141 6141 container_of(cons, struct kvm_kernel_irqfd, consumer);
6142 6142
6143 + irqfd->producer = prod;
6144 +
6143 6145 ret = kvmppc_set_passthru_irq(irqfd->kvm, prod->irq, irqfd->gsi);
6144 6146 if (ret)
6145 6147 pr_info("kvmppc_set_passthru_irq (irq %d, gsi %d) fails: %d\n",
6146 6148 prod->irq, irqfd->gsi, ret);
6147 - else
6148 - irqfd->producer = prod;
6149 6149
6150 6150 return ret;
6151 6151 }
modified arch/powerpc/platforms/pasemi/setup.c
@@ -165,8 +165,6 @@ static int __init pas_setup_mce_regs(void)
165 165 while (dev && reg < MAX_MCE_REGS) {
166 166 mce_regs[reg].name = kasprintf(GFP_KERNEL,
167 167 "mc%d_mcdebug_errsta", reg);
168 - if (!mce_regs[reg].name)
169 - return -ENOMEM;
170 168 mce_regs[reg].addr = pasemi_pci_getcfgaddr(dev, 0x730);
171 169 dev = pci_get_device(PCI_VENDOR_ID_PASEMI, 0xa00a, dev);
172 170 reg++;
modified arch/powerpc/platforms/powernv/pci-ioda.c
@@ -1623,13 +1623,15 @@ int64_t pnv_opal_pci_msi_eoi(struct irq_data *d)
1623 1623 return opal_pci_msi_eoi(phb->opal_id, d->parent_data->hwirq);
1624 1624 }
1625 1625
1626 + static struct irq_chip pnv_pci_msi_irq_chip;
1627 +
1626 1628 /*
1627 1629 * Returns true iff chip is something that we could call
1628 1630 * pnv_opal_pci_msi_eoi for.
1629 1631 */
1630 1632 bool is_pnv_opal_msi(struct irq_chip *chip)
1631 1633 {
1632 - return chip && chip->name && str_has_prefix(chip->name, "PNV-");
1634 + return chip == &pnv_pci_msi_irq_chip;
1633 1635 }
1634 1636 EXPORT_SYMBOL_GPL(is_pnv_opal_msi);
1635 1637
@@ -1726,7 +1728,7 @@ static const struct msi_parent_ops pnv_msi_parent_ops = {
1726 1728 .chip_flags = MSI_CHIP_FLAG_SET_EOI,
1727 1729 .bus_select_token = DOMAIN_BUS_NEXUS,
1728 1730 .bus_select_mask = MATCH_PCI_MSI,
1729 - .prefix = "PNV-", /* Note: is_pnv_opal_msi() uses this */
1731 + .prefix = "PNV-",
1730 1732 .init_dev_msi_info = pnv_init_dev_msi_info,
1731 1733 };
1732 1734
modified arch/powerpc/platforms/ps3/repository.c
@@ -6,8 +6,6 @@
6 6 * Copyright 2006 Sony Corp.
7 7 */
8 8
9 - #include <linux/minmax.h>
10 -
11 9 #include <asm/lv1call.h>
12 10
13 11 #include "platform.h"
@@ -76,9 +74,8 @@ static void _dump_node(unsigned int lpar_id, u64 n1, u64 n2, u64 n3, u64 n4,
76 74 static u64 make_first_field(const char *text, u64 index)
77 75 {
78 76 u64 n = 0;
79 - size_t len = min(strlen(text), sizeof(n));
80 77
81 - memcpy(&n, text, len);
78 + memcpy((char *)&n, text, strnlen(text, sizeof(n)));
82 79 return PS3_VENDOR_ID_NONE + (n >> 32) + index;
83 80 }
84 81
modified arch/powerpc/platforms/pseries/htmdump.c
@@ -527,28 +527,28 @@ static int htmdump_init_debugfs(void)
527 527 htm_status_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
528 528 if (!htm_status_buf) {
529 529 pr_err("Failed to allocate htmstatus buf\n");
530 - goto htm_status_buf_err;
530 + return -ENOMEM;
531 531 }
532 532
533 533 /* Debugfs interface file to present System Processor Configuration */
534 534 htm_info_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
535 535 if (!htm_info_buf) {
536 536 pr_err("Failed to allocate htm info buf\n");
537 - goto htm_info_buf_err;
537 + return -ENOMEM;
538 538 }
539 539
540 540 /* Debugfs interface file to present HTM capabilities */
541 541 htm_caps_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
542 542 if (!htm_caps_buf) {
543 543 pr_err("Failed to allocate htm caps buf\n");
544 - goto htm_caps_buf_err;
544 + return -ENOMEM;
545 545 }
546 546
547 547 /* Memory to present HTM system memory configuration */
548 548 htm_mem_buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
549 549 if (!htm_mem_buf) {
550 550 pr_err("Failed to allocate htm mem buf\n");
551 - goto htm_mem_buf_err;
551 + return -ENOMEM;
552 552 }
553 553
554 554 debugfs_create_file("htmstatus", 0400, htmdump_debugfs_dir, htm_status_buf, &htmstatus_fops);
@@ -557,17 +557,6 @@ static int htmdump_init_debugfs(void)
557 557 debugfs_create_file("htmsystem_mem", 0400, htmdump_debugfs_dir, htm_mem_buf, &htmsystem_mem_fops);
558 558
559 559 return 0;
560 -
561 - htm_mem_buf_err:
562 - kfree(htm_caps_buf);
563 - htm_caps_buf_err:
564 - kfree(htm_info_buf);
565 - htm_info_buf_err:
566 - kfree(htm_status_buf);
567 - htm_status_buf_err:
568 - debugfs_remove_recursive(htmdump_debugfs_dir);
569 - kfree(htm_buf);
570 - return -ENOMEM;
571 560 }
572 561
573 562 static int __init htmdump_init(void)
modified arch/powerpc/platforms/pseries/pci.c
@@ -132,14 +132,11 @@ static int pseries_pci_sriov_enable(struct pci_dev *pdev, u16 num_vfs)
132 132
133 133 /* First integer stores max config */
134 134 max_config_vfs = of_read_number(&max_vfs[0], 1);
135 - if (max_config_vfs < num_vfs) {
136 - dev_err(&pdev->dev, "Num VFs %x > %x Configurable VFs\n",
137 - num_vfs, max_config_vfs);
138 - return -EINVAL;
139 - }
140 - if (num_vfs > MAX_VFS_FOR_MAP_PE) {
141 - dev_err(&pdev->dev, "Num VFs %x > %x PE mapping limit\n",
142 - num_vfs, MAX_VFS_FOR_MAP_PE);
135 + if (max_config_vfs < num_vfs || num_vfs > MAX_VFS_FOR_MAP_PE) {
136 + dev_err(&pdev->dev,
137 + "Num VFs %x > %x Configurable VFs\n",
138 + num_vfs, (num_vfs > MAX_VFS_FOR_MAP_PE) ?
139 + MAX_VFS_FOR_MAP_PE : max_config_vfs);
143 140 return -EINVAL;
144 141 }
145 142
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/Kconfig
@@ -326,7 +326,7 @@ config STACKTRACE_SUPPORT
326 326 config GENERIC_BUG
327 327 def_bool y
328 328 depends on BUG
329 - select GENERIC_BUG_RELATIVE_POINTERS
329 + select GENERIC_BUG_RELATIVE_POINTERS if 64BIT
330 330
331 331 config GENERIC_BUG_RELATIVE_POINTERS
332 332 bool
modified arch/riscv/include/asm/bug.h
@@ -29,8 +29,13 @@
29 29
30 30 typedef u32 bug_insn_t;
31 31
32 + #ifdef CONFIG_GENERIC_BUG_RELATIVE_POINTERS
32 33 #define __BUG_ENTRY_ADDR RISCV_INT " 1b - ."
33 34 #define __BUG_ENTRY_FILE(file) RISCV_INT " " file " - ."
35 + #else
36 + #define __BUG_ENTRY_ADDR RISCV_PTR " 1b"
37 + #define __BUG_ENTRY_FILE(file) RISCV_PTR " " file
38 + #endif
34 39
35 40 #ifdef CONFIG_DEBUG_BUGVERBOSE
36 41 #define __BUG_ENTRY(file, line, flags) \
modified arch/riscv/include/asm/switch_to.h
@@ -61,8 +61,8 @@ static inline void __switch_to_fpu(struct task_struct *prev,
61 61
62 62 static __always_inline bool has_fpu(void)
63 63 {
64 - /* D extension depends on F, so checking D alone is sufficient. */
65 - return riscv_has_extension_likely(RISCV_ISA_EXT_D);
64 + return riscv_has_extension_likely(RISCV_ISA_EXT_F) ||
65 + riscv_has_extension_likely(RISCV_ISA_EXT_D);
66 66 }
67 67 #else
68 68 static __always_inline bool has_fpu(void) { return false; }
modified arch/riscv/kernel/cpufeature.c
@@ -412,19 +412,6 @@ static const unsigned int riscv_zvbb_exts[] = {
412 412 RISCV_ISA_EXT_ZVKB
413 413 };
414 414
415 - /*
416 - * The RISC-V ISA manual specifies that Zfh implies Zfhmin and Zvfh implies
417 - * Zvfhmin. Report the implied subset extensions whenever the supersets are
418 - * detected (see https://github.com/riscv/riscv-isa-manual/pull/3070).
419 - */
420 - static const unsigned int riscv_zfh_exts[] = {
421 - RISCV_ISA_EXT_ZFHMIN
422 - };
423 -
424 - static const unsigned int riscv_zvfh_exts[] = {
425 - RISCV_ISA_EXT_ZVFHMIN
426 - };
427 -
428 415 #define RISCV_ISA_EXT_ZVE64F_IMPLY_LIST \
429 416 RISCV_ISA_EXT_ZVE64X, \
430 417 RISCV_ISA_EXT_ZVE32F, \
@@ -563,8 +550,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
563 550 __RISCV_ISA_EXT_DATA(zawrs, RISCV_ISA_EXT_ZAWRS),
564 551 __RISCV_ISA_EXT_DATA_VALIDATE(zfa, RISCV_ISA_EXT_ZFA, riscv_ext_f_depends),
565 552 __RISCV_ISA_EXT_DATA_VALIDATE(zfbfmin, RISCV_ISA_EXT_ZFBFMIN, riscv_ext_f_depends),
566 - __RISCV_ISA_EXT_SUPERSET_VALIDATE(zfh, RISCV_ISA_EXT_ZFH,
567 - riscv_zfh_exts, riscv_ext_f_depends),
553 + __RISCV_ISA_EXT_DATA_VALIDATE(zfh, RISCV_ISA_EXT_ZFH, riscv_ext_f_depends),
568 554 __RISCV_ISA_EXT_DATA_VALIDATE(zfhmin, RISCV_ISA_EXT_ZFHMIN, riscv_ext_f_depends),
569 555 __RISCV_ISA_EXT_DATA(zca, RISCV_ISA_EXT_ZCA),
570 556 __RISCV_ISA_EXT_DATA_VALIDATE(zcb, RISCV_ISA_EXT_ZCB, riscv_ext_zca_depends),
@@ -600,9 +586,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
600 586 __RISCV_ISA_EXT_SUPERSET_VALIDATE(zve64x, RISCV_ISA_EXT_ZVE64X, riscv_zve64x_exts, riscv_ext_vector_x_validate),
601 587 __RISCV_ISA_EXT_DATA_VALIDATE(zvfbfmin, RISCV_ISA_EXT_ZVFBFMIN, riscv_vector_f_validate),
602 588 __RISCV_ISA_EXT_DATA_VALIDATE(zvfbfwma, RISCV_ISA_EXT_ZVFBFWMA, riscv_ext_zvfbfwma_validate),
603 - __RISCV_ISA_EXT_SUPERSET_VALIDATE(zvfh, RISCV_ISA_EXT_ZVFH,
604 - riscv_zvfh_exts,
605 - riscv_ext_vector_float_validate),
589 + __RISCV_ISA_EXT_DATA(zvfh, RISCV_ISA_EXT_ZVFH),
606 590 __RISCV_ISA_EXT_DATA(zvfhmin, RISCV_ISA_EXT_ZVFHMIN),
607 591 __RISCV_ISA_EXT_DATA_VALIDATE(zvkb, RISCV_ISA_EXT_ZVKB, riscv_ext_vector_crypto_validate),
608 592 __RISCV_ISA_EXT_DATA_VALIDATE(zvkg, RISCV_ISA_EXT_ZVKG, riscv_ext_vector_crypto_validate),
modified arch/riscv/kernel/patch.c
@@ -45,8 +45,6 @@ static __always_inline void *patch_map(void *addr, const unsigned int fixmap)
45 45 phys_addr_t phys;
46 46
47 47 if (core_kernel_text(uintaddr) || is_kernel_exittext(uintaddr)) {
48 - if (!IS_ENABLED(CONFIG_STRICT_KERNEL_RWX))
49 - return addr;
50 48 phys = __pa_symbol(addr);
51 49 } else if (IS_ENABLED(CONFIG_STRICT_MODULE_RWX)) {
52 50 struct page *page = vmalloc_to_page(addr);
modified arch/riscv/kernel/process.c
@@ -349,8 +349,10 @@ long set_tagged_addr_ctrl(struct task_struct *task, unsigned long arg)
349 349 if (arg & PR_TAGGED_ADDR_ENABLE && (tagged_addr_disabled || !pmlen))
350 350 return -EINVAL;
351 351
352 - if (!(arg & PR_TAGGED_ADDR_ENABLE))
352 + if (!(arg & PR_TAGGED_ADDR_ENABLE)) {
353 353 pmlen = PMLEN_0;
354 + pmm = ENVCFG_PMM_PMLEN_0;
355 + }
354 356
355 357 if (mmap_write_lock_killable(mm))
356 358 return -EINTR;
modified arch/riscv/kernel/sys_hwprobe.c
@@ -297,8 +297,6 @@ static u64 hwprobe_vec_misaligned(const struct cpumask *cpus)
297 297 static void hwprobe_one_pair(struct riscv_hwprobe *pair,
298 298 const struct cpumask *cpus)
299 299 {
300 - pair->value = 0;
301 -
302 300 switch (pair->key) {
303 301 case RISCV_HWPROBE_KEY_MVENDORID:
304 302 case RISCV_HWPROBE_KEY_MARCHID:
@@ -333,14 +331,17 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair,
333 331 break;
334 332
335 333 case RISCV_HWPROBE_KEY_ZICBOZ_BLOCK_SIZE:
334 + pair->value = 0;
336 335 if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOZ))
337 336 pair->value = riscv_cboz_block_size;
338 337 break;
339 338 case RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE:
339 + pair->value = 0;
340 340 if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOM))
341 341 pair->value = riscv_cbom_block_size;
342 342 break;
343 343 case RISCV_HWPROBE_KEY_ZICBOP_BLOCK_SIZE:
344 + pair->value = 0;
344 345 if (hwprobe_ext0_has(cpus, RISCV_HWPROBE_EXT_ZICBOP))
345 346 pair->value = riscv_cbop_block_size;
346 347 break;
modified arch/riscv/kernel/usercfi.c
@@ -525,8 +525,9 @@ static int __init setup_global_riscv_enable(char *str)
525 525
526 526 if (riscv_nousercfi)
527 527 pr_info("RISC-V user CFI disabled via cmdline - shadow stack status : %s, landing pad status : %s\n",
528 - str_disabled_enabled(riscv_nousercfi & CMDLINE_DISABLE_RISCV_USERCFI_BCFI),
529 - str_disabled_enabled(riscv_nousercfi & CMDLINE_DISABLE_RISCV_USERCFI_FCFI));
528 + (riscv_nousercfi & CMDLINE_DISABLE_RISCV_USERCFI_BCFI) ? "disabled" :
529 + "enabled", (riscv_nousercfi & CMDLINE_DISABLE_RISCV_USERCFI_FCFI) ?
530 + "disabled" : "enabled");
530 531
531 532 return 1;
532 533 }
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/lib/uaccess.S
@@ -76,7 +76,6 @@ SYM_FUNC_START(fallback_scalar_usercopy_sum_enabled)
76 76 li a3, 9*SZREG-1 /* size must >= (word_copy stride + SZREG-1) */
77 77 bltu a2, a3, .Lbyte_copy_tail
78 78
79 - #if !defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
80 79 /*
81 80 * Copy first bytes until dst is aligned to word boundary.
82 81 * a0 - start of dst
@@ -104,7 +103,7 @@ SYM_FUNC_START(fallback_scalar_usercopy_sum_enabled)
104 103 /* a1 - start of src */
105 104 andi a3, a1, SZREG-1
106 105 bnez a3, .Lshift_copy
107 - #endif
106 +
108 107 .Lword_copy:
109 108 /*
110 109 * Both src and dst are aligned, unrolled word copy
@@ -138,7 +137,6 @@ SYM_FUNC_START(fallback_scalar_usercopy_sum_enabled)
138 137 addi t0, t0, 8*SZREG /* revert to original value */
139 138 j .Lbyte_copy_tail
140 139
141 - #if !defined(CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS)
142 140 .Lshift_copy:
143 141
144 142 /*
@@ -191,7 +189,6 @@ SYM_FUNC_START(fallback_scalar_usercopy_sum_enabled)
191 189
192 190 /* Revert src to original unaligned value */
193 191 add a1, a1, a3
194 - #endif
195 192
196 193 .Lbyte_copy_tail:
197 194 /*
modified arch/riscv/mm/init.c
@@ -1465,9 +1465,7 @@ struct execmem_info __init *execmem_arch_setup(void)
1465 1465 [EXECMEM_KPROBES] = {
1466 1466 .start = VMALLOC_START,
1467 1467 .end = VMALLOC_END,
1468 - .pgprot = IS_ENABLED(CONFIG_STRICT_MODULE_RWX) ?
1469 - PAGE_KERNEL_READ_EXEC :
1470 - PAGE_KERNEL_EXEC,
1468 + .pgprot = PAGE_KERNEL_READ_EXEC,
1471 1469 .alignment = 1,
1472 1470 },
1473 1471 [EXECMEM_BPF] = {
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/crypto/Makefile
@@ -3,8 +3,6 @@
3 3 # Cryptographic API
4 4 #
5 5
6 - CONTEXT_ANALYSIS := y
7 -
8 6 obj-$(CONFIG_CRYPTO_AES_S390) += aes_s390.o
9 7 obj-$(CONFIG_CRYPTO_PAES_S390) += paes_s390.o
10 8 obj-$(CONFIG_S390_PRNG) += prng.o
modified arch/s390/crypto/aes_s390.c
@@ -26,14 +26,14 @@
26 26 #include <linux/module.h>
27 27 #include <linux/cpufeature.h>
28 28 #include <linux/init.h>
29 + #include <linux/mutex.h>
29 30 #include <linux/fips.h>
30 - #include <linux/semaphore.h>
31 31 #include <linux/string.h>
32 32 #include <crypto/xts.h>
33 33 #include <asm/cpacf.h>
34 34
35 35 static u8 *ctrblk;
36 - static DEFINE_SEMAPHORE(ctrblk_sem, 1);
36 + static DEFINE_MUTEX(ctrblk_lock);
37 37
38 38 static cpacf_mask_t km_functions, kmc_functions, kmctr_functions,
39 39 kma_functions;
@@ -129,7 +129,7 @@ static int ecb_aes_crypt(struct skcipher_request *req, unsigned long modifier)
129 129 return fallback_skcipher_crypt(sctx, req, modifier);
130 130
131 131 ret = skcipher_walk_virt(&walk, req, false);
132 - while (!ret && ((nbytes = walk.nbytes) != 0)) {
132 + while ((nbytes = walk.nbytes) != 0) {
133 133 /* only use complete blocks */
134 134 n = nbytes & ~(AES_BLOCK_SIZE - 1);
135 135 cpacf_km(sctx->fc | modifier, sctx->key,
@@ -233,7 +233,7 @@ static int cbc_aes_crypt(struct skcipher_request *req, unsigned long modifier)
233 233 return ret;
234 234 memcpy(param.iv, walk.iv, AES_BLOCK_SIZE);
235 235 memcpy(param.key, sctx->key, sctx->key_len);
236 - while (!ret && ((nbytes = walk.nbytes) != 0)) {
236 + while ((nbytes = walk.nbytes) != 0) {
237 237 /* only use complete blocks */
238 238 n = nbytes & ~(AES_BLOCK_SIZE - 1);
239 239 cpacf_kmc(sctx->fc | modifier, &param,
@@ -359,7 +359,7 @@ static int xts_aes_crypt(struct skcipher_request *req, unsigned long modifier)
359 359 memcpy(xts_param.key + offset, xts_ctx->key, xts_ctx->key_len);
360 360 memcpy(xts_param.init, pcc_param.xts, 16);
361 361
362 - while (!ret && ((nbytes = walk.nbytes) != 0)) {
362 + while ((nbytes = walk.nbytes) != 0) {
363 363 /* only use complete blocks */
364 364 n = nbytes & ~(AES_BLOCK_SIZE - 1);
365 365 cpacf_km(xts_ctx->fc | modifier, xts_param.key + offset,
@@ -487,7 +487,7 @@ static int fullxts_aes_crypt(struct skcipher_request *req, unsigned long modifi
487 487 memcpy(fxts_param.tweak, req->iv, AES_BLOCK_SIZE);
488 488 fxts_param.nap[0] = 0x01; /* initial alpha power (1, little-endian) */
489 489
490 - while (!ret && ((nbytes = walk.nbytes) != 0)) {
490 + while ((nbytes = walk.nbytes) != 0) {
491 491 /* only use complete blocks */
492 492 n = nbytes & ~(AES_BLOCK_SIZE - 1);
493 493 cpacf_km(xts_ctx->fc | modifier, fxts_param.key + offset,
@@ -562,64 +562,48 @@ static unsigned int __ctrblk_init(u8 *ctrptr, u8 *iv, unsigned int nbytes)
562 562 return n;
563 563 }
564 564
565 - static int __ctr_aes_crypt(struct s390_aes_ctx *sctx,
566 - struct skcipher_walk *walk, bool locked)
567 - {
568 - unsigned int n, nbytes;
569 - int ret = 0;
570 - u8 *ctrptr;
571 -
572 - while (!ret && ((nbytes = walk->nbytes) >= AES_BLOCK_SIZE)) {
573 - n = AES_BLOCK_SIZE;
574 - if (nbytes >= 2 * AES_BLOCK_SIZE && locked)
575 - n = __ctrblk_init(ctrblk, walk->iv, nbytes);
576 - ctrptr = (n > AES_BLOCK_SIZE) ? ctrblk : walk->iv;
577 - cpacf_kmctr(sctx->fc, sctx->key, walk->dst.virt.addr,
578 - walk->src.virt.addr, n, ctrptr);
579 - if (ctrptr == ctrblk)
580 - memcpy(walk->iv, ctrptr + n - AES_BLOCK_SIZE,
581 - AES_BLOCK_SIZE);
582 - crypto_inc(walk->iv, AES_BLOCK_SIZE);
583 - ret = skcipher_walk_done(walk, nbytes - n);
584 - }
585 -
586 - return ret;
587 - }
588 -
589 565 static int ctr_aes_crypt(struct skcipher_request *req)
590 566 {
591 567 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
592 568 struct s390_aes_ctx *sctx = crypto_skcipher_ctx(tfm);
569 + u8 buf[AES_BLOCK_SIZE], *ctrptr;
593 570 struct skcipher_walk walk;
594 - u8 buf[AES_BLOCK_SIZE];
595 - int ret;
571 + unsigned int n, nbytes;
572 + int ret, locked;
596 573
597 574 if (unlikely(!sctx->fc))
598 575 return fallback_skcipher_crypt(sctx, req, 0);
599 576
577 + locked = mutex_trylock(&ctrblk_lock);
578 +
600 579 ret = skcipher_walk_virt(&walk, req, false);
601 - if (ret)
602 - return ret;
580 + while ((nbytes = walk.nbytes) >= AES_BLOCK_SIZE) {
581 + n = AES_BLOCK_SIZE;
603 582
604 - if (down_trylock(&ctrblk_sem) == 0) {
605 - ret = __ctr_aes_crypt(sctx, &walk, true);
606 - up(&ctrblk_sem);
607 - } else {
608 - ret = __ctr_aes_crypt(sctx, &walk, false);
583 + if (nbytes >= 2*AES_BLOCK_SIZE && locked)
584 + n = __ctrblk_init(ctrblk, walk.iv, nbytes);
585 + ctrptr = (n > AES_BLOCK_SIZE) ? ctrblk : walk.iv;
586 + cpacf_kmctr(sctx->fc, sctx->key, walk.dst.virt.addr,
587 + walk.src.virt.addr, n, ctrptr);
588 + if (ctrptr == ctrblk)
589 + memcpy(walk.iv, ctrptr + n - AES_BLOCK_SIZE,
590 + AES_BLOCK_SIZE);
591 + crypto_inc(walk.iv, AES_BLOCK_SIZE);
592 + ret = skcipher_walk_done(&walk, nbytes - n);
609 593 }
610 -
594 + if (locked)
595 + mutex_unlock(&ctrblk_lock);
611 596 /*
612 597 * final block may be < AES_BLOCK_SIZE, copy only nbytes
613 598 */
614 - if (!ret && walk.nbytes > 0) {
599 + if (nbytes) {
615 600 memset(buf, 0, AES_BLOCK_SIZE);
616 - memcpy(buf, walk.src.virt.addr, walk.nbytes);
601 + memcpy(buf, walk.src.virt.addr, nbytes);
617 602 cpacf_kmctr(sctx->fc, sctx->key, buf, buf,
618 603 AES_BLOCK_SIZE, walk.iv);
619 - memcpy(walk.dst.virt.addr, buf, walk.nbytes);
604 + memcpy(walk.dst.virt.addr, buf, nbytes);
620 605 crypto_inc(walk.iv, AES_BLOCK_SIZE);
621 606 ret = skcipher_walk_done(&walk, 0);
622 - memzero_explicit(buf, sizeof(buf));
623 607 }
624 608
625 609 return ret;
@@ -911,14 +895,10 @@ static int gcm_aes_crypt(struct aead_request *req, unsigned int flags)
911 895 gw_in.ptr, aad_bytes);
912 896
913 897 n = aad_bytes + pc_bytes;
914 - if (gcm_in_walk_done(&gw_in, n) != n) {
915 - ret = -ENOMEM;
916 - goto out;
917 - }
918 - if (gcm_out_walk_done(&gw_out, n) != n) {
919 - ret = -ENOMEM;
920 - goto out;
921 - }
898 + if (gcm_in_walk_done(&gw_in, n) != n)
899 + return -ENOMEM;
900 + if (gcm_out_walk_done(&gw_out, n) != n)
901 + return -ENOMEM;
922 902 aadlen -= aad_bytes;
923 903 pclen -= pc_bytes;
924 904 } while (aadlen + pclen > 0);
@@ -930,10 +910,7 @@ static int gcm_aes_crypt(struct aead_request *req, unsigned int flags)
930 910 } else
931 911 scatterwalk_map_and_copy(param.t, req->dst, len, taglen, 1);
932 912
933 - out:
934 913 memzero_explicit(&param, sizeof(param));
935 - memzero_explicit(gw_in.buf, sizeof(gw_in.buf));
936 - memzero_explicit(gw_out.buf, sizeof(gw_out.buf));
937 914 return ret;
938 915 }
939 916
modified arch/s390/crypto/paes_s390.c
@@ -19,7 +19,7 @@
19 19 #include <linux/init.h>
20 20 #include <linux/miscdevice.h>
21 21 #include <linux/module.h>
22 - #include <linux/semaphore.h>
22 + #include <linux/mutex.h>
23 23 #include <linux/spinlock.h>
24 24 #include <crypto/aes.h>
25 25 #include <crypto/algapi.h>
@@ -45,7 +45,7 @@ module_param_named(clrkey, pkey_clrkey_allowed, bool, 0444);
45 45 MODULE_PARM_DESC(clrkey, "Allow clear key material (default N)");
46 46
47 47 static u8 *ctrblk;
48 - static DEFINE_SEMAPHORE(ctrblk_sem, 1);
48 + static DEFINE_MUTEX(ctrblk_lock);
49 49
50 50 static cpacf_mask_t km_functions, kmc_functions, kmctr_functions;
51 51
@@ -220,10 +220,6 @@ static inline int convert_key(const u8 *key, unsigned int keylen,
220 220 xflags);
221 221 }
222 222
223 - /* But finally map -EBUSY to -EIO to indicate an IO failure */
224 - if (rc == -EBUSY)
225 - rc = -EIO;
226 -
227 223 out:
228 224 pr_debug("rc=%d\n", rc);
229 225 return rc;
@@ -436,11 +432,8 @@ static int ecb_paes_do_crypt(struct s390_paes_ctx *ctx,
436 432 n = nbytes & ~(AES_BLOCK_SIZE - 1);
437 433 k = cpacf_km(ctx->fc | req_ctx->modifier, param,
438 434 walk->dst.virt.addr, walk->src.virt.addr, n);
439 - if (k) {
435 + if (k)
440 436 rc = skcipher_walk_done(walk, nbytes - k);
441 - if (rc)
442 - goto out;
443 - }
444 437 if (k < n) {
445 438 if (!maysleep) {
446 439 rc = -EKEYEXPIRED;
@@ -467,7 +460,6 @@ static int ecb_paes_crypt(struct skcipher_request *req, unsigned long modifier)
467 460 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
468 461 struct skcipher_walk *walk = &req_ctx->walk;
469 462 bool tested = crypto_skcipher_tested(tfm);
470 - bool cleanup = true;
471 463 int rc;
472 464
473 465 /*
@@ -499,17 +491,15 @@ static int ecb_paes_crypt(struct skcipher_request *req, unsigned long modifier)
499 491 if (rc == 0 || rc == -EKEYEXPIRED) {
500 492 atomic_inc(&ctx->via_engine_ctr);
501 493 rc = crypto_transfer_skcipher_request_to_engine(paes_crypto_engine, req);
502 - if (rc == -EINPROGRESS || rc == -EBUSY)
503 - cleanup = false;
504 - else
494 + if (rc != -EINPROGRESS)
505 495 atomic_dec(&ctx->via_engine_ctr);
506 496 }
507 497
508 - if (cleanup && walk->nbytes)
498 + if (rc != -EINPROGRESS)
509 499 skcipher_walk_done(walk, rc);
510 500
511 501 out:
512 - if (cleanup)
502 + if (rc != -EINPROGRESS)
513 503 memzero_explicit(&req_ctx->param, sizeof(req_ctx->param));
514 504 pr_debug("rc=%d\n", rc);
515 505 return rc;
@@ -559,7 +549,7 @@ static int ecb_paes_do_one_request(struct crypto_engine *engine, void *areq)
559 549 rc = ecb_paes_do_crypt(ctx, req_ctx, tested, true);
560 550 if (rc == -EKEYEXPIRED) {
561 551 return pkey_handle_expired();
562 - } else if (rc && walk->nbytes) {
552 + } else if (rc) {
563 553 skcipher_walk_done(walk, rc);
564 554 }
565 555
@@ -569,7 +559,7 @@ static int ecb_paes_do_one_request(struct crypto_engine *engine, void *areq)
569 559 atomic_dec(&ctx->via_engine_ctr);
570 560 crypto_finalize_skcipher_request(engine, req, rc);
571 561 local_bh_enable();
572 - return 0;
562 + return rc;
573 563 }
574 564
575 565 static struct skcipher_engine_alg ecb_paes_alg = {
@@ -577,7 +567,6 @@ static struct skcipher_engine_alg ecb_paes_alg = {
577 567 .base.cra_name = "ecb(paes)",
578 568 .base.cra_driver_name = "ecb-paes-s390",
579 569 .base.cra_priority = 401, /* combo: aes + ecb + 1 */
580 - .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NO_FALLBACK,
581 570 .base.cra_blocksize = AES_BLOCK_SIZE,
582 571 .base.cra_ctxsize = sizeof(struct s390_paes_ctx),
583 572 .base.cra_module = THIS_MODULE,
@@ -701,8 +690,6 @@ static int cbc_paes_do_crypt(struct s390_paes_ctx *ctx,
701 690 if (k) {
702 691 memcpy(walk->iv, param->iv, AES_BLOCK_SIZE);
703 692 rc = skcipher_walk_done(walk, nbytes - k);
704 - if (rc)
705 - goto out;
706 693 }
707 694 if (k < n) {
708 695 if (!maysleep) {
@@ -730,7 +717,6 @@ static int cbc_paes_crypt(struct skcipher_request *req, unsigned long modifier)
730 717 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
731 718 struct skcipher_walk *walk = &req_ctx->walk;
732 719 bool tested = crypto_skcipher_tested(tfm);
733 - bool cleanup = true;
734 720 int rc;
735 721
736 722 /*
@@ -762,17 +748,15 @@ static int cbc_paes_crypt(struct skcipher_request *req, unsigned long modifier)
762 748 if (rc == 0 || rc == -EKEYEXPIRED) {
763 749 atomic_inc(&ctx->via_engine_ctr);
764 750 rc = crypto_transfer_skcipher_request_to_engine(paes_crypto_engine, req);
765 - if (rc == -EINPROGRESS || rc == -EBUSY)
766 - cleanup = false;
767 - else
751 + if (rc != -EINPROGRESS)
768 752 atomic_dec(&ctx->via_engine_ctr);
769 753 }
770 754
771 - if (cleanup && walk->nbytes)
755 + if (rc != -EINPROGRESS)
772 756 skcipher_walk_done(walk, rc);
773 757
774 758 out:
775 - if (cleanup)
759 + if (rc != -EINPROGRESS)
776 760 memzero_explicit(&req_ctx->param, sizeof(req_ctx->param));
777 761 pr_debug("rc=%d\n", rc);
778 762 return rc;
@@ -822,7 +806,7 @@ static int cbc_paes_do_one_request(struct crypto_engine *engine, void *areq)
822 806 rc = cbc_paes_do_crypt(ctx, req_ctx, tested, true);
823 807 if (rc == -EKEYEXPIRED) {
824 808 return pkey_handle_expired();
825 - } else if (rc && walk->nbytes) {
809 + } else if (rc) {
826 810 skcipher_walk_done(walk, rc);
827 811 }
828 812
@@ -832,7 +816,7 @@ static int cbc_paes_do_one_request(struct crypto_engine *engine, void *areq)
832 816 atomic_dec(&ctx->via_engine_ctr);
833 817 crypto_finalize_skcipher_request(engine, req, rc);
834 818 local_bh_enable();
835 - return 0;
819 + return rc;
836 820 }
837 821
838 822 static struct skcipher_engine_alg cbc_paes_alg = {
@@ -840,7 +824,6 @@ static struct skcipher_engine_alg cbc_paes_alg = {
840 824 .base.cra_name = "cbc(paes)",
841 825 .base.cra_driver_name = "cbc-paes-s390",
842 826 .base.cra_priority = 402, /* cbc-paes-s390 + 1 */
843 - .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NO_FALLBACK,
844 827 .base.cra_blocksize = AES_BLOCK_SIZE,
845 828 .base.cra_ctxsize = sizeof(struct s390_paes_ctx),
846 829 .base.cra_module = THIS_MODULE,
@@ -931,14 +914,41 @@ static inline unsigned int __ctrblk_init(u8 *ctrptr, u8 *iv, unsigned int nbytes
931 914 return n;
932 915 }
933 916
934 - static int __ctr_paes_do_crypt(struct s390_paes_ctx *ctx,
935 - struct ctr_param *param,
936 - struct skcipher_walk *walk,
937 - bool tested, bool maysleep, bool locked)
917 + static int ctr_paes_do_crypt(struct s390_paes_ctx *ctx,
918 + struct s390_pctr_req_ctx *req_ctx,
919 + bool tested, bool maysleep)
938 920 {
921 + struct ctr_param *param = &req_ctx->param;
922 + struct skcipher_walk *walk = &req_ctx->walk;
923 + u8 buf[AES_BLOCK_SIZE], *ctrptr;
939 924 unsigned int nbytes, n, k;
940 - u8 *ctrptr;
941 - int rc = 0;
925 + int pk_state, locked, rc = 0;
926 +
927 + if (!req_ctx->param_init_done) {
928 + /* fetch and check protected key state */
929 + spin_lock_bh(&ctx->pk_lock);
930 + pk_state = ctx->pk_state;
931 + switch (pk_state) {
932 + case PK_STATE_NO_KEY:
933 + rc = -ENOKEY;
934 + break;
935 + case PK_STATE_CONVERT_IN_PROGRESS:
936 + rc = -EKEYEXPIRED;
937 + break;
938 + case PK_STATE_VALID:
939 + memcpy(param->key, ctx->pk.protkey, sizeof(param->key));
940 + req_ctx->param_init_done = true;
941 + break;
942 + default:
943 + rc = pk_state < 0 ? pk_state : -EIO;
944 + break;
945 + }
946 + spin_unlock_bh(&ctx->pk_lock);
947 + }
948 + if (rc)
949 + goto out;
950 +
951 + locked = mutex_trylock(&ctrblk_lock);
942 952
943 953 /*
944 954 * Note that in case of partial processing or failure the walk
@@ -958,71 +968,32 @@ static int __ctr_paes_do_crypt(struct s390_paes_ctx *ctx,
958 968 AES_BLOCK_SIZE);
959 969 crypto_inc(walk->iv, AES_BLOCK_SIZE);
960 970 rc = skcipher_walk_done(walk, nbytes - k);
961 - if (rc)
962 - goto out;
963 971 }
964 972 if (k < n) {
965 973 if (!maysleep) {
974 + if (locked)
975 + mutex_unlock(&ctrblk_lock);
966 976 rc = -EKEYEXPIRED;
967 977 goto out;
968 978 }
969 979 rc = paes_convert_key(ctx, tested);
970 - if (rc)
980 + if (rc) {
981 + if (locked)
982 + mutex_unlock(&ctrblk_lock);
971 983 goto out;
984 + }
972 985 spin_lock_bh(&ctx->pk_lock);
973 986 memcpy(param->key, ctx->pk.protkey, sizeof(param->key));
974 987 spin_unlock_bh(&ctx->pk_lock);
975 988 }
976 989 }
977 -
978 - out:
979 - return rc;
980 - }
981 -
982 - static int ctr_paes_do_crypt(struct s390_paes_ctx *ctx,
983 - struct s390_pctr_req_ctx *req_ctx,
984 - bool tested, bool maysleep)
985 - {
986 - struct ctr_param *param = &req_ctx->param;
987 - struct skcipher_walk *walk = &req_ctx->walk;
988 - u8 buf[AES_BLOCK_SIZE];
989 - int pk_state, rc = 0;
990 -
991 - if (!req_ctx->param_init_done) {
992 - /* fetch and check protected key state */
993 - spin_lock_bh(&ctx->pk_lock);
994 - pk_state = ctx->pk_state;
995 - switch (pk_state) {
996 - case PK_STATE_NO_KEY:
997 - rc = -ENOKEY;
998 - break;
999 - case PK_STATE_CONVERT_IN_PROGRESS:
1000 - rc = -EKEYEXPIRED;
1001 - break;
1002 - case PK_STATE_VALID:
1003 - memcpy(param->key, ctx->pk.protkey, sizeof(param->key));
1004 - req_ctx->param_init_done = true;
1005 - break;
1006 - default:
1007 - rc = pk_state < 0 ? pk_state : -EIO;
1008 - break;
1009 - }
1010 - spin_unlock_bh(&ctx->pk_lock);
1011 - }
1012 - if (rc)
1013 - goto out;
1014 -
1015 - if (down_trylock(&ctrblk_sem) == 0) {
1016 - rc = __ctr_paes_do_crypt(ctx, param, walk, tested, maysleep, true);
1017 - up(&ctrblk_sem);
1018 - } else {
1019 - rc = __ctr_paes_do_crypt(ctx, param, walk, tested, maysleep, false);
1020 - }
990 + if (locked)
991 + mutex_unlock(&ctrblk_lock);
1021 992
1022 993 /* final block may be < AES_BLOCK_SIZE, copy only nbytes */
1023 - if (!rc && walk->nbytes > 0) {
994 + if (nbytes) {
1024 995 memset(buf, 0, AES_BLOCK_SIZE);
1025 - memcpy(buf, walk->src.virt.addr, walk->nbytes);
996 + memcpy(buf, walk->src.virt.addr, nbytes);
1026 997 while (1) {
1027 998 if (cpacf_kmctr(ctx->fc, param, buf,
1028 999 buf, AES_BLOCK_SIZE,
@@ -1039,13 +1010,12 @@ static int ctr_paes_do_crypt(struct s390_paes_ctx *ctx,
1039 1010 memcpy(param->key, ctx->pk.protkey, sizeof(param->key));
1040 1011 spin_unlock_bh(&ctx->pk_lock);
1041 1012 }
1042 - memcpy(walk->dst.virt.addr, buf, walk->nbytes);
1013 + memcpy(walk->dst.virt.addr, buf, nbytes);
1043 1014 crypto_inc(walk->iv, AES_BLOCK_SIZE);
1044 1015 rc = skcipher_walk_done(walk, 0);
1045 1016 }
1046 1017
1047 1018 out:
1048 - memzero_explicit(buf, sizeof(buf));
1049 1019 pr_debug("rc=%d\n", rc);
1050 1020 return rc;
1051 1021 }
@@ -1057,7 +1027,6 @@ static int ctr_paes_crypt(struct skcipher_request *req)
1057 1027 struct s390_paes_ctx *ctx = crypto_skcipher_ctx(tfm);
1058 1028 struct skcipher_walk *walk = &req_ctx->walk;
1059 1029 bool tested = crypto_skcipher_tested(tfm);
1060 - bool cleanup = true;
1061 1030 int rc;
1062 1031
1063 1032 /*
@@ -1088,17 +1057,15 @@ static int ctr_paes_crypt(struct skcipher_request *req)
1088 1057 if (rc == 0 || rc == -EKEYEXPIRED) {
1089 1058 atomic_inc(&ctx->via_engine_ctr);
1090 1059 rc = crypto_transfer_skcipher_request_to_engine(paes_crypto_engine, req);
1091 - if (rc == -EINPROGRESS || rc == -EBUSY)
1092 - cleanup = false;
1093 - else
1060 + if (rc != -EINPROGRESS)
1094 1061 atomic_dec(&ctx->via_engine_ctr);
1095 1062 }
1096 1063
1097 - if (cleanup && walk->nbytes)
1064 + if (rc != -EINPROGRESS)
1098 1065 skcipher_walk_done(walk, rc);
1099 1066
1100 1067 out:
1101 - if (cleanup)
1068 + if (rc != -EINPROGRESS)
1102 1069 memzero_explicit(&req_ctx->param, sizeof(req_ctx->param));
1103 1070 pr_debug("rc=%d\n", rc);
1104 1071 return rc;
@@ -1138,7 +1105,7 @@ static int ctr_paes_do_one_request(struct crypto_engine *engine, void *areq)
1138 1105 rc = ctr_paes_do_crypt(ctx, req_ctx, tested, true);
1139 1106 if (rc == -EKEYEXPIRED) {
1140 1107 return pkey_handle_expired();
1141 - } else if (rc && walk->nbytes) {
1108 + } else if (rc) {
1142 1109 skcipher_walk_done(walk, rc);
1143 1110 }
1144 1111
@@ -1148,7 +1115,7 @@ static int ctr_paes_do_one_request(struct crypto_engine *engine, void *areq)
1148 1115 atomic_dec(&ctx->via_engine_ctr);
1149 1116 crypto_finalize_skcipher_request(engine, req, rc);
1150 1117 local_bh_enable();
1151 - return 0;
1118 + return rc;
1152 1119 }
1153 1120
1154 1121 static struct skcipher_engine_alg ctr_paes_alg = {
@@ -1156,7 +1123,6 @@ static struct skcipher_engine_alg ctr_paes_alg = {
1156 1123 .base.cra_name = "ctr(paes)",
1157 1124 .base.cra_driver_name = "ctr-paes-s390",
1158 1125 .base.cra_priority = 402, /* ecb-paes-s390 + 1 */
1159 - .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NO_FALLBACK,
1160 1126 .base.cra_blocksize = 1,
1161 1127 .base.cra_ctxsize = sizeof(struct s390_paes_ctx),
1162 1128 .base.cra_module = THIS_MODULE,
@@ -1317,11 +1283,8 @@ static int xts_paes_do_crypt_fullkey(struct s390_pxts_ctx *ctx,
1317 1283 n = nbytes & ~(AES_BLOCK_SIZE - 1);
1318 1284 k = cpacf_km(ctx->fc | req_ctx->modifier, param->key + offset,
1319 1285 walk->dst.virt.addr, walk->src.virt.addr, n);
1320 - if (k) {
1286 + if (k)
1321 1287 rc = skcipher_walk_done(walk, nbytes - k);
1322 - if (rc)
1323 - goto out;
1324 - }
1325 1288 if (k < n) {
1326 1289 if (!maysleep) {
1327 1290 rc = -EKEYEXPIRED;
@@ -1374,7 +1337,7 @@ static inline int __xts_2keys_prep_param(struct s390_pxts_ctx *ctx,
1374 1337 memcpy(param->init, pcc_param.xts, 16);
1375 1338 }
1376 1339
1377 - memzero_explicit(&pcc_param, sizeof(pcc_param));
1340 + memzero_explicit(pcc_param.key, sizeof(pcc_param.key));
1378 1341 return rc;
1379 1342 }
1380 1343
@@ -1414,11 +1377,8 @@ static int xts_paes_do_crypt_2keys(struct s390_pxts_ctx *ctx,
1414 1377 n = nbytes & ~(AES_BLOCK_SIZE - 1);
1415 1378 k = cpacf_km(ctx->fc | req_ctx->modifier, param->key + offset,
1416 1379 walk->dst.virt.addr, walk->src.virt.addr, n);
1417 - if (k) {
1380 + if (k)
1418 1381 rc = skcipher_walk_done(walk, nbytes - k);
1419 - if (rc)
1420 - goto out;
1421 - }
1422 1382 if (k < n) {
1423 1383 if (!maysleep) {
1424 1384 rc = -EKEYEXPIRED;
@@ -1490,7 +1450,6 @@ static inline int xts_paes_crypt(struct skcipher_request *req, unsigned long mod
1490 1450 struct s390_pxts_ctx *ctx = crypto_skcipher_ctx(tfm);
1491 1451 struct skcipher_walk *walk = &req_ctx->walk;
1492 1452 bool tested = crypto_skcipher_tested(tfm);
1493 - bool cleanup = true;
1494 1453 int rc;
1495 1454
1496 1455 /*
@@ -1522,17 +1481,15 @@ static inline int xts_paes_crypt(struct skcipher_request *req, unsigned long mod
1522 1481 if (rc == 0 || rc == -EKEYEXPIRED) {
1523 1482 atomic_inc(&ctx->via_engine_ctr);
1524 1483 rc = crypto_transfer_skcipher_request_to_engine(paes_crypto_engine, req);
1525 - if (rc == -EINPROGRESS || rc == -EBUSY)
1526 - cleanup = false;
1527 - else
1484 + if (rc != -EINPROGRESS)
1528 1485 atomic_dec(&ctx->via_engine_ctr);
1529 1486 }
1530 1487
1531 - if (cleanup && walk->nbytes)
1488 + if (rc != -EINPROGRESS)
1532 1489 skcipher_walk_done(walk, rc);
1533 1490
1534 1491 out:
1535 - if (cleanup)
1492 + if (rc != -EINPROGRESS)
1536 1493 memzero_explicit(&req_ctx->param, sizeof(req_ctx->param));
1537 1494 pr_debug("rc=%d\n", rc);
1538 1495 return rc;
@@ -1582,7 +1539,7 @@ static int xts_paes_do_one_request(struct crypto_engine *engine, void *areq)
1582 1539 rc = xts_paes_do_crypt(ctx, req_ctx, tested, true);
1583 1540 if (rc == -EKEYEXPIRED) {
1584 1541 return pkey_handle_expired();
1585 - } else if (rc && walk->nbytes) {
1542 + } else if (rc) {
1586 1543 skcipher_walk_done(walk, rc);
1587 1544 }
1588 1545
@@ -1592,7 +1549,7 @@ static int xts_paes_do_one_request(struct crypto_engine *engine, void *areq)
1592 1549 atomic_dec(&ctx->via_engine_ctr);
1593 1550 crypto_finalize_skcipher_request(engine, req, rc);
1594 1551 local_bh_enable();
1595 - return 0;
1552 + return rc;
1596 1553 }
1597 1554
1598 1555 static struct skcipher_engine_alg xts_paes_alg = {
@@ -1600,7 +1557,6 @@ static struct skcipher_engine_alg xts_paes_alg = {
1600 1557 .base.cra_name = "xts(paes)",
1601 1558 .base.cra_driver_name = "xts-paes-s390",
1602 1559 .base.cra_priority = 402, /* ecb-paes-s390 + 1 */
1603 - .base.cra_flags = CRYPTO_ALG_ASYNC | CRYPTO_ALG_NO_FALLBACK,
1604 1560 .base.cra_blocksize = AES_BLOCK_SIZE,
1605 1561 .base.cra_ctxsize = sizeof(struct s390_pxts_ctx),
1606 1562 .base.cra_module = THIS_MODULE,
modified arch/s390/crypto/phmac_s390.c
@@ -62,10 +62,8 @@ static inline int hwh_prepare(struct ahash_request *req,
62 62 */
63 63 static inline int hwh_advance(struct hash_walk_helper *hwh, int n)
64 64 {
65 - if (n < 0) {
66 - hwh->walkbytes = n;
65 + if (n < 0)
67 66 return crypto_hash_walk_done(&hwh->walk, n);
68 - }
69 67
70 68 hwh->walkbytes -= n;
71 69 hwh->walkaddr += n;
@@ -341,10 +339,6 @@ static inline int convert_key(const u8 *key, unsigned int keylen,
341 339 xflags);
342 340 }
343 341
344 - /* But finally map -EBUSY to -EIO to indicate an IO failure */
345 - if (rc == -EBUSY)
346 - rc = -EIO;
347 -
348 342 out:
349 343 pr_debug("rc=%d\n", rc);
350 344 return rc;
@@ -612,7 +606,6 @@ static int phmac_update(struct ahash_request *req)
612 606 struct phmac_tfm_ctx *tfm_ctx = crypto_ahash_ctx(tfm);
613 607 struct kmac_sha2_ctx *kmac_ctx = &req_ctx->kmac_ctx;
614 608 struct hash_walk_helper *hwh = &req_ctx->hwh;
615 - bool cleanup = true;
616 609 int rc;
617 610
618 611 /* prep the walk in the request context */
@@ -636,15 +629,12 @@ static int phmac_update(struct ahash_request *req)
636 629 req_ctx->async_op = OP_UPDATE;
637 630 atomic_inc(&tfm_ctx->via_engine_ctr);
638 631 rc = crypto_transfer_hash_request_to_engine(phmac_crypto_engine, req);
639 - if (rc == -EINPROGRESS || rc == -EBUSY)
640 - cleanup = false;
641 - else
632 + if (rc != -EINPROGRESS)
642 633 atomic_dec(&tfm_ctx->via_engine_ctr);
643 634 }
644 635
645 - if (cleanup) {
646 - if (hwh->walkbytes > 0)
647 - hwh_advance(hwh, rc);
636 + if (rc != -EINPROGRESS) {
637 + hwh_advance(hwh, rc);
648 638 memzero_explicit(kmac_ctx, sizeof(*kmac_ctx));
649 639 }
650 640
@@ -659,7 +649,6 @@ static int phmac_final(struct ahash_request *req)
659 649 struct crypto_ahash *tfm = crypto_ahash_reqtfm(req);
660 650 struct phmac_tfm_ctx *tfm_ctx = crypto_ahash_ctx(tfm);
661 651 struct kmac_sha2_ctx *kmac_ctx = &req_ctx->kmac_ctx;
662 - bool cleanup = true;
663 652 int rc = 0;
664 653
665 654 /* Try synchronous operation if no active engine usage */
@@ -678,14 +667,12 @@ static int phmac_final(struct ahash_request *req)
678 667 req_ctx->async_op = OP_FINAL;
679 668 atomic_inc(&tfm_ctx->via_engine_ctr);
680 669 rc = crypto_transfer_hash_request_to_engine(phmac_crypto_engine, req);
681 - if (rc == -EINPROGRESS || rc == -EBUSY)
682 - cleanup = false;
683 - else
670 + if (rc != -EINPROGRESS)
684 671 atomic_dec(&tfm_ctx->via_engine_ctr);
685 672 }
686 673
687 674 out:
688 - if (cleanup)
675 + if (rc != -EINPROGRESS)
689 676 memzero_explicit(kmac_ctx, sizeof(*kmac_ctx));
690 677 pr_debug("rc=%d\n", rc);
691 678 return rc;
@@ -698,7 +685,6 @@ static int phmac_finup(struct ahash_request *req)
698 685 struct phmac_tfm_ctx *tfm_ctx = crypto_ahash_ctx(tfm);
699 686 struct kmac_sha2_ctx *kmac_ctx = &req_ctx->kmac_ctx;
700 687 struct hash_walk_helper *hwh = &req_ctx->hwh;
701 - bool cleanup = true;
702 688 int rc;
703 689
704 690 /* prep the walk in the request context */
@@ -730,17 +716,15 @@ static int phmac_finup(struct ahash_request *req)
730 716 /* req->async_op has been set to either OP_FINUP or OP_FINAL */
731 717 atomic_inc(&tfm_ctx->via_engine_ctr);
732 718 rc = crypto_transfer_hash_request_to_engine(phmac_crypto_engine, req);
733 - if (rc == -EINPROGRESS || rc == -EBUSY)
734 - cleanup = false;
735 - else
719 + if (rc != -EINPROGRESS)
736 720 atomic_dec(&tfm_ctx->via_engine_ctr);
737 721 }
738 722
739 - if (cleanup && hwh->walkbytes > 0)
723 + if (rc != -EINPROGRESS)
740 724 hwh_advance(hwh, rc);
741 725
742 726 out:
743 - if (cleanup)
727 + if (rc != -EINPROGRESS)
744 728 memzero_explicit(kmac_ctx, sizeof(*kmac_ctx));
745 729 pr_debug("rc=%d\n", rc);
746 730 return rc;
@@ -930,7 +914,7 @@ out:
930 914 atomic_dec(&tfm_ctx->via_engine_ctr);
931 915 crypto_finalize_hash_request(engine, req, rc);
932 916 local_bh_enable();
933 - return 0;
917 + return rc;
934 918 }
935 919
936 920 #define S390_ASYNC_PHMAC_ALG(x) \
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/pai.h
@@ -76,6 +76,7 @@ static __always_inline void pai_kernel_exit(struct pt_regs *regs)
76 76 }
77 77
78 78 #define PAI_SAVE_AREA(x) ((x)->hw.event_base)
79 + #define PAI_CPU_MASK(x) ((x)->hw.addr_filters)
79 80 #define PAI_PMU_IDX(x) ((x)->hw.last_tag)
80 81 #define PAI_SWLIST(x) (&(x)->hw.tp_list)
81 82
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/debug.c
@@ -182,7 +182,7 @@ static struct debug_param_t {
182 182 static int debug_param_num;
183 183
184 184 /* functions */
185 - static void debug_get_param(const char *name, int *level, int *pages, bool quiet)
185 + static void debug_get_param(const char *name, int *level, int *pages)
186 186 {
187 187 struct debug_param_t *p;
188 188 int i;
@@ -192,13 +192,11 @@ static void debug_get_param(const char *name, int *level, int *pages, bool quiet
192 192 if (!glob_match(p->name, name))
193 193 continue;
194 194 if (level && p->level != PARAM_UNSET) {
195 - if (!quiet)
196 - pr_info("%s: override level to %d\n", name, p->level);
195 + pr_info("%s: override level to %d\n", name, p->level);
197 196 *level = p->level;
198 197 }
199 198 if (pages && p->pages != PARAM_UNSET) {
200 - if (!quiet)
201 - pr_info("%s: override pages to %d\n", name, p->pages);
199 + pr_info("%s: override pages to %d\n", name, p->pages);
202 200 *pages = p->pages;
203 201 }
204 202 }
@@ -253,7 +251,7 @@ static int __init s390dbf_parse(char *arg)
253 251 * regular memory allocations are possible.
254 252 */
255 253 for (i = 0, id = __s390dbf_info; &id[i] < __s390dbf_info_end; i++)
256 - debug_get_param(id[i]->name, &id[i]->level, NULL, false);
254 + debug_get_param(id[i]->name, &id[i]->level, NULL);
257 255
258 256 return rc;
259 257 }
@@ -397,7 +395,7 @@ static debug_info_t *debug_info_create(const char *name, int pages_per_area,
397 395 int level = DEBUG_DEFAULT_LEVEL;
398 396 debug_info_t *rc;
399 397
400 - debug_get_param(name, &level, &pages_per_area, false);
398 + debug_get_param(name, &level, &pages_per_area);
401 399 rc = debug_info_alloc(name, pages_per_area, nr_areas, buf_size, level, ALL_AREAS);
402 400 if (!rc)
403 401 goto out;
@@ -962,7 +960,7 @@ void debug_register_static(debug_info_t *id, int pages_per_area, int nr_areas)
962 960 return;
963 961 }
964 962
965 - debug_get_param(id->name, &id->level, &pages_per_area, false);
963 + debug_get_param(id->name, &id->level, &pages_per_area);
966 964 copy = debug_info_alloc("", pages_per_area, nr_areas, id->buf_size,
967 965 id->level, ALL_AREAS);
968 966 if (!copy) {
@@ -1076,6 +1074,9 @@ static void _debug_set_level(debug_info_t *id, int new_level)
1076 1074 {
1077 1075 unsigned long flags;
1078 1076
1077 + if (!id)
1078 + return;
1079 +
1079 1080 if (new_level == DEBUG_OFF_LEVEL) {
1080 1081 pr_info("%s: switched off\n", id->name);
1081 1082 } else if ((new_level > DEBUG_MAX_LEVEL) || (new_level < 0)) {
@@ -1100,14 +1101,8 @@ static void _debug_set_level(debug_info_t *id, int new_level)
1100 1101 */
1101 1102 void debug_set_level(debug_info_t *id, int new_level)
1102 1103 {
1103 - if (!id)
1104 - return;
1105 -
1106 - /*
1107 - * Level specified via kernel parameter takes precedence. The override
1108 - * was already announced during registration, so stay quiet here.
1109 - */
1110 - debug_get_param(id->name, &new_level, NULL, true);
1104 + /* Level specified via kernel parameter takes precedence */
1105 + debug_get_param(id->name, &new_level, NULL);
1111 1106
1112 1107 _debug_set_level(id, new_level);
1113 1108 }
@@ -1283,7 +1278,7 @@ void debug_set_critical(void)
1283 1278 debug_entry_t *debug_event_common(debug_info_t *id, int level, const void *buf,
1284 1279 int len)
1285 1280 {
1286 - debug_entry_t *active = NULL;
1281 + debug_entry_t *active;
1287 1282 unsigned long flags;
1288 1283
1289 1284 if (!debug_active || !id->areas)
@@ -1294,8 +1289,6 @@ debug_entry_t *debug_event_common(debug_info_t *id, int level, const void *buf,
1294 1289 } else {
1295 1290 raw_spin_lock_irqsave(&id->lock, flags);
1296 1291 }
1297 - if (!id->areas)
1298 - goto out;
1299 1292 do {
1300 1293 active = get_active_entry(id);
1301 1294 memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
@@ -1305,7 +1298,7 @@ debug_entry_t *debug_event_common(debug_info_t *id, int level, const void *buf,
1305 1298 len -= id->buf_size;
1306 1299 buf += id->buf_size;
1307 1300 } while (len > 0);
1308 - out:
1301 +
1309 1302 raw_spin_unlock_irqrestore(&id->lock, flags);
1310 1303 return active;
1311 1304 }
@@ -1318,7 +1311,7 @@ EXPORT_SYMBOL(debug_event_common);
1318 1311 debug_entry_t *debug_exception_common(debug_info_t *id, int level,
1319 1312 const void *buf, int len)
1320 1313 {
1321 - debug_entry_t *active = NULL;
1314 + debug_entry_t *active;
1322 1315 unsigned long flags;
1323 1316
1324 1317 if (!debug_active || !id->areas)
@@ -1329,8 +1322,6 @@ debug_entry_t *debug_exception_common(debug_info_t *id, int level,
1329 1322 } else {
1330 1323 raw_spin_lock_irqsave(&id->lock, flags);
1331 1324 }
1332 - if (!id->areas)
1333 - goto out;
1334 1325 do {
1335 1326 active = get_active_entry(id);
1336 1327 memcpy(DEBUG_DATA(active), buf, min(len, id->buf_size));
@@ -1340,7 +1331,7 @@ debug_entry_t *debug_exception_common(debug_info_t *id, int level,
1340 1331 len -= id->buf_size;
1341 1332 buf += id->buf_size;
1342 1333 } while (len > 0);
1343 - out:
1334 +
1344 1335 raw_spin_unlock_irqrestore(&id->lock, flags);
1345 1336 return active;
1346 1337 }
@@ -1366,7 +1357,7 @@ static inline int debug_count_numargs(char *string)
1366 1357 debug_entry_t *__debug_sprintf_event(debug_info_t *id, int level, char *string, ...)
1367 1358 {
1368 1359 debug_sprintf_entry_t *curr_event;
1369 - debug_entry_t *active = NULL;
1360 + debug_entry_t *active;
1370 1361 unsigned long flags;
1371 1362 int numargs, idx;
1372 1363 va_list ap;
@@ -1381,8 +1372,6 @@ debug_entry_t *__debug_sprintf_event(debug_info_t *id, int level, char *string,
1381 1372 } else {
1382 1373 raw_spin_lock_irqsave(&id->lock, flags);
1383 1374 }
1384 - if (!id->areas)
1385 - goto out;
1386 1375 active = get_active_entry(id);
1387 1376 curr_event = (debug_sprintf_entry_t *) DEBUG_DATA(active);
1388 1377 va_start(ap, string);
@@ -1391,7 +1380,6 @@ debug_entry_t *__debug_sprintf_event(debug_info_t *id, int level, char *string,
1391 1380 curr_event->args[idx] = va_arg(ap, long);
1392 1381 va_end(ap);
1393 1382 debug_finish_entry(id, active, level, 0);
1394 - out:
1395 1383 raw_spin_unlock_irqrestore(&id->lock, flags);
1396 1384
1397 1385 return active;
@@ -1404,7 +1392,7 @@ EXPORT_SYMBOL(__debug_sprintf_event);
1404 1392 debug_entry_t *__debug_sprintf_exception(debug_info_t *id, int level, char *string, ...)
1405 1393 {
1406 1394 debug_sprintf_entry_t *curr_event;
1407 - debug_entry_t *active = NULL;
1395 + debug_entry_t *active;
1408 1396 unsigned long flags;
1409 1397 int numargs, idx;
1410 1398 va_list ap;
@@ -1420,8 +1408,6 @@ debug_entry_t *__debug_sprintf_exception(debug_info_t *id, int level, char *stri
1420 1408 } else {
1421 1409 raw_spin_lock_irqsave(&id->lock, flags);
1422 1410 }
1423 - if (!id->areas)
1424 - goto out;
1425 1411 active = get_active_entry(id);
1426 1412 curr_event = (debug_sprintf_entry_t *)DEBUG_DATA(active);
1427 1413 va_start(ap, string);
@@ -1430,7 +1416,6 @@ debug_entry_t *__debug_sprintf_exception(debug_info_t *id, int level, char *stri
1430 1416 curr_event->args[idx] = va_arg(ap, long);
1431 1417 va_end(ap);
1432 1418 debug_finish_entry(id, active, level, 1);
1433 - out:
1434 1419 raw_spin_unlock_irqrestore(&id->lock, flags);
1435 1420
1436 1421 return active;
@@ -1673,11 +1658,9 @@ static void debug_flush(debug_info_t *id, int area)
1673 1658 unsigned long flags;
1674 1659 int i, j;
1675 1660
1676 - if (!id)
1661 + if (!id || !id->areas)
1677 1662 return;
1678 1663 raw_spin_lock_irqsave(&id->lock, flags);
1679 - if (!id->areas)
1680 - goto out;
1681 1664 if (area == DEBUG_FLUSH_ALL) {
1682 1665 id->active_area = 0;
1683 1666 memset(id->active_entries, 0, id->nr_areas * sizeof(int));
@@ -1692,7 +1675,6 @@ static void debug_flush(debug_info_t *id, int area)
1692 1675 for (i = 0; i < id->pages_per_area; i++)
1693 1676 memset(id->areas[area][i], 0, PAGE_SIZE);
1694 1677 }
1695 - out:
1696 1678 raw_spin_unlock_irqrestore(&id->lock, flags);
1697 1679 }
1698 1680
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
@@ -67,7 +67,6 @@ struct pai_mapptr {
67 67
68 68 static struct pai_root { /* Anchor to per CPU data */
69 69 refcount_t refcnt; /* Overall active events */
70 - atomic_t tskctx; /* Overall per-task events */
71 70 struct pai_mapptr __percpu *mapptr;
72 71 } pai_root[PAI_PMU_MAX];
73 72
@@ -94,15 +93,14 @@ struct pai_pmu { /* Define PAI PMU characteristics */
94 93 static struct pai_pmu pai_pmu[]; /* Forward declaration */
95 94
96 95 /* Free per CPU data when the last event is removed. */
97 - static void pai_root_free(int idx, int tasks)
96 + static void pai_root_free(int idx)
98 97 {
99 - if (refcount_sub_and_test(tasks, &pai_root[idx].refcnt)) {
98 + if (refcount_dec_and_test(&pai_root[idx].refcnt)) {
100 99 free_percpu(pai_root[idx].mapptr);
101 100 pai_root[idx].mapptr = NULL;
102 101 }
103 - debug_sprintf_event(paidbg, 5, "%s root[%d].refcount %d tskctx %d\n",
104 - __func__, idx, refcount_read(&pai_root[idx].refcnt),
105 - atomic_read(&pai_root[idx].tskctx));
102 + debug_sprintf_event(paidbg, 5, "%s root[%d].refcount %d\n", __func__,
103 + idx, refcount_read(&pai_root[idx].refcnt));
106 104 }
107 105
108 106 /*
@@ -139,54 +137,40 @@ static void pai_free(struct pai_mapptr *mp)
139 137 mp->mapptr = NULL;
140 138 }
141 139
142 - /* Called under mutex_lock */
143 - static void pai_event_destroy_cpu(int idx, int cpu, bool hotplug)
140 + /* Adjust usage counters and remove allocated memory when all users are
141 + * gone.
142 + */
143 + static void pai_event_destroy_cpu(struct perf_event *event, int cpu)
144 144 {
145 - struct pai_mapptr *mp;
146 - struct pai_map *cpump;
147 - int tasks = 1;
148 -
149 - /* Check reference count and return when all gone.
150 - * 1. An event is installed on online CPU X.
151 - * 2. CPU x is offlined and the per-CPU data is removed.
152 - * 3. Event is destroyed via close system call.
153 - */
154 - if (!refcount_read(&pai_root[idx].refcnt))
155 - return; /* No events at all */
156 - mp = per_cpu_ptr(pai_root[idx].mapptr, cpu);
157 - if (!mp || !mp->mapptr) /* No events on that CPU */
158 - return;
159 -
160 - /* When hotplug is true, invocation is from CPU hotplug callback.
161 - * Delete per-CPU resource and adjust refcnt when per-task events
162 - * are currently active. This can be more than one.
163 - * In this case adjust counters.
164 - */
165 - if (hotplug)
166 - tasks = atomic_read(&pai_root[idx].tskctx);
145 + int idx = PAI_PMU_IDX(event);
146 + struct pai_mapptr *mp = per_cpu_ptr(pai_root[idx].mapptr, cpu);
147 + struct pai_map *cpump = mp->mapptr;
167 148
168 - cpump = mp->mapptr;
169 - if (refcount_sub_and_test(tasks, &cpump->refcnt))
149 + mutex_lock(&pai_reserve_mutex);
150 + debug_sprintf_event(paidbg, 5, "%s event %#llx idx %d cpu %d users %d "
151 + "refcnt %u\n", __func__, event->attr.config, idx,
152 + event->cpu, cpump->active_events,
153 + refcount_read(&cpump->refcnt));
154 + if (refcount_dec_and_test(&cpump->refcnt))
170 155 pai_free(mp);
171 - pai_root_free(idx, tasks);
156 + pai_root_free(idx);
157 + mutex_unlock(&pai_reserve_mutex);
172 158 }
173 159
174 160 static void pai_event_destroy(struct perf_event *event)
175 161 {
176 - int cpu = 0, idx = PAI_PMU_IDX(event);
162 + int cpu;
177 163
178 164 free_page(PAI_SAVE_AREA(event));
179 - cpus_read_lock();
180 - mutex_lock(&pai_reserve_mutex);
181 165 if (event->cpu == -1) {
182 - atomic_dec(&pai_root[idx].tskctx);
183 - for_each_online_cpu(cpu)
184 - pai_event_destroy_cpu(idx, cpu, false);
166 + struct cpumask *mask = PAI_CPU_MASK(event);
167 +
168 + for_each_cpu(cpu, mask)
169 + pai_event_destroy_cpu(event, cpu);
170 + kfree(mask);
185 171 } else {
186 - pai_event_destroy_cpu(idx, event->cpu, false);
172 + pai_event_destroy_cpu(event, event->cpu);
187 173 }
188 - mutex_unlock(&pai_reserve_mutex);
189 - cpus_read_unlock();
190 174 }
191 175
192 176 static void paicrypt_event_destroy(struct perf_event *event)
@@ -250,30 +234,25 @@ static u64 paicrypt_getall(struct perf_event *event)
250 234 return sum;
251 235 }
252 236
253 - /* Called under mutex_lock */
254 - static int pai_alloc_cpu(int idx, int cpu, bool hotplug)
237 + /* Check concurrent access of counting and sampling for crypto events.
238 + * This function is called in process context and it is save to block.
239 + * When the event initialization functions fails, no other call back will
240 + * be invoked.
241 + *
242 + * Allocate the memory for the event.
243 + */
244 + static int pai_alloc_cpu(struct perf_event *event, int cpu)
255 245 {
246 + int rc, idx = PAI_PMU_IDX(event);
256 247 struct pai_map *cpump = NULL;
257 248 bool need_paiext_cb = false;
258 249 struct pai_mapptr *mp;
259 - int tasks = 1, rc = 0;
260 -
261 - /* When hotplug is true, invocation is from CPU hotplug callback.
262 - * Allocate per-CPU resource when per-task events are currently active.
263 - * This can be more than one. In this case adjust all reference
264 - * counters. Otherwise return, this ensures memory is only allocated
265 - * when needed.
266 - */
267 - if (hotplug) {
268 - tasks = atomic_read(&pai_root[idx].tskctx);
269 - if (!tasks)
270 - goto out;
271 - }
272 250
251 + mutex_lock(&pai_reserve_mutex);
273 252 /* Allocate root node */
274 253 rc = pai_root_alloc(idx);
275 254 if (rc)
276 - goto out;
255 + goto unlock;
277 256
278 257 /* Allocate node for this event */
279 258 mp = per_cpu_ptr(pai_root[idx].mapptr, cpu);
@@ -317,45 +296,28 @@ static int pai_alloc_cpu(int idx, int cpu, bool hotplug)
317 296 goto undo;
318 297 }
319 298 INIT_LIST_HEAD(&cpump->syswide_list);
320 - refcount_set(&cpump->refcnt, tasks);
299 + refcount_set(&cpump->refcnt, 1);
321 300 rc = 0;
322 301 } else {
323 - refcount_add(tasks, &cpump->refcnt);
302 + refcount_inc(&cpump->refcnt);
324 303 }
325 - /* If tasks is greater than 1, we are called from CPU hotplug path
326 - * and need to adjust the pai_root[idx].refcnt by the number of
327 - * per-process events. Function pai_root_alloc(idx) already
328 - * incremented by one. Adjust for the rest.
329 - */
330 - if (tasks > 1)
331 - refcount_add(tasks - 1, &pai_root[idx].refcnt);
332 304
333 305 undo:
334 306 if (rc) {
335 307 /* Error in allocation of event, decrement anchor. Since
336 308 * the event in not created, its destroy() function is never
337 309 * invoked. Adjust the reference counter for the anchor.
338 - * The failure happened in the case of variable
339 - * cpump == NULL branch above. The pai_root[XXX].refcnt has
340 - * been incremented by one. Then the per-CPU allocation
341 - * failed, so decrement it by one, regardless of tasks.
342 310 */
343 - pai_root_free(idx, 1);
311 + pai_root_free(idx);
344 312 }
345 - out:
313 + unlock:
314 + mutex_unlock(&pai_reserve_mutex);
346 315 /* If rc is non-zero, no increment of counter/sampler was done. */
347 316 return rc;
348 317 }
349 318
350 - /* Check concurrent access of counting and sampling for PAI events.
351 - * This function is called in process context and it is safe to block.
352 - * When the event initialization functions fails, no other call back will
353 - * be invoked.
354 - * Called under mutex_lock.
355 - */
356 319 static int pai_alloc(struct perf_event *event)
357 320 {
358 - int idx = PAI_PMU_IDX(event);
359 321 struct cpumask *maskptr;
360 322 int cpu, rc = -ENOMEM;
361 323
@@ -364,20 +326,24 @@ static int pai_alloc(struct perf_event *event)
364 326 goto out;
365 327
366 328 for_each_online_cpu(cpu) {
367 - rc = pai_alloc_cpu(idx, cpu, false);
329 + rc = pai_alloc_cpu(event, cpu);
368 330 if (rc) {
369 331 for_each_cpu(cpu, maskptr)
370 - pai_event_destroy_cpu(idx, cpu, false);
371 - goto undo;
332 + pai_event_destroy_cpu(event, cpu);
333 + kfree(maskptr);
334 + goto out;
372 335 }
373 336 cpumask_set_cpu(cpu, maskptr);
374 337 }
375 338
339 + /*
340 + * On error all cpumask are freed and all events have been destroyed.
341 + * Save of which CPUs data structures have been allocated for.
342 + * Release them in pai_event_destroy call back function
343 + * for this event.
344 + */
345 + PAI_CPU_MASK(event) = maskptr;
376 346 rc = 0;
377 - /* Trace per-task events for CPU hotplug. */
378 - atomic_inc(&pai_root[idx].tskctx);
379 - undo:
380 - kfree(maskptr);
381 347 out:
382 348 return rc;
383 349 }
@@ -425,14 +391,10 @@ static int pai_event_init(struct perf_event *event, int idx)
425 391 }
426 392 }
427 393
428 - cpus_read_lock();
429 - mutex_lock(&pai_reserve_mutex);
430 394 if (event->cpu >= 0)
431 - rc = pai_alloc_cpu(idx, event->cpu, false);
395 + rc = pai_alloc_cpu(event, event->cpu);
432 396 else
433 397 rc = pai_alloc(event);
434 - mutex_unlock(&pai_reserve_mutex);
435 - cpus_read_unlock();
436 398 if (rc) {
437 399 free_page(PAI_SAVE_AREA(event));
438 400 goto out;
@@ -502,7 +464,6 @@ static void pai_start(struct perf_event *event, int flags,
502 464 cpump->event = event;
503 465 }
504 466 }
505 - event->hw.state &= ~PERF_HES_STOPPED;
506 467 }
507 468
508 469 static void paicrypt_start(struct perf_event *event, int flags)
@@ -549,13 +510,6 @@ static void pai_stop(struct perf_event *event, int flags)
549 510 struct pai_mapptr *mp = this_cpu_ptr(pai_root[idx].mapptr);
550 511 struct pai_map *cpump = mp->mapptr;
551 512
552 - /* Cope with multiple invocations:
553 - * 1. perf_event_throttle() --> PMU->stop()
554 - * 2. task schedules out --> PMU->stop()
555 - * Check for event already stopped.
556 - */
557 - if (event->hw.state & PERF_HES_STOPPED)
558 - return;
559 513 if (!event->attr.sample_period) { /* Counting */
560 514 pai_pmu[idx].pmu->read(event);
561 515 } else { /* Sampling */
@@ -718,9 +672,9 @@ static void pai_have_samples(int idx)
718 672 {
719 673 struct pai_mapptr *mp = this_cpu_ptr(pai_root[idx].mapptr);
720 674 struct pai_map *cpump = mp->mapptr;
721 - struct perf_event *event, *e2;
675 + struct perf_event *event;
722 676
723 - 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)
724 678 pai_have_sample(event, cpump);
725 679 }
726 680
@@ -737,17 +691,6 @@ static void paicrypt_sched_task(struct perf_event_pmu_context *pmu_ctx,
737 691 pai_have_samples(PAI_PMU_CRYPTO);
738 692 }
739 693
740 - /* Prevent ioctl(fd, PERF_EVENT_IOC_PERIOD, ...) call.
741 - * It sets perf_event::event_limit to a positive value and causes
742 - * perf_event_overflow() to invoke pai_stop() call back function when
743 - * perf_event::event_limit hits zero. This is not supported because the
744 - * sample events CRYPTO_ALL and NNPA_ALL are always taken at schedule out
745 - * of a task.
746 - */
747 - static int pai_check_period(struct perf_event *event, u64 value)
748 - {
749 - return -EINVAL;
750 - }
751 694 /* ============================= paiext ====================================*/
752 695
753 696 static void paiext_event_destroy(struct perf_event *event)
@@ -861,7 +804,6 @@ static struct pmu paicrypt = {
861 804 .stop = paicrypt_stop,
862 805 .read = paicrypt_read,
863 806 .sched_task = paicrypt_sched_task,
864 - .check_period = pai_check_period,
865 807 .attr_groups = paicrypt_attr_groups
866 808 };
867 809
@@ -1073,7 +1015,6 @@ static struct pmu paiext = {
1073 1015 .stop = paiext_stop,
1074 1016 .read = paiext_read,
1075 1017 .sched_task = paiext_sched_task,
1076 - .check_period = pai_check_period,
1077 1018 .attr_groups = paiext_attr_groups,
1078 1019 };
1079 1020
@@ -1277,61 +1218,23 @@ static int __init paipmu_setup(void)
1277 1218 return install_ok;
1278 1219 }
1279 1220
1280 - static int pai_online_cpu(unsigned int cpu)
1281 - {
1282 - int rc;
1283 -
1284 - mutex_lock(&pai_reserve_mutex);
1285 - rc = pai_alloc_cpu(PAI_PMU_CRYPTO, cpu, true);
1286 - if (rc)
1287 - goto out;
1288 - rc = pai_alloc_cpu(PAI_PMU_EXT, cpu, true);
1289 - if (rc)
1290 - pai_event_destroy_cpu(PAI_PMU_CRYPTO, cpu, true);
1291 - out:
1292 - mutex_unlock(&pai_reserve_mutex);
1293 - return rc;
1294 - }
1295 -
1296 - static int pai_offline_cpu(unsigned int cpu)
1297 - {
1298 - mutex_lock(&pai_reserve_mutex);
1299 - pai_event_destroy_cpu(PAI_PMU_CRYPTO, cpu, true);
1300 - pai_event_destroy_cpu(PAI_PMU_EXT, cpu, true);
1301 - mutex_unlock(&pai_reserve_mutex);
1302 - return 0;
1303 - }
1304 -
1305 1221 static int __init pai_init(void)
1306 1222 {
1307 - int state, rc;
1308 -
1309 1223 /* Setup s390dbf facility */
1310 - paidbg = debug_register("pai", 1, 1, 128);
1224 + paidbg = debug_register("pai", 32, 256, 128);
1311 1225 if (!paidbg) {
1312 1226 pr_err("Registration of s390dbf pai failed\n");
1313 1227 return -ENOMEM;
1314 1228 }
1315 1229 debug_register_view(paidbg, &debug_sprintf_view);
1316 1230
1317 - /* CPUHP_BP_PREPARE_DYN --> before CPU is brought online */
1318 - state = cpuhp_setup_state(CPUHP_BP_PREPARE_DYN, "perf/pai:prepare",
1319 - pai_online_cpu, pai_offline_cpu);
1320 - rc = state < 0 ? state : 0;
1321 - if (rc < 0)
1322 - goto out_debug;
1323 -
1324 - rc = -ENODEV;
1325 - if (!paipmu_setup())
1326 - goto out_cpuhp;
1231 + if (!paipmu_setup()) {
1232 + /* No PMU registration, no need for debug buffer */
1233 + debug_unregister_view(paidbg, &debug_sprintf_view);
1234 + debug_unregister(paidbg);
1235 + return -ENODEV;
1236 + }
1327 1237 return 0;
1328 -
1329 - out_cpuhp:
1330 - cpuhp_remove_state(state);
1331 - out_debug:
1332 - debug_unregister_view(paidbg, &debug_sprintf_view);
1333 - debug_unregister(paidbg);
1334 - return rc;
1335 1238 }
1336 1239
1337 1240 device_initcall(pai_init);
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/crypto/aria-aesni-avx2-asm_64.S
@@ -982,7 +982,6 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_encrypt_32way)
982 982 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
983 983 %ymm15, %rax);
984 984
985 - vzeroupper;
986 985 FRAME_END
987 986 RET;
988 987 SYM_FUNC_END(aria_aesni_avx2_encrypt_32way)
@@ -1008,7 +1007,6 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_decrypt_32way)
1008 1007 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
1009 1008 %ymm15, %rax);
1010 1009
1011 - vzeroupper;
1012 1010 FRAME_END
1013 1011 RET;
1014 1012 SYM_FUNC_END(aria_aesni_avx2_decrypt_32way)
@@ -1211,7 +1209,6 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_ctr_crypt_32way)
1211 1209 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
1212 1210 %ymm15, %r10);
1213 1211
1214 - vzeroupper;
1215 1212 FRAME_END
1216 1213 RET;
1217 1214 SYM_FUNC_END(aria_aesni_avx2_ctr_crypt_32way)
@@ -1362,7 +1359,6 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_gfni_encrypt_32way)
1362 1359 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
1363 1360 %ymm15, %rax);
1364 1361
1365 - vzeroupper;
1366 1362 FRAME_END
1367 1363 RET;
1368 1364 SYM_FUNC_END(aria_aesni_avx2_gfni_encrypt_32way)
@@ -1388,7 +1384,6 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_gfni_decrypt_32way)
1388 1384 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
1389 1385 %ymm15, %rax);
1390 1386
1391 - vzeroupper;
1392 1387 FRAME_END
1393 1388 RET;
1394 1389 SYM_FUNC_END(aria_aesni_avx2_gfni_decrypt_32way)
@@ -1433,7 +1428,6 @@ SYM_TYPED_FUNC_START(aria_aesni_avx2_gfni_ctr_crypt_32way)
1433 1428 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
1434 1429 %ymm15, %r10);
1435 1430
1436 - vzeroupper;
1437 1431 FRAME_END
1438 1432 RET;
1439 1433 SYM_FUNC_END(aria_aesni_avx2_gfni_ctr_crypt_32way)
modified arch/x86/crypto/aria-gfni-avx512-asm_64.S
@@ -800,7 +800,6 @@ SYM_TYPED_FUNC_START(aria_gfni_avx512_encrypt_64way)
800 800 %zmm9, %zmm8, %zmm11, %zmm10, %zmm12, %zmm13, %zmm14,
801 801 %zmm15, %rax);
802 802
803 - vzeroupper;
804 803 FRAME_END
805 804 RET;
806 805 SYM_FUNC_END(aria_gfni_avx512_encrypt_64way)
@@ -826,7 +825,6 @@ SYM_TYPED_FUNC_START(aria_gfni_avx512_decrypt_64way)
826 825 %zmm9, %zmm8, %zmm11, %zmm10, %zmm12, %zmm13, %zmm14,
827 826 %zmm15, %rax);
828 827
829 - vzeroupper;
830 828 FRAME_END
831 829 RET;
832 830 SYM_FUNC_END(aria_gfni_avx512_decrypt_64way)
@@ -968,7 +966,6 @@ SYM_TYPED_FUNC_START(aria_gfni_avx512_ctr_crypt_64way)
968 966 %zmm9, %zmm8, %zmm11, %zmm10, %zmm12, %zmm13, %zmm14,
969 967 %zmm15, %r10);
970 968
971 - vzeroupper;
972 969 FRAME_END
973 970 RET;
974 971 SYM_FUNC_END(aria_gfni_avx512_ctr_crypt_64way)
modified arch/x86/events/intel/core.c
@@ -3125,27 +3125,6 @@ static void intel_pmu_del_event(struct perf_event *event)
3125 3125 this_cpu_ptr(&cpu_hw_events)->n_late_setup--;
3126 3126 }
3127 3127
3128 - int __intel_pmu_quiesce(void)
3129 - {
3130 - struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
3131 - int pmu_enabled = cpuc->enabled;
3132 -
3133 - cpuc->enabled = 0;
3134 - if (pmu_enabled)
3135 - intel_pmu_disable_all();
3136 -
3137 - return pmu_enabled;
3138 - }
3139 -
3140 - void __intel_pmu_resume(int pmu_enabled)
3141 - {
3142 - struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
3143 -
3144 - cpuc->enabled = pmu_enabled;
3145 - if (pmu_enabled)
3146 - intel_pmu_enable_all(0);
3147 - }
3148 -
3149 3128 static int icl_set_topdown_event_period(struct perf_event *event)
3150 3129 {
3151 3130 struct hw_perf_event *hwc = &event->hw;
@@ -3337,13 +3316,16 @@ static void intel_pmu_read_event(struct perf_event *event)
3337 3316 if (event->hw.flags & (PERF_X86_EVENT_AUTO_RELOAD | PERF_X86_EVENT_TOPDOWN) ||
3338 3317 is_pebs_counter_event_group(event)) {
3339 3318 struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
3340 - int pmu_enabled;
3319 + bool pmu_enabled = cpuc->enabled;
3341 3320
3342 3321 /* Only need to call update_topdown_event() once for group read. */
3343 3322 if (is_metric_event(event) && (cpuc->txn_flags & PERF_PMU_TXN_READ))
3344 3323 return;
3345 3324
3346 - pmu_enabled = __intel_pmu_quiesce();
3325 + cpuc->enabled = 0;
3326 + if (pmu_enabled)
3327 + intel_pmu_disable_all();
3328 +
3347 3329 /*
3348 3330 * If the PEBS counters snapshotting is enabled,
3349 3331 * the topdown event is available in PEBS records.
@@ -3352,7 +3334,10 @@ static void intel_pmu_read_event(struct perf_event *event)
3352 3334 static_call(intel_pmu_update_topdown_event)(event, NULL);
3353 3335 else
3354 3336 intel_pmu_drain_pebs_buffer();
3355 - __intel_pmu_resume(pmu_enabled);
3337 +
3338 + cpuc->enabled = pmu_enabled;
3339 + if (pmu_enabled)
3340 + intel_pmu_enable_all(0);
3356 3341
3357 3342 return;
3358 3343 }
modified arch/x86/events/intel/ds.c
@@ -1242,11 +1242,8 @@ unlock:
1242 1242
1243 1243 void intel_pmu_drain_pebs_buffer(void)
1244 1244 {
1245 - struct cpu_hw_events *cpuc = this_cpu_ptr(&cpu_hw_events);
1246 1245 struct perf_sample_data data;
1247 1246
1248 - WARN_ON_ONCE(cpuc->enabled);
1249 -
1250 1247 static_call(x86_pmu_drain_pebs)(NULL, &data);
1251 1248 }
1252 1249
@@ -1867,11 +1864,8 @@ static void intel_pmu_pebs_via_pt_enable(struct perf_event *event)
1867 1864 static inline void intel_pmu_drain_large_pebs(struct cpu_hw_events *cpuc)
1868 1865 {
1869 1866 if (cpuc->n_pebs == cpuc->n_large_pebs &&
1870 - cpuc->n_pebs != cpuc->n_pebs_via_pt) {
1871 - int enabled = __intel_pmu_quiesce();
1867 + cpuc->n_pebs != cpuc->n_pebs_via_pt)
1872 1868 intel_pmu_drain_pebs_buffer();
1873 - __intel_pmu_resume(enabled);
1874 - }
1875 1869 }
1876 1870
1877 1871 static void __intel_pmu_pebs_enable(struct perf_event *event)
@@ -2438,7 +2432,7 @@ static inline void __setup_pebs_basic_group(struct perf_event *event,
2438 2432 {
2439 2433 /* The ip in basic is EventingIP */
2440 2434 set_linear_ip(regs, ip);
2441 - regs->flags |= PERF_EFLAGS_EXACT;
2435 + regs->flags = PERF_EFLAGS_EXACT;
2442 2436 setup_pebs_time(event, data, tsc);
2443 2437
2444 2438 if (sample_type & PERF_SAMPLE_WEIGHT_STRUCT)
@@ -2450,17 +2444,9 @@ static inline void __setup_pebs_gpr_group(struct perf_event *event,
2450 2444 struct pebs_gprs *gprs,
2451 2445 u64 sample_type)
2452 2446 {
2453 - /*
2454 - * Update flags with PEBS data. PERF_EFLAGS_EXACT must be set
2455 - * in previous basic group handling.
2456 - */
2457 - regs->flags = gprs->flags | PERF_EFLAGS_EXACT;
2458 -
2459 2447 if (event->attr.precise_ip < 2) {
2460 2448 set_linear_ip(regs, gprs->ip);
2461 2449 regs->flags &= ~PERF_EFLAGS_EXACT;
2462 - } else if (regs->flags & X86_VM_MASK) {
2463 - regs->flags ^= (PERF_EFLAGS_VM | X86_VM_MASK);
2464 2450 }
2465 2451
2466 2452 if (sample_type & (PERF_SAMPLE_REGS_INTR | PERF_SAMPLE_REGS_USER))
modified arch/x86/events/perf_event.h
@@ -1638,9 +1638,6 @@ static __always_inline void __intel_pmu_lbr_disable(void)
1638 1638 wrmsrq(MSR_IA32_DEBUGCTLMSR, debugctl);
1639 1639 }
1640 1640
1641 - extern int __intel_pmu_quiesce(void);
1642 - extern void __intel_pmu_resume(int pmu_enabled);
1643 -
1644 1641 int intel_pmu_save_and_restart(struct perf_event *event);
1645 1642
1646 1643 struct event_constraint *
modified arch/x86/kernel/amd_node.c
@@ -38,6 +38,7 @@ static struct pci_dev **amd_roots;
38 38
39 39 /* Protect the PCI config register pairs used for SMN. */
40 40 static DEFINE_MUTEX(smn_mutex);
41 + static bool smn_exclusive;
41 42
42 43 #define SMN_INDEX_OFFSET 0x60
43 44 #define SMN_DATA_OFFSET 0x64
@@ -90,18 +91,13 @@ static int __amd_smn_rw(u8 i_off, u8 d_off, u16 node, u32 address, u32 *value, b
90 91 if (node >= amd_num_nodes())
91 92 return err;
92 93
93 - /*
94 - * Uninitialized amd_roots indicates pci_request_config_region_exclusive()
95 - * didn't run or failed and thus the kernel cannot rely on having
96 - * exclusive access to SMN registers so prevent that.
97 - */
98 - if (!amd_roots)
99 - return err;
100 -
101 94 root = amd_roots[node];
102 95 if (!root)
103 96 return err;
104 97
98 + if (!smn_exclusive)
99 + return err;
100 +
105 101 guard(mutex)(&smn_mutex);
106 102
107 103 err = pci_write_config_dword(root, i_off, address);
@@ -291,11 +287,6 @@ static int __init amd_smn_init(void)
291 287 return -ENOMEM;
292 288
293 289 roots_per_node = num_roots / num_nodes;
294 - if (!roots_per_node) {
295 - if (!cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
296 - pr_warn(FW_BUG "Error detecting roots per node.\n");
297 - roots_per_node = 1;
298 - }
299 290
300 291 count = 0;
301 292 node = 0;
@@ -317,6 +308,8 @@ static int __init amd_smn_init(void)
317 308 debugfs_create_file("value", 0600, debugfs_dir, NULL, &smn_value_fops);
318 309 }
319 310
311 + smn_exclusive = true;
312 +
320 313 return 0;
321 314 }
322 315
modified arch/x86/kernel/cpu/mce/amd.c
@@ -865,7 +865,7 @@ static void amd_deferred_error_interrupt(void)
865 865
866 866 void mce_amd_handle_storm(unsigned int bank, bool on)
867 867 {
868 - threshold_restart_bank(bank, !on);
868 + threshold_restart_bank(bank, on);
869 869 }
870 870
871 871 static void amd_reset_thr_limit(unsigned int bank)
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/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/Kconfig
@@ -6,7 +6,6 @@ config DRM_ACCEL_AMDXDNA
6 6 depends on DRM_ACCEL
7 7 depends on PCI && HAS_IOMEM
8 8 depends on X86_64
9 - depends on AMD_PMF || !AMD_PMF
10 9 select DRM_SCHED
11 10 select DRM_GEM_SHMEM_HELPER
12 11 select FW_LOADER
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_device.h
@@ -87,7 +87,6 @@ struct gen_pool;
87 87 #define PMU_EV_TYPE_IDLE 0x20
88 88
89 89 enum ethosu_cmds {
90 - NPU_OP_STOP = 0x0,
91 90 NPU_OP_CONV = 0x2,
92 91 NPU_OP_DEPTHWISE = 0x3,
93 92 NPU_OP_POOL = 0x5,
modified drivers/accel/ethosu/ethosu_drv.c
@@ -281,6 +281,8 @@ static int ethosu_device_suspend(struct device *dev)
281 281
282 282 static int ethosu_sram_init(struct ethosu_device *ethosudev)
283 283 {
284 + ethosudev->npu_info.sram_size = 0;
285 +
284 286 ethosudev->srampool = of_gen_pool_get(ethosudev->base.dev->of_node, "sram", 0);
285 287 if (!ethosudev->srampool)
286 288 return 0;
@@ -291,7 +293,6 @@ static int ethosu_sram_init(struct ethosu_device *ethosudev)
291 293 ethosudev->npu_info.sram_size,
292 294 &ethosudev->sramphys);
293 295 if (!ethosudev->sram) {
294 - ethosudev->npu_info.sram_size = 0;
295 296 dev_err(ethosudev->base.dev, "failed to allocate from SRAM pool\n");
296 297 return -ENOMEM;
297 298 }
@@ -355,8 +356,6 @@ static int ethosu_probe(struct platform_device *pdev)
355 356 dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(40));
356 357
357 358 ethosudev->regs = devm_platform_ioremap_resource(pdev, 0);
358 - if (IS_ERR(ethosudev->regs))
359 - return PTR_ERR(ethosudev->regs);
360 359 ethosudev->pmu_regs = ethosudev->regs;
361 360
362 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
@@ -390,7 +390,6 @@ static int ethosu_gem_cmdstream_copy_and_validate(struct drm_device *ddev,
390 390 struct ethosu_validated_cmdstream_info __free(kfree) *info = kzalloc_obj(*info);
391 391 struct ethosu_device *edev = to_ethosu_device(ddev);
392 392 u32 *bocmds = bo->base.vaddr;
393 - bool ends_with_stop = false;
394 393 struct cmd_state st;
395 394 int i, ret;
396 395
@@ -427,11 +426,6 @@ static int ethosu_gem_cmdstream_copy_and_validate(struct drm_device *ddev,
427 426 }
428 427
429 428 switch (cmd) {
430 - case NPU_OP_STOP:
431 - if (i != size / 4 - 1)
432 - return -EINVAL;
433 - ends_with_stop = true;
434 - break;
435 429 case NPU_OP_DMA_START:
436 430 srclen = dma_length(info, &st.dma, &st.dma.src);
437 431 dstlen = dma_length(info, &st.dma, &st.dma.dst);
@@ -694,9 +688,6 @@ static int ethosu_gem_cmdstream_copy_and_validate(struct drm_device *ddev,
694 688 }
695 689 }
696 690
697 - if (!ends_with_stop)
698 - return -EINVAL;
699 -
700 691 for (i = 0; i < NPU_BASEP_REGION_MAX; i++) {
701 692 if (!info->region_size[i])
702 693 continue;
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);
@@ -343,7 +337,7 @@ int ethosu_job_init(struct ethosu_device *edev)
343 337 ret = devm_request_threaded_irq(dev, edev->irq,
344 338 ethosu_job_irq_handler,
345 339 ethosu_job_irq_handler_thread,
346 - 0, KBUILD_MODNAME,
340 + IRQF_SHARED, KBUILD_MODNAME,
347 341 edev);
348 342 if (ret) {
349 343 dev_err(dev, "failed to request irq\n");
@@ -374,10 +368,12 @@ int ethosu_job_open(struct ethosu_file_priv *ethosu_priv)
374 368 {
375 369 struct ethosu_device *dev = ethosu_priv->edev;
376 370 struct drm_gpu_scheduler *sched = &dev->sched;
371 + int ret;
377 372
378 - return drm_sched_entity_init(&ethosu_priv->sched_entity,
379 - DRM_SCHED_PRIORITY_NORMAL,
380 - &sched, 1, NULL);
373 + ret = drm_sched_entity_init(&ethosu_priv->sched_entity,
374 + DRM_SCHED_PRIORITY_NORMAL,
375 + &sched, 1, NULL);
376 + return WARN_ON(ret);
381 377 }
382 378
383 379 void ethosu_job_close(struct ethosu_file_priv *ethosu_priv)
@@ -419,7 +415,7 @@ static int ethosu_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
419 415 ejob->done_fence = kzalloc_obj(*ejob->done_fence);
420 416 if (!ejob->done_fence) {
421 417 ret = -ENOMEM;
422 - goto out_put_job;
418 + goto out_cleanup_job;
423 419 }
424 420
425 421 ret = drm_sched_job_init(&ejob->base,
@@ -447,13 +443,13 @@ static int ethosu_ioctl_submit_job(struct drm_device *dev, struct drm_file *file
447 443 if (!cmd_info->region_size[i])
448 444 continue;
449 445 if (i == ETHOSU_SRAM_REGION) {
450 - if (cmd_info->region_size[i] <= ejob->sram_size)
446 + if (cmd_info->region_size[i] <= edev->npu_info.sram_size)
451 447 continue;
452 448
453 449 dev_err(dev->dev,
454 - "cmd stream region %d size greater than job SRAM size (%llu > %u)\n",
450 + "cmd stream region %d size greater than SRAM size (%llu > %u)\n",
455 451 i, cmd_info->region_size[i],
456 - ejob->sram_size);
452 + edev->npu_info.sram_size);
457 453 ret = -EINVAL;
458 454 goto out_cleanup_job;
459 455 }
modified drivers/accel/ivpu/ivpu_drv.c
@@ -515,7 +515,6 @@ void ivpu_prepare_for_reset(struct ivpu_device *vdev)
515 515 {
516 516 ivpu_hw_irq_disable(vdev);
517 517 disable_irq(vdev->irq);
518 - atomic_set(&vdev->job_timeout_detected, 0);
519 518 flush_work(&vdev->irq_dct_work);
520 519 flush_work(&vdev->context_abort_work);
521 520 flush_work(&vdev->job_destroy_work);
@@ -711,7 +710,7 @@ static int ivpu_dev_init(struct ivpu_device *vdev)
711 710 vdev->context_xa_limit.max = IVPU_USER_CONTEXT_MAX_SSID;
712 711 atomic64_set(&vdev->unique_id_counter, 0);
713 712 atomic_set(&vdev->job_timeout_counter, 0);
714 - atomic_set(&vdev->job_timeout_detected, 0);
713 + atomic_set(&vdev->faults_detected, 0);
715 714 xa_init_flags(&vdev->context_xa, XA_FLAGS_ALLOC | XA_FLAGS_LOCK_IRQ);
716 715 xa_init_flags(&vdev->submitted_jobs_xa, XA_FLAGS_ALLOC1);
717 716 xa_init_flags(&vdev->db_xa, XA_FLAGS_ALLOC1);
modified drivers/accel/ivpu/ivpu_drv.h
@@ -171,7 +171,7 @@ struct ivpu_device {
171 171 struct xarray submitted_jobs_xa;
172 172 struct ivpu_ipc_consumer job_done_consumer;
173 173 atomic_t job_timeout_counter;
174 - atomic_t job_timeout_detected;
174 + atomic_t faults_detected;
175 175
176 176 atomic64_t unique_id_counter;
177 177
modified drivers/accel/ivpu/ivpu_fw_log.c
@@ -26,17 +26,10 @@ MODULE_PARM_DESC(fw_log_level,
26 26 " error=" __stringify(IVPU_FW_LOG_ERROR)
27 27 " fatal=" __stringify(IVPU_FW_LOG_FATAL));
28 28
29 - struct ivpu_fw_log_desc {
30 - struct vpu_tracing_buffer_header *log;
31 - u32 header_size;
32 - u32 size;
33 - };
34 -
35 29 static int fw_log_from_bo(struct ivpu_device *vdev, struct ivpu_bo *bo, u32 *offset,
36 - struct ivpu_fw_log_desc *desc)
30 + struct vpu_tracing_buffer_header **out_log)
37 31 {
38 32 struct vpu_tracing_buffer_header *log;
39 - u32 header_size, size;
40 33
41 34 if ((*offset + sizeof(*log)) > ivpu_bo_size(bo))
42 35 return -EINVAL;
@@ -46,32 +39,26 @@ static int fw_log_from_bo(struct ivpu_device *vdev, struct ivpu_bo *bo, u32 *off
46 39 if (log->vpu_canary_start != VPU_TRACING_BUFFER_CANARY)
47 40 return -EINVAL;
48 41
49 - header_size = READ_ONCE(log->header_size);
50 - size = READ_ONCE(log->size);
51 -
52 - if (header_size < sizeof(*log) || header_size > 1024) {
53 - ivpu_dbg(vdev, FW_BOOT, "Invalid header size 0x%x\n", header_size);
42 + if (log->header_size < sizeof(*log) || log->header_size > 1024) {
43 + ivpu_dbg(vdev, FW_BOOT, "Invalid header size 0x%x\n", log->header_size);
54 44 return -EINVAL;
55 45 }
56 - if ((char *)log + size > (char *)ivpu_bo_vaddr(bo) + ivpu_bo_size(bo)) {
57 - ivpu_dbg(vdev, FW_BOOT, "Invalid log size 0x%x\n", size);
46 + if (log->size < log->header_size) {
47 + ivpu_dbg(vdev, FW_BOOT, "Invalid log size 0x%x\n", log->size);
58 48 return -EINVAL;
59 49 }
60 - if (size < header_size) {
61 - ivpu_dbg(vdev, FW_BOOT, "Invalid log size 0x%x < header size 0x%x\n",
62 - size, header_size);
50 + if ((char *)log + log->size > (char *)ivpu_bo_vaddr(bo) + ivpu_bo_size(bo)) {
51 + ivpu_dbg(vdev, FW_BOOT, "Invalid log size 0x%x\n", log->size);
63 52 return -EINVAL;
64 53 }
65 54
66 - desc->log = log;
67 - desc->header_size = header_size;
68 - desc->size = size;
69 - *offset += size;
55 + *out_log = log;
56 + *offset += log->size;
70 57
71 58 ivpu_dbg(vdev, FW_BOOT,
72 - "FW log name \"%.*s\", write offset 0x%x size 0x%x, wrap count %d, hdr version %d size %d format %d, alignment %d",
73 - (int)ARRAY_SIZE(log->name), log->name, log->write_index, size, log->wrap_count,
74 - log->header_version, header_size, log->format, log->alignment);
59 + "FW log name \"%s\", write offset 0x%x size 0x%x, wrap count %d, hdr version %d size %d format %d, alignment %d",
60 + log->name, log->write_index, log->size, log->wrap_count, log->header_version,
61 + log->header_size, log->format, log->alignment);
75 62
76 63 return 0;
77 64 }
@@ -107,12 +94,11 @@ static void fw_log_print_lines(char *buffer, u32 size, struct drm_printer *p)
107 94 drm_printf(p, "%s", line);
108 95 }
109 96
110 - static void fw_log_print_buffer(struct ivpu_fw_log_desc *desc, const char *prefix,
97 + static void fw_log_print_buffer(struct vpu_tracing_buffer_header *log, const char *prefix,
111 98 bool only_new_msgs, struct drm_printer *p)
112 99 {
113 - struct vpu_tracing_buffer_header *log = desc->log;
114 - char *log_data = (void *)log + desc->header_size;
115 - u32 data_size = desc->size - desc->header_size;
100 + char *log_data = (void *)log + log->header_size;
101 + u32 data_size = log->size - log->header_size;
116 102 u32 log_start = only_new_msgs ? READ_ONCE(log->read_index) : 0;
117 103 u32 log_end = READ_ONCE(log->write_index);
118 104
@@ -123,8 +109,7 @@ static void fw_log_print_buffer(struct ivpu_fw_log_desc *desc, const char *prefi
123 109
124 110 if (log->wrap_count == log->read_wrap_count) {
125 111 if (log_end <= log_start) {
126 - drm_printf(p, "==== %s \"%.*s\" log empty ====\n", prefix,
127 - (int)ARRAY_SIZE(log->name), log->name);
112 + drm_printf(p, "==== %s \"%s\" log empty ====\n", prefix, log->name);
128 113 return;
129 114 }
130 115 } else if (log->wrap_count == log->read_wrap_count + 1) {
@@ -134,8 +119,7 @@ static void fw_log_print_buffer(struct ivpu_fw_log_desc *desc, const char *prefi
134 119 log_start = log_end;
135 120 }
136 121
137 - drm_printf(p, "==== %s \"%.*s\" log start ====\n", prefix, (int)ARRAY_SIZE(log->name),
138 - log->name);
122 + drm_printf(p, "==== %s \"%s\" log start ====\n", prefix, log->name);
139 123 if (log_end > log_start) {
140 124 fw_log_print_lines(log_data + log_start, log_end - log_start, p);
141 125 } else {
@@ -143,19 +127,18 @@ static void fw_log_print_buffer(struct ivpu_fw_log_desc *desc, const char *prefi
143 127 fw_log_print_lines(log_data, log_end, p);
144 128 }
145 129 drm_printf(p, "\n\x1b[0m"); /* add new line and clear formatting */
146 - drm_printf(p, "==== %s \"%.*s\" log end ====\n", prefix, (int)ARRAY_SIZE(log->name),
147 - log->name);
130 + drm_printf(p, "==== %s \"%s\" log end ====\n", prefix, log->name);
148 131 }
149 132
150 133 static void
151 134 fw_log_print_all_in_bo(struct ivpu_device *vdev, const char *name,
152 135 struct ivpu_bo *bo, bool only_new_msgs, struct drm_printer *p)
153 136 {
154 - struct ivpu_fw_log_desc desc;
137 + struct vpu_tracing_buffer_header *log;
155 138 u32 next = 0;
156 139
157 - while (fw_log_from_bo(vdev, bo, &next, &desc) == 0)
158 - fw_log_print_buffer(&desc, name, only_new_msgs, p);
140 + while (fw_log_from_bo(vdev, bo, &next, &log) == 0)
141 + fw_log_print_buffer(log, name, only_new_msgs, p);
159 142 }
160 143
161 144 void ivpu_fw_log_print(struct ivpu_device *vdev, bool only_new_msgs, struct drm_printer *p)
@@ -166,36 +149,36 @@ void ivpu_fw_log_print(struct ivpu_device *vdev, bool only_new_msgs, struct drm_
166 149
167 150 void ivpu_fw_log_mark_read(struct ivpu_device *vdev)
168 151 {
169 - struct ivpu_fw_log_desc desc;
152 + struct vpu_tracing_buffer_header *log;
170 153 u32 next;
171 154
172 155 next = 0;
173 - while (fw_log_from_bo(vdev, vdev->fw->mem_log_crit, &next, &desc) == 0) {
174 - desc.log->read_index = READ_ONCE(desc.log->write_index);
175 - desc.log->read_wrap_count = READ_ONCE(desc.log->wrap_count);
156 + while (fw_log_from_bo(vdev, vdev->fw->mem_log_crit, &next, &log) == 0) {
157 + log->read_index = READ_ONCE(log->write_index);
158 + log->read_wrap_count = READ_ONCE(log->wrap_count);
176 159 }
177 160
178 161 next = 0;
179 - while (fw_log_from_bo(vdev, vdev->fw->mem_log_verb, &next, &desc) == 0) {
180 - desc.log->read_index = READ_ONCE(desc.log->write_index);
181 - desc.log->read_wrap_count = READ_ONCE(desc.log->wrap_count);
162 + while (fw_log_from_bo(vdev, vdev->fw->mem_log_verb, &next, &log) == 0) {
163 + log->read_index = READ_ONCE(log->write_index);
164 + log->read_wrap_count = READ_ONCE(log->wrap_count);
182 165 }
183 166 }
184 167
185 168 void ivpu_fw_log_reset(struct ivpu_device *vdev)
186 169 {
187 - struct ivpu_fw_log_desc desc;
170 + struct vpu_tracing_buffer_header *log;
188 171 u32 next;
189 172
190 173 next = 0;
191 - while (fw_log_from_bo(vdev, vdev->fw->mem_log_crit, &next, &desc) == 0) {
192 - desc.log->read_index = 0;
193 - desc.log->read_wrap_count = 0;
174 + while (fw_log_from_bo(vdev, vdev->fw->mem_log_crit, &next, &log) == 0) {
175 + log->read_index = 0;
176 + log->read_wrap_count = 0;
194 177 }
195 178
196 179 next = 0;
197 - while (fw_log_from_bo(vdev, vdev->fw->mem_log_verb, &next, &desc) == 0) {
198 - desc.log->read_index = 0;
199 - desc.log->read_wrap_count = 0;
180 + while (fw_log_from_bo(vdev, vdev->fw->mem_log_verb, &next, &log) == 0) {
181 + log->read_index = 0;
182 + log->read_wrap_count = 0;
200 183 }
201 184 }
modified drivers/accel/ivpu/ivpu_gem.h
@@ -87,23 +87,15 @@ static inline bool ivpu_bo_is_resident(struct ivpu_bo *bo)
87 87 return !!bo->base.pages;
88 88 }
89 89
90 - static inline void *ivpu_to_cpu_addr(struct ivpu_bo *bo, u64 vpu_addr, u64 size)
90 + static inline void *ivpu_to_cpu_addr(struct ivpu_bo *bo, u32 vpu_addr)
91 91 {
92 - u64 bo_size = ivpu_bo_size(bo);
93 - u64 offset;
94 -
95 92 if (vpu_addr < bo->vpu_addr)
96 93 return NULL;
97 94
98 - if (size > bo_size)
99 - return NULL;
100 -
101 - offset = vpu_addr - bo->vpu_addr;
102 -
103 - if (offset > bo_size - size)
95 + if (vpu_addr >= (bo->vpu_addr + ivpu_bo_size(bo)))
104 96 return NULL;
105 97
106 - return ivpu_bo_vaddr(bo) + offset;
98 + return ivpu_bo_vaddr(bo) + (vpu_addr - bo->vpu_addr);
107 99 }
108 100
109 101 static inline u32 cpu_to_vpu_addr(struct ivpu_bo *bo, void *cpu_addr)
modified drivers/accel/ivpu/ivpu_ipc.c
@@ -79,7 +79,7 @@ ivpu_ipc_tx_prepare(struct ivpu_device *vdev, struct ivpu_ipc_consumer *cons,
79 79 return -ENOMEM;
80 80 }
81 81
82 - tx_buf = ivpu_to_cpu_addr(ipc->mem_tx, tx_buf_vpu_addr, sizeof(*tx_buf));
82 + tx_buf = ivpu_to_cpu_addr(ipc->mem_tx, tx_buf_vpu_addr);
83 83 if (drm_WARN_ON(&vdev->drm, !tx_buf)) {
84 84 gen_pool_free(ipc->mm_tx, tx_buf_vpu_addr, sizeof(*tx_buf));
85 85 return -EIO;
@@ -420,7 +420,7 @@ void ivpu_ipc_irq_handler(struct ivpu_device *vdev)
420 420 return;
421 421 }
422 422
423 - ipc_hdr = ivpu_to_cpu_addr(ipc->mem_rx, vpu_addr, sizeof(*ipc_hdr));
423 + ipc_hdr = ivpu_to_cpu_addr(ipc->mem_rx, vpu_addr);
424 424 if (!ipc_hdr) {
425 425 ivpu_warn_ratelimited(vdev, "IPC msg 0x%x out of range\n", vpu_addr);
426 426 continue;
@@ -429,8 +429,7 @@ void ivpu_ipc_irq_handler(struct ivpu_device *vdev)
429 429
430 430 jsm_msg = NULL;
431 431 if (ipc_hdr->channel != IVPU_IPC_CHAN_BOOT_MSG) {
432 - jsm_msg = ivpu_to_cpu_addr(ipc->mem_rx, ipc_hdr->data_addr,
433 - sizeof(*jsm_msg));
432 + jsm_msg = ivpu_to_cpu_addr(ipc->mem_rx, ipc_hdr->data_addr);
434 433 if (!jsm_msg) {
435 434 ivpu_warn_ratelimited(vdev, "JSM msg 0x%x out of range\n",
436 435 ipc_hdr->data_addr);
modified drivers/accel/ivpu/ivpu_job.c
@@ -621,6 +621,7 @@ bool ivpu_job_handle_engine_error(struct ivpu_device *vdev, u32 job_id, u32 job_
621 621 * status and ensure both are handled in the same way
622 622 */
623 623 job->file_priv->has_mmu_faults = true;
624 + atomic_set(&vdev->faults_detected, 1);
624 625 queue_work(system_percpu_wq, &vdev->context_abort_work);
625 626 return true;
626 627 }
@@ -1174,10 +1175,10 @@ static int reset_engine_and_mark_faulty_contexts(struct ivpu_device *vdev)
1174 1175 return ret;
1175 1176
1176 1177 /*
1177 - * If job timeout is detected, read guilty context from engine reset, for other reasons
1178 - * faulty context is already known
1178 + * If faults are detected, ignore guilty contexts from engine reset as NPU may not be stuck
1179 + * and could return currently running good context and faulty contexts are already marked
1179 1180 */
1180 - if (atomic_cmpxchg(&vdev->job_timeout_detected, 1, 0) == 0)
1181 + if (atomic_cmpxchg(&vdev->faults_detected, 1, 0) == 1)
1181 1182 return 0;
1182 1183
1183 1184 num_impacted_contexts = resp.payload.engine_reset_done.num_impacted_contexts;
modified drivers/accel/ivpu/ivpu_mmu.c
@@ -964,6 +964,7 @@ void ivpu_mmu_irq_evtq_handler(struct ivpu_device *vdev)
964 964 file_priv = xa_load(&vdev->context_xa, ssid);
965 965 if (file_priv) {
966 966 if (!READ_ONCE(file_priv->has_mmu_faults)) {
967 + atomic_set(&vdev->faults_detected, 1);
967 968 ivpu_mmu_dump_event(vdev, event);
968 969 WRITE_ONCE(file_priv->has_mmu_faults, true);
969 970 }
modified drivers/accel/ivpu/ivpu_pm.c
@@ -229,7 +229,6 @@ abort:
229 229
230 230 ivpu_jsm_state_dump(vdev);
231 231 ivpu_dev_coredump(vdev);
232 - atomic_set(&vdev->job_timeout_detected, 1);
233 232 queue_work(system_percpu_wq, &vdev->context_abort_work);
234 233 }
235 234
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_device.c
@@ -31,8 +31,6 @@ struct rocket_device *rocket_device_init(struct platform_device *pdev,
31 31 if (of_device_is_available(core_node))
32 32 num_cores++;
33 33
34 - rdev->max_cores = num_cores;
35 -
36 34 rdev->cores = devm_kcalloc(dev, num_cores, sizeof(*rdev->cores), GFP_KERNEL);
37 35 if (!rdev->cores)
38 36 return ERR_PTR(-ENOMEM);
modified drivers/accel/rocket/rocket_device.h
@@ -19,7 +19,6 @@ struct rocket_device {
19 19
20 20 struct rocket_core *cores;
21 21 unsigned int num_cores;
22 - unsigned int max_cores;
23 22 };
24 23
25 24 struct rocket_device *rocket_device_init(struct platform_device *pdev,
modified drivers/accel/rocket/rocket_drv.c
@@ -165,11 +165,8 @@ static int rocket_probe(struct platform_device *pdev)
165 165 /* First core probing, initialize DRM device. */
166 166 rdev = rocket_device_init(drm_dev, &rocket_drm_driver);
167 167 if (IS_ERR(rdev)) {
168 - int err = PTR_ERR(rdev);
169 -
170 168 dev_err(&pdev->dev, "failed to initialize rocket device\n");
171 - rdev = NULL;
172 - return err;
169 + return PTR_ERR(rdev);
173 170 }
174 171 }
175 172
@@ -226,7 +223,7 @@ static int find_core_for_dev(struct device *dev)
226 223 {
227 224 struct rocket_device *rdev = dev_get_drvdata(dev);
228 225
229 - for (unsigned int core = 0; core < rdev->max_cores; core++) {
226 + for (unsigned int core = 0; core < rdev->num_cores; core++) {
230 227 if (dev == rdev->cores[core].dev)
231 228 return core;
232 229 }
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 *));
@@ -283,7 +283,7 @@ static struct rocket_core *sched_to_core(struct rocket_device *rdev,
283 283 {
284 284 unsigned int core;
285 285
286 - for (core = 0; core < rdev->max_cores; core++) {
286 + for (core = 0; core < rdev->num_cores; core++) {
287 287 if (&rdev->cores[core].sched == sched)
288 288 return &rdev->cores[core];
289 289 }
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/regmap/regmap-irq.c
@@ -963,7 +963,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
963 963 return 0;
964 964
965 965 err_domain:
966 - /* Should really dispose of the domain but... */
966 + irq_domain_remove(d->domain);
967 967 err_mutex:
968 968 mutex_destroy(&d->lock);
969 969 lockdep_unregister_key(&d->lock_key);
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/sunvdc.c
@@ -525,23 +525,6 @@ static int __send_request(struct request *req)
525 525 err = __vdc_tx_trigger(port);
526 526 if (err < 0) {
527 527 printk(KERN_ERR PFX "vdc_tx_trigger() failure, err=%d\n", err);
528 - /*
529 - * If the port was reset (-ENOTCONN), the dring and the
530 - * LDC channel including all of its mappings are already
531 - * torn down and reallocated - there is nothing to undo
532 - * and @desc must not be touched.
533 - *
534 - * For any other failure the descriptor was never handed
535 - * to the peer: unmap the cookies and free the descriptor
536 - * again, so that a later retry of the request does not
537 - * leak LDC map table entries.
538 - */
539 - if (err != -ENOTCONN) {
540 - ldc_unmap(port->vio.lp, desc->cookies,
541 - desc->ncookies);
542 - desc->hdr.state = VIO_DESC_FREE;
543 - rqe->req = NULL;
544 - }
545 528 } else {
546 529 port->req_id++;
547 530 dr->prod = vio_dring_next(dr, dr->prod);
@@ -556,7 +539,6 @@ static blk_status_t vdc_queue_rq(struct blk_mq_hw_ctx *hctx,
556 539 struct vdc_port *port = hctx->queue->queuedata;
557 540 struct vio_dring_state *dr;
558 541 unsigned long flags;
559 - int ret;
560 542
561 543 dr = &port->vio.drings[VIO_DRIVER_TX_RING];
562 544
@@ -578,13 +560,7 @@ static blk_status_t vdc_queue_rq(struct blk_mq_hw_ctx *hctx,
578 560 return BLK_STS_DEV_RESOURCE;
579 561 }
580 562
581 - ret = __send_request(bd->rq);
582 - if (ret == -EAGAIN) {
583 - spin_unlock_irqrestore(&port->vio.lock, flags);
584 - /* already spun for 10msec, defer 10msec and retry */
585 - blk_mq_delay_kick_requeue_list(hctx->queue, 10);
586 - return BLK_STS_DEV_RESOURCE;
587 - } else if (ret < 0) {
563 + if (__send_request(bd->rq) < 0) {
588 564 spin_unlock_irqrestore(&port->vio.lock, flags);
589 565 return BLK_STS_IOERR;
590 566 }
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;
@@ -3030,7 +3024,6 @@ static void ublk_queue_reset_io_flags(struct ublk_queue *ubq)
3030 3024 ubq->canceling = false;
3031 3025 spin_unlock(&ubq->cancel_lock);
3032 3026 ubq->fail_io = false;
3033 - ubq->force_abort = false;
3034 3027 }
3035 3028
3036 3029 /* device can only be started after all IOs are ready */
@@ -5397,7 +5390,7 @@ static int __ublk_ctrl_reg_buf(struct ublk_device *ub,
5397 5390 page_to_pfn(pages[i + 1]) == pfn + (i - start) + 1)
5398 5391 i++;
5399 5392
5400 - range = kzalloc_obj(*range);
5393 + range = kzalloc(sizeof(*range), GFP_KERNEL);
5401 5394 if (!range) {
5402 5395 ret = -ENOMEM;
5403 5396 goto unwind;
@@ -5460,7 +5453,7 @@ static int ublk_ctrl_reg_buf(struct ublk_device *ub,
5460 5453 nr_pages = buf_reg.len >> PAGE_SHIFT;
5461 5454
5462 5455 /* Pin pages before any locks (may sleep) */
5463 - pages = kvmalloc_objs(*pages, nr_pages);
5456 + pages = kvmalloc_array(nr_pages, sizeof(*pages), GFP_KERNEL);
5464 5457 if (!pages)
5465 5458 return -ENOMEM;
5466 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
@@ -1099,7 +1099,7 @@ static void btintel_pcie_msix_tx_handle(struct btintel_pcie_data *data)
1099 1099
1100 1100 urbd0 = &txq->urbd0s[cr_tia];
1101 1101
1102 - if (urbd0->tfd_index >= txq->count)
1102 + if (urbd0->tfd_index > txq->count)
1103 1103 return;
1104 1104
1105 1105 cr_tia = (cr_tia + 1) % txq->count;
@@ -1599,9 +1599,7 @@ static int btintel_pcie_submit_rx_work(struct btintel_pcie_data *data, u8 status
1599 1599 rfh_hdr = buf;
1600 1600
1601 1601 len = rfh_hdr->packet_len;
1602 - if (len == 0 || len > BTINTEL_PCIE_BUFFER_SIZE - sizeof(*rfh_hdr)) {
1603 - bt_dev_err(data->hdev, "Invalid packet_len %d (max %zu)", len,
1604 - BTINTEL_PCIE_BUFFER_SIZE - sizeof(*rfh_hdr));
1602 + if (len <= 0) {
1605 1603 ret = -EINVAL;
1606 1604 goto resubmit;
1607 1605 }
@@ -1698,9 +1696,6 @@ static irqreturn_t btintel_pcie_irq_msix_handler(int irq, void *dev_id)
1698 1696
1699 1697 if (unlikely(!(intr_fh | intr_hw))) {
1700 1698 /* Ignore interrupt, inta == 0 */
1701 - bt_warn_ratelimited("Bluetooth: btintel_pcie: Received spurious interrupt\n");
1702 - btintel_pcie_wr_reg32(data, BTINTEL_PCIE_CSR_MSIX_AUTOMASK_ST,
1703 - BIT(entry->entry));
1704 1699 return IRQ_NONE;
1705 1700 }
1706 1701
modified drivers/bluetooth/btmtk.c
@@ -1374,6 +1374,16 @@ int btmtk_usb_setup(struct hci_dev *hdev)
1374 1374 break;
1375 1375 case 0x7922:
1376 1376 case 0x7925:
1377 + /*
1378 + * A remote wakeup could cause the device completely unresponsive, and
1379 + * recovering from such a state needs a power cycle.
1380 + *
1381 + * Since the remote wakeup capability is super broken, just disable it
1382 + * to get rid of the troubles. The device can still be autosuspended
1383 + * when the bluetooth interface is closed.
1384 + */
1385 + device_set_wakeup_capable(&btmtk_data->udev->dev, false);
1386 + fallthrough;
1377 1387 case 0x7961:
1378 1388 case 0x7902:
1379 1389 case 0x6639:
@@ -1577,6 +1587,5 @@ MODULE_FIRMWARE(FIRMWARE_MT7663);
1577 1587 MODULE_FIRMWARE(FIRMWARE_MT7668);
1578 1588 MODULE_FIRMWARE(FIRMWARE_MT7922);
1579 1589 MODULE_FIRMWARE(FIRMWARE_MT7961);
1580 - MODULE_FIRMWARE(FIRMWARE_MT7920);
1581 1590 MODULE_FIRMWARE(FIRMWARE_MT7925);
1582 1591 MODULE_FIRMWARE(FIRMWARE_MT7927);
modified drivers/bluetooth/btmtk.h
@@ -7,7 +7,6 @@
7 7 #define FIRMWARE_MT7922 "mediatek/BT_RAM_CODE_MT7922_1_1_hdr.bin"
8 8 #define FIRMWARE_MT7902 "mediatek/BT_RAM_CODE_MT7902_1_1_hdr.bin"
9 9 #define FIRMWARE_MT7961 "mediatek/BT_RAM_CODE_MT7961_1_2_hdr.bin"
10 - #define FIRMWARE_MT7920 "mediatek/BT_RAM_CODE_MT7961_1a_2_hdr.bin"
11 10 #define FIRMWARE_MT7925 "mediatek/mt7925/BT_RAM_CODE_MT7925_1_1_hdr.bin"
12 11 #define FIRMWARE_MT7927 "mediatek/mt7927/BT_RAM_CODE_MT6639_2_1_hdr.bin"
13 12
modified drivers/bluetooth/btqcomsmd.c
@@ -188,10 +188,7 @@ static int btqcomsmd_probe(struct platform_device *pdev)
188 188 return 0;
189 189
190 190 hci_free_dev:
191 - rpmsg_destroy_ept(btq->cmd_channel);
192 - rpmsg_destroy_ept(btq->acl_channel);
193 191 hci_free_dev(hdev);
194 - return ret;
195 192 destroy_cmd_channel:
196 193 rpmsg_destroy_ept(btq->cmd_channel);
197 194 destroy_acl_channel:
@@ -205,11 +202,10 @@ static void btqcomsmd_remove(struct platform_device *pdev)
205 202 struct btqcomsmd *btq = platform_get_drvdata(pdev);
206 203
207 204 hci_unregister_dev(btq->hdev);
205 + hci_free_dev(btq->hdev);
208 206
209 207 rpmsg_destroy_ept(btq->cmd_channel);
210 208 rpmsg_destroy_ept(btq->acl_channel);
211 -
212 - hci_free_dev(btq->hdev);
213 209 }
214 210
215 211 static const struct of_device_id btqcomsmd_of_match[] = {
modified drivers/bluetooth/btrtl.c
@@ -591,7 +591,7 @@ static int rtlbt_parse_firmware_v2(struct hci_dev *hdev,
591 591 * headers.
592 592 */
593 593 if (!key_id)
594 - continue;
594 + break;
595 595 rc = btrtl_parse_section(hdev, btrtl_dev, opcode,
596 596 ptr, section_len);
597 597 break;
@@ -600,7 +600,8 @@ static int rtlbt_parse_firmware_v2(struct hci_dev *hdev,
600 600 ptr, section_len);
601 601 break;
602 602 default:
603 - continue;
603 + rc = 0;
604 + break;
604 605 }
605 606 if (rc < 0) {
606 607 rtl_dev_err(hdev, "RTL: Parse section (%u) err %d",
modified drivers/bluetooth/btusb.c
@@ -6,7 +6,6 @@
6 6 * Copyright (C) 2005-2008 Marcel Holtmann <marcel@holtmann.org>
7 7 */
8 8
9 - #include <linux/cpufeature.h>
10 9 #include <linux/dmi.h>
11 10 #include <linux/module.h>
12 11 #include <linux/usb.h>
@@ -981,8 +980,6 @@ struct btqca_data {
981 980 #define BTUSB_USE_ALT3_FOR_WBS 15
982 981 #define BTUSB_ALT6_CONTINUOUS_TX 16
983 982 #define BTUSB_HW_SSR_ACTIVE 17
984 - #define BTUSB_WAKEUP_BROKEN 18
985 - #define BTUSB_RESET 19
986 983
987 984 struct btusb_data {
988 985 struct hci_dev *hdev;
@@ -1057,15 +1054,13 @@ static void btusb_reset(struct hci_dev *hdev)
1057 1054 int err;
1058 1055
1059 1056 data = hci_get_drvdata(hdev);
1057 + /* This is not an unbalanced PM reference since the device will reset */
1060 1058 err = usb_autopm_get_interface(data->intf);
1061 1059 if (err) {
1062 1060 bt_dev_err(hdev, "Failed usb_autopm_get_interface: %d", err);
1063 1061 return;
1064 1062 }
1065 1063
1066 - if (test_and_set_bit(BTUSB_RESET, &data->flags))
1067 - usb_autopm_put_interface_no_suspend(data->intf);
1068 -
1069 1064 bt_dev_err(hdev, "Resetting usb device.");
1070 1065 usb_queue_reset_device(data->intf);
1071 1066 }
@@ -2097,24 +2092,18 @@ static int btusb_close(struct hci_dev *hdev)
2097 2092
2098 2093 BT_DBG("%s", hdev->name);
2099 2094
2095 + cancel_delayed_work(&data->rx_work);
2100 2096 cancel_work_sync(&data->work);
2101 2097 cancel_work_sync(&data->waker);
2102 2098
2099 + skb_queue_purge(&data->acl_q);
2100 +
2103 2101 clear_bit(BTUSB_ISOC_RUNNING, &data->flags);
2104 2102 clear_bit(BTUSB_BULK_RUNNING, &data->flags);
2105 2103 clear_bit(BTUSB_INTR_RUNNING, &data->flags);
2106 2104 clear_bit(BTUSB_DIAG_RUNNING, &data->flags);
2107 2105
2108 2106 btusb_stop_traffic(data);
2109 -
2110 - /* rx_work must only be canceled once the URBs that can rearm it are
2111 - * gone, and it must be canceled synchronously since btusb_disconnect()
2112 - * frees the btusb_data it dereferences right after hci_unregister_dev().
2113 - */
2114 - cancel_delayed_work_sync(&data->rx_work);
2115 -
2116 - skb_queue_purge(&data->acl_q);
2117 -
2118 2107 btusb_free_frags(data);
2119 2108
2120 2109 err = usb_autopm_get_interface(data->intf);
@@ -2140,7 +2129,7 @@ static int btusb_flush(struct hci_dev *hdev)
2140 2129
2141 2130 BT_DBG("%s", hdev->name);
2142 2131
2143 - cancel_delayed_work_sync(&data->rx_work);
2132 + cancel_delayed_work(&data->rx_work);
2144 2133
2145 2134 skb_queue_purge(&data->acl_q);
2146 2135
@@ -2934,11 +2923,8 @@ static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data)
2934 2923 }
2935 2924
2936 2925 err = usb_autopm_get_interface(data->intf);
2937 - if (err < 0) {
2938 - bt_dev_err(hdev, "Failed usb_autopm_get_interface: %d", err);
2939 - clear_bit(BTMTK_HW_RESET_ACTIVE, &btmtk_data->flags);
2926 + if (err < 0)
2940 2927 return err;
2941 - }
2942 2928
2943 2929 /* Release MediaTek ISO data interface */
2944 2930 btusb_mtk_release_iso_intf(hdev);
@@ -2960,11 +2946,6 @@ static int btusb_mtk_reset(struct hci_dev *hdev, void *rst_data)
2960 2946
2961 2947 err = btmtk_usb_subsys_reset(hdev, btmtk_data->dev_id);
2962 2948
2963 - if (test_and_set_bit(BTUSB_RESET, &data->flags)) {
2964 - bt_dev_err(hdev, "last usb reset failed? Resetting again");
2965 - usb_autopm_put_interface_no_suspend(data->intf);
2966 - }
2967 -
2968 2949 usb_queue_reset_device(data->intf);
2969 2950 clear_bit(BTMTK_HW_RESET_ACTIVE, &btmtk_data->flags);
2970 2951
@@ -2988,25 +2969,10 @@ static int btusb_send_frame_mtk(struct hci_dev *hdev, struct sk_buff *skb)
2988 2969 }
2989 2970 }
2990 2971
2991 - static inline bool platform_is_ryzen(void)
2992 - {
2993 - #ifdef CONFIG_X86
2994 - return boot_cpu_has(X86_FEATURE_ZEN);
2995 - #else
2996 - return false;
2997 - #endif
2998 - }
2999 -
3000 - static inline bool is_direct_child_of_root_hub(struct usb_device *udev)
3001 - {
3002 - return udev->parent == udev->bus->root_hub;
3003 - }
3004 -
3005 2972 static int btusb_mtk_setup(struct hci_dev *hdev)
3006 2973 {
3007 2974 struct btusb_data *data = hci_get_drvdata(hdev);
3008 2975 struct btmtk_data *btmtk_data = hci_get_priv(hdev);
3009 - int err;
3010 2976
3011 2977 /* MediaTek WMT vendor cmd requiring below USB resources to
3012 2978 * complete the handshake.
@@ -3023,40 +2989,7 @@ static int btusb_mtk_setup(struct hci_dev *hdev)
3023 2989 btusb_mtk_claim_iso_intf(data);
3024 2990 }
3025 2991
3026 - err = btmtk_usb_setup(hdev);
3027 - if (err)
3028 - return err;
3029 -
3030 - switch (btmtk_data->dev_id) {
3031 - case 0x7922:
3032 - case 0x7925:
3033 - /*
3034 - * All reports seen to be relevant to Ryzen-based laptops. These
3035 - * NICs are usually used as OEM components thanks to some sort
3036 - * of reference designs.
3037 - *
3038 - * Their popularity on other platforms is unclear. While there
3039 - * is still a chance that the quirk may exist on other
3040 - * platforms, be cautious and only apply the quirk to direct
3041 - * children of Ryzen platforms's root hubs for the time being.
3042 - *
3043 - * In most cases the root hub is on the SoC or PCH, which needs
3044 - * the quirk. Unfortunately, this can't distinguish root hubs on
3045 - * PCIe add-in cards. Such roughness should be acceptable, as
3046 - * PCIe USB controller add-in cards are less commonly used
3047 - * nowadays. On the other hand, applying the quirk doesn't hurt
3048 - * any functionalities either, as the device can still be used
3049 - * as a wakeup source if desired.
3050 - *
3051 - * Theoretically, we could retrieve the root hub's PCI vendor ID
3052 - * with some hierarchy magic, but that's too intrusive...
3053 - */
3054 - if (platform_is_ryzen() && is_direct_child_of_root_hub(data->udev))
3055 - set_bit(BTUSB_WAKEUP_BROKEN, &data->flags);
3056 - break;
3057 - }
3058 -
3059 - return 0;
2992 + return btmtk_usb_setup(hdev);
3060 2993 }
3061 2994
3062 2995 static int btusb_mtk_shutdown(struct hci_dev *hdev)
@@ -4607,9 +4540,6 @@ static void btusb_disconnect(struct usb_interface *intf)
4607 4540 if (data->reset_gpio)
4608 4541 gpiod_put(data->reset_gpio);
4609 4542
4610 - if (test_and_clear_bit(BTUSB_RESET, &data->flags))
4611 - usb_autopm_put_interface_no_suspend(data->intf);
4612 -
4613 4543 if (intf == data->intf) {
4614 4544 if (data->isoc)
4615 4545 usb_driver_release_interface(&btusb_driver, data->isoc);
@@ -4635,26 +4565,11 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
4635 4565
4636 4566 BT_DBG("intf %p", intf);
4637 4567
4638 - /*
4639 - * It is reported that remote wakeup events could sometimes cause some
4640 - * adapters completely unresponsive. Resetting the xHCI root hub doesn't
4641 - * help at all, and recovering from such a state needs a power cycle.
4642 - * Since disabling remote wakeup simply causes the USB core to gate
4643 - * runtime autosuspend as well due to needs_remote_wakeup == 1, let's do
4644 - * this ourselves to make our life easier. The interface can be safely
4645 - * autosuspended as long as remote wakeup is disabled, i.e., after
4646 - * closing the HCI device.
4647 - *
4648 - * Don't auto-suspend if there are connections or discovery in progress.
4649 - *
4650 - * External suspend calls shall never fail. Specifically, a device with
4651 - * broken remote wakeup may still take the advantage of remote wakeup in
4652 - * order to wake up the system from sleep if userspace has enabled it as
4653 - * a wakeup source.
4568 + /* Don't auto-suspend if there are connections or discovery in
4569 + * progress; external suspend calls shall never fail.
4654 4570 */
4655 4571 if (PMSG_IS_AUTO(message) &&
4656 - ((test_bit(BTUSB_WAKEUP_BROKEN, &data->flags) && data->intf->needs_remote_wakeup) ||
4657 - hci_conn_count(data->hdev) || hci_discovery_active(data->hdev)))
4572 + (hci_conn_count(data->hdev) || hci_discovery_active(data->hdev)))
4658 4573 return -EBUSY;
4659 4574
4660 4575 if (data->suspend_count++)
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
@@ -1964,28 +1964,13 @@ static const struct file_operations portdev_fops = {
1964 1964 static void remove_vqs(struct ports_device *portdev)
1965 1965 {
1966 1966 struct virtqueue *vq;
1967 - bool multiport = use_multiport(portdev);
1968 1967
1969 1968 virtio_device_for_each_vq(portdev->vdev, vq) {
1970 1969 struct port_buffer *buf;
1971 - unsigned int len;
1972 1970
1973 - /*
1974 - * c_ovq cookies are &portdev->cpkt, not port_buffer.
1975 - * Detach them but do not free_buf().
1976 - */
1977 - if (multiport && vq == portdev->c_ovq) {
1978 - spin_lock(&portdev->c_ovq_lock);
1979 - while (virtqueue_get_buf(vq, &len))
1980 - ;
1981 - while (virtqueue_detach_unused_buf(vq))
1982 - ;
1983 - spin_unlock(&portdev->c_ovq_lock);
1984 - } else {
1985 - flush_bufs(vq, true);
1986 - while ((buf = virtqueue_detach_unused_buf(vq)))
1987 - free_buf(buf, true);
1988 - }
1971 + flush_bufs(vq, true);
1972 + while ((buf = virtqueue_detach_unused_buf(vq)))
1973 + free_buf(buf, true);
1989 1974 cond_resched();
1990 1975 }
1991 1976 portdev->vdev->config->del_vqs(portdev->vdev);
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/cpufreq/cpufreq.c
@@ -1249,7 +1249,7 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
1249 1249 if (!policy)
1250 1250 return NULL;
1251 1251
1252 - if (!zalloc_cpumask_var(&policy->cpus, GFP_KERNEL))
1252 + if (!alloc_cpumask_var(&policy->cpus, GFP_KERNEL))
1253 1253 goto err_free_policy;
1254 1254
1255 1255 if (!zalloc_cpumask_var(&policy->related_cpus, GFP_KERNEL))
@@ -1258,8 +1258,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
1258 1258 if (!zalloc_cpumask_var(&policy->real_cpus, GFP_KERNEL))
1259 1259 goto err_free_rcpumask;
1260 1260
1261 - init_rwsem(&policy->rwsem);
1262 -
1263 1261 init_completion(&policy->kobj_unregister);
1264 1262 ret = kobject_init_and_add(&policy->kobj, &ktype_cpufreq,
1265 1263 cpufreq_global_kobject, "policy%u", cpu);
@@ -1274,6 +1272,8 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
1274 1272 goto err_free_real_cpus;
1275 1273 }
1276 1274
1275 + init_rwsem(&policy->rwsem);
1276 +
1277 1277 freq_constraints_init(&policy->constraints);
1278 1278
1279 1279 policy->nb_min.notifier_call = cpufreq_notifier_min;
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/dibs/dibs_main.c
@@ -251,19 +251,13 @@ static int __init dibs_init(void)
251 251
252 252 rc = class_register(&dibs_class);
253 253 if (rc)
254 - goto err;
254 + return rc;
255 255
256 256 rc = dibs_loopback_init();
257 257 if (rc)
258 - goto err_unregister;
258 + pr_err("%s fails with %d\n", __func__, rc);
259 259
260 260 return rc;
261 -
262 - err_unregister:
263 - class_unregister(&dibs_class);
264 - err:
265 - pr_err("%s fails with %d\n", __func__, rc);
266 - return rc;
267 261 }
268 262
269 263 static void __exit dibs_exit(void)
modified drivers/dma-buf/Kconfig
@@ -43,7 +43,7 @@ config UDMABUF
43 43 config DMABUF_DEBUG
44 44 bool "DMA-BUF debug checks"
45 45 depends on DMA_SHARED_BUFFER
46 - default y if DEBUG_KERNEL
46 + default y if DEBUG
47 47 help
48 48 This option enables additional checks for DMA-BUF importers and
49 49 exporters. Specifically it validates that importers do not peek at the
modified drivers/dma-buf/dma-buf-mapping.c
@@ -5,18 +5,16 @@
5 5 */
6 6 #include <linux/dma-buf-mapping.h>
7 7 #include <linux/dma-resv.h>
8 - #include <linux/overflow.h>
9 - #include <linux/align.h>
10 -
11 - #define MAX_SG_ENT_SZ ALIGN_DOWN(UINT_MAX, PAGE_SIZE)
12 8
13 9 static struct scatterlist *fill_sg_entry(struct scatterlist *sgl, size_t length,
14 10 dma_addr_t addr)
15 11 {
16 - size_t len;
12 + unsigned int len, nents;
13 + int i;
17 14
18 - while (length) {
19 - len = min(length, MAX_SG_ENT_SZ);
15 + nents = DIV_ROUND_UP(length, UINT_MAX);
16 + for (i = 0; i < nents; i++) {
17 + len = min_t(size_t, length, UINT_MAX);
20 18 length -= len;
21 19 /*
22 20 * DMABUF abuses scatterlist to create a scatterlist
@@ -26,10 +24,8 @@ static struct scatterlist *fill_sg_entry(struct scatterlist *sgl, size_t length,
26 24 * does not require the CPU list for mapping or unmapping.
27 25 */
28 26 sg_set_page(sgl, NULL, 0, 0);
29 - sg_dma_address(sgl) = addr;
27 + sg_dma_address(sgl) = addr + (dma_addr_t)i * UINT_MAX;
30 28 sg_dma_len(sgl) = len;
31 - addr += len;
32 - /* Unconditionally advance. On last segment, this becomes NULL */
33 29 sgl = sg_next(sgl);
34 30 }
35 31
@@ -44,19 +40,15 @@ static unsigned int calc_sg_nents(struct dma_iova_state *state,
44 40 size_t i;
45 41
46 42 if (!state || !dma_use_iova(state)) {
47 - for (i = 0; i < nr_ranges; i++) {
48 - unsigned int added = DIV_ROUND_UP(phys_vec[i].len, MAX_SG_ENT_SZ);
49 -
50 - if (check_add_overflow(nents, added, &nents))
51 - return 0;
52 - }
43 + for (i = 0; i < nr_ranges; i++)
44 + nents += DIV_ROUND_UP(phys_vec[i].len, UINT_MAX);
53 45 } else {
54 46 /*
55 47 * In IOVA case, there is only one SG entry which spans
56 48 * for whole IOVA address space, but we need to make sure
57 49 * that it fits sg->length, maybe we need more.
58 50 */
59 - nents = DIV_ROUND_UP(size, MAX_SG_ENT_SZ);
51 + nents = DIV_ROUND_UP(size, UINT_MAX);
60 52 }
61 53
62 54 return nents;
@@ -103,10 +95,9 @@ struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach,
103 95 size_t nr_ranges, size_t size,
104 96 enum dma_data_direction dir)
105 97 {
98 + unsigned int nents, mapped_len = 0;
106 99 struct dma_buf_dma *dma;
107 100 struct scatterlist *sgl;
108 - size_t mapped_len = 0;
109 - unsigned int nents;
110 101 dma_addr_t addr;
111 102 size_t i;
112 103 int ret;
@@ -142,8 +133,6 @@ struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach,
142 133 }
143 134
144 135 nents = calc_sg_nents(dma->state, phys_vec, nr_ranges, size);
145 -
146 - /* sg_alloc_table will cleanly fail and return -EINVAL if nents == 0 */
147 136 ret = sg_alloc_table(&dma->sgt, nents, GFP_KERNEL | __GFP_ZERO);
148 137 if (ret)
149 138 goto err_free_state;
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-fence.c
@@ -1170,12 +1170,7 @@ const char __rcu *dma_fence_driver_name(struct dma_fence *fence)
1170 1170
1171 1171 /* RCU protection is required for safe access to returned string */
1172 1172 ops = rcu_dereference(fence->ops);
1173 -
1174 - /*
1175 - * Make load ordering irrelevant by checking both signaled state and ops
1176 - * pointer and ops pointer is only set to NULL on newer implementations.
1177 - */
1178 - if (!dma_fence_test_signaled_flag(fence) && ops)
1173 + if (ops)
1179 1174 return (const char __rcu *)ops->get_driver_name(fence);
1180 1175 else
1181 1176 return (const char __rcu *)"detached-driver";
@@ -1208,12 +1203,7 @@ const char __rcu *dma_fence_timeline_name(struct dma_fence *fence)
1208 1203
1209 1204 /* RCU protection is required for safe access to returned string */
1210 1205 ops = rcu_dereference(fence->ops);
1211 -
1212 - /*
1213 - * Make load ordering irrelevant by checking both signaled state and ops
1214 - * pointer and ops pointer is only set to NULL on newer implementations.
1215 - */
1216 - if (!dma_fence_test_signaled_flag(fence) && ops)
1206 + if (ops)
1217 1207 return (const char __rcu *)ops->get_timeline_name(fence);
1218 1208 else
1219 1209 return (const char __rcu *)"signaled-timeline";
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)
@@ -1534,7 +1533,7 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
1534 1533 altdev = dci->pvt_info;
1535 1534 *altdev = *device;
1536 1535
1537 - if (!devres_open_group(device->edac->dev, altr_portb_setup, GFP_KERNEL))
1536 + if (!devres_open_group(&altdev->ddev, altr_portb_setup, GFP_KERNEL))
1538 1537 return -ENOMEM;
1539 1538
1540 1539 /* Update PortB specific values */
@@ -1549,20 +1548,21 @@ 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;
1563 1563 goto err_release_group_1;
1564 1564 }
1565 - rc = devm_request_irq(device->edac->dev, altdev->sb_irq,
1565 + rc = devm_request_irq(&altdev->ddev, altdev->sb_irq,
1566 1566 prv->ecc_irq_handler, IRQF_TRIGGER_HIGH,
1567 1567 ecc_name, altdev);
1568 1568 if (rc) {
@@ -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(device->edac->dev, 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) {
@@ -1604,13 +1605,13 @@ static int altr_portb_setup(struct altr_edac_device_dev *device)
1604 1605
1605 1606 list_add(&altdev->next, &altdev->edac->a10_ecc_devices);
1606 1607
1607 - devres_remove_group(device->edac->dev, altr_portb_setup);
1608 + devres_remove_group(&altdev->ddev, altr_portb_setup);
1608 1609
1609 1610 return 0;
1610 1611
1611 1612 err_release_group_1:
1612 1613 edac_device_free_ctl_info(dci);
1613 - devres_release_group(device->edac->dev, altr_portb_setup);
1614 + devres_release_group(&altdev->ddev, altr_portb_setup);
1614 1615 edac_printk(KERN_ERR, EDAC_DEVICE,
1615 1616 "%s:Error setting up EDAC device: %d\n", ecc_name, rc);
1616 1617 return 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/adp/Kconfig
@@ -6,6 +6,7 @@ config DRM_ADP
6 6 select DRM_KMS_HELPER
7 7 select DRM_BRIDGE_CONNECTOR
8 8 select DRM_DISPLAY_HELPER
9 + select DRM_KMS_DMA_HELPER
9 10 select DRM_GEM_DMA_HELPER
10 11 select DRM_PANEL_BRIDGE
11 12 select VIDEOMODE_HELPERS
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_object.c
@@ -1701,8 +1701,9 @@ u64 amdgpu_bo_print_info(int id, struct amdgpu_bo *bo, struct seq_file *m)
1701 1701 if (dma_resv_trylock(bo->tbo.base.resv)) {
1702 1702 dma_resv_describe(bo->tbo.base.resv, m);
1703 1703 dma_resv_unlock(bo->tbo.base.resv);
1704 + } else {
1705 + seq_puts(m, "\n");
1704 1706 }
1705 - seq_puts(m, "\n");
1706 1707
1707 1708 return size;
1708 1709 }
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
@@ -191,8 +191,6 @@ amdgpu_ttm_job_submit(struct amdgpu_device *adev, struct amdgpu_ttm_buffer_entit
191 191 * @tmz: if we should setup a TMZ enabled mapping
192 192 * @size: in number of bytes to map, out number of bytes mapped
193 193 * @addr: resulting address inside the MC address space
194 - * @vm_needs_flush: out, set true if a GART window was programmed (VMID 0 flush
195 - * needed) or false for a direct address
196 194 *
197 195 * Setup one of the GART windows to access a specific piece of memory or return
198 196 * the physical address for local memory.
@@ -202,8 +200,7 @@ static int amdgpu_ttm_map_buffer(struct amdgpu_ttm_buffer_entity *entity,
202 200 struct ttm_resource *mem,
203 201 struct amdgpu_res_cursor *mm_cur,
204 202 unsigned int window,
205 - bool tmz, uint64_t *size, uint64_t *addr,
206 - bool *vm_needs_flush)
203 + bool tmz, uint64_t *size, uint64_t *addr)
207 204 {
208 205 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
209 206 unsigned int offset, num_pages, num_dw, num_bytes;
@@ -224,12 +221,9 @@ static int amdgpu_ttm_map_buffer(struct amdgpu_ttm_buffer_entity *entity,
224 221 if (!tmz && mem->start != AMDGPU_BO_INVALID_OFFSET) {
225 222 *addr = amdgpu_ttm_domain_start(adev, mem->mem_type) +
226 223 mm_cur->start;
227 - *vm_needs_flush = false;
228 224 return 0;
229 225 }
230 226
231 - /* A GART window is programmed below, so its VMID 0 TLB needs a flush */
232 - *vm_needs_flush = true;
233 227
234 228 /*
235 229 * If start begins at an offset inside the page, then adjust the size
@@ -330,7 +324,6 @@ static int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
330 324 while (src_mm.remaining) {
331 325 uint64_t from, to, cur_size, tiling_flags;
332 326 uint32_t num_type, data_format, max_com, write_compress_disable;
333 - bool src_vm_flush, dst_vm_flush;
334 327 struct dma_fence *next;
335 328
336 329 /* Never copy more than 256MiB at once to avoid a timeout */
@@ -338,12 +331,12 @@ static int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
338 331
339 332 /* Map src to window 0 and dst to window 1. */
340 333 r = amdgpu_ttm_map_buffer(entity, src->bo, src->mem, &src_mm,
341 - 0, tmz, &cur_size, &from, &src_vm_flush);
334 + 0, tmz, &cur_size, &from);
342 335 if (r)
343 336 goto error;
344 337
345 338 r = amdgpu_ttm_map_buffer(entity, dst->bo, dst->mem, &dst_mm,
346 - 1, tmz, &cur_size, &to, &dst_vm_flush);
339 + 1, tmz, &cur_size, &to);
347 340 if (r)
348 341 goto error;
349 342
@@ -371,7 +364,7 @@ static int amdgpu_ttm_copy_mem_to_mem(struct amdgpu_device *adev,
371 364 }
372 365
373 366 r = amdgpu_copy_buffer(adev, entity, from, to, cur_size, resv,
374 - &next, src_vm_flush || dst_vm_flush, copy_flags);
367 + &next, true, copy_flags);
375 368 if (r)
376 369 goto error;
377 370
@@ -2368,8 +2361,9 @@ void amdgpu_ttm_enable_buffer_funcs(struct amdgpu_device *adev)
2368 2361 num_clear_entities = MIN(adev->mman.num_buffer_funcs_scheds, TTM_NUM_MOVE_FENCES);
2369 2362 num_move_entities = MIN(adev->mman.num_buffer_funcs_scheds, TTM_NUM_MOVE_FENCES);
2370 2363
2371 - adev->mman.clear_entities = kzalloc_objs(struct amdgpu_ttm_buffer_entity,
2372 - num_clear_entities);
2364 + adev->mman.clear_entities = kcalloc(num_clear_entities,
2365 + sizeof(struct amdgpu_ttm_buffer_entity),
2366 + GFP_KERNEL);
2373 2367 atomic_set(&adev->mman.next_clear_entity, 0);
2374 2368 if (!adev->mman.clear_entities)
2375 2369 goto error_free_default_entity;
@@ -2631,7 +2625,6 @@ int amdgpu_ttm_clear_buffer(struct amdgpu_ttm_buffer_entity *entity,
2631 2625 struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
2632 2626 struct dma_fence *fence = NULL;
2633 2627 struct amdgpu_res_cursor dst;
2634 - bool vm_needs_flush = false;
2635 2628 int r;
2636 2629
2637 2630 if (!entity)
@@ -2653,13 +2646,13 @@ int amdgpu_ttm_clear_buffer(struct amdgpu_ttm_buffer_entity *entity,
2653 2646 cur_size = min(dst.size, 256ULL << 20);
2654 2647
2655 2648 r = amdgpu_ttm_map_buffer(entity, &bo->tbo, bo->tbo.resource, &dst,
2656 - 0, false, &cur_size, &to, &vm_needs_flush);
2649 + 0, false, &cur_size, &to);
2657 2650 if (r)
2658 2651 goto error;
2659 2652
2660 2653 r = amdgpu_ttm_fill_mem(adev, entity,
2661 2654 0, to, cur_size, resv,
2662 - &next, vm_needs_flush, k_job_id);
2655 + &next, true, k_job_id);
2663 2656 if (r)
2664 2657 goto error;
2665 2658
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
@@ -747,9 +747,9 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
747 747 }
748 748 if (adev->dm.dc->caps.max_links > 0) {
749 749 adev->dm.hdmi_frl_status_polling_wq =
750 - create_singlethread_workqueue("hdmi_frl_status_polling_wq");
750 + create_singlethread_workqueue("hdmi_frl_status_polling_workqueue");
751 751 if (!adev->dm.hdmi_frl_status_polling_wq)
752 - drm_err(adev_to_drm(adev), "failed to initialize hdmi_frl_status_polling_wq\n");
752 + drm_err(adev_to_drm(adev), "failed to initialize hdmi_frl_status_polling_workqueue\n");
753 753 }
754 754 if (dc_is_dmub_outbox_supported(adev->dm.dc)) {
755 755 init_completion(&adev->dm.dmub_aux_transfer_done);
@@ -1972,10 +1972,6 @@ static int dm_resume(struct amdgpu_ip_block *ip_block)
1972 1972 /* On resume we need to rewrite the MSTM control bits to enable MST*/
1973 1973 s3_handle_mst(ddev, false);
1974 1974
1975 - /* Exit IPS before the detection loop's first AUX/DDC access. */
1976 - scoped_guard(mutex, &dm->dc_lock)
1977 - dc_exit_ips_for_hw_access(dm->dc);
1978 -
1979 1975 /* Do detection*/
1980 1976 drm_connector_list_iter_begin(ddev, &iter);
1981 1977 drm_for_each_connector_iter(connector, &iter) {
@@ -3883,7 +3879,7 @@ static void amdgpu_dm_commit_planes(struct drm_atomic_commit *state,
3883 3879 continue;
3884 3880
3885 3881 bundle->surface_updates[planes_count].surface = dc_plane;
3886 - if (new_pcrtc_state->color_mgmt_changed || new_plane_state->color_mgmt_changed) {
3882 + if (new_pcrtc_state->color_mgmt_changed) {
3887 3883 bundle->surface_updates[planes_count].gamma = &dc_plane->gamma_correction;
3888 3884 bundle->surface_updates[planes_count].in_transfer_func = &dc_plane->in_transfer_func;
3889 3885 bundle->surface_updates[planes_count].gamut_remap_matrix = &dc_plane->gamut_remap_matrix;
@@ -5702,10 +5698,6 @@ static bool should_reset_plane(struct drm_atomic_commit *state,
5702 5698 if (new_crtc_state->color_mgmt_changed)
5703 5699 return true;
5704 5700
5705 - /* Plane color pipeline or its colorop changes. */
5706 - if (new_plane_state->color_mgmt_changed)
5707 - return true;
5708 -
5709 5701 /*
5710 5702 * On zpos change, planes need to be reordered by removing and re-adding
5711 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_connector.c
@@ -756,14 +756,10 @@ amdgpu_dm_get_output_color_space(const struct dc_crtc_timing *dc_crtc_timing,
756 756 break;
757 757 case DRM_MODE_COLORIMETRY_BT2020_RGB:
758 758 case DRM_MODE_COLORIMETRY_BT2020_YCC:
759 - if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB) {
760 - if (connector_state->hdmi.broadcast_rgb == DRM_HDMI_BROADCAST_RGB_LIMITED)
761 - color_space = COLOR_SPACE_2020_RGB_LIMITEDRANGE;
762 - else
763 - color_space = COLOR_SPACE_2020_RGB_FULLRANGE;
764 - } else {
759 + if (dc_crtc_timing->pixel_encoding == PIXEL_ENCODING_RGB)
760 + color_space = COLOR_SPACE_2020_RGB_FULLRANGE;
761 + else
765 762 color_space = COLOR_SPACE_2020_YCBCR_LIMITED;
766 - }
767 763 break;
768 764 case DRM_MODE_COLORIMETRY_DEFAULT: /* ITU601 */
769 765 default:
@@ -3941,15 +3937,17 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
3941 3937 }
3942 3938
3943 3939 /* Handle MCCS */
3944 - if (do_mccs) {
3940 + if (do_mccs)
3945 3941 dm_helpers_read_mccs_caps(adev->dm.dc->ctx, amdgpu_dm_connector->dc_link, sink);
3946 3942
3947 - if (sink->edid_caps.freesync_vcp_code && !sink->mccs_caps.freesync_supported)
3948 - freesync_capable = false;
3943 + if ((sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A ||
3944 + as_type == FREESYNC_TYPE_PCON_IN_WHITELIST) &&
3945 + (!sink->edid_caps.freesync_vcp_code ||
3946 + (sink->edid_caps.freesync_vcp_code && !sink->mccs_caps.freesync_supported)))
3947 + freesync_capable = false;
3949 3948
3950 - if (sink->mccs_caps.freesync_supported && freesync_capable)
3951 - dm_helpers_mccs_vcp_set(adev->dm.dc->ctx, amdgpu_dm_connector->dc_link, sink);
3952 - }
3949 + if (do_mccs && sink->mccs_caps.freesync_supported && freesync_capable)
3950 + dm_helpers_mccs_vcp_set(adev->dm.dc->ctx, amdgpu_dm_connector->dc_link, sink);
3953 3951
3954 3952 update:
3955 3953 if (dm_con_state)
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -196,6 +196,7 @@ static ssize_t dp_link_settings_read(struct file *f, char __user *buf,
196 196 char *rd_buf_ptr = NULL;
197 197 const uint32_t rd_buf_size = 100;
198 198 uint32_t result = 0;
199 + uint8_t str_len = 0;
199 200 int r;
200 201
201 202 if (*pos & 3 || size & 3)
@@ -207,26 +208,29 @@ static ssize_t dp_link_settings_read(struct file *f, char __user *buf,
207 208
208 209 rd_buf_ptr = rd_buf;
209 210
210 - rd_buf_ptr += scnprintf(rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf),
211 - "Current: %d 0x%x %d ",
211 + str_len = strlen("Current: %d 0x%x %d ");
212 + snprintf(rd_buf_ptr, str_len, "Current: %d 0x%x %d ",
212 213 link->cur_link_settings.lane_count,
213 214 link->cur_link_settings.link_rate,
214 215 link->cur_link_settings.link_spread);
216 + rd_buf_ptr += str_len;
215 217
216 - rd_buf_ptr += scnprintf(rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf),
217 - "Verified: %d 0x%x %d ",
218 + str_len = strlen("Verified: %d 0x%x %d ");
219 + snprintf(rd_buf_ptr, str_len, "Verified: %d 0x%x %d ",
218 220 link->verified_link_cap.lane_count,
219 221 link->verified_link_cap.link_rate,
220 222 link->verified_link_cap.link_spread);
223 + rd_buf_ptr += str_len;
221 224
222 - rd_buf_ptr += scnprintf(rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf),
223 - "Reported: %d 0x%x %d ",
225 + str_len = strlen("Reported: %d 0x%x %d ");
226 + snprintf(rd_buf_ptr, str_len, "Reported: %d 0x%x %d ",
224 227 link->reported_link_cap.lane_count,
225 228 link->reported_link_cap.link_rate,
226 229 link->reported_link_cap.link_spread);
230 + rd_buf_ptr += str_len;
227 231
228 - rd_buf_ptr += scnprintf(rd_buf_ptr, rd_buf_size - (rd_buf_ptr - rd_buf),
229 - "Preferred: %d 0x%x %d\n",
232 + str_len = strlen("Preferred: %d 0x%x %d ");
233 + snprintf(rd_buf_ptr, str_len, "Preferred: %d 0x%x %d\n",
230 234 link->preferred_link_setting.lane_count,
231 235 link->preferred_link_setting.link_rate,
232 236 link->preferred_link_setting.link_spread);
modified drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -200,7 +200,6 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
200 200 edid_caps->edid_hdmi = connector->display_info.is_hdmi;
201 201
202 202 if (edid_caps->edid_hdmi) {
203 - edid_caps->qs_bit = connector->display_info.rgb_quant_range_selectable;
204 203 populate_hdmi_info_from_connector(link->dc->config.enable_frl, &connector->display_info.hdmi, edid_caps);
205 204 drm_dbg_driver(connector->dev, "%s: HDMI_FRL [%s] max_frl_rate %d\n", __func__, connector->name, edid_caps->max_frl_rate);
206 205 if (edid_caps->frl_dsc_support)
@@ -1203,10 +1202,9 @@ void populate_hdmi_info_from_connector(bool enable_frl, struct drm_hdmi_info *hd
1203 1202 edid_caps->max_frl_rate = get_max_frl_rate(hdmi->max_lanes, hdmi->max_frl_rate_per_lane);
1204 1203 edid_caps->frl_dsc_support = hdmi->dsc_cap.v_1p2;
1205 1204 if (edid_caps->frl_dsc_support) {
1206 - /* HF-VSDB DSC max bpc is cumulative: >=12 implies 10 and 8. */
1207 - if (hdmi->dsc_cap.bpc_supported >= 10)
1205 + if (hdmi->dsc_cap.bpc_supported == 10)
1208 1206 edid_caps->frl_dsc_10bpc = true;
1209 - if (hdmi->dsc_cap.bpc_supported >= 12)
1207 + else if (hdmi->dsc_cap.bpc_supported == 12)
1210 1208 edid_caps->frl_dsc_12bpc = true;
1211 1209 edid_caps->frl_dsc_all_bpp = hdmi->dsc_cap.all_bpp;
1212 1210 edid_caps->frl_dsc_native_420 = hdmi->dsc_cap.native_420;
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
@@ -567,23 +567,6 @@ static void dm_test_output_color_space_bt2020_rgb(struct kunit *test)
567 567 (int)COLOR_SPACE_2020_RGB_FULLRANGE);
568 568 }
569 569
570 - /**
571 - * dm_test_output_color_space_bt2020_rgb_limited - Test limited BT.2020 RGB
572 - * @test: The KUnit test context
573 - */
574 - static void dm_test_output_color_space_bt2020_rgb_limited(struct kunit *test)
575 - {
576 - struct dc_crtc_timing timing = {};
577 - struct drm_connector_state state = {};
578 -
579 - timing.pixel_encoding = PIXEL_ENCODING_RGB;
580 - state.colorspace = DRM_MODE_COLORIMETRY_BT2020_RGB;
581 - state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_LIMITED;
582 -
583 - KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
584 - (int)COLOR_SPACE_2020_RGB_LIMITEDRANGE);
585 - }
586 -
587 570 /**
588 571 * dm_test_output_color_space_bt2020_ycc - Test Output color space bt2020 ycc
589 572 * @test: The KUnit test context
@@ -655,24 +638,6 @@ static void dm_test_output_color_space_bt2020_ycc_rgb_encoding(struct kunit *tes
655 638 (int)COLOR_SPACE_2020_RGB_FULLRANGE);
656 639 }
657 640
658 - /**
659 - * dm_test_output_color_space_bt2020_ycc_rgb_encoding_limited - Test limited
660 - * BT.2020 RGB output selected through the BT.2020 YCC connector colorspace
661 - * @test: The KUnit test context
662 - */
663 - static void dm_test_output_color_space_bt2020_ycc_rgb_encoding_limited(struct kunit *test)
664 - {
665 - struct dc_crtc_timing timing = {};
666 - struct drm_connector_state state = {};
667 -
668 - timing.pixel_encoding = PIXEL_ENCODING_RGB;
669 - state.colorspace = DRM_MODE_COLORIMETRY_BT2020_YCC;
670 - state.hdmi.broadcast_rgb = DRM_HDMI_BROADCAST_RGB_LIMITED;
671 -
672 - KUNIT_EXPECT_EQ(test, (int)amdgpu_dm_get_output_color_space(&timing, &state),
673 - (int)COLOR_SPACE_2020_RGB_LIMITEDRANGE);
674 - }
675 -
676 641 /**
677 642 * dm_test_output_color_space_bt2020_rgb_ycc_encoding - Test Output color space
678 643 * bt2020 rgb with non-rgb pixel encoding falls back to limited ycbcr
@@ -4215,7 +4180,7 @@ dm_test_destroy_connector(struct kunit *test, struct drm_device *drm)
4215 4180 {
4216 4181 struct amdgpu_dm_connector *aconnector;
4217 4182
4218 - aconnector = kzalloc_obj(*aconnector);
4183 + aconnector = kzalloc(sizeof(*aconnector), GFP_KERNEL);
4219 4184 KUNIT_ASSERT_NOT_NULL(test, aconnector);
4220 4185
4221 4186 KUNIT_ASSERT_EQ(test,
@@ -5457,12 +5422,10 @@ static struct kunit_case amdgpu_dm_connector_tests[] = {
5457 5422 KUNIT_CASE(dm_test_output_color_space_bt709_y_only),
5458 5423 KUNIT_CASE(dm_test_output_color_space_oprgb),
5459 5424 KUNIT_CASE(dm_test_output_color_space_bt2020_rgb),
5460 - KUNIT_CASE(dm_test_output_color_space_bt2020_rgb_limited),
5461 5425 KUNIT_CASE(dm_test_output_color_space_bt2020_ycc),
5462 5426 KUNIT_CASE(dm_test_output_color_space_default_ycbcr709_y_only),
5463 5427 KUNIT_CASE(dm_test_output_color_space_default_ycbcr601),
5464 5428 KUNIT_CASE(dm_test_output_color_space_bt2020_ycc_rgb_encoding),
5465 - KUNIT_CASE(dm_test_output_color_space_bt2020_ycc_rgb_encoding_limited),
5466 5429 KUNIT_CASE(dm_test_output_color_space_bt2020_rgb_ycc_encoding),
5467 5430 /* Tests for amdgpu_dm_convert_dc_color_depth_into_bpc */
5468 5431 KUNIT_CASE(dm_test_convert_color_depth_bpc_mappings),
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_helpers_test.c
@@ -358,14 +358,12 @@ static void dm_test_parse_edid_caps_hdmi_frl(struct kunit *test)
358 358
359 359 /* Drive the HDMI/FRL branch */
360 360 connector->display_info.is_hdmi = true;
361 - connector->display_info.rgb_quant_range_selectable = true;
362 361 connector->display_info.hdmi.scdc.supported = true;
363 362 connector->display_info.hdmi.max_lanes = 4;
364 363 connector->display_info.hdmi.max_frl_rate_per_lane = 12;
365 364
366 365 KUNIT_EXPECT_EQ(test, dm_helpers_parse_edid_caps(link, dc_edid, edid_caps), EDID_OK);
367 366 KUNIT_EXPECT_TRUE(test, edid_caps->edid_hdmi);
368 - KUNIT_EXPECT_EQ(test, edid_caps->qs_bit, 1);
369 367 KUNIT_EXPECT_TRUE(test, edid_caps->scdc_present);
370 368 /* max_lanes 4 + max_frl_rate_per_lane 12 -> rate index 6 */
371 369 KUNIT_EXPECT_EQ(test, edid_caps->max_frl_rate, 6);
@@ -911,7 +909,7 @@ static void dm_test_populate_hdmi_frl_dsc_12bpc(struct kunit *test)
911 909
912 910 KUNIT_EXPECT_EQ(test, caps->max_frl_rate, 2);
913 911 KUNIT_EXPECT_TRUE(test, caps->frl_dsc_support);
914 - KUNIT_EXPECT_TRUE(test, caps->frl_dsc_10bpc);
912 + KUNIT_EXPECT_FALSE(test, caps->frl_dsc_10bpc);
915 913 KUNIT_EXPECT_TRUE(test, caps->frl_dsc_12bpc);
916 914 KUNIT_EXPECT_EQ(test, caps->frl_dsc_max_slices, 7);
917 915 KUNIT_EXPECT_EQ(test, caps->frl_dsc_max_frl_rate, 1);
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;
@@ -3198,7 +3199,6 @@ static struct dc_update_descriptor check_update_surfaces_for_stream(
3198 3199 }
3199 3200
3200 3201 if ((stream_update->hdr_static_metadata && !stream_update->stream->use_dynamic_meta) ||
3201 - stream_update->output_color_space ||
3202 3202 stream_update->vrr_infopacket ||
3203 3203 stream_update->vsc_infopacket ||
3204 3204 stream_update->vsp_infopacket ||
@@ -4189,7 +4189,6 @@ static void commit_planes_do_stream_update_sequence(struct dc *dc,
4189 4189 hwss_add_setup_periodic_interrupt(&seq_state, dc, pipe_ctx);
4190 4190
4191 4191 if ((stream_update->hdr_static_metadata && !stream->use_dynamic_meta) ||
4192 - stream_update->output_color_space ||
4193 4192 stream_update->vrr_infopacket ||
4194 4193 stream_update->vsc_infopacket ||
4195 4194 stream_update->vsp_infopacket ||
@@ -4372,7 +4371,6 @@ static void commit_planes_do_stream_update(struct dc *dc,
4372 4371 dc->hwss.setup_periodic_interrupt(dc, pipe_ctx);
4373 4372
4374 4373 if ((stream_update->hdr_static_metadata && !stream->use_dynamic_meta) ||
4375 - stream_update->output_color_space ||
4376 4374 stream_update->vrr_infopacket ||
4377 4375 stream_update->vsc_infopacket ||
4378 4376 stream_update->vsp_infopacket ||
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/amdgpu_dpm.c
@@ -348,8 +348,7 @@ int amdgpu_dpm_switch_power_profile(struct amdgpu_device *adev,
348 348 const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
349 349 int ret = 0;
350 350
351 - if (amdgpu_sriov_vf(adev) ||
352 - amdgpu_in_reset(adev))
351 + if (amdgpu_sriov_vf(adev))
353 352 return 0;
354 353
355 354 if (pp_funcs && pp_funcs->switch_power_profile) {
@@ -368,8 +367,7 @@ int amdgpu_dpm_pause_power_profile(struct amdgpu_device *adev,
368 367 const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
369 368 int ret = 0;
370 369
371 - if (amdgpu_sriov_vf(adev) ||
372 - amdgpu_in_reset(adev))
370 + if (amdgpu_sriov_vf(adev))
373 371 return 0;
374 372
375 373 if (pp_funcs && pp_funcs->pause_power_profile) {
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/smu13/smu_v13_0_0_ppt.c
@@ -2092,11 +2092,11 @@ static ssize_t smu_v13_0_0_get_gpu_metrics(struct smu_context *smu,
2092 2092
2093 2093 gpu_metrics->average_socket_power = metrics->AverageSocketPower;
2094 2094
2095 - if ((mp1_ver == IP_VERSION(13, 0, 0) &&
2096 - (smu->smc_fw_version <= 0x004e1e00 || smu->smc_fw_version >= 0x004e8600)) ||
2097 - (mp1_ver == IP_VERSION(13, 0, 10) &&
2098 - smu->smc_fw_version <= 0x00500800))
2095 + if ((mp1_ver == IP_VERSION(13, 0, 0) && smu->smc_fw_version <= 0x004e1e00) ||
2096 + (mp1_ver == IP_VERSION(13, 0, 10) && smu->smc_fw_version <= 0x00500800))
2099 2097 gpu_metrics->energy_accumulator = metrics->EnergyAccumulator;
2098 + else
2099 + gpu_metrics->energy_accumulator = UINT_MAX;
2100 2100
2101 2101 if (metrics->AverageGfxActivity <= SMU_13_0_0_BUSY_THRESHOLD)
2102 2102 gpu_metrics->average_gfxclk_frequency = metrics->AverageGfxclkFrequencyPostDs;
modified drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
@@ -2097,8 +2097,8 @@ static ssize_t smu_v13_0_7_get_gpu_metrics(struct smu_context *smu,
2097 2097 metrics->Vcn1ActivityPercentage);
2098 2098
2099 2099 gpu_metrics->average_socket_power = metrics->AverageSocketPower;
2100 - if (smu->smc_fw_version <= 0x00521400)
2101 - gpu_metrics->energy_accumulator = metrics->EnergyAccumulator;
2100 + gpu_metrics->energy_accumulator = smu->smc_fw_version <= 0x00521400 ?
2101 + metrics->EnergyAccumulator : UINT_MAX;
2102 2102
2103 2103 if (metrics->AverageGfxActivity <= SMU_13_0_7_BUSY_THRESHOLD)
2104 2104 gpu_metrics->average_gfxclk_frequency = metrics->AverageGfxclkFrequencyPostDs;
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/aspeed/aspeed_gfx_drv.c
@@ -189,12 +189,13 @@ static int aspeed_gfx_load(struct drm_device *drm)
189 189 }
190 190 reset_control_deassert(priv->rst);
191 191
192 - priv->clk = devm_clk_get_enabled(drm->dev, NULL);
192 + priv->clk = devm_clk_get(drm->dev, NULL);
193 193 if (IS_ERR(priv->clk)) {
194 194 dev_err(&pdev->dev,
195 - "failed to get and enable clock\n");
195 + "missing or invalid clk device tree entry");
196 196 return PTR_ERR(priv->clk);
197 197 }
198 + clk_prepare_enable(priv->clk);
198 199
199 200 /* Sanitize control registers */
200 201 writel(0, priv->base + CRT_CTRL1);
modified drivers/gpu/drm/ast/ast_cursor.c
@@ -25,7 +25,6 @@
25 25 #include <linux/sizes.h>
26 26
27 27 #include <drm/drm_atomic.h>
28 - #include <drm/drm_blend.h>
29 28 #include <drm/drm_damage_helper.h>
30 29 #include <drm/drm_format_helper.h>
31 30 #include <drm/drm_gem_atomic_helper.h>
@@ -356,8 +355,6 @@ int ast_cursor_plane_init(struct ast_device *ast)
356 355 }
357 356 drm_plane_helper_add(cursor_plane, &ast_cursor_plane_helper_funcs);
358 357 drm_plane_enable_fb_damage_clips(cursor_plane);
359 - drm_plane_create_blend_mode_property(cursor_plane,
360 - BIT(DRM_MODE_BLEND_COVERAGE));
361 358
362 359 return 0;
363 360 }
modified drivers/gpu/drm/bridge/samsung-dsim.c
@@ -1862,7 +1862,7 @@ static int samsung_dsim_register_te_irq(struct samsung_dsim *dsi, struct device
1862 1862 int te_gpio_irq;
1863 1863 int ret;
1864 1864
1865 - dsi->te_gpio = gpiod_get_optional(dev, "te", GPIOD_IN);
1865 + dsi->te_gpio = devm_gpiod_get_optional(dev, "te", GPIOD_IN);
1866 1866 if (!dsi->te_gpio)
1867 1867 return 0;
1868 1868 else if (IS_ERR(dsi->te_gpio))
modified drivers/gpu/drm/bridge/tc358768.c
@@ -1263,13 +1263,10 @@ tc358768_atomic_get_input_bus_fmts(struct drm_bridge *bridge,
1263 1263 return input_fmts;
1264 1264 }
1265 1265
1266 - static int tc358768_bridge_atomic_check(struct drm_bridge *bridge,
1267 - struct drm_bridge_state *bridge_state,
1268 - struct drm_crtc_state *crtc_state,
1269 - struct drm_connector_state *conn_state)
1266 + static bool tc358768_mode_fixup(struct drm_bridge *bridge,
1267 + const struct drm_display_mode *mode,
1268 + struct drm_display_mode *adjusted_mode)
1270 1269 {
1271 - struct drm_display_mode *adjusted_mode = &crtc_state->adjusted_mode;
1272 -
1273 1270 /* Default to positive sync */
1274 1271
1275 1272 if (!(adjusted_mode->flags &
@@ -1280,15 +1277,13 @@ static int tc358768_bridge_atomic_check(struct drm_bridge *bridge,
1280 1277 (DRM_MODE_FLAG_PVSYNC | DRM_MODE_FLAG_NVSYNC)))
1281 1278 adjusted_mode->flags |= DRM_MODE_FLAG_PVSYNC;
1282 1279
1283 - bridge_state->input_bus_cfg.flags = bridge->timings->input_bus_flags;
1284 -
1285 - return 0;
1280 + return true;
1286 1281 }
1287 1282
1288 1283 static const struct drm_bridge_funcs tc358768_bridge_funcs = {
1289 1284 .attach = tc358768_bridge_attach,
1290 1285 .mode_valid = tc358768_bridge_mode_valid,
1291 - .atomic_check = tc358768_bridge_atomic_check,
1286 + .mode_fixup = tc358768_mode_fixup,
1292 1287 .atomic_pre_enable = tc358768_bridge_atomic_pre_enable,
1293 1288 .atomic_enable = tc358768_bridge_atomic_enable,
1294 1289 .atomic_disable = tc358768_bridge_atomic_disable,
modified drivers/gpu/drm/bridge/th1520-dw-hdmi.c
@@ -135,8 +135,8 @@ static int th1520_dw_hdmi_probe(struct platform_device *pdev)
135 135 plat_data->priv_data = hdmi;
136 136
137 137 hdmi->dw_hdmi = dw_hdmi_probe(pdev, plat_data);
138 - if (IS_ERR(hdmi->dw_hdmi))
139 - return PTR_ERR(hdmi->dw_hdmi);
138 + if (IS_ERR(hdmi))
139 + return PTR_ERR(hdmi);
140 140
141 141 platform_set_drvdata(pdev, hdmi);
142 142
@@ -145,9 +145,9 @@ static int th1520_dw_hdmi_probe(struct platform_device *pdev)
145 145
146 146 static void th1520_dw_hdmi_remove(struct platform_device *pdev)
147 147 {
148 - struct th1520_hdmi *hdmi = platform_get_drvdata(pdev);
148 + struct dw_hdmi *hdmi = platform_get_drvdata(pdev);
149 149
150 - dw_hdmi_remove(hdmi->dw_hdmi);
150 + dw_hdmi_remove(hdmi);
151 151 }
152 152
153 153 static const struct of_device_id th1520_dw_hdmi_of_table[] = {
modified drivers/gpu/drm/bridge/ti-sn65dsi83.c
@@ -403,7 +403,7 @@ retry:
403 403 drm_modeset_drop_locks(&ctx);
404 404 drm_modeset_acquire_fini(&ctx);
405 405
406 - return err;
406 + return 0;
407 407 }
408 408
409 409 static void sn65dsi83_reset_work(struct work_struct *ws)
@@ -419,13 +419,11 @@ static void sn65dsi83_reset_work(struct work_struct *ws)
419 419 ret = sn65dsi83_reset_pipe(ctx);
420 420 if (ret) {
421 421 dev_err(ctx->dev, "reset pipe failed %pe\n", ERR_PTR(ret));
422 - goto bridge_exit;
422 + return;
423 423 }
424 -
425 424 if (ctx->irq)
426 425 enable_irq(ctx->irq);
427 426
428 - bridge_exit:
429 427 drm_bridge_exit(idx);
430 428 }
431 429
modified drivers/gpu/drm/clients/drm_fbdev_client.c
@@ -42,14 +42,6 @@ static int drm_fbdev_client_restore(struct drm_client_dev *client, bool force)
42 42 {
43 43 struct drm_fb_helper *fb_helper = drm_fb_helper_from_client(client);
44 44
45 - /*
46 - * The client is registered before the initial fbdev probe.
47 - * If probing failed, the client remains registered but there
48 - * is no valid fbdev framebuffer to restore.
49 - */
50 - if (!fb_helper->info || !fb_helper->fb)
51 - return 0;
52 -
53 45 drm_fb_helper_restore_fbdev_mode_unlocked(fb_helper, force);
54 46
55 47 return 0;
modified drivers/gpu/drm/display/drm_dp_helper.c
@@ -4634,9 +4634,7 @@ static int dp_aux_backlight_update_status(struct backlight_device *bd)
4634 4634
4635 4635 if (!backlight_is_blank(bd)) {
4636 4636 if (!bl->enabled) {
4637 - ret = drm_edp_backlight_enable(bl->aux, &bl->info, brightness);
4638 - if (ret)
4639 - return ret;
4637 + drm_edp_backlight_enable(bl->aux, &bl->info, brightness);
4640 4638 bl->enabled = true;
4641 4639 return 0;
4642 4640 }
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) {
@@ -1462,12 +1465,10 @@ static int prepare_signaling(struct drm_device *dev,
1462 1465 struct dma_fence *fence;
1463 1466 struct drm_out_fence_state *f;
1464 1467
1465 - ret = -ENOMEM;
1466 -
1467 1468 f = krealloc(*fence_state, sizeof(**fence_state) *
1468 1469 (*num_fences + 1), GFP_KERNEL);
1469 1470 if (!f)
1470 - goto err_free_event;
1471 + return -ENOMEM;
1471 1472
1472 1473 memset(&f[*num_fences], 0, sizeof(*f));
1473 1474
@@ -1476,12 +1477,12 @@ static int prepare_signaling(struct drm_device *dev,
1476 1477
1477 1478 fence = drm_crtc_create_fence(crtc);
1478 1479 if (!fence)
1479 - goto err_free_event;
1480 + return -ENOMEM;
1480 1481
1481 1482 ret = setup_out_fence(&f[(*num_fences)++], fence);
1482 1483 if (ret) {
1483 1484 dma_fence_put(fence);
1484 - goto err_free_event;
1485 + return ret;
1485 1486 }
1486 1487
1487 1488 crtc_state->event->base.fence = fence;
@@ -1537,11 +1538,6 @@ static int prepare_signaling(struct drm_device *dev,
1537 1538 }
1538 1539
1539 1540 return 0;
1540 -
1541 - err_free_event:
1542 - drm_event_cancel_free(dev, &crtc_state->event->base);
1543 - crtc_state->event = NULL;
1544 - return ret;
1545 1541 }
1546 1542
1547 1543 static void complete_signaling(struct drm_device *dev,
@@ -1571,8 +1567,6 @@ static void complete_signaling(struct drm_device *dev,
1571 1567 * to prevent a double free in drm_atomic_commit_clear.
1572 1568 */
1573 1569 if (event && (event->base.fence || event->base.file_priv)) {
1574 - if (crtc_state->commit && crtc_state->commit->abort_completion)
1575 - drm_crtc_commit_put(crtc_state->commit);
1576 1570 drm_event_cancel_free(dev, &event->base);
1577 1571 crtc_state->event = NULL;
1578 1572 }
modified drivers/gpu/drm/drm_bridge.c
@@ -454,10 +454,8 @@ void drm_bridge_add(struct drm_bridge *bridge)
454 454 * in bridge_lingering_list. Remove it or bridge_lingering_list will be
455 455 * corrupted when adding this bridge to bridge_list below.
456 456 */
457 - mutex_lock(&bridge_lock);
458 457 if (!list_empty(&bridge->list))
459 458 list_del_init(&bridge->list);
460 - mutex_unlock(&bridge_lock);
461 459
462 460 mutex_init(&bridge->hpd_state_mutex);
463 461 mutex_init(&bridge->hpd_mutex);
@@ -595,10 +593,8 @@ int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
595 593 if (!bridge->container)
596 594 DRM_WARN("DRM bridge corrupted or not allocated by devm_drm_bridge_alloc()\n");
597 595
598 - scoped_guard(mutex, &bridge_lock) {
599 - if (list_empty(&bridge->list))
600 - DRM_WARN("Missing drm_bridge_add() before attach\n");
601 - }
596 + if (list_empty(&bridge->list))
597 + DRM_WARN("Missing drm_bridge_add() before attach\n");
602 598
603 599 drm_bridge_get(bridge);
604 600
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;
@@ -322,19 +322,6 @@ int drm_exec_prepare_array(struct drm_exec *exec,
322 322 {
323 323 int ret;
324 324
325 - /*
326 - * Make sure to lock a contended object even when no objects are
327 - * given, otherwise drm_exec_retry_on_contention() would loop
328 - * forever on patterns like:
329 - *
330 - * ret = drm_exec_prepare_array(exec, objs, num_objects, ...);
331 - * drm_exec_retry_on_contention(exec);
332 - *
333 - * with num_objects == 0.
334 - */
335 - if (!num_objects)
336 - return drm_exec_lock_contended(exec);
337 -
338 325 for (unsigned int i = 0; i < num_objects; ++i) {
339 326 ret = drm_exec_prepare_obj(exec, objects[i], num_fences);
340 327 if (unlikely(ret))
modified drivers/gpu/drm/drm_fb_helper.c
@@ -1724,10 +1724,10 @@ __drm_fb_helper_initial_config_and_unlock(struct drm_fb_helper *fb_helper)
1724 1724
1725 1725 ret = drm_fb_helper_single_fb_probe(fb_helper);
1726 1726 if (ret < 0) {
1727 - /* modesets are probed but fb_helper->fb isn't; defer restore too */
1728 - fb_helper->deferred_setup = true;
1729 - if (ret == -EAGAIN)
1727 + if (ret == -EAGAIN) {
1728 + fb_helper->deferred_setup = true;
1730 1729 ret = 0;
1730 + }
1731 1731 mutex_unlock(&fb_helper->lock);
1732 1732
1733 1733 goto err_drm_fb_helper_release_info;
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_panic_qr.rs
@@ -407,8 +407,8 @@ impl DecFifo {
407 407 for i in (0..self.len).rev() {
408 408 self.decimals[i + len] = self.decimals[i];
409 409 }
410 - for decimal in &mut self.decimals[..len] {
411 - *decimal = (chunk % 10) as u8;
410 + for i in 0..len {
411 + self.decimals[i] = (chunk % 10) as u8;
412 412 chunk = div10(chunk);
413 413 }
414 414 self.len += len;
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/gud/gud_pipe.c
@@ -482,9 +482,6 @@ int gud_plane_atomic_check(struct drm_plane *plane,
482 482 if (!new_plane_state->visible)
483 483 return 0;
484 484
485 - if (gdrm->flags & GUD_DISPLAY_FLAG_FULL_UPDATE)
486 - new_plane_state->ignore_damage_clips = true;
487 -
488 485 if (old_plane_state->rotation != new_plane_state->rotation)
489 486 crtc_state->mode_changed = true;
490 487
@@ -507,7 +504,6 @@ int gud_plane_atomic_check(struct drm_plane *plane,
507 504 for_each_new_connector_in_state(state, connector, connector_state, i) {
508 505 if (connector_state->crtc)
509 506 break;
510 - connector_state = NULL;
511 507 }
512 508
513 509 /*
@@ -566,8 +562,8 @@ int gud_plane_atomic_check(struct drm_plane *plane,
566 562 goto out;
567 563 }
568 564
569 - req->properties[num_properties].prop = cpu_to_le16(prop);
570 - req->properties[num_properties].val = cpu_to_le64(val);
565 + req->properties[num_properties + i].prop = cpu_to_le16(prop);
566 + req->properties[num_properties + i].val = cpu_to_le64(val);
571 567 num_properties++;
572 568 }
573 569
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_display_types.h
@@ -1946,8 +1946,6 @@ struct intel_dp {
1946 1946
1947 1947 bool colorimetry_support;
1948 1948
1949 - bool sst_split_sdp_support;
1950 -
1951 1949 struct {
1952 1950 enum transcoder transcoder;
1953 1951 struct mutex lock;
modified drivers/gpu/drm/i915/display/intel_dp.c
@@ -3409,22 +3409,12 @@ intel_dp_audio_compute_config(struct intel_encoder *encoder,
3409 3409 struct intel_crtc_state *pipe_config,
3410 3410 struct drm_connector_state *conn_state)
3411 3411 {
3412 - struct intel_dp *intel_dp = enc_to_intel_dp(encoder);
3413 -
3414 3412 pipe_config->has_audio =
3415 3413 intel_dp_has_audio(encoder, conn_state) &&
3416 3414 intel_audio_compute_config(encoder, pipe_config, conn_state);
3417 3415
3418 3416 pipe_config->sdp_split_enable = pipe_config->has_audio &&
3419 3417 intel_dp_is_uhbr(pipe_config);
3420 -
3421 - /*
3422 - * SDP splitting for UHBR audio requires explicit sink capability in
3423 - * SST mode, whereas in MST mode it is inherently supported.
3424 - */
3425 - if (pipe_config->sdp_split_enable &&
3426 - !intel_crtc_has_type(pipe_config, INTEL_OUTPUT_DP_MST))
3427 - pipe_config->sdp_split_enable = intel_dp->sst_split_sdp_support;
3428 3418 }
3429 3419
3430 3420 void
@@ -4472,25 +4462,16 @@ void intel_dp_configure_protocol_converter(struct intel_dp *intel_dp,
4472 4462 str_enable_disable(tmp));
4473 4463 }
4474 4464
4475 - static u8 intel_dp_read_dprx_feature_enum(struct intel_dp *intel_dp)
4465 + static bool intel_dp_get_colorimetry_status(struct intel_dp *intel_dp)
4476 4466 {
4477 4467 u8 dprx = 0;
4478 4468
4479 - drm_dp_dpcd_read_data(&intel_dp->aux, DP_DPRX_FEATURE_ENUMERATION_LIST,
4480 - &dprx, sizeof(dprx));
4481 - return dprx;
4482 - }
4483 -
4484 - static bool intel_dp_get_colorimetry_status(u8 dprx)
4485 - {
4469 + if (drm_dp_dpcd_readb(&intel_dp->aux, DP_DPRX_FEATURE_ENUMERATION_LIST,
4470 + &dprx) != 1)
4471 + return false;
4486 4472 return dprx & DP_VSC_SDP_EXT_FOR_COLORIMETRY_SUPPORTED;
4487 4473 }
4488 4474
4489 - static bool intel_dp_get_sst_split_sdp_status(u8 dprx)
4490 - {
4491 - return dprx & DP_SST_SPLIT_SDP_CAP;
4492 - }
4493 -
4494 4475 static int intel_dp_read_dsc_dpcd(struct drm_dp_aux *aux,
4495 4476 u8 dsc_dpcd[DP_DSC_RECEIVER_CAP_SIZE])
4496 4477 {
@@ -4790,7 +4771,6 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp, struct intel_connector *connector
4790 4771 {
4791 4772 struct intel_display *display = to_intel_display(intel_dp);
4792 4773 int ret;
4793 - u8 dprx;
4794 4774
4795 4775 /* this function is meant to be called only once */
4796 4776 drm_WARN_ON(display->drm, intel_dp->dpcd[DP_DPCD_REV] != 0);
@@ -4802,13 +4782,8 @@ intel_edp_init_dpcd(struct intel_dp *intel_dp, struct intel_connector *connector
4802 4782 drm_dp_is_branch(intel_dp->dpcd));
4803 4783 intel_init_dpcd_quirks(intel_dp, &intel_dp->desc.ident);
4804 4784
4805 - dprx = intel_dp_read_dprx_feature_enum(intel_dp);
4806 -
4807 4785 intel_dp->colorimetry_support =
4808 - intel_dp_get_colorimetry_status(dprx);
4809 -
4810 - intel_dp->sst_split_sdp_support =
4811 - intel_dp_get_sst_split_sdp_status(dprx);
4786 + intel_dp_get_colorimetry_status(intel_dp);
4812 4787
4813 4788 /*
4814 4789 * Read the eDP display control registers.
@@ -4899,20 +4874,13 @@ intel_dp_get_dpcd(struct intel_dp *intel_dp)
4899 4874 * the OUI/ID since we know it won't change.
4900 4875 */
4901 4876 if (!intel_dp_is_edp(intel_dp)) {
4902 - u8 dprx;
4903 -
4904 4877 drm_dp_read_desc(&intel_dp->aux, &intel_dp->desc,
4905 4878 drm_dp_is_branch(intel_dp->dpcd));
4906 4879
4907 4880 intel_init_dpcd_quirks(intel_dp, &intel_dp->desc.ident);
4908 4881
4909 - dprx = intel_dp_read_dprx_feature_enum(intel_dp);
4910 -
4911 4882 intel_dp->colorimetry_support =
4912 - intel_dp_get_colorimetry_status(dprx);
4913 -
4914 - intel_dp->sst_split_sdp_support =
4915 - intel_dp_get_sst_split_sdp_status(dprx);
4883 + intel_dp_get_colorimetry_status(intel_dp);
4916 4884
4917 4885 intel_dp_update_sink_caps(intel_dp);
4918 4886 }
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/i915/i915_query.c
@@ -403,10 +403,8 @@ static int query_perf_config_list(struct drm_i915_private *i915,
403 403 ids = krealloc(oa_config_ids,
404 404 n_configs * sizeof(*oa_config_ids),
405 405 GFP_KERNEL);
406 - if (!ids) {
407 - kfree(oa_config_ids);
406 + if (!ids)
408 407 return -ENOMEM;
409 - }
410 408
411 409 alloc = fetch_and_zero(&n_configs);
412 410
modified drivers/gpu/drm/imagination/pvr_free_list.c
@@ -8,7 +8,6 @@
8 8 #include "pvr_vm.h"
9 9
10 10 #include <drm/drm_gem.h>
11 - #include <drm/drm_print.h>
12 11 #include <linux/slab.h>
13 12 #include <linux/xarray.h>
14 13 #include <uapi/drm/pvr_drm.h>
@@ -613,21 +612,13 @@ pvr_free_list_process_reconstruct_req(struct pvr_device *pvr_dev,
613 612 };
614 613 struct rogue_fwif_freelists_reconstruction_data *resp =
615 614 &resp_cmd.cmd_data.free_lists_reconstruction_data;
616 - u32 count = min_t(u32, req->freelist_count,
617 - ARRAY_SIZE(req->freelist_ids));
618 615
619 - if (count != req->freelist_count) {
620 - drm_warn_once(from_pvr_device(pvr_dev),
621 - "Requested reconstruction of %u freelists, limiting to %u\n",
622 - req->freelist_count, count);
623 - }
624 -
625 - for (u32 i = 0; i < count; i++)
616 + for (u32 i = 0; i < req->freelist_count; i++)
626 617 pvr_free_list_reconstruct(pvr_dev, req->freelist_ids[i]);
627 618
628 - resp->freelist_count = count;
619 + resp->freelist_count = req->freelist_count;
629 620 memcpy(resp->freelist_ids, req->freelist_ids,
630 - count * sizeof(resp->freelist_ids[0]));
621 + req->freelist_count * sizeof(resp->freelist_ids[0]));
631 622
632 623 WARN_ON(pvr_kccb_send_cmd(pvr_dev, &resp_cmd, NULL));
633 624 }
modified drivers/gpu/drm/imagination/pvr_mmu.c
@@ -12,7 +12,6 @@
12 12 #include "pvr_rogue_mmu_defs.h"
13 13
14 14 #include <drm/drm_drv.h>
15 - #include <drm/drm_print.h>
16 15 #include <linux/atomic.h>
17 16 #include <linux/bitops.h>
18 17 #include <linux/dma-mapping.h>
@@ -2336,8 +2335,7 @@ void pvr_mmu_op_context_destroy(struct pvr_mmu_op_context *op_ctx)
2336 2335 * pvr_mmu_op_context_create() - Create an MMU op context.
2337 2336 * @ctx: MMU context associated with owning VM context.
2338 2337 * @sgt: Scatter gather table containing pages pinned for use by this context.
2339 - * @device_addr: Virtual device address at the start of the requested mapping.
2340 - * @sgt_offset: Offset into @sgt of the start of the requested mapping.
2338 + * @sgt_offset: Start offset of the requested device-virtual memory mapping.
2341 2339 * @size: Size in bytes of the requested device-virtual memory mapping. For an
2342 2340 * unmapping, this should be zero so that no page tables are allocated.
2343 2341 *
@@ -2348,7 +2346,7 @@ void pvr_mmu_op_context_destroy(struct pvr_mmu_op_context *op_ctx)
2348 2346 */
2349 2347 struct pvr_mmu_op_context *
2350 2348 pvr_mmu_op_context_create(struct pvr_mmu_context *ctx, struct sg_table *sgt,
2351 - u64 device_addr, u64 sgt_offset, u64 size)
2349 + u64 sgt_offset, u64 size)
2352 2350 {
2353 2351 int err;
2354 2352
@@ -2364,18 +2362,18 @@ pvr_mmu_op_context_create(struct pvr_mmu_context *ctx, struct sg_table *sgt,
2364 2362
2365 2363 if (size) {
2366 2364 /*
2367 - * The page tables needed are set by the device-virtual range
2368 - * being mapped: one level 1 table per 1GiB region and one
2369 - * level 0 table per 2MiB region the range touches. Tables that
2370 - * already exist are not consumed, so this is an upper bound.
2365 + * The number of page table objects we need to prealloc is
2366 + * indicated by the mapping size, start offset and the sizes
2367 + * of the areas mapped per PT or PD. The range calculation is
2368 + * identical to that for the index into a table for a device
2369 + * address, so we reuse those functions here.
2371 2370 */
2372 - const u64 last_addr = device_addr + size - 1;
2373 - const u64 l1_count =
2374 - (last_addr >> ROGUE_MMUCTRL_VADDR_PC_INDEX_SHIFT) -
2375 - (device_addr >> ROGUE_MMUCTRL_VADDR_PC_INDEX_SHIFT) + 1;
2376 - const u64 l0_count =
2377 - (last_addr >> ROGUE_MMUCTRL_VADDR_PD_INDEX_SHIFT) -
2378 - (device_addr >> ROGUE_MMUCTRL_VADDR_PD_INDEX_SHIFT) + 1;
2371 + const u32 l1_start_idx = pvr_page_table_l2_idx(sgt_offset);
2372 + const u32 l1_end_idx = pvr_page_table_l2_idx(sgt_offset + size);
2373 + const u32 l1_count = l1_end_idx - l1_start_idx + 1;
2374 + const u32 l0_start_idx = pvr_page_table_l1_idx(sgt_offset);
2375 + const u32 l0_end_idx = pvr_page_table_l1_idx(sgt_offset + size);
2376 + const u32 l0_count = l0_end_idx - l0_start_idx + 1;
2379 2377
2380 2378 /*
2381 2379 * Alloc and push page table entries until we have enough of
@@ -2555,9 +2553,7 @@ pvr_mmu_map_sgl(struct pvr_mmu_op_context *op_ctx, struct scatterlist *sgl,
2555 2553
2556 2554 err_destroy_pages:
2557 2555 memcpy(&op_ctx->curr_page, &ptr_copy, sizeof(op_ctx->curr_page));
2558 - if (pvr_mmu_op_context_unmap_curr_page(op_ctx, page))
2559 - drm_err(from_pvr_device(op_ctx->mmu_ctx->pvr_dev),
2560 - "%s : Failure in unmapping pages\n", __func__);
2556 + err = pvr_mmu_op_context_unmap_curr_page(op_ctx, page);
2561 2557
2562 2558 return err;
2563 2559 }
modified drivers/gpu/drm/imagination/pvr_mmu.h
@@ -99,7 +99,7 @@ dma_addr_t pvr_mmu_get_root_table_dma_addr(struct pvr_mmu_context *ctx);
99 99 void pvr_mmu_op_context_destroy(struct pvr_mmu_op_context *op_ctx);
100 100 struct pvr_mmu_op_context *
101 101 pvr_mmu_op_context_create(struct pvr_mmu_context *ctx,
102 - struct sg_table *sgt, u64 device_addr, u64 sgt_offset, u64 size);
102 + struct sg_table *sgt, u64 sgt_offset, u64 size);
103 103
104 104 int pvr_mmu_map(struct pvr_mmu_op_context *op_ctx, u64 size, u64 flags,
105 105 u64 device_addr);
modified drivers/gpu/drm/imagination/pvr_vm.c
@@ -276,7 +276,7 @@ pvr_vm_bind_op_map_init(struct pvr_vm_bind_op *bind_op,
276 276 goto err_bind_op_fini;
277 277
278 278 bind_op->mmu_op_ctx =
279 - pvr_mmu_op_context_create(vm_ctx->mmu_ctx, sgt, device_addr, offset, size);
279 + pvr_mmu_op_context_create(vm_ctx->mmu_ctx, sgt, offset, size);
280 280 err = PTR_ERR_OR_ZERO(bind_op->mmu_op_ctx);
281 281 if (err) {
282 282 bind_op->mmu_op_ctx = NULL;
@@ -318,7 +318,7 @@ pvr_vm_bind_op_unmap_init(struct pvr_vm_bind_op *bind_op,
318 318 }
319 319
320 320 bind_op->mmu_op_ctx =
321 - pvr_mmu_op_context_create(vm_ctx->mmu_ctx, NULL, device_addr, 0, 0);
321 + pvr_mmu_op_context_create(vm_ctx->mmu_ctx, NULL, 0, 0);
322 322 err = PTR_ERR_OR_ZERO(bind_op->mmu_op_ctx);
323 323 if (err) {
324 324 bind_op->mmu_op_ctx = NULL;
@@ -418,8 +418,6 @@ pvr_vm_gpuva_unmap(struct drm_gpuva_op *op, void *op_ctx)
418 418 static int
419 419 pvr_vm_gpuva_remap(struct drm_gpuva_op *op, void *op_ctx)
420 420 {
421 - /* The split parts belong to the object of the mapping being split. */
422 - struct drm_gpuvm_bo *vm_bo = op->remap.unmap->va->vm_bo;
423 421 struct pvr_vm_bind_op *ctx = op_ctx;
424 422 u64 va_start = 0, va_range = 0;
425 423 int err;
@@ -435,12 +433,14 @@ pvr_vm_gpuva_remap(struct drm_gpuva_op *op, void *op_ctx)
435 433 drm_gpuva_remap(&ctx->prev_va->base, &ctx->next_va->base, &op->remap);
436 434
437 435 if (op->remap.prev) {
438 - drm_gpuva_link(&ctx->prev_va->base, vm_bo);
436 + pvr_gem_object_get(gem_to_pvr_gem(ctx->prev_va->base.gem.obj));
437 + drm_gpuva_link(&ctx->prev_va->base, ctx->gpuvm_bo);
439 438 ctx->prev_va = NULL;
440 439 }
441 440
442 441 if (op->remap.next) {
443 - drm_gpuva_link(&ctx->next_va->base, vm_bo);
442 + pvr_gem_object_get(gem_to_pvr_gem(ctx->next_va->base.gem.obj));
443 + drm_gpuva_link(&ctx->next_va->base, ctx->gpuvm_bo);
444 444 ctx->next_va = NULL;
445 445 }
446 446
modified drivers/gpu/drm/logicvc/Kconfig
@@ -4,6 +4,7 @@ config DRM_LOGICVC
4 4 depends on OF || COMPILE_TEST
5 5 select DRM_CLIENT_SELECTION
6 6 select DRM_KMS_HELPER
7 + select DRM_KMS_DMA_HELPER
7 8 select DRM_GEM_DMA_HELPER
8 9 select REGMAP
9 10 select REGMAP_MMIO
modified drivers/gpu/drm/loongson/lsdc_plane.c
@@ -7,7 +7,6 @@
7 7
8 8 #include <drm/drm_atomic.h>
9 9 #include <drm/drm_atomic_helper.h>
10 - #include <drm/drm_blend.h>
11 10 #include <drm/drm_framebuffer.h>
12 11 #include <drm/drm_gem_atomic_helper.h>
13 12 #include <drm/drm_print.h>
@@ -766,7 +765,7 @@ int ls7a1000_cursor_plane_init(struct drm_device *ddev,
766 765
767 766 drm_plane_helper_add(plane, &ls7a1000_cursor_plane_helper_funcs);
768 767
769 - return drm_plane_create_blend_mode_property(plane, BIT(DRM_MODE_BLEND_COVERAGE));
768 + return 0;
770 769 }
771 770
772 771 int ls7a2000_cursor_plane_init(struct drm_device *ddev,
@@ -791,5 +790,5 @@ int ls7a2000_cursor_plane_init(struct drm_device *ddev,
791 790
792 791 drm_plane_helper_add(plane, &ls7a2000_cursor_plane_helper_funcs);
793 792
794 - return drm_plane_create_blend_mode_property(plane, BIT(DRM_MODE_BLEND_COVERAGE));
793 + return 0;
795 794 }
modified drivers/gpu/drm/nouveau/include/nvif/cl0080.h
@@ -4,7 +4,6 @@
4 4
5 5 #define NV_DEVICE_V0_INFO 0x00
6 6 #define NV_DEVICE_V0_TIME 0x01
7 - #define NV_DEVICE_V0_GCX_READY 0x02
8 7
9 8 struct nv_device_info_v0 {
10 9 __u8 version;
@@ -56,15 +55,6 @@ struct nv_device_time_v0 {
56 55 __u64 time;
57 56 };
58 57
59 - #define NV_DEVICE_GC6_READY BIT(0)
60 - #define NV_DEVICE_GCOFF_READY BIT(1)
61 -
62 - struct nv_device_gcx_ready_v0 {
63 - __u8 version;
64 - __u8 pad01[6];
65 - __u8 ready;
66 - };
67 -
68 58 #define NV_DEVICE_INFO_UNIT (0xffffffffULL << 32)
69 59 #define NV_DEVICE_INFO(n) ((n) | (0x00000000ULL << 32))
70 60 #define NV_DEVICE_HOST(n) ((n) | (0x00000001ULL << 32))
modified drivers/gpu/drm/nouveau/include/nvif/device.h
@@ -22,5 +22,4 @@ int nvif_device_ctor(struct nvif_client *, const char *name, struct nvif_device
22 22 void nvif_device_dtor(struct nvif_device *);
23 23 int nvif_device_map(struct nvif_device *);
24 24 u64 nvif_device_time(struct nvif_device *);
25 - int nvif_device_gcx_ready(struct nvif_device *);
26 25 #endif
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/include/nvkm/subdev/gsp.h
@@ -156,10 +156,6 @@ struct nvkm_gsp {
156 156 struct sg_table fbsr;
157 157 } sr;
158 158
159 - struct {
160 - bool use_raw_mode_comptagline_alloc;
161 - } memsys;
162 -
163 159 struct {
164 160 struct nvkm_gsp_mem mem;
165 161
@@ -499,8 +495,6 @@ nvkm_gsp_event_dtor(struct nvkm_gsp_event *event)
499 495 int nvkm_gsp_intr_stall(struct nvkm_gsp *, enum nvkm_subdev_type, int);
500 496 int nvkm_gsp_intr_nonstall(struct nvkm_gsp *, enum nvkm_subdev_type, int);
501 497
502 - int nvkm_gsp_gcx_ready(struct nvkm_gsp *gsp);
503 -
504 498 int gv100_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **);
505 499 int tu102_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **);
506 500 int tu116_gsp_new(struct nvkm_device *, enum nvkm_subdev_type, int, struct nvkm_gsp **);
modified drivers/gpu/drm/nouveau/nouveau_abi16.c
@@ -488,7 +488,7 @@ nouveau_abi16_ioctl_channel_alloc(ABI16_IOCTL_ARGS)
488 488 goto done;
489 489 break;
490 490 case NV_DEVICE_INFO_V0_TURING:
491 - if (engine == NV_DEVICE_HOST_RUNLIST_ENGINES_GR) {
491 + if (engine != NV_DEVICE_HOST_RUNLIST_ENGINES_NVDEC) {
492 492 ret = nvif_object_ctor(&chan->chan->user, "abi16CeWar",
493 493 0, TURING_DMA_COPY_A, NULL, 0,
494 494 &chan->ce);
modified drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -578,9 +578,8 @@ int nouveau_bo_pin_locked(struct nouveau_bo *nvbo, uint32_t domain, bool contig)
578 578 "0x%08x vs 0x%08x\n", bo,
579 579 bo->resource->mem_type, domain);
580 580 ret = -EBUSY;
581 - } else {
582 - ttm_bo_pin(&nvbo->bo);
583 581 }
582 + ttm_bo_pin(&nvbo->bo);
584 583 goto out;
585 584 }
586 585
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_connector.c
@@ -600,11 +600,8 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
600 600 new_edid = drm_get_edid(connector, nv_encoder->i2c);
601 601 } else {
602 602 ret = nvif_outp_edid_get(&nv_encoder->outp, (u8 **)&new_edid);
603 - if (ret < 0) {
604 - pm_runtime_mark_last_busy(dev->dev);
605 - pm_runtime_put_autosuspend(dev->dev);
603 + if (ret < 0)
606 604 return connector_status_disconnected;
607 - }
608 605 }
609 606
610 607 nouveau_connector_set_edid(nv_connector, new_edid);
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 = {
@@ -339,8 +325,8 @@ nouveau_dmem_chunk_alloc(struct nouveau_drm *drm, struct page **ppage,
339 325 chunk->pagemap.ops = &nouveau_dmem_pagemap_ops;
340 326 chunk->pagemap.owner = drm->dev;
341 327
342 - ret = nouveau_bo_new_pin(&drm->client, NOUVEAU_GEM_DOMAIN_VRAM,
343 - DMEM_CHUNK_SIZE * NR_CHUNKS, &chunk->bo);
328 + ret = nouveau_bo_new_pin(&drm->client, NOUVEAU_GEM_DOMAIN_VRAM, DMEM_CHUNK_SIZE,
329 + &chunk->bo);
344 330 if (ret)
345 331 goto out_release;
346 332
@@ -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_drm.c
@@ -585,7 +585,6 @@ nouveau_drm_device_fini(struct nouveau_drm *drm)
585 585 if (nouveau_pmops_runtime()) {
586 586 pm_runtime_get_sync(dev->dev);
587 587 pm_runtime_forbid(dev->dev);
588 - pm_runtime_dont_use_autosuspend(dev->dev);
589 588 }
590 589
591 590 nouveau_led_fini(dev);
@@ -1149,7 +1148,6 @@ nouveau_pmops_runtime_suspend(struct device *dev)
1149 1148 {
1150 1149 struct pci_dev *pdev = to_pci_dev(dev);
1151 1150 struct nouveau_drm *drm = pci_get_drvdata(pdev);
1152 - struct nvif_device *nvif = &drm->client.device;
1153 1151 int ret;
1154 1152
1155 1153 if (!nouveau_pmops_runtime()) {
@@ -1157,18 +1155,6 @@ nouveau_pmops_runtime_suspend(struct device *dev)
1157 1155 return -EBUSY;
1158 1156 }
1159 1157
1160 - // Check if the GPU itself is ready for runtime suspend, otherwise mark as busy and check
1161 - // again in a bit.
1162 - ret = nvif_device_gcx_ready(nvif);
1163 - if (ret < 0) {
1164 - NV_ERROR(drm, "Failed to query GCX readiness (returned %d)\n", ret);
1165 - return -EBUSY;
1166 - } else if (!(ret & NV_DEVICE_GCOFF_READY)) {
1167 - NV_DEBUG(drm, "GPU isn't ready for suspend yet, delaying...\n");
1168 - pm_runtime_mark_last_busy(dev);
1169 - return -EBUSY;
1170 - }
1171 -
1172 1158 nouveau_switcheroo_optimus_dsm();
1173 1159 ret = nouveau_do_suspend(drm, true);
1174 1160 pci_save_state(pdev);
@@ -1264,8 +1250,10 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv)
1264 1250 mutex_unlock(&drm->clients_lock);
1265 1251
1266 1252 done:
1267 - if (ret && cli)
1253 + if (ret && cli) {
1254 + nouveau_cli_fini(cli);
1268 1255 kfree(cli);
1256 + }
1269 1257
1270 1258 pm_runtime_mark_last_busy(dev->dev);
1271 1259 pm_runtime_put_autosuspend(dev->dev);
modified drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -522,7 +522,6 @@ retry:
522 522 if (unlikely(ret)) {
523 523 if (ret != -ERESTARTSYS)
524 524 NV_PRINTK(err, cli, "fail reserve\n");
525 - drm_gem_object_put(gem);
526 525 break;
527 526 }
528 527 }
@@ -532,7 +531,6 @@ retry:
532 531 struct nouveau_vma *vma = nouveau_vma_find(nvbo, vmm);
533 532 if (!vma) {
534 533 NV_PRINTK(err, cli, "vma not found!\n");
535 - drm_gem_object_put(gem);
536 534 ret = -EINVAL;
537 535 break;
538 536 }
modified drivers/gpu/drm/nouveau/nouveau_sched.c
@@ -517,7 +517,7 @@ nouveau_sched_destroy(struct nouveau_sched **psched)
517 517 struct nouveau_sched *sched = *psched;
518 518
519 519 nouveau_sched_fini(sched);
520 - kfree_rcu(sched, rcu);
520 + kfree(sched);
521 521
522 522 *psched = NULL;
523 523 }
modified drivers/gpu/drm/nouveau/nouveau_sched.h
@@ -98,7 +98,6 @@ void nouveau_job_free(struct nouveau_job *job);
98 98
99 99 struct nouveau_sched {
100 100 struct drm_gpu_scheduler base;
101 - struct rcu_head rcu;
102 101 struct drm_sched_entity entity;
103 102 struct workqueue_struct *wq;
104 103 struct mutex mutex;
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
@@ -846,9 +846,6 @@ op_map(struct nouveau_uvma *uvma)
846 846 {
847 847 struct nouveau_bo *nvbo = nouveau_gem_object(uvma->va.gem.obj);
848 848
849 - if (drm_gpuva_invalidated(&uvma->va))
850 - return;
851 -
852 849 nouveau_uvma_map(uvma, nouveau_mem(nvbo->bo.resource));
853 850 }
854 851
@@ -1235,7 +1232,6 @@ bind_lock_validate(struct nouveau_job *job, struct drm_exec *exec,
1235 1232
1236 1233 drm_gpuva_for_each_op(va_op, op->ops) {
1237 1234 struct drm_gem_object *obj = op_gem_obj(va_op);
1238 - struct nouveau_bo *nvbo;
1239 1235
1240 1236 if (unlikely(!obj))
1241 1237 continue;
@@ -1250,13 +1246,8 @@ bind_lock_validate(struct nouveau_job *job, struct drm_exec *exec,
1250 1246 if (va_op->op == DRM_GPUVA_OP_UNMAP)
1251 1247 continue;
1252 1248
1253 - nvbo = nouveau_gem_object(obj);
1254 - if (!(nvbo->valid_domains &
1255 - (NOUVEAU_GEM_DOMAIN_VRAM | NOUVEAU_GEM_DOMAIN_GART)))
1256 - return -EINVAL;
1257 -
1258 - nouveau_bo_placement_set(nvbo, nvbo->valid_domains, 0);
1259 - ret = nouveau_bo_validate(nvbo, true, false);
1249 + ret = nouveau_bo_validate(nouveau_gem_object(obj),
1250 + true, false);
1260 1251 if (ret)
1261 1252 return ret;
1262 1253 }
@@ -1328,7 +1319,6 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job,
1328 1319 op->va.range);
1329 1320 if (!op->reg || op->reg->dirty) {
1330 1321 ret = -ENOENT;
1331 - op->reg = NULL;
1332 1322 goto unwind_continue;
1333 1323 }
1334 1324
@@ -1337,7 +1327,6 @@ nouveau_uvmm_bind_job_submit(struct nouveau_job *job,
1337 1327 op->va.range);
1338 1328 if (IS_ERR(op->ops)) {
1339 1329 ret = PTR_ERR(op->ops);
1340 - op->reg = NULL;
1341 1330 goto unwind_continue;
1342 1331 }
1343 1332
@@ -1484,7 +1473,6 @@ unwind:
1484 1473 op->va.range);
1485 1474 break;
1486 1475 case OP_UNMAP_SPARSE:
1487 - op->reg->dirty = false;
1488 1476 __nouveau_uvma_region_insert(uvmm, op->reg);
1489 1477 nouveau_uvmm_sm_unmap_prepare_unwind(uvmm, &op->new,
1490 1478 op->ops);
@@ -1501,8 +1489,7 @@ unwind:
1501 1489 break;
1502 1490 }
1503 1491
1504 - if (!IS_ERR_OR_NULL(op->ops))
1505 - drm_gpuva_ops_free(&uvmm->base, op->ops);
1492 + drm_gpuva_ops_free(&uvmm->base, op->ops);
1506 1493 op->ops = NULL;
1507 1494 op->reg = NULL;
1508 1495 }
modified drivers/gpu/drm/nouveau/nvif/device.c
@@ -38,19 +38,6 @@ nvif_device_time(struct nvif_device *device)
38 38 return device->user.func->time(&device->user);
39 39 }
40 40
41 - int
42 - nvif_device_gcx_ready(struct nvif_device *device)
43 - {
44 - struct nv_device_gcx_ready_v0 args = {};
45 - int ret;
46 -
47 - ret = nvif_object_mthd(&device->object, NV_DEVICE_V0_GCX_READY, &args, sizeof(args));
48 - if (ret)
49 - return ret;
50 -
51 - return args.ready;
52 - }
53 -
54 41 int
55 42 nvif_device_map(struct nvif_device *device)
56 43 {
modified drivers/gpu/drm/nouveau/nvif/vmm.c
@@ -192,7 +192,6 @@ void
192 192 nvif_vmm_dtor(struct nvif_vmm *vmm)
193 193 {
194 194 kfree(vmm->page);
195 - vmm->page = NULL;
196 195 nvif_object_dtor(&vmm->object);
197 196 }
198 197
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/device/ctrl.c
@@ -74,7 +74,6 @@ nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size)
74 74 const struct nvkm_domain *domain;
75 75 struct nvkm_pstate *pstate;
76 76 struct nvkm_cstate *cstate;
77 - bool found = false;
78 77 int i = 0, j = -1;
79 78 u32 lo, hi;
80 79 int ret = -ENOSYS;
@@ -105,15 +104,10 @@ nvkm_control_mthd_pstate_attr(struct nvkm_control *ctrl, void *data, u32 size)
105 104
106 105 if (args->v0.state != NVIF_CONTROL_PSTATE_ATTR_V0_STATE_CURRENT) {
107 106 list_for_each_entry(pstate, &clk->states, head) {
108 - if (i++ == args->v0.state) {
109 - found = true;
107 + if (i++ == args->v0.state)
110 108 break;
111 - }
112 109 }
113 110
114 - if (!found)
115 - return -EINVAL;
116 -
117 111 lo = pstate->base.domain[domain->name];
118 112 hi = lo;
119 113 list_for_each_entry(cstate, &pstate->list, head) {
modified drivers/gpu/drm/nouveau/nvkm/engine/device/user.c
@@ -27,7 +27,6 @@
27 27
28 28 #include <core/client.h>
29 29 #include <subdev/fb.h>
30 - #include <subdev/gsp.h>
31 30 #include <subdev/instmem.h>
32 31 #include <subdev/timer.h>
33 32
@@ -190,38 +189,6 @@ nvkm_udevice_time(struct nvkm_udevice *udev, void *data, u32 size)
190 189 return ret;
191 190 }
192 191
193 - static int
194 - nvkm_udevice_gcx_ready(struct nvkm_udevice *udev, void *data, u32 size)
195 - {
196 - struct nvkm_object *object = &udev->object;
197 - struct nvkm_device *device = udev->device;
198 - struct nvkm_gsp *gsp = device->gsp;
199 - union {
200 - struct nv_device_gcx_ready_v0 v0;
201 - } *args = data;
202 - int ret = -ENOSYS;
203 -
204 - if (!gsp || !gsp->rm) {
205 - args->v0.ready = NV_DEVICE_GC6_READY | NV_DEVICE_GCOFF_READY;
206 - return 0;
207 - }
208 -
209 - nvif_ioctl(object, "device gcx ready size %d\n", size);
210 - ret = nvif_unpack(ret, &data, &size, args->v0, 0, 0, false);
211 - if (!ret) {
212 - nvif_ioctl(object, "device gcx ready vers %d\n", args->v0.version);
213 -
214 - ret = nvkm_gsp_gcx_ready(gsp);
215 - if (ret < 0)
216 - return ret;
217 -
218 - args->v0.ready = ret;
219 - ret = 0;
220 - }
221 -
222 - return ret;
223 - }
224 -
225 192 static int
226 193 nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
227 194 {
@@ -232,8 +199,6 @@ nvkm_udevice_mthd(struct nvkm_object *object, u32 mthd, void *data, u32 size)
232 199 return nvkm_udevice_info(udev, data, size);
233 200 case NV_DEVICE_V0_TIME:
234 201 return nvkm_udevice_time(udev, data, size);
235 - case NV_DEVICE_V0_GCX_READY:
236 - return nvkm_udevice_gcx_ready(udev, data, size);
237 202 default:
238 203 break;
239 204 }
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/engine/disp/uoutp.c
@@ -253,7 +253,8 @@ nvkm_uoutp_mthd_hdmi(struct nvkm_outp *outp, void *argv, u32 argc)
253 253
254 254 if (!ior->func->hdmi ||
255 255 args->v0.max_ac_packet > 0x1f ||
256 - args->v0.rekey > 0x7f)
256 + args->v0.rekey > 0x7f ||
257 + (args->v0.scdc && !ior->func->hdmi->scdc))
257 258 return -EINVAL;
258 259
259 260 if (!args->v0.enable) {
modified drivers/gpu/drm/nouveau/nvkm/subdev/clk/base.c
@@ -199,18 +199,16 @@ nvkm_cstate_prog(struct nvkm_clk *clk, struct nvkm_pstate *pstate, int cstatei)
199 199 }
200 200
201 201 if (volt) {
202 - int err = nvkm_volt_set_id(volt, cstate->voltage,
203 - pstate->base.voltage, clk->temp, -1);
204 -
205 - if (err && err != -ENODEV)
206 - nvkm_error(subdev, "failed to lower voltage: %d\n", err);
202 + ret = nvkm_volt_set_id(volt, cstate->voltage,
203 + pstate->base.voltage, clk->temp, -1);
204 + if (ret && ret != -ENODEV)
205 + nvkm_error(subdev, "failed to lower voltage: %d\n", ret);
207 206 }
208 207
209 208 if (therm) {
210 - int err = nvkm_therm_cstate(therm, pstate->fanspeed, -1);
211 -
212 - if (err && err != -ENODEV)
213 - nvkm_error(subdev, "failed to lower fan speed: %d\n", err);
209 + ret = nvkm_therm_cstate(therm, pstate->fanspeed, -1);
210 + if (ret && ret != -ENODEV)
211 + nvkm_error(subdev, "failed to lower fan speed: %d\n", ret);
214 212 }
215 213
216 214 return ret;
@@ -272,19 +270,13 @@ nvkm_pstate_prog(struct nvkm_clk *clk, int pstatei)
272 270 struct nvkm_fb *fb = subdev->device->fb;
273 271 struct nvkm_pci *pci = subdev->device->pci;
274 272 struct nvkm_pstate *pstate;
275 - bool found = false;
276 273 int ret, idx = 0;
277 274
278 275 list_for_each_entry(pstate, &clk->states, head) {
279 - if (idx++ == pstatei) {
280 - found = true;
276 + if (idx++ == pstatei)
281 277 break;
282 - }
283 278 }
284 279
285 - if (!found)
286 - return -EINVAL;
287 -
288 280 nvkm_debug(subdev, "setting performance state %d\n", pstatei);
289 281 clk->pstate = pstatei;
290 282
@@ -481,7 +473,6 @@ static int
481 473 nvkm_clk_ustate_update(struct nvkm_clk *clk, int req)
482 474 {
483 475 struct nvkm_pstate *pstate;
484 - bool found = false;
485 476 int i = 0;
486 477
487 478 if (!clk->allow_reclock)
@@ -489,14 +480,12 @@ nvkm_clk_ustate_update(struct nvkm_clk *clk, int req)
489 480
490 481 if (req != -1 && req != -2) {
491 482 list_for_each_entry(pstate, &clk->states, head) {
492 - if (pstate->pstate == req) {
493 - found = true;
483 + if (pstate->pstate == req)
494 484 break;
495 - }
496 485 i++;
497 486 }
498 487
499 - if (!found)
488 + if (pstate->pstate != req)
500 489 return -EINVAL;
501 490 req = i;
502 491 }
modified drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramnv1a.c
@@ -51,8 +51,6 @@ nv1a_ram_new(struct nvkm_fb *fb, struct nvkm_ram **pram)
51 51 mib = ((mem >> 4) & 127) + 1;
52 52 }
53 53
54 - pci_dev_put(bridge);
55 -
56 54 return nvkm_ram_new_(&nv04_ram_func, fb, NVKM_RAM_TYPE_STOLEN,
57 55 mib * 1024 * 1024, pram);
58 56 }
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/base.c
@@ -20,7 +20,6 @@
20 20 * OTHER DEALINGS IN THE SOFTWARE.
21 21 */
22 22 #include "priv.h"
23 - #include <nvif/cl0080.h>
24 23
25 24 int
26 25 nvkm_gsp_intr_nonstall(struct nvkm_gsp *gsp, enum nvkm_subdev_type type, int inst)
@@ -48,15 +47,6 @@ nvkm_gsp_intr_stall(struct nvkm_gsp *gsp, enum nvkm_subdev_type type, int inst)
48 47 return -ENOENT;
49 48 }
50 49
51 - int
52 - nvkm_gsp_gcx_ready(struct nvkm_gsp *gsp)
53 - {
54 - if (!gsp->rm->api->gsp->gcx_ready)
55 - return NV_DEVICE_GC6_READY | NV_DEVICE_GCOFF_READY;
56 -
57 - return gsp->rm->api->gsp->gcx_ready(gsp);
58 - }
59 -
60 50 static int
61 51 nvkm_gsp_fini(struct nvkm_subdev *subdev, enum nvkm_suspend_state suspend)
62 52 {
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/priv.h
@@ -93,7 +93,6 @@ void r535_gsp_dtor(struct nvkm_gsp *);
93 93 int r535_gsp_oneinit(struct nvkm_gsp *);
94 94 int r535_gsp_init(struct nvkm_gsp *);
95 95 int r535_gsp_fini(struct nvkm_gsp *, enum nvkm_suspend_state suspend);
96 - int r535_gsp_gcx_ready(struct nvkm_gsp *gsp);
97 96
98 97 int nvkm_gsp_new_(const struct nvkm_gsp_fwif *, struct nvkm_device *, enum nvkm_subdev_type, int,
99 98 struct nvkm_gsp **);
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/r535/fbsr.c
@@ -208,7 +208,7 @@ r535_fbsr_resume(struct nvkm_gsp *gsp)
208 208 }
209 209
210 210 static int
211 - r535_fbsr_suspend(struct nvkm_gsp *gsp)
211 + r535_fbsr_suspend(struct nvkm_gsp *gsp, bool runtime)
212 212 {
213 213 struct nvkm_subdev *subdev = &gsp->subdev;
214 214 struct nvkm_device *device = subdev->device;
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gsp.c
@@ -1749,7 +1749,7 @@ r535_gsp_fini(struct nvkm_gsp *gsp, enum nvkm_suspend_state suspend)
1749 1749 sr->sysmemAddrOfSuspendResumeData = gsp->sr.radix3.lvl0.addr;
1750 1750 sr->sizeOfSuspendResumeData = len;
1751 1751
1752 - ret = rm->api->fbsr->suspend(gsp);
1752 + ret = rm->api->fbsr->suspend(gsp, suspend == NVKM_RUNTIME_SUSPEND);
1753 1753 if (ret) {
1754 1754 nvkm_gsp_mem_dtor(&gsp->sr.meta);
1755 1755 nvkm_gsp_radix3_dtor(gsp, &gsp->sr.radix3);
@@ -1761,12 +1761,8 @@ r535_gsp_fini(struct nvkm_gsp *gsp, enum nvkm_suspend_state suspend)
1761 1761 * TODO: Debug the GSP firmware / RPC handling to find out why
1762 1762 * without this Turing (but none of the other architectures)
1763 1763 * ends up resetting all channels after resume.
1764 - * Additionally, runtime suspend on other architectures quickly
1765 - * becomes unreliable without this sleep. If you're experiencing
1766 - * issues with runtime suspend, try bumping this delay up and
1767 - * sending a patch if it fixes your GPU.
1768 1764 */
1769 - msleep(200);
1765 + msleep(50);
1770 1766 }
1771 1767
1772 1768 ret = r535_gsp_rpc_unloading_guest_driver(gsp, suspend);
@@ -1782,23 +1778,6 @@ r535_gsp_fini(struct nvkm_gsp *gsp, enum nvkm_suspend_state suspend)
1782 1778 return 0;
1783 1779 }
1784 1780
1785 - int
1786 - r535_gsp_get_static_memsys_info(struct nvkm_gsp *gsp)
1787 - {
1788 - NV2080_CTRL_INTERNAL_MEMSYS_GET_STATIC_CONFIG_PARAMS *ctrl;
1789 -
1790 - ctrl = nvkm_gsp_rm_ctrl_rd(&gsp->internal.device.subdevice,
1791 - NV2080_CTRL_CMD_INTERNAL_MEMSYS_GET_STATIC_CONFIG,
1792 - sizeof(*ctrl));
1793 - if (IS_ERR(ctrl))
1794 - return PTR_ERR(ctrl);
1795 -
1796 - gsp->memsys.use_raw_mode_comptagline_alloc = ctrl->bUseRawModeComptaglineAllocation;
1797 -
1798 - nvkm_gsp_rm_ctrl_done(&gsp->internal.device.subdevice, ctrl);
1799 - return 0;
1800 - }
1801 -
1802 1781 int
1803 1782 r535_gsp_init(struct nvkm_gsp *gsp)
1804 1783 {
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/nvrm/gsp.h
@@ -782,51 +782,6 @@ typedef struct NV2080_CTRL_INTERNAL_INTR_GET_KERNEL_TABLE_PARAMS {
782 782
783 783 #define GSP_FW_HEAP_PARAM_CLIENT_ALLOC_SIZE ((48 << 10) * 2048) // Support 2048 channels
784 784
785 - typedef struct NV2080_CTRL_INTERNAL_MEMSYS_GET_STATIC_CONFIG_PARAMS {
786 - /*! Determines if RM should use 1 to 1 Comptagline allocation policy */
787 - NvBool bOneToOneComptagLineAllocation;
788 -
789 - /*! Determines if RM should use 1 to 4 Comptagline allocation policy */
790 - NvBool bUseOneToFourComptagLineAllocation;
791 -
792 - /*! Determines if RM should use raw Comptagline allocation policy */
793 - NvBool bUseRawModeComptaglineAllocation;
794 -
795 - /*! Has COMPBIT_BACKING_SIZE been overridden to zero (i.e. disabled)? */
796 - NvBool bDisableCompbitBacking;
797 -
798 - /*! Determine if we need to disable post L2 compression */
799 - NvBool bDisablePostL2Compression;
800 -
801 - /*! Is ECC DRAM feature supported? */
802 - NvBool bEnabledEccFBPA;
803 -
804 - NvBool bL2PreFill;
805 -
806 - /*! L2 cache size */
807 - NV_DECLARE_ALIGNED(NvU64 l2CacheSize, 8);
808 -
809 - /*! Indicate whether fpba is present or not */
810 - NvBool bFbpaPresent;
811 -
812 - /*! Size covered by one comptag */
813 - NvU32 comprPageSize;
814 -
815 - /*! log32(comprPageSize) */
816 - NvU32 comprPageShift;
817 -
818 - /*! RAM type */
819 - NvU32 ramType;
820 -
821 - /*! LTC count */
822 - NvU32 ltcCount;
823 -
824 - /*! LTS per LTC count */
825 - NvU32 ltsPerLtcCount;
826 - } NV2080_CTRL_INTERNAL_MEMSYS_GET_STATIC_CONFIG_PARAMS;
827 -
828 - #define NV2080_CTRL_CMD_INTERNAL_MEMSYS_GET_STATIC_CONFIG (0x20800a1c) /* finn: Evaluated from "(FINN_NV20_SUBDEVICE_0_INTERNAL_INTERFACE_ID << 8) | NV2080_CTRL_INTERNAL_MEMSYS_GET_STATIC_CONFIG_PARAMS_MESSAGE_ID" */
829 -
830 785 typedef union rpc_message_rpc_union_field_v03_00
831 786 {
832 787 NvU32 spare;
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/fbsr.c
@@ -26,52 +26,6 @@ r570_fbsr_suspend_channels(struct nvkm_gsp *gsp, bool suspend)
26 26 return nvkm_gsp_rm_ctrl_wr(&gsp->internal.device.subdevice, ctrl);
27 27 }
28 28
29 - static int
30 - r570_fb_get_compbit_store_size(struct nvkm_gsp *gsp, u64 *size)
31 - {
32 - NV0080_CTRL_FB_GET_COMPBIT_STORE_INFO_PARAMS *ctrl;
33 -
34 - ctrl = nvkm_gsp_rm_ctrl_rd(&gsp->internal.device.object,
35 - NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO,
36 - sizeof(*ctrl));
37 - if (IS_ERR(ctrl))
38 - return PTR_ERR(ctrl);
39 -
40 - *size = ctrl->Size;
41 -
42 - nvkm_gsp_rm_ctrl_done(&gsp->internal.device.object, ctrl);
43 - return 0;
44 - }
45 -
46 - static int
47 - r570_memsys_enable_raw_comp_mode(struct nvkm_gsp *gsp, bool enable)
48 - {
49 - NV2080_CTRL_INTERNAL_MEMSYS_PROGRAM_RAW_COMPRESSION_MODE_PARAMS *ctrl;
50 - int ret;
51 -
52 - ctrl = nvkm_gsp_rm_ctrl_get(&gsp->internal.device.subdevice,
53 - NV2080_CTRL_CMD_INTERNAL_MEMSYS_PROGRAM_RAW_COMPRESSION_MODE,
54 - sizeof(*ctrl));
55 - if (IS_ERR(ctrl))
56 - return PTR_ERR(ctrl);
57 -
58 - ctrl->bRawMode = enable;
59 -
60 - ret = nvkm_gsp_rm_ctrl_wr(&gsp->internal.device.subdevice, ctrl);
61 - if (!ret)
62 - nvkm_debug(&gsp->subdev, "memsys: Raw compression mode %s\n",
63 - str_enabled_disabled(enable));
64 -
65 - return ret;
66 - }
67 -
68 - static bool
69 - r570_need_raw_comp_war(struct nvkm_gsp *gsp, struct nvkm_device *device)
70 - {
71 - return (device->card_type == GA100 || device->card_type == AD100) &&
72 - gsp->memsys.use_raw_mode_comptagline_alloc;
73 - }
74 -
75 29 static void
76 30 r570_fbsr_resume(struct nvkm_gsp *gsp)
77 31 {
@@ -79,7 +33,6 @@ r570_fbsr_resume(struct nvkm_gsp *gsp)
79 33 struct nvkm_instmem *imem = device->imem;
80 34 struct nvkm_instobj *iobj;
81 35 struct nvkm_vmm *vmm;
82 - int ret;
83 36
84 37 /* Restore BAR2 page tables via BAR0 window, and re-enable BAR2. */
85 38 list_for_each_entry(iobj, &imem->boot, head) {
@@ -101,13 +54,6 @@ r570_fbsr_resume(struct nvkm_gsp *gsp)
101 54 vmm = nvkm_bar_bar1_vmm(device);
102 55 vmm->func->flush(vmm, 0);
103 56
104 - /* Re-enable raw mode if it was previously disabled */
105 - if (r570_need_raw_comp_war(gsp, device)) {
106 - ret = r570_memsys_enable_raw_comp_mode(gsp, true);
107 - if (ret)
108 - nvkm_error(&gsp->subdev, "Failed to re-enable raw comp mode\n");
109 - }
110 -
111 57 /* Resume channel scheduling. */
112 58 r570_fbsr_suspend_channels(device->gsp, false);
113 59
@@ -116,7 +62,7 @@ r570_fbsr_resume(struct nvkm_gsp *gsp)
116 62 }
117 63
118 64 static int
119 - r570_fbsr_init(struct nvkm_gsp *gsp, struct sg_table *sgt, u64 size)
65 + r570_fbsr_init(struct nvkm_gsp *gsp, struct sg_table *sgt, u64 size, bool runtime)
120 66 {
121 67 NV2080_CTRL_INTERNAL_FBSR_INIT_PARAMS *ctrl;
122 68 struct nvkm_gsp_object memlist;
@@ -135,7 +81,7 @@ r570_fbsr_init(struct nvkm_gsp *gsp, struct sg_table *sgt, u64 size)
135 81 ctrl->hClient = gsp->internal.client.object.handle;
136 82 ctrl->hSysMem = memlist.handle;
137 83 ctrl->sysmemAddrOfSuspendResumeData = gsp->sr.meta.addr;
138 - ctrl->bEnteringGcoffState = 1;
84 + ctrl->bEnteringGcoffState = runtime ? 1 : 0;
139 85
140 86 ret = nvkm_gsp_rm_ctrl_wr(&gsp->internal.device.subdevice, ctrl);
141 87 if (ret)
@@ -146,35 +92,18 @@ r570_fbsr_init(struct nvkm_gsp *gsp, struct sg_table *sgt, u64 size)
146 92 }
147 93
148 94 static int
149 - r570_fbsr_suspend(struct nvkm_gsp *gsp)
95 + r570_fbsr_suspend(struct nvkm_gsp *gsp, bool runtime)
150 96 {
151 97 struct nvkm_subdev *subdev = &gsp->subdev;
152 98 struct nvkm_device *device = subdev->device;
153 99 struct nvkm_instmem *imem = device->imem;
154 100 struct nvkm_instobj *iobj;
155 - u64 size, compbit_store_size;
101 + u64 size;
156 102 int ret;
157 103
158 104 /* Stop channel scheduling. */
159 105 r570_fbsr_suspend_channels(gsp, true);
160 106
161 - /* Temporarily disable raw mode to prevent FBSR restore operations from corrupting
162 - * compressed surfaces. Required for ampere and ada.
163 - *
164 - * Nvidia bug #3172217
165 - */
166 - if (r570_need_raw_comp_war(gsp, device)) {
167 - ret = r570_memsys_enable_raw_comp_mode(gsp, false);
168 - if (ret)
169 - return ret;
170 - }
171 -
172 - ret = r570_fb_get_compbit_store_size(gsp, &compbit_store_size);
173 - if (ret < 0)
174 - return ret;
175 - nvkm_debug(&gsp->subdev, "fbsr: Compbit backing store size: 0x%llx bytes\n",
176 - compbit_store_size);
177 -
178 107 /* Save BAR2 allocations to system memory. */
179 108 list_for_each_entry(iobj, &imem->list, head) {
180 109 if (iobj->preserve) {
@@ -197,8 +126,6 @@ r570_fbsr_suspend(struct nvkm_gsp *gsp)
197 126 size = gsp->fb.heap.size;
198 127 size += gsp->fb.rsvd_size;
199 128 size += gsp->fb.bios.vga_workspace.size;
200 - size += compbit_store_size;
201 -
202 129 nvkm_debug(subdev, "fbsr: size: 0x%llx bytes\n", size);
203 130
204 131 ret = nvkm_gsp_sg(device, size, &gsp->sr.fbsr);
@@ -206,7 +133,7 @@ r570_fbsr_suspend(struct nvkm_gsp *gsp)
206 133 return ret;
207 134
208 135 /* Initialise FBSR on RM. */
209 - ret = r570_fbsr_init(gsp, &gsp->sr.fbsr, size);
136 + ret = r570_fbsr_init(gsp, &gsp->sr.fbsr, size, runtime);
210 137 if (ret) {
211 138 nvkm_gsp_sg_free(device, &gsp->sr.fbsr);
212 139 return ret;
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/gsp.c
@@ -10,7 +10,6 @@
10 10 #include "nvrm/gsp.h"
11 11 #include "nvrm/rpcfn.h"
12 12 #include "nvrm/msgfn.h"
13 - #include "nvif/cl0080.h"
14 13
15 14 #include <core/pci.h>
16 15 #include <subdev/pci/priv.h>
@@ -45,15 +44,6 @@ r570_gsp_xlat_mc_engine_idx(u32 mc_engine_idx, enum nvkm_subdev_type *ptype, int
45 44 *ptype = NVKM_ENGINE_DISP;
46 45 *pinst = 0;
47 46 return true;
48 - case MC_ENGINE_IDX_DISP_LOW:
49 - /* GB20x+ report a separate low-latency display vector, used
50 - * for head-timing interrupts. Expose it as a second DISP
51 - * interrupt instance. r535_disp_oneinit() attaches the
52 - * handler to it when the chip's gsp.intr_low_latency is set.
53 - */
54 - *ptype = NVKM_ENGINE_DISP;
55 - *pinst = 1;
56 - return true;
57 47 case MC_ENGINE_IDX_CE0 ... MC_ENGINE_IDX_CE19:
58 48 *ptype = NVKM_ENGINE_CE;
59 49 *pinst = mc_engine_idx - MC_ENGINE_IDX_CE0;
@@ -138,14 +128,6 @@ r570_gsp_get_static_info(struct nvkm_gsp *gsp)
138 128 }
139 129 }
140 130
141 - ret = r535_gsp_get_static_memsys_info(gsp);
142 - if (ret) {
143 - nvkm_error(&gsp->subdev, "Retrieving static memsys info failed\n");
144 - return ret;
145 - }
146 - nvkm_debug(&gsp->subdev, "memsys: Use raw mode for comptag allocations? %s\n",
147 - str_yes_no(gsp->memsys.use_raw_mode_comptagline_alloc));
148 -
149 131 return 0;
150 132 }
151 133
@@ -216,40 +198,13 @@ r570_gsp_set_rmargs(struct nvkm_gsp *gsp, bool resume)
216 198 args->srInitArguments.bInPMTransition = 0;
217 199 } else {
218 200 args->srInitArguments.oldLevel = NV2080_CTRL_GPU_SET_POWER_STATE_GPU_LEVEL_3;
219 - args->srInitArguments.flags =
220 - GPU_STATE_FLAGS_PRESERVING | GPU_STATE_FLAGS_PM_TRANSITION;
201 + args->srInitArguments.flags = 0;
221 202 args->srInitArguments.bInPMTransition = 1;
222 203 }
223 204
224 205 args->bDmemStack = 1;
225 206 }
226 207
227 - int
228 - r570_gsp_gcx_ready(struct nvkm_gsp *gsp)
229 - {
230 - NV2080_CTRL_INTERNAL_GCX_ENTRY_PREREQUISITE_PARAMS *ctrl;
231 - int ret = 0;
232 -
233 - ctrl = nvkm_gsp_rm_ctrl_rd(&gsp->internal.device.subdevice,
234 - NV2080_CTRL_CMD_INTERNAL_GCX_ENTRY_PREREQUISITE,
235 - sizeof(*ctrl));
236 - if (IS_ERR(ctrl))
237 - return PTR_ERR(ctrl);
238 -
239 - if (ctrl->bIsGC6Satisfied)
240 - ret |= NV_DEVICE_GC6_READY;
241 - if (ctrl->bIsGCOFFSatisfied)
242 - ret |= NV_DEVICE_GCOFF_READY;
243 -
244 - nvkm_debug(&gsp->subdev,
245 - "GCX ready status: GC6=%s GCOFF=%s\n",
246 - str_yes_no(ctrl->bIsGC6Satisfied), str_yes_no(ctrl->bIsGCOFFSatisfied));
247 -
248 - nvkm_gsp_rm_ctrl_done(&gsp->internal.device.subdevice, ctrl);
249 - return ret;
250 - }
251 -
252 -
253 208 const struct nvkm_rm_api_gsp
254 209 r570_gsp = {
255 210 .set_rmargs = r570_gsp_set_rmargs,
@@ -258,5 +213,4 @@ r570_gsp = {
258 213 .xlat_mc_engine_idx = r570_gsp_xlat_mc_engine_idx,
259 214 .drop_post_nocat_record = r570_gsp_drop_post_nocat_record,
260 215 .sr_data_size = r570_gsp_sr_data_size,
261 - .gcx_ready = r570_gsp_gcx_ready,
262 216 };
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/r570/nvrm/fbsr.h
@@ -16,33 +16,4 @@ typedef struct NV2080_CTRL_INTERNAL_FBSR_INIT_PARAMS {
16 16 NV_DECLARE_ALIGNED(NvU64 sysmemAddrOfSuspendResumeData, 8);
17 17 } NV2080_CTRL_INTERNAL_FBSR_INIT_PARAMS;
18 18
19 - #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO (0x801306) /* finn: Evaluated from "(FINN_NV01_DEVICE_0_FB_INTERFACE_ID << 8) | NV0080_CTRL_FB_GET_COMPBIT_STORE_INFO_PARAMS_MESSAGE_ID" */
20 -
21 - typedef struct NV0080_CTRL_FB_GET_COMPBIT_STORE_INFO_PARAMS {
22 - NV_DECLARE_ALIGNED(NvU64 Size, 8);
23 - NV_DECLARE_ALIGNED(NvU64 Address, 8);
24 - NvU32 AddressSpace;
25 - NvU32 MaxCompbitLine;
26 - NvU32 comptagsPerCacheLine;
27 - NvU32 cacheLineSize;
28 - NvU32 cacheLineSizePerSlice;
29 - NvU32 cacheLineFetchAlignment;
30 - NV_DECLARE_ALIGNED(NvU64 backingStoreBase, 8);
31 - NvU32 gobsPerComptagPerSlice;
32 - NvU32 backingStoreCbcBase;
33 - NvU32 comptaglineAllocationPolicy;
34 - NV_DECLARE_ALIGNED(NvU64 privRegionStartOffset, 8);
35 - NvU32 cbcCoveragePerSlice;
36 - } NV0080_CTRL_FB_GET_COMPBIT_STORE_INFO_PARAMS;
37 -
38 - #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_ADDRESS_SPACE_UNKNOWN 0 // ADDR_UNKNOWN
39 - #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_ADDRESS_SPACE_SYSMEM 1 // ADDR_SYSMEM
40 - #define NV0080_CTRL_CMD_FB_GET_COMPBIT_STORE_INFO_ADDRESS_SPACE_FBMEM 2 // ADDR_FBMEM
41 -
42 - #define NV2080_CTRL_CMD_INTERNAL_MEMSYS_PROGRAM_RAW_COMPRESSION_MODE (0x20800a6f) /* finn: Evaluated from "(FINN_NV20_SUBDEVICE_0_INTERNAL_INTERFACE_ID << 8) | NV2080_CTRL_INTERNAL_MEMSYS_PROGRAM_RAW_COMPRESSION_MODE_PARAMS_MESSAGE_ID" */
43 -
44 - typedef struct NV2080_CTRL_INTERNAL_MEMSYS_PROGRAM_RAW_COMPRESSION_MODE_PARAMS {
45 - NvBool bRawMode;
46 - } NV2080_CTRL_INTERNAL_MEMSYS_PROGRAM_RAW_COMPRESSION_MODE_PARAMS;
47 -
48 19 #endif
modified drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/nvrm/gsp.h
@@ -523,14 +523,6 @@ typedef struct
523 523
524 524 #define NV2080_CTRL_GPU_SET_POWER_STATE_GPU_LEVEL_3 (0x00000003U)
525 525
526 - #define GPU_STATE_FLAGS_PRESERVING BIT(0) // GPU state is preserved
527 - #define GPU_STATE_FLAGS_VGA_TRANSITION BIT(1) // To be used with GPU_STATE_FLAGS_PRESERVING.
528 - #define GPU_STATE_FLAGS_PM_TRANSITION BIT(2) // To be used with GPU_STATE_FLAGS_PRESERVING.
529 - #define GPU_STATE_FLAGS_PM_SUSPEND BIT(3)
530 - #define GPU_STATE_FLAGS_PM_HIBERNATE BIT(4)
531 - #define GPU_STATE_FLAGS_GC6_TRANSITION BIT(5) // To be used with GPU_STATE_FLAGS_PRESERVING.
532 - #define GPU_STATE_FLAGS_FAST_UNLOAD BIT(6) // Used during windows restart, skips stateDestroy steps
533 -
534 526 typedef struct
535 527 {
536 528 // Magic for verification by secure ucode
@@ -639,11 +631,4 @@ typedef struct GSP_FMC_BOOT_PARAMS
639 631 } GSP_FMC_BOOT_PARAMS;
640 632
641 633 #define GSP_FW_HEAP_PARAM_BASE_RM_SIZE_GH100 (14 << 20) // Hopper+
642 -
643 - #define NV2080_CTRL_CMD_INTERNAL_GCX_ENTRY_PREREQUISITE (0x2080a7d7)
644 -
645 - typedef struct NV2080_CTRL_INTERNAL_GCX_ENTRY_PREREQUISITE_PARAMS {
646 - NvBool bIsGC6Satisfied;
647 - NvBool bIsGCOFFSatisfied;
648 - } NV2080_CTRL_INTERNAL_GCX_ENTRY_PREREQUISITE_PARAMS;
649 634 #endif
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
@@ -40,7 +39,6 @@ struct nvkm_rm_api {
40 39 void (*drop_send_user_shared_data)(struct nvkm_gsp *);
41 40 void (*drop_post_nocat_record)(struct nvkm_gsp *);
42 41 u32 (*sr_data_size)(struct nvkm_gsp *);
43 - int (*gcx_ready)(struct nvkm_gsp *gsp);
44 42 } *gsp;
45 43
46 44 const struct nvkm_rm_api_rpc {
@@ -80,7 +78,7 @@ struct nvkm_rm_api {
80 78 } *device;
81 79
82 80 const struct nvkm_rm_api_fbsr {
83 - int (*suspend)(struct nvkm_gsp *);
81 + int (*suspend)(struct nvkm_gsp *, bool runtime);
84 82 void (*resume)(struct nvkm_gsp *);
85 83 } *fbsr;
86 84
@@ -95,10 +93,6 @@ struct nvkm_rm_api {
95 93 struct {
96 94 int (*get_caps)(struct nvkm_disp *, int *link_bw, bool *mst, bool *wm);
97 95 int (*set_indexed_link_rates)(struct nvkm_outp *);
98 - int (*sst)(struct nvkm_ior *, int head, bool ef,
99 - u32 watermark, u32 hblanksym, u32 vblanksym);
100 - int (*vcpi)(struct nvkm_ior *, int head,
101 - u8 slot, u8 slot_nr, u16 pbn, u16 aligned_pbn);
102 96 } dp;
103 97
104 98 struct {
@@ -175,8 +169,6 @@ int r535_gr_chan_new(struct nvkm_gr *, struct nvkm_chan *, const struct nvkm_ocl
175 169 int r535_gr_promote_ctx(struct r535_gr *, bool golden, struct nvkm_vmm *,
176 170 struct nvkm_memory **pctxbuf_mem, struct nvkm_vma **pctxbuf_vma,
177 171 struct nvkm_gsp_object *chan);
178 - int r570_gsp_gcx_ready(struct nvkm_gsp *gsp);
179 - int r535_gsp_get_static_memsys_info(struct nvkm_gsp *gsp);
180 172 extern const struct nvkm_rm_api_engine r535_nvdec;
181 173 extern const struct nvkm_rm_api_engine r535_nvenc;
182 174 extern const struct nvkm_rm_api_engine r535_nvjpg;
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/panthor/panthor_sched.c
@@ -3674,9 +3674,6 @@ int panthor_group_create(struct panthor_file *pfile,
3674 3674 hweight64(group_args->tiler_core_mask) < group_args->max_tiler_cores)
3675 3675 return -EINVAL;
3676 3676
3677 - if (group_args->queues.count > sched->cs_slot_count)
3678 - return -EINVAL;
3679 -
3680 3677 group = kzalloc_obj(*group);
3681 3678 if (!group)
3682 3679 return -ENOMEM;
modified drivers/gpu/drm/qxl/qxl_display.c
@@ -30,7 +30,6 @@
30 30 #include <drm/drm_drv.h>
31 31 #include <drm/drm_atomic.h>
32 32 #include <drm/drm_atomic_helper.h>
33 - #include <drm/drm_blend.h>
34 33 #include <drm/drm_edid.h>
35 34 #include <drm/drm_encoder.h>
36 35 #include <drm/drm_framebuffer.h>
@@ -982,7 +981,7 @@ static struct drm_plane *qxl_create_plane(struct qxl_device *qdev,
982 981 return ERR_PTR(-EINVAL);
983 982 }
984 983
985 - plane = kzalloc_obj(*plane);
984 + plane = kzalloc(sizeof(*plane), GFP_KERNEL);
986 985 if (!plane)
987 986 return ERR_PTR(-ENOMEM);
988 987
@@ -994,9 +993,6 @@ static struct drm_plane *qxl_create_plane(struct qxl_device *qdev,
994 993
995 994 drm_plane_helper_add(plane, helper_funcs);
996 995
997 - drm_plane_create_blend_mode_property(plane,
998 - BIT(DRM_MODE_BLEND_PREMULTI));
999 -
1000 996 return plane;
1001 997
1002 998 free_plane:
modified drivers/gpu/drm/rockchip/Kconfig
@@ -68,7 +68,6 @@ config ROCKCHIP_CDN_DP
68 68
69 69 config ROCKCHIP_DW_DP
70 70 bool "Rockchip specific extensions for Synopsys DW DP"
71 - select DRM_BRIDGE_CONNECTOR
72 71 help
73 72 This selects support for Rockchip SoC specific extensions
74 73 to enable Synopsys DesignWare Cores based DisplayPort transmit
@@ -146,8 +145,6 @@ config ROCKCHIP_RGB
146 145 config ROCKCHIP_RK3066_HDMI
147 146 bool "Rockchip specific extensions for RK3066 HDMI"
148 147 depends on DRM_ROCKCHIP
149 - select DRM_DISPLAY_HELPER
150 - select DRM_BRIDGE_CONNECTOR
151 148 help
152 149 This selects support for Rockchip SoC specific extensions
153 150 for the RK3066 HDMI driver. If you want to enable
modified drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -241,11 +241,10 @@ static void rockchip_dp_drm_encoder_enable(struct drm_encoder *encoder,
241 241 of_graph_get_remote_port(endpoint.local_node);
242 242
243 243 of_property_read_u32(remote_port, "reg", &port_id);
244 - snprintf(name, sizeof(name), "%s vp%d",
245 - remote_port_parent->full_name, port_id);
244 + sprintf(name, "%s vp%d", remote_port_parent->full_name, port_id);
246 245 } else {
247 - snprintf(name, sizeof(name), "%s %s",
248 - remote_port_parent->full_name, endpoint.id ? "vopl" : "vopb");
246 + sprintf(name, "%s %s",
247 + remote_port_parent->full_name, endpoint.id ? "vopl" : "vopb");
249 248 }
250 249
251 250 DRM_DEV_DEBUG(dp->dev, "vop %s output to dp\n", (ret) ? "LIT" : "BIG");
modified drivers/gpu/drm/scheduler/sched_entity.c
@@ -559,10 +559,9 @@ struct drm_sched_job *drm_sched_entity_pop_job(struct drm_sched_entity *entity)
559 559 */
560 560 smp_wmb();
561 561
562 - spin_lock(&entity->lock);
563 562 spsc_queue_pop(&entity->job_queue);
563 +
564 564 drm_sched_rq_pop_entity(entity);
565 - spin_unlock(&entity->lock);
566 565
567 566 /* Jobs and entities might have different lifecycles. Since we're
568 567 * removing the job from the entities queue, set the jobs entity pointer
@@ -648,9 +647,6 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job)
648 647 * Make sure to set the submit_ts first, to avoid a race.
649 648 */
650 649 sched_job->submit_ts = submit_ts = ktime_get();
651 -
652 - spin_lock(&entity->lock);
653 -
654 650 first = spsc_queue_push(&entity->job_queue, &sched_job->queue_node);
655 651
656 652 /* first job wakes up scheduler */
@@ -661,7 +657,5 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job)
661 657 if (sched)
662 658 drm_sched_wakeup(sched);
663 659 }
664 -
665 - spin_unlock(&entity->lock);
666 660 }
667 661 EXPORT_SYMBOL(drm_sched_entity_push_job);
modified drivers/gpu/drm/scheduler/sched_rq.c
@@ -257,17 +257,19 @@ static ktime_t drm_sched_entity_get_job_ts(struct drm_sched_entity *entity)
257 257 struct drm_gpu_scheduler *
258 258 drm_sched_rq_add_entity(struct drm_sched_entity *entity, ktime_t ts)
259 259 {
260 - struct drm_sched_rq *rq = entity->rq;
261 260 struct drm_gpu_scheduler *sched;
261 + struct drm_sched_rq *rq;
262 262
263 263 /* Add the entity to the run queue */
264 - lockdep_assert_held(&entity->lock);
265 -
264 + spin_lock(&entity->lock);
266 265 if (entity->stopped) {
266 + spin_unlock(&entity->lock);
267 +
267 268 DRM_ERROR("Trying to push to a killed entity\n");
268 269 return NULL;
269 270 }
270 271
272 + rq = entity->rq;
271 273 spin_lock(&rq->lock);
272 274 sched = rq->sched;
273 275
@@ -287,6 +289,7 @@ drm_sched_rq_add_entity(struct drm_sched_entity *entity, ktime_t ts)
287 289 drm_sched_rq_update_fifo_locked(entity, rq, ts);
288 290
289 291 spin_unlock(&rq->lock);
292 + spin_unlock(&entity->lock);
290 293
291 294 return sched;
292 295 }
@@ -340,17 +343,16 @@ drm_sched_rq_next_rr_ts(struct drm_sched_rq *rq,
340 343 */
341 344 void drm_sched_rq_pop_entity(struct drm_sched_entity *entity)
342 345 {
343 - struct drm_sched_rq *rq = entity->rq;
344 346 struct drm_sched_job *next_job;
345 -
346 - lockdep_assert_held(&entity->lock);
347 -
348 - spin_lock(&rq->lock);
347 + struct drm_sched_rq *rq;
349 348
350 349 /*
351 350 * Update the entity's location in the min heap according to
352 351 * the timestamp of the next job, if any.
353 352 */
353 + spin_lock(&entity->lock);
354 + rq = entity->rq;
355 + spin_lock(&rq->lock);
354 356 next_job = drm_sched_entity_queue_peek(entity);
355 357 if (next_job) {
356 358 ktime_t ts;
@@ -373,8 +375,8 @@ void drm_sched_rq_pop_entity(struct drm_sched_entity *entity)
373 375 drm_sched_entity_save_vruntime(entity, min_vruntime);
374 376 }
375 377 }
376 -
377 378 spin_unlock(&rq->lock);
379 + spin_unlock(&entity->lock);
378 380 }
379 381
380 382 /**
modified drivers/gpu/drm/scheduler/tests/mock_scheduler.c
@@ -1,8 +1,6 @@
1 1 // SPDX-License-Identifier: GPL-2.0
2 2 /* Copyright (c) 2025 Valve Corporation */
3 3
4 - #include <kunit/device.h>
5 -
6 4 #include "sched_tests.h"
7 5
8 6 /*
@@ -290,7 +288,6 @@ static const struct drm_sched_backend_ops drm_mock_scheduler_ops = {
290 288 */
291 289 struct drm_mock_scheduler *drm_mock_sched_new(struct kunit *test, long timeout)
292 290 {
293 - static unsigned int instance;
294 291 struct drm_sched_init_args args = {
295 292 .ops = &drm_mock_scheduler_ops,
296 293 .num_rqs = DRM_SCHED_PRIORITY_COUNT,
@@ -300,19 +297,11 @@ struct drm_mock_scheduler *drm_mock_sched_new(struct kunit *test, long timeout)
300 297 .name = "drm-mock-scheduler",
301 298 };
302 299 struct drm_mock_scheduler *sched;
303 - struct device *dev;
304 - char name[64];
305 300 int ret;
306 301
307 302 sched = kunit_kzalloc(test, sizeof(*sched), GFP_KERNEL);
308 303 KUNIT_ASSERT_NOT_NULL(test, sched);
309 304
310 - snprintf(name, sizeof(name), "%s-%u", args.name, instance++);
311 - dev = kunit_device_register(test, name);
312 - KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev);
313 -
314 - args.dev = dev;
315 -
316 305 ret = drm_sched_init(&sched->base, &args);
317 306 KUNIT_ASSERT_EQ(test, ret, 0);
318 307
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/ttm/ttm_bo.c
@@ -1434,7 +1434,7 @@ ttm_bo_swapout_cb(struct ttm_lru_walk *walk, struct ttm_buffer_object *bo)
1434 1434
1435 1435 if (ttm_tt_is_populated(tt)) {
1436 1436 ret = ttm_tt_swapout(bdev, tt, swapout_walk->gfp_flags);
1437 - if (ret > 0) {
1437 + if (!ret) {
1438 1438 spin_lock(&bdev->lru_lock);
1439 1439 ttm_resource_del_bulk_move_unevictable(bo->resource, bo);
1440 1440 ttm_resource_move_to_lru_tail(bo->resource);
modified drivers/gpu/drm/vboxvideo/vbox_mode.c
@@ -15,7 +15,6 @@
15 15
16 16 #include <drm/drm_atomic.h>
17 17 #include <drm/drm_atomic_helper.h>
18 - #include <drm/drm_blend.h>
19 18 #include <drm/drm_edid.h>
20 19 #include <drm/drm_fb_helper.h>
21 20 #include <drm/drm_fourcc.h>
@@ -541,9 +540,6 @@ static struct drm_plane *vbox_create_plane(struct vbox_private *vbox,
541 540
542 541 drm_plane_helper_add(plane, helper_funcs);
543 542
544 - drm_plane_create_blend_mode_property(plane,
545 - BIT(DRM_MODE_BLEND_COVERAGE));
546 -
547 543 return plane;
548 544
549 545 free_plane:
modified drivers/gpu/drm/vc4/vc4_bo.c
@@ -204,7 +204,7 @@ static struct list_head *vc4_get_cache_list_for_size(struct drm_device *dev,
204 204 struct list_head *new_list;
205 205 uint32_t i;
206 206
207 - new_list = kvmalloc_objs(struct list_head, new_size);
207 + new_list = kmalloc_objs(struct list_head, new_size);
208 208 if (!new_list)
209 209 return NULL;
210 210
@@ -224,7 +224,7 @@ static struct list_head *vc4_get_cache_list_for_size(struct drm_device *dev,
224 224 for (i = vc4->bo_cache.size_list_size; i < new_size; i++)
225 225 INIT_LIST_HEAD(&new_list[i]);
226 226
227 - kvfree(vc4->bo_cache.size_list);
227 + kfree(vc4->bo_cache.size_list);
228 228 vc4->bo_cache.size_list = new_list;
229 229 vc4->bo_cache.size_list_size = new_size;
230 230 }
@@ -1052,7 +1052,6 @@ static void vc4_bo_cache_destroy(struct drm_device *dev, void *unused)
1052 1052 cancel_work_sync(&vc4->bo_cache.time_work);
1053 1053
1054 1054 vc4_bo_cache_purge(dev);
1055 - kvfree(vc4->bo_cache.size_list);
1056 1055
1057 1056 for (i = 0; i < vc4->num_labels; i++) {
1058 1057 if (vc4->bo_labels[i].num_allocated) {
modified drivers/gpu/drm/vc4/vc4_drv.c
@@ -360,11 +360,8 @@ static int vc4_drm_bind(struct device *dev)
360 360 }
361 361
362 362 ret = aperture_remove_all_conflicting_devices(driver->name);
363 - if (ret) {
364 - if (firmware)
365 - rpi_firmware_put(firmware);
363 + if (ret)
366 364 goto err;
367 - }
368 365
369 366 if (firmware) {
370 367 ret = rpi_firmware_property(firmware,
modified drivers/gpu/drm/vc4/vc4_drv.h
@@ -1051,7 +1051,7 @@ void vc4_plane_async_set_fb(struct drm_plane *plane,
1051 1051 /* vc4_v3d.c */
1052 1052 extern struct platform_driver vc4_v3d_driver;
1053 1053 extern const struct of_device_id vc4_v3d_dt_match[];
1054 - int vc4_v3d_get_bin_slot(struct vc4_dev *vc4, long timeout);
1054 + int vc4_v3d_get_bin_slot(struct vc4_dev *vc4);
1055 1055 int vc4_v3d_bin_bo_get(struct vc4_dev *vc4, bool *used);
1056 1056 void vc4_v3d_bin_bo_put(struct vc4_dev *vc4);
1057 1057 int vc4_v3d_pm_get(struct vc4_dev *vc4);
modified drivers/gpu/drm/vc4/vc4_gem.c
@@ -877,17 +877,11 @@ vc4_complete_exec(struct drm_device *dev, struct vc4_exec_info *exec)
877 877 drm_gem_object_put(&bo->base.base);
878 878 }
879 879
880 - /* Free up the allocation of any bin slots we used. Jobs that ran to
881 - * completion had their slots released in vc4_irq_finish_render_job().
882 - * Only jobs that never completed still have slots to be released here.
883 - */
880 + /* Free up the allocation of any bin slots we used. */
884 881 spin_lock_irqsave(&vc4->job_lock, irqflags);
885 882 vc4->bin_alloc_used &= ~exec->bin_slots;
886 883 spin_unlock_irqrestore(&vc4->job_lock, irqflags);
887 884
888 - /* Let anyone waiting on the binner pool retry. */
889 - wake_up_all(&vc4->job_wait_queue);
890 -
891 885 /* Release the reference on the binner BO if needed. */
892 886 if (exec->bin_bo_used)
893 887 vc4_v3d_bin_bo_put(vc4);
modified drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -894,7 +894,7 @@ static void vc4_hdmi_encoder_post_crtc_disable(struct drm_encoder *encoder,
894 894
895 895 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
896 896
897 - HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, VC4_HDMI_RAM_PACKET_ENABLE);
897 + HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, 0);
898 898
899 899 HDMI_WRITE(HDMI_VID_CTL, HDMI_READ(HDMI_VID_CTL) | VC4_HD_VID_CTL_CLRRGB);
900 900
@@ -1663,6 +1663,9 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder,
1663 1663 WARN_ONCE(ret, "Timeout waiting for "
1664 1664 "VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE\n");
1665 1665 } else {
1666 + HDMI_WRITE(HDMI_RAM_PACKET_CONFIG,
1667 + HDMI_READ(HDMI_RAM_PACKET_CONFIG) &
1668 + ~(VC4_HDMI_RAM_PACKET_ENABLE));
1666 1669 HDMI_WRITE(HDMI_SCHEDULER_CONTROL,
1667 1670 HDMI_READ(HDMI_SCHEDULER_CONTROL) &
1668 1671 ~VC4_HDMI_SCHEDULER_CONTROL_MODE_HDMI);
@@ -1681,6 +1684,9 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder,
1681 1684 WARN_ON(!(HDMI_READ(HDMI_SCHEDULER_CONTROL) &
1682 1685 VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE));
1683 1686
1687 + HDMI_WRITE(HDMI_RAM_PACKET_CONFIG,
1688 + VC4_HDMI_RAM_PACKET_ENABLE);
1689 +
1684 1690 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
1685 1691 vc4_hdmi->packet_ram_enabled = true;
1686 1692
@@ -3137,11 +3143,6 @@ static int vc5_hdmi_init_resources(struct drm_device *drm,
3137 3143 static int vc4_hdmi_runtime_suspend(struct device *dev)
3138 3144 {
3139 3145 struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev);
3140 - unsigned long flags;
3141 -
3142 - spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
3143 - HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, 0);
3144 - spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
3145 3146
3146 3147 clk_disable_unprepare(vc4_hdmi->audio_clock);
3147 3148 clk_disable_unprepare(vc4_hdmi->hsm_clock);
@@ -3152,8 +3153,9 @@ static int vc4_hdmi_runtime_suspend(struct device *dev)
3152 3153 static int vc4_hdmi_runtime_resume(struct device *dev)
3153 3154 {
3154 3155 struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev);
3155 - unsigned long rate, flags;
3156 + unsigned long __maybe_unused flags;
3156 3157 u32 __maybe_unused value;
3158 + unsigned long rate;
3157 3159 int ret;
3158 3160
3159 3161 ret = clk_prepare_enable(vc4_hdmi->hsm_clock);
@@ -3199,10 +3201,6 @@ static int vc4_hdmi_runtime_resume(struct device *dev)
3199 3201 }
3200 3202 #endif
3201 3203
3202 - spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
3203 - HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, VC4_HDMI_RAM_PACKET_ENABLE);
3204 - spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
3205 -
3206 3204 return 0;
3207 3205
3208 3206 err_disable_clk:
modified drivers/gpu/drm/vc4/vc4_irq.c
@@ -74,7 +74,7 @@ vc4_overflow_mem_work(struct work_struct *work)
74 74
75 75 bo = vc4->bin_bo;
76 76
77 - bin_bo_slot = vc4_v3d_get_bin_slot(vc4, msecs_to_jiffies(500));
77 + bin_bo_slot = vc4_v3d_get_bin_slot(vc4);
78 78 if (bin_bo_slot < 0) {
79 79 drm_err(&vc4->base, "Couldn't allocate binner overflow mem\n");
80 80 goto complete;
@@ -165,10 +165,6 @@ vc4_irq_finish_render_job(struct drm_device *dev)
165 165 trace_vc4_rcl_end_irq(dev, exec->seqno);
166 166
167 167 vc4->finished_seqno++;
168 -
169 - vc4->bin_alloc_used &= ~exec->bin_slots;
170 - exec->bin_slots = 0;
171 -
172 168 list_move_tail(&exec->head, &vc4->job_done_list);
173 169
174 170 nextbin = vc4_first_bin_job(vc4);
@@ -280,7 +276,7 @@ vc4_irq_disable(struct drm_device *dev)
280 276 V3D_WRITE(V3D_INTCTL, V3D_DRIVER_IRQS);
281 277
282 278 /* Finish any interrupt handler still in flight. */
283 - disable_irq(vc4->irq);
279 + synchronize_irq(vc4->irq);
284 280
285 281 cancel_work_sync(&vc4->overflow_mem_work);
286 282 }
@@ -288,6 +284,7 @@ vc4_irq_disable(struct drm_device *dev)
288 284 int vc4_irq_install(struct drm_device *dev, int irq)
289 285 {
290 286 struct vc4_dev *vc4 = to_vc4_dev(dev);
287 + int ret;
291 288
292 289 if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
293 290 return -ENODEV;
@@ -301,8 +298,19 @@ int vc4_irq_install(struct drm_device *dev, int irq)
301 298 init_waitqueue_head(&vc4->job_wait_queue);
302 299 INIT_WORK(&vc4->overflow_mem_work, vc4_overflow_mem_work);
303 300
304 - return devm_request_irq(dev->dev, irq, vc4_irq, IRQF_NO_AUTOEN,
305 - dev_name(dev->dev), dev);
301 + /* Clear any pending interrupts someone might have left around
302 + * for us.
303 + */
304 + V3D_WRITE(V3D_INTCTL, V3D_DRIVER_IRQS);
305 +
306 + ret = devm_request_irq(dev->dev, irq, vc4_irq, 0,
307 + dev_name(dev->dev), dev);
308 + if (ret)
309 + return ret;
310 +
311 + vc4_irq_enable(dev);
312 +
313 + return 0;
306 314 }
307 315
308 316 void vc4_irq_uninstall(struct drm_device *dev)
modified drivers/gpu/drm/vc4/vc4_kms.c
@@ -1188,7 +1188,7 @@ int vc4_kms_load(struct drm_device *dev)
1188 1188
1189 1189 drm_mode_config_reset(dev);
1190 1190
1191 - drmm_kms_helper_poll_init(dev);
1191 + drm_kms_helper_poll_init(dev);
1192 1192
1193 1193 return 0;
1194 1194 }
modified drivers/gpu/drm/vc4/vc4_v3d.c
@@ -9,7 +9,6 @@
9 9 #include <linux/component.h>
10 10 #include <linux/platform_device.h>
11 11 #include <linux/pm_runtime.h>
12 - #include <linux/timer.h>
13 12
14 13 #include <drm/drm_print.h>
15 14
@@ -173,42 +172,46 @@ static void vc4_v3d_init_hw(struct drm_device *dev)
173 172 V3D_WRITE(V3D_VPMBASE, 0);
174 173 }
175 174
176 - static int bin_slot_try_alloc(struct vc4_dev *vc4)
175 + int vc4_v3d_get_bin_slot(struct vc4_dev *vc4)
177 176 {
177 + struct drm_device *dev = &vc4->base;
178 + unsigned long irqflags;
178 179 int slot;
180 + uint64_t seqno = 0;
181 + struct vc4_exec_info *exec;
179 182
180 - guard(spinlock_irqsave)(&vc4->job_lock);
183 + if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
184 + return -ENODEV;
181 185
186 + try_again:
187 + spin_lock_irqsave(&vc4->job_lock, irqflags);
182 188 slot = ffs(~vc4->bin_alloc_used);
183 189 if (slot != 0) {
184 190 /* Switch from ffs() bit index to a 0-based index. */
185 191 slot--;
186 192 vc4->bin_alloc_used |= BIT(slot);
187 - } else {
188 - slot = -ENOMEM;
193 + spin_unlock_irqrestore(&vc4->job_lock, irqflags);
194 + return slot;
189 195 }
190 196
191 - return slot;
192 - }
197 + /* Couldn't find an open slot. Wait for render to complete
198 + * and try again.
199 + */
200 + exec = vc4_last_render_job(vc4);
201 + if (exec)
202 + seqno = exec->seqno;
203 + spin_unlock_irqrestore(&vc4->job_lock, irqflags);
193 204
194 - int vc4_v3d_get_bin_slot(struct vc4_dev *vc4, long timeout)
195 - {
196 - int slot;
197 - long ret;
205 + if (seqno) {
206 + int ret = vc4_wait_for_seqno(dev, seqno, ~0ull, true);
198 207
199 - if (WARN_ON_ONCE(vc4->gen > VC4_GEN_4))
200 - return -ENODEV;
208 + if (ret == 0)
209 + goto try_again;
201 210
202 - /* If the pool is full, wait for a job to release its slots. */
203 - ret = wait_event_interruptible_timeout(vc4->job_wait_queue,
204 - (slot = bin_slot_try_alloc(vc4)) >= 0,
205 - timeout);
206 - if (ret < 0)
207 211 return ret;
208 - if (ret == 0)
209 - return -ENOMEM;
212 + }
210 213
211 - return slot;
214 + return -ENOMEM;
212 215 }
213 216
214 217 /*
@@ -393,7 +396,6 @@ static int vc4_v3d_runtime_resume(struct device *dev)
393 396 vc4_v3d_init_hw(&vc4->base);
394 397
395 398 vc4_irq_enable(&vc4->base);
396 - enable_irq(vc4->irq);
397 399
398 400 return 0;
399 401 }
@@ -450,12 +452,6 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
450 452 return ret;
451 453 vc4->irq = ret;
452 454
453 - ret = vc4_irq_install(drm, vc4->irq);
454 - if (ret) {
455 - drm_err(drm, "Failed to install IRQ handler\n");
456 - return ret;
457 - }
458 -
459 455 ret = devm_pm_runtime_enable(dev);
460 456 if (ret)
461 457 return ret;
@@ -477,6 +473,12 @@ static int vc4_v3d_bind(struct device *dev, struct device *master, void *data)
477 473 V3D_WRITE(V3D_BPOA, 0);
478 474 V3D_WRITE(V3D_BPOS, 0);
479 475
476 + ret = vc4_irq_install(drm, vc4->irq);
477 + if (ret) {
478 + drm_err(drm, "Failed to install IRQ handler\n");
479 + goto err_put_runtime_pm;
480 + }
481 +
480 482 pm_runtime_use_autosuspend(dev);
481 483 pm_runtime_set_autosuspend_delay(dev, 40); /* a little over 2 frames. */
482 484 pm_runtime_put_autosuspend(dev);
@@ -495,15 +497,8 @@ static void vc4_v3d_unbind(struct device *dev, struct device *master,
495 497 struct drm_device *drm = data;
496 498 struct vc4_dev *vc4 = to_vc4_dev(drm);
497 499
498 - /* A straggler vc4_reset() re-enables the interrupt. */
499 - timer_shutdown_sync(&vc4->hangcheck.timer);
500 - cancel_work_sync(&vc4->hangcheck.reset_work);
501 -
502 500 vc4_irq_uninstall(drm);
503 501
504 - /* Flush rather than cancel, so queued completions release their jobs. */
505 - flush_work(&vc4->job_done_work);
506 -
507 502 /* Disable the binner's overflow memory address, so the next
508 503 * driver probe (if any) doesn't try to reuse our old
509 504 * allocation.
modified drivers/gpu/drm/vc4/vc4_validate.c
@@ -402,7 +402,7 @@ validate_tile_binning_config(VALIDATE_ARGS)
402 402 return -EINVAL;
403 403 }
404 404
405 - bin_slot = vc4_v3d_get_bin_slot(vc4, MAX_SCHEDULE_TIMEOUT);
405 + bin_slot = vc4_v3d_get_bin_slot(vc4);
406 406 if (bin_slot < 0) {
407 407 if (bin_slot != -EINTR && bin_slot != -ERESTARTSYS) {
408 408 drm_err(dev, "Failed to allocate binner memory: %d\n",
modified drivers/gpu/drm/verisilicon/vs_cursor_plane.c
@@ -11,7 +11,6 @@
11 11
12 12 #include <drm/drm_atomic.h>
13 13 #include <drm/drm_atomic_helper.h>
14 - #include <drm/drm_blend.h>
15 14 #include <drm/drm_crtc.h>
16 15 #include <drm/drm_fourcc.h>
17 16 #include <drm/drm_framebuffer.h>
@@ -268,7 +267,6 @@ struct drm_plane *vs_cursor_plane_init(struct drm_device *drm_dev,
268 267 return plane;
269 268
270 269 drm_plane_helper_add(plane, &vs_cursor_plane_helper_funcs);
271 - drm_plane_create_blend_mode_property(plane, BIT(DRM_MODE_BLEND_COVERAGE));
272 270
273 271 return plane;
274 272 }
modified drivers/gpu/drm/verisilicon/vs_hwdb.c
@@ -10,50 +10,82 @@
10 10 #include "vs_dc_top_regs.h"
11 11 #include "vs_hwdb.h"
12 12
13 - static const u32 vs_primary_formats_array_no_yuv444[] = {
13 + static const u32 vs_formats_array_no_yuv444[] = {
14 14 DRM_FORMAT_XRGB4444,
15 15 DRM_FORMAT_XBGR4444,
16 16 DRM_FORMAT_RGBX4444,
17 17 DRM_FORMAT_BGRX4444,
18 + DRM_FORMAT_ARGB4444,
19 + DRM_FORMAT_ABGR4444,
20 + DRM_FORMAT_RGBA4444,
21 + DRM_FORMAT_BGRA4444,
18 22 DRM_FORMAT_XRGB1555,
19 23 DRM_FORMAT_XBGR1555,
20 24 DRM_FORMAT_RGBX5551,
21 25 DRM_FORMAT_BGRX5551,
26 + DRM_FORMAT_ARGB1555,
27 + DRM_FORMAT_ABGR1555,
28 + DRM_FORMAT_RGBA5551,
29 + DRM_FORMAT_BGRA5551,
22 30 DRM_FORMAT_RGB565,
23 31 DRM_FORMAT_BGR565,
24 32 DRM_FORMAT_XRGB8888,
25 33 DRM_FORMAT_XBGR8888,
26 34 DRM_FORMAT_RGBX8888,
27 35 DRM_FORMAT_BGRX8888,
36 + DRM_FORMAT_ARGB8888,
37 + DRM_FORMAT_ABGR8888,
38 + DRM_FORMAT_RGBA8888,
39 + DRM_FORMAT_BGRA8888,
40 + DRM_FORMAT_ARGB2101010,
41 + DRM_FORMAT_ABGR2101010,
42 + DRM_FORMAT_RGBA1010102,
43 + DRM_FORMAT_BGRA1010102,
28 44 /* TODO: non-RGB formats */
29 45 };
30 46
31 - static const u32 vs_primary_formats_array_with_yuv444[] = {
47 + static const u32 vs_formats_array_with_yuv444[] = {
32 48 DRM_FORMAT_XRGB4444,
33 49 DRM_FORMAT_XBGR4444,
34 50 DRM_FORMAT_RGBX4444,
35 51 DRM_FORMAT_BGRX4444,
52 + DRM_FORMAT_ARGB4444,
53 + DRM_FORMAT_ABGR4444,
54 + DRM_FORMAT_RGBA4444,
55 + DRM_FORMAT_BGRA4444,
36 56 DRM_FORMAT_XRGB1555,
37 57 DRM_FORMAT_XBGR1555,
38 58 DRM_FORMAT_RGBX5551,
39 59 DRM_FORMAT_BGRX5551,
60 + DRM_FORMAT_ARGB1555,
61 + DRM_FORMAT_ABGR1555,
62 + DRM_FORMAT_RGBA5551,
63 + DRM_FORMAT_BGRA5551,
40 64 DRM_FORMAT_RGB565,
41 65 DRM_FORMAT_BGR565,
42 66 DRM_FORMAT_XRGB8888,
43 67 DRM_FORMAT_XBGR8888,
44 68 DRM_FORMAT_RGBX8888,
45 69 DRM_FORMAT_BGRX8888,
70 + DRM_FORMAT_ARGB8888,
71 + DRM_FORMAT_ABGR8888,
72 + DRM_FORMAT_RGBA8888,
73 + DRM_FORMAT_BGRA8888,
74 + DRM_FORMAT_ARGB2101010,
75 + DRM_FORMAT_ABGR2101010,
76 + DRM_FORMAT_RGBA1010102,
77 + DRM_FORMAT_BGRA1010102,
46 78 /* TODO: non-RGB formats */
47 79 };
48 80
49 81 static const struct vs_formats vs_formats_no_yuv444 = {
50 - .primary_array = vs_primary_formats_array_no_yuv444,
51 - .primary_num = ARRAY_SIZE(vs_primary_formats_array_no_yuv444)
82 + .array = vs_formats_array_no_yuv444,
83 + .num = ARRAY_SIZE(vs_formats_array_no_yuv444)
52 84 };
53 85
54 86 static const struct vs_formats vs_formats_with_yuv444 = {
55 - .primary_array = vs_primary_formats_array_with_yuv444,
56 - .primary_num = ARRAY_SIZE(vs_primary_formats_array_with_yuv444)
87 + .array = vs_formats_array_with_yuv444,
88 + .num = ARRAY_SIZE(vs_formats_array_with_yuv444)
57 89 };
58 90
59 91 static struct vs_chip_identity vs_chip_identities[] = {
modified drivers/gpu/drm/verisilicon/vs_hwdb.h
@@ -10,8 +10,8 @@
10 10 #include <linux/types.h>
11 11
12 12 struct vs_formats {
13 - const u32 *primary_array;
14 - unsigned int primary_num;
13 + const u32 *array;
14 + unsigned int num;
15 15 };
16 16
17 17 struct vs_chip_identity {
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/verisilicon/vs_primary_plane.c
@@ -168,8 +168,8 @@ struct drm_plane *vs_primary_plane_init(struct drm_device *drm_dev, struct vs_dc
168 168
169 169 plane = drmm_universal_plane_alloc(drm_dev, struct drm_plane, dev, 0,
170 170 &vs_primary_plane_funcs,
171 - dc->identity.formats->primary_array,
172 - dc->identity.formats->primary_num,
171 + dc->identity.formats->array,
172 + dc->identity.formats->num,
173 173 NULL,
174 174 DRM_PLANE_TYPE_PRIMARY,
175 175 NULL);
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;
@@ -114,8 +94,6 @@ struct virtio_gpu_object {
114 94 bool dumb;
115 95 bool created;
116 96 bool attached;
117 - /* a guest-bound transfer is queued and its mapping not yet synced */
118 - bool from_host_pending;
119 97 bool host3d_blob, guest_blob;
120 98 uint32_t blob_mem, blob_flags;
121 99
@@ -198,9 +176,6 @@ struct virtio_gpu_vbuffer {
198 176 struct list_head list;
199 177
200 178 uint32_t seqno;
201 -
202 - /* guest-bound transfer whose shmem backing needs a CPU sync */
203 - bool sync_for_cpu;
204 179 };
205 180
206 181 struct virtio_gpu_output {
@@ -368,7 +343,6 @@ void virtio_gpu_array_put_free_work(struct work_struct *work);
368 343 /* virtgpu_vq.c */
369 344 int virtio_gpu_alloc_vbufs(struct virtio_gpu_device *vgdev);
370 345 void virtio_gpu_free_vbufs(struct virtio_gpu_device *vgdev);
371 - void virtio_gpu_reclaim_vbufs(struct virtio_gpu_device *vgdev);
372 346 void virtio_gpu_cmd_create_resource(struct virtio_gpu_device *vgdev,
373 347 struct virtio_gpu_object *bo,
374 348 struct virtio_gpu_object_params *params,
modified drivers/gpu/drm/virtio/virtgpu_gem.c
@@ -45,7 +45,7 @@ static int virtio_gpu_gem_create(struct drm_file *file,
45 45
46 46 ret = drm_gem_handle_create(file, &obj->base.base, &handle);
47 47 if (ret) {
48 - drm_gem_object_put(&obj->base.base);
48 + drm_gem_object_release(&obj->base.base);
49 49 return ret;
50 50 }
51 51
modified drivers/gpu/drm/virtio/virtgpu_ioctl.c
@@ -185,7 +185,7 @@ static int virtio_gpu_resource_create_ioctl(struct drm_device *dev, void *data,
185 185
186 186 ret = drm_gem_handle_create(file, obj, &handle);
187 187 if (ret) {
188 - drm_gem_object_put(obj);
188 + drm_gem_object_release(obj);
189 189 return ret;
190 190 }
191 191
@@ -261,27 +261,6 @@ static int virtio_gpu_transfer_from_host_ioctl(struct drm_device *dev,
261 261 if (ret != 0)
262 262 goto err_put_free;
263 263
264 - if (virtio_gpu_is_shmem(bo) && virtio_gpu_use_dma_api(vgdev->vdev)) {
265 - /*
266 - * The sync on completion restores the whole mapping, so an
267 - * earlier transfer has to be done before this one snapshots it.
268 - * Otherwise the snapshot predates anything the CPU wrote once
269 - * that transfer's fence signalled, and the later sync would
270 - * discard it. Nothing can add a fence behind our back here,
271 - * since doing so takes the reservation we already hold.
272 - * This writes the pages, so it waits as a writer does. READ
273 - * usage covers existing readers.
274 - */
275 - long wait = dma_resv_wait_timeout(objs->objs[0]->resv,
276 - DMA_RESV_USAGE_READ, true,
277 - MAX_SCHEDULE_TIMEOUT);
278 -
279 - if (wait < 0) {
280 - ret = wait;
281 - goto err_unlock;
282 - }
283 - }
284 -
285 264 fence = virtio_gpu_fence_alloc(vgdev, vgdev->fence_drv.context, 0);
286 265 if (!fence) {
287 266 ret = -ENOMEM;
@@ -341,28 +320,6 @@ static int virtio_gpu_transfer_to_host_ioctl(struct drm_device *dev, void *data,
341 320 if (ret != 0)
342 321 goto err_put_free;
343 322
344 - /*
345 - * A transfer the other way may have queued without yet syncing
346 - * its mapping. Pushing the guest pages into it now would
347 - * discard what the device wrote there, so wait for that sync:
348 - * it runs before the fence it belongs to is signalled. The
349 - * flag is only set under this reservation, so it cannot appear
350 - * behind our back, and the acquire pairs with the release in
351 - * that sync, so finding it clear means the pages it wrote are
352 - * visible here too.
353 - */
354 - if (smp_load_acquire(&bo->from_host_pending)) {
355 - long wait = dma_resv_wait_timeout(objs->objs[0]->resv,
356 - DMA_RESV_USAGE_WRITE,
357 - true,
358 - MAX_SCHEDULE_TIMEOUT);
359 -
360 - if (wait < 0) {
361 - ret = wait;
362 - goto err_unlock;
363 - }
364 - }
365 -
366 323 ret = -ENOMEM;
367 324 fence = virtio_gpu_fence_alloc(vgdev, vgdev->fence_drv.context,
368 325 0);
@@ -600,14 +557,14 @@ static int virtio_gpu_resource_create_blob_ioctl(struct drm_device *dev,
600 557 if (params.blob_flags & VIRTGPU_BLOB_FLAG_USE_CROSS_DEVICE) {
601 558 ret = virtio_gpu_resource_assign_uuid(vgdev, bo);
602 559 if (ret) {
603 - drm_gem_object_put(obj);
560 + drm_gem_object_release(obj);
604 561 return ret;
605 562 }
606 563 }
607 564
608 565 ret = drm_gem_handle_create(file, obj, &handle);
609 566 if (ret) {
610 - drm_gem_object_put(obj);
567 + drm_gem_object_release(obj);
611 568 return ret;
612 569 }
613 570
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_plane.c
@@ -24,7 +24,6 @@
24 24 */
25 25
26 26 #include <drm/drm_atomic_helper.h>
27 - #include <drm/drm_blend.h>
28 27 #include <drm/drm_damage_helper.h>
29 28 #include <drm/drm_fourcc.h>
30 29 #include <drm/drm_gem_atomic_helper.h>
@@ -610,9 +609,6 @@ struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev,
610 609
611 610 if (type == DRM_PLANE_TYPE_PRIMARY)
612 611 drm_plane_enable_fb_damage_clips(plane);
613 - else if (type == DRM_PLANE_TYPE_CURSOR)
614 - drm_plane_create_blend_mode_property(plane,
615 - BIT(DRM_MODE_BLEND_PREMULTI));
616 612
617 613 return plane;
618 614 }
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;
@@ -349,7 +351,7 @@ struct drm_gem_object *virtgpu_gem_prime_import(struct drm_device *dev,
349 351 }
350 352 }
351 353
352 - if (!vgdev->has_resource_blob || vgdev->has_virgl_3d)
354 + if (!vgdev->has_resource_blob)
353 355 return drm_gem_prime_import(dev, buf);
354 356
355 357 bo = kzalloc_obj(*bo);
modified drivers/gpu/drm/virtio/virtgpu_submit.c
@@ -389,13 +389,10 @@ static int virtio_gpu_init_submit(struct virtio_gpu_submit *submit,
389 389 if ((exbuf->flags & VIRTGPU_EXECBUF_FENCE_FD_OUT) ||
390 390 exbuf->num_out_syncobjs ||
391 391 exbuf->num_bo_handles ||
392 - drm_fence_event) {
392 + drm_fence_event)
393 393 out_fence = virtio_gpu_fence_alloc(vgdev, fence_ctx, ring_idx);
394 - if (!out_fence)
395 - return -ENOMEM;
396 - } else {
394 + else
397 395 out_fence = NULL;
398 - }
399 396
400 397 if (drm_fence_event) {
401 398 err = virtio_gpu_fence_event_create(dev, file, out_fence, ring_idx);
@@ -541,10 +538,6 @@ int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data,
541 538 virtio_gpu_process_post_deps(&submit);
542 539 virtio_gpu_complete_submit(&submit);
543 540 cleanup:
544 - if (ret && submit.out_fence && submit.out_fence->e) {
545 - drm_event_cancel_free(dev, &submit.out_fence->e->base);
546 - submit.out_fence->e = NULL;
547 - }
548 541 virtio_gpu_cleanup_submit(&submit);
549 542
550 543 return ret;
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;
@@ -256,33 +241,6 @@ void virtio_gpu_dequeue_ctrl_func(struct work_struct *work)
256 241 } while (!virtqueue_enable_cb(vgdev->ctrlq.vq));
257 242 spin_unlock(&vgdev->ctrlq.qlock);
258 243
259 - /*
260 - * Sync guest-bound transfers before signalling anything, so that a
261 - * waiter cannot read the backing pages while what the device wrote is
262 - * still in a bounce buffer. This cannot be folded into the loop below:
263 - * virtio_gpu_fence_event_process() also signals every earlier fence in
264 - * the same context, so any entry there may signal this entry's fence.
265 - */
266 - list_for_each_entry(entry, &reclaim_list, list) {
267 - if (entry->sync_for_cpu) {
268 - struct virtio_gpu_object *bo =
269 - gem_to_virtio_gpu_obj(entry->objs->objs[0]);
270 -
271 - dma_sync_sgtable_for_cpu(vgdev->vdev->dev.parent,
272 - bo->base.sgt, DMA_FROM_DEVICE);
273 - /*
274 - * Release, so a transfer the other way that skips its
275 - * wait on the strength of this cannot go on to read
276 - * the backing pages before the sync above is visible.
277 - * Nothing orders the two otherwise: where the mapping
278 - * bounces on a coherent device the sync is a plain
279 - * copy, and dma_direct_sync_sg_for_cpu() emits its
280 - * barrier only for the non-coherent case.
281 - */
282 - smp_store_release(&bo->from_host_pending, false);
283 - }
284 - }
285 -
286 244 list_for_each_entry(entry, &reclaim_list, list) {
287 245 resp = (struct virtio_gpu_ctrl_hdr *)entry->resp_buf;
288 246
@@ -806,7 +764,7 @@ int virtio_gpu_panic_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
806 764 struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
807 765 struct virtio_gpu_transfer_to_host_2d *cmd_p;
808 766 struct virtio_gpu_vbuffer *vbuf;
809 - bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev);
767 + bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
810 768
811 769 if (virtio_gpu_is_shmem(bo) && use_dma_api)
812 770 dma_sync_sgtable_for_device(vgdev->vdev->dev.parent,
@@ -837,7 +795,7 @@ void virtio_gpu_cmd_transfer_to_host_2d(struct virtio_gpu_device *vgdev,
837 795 struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
838 796 struct virtio_gpu_transfer_to_host_2d *cmd_p;
839 797 struct virtio_gpu_vbuffer *vbuf;
840 - bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev);
798 + bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
841 799
842 800 if (virtio_gpu_is_shmem(bo) && use_dma_api)
843 801 dma_sync_sgtable_for_device(vgdev->vdev->dev.parent,
@@ -1270,7 +1228,7 @@ void virtio_gpu_cmd_transfer_to_host_3d(struct virtio_gpu_device *vgdev,
1270 1228 struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
1271 1229 struct virtio_gpu_transfer_host_3d *cmd_p;
1272 1230 struct virtio_gpu_vbuffer *vbuf;
1273 - bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev);
1231 + bool use_dma_api = !virtio_has_dma_quirk(vgdev->vdev);
1274 1232
1275 1233 if (virtio_gpu_is_shmem(bo) && use_dma_api)
1276 1234 dma_sync_sgtable_for_device(vgdev->vdev->dev.parent,
@@ -1305,31 +1263,12 @@ void virtio_gpu_cmd_transfer_from_host_3d(struct virtio_gpu_device *vgdev,
1305 1263 struct virtio_gpu_object *bo = gem_to_virtio_gpu_obj(objs->objs[0]);
1306 1264 struct virtio_gpu_transfer_host_3d *cmd_p;
1307 1265 struct virtio_gpu_vbuffer *vbuf;
1308 - bool use_dma_api = virtio_gpu_use_dma_api(vgdev->vdev);
1309 1266
1310 1267 cmd_p = virtio_gpu_alloc_cmd(vgdev, &vbuf, sizeof(*cmd_p));
1311 1268 memset(cmd_p, 0, sizeof(*cmd_p));
1312 1269
1313 1270 vbuf->objs = objs;
1314 1271
1315 - if (virtio_gpu_is_shmem(bo) && use_dma_api) {
1316 - /*
1317 - * The device writes only the requested box, so prime the
1318 - * mapping with the current contents: otherwise the sync on
1319 - * completion would hand back whatever a bounce buffer held for
1320 - * the regions the device does not touch.
1321 - */
1322 - dma_sync_sgtable_for_device(vgdev->vdev->dev.parent,
1323 - bo->base.sgt, DMA_TO_DEVICE);
1324 - vbuf->sync_for_cpu = true;
1325 - /*
1326 - * Set under the reservation the caller holds, so a transfer
1327 - * the other way cannot miss it and push the guest pages into
1328 - * the mapping while the device still owns it.
1329 - */
1330 - WRITE_ONCE(bo->from_host_pending, true);
1331 - }
1332 -
1333 1272 cmd_p->hdr.type = cpu_to_le32(VIRTIO_GPU_CMD_TRANSFER_FROM_HOST_3D);
1334 1273 cmd_p->hdr.ctx_id = cpu_to_le32(ctx_id);
1335 1274 cmd_p->resource_id = cpu_to_le32(bo->hw_res_handle);
modified drivers/gpu/drm/virtio/virtgpu_vram.c
@@ -215,12 +215,16 @@ int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev,
215 215
216 216 /* Create fake offset */
217 217 ret = drm_gem_create_mmap_offset(obj);
218 - if (ret)
219 - goto err_release_obj;
218 + if (ret) {
219 + kfree(vram);
220 + return ret;
221 + }
220 222
221 223 ret = virtio_gpu_resource_id_get(vgdev, &vram->base.hw_res_handle);
222 - if (ret)
223 - goto err_release_obj;
224 + if (ret) {
225 + kfree(vram);
226 + return ret;
227 + }
224 228
225 229 virtio_gpu_cmd_resource_create_blob(vgdev, &vram->base, params, NULL,
226 230 0);
@@ -236,11 +240,6 @@ int virtio_gpu_vram_create(struct virtio_gpu_device *vgdev,
236 240
237 241 *bo_ptr = &vram->base;
238 242 return 0;
239 -
240 - err_release_obj:
241 - drm_gem_object_release(obj);
242 - kfree(vram);
243 - return ret;
244 243 }
245 244
246 245 void virtio_gpu_vram_map_deferred(struct virtio_gpu_object_vram *vram)
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/vmwgfx/vmwgfx_cursor_plane.c
@@ -324,7 +324,6 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,
324 324 unsigned long kmap_num;
325 325 SVGA3dCopyBox *box;
326 326 u32 box_count;
327 - u64 src_extent;
328 327 void *virtual;
329 328 bool is_iomem;
330 329 struct vmw_dma_cmd {
@@ -336,8 +335,6 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,
336 335 vmw_surface_get_desc(VMW_CURSOR_SNOOP_FORMAT);
337 336 const u32 image_pitch = VMW_CURSOR_SNOOP_WIDTH * desc->pitchBytesPerBlock;
338 337
339 - BUILD_BUG_ON(sizeof(*srf->snooper.image) != desc->pitchBytesPerBlock);
340 -
341 338 cmd = container_of(header, struct vmw_dma_cmd, header);
342 339
343 340 /* No snooper installed, nothing to copy */
@@ -375,19 +372,8 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,
375 372 return;
376 373 }
377 374
378 - if (box->w == 0 || box->h == 0)
379 - return;
380 -
381 - src_extent = (u64)(box->h - 1) * cmd->dma.guest.pitch +
382 - (u64)box->w * desc->pitchBytesPerBlock;
383 - if (src_extent > bo->base.size) {
384 - DRM_ERROR("Cursor snoop source of %llu bytes exceeds the %zu byte buffer\n",
385 - src_extent, bo->base.size);
386 - return;
387 - }
388 -
389 375 kmap_offset = cmd->dma.guest.ptr.offset >> PAGE_SHIFT;
390 - kmap_num = PFN_UP(src_extent);
376 + kmap_num = (VMW_CURSOR_SNOOP_HEIGHT * image_pitch) >> PAGE_SHIFT;
391 377
392 378 ret = ttm_bo_reserve(bo, true, false, NULL);
393 379 if (unlikely(ret != 0)) {
@@ -401,16 +387,14 @@ void vmw_kms_cursor_snoop(struct vmw_surface *srf,
401 387
402 388 virtual = ttm_kmap_obj_virtual(&map, &is_iomem);
403 389
404 - if (box->w == VMW_CURSOR_SNOOP_WIDTH &&
405 - box->h == VMW_CURSOR_SNOOP_HEIGHT &&
406 - cmd->dma.guest.pitch == image_pitch) {
390 + if (box->w == VMW_CURSOR_SNOOP_WIDTH && cmd->dma.guest.pitch == image_pitch) {
407 391 memcpy(srf->snooper.image, virtual,
408 392 VMW_CURSOR_SNOOP_HEIGHT * image_pitch);
409 393 } else {
410 - /* The destination stride is in pixels. */
394 + /* Image is unsigned pointer. */
411 395 for (i = 0; i < box->h; i++)
412 - memcpy(srf->snooper.image + i * VMW_CURSOR_SNOOP_WIDTH,
413 - virtual + (size_t)i * cmd->dma.guest.pitch,
396 + memcpy(srf->snooper.image + i * image_pitch,
397 + virtual + i * cmd->dma.guest.pitch,
414 398 box->w * desc->pitchBytesPerBlock);
415 399 }
416 400 srf->snooper.id++;
modified drivers/gpu/drm/vmwgfx/vmwgfx_kms.c
@@ -20,18 +20,10 @@
20 20 #include <drm/drm_rect.h>
21 21 #include <drm/drm_sysfs.h>
22 22 #include <drm/drm_edid.h>
23 - #include <drm/drm_blend.h>
24 23
25 24 void vmw_du_init(struct vmw_display_unit *du)
26 25 {
27 26 vmw_vkms_crtc_init(&du->crtc);
28 - drm_plane_create_blend_mode_property(&du->primary,
29 - BIT(DRM_MODE_BLEND_PIXEL_NONE) |
30 - BIT(DRM_MODE_BLEND_PREMULTI));
31 - // Check that the cursor plane was actually initialized
32 - if (du->crtc.cursor == &du->cursor.base)
33 - drm_plane_create_blend_mode_property(&du->cursor.base,
34 - BIT(DRM_MODE_BLEND_PREMULTI));
35 27 }
36 28
37 29 void vmw_du_cleanup(struct vmw_display_unit *du)
modified drivers/gpu/drm/xe/instructions/xe_gpu_commands.h
@@ -46,7 +46,6 @@
46 46 #define GFX_OP_PIPE_CONTROL(len) ((0x3<<29)|(0x3<<27)|(0x2<<24)|((len)-2))
47 47
48 48 #define PIPE_CONTROL0_QUEUE_DRAIN_MODE BIT(12)
49 - #define PIPE_CONTROL0_UNTYPED_DATAPORT_CACHE_FLUSH BIT(11) /* gen12 */
50 49 #define PIPE_CONTROL0_L3_READ_ONLY_CACHE_INVALIDATE BIT(10) /* gen12 */
51 50 #define PIPE_CONTROL0_HDC_PIPELINE_FLUSH BIT(9) /* gen12 */
52 51
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_pagefault.c
@@ -16,7 +16,6 @@
16 16 #include "xe_hw_engine.h"
17 17 #include "xe_pagefault.h"
18 18 #include "xe_pagefault_types.h"
19 - #include "xe_pm.h"
20 19 #include "xe_svm.h"
21 20 #include "xe_trace_bo.h"
22 21 #include "xe_vm.h"
@@ -293,17 +292,9 @@ static void xe_pagefault_queue_work(struct work_struct *w)
293 292 {
294 293 struct xe_pagefault_queue *pf_queue =
295 294 container_of(w, typeof(*pf_queue), worker);
296 - struct xe_device *xe = pf_queue->xe;
297 295 struct xe_pagefault pf;
298 296 unsigned long threshold;
299 297
300 - /*
301 - * A live VM holds a PM reference, but a torn-down VM does not.
302 - * Guard the entire worker loop to safely drain stale faults and
303 - * prevent autosuspends from desyncing batched CT flushes.
304 - */
305 - guard(xe_pm_runtime)(xe);
306 -
307 298 #define USM_QUEUE_MAX_RUNTIME_MS 20
308 299 threshold = jiffies + msecs_to_jiffies(USM_QUEUE_MAX_RUNTIME_MS);
309 300
@@ -374,7 +365,6 @@ static int xe_pagefault_queue_init(struct xe_device *xe,
374 365 drm_dbg(&xe->drm, "xe_pagefault_entry_size=%d, total_num_eus=%d, pf_queue->size=%u",
375 366 xe_pagefault_entry_size(), total_num_eus, pf_queue->size);
376 367
377 - pf_queue->xe = xe;
378 368 spin_lock_init(&pf_queue->lock);
379 369 INIT_WORK(&pf_queue->worker, xe_pagefault_queue_work);
380 370
modified drivers/gpu/drm/xe/xe_pagefault_types.h
@@ -8,7 +8,6 @@
8 8
9 9 #include <linux/workqueue.h>
10 10
11 - struct xe_device;
12 11 struct xe_gt;
13 12 struct xe_pagefault;
14 13
@@ -119,8 +118,6 @@ struct xe_pagefault {
119 118 * queue to absorb the device’s worst-case number of outstanding faults.
120 119 */
121 120 struct xe_pagefault_queue {
122 - /** @xe: Back-pointer to the Xe device */
123 - struct xe_device *xe;
124 121 /**
125 122 * @data: Data in queue containing struct xe_pagefault, protected by
126 123 * @lock
modified drivers/gpu/drm/xe/xe_ring_ops.c
@@ -212,7 +212,6 @@ static int emit_render_cache_flush(struct xe_sched_job *job, u32 *dw, int i)
212 212 {
213 213 struct xe_exec_queue *q = job->q;
214 214 struct xe_gt *gt = q->gt;
215 - struct xe_device *xe = gt_to_xe(gt);
216 215 bool lacks_render = !(gt->info.engine_mask & XE_HW_ENGINE_RCS_MASK);
217 216 u32 flags0, flags1;
218 217
@@ -221,16 +220,6 @@ static int emit_render_cache_flush(struct xe_sched_job *job, u32 *dw, int i)
221 220 LRC_PPHWSP_FLUSH_INVAL_SCRATCH_ADDR, 0);
222 221
223 222 flags0 = PIPE_CONTROL0_HDC_PIPELINE_FLUSH;
224 - /*
225 - * Prior to MTL, HDC Pipeline Flush reliably also flushes the LSC
226 - * untyped L1 dataport cache, provided HDC_CHICKEN0 is programmed
227 - * correctly. Starting with MTL that coupling no longer holds
228 - * regardless of how HDC_CHICKEN0 is programmed, but explicitly
229 - * requesting the flush via PIPE_CONTROL is itself only reliable
230 - * from Xe2 onward, so only gate it in on Xe2+.
231 - */
232 - if (GRAPHICS_VERx100(xe) >= 2000)
233 - flags0 |= PIPE_CONTROL0_UNTYPED_DATAPORT_CACHE_FLUSH;
234 223 flags1 = (PIPE_CONTROL_TILE_CACHE_FLUSH |
235 224 PIPE_CONTROL_RENDER_TARGET_CACHE_FLUSH |
236 225 PIPE_CONTROL_DEPTH_CACHE_FLUSH |
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
@@ -1128,17 +1128,12 @@ static void applesmc_release_light_sensor(void)
1128 1128
1129 1129 static int applesmc_create_key_backlight(void)
1130 1130 {
1131 - int ret;
1132 -
1133 1131 if (!smcreg.has_key_backlight)
1134 1132 return 0;
1135 1133 applesmc_led_wq = create_singlethread_workqueue("applesmc-led");
1136 1134 if (!applesmc_led_wq)
1137 1135 return -ENOMEM;
1138 - ret = led_classdev_register(&pdev->dev, &applesmc_backlight);
1139 - if (ret)
1140 - destroy_workqueue(applesmc_led_wq);
1141 - return ret;
1136 + return led_classdev_register(&pdev->dev, &applesmc_backlight);
1142 1137 }
1143 1138
1144 1139 static void applesmc_release_key_backlight(void)
@@ -1481,9 +1476,9 @@ static int __init applesmc_init(void)
1481 1476 applesmc_fan_config[smcreg.fan_count] = 0;
1482 1477 applesmc_pwm_config[smcreg.fan_count] = 0;
1483 1478
1484 - applesmc_info_temp = kzalloc_obj(*applesmc_info_temp);
1485 - applesmc_info_fan = kzalloc_obj(*applesmc_info_fan);
1486 - 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);
1487 1482 if (!applesmc_info_temp || !applesmc_info_fan || !applesmc_info_pwm) {
1488 1483 ret = -ENOMEM;
1489 1484 goto out_info;
@@ -1498,7 +1493,7 @@ static int __init applesmc_init(void)
1498 1493 applesmc_info_pwm->type = hwmon_pwm;
1499 1494 applesmc_info_pwm->config = applesmc_pwm_config;
1500 1495
1501 - applesmc_info_arr = kzalloc_objs(*applesmc_info_arr, 4);
1496 + applesmc_info_arr = kcalloc(4, sizeof(*applesmc_info_arr), GFP_KERNEL);
1502 1497 if (!applesmc_info_arr) {
1503 1498 ret = -ENOMEM;
1504 1499 goto out_info;
@@ -1509,7 +1504,7 @@ static int __init applesmc_init(void)
1509 1504 applesmc_info_arr[2] = applesmc_info_pwm;
1510 1505 applesmc_info_arr[3] = NULL;
1511 1506
1512 - applesmc_chip = kzalloc_obj(*applesmc_chip);
1507 + applesmc_chip = kzalloc_obj(*applesmc_chip, GFP_KERNEL);
1513 1508 if (!applesmc_chip) {
1514 1509 ret = -ENOMEM;
1515 1510 goto out_info;
@@ -1519,9 +1514,10 @@ static int __init applesmc_init(void)
1519 1514 applesmc_chip->info = applesmc_info_arr;
1520 1515
1521 1516 /* Create non-standard fanX_safe attributes group */
1522 - fan_safe_attrs = kzalloc_objs(*fan_safe_attrs, smcreg.fan_count);
1523 - fan_safe_attr_list = kzalloc_objs(*fan_safe_attr_list,
1524 - 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);
1525 1521 if (!fan_safe_attrs || !fan_safe_attr_list) {
1526 1522 ret = -ENOMEM;
1527 1523 goto out_info;
modified drivers/hwmon/aspeed-pwm-tacho.c
@@ -934,9 +934,7 @@ static int aspeed_pwm_tacho_probe(struct platform_device *pdev)
934 934 "missing or invalid reset controller device tree entry");
935 935 return PTR_ERR(priv->rst);
936 936 }
937 - ret = reset_control_deassert(priv->rst);
938 - if (ret)
939 - return ret;
937 + reset_control_deassert(priv->rst);
940 938
941 939 ret = devm_add_action_or_reset(dev, aspeed_pwm_tacho_remove, priv);
942 940 if (ret)
modified drivers/hwmon/asus_rog_ryujin.c
@@ -184,7 +184,6 @@ static int rog_ryujin_write_expanded(struct rog_ryujin_data *priv, const u8 *cmd
184 184 static int rog_ryujin_execute_cmd(struct rog_ryujin_data *priv, const u8 *cmd, int cmd_length,
185 185 struct completion *status_completion)
186 186 {
187 - unsigned long flags;
188 187 int ret;
189 188
190 189 /*
@@ -192,9 +191,9 @@ static int rog_ryujin_execute_cmd(struct rog_ryujin_data *priv, const u8 *cmd, i
192 191 * completion. Reinit is done because hidraw could have triggered
193 192 * the raw event parsing and marked the passed in completion as done.
194 193 */
195 - spin_lock_irqsave(&priv->status_report_request_lock, flags);
194 + spin_lock_bh(&priv->status_report_request_lock);
196 195 reinit_completion(status_completion);
197 - spin_unlock_irqrestore(&priv->status_report_request_lock, flags);
196 + spin_unlock_bh(&priv->status_report_request_lock);
198 197
199 198 /* Send command for getting data */
200 199 ret = rog_ryujin_write_expanded(priv, cmd, cmd_length);
@@ -422,19 +421,11 @@ static int rog_ryujin_raw_event(struct hid_device *hdev, struct hid_report *repo
422 421 int size)
423 422 {
424 423 struct rog_ryujin_data *priv = hid_get_drvdata(hdev);
425 - unsigned long flags;
426 424
427 - if (size < 2 || data[0] != RYUJIN_CMD_PREFIX)
425 + if (data[0] != RYUJIN_CMD_PREFIX)
428 426 return 0;
429 427
430 - spin_lock_irqsave(&priv->status_report_request_lock, flags);
431 -
432 428 if (data[1] == RYUJIN_GET_COOLER_STATUS_CMD_RESPONSE) {
433 - if (size <= priv->info->temp_offset + 1 ||
434 - size <= priv->info->pump_speed_offset + 1 ||
435 - size <= priv->info->fan_speed_offset + 1)
436 - goto unlock;
437 -
438 429 /* Received coolant temp and speeds of pump and internal fan */
439 430 priv->temp_input[0] = data[priv->info->temp_offset] * 1000 +
440 431 data[priv->info->temp_offset + 1] * 100;
@@ -446,9 +437,6 @@ static int rog_ryujin_raw_event(struct hid_device *hdev, struct hid_report *repo
446 437 if (!completion_done(&priv->cooler_status_received))
447 438 complete_all(&priv->cooler_status_received);
448 439 } else if (data[1] == RYUJIN_GET_CONTROLLER_SPEED_CMD_RESPONSE) {
449 - if (size <= RYUJIN_CONTROLLER_SPEED_3 + 1)
450 - goto unlock;
451 -
452 440 /* Received speeds of four fans attached to the controller */
453 441 priv->speed_input[2] = get_unaligned_le16(data + RYUJIN_CONTROLLER_SPEED_1);
454 442 priv->speed_input[3] = get_unaligned_le16(data + RYUJIN_CONTROLLER_SPEED_2);
@@ -458,9 +446,6 @@ static int rog_ryujin_raw_event(struct hid_device *hdev, struct hid_report *repo
458 446 if (!completion_done(&priv->controller_status_received))
459 447 complete_all(&priv->controller_status_received);
460 448 } else if (data[1] == RYUJIN_GET_COOLER_DUTY_CMD_RESPONSE) {
461 - if (size <= RYUJIN_INTERNAL_FAN_DUTY)
462 - goto unlock;
463 -
464 449 /* Received report for pump and internal fan duties (in %) */
465 450 if (data[RYUJIN_PUMP_DUTY] == 0 && data[RYUJIN_INTERNAL_FAN_DUTY] == 0) {
466 451 /*
@@ -478,7 +463,7 @@ static int rog_ryujin_raw_event(struct hid_device *hdev, struct hid_report *repo
478 463 * We're expecting a report, so parse it.
479 464 */
480 465 goto read_cooler_duty;
481 - goto unlock;
466 + return 0;
482 467 }
483 468 read_cooler_duty:
484 469 priv->duty_input[0] = rog_ryujin_percent_to_pwm(data[RYUJIN_PUMP_DUTY]);
@@ -487,9 +472,6 @@ read_cooler_duty:
487 472 if (!completion_done(&priv->cooler_duty_received))
488 473 complete_all(&priv->cooler_duty_received);
489 474 } else if (data[1] == RYUJIN_GET_CONTROLLER_DUTY_CMD_RESPONSE) {
490 - if (size <= RYUJIN_CONTROLLER_DUTY)
491 - goto unlock;
492 -
493 475 /* Received report for controller duty for fans (in PWM) */
494 476 if (data[RYUJIN_CONTROLLER_DUTY] == 0) {
495 477 /*
@@ -507,7 +489,7 @@ read_cooler_duty:
507 489 * We're expecting a report, so parse it.
508 490 */
509 491 goto read_controller_duty;
510 - goto unlock;
492 + return 0;
511 493 }
512 494 read_controller_duty:
513 495 priv->duty_input[2] = data[RYUJIN_CONTROLLER_DUTY];
@@ -516,8 +498,6 @@ read_controller_duty:
516 498 complete_all(&priv->controller_duty_received);
517 499 }
518 500
519 - unlock:
520 - spin_unlock_irqrestore(&priv->status_report_request_lock, flags);
521 501 return 0;
522 502 }
523 503
modified drivers/hwmon/chipcap2.c
@@ -92,6 +92,11 @@ struct cc2_data {
92 92 bool process_irqs;
93 93 };
94 94
95 + enum cc2_chan_addr {
96 + CC2_CHAN_TEMP = 0,
97 + CC2_CHAN_HUMIDITY,
98 + };
99 +
95 100 /* %RH as a per cent mille from a register value */
96 101 static long cc2_rh_convert(u16 data)
97 102 {
@@ -494,7 +499,7 @@ static irqreturn_t cc2_low_interrupt(int irq, void *data)
494 499
495 500 if (cc2->process_irqs) {
496 501 hwmon_notify_event(cc2->hwmon, hwmon_humidity,
497 - hwmon_humidity_min_alarm, 0);
502 + hwmon_humidity_min_alarm, CC2_CHAN_HUMIDITY);
498 503 cc2->rh_alarm.low_alarm = true;
499 504 }
500 505
@@ -507,7 +512,7 @@ static irqreturn_t cc2_high_interrupt(int irq, void *data)
507 512
508 513 if (cc2->process_irqs) {
509 514 hwmon_notify_event(cc2->hwmon, hwmon_humidity,
510 - hwmon_humidity_max_alarm, 0);
515 + hwmon_humidity_max_alarm, CC2_CHAN_HUMIDITY);
511 516 cc2->rh_alarm.high_alarm = true;
512 517 }
513 518
modified drivers/hwmon/corsair-cpro.c
@@ -566,18 +566,21 @@ static int bootloader_show(struct seq_file *seqf, void *unused)
566 566 }
567 567 DEFINE_SHOW_ATTRIBUTE(bootloader);
568 568
569 - static void ccp_debugfs_init(struct ccp_device *ccp, bool fw_valid, bool bl_valid)
569 + static void ccp_debugfs_init(struct ccp_device *ccp)
570 570 {
571 571 char name[32];
572 + int ret;
572 573
573 574 scnprintf(name, sizeof(name), "corsaircpro-%s", dev_name(&ccp->hdev->dev));
574 575 ccp->debugfs = debugfs_create_dir(name, NULL);
575 576
576 - if (fw_valid)
577 + ret = get_fw_version(ccp);
578 + if (!ret)
577 579 debugfs_create_file("firmware_version", 0444,
578 580 ccp->debugfs, ccp, &firmware_fops);
579 581
580 - if (bl_valid)
582 + ret = get_bl_version(ccp);
583 + if (!ret)
581 584 debugfs_create_file("bootloader_version", 0444,
582 585 ccp->debugfs, ccp, &bootloader_fops);
583 586 }
@@ -585,7 +588,6 @@ static void ccp_debugfs_init(struct ccp_device *ccp, bool fw_valid, bool bl_vali
585 588 static int ccp_probe(struct hid_device *hdev, const struct hid_device_id *id)
586 589 {
587 590 struct ccp_device *ccp;
588 - bool fw_valid, bl_valid;
589 591 int ret;
590 592
591 593 ccp = devm_kzalloc(&hdev->dev, sizeof(*ccp), GFP_KERNEL);
@@ -630,27 +632,17 @@ static int ccp_probe(struct hid_device *hdev, const struct hid_device_id *id)
630 632 if (ret)
631 633 goto out_hw_close;
632 634
633 - /*
634 - * Query the versions before registering the hwmon device: they send
635 - * USB commands without holding ccp->mutex, which is only safe while
636 - * nothing else can call send_usb_cmd().
637 - */
638 - fw_valid = !get_fw_version(ccp);
639 - bl_valid = !get_bl_version(ccp);
635 + ccp_debugfs_init(ccp);
640 636
641 637 ccp->hwmon_dev = hwmon_device_register_with_info(&hdev->dev, "corsaircpro",
642 638 ccp, &ccp_chip_info, NULL);
643 639 if (IS_ERR(ccp->hwmon_dev)) {
644 640 ret = PTR_ERR(ccp->hwmon_dev);
645 - goto out_debugfs_remove;
641 + goto out_hw_close;
646 642 }
647 643
648 - ccp_debugfs_init(ccp, fw_valid, bl_valid);
649 -
650 644 return 0;
651 645
652 - out_debugfs_remove:
653 - debugfs_remove_recursive(ccp->debugfs);
654 646 out_hw_close:
655 647 hid_hw_close(hdev);
656 648 hid_device_io_stop(hdev);
modified drivers/hwmon/gpio-fan.c
@@ -12,7 +12,6 @@
12 12 #include <linux/slab.h>
13 13 #include <linux/interrupt.h>
14 14 #include <linux/irq.h>
15 - #include <linux/devm-helpers.h>
16 15 #include <linux/platform_device.h>
17 16 #include <linux/err.h>
18 17 #include <linux/kstrtox.h>
@@ -85,7 +84,6 @@ static DEVICE_ATTR_RO(fan1_alarm);
85 84 static int fan_alarm_init(struct gpio_fan_data *fan_data)
86 85 {
87 86 int alarm_irq;
88 - int err;
89 87 struct device *dev = fan_data->dev;
90 88
91 89 /*
@@ -96,11 +94,7 @@ static int fan_alarm_init(struct gpio_fan_data *fan_data)
96 94 if (alarm_irq <= 0)
97 95 return 0;
98 96
99 - err = devm_work_autocancel(dev, &fan_data->alarm_work,
100 - fan_alarm_notify);
101 - if (err)
102 - return err;
103 -
97 + INIT_WORK(&fan_data->alarm_work, fan_alarm_notify);
104 98 irq_set_irq_type(alarm_irq, IRQ_TYPE_EDGE_BOTH);
105 99 return devm_request_irq(dev, alarm_irq, fan_alarm_irq_handler,
106 100 IRQF_SHARED, "GPIO fan alarm", fan_data);
@@ -612,11 +606,8 @@ static void gpio_fan_shutdown(struct platform_device *pdev)
612 606 {
613 607 struct gpio_fan_data *fan_data = platform_get_drvdata(pdev);
614 608
615 - if (fan_data->gpios) {
616 - mutex_lock(&fan_data->lock);
609 + if (fan_data->gpios)
617 610 set_fan_speed(fan_data, 0);
618 - mutex_unlock(&fan_data->lock);
619 - }
620 611 }
621 612
622 613 static int gpio_fan_runtime_suspend(struct device *dev)
modified drivers/hwmon/hwmon.c
@@ -318,11 +318,6 @@ static int hwmon_attr_base(enum hwmon_sensor_types type)
318 318 return 1;
319 319 }
320 320
321 - static bool is_hwmon_device(struct device *dev)
322 - {
323 - return dev->class == &hwmon_class;
324 - }
325 -
326 321 #if IS_REACHABLE(CONFIG_I2C)
327 322
328 323 /*
@@ -343,7 +338,7 @@ static bool is_hwmon_device(struct device *dev)
343 338
344 339 static int hwmon_match_device(struct device *dev, const void *data)
345 340 {
346 - return is_hwmon_device(dev);
341 + return dev->class == &hwmon_class;
347 342 }
348 343
349 344 static ssize_t pec_show(struct device *dev, const struct device_attribute *dummy,
@@ -376,17 +371,18 @@ static ssize_t pec_store(struct device *dev, const struct device_attribute *deva
376 371 * handling is not required.
377 372 */
378 373 hwdev = to_hwmon_device(hdev);
379 - scoped_guard(mutex, &hwdev->lock) {
380 - if (hwdev->chip->ops->write) {
381 - err = hwdev->chip->ops->write(hdev, hwmon_chip, hwmon_chip_pec, 0, val);
382 - if (err && err != -EOPNOTSUPP)
383 - goto put;
384 - }
385 - if (!val)
386 - client->flags &= ~I2C_CLIENT_PEC;
387 - else
388 - client->flags |= I2C_CLIENT_PEC;
374 + guard(mutex)(&hwdev->lock);
375 + if (hwdev->chip->ops->write) {
376 + err = hwdev->chip->ops->write(hdev, hwmon_chip, hwmon_chip_pec, 0, val);
377 + if (err && err != -EOPNOTSUPP)
378 + goto put;
389 379 }
380 +
381 + if (!val)
382 + client->flags &= ~I2C_CLIENT_PEC;
383 + else
384 + client->flags |= I2C_CLIENT_PEC;
385 +
390 386 err = count;
391 387 put:
392 388 put_device(hdev);
@@ -786,9 +782,6 @@ int hwmon_notify_event(struct device *dev, enum hwmon_sensor_types type,
786 782 const char *template;
787 783 int base;
788 784
789 - if (WARN(!is_hwmon_device(dev), "%s is not a hardware monitoring device\n",
790 - dev_name(dev)))
791 - return -EINVAL;
792 785 if (type >= ARRAY_SIZE(__templates))
793 786 return -EINVAL;
794 787 if (attr >= __templates_size[type])
modified drivers/hwmon/ina2xx.c
@@ -8,7 +8,6 @@
8 8 */
9 9
10 10 #include <linux/bitfield.h>
11 - #include <linux/bitops.h>
12 11 #include <linux/bits.h>
13 12 #include <linux/delay.h>
14 13 #include <linux/device.h>
@@ -130,17 +129,6 @@ enum ina2xx_ids {
130 129 sy24655
131 130 };
132 131
133 - enum ina2xx_alert_type {
134 - INA2XX_ALERT_NONE,
135 - INA2XX_ALERT_CURRENT_LOW,
136 - INA2XX_ALERT_CURRENT_HIGH,
137 - INA2XX_ALERT_POWER_HIGH,
138 - INA2XX_ALERT_BUS_VOLTAGE_LOW,
139 - INA2XX_ALERT_BUS_VOLTAGE_HIGH,
140 - INA2XX_ALERT_SHUNT_VOLTAGE_LOW,
141 - INA2XX_ALERT_SHUNT_VOLTAGE_HIGH,
142 - };
143 -
144 132 struct ina2xx_config {
145 133 u16 config_default;
146 134 bool has_alerts; /* chip supports alerts and limits */
@@ -160,7 +148,6 @@ struct ina2xx_data {
160 148 const struct ina2xx_config *config;
161 149 enum ina2xx_ids chip;
162 150
163 - enum ina2xx_alert_type active_alert;
164 151 long rshunt;
165 152 long current_lsb_uA;
166 153 long power_lsb_uW;
@@ -441,78 +428,16 @@ static u16 ina226_alert_to_reg(struct ina2xx_data *data, int reg, long val)
441 428 }
442 429 }
443 430
444 - static u32 ina2xx_alert_type_to_mask(enum ina2xx_alert_type alert)
445 - {
446 - switch (alert) {
447 - case INA2XX_ALERT_CURRENT_LOW:
448 - case INA2XX_ALERT_SHUNT_VOLTAGE_LOW:
449 - return INA226_SHUNT_UNDER_VOLTAGE_MASK;
450 - case INA2XX_ALERT_CURRENT_HIGH:
451 - case INA2XX_ALERT_SHUNT_VOLTAGE_HIGH:
452 - return INA226_SHUNT_OVER_VOLTAGE_MASK;
453 - case INA2XX_ALERT_BUS_VOLTAGE_LOW:
454 - return INA226_BUS_UNDER_VOLTAGE_MASK;
455 - case INA2XX_ALERT_BUS_VOLTAGE_HIGH:
456 - return INA226_BUS_OVER_VOLTAGE_MASK;
457 - case INA2XX_ALERT_POWER_HIGH:
458 - return INA226_POWER_OVER_LIMIT_MASK;
459 - case INA2XX_ALERT_NONE:
460 - return 0;
461 - default:
462 - /* programmer error */
463 - WARN_ON_ONCE(1);
464 - return 0;
465 - }
466 - }
467 -
468 - static enum ina2xx_alert_type ina2xx_mask_to_alert_type(u32 mask)
469 - {
470 - int top_bit = fls(mask & INA226_ALERT_CONFIG_MASK);
471 -
472 - if (!top_bit)
473 - return INA2XX_ALERT_NONE;
474 -
475 - /*
476 - * Multiple bits may be set, with the highest-set function taking
477 - * precedence according to the datasheet. Shunt voltage masks are
478 - * assumed to map to voltage monitoring rather than current monitoring,
479 - * since the latter isn't directly implemented in the hardware.
480 - */
481 - switch (BIT(top_bit - 1)) {
482 - case INA226_SHUNT_OVER_VOLTAGE_MASK:
483 - return INA2XX_ALERT_SHUNT_VOLTAGE_HIGH;
484 - case INA226_SHUNT_UNDER_VOLTAGE_MASK:
485 - return INA2XX_ALERT_SHUNT_VOLTAGE_LOW;
486 - case INA226_BUS_OVER_VOLTAGE_MASK:
487 - return INA2XX_ALERT_BUS_VOLTAGE_HIGH;
488 - case INA226_BUS_UNDER_VOLTAGE_MASK:
489 - return INA2XX_ALERT_BUS_VOLTAGE_LOW;
490 - case INA226_POWER_OVER_LIMIT_MASK:
491 - return INA2XX_ALERT_POWER_HIGH;
492 - default:
493 - return INA2XX_ALERT_NONE;
494 - }
495 - }
496 -
497 - static int ina226_alert_limit_read(struct ina2xx_data *data, enum ina2xx_alert_type alert,
498 - int reg, long *val)
431 + static int ina226_alert_limit_read(struct ina2xx_data *data, u32 mask, int reg, long *val)
499 432 {
500 433 struct regmap *regmap = data->regmap;
501 434 int regval;
502 - u32 mask;
503 435 int ret;
504 436
505 - /* Avoid nonzero reads from inactive alerts caused by shared limit register */
506 - if (data->active_alert != alert) {
507 - *val = 0;
508 - return 0;
509 - }
510 -
511 437 ret = regmap_read(regmap, INA226_MASK_ENABLE, &regval);
512 438 if (ret)
513 439 return ret;
514 440
515 - mask = ina2xx_alert_type_to_mask(alert);
516 441 if (regval & mask) {
517 442 ret = regmap_read(regmap, INA226_ALERT_LIMIT, &regval);
518 443 if (ret)
@@ -524,11 +449,9 @@ static int ina226_alert_limit_read(struct ina2xx_data *data, enum ina2xx_alert_t
524 449 return 0;
525 450 }
526 451
527 - static int ina226_alert_limit_write(struct ina2xx_data *data, enum ina2xx_alert_type alert,
528 - int reg, long val)
452 + static int ina226_alert_limit_write(struct ina2xx_data *data, u32 mask, int reg, long val)
529 453 {
530 454 struct regmap *regmap = data->regmap;
531 - u32 mask;
532 455 int ret;
533 456
534 457 if (val < 0)
@@ -543,22 +466,15 @@ static int ina226_alert_limit_write(struct ina2xx_data *data, enum ina2xx_alert_
543 466 INA226_ALERT_CONFIG_MASK, 0);
544 467 if (ret < 0)
545 468 return ret;
546 - data->active_alert = INA2XX_ALERT_NONE;
547 469
548 470 ret = regmap_write(regmap, INA226_ALERT_LIMIT,
549 471 ina226_alert_to_reg(data, reg, val));
550 472 if (ret < 0)
551 473 return ret;
552 474
553 - if (val) {
554 - mask = ina2xx_alert_type_to_mask(alert);
555 - ret = regmap_update_bits(regmap, INA226_MASK_ENABLE,
556 - INA226_ALERT_CONFIG_MASK, mask);
557 - if (ret < 0)
558 - return ret;
559 - data->active_alert = alert;
560 - }
561 -
475 + if (val)
476 + return regmap_update_bits(regmap, INA226_MASK_ENABLE,
477 + INA226_ALERT_CONFIG_MASK, mask);
562 478 return 0;
563 479 }
564 480
@@ -582,26 +498,15 @@ static int ina2xx_chip_read(struct device *dev, u32 attr, long *val)
582 498 return 0;
583 499 }
584 500
585 - static int ina226_alert_read(struct ina2xx_data *data, enum ina2xx_alert_type alert, long *val)
501 + static int ina226_alert_read(struct regmap *regmap, u32 mask, long *val)
586 502 {
587 503 unsigned int regval;
588 - u32 mask;
589 504 int ret;
590 505
591 - /*
592 - * With alert latching, reading alerts from hardware also clears the
593 - * alert, so return early if the alert is inactive.
594 - */
595 - if (data->active_alert != alert) {
596 - *val = 0;
597 - return 0;
598 - }
599 -
600 - ret = regmap_read_bypassed(data->regmap, INA226_MASK_ENABLE, &regval);
506 + ret = regmap_read_bypassed(regmap, INA226_MASK_ENABLE, &regval);
601 507 if (ret)
602 508 return ret;
603 509
604 - mask = ina2xx_alert_type_to_mask(alert);
605 510 *val = (regval & mask) && (regval & INA226_ALERT_FUNCTION_FLAG);
606 511
607 512 return 0;
@@ -610,10 +515,10 @@ static int ina226_alert_read(struct ina2xx_data *data, enum ina2xx_alert_type al
610 515 static int ina2xx_in_read(struct device *dev, u32 attr, int channel, long *val)
611 516 {
612 517 int voltage_reg = channel ? INA2XX_BUS_VOLTAGE : INA2XX_SHUNT_VOLTAGE;
613 - enum ina2xx_alert_type under_voltage_alert = channel ? INA2XX_ALERT_BUS_VOLTAGE_LOW
614 - : INA2XX_ALERT_SHUNT_VOLTAGE_LOW;
615 - enum ina2xx_alert_type over_voltage_alert = channel ? INA2XX_ALERT_BUS_VOLTAGE_HIGH
616 - : INA2XX_ALERT_SHUNT_VOLTAGE_HIGH;
518 + u32 under_voltage_mask = channel ? INA226_BUS_UNDER_VOLTAGE_MASK
519 + : INA226_SHUNT_UNDER_VOLTAGE_MASK;
520 + u32 over_voltage_mask = channel ? INA226_BUS_OVER_VOLTAGE_MASK
521 + : INA226_SHUNT_OVER_VOLTAGE_MASK;
617 522 struct ina2xx_data *data = dev_get_drvdata(dev);
618 523 struct regmap *regmap = data->regmap;
619 524 unsigned int regval;
@@ -627,15 +532,15 @@ static int ina2xx_in_read(struct device *dev, u32 attr, int channel, long *val)
627 532 *val = ina2xx_get_value(data, voltage_reg, regval);
628 533 break;
629 534 case hwmon_in_lcrit:
630 - return ina226_alert_limit_read(data, under_voltage_alert,
535 + return ina226_alert_limit_read(data, under_voltage_mask,
631 536 voltage_reg, val);
632 537 case hwmon_in_crit:
633 - return ina226_alert_limit_read(data, over_voltage_alert,
538 + return ina226_alert_limit_read(data, over_voltage_mask,
634 539 voltage_reg, val);
635 540 case hwmon_in_lcrit_alarm:
636 - return ina226_alert_read(data, under_voltage_alert, val);
541 + return ina226_alert_read(regmap, under_voltage_mask, val);
637 542 case hwmon_in_crit_alarm:
638 - return ina226_alert_read(data, over_voltage_alert, val);
543 + return ina226_alert_read(regmap, over_voltage_mask, val);
639 544 default:
640 545 return -EOPNOTSUPP;
641 546 }
@@ -689,10 +594,10 @@ static int ina2xx_power_read(struct device *dev, u32 attr, long *val)
689 594 case hwmon_power_average:
690 595 return sy24655_average_power_read(data, SY24655_EIN, val);
691 596 case hwmon_power_crit:
692 - return ina226_alert_limit_read(data, INA2XX_ALERT_POWER_HIGH,
597 + return ina226_alert_limit_read(data, INA226_POWER_OVER_LIMIT_MASK,
693 598 INA2XX_POWER, val);
694 599 case hwmon_power_crit_alarm:
695 - return ina226_alert_read(data, INA2XX_ALERT_POWER_HIGH, val);
600 + return ina226_alert_read(data->regmap, INA226_POWER_OVER_LIMIT_MASK, val);
696 601 default:
697 602 return -EOPNOTSUPP;
698 603 }
@@ -728,15 +633,15 @@ static int ina2xx_curr_read(struct device *dev, u32 attr, long *val)
728 633 *val = ina2xx_get_value(data, INA2XX_CURRENT, regval);
729 634 return 0;
730 635 case hwmon_curr_lcrit:
731 - return ina226_alert_limit_read(data, INA2XX_ALERT_CURRENT_LOW,
636 + return ina226_alert_limit_read(data, INA226_SHUNT_UNDER_VOLTAGE_MASK,
732 637 INA2XX_CURRENT, val);
733 638 case hwmon_curr_crit:
734 - return ina226_alert_limit_read(data, INA2XX_ALERT_CURRENT_HIGH,
639 + return ina226_alert_limit_read(data, INA226_SHUNT_OVER_VOLTAGE_MASK,
735 640 INA2XX_CURRENT, val);
736 641 case hwmon_curr_lcrit_alarm:
737 - return ina226_alert_read(data, INA2XX_ALERT_CURRENT_LOW, val);
642 + return ina226_alert_read(regmap, INA226_SHUNT_UNDER_VOLTAGE_MASK, val);
738 643 case hwmon_curr_crit_alarm:
739 - return ina226_alert_read(data, INA2XX_ALERT_CURRENT_HIGH, val);
644 + return ina226_alert_read(regmap, INA226_SHUNT_OVER_VOLTAGE_MASK, val);
740 645 default:
741 646 return -EOPNOTSUPP;
742 647 }
@@ -780,12 +685,12 @@ static int ina2xx_in_write(struct device *dev, u32 attr, int channel, long val)
780 685 switch (attr) {
781 686 case hwmon_in_lcrit:
782 687 return ina226_alert_limit_write(data,
783 - channel ? INA2XX_ALERT_BUS_VOLTAGE_LOW : INA2XX_ALERT_SHUNT_VOLTAGE_LOW,
688 + channel ? INA226_BUS_UNDER_VOLTAGE_MASK : INA226_SHUNT_UNDER_VOLTAGE_MASK,
784 689 channel ? INA2XX_BUS_VOLTAGE : INA2XX_SHUNT_VOLTAGE,
785 690 val);
786 691 case hwmon_in_crit:
787 692 return ina226_alert_limit_write(data,
788 - channel ? INA2XX_ALERT_BUS_VOLTAGE_HIGH : INA2XX_ALERT_SHUNT_VOLTAGE_HIGH,
693 + channel ? INA226_BUS_OVER_VOLTAGE_MASK : INA226_SHUNT_OVER_VOLTAGE_MASK,
789 694 channel ? INA2XX_BUS_VOLTAGE : INA2XX_SHUNT_VOLTAGE,
790 695 val);
791 696 default:
@@ -800,7 +705,7 @@ static int ina2xx_power_write(struct device *dev, u32 attr, long val)
800 705
801 706 switch (attr) {
802 707 case hwmon_power_crit:
803 - return ina226_alert_limit_write(data, INA2XX_ALERT_POWER_HIGH,
708 + return ina226_alert_limit_write(data, INA226_POWER_OVER_LIMIT_MASK,
804 709 INA2XX_POWER, val);
805 710 default:
806 711 return -EOPNOTSUPP;
@@ -814,10 +719,10 @@ static int ina2xx_curr_write(struct device *dev, u32 attr, long val)
814 719
815 720 switch (attr) {
816 721 case hwmon_curr_lcrit:
817 - return ina226_alert_limit_write(data, INA2XX_ALERT_CURRENT_LOW,
722 + return ina226_alert_limit_write(data, INA226_SHUNT_UNDER_VOLTAGE_MASK,
818 723 INA2XX_CURRENT, val);
819 724 case hwmon_curr_crit:
820 - return ina226_alert_limit_write(data, INA2XX_ALERT_CURRENT_HIGH,
725 + return ina226_alert_limit_write(data, INA226_SHUNT_OVER_VOLTAGE_MASK,
821 726 INA2XX_CURRENT, val);
822 727 default:
823 728 return -EOPNOTSUPP;
@@ -978,12 +883,8 @@ static ssize_t shunt_resistor_show(struct device *dev,
978 883 struct device_attribute *da, char *buf)
979 884 {
980 885 struct ina2xx_data *data = dev_get_drvdata(dev);
981 - long rshunt;
982 886
983 - scoped_guard(hwmon_lock, dev) {
984 - rshunt = data->rshunt;
985 - }
986 - return sysfs_emit(buf, "%li\n", rshunt);
887 + return sysfs_emit(buf, "%li\n", data->rshunt);
987 888 }
988 889
989 890 static ssize_t shunt_resistor_store(struct device *dev,
@@ -1039,16 +940,6 @@ static int ina2xx_init(struct device *dev, struct ina2xx_data *data)
1039 940
1040 941 if (data->config->has_alerts) {
1041 942 bool active_high = device_property_read_bool(dev, "ti,alert-polarity-active-high");
1042 - unsigned int mask_enable;
1043 -
1044 - /*
1045 - * Infer active alert from MASK_ENABLE in case it's already
1046 - * configured (e.g., by a past probe or firmware)
1047 - */
1048 - ret = regmap_read(regmap, INA226_MASK_ENABLE, &mask_enable);
1049 - if (ret < 0)
1050 - return ret;
1051 - data->active_alert = ina2xx_mask_to_alert_type(mask_enable);
1052 943
1053 944 regmap_update_bits(regmap, INA226_MASK_ENABLE,
1054 945 INA226_ALERT_LATCH_ENABLE | INA226_ALERT_POLARITY,
modified drivers/hwmon/ltc4282.c
@@ -1106,7 +1106,7 @@ static const struct clk_ops ltc4282_ops = {
1106 1106 static int ltc428_clk_provider_setup(struct ltc4282_state *st,
1107 1107 struct device *dev)
1108 1108 {
1109 - struct clk_init_data init = {};
1109 + struct clk_init_data init;
1110 1110 int ret;
1111 1111
1112 1112 if (!IS_ENABLED(CONFIG_COMMON_CLK))
modified drivers/hwmon/mcp9982.c
@@ -395,8 +395,6 @@ static int mcp9982_read(struct device *dev, enum hwmon_sensor_types type, u32 at
395 395 reg_status, !(reg_status & MCP9982_STATUS_BUSY),
396 396 MCP9982_WAKE_UP_TIME_US,
397 397 MCP9982_WAKE_UP_TIME_US * 10);
398 - if (ret)
399 - return ret;
400 398 break;
401 399 }
402 400 break;
modified drivers/hwmon/nct6694-hwmon.c
@@ -159,9 +159,6 @@ static inline s8 temp_to_reg(long val)
159 159 #define NCT6694_HWMON_TEMP_CONFIG (HWMON_T_INPUT | HWMON_T_ENABLE | \
160 160 HWMON_T_MAX | HWMON_T_MAX_HYST | \
161 161 HWMON_T_MAX_ALARM)
162 - #define NCT6694_HWMON_DTIN_CONFIG (HWMON_T_INPUT | \
163 - HWMON_T_MAX | HWMON_T_MAX_HYST | \
164 - HWMON_T_MAX_ALARM)
165 162 #define NCT6694_HWMON_FAN_CONFIG (HWMON_F_INPUT | HWMON_F_ENABLE | \
166 163 HWMON_F_MIN | HWMON_F_MIN_ALARM)
167 164 #define NCT6694_HWMON_PWM_CONFIG (HWMON_PWM_INPUT | HWMON_PWM_ENABLE | \
@@ -196,22 +193,22 @@ static const struct hwmon_channel_info *nct6694_info[] = {
196 193 NCT6694_HWMON_TEMP_CONFIG, /* TDP2 */
197 194 NCT6694_HWMON_TEMP_CONFIG, /* TDP3 */
198 195 NCT6694_HWMON_TEMP_CONFIG, /* TDP4 */
199 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN0 */
200 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN1 */
201 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN2 */
202 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN3 */
203 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN4 */
204 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN5 */
205 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN6 */
206 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN7 */
207 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN8 */
208 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN9 */
209 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN10 */
210 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN11 */
211 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN12 */
212 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN13 */
213 - NCT6694_HWMON_DTIN_CONFIG, /* DTIN14 */
214 - NCT6694_HWMON_DTIN_CONFIG), /* DTIN15 */
196 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN0 */
197 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN1 */
198 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN2 */
199 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN3 */
200 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN4 */
201 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN5 */
202 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN6 */
203 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN7 */
204 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN8 */
205 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN9 */
206 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN10 */
207 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN11 */
208 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN12 */
209 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN13 */
210 + NCT6694_HWMON_TEMP_CONFIG, /* DTIN14 */
211 + NCT6694_HWMON_TEMP_CONFIG), /* DTIN15 */
215 212
216 213 HWMON_CHANNEL_INFO(fan,
217 214 NCT6694_HWMON_FAN_CONFIG, /* FIN0 */
modified drivers/hwmon/pmbus/pmbus_core.c
@@ -1275,9 +1275,7 @@ static int pmbus_get_boolean(struct i2c_client *client, struct pmbus_boolean *b,
1275 1275
1276 1276 regval = status & mask;
1277 1277 if (regval) {
1278 - /* Generic STATUS_WORD alarms are not individually clearable. */
1279 - if (data->revision >= PMBUS_REV_12 &&
1280 - reg != PMBUS_STATUS_WORD) {
1278 + if (data->revision >= PMBUS_REV_12) {
1281 1279 ret = _pmbus_write_byte_data(client, page, reg, regval);
1282 1280 if (ret)
1283 1281 return ret;
modified drivers/hwmon/sht4x.c
@@ -277,8 +277,6 @@ static ssize_t heater_enable_store(struct device *dev,
277 277 heating_time_bound = 1100;
278 278 }
279 279
280 - guard(hwmon_lock)(dev);
281 -
282 280 if (time_before(jiffies, data->heating_complete))
283 281 return -EBUSY;
284 282
@@ -288,7 +286,7 @@ static ssize_t heater_enable_store(struct device *dev,
288 286
289 287 data->heating_complete = jiffies + msecs_to_jiffies(heating_time_bound);
290 288 data->data_pending = true;
291 - return count;
289 + return 0;
292 290 }
293 291
294 292 static ssize_t heater_power_show(struct device *dev,
@@ -316,8 +314,6 @@ static ssize_t heater_power_store(struct device *dev,
316 314 if (power != 20 && power != 110 && power != 200)
317 315 return -EINVAL;
318 316
319 - guard(hwmon_lock)(dev);
320 -
321 317 data->heater_power = power;
322 318
323 319 return count;
@@ -348,8 +344,6 @@ static ssize_t heater_time_store(struct device *dev,
348 344 if (time != 100 && time != 1000)
349 345 return -EINVAL;
350 346
351 - guard(hwmon_lock)(dev);
352 -
353 347 data->heater_time = time;
354 348
355 349 return count;
modified drivers/hwmon/yogafan.c
@@ -1,5 +1,5 @@
1 1 // SPDX-License-Identifier: GPL-2.0-only
2 - /*
2 + /**
3 3 * yoga_fan.c - Lenovo Yoga/Legion Fan Hardware Monitoring Driver
4 4 *
5 5 * Provides fan speed monitoring for Lenovo Yoga, Legion, and IdeaPad
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/amd/amd_iommu.h
@@ -54,6 +54,9 @@ struct protection_domain *protection_domain_alloc(void);
54 54 struct iommu_domain *amd_iommu_domain_alloc_sva(struct device *dev,
55 55 struct mm_struct *mm);
56 56 void amd_iommu_domain_free(struct iommu_domain *dom);
57 + int iommu_sva_set_dev_pasid(struct iommu_domain *domain,
58 + struct device *dev, ioasid_t pasid,
59 + struct iommu_domain *old);
57 60 void amd_iommu_remove_dev_pasid(struct device *dev, ioasid_t pasid,
58 61 struct iommu_domain *domain);
59 62
modified drivers/iommu/amd/amd_iommu_types.h
@@ -39,6 +39,18 @@
39 39 #define MMIO_RANGE_OFFSET 0x0c
40 40 #define MMIO_MISC_OFFSET 0x10
41 41
42 + /* Masks, shifts and macros to parse the device range capability */
43 + #define MMIO_RANGE_LD_MASK 0xff000000
44 + #define MMIO_RANGE_FD_MASK 0x00ff0000
45 + #define MMIO_RANGE_BUS_MASK 0x0000ff00
46 + #define MMIO_RANGE_LD_SHIFT 24
47 + #define MMIO_RANGE_FD_SHIFT 16
48 + #define MMIO_RANGE_BUS_SHIFT 8
49 + #define MMIO_GET_LD(x) (((x) & MMIO_RANGE_LD_MASK) >> MMIO_RANGE_LD_SHIFT)
50 + #define MMIO_GET_FD(x) (((x) & MMIO_RANGE_FD_MASK) >> MMIO_RANGE_FD_SHIFT)
51 + #define MMIO_GET_BUS(x) (((x) & MMIO_RANGE_BUS_MASK) >> MMIO_RANGE_BUS_SHIFT)
52 + #define MMIO_MSI_NUM(x) ((x) & 0x1f)
53 +
42 54 /* Used offsets into the MMIO space */
43 55 #define MMIO_DEV_TABLE_OFFSET 0x0000
44 56 #define MMIO_CMD_BUF_OFFSET 0x0008
@@ -235,6 +247,7 @@
235 247
236 248 /* constants to configure the command buffer */
237 249 #define CMD_BUFFER_SIZE 8192
250 + #define CMD_BUFFER_UNINITIALIZED 1
238 251 #define CMD_BUFFER_ENTRIES 512
239 252 #define MMIO_CMD_SIZE_SHIFT 56
240 253 #define MMIO_CMD_SIZE_512 (0x9ULL << MMIO_CMD_SIZE_SHIFT)
@@ -421,6 +434,9 @@ struct irq_remap_table {
421 434 u32 *table;
422 435 };
423 436
437 + /* Interrupt remapping feature used? */
438 + extern bool amd_iommu_irq_remap;
439 +
424 440 extern const struct iommu_ops amd_iommu_ops;
425 441
426 442 /* IVRS indicates that pre-boot remapping was enabled */
modified drivers/iommu/amd/init.c
@@ -152,7 +152,7 @@ struct ivmd_header {
152 152 } __attribute__((packed));
153 153
154 154 bool amd_iommu_dump;
155 - static bool amd_iommu_irq_remap __read_mostly;
155 + bool amd_iommu_irq_remap __read_mostly;
156 156
157 157 enum protection_domain_mode amd_iommu_pgtable = PD_MODE_V1;
158 158 /* Virtual address size */
@@ -909,9 +909,7 @@ static void free_ga_log(struct amd_iommu *iommu)
909 909 {
910 910 #ifdef CONFIG_IRQ_REMAP
911 911 iommu_free_pages(iommu->ga_log);
912 - iommu->ga_log = NULL;
913 912 iommu_free_pages(iommu->ga_log_tail);
914 - iommu->ga_log_tail = NULL;
915 913 #endif
916 914 }
917 915
@@ -958,9 +956,6 @@ static int iommu_init_ga_log(struct amd_iommu *iommu)
958 956 if (WARN_ON_ONCE(!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir)))
959 957 return -EINVAL;
960 958
961 - if (iommu->ga_log && iommu->ga_log_tail)
962 - return 0;
963 -
964 959 iommu->ga_log = iommu_alloc_pages_node_sz(nid, GFP_KERNEL, GA_LOG_SIZE);
965 960 if (!iommu->ga_log)
966 961 goto err_out;
@@ -1922,20 +1917,19 @@ static int __init init_iommu_one(struct amd_iommu *iommu, struct ivhd_header *h,
1922 1917 else
1923 1918 iommu->mmio_phys_end = MMIO_CNTR_CONF_OFFSET;
1924 1919
1925 - if (h->efr_attr & BIT(IOMMU_IVHD_ATTR_HATDIS_SHIFT)) {
1926 - pr_warn_once("Host Address Translation is not supported.\n");
1927 - amd_iommu_hatdis = true;
1928 - }
1929 -
1930 1920 /* XT and GAM require GA mode. */
1931 1921 if ((h->efr_reg & (0x1 << IOMMU_EFR_GASUP_SHIFT)) == 0) {
1932 1922 amd_iommu_guest_ir = AMD_IOMMU_GUEST_IR_LEGACY;
1933 - break;
1934 1923 } else {
1935 1924 if (h->efr_reg & BIT(IOMMU_EFR_XTSUP_SHIFT))
1936 1925 amd_iommu_xt_mode = IRQ_REMAP_X2APIC_MODE;
1937 1926 }
1938 1927
1928 + if (h->efr_attr & BIT(IOMMU_IVHD_ATTR_HATDIS_SHIFT)) {
1929 + pr_warn_once("Host Address Translation is not supported.\n");
1930 + amd_iommu_hatdis = true;
1931 + }
1932 +
1939 1933 early_iommu_features_init(iommu, h);
1940 1934
1941 1935 break;
modified drivers/iommu/amd/iommu.c
@@ -1076,6 +1076,9 @@ static void iommu_poll_ga_log(struct amd_iommu *iommu)
1076 1076 {
1077 1077 u32 head, tail;
1078 1078
1079 + if (iommu->ga_log == NULL)
1080 + return;
1081 +
1079 1082 head = readl(iommu->mmio_base + MMIO_GA_HEAD_OFFSET);
1080 1083 tail = readl(iommu->mmio_base + MMIO_GA_TAIL_OFFSET);
1081 1084
@@ -3973,6 +3976,9 @@ static int irq_remapping_select(struct irq_domain *d, struct irq_fwspec *fwspec,
3973 3976 struct amd_iommu *iommu;
3974 3977 int devid = -1;
3975 3978
3979 + if (!amd_iommu_irq_remap)
3980 + return 0;
3981 +
3976 3982 if (x86_fwspec_is_ioapic(fwspec))
3977 3983 devid = get_ioapic_devid(fwspec->param[0]);
3978 3984 else if (x86_fwspec_is_hpet(fwspec))
modified drivers/iommu/amd/nested.c
@@ -96,7 +96,7 @@ struct iommu_domain *
96 96 amd_iommu_alloc_domain_nested(struct iommufd_viommu *viommu, u32 flags,
97 97 const struct iommu_user_data *user_data)
98 98 {
99 - int ret, hdom_id;
99 + int ret;
100 100 unsigned long irqflags;
101 101 struct nested_domain *ndom;
102 102 struct guest_domain_mapping_info *gdom_info;
@@ -161,8 +161,8 @@ amd_iommu_alloc_domain_nested(struct iommufd_viommu *viommu, u32 flags,
161 161 }
162 162
163 163 /* The gDomID does not exist. We allocate new hdom_id */
164 - hdom_id = amd_iommu_pdom_id_alloc();
165 - if (hdom_id <= 0) {
164 + gdom_info->hdom_id = amd_iommu_pdom_id_alloc();
165 + if (gdom_info->hdom_id <= 0) {
166 166 __xa_cmpxchg(&aviommu->gdomid_array,
167 167 ndom->gdom_id, gdom_info, NULL, GFP_ATOMIC);
168 168 xa_unlock_irqrestore(&aviommu->gdomid_array, irqflags);
@@ -170,7 +170,6 @@ amd_iommu_alloc_domain_nested(struct iommufd_viommu *viommu, u32 flags,
170 170 goto out_err_gdom_info;
171 171 }
172 172
173 - gdom_info->hdom_id = hdom_id;
174 173 ndom->gdom_info = gdom_info;
175 174 refcount_set(&gdom_info->users, 1);
176 175
modified drivers/iommu/amd/pasid.c
@@ -99,9 +99,9 @@ static const struct mmu_notifier_ops sva_mn = {
99 99 .release = sva_mn_release,
100 100 };
101 101
102 - static int iommu_sva_set_dev_pasid(struct iommu_domain *domain,
103 - struct device *dev, ioasid_t pasid,
104 - struct iommu_domain *old)
102 + int iommu_sva_set_dev_pasid(struct iommu_domain *domain,
103 + struct device *dev, ioasid_t pasid,
104 + struct iommu_domain *old)
105 105 {
106 106 struct pdom_dev_data *pdom_dev_data;
107 107 struct protection_domain *sva_pdom = to_pdomain(domain);
modified drivers/iommu/amd/ppr.c
@@ -165,6 +165,9 @@ void amd_iommu_poll_ppr_log(struct amd_iommu *iommu)
165 165 {
166 166 u32 head, tail;
167 167
168 + if (iommu->ppr_log == NULL)
169 + return;
170 +
168 171 head = readl(iommu->mmio_base + MMIO_PPR_HEAD_OFFSET);
169 172 tail = readl(iommu->mmio_base + MMIO_PPR_TAIL_OFFSET);
170 173
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/riscv/iommu.c
@@ -382,97 +382,78 @@ static int riscv_iommu_queue_wait(struct riscv_iommu_queue *queue,
382 382 (int)(cons - index) > 0, 0, timeout_us);
383 383 }
384 384
385 - static int riscv_iommu_queue_wait_for_space(struct riscv_iommu_queue *queue,
386 - unsigned int last)
385 + /* Enqueue an entry and wait to be processed if timeout_us > 0
386 + *
387 + * Error handling for IOMMU hardware not responding in reasonable time
388 + * will be added as separate patch series along with other RAS features.
389 + * For now, only report hardware failure and continue.
390 + */
391 + static unsigned int riscv_iommu_queue_send(struct riscv_iommu_queue *queue,
392 + void *entry, size_t entry_size)
387 393 {
394 + unsigned int prod;
388 395 unsigned int head;
389 396 unsigned int tail;
390 - unsigned int hw_head;
391 397 unsigned long flags;
392 - int ret;
393 398
394 - ret = riscv_iommu_readl_timeout(queue->iommu, Q_HEAD(queue), hw_head,
395 - !(hw_head & ~queue->mask) && hw_head != last,
396 - 0, RISCV_IOMMU_QUEUE_TIMEOUT);
397 - if (ret)
398 - return ret;
399 + /* Do not preempt submission flow. */
400 + local_irq_save(flags);
399 401
400 - raw_spin_lock_irqsave(&queue->lock, flags);
402 + /* 1. Allocate some space in the queue */
403 + prod = atomic_inc_return(&queue->prod) - 1;
401 404 head = atomic_read(&queue->head);
402 - tail = atomic_read(&queue->tail);
403 - if ((tail - head) >= queue->mask) {
404 - last = Q_ITEM(queue, head);
405 - /*
406 - * Re-read hw_head under the lock so that it is consistent with
407 - * the freshly computed 'last'. Using the pre-lock snapshot
408 - * could produce a stale value that wraps around relative to the
409 - * new 'last', advancing the shadow head past entries that have
410 - * not yet been consumed by the hardware.
411 - */
412 - hw_head = riscv_iommu_readl(queue->iommu, Q_HEAD(queue));
413 - if (!(hw_head & ~queue->mask) && hw_head != last)
414 - atomic_add((hw_head - last) & queue->mask, &queue->head);
415 - }
416 - raw_spin_unlock_irqrestore(&queue->lock, flags);
417 -
418 - return 0;
419 - }
420 -
421 - /* Enqueue an entry and publish it to the hardware queue. */
422 - static int riscv_iommu_queue_send(struct riscv_iommu_queue *queue,
423 - void *entry, size_t entry_size,
424 - unsigned int *out_prod)
425 - {
426 - unsigned int prod;
427 - unsigned int head;
428 - unsigned long flags;
429 - int ret;
430 -
431 - /* 1. Wait for space availability and reserve the next slot. */
432 - for (;;) {
433 - raw_spin_lock_irqsave(&queue->lock, flags);
434 -
435 - prod = atomic_read(&queue->tail);
436 - head = atomic_read(&queue->head);
437 405
438 - if ((prod - head) < queue->mask)
439 - break;
440 -
441 - head = Q_ITEM(queue, head);
442 - raw_spin_unlock_irqrestore(&queue->lock, flags);
406 + /* 2. Wait for space availability. */
407 + if ((prod - head) > queue->mask) {
408 + if (readx_poll_timeout(atomic_read, &queue->head,
409 + head, (prod - head) < queue->mask,
410 + 0, RISCV_IOMMU_QUEUE_TIMEOUT))
411 + goto err_busy;
412 + } else if ((prod - head) == queue->mask) {
413 + const unsigned int last = Q_ITEM(queue, head);
443 414
444 - ret = riscv_iommu_queue_wait_for_space(queue, head);
445 - if (ret)
415 + if (riscv_iommu_readl_timeout(queue->iommu, Q_HEAD(queue), head,
416 + !(head & ~queue->mask) && head != last,
417 + 0, RISCV_IOMMU_QUEUE_TIMEOUT))
446 418 goto err_busy;
419 + atomic_add((head - last) & queue->mask, &queue->head);
447 420 }
448 421
449 - /* 2. Store entry in the ring buffer. */
422 + /* 3. Store entry in the ring buffer */
450 423 memcpy(queue->base + Q_ITEM(queue, prod) * entry_size, entry, entry_size);
451 424
452 - /* 3. Make sure the entry is visible before updating the queue tail. */
425 + /* 4. Wait for all previous entries to be ready */
426 + if (readx_poll_timeout(atomic_read, &queue->tail, tail, prod == tail,
427 + 0, RISCV_IOMMU_QUEUE_TIMEOUT))
428 + goto err_busy;
429 +
430 + /*
431 + * 5. Make sure the ring buffer update (whether in normal or I/O memory) is
432 + * completed and visible before signaling the tail doorbell to fetch
433 + * the next command. 'fence ow, ow'
434 + */
453 435 dma_wmb();
454 436 riscv_iommu_writel(queue->iommu, Q_TAIL(queue), Q_ITEM(queue, prod + 1));
455 437
456 438 /*
457 - * 4. Make sure the doorbell write to the device has finished before
458 - * updating the shadow tail index in normal memory. 'fence o, w'
439 + * 6. Make sure the doorbell write to the device has finished before updating
440 + * the shadow tail index in normal memory. 'fence o, w'
459 441 */
460 442 #ifdef CONFIG_MMIOWB
461 443 mmiowb();
462 444 #endif
463 - atomic_set(&queue->tail, prod + 1);
464 - atomic_set(&queue->prod, prod + 1);
445 + atomic_inc(&queue->tail);
465 446
466 - if (out_prod)
467 - *out_prod = prod;
447 + /* 7. Complete submission and restore local interrupts */
448 + local_irq_restore(flags);
468 449
469 - raw_spin_unlock_irqrestore(&queue->lock, flags);
470 - return 0;
450 + return prod;
471 451
472 452 err_busy:
473 - /* Report the failure and continue; full RAS recovery is not implemented. */
453 + local_irq_restore(flags);
474 454 dev_err_once(queue->iommu->dev, "Hardware error: command enqueue failed\n");
475 - return ret;
455 +
456 + return prod;
476 457 }
477 458
478 459 /*
@@ -511,7 +492,7 @@ static irqreturn_t riscv_iommu_cmdq_process(int irq, void *data)
511 492 static void riscv_iommu_cmd_send(struct riscv_iommu_device *iommu,
512 493 struct riscv_iommu_command *cmd)
513 494 {
514 - riscv_iommu_queue_send(&iommu->cmdq, cmd, sizeof(*cmd), NULL);
495 + riscv_iommu_queue_send(&iommu->cmdq, cmd, sizeof(*cmd));
515 496 }
516 497
517 498 /* Send IOFENCE.C command and wait for all scheduled commands to complete. */
@@ -520,12 +501,9 @@ static void riscv_iommu_cmd_sync(struct riscv_iommu_device *iommu,
520 501 {
521 502 struct riscv_iommu_command cmd;
522 503 unsigned int prod;
523 - int ret;
524 504
525 505 riscv_iommu_cmd_iofence(&cmd);
526 - ret = riscv_iommu_queue_send(&iommu->cmdq, &cmd, sizeof(cmd), &prod);
527 - if (ret)
528 - return;
506 + prod = riscv_iommu_queue_send(&iommu->cmdq, &cmd, sizeof(cmd));
529 507
530 508 if (!timeout_us)
531 509 return;
@@ -1582,7 +1560,6 @@ int riscv_iommu_init(struct riscv_iommu_device *iommu)
1582 1560 int rc;
1583 1561
1584 1562 RISCV_IOMMU_QUEUE_INIT(&iommu->cmdq, CQ);
1585 - raw_spin_lock_init(&iommu->cmdq.lock);
1586 1563 RISCV_IOMMU_QUEUE_INIT(&iommu->fltq, FQ);
1587 1564
1588 1565 rc = riscv_iommu_init_check(iommu);
modified drivers/iommu/riscv/iommu.h
@@ -12,7 +12,6 @@
12 12 #define _RISCV_IOMMU_H_
13 13
14 14 #include <linux/iommu.h>
15 - #include <linux/spinlock.h>
16 15 #include <linux/types.h>
17 16 #include <linux/iopoll.h>
18 17
@@ -24,7 +23,6 @@ struct riscv_iommu_queue {
24 23 atomic_t prod; /* unbounded producer allocation index */
25 24 atomic_t head; /* unbounded shadow ring buffer consumer index */
26 25 atomic_t tail; /* unbounded shadow ring buffer producer index */
27 - raw_spinlock_t lock; /* serialize queue publishing */
28 26 unsigned int mask; /* index mask, queue length - 1 */
29 27 unsigned int irq; /* allocated interrupt number */
30 28 struct riscv_iommu_device *iommu; /* iommu device handling the queue when active */
modified drivers/iommu/s390-iommu.c
@@ -974,8 +974,6 @@ static unsigned long *get_rto_from_iova(struct s390_domain *domain,
974 974 case ZPCI_TABLE_TYPE_RFX:
975 975 case ZPCI_TABLE_TYPE_RSX:
976 976 rso = get_rso_from_iova(domain, iova);
977 - if (!rso)
978 - return NULL;
979 977 rsx = calc_rsx(iova);
980 978 rse = READ_ONCE(rso[rsx]);
981 979 if (!reg_entry_isvalid(rse))
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-gic-v5.c
@@ -974,8 +974,7 @@ static void gicv5_cpu_disable_interrupts(void)
974 974 {
975 975 u64 cr0;
976 976
977 - cr0 = read_sysreg_s(SYS_ICC_CR0_EL1);
978 - cr0 &= ~ICC_CR0_EL1_EN_MASK;
977 + cr0 = FIELD_PREP(ICC_CR0_EL1_EN, 0);
979 978 write_sysreg_s(cr0, SYS_ICC_CR0_EL1);
980 979 isb();
981 980 }
@@ -992,8 +991,7 @@ static void gicv5_cpu_enable_interrupts(void)
992 991 pcr = FIELD_PREP(ICC_PCR_EL1_PRIORITY, GICV5_IRQ_PRI_MI);
993 992 write_sysreg_s(pcr, SYS_ICC_PCR_EL1);
994 993
995 - cr0 = read_sysreg_s(SYS_ICC_CR0_EL1);
996 - cr0 |= ICC_CR0_EL1_EN_MASK;
994 + cr0 = FIELD_PREP(ICC_CR0_EL1_EN, 1);
997 995 write_sysreg_s(cr0, SYS_ICC_CR0_EL1);
998 996 }
999 997
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/pci/intel/ipu-bridge.c
@@ -232,19 +232,6 @@ static const struct acpi_device_id ivsc_acpi_ids[] = {
232 232 { "INTC10FA" }, /* NVL */
233 233 };
234 234
235 - /*
236 - * The subset of ivsc_acpi_ids[] which are IVSC, rather than CVS, devices. The
237 - * CVS IDs are deliberately not listed here: new ones keep being added, whereas
238 - * this list is complete.
239 - */
240 - static const struct acpi_device_id ivsc_only_acpi_ids[] = {
241 - { "INTC1059" },
242 - { "INTC1095" },
243 - { "INTC100A" },
244 - { "INTC10CF" },
245 - { }
246 - };
247 -
248 235 static struct acpi_device *ipu_bridge_get_ivsc_acpi_dev(struct acpi_device *adev)
249 236 {
250 237 unsigned int i;
@@ -296,17 +283,6 @@ static struct device *ipu_bridge_get_ivsc_csi_dev(struct acpi_device *adev)
296 283 return csi_dev;
297 284 }
298 285
299 - /*
300 - * The lookups below match on the ACPI companion alone. That is fine for
301 - * CVS, which binds a driver to that very device, but not for IVSC: there
302 - * the ACPI device also has a driverless platform device, which would be
303 - * returned instead of the mei-csi client. Return NULL for IVSC so that
304 - * the caller fails and the probe is retried once the IVSC device shows
305 - * up.
306 - */
307 - if (!acpi_match_device_ids(adev, ivsc_only_acpi_ids))
308 - return NULL;
309 -
310 286 /* Try to locate CVS device on the I2C bus */
311 287 csi_dev = bus_find_device_by_acpi_dev(&i2c_bus_type, adev);
312 288 if (csi_dev)
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/dreamchip/rppx1/rpp_params.c
@@ -25,7 +25,6 @@ rppx1_ext_params_blocks_info[] = {
25 25 RPPX1_PARAMS_BLOCK_INFO(LSC_PRE2, lsc),
26 26 RPPX1_PARAMS_BLOCK_INFO(AWBG_PRE1, awbg),
27 27 RPPX1_PARAMS_BLOCK_INFO(AWBG_PRE2, awbg),
28 - RPPX1_PARAMS_BLOCK_INFO(AWBG_POST, awbg),
29 28 RPPX1_PARAMS_BLOCK_INFO(CCOR_POST, ccor),
30 29 RPPX1_PARAMS_BLOCK_INFO(HIST_PRE1, hist),
31 30 RPPX1_PARAMS_BLOCK_INFO(HIST_PRE2, hist),
modified drivers/media/platform/dreamchip/rppx1/rppx1_bls.c
@@ -70,7 +70,7 @@ rppx1_bls_swap_regs(struct rpp_module *mod, const u32 input[4], u32 output[4])
70 70
71 71 /* Swap to pattern used in our path, PRE1 or PRE2. */
72 72 struct rpp_module *acq = mod == &mod->rpp->pre1.bls ?
73 - &mod->rpp->pre1.acq : &mod->rpp->pre2.acq;
73 + &mod->rpp->pre1.acq : &mod->rpp->pre2.bls;
74 74 enum rpp_raw_pattern pattern = acq->info.acq.raw_pattern;
75 75
76 76 for (unsigned int i = 0; i < 4; ++i)
modified drivers/media/platform/mediatek/vcodec/decoder/vdec/vdec_av1_req_lat_if.c
@@ -1299,12 +1299,11 @@ static void vdec_av1_slice_setup_tile(struct vdec_av1_slice_frame *frame,
1299 1299 tile->uniform_tile_spacing_flag =
1300 1300 BIT_FLAG(ctrl_tile, V4L2_AV1_TILE_INFO_FLAG_UNIFORM_TILE_SPACING);
1301 1301
1302 - /* Bound the copy to the mi_col_starts[]/mi_row_starts[] capacity. */
1303 - for (i = 0; i < tile->tile_cols + 1 && i < V4L2_AV1_MAX_TILE_COLS + 1; i++)
1302 + for (i = 0; i < tile->tile_cols + 1; i++)
1304 1303 tile->mi_col_starts[i] =
1305 1304 ALIGN(ctrl_tile->mi_col_starts[i], BIT(mib_size_log2)) >> mib_size_log2;
1306 1305
1307 - for (i = 0; i < tile->tile_rows + 1 && i < V4L2_AV1_MAX_TILE_ROWS + 1; i++)
1306 + for (i = 0; i < tile->tile_rows + 1; i++)
1308 1307 tile->mi_row_starts[i] =
1309 1308 ALIGN(ctrl_tile->mi_row_starts[i], BIT(mib_size_log2)) >> mib_size_log2;
1310 1309 }
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/platform/rockchip/rkvdec/rkvdec-hevc-common.c
@@ -16,7 +16,6 @@
16 16 */
17 17
18 18 #include <linux/v4l2-common.h>
19 - #include <media/v4l2-hevc.h>
20 19 #include <media/v4l2-mem2mem.h>
21 20
22 21 #include "rkvdec.h"
@@ -38,17 +37,15 @@ void compute_tiles_uniform(struct rkvdec_hevc_run *run, u16 log2_min_cb_size,
38 37 s32 pic_in_cts_height, u16 *column_width, u16 *row_height)
39 38 {
40 39 const struct v4l2_ctrl_hevc_pps *pps = run->pps;
41 - unsigned int num_cols = v4l2_hevc_pps_num_tile_columns(pps);
42 - unsigned int num_rows = v4l2_hevc_pps_num_tile_rows(pps);
43 40 int i;
44 41
45 - for (i = 0; i < num_cols; i++)
42 + for (i = 0; i < pps->num_tile_columns_minus1 + 1; i++)
46 43 column_width[i] = ((i + 1) * pic_in_cts_width) /
47 44 (pps->num_tile_columns_minus1 + 1) -
48 45 (i * pic_in_cts_width) /
49 46 (pps->num_tile_columns_minus1 + 1);
50 47
51 - for (i = 0; i < num_rows; i++)
48 + for (i = 0; i < pps->num_tile_rows_minus1 + 1; i++)
52 49 row_height[i] = ((i + 1) * pic_in_cts_height) /
53 50 (pps->num_tile_rows_minus1 + 1) -
54 51 (i * pic_in_cts_height) /
@@ -60,20 +57,17 @@ void compute_tiles_non_uniform(struct rkvdec_hevc_run *run, u16 log2_min_cb_size
60 57 s32 pic_in_cts_height, u16 *column_width, u16 *row_height)
61 58 {
62 59 const struct v4l2_ctrl_hevc_pps *pps = run->pps;
63 - unsigned int num_cols = v4l2_hevc_pps_num_tile_columns(pps);
64 - unsigned int num_rows = v4l2_hevc_pps_num_tile_rows(pps);
65 60 s32 sum = 0;
66 61 int i;
67 62
68 - /* The last tile entry is written after the loop, so iterate one less. */
69 - for (i = 0; i < num_cols - 1; i++) {
63 + for (i = 0; i < pps->num_tile_columns_minus1; i++) {
70 64 column_width[i] = pps->column_width_minus1[i] + 1;
71 65 sum += column_width[i];
72 66 }
73 67 column_width[i] = pic_in_cts_width - sum;
74 68
75 69 sum = 0;
76 - for (i = 0; i < num_rows - 1; i++) {
70 + for (i = 0; i < pps->num_tile_rows_minus1; i++) {
77 71 row_height[i] = pps->row_height_minus1[i] + 1;
78 72 sum += row_height[i];
79 73 }
modified drivers/media/platform/rockchip/rkvdec/rkvdec-hevc.c
@@ -12,7 +12,6 @@
12 12 * Jeffy Chen <jeffy.chen@rock-chips.com>
13 13 */
14 14
15 - #include <media/v4l2-hevc.h>
16 15 #include <media/v4l2-mem2mem.h>
17 16
18 17 #include "rkvdec.h"
@@ -136,8 +135,6 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
136 135 * packet unit). so the driver copy SPS/PPS information to the exact PPS
137 136 * packet unit for HW accessing.
138 137 */
139 - if (pps->pic_parameter_set_id >= ARRAY_SIZE(priv_tbl->param_set))
140 - return;
141 138 hw_ps = &priv_tbl->param_set[pps->pic_parameter_set_id];
142 139 memset(hw_ps, 0, sizeof(*hw_ps));
143 140
@@ -256,9 +253,9 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
256 253
257 254 if (pps->flags & V4L2_HEVC_PPS_FLAG_TILES_ENABLED) {
258 255 /* Userspace also provide column width and row height for uniform spacing */
259 - for (i = 0; i < v4l2_hevc_pps_num_tile_columns(pps); i++)
256 + for (i = 0; i <= pps->num_tile_columns_minus1; i++)
260 257 WRITE_PPS(pps->column_width_minus1[i], COLUMN_WIDTH(i));
261 - for (i = 0; i < v4l2_hevc_pps_num_tile_rows(pps); i++)
258 + for (i = 0; i <= pps->num_tile_rows_minus1; i++)
262 259 WRITE_PPS(pps->row_height_minus1[i], ROW_HEIGHT(i));
263 260 } else {
264 261 WRITE_PPS(DIV_ROUND_UP(sps->pic_width_in_luma_samples, ctb_size_y) - 1,
modified drivers/media/platform/rockchip/rkvdec/rkvdec-vdpu381-hevc.c
@@ -145,8 +145,6 @@ static void assemble_hw_pps(struct rkvdec_ctx *ctx,
145 145 * packet unit). so the driver copy SPS/PPS information to the exact PPS
146 146 * packet unit for HW accessing.
147 147 */
148 - if (pps->pic_parameter_set_id >= ARRAY_SIZE(priv_tbl->param_set))
149 - return;
150 148 hw_ps = &priv_tbl->param_set[pps->pic_parameter_set_id];
151 149 memset(hw_ps, 0, sizeof(*hw_ps));
152 150
modified drivers/media/platform/verisilicon/hantro_g2_hevc_dec.c
@@ -5,8 +5,6 @@
5 5 * Copyright (C) 2020 Safran Passenger Innovations LLC
6 6 */
7 7
8 - #include <media/v4l2-hevc.h>
9 -
10 8 #include "hantro_hw.h"
11 9 #include "hantro_g2_regs.h"
12 10
@@ -17,8 +15,8 @@ static void prepare_tile_info_buffer(struct hantro_ctx *ctx)
17 15 const struct v4l2_ctrl_hevc_pps *pps = ctrls->pps;
18 16 const struct v4l2_ctrl_hevc_sps *sps = ctrls->sps;
19 17 u16 *p = (u16 *)((u8 *)ctx->hevc_dec.tile_sizes.cpu);
20 - unsigned int num_tile_rows = v4l2_hevc_pps_num_tile_rows(pps);
21 - unsigned int num_tile_cols = v4l2_hevc_pps_num_tile_columns(pps);
18 + unsigned int num_tile_rows = pps->num_tile_rows_minus1 + 1;
19 + unsigned int num_tile_cols = pps->num_tile_columns_minus1 + 1;
22 20 unsigned int pic_width_in_ctbs, pic_height_in_ctbs;
23 21 unsigned int max_log2_ctb_size, ctb_size;
24 22 bool tiles_enabled, uniform_spacing;
modified drivers/media/platform/verisilicon/rockchip_vpu981_hw_av1_dec.c
@@ -431,39 +431,20 @@ static int rockchip_vpu981_av1_dec_prepare_run(struct hantro_ctx *ctx)
431 431 {
432 432 struct hantro_av1_dec_hw_ctx *av1_dec = &ctx->av1_dec;
433 433 struct hantro_av1_dec_ctrls *ctrls = &av1_dec->ctrls;
434 - const struct v4l2_av1_tile_info *tile_info;
435 - struct v4l2_ctrl *tge;
436 - u32 num_tiles;
437 434
438 435 ctrls->sequence = hantro_get_ctrl(ctx, V4L2_CID_STATELESS_AV1_SEQUENCE);
439 436 if (WARN_ON(!ctrls->sequence))
440 437 return -EINVAL;
441 438
442 - tge = v4l2_ctrl_find(&ctx->ctrl_handler,
443 - V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY);
444 - if (WARN_ON(!tge))
439 + ctrls->tile_group_entry =
440 + hantro_get_ctrl(ctx, V4L2_CID_STATELESS_AV1_TILE_GROUP_ENTRY);
441 + if (WARN_ON(!ctrls->tile_group_entry))
445 442 return -EINVAL;
446 - ctrls->tile_group_entry = tge->p_cur.p;
447 443
448 444 ctrls->frame = hantro_get_ctrl(ctx, V4L2_CID_STATELESS_AV1_FRAME);
449 445 if (WARN_ON(!ctrls->frame))
450 446 return -EINVAL;
451 447
452 - /*
453 - * rockchip_vpu981_av1_dec_set_tile_info() indexes the tile group
454 - * entry array by tile1 * tile_cols + tile0, so it reads up to
455 - * tile_cols * tile_rows entries, and lays out one descriptor per tile
456 - * in the AV1_MAX_TILES tile_info buffer while programming the real
457 - * tile geometry into the hardware. Reject a frame that claims more
458 - * tiles than userspace submitted, or more than the hardware tile
459 - * buffer holds, so the read stays in bounds and the programmed
460 - * geometry matches the descriptors written.
461 - */
462 - tile_info = &ctrls->frame->tile_info;
463 - num_tiles = (u32)tile_info->tile_cols * tile_info->tile_rows;
464 - if (num_tiles > tge->elems || num_tiles > AV1_MAX_TILES)
465 - return -EINVAL;
466 -
467 448 ctrls->film_grain =
468 449 hantro_get_ctrl(ctx, V4L2_CID_STATELESS_AV1_FILM_GRAIN);
469 450
@@ -597,30 +578,16 @@ static void rockchip_vpu981_av1_dec_set_tile_info(struct hantro_ctx *ctx)
597 578 const struct v4l2_av1_tile_info *tile_info = &ctrls->frame->tile_info;
598 579 const struct v4l2_ctrl_av1_tile_group_entry *group_entry =
599 580 ctrls->tile_group_entry;
600 - int context_update_y = 0;
601 - int context_update_x = 0;
602 - int context_update_tile_id = 0;
581 + int context_update_y =
582 + tile_info->context_update_tile_id / tile_info->tile_cols;
583 + int context_update_x =
584 + tile_info->context_update_tile_id % tile_info->tile_cols;
585 + int context_update_tile_id =
586 + context_update_x * tile_info->tile_rows + context_update_y;
603 587 u8 *dst = av1_dec->tile_info.cpu;
604 - u8 *dst_end = dst + av1_dec->tile_info.size;
605 588 struct hantro_dev *vpu = ctx->dev;
606 589 int tile0, tile1;
607 590
608 - /*
609 - * tile_cols and tile_rows are bounded by the V4L2 control validation
610 - * (V4L2_AV1_MAX_TILE_{COLS,ROWS} and V4L2_AV1_MAX_TILE_COUNT). Guard
611 - * the divisor here, and keep the descriptor writes within the
612 - * AV1_MAX_TILES tile_info buffer below; the register values use the
613 - * unmodified tile geometry.
614 - */
615 - if (tile_info->tile_cols) {
616 - context_update_y =
617 - tile_info->context_update_tile_id / tile_info->tile_cols;
618 - context_update_x =
619 - tile_info->context_update_tile_id % tile_info->tile_cols;
620 - context_update_tile_id =
621 - context_update_x * tile_info->tile_rows + context_update_y;
622 - }
623 -
624 591 memset(dst, 0, av1_dec->tile_info.size);
625 592
626 593 for (tile0 = 0; tile0 < tile_info->tile_cols; tile0++) {
@@ -631,10 +598,6 @@ static void rockchip_vpu981_av1_dec_set_tile_info(struct hantro_ctx *ctx)
631 598 tile_info->height_in_sbs_minus_1[tile1] + 1;
632 599 u32 x0 = tile_info->width_in_sbs_minus_1[tile0] + 1;
633 600
634 - /* Stop once the tile_info descriptor buffer is full. */
635 - if (dst + 16 > dst_end)
636 - break;
637 -
638 601 /* tile size in SB units (width,height) */
639 602 *dst++ = x0;
640 603 *dst++ = 0;
@@ -659,8 +622,6 @@ static void rockchip_vpu981_av1_dec_set_tile_info(struct hantro_ctx *ctx)
659 622 *dst++ = (end >> 16) & 255;
660 623 *dst++ = (end >> 24) & 255;
661 624 }
662 - if (dst + 16 > dst_end)
663 - break;
664 625 }
665 626
666 627 hantro_reg_write(vpu, &av1_multicore_expect_context_update, !!(context_update_x == 0));
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/media/v4l2-core/v4l2-ctrls-core.c
@@ -793,30 +793,10 @@ static int validate_av1_film_grain(struct v4l2_ctrl_av1_film_grain *fg)
793 793 return 0;
794 794 }
795 795
796 - static int validate_av1_tile_info(struct v4l2_av1_tile_info *t)
797 - {
798 - /*
799 - * tile_cols and tile_rows index the per-tile descriptor arrays and
800 - * bound the tile loops in the stateless AV1 drivers; the product
801 - * bounds the total tile descriptor count.
802 - */
803 - if (t->tile_cols > V4L2_AV1_MAX_TILE_COLS ||
804 - t->tile_rows > V4L2_AV1_MAX_TILE_ROWS)
805 - return -EINVAL;
806 -
807 - if ((u32)t->tile_cols * t->tile_rows > V4L2_AV1_MAX_TILE_COUNT)
808 - return -EINVAL;
809 -
810 - return 0;
811 - }
812 -
813 796 static int validate_av1_frame(struct v4l2_ctrl_av1_frame *f)
814 797 {
815 798 int ret = 0;
816 799
817 - ret = validate_av1_tile_info(&f->tile_info);
818 - if (ret)
819 - return ret;
820 800 ret = validate_av1_quantization(&f->quantization);
821 801 if (ret)
822 802 return ret;
@@ -1273,18 +1253,6 @@ static int std_validate_compound(const struct v4l2_ctrl *ctrl, u32 idx,
1273 1253
1274 1254 p_hevc_pps->flags &=
1275 1255 ~V4L2_HEVC_PPS_FLAG_LOOP_FILTER_ACROSS_TILES_ENABLED;
1276 - } else {
1277 - /*
1278 - * These count the entries the stateless HEVC drivers
1279 - * read from column_width_minus1[] / row_height_minus1[]
1280 - * and use as tile-loop bounds.
1281 - */
1282 - if (p_hevc_pps->num_tile_columns_minus1 >=
1283 - ARRAY_SIZE(p_hevc_pps->column_width_minus1))
1284 - return -EINVAL;
1285 - if (p_hevc_pps->num_tile_rows_minus1 >=
1286 - ARRAY_SIZE(p_hevc_pps->row_height_minus1))
1287 - return -EINVAL;
1288 1256 }
1289 1257
1290 1258 if (p_hevc_pps->flags &
modified drivers/media/v4l2-core/v4l2-h264.c
@@ -440,8 +440,7 @@ v4l2_h264_build_b_ref_lists(const struct v4l2_h264_reflist_builder *builder,
440 440 }
441 441
442 442 if (builder->num_valid > 1 &&
443 - !memcmp(b1_reflist, b0_reflist,
444 - sizeof(b1_reflist[0]) * builder->num_valid))
443 + !memcmp(b1_reflist, b0_reflist, builder->num_valid))
445 444 swap(b1_reflist[0], b1_reflist[1]);
446 445
447 446 print_ref_list_b(builder, b0_reflist, 0);
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
@@ -678,15 +678,9 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
678 678 if (arp->op_code == htons(ARPOP_REPLY)) {
679 679 /* the arp must be sent on the selected rx channel */
680 680 tx_slave = rlb_choose_channel(skb, bond, arp);
681 - if (tx_slave &&
682 - !ether_addr_equal_64bits(arp->mac_src,
683 - tx_slave->dev->dev_addr)) {
684 - if (unlikely(skb_cow_head(skb, 0)))
685 - return NULL;
686 - arp = (struct arp_pkt *)skb_network_header(skb);
681 + if (tx_slave)
687 682 bond_hw_addr_copy(arp->mac_src, tx_slave->dev->dev_addr,
688 683 tx_slave->dev->addr_len);
689 - }
690 684 netdev_dbg(bond->dev, "(slave %s): Server sent ARP Reply packet\n",
691 685 tx_slave ? tx_slave->dev->name : "NULL");
692 686 } else if (arp->op_code == htons(ARPOP_REQUEST)) {
@@ -881,7 +875,7 @@ static int rlb_initialize(struct bonding *bond)
881 875 spin_unlock_bh(&bond->mode_lock);
882 876
883 877 /* register to receive ARPs */
884 - WRITE_ONCE(bond->recv_probe, rlb_arp_recv);
878 + bond->recv_probe = rlb_arp_recv;
885 879
886 880 return 0;
887 881 }
@@ -1287,10 +1281,10 @@ unwind:
1287 1281 }
1288 1282
1289 1283 /* determine if the packet is NA or NS */
1290 - static bool alb_determine_nd(struct sk_buff *skb)
1284 + static bool alb_determine_nd(struct sk_buff *skb, struct bonding *bond)
1291 1285 {
1292 - const struct ipv6hdr *ip6hdr;
1293 - const struct icmp6hdr *hdr;
1286 + struct ipv6hdr *ip6hdr;
1287 + struct icmp6hdr *hdr;
1294 1288
1295 1289 if (!pskb_network_may_pull(skb, sizeof(*ip6hdr)))
1296 1290 return true;
@@ -1302,8 +1296,7 @@ static bool alb_determine_nd(struct sk_buff *skb)
1302 1296 if (!pskb_network_may_pull(skb, sizeof(*ip6hdr) + sizeof(*hdr)))
1303 1297 return true;
1304 1298
1305 - ip6hdr = ipv6_hdr(skb);
1306 - hdr = (const struct icmp6hdr *)(ip6hdr + 1);
1299 + hdr = icmp6_hdr(skb);
1307 1300 return hdr->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT ||
1308 1301 hdr->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION;
1309 1302 }
@@ -1346,6 +1339,7 @@ static netdev_tx_t bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,
1346 1339 struct slave *tx_slave)
1347 1340 {
1348 1341 struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
1342 + struct ethhdr *eth_data = eth_hdr(skb);
1349 1343
1350 1344 if (!tx_slave) {
1351 1345 /* unbalanced or unassigned, send through primary */
@@ -1356,9 +1350,7 @@ static netdev_tx_t bond_do_alb_xmit(struct sk_buff *skb, struct bonding *bond,
1356 1350
1357 1351 if (tx_slave && bond_slave_can_tx(tx_slave)) {
1358 1352 if (tx_slave != rcu_access_pointer(bond->curr_active_slave)) {
1359 - if (unlikely(skb_cow_head(skb, 0)))
1360 - return bond_tx_drop(bond->dev, skb);
1361 - ether_addr_copy(skb_eth_hdr(skb)->h_source,
1353 + ether_addr_copy(eth_data->h_source,
1362 1354 tx_slave->dev->dev_addr);
1363 1355 }
1364 1356
@@ -1382,13 +1374,14 @@ struct slave *bond_xmit_tlb_slave_get(struct bonding *bond,
1382 1374 struct ethhdr *eth_data;
1383 1375 u32 hash_index;
1384 1376
1385 - eth_data = skb_eth_hdr(skb);
1377 + skb_reset_mac_header(skb);
1378 + eth_data = eth_hdr(skb);
1386 1379
1387 1380 /* Do not TX balance any multicast or broadcast */
1388 1381 if (!is_multicast_ether_addr(eth_data->h_dest)) {
1389 1382 switch (skb->protocol) {
1390 1383 case htons(ETH_P_IPV6):
1391 - if (alb_determine_nd(skb))
1384 + if (alb_determine_nd(skb, bond))
1392 1385 break;
1393 1386 fallthrough;
1394 1387 case htons(ETH_P_IP):
@@ -1434,7 +1427,8 @@ struct slave *bond_xmit_alb_slave_get(struct bonding *bond,
1434 1427 u32 hash_index = 0;
1435 1428 int hash_size = 0;
1436 1429
1437 - eth_data = skb_eth_hdr(skb);
1430 + skb_reset_mac_header(skb);
1431 + eth_data = eth_hdr(skb);
1438 1432
1439 1433 switch (ntohs(skb->protocol)) {
1440 1434 case ETH_P_IP: {
@@ -1473,7 +1467,7 @@ struct slave *bond_xmit_alb_slave_get(struct bonding *bond,
1473 1467 break;
1474 1468 }
1475 1469
1476 - if (alb_determine_nd(skb)) {
1470 + if (alb_determine_nd(skb, bond)) {
1477 1471 do_tx_balance = false;
1478 1472 break;
1479 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/bcm_sf2_cfp.c
@@ -1088,8 +1088,6 @@ static int bcm_sf2_cfp_rule_get_all(struct bcm_sf2_priv *priv,
1088 1088 unsigned int index = 1, rules_cnt = 0;
1089 1089
1090 1090 for_each_set_bit_from(index, priv->cfp.unique, priv->num_cfp_rules) {
1091 - if (rules_cnt == nfc->rule_cnt)
1092 - return -EMSGSIZE;
1093 1091 rule_locs[rules_cnt] = index;
1094 1092 rules_cnt++;
1095 1093 }
modified drivers/net/dsa/lantiq/lantiq_gswip.h
@@ -42,7 +42,7 @@
42 42 #define GSWIP_MDIO_PHY_FDUP_DIS 0x0600
43 43 #define GSWIP_MDIO_PHY_FCONTX_MASK 0x0180
44 44 #define GSWIP_MDIO_PHY_FCONTX_AUTO 0x0000
45 - #define GSWIP_MDIO_PHY_FCONTX_EN 0x0080
45 + #define GSWIP_MDIO_PHY_FCONTX_EN 0x0100
46 46 #define GSWIP_MDIO_PHY_FCONTX_DIS 0x0180
47 47 #define GSWIP_MDIO_PHY_FCONRX_MASK 0x0060
48 48 #define GSWIP_MDIO_PHY_FCONRX_AUTO 0x0000
modified drivers/net/dsa/mt7530.c
@@ -3172,31 +3172,23 @@ static void mt753x_phylink_get_caps(struct dsa_switch *ds, int port,
3172 3172
3173 3173 config->mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE;
3174 3174
3175 - priv->info->mac_port_get_caps(ds, port, config);
3176 -
3177 3175 /* The EN7528 GPHYs report EEE capability, but negotiating EEE with
3178 3176 * common link partners (e.g. Realtek GbE NICs) results in an unstable
3179 3177 * link with dropped frames. Leave the LPI capabilities empty so that
3180 3178 * phylink disables EEE on these PHYs and refuses to enable it from
3181 3179 * userspace.
3182 3180 */
3183 - if (priv->id != ID_EN7528 &&
3184 - config->mac_capabilities & (MAC_100FD | MAC_1000FD)) {
3181 + if (priv->id != ID_EN7528) {
3185 3182 u32 eeecr = mt7530_read(priv, MT753X_PMEEECR_P(port));
3186 3183
3187 - /* LPI above 1 Gbps is not supported */
3188 - config->lpi_capabilities = config->mac_capabilities &
3189 - (MAC_100FD | MAC_1000FD);
3190 - phy_interface_copy(config->lpi_interfaces,
3191 - config->supported_interfaces);
3192 - __clear_bit(PHY_INTERFACE_MODE_2500BASEX,
3193 - config->lpi_interfaces);
3194 -
3184 + config->lpi_capabilities = MAC_100FD | MAC_1000FD | MAC_2500FD;
3195 3185 /* tx_lpi_timer should be in microseconds. The time units for
3196 3186 * LPI threshold are unspecified.
3197 3187 */
3198 3188 config->lpi_timer_default = FIELD_GET(LPI_THRESH_MASK, eeecr);
3199 3189 }
3190 +
3191 + priv->info->mac_port_get_caps(ds, port, config);
3200 3192 }
3201 3193
3202 3194 static int mt753x_pcs_validate(struct phylink_pcs *pcs,
modified drivers/net/dsa/mv88e6xxx/chip.c
@@ -2438,7 +2438,6 @@ static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
2438 2438 struct ethtool_rx_flow_spec *fs = &rxnfc->fs;
2439 2439 struct mv88e6xxx_chip *chip = ds->priv;
2440 2440 struct mv88e6xxx_policy *policy;
2441 - u32 cnt = 0;
2442 2441 int err;
2443 2442 int id;
2444 2443
@@ -2464,18 +2463,11 @@ static int mv88e6xxx_get_rxnfc(struct dsa_switch *ds, int port,
2464 2463 break;
2465 2464 case ETHTOOL_GRXCLSRLALL:
2466 2465 rxnfc->data = 0;
2466 + rxnfc->rule_cnt = 0;
2467 + idr_for_each_entry(&chip->policies, policy, id)
2468 + if (policy->port == port)
2469 + rule_locs[rxnfc->rule_cnt++] = id;
2467 2470 err = 0;
2468 - idr_for_each_entry(&chip->policies, policy, id) {
2469 - if (policy->port != port)
2470 - continue;
2471 - if (cnt == rxnfc->rule_cnt) {
2472 - err = -EMSGSIZE;
2473 - break;
2474 - }
2475 - rule_locs[cnt++] = id;
2476 - }
2477 - if (!err)
2478 - rxnfc->rule_cnt = cnt;
2479 2471 break;
2480 2472 default:
2481 2473 err = -EOPNOTSUPP;
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/allwinner/sun4i-emac.c
@@ -1067,7 +1067,6 @@ static int emac_probe(struct platform_device *pdev)
1067 1067 return 0;
1068 1068
1069 1069 out_release_sram:
1070 - of_node_put(db->phy_node);
1071 1070 sunxi_sram_release(&pdev->dev);
1072 1071 out_clk_disable_unprepare:
1073 1072 clk_disable_unprepare(db->clk);
@@ -1095,7 +1094,6 @@ static void emac_remove(struct platform_device *pdev)
1095 1094 }
1096 1095
1097 1096 unregister_netdev(ndev);
1098 - of_node_put(db->phy_node);
1099 1097 sunxi_sram_release(&pdev->dev);
1100 1098 clk_disable_unprepare(db->clk);
1101 1099 irq_dispose_mapping(ndev->irq);
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
@@ -171,10 +171,8 @@ pdsc_legacy_firmware_update(struct pdsc *pdsc,
171 171
172 172 dev_info(pdsc->dev, "Installing firmware\n");
173 173
174 - if (!pdsc->cmd_regs) {
175 - NL_SET_ERR_MSG_MOD(extack, "BARs not mapped");
174 + if (!pdsc->cmd_regs)
176 175 return -ENXIO;
177 - }
178 176
179 177 dl = priv_to_devlink(pdsc);
180 178 devlink_flash_update_status_notify(dl, "Preparing to flash",
@@ -200,12 +198,6 @@ pdsc_legacy_firmware_update(struct pdsc *pdsc,
200 198
201 199 copy_sz = min_t(unsigned int, buf_sz, fw->size - offset);
202 200 mutex_lock(&pdsc->devcmd_lock);
203 - if (!pdsc->cmd_regs) {
204 - mutex_unlock(&pdsc->devcmd_lock);
205 - err = -ENXIO;
206 - NL_SET_ERR_MSG_MOD(extack, "Device reset during flash");
207 - goto err_out;
208 - }
209 201 memcpy_toio(&pdsc->cmd_regs->data, fw->data + offset, copy_sz);
210 202 err = pdsc_devcmd_fw_download_locked(pdsc, data_addr,
211 203 offset, copy_sz);
@@ -390,7 +382,7 @@ static int pdsc_send_package_data(struct pldmfw *context, const u8 *data,
390 382 if (!length)
391 383 return 0;
392 384
393 - deferred = kmalloc_obj(*deferred);
385 + deferred = kmalloc_obj(*deferred, GFP_KERNEL);
394 386 if (!deferred)
395 387 return -ENOMEM;
396 388
@@ -513,7 +505,7 @@ static int pdsc_send_component_table(struct pldmfw *context,
513 505 component->version_string, component->index,
514 506 component->component_size, transfer_flag);
515 507
516 - component_priv = kzalloc_obj(*component_priv);
508 + component_priv = kzalloc_obj(*component_priv, GFP_KERNEL);
517 509 if (!component_priv)
518 510 return -ENOMEM;
519 511
@@ -718,7 +710,7 @@ static int pdsc_flash_component_chunk(struct pdsc *pdsc, struct device *dev,
718 710 u8 *component_data;
719 711 int err;
720 712
721 - deferred = kmalloc_obj(*deferred);
713 + deferred = kmalloc_obj(*deferred, GFP_KERNEL);
722 714 if (!deferred)
723 715 return -ENOMEM;
724 716
modified drivers/net/ethernet/amd/pds_core/main.c
@@ -513,12 +513,8 @@ static void pdsc_reset_prepare(struct pci_dev *pdev)
513 513 pdsc_auxbus_dev_del(pdsc, pdsc, &pdsc->padev);
514 514 }
515 515
516 - if (!pdev->is_virtfn) {
517 - mutex_lock(&pdsc->devcmd_lock);
518 - pdsc_unmap_bars(pdsc);
519 - mutex_unlock(&pdsc->devcmd_lock);
520 - pci_release_regions(pdev);
521 - }
516 + pdsc_unmap_bars(pdsc);
517 + pci_release_regions(pdev);
522 518 if (pci_is_enabled(pdev))
523 519 pci_disable_device(pdev);
524 520 pdsc_deferred_dma_free(pdsc);
@@ -547,9 +543,7 @@ static void pdsc_reset_done(struct pci_dev *pdev)
547 543 return;
548 544 }
549 545
550 - mutex_lock(&pdsc->devcmd_lock);
551 546 err = pdsc_map_bars(pdsc);
552 - mutex_unlock(&pdsc->devcmd_lock);
553 547 if (err)
554 548 return;
555 549 }
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/broadcom/asp2/bcmasp_intf.c
@@ -148,9 +148,8 @@ static int tx_spb_ring_full(struct bcmasp_intf *intf, int cnt)
148 148 int next_index, i;
149 149
150 150 /* Check if we have enough room for cnt descriptors */
151 - next_index = intf->tx_spb_index;
152 151 for (i = 0; i < cnt; i++) {
153 - next_index = incr_ring(next_index, DESC_RING_COUNT);
152 + next_index = incr_ring(intf->tx_spb_index, DESC_RING_COUNT);
154 153 if (next_index == intf->tx_spb_clean_index)
155 154 return 1;
156 155 }
@@ -302,7 +301,6 @@ static netdev_tx_t bcmasp_xmit(struct sk_buff *skb, struct net_device *dev)
302 301 txcb->bytes_sent = total_bytes;
303 302 dma_unmap_addr_set(txcb, dma_addr, mapping);
304 303 dma_unmap_len_set(txcb, dma_len, size);
305 - txcb->last = false;
306 304 if (!i) {
307 305 desc->flags |= DESC_SOF;
308 306 if (csum_hw)
modified drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -462,16 +462,6 @@ u16 bnxt_xmit_get_cfa_action(struct sk_buff *skb)
462 462 static void bnxt_txr_db_kick(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
463 463 u16 prod)
464 464 {
465 - /* If the most recent BD has its completion suppressed, unset the bit
466 - * so that a completion is generated, otherwise nothing is left to
467 - * clean the ring and wake the queue.
468 - */
469 - if (txr->kick_txbd0) {
470 - txr->kick_txbd0->tx_bd_len_flags_type &=
471 - cpu_to_le32(~TX_BD_FLAGS_NO_CMPL);
472 - txr->kick_txbd0 = NULL;
473 - }
474 -
475 465 /* Sync BD data before updating doorbell */
476 466 wmb();
477 467 bnxt_db_write(bp, &txr->tx_db, prod);
@@ -495,6 +485,7 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
495 485 struct bnxt_sw_tx_bd *tx_buf;
496 486 __le32 lflags = 0;
497 487 skb_frag_t *frag;
488 + netdev_tx_t ret;
498 489
499 490 i = skb_get_queue_mapping(skb);
500 491 if (unlikely(i >= bp->tx_nr_rings)) {
@@ -518,22 +509,11 @@ static netdev_tx_t bnxt_start_xmit(struct sk_buff *skb, struct net_device *dev)
518 509 if (skb_is_gso(skb) &&
519 510 (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) &&
520 511 !(bp->flags & BNXT_FLAG_UDP_GSO_CAP)) {
521 - int rc = bnxt_sw_udp_gso_xmit(bp, txr, txq, skb);
522 -
523 - /* if SW USO queued a packet, the doorbell will be written
524 - * below and there is no reason to track the last BD with
525 - * suppressed completions
526 - */
527 - if (rc > 0)
528 - txr->kick_txbd0 = NULL;
529 -
530 - /* if a packet was queued by SW USO or a doorbell was pending
531 - * from a previous xmit that was deferred, write the doorbell.
532 - */
533 - if (rc > 0 || txr->kick_pending)
512 + ret = bnxt_sw_udp_gso_xmit(bp, txr, txq, skb);
513 + if (txr->kick_pending)
534 514 bnxt_txr_db_kick(bp, txr, txr->tx_prod);
535 515
536 - return rc < 0 ? NETDEV_TX_BUSY : NETDEV_TX_OK;
516 + return ret;
537 517 }
538 518
539 519 free_size = bnxt_tx_avail(bp, txr);
@@ -771,23 +751,23 @@ normal_tx:
771 751 prod = NEXT_TX(prod);
772 752 WRITE_ONCE(txr->tx_prod, prod);
773 753
774 - txr->kick_txbd0 = NULL;
775 754 if (!netdev_xmit_more() || netif_xmit_stopped(txq)) {
776 755 bnxt_txr_db_kick(bp, txr, prod);
777 756 } else {
778 - if (free_size >= bp->tx_wake_thresh) {
757 + if (free_size >= bp->tx_wake_thresh)
779 758 txbd0->tx_bd_len_flags_type |=
780 759 cpu_to_le32(TX_BD_FLAGS_NO_CMPL);
781 - txr->kick_txbd0 = txbd0;
782 - }
783 760 txr->kick_pending = 1;
784 761 }
785 762
786 763 tx_done:
787 764
788 765 if (unlikely(bnxt_tx_avail(bp, txr) <= MAX_SKB_FRAGS + 1)) {
789 - if (txr->kick_pending)
766 + if (netdev_xmit_more() && !tx_buf->is_push) {
767 + txbd0->tx_bd_len_flags_type &=
768 + cpu_to_le32(~TX_BD_FLAGS_NO_CMPL);
790 769 bnxt_txr_db_kick(bp, txr, prod);
770 + }
791 771
792 772 netif_txq_try_stop(txq, bnxt_tx_avail(bp, txr),
793 773 bp->tx_wake_thresh);
@@ -1534,16 +1514,14 @@ static int bnxt_discard_rx(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
1534 1514 return 0;
1535 1515 }
1536 1516
1537 - static u16 bnxt_alloc_agg_idx(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
1538 - u16 agg_id)
1517 + static u16 bnxt_alloc_agg_idx(struct bnxt_rx_ring_info *rxr, u16 agg_id)
1539 1518 {
1540 1519 struct bnxt_tpa_idx_map *map = rxr->rx_tpa_idx_map;
1541 - u16 idx = agg_id & (bp->max_tpa_roundup_size - 1);
1520 + u16 idx = agg_id & MAX_TPA_P5_MASK;
1542 1521
1543 1522 if (test_bit(idx, map->agg_idx_bmap)) {
1544 - idx = find_first_zero_bit(map->agg_idx_bmap,
1545 - bp->max_tpa_roundup_size);
1546 - if (idx >= bp->max_tpa_roundup_size)
1523 + idx = find_first_zero_bit(map->agg_idx_bmap, MAX_TPA_P5);
1524 + if (idx >= MAX_TPA_P5)
1547 1525 return INVALID_HW_RING_ID;
1548 1526 }
1549 1527 __set_bit(idx, map->agg_idx_bmap);
@@ -1608,7 +1586,7 @@ static void bnxt_tpa_start(struct bnxt *bp, struct bnxt_rx_ring_info *rxr,
1608 1586
1609 1587 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
1610 1588 agg_id = TPA_START_AGG_ID_P5(tpa_start);
1611 - agg_id = bnxt_alloc_agg_idx(bp, rxr, agg_id);
1589 + agg_id = bnxt_alloc_agg_idx(rxr, agg_id);
1612 1590 if (unlikely(agg_id == INVALID_HW_RING_ID)) {
1613 1591 netdev_warn(bp->dev, "Unable to allocate agg ID for ring %d, agg 0x%x\n",
1614 1592 rxr->bnapi->index,
@@ -3606,7 +3584,7 @@ static void bnxt_free_one_tpa_info_data(struct bnxt *bp,
3606 3584 {
3607 3585 int i;
3608 3586
3609 - for (i = 0; i < bp->max_tpa_roundup_size; i++) {
3587 + for (i = 0; i < bp->max_tpa; i++) {
3610 3588 struct bnxt_tpa_info *tpa_info = &rxr->rx_tpa[i];
3611 3589 u8 *data = tpa_info->data;
3612 3590
@@ -3803,7 +3781,7 @@ static void bnxt_free_one_tpa_info(struct bnxt *bp,
3803 3781 kfree(rxr->rx_tpa_idx_map);
3804 3782 rxr->rx_tpa_idx_map = NULL;
3805 3783 if (rxr->rx_tpa) {
3806 - for (i = 0; i < bp->max_tpa_roundup_size; i++) {
3784 + for (i = 0; i < bp->max_tpa; i++) {
3807 3785 kfree(rxr->rx_tpa[i].agg_arr);
3808 3786 rxr->rx_tpa[i].agg_arr = NULL;
3809 3787 }
@@ -3829,14 +3807,13 @@ static int bnxt_alloc_one_tpa_info(struct bnxt *bp,
3829 3807 struct rx_agg_cmp *agg;
3830 3808 int i;
3831 3809
3832 - rxr->rx_tpa = kzalloc_objs(struct bnxt_tpa_info,
3833 - bp->max_tpa_roundup_size);
3810 + rxr->rx_tpa = kzalloc_objs(struct bnxt_tpa_info, bp->max_tpa);
3834 3811 if (!rxr->rx_tpa)
3835 3812 return -ENOMEM;
3836 3813
3837 3814 if (!(bp->flags & BNXT_FLAG_CHIP_P5_PLUS))
3838 3815 return 0;
3839 - for (i = 0; i < bp->max_tpa_roundup_size; i++) {
3816 + for (i = 0; i < bp->max_tpa; i++) {
3840 3817 agg = kzalloc_objs(*agg, MAX_SKB_FRAGS);
3841 3818 if (!agg)
3842 3819 return -ENOMEM;
@@ -3855,9 +3832,6 @@ static int bnxt_alloc_tpa_info(struct bnxt *bp)
3855 3832
3856 3833 bp->max_tpa = MAX_TPA;
3857 3834 if (bp->flags & BNXT_FLAG_CHIP_P5_PLUS) {
3858 - /* TPA is not supported at all, so there is nothing to
3859 - * allocate.
3860 - */
3861 3835 if (!bp->max_tpa_v2)
3862 3836 return 0;
3863 3837 bp->max_tpa = min_t(u16, bp->max_tpa_v2, MAX_TPA_P5);
@@ -3865,7 +3839,6 @@ static int bnxt_alloc_tpa_info(struct bnxt *bp)
3865 3839 if (bp->max_tpa <= 32 && BNXT_CHIP_P5(bp) && !BNXT_NPAR(bp))
3866 3840 bp->max_tpa = MAX_TPA_P5;
3867 3841 }
3868 - bp->max_tpa_roundup_size = roundup_pow_of_two(bp->max_tpa);
3869 3842
3870 3843 for (i = 0; i < bp->rx_nr_rings; i++) {
3871 3844 struct bnxt_rx_ring_info *rxr = &bp->rx_ring[i];
@@ -4578,7 +4551,7 @@ static int bnxt_alloc_one_tpa_info_data(struct bnxt *bp,
4578 4551 u8 *data;
4579 4552 int i;
4580 4553
4581 - for (i = 0; i < bp->max_tpa_roundup_size; i++) {
4554 + for (i = 0; i < bp->max_tpa; i++) {
4582 4555 data = __bnxt_alloc_rx_frag(bp, &mapping, rxr,
4583 4556 GFP_KERNEL);
4584 4557 if (!data)
@@ -5033,8 +5006,7 @@ void bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode)
5033 5006 bnxt_get_max_rings(bp, &rx, &tx, true);
5034 5007 if (rx > 1) {
5035 5008 bp->flags &= ~BNXT_FLAG_NO_AGG_RINGS;
5036 - if (BNXT_SUPPORTS_TPA(bp))
5037 - bp->dev->hw_features |= NETIF_F_LRO;
5009 + bp->dev->hw_features |= NETIF_F_LRO;
5038 5010 }
5039 5011 }
5040 5012
@@ -5455,8 +5427,6 @@ static void bnxt_clear_ring_indices(struct bnxt *bp)
5455 5427 txr->tx_prod = 0;
5456 5428 txr->tx_cons = 0;
5457 5429 txr->tx_hw_cons = 0;
5458 - txr->kick_pending = 0;
5459 - txr->kick_txbd0 = NULL;
5460 5430 }
5461 5431
5462 5432 rxr = bnapi->rx_ring;
@@ -11370,13 +11340,8 @@ static int bnxt_shutdown_nic(struct bnxt *bp, bool irq_re_init)
11370 11340
11371 11341 static int bnxt_init_nic(struct bnxt *bp, bool irq_re_init)
11372 11342 {
11373 - int rc;
11374 -
11375 11343 bnxt_init_cp_rings(bp);
11376 - rc = bnxt_init_rx_rings(bp);
11377 - if (rc)
11378 - return rc;
11379 -
11344 + bnxt_init_rx_rings(bp);
11380 11345 bnxt_init_tx_rings(bp);
11381 11346 bnxt_init_ring_grps(bp, irq_re_init);
11382 11347 bnxt_init_vnics(bp);
@@ -11807,8 +11772,6 @@ static int bnxt_tx_queue_start(struct bnxt *bp, int idx)
11807 11772 txr->tx_prod = 0;
11808 11773 txr->tx_cons = 0;
11809 11774 txr->tx_hw_cons = 0;
11810 - txr->kick_pending = 0;
11811 - txr->kick_txbd0 = NULL;
11812 11775 start_tx:
11813 11776 WRITE_ONCE(txr->dev_state, 0);
11814 11777 synchronize_net();
@@ -14640,14 +14603,7 @@ static void bnxt_rx_ring_reset(struct bnxt *bp)
14640 14603 rxr->rx_sw_agg_prod = 0;
14641 14604 rxr->rx_next_cons = 0;
14642 14605 rxr->bnapi->in_reset = false;
14643 - rc = bnxt_alloc_one_rx_ring(bp, i);
14644 - if (rc) {
14645 - netdev_warn(bp->dev, "RX ring reset failed to allocate buffers, rc = %d, falling back to global reset\n",
14646 - rc);
14647 - bnxt_reset_task(bp, true);
14648 - bnxt_rtnl_unlock_sp(bp);
14649 - return;
14650 - }
14606 + bnxt_alloc_one_rx_ring(bp, i);
14651 14607 cpr = &rxr->bnapi->cp_ring;
14652 14608 cpr->sw_stats->rx.rx_resets++;
14653 14609 if (bp->flags & BNXT_FLAG_AGG_RINGS)
@@ -16376,8 +16332,6 @@ static int bnxt_queue_mem_alloc(struct net_device *dev,
16376 16332 clone->need_head_pool = false;
16377 16333 clone->rx_page_size = qcfg->rx_page_size;
16378 16334 clone->rx_agg_bmap = NULL;
16379 - clone->rx_tpa = NULL;
16380 - clone->rx_tpa_idx_map = NULL;
16381 16335
16382 16336 rc = bnxt_alloc_rx_page_pool(bp, clone, rxr->page_pool->p.nid);
16383 16337 if (rc)
@@ -16421,16 +16375,11 @@ static int bnxt_queue_mem_alloc(struct net_device *dev,
16421 16375 bnxt_alloc_one_rx_ring_skb(bp, clone, idx);
16422 16376 if (bp->flags & BNXT_FLAG_AGG_RINGS)
16423 16377 bnxt_alloc_one_rx_ring_netmem(bp, clone, idx);
16424 - if (bp->flags & BNXT_FLAG_TPA) {
16425 - rc = bnxt_alloc_one_tpa_info_data(bp, clone);
16426 - if (rc)
16427 - goto err_free_rx_ring_skbs;
16428 - }
16378 + if (bp->flags & BNXT_FLAG_TPA)
16379 + bnxt_alloc_one_tpa_info_data(bp, clone);
16429 16380
16430 16381 return 0;
16431 16382
16432 - err_free_rx_ring_skbs:
16433 - bnxt_free_one_rx_ring_skbs(bp, clone);
16434 16383 err_free_tpa_info:
16435 16384 bnxt_free_one_tpa_info(bp, clone);
16436 16385 err_free_rx_agg_ring:
modified drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -789,6 +789,7 @@ struct nqe_cn {
789 789
790 790 #define MAX_TPA 64
791 791 #define MAX_TPA_P5 256
792 + #define MAX_TPA_P5_MASK (MAX_TPA_P5 - 1)
792 793 #define MAX_TPA_SEGS_P5 0x3f
793 794
794 795 #if (BNXT_PAGE_SHIFT == 16)
@@ -992,7 +993,6 @@ struct bnxt_tx_ring_info {
992 993 u16 txq_index;
993 994 u8 tx_napi_idx;
994 995 u8 kick_pending;
995 - struct tx_bd *kick_txbd0;
996 996 struct bnxt_db_info tx_db;
997 997
998 998 struct tx_bd *tx_desc_ring[MAX_TX_PAGES];
@@ -2380,7 +2380,6 @@ struct bnxt {
2380 2380
2381 2381 u16 max_tpa_v2;
2382 2382 u16 max_tpa;
2383 - u16 max_tpa_roundup_size;
2384 2383 u32 rx_buf_size;
2385 2384 u32 rx_buf_use_size; /* useable size */
2386 2385 u16 rx_offset;
modified drivers/net/ethernet/broadcom/bnxt/bnxt_gso.c
@@ -31,14 +31,10 @@ static u32 bnxt_sw_gso_lhint(unsigned int len)
31 31 return TX_BD_FLAGS_LHINT_2048_AND_LARGER;
32 32 }
33 33
34 - /* Transmit an skb requiring software UDP segmentation.
35 - *
36 - * Returns 1 if the skb was queued and new BDs were produced, 0 if the skb
37 - * was dropped, or -1 if the ring is full and the skb should be retried.
38 - * The caller owns the doorbell for all three cases.
39 - */
40 - int bnxt_sw_udp_gso_xmit(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
41 - struct netdev_queue *txq, struct sk_buff *skb)
34 + netdev_tx_t bnxt_sw_udp_gso_xmit(struct bnxt *bp,
35 + struct bnxt_tx_ring_info *txr,
36 + struct netdev_queue *txq,
37 + struct sk_buff *skb)
42 38 {
43 39 unsigned int last_unmap_len __maybe_unused = 0;
44 40 dma_addr_t last_unmap_addr __maybe_unused = 0;
@@ -73,7 +69,7 @@ int bnxt_sw_udp_gso_xmit(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
73 69 if (unlikely(bnxt_tx_avail(bp, txr) < bds_needed)) {
74 70 netif_txq_try_stop(txq, bnxt_tx_avail(bp, txr),
75 71 bp->tx_wake_thresh);
76 - return -1;
72 + return NETDEV_TX_BUSY;
77 73 }
78 74
79 75 /* BD backpressure alone cannot prevent overwriting in-flight
@@ -81,7 +77,7 @@ int bnxt_sw_udp_gso_xmit(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
81 77 */
82 78 if (!netif_txq_maybe_stop(txq, bnxt_inline_avail(txr),
83 79 num_segs, num_segs))
84 - return -1;
80 + return NETDEV_TX_BUSY;
85 81
86 82 if (unlikely(tso_dma_map_init(&map, &pdev->dev, skb, hdr_len)))
87 83 goto drop;
@@ -227,15 +223,16 @@ int bnxt_sw_udp_gso_xmit(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
227 223 netdev_tx_sent_queue(txq, skb->len);
228 224
229 225 WRITE_ONCE(txr->tx_prod, prod);
226 + txr->kick_pending = 1;
230 227
231 228 if (unlikely(bnxt_tx_avail(bp, txr) <= bp->tx_wake_thresh))
232 229 netif_txq_try_stop(txq, bnxt_tx_avail(bp, txr),
233 230 bp->tx_wake_thresh);
234 231
235 - return 1;
232 + return NETDEV_TX_OK;
236 233
237 234 drop:
238 235 dev_kfree_skb_any(skb);
239 236 dev_core_stats_tx_dropped_inc(bp->dev);
240 - return 0;
237 + return NETDEV_TX_OK;
241 238 }
modified drivers/net/ethernet/broadcom/bnxt/bnxt_gso.h
@@ -38,7 +38,9 @@ static inline int bnxt_min_tx_desc_cnt(struct bnxt *bp,
38 38 return BNXT_MIN_TX_DESC_CNT;
39 39 }
40 40
41 - int bnxt_sw_udp_gso_xmit(struct bnxt *bp, struct bnxt_tx_ring_info *txr,
42 - struct netdev_queue *txq, struct sk_buff *skb);
41 + netdev_tx_t bnxt_sw_udp_gso_xmit(struct bnxt *bp,
42 + struct bnxt_tx_ring_info *txr,
43 + struct netdev_queue *txq,
44 + struct sk_buff *skb);
43 45
44 46 #endif
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
@@ -1164,8 +1164,6 @@ static int macb_mii_init(struct macb *bp)
1164 1164 if (err)
1165 1165 goto err_out_unregister_bus;
1166 1166
1167 - of_node_put(mdio_np);
1168 -
1169 1167 return 0;
1170 1168
1171 1169 err_out_unregister_bus:
@@ -1324,8 +1322,8 @@ static void macb_tx_error_task(struct work_struct *work)
1324 1322 bp->netdev->stats.tx_packets++;
1325 1323 queue->stats.tx_packets++;
1326 1324 packets++;
1327 - bp->netdev->stats.tx_bytes += skb->len - tx_skb->fcs_len;
1328 - 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;
1329 1327 bytes += skb->len;
1330 1328 }
1331 1329 } else {
@@ -1452,8 +1450,8 @@ static int macb_tx_complete(struct macb_queue *queue, int budget)
1452 1450 skb->data);
1453 1451 bp->netdev->stats.tx_packets++;
1454 1452 queue->stats.tx_packets++;
1455 - bp->netdev->stats.tx_bytes += skb->len - tx_skb->fcs_len;
1456 - 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;
1457 1455 packets++;
1458 1456 bytes += skb->len;
1459 1457 }
@@ -2201,8 +2199,7 @@ static void macb_poll_controller(struct net_device *netdev)
2201 2199 static unsigned int macb_tx_map(struct macb *bp,
2202 2200 struct macb_queue *queue,
2203 2201 struct sk_buff *skb,
2204 - unsigned int hdrlen,
2205 - u8 fcs_len)
2202 + unsigned int hdrlen)
2206 2203 {
2207 2204 unsigned int f, nr_frags = skb_shinfo(skb)->nr_frags;
2208 2205 unsigned int len, i, tx_head = queue->tx_head;
@@ -2287,7 +2284,6 @@ static unsigned int macb_tx_map(struct macb *bp,
2287 2284
2288 2285 /* This is the last buffer of the frame: save socket buffer */
2289 2286 tx_skb->skb = skb;
2290 - tx_skb->fcs_len = fcs_len;
2291 2287
2292 2288 /* Update TX ring: update buffer descriptors in reverse order
2293 2289 * to avoid race condition
@@ -2421,7 +2417,6 @@ static inline int macb_clear_csum(struct sk_buff *skb)
2421 2417 return 0;
2422 2418 }
2423 2419
2424 - /* Returns a negative errno, or the FCS bytes appended (0 or ETH_FCS_LEN). */
2425 2420 static int macb_pad_and_fcs(struct sk_buff **skb, struct net_device *netdev)
2426 2421 {
2427 2422 bool cloned = skb_cloned(*skb) || skb_header_cloned(*skb) ||
@@ -2470,7 +2465,7 @@ add_fcs:
2470 2465 skb_put_u8(*skb, (fcs >> 16) & 0xff);
2471 2466 skb_put_u8(*skb, (fcs >> 24) & 0xff);
2472 2467
2473 - return ETH_FCS_LEN;
2468 + return 0;
2474 2469 }
2475 2470
2476 2471 static netdev_tx_t macb_start_xmit(struct sk_buff *skb,
@@ -2483,7 +2478,6 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb,
2483 2478 netdev_tx_t ret = NETDEV_TX_OK;
2484 2479 unsigned int hdrlen;
2485 2480 unsigned long flags;
2486 - int fcs_len;
2487 2481 bool is_lso;
2488 2482
2489 2483 if (macb_clear_csum(skb)) {
@@ -2491,8 +2485,7 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb,
2491 2485 return ret;
2492 2486 }
2493 2487
2494 - fcs_len = macb_pad_and_fcs(&skb, netdev);
2495 - if (fcs_len < 0) {
2488 + if (macb_pad_and_fcs(&skb, netdev)) {
2496 2489 dev_kfree_skb_any(skb);
2497 2490 return ret;
2498 2491 }
@@ -2555,7 +2548,7 @@ static netdev_tx_t macb_start_xmit(struct sk_buff *skb,
2555 2548 }
2556 2549
2557 2550 /* Map socket buffer for DMA transfer */
2558 - if (macb_tx_map(bp, queue, skb, hdrlen, fcs_len)) {
2551 + if (macb_tx_map(bp, queue, skb, hdrlen)) {
2559 2552 dev_kfree_skb_any(skb);
2560 2553 goto unlock;
2561 2554 }
@@ -4302,9 +4295,9 @@ static int macb_taprio_setup_replace(struct net_device *netdev,
4302 4295 u64 total_on_time = 0, start_time_sec = 0, start_time = conf->base_time;
4303 4296 u32 configured_queues = 0, speed = 0, start_time_nsec;
4304 4297 struct macb_queue_enst_config *enst_queue;
4305 - struct ethtool_link_ksettings kset = {};
4306 - struct macb *bp = netdev_priv(netdev);
4307 4298 struct tc_taprio_sched_entry *entry;
4299 + struct macb *bp = netdev_priv(netdev);
4300 + struct ethtool_link_ksettings kset;
4308 4301 struct macb_queue *queue;
4309 4302 u32 queue_mask;
4310 4303 u8 queue_id;
@@ -4331,12 +4324,12 @@ static int macb_taprio_setup_replace(struct net_device *netdev,
4331 4324 }
4332 4325
4333 4326 speed = kset.base.speed;
4334 - if (unlikely(speed == SPEED_UNKNOWN || !speed)) {
4335 - netdev_err(netdev, "Invalid speed %d, link-down?\n", speed);
4327 + if (unlikely(speed <= 0)) {
4328 + netdev_err(netdev, "Invalid speed: %d\n", speed);
4336 4329 return -EINVAL;
4337 4330 }
4338 4331
4339 - enst_queue = kzalloc_objs(*enst_queue, conf->num_entries);
4332 + enst_queue = kcalloc(conf->num_entries, sizeof(*enst_queue), GFP_KERNEL);
4340 4333 if (unlikely(!enst_queue))
4341 4334 return -ENOMEM;
4342 4335
@@ -5883,7 +5876,6 @@ static int macb_probe(struct platform_device *pdev)
5883 5876 }
5884 5877 spin_lock_init(&bp->lock);
5885 5878 spin_lock_init(&bp->stats_lock);
5886 - spin_lock_init(&bp->tsu_clk_lock);
5887 5879
5888 5880 /* setup capabilities */
5889 5881 macb_configure_caps(bp, macb_config);
@@ -5979,11 +5971,8 @@ err_out_free_tieoff:
5979 5971 macb_free_tieoff(bp);
5980 5972
5981 5973 err_out_unregister_mdio:
5982 - if (bp->mii_bus) {
5983 - mdiobus_unregister(bp->mii_bus);
5984 - mdiobus_free(bp->mii_bus);
5985 - }
5986 - phylink_destroy(bp->phylink);
5974 + mdiobus_unregister(bp->mii_bus);
5975 + mdiobus_free(bp->mii_bus);
5987 5976
5988 5977 err_out_phy_exit:
5989 5978 phy_exit(bp->phy);
@@ -6012,10 +6001,8 @@ static void macb_remove(struct platform_device *pdev)
6012 6001 unregister_netdev(netdev);
6013 6002 macb_free_tieoff(bp);
6014 6003 phy_exit(bp->phy);
6015 - if (bp->mii_bus) {
6016 - mdiobus_unregister(bp->mii_bus);
6017 - mdiobus_free(bp->mii_bus);
6018 - }
6004 + mdiobus_unregister(bp->mii_bus);
6005 + mdiobus_free(bp->mii_bus);
6019 6006
6020 6007 device_set_wakeup_enable(&bp->pdev->dev, 0);
6021 6008 cancel_delayed_work_sync(&bp->tx_lpi_work);
modified drivers/net/ethernet/cadence/macb_ptp.c
@@ -334,7 +334,6 @@ void gem_ptp_init(struct net_device *netdev)
334 334 bp->tsu_rate = bp->ptp_info->get_tsu_rate(bp);
335 335 bp->ptp_clock_info.max_adj = bp->ptp_info->get_ptp_max_adj();
336 336 gem_ptp_init_timer(bp);
337 - gem_ptp_init_tsu(bp);
338 337 bp->ptp_clock = ptp_clock_register(&bp->ptp_clock_info, &netdev->dev);
339 338 if (IS_ERR(bp->ptp_clock)) {
340 339 pr_err("ptp clock register failed: %ld\n",
@@ -346,6 +345,10 @@ void gem_ptp_init(struct net_device *netdev)
346 345 return;
347 346 }
348 347
348 + spin_lock_init(&bp->tsu_clk_lock);
349 +
350 + gem_ptp_init_tsu(bp);
351 +
349 352 dev_info(&bp->pdev->dev, "%s ptp clock registered.\n",
350 353 GEM_PTP_TIMER_NAME);
351 354 }
modified drivers/net/ethernet/cisco/enic/enic.h
@@ -137,12 +137,6 @@ struct enic_port_profile {
137 137 u8 mac_addr[ETH_ALEN];
138 138 };
139 139
140 - enum enic_vf_link_state {
141 - ENIC_VF_LINK_STATE_UNKNOWN,
142 - ENIC_VF_LINK_STATE_DOWN,
143 - ENIC_VF_LINK_STATE_UP,
144 - };
145 -
146 140 /* enic_rfs_fltr_node - rfs filter node in hash table
147 141 * @@keys: IPv4 5 tuple
148 142 * @flow_id: flow_id of clsf filter provided by kernel
@@ -318,25 +312,19 @@ struct enic {
318 312 unsigned int admin_msg_count; /* current depth of admin_msg_list */
319 313 void (*admin_rq_handler)(struct enic *enic, void *buf,
320 314 unsigned int len);
321 - /* The PF is authoritative for a V2 VF's carrier. Keep the last
322 - * notification across an ordinary netdev close/open and serialize it
323 - * against the open/stop carrier transition.
324 - */
325 - spinlock_t vf_link_state_lock;
326 - enum enic_vf_link_state vf_link_state;
327 - bool vf_link_running;
328 315
329 316 /* MBOX protocol state — mbox_lock serializes admin WQ sends */
330 317 struct mutex mbox_lock;
331 318 u64 mbox_msg_num;
332 - /* MBOX request-reply state. Existing request callers allow only one
333 - * request in flight. The state lock arbitrates reply acceptance against
334 - * timeout invalidation, while mbox_comp publishes the accepted result to
335 - * the requester.
319 + /* MBOX request-reply state. mbox_expected_reply is written and
320 + * cleared by the process-context request helpers (capability/register/
321 + * unregister) and only read by the admin_msg_work receive handlers, so
322 + * it is annotated with READ_ONCE()/WRITE_ONCE() rather than locked:
323 + * only one request is in flight at a time (requesters run under RTNL or
324 + * single-threaded probe/remove), so each request is serialized and its
325 + * reply completes mbox_comp before the next request is issued.
336 326 */
337 327 struct completion mbox_comp;
338 - spinlock_t mbox_state_lock; /* protects expected reply state */
339 - u64 mbox_expected_msg_num;
340 328 u8 mbox_expected_reply;
341 329 bool mbox_initialized;
342 330
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
@@ -1800,8 +1800,6 @@ static int enic_open(struct net_device *netdev)
1800 1800
1801 1801 enic_notify_timer_start(enic);
1802 1802 enic_rfs_timer_start(enic);
1803 - if (enic_is_sriov_vf_v2(enic))
1804 - enic_mbox_vf_link_state_set_running(enic, true);
1805 1803
1806 1804 return 0;
1807 1805
@@ -1855,10 +1853,7 @@ static int enic_stop(struct net_device *netdev)
1855 1853 for (i = 0; i < enic->rq_count; i++)
1856 1854 napi_disable(&enic->napi[i]);
1857 1855
1858 - if (enic_is_sriov_vf_v2(enic))
1859 - enic_mbox_vf_link_state_set_running(enic, false);
1860 - else
1861 - netif_carrier_off(netdev);
1856 + netif_carrier_off(netdev);
1862 1857 if (vnic_dev_get_intr_mode(enic->vdev) == VNIC_DEV_INTR_MODE_MSIX)
1863 1858 for (i = 0; i < enic->wq_count; i++)
1864 1859 napi_disable(&enic->napi[enic_cq_wq(enic, i)]);
@@ -2206,10 +2201,9 @@ static void enic_admin_chan_reopen(struct enic *enic)
2206 2201 {
2207 2202 int err;
2208 2203
2209 - /* Install the MBOX receive handler and clear pending reply state before
2210 - * opening the channel, so the handler is in place before the admin
2211 - * interrupt is unmasked and no early completion is dropped. Keep the
2212 - * sequence number monotonic across channel generations.
2204 + /* Install the MBOX receive handler and reset the sequence number
2205 + * before opening the channel, so the handler is in place before the
2206 + * admin interrupt is unmasked and no early completion is dropped.
2213 2207 */
2214 2208 enic_mbox_init(enic);
2215 2209
@@ -2221,7 +2215,7 @@ static void enic_admin_chan_reopen(struct enic *enic)
2221 2215 * registration over a dead channel.
2222 2216 */
2223 2217 if (enic_is_sriov_vf_v2(enic))
2224 - WRITE_ONCE(enic->vf_registered, false);
2218 + enic->vf_registered = false;
2225 2219
2226 2220 err = enic_admin_channel_open(enic);
2227 2221 if (err) {
@@ -2277,8 +2271,6 @@ static void enic_reset(struct work_struct *work)
2277 2271 enic_admin_channel_close(enic);
2278 2272
2279 2273 enic_stop(enic->netdev);
2280 - if (enic_is_sriov_vf_v2(enic))
2281 - enic_mbox_vf_link_state_reset(enic);
2282 2274
2283 2275 enic_dev_soft_reset(enic);
2284 2276 enic_reset_addr_lists(enic);
@@ -2323,8 +2315,6 @@ static void enic_tx_hang_reset(struct work_struct *work)
2323 2315
2324 2316 enic_dev_hang_notify(enic);
2325 2317 enic_stop(enic->netdev);
2326 - if (enic_is_sriov_vf_v2(enic))
2327 - enic_mbox_vf_link_state_reset(enic);
2328 2318
2329 2319 enic_dev_hang_reset(enic);
2330 2320 enic_reset_addr_lists(enic);
@@ -2868,7 +2858,7 @@ enic_sriov_v2_enable(struct enic *enic, int num_vfs)
2868 2858 return -EOPNOTSUPP;
2869 2859 }
2870 2860
2871 - enic->vf_state = kzalloc_objs(*enic->vf_state, num_vfs);
2861 + enic->vf_state = kcalloc(num_vfs, sizeof(*enic->vf_state), GFP_KERNEL);
2872 2862 if (!enic->vf_state)
2873 2863 return -ENOMEM;
2874 2864
@@ -2956,7 +2946,7 @@ enic_sriov_configure(struct pci_dev *pdev, int num_vfs)
2956 2946 if (enic->vf_type == ENIC_VF_TYPE_V2)
2957 2947 return enic_sriov_v2_enable(enic, num_vfs);
2958 2948
2959 - pp = kzalloc_objs(*pp, num_vfs);
2949 + pp = kcalloc(num_vfs, sizeof(*pp), GFP_KERNEL);
2960 2950 if (!pp)
2961 2951 return -ENOMEM;
2962 2952
@@ -2981,7 +2971,7 @@ enic_sriov_configure(struct pci_dev *pdev, int num_vfs)
2981 2971 return 0;
2982 2972 }
2983 2973
2984 - pp = kzalloc_obj(*enic->pp);
2974 + pp = kzalloc_obj(*enic->pp, GFP_KERNEL);
2985 2975 if (!pp)
2986 2976 return -ENOMEM;
2987 2977
@@ -3025,7 +3015,6 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3025 3015 enic = netdev_priv(netdev);
3026 3016 enic->netdev = netdev;
3027 3017 enic->pdev = pdev;
3028 - spin_lock_init(&enic->vf_link_state_lock);
3029 3018
3030 3019 /* Setup PCI resources
3031 3020 */
@@ -3350,7 +3339,7 @@ static int enic_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
3350 3339
3351 3340 err_out_admin_close:
3352 3341 if (enic_is_sriov_vf_v2(enic)) {
3353 - if (READ_ONCE(enic->vf_registered)) {
3342 + if (enic->vf_registered) {
3354 3343 int unreg_err = enic_mbox_vf_unregister(enic);
3355 3344
3356 3345 if (unreg_err)
@@ -3403,7 +3392,7 @@ static void enic_remove(struct pci_dev *pdev)
3403 3392 * touching a netdev that is being torn down.
3404 3393 */
3405 3394 if (enic_is_sriov_vf_v2(enic)) {
3406 - if (READ_ONCE(enic->vf_registered)) {
3395 + if (enic->vf_registered) {
3407 3396 int unreg_err = enic_mbox_vf_unregister(enic);
3408 3397
3409 3398 if (unreg_err)
modified drivers/net/ethernet/cisco/enic/enic_mbox.c
@@ -18,25 +18,22 @@
18 18 #define ENIC_MBOX_POLL_TIMEOUT_US 5000000
19 19 #define ENIC_MBOX_POLL_INTERVAL_US 100
20 20
21 - static void enic_mbox_fill_hdr(struct enic_mbox_hdr *hdr, u8 msg_type,
22 - u16 dst_vnic_id, u16 msg_len, u64 msg_num)
21 + static void enic_mbox_fill_hdr(struct enic *enic, struct enic_mbox_hdr *hdr,
22 + u8 msg_type, u16 dst_vnic_id, u16 msg_len)
23 23 {
24 24 memset(hdr, 0, sizeof(*hdr));
25 25 hdr->dst_vnic_id = cpu_to_le16(dst_vnic_id);
26 26 hdr->msg_type = msg_type;
27 27 hdr->msg_len = cpu_to_le16(msg_len);
28 - hdr->msg_num = cpu_to_le64(msg_num);
28 + hdr->msg_num = cpu_to_le64(++enic->mbox_msg_num);
29 29 }
30 30
31 - static int enic_mbox_send_msg_id(struct enic *enic, u8 msg_type,
32 - u16 dst_vnic_id, void *payload,
33 - u16 payload_len, u64 msg_num, bool reuse_msg_num,
34 - u8 expected_reply)
31 + int enic_mbox_send_msg(struct enic *enic, u8 msg_type, u16 dst_vnic_id,
32 + void *payload, u16 payload_len)
35 33 {
36 34 size_t total_len = sizeof(struct enic_mbox_hdr) + payload_len;
37 35 struct vnic_wq *wq = &enic->admin_wq;
38 36 struct wq_enet_desc *desc;
39 - bool reply_expected = false;
40 37 unsigned long timeout;
41 38 dma_addr_t dma_addr;
42 39 u16 vlan_tag;
@@ -71,21 +68,7 @@ static int enic_mbox_send_msg_id(struct enic *enic, u8 msg_type,
71 68 goto unlock;
72 69 }
73 70
74 - /* Replies reuse the initiating message number. Requests and
75 - * notifications allocate a new one.
76 - */
77 - if (!reuse_msg_num)
78 - msg_num = ++enic->mbox_msg_num;
79 - if (expected_reply) {
80 - reinit_completion(&enic->mbox_comp);
81 - spin_lock_bh(&enic->mbox_state_lock);
82 - enic->mbox_expected_reply = expected_reply;
83 - enic->mbox_expected_msg_num = msg_num;
84 - spin_unlock_bh(&enic->mbox_state_lock);
85 - reply_expected = true;
86 - }
87 -
88 - enic_mbox_fill_hdr(buf, msg_type, dst_vnic_id, total_len, msg_num);
71 + enic_mbox_fill_hdr(enic, buf, msg_type, dst_vnic_id, total_len);
89 72 if (payload_len) {
90 73 void *dst = buf + sizeof(struct enic_mbox_hdr);
91 74
@@ -156,66 +139,18 @@ static int enic_mbox_send_msg_id(struct enic *enic, u8 msg_type,
156 139 "MBOX send msg_type %u dst %u vlan %u err %d\n",
157 140 msg_type, dst_vnic_id, vlan_tag, err);
158 141 unlock:
159 - if (err && reply_expected) {
160 - spin_lock_bh(&enic->mbox_state_lock);
161 - if (enic->mbox_expected_reply == expected_reply &&
162 - enic->mbox_expected_msg_num == msg_num) {
163 - enic->mbox_expected_reply = 0;
164 - enic->mbox_expected_msg_num = 0;
165 - }
166 - spin_unlock_bh(&enic->mbox_state_lock);
167 - }
168 142 mutex_unlock(&enic->mbox_lock);
169 143 return err;
170 144 }
171 145
172 - int enic_mbox_send_msg(struct enic *enic, u8 msg_type, u16 dst_vnic_id,
173 - void *payload, u16 payload_len)
174 - {
175 - return enic_mbox_send_msg_id(enic, msg_type, dst_vnic_id, payload,
176 - payload_len, 0, false, 0);
177 - }
178 -
179 - static int enic_mbox_send_reply(struct enic *enic, u8 msg_type,
180 - u16 dst_vnic_id, void *payload, u16 payload_len,
181 - u64 msg_num)
182 - {
183 - return enic_mbox_send_msg_id(enic, msg_type, dst_vnic_id, payload,
184 - payload_len, msg_num, true, 0);
185 - }
186 -
187 - static int enic_mbox_vf_send_request(struct enic *enic, u8 request_type,
188 - u8 expected_reply, void *payload,
189 - u16 payload_len)
190 - {
191 - return enic_mbox_send_msg_id(enic, request_type, ENIC_MBOX_DST_PF,
192 - payload, payload_len, 0, false,
193 - expected_reply);
194 - }
195 -
196 146 static int enic_mbox_wait_reply(struct enic *enic, unsigned long timeout_ms)
197 147 {
198 148 unsigned long left;
199 - int err = 0;
200 149
201 150 left = wait_for_completion_timeout(&enic->mbox_comp,
202 151 msecs_to_jiffies(timeout_ms));
203 - if (left)
204 - return 0;
205 -
206 - /* Invalidate a request that the handler has not already accepted. A
207 - * delayed reply cannot match a later request because message numbers are
208 - * monotonic across channel reopen.
209 - */
210 - spin_lock_bh(&enic->mbox_state_lock);
211 - if (enic->mbox_expected_reply) {
212 - enic->mbox_expected_reply = 0;
213 - enic->mbox_expected_msg_num = 0;
214 - err = -ETIMEDOUT;
215 - }
216 - spin_unlock_bh(&enic->mbox_state_lock);
217 152
218 - return err;
153 + return left ? 0 : -ETIMEDOUT;
219 154 }
220 155
221 156 int enic_mbox_send_link_state(struct enic *enic, u16 vf_id, u32 link_state)
@@ -243,8 +178,8 @@ static int enic_mbox_pf_handle_capability(struct enic *enic, void *msg,
243 178 reply.reply.ret_major = cpu_to_le16(0);
244 179 reply.version = cpu_to_le32(ENIC_MBOX_CAP_VERSION_1);
245 180
246 - return enic_mbox_send_reply(enic, ENIC_MBOX_VF_CAPABILITY_REPLY, vf_id,
247 - &reply, sizeof(reply), msg_num);
181 + return enic_mbox_send_msg(enic, ENIC_MBOX_VF_CAPABILITY_REPLY, vf_id,
182 + &reply, sizeof(reply));
248 183 }
249 184
250 185 static int enic_mbox_pf_handle_register(struct enic *enic, void *msg,
@@ -273,8 +208,8 @@ static int enic_mbox_pf_handle_register(struct enic *enic, void *msg,
273 208 }
274 209
275 210 reply.reply.ret_major = cpu_to_le16(0);
276 - err = enic_mbox_send_reply(enic, ENIC_MBOX_VF_REGISTER_REPLY, vf_id,
277 - &reply, sizeof(reply), msg_num);
211 + err = enic_mbox_send_msg(enic, ENIC_MBOX_VF_REGISTER_REPLY, vf_id,
212 + &reply, sizeof(reply));
278 213 if (err)
279 214 return err;
280 215
@@ -318,8 +253,8 @@ static int enic_mbox_pf_handle_unregister(struct enic *enic, void *msg,
318 253 enic->vf_state[vf_id].registered = false;
319 254
320 255 reply.reply.ret_major = cpu_to_le16(0);
321 - err = enic_mbox_send_reply(enic, ENIC_MBOX_VF_UNREGISTER_REPLY, vf_id,
322 - &reply, sizeof(reply), msg_num);
256 + err = enic_mbox_send_msg(enic, ENIC_MBOX_VF_UNREGISTER_REPLY, vf_id,
257 + &reply, sizeof(reply));
323 258
324 259 if (net_ratelimit())
325 260 netdev_info(enic->netdev,
@@ -389,116 +324,105 @@ static void enic_mbox_pf_process_msg(struct enic *enic,
389 324 hdr->msg_type, vf_id, err);
390 325 }
391 326
392 - static void enic_mbox_vf_handle_reply(struct enic *enic, u8 reply_type,
393 - void *payload, u64 msg_num)
327 + static void enic_mbox_vf_handle_capability_reply(struct enic *enic,
328 + void *payload)
394 329 {
395 - struct enic_mbox_generic_reply *reply = payload;
396 - u16 ret_major = le16_to_cpu(reply->ret_major);
397 - u64 expected_msg_num;
398 - u8 expected_type;
399 -
400 - spin_lock_bh(&enic->mbox_state_lock);
401 - expected_type = enic->mbox_expected_reply;
402 - expected_msg_num = enic->mbox_expected_msg_num;
403 - if (expected_type != reply_type || expected_msg_num != msg_num) {
404 - spin_unlock_bh(&enic->mbox_state_lock);
330 + struct enic_mbox_vf_capability_reply_msg *reply = payload;
331 +
332 + if (READ_ONCE(enic->mbox_expected_reply) != ENIC_MBOX_VF_CAPABILITY_REPLY) {
405 333 netdev_warn(enic->netdev,
406 - "MBOX: stale reply %u/%llu (expected %u/%llu), drop\n",
407 - reply_type, (unsigned long long)msg_num,
408 - expected_type, (unsigned long long)expected_msg_num);
334 + "MBOX: stale capability reply (expected %u), drop\n",
335 + READ_ONCE(enic->mbox_expected_reply));
409 336 return;
410 337 }
411 338
412 - if (!ret_major) {
413 - switch (reply_type) {
414 - case ENIC_MBOX_VF_CAPABILITY_REPLY: {
415 - struct enic_mbox_vf_capability_reply_msg *cap = payload;
339 + if (le16_to_cpu(reply->reply.ret_major) == 0)
340 + enic->pf_cap_version = le32_to_cpu(reply->version);
341 + else
342 + netdev_warn(enic->netdev,
343 + "MBOX: PF rejected capability request: %u/%u\n",
344 + le16_to_cpu(reply->reply.ret_major),
345 + le16_to_cpu(reply->reply.ret_minor));
346 + complete(&enic->mbox_comp);
347 + }
416 348
417 - WRITE_ONCE(enic->pf_cap_version,
418 - le32_to_cpu(cap->version));
419 - break;
420 - }
421 - case ENIC_MBOX_VF_REGISTER_REPLY:
422 - WRITE_ONCE(enic->vf_registered, true);
423 - break;
424 - case ENIC_MBOX_VF_UNREGISTER_REPLY:
425 - WRITE_ONCE(enic->vf_registered, false);
426 - break;
427 - }
349 + static void enic_mbox_vf_handle_register_reply(struct enic *enic,
350 + void *payload)
351 + {
352 + struct enic_mbox_vf_register_reply_msg *reply = payload;
353 +
354 + if (READ_ONCE(enic->mbox_expected_reply) != ENIC_MBOX_VF_REGISTER_REPLY) {
355 + netdev_warn(enic->netdev,
356 + "MBOX: stale register reply (expected %u), drop\n",
357 + READ_ONCE(enic->mbox_expected_reply));
358 + return;
359 + }
360 +
361 + if (le16_to_cpu(reply->reply.ret_major)) {
362 + netdev_warn(enic->netdev,
363 + "MBOX: VF register rejected by PF: %u/%u\n",
364 + le16_to_cpu(reply->reply.ret_major),
365 + le16_to_cpu(reply->reply.ret_minor));
366 + } else {
367 + enic->vf_registered = true;
428 368 }
429 - enic->mbox_expected_reply = 0;
430 - enic->mbox_expected_msg_num = 0;
431 369 complete(&enic->mbox_comp);
432 - spin_unlock_bh(&enic->mbox_state_lock);
370 + }
433 371
434 - if (ret_major)
372 + static void enic_mbox_vf_handle_unregister_reply(struct enic *enic,
373 + void *payload)
374 + {
375 + struct enic_mbox_vf_register_reply_msg *reply = payload;
376 +
377 + if (READ_ONCE(enic->mbox_expected_reply) != ENIC_MBOX_VF_UNREGISTER_REPLY) {
435 378 netdev_warn(enic->netdev,
436 - "MBOX: PF rejected reply type %u: %u/%u\n",
437 - reply_type, ret_major,
438 - le16_to_cpu(reply->ret_minor));
379 + "MBOX: stale unregister reply (expected %u), drop\n",
380 + READ_ONCE(enic->mbox_expected_reply));
381 + return;
382 + }
383 +
384 + if (le16_to_cpu(reply->reply.ret_major)) {
385 + netdev_warn(enic->netdev,
386 + "MBOX: VF unregister rejected by PF: %u/%u\n",
387 + le16_to_cpu(reply->reply.ret_major),
388 + le16_to_cpu(reply->reply.ret_minor));
389 + } else {
390 + enic->vf_registered = false;
391 + }
392 + complete(&enic->mbox_comp);
439 393 }
440 394
441 - static void enic_mbox_vf_handle_link_state(struct enic *enic, void *payload,
442 - u64 msg_num)
395 + static void enic_mbox_vf_handle_link_state(struct enic *enic, void *payload)
443 396 {
444 397 struct enic_mbox_pf_link_state_notif_msg *notif = payload;
445 398 struct enic_mbox_pf_link_state_ack_msg ack = {};
446 - u32 link_state = le32_to_cpu(notif->link_state);
447 399 int err;
448 400
449 - spin_lock_bh(&enic->vf_link_state_lock);
450 - switch (link_state) {
401 + switch (le32_to_cpu(notif->link_state)) {
451 402 case ENIC_MBOX_LINK_STATE_ENABLE:
452 - enic->vf_link_state = ENIC_VF_LINK_STATE_UP;
453 - if (enic->vf_link_running &&
454 - !netif_carrier_ok(enic->netdev))
403 + if (!netif_carrier_ok(enic->netdev))
455 404 netif_carrier_on(enic->netdev);
456 405 netdev_dbg(enic->netdev, "MBOX: link state -> UP\n");
457 406 break;
458 407 case ENIC_MBOX_LINK_STATE_DISABLE:
459 - enic->vf_link_state = ENIC_VF_LINK_STATE_DOWN;
460 - if (enic->vf_link_running &&
461 - netif_carrier_ok(enic->netdev))
408 + if (netif_carrier_ok(enic->netdev))
462 409 netif_carrier_off(enic->netdev);
463 410 netdev_dbg(enic->netdev, "MBOX: link state -> DOWN\n");
464 411 break;
465 412 default:
466 413 netdev_warn(enic->netdev, "MBOX: unknown link state %u\n",
467 - link_state);
414 + le32_to_cpu(notif->link_state));
468 415 ack.ack.ret_major = cpu_to_le16(ENIC_MBOX_ERR_GENERIC);
469 416 break;
470 417 }
471 - spin_unlock_bh(&enic->vf_link_state_lock);
472 418
473 - err = enic_mbox_send_reply(enic, ENIC_MBOX_PF_LINK_STATE_ACK,
474 - ENIC_MBOX_DST_PF, &ack, sizeof(ack), msg_num);
419 + err = enic_mbox_send_msg(enic, ENIC_MBOX_PF_LINK_STATE_ACK,
420 + ENIC_MBOX_DST_PF, &ack, sizeof(ack));
475 421 if (err && net_ratelimit())
476 422 netdev_warn(enic->netdev,
477 423 "MBOX: failed to send link state ACK: %d\n", err);
478 424 }
479 425
480 - void enic_mbox_vf_link_state_reset(struct enic *enic)
481 - {
482 - spin_lock_bh(&enic->vf_link_state_lock);
483 - enic->vf_link_state = ENIC_VF_LINK_STATE_UNKNOWN;
484 - if (enic->vf_link_running && netif_carrier_ok(enic->netdev))
485 - netif_carrier_off(enic->netdev);
486 - spin_unlock_bh(&enic->vf_link_state_lock);
487 - }
488 -
489 - void enic_mbox_vf_link_state_set_running(struct enic *enic, bool running)
490 - {
491 - spin_lock_bh(&enic->vf_link_state_lock);
492 - enic->vf_link_running = running;
493 - if (running && enic->vf_link_state == ENIC_VF_LINK_STATE_UP) {
494 - if (!netif_carrier_ok(enic->netdev))
495 - netif_carrier_on(enic->netdev);
496 - } else if (netif_carrier_ok(enic->netdev)) {
497 - netif_carrier_off(enic->netdev);
498 - }
499 - spin_unlock_bh(&enic->vf_link_state_lock);
500 - }
501 -
502 426 static bool enic_mbox_vf_payload_ok(struct enic *enic, u8 msg_type,
503 427 u16 payload_len, size_t min_len)
504 428 {
@@ -515,8 +439,6 @@ static void enic_mbox_vf_process_msg(struct enic *enic,
515 439 struct enic_mbox_hdr *hdr, void *payload,
516 440 u16 payload_len)
517 441 {
518 - u64 msg_num = le64_to_cpu(hdr->msg_num);
519 -
520 442 switch (hdr->msg_type) {
521 443 case ENIC_MBOX_VF_CAPABILITY_REPLY: {
522 444 size_t exp = sizeof(struct enic_mbox_vf_capability_reply_msg);
@@ -524,7 +446,7 @@ static void enic_mbox_vf_process_msg(struct enic *enic,
524 446 if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type,
525 447 payload_len, exp))
526 448 return;
527 - enic_mbox_vf_handle_reply(enic, hdr->msg_type, payload, msg_num);
449 + enic_mbox_vf_handle_capability_reply(enic, payload);
528 450 break;
529 451 }
530 452 case ENIC_MBOX_VF_REGISTER_REPLY: {
@@ -533,7 +455,7 @@ static void enic_mbox_vf_process_msg(struct enic *enic,
533 455 if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type,
534 456 payload_len, exp))
535 457 return;
536 - enic_mbox_vf_handle_reply(enic, hdr->msg_type, payload, msg_num);
458 + enic_mbox_vf_handle_register_reply(enic, payload);
537 459 break;
538 460 }
539 461 case ENIC_MBOX_VF_UNREGISTER_REPLY: {
@@ -542,7 +464,7 @@ static void enic_mbox_vf_process_msg(struct enic *enic,
542 464 if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type,
543 465 payload_len, exp))
544 466 return;
545 - enic_mbox_vf_handle_reply(enic, hdr->msg_type, payload, msg_num);
467 + enic_mbox_vf_handle_unregister_reply(enic, payload);
546 468 break;
547 469 }
548 470 case ENIC_MBOX_PF_LINK_STATE_NOTIF: {
@@ -551,7 +473,7 @@ static void enic_mbox_vf_process_msg(struct enic *enic,
551 473 if (!enic_mbox_vf_payload_ok(enic, hdr->msg_type,
552 474 payload_len, exp))
553 475 return;
554 - enic_mbox_vf_handle_link_state(enic, payload, msg_num);
476 + enic_mbox_vf_handle_link_state(enic, payload);
555 477 break;
556 478 }
557 479 default:
@@ -620,31 +542,32 @@ static void enic_mbox_recv_handler(struct enic *enic, void *buf,
620 542 int enic_mbox_vf_capability_check(struct enic *enic)
621 543 {
622 544 struct enic_mbox_vf_capability_msg req = {};
623 - u32 version;
624 545 int err;
625 546
626 - WRITE_ONCE(enic->pf_cap_version, 0);
547 + enic->pf_cap_version = 0;
548 + reinit_completion(&enic->mbox_comp);
549 + WRITE_ONCE(enic->mbox_expected_reply, ENIC_MBOX_VF_CAPABILITY_REPLY);
627 550 req.version = cpu_to_le32(ENIC_MBOX_CAP_VERSION_1);
628 551
629 - err = enic_mbox_vf_send_request(enic,
630 - ENIC_MBOX_VF_CAPABILITY_REQUEST,
631 - ENIC_MBOX_VF_CAPABILITY_REPLY,
632 - &req, sizeof(req));
633 - if (err)
552 + err = enic_mbox_send_msg(enic, ENIC_MBOX_VF_CAPABILITY_REQUEST,
553 + ENIC_MBOX_DST_PF, &req, sizeof(req));
554 + if (err) {
555 + WRITE_ONCE(enic->mbox_expected_reply, 0);
634 556 return err;
557 + }
635 558
636 559 err = enic_mbox_wait_reply(enic, 3000);
637 - version = READ_ONCE(enic->pf_cap_version);
560 + WRITE_ONCE(enic->mbox_expected_reply, 0);
638 561 if (err) {
639 562 netdev_warn(enic->netdev,
640 563 "MBOX: no capability reply from PF\n");
641 564 return err;
642 565 }
643 566
644 - if (version < ENIC_MBOX_CAP_VERSION_1) {
567 + if (enic->pf_cap_version < ENIC_MBOX_CAP_VERSION_1) {
645 568 netdev_warn(enic->netdev,
646 569 "MBOX: PF rejected capability request or reported unsupported version %u\n",
647 - version);
570 + enic->pf_cap_version);
648 571 return -EOPNOTSUPP;
649 572 }
650 573
@@ -653,25 +576,28 @@ int enic_mbox_vf_capability_check(struct enic *enic)
653 576
654 577 int enic_mbox_vf_register(struct enic *enic)
655 578 {
656 - bool registered;
657 579 int err;
658 580
659 - WRITE_ONCE(enic->vf_registered, false);
581 + enic->vf_registered = false;
582 + reinit_completion(&enic->mbox_comp);
583 + WRITE_ONCE(enic->mbox_expected_reply, ENIC_MBOX_VF_REGISTER_REPLY);
660 584
661 - err = enic_mbox_vf_send_request(enic, ENIC_MBOX_VF_REGISTER_REQUEST,
662 - ENIC_MBOX_VF_REGISTER_REPLY, NULL, 0);
663 - if (err)
585 + err = enic_mbox_send_msg(enic, ENIC_MBOX_VF_REGISTER_REQUEST,
586 + ENIC_MBOX_DST_PF, NULL, 0);
587 + if (err) {
588 + WRITE_ONCE(enic->mbox_expected_reply, 0);
664 589 return err;
590 + }
665 591
666 592 err = enic_mbox_wait_reply(enic, 3000);
667 - registered = READ_ONCE(enic->vf_registered);
593 + WRITE_ONCE(enic->mbox_expected_reply, 0);
668 594 if (err) {
669 595 netdev_warn(enic->netdev,
670 596 "MBOX: VF registration with PF timed out\n");
671 597 return err;
672 598 }
673 599
674 - if (!registered)
600 + if (!enic->vf_registered)
675 601 return -ENODEV;
676 602
677 603 return 0;
@@ -679,48 +605,43 @@ int enic_mbox_vf_register(struct enic *enic)
679 605
680 606 int enic_mbox_vf_unregister(struct enic *enic)
681 607 {
682 - bool registered;
683 608 int err;
684 609
685 - if (!READ_ONCE(enic->vf_registered))
610 + if (!enic->vf_registered)
686 611 return 0;
687 612
688 - err = enic_mbox_vf_send_request(enic,
689 - ENIC_MBOX_VF_UNREGISTER_REQUEST,
690 - ENIC_MBOX_VF_UNREGISTER_REPLY,
691 - NULL, 0);
692 - if (err)
613 + reinit_completion(&enic->mbox_comp);
614 + WRITE_ONCE(enic->mbox_expected_reply, ENIC_MBOX_VF_UNREGISTER_REPLY);
615 +
616 + err = enic_mbox_send_msg(enic, ENIC_MBOX_VF_UNREGISTER_REQUEST,
617 + ENIC_MBOX_DST_PF, NULL, 0);
618 + if (err) {
619 + WRITE_ONCE(enic->mbox_expected_reply, 0);
693 620 return err;
621 + }
694 622
695 623 err = enic_mbox_wait_reply(enic, 3000);
696 - registered = READ_ONCE(enic->vf_registered);
624 + WRITE_ONCE(enic->mbox_expected_reply, 0);
697 625 if (err)
698 626 return err;
699 - if (registered)
627 + if (enic->vf_registered)
700 628 return -EACCES;
701 629 return 0;
702 630 }
703 631
704 632 void enic_mbox_init(struct enic *enic)
705 633 {
706 - bool reinit = enic->mbox_initialized;
707 -
708 - /* MBOX locks and mbox_comp must be initialized exactly once per
634 + /* mbox_lock and mbox_comp must be initialized exactly once per
709 635 * device lifetime; the PF sriov_configure path can re-enter this
710 636 * on each enable cycle where these primitives are already set up.
711 637 */
712 - if (!reinit) {
638 + if (!enic->mbox_initialized) {
713 639 mutex_init(&enic->mbox_lock);
714 640 init_completion(&enic->mbox_comp);
715 - spin_lock_init(&enic->mbox_state_lock);
716 - enic->mbox_msg_num = 0;
717 641 enic->mbox_initialized = true;
718 642 } else {
719 643 reinit_completion(&enic->mbox_comp);
720 644 }
721 - spin_lock_bh(&enic->mbox_state_lock);
722 - enic->mbox_expected_reply = 0;
723 - enic->mbox_expected_msg_num = 0;
724 - spin_unlock_bh(&enic->mbox_state_lock);
645 + enic->mbox_msg_num = 0;
725 646 enic->admin_rq_handler = enic_mbox_recv_handler;
726 647 }
modified drivers/net/ethernet/cisco/enic/enic_mbox.h
@@ -88,8 +88,6 @@ void enic_mbox_init(struct enic *enic);
88 88 int enic_mbox_send_msg(struct enic *enic, u8 msg_type, u16 dst_vnic_id,
89 89 void *payload, u16 payload_len);
90 90 int enic_mbox_send_link_state(struct enic *enic, u16 vf_id, u32 link_state);
91 - void enic_mbox_vf_link_state_reset(struct enic *enic);
92 - void enic_mbox_vf_link_state_set_running(struct enic *enic, bool running);
93 91 int enic_mbox_vf_capability_check(struct enic *enic);
94 92 int enic_mbox_vf_register(struct enic *enic);
95 93 int enic_mbox_vf_unregister(struct enic *enic);
modified drivers/net/ethernet/cortina/gemini.c
@@ -124,7 +124,6 @@ struct gemini_ethernet_port {
124 124 unsigned int rx_coalesce_nsecs;
125 125 struct sk_buff *rx_skb;
126 126 unsigned int rx_frag_nr;
127 - bool rx_dropping;
128 127
129 128 unsigned int freeq_refill;
130 129 struct gmac_txq txq[TX_QUEUE_NUM];
@@ -1440,8 +1439,7 @@ update_exit:
1440 1439 return skb;
1441 1440 }
1442 1441
1443 - static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
1444 - unsigned int *freeq_consumed)
1442 + static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget)
1445 1443 {
1446 1444 struct gemini_ethernet_port *port = netdev_priv(netdev);
1447 1445 unsigned short m = (1 << port->rxq_order) - 1;
@@ -1449,12 +1447,9 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
1449 1447 void __iomem *ptr_reg = port->rxq_rwptr;
1450 1448 unsigned int frag_nr = port->rx_frag_nr;
1451 1449 struct sk_buff *skb = port->rx_skb;
1452 - unsigned int consumed = 0;
1453 1450 unsigned int frame_len, frag_len;
1454 1451 struct gmac_rxdesc *rx = NULL;
1455 1452 struct gmac_queue_page *gpage;
1456 - unsigned int received = 0;
1457 - bool dropping = port->rx_dropping;
1458 1453 union gmac_rxdesc_0 word0;
1459 1454 union gmac_rxdesc_1 word1;
1460 1455 union gmac_rxdesc_3 word3;
@@ -1476,7 +1471,6 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
1476 1471 w = rw.bits.wptr;
1477 1472
1478 1473 while (budget && w != r) {
1479 - page = NULL;
1480 1474 rx = port->rxq_ring + r;
1481 1475 word0 = rx->word0;
1482 1476 word1 = rx->word1;
@@ -1485,22 +1479,11 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
1485 1479
1486 1480 r++;
1487 1481 r &= m;
1488 - consumed++;
1489 1482
1490 1483 frag_len = word0.bits.buffer_size;
1491 1484 frame_len = word1.bits.byte_count;
1492 1485 page_offs = mapping & ~PAGE_MASK;
1493 1486
1494 - if (word3.bits32 & SOF_BIT) {
1495 - if (skb) {
1496 - napi_free_frags(&port->napi);
1497 - port->stats.rx_dropped++;
1498 - skb = NULL;
1499 - frag_nr = 0;
1500 - }
1501 - dropping = false;
1502 - }
1503 -
1504 1487 if (!mapping) {
1505 1488 netdev_err(netdev,
1506 1489 "rxq[%u]: HW BUG: zero DMA desc\n", r);
@@ -1511,11 +1494,24 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
1511 1494 gpage = gmac_get_queue_page(geth, port, mapping + PAGE_SIZE);
1512 1495 if (!gpage) {
1513 1496 dev_err(geth->dev, "could not find mapping\n");
1514 - goto err_drop;
1497 + port->stats.rx_dropped++;
1498 + if (skb) {
1499 + napi_free_frags(&port->napi);
1500 + skb = NULL;
1501 + frag_nr = 0;
1502 + }
1503 + continue;
1515 1504 }
1516 1505 page = gpage->page;
1517 1506
1518 1507 if (word3.bits32 & SOF_BIT) {
1508 + if (skb) {
1509 + napi_free_frags(&port->napi);
1510 + port->stats.rx_dropped++;
1511 + skb = NULL;
1512 + frag_nr = 0;
1513 + }
1514 +
1519 1515 skb = gmac_skb_if_good_frame(port, word0, frame_len);
1520 1516 if (!skb)
1521 1517 goto err_drop;
@@ -1525,7 +1521,8 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
1525 1521 frag_nr = 0;
1526 1522
1527 1523 } else if (!skb) {
1528 - goto err_drop;
1524 + put_page(page);
1525 + continue;
1529 1526 }
1530 1527
1531 1528 if (word3.bits32 & EOF_BIT)
@@ -1548,8 +1545,9 @@ static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget,
1548 1545 napi_gro_frags(&port->napi);
1549 1546 skb = NULL;
1550 1547 frag_nr = 0;
1548 + --budget;
1551 1549 }
1552 - goto next_desc;
1550 + continue;
1553 1551
1554 1552 err_drop:
1555 1553 if (skb) {
@@ -1558,29 +1556,16 @@ err_drop:
1558 1556 frag_nr = 0;
1559 1557 }
1560 1558
1561 - if (page)
1559 + if (mapping)
1562 1560 put_page(page);
1563 1561
1564 - if (!dropping) {
1565 - port->stats.rx_dropped++;
1566 - dropping = true;
1567 - }
1568 -
1569 - next_desc:
1570 - /* Final or single-descriptor fragment, advance things */
1571 - if (word3.bits32 & EOF_BIT) {
1572 - budget--;
1573 - received++;
1574 - dropping = false;
1575 - }
1562 + port->stats.rx_dropped++;
1576 1563 }
1577 1564
1578 1565 port->rx_skb = skb;
1579 1566 port->rx_frag_nr = frag_nr;
1580 - port->rx_dropping = dropping;
1581 - *freeq_consumed = consumed;
1582 1567 writew(r, ptr_reg);
1583 - return received;
1568 + return budget;
1584 1569 }
1585 1570
1586 1571 static int gmac_napi_poll(struct napi_struct *napi, int budget)
@@ -1588,27 +1573,26 @@ static int gmac_napi_poll(struct napi_struct *napi, int budget)
1588 1573 struct gemini_ethernet_port *port = netdev_priv(napi->dev);
1589 1574 struct gemini_ethernet *geth = port->geth;
1590 1575 unsigned int freeq_threshold;
1591 - unsigned int freeq_consumed;
1592 1576 unsigned int received;
1593 1577
1594 1578 freeq_threshold = 1 << (geth->freeq_order - 1);
1595 1579 u64_stats_update_begin(&port->rx_stats_syncp);
1596 1580
1597 - received = gmac_rx(napi->dev, budget, &freeq_consumed);
1598 - if (received < budget)
1581 + received = gmac_rx(napi->dev, budget);
1582 + if (received < budget) {
1583 + napi_gro_flush(napi, false);
1584 + napi_complete_done(napi, received);
1585 + gmac_enable_rx_irq(napi->dev, 1);
1599 1586 ++port->rx_napi_exits;
1587 + }
1600 1588
1601 - u64_stats_update_end(&port->rx_stats_syncp);
1602 -
1603 - port->freeq_refill += freeq_consumed;
1589 + port->freeq_refill += (budget - received);
1604 1590 if (port->freeq_refill > freeq_threshold) {
1605 1591 port->freeq_refill -= freeq_threshold;
1606 1592 geth_fill_freeq(geth, true);
1607 1593 }
1608 1594
1609 - if (received < budget && napi_complete_done(napi, received))
1610 - gmac_enable_rx_irq(napi->dev, 1);
1611 -
1595 + u64_stats_update_end(&port->rx_stats_syncp);
1612 1596 return received;
1613 1597 }
1614 1598
@@ -1909,7 +1893,6 @@ static int gmac_stop(struct net_device *netdev)
1909 1893 napi_disable(&port->napi);
1910 1894 port->rx_skb = NULL;
1911 1895 port->rx_frag_nr = 0;
1912 - port->rx_dropping = false;
1913 1896
1914 1897 gmac_enable_irq(netdev, 0);
1915 1898 gmac_cleanup_rxq(netdev);
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/huawei/hinic/hinic_hw_mbox.c
@@ -128,7 +128,6 @@ enum hinic_mbox_tx_status {
128 128
129 129 #define SEQ_ID_START_VAL 0
130 130 #define SEQ_ID_MAX_VAL 42
131 - #define MBOX_LAST_SEG_MAX_LEN (MBOX_MAX_BUF_SZ - SEQ_ID_MAX_VAL * MBOX_SEG_LEN)
132 131
133 132 #define NO_DMA_ATTRIBUTE_VAL 0
134 133
@@ -373,8 +372,7 @@ recv_pf_from_vf_mbox_handler(struct hinic_mbox_func_to_func *func_to_func,
373 372 static bool check_mbox_seq_id_and_seg_len(struct hinic_recv_mbox *recv_mbox,
374 373 u8 seq_id, u8 seg_len)
375 374 {
376 - if (seq_id > SEQ_ID_MAX_VAL || seg_len > MBOX_SEG_LEN ||
377 - (seq_id == SEQ_ID_MAX_VAL && seg_len > MBOX_LAST_SEG_MAX_LEN))
375 + if (seq_id > SEQ_ID_MAX_VAL || seg_len > MBOX_SEG_LEN)
378 376 return false;
379 377
380 378 if (seq_id == 0) {
modified drivers/net/ethernet/intel/ice/ice_common.c
@@ -1051,13 +1051,14 @@ int ice_init_hw(struct ice_hw *hw)
1051 1051
1052 1052 hw->evb_veb = true;
1053 1053
1054 - xa_init_flags(&hw->sched_node_ids, XA_FLAGS_ALLOC);
1054 + /* init xarray for identifying scheduling nodes uniquely */
1055 + xa_init_flags(&hw->port_info->sched_node_ids, XA_FLAGS_ALLOC);
1055 1056
1056 1057 /* Query the allocated resources for Tx scheduler */
1057 1058 status = ice_sched_query_res_alloc(hw);
1058 1059 if (status) {
1059 1060 ice_debug(hw, ICE_DBG_SCHED, "Failed to get scheduler allocated resources\n");
1060 - goto err_unroll_xarray;
1061 + goto err_unroll_alloc;
1061 1062 }
1062 1063 ice_sched_get_psm_clk_freq(hw);
1063 1064
@@ -1145,8 +1146,6 @@ err_unroll_fltr_mgmt_struct:
1145 1146 ice_cleanup_fltr_mgmt_struct(hw);
1146 1147 err_unroll_sched:
1147 1148 ice_sched_cleanup_all(hw);
1148 - err_unroll_xarray:
1149 - xa_destroy(&hw->sched_node_ids);
1150 1149 err_unroll_alloc:
1151 1150 devm_kfree(ice_hw_to_dev(hw), hw->port_info);
1152 1151 err_unroll_cqinit:
@@ -1187,8 +1186,6 @@ void ice_deinit_hw(struct ice_hw *hw)
1187 1186
1188 1187 /* Clear VSI contexts if not already cleared */
1189 1188 ice_clear_all_vsi_ctx(hw);
1190 -
1191 - xa_destroy(&hw->sched_node_ids);
1192 1189 }
1193 1190
1194 1191 /**
modified drivers/net/ethernet/intel/ice/ice_sched.c
@@ -371,7 +371,7 @@ void ice_free_sched_node(struct ice_port_info *pi, struct ice_sched_node *node)
371 371
372 372 devm_kfree(ice_hw_to_dev(hw), node->children);
373 373 kfree(node->name);
374 - xa_erase(&hw->sched_node_ids, node->id);
374 + xa_erase(&pi->sched_node_ids, node->id);
375 375 devm_kfree(ice_hw_to_dev(hw), node);
376 376 }
377 377
@@ -977,7 +977,7 @@ ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node,
977 977 if (!new_node->name)
978 978 return -ENOMEM;
979 979
980 - status = xa_alloc(&hw->sched_node_ids, &new_node->id, NULL, XA_LIMIT(0, UINT_MAX),
980 + status = xa_alloc(&pi->sched_node_ids, &new_node->id, NULL, XA_LIMIT(0, UINT_MAX),
981 981 GFP_KERNEL);
982 982 if (status) {
983 983 ice_debug(hw, ICE_DBG_SCHED, "xa_alloc failed for sched node status =%d\n",
modified drivers/net/ethernet/intel/ice/ice_trace.h
@@ -63,33 +63,23 @@
63 63 DECLARE_EVENT_CLASS(ice_rx_dim_template,
64 64 TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim),
65 65 TP_ARGS(q_vector, dim),
66 - TP_STRUCT__entry(__field(u16, q_index)
67 - __field(u8, state)
68 - __field(u8, profile_ix)
69 - __field(u8, tune_state)
70 - __field(u8, steps_right)
71 - __field(u8, steps_left)
72 - __field(u8, tired)
66 + TP_STRUCT__entry(__field(struct ice_q_vector *, q_vector)
67 + __field(struct dim *, dim)
73 68 __string(devname, q_vector->rx.rx_ring->netdev->name)),
74 69
75 - TP_fast_assign(__entry->q_index = q_vector->rx.rx_ring->q_index;
76 - __entry->state = dim->state;
77 - __entry->profile_ix = dim->profile_ix;
78 - __entry->tune_state = dim->tune_state;
79 - __entry->steps_right = dim->steps_right;
80 - __entry->steps_left = dim->steps_left;
81 - __entry->tired = dim->tired;
70 + TP_fast_assign(__entry->q_vector = q_vector;
71 + __entry->dim = dim;
82 72 __assign_str(devname);),
83 73
84 74 TP_printk("netdev: %s Rx-Q: %d dim-state: %d dim-profile: %d dim-tune: %d dim-st-right: %d dim-st-left: %d dim-tired: %d",
85 75 __get_str(devname),
86 - __entry->q_index,
87 - __entry->state,
88 - __entry->profile_ix,
89 - __entry->tune_state,
90 - __entry->steps_right,
91 - __entry->steps_left,
92 - __entry->tired)
76 + __entry->q_vector->rx.rx_ring->q_index,
77 + __entry->dim->state,
78 + __entry->dim->profile_ix,
79 + __entry->dim->tune_state,
80 + __entry->dim->steps_right,
81 + __entry->dim->steps_left,
82 + __entry->dim->tired)
93 83 );
94 84
95 85 DEFINE_EVENT(ice_rx_dim_template, ice_rx_dim_work,
@@ -100,33 +90,23 @@ DEFINE_EVENT(ice_rx_dim_template, ice_rx_dim_work,
100 90 DECLARE_EVENT_CLASS(ice_tx_dim_template,
101 91 TP_PROTO(struct ice_q_vector *q_vector, struct dim *dim),
102 92 TP_ARGS(q_vector, dim),
103 - TP_STRUCT__entry(__field(u16, q_index)
104 - __field(u8, state)
105 - __field(u8, profile_ix)
106 - __field(u8, tune_state)
107 - __field(u8, steps_right)
108 - __field(u8, steps_left)
109 - __field(u8, tired)
93 + TP_STRUCT__entry(__field(struct ice_q_vector *, q_vector)
94 + __field(struct dim *, dim)
110 95 __string(devname, q_vector->tx.tx_ring->netdev->name)),
111 96
112 - TP_fast_assign(__entry->q_index = q_vector->tx.tx_ring->q_index;
113 - __entry->state = dim->state;
114 - __entry->profile_ix = dim->profile_ix;
115 - __entry->tune_state = dim->tune_state;
116 - __entry->steps_right = dim->steps_right;
117 - __entry->steps_left = dim->steps_left;
118 - __entry->tired = dim->tired;
97 + TP_fast_assign(__entry->q_vector = q_vector;
98 + __entry->dim = dim;
119 99 __assign_str(devname);),
120 100
121 101 TP_printk("netdev: %s Tx-Q: %d dim-state: %d dim-profile: %d dim-tune: %d dim-st-right: %d dim-st-left: %d dim-tired: %d",
122 102 __get_str(devname),
123 - __entry->q_index,
124 - __entry->state,
125 - __entry->profile_ix,
126 - __entry->tune_state,
127 - __entry->steps_right,
128 - __entry->steps_left,
129 - __entry->tired)
103 + __entry->q_vector->tx.tx_ring->q_index,
104 + __entry->dim->state,
105 + __entry->dim->profile_ix,
106 + __entry->dim->tune_state,
107 + __entry->dim->steps_right,
108 + __entry->dim->steps_left,
109 + __entry->dim->tired)
130 110 );
131 111
132 112 DEFINE_EVENT(ice_tx_dim_template, ice_tx_dim_work,
modified drivers/net/ethernet/intel/ice/ice_type.h
@@ -765,6 +765,7 @@ struct ice_port_info {
765 765 /* List contain profile ID(s) and other params per layer */
766 766 struct list_head rl_prof_list[ICE_AQC_TOPO_MAX_LEVEL_NUM];
767 767 struct ice_qos_cfg qos_cfg;
768 + struct xarray sched_node_ids;
768 769 u8 is_vf:1;
769 770 u8 is_custom_tx_enabled:1;
770 771 };
@@ -929,7 +930,6 @@ struct ice_hw {
929 930 u8 sw_entry_point_layer;
930 931 u16 max_children[ICE_AQC_TOPO_MAX_LEVEL_NUM];
931 932 struct list_head agg_list; /* lists all aggregator */
932 - struct xarray sched_node_ids;
933 933
934 934 struct ice_vsi_ctx *vsi_ctx[ICE_MAX_VSI];
935 935 u8 evb_veb; /* true for VEB, false for VEPA */
modified drivers/net/ethernet/intel/idpf/idpf_main.c
@@ -106,11 +106,6 @@ static int idpf_dev_init(struct idpf_adapter *adapter,
106 106 */
107 107 static void idpf_decfg_device(struct idpf_adapter *adapter)
108 108 {
109 - struct pci_dev *pdev = adapter->pdev;
110 -
111 - if (pcie_ptm_enabled(pdev))
112 - pci_disable_ptm(pdev);
113 -
114 109 libie_pci_unmap_all_mmio_regions(&adapter->ctlq_ctx.mmio_info);
115 110 }
116 111
modified drivers/net/ethernet/intel/idpf/idpf_txrx.c
@@ -3299,7 +3299,6 @@ static int idpf_rx_rsc(struct idpf_rx_queue *rxq, struct sk_buff *skb,
3299 3299 struct libeth_rx_pt decoded)
3300 3300 {
3301 3301 u16 rsc_segments, rsc_seg_len;
3302 - u16 l3_start = 0;
3303 3302 bool ipv4, ipv6;
3304 3303 int len;
3305 3304
@@ -3322,10 +3321,7 @@ static int idpf_rx_rsc(struct idpf_rx_queue *rxq, struct sk_buff *skb,
3322 3321 NAPI_GRO_CB(skb)->count = rsc_segments;
3323 3322 skb_shinfo(skb)->gso_size = rsc_seg_len;
3324 3323
3325 - if (unlikely(eth_type_vlan(skb->protocol)))
3326 - l3_start = VLAN_HLEN;
3327 -
3328 - skb_set_network_header(skb, l3_start);
3324 + skb_reset_network_header(skb);
3329 3325
3330 3326 if (ipv4) {
3331 3327 struct iphdr *ipv4h = ip_hdr(skb);
@@ -3333,7 +3329,7 @@ static int idpf_rx_rsc(struct idpf_rx_queue *rxq, struct sk_buff *skb,
3333 3329 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
3334 3330
3335 3331 /* Reset and set transport header offset in skb */
3336 - skb_set_transport_header(skb, l3_start + sizeof(struct iphdr));
3332 + skb_set_transport_header(skb, sizeof(struct iphdr));
3337 3333 len = skb->len - skb_transport_offset(skb);
3338 3334
3339 3335 /* Compute the TCP pseudo header checksum*/
@@ -3343,7 +3339,7 @@ static int idpf_rx_rsc(struct idpf_rx_queue *rxq, struct sk_buff *skb,
3343 3339 struct ipv6hdr *ipv6h = ipv6_hdr(skb);
3344 3340
3345 3341 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
3346 - skb_set_transport_header(skb, l3_start + sizeof(struct ipv6hdr));
3342 + skb_set_transport_header(skb, sizeof(struct ipv6hdr));
3347 3343 len = skb->len - skb_transport_offset(skb);
3348 3344 tcp_hdr(skb)->check =
3349 3345 ~tcp_v6_check(len, &ipv6h->saddr, &ipv6h->daddr, 0);
@@ -4149,26 +4145,6 @@ static void idpf_vport_intr_ena_irq_all(struct idpf_vport *vport,
4149 4145 writel(rsrc->noirq_dyn_ctl_ena, rsrc->noirq_dyn_ctl);
4150 4146 }
4151 4147
4152 - /**
4153 - * idpf_vport_intr_dis_dim_all - Disable DIM work for all q_vectors
4154 - * @rsrc: pointer to queue and vector resources
4155 - *
4156 - * The DIM works are embedded in the q_vector array that
4157 - * idpf_vport_intr_rel() frees, and the poll arms them after
4158 - * napi_complete_done() has already cleared NAPI_STATE_SCHED. Disable
4159 - * rather than just cancel, so that a poll tail still running past
4160 - * napi_disable() cannot queue them again behind the drain.
4161 - */
4162 - static void idpf_vport_intr_dis_dim_all(struct idpf_q_vec_rsrc *rsrc)
4163 - {
4164 - for (u16 v_idx = 0; v_idx < rsrc->num_q_vectors; v_idx++) {
4165 - struct idpf_q_vector *q_vector = &rsrc->q_vectors[v_idx];
4166 -
4167 - disable_work_sync(&q_vector->tx_dim.work);
4168 - disable_work_sync(&q_vector->rx_dim.work);
4169 - }
4170 - }
4171 -
4172 4148 /**
4173 4149 * idpf_vport_intr_deinit - Release all vector associations for the vport
4174 4150 * @vport: main vport structure
@@ -4179,7 +4155,6 @@ void idpf_vport_intr_deinit(struct idpf_vport *vport,
4179 4155 {
4180 4156 idpf_vport_intr_dis_irq_all(rsrc);
4181 4157 idpf_vport_intr_napi_dis_all(rsrc);
4182 - idpf_vport_intr_dis_dim_all(rsrc);
4183 4158 idpf_vport_intr_napi_del_all(rsrc);
4184 4159 idpf_vport_intr_rel_irq(vport, rsrc);
4185 4160 }
@@ -4260,6 +4235,7 @@ static void idpf_vport_intr_napi_ena_all(struct idpf_q_vec_rsrc *rsrc)
4260 4235 for (u16 q_idx = 0; q_idx < rsrc->num_q_vectors; q_idx++) {
4261 4236 struct idpf_q_vector *q_vector = &rsrc->q_vectors[q_idx];
4262 4237
4238 + idpf_init_dim(q_vector);
4263 4239 napi_enable(&q_vector->napi);
4264 4240 }
4265 4241 }
@@ -4602,8 +4578,6 @@ int idpf_vport_intr_alloc(struct idpf_vport *vport,
4602 4578 q_coal = &user_config->q_coalesce[v_idx];
4603 4579 q_vector->vport = vport;
4604 4580
4605 - idpf_init_dim(q_vector);
4606 -
4607 4581 q_vector->tx_itr_value = q_coal->tx_coalesce_usecs;
4608 4582 q_vector->tx_intr_mode = q_coal->tx_intr_mode;
4609 4583 q_vector->tx_itr_idx = VIRTCHNL2_ITR_IDX_1;
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/mcs.c
@@ -1417,16 +1417,6 @@ static int mcs_x2p_calibration(struct mcs *mcs)
1417 1417 int i, err = 0;
1418 1418 u64 val;
1419 1419
1420 - /* Clear any stale calibration state left by firmware/bootloader.
1421 - * Some firmware versions may leave MCSX_MIL_GLOBAL bit 5 set,
1422 - * preventing the hardware from detecting the rising edge needed to
1423 - * trigger X2P calibration.
1424 - */
1425 - val = mcs_reg_read(mcs, MCSX_MIL_GLOBAL);
1426 - val &= ~BIT_ULL(5);
1427 - mcs_reg_write(mcs, MCSX_MIL_GLOBAL, val);
1428 - usleep_range(100, 200);
1429 -
1430 1420 /* set X2P calibration */
1431 1421 val = mcs_reg_read(mcs, MCSX_MIL_GLOBAL);
1432 1422 val |= BIT_ULL(5);
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_debugfs.c
@@ -829,25 +829,19 @@ static int rvu_dbg_rvu_pf_cgx_map_display(struct seq_file *filp, void *unused)
829 829 int pf, domain, blkid;
830 830 u8 cgx_id, lmac_id;
831 831 u16 pcifunc;
832 - u8 start;
833 832
834 - domain = pci_domain_nr(rvu->pdev->bus);
833 + domain = 2;
835 834 mac_ops = get_mac_ops(rvu_first_cgx_pdata(rvu));
836 835 /* There can be no CGX devices at all */
837 836 if (!mac_ops)
838 837 return 0;
839 838 seq_printf(filp, "PCI dev\t\tRVU PF Func\tNIX block\t%s\tLMAC\tCHAN\n",
840 839 mac_ops->name);
841 -
842 - /* All the PF devices are on contiguous PCI bus numbers, but the PF0(AF)
843 - * may not start from 1 always. Hence get domain and bus from PCI device.
844 - */
845 - start = rvu->pdev->bus->number;
846 840 for (pf = 0; pf < rvu->hw->total_pfs; pf++) {
847 841 if (!is_pf_cgxmapped(rvu, pf))
848 842 continue;
849 843
850 - pdev = pci_get_domain_bus_and_slot(domain, pf + start, 0);
844 + pdev = pci_get_domain_bus_and_slot(domain, pf + 1, 0);
851 845 if (!pdev)
852 846 continue;
853 847
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/marvell/octeontx2/nic/qos.c
@@ -235,63 +235,13 @@ static int otx2_qos_txschq_set_parent_topology(struct otx2_nic *pfvf,
235 235 return rc;
236 236 }
237 237
238 - static int otx2_qos_reset_schq_topology(struct otx2_nic *pfvf, u16 lvl,
239 - u16 schq)
240 - {
241 - struct mbox *mbox = &pfvf->mbox;
242 - struct nix_txschq_config *cfg;
243 - int rc;
244 -
245 - if (lvl < NIX_TXSCH_LVL_TL4 || lvl >= NIX_TXSCH_LVL_TL1)
246 - return 0;
247 -
248 - mutex_lock(&mbox->lock);
249 -
250 - cfg = otx2_mbox_alloc_msg_nix_txschq_cfg(mbox);
251 - if (!cfg) {
252 - mutex_unlock(&mbox->lock);
253 - return -ENOMEM;
254 - }
255 -
256 - cfg->lvl = lvl;
257 - cfg->num_regs = 1;
258 -
259 - if (lvl == NIX_TXSCH_LVL_TL4)
260 - cfg->reg[0] = NIX_AF_TL4X_TOPOLOGY(schq);
261 - else if (lvl == NIX_TXSCH_LVL_TL3)
262 - cfg->reg[0] = NIX_AF_TL3X_TOPOLOGY(schq);
263 - else if (lvl == NIX_TXSCH_LVL_TL2)
264 - cfg->reg[0] = NIX_AF_TL2X_TOPOLOGY(schq);
265 -
266 - cfg->regval[0] = 0;
267 -
268 - rc = otx2_sync_mbox_msg(mbox);
269 -
270 - mutex_unlock(&mbox->lock);
271 -
272 - return rc;
273 - }
274 -
275 - static void otx2_qos_free_hw_schq(struct otx2_nic *pfvf, u16 lvl, u16 schq)
276 - {
277 - int err;
278 -
279 - err = otx2_qos_reset_schq_topology(pfvf, lvl, schq);
280 - if (err)
281 - netdev_warn(pfvf->netdev,
282 - "QoS: failed to reset topology for schq %u at level %u: %d\n",
283 - schq, lvl, err);
284 -
285 - otx2_txschq_free_one(pfvf, lvl, schq);
286 - }
287 -
288 238 static void otx2_qos_free_hw_node_schq(struct otx2_nic *pfvf,
289 239 struct otx2_qos_node *parent)
290 240 {
291 241 struct otx2_qos_node *node;
292 242
293 243 list_for_each_entry_reverse(node, &parent->child_schq_list, list)
294 - otx2_qos_free_hw_schq(pfvf, node->level, node->schq);
244 + otx2_txschq_free_one(pfvf, node->level, node->schq);
295 245 }
296 246
297 247 static void otx2_qos_free_hw_node(struct otx2_nic *pfvf,
@@ -302,7 +252,7 @@ static void otx2_qos_free_hw_node(struct otx2_nic *pfvf,
302 252 list_for_each_entry_safe(node, tmp, &parent->child_list, list) {
303 253 otx2_qos_free_hw_node(pfvf, node);
304 254 otx2_qos_free_hw_node_schq(pfvf, node);
305 - otx2_qos_free_hw_schq(pfvf, node->level, node->schq);
255 + otx2_txschq_free_one(pfvf, node->level, node->schq);
306 256 }
307 257 }
308 258
@@ -316,7 +266,7 @@ static void otx2_qos_free_hw_cfg(struct otx2_nic *pfvf,
316 266 otx2_qos_free_hw_node_schq(pfvf, node);
317 267
318 268 /* free node hw mappings */
319 - otx2_qos_free_hw_schq(pfvf, node->level, node->schq);
269 + otx2_txschq_free_one(pfvf, node->level, node->schq);
320 270
321 271 mutex_unlock(&pfvf->qos.qos_lock);
322 272 }
@@ -963,7 +913,7 @@ static void otx2_qos_free_cfg(struct otx2_nic *pfvf, struct otx2_qos_cfg *cfg)
963 913 for (lvl = 0; lvl < NIX_TXSCH_LVL_CNT; lvl++) {
964 914 for (idx = 0; idx < cfg->schq[lvl]; idx++) {
965 915 schq = cfg->schq_list[lvl][idx];
966 - otx2_qos_free_hw_schq(pfvf, lvl, schq);
916 + otx2_txschq_free_one(pfvf, lvl, schq);
967 917 }
968 918 }
969 919
@@ -971,7 +921,7 @@ static void otx2_qos_free_cfg(struct otx2_nic *pfvf, struct otx2_qos_cfg *cfg)
971 921 for (idx = 0; idx < cfg->schq_contig[lvl]; idx++) {
972 922 if (cfg->schq_index_used[lvl][idx]) {
973 923 schq = cfg->schq_contig_list[lvl][idx];
974 - otx2_qos_free_hw_schq(pfvf, lvl, schq);
924 + otx2_txschq_free_one(pfvf, lvl, schq);
975 925 }
976 926 }
977 927 }
modified drivers/net/ethernet/mediatek/mtk_eth_soc.c
@@ -4828,7 +4828,7 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
4828 4828 phy_interface_t phy_mode;
4829 4829 struct phylink *phylink;
4830 4830 struct mtk_mac *mac;
4831 - int id, err, i;
4831 + int id, err;
4832 4832 int txqs = 1;
4833 4833 u32 val;
4834 4834
@@ -4907,8 +4907,8 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
4907 4907 mac->phylink_config.type = PHYLINK_NETDEV;
4908 4908 mac->phylink_config.mac_capabilities = MAC_ASYM_PAUSE | MAC_SYM_PAUSE |
4909 4909 MAC_10 | MAC_100 | MAC_1000 | MAC_2500FD;
4910 - /* LPI above 1 Gbps is not supported */
4911 - mac->phylink_config.lpi_capabilities = MAC_100FD | MAC_1000FD;
4910 + mac->phylink_config.lpi_capabilities = MAC_100FD | MAC_1000FD |
4911 + MAC_2500FD;
4912 4912 mac->phylink_config.lpi_timer_default = 1000;
4913 4913
4914 4914 /* MT7623 gmac0 is now missing its speed-specific PLL configuration
@@ -4966,18 +4966,6 @@ static int mtk_add_mac(struct mtk_eth *eth, struct device_node *np)
4966 4966 __set_bit(PHY_INTERFACE_MODE_INTERNAL,
4967 4967 mac->phylink_config.supported_interfaces);
4968 4968
4969 - /* LPI wake-up timing is only verified on MTK_GMAC_EEE SoCs */
4970 - if (MTK_HAS_CAPS(eth->soc->caps, MTK_GMAC_EEE)) {
4971 - phy_interface_copy(mac->phylink_config.lpi_interfaces,
4972 - mac->phylink_config.supported_interfaces);
4973 - __clear_bit(PHY_INTERFACE_MODE_2500BASEX,
4974 - mac->phylink_config.lpi_interfaces);
4975 - for (i = 0; i < PHY_INTERFACE_MODE_MAX; i++)
4976 - if (mtk_interface_mode_is_xgmii(eth, i))
4977 - __clear_bit(i,
4978 - mac->phylink_config.lpi_interfaces);
4979 - }
4980 -
4981 4969 phylink = phylink_create(&mac->phylink_config,
4982 4970 of_fwnode_handle(mac->of_node),
4983 4971 phy_mode, mac_ops);
modified drivers/net/ethernet/mediatek/mtk_eth_soc.h
@@ -994,7 +994,6 @@ enum mkt_eth_capabilities {
994 994 MTK_U3_COPHY_V2_BIT,
995 995 MTK_SRAM_BIT,
996 996 MTK_36BIT_DMA_BIT,
997 - MTK_GMAC_EEE_BIT,
998 997
999 998 /* MUX BITS*/
1000 999 MTK_ETH_MUX_GDM1_TO_GMAC1_ESW_BIT,
@@ -1035,7 +1034,6 @@ enum mkt_eth_capabilities {
1035 1034 #define MTK_U3_COPHY_V2 BIT_ULL(MTK_U3_COPHY_V2_BIT)
1036 1035 #define MTK_SRAM BIT_ULL(MTK_SRAM_BIT)
1037 1036 #define MTK_36BIT_DMA BIT_ULL(MTK_36BIT_DMA_BIT)
1038 - #define MTK_GMAC_EEE BIT_ULL(MTK_GMAC_EEE_BIT)
1039 1037
1040 1038 #define MTK_ETH_MUX_GDM1_TO_GMAC1_ESW \
1041 1039 BIT_ULL(MTK_ETH_MUX_GDM1_TO_GMAC1_ESW_BIT)
@@ -1119,7 +1117,7 @@ enum mkt_eth_capabilities {
1119 1117 #define MT7981_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | MTK_GMAC2_GEPHY | \
1120 1118 MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \
1121 1119 MTK_MUX_U3_GMAC2_TO_QPHY | MTK_U3_COPHY_V2 | \
1122 - MTK_RSTCTRL_PPE1 | MTK_SRAM | MTK_GMAC_EEE)
1120 + MTK_RSTCTRL_PPE1 | MTK_SRAM)
1123 1121
1124 1122 #define MT7986_CAPS (MTK_GMAC1_SGMII | MTK_GMAC2_SGMII | \
1125 1123 MTK_MUX_GMAC12_TO_GEPHY_SGMII | MTK_QDMA | \
modified drivers/net/ethernet/mellanox/mlx5/core/en/port.c
@@ -557,7 +557,6 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u16 fec_policy)
557 557 u32 in[MLX5_ST_SZ_DW(pplm_reg)] = {};
558 558 int sz = MLX5_ST_SZ_BYTES(pplm_reg);
559 559 u16 fec_policy_auto = 0;
560 - bool fec_set = false;
561 560 int err;
562 561 int i;
563 562
@@ -570,6 +569,9 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u16 fec_policy)
570 569 if (fec_policy >= (1 << MLX5E_FEC_LLRS_272_257_1) && !fec_50g_per_lane)
571 570 return -EOPNOTSUPP;
572 571
572 + if (fec_policy && !mlx5e_fec_in_caps(dev, fec_policy))
573 + return -EOPNOTSUPP;
574 +
573 575 MLX5_SET(pplm_reg, in, local_port, 1);
574 576 err = mlx5_core_access_reg(dev, in, sz, out, sz, MLX5_REG_PPLM, 0, 0);
575 577 if (err)
@@ -589,17 +591,12 @@ int mlx5e_set_fec_mode(struct mlx5_core_dev *dev, u16 fec_policy)
589 591 mlx5e_get_fec_cap_field(out, &fec_caps, i);
590 592
591 593 /* policy supported for link speed */
592 - if (fec_caps & conf_fec) {
594 + if (fec_caps & conf_fec)
593 595 mlx5e_fec_admin_field(out, &conf_fec, 1, i);
594 - fec_set = true;
595 - } else {
596 - /* set FEC to auto */
596 + else
597 + /* set FEC to auto*/
597 598 mlx5e_fec_admin_field(out, &fec_policy_auto, 1, i);
598 - }
599 599 }
600 600
601 - if (fec_policy && !fec_set)
602 - return -EOPNOTSUPP;
603 -
604 601 return mlx5_core_access_reg(dev, out, sz, out, sz, MLX5_REG_PPLM, 0, 1);
605 602 }
modified drivers/net/ethernet/mellanox/mlx5/core/en/port.h
@@ -66,8 +66,4 @@ enum {
66 66 MLX5E_FEC_LLRS_272_257_1 = 9,
67 67 };
68 68
69 - #define MLX5E_FEC_RS_MASK (BIT(MLX5E_FEC_RS_528_514) | \
70 - BIT(MLX5E_FEC_RS_544_514_INTERLEAVED_QUAD) | \
71 - BIT(MLX5E_FEC_RS_544_514))
72 -
73 69 #endif
modified drivers/net/ethernet/mellanox/mlx5/core/en/tc/sample.c
@@ -311,15 +311,12 @@ err_alloc:
311 311 static void
312 312 sample_restore_put(struct mlx5e_tc_psample *tc_psample, struct mlx5e_sample_restore *restore)
313 313 {
314 - bool last;
315 -
316 314 mutex_lock(&tc_psample->restore_lock);
317 - last = --restore->count == 0;
318 - if (last)
315 + if (--restore->count == 0)
319 316 hash_del(&restore->hlist);
320 317 mutex_unlock(&tc_psample->restore_lock);
321 318
322 - if (last) {
319 + if (!restore->count) {
323 320 mlx5_del_flow_rules(restore->rule);
324 321 mlx5_modify_header_dealloc(tc_psample->esw->dev, restore->modify_hdr);
325 322 kfree(restore);
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_dcbnl.c
@@ -148,7 +148,7 @@ static int mlx5e_dcbnl_ieee_getets(struct net_device *netdev,
148 148 if (err)
149 149 return err;
150 150
151 - if (priv->dcbx.tc_tsa[i] == IEEE_8021QAZ_TSA_ETS &&
151 + if (ets->tc_tx_bw[i] < MLX5E_MAX_BW_ALLOC &&
152 152 tc_group[i] == (MLX5E_LOWEST_PRIO_GROUP + 1))
153 153 is_zero_bw_ets_tc = true;
154 154
modified drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c
@@ -1002,9 +1002,9 @@ static u32 pplm2ethtool_fec(u_long fec_mode, unsigned long size)
1002 1002 return 0;
1003 1003 }
1004 1004
1005 - #define MLX5E_ADVERTISE_SUPPORTED_FEC(fec_mask, ethtool_fec) \
1005 + #define MLX5E_ADVERTISE_SUPPORTED_FEC(mlx5_fec, ethtool_fec) \
1006 1006 do { \
1007 - if (mlx5e_fec_in_caps(dev, fec_mask)) \
1007 + if (mlx5e_fec_in_caps(dev, 1 << (mlx5_fec))) \
1008 1008 __set_bit(ethtool_fec, \
1009 1009 link_ksettings->link_modes.supported);\
1010 1010 } while (0)
@@ -1013,7 +1013,6 @@ static const u32 pplm_fec_2_ethtool_linkmodes[] = {
1013 1013 [MLX5E_FEC_NOFEC] = ETHTOOL_LINK_MODE_FEC_NONE_BIT,
1014 1014 [MLX5E_FEC_FIRECODE] = ETHTOOL_LINK_MODE_FEC_BASER_BIT,
1015 1015 [MLX5E_FEC_RS_528_514] = ETHTOOL_LINK_MODE_FEC_RS_BIT,
1016 - [MLX5E_FEC_RS_544_514_INTERLEAVED_QUAD] = ETHTOOL_LINK_MODE_FEC_RS_BIT,
1017 1016 [MLX5E_FEC_RS_544_514] = ETHTOOL_LINK_MODE_FEC_RS_BIT,
1018 1017 [MLX5E_FEC_LLRS_272_257_1] = ETHTOOL_LINK_MODE_FEC_LLRS_BIT,
1019 1018 };
@@ -1030,13 +1029,13 @@ static int get_fec_supported_advertised(struct mlx5_core_dev *dev,
1030 1029 if (err)
1031 1030 return (err == -EOPNOTSUPP) ? 0 : err;
1032 1031
1033 - MLX5E_ADVERTISE_SUPPORTED_FEC(BIT(MLX5E_FEC_NOFEC),
1032 + MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_NOFEC,
1034 1033 ETHTOOL_LINK_MODE_FEC_NONE_BIT);
1035 - MLX5E_ADVERTISE_SUPPORTED_FEC(BIT(MLX5E_FEC_FIRECODE),
1034 + MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_FIRECODE,
1036 1035 ETHTOOL_LINK_MODE_FEC_BASER_BIT);
1037 - MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_RS_MASK,
1036 + MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_RS_528_514,
1038 1037 ETHTOOL_LINK_MODE_FEC_RS_BIT);
1039 - MLX5E_ADVERTISE_SUPPORTED_FEC(BIT(MLX5E_FEC_LLRS_272_257_1),
1038 + MLX5E_ADVERTISE_SUPPORTED_FEC(MLX5E_FEC_LLRS_272_257_1,
1040 1039 ETHTOOL_LINK_MODE_FEC_LLRS_BIT);
1041 1040
1042 1041 active_fec_long = active_fec;
modified drivers/net/ethernet/mellanox/mlx5/core/en_rep.c
@@ -56,6 +56,7 @@
56 56 #include "lib/vxlan.h"
57 57 #define CREATE_TRACE_POINTS
58 58 #include "diag/en_rep_tracepoint.h"
59 + #include "diag/reporter_vnic.h"
59 60 #include "en_accel/ipsec.h"
60 61 #include "en/tc/int_port.h"
61 62 #include "en/ptp.h"
@@ -1438,6 +1439,51 @@ static unsigned int mlx5e_ul_rep_stats_grps_num(struct mlx5e_priv *priv)
1438 1439 return ARRAY_SIZE(mlx5e_ul_rep_stats_grps);
1439 1440 }
1440 1441
1442 + static int
1443 + mlx5e_rep_vnic_reporter_diagnose(struct devlink_health_reporter *reporter,
1444 + struct devlink_fmsg *fmsg,
1445 + struct netlink_ext_ack *extack)
1446 + {
1447 + struct mlx5e_rep_priv *rpriv = devlink_health_reporter_priv(reporter);
1448 + struct mlx5_eswitch_rep *rep = rpriv->rep;
1449 +
1450 + mlx5_reporter_vnic_diagnose_counters(rep->esw->dev, fmsg, rep->vport,
1451 + true);
1452 + return 0;
1453 + }
1454 +
1455 + static const struct devlink_health_reporter_ops mlx5_rep_vnic_reporter_ops = {
1456 + .name = "vnic",
1457 + .diagnose = mlx5e_rep_vnic_reporter_diagnose,
1458 + };
1459 +
1460 + static void mlx5e_rep_vnic_reporter_create(struct mlx5e_priv *priv,
1461 + struct devlink_port *dl_port)
1462 + {
1463 + struct mlx5e_rep_priv *rpriv = priv->ppriv;
1464 + struct devlink_health_reporter *reporter;
1465 +
1466 + reporter = devl_port_health_reporter_create(dl_port,
1467 + &mlx5_rep_vnic_reporter_ops,
1468 + rpriv);
1469 + if (IS_ERR(reporter)) {
1470 + mlx5_core_err(priv->mdev,
1471 + "Failed to create representor vnic reporter, err = %pe\n",
1472 + reporter);
1473 + return;
1474 + }
1475 +
1476 + rpriv->rep_vnic_reporter = reporter;
1477 + }
1478 +
1479 + static void mlx5e_rep_vnic_reporter_destroy(struct mlx5e_priv *priv)
1480 + {
1481 + struct mlx5e_rep_priv *rpriv = priv->ppriv;
1482 +
1483 + if (!IS_ERR_OR_NULL(rpriv->rep_vnic_reporter))
1484 + devl_health_reporter_destroy(rpriv->rep_vnic_reporter);
1485 + }
1486 +
1441 1487 static const struct mlx5e_profile mlx5e_rep_profile = {
1442 1488 .init = mlx5e_init_rep,
1443 1489 .cleanup = mlx5e_cleanup_rep,
@@ -1561,8 +1607,10 @@ mlx5e_vport_vf_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
1561 1607
1562 1608 dl_port = mlx5_esw_offloads_devlink_port(dev->priv.eswitch,
1563 1609 rpriv->rep->vport);
1564 - if (!IS_ERR(dl_port))
1610 + if (!IS_ERR(dl_port)) {
1565 1611 SET_NETDEV_DEVLINK_PORT(netdev, dl_port);
1612 + mlx5e_rep_vnic_reporter_create(priv, dl_port);
1613 + }
1566 1614
1567 1615 err = register_netdev(netdev);
1568 1616 if (err) {
@@ -1575,6 +1623,7 @@ mlx5e_vport_vf_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
1575 1623 return 0;
1576 1624
1577 1625 err_detach_netdev:
1626 + mlx5e_rep_vnic_reporter_destroy(priv);
1578 1627 mlx5e_detach_netdev(netdev_priv(netdev));
1579 1628 err_cleanup_profile:
1580 1629 priv->profile->cleanup(priv);
@@ -1632,6 +1681,7 @@ mlx5e_vport_rep_unload(struct mlx5_eswitch_rep *rep)
1632 1681 }
1633 1682
1634 1683 unregister_netdev(netdev);
1684 + mlx5e_rep_vnic_reporter_destroy(priv);
1635 1685 mlx5e_detach_netdev(priv);
1636 1686 priv->profile->cleanup(priv);
1637 1687 mlx5e_destroy_netdev(netdev);
modified drivers/net/ethernet/mellanox/mlx5/core/en_rep.h
@@ -118,6 +118,7 @@ struct mlx5e_rep_priv {
118 118 struct rtnl_link_stats64 prev_vf_vport_stats;
119 119 struct mlx5_flow_handle *send_to_vport_meta_rule;
120 120 struct rhashtable tc_ht;
121 + struct devlink_health_reporter *rep_vnic_reporter;
121 122 };
122 123
123 124 static inline
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/en_stats.c
@@ -1199,39 +1199,50 @@ void mlx5e_stats_rmon_get(struct mlx5e_priv *priv,
1199 1199 void mlx5e_stats_ts_get(struct mlx5e_priv *priv,
1200 1200 struct ethtool_ts_stats *ts_stats)
1201 1201 {
1202 - u16 nch = mlx5e_stats_nch_read(priv);
1203 - int i, tc;
1204 -
1205 - ts_stats->pkts = 0;
1206 -
1207 - for (i = 0; i < nch; i++) {
1208 - struct mlx5e_channel_stats *channel_stats =
1209 - priv->channel_stats[i];
1202 + int i, j;
1210 1203
1211 - for (tc = 0; tc < priv->max_opened_tc; tc++)
1212 - ts_stats->pkts += channel_stats->sq[tc].timestamps;
1213 - }
1204 + mutex_lock(&priv->state_lock);
1214 1205
1215 - /* Accumulate DMA and port timestamp counters so values stay monotonic
1216 - * across channel teardown and mode switches.
1217 - */
1218 1206 if (priv->tx_ptp_opened) {
1219 - /* Err and Lost stats are only relevant for port timestamping,
1220 - * as the DMA layer will always successfully timestamp packets.
1221 - */
1207 + struct mlx5e_ptp *ptp = priv->channels.ptp;
1208 +
1209 + ts_stats->pkts = 0;
1222 1210 ts_stats->err = 0;
1223 1211 ts_stats->lost = 0;
1224 1212
1225 - for (tc = 0; tc < priv->max_opened_tc; tc++) {
1213 + if (!ptp)
1214 + goto out;
1215 +
1216 + /* Aggregate stats across all TCs */
1217 + for (i = 0; i < ptp->num_tc; i++) {
1226 1218 struct mlx5e_ptp_cq_stats *stats =
1227 - &priv->ptp_stats.cq[tc];
1219 + ptp->ptpsq[i].cq_stats;
1228 1220
1229 1221 ts_stats->pkts += stats->cqe;
1230 1222 ts_stats->err += stats->abort + stats->err_cqe +
1231 - stats->late_cqe;
1223 + stats->late_cqe;
1232 1224 ts_stats->lost += stats->lost_cqe;
1233 1225 }
1226 + } else {
1227 + /* DMA layer will always successfully timestamp packets. Other
1228 + * counters do not make sense for this layer.
1229 + */
1230 + ts_stats->pkts = 0;
1231 +
1232 + /* Aggregate stats across all SQs */
1233 + for (j = 0; j < priv->channels.num; j++) {
1234 + struct mlx5e_channel *c = priv->channels.c[j];
1235 +
1236 + for (i = 0; i < c->num_tc; i++) {
1237 + struct mlx5e_sq_stats *stats = c->sq[i].stats;
1238 +
1239 + ts_stats->pkts += stats->timestamps;
1240 + }
1241 + }
1234 1242 }
1243 +
1244 + out:
1245 + mutex_unlock(&priv->state_lock);
1235 1246 }
1236 1247
1237 1248 #define PPORT_PHY_LAYER_OFF(c) \
modified drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
@@ -1040,19 +1040,13 @@ void mlx5_esw_vport_disable(struct mlx5_eswitch *esw, struct mlx5_vport *vport)
1040 1040 (vport->info.ipsec_crypto_enabled || vport->info.ipsec_packet_enabled))
1041 1041 esw->enabled_ipsec_vf_count--;
1042 1042
1043 - /* Clear rx-mode before esw_vport_change_handle_locked(): on
1044 - * MLX5_VPORT_PROMISC_CHANGE it calls esw_update_vport_mc_promisc()
1045 - * when vport->allmulti_rule is set, repopulating mc_list with FDB
1046 - * rules that dangle once the FDB is destroyed. NULL allmulti_rule
1047 - * here skips that path.
1048 - */
1049 - esw_apply_vport_rx_mode(esw, vport, false, false);
1050 1043 /* We don't assume VFs will cleanup after themselves.
1051 1044 * Calling vport change handler while vport is disabled will cleanup
1052 1045 * the vport resources.
1053 1046 */
1054 1047 esw_vport_change_handle_locked(vport);
1055 1048 vport->enabled_events = 0;
1049 + esw_apply_vport_rx_mode(esw, vport, false, false);
1056 1050 esw_vport_cleanup(esw, vport);
1057 1051 esw->enabled_vports--;
1058 1052
@@ -2294,7 +2288,8 @@ static int mlx5_esw_spfs_init(struct mlx5_eswitch *esw)
2294 2288 if (!num_entries)
2295 2289 goto out_free;
2296 2290
2297 - esw_funcs->spfs = kzalloc_objs(*esw_funcs->spfs, num_entries);
2291 + esw_funcs->spfs = kcalloc(num_entries, sizeof(*esw_funcs->spfs),
2292 + GFP_KERNEL);
2298 2293 if (!esw_funcs->spfs) {
2299 2294 err = -ENOMEM;
2300 2295 goto out_free;
modified drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
@@ -189,7 +189,6 @@ struct mlx5_vport;
189 189 struct mlx5_devlink_port {
190 190 struct devlink_port dl_port;
191 191 struct mlx5_vport *vport;
192 - struct devlink_health_reporter *vnic_reporter;
193 192 };
194 193
195 194 static inline void mlx5_devlink_port_init(struct mlx5_devlink_port *dl_port,
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/eswitch_offloads_termtbl.c
@@ -163,15 +163,12 @@ void
163 163 mlx5_eswitch_termtbl_put(struct mlx5_eswitch *esw,
164 164 struct mlx5_termtbl_handle *tt)
165 165 {
166 - bool last;
167 -
168 166 mutex_lock(&esw->offloads.termtbl_mutex);
169 - last = (--tt->ref_count == 0);
170 - if (last)
167 + if (--tt->ref_count == 0)
171 168 hash_del(&tt->termtbl_hlist);
172 169 mutex_unlock(&esw->offloads.termtbl_mutex);
173 170
174 - if (last) {
171 + if (!tt->ref_count) {
175 172 mlx5_del_flow_rules(tt->rule);
176 173 mlx5_destroy_flow_table(tt->termtbl);
177 174 kfree(tt);
modified drivers/net/ethernet/mellanox/mlx5/core/lag/lag.c
@@ -63,15 +63,14 @@ static int get_port_sel_mode(enum mlx5_lag_mode mode, unsigned long flags)
63 63 return MLX5_LAG_PORT_SELECT_MODE_QUEUE_AFFINITY;
64 64 }
65 65
66 - static u8 lag_active_port_bits(struct mlx5_lag *ldev,
67 - struct lag_tracker *tracker)
66 + static u8 lag_active_port_bits(struct mlx5_lag *ldev)
68 67 {
69 68 u8 enabled_ports[MLX5_MAX_PORTS] = {};
70 69 u8 active_port = 0;
71 70 int num_enabled;
72 71 int idx;
73 72
74 - mlx5_infer_tx_enabled(tracker, ldev, enabled_ports,
73 + mlx5_infer_tx_enabled(&ldev->tracker, ldev, enabled_ports,
75 74 &num_enabled);
76 75 for (idx = 0; idx < num_enabled; idx++)
77 76 active_port |= BIT_MASK(enabled_ports[idx]);
@@ -80,8 +79,7 @@ static u8 lag_active_port_bits(struct mlx5_lag *ldev,
80 79 }
81 80
82 81 static int mlx5_cmd_create_lag(struct mlx5_core_dev *dev, struct mlx5_lag *ldev,
83 - struct lag_tracker *tracker, int mode,
84 - unsigned long flags)
82 + int mode, unsigned long flags)
85 83 {
86 84 bool fdb_sel_mode = test_bit(MLX5_LAG_MODE_FLAG_FDB_SEL_MODE_NATIVE,
87 85 &flags);
@@ -110,7 +108,7 @@ static int mlx5_cmd_create_lag(struct mlx5_core_dev *dev, struct mlx5_lag *ldev,
110 108 break;
111 109
112 110 MLX5_SET(lagc, lag_ctx, active_port,
113 - lag_active_port_bits(ldev, tracker));
111 + lag_active_port_bits(mlx5_lag_dev(dev)));
114 112 break;
115 113 default:
116 114 break;
@@ -789,8 +787,7 @@ static int mlx5_cmd_modify_active_port(struct mlx5_core_dev *dev, u8 ports)
789 787 return mlx5_cmd_exec_in(dev, modify_lag, in);
790 788 }
791 789
792 - static int _mlx5_modify_lag(struct mlx5_lag *ldev,
793 - struct lag_tracker *tracker, u8 *ports)
790 + static int _mlx5_modify_lag(struct mlx5_lag *ldev, u8 *ports)
794 791 {
795 792 int idx = mlx5_lag_get_dev_index_by_seq(ldev, MLX5_LAG_P1);
796 793 struct mlx5_core_dev *dev0;
@@ -807,7 +804,7 @@ static int _mlx5_modify_lag(struct mlx5_lag *ldev,
807 804 !MLX5_CAP_PORT_SELECTION(dev0, port_select_flow_table_bypass))
808 805 return ret;
809 806
810 - active_ports = lag_active_port_bits(ldev, tracker);
807 + active_ports = lag_active_port_bits(ldev);
811 808
812 809 return mlx5_cmd_modify_active_port(dev0, active_ports);
813 810 }
@@ -871,7 +868,7 @@ void mlx5_modify_lag(struct mlx5_lag *ldev,
871 868 idx = i * ldev->buckets + j;
872 869 if (ports[idx] == ldev->v2p_map[idx])
873 870 continue;
874 - err = _mlx5_modify_lag(ldev, tracker, ports);
871 + err = _mlx5_modify_lag(ldev, ports);
875 872 if (err) {
876 873 mlx5_core_err(dev0,
877 874 "Failed to modify LAG (%d)\n",
@@ -979,7 +976,7 @@ static int mlx5_create_lag(struct mlx5_lag *ldev,
979 976 mlx5_core_info(dev0, "shared_fdb:%d mode:%s\n",
980 977 shared_fdb, mlx5_get_str_port_sel_mode(mode, flags));
981 978
982 - err = mlx5_cmd_create_lag(dev0, ldev, tracker, mode, flags);
979 + err = mlx5_cmd_create_lag(dev0, ldev, mode, flags);
983 980 if (err) {
984 981 mlx5_core_err(dev0,
985 982 "Failed to create LAG (%d)\n",
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/mellanox/mlxsw/spectrum_ptp.c
@@ -572,38 +572,6 @@ mlxsw_sp1_ptp_unmatched_remove(struct mlxsw_sp *mlxsw_sp,
572 572 mlxsw_sp1_ptp_unmatched_ht_params);
573 573 }
574 574
575 - /* mlxsw_sp1_ptp_packet_finish() is reached both from the NAPI poll context
576 - * (mlxsw_sp1_ptp_got_packet(), mlxsw_sp1_ptp_got_piece() and
577 - * mlxsw_sp1_packet_timestamp()) and from process context, by way of the GC
578 - * workqueue (mlxsw_sp1_ptp_ht_gc_collect() ->
579 - * mlxsw_sp1_ptp_unmatched_finish()).
580 - *
581 - * mlxsw_sp_rx_listener_no_mark_func() ends in napi_gro_receive(), using the
582 - * NAPI pointer that was placed in the SKB control block when the trapped
583 - * packet was received in the NAPI context. That pointer may only be used
584 - * from its own poll context, which this call site cannot guarantee.
585 - *
586 - * netif_receive_skb(), unlike napi_gro_receive(), can be called from outside
587 - * of the NAPI instance's poll context. RX stats accounting and the skb->dev
588 - * assignment are still preserved; the only change is the delivery call.
589 - */
590 - static void mlxsw_sp1_ptp_rx_finish(struct mlxsw_sp_port *mlxsw_sp_port,
591 - struct sk_buff *skb)
592 - {
593 - struct mlxsw_sp_port_pcpu_stats *pcpu_stats;
594 -
595 - skb->dev = mlxsw_sp_port->dev;
596 -
597 - pcpu_stats = this_cpu_ptr(mlxsw_sp_port->pcpu_stats);
598 - u64_stats_update_begin(&pcpu_stats->syncp);
599 - pcpu_stats->rx_packets++;
600 - pcpu_stats->rx_bytes += skb->len;
601 - u64_stats_update_end(&pcpu_stats->syncp);
602 -
603 - skb->protocol = eth_type_trans(skb, skb->dev);
604 - netif_receive_skb(skb);
605 - }
606 -
607 575 /* This function is called in the following scenarios:
608 576 *
609 577 * 1) When a packet is matched with its timestamp.
@@ -632,7 +600,7 @@ static void mlxsw_sp1_ptp_packet_finish(struct mlxsw_sp *mlxsw_sp,
632 600 if (ingress) {
633 601 if (hwtstamps)
634 602 *skb_hwtstamps(skb) = *hwtstamps;
635 - mlxsw_sp1_ptp_rx_finish(mlxsw_sp_port, skb);
603 + mlxsw_sp_rx_listener_no_mark_func(skb, local_port, mlxsw_sp);
636 604 } else {
637 605 /* skb_tstamp_tx() allows hwtstamps to be NULL. */
638 606 skb_tstamp_tx(skb, hwtstamps);
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/micrel/ks8851_common.c
@@ -143,6 +143,9 @@ static int ks8851_write_mac_addr(struct net_device *dev)
143 143 ks8851_wrreg16(ks, KS_MAR(i), val);
144 144 }
145 145
146 + if (!netif_running(dev))
147 + ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN);
148 +
146 149 ks8851_unlock(ks);
147 150
148 151 return 0;
@@ -475,7 +478,8 @@ static int ks8851_net_open(struct net_device *dev)
475 478 * @dev: The device being closed.
476 479 *
477 480 * Called to close down a network device which has been active. Cancel any
478 - * work and shutdown the RX and TX process.
481 + * work, shutdown the RX and TX process and then place the chip into a low
482 + * power state whilst it is not being used.
479 483 */
480 484 static int ks8851_net_stop(struct net_device *dev)
481 485 {
@@ -502,6 +506,8 @@ static int ks8851_net_stop(struct net_device *dev)
502 506 /* shutdown TX process */
503 507 ks8851_wrreg16(ks, KS_TXCR, 0x0000);
504 508
509 + /* set powermode to soft power down to save power */
510 + ks8851_set_powermode(ks, PMECR_PM_SOFTDOWN);
505 511 ks8851_unlock(ks);
506 512
507 513 /* ensure any queued tx buffers are dumped */
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/microsoft/mana/mana_bpf.c
@@ -208,7 +208,6 @@ static int mana_xdp_set(struct net_device *ndev, struct bpf_prog *prog,
208 208 if (err) {
209 209 NL_SET_ERR_MSG_MOD(extack,
210 210 "XDP: Insufficient memory for tx/rx re-config");
211 - apc->bpf_prog = old_prog;
212 211 return err;
213 212 }
214 213
modified drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -2986,10 +2986,6 @@ static int mana_alloc_rx_wqe(struct mana_port_context *apc,
2986 2986 *cq_size += COMP_ENTRY_SIZE;
2987 2987 }
2988 2988
2989 - /* Reserve an extra slot for Fence completion
2990 - * event (CQE_RX_OBJECT_FENCE) in case RX CQ is full.
2991 - */
2992 - *cq_size += COMP_ENTRY_SIZE;
2993 2989 return 0;
2994 2990 }
2995 2991
@@ -3084,7 +3080,7 @@ static struct mana_rxq *mana_create_rxq(struct mana_port_context *apc,
3084 3080 goto out;
3085 3081
3086 3082 rq_size = MANA_PAGE_ALIGN(rq_size);
3087 - cq_size = MANA_PAGE_ALIGN(roundup_pow_of_two(cq_size));
3083 + cq_size = MANA_PAGE_ALIGN(cq_size);
3088 3084
3089 3085 /* Create RQ */
3090 3086 memset(&spec, 0, sizeof(spec));
@@ -3987,8 +3983,7 @@ static void mana_rdma_service_handle(struct work_struct *work)
3987 3983 struct device *dev = gd->gdma_context->dev;
3988 3984 int ret;
3989 3985
3990 - /* Pairs with the smp_store_release() in mana_rdma_probe(). */
3991 - if (smp_load_acquire(&gd->rdma_teardown))
3986 + if (READ_ONCE(gd->rdma_teardown))
3992 3987 goto out;
3993 3988
3994 3989 switch (serv_work->event) {
@@ -4284,21 +4279,6 @@ int mana_rdma_probe(struct gdma_dev *gd)
4284 4279 if (err)
4285 4280 return err;
4286 4281
4287 - /* Clear the state left by a previous mana_rdma_remove() so servicing
4288 - * events are handled again after a reset cycle.
4289 - */
4290 - gd->is_suspended = false;
4291 -
4292 - /* Publish is_suspended before re-opening the gate, so the handler
4293 - * cannot observe an open gate with a stale is_suspended. Pairs
4294 - * with the smp_load_acquire() in mana_rdma_service_handle(). This
4295 - * matters on the reset path, where mana_rdma_remove() closed the
4296 - * gate and drained the workqueue; on the initial probe path the
4297 - * gate was never closed and both flags are already clear. It does
4298 - * not order gd->adev, which add_adev() publishes below.
4299 - */
4300 - smp_store_release(&gd->rdma_teardown, false);
4301 -
4302 4282 err = add_adev(gd, "rdma");
4303 4283 if (err)
4304 4284 mana_gd_deregister_device(gd);
modified drivers/net/ethernet/netronome/nfp/nfp_net_ethtool.c
@@ -1421,8 +1421,7 @@ static int nfp_net_get_fs_rule(struct nfp_net *nn, struct ethtool_rxnfc *cmd)
1421 1421 return -ENOENT;
1422 1422 }
1423 1423
1424 - static int nfp_net_get_fs_loc(struct nfp_net *nn, struct ethtool_rxnfc *cmd,
1425 - u32 *rule_locs)
1424 + static int nfp_net_get_fs_loc(struct nfp_net *nn, u32 *rule_locs)
1426 1425 {
1427 1426 struct nfp_fs_entry *entry;
1428 1427 u32 count = 0;
@@ -1430,12 +1429,8 @@ static int nfp_net_get_fs_loc(struct nfp_net *nn, struct ethtool_rxnfc *cmd,
1430 1429 if (!(nn->cap_w1 & NFP_NET_CFG_CTRL_FLOW_STEER))
1431 1430 return -EOPNOTSUPP;
1432 1431
1433 - list_for_each_entry(entry, &nn->fs.list, node) {
1434 - if (count == cmd->rule_cnt)
1435 - return -EMSGSIZE;
1432 + list_for_each_entry(entry, &nn->fs.list, node)
1436 1433 rule_locs[count++] = entry->loc;
1437 - }
1438 - cmd->rule_cnt = count;
1439 1434
1440 1435 return 0;
1441 1436 }
@@ -1460,7 +1455,7 @@ static int nfp_net_get_rxnfc(struct net_device *netdev,
1460 1455 return nfp_net_get_fs_rule(nn, cmd);
1461 1456 case ETHTOOL_GRXCLSRLALL:
1462 1457 cmd->data = NFP_FS_MAX_ENTRY;
1463 - return nfp_net_get_fs_loc(nn, cmd, rule_locs);
1458 + return nfp_net_get_fs_loc(nn, rule_locs);
1464 1459 default:
1465 1460 return -EOPNOTSUPP;
1466 1461 }
@@ -1703,14 +1698,8 @@ static int nfp_net_fs_add(struct nfp_net *nn, struct ethtool_rxnfc *cmd)
1703 1698
1704 1699 nn->fs.count--;
1705 1700 err = nfp_net_fs_add_hw(nn, new);
1706 - if (err) {
1707 - /* mbox broken, adding the old rule back will
1708 - * likely also fail.
1709 - */
1710 - list_del(&entry->node);
1711 - kfree(entry);
1701 + if (err)
1712 1702 goto err;
1713 - }
1714 1703
1715 1704 nn->fs.count++;
1716 1705 list_replace(&entry->node, &new->node);
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/pensando/ionic/ionic_txrx.c
@@ -1672,22 +1672,15 @@ static int ionic_tx(struct net_device *netdev, struct ionic_queue *q,
1672 1672 stats->pkts++;
1673 1673 stats->bytes += skb->len;
1674 1674
1675 - ionic_txq_post(q, false);
1676 -
1677 1675 if (likely(!ionic_txq_hwstamp_enabled(q))) {
1678 1676 struct netdev_queue *ndq = q_to_ndq(netdev, q);
1679 1677
1680 - netif_txq_maybe_stop(ndq, ionic_q_space_avail(q),
1681 - MAX_SKB_FRAGS + 1, MAX_SKB_FRAGS + 1);
1678 + if (unlikely(!ionic_q_has_space(q, MAX_SKB_FRAGS + 1)))
1679 + netif_tx_stop_queue(ndq);
1682 1680 ring_dbell = __netdev_tx_sent_queue(ndq, skb->len,
1683 1681 netdev_xmit_more());
1684 1682 }
1685 -
1686 - if (ring_dbell) {
1687 - ionic_dbell_ring(q->lif->kern_dbpage, q->hw_type,
1688 - q->dbval | q->head_idx);
1689 - q->dbell_jiffies = jiffies;
1690 - }
1683 + ionic_txq_post(q, ring_dbell);
1691 1684
1692 1685 return 0;
1693 1686 }
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);
@@ -4454,26 +4445,6 @@ static bool stmmac_tso_valid_packet(struct sk_buff *skb)
4454 4445 header_len + gso_size < 16383;
4455 4446 }
4456 4447
4457 - static int stmmac_tso_get_num_desc(struct stmmac_tx_queue *tx_q,
4458 - struct sk_buff *skb, u32 pay_len)
4459 - {
4460 - int i, ndesc = 1;
4461 -
4462 - /* head payload */
4463 - ndesc += DIV_ROUND_UP(pay_len, TSO_MAX_BUFF_SIZE);
4464 - /* frag payload */
4465 - for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
4466 - const skb_frag_t *frag = &skb_shinfo(skb)->frags[i];
4467 -
4468 - ndesc += DIV_ROUND_UP(skb_frag_size(frag),
4469 - TSO_MAX_BUFF_SIZE);
4470 - }
4471 - /* MSS update requires a new descriptor */
4472 - ndesc += !!(skb_shinfo(skb)->gso_size != tx_q->mss);
4473 -
4474 - return ndesc;
4475 - }
4476 -
4477 4448 /**
4478 4449 * stmmac_tso_xmit - Tx entry point of the driver for oversized frames (TSO)
4479 4450 * @skb : the socket buffer
@@ -4515,12 +4486,12 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
4515 4486 {
4516 4487 struct dma_desc *desc, *first, *mss_desc = NULL;
4517 4488 struct stmmac_priv *priv = netdev_priv(dev);
4518 - unsigned int first_entry, entry, tx_packets;
4489 + unsigned int first_entry, tx_packets;
4519 4490 struct stmmac_txq_stats *txq_stats;
4520 - int i, first_tx, nfrags, ndesc;
4521 4491 struct stmmac_tx_queue *tx_q;
4522 4492 bool set_ic, is_last_segment;
4523 4493 u32 pay_len, mss, queue;
4494 + int i, first_tx, nfrags;
4524 4495 u8 proto_hdr_len, hdr;
4525 4496 dma_addr_t des;
4526 4497
@@ -4533,15 +4504,14 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
4533 4504
4534 4505 /* Compute header lengths */
4535 4506 proto_hdr_len = stmmac_tso_header_size(skb);
4536 - pay_len = skb_headlen(skb) - proto_hdr_len; /* no frags */
4537 -
4538 4507 if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4)
4539 4508 hdr = sizeof(struct udphdr);
4540 4509 else
4541 4510 hdr = tcp_hdrlen(skb);
4542 4511
4543 - ndesc = stmmac_tso_get_num_desc(tx_q, skb, pay_len);
4544 - if (unlikely(stmmac_tx_avail(priv, queue) < ndesc)) {
4512 + /* Desc availability based on threshold should be enough safe */
4513 + if (unlikely(stmmac_tx_avail(priv, queue) <
4514 + (((skb->len - proto_hdr_len) / TSO_MAX_BUFF_SIZE + 1)))) {
4545 4515 if (!netif_tx_queue_stopped(netdev_get_tx_queue(dev, queue))) {
4546 4516 netif_tx_stop_queue(netdev_get_tx_queue(priv->dev,
4547 4517 queue));
@@ -4553,6 +4523,8 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
4553 4523 return NETDEV_TX_BUSY;
4554 4524 }
4555 4525
4526 + pay_len = skb_headlen(skb) - proto_hdr_len; /* no frags */
4527 +
4556 4528 mss = skb_shinfo(skb)->gso_size;
4557 4529
4558 4530 /* set new MSS value if needed */
@@ -4577,24 +4549,22 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
4577 4549 }
4578 4550
4579 4551 first_entry = tx_q->cur_tx;
4580 - entry = first_entry;
4581 -
4582 - WARN_ON(tx_q->tx_skbuff[entry]);
4552 + WARN_ON(tx_q->tx_skbuff[first_entry]);
4583 4553
4584 4554 if (tx_q->tbs & STMMAC_TBS_AVAIL)
4585 - desc = &tx_q->dma_entx[entry].basic;
4555 + desc = &tx_q->dma_entx[first_entry].basic;
4586 4556 else
4587 - desc = &tx_q->dma_tx[entry];
4557 + desc = &tx_q->dma_tx[first_entry];
4588 4558 first = desc;
4589 4559
4590 4560 /* first descriptor: fill Headers on Buf1 */
4591 4561 des = dma_map_single(priv->device, skb->data, skb_headlen(skb),
4592 4562 DMA_TO_DEVICE);
4593 4563 if (dma_mapping_error(priv->device, des))
4594 - goto error;
4564 + goto dma_map_err;
4595 4565
4596 4566 stmmac_set_desc_addr(priv, first, des);
4597 - stmmac_tso_allocator(priv, &entry, des + proto_hdr_len, pay_len,
4567 + stmmac_tso_allocator(priv, des + proto_hdr_len, pay_len,
4598 4568 (nfrags == 0), queue);
4599 4569
4600 4570 /* In case two or more DMA transmit descriptors are allocated for this
@@ -4609,7 +4579,8 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
4609 4579 * this DMA buffer right after the DMA engine completely finishes the
4610 4580 * full buffer transmission.
4611 4581 */
4612 - 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);
4613 4584
4614 4585 /* Prepare fragments */
4615 4586 for (i = 0; i < nfrags; i++) {
@@ -4619,15 +4590,14 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
4619 4590 skb_frag_size(frag),
4620 4591 DMA_TO_DEVICE);
4621 4592 if (dma_mapping_error(priv->device, des))
4622 - goto error_dma_unmap;
4593 + goto dma_map_err;
4623 4594
4624 - stmmac_tso_allocator(priv, &entry, des, skb_frag_size(frag),
4595 + stmmac_tso_allocator(priv, des, skb_frag_size(frag),
4625 4596 (i == nfrags - 1), queue);
4626 4597
4627 - stmmac_set_tx_skb_dma_entry(tx_q, entry, des,
4598 + stmmac_set_tx_skb_dma_entry(tx_q, tx_q->cur_tx, des,
4628 4599 skb_frag_size(frag), true);
4629 4600 }
4630 - tx_q->cur_tx = entry;
4631 4601
4632 4602 stmmac_set_tx_dma_last_segment(tx_q, tx_q->cur_tx);
4633 4603
@@ -4732,19 +4702,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
4732 4702
4733 4703 return NETDEV_TX_OK;
4734 4704
4735 - error_dma_unmap:
4736 - for (;;) {
4737 - desc = stmmac_get_tx_desc(priv, tx_q, first_entry);
4738 - stmmac_release_tx_desc(priv, desc, priv->descriptor_mode);
4739 - stmmac_free_tx_buffer(priv, &priv->dma_conf, queue,
4740 - first_entry);
4741 - if (first_entry == entry)
4742 - break;
4743 -
4744 - first_entry = STMMAC_NEXT_ENTRY(first_entry,
4745 - priv->dma_conf.dma_tx_size);
4746 - }
4747 - error:
4705 + dma_map_err:
4748 4706 dev_err(priv->device, "Tx dma map failed\n");
4749 4707 dev_kfree_skb(skb);
4750 4708 priv->xstats.tx_dropped++;
@@ -8044,7 +8002,6 @@ static int __stmmac_dvr_probe(struct device *device,
8044 8002 stmmac_napi_add(ndev);
8045 8003
8046 8004 mutex_init(&priv->lock);
8047 - rwlock_init(&priv->ptp_lock);
8048 8005
8049 8006 stmmac_fpe_init(priv);
8050 8007
modified drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
@@ -365,6 +365,7 @@ void stmmac_ptp_register(struct stmmac_priv *priv)
365 365 if (priv->plat->crosststamp)
366 366 priv->ptp_clock_ops.getcrosststamp = stmmac_getcrosststamp;
367 367
368 + rwlock_init(&priv->ptp_lock);
368 369 mutex_init(&priv->aux_ts_lock);
369 370
370 371 priv->ptp_clock = ptp_clock_register(&priv->ptp_clock_ops,
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/ieee802154/cc2520.c
@@ -1156,10 +1156,11 @@ static void cc2520_remove(struct spi_device *spi)
1156 1156 {
1157 1157 struct cc2520_private *priv = spi_get_drvdata(spi);
1158 1158
1159 - disable_work_sync(&priv->fifop_irqwork);
1159 + mutex_destroy(&priv->buffer_mutex);
1160 + flush_work(&priv->fifop_irqwork);
1161 +
1160 1162 ieee802154_unregister_hw(priv->hw);
1161 1163 ieee802154_free_hw(priv->hw);
1162 - mutex_destroy(&priv->buffer_mutex);
1163 1164 }
1164 1165
1165 1166 static const struct spi_device_id cc2520_ids[] = {
modified drivers/net/ieee802154/mac802154_hwsim.c
@@ -72,8 +72,6 @@ struct hwsim_phy {
72 72 struct ieee802154_hw *hw;
73 73 u32 idx;
74 74
75 - /* Serializes phy->pib_updates. */
76 - spinlock_t pib_lock;
77 75 struct hwsim_pib __rcu *pib;
78 76
79 77 bool suspended;
@@ -104,6 +102,8 @@ static int hwsim_update_pib(struct ieee802154_hw *hw, u8 page, u8 channel,
104 102 if (!pib)
105 103 return -ENOMEM;
106 104
105 + pib_old = rtnl_dereference(phy->pib);
106 +
107 107 pib->page = page;
108 108 pib->channel = channel;
109 109 pib->filt.short_addr = filt->short_addr;
@@ -112,10 +112,7 @@ static int hwsim_update_pib(struct ieee802154_hw *hw, u8 page, u8 channel,
112 112 pib->filt.pan_coord = filt->pan_coord;
113 113 pib->filt_level = filt_level;
114 114
115 - spin_lock_bh(&phy->pib_lock);
116 - pib_old = rcu_replace_pointer(phy->pib, pib,
117 - lockdep_is_held(&phy->pib_lock));
118 - spin_unlock_bh(&phy->pib_lock);
115 + rcu_assign_pointer(phy->pib, pib);
119 116 kfree_rcu(pib_old, rcu);
120 117 return 0;
121 118 }
@@ -955,7 +952,6 @@ static int hwsim_add_one(struct genl_info *info, struct device *dev,
955 952 goto err_pib;
956 953 }
957 954
958 - spin_lock_init(&phy->pib_lock);
959 955 pib->channel = 13;
960 956 pib->filt.short_addr = cpu_to_le16(IEEE802154_ADDR_BROADCAST);
961 957 pib->filt.pan_id = cpu_to_le16(IEEE802154_PANID_BROADCAST);
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/mctp/mctp-i3c.c
@@ -288,7 +288,6 @@ err:
288 288 static int mctp_i3c_probe(struct i3c_device *i3c)
289 289 {
290 290 struct mctp_i3c_bus *b = NULL, *mbus = NULL;
291 - int rc;
292 291
293 292 /* Look for a known bus */
294 293 mutex_lock(&busdevs_lock);
@@ -297,16 +296,14 @@ static int mctp_i3c_probe(struct i3c_device *i3c)
297 296 mbus = b;
298 297 break;
299 298 }
299 + mutex_unlock(&busdevs_lock);
300 300
301 301 if (!mbus) {
302 302 /* probably no "mctp-controller" property on the i3c bus */
303 - rc = -ENODEV;
304 - } else {
305 - rc = mctp_i3c_add_device(mbus, i3c);
303 + return -ENODEV;
306 304 }
307 - mutex_unlock(&busdevs_lock);
308 305
309 - return rc;
306 + return mctp_i3c_add_device(mbus, i3c);
310 307 }
311 308
312 309 static void mctp_i3c_remove_device(struct mctp_i3c_device *mi)
modified drivers/net/net_failover.c
@@ -675,7 +675,7 @@ static int net_failover_slave_name_change(struct net_device *slave_dev,
675 675 /* We need to bring up the slave after the rename by udev in case
676 676 * open failed with EBUSY when it was registered.
677 677 */
678 - netif_open(slave_dev, NULL);
678 + dev_open(slave_dev, NULL);
679 679
680 680 return 0;
681 681 }
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/phy/dp83867.c
@@ -1150,9 +1150,6 @@ static int dp83867_led_polarity_set(struct phy_device *phydev, int index,
1150 1150 case PHY_LED_ACTIVE_LOW:
1151 1151 polarity = 0;
1152 1152 break;
1153 - case PHY_LED_ACTIVE_HIGH:
1154 - polarity = DP83867_LED_POLARITY(index);
1155 - break;
1156 1153 default:
1157 1154 return -EINVAL;
1158 1155 }
modified drivers/net/phy/dp83td510.c
@@ -439,9 +439,6 @@ static int dp83td510_led_polarity_set(struct phy_device *phydev, int index,
439 439 case PHY_LED_ACTIVE_LOW:
440 440 polarity = 0;
441 441 break;
442 - case PHY_LED_ACTIVE_HIGH:
443 - polarity = DP83TD510E_LED_POLARITY(index);
444 - break;
445 442 default:
446 443 return -EINVAL;
447 444 }
modified drivers/net/phy/mediatek/mtk-ge.c
@@ -62,38 +62,10 @@ static void mtk_gephy_config_init(struct phy_device *phydev)
62 62 FIELD_PREP(MTK_MCC_NEARECHO_OFFSET_MASK, 0x3));
63 63 }
64 64
65 - static int mt7530_phy_probe(struct phy_device *phydev)
66 - {
67 - /* The MT7530 internal GE PHY has broken EEE: with EEE advertised,
68 - * some link partners fail to establish a stable link (on a 2-pair
69 - * cable, 1000BASE-T training fails and the port loops instead of
70 - * falling back). MediaTek recommends disabling EEE on this PHY.
71 - * Clear the advertisement as early as possible, before anything
72 - * can negotiate EEE with the link partner.
73 - */
74 - return phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, 0);
75 - }
76 -
77 65 static int mt7530_phy_config_init(struct phy_device *phydev)
78 66 {
79 - int ret;
80 -
81 67 mtk_gephy_config_init(phydev);
82 68
83 - /* The probe() clear alone is not durable: phy_init_hw() replays only
84 - * ->config_init after a PHY reset, with the register back at its
85 - * EEE-advertising hardware default, and phy_probe() zeroes
86 - * eee_disabled_modes (of_set_phy_eee_broken()) after ->probe already
87 - * ran. Clear the advertisement again and mark EEE disabled, so that
88 - * neither phylib nor userspace can re-enable it; dp83867 disables
89 - * broken EEE from config_init() the same way.
90 - */
91 - ret = phy_write_mmd(phydev, MDIO_MMD_AN, MDIO_AN_EEE_ADV, 0);
92 - if (ret)
93 - return ret;
94 -
95 - phy_disable_eee(phydev);
96 -
97 69 /* Increase post_update_timer */
98 70 phy_write_paged(phydev, MTK_PHY_PAGE_EXTENDED_3,
99 71 MTK_PHY_RG_LPI_PCS_DSP_CTRL_REG11, 0x4b);
@@ -128,7 +100,6 @@ static struct phy_driver mtk_gephy_driver[] = {
128 100 {
129 101 PHY_ID_MATCH_EXACT(MTK_GPHY_ID_MT7530),
130 102 .name = "MediaTek MT7530 PHY",
131 - .probe = mt7530_phy_probe,
132 103 .config_init = mt7530_phy_config_init,
133 104 /* Interrupts are handled by the switch, not the PHY
134 105 * itself.
modified drivers/net/phy/phylink.c
@@ -1630,10 +1630,8 @@ static void phylink_resolve(struct work_struct *w)
1630 1630
1631 1631 if (pl->phylink_disable_state) {
1632 1632 pl->link_failed = false;
1633 - link_state = pl->link_config;
1634 1633 link_state.link = false;
1635 1634 } else if (pl->link_failed) {
1636 - link_state = pl->link_config;
1637 1635 link_state.link = false;
1638 1636 retrigger = true;
1639 1637 } else if (pl->act_link_an_mode == MLO_AN_FIXED) {
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,
@@ -742,8 +810,11 @@ process_input_packet(struct asyncppp *ap)
742 810 err:
743 811 /* frame had an error, remember that, reset SC_TOSS & SC_ESCAPE */
744 812 ap->state = SC_PREV_ERROR;
745 - kfree_skb(skb);
746 - ap->rpkt = NULL;
813 + if (skb) {
814 + /* make skb appear as freshly allocated */
815 + skb_trim(skb, 0);
816 + skb_reserve(skb, - skb_headroom(skb));
817 + }
747 818 }
748 819
749 820 /* Called when the tty driver has data for us. Runs parallel with the
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,
@@ -455,9 +524,17 @@ ppp_sync_txmunge(struct syncppp *ap, struct sk_buff *skb)
455 524
456 525 /* prepend address/control fields if necessary */
457 526 if ((ap->flags & SC_COMP_AC) == 0 || islcp) {
458 - if (skb_cow_head(skb, 2)) {
459 - kfree_skb(skb);
460 - return NULL;
527 + if (skb_headroom(skb) < 2) {
528 + struct sk_buff *npkt = dev_alloc_skb(skb->len + 2);
529 + if (npkt == NULL) {
530 + kfree_skb(skb);
531 + return NULL;
532 + }
533 + skb_reserve(npkt,2);
534 + skb_copy_from_linear_data(skb,
535 + skb_put(npkt, skb->len), skb->len);
536 + consume_skb(skb);
537 + skb = npkt;
461 538 }
462 539 skb_push(skb,2);
463 540 skb->data[0] = PPP_ALLSTATIONS;
modified drivers/net/usb/cx82310_eth.c
@@ -282,7 +282,6 @@ static int cx82310_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
282 282 if (len == 0xffff) {
283 283 netdev_info(dev->net, "router was rebooted, re-enabling ethernet mode");
284 284 schedule_work(&priv->reenable_work);
285 - return 0;
286 285 } else if (len > CX82310_MTU) {
287 286 netdev_err(dev->net, "RX packet too long: %d B\n", len);
288 287 return 0;
modified drivers/net/usb/hso.c
@@ -1547,10 +1547,10 @@ hso_wait_modem_status(struct hso_serial *serial, unsigned long arg)
1547 1547 spin_unlock_irq(&serial->serial_lock);
1548 1548 add_wait_queue(&tiocmget->waitq, &wait);
1549 1549 for (;;) {
1550 - set_current_state(TASK_INTERRUPTIBLE);
1551 1550 spin_lock_irq(&serial->serial_lock);
1552 1551 memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount));
1553 1552 spin_unlock_irq(&serial->serial_lock);
1553 + set_current_state(TASK_INTERRUPTIBLE);
1554 1554 if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
1555 1555 ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
1556 1556 ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd))) {
modified drivers/net/usb/qmi_wwan.c
@@ -1084,7 +1084,6 @@ static const struct usb_device_id products[] = {
1084 1084 },
1085 1085 {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0122)}, /* Quectel RG650V */
1086 1086 {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0125)}, /* Quectel EC25, EC20 R2.0 Mini PCIe */
1087 - {QMI_MATCH_FF_FF_FF(0x2c7c, 0x013d)}, /* Quectel RG660QB */
1088 1087 {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0306)}, /* Quectel EP06/EG06/EM06 */
1089 1088 {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0512)}, /* Quectel EG12/EM12 */
1090 1089 {QMI_MATCH_FF_FF_FF(0x2c7c, 0x0620)}, /* Quectel EM160R-GL */
@@ -1447,7 +1446,6 @@ static const struct usb_device_id products[] = {
1447 1446 {QMI_QUIRK_SET_DTR(0x2c7c, 0x0316, 3)}, /* Quectel RG255C */
1448 1447 {QMI_QUIRK_SET_DTR(0x2cb7, 0x0104, 4)}, /* Fibocom NL678 series */
1449 1448 {QMI_QUIRK_SET_DTR(0x2cb7, 0x0112, 0)}, /* Fibocom FG132 */
1450 - {QMI_QUIRK_SET_DTR(0x04b7, 0x8217, 8)}, /* Compal EXM-G1x */
1451 1449 {QMI_FIXED_INTF(0x0489, 0xe0b4, 0)}, /* Foxconn T77W968 LTE */
1452 1450 {QMI_FIXED_INTF(0x0489, 0xe0b5, 0)}, /* Foxconn T77W968 LTE with eSIM support*/
1453 1451 {QMI_FIXED_INTF(0x2692, 0x9025, 4)}, /* Cellient MPL200 (rebranded Qualcomm 05c6:9025) */
modified drivers/net/vxlan/vxlan_core.c
@@ -996,12 +996,6 @@ static int vxlan_fdb_update_existing(struct vxlan_dev *vxlan,
996 996 return -EOPNOTSUPP;
997 997 }
998 998
999 - if (rcu_access_pointer(f->nh) &&
1000 - !(state & (NUD_PERMANENT | NUD_NOARP))) {
1001 - NL_SET_ERR_MSG(extack, "Cannot make a nexthop fdb dynamic");
1002 - return -EOPNOTSUPP;
1003 - }
1004 -
1005 999 /* Do not allow an externally learned entry to take over an entry added
1006 1000 * by the user.
1007 1001 */
@@ -1263,11 +1257,6 @@ static int vxlan_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
1263 1257 if (err)
1264 1258 return err;
1265 1259
1266 - if (nhid && !(ndm->ndm_state & (NUD_PERMANENT | NUD_NOARP))) {
1267 - NL_SET_ERR_MSG(extack, "A nexthop fdb cannot be dynamic");
1268 - return -EINVAL;
1269 - }
1270 -
1271 1260 if (vxlan->default_dst.remote_ip.sa.sa_family != ip.sa.sa_family)
1272 1261 return -EAFNOSUPPORT;
1273 1262
@@ -2373,7 +2362,7 @@ void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
2373 2362 struct ip_tunnel_key key;
2374 2363 struct vxlan_dev *vxlan = netdev_priv(dev);
2375 2364 const struct iphdr *old_iph;
2376 - struct vxlan_metadata _md = {};
2365 + struct vxlan_metadata _md;
2377 2366 struct vxlan_metadata *md = &_md;
2378 2367 unsigned int pkt_len = skb->len;
2379 2368 __be16 src_port = 0, dst_port;
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/mcu.c
@@ -477,23 +477,18 @@ static int mt7921_load_clc(struct mt792x_dev *dev, const char *fw_name)
477 477
478 478 for (offset = 0; offset < len; offset += clc_len) {
479 479 if (len - offset < sizeof(*clc)) {
480 - dev_err(mdev->dev, "Invalid CLC record\n");
481 480 ret = -EINVAL;
482 481 goto out;
483 482 }
484 483
485 484 clc = (const struct mt7921_clc *)(clc_base + offset);
486 485 clc_len = le32_to_cpu(clc->len);
487 - if (clc_len < sizeof(*clc) || clc_len > len - offset) {
488 - dev_err(mdev->dev, "Invalid CLC record\n");
486 + if (clc_len < sizeof(*clc) || clc_len > len - offset ||
487 + clc->idx >= ARRAY_SIZE(phy->clc)) {
489 488 ret = -EINVAL;
490 489 goto out;
491 490 }
492 491
493 - /* Newer firmware may add records this driver does not use yet */
494 - if (clc->idx >= ARRAY_SIZE(phy->clc))
495 - continue;
496 -
497 492 /* do not init buf again if chip reset triggered */
498 493 if (phy->clc[clc->idx])
499 494 continue;
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/mediatek/mt76/mt792x_acpi_sar.c
@@ -323,8 +323,7 @@ int mt792x_init_acpi_sar_power(struct mt792x_phy *phy, bool set_default)
323 323 const struct cfg80211_sar_capa *capa = phy->mt76->hw->wiphy->sar_capa;
324 324 int i;
325 325
326 - if (!capa || !phy->acpisar ||
327 - !((struct mt792x_acpi_sar *)phy->acpisar)->dyn)
326 + if (!phy->acpisar || !((struct mt792x_acpi_sar *)phy->acpisar)->dyn)
328 327 return 0;
329 328
330 329 /* When ACPI SAR enabled in HW, we should apply rules for .frp
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
@@ -453,8 +453,8 @@ int dev_pm_opp_get_opp_count(struct device *dev)
453 453 _find_opp_table(dev);
454 454
455 455 if (IS_ERR(opp_table)) {
456 - dev_dbg(dev, "%s: OPP table not found (%pe)\n",
457 - __func__, opp_table);
456 + dev_dbg(dev, "%s: OPP table not found (%ld)\n",
457 + __func__, PTR_ERR(opp_table));
458 458 return PTR_ERR(opp_table);
459 459 }
460 460
@@ -611,8 +611,8 @@ _find_key(struct device *dev, unsigned long *key, int index, bool available,
611 611 _find_opp_table(dev);
612 612
613 613 if (IS_ERR(opp_table)) {
614 - dev_err(dev, "%s: OPP table not found (%pe)\n", __func__,
615 - opp_table);
614 + dev_err(dev, "%s: OPP table not found (%ld)\n", __func__,
615 + PTR_ERR(opp_table));
616 616 return ERR_CAST(opp_table);
617 617 }
618 618
@@ -722,8 +722,8 @@ struct dev_pm_opp *dev_pm_opp_find_key_exact(struct device *dev,
722 722 struct opp_table *opp_table __free(put_opp_table) = _find_opp_table(dev);
723 723
724 724 if (IS_ERR(opp_table)) {
725 - dev_err(dev, "%s: OPP table not found (%pe)\n", __func__,
726 - opp_table);
725 + dev_err(dev, "%s: OPP table not found (%ld)\n", __func__,
726 + PTR_ERR(opp_table));
727 727 return ERR_CAST(opp_table);
728 728 }
729 729
@@ -1036,8 +1036,8 @@ static int _set_opp_voltage(struct device *dev, struct regulator *reg,
1036 1036
1037 1037 /* Regulator not available for device */
1038 1038 if (IS_ERR(reg)) {
1039 - dev_dbg(dev, "%s: regulator not available: %pe\n", __func__,
1040 - reg);
1039 + dev_dbg(dev, "%s: regulator not available: %ld\n", __func__,
1040 + PTR_ERR(reg));
1041 1041 return 0;
1042 1042 }
1043 1043
@@ -1448,8 +1448,8 @@ int dev_pm_opp_set_rate(struct device *dev, unsigned long target_freq)
1448 1448 temp_freq = freq;
1449 1449 opp = _find_freq_ceil(opp_table, &temp_freq);
1450 1450 if (IS_ERR(opp)) {
1451 - dev_err(dev, "%s: failed to find OPP for freq %lu (%pe)\n",
1452 - __func__, freq, opp);
1451 + dev_err(dev, "%s: failed to find OPP for freq %lu (%ld)\n",
1452 + __func__, freq, PTR_ERR(opp));
1453 1453 return PTR_ERR(opp);
1454 1454 }
1455 1455
@@ -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
@@ -1581,8 +1581,6 @@ static struct opp_table *_update_opp_table_clk(struct device *dev,
1581 1581 struct opp_table *opp_table,
1582 1582 bool getclk)
1583 1583 {
1584 - int ret;
1585 -
1586 1584 /*
1587 1585 * Return early if we don't need to get clk or we have already done it
1588 1586 * earlier.
@@ -1609,9 +1607,9 @@ static struct opp_table *_update_opp_table_clk(struct device *dev,
1609 1607 opp_table->clk = clk_get_optional(dev, NULL);
1610 1608
1611 1609 if (IS_ERR(opp_table->clk)) {
1612 - ret = dev_err_probe(dev, PTR_ERR(opp_table->clk), "Couldn't find clock\n");
1613 1610 dev_pm_opp_put_opp_table(opp_table);
1614 - return ERR_PTR(ret);
1611 + dev_err_probe(dev, PTR_ERR(opp_table->clk), "Couldn't find clock\n");
1612 + return ERR_CAST(opp_table->clk);
1615 1613 }
1616 1614
1617 1615 if (opp_table->clk)
@@ -2871,8 +2869,8 @@ static int _opp_set_availability(struct device *dev, unsigned long freq,
2871 2869 struct dev_pm_opp *opp __free(put_opp) = ERR_PTR(-ENODEV), *tmp_opp;
2872 2870
2873 2871 if (IS_ERR(opp_table)) {
2874 - dev_warn(dev, "%s: Device OPP not found (%pe)\n", __func__,
2875 - opp_table);
2872 + dev_warn(dev, "%s: Device OPP not found (%ld)\n", __func__,
2873 + PTR_ERR(opp_table));
2876 2874 return PTR_ERR(opp_table);
2877 2875 }
2878 2876
modified drivers/opp/of.c
@@ -1039,7 +1039,7 @@ static int _of_add_opp_table_v1(struct device *dev, struct opp_table *opp_table)
1039 1039
1040 1040 val = prop->value;
1041 1041 while (nr) {
1042 - unsigned long freq = (unsigned long)be32_to_cpup(val++) * 1000;
1042 + unsigned long freq = be32_to_cpup(val++) * 1000;
1043 1043 unsigned long volt = be32_to_cpup(val++);
1044 1044 struct dev_pm_opp_data data = {
1045 1045 .freq = freq,
@@ -1345,8 +1345,8 @@ int of_get_required_opp_performance_state(struct device_node *np, int index)
1345 1345 _find_table_of_opp_np(required_np);
1346 1346
1347 1347 if (IS_ERR(opp_table)) {
1348 - pr_err("%s: Failed to find required OPP table %pOF: %pe\n",
1349 - __func__, np, opp_table);
1348 + pr_err("%s: Failed to find required OPP table %pOF: %ld\n",
1349 + __func__, np, PTR_ERR(opp_table));
1350 1350 return PTR_ERR(opp_table);
1351 1351 }
1352 1352
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/perf/riscv_pmu_legacy.c
@@ -110,9 +110,8 @@ static void pmu_legacy_init(struct riscv_pmu *pmu)
110 110 {
111 111 pr_info("Legacy PMU implementation is available\n");
112 112
113 - bitmap_zero(pmu->cmask, RISCV_MAX_COUNTERS);
114 - set_bit(RISCV_PMU_LEGACY_CYCLE, pmu->cmask);
115 - set_bit(RISCV_PMU_LEGACY_INSTRET, pmu->cmask);
113 + pmu->cmask = BIT(RISCV_PMU_LEGACY_CYCLE) |
114 + BIT(RISCV_PMU_LEGACY_INSTRET);
116 115 pmu->ctr_start = pmu_legacy_ctr_start;
117 116 pmu->ctr_stop = NULL;
118 117 pmu->event_map = pmu_legacy_event_map;
modified drivers/perf/riscv_pmu_sbi.c
@@ -97,7 +97,7 @@ static unsigned int riscv_pmu_irq_mask;
97 97 static unsigned int riscv_pmu_irq;
98 98
99 99 /* Cache the available counters in a bitmask */
100 - static DECLARE_BITMAP(cmask, RISCV_MAX_COUNTERS);
100 + static unsigned long cmask;
101 101
102 102 static int pmu_event_find_cache(u64 config);
103 103 struct sbi_pmu_event_data {
@@ -359,38 +359,16 @@ free_mem:
359 359 return result;
360 360 }
361 361
362 - static struct sbiret pmu_sbi_ctr_cfg_match(unsigned long cbase,
363 - unsigned long ctr_mask,
364 - unsigned long cflags,
365 - unsigned long event_idx,
366 - u64 config)
367 - {
368 - #if defined(CONFIG_32BIT)
369 - return sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, cbase,
370 - ctr_mask, cflags, event_idx, config, config >> 32);
371 - #else
372 - return sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, cbase,
373 - ctr_mask, cflags, event_idx, config, 0);
374 - #endif
375 - }
376 -
377 362 static void pmu_sbi_check_event(struct sbi_pmu_event_data *edata)
378 363 {
379 - struct sbiret ret = { .error = SBI_ERR_NOT_SUPPORTED };
380 - int i;
364 + struct sbiret ret;
381 365
382 - for (i = 0; i < BITS_TO_LONGS(RISCV_MAX_COUNTERS); i++) {
383 - if (!cmask[i])
384 - continue;
385 - ret = pmu_sbi_ctr_cfg_match(i * BITS_PER_LONG, cmask[i], 0,
386 - edata->event_idx, 0);
387 - if (!ret.error) {
388 - sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP,
389 - ret.value, 0x1, SBI_PMU_STOP_FLAG_RESET, 0, 0, 0);
390 - return;
391 - }
392 - }
393 - if (ret.error == SBI_ERR_NOT_SUPPORTED) {
366 + ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH,
367 + 0, cmask, 0, edata->event_idx, 0, 0);
368 + if (!ret.error) {
369 + sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP,
370 + ret.value, 0x1, SBI_PMU_STOP_FLAG_RESET, 0, 0, 0);
371 + } else if (ret.error == SBI_ERR_NOT_SUPPORTED) {
394 372 /* This event cannot be monitored by any counter */
395 373 edata->event_idx = -ENOENT;
396 374 }
@@ -510,10 +488,10 @@ int riscv_pmu_get_hpm_info(u32 *hw_ctr_width, u32 *num_hw_ctr)
510 488 union sbi_pmu_ctr_info *info;
511 489 u32 hpm_width = 0, hpm_count = 0;
512 490
513 - if (bitmap_empty(cmask, RISCV_MAX_COUNTERS))
491 + if (!cmask)
514 492 return -EINVAL;
515 493
516 - for_each_set_bit(i, cmask, RISCV_MAX_COUNTERS) {
494 + for_each_set_bit(i, &cmask, RISCV_MAX_COUNTERS) {
517 495 info = &pmu_ctr_list[i];
518 496 if (!info)
519 497 continue;
@@ -562,8 +540,8 @@ static int pmu_sbi_ctr_get_idx(struct perf_event *event)
562 540 struct riscv_pmu *rvpmu = to_riscv_pmu(event->pmu);
563 541 struct cpu_hw_events *cpuc = this_cpu_ptr(rvpmu->hw_events);
564 542 struct sbiret ret;
565 - int idx, i;
566 - u64 cbase = 0, cmask = 0;
543 + int idx;
544 + uint64_t cbase = 0, cmask = rvpmu->cmask;
567 545 unsigned long cflags = 0;
568 546
569 547 cflags = pmu_sbi_get_filter_flags(event);
@@ -584,21 +562,14 @@ static int pmu_sbi_ctr_get_idx(struct perf_event *event)
584 562 }
585 563
586 564 /* retrieve the available counter index */
587 - if (cmask) {
588 - ret = pmu_sbi_ctr_cfg_match(cbase, cmask, cflags, hwc->event_base,
589 - hwc->config);
590 - } else {
591 - ret.error = SBI_ERR_NOT_SUPPORTED;
592 - for (i = 0; i < BITS_TO_LONGS(RISCV_MAX_COUNTERS); i++) {
593 - if (!rvpmu->cmask[i])
594 - continue;
595 - cbase = i * BITS_PER_LONG;
596 - ret = pmu_sbi_ctr_cfg_match(cbase, rvpmu->cmask[i], cflags,
597 - hwc->event_base, hwc->config);
598 - if (!ret.error)
599 - break;
600 - }
601 - }
565 + #if defined(CONFIG_32BIT)
566 + ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, cbase,
567 + cmask, cflags, hwc->event_base, hwc->config,
568 + hwc->config >> 32);
569 + #else
570 + ret = sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_CFG_MATCH, cbase,
571 + cmask, cflags, hwc->event_base, hwc->config, 0);
572 + #endif
602 573 if (ret.error) {
603 574 pr_debug("Not able to find a counter for event %lx config %llx\n",
604 575 hwc->event_base, hwc->config);
@@ -606,7 +577,7 @@ static int pmu_sbi_ctr_get_idx(struct perf_event *event)
606 577 }
607 578
608 579 idx = ret.value;
609 - if (!test_bit(idx, rvpmu->cmask) || !pmu_ctr_list[idx].value)
580 + if (!test_bit(idx, &rvpmu->cmask) || !pmu_ctr_list[idx].value)
610 581 return -ENOENT;
611 582
612 583 /* Additional sanity check for the counter id */
@@ -910,7 +881,7 @@ static int pmu_sbi_get_ctrinfo(int nctr, unsigned long *mask)
910 881 /* The logical counter ids are not expected to be contiguous */
911 882 continue;
912 883
913 - set_bit(i, mask);
884 + *mask |= BIT(i);
914 885
915 886 cinfo.value = ret.value;
916 887 if (cinfo.type == SBI_PMU_CTR_TYPE_FW)
@@ -927,19 +898,12 @@ static int pmu_sbi_get_ctrinfo(int nctr, unsigned long *mask)
927 898
928 899 static inline void pmu_sbi_stop_all(struct riscv_pmu *pmu)
929 900 {
930 - int i;
931 -
932 901 /*
933 902 * No need to check the error because we are disabling all the counters
934 903 * which may include counters that are not enabled yet.
935 904 */
936 - for (i = 0; i < BITS_TO_LONGS(RISCV_MAX_COUNTERS); i++) {
937 - if (!pmu->cmask[i])
938 - continue;
939 - sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP,
940 - i * BITS_PER_LONG, pmu->cmask[i],
941 - SBI_PMU_STOP_FLAG_RESET, 0, 0, 0);
942 - }
905 + sbi_ecall(SBI_EXT_PMU, SBI_EXT_PMU_COUNTER_STOP,
906 + 0, pmu->cmask, SBI_PMU_STOP_FLAG_RESET, 0, 0, 0);
943 907 }
944 908
945 909 static inline void pmu_sbi_stop_hw_ctrs(struct riscv_pmu *pmu)
@@ -1038,7 +1002,7 @@ static inline void pmu_sbi_start_ovf_ctrs_snapshot(struct cpu_hw_events *cpu_hw_
1038 1002 struct riscv_pmu_snapshot_data *sdata = cpu_hw_evt->snapshot_addr;
1039 1003
1040 1004 for_each_set_bit(idx, cpu_hw_evt->used_hw_ctrs, RISCV_MAX_COUNTERS) {
1041 - if (ctr_ovf_mask & BIT_ULL(idx)) {
1005 + if (ctr_ovf_mask & BIT(idx)) {
1042 1006 event = cpu_hw_evt->events[idx];
1043 1007 hwc = &event->hw;
1044 1008 max_period = riscv_pmu_ctr_get_width_mask(event);
@@ -1086,13 +1050,11 @@ static irqreturn_t pmu_sbi_ovf_handler(int irq, void *dev)
1086 1050 u64 overflowed_ctrs = 0;
1087 1051 struct cpu_hw_events *cpu_hw_evt = dev;
1088 1052 u64 start_clock = sched_clock();
1089 - struct riscv_pmu_snapshot_data *sdata;
1053 + struct riscv_pmu_snapshot_data *sdata = cpu_hw_evt->snapshot_addr;
1090 1054
1091 1055 if (WARN_ON_ONCE(!cpu_hw_evt))
1092 1056 return IRQ_NONE;
1093 1057
1094 - sdata = cpu_hw_evt->snapshot_addr;
1095 -
1096 1058 /* Firmware counter don't support overflow yet */
1097 1059 fidx = find_first_bit(cpu_hw_evt->used_hw_ctrs, RISCV_MAX_COUNTERS);
1098 1060 if (fidx == RISCV_MAX_COUNTERS) {
@@ -1147,14 +1109,14 @@ static irqreturn_t pmu_sbi_ovf_handler(int irq, void *dev)
1147 1109 hidx = info->csr - CSR_CYCLE;
1148 1110
1149 1111 /* check if the corresponding bit is set in scountovf or overflow mask in shmem */
1150 - if (!(overflow & BIT_ULL(hidx)))
1112 + if (!(overflow & BIT(hidx)))
1151 1113 continue;
1152 1114
1153 1115 /*
1154 1116 * Keep a track of overflowed counters so that they can be started
1155 1117 * with updated initial value.
1156 1118 */
1157 - overflowed_ctrs |= BIT_ULL(lidx);
1119 + overflowed_ctrs |= BIT(lidx);
1158 1120 hw_evt = &event->hw;
1159 1121 /* Update the event states here so that we know the state while reading */
1160 1122 hw_evt->state |= PERF_HES_STOPPED;
@@ -1489,7 +1451,7 @@ static int pmu_sbi_device_probe(struct platform_device *pdev)
1489 1451 }
1490 1452
1491 1453 /* cache all the information about counters now */
1492 - if (pmu_sbi_get_ctrinfo(num_counters, cmask))
1454 + if (pmu_sbi_get_ctrinfo(num_counters, &cmask))
1493 1455 goto out_free;
1494 1456
1495 1457 ret = pmu_sbi_setup_irqs(pmu, pdev);
@@ -1502,7 +1464,7 @@ static int pmu_sbi_device_probe(struct platform_device *pdev)
1502 1464
1503 1465 pmu->pmu.attr_groups = riscv_pmu_attr_groups;
1504 1466 pmu->pmu.parent = &pdev->dev;
1505 - bitmap_copy(pmu->cmask, cmask, RISCV_MAX_COUNTERS);
1467 + pmu->cmask = cmask;
1506 1468 pmu->ctr_start = pmu_sbi_ctr_start;
1507 1469 pmu->ctr_stop = pmu_sbi_ctr_stop;
1508 1470 pmu->event_map = pmu_sbi_event_map;
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/amd/pmf/spc.c
@@ -17,6 +17,7 @@
17 17 #include <linux/units.h>
18 18 #include "pmf.h"
19 19
20 + #ifdef CONFIG_AMD_PMF_DEBUG
20 21 u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *in, int index)
21 22 {
22 23 switch (index) {
@@ -30,7 +31,6 @@ u32 amd_pmf_get_ta_custom_bios_inputs(struct ta_pmf_enact_table *in, int index)
30 31 }
31 32 EXPORT_SYMBOL(amd_pmf_get_ta_custom_bios_inputs);
32 33
33 - #ifdef CONFIG_AMD_PMF_DEBUG
34 34 void amd_pmf_dump_ta_inputs(struct amd_pmf_dev *dev, struct ta_pmf_enact_table *in)
35 35 {
36 36 int i;
modified drivers/platform/x86/asus-laptop.c
@@ -1882,7 +1882,7 @@ static int asus_acpi_probe(struct platform_device *pdev)
1882 1882 if (result && result != -ENODEV)
1883 1883 goto fail_pega_rfkill;
1884 1884
1885 - result = acpi_dev_install_notify_handler(device, ACPI_ALL_NOTIFY,
1885 + result = acpi_dev_install_notify_handler(device, ACPI_DEVICE_NOTIFY,
1886 1886 asus_acpi_notify, asus);
1887 1887 if (result)
1888 1888 goto fail_pega_rfkill;
@@ -1912,7 +1912,7 @@ static void asus_acpi_remove(struct platform_device *pdev)
1912 1912 {
1913 1913 struct asus_laptop *asus = platform_get_drvdata(pdev);
1914 1914
1915 - acpi_dev_remove_notify_handler(asus->device, ACPI_ALL_NOTIFY,
1915 + acpi_dev_remove_notify_handler(asus->device, ACPI_DEVICE_NOTIFY,
1916 1916 asus_acpi_notify);
1917 1917 asus_backlight_exit(asus);
1918 1918 asus_rfkill_exit(asus);
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/hp/hp-wmi.c
@@ -337,7 +337,7 @@ static const struct dmi_system_id hp_wmi_feature_boards[] __initconst = {
337 337 },
338 338 {
339 339 .matches = { DMI_MATCH(DMI_BOARD_NAME, "8DD6") },
340 - .driver_data = (void *)&omen_v1_no_ec_board_params,
340 + .driver_data = (void *)&omen_v1_no_ec_thermal_params,
341 341 },
342 342 {
343 343 .matches = { DMI_MATCH(DMI_BOARD_NAME, "8E35") },
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/platform/x86/x86-android-tablets/core.c
@@ -156,6 +156,7 @@ static struct platform_device **pdevs;
156 156 static struct serdev_device **serdevs;
157 157 static const struct software_node **gpio_button_swnodes;
158 158 static const struct software_node **swnode_group;
159 + static const struct software_node **gpiochip_node_group;
159 160 static void (*exit_handler)(void);
160 161
161 162 static __init struct i2c_adapter *
@@ -361,21 +362,11 @@ static const struct software_node *cherryview_gpiochip_node_group[] = {
361 362 NULL
362 363 };
363 364
364 - const struct software_node crystalcove_gpiochip_node = {
365 - .name = "INT33FD:00",
366 - };
367 -
368 - static const struct software_node *crystalcove_gpiochip_node_group[] = {
369 - &crystalcove_gpiochip_node,
370 - NULL
371 - };
372 -
373 365 static void gpio_secondary_unset(void *data)
374 366 {
375 367 struct device *dev = data;
376 368
377 369 set_secondary_fwnode(dev, NULL);
378 - put_device(dev);
379 370 }
380 371
381 372 static void gpio_secondary_unregister_node_group(void *data)
@@ -385,28 +376,26 @@ static void gpio_secondary_unregister_node_group(void *data)
385 376 software_node_unregister_node_group(nodes);
386 377 }
387 378
388 - static int gpio_secondary_fwnode_init(struct device *parent,
389 - const struct software_node * const *node_group)
379 + static int gpio_secondary_fwnode_init(struct device *parent)
390 380 {
391 381 const struct software_node *const *swnode;
392 382 struct fwnode_handle *fwnode;
393 - struct device *phys_dev;
394 383 int ret;
395 384
396 - if (!node_group)
385 + if (!gpiochip_node_group)
397 386 return 0;
398 387
399 - ret = software_node_register_node_group(node_group);
388 + ret = software_node_register_node_group(gpiochip_node_group);
400 389 if (ret)
401 390 return ret;
402 391
403 392 ret = devm_add_action_or_reset(parent,
404 393 gpio_secondary_unregister_node_group,
405 - (void *)node_group);
394 + gpiochip_node_group);
406 395 if (ret)
407 396 return ret;
408 397
409 - for (swnode = node_group; *swnode; swnode++) {
398 + for (swnode = gpiochip_node_group; *swnode; swnode++) {
410 399 struct device *dev __free(put_device) =
411 400 acpi_bus_find_device_by_name((*swnode)->name);
412 401 if (!dev)
@@ -418,15 +407,9 @@ static int gpio_secondary_fwnode_init(struct device *parent,
418 407 if (WARN_ON(!fwnode))
419 408 return -ENOENT;
420 409
421 - phys_dev = acpi_get_first_physical_node(to_acpi_device(dev));
422 - if (!phys_dev)
423 - return dev_err_probe(parent, -ENODEV,
424 - "No physical device for ACPI GPIO dev: %pfwP\n",
425 - fwnode);
426 -
427 - set_secondary_fwnode(phys_dev, fwnode);
410 + set_secondary_fwnode(dev, fwnode);
428 411
429 - ret = devm_add_action_or_reset(parent, gpio_secondary_unset, get_device(phys_dev));
412 + ret = devm_add_action_or_reset(parent, gpio_secondary_unset, dev);
430 413 if (ret)
431 414 return ret;
432 415 }
@@ -469,7 +452,6 @@ static void x86_android_tablet_remove(struct platform_device *pdev)
469 452
470 453 static __init int x86_android_tablet_probe(struct platform_device *pdev)
471 454 {
472 - const struct software_node * const *gpiochip_node_group;
473 455 const struct x86_dev_info *dev_info;
474 456 const struct dmi_system_id *id;
475 457 int i, ret = 0;
@@ -501,20 +483,12 @@ static __init int x86_android_tablet_probe(struct platform_device *pdev)
501 483 break;
502 484 }
503 485
504 - ret = gpio_secondary_fwnode_init(&pdev->dev, gpiochip_node_group);
486 + ret = gpio_secondary_fwnode_init(&pdev->dev);
505 487 if (ret) {
506 488 x86_android_tablet_remove(pdev);
507 489 return ret;
508 490 }
509 491
510 - if (dev_info->has_crystalcove) {
511 - ret = gpio_secondary_fwnode_init(&pdev->dev, crystalcove_gpiochip_node_group);
512 - if (ret) {
513 - x86_android_tablet_remove(pdev);
514 - return ret;
515 - }
516 - }
517 -
518 492 ret = software_node_register_node_group(dev_info->swnode_group);
519 493 if (ret) {
520 494 x86_android_tablet_remove(pdev);
modified drivers/platform/x86/x86-android-tablets/lenovo.c
@@ -61,6 +61,13 @@ static struct lp855x_platform_data lenovo_lp8557_reg_only_pdata = {
61 61 .initial_brightness = 128,
62 62 };
63 63
64 + static const struct software_node arizona_gpiochip_node = {
65 + .name = "arizona",
66 + };
67 +
68 + static const struct software_node crystalcove_gpiochip_node = {
69 + .name = "gpio_crystalcove",
70 + };
64 71
65 72 /* Lenovo Yoga Book X90F / X90L's Android factory image has everything hardcoded */
66 73
@@ -409,17 +416,15 @@ static const struct platform_device_info lenovo_yoga_tab2_830_1050_pdevs[] __ini
409 416
410 417 #define LENOVO_YOGA_TAB2_830_1050_CODEC_NAME "spi-10WM5102:00"
411 418
412 - static const struct software_node lenovo_yoga_tab2_830_1050_wm5102;
413 -
414 419 static const struct property_entry lenovo_yoga_tab2_830_1050_wm1502_props[] = {
415 420 PROPERTY_ENTRY_GPIO("reset-gpios",
416 421 &crystalcove_gpiochip_node, 3, GPIO_ACTIVE_HIGH),
417 422 PROPERTY_ENTRY_GPIO("wlf,ldoena-gpios",
418 423 &baytrail_gpiochip_nodes[1], 23, GPIO_ACTIVE_HIGH),
419 424 PROPERTY_ENTRY_GPIO("wlf,spkvdd-ena-gpios",
420 - &lenovo_yoga_tab2_830_1050_wm5102, 2, GPIO_ACTIVE_HIGH),
425 + &arizona_gpiochip_node, 2, GPIO_ACTIVE_HIGH),
421 426 PROPERTY_ENTRY_GPIO("wlf,micd-pol-gpios",
422 - &lenovo_yoga_tab2_830_1050_wm5102, 4, GPIO_ACTIVE_LOW),
427 + &arizona_gpiochip_node, 4, GPIO_ACTIVE_LOW),
423 428 { }
424 429 };
425 430
@@ -427,6 +432,14 @@ static const struct software_node lenovo_yoga_tab2_830_1050_wm5102 = {
427 432 .properties = lenovo_yoga_tab2_830_1050_wm1502_props,
428 433 };
429 434
435 + static const struct software_node *lenovo_yoga_tab2_830_1050_swnodes[] = {
436 + &crystalcove_gpiochip_node,
437 + &arizona_gpiochip_node,
438 + &lenovo_yoga_tab2_830_1050_wm5102,
439 + &generic_lipo_hv_4v35_battery_node,
440 + NULL
441 + };
442 +
430 443 static int __init lenovo_yoga_tab2_830_1050_init(struct device *dev);
431 444 static void lenovo_yoga_tab2_830_1050_exit(void);
432 445
@@ -442,9 +455,8 @@ const struct x86_dev_info lenovo_yoga_tab2_830_1050_info __initconst = {
442 455 .pdev_info = lenovo_yoga_tab2_830_1050_pdevs,
443 456 .pdev_count = ARRAY_SIZE(lenovo_yoga_tab2_830_1050_pdevs),
444 457 .gpio_button_swnodes = lenovo_yoga_tab2_830_1050_lid_swnodes,
445 - .swnode_group = generic_lipo_hv_4v35_battery_swnodes,
458 + .swnode_group = lenovo_yoga_tab2_830_1050_swnodes,
446 459 .modules = lenovo_yoga_tab2_modules,
447 - .has_crystalcove = true,
448 460 .gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
449 461 .init = lenovo_yoga_tab2_830_1050_init,
450 462 .exit = lenovo_yoga_tab2_830_1050_exit,
@@ -788,9 +800,8 @@ const struct x86_dev_info lenovo_yoga_tab2_1380_info __initconst = {
788 800 .pdev_info = lenovo_yoga_tab2_1380_pdevs,
789 801 .pdev_count = ARRAY_SIZE(lenovo_yoga_tab2_1380_pdevs),
790 802 .gpio_button_swnodes = lenovo_yoga_tab2_830_1050_lid_swnodes,
791 - .swnode_group = generic_lipo_hv_4v35_battery_swnodes,
803 + .swnode_group = lenovo_yoga_tab2_830_1050_swnodes,
792 804 .modules = lenovo_yoga_tab2_modules,
793 - .has_crystalcove = true,
794 805 .gpiochip_type = X86_GPIOCHIP_BAYTRAIL,
795 806 .init = lenovo_yoga_tab2_1380_init,
796 807 .exit = lenovo_yoga_tab2_830_1050_exit,
@@ -974,15 +985,13 @@ static struct arizona_pdata lenovo_yt3_wm5102_pdata = {
974 985 },
975 986 };
976 987
977 - static const struct software_node lenovo_yt3_wm5102;
978 -
979 988 static const struct property_entry lenovo_yt3_wm1502_props[] = {
980 989 PROPERTY_ENTRY_GPIO("wlf,spkvdd-ena-gpios",
981 990 &cherryview_gpiochip_nodes[0], 75, GPIO_ACTIVE_HIGH),
982 991 PROPERTY_ENTRY_GPIO("wlf,ldoena-gpios",
983 992 &cherryview_gpiochip_nodes[0], 81, GPIO_ACTIVE_HIGH),
984 993 PROPERTY_ENTRY_GPIO("reset-gpios", &cherryview_gpiochip_nodes[0], 82, GPIO_ACTIVE_HIGH),
985 - PROPERTY_ENTRY_GPIO("wlf,micd-pol-gpios", &lenovo_yt3_wm5102, 2, GPIO_ACTIVE_HIGH),
994 + PROPERTY_ENTRY_GPIO("wlf,micd-pol-gpios", &arizona_gpiochip_node, 2, GPIO_ACTIVE_HIGH),
986 995 { }
987 996 };
988 997
@@ -991,6 +1000,11 @@ static const struct software_node lenovo_yt3_wm5102 = {
991 1000 .name = "wm5102",
992 1001 };
993 1002
1003 + static const struct software_node *lenovo_yt3_swnodes[] = {
1004 + &arizona_gpiochip_node,
1005 + &lenovo_yt3_wm5102,
1006 + NULL
1007 + };
994 1008
995 1009 static const struct x86_spi_dev_info lenovo_yt3_spi_devs[] __initconst = {
996 1010 {
@@ -1058,6 +1072,7 @@ const struct x86_dev_info lenovo_yt3_info __initconst = {
1058 1072 .i2c_client_count = ARRAY_SIZE(lenovo_yt3_i2c_clients),
1059 1073 .spi_dev_info = lenovo_yt3_spi_devs,
1060 1074 .spi_dev_count = ARRAY_SIZE(lenovo_yt3_spi_devs),
1075 + .swnode_group = lenovo_yt3_swnodes,
1061 1076 .modules = lenovo_yt3_modules,
1062 1077 .gpiochip_type = X86_GPIOCHIP_CHERRYVIEW,
1063 1078 .init = lenovo_yt3_init,
modified drivers/platform/x86/x86-android-tablets/x86-android-tablets.h
@@ -96,7 +96,6 @@ struct x86_dev_info {
96 96 int (*init)(struct device *dev);
97 97 void (*exit)(void);
98 98 bool use_pci;
99 - bool has_crystalcove;
100 99 enum x86_gpiochip_type gpiochip_type;
101 100 };
102 101
@@ -108,7 +107,6 @@ int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data);
108 107 /* Software nodes representing GPIO chips used by various tablets */
109 108 extern const struct software_node baytrail_gpiochip_nodes[];
110 109 extern const struct software_node cherryview_gpiochip_nodes[];
111 - extern const struct software_node crystalcove_gpiochip_node;
112 110
113 111 /*
114 112 * Extern declarations of x86_dev_info structs so there can be a single
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/regulator/pf1550-regulator.c
@@ -283,61 +283,63 @@ static struct pf1550_desc pf1550_regulators[] = {
283 283 PF_LDO1(PF1550, "ldo3", LDO3, 0x1f, pf1550_ldo13_volts),
284 284 };
285 285
286 - /*
287 - * The _LS interrupts indicate an over-current event. The _HS
288 - * interrupts, which are more accurate and can detect catastrophic
289 - * faults, issue an error event. The current limit FAULT interrupt is
290 - * similar to the _HS.
291 - */
292 - static const struct pf1550_regulator_irq {
293 - unsigned int event;
294 - u8 id;
295 - } pf1550_regulator_irqs[] = {
296 - [PF1550_PMIC_IRQ_SW1_LS] = { REGULATOR_EVENT_OVER_CURRENT_WARN, PF1550_SW1 },
297 - [PF1550_PMIC_IRQ_SW2_LS] = { REGULATOR_EVENT_OVER_CURRENT_WARN, PF1550_SW2 },
298 - [PF1550_PMIC_IRQ_SW3_LS] = { REGULATOR_EVENT_OVER_CURRENT_WARN, PF1550_SW3 },
299 - [PF1550_PMIC_IRQ_SW1_HS] = { REGULATOR_EVENT_OVER_CURRENT, PF1550_SW1 },
300 - [PF1550_PMIC_IRQ_SW2_HS] = { REGULATOR_EVENT_OVER_CURRENT, PF1550_SW2 },
301 - [PF1550_PMIC_IRQ_SW3_HS] = { REGULATOR_EVENT_OVER_CURRENT, PF1550_SW3 },
302 - [PF1550_PMIC_IRQ_LDO1_FAULT] = { REGULATOR_EVENT_OVER_CURRENT, PF1550_LDO1 },
303 - [PF1550_PMIC_IRQ_LDO2_FAULT] = { REGULATOR_EVENT_OVER_CURRENT, PF1550_LDO2 },
304 - [PF1550_PMIC_IRQ_LDO3_FAULT] = { REGULATOR_EVENT_OVER_CURRENT, PF1550_LDO3 },
305 - };
306 -
307 286 static irqreturn_t pf1550_regulator_irq_handler(int irq, void *data)
308 287 {
309 - const struct pf1550_regulator_irq *map;
310 288 struct pf1550_regulator_info *info = data;
311 289 struct device *dev = info->dev;
312 290 struct platform_device *pdev = to_platform_device(dev);
313 291 int i, irq_type = -1;
292 + unsigned int event;
314 293
315 294 for (i = 0; i < PF1550_REGULATOR_IRQ_NR; i++)
316 295 if (irq == platform_get_irq(pdev, i))
317 296 irq_type = i;
318 297
319 - /* The die temperature concerns every rail. */
320 - if (irq_type == PF1550_PMIC_IRQ_TEMP_110 ||
321 - irq_type == PF1550_PMIC_IRQ_TEMP_125) {
298 + switch (irq_type) {
299 + /* The _LS interrupts indicate over-current event. The _HS interrupts
300 + * which are more accurate and can detect catastrophic faults, issue
301 + * an error event. The current limit FAULT interrupt is similar to the
302 + * _HS'
303 + */
304 + case PF1550_PMIC_IRQ_SW1_LS:
305 + case PF1550_PMIC_IRQ_SW2_LS:
306 + case PF1550_PMIC_IRQ_SW3_LS:
307 + event = REGULATOR_EVENT_OVER_CURRENT_WARN;
308 + for (i = 0; i < PF1550_MAX_REGULATOR; i++)
309 + if (!strcmp(rdev_get_name(info->rdevs[i]), "SW3"))
310 + regulator_notifier_call_chain(info->rdevs[i],
311 + event, NULL);
312 + break;
313 + case PF1550_PMIC_IRQ_SW1_HS:
314 + case PF1550_PMIC_IRQ_SW2_HS:
315 + case PF1550_PMIC_IRQ_SW3_HS:
316 + event = REGULATOR_EVENT_OVER_CURRENT;
317 + for (i = 0; i < PF1550_MAX_REGULATOR; i++)
318 + if (!strcmp(rdev_get_name(info->rdevs[i]), "SW3"))
319 + regulator_notifier_call_chain(info->rdevs[i],
320 + event, NULL);
321 + break;
322 + case PF1550_PMIC_IRQ_LDO1_FAULT:
323 + case PF1550_PMIC_IRQ_LDO2_FAULT:
324 + case PF1550_PMIC_IRQ_LDO3_FAULT:
325 + event = REGULATOR_EVENT_OVER_CURRENT;
326 + for (i = 0; i < PF1550_MAX_REGULATOR; i++)
327 + if (!strcmp(rdev_get_name(info->rdevs[i]), "LDO3"))
328 + regulator_notifier_call_chain(info->rdevs[i],
329 + event, NULL);
330 + break;
331 + case PF1550_PMIC_IRQ_TEMP_110:
332 + case PF1550_PMIC_IRQ_TEMP_125:
333 + event = REGULATOR_EVENT_OVER_TEMP;
322 334 for (i = 0; i < PF1550_MAX_REGULATOR; i++)
323 335 regulator_notifier_call_chain(info->rdevs[i],
324 - REGULATOR_EVENT_OVER_TEMP,
325 - NULL);
326 - return IRQ_HANDLED;
327 - }
328 -
329 - if (irq_type < 0 || irq_type >= (int)ARRAY_SIZE(pf1550_regulator_irqs)) {
330 - dev_err(dev, "regulator interrupt: irq %d occurred\n", irq_type);
331 - return IRQ_HANDLED;
336 + event, NULL);
337 + break;
338 + default:
339 + dev_err(dev, "regulator interrupt: irq %d occurred\n",
340 + irq_type);
332 341 }
333 342
334 - map = &pf1550_regulator_irqs[irq_type];
335 -
336 - for (i = 0; i < PF1550_MAX_REGULATOR; i++)
337 - if (rdev_get_id(info->rdevs[i]) == map->id)
338 - regulator_notifier_call_chain(info->rdevs[i],
339 - map->event, NULL);
340 -
341 343 return IRQ_HANDLED;
342 344 }
343 345
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/s390/net/ism_drv.c
@@ -231,7 +231,6 @@ static void ism_free_dmb(struct ism_dev *ism, struct dibs_dmb *dmb)
231 231 dma_unmap_page(&ism->pdev->dev, dmb->dma_addr, dmb->dmb_len,
232 232 DMA_FROM_DEVICE);
233 233 folio_put(virt_to_folio(dmb->cpu_addr));
234 - dmb->cpu_addr = NULL;
235 234 }
236 235
237 236 static int ism_alloc_dmb(struct ism_dev *ism, struct dibs_dmb *dmb)
@@ -275,8 +274,7 @@ static int ism_alloc_dmb(struct ism_dev *ism, struct dibs_dmb *dmb)
275 274 return 0;
276 275
277 276 out_free:
278 - folio_put(folio);
279 - dmb->cpu_addr = NULL;
277 + kfree(dmb->cpu_addr);
280 278 out_bit:
281 279 clear_bit(dmb->idx, ism->sba_bitmap);
282 280 return rc;
modified drivers/s390/net/qeth_l2.h
@@ -13,8 +13,7 @@ extern const struct attribute_group *qeth_l2_attr_groups[];
13 13
14 14 int qeth_bridgeport_query_ports(struct qeth_card *card,
15 15 enum qeth_sbp_roles *role,
16 - enum qeth_sbp_states *state,
17 - bool *os_mismatch);
16 + enum qeth_sbp_states *state);
18 17 int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role);
19 18 int qeth_bridgeport_an_set(struct qeth_card *card, int enable);
20 19
modified drivers/s390/net/qeth_l2_main.c
@@ -1158,7 +1158,7 @@ static void qeth_l2_setup_bridgeport_attrs(struct qeth_card *card)
1158 1158 qeth_bridgeport_setrole(card, card->options.sbp.role);
1159 1159 /* Let the callback function refresh the stored role value. */
1160 1160 qeth_bridgeport_query_ports(card, &card->options.sbp.role,
1161 - NULL, NULL);
1161 + NULL);
1162 1162 }
1163 1163 if (card->options.sbp.hostnotification) {
1164 1164 if (qeth_bridgeport_an_set(card, 1))
@@ -1545,7 +1545,6 @@ struct _qeth_sbp_cbctl {
1545 1545 struct {
1546 1546 enum qeth_sbp_roles *role;
1547 1547 enum qeth_sbp_states *state;
1548 - bool *os_mismatch;
1549 1548 } qports;
1550 1549 } data;
1551 1550 };
@@ -1722,19 +1721,10 @@ static int qeth_bridgeport_query_ports_cb(struct qeth_card *card,
1722 1721 struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data;
1723 1722 struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param;
1724 1723 struct qeth_sbp_port_data *qports;
1725 - u16 sbp_rc;
1726 1724 int rc;
1727 1725
1728 1726 QETH_CARD_TEXT(card, 2, "brqprtcb");
1729 - sbp_rc = cmd->data.sbp.hdr.return_code;
1730 -
1731 - /* on OS family mismatch, query still returns valid port data;
1732 - * treat as success
1733 - */
1734 - if (sbp_rc == IPA_RC_SBP_IQD_OS_MISMATCH && !cmd->hdr.return_code)
1735 - rc = 0;
1736 - else
1737 - rc = qeth_bridgeport_makerc(card, cmd);
1727 + rc = qeth_bridgeport_makerc(card, cmd);
1738 1728 if (rc)
1739 1729 return rc;
1740 1730
@@ -1750,9 +1740,6 @@ static int qeth_bridgeport_query_ports_cb(struct qeth_card *card,
1750 1740 if (cbctl->data.qports.state)
1751 1741 *cbctl->data.qports.state = qports->entry[0].state;
1752 1742 }
1753 - if (cbctl->data.qports.os_mismatch)
1754 - *cbctl->data.qports.os_mismatch =
1755 - (sbp_rc == IPA_RC_SBP_IQD_OS_MISMATCH);
1756 1743 return 0;
1757 1744 }
1758 1745
@@ -1761,17 +1748,13 @@ static int qeth_bridgeport_query_ports_cb(struct qeth_card *card,
1761 1748 * @card: qeth_card structure pointer.
1762 1749 * @role: Role of the port: 0-none, 1-primary, 2-secondary.
1763 1750 * @state: State of the port: 0-inactive, 1-standby, 2-active.
1764 - * @os_mismatch: if non-NULL, set to true when firmware reports
1765 - * OS family mismatch.
1766 1751 *
1767 1752 * Returns negative errno-compatible error indication or 0 on success.
1768 1753 *
1769 - * 'role', 'state' and 'os_mismatch' are not updated in case of
1770 - * hardware operation failure.
1754 + * 'role' and 'state' are not updated in case of hardware operation failure.
1771 1755 */
1772 1756 int qeth_bridgeport_query_ports(struct qeth_card *card,
1773 - enum qeth_sbp_roles *role, enum qeth_sbp_states *state,
1774 - bool *os_mismatch)
1757 + enum qeth_sbp_roles *role, enum qeth_sbp_states *state)
1775 1758 {
1776 1759 struct qeth_cmd_buffer *iob;
1777 1760 struct _qeth_sbp_cbctl cbctl = {
@@ -1779,7 +1762,6 @@ int qeth_bridgeport_query_ports(struct qeth_card *card,
1779 1762 .qports = {
1780 1763 .role = role,
1781 1764 .state = state,
1782 - .os_mismatch = os_mismatch,
1783 1765 },
1784 1766 },
1785 1767 };
modified drivers/s390/net/qeth_l2_sys.c
@@ -15,7 +15,6 @@ static ssize_t qeth_bridge_port_role_state_show(struct device *dev,
15 15 {
16 16 struct qeth_card *card = dev_get_drvdata(dev);
17 17 enum qeth_sbp_states state = QETH_SBP_STATE_INACTIVE;
18 - bool os_mismatch = false;
19 18 int rc = 0;
20 19 char *word;
21 20
@@ -26,7 +25,7 @@ static ssize_t qeth_bridge_port_role_state_show(struct device *dev,
26 25 if (qeth_card_hw_is_reachable(card) &&
27 26 card->options.sbp.supported_funcs)
28 27 rc = qeth_bridgeport_query_ports(card,
29 - &card->options.sbp.role, &state, &os_mismatch);
28 + &card->options.sbp.role, &state);
30 29 if (!rc) {
31 30 if (show_state)
32 31 switch (state) {
@@ -53,10 +52,6 @@ static ssize_t qeth_bridge_port_role_state_show(struct device *dev,
53 52 if (rc)
54 53 QETH_CARD_TEXT_(card, 2, "SBP%02x:%02x",
55 54 card->options.sbp.role, state);
56 - else if (!show_state &&
57 - card->options.sbp.role == QETH_SBP_ROLE_NONE &&
58 - os_mismatch)
59 - rc = sysfs_emit(buf, "%s (OS family mismatch)\n", word);
60 55 else
61 56 rc = sysfs_emit(buf, "%s\n", word);
62 57 }
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_nvme.c
@@ -2216,7 +2216,7 @@ int nvfnic_add_tport(struct fnic *fnic, struct fnic_tport_s *tport,
2216 2216
2217 2217 int nvfnic_add_lport(struct fnic *fnic)
2218 2218 {
2219 - struct nvme_fc_port_info pinfo = {};
2219 + struct nvme_fc_port_info pinfo;
2220 2220 struct fnic_iport_s *iport = &fnic->iport;
2221 2221 int ret = 0;
2222 2222
modified drivers/scsi/ibmvscsi/ibmvfc-core.c
@@ -1894,7 +1894,7 @@ static void ibmvfc_log_error(struct ibmvfc_event *evt)
1894 1894 }
1895 1895
1896 1896 /**
1897 - * ibmvfc_scsi_relogin - Log back into the specified device
1897 + * ibmvfc_relogin - Log back into the specified device
1898 1898 * @sdev: scsi device struct
1899 1899 *
1900 1900 **/
@@ -4987,7 +4987,6 @@ static void ibmvfc_tgt_query_target(struct ibmvfc_target *tgt)
4987 4987 * ibmvfc_alloc_target - Allocate and initialize an ibmvfc target
4988 4988 * @vhost: ibmvfc host struct
4989 4989 * @target: Holds SCSI ID to allocate target forand the WWPN
4990 - * @protocol: protocol of the target to allocate
4991 4990 *
4992 4991 * Returns:
4993 4992 * 0 on success / other on failure
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/megaraid/megaraid_sas_base.c
@@ -1973,23 +1973,12 @@ megasas_set_nvme_device_properties(struct scsi_device *sdev,
1973 1973 {
1974 1974 struct megasas_instance *instance;
1975 1975 u32 mr_nvme_pg_size;
1976 - u64 max_prp_io;
1977 1976
1978 1977 instance = (struct megasas_instance *)sdev->host->hostdata;
1979 1978 mr_nvme_pg_size = max_t(u32, instance->nvme_page_size,
1980 1979 MR_DEFAULT_NVME_PAGE_SIZE);
1981 1980
1982 - /*
1983 - * megasas_make_prp_nvme() builds the PRP list in cmd->sg_frame without
1984 - * bounding it against that buffer, and spends one entry per page of
1985 - * it on the chain pointer. Cap the transfer at what the buffer holds,
1986 - * less one page for lists that start off a page boundary.
1987 - */
1988 - max_prp_io = (u64)((instance->max_chain_frame_sz / sizeof(u64)) -
1989 - (instance->max_chain_frame_sz / mr_nvme_pg_size) - 1) *
1990 - mr_nvme_pg_size;
1991 -
1992 - lim->max_hw_sectors = min_t(u64, max_io_size, max_prp_io) >> SECTOR_SHIFT;
1981 + lim->max_hw_sectors = max_io_size / 512;
1993 1982 lim->virt_boundary_mask = mr_nvme_pg_size - 1;
1994 1983 }
1995 1984
modified drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -1094,13 +1094,10 @@ static void mpi3mr_refresh_tgtdevs(struct mpi3mr_ioc *mrioc)
1094 1094 {
1095 1095 struct mpi3mr_tgt_dev *tgtdev, *tgtdev_next;
1096 1096 struct mpi3mr_stgt_priv_data *tgt_priv;
1097 - struct scsi_target *starget;
1098 - unsigned long flags;
1099 1097
1100 1098 dprint_reset(mrioc, "refresh target devices: check for removals\n");
1101 1099 list_for_each_entry_safe(tgtdev, tgtdev_next, &mrioc->tgtdev_list,
1102 1100 list) {
1103 - spin_lock_irqsave(&mrioc->tgtdev_lock, flags);
1104 1101 if (((tgtdev->dev_handle == MPI3MR_INVALID_DEV_HANDLE) ||
1105 1102 tgtdev->is_hidden) &&
1106 1103 tgtdev->host_exposed && tgtdev->starget &&
@@ -1109,7 +1106,6 @@ static void mpi3mr_refresh_tgtdevs(struct mpi3mr_ioc *mrioc)
1109 1106 tgt_priv->dev_removed = 1;
1110 1107 atomic_set(&tgt_priv->block_io, 0);
1111 1108 }
1112 - spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags);
1113 1109 }
1114 1110
1115 1111 list_for_each_entry_safe(tgtdev, tgtdev_next, &mrioc->tgtdev_list,
@@ -1131,25 +1127,15 @@ static void mpi3mr_refresh_tgtdevs(struct mpi3mr_ioc *mrioc)
1131 1127 tgtdev = NULL;
1132 1128 list_for_each_entry(tgtdev, &mrioc->tgtdev_list, list) {
1133 1129 if ((tgtdev->dev_handle != MPI3MR_INVALID_DEV_HANDLE) &&
1134 - !tgtdev->is_hidden) {
1135 - if (!tgtdev->host_exposed) {
1130 + !tgtdev->is_hidden) {
1131 + if (!tgtdev->host_exposed)
1136 1132 mpi3mr_report_tgtdev_to_host(mrioc,
1137 - tgtdev->perst_id);
1138 - continue;
1139 - }
1140 - spin_lock_irqsave(&mrioc->tgtdev_lock, flags);
1141 - starget = tgtdev->starget;
1142 - if (starget)
1143 - get_device(&starget->dev);
1144 - spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags);
1145 - if (starget) {
1146 - starget_for_each_device(starget, (void *)tgtdev,
1147 - mpi3mr_update_sdev);
1148 - put_device(&starget->dev);
1149 - }
1150 - }
1133 + tgtdev->perst_id);
1134 + else if (tgtdev->starget)
1135 + starget_for_each_device(tgtdev->starget,
1136 + (void *)tgtdev, mpi3mr_update_sdev);
1137 + }
1151 1138 }
1152 - dprint_reset(mrioc, "refresh target devices: done\n");
1153 1139 }
1154 1140
1155 1141 /**
@@ -1529,8 +1515,6 @@ static void mpi3mr_devinfochg_evt_bh(struct mpi3mr_ioc *mrioc,
1529 1515 struct mpi3_device_page0 *dev_pg0)
1530 1516 {
1531 1517 struct mpi3mr_tgt_dev *tgtdev = NULL;
1532 - struct scsi_target *starget;
1533 - unsigned long flags;
1534 1518 u16 dev_handle = 0, perst_id = 0;
1535 1519
1536 1520 perst_id = le16_to_cpu(dev_pg0->persistent_id);
@@ -1551,18 +1535,9 @@ static void mpi3mr_devinfochg_evt_bh(struct mpi3mr_ioc *mrioc,
1551 1535 mpi3mr_report_tgtdev_to_host(mrioc, perst_id);
1552 1536 if (tgtdev->is_hidden && tgtdev->host_exposed)
1553 1537 mpi3mr_remove_tgtdev_from_host(mrioc, tgtdev);
1554 - if (!tgtdev->is_hidden && tgtdev->host_exposed) {
1555 - spin_lock_irqsave(&mrioc->tgtdev_lock, flags);
1556 - starget = tgtdev->starget;
1557 - if (starget)
1558 - get_device(&starget->dev);
1559 - spin_unlock_irqrestore(&mrioc->tgtdev_lock, flags);
1560 - if (starget) {
1561 - starget_for_each_device(starget, (void *)tgtdev,
1562 - mpi3mr_update_sdev);
1563 - put_device(&starget->dev);
1564 - }
1565 - }
1538 + if (!tgtdev->is_hidden && tgtdev->host_exposed && tgtdev->starget)
1539 + starget_for_each_device(tgtdev->starget, (void *)tgtdev,
1540 + mpi3mr_update_sdev);
1566 1541 out:
1567 1542 if (tgtdev)
1568 1543 mpi3mr_tgtdev_put(tgtdev);
modified drivers/scsi/mpi3mr/mpi3mr_transport.c
@@ -1428,15 +1428,9 @@ static struct mpi3mr_sas_port *mpi3mr_sas_port_add(struct mpi3mr_ioc *mrioc,
1428 1428 }
1429 1429
1430 1430 port = sas_port_alloc_num(mr_sas_node->parent_dev);
1431 - if (!port) {
1432 - ioc_err(mrioc, "failure at %s:%d/%s()!\n",
1433 - __FILE__, __LINE__, __func__);
1434 - goto out_fail;
1435 - }
1436 1431 if ((sas_port_add(port))) {
1437 1432 ioc_err(mrioc, "failure at %s:%d/%s()!\n",
1438 1433 __FILE__, __LINE__, __func__);
1439 - sas_port_free(port);
1440 1434 goto out_fail;
1441 1435 }
1442 1436
@@ -1507,8 +1501,6 @@ static struct mpi3mr_sas_port *mpi3mr_sas_port_add(struct mpi3mr_ioc *mrioc,
1507 1501 list_for_each_entry_safe(mr_sas_phy, next, &mr_sas_port->phy_list,
1508 1502 port_siblings)
1509 1503 list_del(&mr_sas_phy->port_siblings);
1510 - if (tgtdev)
1511 - mpi3mr_tgtdev_put(tgtdev);
1512 1504 kfree(mr_sas_port);
1513 1505 return NULL;
1514 1506 }
modified drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -3238,10 +3238,7 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc)
3238 3238 * corresponding to high iops queues.
3239 3239 */
3240 3240 if (ioc->high_iops_queues) {
3241 - int node = dev_to_node(&ioc->pdev->dev);
3242 -
3243 - mask = (node == NUMA_NO_NODE) ?
3244 - cpu_online_mask : cpumask_of_node(node);
3241 + mask = cpumask_of_node(dev_to_node(&ioc->pdev->dev));
3245 3242 for (index = 0; index < ioc->high_iops_queues;
3246 3243 index++) {
3247 3244 irq = pci_irq_vector(ioc->pdev, index);
modified drivers/scsi/pm8001/pm8001_init.c
@@ -1029,8 +1029,8 @@ static u32 pm8001_request_msix(struct pm8001_hba_info *pm8001_ha)
1029 1029 &(pm8001_ha->irq_vector[i]));
1030 1030 if (rc) {
1031 1031 for (j = 0; j < i; j++) {
1032 - free_irq(pci_irq_vector(pm8001_ha->pdev, j),
1033 - &pm8001_ha->irq_vector[j]);
1032 + free_irq(pci_irq_vector(pm8001_ha->pdev, i),
1033 + &(pm8001_ha->irq_vector[i]));
1034 1034 }
1035 1035 pci_free_irq_vectors(pm8001_ha->pdev);
1036 1036 break;
modified drivers/scsi/scsi_bsg.c
@@ -18,7 +18,6 @@ struct scsi_bsg_uring_cmd_pdu {
18 18 struct bio *bio; /* mapped user buffer, unmap in task work */
19 19 struct request *req; /* block request, freed in task work */
20 20 u64 response_addr; /* user space response buffer address */
21 - u32 max_response_len; /* user response buffer size */
22 21 };
23 22 static_assert(sizeof(struct scsi_bsg_uring_cmd_pdu) <= sizeof_field(struct io_uring_cmd, pdu));
24 23
@@ -46,8 +45,8 @@ static void scsi_bsg_uring_task_cb(struct io_tw_req tw_req, io_tw_token_t tw)
46 45 if (scsi_status_is_check_condition(scmd->result)) {
47 46 driver_status = DRIVER_SENSE;
48 47 if (pdu->response_addr)
49 - sense_len_wr = min_t(unsigned int, pdu->max_response_len,
50 - scmd->sense_len);
48 + sense_len_wr = min_t(u8, scmd->sense_len,
49 + SCSI_SENSE_BUFFERSIZE);
51 50 }
52 51
53 52 if (sense_len_wr) {
@@ -77,10 +76,12 @@ static enum rq_end_io_ret scsi_bsg_uring_cmd_done(struct request *req,
77 76
78 77 static int scsi_bsg_map_user_buffer(struct request *req,
79 78 struct io_uring_cmd *ioucmd,
80 - unsigned int issue_flags, gfp_t gfp_mask,
81 - bool is_write, u64 buf_addr,
82 - unsigned long buf_len)
79 + unsigned int issue_flags, gfp_t gfp_mask)
83 80 {
81 + const struct bsg_uring_cmd *cmd = io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd);
82 + bool is_write = cmd->dout_xfer_len > 0;
83 + u64 buf_addr = is_write ? cmd->dout_xferp : cmd->din_xferp;
84 + unsigned long buf_len = is_write ? cmd->dout_xfer_len : cmd->din_xfer_len;
84 85 struct iov_iter iter;
85 86 int ret;
86 87
@@ -103,28 +104,21 @@ static int scsi_bsg_uring_cmd(struct request_queue *q, struct io_uring_cmd *iouc
103 104 unsigned int issue_flags, bool open_for_write)
104 105 {
105 106 struct scsi_bsg_uring_cmd_pdu *pdu = scsi_bsg_uring_cmd_pdu(ioucmd);
106 - const struct bsg_uring_cmd *cmd =
107 - io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd);
107 + const struct bsg_uring_cmd *cmd = io_uring_sqe128_cmd(ioucmd->sqe, struct bsg_uring_cmd);
108 108 struct scsi_cmnd *scmd;
109 109 struct request *req;
110 110 blk_mq_req_flags_t blk_flags = 0;
111 111 gfp_t gfp_mask = GFP_KERNEL;
112 - u64 request = READ_ONCE(cmd->request);
113 - u32 request_len = READ_ONCE(cmd->request_len);
114 - u64 dout_xferp = READ_ONCE(cmd->dout_xferp);
115 - u32 dout_xfer_len = READ_ONCE(cmd->dout_xfer_len);
116 - u64 din_xferp = READ_ONCE(cmd->din_xferp);
117 - u32 din_xfer_len = READ_ONCE(cmd->din_xfer_len);
118 112 int ret;
119 113
120 114 if (cmd->protocol != BSG_PROTOCOL_SCSI ||
121 115 cmd->subprotocol != BSG_SUB_PROTOCOL_SCSI_CMD)
122 116 return -EINVAL;
123 117
124 - if (!request || request_len == 0)
118 + if (!cmd->request || cmd->request_len == 0)
125 119 return -EINVAL;
126 120
127 - if (dout_xfer_len && din_xfer_len) {
121 + if (cmd->dout_xfer_len && cmd->din_xfer_len) {
128 122 pr_warn_once("BIDI support in bsg has been removed.\n");
129 123 return -EOPNOTSUPP;
130 124 }
@@ -137,20 +131,20 @@ static int scsi_bsg_uring_cmd(struct request_queue *q, struct io_uring_cmd *iouc
137 131 gfp_mask = GFP_NOWAIT;
138 132 }
139 133
140 - req = scsi_alloc_request(q, dout_xfer_len ?
134 + req = scsi_alloc_request(q, cmd->dout_xfer_len ?
141 135 REQ_OP_DRV_OUT : REQ_OP_DRV_IN, blk_flags);
142 136 if (IS_ERR(req))
143 137 return PTR_ERR(req);
144 138
145 139 scmd = blk_mq_rq_to_pdu(req);
146 - if (request_len > sizeof(scmd->cmnd)) {
140 + if (cmd->request_len > sizeof(scmd->cmnd)) {
147 141 ret = -EINVAL;
148 142 goto out_free_req;
149 143 }
150 - scmd->cmd_len = request_len;
144 + scmd->cmd_len = cmd->request_len;
151 145 scmd->allowed = SG_DEFAULT_RETRIES;
152 146
153 - if (copy_from_user(scmd->cmnd, uptr64(request), request_len)) {
147 + if (copy_from_user(scmd->cmnd, uptr64(cmd->request), cmd->request_len)) {
154 148 ret = -EFAULT;
155 149 goto out_free_req;
156 150 }
@@ -161,16 +155,11 @@ static int scsi_bsg_uring_cmd(struct request_queue *q, struct io_uring_cmd *iouc
161 155 }
162 156
163 157 pdu->response_addr = cmd->response;
164 - pdu->max_response_len = cmd->max_response_len;
158 + scmd->sense_len = cmd->max_response_len ?
159 + min(cmd->max_response_len, SCSI_SENSE_BUFFERSIZE) : SCSI_SENSE_BUFFERSIZE;
165 160
166 - if (dout_xfer_len || din_xfer_len) {
167 - bool is_write = dout_xfer_len > 0;
168 - u64 buf_addr = is_write ? dout_xferp : din_xferp;
169 - unsigned long buf_len = is_write ? dout_xfer_len : din_xfer_len;
170 -
171 - ret = scsi_bsg_map_user_buffer(req, ioucmd, issue_flags,
172 - gfp_mask, is_write, buf_addr,
173 - buf_len);
161 + if (cmd->dout_xfer_len || cmd->din_xfer_len) {
162 + ret = scsi_bsg_map_user_buffer(req, ioucmd, issue_flags, gfp_mask);
174 163 if (ret)
175 164 goto out_free_req;
176 165 pdu->bio = req->bio;
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/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.c
@@ -1533,10 +1533,8 @@ __iscsit_check_dataout_hdr(struct iscsit_conn *conn, void *buf,
1533 1533 */
1534 1534 if (se_cmd->transport_state & CMD_T_ABORTED) {
1535 1535 if (hdr->flags & ISCSI_FLAG_CMD_FINAL &&
1536 - --cmd->outstanding_r2ts < 1) {
1536 + --cmd->outstanding_r2ts < 1)
1537 1537 iscsit_stop_dataout_timer(cmd);
1538 - target_complete_cmd(se_cmd, SAM_STAT_TASK_ABORTED);
1539 - }
1540 1538
1541 1539 return iscsit_dump_data_payload(conn, payload_length, 1);
1542 1540 }
modified drivers/target/iscsi/iscsi_target_login.c
@@ -47,7 +47,7 @@ static struct iscsi_login *iscsi_login_init_conn(struct iscsit_conn *conn)
47 47 login->conn = conn;
48 48 login->first_request = 1;
49 49
50 - login->req_buf = kzalloc(MAX_KEY_VALUE_PAIRS + 1, GFP_KERNEL);
50 + login->req_buf = kzalloc(MAX_KEY_VALUE_PAIRS, GFP_KERNEL);
51 51 if (!login->req_buf) {
52 52 pr_err("Unable to allocate memory for response buffer.\n");
53 53 goto out_login;
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/thermal/thermal_sysfs.c
@@ -400,8 +400,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz)
400 400 struct thermal_trip_attrs *trip_attrs = &td->trip_attrs;
401 401
402 402 /* create trip type attribute */
403 - scnprintf(trip_attrs->type.name, sizeof(trip_attrs->type.name),
404 - "trip_point_%d_type", i);
403 + snprintf(trip_attrs->type.name, THERMAL_NAME_LENGTH,
404 + "trip_point_%d_type", i);
405 405
406 406 sysfs_attr_init(&trip_attrs->type.attr.attr);
407 407 trip_attrs->type.attr.attr.name = trip_attrs->type.name;
@@ -410,8 +410,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz)
410 410 attrs[i] = &trip_attrs->type.attr.attr;
411 411
412 412 /* create trip temp attribute */
413 - scnprintf(trip_attrs->temp.name, sizeof(trip_attrs->temp.name),
414 - "trip_point_%d_temp", i);
413 + snprintf(trip_attrs->temp.name, THERMAL_NAME_LENGTH,
414 + "trip_point_%d_temp", i);
415 415
416 416 sysfs_attr_init(&trip_attrs->temp.attr.attr);
417 417 trip_attrs->temp.attr.attr.name = trip_attrs->temp.name;
@@ -423,8 +423,8 @@ static int create_trip_attrs(struct thermal_zone_device *tz)
423 423 }
424 424 attrs[i + tz->num_trips] = &trip_attrs->temp.attr.attr;
425 425
426 - scnprintf(trip_attrs->hyst.name, sizeof(trip_attrs->hyst.name),
427 - "trip_point_%d_hyst", i);
426 + snprintf(trip_attrs->hyst.name, THERMAL_NAME_LENGTH,
427 + "trip_point_%d_hyst", i);
428 428
429 429 sysfs_attr_init(&trip_attrs->hyst.attr.attr);
430 430 trip_attrs->hyst.attr.attr.name = trip_attrs->hyst.name;
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/tty/vt/vt.c
@@ -4986,8 +4986,8 @@ static int con_font_set(struct vc_data *vc, const struct console_font_op *op)
4986 4986 if (!vc->vc_sw->con_font_set)
4987 4987 return -ENOSYS;
4988 4988
4989 - /* hide selection and cursor prior font changes */
4990 - hide_cursor(vc);
4989 + if (vc_is_sel(vc))
4990 + clear_selection();
4991 4991
4992 4992 return vc->vc_sw->con_font_set(vc, &font, vpitch, op->flags);
4993 4993 }
@@ -5011,9 +5011,8 @@ static int con_font_default(struct vc_data *vc, struct console_font_op *op)
5011 5011 if (!vc->vc_sw->con_font_default)
5012 5012 return -ENOSYS;
5013 5013
5014 - /* hide selection and cursor prior font changes */
5015 - hide_cursor(vc);
5016 -
5014 + if (vc_is_sel(vc))
5015 + clear_selection();
5017 5016 int ret = vc->vc_sw->con_font_default(vc, &font, s);
5018 5017 if (ret)
5019 5018 return ret;
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/host/ufs-qcom.c
@@ -715,7 +715,6 @@ static void ufs_qcom_link_startup_post_change(struct ufs_hba *hba)
715 715 static int ufs_qcom_link_startup_notify(struct ufs_hba *hba,
716 716 enum ufs_notify_change_status status)
717 717 {
718 - struct ufs_qcom_host *host = ufshcd_get_variant(hba);
719 718 int err = 0;
720 719
721 720 switch (status) {
@@ -738,14 +737,6 @@ static int ufs_qcom_link_startup_notify(struct ufs_hba *hba,
738 737 */
739 738 err = ufshcd_disable_host_tx_lcc(hba);
740 739
741 - /*
742 - * Restore HS/LS link startup mode set by bootloader
743 - * after UFS reset clears REG_UFS_DEBUG_SPARE_CFG.
744 - */
745 - if (host->hw_ver.major > 0x6 ||
746 - (host->hw_ver.major == 0x6 && host->hw_ver.minor >= 0x2))
747 - ufshcd_writel(hba, host->boot_spare_cfg,
748 - REG_UFS_DEBUG_SPARE_CFG);
749 740 break;
750 741 case POST_CHANGE:
751 742 ufs_qcom_link_startup_post_change(hba);
@@ -1334,7 +1325,7 @@ static void ufs_qcom_advertise_quirks(struct ufs_hba *hba)
1334 1325 static void ufs_qcom_set_phy_gear(struct ufs_qcom_host *host)
1335 1326 {
1336 1327 struct ufs_host_params *host_params = &host->host_params;
1337 - u32 dev_major;
1328 + u32 val, dev_major;
1338 1329
1339 1330 /*
1340 1331 * Default to powering up the PHY to the max gear possible, which is
@@ -1353,8 +1344,8 @@ static void ufs_qcom_set_phy_gear(struct ufs_qcom_host *host)
1353 1344 */
1354 1345 host->phy_gear = UFS_HS_G2;
1355 1346 } else if (host->hw_ver.major >= 0x5) {
1356 - host->boot_spare_cfg = ufshcd_readl(host->hba, REG_UFS_DEBUG_SPARE_CFG);
1357 - dev_major = FIELD_GET(UFS_DEV_VER_MAJOR_MASK, host->boot_spare_cfg);
1347 + val = ufshcd_readl(host->hba, REG_UFS_DEBUG_SPARE_CFG);
1348 + dev_major = FIELD_GET(UFS_DEV_VER_MAJOR_MASK, val);
1358 1349
1359 1350 /*
1360 1351 * Since the UFS device version is populated, let's remove the
@@ -2291,7 +2282,7 @@ static void ufs_qcom_config_scaling_param(struct ufs_hba *hba,
2291 2282 p->polling_ms = 60;
2292 2283 p->timer = DEVFREQ_TIMER_DELAYED;
2293 2284 d->upthreshold = 70;
2294 - d->downdifferential = 65;
2285 + d->downdifferential = 5;
2295 2286
2296 2287 hba->clk_scaling.suspend_on_no_request = true;
2297 2288 }
@@ -2770,7 +2761,7 @@ static int ufs_qcom_get_rx_fom(struct ufs_hba *hba,
2770 2761 struct tx_eqtr_iter *d_iter)
2771 2762 {
2772 2763 struct ufshcd_tx_eq_params *params __free(kfree) =
2773 - kzalloc_obj(*params);
2764 + kzalloc(sizeof(*params), GFP_KERNEL);
2774 2765 struct ufs_qcom_host *host = ufshcd_get_variant(hba);
2775 2766 struct ufs_pa_layer_attr old_pwr_info;
2776 2767 u32 fom[PA_MAXDATALANES] = { 0 };
modified drivers/ufs/host/ufs-qcom.h
@@ -361,7 +361,6 @@ struct ufs_qcom_host {
361 361 bool esi_enabled;
362 362
363 363 u32 saved_tx_eq_g1_setting;
364 - u32 boot_spare_cfg;
365 364 };
366 365
367 366 struct ufs_qcom_drvdata {
modified drivers/ufs/host/ufshcd-pci.c
@@ -181,25 +181,6 @@ static int ufs_intel_lkf_pwr_change_notify(struct ufs_hba *hba,
181 181 return err;
182 182 }
183 183
184 - static int ufs_intel_nvl_pwr_change_notify(struct ufs_hba *hba,
185 - enum ufs_notify_change_status stage,
186 - struct ufs_pa_layer_attr *dev_req_params)
187 - {
188 - int adapt_val;
189 -
190 - if (stage != PRE_CHANGE || hba->ufs_version < ufshci_version(4, 0))
191 - return 0;
192 -
193 - if (dev_req_params->pwr_tx == FAST_MODE || dev_req_params->pwr_tx == FASTAUTO_MODE)
194 - adapt_val = PA_INITIAL_ADAPT;
195 - else
196 - adapt_val = PA_NO_ADAPT;
197 -
198 - ufshcd_dme_configure_adapt(hba, dev_req_params->gear_tx, adapt_val);
199 -
200 - return 0;
201 - }
202 -
203 184 static int ufs_intel_lkf_apply_dev_quirks(struct ufs_hba *hba)
204 185 {
205 186 u32 granularity, peer_granularity;
@@ -460,43 +441,6 @@ static int ufs_intel_mtl_init(struct ufs_hba *hba)
460 441 return ufs_intel_common_init(hba);
461 442 }
462 443
463 - static int ufs_intel_mcq_config_resource(struct ufs_hba *hba)
464 - {
465 - hba->mcq_base = hba->mmio_base + ufshcd_mcq_queue_cfg_addr(hba);
466 -
467 - return 0;
468 - }
469 -
470 - /*
471 - * This Intel UFS4.0 controller maps MCQ doorbell and interrupt-status
472 - * registers into the same PCI BAR as the legacy HCI space, at this
473 - * fixed offset/stride.
474 - */
475 - #define UFS_INTEL_SQDAO0 0x2800
476 - #define UFS_INTEL_SQISAO0 0x2814
477 - #define UFS_INTEL_CQDAO0 0x281C
478 - #define UFS_INTEL_CQISAO0 0x2824
479 - #define UFS_INTEL_MCQ_STRIDE 0x30
480 -
481 - static int ufs_intel_op_runtime_config(struct ufs_hba *hba)
482 - {
483 - struct ufshcd_mcq_opr_info_t *opr;
484 - int i;
485 -
486 - hba->mcq_opr[OPR_SQD].offset = UFS_INTEL_SQDAO0;
487 - hba->mcq_opr[OPR_SQIS].offset = UFS_INTEL_SQISAO0;
488 - hba->mcq_opr[OPR_CQD].offset = UFS_INTEL_CQDAO0;
489 - hba->mcq_opr[OPR_CQIS].offset = UFS_INTEL_CQISAO0;
490 -
491 - for (i = 0; i < OPR_MAX; i++) {
492 - opr = &hba->mcq_opr[i];
493 - opr->stride = UFS_INTEL_MCQ_STRIDE;
494 - opr->base = hba->mmio_base + opr->offset;
495 - }
496 -
497 - return 0;
498 - }
499 -
500 444 static int ufs_qemu_get_hba_mac(struct ufs_hba *hba)
501 445 {
502 446 return MAX_SUPP_MAC;
@@ -583,9 +527,6 @@ static struct ufs_hba_variant_ops ufs_intel_mtl_hba_vops = {
583 527 .exit = ufs_intel_common_exit,
584 528 .hce_enable_notify = ufs_intel_hce_enable_notify,
585 529 .link_startup_notify = ufs_intel_link_startup_notify,
586 - .pwr_change_notify = ufs_intel_nvl_pwr_change_notify,
587 - .mcq_config_resource = ufs_intel_mcq_config_resource,
588 - .op_runtime_config = ufs_intel_op_runtime_config,
589 530 .resume = ufs_intel_resume,
590 531 .device_reset = ufs_intel_device_reset,
591 532 };
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

No content changes.

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