summaryrefslogtreecommitdiff
path: root/drivers/rpmsg
AgeCommit message (Collapse)Author
2019-12-04rpmsg: virtio rpmsg: compilation error and warningsIgor Opaniuk
1. Fix this compilation error: /workdir/oe/tmp-glibc/work-shared/verdin-imx8mm/kernel-source/drivers/ rpmsg/virtio_rpmsg_bus.c:1106:23: error: redeclaration of 'newch' with no linkage struct rpmsg_device *newch; ^~~~~ /workdir/oe/tmp-glibc/work-shared/verdin-imx8mm/kernel-source/drivers/ rpmsg/virtio_rpmsg_bus.c:1101:23: note: previous declaration of 'newch' was here struct rpmsg_device *newch; 2. Fix warnings that are reproduced when RPMsg char device support is disabled. Fixes: 1172ee2e ("rpmsg: virtio rpmsg: Add RPMsg char driver support") Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>
2019-12-03rpmsg: virtio rpmsg: Add RPMsg char driver supportIgor Opaniuk
virtio rpmsg was not implemented to use RPMsg char driver. Each virtio ns announcement will create a new RPMsg device which is supposed to bound to a RPMsg driver. It doesn't support dynamic endpoints with name service per RPMsg device. With RPMsg char driver, you can have multiple endpoints per RPMsg device. Here is the change from this patch: * Introduce a macro to indicate if want to use RPMsg char driver for virtio RPMsg. The RPMsg device can either be bounded to a simple RPMsg driver or the RPMsg char driver. * Create Virtio RPMsg char device when the virtio RPMsg driver is probed. * when there is a remote service announced, keep it in the virtio proc remote services list. * when there is an endpoint created, bind it to a remote service from the remote services list. If the service doesn't exist yet, create one and mark the service address as ANY. That patch ported to our 4.14 kernel + additional fixes added [1]. Example of usage from userspace app: ``` char data_buf [] = {'a', 'b', 'c', 'd', '\0'}; struct rpmsg_endpoint_info ept_info = {"rpmsg-openamp-demo-channel", 0x2, 0x1}; int fd = open("/dev/rpmsg_ctrl0", O_RDWR); /* create endpoint interface */ ioctl(fd, RPMSG_CREATE_EPT_IOCTL, &ept_info); /* create endpoint */ int fd_ept = open("/dev/rpmsg0", O_RDWR); /* receive data from remote device */ read(fd_ept, &data_buf, sizeof(data_buf)); /* send data to remote device */ write(fd_ept, &data_buf, sizeof(data_buf)); /* destroy endpoint */ ioctl(fd_ept, RPMSG_DESTROY_EPT_IOCTL); close(fd_ept); close(fd); ``` [1] https://patchwork.kernel.org/patch/10145779/ Signed-off-by: Wendy Liang <jliang@xilinx.com> Signed-off-by: Igor Opaniuk <igor.opaniuk@toradex.com>
2019-05-24rpmsg: imx: Disable character echoing by defaultAndri Schmidt
Signed-off-by: Andri Schmidt <a.schmidt@scewo.ch> Signed-off-by: Stefan Agner <stefan.agner@toradex.com>
2019-05-24rpmsg: imx: return ENOTTY if no tty connectedStefan Agner
Return ENOTTY if no reader is using the TTY. Note that the VirtIO transport used by RPmsg currently does not use the return value of this callback, hence currently will not influence operation in any way. Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com>
2019-05-24rpmsg: imx: do not push data when no reader is availableStefan Agner
Pushing data while there is no reader seems to lock/crash the TTY layer in some way. Especially when a reader gets attached again, the kernel crashes with Unable to handle kernel paging request at virtual address 00002248 Also use tty_insert_flip_string which handels the copying and TTY buffer resizing if necessary. Signed-off-by: Stefan Agner <stefan.agner@toradex.com> Acked-by: Marcel Ziswiler <marcel.ziswiler@toradex.com> (cherry picked from commit 5aba75e2c61d4044bed21730b7c471822860fac1)
2019-03-25MLK-21247 rpmsg: imx: do not check the remote ready flag in suspend modeRichard Zhu
Since, the partition reset irq would be triggered anytime. Do not read the status of the MU if master side is in suspend mode. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> (cherry picked from commit 117dbcb1ce258587f8d162c0b3219f32d6de6fbc)
2019-03-23MLK-21244 rpmsg: imx: move pm ops to noirq phraseAnson Huang
Some rpmsg user may require rpmsg resume before the user start handle its irq, e.g the typec controller use a GPIO as irq and use rpmsg to get event status, so move imx rpmsg power management ops to noirq phrase. Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com> Tested-by: Clark Wang <xiaoning.wang@nxp.com> Signed-off-by: Anson Huang <anson.huang@nxp.com> Signed-off-by: Li Jun <jun.li@nxp.com>
2019-03-20MLK-21167 rpmsg: imx: add the sync mechanism during partition resetRichard Zhu
Remove the delay waiting, add the sync mechanism during partition reset. In order to avoid the hang at master side during the rpmsg restore procedure. Re-initialize the first_notify parameter, when rpmsg master assumes remote processor is dead. Otherwise, master side maybe hang during the rpmsg restore procedure in some corner cases. ~14ms is required by M4 to process the MU message from the cold boot. Set the max wait of MU_SendMessageTimeout to 20ms. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> Reviewed-by: Robin Gong <yibin.gong@nxp.com> (cherry picked from commit 6b5573a9c645b947688c171b2dbdb6b70b59356c)
2019-03-20MLK-21194 rpmsg: imx_rpmsg: clear pending partition reboot irq statusFugang Duan
Clear pending interrupt status of partition reboot during rpmsg driver probe to avoid to unregister/register virtio device again. Tested-by: Clark Wang <xiaoning.wang@nxp.com> Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-22MLK-20940-2 rpmsg: adjust the order of rpmsg initializationClark Wang
For the virtual i2c driver should be initialized in subsystem before the other modules initialize. So, the imx_rpmsg and virtio_rpmsg_bus should be initialized before virtual i2c driver. Now, use arch_initcall to initialize these two modules. Signed-off-by: Clark Wang <xiaoning.wang@nxp.com>
2019-02-12MLK-20790-2 rpmsg: imx_rpmsg: use unregister/register virtio device instead ↵Robin Gong
of rpmsg device Currently, issue RPMSG_NS_DESTROY before kick off ready notification to m4 to let m4 side go through all the stale message in vring buffer without doing anything after m4 reset, that's not good enough. The better way is to clear vring buffer after m4 reset, thus everything will be done as the first time of kernel/m4 bootup. So unregister/register virtio device instead of rpmsg device if m4 partition reset. Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2019-02-12MLK-20790-1: rpmsg: imx_rpmsg: dynamic allocate ivdev insteadRobin Gong
Allocate ivdev dynamically instead of static, so that ivdev could be re-initialized by kzalloc() such as 'struct virtio_device', otherwise, the later patch that unregister/register virtio device instead of rpmsg device will cause kernel complain such as 'kobject: tried to init an initialized' and finally register virtio device failure after m4 partition reset. Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2019-02-12MLK-20776-2 RPMSG: imx: add the imx8mq rpmsg variantRichard Zhu
Add the imx8mq/mm rpmsg variant in the driver. No function changes. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2019-02-12MLK-20706 rpmsg: imx_rpmsg: fix building error on i.mx6/7 legancy chipRobin Gong
Fix building error caused by commit c6cd4096c224f("MLK-20691-1: rpmsg: imx_rpmsg: add new partition reset interrupt") because of no scu functions on i.mx6sx/7d legancy chip. Signed-off-by: Robin Gong <yibin.gong@nxp.com> Acked-by: Richard Zhu <hongxing.zhu@nxp.com>
2019-02-12MLK-20691-3 rpmsg: imx_rpmsg: add partition reset supportRobin Gong
unregister all rpmsg devices and kick off ready notifyication again to restore back rpmsg communications after M4 partion reset. Signed-off-by: Robin Gong <yibin.gong@nxp.com> Acked-by: Richard Zhu <hongxing.zhu@nxp.com>
2019-02-12MLK-20691-1: rpmsg: imx_rpmsg: add new partition reset interruptRobin Gong
Add new partition reset interrupt group to know M4 reset and restore back at rpmsg level later. Signed-off-by: Robin Gong <yibin.gong@nxp.com> Acked-by: Richard Zhu <hongxing.zhu@nxp.com>
2019-02-12MLK-20637-2 rpmsg: imx: alloc share mem from per dev dma poolRichard Zhu
- reserve one per dev dma pool, and alloc the share memory from it. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> Acked-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-12MLK-20653 rpmsg: virtio_rpmsg_bus: fix unexpected huge vmap mappingsFugang Duan
If RPMSG dma memory allocate from per-device mem pool by calling .dma_alloc_coherent(), the size is bigger than 2M bytes and alignment with 2M (PMD_SIZE), then kernel dump by calling .vmalloc_to_page(). Since per-device dma pool do vmap mappings by __ioremap(), __ioremap() might use the hugepage mapping, which in turn will cause the vmalloc_page failed to return the correct page due to the PTE not setup. For exp, when reserve 8M bytes per-device dma mem pool, __ioremap() will use hugepage mapping: __ioremap ioremap_page_range ioremap_pud_range ioremap_pmd_range pmd_set_huge(pmd, phys_addr + addr, prot) Commit:029c54b09599 ("mm/vmalloc.c: huge-vmap: fail gracefully on unexpected huge vmap mapping") ensure that vmalloc_to_page() does not go off into the weeds trying to dereference huge PUDs or PMDs as table entries: rpmsg_sg_init -> vmalloc_to_page-> WARN_ON_ONCE(pmd_bad(*pmd)); In generally, .dma_alloc_coherent() allocate memory from CMA pool/DMA pool/atomic_pool, or swiotlb slabs pool, the virt address mapping to physical address should be lineal, so for the rpmsg scatterlist initialization can use pfn to find the page to avoid to call .vmalloc_to_page(). Kernel dump: [ 0.881722] WARNING: CPU: 0 PID: 1 at mm/vmalloc.c:301 vmalloc_to_page+0xbc/0xc8 [ 0.889094] Modules linked in: [ 0.892139] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.14.78-05581-gc61a572 #206 [ 0.899604] Hardware name: Freescale i.MX8QM MEK (DT) [ 0.904643] task: ffff8008f6c98000 task.stack: ffff000008068000 [ 0.910549] PC is at vmalloc_to_page+0xbc/0xc8 [ 0.914987] LR is at rpmsg_sg_init+0x70/0xcc [ 0.919238] pc : [<ffff0000081c80d4>] lr : [<ffff000008ac471c>] pstate: 40000045 [ 0.926619] sp : ffff00000806b8b0 [ 0.929923] x29: ffff00000806b8b0 x28: ffff00000961cdf0 [ 0.935220] x27: ffff00000961cdf0 x26: 0000000000000000 [ 0.940519] x25: 0000000000040000 x24: ffff00000961ce40 [ 0.945819] x23: ffff00000f000000 x22: ffff00000961ce30 [ 0.951118] x21: 0000000000000000 x20: ffff00000806b950 [ 0.956417] x19: 0000000000000000 x18: 000000000000000e [ 0.961717] x17: 0000000000000001 x16: 0000000000000019 [ 0.967016] x15: 0000000000000033 x14: 616d64202c303030 [ 0.972316] x13: 3030306630303030 x12: 3066666666206176 [ 0.977615] x11: 203a737265666675 x10: 62203334394c203a [ 0.982914] x9 : 000000000000009f x8 : ffff00000806b970 [ 0.988214] x7 : 0000000000000000 x6 : ffff000009690712 [ 0.993513] x5 : 0000000000000000 x4 : 0000000080000000 [ 0.998812] x3 : 00e8000090800f0d x2 : ffff8008ffffd3c0 [ 1.004112] x1 : 0000000000000000 x0 : ffff00000f000000 [ 1.009416] Call trace: [ 1.011849] Exception stack(0xffff00000806b770 to 0xffff00000806b8b0) [ 1.018279] b760: ffff00000f000000 0000000000000000 [ 1.026094] b780: ffff8008ffffd3c0 00e8000090800f0d 0000000080000000 0000000000000000 [ 1.033915] b7a0: ffff000009690712 0000000000000000 ffff00000806b970 000000000000009f [ 1.041731] b7c0: 62203334394c203a 203a737265666675 3066666666206176 3030306630303030 [ 1.049550] b7e0: 616d64202c303030 0000000000000033 0000000000000019 0000000000000001 [ 1.057368] b800: 000000000000000e 0000000000000000 ffff00000806b950 0000000000000000 [ 1.065188] b820: ffff00000961ce30 ffff00000f000000 ffff00000961ce40 0000000000040000 [ 1.073008] b840: 0000000000000000 ffff00000961cdf0 ffff00000961cdf0 ffff00000806b8b0 [ 1.080825] b860: ffff000008ac471c ffff00000806b8b0 ffff0000081c80d4 0000000040000045 [ 1.088646] b880: ffff0000092c8528 ffff00000806b890 ffffffffffffffff ffff000008ac4710 [ 1.096461] b8a0: ffff00000806b8b0 ffff0000081c80d4 [ 1.101327] [<ffff0000081c80d4>] vmalloc_to_page+0xbc/0xc8 [ 1.106800] [<ffff000008ac4968>] rpmsg_probe+0x1f0/0x49c [ 1.112107] [<ffff00000859a9a0>] virtio_dev_probe+0x198/0x210 [ 1.117839] [<ffff0000086a1c70>] driver_probe_device+0x220/0x2d4 [ 1.123829] [<ffff0000086a1e90>] __device_attach_driver+0x98/0xc8 [ 1.129913] [<ffff00000869fe7c>] bus_for_each_drv+0x54/0x94 [ 1.135470] [<ffff0000086a1944>] __device_attach+0xc4/0x12c [ 1.141029] [<ffff0000086a1ed0>] device_initial_probe+0x10/0x18 [ 1.146937] [<ffff0000086a0e48>] bus_probe_device+0x90/0x98 [ 1.152501] [<ffff00000869ef88>] device_add+0x3f4/0x570 [ 1.157709] [<ffff00000869f120>] device_register+0x1c/0x28 [ 1.163182] [<ffff00000859a4f8>] register_virtio_device+0xb8/0x114 [ 1.169353] [<ffff000008ac5e94>] imx_rpmsg_probe+0x3a0/0x5d0 [ 1.175003] [<ffff0000086a3768>] platform_drv_probe+0x50/0xbc [ 1.180730] [<ffff0000086a1c70>] driver_probe_device+0x220/0x2d4 [ 1.186725] [<ffff0000086a1dc8>] __driver_attach+0xa4/0xa8 [ 1.192199] [<ffff00000869fdc4>] bus_for_each_dev+0x58/0x98 [ 1.197759] [<ffff0000086a1598>] driver_attach+0x20/0x28 [ 1.203058] [<ffff0000086a1114>] bus_add_driver+0x1c0/0x224 [ 1.208619] [<ffff0000086a26ec>] driver_register+0x68/0x108 [ 1.214178] [<ffff0000086a36ac>] __platform_driver_register+0x4c/0x54 [ 1.220614] [<ffff0000093d14fc>] imx_rpmsg_init+0x1c/0x50 [ 1.225999] [<ffff000008084144>] do_one_initcall+0x38/0x124 [ 1.231560] [<ffff000009370d28>] kernel_init_freeable+0x18c/0x228 [ 1.237640] [<ffff000008d51b60>] kernel_init+0x10/0x100 [ 1.242849] [<ffff000008085348>] ret_from_fork+0x10/0x18 [ 1.248154] ---[ end trace bcc95d4e07033434 ]--- Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com> Suggested-and-reviewed-by: Jason Liu <jason.hui.liu@nxp.com> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-12MLK-20446 rpmsg: imx: only use the timeout by the first notifyRichard Zhu
To make sure that the message wound't be discarded when M4 is running normally or in the suspend mode. Only use the timeout mechanism by the first notify when the vdev is registered. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2019-02-12MLK-19864 rpmsg: imx: fix the kernel panic during tty rpmsg demoRichard Zhu
Fix the kernel panic during tty rpmsg str echo demo. Root cause: The driver name may be flushed. Use the kasprintf to setup the rpmsg tty driver name to fix this issue. [ 35.494361] Unable to handle kernel paging request at virtual address ffff000021b4ba40 [ 35.502321] Mem abort info: [ 35.505117] Exception class = DABT (current EL), IL = 32 bits [ 35.511099] SET = 0, FnV = 0 [ 35.514188] EA = 0, S1PTW = 0 [ 35.517328] Data abort info: [ 35.520255] ISV = 0, ISS = 0x00000007 [ 35.524130] CM = 0, WnR = 0 [ 35.527140] swapper pgtable: 4k pages, 48-bit VAs, pgd = ffff0000096dd000 [ 35.533964] [ffff000021b4ba40] *pgd=000000097fffe803, *pud=000000097fffd803, *pmd=0000000973d20003, *pte=0000000000000000 [ 35.544976] Internal error: Oops: 96000007 [#1] PREEMPT SMP [ 35.550553] Modules linked in: imx_rpmsg_tty [ 35.554843] CPU: 2 PID: 3911 Comm: sh Not tainted 4.14.62-05098-gcff652e-dirty #41 [ 35.562419] Hardware name: Freescale i.MX8QM MEK (DT) [ 35.567479] task: ffff8008f3950000 task.stack: ffff000021b10000 [ 35.573413] PC is at string+0x28/0x98 [ 35.577080] LR is at vsnprintf+0x3c0/0x688 [ 35.581177] pc : [<ffff000008d5f1a0>] lr : [<ffff000008d61c70>] pstate: a0000145 [ 35.588577] sp : ffff000021b13970 [ 35.591894] x29: ffff000021b13970 x28: ffff80097365f56f [ 35.597219] x27: ffff0000092cf03a x26: ffff0000092cf03a [ 35.602544] x25: ffff000021b13a80 x24: ffff8008f365f570 [ 35.607869] x23: 00000000ffffffd8 x22: ffff000008fc08dc [ 35.613195] x21: 000000007fffffff x20: ffff000008fc08cc [ 35.618512] x19: ffff8008f365f570 x18: 0000000000000000 [ 35.623827] x17: 0000ffffbec93588 x16: ffff00000820b2c0 [ 35.629144] x15: 0000000000000000 x14: ffffffffffffffff [ 35.634461] x13: 0000000000000018 x12: 0101010101010101 [ 35.639777] x11: 0000000000000000 x10: ffff000021b13a80 [ 35.645085] x9 : ffff000021b13a80 x8 : ffff000021b13a80 [ 35.650402] x7 : ffff8008f365f570 x6 : fffffffffffffffe [ 35.655718] x5 : 00000000ffffffd0 x4 : ffff000021b4ba40 [ 35.661035] x3 : ffff0a00ffffff04 x2 : ffff80097365f56f [ 35.666354] x1 : ffff80097365f56f x0 : ffffffffffffffff [ 35.671672] Process sh (pid: 3911, stack limit = 0xffff000021b10000) [ 35.678022] Call trace: [ 35.680465] Exception stack(0xffff000021b13830 to 0xffff000021b13970) [ 35.686911] 3820: ffffffffffffffff ffff80097365f56f [ 35.694748] 3840: ffff80097365f56f ffff0a00ffffff04 ffff000021b4ba40 00000000ffffffd0 [ 35.702581] 3860: fffffffffffffffe ffff8008f365f570 ffff000021b13a80 ffff000021b13a80 [ 35.710409] 3880: ffff000021b13a80 0000000000000000 0101010101010101 0000000000000018 [ 35.718245] 38a0: ffffffffffffffff 0000000000000000 ffff00000820b2c0 0000ffffbec93588 [ 35.726081] 38c0: 0000000000000000 ffff8008f365f570 ffff000008fc08cc 000000007fffffff [ 35.733908] 38e0: ffff000008fc08dc 00000000ffffffd8 ffff8008f365f570 ffff000021b13a80 [ 35.741744] 3900: ffff0000092cf03a ffff0000092cf03a ffff80097365f56f ffff000021b13970 [ 35.749583] 3920: ffff000008d61c70 ffff000021b13970 ffff000008d5f1a0 00000000a0000145 [ 35.757417] 3940: ffff8008fff5fb00 0000000000001c00 0000ffffffffffff ffff000008d61930 [ 35.765254] 3960: ffff000021b13970 ffff000008d5f1a0 [ 35.770129] [<ffff000008d5f1a0>] string+0x28/0x98 [ 35.774837] [<ffff000008d61c70>] vsnprintf+0x3c0/0x688 [ 35.779980] [<ffff000008d620e4>] sprintf+0x4c/0x58 Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> Reviewed-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-12MLK-19588-1 imx: rpmsg: use timeout for MU_SendMessage functionRichard Zhu
- Add the timeout mu msg send api. - Use the timeout mu send message function to do the notification when multi-vdev is enabled on one channel. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2019-02-12MLK-18660-4 rpmsg: imx: add the pm opsRichard Zhu
Add the power management operations into imx rpmsg driver. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2019-02-12MLK-18308-1: rpmsg: imx_rpmsg: initialize spinlock before usingRobin Gong
Initialize spinlock before using, otherwise the below oops triggered if CONFIG_DEBUG_SPINLOCK enabled. BUG: spinlock bad magic on CPU#0, kthreadd/2 lock: imx_rpmsg_vprocs+0x1240/0x24a0, .magic: 00000000, .owner: <none>/-1, .ow0 CPU: 0 PID: 2 Comm: kthreadd Not tainted 4.9.88-04946-gf984c92 #324 Hardware name: Freescale i.MX7ULP (Device Tree) [<8010ea64>] (unwind_backtrace) from [<8010b184>] (show_stack+0x10/0x14) [<8010b184>] (show_stack) from [<803c3a8c>] (dump_stack+0x78/0x8c) [<803c3a8c>] (dump_stack) from [<8016a744>] (do_raw_spin_lock+0xc4/0x120) [<8016a744>] (do_raw_spin_lock) from [<809f7448>] (_raw_spin_lock_irqsave+0x20/) [<809f7448>] (_raw_spin_lock_irqsave) from [<807bcdc8>] (imx_mu_rpmsg_isr+0x38/) [<807bcdc8>] (imx_mu_rpmsg_isr) from [<801722d8>] (__handle_irq_event_percpu+0x) [<801722d8>] (__handle_irq_event_percpu) from [<8017237c>] (handle_irq_event_pe) [<8017237c>] (handle_irq_event_percpu) from [<801723f0>] (handle_irq_event+0x38) [<801723f0>] (handle_irq_event) from [<801757f4>] (handle_fasteoi_irq+0xd0/0x1a) [<801757f4>] (handle_fasteoi_irq) from [<80171594>] (generic_handle_irq+0x24/0x) [<80171594>] (generic_handle_irq) from [<80171abc>] (__handle_domain_irq+0x7c/0) [<80171abc>] (__handle_domain_irq) from [<801014e8>] (gic_handle_irq+0x48/0x8c) [<801014e8>] (gic_handle_irq) from [<8010bb8c>] (__irq_svc+0x6c/0xa8) Signed-off-by: Robin Gong <yibin.gong@nxp.com>
2019-02-12MLK-18113: rpmsg: virtio_rpmsg_bus: fix rpmsg_probe() for virtio-mmio transportAnup Patel
This patch was cherry picked from https://patchwork.kernel.org/patch/10155143/ When virtio-rpmsg device is provided via virtio-mmio transport, the dma_alloc_coherent() (called by rpmsg_probe()) fails on ARM/ARM64 systems because "vdev->dev.parent->parent" device is used as parameter to dma_alloc_coherent(). The "vdev->dev.parent->parent" device represents underlying remoteproc platform device when virtio-rpmsg device is provided via virtio-remoteproc transport. When virtio-rpmsg device is provided via virtio-mmio transport, the "vdev->dev.parent->parent" device represents the parent device of virtio-mmio platform device and dma_alloc_coherent() fails for this device because generally there is no corresponding platform device and dma_ops are not setup for "vdev->dev.parent->parent". This patch fixes dma_alloc_coherent() usage in rpmsg_probe() by trying dma_alloc_coherent() with "vdev->dev.parent" device when it fails with "vdev->dev.parent->parent" device. Fixes: b5ab5e24e960 ("remoteproc: maintain a generic child device for Signed-off-by: Anup Patel <anup@brainfault.org> Signed-off-by: Adriana Reus <adriana.reus@nxp.com>
2019-02-12MLK-17837-01 input: misc: rpmsg_input: add rpmsg virtual sensor driverFugang Duan
NXP i.MX7ULP EVK boards all sensors connect with M4 core, A core has to conmunicate with sensors by virtual io bus like rpmsg bus. The driver implement the virtual sensor input driver to configure sensors active/idle/delay actions and report the sensors' event to user space. Supply below sysfs for user to enable/disable detector and counter, set poll delay: /sys/class/misc/step_counter/enable /sys/class/misc/step_detector/enable /sys/class/misc/step_counter/poll_delay Reviewed-by: Elven Wang <elven.wang@nxp.com> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-12MLK-16595 rpmsg: imx: enable multi-core string demoRichard Zhu
Because that there are two M4 cores on iMX8QM. Enable the multi-core string echo support. BuildInfo: - SCFW a6fd9a48, IMX-MKIMAGE 0, ATF 0 - U-Boot 2017.03-imx_v2017.03_4.9.11_imx8_alpha+g258936c Reviewed-by: Frank Li <frank.li@nxp.com> Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2019-02-12MLK-16586-3 rpmsg: imx: enable multi-core rpmsgRichard Zhu
- Init multi-core mu power and clk. - enable the multi-core rpmsg support BuildInfo: - SCFW a6fd9a48, IMX-MKIMAGE 0, ATF 0 - U-Boot 2017.03-imx_v2017.03_4.9.11_imx8_alpha+g258936c Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> Reviewed-by: Robin Gong <yibin.gong@nxp.com> Tested-by: Andy Duan <fugang.duan@nxp.com>
2019-02-12MLK-16564-01 gpio: imx-rpmsg: add rpmsg virtual gpio driverFugang Duan
Add rpmsg virtual gpio driver support. i.MX7ULP GPIO PTA and PTB resource are managed by M4 core, setup one simple protocol with M4 core based on RPMSG virtual IO to let A core access such GPIOs that is what the driver do. Reviewed-by: Richard Zhu <hongxing.zhu@nxp.com> Reviewed-by: Robin Gong <yibin.gong@nxp.com> Signed-off-by: Fugang Duan <fugang.duan@nxp.com>
2019-02-12MLK-16530-3 rpmsg: imx: init mu and limit the pingpong cyclesRichard Zhu
- Init mu power and clk. - Change the cycles of the pingpong demot refer to the limitation of M4 side. When the received data larger than 100, the pingpong of M4 side would be finished. BuildInfo: SCFW 9e9f6ec6, IMX-MKIMAGE 0, ATF 0 Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2019-02-12MLK-16371-2 rpmsg: imx: add the rpmsg for imx8qxpRichard Zhu
Add rpmsg support for imx8qxp. The pingpong demo had been verified on 8qxp platforms. Use memset_io replace memset, because that the memory type of rpvq->addr is strong order type. There would be kernel dump when memset is used on imx8qxp. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2019-02-12MLK-16114: RPMSG: Fixed ulp can't boot after e12586Frank Li
Need call MU_Init before call other function Signed-off-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
2019-02-12MLK-14659 rpmsg: imx: tty: restore support for imx7dOctavian Purdila
Commit 2a596c353234 ("MLK-13981-2 rpmsg: imx: enable rpmsg virt tty") enabled support for imx7ulp but it broke support for imx7d since the currently distributed M4 image for imx7d still uses the old "rpmsg-openamp-demo-channel" naming. While we could change the channel name in the M4 image it is better to maintain backwards compatibility, so add the old naming back to the id table. Signed-off-by: Octavian Purdila <octavian.purdila@nxp.com>
2019-02-12MLK-14619 input: keyboard: rpmsg-keys: add rpmsg-keys driverRobin Gong
Add rpmsg-keys driver on i.mx7ulp-evk board since vol+/vol- keys are connected on m4 side and have to get the status of keys by rpmsg. Signed-off-by: Robin Gong <yibin.gong@nxp.com> [Irina: updated for 4.9 APIs] Signed-off-by: Irina Tirdea <irina.tirdea@nxp.com>
2019-02-12MLK-14487-2 rpmsg: imx: validate the rpmsg on imx7ulpRichard Zhu
- add the .data into the imx_rpmsg_dt_ids table, thus the driver can distinguish the different platforms. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> Tested-by: Daniel Baluta <daniel.baluta@nxp.com>
2019-02-12MLK-14487-1 rpmsg: imx: validate the rpmsg on imx7ulpRichard Zhu
- change the module_init to subsys_initcall. Otherwise, the pf1550-rpmsg would be invoked before the rpmsg bus driver on imx7ulp. Then, sdhc wouldn't be powered up properly if pf1550 isn't functional. - remove the no longer used imc_rpmsg_exit. - pass the real device id if the shared irq is requested. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> Tested-by: Daniel Baluta <daniel.baluta@nxp.com>
2019-02-12MLK-14439-3 rpmsg: imx: setup the imx rpmsg driverRichard Zhu
- move imx_rpmsg from arch/arm/ to drivers/rpmsg. - use the new MU generic APIs in the rpmsg implementation. - Validated the pingpong test on both imx6sx and imx7d sdb boards. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2019-02-12MLK-13981-2 rpmsg: imx: enable rpmsg virt ttyRichard Zhu
Message can be transferred between remote device and iMX7ULP M4. Then the message can be transferred between A7 and M4 by rpmsg channel. demo howto: - insmode the imx_rpmsg_tty.ko module after login A7/Linux. - Receive messages. Used the following command to dump out the msg from the virtual tty. ./unit_tests/mxc_mcc_tty_test.out /dev/ttyRPMSG 115200 R 100 1000 & - Send: use the following command to send the message to M4. echo <your string message> /dev/ttyRPMSG Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com>
2019-02-12MLK-12265 rpmsg: imx: set the imx rpmsg tests be moduleRichard Zhu
Set the imx rpmsg tests to be module in defaut. Signed-off-by: Richard Zhu <hongxing.zhu@nxp.com> (cherry picked from commit 20adce35ef6abfd6b0a52207febe069c7f09a1be)
2019-02-12MLK-11498 rpmsg: imx: tell remote process about the channelRichard Zhu
send a message to our remote processor, and tell remote processor about this channel Signed-off-by: Richard Zhu <Richard.Zhu@freescale.com> (cherry picked from commit 2708c004a60c5b6da020803ee9291b83984d4a65)
2019-02-12MLK-11286-3 rpmsg: imx: enable rpmsg tests on imxRichard Zhu
enable the rpmsg pingpong and tty string echo tests on imx amp socs - pingpong test howto insmod imx_rpmsg_pingpong.ko - tty string echo test howto - step 1, load the imx_rpmsg_tty.ko insmod imx_rpmsg_tty.ko - step 2, lanunch the mxc_mcc_tty_test.out in backend ./mxc_mcc_tty_test.out /dev/ttyRPMSG 115200 R 512 512 & - step 3, issue the echo command echo <string> > /dev/ttyRPMSG Signed-off-by: Richard Zhu <Richard.Zhu@freescale.com>
2018-11-13rpmsg: smd: fix memory leak on channel createColin Ian King
commit 940c620d6af8fca7d115de40f19870fba415efac upstream. Currently a failed allocation of channel->name leads to an immediate return without freeing channel. Fix this by setting ret to -ENOMEM and jumping to an exit path that kfree's channel. Detected by CoverityScan, CID#1473692 ("Resource Leak") Fixes: 53e2822e56c7 ("rpmsg: Introduce Qualcomm SMD backend") Cc: stable@vger.kernel.org Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-29Revert "rpmsg: core: add support to power domains for devices"Greg Kroah-Hartman
This reverts commit 1ed3a93072307265d6385031b72929a904b50f87 which is commit fe782affd0f440a4e60e2cc81b8f2eccb2923113 upstream Rafael reports that this patch causes problems: > -rc2 looks good. There is a problem on dragonboard during boot that was > introduced in v4.14.71 that I didn't notice last week. We'll bisect it > and report back later this week. dragonboard on the other branches (4.9, > 4.18, mainline) looks fine. As Dan pointed out, during validation, we have bisected this issue on a dragonboard 410c (can't find root device) to the following commit for v4.14: [1ed3a9307230] rpmsg: core: add support to power domains for devices There is an on-going discussion on "[PATCH] rpmsg: core: add support to power domains for devices" about this patch having other dependencies and breaking something else on v4.14 as well. so drop it. Reported-by: Rafael Tinoco <rafael.tinoco@linaro.org> Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Cc: Bjorn Andersson <bjorn.andersson@linaro.org> Cc: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-09-19rpmsg: core: add support to power domains for devicesSrinivas Kandagatla
[ Upstream commit fe782affd0f440a4e60e2cc81b8f2eccb2923113 ] Some of the rpmsg devices need to switch on power domains to communicate with remote processor. For example on Qualcomm DB820c platform LPASS power domain needs to switched on for any kind of audio services. This patch adds the missing power domain support in rpmsg core. Without this patch attempting to play audio via QDSP on DB820c would reboot the system. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-03rpmsg: smd: do not use mananged resources for endpoints and channelsSrinivas Kandagatla
commit 4a2e84c6ed85434ce7843e4844b4d3263f7e233b upstream. All the managed resources would be freed by the time release function is invoked. Handling such memory in qcom_smd_edge_release() would do bad things. Found this issue while testing Audio usecase where the dsp is started up and shutdown in a loop. This patch fixes this issue by using simple kzalloc for allocating channel->name and channel which is then freed in qcom_smd_edge_release(). Without this patch restarting a remoteproc would crash the system. Fixes: 53e2822e56c7 ("rpmsg: Introduce Qualcomm SMD backend") Cc: <stable@vger.kernel.org> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-21rpmsg: added MODULE_ALIAS for rpmsg_charRamon Fried
[ Upstream commit 93dd4e73c0d9cc32f835d76a54257020b0bfc75a ] Added "rpmsg:rpmsg_chrdev" MODULE_ALIAS to autoload rpmg_chrdev module automatically. Signed-off-by: Ramon Fried <rfried@codeaurora.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Sasha Levin <alexander.levin@microsoft.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-12-20rpmsg: glink: Initialize the "intent_req_comp" completion variableArun Kumar Neelakantam
[ Upstream commit 2394facb17bcace4b3c19b50202177a5d8903b64 ] The "intent_req_comp" variable is used without initialization which results in NULL pointer dereference in qcom_glink_request_intent(). we need to initialize the completion variable before using it. Fixes: 27b9c5b66b23 ("rpmsg: glink: Request for intents when unavailable") Signed-off-by: Arun Kumar Neelakantam <aneela@codeaurora.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-21rpmsg: glink: Add missing MODULE_LICENSEBjorn Andersson
commit 1e0d5615bbc37deb7732491798abccf8d3c3d244 upstream. The qcom_glink_native driver is missing a MODULE_LICENSE(), correct this. Fixes: 835764ddd9af ("rpmsg: glink: Move the common glink protocol implementation to glink_native.c") Reported-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-02License cleanup: add SPDX GPL-2.0 license identifier to files with no licenseGreg Kroah-Hartman
Many source files in the tree are missing licensing information, which makes it harder for compliance tools to determine the correct license. By default all files without license information are under the default license of the kernel, which is GPL version 2. Update the files which contain no license information with the 'GPL-2.0' SPDX license identifier. The SPDX identifier is a legally binding shorthand, which can be used instead of the full boiler plate text. This patch is based on work done by Thomas Gleixner and Kate Stewart and Philippe Ombredanne. How this work was done: Patches were generated and checked against linux-4.14-rc6 for a subset of the use cases: - file had no licensing information it it. - file was a */uapi/* one with no licensing information in it, - file was a */uapi/* one with existing licensing information, Further patches will be generated in subsequent months to fix up cases where non-standard license headers were used, and references to license had to be inferred by heuristics based on keywords. The analysis to determine which SPDX License Identifier to be applied to a file was done in a spreadsheet of side by side results from of the output of two independent scanners (ScanCode & Windriver) producing SPDX tag:value files created by Philippe Ombredanne. Philippe prepared the base worksheet, and did an initial spot review of a few 1000 files. The 4.13 kernel was the starting point of the analysis with 60,537 files assessed. Kate Stewart did a file by file comparison of the scanner results in the spreadsheet to determine which SPDX license identifier(s) to be applied to the file. She confirmed any determination that was not immediately clear with lawyers working with the Linux Foundation. Criteria used to select files for SPDX license identifier tagging was: - Files considered eligible had to be source code files. - Make and config files were included as candidates if they contained >5 lines of source - File already had some variant of a license header in it (even if <5 lines). All documentation files were explicitly excluded. The following heuristics were used to determine which SPDX license identifiers to apply. - when both scanners couldn't find any license traces, file was considered to have no license information in it, and the top level COPYING file license applied. For non */uapi/* files that summary was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 11139 and resulted in the first patch in this series. If that file was a */uapi/* path one, it was "GPL-2.0 WITH Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was: SPDX license identifier # files ---------------------------------------------------|------- GPL-2.0 WITH Linux-syscall-note 930 and resulted in the second patch in this series. - if a file had some form of licensing information in it, and was one of the */uapi/* ones, it was denoted with the Linux-syscall-note if any GPL family license was found in the file or had no licensing in it (per prior point). Results summary: SPDX license identifier # files ---------------------------------------------------|------ GPL-2.0 WITH Linux-syscall-note 270 GPL-2.0+ WITH Linux-syscall-note 169 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21 ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17 LGPL-2.1+ WITH Linux-syscall-note 15 GPL-1.0+ WITH Linux-syscall-note 14 ((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5 LGPL-2.0+ WITH Linux-syscall-note 4 LGPL-2.1 WITH Linux-syscall-note 3 ((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3 ((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1 and that resulted in the third patch in this series. - when the two scanners agreed on the detected license(s), that became the concluded license(s). - when there was disagreement between the two scanners (one detected a license but the other didn't, or they both detected different licenses) a manual inspection of the file occurred. - In most cases a manual inspection of the information in the file resulted in a clear resolution of the license that should apply (and which scanner probably needed to revisit its heuristics). - When it was not immediately clear, the license identifier was confirmed with lawyers working with the Linux Foundation. - If there was any question as to the appropriate license identifier, the file was flagged for further research and to be revisited later in time. In total, over 70 hours of logged manual review was done on the spreadsheet to determine the SPDX license identifiers to apply to the source files by Kate, Philippe, Thomas and, in some cases, confirmation by lawyers working with the Linux Foundation. Kate also obtained a third independent scan of the 4.13 code base from FOSSology, and compared selected files where the other two scanners disagreed against that SPDX file, to see if there was new insights. The Windriver scanner is based on an older version of FOSSology in part, so they are related. Thomas did random spot checks in about 500 files from the spreadsheets for the uapi headers and agreed with SPDX license identifier in the files he inspected. For the non-uapi files Thomas did random spot checks in about 15000 files. In initial set of patches against 4.14-rc6, 3 files were found to have copy/paste license identifier errors, and have been fixed to reflect the correct identifier. Additionally Philippe spent 10 hours this week doing a detailed manual inspection and review of the 12,461 patched files from the initial patch version early this week with: - a full scancode scan run, collecting the matched texts, detected license ids and scores - reviewing anything where there was a license detected (about 500+ files) to ensure that the applied SPDX license was correct - reviewing anything where there was no detection but the patch license was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied SPDX license was correct This produced a worksheet with 20 files needing minor correction. This worksheet was then exported into 3 different .csv files for the different types of files to be modified. These .csv files were then reviewed by Greg. Thomas wrote a script to parse the csv files and add the proper SPDX tag to the file, in the format that the file expected. This script was further refined by Greg based on the output to detect more types of files automatically and to distinguish between header and source .c files (which need different comment types.) Finally Greg ran the script using the .csv files to generate the patches. Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com> Reviewed-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-10-10rpmsg: glink: Fix memory leak in qcom_glink_alloc_intent()Dan Carpenter
We need to free "intent" and "intent->data" on a couple error paths. Fixes: 933b45da5d1d ("rpmsg: glink: Add support for TX intents") Acked-by: Sricharan R <sricharan@codeaurora.org> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2017-10-10rpmsg: glink: Unlock on error in qcom_glink_request_intent()Dan Carpenter
If qcom_glink_tx() fails, then we need to unlock before returning the error code. Fixes: 27b9c5b66b23 ("rpmsg: glink: Request for intents when unavailable") Acked-by: Sricharan R <sricharan@codeaurora.org> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>