drivers/soc/qcom/rpmh.c
Source file repositories/reference/linux-study-clean/drivers/soc/qcom/rpmh.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/soc/qcom/rpmh.c- Extension
.c- Size
- 11799 bytes
- Lines
- 503
- 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/atomic.hlinux/bug.hlinux/interrupt.hlinux/jiffies.hlinux/kernel.hlinux/list.hlinux/lockdep.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/slab.hlinux/spinlock.hlinux/types.hlinux/wait.hsoc/qcom/rpmh.hrpmh-internal.h
Detected Declarations
struct cache_reqstruct batch_cache_reqfunction rpmh_tx_donefunction list_for_each_entryfunction __rpmh_writefunction __fill_rpmh_msgfunction rpmh_write_asyncfunction rpmh_writefunction cache_batchfunction flush_batchfunction rpmh_write_batchfunction is_req_validfunction send_singlefunction rpmh_flushfunction list_for_each_entryfunction rpmh_invalidateexport rpmh_write_asyncexport rpmh_writeexport rpmh_write_batchexport rpmh_invalidate
Annotated Snippet
struct cache_req {
u32 addr;
u32 sleep_val;
u32 wake_val;
struct list_head list;
};
/**
* struct batch_cache_req - An entry in our batch catch
*
* @list: linked list obj
* @count: number of messages
* @rpm_msgs: the messages
*/
struct batch_cache_req {
struct list_head list;
int count;
struct rpmh_request rpm_msgs[];
};
static struct rpmh_ctrlr *get_rpmh_ctrlr(const struct device *dev)
{
struct rsc_drv *drv = dev_get_drvdata(dev->parent);
return &drv->client;
}
void rpmh_tx_done(const struct tcs_request *msg)
{
struct rpmh_request *rpm_msg = container_of(msg, struct rpmh_request,
msg);
struct completion *compl = rpm_msg->completion;
bool free = rpm_msg->needs_free;
if (!compl)
goto exit;
/* Signal the blocking thread we are done */
complete(compl);
exit:
if (free)
kfree(rpm_msg);
}
static struct cache_req *__find_req(struct rpmh_ctrlr *ctrlr, u32 addr)
{
struct cache_req *p, *req = NULL;
list_for_each_entry(p, &ctrlr->cache, list) {
if (p->addr == addr) {
req = p;
break;
}
}
return req;
}
static struct cache_req *cache_rpm_request(struct rpmh_ctrlr *ctrlr,
enum rpmh_state state,
struct tcs_cmd *cmd)
{
struct cache_req *req;
unsigned long flags;
u32 old_sleep_val, old_wake_val;
spin_lock_irqsave(&ctrlr->cache_lock, flags);
req = __find_req(ctrlr, cmd->addr);
if (req)
goto existing;
req = kzalloc_obj(*req, GFP_ATOMIC);
if (!req) {
req = ERR_PTR(-ENOMEM);
goto unlock;
}
req->addr = cmd->addr;
req->sleep_val = req->wake_val = UINT_MAX;
list_add_tail(&req->list, &ctrlr->cache);
existing:
old_sleep_val = req->sleep_val;
old_wake_val = req->wake_val;
switch (state) {
case RPMH_ACTIVE_ONLY_STATE:
case RPMH_WAKE_ONLY_STATE:
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/bug.h`, `linux/interrupt.h`, `linux/jiffies.h`, `linux/kernel.h`, `linux/list.h`, `linux/lockdep.h`, `linux/module.h`.
- Detected declarations: `struct cache_req`, `struct batch_cache_req`, `function rpmh_tx_done`, `function list_for_each_entry`, `function __rpmh_write`, `function __fill_rpmh_msg`, `function rpmh_write_async`, `function rpmh_write`, `function cache_batch`, `function flush_batch`.
- 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.