Skip to contentSkip to conversation

drm/panthor: Expose size of driver internal BO's over fdinfo

bug report Dan Carpenter 2 participants 3 messages Feb 16, 2025 – Feb 17, 2025

lore
Share & tools
lore
#0 lore raw

Hello Adrián Larumbe,

Commit 434e5ca5b5d7 ("drm/panthor: Expose size of driver internal BO's over fdinfo") from Jan 30, 2025 (linux-next), leads to the following Smatch static checker warning:

drivers/gpu/drm/panthor/panthor_mmu.c:1968 panthor_vm_heaps_sizes()
warn: sleeping in atomic context

drivers/gpu/drm/panthor/panthor_mmu.c

    1956 void panthor_vm_heaps_sizes(struct panthor_file *pfile, struct drm_memory_stats *stats)
    1957 {
    1958         struct panthor_vm *vm;
    1959         unsigned long i;
    1960 
    1961         if (!pfile->vms)
    1962                 return;
    1963 
    1964         xa_lock(&pfile->vms->xa);
                 ^^^^^^^

This is a spinlock.

    1965         xa_for_each(&pfile->vms->xa, i, vm) {
    1966                 size_t size = 0;
    1967 
--> 1968                 mutex_lock(&vm->heaps.lock);
                         ^^^^^^^^^^

So we can't take a mutex if we're holding a spinlock.

    1969                 if (vm->heaps.pool)
    1970                         size = panthor_heap_pool_size(vm->heaps.pool);
    1971                 mutex_unlock(&vm->heaps.lock);
    1972 
    1973                 stats->resident += size;
    1974                 if (vm->as.id >= 0)
    1975                         stats->active += size;
    1976         }
    1977         xa_unlock(&pfile->vms->xa);
    1978 }

regards,
dan carpenter

#1 lore raw

Similar issue in panthor_fdinfo_gather_group_samples()

drivers/gpu/drm/panthor/panthor_sched.c:2883 panthor_fdinfo_gather_group_samples() warn: sleeping in atomic context

regards,
dan carpenter

#2 lore raw
In reply to Dan Carpenter

Hi Dan, thanks for the bug report.

A fix is already being discussed at https://lore.kernel.org/dri-devel/[email protected]/

Quoted 40 lines · Dan Carpenter

Hello Adrián Larumbe,

Commit 434e5ca5b5d7 ("drm/panthor: Expose size of driver internal BO's over fdinfo") from Jan 30, 2025 (linux-next), leads to the following Smatch static checker warning:

drivers/gpu/drm/panthor/panthor_mmu.c:1968 panthor_vm_heaps_sizes()
warn: sleeping in atomic context

drivers/gpu/drm/panthor/panthor_mmu.c

    1956 void panthor_vm_heaps_sizes(struct panthor_file *pfile, struct drm_memory_stats *stats)
    1957 {
    1958         struct panthor_vm *vm;
    1959         unsigned long i;
    1960
    1961         if (!pfile->vms)
    1962                 return;
    1963
    1964         xa_lock(&pfile->vms->xa);
                 ^^^^^^^

This is a spinlock.

    1965         xa_for_each(&pfile->vms->xa, i, vm) {
    1966                 size_t size = 0;
    1967
--> 1968                 mutex_lock(&vm->heaps.lock);
                         ^^^^^^^^^^

So we can't take a mutex if we're holding a spinlock.

    1969                 if (vm->heaps.pool)
    1970                         size = panthor_heap_pool_size(vm->heaps.pool);
    1971                 mutex_unlock(&vm->heaps.lock);
    1972
    1973                 stats->resident += size;
    1974                 if (vm->as.id >= 0)
    1975                         stats->active += size;
    1976         }
    1977         xa_unlock(&pfile->vms->xa);
    1978 }
Quoted 2 lines

regards,
dan carpenter

Kind Regards,
Adrian Larumbe