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()
664 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_clear_hw_header()
709 static int msc_win_set_lockout(struct msc_window *win, in msc_win_set_lockout() argument
717 if (!win->msc->mbuf) in msc_win_set_lockout()
720 spin_lock_irqsave(&win->lo_lock, flags); in msc_win_set_lockout()
721 old = win->lockout; in msc_win_set_lockout()
728 win->lockout = new; in msc_win_set_lockout()
731 atomic_inc(&win->msc->user_count); in msc_win_set_lockout()
733 atomic_dec(&win->msc->user_count); in msc_win_set_lockout()
736 spin_unlock_irqrestore(&win->lo_lock, flags); in msc_win_set_lockout()
746 dev_warn_ratelimited(msc_dev(win->msc), in msc_win_set_lockout()
821 struct msc_window *win = msc->cur_win; in msc_disable() local
827 msc_win_set_lockout(win, WIN_INUSE, WIN_LOCKED); in msc_disable()
849 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in msc_disable()
850 msc_win_total_sz(win)); in msc_disable()
993 static int __msc_buffer_win_alloc(struct msc_window *win, in __msc_buffer_win_alloc() argument
1000 ret = sg_alloc_table(win->sgt, nr_segs, GFP_KERNEL); in __msc_buffer_win_alloc()
1004 for_each_sg(win->sgt->sgl, sg_ptr, nr_segs, i) { in __msc_buffer_win_alloc()
1005 block = dma_alloc_coherent(msc_dev(win->msc)->parent->parent, in __msc_buffer_win_alloc()
1017 for_each_sg(win->sgt->sgl, sg_ptr, i, ret) in __msc_buffer_win_alloc()
1018 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_alloc()
1021 sg_free_table(win->sgt); in __msc_buffer_win_alloc()
1030 struct msc_window *win; in msc_buffer_set_uc() local
1038 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_set_uc()
1039 for_each_sg(win->sgt->sgl, sg_ptr, win->nr_segs, i) { in msc_buffer_set_uc()
1050 struct msc_window *win; in msc_buffer_set_wb() local
1058 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_set_wb()
1059 for_each_sg(win->sgt->sgl, sg_ptr, win->nr_segs, i) { in msc_buffer_set_wb()
1084 struct msc_window *win; in msc_buffer_win_alloc() local
1090 win = kzalloc(sizeof(*win), GFP_KERNEL); in msc_buffer_win_alloc()
1091 if (!win) in msc_buffer_win_alloc()
1094 win->msc = msc; in msc_buffer_win_alloc()
1095 win->sgt = &win->_sgt; in msc_buffer_win_alloc()
1096 win->lockout = WIN_READY; in msc_buffer_win_alloc()
1097 spin_lock_init(&win->lo_lock); in msc_buffer_win_alloc()
1104 win->pgoff = prev->pgoff + prev->nr_blocks; in msc_buffer_win_alloc()
1108 ret = msc->mbuf->alloc_window(msc->mbuf_priv, &win->sgt, in msc_buffer_win_alloc()
1111 ret = __msc_buffer_win_alloc(win, nr_blocks); in msc_buffer_win_alloc()
1116 win->nr_segs = ret; in msc_buffer_win_alloc()
1117 win->nr_blocks = nr_blocks; in msc_buffer_win_alloc()
1120 msc->base = msc_win_base(win); in msc_buffer_win_alloc()
1121 msc->base_addr = msc_win_base_dma(win); in msc_buffer_win_alloc()
1122 msc->cur_win = win; in msc_buffer_win_alloc()
1125 list_add_tail(&win->entry, &msc->win_list); in msc_buffer_win_alloc()
1131 kfree(win); in msc_buffer_win_alloc()
1136 static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win) in __msc_buffer_win_free() argument
1141 for_each_sg(win->sgt->sgl, sg, win->nr_segs, i) { in __msc_buffer_win_free()
1145 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_free()
1148 sg_free_table(win->sgt); in __msc_buffer_win_free()
1159 static void msc_buffer_win_free(struct msc *msc, struct msc_window *win) in msc_buffer_win_free() argument
1161 msc->nr_pages -= win->nr_blocks; in msc_buffer_win_free()
1163 list_del(&win->entry); in msc_buffer_win_free()
1170 msc->mbuf->free_window(msc->mbuf_priv, win->sgt); in msc_buffer_win_free()
1172 __msc_buffer_win_free(msc, win); in msc_buffer_win_free()
1174 kfree(win); in msc_buffer_win_free()
1186 struct msc_window *win, *next_win; in msc_buffer_relink() local
1189 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_relink()
1198 if (msc_is_last_win(win)) { in msc_buffer_relink()
1203 next_win = list_next_entry(win, entry); in msc_buffer_relink()
1206 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_relink()
1217 if (blk == win->nr_segs - 1) { in msc_buffer_relink()
1219 bdesc->next_blk = msc_win_base_pfn(win); in msc_buffer_relink()
1240 struct msc_window *win, *iter; in msc_buffer_multi_free() local
1242 list_for_each_entry_safe(win, iter, &msc->win_list, entry) in msc_buffer_multi_free()
1243 msc_buffer_win_free(msc, win); in msc_buffer_multi_free()
1389 struct msc_window *win; in msc_buffer_get_page() local
1396 list_for_each_entry(win, &msc->win_list, entry) in msc_buffer_get_page()
1397 if (pgoff >= win->pgoff && pgoff < win->pgoff + win->nr_blocks) in msc_buffer_get_page()
1403 pgoff -= win->pgoff; in msc_buffer_get_page()
1405 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_get_page()
1730 struct msc_window *win; in intel_th_msc_window_unlock() local
1735 win = msc_find_window(msc, sgt, false); in intel_th_msc_window_unlock()
1736 if (!win) in intel_th_msc_window_unlock()
1739 msc_win_set_lockout(win, WIN_LOCKED, WIN_READY); in intel_th_msc_window_unlock()
1740 if (msc->switch_on_unlock == win) { in intel_th_msc_window_unlock()
1759 struct msc_window *win, *next_win; in intel_th_msc_interrupt() local
1775 win = msc->cur_win; in intel_th_msc_interrupt()
1776 if (!win) in intel_th_msc_interrupt()
1778 next_win = msc_next_window(win); in intel_th_msc_interrupt()
1793 msc_win_set_lockout(win, WIN_INUSE, WIN_LOCKED); in intel_th_msc_interrupt()
1798 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in intel_th_msc_interrupt()
1799 msc_win_total_sz(win)); in intel_th_msc_interrupt()
1956 struct msc_window *win; in nr_pages_show() local
1964 list_for_each_entry(win, &msc->win_list, entry) { in nr_pages_show()
1966 "%d%c", win->nr_blocks, in nr_pages_show()
1967 msc_is_last_win(win) ? '\n' : ','); in nr_pages_show()
1983 unsigned long val, *win = NULL, *rewin; in nr_pages_store() local
2021 rewin = krealloc_array(win, nr_wins, sizeof(*win), GFP_KERNEL); in nr_pages_store()
2023 kfree(win); in nr_pages_store()
2027 win = rewin; in nr_pages_store()
2028 win[nr_wins - 1] = val; in nr_pages_store()
2039 ret = msc_buffer_alloc(msc, win, nr_wins); in nr_pages_store()
2043 kfree(win); in nr_pages_store()