• Home
  • Raw
  • Download

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()
670 static int intel_th_msu_init(struct msc *msc) in intel_th_msu_init() argument
674 if (!msc->do_irq) in intel_th_msu_init()
677 if (!msc->mbuf) in intel_th_msu_init()
680 mintctl = ioread32(msc->msu_base + REG_MSU_MINTCTL); in intel_th_msu_init()
681 mintctl |= msc->index ? M1BLIE : M0BLIE; in intel_th_msu_init()
682 iowrite32(mintctl, msc->msu_base + REG_MSU_MINTCTL); in intel_th_msu_init()
683 if (mintctl != ioread32(msc->msu_base + REG_MSU_MINTCTL)) { in intel_th_msu_init()
684 dev_info(msc_dev(msc), "MINTCTL ignores writes: no usable interrupts\n"); in intel_th_msu_init()
685 msc->do_irq = 0; in intel_th_msu_init()
689 msusts = ioread32(msc->msu_base + REG_MSU_MSUSTS); in intel_th_msu_init()
690 iowrite32(msusts, msc->msu_base + REG_MSU_MSUSTS); in intel_th_msu_init()
695 static void intel_th_msu_deinit(struct msc *msc) in intel_th_msu_deinit() argument
699 if (!msc->do_irq) in intel_th_msu_deinit()
702 mintctl = ioread32(msc->msu_base + REG_MSU_MINTCTL); in intel_th_msu_deinit()
703 mintctl &= msc->index ? ~M1BLIE : ~M0BLIE; in intel_th_msu_deinit()
704 iowrite32(mintctl, msc->msu_base + REG_MSU_MINTCTL); in intel_th_msu_deinit()
715 if (!win->msc->mbuf) in msc_win_set_lockout()
729 atomic_inc(&win->msc->user_count); in msc_win_set_lockout()
731 atomic_dec(&win->msc->user_count); in msc_win_set_lockout()
744 dev_warn_ratelimited(msc_dev(win->msc), in msc_win_set_lockout()
759 static int msc_configure(struct msc *msc) in msc_configure() argument
763 lockdep_assert_held(&msc->buf_mutex); in msc_configure()
765 if (msc->mode > MSC_MODE_MULTI) in msc_configure()
768 if (msc->mode == MSC_MODE_MULTI) { in msc_configure()
769 if (msc_win_set_lockout(msc->cur_win, WIN_READY, WIN_INUSE)) in msc_configure()
772 msc_buffer_clear_hw_header(msc); in msc_configure()
775 msc->orig_addr = ioread32(msc->reg_base + REG_MSU_MSC0BAR); in msc_configure()
776 msc->orig_sz = ioread32(msc->reg_base + REG_MSU_MSC0SIZE); in msc_configure()
778 reg = msc->base_addr >> PAGE_SHIFT; in msc_configure()
779 iowrite32(reg, msc->reg_base + REG_MSU_MSC0BAR); in msc_configure()
781 if (msc->mode == MSC_MODE_SINGLE) { in msc_configure()
782 reg = msc->nr_pages; in msc_configure()
783 iowrite32(reg, msc->reg_base + REG_MSU_MSC0SIZE); in msc_configure()
786 reg = ioread32(msc->reg_base + REG_MSU_MSC0CTL); in msc_configure()
790 reg |= msc->mode << __ffs(MSC_MODE); in msc_configure()
791 reg |= msc->burst_len << __ffs(MSC_LEN); in msc_configure()
793 if (msc->wrap) in msc_configure()
796 iowrite32(reg, msc->reg_base + REG_MSU_MSC0CTL); in msc_configure()
798 intel_th_msu_init(msc); in msc_configure()
800 msc->thdev->output.multiblock = msc->mode == MSC_MODE_MULTI; in msc_configure()
801 intel_th_trace_enable(msc->thdev); in msc_configure()
802 msc->enabled = 1; in msc_configure()
804 if (msc->mbuf && msc->mbuf->activate) in msc_configure()
805 msc->mbuf->activate(msc->mbuf_priv); in msc_configure()
817 static void msc_disable(struct msc *msc) in msc_disable() argument
819 struct msc_window *win = msc->cur_win; in msc_disable()
822 lockdep_assert_held(&msc->buf_mutex); in msc_disable()
824 if (msc->mode == MSC_MODE_MULTI) in msc_disable()
827 if (msc->mbuf && msc->mbuf->deactivate) in msc_disable()
828 msc->mbuf->deactivate(msc->mbuf_priv); in msc_disable()
829 intel_th_msu_deinit(msc); in msc_disable()
830 intel_th_trace_disable(msc->thdev); in msc_disable()
832 if (msc->mode == MSC_MODE_SINGLE) { in msc_disable()
833 reg = ioread32(msc->reg_base + REG_MSU_MSC0STS); in msc_disable()
834 msc->single_wrap = !!(reg & MSCSTS_WRAPSTAT); in msc_disable()
836 reg = ioread32(msc->reg_base + REG_MSU_MSC0MWP); in msc_disable()
837 msc->single_sz = reg & ((msc->nr_pages << PAGE_SHIFT) - 1); in msc_disable()
838 dev_dbg(msc_dev(msc), "MSCnMWP: %08x/%08lx, wrap: %d\n", in msc_disable()
839 reg, msc->single_sz, msc->single_wrap); in msc_disable()
842 reg = ioread32(msc->reg_base + REG_MSU_MSC0CTL); in msc_disable()
844 iowrite32(reg, msc->reg_base + REG_MSU_MSC0CTL); in msc_disable()
846 if (msc->mbuf && msc->mbuf->ready) in msc_disable()
847 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in msc_disable()
850 msc->enabled = 0; in msc_disable()
852 iowrite32(msc->orig_addr, msc->reg_base + REG_MSU_MSC0BAR); in msc_disable()
853 iowrite32(msc->orig_sz, msc->reg_base + REG_MSU_MSC0SIZE); in msc_disable()
855 dev_dbg(msc_dev(msc), "MSCnNWSA: %08x\n", in msc_disable()
856 ioread32(msc->reg_base + REG_MSU_MSC0NWSA)); in msc_disable()
858 reg = ioread32(msc->reg_base + REG_MSU_MSC0STS); in msc_disable()
859 dev_dbg(msc_dev(msc), "MSCnSTS: %08x\n", reg); in msc_disable()
861 reg = ioread32(msc->reg_base + REG_MSU_MSUSTS); in msc_disable()
862 reg &= msc->index ? MSUSTS_MSC1BLAST : MSUSTS_MSC0BLAST; in msc_disable()
863 iowrite32(reg, msc->reg_base + REG_MSU_MSUSTS); in msc_disable()
868 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_activate() local
871 if (!atomic_inc_unless_negative(&msc->user_count)) in intel_th_msc_activate()
874 mutex_lock(&msc->buf_mutex); in intel_th_msc_activate()
877 if (list_empty(&msc->iter_list)) in intel_th_msc_activate()
878 ret = msc_configure(msc); in intel_th_msc_activate()
880 mutex_unlock(&msc->buf_mutex); in intel_th_msc_activate()
883 atomic_dec(&msc->user_count); in intel_th_msc_activate()
890 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_deactivate() local
892 mutex_lock(&msc->buf_mutex); in intel_th_msc_deactivate()
893 if (msc->enabled) { in intel_th_msc_deactivate()
894 msc_disable(msc); in intel_th_msc_deactivate()
895 atomic_dec(&msc->user_count); in intel_th_msc_deactivate()
897 mutex_unlock(&msc->buf_mutex); in intel_th_msc_deactivate()
910 static int msc_buffer_contig_alloc(struct msc *msc, unsigned long size) in msc_buffer_contig_alloc() argument
920 ret = sg_alloc_table(&msc->single_sgt, 1, GFP_KERNEL); in msc_buffer_contig_alloc()
930 sg_set_buf(msc->single_sgt.sgl, page_address(page), size); in msc_buffer_contig_alloc()
932 ret = dma_map_sg(msc_dev(msc)->parent->parent, msc->single_sgt.sgl, 1, in msc_buffer_contig_alloc()
937 msc->nr_pages = nr_pages; in msc_buffer_contig_alloc()
938 msc->base = page_address(page); in msc_buffer_contig_alloc()
939 msc->base_addr = sg_dma_address(msc->single_sgt.sgl); in msc_buffer_contig_alloc()
947 sg_free_table(&msc->single_sgt); in msc_buffer_contig_alloc()
957 static void msc_buffer_contig_free(struct msc *msc) in msc_buffer_contig_free() argument
961 dma_unmap_sg(msc_dev(msc)->parent->parent, msc->single_sgt.sgl, in msc_buffer_contig_free()
963 sg_free_table(&msc->single_sgt); in msc_buffer_contig_free()
965 for (off = 0; off < msc->nr_pages << PAGE_SHIFT; off += PAGE_SIZE) { in msc_buffer_contig_free()
966 struct page *page = virt_to_page(msc->base + off); in msc_buffer_contig_free()
972 msc->nr_pages = 0; in msc_buffer_contig_free()
982 static struct page *msc_buffer_contig_get_page(struct msc *msc, in msc_buffer_contig_get_page() argument
985 if (pgoff >= msc->nr_pages) in msc_buffer_contig_get_page()
988 return virt_to_page(msc->base + (pgoff << PAGE_SHIFT)); in msc_buffer_contig_get_page()
1003 block = dma_alloc_coherent(msc_dev(win->msc)->parent->parent, in __msc_buffer_win_alloc()
1016 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_alloc()
1025 static void msc_buffer_set_uc(struct msc *msc) in msc_buffer_set_uc() argument
1031 if (msc->mode == MSC_MODE_SINGLE) { in msc_buffer_set_uc()
1032 set_memory_uc((unsigned long)msc->base, msc->nr_pages); in msc_buffer_set_uc()
1036 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_set_uc()
1045 static void msc_buffer_set_wb(struct msc *msc) in msc_buffer_set_wb() argument
1051 if (msc->mode == MSC_MODE_SINGLE) { in msc_buffer_set_wb()
1052 set_memory_wb((unsigned long)msc->base, msc->nr_pages); in msc_buffer_set_wb()
1056 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_set_wb()
1066 msc_buffer_set_uc(struct msc *msc) {} in msc_buffer_set_uc() argument
1067 static inline void msc_buffer_set_wb(struct msc *msc) {} in msc_buffer_set_wb() argument
1090 static int msc_buffer_win_alloc(struct msc *msc, unsigned int nr_blocks) in msc_buffer_win_alloc() argument
1102 win->msc = msc; in msc_buffer_win_alloc()
1107 if (!list_empty(&msc->win_list)) { in msc_buffer_win_alloc()
1108 struct msc_window *prev = list_last_entry(&msc->win_list, in msc_buffer_win_alloc()
1115 if (msc->mbuf && msc->mbuf->alloc_window) in msc_buffer_win_alloc()
1116 ret = msc->mbuf->alloc_window(msc->mbuf_priv, &win->sgt, in msc_buffer_win_alloc()
1127 if (list_empty(&msc->win_list)) { in msc_buffer_win_alloc()
1128 msc->base = msc_win_base(win); in msc_buffer_win_alloc()
1129 msc->base_addr = msc_win_base_dma(win); in msc_buffer_win_alloc()
1130 msc->cur_win = win; in msc_buffer_win_alloc()
1133 list_add_tail(&win->entry, &msc->win_list); in msc_buffer_win_alloc()
1134 msc->nr_pages += nr_blocks; in msc_buffer_win_alloc()
1144 static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win) in __msc_buffer_win_free() argument
1153 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_free()
1167 static void msc_buffer_win_free(struct msc *msc, struct msc_window *win) in msc_buffer_win_free() argument
1169 msc->nr_pages -= win->nr_blocks; in msc_buffer_win_free()
1172 if (list_empty(&msc->win_list)) { in msc_buffer_win_free()
1173 msc->base = NULL; in msc_buffer_win_free()
1174 msc->base_addr = 0; in msc_buffer_win_free()
1177 if (msc->mbuf && msc->mbuf->free_window) in msc_buffer_win_free()
1178 msc->mbuf->free_window(msc->mbuf_priv, win->sgt); in msc_buffer_win_free()
1180 __msc_buffer_win_free(msc, win); in msc_buffer_win_free()
1192 static void msc_buffer_relink(struct msc *msc) in msc_buffer_relink() argument
1197 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_relink()
1208 next_win = list_first_entry(&msc->win_list, in msc_buffer_relink()
1246 static void msc_buffer_multi_free(struct msc *msc) in msc_buffer_multi_free() argument
1250 list_for_each_entry_safe(win, iter, &msc->win_list, entry) in msc_buffer_multi_free()
1251 msc_buffer_win_free(msc, win); in msc_buffer_multi_free()
1254 static int msc_buffer_multi_alloc(struct msc *msc, unsigned long *nr_pages, in msc_buffer_multi_alloc() argument
1260 ret = msc_buffer_win_alloc(msc, nr_pages[i]); in msc_buffer_multi_alloc()
1262 msc_buffer_multi_free(msc); in msc_buffer_multi_alloc()
1267 msc_buffer_relink(msc); in msc_buffer_multi_alloc()
1281 static void msc_buffer_free(struct msc *msc) in msc_buffer_free() argument
1283 msc_buffer_set_wb(msc); in msc_buffer_free()
1285 if (msc->mode == MSC_MODE_SINGLE) in msc_buffer_free()
1286 msc_buffer_contig_free(msc); in msc_buffer_free()
1287 else if (msc->mode == MSC_MODE_MULTI) in msc_buffer_free()
1288 msc_buffer_multi_free(msc); in msc_buffer_free()
1307 static int msc_buffer_alloc(struct msc *msc, unsigned long *nr_pages, in msc_buffer_alloc() argument
1313 if (atomic_read(&msc->user_count) != -1) in msc_buffer_alloc()
1316 if (msc->mode == MSC_MODE_SINGLE) { in msc_buffer_alloc()
1320 ret = msc_buffer_contig_alloc(msc, nr_pages[0] << PAGE_SHIFT); in msc_buffer_alloc()
1321 } else if (msc->mode == MSC_MODE_MULTI) { in msc_buffer_alloc()
1322 ret = msc_buffer_multi_alloc(msc, nr_pages, nr_wins); in msc_buffer_alloc()
1328 msc_buffer_set_uc(msc); in msc_buffer_alloc()
1333 if (WARN_ON_ONCE(atomic_cmpxchg(&msc->user_count, -1, 0) != -1)) in msc_buffer_alloc()
1351 static int msc_buffer_unlocked_free_unless_used(struct msc *msc) in msc_buffer_unlocked_free_unless_used() argument
1355 count = atomic_cmpxchg(&msc->user_count, 0, -1); in msc_buffer_unlocked_free_unless_used()
1362 msc_buffer_free(msc); in msc_buffer_unlocked_free_unless_used()
1374 static int msc_buffer_free_unless_used(struct msc *msc) in msc_buffer_free_unless_used() argument
1378 mutex_lock(&msc->buf_mutex); in msc_buffer_free_unless_used()
1379 ret = msc_buffer_unlocked_free_unless_used(msc); in msc_buffer_free_unless_used()
1380 mutex_unlock(&msc->buf_mutex); in msc_buffer_free_unless_used()
1395 static struct page *msc_buffer_get_page(struct msc *msc, unsigned long pgoff) in msc_buffer_get_page() argument
1401 if (msc->mode == MSC_MODE_SINGLE) in msc_buffer_get_page()
1402 return msc_buffer_contig_get_page(msc, pgoff); in msc_buffer_get_page()
1404 list_for_each_entry(win, &msc->win_list, entry) in msc_buffer_get_page()
1461 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_open() local
1467 iter = msc_iter_install(msc); in intel_th_msc_open()
1479 struct msc *msc = iter->msc; in intel_th_msc_release() local
1481 msc_iter_remove(iter, msc); in intel_th_msc_release()
1487 msc_single_to_user(struct msc *msc, char __user *buf, loff_t off, size_t len) in msc_single_to_user() argument
1489 unsigned long size = msc->nr_pages << PAGE_SHIFT, rem = len; in msc_single_to_user()
1492 if (msc->single_wrap) { in msc_single_to_user()
1493 start += msc->single_sz; in msc_single_to_user()
1496 if (copy_to_user(buf, msc->base + start, tocopy)) in msc_single_to_user()
1506 tocopy = min(rem, msc->single_sz - start); in msc_single_to_user()
1507 if (copy_to_user(buf, msc->base + start, tocopy)) in msc_single_to_user()
1516 if (copy_to_user(buf, msc->base + start, rem)) in msc_single_to_user()
1526 struct msc *msc = iter->msc; in intel_th_msc_read() local
1531 if (!atomic_inc_unless_negative(&msc->user_count)) in intel_th_msc_read()
1534 if (msc->mode == MSC_MODE_SINGLE && !msc->single_wrap) in intel_th_msc_read()
1535 size = msc->single_sz; in intel_th_msc_read()
1537 size = msc->nr_pages << PAGE_SHIFT; in intel_th_msc_read()
1548 if (msc->mode == MSC_MODE_SINGLE) { in intel_th_msc_read()
1549 ret = msc_single_to_user(msc, buf, off, len); in intel_th_msc_read()
1552 } else if (msc->mode == MSC_MODE_MULTI) { in intel_th_msc_read()
1566 atomic_dec(&msc->user_count); in intel_th_msc_read()
1578 struct msc *msc = iter->msc; in msc_mmap_open() local
1580 atomic_inc(&msc->mmap_count); in msc_mmap_open()
1586 struct msc *msc = iter->msc; in msc_mmap_close() local
1589 if (!atomic_dec_and_mutex_lock(&msc->mmap_count, &msc->buf_mutex)) in msc_mmap_close()
1593 for (pg = 0; pg < msc->nr_pages; pg++) { in msc_mmap_close()
1594 struct page *page = msc_buffer_get_page(msc, pg); in msc_mmap_close()
1604 atomic_dec(&msc->user_count); in msc_mmap_close()
1605 mutex_unlock(&msc->buf_mutex); in msc_mmap_close()
1611 struct msc *msc = iter->msc; in msc_mmap_fault() local
1613 vmf->page = msc_buffer_get_page(msc, vmf->pgoff); in msc_mmap_fault()
1634 struct msc *msc = iter->msc; in intel_th_msc_mmap() local
1644 if (!atomic_inc_unless_negative(&msc->user_count)) in intel_th_msc_mmap()
1647 if (msc->mode != MSC_MODE_SINGLE && in intel_th_msc_mmap()
1648 msc->mode != MSC_MODE_MULTI) in intel_th_msc_mmap()
1651 if (size >> PAGE_SHIFT != msc->nr_pages) in intel_th_msc_mmap()
1654 atomic_set(&msc->mmap_count, 1); in intel_th_msc_mmap()
1659 atomic_dec(&msc->user_count); in intel_th_msc_mmap()
1678 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_wait_empty() local
1684 reg = __raw_readl(msc->reg_base + REG_MSU_MSC0STS); in intel_th_msc_wait_empty()
1689 dev_dbg(msc_dev(msc), "timeout waiting for MSC0 PLE\n"); in intel_th_msc_wait_empty()
1692 static int intel_th_msc_init(struct msc *msc) in intel_th_msc_init() argument
1694 atomic_set(&msc->user_count, -1); in intel_th_msc_init()
1696 msc->mode = msc->multi_is_broken ? MSC_MODE_SINGLE : MSC_MODE_MULTI; in intel_th_msc_init()
1697 mutex_init(&msc->buf_mutex); in intel_th_msc_init()
1698 INIT_LIST_HEAD(&msc->win_list); in intel_th_msc_init()
1699 INIT_LIST_HEAD(&msc->iter_list); in intel_th_msc_init()
1701 msc->burst_len = in intel_th_msc_init()
1702 (ioread32(msc->reg_base + REG_MSU_MSC0CTL) & MSC_LEN) >> in intel_th_msc_init()
1708 static int msc_win_switch(struct msc *msc) in msc_win_switch() argument
1712 if (list_empty(&msc->win_list)) in msc_win_switch()
1715 first = list_first_entry(&msc->win_list, struct msc_window, entry); in msc_win_switch()
1717 if (msc_is_last_win(msc->cur_win)) in msc_win_switch()
1718 msc->cur_win = first; in msc_win_switch()
1720 msc->cur_win = list_next_entry(msc->cur_win, entry); in msc_win_switch()
1722 msc->base = msc_win_base(msc->cur_win); in msc_win_switch()
1723 msc->base_addr = msc_win_base_dma(msc->cur_win); in msc_win_switch()
1725 intel_th_trace_switch(msc->thdev); in msc_win_switch()
1737 struct msc *msc = dev_get_drvdata(dev); in intel_th_msc_window_unlock() local
1743 win = msc_find_window(msc, sgt, false); in intel_th_msc_window_unlock()
1748 if (msc->switch_on_unlock == win) { in intel_th_msc_window_unlock()
1749 msc->switch_on_unlock = NULL; in intel_th_msc_window_unlock()
1750 msc_win_switch(msc); in intel_th_msc_window_unlock()
1757 struct msc *msc = container_of(work, struct msc, work); in msc_work() local
1759 intel_th_msc_deactivate(msc->thdev); in msc_work()
1764 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_interrupt() local
1765 u32 msusts = ioread32(msc->msu_base + REG_MSU_MSUSTS); in intel_th_msc_interrupt()
1766 u32 mask = msc->index ? MSUSTS_MSC1BLAST : MSUSTS_MSC0BLAST; in intel_th_msc_interrupt()
1769 if (!msc->do_irq || !msc->mbuf) in intel_th_msc_interrupt()
1775 return msc->enabled ? IRQ_HANDLED : IRQ_NONE; in intel_th_msc_interrupt()
1777 iowrite32(msusts, msc->msu_base + REG_MSU_MSUSTS); in intel_th_msc_interrupt()
1779 if (!msc->enabled) in intel_th_msc_interrupt()
1783 win = msc->cur_win; in intel_th_msc_interrupt()
1792 if (msc->stop_on_full) in intel_th_msc_interrupt()
1793 schedule_work(&msc->work); in intel_th_msc_interrupt()
1795 msc->switch_on_unlock = next_win; in intel_th_msc_interrupt()
1803 msc_win_switch(msc); in intel_th_msc_interrupt()
1805 if (msc->mbuf && msc->mbuf->ready) in intel_th_msc_interrupt()
1806 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in intel_th_msc_interrupt()
1822 struct msc *msc = dev_get_drvdata(dev); in wrap_show() local
1824 return scnprintf(buf, PAGE_SIZE, "%d\n", msc->wrap); in wrap_show()
1831 struct msc *msc = dev_get_drvdata(dev); in wrap_store() local
1839 msc->wrap = !!val; in wrap_store()
1846 static void msc_buffer_unassign(struct msc *msc) in msc_buffer_unassign() argument
1848 lockdep_assert_held(&msc->buf_mutex); in msc_buffer_unassign()
1850 if (!msc->mbuf) in msc_buffer_unassign()
1853 msc->mbuf->unassign(msc->mbuf_priv); in msc_buffer_unassign()
1854 msu_buffer_put(msc->mbuf); in msc_buffer_unassign()
1855 msc->mbuf_priv = NULL; in msc_buffer_unassign()
1856 msc->mbuf = NULL; in msc_buffer_unassign()
1862 struct msc *msc = dev_get_drvdata(dev); in mode_show() local
1863 const char *mode = msc_mode[msc->mode]; in mode_show()
1866 mutex_lock(&msc->buf_mutex); in mode_show()
1867 if (msc->mbuf) in mode_show()
1868 mode = msc->mbuf->name; in mode_show()
1870 mutex_unlock(&msc->buf_mutex); in mode_show()
1880 struct msc *msc = dev_get_drvdata(dev); in mode_store() local
1903 if (!msc->do_irq) { in mode_store()
1916 if (i == MSC_MODE_MULTI && msc->multi_is_broken) in mode_store()
1919 mutex_lock(&msc->buf_mutex); in mode_store()
1923 if (mbuf && mbuf == msc->mbuf) { in mode_store()
1929 ret = msc_buffer_unlocked_free_unless_used(msc); in mode_store()
1941 msc_buffer_unassign(msc); in mode_store()
1942 msc->mbuf_priv = mbuf_priv; in mode_store()
1943 msc->mbuf = mbuf; in mode_store()
1945 msc_buffer_unassign(msc); in mode_store()
1948 msc->mode = i; in mode_store()
1953 mutex_unlock(&msc->buf_mutex); in mode_store()
1963 struct msc *msc = dev_get_drvdata(dev); in nr_pages_show() local
1967 mutex_lock(&msc->buf_mutex); in nr_pages_show()
1969 if (msc->mode == MSC_MODE_SINGLE) in nr_pages_show()
1970 count = scnprintf(buf, PAGE_SIZE, "%ld\n", msc->nr_pages); in nr_pages_show()
1971 else if (msc->mode == MSC_MODE_MULTI) { in nr_pages_show()
1972 list_for_each_entry(win, &msc->win_list, entry) { in nr_pages_show()
1981 mutex_unlock(&msc->buf_mutex); in nr_pages_show()
1990 struct msc *msc = dev_get_drvdata(dev); in nr_pages_store() local
2000 ret = msc_buffer_free_unless_used(msc); in nr_pages_store()
2023 if (nr_wins && msc->mode == MSC_MODE_SINGLE) { in nr_pages_store()
2046 mutex_lock(&msc->buf_mutex); in nr_pages_store()
2047 ret = msc_buffer_alloc(msc, win, nr_wins); in nr_pages_store()
2048 mutex_unlock(&msc->buf_mutex); in nr_pages_store()
2062 struct msc *msc = dev_get_drvdata(dev); in win_switch_store() local
2074 mutex_lock(&msc->buf_mutex); in win_switch_store()
2080 if (msc->mode == MSC_MODE_MULTI && !msc->mbuf) in win_switch_store()
2081 ret = msc_win_switch(msc); in win_switch_store()
2082 mutex_unlock(&msc->buf_mutex); in win_switch_store()
2092 struct msc *msc = dev_get_drvdata(dev); in stop_on_full_show() local
2094 return sprintf(buf, "%d\n", msc->stop_on_full); in stop_on_full_show()
2101 struct msc *msc = dev_get_drvdata(dev); in stop_on_full_store() local
2104 ret = kstrtobool(buf, &msc->stop_on_full); in stop_on_full_store()
2130 struct msc *msc; in intel_th_msc_probe() local
2142 msc = devm_kzalloc(dev, sizeof(*msc), GFP_KERNEL); in intel_th_msc_probe()
2143 if (!msc) in intel_th_msc_probe()
2148 msc->do_irq = 1; in intel_th_msc_probe()
2151 msc->multi_is_broken = 1; in intel_th_msc_probe()
2153 msc->index = thdev->id; in intel_th_msc_probe()
2155 msc->thdev = thdev; in intel_th_msc_probe()
2156 msc->reg_base = base + msc->index * 0x100; in intel_th_msc_probe()
2157 msc->msu_base = base; in intel_th_msc_probe()
2159 INIT_WORK(&msc->work, msc_work); in intel_th_msc_probe()
2160 err = intel_th_msc_init(msc); in intel_th_msc_probe()
2164 dev_set_drvdata(dev, msc); in intel_th_msc_probe()
2171 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_remove() local
2181 ret = msc_buffer_free_unless_used(msc); in intel_th_msc_remove()