diff mbox

[3/4] venus: add check to make scm calls

Message ID 1526556740-25494-4-git-send-email-vgarodia@codeaurora.org (mailing list archive)
State Not Applicable, archived
Delegated to: Andy Gross
Headers show

Commit Message

Vikash Garodia May 17, 2018, 11:32 a.m. UTC
In order to invoke scm calls, ensure that the platform
has the required support to invoke the scm calls in
secure world. This code is in preparation to add PIL
functionality in venus driver.

Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
---
 drivers/media/platform/qcom/venus/hfi_venus.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

Comments

Stanimir Varbanov May 22, 2018, 1:04 p.m. UTC | #1
Hi Vikash,

On 05/17/2018 02:32 PM, Vikash Garodia wrote:
> In order to invoke scm calls, ensure that the platform
> has the required support to invoke the scm calls in
> secure world. This code is in preparation to add PIL
> functionality in venus driver.
> 
> Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
> ---
>  drivers/media/platform/qcom/venus/hfi_venus.c | 26 +++++++++++++++++++-------
>  1 file changed, 19 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
> index f61d34b..9bcce94 100644
> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
> @@ -27,6 +27,7 @@
>  #include "hfi_msgs.h"
>  #include "hfi_venus.h"
>  #include "hfi_venus_io.h"
> +#include "firmware.h"
>  
>  #define HFI_MASK_QHDR_TX_TYPE		0xff000000
>  #define HFI_MASK_QHDR_RX_TYPE		0x00ff0000
> @@ -570,13 +571,19 @@ static int venus_halt_axi(struct venus_hfi_device *hdev)
>  static int venus_power_off(struct venus_hfi_device *hdev)
>  {
>  	int ret;
> +	void __iomem *reg_base;
>  
>  	if (!hdev->power_enabled)
>  		return 0;
>  
> -	ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
> -	if (ret)
> -		return ret;
> +	if (qcom_scm_is_available()) {
> +		ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);

I think it will be clearer if we abstract qcom_scm_set_remote_state to
something like venus_set_state(SUSPEND|RESUME) in firmware.c and export
the functions to be used here.
Jordan Crouse May 22, 2018, 7:50 p.m. UTC | #2
On Tue, May 22, 2018 at 04:04:51PM +0300, Stanimir Varbanov wrote:
> Hi Vikash,
> 
> On 05/17/2018 02:32 PM, Vikash Garodia wrote:
> > In order to invoke scm calls, ensure that the platform
> > has the required support to invoke the scm calls in
> > secure world. This code is in preparation to add PIL
> > functionality in venus driver.
> > 
> > Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
> > ---
> >  drivers/media/platform/qcom/venus/hfi_venus.c | 26 +++++++++++++++++++-------
> >  1 file changed, 19 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
> > index f61d34b..9bcce94 100644
> > --- a/drivers/media/platform/qcom/venus/hfi_venus.c
> > +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
> > @@ -27,6 +27,7 @@
> >  #include "hfi_msgs.h"
> >  #include "hfi_venus.h"
> >  #include "hfi_venus_io.h"
> > +#include "firmware.h"
> >  
> >  #define HFI_MASK_QHDR_TX_TYPE		0xff000000
> >  #define HFI_MASK_QHDR_RX_TYPE		0x00ff0000
> > @@ -570,13 +571,19 @@ static int venus_halt_axi(struct venus_hfi_device *hdev)
> >  static int venus_power_off(struct venus_hfi_device *hdev)
> >  {
> >  	int ret;
> > +	void __iomem *reg_base;
> >  
> >  	if (!hdev->power_enabled)
> >  		return 0;
> >  
> > -	ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
> > -	if (ret)
> > -		return ret;
> > +	if (qcom_scm_is_available()) {
> > +		ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
> 
> I think it will be clearer if we abstract qcom_scm_set_remote_state to
> something like venus_set_state(SUSPEND|RESUME) in firmware.c and export
> the functions to be used here.

This specific function is a little odd because the SCM function got overloaded
and used as a hardware workaround for the adreno a5xx zap shader.

When we added it for the GPU we knew the day would come that we would need it
for Venus so we kept the name purposely generic. You can wrap if if you want
but just know that there are other non video entities out there using it.

Jordan
Stanimir Varbanov May 22, 2018, 8:57 p.m. UTC | #3
Hi Jordan,

On 22.05.2018 22:50, Jordan Crouse wrote:
> On Tue, May 22, 2018 at 04:04:51PM +0300, Stanimir Varbanov wrote:
>> Hi Vikash,
>>
>> On 05/17/2018 02:32 PM, Vikash Garodia wrote:
>>> In order to invoke scm calls, ensure that the platform
>>> has the required support to invoke the scm calls in
>>> secure world. This code is in preparation to add PIL
>>> functionality in venus driver.
>>>
>>> Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
>>> ---
>>>   drivers/media/platform/qcom/venus/hfi_venus.c | 26 +++++++++++++++++++-------
>>>   1 file changed, 19 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
>>> index f61d34b..9bcce94 100644
>>> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
>>> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
>>> @@ -27,6 +27,7 @@
>>>   #include "hfi_msgs.h"
>>>   #include "hfi_venus.h"
>>>   #include "hfi_venus_io.h"
>>> +#include "firmware.h"
>>>   
>>>   #define HFI_MASK_QHDR_TX_TYPE		0xff000000
>>>   #define HFI_MASK_QHDR_RX_TYPE		0x00ff0000
>>> @@ -570,13 +571,19 @@ static int venus_halt_axi(struct venus_hfi_device *hdev)
>>>   static int venus_power_off(struct venus_hfi_device *hdev)
>>>   {
>>>   	int ret;
>>> +	void __iomem *reg_base;
>>>   
>>>   	if (!hdev->power_enabled)
>>>   		return 0;
>>>   
>>> -	ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
>>> -	if (ret)
>>> -		return ret;
>>> +	if (qcom_scm_is_available()) {
>>> +		ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
>>
>> I think it will be clearer if we abstract qcom_scm_set_remote_state to
>> something like venus_set_state(SUSPEND|RESUME) in firmware.c and export
>> the functions to be used here.
> 
> This specific function is a little odd because the SCM function got overloaded
> and used as a hardware workaround for the adreno a5xx zap shader.
> 
> When we added it for the GPU we knew the day would come that we would need it
> for Venus so we kept the name purposely generic. You can wrap if if you want
> but just know that there are other non video entities out there using it.

Sorry I wasn't clear, by abstract it I meant to introduce a new 
venus_set_state function in venus/firmware.c where we'll select 
tz/non-tz functions for suspend / resume depending on the configuration.

regards,
Stan
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Vikash Garodia May 23, 2018, 5:30 a.m. UTC | #4
Hi Stan,

On 2018-05-23 02:27, Stanimir Varbanov wrote:
> Hi Jordan,
> 
> On 22.05.2018 22:50, Jordan Crouse wrote:
>> On Tue, May 22, 2018 at 04:04:51PM +0300, Stanimir Varbanov wrote:
>>> Hi Vikash,
>>> 
>>> On 05/17/2018 02:32 PM, Vikash Garodia wrote:
>>>> In order to invoke scm calls, ensure that the platform
>>>> has the required support to invoke the scm calls in
>>>> secure world. This code is in preparation to add PIL
>>>> functionality in venus driver.
>>>> 
>>>> Signed-off-by: Vikash Garodia <vgarodia@codeaurora.org>
>>>> ---
>>>>   drivers/media/platform/qcom/venus/hfi_venus.c | 26 
>>>> +++++++++++++++++++-------
>>>>   1 file changed, 19 insertions(+), 7 deletions(-)
>>>> 
>>>> diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c 
>>>> b/drivers/media/platform/qcom/venus/hfi_venus.c
>>>> index f61d34b..9bcce94 100644
>>>> --- a/drivers/media/platform/qcom/venus/hfi_venus.c
>>>> +++ b/drivers/media/platform/qcom/venus/hfi_venus.c
>>>> @@ -27,6 +27,7 @@
>>>>   #include "hfi_msgs.h"
>>>>   #include "hfi_venus.h"
>>>>   #include "hfi_venus_io.h"
>>>> +#include "firmware.h"
>>>>     #define HFI_MASK_QHDR_TX_TYPE		0xff000000
>>>>   #define HFI_MASK_QHDR_RX_TYPE		0x00ff0000
>>>> @@ -570,13 +571,19 @@ static int venus_halt_axi(struct 
>>>> venus_hfi_device *hdev)
>>>>   static int venus_power_off(struct venus_hfi_device *hdev)
>>>>   {
>>>>   	int ret;
>>>> +	void __iomem *reg_base;
>>>>     	if (!hdev->power_enabled)
>>>>   		return 0;
>>>>   -	ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
>>>> -	if (ret)
>>>> -		return ret;
>>>> +	if (qcom_scm_is_available()) {
>>>> +		ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
>>> 
>>> I think it will be clearer if we abstract qcom_scm_set_remote_state 
>>> to
>>> something like venus_set_state(SUSPEND|RESUME) in firmware.c and 
>>> export
>>> the functions to be used here.
>> 
>> This specific function is a little odd because the SCM function got 
>> overloaded
>> and used as a hardware workaround for the adreno a5xx zap shader.
>> 
>> When we added it for the GPU we knew the day would come that we would 
>> need it
>> for Venus so we kept the name purposely generic. You can wrap if if 
>> you want
>> but just know that there are other non video entities out there using 
>> it.
> 
> Sorry I wasn't clear, by abstract it I meant to introduce a new
> venus_set_state function in venus/firmware.c where we'll select
> tz/non-tz functions for suspend / resume depending on the
> configuration.

Yes, that's a good idea to abstract the decision to use tz or non-tz way 
as much
as possible to firmware.c. Will add this in my next patch.

> regards,
> Stan
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/media/platform/qcom/venus/hfi_venus.c b/drivers/media/platform/qcom/venus/hfi_venus.c
index f61d34b..9bcce94 100644
--- a/drivers/media/platform/qcom/venus/hfi_venus.c
+++ b/drivers/media/platform/qcom/venus/hfi_venus.c
@@ -27,6 +27,7 @@ 
 #include "hfi_msgs.h"
 #include "hfi_venus.h"
 #include "hfi_venus_io.h"
+#include "firmware.h"
 
 #define HFI_MASK_QHDR_TX_TYPE		0xff000000
 #define HFI_MASK_QHDR_RX_TYPE		0x00ff0000
@@ -570,13 +571,19 @@  static int venus_halt_axi(struct venus_hfi_device *hdev)
 static int venus_power_off(struct venus_hfi_device *hdev)
 {
 	int ret;
+	void __iomem *reg_base;
 
 	if (!hdev->power_enabled)
 		return 0;
 
-	ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
-	if (ret)
-		return ret;
+	if (qcom_scm_is_available()) {
+		ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
+		if (ret)
+			return ret;
+	} else {
+		reg_base = hdev->core->base;
+		writel_relaxed(1, reg_base + WRAPPER_A9SS_SW_RESET);
+	}
 
 	ret = venus_halt_axi(hdev);
 	if (ret)
@@ -594,9 +601,13 @@  static int venus_power_on(struct venus_hfi_device *hdev)
 	if (hdev->power_enabled)
 		return 0;
 
-	ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_RESUME, 0);
-	if (ret)
-		goto err;
+	if (qcom_scm_is_available()) {
+		ret = qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_RESUME, 0);
+		if (ret)
+			goto err;
+	} else {
+		venus_reset_hw(hdev->core);
+	}
 
 	ret = venus_run(hdev);
 	if (ret)
@@ -607,7 +618,8 @@  static int venus_power_on(struct venus_hfi_device *hdev)
 	return 0;
 
 err_suspend:
-	qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
+	if (qcom_scm_is_available())
+		qcom_scm_set_remote_state(TZBSP_VIDEO_STATE_SUSPEND, 0);
 err:
 	hdev->power_enabled = false;
 	return ret;