kernel_optimize_test/drivers/interconnect/qcom
Stephen Boyd bcae8f8338 interconnect: qcom: sc7180: Drop IP0 interconnects
commit 2f3724930eb4bba74f7d10bc3bef5bb22dd323df upstream.

The IPA BCM resource ("IP0") on sc7180 was moved to the clk-rpmh driver
in commit bcd63d222b ("clk: qcom: rpmh: Add IPA clock for SC7180") and
modeled as a clk, but this interconnect driver still had it modeled as
an interconnect. This was mostly OK because nobody used the interconnect
definition, until the interconnect framework started dropping bandwidth
requests on interconnects that aren't used via the sync_state callback
in commit 7d3b0b0d81 ("interconnect: qcom: Use icc_sync_state"). Once
that patch was applied the IP0 resource was going to be controlled from
two places, the clk framework and the interconnect framework.

Even then, things were probably going to be OK, because commit
b95b668eaaa2 ("interconnect: qcom: icc-rpmh: Add BCMs to commit list in
pre_aggregate") was needed to actually drop bandwidth requests on unused
interconnects, of which the IPA was one of the interconnect that wasn't
getting dropped to zero. Combining the three commits together leads to
bad behavior where the interconnect framework is disabling the IP0
resource because it has no users while the clk framework thinks the IP0
resource is on because the only user, the IPA driver, has turned it on
via clk_prepare_enable(). Depending on when sync_state is called, we can
get into a situation like below:

  IPA driver probes
  IPA driver gets notified modem started
   runtime PM get()
    IPA clk enabled -> IP0 resource is ON
  sync_state runs
   interconnect zeroes out the IP0 resource -> IP0 resource is off
  IPA driver tries to access a register and blows up

The crash is an unclocked access that manifest as an SError.

 SError Interrupt on CPU0, code 0xbe000011 -- SError
 CPU: 0 PID: 3595 Comm: mmdata_mgr Not tainted 5.17.1+ #166
 Hardware name: Google Lazor (rev1 - 2) with LTE (DT)
 pstate: 60400009 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
 pc : mutex_lock+0x4c/0x80
 lr : mutex_lock+0x30/0x80
 sp : ffffffc00da9b9c0
 x29: ffffffc00da9b9c0 x28: 0000000000000000 x27: 0000000000000000
 x26: ffffffc00da9bc90 x25: ffffff80c2024010 x24: ffffff80c2024000
 x23: ffffff8083100000 x22: ffffff80831000d0 x21: ffffff80831000a8
 x20: ffffff80831000a8 x19: ffffff8083100070 x18: 00000000ffff0a00
 x17: 000000002f7254f1 x16: 0000000000000100 x15: 0000000000000000
 x14: 0000000000000000 x13: 0000000000000000 x12: 0000000000000000
 x11: 000000000001f0b8 x10: ffffffc00931f0b8 x9 : 0000000000000000
 x8 : 0000000000000000 x7 : fefefefefeff2f60 x6 : 0000808080808080
 x5 : 0000000000000000 x4 : 8080808080800000 x3 : ffffff80d2d4ee28
 x2 : ffffff808c1d6e40 x1 : 0000000000000000 x0 : ffffff8083100070
 Kernel panic - not syncing: Asynchronous SError Interrupt
 CPU: 0 PID: 3595 Comm: mmdata_mgr Not tainted 5.17.1+ #166
 Hardware name: Google Lazor (rev1 - 2) with LTE (DT)
 Call trace:
  dump_backtrace+0xf4/0x114
  show_stack+0x24/0x30
  dump_stack_lvl+0x64/0x7c
  dump_stack+0x18/0x38
  panic+0x150/0x38c
  nmi_panic+0x88/0xa0
  arm64_serror_panic+0x74/0x80
  do_serror+0x0/0x80
  do_serror+0x58/0x80
  el1h_64_error_handler+0x34/0x4c
  el1h_64_error+0x78/0x7c
  mutex_lock+0x4c/0x80
  __gsi_channel_start+0x50/0x17c
  gsi_channel_start+0x54/0x90
  ipa_endpoint_enable_one+0x34/0xc0
  ipa_open+0x4c/0x120

Remove all IP0 resource management from the interconnect driver so that
clk-rpmh is the sole owner. This fixes the issue by preventing the
interconnect driver from overwriting the IP0 resource data that the
clk-rpmh driver wrote.

Cc: Alex Elder <elder@linaro.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Taniya Das <quic_tdas@quicinc.com>
Cc: Mike Tipton <quic_mdtipton@quicinc.com>
Cc: <stable@vger.kernel.org>	# 5.10.x
Fixes: b95b668eaaa2 ("interconnect: qcom: icc-rpmh: Add BCMs to commit list in pre_aggregate")
Fixes: bcd63d222b ("clk: qcom: rpmh: Add IPA clock for SC7180")
Fixes: 7d3b0b0d81 ("interconnect: qcom: Use icc_sync_state")
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Tested-by: Alex Elder <elder@linaro.org>
Reviewed-by: Alex Elder <elder@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Link: https://lore.kernel.org/r/20220412220033.1273607-2-swboyd@chromium.org
Signed-off-by: Georgi Djakov <djakov@kernel.org>
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-14 18:32:47 +02:00
..
bcm-voter.c treewide: Change list_sort to use const pointers 2021-09-30 10:11:04 +02:00
bcm-voter.h interconnect: qcom: Consolidate interconnect RPMh support 2020-02-28 12:11:40 +02:00
icc-rpmh.c interconnect: qcom: icc-rpmh: Ensure floor BW is enforced for all nodes 2021-08-12 13:22:18 +02:00
icc-rpmh.h interconnect: qcom: Implement xlate_extended() to parse tags 2020-09-08 16:29:00 +03:00
Kconfig interconnect: qcom: fix rpmh link failures 2021-01-17 14:17:01 +01:00
Makefile interconnect: qcom: Add SM8250 interconnect provider driver 2020-09-08 16:28:53 +03:00
msm8916.c interconnect: qcom: msm8916: Remove rpm-ids from non-RPM nodes 2020-11-20 15:51:51 +02:00
msm8974.c interconnect: qcom: msm8974: Don't boost the NoC rate during boot 2020-11-18 00:21:47 +02:00
osm-l3.c Merge branch 'icc-syncstate' into icc-next 2020-09-18 09:13:40 +03:00
qcs404.c interconnect: qcom: qcs404: Remove GPU and display RPM IDs 2020-11-20 15:52:05 +02:00
sc7180.c interconnect: qcom: sc7180: Drop IP0 interconnects 2022-06-14 18:32:47 +02:00
sc7180.h interconnect: qcom: Add OSM L3 support on SC7180 2020-03-03 19:02:52 +02:00
sdm845.c interconnect: qcom: sdm845: Init BCMs before creating the nodes 2020-10-15 09:24:00 +03:00
sdm845.h interconnect: qcom: Add OSM L3 interconnect provider support 2020-03-03 19:02:52 +02:00
sm8150.c interconnect: qcom: use icc_sync state for sm8[12]50 2020-10-27 16:01:22 +02:00
sm8150.h interconnect: qcom: Add OSM L3 support on SM8150 2020-09-08 16:29:01 +03:00
sm8250.c interconnect: qcom: use icc_sync state for sm8[12]50 2020-10-27 16:01:22 +02:00
sm8250.h interconnect: qcom: Add EPSS L3 support on SM8250 2020-09-08 16:29:01 +03:00
smd-rpm.c interconnect: qcom: Add interconnect RPM over SMD driver 2019-08-13 23:06:40 +03:00
smd-rpm.h interconnect: qcom: Add interconnect RPM over SMD driver 2019-08-13 23:06:40 +03:00