STRUCT DRM_PAGEMAP_OPS(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

✨ NAME ✨

okay so bestie, welcome to the struct drm_pagemap_ops(9) page from the Kernel API Manual. The whole name situation is: struct drm_pagemap_ops β€” ops for a drm-pagemap. That's the vibe. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

here's the exact struct shape, no cap β€” function-pointer syntax and all:

       struct drm_pagemap_ops {
           struct drm_pagemap_addr (*device_map)(struct drm_pagemap *dpagemap,
       struct device *dev, struct page *page, unsigned int order, enum
       dma_data_direction dir);
           void (*device_unmap)(struct drm_pagemap *dpagemap, struct device
       *dev, const struct drm_pagemap_addr *addr);
           int (*populate_mm)(struct drm_pagemap *dpagemap, unsigned long
       start, unsigned long end, struct mm_struct *mm, unsigned long
       timeslice_ms);
           void (*destroy)(struct drm_pagemap *dpagemap, bool
       is_atomic_or_reclaim);
        };

πŸŽ€ Members πŸŽ€

okay, member-by-member, because this struct is literally a little squad of callbacks:

  • device_map β€” struct drm_pagemap_addr (*device_map)(struct drm_pagemap *dpagemap, struct device *dev, struct page *page, unsigned int order, enum dma_data_direction dir); The official description is literally: β€œMap for device access or provide a virtual address suitable for”. The params are: dpagemap: the struct drm_pagemap for the page. dev: the device mapper. page: the page to map. order: the page order of the device mapping. (Size is PAGE_SIZE << order.) dir: the transfer direction.
  • device_unmap β€” void (*device_unmap)(struct drm_pagemap *dpagemap, struct device *dev, const struct drm_pagemap_addr *addr); Unmap a device address previously obtained using device_map. The params are: dpagemap: the struct drm_pagemap for the mapping. dev: the device unmapper. addr: the device address obtained when mapping.
  • populate_mm β€” int (*populate_mm)(struct drm_pagemap *dpagemap, unsigned long start, unsigned long end, struct mm_struct *mm, unsigned long timeslice_ms); Populate part of the mm with dpagemap memory, migrating existing data. The params are: dpagemap: the struct drm_pagemap managing the memory. start: the virtual start address in mm. end: the virtual end address in mm. mm: pointer to a live mm. The caller must have an mmget reference.

The caller will have the mm lock at least in read mode. Note that there is no guarantee that the memory is resident after the function returns, it's best effort only. When the mm is not using the memory anymore, it will be released. The struct drm_pagemap might have a mechanism in place to reclaim the memory and the data will then be migrated. Typically to system memory. The implementation should hold sufficient runtime power-references while pages are used in an address space and should ideally guard against hardware device unbind in a way such that device pages are migrated back to system followed by device page removal. The implementation should return -ENODEV after device removal.

Return: 0 if successful. Negative error code on error.

  • destroy β€” void (*destroy)(struct drm_pagemap *dpagemap, bool is_atomic_or_reclaim); Destroy the drm_pagemap and associated resources. The params are: dpagemap: the drm_pagemap to destroy. is_atomic_or_reclaim: the function may be called from atomic- or reclaim context.

The implementation should take care not to attempt to destroy resources that may already have been destroyed using devm_ callbacks, since this function may be called after the underlying struct device has been unbound. If the implementation defers the execution to a work item to avoid locking issues, then it must make sure the work items are flushed before module exit. If the destroy call happens after the provider's pci_remove callback has been executed, a module reference and drm device reference is held across the destroy callback.


🌈 SEE ALSO 🌈

mwah πŸ’– this page was served from ./include/drm, dated October 2026, and you just read struct drm_pagemap_ops(9) β€” periodt. 🫢

πŸ“¦ where this page comes from