Compare

4766082b791b515953d87f7a24c2ea857e6c10b0..c03c1a14507dfaf8b856c2608f9ac216021fc222

Linux 7.3

Linus Torvalds <torvalds@linux-foundation.org> · 2026-10-18 23:14 UTC

Browse files
82 files changed, +706 −325
modified MAINTAINERS
@@ -8013,6 +8013,7 @@ F: include/uapi/drm/ivpu_accel.h
8013 8013
8014 8014 DRM ACCEL DRIVER FOR ROCKCHIP NPU
8015 8015 M: Tomeu Vizoso <tomeu@tomeuvizoso.net>
8016 + R: Heiko Stuebner <heiko@sntech.de>
8016 8017 L: dri-devel@lists.freedesktop.org
8017 8018 S: Supported
8018 8019 T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
@@ -8574,7 +8575,7 @@ F: Documentation/devicetree/bindings/display/panel/synaptics,r63353.yaml
8574 8575 F: drivers/gpu/drm/panel/panel-synaptics-r63353.c
8575 8576
8576 8577 DRM DRIVER FOR SYNOPSYS DESIGNWARE DISPLAYPORT BRIDGE
8577 - M: Andy Yan <andy.yan@rock-chips.com>
8578 + M: Andy Yan <andyshrk@163.com>
8578 8579 S: Maintained
8579 8580 T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
8580 8581 F: Documentation/devicetree/bindings/display/rockchip/rockchip,dw-dp.yaml
@@ -8927,7 +8928,7 @@ F: include/linux/platform_data/shmob_drm.h
8927 8928 DRM DRIVERS FOR ROCKCHIP
8928 8929 M: Sandy Huang <hjc@rock-chips.com>
8929 8930 M: Heiko Stübner <heiko@sntech.de>
8930 - M: Andy Yan <andy.yan@rock-chips.com>
8931 + M: Andy Yan <andyshrk@163.com>
8931 8932 L: dri-devel@lists.freedesktop.org
8932 8933 L: linux-rockchip@lists.infradead.org
8933 8934 S: Maintained
@@ -12879,7 +12880,7 @@ S: Maintained
12879 12880 F: drivers/power/supply/ip5xxx_power.c
12880 12881
12881 12882 INNOSILICON HDMI BRIDGE DRIVER
12882 - M: Andy Yan <andy.yan@rock-chips.com>
12883 + M: Andy Yan <andyshrk@163.com>
12883 12884 L: dri-devel@lists.freedesktop.org
12884 12885 S: Maintained
12885 12886 T: git https://gitlab.freedesktop.org/drm/misc/kernel.git
modified Makefile
@@ -2,7 +2,7 @@
2 2 VERSION = 7
3 3 PATCHLEVEL = 3
4 4 SUBLEVEL = 0
5 - EXTRAVERSION = -rc7
5 + EXTRAVERSION =
6 6 NAME = Baby Opossum Posse
7 7
8 8 # *DOCUMENTATION*
modified arch/x86/events/intel/uncore_snbep.c
@@ -474,6 +474,9 @@
474 474 /* DMR */
475 475 #define DMR_IMH1_HIOP_MMIO_BASE 0x1ffff6ae7000
476 476 #define DMR_HIOP_MMIO_SIZE 0x8000
477 + #define DMR_CXLCM_PMON_CTL_INVERT BIT(21)
478 + #define DMR_CXLCM_PMON_RAW_EVENT_MASK (GENERIC_PMON_RAW_EVENT_MASK | \
479 + DMR_CXLCM_PMON_CTL_INVERT)
477 480 #define DMR_CXLCM_EVENT_MASK_EXT 0xf
478 481 #define DMR_HAMVF_EVENT_MASK_EXT 0xffffffff
479 482 #define DMR_PCIE4_EVENT_MASK_EXT 0xffffff
@@ -6696,7 +6699,7 @@ static struct event_constraint dmr_uncore_cxlcm_constraints[] = {
6696 6699
6697 6700 static struct intel_uncore_type dmr_uncore_cxlcm = {
6698 6701 .name = "cxlcm",
6699 - .event_mask = GENERIC_PMON_RAW_EVENT_MASK,
6702 + .event_mask = DMR_CXLCM_PMON_RAW_EVENT_MASK,
6700 6703 .event_mask_ext = DMR_CXLCM_EVENT_MASK_EXT,
6701 6704 .constraints = dmr_uncore_cxlcm_constraints,
6702 6705 .format_group = &dmr_cxlcm_uncore_format_group,
modified arch/x86/include/asm/insn.h
@@ -321,7 +321,7 @@ static inline int insn_offset_immediate(struct insn *insn)
321 321 * are repeated, it cannot be used for looping over the prefixes.
322 322 */
323 323 #define for_each_insn_prefix(insn, prefix) \
324 - for (int idx = 0; idx < ARRAY_SIZE(insn->prefixes.bytes) && (prefix = insn->prefixes.bytes[idx]) != 0; idx++)
324 + for (int __i = 0; __i < ARRAY_SIZE(insn->prefixes.bytes) && (prefix = insn->prefixes.bytes[__i]) != 0; __i++)
325 325
326 326 #define POP_SS_OPCODE 0x1f
327 327 #define MOV_SREG_OPCODE 0x8e
modified arch/x86/kernel/alternative.c
@@ -1455,7 +1455,8 @@ asm( ".pushsection .rodata \n"
1455 1455 "fineibt_paranoid_start: \n"
1456 1456 " mov $0x12345678, %eax \n"
1457 1457 " cmpl -11(%r11), %eax \n"
1458 - " cs lea -0x10(%r11), %r11 \n"
1458 + " .byte 0x2e \n"
1459 + " lea -0x10(%r11), %r11 \n"
1459 1460 "#fineibt_caller_size: \n"
1460 1461 " jne fineibt_paranoid_start+0xd \n"
1461 1462 "fineibt_paranoid_ind: \n"
modified arch/x86/kernel/cfi.c
@@ -10,11 +10,11 @@
10 10 #include <asm/insn-eval.h>
11 11
12 12 /*
13 - * Returns the target address and the expected type when regs->ip points
13 + * Returns the target address and the expected type when addr points
14 14 * to a compiler-generated CFI trap.
15 15 */
16 - static bool decode_cfi_insn(struct pt_regs *regs, unsigned long *target,
17 - u32 *type)
16 + static bool decode_cfi_insn(struct pt_regs *regs, unsigned long addr,
17 + unsigned long *target, u32 *type)
18 18 {
19 19 char buffer[MAX_INSN_SIZE];
20 20 struct insn insn;
@@ -29,13 +29,13 @@ static bool decode_cfi_insn(struct pt_regs *regs, unsigned long *target,
29 29 *   movl -<id>, %r10d ; 6 bytes
30 30 * addl -<pos>(%reg), %r10d; 4 bytes
31 31 * je .Ltmp1 ; 2 bytes
32 - * ud2 ; <- regs->ip
32 + * ud2 ; <- addr
33 33 * .Ltmp1:
34 34 *
35 35 * We can decode the expected type and the target address from the
36 36 * movl/addl instructions.
37 37 */
38 - if (copy_from_kernel_nofault(buffer, (void *)regs->ip - 12, MAX_INSN_SIZE))
38 + if (copy_from_kernel_nofault(buffer, (void *)addr - 12, MAX_INSN_SIZE))
39 39 return false;
40 40 if (insn_decode_kernel(&insn, &buffer[offset]))
41 41 return false;
@@ -44,7 +44,7 @@ static bool decode_cfi_insn(struct pt_regs *regs, unsigned long *target,
44 44
45 45 *type = -(u32)insn.immediate.value;
46 46
47 - if (copy_from_kernel_nofault(buffer, (void *)regs->ip - 6, MAX_INSN_SIZE))
47 + if (copy_from_kernel_nofault(buffer, (void *)addr - 6, MAX_INSN_SIZE))
48 48 return false;
49 49 if (insn_decode_kernel(&insn, &buffer[offset]))
50 50 return false;
@@ -82,7 +82,7 @@ enum bug_trap_type handle_cfi_failure(struct pt_regs *regs)
82 82 return BUG_TRAP_TYPE_NONE;
83 83 }
84 84
85 - if (!decode_cfi_insn(regs, &target, &type))
85 + if (!decode_cfi_insn(regs, addr, &target, &type))
86 86 return report_cfi_failure_noaddr(regs, addr);
87 87
88 88 break;
modified block/bsg-lib.c
@@ -23,11 +23,14 @@ struct bsg_set {
23 23 struct bsg_device *bd;
24 24 bsg_job_fn *job_fn;
25 25 bsg_timeout_fn *timeout_fn;
26 + unsigned int reply_len;
26 27 };
27 28
28 29 static int bsg_transport_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
29 30 bool open_for_write, unsigned int timeout)
30 31 {
32 + struct bsg_set *bset =
33 + container_of(q->tag_set, struct bsg_set, tag_set);
31 34 struct bsg_job *job;
32 35 struct request *rq;
33 36 struct bio *bio;
@@ -50,7 +53,7 @@ static int bsg_transport_sg_io_fn(struct request_queue *q, struct sg_io_v4 *hdr,
50 53 reply = job->reply;
51 54 memset(job, 0, sizeof(*job));
52 55 job->reply = reply;
53 - job->reply_len = SCSI_SENSE_BUFFERSIZE;
56 + job->reply_len = bset->reply_len;
54 57 job->dd_data = job + 1;
55 58
56 59 job->request_len = hdr->request_len;
@@ -301,9 +304,10 @@ out:
301 304 static int bsg_init_rq(struct blk_mq_tag_set *set, struct request *req,
302 305 unsigned int hctx_idx, int numa_node)
303 306 {
307 + struct bsg_set *bset = container_of(set, struct bsg_set, tag_set);
304 308 struct bsg_job *job = blk_mq_rq_to_pdu(req);
305 309
306 - job->reply = kzalloc(SCSI_SENSE_BUFFERSIZE, GFP_KERNEL);
310 + job->reply = kzalloc(bset->reply_len, GFP_KERNEL);
307 311 if (!job->reply)
308 312 return -ENOMEM;
309 313 return 0;
@@ -358,10 +362,12 @@ static const struct blk_mq_ops bsg_mq_ops = {
358 362 * @job_fn: bsg job handler
359 363 * @timeout: timeout handler function pointer
360 364 * @dd_job_size: size of LLD data needed for each job
365 + * @reply_len: size of the reply buffer needed for each job
361 366 */
362 367 struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
363 368 struct queue_limits *lim, bsg_job_fn *job_fn,
364 - bsg_timeout_fn *timeout, int dd_job_size)
369 + bsg_timeout_fn *timeout, int dd_job_size,
370 + unsigned int reply_len)
365 371 {
366 372 struct bsg_set *bset;
367 373 struct blk_mq_tag_set *set;
@@ -374,6 +380,7 @@ struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
374 380
375 381 bset->job_fn = job_fn;
376 382 bset->timeout_fn = timeout;
383 + bset->reply_len = reply_len;
377 384
378 385 set = &bset->tag_set;
379 386 set->ops = &bsg_mq_ops;
modified drivers/accel/amdxdna/Kconfig
@@ -6,6 +6,7 @@ config DRM_ACCEL_AMDXDNA
6 6 depends on DRM_ACCEL
7 7 depends on PCI && HAS_IOMEM
8 8 depends on X86_64
9 + depends on AMD_PMF || !AMD_PMF
9 10 select DRM_SCHED
10 11 select DRM_GEM_SHMEM_HELPER
11 12 select FW_LOADER
modified drivers/accel/rocket/rocket_device.c
@@ -31,6 +31,8 @@ struct rocket_device *rocket_device_init(struct platform_device *pdev,
31 31 if (of_device_is_available(core_node))
32 32 num_cores++;
33 33
34 + rdev->max_cores = num_cores;
35 +
34 36 rdev->cores = devm_kcalloc(dev, num_cores, sizeof(*rdev->cores), GFP_KERNEL);
35 37 if (!rdev->cores)
36 38 return ERR_PTR(-ENOMEM);
modified drivers/accel/rocket/rocket_device.h
@@ -19,6 +19,7 @@ struct rocket_device {
19 19
20 20 struct rocket_core *cores;
21 21 unsigned int num_cores;
22 + unsigned int max_cores;
22 23 };
23 24
24 25 struct rocket_device *rocket_device_init(struct platform_device *pdev,
modified drivers/accel/rocket/rocket_drv.c
@@ -165,8 +165,11 @@ static int rocket_probe(struct platform_device *pdev)
165 165 /* First core probing, initialize DRM device. */
166 166 rdev = rocket_device_init(drm_dev, &rocket_drm_driver);
167 167 if (IS_ERR(rdev)) {
168 + int err = PTR_ERR(rdev);
169 +
168 170 dev_err(&pdev->dev, "failed to initialize rocket device\n");
169 - return PTR_ERR(rdev);
171 + rdev = NULL;
172 + return err;
170 173 }
171 174 }
172 175
@@ -223,7 +226,7 @@ static int find_core_for_dev(struct device *dev)
223 226 {
224 227 struct rocket_device *rdev = dev_get_drvdata(dev);
225 228
226 - for (unsigned int core = 0; core < rdev->num_cores; core++) {
229 + for (unsigned int core = 0; core < rdev->max_cores; core++) {
227 230 if (dev == rdev->cores[core].dev)
228 231 return core;
229 232 }
modified drivers/accel/rocket/rocket_job.c
@@ -283,7 +283,7 @@ static struct rocket_core *sched_to_core(struct rocket_device *rdev,
283 283 {
284 284 unsigned int core;
285 285
286 - for (core = 0; core < rdev->num_cores; core++) {
286 + for (core = 0; core < rdev->max_cores; core++) {
287 287 if (&rdev->cores[core].sched == sched)
288 288 return &rdev->cores[core];
289 289 }
modified drivers/base/regmap/regcache-maple.c
@@ -312,16 +312,21 @@ static void regcache_maple_exit(struct regmap *map)
312 312 struct maple_tree *mt = map->cache;
313 313 MA_STATE(mas, mt, 0, UINT_MAX);
314 314 unsigned int *entry;
315 + unsigned long flags;
315 316
316 317 /* if we've already been called then just return */
317 318 if (!mt)
318 319 return;
319 320
320 - mas_lock(&mas);
321 + /*
322 + * Register access may take the Maple lock from hard IRQ context, so
323 + * preserve its IRQ-safe lockdep state during teardown.
324 + */
325 + mas_lock_irqsave(&mas, flags);
321 326 mas_for_each(&mas, entry, UINT_MAX)
322 327 kfree(entry);
323 328 __mt_destroy(mt);
324 - mas_unlock(&mas);
329 + mas_unlock_irqrestore(&mas, flags);
325 330
326 331 kfree(mt);
327 332 map->cache = NULL;
modified drivers/base/regmap/regcache.c
@@ -225,9 +225,7 @@ int regcache_init(struct regmap *map, const struct regmap_config *config)
225 225 if (map->cache_ops->init) {
226 226 dev_dbg(map->dev, "Initializing %s cache\n",
227 227 map->cache_ops->name);
228 - map->lock(map->lock_arg);
229 228 ret = map->cache_ops->init(map);
230 - map->unlock(map->lock_arg);
231 229 if (ret)
232 230 goto err_free_reg_defaults;
233 231 }
@@ -259,9 +257,7 @@ err_free:
259 257 err_exit:
260 258 if (map->cache_ops->exit) {
261 259 dev_dbg(map->dev, "Destroying %s cache\n", map->cache_ops->name);
262 - map->lock(map->lock_arg);
263 260 map->cache_ops->exit(map);
264 - map->unlock(map->lock_arg);
265 261 }
266 262 err_free_reg_defaults:
267 263 kfree(map->reg_defaults);
@@ -281,9 +277,7 @@ void regcache_exit(struct regmap *map)
281 277 if (map->cache_ops->exit) {
282 278 dev_dbg(map->dev, "Destroying %s cache\n",
283 279 map->cache_ops->name);
284 - map->lock(map->lock_arg);
285 280 map->cache_ops->exit(map);
286 - map->unlock(map->lock_arg);
287 281 }
288 282
289 283 kfree(map->reg_defaults);
modified drivers/base/regmap/regmap-debugfs.c
@@ -664,6 +664,7 @@ void regmap_debugfs_exit(struct regmap *map)
664 664 {
665 665 if (map->debugfs) {
666 666 debugfs_remove_recursive(map->debugfs);
667 + map->debugfs = NULL;
667 668 mutex_lock(&map->cache_lock);
668 669 regmap_debugfs_free_dump_cache(map);
669 670 mutex_unlock(&map->cache_lock);
modified drivers/base/regmap/regmap-irq.c
@@ -963,7 +963,7 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode,
963 963 return 0;
964 964
965 965 err_domain:
966 - /* Should really dispose of the domain but... */
966 + irq_domain_remove(d->domain);
967 967 err_mutex:
968 968 mutex_destroy(&d->lock);
969 969 lockdep_unregister_key(&d->lock_key);
modified drivers/base/regmap/regmap.c
@@ -1422,8 +1422,8 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
1422 1422 {
1423 1423 int ret;
1424 1424
1425 - regcache_exit(map);
1426 1425 regmap_debugfs_exit(map);
1426 + regcache_exit(map);
1427 1427
1428 1428 map->max_register = config->max_register;
1429 1429 map->max_register_is_set = map->max_register ?: config->max_register_is_0;
@@ -1440,12 +1440,16 @@ int regmap_reinit_cache(struct regmap *map, const struct regmap_config *config)
1440 1440 if (ret)
1441 1441 return ret;
1442 1442
1443 - regmap_debugfs_init(map);
1444 -
1445 1443 map->cache_bypass = false;
1446 1444 map->cache_only = false;
1447 1445
1448 - return regcache_init(map, config);
1446 + ret = regcache_init(map, config);
1447 + if (ret)
1448 + return ret;
1449 +
1450 + regmap_debugfs_init(map);
1451 +
1452 + return 0;
1449 1453 }
1450 1454 EXPORT_SYMBOL_GPL(regmap_reinit_cache);
1451 1455
@@ -1459,9 +1463,8 @@ void regmap_exit(struct regmap *map)
1459 1463 struct regmap_async *async;
1460 1464
1461 1465 regmap_detach_dev(map->dev, map);
1462 - regcache_exit(map);
1463 -
1464 1466 regmap_debugfs_exit(map);
1467 + regcache_exit(map);
1465 1468 regmap_range_exit(map);
1466 1469 if (map->bus && map->bus->free_context)
1467 1470 map->bus->free_context(map->bus_context);
modified drivers/dma-buf/Kconfig
@@ -43,7 +43,7 @@ config UDMABUF
43 43 config DMABUF_DEBUG
44 44 bool "DMA-BUF debug checks"
45 45 depends on DMA_SHARED_BUFFER
46 - default y if DEBUG_KERNEL
46 + default y if DEBUG
47 47 help
48 48 This option enables additional checks for DMA-BUF importers and
49 49 exporters. Specifically it validates that importers do not peek at the
modified drivers/firewire/core-transaction.c
@@ -89,8 +89,12 @@ void fw_cancel_pending_transactions(struct fw_card *card)
89 89 break; \
90 90 } \
91 91 } \
92 - if (t && try_cancel_split_timeout(t)) \
93 - remove_transaction_entry(card, t); \
92 + if (t) { \
93 + if (try_cancel_split_timeout(t)) \
94 + remove_transaction_entry(card, t); \
95 + else \
96 + t = NULL; \
97 + } \
94 98 t; \
95 99 })
96 100
modified drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
@@ -1431,6 +1431,7 @@ static void amdgpu_cs_parser_fini(struct amdgpu_cs_parser *parser)
1431 1431 int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
1432 1432 {
1433 1433 struct amdgpu_device *adev = drm_to_adev(dev);
1434 + struct amdgpu_bo_list_entry *e;
1434 1435 struct amdgpu_cs_parser parser;
1435 1436 int r;
1436 1437
@@ -1465,25 +1466,31 @@ int amdgpu_cs_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
1465 1466
1466 1467 r = amdgpu_cs_patch_jobs(&parser);
1467 1468 if (r)
1468 - goto error_fini;
1469 + goto error_free_user_pages;
1469 1470
1470 1471 r = amdgpu_cs_vm_handling(&parser);
1471 1472 if (r)
1472 - goto error_fini;
1473 + goto error_free_user_pages;
1473 1474
1474 1475 r = amdgpu_cs_sync_rings(&parser);
1475 1476 if (r)
1476 - goto error_fini;
1477 + goto error_free_user_pages;
1477 1478
1478 1479 trace_amdgpu_cs_ibs(&parser);
1479 1480
1480 1481 r = amdgpu_cs_submit(&parser, data);
1481 1482 if (r)
1482 - goto error_fini;
1483 + goto error_free_user_pages;
1483 1484
1484 1485 amdgpu_cs_parser_fini(&parser);
1485 1486 return 0;
1486 1487
1488 + error_free_user_pages:
1489 + /* amdgpu_cs_submit() only drops the ranges once it got that far. */
1490 + amdgpu_bo_list_for_each_userptr_entry(e, parser.bo_list) {
1491 + amdgpu_hmm_range_free(e->range);
1492 + e->range = NULL;
1493 + }
1487 1494 error_fini:
1488 1495 amdgpu_cs_parser_fini(&parser);
1489 1496 return r;
modified drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c
@@ -1266,7 +1266,6 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,
1266 1266 {
1267 1267 struct amdgpu_device *adev = f->f_inode->i_private;
1268 1268 int r;
1269 - ssize_t result = 0;
1270 1269 uint32_t offset, se, sh, cu, wave, simd, thread, bank, *data;
1271 1270
1272 1271 if (size > 4096 || size & 3 || *pos & 3)
@@ -1310,25 +1309,11 @@ static ssize_t amdgpu_debugfs_gpr_read(struct file *f, char __user *buf,
1310 1309 mutex_unlock(&adev->grbm_idx_mutex);
1311 1310
1312 1311 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
1312 + amdgpu_virt_disable_access_debugfs(adev);
1313 1313
1314 - while (size) {
1315 - uint32_t value;
1316 -
1317 - value = data[result >> 2];
1318 - r = put_user(value, (uint32_t *)buf);
1319 - if (r) {
1320 - amdgpu_virt_disable_access_debugfs(adev);
1321 - goto err;
1322 - }
1323 -
1324 - result += 4;
1325 - buf += 4;
1326 - size -= 4;
1327 - }
1328 -
1314 + r = copy_to_user(buf, data, size) ? -EFAULT : size;
1329 1315 kfree(data);
1330 - amdgpu_virt_disable_access_debugfs(adev);
1331 - return result;
1316 + return r;
1332 1317
1333 1318 err:
1334 1319 pm_runtime_put_autosuspend(adev_to_drm(adev)->dev);
modified drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -337,11 +337,14 @@ static void amdgpu_gem_object_close(struct drm_gem_object *obj,
337 337 goto out_unlock;
338 338 }
339 339
340 + bo_va = amdgpu_vm_bo_find(vm, bo);
341 + /* the fence is attached once per bo_va, so keep it for other handles */
342 + if (bo_va && --bo_va->ref_count)
343 + goto out_unlock;
344 +
340 345 if (!amdgpu_vm_is_bo_always_valid(vm, bo))
341 346 amdgpu_evf_mgr_detach_fence(&fpriv->evf_mgr, bo);
342 -
343 - bo_va = amdgpu_vm_bo_find(vm, bo);
344 - if (!bo_va || --bo_va->ref_count)
347 + if (!bo_va)
345 348 goto out_unlock;
346 349
347 350 amdgpu_vm_bo_del(adev, bo_va);
@@ -567,8 +570,10 @@ int amdgpu_gem_userptr_ioctl(struct drm_device *dev, void *data,
567 570
568 571 if (args->flags & AMDGPU_GEM_USERPTR_VALIDATE) {
569 572 range = amdgpu_hmm_range_alloc(NULL);
570 - if (unlikely(!range))
571 - return -ENOMEM;
573 + if (unlikely(!range)) {
574 + r = -ENOMEM;
575 + goto release_object;
576 + }
572 577 r = amdgpu_ttm_tt_get_user_pages(bo, range);
573 578 if (r) {
574 579 amdgpu_hmm_range_free(range);
@@ -1236,7 +1241,7 @@ int amdgpu_gem_list_handles_ioctl(struct drm_device *dev, void *data,
1236 1241 bo_entry->alloc_flags = bo->flags & AMDGPU_GEM_CREATE_SETTABLE_MASK;
1237 1242 bo_entry->preferred_domains = bo->preferred_domains;
1238 1243 bo_entry->gem_handle = id;
1239 - bo_entry->alignment = bo->tbo.page_alignment;
1244 + bo_entry->alignment = (u64)bo->tbo.page_alignment << PAGE_SHIFT;
1240 1245
1241 1246 if (bo->tbo.base.import_attach)
1242 1247 bo_entry->flags |= AMDGPU_GEM_LIST_HANDLES_FLAG_IS_IMPORT;
modified drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -2065,14 +2065,15 @@ static int amdgpu_ttm_buffer_entity_init(struct amdgpu_gtt_mgr *mgr,
2065 2065 int i, r, num_pages;
2066 2066 const u64 GTT_MAX_PAGES = (AMDGPU_GTT_MAX_TRANSFER_SIZE >> PAGE_SHIFT);
2067 2067
2068 + if (ARRAY_SIZE(entity->gart_window_offs) < num_gart_windows)
2069 + return -EINVAL;
2070 +
2068 2071 r = drm_sched_entity_init(&entity->base, prio, scheds, num_schedulers, NULL);
2069 2072 if (r)
2070 2073 return r;
2071 2074
2072 2075 mutex_init(&entity->lock);
2073 2076
2074 - if (ARRAY_SIZE(entity->gart_window_offs) < num_gart_windows)
2075 - return -EINVAL;
2076 2077 if (num_gart_windows == 0)
2077 2078 return 0;
2078 2079
@@ -2080,6 +2081,7 @@ static int amdgpu_ttm_buffer_entity_init(struct amdgpu_gtt_mgr *mgr,
2080 2081 r = amdgpu_gtt_mgr_alloc_entries(mgr, &entity->gart_node, num_pages,
2081 2082 DRM_MM_INSERT_BEST);
2082 2083 if (r) {
2084 + mutex_destroy(&entity->lock);
2083 2085 drm_sched_entity_destroy(&entity->base);
2084 2086 return r;
2085 2087 }
@@ -2097,6 +2099,7 @@ static void amdgpu_ttm_buffer_entity_fini(struct amdgpu_gtt_mgr *mgr,
2097 2099 struct amdgpu_ttm_buffer_entity *entity)
2098 2100 {
2099 2101 amdgpu_gtt_mgr_free_entries(mgr, &entity->gart_node);
2102 + mutex_destroy(&entity->lock);
2100 2103 drm_sched_entity_destroy(&entity->base);
2101 2104 }
2102 2105
modified drivers/gpu/drm/amd/amdgpu/amdgpu_userq.c
@@ -980,19 +980,21 @@ amdgpu_userq_bo_validate(struct amdgpu_device *adev, struct drm_exec *exec,
980 980 {
981 981 struct ttm_operation_ctx ctx = { false, false };
982 982 struct amdgpu_bo_va *bo_va;
983 - struct amdgpu_bo *bo;
983 + struct amdgpu_bo *bo, *tmp;
984 984 int ret;
985 985
986 986 spin_lock(&vm->individual_lock);
987 - while (!list_empty(&vm->always_valid.evicted)) {
988 - bo_va = list_first_entry(&vm->always_valid.evicted,
987 + while (!list_empty(&vm->individual.evicted)) {
988 + bo_va = list_first_entry(&vm->individual.evicted,
989 989 struct amdgpu_bo_va,
990 990 base.vm_status);
991 + bo = bo_va->base.bo;
992 + tmp = amdgpu_bo_ref(bo);
991 993 spin_unlock(&vm->individual_lock);
992 994
993 - bo = bo_va->base.bo;
994 995 ret = drm_exec_prepare_obj(exec, &bo->tbo.base,
995 996 TTM_NUM_MOVE_FENCES + 1);
997 + amdgpu_bo_unref(&tmp);
996 998 if (unlikely(ret))
997 999 return ret;
998 1000
modified drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
@@ -457,6 +457,9 @@ static void sdma_v3_0_ring_emit_hdp_flush(struct amdgpu_ring *ring)
457 457 else
458 458 ref_and_mask = REG_SET_FIELD(ref_and_mask, GPU_HDP_FLUSH_DONE, SDMA1, 1);
459 459
460 + /* Hang workaround */
461 + amdgpu_ring_write(ring, SDMA_PKT_NOP_HEADER_OP(SDMA_OP_NOP));
462 +
460 463 amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_POLL_REGMEM) |
461 464 SDMA_PKT_POLL_REGMEM_HEADER_HDP_FLUSH(1) |
462 465 SDMA_PKT_POLL_REGMEM_HEADER_FUNC(3)); /* == */
@@ -484,6 +487,10 @@ static void sdma_v3_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 se
484 487 unsigned flags)
485 488 {
486 489 bool write64bit = flags & AMDGPU_FENCE_FLAG_64BIT;
490 +
491 + /* Hang workaround */
492 + amdgpu_ring_write(ring, SDMA_PKT_NOP_HEADER_OP(SDMA_OP_NOP));
493 +
487 494 /* write the fence */
488 495 amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_FENCE));
489 496 amdgpu_ring_write(ring, lower_32_bits(addr));
@@ -492,7 +499,11 @@ static void sdma_v3_0_ring_emit_fence(struct amdgpu_ring *ring, u64 addr, u64 se
492 499
493 500 /* optionally write high bits as well */
494 501 if (write64bit) {
502 + /* Hang workaround */
503 + amdgpu_ring_write(ring, SDMA_PKT_NOP_HEADER_OP(SDMA_OP_NOP));
504 +
495 505 addr += 4;
506 +
496 507 amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_FENCE));
497 508 amdgpu_ring_write(ring, lower_32_bits(addr));
498 509 amdgpu_ring_write(ring, upper_32_bits(addr));
@@ -1033,6 +1044,9 @@ static void sdma_v3_0_ring_emit_pipeline_sync(struct amdgpu_ring *ring)
1033 1044 uint32_t seq = ring->fence_drv.sync_seq;
1034 1045 uint64_t addr = ring->fence_drv.gpu_addr;
1035 1046
1047 + /* Hang workaround */
1048 + amdgpu_ring_write(ring, SDMA_PKT_NOP_HEADER_OP(SDMA_OP_NOP));
1049 +
1036 1050 /* wait for idle */
1037 1051 amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_POLL_REGMEM) |
1038 1052 SDMA_PKT_POLL_REGMEM_HEADER_HDP_FLUSH(0) |
@@ -1061,6 +1075,9 @@ static void sdma_v3_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
1061 1075 {
1062 1076 amdgpu_gmc_emit_flush_gpu_tlb(ring, vmid, pd_addr);
1063 1077
1078 + /* Hang workaround */
1079 + amdgpu_ring_write(ring, SDMA_PKT_NOP_HEADER_OP(SDMA_OP_NOP));
1080 +
1064 1081 /* wait for flush */
1065 1082 amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_POLL_REGMEM) |
1066 1083 SDMA_PKT_POLL_REGMEM_HEADER_HDP_FLUSH(0) |
@@ -1510,11 +1527,11 @@ static const struct amdgpu_ring_funcs sdma_v3_0_ring_funcs = {
1510 1527 .get_wptr = sdma_v3_0_ring_get_wptr,
1511 1528 .set_wptr = sdma_v3_0_ring_set_wptr,
1512 1529 .emit_frame_size =
1513 - 6 + /* sdma_v3_0_ring_emit_hdp_flush */
1530 + 6 + 1 + /* sdma_v3_0_ring_emit_hdp_flush */
1514 1531 3 + /* hdp invalidate */
1515 - 6 + /* sdma_v3_0_ring_emit_pipeline_sync */
1516 - VI_FLUSH_GPU_TLB_NUM_WREG * 3 + 6 + /* sdma_v3_0_ring_emit_vm_flush */
1517 - 10 + 10 + 10, /* sdma_v3_0_ring_emit_fence x3 for user fence, vm fence */
1532 + 6 + 1 + /* sdma_v3_0_ring_emit_pipeline_sync */
1533 + VI_FLUSH_GPU_TLB_NUM_WREG * 3 + 6 + 1 + /* sdma_v3_0_ring_emit_vm_flush */
1534 + (10 + 1) * 3, /* sdma_v3_0_ring_emit_fence x3 for user fence, vm fence */
1518 1535 .emit_ib_size = 7 + 6, /* sdma_v3_0_ring_emit_ib */
1519 1536 .emit_ib = sdma_v3_0_ring_emit_ib,
1520 1537 .emit_fence = sdma_v3_0_ring_emit_fence,
modified drivers/gpu/drm/amd/amdgpu/uvd_v3_1.c
@@ -288,7 +288,7 @@ static int uvd_v3_1_fw_validate(struct amdgpu_device *adev)
288 288 int i;
289 289 uint32_t keysel = adev->uvd.keyselect;
290 290
291 - if (RREG32(mmUVD_FW_START) & UVD_FW_STATUS__PASS_MASK) {
291 + if (RREG32(mmUVD_FW_START)) {
292 292 dev_dbg(adev->dev, "UVD keyselect already set: 0x%x (on CPU: 0x%x)\n",
293 293 RREG32(mmUVD_FW_START), adev->uvd.keyselect);
294 294 return 0;
modified drivers/gpu/drm/amd/pm/swsmu/smu14/smu_v14_0_2_ppt.c
@@ -89,6 +89,7 @@ static const struct smu_feature_bits smu_v14_0_2_dpm_features = {
89 89 #define PP_OD_FEATURE_FAN_TARGET_TEMPERATURE 9
90 90 #define PP_OD_FEATURE_FAN_MINIMUM_PWM 10
91 91 #define PP_OD_FEATURE_FAN_ZERO_RPM_ENABLE 11
92 + #define PP_OD_FEATURE_FAN_ZERO_RPM_STOP_TEMP 12
92 93
93 94 static struct cmn2asic_msg_mapping smu_v14_0_2_message_map[SMU_MSG_MAX_COUNT] = {
94 95 MSG_MAP(TestMessage, PPSMC_MSG_TestMessage, 1),
@@ -1020,6 +1021,10 @@ static void smu_v14_0_2_get_od_setting_limits(struct smu_context *smu,
1020 1021 od_min_setting = overdrive_lowerlimits->FanZeroRpmEnable;
1021 1022 od_max_setting = overdrive_upperlimits->FanZeroRpmEnable;
1022 1023 break;
1024 + case PP_OD_FEATURE_FAN_ZERO_RPM_STOP_TEMP:
1025 + od_min_setting = pptable->SkuTable.MsgLimits.FanStopTempMin;
1026 + od_max_setting = pptable->SkuTable.MsgLimits.FanStopTempMax;
1027 + break;
1023 1028 default:
1024 1029 od_min_setting = od_max_setting = INT_MAX;
1025 1030 break;
@@ -1244,6 +1249,24 @@ static int smu_v14_0_2_emit_clk_levels(struct smu_context *smu,
1244 1249 min_value, max_value);
1245 1250 break;
1246 1251
1252 + case SMU_OD_FAN_ZERO_RPM_STOP_TEMP:
1253 + if (!smu_v14_0_2_is_od_feature_supported(smu,
1254 + PP_OD_FEATURE_ZERO_FAN_BIT))
1255 + break;
1256 +
1257 + size += sysfs_emit_at(buf, size, "FAN_ZERO_RPM_STOP_TEMPERATURE:\n");
1258 + size += sysfs_emit_at(buf, size, "%d\n",
1259 + (int)od_table->OverDriveTable.FanZeroRpmStopTemp);
1260 +
1261 + size += sysfs_emit_at(buf, size, "%s:\n", "OD_RANGE");
1262 + smu_v14_0_2_get_od_setting_limits(smu,
1263 + PP_OD_FEATURE_FAN_ZERO_RPM_STOP_TEMP,
1264 + &min_value,
1265 + &max_value);
1266 + size += sysfs_emit_at(buf, size, "ZERO_RPM_STOP_TEMPERATURE: %u %u\n",
1267 + min_value, max_value);
1268 + break;
1269 +
1247 1270 case SMU_OD_RANGE:
1248 1271 if (!smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_GFXCLK_BIT) &&
1249 1272 !smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_UCLK_BIT) &&
@@ -2311,7 +2334,9 @@ static void smu_v14_0_2_set_supported_od_feature_mask(struct smu_context *smu)
2311 2334 OD_OPS_SUPPORT_FAN_MINIMUM_PWM_RETRIEVE |
2312 2335 OD_OPS_SUPPORT_FAN_MINIMUM_PWM_SET |
2313 2336 OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_RETRIEVE |
2314 - OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_SET;
2337 + OD_OPS_SUPPORT_FAN_ZERO_RPM_ENABLE_SET |
2338 + OD_OPS_SUPPORT_FAN_ZERO_RPM_STOP_TEMP_RETRIEVE |
2339 + OD_OPS_SUPPORT_FAN_ZERO_RPM_STOP_TEMP_SET;
2315 2340 }
2316 2341
2317 2342 static int smu_v14_0_2_get_overdrive_table(struct smu_context *smu,
@@ -2392,6 +2417,8 @@ static int smu_v14_0_2_set_default_od_settings(struct smu_context *smu)
2392 2417 user_od_table_bak.OverDriveTable.FanMinimumPwm;
2393 2418 user_od_table->OverDriveTable.FanZeroRpmEnable =
2394 2419 user_od_table_bak.OverDriveTable.FanZeroRpmEnable;
2420 + user_od_table->OverDriveTable.FanZeroRpmStopTemp =
2421 + user_od_table_bak.OverDriveTable.FanZeroRpmStopTemp;
2395 2422 }
2396 2423
2397 2424 smu_v14_0_2_set_supported_od_feature_mask(smu);
@@ -2446,6 +2473,11 @@ static int smu_v14_0_2_od_restore_table_single(struct smu_context *smu, long inp
2446 2473 boot_overdrive_table->OverDriveTable.FanZeroRpmEnable;
2447 2474 od_table->OverDriveTable.FeatureCtrlMask |= BIT(PP_OD_FEATURE_ZERO_FAN_BIT);
2448 2475 break;
2476 + case PP_OD_EDIT_FAN_ZERO_RPM_STOP_TEMP:
2477 + od_table->OverDriveTable.FanZeroRpmStopTemp =
2478 + boot_overdrive_table->OverDriveTable.FanZeroRpmStopTemp;
2479 + od_table->OverDriveTable.FeatureCtrlMask |= BIT(PP_OD_FEATURE_ZERO_FAN_BIT);
2480 + break;
2449 2481 case PP_OD_EDIT_ACOUSTIC_LIMIT:
2450 2482 od_table->OverDriveTable.AcousticLimitRpmThreshold =
2451 2483 boot_overdrive_table->OverDriveTable.AcousticLimitRpmThreshold;
@@ -2752,6 +2784,27 @@ static int smu_v14_0_2_od_edit_dpm_table(struct smu_context *smu,
2752 2784 od_table->OverDriveTable.FeatureCtrlMask |= BIT(PP_OD_FEATURE_ZERO_FAN_BIT);
2753 2785 break;
2754 2786
2787 + case PP_OD_EDIT_FAN_ZERO_RPM_STOP_TEMP:
2788 + if (!smu_v14_0_2_is_od_feature_supported(smu, PP_OD_FEATURE_ZERO_FAN_BIT)) {
2789 + dev_warn(adev->dev, "Zero RPM setting not supported!\n");
2790 + return -ENOTSUPP;
2791 + }
2792 +
2793 + smu_v14_0_2_get_od_setting_limits(smu,
2794 + PP_OD_FEATURE_FAN_ZERO_RPM_STOP_TEMP,
2795 + &minimum,
2796 + &maximum);
2797 + if (input[0] < minimum ||
2798 + input[0] > maximum) {
2799 + dev_info(adev->dev, "zero RPM stop temperature setting(%ld) must be within [%d, %d]!\n",
2800 + input[0], minimum, maximum);
2801 + return -EINVAL;
2802 + }
2803 +
2804 + od_table->OverDriveTable.FanZeroRpmStopTemp = input[0];
2805 + od_table->OverDriveTable.FeatureCtrlMask |= BIT(PP_OD_FEATURE_ZERO_FAN_BIT);
2806 + break;
2807 +
2755 2808 case PP_OD_RESTORE_DEFAULT_TABLE:
2756 2809 if (size == 1) {
2757 2810 ret = smu_v14_0_2_od_restore_table_single(smu, input[0]);
modified drivers/gpu/drm/drm_exec.c
@@ -48,6 +48,16 @@
48 48 * See struct dma_exec for more details.
49 49 */
50 50
51 + /* Unlock and put the prelocked obj */
52 + static void drm_exec_drop_prelocked(struct drm_exec *exec)
53 + {
54 + if (exec->prelocked) {
55 + dma_resv_unlock(exec->prelocked->resv);
56 + drm_gem_object_put(exec->prelocked);
57 + exec->prelocked = NULL;
58 + }
59 + }
60 +
51 61 /* Unlock all objects and drop references */
52 62 static void drm_exec_unlock_all(struct drm_exec *exec)
53 63 {
@@ -58,8 +68,7 @@ static void drm_exec_unlock_all(struct drm_exec *exec)
58 68 drm_gem_object_put(obj);
59 69 }
60 70
61 - drm_gem_object_put(exec->prelocked);
62 - exec->prelocked = NULL;
71 + drm_exec_drop_prelocked(exec);
63 72 }
64 73
65 74 /**
@@ -118,6 +127,14 @@ EXPORT_SYMBOL(drm_exec_fini);
118 127 bool drm_exec_cleanup(struct drm_exec *exec)
119 128 {
120 129 if (likely(!exec->contended)) {
130 +
131 + /*
132 + * The contended and prelocked object might never be passed to
133 + * drm_exec_lock_obj() again. This can happen when the object
134 + * is about to be cleaned up and we now hold the last reference
135 + * to it. Make sure that we don't unnecessarily keep it around.
136 + */
137 + drm_exec_drop_prelocked(exec);
121 138 ww_acquire_done(&exec->ticket);
122 139 return false;
123 140 }
@@ -175,16 +192,16 @@ static int drm_exec_lock_contended(struct drm_exec *exec)
175 192 dma_resv_lock_slow(obj->resv, &exec->ticket);
176 193 }
177 194
178 - ret = drm_exec_obj_locked(exec, obj);
179 - if (unlikely(ret))
180 - goto error_unlock;
195 + /*
196 + * It is perfectly possible that we see another contention before the
197 + * first one is fully handled.
198 + */
199 + drm_exec_drop_prelocked(exec);
181 200
201 + /* We move the reference from contended to prelocked here */
182 202 exec->prelocked = obj;
183 203 return 0;
184 204
185 - error_unlock:
186 - dma_resv_unlock(obj->resv);
187 -
188 205 error_dropref:
189 206 drm_gem_object_put(obj);
190 207 return ret;
@@ -212,35 +229,31 @@ int drm_exec_lock_obj(struct drm_exec *exec, struct drm_gem_object *obj)
212 229 if (exec->prelocked == obj) {
213 230 drm_gem_object_put(exec->prelocked);
214 231 exec->prelocked = NULL;
215 - return 0;
216 - }
232 + } else {
233 + if (exec->flags & DRM_EXEC_INTERRUPTIBLE_WAIT)
234 + ret = dma_resv_lock_interruptible(obj->resv,
235 + &exec->ticket);
236 + else
237 + ret = dma_resv_lock(obj->resv, &exec->ticket);
238 +
239 + if (unlikely(ret == -EDEADLK)) {
240 + drm_gem_object_get(obj);
241 + exec->contended = obj;
242 + return -EDEADLK;
243 + }
217 244
218 - if (exec->flags & DRM_EXEC_INTERRUPTIBLE_WAIT)
219 - ret = dma_resv_lock_interruptible(obj->resv, &exec->ticket);
220 - else
221 - ret = dma_resv_lock(obj->resv, &exec->ticket);
245 + if (unlikely(ret == -EALREADY) &&
246 + exec->flags & DRM_EXEC_IGNORE_DUPLICATES)
247 + return 0;
222 248
223 - if (unlikely(ret == -EDEADLK)) {
224 - drm_gem_object_get(obj);
225 - exec->contended = obj;
226 - return -EDEADLK;
249 + if (unlikely(ret))
250 + return ret;
227 251 }
228 252
229 - if (unlikely(ret == -EALREADY) &&
230 - exec->flags & DRM_EXEC_IGNORE_DUPLICATES)
231 - return 0;
232 -
233 - if (unlikely(ret))
234 - return ret;
235 -
236 253 ret = drm_exec_obj_locked(exec, obj);
237 254 if (ret)
238 - goto error_unlock;
239 -
240 - return 0;
255 + dma_resv_unlock(obj->resv);
241 256
242 - error_unlock:
243 - dma_resv_unlock(obj->resv);
244 257 return ret;
245 258 }
246 259 EXPORT_SYMBOL(drm_exec_lock_obj);
modified drivers/gpu/drm/i915/display/intel_cx0_phy.c
@@ -2342,12 +2342,14 @@ static void intel_c10pll_dump_hw_state(struct drm_printer *p,
2342 2342 static bool is_arrowlake_s_by_host_bridge(void)
2343 2343 {
2344 2344 struct pci_dev *pdev = NULL;
2345 - u16 host_bridge_pci_dev_id;
2346 -
2347 - while ((pdev = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, pdev)))
2348 - host_bridge_pci_dev_id = pdev->device;
2345 + while ((pdev = pci_get_class(PCI_CLASS_BRIDGE_HOST << 8, pdev))) {
2346 + if (IS_ARROWLAKE_S_BY_HOST_BRIDGE_ID(pdev->device)) {
2347 + pci_dev_put(pdev);
2348 + return true;
2349 + }
2350 + }
2349 2351
2350 - return pdev && IS_ARROWLAKE_S_BY_HOST_BRIDGE_ID(host_bridge_pci_dev_id);
2352 + return false;
2351 2353 }
2352 2354
2353 2355 static u16 intel_c20_hdmi_tmds_tx_cgf_1(struct intel_display *display)
modified drivers/gpu/drm/i915/display/intel_dmc.c
@@ -1023,6 +1023,55 @@ static void dmc_set_fw_offset(struct intel_dmc *dmc,
1023 1023 }
1024 1024 }
1025 1025
1026 + /*
1027 + * Check if the load address is within the valid range for the given DMC ID.
1028 + */
1029 + static bool dmc_load_addr_sanity_check(struct intel_dmc *dmc,
1030 + u32 start_addr, u32 payload_size,
1031 + int header_ver, enum intel_dmc_id dmc_id)
1032 + {
1033 + u32 start_range, end_range, end_addr;
1034 +
1035 + if (header_ver != 3)
1036 + return true;
1037 +
1038 + switch (dmc_id) {
1039 + case DMC_FW_MAIN:
1040 + start_range = DMC_MAIN_PROGRAM_BASE_START;
1041 + end_range = DMC_MAIN_PROGRAM_BASE_END;
1042 + break;
1043 + case DMC_FW_PIPEA:
1044 + start_range = DMC_PIPEA_PROGRAM_BASE_START;
1045 + end_range = DMC_PIPEA_PROGRAM_BASE_END;
1046 + break;
1047 + case DMC_FW_PIPEB:
1048 + start_range = DMC_PIPEB_PROGRAM_BASE_START;
1049 + end_range = DMC_PIPEB_PROGRAM_BASE_END;
1050 + break;
1051 + case DMC_FW_PIPEC:
1052 + start_range = DMC_PIPEC_PROGRAM_BASE_START;
1053 + end_range = DMC_PIPEC_PROGRAM_BASE_END;
1054 + break;
1055 + case DMC_FW_PIPED:
1056 + start_range = DMC_PIPED_PROGRAM_BASE_START;
1057 + end_range = DMC_PIPED_PROGRAM_BASE_END;
1058 + break;
1059 + default:
1060 + MISSING_CASE(dmc_id);
1061 + return false;
1062 + }
1063 +
1064 + if (payload_size == 0)
1065 + end_addr = start_addr;
1066 + else if (check_add_overflow(start_addr, payload_size - 1, &end_addr))
1067 + return false;
1068 +
1069 + if (start_addr < start_range || end_addr > end_range)
1070 + return false;
1071 +
1072 + return true;
1073 + }
1074 +
1026 1075 static bool dmc_mmio_addr_sanity_check(struct intel_dmc *dmc,
1027 1076 const u32 *mmioaddr, u32 mmio_count,
1028 1077 int header_ver, enum intel_dmc_id dmc_id)
@@ -1120,7 +1169,7 @@ static u32 parse_dmc_fw_header(struct intel_dmc *dmc,
1120 1169 }
1121 1170
1122 1171 /* Cache the dmc header info. */
1123 - if (mmio_count > mmio_count_max) {
1172 + if (!mmio_count || mmio_count > mmio_count_max) {
1124 1173 drm_err(display->drm, "DMC firmware has wrong mmio count %u\n", mmio_count);
1125 1174 return 0;
1126 1175 }
@@ -1166,13 +1215,21 @@ static u32 parse_dmc_fw_header(struct intel_dmc *dmc,
1166 1215 disable_dmc_evt(display, dmc_id, dmc_info->mmioaddr[i],
1167 1216 dmc_info->mmiodata[i]) ? " (disabling)" : "");
1168 1217 }
1169 - dmc_info->mmio_count = mmio_count;
1170 - dmc_info->start_mmioaddr = start_mmioaddr;
1171 1218
1172 1219 rem_size -= header_len_bytes;
1173 1220
1174 1221 /* fw_size is in dwords, so multiplied by 4 to convert into bytes. */
1175 - payload_size = dmc_header->fw_size * 4;
1222 + if (check_mul_overflow(dmc_header->fw_size, 4u, &payload_size)) {
1223 + drm_err(display->drm, "DMC fw_size too large (%u dwords)\n",
1224 + dmc_header->fw_size);
1225 + return 0;
1226 + }
1227 +
1228 + if (!payload_size) {
1229 + drm_err(display->drm, "DMC firmware has empty payload\n");
1230 + return 0;
1231 + }
1232 +
1176 1233 if (rem_size < payload_size)
1177 1234 goto error_truncated;
1178 1235
@@ -1180,12 +1237,21 @@ static u32 parse_dmc_fw_header(struct intel_dmc *dmc,
1180 1237 drm_err(display->drm, "DMC FW too big (%u bytes)\n", payload_size);
1181 1238 return 0;
1182 1239 }
1183 - dmc_info->dmc_fw_size = dmc_header->fw_size;
1240 +
1241 + if (!dmc_load_addr_sanity_check(dmc, start_mmioaddr, payload_size,
1242 + dmc_header->header_ver, dmc_id)) {
1243 + drm_err(display->drm, "DMC %d: firmware has wrong load address\n", dmc_id);
1244 + return 0;
1245 + }
1184 1246
1185 1247 dmc_info->payload = kmalloc(payload_size, GFP_KERNEL);
1186 1248 if (!dmc_info->payload)
1187 1249 return 0;
1188 1250
1251 + dmc_info->mmio_count = mmio_count;
1252 + dmc_info->start_mmioaddr = start_mmioaddr;
1253 + dmc_info->dmc_fw_size = dmc_header->fw_size;
1254 +
1189 1255 payload = (u8 *)(dmc_header) + header_len_bytes;
1190 1256 memcpy(dmc_info->payload, payload, payload_size);
1191 1257
modified drivers/gpu/drm/i915/display/intel_dmc_regs.h
@@ -521,6 +521,18 @@ enum pipedmc_event_id {
521 521 #define TGL_PIPE_MMIO_END(dmc_id) _PICK_EVEN(((dmc_id) - 1), _TGL_PIPEA_MMIO_END,\
522 522 _TGL_PIPEB_MMIO_END)
523 523
524 + /* For DMC header version v3*/
525 + #define DMC_MAIN_PROGRAM_BASE_START 0x80000
526 + #define DMC_MAIN_PROGRAM_BASE_END 0x86fff
527 + #define DMC_PIPEA_PROGRAM_BASE_START 0x90000
528 + #define DMC_PIPEA_PROGRAM_BASE_END 0x96fff
529 + #define DMC_PIPEB_PROGRAM_BASE_START 0x98000
530 + #define DMC_PIPEB_PROGRAM_BASE_END 0x9efff
531 + #define DMC_PIPEC_PROGRAM_BASE_START 0x52000
532 + #define DMC_PIPEC_PROGRAM_BASE_END 0x53fff
533 + #define DMC_PIPED_PROGRAM_BASE_START 0x59000
534 + #define DMC_PIPED_PROGRAM_BASE_END 0x5afff
535 +
524 536 #define SKL_DMC_DC3_DC5_COUNT _MMIO(0x80030)
525 537 #define SKL_DMC_DC5_DC6_COUNT _MMIO(0x8002C)
526 538 #define BXT_DMC_DC3_DC5_COUNT _MMIO(0x80038)
modified drivers/gpu/drm/panthor/panthor_hw.c
@@ -136,7 +136,7 @@ static char *get_gpu_model_name(struct panthor_device *ptdev)
136 136 case GPU_PROD_ID_MAKE(10, 7):
137 137 return "Mali-G610";
138 138 case GPU_PROD_ID_MAKE(11, 2):
139 - if (shader_core_count > 10 && ray_intersection)
139 + if (shader_core_count >= 10 && ray_intersection)
140 140 return "Mali-G715-Immortalis";
141 141 else if (shader_core_count >= 7)
142 142 return "Mali-G715";
modified drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -894,7 +894,7 @@ static void vc4_hdmi_encoder_post_crtc_disable(struct drm_encoder *encoder,
894 894
895 895 spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
896 896
897 - HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, 0);
897 + HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, VC4_HDMI_RAM_PACKET_ENABLE);
898 898
899 899 HDMI_WRITE(HDMI_VID_CTL, HDMI_READ(HDMI_VID_CTL) | VC4_HD_VID_CTL_CLRRGB);
900 900
@@ -1663,9 +1663,6 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder,
1663 1663 WARN_ONCE(ret, "Timeout waiting for "
1664 1664 "VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE\n");
1665 1665 } else {
1666 - HDMI_WRITE(HDMI_RAM_PACKET_CONFIG,
1667 - HDMI_READ(HDMI_RAM_PACKET_CONFIG) &
1668 - ~(VC4_HDMI_RAM_PACKET_ENABLE));
1669 1666 HDMI_WRITE(HDMI_SCHEDULER_CONTROL,
1670 1667 HDMI_READ(HDMI_SCHEDULER_CONTROL) &
1671 1668 ~VC4_HDMI_SCHEDULER_CONTROL_MODE_HDMI);
@@ -1684,9 +1681,6 @@ static void vc4_hdmi_encoder_post_crtc_enable(struct drm_encoder *encoder,
1684 1681 WARN_ON(!(HDMI_READ(HDMI_SCHEDULER_CONTROL) &
1685 1682 VC4_HDMI_SCHEDULER_CONTROL_HDMI_ACTIVE));
1686 1683
1687 - HDMI_WRITE(HDMI_RAM_PACKET_CONFIG,
1688 - VC4_HDMI_RAM_PACKET_ENABLE);
1689 -
1690 1684 spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
1691 1685 vc4_hdmi->packet_ram_enabled = true;
1692 1686
@@ -3143,6 +3137,11 @@ static int vc5_hdmi_init_resources(struct drm_device *drm,
3143 3137 static int vc4_hdmi_runtime_suspend(struct device *dev)
3144 3138 {
3145 3139 struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev);
3140 + unsigned long flags;
3141 +
3142 + spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
3143 + HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, 0);
3144 + spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
3146 3145
3147 3146 clk_disable_unprepare(vc4_hdmi->audio_clock);
3148 3147 clk_disable_unprepare(vc4_hdmi->hsm_clock);
@@ -3153,9 +3152,8 @@ static int vc4_hdmi_runtime_suspend(struct device *dev)
3153 3152 static int vc4_hdmi_runtime_resume(struct device *dev)
3154 3153 {
3155 3154 struct vc4_hdmi *vc4_hdmi = dev_get_drvdata(dev);
3156 - unsigned long __maybe_unused flags;
3155 + unsigned long rate, flags;
3157 3156 u32 __maybe_unused value;
3158 - unsigned long rate;
3159 3157 int ret;
3160 3158
3161 3159 ret = clk_prepare_enable(vc4_hdmi->hsm_clock);
@@ -3201,6 +3199,10 @@ static int vc4_hdmi_runtime_resume(struct device *dev)
3201 3199 }
3202 3200 #endif
3203 3201
3202 + spin_lock_irqsave(&vc4_hdmi->hw_lock, flags);
3203 + HDMI_WRITE(HDMI_RAM_PACKET_CONFIG, VC4_HDMI_RAM_PACKET_ENABLE);
3204 + spin_unlock_irqrestore(&vc4_hdmi->hw_lock, flags);
3205 +
3204 3206 return 0;
3205 3207
3206 3208 err_disable_clk:
modified drivers/gpu/drm/virtio/virtgpu_drv.c
@@ -225,6 +225,7 @@ static int virtgpu_freeze(struct virtio_device *vdev)
225 225 goto err_resume;
226 226 }
227 227
228 + virtio_reset_device(vdev);
228 229 vdev->config->del_vqs(vdev);
229 230
230 231 return 0;
modified drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -589,7 +589,6 @@ struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev,
589 589 struct drm_plane *plane;
590 590 const uint32_t *formats;
591 591 int nformats;
592 - int ret;
593 592
594 593 if (type == DRM_PLANE_TYPE_CURSOR) {
595 594 formats = virtio_gpu_cursor_formats;
@@ -615,17 +614,5 @@ struct drm_plane *virtio_gpu_plane_init(struct virtio_gpu_device *vgdev,
615 614 drm_plane_create_blend_mode_property(plane,
616 615 BIT(DRM_MODE_BLEND_PREMULTI));
617 616
618 - if (type == DRM_PLANE_TYPE_CURSOR) {
619 - /*
620 - * The cursor plane exposes a format with an alpha channel,
621 - * which requires a blend mode property. The host blends
622 - * premultiplied alpha, matching the property's default.
623 - */
624 - ret = drm_plane_create_blend_mode_property(plane,
625 - BIT(DRM_MODE_BLEND_PREMULTI));
626 - if (ret)
627 - return ERR_PTR(ret);
628 - }
629 -
630 617 return plane;
631 618 }
modified drivers/gpu/drm/xe/xe_bo.c
@@ -330,6 +330,12 @@ static void xe_evict_flags(struct ttm_buffer_object *tbo,
330 330 return;
331 331 }
332 332
333 + /* No resource: nothing is placed/mapped, so there is nothing to evict. */
334 + if (!tbo->resource) {
335 + placement->num_placement = 0;
336 + return;
337 + }
338 +
333 339 bo = ttm_to_xe_bo(tbo);
334 340 if (bo->flags & XE_BO_FLAG_CPU_ADDR_MIRROR) {
335 341 *placement = sys_placement;
@@ -944,6 +950,8 @@ static int xe_bo_move_notify(struct xe_bo *bo,
944 950 *
945 951 * Transfers pages between shrinkable and purgeable buckets when the BO
946 952 * purgeable state changes. Called automatically from xe_bo_set_purgeable_state().
953 + * For pinned BOs, whose pages are not accounted, only the purgeable flag is
954 + * updated, so that the correct bucket is used when the BO is unpinned.
947 955 */
948 956 static void xe_bo_set_purgeable_shrinker(struct xe_bo *bo,
949 957 enum xe_madv_purgeable_state new_state)
@@ -960,7 +968,8 @@ static void xe_bo_set_purgeable_shrinker(struct xe_bo *bo,
960 968 return;
961 969
962 970 xe_tt = container_of(tt, struct xe_ttm_tt, ttm);
963 - tt_pages = tt->num_pages;
971 + /* Pinned bos are not accounted. Only update the purgeable flag. */
972 + tt_pages = xe_bo_is_pinned(bo) ? 0 : tt->num_pages;
964 973
965 974 if (!xe_tt->purgeable && new_state == XE_MADV_PURGEABLE_DONTNEED) {
966 975 xe_tt->purgeable = true;
modified drivers/gpu/drm/xe/xe_exec.c
@@ -346,11 +346,8 @@ retry:
346 346 xe_sched_job_push(job);
347 347 xe_vm_reactivate_rebind(vm);
348 348
349 - if (!err && !xe_vm_in_lr_mode(vm)) {
350 - spin_lock(&xe->ttm.lru_lock);
351 - ttm_lru_bulk_move_tail(&vm->lru_bulk_move);
352 - spin_unlock(&xe->ttm.lru_lock);
353 - }
349 + if (!err && !xe_vm_in_lr_mode(vm))
350 + xe_vm_bump_lru(vm, exec);
354 351
355 352 if (mode == EXEC_MODE_LR)
356 353 xe_hw_engine_group_resume_faulting_lr_jobs(group);
modified drivers/gpu/drm/xe/xe_oa.c
@@ -914,6 +914,13 @@ static int xe_oa_alloc_oa_buffer(struct xe_oa_stream *stream, size_t size)
914 914 if (IS_ERR(bo))
915 915 return PTR_ERR(bo);
916 916
917 + /*
918 + * ttm_bo_type_kernel BOs are not zeroed on allocation, so the buffer can
919 + * hold stale data from previously freed pages. Since the OA buffer is
920 + * mmap'able by userspace, clear it here to avoid leaking kernel memory.
921 + */
922 + xe_map_memset(stream->oa->xe, &bo->vmap, 0, 0, xe_bo_size(bo));
923 +
917 924 stream->oa_buffer.bo = bo;
918 925
919 926 stream->oa_buffer.bounce = kmalloc(stream->oa_buffer.format->size, GFP_KERNEL);
modified drivers/gpu/drm/xe/xe_vm.c
@@ -410,6 +410,33 @@ int xe_vm_validate_rebind(struct xe_vm *vm, struct drm_exec *exec,
410 410 return 0;
411 411 }
412 412
413 + /**
414 + * xe_vm_bump_lru() - Bump the LRU position of BOs used by a submission
415 + * @vm: The vm for which we are bumping LRUs.
416 + * @exec: The struct drm_exec with the locked GEM objects.
417 + *
418 + * Move the VM's private BOs, and all external objects locked by @exec,
419 + * to the LRU tail. Private BOs are moved in bulk using @vm's
420 + * &xe_vm.lru_bulk_move. External objects, which may be shared with other
421 + * VMs, are not part of that bulk move and are bumped individually.
422 + */
423 + void xe_vm_bump_lru(struct xe_vm *vm, struct drm_exec *exec)
424 + {
425 + spinlock_t *lru_lock = &vm->xe->ttm.lru_lock;
426 + struct drm_gem_object *obj;
427 +
428 + spin_lock(lru_lock);
429 + ttm_lru_bulk_move_tail(&vm->lru_bulk_move);
430 + drm_exec_for_each_locked_object(exec, obj) {
431 + if (!drm_gpuvm_is_extobj(&vm->gpuvm, obj))
432 + continue;
433 +
434 + ttm_bo_move_to_lru_tail(&gem_to_xe_bo(obj)->ttm);
435 + cond_resched_lock(lru_lock);
436 + }
437 + spin_unlock(lru_lock);
438 + }
439 +
413 440 static int xe_preempt_work_begin(struct drm_exec *exec, struct xe_vm *vm,
414 441 bool *done)
415 442 {
@@ -560,9 +587,7 @@ retry:
560 587
561 588 #undef retry_required
562 589
563 - spin_lock(&vm->xe->ttm.lru_lock);
564 - ttm_lru_bulk_move_tail(&vm->lru_bulk_move);
565 - spin_unlock(&vm->xe->ttm.lru_lock);
590 + xe_vm_bump_lru(vm, &exec);
566 591
567 592 /* Point of no return. */
568 593 arm_preempt_fences(vm, &preempt_fences);
modified drivers/gpu/drm/xe/xe_vm.h
@@ -284,6 +284,8 @@ int xe_vm_lock_vma(struct drm_exec *exec, struct xe_vma *vma);
284 284 int xe_vm_validate_rebind(struct xe_vm *vm, struct drm_exec *exec,
285 285 unsigned int num_fences);
286 286
287 + void xe_vm_bump_lru(struct xe_vm *vm, struct drm_exec *exec);
288 +
287 289 struct dma_fence *xe_vm_bind_kernel_bo(struct xe_vm *vm, struct xe_bo *bo,
288 290 struct xe_exec_queue *q, u64 addr,
289 291 enum xe_cache_level cache_lvl);
modified drivers/i2c/busses/i2c-qcom-cci.c
@@ -164,12 +164,12 @@ static irqreturn_t cci_isr(int irq, void *dev)
164 164 }
165 165
166 166 if (unlikely(val & CCI_IRQ_STATUS_0_I2C_M0_Q0Q1_HALT_ACK)) {
167 - reset = CCI_RESET_CMD_M0_MASK;
167 + reset |= CCI_RESET_CMD_M0_MASK;
168 168 ret = IRQ_HANDLED;
169 169 }
170 170
171 171 if (unlikely(val & CCI_IRQ_STATUS_0_I2C_M1_Q0Q1_HALT_ACK)) {
172 - reset = CCI_RESET_CMD_M1_MASK;
172 + reset |= CCI_RESET_CMD_M1_MASK;
173 173 ret = IRQ_HANDLED;
174 174 }
175 175
modified drivers/i2c/busses/i2c-qcom-geni.c
@@ -201,28 +201,31 @@ static const struct geni_i2c_clk_fld geni_i2c_clk_map_32mhz[] = {
201 201 static int geni_i2c_clk_map_idx(struct geni_i2c_dev *gi2c)
202 202 {
203 203 const struct geni_i2c_clk_fld *itr;
204 - unsigned long res_freq;
204 + unsigned long req_freq, res_freq;
205 + int ret;
205 206
206 207 /*
207 - * Frequency counter tables are calibrated for a specific source
208 - * clock frequency and are not valid for any multiple of it
209 - * (e.g. 64 MHz, 128 MHz).
210 - * Use exact=true and verify res_freq matches req_freq literally
211 - * to reject harmonics: a 64 MHz clock that divides evenly to
212 - * 32 MHz would pass exact matching but produce double the intended
213 - * I2C frequency with these counter values.
208 + * Use 32 MHz only if already selected, otherwise use 19.2 MHz.
209 + * Preferring 32 MHz merely because DFS supports it breaks I2C
210 + * transfers on X1E80100 CRD.
214 211 */
215 - if (!geni_se_clk_freq_match(&gi2c->se, GENI_SE_CLK_32MHZ,
216 - &gi2c->clk_idx, &res_freq, true) &&
217 - res_freq == GENI_SE_CLK_32MHZ) {
212 + if (clk_get_rate(gi2c->se.clk) == GENI_SE_CLK_32MHZ) {
213 + req_freq = GENI_SE_CLK_32MHZ;
218 214 itr = geni_i2c_clk_map_32mhz;
219 - } else if (!geni_se_clk_freq_match(&gi2c->se, GENI_SE_CLK_19P2MHZ,
220 - &gi2c->clk_idx, &res_freq, true) &&
221 - res_freq == GENI_SE_CLK_19P2MHZ) {
222 - itr = geni_i2c_clk_map_19p2mhz;
223 215 } else {
224 - dev_err(gi2c->se.dev,
225 - "Unsupported SE source clock: must be exactly 32 MHz or 19.2 MHz\n");
216 + req_freq = GENI_SE_CLK_19P2MHZ;
217 + itr = geni_i2c_clk_map_19p2mhz;
218 + }
219 +
220 + ret = geni_se_clk_freq_match(&gi2c->se, req_freq, &gi2c->clk_idx,
221 + &res_freq, true);
222 + if (ret)
223 + return dev_err_probe(gi2c->se.dev, ret,
224 + "Failed to find SE source clock %lu Hz\n",
225 + req_freq);
226 + if (res_freq != req_freq) {
227 + dev_err(gi2c->se.dev, "Unsupported SE source clock %lu Hz\n",
228 + res_freq);
226 229 return -EINVAL;
227 230 }
228 231
modified drivers/i2c/busses/i2c-viai2c-wmt.c
@@ -116,7 +116,7 @@ static int wmt_i2c_probe(struct platform_device *pdev)
116 116 if (err)
117 117 return err;
118 118
119 - i2c->clk = of_clk_get(np, 0);
119 + i2c->clk = devm_clk_get(&pdev->dev, NULL);
120 120 if (IS_ERR(i2c->clk))
121 121 return dev_err_probe(&pdev->dev, PTR_ERR(i2c->clk),
122 122 "unable to request clock\n");
modified drivers/i2c/busses/i2c-xiic.c
@@ -67,6 +67,7 @@ enum i2c_scl_freq {
67 67 * @rx_pos: Position within current RX message
68 68 * @endianness: big/little-endian byte order
69 69 * @clk: Pointer to AXI4-lite input clock
70 + * @irq: Interrupt number
70 71 * @state: See STATE_
71 72 * @singlemaster: Indicates bus is single master
72 73 * @dynamic: Mode of controller
@@ -95,6 +96,7 @@ struct xiic_i2c {
95 96 int rx_pos;
96 97 enum xiic_endian endianness;
97 98 struct clk *clk;
99 + int irq;
98 100 enum xilinx_i2c_state state;
99 101 bool singlemaster;
100 102 bool dynamic;
@@ -1506,9 +1508,17 @@ static int xiic_i2c_probe(struct platform_device *pdev)
1506 1508
1507 1509 pm_runtime_set_autosuspend_delay(dev, XIIC_PM_TIMEOUT);
1508 1510 pm_runtime_use_autosuspend(dev);
1509 - ret = devm_pm_runtime_set_active_enabled(dev);
1510 - if (ret)
1511 + /*
1512 + * Enable runtime PM by hand: devm_pm_runtime_set_active_enabled()
1513 + * tears down in an order that races the devm-enabled clock release and
1514 + * makes clk_core_disable() WARN (see xiic_i2c_remove()).
1515 + */
1516 + ret = pm_runtime_set_active(dev);
1517 + if (ret) {
1518 + pm_runtime_dont_use_autosuspend(dev);
1511 1519 return ret;
1520 + }
1521 + pm_runtime_enable(dev);
1512 1522
1513 1523 /* SCL frequency configuration */
1514 1524 i2c->input_clk = clk_get_rate(i2c->clk);
@@ -1517,10 +1527,15 @@ static int xiic_i2c_probe(struct platform_device *pdev)
1517 1527 if (ret || i2c->i2c_clk > I2C_MAX_FAST_MODE_PLUS_FREQ)
1518 1528 i2c->i2c_clk = 0;
1519 1529
1520 - ret = devm_request_threaded_irq(dev, irq, NULL, xiic_process,
1521 - IRQF_ONESHOT, pdev->name, i2c);
1530 + /*
1531 + * Request the IRQ non-managed: later probe steps unwind manually via
1532 + * goto, so a devm handler could still be live after that teardown runs.
1533 + */
1534 + i2c->irq = irq;
1535 + ret = request_threaded_irq(irq, NULL, xiic_process, IRQF_ONESHOT,
1536 + pdev->name, i2c);
1522 1537 if (ret)
1523 - return ret;
1538 + goto err_pm_disable;
1524 1539
1525 1540 i2c->singlemaster = device_property_read_bool(dev, "single-master");
1526 1541
@@ -1537,14 +1552,16 @@ static int xiic_i2c_probe(struct platform_device *pdev)
1537 1552 i2c->endianness = BIG;
1538 1553
1539 1554 ret = xiic_reinit(i2c);
1540 - if (ret)
1541 - return dev_err_probe(dev, ret, "Cannot xiic_reinit\n");
1555 + if (ret) {
1556 + dev_err_probe(dev, ret, "Cannot xiic_reinit\n");
1557 + goto err_free_irq;
1558 + }
1542 1559
1543 1560 /* add i2c adapter to i2c tree */
1544 1561 ret = i2c_add_numbered_adapter(&i2c->adap);
1545 1562 if (ret) {
1546 1563 xiic_deinit(i2c);
1547 - return ret;
1564 + goto err_free_irq;
1548 1565 }
1549 1566
1550 1567 if (pdata) {
@@ -1557,6 +1574,15 @@ static int xiic_i2c_probe(struct platform_device *pdev)
1557 1574 res, irq, i2c->i2c_clk);
1558 1575
1559 1576 return 0;
1577 +
1578 + err_free_irq:
1579 + free_irq(irq, i2c);
1580 + err_pm_disable:
1581 + pm_runtime_disable(dev);
1582 + pm_runtime_set_suspended(dev);
1583 + pm_runtime_dont_use_autosuspend(dev);
1584 +
1585 + return ret;
1560 1586 }
1561 1587
1562 1588 static void xiic_i2c_remove(struct platform_device *pdev)
@@ -1568,6 +1594,8 @@ static void xiic_i2c_remove(struct platform_device *pdev)
1568 1594 /* remove adapter & data */
1569 1595 i2c_del_adapter(&i2c->adap);
1570 1596
1597 + free_irq(i2c->irq, i2c);
1598 +
1571 1599 ret = pm_runtime_get_sync(dev);
1572 1600 if (ret < 0)
1573 1601 dev_warn(dev, "Failed to activate device for removal (%pe)\n",
@@ -1575,7 +1603,10 @@ static void xiic_i2c_remove(struct platform_device *pdev)
1575 1603 else
1576 1604 xiic_deinit(i2c);
1577 1605
1578 - pm_runtime_put_sync(dev);
1606 + pm_runtime_disable(dev);
1607 + pm_runtime_put_noidle(dev);
1608 + pm_runtime_set_suspended(dev);
1609 + pm_runtime_dont_use_autosuspend(dev);
1579 1610 }
1580 1611
1581 1612 static const struct dev_pm_ops xiic_dev_pm_ops = {
modified drivers/scsi/libiscsi.c
@@ -1142,13 +1142,15 @@ static int iscsi_handle_reject(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1142 1142 spin_unlock(&conn->session->frwd_lock);
1143 1143 spin_lock(&conn->session->back_lock);
1144 1144 } else {
1145 - struct iscsi_task *task;
1145 + struct iscsi_task *task = NULL;
1146 1146 /*
1147 1147 * Our nop as ping got dropped. We know the target
1148 1148 * and transport are ok so just clean up
1149 1149 */
1150 - task = iscsi_itt_to_task(conn, rejected_pdu.itt);
1151 - if (!task) {
1150 + if (!iscsi_verify_itt(conn, rejected_pdu.itt))
1151 + task = iscsi_itt_to_task(conn, rejected_pdu.itt);
1152 + if (!task || task->state == ISCSI_TASK_FREE ||
1153 + task->sc) {
1152 1154 iscsi_conn_printk(KERN_ERR, conn,
1153 1155 "Invalid pdu reject. Could "
1154 1156 "not lookup rejected task.\n");
@@ -1191,7 +1193,7 @@ struct iscsi_task *iscsi_itt_to_task(struct iscsi_conn *conn, itt_t itt)
1191 1193 session->tt->parse_pdu_itt(conn, itt, &i, NULL);
1192 1194 else
1193 1195 i = get_itt(itt);
1194 - if (i >= session->cmds_max)
1196 + if (i < 0 || i >= session->cmds_max)
1195 1197 return NULL;
1196 1198
1197 1199 return session->cmds[i];
@@ -1284,7 +1286,7 @@ int __iscsi_complete_pdu(struct iscsi_conn *conn, struct iscsi_hdr *hdr,
1284 1286 case ISCSI_OP_SCSI_TMFUNC_RSP:
1285 1287 case ISCSI_OP_NOOP_IN:
1286 1288 task = iscsi_itt_to_task(conn, hdr->itt);
1287 - if (!task)
1289 + if (!task || task->state == ISCSI_TASK_FREE || task->sc)
1288 1290 return ISCSI_ERR_BAD_ITT;
1289 1291 break;
1290 1292 default:
@@ -1384,7 +1386,7 @@ int iscsi_verify_itt(struct iscsi_conn *conn, itt_t itt)
1384 1386 return ISCSI_ERR_BAD_ITT;
1385 1387 }
1386 1388
1387 - if (i >= session->cmds_max) {
1389 + if (i < 0 || i >= session->cmds_max) {
1388 1390 iscsi_conn_printk(KERN_ERR, conn,
1389 1391 "received invalid itt index %u (max cmds "
1390 1392 "%u.\n", i, session->cmds_max);
modified drivers/scsi/libsas/sas_expander.c
@@ -62,7 +62,11 @@ static int smp_execute_task_sg(struct domain_device *dev,
62 62 to_sas_internal(dev->port->ha->shost->transportt);
63 63 struct sas_ha_struct *ha = dev->port->ha;
64 64
65 - pm_runtime_get_sync(ha->dev);
65 + /*
66 + * Non-blocking: a sync resume here would deadlock against
67 + * sas_drain_work() during HA resume.
68 + */
69 + pm_runtime_get_noresume(ha->dev);
66 70 mutex_lock(&dev->ex_dev.cmd_mutex);
67 71 for (retry = 0; retry < 3; retry++) {
68 72 if (test_bit(SAS_DEV_GONE, &dev->state)) {
@@ -135,7 +139,7 @@ static int smp_execute_task_sg(struct domain_device *dev,
135 139 }
136 140 }
137 141 mutex_unlock(&dev->ex_dev.cmd_mutex);
138 - pm_runtime_put_sync(ha->dev);
142 + pm_runtime_put(ha->dev);
139 143
140 144 BUG_ON(retry == 3 && task != NULL);
141 145 sas_free_task(task);
@@ -2222,6 +2226,11 @@ void sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost,
2222 2226 goto out;
2223 2227 }
2224 2228
2229 + /* The host may have autosuspended, resume it here. */
2230 + ret = pm_runtime_resume_and_get(dev->port->ha->dev);
2231 + if (ret)
2232 + goto out;
2233 +
2225 2234 ret = smp_execute_task_sg(dev, job->request_payload.sg_list,
2226 2235 job->reply_payload.sg_list);
2227 2236 if (ret >= 0) {
@@ -2229,6 +2238,7 @@ void sas_smp_handler(struct bsg_job *job, struct Scsi_Host *shost,
2229 2238 rcvlen = job->reply_payload.payload_len - ret;
2230 2239 ret = 0;
2231 2240 }
2241 + pm_runtime_put(dev->port->ha->dev);
2232 2242
2233 2243 out:
2234 2244 bsg_job_done(job, ret, rcvlen);
modified drivers/scsi/mpi3mr/mpi3mr_app.c
@@ -3053,7 +3053,7 @@ void mpi3mr_bsg_init(struct mpi3mr_ioc *mrioc)
3053 3053 }
3054 3054
3055 3055 q = bsg_setup_queue(bsg_dev, dev_name(bsg_dev), &lim,
3056 - mpi3mr_bsg_request, NULL, 0);
3056 + mpi3mr_bsg_request, NULL, 0, SCSI_SENSE_BUFFERSIZE);
3057 3057 if (IS_ERR(q)) {
3058 3058 ioc_err(mrioc, "%s: bsg registration failed\n",
3059 3059 dev_name(bsg_dev));
modified drivers/scsi/scsi_transport_fc.c
@@ -4345,7 +4345,8 @@ fc_bsg_hostadd(struct Scsi_Host *shost, struct fc_host_attrs *fc_host)
4345 4345 scsi_init_limits(shost, &lim);
4346 4346 lim.max_segments = min_not_zero(lim.max_segments, i->f->max_bsg_segments);
4347 4347 q = bsg_setup_queue(dev, bsg_name, &lim, fc_bsg_dispatch,
4348 - fc_bsg_job_timeout, i->f->dd_bsg_size);
4348 + fc_bsg_job_timeout, i->f->dd_bsg_size,
4349 + SCSI_SENSE_BUFFERSIZE);
4349 4350 if (IS_ERR(q)) {
4350 4351 dev_err(dev,
4351 4352 "fc_host%d: bsg interface failed to initialize - setup queue\n",
@@ -4378,7 +4379,8 @@ fc_bsg_rportadd(struct Scsi_Host *shost, struct fc_rport *rport)
4378 4379 scsi_init_limits(shost, &lim);
4379 4380 lim.max_segments = min_not_zero(lim.max_segments, i->f->max_bsg_segments);
4380 4381 q = bsg_setup_queue(dev, dev_name(dev), &lim, fc_bsg_dispatch_prep,
4381 - fc_bsg_job_timeout, i->f->dd_bsg_size);
4382 + fc_bsg_job_timeout, i->f->dd_bsg_size,
4383 + SCSI_SENSE_BUFFERSIZE);
4382 4384 if (IS_ERR(q)) {
4383 4385 dev_err(dev, "failed to setup bsg queue\n");
4384 4386 return PTR_ERR(q);
modified drivers/scsi/scsi_transport_iscsi.c
@@ -1545,7 +1545,7 @@ iscsi_bsg_host_add(struct Scsi_Host *shost, struct iscsi_cls_host *ihost)
1545 1545 snprintf(bsg_name, sizeof(bsg_name), "iscsi_host%d", shost->host_no);
1546 1546 scsi_init_limits(shost, &lim);
1547 1547 q = bsg_setup_queue(dev, bsg_name, &lim, iscsi_bsg_host_dispatch, NULL,
1548 - 0);
1548 + 0, SCSI_SENSE_BUFFERSIZE);
1549 1549 if (IS_ERR(q)) {
1550 1550 shost_printk(KERN_ERR, shost, "bsg interface failed to "
1551 1551 "initialize - no request queue\n");
modified drivers/scsi/scsi_transport_sas.c
@@ -199,7 +199,8 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy)
199 199
200 200 if (rphy) {
201 201 q = bsg_setup_queue(&rphy->dev, dev_name(&rphy->dev), NULL,
202 - sas_smp_dispatch, NULL, 0);
202 + sas_smp_dispatch, NULL, 0,
203 + SCSI_SENSE_BUFFERSIZE);
203 204 if (IS_ERR(q))
204 205 return PTR_ERR(q);
205 206 rphy->q = q;
@@ -208,7 +209,8 @@ static int sas_bsg_initialize(struct Scsi_Host *shost, struct sas_rphy *rphy)
208 209
209 210 snprintf(name, sizeof(name), "sas_host%d", shost->host_no);
210 211 q = bsg_setup_queue(&shost->shost_gendev, name, NULL,
211 - sas_smp_dispatch, NULL, 0);
212 + sas_smp_dispatch, NULL, 0,
213 + SCSI_SENSE_BUFFERSIZE);
212 214 if (IS_ERR(q))
213 215 return PTR_ERR(q);
214 216 to_sas_host_attrs(shost)->q = q;
modified drivers/scsi/st.c
@@ -3217,14 +3217,20 @@ static int set_location(struct scsi_tape *STp, unsigned int block, int partition
3217 3217 partition >= ST_NBR_PARTITIONS)
3218 3218 return (-EINVAL);
3219 3219 if (partition != STp->partition) {
3220 - if (get_location(STp, &blk, &p, 1))
3220 + /*
3221 + * Save the location for the partition the drive reports,
3222 + * not for STp->partition: after a reset STp->partition may
3223 + * not match the partition the drive is in.
3224 + */
3225 + if (get_location(STp, &blk, &p, 1) ||
3226 + p < 0 || p >= ST_NBR_PARTITIONS)
3221 3227 STps->last_block_valid = 0;
3222 3228 else {
3223 - STps->last_block_valid = 1;
3224 - STps->last_block_visited = blk;
3229 + STp->ps[p].last_block_valid = 1;
3230 + STp->ps[p].last_block_visited = blk;
3225 3231 DEBC_printk(STp, "Visited block %d for "
3226 3232 "partition %d saved.\n",
3227 - blk, STp->partition);
3233 + blk, p);
3228 3234 }
3229 3235 }
3230 3236
@@ -4509,11 +4515,11 @@ static void st_remove(struct scsi_device *SDp)
4509 4515 remove_cdevs(tpnt);
4510 4516
4511 4517 mutex_lock(&st_ref_mutex);
4512 - kref_put(&tpnt->kref, scsi_tape_release);
4513 - mutex_unlock(&st_ref_mutex);
4514 4518 spin_lock(&st_index_lock);
4515 4519 idr_remove(&st_index_idr, index);
4516 4520 spin_unlock(&st_index_lock);
4521 + kref_put(&tpnt->kref, scsi_tape_release);
4522 + mutex_unlock(&st_ref_mutex);
4517 4523 }
4518 4524
4519 4525 /**
modified drivers/scsi/xen-scsifront.c
@@ -367,6 +367,7 @@ static void scsifront_do_response(struct vscsifrnt_info *info,
367 367 struct vscsifrnt_shadow *shadow;
368 368
369 369 if (ring_rsp->rqid >= VSCSIIF_MAX_REQS ||
370 + !info->shadow[ring_rsp->rqid] ||
370 371 !info->shadow[ring_rsp->rqid]->inflight) {
371 372 scsifront_set_error(info, "illegal rqid returned by backend!");
372 373 return;
modified drivers/spi/spi-fsl-lpspi.c
@@ -550,11 +550,8 @@ static int fsl_lpspi_target_abort(struct spi_controller *controller)
550 550 return 0;
551 551 }
552 552
553 - static int fsl_lpspi_wait_for_completion(struct spi_controller *controller)
553 + static int fsl_lpspi_wait_for_completion(struct fsl_lpspi_data *fsl_lpspi)
554 554 {
555 - struct fsl_lpspi_data *fsl_lpspi =
556 - spi_controller_get_devdata(controller);
557 -
558 555 if (fsl_lpspi->is_target) {
559 556 if (wait_for_completion_interruptible(&fsl_lpspi->xfer_done) ||
560 557 fsl_lpspi->target_aborted) {
@@ -758,11 +755,9 @@ err:
758 755 return ret;
759 756 }
760 757
761 - static int fsl_lpspi_pio_transfer(struct spi_controller *controller,
758 + static int fsl_lpspi_pio_transfer(struct fsl_lpspi_data *fsl_lpspi,
762 759 struct spi_transfer *t)
763 760 {
764 - struct fsl_lpspi_data *fsl_lpspi =
765 - spi_controller_get_devdata(controller);
766 761 int ret;
767 762
768 763 fsl_lpspi->tx_buf = t->tx_buf;
@@ -774,7 +769,7 @@ static int fsl_lpspi_pio_transfer(struct spi_controller *controller,
774 769
775 770 fsl_lpspi_write_tx_fifo(fsl_lpspi);
776 771
777 - ret = fsl_lpspi_wait_for_completion(controller);
772 + ret = fsl_lpspi_wait_for_completion(fsl_lpspi);
778 773
779 774 fsl_lpspi_reset(fsl_lpspi);
780 775
@@ -803,11 +798,9 @@ static int fsl_lpspi_transfer_one(struct spi_controller *controller,
803 798 if (fsl_lpspi->usedma)
804 799 ret = fsl_lpspi_dma_transfer(controller, fsl_lpspi, t);
805 800 else
806 - ret = fsl_lpspi_pio_transfer(controller, t);
807 - if (ret < 0)
808 - return ret;
801 + ret = fsl_lpspi_pio_transfer(fsl_lpspi, t);
809 802
810 - return 0;
803 + return ret;
811 804 }
812 805
813 806 static irqreturn_t fsl_lpspi_isr(int irq, void *dev_id)
modified drivers/spi/spi-imx.c
@@ -1578,11 +1578,13 @@ static int spi_imx_dma_tx_data_handle(struct spi_imx_data *spi_imx,
1578 1578 dma_data->dma_len = ALIGN(dma_data->data_len, BYTES_PER_32BITS_WORD);
1579 1579 }
1580 1580
1581 - dma_data->dma_tx_buf = kzalloc(dma_data->dma_len, GFP_KERNEL);
1581 + dma_data->dma_tx_buf = kzalloc(DMA_CACHE_ALIGNED_LEN(dma_data->dma_len),
1582 + GFP_KERNEL);
1582 1583 if (!dma_data->dma_tx_buf)
1583 1584 return -ENOMEM;
1584 1585
1585 - dma_data->dma_rx_buf = kzalloc(dma_data->dma_len, GFP_KERNEL);
1586 + dma_data->dma_rx_buf = kzalloc(DMA_CACHE_ALIGNED_LEN(dma_data->dma_len),
1587 + GFP_KERNEL);
1586 1588 if (!dma_data->dma_rx_buf) {
1587 1589 kfree(dma_data->dma_tx_buf);
1588 1590 return -ENOMEM;
@@ -1920,7 +1922,8 @@ static int spi_imx_dma_package_transfer(struct spi_imx_data *spi_imx,
1920 1922
1921 1923 /* Trim the DMA RX buffer and copy the actual data to rx_buf */
1922 1924 dma_sync_single_for_cpu(controller->dma_rx->device->dev, dma_data->dma_rx_addr,
1923 - dma_data->dma_len, DMA_FROM_DEVICE);
1925 + DMA_CACHE_ALIGNED_LEN(dma_data->dma_len),
1926 + DMA_FROM_DEVICE);
1924 1927 spi_imx_dma_rx_data_handle(spi_imx, dma_data, transfer->rx_buf + spi_imx->rx_offset,
1925 1928 word_delay);
1926 1929 spi_imx->rx_offset += dma_data->data_len;
modified drivers/spi/spi-tegra114.c
@@ -859,6 +859,13 @@ static u32 tegra_spi_setup_transfer_one(struct spi_device *spi,
859 859 command1 |= SPI_BIT_LENGTH(bits_per_word - 1);
860 860 }
861 861
862 + /*
863 + * Re-assert the CS GPIO for every transfer: transfer_end() drops it
864 + * on cs_change, and the assert above only covers is_first_of_msg.
865 + */
866 + if (spi_get_csgpiod(spi, 0))
867 + gpiod_set_value(spi_get_csgpiod(spi, 0), 1);
868 +
862 869 return command1;
863 870 }
864 871
modified drivers/target/iscsi/iscsi_target_configfs.c
@@ -1306,17 +1306,24 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
1306 1306 return -EINVAL;
1307 1307 }
1308 1308
1309 + if (iscsit_get_tpg(discovery_tpg) < 0)
1310 + return -EINVAL;
1311 +
1309 1312 param = iscsi_find_param_from_key(AUTHMETHOD,
1310 1313 discovery_tpg->param_list);
1311 - if (!param)
1312 - return -EINVAL;
1314 + if (!param) {
1315 + err = -EINVAL;
1316 + goto out;
1317 + }
1313 1318
1314 1319 if (op) {
1315 1320 /*
1316 1321 * Reset the AuthMethod key to CHAP.
1317 1322 */
1318 - if (iscsi_update_param_value(param, CHAP) < 0)
1319 - return -EINVAL;
1323 + if (iscsi_update_param_value(param, CHAP) < 0) {
1324 + err = -EINVAL;
1325 + goto out;
1326 + }
1320 1327
1321 1328 discovery_tpg->tpg_attrib.authentication = 1;
1322 1329 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 1;
@@ -1327,8 +1334,10 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
1327 1334 /*
1328 1335 * Reset the AuthMethod key to CHAP,None
1329 1336 */
1330 - if (iscsi_update_param_value(param, "CHAP,None") < 0)
1331 - return -EINVAL;
1337 + if (iscsi_update_param_value(param, "CHAP,None") < 0) {
1338 + err = -EINVAL;
1339 + goto out;
1340 + }
1332 1341
1333 1342 discovery_tpg->tpg_attrib.authentication = 0;
1334 1343 iscsit_global->discovery_acl.node_auth.enforce_discovery_auth = 0;
@@ -1337,7 +1346,10 @@ static ssize_t iscsi_disc_enforce_discovery_auth_store(struct config_item *item,
1337 1346 " Discovery TPG\n");
1338 1347 }
1339 1348
1340 - return count;
1349 + err = count;
1350 + out:
1351 + iscsit_put_tpg(discovery_tpg);
1352 + return err;
1341 1353 }
1342 1354
1343 1355 CONFIGFS_ATTR(iscsi_disc_, enforce_discovery_auth);
modified drivers/target/target_core_transport.c
@@ -2359,7 +2359,7 @@ void target_do_delayed_work(struct work_struct *work)
2359 2359 struct se_device *dev = container_of(work, struct se_device,
2360 2360 delayed_cmd_work);
2361 2361
2362 - spin_lock(&dev->delayed_cmd_lock);
2362 + spin_lock_irq(&dev->delayed_cmd_lock);
2363 2363 while (!dev->ordered_sync_in_progress) {
2364 2364 struct se_cmd *cmd;
2365 2365
@@ -2380,12 +2380,12 @@ void target_do_delayed_work(struct work_struct *work)
2380 2380 dev->ordered_sync_in_progress = true;
2381 2381
2382 2382 list_del(&cmd->se_delayed_node);
2383 - spin_unlock(&dev->delayed_cmd_lock);
2383 + spin_unlock_irq(&dev->delayed_cmd_lock);
2384 2384
2385 2385 __target_execute_cmd(cmd, true);
2386 - spin_lock(&dev->delayed_cmd_lock);
2386 + spin_lock_irq(&dev->delayed_cmd_lock);
2387 2387 }
2388 - spin_unlock(&dev->delayed_cmd_lock);
2388 + spin_unlock_irq(&dev->delayed_cmd_lock);
2389 2389 }
2390 2390
2391 2391 static void transport_complete_ordered_sync(struct se_cmd *cmd)
modified drivers/ufs/core/ufs_bsg.c
@@ -258,7 +258,7 @@ int ufs_bsg_probe(struct ufs_hba *hba)
258 258 goto out;
259 259
260 260 q = bsg_setup_queue(bsg_dev, dev_name(bsg_dev), NULL, ufs_bsg_request,
261 - NULL, 0);
261 + NULL, 0, sizeof(struct ufs_rpmb_reply));
262 262 if (IS_ERR(q)) {
263 263 ret = PTR_ERR(q);
264 264 device_del(bsg_dev);
modified include/drm/drm_exec.h
@@ -73,13 +73,15 @@ drm_exec_obj(struct drm_exec *exec, unsigned long index)
73 73
74 74 /* Helper for drm_exec_for_each_locked_object(). Internal use only. */
75 75 #define __drm_exec_for_each_locked_object(exec, obj, __index) \
76 - for (unsigned long __index = 0; ((obj) = drm_exec_obj(exec, __index)); ++__index)
76 + for (unsigned long __index = 0; ((obj) = drm_exec_obj(exec, __index)); \
77 + ++__index)
77 78 /**
78 79 * drm_exec_for_each_locked_object - iterate over all the locked objects
79 80 * @exec: drm_exec object
80 81 * @obj: the current GEM object
81 82 *
82 - * Iterate over all the locked GEM objects inside the drm_exec object.
83 + * Iterate over all the explicitly locked GEM objects inside the drm_exec
84 + * container, except for the contended and implicit prelocked one.
83 85 */
84 86 #define drm_exec_for_each_locked_object(exec, obj) \
85 87 __drm_exec_for_each_locked_object(exec, obj, __UNIQUE_ID(drm_exec))
@@ -94,12 +96,13 @@ drm_exec_obj(struct drm_exec *exec, unsigned long index)
94 96 * @exec: drm_exec object
95 97 * @obj: the current GEM object
96 98 *
97 - * Iterate over all the locked GEM objects inside the drm_exec object in
98 - * reverse locking order. Note that the internal index may wrap around,
99 - * but that will be caught by drm_exec_obj(), returning a NULL object.
99 + * Iterate over all the explicitly locked GEM objects inside the drm_exec
100 + * container in reverse locking order. Note that the internal index may wrap
101 + * around, but that will be caught by drm_exec_obj(), returning a NULL object.
100 102 */
101 103 #define drm_exec_for_each_locked_object_reverse(exec, obj) \
102 - __drm_exec_for_each_locked_object_reverse(exec, obj, __UNIQUE_ID(drm_exec))
104 + __drm_exec_for_each_locked_object_reverse(exec, obj, \
105 + __UNIQUE_ID(drm_exec))
103 106
104 107 /**
105 108 * drm_exec_until_all_locked - loop until all GEM objects are locked
modified include/linux/bsg-lib.h
@@ -66,7 +66,8 @@ void bsg_job_done(struct bsg_job *job, int result,
66 66 unsigned int reply_payload_rcv_len);
67 67 struct request_queue *bsg_setup_queue(struct device *dev, const char *name,
68 68 struct queue_limits *lim, bsg_job_fn *job_fn,
69 - bsg_timeout_fn *timeout, int dd_job_size);
69 + bsg_timeout_fn *timeout, int dd_job_size,
70 + unsigned int reply_len);
70 71 void bsg_remove_queue(struct request_queue *q);
71 72 void bsg_job_put(struct bsg_job *job);
72 73 int __must_check bsg_job_get(struct bsg_job *job);
modified include/linux/futex.h
@@ -23,28 +23,32 @@ struct task_struct;
23 23 * 01 : Shared futex (PTHREAD_PROCESS_SHARED)
24 24 * mapped on a file (reference on the underlying inode)
25 25 * 10 : Shared futex (PTHREAD_PROCESS_SHARED)
26 - * (but private mapping on an mm, and reference taken on it)
26 + * (but private mapping on an mm)
27 27 */
28 28
29 - #define FUT_OFF_INODE 1 /* We set bit 0 if key has a reference on inode */
30 - #define FUT_OFF_MMSHARED 2 /* We set bit 1 if key has a reference on mm */
29 + #define FUT_OFF_INODE 1 /* We set bit 0 if shared key identifies an inode */
30 + #define FUT_OFF_MMSHARED 2 /* We set bit 1 if shared key identifies an mm */
31 31
32 32 union futex_key {
33 + /* For FUT_OFF_INODE */
33 34 struct {
34 35 u64 i_seq;
35 36 unsigned long pgoff;
36 37 unsigned int offset;
37 38 /* unsigned int node; */
38 39 } shared;
40 +
41 + /* For FUT_OFF_MMSHARED or private */
39 42 struct {
40 43 union {
41 - struct mm_struct *mm;
42 - u64 __tmp;
44 + struct mm_struct *mm; /* for private */
45 + u64 mm_seq; /* for FUT_OFF_MMSHARED */
43 46 };
44 47 unsigned long address;
45 48 unsigned int offset;
46 49 /* unsigned int node; */
47 50 } private;
51 +
48 52 struct {
49 53 u64 ptr;
50 54 unsigned long word;
@@ -152,11 +156,10 @@ static inline void futex_set_vdso_cs_range(struct futex_mm_data *fd, unsigned in
152 156 static inline void futex_fixup_robust_unlock(struct pt_regs *regs) { }
153 157 #endif /* !CONFIG_FUTEX_ROBUST_UNLOCK */
154 158
155 -
156 - #if defined(CONFIG_FUTEX_PRIVATE_HASH) || defined(CONFIG_FUTEX_ROBUST_UNLOCK)
159 + #ifdef CONFIG_FUTEX
157 160 void futex_mm_init(struct mm_struct *mm);
158 161 #else
159 162 static inline void futex_mm_init(struct mm_struct *mm) { }
160 - #endif
163 + #endif /* !CONFIG_FUTEX */
161 164
162 165 #endif /* _LINUX_FUTEX_H */
modified include/linux/futex_types.h
@@ -85,10 +85,12 @@ struct futex_unlock_cs_ranges { };
85 85 * struct futex_mm_data - Futex related per MM data
86 86 * @phash: Futex private hash related data
87 87 * @unlock: Futex unlock VDSO critical sections
88 + * @unique_id: Unique ID of the MM, for FUT_OFF_MMSHARED futexes
88 89 */
89 90 struct futex_mm_data {
90 91 struct futex_mm_phash phash;
91 92 struct futex_unlock_cs_ranges unlock;
93 + atomic64_t unique_id;
92 94 };
93 95 #else /* CONFIG_FUTEX */
94 96 struct futex_sched_data { };
modified include/linux/irq-entry-common.h
@@ -468,6 +468,25 @@ static inline void irqentry_exit_to_kernel_mode_preempt(struct pt_regs *regs,
468 468 irqentry_exit_cond_resched();
469 469 }
470 470
471 + /*
472 + * The deferred hrtimer rearm is the tail of the timer interrupt, moved to the
473 + * interrupt return path so that it runs after a possible reschedule. By now
474 + * irq_exit_rcu() has left lockdep's hardirq context. Re-enter it for the
475 + * rearm, so that the hrtimer base lock and the timekeeping sequence count are
476 + * not chained onto the locks held by the interrupted context, which would add
477 + * new lock chains for every lock stack an interrupt hits.
478 + *
479 + * The rearm on return to user mode needs no such annotation: no locks are
480 + * held there, so it uses the same lock chains as the rearm in hardirq
481 + * context.
482 + */
483 + static __always_inline void irqentry_hrtimer_rearm_deferred(void)
484 + {
485 + lockdep_hardirq_enter();
486 + hrtimer_rearm_deferred();
487 + lockdep_hardirq_exit();
488 + }
489 +
471 490 /**
472 491 * irqentry_exit_to_kernel_mode_after_preempt - Establish trace, lockdep and RCU state
473 492 * @regs: Pointer to current's pt_regs
@@ -491,7 +510,7 @@ irqentry_exit_to_kernel_mode_after_preempt(struct pt_regs *regs, irqentry_state_
491 510 */
492 511 if (state.exit_rcu) {
493 512 instrumentation_begin();
494 - hrtimer_rearm_deferred();
513 + irqentry_hrtimer_rearm_deferred();
495 514 /* Tell the tracer that IRET will enable interrupts */
496 515 trace_hardirqs_on_prepare();
497 516 lockdep_hardirqs_on_prepare();
@@ -502,7 +521,7 @@ irqentry_exit_to_kernel_mode_after_preempt(struct pt_regs *regs, irqentry_state_
502 521 }
503 522
504 523 instrumentation_begin();
505 - hrtimer_rearm_deferred();
524 + irqentry_hrtimer_rearm_deferred();
506 525 /* Covers both tracing and lockdep */
507 526 trace_hardirqs_on();
508 527 instrumentation_end();
modified include/linux/maple_tree.h
@@ -507,9 +507,13 @@ struct ma_wr_state {
507 507 };
508 508
509 509 #define mas_lock(mas) spin_lock(&((mas)->tree->ma_lock))
510 + #define mas_lock_irqsave(mas, flags) \
511 + spin_lock_irqsave(&((mas)->tree->ma_lock), flags)
510 512 #define mas_lock_nested(mas, subclass) \
511 513 spin_lock_nested(&((mas)->tree->ma_lock), subclass)
512 514 #define mas_unlock(mas) spin_unlock(&((mas)->tree->ma_lock))
515 + #define mas_unlock_irqrestore(mas, flags) \
516 + spin_unlock_irqrestore(&((mas)->tree->ma_lock), flags)
513 517
514 518 /*
515 519 * Special values for ma_state.node.
modified include/linux/sched/user.h
@@ -23,11 +23,13 @@ struct user_struct {
23 23 struct hlist_node uidhash_node;
24 24 kuid_t uid;
25 25
26 - #if defined(CONFIG_PERF_EVENTS) || defined(CONFIG_BPF_SYSCALL) || \
27 - defined(CONFIG_NET) || defined(CONFIG_IO_URING) || \
26 + #if defined(CONFIG_NET) || defined(CONFIG_IO_URING) || \
28 27 defined(CONFIG_VFIO_PCI_ZDEV_KVM) || IS_ENABLED(CONFIG_IOMMUFD) || \
29 28 defined(CONFIG_SECRETMEM)
30 - atomic_long_t locked_vm;
29 + atomic_long_t locked_vm; /* pinned pages charged to RLIMIT_MEMLOCK */
30 + #endif
31 + #ifdef CONFIG_PERF_EVENTS
32 + atomic_long_t perf_mlock; /* perf buffer pages within perf_event_mlock_kb */
31 33 #endif
32 34 #ifdef CONFIG_WATCH_QUEUE
33 35 atomic_t nr_watches; /* The number of watches this user currently has */
modified kernel/events/core.c
@@ -4639,6 +4639,7 @@ static bool perf_rotate_context(struct perf_cpu_pmu_context *cpc)
4639 4639
4640 4640 if (cpu_event) {
4641 4641 update_context_time(&cpuctx->ctx);
4642 + update_cgrp_time_from_cpuctx(cpuctx, false);
4642 4643 __pmu_ctx_sched_out(cpu_epc, EVENT_FLEXIBLE);
4643 4644 rotate_ctx(&cpuctx->ctx, cpu_event);
4644 4645 __pmu_ctx_sched_in(cpu_epc, EVENT_FLEXIBLE);
@@ -7059,7 +7060,7 @@ static void perf_mmap_close(struct vm_area_struct *vma)
7059 7060 perf_pmu_output_stop(event);
7060 7061
7061 7062 /* now it's safe to free the pages */
7062 - atomic_long_sub(rb->aux_nr_pages - rb->aux_mmap_locked, &mmap_user->locked_vm);
7063 + atomic_long_sub(rb->aux_nr_pages - rb->aux_mmap_locked, &mmap_user->perf_mlock);
7063 7064 atomic64_sub(rb->aux_mmap_locked, &vma->vm_mm->pinned_vm);
7064 7065
7065 7066 /* this has to be the last one */
@@ -7242,11 +7243,11 @@ static bool perf_mmap_calc_limits(struct vm_area_struct *vma, long *user_extra,
7242 7243 /* Increase the limit linearly with more CPUs */
7243 7244 user_lock_limit *= num_online_cpus();
7244 7245
7245 - user_locked = atomic_long_read(&user->locked_vm);
7246 + user_locked = atomic_long_read(&user->perf_mlock);
7246 7247
7247 7248 /*
7248 7249 * sysctl_perf_event_mlock may have changed, so that
7249 - * user->locked_vm > user_lock_limit
7250 + * user->perf_mlock > user_lock_limit
7250 7251 */
7251 7252 if (user_locked > user_lock_limit)
7252 7253 user_locked = user_lock_limit;
@@ -7254,7 +7255,7 @@ static bool perf_mmap_calc_limits(struct vm_area_struct *vma, long *user_extra,
7254 7255
7255 7256 if (user_locked > user_lock_limit) {
7256 7257 /*
7257 - * charge locked_vm until it hits user_lock_limit;
7258 + * charge perf_mlock until it hits user_lock_limit;
7258 7259 * charge the rest from pinned_vm
7259 7260 */
7260 7261 *extra = user_locked - user_lock_limit;
@@ -7272,7 +7273,7 @@ static void perf_mmap_account(struct vm_area_struct *vma, long user_extra, long
7272 7273 {
7273 7274 struct user_struct *user = current_user();
7274 7275
7275 - atomic_long_add(user_extra, &user->locked_vm);
7276 + atomic_long_add(user_extra, &user->perf_mlock);
7276 7277 atomic64_add(extra, &vma->vm_mm->pinned_vm);
7277 7278 }
7278 7279
@@ -7281,7 +7282,7 @@ static void perf_mmap_unaccount(struct vm_area_struct *vma, struct perf_buffer *
7281 7282 struct user_struct *user = rb->mmap_user;
7282 7283
7283 7284 atomic_long_sub((perf_data_size(rb) >> PAGE_SHIFT) + 1 - rb->mmap_locked,
7284 - &user->locked_vm);
7285 + &user->perf_mlock);
7285 7286 atomic64_sub(rb->mmap_locked, &vma->vm_mm->pinned_vm);
7286 7287 }
7287 7288
@@ -14394,23 +14395,18 @@ err:
14394 14395 }
14395 14396 EXPORT_SYMBOL_GPL(perf_event_create_kernel_counter);
14396 14397
14397 - static void __perf_pmu_remove(struct perf_event_context *ctx,
14398 - int cpu, struct pmu *pmu,
14399 - struct perf_event_groups *groups,
14398 + static void __perf_pmu_remove(struct perf_event_context *ctx, struct pmu *pmu,
14400 14399 struct list_head *events)
14401 14400 {
14402 - struct perf_event *event, *sibling;
14401 + struct perf_event *event, *tmp;
14402 +
14403 + list_for_each_entry_safe(event, tmp, &ctx->event_list, event_entry) {
14404 + if (event->pmu_ctx->pmu != pmu)
14405 + continue;
14403 14406
14404 - perf_event_groups_for_cpu_pmu(event, groups, cpu, pmu) {
14405 14407 perf_remove_from_context(event, 0);
14406 14408 put_pmu_ctx(event->pmu_ctx);
14407 14409 list_add(&event->migrate_entry, events);
14408 -
14409 - for_each_sibling_event(sibling, event) {
14410 - perf_remove_from_context(sibling, 0);
14411 - put_pmu_ctx(sibling->pmu_ctx);
14412 - list_add(&sibling->migrate_entry, events);
14413 - }
14414 14410 }
14415 14411 }
14416 14412
@@ -14486,8 +14482,7 @@ void perf_pmu_migrate_context(struct pmu *pmu, int src_cpu, int dst_cpu)
14486 14482 */
14487 14483 mutex_lock_double(&src_ctx->mutex, &dst_ctx->mutex);
14488 14484
14489 - __perf_pmu_remove(src_ctx, src_cpu, pmu, &src_ctx->pinned_groups, &events);
14490 - __perf_pmu_remove(src_ctx, src_cpu, pmu, &src_ctx->flexible_groups, &events);
14485 + __perf_pmu_remove(src_ctx, pmu, &events);
14491 14486
14492 14487 if (!list_empty(&events)) {
14493 14488 /*
modified kernel/futex/core.c
@@ -439,45 +439,51 @@ struct hrtimer_sleeper *futex_setup_timer(ktime_t *time, struct hrtimer_sleeper
439 439 }
440 440
441 441 /*
442 - * Generate a machine wide unique identifier for this inode.
442 + * Generate a machine wide unique identifier for this object (inode or mm).
443 443 *
444 444 * This relies on u64 not wrapping in the life-time of the machine; which with
445 445 * 1ns resolution means almost 585 years.
446 - *
447 - * This further relies on the fact that a well formed program will not unmap
448 - * the file while it has a (shared) futex waiting on it. This mapping will have
449 - * a file reference which pins the mount and inode.
450 - *
451 - * If for some reason an inode gets evicted and read back in again, it will get
452 - * a new sequence number and will _NOT_ match, even though it is the exact same
453 - * file.
454 - *
455 - * It is important that futex_match() will never have a false-positive, esp.
456 - * for PI futexes that can mess up the state. The above argues that false-negatives
457 - * are only possible for malformed programs.
458 446 */
459 - static u64 get_inode_sequence_number(struct inode *inode)
447 + static u64 get_object_id(atomic64_t *object_seq)
460 448 {
461 - static atomic64_t i_seq;
449 + static atomic64_t last_assigned_seq;
462 450 u64 old;
463 451
464 - /* Does the inode already have a sequence number? */
465 - old = atomic64_read(&inode->i_sequence);
452 + /* Does the object already have a sequence number? */
453 + old = atomic64_read(object_seq);
466 454 if (likely(old))
467 455 return old;
468 456
469 457 for (;;) {
470 - u64 new = atomic64_inc_return(&i_seq);
458 + u64 new = atomic64_inc_return(&last_assigned_seq);
471 459 if (WARN_ON_ONCE(!new))
472 460 continue;
473 461
474 462 old = 0;
475 - if (!atomic64_try_cmpxchg_relaxed(&inode->i_sequence, &old, new))
463 + if (!atomic64_try_cmpxchg_relaxed(object_seq, &old, new))
476 464 return old;
477 465 return new;
478 466 }
479 467 }
480 468
469 + /*
470 + * This relies on the fact that a well formed program will not unmap
471 + * the file while it has a (shared) futex waiting on it. This mapping will have
472 + * a file reference which pins the mount and inode.
473 + *
474 + * If for some reason an inode gets evicted and read back in again, it will get
475 + * a new sequence number and will _NOT_ match, even though it is the exact same
476 + * file.
477 + *
478 + * It is important that futex_match() will never have a false-positive, esp.
479 + * for PI futexes that can mess up the state. The above argues that false-negatives
480 + * are only possible for malformed programs.
481 + */
482 + static u64 get_inode_sequence_number(struct inode *inode)
483 + {
484 + return get_object_id(&inode->i_sequence);
485 + }
486 +
481 487 /**
482 488 * get_futex_key() - Get parameters which are the keys for a futex
483 489 * @uaddr: virtual address of the futex
@@ -683,8 +689,8 @@ again:
683 689 goto out;
684 690 }
685 691
686 - key->both.offset |= FUT_OFF_MMSHARED; /* ref taken on mm */
687 - key->private.mm = mm;
692 + key->both.offset |= FUT_OFF_MMSHARED;
693 + key->private.mm_seq = get_object_id(&mm->futex.unique_id);
688 694 key->private.address = address;
689 695
690 696 } else {
@@ -2055,13 +2061,12 @@ static void futex_robust_unlock_init_mm(struct futex_mm_data *fd)
2055 2061 static inline void futex_robust_unlock_init_mm(struct futex_mm_data *fd) { }
2056 2062 #endif /* !CONFIG_FUTEX_ROBUST_UNLOCK */
2057 2063
2058 - #if defined(CONFIG_FUTEX_PRIVATE_HASH) || defined(CONFIG_FUTEX_ROBUST_UNLOCK)
2059 2064 void futex_mm_init(struct mm_struct *mm)
2060 2065 {
2066 + atomic64_set(&mm->futex.unique_id, 0);
2061 2067 futex_hash_init_mm(&mm->futex);
2062 2068 futex_robust_unlock_init_mm(&mm->futex);
2063 2069 }
2064 - #endif
2065 2070
2066 2071 int futex_hash_prctl(unsigned long arg2, unsigned long arg3, unsigned long arg4)
2067 2072 {
modified kernel/sched/core.c
@@ -11327,17 +11327,16 @@ void sched_change_end(struct sched_change_ctx *ctx)
11327 11327 if (p->sched_class->switched_to)
11328 11328 p->sched_class->switched_to(rq, p);
11329 11329
11330 + /*
11331 + * Check if the task can preempt the current in case the class
11332 + * was upgraded. Note that none of the switch*_from() methods
11333 + * know the new class and none of the switch*_to() methods know
11334 + * the old class so we must resched here.
11335 + */
11336 + if (ctx->queued)
11337 + wakeup_preempt(rq, p, 0);
11338 +
11330 11339 if (ctx->running) {
11331 - /*
11332 - * If this was a class promotion; let the old class
11333 - * know it got preempted. Note that none of the
11334 - * switch*_from() methods know the new class and none
11335 - * of the switch*_to() methods know the old class.
11336 - */
11337 - if (sched_class_above(p->sched_class, ctx->class)) {
11338 - rq->next_class->wakeup_preempt(rq, p, 0);
11339 - rq->next_class = p->sched_class;
11340 - }
11341 11340 /*
11342 11341 * If this was a degradation in class; make sure to
11343 11342 * reschedule.
modified kernel/sched/fair.c
@@ -6463,12 +6463,20 @@ place_entity(struct cfs_rq *cfs_rq, struct sched_entity *se, int flags)
6463 6463 load = cfs_rq->sum_weight;
6464 6464 if (curr && curr->on_rq)
6465 6465 load += avg_vruntime_weight(cfs_rq, curr->h_load.weight);
6466 -
6467 - weight = avg_vruntime_weight(cfs_rq, se->h_load.weight);
6468 - lag *= load + weight;
6469 6466 if (WARN_ON_ONCE(!load))
6470 6467 load = 1;
6471 - lag = div64_long(lag, load);
6468 +
6469 + weight = avg_vruntime_weight(cfs_rq, se->h_load.weight);
6470 +
6471 + /*
6472 + * Rewrite, because the product (W + w_i)*vl'_i might
6473 + * overflow s64:
6474 + *
6475 + * vl_i = (W + w_i)*vl'_i / W
6476 + * = (W*vl'_i + w_i*vl'_i) / W
6477 + * = vl'_i + w_i*vl'_i/W
6478 + */
6479 + lag += div64_long(lag * weight, load);
6472 6480
6473 6481 /*
6474 6482 * A heavy entity (relative to the tree) will pull the
modified sound/soc/amd/yc/pci-acp6x.c
@@ -301,7 +301,7 @@ static int snd_acp6x_suspend(struct device *dev)
301 301 return ret;
302 302 }
303 303
304 - static int snd_acp6x_resume(struct device *dev)
304 + static int snd_acp6x_runtime_resume(struct device *dev)
305 305 {
306 306 struct acp6x_dev_data *adata;
307 307 int ret;
@@ -313,8 +313,42 @@ static int snd_acp6x_resume(struct device *dev)
313 313 return ret;
314 314 }
315 315
316 + static void acp6x_disable_msi_on_resume(struct pci_dev *pdev)
317 + {
318 + u16 control;
319 +
320 + if (!pdev->msi_cap)
321 + return;
322 +
323 + pci_read_config_word(pdev, pdev->msi_cap + PCI_MSI_FLAGS, &control);
324 + if (control & PCI_MSI_FLAGS_ENABLE) {
325 + dev_warn(&pdev->dev,
326 + "ACP: MSI unexpectedly enabled after resume (flags=0x%04x), disabling\n",
327 + control);
328 + control &= ~PCI_MSI_FLAGS_ENABLE;
329 + pci_write_config_word(pdev, pdev->msi_cap + PCI_MSI_FLAGS, control);
330 + }
331 + }
332 +
333 + static int snd_acp6x_resume(struct device *dev)
334 + {
335 + struct pci_dev *pdev = to_pci_dev(dev);
336 +
337 + /*
338 + * BIOS/firmware may re-enable MSI in PCI config space during
339 + * system resume even though this driver only uses legacy INTx
340 + * interrupts. If MSI is left enabled with stale address/data
341 + * registers, the device will write interrupts to a bogus address
342 + * causing IOMMU IO_PAGE_FAULT and interrupt delivery failure.
343 + * Explicitly clear the MSI Enable bit before reinitializing
344 + * the ACP hardware.
345 + */
346 + acp6x_disable_msi_on_resume(pdev);
347 + return snd_acp6x_runtime_resume(dev);
348 + }
349 +
316 350 static const struct dev_pm_ops acp6x_pm = {
317 - RUNTIME_PM_OPS(snd_acp6x_suspend, snd_acp6x_resume, NULL)
351 + RUNTIME_PM_OPS(snd_acp6x_suspend, snd_acp6x_runtime_resume, NULL)
318 352 SYSTEM_SLEEP_PM_OPS(snd_acp6x_suspend, snd_acp6x_resume)
319 353 };
320 354
modified sound/soc/codecs/cs42l52.c
@@ -290,7 +290,7 @@ static const char * const cs42l52_ng_type_text[] = {
290 290 };
291 291
292 292 static SOC_ENUM_SINGLE_DECL(ng_type_enum,
293 - CS42L52_NOISE_GATE_CTL, 6,
293 + CS42L52_NOISE_GATE_CTL, 7,
294 294 cs42l52_ng_type_text);
295 295
296 296 static const char * const left_swap_text[] = {
modified sound/soc/codecs/cs42l56.c
@@ -481,7 +481,7 @@ static const struct snd_kcontrol_new cs42l56_snd_controls[] = {
481 481 0, 0x3f, 0, 0),
482 482 SOC_SINGLE_TLV("Limiter MAX", CS42L56_LIM_THRESHOLD_CTL,
483 483 5, 0x07, 1, alc_tlv),
484 - SOC_SINGLE_TLV("Limiter Cushion", CS42L56_ALC_THRESHOLD,
484 + SOC_SINGLE_TLV("Limiter Cushion", CS42L56_LIM_THRESHOLD_CTL,
485 485 2, 0x07, 1, alc_tlv),
486 486
487 487 SOC_SINGLE("NG Switch", CS42L56_NOISE_GATE_CTL, 6, 1, 1),
modified sound/soc/codecs/max98371.c
@@ -166,7 +166,7 @@ static const struct snd_kcontrol_new max98371_snd_controls[] = {
166 166 0, (1<<MAX98371_DHT_MAX_WIDTH)-1, 0,
167 167 max98371_dht_max_gain),
168 168 SOC_SINGLE_TLV("Speaker DHT Min Volume", MAX98371_DHT_GAIN,
169 - 0, (1<<MAX98371_DHT_GAIN_WIDTH)-1, 0,
169 + 4, (1<<MAX98371_DHT_GAIN_WIDTH)-1, 0,
170 170 max98371_dht_min_gain),
171 171 SOC_SINGLE_TLV("Speaker DHT Rotation Volume", MAX98371_DHT_GAIN,
172 172 0, (1<<MAX98371_DHT_ROT_WIDTH)-1, 0,
modified sound/soc/codecs/nau8822.c
@@ -383,9 +383,9 @@ static const struct snd_kcontrol_new nau8822_snd_controls[] = {
383 383 NAU8822_REG_RIGHT_ADC_BOOST_CONTROL, 0, 7, 0, boost_tlv),
384 384
385 385 SOC_SINGLE("DAC 128x Oversampling Switch",
386 - NAU8822_REG_DAC_CONTROL, 5, 1, 0),
386 + NAU8822_REG_DAC_CONTROL, 3, 1, 0),
387 387 SOC_SINGLE("ADC 128x Oversampling Switch",
388 - NAU8822_REG_ADC_CONTROL, 5, 1, 0),
388 + NAU8822_REG_ADC_CONTROL, 3, 1, 0),
389 389 };
390 390
391 391 /* LMAIN and RMAIN Mixer */
modified sound/soc/codecs/pcm3168a.c
@@ -103,7 +103,7 @@ static SOC_ENUM_SINGLE_DECL(pcm3168a_dac_zf_func, PCM3168A_DAC_ATT_DEMP_ZF,
103 103 static const char *const pcm3168a_pol[] = { "Active High", "Active Low" };
104 104
105 105 static SOC_ENUM_SINGLE_DECL(pcm3168a_dac_zf_pol, PCM3168A_DAC_ATT_DEMP_ZF,
106 - PCM3168A_DAC_ATSPDA_SHIFT, pcm3168a_pol);
106 + PCM3168A_DAC_ZREV_SHIFT, pcm3168a_pol);
107 107
108 108 static const char *const pcm3168a_con[] = { "Differential", "Single-Ended" };
109 109
modified sound/soc/codecs/wm8978.c
@@ -255,9 +255,9 @@ static const struct snd_kcontrol_new wm8978_snd_controls[] = {
255 255
256 256 /* DAC / ADC oversampling */
257 257 SOC_SINGLE("DAC 128x Oversampling Switch", WM8978_DAC_CONTROL,
258 - 5, 1, 0),
258 + 3, 1, 0),
259 259 SOC_SINGLE("ADC 128x Oversampling Switch", WM8978_ADC_CONTROL,
260 - 5, 1, 0),
260 + 3, 1, 0),
261 261 };
262 262
263 263 /* Mixer #1: Output (OUT1, OUT2) Mixer: mix AUX, Input mixer output and DAC */
modified sound/soc/intel/avs/pcm.c
@@ -756,7 +756,7 @@ static int avs_dai_fe_prepare(struct snd_pcm_substream *substream, struct snd_so
756 756 data = snd_soc_dai_get_dma_data(dai, substream);
757 757 host_stream = data->host_stream;
758 758
759 - if (runtime->state == SNDRV_PCM_STATE_XRUN)
759 + if (runtime->state != SNDRV_PCM_STATE_PREPARED)
760 760 hdac_stream(host_stream)->prepared = false;
761 761 if (hdac_stream(host_stream)->prepared)
762 762 return 0;
modified sound/soc/sof/ipc4-topology.c
@@ -2458,11 +2458,14 @@ _sof_ipc4_prepare_copier_module(struct snd_sof_widget *swidget,
2458 2458 ch_map >>= 4;
2459 2459 }
2460 2460
2461 - if (swidget->id == snd_soc_dapm_dai_in && ch_count == out_ref_channels) {
2461 + if ((swidget->id == snd_soc_dapm_dai_in && ch_count == out_ref_channels) ||
2462 + ch_count < blob->alh_cfg.device_count) {
2462 2463 /*
2463 2464 * For playback DAI widgets where the channel number is equal to
2464 - * the output reference channels, set the step = 0 to ensure all
2465 - * the ch_mask is applied to all alh mappings.
2465 + * the output reference channels, or when there are fewer
2466 + * channels than aggregated devices (e.g. a mono capture
2467 + * stream split across multiple links), set step = 0 to
2468 + * ensure all the ch_mask is applied to all alh mappings.
2466 2469 */
2467 2470 mask = ch_mask;
2468 2471 step = 0;
modified sound/soc/sof/sof-client.c
@@ -576,7 +576,7 @@ void sof_client_unregister_ipc_rx_handler(struct sof_client_dev *cdev,
576 576 struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
577 577 struct sof_ipc_event_entry *event;
578 578
579 - guard(mutex)(&sdev->ipc_client_mutex);
579 + guard(mutex)(&sdev->client_event_handler_mutex);
580 580
581 581 list_for_each_entry(event, &sdev->ipc_rx_handler_list, list) {
582 582 if (event->cdev == cdev && event->ipc_msg_type == ipc_msg_type) {
@@ -593,7 +593,7 @@ void sof_client_fw_state_dispatcher(struct snd_sof_dev *sdev)
593 593 {
594 594 struct sof_state_event_entry *event;
595 595
596 - guard(mutex)(&sdev->ipc_client_mutex);
596 + guard(mutex)(&sdev->client_event_handler_mutex);
597 597
598 598 list_for_each_entry(event, &sdev->fw_state_handler_list, list)
599 599 event->callback(event->cdev, sdev->fw_state);
@@ -628,7 +628,7 @@ void sof_client_unregister_fw_state_handler(struct sof_client_dev *cdev)
628 628 struct snd_sof_dev *sdev = sof_client_dev_to_sof_dev(cdev);
629 629 struct sof_state_event_entry *event;
630 630
631 - guard(mutex)(&sdev->ipc_client_mutex);
631 + guard(mutex)(&sdev->client_event_handler_mutex);
632 632
633 633 list_for_each_entry(event, &sdev->fw_state_handler_list, list) {
634 634 if (event->cdev == cdev) {
modified sound/soc/stm/stm32_spdifrx.c
@@ -720,7 +720,7 @@ static irqreturn_t stm32_spdifrx_isr(int irq, void *devid)
720 720
721 721 if (err) {
722 722 regmap_read(spdifrx->regmap, STM32_SPDIFRX_CR, &cr);
723 - sync_state = FIELD_GET(SPDIFRX_CR_SPDIFEN_MASK, cr) &&
723 + sync_state = FIELD_GET(SPDIFRX_CR_SPDIFEN_MASK, cr) ==
724 724 SPDIFRX_SPDIFEN_SYNC;
725 725
726 726 /* SPDIFRX is in STATE_STOP. Disable SPDIFRX to clear errors */
modified tools/arch/x86/include/asm/insn.h
@@ -321,7 +321,7 @@ static inline int insn_offset_immediate(struct insn *insn)
321 321 * are repeated, it cannot be used for looping over the prefixes.
322 322 */
323 323 #define for_each_insn_prefix(insn, prefix) \
324 - for (int idx = 0; idx < ARRAY_SIZE(insn->prefixes.bytes) && (prefix = insn->prefixes.bytes[idx]) != 0; idx++)
324 + for (int __i = 0; __i < ARRAY_SIZE(insn->prefixes.bytes) && (prefix = insn->prefixes.bytes[__i]) != 0; __i++)
325 325
326 326 #define POP_SS_OPCODE 0x1f
327 327 #define MOV_SREG_OPCODE 0x8e