drivers/pci/ats.c
Source file repositories/reference/linux-study-clean/drivers/pci/ats.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/pci/ats.c- Extension
.c- Size
- 14001 bytes
- Lines
- 622
- Domain
- Representative Device Path
- Bucket
- PCIe NVMe Storage Path
- Inferred role
- Representative Device Path: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Part of the selected hardware vertical slice: PCI discovery, driver binding, NVMe queues, block requests, DMA, interrupts, and completion.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bitfield.hlinux/export.hlinux/pci-ats.hlinux/pci.hlinux/slab.hpci.h
Detected Declarations
function Copyrightfunction pci_ats_supportedfunction pci_prepare_atsfunction pci_enable_atsfunction pci_disable_atsfunction pci_restore_ats_statefunction functionsfunction pci_ats_page_alignedfunction pci_cxl_ats_requiredfunction pci_ats_requiredfunction pci_pri_initfunction pci_enable_prifunction pci_disable_prifunction pci_restore_pri_statefunction pci_reset_prifunction pci_prg_resp_pasid_requiredfunction pci_pri_supportedfunction pci_pasid_initfunction pci_enable_pasidfunction pci_disable_pasidfunction pci_restore_pasid_statefunction pci_pasid_featuresfunction pci_max_pasidsfunction pci_pasid_statusexport pci_ats_supportedexport pci_prepare_atsexport pci_enable_atsexport pci_disable_atsexport pci_ats_requiredexport pci_disable_priexport pci_pri_supportedexport pci_enable_pasidexport pci_disable_pasidexport pci_pasid_featuresexport pci_max_pasidsexport pci_pasid_status
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* PCI Express I/O Virtualization (IOV) support
* Address Translation Service 1.0
* Page Request Interface added by Joerg Roedel <joerg.roedel@amd.com>
* PASID support added by Joerg Roedel <joerg.roedel@amd.com>
*
* Copyright (C) 2009 Intel Corporation, Yu Zhao <yu.zhao@intel.com>
* Copyright (C) 2011 Advanced Micro Devices,
*/
#include <linux/bitfield.h>
#include <linux/export.h>
#include <linux/pci-ats.h>
#include <linux/pci.h>
#include <linux/slab.h>
#include "pci.h"
void pci_ats_init(struct pci_dev *dev)
{
int pos;
if (pci_ats_disabled())
return;
pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ATS);
if (!pos)
return;
dev->ats_cap = pos;
}
/**
* pci_ats_supported - check if the device can use ATS
* @dev: the PCI device
*
* Returns true if the device supports ATS and is allowed to use it, false
* otherwise.
*/
bool pci_ats_supported(struct pci_dev *dev)
{
if (!dev->ats_cap)
return false;
return (dev->untrusted == 0);
}
EXPORT_SYMBOL_GPL(pci_ats_supported);
/**
* pci_prepare_ats - Setup the PS for ATS
* @dev: the PCI device
* @ps: the IOMMU page shift
*
* This must be done by the IOMMU driver on the PF before any VFs are created to
* ensure that the VF can have ATS enabled.
*
* Returns 0 on success, or negative on failure.
*/
int pci_prepare_ats(struct pci_dev *dev, int ps)
{
u16 ctrl;
if (!pci_ats_supported(dev))
return -EINVAL;
if (WARN_ON(dev->ats_enabled))
return -EBUSY;
if (ps < PCI_ATS_MIN_STU)
return -EINVAL;
if (dev->is_virtfn)
return 0;
dev->ats_stu = ps;
ctrl = PCI_ATS_CTRL_STU(dev->ats_stu - PCI_ATS_MIN_STU);
pci_write_config_word(dev, dev->ats_cap + PCI_ATS_CTRL, ctrl);
return 0;
}
EXPORT_SYMBOL_GPL(pci_prepare_ats);
/**
* pci_enable_ats - enable the ATS capability
* @dev: the PCI device
* @ps: the IOMMU page shift
*
* Returns 0 on success, or negative on failure.
*/
int pci_enable_ats(struct pci_dev *dev, int ps)
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/export.h`, `linux/pci-ats.h`, `linux/pci.h`, `linux/slab.h`, `pci.h`.
- Detected declarations: `function Copyright`, `function pci_ats_supported`, `function pci_prepare_ats`, `function pci_enable_ats`, `function pci_disable_ats`, `function pci_restore_ats_state`, `function functions`, `function pci_ats_page_aligned`, `function pci_cxl_ats_required`, `function pci_ats_required`.
- Atlas domain: Representative Device Path / PCIe NVMe Storage Path.
- Implementation status: integration implementation candidate.
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.