Compare

bd22f7e63509fa758cf500d9af3e88a3d3df96be..5b0a459f990be2faba33229fd93f10f23745fab2

drm/amdgpu: destroy mutex when tearing down ttm buffer entity

Pair mutex_init() with mutex_destroy() on the GART window allocation
failure path and in amdgpu_ttm_buffer_entity_fini(). This is a no-op
without CONFIG_DEBUG_MUTEXES, but it keeps lockdep from seeing a live
mutex after the entity is freed or re-initialized.

Signed-off-by: Perry Yuan <perry.yuan@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
(cherry picked from commit 03ac40aeed034a0a0d5824ad26f8fbe1f6463698)
Cc: stable@vger.kernel.org

Perry Yuan <perry.yuan@amd.com> · 2026-09-10 08:58 UTC · committed by Alex Deucher

Browse files
5 files changed, +11 −18
modified drivers/gpio/gpio-nct6694.c
@@ -444,7 +444,7 @@ static int nct6694_gpio_probe(struct platform_device *pdev)
444 444 data->gpio.set_config = nct6694_set_config;
445 445 data->gpio.init_valid_mask = nct6694_init_valid_mask;
446 446 data->gpio.base = -1;
447 - data->gpio.can_sleep = true;
447 + data->gpio.can_sleep = false;
448 448 data->gpio.owner = THIS_MODULE;
449 449 data->gpio.ngpio = NCT6694_NR_GPIO;
450 450
modified drivers/gpio/gpiolib-shared.c
@@ -450,6 +450,7 @@ int gpio_shared_add_proxy_lookup(struct device *consumer, struct fwnode_handle *
450 450 const char *con_id, unsigned long lflags)
451 451 {
452 452 const char *dev_id = dev_name(consumer);
453 + struct gpiod_lookup_table *lookup;
453 454 struct gpio_shared_entry *entry;
454 455 struct gpio_shared_ref *ref;
455 456
@@ -479,22 +480,18 @@ int gpio_shared_add_proxy_lookup(struct device *consumer, struct fwnode_handle *
479 480 if (!key)
480 481 return -ENOMEM;
481 482
482 - struct gpiod_lookup_table *lookup __free(kfree) =
483 - kzalloc_flex(*lookup, table, 2);
483 + lookup = kzalloc_flex(*lookup, table, 2);
484 484 if (!lookup)
485 485 return -ENOMEM;
486 486
487 487 pr_debug("Adding machine lookup entry for a shared GPIO for consumer %s, with key '%s' and con_id '%s'\n",
488 488 dev_id, key, ref->con_id ?: "none");
489 489
490 - lookup->dev_id = kstrdup(dev_id, GFP_KERNEL);
491 - if (!lookup->dev_id)
492 - return -ENOMEM;
493 -
490 + lookup->dev_id = dev_id;
494 491 lookup->table[0] = GPIO_LOOKUP(no_free_ptr(key), 0,
495 492 ref->con_id, lflags);
496 493
497 - ref->lookup = no_free_ptr(lookup);
494 + ref->lookup = lookup;
498 495 gpiod_add_lookup_table(ref->lookup);
499 496
500 497 return 0;
@@ -614,7 +611,6 @@ void gpio_device_teardown_shared(struct gpio_device *gdev)
614 611 if (ref->lookup) {
615 612 gpiod_remove_lookup_table(ref->lookup);
616 613 kfree(ref->lookup->table[0].key);
617 - kfree(ref->lookup->dev_id);
618 614 kfree(ref->lookup);
619 615 ref->lookup = NULL;
620 616 }
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/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 tools/gpio/Makefile
@@ -7,13 +7,7 @@ bindir ?= /usr/bin
7 7 # isn't set and when invoked from selftests build, where srctree
8 8 # is set to ".". building_out_of_srctree is undefined for in srctree
9 9 # builds
10 - ifeq ($(srctree),)
11 - update_srctree := 1
12 - endif
13 10 ifndef building_out_of_srctree
14 - update_srctree := 1
15 - endif
16 - ifeq ($(update_srctree),1)
17 11 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
18 12 srctree := $(patsubst %/,%,$(dir $(srctree)))
19 13 endif