drivers/soc/qcom/smd-rpm.c
Source file repositories/reference/linux-study-clean/drivers/soc/qcom/smd-rpm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/qcom/smd-rpm.c- Extension
.c- Size
- 6870 bytes
- Lines
- 273
- Domain
- Driver Families
- Bucket
- drivers/soc
- 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/module.hlinux/platform_device.hlinux/of_platform.hlinux/io.hlinux/interrupt.hlinux/slab.hlinux/rpmsg.hlinux/soc/qcom/smd-rpm.h
Detected Declarations
struct qcom_smd_rpmstruct qcom_rpm_headerstruct qcom_rpm_requeststruct qcom_rpm_messagefunction qcom_rpm_smd_writefunction qcom_smd_rpm_callbackfunction qcom_smd_rpm_probefunction qcom_smd_rpm_removefunction qcom_smd_rpm_initfunction qcom_smd_rpm_exitexport qcom_rpm_smd_write
Annotated Snippet
struct qcom_smd_rpm {
struct rpmsg_endpoint *rpm_channel;
struct device *dev;
struct completion ack;
struct mutex lock;
int ack_status;
};
/**
* struct qcom_rpm_header - header for all rpm requests and responses
* @service_type: identifier of the service
* @length: length of the payload
*/
struct qcom_rpm_header {
__le32 service_type;
__le32 length;
};
/**
* struct qcom_rpm_request - request message to the rpm
* @msg_id: identifier of the outgoing message
* @flags: active/sleep state flags
* @type: resource type
* @id: resource id
* @data_len: length of the payload following this header
*/
struct qcom_rpm_request {
__le32 msg_id;
__le32 flags;
__le32 type;
__le32 id;
__le32 data_len;
};
/**
* struct qcom_rpm_message - response message from the rpm
* @msg_type: indicator of the type of message
* @length: the size of this message, including the message header
* @msg_id: message id
* @message: textual message from the rpm
*
* Multiple of these messages can be stacked in an rpm message.
*/
struct qcom_rpm_message {
__le32 msg_type;
__le32 length;
union {
__le32 msg_id;
DECLARE_FLEX_ARRAY(u8, message);
};
};
#define RPM_SERVICE_TYPE_REQUEST 0x00716572 /* "req\0" */
#define RPM_MSG_TYPE_ERR 0x00727265 /* "err\0" */
#define RPM_MSG_TYPE_MSG_ID 0x2367736d /* "msg#" */
/**
* qcom_rpm_smd_write - write @buf to @type:@id
* @rpm: rpm handle
* @state: active/sleep state flags
* @type: resource type
* @id: resource identifier
* @buf: the data to be written
* @count: number of bytes in @buf
*/
int qcom_rpm_smd_write(struct qcom_smd_rpm *rpm,
int state,
u32 type, u32 id,
void *buf,
size_t count)
{
static unsigned msg_id = 1;
int left;
int ret;
struct {
struct qcom_rpm_header hdr;
struct qcom_rpm_request req;
u8 payload[];
} *pkt;
size_t size = sizeof(*pkt) + count;
/* SMD packets to the RPM may not exceed 256 bytes */
if (WARN_ON(size >= 256))
return -EINVAL;
pkt = kmalloc(size, GFP_ATOMIC);
if (!pkt)
return -ENOMEM;
Annotation
- Immediate include surface: `linux/module.h`, `linux/platform_device.h`, `linux/of_platform.h`, `linux/io.h`, `linux/interrupt.h`, `linux/slab.h`, `linux/rpmsg.h`, `linux/soc/qcom/smd-rpm.h`.
- Detected declarations: `struct qcom_smd_rpm`, `struct qcom_rpm_header`, `struct qcom_rpm_request`, `struct qcom_rpm_message`, `function qcom_rpm_smd_write`, `function qcom_smd_rpm_callback`, `function qcom_smd_rpm_probe`, `function qcom_smd_rpm_remove`, `function qcom_smd_rpm_init`, `function qcom_smd_rpm_exit`.
- Atlas domain: Driver Families / drivers/soc.
- 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.