Lines Matching refs:qi
837 static inline void reclaim_free_desc(struct q_inval *qi) in reclaim_free_desc() argument
839 while (qi->desc_status[qi->free_tail] == QI_DONE || in reclaim_free_desc()
840 qi->desc_status[qi->free_tail] == QI_ABORT) { in reclaim_free_desc()
841 qi->desc_status[qi->free_tail] = QI_FREE; in reclaim_free_desc()
842 qi->free_tail = (qi->free_tail + 1) % QI_LENGTH; in reclaim_free_desc()
843 qi->free_cnt++; in reclaim_free_desc()
851 struct q_inval *qi = iommu->qi; in qi_check_fault() local
854 if (qi->desc_status[wait_index] == QI_ABORT) in qi_check_fault()
869 (unsigned long long)qi->desc[index].low, in qi_check_fault()
870 (unsigned long long)qi->desc[index].high); in qi_check_fault()
871 memcpy(&qi->desc[index], &qi->desc[wait_index], in qi_check_fault()
873 __iommu_flush_cache(iommu, &qi->desc[index], in qi_check_fault()
894 if (qi->desc_status[head] == QI_IN_USE) in qi_check_fault()
895 qi->desc_status[head] = QI_ABORT; in qi_check_fault()
899 if (qi->desc_status[wait_index] == QI_ABORT) in qi_check_fault()
916 struct q_inval *qi = iommu->qi; in qi_submit_sync() local
921 if (!qi) in qi_submit_sync()
924 hw = qi->desc; in qi_submit_sync()
929 spin_lock_irqsave(&qi->q_lock, flags); in qi_submit_sync()
930 while (qi->free_cnt < 3) { in qi_submit_sync()
931 spin_unlock_irqrestore(&qi->q_lock, flags); in qi_submit_sync()
933 spin_lock_irqsave(&qi->q_lock, flags); in qi_submit_sync()
936 index = qi->free_head; in qi_submit_sync()
939 qi->desc_status[index] = qi->desc_status[wait_index] = QI_IN_USE; in qi_submit_sync()
945 wait_desc.high = virt_to_phys(&qi->desc_status[wait_index]); in qi_submit_sync()
952 qi->free_head = (qi->free_head + 2) % QI_LENGTH; in qi_submit_sync()
953 qi->free_cnt -= 2; in qi_submit_sync()
959 writel(qi->free_head << DMAR_IQ_SHIFT, iommu->reg + DMAR_IQT_REG); in qi_submit_sync()
961 while (qi->desc_status[wait_index] != QI_DONE) { in qi_submit_sync()
973 spin_unlock(&qi->q_lock); in qi_submit_sync()
975 spin_lock(&qi->q_lock); in qi_submit_sync()
978 qi->desc_status[index] = QI_DONE; in qi_submit_sync()
980 reclaim_free_desc(qi); in qi_submit_sync()
981 spin_unlock_irqrestore(&qi->q_lock, flags); in qi_submit_sync()
1100 struct q_inval *qi = iommu->qi; in __dmar_enable_qi() local
1102 qi->free_head = qi->free_tail = 0; in __dmar_enable_qi()
1103 qi->free_cnt = QI_LENGTH; in __dmar_enable_qi()
1110 dmar_writeq(iommu->reg + DMAR_IQA_REG, virt_to_phys(qi->desc)); in __dmar_enable_qi()
1128 struct q_inval *qi; in dmar_enable_qi() local
1137 if (iommu->qi) in dmar_enable_qi()
1140 iommu->qi = kmalloc(sizeof(*qi), GFP_ATOMIC); in dmar_enable_qi()
1141 if (!iommu->qi) in dmar_enable_qi()
1144 qi = iommu->qi; in dmar_enable_qi()
1149 kfree(qi); in dmar_enable_qi()
1150 iommu->qi = 0; in dmar_enable_qi()
1154 qi->desc = page_address(desc_page); in dmar_enable_qi()
1156 qi->desc_status = kmalloc(QI_LENGTH * sizeof(int), GFP_ATOMIC); in dmar_enable_qi()
1157 if (!qi->desc_status) { in dmar_enable_qi()
1158 free_page((unsigned long) qi->desc); in dmar_enable_qi()
1159 kfree(qi); in dmar_enable_qi()
1160 iommu->qi = 0; in dmar_enable_qi()
1164 qi->free_head = qi->free_tail = 0; in dmar_enable_qi()
1165 qi->free_cnt = QI_LENGTH; in dmar_enable_qi()
1167 spin_lock_init(&qi->q_lock); in dmar_enable_qi()
1438 if (!iommu->qi) in dmar_reenable_qi()