Lines Matching refs:win
96 struct msc_window *win; member
278 static inline struct scatterlist *msc_win_base_sg(struct msc_window *win) in msc_win_base_sg() argument
280 return win->sgt->sgl; in msc_win_base_sg()
283 static inline struct msc_block_desc *msc_win_base(struct msc_window *win) in msc_win_base() argument
285 return sg_virt(msc_win_base_sg(win)); in msc_win_base()
288 static inline dma_addr_t msc_win_base_dma(struct msc_window *win) in msc_win_base_dma() argument
290 return sg_dma_address(msc_win_base_sg(win)); in msc_win_base_dma()
294 msc_win_base_pfn(struct msc_window *win) in msc_win_base_pfn() argument
296 return PFN_DOWN(msc_win_base_dma(win)); in msc_win_base_pfn()
304 static inline bool msc_is_last_win(struct msc_window *win) in msc_is_last_win() argument
306 return win->entry.next == &win->msc->win_list; in msc_is_last_win()
315 static struct msc_window *msc_next_window(struct msc_window *win) in msc_next_window() argument
317 if (msc_is_last_win(win)) in msc_next_window()
318 return list_first_entry(&win->msc->win_list, struct msc_window, in msc_next_window()
321 return list_next_entry(win, entry); in msc_next_window()
324 static size_t msc_win_total_sz(struct msc_window *win) in msc_win_total_sz() argument
330 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_win_total_sz()
334 return (size_t)win->nr_blocks << PAGE_SHIFT; in msc_win_total_sz()
356 struct msc_window *win; in msc_find_window() local
367 list_for_each_entry(win, &msc->win_list, entry) { in msc_find_window()
368 if (win->sgt == sgt) in msc_find_window()
372 if (nonempty && msc_block_is_empty(msc_win_base(win))) in msc_find_window()
376 return win; in msc_find_window()
393 struct msc_window *win; in msc_oldest_window() local
398 win = msc_find_window(msc, msc_next_window(msc->cur_win)->sgt, true); in msc_oldest_window()
399 if (win) in msc_oldest_window()
400 return win; in msc_oldest_window()
411 static struct scatterlist *msc_win_oldest_sg(struct msc_window *win) in msc_win_oldest_sg() argument
415 struct msc_block_desc *bdesc = msc_win_base(win); in msc_win_oldest_sg()
419 return msc_win_base_sg(win); in msc_win_oldest_sg()
425 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_win_oldest_sg()
432 return msc_win_base_sg(win); in msc_win_oldest_sg()
485 iter->start_block = msc_win_oldest_sg(iter->win); in msc_iter_block_start()
508 iter->win = iter->start_win; in msc_iter_win_start()
518 iter->win = msc_next_window(iter->win); in msc_iter_win_advance()
521 if (iter->win == iter->start_win) { in msc_iter_win_advance()
550 iter->block = msc_win_base_sg(iter->win); in msc_iter_block_advance()
656 struct msc_window *win; in msc_buffer_clear_hw_header() local
659 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_clear_hw_header()
662 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_clear_hw_header()
707 static int msc_win_set_lockout(struct msc_window *win, in msc_win_set_lockout() argument
715 if (!win->msc->mbuf) in msc_win_set_lockout()
718 spin_lock_irqsave(&win->lo_lock, flags); in msc_win_set_lockout()
719 old = win->lockout; in msc_win_set_lockout()
726 win->lockout = new; in msc_win_set_lockout()
729 atomic_inc(&win->msc->user_count); in msc_win_set_lockout()
731 atomic_dec(&win->msc->user_count); in msc_win_set_lockout()
734 spin_unlock_irqrestore(&win->lo_lock, flags); in msc_win_set_lockout()
744 dev_warn_ratelimited(msc_dev(win->msc), in msc_win_set_lockout()
819 struct msc_window *win = msc->cur_win; in msc_disable() local
825 msc_win_set_lockout(win, WIN_INUSE, WIN_LOCKED); in msc_disable()
847 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in msc_disable()
848 msc_win_total_sz(win)); in msc_disable()
991 static int __msc_buffer_win_alloc(struct msc_window *win, in __msc_buffer_win_alloc() argument
998 ret = sg_alloc_table(win->sgt, nr_segs, GFP_KERNEL); in __msc_buffer_win_alloc()
1002 for_each_sg(win->sgt->sgl, sg_ptr, nr_segs, i) { in __msc_buffer_win_alloc()
1003 block = dma_alloc_coherent(msc_dev(win->msc)->parent->parent, in __msc_buffer_win_alloc()
1015 for_each_sg(win->sgt->sgl, sg_ptr, i, ret) in __msc_buffer_win_alloc()
1016 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_alloc()
1019 sg_free_table(win->sgt); in __msc_buffer_win_alloc()
1028 struct msc_window *win; in msc_buffer_set_uc() local
1036 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_set_uc()
1037 for_each_sg(win->sgt->sgl, sg_ptr, win->nr_segs, i) { in msc_buffer_set_uc()
1048 struct msc_window *win; in msc_buffer_set_wb() local
1056 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_set_wb()
1057 for_each_sg(win->sgt->sgl, sg_ptr, win->nr_segs, i) { in msc_buffer_set_wb()
1092 struct msc_window *win; in msc_buffer_win_alloc() local
1098 win = kzalloc(sizeof(*win), GFP_KERNEL); in msc_buffer_win_alloc()
1099 if (!win) in msc_buffer_win_alloc()
1102 win->msc = msc; in msc_buffer_win_alloc()
1103 win->sgt = &win->_sgt; in msc_buffer_win_alloc()
1104 win->lockout = WIN_READY; in msc_buffer_win_alloc()
1105 spin_lock_init(&win->lo_lock); in msc_buffer_win_alloc()
1112 win->pgoff = prev->pgoff + prev->nr_blocks; in msc_buffer_win_alloc()
1116 ret = msc->mbuf->alloc_window(msc->mbuf_priv, &win->sgt, in msc_buffer_win_alloc()
1119 ret = __msc_buffer_win_alloc(win, nr_blocks); in msc_buffer_win_alloc()
1124 win->nr_segs = ret; in msc_buffer_win_alloc()
1125 win->nr_blocks = nr_blocks; in msc_buffer_win_alloc()
1128 msc->base = msc_win_base(win); in msc_buffer_win_alloc()
1129 msc->base_addr = msc_win_base_dma(win); in msc_buffer_win_alloc()
1130 msc->cur_win = win; in msc_buffer_win_alloc()
1133 list_add_tail(&win->entry, &msc->win_list); in msc_buffer_win_alloc()
1139 kfree(win); in msc_buffer_win_alloc()
1144 static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win) in __msc_buffer_win_free() argument
1149 for_each_sg(win->sgt->sgl, sg, win->nr_segs, i) { in __msc_buffer_win_free()
1153 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_free()
1156 sg_free_table(win->sgt); in __msc_buffer_win_free()
1167 static void msc_buffer_win_free(struct msc *msc, struct msc_window *win) in msc_buffer_win_free() argument
1169 msc->nr_pages -= win->nr_blocks; in msc_buffer_win_free()
1171 list_del(&win->entry); in msc_buffer_win_free()
1178 msc->mbuf->free_window(msc->mbuf_priv, win->sgt); in msc_buffer_win_free()
1180 __msc_buffer_win_free(msc, win); in msc_buffer_win_free()
1182 kfree(win); in msc_buffer_win_free()
1194 struct msc_window *win, *next_win; in msc_buffer_relink() local
1197 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_relink()
1206 if (msc_is_last_win(win)) { in msc_buffer_relink()
1211 next_win = list_next_entry(win, entry); in msc_buffer_relink()
1214 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_relink()
1225 if (blk == win->nr_segs - 1) { in msc_buffer_relink()
1227 bdesc->next_blk = msc_win_base_pfn(win); in msc_buffer_relink()
1248 struct msc_window *win, *iter; in msc_buffer_multi_free() local
1250 list_for_each_entry_safe(win, iter, &msc->win_list, entry) in msc_buffer_multi_free()
1251 msc_buffer_win_free(msc, win); in msc_buffer_multi_free()
1397 struct msc_window *win; in msc_buffer_get_page() local
1404 list_for_each_entry(win, &msc->win_list, entry) in msc_buffer_get_page()
1405 if (pgoff >= win->pgoff && pgoff < win->pgoff + win->nr_blocks) in msc_buffer_get_page()
1411 pgoff -= win->pgoff; in msc_buffer_get_page()
1413 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_get_page()
1738 struct msc_window *win; in intel_th_msc_window_unlock() local
1743 win = msc_find_window(msc, sgt, false); in intel_th_msc_window_unlock()
1744 if (!win) in intel_th_msc_window_unlock()
1747 msc_win_set_lockout(win, WIN_LOCKED, WIN_READY); in intel_th_msc_window_unlock()
1748 if (msc->switch_on_unlock == win) { in intel_th_msc_window_unlock()
1767 struct msc_window *win, *next_win; in intel_th_msc_interrupt() local
1783 win = msc->cur_win; in intel_th_msc_interrupt()
1784 if (!win) in intel_th_msc_interrupt()
1786 next_win = msc_next_window(win); in intel_th_msc_interrupt()
1801 msc_win_set_lockout(win, WIN_INUSE, WIN_LOCKED); in intel_th_msc_interrupt()
1806 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in intel_th_msc_interrupt()
1807 msc_win_total_sz(win)); in intel_th_msc_interrupt()
1964 struct msc_window *win; in nr_pages_show() local
1972 list_for_each_entry(win, &msc->win_list, entry) { in nr_pages_show()
1974 "%d%c", win->nr_blocks, in nr_pages_show()
1975 msc_is_last_win(win) ? '\n' : ','); in nr_pages_show()
1991 unsigned long val, *win = NULL, *rewin; in nr_pages_store() local
2029 rewin = krealloc_array(win, nr_wins, sizeof(*win), GFP_KERNEL); in nr_pages_store()
2031 kfree(win); in nr_pages_store()
2035 win = rewin; in nr_pages_store()
2036 win[nr_wins - 1] = val; in nr_pages_store()
2047 ret = msc_buffer_alloc(msc, win, nr_wins); in nr_pages_store()
2051 kfree(win); in nr_pages_store()