drivers/char/agp/intel-gtt.c
Source file repositories/reference/linux-study-clean/drivers/char/agp/intel-gtt.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/agp/intel-gtt.c- Extension
.c- Size
- 38956 bytes
- Lines
- 1521
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/kernel.hlinux/pagemap.hlinux/agp_backend.hlinux/iommu.hlinux/delay.hasm/smp.hagp.hintel-agp.hdrm/intel/intel-gtt.hasm/set_memory.h
Detected Declarations
struct intel_gtt_driverfunction intel_gtt_map_memoryfunction intel_gtt_unmap_memoryfunction intel_fake_agp_enablefunction i8xx_destroy_pagesfunction i810_setupfunction i810_cleanupfunction i810_insert_dcache_entriesfunction intel_i810_free_by_typefunction intel_gtt_setup_scratch_pagefunction i810_write_entryfunction i810_read_entryfunction intel_gtt_stolen_sizefunction i965_adjust_pgetbl_sizefunction i965_gtt_total_entriesfunction intel_gtt_total_entriesfunction intel_gtt_mappable_entriesfunction intel_gtt_teardown_scratch_pagefunction intel_gtt_cleanupfunction needs_ilk_vtd_wafunction intel_gtt_can_wcfunction intel_gtt_initfunction intel_fake_agp_fetch_sizefunction i830_cleanupfunction i830_write_entryfunction i830_read_entryfunction intel_gmch_enable_gttfunction i830_setupfunction intel_fake_agp_create_gatt_tablefunction intel_fake_agp_free_gatt_tablefunction intel_fake_agp_configurefunction i830_check_flagsfunction intel_gmch_gtt_insert_pagefunction intel_gmch_gtt_insert_sg_entriesfunction intel_gmch_gtt_read_entryfunction intel_gmch_gtt_insert_pagesfunction intel_fake_agp_insert_entriesfunction intel_gmch_gtt_clear_rangefunction intel_fake_agp_remove_entriesfunction intel_alloc_chipset_flush_resourcefunction intel_i915_setup_chipset_flushfunction intel_i965_g33_setup_chipset_flushfunction intel_i9xx_setup_flushfunction i9xx_cleanupfunction i9xx_chipset_flushfunction i965_write_entryfunction i965_read_entryfunction i9xx_setup
Annotated Snippet
struct intel_gtt_driver {
unsigned int gen : 8;
unsigned int is_g33 : 1;
unsigned int is_pineview : 1;
unsigned int is_ironlake : 1;
unsigned int has_pgtbl_enable : 1;
unsigned int dma_mask_size : 8;
/* Chipset specific GTT setup */
int (*setup)(void);
/* This should undo anything done in ->setup() save the unmapping
* of the mmio register file, that's done in the generic code. */
void (*cleanup)(void);
void (*write_entry)(dma_addr_t addr, unsigned int entry, unsigned int flags);
dma_addr_t (*read_entry)(unsigned int entry, bool *is_present, bool *is_local);
/* Flags is a more or less chipset specific opaque value.
* For chipsets that need to support old ums (non-gem) code, this
* needs to be identical to the various supported agp memory types! */
bool (*check_flags)(unsigned int flags);
void (*chipset_flush)(void);
};
static struct _intel_private {
const struct intel_gtt_driver *driver;
struct pci_dev *pcidev; /* device one */
struct pci_dev *bridge_dev;
u8 __iomem *registers;
phys_addr_t gtt_phys_addr;
u32 PGETBL_save;
u32 __iomem *gtt; /* I915G */
bool clear_fake_agp; /* on first access via agp, fill with scratch */
int num_dcache_entries;
void __iomem *i9xx_flush_page;
char *i81x_gtt_table;
struct resource ifp_resource;
int resource_valid;
struct page *scratch_page;
phys_addr_t scratch_page_dma;
int refcount;
/* Whether i915 needs to use the dmar apis or not. */
unsigned int needs_dmar : 1;
phys_addr_t gma_bus_addr;
/* Size of memory reserved for graphics by the BIOS */
resource_size_t stolen_size;
/* Total number of gtt entries. */
unsigned int gtt_total_entries;
/* Part of the gtt that is mappable by the cpu, for those chips where
* this is not the full gtt. */
unsigned int gtt_mappable_entries;
} intel_private;
#define INTEL_GTT_GEN intel_private.driver->gen
#define IS_G33 intel_private.driver->is_g33
#define IS_PINEVIEW intel_private.driver->is_pineview
#define IS_IRONLAKE intel_private.driver->is_ironlake
#define HAS_PGTBL_EN intel_private.driver->has_pgtbl_enable
#if IS_ENABLED(CONFIG_AGP_INTEL)
static int intel_gtt_map_memory(struct page **pages,
unsigned int num_entries,
struct sg_table *st)
{
struct scatterlist *sg;
int i;
DBG("try mapping %lu pages\n", (unsigned long)num_entries);
if (sg_alloc_table(st, num_entries, GFP_KERNEL))
goto err;
for_each_sg(st->sgl, sg, num_entries, i)
sg_set_page(sg, pages[i], PAGE_SIZE, 0);
if (!dma_map_sg(&intel_private.pcidev->dev, st->sgl, st->nents,
DMA_BIDIRECTIONAL))
goto err;
return 0;
err:
sg_free_table(st);
return -ENOMEM;
}
static void intel_gtt_unmap_memory(struct scatterlist *sg_list, int num_sg)
{
struct sg_table st;
DBG("try unmapping %lu pages\n", (unsigned long)mem->page_count);
dma_unmap_sg(&intel_private.pcidev->dev, sg_list, num_sg,
DMA_BIDIRECTIONAL);
Annotation
- Immediate include surface: `linux/module.h`, `linux/pci.h`, `linux/kernel.h`, `linux/pagemap.h`, `linux/agp_backend.h`, `linux/iommu.h`, `linux/delay.h`, `asm/smp.h`.
- Detected declarations: `struct intel_gtt_driver`, `function intel_gtt_map_memory`, `function intel_gtt_unmap_memory`, `function intel_fake_agp_enable`, `function i8xx_destroy_pages`, `function i810_setup`, `function i810_cleanup`, `function i810_insert_dcache_entries`, `function intel_i810_free_by_type`, `function intel_gtt_setup_scratch_page`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.