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()
1027 static void msc_buffer_set_uc(struct msc_window *win, unsigned int nr_segs) in msc_buffer_set_uc() argument
1032 for_each_sg(win->sgt->sgl, sg_ptr, nr_segs, i) { in msc_buffer_set_uc()
1039 static void msc_buffer_set_wb(struct msc_window *win) in msc_buffer_set_wb() argument
1044 for_each_sg(win->sgt->sgl, sg_ptr, win->nr_segs, i) { in msc_buffer_set_wb()
1052 msc_buffer_set_uc(struct msc_window *win, unsigned int nr_segs) {} in msc_buffer_set_uc() argument
1053 static inline void msc_buffer_set_wb(struct msc_window *win) {} in msc_buffer_set_wb() argument
1068 struct msc_window *win; in msc_buffer_win_alloc() local
1074 win = kzalloc(sizeof(*win), GFP_KERNEL); in msc_buffer_win_alloc()
1075 if (!win) in msc_buffer_win_alloc()
1078 win->msc = msc; in msc_buffer_win_alloc()
1079 win->sgt = &win->_sgt; in msc_buffer_win_alloc()
1080 win->lockout = WIN_READY; in msc_buffer_win_alloc()
1081 spin_lock_init(&win->lo_lock); in msc_buffer_win_alloc()
1088 win->pgoff = prev->pgoff + prev->nr_blocks; in msc_buffer_win_alloc()
1092 ret = msc->mbuf->alloc_window(msc->mbuf_priv, &win->sgt, in msc_buffer_win_alloc()
1095 ret = __msc_buffer_win_alloc(win, nr_blocks); in msc_buffer_win_alloc()
1100 msc_buffer_set_uc(win, ret); in msc_buffer_win_alloc()
1102 win->nr_segs = ret; in msc_buffer_win_alloc()
1103 win->nr_blocks = nr_blocks; in msc_buffer_win_alloc()
1106 msc->base = msc_win_base(win); in msc_buffer_win_alloc()
1107 msc->base_addr = msc_win_base_dma(win); in msc_buffer_win_alloc()
1108 msc->cur_win = win; in msc_buffer_win_alloc()
1111 list_add_tail(&win->entry, &msc->win_list); in msc_buffer_win_alloc()
1117 kfree(win); in msc_buffer_win_alloc()
1122 static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win) in __msc_buffer_win_free() argument
1127 for_each_sg(win->sgt->sgl, sg, win->nr_segs, i) { in __msc_buffer_win_free()
1131 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_free()
1134 sg_free_table(win->sgt); in __msc_buffer_win_free()
1145 static void msc_buffer_win_free(struct msc *msc, struct msc_window *win) in msc_buffer_win_free() argument
1147 msc->nr_pages -= win->nr_blocks; in msc_buffer_win_free()
1149 list_del(&win->entry); in msc_buffer_win_free()
1155 msc_buffer_set_wb(win); in msc_buffer_win_free()
1158 msc->mbuf->free_window(msc->mbuf_priv, win->sgt); in msc_buffer_win_free()
1160 __msc_buffer_win_free(msc, win); in msc_buffer_win_free()
1162 kfree(win); in msc_buffer_win_free()
1174 struct msc_window *win, *next_win; in msc_buffer_relink() local
1177 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_relink()
1186 if (msc_is_last_win(win)) { in msc_buffer_relink()
1191 next_win = list_next_entry(win, entry); in msc_buffer_relink()
1194 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_relink()
1205 if (blk == win->nr_segs - 1) { in msc_buffer_relink()
1207 bdesc->next_blk = msc_win_base_pfn(win); in msc_buffer_relink()
1228 struct msc_window *win, *iter; in msc_buffer_multi_free() local
1230 list_for_each_entry_safe(win, iter, &msc->win_list, entry) in msc_buffer_multi_free()
1231 msc_buffer_win_free(msc, win); in msc_buffer_multi_free()
1373 struct msc_window *win; in msc_buffer_get_page() local
1380 list_for_each_entry(win, &msc->win_list, entry) in msc_buffer_get_page()
1381 if (pgoff >= win->pgoff && pgoff < win->pgoff + win->nr_blocks) in msc_buffer_get_page()
1387 pgoff -= win->pgoff; in msc_buffer_get_page()
1389 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_get_page()
1714 struct msc_window *win; in intel_th_msc_window_unlock() local
1719 win = msc_find_window(msc, sgt, false); in intel_th_msc_window_unlock()
1720 if (!win) in intel_th_msc_window_unlock()
1723 msc_win_set_lockout(win, WIN_LOCKED, WIN_READY); in intel_th_msc_window_unlock()
1724 if (msc->switch_on_unlock == win) { in intel_th_msc_window_unlock()
1743 struct msc_window *win, *next_win; in intel_th_msc_interrupt() local
1759 win = msc->cur_win; in intel_th_msc_interrupt()
1760 if (!win) in intel_th_msc_interrupt()
1762 next_win = msc_next_window(win); in intel_th_msc_interrupt()
1777 msc_win_set_lockout(win, WIN_INUSE, WIN_LOCKED); in intel_th_msc_interrupt()
1782 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in intel_th_msc_interrupt()
1783 msc_win_total_sz(win)); in intel_th_msc_interrupt()
1940 struct msc_window *win; in nr_pages_show() local
1948 list_for_each_entry(win, &msc->win_list, entry) { in nr_pages_show()
1950 "%d%c", win->nr_blocks, in nr_pages_show()
1951 msc_is_last_win(win) ? '\n' : ','); in nr_pages_show()
1967 unsigned long val, *win = NULL, *rewin; in nr_pages_store() local
2005 rewin = krealloc(win, sizeof(*win) * nr_wins, GFP_KERNEL); in nr_pages_store()
2007 kfree(win); in nr_pages_store()
2011 win = rewin; in nr_pages_store()
2012 win[nr_wins - 1] = val; in nr_pages_store()
2023 ret = msc_buffer_alloc(msc, win, nr_wins); in nr_pages_store()
2027 kfree(win); in nr_pages_store()