drivers/rpmsg/qcom_glink_ssr.c
Source file repositories/reference/linux-study-clean/drivers/rpmsg/qcom_glink_ssr.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/rpmsg/qcom_glink_ssr.c- Extension
.c- Size
- 4204 bytes
- Lines
- 169
- 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.
- 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/completion.hlinux/module.hlinux/notifier.hlinux/rpmsg.hlinux/rpmsg/qcom_glink.hlinux/remoteproc/qcom_rproc.h
Detected Declarations
struct do_cleanup_msgstruct cleanup_done_msgstruct glink_ssrfunction qcom_glink_ssr_notifyfunction qcom_glink_ssr_callbackfunction qcom_glink_ssr_notifier_callfunction qcom_glink_ssr_probefunction qcom_glink_ssr_removeexport qcom_glink_ssr_notify
Annotated Snippet
struct do_cleanup_msg {
__le32 version;
__le32 command;
__le32 seq_num;
__le32 name_len;
char name[32];
};
/**
* struct cleanup_done_msg - The data structure for an SSR cleanup_done message
* @version: The G-Link SSR protocol version
* @response: The G-Link SSR response to a do_cleanup command, cleanup_done
* @seq_num: Sequence number
*/
struct cleanup_done_msg {
__le32 version;
__le32 response;
__le32 seq_num;
};
/*
* G-Link SSR protocol commands
*/
#define GLINK_SSR_DO_CLEANUP 0
#define GLINK_SSR_CLEANUP_DONE 1
struct glink_ssr {
struct device *dev;
struct rpmsg_endpoint *ept;
struct notifier_block nb;
u32 seq_num;
struct completion completion;
};
/* Notifier list for all registered glink_ssr instances */
static BLOCKING_NOTIFIER_HEAD(ssr_notifiers);
/**
* qcom_glink_ssr_notify() - notify GLINK SSR about stopped remoteproc
* @ssr_name: name of the remoteproc that has been stopped
*/
void qcom_glink_ssr_notify(const char *ssr_name)
{
blocking_notifier_call_chain(&ssr_notifiers, 0, (void *)ssr_name);
}
EXPORT_SYMBOL_GPL(qcom_glink_ssr_notify);
static int qcom_glink_ssr_callback(struct rpmsg_device *rpdev,
void *data, int len, void *priv, u32 addr)
{
struct cleanup_done_msg *msg = data;
struct glink_ssr *ssr = dev_get_drvdata(&rpdev->dev);
if (len < sizeof(*msg)) {
dev_err(ssr->dev, "message too short\n");
return -EINVAL;
}
if (le32_to_cpu(msg->version) != 0)
return -EINVAL;
if (le32_to_cpu(msg->response) != GLINK_SSR_CLEANUP_DONE)
return 0;
if (le32_to_cpu(msg->seq_num) != ssr->seq_num) {
dev_err(ssr->dev, "invalid sequence number of response\n");
return -EINVAL;
}
complete(&ssr->completion);
return 0;
}
static int qcom_glink_ssr_notifier_call(struct notifier_block *nb,
unsigned long event,
void *data)
{
struct glink_ssr *ssr = container_of(nb, struct glink_ssr, nb);
struct do_cleanup_msg msg;
char *ssr_name = data;
int ret;
ssr->seq_num++;
reinit_completion(&ssr->completion);
memset(&msg, 0, sizeof(msg));
msg.command = cpu_to_le32(GLINK_SSR_DO_CLEANUP);
Annotation
- Immediate include surface: `linux/completion.h`, `linux/module.h`, `linux/notifier.h`, `linux/rpmsg.h`, `linux/rpmsg/qcom_glink.h`, `linux/remoteproc/qcom_rproc.h`.
- Detected declarations: `struct do_cleanup_msg`, `struct cleanup_done_msg`, `struct glink_ssr`, `function qcom_glink_ssr_notify`, `function qcom_glink_ssr_callback`, `function qcom_glink_ssr_notifier_call`, `function qcom_glink_ssr_probe`, `function qcom_glink_ssr_remove`, `export qcom_glink_ssr_notify`.
- Atlas domain: Driver Families / drivers/rpmsg.
- Implementation status: integration implementation candidate.
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.