drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c
Source file repositories/reference/linux-study-clean/drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c- Extension
.c- Size
- 110917 bytes
- Lines
- 4014
- Domain
- Driver Families
- Bucket
- drivers/platform
- 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.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/types.hlinux/completion.hlinux/mutex.hlinux/bitops.hlinux/io.hlinux/highmem.hlinux/kthread.hlinux/wait.hlinux/delay.hlinux/slab.hlinux/kref.hlinux/rcupdate.hlinux/sched/signal.hlinux/raspberrypi/vchiq_arm.hlinux/raspberrypi/vchiq_core.h
Detected Declarations
struct vchiq_open_payloadstruct vchiq_openack_payloadfunction check_sizesfunction set_service_statefunction find_service_by_handlefunction kref_get_unless_zerofunction find_service_by_portfunction find_service_for_instancefunction kref_get_unless_zerofunction find_closed_service_for_instancefunction kref_get_unless_zerofunction __next_service_by_instancefunction next_service_by_instancefunction vchiq_service_getfunction service_releasefunction vchiq_service_putfunction vchiq_get_client_idfunction vchiq_get_service_userdatafunction mark_service_closing_internalfunction mark_service_closingfunction make_service_callbackfunction vchiq_set_conn_statefunction remote_event_createfunction remote_event_waitfunction remote_event_signalfunction remote_event_signal_localfunction remote_event_pollfunction remote_event_pollallfunction calc_stridefunction get_listening_servicefunction get_connected_servicefunction request_pollfunction reserve_spacefunction process_free_data_messagefunction process_free_queuefunction memcpy_copy_callbackfunction copy_message_datafunction queue_messagefunction queue_message_syncfunction claim_slotfunction release_slotfunction get_bulk_reasonfunction service_notify_bulkfunction notify_bulksfunction poll_services_of_groupfunction poll_servicesfunction cleanup_pagelistinfofunction is_adjacent_block
Annotated Snippet
struct vchiq_open_payload {
int fourcc;
int client_id;
short version;
short version_min;
};
struct vchiq_openack_payload {
short version;
};
enum {
QMFLAGS_IS_BLOCKING = BIT(0),
QMFLAGS_NO_MUTEX_LOCK = BIT(1),
QMFLAGS_NO_MUTEX_UNLOCK = BIT(2)
};
enum {
VCHIQ_POLL_TERMINATE,
VCHIQ_POLL_REMOVE,
VCHIQ_POLL_TXNOTIFY,
VCHIQ_POLL_RXNOTIFY,
VCHIQ_POLL_COUNT
};
/* we require this for consistency between endpoints */
static_assert(sizeof(struct vchiq_header) == 8);
static_assert(VCHIQ_VERSION >= VCHIQ_VERSION_MIN);
static inline void check_sizes(void)
{
BUILD_BUG_ON_NOT_POWER_OF_2(VCHIQ_SLOT_SIZE);
BUILD_BUG_ON_NOT_POWER_OF_2(VCHIQ_MAX_SLOTS);
BUILD_BUG_ON_NOT_POWER_OF_2(VCHIQ_MAX_SLOTS_PER_SIDE);
BUILD_BUG_ON_NOT_POWER_OF_2(sizeof(struct vchiq_header));
BUILD_BUG_ON_NOT_POWER_OF_2(VCHIQ_NUM_CURRENT_BULKS);
BUILD_BUG_ON_NOT_POWER_OF_2(VCHIQ_NUM_SERVICE_BULKS);
BUILD_BUG_ON_NOT_POWER_OF_2(VCHIQ_MAX_SERVICES);
}
static unsigned int handle_seq;
static const char *const srvstate_names[] = {
"FREE",
"HIDDEN",
"LISTENING",
"OPENING",
"OPEN",
"OPENSYNC",
"CLOSESENT",
"CLOSERECVD",
"CLOSEWAIT",
"CLOSED"
};
static const char *const reason_names[] = {
"SERVICE_OPENED",
"SERVICE_CLOSED",
"MESSAGE_AVAILABLE",
"BULK_TRANSMIT_DONE",
"BULK_RECEIVE_DONE",
"BULK_TRANSMIT_ABORTED",
"BULK_RECEIVE_ABORTED"
};
static const char *const conn_state_names[] = {
"DISCONNECTED",
"CONNECTING",
"CONNECTED",
"PAUSING",
"PAUSE_SENT",
"PAUSED",
"RESUMING",
"PAUSE_TIMEOUT",
"RESUME_TIMEOUT"
};
static void
release_message_sync(struct vchiq_state *state, struct vchiq_header *header);
static const char *msg_type_str(unsigned int msg_type)
{
switch (msg_type) {
case VCHIQ_MSG_PADDING: return "PADDING";
case VCHIQ_MSG_CONNECT: return "CONNECT";
case VCHIQ_MSG_OPEN: return "OPEN";
case VCHIQ_MSG_OPENACK: return "OPENACK";
case VCHIQ_MSG_CLOSE: return "CLOSE";
case VCHIQ_MSG_DATA: return "DATA";
case VCHIQ_MSG_BULK_RX: return "BULK_RX";
Annotation
- Immediate include surface: `linux/types.h`, `linux/completion.h`, `linux/mutex.h`, `linux/bitops.h`, `linux/io.h`, `linux/highmem.h`, `linux/kthread.h`, `linux/wait.h`.
- Detected declarations: `struct vchiq_open_payload`, `struct vchiq_openack_payload`, `function check_sizes`, `function set_service_state`, `function find_service_by_handle`, `function kref_get_unless_zero`, `function find_service_by_port`, `function find_service_for_instance`, `function kref_get_unless_zero`, `function find_closed_service_for_instance`.
- Atlas domain: Driver Families / drivers/platform.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- 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.