drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c
Source file repositories/reference/linux-study-clean/drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/gpu/drm/panfrost/panfrost_gem_shrinker.c- Extension
.c- Size
- 3065 bytes
- Lines
- 128
- Domain
- Driver Families
- Bucket
- drivers/gpu
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/list.hdrm/drm_device.hdrm/drm_gem_shmem_helper.hpanfrost_device.hpanfrost_gem.hpanfrost_mmu.h
Detected Declarations
function Copyrightfunction list_for_each_entryfunction panfrost_gem_purgefunction panfrost_gem_shrinker_scanfunction list_for_each_entry_safefunction panfrost_gem_shrinker_initfunction panfrost_gem_shrinker_cleanup
Annotated Snippet
panfrost_gem_purge(&shmem->base)) {
freed += shmem->base.size >> PAGE_SHIFT;
list_del_init(&shmem->madv_list);
}
}
mutex_unlock(&pfdev->shrinker_lock);
if (freed > 0)
pr_info_ratelimited("Purging %lu bytes\n", freed << PAGE_SHIFT);
return freed;
}
/**
* panfrost_gem_shrinker_init - Initialize panfrost shrinker
* @dev: DRM device
*
* This function registers and sets up the panfrost shrinker.
*/
int panfrost_gem_shrinker_init(struct drm_device *dev)
{
struct panfrost_device *pfdev = to_panfrost_device(dev);
pfdev->shrinker = shrinker_alloc(0, "drm-panfrost");
if (!pfdev->shrinker)
return -ENOMEM;
pfdev->shrinker->count_objects = panfrost_gem_shrinker_count;
pfdev->shrinker->scan_objects = panfrost_gem_shrinker_scan;
pfdev->shrinker->private_data = pfdev;
shrinker_register(pfdev->shrinker);
return 0;
}
/**
* panfrost_gem_shrinker_cleanup - Clean up panfrost shrinker
* @dev: DRM device
*
* This function unregisters the panfrost shrinker.
*/
void panfrost_gem_shrinker_cleanup(struct drm_device *dev)
{
struct panfrost_device *pfdev = to_panfrost_device(dev);
if (pfdev->shrinker)
shrinker_free(pfdev->shrinker);
}
Annotation
- Immediate include surface: `linux/list.h`, `drm/drm_device.h`, `drm/drm_gem_shmem_helper.h`, `panfrost_device.h`, `panfrost_gem.h`, `panfrost_mmu.h`.
- Detected declarations: `function Copyright`, `function list_for_each_entry`, `function panfrost_gem_purge`, `function panfrost_gem_shrinker_scan`, `function list_for_each_entry_safe`, `function panfrost_gem_shrinker_init`, `function panfrost_gem_shrinker_cleanup`.
- Atlas domain: Driver Families / drivers/gpu.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.