History log of /linux-master/drivers/soc/qcom/smsm.c
Revision Date Author Comments
# bdd7cc62 25-Sep-2023 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>

soc: qcom: smsm: Convert to platform remove callback returning void

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>


# 74f9d27a 23-Mar-2023 Ye Xingchen <ye.xingchen@zte.com.cn>

soc: qcom: smsm: Use dev_err_probe()

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


# 4a1b9f4e 10-Mar-2023 Rob Herring <robh@kernel.org>

soc: qcom: Use of_property_present() for testing DT property presence

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


# af8f6f39 21-Jul-2022 Liang He <windhl@126.com>

soc: qcom: smsm: Fix refcount leak bugs in qcom_smsm_probe()

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


# aad66a3c 08-Mar-2022 Miaoqian Lin <linmq006@gmail.com>

soc: qcom: smsm: Fix missing of_node_put() in smsm_parse_ipc

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


# e3d45719 12-Jul-2021 Stephan Gerhold <stephan@gerhold.net>

soc: qcom: smsm: Fix missed interrupts if state changes while masked

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>


# c73a6852 12-Jul-2021 Stephan Gerhold <stephan@gerhold.net>

soc: qcom: smsm: Implement support for get_irqchip_state

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>


# fac312df 03-Nov-2020 Lee Jones <lee.jones@linaro.org>

soc: qcom: smsm: Fix some kernel-doc formatting and naming problems

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>


# 97fb5e8d 29-May-2019 Thomas Gleixner <tglx@linutronix.de>

treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284

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>


# 8804517e 14-Nov-2017 Johan Hovold <johan@kernel.org>

soc: qcom: smsm: fix child-node lookup

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>


# 3e8b5541 30-Jun-2017 Rob Clark <robdclark@gmail.com>

soc: qcom: smsm: fix of_node refcnting problem

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>


# 35dfa3ef 05-Apr-2017 Jonathan Neuschäfer <j.neuschaefer@gmx.net>

soc: qcom: smsm: Improve error handling, quiesce probe deferral

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>


# 3680a4a9 09-Jun-2016 Bjorn Andersson <bjorn.andersson@linaro.org>

soc: qcom: Update properties for smem state referencing

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>


# c97c4090 24-Sep-2015 Bjorn Andersson <bjorn.andersson@sonymobile.com>

soc: qcom: smsm: Add driver for Qualcomm SMSM

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>