Skip to content

Commit 1d3173a

Browse files
Mani-Sadhasivamgregkh
authored andcommitted
bus: mhi: core: Add support for processing events from client device
This commit adds support for processing the MHI data and control events from the client device. The client device can report various events such as EE events, state change events by interrupting the host through IRQ and adding events to the event rings allocated by the host during initialization. This is based on the patch submitted by Sujeev Dias: https://lkml.org/lkml/2018/7/9/988 Signed-off-by: Sujeev Dias <[email protected]> Signed-off-by: Siddartha Mohanadoss <[email protected]> [mani: splitted the data transfer patch and cleaned up for upstream] Signed-off-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Jeffrey Hugo <[email protected]> Tested-by: Jeffrey Hugo <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 6fdfdd2 commit 1d3173a

File tree

4 files changed

+510
-0
lines changed

4 files changed

+510
-0
lines changed

drivers/bus/mhi/core/init.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,18 @@ static int parse_ev_cfg(struct mhi_controller *mhi_cntrl,
543543

544544
mhi_event->data_type = event_cfg->data_type;
545545

546+
switch (mhi_event->data_type) {
547+
case MHI_ER_DATA:
548+
mhi_event->process_event = mhi_process_data_event_ring;
549+
break;
550+
case MHI_ER_CTRL:
551+
mhi_event->process_event = mhi_process_ctrl_ev_ring;
552+
break;
553+
default:
554+
dev_err(dev, "Event Ring type not supported\n");
555+
goto error_ev_cfg;
556+
}
557+
546558
mhi_event->hw_ring = event_cfg->hardware_event;
547559
if (mhi_event->hw_ring)
548560
mhi_cntrl->hw_ev_rings++;
@@ -772,6 +784,12 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl,
772784

773785
mhi_event->mhi_cntrl = mhi_cntrl;
774786
spin_lock_init(&mhi_event->lock);
787+
if (mhi_event->data_type == MHI_ER_CTRL)
788+
tasklet_init(&mhi_event->task, mhi_ctrl_ev_task,
789+
(ulong)mhi_event);
790+
else
791+
tasklet_init(&mhi_event->task, mhi_ev_task,
792+
(ulong)mhi_event);
775793
}
776794

777795
mhi_chan = mhi_cntrl->mhi_chan;

drivers/bus/mhi/core/internal.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,8 @@ struct mhi_buf_info {
500500
dma_addr_t p_addr;
501501
size_t len;
502502
enum dma_data_direction dir;
503+
bool used; /* Indicates whether the buffer is used or not */
504+
bool pre_mapped; /* Already pre-mapped by client */
503505
};
504506

505507
struct mhi_event {
@@ -637,6 +639,14 @@ static inline void mhi_free_coherent(struct mhi_controller *mhi_cntrl,
637639
dma_free_coherent(mhi_cntrl->cntrl_dev, size, vaddr, dma_handle);
638640
}
639641

642+
/* Event processing methods */
643+
void mhi_ctrl_ev_task(unsigned long data);
644+
void mhi_ev_task(unsigned long data);
645+
int mhi_process_data_event_ring(struct mhi_controller *mhi_cntrl,
646+
struct mhi_event *mhi_event, u32 event_quota);
647+
int mhi_process_ctrl_ev_ring(struct mhi_controller *mhi_cntrl,
648+
struct mhi_event *mhi_event, u32 event_quota);
649+
640650
/* ISR handlers */
641651
irqreturn_t mhi_irq_handler(int irq_number, void *dev);
642652
irqreturn_t mhi_intvec_threaded_handler(int irq_number, void *dev);

0 commit comments

Comments
 (0)