drivers/char/ipmi/ipmi_powernv.c
Source file repositories/reference/linux-study-clean/drivers/char/ipmi/ipmi_powernv.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/char/ipmi/ipmi_powernv.c- Extension
.c- Size
- 7380 bytes
- Lines
- 316
- Domain
- Driver Families
- Bucket
- drivers/char
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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/ipmi_smi.hlinux/list.hlinux/module.hlinux/of.hlinux/of_irq.hlinux/interrupt.hasm/opal.h
Detected Declarations
struct ipmi_smi_powernvfunction ipmi_powernv_start_processingfunction send_error_replyfunction ipmi_powernv_sendfunction ipmi_powernv_recvfunction ipmi_powernv_request_eventsfunction ipmi_opal_eventfunction ipmi_powernv_probefunction ipmi_powernv_remove
Annotated Snippet
struct ipmi_smi_powernv {
u64 interface_id;
struct ipmi_smi *intf;
unsigned int irq;
/**
* We assume that there can only be one outstanding request, so
* keep the pending message in cur_msg. We protect this from concurrent
* updates through send & recv calls, (and consequently opal_msg, which
* is in-use when cur_msg is set) with msg_lock
*/
spinlock_t msg_lock;
struct ipmi_smi_msg *cur_msg;
struct opal_ipmi_msg *opal_msg;
};
static int ipmi_powernv_start_processing(void *send_info, struct ipmi_smi *intf)
{
struct ipmi_smi_powernv *smi = send_info;
smi->intf = intf;
return 0;
}
static void send_error_reply(struct ipmi_smi_powernv *smi,
struct ipmi_smi_msg *msg, u8 completion_code)
{
msg->rsp[0] = msg->data[0] | 0x4;
msg->rsp[1] = msg->data[1];
msg->rsp[2] = completion_code;
msg->rsp_size = 3;
ipmi_smi_msg_received(smi->intf, msg);
}
static int ipmi_powernv_send(void *send_info, struct ipmi_smi_msg *msg)
{
struct ipmi_smi_powernv *smi = send_info;
struct opal_ipmi_msg *opal_msg;
unsigned long flags;
int comp, rc;
size_t size;
/* ensure data_len will fit in the opal_ipmi_msg buffer... */
if (msg->data_size > IPMI_MAX_MSG_LENGTH) {
comp = IPMI_REQ_LEN_EXCEEDED_ERR;
goto err;
}
/* ... and that we at least have netfn and cmd bytes */
if (msg->data_size < 2) {
comp = IPMI_REQ_LEN_INVALID_ERR;
goto err;
}
spin_lock_irqsave(&smi->msg_lock, flags);
if (smi->cur_msg) {
comp = IPMI_NODE_BUSY_ERR;
goto err_unlock;
}
/* format our data for the OPAL API */
opal_msg = smi->opal_msg;
opal_msg->version = OPAL_IPMI_MSG_FORMAT_VERSION_1;
opal_msg->netfn = msg->data[0];
opal_msg->cmd = msg->data[1];
if (msg->data_size > 2)
memcpy(opal_msg->data, msg->data + 2, msg->data_size - 2);
/* data_size already includes the netfn and cmd bytes */
size = sizeof(*opal_msg) + msg->data_size - 2;
pr_devel("%s: opal_ipmi_send(0x%llx, %p, %ld)\n", __func__,
smi->interface_id, opal_msg, size);
rc = opal_ipmi_send(smi->interface_id, opal_msg, size);
pr_devel("%s: -> %d\n", __func__, rc);
if (rc) {
comp = IPMI_ERR_UNSPECIFIED;
goto err_unlock;
}
smi->cur_msg = msg;
spin_unlock_irqrestore(&smi->msg_lock, flags);
return IPMI_CC_NO_ERROR;
err_unlock:
spin_unlock_irqrestore(&smi->msg_lock, flags);
err:
return comp;
}
Annotation
- Immediate include surface: `linux/ipmi_smi.h`, `linux/list.h`, `linux/module.h`, `linux/of.h`, `linux/of_irq.h`, `linux/interrupt.h`, `asm/opal.h`.
- Detected declarations: `struct ipmi_smi_powernv`, `function ipmi_powernv_start_processing`, `function send_error_reply`, `function ipmi_powernv_send`, `function ipmi_powernv_recv`, `function ipmi_powernv_request_events`, `function ipmi_opal_event`, `function ipmi_powernv_probe`, `function ipmi_powernv_remove`.
- Atlas domain: Driver Families / drivers/char.
- Implementation status: source 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.