drivers/vdpa/pds/vdpa_dev.c
Source file repositories/reference/linux-study-clean/drivers/vdpa/pds/vdpa_dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/vdpa/pds/vdpa_dev.c- Extension
.c- Size
- 23023 bytes
- Lines
- 860
- Domain
- Driver Families
- Bucket
- drivers/vdpa
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/pci.hlinux/vdpa.huapi/linux/vdpa.hlinux/virtio_pci_modern.hlinux/pds/pds_common.hlinux/pds/pds_core_if.hlinux/pds/pds_adminq.hlinux/pds/pds_auxbus.hvdpa_dev.haux_drv.hcmds.hdebugfs.h
Detected Declarations
function pds_vdpa_notify_handlerfunction pds_vdpa_register_event_handlerfunction pds_vdpa_unregister_event_handlerfunction pds_vdpa_set_vq_addressfunction pds_vdpa_set_vq_numfunction pds_vdpa_kick_vqfunction pds_vdpa_set_vq_cbfunction pds_vdpa_isrfunction pds_vdpa_release_irqfunction pds_vdpa_set_vq_readyfunction pds_vdpa_get_vq_readyfunction pds_vdpa_set_vq_statefunction pds_vdpa_get_vq_statefunction pds_vdpa_get_vq_notificationfunction pds_vdpa_get_vq_irqfunction pds_vdpa_get_vq_alignfunction pds_vdpa_get_vq_groupfunction pds_vdpa_get_device_featuresfunction pds_vdpa_set_driver_featuresfunction pds_vdpa_get_driver_featuresfunction pds_vdpa_set_config_cbfunction pds_vdpa_get_vq_num_maxfunction pds_vdpa_get_device_idfunction pds_vdpa_get_vendor_idfunction pds_vdpa_get_statusfunction pds_vdpa_request_irqsfunction pds_vdpa_release_irqsfunction pds_vdpa_set_statusfunction pds_vdpa_init_vqs_entryfunction pds_vdpa_resetfunction pds_vdpa_get_config_sizefunction pds_vdpa_get_configfunction pds_vdpa_set_configfunction pds_vdpa_dev_addfunction pds_vdpa_dev_delfunction pds_vdpa_get_mgmt_info
Annotated Snippet
if (err) {
nb->notifier_call = NULL;
dev_err(dev, "failed to register pds event handler: %pe\n",
ERR_PTR(err));
return -EINVAL;
}
dev_dbg(dev, "pds event handler registered\n");
}
return 0;
}
static void pds_vdpa_unregister_event_handler(struct pds_vdpa_device *pdsv)
{
if (pdsv->nb.notifier_call) {
pdsc_unregister_notify(&pdsv->nb);
pdsv->nb.notifier_call = NULL;
}
}
static int pds_vdpa_set_vq_address(struct vdpa_device *vdpa_dev, u16 qid,
u64 desc_addr, u64 driver_addr, u64 device_addr)
{
struct pds_vdpa_device *pdsv = vdpa_to_pdsv(vdpa_dev);
pdsv->vqs[qid].desc_addr = desc_addr;
pdsv->vqs[qid].avail_addr = driver_addr;
pdsv->vqs[qid].used_addr = device_addr;
return 0;
}
static void pds_vdpa_set_vq_num(struct vdpa_device *vdpa_dev, u16 qid, u32 num)
{
struct pds_vdpa_device *pdsv = vdpa_to_pdsv(vdpa_dev);
pdsv->vqs[qid].q_len = num;
}
static void pds_vdpa_kick_vq(struct vdpa_device *vdpa_dev, u16 qid)
{
struct pds_vdpa_device *pdsv = vdpa_to_pdsv(vdpa_dev);
iowrite16(qid, pdsv->vqs[qid].notify);
}
static void pds_vdpa_set_vq_cb(struct vdpa_device *vdpa_dev, u16 qid,
struct vdpa_callback *cb)
{
struct pds_vdpa_device *pdsv = vdpa_to_pdsv(vdpa_dev);
pdsv->vqs[qid].event_cb = *cb;
}
static irqreturn_t pds_vdpa_isr(int irq, void *data)
{
struct pds_vdpa_vq_info *vq;
vq = data;
if (vq->event_cb.callback)
vq->event_cb.callback(vq->event_cb.private);
return IRQ_HANDLED;
}
static void pds_vdpa_release_irq(struct pds_vdpa_device *pdsv, int qid)
{
if (pdsv->vqs[qid].irq == VIRTIO_MSI_NO_VECTOR)
return;
free_irq(pdsv->vqs[qid].irq, &pdsv->vqs[qid]);
pdsv->vqs[qid].irq = VIRTIO_MSI_NO_VECTOR;
}
static void pds_vdpa_set_vq_ready(struct vdpa_device *vdpa_dev, u16 qid, bool ready)
{
struct pds_vdpa_device *pdsv = vdpa_to_pdsv(vdpa_dev);
struct device *dev = &pdsv->vdpa_dev.dev;
u64 driver_features;
u16 invert_idx = 0;
int err;
dev_dbg(dev, "%s: qid %d ready %d => %d\n",
__func__, qid, pdsv->vqs[qid].ready, ready);
if (ready == pdsv->vqs[qid].ready)
return;
driver_features = pds_vdpa_get_driver_features(vdpa_dev);
if (driver_features & BIT_ULL(VIRTIO_F_RING_PACKED))
invert_idx = PDS_VDPA_PACKED_INVERT_IDX;
Annotation
- Immediate include surface: `linux/pci.h`, `linux/vdpa.h`, `uapi/linux/vdpa.h`, `linux/virtio_pci_modern.h`, `linux/pds/pds_common.h`, `linux/pds/pds_core_if.h`, `linux/pds/pds_adminq.h`, `linux/pds/pds_auxbus.h`.
- Detected declarations: `function pds_vdpa_notify_handler`, `function pds_vdpa_register_event_handler`, `function pds_vdpa_unregister_event_handler`, `function pds_vdpa_set_vq_address`, `function pds_vdpa_set_vq_num`, `function pds_vdpa_kick_vq`, `function pds_vdpa_set_vq_cb`, `function pds_vdpa_isr`, `function pds_vdpa_release_irq`, `function pds_vdpa_set_vq_ready`.
- Atlas domain: Driver Families / drivers/vdpa.
- Implementation status: source implementation candidate.
- 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.