summaryrefslogtreecommitdiffstats
path: root/drivers/soc/qcom/smsm.c
Commit message (Collapse)AuthorAgeFilesLines
* soc: qcom: smsm: Support using mailbox interfaceLuca Weiss2024-06-121-1/+50
| | | | | | | | | | | | Add support for using the mbox interface instead of manually writing to the syscon. With this change the driver will attempt to get the mailbox first, and if that fails it will fall back to the existing way of using qcom,ipc-* properties and converting to syscon. Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Signed-off-by: Luca Weiss <luca@z3ntu.xyz> Link: https://lore.kernel.org/r/20240606-smsm-mbox-v2-2-8abe6b5f01da@z3ntu.xyz Signed-off-by: Bjorn Andersson <andersson@kernel.org>
* soc: qcom: smsm: Convert to platform remove callback returning voidUwe Kleine-König2023-10-021-4/+2
| | | | | | | | | | | | | | | | | | | The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is ignored (apart from emitting a warning) and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void. Eventually after all drivers are converted, .remove_new() will be renamed to .remove(). Trivially convert this driver from always returning zero in the remove callback to the void returning variant. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Acked-by: Konrad Dybcio <konrad.dybcio@linaro.org> # qcom Link: https://lore.kernel.org/r/20230925095532.1984344-29-u.kleine-koenig@pengutronix.de Signed-off-by: Bjorn Andersson <andersson@kernel.org>
* soc: qcom: smsm: Use dev_err_probe()Ye Xingchen2023-03-241-5/+4
| | | | | | | | Replace the open-code with dev_err_probe() to simplify the code. Signed-off-by: Ye Xingchen <ye.xingchen@zte.com.cn> Signed-off-by: Bjorn Andersson <andersson@kernel.org> Link: https://lore.kernel.org/r/202303241018532824420@zte.com.cn
* soc: qcom: Use of_property_present() for testing DT property presenceRob Herring2023-03-131-1/+1
| | | | | | | | | | | | | | It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more. Signed-off-by: Rob Herring <robh@kernel.org> Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org> Signed-off-by: Bjorn Andersson <andersson@kernel.org> Link: https://lore.kernel.org/r/20230310144724.1545153-1-robh@kernel.org
* soc: qcom: smsm: Fix refcount leak bugs in qcom_smsm_probe()Liang He2022-08-181-7/+13
| | | | | | | | | | | | | | | There are two refcount leak bugs in qcom_smsm_probe(): (1) The 'local_node' is escaped out from for_each_child_of_node() as the break of iteration, we should call of_node_put() for it in error path or when it is not used anymore. (2) The 'node' is escaped out from for_each_available_child_of_node() as the 'goto', we should call of_node_put() for it in goto target. Fixes: c97c4090ff72 ("soc: qcom: smsm: Add driver for Qualcomm SMSM") Signed-off-by: Liang He <windhl@126.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Link: https://lore.kernel.org/r/20220721135217.1301039-1-windhl@126.com
* soc: qcom: smsm: Fix missing of_node_put() in smsm_parse_ipcMiaoqian Lin2022-04-071-0/+1
| | | | | | | | | | The device_node pointer is returned by of_parse_phandle() with refcount incremented. We should use of_node_put() on it when done. Fixes: c97c4090ff72 ("soc: qcom: smsm: Add driver for Qualcomm SMSM") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Link: https://lore.kernel.org/r/20220308073648.24634-1-linmq006@gmail.com
* soc: qcom: smsm: Fix missed interrupts if state changes while maskedStephan Gerhold2021-08-041-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The SMSM driver detects interrupt edges by tracking the last state it has seen (and has triggered the interrupt handler for). This works fine, but only if the interrupt does not change state while masked. For example, if an interrupt is unmasked while the state is HIGH, the stored last_value for that interrupt might still be LOW. Then, when the remote processor triggers smsm_intr() we assume that nothing has changed, even though the state might have changed from HIGH to LOW. Attempt to fix this by checking the current remote state before unmasking an IRQ. Use atomic operations to avoid the interrupt handler from interfering with the unmask function. This fixes modem crashes in some edge cases with the BAM-DMUX driver. Specifically, the BAM-DMUX interrupt handler is not called for the HIGH -> LOW smsm state transition if the BAM-DMUX driver is loaded (and therefore unmasks the interrupt) after the modem was already started: qcom-q6v5-mss 4080000.remoteproc: fatal error received: a2_task.c:3188: Assert FALSE failed: A2 DL PER deadlock timer expired waiting for Apps ACK Fixes: c97c4090ff72 ("soc: qcom: smsm: Add driver for Qualcomm SMSM") Signed-off-by: Stephan Gerhold <stephan@gerhold.net> Link: https://lore.kernel.org/r/20210712135703.324748-2-stephan@gerhold.net Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* soc: qcom: smsm: Implement support for get_irqchip_stateStephan Gerhold2021-08-041-0/+17
| | | | | | | | | | | | | At the moment there is no way for drivers to get the current state of the interrupt signal reported by a remote processor. The irqchip API has generic functionality for this, using irq_get_irqchip_state(). Implement support for getting the IRQCHIP_STATE_LINE_LEVEL by reading the remote state and checking the bit for the specified IRQ. Signed-off-by: Stephan Gerhold <stephan@gerhold.net> Link: https://lore.kernel.org/r/20210712135703.324748-1-stephan@gerhold.net Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* soc: qcom: smsm: Fix some kernel-doc formatting and naming problemsLee Jones2020-11-101-3/+1
| | | | | | | | | | | | | | | | | Fixes the following W=1 kernel build warning(s): drivers/soc/qcom/smsm.c:140: warning: Function parameter or member 'mask' not described in 'smsm_update_bits' drivers/soc/qcom/smsm.c:140: warning: Excess function parameter 'offset' description in 'smsm_update_bits' drivers/soc/qcom/smsm.c:257: warning: bad line: drivers/soc/qcom/smsm.c:260: warning: bad line: Cc: Andy Gross <agross@kernel.org> Cc: Bjorn Andersson <bjorn.andersson@linaro.org> Cc: linux-arm-msm@vger.kernel.org Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Lee Jones <lee.jones@linaro.org> Link: https://lore.kernel.org/r/20201103152838.1290217-18-lee.jones@linaro.org Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
* treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284Thomas Gleixner2019-06-051-9/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license version 2 and only version 2 as published by the free software foundation this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-only has been chosen to replace the boilerplate/reference in 294 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Alexios Zavras <alexios.zavras@intel.com> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190529141900.825281744@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* soc: qcom: smsm: fix child-node lookupJohan Hovold2017-12-201-2/+4
| | | | | | | | | | | | | | | | | | | | | Fix child-node lookup during probe, which ended up searching the whole device tree depth-first starting at the parent rather than just matching on its children. Note that the original premature free of the parent node has already been fixed separately. Also note that this pattern of looking up the first child node with a given property is rare enough that a generic helper is probably not warranted. Fixes: c97c4090ff72 ("soc: qcom: smsm: Add driver for Qualcomm SMSM") Fixes: 3e8b55411468 ("soc: qcom: smsm: fix of_node refcnting problem") Cc: Bjorn Andersson <bjorn.andersson@linaro.org> Cc: Rob Clark <robdclark@gmail.com> Signed-off-by: Johan Hovold <johan@kernel.org> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Andy Gross <andy.gross@linaro.org>
* soc: qcom: smsm: fix of_node refcnting problemRob Clark2017-08-081-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | of_find_node_with_property() drops the reference to the 'from' node, which eventually (after enough -EPROBE_DEFERs) drops the last reference to the node causing all sorts of fun problems, and this nice splat. BUG: sleeping function called from invalid context at ../kernel/locking/mutex.c:747 in_atomic(): 1, irqs_disabled(): 128, pid: 33, name: kworker/0:1 4 locks held by kworker/0:1/33: #0: ("events"){.+.+.+}, at: [<ffff0000080fa91c>] process_one_work+0x1a4/0x728 #1: (deferred_probe_work){+.+.+.}, at: [<ffff0000080fa91c>] process_one_work+0x1a4/0x728 #2: (&dev->mutex){......}, at: [<ffff000008676078>] __device_attach+0x30/0x168 #3: (devtree_lock){......}, at: [<ffff000008828fd0>] of_find_node_with_property+0x30/0xe0 irq event stamp: 18976 hardirqs last enabled at (18975): [<ffff00000815794c>] __down_trylock_console_sem+0x74/0xb8 hardirqs last disabled at (18976): [<ffff0000089e26d4>] _raw_spin_lock_irqsave+0x2c/0x78 softirqs last enabled at (16880): [<ffff0000080e0f00>] __do_softirq+0x580/0x640 softirqs last disabled at (16871): [<ffff0000080e13a4>] irq_exit+0xe4/0x138 CPU: 0 PID: 33 Comm: kworker/0:1 Tainted: G E 4.12.0-rc5+ #1455 Hardware name: qualcomm dragonboard410c/dragonboard410c, BIOS 2017.07-rc1-00234-g22fa70a-dirty 06/26/2017 Workqueue: events deferred_probe_work_func Call trace: [<ffff000008089ee0>] dump_backtrace+0x0/0x230 [<ffff00000808a134>] show_stack+0x24/0x30 [<ffff0000084e1944>] dump_stack+0xac/0xe8 [<ffff00000810d7e0>] ___might_sleep+0x150/0x230 [<ffff00000810d918>] __might_sleep+0x58/0x90 [<ffff0000089dde18>] __mutex_lock+0x50/0x870 [<ffff0000089de674>] mutex_lock_nested+0x3c/0x50 [<ffff000008388ae0>] kernfs_remove+0x30/0x50 [<ffff00000838b720>] sysfs_remove_dir+0x58/0x70 [<ffff0000084e393c>] kobject_del+0x1c/0x58 [<ffff0000084e374c>] kobject_put+0xb4/0x208 [<ffff00000882c364>] of_node_put+0x24/0x30 [<ffff000008829018>] of_find_node_with_property+0x78/0xe0 [<ffff000000aff5f4>] qcom_smsm_probe+0x194/0x720 [smsm] [<ffff0000086793b4>] platform_drv_probe+0x74/0x110 [<ffff0000086765bc>] driver_probe_device+0x2b4/0x420 [<ffff000008676920>] __device_attach_driver+0xd0/0x150 [<ffff000008673e78>] bus_for_each_drv+0x68/0xa8 [<ffff00000867611c>] __device_attach+0xd4/0x168 [<ffff000008676a1c>] device_initial_probe+0x24/0x30 [<ffff000008675380>] bus_probe_device+0xa0/0xa8 [<ffff000008675948>] deferred_probe_work_func+0xb8/0xf8 [<ffff0000080fa9d4>] process_one_work+0x25c/0x728 [<ffff0000080faef4>] worker_thread+0x54/0x3d8 [<ffff0000081031d8>] kthread+0x110/0x140 [<ffff000008082d90>] ret_from_fork+0x10/0x40 OF: ERROR: Bad of_node_put() on /smsm CPU: 0 PID: 33 Comm: kworker/0:1 Tainted: G W E 4.12.0-rc5+ #1455 Hardware name: qualcomm dragonboard410c/dragonboard410c, BIOS 2017.07-rc1-00234-g22fa70a-dirty 06/26/2017 Workqueue: events deferred_probe_work_func Signed-off-by: Rob Clark <robdclark@gmail.com> Signed-off-by: Andy Gross <andy.gross@linaro.org>
* soc: qcom: smsm: Improve error handling, quiesce probe deferralJonathan Neuschäfer2017-06-051-4/+5
| | | | | | | | | | | | Don't use size if info indicates an error condition. Previously a non-ENOENT error (such as -EPROBE_DEFER) would lead to size being used even though it hadn't necessarily been initialized in qcom_smem_get. Don't print an error message in the -EPROBE_DEFER case. Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net> Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org> Signed-off-by: Andy Gross <andy.gross@linaro.org>
* soc: qcom: Update properties for smem state referencingBjorn Andersson2016-06-241-1/+1
| | | | | | | | | | | | Update the property names to match device tree bindings, the correct values should be qcom,smem-states and qcom,smem-state-names. Also update the #qcom,smem-state-cells for consistency, before we merge any users of these properties. Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Andy Gross <andy.gross@linaro.org>
* soc: qcom: smsm: Add driver for Qualcomm SMSMBjorn Andersson2015-12-081-0/+625
This driver exposed the Qualcomm Shared Memory State Machine bits. Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com> Signed-off-by: Andy Gross <agross@codeaurora.org>