drivers/i3c/master/mipi-i3c-hci/core.c
Source file repositories/reference/linux-study-clean/drivers/i3c/master/mipi-i3c-hci/core.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/i3c/master/mipi-i3c-hci/core.c- Extension
.c- Size
- 33197 bytes
- Lines
- 1231
- Domain
- Driver Families
- Bucket
- drivers/i3c
- 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.
- 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/bitfield.hlinux/clk.hlinux/device.hlinux/errno.hlinux/i3c/master.hlinux/interrupt.hlinux/iopoll.hlinux/module.hlinux/platform_data/mipi-i3c-hci.hlinux/platform_device.hlinux/pm_runtime.hhci.hext_caps.hcmd.hdat.hibi.h
Detected Declarations
function Copyrightfunction i3c_hci_set_master_dyn_addrfunction i3c_hci_bus_initfunction i3c_hci_bus_disablefunction i3c_hci_software_resetfunction i3c_hci_sync_irq_inactivefunction i3c_hci_bus_cleanupfunction mipi_i3c_hci_resumefunction mipi_i3c_hci_abortfunction mipi_i3c_hci_pio_resetfunction mipi_i3c_hci_pio_reset_all_queuesfunction mipi_i3c_hci_dct_index_resetfunction i3c_hci_process_xferfunction i3c_hci_send_ccc_cmdfunction i3c_hci_enable_hotjoinfunction i3c_hci_disable_hotjoinfunction i3c_hci_daafunction i3c_hci_i3c_xfersfunction i3c_hci_i2c_xfersfunction i3c_hci_attach_i3c_devfunction i3c_hci_reattach_i3c_devfunction i3c_hci_detach_i3c_devfunction i3c_hci_attach_i2c_devfunction i3c_hci_detach_i2c_devfunction i3c_hci_request_ibifunction __i3c_hci_disable_ibifunction i3c_hci_free_ibifunction i3c_hci_enable_ibifunction i3c_hci_disable_ibifunction i3c_hci_recycle_ibi_slotfunction i3c_hci_irq_handlerfunction is_version_1_1_or_newerfunction i3c_hci_set_io_modefunction i3c_hci_reset_and_initfunction i3c_hci_rpm_suspendfunction i3c_hci_do_reset_and_restorefunction i3c_hci_reset_and_restorefunction i3c_hci_rpm_resumefunction i3c_hci_runtime_suspendfunction i3c_hci_runtime_resumefunction i3c_hci_suspendfunction i3c_hci_resume_commonfunction i3c_hci_resumefunction i3c_hci_restorefunction i3c_hci_rpm_enablefunction i3c_hci_initfunction i3c_hci_probefunction i3c_hci_remove
Annotated Snippet
scoped_guard(spinlock_irqsave, &hci->lock) {
started = xfer[0].started;
time_taken = jiffies - xfer[0].start_jiffies;
}
/* Keep waiting if xfer has not started */
if (!started)
continue;
/* Recalculate timeout based on actual start time */
if (time_taken < timeout) {
remaining_timeout = timeout - time_taken;
continue;
}
if (hci->io->dequeue_xfer(hci, xfer, n)) {
dev_err(&hci->master.dev, "%s: timeout error\n", __func__);
return -ETIMEDOUT;
}
return 0;
}
if (hci->io->handle_error) {
bool error = false;
for (int i = 0; i < n && !error; i++)
error = RESP_STATUS(xfer[i].response);
if (error)
return hci->io->handle_error(hci, xfer, n);
}
return 0;
}
static int i3c_hci_send_ccc_cmd(struct i3c_master_controller *m,
struct i3c_ccc_cmd *ccc)
{
struct i3c_hci *hci = to_i3c_hci(m);
struct hci_xfer *xfer;
bool raw = !!(hci->quirks & HCI_QUIRK_RAW_CCC);
bool prefixed = raw && !!(ccc->id & I3C_CCC_DIRECT);
unsigned int nxfers = ccc->ndests + prefixed;
DECLARE_COMPLETION_ONSTACK(done);
int i, last, ret = 0;
dev_dbg(&hci->master.dev, "cmd=%#x rnw=%d ndests=%d data[0].len=%d",
ccc->id, ccc->rnw, ccc->ndests, ccc->dests[0].payload.len);
xfer = hci_alloc_xfer(nxfers);
if (!xfer)
return -ENOMEM;
if (prefixed) {
xfer->data = NULL;
xfer->data_len = 0;
xfer->rnw = false;
hci->cmd->prep_ccc(hci, xfer, I3C_BROADCAST_ADDR,
ccc->id, true);
xfer++;
}
for (i = 0; i < nxfers - prefixed; i++) {
xfer[i].data = ccc->dests[i].payload.data;
xfer[i].data_len = ccc->dests[i].payload.len;
xfer[i].rnw = ccc->rnw;
ret = hci->cmd->prep_ccc(hci, &xfer[i], ccc->dests[i].addr,
ccc->id, raw);
if (ret)
goto out;
xfer[i].cmd_desc[0] |= CMD_0_ROC;
}
last = i - 1;
xfer[last].cmd_desc[0] |= CMD_0_TOC;
xfer[last].completion = &done;
xfer[last].timeout = HZ;
if (prefixed)
xfer--;
ret = i3c_hci_process_xfer(hci, xfer, nxfers);
if (ret)
goto out;
for (i = prefixed; i < nxfers; i++) {
if (ccc->rnw)
ccc->dests[i - prefixed].payload.len =
RESP_DATA_LENGTH(xfer[i].response);
switch (RESP_STATUS(xfer[i].response)) {
case RESP_SUCCESS:
continue;
case RESP_ERR_ADDR_HEADER:
case RESP_ERR_NACK:
ccc->err = I3C_ERROR_M2;
fallthrough;
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/clk.h`, `linux/device.h`, `linux/errno.h`, `linux/i3c/master.h`, `linux/interrupt.h`, `linux/iopoll.h`, `linux/module.h`.
- Detected declarations: `function Copyright`, `function i3c_hci_set_master_dyn_addr`, `function i3c_hci_bus_init`, `function i3c_hci_bus_disable`, `function i3c_hci_software_reset`, `function i3c_hci_sync_irq_inactive`, `function i3c_hci_bus_cleanup`, `function mipi_i3c_hci_resume`, `function mipi_i3c_hci_abort`, `function mipi_i3c_hci_pio_reset`.
- Atlas domain: Driver Families / drivers/i3c.
- Implementation status: integration 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.