drivers/bus/mhi/host/pm.c
Source file repositories/reference/linux-study-clean/drivers/bus/mhi/host/pm.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/bus/mhi/host/pm.c- Extension
.c- Size
- 39042 bytes
- Lines
- 1368
- Domain
- Driver Families
- Bucket
- drivers/bus
- 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/delay.hlinux/device.hlinux/dma-direction.hlinux/dma-mapping.hlinux/interrupt.hlinux/list.hlinux/mhi.hlinux/module.hlinux/slab.hlinux/wait.hinternal.htrace.h
Detected Declarations
function mhi_tryset_pm_statefunction mhi_set_mhi_statefunction mhi_toggle_dev_wake_nopfunction mhi_ready_state_transitionfunction mhi_pm_m0_transitionfunction mhi_pm_m1_transitionfunction mhi_pm_m3_transitionfunction mhi_pm_mission_mode_transitionfunction mhi_pm_disable_transitionfunction mhi_pm_sys_error_transitionfunction mhi_queue_state_transitionfunction mhi_pm_sys_err_handlerfunction mhi_pm_st_workerfunction list_for_each_entry_safefunction mhi_pm_suspendfunction __mhi_pm_resumefunction mhi_pm_resumefunction mhi_pm_resume_forcefunction __mhi_device_get_syncfunction mhi_assert_dev_wakefunction mhi_deassert_dev_wakefunction MHI_WAKE_DB_CLEAR_VALIDfunction mhi_async_power_upfunction __mhi_power_downfunction mhi_power_downfunction mhi_power_down_keep_devfunction mhi_sync_power_upfunction mhi_force_rddm_modefunction mhi_device_get_syncfunction mhi_device_putfunction mhi_uevent_notifyexport mhi_pm_suspendexport mhi_pm_resumeexport mhi_pm_resume_forceexport mhi_async_power_upexport mhi_power_downexport mhi_power_down_keep_devexport mhi_sync_power_upexport mhi_force_rddm_modeexport mhi_device_get_syncexport mhi_device_put
Annotated Snippet
if (mhi_chan->db_cfg.reset_req) {
write_lock_irq(&mhi_chan->lock);
mhi_chan->db_cfg.db_mode = true;
write_unlock_irq(&mhi_chan->lock);
}
read_lock_irq(&mhi_chan->lock);
/* Only ring DB if ring is not empty */
if (tre_ring->base && tre_ring->wp != tre_ring->rp &&
mhi_chan->ch_state == MHI_CH_STATE_ENABLED)
mhi_ring_chan_db(mhi_cntrl, mhi_chan);
read_unlock_irq(&mhi_chan->lock);
}
mhi_cntrl->wake_put(mhi_cntrl, false);
read_unlock_bh(&mhi_cntrl->pm_lock);
wake_up_all(&mhi_cntrl->state_event);
return 0;
}
/*
* After receiving the MHI state change event from the device indicating the
* transition to M1 state, the host can transition the device to M2 state
* for keeping it in low power state.
*/
void mhi_pm_m1_transition(struct mhi_controller *mhi_cntrl)
{
enum mhi_pm_state state;
struct device *dev = &mhi_cntrl->mhi_dev->dev;
write_lock_irq(&mhi_cntrl->pm_lock);
state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M2);
if (state == MHI_PM_M2) {
mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M2);
mhi_cntrl->dev_state = MHI_STATE_M2;
write_unlock_irq(&mhi_cntrl->pm_lock);
mhi_cntrl->M2++;
wake_up_all(&mhi_cntrl->state_event);
/* If there are any pending resources, exit M2 immediately */
if (unlikely(atomic_read(&mhi_cntrl->pending_pkts) ||
atomic_read(&mhi_cntrl->dev_wake))) {
dev_dbg(dev,
"Exiting M2, pending_pkts: %d dev_wake: %d\n",
atomic_read(&mhi_cntrl->pending_pkts),
atomic_read(&mhi_cntrl->dev_wake));
read_lock_bh(&mhi_cntrl->pm_lock);
mhi_cntrl->wake_get(mhi_cntrl, true);
mhi_cntrl->wake_put(mhi_cntrl, true);
read_unlock_bh(&mhi_cntrl->pm_lock);
} else {
mhi_cntrl->status_cb(mhi_cntrl, MHI_CB_IDLE);
}
} else {
write_unlock_irq(&mhi_cntrl->pm_lock);
}
}
/* MHI M3 completion handler */
int mhi_pm_m3_transition(struct mhi_controller *mhi_cntrl)
{
enum mhi_pm_state state;
struct device *dev = &mhi_cntrl->mhi_dev->dev;
write_lock_irq(&mhi_cntrl->pm_lock);
mhi_cntrl->dev_state = MHI_STATE_M3;
state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M3);
write_unlock_irq(&mhi_cntrl->pm_lock);
if (state != MHI_PM_M3) {
dev_err(dev, "Unable to transition to M3 state\n");
return -EIO;
}
mhi_cntrl->M3++;
wake_up_all(&mhi_cntrl->state_event);
return 0;
}
/* Handle device Mission Mode transition */
static int mhi_pm_mission_mode_transition(struct mhi_controller *mhi_cntrl)
{
struct mhi_event *mhi_event;
struct device *dev = &mhi_cntrl->mhi_dev->dev;
enum mhi_ee_type ee = MHI_EE_MAX, current_ee = mhi_cntrl->ee;
int i, ret;
Annotation
- Immediate include surface: `linux/delay.h`, `linux/device.h`, `linux/dma-direction.h`, `linux/dma-mapping.h`, `linux/interrupt.h`, `linux/list.h`, `linux/mhi.h`, `linux/module.h`.
- Detected declarations: `function mhi_tryset_pm_state`, `function mhi_set_mhi_state`, `function mhi_toggle_dev_wake_nop`, `function mhi_ready_state_transition`, `function mhi_pm_m0_transition`, `function mhi_pm_m1_transition`, `function mhi_pm_m3_transition`, `function mhi_pm_mission_mode_transition`, `function mhi_pm_disable_transition`, `function mhi_pm_sys_error_transition`.
- Atlas domain: Driver Families / drivers/bus.
- 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.