firmware: qcom_scm: Reduce locking section for __get_convention()
authorStephen Boyd <swboyd@chromium.org>
Tue, 23 Feb 2021 21:45:35 +0000 (13:45 -0800)
committerBjorn Andersson <bjorn.andersson@linaro.org>
Wed, 7 Apr 2021 02:25:23 +0000 (21:25 -0500)
commitf6ea568f0ddcdfad52807110ed8983e610f0e03b
tree7dfa9dccdbb2e586536b293d97d2ff35502e9591
parent9d11af8b06a811c5c4878625f51ce109e2af4e80
firmware: qcom_scm: Reduce locking section for __get_convention()

We shouldn't need to hold this spinlock here around the entire SCM call
into the firmware and back. Instead, we should be able to query the
firmware, potentially in parallel with other CPUs making the same
convention detection firmware call, and then grab the lock to update the
calling convention detected. The convention doesn't change at runtime so
calling into firmware more than once is possibly wasteful but simpler.
Besides, this is the slow path, not the fast path where we've already
detected the convention used.

More importantly, this allows us to add more logic here to workaround
the case where the firmware call to check for availability isn't
implemented in the firmware at all. In that case we can check the
firmware node compatible string and force a calling convention.

Note that we remove the 'has_queried' logic that is repeated twice. That
could lead to the calling convention being printed multiple times to the
kernel logs if the bool is true but __query_convention() is running on
multiple CPUs. We also shorten the time where the lock is held, but we
keep the lock held around the printk because it doesn't seem hugely
important to drop it for that.

Cc: Elliot Berman <eberman@codeaurora.org>
Cc: Brian Masney <masneyb@onstation.org>
Cc: Stephan Gerhold <stephan@gerhold.net>
Cc: Jeffrey Hugo <jhugo@codeaurora.org>
Cc: Douglas Anderson <dianders@chromium.org>
Fixes: 9a434cee773a ("firmware: qcom_scm: Dynamically support SMCCC and legacy conventions")
Signed-off-by: Stephen Boyd <swboyd@chromium.org>
Link: https://lore.kernel.org/r/20210223214539.1336155-3-swboyd@chromium.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
drivers/firmware/qcom_scm-smc.c
drivers/firmware/qcom_scm.c
drivers/firmware/qcom_scm.h