linux/drivers/soc/qcom
Douglas Anderson 881808d0bb soc: qcom: rpmh-rsc: Caller handles tcs_invalidate() exclusivity
Auditing tcs_invalidate() made me worried.  Specifically I saw that it
used spin_lock(), not spin_lock_irqsave().  That always worries me
unless I can trace for sure that I'm in the interrupt handler or that
someone else already disabled interrupts.

Looking more at it, there is actually no reason for these locks
anyway.  Specifically the only reason you'd ever call
rpmh_rsc_invalidate() is if you cared that the sleep/wake TCSes were
empty.  That means that they need to continue to be empty even after
rpmh_rsc_invalidate() returns.  The only way that can happen is if the
caller already has done something to keep all other RPMH users out.
It should be noted that even though the caller is only worried about
making sleep/wake TCSes empty, they also need to worry about stopping
active-only transfers if they need to handle the case where
active-only transfers might borrow the wake TCS.

At the moment rpmh_rsc_invalidate() is only called in PM code from the
last CPU.  If that later changes the caller will still need to solve
the above problems themselves, so these locks will never be useful.

Continuing to audit tcs_invalidate(), I found a bug.  The function
didn't properly check for a borrowed TCS if we hadn't recently written
anything into the TCS.  Specifically, if we've never written to the
WAKE_TCS (or we've flushed it recently) then tcs->slots is empty.
We'll early-out and we'll never call tcs_is_free().

I thought about fixing this bug by either deleting the early check for
bitmap_empty() or possibly only doing it if we knew we weren't on a
TCS that could be borrowed.  However, I think it's better to just
delete the checks.

As argued above it's up to the caller to make sure that all other
users of RPMH are quiet before tcs_invalidate() is called.  Since
callers need to handle the zero-active-TCS case anyway that means they
need to make sure that the active-only transfers are quiet before
calling too.  The one way tcs_invalidate() gets called today is
through rpmh_rsc_cpu_pm_callback() which calls
rpmh_rsc_ctrlr_is_busy() to handle this.  When we have another path to
get to tcs_invalidate() it will also need to come up with something
similar and it won't need this extra check either.  If we later find
some code path that actually needs this check back in (and somehow
manages to be race free) we can always add it back in.

Signed-off-by: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Maulik Shah <mkshah@codeaurora.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Tested-by: Maulik Shah <mkshah@codeaurora.org>
Link: https://lore.kernel.org/r/20200413100321.v4.9.I07c1f70e0e8f2dc0004bd38970b4e258acdc773e@changeid
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-04-13 22:09:43 -07:00
..
Kconfig soc: qcom: Fix QCOM_APR dependencies 2020-03-16 15:07:19 -07:00
Makefile soc: qcom: Introduce Protection Domain Restart helpers 2020-03-14 22:38:42 -07:00
apr.c soc: qcom: apr: Add avs/audio tracking functionality 2020-03-14 22:38:50 -07:00
cmd-db.c soc: qcom: cmd-db: Add debugfs dumping file 2020-04-13 18:10:11 -07:00
glink_ssr.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284 2019-06-05 17:36:37 +02:00
llcc-qcom.c soc: qcom: llcc: Add configuration data for SC7180 2019-10-20 19:15:20 -07:00
mdt_loader.c remoteproc updates for v5.3 2019-07-17 11:44:41 -07:00
ocmem.c soc: qcom: add OCMEM driver 2019-10-07 08:17:33 -07:00
pdr_interface.c soc: qcom: pdr: Avoid uninitialized use of found in pdr_indication_cb 2020-03-16 14:56:57 -07:00
pdr_internal.h soc: qcom: Introduce Protection Domain Restart helpers 2020-03-14 22:38:42 -07:00
qcom-geni-se.c soc: qcom: geni: Provide parameter error checking 2019-09-06 11:08:08 +02:00
qcom_aoss.c soc: qcom: aoss: Read back before triggering the IRQ 2020-02-13 21:18:16 -08:00
qcom_gsbi.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 409 2019-06-05 17:37:14 +02:00
qmi_encdec.c soc: qcom: Introduce QMI encoder/decoder 2017-12-20 15:38:34 -06:00
qmi_interface.c soc: qcom: qmi: Return EPROBE_DEFER if no address family 2019-12-10 22:44:34 -08:00
rmtfs_mem.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284 2019-06-05 17:36:37 +02:00
rpmh-internal.h soc: qcom: rpmh-rsc: Caller handles tcs_invalidate() exclusivity 2020-04-13 22:09:43 -07:00
rpmh-rsc.c soc: qcom: rpmh-rsc: Caller handles tcs_invalidate() exclusivity 2020-04-13 22:09:43 -07:00
rpmh.c soc: qcom: rpmh-rsc: Caller handles tcs_invalidate() exclusivity 2020-04-13 22:09:43 -07:00
rpmhpd.c soc: qcom: rpmhpd: Set 'active_only' for active only power domains 2020-01-07 15:19:30 -08:00
rpmpd.c soc: qcom: rpmpd: Add rpm power domains for msm8976 2019-10-06 22:51:32 -07:00
smd-rpm.c soc: qcom: smd-rpm: Add MSM8976 compatible 2019-10-04 21:20:10 -07:00
smem.c soc: qcom: smem: Update max processor count 2019-08-21 15:58:01 -07:00
smem_state.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284 2019-06-05 17:36:37 +02:00
smp2p.c soc: qcom: smp2p: Delete an error message in qcom_smp2p_probe() 2020-04-13 18:10:12 -07:00
smsm.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284 2019-06-05 17:36:37 +02:00
socinfo.c soc: qcom: socinfo: add missing soc_id sysfs entry 2020-04-13 18:10:10 -07:00
spm.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284 2019-06-05 17:36:37 +02:00
trace-rpmh.h drivers: qcom: rpmh-rsc: log RPMH requests in FTRACE 2018-07-21 13:32:31 -05:00
wcnss_ctrl.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284 2019-06-05 17:36:37 +02:00