Lines Matching refs:msc
74 struct msc *msc; member
94 struct msc *msc; member
129 struct msc { struct
306 return win->entry.next == &win->msc->win_list; in msc_is_last_win()
318 return list_first_entry(&win->msc->win_list, struct msc_window, in msc_next_window()
354 msc_find_window(struct msc *msc, struct sg_table *sgt, bool nonempty) in msc_find_window() argument
359 if (list_empty(&msc->win_list)) in msc_find_window()
367 list_for_each_entry(win, &msc->win_list, entry) { in msc_find_window()
391 static struct msc_window *msc_oldest_window(struct msc *msc) in msc_oldest_window() argument
395 if (list_empty(&msc->win_list)) in msc_oldest_window()
398 win = msc_find_window(msc, msc_next_window(msc->cur_win)->sgt, true); in msc_oldest_window()
402 return list_first_entry(&msc->win_list, struct msc_window, entry); in msc_oldest_window()
440 static struct msc_iter *msc_iter_install(struct msc *msc) in msc_iter_install() argument
448 mutex_lock(&msc->buf_mutex); in msc_iter_install()
456 if (msc->enabled) { in msc_iter_install()
462 iter->msc = msc; in msc_iter_install()
464 list_add_tail(&iter->entry, &msc->iter_list); in msc_iter_install()
466 mutex_unlock(&msc->buf_mutex); in msc_iter_install()
471 static void msc_iter_remove(struct msc_iter *iter, struct msc *msc) in msc_iter_remove() argument
473 mutex_lock(&msc->buf_mutex); in msc_iter_remove()
475 mutex_unlock(&msc->buf_mutex); in msc_iter_remove()
498 static int msc_iter_win_start(struct msc_iter *iter, struct msc *msc) in msc_iter_win_start() argument
504 iter->start_win = msc_oldest_window(msc); in msc_iter_win_start()
581 struct msc *msc = iter->msc; in msc_buffer_iterate() local
589 if (msc_iter_win_start(iter, msc)) in msc_buffer_iterate()
654 static void msc_buffer_clear_hw_header(struct msc *msc) in msc_buffer_clear_hw_header() argument
659 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_clear_hw_header()
672 static int intel_th_msu_init(struct msc *msc) in intel_th_msu_init() argument
676 if (!msc->do_irq) in intel_th_msu_init()
679 if (!msc->mbuf) in intel_th_msu_init()
682 mintctl = ioread32(msc->msu_base + REG_MSU_MINTCTL); in intel_th_msu_init()
683 mintctl |= msc->index ? M1BLIE : M0BLIE; in intel_th_msu_init()
684 iowrite32(mintctl, msc->msu_base + REG_MSU_MINTCTL); in intel_th_msu_init()
685 if (mintctl != ioread32(msc->msu_base + REG_MSU_MINTCTL)) { in intel_th_msu_init()
686 dev_info(msc_dev(msc), "MINTCTL ignores writes: no usable interrupts\n"); in intel_th_msu_init()
687 msc->do_irq = 0; in intel_th_msu_init()
691 msusts = ioread32(msc->msu_base + REG_MSU_MSUSTS); in intel_th_msu_init()
692 iowrite32(msusts, msc->msu_base + REG_MSU_MSUSTS); in intel_th_msu_init()
697 static void intel_th_msu_deinit(struct msc *msc) in intel_th_msu_deinit() argument
701 if (!msc->do_irq) in intel_th_msu_deinit()
704 mintctl = ioread32(msc->msu_base + REG_MSU_MINTCTL); in intel_th_msu_deinit()
705 mintctl &= msc->index ? ~M1BLIE : ~M0BLIE; in intel_th_msu_deinit()
706 iowrite32(mintctl, msc->msu_base + REG_MSU_MINTCTL); in intel_th_msu_deinit()
717 if (!win->msc->mbuf) 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()
746 dev_warn_ratelimited(msc_dev(win->msc), in msc_win_set_lockout()
761 static int msc_configure(struct msc *msc) in msc_configure() argument
765 lockdep_assert_held(&msc->buf_mutex); in msc_configure()
767 if (msc->mode > MSC_MODE_MULTI) in msc_configure()
770 if (msc->mode == MSC_MODE_MULTI) { in msc_configure()
771 if (msc_win_set_lockout(msc->cur_win, WIN_READY, WIN_INUSE)) in msc_configure()
774 msc_buffer_clear_hw_header(msc); in msc_configure()
777 msc->orig_addr = ioread32(msc->reg_base + REG_MSU_MSC0BAR); in msc_configure()
778 msc->orig_sz = ioread32(msc->reg_base + REG_MSU_MSC0SIZE); in msc_configure()
780 reg = msc->base_addr >> PAGE_SHIFT; in msc_configure()
781 iowrite32(reg, msc->reg_base + REG_MSU_MSC0BAR); in msc_configure()
783 if (msc->mode == MSC_MODE_SINGLE) { in msc_configure()
784 reg = msc->nr_pages; in msc_configure()
785 iowrite32(reg, msc->reg_base + REG_MSU_MSC0SIZE); in msc_configure()
788 reg = ioread32(msc->reg_base + REG_MSU_MSC0CTL); in msc_configure()
792 reg |= msc->mode << __ffs(MSC_MODE); in msc_configure()
793 reg |= msc->burst_len << __ffs(MSC_LEN); in msc_configure()
795 if (msc->wrap) in msc_configure()
798 iowrite32(reg, msc->reg_base + REG_MSU_MSC0CTL); in msc_configure()
800 intel_th_msu_init(msc); in msc_configure()
802 msc->thdev->output.multiblock = msc->mode == MSC_MODE_MULTI; in msc_configure()
803 intel_th_trace_enable(msc->thdev); in msc_configure()
804 msc->enabled = 1; in msc_configure()
806 if (msc->mbuf && msc->mbuf->activate) in msc_configure()
807 msc->mbuf->activate(msc->mbuf_priv); in msc_configure()
819 static void msc_disable(struct msc *msc) in msc_disable() argument
821 struct msc_window *win = msc->cur_win; in msc_disable()
824 lockdep_assert_held(&msc->buf_mutex); in msc_disable()
826 if (msc->mode == MSC_MODE_MULTI) in msc_disable()
829 if (msc->mbuf && msc->mbuf->deactivate) in msc_disable()
830 msc->mbuf->deactivate(msc->mbuf_priv); in msc_disable()
831 intel_th_msu_deinit(msc); in msc_disable()
832 intel_th_trace_disable(msc->thdev); in msc_disable()
834 if (msc->mode == MSC_MODE_SINGLE) { in msc_disable()
835 reg = ioread32(msc->reg_base + REG_MSU_MSC0STS); in msc_disable()
836 msc->single_wrap = !!(reg & MSCSTS_WRAPSTAT); in msc_disable()
838 reg = ioread32(msc->reg_base + REG_MSU_MSC0MWP); in msc_disable()
839 msc->single_sz = reg & ((msc->nr_pages << PAGE_SHIFT) - 1); in msc_disable()
840 dev_dbg(msc_dev(msc), "MSCnMWP: %08x/%08lx, wrap: %d\n", in msc_disable()
841 reg, msc->single_sz, msc->single_wrap); in msc_disable()
844 reg = ioread32(msc->reg_base + REG_MSU_MSC0CTL); in msc_disable()
846 iowrite32(reg, msc->reg_base + REG_MSU_MSC0CTL); in msc_disable()
848 if (msc->mbuf && msc->mbuf->ready) in msc_disable()
849 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in msc_disable()
852 msc->enabled = 0; in msc_disable()
854 iowrite32(msc->orig_addr, msc->reg_base + REG_MSU_MSC0BAR); in msc_disable()
855 iowrite32(msc->orig_sz, msc->reg_base + REG_MSU_MSC0SIZE); in msc_disable()
857 dev_dbg(msc_dev(msc), "MSCnNWSA: %08x\n", in msc_disable()
858 ioread32(msc->reg_base + REG_MSU_MSC0NWSA)); in msc_disable()
860 reg = ioread32(msc->reg_base + REG_MSU_MSC0STS); in msc_disable()
861 dev_dbg(msc_dev(msc), "MSCnSTS: %08x\n", reg); in msc_disable()
863 reg = ioread32(msc->reg_base + REG_MSU_MSUSTS); in msc_disable()
864 reg &= msc->index ? MSUSTS_MSC1BLAST : MSUSTS_MSC0BLAST; in msc_disable()
865 iowrite32(reg, msc->reg_base + REG_MSU_MSUSTS); in msc_disable()
870 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_activate() local
873 if (!atomic_inc_unless_negative(&msc->user_count)) in intel_th_msc_activate()
876 mutex_lock(&msc->buf_mutex); in intel_th_msc_activate()
879 if (list_empty(&msc->iter_list)) in intel_th_msc_activate()
880 ret = msc_configure(msc); in intel_th_msc_activate()
882 mutex_unlock(&msc->buf_mutex); in intel_th_msc_activate()
885 atomic_dec(&msc->user_count); in intel_th_msc_activate()
892 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_deactivate() local
894 mutex_lock(&msc->buf_mutex); in intel_th_msc_deactivate()
895 if (msc->enabled) { in intel_th_msc_deactivate()
896 msc_disable(msc); in intel_th_msc_deactivate()
897 atomic_dec(&msc->user_count); in intel_th_msc_deactivate()
899 mutex_unlock(&msc->buf_mutex); in intel_th_msc_deactivate()
912 static int msc_buffer_contig_alloc(struct msc *msc, unsigned long size) in msc_buffer_contig_alloc() argument
922 ret = sg_alloc_table(&msc->single_sgt, 1, GFP_KERNEL); in msc_buffer_contig_alloc()
932 sg_set_buf(msc->single_sgt.sgl, page_address(page), size); in msc_buffer_contig_alloc()
934 ret = dma_map_sg(msc_dev(msc)->parent->parent, msc->single_sgt.sgl, 1, in msc_buffer_contig_alloc()
939 msc->nr_pages = nr_pages; in msc_buffer_contig_alloc()
940 msc->base = page_address(page); in msc_buffer_contig_alloc()
941 msc->base_addr = sg_dma_address(msc->single_sgt.sgl); in msc_buffer_contig_alloc()
949 sg_free_table(&msc->single_sgt); in msc_buffer_contig_alloc()
959 static void msc_buffer_contig_free(struct msc *msc) in msc_buffer_contig_free() argument
963 dma_unmap_sg(msc_dev(msc)->parent->parent, msc->single_sgt.sgl, in msc_buffer_contig_free()
965 sg_free_table(&msc->single_sgt); in msc_buffer_contig_free()
967 for (off = 0; off < msc->nr_pages << PAGE_SHIFT; off += PAGE_SIZE) { in msc_buffer_contig_free()
968 struct page *page = virt_to_page(msc->base + off); in msc_buffer_contig_free()
974 msc->nr_pages = 0; in msc_buffer_contig_free()
984 static struct page *msc_buffer_contig_get_page(struct msc *msc, in msc_buffer_contig_get_page() argument
987 if (pgoff >= msc->nr_pages) in msc_buffer_contig_get_page()
990 return virt_to_page(msc->base + (pgoff << PAGE_SHIFT)); in msc_buffer_contig_get_page()
1005 block = dma_alloc_coherent(msc_dev(win->msc)->parent->parent, in __msc_buffer_win_alloc()
1018 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_alloc()
1076 static int msc_buffer_win_alloc(struct msc *msc, unsigned int nr_blocks) in msc_buffer_win_alloc() argument
1088 win->msc = msc; in msc_buffer_win_alloc()
1093 if (!list_empty(&msc->win_list)) { in msc_buffer_win_alloc()
1094 struct msc_window *prev = list_last_entry(&msc->win_list, in msc_buffer_win_alloc()
1101 if (msc->mbuf && msc->mbuf->alloc_window) in msc_buffer_win_alloc()
1102 ret = msc->mbuf->alloc_window(msc->mbuf_priv, &win->sgt, in msc_buffer_win_alloc()
1115 if (list_empty(&msc->win_list)) { 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()
1122 msc->nr_pages += nr_blocks; 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
1141 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, 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()
1160 if (list_empty(&msc->win_list)) { in msc_buffer_win_free()
1161 msc->base = NULL; in msc_buffer_win_free()
1162 msc->base_addr = 0; in msc_buffer_win_free()
1167 if (msc->mbuf && msc->mbuf->free_window) 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()
1182 static void msc_buffer_relink(struct msc *msc) in msc_buffer_relink() argument
1187 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_relink()
1198 next_win = list_first_entry(&msc->win_list, in msc_buffer_relink()
1236 static void msc_buffer_multi_free(struct msc *msc) in msc_buffer_multi_free() argument
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()
1244 static int msc_buffer_multi_alloc(struct msc *msc, unsigned long *nr_pages, in msc_buffer_multi_alloc() argument
1250 ret = msc_buffer_win_alloc(msc, nr_pages[i]); in msc_buffer_multi_alloc()
1252 msc_buffer_multi_free(msc); in msc_buffer_multi_alloc()
1257 msc_buffer_relink(msc); in msc_buffer_multi_alloc()
1271 static void msc_buffer_free(struct msc *msc) in msc_buffer_free() argument
1273 if (msc->mode == MSC_MODE_SINGLE) in msc_buffer_free()
1274 msc_buffer_contig_free(msc); in msc_buffer_free()
1275 else if (msc->mode == MSC_MODE_MULTI) in msc_buffer_free()
1276 msc_buffer_multi_free(msc); in msc_buffer_free()
1295 static int msc_buffer_alloc(struct msc *msc, unsigned long *nr_pages, in msc_buffer_alloc() argument
1301 if (atomic_read(&msc->user_count) != -1) in msc_buffer_alloc()
1304 if (msc->mode == MSC_MODE_SINGLE) { in msc_buffer_alloc()
1308 ret = msc_buffer_contig_alloc(msc, nr_pages[0] << PAGE_SHIFT); in msc_buffer_alloc()
1309 } else if (msc->mode == MSC_MODE_MULTI) { in msc_buffer_alloc()
1310 ret = msc_buffer_multi_alloc(msc, nr_pages, nr_wins); in msc_buffer_alloc()
1319 if (WARN_ON_ONCE(atomic_cmpxchg(&msc->user_count, -1, 0) != -1)) in msc_buffer_alloc()
1337 static int msc_buffer_unlocked_free_unless_used(struct msc *msc) in msc_buffer_unlocked_free_unless_used() argument
1341 count = atomic_cmpxchg(&msc->user_count, 0, -1); in msc_buffer_unlocked_free_unless_used()
1348 msc_buffer_free(msc); in msc_buffer_unlocked_free_unless_used()
1360 static int msc_buffer_free_unless_used(struct msc *msc) in msc_buffer_free_unless_used() argument
1364 mutex_lock(&msc->buf_mutex); in msc_buffer_free_unless_used()
1365 ret = msc_buffer_unlocked_free_unless_used(msc); in msc_buffer_free_unless_used()
1366 mutex_unlock(&msc->buf_mutex); in msc_buffer_free_unless_used()
1381 static struct page *msc_buffer_get_page(struct msc *msc, unsigned long pgoff) in msc_buffer_get_page() argument
1387 if (msc->mode == MSC_MODE_SINGLE) in msc_buffer_get_page()
1388 return msc_buffer_contig_get_page(msc, pgoff); in msc_buffer_get_page()
1390 list_for_each_entry(win, &msc->win_list, entry) in msc_buffer_get_page()
1447 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_open() local
1453 iter = msc_iter_install(msc); in intel_th_msc_open()
1465 struct msc *msc = iter->msc; in intel_th_msc_release() local
1467 msc_iter_remove(iter, msc); in intel_th_msc_release()
1473 msc_single_to_user(struct msc *msc, char __user *buf, loff_t off, size_t len) in msc_single_to_user() argument
1475 unsigned long size = msc->nr_pages << PAGE_SHIFT, rem = len; in msc_single_to_user()
1478 if (msc->single_wrap) { in msc_single_to_user()
1479 start += msc->single_sz; in msc_single_to_user()
1482 if (copy_to_user(buf, msc->base + start, tocopy)) in msc_single_to_user()
1492 tocopy = min(rem, msc->single_sz - start); in msc_single_to_user()
1493 if (copy_to_user(buf, msc->base + start, tocopy)) in msc_single_to_user()
1502 if (copy_to_user(buf, msc->base + start, rem)) in msc_single_to_user()
1512 struct msc *msc = iter->msc; in intel_th_msc_read() local
1517 if (!atomic_inc_unless_negative(&msc->user_count)) in intel_th_msc_read()
1520 if (msc->mode == MSC_MODE_SINGLE && !msc->single_wrap) in intel_th_msc_read()
1521 size = msc->single_sz; in intel_th_msc_read()
1523 size = msc->nr_pages << PAGE_SHIFT; in intel_th_msc_read()
1534 if (msc->mode == MSC_MODE_SINGLE) { in intel_th_msc_read()
1535 ret = msc_single_to_user(msc, buf, off, len); in intel_th_msc_read()
1538 } else if (msc->mode == MSC_MODE_MULTI) { in intel_th_msc_read()
1552 atomic_dec(&msc->user_count); in intel_th_msc_read()
1564 struct msc *msc = iter->msc; in msc_mmap_open() local
1566 atomic_inc(&msc->mmap_count); in msc_mmap_open()
1572 struct msc *msc = iter->msc; in msc_mmap_close() local
1575 if (!atomic_dec_and_mutex_lock(&msc->mmap_count, &msc->buf_mutex)) in msc_mmap_close()
1579 for (pg = 0; pg < msc->nr_pages; pg++) { in msc_mmap_close()
1580 struct page *page = msc_buffer_get_page(msc, pg); in msc_mmap_close()
1590 atomic_dec(&msc->user_count); in msc_mmap_close()
1591 mutex_unlock(&msc->buf_mutex); in msc_mmap_close()
1597 struct msc *msc = iter->msc; in msc_mmap_fault() local
1599 vmf->page = msc_buffer_get_page(msc, vmf->pgoff); in msc_mmap_fault()
1620 struct msc *msc = iter->msc; in intel_th_msc_mmap() local
1630 if (!atomic_inc_unless_negative(&msc->user_count)) in intel_th_msc_mmap()
1633 if (msc->mode != MSC_MODE_SINGLE && in intel_th_msc_mmap()
1634 msc->mode != MSC_MODE_MULTI) in intel_th_msc_mmap()
1637 if (size >> PAGE_SHIFT != msc->nr_pages) in intel_th_msc_mmap()
1640 atomic_set(&msc->mmap_count, 1); in intel_th_msc_mmap()
1645 atomic_dec(&msc->user_count); in intel_th_msc_mmap()
1664 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_wait_empty() local
1670 reg = __raw_readl(msc->reg_base + REG_MSU_MSC0STS); in intel_th_msc_wait_empty()
1675 dev_dbg(msc_dev(msc), "timeout waiting for MSC0 PLE\n"); in intel_th_msc_wait_empty()
1678 static int intel_th_msc_init(struct msc *msc) in intel_th_msc_init() argument
1680 atomic_set(&msc->user_count, -1); in intel_th_msc_init()
1682 msc->mode = msc->multi_is_broken ? MSC_MODE_SINGLE : MSC_MODE_MULTI; in intel_th_msc_init()
1683 mutex_init(&msc->buf_mutex); in intel_th_msc_init()
1684 INIT_LIST_HEAD(&msc->win_list); in intel_th_msc_init()
1685 INIT_LIST_HEAD(&msc->iter_list); in intel_th_msc_init()
1687 msc->burst_len = in intel_th_msc_init()
1688 (ioread32(msc->reg_base + REG_MSU_MSC0CTL) & MSC_LEN) >> in intel_th_msc_init()
1694 static int msc_win_switch(struct msc *msc) in msc_win_switch() argument
1698 if (list_empty(&msc->win_list)) in msc_win_switch()
1701 first = list_first_entry(&msc->win_list, struct msc_window, entry); in msc_win_switch()
1703 if (msc_is_last_win(msc->cur_win)) in msc_win_switch()
1704 msc->cur_win = first; in msc_win_switch()
1706 msc->cur_win = list_next_entry(msc->cur_win, entry); in msc_win_switch()
1708 msc->base = msc_win_base(msc->cur_win); in msc_win_switch()
1709 msc->base_addr = msc_win_base_dma(msc->cur_win); in msc_win_switch()
1711 intel_th_trace_switch(msc->thdev); in msc_win_switch()
1723 struct msc *msc = dev_get_drvdata(dev); in intel_th_msc_window_unlock() local
1729 win = msc_find_window(msc, sgt, false); in intel_th_msc_window_unlock()
1734 if (msc->switch_on_unlock == win) { in intel_th_msc_window_unlock()
1735 msc->switch_on_unlock = NULL; in intel_th_msc_window_unlock()
1736 msc_win_switch(msc); in intel_th_msc_window_unlock()
1743 struct msc *msc = container_of(work, struct msc, work); in msc_work() local
1745 intel_th_msc_deactivate(msc->thdev); in msc_work()
1750 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_interrupt() local
1751 u32 msusts = ioread32(msc->msu_base + REG_MSU_MSUSTS); in intel_th_msc_interrupt()
1752 u32 mask = msc->index ? MSUSTS_MSC1BLAST : MSUSTS_MSC0BLAST; in intel_th_msc_interrupt()
1755 if (!msc->do_irq || !msc->mbuf) in intel_th_msc_interrupt()
1761 return msc->enabled ? IRQ_HANDLED : IRQ_NONE; in intel_th_msc_interrupt()
1763 iowrite32(msusts, msc->msu_base + REG_MSU_MSUSTS); in intel_th_msc_interrupt()
1765 if (!msc->enabled) in intel_th_msc_interrupt()
1769 win = msc->cur_win; in intel_th_msc_interrupt()
1778 if (msc->stop_on_full) in intel_th_msc_interrupt()
1779 schedule_work(&msc->work); in intel_th_msc_interrupt()
1781 msc->switch_on_unlock = next_win; in intel_th_msc_interrupt()
1789 msc_win_switch(msc); in intel_th_msc_interrupt()
1791 if (msc->mbuf && msc->mbuf->ready) in intel_th_msc_interrupt()
1792 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in intel_th_msc_interrupt()
1808 struct msc *msc = dev_get_drvdata(dev); in wrap_show() local
1810 return scnprintf(buf, PAGE_SIZE, "%d\n", msc->wrap); in wrap_show()
1817 struct msc *msc = dev_get_drvdata(dev); in wrap_store() local
1825 msc->wrap = !!val; in wrap_store()
1832 static void msc_buffer_unassign(struct msc *msc) in msc_buffer_unassign() argument
1834 lockdep_assert_held(&msc->buf_mutex); in msc_buffer_unassign()
1836 if (!msc->mbuf) in msc_buffer_unassign()
1839 msc->mbuf->unassign(msc->mbuf_priv); in msc_buffer_unassign()
1840 msu_buffer_put(msc->mbuf); in msc_buffer_unassign()
1841 msc->mbuf_priv = NULL; in msc_buffer_unassign()
1842 msc->mbuf = NULL; in msc_buffer_unassign()
1848 struct msc *msc = dev_get_drvdata(dev); in mode_show() local
1849 const char *mode = msc_mode[msc->mode]; in mode_show()
1852 mutex_lock(&msc->buf_mutex); in mode_show()
1853 if (msc->mbuf) in mode_show()
1854 mode = msc->mbuf->name; in mode_show()
1856 mutex_unlock(&msc->buf_mutex); in mode_show()
1866 struct msc *msc = dev_get_drvdata(dev); in mode_store() local
1889 if (!msc->do_irq) { in mode_store()
1902 if (i == MSC_MODE_MULTI && msc->multi_is_broken) in mode_store()
1905 mutex_lock(&msc->buf_mutex); in mode_store()
1909 if (mbuf && mbuf == msc->mbuf) { in mode_store()
1915 ret = msc_buffer_unlocked_free_unless_used(msc); in mode_store()
1927 msc_buffer_unassign(msc); in mode_store()
1928 msc->mbuf_priv = mbuf_priv; in mode_store()
1929 msc->mbuf = mbuf; in mode_store()
1931 msc_buffer_unassign(msc); in mode_store()
1934 msc->mode = i; in mode_store()
1939 mutex_unlock(&msc->buf_mutex); in mode_store()
1949 struct msc *msc = dev_get_drvdata(dev); in nr_pages_show() local
1953 mutex_lock(&msc->buf_mutex); in nr_pages_show()
1955 if (msc->mode == MSC_MODE_SINGLE) in nr_pages_show()
1956 count = scnprintf(buf, PAGE_SIZE, "%ld\n", msc->nr_pages); in nr_pages_show()
1957 else if (msc->mode == MSC_MODE_MULTI) { in nr_pages_show()
1958 list_for_each_entry(win, &msc->win_list, entry) { in nr_pages_show()
1967 mutex_unlock(&msc->buf_mutex); in nr_pages_show()
1976 struct msc *msc = dev_get_drvdata(dev); in nr_pages_store() local
1986 ret = msc_buffer_free_unless_used(msc); in nr_pages_store()
2009 if (nr_wins && msc->mode == MSC_MODE_SINGLE) { in nr_pages_store()
2032 mutex_lock(&msc->buf_mutex); in nr_pages_store()
2033 ret = msc_buffer_alloc(msc, win, nr_wins); in nr_pages_store()
2034 mutex_unlock(&msc->buf_mutex); in nr_pages_store()
2048 struct msc *msc = dev_get_drvdata(dev); in win_switch_store() local
2060 mutex_lock(&msc->buf_mutex); in win_switch_store()
2066 if (msc->mode == MSC_MODE_MULTI && !msc->mbuf) in win_switch_store()
2067 ret = msc_win_switch(msc); in win_switch_store()
2068 mutex_unlock(&msc->buf_mutex); in win_switch_store()
2078 struct msc *msc = dev_get_drvdata(dev); in stop_on_full_show() local
2080 return sprintf(buf, "%d\n", msc->stop_on_full); in stop_on_full_show()
2087 struct msc *msc = dev_get_drvdata(dev); in stop_on_full_store() local
2090 ret = kstrtobool(buf, &msc->stop_on_full); in stop_on_full_store()
2116 struct msc *msc; in intel_th_msc_probe() local
2128 msc = devm_kzalloc(dev, sizeof(*msc), GFP_KERNEL); in intel_th_msc_probe()
2129 if (!msc) in intel_th_msc_probe()
2134 msc->do_irq = 1; in intel_th_msc_probe()
2137 msc->multi_is_broken = 1; in intel_th_msc_probe()
2139 msc->index = thdev->id; in intel_th_msc_probe()
2141 msc->thdev = thdev; in intel_th_msc_probe()
2142 msc->reg_base = base + msc->index * 0x100; in intel_th_msc_probe()
2143 msc->msu_base = base; in intel_th_msc_probe()
2145 INIT_WORK(&msc->work, msc_work); in intel_th_msc_probe()
2146 err = intel_th_msc_init(msc); in intel_th_msc_probe()
2150 dev_set_drvdata(dev, msc); in intel_th_msc_probe()
2157 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_remove() local
2167 ret = msc_buffer_free_unless_used(msc); in intel_th_msc_remove()