Commit 795a6ee
committed
firmware: qcom: scm: Fix missing read barrier in qcom_scm_is_available()
JIRA: https://issues.redhat.com/browse/RHEL-117514
commit 0a744cc
Author: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Date: Mon Dec 9 15:27:54 2024 +0100
firmware: qcom: scm: Fix missing read barrier in qcom_scm_is_available()
Commit 2e49551 ("firmware: qcom: scm: Fix __scm and waitq
completion variable initialization") introduced a write barrier in probe
function to store global '__scm' variable. It also claimed that it
added a read barrier, because as we all known barriers are paired (see
memory-barriers.txt: "Note that write barriers should normally be paired
with read or address-dependency barriers"), however it did not really
add it.
The offending commit used READ_ONCE() to access '__scm' global which is
not a barrier.
The barrier is needed so the store to '__scm' will be properly visible.
This is most likely not fatal in current driver design, because missing
read barrier would mean qcom_scm_is_available() callers will access old
value, NULL. Driver does not support unbinding and does not correctly
handle probe failures, thus there is no risk of stale or old pointer in
'__scm' variable.
However for code correctness, readability and to be sure that we did not
mess up something in this tricky topic of SMP barriers, add a read
barrier for accessing '__scm'. Change also comment from useless/obvious
what does barrier do, to what is expected: which other parts of the code
are involved here.
Fixes: 2e49551 ("firmware: qcom: scm: Fix __scm and waitq completion variable initialization")
Cc: stable@vger.kernel.org
Reviewed-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Link: https://lore.kernel.org/r/20241209-qcom-scm-missing-barriers-and-all-sort-of-srap-v2-1-9061013c8d92@linaro.org
Signed-off-by: Bjorn Andersson <andersson@kernel.org>
Signed-off-by: Eric Chanudet <echanude@redhat.com>1 parent 8518493 commit 795a6ee
1 file changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1872 | 1872 | | |
1873 | 1873 | | |
1874 | 1874 | | |
1875 | | - | |
| 1875 | + | |
| 1876 | + | |
1876 | 1877 | | |
1877 | 1878 | | |
1878 | 1879 | | |
| |||
2029 | 2030 | | |
2030 | 2031 | | |
2031 | 2032 | | |
2032 | | - | |
| 2033 | + | |
2033 | 2034 | | |
2034 | 2035 | | |
2035 | 2036 | | |
| |||
0 commit comments