drivers/char/agp/generic.c
Source file repositories/reference/linux-study-clean/drivers/char/agp/generic.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/agp/generic.c- Extension
.c- Size
- 37054 bytes
- Lines
- 1417
- Domain
- Driver Families
- Bucket
- drivers/char
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/pci.hlinux/pagemap.hlinux/miscdevice.hlinux/pm.hlinux/agp_backend.hlinux/vmalloc.hlinux/dma-mapping.hlinux/mm.hlinux/sched.hlinux/slab.hasm/io.hasm/set_memory.hagp.h
Detected Declarations
function agp_free_keyfunction agp_get_keyfunction agp_alloc_page_arrayfunction agp_free_memoryfunction agp_return_sizefunction agp_num_entriesfunction agp_copy_infofunction agp_bind_memoryfunction agp_unbind_memoryfunction agp_v2_parse_onefunction agp_v3_parse_onefunction agp_collect_device_statusfunction agp_device_commandfunction for_each_pci_devfunction get_agp_versionfunction agp_generic_enablefunction agp_generic_create_gatt_tablefunction agp_generic_free_gatt_tablefunction agp_generic_insert_memoryfunction agp_generic_remove_memoryfunction agp_generic_free_by_typefunction agp_generic_alloc_pagesfunction agp_generic_destroy_pagesfunction agp_generic_destroy_pagefunction agp_enablefunction ipi_handlerfunction global_cache_flushfunction agp_generic_mask_memoryfunction agp_generic_type_to_mask_typefunction agp3_generic_fetch_sizefunction agp3_generic_tlbflushfunction agp3_generic_configurefunction agp3_generic_cleanupexport agp_memory_reservedexport agp_free_keyexport agp_alloc_page_arrayexport agp_create_memoryexport agp_free_memoryexport agp_allocate_memoryexport agp_num_entriesexport agp_copy_infoexport agp_bind_memoryexport agp_unbind_memoryexport agp_collect_device_statusexport agp_device_commandexport get_agp_versionexport agp_generic_enableexport agp_generic_create_gatt_table
Annotated Snippet
if (curr->bridge->driver->agp_destroy_pages) {
curr->bridge->driver->agp_destroy_pages(curr);
} else {
for (i = 0; i < curr->page_count; i++) {
curr->bridge->driver->agp_destroy_page(
curr->pages[i],
AGP_PAGE_DESTROY_UNMAP);
}
for (i = 0; i < curr->page_count; i++) {
curr->bridge->driver->agp_destroy_page(
curr->pages[i],
AGP_PAGE_DESTROY_FREE);
}
}
}
agp_free_key(curr->key);
agp_free_page_array(curr);
kfree(curr);
}
EXPORT_SYMBOL(agp_free_memory);
#define ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(unsigned long))
/**
* agp_allocate_memory - allocate a group of pages of a certain type.
*
* @bridge: an agp_bridge_data struct allocated for the AGP host bridge.
* @page_count: size_t argument of the number of pages
* @type: u32 argument of the type of memory to be allocated.
*
* Every agp bridge device will allow you to allocate AGP_NORMAL_MEMORY which
* maps to physical ram. Any other type is device dependent.
*
* It returns NULL whenever memory is unavailable.
*/
struct agp_memory *agp_allocate_memory(struct agp_bridge_data *bridge,
size_t page_count, u32 type)
{
int scratch_pages;
struct agp_memory *new;
size_t i;
int cur_memory;
if (!bridge)
return NULL;
cur_memory = atomic_read(&bridge->current_memory_agp);
if ((cur_memory + page_count > bridge->max_memory_agp) ||
(cur_memory + page_count < page_count))
return NULL;
if (type >= AGP_USER_TYPES) {
new = agp_generic_alloc_user(page_count, type);
if (new)
new->bridge = bridge;
return new;
}
if (type != 0) {
new = bridge->driver->alloc_by_type(page_count, type);
if (new)
new->bridge = bridge;
return new;
}
scratch_pages = (page_count + ENTRIES_PER_PAGE - 1) / ENTRIES_PER_PAGE;
new = agp_create_memory(scratch_pages);
if (new == NULL)
return NULL;
if (bridge->driver->agp_alloc_pages) {
if (bridge->driver->agp_alloc_pages(bridge, new, page_count)) {
agp_free_memory(new);
return NULL;
}
new->bridge = bridge;
return new;
}
for (i = 0; i < page_count; i++) {
struct page *page = bridge->driver->agp_alloc_page(bridge);
if (page == NULL) {
agp_free_memory(new);
return NULL;
}
new->pages[i] = page;
Annotation
- Immediate include surface: `linux/module.h`, `linux/pci.h`, `linux/pagemap.h`, `linux/miscdevice.h`, `linux/pm.h`, `linux/agp_backend.h`, `linux/vmalloc.h`, `linux/dma-mapping.h`.
- Detected declarations: `function agp_free_key`, `function agp_get_key`, `function agp_alloc_page_array`, `function agp_free_memory`, `function agp_return_size`, `function agp_num_entries`, `function agp_copy_info`, `function agp_bind_memory`, `function agp_unbind_memory`, `function agp_v2_parse_one`.
- Atlas domain: Driver Families / drivers/char.
- Implementation status: integration 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.