Lines Matching refs:msc
74 struct msc *msc; member
94 struct msc *msc; member
129 struct msc { struct
302 return win->entry.next == &win->msc->win_list; in msc_is_last_win()
314 return list_first_entry(&win->msc->win_list, struct msc_window, in msc_next_window()
350 msc_find_window(struct msc *msc, struct sg_table *sgt, bool nonempty) in msc_find_window() argument
355 if (list_empty(&msc->win_list)) in msc_find_window()
363 list_for_each_entry(win, &msc->win_list, entry) { in msc_find_window()
387 static struct msc_window *msc_oldest_window(struct msc *msc) in msc_oldest_window() argument
391 if (list_empty(&msc->win_list)) in msc_oldest_window()
394 win = msc_find_window(msc, msc_next_window(msc->cur_win)->sgt, true); in msc_oldest_window()
398 return list_first_entry(&msc->win_list, struct msc_window, entry); in msc_oldest_window()
436 static struct msc_iter *msc_iter_install(struct msc *msc) in msc_iter_install() argument
444 mutex_lock(&msc->buf_mutex); in msc_iter_install()
452 if (msc->enabled) { in msc_iter_install()
458 iter->msc = msc; in msc_iter_install()
460 list_add_tail(&iter->entry, &msc->iter_list); in msc_iter_install()
462 mutex_unlock(&msc->buf_mutex); in msc_iter_install()
467 static void msc_iter_remove(struct msc_iter *iter, struct msc *msc) in msc_iter_remove() argument
469 mutex_lock(&msc->buf_mutex); in msc_iter_remove()
471 mutex_unlock(&msc->buf_mutex); in msc_iter_remove()
494 static int msc_iter_win_start(struct msc_iter *iter, struct msc *msc) in msc_iter_win_start() argument
500 iter->start_win = msc_oldest_window(msc); in msc_iter_win_start()
577 struct msc *msc = iter->msc; in msc_buffer_iterate() local
585 if (msc_iter_win_start(iter, msc)) in msc_buffer_iterate()
650 static void msc_buffer_clear_hw_header(struct msc *msc) in msc_buffer_clear_hw_header() argument
655 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_clear_hw_header()
668 static int intel_th_msu_init(struct msc *msc) in intel_th_msu_init() argument
672 if (!msc->do_irq) in intel_th_msu_init()
675 if (!msc->mbuf) in intel_th_msu_init()
678 mintctl = ioread32(msc->msu_base + REG_MSU_MINTCTL); in intel_th_msu_init()
679 mintctl |= msc->index ? M1BLIE : M0BLIE; in intel_th_msu_init()
680 iowrite32(mintctl, msc->msu_base + REG_MSU_MINTCTL); in intel_th_msu_init()
681 if (mintctl != ioread32(msc->msu_base + REG_MSU_MINTCTL)) { in intel_th_msu_init()
682 dev_info(msc_dev(msc), "MINTCTL ignores writes: no usable interrupts\n"); in intel_th_msu_init()
683 msc->do_irq = 0; in intel_th_msu_init()
687 msusts = ioread32(msc->msu_base + REG_MSU_MSUSTS); in intel_th_msu_init()
688 iowrite32(msusts, msc->msu_base + REG_MSU_MSUSTS); in intel_th_msu_init()
693 static void intel_th_msu_deinit(struct msc *msc) in intel_th_msu_deinit() argument
697 if (!msc->do_irq) in intel_th_msu_deinit()
700 mintctl = ioread32(msc->msu_base + REG_MSU_MINTCTL); in intel_th_msu_deinit()
701 mintctl &= msc->index ? ~M1BLIE : ~M0BLIE; in intel_th_msu_deinit()
702 iowrite32(mintctl, msc->msu_base + REG_MSU_MINTCTL); in intel_th_msu_deinit()
713 if (!win->msc->mbuf) in msc_win_set_lockout()
721 dev_warn_ratelimited(msc_dev(win->msc), in msc_win_set_lockout()
730 atomic_inc(&win->msc->user_count); in msc_win_set_lockout()
732 atomic_dec(&win->msc->user_count); in msc_win_set_lockout()
756 static int msc_configure(struct msc *msc) in msc_configure() argument
760 lockdep_assert_held(&msc->buf_mutex); in msc_configure()
762 if (msc->mode > MSC_MODE_MULTI) in msc_configure()
765 if (msc->mode == MSC_MODE_MULTI) { in msc_configure()
766 if (msc_win_set_lockout(msc->cur_win, WIN_READY, WIN_INUSE)) in msc_configure()
769 msc_buffer_clear_hw_header(msc); in msc_configure()
772 msc->orig_addr = ioread32(msc->reg_base + REG_MSU_MSC0BAR); in msc_configure()
773 msc->orig_sz = ioread32(msc->reg_base + REG_MSU_MSC0SIZE); in msc_configure()
775 reg = msc->base_addr >> PAGE_SHIFT; in msc_configure()
776 iowrite32(reg, msc->reg_base + REG_MSU_MSC0BAR); in msc_configure()
778 if (msc->mode == MSC_MODE_SINGLE) { in msc_configure()
779 reg = msc->nr_pages; in msc_configure()
780 iowrite32(reg, msc->reg_base + REG_MSU_MSC0SIZE); in msc_configure()
783 reg = ioread32(msc->reg_base + REG_MSU_MSC0CTL); in msc_configure()
787 reg |= msc->mode << __ffs(MSC_MODE); in msc_configure()
788 reg |= msc->burst_len << __ffs(MSC_LEN); in msc_configure()
790 if (msc->wrap) in msc_configure()
793 iowrite32(reg, msc->reg_base + REG_MSU_MSC0CTL); in msc_configure()
795 intel_th_msu_init(msc); in msc_configure()
797 msc->thdev->output.multiblock = msc->mode == MSC_MODE_MULTI; in msc_configure()
798 intel_th_trace_enable(msc->thdev); in msc_configure()
799 msc->enabled = 1; in msc_configure()
801 if (msc->mbuf && msc->mbuf->activate) in msc_configure()
802 msc->mbuf->activate(msc->mbuf_priv); in msc_configure()
814 static void msc_disable(struct msc *msc) in msc_disable() argument
816 struct msc_window *win = msc->cur_win; in msc_disable()
819 lockdep_assert_held(&msc->buf_mutex); in msc_disable()
821 if (msc->mode == MSC_MODE_MULTI) in msc_disable()
824 if (msc->mbuf && msc->mbuf->deactivate) in msc_disable()
825 msc->mbuf->deactivate(msc->mbuf_priv); in msc_disable()
826 intel_th_msu_deinit(msc); in msc_disable()
827 intel_th_trace_disable(msc->thdev); in msc_disable()
829 if (msc->mode == MSC_MODE_SINGLE) { in msc_disable()
830 reg = ioread32(msc->reg_base + REG_MSU_MSC0STS); in msc_disable()
831 msc->single_wrap = !!(reg & MSCSTS_WRAPSTAT); in msc_disable()
833 reg = ioread32(msc->reg_base + REG_MSU_MSC0MWP); in msc_disable()
834 msc->single_sz = reg & ((msc->nr_pages << PAGE_SHIFT) - 1); in msc_disable()
835 dev_dbg(msc_dev(msc), "MSCnMWP: %08x/%08lx, wrap: %d\n", in msc_disable()
836 reg, msc->single_sz, msc->single_wrap); in msc_disable()
839 reg = ioread32(msc->reg_base + REG_MSU_MSC0CTL); in msc_disable()
841 iowrite32(reg, msc->reg_base + REG_MSU_MSC0CTL); in msc_disable()
843 if (msc->mbuf && msc->mbuf->ready) in msc_disable()
844 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in msc_disable()
847 msc->enabled = 0; in msc_disable()
849 iowrite32(msc->orig_addr, msc->reg_base + REG_MSU_MSC0BAR); in msc_disable()
850 iowrite32(msc->orig_sz, msc->reg_base + REG_MSU_MSC0SIZE); in msc_disable()
852 dev_dbg(msc_dev(msc), "MSCnNWSA: %08x\n", in msc_disable()
853 ioread32(msc->reg_base + REG_MSU_MSC0NWSA)); in msc_disable()
855 reg = ioread32(msc->reg_base + REG_MSU_MSC0STS); in msc_disable()
856 dev_dbg(msc_dev(msc), "MSCnSTS: %08x\n", reg); in msc_disable()
858 reg = ioread32(msc->reg_base + REG_MSU_MSUSTS); in msc_disable()
859 reg &= msc->index ? MSUSTS_MSC1BLAST : MSUSTS_MSC0BLAST; in msc_disable()
860 iowrite32(reg, msc->reg_base + REG_MSU_MSUSTS); in msc_disable()
865 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_activate() local
868 if (!atomic_inc_unless_negative(&msc->user_count)) in intel_th_msc_activate()
871 mutex_lock(&msc->buf_mutex); in intel_th_msc_activate()
874 if (list_empty(&msc->iter_list)) in intel_th_msc_activate()
875 ret = msc_configure(msc); in intel_th_msc_activate()
877 mutex_unlock(&msc->buf_mutex); in intel_th_msc_activate()
880 atomic_dec(&msc->user_count); in intel_th_msc_activate()
887 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_deactivate() local
889 mutex_lock(&msc->buf_mutex); in intel_th_msc_deactivate()
890 if (msc->enabled) { in intel_th_msc_deactivate()
891 msc_disable(msc); in intel_th_msc_deactivate()
892 atomic_dec(&msc->user_count); in intel_th_msc_deactivate()
894 mutex_unlock(&msc->buf_mutex); in intel_th_msc_deactivate()
907 static int msc_buffer_contig_alloc(struct msc *msc, unsigned long size) in msc_buffer_contig_alloc() argument
917 ret = sg_alloc_table(&msc->single_sgt, 1, GFP_KERNEL); in msc_buffer_contig_alloc()
927 sg_set_buf(msc->single_sgt.sgl, page_address(page), size); in msc_buffer_contig_alloc()
929 ret = dma_map_sg(msc_dev(msc)->parent->parent, msc->single_sgt.sgl, 1, in msc_buffer_contig_alloc()
934 msc->nr_pages = nr_pages; in msc_buffer_contig_alloc()
935 msc->base = page_address(page); in msc_buffer_contig_alloc()
936 msc->base_addr = sg_dma_address(msc->single_sgt.sgl); in msc_buffer_contig_alloc()
944 sg_free_table(&msc->single_sgt); in msc_buffer_contig_alloc()
954 static void msc_buffer_contig_free(struct msc *msc) in msc_buffer_contig_free() argument
958 dma_unmap_sg(msc_dev(msc)->parent->parent, msc->single_sgt.sgl, in msc_buffer_contig_free()
960 sg_free_table(&msc->single_sgt); in msc_buffer_contig_free()
962 for (off = 0; off < msc->nr_pages << PAGE_SHIFT; off += PAGE_SIZE) { in msc_buffer_contig_free()
963 struct page *page = virt_to_page(msc->base + off); in msc_buffer_contig_free()
969 msc->nr_pages = 0; in msc_buffer_contig_free()
979 static struct page *msc_buffer_contig_get_page(struct msc *msc, in msc_buffer_contig_get_page() argument
982 if (pgoff >= msc->nr_pages) in msc_buffer_contig_get_page()
985 return virt_to_page(msc->base + (pgoff << PAGE_SHIFT)); in msc_buffer_contig_get_page()
1000 block = dma_alloc_coherent(msc_dev(win->msc)->parent->parent, in __msc_buffer_win_alloc()
1013 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_alloc()
1061 static int msc_buffer_win_alloc(struct msc *msc, unsigned int nr_blocks) in msc_buffer_win_alloc() argument
1073 win->msc = msc; in msc_buffer_win_alloc()
1078 if (!list_empty(&msc->win_list)) { in msc_buffer_win_alloc()
1079 struct msc_window *prev = list_last_entry(&msc->win_list, in msc_buffer_win_alloc()
1086 if (msc->mbuf && msc->mbuf->alloc_window) in msc_buffer_win_alloc()
1087 ret = msc->mbuf->alloc_window(msc->mbuf_priv, &win->sgt, in msc_buffer_win_alloc()
1100 if (list_empty(&msc->win_list)) { in msc_buffer_win_alloc()
1101 msc->base = msc_win_base(win); in msc_buffer_win_alloc()
1102 msc->base_addr = msc_win_base_dma(win); in msc_buffer_win_alloc()
1103 msc->cur_win = win; in msc_buffer_win_alloc()
1106 list_add_tail(&win->entry, &msc->win_list); in msc_buffer_win_alloc()
1107 msc->nr_pages += nr_blocks; in msc_buffer_win_alloc()
1117 static void __msc_buffer_win_free(struct msc *msc, struct msc_window *win) in __msc_buffer_win_free() argument
1126 dma_free_coherent(msc_dev(win->msc)->parent->parent, PAGE_SIZE, in __msc_buffer_win_free()
1140 static void msc_buffer_win_free(struct msc *msc, struct msc_window *win) in msc_buffer_win_free() argument
1142 msc->nr_pages -= win->nr_blocks; in msc_buffer_win_free()
1145 if (list_empty(&msc->win_list)) { in msc_buffer_win_free()
1146 msc->base = NULL; in msc_buffer_win_free()
1147 msc->base_addr = 0; in msc_buffer_win_free()
1152 if (msc->mbuf && msc->mbuf->free_window) in msc_buffer_win_free()
1153 msc->mbuf->free_window(msc->mbuf_priv, win->sgt); in msc_buffer_win_free()
1155 __msc_buffer_win_free(msc, win); in msc_buffer_win_free()
1167 static void msc_buffer_relink(struct msc *msc) in msc_buffer_relink() argument
1172 list_for_each_entry(win, &msc->win_list, entry) { in msc_buffer_relink()
1183 next_win = list_first_entry(&msc->win_list, in msc_buffer_relink()
1221 static void msc_buffer_multi_free(struct msc *msc) in msc_buffer_multi_free() argument
1225 list_for_each_entry_safe(win, iter, &msc->win_list, entry) in msc_buffer_multi_free()
1226 msc_buffer_win_free(msc, win); in msc_buffer_multi_free()
1229 static int msc_buffer_multi_alloc(struct msc *msc, unsigned long *nr_pages, in msc_buffer_multi_alloc() argument
1235 ret = msc_buffer_win_alloc(msc, nr_pages[i]); in msc_buffer_multi_alloc()
1237 msc_buffer_multi_free(msc); in msc_buffer_multi_alloc()
1242 msc_buffer_relink(msc); in msc_buffer_multi_alloc()
1256 static void msc_buffer_free(struct msc *msc) in msc_buffer_free() argument
1258 if (msc->mode == MSC_MODE_SINGLE) in msc_buffer_free()
1259 msc_buffer_contig_free(msc); in msc_buffer_free()
1260 else if (msc->mode == MSC_MODE_MULTI) in msc_buffer_free()
1261 msc_buffer_multi_free(msc); in msc_buffer_free()
1280 static int msc_buffer_alloc(struct msc *msc, unsigned long *nr_pages, in msc_buffer_alloc() argument
1286 if (atomic_read(&msc->user_count) != -1) in msc_buffer_alloc()
1289 if (msc->mode == MSC_MODE_SINGLE) { in msc_buffer_alloc()
1293 ret = msc_buffer_contig_alloc(msc, nr_pages[0] << PAGE_SHIFT); in msc_buffer_alloc()
1294 } else if (msc->mode == MSC_MODE_MULTI) { in msc_buffer_alloc()
1295 ret = msc_buffer_multi_alloc(msc, nr_pages, nr_wins); in msc_buffer_alloc()
1304 if (WARN_ON_ONCE(atomic_cmpxchg(&msc->user_count, -1, 0) != -1)) in msc_buffer_alloc()
1322 static int msc_buffer_unlocked_free_unless_used(struct msc *msc) in msc_buffer_unlocked_free_unless_used() argument
1326 count = atomic_cmpxchg(&msc->user_count, 0, -1); in msc_buffer_unlocked_free_unless_used()
1333 msc_buffer_free(msc); in msc_buffer_unlocked_free_unless_used()
1345 static int msc_buffer_free_unless_used(struct msc *msc) in msc_buffer_free_unless_used() argument
1349 mutex_lock(&msc->buf_mutex); in msc_buffer_free_unless_used()
1350 ret = msc_buffer_unlocked_free_unless_used(msc); in msc_buffer_free_unless_used()
1351 mutex_unlock(&msc->buf_mutex); in msc_buffer_free_unless_used()
1366 static struct page *msc_buffer_get_page(struct msc *msc, unsigned long pgoff) in msc_buffer_get_page() argument
1372 if (msc->mode == MSC_MODE_SINGLE) in msc_buffer_get_page()
1373 return msc_buffer_contig_get_page(msc, pgoff); in msc_buffer_get_page()
1375 list_for_each_entry(win, &msc->win_list, entry) in msc_buffer_get_page()
1432 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_open() local
1438 iter = msc_iter_install(msc); in intel_th_msc_open()
1450 struct msc *msc = iter->msc; in intel_th_msc_release() local
1452 msc_iter_remove(iter, msc); in intel_th_msc_release()
1458 msc_single_to_user(struct msc *msc, char __user *buf, loff_t off, size_t len) in msc_single_to_user() argument
1460 unsigned long size = msc->nr_pages << PAGE_SHIFT, rem = len; in msc_single_to_user()
1463 if (msc->single_wrap) { in msc_single_to_user()
1464 start += msc->single_sz; in msc_single_to_user()
1467 if (copy_to_user(buf, msc->base + start, tocopy)) in msc_single_to_user()
1477 tocopy = min(rem, msc->single_sz - start); in msc_single_to_user()
1478 if (copy_to_user(buf, msc->base + start, tocopy)) in msc_single_to_user()
1487 if (copy_to_user(buf, msc->base + start, rem)) in msc_single_to_user()
1497 struct msc *msc = iter->msc; in intel_th_msc_read() local
1502 if (!atomic_inc_unless_negative(&msc->user_count)) in intel_th_msc_read()
1505 if (msc->mode == MSC_MODE_SINGLE && !msc->single_wrap) in intel_th_msc_read()
1506 size = msc->single_sz; in intel_th_msc_read()
1508 size = msc->nr_pages << PAGE_SHIFT; in intel_th_msc_read()
1519 if (msc->mode == MSC_MODE_SINGLE) { in intel_th_msc_read()
1520 ret = msc_single_to_user(msc, buf, off, len); in intel_th_msc_read()
1523 } else if (msc->mode == MSC_MODE_MULTI) { in intel_th_msc_read()
1537 atomic_dec(&msc->user_count); in intel_th_msc_read()
1549 struct msc *msc = iter->msc; in msc_mmap_open() local
1551 atomic_inc(&msc->mmap_count); in msc_mmap_open()
1557 struct msc *msc = iter->msc; in msc_mmap_close() local
1560 if (!atomic_dec_and_mutex_lock(&msc->mmap_count, &msc->buf_mutex)) in msc_mmap_close()
1564 for (pg = 0; pg < msc->nr_pages; pg++) { in msc_mmap_close()
1565 struct page *page = msc_buffer_get_page(msc, pg); in msc_mmap_close()
1575 atomic_dec(&msc->user_count); in msc_mmap_close()
1576 mutex_unlock(&msc->buf_mutex); in msc_mmap_close()
1582 struct msc *msc = iter->msc; in msc_mmap_fault() local
1584 vmf->page = msc_buffer_get_page(msc, vmf->pgoff); in msc_mmap_fault()
1605 struct msc *msc = iter->msc; in intel_th_msc_mmap() local
1615 if (!atomic_inc_unless_negative(&msc->user_count)) in intel_th_msc_mmap()
1618 if (msc->mode != MSC_MODE_SINGLE && in intel_th_msc_mmap()
1619 msc->mode != MSC_MODE_MULTI) in intel_th_msc_mmap()
1622 if (size >> PAGE_SHIFT != msc->nr_pages) in intel_th_msc_mmap()
1625 atomic_set(&msc->mmap_count, 1); in intel_th_msc_mmap()
1630 atomic_dec(&msc->user_count); in intel_th_msc_mmap()
1649 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_wait_empty() local
1655 reg = __raw_readl(msc->reg_base + REG_MSU_MSC0STS); in intel_th_msc_wait_empty()
1660 dev_dbg(msc_dev(msc), "timeout waiting for MSC0 PLE\n"); in intel_th_msc_wait_empty()
1663 static int intel_th_msc_init(struct msc *msc) in intel_th_msc_init() argument
1665 atomic_set(&msc->user_count, -1); in intel_th_msc_init()
1667 msc->mode = MSC_MODE_MULTI; in intel_th_msc_init()
1668 mutex_init(&msc->buf_mutex); in intel_th_msc_init()
1669 INIT_LIST_HEAD(&msc->win_list); in intel_th_msc_init()
1670 INIT_LIST_HEAD(&msc->iter_list); in intel_th_msc_init()
1672 msc->burst_len = in intel_th_msc_init()
1673 (ioread32(msc->reg_base + REG_MSU_MSC0CTL) & MSC_LEN) >> in intel_th_msc_init()
1679 static void msc_win_switch(struct msc *msc) in msc_win_switch() argument
1683 first = list_first_entry(&msc->win_list, struct msc_window, entry); in msc_win_switch()
1685 if (msc_is_last_win(msc->cur_win)) in msc_win_switch()
1686 msc->cur_win = first; in msc_win_switch()
1688 msc->cur_win = list_next_entry(msc->cur_win, entry); in msc_win_switch()
1690 msc->base = msc_win_base(msc->cur_win); in msc_win_switch()
1691 msc->base_addr = msc_win_base_dma(msc->cur_win); in msc_win_switch()
1693 intel_th_trace_switch(msc->thdev); in msc_win_switch()
1703 struct msc *msc = dev_get_drvdata(dev); in intel_th_msc_window_unlock() local
1709 win = msc_find_window(msc, sgt, false); in intel_th_msc_window_unlock()
1719 struct msc *msc = container_of(work, struct msc, work); in msc_work() local
1721 intel_th_msc_deactivate(msc->thdev); in msc_work()
1726 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_interrupt() local
1727 u32 msusts = ioread32(msc->msu_base + REG_MSU_MSUSTS); in intel_th_msc_interrupt()
1728 u32 mask = msc->index ? MSUSTS_MSC1BLAST : MSUSTS_MSC0BLAST; in intel_th_msc_interrupt()
1731 if (!msc->do_irq || !msc->mbuf) in intel_th_msc_interrupt()
1737 return msc->enabled ? IRQ_HANDLED : IRQ_NONE; in intel_th_msc_interrupt()
1739 iowrite32(msusts, msc->msu_base + REG_MSU_MSUSTS); in intel_th_msc_interrupt()
1741 if (!msc->enabled) in intel_th_msc_interrupt()
1745 win = msc->cur_win; in intel_th_msc_interrupt()
1754 schedule_work(&msc->work); in intel_th_msc_interrupt()
1761 msc_win_switch(msc); in intel_th_msc_interrupt()
1763 if (msc->mbuf && msc->mbuf->ready) in intel_th_msc_interrupt()
1764 msc->mbuf->ready(msc->mbuf_priv, win->sgt, in intel_th_msc_interrupt()
1780 struct msc *msc = dev_get_drvdata(dev); in wrap_show() local
1782 return scnprintf(buf, PAGE_SIZE, "%d\n", msc->wrap); in wrap_show()
1789 struct msc *msc = dev_get_drvdata(dev); in wrap_store() local
1797 msc->wrap = !!val; in wrap_store()
1804 static void msc_buffer_unassign(struct msc *msc) in msc_buffer_unassign() argument
1806 lockdep_assert_held(&msc->buf_mutex); in msc_buffer_unassign()
1808 if (!msc->mbuf) in msc_buffer_unassign()
1811 msc->mbuf->unassign(msc->mbuf_priv); in msc_buffer_unassign()
1812 msu_buffer_put(msc->mbuf); in msc_buffer_unassign()
1813 msc->mbuf_priv = NULL; in msc_buffer_unassign()
1814 msc->mbuf = NULL; in msc_buffer_unassign()
1820 struct msc *msc = dev_get_drvdata(dev); in mode_show() local
1821 const char *mode = msc_mode[msc->mode]; in mode_show()
1824 mutex_lock(&msc->buf_mutex); in mode_show()
1825 if (msc->mbuf) in mode_show()
1826 mode = msc->mbuf->name; in mode_show()
1828 mutex_unlock(&msc->buf_mutex); in mode_show()
1838 struct msc *msc = dev_get_drvdata(dev); in mode_store() local
1861 if (!msc->do_irq) { in mode_store()
1874 mutex_lock(&msc->buf_mutex); in mode_store()
1878 if (mbuf && mbuf == msc->mbuf) { in mode_store()
1884 ret = msc_buffer_unlocked_free_unless_used(msc); in mode_store()
1896 msc_buffer_unassign(msc); in mode_store()
1897 msc->mbuf_priv = mbuf_priv; in mode_store()
1898 msc->mbuf = mbuf; in mode_store()
1900 msc_buffer_unassign(msc); in mode_store()
1903 msc->mode = i; in mode_store()
1908 mutex_unlock(&msc->buf_mutex); in mode_store()
1918 struct msc *msc = dev_get_drvdata(dev); in nr_pages_show() local
1922 mutex_lock(&msc->buf_mutex); in nr_pages_show()
1924 if (msc->mode == MSC_MODE_SINGLE) in nr_pages_show()
1925 count = scnprintf(buf, PAGE_SIZE, "%ld\n", msc->nr_pages); in nr_pages_show()
1926 else if (msc->mode == MSC_MODE_MULTI) { in nr_pages_show()
1927 list_for_each_entry(win, &msc->win_list, entry) { in nr_pages_show()
1936 mutex_unlock(&msc->buf_mutex); in nr_pages_show()
1945 struct msc *msc = dev_get_drvdata(dev); in nr_pages_store() local
1955 ret = msc_buffer_free_unless_used(msc); in nr_pages_store()
1978 if (nr_wins && msc->mode == MSC_MODE_SINGLE) { in nr_pages_store()
2001 mutex_lock(&msc->buf_mutex); in nr_pages_store()
2002 ret = msc_buffer_alloc(msc, win, nr_wins); in nr_pages_store()
2003 mutex_unlock(&msc->buf_mutex); in nr_pages_store()
2017 struct msc *msc = dev_get_drvdata(dev); in win_switch_store() local
2028 mutex_lock(&msc->buf_mutex); in win_switch_store()
2034 if (msc->mode != MSC_MODE_MULTI || msc->mbuf) in win_switch_store()
2037 msc_win_switch(msc); in win_switch_store()
2038 mutex_unlock(&msc->buf_mutex); in win_switch_store()
2061 struct msc *msc; in intel_th_msc_probe() local
2073 msc = devm_kzalloc(dev, sizeof(*msc), GFP_KERNEL); in intel_th_msc_probe()
2074 if (!msc) in intel_th_msc_probe()
2079 msc->do_irq = 1; in intel_th_msc_probe()
2081 msc->index = thdev->id; in intel_th_msc_probe()
2083 msc->thdev = thdev; in intel_th_msc_probe()
2084 msc->reg_base = base + msc->index * 0x100; in intel_th_msc_probe()
2085 msc->msu_base = base; in intel_th_msc_probe()
2087 INIT_WORK(&msc->work, msc_work); in intel_th_msc_probe()
2088 err = intel_th_msc_init(msc); in intel_th_msc_probe()
2092 dev_set_drvdata(dev, msc); in intel_th_msc_probe()
2099 struct msc *msc = dev_get_drvdata(&thdev->dev); in intel_th_msc_remove() local
2109 ret = msc_buffer_free_unless_used(msc); in intel_th_msc_remove()