Lines Matching refs:win
97 struct msc_window *win; member
287 static inline struct scatterlist *msc_win_base_sg(struct msc_window *win) in msc_win_base_sg() argument
289 return win->sgt->sgl; in msc_win_base_sg()
292 static inline struct msc_block_desc *msc_win_base(struct msc_window *win) in msc_win_base() argument
294 return sg_virt(msc_win_base_sg(win)); in msc_win_base()
297 static inline dma_addr_t msc_win_base_dma(struct msc_window *win) in msc_win_base_dma() argument
299 return sg_dma_address(msc_win_base_sg(win)); in msc_win_base_dma()
303 msc_win_base_pfn(struct msc_window *win) in msc_win_base_pfn() argument
305 return PFN_DOWN(msc_win_base_dma(win)); in msc_win_base_pfn()
313 static inline bool msc_is_last_win(struct msc_window *win) in msc_is_last_win() argument
315 return win->entry.next == &win->msc->win_list; in msc_is_last_win()
324 static struct msc_window *msc_next_window(struct msc_window *win) in msc_next_window() argument
326 if (msc_is_last_win(win)) in msc_next_window()
327 return list_first_entry(&win->msc->win_list, struct msc_window, in msc_next_window()
330 return list_next_entry(win, entry); in msc_next_window()
333 static size_t msc_win_total_sz(struct msc_window *win) in msc_win_total_sz() argument
339 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_win_total_sz()
343 return (size_t)win->nr_blocks << PAGE_SHIFT; in msc_win_total_sz()
365 struct msc_window *win; in msc_find_window() local
376 list_for_each_entry(win, &msc->win_list, entry) { in msc_find_window()
377 if (win->sgt == sgt) in msc_find_window()
381 if (nonempty && msc_block_is_empty(msc_win_base(win))) in msc_find_window()
385 return win; in msc_find_window()
402 struct msc_window *win; in msc_oldest_window() local
407 win = msc_find_window(msc, msc_next_window(msc->cur_win)->sgt, true); in msc_oldest_window()
408 if (win) in msc_oldest_window()
409 return win; in msc_oldest_window()
420 static struct scatterlist *msc_win_oldest_sg(struct msc_window *win) in msc_win_oldest_sg() argument
424 struct msc_block_desc *bdesc = msc_win_base(win); in msc_win_oldest_sg()
428 return msc_win_base_sg(win); in msc_win_oldest_sg()
434 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_win_oldest_sg()
441 return msc_win_base_sg(win); in msc_win_oldest_sg()
494 iter->start_block = msc_win_oldest_sg(iter->win); in msc_iter_block_start()
517 iter->win = iter->start_win; in msc_iter_win_start()
527 iter->win = msc_next_window(iter->win); in msc_iter_win_advance()
530 if (iter->win == iter->start_win) { in msc_iter_win_advance()
559 iter->block = msc_win_base_sg(iter->win); in msc_iter_block_advance()
665 struct msc_window *win; in msc_buffer_clear_hw_header() local
668 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_clear_hw_header()
671 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_clear_hw_header()
716 static int msc_win_set_lockout(struct msc_window *win, in msc_win_set_lockout() argument
724 if (!win->msc->mbuf) in msc_win_set_lockout()
727 spin_lock_irqsave(&win->lo_lock, flags); in msc_win_set_lockout()
728 old = win->lockout; in msc_win_set_lockout()
735 win->lockout = new; in msc_win_set_lockout()
738 atomic_inc(&win->msc->user_count); in msc_win_set_lockout()
740 atomic_dec(&win->msc->user_count); in msc_win_set_lockout()
743 spin_unlock_irqrestore(&win->lo_lock, flags); in msc_win_set_lockout()
753 dev_warn_ratelimited(msc_dev(win->msc), in msc_win_set_lockout()
830 struct msc_window *win = msc->cur_win; in msc_disable() local
836 msc_win_set_lockout(win, WIN_INUSE, WIN_LOCKED); in msc_disable()
858 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in msc_disable()
859 msc_win_total_sz(win)); in msc_disable()
1002 static int __msc_buffer_win_alloc(struct msc_window *win, in __msc_buffer_win_alloc() argument
1009 ret = sg_alloc_table(win->sgt, nr_segs, GFP_KERNEL); in __msc_buffer_win_alloc()
1013 for_each_sg(win->sgt->sgl, sg_ptr, nr_segs, i) { in __msc_buffer_win_alloc()
1014 block = dma_alloc_coherent(msc_dev(win->msc)->parent->parent, in __msc_buffer_win_alloc()
1026 for_each_sg(win->sgt->sgl, sg_ptr, i, ret) in __msc_buffer_win_alloc()
1027 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_alloc()
1030 sg_free_table(win->sgt); in __msc_buffer_win_alloc()
1039 struct msc_window *win; in msc_buffer_set_uc() local
1047 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_set_uc()
1048 for_each_sg(win->sgt->sgl, sg_ptr, win->nr_segs, i) { in msc_buffer_set_uc()
1059 struct msc_window *win; in msc_buffer_set_wb() local
1067 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_set_wb()
1068 for_each_sg(win->sgt->sgl, sg_ptr, win->nr_segs, i) { in msc_buffer_set_wb()
1103 struct msc_window *win; in msc_buffer_win_alloc() local
1109 win = kzalloc(sizeof(*win), GFP_KERNEL); in msc_buffer_win_alloc()
1110 if (!win) in msc_buffer_win_alloc()
1113 win->msc = msc; in msc_buffer_win_alloc()
1114 win->sgt = &win->_sgt; in msc_buffer_win_alloc()
1115 win->lockout = WIN_READY; in msc_buffer_win_alloc()
1116 spin_lock_init(&win->lo_lock); in msc_buffer_win_alloc()
1123 win->pgoff = prev->pgoff + prev->nr_blocks; in msc_buffer_win_alloc()
1127 ret = msc->mbuf->alloc_window(msc->mbuf_priv, &win->sgt, in msc_buffer_win_alloc()
1130 ret = __msc_buffer_win_alloc(win, nr_blocks); in msc_buffer_win_alloc()
1135 win->nr_segs = ret; in msc_buffer_win_alloc()
1136 win->nr_blocks = nr_blocks; in msc_buffer_win_alloc()
1139 msc->base = msc_win_base(win); in msc_buffer_win_alloc()
1140 msc->base_addr = msc_win_base_dma(win); in msc_buffer_win_alloc()
1141 msc->cur_win = win; in msc_buffer_win_alloc()
1144 list_add_tail(&win->entry, &msc->win_list); in msc_buffer_win_alloc()
1150 kfree(win); in msc_buffer_win_alloc()
1155 static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win) in __msc_buffer_win_free() argument
1160 for_each_sg(win->sgt->sgl, sg, win->nr_segs, i) { in __msc_buffer_win_free()
1164 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_free()
1167 sg_free_table(win->sgt); in __msc_buffer_win_free()
1178 static void msc_buffer_win_free(struct msc *msc, struct msc_window *win) in msc_buffer_win_free() argument
1180 msc->nr_pages -= win->nr_blocks; in msc_buffer_win_free()
1182 list_del(&win->entry); in msc_buffer_win_free()
1189 msc->mbuf->free_window(msc->mbuf_priv, win->sgt); in msc_buffer_win_free()
1191 __msc_buffer_win_free(msc, win); in msc_buffer_win_free()
1193 kfree(win); in msc_buffer_win_free()
1205 struct msc_window *win, *next_win; in msc_buffer_relink() local
1208 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_relink()
1217 if (msc_is_last_win(win)) { in msc_buffer_relink()
1222 next_win = list_next_entry(win, entry); in msc_buffer_relink()
1225 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_relink()
1236 if (blk == win->nr_segs - 1) { in msc_buffer_relink()
1238 bdesc->next_blk = msc_win_base_pfn(win); in msc_buffer_relink()
1259 struct msc_window *win, *iter; in msc_buffer_multi_free() local
1261 list_for_each_entry_safe(win, iter, &msc->win_list, entry) in msc_buffer_multi_free()
1262 msc_buffer_win_free(msc, win); in msc_buffer_multi_free()
1412 struct msc_window *win; in msc_buffer_get_page() local
1419 list_for_each_entry(win, &msc->win_list, entry) in msc_buffer_get_page()
1420 if (pgoff >= win->pgoff && pgoff < win->pgoff + win->nr_blocks) in msc_buffer_get_page()
1426 pgoff -= win->pgoff; in msc_buffer_get_page()
1428 for_each_sg(win->sgt->sgl, sg, win->nr_segs, blk) { in msc_buffer_get_page()
1754 struct msc_window *win; in intel_th_msc_window_unlock() local
1759 win = msc_find_window(msc, sgt, false); in intel_th_msc_window_unlock()
1760 if (!win) in intel_th_msc_window_unlock()
1763 msc_win_set_lockout(win, WIN_LOCKED, WIN_READY); in intel_th_msc_window_unlock()
1764 if (msc->switch_on_unlock == win) { in intel_th_msc_window_unlock()
1783 struct msc_window *win, *next_win; in intel_th_msc_interrupt() local
1799 win = msc->cur_win; in intel_th_msc_interrupt()
1800 if (!win) in intel_th_msc_interrupt()
1802 next_win = msc_next_window(win); in intel_th_msc_interrupt()
1817 msc_win_set_lockout(win, WIN_INUSE, WIN_LOCKED); in intel_th_msc_interrupt()
1822 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in intel_th_msc_interrupt()
1823 msc_win_total_sz(win)); in intel_th_msc_interrupt()
1980 struct msc_window *win; in nr_pages_show() local
1988 list_for_each_entry(win, &msc->win_list, entry) { in nr_pages_show()
1990 "%d%c", win->nr_blocks, in nr_pages_show()
1991 msc_is_last_win(win) ? '\n' : ','); in nr_pages_show()
2007 unsigned long val, *win = NULL, *rewin; in nr_pages_store() local
2045 rewin = krealloc_array(win, nr_wins, sizeof(*win), GFP_KERNEL); in nr_pages_store()
2047 kfree(win); in nr_pages_store()
2051 win = rewin; in nr_pages_store()
2052 win[nr_wins - 1] = val; in nr_pages_store()
2063 ret = msc_buffer_alloc(msc, win, nr_wins); in nr_pages_store()
2067 kfree(win); in nr_pages_store()