From: Kuldeep Singh <quic_kuldsing@quicinc.com>
To: Bjorn Andersson <andersson@kernel.org>
Cc: Konrad Dybcio <konradybcio@kernel.org>,
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
<linux-arm-msm@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
Qingqing Zhou <quic_qqzhou@quicinc.com>
Subject: Re: [PATCH 1/2] firmware: qcom: scm: Return -EOPNOTSUPP for unsupported SHM bridge enabling
Date: Tue, 8 Oct 2024 02:10:02 +0530 [thread overview]
Message-ID: <87f778cf-0e1e-4505-a0e8-7434316a9537@quicinc.com> (raw)
In-Reply-To: <mgdj5xvqby3ftnnhma7dxvxskavx4p2pkzyorg4z3cza5xkimr@sqe4k2szwfbq>
On 10/7/2024 7:10 AM, Bjorn Andersson wrote:
> On Sat, Oct 05, 2024 at 07:31:49PM GMT, Kuldeep Singh wrote:
>
> Please shorten the subject a bit, perhaps:
> "firmware: qcom: scm: Improve unsupported SHM bridge detection"
>
>> From: Qingqing Zhou <quic_qqzhou@quicinc.com>
>>
>> Currently for enabling shm bridge, QTEE will return 0 and put error 4 into
>
> s/for/when/
Ack.
>
>> result[0] to qcom_scm for unsupported platform, tzmem will consider this
>> as an unknown error not the unsupported case on the platform.
>>
>> Error log:
>> [ 0.177224] qcom_scm firmware:scm: error (____ptrval____): Failed to enable the TrustZone memory allocator
>> [ 0.177244] qcom_scm firmware:scm: probe with driver qcom_scm failed with error 4
>>
>> Change the function call qcom_scm_shm_bridge_enable() to remap this
>> result[0] into the unsupported error and then tzmem can consider this as
>> unsupported case instead of reporting an error.
>>
>
> Sounds like we want a Fixes tag here.
Ack.
>
>> Signed-off-by: Qingqing Zhou <quic_qqzhou@quicinc.com>
>> Co-developed-by: Kuldeep Singh <quic_kuldsing@quicinc.com>
>> Signed-off-by: Kuldeep Singh <quic_kuldsing@quicinc.com>
>> ---
>> drivers/firmware/qcom/qcom_scm.c | 12 +++++++++++-
>> 1 file changed, 11 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
>> index 10986cb11ec0..620313359042 100644
>> --- a/drivers/firmware/qcom/qcom_scm.c
>> +++ b/drivers/firmware/qcom/qcom_scm.c
>> @@ -111,6 +111,10 @@ enum qcom_scm_qseecom_tz_cmd_info {
>> QSEECOM_TZ_CMD_INFO_VERSION = 3,
>> };
>>
>> +enum qcom_scm_shm_bridge_result {
>> + SHMBRIDGE_RESULT_NOTSUPP = 4,
>> +};
>
> This is not an enumeration, but a fixed defined constant. Please use
> #define.
Ack.
>> +
>> #define QSEECOM_MAX_APP_NAME_SIZE 64
>>
>> /* Each bit configures cold/warm boot address for one of the 4 CPUs */
>> @@ -1361,6 +1365,8 @@ EXPORT_SYMBOL_GPL(qcom_scm_lmh_dcvsh_available);
>>
>> int qcom_scm_shm_bridge_enable(void)
>> {
>> + int ret;
>> +
>> struct qcom_scm_desc desc = {
>> .svc = QCOM_SCM_SVC_MP,
>> .cmd = QCOM_SCM_MP_SHM_BRIDGE_ENABLE,
>> @@ -1373,7 +1379,11 @@ int qcom_scm_shm_bridge_enable(void)
>> QCOM_SCM_MP_SHM_BRIDGE_ENABLE))
>> return -EOPNOTSUPP;
>>
>> - return qcom_scm_call(__scm->dev, &desc, &res) ?: res.result[0];
>> + ret = qcom_scm_call(__scm->dev, &desc, &res);
>> + if (!ret && res.result[0] == SHMBRIDGE_RESULT_NOTSUPP)
>> + return -EOPNOTSUPP;
>> +
>> + return ret ?: res.result[0];
>
> I'd prefer, with the additional check, that you'd structure it like this:
>
> if (ret)
> return ret;
>
> if (res.result[0] == SHMBRIDGE_RESULT_NOTSUPP)
> return -EOPNOTSUPP;
>
> return res.result[0];
Sure, above looks more cleaner. Will update in next rev.
>
> That way we deal with SCM-call errors first, otherwise we inspect and
> act on the returned data.
>
> That said, the return value of this function, if non-zero, will trickle
> back to and be returned from qcom_scm_probe(), where Linux expects to
> see a valid error code. Are there any other result[0] values we should
> handle, which would allow us to end this function with "return 0"?
As qcom_scm_shm_bridge_enable() is an shm enablement call, need to handle
supported(or unsupported) scenario appropriately and other errors can be
propagated to qcom_tzmem/qcom_scm_probe.
Please note, other return values(related to access control) from QTEE are
failures and do not require conversion to Linux error codes.
--
Regards
Kuldeep
next prev parent reply other threads:[~2024-10-07 20:40 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-05 14:01 [PATCH 0/2] qcom_tzmem: Enhance Error Handling for shmbridge Kuldeep Singh
2024-10-05 14:01 ` [PATCH 1/2] firmware: qcom: scm: Return -EOPNOTSUPP for unsupported SHM bridge enabling Kuldeep Singh
2024-10-06 17:35 ` Dmitry Baryshkov
2024-10-06 22:01 ` Kuldeep Singh
2024-10-07 18:11 ` Mukesh Ojha
2024-10-07 1:40 ` Bjorn Andersson
2024-10-07 20:40 ` Kuldeep Singh [this message]
2024-10-07 21:45 ` Bjorn Andersson
2024-10-05 14:01 ` [PATCH 2/2] firmware: qcom: qcom_tzmem: Implement sanity checks Kuldeep Singh
2024-10-06 19:30 ` Dmitry Baryshkov
2024-10-07 19:17 ` Kuldeep Singh
2024-10-07 20:13 ` Dmitry Baryshkov
2024-10-07 20:44 ` Kuldeep Singh
2024-10-07 20:56 ` Bartosz Golaszewski
2024-10-07 1:18 ` Bjorn Andersson
2024-10-07 14:23 ` Bartosz Golaszewski
2024-10-07 19:23 ` Kuldeep Singh
2024-10-07 14:25 ` [PATCH 0/2] qcom_tzmem: Enhance Error Handling for shmbridge Bartosz Golaszewski
2024-10-07 19:35 ` Kuldeep Singh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87f778cf-0e1e-4505-a0e8-7434316a9537@quicinc.com \
--to=quic_kuldsing@quicinc.com \
--cc=andersson@kernel.org \
--cc=bartosz.golaszewski@linaro.org \
--cc=konradybcio@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quic_qqzhou@quicinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®