Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net

Cross-merge networking fixes after downstream PR.

No conflicts or adjacent changes.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+3074 -1721
+4
.mailmap
··· 241 241 Johan Hovold <johan@kernel.org> <jhovold@gmail.com> 242 242 Johan Hovold <johan@kernel.org> <johan@hovoldconsulting.com> 243 243 John Crispin <john@phrozen.org> <blogic@openwrt.org> 244 + John Fastabend <john.fastabend@gmail.com> <john.r.fastabend@intel.com> 244 245 John Keeping <john@keeping.me.uk> <john@metanate.com> 245 246 John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de> 246 247 John Stultz <johnstul@us.ibm.com> 247 248 <jon.toppins+linux@gmail.com> <jtoppins@cumulusnetworks.com> 248 249 <jon.toppins+linux@gmail.com> <jtoppins@redhat.com> 250 + Jonas Gorski <jonas.gorski@gmail.com> <jogo@openwrt.org> 249 251 Jordan Crouse <jordan@cosmicpenguin.net> <jcrouse@codeaurora.org> 250 252 <josh@joshtriplett.org> <josh@freedesktop.org> 251 253 <josh@joshtriplett.org> <josh@kernel.org> ··· 455 453 Sedat Dilek <sedat.dilek@gmail.com> <sedat.dilek@credativ.de> 456 454 Seth Forshee <sforshee@kernel.org> <seth.forshee@canonical.com> 457 455 Shannon Nelson <shannon.nelson@amd.com> <snelson@pensando.io> 456 + Shannon Nelson <shannon.nelson@amd.com> <shannon.nelson@intel.com> 457 + Shannon Nelson <shannon.nelson@amd.com> <shannon.nelson@oracle.com> 458 458 Shiraz Hashim <shiraz.linux.kernel@gmail.com> <shiraz.hashim@st.com> 459 459 Shuah Khan <shuah@kernel.org> <shuahkhan@gmail.com> 460 460 Shuah Khan <shuah@kernel.org> <shuah.khan@hp.com>
+38 -38
Documentation/ABI/testing/sysfs-driver-ufs
··· 994 994 What: /sys/bus/platform/drivers/ufshcd/*/rpm_lvl 995 995 What: /sys/bus/platform/devices/*.ufs/rpm_lvl 996 996 Date: September 2014 997 - Contact: Subhash Jadavani <subhashj@codeaurora.org> 997 + Contact: Can Guo <quic_cang@quicinc.com> 998 998 Description: This entry could be used to set or show the UFS device 999 999 runtime power management level. The current driver 1000 1000 implementation supports 7 levels with next target states: ··· 1021 1021 What: /sys/bus/platform/drivers/ufshcd/*/rpm_target_dev_state 1022 1022 What: /sys/bus/platform/devices/*.ufs/rpm_target_dev_state 1023 1023 Date: February 2018 1024 - Contact: Subhash Jadavani <subhashj@codeaurora.org> 1024 + Contact: Can Guo <quic_cang@quicinc.com> 1025 1025 Description: This entry shows the target power mode of an UFS device 1026 1026 for the chosen runtime power management level. 1027 1027 ··· 1030 1030 What: /sys/bus/platform/drivers/ufshcd/*/rpm_target_link_state 1031 1031 What: /sys/bus/platform/devices/*.ufs/rpm_target_link_state 1032 1032 Date: February 2018 1033 - Contact: Subhash Jadavani <subhashj@codeaurora.org> 1033 + Contact: Can Guo <quic_cang@quicinc.com> 1034 1034 Description: This entry shows the target state of an UFS UIC link 1035 1035 for the chosen runtime power management level. 1036 1036 ··· 1039 1039 What: /sys/bus/platform/drivers/ufshcd/*/spm_lvl 1040 1040 What: /sys/bus/platform/devices/*.ufs/spm_lvl 1041 1041 Date: September 2014 1042 - Contact: Subhash Jadavani <subhashj@codeaurora.org> 1042 + Contact: Can Guo <quic_cang@quicinc.com> 1043 1043 Description: This entry could be used to set or show the UFS device 1044 1044 system power management level. The current driver 1045 1045 implementation supports 7 levels with next target states: ··· 1066 1066 What: /sys/bus/platform/drivers/ufshcd/*/spm_target_dev_state 1067 1067 What: /sys/bus/platform/devices/*.ufs/spm_target_dev_state 1068 1068 Date: February 2018 1069 - Contact: Subhash Jadavani <subhashj@codeaurora.org> 1069 + Contact: Can Guo <quic_cang@quicinc.com> 1070 1070 Description: This entry shows the target power mode of an UFS device 1071 1071 for the chosen system power management level. 1072 1072 ··· 1075 1075 What: /sys/bus/platform/drivers/ufshcd/*/spm_target_link_state 1076 1076 What: /sys/bus/platform/devices/*.ufs/spm_target_link_state 1077 1077 Date: February 2018 1078 - Contact: Subhash Jadavani <subhashj@codeaurora.org> 1078 + Contact: Can Guo <quic_cang@quicinc.com> 1079 1079 Description: This entry shows the target state of an UFS UIC link 1080 1080 for the chosen system power management level. 1081 1081 ··· 1084 1084 What: /sys/bus/platform/drivers/ufshcd/*/monitor/monitor_enable 1085 1085 What: /sys/bus/platform/devices/*.ufs/monitor/monitor_enable 1086 1086 Date: January 2021 1087 - Contact: Can Guo <cang@codeaurora.org> 1087 + Contact: Can Guo <quic_cang@quicinc.com> 1088 1088 Description: This file shows the status of performance monitor enablement 1089 1089 and it can be used to start/stop the monitor. When the monitor 1090 1090 is stopped, the performance data collected is also cleared. ··· 1092 1092 What: /sys/bus/platform/drivers/ufshcd/*/monitor/monitor_chunk_size 1093 1093 What: /sys/bus/platform/devices/*.ufs/monitor/monitor_chunk_size 1094 1094 Date: January 2021 1095 - Contact: Can Guo <cang@codeaurora.org> 1095 + Contact: Can Guo <quic_cang@quicinc.com> 1096 1096 Description: This file tells the monitor to focus on requests transferring 1097 1097 data of specific chunk size (in Bytes). 0 means any chunk size. 1098 1098 It can only be changed when monitor is disabled. ··· 1100 1100 What: /sys/bus/platform/drivers/ufshcd/*/monitor/read_total_sectors 1101 1101 What: /sys/bus/platform/devices/*.ufs/monitor/read_total_sectors 1102 1102 Date: January 2021 1103 - Contact: Can Guo <cang@codeaurora.org> 1103 + Contact: Can Guo <quic_cang@quicinc.com> 1104 1104 Description: This file shows how many sectors (in 512 Bytes) have been 1105 1105 sent from device to host after monitor gets started. 1106 1106 ··· 1109 1109 What: /sys/bus/platform/drivers/ufshcd/*/monitor/read_total_busy 1110 1110 What: /sys/bus/platform/devices/*.ufs/monitor/read_total_busy 1111 1111 Date: January 2021 1112 - Contact: Can Guo <cang@codeaurora.org> 1112 + Contact: Can Guo <quic_cang@quicinc.com> 1113 1113 Description: This file shows how long (in micro seconds) has been spent 1114 1114 sending data from device to host after monitor gets started. 1115 1115 ··· 1118 1118 What: /sys/bus/platform/drivers/ufshcd/*/monitor/read_nr_requests 1119 1119 What: /sys/bus/platform/devices/*.ufs/monitor/read_nr_requests 1120 1120 Date: January 2021 1121 - Contact: Can Guo <cang@codeaurora.org> 1121 + Contact: Can Guo <quic_cang@quicinc.com> 1122 1122 Description: This file shows how many read requests have been sent after 1123 1123 monitor gets started. 1124 1124 ··· 1127 1127 What: /sys/bus/platform/drivers/ufshcd/*/monitor/read_req_latency_max 1128 1128 What: /sys/bus/platform/devices/*.ufs/monitor/read_req_latency_max 1129 1129 Date: January 2021 1130 - Contact: Can Guo <cang@codeaurora.org> 1130 + Contact: Can Guo <quic_cang@quicinc.com> 1131 1131 Description: This file shows the maximum latency (in micro seconds) of 1132 1132 read requests after monitor gets started. 1133 1133 ··· 1136 1136 What: /sys/bus/platform/drivers/ufshcd/*/monitor/read_req_latency_min 1137 1137 What: /sys/bus/platform/devices/*.ufs/monitor/read_req_latency_min 1138 1138 Date: January 2021 1139 - Contact: Can Guo <cang@codeaurora.org> 1139 + Contact: Can Guo <quic_cang@quicinc.com> 1140 1140 Description: This file shows the minimum latency (in micro seconds) of 1141 1141 read requests after monitor gets started. 1142 1142 ··· 1145 1145 What: /sys/bus/platform/drivers/ufshcd/*/monitor/read_req_latency_avg 1146 1146 What: /sys/bus/platform/devices/*.ufs/monitor/read_req_latency_avg 1147 1147 Date: January 2021 1148 - Contact: Can Guo <cang@codeaurora.org> 1148 + Contact: Can Guo <quic_cang@quicinc.com> 1149 1149 Description: This file shows the average latency (in micro seconds) of 1150 1150 read requests after monitor gets started. 1151 1151 ··· 1154 1154 What: /sys/bus/platform/drivers/ufshcd/*/monitor/read_req_latency_sum 1155 1155 What: /sys/bus/platform/devices/*.ufs/monitor/read_req_latency_sum 1156 1156 Date: January 2021 1157 - Contact: Can Guo <cang@codeaurora.org> 1157 + Contact: Can Guo <quic_cang@quicinc.com> 1158 1158 Description: This file shows the total latency (in micro seconds) of 1159 1159 read requests sent after monitor gets started. 1160 1160 ··· 1163 1163 What: /sys/bus/platform/drivers/ufshcd/*/monitor/write_total_sectors 1164 1164 What: /sys/bus/platform/devices/*.ufs/monitor/write_total_sectors 1165 1165 Date: January 2021 1166 - Contact: Can Guo <cang@codeaurora.org> 1166 + Contact: Can Guo <quic_cang@quicinc.com> 1167 1167 Description: This file shows how many sectors (in 512 Bytes) have been sent 1168 1168 from host to device after monitor gets started. 1169 1169 ··· 1172 1172 What: /sys/bus/platform/drivers/ufshcd/*/monitor/write_total_busy 1173 1173 What: /sys/bus/platform/devices/*.ufs/monitor/write_total_busy 1174 1174 Date: January 2021 1175 - Contact: Can Guo <cang@codeaurora.org> 1175 + Contact: Can Guo <quic_cang@quicinc.com> 1176 1176 Description: This file shows how long (in micro seconds) has been spent 1177 1177 sending data from host to device after monitor gets started. 1178 1178 ··· 1181 1181 What: /sys/bus/platform/drivers/ufshcd/*/monitor/write_nr_requests 1182 1182 What: /sys/bus/platform/devices/*.ufs/monitor/write_nr_requests 1183 1183 Date: January 2021 1184 - Contact: Can Guo <cang@codeaurora.org> 1184 + Contact: Can Guo <quic_cang@quicinc.com> 1185 1185 Description: This file shows how many write requests have been sent after 1186 1186 monitor gets started. 1187 1187 ··· 1190 1190 What: /sys/bus/platform/drivers/ufshcd/*/monitor/write_req_latency_max 1191 1191 What: /sys/bus/platform/devices/*.ufs/monitor/write_req_latency_max 1192 1192 Date: January 2021 1193 - Contact: Can Guo <cang@codeaurora.org> 1193 + Contact: Can Guo <quic_cang@quicinc.com> 1194 1194 Description: This file shows the maximum latency (in micro seconds) of write 1195 1195 requests after monitor gets started. 1196 1196 ··· 1199 1199 What: /sys/bus/platform/drivers/ufshcd/*/monitor/write_req_latency_min 1200 1200 What: /sys/bus/platform/devices/*.ufs/monitor/write_req_latency_min 1201 1201 Date: January 2021 1202 - Contact: Can Guo <cang@codeaurora.org> 1202 + Contact: Can Guo <quic_cang@quicinc.com> 1203 1203 Description: This file shows the minimum latency (in micro seconds) of write 1204 1204 requests after monitor gets started. 1205 1205 ··· 1208 1208 What: /sys/bus/platform/drivers/ufshcd/*/monitor/write_req_latency_avg 1209 1209 What: /sys/bus/platform/devices/*.ufs/monitor/write_req_latency_avg 1210 1210 Date: January 2021 1211 - Contact: Can Guo <cang@codeaurora.org> 1211 + Contact: Can Guo <quic_cang@quicinc.com> 1212 1212 Description: This file shows the average latency (in micro seconds) of write 1213 1213 requests after monitor gets started. 1214 1214 ··· 1217 1217 What: /sys/bus/platform/drivers/ufshcd/*/monitor/write_req_latency_sum 1218 1218 What: /sys/bus/platform/devices/*.ufs/monitor/write_req_latency_sum 1219 1219 Date: January 2021 1220 - Contact: Can Guo <cang@codeaurora.org> 1220 + Contact: Can Guo <quic_cang@quicinc.com> 1221 1221 Description: This file shows the total latency (in micro seconds) of write 1222 1222 requests after monitor gets started. 1223 1223 ··· 1226 1226 What: /sys/bus/platform/drivers/ufshcd/*/device_descriptor/wb_presv_us_en 1227 1227 What: /sys/bus/platform/devices/*.ufs/device_descriptor/wb_presv_us_en 1228 1228 Date: June 2020 1229 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1229 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1230 1230 Description: This entry shows if preserve user-space was configured 1231 1231 1232 1232 The file is read only. ··· 1234 1234 What: /sys/bus/platform/drivers/ufshcd/*/device_descriptor/wb_shared_alloc_units 1235 1235 What: /sys/bus/platform/devices/*.ufs/device_descriptor/wb_shared_alloc_units 1236 1236 Date: June 2020 1237 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1237 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1238 1238 Description: This entry shows the shared allocated units of WB buffer 1239 1239 1240 1240 The file is read only. ··· 1242 1242 What: /sys/bus/platform/drivers/ufshcd/*/device_descriptor/wb_type 1243 1243 What: /sys/bus/platform/devices/*.ufs/device_descriptor/wb_type 1244 1244 Date: June 2020 1245 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1245 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1246 1246 Description: This entry shows the configured WB type. 1247 1247 0x1 for shared buffer mode. 0x0 for dedicated buffer mode. 1248 1248 ··· 1251 1251 What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/wb_buff_cap_adj 1252 1252 What: /sys/bus/platform/devices/*.ufs/geometry_descriptor/wb_buff_cap_adj 1253 1253 Date: June 2020 1254 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1254 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1255 1255 Description: This entry shows the total user-space decrease in shared 1256 1256 buffer mode. 1257 1257 The value of this parameter is 3 for TLC NAND when SLC mode ··· 1262 1262 What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/wb_max_alloc_units 1263 1263 What: /sys/bus/platform/devices/*.ufs/geometry_descriptor/wb_max_alloc_units 1264 1264 Date: June 2020 1265 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1265 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1266 1266 Description: This entry shows the Maximum total WriteBooster Buffer size 1267 1267 which is supported by the entire device. 1268 1268 ··· 1271 1271 What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/wb_max_wb_luns 1272 1272 What: /sys/bus/platform/devices/*.ufs/geometry_descriptor/wb_max_wb_luns 1273 1273 Date: June 2020 1274 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1274 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1275 1275 Description: This entry shows the maximum number of luns that can support 1276 1276 WriteBooster. 1277 1277 ··· 1280 1280 What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/wb_sup_red_type 1281 1281 What: /sys/bus/platform/devices/*.ufs/geometry_descriptor/wb_sup_red_type 1282 1282 Date: June 2020 1283 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1283 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1284 1284 Description: The supportability of user space reduction mode 1285 1285 and preserve user space mode. 1286 1286 00h: WriteBooster Buffer can be configured only in ··· 1295 1295 What: /sys/bus/platform/drivers/ufshcd/*/geometry_descriptor/wb_sup_wb_type 1296 1296 What: /sys/bus/platform/devices/*.ufs/geometry_descriptor/wb_sup_wb_type 1297 1297 Date: June 2020 1298 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1298 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1299 1299 Description: The supportability of WriteBooster Buffer type. 1300 1300 1301 1301 === ========================================================== ··· 1310 1310 What: /sys/bus/platform/drivers/ufshcd/*/flags/wb_enable 1311 1311 What: /sys/bus/platform/devices/*.ufs/flags/wb_enable 1312 1312 Date: June 2020 1313 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1313 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1314 1314 Description: This entry shows the status of WriteBooster. 1315 1315 1316 1316 == ============================ ··· 1323 1323 What: /sys/bus/platform/drivers/ufshcd/*/flags/wb_flush_en 1324 1324 What: /sys/bus/platform/devices/*.ufs/flags/wb_flush_en 1325 1325 Date: June 2020 1326 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1326 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1327 1327 Description: This entry shows if flush is enabled. 1328 1328 1329 1329 == ================================= ··· 1336 1336 What: /sys/bus/platform/drivers/ufshcd/*/flags/wb_flush_during_h8 1337 1337 What: /sys/bus/platform/devices/*.ufs/flags/wb_flush_during_h8 1338 1338 Date: June 2020 1339 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1339 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1340 1340 Description: Flush WriteBooster Buffer during hibernate state. 1341 1341 1342 1342 == ================================================= ··· 1351 1351 What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_avail_buf 1352 1352 What: /sys/bus/platform/devices/*.ufs/attributes/wb_avail_buf 1353 1353 Date: June 2020 1354 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1354 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1355 1355 Description: This entry shows the amount of unused WriteBooster buffer 1356 1356 available. 1357 1357 ··· 1360 1360 What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_cur_buf 1361 1361 What: /sys/bus/platform/devices/*.ufs/attributes/wb_cur_buf 1362 1362 Date: June 2020 1363 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1363 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1364 1364 Description: This entry shows the amount of unused current buffer. 1365 1365 1366 1366 The file is read only. ··· 1368 1368 What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_flush_status 1369 1369 What: /sys/bus/platform/devices/*.ufs/attributes/wb_flush_status 1370 1370 Date: June 2020 1371 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1371 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1372 1372 Description: This entry shows the flush operation status. 1373 1373 1374 1374 ··· 1385 1385 What: /sys/bus/platform/drivers/ufshcd/*/attributes/wb_life_time_est 1386 1386 What: /sys/bus/platform/devices/*.ufs/attributes/wb_life_time_est 1387 1387 Date: June 2020 1388 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1388 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1389 1389 Description: This entry shows an indication of the WriteBooster Buffer 1390 1390 lifetime based on the amount of performed program/erase cycles 1391 1391 ··· 1399 1399 1400 1400 What: /sys/class/scsi_device/*/device/unit_descriptor/wb_buf_alloc_units 1401 1401 Date: June 2020 1402 - Contact: Asutosh Das <asutoshd@codeaurora.org> 1402 + Contact: Asutosh Das <quic_asutoshd@quicinc.com> 1403 1403 Description: This entry shows the configured size of WriteBooster buffer. 1404 1404 0400h corresponds to 4GB. 1405 1405
+1 -1
Documentation/riscv/hwprobe.rst
··· 49 49 privileged ISA, with the following known exceptions (more exceptions may be 50 50 added, but only if it can be demonstrated that the user ABI is not broken): 51 51 52 - * The :fence.i: instruction cannot be directly executed by userspace 52 + * The ``fence.i`` instruction cannot be directly executed by userspace 53 53 programs (it may still be executed in userspace via a 54 54 kernel-controlled mechanism such as the vDSO). 55 55
+12 -2
MAINTAINERS
··· 4124 4124 F: drivers/spi/spi-bcm63xx-hsspi.c 4125 4125 F: drivers/spi/spi-bcmbca-hsspi.c 4126 4126 4127 + BROADCOM BCM6348/BCM6358 SPI controller DRIVER 4128 + M: Jonas Gorski <jonas.gorski@gmail.com> 4129 + L: linux-spi@vger.kernel.org 4130 + S: Odd Fixes 4131 + F: Documentation/devicetree/bindings/spi/spi-bcm63xx.txt 4132 + F: drivers/spi/spi-bcm63xx.c 4133 + 4127 4134 BROADCOM ETHERNET PHY DRIVERS 4128 4135 M: Florian Fainelli <florian.fainelli@broadcom.com> 4129 4136 R: Broadcom internal kernel review list <bcm-kernel-feedback-list@broadcom.com> ··· 8691 8684 F: drivers/input/touchscreen/resistive-adc-touch.c 8692 8685 8693 8686 GENERIC STRING LIBRARY 8687 + M: Kees Cook <keescook@chromium.org> 8694 8688 R: Andy Shevchenko <andy@kernel.org> 8695 - S: Maintained 8689 + L: linux-hardening@vger.kernel.org 8690 + S: Supported 8691 + T: git git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/hardening 8696 8692 F: include/linux/string.h 8697 8693 F: include/linux/string_choices.h 8698 8694 F: include/linux/string_helpers.h ··· 13990 13980 F: drivers/soc/microchip/ 13991 13981 13992 13982 MICROCHIP SPI DRIVER 13993 - M: Tudor Ambarus <tudor.ambarus@linaro.org> 13983 + M: Ryan Wanner <ryan.wanner@microchip.com> 13994 13984 S: Supported 13995 13985 F: drivers/spi/spi-atmel.* 13996 13986
+1 -1
Makefile
··· 2 2 VERSION = 6 3 3 PATCHLEVEL = 5 4 4 SUBLEVEL = 0 5 - EXTRAVERSION = -rc1 5 + EXTRAVERSION = -rc2 6 6 NAME = Hurr durr I'ma ninja sloth 7 7 8 8 # *DOCUMENTATION*
+7 -1
arch/arm64/net/bpf_jit_comp.c
··· 322 322 * 323 323 */ 324 324 325 - emit_bti(A64_BTI_C, ctx); 325 + /* bpf function may be invoked by 3 instruction types: 326 + * 1. bl, attached via freplace to bpf prog via short jump 327 + * 2. br, attached via freplace to bpf prog via long jump 328 + * 3. blr, working as a function pointer, used by emit_call. 329 + * So BTI_JC should used here to support both br and blr. 330 + */ 331 + emit_bti(A64_BTI_JC, ctx); 326 332 327 333 emit(A64_MOV(1, A64_R(9), A64_LR), ctx); 328 334 emit(A64_NOP, ctx);
-6
arch/powerpc/include/asm/book3s/64/hash-4k.h
··· 136 136 return 0; 137 137 } 138 138 139 - static inline int hash__pmd_same(pmd_t pmd_a, pmd_t pmd_b) 140 - { 141 - BUG(); 142 - return 0; 143 - } 144 - 145 139 static inline pmd_t hash__pmd_mkhuge(pmd_t pmd) 146 140 { 147 141 BUG();
-5
arch/powerpc/include/asm/book3s/64/hash-64k.h
··· 263 263 (_PAGE_PTE | H_PAGE_THP_HUGE)); 264 264 } 265 265 266 - static inline int hash__pmd_same(pmd_t pmd_a, pmd_t pmd_b) 267 - { 268 - return (((pmd_raw(pmd_a) ^ pmd_raw(pmd_b)) & ~cpu_to_be64(_PAGE_HPTEFLAGS)) == 0); 269 - } 270 - 271 266 static inline pmd_t hash__pmd_mkhuge(pmd_t pmd) 272 267 { 273 268 return __pmd(pmd_val(pmd) | (_PAGE_PTE | H_PAGE_THP_HUGE));
+5
arch/powerpc/include/asm/book3s/64/hash.h
··· 132 132 return region_id; 133 133 } 134 134 135 + static inline int hash__pmd_same(pmd_t pmd_a, pmd_t pmd_b) 136 + { 137 + return (((pmd_raw(pmd_a) ^ pmd_raw(pmd_b)) & ~cpu_to_be64(_PAGE_HPTEFLAGS)) == 0); 138 + } 139 + 135 140 #define hash__pmd_bad(pmd) (pmd_val(pmd) & H_PMD_BAD_BITS) 136 141 #define hash__pud_bad(pud) (pud_val(pud) & H_PUD_BAD_BITS) 137 142 static inline int hash__p4d_bad(p4d_t p4d)
+18 -13
arch/powerpc/kernel/exceptions-64e.S
··· 5 5 * Copyright (C) 2007 Ben. Herrenschmidt (benh@kernel.crashing.org), IBM Corp. 6 6 */ 7 7 8 + #include <linux/linkage.h> 8 9 #include <linux/threads.h> 9 10 #include <asm/reg.h> 10 11 #include <asm/page.h> ··· 67 66 #define SPECIAL_EXC_LOAD(reg, name) \ 68 67 ld reg, (SPECIAL_EXC_##name * 8 + SPECIAL_EXC_FRAME_OFFS)(r1) 69 68 70 - special_reg_save: 69 + SYM_CODE_START_LOCAL(special_reg_save) 71 70 /* 72 71 * We only need (or have stack space) to save this stuff if 73 72 * we interrupted the kernel. ··· 132 131 SPECIAL_EXC_STORE(r10,CSRR1) 133 132 134 133 blr 134 + SYM_CODE_END(special_reg_save) 135 135 136 - ret_from_level_except: 136 + SYM_CODE_START_LOCAL(ret_from_level_except) 137 137 ld r3,_MSR(r1) 138 138 andi. r3,r3,MSR_PR 139 139 beq 1f ··· 208 206 mtxer r11 209 207 210 208 blr 209 + SYM_CODE_END(ret_from_level_except) 211 210 212 211 .macro ret_from_level srr0 srr1 paca_ex scratch 213 212 bl ret_from_level_except ··· 235 232 mfspr r13,\scratch 236 233 .endm 237 234 238 - ret_from_crit_except: 235 + SYM_CODE_START_LOCAL(ret_from_crit_except) 239 236 ret_from_level SPRN_CSRR0 SPRN_CSRR1 PACA_EXCRIT SPRN_SPRG_CRIT_SCRATCH 240 237 rfci 238 + SYM_CODE_END(ret_from_crit_except) 241 239 242 - ret_from_mc_except: 240 + SYM_CODE_START_LOCAL(ret_from_mc_except) 243 241 ret_from_level SPRN_MCSRR0 SPRN_MCSRR1 PACA_EXMC SPRN_SPRG_MC_SCRATCH 244 242 rfmci 243 + SYM_CODE_END(ret_from_mc_except) 245 244 246 245 /* Exception prolog code for all exceptions */ 247 246 #define EXCEPTION_PROLOG(n, intnum, type, addition) \ ··· 983 978 * r14 and r15 containing the fault address and error code, with the 984 979 * original values stashed away in the PACA 985 980 */ 986 - storage_fault_common: 981 + SYM_CODE_START_LOCAL(storage_fault_common) 987 982 addi r3,r1,STACK_INT_FRAME_REGS 988 983 bl do_page_fault 989 984 b interrupt_return 985 + SYM_CODE_END(storage_fault_common) 990 986 991 987 /* 992 988 * Alignment exception doesn't fit entirely in the 0x100 bytes so it 993 989 * continues here. 994 990 */ 995 - alignment_more: 991 + SYM_CODE_START_LOCAL(alignment_more) 996 992 addi r3,r1,STACK_INT_FRAME_REGS 997 993 bl alignment_exception 998 994 REST_NVGPRS(r1) 999 995 b interrupt_return 996 + SYM_CODE_END(alignment_more) 1000 997 1001 998 /* 1002 999 * Trampolines used when spotting a bad kernel stack pointer in ··· 1037 1030 BAD_STACK_TRAMPOLINE(0xf00) 1038 1031 BAD_STACK_TRAMPOLINE(0xf20) 1039 1032 1040 - .globl bad_stack_book3e 1041 - bad_stack_book3e: 1033 + _GLOBAL(bad_stack_book3e) 1042 1034 /* XXX: Needs to make SPRN_SPRG_GEN depend on exception type */ 1043 1035 mfspr r10,SPRN_SRR0; /* read SRR0 before touching stack */ 1044 1036 ld r1,PACAEMERGSP(r13) ··· 1291 1285 * ever takes any parameters, the SCOM code must also be updated to 1292 1286 * provide them. 1293 1287 */ 1294 - .globl a2_tlbinit_code_start 1295 - a2_tlbinit_code_start: 1288 + _GLOBAL(a2_tlbinit_code_start) 1296 1289 1297 1290 ori r11,r3,MAS0_WQ_ALLWAYS 1298 1291 oris r11,r11,MAS0_ESEL(3)@h /* Use way 3: workaround A2 erratum 376 */ ··· 1484 1479 mflr r28 1485 1480 b 3b 1486 1481 1487 - .globl init_core_book3e 1488 - init_core_book3e: 1482 + _GLOBAL(init_core_book3e) 1489 1483 /* Establish the interrupt vector base */ 1490 1484 tovirt(r2,r2) 1491 1485 LOAD_REG_ADDR(r3, interrupt_base_book3e) ··· 1492 1488 sync 1493 1489 blr 1494 1490 1495 - init_thread_book3e: 1491 + SYM_CODE_START_LOCAL(init_thread_book3e) 1496 1492 lis r3,(SPRN_EPCR_ICM | SPRN_EPCR_GICM)@h 1497 1493 mtspr SPRN_EPCR,r3 1498 1494 ··· 1506 1502 mtspr SPRN_TSR,r3 1507 1503 1508 1504 blr 1505 + SYM_CODE_END(init_thread_book3e) 1509 1506 1510 1507 _GLOBAL(__setup_base_ivors) 1511 1508 SET_IVOR(0, 0x020) /* Critical Input */
+19 -18
arch/powerpc/kernel/security.c
··· 364 364 365 365 static int ssb_prctl_get(struct task_struct *task) 366 366 { 367 - if (stf_enabled_flush_types == STF_BARRIER_NONE) 368 - /* 369 - * We don't have an explicit signal from firmware that we're 370 - * vulnerable or not, we only have certain CPU revisions that 371 - * are known to be vulnerable. 372 - * 373 - * We assume that if we're on another CPU, where the barrier is 374 - * NONE, then we are not vulnerable. 375 - */ 367 + /* 368 + * The STF_BARRIER feature is on by default, so if it's off that means 369 + * firmware has explicitly said the CPU is not vulnerable via either 370 + * the hypercall or device tree. 371 + */ 372 + if (!security_ftr_enabled(SEC_FTR_STF_BARRIER)) 376 373 return PR_SPEC_NOT_AFFECTED; 377 - else 378 - /* 379 - * If we do have a barrier type then we are vulnerable. The 380 - * barrier is not a global or per-process mitigation, so the 381 - * only value we can report here is PR_SPEC_ENABLE, which 382 - * appears as "vulnerable" in /proc. 383 - */ 384 - return PR_SPEC_ENABLE; 385 374 386 - return -EINVAL; 375 + /* 376 + * If the system's CPU has no known barrier (see setup_stf_barrier()) 377 + * then assume that the CPU is not vulnerable. 378 + */ 379 + if (stf_enabled_flush_types == STF_BARRIER_NONE) 380 + return PR_SPEC_NOT_AFFECTED; 381 + 382 + /* 383 + * Otherwise the CPU is vulnerable. The barrier is not a global or 384 + * per-process mitigation, so the only value that can be reported here 385 + * is PR_SPEC_ENABLE, which appears as "vulnerable" in /proc. 386 + */ 387 + return PR_SPEC_ENABLE; 387 388 } 388 389 389 390 int arch_prctl_spec_ctrl_get(struct task_struct *task, unsigned long which)
+9 -4
arch/powerpc/mm/book3s64/hash_native.c
··· 328 328 329 329 static long native_hpte_remove(unsigned long hpte_group) 330 330 { 331 + unsigned long hpte_v, flags; 331 332 struct hash_pte *hptep; 332 333 int i; 333 334 int slot_offset; 334 - unsigned long hpte_v; 335 + 336 + local_irq_save(flags); 335 337 336 338 DBG_LOW(" remove(group=%lx)\n", hpte_group); 337 339 ··· 358 356 slot_offset &= 0x7; 359 357 } 360 358 361 - if (i == HPTES_PER_GROUP) 362 - return -1; 359 + if (i == HPTES_PER_GROUP) { 360 + i = -1; 361 + goto out; 362 + } 363 363 364 364 /* Invalidate the hpte. NOTE: this also unlocks it */ 365 365 release_hpte_lock(); 366 366 hptep->v = 0; 367 - 367 + out: 368 + local_irq_restore(flags); 368 369 return i; 369 370 } 370 371
+2 -7
arch/riscv/kernel/cpufeature.c
··· 318 318 } 319 319 320 320 /* 321 - * Linux requires the following extensions, so we may as well 322 - * always set them. 323 - */ 324 - set_bit(RISCV_ISA_EXT_ZICSR, isainfo->isa); 325 - set_bit(RISCV_ISA_EXT_ZIFENCEI, isainfo->isa); 326 - 327 - /* 328 321 * These ones were as they were part of the base ISA when the 329 322 * port & dt-bindings were upstreamed, and so can be set 330 323 * unconditionally where `i` is in riscv,isa on DT systems. 331 324 */ 332 325 if (acpi_disabled) { 326 + set_bit(RISCV_ISA_EXT_ZICSR, isainfo->isa); 327 + set_bit(RISCV_ISA_EXT_ZIFENCEI, isainfo->isa); 333 328 set_bit(RISCV_ISA_EXT_ZICNTR, isainfo->isa); 334 329 set_bit(RISCV_ISA_EXT_ZIHPM, isainfo->isa); 335 330 }
+1 -1
arch/riscv/mm/init.c
··· 1346 1346 */ 1347 1347 crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE, 1348 1348 search_start, 1349 - min(search_end, (unsigned long) SZ_4G)); 1349 + min(search_end, (unsigned long)(SZ_4G - 1))); 1350 1350 if (crash_base == 0) { 1351 1351 /* Try again without restricting region to 32bit addressible memory */ 1352 1352 crash_base = memblock_phys_alloc_range(crash_size, PMD_SIZE,
+1 -1
arch/sparc/include/asm/cmpxchg_32.h
··· 15 15 unsigned long __xchg_u32(volatile u32 *m, u32 new); 16 16 void __xchg_called_with_bad_pointer(void); 17 17 18 - static inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) 18 + static __always_inline unsigned long __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) 19 19 { 20 20 switch (size) { 21 21 case 4:
+1 -1
arch/sparc/include/asm/cmpxchg_64.h
··· 87 87 return (load32 & mask) >> bit_shift; 88 88 } 89 89 90 - static inline unsigned long 90 + static __always_inline unsigned long 91 91 __arch_xchg(unsigned long x, __volatile__ void * ptr, int size) 92 92 { 93 93 switch (size) {
+1 -1
arch/um/kernel/um_arch.c
··· 437 437 os_check_bugs(); 438 438 } 439 439 440 - void apply_ibt_endbr(s32 *start, s32 *end) 440 + void apply_seal_endbr(s32 *start, s32 *end) 441 441 { 442 442 } 443 443
+13 -40
arch/x86/entry/entry_32.S
··· 720 720 .popsection 721 721 722 722 /* 723 - * The unwinder expects the last frame on the stack to always be at the same 724 - * offset from the end of the page, which allows it to validate the stack. 725 - * Calling schedule_tail() directly would break that convention because its an 726 - * asmlinkage function so its argument has to be pushed on the stack. This 727 - * wrapper creates a proper "end of stack" frame header before the call. 728 - */ 729 - .pushsection .text, "ax" 730 - SYM_FUNC_START(schedule_tail_wrapper) 731 - FRAME_BEGIN 732 - 733 - pushl %eax 734 - call schedule_tail 735 - popl %eax 736 - 737 - FRAME_END 738 - RET 739 - SYM_FUNC_END(schedule_tail_wrapper) 740 - .popsection 741 - 742 - /* 743 723 * A newly forked process directly context switches into this address. 744 724 * 745 725 * eax: prev task we switched from ··· 727 747 * edi: kernel thread arg 728 748 */ 729 749 .pushsection .text, "ax" 730 - SYM_CODE_START(ret_from_fork) 731 - call schedule_tail_wrapper 750 + SYM_CODE_START(ret_from_fork_asm) 751 + movl %esp, %edx /* regs */ 732 752 733 - testl %ebx, %ebx 734 - jnz 1f /* kernel threads are uncommon */ 753 + /* return address for the stack unwinder */ 754 + pushl $.Lsyscall_32_done 735 755 736 - 2: 737 - /* When we fork, we trace the syscall return in the child, too. */ 738 - movl %esp, %eax 739 - call syscall_exit_to_user_mode 740 - jmp .Lsyscall_32_done 756 + FRAME_BEGIN 757 + /* prev already in EAX */ 758 + movl %ebx, %ecx /* fn */ 759 + pushl %edi /* fn_arg */ 760 + call ret_from_fork 761 + addl $4, %esp 762 + FRAME_END 741 763 742 - /* kernel thread */ 743 - 1: movl %edi, %eax 744 - CALL_NOSPEC ebx 745 - /* 746 - * A kernel thread is allowed to return here after successfully 747 - * calling kernel_execve(). Exit to userspace to complete the execve() 748 - * syscall. 749 - */ 750 - movl $0, PT_EAX(%esp) 751 - jmp 2b 752 - SYM_CODE_END(ret_from_fork) 764 + RET 765 + SYM_CODE_END(ret_from_fork_asm) 753 766 .popsection 754 767 755 768 SYM_ENTRY(__begin_SYSENTER_singlestep_region, SYM_L_GLOBAL, SYM_A_NONE)
+8 -25
arch/x86/entry/entry_64.S
··· 284 284 * r12: kernel thread arg 285 285 */ 286 286 .pushsection .text, "ax" 287 - __FUNC_ALIGN 288 - SYM_CODE_START_NOALIGN(ret_from_fork) 289 - UNWIND_HINT_END_OF_STACK 287 + SYM_CODE_START(ret_from_fork_asm) 288 + UNWIND_HINT_REGS 290 289 ANNOTATE_NOENDBR // copy_thread 291 290 CALL_DEPTH_ACCOUNT 292 - movq %rax, %rdi 293 - call schedule_tail /* rdi: 'prev' task parameter */ 294 291 295 - testq %rbx, %rbx /* from kernel_thread? */ 296 - jnz 1f /* kernel threads are uncommon */ 292 + movq %rax, %rdi /* prev */ 293 + movq %rsp, %rsi /* regs */ 294 + movq %rbx, %rdx /* fn */ 295 + movq %r12, %rcx /* fn_arg */ 296 + call ret_from_fork 297 297 298 - 2: 299 - UNWIND_HINT_REGS 300 - movq %rsp, %rdi 301 - call syscall_exit_to_user_mode /* returns with IRQs disabled */ 302 298 jmp swapgs_restore_regs_and_return_to_usermode 303 - 304 - 1: 305 - /* kernel thread */ 306 - UNWIND_HINT_END_OF_STACK 307 - movq %r12, %rdi 308 - CALL_NOSPEC rbx 309 - /* 310 - * A kernel thread is allowed to return here after successfully 311 - * calling kernel_execve(). Exit to userspace to complete the execve() 312 - * syscall. 313 - */ 314 - movq $0, RAX(%rsp) 315 - jmp 2b 316 - SYM_CODE_END(ret_from_fork) 299 + SYM_CODE_END(ret_from_fork_asm) 317 300 .popsection 318 301 319 302 .macro DEBUG_ENTRY_ASSERT_IRQS_OFF
+7
arch/x86/events/intel/core.c
··· 3993 3993 struct perf_event *leader = event->group_leader; 3994 3994 struct perf_event *sibling = NULL; 3995 3995 3996 + /* 3997 + * When this memload event is also the first event (no group 3998 + * exists yet), then there is no aux event before it. 3999 + */ 4000 + if (leader == event) 4001 + return -ENODATA; 4002 + 3996 4003 if (!is_mem_loads_aux_event(leader)) { 3997 4004 for_each_sibling_event(sibling, leader) { 3998 4005 if (is_mem_loads_aux_event(sibling))
+1 -1
arch/x86/include/asm/alternative.h
··· 96 96 extern void apply_alternatives(struct alt_instr *start, struct alt_instr *end); 97 97 extern void apply_retpolines(s32 *start, s32 *end); 98 98 extern void apply_returns(s32 *start, s32 *end); 99 - extern void apply_ibt_endbr(s32 *start, s32 *end); 99 + extern void apply_seal_endbr(s32 *start, s32 *end); 100 100 extern void apply_fineibt(s32 *start_retpoline, s32 *end_retpoine, 101 101 s32 *start_cfi, s32 *end_cfi); 102 102
+1 -1
arch/x86/include/asm/ibt.h
··· 34 34 /* 35 35 * Create a dummy function pointer reference to prevent objtool from marking 36 36 * the function as needing to be "sealed" (i.e. ENDBR converted to NOP by 37 - * apply_ibt_endbr()). 37 + * apply_seal_endbr()). 38 38 */ 39 39 #define IBT_NOSEAL(fname) \ 40 40 ".pushsection .discard.ibt_endbr_noseal\n\t" \
+4
arch/x86/include/asm/nospec-branch.h
··· 234 234 * JMP_NOSPEC and CALL_NOSPEC macros can be used instead of a simple 235 235 * indirect jmp/call which may be susceptible to the Spectre variant 2 236 236 * attack. 237 + * 238 + * NOTE: these do not take kCFI into account and are thus not comparable to C 239 + * indirect calls, take care when using. The target of these should be an ENDBR 240 + * instruction irrespective of kCFI. 237 241 */ 238 242 .macro JMP_NOSPEC reg:req 239 243 #ifdef CONFIG_RETPOLINE
+3 -1
arch/x86/include/asm/switch_to.h
··· 12 12 __visible struct task_struct *__switch_to(struct task_struct *prev, 13 13 struct task_struct *next); 14 14 15 - asmlinkage void ret_from_fork(void); 15 + asmlinkage void ret_from_fork_asm(void); 16 + __visible void ret_from_fork(struct task_struct *prev, struct pt_regs *regs, 17 + int (*fn)(void *), void *fn_arg); 16 18 17 19 /* 18 20 * This is the structure pointed to by thread.sp for an inactive task. The
+67 -4
arch/x86/kernel/alternative.c
··· 778 778 779 779 #ifdef CONFIG_X86_KERNEL_IBT 780 780 781 + static void poison_cfi(void *addr); 782 + 781 783 static void __init_or_module poison_endbr(void *addr, bool warn) 782 784 { 783 785 u32 endbr, poison = gen_endbr_poison(); ··· 804 802 805 803 /* 806 804 * Generated by: objtool --ibt 805 + * 806 + * Seal the functions for indirect calls by clobbering the ENDBR instructions 807 + * and the kCFI hash value. 807 808 */ 808 - void __init_or_module noinline apply_ibt_endbr(s32 *start, s32 *end) 809 + void __init_or_module noinline apply_seal_endbr(s32 *start, s32 *end) 809 810 { 810 811 s32 *s; 811 812 ··· 817 812 818 813 poison_endbr(addr, true); 819 814 if (IS_ENABLED(CONFIG_FINEIBT)) 820 - poison_endbr(addr - 16, false); 815 + poison_cfi(addr - 16); 821 816 } 822 817 } 823 818 824 819 #else 825 820 826 - void __init_or_module apply_ibt_endbr(s32 *start, s32 *end) { } 821 + void __init_or_module apply_seal_endbr(s32 *start, s32 *end) { } 827 822 828 823 #endif /* CONFIG_X86_KERNEL_IBT */ 829 824 ··· 1068 1063 return 0; 1069 1064 } 1070 1065 1066 + static void cfi_rewrite_endbr(s32 *start, s32 *end) 1067 + { 1068 + s32 *s; 1069 + 1070 + for (s = start; s < end; s++) { 1071 + void *addr = (void *)s + *s; 1072 + 1073 + poison_endbr(addr+16, false); 1074 + } 1075 + } 1076 + 1071 1077 /* .retpoline_sites */ 1072 1078 static int cfi_rand_callers(s32 *start, s32 *end) 1073 1079 { ··· 1173 1157 return; 1174 1158 1175 1159 case CFI_FINEIBT: 1160 + /* place the FineIBT preamble at func()-16 */ 1176 1161 ret = cfi_rewrite_preamble(start_cfi, end_cfi); 1177 1162 if (ret) 1178 1163 goto err; 1179 1164 1165 + /* rewrite the callers to target func()-16 */ 1180 1166 ret = cfi_rewrite_callers(start_retpoline, end_retpoline); 1181 1167 if (ret) 1182 1168 goto err; 1169 + 1170 + /* now that nobody targets func()+0, remove ENDBR there */ 1171 + cfi_rewrite_endbr(start_cfi, end_cfi); 1183 1172 1184 1173 if (builtin) 1185 1174 pr_info("Using FineIBT CFI\n"); ··· 1198 1177 pr_err("Something went horribly wrong trying to rewrite the CFI implementation.\n"); 1199 1178 } 1200 1179 1180 + static inline void poison_hash(void *addr) 1181 + { 1182 + *(u32 *)addr = 0; 1183 + } 1184 + 1185 + static void poison_cfi(void *addr) 1186 + { 1187 + switch (cfi_mode) { 1188 + case CFI_FINEIBT: 1189 + /* 1190 + * __cfi_\func: 1191 + * osp nopl (%rax) 1192 + * subl $0, %r10d 1193 + * jz 1f 1194 + * ud2 1195 + * 1: nop 1196 + */ 1197 + poison_endbr(addr, false); 1198 + poison_hash(addr + fineibt_preamble_hash); 1199 + break; 1200 + 1201 + case CFI_KCFI: 1202 + /* 1203 + * __cfi_\func: 1204 + * movl $0, %eax 1205 + * .skip 11, 0x90 1206 + */ 1207 + poison_hash(addr + 1); 1208 + break; 1209 + 1210 + default: 1211 + break; 1212 + } 1213 + } 1214 + 1201 1215 #else 1202 1216 1203 1217 static void __apply_fineibt(s32 *start_retpoline, s32 *end_retpoline, 1204 1218 s32 *start_cfi, s32 *end_cfi, bool builtin) 1205 1219 { 1206 1220 } 1221 + 1222 + #ifdef CONFIG_X86_KERNEL_IBT 1223 + static void poison_cfi(void *addr) { } 1224 + #endif 1207 1225 1208 1226 #endif 1209 1227 ··· 1625 1565 */ 1626 1566 callthunks_patch_builtin_calls(); 1627 1567 1628 - apply_ibt_endbr(__ibt_endbr_seal, __ibt_endbr_seal_end); 1568 + /* 1569 + * Seal all functions that do not have their address taken. 1570 + */ 1571 + apply_seal_endbr(__ibt_endbr_seal, __ibt_endbr_seal_end); 1629 1572 1630 1573 #ifdef CONFIG_SMP 1631 1574 /* Patch to UP if other cpus not imminent. */
+1 -1
arch/x86/kernel/module.c
··· 358 358 } 359 359 if (ibt_endbr) { 360 360 void *iseg = (void *)ibt_endbr->sh_addr; 361 - apply_ibt_endbr(iseg, iseg + ibt_endbr->sh_size); 361 + apply_seal_endbr(iseg, iseg + ibt_endbr->sh_size); 362 362 } 363 363 if (locks) { 364 364 void *lseg = (void *)locks->sh_addr;
+21 -1
arch/x86/kernel/process.c
··· 28 28 #include <linux/static_call.h> 29 29 #include <trace/events/power.h> 30 30 #include <linux/hw_breakpoint.h> 31 + #include <linux/entry-common.h> 31 32 #include <asm/cpu.h> 32 33 #include <asm/apic.h> 33 34 #include <linux/uaccess.h> ··· 135 134 return do_set_thread_area_64(p, ARCH_SET_FS, tls); 136 135 } 137 136 137 + __visible void ret_from_fork(struct task_struct *prev, struct pt_regs *regs, 138 + int (*fn)(void *), void *fn_arg) 139 + { 140 + schedule_tail(prev); 141 + 142 + /* Is this a kernel thread? */ 143 + if (unlikely(fn)) { 144 + fn(fn_arg); 145 + /* 146 + * A kernel thread is allowed to return here after successfully 147 + * calling kernel_execve(). Exit to userspace to complete the 148 + * execve() syscall. 149 + */ 150 + regs->ax = 0; 151 + } 152 + 153 + syscall_exit_to_user_mode(regs); 154 + } 155 + 138 156 int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) 139 157 { 140 158 unsigned long clone_flags = args->flags; ··· 169 149 frame = &fork_frame->frame; 170 150 171 151 frame->bp = encode_frame_pointer(childregs); 172 - frame->ret_addr = (unsigned long) ret_from_fork; 152 + frame->ret_addr = (unsigned long) ret_from_fork_asm; 173 153 p->thread.sp = (unsigned long) fork_frame; 174 154 p->thread.io_bitmap = NULL; 175 155 p->thread.iopl_warn = 0;
+14 -20
arch/xtensa/kernel/align.S
··· 1 1 /* 2 2 * arch/xtensa/kernel/align.S 3 3 * 4 - * Handle unalignment exceptions in kernel space. 4 + * Handle unalignment and load/store exceptions. 5 5 * 6 6 * This file is subject to the terms and conditions of the GNU General 7 7 * Public License. See the file "COPYING" in the main directory of ··· 26 26 #define LOAD_EXCEPTION_HANDLER 27 27 #endif 28 28 29 - #if XCHAL_UNALIGNED_STORE_EXCEPTION || defined LOAD_EXCEPTION_HANDLER 29 + #if XCHAL_UNALIGNED_STORE_EXCEPTION || defined CONFIG_XTENSA_LOAD_STORE 30 + #define STORE_EXCEPTION_HANDLER 31 + #endif 32 + 33 + #if defined LOAD_EXCEPTION_HANDLER || defined STORE_EXCEPTION_HANDLER 30 34 #define ANY_EXCEPTION_HANDLER 31 35 #endif 32 36 33 - #if XCHAL_HAVE_WINDOWED 37 + #if XCHAL_HAVE_WINDOWED && defined CONFIG_MMU 34 38 #define UNALIGNED_USER_EXCEPTION 35 39 #endif 36 - 37 - /* First-level exception handler for unaligned exceptions. 38 - * 39 - * Note: This handler works only for kernel exceptions. Unaligned user 40 - * access should get a seg fault. 41 - */ 42 40 43 41 /* Big and little endian 16-bit values are located in 44 42 * different halves of a register. HWORD_START helps to ··· 226 228 #ifdef ANY_EXCEPTION_HANDLER 227 229 ENTRY(fast_unaligned) 228 230 229 - #if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION 230 - 231 231 call0 .Lsave_and_load_instruction 232 232 233 233 /* Analyze the instruction (load or store?). */ ··· 240 244 /* 'store indicator bit' not set, jump */ 241 245 _bbci.l a4, OP1_SI_BIT + INSN_OP1, .Lload 242 246 243 - #endif 244 - #if XCHAL_UNALIGNED_STORE_EXCEPTION 247 + #ifdef STORE_EXCEPTION_HANDLER 245 248 246 249 /* Store: Jump to table entry to get the value in the source register.*/ 247 250 ··· 249 254 addx8 a5, a6, a5 250 255 jx a5 # jump into table 251 256 #endif 252 - #if XCHAL_UNALIGNED_LOAD_EXCEPTION 257 + #ifdef LOAD_EXCEPTION_HANDLER 253 258 254 259 /* Load: Load memory address. */ 255 260 ··· 323 328 mov a14, a3 ; _j .Lexit; .align 8 324 329 mov a15, a3 ; _j .Lexit; .align 8 325 330 #endif 326 - #if XCHAL_UNALIGNED_STORE_EXCEPTION 331 + #ifdef STORE_EXCEPTION_HANDLER 327 332 .Lstore_table: 328 333 l32i a3, a2, PT_AREG0; _j .Lstore_w; .align 8 329 334 mov a3, a1; _j .Lstore_w; .align 8 # fishy?? ··· 343 348 mov a3, a15 ; _j .Lstore_w; .align 8 344 349 #endif 345 350 346 - #ifdef ANY_EXCEPTION_HANDLER 347 351 /* We cannot handle this exception. */ 348 352 349 353 .extern _kernel_exception ··· 371 377 372 378 2: movi a0, _user_exception 373 379 jx a0 374 - #endif 375 - #if XCHAL_UNALIGNED_STORE_EXCEPTION 380 + 381 + #ifdef STORE_EXCEPTION_HANDLER 376 382 377 383 # a7: instruction pointer, a4: instruction, a3: value 378 384 .Lstore_w: ··· 438 444 s32i a6, a4, 4 439 445 #endif 440 446 #endif 441 - #ifdef ANY_EXCEPTION_HANDLER 447 + 442 448 .Lexit: 443 449 #if XCHAL_HAVE_LOOPS 444 450 rsr a4, lend # check if we reached LEND ··· 533 539 __src_b a4, a4, a5 # a4 has the instruction 534 540 535 541 ret 536 - #endif 542 + 537 543 ENDPROC(fast_unaligned) 538 544 539 545 ENTRY(fast_unaligned_fixup)
+2 -1
arch/xtensa/kernel/traps.c
··· 102 102 #endif 103 103 { EXCCAUSE_INTEGER_DIVIDE_BY_ZERO, 0, do_div0 }, 104 104 /* EXCCAUSE_PRIVILEGED unhandled */ 105 - #if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION 105 + #if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION || \ 106 + IS_ENABLED(CONFIG_XTENSA_LOAD_STORE) 106 107 #ifdef CONFIG_XTENSA_UNALIGNED_USER 107 108 { EXCCAUSE_UNALIGNED, USER, fast_unaligned }, 108 109 #endif
+2 -1
arch/xtensa/platforms/iss/network.c
··· 237 237 238 238 init += sizeof(TRANSPORT_TUNTAP_NAME) - 1; 239 239 if (*init == ',') { 240 - rem = split_if_spec(init + 1, &mac_str, &dev_name); 240 + rem = split_if_spec(init + 1, &mac_str, &dev_name, NULL); 241 241 if (rem != NULL) { 242 242 pr_err("%s: extra garbage on specification : '%s'\n", 243 243 dev->name, rem); ··· 540 540 rtnl_unlock(); 541 541 pr_err("%s: error registering net device!\n", dev->name); 542 542 platform_device_unregister(&lp->pdev); 543 + /* dev is freed by the iss_net_pdev_release callback */ 543 544 return; 544 545 } 545 546 rtnl_unlock();
+10 -2
block/blk-crypto-profile.c
··· 79 79 unsigned int slot_hashtable_size; 80 80 81 81 memset(profile, 0, sizeof(*profile)); 82 - init_rwsem(&profile->lock); 82 + 83 + /* 84 + * profile->lock of an underlying device can nest inside profile->lock 85 + * of a device-mapper device, so use a dynamic lock class to avoid 86 + * false-positive lockdep reports. 87 + */ 88 + lockdep_register_key(&profile->lockdep_key); 89 + __init_rwsem(&profile->lock, "&profile->lock", &profile->lockdep_key); 83 90 84 91 if (num_slots == 0) 85 92 return 0; ··· 96 89 profile->slots = kvcalloc(num_slots, sizeof(profile->slots[0]), 97 90 GFP_KERNEL); 98 91 if (!profile->slots) 99 - return -ENOMEM; 92 + goto err_destroy; 100 93 101 94 profile->num_slots = num_slots; 102 95 ··· 442 435 { 443 436 if (!profile) 444 437 return; 438 + lockdep_unregister_key(&profile->lockdep_key); 445 439 kvfree(profile->slot_hashtable); 446 440 kvfree_sensitive(profile->slots, 447 441 sizeof(profile->slots[0]) * profile->num_slots);
+1 -1
block/blk-flush.c
··· 189 189 case REQ_FSEQ_DATA: 190 190 list_move_tail(&rq->flush.list, &fq->flush_data_in_flight); 191 191 spin_lock(&q->requeue_lock); 192 - list_add_tail(&rq->queuelist, &q->flush_list); 192 + list_add(&rq->queuelist, &q->requeue_list); 193 193 spin_unlock(&q->requeue_lock); 194 194 blk_mq_kick_requeue_list(q); 195 195 break;
+30 -17
block/blk-mq.c
··· 328 328 } 329 329 EXPORT_SYMBOL(blk_rq_init); 330 330 331 + /* Set start and alloc time when the allocated request is actually used */ 332 + static inline void blk_mq_rq_time_init(struct request *rq, u64 alloc_time_ns) 333 + { 334 + if (blk_mq_need_time_stamp(rq)) 335 + rq->start_time_ns = ktime_get_ns(); 336 + else 337 + rq->start_time_ns = 0; 338 + 339 + #ifdef CONFIG_BLK_RQ_ALLOC_TIME 340 + if (blk_queue_rq_alloc_time(rq->q)) 341 + rq->alloc_time_ns = alloc_time_ns ?: rq->start_time_ns; 342 + else 343 + rq->alloc_time_ns = 0; 344 + #endif 345 + } 346 + 331 347 static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, 332 - struct blk_mq_tags *tags, unsigned int tag, u64 alloc_time_ns) 348 + struct blk_mq_tags *tags, unsigned int tag) 333 349 { 334 350 struct blk_mq_ctx *ctx = data->ctx; 335 351 struct blk_mq_hw_ctx *hctx = data->hctx; ··· 372 356 } 373 357 rq->timeout = 0; 374 358 375 - if (blk_mq_need_time_stamp(rq)) 376 - rq->start_time_ns = ktime_get_ns(); 377 - else 378 - rq->start_time_ns = 0; 379 359 rq->part = NULL; 380 - #ifdef CONFIG_BLK_RQ_ALLOC_TIME 381 - rq->alloc_time_ns = alloc_time_ns; 382 - #endif 383 360 rq->io_start_time_ns = 0; 384 361 rq->stats_sectors = 0; 385 362 rq->nr_phys_segments = 0; ··· 402 393 } 403 394 404 395 static inline struct request * 405 - __blk_mq_alloc_requests_batch(struct blk_mq_alloc_data *data, 406 - u64 alloc_time_ns) 396 + __blk_mq_alloc_requests_batch(struct blk_mq_alloc_data *data) 407 397 { 408 398 unsigned int tag, tag_offset; 409 399 struct blk_mq_tags *tags; ··· 421 413 tag = tag_offset + i; 422 414 prefetch(tags->static_rqs[tag]); 423 415 tag_mask &= ~(1UL << i); 424 - rq = blk_mq_rq_ctx_init(data, tags, tag, alloc_time_ns); 416 + rq = blk_mq_rq_ctx_init(data, tags, tag); 425 417 rq_list_add(data->cached_rq, rq); 426 418 nr++; 427 419 } ··· 482 474 * Try batched alloc if we want more than 1 tag. 483 475 */ 484 476 if (data->nr_tags > 1) { 485 - rq = __blk_mq_alloc_requests_batch(data, alloc_time_ns); 486 - if (rq) 477 + rq = __blk_mq_alloc_requests_batch(data); 478 + if (rq) { 479 + blk_mq_rq_time_init(rq, alloc_time_ns); 487 480 return rq; 481 + } 488 482 data->nr_tags = 1; 489 483 } 490 484 ··· 509 499 goto retry; 510 500 } 511 501 512 - return blk_mq_rq_ctx_init(data, blk_mq_tags_from_data(data), tag, 513 - alloc_time_ns); 502 + rq = blk_mq_rq_ctx_init(data, blk_mq_tags_from_data(data), tag); 503 + blk_mq_rq_time_init(rq, alloc_time_ns); 504 + return rq; 514 505 } 515 506 516 507 static struct request *blk_mq_rq_cache_fill(struct request_queue *q, ··· 566 555 return NULL; 567 556 568 557 plug->cached_rq = rq_list_next(rq); 558 + blk_mq_rq_time_init(rq, 0); 569 559 } 570 560 571 561 rq->cmd_flags = opf; ··· 668 656 tag = blk_mq_get_tag(&data); 669 657 if (tag == BLK_MQ_NO_TAG) 670 658 goto out_queue_exit; 671 - rq = blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag, 672 - alloc_time_ns); 659 + rq = blk_mq_rq_ctx_init(&data, blk_mq_tags_from_data(&data), tag); 660 + blk_mq_rq_time_init(rq, alloc_time_ns); 673 661 rq->__data_len = 0; 674 662 rq->__sector = (sector_t) -1; 675 663 rq->bio = rq->biotail = NULL; ··· 2908 2896 plug->cached_rq = rq_list_next(rq); 2909 2897 rq_qos_throttle(q, *bio); 2910 2898 2899 + blk_mq_rq_time_init(rq, 0); 2911 2900 rq->cmd_flags = (*bio)->bi_opf; 2912 2901 INIT_LIST_HEAD(&rq->queuelist); 2913 2902 return rq;
+50 -36
block/blk-zoned.c
··· 442 442 unsigned long *conv_zones_bitmap; 443 443 unsigned long *seq_zones_wlock; 444 444 unsigned int nr_zones; 445 - sector_t zone_sectors; 446 445 sector_t sector; 447 446 }; 448 447 ··· 455 456 struct gendisk *disk = args->disk; 456 457 struct request_queue *q = disk->queue; 457 458 sector_t capacity = get_capacity(disk); 459 + sector_t zone_sectors = q->limits.chunk_sectors; 460 + 461 + /* Check for bad zones and holes in the zone report */ 462 + if (zone->start != args->sector) { 463 + pr_warn("%s: Zone gap at sectors %llu..%llu\n", 464 + disk->disk_name, args->sector, zone->start); 465 + return -ENODEV; 466 + } 467 + 468 + if (zone->start >= capacity || !zone->len) { 469 + pr_warn("%s: Invalid zone start %llu, length %llu\n", 470 + disk->disk_name, zone->start, zone->len); 471 + return -ENODEV; 472 + } 458 473 459 474 /* 460 475 * All zones must have the same size, with the exception on an eventual 461 476 * smaller last zone. 462 477 */ 463 - if (zone->start == 0) { 464 - if (zone->len == 0 || !is_power_of_2(zone->len)) { 465 - pr_warn("%s: Invalid zoned device with non power of two zone size (%llu)\n", 466 - disk->disk_name, zone->len); 467 - return -ENODEV; 468 - } 469 - 470 - args->zone_sectors = zone->len; 471 - args->nr_zones = (capacity + zone->len - 1) >> ilog2(zone->len); 472 - } else if (zone->start + args->zone_sectors < capacity) { 473 - if (zone->len != args->zone_sectors) { 478 + if (zone->start + zone->len < capacity) { 479 + if (zone->len != zone_sectors) { 474 480 pr_warn("%s: Invalid zoned device with non constant zone size\n", 475 481 disk->disk_name); 476 482 return -ENODEV; 477 483 } 478 - } else { 479 - if (zone->len > args->zone_sectors) { 480 - pr_warn("%s: Invalid zoned device with larger last zone size\n", 481 - disk->disk_name); 482 - return -ENODEV; 483 - } 484 - } 485 - 486 - /* Check for holes in the zone report */ 487 - if (zone->start != args->sector) { 488 - pr_warn("%s: Zone gap at sectors %llu..%llu\n", 489 - disk->disk_name, args->sector, zone->start); 484 + } else if (zone->len > zone_sectors) { 485 + pr_warn("%s: Invalid zoned device with larger last zone size\n", 486 + disk->disk_name); 490 487 return -ENODEV; 491 488 } 492 489 ··· 521 526 * @disk: Target disk 522 527 * @update_driver_data: Callback to update driver data on the frozen disk 523 528 * 524 - * Helper function for low-level device drivers to (re) allocate and initialize 525 - * a disk request queue zone bitmaps. This functions should normally be called 526 - * within the disk ->revalidate method for blk-mq based drivers. For BIO based 527 - * drivers only q->nr_zones needs to be updated so that the sysfs exposed value 528 - * is correct. 529 + * Helper function for low-level device drivers to check and (re) allocate and 530 + * initialize a disk request queue zone bitmaps. This functions should normally 531 + * be called within the disk ->revalidate method for blk-mq based drivers. 532 + * Before calling this function, the device driver must already have set the 533 + * device zone size (chunk_sector limit) and the max zone append limit. 534 + * For BIO based drivers, this function cannot be used. BIO based device drivers 535 + * only need to set disk->nr_zones so that the sysfs exposed value is correct. 529 536 * If the @update_driver_data callback function is not NULL, the callback is 530 537 * executed with the device request queue frozen after all zones have been 531 538 * checked. ··· 536 539 void (*update_driver_data)(struct gendisk *disk)) 537 540 { 538 541 struct request_queue *q = disk->queue; 539 - struct blk_revalidate_zone_args args = { 540 - .disk = disk, 541 - }; 542 + sector_t zone_sectors = q->limits.chunk_sectors; 543 + sector_t capacity = get_capacity(disk); 544 + struct blk_revalidate_zone_args args = { }; 542 545 unsigned int noio_flag; 543 546 int ret; 544 547 ··· 547 550 if (WARN_ON_ONCE(!queue_is_mq(q))) 548 551 return -EIO; 549 552 550 - if (!get_capacity(disk)) 551 - return -EIO; 553 + if (!capacity) 554 + return -ENODEV; 555 + 556 + /* 557 + * Checks that the device driver indicated a valid zone size and that 558 + * the max zone append limit is set. 559 + */ 560 + if (!zone_sectors || !is_power_of_2(zone_sectors)) { 561 + pr_warn("%s: Invalid non power of two zone size (%llu)\n", 562 + disk->disk_name, zone_sectors); 563 + return -ENODEV; 564 + } 565 + 566 + if (!q->limits.max_zone_append_sectors) { 567 + pr_warn("%s: Invalid 0 maximum zone append limit\n", 568 + disk->disk_name); 569 + return -ENODEV; 570 + } 552 571 553 572 /* 554 573 * Ensure that all memory allocations in this context are done as if 555 574 * GFP_NOIO was specified. 556 575 */ 576 + args.disk = disk; 577 + args.nr_zones = (capacity + zone_sectors - 1) >> ilog2(zone_sectors); 557 578 noio_flag = memalloc_noio_save(); 558 579 ret = disk->fops->report_zones(disk, 0, UINT_MAX, 559 580 blk_revalidate_zone_cb, &args); ··· 585 570 * If zones where reported, make sure that the entire disk capacity 586 571 * has been checked. 587 572 */ 588 - if (ret > 0 && args.sector != get_capacity(disk)) { 573 + if (ret > 0 && args.sector != capacity) { 589 574 pr_warn("%s: Missing zones from sector %llu\n", 590 575 disk->disk_name, args.sector); 591 576 ret = -ENODEV; ··· 598 583 */ 599 584 blk_mq_freeze_queue(q); 600 585 if (ret > 0) { 601 - blk_queue_chunk_sectors(q, args.zone_sectors); 602 586 disk->nr_zones = args.nr_zones; 603 587 swap(disk->seq_zones_wlock, args.seq_zones_wlock); 604 588 swap(disk->conv_zones_bitmap, args.conv_zones_bitmap);
+1 -1
block/mq-deadline.c
··· 176 176 * zoned writes, start searching from the start of a zone. 177 177 */ 178 178 if (blk_rq_is_seq_zoned_write(rq)) 179 - pos -= round_down(pos, rq->q->limits.chunk_sectors); 179 + pos = round_down(pos, rq->q->limits.chunk_sectors); 180 180 181 181 while (node) { 182 182 rq = rb_entry_rq(node);
+1 -1
block/partitions/amiga.c
··· 90 90 } 91 91 blk = be32_to_cpu(rdb->rdb_PartitionList); 92 92 put_dev_sector(sect); 93 - for (part = 1; blk>0 && part<=16; part++, put_dev_sector(sect)) { 93 + for (part = 1; (s32) blk>0 && part<=16; part++, put_dev_sector(sect)) { 94 94 /* Read in terms partition table understands */ 95 95 if (check_mul_overflow(blk, (sector_t) blksize, &blk)) { 96 96 pr_err("Dev %s: overflow calculating partition block %llu! Skipping partitions %u and beyond\n",
+1
drivers/accel/ivpu/ivpu_drv.h
··· 75 75 bool punit_disabled; 76 76 bool clear_runtime_mem; 77 77 bool d3hot_after_power_off; 78 + bool interrupt_clear_with_0; 78 79 }; 79 80 80 81 struct ivpu_hw_info;
+13 -7
drivers/accel/ivpu/ivpu_hw_mtl.c
··· 101 101 vdev->wa.punit_disabled = ivpu_is_fpga(vdev); 102 102 vdev->wa.clear_runtime_mem = false; 103 103 vdev->wa.d3hot_after_power_off = true; 104 + 105 + if (ivpu_device_id(vdev) == PCI_DEVICE_ID_MTL && ivpu_revision(vdev) < 4) 106 + vdev->wa.interrupt_clear_with_0 = true; 104 107 } 105 108 106 109 static void ivpu_hw_timeouts_init(struct ivpu_device *vdev) ··· 888 885 REGB_WR32(MTL_BUTTRESS_GLOBAL_INT_MASK, 0x1); 889 886 REGB_WR32(MTL_BUTTRESS_LOCAL_INT_MASK, BUTTRESS_IRQ_DISABLE_MASK); 890 887 REGV_WR64(MTL_VPU_HOST_SS_ICB_ENABLE_0, 0x0ull); 891 - REGB_WR32(MTL_VPU_HOST_SS_FW_SOC_IRQ_EN, 0x0); 888 + REGV_WR32(MTL_VPU_HOST_SS_FW_SOC_IRQ_EN, 0x0); 892 889 } 893 890 894 891 static void ivpu_hw_mtl_irq_wdt_nce_handler(struct ivpu_device *vdev) ··· 976 973 schedule_recovery = true; 977 974 } 978 975 979 - /* 980 - * Clear local interrupt status by writing 0 to all bits. 981 - * This must be done after interrupts are cleared at the source. 982 - * Writing 1 triggers an interrupt, so we can't perform read update write. 983 - */ 984 - REGB_WR32(MTL_BUTTRESS_INTERRUPT_STAT, 0x0); 976 + /* This must be done after interrupts are cleared at the source. */ 977 + if (IVPU_WA(interrupt_clear_with_0)) 978 + /* 979 + * Writing 1 triggers an interrupt, so we can't perform read update write. 980 + * Clear local interrupt status by writing 0 to all bits. 981 + */ 982 + REGB_WR32(MTL_BUTTRESS_INTERRUPT_STAT, 0x0); 983 + else 984 + REGB_WR32(MTL_BUTTRESS_INTERRUPT_STAT, status); 985 985 986 986 /* Re-enable global interrupt */ 987 987 REGB_WR32(MTL_BUTTRESS_GLOBAL_INT_MASK, 0x0);
+1 -1
drivers/base/regmap/regmap-irq.c
··· 717 717 if (!d->config_buf) 718 718 goto err_alloc; 719 719 720 - for (i = 0; i < chip->num_config_regs; i++) { 720 + for (i = 0; i < chip->num_config_bases; i++) { 721 721 d->config_buf[i] = kcalloc(chip->num_config_regs, 722 722 sizeof(**d->config_buf), 723 723 GFP_KERNEL);
+5 -11
drivers/block/null_blk/zoned.c
··· 162 162 disk_set_zoned(nullb->disk, BLK_ZONED_HM); 163 163 blk_queue_flag_set(QUEUE_FLAG_ZONE_RESETALL, q); 164 164 blk_queue_required_elevator_features(q, ELEVATOR_F_ZBD_SEQ_WRITE); 165 - 166 - if (queue_is_mq(q)) { 167 - int ret = blk_revalidate_disk_zones(nullb->disk, NULL); 168 - 169 - if (ret) 170 - return ret; 171 - } else { 172 - blk_queue_chunk_sectors(q, dev->zone_size_sects); 173 - nullb->disk->nr_zones = bdev_nr_zones(nullb->disk->part0); 174 - } 175 - 165 + blk_queue_chunk_sectors(q, dev->zone_size_sects); 166 + nullb->disk->nr_zones = bdev_nr_zones(nullb->disk->part0); 176 167 blk_queue_max_zone_append_sectors(q, dev->zone_size_sects); 177 168 disk_set_max_open_zones(nullb->disk, dev->zone_max_open); 178 169 disk_set_max_active_zones(nullb->disk, dev->zone_max_active); 170 + 171 + if (queue_is_mq(q)) 172 + return blk_revalidate_disk_zones(nullb->disk, NULL); 179 173 180 174 return 0; 181 175 }
+15 -19
drivers/block/virtio_blk.c
··· 751 751 { 752 752 u32 v, wg; 753 753 u8 model; 754 - int ret; 755 754 756 755 virtio_cread(vdev, struct virtio_blk_config, 757 756 zoned.model, &model); ··· 805 806 vblk->zone_sectors); 806 807 return -ENODEV; 807 808 } 809 + blk_queue_chunk_sectors(q, vblk->zone_sectors); 808 810 dev_dbg(&vdev->dev, "zone sectors = %u\n", vblk->zone_sectors); 809 811 810 812 if (virtio_has_feature(vdev, VIRTIO_BLK_F_DISCARD)) { ··· 814 814 blk_queue_max_discard_sectors(q, 0); 815 815 } 816 816 817 - ret = blk_revalidate_disk_zones(vblk->disk, NULL); 818 - if (!ret) { 819 - virtio_cread(vdev, struct virtio_blk_config, 820 - zoned.max_append_sectors, &v); 821 - if (!v) { 822 - dev_warn(&vdev->dev, "zero max_append_sectors reported\n"); 823 - return -ENODEV; 824 - } 825 - if ((v << SECTOR_SHIFT) < wg) { 826 - dev_err(&vdev->dev, 827 - "write granularity %u exceeds max_append_sectors %u limit\n", 828 - wg, v); 829 - return -ENODEV; 830 - } 831 - 832 - blk_queue_max_zone_append_sectors(q, v); 833 - dev_dbg(&vdev->dev, "max append sectors = %u\n", v); 817 + virtio_cread(vdev, struct virtio_blk_config, 818 + zoned.max_append_sectors, &v); 819 + if (!v) { 820 + dev_warn(&vdev->dev, "zero max_append_sectors reported\n"); 821 + return -ENODEV; 834 822 } 823 + if ((v << SECTOR_SHIFT) < wg) { 824 + dev_err(&vdev->dev, 825 + "write granularity %u exceeds max_append_sectors %u limit\n", 826 + wg, v); 827 + return -ENODEV; 828 + } 829 + blk_queue_max_zone_append_sectors(q, v); 830 + dev_dbg(&vdev->dev, "max append sectors = %u\n", v); 835 831 836 - return ret; 832 + return blk_revalidate_disk_zones(vblk->disk, NULL); 837 833 } 838 834 839 835 #else
+1
drivers/bluetooth/btusb.c
··· 4104 4104 BT_DBG("intf %p id %p", intf, id); 4105 4105 4106 4106 if ((id->driver_info & BTUSB_IFNUM_2) && 4107 + (intf->cur_altsetting->desc.bInterfaceNumber != 0) && 4107 4108 (intf->cur_altsetting->desc.bInterfaceNumber != 2)) 4108 4109 return -ENODEV; 4109 4110
+7
drivers/char/tpm/tpm-chip.c
··· 518 518 * 6.x.y.z series: 6.0.18.6 + 519 519 * 3.x.y.z series: 3.57.y.5 + 520 520 */ 521 + #ifdef CONFIG_X86 521 522 static bool tpm_amd_is_rng_defective(struct tpm_chip *chip) 522 523 { 523 524 u32 val1, val2; ··· 567 566 568 567 return true; 569 568 } 569 + #else 570 + static inline bool tpm_amd_is_rng_defective(struct tpm_chip *chip) 571 + { 572 + return false; 573 + } 574 + #endif /* CONFIG_X86 */ 570 575 571 576 static int tpm_hwrng_read(struct hwrng *rng, void *data, size_t max, bool wait) 572 577 {
+11 -8
drivers/char/tpm/tpm_crb.c
··· 563 563 u32 rsp_size; 564 564 int ret; 565 565 566 - INIT_LIST_HEAD(&acpi_resource_list); 567 - ret = acpi_dev_get_resources(device, &acpi_resource_list, 568 - crb_check_resource, iores_array); 569 - if (ret < 0) 570 - return ret; 571 - acpi_dev_free_resource_list(&acpi_resource_list); 572 - 573 - /* Pluton doesn't appear to define ACPI memory regions */ 566 + /* 567 + * Pluton sometimes does not define ACPI memory regions. 568 + * Mapping is then done in crb_map_pluton 569 + */ 574 570 if (priv->sm != ACPI_TPM2_COMMAND_BUFFER_WITH_PLUTON) { 571 + INIT_LIST_HEAD(&acpi_resource_list); 572 + ret = acpi_dev_get_resources(device, &acpi_resource_list, 573 + crb_check_resource, iores_array); 574 + if (ret < 0) 575 + return ret; 576 + acpi_dev_free_resource_list(&acpi_resource_list); 577 + 575 578 if (resource_type(iores_array) != IORESOURCE_MEM) { 576 579 dev_err(dev, FW_BUG "TPM2 ACPI table does not define a memory resource\n"); 577 580 return -EINVAL;
+25
drivers/char/tpm/tpm_tis.c
··· 116 116 static const struct dmi_system_id tpm_tis_dmi_table[] = { 117 117 { 118 118 .callback = tpm_tis_disable_irq, 119 + .ident = "Framework Laptop (12th Gen Intel Core)", 120 + .matches = { 121 + DMI_MATCH(DMI_SYS_VENDOR, "Framework"), 122 + DMI_MATCH(DMI_PRODUCT_NAME, "Laptop (12th Gen Intel Core)"), 123 + }, 124 + }, 125 + { 126 + .callback = tpm_tis_disable_irq, 127 + .ident = "Framework Laptop (13th Gen Intel Core)", 128 + .matches = { 129 + DMI_MATCH(DMI_SYS_VENDOR, "Framework"), 130 + DMI_MATCH(DMI_PRODUCT_NAME, "Laptop (13th Gen Intel Core)"), 131 + }, 132 + }, 133 + { 134 + .callback = tpm_tis_disable_irq, 119 135 .ident = "ThinkPad T490s", 120 136 .matches = { 121 137 DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), ··· 156 140 }, 157 141 { 158 142 .callback = tpm_tis_disable_irq, 143 + .ident = "ThinkPad L590", 144 + .matches = { 145 + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), 146 + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad L590"), 147 + }, 148 + }, 149 + { 150 + .callback = tpm_tis_disable_irq, 159 151 .ident = "UPX-TGL", 160 152 .matches = { 161 153 DMI_MATCH(DMI_SYS_VENDOR, "AAEON"), 154 + DMI_MATCH(DMI_PRODUCT_VERSION, "UPX-TGL"), 162 155 }, 163 156 }, 164 157 {}
+88 -15
drivers/char/tpm/tpm_tis_core.c
··· 24 24 #include <linux/wait.h> 25 25 #include <linux/acpi.h> 26 26 #include <linux/freezer.h> 27 + #include <linux/dmi.h> 27 28 #include "tpm.h" 28 29 #include "tpm_tis_core.h" 30 + 31 + #define TPM_TIS_MAX_UNHANDLED_IRQS 1000 29 32 30 33 static void tpm_tis_clkrun_enable(struct tpm_chip *chip, bool value); 31 34 ··· 471 468 return rc; 472 469 } 473 470 474 - static void disable_interrupts(struct tpm_chip *chip) 471 + static void __tpm_tis_disable_interrupts(struct tpm_chip *chip) 475 472 { 476 473 struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); 477 - u32 intmask; 478 - int rc; 474 + u32 int_mask = 0; 475 + 476 + tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &int_mask); 477 + int_mask &= ~TPM_GLOBAL_INT_ENABLE; 478 + tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), int_mask); 479 + 480 + chip->flags &= ~TPM_CHIP_FLAG_IRQ; 481 + } 482 + 483 + static void tpm_tis_disable_interrupts(struct tpm_chip *chip) 484 + { 485 + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); 479 486 480 487 if (priv->irq == 0) 481 488 return; 482 489 483 - rc = tpm_tis_read32(priv, TPM_INT_ENABLE(priv->locality), &intmask); 484 - if (rc < 0) 485 - intmask = 0; 486 - 487 - intmask &= ~TPM_GLOBAL_INT_ENABLE; 488 - rc = tpm_tis_write32(priv, TPM_INT_ENABLE(priv->locality), intmask); 490 + __tpm_tis_disable_interrupts(chip); 489 491 490 492 devm_free_irq(chip->dev.parent, priv->irq, chip); 491 493 priv->irq = 0; 492 - chip->flags &= ~TPM_CHIP_FLAG_IRQ; 493 494 } 494 495 495 496 /* ··· 559 552 if (!test_bit(TPM_TIS_IRQ_TESTED, &priv->flags)) 560 553 tpm_msleep(1); 561 554 if (!test_bit(TPM_TIS_IRQ_TESTED, &priv->flags)) 562 - disable_interrupts(chip); 555 + tpm_tis_disable_interrupts(chip); 563 556 set_bit(TPM_TIS_IRQ_TESTED, &priv->flags); 564 557 return rc; 565 558 } ··· 759 752 return status == TPM_STS_COMMAND_READY; 760 753 } 761 754 755 + static irqreturn_t tpm_tis_revert_interrupts(struct tpm_chip *chip) 756 + { 757 + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); 758 + const char *product; 759 + const char *vendor; 760 + 761 + dev_warn(&chip->dev, FW_BUG 762 + "TPM interrupt storm detected, polling instead\n"); 763 + 764 + vendor = dmi_get_system_info(DMI_SYS_VENDOR); 765 + product = dmi_get_system_info(DMI_PRODUCT_VERSION); 766 + 767 + if (vendor && product) { 768 + dev_info(&chip->dev, 769 + "Consider adding the following entry to tpm_tis_dmi_table:\n"); 770 + dev_info(&chip->dev, "\tDMI_SYS_VENDOR: %s\n", vendor); 771 + dev_info(&chip->dev, "\tDMI_PRODUCT_VERSION: %s\n", product); 772 + } 773 + 774 + if (tpm_tis_request_locality(chip, 0) != 0) 775 + return IRQ_NONE; 776 + 777 + __tpm_tis_disable_interrupts(chip); 778 + tpm_tis_relinquish_locality(chip, 0); 779 + 780 + schedule_work(&priv->free_irq_work); 781 + 782 + return IRQ_HANDLED; 783 + } 784 + 785 + static irqreturn_t tpm_tis_update_unhandled_irqs(struct tpm_chip *chip) 786 + { 787 + struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); 788 + irqreturn_t irqret = IRQ_HANDLED; 789 + 790 + if (!(chip->flags & TPM_CHIP_FLAG_IRQ)) 791 + return IRQ_HANDLED; 792 + 793 + if (time_after(jiffies, priv->last_unhandled_irq + HZ/10)) 794 + priv->unhandled_irqs = 1; 795 + else 796 + priv->unhandled_irqs++; 797 + 798 + priv->last_unhandled_irq = jiffies; 799 + 800 + if (priv->unhandled_irqs > TPM_TIS_MAX_UNHANDLED_IRQS) 801 + irqret = tpm_tis_revert_interrupts(chip); 802 + 803 + return irqret; 804 + } 805 + 762 806 static irqreturn_t tis_int_handler(int dummy, void *dev_id) 763 807 { 764 808 struct tpm_chip *chip = dev_id; ··· 819 761 820 762 rc = tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), &interrupt); 821 763 if (rc < 0) 822 - return IRQ_NONE; 764 + goto err; 823 765 824 766 if (interrupt == 0) 825 - return IRQ_NONE; 767 + goto err; 826 768 827 769 set_bit(TPM_TIS_IRQ_TESTED, &priv->flags); 828 770 if (interrupt & TPM_INTF_DATA_AVAIL_INT) ··· 838 780 rc = tpm_tis_write32(priv, TPM_INT_STATUS(priv->locality), interrupt); 839 781 tpm_tis_relinquish_locality(chip, 0); 840 782 if (rc < 0) 841 - return IRQ_NONE; 783 + goto err; 842 784 843 785 tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), &interrupt); 844 786 return IRQ_HANDLED; 787 + 788 + err: 789 + return tpm_tis_update_unhandled_irqs(chip); 845 790 } 846 791 847 792 static void tpm_tis_gen_interrupt(struct tpm_chip *chip) ··· 865 804 chip->flags &= ~TPM_CHIP_FLAG_IRQ; 866 805 } 867 806 807 + static void tpm_tis_free_irq_func(struct work_struct *work) 808 + { 809 + struct tpm_tis_data *priv = container_of(work, typeof(*priv), free_irq_work); 810 + struct tpm_chip *chip = priv->chip; 811 + 812 + devm_free_irq(chip->dev.parent, priv->irq, chip); 813 + priv->irq = 0; 814 + } 815 + 868 816 /* Register the IRQ and issue a command that will cause an interrupt. If an 869 817 * irq is seen then leave the chip setup for IRQ operation, otherwise reverse 870 818 * everything and leave in polling mode. Returns 0 on success. ··· 886 816 int rc; 887 817 u32 int_status; 888 818 819 + INIT_WORK(&priv->free_irq_work, tpm_tis_free_irq_func); 889 820 890 821 rc = devm_request_threaded_irq(chip->dev.parent, irq, NULL, 891 822 tis_int_handler, IRQF_ONESHOT | flags, ··· 989 918 interrupt = 0; 990 919 991 920 tpm_tis_write32(priv, reg, ~TPM_GLOBAL_INT_ENABLE & interrupt); 921 + flush_work(&priv->free_irq_work); 992 922 993 923 tpm_tis_clkrun_enable(chip, false); 994 924 ··· 1093 1021 chip->timeout_b = msecs_to_jiffies(TIS_TIMEOUT_B_MAX); 1094 1022 chip->timeout_c = msecs_to_jiffies(TIS_TIMEOUT_C_MAX); 1095 1023 chip->timeout_d = msecs_to_jiffies(TIS_TIMEOUT_D_MAX); 1024 + priv->chip = chip; 1096 1025 priv->timeout_min = TPM_TIMEOUT_USECS_MIN; 1097 1026 priv->timeout_max = TPM_TIMEOUT_USECS_MAX; 1098 1027 priv->phy_ops = phy_ops; ··· 1252 1179 rc = tpm_tis_request_locality(chip, 0); 1253 1180 if (rc < 0) 1254 1181 goto out_err; 1255 - disable_interrupts(chip); 1182 + tpm_tis_disable_interrupts(chip); 1256 1183 tpm_tis_relinquish_locality(chip, 0); 1257 1184 } 1258 1185 }
+4
drivers/char/tpm/tpm_tis_core.h
··· 91 91 }; 92 92 93 93 struct tpm_tis_data { 94 + struct tpm_chip *chip; 94 95 u16 manufacturer_id; 95 96 struct mutex locality_count_mutex; 96 97 unsigned int locality_count; 97 98 int locality; 98 99 int irq; 100 + struct work_struct free_irq_work; 101 + unsigned long last_unhandled_irq; 102 + unsigned int unhandled_irqs; 99 103 unsigned int int_mask; 100 104 unsigned long flags; 101 105 void __iomem *ilb_base_addr;
+36 -21
drivers/char/tpm/tpm_tis_i2c.c
··· 189 189 int ret; 190 190 191 191 for (i = 0; i < TPM_RETRY; i++) { 192 - /* write register */ 193 - msg.len = sizeof(reg); 194 - msg.buf = &reg; 195 - msg.flags = 0; 196 - ret = tpm_tis_i2c_retry_transfer_until_ack(data, &msg); 197 - if (ret < 0) 198 - return ret; 192 + u16 read = 0; 199 193 200 - /* read data */ 201 - msg.buf = result; 202 - msg.len = len; 203 - msg.flags = I2C_M_RD; 204 - ret = tpm_tis_i2c_retry_transfer_until_ack(data, &msg); 205 - if (ret < 0) 206 - return ret; 194 + while (read < len) { 195 + /* write register */ 196 + msg.len = sizeof(reg); 197 + msg.buf = &reg; 198 + msg.flags = 0; 199 + ret = tpm_tis_i2c_retry_transfer_until_ack(data, &msg); 200 + if (ret < 0) 201 + return ret; 202 + 203 + /* read data */ 204 + msg.buf = result + read; 205 + msg.len = len - read; 206 + msg.flags = I2C_M_RD; 207 + if (msg.len > I2C_SMBUS_BLOCK_MAX) 208 + msg.len = I2C_SMBUS_BLOCK_MAX; 209 + ret = tpm_tis_i2c_retry_transfer_until_ack(data, &msg); 210 + if (ret < 0) 211 + return ret; 212 + read += msg.len; 213 + } 207 214 208 215 ret = tpm_tis_i2c_sanity_check_read(reg, len, result); 209 216 if (ret == 0) ··· 230 223 struct i2c_msg msg = { .addr = phy->i2c_client->addr }; 231 224 u8 reg = tpm_tis_i2c_address_to_register(addr); 232 225 int ret; 226 + u16 wrote = 0; 233 227 234 228 if (len > TPM_BUFSIZE - 1) 235 229 return -EIO; 236 230 237 - /* write register and data in one go */ 238 231 phy->io_buf[0] = reg; 239 - memcpy(phy->io_buf + sizeof(reg), value, len); 240 - 241 - msg.len = sizeof(reg) + len; 242 232 msg.buf = phy->io_buf; 243 - ret = tpm_tis_i2c_retry_transfer_until_ack(data, &msg); 244 - if (ret < 0) 245 - return ret; 233 + while (wrote < len) { 234 + /* write register and data in one go */ 235 + msg.len = sizeof(reg) + len - wrote; 236 + if (msg.len > I2C_SMBUS_BLOCK_MAX) 237 + msg.len = I2C_SMBUS_BLOCK_MAX; 238 + 239 + memcpy(phy->io_buf + sizeof(reg), value + wrote, 240 + msg.len - sizeof(reg)); 241 + 242 + ret = tpm_tis_i2c_retry_transfer_until_ack(data, &msg); 243 + if (ret < 0) 244 + return ret; 245 + wrote += msg.len - sizeof(reg); 246 + } 246 247 247 248 return 0; 248 249 }
+8
drivers/char/tpm/tpm_tis_spi_main.c
··· 136 136 } 137 137 138 138 exit: 139 + if (ret < 0) { 140 + /* Deactivate chip select */ 141 + memset(&spi_xfer, 0, sizeof(spi_xfer)); 142 + spi_message_init(&m); 143 + spi_message_add_tail(&spi_xfer, &m); 144 + spi_sync_locked(phy->spi_device, &m); 145 + } 146 + 139 147 spi_bus_unlock(phy->spi_device->master); 140 148 return ret; 141 149 }
+7 -23
drivers/char/tpm/tpm_vtpm_proxy.c
··· 683 683 .fops = &vtpmx_fops, 684 684 }; 685 685 686 - static int vtpmx_init(void) 687 - { 688 - return misc_register(&vtpmx_miscdev); 689 - } 690 - 691 - static void vtpmx_cleanup(void) 692 - { 693 - misc_deregister(&vtpmx_miscdev); 694 - } 695 - 696 686 static int __init vtpm_module_init(void) 697 687 { 698 688 int rc; 699 689 700 - rc = vtpmx_init(); 701 - if (rc) { 702 - pr_err("couldn't create vtpmx device\n"); 703 - return rc; 704 - } 705 - 706 690 workqueue = create_workqueue("tpm-vtpm"); 707 691 if (!workqueue) { 708 692 pr_err("couldn't create workqueue\n"); 709 - rc = -ENOMEM; 710 - goto err_vtpmx_cleanup; 693 + return -ENOMEM; 711 694 } 712 695 713 - return 0; 714 - 715 - err_vtpmx_cleanup: 716 - vtpmx_cleanup(); 696 + rc = misc_register(&vtpmx_miscdev); 697 + if (rc) { 698 + pr_err("couldn't create vtpmx device\n"); 699 + destroy_workqueue(workqueue); 700 + } 717 701 718 702 return rc; 719 703 } ··· 705 721 static void __exit vtpm_module_exit(void) 706 722 { 707 723 destroy_workqueue(workqueue); 708 - vtpmx_cleanup(); 724 + misc_deregister(&vtpmx_miscdev); 709 725 } 710 726 711 727 module_init(vtpm_module_init);
+1 -1
drivers/cpufreq/sparc-us2e-cpufreq.c
··· 269 269 return smp_call_function_single(cpu, __us2e_freq_target, &index, 1); 270 270 } 271 271 272 - static int __init us2e_freq_cpu_init(struct cpufreq_policy *policy) 272 + static int us2e_freq_cpu_init(struct cpufreq_policy *policy) 273 273 { 274 274 unsigned int cpu = policy->cpu; 275 275 unsigned long clock_tick = sparc64_get_clock_tick(cpu) / 1000;
+1 -1
drivers/cpufreq/sparc-us3-cpufreq.c
··· 117 117 return smp_call_function_single(cpu, update_safari_cfg, &new_bits, 1); 118 118 } 119 119 120 - static int __init us3_freq_cpu_init(struct cpufreq_policy *policy) 120 + static int us3_freq_cpu_init(struct cpufreq_policy *policy) 121 121 { 122 122 unsigned int cpu = policy->cpu; 123 123 unsigned long clock_tick = sparc64_get_clock_tick(cpu) / 1000;
+22 -4
drivers/dma-buf/dma-fence-unwrap.c
··· 66 66 { 67 67 struct dma_fence_array *result; 68 68 struct dma_fence *tmp, **array; 69 + ktime_t timestamp; 69 70 unsigned int i; 70 71 size_t count; 71 72 72 73 count = 0; 74 + timestamp = ns_to_ktime(0); 73 75 for (i = 0; i < num_fences; ++i) { 74 - dma_fence_unwrap_for_each(tmp, &iter[i], fences[i]) 75 - if (!dma_fence_is_signaled(tmp)) 76 + dma_fence_unwrap_for_each(tmp, &iter[i], fences[i]) { 77 + if (!dma_fence_is_signaled(tmp)) { 76 78 ++count; 79 + } else if (test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, 80 + &tmp->flags)) { 81 + if (ktime_after(tmp->timestamp, timestamp)) 82 + timestamp = tmp->timestamp; 83 + } else { 84 + /* 85 + * Use the current time if the fence is 86 + * currently signaling. 87 + */ 88 + timestamp = ktime_get(); 89 + } 90 + } 77 91 } 78 92 93 + /* 94 + * If we couldn't find a pending fence just return a private signaled 95 + * fence with the timestamp of the last signaled one. 96 + */ 79 97 if (count == 0) 80 - return dma_fence_get_stub(); 98 + return dma_fence_allocate_private_stub(timestamp); 81 99 82 100 array = kmalloc_array(count, sizeof(*array), GFP_KERNEL); 83 101 if (!array) ··· 156 138 } while (tmp); 157 139 158 140 if (count == 0) { 159 - tmp = dma_fence_get_stub(); 141 + tmp = dma_fence_allocate_private_stub(ktime_get()); 160 142 goto return_tmp; 161 143 } 162 144
+4 -3
drivers/dma-buf/dma-fence.c
··· 150 150 151 151 /** 152 152 * dma_fence_allocate_private_stub - return a private, signaled fence 153 + * @timestamp: timestamp when the fence was signaled 153 154 * 154 155 * Return a newly allocated and signaled stub fence. 155 156 */ 156 - struct dma_fence *dma_fence_allocate_private_stub(void) 157 + struct dma_fence *dma_fence_allocate_private_stub(ktime_t timestamp) 157 158 { 158 159 struct dma_fence *fence; 159 160 160 161 fence = kzalloc(sizeof(*fence), GFP_KERNEL); 161 162 if (fence == NULL) 162 - return ERR_PTR(-ENOMEM); 163 + return NULL; 163 164 164 165 dma_fence_init(fence, 165 166 &dma_fence_stub_ops, ··· 170 169 set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT, 171 170 &fence->flags); 172 171 173 - dma_fence_signal(fence); 172 + dma_fence_signal_timestamp(fence, timestamp); 174 173 175 174 return fence; 176 175 }
+1
drivers/gpu/drm/amd/amdgpu/amdgpu.h
··· 1296 1296 void amdgpu_device_pci_config_reset(struct amdgpu_device *adev); 1297 1297 int amdgpu_device_pci_reset(struct amdgpu_device *adev); 1298 1298 bool amdgpu_device_need_post(struct amdgpu_device *adev); 1299 + bool amdgpu_device_pcie_dynamic_switching_supported(void); 1299 1300 bool amdgpu_device_should_use_aspm(struct amdgpu_device *adev); 1300 1301 bool amdgpu_device_aspm_support_quirk(void); 1301 1302
+3
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gpuvm.c
··· 2881 2881 if (!attachment->is_mapped) 2882 2882 continue; 2883 2883 2884 + if (attachment->bo_va->base.bo->tbo.pin_count) 2885 + continue; 2886 + 2884 2887 kfd_mem_dmaunmap_attachment(mem, attachment); 2885 2888 ret = update_gpuvm_pte(mem, attachment, &sync_obj); 2886 2889 if (ret) {
+19
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
··· 1458 1458 return true; 1459 1459 } 1460 1460 1461 + /* 1462 + * Intel hosts such as Raptor Lake and Sapphire Rapids don't support dynamic 1463 + * speed switching. Until we have confirmation from Intel that a specific host 1464 + * supports it, it's safer that we keep it disabled for all. 1465 + * 1466 + * https://edc.intel.com/content/www/us/en/design/products/platforms/details/raptor-lake-s/13th-generation-core-processors-datasheet-volume-1-of-2/005/pci-express-support/ 1467 + * https://gitlab.freedesktop.org/drm/amd/-/issues/2663 1468 + */ 1469 + bool amdgpu_device_pcie_dynamic_switching_supported(void) 1470 + { 1471 + #if IS_ENABLED(CONFIG_X86) 1472 + struct cpuinfo_x86 *c = &cpu_data(0); 1473 + 1474 + if (c->x86_vendor == X86_VENDOR_INTEL) 1475 + return false; 1476 + #endif 1477 + return true; 1478 + } 1479 + 1461 1480 /** 1462 1481 * amdgpu_device_should_use_aspm - check if the device should program ASPM 1463 1482 *
+4
drivers/gpu/drm/amd/pm/swsmu/inc/smu_v13_0.h
··· 295 295 uint32_t *size, 296 296 uint32_t pptable_id); 297 297 298 + int smu_v13_0_update_pcie_parameters(struct smu_context *smu, 299 + uint32_t pcie_gen_cap, 300 + uint32_t pcie_width_cap); 301 + 298 302 #endif 299 303 #endif
+1 -1
drivers/gpu/drm/amd/pm/swsmu/smu11/arcturus_ppt.c
··· 2113 2113 } 2114 2114 mutex_lock(&adev->pm.mutex); 2115 2115 r = smu_cmn_update_table(smu, SMU_TABLE_I2C_COMMANDS, 0, req, true); 2116 - mutex_unlock(&adev->pm.mutex); 2117 2116 if (r) 2118 2117 goto fail; 2119 2118 ··· 2129 2130 } 2130 2131 r = num_msgs; 2131 2132 fail: 2133 + mutex_unlock(&adev->pm.mutex); 2132 2134 kfree(req); 2133 2135 return r; 2134 2136 }
+1 -1
drivers/gpu/drm/amd/pm/swsmu/smu11/navi10_ppt.c
··· 3021 3021 } 3022 3022 mutex_lock(&adev->pm.mutex); 3023 3023 r = smu_cmn_update_table(smu, SMU_TABLE_I2C_COMMANDS, 0, req, true); 3024 - mutex_unlock(&adev->pm.mutex); 3025 3024 if (r) 3026 3025 goto fail; 3027 3026 ··· 3037 3038 } 3038 3039 r = num_msgs; 3039 3040 fail: 3041 + mutex_unlock(&adev->pm.mutex); 3040 3042 kfree(req); 3041 3043 return r; 3042 3044 }
+19 -72
drivers/gpu/drm/amd/pm/swsmu/smu11/sienna_cichlid_ppt.c
··· 2077 2077 return ret; 2078 2078 } 2079 2079 2080 - static void sienna_cichlid_get_override_pcie_settings(struct smu_context *smu, 2081 - uint32_t *gen_speed_override, 2082 - uint32_t *lane_width_override) 2083 - { 2084 - struct amdgpu_device *adev = smu->adev; 2085 - 2086 - *gen_speed_override = 0xff; 2087 - *lane_width_override = 0xff; 2088 - 2089 - switch (adev->pdev->device) { 2090 - case 0x73A0: 2091 - case 0x73A1: 2092 - case 0x73A2: 2093 - case 0x73A3: 2094 - case 0x73AB: 2095 - case 0x73AE: 2096 - /* Bit 7:0: PCIE lane width, 1 to 7 corresponds is x1 to x32 */ 2097 - *lane_width_override = 6; 2098 - break; 2099 - case 0x73E0: 2100 - case 0x73E1: 2101 - case 0x73E3: 2102 - *lane_width_override = 4; 2103 - break; 2104 - case 0x7420: 2105 - case 0x7421: 2106 - case 0x7422: 2107 - case 0x7423: 2108 - case 0x7424: 2109 - *lane_width_override = 3; 2110 - break; 2111 - default: 2112 - break; 2113 - } 2114 - } 2115 - 2116 - #define MAX(a, b) ((a) > (b) ? (a) : (b)) 2117 - 2118 2080 static int sienna_cichlid_update_pcie_parameters(struct smu_context *smu, 2119 2081 uint32_t pcie_gen_cap, 2120 2082 uint32_t pcie_width_cap) 2121 2083 { 2122 2084 struct smu_11_0_dpm_context *dpm_context = smu->smu_dpm.dpm_context; 2123 2085 struct smu_11_0_pcie_table *pcie_table = &dpm_context->dpm_tables.pcie_table; 2124 - uint32_t gen_speed_override, lane_width_override; 2125 - uint8_t *table_member1, *table_member2; 2126 - uint32_t min_gen_speed, max_gen_speed; 2127 - uint32_t min_lane_width, max_lane_width; 2128 - uint32_t smu_pcie_arg; 2086 + u32 smu_pcie_arg; 2129 2087 int ret, i; 2130 2088 2131 - GET_PPTABLE_MEMBER(PcieGenSpeed, &table_member1); 2132 - GET_PPTABLE_MEMBER(PcieLaneCount, &table_member2); 2089 + /* PCIE gen speed and lane width override */ 2090 + if (!amdgpu_device_pcie_dynamic_switching_supported()) { 2091 + if (pcie_table->pcie_gen[NUM_LINK_LEVELS - 1] < pcie_gen_cap) 2092 + pcie_gen_cap = pcie_table->pcie_gen[NUM_LINK_LEVELS - 1]; 2133 2093 2134 - sienna_cichlid_get_override_pcie_settings(smu, 2135 - &gen_speed_override, 2136 - &lane_width_override); 2094 + if (pcie_table->pcie_lane[NUM_LINK_LEVELS - 1] < pcie_width_cap) 2095 + pcie_width_cap = pcie_table->pcie_lane[NUM_LINK_LEVELS - 1]; 2137 2096 2138 - /* PCIE gen speed override */ 2139 - if (gen_speed_override != 0xff) { 2140 - min_gen_speed = MIN(pcie_gen_cap, gen_speed_override); 2141 - max_gen_speed = MIN(pcie_gen_cap, gen_speed_override); 2097 + /* Force all levels to use the same settings */ 2098 + for (i = 0; i < NUM_LINK_LEVELS; i++) { 2099 + pcie_table->pcie_gen[i] = pcie_gen_cap; 2100 + pcie_table->pcie_lane[i] = pcie_width_cap; 2101 + } 2142 2102 } else { 2143 - min_gen_speed = MAX(0, table_member1[0]); 2144 - max_gen_speed = MIN(pcie_gen_cap, table_member1[1]); 2145 - min_gen_speed = min_gen_speed > max_gen_speed ? 2146 - max_gen_speed : min_gen_speed; 2103 + for (i = 0; i < NUM_LINK_LEVELS; i++) { 2104 + if (pcie_table->pcie_gen[i] > pcie_gen_cap) 2105 + pcie_table->pcie_gen[i] = pcie_gen_cap; 2106 + if (pcie_table->pcie_lane[i] > pcie_width_cap) 2107 + pcie_table->pcie_lane[i] = pcie_width_cap; 2108 + } 2147 2109 } 2148 - pcie_table->pcie_gen[0] = min_gen_speed; 2149 - pcie_table->pcie_gen[1] = max_gen_speed; 2150 - 2151 - /* PCIE lane width override */ 2152 - if (lane_width_override != 0xff) { 2153 - min_lane_width = MIN(pcie_width_cap, lane_width_override); 2154 - max_lane_width = MIN(pcie_width_cap, lane_width_override); 2155 - } else { 2156 - min_lane_width = MAX(1, table_member2[0]); 2157 - max_lane_width = MIN(pcie_width_cap, table_member2[1]); 2158 - min_lane_width = min_lane_width > max_lane_width ? 2159 - max_lane_width : min_lane_width; 2160 - } 2161 - pcie_table->pcie_lane[0] = min_lane_width; 2162 - pcie_table->pcie_lane[1] = max_lane_width; 2163 2110 2164 2111 for (i = 0; i < NUM_LINK_LEVELS; i++) { 2165 2112 smu_pcie_arg = (i << 16 | ··· 3789 3842 } 3790 3843 mutex_lock(&adev->pm.mutex); 3791 3844 r = smu_cmn_update_table(smu, SMU_TABLE_I2C_COMMANDS, 0, req, true); 3792 - mutex_unlock(&adev->pm.mutex); 3793 3845 if (r) 3794 3846 goto fail; 3795 3847 ··· 3805 3859 } 3806 3860 r = num_msgs; 3807 3861 fail: 3862 + mutex_unlock(&adev->pm.mutex); 3808 3863 kfree(req); 3809 3864 return r; 3810 3865 }
+1 -1
drivers/gpu/drm/amd/pm/swsmu/smu13/aldebaran_ppt.c
··· 1525 1525 } 1526 1526 mutex_lock(&adev->pm.mutex); 1527 1527 r = smu_cmn_update_table(smu, SMU_TABLE_I2C_COMMANDS, 0, req, true); 1528 - mutex_unlock(&adev->pm.mutex); 1529 1528 if (r) 1530 1529 goto fail; 1531 1530 ··· 1541 1542 } 1542 1543 r = num_msgs; 1543 1544 fail: 1545 + mutex_unlock(&adev->pm.mutex); 1544 1546 kfree(req); 1545 1547 return r; 1546 1548 }
+48
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0.c
··· 2424 2424 2425 2425 return ret; 2426 2426 } 2427 + 2428 + int smu_v13_0_update_pcie_parameters(struct smu_context *smu, 2429 + uint32_t pcie_gen_cap, 2430 + uint32_t pcie_width_cap) 2431 + { 2432 + struct smu_13_0_dpm_context *dpm_context = smu->smu_dpm.dpm_context; 2433 + struct smu_13_0_pcie_table *pcie_table = 2434 + &dpm_context->dpm_tables.pcie_table; 2435 + int num_of_levels = pcie_table->num_of_link_levels; 2436 + uint32_t smu_pcie_arg; 2437 + int ret, i; 2438 + 2439 + if (!amdgpu_device_pcie_dynamic_switching_supported()) { 2440 + if (pcie_table->pcie_gen[num_of_levels - 1] < pcie_gen_cap) 2441 + pcie_gen_cap = pcie_table->pcie_gen[num_of_levels - 1]; 2442 + 2443 + if (pcie_table->pcie_lane[num_of_levels - 1] < pcie_width_cap) 2444 + pcie_width_cap = pcie_table->pcie_lane[num_of_levels - 1]; 2445 + 2446 + /* Force all levels to use the same settings */ 2447 + for (i = 0; i < num_of_levels; i++) { 2448 + pcie_table->pcie_gen[i] = pcie_gen_cap; 2449 + pcie_table->pcie_lane[i] = pcie_width_cap; 2450 + } 2451 + } else { 2452 + for (i = 0; i < num_of_levels; i++) { 2453 + if (pcie_table->pcie_gen[i] > pcie_gen_cap) 2454 + pcie_table->pcie_gen[i] = pcie_gen_cap; 2455 + if (pcie_table->pcie_lane[i] > pcie_width_cap) 2456 + pcie_table->pcie_lane[i] = pcie_width_cap; 2457 + } 2458 + } 2459 + 2460 + for (i = 0; i < num_of_levels; i++) { 2461 + smu_pcie_arg = i << 16; 2462 + smu_pcie_arg |= pcie_table->pcie_gen[i] << 8; 2463 + smu_pcie_arg |= pcie_table->pcie_lane[i]; 2464 + 2465 + ret = smu_cmn_send_smc_msg_with_param(smu, 2466 + SMU_MSG_OverridePcieParameters, 2467 + smu_pcie_arg, 2468 + NULL); 2469 + if (ret) 2470 + return ret; 2471 + } 2472 + 2473 + return 0; 2474 + }
+2 -33
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_0_ppt.c
··· 1645 1645 return ret; 1646 1646 } 1647 1647 1648 - static int smu_v13_0_0_update_pcie_parameters(struct smu_context *smu, 1649 - uint32_t pcie_gen_cap, 1650 - uint32_t pcie_width_cap) 1651 - { 1652 - struct smu_13_0_dpm_context *dpm_context = smu->smu_dpm.dpm_context; 1653 - struct smu_13_0_pcie_table *pcie_table = 1654 - &dpm_context->dpm_tables.pcie_table; 1655 - uint32_t smu_pcie_arg; 1656 - int ret, i; 1657 - 1658 - for (i = 0; i < pcie_table->num_of_link_levels; i++) { 1659 - if (pcie_table->pcie_gen[i] > pcie_gen_cap) 1660 - pcie_table->pcie_gen[i] = pcie_gen_cap; 1661 - if (pcie_table->pcie_lane[i] > pcie_width_cap) 1662 - pcie_table->pcie_lane[i] = pcie_width_cap; 1663 - 1664 - smu_pcie_arg = i << 16; 1665 - smu_pcie_arg |= pcie_table->pcie_gen[i] << 8; 1666 - smu_pcie_arg |= pcie_table->pcie_lane[i]; 1667 - 1668 - ret = smu_cmn_send_smc_msg_with_param(smu, 1669 - SMU_MSG_OverridePcieParameters, 1670 - smu_pcie_arg, 1671 - NULL); 1672 - if (ret) 1673 - return ret; 1674 - } 1675 - 1676 - return 0; 1677 - } 1678 - 1679 1648 static const struct smu_temperature_range smu13_thermal_policy[] = { 1680 1649 {-273150, 99000, 99000, -273150, 99000, 99000, -273150, 99000, 99000}, 1681 1650 { 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000, 120000}, ··· 2289 2320 } 2290 2321 mutex_lock(&adev->pm.mutex); 2291 2322 r = smu_cmn_update_table(smu, SMU_TABLE_I2C_COMMANDS, 0, req, true); 2292 - mutex_unlock(&adev->pm.mutex); 2293 2323 if (r) 2294 2324 goto fail; 2295 2325 ··· 2305 2337 } 2306 2338 r = num_msgs; 2307 2339 fail: 2340 + mutex_unlock(&adev->pm.mutex); 2308 2341 kfree(req); 2309 2342 return r; 2310 2343 } ··· 2623 2654 .feature_is_enabled = smu_cmn_feature_is_enabled, 2624 2655 .print_clk_levels = smu_v13_0_0_print_clk_levels, 2625 2656 .force_clk_levels = smu_v13_0_0_force_clk_levels, 2626 - .update_pcie_parameters = smu_v13_0_0_update_pcie_parameters, 2657 + .update_pcie_parameters = smu_v13_0_update_pcie_parameters, 2627 2658 .get_thermal_temperature_range = smu_v13_0_0_get_thermal_temperature_range, 2628 2659 .register_irq_handler = smu_v13_0_register_irq_handler, 2629 2660 .enable_thermal_alert = smu_v13_0_enable_thermal_alert,
+1 -1
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_6_ppt.c
··· 1763 1763 } 1764 1764 mutex_lock(&adev->pm.mutex); 1765 1765 r = smu_v13_0_6_request_i2c_xfer(smu, req); 1766 - mutex_unlock(&adev->pm.mutex); 1767 1766 if (r) 1768 1767 goto fail; 1769 1768 ··· 1779 1780 } 1780 1781 r = num_msgs; 1781 1782 fail: 1783 + mutex_unlock(&adev->pm.mutex); 1782 1784 kfree(req); 1783 1785 return r; 1784 1786 }
+1 -32
drivers/gpu/drm/amd/pm/swsmu/smu13/smu_v13_0_7_ppt.c
··· 1635 1635 return ret; 1636 1636 } 1637 1637 1638 - static int smu_v13_0_7_update_pcie_parameters(struct smu_context *smu, 1639 - uint32_t pcie_gen_cap, 1640 - uint32_t pcie_width_cap) 1641 - { 1642 - struct smu_13_0_dpm_context *dpm_context = smu->smu_dpm.dpm_context; 1643 - struct smu_13_0_pcie_table *pcie_table = 1644 - &dpm_context->dpm_tables.pcie_table; 1645 - uint32_t smu_pcie_arg; 1646 - int ret, i; 1647 - 1648 - for (i = 0; i < pcie_table->num_of_link_levels; i++) { 1649 - if (pcie_table->pcie_gen[i] > pcie_gen_cap) 1650 - pcie_table->pcie_gen[i] = pcie_gen_cap; 1651 - if (pcie_table->pcie_lane[i] > pcie_width_cap) 1652 - pcie_table->pcie_lane[i] = pcie_width_cap; 1653 - 1654 - smu_pcie_arg = i << 16; 1655 - smu_pcie_arg |= pcie_table->pcie_gen[i] << 8; 1656 - smu_pcie_arg |= pcie_table->pcie_lane[i]; 1657 - 1658 - ret = smu_cmn_send_smc_msg_with_param(smu, 1659 - SMU_MSG_OverridePcieParameters, 1660 - smu_pcie_arg, 1661 - NULL); 1662 - if (ret) 1663 - return ret; 1664 - } 1665 - 1666 - return 0; 1667 - } 1668 - 1669 1638 static const struct smu_temperature_range smu13_thermal_policy[] = 1670 1639 { 1671 1640 {-273150, 99000, 99000, -273150, 99000, 99000, -273150, 99000, 99000}, ··· 2203 2234 .feature_is_enabled = smu_cmn_feature_is_enabled, 2204 2235 .print_clk_levels = smu_v13_0_7_print_clk_levels, 2205 2236 .force_clk_levels = smu_v13_0_7_force_clk_levels, 2206 - .update_pcie_parameters = smu_v13_0_7_update_pcie_parameters, 2237 + .update_pcie_parameters = smu_v13_0_update_pcie_parameters, 2207 2238 .get_thermal_temperature_range = smu_v13_0_7_get_thermal_temperature_range, 2208 2239 .register_irq_handler = smu_v13_0_register_irq_handler, 2209 2240 .enable_thermal_alert = smu_v13_0_enable_thermal_alert,
-4
drivers/gpu/drm/armada/armada_fbdev.c
··· 209 209 goto err_drm_client_init; 210 210 } 211 211 212 - ret = armada_fbdev_client_hotplug(&fbh->client); 213 - if (ret) 214 - drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); 215 - 216 212 drm_client_register(&fbh->client); 217 213 218 214 return;
+5 -4
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
··· 1426 1426 /* Control for TMDS Bit Period/TMDS Clock-Period Ratio */ 1427 1427 if (dw_hdmi_support_scdc(hdmi, display)) { 1428 1428 if (mtmdsclock > HDMI14_MAX_TMDSCLK) 1429 - drm_scdc_set_high_tmds_clock_ratio(&hdmi->connector, 1); 1429 + drm_scdc_set_high_tmds_clock_ratio(hdmi->curr_conn, 1); 1430 1430 else 1431 - drm_scdc_set_high_tmds_clock_ratio(&hdmi->connector, 0); 1431 + drm_scdc_set_high_tmds_clock_ratio(hdmi->curr_conn, 0); 1432 1432 } 1433 1433 } 1434 1434 EXPORT_SYMBOL_GPL(dw_hdmi_set_high_tmds_clock_ratio); ··· 2116 2116 min_t(u8, bytes, SCDC_MIN_SOURCE_VERSION)); 2117 2117 2118 2118 /* Enabled Scrambling in the Sink */ 2119 - drm_scdc_set_scrambling(&hdmi->connector, 1); 2119 + drm_scdc_set_scrambling(hdmi->curr_conn, 1); 2120 2120 2121 2121 /* 2122 2122 * To activate the scrambler feature, you must ensure ··· 2132 2132 hdmi_writeb(hdmi, 0, HDMI_FC_SCRAMBLER_CTRL); 2133 2133 hdmi_writeb(hdmi, (u8)~HDMI_MC_SWRSTZ_TMDSSWRST_REQ, 2134 2134 HDMI_MC_SWRSTZ); 2135 - drm_scdc_set_scrambling(&hdmi->connector, 0); 2135 + drm_scdc_set_scrambling(hdmi->curr_conn, 0); 2136 2136 } 2137 2137 } 2138 2138 ··· 3553 3553 hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT | DRM_BRIDGE_OP_EDID 3554 3554 | DRM_BRIDGE_OP_HPD; 3555 3555 hdmi->bridge.interlace_allowed = true; 3556 + hdmi->bridge.ddc = hdmi->ddc; 3556 3557 #ifdef CONFIG_OF 3557 3558 hdmi->bridge.of_node = pdev->dev.of_node; 3558 3559 #endif
+22 -13
drivers/gpu/drm/bridge/ti-sn65dsi86.c
··· 170 170 * @pwm_refclk_freq: Cache for the reference clock input to the PWM. 171 171 */ 172 172 struct ti_sn65dsi86 { 173 - struct auxiliary_device bridge_aux; 174 - struct auxiliary_device gpio_aux; 175 - struct auxiliary_device aux_aux; 176 - struct auxiliary_device pwm_aux; 173 + struct auxiliary_device *bridge_aux; 174 + struct auxiliary_device *gpio_aux; 175 + struct auxiliary_device *aux_aux; 176 + struct auxiliary_device *pwm_aux; 177 177 178 178 struct device *dev; 179 179 struct regmap *regmap; ··· 468 468 auxiliary_device_delete(data); 469 469 } 470 470 471 - /* 472 - * AUX bus docs say that a non-NULL release is mandatory, but it makes no 473 - * sense for the model used here where all of the aux devices are allocated 474 - * in the single shared structure. We'll use this noop as a workaround. 475 - */ 476 - static void ti_sn65dsi86_noop(struct device *dev) {} 471 + static void ti_sn65dsi86_aux_device_release(struct device *dev) 472 + { 473 + struct auxiliary_device *aux = container_of(dev, struct auxiliary_device, dev); 474 + 475 + kfree(aux); 476 + } 477 477 478 478 static int ti_sn65dsi86_add_aux_device(struct ti_sn65dsi86 *pdata, 479 - struct auxiliary_device *aux, 479 + struct auxiliary_device **aux_out, 480 480 const char *name) 481 481 { 482 482 struct device *dev = pdata->dev; 483 + struct auxiliary_device *aux; 483 484 int ret; 485 + 486 + aux = kzalloc(sizeof(*aux), GFP_KERNEL); 487 + if (!aux) 488 + return -ENOMEM; 484 489 485 490 aux->name = name; 486 491 aux->dev.parent = dev; 487 - aux->dev.release = ti_sn65dsi86_noop; 492 + aux->dev.release = ti_sn65dsi86_aux_device_release; 488 493 device_set_of_node_from_dev(&aux->dev, dev); 489 494 ret = auxiliary_device_init(aux); 490 - if (ret) 495 + if (ret) { 496 + kfree(aux); 491 497 return ret; 498 + } 492 499 ret = devm_add_action_or_reset(dev, ti_sn65dsi86_uninit_aux, aux); 493 500 if (ret) 494 501 return ret; ··· 504 497 if (ret) 505 498 return ret; 506 499 ret = devm_add_action_or_reset(dev, ti_sn65dsi86_delete_aux, aux); 500 + if (!ret) 501 + *aux_out = aux; 507 502 508 503 return ret; 509 504 }
+21
drivers/gpu/drm/drm_client.c
··· 122 122 * drm_client_register() it is no longer permissible to call drm_client_release() 123 123 * directly (outside the unregister callback), instead cleanup will happen 124 124 * automatically on driver unload. 125 + * 126 + * Registering a client generates a hotplug event that allows the client 127 + * to set up its display from pre-existing outputs. The client must have 128 + * initialized its state to able to handle the hotplug event successfully. 125 129 */ 126 130 void drm_client_register(struct drm_client_dev *client) 127 131 { 128 132 struct drm_device *dev = client->dev; 133 + int ret; 129 134 130 135 mutex_lock(&dev->clientlist_mutex); 131 136 list_add(&client->list, &dev->clientlist); 137 + 138 + if (client->funcs && client->funcs->hotplug) { 139 + /* 140 + * Perform an initial hotplug event to pick up the 141 + * display configuration for the client. This step 142 + * has to be performed *after* registering the client 143 + * in the list of clients, or a concurrent hotplug 144 + * event might be lost; leaving the display off. 145 + * 146 + * Hold the clientlist_mutex as for a regular hotplug 147 + * event. 148 + */ 149 + ret = client->funcs->hotplug(client); 150 + if (ret) 151 + drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); 152 + } 132 153 mutex_unlock(&dev->clientlist_mutex); 133 154 } 134 155 EXPORT_SYMBOL(drm_client_register);
+1 -5
drivers/gpu/drm/drm_fbdev_dma.c
··· 217 217 * drm_fbdev_dma_setup() - Setup fbdev emulation for GEM DMA helpers 218 218 * @dev: DRM device 219 219 * @preferred_bpp: Preferred bits per pixel for the device. 220 - * @dev->mode_config.preferred_depth is used if this is zero. 220 + * 32 is used if this is zero. 221 221 * 222 222 * This function sets up fbdev emulation for GEM DMA drivers that support 223 223 * dumb buffers with a virtual address and that can be mmap'ed. ··· 251 251 drm_err(dev, "Failed to register client: %d\n", ret); 252 252 goto err_drm_client_init; 253 253 } 254 - 255 - ret = drm_fbdev_dma_client_hotplug(&fb_helper->client); 256 - if (ret) 257 - drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); 258 254 259 255 drm_client_register(&fb_helper->client); 260 256
-4
drivers/gpu/drm/drm_fbdev_generic.c
··· 339 339 goto err_drm_client_init; 340 340 } 341 341 342 - ret = drm_fbdev_generic_client_hotplug(&fb_helper->client); 343 - if (ret) 344 - drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); 345 - 346 342 drm_client_register(&fb_helper->client); 347 343 348 344 return;
+3 -3
drivers/gpu/drm/drm_syncobj.c
··· 353 353 */ 354 354 static int drm_syncobj_assign_null_handle(struct drm_syncobj *syncobj) 355 355 { 356 - struct dma_fence *fence = dma_fence_allocate_private_stub(); 356 + struct dma_fence *fence = dma_fence_allocate_private_stub(ktime_get()); 357 357 358 - if (IS_ERR(fence)) 359 - return PTR_ERR(fence); 358 + if (!fence) 359 + return -ENOMEM; 360 360 361 361 drm_syncobj_replace_fence(syncobj, fence); 362 362 dma_fence_put(fence);
-4
drivers/gpu/drm/exynos/exynos_drm_fbdev.c
··· 215 215 if (ret) 216 216 goto err_drm_client_init; 217 217 218 - ret = exynos_drm_fbdev_client_hotplug(&fb_helper->client); 219 - if (ret) 220 - drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); 221 - 222 218 drm_client_register(&fb_helper->client); 223 219 224 220 return;
-4
drivers/gpu/drm/gma500/fbdev.c
··· 328 328 goto err_drm_fb_helper_unprepare; 329 329 } 330 330 331 - ret = psb_fbdev_client_hotplug(&fb_helper->client); 332 - if (ret) 333 - drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); 334 - 335 331 drm_client_register(&fb_helper->client); 336 332 337 333 return;
-1
drivers/gpu/drm/i915/display/intel_display.c
··· 4564 4564 saved_state->uapi = slave_crtc_state->uapi; 4565 4565 saved_state->scaler_state = slave_crtc_state->scaler_state; 4566 4566 saved_state->shared_dpll = slave_crtc_state->shared_dpll; 4567 - saved_state->dpll_hw_state = slave_crtc_state->dpll_hw_state; 4568 4567 saved_state->crc_enabled = slave_crtc_state->crc_enabled; 4569 4568 4570 4569 intel_crtc_free_hw_state(slave_crtc_state);
-3
drivers/gpu/drm/i915/gt/gen8_ppgtt.c
··· 37 37 if (unlikely(flags & PTE_READ_ONLY)) 38 38 pte &= ~GEN8_PAGE_RW; 39 39 40 - if (flags & PTE_LM) 41 - pte |= GEN12_PPGTT_PTE_LM; 42 - 43 40 /* 44 41 * For pre-gen12 platforms pat_index is the same as enum 45 42 * i915_cache_level, so the switch-case here is still valid.
+1 -1
drivers/gpu/drm/i915/gt/intel_gtt.c
··· 670 670 if (IS_ERR(obj)) 671 671 return ERR_CAST(obj); 672 672 673 - i915_gem_object_set_cache_coherency(obj, I915_CACHING_CACHED); 673 + i915_gem_object_set_cache_coherency(obj, I915_CACHE_LLC); 674 674 675 675 vma = i915_vma_instance(obj, vm, NULL); 676 676 if (IS_ERR(vma)) {
+10 -1
drivers/gpu/drm/i915/i915_perf.c
··· 868 868 oa_report_id_clear(stream, report32); 869 869 oa_timestamp_clear(stream, report32); 870 870 } else { 871 + u8 *oa_buf_end = stream->oa_buffer.vaddr + 872 + OA_BUFFER_SIZE; 873 + u32 part = oa_buf_end - (u8 *)report32; 874 + 871 875 /* Zero out the entire report */ 872 - memset(report32, 0, report_size); 876 + if (report_size <= part) { 877 + memset(report32, 0, report_size); 878 + } else { 879 + memset(report32, 0, part); 880 + memset(oa_buf_base, 0, report_size - part); 881 + } 873 882 } 874 883 } 875 884
-4
drivers/gpu/drm/msm/msm_fbdev.c
··· 246 246 goto err_drm_fb_helper_unprepare; 247 247 } 248 248 249 - ret = msm_fbdev_client_hotplug(&helper->client); 250 - if (ret) 251 - drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); 252 - 253 249 drm_client_register(&helper->client); 254 250 255 251 return;
+6 -2
drivers/gpu/drm/nouveau/dispnv50/disp.c
··· 910 910 struct nouveau_drm *drm = nouveau_drm(msto->encoder.dev); 911 911 struct nv50_mstc *mstc = msto->mstc; 912 912 struct nv50_mstm *mstm = mstc->mstm; 913 - struct drm_dp_mst_atomic_payload *payload; 913 + struct drm_dp_mst_topology_state *old_mst_state; 914 + struct drm_dp_mst_atomic_payload *payload, *old_payload; 914 915 915 916 NV_ATOMIC(drm, "%s: msto prepare\n", msto->encoder.name); 916 917 918 + old_mst_state = drm_atomic_get_old_mst_topology_state(state, mgr); 919 + 917 920 payload = drm_atomic_get_mst_payload_state(mst_state, mstc->port); 921 + old_payload = drm_atomic_get_mst_payload_state(old_mst_state, mstc->port); 918 922 919 923 // TODO: Figure out if we want to do a better job of handling VCPI allocation failures here? 920 924 if (msto->disabled) { 921 - drm_dp_remove_payload(mgr, mst_state, payload, payload); 925 + drm_dp_remove_payload(mgr, mst_state, old_payload, payload); 922 926 923 927 nvif_outp_dp_mst_vcpi(&mstm->outp->outp, msto->head->base.index, 0, 0, 0, 0); 924 928 } else {
+1
drivers/gpu/drm/nouveau/nouveau_chan.c
··· 90 90 if (cli) 91 91 nouveau_svmm_part(chan->vmm->svmm, chan->inst); 92 92 93 + nvif_object_dtor(&chan->blit); 93 94 nvif_object_dtor(&chan->nvsw); 94 95 nvif_object_dtor(&chan->gart); 95 96 nvif_object_dtor(&chan->vram);
+1
drivers/gpu/drm/nouveau/nouveau_chan.h
··· 53 53 u32 user_put; 54 54 55 55 struct nvif_object user; 56 + struct nvif_object blit; 56 57 57 58 struct nvif_event kill; 58 59 atomic_t killed;
+17 -3
drivers/gpu/drm/nouveau/nouveau_drm.c
··· 375 375 ret = nvif_object_ctor(&drm->channel->user, "drmNvsw", 376 376 NVDRM_NVSW, nouveau_abi16_swclass(drm), 377 377 NULL, 0, &drm->channel->nvsw); 378 + 379 + if (ret == 0 && device->info.chipset >= 0x11) { 380 + ret = nvif_object_ctor(&drm->channel->user, "drmBlit", 381 + 0x005f, 0x009f, 382 + NULL, 0, &drm->channel->blit); 383 + } 384 + 378 385 if (ret == 0) { 379 386 struct nvif_push *push = drm->channel->chan.push; 380 - ret = PUSH_WAIT(push, 2); 381 - if (ret == 0) 387 + ret = PUSH_WAIT(push, 8); 388 + if (ret == 0) { 389 + if (device->info.chipset >= 0x11) { 390 + PUSH_NVSQ(push, NV05F, 0x0000, drm->channel->blit.handle); 391 + PUSH_NVSQ(push, NV09F, 0x0120, 0, 392 + 0x0124, 1, 393 + 0x0128, 2); 394 + } 382 395 PUSH_NVSQ(push, NV_SW, 0x0000, drm->channel->nvsw.handle); 396 + } 383 397 } 384 398 385 399 if (ret) { 386 - NV_ERROR(drm, "failed to allocate sw class, %d\n", ret); 400 + NV_ERROR(drm, "failed to allocate sw or blit class, %d\n", ret); 387 401 nouveau_accel_gr_fini(drm); 388 402 return; 389 403 }
+1
drivers/gpu/drm/nouveau/nvkm/engine/disp/g94.c
··· 295 295 .clock = nv50_sor_clock, 296 296 .war_2 = g94_sor_war_2, 297 297 .war_3 = g94_sor_war_3, 298 + .hdmi = &g84_sor_hdmi, 298 299 .dp = &g94_sor_dp, 299 300 }; 300 301
+1 -1
drivers/gpu/drm/nouveau/nvkm/engine/disp/gt215.c
··· 125 125 pack_hdmi_infoframe(&avi, data, size); 126 126 127 127 nvkm_mask(device, 0x61c520 + soff, 0x00000001, 0x00000000); 128 - if (size) 128 + if (!size) 129 129 return; 130 130 131 131 nvkm_wr32(device, 0x61c528 + soff, avi.header);
+1 -1
drivers/gpu/drm/nouveau/nvkm/subdev/acr/base.c
··· 224 224 u64 falcons; 225 225 int ret, i; 226 226 227 - if (list_empty(&acr->hsfw)) { 227 + if (list_empty(&acr->hsfw) || !acr->func || !acr->func->wpr_layout) { 228 228 nvkm_debug(subdev, "No HSFW(s)\n"); 229 229 nvkm_acr_cleanup(acr); 230 230 return 0;
-4
drivers/gpu/drm/omapdrm/omap_fbdev.c
··· 318 318 319 319 INIT_WORK(&fbdev->work, pan_worker); 320 320 321 - ret = omap_fbdev_client_hotplug(&helper->client); 322 - if (ret) 323 - drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); 324 - 325 321 drm_client_register(&helper->client); 326 322 327 323 return;
+2
drivers/gpu/drm/panel/panel-simple.c
··· 2178 2178 .height = 54, 2179 2179 }, 2180 2180 .bus_format = MEDIA_BUS_FMT_RGB888_1X24, 2181 + .connector_type = DRM_MODE_CONNECTOR_DPI, 2181 2182 .bus_flags = DRM_BUS_FLAG_DE_HIGH | DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE, 2182 2183 }; 2183 2184 ··· 3203 3202 .vsync_start = 480 + 49, 3204 3203 .vsync_end = 480 + 49 + 2, 3205 3204 .vtotal = 480 + 49 + 2 + 22, 3205 + .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC, 3206 3206 }; 3207 3207 3208 3208 static const struct panel_desc powertip_ph800480t013_idf02 = {
-4
drivers/gpu/drm/radeon/radeon_fbdev.c
··· 383 383 goto err_drm_client_init; 384 384 } 385 385 386 - ret = radeon_fbdev_client_hotplug(&fb_helper->client); 387 - if (ret) 388 - drm_dbg_kms(rdev->ddev, "client hotplug ret=%d\n", ret); 389 - 390 386 drm_client_register(&fb_helper->client); 391 387 392 388 return;
+33 -8
drivers/gpu/drm/scheduler/sched_entity.c
··· 176 176 { 177 177 struct drm_sched_job *job = container_of(cb, struct drm_sched_job, 178 178 finish_cb); 179 - int r; 179 + unsigned long index; 180 180 181 181 dma_fence_put(f); 182 182 183 183 /* Wait for all dependencies to avoid data corruptions */ 184 - while (!xa_empty(&job->dependencies)) { 185 - f = xa_erase(&job->dependencies, job->last_dependency++); 186 - r = dma_fence_add_callback(f, &job->finish_cb, 187 - drm_sched_entity_kill_jobs_cb); 188 - if (!r) 184 + xa_for_each(&job->dependencies, index, f) { 185 + struct drm_sched_fence *s_fence = to_drm_sched_fence(f); 186 + 187 + if (s_fence && f == &s_fence->scheduled) { 188 + /* The dependencies array had a reference on the scheduled 189 + * fence, and the finished fence refcount might have 190 + * dropped to zero. Use dma_fence_get_rcu() so we get 191 + * a NULL fence in that case. 192 + */ 193 + f = dma_fence_get_rcu(&s_fence->finished); 194 + 195 + /* Now that we have a reference on the finished fence, 196 + * we can release the reference the dependencies array 197 + * had on the scheduled fence. 198 + */ 199 + dma_fence_put(&s_fence->scheduled); 200 + } 201 + 202 + xa_erase(&job->dependencies, index); 203 + if (f && !dma_fence_add_callback(f, &job->finish_cb, 204 + drm_sched_entity_kill_jobs_cb)) 189 205 return; 190 206 191 207 dma_fence_put(f); ··· 431 415 drm_sched_job_dependency(struct drm_sched_job *job, 432 416 struct drm_sched_entity *entity) 433 417 { 434 - if (!xa_empty(&job->dependencies)) 435 - return xa_erase(&job->dependencies, job->last_dependency++); 418 + struct dma_fence *f; 419 + 420 + /* We keep the fence around, so we can iterate over all dependencies 421 + * in drm_sched_entity_kill_jobs_cb() to ensure all deps are signaled 422 + * before killing the job. 423 + */ 424 + f = xa_load(&job->dependencies, job->last_dependency); 425 + if (f) { 426 + job->last_dependency++; 427 + return dma_fence_get(f); 428 + } 436 429 437 430 if (job->sched->ops->prepare_job) 438 431 return job->sched->ops->prepare_job(job, entity);
+25 -15
drivers/gpu/drm/scheduler/sched_fence.c
··· 48 48 kmem_cache_destroy(sched_fence_slab); 49 49 } 50 50 51 - void drm_sched_fence_scheduled(struct drm_sched_fence *fence) 51 + static void drm_sched_fence_set_parent(struct drm_sched_fence *s_fence, 52 + struct dma_fence *fence) 52 53 { 54 + /* 55 + * smp_store_release() to ensure another thread racing us 56 + * in drm_sched_fence_set_deadline_finished() sees the 57 + * fence's parent set before test_bit() 58 + */ 59 + smp_store_release(&s_fence->parent, dma_fence_get(fence)); 60 + if (test_bit(DRM_SCHED_FENCE_FLAG_HAS_DEADLINE_BIT, 61 + &s_fence->finished.flags)) 62 + dma_fence_set_deadline(fence, s_fence->deadline); 63 + } 64 + 65 + void drm_sched_fence_scheduled(struct drm_sched_fence *fence, 66 + struct dma_fence *parent) 67 + { 68 + /* Set the parent before signaling the scheduled fence, such that, 69 + * any waiter expecting the parent to be filled after the job has 70 + * been scheduled (which is the case for drivers delegating waits 71 + * to some firmware) doesn't have to busy wait for parent to show 72 + * up. 73 + */ 74 + if (!IS_ERR_OR_NULL(parent)) 75 + drm_sched_fence_set_parent(fence, parent); 76 + 53 77 dma_fence_signal(&fence->scheduled); 54 78 } 55 79 ··· 204 180 return NULL; 205 181 } 206 182 EXPORT_SYMBOL(to_drm_sched_fence); 207 - 208 - void drm_sched_fence_set_parent(struct drm_sched_fence *s_fence, 209 - struct dma_fence *fence) 210 - { 211 - /* 212 - * smp_store_release() to ensure another thread racing us 213 - * in drm_sched_fence_set_deadline_finished() sees the 214 - * fence's parent set before test_bit() 215 - */ 216 - smp_store_release(&s_fence->parent, dma_fence_get(fence)); 217 - if (test_bit(DRM_SCHED_FENCE_FLAG_HAS_DEADLINE_BIT, 218 - &s_fence->finished.flags)) 219 - dma_fence_set_deadline(fence, s_fence->deadline); 220 - } 221 183 222 184 struct drm_sched_fence *drm_sched_fence_alloc(struct drm_sched_entity *entity, 223 185 void *owner)
+1 -2
drivers/gpu/drm/scheduler/sched_main.c
··· 1043 1043 trace_drm_run_job(sched_job, entity); 1044 1044 fence = sched->ops->run_job(sched_job); 1045 1045 complete_all(&entity->entity_idle); 1046 - drm_sched_fence_scheduled(s_fence); 1046 + drm_sched_fence_scheduled(s_fence, fence); 1047 1047 1048 1048 if (!IS_ERR_OR_NULL(fence)) { 1049 - drm_sched_fence_set_parent(s_fence, fence); 1050 1049 /* Drop for original kref_init of the fence */ 1051 1050 dma_fence_put(fence); 1052 1051
-4
drivers/gpu/drm/tegra/fbdev.c
··· 225 225 if (ret) 226 226 goto err_drm_client_init; 227 227 228 - ret = tegra_fbdev_client_hotplug(&helper->client); 229 - if (ret) 230 - drm_dbg_kms(dev, "client hotplug ret=%d\n", ret); 231 - 232 228 drm_client_register(&helper->client); 233 229 234 230 return;
+18 -11
drivers/gpu/drm/ttm/ttm_bo.c
··· 458 458 goto out; 459 459 } 460 460 461 - bounce: 462 - ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); 463 - if (ret == -EMULTIHOP) { 461 + do { 462 + ret = ttm_bo_handle_move_mem(bo, evict_mem, true, ctx, &hop); 463 + if (ret != -EMULTIHOP) 464 + break; 465 + 464 466 ret = ttm_bo_bounce_temp_buffer(bo, &evict_mem, ctx, &hop); 465 - if (ret) { 466 - if (ret != -ERESTARTSYS && ret != -EINTR) 467 - pr_err("Buffer eviction failed\n"); 468 - ttm_resource_free(bo, &evict_mem); 469 - goto out; 470 - } 471 - /* try and move to final place now. */ 472 - goto bounce; 467 + } while (!ret); 468 + 469 + if (ret) { 470 + ttm_resource_free(bo, &evict_mem); 471 + if (ret != -ERESTARTSYS && ret != -EINTR) 472 + pr_err("Buffer eviction failed\n"); 473 473 } 474 474 out: 475 475 return ret; ··· 516 516 bool *locked, bool *busy) 517 517 { 518 518 bool ret = false; 519 + 520 + if (bo->pin_count) { 521 + *locked = false; 522 + *busy = false; 523 + return false; 524 + } 519 525 520 526 if (bo->base.resv == ctx->resv) { 521 527 dma_resv_assert_held(bo->base.resv); ··· 1173 1167 ret = ttm_bo_handle_move_mem(bo, evict_mem, true, &ctx, &hop); 1174 1168 if (unlikely(ret != 0)) { 1175 1169 WARN(ret == -EMULTIHOP, "Unexpected multihop in swaput - likely driver bug.\n"); 1170 + ttm_resource_free(bo, &evict_mem); 1176 1171 goto out; 1177 1172 } 1178 1173 }
+4 -1
drivers/gpu/drm/ttm/ttm_resource.c
··· 86 86 struct ttm_resource *res) 87 87 { 88 88 if (pos->last != res) { 89 + if (pos->first == res) 90 + pos->first = list_next_entry(res, lru); 89 91 list_move(&res->lru, &pos->last->lru); 90 92 pos->last = res; 91 93 } ··· 113 111 { 114 112 struct ttm_lru_bulk_move_pos *pos = ttm_lru_bulk_move_pos(bulk, res); 115 113 116 - if (unlikely(pos->first == res && pos->last == res)) { 114 + if (unlikely(WARN_ON(!pos->first || !pos->last) || 115 + (pos->first == res && pos->last == res))) { 117 116 pos->first = NULL; 118 117 pos->last = NULL; 119 118 } else if (pos->first == res) {
+2 -1
drivers/iommu/iommu-sva.c
··· 34 34 } 35 35 36 36 ret = ida_alloc_range(&iommu_global_pasid_ida, min, max, GFP_KERNEL); 37 - if (ret < min) 37 + if (ret < 0) 38 38 goto out; 39 + 39 40 mm->pasid = ret; 40 41 ret = 0; 41 42 out:
+16 -15
drivers/iommu/iommu.c
··· 2891 2891 ret = __iommu_group_set_domain_internal( 2892 2892 group, dom, IOMMU_SET_DOMAIN_MUST_SUCCEED); 2893 2893 if (WARN_ON(ret)) 2894 - goto out_free; 2894 + goto out_free_old; 2895 2895 } else { 2896 2896 ret = __iommu_group_set_domain(group, dom); 2897 - if (ret) { 2898 - iommu_domain_free(dom); 2899 - group->default_domain = old_dom; 2900 - return ret; 2901 - } 2897 + if (ret) 2898 + goto err_restore_def_domain; 2902 2899 } 2903 2900 2904 2901 /* ··· 2908 2911 for_each_group_device(group, gdev) { 2909 2912 ret = iommu_create_device_direct_mappings(dom, gdev->dev); 2910 2913 if (ret) 2911 - goto err_restore; 2914 + goto err_restore_domain; 2912 2915 } 2913 2916 } 2914 2917 2915 - err_restore: 2916 - if (old_dom) { 2917 - __iommu_group_set_domain_internal( 2918 - group, old_dom, IOMMU_SET_DOMAIN_MUST_SUCCEED); 2919 - iommu_domain_free(dom); 2920 - old_dom = NULL; 2921 - } 2922 - out_free: 2918 + out_free_old: 2923 2919 if (old_dom) 2924 2920 iommu_domain_free(old_dom); 2921 + return ret; 2922 + 2923 + err_restore_domain: 2924 + if (old_dom) 2925 + __iommu_group_set_domain_internal( 2926 + group, old_dom, IOMMU_SET_DOMAIN_MUST_SUCCEED); 2927 + err_restore_def_domain: 2928 + if (old_dom) { 2929 + iommu_domain_free(dom); 2930 + group->default_domain = old_dom; 2931 + } 2925 2932 return ret; 2926 2933 } 2927 2934
+8 -2
drivers/net/can/spi/mcp251xfd/mcp251xfd-core.c
··· 227 227 __mcp251xfd_chip_set_mode(const struct mcp251xfd_priv *priv, 228 228 const u8 mode_req, bool nowait) 229 229 { 230 + const struct can_bittiming *bt = &priv->can.bittiming; 231 + unsigned long timeout_us = MCP251XFD_POLL_TIMEOUT_US; 230 232 u32 con = 0, con_reqop, osc = 0; 231 233 u8 mode; 232 234 int err; ··· 248 246 if (mode_req == MCP251XFD_REG_CON_MODE_SLEEP || nowait) 249 247 return 0; 250 248 249 + if (bt->bitrate) 250 + timeout_us = max_t(unsigned long, timeout_us, 251 + MCP251XFD_FRAME_LEN_MAX_BITS * USEC_PER_SEC / 252 + bt->bitrate); 253 + 251 254 err = regmap_read_poll_timeout(priv->map_reg, MCP251XFD_REG_CON, con, 252 255 !mcp251xfd_reg_invalid(con) && 253 256 FIELD_GET(MCP251XFD_REG_CON_OPMOD_MASK, 254 257 con) == mode_req, 255 - MCP251XFD_POLL_SLEEP_US, 256 - MCP251XFD_POLL_TIMEOUT_US); 258 + MCP251XFD_POLL_SLEEP_US, timeout_us); 257 259 if (err != -ETIMEDOUT && err != -EBADMSG) 258 260 return err; 259 261
+1
drivers/net/can/spi/mcp251xfd/mcp251xfd.h
··· 387 387 #define MCP251XFD_OSC_STAB_TIMEOUT_US (10 * MCP251XFD_OSC_STAB_SLEEP_US) 388 388 #define MCP251XFD_POLL_SLEEP_US (10) 389 389 #define MCP251XFD_POLL_TIMEOUT_US (USEC_PER_MSEC) 390 + #define MCP251XFD_FRAME_LEN_MAX_BITS (736) 390 391 391 392 /* Misc */ 392 393 #define MCP251XFD_NAPI_WEIGHT 32
+74 -56
drivers/net/can/usb/gs_usb.c
··· 303 303 struct can_bittiming_const bt_const, data_bt_const; 304 304 unsigned int channel; /* channel number */ 305 305 306 - /* time counter for hardware timestamps */ 307 - struct cyclecounter cc; 308 - struct timecounter tc; 309 - spinlock_t tc_lock; /* spinlock to guard access tc->cycle_last */ 310 - struct delayed_work timestamp; 311 - 312 306 u32 feature; 313 307 unsigned int hf_size_tx; 314 308 ··· 319 325 struct gs_can *canch[GS_MAX_INTF]; 320 326 struct usb_anchor rx_submitted; 321 327 struct usb_device *udev; 328 + 329 + /* time counter for hardware timestamps */ 330 + struct cyclecounter cc; 331 + struct timecounter tc; 332 + spinlock_t tc_lock; /* spinlock to guard access tc->cycle_last */ 333 + struct delayed_work timestamp; 334 + 322 335 unsigned int hf_size_rx; 323 336 u8 active_channels; 324 337 }; ··· 389 388 GFP_KERNEL); 390 389 } 391 390 392 - static inline int gs_usb_get_timestamp(const struct gs_can *dev, 391 + static inline int gs_usb_get_timestamp(const struct gs_usb *parent, 393 392 u32 *timestamp_p) 394 393 { 395 394 __le32 timestamp; 396 395 int rc; 397 396 398 - rc = usb_control_msg_recv(dev->udev, 0, GS_USB_BREQ_TIMESTAMP, 397 + rc = usb_control_msg_recv(parent->udev, 0, GS_USB_BREQ_TIMESTAMP, 399 398 USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_INTERFACE, 400 - dev->channel, 0, 399 + 0, 0, 401 400 &timestamp, sizeof(timestamp), 402 401 USB_CTRL_GET_TIMEOUT, 403 402 GFP_KERNEL); ··· 411 410 412 411 static u64 gs_usb_timestamp_read(const struct cyclecounter *cc) __must_hold(&dev->tc_lock) 413 412 { 414 - struct gs_can *dev = container_of(cc, struct gs_can, cc); 413 + struct gs_usb *parent = container_of(cc, struct gs_usb, cc); 415 414 u32 timestamp = 0; 416 415 int err; 417 416 418 - lockdep_assert_held(&dev->tc_lock); 417 + lockdep_assert_held(&parent->tc_lock); 419 418 420 419 /* drop lock for synchronous USB transfer */ 421 - spin_unlock_bh(&dev->tc_lock); 422 - err = gs_usb_get_timestamp(dev, &timestamp); 423 - spin_lock_bh(&dev->tc_lock); 420 + spin_unlock_bh(&parent->tc_lock); 421 + err = gs_usb_get_timestamp(parent, &timestamp); 422 + spin_lock_bh(&parent->tc_lock); 424 423 if (err) 425 - netdev_err(dev->netdev, 426 - "Error %d while reading timestamp. HW timestamps may be inaccurate.", 427 - err); 424 + dev_err(&parent->udev->dev, 425 + "Error %d while reading timestamp. HW timestamps may be inaccurate.", 426 + err); 428 427 429 428 return timestamp; 430 429 } ··· 432 431 static void gs_usb_timestamp_work(struct work_struct *work) 433 432 { 434 433 struct delayed_work *delayed_work = to_delayed_work(work); 435 - struct gs_can *dev; 434 + struct gs_usb *parent; 436 435 437 - dev = container_of(delayed_work, struct gs_can, timestamp); 438 - spin_lock_bh(&dev->tc_lock); 439 - timecounter_read(&dev->tc); 440 - spin_unlock_bh(&dev->tc_lock); 436 + parent = container_of(delayed_work, struct gs_usb, timestamp); 437 + spin_lock_bh(&parent->tc_lock); 438 + timecounter_read(&parent->tc); 439 + spin_unlock_bh(&parent->tc_lock); 441 440 442 - schedule_delayed_work(&dev->timestamp, 441 + schedule_delayed_work(&parent->timestamp, 443 442 GS_USB_TIMESTAMP_WORK_DELAY_SEC * HZ); 444 443 } 445 444 ··· 447 446 struct sk_buff *skb, u32 timestamp) 448 447 { 449 448 struct skb_shared_hwtstamps *hwtstamps = skb_hwtstamps(skb); 449 + struct gs_usb *parent = dev->parent; 450 450 u64 ns; 451 451 452 - spin_lock_bh(&dev->tc_lock); 453 - ns = timecounter_cyc2time(&dev->tc, timestamp); 454 - spin_unlock_bh(&dev->tc_lock); 452 + spin_lock_bh(&parent->tc_lock); 453 + ns = timecounter_cyc2time(&parent->tc, timestamp); 454 + spin_unlock_bh(&parent->tc_lock); 455 455 456 456 hwtstamps->hwtstamp = ns_to_ktime(ns); 457 457 } 458 458 459 - static void gs_usb_timestamp_init(struct gs_can *dev) 459 + static void gs_usb_timestamp_init(struct gs_usb *parent) 460 460 { 461 - struct cyclecounter *cc = &dev->cc; 461 + struct cyclecounter *cc = &parent->cc; 462 462 463 463 cc->read = gs_usb_timestamp_read; 464 464 cc->mask = CYCLECOUNTER_MASK(32); 465 465 cc->shift = 32 - bits_per(NSEC_PER_SEC / GS_USB_TIMESTAMP_TIMER_HZ); 466 466 cc->mult = clocksource_hz2mult(GS_USB_TIMESTAMP_TIMER_HZ, cc->shift); 467 467 468 - spin_lock_init(&dev->tc_lock); 469 - spin_lock_bh(&dev->tc_lock); 470 - timecounter_init(&dev->tc, &dev->cc, ktime_get_real_ns()); 471 - spin_unlock_bh(&dev->tc_lock); 468 + spin_lock_init(&parent->tc_lock); 469 + spin_lock_bh(&parent->tc_lock); 470 + timecounter_init(&parent->tc, &parent->cc, ktime_get_real_ns()); 471 + spin_unlock_bh(&parent->tc_lock); 472 472 473 - INIT_DELAYED_WORK(&dev->timestamp, gs_usb_timestamp_work); 474 - schedule_delayed_work(&dev->timestamp, 473 + INIT_DELAYED_WORK(&parent->timestamp, gs_usb_timestamp_work); 474 + schedule_delayed_work(&parent->timestamp, 475 475 GS_USB_TIMESTAMP_WORK_DELAY_SEC * HZ); 476 476 } 477 477 478 - static void gs_usb_timestamp_stop(struct gs_can *dev) 478 + static void gs_usb_timestamp_stop(struct gs_usb *parent) 479 479 { 480 - cancel_delayed_work_sync(&dev->timestamp); 480 + cancel_delayed_work_sync(&parent->timestamp); 481 481 } 482 482 483 483 static void gs_update_state(struct gs_can *dev, struct can_frame *cf) ··· 561 559 562 560 if (!netif_device_present(netdev)) 563 561 return; 562 + 563 + if (!netif_running(netdev)) 564 + goto resubmit_urb; 564 565 565 566 if (hf->echo_id == -1) { /* normal rx */ 566 567 if (hf->flags & GS_CAN_FLAG_FD) { ··· 838 833 .mode = cpu_to_le32(GS_CAN_MODE_START), 839 834 }; 840 835 struct gs_host_frame *hf; 836 + struct urb *urb = NULL; 841 837 u32 ctrlmode; 842 838 u32 flags = 0; 843 839 int rc, i; ··· 861 855 } 862 856 863 857 if (!parent->active_channels) { 858 + if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) 859 + gs_usb_timestamp_init(parent); 860 + 864 861 for (i = 0; i < GS_MAX_RX_URBS; i++) { 865 - struct urb *urb; 866 862 u8 *buf; 867 863 868 864 /* alloc rx urb */ 869 865 urb = usb_alloc_urb(0, GFP_KERNEL); 870 - if (!urb) 871 - return -ENOMEM; 866 + if (!urb) { 867 + rc = -ENOMEM; 868 + goto out_usb_kill_anchored_urbs; 869 + } 872 870 873 871 /* alloc rx buffer */ 874 872 buf = kmalloc(dev->parent->hf_size_rx, ··· 880 870 if (!buf) { 881 871 netdev_err(netdev, 882 872 "No memory left for USB buffer\n"); 883 - usb_free_urb(urb); 884 - return -ENOMEM; 873 + rc = -ENOMEM; 874 + goto out_usb_free_urb; 885 875 } 886 876 887 877 /* fill, anchor, and submit rx urb */ ··· 904 894 netdev_err(netdev, 905 895 "usb_submit failed (err=%d)\n", rc); 906 896 907 - usb_unanchor_urb(urb); 908 - usb_free_urb(urb); 909 - break; 897 + goto out_usb_unanchor_urb; 910 898 } 911 899 912 900 /* Drop reference, ··· 934 926 flags |= GS_CAN_MODE_FD; 935 927 936 928 /* if hardware supports timestamps, enable it */ 937 - if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) { 929 + if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) 938 930 flags |= GS_CAN_MODE_HW_TIMESTAMP; 939 - 940 - /* start polling timestamp */ 941 - gs_usb_timestamp_init(dev); 942 - } 943 931 944 932 /* finally start device */ 945 933 dev->can.state = CAN_STATE_ERROR_ACTIVE; ··· 946 942 GFP_KERNEL); 947 943 if (rc) { 948 944 netdev_err(netdev, "Couldn't start device (err=%d)\n", rc); 949 - if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) 950 - gs_usb_timestamp_stop(dev); 951 945 dev->can.state = CAN_STATE_STOPPED; 952 - return rc; 946 + 947 + goto out_usb_kill_anchored_urbs; 953 948 } 954 949 955 950 parent->active_channels++; ··· 956 953 netif_start_queue(netdev); 957 954 958 955 return 0; 956 + 957 + out_usb_unanchor_urb: 958 + usb_unanchor_urb(urb); 959 + out_usb_free_urb: 960 + usb_free_urb(urb); 961 + out_usb_kill_anchored_urbs: 962 + if (!parent->active_channels) { 963 + usb_kill_anchored_urbs(&dev->tx_submitted); 964 + 965 + if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) 966 + gs_usb_timestamp_stop(parent); 967 + } 968 + 969 + close_candev(netdev); 970 + 971 + return rc; 959 972 } 960 973 961 974 static int gs_usb_get_state(const struct net_device *netdev, ··· 1017 998 1018 999 netif_stop_queue(netdev); 1019 1000 1020 - /* stop polling timestamp */ 1021 - if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) 1022 - gs_usb_timestamp_stop(dev); 1023 - 1024 1001 /* Stop polling */ 1025 1002 parent->active_channels--; 1026 1003 if (!parent->active_channels) { 1027 1004 usb_kill_anchored_urbs(&parent->rx_submitted); 1005 + 1006 + if (dev->feature & GS_CAN_FEATURE_HW_TIMESTAMP) 1007 + gs_usb_timestamp_stop(parent); 1028 1008 } 1029 1009 1030 1010 /* Stop sending URBs */
+7 -1
drivers/net/dsa/microchip/ksz8795.c
··· 506 506 (data_hi & masks[STATIC_MAC_TABLE_FWD_PORTS]) >> 507 507 shifts[STATIC_MAC_FWD_PORTS]; 508 508 alu->is_override = (data_hi & masks[STATIC_MAC_TABLE_OVERRIDE]) ? 1 : 0; 509 - data_hi >>= 1; 509 + 510 + /* KSZ8795 family switches have STATIC_MAC_TABLE_USE_FID and 511 + * STATIC_MAC_TABLE_FID definitions off by 1 when doing read on the 512 + * static MAC table compared to doing write. 513 + */ 514 + if (ksz_is_ksz87xx(dev)) 515 + data_hi >>= 1; 510 516 alu->is_static = true; 511 517 alu->is_use_fid = (data_hi & masks[STATIC_MAC_TABLE_USE_FID]) ? 1 : 0; 512 518 alu->fid = (data_hi & masks[STATIC_MAC_TABLE_FID]) >>
+4 -4
drivers/net/dsa/microchip/ksz_common.c
··· 331 331 [STATIC_MAC_TABLE_VALID] = BIT(21), 332 332 [STATIC_MAC_TABLE_USE_FID] = BIT(23), 333 333 [STATIC_MAC_TABLE_FID] = GENMASK(30, 24), 334 - [STATIC_MAC_TABLE_OVERRIDE] = BIT(26), 335 - [STATIC_MAC_TABLE_FWD_PORTS] = GENMASK(24, 20), 334 + [STATIC_MAC_TABLE_OVERRIDE] = BIT(22), 335 + [STATIC_MAC_TABLE_FWD_PORTS] = GENMASK(20, 16), 336 336 [DYNAMIC_MAC_TABLE_ENTRIES_H] = GENMASK(6, 0), 337 - [DYNAMIC_MAC_TABLE_MAC_EMPTY] = BIT(8), 337 + [DYNAMIC_MAC_TABLE_MAC_EMPTY] = BIT(7), 338 338 [DYNAMIC_MAC_TABLE_NOT_READY] = BIT(7), 339 339 [DYNAMIC_MAC_TABLE_ENTRIES] = GENMASK(31, 29), 340 - [DYNAMIC_MAC_TABLE_FID] = GENMASK(26, 20), 340 + [DYNAMIC_MAC_TABLE_FID] = GENMASK(22, 16), 341 341 [DYNAMIC_MAC_TABLE_SRC_PORT] = GENMASK(26, 24), 342 342 [DYNAMIC_MAC_TABLE_TIMESTAMP] = GENMASK(28, 27), 343 343 [P_MII_TX_FLOW_CTRL] = BIT(5),
+7
drivers/net/dsa/microchip/ksz_common.h
··· 601 601 mutex_unlock(mtx); 602 602 } 603 603 604 + static inline bool ksz_is_ksz87xx(struct ksz_device *dev) 605 + { 606 + return dev->chip_id == KSZ8795_CHIP_ID || 607 + dev->chip_id == KSZ8794_CHIP_ID || 608 + dev->chip_id == KSZ8765_CHIP_ID; 609 + } 610 + 604 611 static inline bool ksz_is_ksz88x3(struct ksz_device *dev) 605 612 { 606 613 return dev->chip_id == KSZ8830_CHIP_ID;
+7
drivers/net/dsa/mv88e6xxx/chip.c
··· 109 109 usleep_range(1000, 2000); 110 110 } 111 111 112 + err = mv88e6xxx_read(chip, addr, reg, &data); 113 + if (err) 114 + return err; 115 + 116 + if ((data & mask) == val) 117 + return 0; 118 + 112 119 dev_err(chip->dev, "Timeout while waiting for switch\n"); 113 120 return -ETIMEDOUT; 114 121 }
+2 -2
drivers/net/dsa/qca/ar9331.c
··· 1002 1002 .val_bits = 32, 1003 1003 .reg_stride = 4, 1004 1004 .max_register = AR9331_SW_REG_PAGE, 1005 + .use_single_read = true, 1006 + .use_single_write = true, 1005 1007 1006 1008 .ranges = ar9331_regmap_range, 1007 1009 .num_ranges = ARRAY_SIZE(ar9331_regmap_range), ··· 1020 1018 .val_format_endian_default = REGMAP_ENDIAN_NATIVE, 1021 1019 .read = ar9331_mdio_read, 1022 1020 .write = ar9331_sw_bus_write, 1023 - .max_raw_read = 4, 1024 - .max_raw_write = 4, 1025 1021 }; 1026 1022 1027 1023 static int ar9331_sw_probe(struct mdio_device *mdiodev)
-5
drivers/net/ethernet/brocade/bna/bnad_debugfs.c
··· 512 512 if (!bnad->port_debugfs_root) { 513 513 bnad->port_debugfs_root = 514 514 debugfs_create_dir(name, bna_debugfs_root); 515 - if (!bnad->port_debugfs_root) { 516 - netdev_warn(bnad->netdev, 517 - "debugfs root dir creation failed\n"); 518 - return; 519 - } 520 515 521 516 atomic_inc(&bna_debugfs_port_count); 522 517
+5 -1
drivers/net/ethernet/intel/iavf/iavf.h
··· 255 255 struct workqueue_struct *wq; 256 256 struct work_struct reset_task; 257 257 struct work_struct adminq_task; 258 + struct work_struct finish_config; 258 259 struct delayed_work client_task; 259 260 wait_queue_head_t down_waitqueue; 261 + wait_queue_head_t reset_waitqueue; 260 262 wait_queue_head_t vc_waitqueue; 261 263 struct iavf_q_vector *q_vectors; 262 264 struct list_head vlan_filter_list; ··· 520 518 void iavf_down(struct iavf_adapter *adapter); 521 519 int iavf_process_config(struct iavf_adapter *adapter); 522 520 int iavf_parse_vf_resource_msg(struct iavf_adapter *adapter); 523 - void iavf_schedule_reset(struct iavf_adapter *adapter); 521 + void iavf_schedule_reset(struct iavf_adapter *adapter, u64 flags); 524 522 void iavf_schedule_request_stats(struct iavf_adapter *adapter); 523 + void iavf_schedule_finish_config(struct iavf_adapter *adapter); 525 524 void iavf_reset(struct iavf_adapter *adapter); 526 525 void iavf_set_ethtool_ops(struct net_device *netdev); 527 526 void iavf_update_stats(struct iavf_adapter *adapter); ··· 585 582 void iavf_del_adv_rss_cfg(struct iavf_adapter *adapter); 586 583 struct iavf_mac_filter *iavf_add_filter(struct iavf_adapter *adapter, 587 584 const u8 *macaddr); 585 + int iavf_wait_for_reset(struct iavf_adapter *adapter); 588 586 #endif /* _IAVF_H_ */
+18 -21
drivers/net/ethernet/intel/iavf/iavf_ethtool.c
··· 484 484 { 485 485 struct iavf_adapter *adapter = netdev_priv(netdev); 486 486 u32 orig_flags, new_flags, changed_flags; 487 + int ret = 0; 487 488 u32 i; 488 489 489 490 orig_flags = READ_ONCE(adapter->flags); ··· 532 531 /* issue a reset to force legacy-rx change to take effect */ 533 532 if (changed_flags & IAVF_FLAG_LEGACY_RX) { 534 533 if (netif_running(netdev)) { 535 - adapter->flags |= IAVF_FLAG_RESET_NEEDED; 536 - queue_work(adapter->wq, &adapter->reset_task); 534 + iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); 535 + ret = iavf_wait_for_reset(adapter); 536 + if (ret) 537 + netdev_warn(netdev, "Changing private flags timeout or interrupted waiting for reset"); 537 538 } 538 539 } 539 540 540 - return 0; 541 + return ret; 541 542 } 542 543 543 544 /** ··· 630 627 { 631 628 struct iavf_adapter *adapter = netdev_priv(netdev); 632 629 u32 new_rx_count, new_tx_count; 630 + int ret = 0; 633 631 634 632 if ((ring->rx_mini_pending) || (ring->rx_jumbo_pending)) 635 633 return -EINVAL; ··· 675 671 } 676 672 677 673 if (netif_running(netdev)) { 678 - adapter->flags |= IAVF_FLAG_RESET_NEEDED; 679 - queue_work(adapter->wq, &adapter->reset_task); 674 + iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); 675 + ret = iavf_wait_for_reset(adapter); 676 + if (ret) 677 + netdev_warn(netdev, "Changing ring parameters timeout or interrupted waiting for reset"); 680 678 } 681 679 682 - return 0; 680 + return ret; 683 681 } 684 682 685 683 /** ··· 1836 1830 { 1837 1831 struct iavf_adapter *adapter = netdev_priv(netdev); 1838 1832 u32 num_req = ch->combined_count; 1839 - int i; 1833 + int ret = 0; 1840 1834 1841 1835 if ((adapter->vf_res->vf_cap_flags & VIRTCHNL_VF_OFFLOAD_ADQ) && 1842 1836 adapter->num_tc) { ··· 1858 1852 1859 1853 adapter->num_req_queues = num_req; 1860 1854 adapter->flags |= IAVF_FLAG_REINIT_ITR_NEEDED; 1861 - iavf_schedule_reset(adapter); 1855 + iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); 1862 1856 1863 - /* wait for the reset is done */ 1864 - for (i = 0; i < IAVF_RESET_WAIT_COMPLETE_COUNT; i++) { 1865 - msleep(IAVF_RESET_WAIT_MS); 1866 - if (adapter->flags & IAVF_FLAG_RESET_PENDING) 1867 - continue; 1868 - break; 1869 - } 1870 - if (i == IAVF_RESET_WAIT_COMPLETE_COUNT) { 1871 - adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED; 1872 - adapter->num_active_queues = num_req; 1873 - return -EOPNOTSUPP; 1874 - } 1857 + ret = iavf_wait_for_reset(adapter); 1858 + if (ret) 1859 + netdev_warn(netdev, "Changing channel count timeout or interrupted waiting for reset"); 1875 1860 1876 - return 0; 1861 + return ret; 1877 1862 } 1878 1863 1879 1864 /**
+150 -87
drivers/net/ethernet/intel/iavf/iavf_main.c
··· 167 167 } 168 168 169 169 /** 170 + * iavf_is_reset_in_progress - Check if a reset is in progress 171 + * @adapter: board private structure 172 + */ 173 + static bool iavf_is_reset_in_progress(struct iavf_adapter *adapter) 174 + { 175 + if (adapter->state == __IAVF_RESETTING || 176 + adapter->flags & (IAVF_FLAG_RESET_PENDING | 177 + IAVF_FLAG_RESET_NEEDED)) 178 + return true; 179 + 180 + return false; 181 + } 182 + 183 + /** 184 + * iavf_wait_for_reset - Wait for reset to finish. 185 + * @adapter: board private structure 186 + * 187 + * Returns 0 if reset finished successfully, negative on timeout or interrupt. 188 + */ 189 + int iavf_wait_for_reset(struct iavf_adapter *adapter) 190 + { 191 + int ret = wait_event_interruptible_timeout(adapter->reset_waitqueue, 192 + !iavf_is_reset_in_progress(adapter), 193 + msecs_to_jiffies(5000)); 194 + 195 + /* If ret < 0 then it means wait was interrupted. 196 + * If ret == 0 then it means we got a timeout while waiting 197 + * for reset to finish. 198 + * If ret > 0 it means reset has finished. 199 + */ 200 + if (ret > 0) 201 + return 0; 202 + else if (ret < 0) 203 + return -EINTR; 204 + else 205 + return -EBUSY; 206 + } 207 + 208 + /** 170 209 * iavf_allocate_dma_mem_d - OS specific memory alloc for shared code 171 210 * @hw: pointer to the HW structure 172 211 * @mem: ptr to mem struct to fill out ··· 301 262 /** 302 263 * iavf_schedule_reset - Set the flags and schedule a reset event 303 264 * @adapter: board private structure 265 + * @flags: IAVF_FLAG_RESET_PENDING or IAVF_FLAG_RESET_NEEDED 304 266 **/ 305 - void iavf_schedule_reset(struct iavf_adapter *adapter) 267 + void iavf_schedule_reset(struct iavf_adapter *adapter, u64 flags) 306 268 { 307 - if (!(adapter->flags & 308 - (IAVF_FLAG_RESET_PENDING | IAVF_FLAG_RESET_NEEDED))) { 309 - adapter->flags |= IAVF_FLAG_RESET_NEEDED; 269 + if (!test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section) && 270 + !(adapter->flags & 271 + (IAVF_FLAG_RESET_PENDING | IAVF_FLAG_RESET_NEEDED))) { 272 + adapter->flags |= flags; 310 273 queue_work(adapter->wq, &adapter->reset_task); 311 274 } 312 275 } ··· 336 295 struct iavf_adapter *adapter = netdev_priv(netdev); 337 296 338 297 adapter->tx_timeout_count++; 339 - iavf_schedule_reset(adapter); 298 + iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); 340 299 } 341 300 342 301 /** ··· 1692 1651 adapter->msix_entries[vector].entry = vector; 1693 1652 1694 1653 err = iavf_acquire_msix_vectors(adapter, v_budget); 1654 + if (!err) 1655 + iavf_schedule_finish_config(adapter); 1695 1656 1696 1657 out: 1697 - netif_set_real_num_rx_queues(adapter->netdev, pairs); 1698 - netif_set_real_num_tx_queues(adapter->netdev, pairs); 1699 1658 return err; 1700 1659 } 1701 1660 ··· 1869 1828 static void iavf_free_q_vectors(struct iavf_adapter *adapter) 1870 1829 { 1871 1830 int q_idx, num_q_vectors; 1872 - int napi_vectors; 1873 1831 1874 1832 if (!adapter->q_vectors) 1875 1833 return; 1876 1834 1877 1835 num_q_vectors = adapter->num_msix_vectors - NONQ_VECS; 1878 - napi_vectors = adapter->num_active_queues; 1879 1836 1880 1837 for (q_idx = 0; q_idx < num_q_vectors; q_idx++) { 1881 1838 struct iavf_q_vector *q_vector = &adapter->q_vectors[q_idx]; 1882 1839 1883 - if (q_idx < napi_vectors) 1884 - netif_napi_del(&q_vector->napi); 1840 + netif_napi_del(&q_vector->napi); 1885 1841 } 1886 1842 kfree(adapter->q_vectors); 1887 1843 adapter->q_vectors = NULL; ··· 1915 1877 goto err_alloc_queues; 1916 1878 } 1917 1879 1918 - rtnl_lock(); 1919 1880 err = iavf_set_interrupt_capability(adapter); 1920 - rtnl_unlock(); 1921 1881 if (err) { 1922 1882 dev_err(&adapter->pdev->dev, 1923 1883 "Unable to setup interrupt capabilities\n"); ··· 1968 1932 /** 1969 1933 * iavf_reinit_interrupt_scheme - Reallocate queues and vectors 1970 1934 * @adapter: board private structure 1935 + * @running: true if adapter->state == __IAVF_RUNNING 1971 1936 * 1972 1937 * Returns 0 on success, negative on failure 1973 1938 **/ 1974 - static int iavf_reinit_interrupt_scheme(struct iavf_adapter *adapter) 1939 + static int iavf_reinit_interrupt_scheme(struct iavf_adapter *adapter, bool running) 1975 1940 { 1976 1941 struct net_device *netdev = adapter->netdev; 1977 1942 int err; 1978 1943 1979 - if (netif_running(netdev)) 1944 + if (running) 1980 1945 iavf_free_traffic_irqs(adapter); 1981 1946 iavf_free_misc_irq(adapter); 1982 1947 iavf_reset_interrupt_capability(adapter); ··· 1999 1962 iavf_map_rings_to_vectors(adapter); 2000 1963 err: 2001 1964 return err; 1965 + } 1966 + 1967 + /** 1968 + * iavf_finish_config - do all netdev work that needs RTNL 1969 + * @work: our work_struct 1970 + * 1971 + * Do work that needs both RTNL and crit_lock. 1972 + **/ 1973 + static void iavf_finish_config(struct work_struct *work) 1974 + { 1975 + struct iavf_adapter *adapter; 1976 + int pairs, err; 1977 + 1978 + adapter = container_of(work, struct iavf_adapter, finish_config); 1979 + 1980 + /* Always take RTNL first to prevent circular lock dependency */ 1981 + rtnl_lock(); 1982 + mutex_lock(&adapter->crit_lock); 1983 + 1984 + if ((adapter->flags & IAVF_FLAG_SETUP_NETDEV_FEATURES) && 1985 + adapter->netdev_registered && 1986 + !test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) { 1987 + netdev_update_features(adapter->netdev); 1988 + adapter->flags &= ~IAVF_FLAG_SETUP_NETDEV_FEATURES; 1989 + } 1990 + 1991 + switch (adapter->state) { 1992 + case __IAVF_DOWN: 1993 + if (!adapter->netdev_registered) { 1994 + err = register_netdevice(adapter->netdev); 1995 + if (err) { 1996 + dev_err(&adapter->pdev->dev, "Unable to register netdev (%d)\n", 1997 + err); 1998 + 1999 + /* go back and try again.*/ 2000 + iavf_free_rss(adapter); 2001 + iavf_free_misc_irq(adapter); 2002 + iavf_reset_interrupt_capability(adapter); 2003 + iavf_change_state(adapter, 2004 + __IAVF_INIT_CONFIG_ADAPTER); 2005 + goto out; 2006 + } 2007 + adapter->netdev_registered = true; 2008 + } 2009 + 2010 + /* Set the real number of queues when reset occurs while 2011 + * state == __IAVF_DOWN 2012 + */ 2013 + fallthrough; 2014 + case __IAVF_RUNNING: 2015 + pairs = adapter->num_active_queues; 2016 + netif_set_real_num_rx_queues(adapter->netdev, pairs); 2017 + netif_set_real_num_tx_queues(adapter->netdev, pairs); 2018 + break; 2019 + 2020 + default: 2021 + break; 2022 + } 2023 + 2024 + out: 2025 + mutex_unlock(&adapter->crit_lock); 2026 + rtnl_unlock(); 2027 + } 2028 + 2029 + /** 2030 + * iavf_schedule_finish_config - Set the flags and schedule a reset event 2031 + * @adapter: board private structure 2032 + **/ 2033 + void iavf_schedule_finish_config(struct iavf_adapter *adapter) 2034 + { 2035 + if (!test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section)) 2036 + queue_work(adapter->wq, &adapter->finish_config); 2002 2037 } 2003 2038 2004 2039 /** ··· 2480 2371 adapter->vsi_res->num_queue_pairs); 2481 2372 adapter->flags |= IAVF_FLAG_REINIT_MSIX_NEEDED; 2482 2373 adapter->num_req_queues = adapter->vsi_res->num_queue_pairs; 2483 - iavf_schedule_reset(adapter); 2374 + iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); 2484 2375 2485 2376 return -EAGAIN; 2486 2377 } ··· 2710 2601 2711 2602 netif_carrier_off(netdev); 2712 2603 adapter->link_up = false; 2713 - 2714 - /* set the semaphore to prevent any callbacks after device registration 2715 - * up to time when state of driver will be set to __IAVF_DOWN 2716 - */ 2717 - rtnl_lock(); 2718 - if (!adapter->netdev_registered) { 2719 - err = register_netdevice(netdev); 2720 - if (err) { 2721 - rtnl_unlock(); 2722 - goto err_register; 2723 - } 2724 - } 2725 - 2726 - adapter->netdev_registered = true; 2727 - 2728 2604 netif_tx_stop_all_queues(netdev); 2605 + 2729 2606 if (CLIENT_ALLOWED(adapter)) { 2730 2607 err = iavf_lan_add_device(adapter); 2731 2608 if (err) ··· 2724 2629 2725 2630 iavf_change_state(adapter, __IAVF_DOWN); 2726 2631 set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); 2727 - rtnl_unlock(); 2728 2632 2729 2633 iavf_misc_irq_enable(adapter); 2730 2634 wake_up(&adapter->down_waitqueue); ··· 2743 2649 /* request initial VLAN offload settings */ 2744 2650 iavf_set_vlan_offload_features(adapter, 0, netdev->features); 2745 2651 2652 + iavf_schedule_finish_config(adapter); 2746 2653 return; 2654 + 2747 2655 err_mem: 2748 2656 iavf_free_rss(adapter); 2749 - err_register: 2750 2657 iavf_free_misc_irq(adapter); 2751 2658 err_sw_init: 2752 2659 iavf_reset_interrupt_capability(adapter); ··· 2774 2679 goto restart_watchdog; 2775 2680 } 2776 2681 2777 - if ((adapter->flags & IAVF_FLAG_SETUP_NETDEV_FEATURES) && 2778 - adapter->netdev_registered && 2779 - !test_bit(__IAVF_IN_REMOVE_TASK, &adapter->crit_section) && 2780 - rtnl_trylock()) { 2781 - netdev_update_features(adapter->netdev); 2782 - rtnl_unlock(); 2783 - adapter->flags &= ~IAVF_FLAG_SETUP_NETDEV_FEATURES; 2784 - } 2785 - 2786 2682 if (adapter->flags & IAVF_FLAG_PF_COMMS_FAILED) 2787 2683 iavf_change_state(adapter, __IAVF_COMM_FAILED); 2788 - 2789 - if (adapter->flags & IAVF_FLAG_RESET_NEEDED) { 2790 - adapter->aq_required = 0; 2791 - adapter->current_op = VIRTCHNL_OP_UNKNOWN; 2792 - mutex_unlock(&adapter->crit_lock); 2793 - queue_work(adapter->wq, &adapter->reset_task); 2794 - return; 2795 - } 2796 2684 2797 2685 switch (adapter->state) { 2798 2686 case __IAVF_STARTUP: ··· 2904 2826 /* check for hw reset */ 2905 2827 reg_val = rd32(hw, IAVF_VF_ARQLEN1) & IAVF_VF_ARQLEN1_ARQENABLE_MASK; 2906 2828 if (!reg_val) { 2907 - adapter->flags |= IAVF_FLAG_RESET_PENDING; 2908 2829 adapter->aq_required = 0; 2909 2830 adapter->current_op = VIRTCHNL_OP_UNKNOWN; 2910 2831 dev_err(&adapter->pdev->dev, "Hardware reset detected\n"); 2911 - queue_work(adapter->wq, &adapter->reset_task); 2832 + iavf_schedule_reset(adapter, IAVF_FLAG_RESET_PENDING); 2912 2833 mutex_unlock(&adapter->crit_lock); 2913 2834 queue_delayed_work(adapter->wq, 2914 2835 &adapter->watchdog_task, HZ * 2); ··· 3017 2940 int i = 0, err; 3018 2941 bool running; 3019 2942 3020 - /* Detach interface to avoid subsequent NDO callbacks */ 3021 - rtnl_lock(); 3022 - netif_device_detach(netdev); 3023 - rtnl_unlock(); 3024 - 3025 2943 /* When device is being removed it doesn't make sense to run the reset 3026 2944 * task, just return in such a case. 3027 2945 */ ··· 3024 2952 if (adapter->state != __IAVF_REMOVE) 3025 2953 queue_work(adapter->wq, &adapter->reset_task); 3026 2954 3027 - goto reset_finish; 2955 + return; 3028 2956 } 3029 2957 3030 2958 while (!mutex_trylock(&adapter->client_lock)) ··· 3082 3010 iavf_disable_vf(adapter); 3083 3011 mutex_unlock(&adapter->client_lock); 3084 3012 mutex_unlock(&adapter->crit_lock); 3085 - if (netif_running(netdev)) { 3086 - rtnl_lock(); 3087 - dev_close(netdev); 3088 - rtnl_unlock(); 3089 - } 3090 3013 return; /* Do not attempt to reinit. It's dead, Jim. */ 3091 3014 } 3092 3015 ··· 3123 3056 3124 3057 if ((adapter->flags & IAVF_FLAG_REINIT_MSIX_NEEDED) || 3125 3058 (adapter->flags & IAVF_FLAG_REINIT_ITR_NEEDED)) { 3126 - err = iavf_reinit_interrupt_scheme(adapter); 3059 + err = iavf_reinit_interrupt_scheme(adapter, running); 3127 3060 if (err) 3128 3061 goto reset_err; 3129 3062 } ··· 3218 3151 3219 3152 adapter->flags &= ~IAVF_FLAG_REINIT_ITR_NEEDED; 3220 3153 3154 + wake_up(&adapter->reset_waitqueue); 3221 3155 mutex_unlock(&adapter->client_lock); 3222 3156 mutex_unlock(&adapter->crit_lock); 3223 3157 3224 - goto reset_finish; 3158 + return; 3225 3159 reset_err: 3226 3160 if (running) { 3227 3161 set_bit(__IAVF_VSI_DOWN, adapter->vsi.state); ··· 3232 3164 3233 3165 mutex_unlock(&adapter->client_lock); 3234 3166 mutex_unlock(&adapter->crit_lock); 3235 - 3236 - if (netif_running(netdev)) { 3237 - /* Close device to ensure that Tx queues will not be started 3238 - * during netif_device_attach() at the end of the reset task. 3239 - */ 3240 - rtnl_lock(); 3241 - dev_close(netdev); 3242 - rtnl_unlock(); 3243 - } 3244 - 3245 3167 dev_err(&adapter->pdev->dev, "failed to allocate resources during reinit\n"); 3246 - reset_finish: 3247 - rtnl_lock(); 3248 - netif_device_attach(netdev); 3249 - rtnl_unlock(); 3250 3168 } 3251 3169 3252 3170 /** ··· 3281 3227 } while (pending); 3282 3228 mutex_unlock(&adapter->crit_lock); 3283 3229 3284 - if ((adapter->flags & 3285 - (IAVF_FLAG_RESET_PENDING | IAVF_FLAG_RESET_NEEDED)) || 3286 - adapter->state == __IAVF_RESETTING) 3230 + if (iavf_is_reset_in_progress(adapter)) 3287 3231 goto freedom; 3288 3232 3289 3233 /* check for error indications */ ··· 4367 4315 static int iavf_change_mtu(struct net_device *netdev, int new_mtu) 4368 4316 { 4369 4317 struct iavf_adapter *adapter = netdev_priv(netdev); 4318 + int ret = 0; 4370 4319 4371 4320 netdev_dbg(netdev, "changing MTU from %d to %d\n", 4372 4321 netdev->mtu, new_mtu); ··· 4378 4325 } 4379 4326 4380 4327 if (netif_running(netdev)) { 4381 - adapter->flags |= IAVF_FLAG_RESET_NEEDED; 4382 - queue_work(adapter->wq, &adapter->reset_task); 4328 + iavf_schedule_reset(adapter, IAVF_FLAG_RESET_NEEDED); 4329 + ret = iavf_wait_for_reset(adapter); 4330 + if (ret < 0) 4331 + netdev_warn(netdev, "MTU change interrupted waiting for reset"); 4332 + else if (ret) 4333 + netdev_warn(netdev, "MTU change timed out waiting for reset"); 4383 4334 } 4384 4335 4385 - return 0; 4336 + return ret; 4386 4337 } 4387 4338 4388 4339 #define NETIF_VLAN_OFFLOAD_FEATURES (NETIF_F_HW_VLAN_CTAG_RX | \ ··· 4979 4922 4980 4923 INIT_WORK(&adapter->reset_task, iavf_reset_task); 4981 4924 INIT_WORK(&adapter->adminq_task, iavf_adminq_task); 4925 + INIT_WORK(&adapter->finish_config, iavf_finish_config); 4982 4926 INIT_DELAYED_WORK(&adapter->watchdog_task, iavf_watchdog_task); 4983 4927 INIT_DELAYED_WORK(&adapter->client_task, iavf_client_task); 4984 4928 queue_delayed_work(adapter->wq, &adapter->watchdog_task, ··· 4987 4929 4988 4930 /* Setup the wait queue for indicating transition to down status */ 4989 4931 init_waitqueue_head(&adapter->down_waitqueue); 4932 + 4933 + /* Setup the wait queue for indicating transition to running state */ 4934 + init_waitqueue_head(&adapter->reset_waitqueue); 4990 4935 4991 4936 /* Setup the wait queue for indicating virtchannel events */ 4992 4937 init_waitqueue_head(&adapter->vc_waitqueue); ··· 5122 5061 usleep_range(500, 1000); 5123 5062 } 5124 5063 cancel_delayed_work_sync(&adapter->watchdog_task); 5064 + cancel_work_sync(&adapter->finish_config); 5125 5065 5066 + rtnl_lock(); 5126 5067 if (adapter->netdev_registered) { 5127 - rtnl_lock(); 5128 5068 unregister_netdevice(netdev); 5129 5069 adapter->netdev_registered = false; 5130 - rtnl_unlock(); 5131 5070 } 5071 + rtnl_unlock(); 5072 + 5132 5073 if (CLIENT_ALLOWED(adapter)) { 5133 5074 err = iavf_lan_del_device(adapter); 5134 5075 if (err)
+3 -2
drivers/net/ethernet/intel/iavf/iavf_virtchnl.c
··· 1961 1961 case VIRTCHNL_EVENT_RESET_IMPENDING: 1962 1962 dev_info(&adapter->pdev->dev, "Reset indication received from the PF\n"); 1963 1963 if (!(adapter->flags & IAVF_FLAG_RESET_PENDING)) { 1964 - adapter->flags |= IAVF_FLAG_RESET_PENDING; 1965 1964 dev_info(&adapter->pdev->dev, "Scheduling reset task\n"); 1966 - queue_work(adapter->wq, &adapter->reset_task); 1965 + iavf_schedule_reset(adapter, IAVF_FLAG_RESET_PENDING); 1967 1966 } 1968 1967 break; 1969 1968 default: ··· 2236 2237 2237 2238 iavf_process_config(adapter); 2238 2239 adapter->flags |= IAVF_FLAG_SETUP_NETDEV_FEATURES; 2240 + iavf_schedule_finish_config(adapter); 2239 2241 2240 2242 iavf_set_queue_vlan_tag_loc(adapter); 2241 2243 ··· 2285 2285 case VIRTCHNL_OP_ENABLE_QUEUES: 2286 2286 /* enable transmits */ 2287 2287 iavf_irq_enable(adapter, true); 2288 + wake_up(&adapter->reset_waitqueue); 2288 2289 adapter->flags &= ~IAVF_FLAG_QUEUES_DISABLED; 2289 2290 break; 2290 2291 case VIRTCHNL_OP_DISABLE_QUEUES:
+2
drivers/net/ethernet/intel/ice/ice_base.c
··· 793 793 794 794 ice_for_each_q_vector(vsi, v_idx) 795 795 ice_free_q_vector(vsi, v_idx); 796 + 797 + vsi->num_q_vectors = 0; 796 798 } 797 799 798 800 /**
+11 -2
drivers/net/ethernet/intel/ice/ice_ethtool.c
··· 2681 2681 2682 2682 ring->rx_max_pending = ICE_MAX_NUM_DESC; 2683 2683 ring->tx_max_pending = ICE_MAX_NUM_DESC; 2684 - ring->rx_pending = vsi->rx_rings[0]->count; 2685 - ring->tx_pending = vsi->tx_rings[0]->count; 2684 + if (vsi->tx_rings && vsi->rx_rings) { 2685 + ring->rx_pending = vsi->rx_rings[0]->count; 2686 + ring->tx_pending = vsi->tx_rings[0]->count; 2687 + } else { 2688 + ring->rx_pending = 0; 2689 + ring->tx_pending = 0; 2690 + } 2686 2691 2687 2692 /* Rx mini and jumbo rings are not supported */ 2688 2693 ring->rx_mini_max_pending = 0; ··· 2720 2715 ICE_REQ_DESC_MULTIPLE); 2721 2716 return -EINVAL; 2722 2717 } 2718 + 2719 + /* Return if there is no rings (device is reloading) */ 2720 + if (!vsi->tx_rings || !vsi->rx_rings) 2721 + return -EBUSY; 2723 2722 2724 2723 new_tx_cnt = ALIGN(ring->tx_pending, ICE_REQ_DESC_MULTIPLE); 2725 2724 if (new_tx_cnt != ring->tx_pending)
-27
drivers/net/ethernet/intel/ice/ice_lib.c
··· 2972 2972 return -ENODEV; 2973 2973 pf = vsi->back; 2974 2974 2975 - /* do not unregister while driver is in the reset recovery pending 2976 - * state. Since reset/rebuild happens through PF service task workqueue, 2977 - * it's not a good idea to unregister netdev that is associated to the 2978 - * PF that is running the work queue items currently. This is done to 2979 - * avoid check_flush_dependency() warning on this wq 2980 - */ 2981 - if (vsi->netdev && !ice_is_reset_in_progress(pf->state) && 2982 - (test_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state))) { 2983 - unregister_netdev(vsi->netdev); 2984 - clear_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state); 2985 - } 2986 - 2987 - if (vsi->type == ICE_VSI_PF) 2988 - ice_devlink_destroy_pf_port(pf); 2989 - 2990 2975 if (test_bit(ICE_FLAG_RSS_ENA, pf->flags)) 2991 2976 ice_rss_clean(vsi); 2992 2977 2993 2978 ice_vsi_close(vsi); 2994 2979 ice_vsi_decfg(vsi); 2995 - 2996 - if (vsi->netdev) { 2997 - if (test_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state)) { 2998 - unregister_netdev(vsi->netdev); 2999 - clear_bit(ICE_VSI_NETDEV_REGISTERED, vsi->state); 3000 - } 3001 - if (test_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state)) { 3002 - free_netdev(vsi->netdev); 3003 - vsi->netdev = NULL; 3004 - clear_bit(ICE_VSI_NETDEV_ALLOCD, vsi->state); 3005 - } 3006 - } 3007 2980 3008 2981 /* retain SW VSI data structure since it is needed to unregister and 3009 2982 * free VSI netdev when PF is not in reset recovery pending state,\
+8 -2
drivers/net/ethernet/intel/ice/ice_main.c
··· 4431 4431 if (err) 4432 4432 return err; 4433 4433 4434 - rtnl_lock(); 4435 4434 err = ice_vsi_open(vsi); 4436 - rtnl_unlock(); 4435 + if (err) 4436 + ice_fltr_remove_all(vsi); 4437 4437 4438 4438 return err; 4439 4439 } ··· 4896 4896 params = ice_vsi_to_params(vsi); 4897 4897 params.flags = ICE_VSI_FLAG_INIT; 4898 4898 4899 + rtnl_lock(); 4899 4900 err = ice_vsi_cfg(vsi, &params); 4900 4901 if (err) 4901 4902 goto err_vsi_cfg; ··· 4904 4903 err = ice_start_eth(ice_get_main_vsi(pf)); 4905 4904 if (err) 4906 4905 goto err_start_eth; 4906 + rtnl_unlock(); 4907 4907 4908 4908 err = ice_init_rdma(pf); 4909 4909 if (err) ··· 4919 4917 4920 4918 err_init_rdma: 4921 4919 ice_vsi_close(ice_get_main_vsi(pf)); 4920 + rtnl_lock(); 4922 4921 err_start_eth: 4923 4922 ice_vsi_decfg(ice_get_main_vsi(pf)); 4924 4923 err_vsi_cfg: 4924 + rtnl_unlock(); 4925 4925 ice_deinit_dev(pf); 4926 4926 return err; 4927 4927 } ··· 4936 4932 { 4937 4933 ice_deinit_features(pf); 4938 4934 ice_deinit_rdma(pf); 4935 + rtnl_lock(); 4939 4936 ice_stop_eth(ice_get_main_vsi(pf)); 4940 4937 ice_vsi_decfg(ice_get_main_vsi(pf)); 4938 + rtnl_unlock(); 4941 4939 ice_deinit_dev(pf); 4942 4940 } 4943 4941
+2 -2
drivers/net/ethernet/intel/igc/igc_main.c
··· 2828 2828 struct netdev_queue *nq = txring_txq(ring); 2829 2829 union igc_adv_tx_desc *tx_desc = NULL; 2830 2830 int cpu = smp_processor_id(); 2831 - u16 ntu = ring->next_to_use; 2832 2831 struct xdp_desc xdp_desc; 2833 - u16 budget; 2832 + u16 budget, ntu; 2834 2833 2835 2834 if (!netif_carrier_ok(ring->netdev)) 2836 2835 return; ··· 2839 2840 /* Avoid transmit queue timeout since we share it with the slow path */ 2840 2841 txq_trans_cond_update(nq); 2841 2842 2843 + ntu = ring->next_to_use; 2842 2844 budget = igc_desc_unused(ring); 2843 2845 2844 2846 while (xsk_tx_peek_desc(pool, &xdp_desc) && budget--) {
+100 -37
drivers/net/ethernet/marvell/octeontx2/nic/cn10k_macsec.c
··· 4 4 * Copyright (C) 2022 Marvell. 5 5 */ 6 6 7 + #include <crypto/skcipher.h> 7 8 #include <linux/rtnetlink.h> 8 9 #include <linux/bitfield.h> 9 10 #include "otx2_common.h" ··· 42 41 #define MCS_TCI_SCB 0x10 /* epon */ 43 42 #define MCS_TCI_E 0x08 /* encryption */ 44 43 #define MCS_TCI_C 0x04 /* changed text */ 44 + 45 + #define CN10K_MAX_HASH_LEN 16 46 + #define CN10K_MAX_SAK_LEN 32 47 + 48 + static int cn10k_ecb_aes_encrypt(struct otx2_nic *pfvf, u8 *sak, 49 + u16 sak_len, u8 *hash) 50 + { 51 + u8 data[CN10K_MAX_HASH_LEN] = { 0 }; 52 + struct skcipher_request *req = NULL; 53 + struct scatterlist sg_src, sg_dst; 54 + struct crypto_skcipher *tfm; 55 + DECLARE_CRYPTO_WAIT(wait); 56 + int err; 57 + 58 + tfm = crypto_alloc_skcipher("ecb(aes)", 0, 0); 59 + if (IS_ERR(tfm)) { 60 + dev_err(pfvf->dev, "failed to allocate transform for ecb-aes\n"); 61 + return PTR_ERR(tfm); 62 + } 63 + 64 + req = skcipher_request_alloc(tfm, GFP_KERNEL); 65 + if (!req) { 66 + dev_err(pfvf->dev, "failed to allocate request for skcipher\n"); 67 + err = -ENOMEM; 68 + goto free_tfm; 69 + } 70 + 71 + err = crypto_skcipher_setkey(tfm, sak, sak_len); 72 + if (err) { 73 + dev_err(pfvf->dev, "failed to set key for skcipher\n"); 74 + goto free_req; 75 + } 76 + 77 + /* build sg list */ 78 + sg_init_one(&sg_src, data, CN10K_MAX_HASH_LEN); 79 + sg_init_one(&sg_dst, hash, CN10K_MAX_HASH_LEN); 80 + 81 + skcipher_request_set_callback(req, 0, crypto_req_done, &wait); 82 + skcipher_request_set_crypt(req, &sg_src, &sg_dst, 83 + CN10K_MAX_HASH_LEN, NULL); 84 + 85 + err = crypto_skcipher_encrypt(req); 86 + err = crypto_wait_req(err, &wait); 87 + 88 + free_req: 89 + skcipher_request_free(req); 90 + free_tfm: 91 + crypto_free_skcipher(tfm); 92 + return err; 93 + } 45 94 46 95 static struct cn10k_mcs_txsc *cn10k_mcs_get_txsc(struct cn10k_mcs_cfg *cfg, 47 96 struct macsec_secy *secy) ··· 381 330 return ret; 382 331 } 383 332 333 + static int cn10k_mcs_write_keys(struct otx2_nic *pfvf, 334 + struct macsec_secy *secy, 335 + struct mcs_sa_plcy_write_req *req, 336 + u8 *sak, u8 *salt, ssci_t ssci) 337 + { 338 + u8 hash_rev[CN10K_MAX_HASH_LEN]; 339 + u8 sak_rev[CN10K_MAX_SAK_LEN]; 340 + u8 salt_rev[MACSEC_SALT_LEN]; 341 + u8 hash[CN10K_MAX_HASH_LEN]; 342 + u32 ssci_63_32; 343 + int err, i; 344 + 345 + err = cn10k_ecb_aes_encrypt(pfvf, sak, secy->key_len, hash); 346 + if (err) { 347 + dev_err(pfvf->dev, "Generating hash using ECB(AES) failed\n"); 348 + return err; 349 + } 350 + 351 + for (i = 0; i < secy->key_len; i++) 352 + sak_rev[i] = sak[secy->key_len - 1 - i]; 353 + 354 + for (i = 0; i < CN10K_MAX_HASH_LEN; i++) 355 + hash_rev[i] = hash[CN10K_MAX_HASH_LEN - 1 - i]; 356 + 357 + for (i = 0; i < MACSEC_SALT_LEN; i++) 358 + salt_rev[i] = salt[MACSEC_SALT_LEN - 1 - i]; 359 + 360 + ssci_63_32 = (__force u32)cpu_to_be32((__force u32)ssci); 361 + 362 + memcpy(&req->plcy[0][0], sak_rev, secy->key_len); 363 + memcpy(&req->plcy[0][4], hash_rev, CN10K_MAX_HASH_LEN); 364 + memcpy(&req->plcy[0][6], salt_rev, MACSEC_SALT_LEN); 365 + req->plcy[0][7] |= (u64)ssci_63_32 << 32; 366 + 367 + return 0; 368 + } 369 + 384 370 static int cn10k_mcs_write_rx_sa_plcy(struct otx2_nic *pfvf, 385 371 struct macsec_secy *secy, 386 372 struct cn10k_mcs_rxsc *rxsc, 387 373 u8 assoc_num, bool sa_in_use) 388 374 { 389 - unsigned char *src = rxsc->sa_key[assoc_num]; 390 375 struct mcs_sa_plcy_write_req *plcy_req; 391 - u8 *salt_p = rxsc->salt[assoc_num]; 376 + u8 *sak = rxsc->sa_key[assoc_num]; 377 + u8 *salt = rxsc->salt[assoc_num]; 392 378 struct mcs_rx_sc_sa_map *map_req; 393 379 struct mbox *mbox = &pfvf->mbox; 394 - u64 ssci_salt_95_64 = 0; 395 - u8 reg, key_len; 396 - u64 salt_63_0; 397 380 int ret; 398 381 399 382 mutex_lock(&mbox->lock); ··· 445 360 goto fail; 446 361 } 447 362 448 - for (reg = 0, key_len = 0; key_len < secy->key_len; key_len += 8) { 449 - memcpy((u8 *)&plcy_req->plcy[0][reg], 450 - (src + reg * 8), 8); 451 - reg++; 452 - } 453 - 454 - if (secy->xpn) { 455 - memcpy((u8 *)&salt_63_0, salt_p, 8); 456 - memcpy((u8 *)&ssci_salt_95_64, salt_p + 8, 4); 457 - ssci_salt_95_64 |= (__force u64)rxsc->ssci[assoc_num] << 32; 458 - 459 - plcy_req->plcy[0][6] = salt_63_0; 460 - plcy_req->plcy[0][7] = ssci_salt_95_64; 461 - } 363 + ret = cn10k_mcs_write_keys(pfvf, secy, plcy_req, sak, 364 + salt, rxsc->ssci[assoc_num]); 365 + if (ret) 366 + goto fail; 462 367 463 368 plcy_req->sa_index[0] = rxsc->hw_sa_id[assoc_num]; 464 369 plcy_req->sa_cnt = 1; ··· 661 586 struct cn10k_mcs_txsc *txsc, 662 587 u8 assoc_num) 663 588 { 664 - unsigned char *src = txsc->sa_key[assoc_num]; 665 589 struct mcs_sa_plcy_write_req *plcy_req; 666 - u8 *salt_p = txsc->salt[assoc_num]; 590 + u8 *sak = txsc->sa_key[assoc_num]; 591 + u8 *salt = txsc->salt[assoc_num]; 667 592 struct mbox *mbox = &pfvf->mbox; 668 - u64 ssci_salt_95_64 = 0; 669 - u8 reg, key_len; 670 - u64 salt_63_0; 671 593 int ret; 672 594 673 595 mutex_lock(&mbox->lock); ··· 675 603 goto fail; 676 604 } 677 605 678 - for (reg = 0, key_len = 0; key_len < secy->key_len; key_len += 8) { 679 - memcpy((u8 *)&plcy_req->plcy[0][reg], (src + reg * 8), 8); 680 - reg++; 681 - } 682 - 683 - if (secy->xpn) { 684 - memcpy((u8 *)&salt_63_0, salt_p, 8); 685 - memcpy((u8 *)&ssci_salt_95_64, salt_p + 8, 4); 686 - ssci_salt_95_64 |= (__force u64)txsc->ssci[assoc_num] << 32; 687 - 688 - plcy_req->plcy[0][6] = salt_63_0; 689 - plcy_req->plcy[0][7] = ssci_salt_95_64; 690 - } 606 + ret = cn10k_mcs_write_keys(pfvf, secy, plcy_req, sak, 607 + salt, txsc->ssci[assoc_num]); 608 + if (ret) 609 + goto fail; 691 610 692 611 plcy_req->plcy[0][8] = assoc_num; 693 612 plcy_req->sa_index[0] = txsc->hw_sa_id[assoc_num];
+3 -2
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c
··· 1454 1454 if (err) 1455 1455 goto err_free_npa_lf; 1456 1456 1457 - /* Enable backpressure */ 1458 - otx2_nix_config_bp(pf, true); 1457 + /* Enable backpressure for CGX mapped PF/VFs */ 1458 + if (!is_otx2_lbkvf(pf->pdev)) 1459 + otx2_nix_config_bp(pf, true); 1459 1460 1460 1461 /* Init Auras and pools used by NIX RQ, for free buffer ptrs */ 1461 1462 err = otx2_rq_aura_pool_init(pf);
+11 -18
drivers/net/ethernet/mediatek/mtk_eth_soc.c
··· 3846 3846 return 0; 3847 3847 } 3848 3848 3849 - static int __init mtk_init(struct net_device *dev) 3850 - { 3851 - struct mtk_mac *mac = netdev_priv(dev); 3852 - struct mtk_eth *eth = mac->hw; 3853 - int ret; 3854 - 3855 - ret = of_get_ethdev_address(mac->of_node, dev); 3856 - if (ret) { 3857 - /* If the mac address is invalid, use random mac address */ 3858 - eth_hw_addr_random(dev); 3859 - dev_err(eth->dev, "generated random MAC address %pM\n", 3860 - dev->dev_addr); 3861 - } 3862 - 3863 - return 0; 3864 - } 3865 - 3866 3849 static void mtk_uninit(struct net_device *dev) 3867 3850 { 3868 3851 struct mtk_mac *mac = netdev_priv(dev); ··· 4261 4278 }; 4262 4279 4263 4280 static const struct net_device_ops mtk_netdev_ops = { 4264 - .ndo_init = mtk_init, 4265 4281 .ndo_uninit = mtk_uninit, 4266 4282 .ndo_open = mtk_open, 4267 4283 .ndo_stop = mtk_stop, ··· 4321 4339 mac->id = id; 4322 4340 mac->hw = eth; 4323 4341 mac->of_node = np; 4342 + 4343 + err = of_get_ethdev_address(mac->of_node, eth->netdev[id]); 4344 + if (err == -EPROBE_DEFER) 4345 + return err; 4346 + 4347 + if (err) { 4348 + /* If the mac address is invalid, use random mac address */ 4349 + eth_hw_addr_random(eth->netdev[id]); 4350 + dev_err(eth->dev, "generated random MAC address %pM\n", 4351 + eth->netdev[id]->dev_addr); 4352 + } 4324 4353 4325 4354 memset(mac->hwlro_ip, 0, sizeof(mac->hwlro_ip)); 4326 4355 mac->hwlro_ip_cnt = 0;
+1 -1
drivers/net/ethernet/mediatek/mtk_ppe_debugfs.c
··· 98 98 99 99 acct = mtk_foe_entry_get_mib(ppe, i, NULL); 100 100 101 - type = FIELD_GET(MTK_FOE_IB1_PACKET_TYPE, entry->ib1); 101 + type = mtk_get_ib1_pkt_type(ppe->eth, entry->ib1); 102 102 seq_printf(m, "%05x %s %7s", i, 103 103 mtk_foe_entry_state_str(state), 104 104 mtk_foe_pkt_type_str(type));
+2 -1
drivers/net/ethernet/mscc/ocelot_fdma.c
··· 368 368 if (unlikely(!ndev)) 369 369 return false; 370 370 371 - pskb_trim(skb, skb->len - ETH_FCS_LEN); 371 + if (pskb_trim(skb, skb->len - ETH_FCS_LEN)) 372 + return false; 372 373 373 374 skb->dev = ndev; 374 375 skb->protocol = eth_type_trans(skb, skb->dev);
+5 -2
drivers/net/ethernet/qualcomm/emac/emac-mac.c
··· 1260 1260 if (skb->protocol == htons(ETH_P_IP)) { 1261 1261 u32 pkt_len = ((unsigned char *)ip_hdr(skb) - skb->data) 1262 1262 + ntohs(ip_hdr(skb)->tot_len); 1263 - if (skb->len > pkt_len) 1264 - pskb_trim(skb, pkt_len); 1263 + if (skb->len > pkt_len) { 1264 + ret = pskb_trim(skb, pkt_len); 1265 + if (unlikely(ret)) 1266 + return ret; 1267 + } 1265 1268 } 1266 1269 1267 1270 hdr_len = skb_tcp_all_headers(skb);
+34 -11
drivers/net/ethernet/realtek/r8169_main.c
··· 623 623 int cfg9346_usage_count; 624 624 625 625 unsigned supports_gmii:1; 626 + unsigned aspm_manageable:1; 626 627 dma_addr_t counters_phys_addr; 627 628 struct rtl8169_counters *counters; 628 629 struct rtl8169_tc_offsets tc_offset; ··· 2747 2746 if (tp->mac_version < RTL_GIGA_MAC_VER_32) 2748 2747 return; 2749 2748 2750 - if (enable) { 2749 + /* Don't enable ASPM in the chip if OS can't control ASPM */ 2750 + if (enable && tp->aspm_manageable) { 2751 + /* On these chip versions ASPM can even harm 2752 + * bus communication of other PCI devices. 2753 + */ 2754 + if (tp->mac_version == RTL_GIGA_MAC_VER_42 || 2755 + tp->mac_version == RTL_GIGA_MAC_VER_43) 2756 + return; 2757 + 2751 2758 rtl_mod_config5(tp, 0, ASPM_en); 2752 2759 rtl_mod_config2(tp, 0, ClkReqEn); 2753 2760 ··· 4523 4514 } 4524 4515 4525 4516 if (napi_schedule_prep(&tp->napi)) { 4526 - rtl_unlock_config_regs(tp); 4527 - rtl_hw_aspm_clkreq_enable(tp, false); 4528 - rtl_lock_config_regs(tp); 4529 - 4530 4517 rtl_irq_disable(tp); 4531 4518 __napi_schedule(&tp->napi); 4532 4519 } ··· 4582 4577 4583 4578 work_done = rtl_rx(dev, tp, budget); 4584 4579 4585 - if (work_done < budget && napi_complete_done(napi, work_done)) { 4580 + if (work_done < budget && napi_complete_done(napi, work_done)) 4586 4581 rtl_irq_enable(tp); 4587 - 4588 - rtl_unlock_config_regs(tp); 4589 - rtl_hw_aspm_clkreq_enable(tp, true); 4590 - rtl_lock_config_regs(tp); 4591 - } 4592 4582 4593 4583 return work_done; 4594 4584 } ··· 5158 5158 rtl_rar_set(tp, mac_addr); 5159 5159 } 5160 5160 5161 + /* register is set if system vendor successfully tested ASPM 1.2 */ 5162 + static bool rtl_aspm_is_safe(struct rtl8169_private *tp) 5163 + { 5164 + if (tp->mac_version >= RTL_GIGA_MAC_VER_61 && 5165 + r8168_mac_ocp_read(tp, 0xc0b2) & 0xf) 5166 + return true; 5167 + 5168 + return false; 5169 + } 5170 + 5161 5171 static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) 5162 5172 { 5163 5173 struct rtl8169_private *tp; ··· 5236 5226 "unknown chip XID %03x, contact r8169 maintainers (see MAINTAINERS file)\n", 5237 5227 xid); 5238 5228 tp->mac_version = chipset; 5229 + 5230 + /* Disable ASPM L1 as that cause random device stop working 5231 + * problems as well as full system hangs for some PCIe devices users. 5232 + * Chips from RTL8168h partially have issues with L1.2, but seem 5233 + * to work fine with L1 and L1.1. 5234 + */ 5235 + if (rtl_aspm_is_safe(tp)) 5236 + rc = 0; 5237 + else if (tp->mac_version >= RTL_GIGA_MAC_VER_46) 5238 + rc = pci_disable_link_state(pdev, PCIE_LINK_STATE_L1_2); 5239 + else 5240 + rc = pci_disable_link_state(pdev, PCIE_LINK_STATE_L1); 5241 + tp->aspm_manageable = !rc; 5239 5242 5240 5243 tp->dash_type = rtl_check_dash(tp); 5241 5244
+19 -5
drivers/net/ethernet/ti/cpsw_ale.c
··· 106 106 107 107 static inline int cpsw_ale_get_field(u32 *ale_entry, u32 start, u32 bits) 108 108 { 109 - int idx; 109 + int idx, idx2; 110 + u32 hi_val = 0; 110 111 111 112 idx = start / 32; 113 + idx2 = (start + bits - 1) / 32; 114 + /* Check if bits to be fetched exceed a word */ 115 + if (idx != idx2) { 116 + idx2 = 2 - idx2; /* flip */ 117 + hi_val = ale_entry[idx2] << ((idx2 * 32) - start); 118 + } 112 119 start -= idx * 32; 113 120 idx = 2 - idx; /* flip */ 114 - return (ale_entry[idx] >> start) & BITMASK(bits); 121 + return (hi_val + (ale_entry[idx] >> start)) & BITMASK(bits); 115 122 } 116 123 117 124 static inline void cpsw_ale_set_field(u32 *ale_entry, u32 start, u32 bits, 118 125 u32 value) 119 126 { 120 - int idx; 127 + int idx, idx2; 121 128 122 129 value &= BITMASK(bits); 123 - idx = start / 32; 130 + idx = start / 32; 131 + idx2 = (start + bits - 1) / 32; 132 + /* Check if bits to be set exceed a word */ 133 + if (idx != idx2) { 134 + idx2 = 2 - idx2; /* flip */ 135 + ale_entry[idx2] &= ~(BITMASK(bits + start - (idx2 * 32))); 136 + ale_entry[idx2] |= (value >> ((idx2 * 32) - start)); 137 + } 124 138 start -= idx * 32; 125 - idx = 2 - idx; /* flip */ 139 + idx = 2 - idx; /* flip */ 126 140 ale_entry[idx] &= ~(BITMASK(bits) << start); 127 141 ale_entry[idx] |= (value << start); 128 142 }
-1
drivers/net/ethernet/wangxun/libwx/wx_hw.c
··· 1446 1446 psrtype = WX_RDB_PL_CFG_L4HDR | 1447 1447 WX_RDB_PL_CFG_L3HDR | 1448 1448 WX_RDB_PL_CFG_L2HDR | 1449 - WX_RDB_PL_CFG_TUN_TUNHDR | 1450 1449 WX_RDB_PL_CFG_TUN_TUNHDR; 1451 1450 wr32(wx, WX_RDB_PL_CFG(0), psrtype); 1452 1451
+14 -7
drivers/net/phy/phy_device.c
··· 3451 3451 { 3452 3452 int rc; 3453 3453 3454 + ethtool_set_ethtool_phy_ops(&phy_ethtool_phy_ops); 3455 + 3454 3456 rc = mdio_bus_init(); 3455 3457 if (rc) 3456 - return rc; 3458 + goto err_ethtool_phy_ops; 3457 3459 3458 - ethtool_set_ethtool_phy_ops(&phy_ethtool_phy_ops); 3459 3460 features_init(); 3460 3461 3461 3462 rc = phy_driver_register(&genphy_c45_driver, THIS_MODULE); 3462 3463 if (rc) 3463 - goto err_c45; 3464 + goto err_mdio_bus; 3464 3465 3465 3466 rc = phy_driver_register(&genphy_driver, THIS_MODULE); 3466 - if (rc) { 3467 - phy_driver_unregister(&genphy_c45_driver); 3467 + if (rc) 3468 + goto err_c45; 3469 + 3470 + return 0; 3471 + 3468 3472 err_c45: 3469 - mdio_bus_exit(); 3470 - } 3473 + phy_driver_unregister(&genphy_c45_driver); 3474 + err_mdio_bus: 3475 + mdio_bus_exit(); 3476 + err_ethtool_phy_ops: 3477 + ethtool_set_ethtool_phy_ops(NULL); 3471 3478 3472 3479 return rc; 3473 3480 }
+6
drivers/net/usb/usbnet.c
··· 1775 1775 } else if (!info->in || !info->out) 1776 1776 status = usbnet_get_endpoints (dev, udev); 1777 1777 else { 1778 + u8 ep_addrs[3] = { 1779 + info->in + USB_DIR_IN, info->out + USB_DIR_OUT, 0 1780 + }; 1781 + 1778 1782 dev->in = usb_rcvbulkpipe (xdev, info->in); 1779 1783 dev->out = usb_sndbulkpipe (xdev, info->out); 1780 1784 if (!(info->flags & FLAG_NO_SETINT)) ··· 1788 1784 else 1789 1785 status = 0; 1790 1786 1787 + if (status == 0 && !usb_check_bulk_endpoints(udev, ep_addrs)) 1788 + status = -EINVAL; 1791 1789 } 1792 1790 if (status >= 0 && dev->status) 1793 1791 status = init_status (dev, udev);
+6 -6
drivers/net/vrf.c
··· 664 664 skb->protocol = htons(ETH_P_IPV6); 665 665 skb->dev = dev; 666 666 667 - rcu_read_lock_bh(); 667 + rcu_read_lock(); 668 668 nexthop = rt6_nexthop((struct rt6_info *)dst, &ipv6_hdr(skb)->daddr); 669 669 neigh = __ipv6_neigh_lookup_noref(dst->dev, nexthop); 670 670 if (unlikely(!neigh)) ··· 672 672 if (!IS_ERR(neigh)) { 673 673 sock_confirm_neigh(skb, neigh); 674 674 ret = neigh_output(neigh, skb, false); 675 - rcu_read_unlock_bh(); 675 + rcu_read_unlock(); 676 676 return ret; 677 677 } 678 - rcu_read_unlock_bh(); 678 + rcu_read_unlock(); 679 679 680 680 IP6_INC_STATS(dev_net(dst->dev), 681 681 ip6_dst_idev(dst), IPSTATS_MIB_OUTNOROUTES); ··· 889 889 } 890 890 } 891 891 892 - rcu_read_lock_bh(); 892 + rcu_read_lock(); 893 893 894 894 neigh = ip_neigh_for_gw(rt, skb, &is_v6gw); 895 895 if (!IS_ERR(neigh)) { ··· 898 898 sock_confirm_neigh(skb, neigh); 899 899 /* if crossing protocols, can not use the cached header */ 900 900 ret = neigh_output(neigh, skb, is_v6gw); 901 - rcu_read_unlock_bh(); 901 + rcu_read_unlock(); 902 902 return ret; 903 903 } 904 904 905 - rcu_read_unlock_bh(); 905 + rcu_read_unlock(); 906 906 vrf_tx_error(skb->dev, skb); 907 907 return -EINVAL; 908 908 }
+33 -3
drivers/nvme/host/core.c
··· 3431 3431 3432 3432 ret = nvme_global_check_duplicate_ids(ctrl->subsys, &info->ids); 3433 3433 if (ret) { 3434 - dev_err(ctrl->device, 3435 - "globally duplicate IDs for nsid %d\n", info->nsid); 3434 + /* 3435 + * We've found two different namespaces on two different 3436 + * subsystems that report the same ID. This is pretty nasty 3437 + * for anything that actually requires unique device 3438 + * identification. In the kernel we need this for multipathing, 3439 + * and in user space the /dev/disk/by-id/ links rely on it. 3440 + * 3441 + * If the device also claims to be multi-path capable back off 3442 + * here now and refuse the probe the second device as this is a 3443 + * recipe for data corruption. If not this is probably a 3444 + * cheap consumer device if on the PCIe bus, so let the user 3445 + * proceed and use the shiny toy, but warn that with changing 3446 + * probing order (which due to our async probing could just be 3447 + * device taking longer to startup) the other device could show 3448 + * up at any time. 3449 + */ 3436 3450 nvme_print_device_info(ctrl); 3437 - return ret; 3451 + if ((ns->ctrl->ops->flags & NVME_F_FABRICS) || /* !PCIe */ 3452 + ((ns->ctrl->subsys->cmic & NVME_CTRL_CMIC_MULTI_CTRL) && 3453 + info->is_shared)) { 3454 + dev_err(ctrl->device, 3455 + "ignoring nsid %d because of duplicate IDs\n", 3456 + info->nsid); 3457 + return ret; 3458 + } 3459 + 3460 + dev_err(ctrl->device, 3461 + "clearing duplicate IDs for nsid %d\n", info->nsid); 3462 + dev_err(ctrl->device, 3463 + "use of /dev/disk/by-id/ may cause data corruption\n"); 3464 + memset(&info->ids.nguid, 0, sizeof(info->ids.nguid)); 3465 + memset(&info->ids.uuid, 0, sizeof(info->ids.uuid)); 3466 + memset(&info->ids.eui64, 0, sizeof(info->ids.eui64)); 3467 + ctrl->quirks |= NVME_QUIRK_BOGUS_NID; 3438 3468 } 3439 3469 3440 3470 mutex_lock(&ctrl->subsys->lock);
+1 -1
drivers/nvme/host/fault_inject.c
··· 27 27 28 28 /* create debugfs directory and attribute */ 29 29 parent = debugfs_create_dir(dev_name, NULL); 30 - if (!parent) { 30 + if (IS_ERR(parent)) { 31 31 pr_warn("%s: failed to create debugfs directory\n", dev_name); 32 32 return; 33 33 }
+30 -7
drivers/nvme/host/fc.c
··· 2548 2548 * the controller. Abort any ios on the association and let the 2549 2549 * create_association error path resolve things. 2550 2550 */ 2551 - if (ctrl->ctrl.state == NVME_CTRL_CONNECTING) { 2552 - __nvme_fc_abort_outstanding_ios(ctrl, true); 2551 + enum nvme_ctrl_state state; 2552 + unsigned long flags; 2553 + 2554 + spin_lock_irqsave(&ctrl->lock, flags); 2555 + state = ctrl->ctrl.state; 2556 + if (state == NVME_CTRL_CONNECTING) { 2553 2557 set_bit(ASSOC_FAILED, &ctrl->flags); 2558 + spin_unlock_irqrestore(&ctrl->lock, flags); 2559 + __nvme_fc_abort_outstanding_ios(ctrl, true); 2560 + dev_warn(ctrl->ctrl.device, 2561 + "NVME-FC{%d}: transport error during (re)connect\n", 2562 + ctrl->cnum); 2554 2563 return; 2555 2564 } 2565 + spin_unlock_irqrestore(&ctrl->lock, flags); 2556 2566 2557 2567 /* Otherwise, only proceed if in LIVE state - e.g. on first error */ 2558 - if (ctrl->ctrl.state != NVME_CTRL_LIVE) 2568 + if (state != NVME_CTRL_LIVE) 2559 2569 return; 2560 2570 2561 2571 dev_warn(ctrl->ctrl.device, ··· 3120 3110 */ 3121 3111 3122 3112 ret = nvme_enable_ctrl(&ctrl->ctrl); 3123 - if (ret || test_bit(ASSOC_FAILED, &ctrl->flags)) 3113 + if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags)) 3114 + ret = -EIO; 3115 + if (ret) 3124 3116 goto out_disconnect_admin_queue; 3125 3117 3126 3118 ctrl->ctrl.max_segments = ctrl->lport->ops->max_sgl_segments; ··· 3132 3120 nvme_unquiesce_admin_queue(&ctrl->ctrl); 3133 3121 3134 3122 ret = nvme_init_ctrl_finish(&ctrl->ctrl, false); 3135 - if (ret || test_bit(ASSOC_FAILED, &ctrl->flags)) 3123 + if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags)) 3124 + ret = -EIO; 3125 + if (ret) 3136 3126 goto out_disconnect_admin_queue; 3137 3127 3138 3128 /* sanity checks */ ··· 3179 3165 else 3180 3166 ret = nvme_fc_recreate_io_queues(ctrl); 3181 3167 } 3182 - if (ret || test_bit(ASSOC_FAILED, &ctrl->flags)) 3183 - goto out_term_aen_ops; 3184 3168 3169 + spin_lock_irqsave(&ctrl->lock, flags); 3170 + if (!ret && test_bit(ASSOC_FAILED, &ctrl->flags)) 3171 + ret = -EIO; 3172 + if (ret) { 3173 + spin_unlock_irqrestore(&ctrl->lock, flags); 3174 + goto out_term_aen_ops; 3175 + } 3185 3176 changed = nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_LIVE); 3177 + spin_unlock_irqrestore(&ctrl->lock, flags); 3186 3178 3187 3179 ctrl->ctrl.nr_reconnects = 0; 3188 3180 ··· 3200 3180 out_term_aen_ops: 3201 3181 nvme_fc_term_aen_ops(ctrl); 3202 3182 out_disconnect_admin_queue: 3183 + dev_warn(ctrl->ctrl.device, 3184 + "NVME-FC{%d}: create_assoc failed, assoc_id %llx ret %d\n", 3185 + ctrl->cnum, ctrl->association_id, ret); 3203 3186 /* send a Disconnect(association) LS to fc-nvme target */ 3204 3187 nvme_fc_xmt_disconnect_assoc(ctrl); 3205 3188 spin_lock_irqsave(&ctrl->lock, flags);
+20 -9
drivers/nvme/host/pci.c
··· 967 967 struct nvme_iod *iod = blk_mq_rq_to_pdu(req); 968 968 969 969 dma_unmap_page(dev->dev, iod->meta_dma, 970 - rq_integrity_vec(req)->bv_len, rq_data_dir(req)); 970 + rq_integrity_vec(req)->bv_len, rq_dma_dir(req)); 971 971 } 972 972 973 973 if (blk_rq_nr_phys_segments(req)) ··· 1298 1298 */ 1299 1299 if (nvme_should_reset(dev, csts)) { 1300 1300 nvme_warn_reset(dev, csts); 1301 - nvme_dev_disable(dev, false); 1302 - nvme_reset_ctrl(&dev->ctrl); 1303 - return BLK_EH_DONE; 1301 + goto disable; 1304 1302 } 1305 1303 1306 1304 /* ··· 1349 1351 "I/O %d QID %d timeout, reset controller\n", 1350 1352 req->tag, nvmeq->qid); 1351 1353 nvme_req(req)->flags |= NVME_REQ_CANCELLED; 1352 - nvme_dev_disable(dev, false); 1353 - nvme_reset_ctrl(&dev->ctrl); 1354 - 1355 - return BLK_EH_DONE; 1354 + goto disable; 1356 1355 } 1357 1356 1358 1357 if (atomic_dec_return(&dev->ctrl.abort_limit) < 0) { ··· 1386 1391 * as the device then is in a faulty state. 1387 1392 */ 1388 1393 return BLK_EH_RESET_TIMER; 1394 + 1395 + disable: 1396 + if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_RESETTING)) 1397 + return BLK_EH_DONE; 1398 + 1399 + nvme_dev_disable(dev, false); 1400 + if (nvme_try_sched_reset(&dev->ctrl)) 1401 + nvme_unquiesce_io_queues(&dev->ctrl); 1402 + return BLK_EH_DONE; 1389 1403 } 1390 1404 1391 1405 static void nvme_free_queue(struct nvme_queue *nvmeq) ··· 3282 3278 case pci_channel_io_frozen: 3283 3279 dev_warn(dev->ctrl.device, 3284 3280 "frozen state error detected, reset controller\n"); 3281 + if (!nvme_change_ctrl_state(&dev->ctrl, NVME_CTRL_RESETTING)) { 3282 + nvme_dev_disable(dev, true); 3283 + return PCI_ERS_RESULT_DISCONNECT; 3284 + } 3285 3285 nvme_dev_disable(dev, false); 3286 3286 return PCI_ERS_RESULT_NEED_RESET; 3287 3287 case pci_channel_io_perm_failure: ··· 3302 3294 3303 3295 dev_info(dev->ctrl.device, "restart after slot reset\n"); 3304 3296 pci_restore_state(pdev); 3305 - nvme_reset_ctrl(&dev->ctrl); 3297 + if (!nvme_try_sched_reset(&dev->ctrl)) 3298 + nvme_unquiesce_io_queues(&dev->ctrl); 3306 3299 return PCI_ERS_RESULT_RECOVERED; 3307 3300 } 3308 3301 ··· 3405 3396 .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, 3406 3397 { PCI_DEVICE(0x144d, 0xa809), /* Samsung MZALQ256HBJD 256G */ 3407 3398 .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, 3399 + { PCI_DEVICE(0x144d, 0xa802), /* Samsung SM953 */ 3400 + .driver_data = NVME_QUIRK_BOGUS_NID, }, 3408 3401 { PCI_DEVICE(0x1cc4, 0x6303), /* UMIS RPJTJ512MGE1QDY 512G */ 3409 3402 .driver_data = NVME_QUIRK_DISABLE_WRITE_ZEROES, }, 3410 3403 { PCI_DEVICE(0x1cc4, 0x6302), /* UMIS RPJTJ256MGE1QDY 256G */
+1 -1
drivers/nvme/host/sysfs.c
··· 92 92 * we have no UUID set 93 93 */ 94 94 if (uuid_is_null(&ids->uuid)) { 95 - dev_warn_ratelimited(dev, 95 + dev_warn_once(dev, 96 96 "No UUID available providing old NGUID\n"); 97 97 return sysfs_emit(buf, "%pU\n", ids->nguid); 98 98 }
+4 -5
drivers/nvme/host/zns.c
··· 10 10 int nvme_revalidate_zones(struct nvme_ns *ns) 11 11 { 12 12 struct request_queue *q = ns->queue; 13 - int ret; 14 13 15 - ret = blk_revalidate_disk_zones(ns->disk, NULL); 16 - if (!ret) 17 - blk_queue_max_zone_append_sectors(q, ns->ctrl->max_zone_append); 18 - return ret; 14 + blk_queue_chunk_sectors(q, ns->zsze); 15 + blk_queue_max_zone_append_sectors(q, ns->ctrl->max_zone_append); 16 + 17 + return blk_revalidate_disk_zones(ns->disk, NULL); 19 18 } 20 19 21 20 static int nvme_set_max_append(struct nvme_ctrl *ctrl)
+1 -1
drivers/nvme/target/loop.c
··· 373 373 goto out_cleanup_tagset; 374 374 375 375 ctrl->ctrl.max_hw_sectors = 376 - (NVME_LOOP_MAX_SEGMENTS - 1) << (PAGE_SHIFT - 9); 376 + (NVME_LOOP_MAX_SEGMENTS - 1) << PAGE_SECTORS_SHIFT; 377 377 378 378 nvme_unquiesce_admin_queue(&ctrl->ctrl); 379 379
+2 -2
drivers/nvme/target/passthru.c
··· 102 102 * which depends on the host's memory fragementation. To solve this, 103 103 * ensure mdts is limited to the pages equal to the number of segments. 104 104 */ 105 - max_hw_sectors = min_not_zero(pctrl->max_segments << (PAGE_SHIFT - 9), 105 + max_hw_sectors = min_not_zero(pctrl->max_segments << PAGE_SECTORS_SHIFT, 106 106 pctrl->max_hw_sectors); 107 107 108 108 /* 109 109 * nvmet_passthru_map_sg is limitted to using a single bio so limit 110 110 * the mdts based on BIO_MAX_VECS as well 111 111 */ 112 - max_hw_sectors = min_not_zero(BIO_MAX_VECS << (PAGE_SHIFT - 9), 112 + max_hw_sectors = min_not_zero(BIO_MAX_VECS << PAGE_SECTORS_SHIFT, 113 113 max_hw_sectors); 114 114 115 115 page_shift = NVME_CAP_MPSMIN(ctrl->cap) + 12;
-3
drivers/perf/riscv_pmu.c
··· 181 181 uint64_t max_period = riscv_pmu_ctr_get_width_mask(event); 182 182 u64 init_val; 183 183 184 - if (WARN_ON_ONCE(!(event->hw.state & PERF_HES_STOPPED))) 185 - return; 186 - 187 184 if (flags & PERF_EF_RELOAD) 188 185 WARN_ON_ONCE(!(event->hw.state & PERF_HES_UPTODATE)); 189 186
+23 -38
drivers/pinctrl/pinctrl-amd.c
··· 116 116 raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); 117 117 } 118 118 119 - static int amd_gpio_set_debounce(struct gpio_chip *gc, unsigned offset, 120 - unsigned debounce) 119 + static int amd_gpio_set_debounce(struct amd_gpio *gpio_dev, unsigned int offset, 120 + unsigned int debounce) 121 121 { 122 122 u32 time; 123 123 u32 pin_reg; 124 124 int ret = 0; 125 - unsigned long flags; 126 - struct amd_gpio *gpio_dev = gpiochip_get_data(gc); 127 - 128 - raw_spin_lock_irqsave(&gpio_dev->lock, flags); 129 125 130 126 /* Use special handling for Pin0 debounce */ 131 - pin_reg = readl(gpio_dev->base + WAKE_INT_MASTER_REG); 132 - if (pin_reg & INTERNAL_GPIO0_DEBOUNCE) 133 - debounce = 0; 127 + if (offset == 0) { 128 + pin_reg = readl(gpio_dev->base + WAKE_INT_MASTER_REG); 129 + if (pin_reg & INTERNAL_GPIO0_DEBOUNCE) 130 + debounce = 0; 131 + } 134 132 135 133 pin_reg = readl(gpio_dev->base + offset * 4); 136 134 ··· 180 182 pin_reg &= ~(DB_CNTRl_MASK << DB_CNTRL_OFF); 181 183 } 182 184 writel(pin_reg, gpio_dev->base + offset * 4); 183 - raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); 184 185 185 186 return ret; 186 - } 187 - 188 - static int amd_gpio_set_config(struct gpio_chip *gc, unsigned offset, 189 - unsigned long config) 190 - { 191 - u32 debounce; 192 - 193 - if (pinconf_to_config_param(config) != PIN_CONFIG_INPUT_DEBOUNCE) 194 - return -ENOTSUPP; 195 - 196 - debounce = pinconf_to_config_argument(config); 197 - return amd_gpio_set_debounce(gc, offset, debounce); 198 187 } 199 188 200 189 #ifdef CONFIG_DEBUG_FS ··· 205 220 char *pin_sts; 206 221 char *interrupt_sts; 207 222 char *wake_sts; 208 - char *pull_up_sel; 209 223 char *orientation; 210 224 char debounce_value[40]; 211 225 char *debounce_enable; ··· 312 328 seq_printf(s, " %s|", wake_sts); 313 329 314 330 if (pin_reg & BIT(PULL_UP_ENABLE_OFF)) { 315 - if (pin_reg & BIT(PULL_UP_SEL_OFF)) 316 - pull_up_sel = "8k"; 317 - else 318 - pull_up_sel = "4k"; 319 - seq_printf(s, "%s ↑|", 320 - pull_up_sel); 331 + seq_puts(s, " ↑ |"); 321 332 } else if (pin_reg & BIT(PULL_DOWN_ENABLE_OFF)) { 322 - seq_puts(s, " ↓|"); 333 + seq_puts(s, " ↓ |"); 323 334 } else { 324 335 seq_puts(s, " |"); 325 336 } ··· 740 761 break; 741 762 742 763 case PIN_CONFIG_BIAS_PULL_UP: 743 - arg = (pin_reg >> PULL_UP_SEL_OFF) & (BIT(0) | BIT(1)); 764 + arg = (pin_reg >> PULL_UP_ENABLE_OFF) & BIT(0); 744 765 break; 745 766 746 767 case PIN_CONFIG_DRIVE_STRENGTH: ··· 759 780 } 760 781 761 782 static int amd_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, 762 - unsigned long *configs, unsigned num_configs) 783 + unsigned long *configs, unsigned int num_configs) 763 784 { 764 785 int i; 765 786 u32 arg; ··· 777 798 778 799 switch (param) { 779 800 case PIN_CONFIG_INPUT_DEBOUNCE: 780 - pin_reg &= ~DB_TMR_OUT_MASK; 781 - pin_reg |= arg & DB_TMR_OUT_MASK; 782 - break; 801 + ret = amd_gpio_set_debounce(gpio_dev, pin, arg); 802 + goto out_unlock; 783 803 784 804 case PIN_CONFIG_BIAS_PULL_DOWN: 785 805 pin_reg &= ~BIT(PULL_DOWN_ENABLE_OFF); ··· 786 808 break; 787 809 788 810 case PIN_CONFIG_BIAS_PULL_UP: 789 - pin_reg &= ~BIT(PULL_UP_SEL_OFF); 790 - pin_reg |= (arg & BIT(0)) << PULL_UP_SEL_OFF; 791 811 pin_reg &= ~BIT(PULL_UP_ENABLE_OFF); 792 - pin_reg |= ((arg>>1) & BIT(0)) << PULL_UP_ENABLE_OFF; 812 + pin_reg |= (arg & BIT(0)) << PULL_UP_ENABLE_OFF; 793 813 break; 794 814 795 815 case PIN_CONFIG_DRIVE_STRENGTH: ··· 805 829 806 830 writel(pin_reg, gpio_dev->base + pin*4); 807 831 } 832 + out_unlock: 808 833 raw_spin_unlock_irqrestore(&gpio_dev->lock, flags); 809 834 810 835 return ret; ··· 845 868 return -ENOTSUPP; 846 869 } 847 870 return 0; 871 + } 872 + 873 + static int amd_gpio_set_config(struct gpio_chip *gc, unsigned int pin, 874 + unsigned long config) 875 + { 876 + struct amd_gpio *gpio_dev = gpiochip_get_data(gc); 877 + 878 + return amd_pinconf_set(gpio_dev->pctrl, pin, &config, 1); 848 879 } 849 880 850 881 static const struct pinconf_ops amd_pinconf_ops = {
-1
drivers/pinctrl/pinctrl-amd.h
··· 36 36 #define WAKE_CNTRL_OFF_S4 15 37 37 #define PIN_STS_OFF 16 38 38 #define DRV_STRENGTH_SEL_OFF 17 39 - #define PULL_UP_SEL_OFF 19 40 39 #define PULL_UP_ENABLE_OFF 20 41 40 #define PULL_DOWN_ENABLE_OFF 21 42 41 #define OUTPUT_VALUE_OFF 22
+20 -8
drivers/pinctrl/renesas/pinctrl-rzg2l.c
··· 249 249 250 250 static int rzg2l_dt_subnode_to_map(struct pinctrl_dev *pctldev, 251 251 struct device_node *np, 252 + struct device_node *parent, 252 253 struct pinctrl_map **map, 253 254 unsigned int *num_maps, 254 255 unsigned int *index) ··· 267 266 struct property *prop; 268 267 int ret, gsel, fsel; 269 268 const char **pin_fn; 269 + const char *name; 270 270 const char *pin; 271 271 272 272 pinmux = of_find_property(np, "pinmux", NULL); ··· 351 349 psel_val[i] = MUX_FUNC(value); 352 350 } 353 351 352 + if (parent) { 353 + name = devm_kasprintf(pctrl->dev, GFP_KERNEL, "%pOFn.%pOFn", 354 + parent, np); 355 + if (!name) { 356 + ret = -ENOMEM; 357 + goto done; 358 + } 359 + } else { 360 + name = np->name; 361 + } 362 + 354 363 /* Register a single pin group listing all the pins we read from DT */ 355 - gsel = pinctrl_generic_add_group(pctldev, np->name, pins, num_pinmux, NULL); 364 + gsel = pinctrl_generic_add_group(pctldev, name, pins, num_pinmux, NULL); 356 365 if (gsel < 0) { 357 366 ret = gsel; 358 367 goto done; ··· 373 360 * Register a single group function where the 'data' is an array PSEL 374 361 * register values read from DT. 375 362 */ 376 - pin_fn[0] = np->name; 377 - fsel = pinmux_generic_add_function(pctldev, np->name, pin_fn, 1, 378 - psel_val); 363 + pin_fn[0] = name; 364 + fsel = pinmux_generic_add_function(pctldev, name, pin_fn, 1, psel_val); 379 365 if (fsel < 0) { 380 366 ret = fsel; 381 367 goto remove_group; 382 368 } 383 369 384 370 maps[idx].type = PIN_MAP_TYPE_MUX_GROUP; 385 - maps[idx].data.mux.group = np->name; 386 - maps[idx].data.mux.function = np->name; 371 + maps[idx].data.mux.group = name; 372 + maps[idx].data.mux.function = name; 387 373 idx++; 388 374 389 375 dev_dbg(pctrl->dev, "Parsed %pOF with %d pins\n", np, num_pinmux); ··· 429 417 index = 0; 430 418 431 419 for_each_child_of_node(np, child) { 432 - ret = rzg2l_dt_subnode_to_map(pctldev, child, map, 420 + ret = rzg2l_dt_subnode_to_map(pctldev, child, np, map, 433 421 num_maps, &index); 434 422 if (ret < 0) { 435 423 of_node_put(child); ··· 438 426 } 439 427 440 428 if (*num_maps == 0) { 441 - ret = rzg2l_dt_subnode_to_map(pctldev, np, map, 429 + ret = rzg2l_dt_subnode_to_map(pctldev, np, NULL, map, 442 430 num_maps, &index); 443 431 if (ret < 0) 444 432 goto done;
+20 -8
drivers/pinctrl/renesas/pinctrl-rzv2m.c
··· 209 209 210 210 static int rzv2m_dt_subnode_to_map(struct pinctrl_dev *pctldev, 211 211 struct device_node *np, 212 + struct device_node *parent, 212 213 struct pinctrl_map **map, 213 214 unsigned int *num_maps, 214 215 unsigned int *index) ··· 227 226 struct property *prop; 228 227 int ret, gsel, fsel; 229 228 const char **pin_fn; 229 + const char *name; 230 230 const char *pin; 231 231 232 232 pinmux = of_find_property(np, "pinmux", NULL); ··· 311 309 psel_val[i] = MUX_FUNC(value); 312 310 } 313 311 312 + if (parent) { 313 + name = devm_kasprintf(pctrl->dev, GFP_KERNEL, "%pOFn.%pOFn", 314 + parent, np); 315 + if (!name) { 316 + ret = -ENOMEM; 317 + goto done; 318 + } 319 + } else { 320 + name = np->name; 321 + } 322 + 314 323 /* Register a single pin group listing all the pins we read from DT */ 315 - gsel = pinctrl_generic_add_group(pctldev, np->name, pins, num_pinmux, NULL); 324 + gsel = pinctrl_generic_add_group(pctldev, name, pins, num_pinmux, NULL); 316 325 if (gsel < 0) { 317 326 ret = gsel; 318 327 goto done; ··· 333 320 * Register a single group function where the 'data' is an array PSEL 334 321 * register values read from DT. 335 322 */ 336 - pin_fn[0] = np->name; 337 - fsel = pinmux_generic_add_function(pctldev, np->name, pin_fn, 1, 338 - psel_val); 323 + pin_fn[0] = name; 324 + fsel = pinmux_generic_add_function(pctldev, name, pin_fn, 1, psel_val); 339 325 if (fsel < 0) { 340 326 ret = fsel; 341 327 goto remove_group; 342 328 } 343 329 344 330 maps[idx].type = PIN_MAP_TYPE_MUX_GROUP; 345 - maps[idx].data.mux.group = np->name; 346 - maps[idx].data.mux.function = np->name; 331 + maps[idx].data.mux.group = name; 332 + maps[idx].data.mux.function = name; 347 333 idx++; 348 334 349 335 dev_dbg(pctrl->dev, "Parsed %pOF with %d pins\n", np, num_pinmux); ··· 389 377 index = 0; 390 378 391 379 for_each_child_of_node(np, child) { 392 - ret = rzv2m_dt_subnode_to_map(pctldev, child, map, 380 + ret = rzv2m_dt_subnode_to_map(pctldev, child, np, map, 393 381 num_maps, &index); 394 382 if (ret < 0) { 395 383 of_node_put(child); ··· 398 386 } 399 387 400 388 if (*num_maps == 0) { 401 - ret = rzv2m_dt_subnode_to_map(pctldev, np, map, 389 + ret = rzv2m_dt_subnode_to_map(pctldev, np, NULL, map, 402 390 num_maps, &index); 403 391 if (ret < 0) 404 392 goto done;
+3
drivers/regulator/da9063-regulator.c
··· 778 778 const struct notification_limit *uv_l = &constr->under_voltage_limits; 779 779 const struct notification_limit *ov_l = &constr->over_voltage_limits; 780 780 781 + if (!config->init_data) /* No config in DT, pointers will be invalid */ 782 + return 0; 783 + 781 784 /* make sure that only one severity is used to clarify if unchanged, enabled or disabled */ 782 785 if ((!!uv_l->prot + !!uv_l->err + !!uv_l->warn) > 1) { 783 786 dev_err(config->dev, "%s: at most one voltage monitoring severity allowed!\n",
+1 -1
drivers/scsi/aacraid/aacraid.h
··· 2618 2618 struct aac_aifcmd { 2619 2619 __le32 command; /* Tell host what type of notify this is */ 2620 2620 __le32 seqnum; /* To allow ordering of reports (if necessary) */ 2621 - u8 data[1]; /* Undefined length (from kernel viewpoint) */ 2621 + u8 data[]; /* Undefined length (from kernel viewpoint) */ 2622 2622 }; 2623 2623 2624 2624 /**
+1 -1
drivers/scsi/fnic/fnic_trace.c
··· 465 465 fnic_max_trace_entries = (trace_max_pages * PAGE_SIZE)/ 466 466 FNIC_ENTRY_SIZE_BYTES; 467 467 468 - fnic_trace_buf_p = (unsigned long)vzalloc(trace_max_pages * PAGE_SIZE); 468 + fnic_trace_buf_p = (unsigned long)vcalloc(trace_max_pages, PAGE_SIZE); 469 469 if (!fnic_trace_buf_p) { 470 470 printk(KERN_ERR PFX "Failed to allocate memory " 471 471 "for fnic_trace_buf_p\n");
+2
drivers/scsi/lpfc/lpfc_hbadisc.c
··· 6944 6944 if (rc) 6945 6945 return; 6946 6946 /* Reset HBA FCF states after successful unregister FCF */ 6947 + spin_lock_irq(&phba->hbalock); 6947 6948 phba->fcf.fcf_flag = 0; 6949 + spin_unlock_irq(&phba->hbalock); 6948 6950 phba->fcf.current_rec.flag = 0; 6949 6951 6950 6952 /*
-1
drivers/scsi/qla2xxx/qla_def.h
··· 4462 4462 4463 4463 /* n2n */ 4464 4464 struct fc_els_flogi plogi_els_payld; 4465 - #define LOGIN_TEMPLATE_SIZE (sizeof(struct fc_els_flogi) - 4) 4466 4465 4467 4466 void *swl; 4468 4467
+2 -2
drivers/scsi/qla2xxx/qla_init.c
··· 8434 8434 ql_dbg(ql_dbg_init, vha, 0x0163, 8435 8435 "-> fwdt%u template allocate template %#x words...\n", 8436 8436 j, risc_size); 8437 - fwdt->template = vmalloc(risc_size * sizeof(*dcode)); 8437 + fwdt->template = vmalloc_array(risc_size, sizeof(*dcode)); 8438 8438 if (!fwdt->template) { 8439 8439 ql_log(ql_log_warn, vha, 0x0164, 8440 8440 "-> fwdt%u failed allocate template.\n", j); ··· 8689 8689 ql_dbg(ql_dbg_init, vha, 0x0173, 8690 8690 "-> fwdt%u template allocate template %#x words...\n", 8691 8691 j, risc_size); 8692 - fwdt->template = vmalloc(risc_size * sizeof(*dcode)); 8692 + fwdt->template = vmalloc_array(risc_size, sizeof(*dcode)); 8693 8693 if (!fwdt->template) { 8694 8694 ql_log(ql_log_warn, vha, 0x0174, 8695 8695 "-> fwdt%u failed allocate template.\n", j);
+3 -2
drivers/scsi/qla2xxx/qla_iocb.c
··· 3073 3073 memset(ptr, 0, sizeof(struct els_plogi_payload)); 3074 3074 memset(resp_ptr, 0, sizeof(struct els_plogi_payload)); 3075 3075 memcpy(elsio->u.els_plogi.els_plogi_pyld->data, 3076 - &ha->plogi_els_payld.fl_csp, LOGIN_TEMPLATE_SIZE); 3076 + (void *)&ha->plogi_els_payld + offsetof(struct fc_els_flogi, fl_csp), 3077 + sizeof(ha->plogi_els_payld) - offsetof(struct fc_els_flogi, fl_csp)); 3077 3078 3078 3079 elsio->u.els_plogi.els_cmd = els_opcode; 3079 3080 elsio->u.els_plogi.els_plogi_pyld->opcode = els_opcode; ··· 3912 3911 3913 3912 pkt = __qla2x00_alloc_iocbs(sp->qpair, sp); 3914 3913 if (!pkt) { 3915 - rval = EAGAIN; 3914 + rval = -EAGAIN; 3916 3915 ql_log(ql_log_warn, vha, 0x700c, 3917 3916 "qla2x00_alloc_iocbs failed.\n"); 3918 3917 goto done;
-8
drivers/scsi/scsi_debug.c
··· 841 841 static int submit_queues = DEF_SUBMIT_QUEUES; /* > 1 for multi-queue (mq) */ 842 842 static int poll_queues; /* iouring iopoll interface.*/ 843 843 844 - static DEFINE_RWLOCK(atomic_rw); 845 - static DEFINE_RWLOCK(atomic_rw2); 846 - 847 - static rwlock_t *ramdisk_lck_a[2]; 848 - 849 844 static char sdebug_proc_name[] = MY_NAME; 850 845 static const char *my_name = MY_NAME; 851 846 ··· 6812 6817 unsigned long sz; 6813 6818 int k, ret, hosts_to_add; 6814 6819 int idx = -1; 6815 - 6816 - ramdisk_lck_a[0] = &atomic_rw; 6817 - ramdisk_lck_a[1] = &atomic_rw2; 6818 6820 6819 6821 if (sdebug_ndelay >= 1000 * 1000 * 1000) { 6820 6822 pr_warn("ndelay must be less than 1 second, ignored\n");
+5 -7
drivers/scsi/sd_zbc.c
··· 831 831 struct request_queue *q = disk->queue; 832 832 u32 zone_blocks = sdkp->early_zone_info.zone_blocks; 833 833 unsigned int nr_zones = sdkp->early_zone_info.nr_zones; 834 - u32 max_append; 835 834 int ret = 0; 836 835 unsigned int flags; 837 836 ··· 875 876 goto unlock; 876 877 } 877 878 879 + blk_queue_chunk_sectors(q, 880 + logical_to_sectors(sdkp->device, zone_blocks)); 881 + blk_queue_max_zone_append_sectors(q, 882 + q->limits.max_segments << PAGE_SECTORS_SHIFT); 883 + 878 884 ret = blk_revalidate_disk_zones(disk, sd_zbc_revalidate_zones_cb); 879 885 880 886 memalloc_noio_restore(flags); ··· 891 887 sdkp->capacity = 0; 892 888 goto unlock; 893 889 } 894 - 895 - max_append = min_t(u32, logical_to_sectors(sdkp->device, zone_blocks), 896 - q->limits.max_segments << PAGE_SECTORS_SHIFT); 897 - max_append = min_t(u32, max_append, queue_max_hw_sectors(q)); 898 - 899 - blk_queue_max_zone_append_sectors(q, max_append); 900 890 901 891 sd_zbc_print_zones(sdkp); 902 892
+2
drivers/scsi/storvsc_drv.c
··· 318 318 #define SRB_STATUS_INVALID_REQUEST 0x06 319 319 #define SRB_STATUS_DATA_OVERRUN 0x12 320 320 #define SRB_STATUS_INVALID_LUN 0x20 321 + #define SRB_STATUS_INTERNAL_ERROR 0x30 321 322 322 323 #define SRB_STATUS(status) \ 323 324 (status & ~(SRB_STATUS_AUTOSENSE_VALID | SRB_STATUS_QUEUE_FROZEN)) ··· 979 978 case SRB_STATUS_ERROR: 980 979 case SRB_STATUS_ABORTED: 981 980 case SRB_STATUS_INVALID_REQUEST: 981 + case SRB_STATUS_INTERNAL_ERROR: 982 982 if (vm_srb->srb_status & SRB_STATUS_AUTOSENSE_VALID) { 983 983 /* Check for capacity change */ 984 984 if ((asc == 0x2a) && (ascq == 0x9)) {
+1 -1
drivers/spi/spi-bcm63xx.c
··· 126 126 SPI_MSG_DATA_SIZE, 127 127 }; 128 128 129 - #define BCM63XX_SPI_MAX_PREPEND 15 129 + #define BCM63XX_SPI_MAX_PREPEND 7 130 130 131 131 #define BCM63XX_SPI_MAX_CS 8 132 132 #define BCM63XX_SPI_BUS_NUM 0
+2
drivers/spi/spi-s3c64xx.c
··· 684 684 685 685 if ((sdd->cur_mode & SPI_LOOP) && sdd->port_conf->has_loopback) 686 686 val |= S3C64XX_SPI_MODE_SELF_LOOPBACK; 687 + else 688 + val &= ~S3C64XX_SPI_MODE_SELF_LOOPBACK; 687 689 688 690 writel(val, regs + S3C64XX_SPI_MODE_CFG); 689 691
+38
drivers/ufs/core/ufshcd.c
··· 8520 8520 return ret; 8521 8521 } 8522 8522 8523 + static void ufshcd_set_timestamp_attr(struct ufs_hba *hba) 8524 + { 8525 + int err; 8526 + struct ufs_query_req *request = NULL; 8527 + struct ufs_query_res *response = NULL; 8528 + struct ufs_dev_info *dev_info = &hba->dev_info; 8529 + struct utp_upiu_query_v4_0 *upiu_data; 8530 + 8531 + if (dev_info->wspecversion < 0x400) 8532 + return; 8533 + 8534 + ufshcd_hold(hba); 8535 + 8536 + mutex_lock(&hba->dev_cmd.lock); 8537 + 8538 + ufshcd_init_query(hba, &request, &response, 8539 + UPIU_QUERY_OPCODE_WRITE_ATTR, 8540 + QUERY_ATTR_IDN_TIMESTAMP, 0, 0); 8541 + 8542 + request->query_func = UPIU_QUERY_FUNC_STANDARD_WRITE_REQUEST; 8543 + 8544 + upiu_data = (struct utp_upiu_query_v4_0 *)&request->upiu_req; 8545 + 8546 + put_unaligned_be64(ktime_get_real_ns(), &upiu_data->osf3); 8547 + 8548 + err = ufshcd_exec_dev_cmd(hba, DEV_CMD_TYPE_QUERY, QUERY_REQ_TIMEOUT); 8549 + 8550 + if (err) 8551 + dev_err(hba->dev, "%s: failed to set timestamp %d\n", 8552 + __func__, err); 8553 + 8554 + mutex_unlock(&hba->dev_cmd.lock); 8555 + ufshcd_release(hba); 8556 + } 8557 + 8523 8558 /** 8524 8559 * ufshcd_add_lus - probe and add UFS logical units 8525 8560 * @hba: per-adapter instance ··· 8742 8707 /* UFS device is also active now */ 8743 8708 ufshcd_set_ufs_dev_active(hba); 8744 8709 ufshcd_force_reset_auto_bkops(hba); 8710 + 8711 + ufshcd_set_timestamp_attr(hba); 8745 8712 8746 8713 /* Gear up to HS gear if supported */ 8747 8714 if (hba->max_pwr_info.is_valid) { ··· 9786 9749 ret = ufshcd_set_dev_pwr_mode(hba, UFS_ACTIVE_PWR_MODE); 9787 9750 if (ret) 9788 9751 goto set_old_link_state; 9752 + ufshcd_set_timestamp_attr(hba); 9789 9753 } 9790 9754 9791 9755 if (ufshcd_keep_autobkops_enabled_except_suspend(hba))
+1
drivers/ufs/host/Kconfig
··· 72 72 config SCSI_UFS_MEDIATEK 73 73 tristate "Mediatek specific hooks to UFS controller platform driver" 74 74 depends on SCSI_UFSHCD_PLATFORM && ARCH_MEDIATEK 75 + depends on RESET_CONTROLLER 75 76 select PHY_MTK_UFS 76 77 select RESET_TI_SYSCON 77 78 help
+12 -2
fs/btrfs/block-group.c
··· 1640 1640 { 1641 1641 struct btrfs_fs_info *fs_info = bg->fs_info; 1642 1642 1643 - trace_btrfs_add_unused_block_group(bg); 1644 1643 spin_lock(&fs_info->unused_bgs_lock); 1645 1644 if (list_empty(&bg->bg_list)) { 1646 1645 btrfs_get_block_group(bg); 1646 + trace_btrfs_add_unused_block_group(bg); 1647 1647 list_add_tail(&bg->bg_list, &fs_info->unused_bgs); 1648 - } else { 1648 + } else if (!test_bit(BLOCK_GROUP_FLAG_NEW, &bg->runtime_flags)) { 1649 1649 /* Pull out the block group from the reclaim_bgs list. */ 1650 + trace_btrfs_add_unused_block_group(bg); 1650 1651 list_move_tail(&bg->bg_list, &fs_info->unused_bgs); 1651 1652 } 1652 1653 spin_unlock(&fs_info->unused_bgs_lock); ··· 2088 2087 2089 2088 /* Shouldn't have super stripes in sequential zones */ 2090 2089 if (zoned && nr) { 2090 + kfree(logical); 2091 2091 btrfs_err(fs_info, 2092 2092 "zoned: block group %llu must not contain super block", 2093 2093 cache->start); ··· 2670 2668 next: 2671 2669 btrfs_delayed_refs_rsv_release(fs_info, 1); 2672 2670 list_del_init(&block_group->bg_list); 2671 + clear_bit(BLOCK_GROUP_FLAG_NEW, &block_group->runtime_flags); 2673 2672 } 2674 2673 btrfs_trans_release_chunk_metadata(trans); 2675 2674 } ··· 2709 2706 cache = btrfs_create_block_group_cache(fs_info, chunk_offset); 2710 2707 if (!cache) 2711 2708 return ERR_PTR(-ENOMEM); 2709 + 2710 + /* 2711 + * Mark it as new before adding it to the rbtree of block groups or any 2712 + * list, so that no other task finds it and calls btrfs_mark_bg_unused() 2713 + * before the new flag is set. 2714 + */ 2715 + set_bit(BLOCK_GROUP_FLAG_NEW, &cache->runtime_flags); 2712 2716 2713 2717 cache->length = size; 2714 2718 set_free_space_tree_thresholds(cache);
+5
fs/btrfs/block-group.h
··· 70 70 BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, 71 71 /* Indicate that the block group is placed on a sequential zone */ 72 72 BLOCK_GROUP_FLAG_SEQUENTIAL_ZONE, 73 + /* 74 + * Indicate that block group is in the list of new block groups of a 75 + * transaction. 76 + */ 77 + BLOCK_GROUP_FLAG_NEW, 73 78 }; 74 79 75 80 enum btrfs_caching_type {
+52 -25
fs/btrfs/inode.c
··· 3482 3482 void btrfs_add_delayed_iput(struct btrfs_inode *inode) 3483 3483 { 3484 3484 struct btrfs_fs_info *fs_info = inode->root->fs_info; 3485 + unsigned long flags; 3485 3486 3486 3487 if (atomic_add_unless(&inode->vfs_inode.i_count, -1, 1)) 3487 3488 return; 3488 3489 3489 3490 atomic_inc(&fs_info->nr_delayed_iputs); 3490 - spin_lock(&fs_info->delayed_iput_lock); 3491 + /* 3492 + * Need to be irq safe here because we can be called from either an irq 3493 + * context (see bio.c and btrfs_put_ordered_extent()) or a non-irq 3494 + * context. 3495 + */ 3496 + spin_lock_irqsave(&fs_info->delayed_iput_lock, flags); 3491 3497 ASSERT(list_empty(&inode->delayed_iput)); 3492 3498 list_add_tail(&inode->delayed_iput, &fs_info->delayed_iputs); 3493 - spin_unlock(&fs_info->delayed_iput_lock); 3499 + spin_unlock_irqrestore(&fs_info->delayed_iput_lock, flags); 3494 3500 if (!test_bit(BTRFS_FS_CLEANER_RUNNING, &fs_info->flags)) 3495 3501 wake_up_process(fs_info->cleaner_kthread); 3496 3502 } ··· 3505 3499 struct btrfs_inode *inode) 3506 3500 { 3507 3501 list_del_init(&inode->delayed_iput); 3508 - spin_unlock(&fs_info->delayed_iput_lock); 3502 + spin_unlock_irq(&fs_info->delayed_iput_lock); 3509 3503 iput(&inode->vfs_inode); 3510 3504 if (atomic_dec_and_test(&fs_info->nr_delayed_iputs)) 3511 3505 wake_up(&fs_info->delayed_iputs_wait); 3512 - spin_lock(&fs_info->delayed_iput_lock); 3506 + spin_lock_irq(&fs_info->delayed_iput_lock); 3513 3507 } 3514 3508 3515 3509 static void btrfs_run_delayed_iput(struct btrfs_fs_info *fs_info, 3516 3510 struct btrfs_inode *inode) 3517 3511 { 3518 3512 if (!list_empty(&inode->delayed_iput)) { 3519 - spin_lock(&fs_info->delayed_iput_lock); 3513 + spin_lock_irq(&fs_info->delayed_iput_lock); 3520 3514 if (!list_empty(&inode->delayed_iput)) 3521 3515 run_delayed_iput_locked(fs_info, inode); 3522 - spin_unlock(&fs_info->delayed_iput_lock); 3516 + spin_unlock_irq(&fs_info->delayed_iput_lock); 3523 3517 } 3524 3518 } 3525 3519 3526 3520 void btrfs_run_delayed_iputs(struct btrfs_fs_info *fs_info) 3527 3521 { 3528 - 3529 - spin_lock(&fs_info->delayed_iput_lock); 3522 + /* 3523 + * btrfs_put_ordered_extent() can run in irq context (see bio.c), which 3524 + * calls btrfs_add_delayed_iput() and that needs to lock 3525 + * fs_info->delayed_iput_lock. So we need to disable irqs here to 3526 + * prevent a deadlock. 3527 + */ 3528 + spin_lock_irq(&fs_info->delayed_iput_lock); 3530 3529 while (!list_empty(&fs_info->delayed_iputs)) { 3531 3530 struct btrfs_inode *inode; 3532 3531 3533 3532 inode = list_first_entry(&fs_info->delayed_iputs, 3534 3533 struct btrfs_inode, delayed_iput); 3535 3534 run_delayed_iput_locked(fs_info, inode); 3536 - cond_resched_lock(&fs_info->delayed_iput_lock); 3535 + if (need_resched()) { 3536 + spin_unlock_irq(&fs_info->delayed_iput_lock); 3537 + cond_resched(); 3538 + spin_lock_irq(&fs_info->delayed_iput_lock); 3539 + } 3537 3540 } 3538 - spin_unlock(&fs_info->delayed_iput_lock); 3541 + spin_unlock_irq(&fs_info->delayed_iput_lock); 3539 3542 } 3540 3543 3541 3544 /* ··· 3674 3659 found_key.type = BTRFS_INODE_ITEM_KEY; 3675 3660 found_key.offset = 0; 3676 3661 inode = btrfs_iget(fs_info->sb, last_objectid, root); 3677 - ret = PTR_ERR_OR_ZERO(inode); 3678 - if (ret && ret != -ENOENT) 3679 - goto out; 3662 + if (IS_ERR(inode)) { 3663 + ret = PTR_ERR(inode); 3664 + inode = NULL; 3665 + if (ret != -ENOENT) 3666 + goto out; 3667 + } 3680 3668 3681 - if (ret == -ENOENT && root == fs_info->tree_root) { 3669 + if (!inode && root == fs_info->tree_root) { 3682 3670 struct btrfs_root *dead_root; 3683 3671 int is_dead_root = 0; 3684 3672 ··· 3742 3724 * deleted but wasn't. The inode number may have been reused, 3743 3725 * but either way, we can delete the orphan item. 3744 3726 */ 3745 - if (ret == -ENOENT || inode->i_nlink) { 3746 - if (!ret) { 3727 + if (!inode || inode->i_nlink) { 3728 + if (inode) { 3747 3729 ret = btrfs_drop_verity_items(BTRFS_I(inode)); 3748 3730 iput(inode); 3731 + inode = NULL; 3749 3732 if (ret) 3750 3733 goto out; 3751 3734 } 3752 3735 trans = btrfs_start_transaction(root, 1); 3753 3736 if (IS_ERR(trans)) { 3754 3737 ret = PTR_ERR(trans); 3755 - iput(inode); 3756 3738 goto out; 3757 3739 } 3758 3740 btrfs_debug(fs_info, "auto deleting %Lu", ··· 3760 3742 ret = btrfs_del_orphan_item(trans, root, 3761 3743 found_key.objectid); 3762 3744 btrfs_end_transaction(trans); 3763 - if (ret) { 3764 - iput(inode); 3745 + if (ret) 3765 3746 goto out; 3766 - } 3767 3747 continue; 3768 3748 } 3769 3749 ··· 4863 4847 ret = -ENOMEM; 4864 4848 goto out; 4865 4849 } 4866 - ret = set_page_extent_mapped(page); 4867 - if (ret < 0) 4868 - goto out_unlock; 4869 4850 4870 4851 if (!PageUptodate(page)) { 4871 4852 ret = btrfs_read_folio(NULL, page_folio(page)); ··· 4877 4864 goto out_unlock; 4878 4865 } 4879 4866 } 4867 + 4868 + /* 4869 + * We unlock the page after the io is completed and then re-lock it 4870 + * above. release_folio() could have come in between that and cleared 4871 + * PagePrivate(), but left the page in the mapping. Set the page mapped 4872 + * here to make sure it's properly set for the subpage stuff. 4873 + */ 4874 + ret = set_page_extent_mapped(page); 4875 + if (ret < 0) 4876 + goto out_unlock; 4877 + 4880 4878 wait_on_page_writeback(page); 4881 4879 4882 4880 lock_extent(io_tree, block_start, block_end, &cached_state); ··· 7873 7849 7874 7850 ret = btrfs_extract_ordered_extent(bbio, dio_data->ordered); 7875 7851 if (ret) { 7876 - bbio->bio.bi_status = errno_to_blk_status(ret); 7877 - btrfs_dio_end_io(bbio); 7852 + btrfs_finish_ordered_extent(dio_data->ordered, NULL, 7853 + file_offset, dip->bytes, 7854 + !ret); 7855 + bio->bi_status = errno_to_blk_status(ret); 7856 + iomap_dio_bio_end_io(bio); 7878 7857 return; 7879 7858 } 7880 7859 }
+1
fs/btrfs/qgroup.c
··· 4445 4445 ulist_free(entry->old_roots); 4446 4446 kfree(entry); 4447 4447 } 4448 + *root = RB_ROOT; 4448 4449 }
+3 -8
fs/btrfs/raid56.c
··· 71 71 static void index_rbio_pages(struct btrfs_raid_bio *rbio); 72 72 static int alloc_rbio_pages(struct btrfs_raid_bio *rbio); 73 73 74 - static int finish_parity_scrub(struct btrfs_raid_bio *rbio, int need_check); 74 + static int finish_parity_scrub(struct btrfs_raid_bio *rbio); 75 75 static void scrub_rbio_work_locked(struct work_struct *work); 76 76 77 77 static void free_raid_bio_pointers(struct btrfs_raid_bio *rbio) ··· 2404 2404 return 0; 2405 2405 } 2406 2406 2407 - static int finish_parity_scrub(struct btrfs_raid_bio *rbio, int need_check) 2407 + static int finish_parity_scrub(struct btrfs_raid_bio *rbio) 2408 2408 { 2409 2409 struct btrfs_io_context *bioc = rbio->bioc; 2410 2410 const u32 sectorsize = bioc->fs_info->sectorsize; ··· 2444 2444 * it. 2445 2445 */ 2446 2446 clear_bit(RBIO_CACHE_READY_BIT, &rbio->flags); 2447 - 2448 - if (!need_check) 2449 - goto writeback; 2450 2447 2451 2448 p_sector.page = alloc_page(GFP_NOFS); 2452 2449 if (!p_sector.page) ··· 2513 2516 q_sector.page = NULL; 2514 2517 } 2515 2518 2516 - writeback: 2517 2519 /* 2518 2520 * time to start writing. Make bios for everything from the 2519 2521 * higher layers (the bio_list in our rbio) and our p/q. Ignore ··· 2695 2699 2696 2700 static void scrub_rbio(struct btrfs_raid_bio *rbio) 2697 2701 { 2698 - bool need_check = false; 2699 2702 int sector_nr; 2700 2703 int ret; 2701 2704 ··· 2717 2722 * We have every sector properly prepared. Can finish the scrub 2718 2723 * and writeback the good content. 2719 2724 */ 2720 - ret = finish_parity_scrub(rbio, need_check); 2725 + ret = finish_parity_scrub(rbio); 2721 2726 wait_event(rbio->io_wait, atomic_read(&rbio->stripes_pending) == 0); 2722 2727 for (sector_nr = 0; sector_nr < rbio->stripe_nsectors; sector_nr++) { 2723 2728 int found_errors;
+6 -11
fs/btrfs/volumes.c
··· 4078 4078 return has_single_bit_set(flags); 4079 4079 } 4080 4080 4081 - static inline int balance_need_close(struct btrfs_fs_info *fs_info) 4082 - { 4083 - /* cancel requested || normal exit path */ 4084 - return atomic_read(&fs_info->balance_cancel_req) || 4085 - (atomic_read(&fs_info->balance_pause_req) == 0 && 4086 - atomic_read(&fs_info->balance_cancel_req) == 0); 4087 - } 4088 - 4089 4081 /* 4090 4082 * Validate target profile against allowed profiles and return true if it's OK. 4091 4083 * Otherwise print the error message and return false. ··· 4267 4275 u64 num_devices; 4268 4276 unsigned seq; 4269 4277 bool reducing_redundancy; 4278 + bool paused = false; 4270 4279 int i; 4271 4280 4272 4281 if (btrfs_fs_closing(fs_info) || ··· 4398 4405 if (ret == -ECANCELED && atomic_read(&fs_info->balance_pause_req)) { 4399 4406 btrfs_info(fs_info, "balance: paused"); 4400 4407 btrfs_exclop_balance(fs_info, BTRFS_EXCLOP_BALANCE_PAUSED); 4408 + paused = true; 4401 4409 } 4402 4410 /* 4403 4411 * Balance can be canceled by: ··· 4427 4433 btrfs_update_ioctl_balance_args(fs_info, bargs); 4428 4434 } 4429 4435 4430 - if ((ret && ret != -ECANCELED && ret != -ENOSPC) || 4431 - balance_need_close(fs_info)) { 4436 + /* We didn't pause, we can clean everything up. */ 4437 + if (!paused) { 4432 4438 reset_balance_state(fs_info); 4433 4439 btrfs_exclop_finish(fs_info); 4434 4440 } ··· 6398 6404 (op == BTRFS_MAP_READ || !dev_replace_is_ongoing || 6399 6405 !dev_replace->tgtdev)) { 6400 6406 set_io_stripe(smap, map, stripe_index, stripe_offset, stripe_nr); 6401 - *mirror_num_ret = mirror_num; 6407 + if (mirror_num_ret) 6408 + *mirror_num_ret = mirror_num; 6402 6409 *bioc_ret = NULL; 6403 6410 ret = 0; 6404 6411 goto out;
+17 -20
fs/erofs/decompressor.c
··· 148 148 *maptype = 0; 149 149 return inpage; 150 150 } 151 - kunmap_atomic(inpage); 151 + kunmap_local(inpage); 152 152 might_sleep(); 153 153 src = erofs_vm_map_ram(rq->in, ctx->inpages); 154 154 if (!src) ··· 162 162 src = erofs_get_pcpubuf(ctx->inpages); 163 163 if (!src) { 164 164 DBG_BUGON(1); 165 - kunmap_atomic(inpage); 165 + kunmap_local(inpage); 166 166 return ERR_PTR(-EFAULT); 167 167 } 168 168 ··· 173 173 min_t(unsigned int, total, PAGE_SIZE - *inputmargin); 174 174 175 175 if (!inpage) 176 - inpage = kmap_atomic(*in); 176 + inpage = kmap_local_page(*in); 177 177 memcpy(tmp, inpage + *inputmargin, page_copycnt); 178 - kunmap_atomic(inpage); 178 + kunmap_local(inpage); 179 179 inpage = NULL; 180 180 tmp += page_copycnt; 181 181 total -= page_copycnt; ··· 214 214 int ret, maptype; 215 215 216 216 DBG_BUGON(*rq->in == NULL); 217 - headpage = kmap_atomic(*rq->in); 217 + headpage = kmap_local_page(*rq->in); 218 218 219 219 /* LZ4 decompression inplace is only safe if zero_padding is enabled */ 220 220 if (erofs_sb_has_zero_padding(EROFS_SB(rq->sb))) { ··· 223 223 min_t(unsigned int, rq->inputsize, 224 224 rq->sb->s_blocksize - rq->pageofs_in)); 225 225 if (ret) { 226 - kunmap_atomic(headpage); 226 + kunmap_local(headpage); 227 227 return ret; 228 228 } 229 229 may_inplace = !((rq->pageofs_in + rq->inputsize) & ··· 261 261 } 262 262 263 263 if (maptype == 0) { 264 - kunmap_atomic(headpage); 264 + kunmap_local(headpage); 265 265 } else if (maptype == 1) { 266 266 vm_unmap_ram(src, ctx->inpages); 267 267 } else if (maptype == 2) { ··· 289 289 /* one optimized fast path only for non bigpcluster cases yet */ 290 290 if (ctx.inpages == 1 && ctx.outpages == 1 && !rq->inplace_io) { 291 291 DBG_BUGON(!*rq->out); 292 - dst = kmap_atomic(*rq->out); 292 + dst = kmap_local_page(*rq->out); 293 293 dst_maptype = 0; 294 294 goto dstmap_out; 295 295 } ··· 311 311 dstmap_out: 312 312 ret = z_erofs_lz4_decompress_mem(&ctx, dst + rq->pageofs_out); 313 313 if (!dst_maptype) 314 - kunmap_atomic(dst); 314 + kunmap_local(dst); 315 315 else if (dst_maptype == 2) 316 316 vm_unmap_ram(dst, ctx.outpages); 317 317 return ret; ··· 328 328 const unsigned int lefthalf = rq->outputsize - righthalf; 329 329 const unsigned int interlaced_offset = 330 330 rq->alg == Z_EROFS_COMPRESSION_SHIFTED ? 0 : rq->pageofs_out; 331 - unsigned char *src, *dst; 331 + u8 *src; 332 332 333 333 if (outpages > 2 && rq->alg == Z_EROFS_COMPRESSION_SHIFTED) { 334 334 DBG_BUGON(1); ··· 341 341 } 342 342 343 343 src = kmap_local_page(rq->in[inpages - 1]) + rq->pageofs_in; 344 - if (rq->out[0]) { 345 - dst = kmap_local_page(rq->out[0]); 346 - memcpy(dst + rq->pageofs_out, src + interlaced_offset, 347 - righthalf); 348 - kunmap_local(dst); 349 - } 344 + if (rq->out[0]) 345 + memcpy_to_page(rq->out[0], rq->pageofs_out, 346 + src + interlaced_offset, righthalf); 350 347 351 348 if (outpages > inpages) { 352 349 DBG_BUGON(!rq->out[outpages - 1]); 353 350 if (rq->out[outpages - 1] != rq->in[inpages - 1]) { 354 - dst = kmap_local_page(rq->out[outpages - 1]); 355 - memcpy(dst, interlaced_offset ? src : 356 - (src + righthalf), lefthalf); 357 - kunmap_local(dst); 351 + memcpy_to_page(rq->out[outpages - 1], 0, src + 352 + (interlaced_offset ? 0 : righthalf), 353 + lefthalf); 358 354 } else if (!interlaced_offset) { 359 355 memmove(src, src + righthalf, lefthalf); 356 + flush_dcache_page(rq->in[inpages - 1]); 360 357 } 361 358 } 362 359 kunmap_local(src);
+2 -1
fs/erofs/inode.c
··· 183 183 184 184 inode->i_flags &= ~S_DAX; 185 185 if (test_opt(&sbi->opt, DAX_ALWAYS) && S_ISREG(inode->i_mode) && 186 - vi->datalayout == EROFS_INODE_FLAT_PLAIN) 186 + (vi->datalayout == EROFS_INODE_FLAT_PLAIN || 187 + vi->datalayout == EROFS_INODE_CHUNK_BASED)) 187 188 inode->i_flags |= S_DAX; 188 189 189 190 if (!nblks)
+2 -2
fs/erofs/zdata.c
··· 1035 1035 */ 1036 1036 tight &= (fe->mode > Z_EROFS_PCLUSTER_FOLLOWED_NOINPLACE); 1037 1037 1038 - cur = end - min_t(unsigned int, offset + end - map->m_la, end); 1038 + cur = end - min_t(erofs_off_t, offset + end - map->m_la, end); 1039 1039 if (!(map->m_flags & EROFS_MAP_MAPPED)) { 1040 1040 zero_user_segment(page, cur, end); 1041 1041 goto next_part; ··· 1841 1841 } 1842 1842 1843 1843 cur = map->m_la + map->m_llen - 1; 1844 - while (cur >= end) { 1844 + while ((cur >= end) && (cur < i_size_read(inode))) { 1845 1845 pgoff_t index = cur >> PAGE_SHIFT; 1846 1846 struct page *page; 1847 1847
+1 -3
fs/fuse/dir.c
··· 258 258 spin_unlock(&fi->lock); 259 259 } 260 260 kfree(forget); 261 - if (ret == -ENOMEM) 261 + if (ret == -ENOMEM || ret == -EINTR) 262 262 goto out; 263 263 if (ret || fuse_invalid_attr(&outarg.attr) || 264 264 fuse_stale_inode(inode, outarg.generation, &outarg.attr)) ··· 395 395 goto out_put_forget; 396 396 397 397 err = -EIO; 398 - if (!outarg->nodeid) 399 - goto out_put_forget; 400 398 if (fuse_invalid_attr(&outarg->attr)) 401 399 goto out_put_forget; 402 400
+6 -2
fs/fuse/inode.c
··· 1134 1134 process_init_limits(fc, arg); 1135 1135 1136 1136 if (arg->minor >= 6) { 1137 - u64 flags = arg->flags | (u64) arg->flags2 << 32; 1137 + u64 flags = arg->flags; 1138 + 1139 + if (flags & FUSE_INIT_EXT) 1140 + flags |= (u64) arg->flags2 << 32; 1138 1141 1139 1142 ra_pages = arg->max_readahead / PAGE_SIZE; 1140 1143 if (flags & FUSE_ASYNC_READ) ··· 1257 1254 FUSE_ABORT_ERROR | FUSE_MAX_PAGES | FUSE_CACHE_SYMLINKS | 1258 1255 FUSE_NO_OPENDIR_SUPPORT | FUSE_EXPLICIT_INVAL_DATA | 1259 1256 FUSE_HANDLE_KILLPRIV_V2 | FUSE_SETXATTR_EXT | FUSE_INIT_EXT | 1260 - FUSE_SECURITY_CTX | FUSE_CREATE_SUPP_GROUP; 1257 + FUSE_SECURITY_CTX | FUSE_CREATE_SUPP_GROUP | 1258 + FUSE_HAS_EXPIRE_ONLY; 1261 1259 #ifdef CONFIG_FUSE_DAX 1262 1260 if (fm->fc->dax) 1263 1261 flags |= FUSE_MAP_ALIGNMENT;
+13 -8
fs/fuse/ioctl.c
··· 9 9 #include <linux/compat.h> 10 10 #include <linux/fileattr.h> 11 11 12 - static ssize_t fuse_send_ioctl(struct fuse_mount *fm, struct fuse_args *args) 12 + static ssize_t fuse_send_ioctl(struct fuse_mount *fm, struct fuse_args *args, 13 + struct fuse_ioctl_out *outarg) 13 14 { 14 - ssize_t ret = fuse_simple_request(fm, args); 15 + ssize_t ret; 16 + 17 + args->out_args[0].size = sizeof(*outarg); 18 + args->out_args[0].value = outarg; 19 + 20 + ret = fuse_simple_request(fm, args); 15 21 16 22 /* Translate ENOSYS, which shouldn't be returned from fs */ 17 23 if (ret == -ENOSYS) 18 24 ret = -ENOTTY; 25 + 26 + if (ret >= 0 && outarg->result == -ENOSYS) 27 + outarg->result = -ENOTTY; 19 28 20 29 return ret; 21 30 } ··· 273 264 } 274 265 275 266 ap.args.out_numargs = 2; 276 - ap.args.out_args[0].size = sizeof(outarg); 277 - ap.args.out_args[0].value = &outarg; 278 267 ap.args.out_args[1].size = out_size; 279 268 ap.args.out_pages = true; 280 269 ap.args.out_argvar = true; 281 270 282 - transferred = fuse_send_ioctl(fm, &ap.args); 271 + transferred = fuse_send_ioctl(fm, &ap.args, &outarg); 283 272 err = transferred; 284 273 if (transferred < 0) 285 274 goto out; ··· 406 399 args.in_args[1].size = inarg.in_size; 407 400 args.in_args[1].value = ptr; 408 401 args.out_numargs = 2; 409 - args.out_args[0].size = sizeof(outarg); 410 - args.out_args[0].value = &outarg; 411 402 args.out_args[1].size = inarg.out_size; 412 403 args.out_args[1].value = ptr; 413 404 414 - err = fuse_send_ioctl(fm, &args); 405 + err = fuse_send_ioctl(fm, &args, &outarg); 415 406 if (!err) { 416 407 if (outarg.result < 0) 417 408 err = outarg.result;
+2 -2
fs/iomap/buffered-io.c
··· 872 872 while ((ret = iomap_iter(&iter, ops)) > 0) 873 873 iter.processed = iomap_write_iter(&iter, i); 874 874 875 - if (unlikely(ret < 0)) 875 + if (unlikely(iter.pos == iocb->ki_pos)) 876 876 return ret; 877 877 ret = iter.pos - iocb->ki_pos; 878 - iocb->ki_pos += ret; 878 + iocb->ki_pos = iter.pos; 879 879 return ret; 880 880 } 881 881 EXPORT_SYMBOL_GPL(iomap_file_buffered_write);
+1 -1
fs/smb/client/cifsglob.h
··· 532 532 /* Check for STATUS_IO_TIMEOUT */ 533 533 bool (*is_status_io_timeout)(char *buf); 534 534 /* Check for STATUS_NETWORK_NAME_DELETED */ 535 - void (*is_network_name_deleted)(char *buf, struct TCP_Server_Info *srv); 535 + bool (*is_network_name_deleted)(char *buf, struct TCP_Server_Info *srv); 536 536 }; 537 537 538 538 struct smb_version_values {
+1 -1
fs/smb/client/cifssmb.c
··· 3184 3184 param_offset = offsetof(struct smb_com_transaction2_spi_req, 3185 3185 InformationLevel) - 4; 3186 3186 offset = param_offset + params; 3187 - parm_data = ((char *) &pSMB->hdr.Protocol) + offset; 3187 + parm_data = ((char *)pSMB) + sizeof(pSMB->hdr.smb_buf_length) + offset; 3188 3188 pSMB->ParameterOffset = cpu_to_le16(param_offset); 3189 3189 3190 3190 /* convert to on the wire format for POSIX ACL */
+23 -7
fs/smb/client/connect.c
··· 60 60 #define TLINK_IDLE_EXPIRE (600 * HZ) 61 61 62 62 /* Drop the connection to not overload the server */ 63 - #define NUM_STATUS_IO_TIMEOUT 5 63 + #define MAX_STATUS_IO_TIMEOUT 5 64 64 65 65 static int ip_connect(struct TCP_Server_Info *server); 66 66 static int generic_ip_connect(struct TCP_Server_Info *server); ··· 1117 1117 struct mid_q_entry *mids[MAX_COMPOUND]; 1118 1118 char *bufs[MAX_COMPOUND]; 1119 1119 unsigned int noreclaim_flag, num_io_timeout = 0; 1120 + bool pending_reconnect = false; 1120 1121 1121 1122 noreclaim_flag = memalloc_noreclaim_save(); 1122 1123 cifs_dbg(FYI, "Demultiplex PID: %d\n", task_pid_nr(current)); ··· 1157 1156 cifs_dbg(FYI, "RFC1002 header 0x%x\n", pdu_length); 1158 1157 if (!is_smb_response(server, buf[0])) 1159 1158 continue; 1159 + 1160 + pending_reconnect = false; 1160 1161 next_pdu: 1161 1162 server->pdu_size = pdu_length; 1162 1163 ··· 1216 1213 if (server->ops->is_status_io_timeout && 1217 1214 server->ops->is_status_io_timeout(buf)) { 1218 1215 num_io_timeout++; 1219 - if (num_io_timeout > NUM_STATUS_IO_TIMEOUT) { 1220 - cifs_reconnect(server, false); 1216 + if (num_io_timeout > MAX_STATUS_IO_TIMEOUT) { 1217 + cifs_server_dbg(VFS, 1218 + "Number of request timeouts exceeded %d. Reconnecting", 1219 + MAX_STATUS_IO_TIMEOUT); 1220 + 1221 + pending_reconnect = true; 1221 1222 num_io_timeout = 0; 1222 - continue; 1223 1223 } 1224 1224 } 1225 1225 ··· 1232 1226 if (mids[i] != NULL) { 1233 1227 mids[i]->resp_buf_size = server->pdu_size; 1234 1228 1235 - if (bufs[i] && server->ops->is_network_name_deleted) 1236 - server->ops->is_network_name_deleted(bufs[i], 1237 - server); 1229 + if (bufs[i] != NULL) { 1230 + if (server->ops->is_network_name_deleted && 1231 + server->ops->is_network_name_deleted(bufs[i], 1232 + server)) { 1233 + cifs_server_dbg(FYI, 1234 + "Share deleted. Reconnect needed"); 1235 + } 1236 + } 1238 1237 1239 1238 if (!mids[i]->multiRsp || mids[i]->multiEnd) 1240 1239 mids[i]->callback(mids[i]); ··· 1274 1263 buf = server->smallbuf; 1275 1264 goto next_pdu; 1276 1265 } 1266 + 1267 + /* do this reconnect at the very end after processing all MIDs */ 1268 + if (pending_reconnect) 1269 + cifs_reconnect(server, true); 1270 + 1277 1271 } /* end while !EXITING */ 1278 1272 1279 1273 /* buffer usually freed in free_mid - need to free it here on exit */
+10 -16
fs/smb/client/dfs.c
··· 66 66 return rc; 67 67 } 68 68 69 + /* 70 + * Track individual DFS referral servers used by new DFS mount. 71 + * 72 + * On success, their lifetime will be shared by final tcon (dfs_ses_list). 73 + * Otherwise, they will be put by dfs_put_root_smb_sessions() in cifs_mount(). 74 + */ 69 75 static int add_root_smb_session(struct cifs_mount_ctx *mnt_ctx) 70 76 { 71 77 struct smb3_fs_context *ctx = mnt_ctx->fs_ctx; ··· 86 80 INIT_LIST_HEAD(&root_ses->list); 87 81 88 82 spin_lock(&cifs_tcp_ses_lock); 89 - ses->ses_count++; 83 + cifs_smb_ses_inc_refcount(ses); 90 84 spin_unlock(&cifs_tcp_ses_lock); 91 85 root_ses->ses = ses; 92 86 list_add_tail(&root_ses->list, &mnt_ctx->dfs_ses_list); 93 87 } 88 + /* Select new DFS referral server so that new referrals go through it */ 94 89 ctx->dfs_root_ses = ses; 95 90 return 0; 96 91 } ··· 249 242 int dfs_mount_share(struct cifs_mount_ctx *mnt_ctx, bool *isdfs) 250 243 { 251 244 struct smb3_fs_context *ctx = mnt_ctx->fs_ctx; 252 - struct cifs_ses *ses; 253 245 bool nodfs = ctx->nodfs; 254 246 int rc; 255 247 ··· 282 276 } 283 277 284 278 *isdfs = true; 285 - /* 286 - * Prevent DFS root session of being put in the first call to 287 - * cifs_mount_put_conns(). If another DFS root server was not found 288 - * while chasing the referrals (@ctx->dfs_root_ses == @ses), then we 289 - * can safely put extra refcount of @ses. 290 - */ 291 - ses = mnt_ctx->ses; 292 - mnt_ctx->ses = NULL; 293 - mnt_ctx->server = NULL; 294 - rc = __dfs_mount_share(mnt_ctx); 295 - if (ses == ctx->dfs_root_ses) 296 - cifs_put_smb_ses(ses); 297 - 298 - return rc; 279 + add_root_smb_session(mnt_ctx); 280 + return __dfs_mount_share(mnt_ctx); 299 281 } 300 282 301 283 /* Update dfs referral path of superblock */
+2 -2
fs/smb/client/file.c
··· 1080 1080 cfile = file->private_data; 1081 1081 file->private_data = NULL; 1082 1082 dclose = kmalloc(sizeof(struct cifs_deferred_close), GFP_KERNEL); 1083 - if ((cinode->oplock == CIFS_CACHE_RHW_FLG) && 1084 - cinode->lease_granted && 1083 + if ((cifs_sb->ctx->closetimeo && cinode->oplock == CIFS_CACHE_RHW_FLG) 1084 + && cinode->lease_granted && 1085 1085 !test_bit(CIFS_INO_CLOSE_ON_LOCK, &cinode->flags) && 1086 1086 dclose) { 1087 1087 if (test_and_clear_bit(CIFS_INO_MODIFIED_ATTR, &cinode->flags)) {
+5 -3
fs/smb/client/smb2ops.c
··· 2395 2395 return false; 2396 2396 } 2397 2397 2398 - static void 2398 + static bool 2399 2399 smb2_is_network_name_deleted(char *buf, struct TCP_Server_Info *server) 2400 2400 { 2401 2401 struct smb2_hdr *shdr = (struct smb2_hdr *)buf; ··· 2404 2404 struct cifs_tcon *tcon; 2405 2405 2406 2406 if (shdr->Status != STATUS_NETWORK_NAME_DELETED) 2407 - return; 2407 + return false; 2408 2408 2409 2409 /* If server is a channel, select the primary channel */ 2410 2410 pserver = CIFS_SERVER_IS_CHAN(server) ? server->primary_server : server; ··· 2419 2419 spin_unlock(&cifs_tcp_ses_lock); 2420 2420 pr_warn_once("Server share %s deleted.\n", 2421 2421 tcon->tree_name); 2422 - return; 2422 + return true; 2423 2423 } 2424 2424 } 2425 2425 } 2426 2426 spin_unlock(&cifs_tcp_ses_lock); 2427 + 2428 + return false; 2427 2429 } 2428 2430 2429 2431 static int
+1 -1
fs/smb/client/smb2transport.c
··· 160 160 spin_unlock(&ses->ses_lock); 161 161 continue; 162 162 } 163 - ++ses->ses_count; 163 + cifs_smb_ses_inc_refcount(ses); 164 164 spin_unlock(&ses->ses_lock); 165 165 return ses; 166 166 }
+66 -9
fs/xfs/libxfs/xfs_da_format.h
··· 591 591 uint8_t valuelen; /* actual length of value (no NULL) */ 592 592 uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */ 593 593 uint8_t nameval[]; /* name & value bytes concatenated */ 594 - } list[1]; /* variable sized array */ 594 + } list[]; /* variable sized array */ 595 595 }; 596 596 597 597 typedef struct xfs_attr_leaf_map { /* RLE map of free bytes */ ··· 620 620 typedef struct xfs_attr_leaf_name_local { 621 621 __be16 valuelen; /* number of bytes in value */ 622 622 __u8 namelen; /* length of name bytes */ 623 - __u8 nameval[1]; /* name/value bytes */ 623 + /* 624 + * In Linux 6.5 this flex array was converted from nameval[1] to 625 + * nameval[]. Be very careful here about extra padding at the end; 626 + * see xfs_attr_leaf_entsize_local() for details. 627 + */ 628 + __u8 nameval[]; /* name/value bytes */ 624 629 } xfs_attr_leaf_name_local_t; 625 630 626 631 typedef struct xfs_attr_leaf_name_remote { 627 632 __be32 valueblk; /* block number of value bytes */ 628 633 __be32 valuelen; /* number of bytes in value */ 629 634 __u8 namelen; /* length of name bytes */ 630 - __u8 name[1]; /* name bytes */ 635 + /* 636 + * In Linux 6.5 this flex array was converted from name[1] to name[]. 637 + * Be very careful here about extra padding at the end; see 638 + * xfs_attr_leaf_entsize_remote() for details. 639 + */ 640 + __u8 name[]; /* name bytes */ 631 641 } xfs_attr_leaf_name_remote_t; 632 642 633 643 typedef struct xfs_attr_leafblock { 634 644 xfs_attr_leaf_hdr_t hdr; /* constant-structure header block */ 635 - xfs_attr_leaf_entry_t entries[1]; /* sorted on key, not name */ 645 + xfs_attr_leaf_entry_t entries[]; /* sorted on key, not name */ 636 646 /* 637 647 * The rest of the block contains the following structures after the 638 648 * leaf entries, growing from the bottom up. The variables are never ··· 674 664 675 665 struct xfs_attr3_leafblock { 676 666 struct xfs_attr3_leaf_hdr hdr; 677 - struct xfs_attr_leaf_entry entries[1]; 667 + struct xfs_attr_leaf_entry entries[]; 678 668 679 669 /* 680 670 * The rest of the block contains the following structures after the ··· 757 747 */ 758 748 static inline int xfs_attr_leaf_entsize_remote(int nlen) 759 749 { 760 - return round_up(sizeof(struct xfs_attr_leaf_name_remote) - 1 + 761 - nlen, XFS_ATTR_LEAF_NAME_ALIGN); 750 + /* 751 + * Prior to Linux 6.5, struct xfs_attr_leaf_name_remote ended with 752 + * name[1], which was used as a flexarray. The layout of this struct 753 + * is 9 bytes of fixed-length fields followed by a __u8 flex array at 754 + * offset 9. 755 + * 756 + * On most architectures, struct xfs_attr_leaf_name_remote had two 757 + * bytes of implicit padding at the end of the struct to make the 758 + * struct length 12. After converting name[1] to name[], there are 759 + * three implicit padding bytes and the struct size remains 12. 760 + * However, there are compiler configurations that do not add implicit 761 + * padding at all (m68k) and have been broken for years. 762 + * 763 + * This entsize computation historically added (the xattr name length) 764 + * to (the padded struct length - 1) and rounded that sum up to the 765 + * nearest multiple of 4 (NAME_ALIGN). IOWs, round_up(11 + nlen, 4). 766 + * This is encoded in the ondisk format, so we cannot change this. 767 + * 768 + * Compute the entsize from offsetof of the flexarray and manually 769 + * adding bytes for the implicit padding. 770 + */ 771 + const size_t remotesize = 772 + offsetof(struct xfs_attr_leaf_name_remote, name) + 2; 773 + 774 + return round_up(remotesize + nlen, XFS_ATTR_LEAF_NAME_ALIGN); 762 775 } 763 776 764 777 static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen) 765 778 { 766 - return round_up(sizeof(struct xfs_attr_leaf_name_local) - 1 + 767 - nlen + vlen, XFS_ATTR_LEAF_NAME_ALIGN); 779 + /* 780 + * Prior to Linux 6.5, struct xfs_attr_leaf_name_local ended with 781 + * nameval[1], which was used as a flexarray. The layout of this 782 + * struct is 3 bytes of fixed-length fields followed by a __u8 flex 783 + * array at offset 3. 784 + * 785 + * struct xfs_attr_leaf_name_local had zero bytes of implicit padding 786 + * at the end of the struct to make the struct length 4. On most 787 + * architectures, after converting nameval[1] to nameval[], there is 788 + * one implicit padding byte and the struct size remains 4. However, 789 + * there are compiler configurations that do not add implicit padding 790 + * at all (m68k) and would break. 791 + * 792 + * This entsize computation historically added (the xattr name and 793 + * value length) to (the padded struct length - 1) and rounded that sum 794 + * up to the nearest multiple of 4 (NAME_ALIGN). IOWs, the formula is 795 + * round_up(3 + nlen + vlen, 4). This is encoded in the ondisk format, 796 + * so we cannot change this. 797 + * 798 + * Compute the entsize from offsetof of the flexarray and manually 799 + * adding bytes for the implicit padding. 800 + */ 801 + const size_t localsize = 802 + offsetof(struct xfs_attr_leaf_name_local, nameval); 803 + 804 + return round_up(localsize + nlen + vlen, XFS_ATTR_LEAF_NAME_ALIGN); 768 805 } 769 806 770 807 static inline int xfs_attr_leaf_entsize_local_max(int bsize)
+2 -2
fs/xfs/libxfs/xfs_fs.h
··· 592 592 struct xfs_attrlist { 593 593 __s32 al_count; /* number of entries in attrlist */ 594 594 __s32 al_more; /* T/F: more attrs (do call again) */ 595 - __s32 al_offset[1]; /* byte offsets of attrs [var-sized] */ 595 + __s32 al_offset[]; /* byte offsets of attrs [var-sized] */ 596 596 }; 597 597 598 598 struct xfs_attrlist_ent { /* data from attr_list() */ 599 599 __u32 a_valuelen; /* number bytes in value of attr */ 600 - char a_name[1]; /* attr name (NULL terminated) */ 600 + char a_name[]; /* attr name (NULL terminated) */ 601 601 }; 602 602 603 603 typedef struct xfs_fsop_attrlist_handlereq {
+3 -2
fs/xfs/xfs_ondisk.h
··· 56 56 57 57 /* dir/attr trees */ 58 58 XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leaf_hdr, 80); 59 - XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leafblock, 88); 59 + XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leafblock, 80); 60 60 XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_rmt_hdr, 56); 61 61 XFS_CHECK_STRUCT_SIZE(struct xfs_da3_blkinfo, 56); 62 62 XFS_CHECK_STRUCT_SIZE(struct xfs_da3_intnode, 64); ··· 88 88 XFS_CHECK_OFFSET(xfs_attr_leaf_name_remote_t, valuelen, 4); 89 89 XFS_CHECK_OFFSET(xfs_attr_leaf_name_remote_t, namelen, 8); 90 90 XFS_CHECK_OFFSET(xfs_attr_leaf_name_remote_t, name, 9); 91 - XFS_CHECK_STRUCT_SIZE(xfs_attr_leafblock_t, 40); 91 + XFS_CHECK_STRUCT_SIZE(xfs_attr_leafblock_t, 32); 92 + XFS_CHECK_STRUCT_SIZE(struct xfs_attr_shortform, 4); 92 93 XFS_CHECK_OFFSET(struct xfs_attr_shortform, hdr.totsize, 0); 93 94 XFS_CHECK_OFFSET(struct xfs_attr_shortform, hdr.count, 2); 94 95 XFS_CHECK_OFFSET(struct xfs_attr_shortform, list[0].namelen, 4);
-1
include/asm-generic/vmlinux.lds.h
··· 578 578 *(.text.unlikely .text.unlikely.*) \ 579 579 *(.text.unknown .text.unknown.*) \ 580 580 NOINSTR_TEXT \ 581 - *(.text..refcount) \ 582 581 *(.ref.text) \ 583 582 *(.text.asan.* .text.tsan.*) \ 584 583 MEM_KEEP(init.text*) \
+2 -3
include/drm/gpu_scheduler.h
··· 583 583 bool drm_sched_entity_is_ready(struct drm_sched_entity *entity); 584 584 int drm_sched_entity_error(struct drm_sched_entity *entity); 585 585 586 - void drm_sched_fence_set_parent(struct drm_sched_fence *s_fence, 587 - struct dma_fence *fence); 588 586 struct drm_sched_fence *drm_sched_fence_alloc( 589 587 struct drm_sched_entity *s_entity, void *owner); 590 588 void drm_sched_fence_init(struct drm_sched_fence *fence, 591 589 struct drm_sched_entity *entity); 592 590 void drm_sched_fence_free(struct drm_sched_fence *fence); 593 591 594 - void drm_sched_fence_scheduled(struct drm_sched_fence *fence); 592 + void drm_sched_fence_scheduled(struct drm_sched_fence *fence, 593 + struct dma_fence *parent); 595 594 void drm_sched_fence_finished(struct drm_sched_fence *fence, int result); 596 595 597 596 unsigned long drm_sched_suspend_timeout(struct drm_gpu_scheduler *sched);
+1
include/linux/blk-crypto-profile.h
··· 111 111 * keyslots while ensuring that they can't be changed concurrently. 112 112 */ 113 113 struct rw_semaphore lock; 114 + struct lock_class_key lockdep_key; 114 115 115 116 /* List of idle slots, with least recently used slot at front */ 116 117 wait_queue_head_t idle_slots_wait_queue;
+3 -3
include/linux/blk-mq.h
··· 158 158 159 159 /* 160 160 * The rb_node is only used inside the io scheduler, requests 161 - * are pruned when moved to the dispatch queue. So let the 162 - * completion_data share space with the rb_node. 161 + * are pruned when moved to the dispatch queue. special_vec must 162 + * only be used if RQF_SPECIAL_PAYLOAD is set, and those cannot be 163 + * insert into an IO scheduler. 163 164 */ 164 165 union { 165 166 struct rb_node rb_node; /* sort/lookup */ 166 167 struct bio_vec special_vec; 167 - void *completion_data; 168 168 }; 169 169 170 170 /*
+1 -1
include/linux/dma-fence.h
··· 606 606 void dma_fence_set_deadline(struct dma_fence *fence, ktime_t deadline); 607 607 608 608 struct dma_fence *dma_fence_get_stub(void); 609 - struct dma_fence *dma_fence_allocate_private_stub(void); 609 + struct dma_fence *dma_fence_allocate_private_stub(ktime_t timestamp); 610 610 u64 dma_fence_context_alloc(unsigned num); 611 611 612 612 extern const struct dma_fence_ops dma_fence_array_ops;
+1 -1
include/linux/nvme.h
··· 473 473 }; 474 474 475 475 enum { 476 - NVME_ID_NS_NVM_STS_MASK = 0x3f, 476 + NVME_ID_NS_NVM_STS_MASK = 0x7f, 477 477 NVME_ID_NS_NVM_GUARD_SHIFT = 7, 478 478 NVME_ID_NS_NVM_GUARD_MASK = 0x3, 479 479 };
+3 -2
include/linux/psi.h
··· 23 23 void psi_memstall_leave(unsigned long *flags); 24 24 25 25 int psi_show(struct seq_file *s, struct psi_group *group, enum psi_res res); 26 - struct psi_trigger *psi_trigger_create(struct psi_group *group, 27 - char *buf, enum psi_res res, struct file *file); 26 + struct psi_trigger *psi_trigger_create(struct psi_group *group, char *buf, 27 + enum psi_res res, struct file *file, 28 + struct kernfs_open_file *of); 28 29 void psi_trigger_destroy(struct psi_trigger *t); 29 30 30 31 __poll_t psi_trigger_poll(void **trigger_ptr, struct file *file,
+3
include/linux/psi_types.h
··· 137 137 /* Wait queue for polling */ 138 138 wait_queue_head_t event_wait; 139 139 140 + /* Kernfs file for cgroup triggers */ 141 + struct kernfs_open_file *of; 142 + 140 143 /* Pending event flag */ 141 144 int event; 142 145
+1 -1
include/linux/tcp.h
··· 515 515 struct request_sock_queue *queue = &inet_csk(sk)->icsk_accept_queue; 516 516 int somaxconn = READ_ONCE(sock_net(sk)->core.sysctl_somaxconn); 517 517 518 - queue->fastopenq.max_qlen = min_t(unsigned int, backlog, somaxconn); 518 + WRITE_ONCE(queue->fastopenq.max_qlen, min_t(unsigned int, backlog, somaxconn)); 519 519 } 520 520 521 521 static inline void tcp_move_syn(struct tcp_sock *tp,
+5 -2
include/net/bluetooth/hci_core.h
··· 593 593 const char *fw_info; 594 594 struct dentry *debugfs; 595 595 596 - #ifdef CONFIG_DEV_COREDUMP 597 596 struct hci_devcoredump dump; 598 - #endif 599 597 600 598 struct device dev; 601 599 ··· 820 822 821 823 struct hci_conn *conn; 822 824 bool explicit_connect; 825 + /* Accessed without hdev->lock: */ 823 826 hci_conn_flags_t flags; 824 827 u8 privacy_mode; 825 828 }; ··· 1572 1573 bdaddr_t *addr, u8 addr_type); 1573 1574 void hci_conn_params_del(struct hci_dev *hdev, bdaddr_t *addr, u8 addr_type); 1574 1575 void hci_conn_params_clear_disabled(struct hci_dev *hdev); 1576 + void hci_conn_params_free(struct hci_conn_params *param); 1575 1577 1578 + void hci_pend_le_list_del_init(struct hci_conn_params *param); 1579 + void hci_pend_le_list_add(struct hci_conn_params *param, 1580 + struct list_head *list); 1576 1581 struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list, 1577 1582 bdaddr_t *addr, 1578 1583 u8 addr_type);
+1 -1
include/net/bonding.h
··· 277 277 unsigned short vlan_id; 278 278 }; 279 279 280 - /** 280 + /* 281 281 * Returns NULL if the net_device does not belong to any of the bond's slaves 282 282 * 283 283 * Caller must hold bond lock for read
+2 -1
include/net/cfg802154.h
··· 170 170 } 171 171 172 172 /** 173 - * @WPAN_PHY_FLAG_TRANSMIT_POWER: Indicates that transceiver will support 173 + * enum wpan_phy_flags - WPAN PHY state flags 174 + * @WPAN_PHY_FLAG_TXPOWER: Indicates that transceiver will support 174 175 * transmit power setting. 175 176 * @WPAN_PHY_FLAG_CCA_ED_LEVEL: Indicates that transceiver will support cca ed 176 177 * level setting.
+2 -2
include/net/codel.h
··· 145 145 * @maxpacket: largest packet we've seen so far 146 146 * @drop_count: temp count of dropped packets in dequeue() 147 147 * @drop_len: bytes of dropped packets in dequeue() 148 - * ecn_mark: number of packets we ECN marked instead of dropping 149 - * ce_mark: number of packets CE marked because sojourn time was above ce_threshold 148 + * @ecn_mark: number of packets we ECN marked instead of dropping 149 + * @ce_mark: number of packets CE marked because sojourn time was above ce_threshold 150 150 */ 151 151 struct codel_stats { 152 152 u32 maxpacket;
+16 -12
include/net/devlink.h
··· 221 221 /** 222 222 * struct devlink_dpipe_header - dpipe header object 223 223 * @name: header name 224 - * @id: index, global/local detrmined by global bit 224 + * @id: index, global/local determined by global bit 225 225 * @fields: fields 226 226 * @fields_count: number of fields 227 227 * @global: indicates if header is shared like most protocol header ··· 241 241 * @header_index: header index (packets can have several headers of same 242 242 * type like in case of tunnels) 243 243 * @header: header 244 - * @fieled_id: field index 244 + * @field_id: field index 245 245 */ 246 246 struct devlink_dpipe_match { 247 247 enum devlink_dpipe_match_type type; ··· 256 256 * @header_index: header index (packets can have several headers of same 257 257 * type like in case of tunnels) 258 258 * @header: header 259 - * @fieled_id: field index 259 + * @field_id: field index 260 260 */ 261 261 struct devlink_dpipe_action { 262 262 enum devlink_dpipe_action_type type; ··· 292 292 * struct devlink_dpipe_entry - table entry object 293 293 * @index: index of the entry in the table 294 294 * @match_values: match values 295 - * @matche_values_count: count of matches tuples 295 + * @match_values_count: count of matches tuples 296 296 * @action_values: actions values 297 297 * @action_values_count: count of actions values 298 298 * @counter: value of counter ··· 342 342 */ 343 343 struct devlink_dpipe_table { 344 344 void *priv; 345 + /* private: */ 345 346 struct list_head list; 347 + /* public: */ 346 348 const char *name; 347 349 bool counters_enabled; 348 350 bool counter_control_extern; ··· 357 355 358 356 /** 359 357 * struct devlink_dpipe_table_ops - dpipe_table ops 360 - * @actions_dump - dumps all tables actions 361 - * @matches_dump - dumps all tables matches 362 - * @entries_dump - dumps all active entries in the table 363 - * @counters_set_update - when changing the counter status hardware sync 358 + * @actions_dump: dumps all tables actions 359 + * @matches_dump: dumps all tables matches 360 + * @entries_dump: dumps all active entries in the table 361 + * @counters_set_update: when changing the counter status hardware sync 364 362 * maybe needed to allocate/free counter related 365 363 * resources 366 - * @size_get - get size 364 + * @size_get: get size 367 365 */ 368 366 struct devlink_dpipe_table_ops { 369 367 int (*actions_dump)(void *priv, struct sk_buff *skb); ··· 376 374 377 375 /** 378 376 * struct devlink_dpipe_headers - dpipe headers 379 - * @headers - header array can be shared (global bit) or driver specific 380 - * @headers_count - count of headers 377 + * @headers: header array can be shared (global bit) or driver specific 378 + * @headers_count: count of headers 381 379 */ 382 380 struct devlink_dpipe_headers { 383 381 struct devlink_dpipe_header **headers; ··· 389 387 * @size_min: minimum size which can be set 390 388 * @size_max: maximum size which can be set 391 389 * @size_granularity: size granularity 392 - * @size_unit: resource's basic unit 390 + * @unit: resource's basic unit 393 391 */ 394 392 struct devlink_resource_size_params { 395 393 u64 size_min; ··· 459 457 460 458 /** 461 459 * struct devlink_param - devlink configuration parameter data 460 + * @id: devlink parameter id number 462 461 * @name: name of the parameter 463 462 * @generic: indicates if the parameter is generic or driver specific 464 463 * @type: parameter type ··· 635 632 * struct devlink_flash_update_params - Flash Update parameters 636 633 * @fw: pointer to the firmware data to update from 637 634 * @component: the flash component to update 635 + * @overwrite_mask: which types of flash update are supported (may be %0) 638 636 * 639 637 * With the exception of fw, drivers must opt-in to parameters by 640 638 * setting the appropriate bit in the supported_flash_update_params field in
+1 -1
include/net/inet_frag.h
··· 29 29 }; 30 30 31 31 /** 32 - * fragment queue flags 32 + * enum: fragment queue flags 33 33 * 34 34 * @INET_FRAG_FIRST_IN: first fragment has arrived 35 35 * @INET_FRAG_LAST_IN: final fragment has arrived
+1 -1
include/net/llc_conn.h
··· 111 111 void llc_conn_resend_i_pdu_as_rsp(struct sock *sk, u8 nr, u8 first_f_bit); 112 112 int llc_conn_remove_acked_pdus(struct sock *conn, u8 nr, u16 *how_many_unacked); 113 113 struct sock *llc_lookup_established(struct llc_sap *sap, struct llc_addr *daddr, 114 - struct llc_addr *laddr); 114 + struct llc_addr *laddr, const struct net *net); 115 115 void llc_sap_add_socket(struct llc_sap *sap, struct sock *sk); 116 116 void llc_sap_remove_socket(struct llc_sap *sap, struct sock *sk); 117 117
+4 -2
include/net/llc_pdu.h
··· 269 269 /** 270 270 * llc_pdu_decode_da - extracts dest address of input frame 271 271 * @skb: input skb that destination address must be extracted from it 272 - * @sa: pointer to destination address (6 byte array). 272 + * @da: pointer to destination address (6 byte array). 273 273 * 274 274 * This function extracts destination address(MAC) of input frame. 275 275 */ ··· 321 321 322 322 /** 323 323 * llc_pdu_init_as_test_cmd - sets PDU as TEST 324 - * @skb - Address of the skb to build 324 + * @skb: Address of the skb to build 325 325 * 326 326 * Sets a PDU as TEST 327 327 */ ··· 369 369 /** 370 370 * llc_pdu_init_as_xid_cmd - sets bytes 3, 4 & 5 of LLC header as XID 371 371 * @skb: input skb that header must be set into it. 372 + * @svcs_supported: The class of the LLC (I or II) 373 + * @rx_window: The size of the receive window of the LLC 372 374 * 373 375 * This function sets third,fourth,fifth and sixth bytes of LLC header as 374 376 * a XID PDU.
+1 -1
include/net/nsh.h
··· 192 192 193 193 /** 194 194 * struct nsh_md1_ctx - Keeps track of NSH context data 195 - * @nshc<1-4>: NSH Contexts. 195 + * @context: NSH Contexts. 196 196 */ 197 197 struct nsh_md1_ctx { 198 198 __be32 context[4];
+1 -1
include/net/pie.h
··· 17 17 /** 18 18 * struct pie_params - contains pie parameters 19 19 * @target: target delay in pschedtime 20 - * @tudpate: interval at which drop probability is calculated 20 + * @tupdate: interval at which drop probability is calculated 21 21 * @limit: total number of packets that can be in the queue 22 22 * @alpha: parameter to control drop probability 23 23 * @beta: parameter to control drop probability
+1 -1
include/net/rsi_91x.h
··· 1 - /** 1 + /* 2 2 * Copyright (c) 2017 Redpine Signals Inc. 3 3 * 4 4 * Permission to use, copy, modify, and/or distribute this software for any
+24 -7
include/net/tcp.h
··· 1523 1523 static inline int keepalive_intvl_when(const struct tcp_sock *tp) 1524 1524 { 1525 1525 struct net *net = sock_net((struct sock *)tp); 1526 + int val; 1526 1527 1527 - return tp->keepalive_intvl ? : 1528 - READ_ONCE(net->ipv4.sysctl_tcp_keepalive_intvl); 1528 + /* Paired with WRITE_ONCE() in tcp_sock_set_keepintvl() 1529 + * and do_tcp_setsockopt(). 1530 + */ 1531 + val = READ_ONCE(tp->keepalive_intvl); 1532 + 1533 + return val ? : READ_ONCE(net->ipv4.sysctl_tcp_keepalive_intvl); 1529 1534 } 1530 1535 1531 1536 static inline int keepalive_time_when(const struct tcp_sock *tp) 1532 1537 { 1533 1538 struct net *net = sock_net((struct sock *)tp); 1539 + int val; 1534 1540 1535 - return tp->keepalive_time ? : 1536 - READ_ONCE(net->ipv4.sysctl_tcp_keepalive_time); 1541 + /* Paired with WRITE_ONCE() in tcp_sock_set_keepidle_locked() */ 1542 + val = READ_ONCE(tp->keepalive_time); 1543 + 1544 + return val ? : READ_ONCE(net->ipv4.sysctl_tcp_keepalive_time); 1537 1545 } 1538 1546 1539 1547 static inline int keepalive_probes(const struct tcp_sock *tp) 1540 1548 { 1541 1549 struct net *net = sock_net((struct sock *)tp); 1550 + int val; 1542 1551 1543 - return tp->keepalive_probes ? : 1544 - READ_ONCE(net->ipv4.sysctl_tcp_keepalive_probes); 1552 + /* Paired with WRITE_ONCE() in tcp_sock_set_keepcnt() 1553 + * and do_tcp_setsockopt(). 1554 + */ 1555 + val = READ_ONCE(tp->keepalive_probes); 1556 + 1557 + return val ? : READ_ONCE(net->ipv4.sysctl_tcp_keepalive_probes); 1545 1558 } 1546 1559 1547 1560 static inline u32 keepalive_time_elapsed(const struct tcp_sock *tp) ··· 2075 2062 static inline u32 tcp_notsent_lowat(const struct tcp_sock *tp) 2076 2063 { 2077 2064 struct net *net = sock_net((struct sock *)tp); 2078 - return tp->notsent_lowat ?: READ_ONCE(net->ipv4.sysctl_tcp_notsent_lowat); 2065 + u32 val; 2066 + 2067 + val = READ_ONCE(tp->notsent_lowat); 2068 + 2069 + return val ?: READ_ONCE(net->ipv4.sysctl_tcp_notsent_lowat); 2079 2070 } 2080 2071 2081 2072 bool tcp_stream_memory_free(const struct sock *sk, int wake);
+3
include/uapi/linux/fuse.h
··· 206 206 * - add extension header 207 207 * - add FUSE_EXT_GROUPS 208 208 * - add FUSE_CREATE_SUPP_GROUP 209 + * - add FUSE_HAS_EXPIRE_ONLY 209 210 */ 210 211 211 212 #ifndef _LINUX_FUSE_H ··· 370 369 * FUSE_HAS_INODE_DAX: use per inode DAX 371 370 * FUSE_CREATE_SUPP_GROUP: add supplementary group info to create, mkdir, 372 371 * symlink and mknod (single group that matches parent) 372 + * FUSE_HAS_EXPIRE_ONLY: kernel supports expiry-only entry invalidation 373 373 */ 374 374 #define FUSE_ASYNC_READ (1 << 0) 375 375 #define FUSE_POSIX_LOCKS (1 << 1) ··· 408 406 #define FUSE_SECURITY_CTX (1ULL << 32) 409 407 #define FUSE_HAS_INODE_DAX (1ULL << 33) 410 408 #define FUSE_CREATE_SUPP_GROUP (1ULL << 34) 409 + #define FUSE_HAS_EXPIRE_ONLY (1ULL << 35) 411 410 412 411 /** 413 412 * CUSE INIT request/reply flags
+25
include/uapi/scsi/scsi_bsg_ufs.h
··· 71 71 }; 72 72 73 73 /** 74 + * struct utp_upiu_query_v4_0 - upiu request buffer structure for 75 + * query request >= UFS 4.0 spec. 76 + * @opcode: command to perform B-0 77 + * @idn: a value that indicates the particular type of data B-1 78 + * @index: Index to further identify data B-2 79 + * @selector: Index to further identify data B-3 80 + * @osf4: spec field B-5 81 + * @osf5: spec field B 6,7 82 + * @osf6: spec field DW 8,9 83 + * @osf7: spec field DW 10,11 84 + */ 85 + struct utp_upiu_query_v4_0 { 86 + __u8 opcode; 87 + __u8 idn; 88 + __u8 index; 89 + __u8 selector; 90 + __u8 osf3; 91 + __u8 osf4; 92 + __be16 osf5; 93 + __be32 osf6; 94 + __be32 osf7; 95 + __be32 reserved; 96 + }; 97 + 98 + /** 74 99 * struct utp_upiu_cmd - Command UPIU structure 75 100 * @data_transfer_len: Data Transfer Length DW-3 76 101 * @cdb: Command Descriptor Block CDB DW-4 to DW-7
+1
include/ufs/ufs.h
··· 170 170 QUERY_ATTR_IDN_WB_BUFF_LIFE_TIME_EST = 0x1E, 171 171 QUERY_ATTR_IDN_CURR_WB_BUFF_SIZE = 0x1F, 172 172 QUERY_ATTR_IDN_EXT_IID_EN = 0x2A, 173 + QUERY_ATTR_IDN_TIMESTAMP = 0x30 173 174 }; 174 175 175 176 /* Descriptor idn for Query requests */
+13 -2
io_uring/io_uring.c
··· 2489 2489 static inline int io_cqring_wait_schedule(struct io_ring_ctx *ctx, 2490 2490 struct io_wait_queue *iowq) 2491 2491 { 2492 + int token, ret; 2493 + 2492 2494 if (unlikely(READ_ONCE(ctx->check_cq))) 2493 2495 return 1; 2494 2496 if (unlikely(!llist_empty(&ctx->work_llist))) ··· 2501 2499 return -EINTR; 2502 2500 if (unlikely(io_should_wake(iowq))) 2503 2501 return 0; 2502 + 2503 + /* 2504 + * Use io_schedule_prepare/finish, so cpufreq can take into account 2505 + * that the task is waiting for IO - turns out to be important for low 2506 + * QD IO. 2507 + */ 2508 + token = io_schedule_prepare(); 2509 + ret = 0; 2504 2510 if (iowq->timeout == KTIME_MAX) 2505 2511 schedule(); 2506 2512 else if (!schedule_hrtimeout(&iowq->timeout, HRTIMER_MODE_ABS)) 2507 - return -ETIME; 2508 - return 0; 2513 + ret = -ETIME; 2514 + io_schedule_finish(token); 2515 + return ret; 2509 2516 } 2510 2517 2511 2518 /*
+25 -7
kernel/bpf/verifier.c
··· 5587 5587 * Since recursion is prevented by check_cfg() this algorithm 5588 5588 * only needs a local stack of MAX_CALL_FRAMES to remember callsites 5589 5589 */ 5590 - static int check_max_stack_depth(struct bpf_verifier_env *env) 5590 + static int check_max_stack_depth_subprog(struct bpf_verifier_env *env, int idx) 5591 5591 { 5592 - int depth = 0, frame = 0, idx = 0, i = 0, subprog_end; 5593 5592 struct bpf_subprog_info *subprog = env->subprog_info; 5594 5593 struct bpf_insn *insn = env->prog->insnsi; 5594 + int depth = 0, frame = 0, i, subprog_end; 5595 5595 bool tail_call_reachable = false; 5596 5596 int ret_insn[MAX_CALL_FRAMES]; 5597 5597 int ret_prog[MAX_CALL_FRAMES]; 5598 5598 int j; 5599 5599 5600 + i = subprog[idx].start; 5600 5601 process_func: 5601 5602 /* protect against potential stack overflow that might happen when 5602 5603 * bpf2bpf calls get combined with tailcalls. Limit the caller's stack ··· 5636 5635 continue_func: 5637 5636 subprog_end = subprog[idx + 1].start; 5638 5637 for (; i < subprog_end; i++) { 5639 - int next_insn; 5638 + int next_insn, sidx; 5640 5639 5641 5640 if (!bpf_pseudo_call(insn + i) && !bpf_pseudo_func(insn + i)) 5642 5641 continue; ··· 5646 5645 5647 5646 /* find the callee */ 5648 5647 next_insn = i + insn[i].imm + 1; 5649 - idx = find_subprog(env, next_insn); 5650 - if (idx < 0) { 5648 + sidx = find_subprog(env, next_insn); 5649 + if (sidx < 0) { 5651 5650 WARN_ONCE(1, "verifier bug. No program starts at insn %d\n", 5652 5651 next_insn); 5653 5652 return -EFAULT; 5654 5653 } 5655 - if (subprog[idx].is_async_cb) { 5656 - if (subprog[idx].has_tail_call) { 5654 + if (subprog[sidx].is_async_cb) { 5655 + if (subprog[sidx].has_tail_call) { 5657 5656 verbose(env, "verifier bug. subprog has tail_call and async cb\n"); 5658 5657 return -EFAULT; 5659 5658 } ··· 5662 5661 continue; 5663 5662 } 5664 5663 i = next_insn; 5664 + idx = sidx; 5665 5665 5666 5666 if (subprog[idx].has_tail_call) 5667 5667 tail_call_reachable = true; ··· 5696 5694 i = ret_insn[frame]; 5697 5695 idx = ret_prog[frame]; 5698 5696 goto continue_func; 5697 + } 5698 + 5699 + static int check_max_stack_depth(struct bpf_verifier_env *env) 5700 + { 5701 + struct bpf_subprog_info *si = env->subprog_info; 5702 + int ret; 5703 + 5704 + for (int i = 0; i < env->subprog_cnt; i++) { 5705 + if (!i || si[i].is_async_cb) { 5706 + ret = check_max_stack_depth_subprog(env, i); 5707 + if (ret < 0) 5708 + return ret; 5709 + } 5710 + continue; 5711 + } 5712 + return 0; 5699 5713 } 5700 5714 5701 5715 #ifndef CONFIG_BPF_JIT_ALWAYS_ON
+1 -1
kernel/cgroup/cgroup.c
··· 3730 3730 } 3731 3731 3732 3732 psi = cgroup_psi(cgrp); 3733 - new = psi_trigger_create(psi, buf, res, of->file); 3733 + new = psi_trigger_create(psi, buf, res, of->file, of); 3734 3734 if (IS_ERR(new)) { 3735 3735 cgroup_put(cgrp); 3736 3736 return PTR_ERR(new);
+2 -3
kernel/kallsyms.c
··· 174 174 * LLVM appends various suffixes for local functions and variables that 175 175 * must be promoted to global scope as part of LTO. This can break 176 176 * hooking of static functions with kprobes. '.' is not a valid 177 - * character in an identifier in C. Suffixes observed: 177 + * character in an identifier in C. Suffixes only in LLVM LTO observed: 178 178 * - foo.llvm.[0-9a-f]+ 179 - * - foo.[0-9a-f]+ 180 179 */ 181 - res = strchr(s, '.'); 180 + res = strstr(s, ".llvm."); 182 181 if (res) { 183 182 *res = '\0'; 184 183 return true;
+1
kernel/power/hibernate.c
··· 1179 1179 unsigned maj, min, offset; 1180 1180 char *p, dummy; 1181 1181 1182 + error = 0; 1182 1183 if (sscanf(name, "%u:%u%c", &maj, &min, &dummy) == 2 || 1183 1184 sscanf(name, "%u:%u:%u:%c", &maj, &min, &offset, 1184 1185 &dummy) == 3) {
+7 -2
kernel/power/qos.c
··· 426 426 427 427 /* Definitions related to the frequency QoS below. */ 428 428 429 + static inline bool freq_qos_value_invalid(s32 value) 430 + { 431 + return value < 0 && value != PM_QOS_DEFAULT_VALUE; 432 + } 433 + 429 434 /** 430 435 * freq_constraints_init - Initialize frequency QoS constraints. 431 436 * @qos: Frequency QoS constraints to initialize. ··· 536 531 { 537 532 int ret; 538 533 539 - if (IS_ERR_OR_NULL(qos) || !req || value < 0) 534 + if (IS_ERR_OR_NULL(qos) || !req || freq_qos_value_invalid(value)) 540 535 return -EINVAL; 541 536 542 537 if (WARN(freq_qos_request_active(req), ··· 568 563 */ 569 564 int freq_qos_update_request(struct freq_qos_request *req, s32 new_value) 570 565 { 571 - if (!req || new_value < 0) 566 + if (!req || freq_qos_value_invalid(new_value)) 572 567 return -EINVAL; 573 568 574 569 if (WARN(!freq_qos_request_active(req),
+1 -1
kernel/sched/fair.c
··· 7174 7174 recent_used_cpu != target && 7175 7175 cpus_share_cache(recent_used_cpu, target) && 7176 7176 (available_idle_cpu(recent_used_cpu) || sched_idle_cpu(recent_used_cpu)) && 7177 - cpumask_test_cpu(p->recent_used_cpu, p->cpus_ptr) && 7177 + cpumask_test_cpu(recent_used_cpu, p->cpus_ptr) && 7178 7178 asym_fits_cpu(task_util, util_min, util_max, recent_used_cpu)) { 7179 7179 return recent_used_cpu; 7180 7180 }
+21 -8
kernel/sched/psi.c
··· 493 493 continue; 494 494 495 495 /* Generate an event */ 496 - if (cmpxchg(&t->event, 0, 1) == 0) 497 - wake_up_interruptible(&t->event_wait); 496 + if (cmpxchg(&t->event, 0, 1) == 0) { 497 + if (t->of) 498 + kernfs_notify(t->of->kn); 499 + else 500 + wake_up_interruptible(&t->event_wait); 501 + } 498 502 t->last_event_time = now; 499 503 /* Reset threshold breach flag once event got generated */ 500 504 t->pending_event = false; ··· 1275 1271 return 0; 1276 1272 } 1277 1273 1278 - struct psi_trigger *psi_trigger_create(struct psi_group *group, 1279 - char *buf, enum psi_res res, struct file *file) 1274 + struct psi_trigger *psi_trigger_create(struct psi_group *group, char *buf, 1275 + enum psi_res res, struct file *file, 1276 + struct kernfs_open_file *of) 1280 1277 { 1281 1278 struct psi_trigger *t; 1282 1279 enum psi_states state; ··· 1336 1331 1337 1332 t->event = 0; 1338 1333 t->last_event_time = 0; 1339 - init_waitqueue_head(&t->event_wait); 1334 + t->of = of; 1335 + if (!of) 1336 + init_waitqueue_head(&t->event_wait); 1340 1337 t->pending_event = false; 1341 1338 t->aggregator = privileged ? PSI_POLL : PSI_AVGS; 1342 1339 ··· 1395 1388 * being accessed later. Can happen if cgroup is deleted from under a 1396 1389 * polling process. 1397 1390 */ 1398 - wake_up_pollfree(&t->event_wait); 1391 + if (t->of) 1392 + kernfs_notify(t->of->kn); 1393 + else 1394 + wake_up_interruptible(&t->event_wait); 1399 1395 1400 1396 if (t->aggregator == PSI_AVGS) { 1401 1397 mutex_lock(&group->avgs_lock); ··· 1475 1465 if (!t) 1476 1466 return DEFAULT_POLLMASK | EPOLLERR | EPOLLPRI; 1477 1467 1478 - poll_wait(file, &t->event_wait, wait); 1468 + if (t->of) 1469 + kernfs_generic_poll(t->of, wait); 1470 + else 1471 + poll_wait(file, &t->event_wait, wait); 1479 1472 1480 1473 if (cmpxchg(&t->event, 1, 0) == 1) 1481 1474 ret |= EPOLLPRI; ··· 1548 1535 return -EBUSY; 1549 1536 } 1550 1537 1551 - new = psi_trigger_create(&psi_system, buf, res, file); 1538 + new = psi_trigger_create(&psi_system, buf, res, file, NULL); 1552 1539 if (IS_ERR(new)) { 1553 1540 mutex_unlock(&seq->lock); 1554 1541 return PTR_ERR(new);
+5 -5
kernel/sys.c
··· 2535 2535 else 2536 2536 return -EINVAL; 2537 2537 break; 2538 - case PR_GET_AUXV: 2539 - if (arg4 || arg5) 2540 - return -EINVAL; 2541 - error = prctl_get_auxv((void __user *)arg2, arg3); 2542 - break; 2543 2538 default: 2544 2539 return -EINVAL; 2545 2540 } ··· 2688 2693 break; 2689 2694 case PR_SET_VMA: 2690 2695 error = prctl_set_vma(arg2, arg3, arg4, arg5); 2696 + break; 2697 + case PR_GET_AUXV: 2698 + if (arg4 || arg5) 2699 + return -EINVAL; 2700 + error = prctl_get_auxv((void __user *)arg2, arg3); 2691 2701 break; 2692 2702 #ifdef CONFIG_KSM 2693 2703 case PR_SET_MEMORY_MERGE:
+6
kernel/trace/fprobe.c
··· 100 100 return; 101 101 } 102 102 103 + /* 104 + * This user handler is shared with other kprobes and is not expected to be 105 + * called recursively. So if any other kprobe handler is running, this will 106 + * exit as kprobe does. See the section 'Share the callbacks with kprobes' 107 + * in Documentation/trace/fprobe.rst for more information. 108 + */ 103 109 if (unlikely(kprobe_running())) { 104 110 fp->nmissed++; 105 111 goto recursion_unlock;
+2
kernel/trace/trace.h
··· 113 113 #define MEM_FAIL(condition, fmt, ...) \ 114 114 DO_ONCE_LITE_IF(condition, pr_err, "ERROR: " fmt, ##__VA_ARGS__) 115 115 116 + #define FAULT_STRING "(fault)" 117 + 116 118 #define HIST_STACKTRACE_DEPTH 16 117 119 #define HIST_STACKTRACE_SIZE (HIST_STACKTRACE_DEPTH * sizeof(unsigned long)) 118 120 #define HIST_STACKTRACE_SKIP 5
+1 -1
kernel/trace/trace_probe.c
··· 67 67 int len = *(u32 *)data >> 16; 68 68 69 69 if (!len) 70 - trace_seq_puts(s, "(fault)"); 70 + trace_seq_puts(s, FAULT_STRING); 71 71 else 72 72 trace_seq_printf(s, "\"%s\"", 73 73 (const char *)get_loc_data(data, ent));
+8 -22
kernel/trace/trace_probe_kernel.h
··· 2 2 #ifndef __TRACE_PROBE_KERNEL_H_ 3 3 #define __TRACE_PROBE_KERNEL_H_ 4 4 5 - #define FAULT_STRING "(fault)" 6 - 7 5 /* 8 6 * This depends on trace_probe.h, but can not include it due to 9 7 * the way trace_probe_tmpl.h is used by trace_kprobe.c and trace_eprobe.c. ··· 13 15 fetch_store_strlen_user(unsigned long addr) 14 16 { 15 17 const void __user *uaddr = (__force const void __user *)addr; 16 - int ret; 17 18 18 - ret = strnlen_user_nofault(uaddr, MAX_STRING_SIZE); 19 - /* 20 - * strnlen_user_nofault returns zero on fault, insert the 21 - * FAULT_STRING when that occurs. 22 - */ 23 - if (ret <= 0) 24 - return strlen(FAULT_STRING) + 1; 25 - return ret; 19 + return strnlen_user_nofault(uaddr, MAX_STRING_SIZE); 26 20 } 27 21 28 22 /* Return the length of string -- including null terminal byte */ ··· 34 44 len++; 35 45 } while (c && ret == 0 && len < MAX_STRING_SIZE); 36 46 37 - /* For faults, return enough to hold the FAULT_STRING */ 38 - return (ret < 0) ? strlen(FAULT_STRING) + 1 : len; 47 + return (ret < 0) ? ret : len; 39 48 } 40 49 41 - static nokprobe_inline void set_data_loc(int ret, void *dest, void *__dest, void *base, int len) 50 + static nokprobe_inline void set_data_loc(int ret, void *dest, void *__dest, void *base) 42 51 { 43 - if (ret >= 0) { 44 - *(u32 *)dest = make_data_loc(ret, __dest - base); 45 - } else { 46 - strscpy(__dest, FAULT_STRING, len); 47 - ret = strlen(__dest) + 1; 48 - } 52 + if (ret < 0) 53 + ret = 0; 54 + *(u32 *)dest = make_data_loc(ret, __dest - base); 49 55 } 50 56 51 57 /* ··· 62 76 __dest = get_loc_data(dest, base); 63 77 64 78 ret = strncpy_from_user_nofault(__dest, uaddr, maxlen); 65 - set_data_loc(ret, dest, __dest, base, maxlen); 79 + set_data_loc(ret, dest, __dest, base); 66 80 67 81 return ret; 68 82 } ··· 93 107 * probing. 94 108 */ 95 109 ret = strncpy_from_kernel_nofault(__dest, (void *)addr, maxlen); 96 - set_data_loc(ret, dest, __dest, base, maxlen); 110 + set_data_loc(ret, dest, __dest, base); 97 111 98 112 return ret; 99 113 }
+5 -5
kernel/trace/trace_probe_tmpl.h
··· 156 156 code++; 157 157 goto array; 158 158 case FETCH_OP_ST_USTRING: 159 - ret += fetch_store_strlen_user(val + code->offset); 159 + ret = fetch_store_strlen_user(val + code->offset); 160 160 code++; 161 161 goto array; 162 162 case FETCH_OP_ST_SYMSTR: 163 - ret += fetch_store_symstrlen(val + code->offset); 163 + ret = fetch_store_symstrlen(val + code->offset); 164 164 code++; 165 165 goto array; 166 166 default: ··· 204 204 array: 205 205 /* the last stage: Loop on array */ 206 206 if (code->op == FETCH_OP_LP_ARRAY) { 207 + if (ret < 0) 208 + ret = 0; 207 209 total += ret; 208 210 if (++i < code->param) { 209 211 code = s3; ··· 267 265 if (unlikely(arg->dynamic)) 268 266 *dl = make_data_loc(maxlen, dyndata - base); 269 267 ret = process_fetch_insn(arg->code, rec, dl, base); 270 - if (unlikely(ret < 0 && arg->dynamic)) { 271 - *dl = make_data_loc(0, dyndata - base); 272 - } else { 268 + if (arg->dynamic && likely(ret > 0)) { 273 269 dyndata += ret; 274 270 maxlen -= ret; 275 271 }
+2 -1
kernel/trace/trace_uprobe.c
··· 170 170 */ 171 171 ret++; 172 172 *(u32 *)dest = make_data_loc(ret, (void *)dst - base); 173 - } 173 + } else 174 + *(u32 *)dest = make_data_loc(0, (void *)dst - base); 174 175 175 176 return ret; 176 177 }
+1 -1
lib/iov_iter.c
··· 1349 1349 return ret; 1350 1350 } 1351 1351 1352 - static int copy_iovec_from_user(struct iovec *iov, 1352 + static __noclone int copy_iovec_from_user(struct iovec *iov, 1353 1353 const struct iovec __user *uiov, unsigned long nr_segs) 1354 1354 { 1355 1355 int ret = -EFAULT;
+2 -1
lib/maple_tree.c
··· 3692 3692 mas->offset = slot; 3693 3693 pivots[slot] = mas->last; 3694 3694 if (mas->last != ULONG_MAX) 3695 - slot++; 3695 + pivots[++slot] = ULONG_MAX; 3696 + 3696 3697 mas->depth = 1; 3697 3698 mas_set_height(mas); 3698 3699 ma_set_meta(node, maple_leaf_64, 0, slot);
+4 -1
lib/test_maple_tree.c
··· 1898 1898 725}; 1899 1899 static const unsigned long level2_32[] = { 1747, 2000, 1750, 1755, 1900 1900 1760, 1765}; 1901 + unsigned long last_index; 1901 1902 1902 1903 if (MAPLE_32BIT) { 1903 1904 nr_entries = 500; 1904 1905 level2 = level2_32; 1906 + last_index = 0x138e; 1905 1907 } else { 1906 1908 nr_entries = 200; 1907 1909 level2 = level2_64; 1910 + last_index = 0x7d6; 1908 1911 } 1909 1912 1910 1913 for (i = 0; i <= nr_entries; i++) ··· 2014 2011 2015 2012 val = mas_next(&mas, ULONG_MAX); 2016 2013 MT_BUG_ON(mt, val != NULL); 2017 - MT_BUG_ON(mt, mas.index != 0x7d6); 2014 + MT_BUG_ON(mt, mas.index != last_index); 2018 2015 MT_BUG_ON(mt, mas.last != ULONG_MAX); 2019 2016 2020 2017 val = mas_prev(&mas, 0);
+5 -4
mm/mlock.c
··· 477 477 { 478 478 unsigned long nstart, end, tmp; 479 479 struct vm_area_struct *vma, *prev; 480 - int error; 481 480 VMA_ITERATOR(vmi, current->mm, start); 482 481 483 482 VM_BUG_ON(offset_in_page(start)); ··· 497 498 nstart = start; 498 499 tmp = vma->vm_start; 499 500 for_each_vma_range(vmi, vma, end) { 501 + int error; 500 502 vm_flags_t newflags; 501 503 502 504 if (vma->vm_start != tmp) ··· 511 511 tmp = end; 512 512 error = mlock_fixup(&vmi, vma, &prev, nstart, tmp, newflags); 513 513 if (error) 514 - break; 514 + return error; 515 + tmp = vma_iter_end(&vmi); 515 516 nstart = tmp; 516 517 } 517 518 518 - if (vma_iter_end(&vmi) < end) 519 + if (tmp < end) 519 520 return -ENOMEM; 520 521 521 - return error; 522 + return 0; 522 523 } 523 524 524 525 /*
+7 -7
net/bluetooth/hci_conn.c
··· 118 118 */ 119 119 params->explicit_connect = false; 120 120 121 - list_del_init(&params->action); 121 + hci_pend_le_list_del_init(params); 122 122 123 123 switch (params->auto_connect) { 124 124 case HCI_AUTO_CONN_EXPLICIT: ··· 127 127 return; 128 128 case HCI_AUTO_CONN_DIRECT: 129 129 case HCI_AUTO_CONN_ALWAYS: 130 - list_add(&params->action, &hdev->pend_le_conns); 130 + hci_pend_le_list_add(params, &hdev->pend_le_conns); 131 131 break; 132 132 case HCI_AUTO_CONN_REPORT: 133 - list_add(&params->action, &hdev->pend_le_reports); 133 + hci_pend_le_list_add(params, &hdev->pend_le_reports); 134 134 break; 135 135 default: 136 136 break; ··· 1426 1426 if (params->auto_connect == HCI_AUTO_CONN_DISABLED || 1427 1427 params->auto_connect == HCI_AUTO_CONN_REPORT || 1428 1428 params->auto_connect == HCI_AUTO_CONN_EXPLICIT) { 1429 - list_del_init(&params->action); 1430 - list_add(&params->action, &hdev->pend_le_conns); 1429 + hci_pend_le_list_del_init(params); 1430 + hci_pend_le_list_add(params, &hdev->pend_le_conns); 1431 1431 } 1432 1432 1433 1433 params->explicit_connect = true; ··· 1684 1684 if (!link) { 1685 1685 hci_conn_drop(acl); 1686 1686 hci_conn_drop(sco); 1687 - return NULL; 1687 + return ERR_PTR(-ENOLINK); 1688 1688 } 1689 1689 1690 1690 sco->setting = setting; ··· 2254 2254 if (!link) { 2255 2255 hci_conn_drop(le); 2256 2256 hci_conn_drop(cis); 2257 - return NULL; 2257 + return ERR_PTR(-ENOLINK); 2258 2258 } 2259 2259 2260 2260 /* If LE is already connected and CIS handle is already set proceed to
+34 -8
net/bluetooth/hci_core.c
··· 1972 1972 struct adv_monitor *monitor) 1973 1973 { 1974 1974 int status = 0; 1975 + int handle; 1975 1976 1976 1977 switch (hci_get_adv_monitor_offload_ext(hdev)) { 1977 1978 case HCI_ADV_MONITOR_EXT_NONE: /* also goes here when powered off */ ··· 1981 1980 goto free_monitor; 1982 1981 1983 1982 case HCI_ADV_MONITOR_EXT_MSFT: 1983 + handle = monitor->handle; 1984 1984 status = msft_remove_monitor(hdev, monitor); 1985 1985 bt_dev_dbg(hdev, "%s remove monitor %d msft status %d", 1986 - hdev->name, monitor->handle, status); 1986 + hdev->name, handle, status); 1987 1987 break; 1988 1988 } 1989 1989 ··· 2251 2249 return NULL; 2252 2250 } 2253 2251 2254 - /* This function requires the caller holds hdev->lock */ 2252 + /* This function requires the caller holds hdev->lock or rcu_read_lock */ 2255 2253 struct hci_conn_params *hci_pend_le_action_lookup(struct list_head *list, 2256 2254 bdaddr_t *addr, u8 addr_type) 2257 2255 { 2258 2256 struct hci_conn_params *param; 2259 2257 2260 - list_for_each_entry(param, list, action) { 2258 + rcu_read_lock(); 2259 + 2260 + list_for_each_entry_rcu(param, list, action) { 2261 2261 if (bacmp(&param->addr, addr) == 0 && 2262 - param->addr_type == addr_type) 2262 + param->addr_type == addr_type) { 2263 + rcu_read_unlock(); 2263 2264 return param; 2265 + } 2264 2266 } 2265 2267 2268 + rcu_read_unlock(); 2269 + 2266 2270 return NULL; 2271 + } 2272 + 2273 + /* This function requires the caller holds hdev->lock */ 2274 + void hci_pend_le_list_del_init(struct hci_conn_params *param) 2275 + { 2276 + if (list_empty(&param->action)) 2277 + return; 2278 + 2279 + list_del_rcu(&param->action); 2280 + synchronize_rcu(); 2281 + INIT_LIST_HEAD(&param->action); 2282 + } 2283 + 2284 + /* This function requires the caller holds hdev->lock */ 2285 + void hci_pend_le_list_add(struct hci_conn_params *param, 2286 + struct list_head *list) 2287 + { 2288 + list_add_rcu(&param->action, list); 2267 2289 } 2268 2290 2269 2291 /* This function requires the caller holds hdev->lock */ ··· 2323 2297 return params; 2324 2298 } 2325 2299 2326 - static void hci_conn_params_free(struct hci_conn_params *params) 2300 + void hci_conn_params_free(struct hci_conn_params *params) 2327 2301 { 2302 + hci_pend_le_list_del_init(params); 2303 + 2328 2304 if (params->conn) { 2329 2305 hci_conn_drop(params->conn); 2330 2306 hci_conn_put(params->conn); 2331 2307 } 2332 2308 2333 - list_del(&params->action); 2334 2309 list_del(&params->list); 2335 2310 kfree(params); 2336 2311 } ··· 2369 2342 continue; 2370 2343 } 2371 2344 2372 - list_del(&params->list); 2373 - kfree(params); 2345 + hci_conn_params_free(params); 2374 2346 } 2375 2347 2376 2348 BT_DBG("All LE disabled connection parameters were removed");
+9 -6
net/bluetooth/hci_event.c
··· 1564 1564 1565 1565 params = hci_conn_params_lookup(hdev, &cp->bdaddr, cp->bdaddr_type); 1566 1566 if (params) 1567 - params->privacy_mode = cp->mode; 1567 + WRITE_ONCE(params->privacy_mode, cp->mode); 1568 1568 1569 1569 hci_dev_unlock(hdev); 1570 1570 ··· 2784 2784 hci_enable_advertising(hdev); 2785 2785 } 2786 2786 2787 + /* Inform sockets conn is gone before we delete it */ 2788 + hci_disconn_cfm(conn, HCI_ERROR_UNSPECIFIED); 2789 + 2787 2790 goto done; 2788 2791 } 2789 2792 ··· 2807 2804 2808 2805 case HCI_AUTO_CONN_DIRECT: 2809 2806 case HCI_AUTO_CONN_ALWAYS: 2810 - list_del_init(&params->action); 2811 - list_add(&params->action, &hdev->pend_le_conns); 2807 + hci_pend_le_list_del_init(params); 2808 + hci_pend_le_list_add(params, &hdev->pend_le_conns); 2812 2809 break; 2813 2810 2814 2811 default: ··· 3426 3423 3427 3424 case HCI_AUTO_CONN_DIRECT: 3428 3425 case HCI_AUTO_CONN_ALWAYS: 3429 - list_del_init(&params->action); 3430 - list_add(&params->action, &hdev->pend_le_conns); 3426 + hci_pend_le_list_del_init(params); 3427 + hci_pend_le_list_add(params, &hdev->pend_le_conns); 3431 3428 hci_update_passive_scan(hdev); 3432 3429 break; 3433 3430 ··· 5965 5962 params = hci_pend_le_action_lookup(&hdev->pend_le_conns, &conn->dst, 5966 5963 conn->dst_type); 5967 5964 if (params) { 5968 - list_del_init(&params->action); 5965 + hci_pend_le_list_del_init(params); 5969 5966 if (params->conn) { 5970 5967 hci_conn_drop(params->conn); 5971 5968 hci_conn_put(params->conn);
+108 -13
net/bluetooth/hci_sync.c
··· 2160 2160 return 0; 2161 2161 } 2162 2162 2163 + struct conn_params { 2164 + bdaddr_t addr; 2165 + u8 addr_type; 2166 + hci_conn_flags_t flags; 2167 + u8 privacy_mode; 2168 + }; 2169 + 2163 2170 /* Adds connection to resolve list if needed. 2164 2171 * Setting params to NULL programs local hdev->irk 2165 2172 */ 2166 2173 static int hci_le_add_resolve_list_sync(struct hci_dev *hdev, 2167 - struct hci_conn_params *params) 2174 + struct conn_params *params) 2168 2175 { 2169 2176 struct hci_cp_le_add_to_resolv_list cp; 2170 2177 struct smp_irk *irk; 2171 2178 struct bdaddr_list_with_irk *entry; 2179 + struct hci_conn_params *p; 2172 2180 2173 2181 if (!use_ll_privacy(hdev)) 2174 2182 return 0; ··· 2211 2203 /* Default privacy mode is always Network */ 2212 2204 params->privacy_mode = HCI_NETWORK_PRIVACY; 2213 2205 2206 + rcu_read_lock(); 2207 + p = hci_pend_le_action_lookup(&hdev->pend_le_conns, 2208 + &params->addr, params->addr_type); 2209 + if (!p) 2210 + p = hci_pend_le_action_lookup(&hdev->pend_le_reports, 2211 + &params->addr, params->addr_type); 2212 + if (p) 2213 + WRITE_ONCE(p->privacy_mode, HCI_NETWORK_PRIVACY); 2214 + rcu_read_unlock(); 2215 + 2214 2216 done: 2215 2217 if (hci_dev_test_flag(hdev, HCI_PRIVACY)) 2216 2218 memcpy(cp.local_irk, hdev->irk, 16); ··· 2233 2215 2234 2216 /* Set Device Privacy Mode. */ 2235 2217 static int hci_le_set_privacy_mode_sync(struct hci_dev *hdev, 2236 - struct hci_conn_params *params) 2218 + struct conn_params *params) 2237 2219 { 2238 2220 struct hci_cp_le_set_privacy_mode cp; 2239 2221 struct smp_irk *irk; ··· 2258 2240 bacpy(&cp.bdaddr, &irk->bdaddr); 2259 2241 cp.mode = HCI_DEVICE_PRIVACY; 2260 2242 2243 + /* Note: params->privacy_mode is not updated since it is a copy */ 2244 + 2261 2245 return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_PRIVACY_MODE, 2262 2246 sizeof(cp), &cp, HCI_CMD_TIMEOUT); 2263 2247 } ··· 2269 2249 * properly set the privacy mode. 2270 2250 */ 2271 2251 static int hci_le_add_accept_list_sync(struct hci_dev *hdev, 2272 - struct hci_conn_params *params, 2252 + struct conn_params *params, 2273 2253 u8 *num_entries) 2274 2254 { 2275 2255 struct hci_cp_le_add_to_accept_list cp; ··· 2467 2447 return __hci_cmd_sync_sk(hdev, opcode, 0, NULL, 0, HCI_CMD_TIMEOUT, sk); 2468 2448 } 2469 2449 2450 + static struct conn_params *conn_params_copy(struct list_head *list, size_t *n) 2451 + { 2452 + struct hci_conn_params *params; 2453 + struct conn_params *p; 2454 + size_t i; 2455 + 2456 + rcu_read_lock(); 2457 + 2458 + i = 0; 2459 + list_for_each_entry_rcu(params, list, action) 2460 + ++i; 2461 + *n = i; 2462 + 2463 + rcu_read_unlock(); 2464 + 2465 + p = kvcalloc(*n, sizeof(struct conn_params), GFP_KERNEL); 2466 + if (!p) 2467 + return NULL; 2468 + 2469 + rcu_read_lock(); 2470 + 2471 + i = 0; 2472 + list_for_each_entry_rcu(params, list, action) { 2473 + /* Racing adds are handled in next scan update */ 2474 + if (i >= *n) 2475 + break; 2476 + 2477 + /* No hdev->lock, but: addr, addr_type are immutable. 2478 + * privacy_mode is only written by us or in 2479 + * hci_cc_le_set_privacy_mode that we wait for. 2480 + * We should be idempotent so MGMT updating flags 2481 + * while we are processing is OK. 2482 + */ 2483 + bacpy(&p[i].addr, &params->addr); 2484 + p[i].addr_type = params->addr_type; 2485 + p[i].flags = READ_ONCE(params->flags); 2486 + p[i].privacy_mode = READ_ONCE(params->privacy_mode); 2487 + ++i; 2488 + } 2489 + 2490 + rcu_read_unlock(); 2491 + 2492 + *n = i; 2493 + return p; 2494 + } 2495 + 2470 2496 /* Device must not be scanning when updating the accept list. 2471 2497 * 2472 2498 * Update is done using the following sequence: ··· 2532 2466 */ 2533 2467 static u8 hci_update_accept_list_sync(struct hci_dev *hdev) 2534 2468 { 2535 - struct hci_conn_params *params; 2469 + struct conn_params *params; 2536 2470 struct bdaddr_list *b, *t; 2537 2471 u8 num_entries = 0; 2538 2472 bool pend_conn, pend_report; 2539 2473 u8 filter_policy; 2474 + size_t i, n; 2540 2475 int err; 2541 2476 2542 2477 /* Pause advertising if resolving list can be used as controllers ··· 2571 2504 if (hci_conn_hash_lookup_le(hdev, &b->bdaddr, b->bdaddr_type)) 2572 2505 continue; 2573 2506 2507 + /* Pointers not dereferenced, no locks needed */ 2574 2508 pend_conn = hci_pend_le_action_lookup(&hdev->pend_le_conns, 2575 2509 &b->bdaddr, 2576 2510 b->bdaddr_type); ··· 2600 2532 * available accept list entries in the controller, then 2601 2533 * just abort and return filer policy value to not use the 2602 2534 * accept list. 2535 + * 2536 + * The list and params may be mutated while we wait for events, 2537 + * so make a copy and iterate it. 2603 2538 */ 2604 - list_for_each_entry(params, &hdev->pend_le_conns, action) { 2605 - err = hci_le_add_accept_list_sync(hdev, params, &num_entries); 2606 - if (err) 2607 - goto done; 2539 + 2540 + params = conn_params_copy(&hdev->pend_le_conns, &n); 2541 + if (!params) { 2542 + err = -ENOMEM; 2543 + goto done; 2608 2544 } 2545 + 2546 + for (i = 0; i < n; ++i) { 2547 + err = hci_le_add_accept_list_sync(hdev, &params[i], 2548 + &num_entries); 2549 + if (err) { 2550 + kvfree(params); 2551 + goto done; 2552 + } 2553 + } 2554 + 2555 + kvfree(params); 2609 2556 2610 2557 /* After adding all new pending connections, walk through 2611 2558 * the list of pending reports and also add these to the 2612 2559 * accept list if there is still space. Abort if space runs out. 2613 2560 */ 2614 - list_for_each_entry(params, &hdev->pend_le_reports, action) { 2615 - err = hci_le_add_accept_list_sync(hdev, params, &num_entries); 2616 - if (err) 2617 - goto done; 2561 + 2562 + params = conn_params_copy(&hdev->pend_le_reports, &n); 2563 + if (!params) { 2564 + err = -ENOMEM; 2565 + goto done; 2618 2566 } 2567 + 2568 + for (i = 0; i < n; ++i) { 2569 + err = hci_le_add_accept_list_sync(hdev, &params[i], 2570 + &num_entries); 2571 + if (err) { 2572 + kvfree(params); 2573 + goto done; 2574 + } 2575 + } 2576 + 2577 + kvfree(params); 2619 2578 2620 2579 /* Use the allowlist unless the following conditions are all true: 2621 2580 * - We are not currently suspending ··· 4932 4837 struct hci_conn_params *p; 4933 4838 4934 4839 list_for_each_entry(p, &hdev->le_conn_params, list) { 4840 + hci_pend_le_list_del_init(p); 4935 4841 if (p->conn) { 4936 4842 hci_conn_drop(p->conn); 4937 4843 hci_conn_put(p->conn); 4938 4844 p->conn = NULL; 4939 4845 } 4940 - list_del_init(&p->action); 4941 4846 } 4942 4847 4943 4848 BT_DBG("All LE pending actions cleared");
+32 -23
net/bluetooth/iso.c
··· 123 123 { 124 124 struct iso_conn *conn = hcon->iso_data; 125 125 126 - if (conn) 126 + if (conn) { 127 + if (!conn->hcon) 128 + conn->hcon = hcon; 127 129 return conn; 130 + } 128 131 129 132 conn = kzalloc(sizeof(*conn), GFP_KERNEL); 130 133 if (!conn) ··· 303 300 goto unlock; 304 301 } 305 302 306 - hci_dev_unlock(hdev); 307 - hci_dev_put(hdev); 303 + lock_sock(sk); 308 304 309 305 err = iso_chan_add(conn, sk, NULL); 310 - if (err) 311 - return err; 312 - 313 - lock_sock(sk); 306 + if (err) { 307 + release_sock(sk); 308 + goto unlock; 309 + } 314 310 315 311 /* Update source addr of the socket */ 316 312 bacpy(&iso_pi(sk)->src, &hcon->src); ··· 323 321 } 324 322 325 323 release_sock(sk); 326 - return err; 327 324 328 325 unlock: 329 326 hci_dev_unlock(hdev); ··· 390 389 goto unlock; 391 390 } 392 391 393 - hci_dev_unlock(hdev); 394 - hci_dev_put(hdev); 392 + lock_sock(sk); 395 393 396 394 err = iso_chan_add(conn, sk, NULL); 397 - if (err) 398 - return err; 399 - 400 - lock_sock(sk); 395 + if (err) { 396 + release_sock(sk); 397 + goto unlock; 398 + } 401 399 402 400 /* Update source addr of the socket */ 403 401 bacpy(&iso_pi(sk)->src, &hcon->src); ··· 413 413 } 414 414 415 415 release_sock(sk); 416 - return err; 417 416 418 417 unlock: 419 418 hci_dev_unlock(hdev); ··· 1071 1072 size_t len) 1072 1073 { 1073 1074 struct sock *sk = sock->sk; 1074 - struct iso_conn *conn = iso_pi(sk)->conn; 1075 1075 struct sk_buff *skb, **frag; 1076 + size_t mtu; 1076 1077 int err; 1077 1078 1078 1079 BT_DBG("sock %p, sk %p", sock, sk); ··· 1084 1085 if (msg->msg_flags & MSG_OOB) 1085 1086 return -EOPNOTSUPP; 1086 1087 1087 - if (sk->sk_state != BT_CONNECTED) 1088 - return -ENOTCONN; 1088 + lock_sock(sk); 1089 1089 1090 - skb = bt_skb_sendmsg(sk, msg, len, conn->hcon->hdev->iso_mtu, 1091 - HCI_ISO_DATA_HDR_SIZE, 0); 1090 + if (sk->sk_state != BT_CONNECTED) { 1091 + release_sock(sk); 1092 + return -ENOTCONN; 1093 + } 1094 + 1095 + mtu = iso_pi(sk)->conn->hcon->hdev->iso_mtu; 1096 + 1097 + release_sock(sk); 1098 + 1099 + skb = bt_skb_sendmsg(sk, msg, len, mtu, HCI_ISO_DATA_HDR_SIZE, 0); 1092 1100 if (IS_ERR(skb)) 1093 1101 return PTR_ERR(skb); 1094 1102 ··· 1108 1102 while (len) { 1109 1103 struct sk_buff *tmp; 1110 1104 1111 - tmp = bt_skb_sendmsg(sk, msg, len, conn->hcon->hdev->iso_mtu, 1112 - 0, 0); 1105 + tmp = bt_skb_sendmsg(sk, msg, len, mtu, 0, 0); 1113 1106 if (IS_ERR(tmp)) { 1114 1107 kfree_skb(skb); 1115 1108 return PTR_ERR(tmp); ··· 1163 1158 BT_DBG("sk %p", sk); 1164 1159 1165 1160 if (test_and_clear_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags)) { 1161 + lock_sock(sk); 1166 1162 switch (sk->sk_state) { 1167 1163 case BT_CONNECT2: 1168 - lock_sock(sk); 1169 1164 iso_conn_defer_accept(pi->conn->hcon); 1170 1165 sk->sk_state = BT_CONFIG; 1171 1166 release_sock(sk); 1172 1167 return 0; 1173 1168 case BT_CONNECT: 1169 + release_sock(sk); 1174 1170 return iso_connect_cis(sk); 1171 + default: 1172 + release_sock(sk); 1173 + break; 1175 1174 } 1176 1175 } 1177 1176
+12 -16
net/bluetooth/mgmt.c
··· 1297 1297 /* Needed for AUTO_OFF case where might not "really" 1298 1298 * have been powered off. 1299 1299 */ 1300 - list_del_init(&p->action); 1300 + hci_pend_le_list_del_init(p); 1301 1301 1302 1302 switch (p->auto_connect) { 1303 1303 case HCI_AUTO_CONN_DIRECT: 1304 1304 case HCI_AUTO_CONN_ALWAYS: 1305 - list_add(&p->action, &hdev->pend_le_conns); 1305 + hci_pend_le_list_add(p, &hdev->pend_le_conns); 1306 1306 break; 1307 1307 case HCI_AUTO_CONN_REPORT: 1308 - list_add(&p->action, &hdev->pend_le_reports); 1308 + hci_pend_le_list_add(p, &hdev->pend_le_reports); 1309 1309 break; 1310 1310 default: 1311 1311 break; ··· 5169 5169 goto unlock; 5170 5170 } 5171 5171 5172 - params->flags = current_flags; 5172 + WRITE_ONCE(params->flags, current_flags); 5173 5173 status = MGMT_STATUS_SUCCESS; 5174 5174 5175 5175 /* Update passive scan if HCI_CONN_FLAG_DEVICE_PRIVACY ··· 7285 7285 7286 7286 bt_dev_dbg(hdev, "err %d", err); 7287 7287 7288 - memcpy(&rp.addr, &cp->addr.bdaddr, sizeof(rp.addr)); 7288 + memcpy(&rp.addr, &cp->addr, sizeof(rp.addr)); 7289 7289 7290 7290 status = mgmt_status(err); 7291 7291 if (status == MGMT_STATUS_SUCCESS) { ··· 7580 7580 if (params->auto_connect == auto_connect) 7581 7581 return 0; 7582 7582 7583 - list_del_init(&params->action); 7583 + hci_pend_le_list_del_init(params); 7584 7584 7585 7585 switch (auto_connect) { 7586 7586 case HCI_AUTO_CONN_DISABLED: ··· 7589 7589 * connect to device, keep connecting. 7590 7590 */ 7591 7591 if (params->explicit_connect) 7592 - list_add(&params->action, &hdev->pend_le_conns); 7592 + hci_pend_le_list_add(params, &hdev->pend_le_conns); 7593 7593 break; 7594 7594 case HCI_AUTO_CONN_REPORT: 7595 7595 if (params->explicit_connect) 7596 - list_add(&params->action, &hdev->pend_le_conns); 7596 + hci_pend_le_list_add(params, &hdev->pend_le_conns); 7597 7597 else 7598 - list_add(&params->action, &hdev->pend_le_reports); 7598 + hci_pend_le_list_add(params, &hdev->pend_le_reports); 7599 7599 break; 7600 7600 case HCI_AUTO_CONN_DIRECT: 7601 7601 case HCI_AUTO_CONN_ALWAYS: 7602 7602 if (!is_connected(hdev, addr, addr_type)) 7603 - list_add(&params->action, &hdev->pend_le_conns); 7603 + hci_pend_le_list_add(params, &hdev->pend_le_conns); 7604 7604 break; 7605 7605 } 7606 7606 ··· 7823 7823 goto unlock; 7824 7824 } 7825 7825 7826 - list_del(&params->action); 7827 - list_del(&params->list); 7828 - kfree(params); 7826 + hci_conn_params_free(params); 7829 7827 7830 7828 device_removed(sk, hdev, &cp->addr.bdaddr, cp->addr.type); 7831 7829 } else { ··· 7854 7856 p->auto_connect = HCI_AUTO_CONN_EXPLICIT; 7855 7857 continue; 7856 7858 } 7857 - list_del(&p->action); 7858 - list_del(&p->list); 7859 - kfree(p); 7859 + hci_conn_params_free(p); 7860 7860 } 7861 7861 7862 7862 bt_dev_dbg(hdev, "All LE connection parameters were removed");
+12 -11
net/bluetooth/sco.c
··· 126 126 struct hci_dev *hdev = hcon->hdev; 127 127 struct sco_conn *conn = hcon->sco_data; 128 128 129 - if (conn) 129 + if (conn) { 130 + if (!conn->hcon) 131 + conn->hcon = hcon; 130 132 return conn; 133 + } 131 134 132 135 conn = kzalloc(sizeof(struct sco_conn), GFP_KERNEL); 133 136 if (!conn) ··· 271 268 goto unlock; 272 269 } 273 270 274 - hci_dev_unlock(hdev); 275 - hci_dev_put(hdev); 276 - 277 271 conn = sco_conn_add(hcon); 278 272 if (!conn) { 279 273 hci_conn_drop(hcon); 280 - return -ENOMEM; 274 + err = -ENOMEM; 275 + goto unlock; 281 276 } 282 277 283 - err = sco_chan_add(conn, sk, NULL); 284 - if (err) 285 - return err; 286 - 287 278 lock_sock(sk); 279 + 280 + err = sco_chan_add(conn, sk, NULL); 281 + if (err) { 282 + release_sock(sk); 283 + goto unlock; 284 + } 288 285 289 286 /* Update source addr of the socket */ 290 287 bacpy(&sco_pi(sk)->src, &hcon->src); ··· 298 295 } 299 296 300 297 release_sock(sk); 301 - 302 - return err; 303 298 304 299 unlock: 305 300 hci_dev_unlock(hdev);
+6 -6
net/can/bcm.c
··· 1526 1526 1527 1527 lock_sock(sk); 1528 1528 1529 + #if IS_ENABLED(CONFIG_PROC_FS) 1530 + /* remove procfs entry */ 1531 + if (net->can.bcmproc_dir && bo->bcm_proc_read) 1532 + remove_proc_entry(bo->procname, net->can.bcmproc_dir); 1533 + #endif /* CONFIG_PROC_FS */ 1534 + 1529 1535 list_for_each_entry_safe(op, next, &bo->tx_ops, list) 1530 1536 bcm_remove_op(op); 1531 1537 ··· 1566 1560 1567 1561 list_for_each_entry_safe(op, next, &bo->rx_ops, list) 1568 1562 bcm_remove_op(op); 1569 - 1570 - #if IS_ENABLED(CONFIG_PROC_FS) 1571 - /* remove procfs entry */ 1572 - if (net->can.bcmproc_dir && bo->bcm_proc_read) 1573 - remove_proc_entry(bo->procname, net->can.bcmproc_dir); 1574 - #endif /* CONFIG_PROC_FS */ 1575 1563 1576 1564 /* remove device reference */ 1577 1565 if (bo->bound) {
+24 -33
net/can/raw.c
··· 84 84 struct sock sk; 85 85 int bound; 86 86 int ifindex; 87 + struct net_device *dev; 87 88 struct list_head notifier; 88 89 int loopback; 89 90 int recv_own_msgs; ··· 278 277 if (!net_eq(dev_net(dev), sock_net(sk))) 279 278 return; 280 279 281 - if (ro->ifindex != dev->ifindex) 280 + if (ro->dev != dev) 282 281 return; 283 282 284 283 switch (msg) { ··· 293 292 294 293 ro->ifindex = 0; 295 294 ro->bound = 0; 295 + ro->dev = NULL; 296 296 ro->count = 0; 297 297 release_sock(sk); 298 298 ··· 339 337 340 338 ro->bound = 0; 341 339 ro->ifindex = 0; 340 + ro->dev = NULL; 342 341 343 342 /* set default filter to single entry dfilter */ 344 343 ro->dfilter.can_id = 0; ··· 388 385 389 386 lock_sock(sk); 390 387 388 + rtnl_lock(); 391 389 /* remove current filters & unregister */ 392 390 if (ro->bound) { 393 - if (ro->ifindex) { 394 - struct net_device *dev; 395 - 396 - dev = dev_get_by_index(sock_net(sk), ro->ifindex); 397 - if (dev) { 398 - raw_disable_allfilters(dev_net(dev), dev, sk); 399 - dev_put(dev); 400 - } 401 - } else { 391 + if (ro->dev) 392 + raw_disable_allfilters(dev_net(ro->dev), ro->dev, sk); 393 + else 402 394 raw_disable_allfilters(sock_net(sk), NULL, sk); 403 - } 404 395 } 405 396 406 397 if (ro->count > 1) ··· 402 405 403 406 ro->ifindex = 0; 404 407 ro->bound = 0; 408 + ro->dev = NULL; 405 409 ro->count = 0; 406 410 free_percpu(ro->uniq); 411 + rtnl_unlock(); 407 412 408 413 sock_orphan(sk); 409 414 sock->sk = NULL; ··· 421 422 struct sockaddr_can *addr = (struct sockaddr_can *)uaddr; 422 423 struct sock *sk = sock->sk; 423 424 struct raw_sock *ro = raw_sk(sk); 425 + struct net_device *dev = NULL; 424 426 int ifindex; 425 427 int err = 0; 426 428 int notify_enetdown = 0; ··· 431 431 if (addr->can_family != AF_CAN) 432 432 return -EINVAL; 433 433 434 + rtnl_lock(); 434 435 lock_sock(sk); 435 436 436 437 if (ro->bound && addr->can_ifindex == ro->ifindex) 437 438 goto out; 438 439 439 440 if (addr->can_ifindex) { 440 - struct net_device *dev; 441 - 442 441 dev = dev_get_by_index(sock_net(sk), addr->can_ifindex); 443 442 if (!dev) { 444 443 err = -ENODEV; ··· 466 467 if (!err) { 467 468 if (ro->bound) { 468 469 /* unregister old filters */ 469 - if (ro->ifindex) { 470 - struct net_device *dev; 471 - 472 - dev = dev_get_by_index(sock_net(sk), 473 - ro->ifindex); 474 - if (dev) { 475 - raw_disable_allfilters(dev_net(dev), 476 - dev, sk); 477 - dev_put(dev); 478 - } 479 - } else { 470 + if (ro->dev) 471 + raw_disable_allfilters(dev_net(ro->dev), 472 + ro->dev, sk); 473 + else 480 474 raw_disable_allfilters(sock_net(sk), NULL, sk); 481 - } 482 475 } 483 476 ro->ifindex = ifindex; 484 477 ro->bound = 1; 478 + ro->dev = dev; 485 479 } 486 480 487 481 out: 488 482 release_sock(sk); 483 + rtnl_unlock(); 489 484 490 485 if (notify_enetdown) { 491 486 sk->sk_err = ENETDOWN; ··· 546 553 rtnl_lock(); 547 554 lock_sock(sk); 548 555 549 - if (ro->bound && ro->ifindex) { 550 - dev = dev_get_by_index(sock_net(sk), ro->ifindex); 551 - if (!dev) { 556 + dev = ro->dev; 557 + if (ro->bound && dev) { 558 + if (dev->reg_state != NETREG_REGISTERED) { 552 559 if (count > 1) 553 560 kfree(filter); 554 561 err = -ENODEV; ··· 589 596 ro->count = count; 590 597 591 598 out_fil: 592 - dev_put(dev); 593 599 release_sock(sk); 594 600 rtnl_unlock(); 595 601 ··· 606 614 rtnl_lock(); 607 615 lock_sock(sk); 608 616 609 - if (ro->bound && ro->ifindex) { 610 - dev = dev_get_by_index(sock_net(sk), ro->ifindex); 611 - if (!dev) { 617 + dev = ro->dev; 618 + if (ro->bound && dev) { 619 + if (dev->reg_state != NETREG_REGISTERED) { 612 620 err = -ENODEV; 613 621 goto out_err; 614 622 } ··· 632 640 ro->err_mask = err_mask; 633 641 634 642 out_err: 635 - dev_put(dev); 636 643 release_sock(sk); 637 644 rtnl_unlock(); 638 645
+29 -18
net/ceph/messenger_v2.c
··· 390 390 int head_len; 391 391 int rem_len; 392 392 393 + BUG_ON(ctrl_len < 0 || ctrl_len > CEPH_MSG_MAX_CONTROL_LEN); 394 + 393 395 if (secure) { 394 396 head_len = CEPH_PREAMBLE_SECURE_LEN; 395 397 if (ctrl_len > CEPH_PREAMBLE_INLINE_LEN) { ··· 410 408 static int __tail_onwire_len(int front_len, int middle_len, int data_len, 411 409 bool secure) 412 410 { 411 + BUG_ON(front_len < 0 || front_len > CEPH_MSG_MAX_FRONT_LEN || 412 + middle_len < 0 || middle_len > CEPH_MSG_MAX_MIDDLE_LEN || 413 + data_len < 0 || data_len > CEPH_MSG_MAX_DATA_LEN); 414 + 413 415 if (!front_len && !middle_len && !data_len) 414 416 return 0; 415 417 ··· 526 520 desc->fd_aligns[i] = ceph_decode_16(&p); 527 521 } 528 522 523 + if (desc->fd_lens[0] < 0 || 524 + desc->fd_lens[0] > CEPH_MSG_MAX_CONTROL_LEN) { 525 + pr_err("bad control segment length %d\n", desc->fd_lens[0]); 526 + return -EINVAL; 527 + } 528 + if (desc->fd_lens[1] < 0 || 529 + desc->fd_lens[1] > CEPH_MSG_MAX_FRONT_LEN) { 530 + pr_err("bad front segment length %d\n", desc->fd_lens[1]); 531 + return -EINVAL; 532 + } 533 + if (desc->fd_lens[2] < 0 || 534 + desc->fd_lens[2] > CEPH_MSG_MAX_MIDDLE_LEN) { 535 + pr_err("bad middle segment length %d\n", desc->fd_lens[2]); 536 + return -EINVAL; 537 + } 538 + if (desc->fd_lens[3] < 0 || 539 + desc->fd_lens[3] > CEPH_MSG_MAX_DATA_LEN) { 540 + pr_err("bad data segment length %d\n", desc->fd_lens[3]); 541 + return -EINVAL; 542 + } 543 + 529 544 /* 530 545 * This would fire for FRAME_TAG_WAIT (it has one empty 531 546 * segment), but we should never get it as client. 532 547 */ 533 548 if (!desc->fd_lens[desc->fd_seg_cnt - 1]) { 534 - pr_err("last segment empty\n"); 535 - return -EINVAL; 536 - } 537 - 538 - if (desc->fd_lens[0] > CEPH_MSG_MAX_CONTROL_LEN) { 539 - pr_err("control segment too big %d\n", desc->fd_lens[0]); 540 - return -EINVAL; 541 - } 542 - if (desc->fd_lens[1] > CEPH_MSG_MAX_FRONT_LEN) { 543 - pr_err("front segment too big %d\n", desc->fd_lens[1]); 544 - return -EINVAL; 545 - } 546 - if (desc->fd_lens[2] > CEPH_MSG_MAX_MIDDLE_LEN) { 547 - pr_err("middle segment too big %d\n", desc->fd_lens[2]); 548 - return -EINVAL; 549 - } 550 - if (desc->fd_lens[3] > CEPH_MSG_MAX_DATA_LEN) { 551 - pr_err("data segment too big %d\n", desc->fd_lens[3]); 549 + pr_err("last segment empty, segment count %d\n", 550 + desc->fd_seg_cnt); 552 551 return -EINVAL; 553 552 } 554 553
+1 -1
net/ipv4/esp4.c
··· 1132 1132 err = crypto_aead_setkey(aead, key, keylen); 1133 1133 1134 1134 free_key: 1135 - kfree(key); 1135 + kfree_sensitive(key); 1136 1136 1137 1137 error: 1138 1138 return err;
+1 -1
net/ipv4/inet_connection_sock.c
··· 1019 1019 1020 1020 icsk = inet_csk(sk_listener); 1021 1021 net = sock_net(sk_listener); 1022 - max_syn_ack_retries = icsk->icsk_syn_retries ? : 1022 + max_syn_ack_retries = READ_ONCE(icsk->icsk_syn_retries) ? : 1023 1023 READ_ONCE(net->ipv4.sysctl_tcp_synack_retries); 1024 1024 /* Normally all the openreqs are young and become mature 1025 1025 * (i.e. converted to established socket) for first timeout.
+2 -15
net/ipv4/inet_hashtables.c
··· 650 650 spin_lock(lock); 651 651 if (osk) { 652 652 WARN_ON_ONCE(sk->sk_hash != osk->sk_hash); 653 - ret = sk_hashed(osk); 654 - if (ret) { 655 - /* Before deleting the node, we insert a new one to make 656 - * sure that the look-up-sk process would not miss either 657 - * of them and that at least one node would exist in ehash 658 - * table all the time. Otherwise there's a tiny chance 659 - * that lookup process could find nothing in ehash table. 660 - */ 661 - __sk_nulls_add_node_tail_rcu(sk, list); 662 - sk_nulls_del_node_init_rcu(osk); 663 - } 664 - goto unlock; 665 - } 666 - if (found_dup_sk) { 653 + ret = sk_nulls_del_node_init_rcu(osk); 654 + } else if (found_dup_sk) { 667 655 *found_dup_sk = inet_ehash_lookup_by_sk(sk, list); 668 656 if (*found_dup_sk) 669 657 ret = false; ··· 660 672 if (ret) 661 673 __sk_nulls_add_node_rcu(sk, list); 662 674 663 - unlock: 664 675 spin_unlock(lock); 665 676 666 677 return ret;
+4 -4
net/ipv4/inet_timewait_sock.c
··· 88 88 } 89 89 EXPORT_SYMBOL_GPL(inet_twsk_put); 90 90 91 - static void inet_twsk_add_node_tail_rcu(struct inet_timewait_sock *tw, 92 - struct hlist_nulls_head *list) 91 + static void inet_twsk_add_node_rcu(struct inet_timewait_sock *tw, 92 + struct hlist_nulls_head *list) 93 93 { 94 - hlist_nulls_add_tail_rcu(&tw->tw_node, list); 94 + hlist_nulls_add_head_rcu(&tw->tw_node, list); 95 95 } 96 96 97 97 static void inet_twsk_add_bind_node(struct inet_timewait_sock *tw, ··· 144 144 145 145 spin_lock(lock); 146 146 147 - inet_twsk_add_node_tail_rcu(tw, &ehead->chain); 147 + inet_twsk_add_node_rcu(tw, &ehead->chain); 148 148 149 149 /* Step 3: Remove SK from hash chain */ 150 150 if (__sk_nulls_del_node_init_rcu(sk))
+4 -2
net/ipv4/ip_gre.c
··· 548 548 goto err_free_skb; 549 549 550 550 if (skb->len > dev->mtu + dev->hard_header_len) { 551 - pskb_trim(skb, dev->mtu + dev->hard_header_len); 551 + if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) 552 + goto err_free_skb; 552 553 truncate = true; 553 554 } 554 555 ··· 690 689 goto free_skb; 691 690 692 691 if (skb->len > dev->mtu + dev->hard_header_len) { 693 - pskb_trim(skb, dev->mtu + dev->hard_header_len); 692 + if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) 693 + goto free_skb; 694 694 truncate = true; 695 695 } 696 696
+30 -27
net/ipv4/tcp.c
··· 3292 3292 return -EINVAL; 3293 3293 3294 3294 lock_sock(sk); 3295 - inet_csk(sk)->icsk_syn_retries = val; 3295 + WRITE_ONCE(inet_csk(sk)->icsk_syn_retries, val); 3296 3296 release_sock(sk); 3297 3297 return 0; 3298 3298 } ··· 3301 3301 void tcp_sock_set_user_timeout(struct sock *sk, u32 val) 3302 3302 { 3303 3303 lock_sock(sk); 3304 - inet_csk(sk)->icsk_user_timeout = val; 3304 + WRITE_ONCE(inet_csk(sk)->icsk_user_timeout, val); 3305 3305 release_sock(sk); 3306 3306 } 3307 3307 EXPORT_SYMBOL(tcp_sock_set_user_timeout); ··· 3313 3313 if (val < 1 || val > MAX_TCP_KEEPIDLE) 3314 3314 return -EINVAL; 3315 3315 3316 - tp->keepalive_time = val * HZ; 3316 + /* Paired with WRITE_ONCE() in keepalive_time_when() */ 3317 + WRITE_ONCE(tp->keepalive_time, val * HZ); 3317 3318 if (sock_flag(sk, SOCK_KEEPOPEN) && 3318 3319 !((1 << sk->sk_state) & (TCPF_CLOSE | TCPF_LISTEN))) { 3319 3320 u32 elapsed = keepalive_time_elapsed(tp); ··· 3346 3345 return -EINVAL; 3347 3346 3348 3347 lock_sock(sk); 3349 - tcp_sk(sk)->keepalive_intvl = val * HZ; 3348 + WRITE_ONCE(tcp_sk(sk)->keepalive_intvl, val * HZ); 3350 3349 release_sock(sk); 3351 3350 return 0; 3352 3351 } ··· 3358 3357 return -EINVAL; 3359 3358 3360 3359 lock_sock(sk); 3361 - tcp_sk(sk)->keepalive_probes = val; 3360 + /* Paired with READ_ONCE() in keepalive_probes() */ 3361 + WRITE_ONCE(tcp_sk(sk)->keepalive_probes, val); 3362 3362 release_sock(sk); 3363 3363 return 0; 3364 3364 } ··· 3561 3559 if (val < 1 || val > MAX_TCP_KEEPINTVL) 3562 3560 err = -EINVAL; 3563 3561 else 3564 - tp->keepalive_intvl = val * HZ; 3562 + WRITE_ONCE(tp->keepalive_intvl, val * HZ); 3565 3563 break; 3566 3564 case TCP_KEEPCNT: 3567 3565 if (val < 1 || val > MAX_TCP_KEEPCNT) 3568 3566 err = -EINVAL; 3569 3567 else 3570 - tp->keepalive_probes = val; 3568 + WRITE_ONCE(tp->keepalive_probes, val); 3571 3569 break; 3572 3570 case TCP_SYNCNT: 3573 3571 if (val < 1 || val > MAX_TCP_SYNCNT) 3574 3572 err = -EINVAL; 3575 3573 else 3576 - icsk->icsk_syn_retries = val; 3574 + WRITE_ONCE(icsk->icsk_syn_retries, val); 3577 3575 break; 3578 3576 3579 3577 case TCP_SAVE_SYN: ··· 3586 3584 3587 3585 case TCP_LINGER2: 3588 3586 if (val < 0) 3589 - tp->linger2 = -1; 3587 + WRITE_ONCE(tp->linger2, -1); 3590 3588 else if (val > TCP_FIN_TIMEOUT_MAX / HZ) 3591 - tp->linger2 = TCP_FIN_TIMEOUT_MAX; 3589 + WRITE_ONCE(tp->linger2, TCP_FIN_TIMEOUT_MAX); 3592 3590 else 3593 - tp->linger2 = val * HZ; 3591 + WRITE_ONCE(tp->linger2, val * HZ); 3594 3592 break; 3595 3593 3596 3594 case TCP_DEFER_ACCEPT: 3597 3595 /* Translate value in seconds to number of retransmits */ 3598 - icsk->icsk_accept_queue.rskq_defer_accept = 3599 - secs_to_retrans(val, TCP_TIMEOUT_INIT / HZ, 3600 - TCP_RTO_MAX / HZ); 3596 + WRITE_ONCE(icsk->icsk_accept_queue.rskq_defer_accept, 3597 + secs_to_retrans(val, TCP_TIMEOUT_INIT / HZ, 3598 + TCP_RTO_MAX / HZ)); 3601 3599 break; 3602 3600 3603 3601 case TCP_WINDOW_CLAMP: ··· 3621 3619 if (val < 0) 3622 3620 err = -EINVAL; 3623 3621 else 3624 - icsk->icsk_user_timeout = val; 3622 + WRITE_ONCE(icsk->icsk_user_timeout, val); 3625 3623 break; 3626 3624 3627 3625 case TCP_FASTOPEN: ··· 3659 3657 if (!tp->repair) 3660 3658 err = -EPERM; 3661 3659 else 3662 - tp->tsoffset = val - tcp_time_stamp_raw(); 3660 + WRITE_ONCE(tp->tsoffset, val - tcp_time_stamp_raw()); 3663 3661 break; 3664 3662 case TCP_REPAIR_WINDOW: 3665 3663 err = tcp_repair_set_window(tp, optval, optlen); 3666 3664 break; 3667 3665 case TCP_NOTSENT_LOWAT: 3668 - tp->notsent_lowat = val; 3666 + WRITE_ONCE(tp->notsent_lowat, val); 3669 3667 sk->sk_write_space(sk); 3670 3668 break; 3671 3669 case TCP_INQ: ··· 3677 3675 case TCP_TX_DELAY: 3678 3676 if (val) 3679 3677 tcp_enable_tx_delay(); 3680 - tp->tcp_tx_delay = val; 3678 + WRITE_ONCE(tp->tcp_tx_delay, val); 3681 3679 break; 3682 3680 default: 3683 3681 err = -ENOPROTOOPT; ··· 3994 3992 val = keepalive_probes(tp); 3995 3993 break; 3996 3994 case TCP_SYNCNT: 3997 - val = icsk->icsk_syn_retries ? : 3995 + val = READ_ONCE(icsk->icsk_syn_retries) ? : 3998 3996 READ_ONCE(net->ipv4.sysctl_tcp_syn_retries); 3999 3997 break; 4000 3998 case TCP_LINGER2: 4001 - val = tp->linger2; 3999 + val = READ_ONCE(tp->linger2); 4002 4000 if (val >= 0) 4003 4001 val = (val ? : READ_ONCE(net->ipv4.sysctl_tcp_fin_timeout)) / HZ; 4004 4002 break; 4005 4003 case TCP_DEFER_ACCEPT: 4006 - val = retrans_to_secs(icsk->icsk_accept_queue.rskq_defer_accept, 4007 - TCP_TIMEOUT_INIT / HZ, TCP_RTO_MAX / HZ); 4004 + val = READ_ONCE(icsk->icsk_accept_queue.rskq_defer_accept); 4005 + val = retrans_to_secs(val, TCP_TIMEOUT_INIT / HZ, 4006 + TCP_RTO_MAX / HZ); 4008 4007 break; 4009 4008 case TCP_WINDOW_CLAMP: 4010 4009 val = tp->window_clamp; ··· 4142 4139 break; 4143 4140 4144 4141 case TCP_USER_TIMEOUT: 4145 - val = icsk->icsk_user_timeout; 4142 + val = READ_ONCE(icsk->icsk_user_timeout); 4146 4143 break; 4147 4144 4148 4145 case TCP_FASTOPEN: 4149 - val = icsk->icsk_accept_queue.fastopenq.max_qlen; 4146 + val = READ_ONCE(icsk->icsk_accept_queue.fastopenq.max_qlen); 4150 4147 break; 4151 4148 4152 4149 case TCP_FASTOPEN_CONNECT: ··· 4158 4155 break; 4159 4156 4160 4157 case TCP_TX_DELAY: 4161 - val = tp->tcp_tx_delay; 4158 + val = READ_ONCE(tp->tcp_tx_delay); 4162 4159 break; 4163 4160 4164 4161 case TCP_TIMESTAMP: 4165 - val = tcp_time_stamp_raw() + tp->tsoffset; 4162 + val = tcp_time_stamp_raw() + READ_ONCE(tp->tsoffset); 4166 4163 break; 4167 4164 case TCP_NOTSENT_LOWAT: 4168 - val = tp->notsent_lowat; 4165 + val = READ_ONCE(tp->notsent_lowat); 4169 4166 break; 4170 4167 case TCP_INQ: 4171 4168 val = tp->recvmsg_inq;
+4 -2
net/ipv4/tcp_fastopen.c
··· 296 296 static bool tcp_fastopen_queue_check(struct sock *sk) 297 297 { 298 298 struct fastopen_queue *fastopenq; 299 + int max_qlen; 299 300 300 301 /* Make sure the listener has enabled fastopen, and we don't 301 302 * exceed the max # of pending TFO requests allowed before trying ··· 309 308 * temporarily vs a server not supporting Fast Open at all. 310 309 */ 311 310 fastopenq = &inet_csk(sk)->icsk_accept_queue.fastopenq; 312 - if (fastopenq->max_qlen == 0) 311 + max_qlen = READ_ONCE(fastopenq->max_qlen); 312 + if (max_qlen == 0) 313 313 return false; 314 314 315 - if (fastopenq->qlen >= fastopenq->max_qlen) { 315 + if (fastopenq->qlen >= max_qlen) { 316 316 struct request_sock *req1; 317 317 spin_lock(&fastopenq->lock); 318 318 req1 = fastopenq->rskq_rst_head;
+6 -4
net/ipv4/tcp_ipv4.c
··· 308 308 inet->inet_daddr, 309 309 inet->inet_sport, 310 310 usin->sin_port)); 311 - tp->tsoffset = secure_tcp_ts_off(net, inet->inet_saddr, 312 - inet->inet_daddr); 311 + WRITE_ONCE(tp->tsoffset, 312 + secure_tcp_ts_off(net, inet->inet_saddr, 313 + inet->inet_daddr)); 313 314 } 314 315 315 316 inet->inet_id = get_random_u16(); ··· 990 989 tcp_rsk(req)->rcv_nxt, 991 990 req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale, 992 991 tcp_time_stamp_raw() + tcp_rsk(req)->ts_off, 993 - req->ts_recent, 992 + READ_ONCE(req->ts_recent), 994 993 0, 995 994 tcp_md5_do_lookup(sk, l3index, addr, AF_INET), 996 995 inet_rsk(req)->no_srccheck ? IP_REPLY_ARG_NOSRCCHECK : 0, 997 - ip_hdr(skb)->tos, tcp_rsk(req)->txhash); 996 + ip_hdr(skb)->tos, 997 + READ_ONCE(tcp_rsk(req)->txhash)); 998 998 } 999 999 1000 1000 /*
+7 -4
net/ipv4/tcp_minisocks.c
··· 528 528 newicsk->icsk_ack.lrcvtime = tcp_jiffies32; 529 529 530 530 newtp->lsndtime = tcp_jiffies32; 531 - newsk->sk_txhash = treq->txhash; 531 + newsk->sk_txhash = READ_ONCE(treq->txhash); 532 532 newtp->total_retrans = req->num_retrans; 533 533 534 534 tcp_init_xmit_timers(newsk); ··· 555 555 newtp->max_window = newtp->snd_wnd; 556 556 557 557 if (newtp->rx_opt.tstamp_ok) { 558 - newtp->rx_opt.ts_recent = req->ts_recent; 558 + newtp->rx_opt.ts_recent = READ_ONCE(req->ts_recent); 559 559 newtp->rx_opt.ts_recent_stamp = ktime_get_seconds(); 560 560 newtp->tcp_header_len = sizeof(struct tcphdr) + TCPOLEN_TSTAMP_ALIGNED; 561 561 } else { ··· 619 619 tcp_parse_options(sock_net(sk), skb, &tmp_opt, 0, NULL); 620 620 621 621 if (tmp_opt.saw_tstamp) { 622 - tmp_opt.ts_recent = req->ts_recent; 622 + tmp_opt.ts_recent = READ_ONCE(req->ts_recent); 623 623 if (tmp_opt.rcv_tsecr) 624 624 tmp_opt.rcv_tsecr -= tcp_rsk(req)->ts_off; 625 625 /* We do not store true stamp, but it is not required, ··· 758 758 759 759 /* In sequence, PAWS is OK. */ 760 760 761 + /* TODO: We probably should defer ts_recent change once 762 + * we take ownership of @req. 763 + */ 761 764 if (tmp_opt.saw_tstamp && !after(TCP_SKB_CB(skb)->seq, tcp_rsk(req)->rcv_nxt)) 762 - req->ts_recent = tmp_opt.rcv_tsval; 765 + WRITE_ONCE(req->ts_recent, tmp_opt.rcv_tsval); 763 766 764 767 if (TCP_SKB_CB(skb)->seq == tcp_rsk(req)->rcv_isn) { 765 768 /* Truncate SYN, it is out of window starting
+3 -3
net/ipv4/tcp_output.c
··· 878 878 if (likely(ireq->tstamp_ok)) { 879 879 opts->options |= OPTION_TS; 880 880 opts->tsval = tcp_skb_timestamp(skb) + tcp_rsk(req)->ts_off; 881 - opts->tsecr = req->ts_recent; 881 + opts->tsecr = READ_ONCE(req->ts_recent); 882 882 remaining -= TCPOLEN_TSTAMP_ALIGNED; 883 883 } 884 884 if (likely(ireq->sack_ok)) { ··· 3660 3660 rcu_read_lock(); 3661 3661 md5 = tcp_rsk(req)->af_specific->req_md5_lookup(sk, req_to_sk(req)); 3662 3662 #endif 3663 - skb_set_hash(skb, tcp_rsk(req)->txhash, PKT_HASH_TYPE_L4); 3663 + skb_set_hash(skb, READ_ONCE(tcp_rsk(req)->txhash), PKT_HASH_TYPE_L4); 3664 3664 /* bpf program will be interested in the tcp_flags */ 3665 3665 TCP_SKB_CB(skb)->tcp_flags = TCPHDR_SYN | TCPHDR_ACK; 3666 3666 tcp_header_size = tcp_synack_options(sk, req, mss, skb, &opts, md5, ··· 4210 4210 4211 4211 /* Paired with WRITE_ONCE() in sock_setsockopt() */ 4212 4212 if (READ_ONCE(sk->sk_txrehash) == SOCK_TXREHASH_ENABLED) 4213 - tcp_rsk(req)->txhash = net_tx_rndhash(); 4213 + WRITE_ONCE(tcp_rsk(req)->txhash, net_tx_rndhash()); 4214 4214 res = af_ops->send_synack(sk, NULL, &fl, req, NULL, TCP_SYNACK_NORMAL, 4215 4215 NULL); 4216 4216 if (!res) {
+11 -5
net/ipv4/udp_offload.c
··· 274 274 __sum16 check; 275 275 __be16 newlen; 276 276 277 - if (skb_shinfo(gso_skb)->gso_type & SKB_GSO_FRAGLIST) 278 - return __udp_gso_segment_list(gso_skb, features, is_ipv6); 279 - 280 277 mss = skb_shinfo(gso_skb)->gso_size; 281 278 if (gso_skb->len <= sizeof(*uh) + mss) 282 279 return ERR_PTR(-EINVAL); 280 + 281 + if (skb_gso_ok(gso_skb, features | NETIF_F_GSO_ROBUST)) { 282 + /* Packet is from an untrusted source, reset gso_segs. */ 283 + skb_shinfo(gso_skb)->gso_segs = DIV_ROUND_UP(gso_skb->len - sizeof(*uh), 284 + mss); 285 + return NULL; 286 + } 287 + 288 + if (skb_shinfo(gso_skb)->gso_type & SKB_GSO_FRAGLIST) 289 + return __udp_gso_segment_list(gso_skb, features, is_ipv6); 283 290 284 291 skb_pull(gso_skb, sizeof(*uh)); 285 292 ··· 395 388 if (!pskb_may_pull(skb, sizeof(struct udphdr))) 396 389 goto out; 397 390 398 - if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 && 399 - !skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) 391 + if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) 400 392 return __udp_gso_segment(skb, features, false); 401 393 402 394 mss = skb_shinfo(skb)->gso_size;
+2 -1
net/ipv6/ip6_gre.c
··· 955 955 goto tx_err; 956 956 957 957 if (skb->len > dev->mtu + dev->hard_header_len) { 958 - pskb_trim(skb, dev->mtu + dev->hard_header_len); 958 + if (pskb_trim(skb, dev->mtu + dev->hard_header_len)) 959 + goto tx_err; 959 960 truncate = true; 960 961 } 961 962
+2 -2
net/ipv6/tcp_ipv6.c
··· 1126 1126 tcp_rsk(req)->rcv_nxt, 1127 1127 req->rsk_rcv_wnd >> inet_rsk(req)->rcv_wscale, 1128 1128 tcp_time_stamp_raw() + tcp_rsk(req)->ts_off, 1129 - req->ts_recent, sk->sk_bound_dev_if, 1129 + READ_ONCE(req->ts_recent), sk->sk_bound_dev_if, 1130 1130 tcp_v6_md5_do_lookup(sk, &ipv6_hdr(skb)->saddr, l3index), 1131 1131 ipv6_get_dsfield(ipv6_hdr(skb)), 0, sk->sk_priority, 1132 - tcp_rsk(req)->txhash); 1132 + READ_ONCE(tcp_rsk(req)->txhash)); 1133 1133 } 1134 1134 1135 1135
+1 -2
net/ipv6/udp_offload.c
··· 43 43 if (!pskb_may_pull(skb, sizeof(struct udphdr))) 44 44 goto out; 45 45 46 - if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4 && 47 - !skb_gso_ok(skb, features | NETIF_F_GSO_ROBUST)) 46 + if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) 48 47 return __udp_gso_segment(skb, features, true); 49 48 50 49 mss = skb_shinfo(skb)->gso_size;
+1 -1
net/llc/af_llc.c
··· 402 402 memcpy(laddr.mac, addr->sllc_mac, IFHWADDRLEN); 403 403 laddr.lsap = addr->sllc_sap; 404 404 rc = -EADDRINUSE; /* mac + sap clash. */ 405 - ask = llc_lookup_established(sap, &daddr, &laddr); 405 + ask = llc_lookup_established(sap, &daddr, &laddr, &init_net); 406 406 if (ask) { 407 407 sock_put(ask); 408 408 goto out_put;
+30 -19
net/llc/llc_conn.c
··· 453 453 static inline bool llc_estab_match(const struct llc_sap *sap, 454 454 const struct llc_addr *daddr, 455 455 const struct llc_addr *laddr, 456 - const struct sock *sk) 456 + const struct sock *sk, 457 + const struct net *net) 457 458 { 458 459 struct llc_sock *llc = llc_sk(sk); 459 460 460 - return llc->laddr.lsap == laddr->lsap && 461 + return net_eq(sock_net(sk), net) && 462 + llc->laddr.lsap == laddr->lsap && 461 463 llc->daddr.lsap == daddr->lsap && 462 464 ether_addr_equal(llc->laddr.mac, laddr->mac) && 463 465 ether_addr_equal(llc->daddr.mac, daddr->mac); ··· 470 468 * @sap: SAP 471 469 * @daddr: address of remote LLC (MAC + SAP) 472 470 * @laddr: address of local LLC (MAC + SAP) 471 + * @net: netns to look up a socket in 473 472 * 474 473 * Search connection list of the SAP and finds connection using the remote 475 474 * mac, remote sap, local mac, and local sap. Returns pointer for ··· 479 476 */ 480 477 static struct sock *__llc_lookup_established(struct llc_sap *sap, 481 478 struct llc_addr *daddr, 482 - struct llc_addr *laddr) 479 + struct llc_addr *laddr, 480 + const struct net *net) 483 481 { 484 482 struct sock *rc; 485 483 struct hlist_nulls_node *node; ··· 490 486 rcu_read_lock(); 491 487 again: 492 488 sk_nulls_for_each_rcu(rc, node, laddr_hb) { 493 - if (llc_estab_match(sap, daddr, laddr, rc)) { 489 + if (llc_estab_match(sap, daddr, laddr, rc, net)) { 494 490 /* Extra checks required by SLAB_TYPESAFE_BY_RCU */ 495 491 if (unlikely(!refcount_inc_not_zero(&rc->sk_refcnt))) 496 492 goto again; 497 493 if (unlikely(llc_sk(rc)->sap != sap || 498 - !llc_estab_match(sap, daddr, laddr, rc))) { 494 + !llc_estab_match(sap, daddr, laddr, rc, net))) { 499 495 sock_put(rc); 500 496 continue; 501 497 } ··· 517 513 518 514 struct sock *llc_lookup_established(struct llc_sap *sap, 519 515 struct llc_addr *daddr, 520 - struct llc_addr *laddr) 516 + struct llc_addr *laddr, 517 + const struct net *net) 521 518 { 522 519 struct sock *sk; 523 520 524 521 local_bh_disable(); 525 - sk = __llc_lookup_established(sap, daddr, laddr); 522 + sk = __llc_lookup_established(sap, daddr, laddr, net); 526 523 local_bh_enable(); 527 524 return sk; 528 525 } 529 526 530 527 static inline bool llc_listener_match(const struct llc_sap *sap, 531 528 const struct llc_addr *laddr, 532 - const struct sock *sk) 529 + const struct sock *sk, 530 + const struct net *net) 533 531 { 534 532 struct llc_sock *llc = llc_sk(sk); 535 533 536 - return sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_LISTEN && 534 + return net_eq(sock_net(sk), net) && 535 + sk->sk_type == SOCK_STREAM && sk->sk_state == TCP_LISTEN && 537 536 llc->laddr.lsap == laddr->lsap && 538 537 ether_addr_equal(llc->laddr.mac, laddr->mac); 539 538 } 540 539 541 540 static struct sock *__llc_lookup_listener(struct llc_sap *sap, 542 - struct llc_addr *laddr) 541 + struct llc_addr *laddr, 542 + const struct net *net) 543 543 { 544 544 struct sock *rc; 545 545 struct hlist_nulls_node *node; ··· 553 545 rcu_read_lock(); 554 546 again: 555 547 sk_nulls_for_each_rcu(rc, node, laddr_hb) { 556 - if (llc_listener_match(sap, laddr, rc)) { 548 + if (llc_listener_match(sap, laddr, rc, net)) { 557 549 /* Extra checks required by SLAB_TYPESAFE_BY_RCU */ 558 550 if (unlikely(!refcount_inc_not_zero(&rc->sk_refcnt))) 559 551 goto again; 560 552 if (unlikely(llc_sk(rc)->sap != sap || 561 - !llc_listener_match(sap, laddr, rc))) { 553 + !llc_listener_match(sap, laddr, rc, net))) { 562 554 sock_put(rc); 563 555 continue; 564 556 } ··· 582 574 * llc_lookup_listener - Finds listener for local MAC + SAP 583 575 * @sap: SAP 584 576 * @laddr: address of local LLC (MAC + SAP) 577 + * @net: netns to look up a socket in 585 578 * 586 579 * Search connection list of the SAP and finds connection listening on 587 580 * local mac, and local sap. Returns pointer for parent socket found, ··· 590 581 * Caller has to make sure local_bh is disabled. 591 582 */ 592 583 static struct sock *llc_lookup_listener(struct llc_sap *sap, 593 - struct llc_addr *laddr) 584 + struct llc_addr *laddr, 585 + const struct net *net) 594 586 { 587 + struct sock *rc = __llc_lookup_listener(sap, laddr, net); 595 588 static struct llc_addr null_addr; 596 - struct sock *rc = __llc_lookup_listener(sap, laddr); 597 589 598 590 if (!rc) 599 - rc = __llc_lookup_listener(sap, &null_addr); 591 + rc = __llc_lookup_listener(sap, &null_addr, net); 600 592 601 593 return rc; 602 594 } 603 595 604 596 static struct sock *__llc_lookup(struct llc_sap *sap, 605 597 struct llc_addr *daddr, 606 - struct llc_addr *laddr) 598 + struct llc_addr *laddr, 599 + const struct net *net) 607 600 { 608 - struct sock *sk = __llc_lookup_established(sap, daddr, laddr); 601 + struct sock *sk = __llc_lookup_established(sap, daddr, laddr, net); 609 602 610 - return sk ? : llc_lookup_listener(sap, laddr); 603 + return sk ? : llc_lookup_listener(sap, laddr, net); 611 604 } 612 605 613 606 /** ··· 787 776 llc_pdu_decode_da(skb, daddr.mac); 788 777 llc_pdu_decode_dsap(skb, &daddr.lsap); 789 778 790 - sk = __llc_lookup(sap, &saddr, &daddr); 779 + sk = __llc_lookup(sap, &saddr, &daddr, dev_net(skb->dev)); 791 780 if (!sk) 792 781 goto drop; 793 782
+1 -1
net/llc/llc_if.c
··· 92 92 daddr.lsap = dsap; 93 93 memcpy(daddr.mac, dmac, sizeof(daddr.mac)); 94 94 memcpy(laddr.mac, lmac, sizeof(laddr.mac)); 95 - existing = llc_lookup_established(llc->sap, &daddr, &laddr); 95 + existing = llc_lookup_established(llc->sap, &daddr, &laddr, sock_net(sk)); 96 96 if (existing) { 97 97 if (existing->sk_state == TCP_ESTABLISHED) { 98 98 sk = existing;
-3
net/llc/llc_input.c
··· 163 163 void (*sta_handler)(struct sk_buff *skb); 164 164 void (*sap_handler)(struct llc_sap *sap, struct sk_buff *skb); 165 165 166 - if (!net_eq(dev_net(dev), &init_net)) 167 - goto drop; 168 - 169 166 /* 170 167 * When the interface is in promisc. mode, drop all the crap that it 171 168 * receives, do not try to analyse it.
+11 -7
net/llc/llc_sap.c
··· 294 294 295 295 static inline bool llc_dgram_match(const struct llc_sap *sap, 296 296 const struct llc_addr *laddr, 297 - const struct sock *sk) 297 + const struct sock *sk, 298 + const struct net *net) 298 299 { 299 300 struct llc_sock *llc = llc_sk(sk); 300 301 301 302 return sk->sk_type == SOCK_DGRAM && 302 - llc->laddr.lsap == laddr->lsap && 303 - ether_addr_equal(llc->laddr.mac, laddr->mac); 303 + net_eq(sock_net(sk), net) && 304 + llc->laddr.lsap == laddr->lsap && 305 + ether_addr_equal(llc->laddr.mac, laddr->mac); 304 306 } 305 307 306 308 /** 307 309 * llc_lookup_dgram - Finds dgram socket for the local sap/mac 308 310 * @sap: SAP 309 311 * @laddr: address of local LLC (MAC + SAP) 312 + * @net: netns to look up a socket in 310 313 * 311 314 * Search socket list of the SAP and finds connection using the local 312 315 * mac, and local sap. Returns pointer for socket found, %NULL otherwise. 313 316 */ 314 317 static struct sock *llc_lookup_dgram(struct llc_sap *sap, 315 - const struct llc_addr *laddr) 318 + const struct llc_addr *laddr, 319 + const struct net *net) 316 320 { 317 321 struct sock *rc; 318 322 struct hlist_nulls_node *node; ··· 326 322 rcu_read_lock_bh(); 327 323 again: 328 324 sk_nulls_for_each_rcu(rc, node, laddr_hb) { 329 - if (llc_dgram_match(sap, laddr, rc)) { 325 + if (llc_dgram_match(sap, laddr, rc, net)) { 330 326 /* Extra checks required by SLAB_TYPESAFE_BY_RCU */ 331 327 if (unlikely(!refcount_inc_not_zero(&rc->sk_refcnt))) 332 328 goto again; 333 329 if (unlikely(llc_sk(rc)->sap != sap || 334 - !llc_dgram_match(sap, laddr, rc))) { 330 + !llc_dgram_match(sap, laddr, rc, net))) { 335 331 sock_put(rc); 336 332 continue; 337 333 } ··· 433 429 llc_sap_mcast(sap, &laddr, skb); 434 430 kfree_skb(skb); 435 431 } else { 436 - struct sock *sk = llc_lookup_dgram(sap, &laddr); 432 + struct sock *sk = llc_lookup_dgram(sap, &laddr, dev_net(skb->dev)); 437 433 if (sk) { 438 434 llc_sap_rcv(sap, skb, sk); 439 435 sock_put(sk);
+10 -2
net/netfilter/nf_tables_api.c
··· 3685 3685 if (err < 0) 3686 3686 return err; 3687 3687 } 3688 - 3689 - cond_resched(); 3690 3688 } 3691 3689 3692 3690 return 0; ··· 3708 3710 err = nft_chain_validate(&ctx, chain); 3709 3711 if (err < 0) 3710 3712 return err; 3713 + 3714 + cond_resched(); 3711 3715 } 3712 3716 3713 3717 return 0; ··· 4086 4086 } else { 4087 4087 list_for_each_entry(chain, &table->chains, list) { 4088 4088 if (!nft_is_active_next(net, chain)) 4089 + continue; 4090 + if (nft_chain_is_bound(chain)) 4089 4091 continue; 4090 4092 4091 4093 ctx.chain = chain; ··· 10519 10517 10520 10518 if (!tb[NFTA_VERDICT_CODE]) 10521 10519 return -EINVAL; 10520 + 10521 + /* zero padding hole for memcmp */ 10522 + memset(data, 0, sizeof(*data)); 10522 10523 data->verdict.code = ntohl(nla_get_be32(tb[NFTA_VERDICT_CODE])); 10523 10524 10524 10525 switch (data->verdict.code) { ··· 10804 10799 ctx.family = table->family; 10805 10800 ctx.table = table; 10806 10801 list_for_each_entry(chain, &table->chains, list) { 10802 + if (nft_chain_is_bound(chain)) 10803 + continue; 10804 + 10807 10805 ctx.chain = chain; 10808 10806 list_for_each_entry_safe(rule, nr, &chain->rules, list) { 10809 10807 list_del(&rule->list);
+5 -1
net/netfilter/nft_set_pipapo.c
··· 1929 1929 int i, start, rules_fx; 1930 1930 1931 1931 match_start = data; 1932 - match_end = (const u8 *)nft_set_ext_key_end(&e->ext)->data; 1932 + 1933 + if (nft_set_ext_exists(&e->ext, NFT_SET_EXT_KEY_END)) 1934 + match_end = (const u8 *)nft_set_ext_key_end(&e->ext)->data; 1935 + else 1936 + match_end = data; 1933 1937 1934 1938 start = first_rule; 1935 1939 rules_fx = rules_f0;
+47 -52
net/sched/cls_bpf.c
··· 406 406 return 0; 407 407 } 408 408 409 - static int cls_bpf_set_parms(struct net *net, struct tcf_proto *tp, 410 - struct cls_bpf_prog *prog, unsigned long base, 411 - struct nlattr **tb, struct nlattr *est, u32 flags, 412 - struct netlink_ext_ack *extack) 413 - { 414 - bool is_bpf, is_ebpf, have_exts = false; 415 - u32 gen_flags = 0; 416 - int ret; 417 - 418 - is_bpf = tb[TCA_BPF_OPS_LEN] && tb[TCA_BPF_OPS]; 419 - is_ebpf = tb[TCA_BPF_FD]; 420 - if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf)) 421 - return -EINVAL; 422 - 423 - ret = tcf_exts_validate(net, tp, tb, est, &prog->exts, flags, 424 - extack); 425 - if (ret < 0) 426 - return ret; 427 - 428 - if (tb[TCA_BPF_FLAGS]) { 429 - u32 bpf_flags = nla_get_u32(tb[TCA_BPF_FLAGS]); 430 - 431 - if (bpf_flags & ~TCA_BPF_FLAG_ACT_DIRECT) 432 - return -EINVAL; 433 - 434 - have_exts = bpf_flags & TCA_BPF_FLAG_ACT_DIRECT; 435 - } 436 - if (tb[TCA_BPF_FLAGS_GEN]) { 437 - gen_flags = nla_get_u32(tb[TCA_BPF_FLAGS_GEN]); 438 - if (gen_flags & ~CLS_BPF_SUPPORTED_GEN_FLAGS || 439 - !tc_flags_valid(gen_flags)) 440 - return -EINVAL; 441 - } 442 - 443 - prog->exts_integrated = have_exts; 444 - prog->gen_flags = gen_flags; 445 - 446 - ret = is_bpf ? cls_bpf_prog_from_ops(tb, prog) : 447 - cls_bpf_prog_from_efd(tb, prog, gen_flags, tp); 448 - if (ret < 0) 449 - return ret; 450 - 451 - if (tb[TCA_BPF_CLASSID]) { 452 - prog->res.classid = nla_get_u32(tb[TCA_BPF_CLASSID]); 453 - tcf_bind_filter(tp, &prog->res, base); 454 - } 455 - 456 - return 0; 457 - } 458 - 459 409 static int cls_bpf_change(struct net *net, struct sk_buff *in_skb, 460 410 struct tcf_proto *tp, unsigned long base, 461 411 u32 handle, struct nlattr **tca, ··· 413 463 struct netlink_ext_ack *extack) 414 464 { 415 465 struct cls_bpf_head *head = rtnl_dereference(tp->root); 466 + bool is_bpf, is_ebpf, have_exts = false; 416 467 struct cls_bpf_prog *oldprog = *arg; 417 468 struct nlattr *tb[TCA_BPF_MAX + 1]; 469 + bool bound_to_filter = false; 418 470 struct cls_bpf_prog *prog; 471 + u32 gen_flags = 0; 419 472 int ret; 420 473 421 474 if (tca[TCA_OPTIONS] == NULL) ··· 457 504 goto errout; 458 505 prog->handle = handle; 459 506 460 - ret = cls_bpf_set_parms(net, tp, prog, base, tb, tca[TCA_RATE], flags, 461 - extack); 507 + is_bpf = tb[TCA_BPF_OPS_LEN] && tb[TCA_BPF_OPS]; 508 + is_ebpf = tb[TCA_BPF_FD]; 509 + if ((!is_bpf && !is_ebpf) || (is_bpf && is_ebpf)) { 510 + ret = -EINVAL; 511 + goto errout_idr; 512 + } 513 + 514 + ret = tcf_exts_validate(net, tp, tb, tca[TCA_RATE], &prog->exts, 515 + flags, extack); 462 516 if (ret < 0) 463 517 goto errout_idr; 518 + 519 + if (tb[TCA_BPF_FLAGS]) { 520 + u32 bpf_flags = nla_get_u32(tb[TCA_BPF_FLAGS]); 521 + 522 + if (bpf_flags & ~TCA_BPF_FLAG_ACT_DIRECT) { 523 + ret = -EINVAL; 524 + goto errout_idr; 525 + } 526 + 527 + have_exts = bpf_flags & TCA_BPF_FLAG_ACT_DIRECT; 528 + } 529 + if (tb[TCA_BPF_FLAGS_GEN]) { 530 + gen_flags = nla_get_u32(tb[TCA_BPF_FLAGS_GEN]); 531 + if (gen_flags & ~CLS_BPF_SUPPORTED_GEN_FLAGS || 532 + !tc_flags_valid(gen_flags)) { 533 + ret = -EINVAL; 534 + goto errout_idr; 535 + } 536 + } 537 + 538 + prog->exts_integrated = have_exts; 539 + prog->gen_flags = gen_flags; 540 + 541 + ret = is_bpf ? cls_bpf_prog_from_ops(tb, prog) : 542 + cls_bpf_prog_from_efd(tb, prog, gen_flags, tp); 543 + if (ret < 0) 544 + goto errout_idr; 545 + 546 + if (tb[TCA_BPF_CLASSID]) { 547 + prog->res.classid = nla_get_u32(tb[TCA_BPF_CLASSID]); 548 + tcf_bind_filter(tp, &prog->res, base); 549 + bound_to_filter = true; 550 + } 464 551 465 552 ret = cls_bpf_offload(tp, prog, oldprog, extack); 466 553 if (ret) ··· 523 530 return 0; 524 531 525 532 errout_parms: 533 + if (bound_to_filter) 534 + tcf_unbind_filter(tp, &prog->res); 526 535 cls_bpf_free_parms(prog); 527 536 errout_idr: 528 537 if (!oldprog)
+47 -52
net/sched/cls_flower.c
··· 2173 2173 return mask->meta.l2_miss; 2174 2174 } 2175 2175 2176 - static int fl_set_parms(struct net *net, struct tcf_proto *tp, 2177 - struct cls_fl_filter *f, struct fl_flow_mask *mask, 2178 - unsigned long base, struct nlattr **tb, 2179 - struct nlattr *est, 2180 - struct fl_flow_tmplt *tmplt, 2181 - u32 flags, u32 fl_flags, 2182 - struct netlink_ext_ack *extack) 2183 - { 2184 - int err; 2185 - 2186 - err = tcf_exts_validate_ex(net, tp, tb, est, &f->exts, flags, 2187 - fl_flags, extack); 2188 - if (err < 0) 2189 - return err; 2190 - 2191 - if (tb[TCA_FLOWER_CLASSID]) { 2192 - f->res.classid = nla_get_u32(tb[TCA_FLOWER_CLASSID]); 2193 - if (flags & TCA_ACT_FLAGS_NO_RTNL) 2194 - rtnl_lock(); 2195 - tcf_bind_filter(tp, &f->res, base); 2196 - if (flags & TCA_ACT_FLAGS_NO_RTNL) 2197 - rtnl_unlock(); 2198 - } 2199 - 2200 - err = fl_set_key(net, tb, &f->key, &mask->key, extack); 2201 - if (err) 2202 - return err; 2203 - 2204 - fl_mask_update_range(mask); 2205 - fl_set_masked_key(&f->mkey, &f->key, mask); 2206 - 2207 - if (!fl_mask_fits_tmplt(tmplt, mask)) { 2208 - NL_SET_ERR_MSG_MOD(extack, "Mask does not fit the template"); 2209 - return -EINVAL; 2210 - } 2211 - 2212 - /* Enable tc skb extension if filter matches on data extracted from 2213 - * this extension. 2214 - */ 2215 - if (fl_needs_tc_skb_ext(&mask->key)) { 2216 - f->needs_tc_skb_ext = 1; 2217 - tc_skb_ext_tc_enable(); 2218 - } 2219 - 2220 - return 0; 2221 - } 2222 - 2223 2176 static int fl_ht_insert_unique(struct cls_fl_filter *fnew, 2224 2177 struct cls_fl_filter *fold, 2225 2178 bool *in_ht) ··· 2204 2251 struct cls_fl_head *head = fl_head_dereference(tp); 2205 2252 bool rtnl_held = !(flags & TCA_ACT_FLAGS_NO_RTNL); 2206 2253 struct cls_fl_filter *fold = *arg; 2254 + bool bound_to_filter = false; 2207 2255 struct cls_fl_filter *fnew; 2208 2256 struct fl_flow_mask *mask; 2209 2257 struct nlattr **tb; ··· 2289 2335 if (err < 0) 2290 2336 goto errout_idr; 2291 2337 2292 - err = fl_set_parms(net, tp, fnew, mask, base, tb, tca[TCA_RATE], 2293 - tp->chain->tmplt_priv, flags, fnew->flags, 2294 - extack); 2295 - if (err) 2338 + err = tcf_exts_validate_ex(net, tp, tb, tca[TCA_RATE], 2339 + &fnew->exts, flags, fnew->flags, 2340 + extack); 2341 + if (err < 0) 2296 2342 goto errout_idr; 2343 + 2344 + if (tb[TCA_FLOWER_CLASSID]) { 2345 + fnew->res.classid = nla_get_u32(tb[TCA_FLOWER_CLASSID]); 2346 + if (flags & TCA_ACT_FLAGS_NO_RTNL) 2347 + rtnl_lock(); 2348 + tcf_bind_filter(tp, &fnew->res, base); 2349 + if (flags & TCA_ACT_FLAGS_NO_RTNL) 2350 + rtnl_unlock(); 2351 + bound_to_filter = true; 2352 + } 2353 + 2354 + err = fl_set_key(net, tb, &fnew->key, &mask->key, extack); 2355 + if (err) 2356 + goto unbind_filter; 2357 + 2358 + fl_mask_update_range(mask); 2359 + fl_set_masked_key(&fnew->mkey, &fnew->key, mask); 2360 + 2361 + if (!fl_mask_fits_tmplt(tp->chain->tmplt_priv, mask)) { 2362 + NL_SET_ERR_MSG_MOD(extack, "Mask does not fit the template"); 2363 + err = -EINVAL; 2364 + goto unbind_filter; 2365 + } 2366 + 2367 + /* Enable tc skb extension if filter matches on data extracted from 2368 + * this extension. 2369 + */ 2370 + if (fl_needs_tc_skb_ext(&mask->key)) { 2371 + fnew->needs_tc_skb_ext = 1; 2372 + tc_skb_ext_tc_enable(); 2373 + } 2297 2374 2298 2375 err = fl_check_assign_mask(head, fnew, fold, mask); 2299 2376 if (err) 2300 - goto errout_idr; 2377 + goto unbind_filter; 2301 2378 2302 2379 err = fl_ht_insert_unique(fnew, fold, &in_ht); 2303 2380 if (err) ··· 2419 2434 fnew->mask->filter_ht_params); 2420 2435 errout_mask: 2421 2436 fl_mask_put(head, fnew->mask); 2437 + 2438 + unbind_filter: 2439 + if (bound_to_filter) { 2440 + if (flags & TCA_ACT_FLAGS_NO_RTNL) 2441 + rtnl_lock(); 2442 + tcf_unbind_filter(tp, &fnew->res); 2443 + if (flags & TCA_ACT_FLAGS_NO_RTNL) 2444 + rtnl_unlock(); 2445 + } 2446 + 2422 2447 errout_idr: 2423 2448 if (!fold) 2424 2449 idr_remove(&head->handle_idr, fnew->handle);
+12 -23
net/sched/cls_matchall.c
··· 159 159 [TCA_MATCHALL_FLAGS] = { .type = NLA_U32 }, 160 160 }; 161 161 162 - static int mall_set_parms(struct net *net, struct tcf_proto *tp, 163 - struct cls_mall_head *head, 164 - unsigned long base, struct nlattr **tb, 165 - struct nlattr *est, u32 flags, u32 fl_flags, 166 - struct netlink_ext_ack *extack) 167 - { 168 - int err; 169 - 170 - err = tcf_exts_validate_ex(net, tp, tb, est, &head->exts, flags, 171 - fl_flags, extack); 172 - if (err < 0) 173 - return err; 174 - 175 - if (tb[TCA_MATCHALL_CLASSID]) { 176 - head->res.classid = nla_get_u32(tb[TCA_MATCHALL_CLASSID]); 177 - tcf_bind_filter(tp, &head->res, base); 178 - } 179 - return 0; 180 - } 181 - 182 162 static int mall_change(struct net *net, struct sk_buff *in_skb, 183 163 struct tcf_proto *tp, unsigned long base, 184 164 u32 handle, struct nlattr **tca, ··· 167 187 { 168 188 struct cls_mall_head *head = rtnl_dereference(tp->root); 169 189 struct nlattr *tb[TCA_MATCHALL_MAX + 1]; 190 + bool bound_to_filter = false; 170 191 struct cls_mall_head *new; 171 192 u32 userflags = 0; 172 193 int err; ··· 207 226 goto err_alloc_percpu; 208 227 } 209 228 210 - err = mall_set_parms(net, tp, new, base, tb, tca[TCA_RATE], 211 - flags, new->flags, extack); 212 - if (err) 229 + err = tcf_exts_validate_ex(net, tp, tb, tca[TCA_RATE], 230 + &new->exts, flags, new->flags, extack); 231 + if (err < 0) 213 232 goto err_set_parms; 233 + 234 + if (tb[TCA_MATCHALL_CLASSID]) { 235 + new->res.classid = nla_get_u32(tb[TCA_MATCHALL_CLASSID]); 236 + tcf_bind_filter(tp, &new->res, base); 237 + bound_to_filter = true; 238 + } 214 239 215 240 if (!tc_skip_hw(new->flags)) { 216 241 err = mall_replace_hw_filter(tp, new, (unsigned long)new, ··· 233 246 return 0; 234 247 235 248 err_replace_hw_filter: 249 + if (bound_to_filter) 250 + tcf_unbind_filter(tp, &new->res); 236 251 err_set_parms: 237 252 free_percpu(new->pf); 238 253 err_alloc_percpu:
+37 -11
net/sched/cls_u32.c
··· 712 712 [TCA_U32_FLAGS] = { .type = NLA_U32 }, 713 713 }; 714 714 715 + static void u32_unbind_filter(struct tcf_proto *tp, struct tc_u_knode *n, 716 + struct nlattr **tb) 717 + { 718 + if (tb[TCA_U32_CLASSID]) 719 + tcf_unbind_filter(tp, &n->res); 720 + } 721 + 722 + static void u32_bind_filter(struct tcf_proto *tp, struct tc_u_knode *n, 723 + unsigned long base, struct nlattr **tb) 724 + { 725 + if (tb[TCA_U32_CLASSID]) { 726 + n->res.classid = nla_get_u32(tb[TCA_U32_CLASSID]); 727 + tcf_bind_filter(tp, &n->res, base); 728 + } 729 + } 730 + 715 731 static int u32_set_parms(struct net *net, struct tcf_proto *tp, 716 - unsigned long base, 717 732 struct tc_u_knode *n, struct nlattr **tb, 718 733 struct nlattr *est, u32 flags, u32 fl_flags, 719 734 struct netlink_ext_ack *extack) ··· 774 759 775 760 if (ht_old) 776 761 ht_old->refcnt--; 777 - } 778 - if (tb[TCA_U32_CLASSID]) { 779 - n->res.classid = nla_get_u32(tb[TCA_U32_CLASSID]); 780 - tcf_bind_filter(tp, &n->res, base); 781 762 } 782 763 783 764 if (ifindex >= 0) ··· 914 903 if (!new) 915 904 return -ENOMEM; 916 905 917 - err = u32_set_parms(net, tp, base, new, tb, 918 - tca[TCA_RATE], flags, new->flags, 919 - extack); 906 + err = u32_set_parms(net, tp, new, tb, tca[TCA_RATE], 907 + flags, new->flags, extack); 920 908 921 909 if (err) { 922 910 __u32_destroy_key(new); 923 911 return err; 924 912 } 925 913 914 + u32_bind_filter(tp, new, base, tb); 915 + 926 916 err = u32_replace_hw_knode(tp, new, flags, extack); 927 917 if (err) { 918 + u32_unbind_filter(tp, new, tb); 919 + 920 + if (tb[TCA_U32_LINK]) { 921 + struct tc_u_hnode *ht_old; 922 + 923 + ht_old = rtnl_dereference(n->ht_down); 924 + if (ht_old) 925 + ht_old->refcnt++; 926 + } 928 927 __u32_destroy_key(new); 929 928 return err; 930 929 } ··· 1095 1074 } 1096 1075 #endif 1097 1076 1098 - err = u32_set_parms(net, tp, base, n, tb, tca[TCA_RATE], 1077 + err = u32_set_parms(net, tp, n, tb, tca[TCA_RATE], 1099 1078 flags, n->flags, extack); 1079 + 1080 + u32_bind_filter(tp, n, base, tb); 1081 + 1100 1082 if (err == 0) { 1101 1083 struct tc_u_knode __rcu **ins; 1102 1084 struct tc_u_knode *pins; 1103 1085 1104 1086 err = u32_replace_hw_knode(tp, n, flags, extack); 1105 1087 if (err) 1106 - goto errhw; 1088 + goto errunbind; 1107 1089 1108 1090 if (!tc_in_hw(n->flags)) 1109 1091 n->flags |= TCA_CLS_FLAGS_NOT_IN_HW; ··· 1124 1100 return 0; 1125 1101 } 1126 1102 1127 - errhw: 1103 + errunbind: 1104 + u32_unbind_filter(tp, n, tb); 1105 + 1128 1106 #ifdef CONFIG_CLS_U32_MARK 1129 1107 free_percpu(n->pcpu_success); 1130 1108 #endif
+3 -3
scripts/kallsyms.c
··· 349 349 * ASCII[_] = 5f 350 350 * ASCII[a-z] = 61,7a 351 351 * 352 - * As above, replacing '.' with '\0' does not affect the main sorting, 353 - * but it helps us with subsorting. 352 + * As above, replacing the first '.' in ".llvm." with '\0' does not 353 + * affect the main sorting, but it helps us with subsorting. 354 354 */ 355 - p = strchr(s, '.'); 355 + p = strstr(s, ".llvm."); 356 356 if (p) 357 357 *p = '\0'; 358 358 }
+24 -11
security/keys/request_key.c
··· 401 401 set_bit(KEY_FLAG_USER_CONSTRUCT, &key->flags); 402 402 403 403 if (dest_keyring) { 404 - ret = __key_link_lock(dest_keyring, &ctx->index_key); 404 + ret = __key_link_lock(dest_keyring, &key->index_key); 405 405 if (ret < 0) 406 406 goto link_lock_failed; 407 - ret = __key_link_begin(dest_keyring, &ctx->index_key, &edit); 408 - if (ret < 0) 409 - goto link_prealloc_failed; 410 407 } 411 408 412 - /* attach the key to the destination keyring under lock, but we do need 409 + /* 410 + * Attach the key to the destination keyring under lock, but we do need 413 411 * to do another check just in case someone beat us to it whilst we 414 - * waited for locks */ 412 + * waited for locks. 413 + * 414 + * The caller might specify a comparison function which looks for keys 415 + * that do not exactly match but are still equivalent from the caller's 416 + * perspective. The __key_link_begin() operation must be done only after 417 + * an actual key is determined. 418 + */ 415 419 mutex_lock(&key_construction_mutex); 416 420 417 421 rcu_read_lock(); ··· 424 420 if (!IS_ERR(key_ref)) 425 421 goto key_already_present; 426 422 427 - if (dest_keyring) 423 + if (dest_keyring) { 424 + ret = __key_link_begin(dest_keyring, &key->index_key, &edit); 425 + if (ret < 0) 426 + goto link_alloc_failed; 428 427 __key_link(dest_keyring, key, &edit); 428 + } 429 429 430 430 mutex_unlock(&key_construction_mutex); 431 431 if (dest_keyring) 432 - __key_link_end(dest_keyring, &ctx->index_key, edit); 432 + __key_link_end(dest_keyring, &key->index_key, edit); 433 433 mutex_unlock(&user->cons_lock); 434 434 *_key = key; 435 435 kleave(" = 0 [%d]", key_serial(key)); ··· 446 438 mutex_unlock(&key_construction_mutex); 447 439 key = key_ref_to_ptr(key_ref); 448 440 if (dest_keyring) { 441 + ret = __key_link_begin(dest_keyring, &key->index_key, &edit); 442 + if (ret < 0) 443 + goto link_alloc_failed_unlocked; 449 444 ret = __key_link_check_live_key(dest_keyring, key); 450 445 if (ret == 0) 451 446 __key_link(dest_keyring, key, &edit); 452 - __key_link_end(dest_keyring, &ctx->index_key, edit); 447 + __key_link_end(dest_keyring, &key->index_key, edit); 453 448 if (ret < 0) 454 449 goto link_check_failed; 455 450 } ··· 467 456 kleave(" = %d [linkcheck]", ret); 468 457 return ret; 469 458 470 - link_prealloc_failed: 471 - __key_link_end(dest_keyring, &ctx->index_key, edit); 459 + link_alloc_failed: 460 + mutex_unlock(&key_construction_mutex); 461 + link_alloc_failed_unlocked: 462 + __key_link_end(dest_keyring, &key->index_key, edit); 472 463 link_lock_failed: 473 464 mutex_unlock(&user->cons_lock); 474 465 key_put(key);
+1 -1
security/keys/trusted-keys/trusted_tpm2.c
··· 186 186 } 187 187 188 188 /** 189 - * tpm_buf_append_auth() - append TPMS_AUTH_COMMAND to the buffer. 189 + * tpm2_buf_append_auth() - append TPMS_AUTH_COMMAND to the buffer. 190 190 * 191 191 * @buf: an allocated tpm_buf instance 192 192 * @session_handle: session handle
+8
tools/arch/arm64/include/asm/cputype.h
··· 126 126 #define APPLE_CPU_PART_M1_FIRESTORM_MAX 0x029 127 127 #define APPLE_CPU_PART_M2_BLIZZARD 0x032 128 128 #define APPLE_CPU_PART_M2_AVALANCHE 0x033 129 + #define APPLE_CPU_PART_M2_BLIZZARD_PRO 0x034 130 + #define APPLE_CPU_PART_M2_AVALANCHE_PRO 0x035 131 + #define APPLE_CPU_PART_M2_BLIZZARD_MAX 0x038 132 + #define APPLE_CPU_PART_M2_AVALANCHE_MAX 0x039 129 133 130 134 #define AMPERE_CPU_PART_AMPERE1 0xAC3 131 135 ··· 185 181 #define MIDR_APPLE_M1_FIRESTORM_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M1_FIRESTORM_MAX) 186 182 #define MIDR_APPLE_M2_BLIZZARD MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD) 187 183 #define MIDR_APPLE_M2_AVALANCHE MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE) 184 + #define MIDR_APPLE_M2_BLIZZARD_PRO MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD_PRO) 185 + #define MIDR_APPLE_M2_AVALANCHE_PRO MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_PRO) 186 + #define MIDR_APPLE_M2_BLIZZARD_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_BLIZZARD_MAX) 187 + #define MIDR_APPLE_M2_AVALANCHE_MAX MIDR_CPU_MODEL(ARM_CPU_IMP_APPLE, APPLE_CPU_PART_M2_AVALANCHE_MAX) 188 188 #define MIDR_AMPERE1 MIDR_CPU_MODEL(ARM_CPU_IMP_AMPERE, AMPERE_CPU_PART_AMPERE1) 189 189 190 190 /* Fujitsu Erratum 010001 affects A64FX 1.0 and 1.1, (v0r0 and v1r0) */
+1 -1
tools/build/feature/Makefile
··· 208 208 $(BUILD) -ltraceevent 209 209 210 210 $(OUTPUT)test-libtracefs.bin: 211 - $(BUILD) -ltracefs 211 + $(BUILD) $(shell $(PKG_CONFIG) --cflags libtraceevent 2>/dev/null) -ltracefs 212 212 213 213 $(OUTPUT)test-libcrypto.bin: 214 214 $(BUILD) -lcrypto
+4 -1
tools/include/uapi/asm-generic/unistd.h
··· 817 817 #define __NR_set_mempolicy_home_node 450 818 818 __SYSCALL(__NR_set_mempolicy_home_node, sys_set_mempolicy_home_node) 819 819 820 + #define __NR_cachestat 451 821 + __SYSCALL(__NR_cachestat, sys_cachestat) 822 + 820 823 #undef __NR_syscalls 821 - #define __NR_syscalls 451 824 + #define __NR_syscalls 452 822 825 823 826 /* 824 827 * 32 bit systems traditionally used different
+93 -2
tools/include/uapi/drm/i915_drm.h
··· 280 280 #define I915_PMU_ENGINE_SEMA(class, instance) \ 281 281 __I915_PMU_ENGINE(class, instance, I915_SAMPLE_SEMA) 282 282 283 - #define __I915_PMU_OTHER(x) (__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x)) 283 + /* 284 + * Top 4 bits of every non-engine counter are GT id. 285 + */ 286 + #define __I915_PMU_GT_SHIFT (60) 287 + 288 + #define ___I915_PMU_OTHER(gt, x) \ 289 + (((__u64)__I915_PMU_ENGINE(0xff, 0xff, 0xf) + 1 + (x)) | \ 290 + ((__u64)(gt) << __I915_PMU_GT_SHIFT)) 291 + 292 + #define __I915_PMU_OTHER(x) ___I915_PMU_OTHER(0, x) 284 293 285 294 #define I915_PMU_ACTUAL_FREQUENCY __I915_PMU_OTHER(0) 286 295 #define I915_PMU_REQUESTED_FREQUENCY __I915_PMU_OTHER(1) ··· 298 289 #define I915_PMU_SOFTWARE_GT_AWAKE_TIME __I915_PMU_OTHER(4) 299 290 300 291 #define I915_PMU_LAST /* Deprecated - do not use */ I915_PMU_RC6_RESIDENCY 292 + 293 + #define __I915_PMU_ACTUAL_FREQUENCY(gt) ___I915_PMU_OTHER(gt, 0) 294 + #define __I915_PMU_REQUESTED_FREQUENCY(gt) ___I915_PMU_OTHER(gt, 1) 295 + #define __I915_PMU_INTERRUPTS(gt) ___I915_PMU_OTHER(gt, 2) 296 + #define __I915_PMU_RC6_RESIDENCY(gt) ___I915_PMU_OTHER(gt, 3) 297 + #define __I915_PMU_SOFTWARE_GT_AWAKE_TIME(gt) ___I915_PMU_OTHER(gt, 4) 301 298 302 299 /* Each region is a minimum of 16k, and there are at most 255 of them. 303 300 */ ··· 674 659 * If the IOCTL is successful, the returned parameter will be set to one of the 675 660 * following values: 676 661 * * 0 if HuC firmware load is not complete, 677 - * * 1 if HuC firmware is authenticated and running. 662 + * * 1 if HuC firmware is loaded and fully authenticated, 663 + * * 2 if HuC firmware is loaded and authenticated for clear media only 678 664 */ 679 665 #define I915_PARAM_HUC_STATUS 42 680 666 ··· 786 770 * timestamp frequency, but differs on some platforms. 787 771 */ 788 772 #define I915_PARAM_OA_TIMESTAMP_FREQUENCY 57 773 + 774 + /* 775 + * Query the status of PXP support in i915. 776 + * 777 + * The query can fail in the following scenarios with the listed error codes: 778 + * -ENODEV = PXP support is not available on the GPU device or in the 779 + * kernel due to missing component drivers or kernel configs. 780 + * 781 + * If the IOCTL is successful, the returned parameter will be set to one of 782 + * the following values: 783 + * 1 = PXP feature is supported and is ready for use. 784 + * 2 = PXP feature is supported but should be ready soon (pending 785 + * initialization of non-i915 system dependencies). 786 + * 787 + * NOTE: When param is supported (positive return values), user space should 788 + * still refer to the GEM PXP context-creation UAPI header specs to be 789 + * aware of possible failure due to system state machine at the time. 790 + */ 791 + #define I915_PARAM_PXP_STATUS 58 789 792 790 793 /* Must be kept compact -- no holes and well documented */ 791 794 ··· 2131 2096 * 2132 2097 * -ENODEV: feature not available 2133 2098 * -EPERM: trying to mark a recoverable or not bannable context as protected 2099 + * -ENXIO: A dependency such as a component driver or firmware is not yet 2100 + * loaded so user space may need to attempt again. Depending on the 2101 + * device, this error may be reported if protected context creation is 2102 + * attempted very early after kernel start because the internal timeout 2103 + * waiting for such dependencies is not guaranteed to be larger than 2104 + * required (numbers differ depending on system and kernel config): 2105 + * - ADL/RPL: dependencies may take up to 3 seconds from kernel start 2106 + * while context creation internal timeout is 250 milisecs 2107 + * - MTL: dependencies may take up to 8 seconds from kernel start 2108 + * while context creation internal timeout is 250 milisecs 2109 + * NOTE: such dependencies happen once, so a subsequent call to create a 2110 + * protected context after a prior successful call will not experience 2111 + * such timeouts and will not return -ENXIO (unless the driver is reloaded, 2112 + * or, depending on the device, resumes from a suspended state). 2113 + * -EIO: The firmware did not succeed in creating the protected context. 2134 2114 */ 2135 2115 #define I915_CONTEXT_PARAM_PROTECTED_CONTENT 0xd 2136 2116 /* Must be kept compact -- no holes and well documented */ ··· 3680 3630 * 3681 3631 * For I915_GEM_CREATE_EXT_PROTECTED_CONTENT usage see 3682 3632 * struct drm_i915_gem_create_ext_protected_content. 3633 + * 3634 + * For I915_GEM_CREATE_EXT_SET_PAT usage see 3635 + * struct drm_i915_gem_create_ext_set_pat. 3683 3636 */ 3684 3637 #define I915_GEM_CREATE_EXT_MEMORY_REGIONS 0 3685 3638 #define I915_GEM_CREATE_EXT_PROTECTED_CONTENT 1 3639 + #define I915_GEM_CREATE_EXT_SET_PAT 2 3686 3640 __u64 extensions; 3687 3641 }; 3688 3642 ··· 3799 3745 struct i915_user_extension base; 3800 3746 /** @flags: reserved for future usage, currently MBZ */ 3801 3747 __u32 flags; 3748 + }; 3749 + 3750 + /** 3751 + * struct drm_i915_gem_create_ext_set_pat - The 3752 + * I915_GEM_CREATE_EXT_SET_PAT extension. 3753 + * 3754 + * If this extension is provided, the specified caching policy (PAT index) is 3755 + * applied to the buffer object. 3756 + * 3757 + * Below is an example on how to create an object with specific caching policy: 3758 + * 3759 + * .. code-block:: C 3760 + * 3761 + * struct drm_i915_gem_create_ext_set_pat set_pat_ext = { 3762 + * .base = { .name = I915_GEM_CREATE_EXT_SET_PAT }, 3763 + * .pat_index = 0, 3764 + * }; 3765 + * struct drm_i915_gem_create_ext create_ext = { 3766 + * .size = PAGE_SIZE, 3767 + * .extensions = (uintptr_t)&set_pat_ext, 3768 + * }; 3769 + * 3770 + * int err = ioctl(fd, DRM_IOCTL_I915_GEM_CREATE_EXT, &create_ext); 3771 + * if (err) ... 3772 + */ 3773 + struct drm_i915_gem_create_ext_set_pat { 3774 + /** @base: Extension link. See struct i915_user_extension. */ 3775 + struct i915_user_extension base; 3776 + /** 3777 + * @pat_index: PAT index to be set 3778 + * PAT index is a bit field in Page Table Entry to control caching 3779 + * behaviors for GPU accesses. The definition of PAT index is 3780 + * platform dependent and can be found in hardware specifications, 3781 + */ 3782 + __u32 pat_index; 3783 + /** @rsvd: reserved for future use */ 3784 + __u32 rsvd; 3802 3785 }; 3803 3786 3804 3787 /* ID of the protected content session managed by i915 when PXP is active */
+5
tools/include/uapi/linux/fcntl.h
··· 112 112 113 113 #define AT_RECURSIVE 0x8000 /* Apply to the entire subtree */ 114 114 115 + /* Flags for name_to_handle_at(2). We reuse AT_ flag space to save bits... */ 116 + #define AT_HANDLE_FID AT_REMOVEDIR /* file handle is needed to 117 + compare object identity and may not 118 + be usable to open_by_handle_at(2) */ 119 + 115 120 #endif /* _UAPI_LINUX_FCNTL_H */
+5 -1
tools/include/uapi/linux/kvm.h
··· 1190 1190 #define KVM_CAP_DIRTY_LOG_RING_WITH_BITMAP 225 1191 1191 #define KVM_CAP_PMU_EVENT_MASKED_EVENTS 226 1192 1192 #define KVM_CAP_COUNTER_OFFSET 227 1193 + #define KVM_CAP_ARM_EAGER_SPLIT_CHUNK_SIZE 228 1194 + #define KVM_CAP_ARM_SUPPORTED_BLOCK_SIZES 229 1193 1195 1194 1196 #ifdef KVM_CAP_IRQ_ROUTING 1195 1197 ··· 1444 1442 #define KVM_DEV_TYPE_XIVE KVM_DEV_TYPE_XIVE 1445 1443 KVM_DEV_TYPE_ARM_PV_TIME, 1446 1444 #define KVM_DEV_TYPE_ARM_PV_TIME KVM_DEV_TYPE_ARM_PV_TIME 1445 + KVM_DEV_TYPE_RISCV_AIA, 1446 + #define KVM_DEV_TYPE_RISCV_AIA KVM_DEV_TYPE_RISCV_AIA 1447 1447 KVM_DEV_TYPE_MAX, 1448 1448 }; 1449 1449 ··· 1617 1613 #define KVM_GET_DEBUGREGS _IOR(KVMIO, 0xa1, struct kvm_debugregs) 1618 1614 #define KVM_SET_DEBUGREGS _IOW(KVMIO, 0xa2, struct kvm_debugregs) 1619 1615 /* 1620 - * vcpu version available with KVM_ENABLE_CAP 1616 + * vcpu version available with KVM_CAP_ENABLE_CAP 1621 1617 * vm version available with KVM_CAP_ENABLE_CAP_VM 1622 1618 */ 1623 1619 #define KVM_ENABLE_CAP _IOW(KVMIO, 0xa3, struct kvm_enable_cap)
+14
tools/include/uapi/linux/mman.h
··· 4 4 5 5 #include <asm/mman.h> 6 6 #include <asm-generic/hugetlb_encode.h> 7 + #include <linux/types.h> 7 8 8 9 #define MREMAP_MAYMOVE 1 9 10 #define MREMAP_FIXED 2 ··· 41 40 #define MAP_HUGE_1GB HUGETLB_FLAG_ENCODE_1GB 42 41 #define MAP_HUGE_2GB HUGETLB_FLAG_ENCODE_2GB 43 42 #define MAP_HUGE_16GB HUGETLB_FLAG_ENCODE_16GB 43 + 44 + struct cachestat_range { 45 + __u64 off; 46 + __u64 len; 47 + }; 48 + 49 + struct cachestat { 50 + __u64 nr_cache; 51 + __u64 nr_dirty; 52 + __u64 nr_writeback; 53 + __u64 nr_evicted; 54 + __u64 nr_recently_evicted; 55 + }; 44 56 45 57 #endif /* _UAPI_LINUX_MMAN_H */
+2 -1
tools/include/uapi/linux/mount.h
··· 74 74 #define MOVE_MOUNT_T_AUTOMOUNTS 0x00000020 /* Follow automounts on to path */ 75 75 #define MOVE_MOUNT_T_EMPTY_PATH 0x00000040 /* Empty to path permitted */ 76 76 #define MOVE_MOUNT_SET_GROUP 0x00000100 /* Set sharing group instead */ 77 - #define MOVE_MOUNT__MASK 0x00000177 77 + #define MOVE_MOUNT_BENEATH 0x00000200 /* Mount beneath top mount */ 78 + #define MOVE_MOUNT__MASK 0x00000377 78 79 79 80 /* 80 81 * fsopen() flags.
+11
tools/include/uapi/linux/prctl.h
··· 294 294 295 295 #define PR_SET_MEMORY_MERGE 67 296 296 #define PR_GET_MEMORY_MERGE 68 297 + 298 + #define PR_RISCV_V_SET_CONTROL 69 299 + #define PR_RISCV_V_GET_CONTROL 70 300 + # define PR_RISCV_V_VSTATE_CTRL_DEFAULT 0 301 + # define PR_RISCV_V_VSTATE_CTRL_OFF 1 302 + # define PR_RISCV_V_VSTATE_CTRL_ON 2 303 + # define PR_RISCV_V_VSTATE_CTRL_INHERIT (1 << 4) 304 + # define PR_RISCV_V_VSTATE_CTRL_CUR_MASK 0x3 305 + # define PR_RISCV_V_VSTATE_CTRL_NEXT_MASK 0xc 306 + # define PR_RISCV_V_VSTATE_CTRL_MASK 0x1f 307 + 297 308 #endif /* _LINUX_PRCTL_H */
+31
tools/include/uapi/linux/vhost.h
··· 45 45 #define VHOST_SET_LOG_BASE _IOW(VHOST_VIRTIO, 0x04, __u64) 46 46 /* Specify an eventfd file descriptor to signal on log write. */ 47 47 #define VHOST_SET_LOG_FD _IOW(VHOST_VIRTIO, 0x07, int) 48 + /* By default, a device gets one vhost_worker that its virtqueues share. This 49 + * command allows the owner of the device to create an additional vhost_worker 50 + * for the device. It can later be bound to 1 or more of its virtqueues using 51 + * the VHOST_ATTACH_VRING_WORKER command. 52 + * 53 + * This must be called after VHOST_SET_OWNER and the caller must be the owner 54 + * of the device. The new thread will inherit caller's cgroups and namespaces, 55 + * and will share the caller's memory space. The new thread will also be 56 + * counted against the caller's RLIMIT_NPROC value. 57 + * 58 + * The worker's ID used in other commands will be returned in 59 + * vhost_worker_state. 60 + */ 61 + #define VHOST_NEW_WORKER _IOR(VHOST_VIRTIO, 0x8, struct vhost_worker_state) 62 + /* Free a worker created with VHOST_NEW_WORKER if it's not attached to any 63 + * virtqueue. If userspace is not able to call this for workers its created, 64 + * the kernel will free all the device's workers when the device is closed. 65 + */ 66 + #define VHOST_FREE_WORKER _IOW(VHOST_VIRTIO, 0x9, struct vhost_worker_state) 48 67 49 68 /* Ring setup. */ 50 69 /* Set number of descriptors in ring. This parameter can not ··· 89 70 #define VHOST_VRING_BIG_ENDIAN 1 90 71 #define VHOST_SET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x13, struct vhost_vring_state) 91 72 #define VHOST_GET_VRING_ENDIAN _IOW(VHOST_VIRTIO, 0x14, struct vhost_vring_state) 73 + /* Attach a vhost_worker created with VHOST_NEW_WORKER to one of the device's 74 + * virtqueues. 75 + * 76 + * This will replace the virtqueue's existing worker. If the replaced worker 77 + * is no longer attached to any virtqueues, it can be freed with 78 + * VHOST_FREE_WORKER. 79 + */ 80 + #define VHOST_ATTACH_VRING_WORKER _IOW(VHOST_VIRTIO, 0x15, \ 81 + struct vhost_vring_worker) 82 + /* Return the vring worker's ID */ 83 + #define VHOST_GET_VRING_WORKER _IOWR(VHOST_VIRTIO, 0x16, \ 84 + struct vhost_vring_worker) 92 85 93 86 /* The following ioctls use eventfd file descriptors to signal and poll 94 87 * for events. */
+79 -2
tools/include/uapi/sound/asound.h
··· 274 274 #define SNDRV_PCM_INFO_DOUBLE 0x00000004 /* Double buffering needed for PCM start/stop */ 275 275 #define SNDRV_PCM_INFO_BATCH 0x00000010 /* double buffering */ 276 276 #define SNDRV_PCM_INFO_SYNC_APPLPTR 0x00000020 /* need the explicit sync of appl_ptr update */ 277 + #define SNDRV_PCM_INFO_PERFECT_DRAIN 0x00000040 /* silencing at the end of stream is not required */ 277 278 #define SNDRV_PCM_INFO_INTERLEAVED 0x00000100 /* channels are interleaved */ 278 279 #define SNDRV_PCM_INFO_NONINTERLEAVED 0x00000200 /* channels are not interleaved */ 279 280 #define SNDRV_PCM_INFO_COMPLEX 0x00000400 /* complex frame organization (mmap only) */ ··· 384 383 #define SNDRV_PCM_HW_PARAMS_NORESAMPLE (1<<0) /* avoid rate resampling */ 385 384 #define SNDRV_PCM_HW_PARAMS_EXPORT_BUFFER (1<<1) /* export buffer */ 386 385 #define SNDRV_PCM_HW_PARAMS_NO_PERIOD_WAKEUP (1<<2) /* disable period wakeups */ 386 + #define SNDRV_PCM_HW_PARAMS_NO_DRAIN_SILENCE (1<<3) /* suppress drain with the filling 387 + * of the silence samples 388 + */ 387 389 388 390 struct snd_interval { 389 391 unsigned int min, max; ··· 712 708 * Raw MIDI section - /dev/snd/midi?? 713 709 */ 714 710 715 - #define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 2) 711 + #define SNDRV_RAWMIDI_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 4) 716 712 717 713 enum { 718 714 SNDRV_RAWMIDI_STREAM_OUTPUT = 0, ··· 723 719 #define SNDRV_RAWMIDI_INFO_OUTPUT 0x00000001 724 720 #define SNDRV_RAWMIDI_INFO_INPUT 0x00000002 725 721 #define SNDRV_RAWMIDI_INFO_DUPLEX 0x00000004 722 + #define SNDRV_RAWMIDI_INFO_UMP 0x00000008 726 723 727 724 struct snd_rawmidi_info { 728 725 unsigned int device; /* RO/WR (control): device number */ ··· 784 779 }; 785 780 #endif 786 781 782 + /* UMP EP info flags */ 783 + #define SNDRV_UMP_EP_INFO_STATIC_BLOCKS 0x01 784 + 785 + /* UMP EP Protocol / JRTS capability bits */ 786 + #define SNDRV_UMP_EP_INFO_PROTO_MIDI_MASK 0x0300 787 + #define SNDRV_UMP_EP_INFO_PROTO_MIDI1 0x0100 /* MIDI 1.0 */ 788 + #define SNDRV_UMP_EP_INFO_PROTO_MIDI2 0x0200 /* MIDI 2.0 */ 789 + #define SNDRV_UMP_EP_INFO_PROTO_JRTS_MASK 0x0003 790 + #define SNDRV_UMP_EP_INFO_PROTO_JRTS_TX 0x0001 /* JRTS Transmit */ 791 + #define SNDRV_UMP_EP_INFO_PROTO_JRTS_RX 0x0002 /* JRTS Receive */ 792 + 793 + /* UMP Endpoint information */ 794 + struct snd_ump_endpoint_info { 795 + int card; /* card number */ 796 + int device; /* device number */ 797 + unsigned int flags; /* additional info */ 798 + unsigned int protocol_caps; /* protocol capabilities */ 799 + unsigned int protocol; /* current protocol */ 800 + unsigned int num_blocks; /* # of function blocks */ 801 + unsigned short version; /* UMP major/minor version */ 802 + unsigned short family_id; /* MIDI device family ID */ 803 + unsigned short model_id; /* MIDI family model ID */ 804 + unsigned int manufacturer_id; /* MIDI manufacturer ID */ 805 + unsigned char sw_revision[4]; /* software revision */ 806 + unsigned short padding; 807 + unsigned char name[128]; /* endpoint name string */ 808 + unsigned char product_id[128]; /* unique product id string */ 809 + unsigned char reserved[32]; 810 + } __packed; 811 + 812 + /* UMP direction */ 813 + #define SNDRV_UMP_DIR_INPUT 0x01 814 + #define SNDRV_UMP_DIR_OUTPUT 0x02 815 + #define SNDRV_UMP_DIR_BIDIRECTION 0x03 816 + 817 + /* UMP block info flags */ 818 + #define SNDRV_UMP_BLOCK_IS_MIDI1 (1U << 0) /* MIDI 1.0 port w/o restrict */ 819 + #define SNDRV_UMP_BLOCK_IS_LOWSPEED (1U << 1) /* 31.25Kbps B/W MIDI1 port */ 820 + 821 + /* UMP block user-interface hint */ 822 + #define SNDRV_UMP_BLOCK_UI_HINT_UNKNOWN 0x00 823 + #define SNDRV_UMP_BLOCK_UI_HINT_RECEIVER 0x01 824 + #define SNDRV_UMP_BLOCK_UI_HINT_SENDER 0x02 825 + #define SNDRV_UMP_BLOCK_UI_HINT_BOTH 0x03 826 + 827 + /* UMP groups and blocks */ 828 + #define SNDRV_UMP_MAX_GROUPS 16 829 + #define SNDRV_UMP_MAX_BLOCKS 32 830 + 831 + /* UMP Block information */ 832 + struct snd_ump_block_info { 833 + int card; /* card number */ 834 + int device; /* device number */ 835 + unsigned char block_id; /* block ID (R/W) */ 836 + unsigned char direction; /* UMP direction */ 837 + unsigned char active; /* Activeness */ 838 + unsigned char first_group; /* first group ID */ 839 + unsigned char num_groups; /* number of groups */ 840 + unsigned char midi_ci_version; /* MIDI-CI support version */ 841 + unsigned char sysex8_streams; /* max number of sysex8 streams */ 842 + unsigned char ui_hint; /* user interface hint */ 843 + unsigned int flags; /* various info flags */ 844 + unsigned char name[128]; /* block name string */ 845 + unsigned char reserved[32]; 846 + } __packed; 847 + 787 848 #define SNDRV_RAWMIDI_IOCTL_PVERSION _IOR('W', 0x00, int) 788 849 #define SNDRV_RAWMIDI_IOCTL_INFO _IOR('W', 0x01, struct snd_rawmidi_info) 789 850 #define SNDRV_RAWMIDI_IOCTL_USER_PVERSION _IOW('W', 0x02, int) ··· 857 786 #define SNDRV_RAWMIDI_IOCTL_STATUS _IOWR('W', 0x20, struct snd_rawmidi_status) 858 787 #define SNDRV_RAWMIDI_IOCTL_DROP _IOW('W', 0x30, int) 859 788 #define SNDRV_RAWMIDI_IOCTL_DRAIN _IOW('W', 0x31, int) 789 + /* Additional ioctls for UMP rawmidi devices */ 790 + #define SNDRV_UMP_IOCTL_ENDPOINT_INFO _IOR('W', 0x40, struct snd_ump_endpoint_info) 791 + #define SNDRV_UMP_IOCTL_BLOCK_INFO _IOR('W', 0x41, struct snd_ump_block_info) 860 792 861 793 /* 862 794 * Timer section - /dev/snd/timer ··· 1035 961 * * 1036 962 ****************************************************************************/ 1037 963 1038 - #define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 8) 964 + #define SNDRV_CTL_VERSION SNDRV_PROTOCOL_VERSION(2, 0, 9) 1039 965 1040 966 struct snd_ctl_card_info { 1041 967 int card; /* card number */ ··· 1196 1122 #define SNDRV_CTL_IOCTL_RAWMIDI_NEXT_DEVICE _IOWR('U', 0x40, int) 1197 1123 #define SNDRV_CTL_IOCTL_RAWMIDI_INFO _IOWR('U', 0x41, struct snd_rawmidi_info) 1198 1124 #define SNDRV_CTL_IOCTL_RAWMIDI_PREFER_SUBDEVICE _IOW('U', 0x42, int) 1125 + #define SNDRV_CTL_IOCTL_UMP_NEXT_DEVICE _IOWR('U', 0x43, int) 1126 + #define SNDRV_CTL_IOCTL_UMP_ENDPOINT_INFO _IOWR('U', 0x44, struct snd_ump_endpoint_info) 1127 + #define SNDRV_CTL_IOCTL_UMP_BLOCK_INFO _IOWR('U', 0x45, struct snd_ump_block_info) 1199 1128 #define SNDRV_CTL_IOCTL_POWER _IOWR('U', 0xd0, int) 1200 1129 #define SNDRV_CTL_IOCTL_POWER_STATE _IOR('U', 0xd1, int) 1201 1130
+12 -6
tools/lib/subcmd/help.c
··· 68 68 while (ci < cmds->cnt && ei < excludes->cnt) { 69 69 cmp = strcmp(cmds->names[ci]->name, excludes->names[ei]->name); 70 70 if (cmp < 0) { 71 - zfree(&cmds->names[cj]); 72 - cmds->names[cj++] = cmds->names[ci++]; 71 + if (ci == cj) { 72 + ci++; 73 + cj++; 74 + } else { 75 + zfree(&cmds->names[cj]); 76 + cmds->names[cj++] = cmds->names[ci++]; 77 + } 73 78 } else if (cmp == 0) { 74 79 ci++; 75 80 ei++; ··· 82 77 ei++; 83 78 } 84 79 } 85 - 86 - while (ci < cmds->cnt) { 87 - zfree(&cmds->names[cj]); 88 - cmds->names[cj++] = cmds->names[ci++]; 80 + if (ci != cj) { 81 + while (ci < cmds->cnt) { 82 + zfree(&cmds->names[cj]); 83 + cmds->names[cj++] = cmds->names[ci++]; 84 + } 89 85 } 90 86 for (ci = cj; ci < cmds->cnt; ci++) 91 87 zfree(&cmds->names[ci]);
+1 -1
tools/objtool/elf.c
··· 1005 1005 perror("malloc"); 1006 1006 return NULL; 1007 1007 } 1008 - memset(elf, 0, offsetof(struct elf, sections)); 1008 + memset(elf, 0, sizeof(*elf)); 1009 1009 1010 1010 INIT_LIST_HEAD(&elf->sections); 1011 1011
+2 -2
tools/perf/Makefile.config
··· 155 155 ifdef CSINCLUDES 156 156 LIBOPENCSD_CFLAGS := -I$(CSINCLUDES) 157 157 endif 158 - OPENCSDLIBS := -lopencsd_c_api 158 + OPENCSDLIBS := -lopencsd_c_api -lopencsd 159 159 ifeq ($(findstring -static,${LDFLAGS}),-static) 160 - OPENCSDLIBS += -lopencsd -lstdc++ 160 + OPENCSDLIBS += -lstdc++ 161 161 endif 162 162 ifdef CSLIBS 163 163 LIBOPENCSD_LDFLAGS := -L$(CSLIBS)
+1
tools/perf/arch/mips/entry/syscalls/syscall_n64.tbl
··· 365 365 448 n64 process_mrelease sys_process_mrelease 366 366 449 n64 futex_waitv sys_futex_waitv 367 367 450 common set_mempolicy_home_node sys_set_mempolicy_home_node 368 + 451 n64 cachestat sys_cachestat
+1
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl
··· 537 537 448 common process_mrelease sys_process_mrelease 538 538 449 common futex_waitv sys_futex_waitv 539 539 450 nospu set_mempolicy_home_node sys_set_mempolicy_home_node 540 + 451 common cachestat sys_cachestat
+1
tools/perf/arch/s390/entry/syscalls/syscall.tbl
··· 453 453 448 common process_mrelease sys_process_mrelease sys_process_mrelease 454 454 449 common futex_waitv sys_futex_waitv sys_futex_waitv 455 455 450 common set_mempolicy_home_node sys_set_mempolicy_home_node sys_set_mempolicy_home_node 456 + 451 common cachestat sys_cachestat sys_cachestat
+1
tools/perf/arch/x86/entry/syscalls/syscall_64.tbl
··· 372 372 448 common process_mrelease sys_process_mrelease 373 373 449 common futex_waitv sys_futex_waitv 374 374 450 common set_mempolicy_home_node sys_set_mempolicy_home_node 375 + 451 common cachestat sys_cachestat 375 376 376 377 # 377 378 # Due to a historical design error, certain syscalls are numbered differently
+2 -1
tools/perf/pmu-events/arch/x86/amdzen1/recommended.json
··· 169 169 }, 170 170 { 171 171 "MetricName": "nps1_die_to_dram", 172 - "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die) (may need --metric-no-group)", 172 + "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die)", 173 173 "MetricExpr": "dram_channel_data_controller_0 + dram_channel_data_controller_1 + dram_channel_data_controller_2 + dram_channel_data_controller_3 + dram_channel_data_controller_4 + dram_channel_data_controller_5 + dram_channel_data_controller_6 + dram_channel_data_controller_7", 174 + "MetricConstraint": "NO_GROUP_EVENTS", 174 175 "MetricGroup": "data_fabric", 175 176 "PerPkg": "1", 176 177 "ScaleUnit": "6.1e-5MiB"
+2 -1
tools/perf/pmu-events/arch/x86/amdzen2/recommended.json
··· 169 169 }, 170 170 { 171 171 "MetricName": "nps1_die_to_dram", 172 - "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die) (may need --metric-no-group)", 172 + "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die)", 173 173 "MetricExpr": "dram_channel_data_controller_0 + dram_channel_data_controller_1 + dram_channel_data_controller_2 + dram_channel_data_controller_3 + dram_channel_data_controller_4 + dram_channel_data_controller_5 + dram_channel_data_controller_6 + dram_channel_data_controller_7", 174 + "MetricConstraint": "NO_GROUP_EVENTS", 174 175 "MetricGroup": "data_fabric", 175 176 "PerPkg": "1", 176 177 "ScaleUnit": "6.1e-5MiB"
+2 -1
tools/perf/pmu-events/arch/x86/amdzen3/recommended.json
··· 205 205 }, 206 206 { 207 207 "MetricName": "nps1_die_to_dram", 208 - "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die) (may need --metric-no-group)", 208 + "BriefDescription": "Approximate: Combined DRAM B/bytes of all channels on a NPS1 node (die)", 209 209 "MetricExpr": "dram_channel_data_controller_0 + dram_channel_data_controller_1 + dram_channel_data_controller_2 + dram_channel_data_controller_3 + dram_channel_data_controller_4 + dram_channel_data_controller_5 + dram_channel_data_controller_6 + dram_channel_data_controller_7", 210 210 "MetricGroup": "data_fabric", 211 211 "PerPkg": "1", 212 + "MetricConstraint": "NO_GROUP_EVENTS", 212 213 "ScaleUnit": "6.1e-5MiB" 213 214 } 214 215 ]
+77
tools/perf/tests/shell/test_uprobe_from_different_cu.sh
··· 1 + #!/bin/bash 2 + # test perf probe of function from different CU 3 + # SPDX-License-Identifier: GPL-2.0 4 + 5 + set -e 6 + 7 + temp_dir=$(mktemp -d /tmp/perf-uprobe-different-cu-sh.XXXXXXXXXX) 8 + 9 + cleanup() 10 + { 11 + trap - EXIT TERM INT 12 + if [[ "${temp_dir}" =~ ^/tmp/perf-uprobe-different-cu-sh.*$ ]]; then 13 + echo "--- Cleaning up ---" 14 + perf probe -x ${temp_dir}/testfile -d foo 15 + rm -f "${temp_dir}/"* 16 + rmdir "${temp_dir}" 17 + fi 18 + } 19 + 20 + trap_cleanup() 21 + { 22 + cleanup 23 + exit 1 24 + } 25 + 26 + trap trap_cleanup EXIT TERM INT 27 + 28 + cat > ${temp_dir}/testfile-foo.h << EOF 29 + struct t 30 + { 31 + int *p; 32 + int c; 33 + }; 34 + 35 + extern int foo (int i, struct t *t); 36 + EOF 37 + 38 + cat > ${temp_dir}/testfile-foo.c << EOF 39 + #include "testfile-foo.h" 40 + 41 + int 42 + foo (int i, struct t *t) 43 + { 44 + int j, res = 0; 45 + for (j = 0; j < i && j < t->c; j++) 46 + res += t->p[j]; 47 + 48 + return res; 49 + } 50 + EOF 51 + 52 + cat > ${temp_dir}/testfile-main.c << EOF 53 + #include "testfile-foo.h" 54 + 55 + static struct t g; 56 + 57 + int 58 + main (int argc, char **argv) 59 + { 60 + int i; 61 + int j[argc]; 62 + g.c = argc; 63 + g.p = j; 64 + for (i = 0; i < argc; i++) 65 + j[i] = (int) argv[i][0]; 66 + return foo (3, &g); 67 + } 68 + EOF 69 + 70 + gcc -g -Og -flto -c ${temp_dir}/testfile-foo.c -o ${temp_dir}/testfile-foo.o 71 + gcc -g -Og -c ${temp_dir}/testfile-main.c -o ${temp_dir}/testfile-main.o 72 + gcc -g -Og -o ${temp_dir}/testfile ${temp_dir}/testfile-foo.o ${temp_dir}/testfile-main.o 73 + 74 + perf probe -x ${temp_dir}/testfile --funcs foo 75 + perf probe -x ${temp_dir}/testfile foo 76 + 77 + cleanup
+2 -2
tools/perf/tests/task-exit.c
··· 58 58 59 59 signal(SIGCHLD, sig_handler); 60 60 61 - evlist = evlist__new_default(); 61 + evlist = evlist__new_dummy(); 62 62 if (evlist == NULL) { 63 - pr_debug("evlist__new_default\n"); 63 + pr_debug("evlist__new_dummy\n"); 64 64 return -1; 65 65 } 66 66
+5
tools/perf/trace/beauty/include/linux/socket.h
··· 177 177 #define SCM_RIGHTS 0x01 /* rw: access rights (array of int) */ 178 178 #define SCM_CREDENTIALS 0x02 /* rw: struct ucred */ 179 179 #define SCM_SECURITY 0x03 /* rw: security label */ 180 + #define SCM_PIDFD 0x04 /* ro: pidfd (int) */ 180 181 181 182 struct ucred { 182 183 __u32 pid; ··· 327 326 */ 328 327 329 328 #define MSG_ZEROCOPY 0x4000000 /* Use user data in kernel path */ 329 + #define MSG_SPLICE_PAGES 0x8000000 /* Splice the pages from the iterator in sendmsg() */ 330 330 #define MSG_FASTOPEN 0x20000000 /* Send data in TCP SYN */ 331 331 #define MSG_CMSG_CLOEXEC 0x40000000 /* Set close_on_exec for file 332 332 descriptor received through ··· 338 336 #define MSG_CMSG_COMPAT 0 /* We never have 32 bit fixups */ 339 337 #endif 340 338 339 + /* Flags to be cleared on entry by sendmsg and sendmmsg syscalls */ 340 + #define MSG_INTERNAL_SENDMSG_FLAGS \ 341 + (MSG_SPLICE_PAGES | MSG_SENDPAGE_NOPOLICY | MSG_SENDPAGE_DECRYPTED) 341 342 342 343 /* Setsockoptions(2) level. Thanks to BSD these must match IPPROTO_xxx */ 343 344 #define SOL_IP 0
+1 -1
tools/perf/trace/beauty/move_mount_flags.sh
··· 10 10 linux_mount=${linux_header_dir}/mount.h 11 11 12 12 printf "static const char *move_mount_flags[] = {\n" 13 - regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MOVE_MOUNT_([^_]+_[[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' 13 + regex='^[[:space:]]*#[[:space:]]*define[[:space:]]+MOVE_MOUNT_([^_]+[[:alnum:]_]+)[[:space:]]+(0x[[:xdigit:]]+)[[:space:]]*.*' 14 14 grep -E $regex ${linux_mount} | \ 15 15 sed -r "s/$regex/\2 \1/g" | \ 16 16 xargs printf "\t[ilog2(%s) + 1] = \"%s\",\n"
+8
tools/perf/trace/beauty/msg_flags.c
··· 8 8 #ifndef MSG_WAITFORONE 9 9 #define MSG_WAITFORONE 0x10000 10 10 #endif 11 + #ifndef MSG_BATCH 12 + #define MSG_BATCH 0x40000 13 + #endif 14 + #ifndef MSG_ZEROCOPY 15 + #define MSG_ZEROCOPY 0x4000000 16 + #endif 11 17 #ifndef MSG_SPLICE_PAGES 12 18 #define MSG_SPLICE_PAGES 0x8000000 13 19 #endif ··· 56 50 P_MSG_FLAG(NOSIGNAL); 57 51 P_MSG_FLAG(MORE); 58 52 P_MSG_FLAG(WAITFORONE); 53 + P_MSG_FLAG(BATCH); 54 + P_MSG_FLAG(ZEROCOPY); 59 55 P_MSG_FLAG(SPLICE_PAGES); 60 56 P_MSG_FLAG(FASTOPEN); 61 57 P_MSG_FLAG(CMSG_CLOEXEC);
+3 -1
tools/perf/util/dwarf-aux.c
··· 478 478 { 479 479 Dwarf_Die cu_die; 480 480 Dwarf_Files *files; 481 + Dwarf_Attribute attr_mem; 481 482 482 - if (idx < 0 || !dwarf_diecu(dw_die, &cu_die, NULL, NULL) || 483 + if (idx < 0 || !dwarf_attr_integrate(dw_die, DW_AT_decl_file, &attr_mem) || 484 + !dwarf_cu_die(attr_mem.cu, &cu_die, NULL, NULL, NULL, NULL, NULL, NULL) || 483 485 dwarf_getsrcfiles(&cu_die, &files, NULL) != 0) 484 486 return NULL; 485 487
+8
tools/perf/util/parse-events.c
··· 1216 1216 if (term->type_term == PARSE_EVENTS__TERM_TYPE_LEGACY_CACHE) { 1217 1217 const struct perf_pmu *pmu = perf_pmus__find_by_type(attr->type); 1218 1218 1219 + if (!pmu) { 1220 + char *err_str; 1221 + 1222 + if (asprintf(&err_str, "Failed to find PMU for type %d", attr->type) >= 0) 1223 + parse_events_error__handle(err, term->err_term, 1224 + err_str, /*help=*/NULL); 1225 + return -EINVAL; 1226 + } 1219 1227 if (perf_pmu__supports_legacy_cache(pmu)) { 1220 1228 attr->type = PERF_TYPE_HW_CACHE; 1221 1229 return parse_events__decode_legacy_cache(term->config, pmu->type,
+3 -3
tools/testing/radix-tree/maple.c
··· 206 206 e = i - 1; 207 207 } else { 208 208 if (i >= 4) 209 - e = i - 4; 210 - else if (i == 3) 211 - e = i - 2; 209 + e = i - 3; 210 + else if (i >= 1) 211 + e = i - 1; 212 212 else 213 213 e = 0; 214 214 }
+1 -1
tools/testing/selftests/arm64/Makefile
··· 42 42 done 43 43 44 44 # Avoid any output on non arm64 on emit_tests 45 - emit_tests: all 45 + emit_tests: 46 46 @for DIR in $(ARM64_SUBTARGETS); do \ 47 47 BUILD_TARGET=$(OUTPUT)/$$DIR; \ 48 48 make OUTPUT=$$BUILD_TARGET -C $$DIR $@; \
+23 -2
tools/testing/selftests/bpf/progs/async_stack_depth.c
··· 22 22 return buf[69]; 23 23 } 24 24 25 + __attribute__((noinline)) 26 + static int bad_timer_cb(void *map, int *key, struct bpf_timer *timer) 27 + { 28 + volatile char buf[300] = {}; 29 + return buf[255] + timer_cb(NULL, NULL, NULL); 30 + } 31 + 25 32 SEC("tc") 26 - __failure __msg("combined stack size of 2 calls") 27 - int prog(struct __sk_buff *ctx) 33 + __failure __msg("combined stack size of 2 calls is 576. Too large") 34 + int pseudo_call_check(struct __sk_buff *ctx) 28 35 { 29 36 struct hmap_elem *elem; 30 37 volatile char buf[256] = {}; ··· 42 35 43 36 timer_cb(NULL, NULL, NULL); 44 37 return bpf_timer_set_callback(&elem->timer, timer_cb) + buf[0]; 38 + } 39 + 40 + SEC("tc") 41 + __failure __msg("combined stack size of 2 calls is 608. Too large") 42 + int async_call_root_check(struct __sk_buff *ctx) 43 + { 44 + struct hmap_elem *elem; 45 + volatile char buf[256] = {}; 46 + 47 + elem = bpf_map_lookup_elem(&hmap, &(int){0}); 48 + if (!elem) 49 + return 0; 50 + 51 + return bpf_timer_set_callback(&elem->timer, bad_timer_cb) + buf[0]; 45 52 } 46 53 47 54 char _license[] SEC("license") = "GPL";
+2 -2
tools/testing/selftests/mincore/mincore_selftest.c
··· 150 150 MAP_PRIVATE | MAP_ANONYMOUS | MAP_HUGETLB, 151 151 -1, 0); 152 152 if (addr == MAP_FAILED) { 153 - if (errno == ENOMEM) 154 - SKIP(return, "No huge pages available."); 153 + if (errno == ENOMEM || errno == EINVAL) 154 + SKIP(return, "No huge pages available or CONFIG_HUGETLB_PAGE disabled."); 155 155 else 156 156 TH_LOG("mmap error: %s", strerror(errno)); 157 157 }
tools/testing/selftests/mm/charge_reserved_hugetlb.sh
tools/testing/selftests/mm/check_config.sh
tools/testing/selftests/mm/hugetlb_reparenting_test.sh
+1 -1
tools/testing/selftests/mm/mkdirty.c
··· 321 321 munmap: 322 322 munmap(dst, pagesize); 323 323 free(src); 324 - #endif /* __NR_userfaultfd */ 325 324 } 325 + #endif /* __NR_userfaultfd */ 326 326 327 327 int main(void) 328 328 {
tools/testing/selftests/mm/run_vmtests.sh
tools/testing/selftests/mm/test_hmm.sh
tools/testing/selftests/mm/test_vmalloc.sh
tools/testing/selftests/mm/va_high_addr_switch.sh
tools/testing/selftests/mm/write_hugetlb_memory.sh
+1 -1
tools/testing/selftests/riscv/Makefile
··· 43 43 done 44 44 45 45 # Avoid any output on non riscv on emit_tests 46 - emit_tests: all 46 + emit_tests: 47 47 @for DIR in $(RISCV_SUBTARGETS); do \ 48 48 BUILD_TARGET=$(OUTPUT)/$$DIR; \ 49 49 $(MAKE) OUTPUT=$$BUILD_TARGET -C $$DIR $@; \
+2
tools/testing/selftests/tc-testing/config
··· 5 5 CONFIG_NF_CONNTRACK_MARK=y 6 6 CONFIG_NF_CONNTRACK_ZONES=y 7 7 CONFIG_NF_CONNTRACK_LABELS=y 8 + CONFIG_NF_CONNTRACK_PROCFS=y 9 + CONFIG_NF_FLOW_TABLE=m 8 10 CONFIG_NF_NAT=m 9 11 CONFIG_NETFILTER_XT_TARGET_LOG=m 10 12
+1
tools/testing/selftests/tc-testing/settings
··· 1 + timeout=900
+1 -2
tools/testing/selftests/timers/raw_skew.c
··· 129 129 printf("%lld.%i(est)", eppm/1000, abs((int)(eppm%1000))); 130 130 131 131 /* Avg the two actual freq samples adjtimex gave us */ 132 - ppm = (tx1.freq + tx2.freq) * 1000 / 2; 133 - ppm = (long long)tx1.freq * 1000; 132 + ppm = (long long)(tx1.freq + tx2.freq) * 1000 / 2; 134 133 ppm = shift_right(ppm, 16); 135 134 printf(" %lld.%i(act)", ppm/1000, abs((int)(ppm%1000))); 136 135