drivers/rpmsg/mtk_rpmsg.c
Source file repositories/reference/linux-study-clean/drivers/rpmsg/mtk_rpmsg.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rpmsg/mtk_rpmsg.c- Extension
.c- Size
- 10702 bytes
- Lines
- 411
- Domain
- Driver Families
- Bucket
- drivers/rpmsg
- 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.
- 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/kernel.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/remoteproc.hlinux/rpmsg/mtk_rpmsg.hlinux/slab.hlinux/workqueue.hrpmsg_internal.h
Detected Declarations
struct mtk_rpmsg_rproc_subdevstruct mtk_rpmsg_channel_infostruct rpmsg_ns_msgstruct mtk_rpmsg_devicestruct mtk_rpmsg_endpointfunction __mtk_ept_releasefunction mtk_rpmsg_ipi_handlerfunction __mtk_create_eptfunction mtk_rpmsg_create_eptfunction mtk_rpmsg_destroy_eptfunction mtk_rpmsg_sendfunction mtk_rpmsg_trysendfunction mtk_rpmsg_release_devicefunction mtk_rpmsg_match_device_subnodefunction for_each_available_child_of_nodefunction mtk_rpmsg_register_devicefunction mtk_register_device_work_functionfunction mtk_rpmsg_create_devicefunction mtk_rpmsg_ns_cbfunction mtk_rpmsg_preparefunction mtk_rpmsg_unpreparefunction mtk_rpmsg_stopfunction list_for_each_entry_safefunction mtk_rpmsg_create_rproc_subdevfunction mtk_rpmsg_destroy_rproc_subdevexport mtk_rpmsg_create_rproc_subdevexport mtk_rpmsg_destroy_rproc_subdev
Annotated Snippet
struct mtk_rpmsg_rproc_subdev {
struct platform_device *pdev;
struct mtk_rpmsg_info *info;
struct rpmsg_endpoint *ns_ept;
struct rproc_subdev subdev;
struct work_struct register_work;
struct list_head channels;
struct mutex channels_lock;
};
#define to_mtk_subdev(d) container_of(d, struct mtk_rpmsg_rproc_subdev, subdev)
struct mtk_rpmsg_channel_info {
struct rpmsg_channel_info info;
bool registered;
struct list_head list;
};
/**
* struct rpmsg_ns_msg - dynamic name service announcement message
* @name: name of remote service that is published
* @addr: address of remote service that is published
*
* This message is sent across to publish a new service. When we receive these
* messages, an appropriate rpmsg channel (i.e device) is created. In turn, the
* ->probe() handler of the appropriate rpmsg driver will be invoked
* (if/as-soon-as one is registered).
*/
struct rpmsg_ns_msg {
char name[RPMSG_NAME_SIZE];
u32 addr;
} __packed;
struct mtk_rpmsg_device {
struct rpmsg_device rpdev;
struct mtk_rpmsg_rproc_subdev *mtk_subdev;
};
struct mtk_rpmsg_endpoint {
struct rpmsg_endpoint ept;
struct mtk_rpmsg_rproc_subdev *mtk_subdev;
};
#define to_mtk_rpmsg_device(r) container_of(r, struct mtk_rpmsg_device, rpdev)
#define to_mtk_rpmsg_endpoint(r) container_of(r, struct mtk_rpmsg_endpoint, ept)
static const struct rpmsg_endpoint_ops mtk_rpmsg_endpoint_ops;
static void __mtk_ept_release(struct kref *kref)
{
struct rpmsg_endpoint *ept = container_of(kref, struct rpmsg_endpoint,
refcount);
kfree(to_mtk_rpmsg_endpoint(ept));
}
static void mtk_rpmsg_ipi_handler(void *data, unsigned int len, void *priv)
{
struct mtk_rpmsg_endpoint *mept = priv;
struct rpmsg_endpoint *ept = &mept->ept;
int ret;
ret = (*ept->cb)(ept->rpdev, data, len, ept->priv, ept->addr);
if (ret)
dev_warn(&ept->rpdev->dev, "rpmsg handler return error = %d",
ret);
}
static struct rpmsg_endpoint *
__mtk_create_ept(struct mtk_rpmsg_rproc_subdev *mtk_subdev,
struct rpmsg_device *rpdev, rpmsg_rx_cb_t cb, void *priv,
u32 id)
{
struct mtk_rpmsg_endpoint *mept;
struct rpmsg_endpoint *ept;
struct platform_device *pdev = mtk_subdev->pdev;
int ret;
mept = kzalloc_obj(*mept);
if (!mept)
return NULL;
mept->mtk_subdev = mtk_subdev;
ept = &mept->ept;
kref_init(&ept->refcount);
ept->rpdev = rpdev;
ept->cb = cb;
ept->priv = priv;
ept->ops = &mtk_rpmsg_endpoint_ops;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/of.h`, `linux/platform_device.h`, `linux/remoteproc.h`, `linux/rpmsg/mtk_rpmsg.h`, `linux/slab.h`, `linux/workqueue.h`.
- Detected declarations: `struct mtk_rpmsg_rproc_subdev`, `struct mtk_rpmsg_channel_info`, `struct rpmsg_ns_msg`, `struct mtk_rpmsg_device`, `struct mtk_rpmsg_endpoint`, `function __mtk_ept_release`, `function mtk_rpmsg_ipi_handler`, `function __mtk_create_ept`, `function mtk_rpmsg_create_ept`, `function mtk_rpmsg_destroy_ept`.
- Atlas domain: Driver Families / drivers/rpmsg.
- Implementation status: integration 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.