drivers/accel/amdxdna/amdxdna_pci_drv.c
Source file repositories/reference/linux-study-clean/drivers/accel/amdxdna/amdxdna_pci_drv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/accel/amdxdna/amdxdna_pci_drv.c- Extension
.c- Size
- 13914 bytes
- Lines
- 492
- Domain
- Driver Families
- Bucket
- drivers/accel
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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
drm/amdxdna_accel.hdrm/drm_accel.hdrm/drm_drv.hdrm/drm_gem.hdrm/drm_gem_shmem_helper.hdrm/drm_ioctl.hdrm/drm_managed.hdrm/gpu_scheduler.hlinux/iommu.hlinux/pci.hamdxdna_cbuf.hamdxdna_ctx.hamdxdna_debugfs.hamdxdna_gem.hamdxdna_pci_drv.hamdxdna_pm.h
Detected Declarations
function amdxdna_sva_initfunction amdxdna_sva_finifunction amdxdna_drm_openfunction amdxdna_client_cleanupfunction amdxdna_drm_closefunction amdxdna_drm_get_info_ioctlfunction amdxdna_drm_get_array_ioctlfunction amdxdna_drm_set_state_ioctlfunction amdxdna_drm_gem_mmapfunction amdxdna_show_fdinfofunction amdxdna_get_dev_infofunction amdxdna_xdna_drm_releasefunction amdxdna_probefunction amdxdna_removefunction amdxdna_sriov_configure
Annotated Snippet
static const struct file_operations amdxdna_fops = {
.owner = THIS_MODULE,
.open = accel_open,
.release = drm_release,
.unlocked_ioctl = drm_ioctl,
.compat_ioctl = drm_compat_ioctl,
.poll = drm_poll,
.read = drm_read,
.llseek = noop_llseek,
.mmap = amdxdna_drm_gem_mmap,
.show_fdinfo = drm_show_fdinfo,
.fop_flags = FOP_UNSIGNED_OFFSET,
};
const struct drm_driver amdxdna_drm_drv = {
.driver_features = DRIVER_GEM | DRIVER_COMPUTE_ACCEL |
DRIVER_SYNCOBJ | DRIVER_SYNCOBJ_TIMELINE,
.fops = &amdxdna_fops,
.name = "amdxdna_accel_driver",
.desc = "AMD XDNA DRM implementation",
.major = AMDXDNA_DRIVER_MAJOR,
.minor = AMDXDNA_DRIVER_MINOR,
.open = amdxdna_drm_open,
.postclose = amdxdna_drm_close,
.ioctls = amdxdna_drm_ioctls,
.num_ioctls = ARRAY_SIZE(amdxdna_drm_ioctls),
.show_fdinfo = amdxdna_show_fdinfo,
.gem_create_object = amdxdna_gem_create_shmem_object_cb,
.gem_prime_import = amdxdna_gem_prime_import,
};
static const struct amdxdna_dev_info *
amdxdna_get_dev_info(struct pci_dev *pdev)
{
int i;
for (i = 0; i < ARRAY_SIZE(amdxdna_ids); i++) {
if (pdev->device == amdxdna_ids[i].device &&
pdev->revision == amdxdna_ids[i].revision)
return amdxdna_ids[i].dev_info;
}
return NULL;
}
static void amdxdna_xdna_drm_release(struct drm_device *drm, void *res)
{
struct amdxdna_dev *xdna = res;
amdxdna_carveout_fini(xdna);
}
static int amdxdna_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{
struct device *dev = &pdev->dev;
struct amdxdna_dev *xdna;
struct drm_device *ddev;
int ret;
xdna = devm_drm_dev_alloc(dev, &amdxdna_drm_drv, typeof(*xdna), ddev);
if (IS_ERR(xdna))
return PTR_ERR(xdna);
ddev = &xdna->ddev;
xdna->dev_info = amdxdna_get_dev_info(pdev);
if (!xdna->dev_info)
return -ENODEV;
drmm_mutex_init(ddev, &xdna->dev_lock);
init_rwsem(&xdna->notifier_lock);
INIT_LIST_HEAD(&xdna->client_list);
pci_set_drvdata(pdev, xdna);
ret = drmm_add_action(ddev, amdxdna_xdna_drm_release, xdna);
if (ret)
return ret;
if (IS_ENABLED(CONFIG_LOCKDEP)) {
fs_reclaim_acquire(GFP_KERNEL);
might_lock(&xdna->notifier_lock);
fs_reclaim_release(GFP_KERNEL);
}
ret = amdxdna_iommu_init(xdna);
if (ret)
return ret;
xdna->notifier_wq = alloc_ordered_workqueue("notifier_wq", WQ_MEM_RECLAIM);
if (!xdna->notifier_wq) {
ret = -ENOMEM;
goto iommu_fini;
Annotation
- Immediate include surface: `drm/amdxdna_accel.h`, `drm/drm_accel.h`, `drm/drm_drv.h`, `drm/drm_gem.h`, `drm/drm_gem_shmem_helper.h`, `drm/drm_ioctl.h`, `drm/drm_managed.h`, `drm/gpu_scheduler.h`.
- Detected declarations: `function amdxdna_sva_init`, `function amdxdna_sva_fini`, `function amdxdna_drm_open`, `function amdxdna_client_cleanup`, `function amdxdna_drm_close`, `function amdxdna_drm_get_info_ioctl`, `function amdxdna_drm_get_array_ioctl`, `function amdxdna_drm_set_state_ioctl`, `function amdxdna_drm_gem_mmap`, `function amdxdna_show_fdinfo`.
- Atlas domain: Driver Families / drivers/accel.
- Implementation status: pattern 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.