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
1078 struct msc_window *win; in msc_buffer_win_alloc() local
1084 win = kzalloc(sizeof(*win), GFP_KERNEL); in msc_buffer_win_alloc()
1085 if (!win) in msc_buffer_win_alloc()
1088 win->msc = msc; in msc_buffer_win_alloc()
1089 win->sgt = &win->_sgt; in msc_buffer_win_alloc()
1090 win->lockout = WIN_READY; in msc_buffer_win_alloc()
1091 spin_lock_init(&win->lo_lock); in msc_buffer_win_alloc()
1098 win->pgoff = prev->pgoff + prev->nr_blocks; in msc_buffer_win_alloc()
1102 ret = msc->mbuf->alloc_window(msc->mbuf_priv, &win->sgt, in msc_buffer_win_alloc()
1105 ret = __msc_buffer_win_alloc(win, nr_blocks); in msc_buffer_win_alloc()
1110 msc_buffer_set_uc(win, ret); in msc_buffer_win_alloc()
1112 win->nr_segs = ret; in msc_buffer_win_alloc()
1113 win->nr_blocks = nr_blocks; in msc_buffer_win_alloc()
1116 msc->base = msc_win_base(win); in msc_buffer_win_alloc()
1117 msc->base_addr = msc_win_base_dma(win); in msc_buffer_win_alloc()
1118 msc->cur_win = win; in msc_buffer_win_alloc()
1121 list_add_tail(&win->entry, &msc->win_list); in msc_buffer_win_alloc()
1127 kfree(win); in msc_buffer_win_alloc()
1132 static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win) in __msc_buffer_win_free() argument
1137 for_each_sg(win->sgt->sgl, sg, win->nr_segs, i) { in __msc_buffer_win_free()
1141 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_free()
1144 sg_free_table(win->sgt); in __msc_buffer_win_free()
1155 static void msc_buffer_win_free(struct msc *msc, struct msc_window *win) in msc_buffer_win_free() argument
1157 msc->nr_pages -= win->nr_blocks; in msc_buffer_win_free()
1159 list_del(&win->entry); in msc_buffer_win_free()
1165 msc_buffer_set_wb(win); in msc_buffer_win_free()
1168 msc->mbuf->free_window(msc->mbuf_priv, win->sgt); in msc_buffer_win_free()
1170 __msc_buffer_win_free(msc, win); in msc_buffer_win_free()
1172 kfree(win); in msc_buffer_win_free()
1184 struct msc_window *win, *next_win; in msc_buffer_relink() local
1187 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_relink()
1196 if (msc_is_last_win(win)) { in msc_buffer_relink()
1201 next_win = list_next_entry(win, entry); in msc_buffer_relink()
1204 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_relink()
1215 if (blk == win->nr_segs - 1) { in msc_buffer_relink()
1217 bdesc->next_blk = msc_win_base_pfn(win); in msc_buffer_relink()
1238 struct msc_window *win, *iter; in msc_buffer_multi_free() local
1240 list_for_each_entry_safe(win, iter, &msc->win_list, entry) in msc_buffer_multi_free()
1241 msc_buffer_win_free(msc, win); in msc_buffer_multi_free()
1383 struct msc_window *win; in msc_buffer_get_page() local
1390 list_for_each_entry(win, &msc->win_list, entry) in msc_buffer_get_page()
1391 if (pgoff >= win->pgoff && pgoff < win->pgoff + win->nr_blocks) in msc_buffer_get_page()
1397 pgoff -= win->pgoff; in msc_buffer_get_page()
1399 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_get_page()
1724 struct msc_window *win; in intel_th_msc_window_unlock() local
1729 win = msc_find_window(msc, sgt, false); in intel_th_msc_window_unlock()
1730 if (!win) in intel_th_msc_window_unlock()
1733 msc_win_set_lockout(win, WIN_LOCKED, WIN_READY); in intel_th_msc_window_unlock()
1734 if (msc->switch_on_unlock == win) { in intel_th_msc_window_unlock()
1753 struct msc_window *win, *next_win; in intel_th_msc_interrupt() local
1769 win = msc->cur_win; in intel_th_msc_interrupt()
1770 if (!win) in intel_th_msc_interrupt()
1772 next_win = msc_next_window(win); in intel_th_msc_interrupt()
1787 msc_win_set_lockout(win, WIN_INUSE, WIN_LOCKED); in intel_th_msc_interrupt()
1792 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in intel_th_msc_interrupt()
1793 msc_win_total_sz(win)); in intel_th_msc_interrupt()
1950 struct msc_window *win; in nr_pages_show() local
1958 list_for_each_entry(win, &msc->win_list, entry) { in nr_pages_show()
1960 "%d%c", win->nr_blocks, in nr_pages_show()
1961 msc_is_last_win(win) ? '\n' : ','); in nr_pages_show()
1977 unsigned long val, *win = NULL, *rewin; in nr_pages_store() local
2015 rewin = krealloc(win, sizeof(*win) * nr_wins, GFP_KERNEL); in nr_pages_store()
2017 kfree(win); in nr_pages_store()
2021 win = rewin; in nr_pages_store()
2022 win[nr_wins - 1] = val; in nr_pages_store()
2033 ret = msc_buffer_alloc(msc, win, nr_wins); in nr_pages_store()
2037 kfree(win); in nr_pages_store()