Loading Documentation/devicetree/bindings/mhi/msm_mhi.txt +5 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,11 @@ Required properties: - qcom,msm-bus,num-paths - qcom,msm-bus,vectors-KBps - mhi-chan-cfg-#: mhi channel configuration parameters for platform defined as below <A B C D>: A = chan number B = maximum descriptors C = event ring associated with channel D = flags defined by mhi_macros.h GET_CHAN_PROPS - mhi-event-cfg-#: mhi event ring configuration parameters for platform - mhi-event-rings: number of event rings supported by platform - mhi-dev-address-win-size: size of the MHI device addressing window Loading drivers/platform/msm/mhi/mhi.h +9 −2 Original line number Diff line number Diff line Loading @@ -261,6 +261,12 @@ enum MHI_EVENT_CCS { MHI_EVENT_CC_BAD_TRE = 0x11, }; struct db_mode { /* if set do not reset DB_Mode during M0 resume */ u32 preserve_db_state : 1; u32 db_mode : 1; }; struct mhi_ring { void *base; void *wp; Loading @@ -270,6 +276,7 @@ struct mhi_ring { uintptr_t el_size; u32 overwrite_en; enum MHI_CHAN_DIR dir; struct db_mode db_mode; }; enum MHI_CMD_STATUS { Loading Loading @@ -414,7 +421,6 @@ struct mhi_flags { u32 ev_thread_stopped; u32 st_thread_stopped; u32 uldl_enabled; u32 db_mode[MHI_MAX_CHANNELS]; }; struct mhi_wait_queues { Loading Loading @@ -577,7 +583,8 @@ int mhi_init_chan_ctxt(struct mhi_chan_ctxt *cc_list, enum MHI_CHAN_DIR chan_type, u32 event_ring, struct mhi_ring *ring, enum MHI_CHAN_STATE chan_state); enum MHI_CHAN_STATE chan_state, bool preserve_db_state); int mhi_populate_event_cfg(struct mhi_device_ctxt *mhi_dev_ctxt); int mhi_get_event_ring_for_channel(struct mhi_device_ctxt *mhi_dev_ctxt, u32 chan); Loading drivers/platform/msm/mhi/mhi_init.c +16 −12 Original line number Diff line number Diff line Loading @@ -592,14 +592,16 @@ error_during_props: * @chan_type: Type of channel IN/OUT * @event_ring: Event ring to be mapped to this channel context * @ring: Shadow context to be initialized alongside * * @chan_state: Channel state * @preserve_db_state: Do not reset DB state during resume * @Return errno */ int mhi_init_chan_ctxt(struct mhi_chan_ctxt *cc_list, uintptr_t trb_list_phy, uintptr_t trb_list_virt, u64 el_per_ring, enum MHI_CHAN_DIR chan_type, u32 event_ring, struct mhi_ring *ring, enum MHI_CHAN_STATE chan_state) enum MHI_CHAN_STATE chan_state, bool preserve_db_state) { cc_list->mhi_chan_state = chan_state; cc_list->mhi_chan_type = chan_type; Loading @@ -617,6 +619,8 @@ int mhi_init_chan_ctxt(struct mhi_chan_ctxt *cc_list, ring->el_size = sizeof(struct mhi_tx_pkt); ring->overwrite_en = 0; ring->dir = chan_type; ring->db_mode.db_mode = 1; ring->db_mode.preserve_db_state = (preserve_db_state) ? 1 : 0; /* Flush writes to MMIO */ wmb(); return 0; Loading drivers/platform/msm/mhi/mhi_macros.h +4 −0 Original line number Diff line number Diff line Loading @@ -244,6 +244,10 @@ #define MHI_CHAN_TYPE__MASK (3) #define MHI_CHAN_TYPE__SHIFT (6) #define PRESERVE_DB_STATE #define MHI_PRESERVE_DB_STATE__MASK (1) #define MHI_PRESERVE_DB_STATE__SHIFT (8) #define GET_CHAN_PROPS(_FIELD, _VAL) \ (((_VAL) >> MHI_##_FIELD ## __SHIFT) & MHI_##_FIELD ## __MASK) Loading drivers/platform/msm/mhi/mhi_main.c +15 −10 Original line number Diff line number Diff line Loading @@ -212,7 +212,7 @@ int mhi_release_chan_ctxt(struct mhi_device_ctxt *mhi_dev_ctxt, ring->len, ring->base, cc_list->mhi_trb_ring_base_addr); mhi_init_chan_ctxt(cc_list, 0, 0, 0, 0, 0, ring, MHI_CHAN_STATE_DISABLED); MHI_CHAN_STATE_DISABLED, false); return 0; } Loading Loading @@ -259,7 +259,9 @@ static int populate_tre_ring(struct mhi_client_handle *client_handle) client_handle->chan_info.flags), client_handle->chan_info.ev_ring, &mhi_dev_ctxt->mhi_local_chan_ctxt[chan], MHI_CHAN_STATE_ENABLED); MHI_CHAN_STATE_ENABLED, GET_CHAN_PROPS(PRESERVE_DB_STATE, client_handle->chan_info.flags)); mhi_log(MHI_MSG_INFO, "Exited\n"); return 0; } Loading Loading @@ -654,6 +656,7 @@ static int mhi_queue_dma_xfer( MHI_ASSERT(VALID_BUF(buf, buf_len, mhi_dev_ctxt), "Client buffer is of invalid length\n"); chan = client_handle->chan_info.chan_nr; mhi_log(MHI_MSG_INFO, "Getting Reference %d", chan); pm_runtime_get(&mhi_dev_ctxt->dev_info->pcie_device->dev); Loading Loading @@ -698,6 +701,7 @@ static int mhi_queue_dma_xfer( error: pm_runtime_mark_last_busy(&mhi_dev_ctxt->dev_info->pcie_device->dev); mhi_log(MHI_MSG_INFO, "Putting Reference %d", chan); pm_runtime_put_noidle(&mhi_dev_ctxt->dev_info->pcie_device->dev); return ret_val; Loading Loading @@ -1169,12 +1173,13 @@ int parse_xfer_event(struct mhi_device_ctxt *ctxt, mhi_dev_ctxt->flags.uldl_enabled = 1; chan = MHI_EV_READ_CHID(EV_CHID, event); mhi_dev_ctxt->flags.db_mode[chan] = 1; chan_ctxt = &mhi_dev_ctxt->mhi_local_chan_ctxt[chan]; mhi_log(MHI_MSG_INFO, "DB_MODE/OOB Detected chan %d.\n", chan); spin_lock_irqsave(&mhi_dev_ctxt->db_write_lock[chan], flags); chan_ctxt->db_mode.db_mode = 1; if (chan_ctxt->wp != chan_ctxt->rp) { db_value = mhi_v2p_addr(mhi_dev_ctxt, MHI_RING_TYPE_XFER_RING, chan, Loading Loading @@ -1658,6 +1663,8 @@ void mhi_process_db(struct mhi_device_ctxt *mhi_dev_ctxt, void __iomem *io_addr, uintptr_t chan, u32 val) { struct mhi_ring *chan_ctxt = &mhi_dev_ctxt->mhi_local_chan_ctxt[chan]; mhi_log(MHI_MSG_VERBOSE, "db.set addr: %p io_offset 0x%lx val:0x%x\n", io_addr, chan, val); Loading @@ -1668,14 +1675,14 @@ void mhi_process_db(struct mhi_device_ctxt *mhi_dev_ctxt, if (io_addr == mhi_dev_ctxt->mmio_info.chan_db_addr) { if (!(IS_HARDWARE_CHANNEL(chan) && mhi_dev_ctxt->flags.uldl_enabled && !mhi_dev_ctxt->flags.db_mode[chan])) { !chan_ctxt->db_mode.db_mode)) { mhi_write_db(mhi_dev_ctxt, io_addr, chan, val); mhi_dev_ctxt->flags.db_mode[chan] = 0; chan_ctxt->db_mode.db_mode = 0; } else { mhi_log(MHI_MSG_INFO, "Not ringing xfer db, chan %ld, ul_dl %d db_mode %d\n", chan, mhi_dev_ctxt->flags.uldl_enabled, mhi_dev_ctxt->flags.db_mode[chan]); chan_ctxt->db_mode.db_mode); } /* Event Doorbell and Polling mode Disabled */ } else if (io_addr == mhi_dev_ctxt->mmio_info.event_db_addr) { Loading @@ -1683,11 +1690,9 @@ void mhi_process_db(struct mhi_device_ctxt *mhi_dev_ctxt, if (IS_SW_EV_RING(mhi_dev_ctxt, chan) || !mhi_dev_ctxt->flags.uldl_enabled) { mhi_write_db(mhi_dev_ctxt, io_addr, chan, val); mhi_dev_ctxt->flags.db_mode[chan] = 0; } } else { mhi_write_db(mhi_dev_ctxt, io_addr, chan, val); mhi_dev_ctxt->flags.db_mode[chan] = 0; } } Loading Loading
Documentation/devicetree/bindings/mhi/msm_mhi.txt +5 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,11 @@ Required properties: - qcom,msm-bus,num-paths - qcom,msm-bus,vectors-KBps - mhi-chan-cfg-#: mhi channel configuration parameters for platform defined as below <A B C D>: A = chan number B = maximum descriptors C = event ring associated with channel D = flags defined by mhi_macros.h GET_CHAN_PROPS - mhi-event-cfg-#: mhi event ring configuration parameters for platform - mhi-event-rings: number of event rings supported by platform - mhi-dev-address-win-size: size of the MHI device addressing window Loading
drivers/platform/msm/mhi/mhi.h +9 −2 Original line number Diff line number Diff line Loading @@ -261,6 +261,12 @@ enum MHI_EVENT_CCS { MHI_EVENT_CC_BAD_TRE = 0x11, }; struct db_mode { /* if set do not reset DB_Mode during M0 resume */ u32 preserve_db_state : 1; u32 db_mode : 1; }; struct mhi_ring { void *base; void *wp; Loading @@ -270,6 +276,7 @@ struct mhi_ring { uintptr_t el_size; u32 overwrite_en; enum MHI_CHAN_DIR dir; struct db_mode db_mode; }; enum MHI_CMD_STATUS { Loading Loading @@ -414,7 +421,6 @@ struct mhi_flags { u32 ev_thread_stopped; u32 st_thread_stopped; u32 uldl_enabled; u32 db_mode[MHI_MAX_CHANNELS]; }; struct mhi_wait_queues { Loading Loading @@ -577,7 +583,8 @@ int mhi_init_chan_ctxt(struct mhi_chan_ctxt *cc_list, enum MHI_CHAN_DIR chan_type, u32 event_ring, struct mhi_ring *ring, enum MHI_CHAN_STATE chan_state); enum MHI_CHAN_STATE chan_state, bool preserve_db_state); int mhi_populate_event_cfg(struct mhi_device_ctxt *mhi_dev_ctxt); int mhi_get_event_ring_for_channel(struct mhi_device_ctxt *mhi_dev_ctxt, u32 chan); Loading
drivers/platform/msm/mhi/mhi_init.c +16 −12 Original line number Diff line number Diff line Loading @@ -592,14 +592,16 @@ error_during_props: * @chan_type: Type of channel IN/OUT * @event_ring: Event ring to be mapped to this channel context * @ring: Shadow context to be initialized alongside * * @chan_state: Channel state * @preserve_db_state: Do not reset DB state during resume * @Return errno */ int mhi_init_chan_ctxt(struct mhi_chan_ctxt *cc_list, uintptr_t trb_list_phy, uintptr_t trb_list_virt, u64 el_per_ring, enum MHI_CHAN_DIR chan_type, u32 event_ring, struct mhi_ring *ring, enum MHI_CHAN_STATE chan_state) enum MHI_CHAN_STATE chan_state, bool preserve_db_state) { cc_list->mhi_chan_state = chan_state; cc_list->mhi_chan_type = chan_type; Loading @@ -617,6 +619,8 @@ int mhi_init_chan_ctxt(struct mhi_chan_ctxt *cc_list, ring->el_size = sizeof(struct mhi_tx_pkt); ring->overwrite_en = 0; ring->dir = chan_type; ring->db_mode.db_mode = 1; ring->db_mode.preserve_db_state = (preserve_db_state) ? 1 : 0; /* Flush writes to MMIO */ wmb(); return 0; Loading
drivers/platform/msm/mhi/mhi_macros.h +4 −0 Original line number Diff line number Diff line Loading @@ -244,6 +244,10 @@ #define MHI_CHAN_TYPE__MASK (3) #define MHI_CHAN_TYPE__SHIFT (6) #define PRESERVE_DB_STATE #define MHI_PRESERVE_DB_STATE__MASK (1) #define MHI_PRESERVE_DB_STATE__SHIFT (8) #define GET_CHAN_PROPS(_FIELD, _VAL) \ (((_VAL) >> MHI_##_FIELD ## __SHIFT) & MHI_##_FIELD ## __MASK) Loading
drivers/platform/msm/mhi/mhi_main.c +15 −10 Original line number Diff line number Diff line Loading @@ -212,7 +212,7 @@ int mhi_release_chan_ctxt(struct mhi_device_ctxt *mhi_dev_ctxt, ring->len, ring->base, cc_list->mhi_trb_ring_base_addr); mhi_init_chan_ctxt(cc_list, 0, 0, 0, 0, 0, ring, MHI_CHAN_STATE_DISABLED); MHI_CHAN_STATE_DISABLED, false); return 0; } Loading Loading @@ -259,7 +259,9 @@ static int populate_tre_ring(struct mhi_client_handle *client_handle) client_handle->chan_info.flags), client_handle->chan_info.ev_ring, &mhi_dev_ctxt->mhi_local_chan_ctxt[chan], MHI_CHAN_STATE_ENABLED); MHI_CHAN_STATE_ENABLED, GET_CHAN_PROPS(PRESERVE_DB_STATE, client_handle->chan_info.flags)); mhi_log(MHI_MSG_INFO, "Exited\n"); return 0; } Loading Loading @@ -654,6 +656,7 @@ static int mhi_queue_dma_xfer( MHI_ASSERT(VALID_BUF(buf, buf_len, mhi_dev_ctxt), "Client buffer is of invalid length\n"); chan = client_handle->chan_info.chan_nr; mhi_log(MHI_MSG_INFO, "Getting Reference %d", chan); pm_runtime_get(&mhi_dev_ctxt->dev_info->pcie_device->dev); Loading Loading @@ -698,6 +701,7 @@ static int mhi_queue_dma_xfer( error: pm_runtime_mark_last_busy(&mhi_dev_ctxt->dev_info->pcie_device->dev); mhi_log(MHI_MSG_INFO, "Putting Reference %d", chan); pm_runtime_put_noidle(&mhi_dev_ctxt->dev_info->pcie_device->dev); return ret_val; Loading Loading @@ -1169,12 +1173,13 @@ int parse_xfer_event(struct mhi_device_ctxt *ctxt, mhi_dev_ctxt->flags.uldl_enabled = 1; chan = MHI_EV_READ_CHID(EV_CHID, event); mhi_dev_ctxt->flags.db_mode[chan] = 1; chan_ctxt = &mhi_dev_ctxt->mhi_local_chan_ctxt[chan]; mhi_log(MHI_MSG_INFO, "DB_MODE/OOB Detected chan %d.\n", chan); spin_lock_irqsave(&mhi_dev_ctxt->db_write_lock[chan], flags); chan_ctxt->db_mode.db_mode = 1; if (chan_ctxt->wp != chan_ctxt->rp) { db_value = mhi_v2p_addr(mhi_dev_ctxt, MHI_RING_TYPE_XFER_RING, chan, Loading Loading @@ -1658,6 +1663,8 @@ void mhi_process_db(struct mhi_device_ctxt *mhi_dev_ctxt, void __iomem *io_addr, uintptr_t chan, u32 val) { struct mhi_ring *chan_ctxt = &mhi_dev_ctxt->mhi_local_chan_ctxt[chan]; mhi_log(MHI_MSG_VERBOSE, "db.set addr: %p io_offset 0x%lx val:0x%x\n", io_addr, chan, val); Loading @@ -1668,14 +1675,14 @@ void mhi_process_db(struct mhi_device_ctxt *mhi_dev_ctxt, if (io_addr == mhi_dev_ctxt->mmio_info.chan_db_addr) { if (!(IS_HARDWARE_CHANNEL(chan) && mhi_dev_ctxt->flags.uldl_enabled && !mhi_dev_ctxt->flags.db_mode[chan])) { !chan_ctxt->db_mode.db_mode)) { mhi_write_db(mhi_dev_ctxt, io_addr, chan, val); mhi_dev_ctxt->flags.db_mode[chan] = 0; chan_ctxt->db_mode.db_mode = 0; } else { mhi_log(MHI_MSG_INFO, "Not ringing xfer db, chan %ld, ul_dl %d db_mode %d\n", chan, mhi_dev_ctxt->flags.uldl_enabled, mhi_dev_ctxt->flags.db_mode[chan]); chan_ctxt->db_mode.db_mode); } /* Event Doorbell and Polling mode Disabled */ } else if (io_addr == mhi_dev_ctxt->mmio_info.event_db_addr) { Loading @@ -1683,11 +1690,9 @@ void mhi_process_db(struct mhi_device_ctxt *mhi_dev_ctxt, if (IS_SW_EV_RING(mhi_dev_ctxt, chan) || !mhi_dev_ctxt->flags.uldl_enabled) { mhi_write_db(mhi_dev_ctxt, io_addr, chan, val); mhi_dev_ctxt->flags.db_mode[chan] = 0; } } else { mhi_write_db(mhi_dev_ctxt, io_addr, chan, val); mhi_dev_ctxt->flags.db_mode[chan] = 0; } } Loading