Lines Matching refs:win

96 	struct msc_window	*win;  member
274 static inline struct scatterlist *msc_win_base_sg(struct msc_window *win) in msc_win_base_sg() argument
276 return win->sgt->sgl; in msc_win_base_sg()
279 static inline struct msc_block_desc *msc_win_base(struct msc_window *win) in msc_win_base() argument
281 return sg_virt(msc_win_base_sg(win)); in msc_win_base()
284 static inline dma_addr_t msc_win_base_dma(struct msc_window *win) in msc_win_base_dma() argument
286 return sg_dma_address(msc_win_base_sg(win)); in msc_win_base_dma()
290 msc_win_base_pfn(struct msc_window *win) in msc_win_base_pfn() argument
292 return PFN_DOWN(msc_win_base_dma(win)); in msc_win_base_pfn()
300 static inline bool msc_is_last_win(struct msc_window *win) in msc_is_last_win() argument
302 return win->entry.next == &win->msc->win_list; in msc_is_last_win()
311 static struct msc_window *msc_next_window(struct msc_window *win) in msc_next_window() argument
313 if (msc_is_last_win(win)) in msc_next_window()
314 return list_first_entry(&win->msc->win_list, struct msc_window, in msc_next_window()
317 return list_next_entry(win, entry); in msc_next_window()
320 static size_t msc_win_total_sz(struct msc_window *win) in msc_win_total_sz() argument
326 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_win_total_sz()
330 return (size_t)win->nr_blocks << PAGE_SHIFT; in msc_win_total_sz()
352 struct msc_window *win; in msc_find_window() local
363 list_for_each_entry(win, &msc->win_list, entry) { in msc_find_window()
364 if (win->sgt == sgt) in msc_find_window()
368 if (nonempty && msc_block_is_empty(msc_win_base(win))) in msc_find_window()
372 return win; in msc_find_window()
389 struct msc_window *win; in msc_oldest_window() local
394 win = msc_find_window(msc, msc_next_window(msc->cur_win)->sgt, true); in msc_oldest_window()
395 if (win) in msc_oldest_window()
396 return win; in msc_oldest_window()
407 static struct scatterlist *msc_win_oldest_sg(struct msc_window *win) in msc_win_oldest_sg() argument
411 struct msc_block_desc *bdesc = msc_win_base(win); in msc_win_oldest_sg()
415 return msc_win_base_sg(win); in msc_win_oldest_sg()
421 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_win_oldest_sg()
428 return msc_win_base_sg(win); in msc_win_oldest_sg()
481 iter->start_block = msc_win_oldest_sg(iter->win); in msc_iter_block_start()
504 iter->win = iter->start_win; in msc_iter_win_start()
514 iter->win = msc_next_window(iter->win); in msc_iter_win_advance()
517 if (iter->win == iter->start_win) { in msc_iter_win_advance()
546 iter->block = msc_win_base_sg(iter->win); in msc_iter_block_advance()
652 struct msc_window *win; in msc_buffer_clear_hw_header() local
655 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_clear_hw_header()
660 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_clear_hw_header()
705 static int msc_win_set_lockout(struct msc_window *win, in msc_win_set_lockout() argument
713 if (!win->msc->mbuf) in msc_win_set_lockout()
716 spin_lock_irqsave(&win->lo_lock, flags); in msc_win_set_lockout()
717 old = win->lockout; in msc_win_set_lockout()
721 dev_warn_ratelimited(msc_dev(win->msc), in msc_win_set_lockout()
727 win->lockout = new; in msc_win_set_lockout()
730 atomic_inc(&win->msc->user_count); in msc_win_set_lockout()
732 atomic_dec(&win->msc->user_count); in msc_win_set_lockout()
735 spin_unlock_irqrestore(&win->lo_lock, flags); in msc_win_set_lockout()
816 struct msc_window *win = msc->cur_win; in msc_disable() local
822 msc_win_set_lockout(win, WIN_INUSE, WIN_LOCKED); in msc_disable()
844 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in msc_disable()
845 msc_win_total_sz(win)); in msc_disable()
988 static int __msc_buffer_win_alloc(struct msc_window *win, in __msc_buffer_win_alloc() argument
995 ret = sg_alloc_table(win->sgt, nr_segs, GFP_KERNEL); in __msc_buffer_win_alloc()
999 for_each_sg(win->sgt->sgl, sg_ptr, nr_segs, i) { in __msc_buffer_win_alloc()
1000 block = dma_alloc_coherent(msc_dev(win->msc)->parent->parent, in __msc_buffer_win_alloc()
1012 for_each_sg(win->sgt->sgl, sg_ptr, i, ret) in __msc_buffer_win_alloc()
1013 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_alloc()
1016 sg_free_table(win->sgt); in __msc_buffer_win_alloc()
1022 static void msc_buffer_set_uc(struct msc_window *win, unsigned int nr_segs) in msc_buffer_set_uc() argument
1027 for_each_sg(win->sgt->sgl, sg_ptr, nr_segs, i) { in msc_buffer_set_uc()
1034 static void msc_buffer_set_wb(struct msc_window *win) in msc_buffer_set_wb() argument
1039 for_each_sg(win->sgt->sgl, sg_ptr, win->nr_segs, i) { in msc_buffer_set_wb()
1047 msc_buffer_set_uc(struct msc_window *win, unsigned int nr_segs) {} in msc_buffer_set_uc() argument
1048 static inline void msc_buffer_set_wb(struct msc_window *win) {} in msc_buffer_set_wb() argument
1063 struct msc_window *win; in msc_buffer_win_alloc() local
1069 win = kzalloc(sizeof(*win), GFP_KERNEL); in msc_buffer_win_alloc()
1070 if (!win) in msc_buffer_win_alloc()
1073 win->msc = msc; in msc_buffer_win_alloc()
1074 win->sgt = &win->_sgt; in msc_buffer_win_alloc()
1075 win->lockout = WIN_READY; in msc_buffer_win_alloc()
1076 spin_lock_init(&win->lo_lock); in msc_buffer_win_alloc()
1083 win->pgoff = prev->pgoff + prev->nr_blocks; in msc_buffer_win_alloc()
1087 ret = msc->mbuf->alloc_window(msc->mbuf_priv, &win->sgt, in msc_buffer_win_alloc()
1090 ret = __msc_buffer_win_alloc(win, nr_blocks); in msc_buffer_win_alloc()
1095 msc_buffer_set_uc(win, ret); in msc_buffer_win_alloc()
1097 win->nr_segs = ret; in msc_buffer_win_alloc()
1098 win->nr_blocks = nr_blocks; in msc_buffer_win_alloc()
1101 msc->base = msc_win_base(win); in msc_buffer_win_alloc()
1102 msc->base_addr = msc_win_base_dma(win); in msc_buffer_win_alloc()
1103 msc->cur_win = win; in msc_buffer_win_alloc()
1106 list_add_tail(&win->entry, &msc->win_list); in msc_buffer_win_alloc()
1112 kfree(win); in msc_buffer_win_alloc()
1117 static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win) in __msc_buffer_win_free() argument
1122 for_each_sg(win->sgt->sgl, sg, win->nr_segs, i) { in __msc_buffer_win_free()
1126 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_free()
1129 sg_free_table(win->sgt); in __msc_buffer_win_free()
1140 static void msc_buffer_win_free(struct msc *msc, struct msc_window *win) in msc_buffer_win_free() argument
1142 msc->nr_pages -= win->nr_blocks; in msc_buffer_win_free()
1144 list_del(&win->entry); in msc_buffer_win_free()
1150 msc_buffer_set_wb(win); in msc_buffer_win_free()
1153 msc->mbuf->free_window(msc->mbuf_priv, win->sgt); in msc_buffer_win_free()
1155 __msc_buffer_win_free(msc, win); in msc_buffer_win_free()
1157 kfree(win); in msc_buffer_win_free()
1169 struct msc_window *win, *next_win; in msc_buffer_relink() local
1172 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_relink()
1181 if (msc_is_last_win(win)) { in msc_buffer_relink()
1186 next_win = list_next_entry(win, entry); in msc_buffer_relink()
1189 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_relink()
1200 if (blk == win->nr_segs - 1) { in msc_buffer_relink()
1202 bdesc->next_blk = msc_win_base_pfn(win); in msc_buffer_relink()
1223 struct msc_window *win, *iter; in msc_buffer_multi_free() local
1225 list_for_each_entry_safe(win, iter, &msc->win_list, entry) in msc_buffer_multi_free()
1226 msc_buffer_win_free(msc, win); in msc_buffer_multi_free()
1368 struct msc_window *win; in msc_buffer_get_page() local
1375 list_for_each_entry(win, &msc->win_list, entry) in msc_buffer_get_page()
1376 if (pgoff >= win->pgoff && pgoff < win->pgoff + win->nr_blocks) in msc_buffer_get_page()
1382 pgoff -= win->pgoff; in msc_buffer_get_page()
1384 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_get_page()
1704 struct msc_window *win; in intel_th_msc_window_unlock() local
1709 win = msc_find_window(msc, sgt, false); in intel_th_msc_window_unlock()
1710 if (!win) in intel_th_msc_window_unlock()
1713 msc_win_set_lockout(win, WIN_LOCKED, WIN_READY); in intel_th_msc_window_unlock()
1729 struct msc_window *win, *next_win; in intel_th_msc_interrupt() local
1745 win = msc->cur_win; in intel_th_msc_interrupt()
1746 if (!win) in intel_th_msc_interrupt()
1748 next_win = msc_next_window(win); in intel_th_msc_interrupt()
1759 msc_win_set_lockout(win, WIN_INUSE, WIN_LOCKED); in intel_th_msc_interrupt()
1764 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in intel_th_msc_interrupt()
1765 msc_win_total_sz(win)); in intel_th_msc_interrupt()
1919 struct msc_window *win; in nr_pages_show() local
1927 list_for_each_entry(win, &msc->win_list, entry) { in nr_pages_show()
1929 "%d%c", win->nr_blocks, in nr_pages_show()
1930 msc_is_last_win(win) ? '\n' : ','); in nr_pages_show()
1946 unsigned long val, *win = NULL, *rewin; in nr_pages_store() local
1984 rewin = krealloc(win, sizeof(*win) * nr_wins, GFP_KERNEL); in nr_pages_store()
1986 kfree(win); in nr_pages_store()
1990 win = rewin; in nr_pages_store()
1991 win[nr_wins - 1] = val; in nr_pages_store()
2002 ret = msc_buffer_alloc(msc, win, nr_wins); in nr_pages_store()
2006 kfree(win); in nr_pages_store()