.. | .. |
---|
36 | 36 | #include "mpp_common.h" |
---|
37 | 37 | #include "mpp_iommu.h" |
---|
38 | 38 | |
---|
39 | | -#define MPP_WAIT_TIMEOUT_DELAY (2000) |
---|
40 | | - |
---|
41 | 39 | /* Use 'v' as magic number */ |
---|
42 | 40 | #define MPP_IOC_MAGIC 'v' |
---|
43 | 41 | |
---|
.. | .. |
---|
355 | 353 | mutex_unlock(&queue->session_lock); |
---|
356 | 354 | |
---|
357 | 355 | if (task_count) { |
---|
358 | | - mpp_dbg_session("session %d:%d task not finished %d\n", |
---|
359 | | - session->pid, session->index, |
---|
360 | | - atomic_read(&queue->detach_count)); |
---|
| 356 | + mpp_dbg_session("session %d:%d not finished %d task cnt %d\n", |
---|
| 357 | + session->device_type, session->index, |
---|
| 358 | + atomic_read(&queue->detach_count), task_count); |
---|
361 | 359 | |
---|
362 | 360 | mpp_session_clear_pending(session); |
---|
363 | 361 | } else { |
---|
.. | .. |
---|
588 | 586 | mpp_dev_reset(mpp); |
---|
589 | 587 | mpp_power_off(mpp); |
---|
590 | 588 | |
---|
| 589 | + mpp_iommu_dev_deactivate(mpp->iommu_info, mpp); |
---|
591 | 590 | set_bit(TASK_STATE_TIMEOUT, &task->state); |
---|
592 | 591 | set_bit(TASK_STATE_DONE, &task->state); |
---|
593 | 592 | /* Wake up the GET thread */ |
---|
.. | .. |
---|
717 | 716 | group->resets[type] = rst; |
---|
718 | 717 | group->queue = mpp->queue; |
---|
719 | 718 | } |
---|
720 | | - /* if reset not in the same queue, it means different device |
---|
721 | | - * may reset in the same time, then rw_sem_on should set true. |
---|
722 | | - */ |
---|
723 | | - group->rw_sem_on |= (group->queue != mpp->queue) ? true : false; |
---|
724 | 719 | dev_info(mpp->dev, "reset_group->rw_sem_on=%d\n", group->rw_sem_on); |
---|
725 | 720 | up_write(&group->rw_sem); |
---|
726 | 721 | |
---|
.. | .. |
---|
821 | 816 | mpp_set_grf(mpp->grf_info); |
---|
822 | 817 | } |
---|
823 | 818 | /* |
---|
| 819 | + * Lock the reader locker of the device resource lock here, |
---|
| 820 | + * release at the finish operation |
---|
| 821 | + */ |
---|
| 822 | + mpp_reset_down_read(mpp->reset_group); |
---|
| 823 | + |
---|
| 824 | + /* |
---|
824 | 825 | * for iommu share hardware, should attach to ensure |
---|
825 | 826 | * working in current device |
---|
826 | 827 | */ |
---|
827 | 828 | ret = mpp_iommu_attach(mpp->iommu_info); |
---|
828 | 829 | if (ret) { |
---|
829 | 830 | dev_err(mpp->dev, "mpp_iommu_attach failed\n"); |
---|
| 831 | + mpp_reset_up_read(mpp->reset_group); |
---|
830 | 832 | return -ENODATA; |
---|
831 | 833 | } |
---|
832 | 834 | |
---|
.. | .. |
---|
836 | 838 | |
---|
837 | 839 | if (mpp->auto_freq_en && mpp->hw_ops->set_freq) |
---|
838 | 840 | mpp->hw_ops->set_freq(mpp, task); |
---|
839 | | - /* |
---|
840 | | - * TODO: Lock the reader locker of the device resource lock here, |
---|
841 | | - * release at the finish operation |
---|
842 | | - */ |
---|
843 | | - mpp_reset_down_read(mpp->reset_group); |
---|
844 | 841 | |
---|
845 | 842 | mpp_iommu_dev_activate(mpp->iommu_info, mpp); |
---|
846 | 843 | if (mpp->dev_ops->run) |
---|
.. | .. |
---|
922 | 919 | } |
---|
923 | 920 | mpp = mpp_get_task_used_device(task, session); |
---|
924 | 921 | |
---|
925 | | - ret = wait_event_timeout(task->wait, |
---|
926 | | - test_bit(TASK_STATE_DONE, &task->state), |
---|
927 | | - msecs_to_jiffies(MPP_WAIT_TIMEOUT_DELAY)); |
---|
928 | | - if (ret > 0) { |
---|
929 | | - if (mpp->dev_ops->result) |
---|
930 | | - ret = mpp->dev_ops->result(mpp, task, msgs); |
---|
931 | | - } else { |
---|
932 | | - atomic_inc(&task->abort_request); |
---|
933 | | - set_bit(TASK_STATE_ABORT, &task->state); |
---|
934 | | - mpp_err("timeout, pid %d session %d:%d count %d cur_task %p id %d\n", |
---|
935 | | - session->pid, session->pid, session->index, |
---|
936 | | - atomic_read(&session->task_count), task, |
---|
937 | | - task->task_id); |
---|
938 | | - } |
---|
| 922 | + ret = wait_event_interruptible(task->wait, test_bit(TASK_STATE_DONE, &task->state)); |
---|
| 923 | + if (ret == -ERESTARTSYS) |
---|
| 924 | + mpp_err("wait task break by signal\n"); |
---|
939 | 925 | |
---|
940 | | - mpp_debug_func(DEBUG_TASK_INFO, "task %d kref_%d\n", |
---|
941 | | - task->task_id, kref_read(&task->ref)); |
---|
| 926 | + if (mpp->dev_ops->result) |
---|
| 927 | + ret = mpp->dev_ops->result(mpp, task, msgs); |
---|
| 928 | + mpp_debug_func(DEBUG_TASK_INFO, "wait done session %d:%d count %d task %d state %lx\n", |
---|
| 929 | + session->device_type, session->index, atomic_read(&session->task_count), |
---|
| 930 | + task->task_index, task->state); |
---|
942 | 931 | |
---|
943 | 932 | mpp_session_pop_pending(session, task); |
---|
944 | 933 | |
---|
.. | .. |
---|
1013 | 1002 | return -ENODEV; |
---|
1014 | 1003 | } else { |
---|
1015 | 1004 | mpp->reset_group = mpp->srv->reset_groups[reset_group_node]; |
---|
| 1005 | + if (!mpp->reset_group->queue) |
---|
| 1006 | + mpp->reset_group->queue = queue; |
---|
| 1007 | + if (mpp->reset_group->queue != mpp->queue) |
---|
| 1008 | + mpp->reset_group->rw_sem_on = true; |
---|
1016 | 1009 | } |
---|
1017 | 1010 | } |
---|
1018 | 1011 | |
---|
.. | .. |
---|
2266 | 2259 | irq_ret = mpp->dev_ops->irq(mpp); |
---|
2267 | 2260 | |
---|
2268 | 2261 | if (task) { |
---|
2269 | | - if (irq_ret != IRQ_NONE) { |
---|
| 2262 | + if (irq_ret == IRQ_WAKE_THREAD) { |
---|
2270 | 2263 | /* if wait or delayed work timeout, abort request will turn on, |
---|
2271 | 2264 | * isr should not to response, and handle it in delayed work |
---|
2272 | 2265 | */ |
---|