aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mailbox
AgeCommit message (Collapse)Author
2022-04-14drivers: mailbox: llce: add logger config channelRadu Pirea (NXP OSS)
commit bed1cfe754d07f5ac1426f9380f4a88d2655cd5d from https://source.codeaurora.org/external/autobsps32/linux Add logger config channel that can be used to check if the firmware have the logging feature. Issue: ALB-8659 Signed-off-by: Radu Pirea (NXP OSS) <radu-nicolae.pirea@oss.nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2022-04-11Merge branch 'v5.10/standard/base' into v5.10/standard/nxp-sdk-5.10/nxp-s32g2xxBruce Ashfield
2022-04-08mailbox: imx: fix wakeup failure from freeze modeRobin Gong
commit 892cb524ae8a27bf5e42f711318371acd9a9f74a upstream. Since IRQF_NO_SUSPEND used for imx mailbox driver, that means this irq can't be used for wakeup source so that can't wakeup from freeze mode. Add pm_system_wakeup() to wakeup from freeze mode. Fixes: b7b2796b9b31e("mailbox: imx: ONLY IPC MU needs IRQF_NO_SUSPEND flag") Reviewed-by: Jacky Bai <ping.bai@nxp.com> Reviewed-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Robin Gong <yibin.gong@nxp.com> Signed-off-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-04-08mailbox: tegra-hsp: Flush whole channelPekka Pessi
commit 60de2d2dc284e0dd1c2c897d08625bde24ef3454 upstream. The txdone can re-fill the mailbox. Keep polling the mailbox during the flush until all the messages have been delivered. This fixes an issue with the Tegra Combined UART (TCU) where output can get truncated under high traffic load. Signed-off-by: Pekka Pessi <ppessi@nvidia.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Fixes: 91b1b1c3da8a ("mailbox: tegra-hsp: Add support for shared mailboxes") Cc: stable@vger.kernel.org Signed-off-by: Thierry Reding <treding@nvidia.com> Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-01-11mailbox: llce: Add channel type name when reportring an error on itGhennadi Procopciuc
commit 266dfbd7f8a34e86164158d55a0a57fc6d4a4c57 from https://source.codeaurora.org/external/autobsps32/linux Issue: ALB-8293 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2022-01-11net: llce-can: Add support for ethtool private statsGhennadi Procopciuc
commit 0d6331cfebeb91770b68a7b1f29e34ed9aee04b3 from https://source.codeaurora.org/external/autobsps32/linux Add ethtool private stats handlers to debug the handling of the errors received on RX and TX. This exports a CAN specific subset of the errors returned by LLCE FW. Issue: ALB-8259 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-12-06drivers: llce-mailbox: change GFP_KERNEL to GFP_ATOMIC to fix debug calltraceZhantao Tang
The llce_logger driver will show the following calltrace when debug configures enabled: BUG: sleeping function called from invalid context at mm/slab.h:513 in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 338, name: dhcpcd ...... CPU: 1 PID: 338 Comm: dhcpcd Not tainted 5.10.63-yocto-standard #1 Hardware name: Freescale S32G274 (DT) Call trace: dump_backtrace+0x0/0x1d4 show_stack+0x24/0x30 dump_stack+0xf0/0x13c ___might_sleep+0x19c/0x244 __might_sleep+0x60/0x9c kmem_cache_alloc_trace+0x318/0x47c llce_logger_startup+0x5c/0xa0 [llce_mailbox] llce_mb_startup+0x3c/0x50 [llce_mailbox] mbox_request_channel+0x21c/0x2b4 llce_logger_open+0x7c/0xf4 [llce_logger] __dev_open+0x128/0x1f4 __dev_change_flags+0x1d4/0x254 dev_change_flags+0x30/0x70 devinet_ioctl+0x68c/0x700 inet_ioctl+0x1e0/0x254 sock_do_ioctl+0x50/0x1c4 sock_ioctl+0x1fc/0x49c __arm64_sys_ioctl+0xb4/0x100 el0_svc_common.constprop.0+0x9c/0x1a0 do_el0_svc+0x78/0xa0 el0_svc+0x20/0x30 el0_sync_handler+0x1a4/0x1b0 el0_sync+0x180/0x1c0 This is due to GPF_KERNEL flag used when memory allocation in llce_logger_startup() with spin lock acquired. This patch will change the GPF_KERNEL to GPF_ATOMIC to fix the issue. Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-12-06drivers: llce-mailbox: delete DO_ONCE() call for llce_can driverZhantao Tang
In llce-mailbox driver, commit 38262a381b8f ("mailbox: Lazy irq request for llce channels") introduced the DO_ONCE() calls to avoid LLCE host reconfiguration when only the logger is managed by Linux(actually the driver managed by Linux is llce_can not the logger), but for llce, this situation is not common in reality. Moreover, the DO_ONCE() call will cause debug calltrace like the following : Call trace: dump_backtrace+0x0/0x1d4 show_stack+0x24/0x30 dump_stack+0xf0/0x13c ___might_sleep+0x19c/0x244 __might_sleep+0x60/0x9c __kmalloc_track_caller+0x2d4/0x420 __devres_alloc_node+0x5c/0xc0 devm_request_threaded_irq+0x64/0x110 request_llce_pair_irq.isra.0+0x3c/0xac [llce_mailbox] llce_rx_startup+0xf8/0x110 [llce_mailbox] llce_mb_startup+0x3c/0x50 [llce_mailbox] mbox_request_channel+0x21c/0x2b4 mbox_request_channel_byname+0xc4/0x150 llce_can_open+0xd8/0x1f0 [llce_can] __dev_open+0x128/0x1f4 __dev_change_flags+0x1d4/0x254 dev_change_flags+0x30/0x70 do_setlink+0x214/0xaa0 __rtnl_newlink+0x52c/0x830 rtnl_newlink+0x5c/0x8c rtnetlink_rcv_msg+0x174/0x4c0 netlink_rcv_skb+0x64/0x12c rtnetlink_rcv+0x24/0x30 netlink_unicast+0x1b4/0x270 netlink_sendmsg+0x1b4/0x3b4 ____sys_sendmsg+0x1e0/0x234 ___sys_sendmsg+0x88/0xd0 __sys_sendmsg+0x74/0xcc __arm64_sys_sendmsg+0x30/0x40 el0_svc_common.constprop.0+0x9c/0x174 do_el0_svc+0x78/0x9c el0_svc+0x20/0x30 el0_sync_handler+0x1a4/0x1b0 el0_sync+0x180/0x1c0 The reason is that DO_ONCE() will acquire a spin lock before the acctual irq allocation(which may sleep by using GFP_KERNEL flag), so drop these DO_ONCE() calls to fix this issue. Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-12-06drivers: mailbox: replace mutex with spinlock in llce_mailboxZhantao Tang
This patch is to fix the following debug calltrace: BUG: sleeping function called from invalid context at kernel/locking/mutex.c:1149 in_atomic(): 1, irqs_disabled(): 128, non_block: 0, pid: 4974, name: ip INFO: lockdep is turned off. irq event stamp: 0 hardirqs last enabled at (0): [<0000000000000000>] 0x0 hardirqs last disabled at (0): [<ffffffc0100b13f4>] copy_process+0x2e4/0x1000 softirqs last enabled at (0): [<ffffffc0100b13f4>] copy_process+0x2e4/0x1000 softirqs last disabled at (0): [<0000000000000000>] 0x0 Preemption disabled at: [<ffffffc010cad810>] msg_submit+0x2c/0x100 CPU: 2 PID: 4974 Comm: ip Tainted: G W 5.4.105-yocto-standard #1 Hardware name: Freescale S32G274 (DT) Call trace: dump_backtrace+0x0/0x184 show_stack+0x28/0x34 dump_stack+0xd0/0x12c ___might_sleep+0x1a4/0x244 __might_sleep+0x5c/0x90 mutex_lock_io_nested+0x68/0x8bc execute_config_cmd.isra.0+0x40/0xe0 [llce_mailbox] llce_mb_send_data+0xe0/0x234 [llce_mailbox] msg_submit+0xa8/0x100 mbox_send_message+0x84/0x120 llce_can_init+0x94/0x110 [llce_can] llce_can_open+0x4c/0x1e0 [llce_can] __dev_open+0x108/0x1b0 __dev_change_flags+0x1b4/0x220 dev_change_flags+0x40/0x80 do_setlink+0x1f8/0x930 __rtnl_newlink+0x51c/0x7c4 rtnl_newlink+0x58/0x80 rtnetlink_rcv_msg+0x18c/0x490 netlink_rcv_skb+0x60/0x120 rtnetlink_rcv+0x2c/0x3c netlink_unicast+0x184/0x224 netlink_sendmsg+0x1a0/0x340 ____sys_sendmsg+0x1c8/0x214 ___sys_sendmsg+0x94/0xec __sys_sendmsg+0x7c/0xd0 __arm64_sys_sendmsg+0x30/0x3c el0_svc_common.constprop.0+0x78/0x13c el0_svc_handler+0x80/0xa0 el0_svc+0x8/0x208 IPv6: ADDRCONF(NETDEV_CHANGE): llcecan0: link becomes ready The root cause of this issue is that, in msg_submit()(in drivers/mailbox/mailbox.c) the irq will be disabled by spin_lock_irqsave(&chan->lock, flags) then llce_mb_send_data()(in drivers/mailbox/llce-mailbox.c) will execute mutex_lock_io(), this mutex may sleep, so the calltrace shows. So replace the mutex with spinlock to fix it. Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
2021-12-06mailbox: llce: Correct IRQ enablementGhennadi Procopciuc
commit 7a960ab078db8940a66211a348064e50ca603751 from https://source.codeaurora.org/external/autobsps32/linux Issue: ALB-7935 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-12-06mailbox: llce: Send config commands over host0 interfaceGhennadi Procopciuc
commit 3f6b029dd3be0dd21bbd23d1a28af7242d5c6ffe from https://source.codeaurora.org/external/autobsps32/linux Issue: ALB-7935 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-12-06mailbox: llce: Use sema42 to synchronize host and firmwareGhennadi Procopciuc
commit b4d5e6328f265cf4ce9cbaf16929f3156975d476 from https://source.codeaurora.org/external/autobsps32/linux LLCE SEMA42 will be used to serialize IRQ enablement and disablement between LLCE firmware and host execution. Issue: ALB-7935 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-12-06can/llce: Use short packets for Classic CAN interfacesGhennadi Procopciuc
commit 6332ae8e72b43910c99502395e1e8381a1fe8725 from https://source.codeaurora.org/external/autobsps32/linux Issue: ALB-7935 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-12-06llce: Interface update for 1.0.3 firmwareGhennadi Procopciuc
commit 05038e0a2c9d32feff026c721b69b56a2c78c84c from https://source.codeaurora.org/external/autobsps32/linux Issue: ALB-7935 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-10-28llce: s32g2: Fixed bugs about link setup and unavailable phys for LLCE CAN.Dorin Ionita
commit 560d499489495fd6dea687f4c2da81c17545f534 from https://source.codeaurora.org/external/autobsps32/linux In case of unregistered channel, the printing function of received data function was trying to access a NULL pointer instead of the dev argument and this resulted in kernel panic. This fixes the issue by changing the dev argument. Issue: ALB-7896, ALB-7959 Signed-off-by: Dorin Ionita <dorin.ionita@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-09-27Merge branch 'v5.10/standard/base' into v5.10/standard/nxp-sdk-5.10/nxp-s32g2xxBruce Ashfield
Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
2021-09-18soc: mediatek: cmdq: add address shift in jumpYongqiang Niu
[ Upstream commit 8b60ed2b1674b78ebc433a11efa7d48821229037 ] Add address shift when compose jump instruction to compatible with 35bit format. Fixes: 0858fde496f8 ("mailbox: cmdq: variablize address shift in platform") Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-08-15mailbox: llce: Use 16 channels for loggerGhennadi Procopciuc
commit e86d630d707ebba1af423686e3cea67e19671a9e from https://source.codeaurora.org/external/autobsps32/linux This commit prepares the ground for LLCE logger driver which will use SocketCAN interfaces to send the frames to user space. For this purpose, the logger will use a channel for each interface and NAPI specific commands (pop, release, enable / disable notifications) to control the received data. It inherits all operations already performed by LLCE CAN on RX except the local storage of a frame. A local buffer for each interface was needed because all LLCE Logger interfaces are receiving the frames over one single interrupt line and the ID of the interface can be only identified after the frame is popped. Issue: ALB-7505 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-08-15mailbox, can: Fix LLCE_RELESE_RX_INDEX typoGhennadi Procopciuc
commit e9e23d7728b72ccf454235e602453dad6b348226 from https://source.codeaurora.org/external/autobsps32/linux Issue: ALB-5830 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-08-15llce: Replace memory pools with mapped areasGhennadi Procopciuc
commit a93668920a9e1a927d4570ce4a0a222570f66e62 from https://source.codeaurora.org/external/autobsps32/linux This commit replaces the LLCE SRAM memory pools with memory mapped areas in order to perform SRAM initialization when it's needed only. The previous implementation delegated this operation to SRAM driver and, as a direct consequence, the memory was initialized even in cases where the LLCE management was split between Linux and another software stack. Issue: ALB-5830 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-08-15mailbox: llce: Add 'config_platform' parameterGhennadi Procopciuc
commit e5459879c54936d5ea0779443fcdda4298bc8e86 from https://source.codeaurora.org/external/autobsps32/linux This parameter will be used to skip LLCE platform configuration. It's useful for use cases when the mailbox is used only by the logger and the rest of the management is assigned to other software entities. Issue: ALB-5830, ALB-7344 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-08-15mailbox: Lazy irq request for llce channelsGhennadi Procopciuc
commit 38262a381b8f48669c226d8b588cd2a55d35c606 from https://source.codeaurora.org/external/autobsps32/linux LLCE mailbox should request all its interrupts in a lazy way in order to avoid LLCE host reconfiguration when only the logger is managed by Linux. Issue: ALB-5830, ALB-7344 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-08-15llce: share status memory region between core and mailbox driverGhennadi Procopciuc
commit 7ec0203cbe0f32502ecc6f4bd3d1afe4e1e8e38a from https://source.codeaurora.org/external/autobsps32/linux This is needed to allow the LLCE mailbox driver to retrieve the id of the physical interface that captured a logging packet. Issue: ALB-5830, ALB-7344 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-08-15mailbox: llce: Add channel for can loggerGhennadi Procopciuc
commit d4fef0e51cd305a5bc524ea31757222a256dfe38 from https://source.codeaurora.org/external/autobsps32/linux Issue: ALB-5830, ALB-7344 Signed-off-by: Ghennadi Procopciuc <ghennadi.procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-07-14Merge branch 'v5.10/base' into v5.10/standard/nxp-sdk-5.10/nxp-s32g2xxBruce Ashfield
2021-07-14mailbox: qcom-ipcc: Fix IPCC mbox channel exhaustionSibi Sankar
commit d6fbfdbc12745ce24bcd348dbf7e652353b3e59c upstream. Fix IPCC (Inter-Processor Communication Controller) channel exhaustion by setting the channel private data to NULL on mbox shutdown. Err Logs: remoteproc: MBA booted without debug policy, loading mpss remoteproc: glink-edge: failed to acquire IPC channel remoteproc: failed to probe subdevices for remoteproc: -16 Fixes: fa74a0257f45 ("mailbox: Add support for Qualcomm IPCC") Signed-off-by: Sibi Sankar <sibis@codeaurora.org> Cc: stable@vger.kernel.org Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Reviewed-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-07-14mailbox: qcom: Use PLATFORM_DEVID_AUTO to register platform deviceShawn Guo
[ Upstream commit 96e39e95c01283ff5695dafe659df88ada802159 ] In adding APCS clock support for MSM8939, the second clock registration fails due to duplicate device name like below. [ 0.519657] sysfs: cannot create duplicate filename '/bus/platform/devices/qcom-apcs-msm8916-clk' ... [ 0.661158] qcom_apcs_ipc b111000.mailbox: failed to register APCS clk This is because MSM8939 has 3 APCS instances for Cluster0 (little cores), Cluster1 (big cores) and CCI (Cache Coherent Interconnect). Although only APCS of Cluster0 and Cluster1 have IPC bits, each of 3 APCS has A53PLL clock control bits. That said, 3 'qcom-apcs-msm8916-clk' devices need to be registered to instantiate all 3 clocks. Use PLATFORM_DEVID_AUTO rather than PLATFORM_DEVID_NONE for platform_device_register_data() call to fix the issue above. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-06-29drivers: llce: Replace s32g274 occurrence with s32gLarisa Grigore
commit 3c4d75d84a6d2bcae1e51ef7aa0f594d97ef9371 from https://source.codeaurora.org/external/autobsps32/linux The change is necessary for the new S32G3. Issue: ALB-6122 Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-06-29llce-can: Add compatibility with LLCE firmware 1.0.1 CD1Ghennadi Procopciuc
commit 60582346a0de53bdf58557d67bc5970b30e420a1 from https://source.codeaurora.org/external/autobsps32/linux Issue: ALB-6347 Issue: ALB-7000 Signed-off-by: Ghennadi Procopciuc <Ghennadi.Procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-06-29llce-mailbox: Limit bus errorsGhennadi Procopciuc
commit 746e43b662e7e09fc1645dcc06fe925d0c129193 from https://source.codeaurora.org/external/autobsps32/linux Issue: ALB-6347 Issue: ALB-7000 Signed-off-by: Ghennadi Procopciuc <Ghennadi.Procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-06-29llce-can: Add compatibility with LLCE firmware 1.0.0Ghennadi Procopciuc
commit f469f9833ccaf3d51c30c42b24284758590eb41b from https://source.codeaurora.org/external/autobsps32/linux Issue: ALB-6347 Issue: ALB-7000 Signed-off-by: Ghennadi Procopciuc <Ghennadi.Procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-06-29mailbox: llce: Limit the warning messagesGhennadi Procopciuc
commit 3ffa96994f7183d5c45bf6f5a4dca51a66adbb47 from https://source.codeaurora.org/external/autobsps32/linux Spamming the console with warning messages makes the board unusable. Issue: ALB-6442 Issue: ALB-6347 Signed-off-by: Ghennadi Procopciuc <Ghennadi.Procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-06-29llce-can: Use NAPI on RXGhennadi Procopciuc
commit 64e8978a550d15cd7eb68281ff6cb1337209db39 from https://source.codeaurora.org/external/autobsps32/linux Issue: ALB-5610 Signed-off-by: Ghennadi Procopciuc <Ghennadi.Procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-06-29driver: llce-mailbox: Add power management operationsGhennadi Procopciuc
commit f24ba1a692e2a3cf1b919a2243e974e1b16ae075 from https://source.codeaurora.org/external/autobsps32/linux Issue: ALB-5829 Signed-off-by: Ghennadi Procopciuc <Ghennadi.Procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-06-29drivers: mailbox: Add LLCE CAN mailboxGhennadi Procopciuc
commit 00786bbbfabcb306395355207e47dba63cedbcbd from https://source.codeaurora.org/external/autobsps32/linux This mailbox is use to send notification or messages between LLCE accelerator and A53 cores. Issue: ALB-5829 Signed-off-by: Ghennadi Procopciuc <Ghennadi.Procopciuc@nxp.com> Signed-off-by: Zhantao Tang <zhantao.tang@windriver.com>
2021-05-14mailbox: sprd: Introduce refcnt when clients requests/free channelsOrson Zhai
[ Upstream commit 9468ab84032f96496e998cfa173cd1d0ac316bcd ] Unisoc mailbox has no way to be enabled/disabled for any single channel. They can only be set to startup or shutdown as a whole device at same time. Add a variable to count references to avoid mailbox FIFO being reset unexpectedly when clients are requesting or freeing channels. Also add a lock to dismiss possible conflicts from register r/w in different startup or shutdown threads. And fix the crash problem when early interrupts come from channel which has not been requested by client yet. Fixes: ca27fc26cd22 ("mailbox: sprd: Add Spreadtrum mailbox driver") Signed-off-by: Orson Zhai <orson.zhai@unisoc.com> Reviewed-by: Baolin Wang <baolin.wang7@gmail.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-03-04mailbox: sprd: correct definition of SPRD_OUTBOX_FIFO_FULLMagnum Shan
[ Upstream commit 4450f128c51160bfded6b483eba37d0628d7adb2 ] According to the specification, bit[2] represents SPRD_OUTBOX_FIFO_FULL, not bit[0], so correct it. Fixes: ca27fc26cd22 ("mailbox: sprd: Add Spreadtrum mailbox driver") Signed-off-by: Magnum Shan <magnum.shan@unisoc.com> Signed-off-by: Chunyan Zhang <chunyan.zhang@unisoc.com> Reviewed-by: Baolin Wang <baolin.wang7@gmail.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-12-30mailbox: arm_mhu_db: Fix mhu_db_shutdown by replacing kfree with devm_kfreeSudeep Holla
[ Upstream commit 9905f728b0bda737fe2c2afd7c24f3365a45cc7b ] The mhu_db_channel info is allocated per channel using devm_kzalloc from mhu_db_mbox_xlate which gets called from mbox_request_channel. However we are releasing the allocated mhu_db_channel info using plain kfree from mhu_db_shutdown which is called from mbox_free_channel. This leads to random crashes when the channel is freed like below one: Unable to handle kernel paging request at virtual address 0080000400000008 [0080000400000008] address between user and kernel address ranges Internal error: Oops: 96000044 [#1] PREEMPT SMP Modules linked in: scmi_module(-) CPU: 1 PID: 2212 Comm: rmmod Not tainted 5.10.0-rc5 #31 Hardware name: ARM LTD ARM Juno Development Platform/ARM Juno Development Platform, BIOS EDK II Nov 19 2020 pstate: 20000085 (nzCv daIf -PAN -UAO -TCO BTYPE=--) pc : release_nodes+0x74/0x230 lr : devres_release_all+0x40/0x68 Call trace: release_nodes+0x74/0x230 devres_release_all+0x40/0x68 device_release_driver_internal+0x12c/0x1f8 driver_detach+0x58/0xe8 bus_remove_driver+0x64/0xe0 driver_unregister+0x38/0x68 platform_driver_unregister+0x1c/0x28 scmi_driver_exit+0x38/0x44 [scmi_module] __arm64_sys_delete_module+0x188/0x260 el0_svc_common.constprop.0+0x80/0x1a8 do_el0_svc+0x2c/0x98 el0_sync_handler+0x160/0x168 el0_sync+0x174/0x180 Code: 1400000d eb07009f 54000460 f9400486 (f90004a6) ---[ end trace c55ffd306c140233 ]--- Fix it by replacing kfree with devm_kfree as required. Fixes: 7002ca237b21 ("mailbox: arm_mhu: Add ARM MHU doorbell driver") Reported-by: Cristian Marussi <cristian.marussi@arm.com> Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Tested-by: Cristian Marussi <cristian.marussi@arm.com> Reviewed-by: Cristian Marussi <cristian.marussi@arm.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
2020-10-24Merge tag 'armsoc-drivers' of ↵Linus Torvalds
git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc Pull ARM SoC-related driver updates from Olof Johansson: "Various driver updates for platforms. A bulk of this is smaller fixes or cleanups, but some of the new material this time around is: - Support for Nvidia Tegra234 SoC - Ring accelerator support for TI AM65x - PRUSS driver for TI platforms - Renesas support for R-Car V3U SoC - Reset support for Cortex-M4 processor on i.MX8MQ There are also new socinfo entries for a handful of different SoCs and platforms" * tag 'armsoc-drivers' of git://git.kernel.org/pub/scm/linux/kernel/git/soc/soc: (131 commits) drm/mediatek: reduce clear event soc: mediatek: cmdq: add clear option in cmdq_pkt_wfe api soc: mediatek: cmdq: add jump function soc: mediatek: cmdq: add write_s_mask value function soc: mediatek: cmdq: add write_s value function soc: mediatek: cmdq: add read_s function soc: mediatek: cmdq: add write_s_mask function soc: mediatek: cmdq: add write_s function soc: mediatek: cmdq: add address shift in jump soc: mediatek: mtk-infracfg: Fix kerneldoc soc: amlogic: pm-domains: use always-on flag reset: sti: reset-syscfg: fix struct description warnings reset: imx7: add the cm4 reset for i.MX8MQ dt-bindings: reset: imx8mq: add m4 reset reset: Fix and extend kerneldoc reset: reset-zynqmp: Added support for Versal platform dt-bindings: reset: Updated binding for Versal reset driver reset: imx7: Support module build soc: fsl: qe: Remove unnessesary check in ucc_set_tdm_rxtx_clk soc: fsl: qman: convert to use be32_add_cpu() ...
2020-10-16mailbox: avoid timer start from callbackJassi Brar
If the txdone is done by polling, it is possible for msg_submit() to start the timer while txdone_hrtimer() callback is running. If the timer needs recheduling, it could already be enqueued by the time hrtimer_forward_now() is called, leading hrtimer to loudly complain. WARNING: CPU: 3 PID: 74 at kernel/time/hrtimer.c:932 hrtimer_forward+0xc4/0x110 CPU: 3 PID: 74 Comm: kworker/u8:1 Not tainted 5.9.0-rc2-00236-gd3520067d01c-dirty #5 Hardware name: Libre Computer AML-S805X-AC (DT) Workqueue: events_freezable_power_ thermal_zone_device_check pstate: 20000085 (nzCv daIf -PAN -UAO BTYPE=--) pc : hrtimer_forward+0xc4/0x110 lr : txdone_hrtimer+0xf8/0x118 [...] This can be fixed by not starting the timer from the callback path. Which requires the timer reloading as long as any message is queued on the channel, and not just when current tx is not done yet. Fixes: 0cc67945ea59 ("mailbox: switch to hrtimer for tx_complete polling") Reported-by: Da Xue <da@libre.computer> Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Tested-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Jerome Brunet <jbrunet@baylibre.com> Tested-by: Jerome Brunet <jbrunet@baylibre.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2020-10-12maiblox: mediatek: Fix handling of platform_get_irq() errorKrzysztof Kozlowski
platform_get_irq() returns -ERRNO on error. In such case casting to u32 and comparing to 0 would pass the check. Fixes: 623a6143a845 ("mailbox: mediatek: Add Mediatek CMDQ driver") Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2020-10-12mailbox: arm_mhu: Add ARM MHU doorbell driverSudeep Holla
The MHU drives the signal using a 32-bit register, with all 32 bits logically ORed together. The MHU provides a set of registers to enable software to set, clear, and check the status of each of the bits of this register independently. The use of 32 bits for each interrupt line enables software to provide more information about the source of the interrupt. For example, each bit of the register can be associated with a type of event that can contribute to raising the interrupt. This patch adds a separate the MHU controller driver for doorbel mode of operation using the extended DT binding to add support the same. Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2020-10-12mailbox: arm_mhu: Match only if compatible is "arm,mhu"Sudeep Holla
Since we will be soon adding a separate driver based on this ARM MHU driver to support doorbell mode, let us add explicit check to match the default compatible for this driver. This is needed as the probe and match reuses the AMBA device ids currently and don't have any explicit compatible check. Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2020-10-12mailbox: bcm: convert tasklets to use new tasklet_setup() APIAllen Pais
In preparation for unconditionally passing the struct tasklet_struct pointer to all tasklet callbacks, switch to using the new tasklet_setup() and from_tasklet() to pass the tasklet pointer explicitly. Signed-off-by: Romain Perier <romain.perier@gmail.com> Signed-off-by: Allen Pais <allen.lkml@gmail.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2020-09-18firmware: tegra: Enable BPMP support on Tegra234Thierry Reding
Enable support for the BPMP on Tegra234 to avoid relying on Tegra194 being enabled to pull in the needed OF device ID table entry. On simulation platforms the BPMP hasn't booted up yet by the time we probe the BPMP driver and the BPMP hasn't had a chance to mark the doorbell as ringable by the CCPLEX. This corresponding check in the BPMP driver will therefore fail. Work around this by disabling the check on simulation platforms. Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Signed-off-by: Thierry Reding <treding@nvidia.com>
2020-08-14iomap: constify ioreadX() iomem argument (as in generic implementation)Krzysztof Kozlowski
Patch series "iomap: Constify ioreadX() iomem argument", v3. The ioread8/16/32() and others have inconsistent interface among the architectures: some taking address as const, some not. It seems there is nothing really stopping all of them to take pointer to const. This patch (of 4): The ioreadX() and ioreadX_rep() helpers have inconsistent interface. On some architectures void *__iomem address argument is a pointer to const, on some not. Implementations of ioreadX() do not modify the memory under the address so they can be converted to a "const" version for const-safety and consistency among architectures. [krzk@kernel.org: sh: clk: fix assignment from incompatible pointer type for ioreadX()] Link: http://lkml.kernel.org/r/20200723082017.24053-1-krzk@kernel.org [akpm@linux-foundation.org: fix drivers/mailbox/bcm-pdc-mailbox.c] Link: http://lkml.kernel.org/r/202007132209.Rxmv4QyS%25lkp@intel.com Suggested-by: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Cc: Richard Henderson <rth@twiddle.net> Cc: Ivan Kokshaysky <ink@jurassic.park.msu.ru> Cc: Matt Turner <mattst88@gmail.com> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> Cc: Helge Deller <deller@gmx.de> Cc: Michael Ellerman <mpe@ellerman.id.au> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Yoshinori Sato <ysato@users.sourceforge.jp> Cc: Rich Felker <dalias@libc.org> Cc: Kalle Valo <kvalo@codeaurora.org> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Dave Jiang <dave.jiang@intel.com> Cc: Jon Mason <jdmason@kudzu.us> Cc: Allen Hubbe <allenbh@gmail.com> Cc: "Michael S. Tsirkin" <mst@redhat.com> Cc: Jason Wang <jasowang@redhat.com> Link: http://lkml.kernel.org/r/20200709072837.5869-1-krzk@kernel.org Link: http://lkml.kernel.org/r/20200709072837.5869-2-krzk@kernel.org Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2020-08-03mailbox: mediatek: cmdq: clear task in channel before shutdownDennis YC Hsieh
Do success callback in channel when shutdown. For those task not finish, callback with error code thus client has chance to cleanup or reset. Signed-off-by: Dennis YC Hsieh <dennis-yc.hsieh@mediatek.com> Reviewed-by: CK Hu <ck.hu@mediatek.com> Reviewed-by: Bibby Hsieh <bibby.hsieh@mediatek.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2020-08-03mailbox: cmdq: support mt6779 gce platform definitionDennis YC Hsieh
Add gce v4 hardware support with different thread number and shift. Signed-off-by: Dennis YC Hsieh <dennis-yc.hsieh@mediatek.com> Reviewed-by: CK Hu <ck.hu@mediatek.com> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Reviewed-by: Bibby Hsieh <bibby.hsieh@mediatek.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2020-08-03mailbox: cmdq: variablize address shift in platformDennis YC Hsieh
Some gce hardware shift pc and end address in register to support large dram addressing. Implement gce address shift when write or read pc and end register. And add shift bit in platform definition. Signed-off-by: Dennis YC Hsieh <dennis-yc.hsieh@mediatek.com> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>
2020-08-03mailbox: qcom: Add msm8994 apcs compatibleKonrad Dybcio
MSM8994 has an APCS block similar to 8916, but with a different clock driver due to the former one having 2 clusters. Signed-off-by: Konrad Dybcio <konradybcio@gmail.com> Acked-by: Rob Herring <robh@kernel.org> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Jassi Brar <jaswinder.singh@linaro.org>