drivers/remoteproc/remoteproc_virtio.c
Source file repositories/reference/linux-study-clean/drivers/remoteproc/remoteproc_virtio.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/remoteproc/remoteproc_virtio.c- Extension
.c- Size
- 15335 bytes
- Lines
- 602
- Domain
- Driver Families
- Bucket
- drivers/remoteproc
- 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.
- 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/dma-direct.hlinux/dma-map-ops.hlinux/dma-mapping.hlinux/export.hlinux/of_reserved_mem.hlinux/platform_device.hlinux/remoteproc.hlinux/virtio.hlinux/virtio_config.hlinux/virtio_ids.hlinux/virtio_ring.hlinux/err.hlinux/kref.hlinux/slab.hremoteproc_internal.h
Detected Declarations
function transportfunction rproc_virtio_notifyfunction rproc_vq_interruptfunction voidfunction __rproc_virtio_del_vqsfunction list_for_each_entry_safefunction rproc_virtio_del_vqsfunction rproc_virtio_find_vqsfunction rproc_virtio_get_statusfunction rproc_virtio_set_statusfunction rproc_virtio_resetfunction rproc_virtio_get_featuresfunction rproc_transport_featuresfunction rproc_virtio_finalize_featuresfunction rproc_virtio_getfunction rproc_virtio_setfunction rproc_virtio_dev_releasefunction rproc_add_virtio_devfunction rproc_remove_virtio_devfunction rproc_vdev_do_startfunction rproc_vdev_do_stopfunction rproc_virtio_probefunction rproc_virtio_removeexport rproc_vq_interrupt
Annotated Snippet
if (!vqi->name) {
vqs[i] = NULL;
continue;
}
vqs[i] = rp_find_vq(vdev, queue_idx++, vqi->callback,
vqi->name, vqi->ctx);
if (IS_ERR(vqs[i])) {
ret = PTR_ERR(vqs[i]);
goto error;
}
}
return 0;
error:
__rproc_virtio_del_vqs(vdev);
return ret;
}
static u8 rproc_virtio_get_status(struct virtio_device *vdev)
{
struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
struct fw_rsc_vdev *rsc;
rsc = (void *)rvdev->rproc->table_ptr + rvdev->rsc_offset;
return rsc->status;
}
static void rproc_virtio_set_status(struct virtio_device *vdev, u8 status)
{
struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
struct fw_rsc_vdev *rsc;
rsc = (void *)rvdev->rproc->table_ptr + rvdev->rsc_offset;
rsc->status = status;
dev_dbg(&vdev->dev, "status: %d\n", status);
}
static void rproc_virtio_reset(struct virtio_device *vdev)
{
struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
struct fw_rsc_vdev *rsc;
rsc = (void *)rvdev->rproc->table_ptr + rvdev->rsc_offset;
rsc->status = 0;
dev_dbg(&vdev->dev, "reset !\n");
}
/* provide the vdev features as retrieved from the firmware */
static u64 rproc_virtio_get_features(struct virtio_device *vdev)
{
struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
struct fw_rsc_vdev *rsc;
rsc = (void *)rvdev->rproc->table_ptr + rvdev->rsc_offset;
return rsc->dfeatures;
}
static void rproc_transport_features(struct virtio_device *vdev)
{
/*
* Packed ring isn't enabled on remoteproc for now,
* because remoteproc uses vring_new_virtqueue() which
* creates virtio rings on preallocated memory.
*/
__virtio_clear_bit(vdev, VIRTIO_F_RING_PACKED);
}
static int rproc_virtio_finalize_features(struct virtio_device *vdev)
{
struct rproc_vdev *rvdev = vdev_to_rvdev(vdev);
struct fw_rsc_vdev *rsc;
rsc = (void *)rvdev->rproc->table_ptr + rvdev->rsc_offset;
/* Give virtio_ring a chance to accept features */
vring_transport_features(vdev);
/* Give virtio_rproc a chance to accept features. */
rproc_transport_features(vdev);
/* Make sure we don't have any features > 32 bits! */
BUG_ON((u32)vdev->features != vdev->features);
/*
Annotation
- Immediate include surface: `linux/dma-direct.h`, `linux/dma-map-ops.h`, `linux/dma-mapping.h`, `linux/export.h`, `linux/of_reserved_mem.h`, `linux/platform_device.h`, `linux/remoteproc.h`, `linux/virtio.h`.
- Detected declarations: `function transport`, `function rproc_virtio_notify`, `function rproc_vq_interrupt`, `function void`, `function __rproc_virtio_del_vqs`, `function list_for_each_entry_safe`, `function rproc_virtio_del_vqs`, `function rproc_virtio_find_vqs`, `function rproc_virtio_get_status`, `function rproc_virtio_set_status`.
- Atlas domain: Driver Families / drivers/remoteproc.
- Implementation status: integration 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.