STRUCT MHI_EP_CNTRL(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 struct mhi_ep_cntrl(9) 🌸

okay so bestie, we're in the Kernel API Manual and this page is all about struct mhi_ep_cntrl β€” literally the MHI Endpoint controller structure. it's the big main-character struct that holds everything the endpoint side needs. no cap, it's a long one, but we're gonna walk through every single field together, hand in hand 🫢


✨ SYNOPSIS ✨

like, here's the whole vibe of the struct, every field, exactly as it is β€” don't touch, just read πŸ’…

struct mhi_ep_cntrl {
    struct device *cntrl_dev;
    struct mhi_ep_device *mhi_dev;
    void __iomem *mmio;
    struct mhi_ep_chan *mhi_chan;
    struct mhi_ep_event *mhi_event;
    struct mhi_ep_cmd *mhi_cmd;
    struct mhi_ep_sm *sm;
    struct mhi_chan_ctxt *ch_ctx_cache;
    struct mhi_event_ctxt *ev_ctx_cache;
    struct mhi_cmd_ctxt *cmd_ctx_cache;
    u64 ch_ctx_host_pa;
    u64 ev_ctx_host_pa;
    u64 cmd_ctx_host_pa;
    phys_addr_t ch_ctx_cache_phys;
    phys_addr_t ev_ctx_cache_phys;
    phys_addr_t cmd_ctx_cache_phys;
    struct mhi_ep_db_info chdb[4];
    struct mutex event_lock;
    struct mutex state_lock;
    spinlock_t list_lock;
    struct list_head st_transition_list;
    struct list_head ch_db_list;
    struct workqueue_struct *wq;
    struct work_struct state_work;
    struct work_struct reset_work;
    struct work_struct cmd_ring_work;
    struct work_struct ch_ring_work;
    struct kmem_cache *ring_item_cache;
    struct kmem_cache *ev_ring_el_cache;
    struct kmem_cache *tre_buf_cache;
    void (*raise_irq)(struct mhi_ep_cntrl *mhi_cntrl, u32 vector);
    int (*alloc_map)(struct mhi_ep_cntrl *mhi_cntrl, u64 pci_addr,
phys_addr_t *phys_ptr, void __iomem **virt, size_t size);
    void (*unmap_free)(struct mhi_ep_cntrl *mhi_cntrl, u64 pci_addr,
phys_addr_t phys, void __iomem *virt, size_t size);
    int (*read_sync)(struct mhi_ep_cntrl *mhi_cntrl, struct
mhi_ep_buf_info *buf_info);
    int (*write_sync)(struct mhi_ep_cntrl *mhi_cntrl, struct
mhi_ep_buf_info *buf_info);
    int (*read_async)(struct mhi_ep_cntrl *mhi_cntrl, struct
mhi_ep_buf_info *buf_info);
    int (*write_async)(struct mhi_ep_cntrl *mhi_cntrl, struct
mhi_ep_buf_info *buf_info);
    void (*flush_async)(struct mhi_ep_cntrl *mhi_cntrl);
    enum mhi_state mhi_state;
    u32 max_chan;
    u32 mru;
    u32 event_rings;
    u32 hw_event_rings;
    u32 chdb_offset;
    u32 erdb_offset;
    u32 index;
    int irq;
    bool enabled;
 };

πŸŽ€ Members πŸŽ€

πŸ’– the pointers & basics

  • cntrl_dev β€” pointer to the struct device of the physical bus that's acting as the MHI Endpoint controller. like, the actual device it lives on πŸ¦‹
  • mhi_dev β€” the MHI Endpoint device instance for this controller
  • mmio β€” the MMIO region that contains the MHI registers
  • mhi_chan β€” points to the channel configuration table
  • mhi_event β€” points to the event ring configurations table
  • mhi_cmd β€” points to the command ring configurations table
  • sm β€” the MHI Endpoint state machine (yes, she has a whole state machine, queen behavior πŸ‘‘)

🧚 the host context caches

  • ch_ctx_cache β€” cache of the host channel context data structure
  • ev_ctx_cache β€” cache of the host event context data structure
  • cmd_ctx_cache β€” cache of the host command context data structure

⭐ the host context physical addresses

  • ch_ctx_host_pa β€” physical address of the host channel context data structure
  • ev_ctx_host_pa β€” physical address of the host event context data structure
  • cmd_ctx_host_pa β€” physical address of the host command context data structure

🌸 the cache physical addresses

  • ch_ctx_cache_phys β€” physical address of the host channel context cache
  • ev_ctx_cache_phys β€” physical address of the host event context cache
  • cmd_ctx_cache_phys β€” physical address of the host command context cache

πŸ”₯ doorbells, locks & lists

  • chdb β€” array of channel doorbell interrupt info
  • event_lock β€” the lock protecting event rings
  • state_lock β€” the lock protecting state transitions
  • list_lock β€” the lock protecting the state transition and channel doorbell lists
  • st_transition_list β€” list of state transitions
  • ch_db_list β€” list of queued channel doorbells

🫢 the workqueue situation

  • wq β€” a dedicated workqueue for handling rings and state changes
  • state_work β€” the state transition worker
  • reset_work β€” the worker for MHI Endpoint reset
  • cmd_ring_work β€” the worker for processing command rings
  • ch_ring_work β€” the worker for processing channel rings

πŸ“ the callbacks (iykyk)

  • raise_irq β€” CB function for raising an IRQ to the host
  • alloc_map β€” CB function for allocating memory in the endpoint for storing host context and mapping it
  • unmap_free β€” CB function to unmap and free the allocated memory in the endpoint for storing host context
  • read_sync β€” CB function for reading from host memory synchronously
  • write_sync β€” CB function for writing to host memory synchronously
  • read_async β€” CB function for reading from host memory asynchronously
  • write_async β€” CB function for writing to host memory asynchronously
  • flush_async β€” CB function for flushing asynchronous read/writes

🌈 the config & state bits

  • mhi_state β€” the MHI Endpoint state
  • max_chan β€” maximum channels supported by the endpoint controller
  • mru β€” the MRU (Maximum Receive Unit) value of the endpoint controller
  • event_rings β€” number of event rings supported by the endpoint controller
  • hw_event_rings β€” number of hardware event rings supported by the endpoint controller
  • chdb_offset β€” channel doorbell offset set by the host
  • erdb_offset β€” event ring doorbell offset set by the host
  • index β€” the MHI Endpoint controller index
  • irq β€” the IRQ used by the endpoint controller
  • enabled β€” check if the endpoint controller is enabled or not

πŸ‘‘ SEE ALSO πŸ‘‘

go read these next bestie, they're all in the kernel file ./include/linux/mhi_ep.h:


πŸ’€ reminder bestie: this page lives in ./include/linux and it's dated October 2026 β€” that's the Linux kernel source tree, so check the actual header before you go shipping anything, fr fr.

okay that's the whole struct, you ate that πŸ’…βœ¨ go be iconic with your endpoint controller πŸŽ€πŸ¦‹πŸ’œ

πŸ“¦ where this page comes from