All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xingyu Chen <xingyu.chen@amlogic.com>
To: Guenter Roeck <linux@roeck-us.net>,
	Wim Van Sebroeck <wim@linux-watchdog.org>,
	Kevin Hilman <khilman@baylibre.com>,
	Neil Armstrong <narmstrong@baylibre.com>
Cc: Rob Herring <robh+dt@kernel.org>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Qianggui Song <qianggui.song@amlogic.com>,
	Jianxin Pan <jianxin.pan@amlogic.com>,
	Jian Hu <jian.hu@amlogic.com>, <linux-watchdog@vger.kernel.org>,
	<linux-amlogic@lists.infradead.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2 3/4] watchdog: add meson secure watchdog driver
Date: Tue, 22 Oct 2019 13:49:20 +0800	[thread overview]
Message-ID: <1b841195-cf76-7128-9569-5c2b0d39c1c1@amlogic.com> (raw)
In-Reply-To: <bd5ed275-4ae4-4163-b585-23fbead9833f@roeck-us.net>

Hi, Guenter

On 2019/10/21 21:38, Guenter Roeck wrote:
> On 10/21/19 1:03 AM, Xingyu Chen wrote:
>> Hi, Guenter
>>
>> On 2019/10/21 0:56, Guenter Roeck wrote:
>>> On 10/18/19 1:33 AM, Xingyu Chen wrote:
>>>> The watchdog controller on the Meson-A/C series SoCs is moved to secure
>>>> world, watchdog operation needs to be done in secure EL3 mode via ATF,
>>>> Non-secure world can call SMC instruction to trap to AFT for watchdog
>>>> operation.
>>>>
>>>> Signed-off-by: Xingyu Chen <xingyu.chen@amlogic.com>
>>>> ---
>>>>   drivers/watchdog/Kconfig         |  17 ++++
>>>>   drivers/watchdog/Makefile        |   1 +
>>>>   drivers/watchdog/meson_sec_wdt.c | 187 
>>>> +++++++++++++++++++++++++++++++++++++++
>>>>   3 files changed, 205 insertions(+)
>>>>   create mode 100644 drivers/watchdog/meson_sec_wdt.c
>>>>
>>>> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
>>>> index 58e7c10..e84be42 100644
>>>> --- a/drivers/watchdog/Kconfig
>>>> +++ b/drivers/watchdog/Kconfig
>>>> @@ -826,6 +826,23 @@ config MESON_GXBB_WATCHDOG
>>>>         To compile this driver as a module, choose M here: the
>>>>         module will be called meson_gxbb_wdt.
>>>> +config MESON_SEC_WATCHDOG
>>>> +    tristate "Amlogic Meson Secure watchdog support"
>>>> +    depends on MESON_SM
>>>> +    depends on ARCH_MESON || COMPILE_TEST
>>>
>>> This dependency is pointless. MESON_SM already depends on ARCH_MESON,
>>> thus specifying "COMPILE_TEST" here adds no value but only
>>> creates confusion.
>> Thanks for your analysis, perhaps i should remove the line below.
>> - depends on ARCH_MESON || COMPILE_TEST
>>
>> Is it ok to modify code above like this ?
> 
> Yes.
Thanks, fix it in next version.

> [ ... ]
> 
>>>> +static unsigned int meson_sec_wdt_get_timeleft(struct 
>>>> watchdog_device *wdt_dev)
>>>> +{
>>>> +    int ret;
>>>> +    unsigned int timeleft;
>>>> +    struct meson_sec_wdt *data = watchdog_get_drvdata(wdt_dev);
>>>> +
>>>> +    ret = meson_sm_call(data->fw, SM_WATCHDOG_OPS, Thanks&timeleft,
>>>> +                MESON_SIP_WDT_GETTIMELEFT, 0, 0, 0, 0);
>>>> +
>>>> +    if (ret)
>>>> +        return ret;
>>>
>>> Meh, that doesn't work. I just realized that the return type is 
>>> unsigned,
>>> so returning a negative error code is pointless. Guess we'll have to
>>> live with returning 0 in this case after all. I wonder if we should
>>> fix the API and return an integer (with negative error code), but that
>>> is a different question.
>> Thanks for your review.
>>
>> IMO, if returning an integer, and the value which copy to user buf 
>> should be formatted with %d instead of %u (see timeleft_show), it will 
>> cause the max value of timeleft is reduced from 4294967295 to 
>> 2147483647. but i'am not sure whether it will bring risk.
> 
> Not that it matters right now, but I don't think that limiting 'timeleft'
> reporting to 2147483647 seconds, or ~68 years, would cause any risk.
> It would just be a large patch changing several drivers all at once,
> that is all.
> 
>>
>> So i also think returning 0 may be better in this case.
> 
> Yes, please do that.
Thanks, fix it in next version.
> 
> Thanks,
> Guenter
> 
> .
> 

WARNING: multiple messages have this Message-ID (diff)
From: Xingyu Chen <xingyu.chen@amlogic.com>
To: Guenter Roeck <linux@roeck-us.net>,
	Wim Van Sebroeck <wim@linux-watchdog.org>,
	Kevin Hilman <khilman@baylibre.com>,
	Neil Armstrong <narmstrong@baylibre.com>
Cc: Qianggui Song <qianggui.song@amlogic.com>,
	linux-watchdog@vger.kernel.org,
	Jianxin Pan <jianxin.pan@amlogic.com>,
	linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	Jian Hu <jian.hu@amlogic.com>,
	linux-amlogic@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	Jerome Brunet <jbrunet@baylibre.com>
Subject: Re: [PATCH v2 3/4] watchdog: add meson secure watchdog driver
Date: Tue, 22 Oct 2019 13:49:20 +0800	[thread overview]
Message-ID: <1b841195-cf76-7128-9569-5c2b0d39c1c1@amlogic.com> (raw)
In-Reply-To: <bd5ed275-4ae4-4163-b585-23fbead9833f@roeck-us.net>

Hi, Guenter

On 2019/10/21 21:38, Guenter Roeck wrote:
> On 10/21/19 1:03 AM, Xingyu Chen wrote:
>> Hi, Guenter
>>
>> On 2019/10/21 0:56, Guenter Roeck wrote:
>>> On 10/18/19 1:33 AM, Xingyu Chen wrote:
>>>> The watchdog controller on the Meson-A/C series SoCs is moved to secure
>>>> world, watchdog operation needs to be done in secure EL3 mode via ATF,
>>>> Non-secure world can call SMC instruction to trap to AFT for watchdog
>>>> operation.
>>>>
>>>> Signed-off-by: Xingyu Chen <xingyu.chen@amlogic.com>
>>>> ---
>>>>   drivers/watchdog/Kconfig         |  17 ++++
>>>>   drivers/watchdog/Makefile        |   1 +
>>>>   drivers/watchdog/meson_sec_wdt.c | 187 
>>>> +++++++++++++++++++++++++++++++++++++++
>>>>   3 files changed, 205 insertions(+)
>>>>   create mode 100644 drivers/watchdog/meson_sec_wdt.c
>>>>
>>>> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
>>>> index 58e7c10..e84be42 100644
>>>> --- a/drivers/watchdog/Kconfig
>>>> +++ b/drivers/watchdog/Kconfig
>>>> @@ -826,6 +826,23 @@ config MESON_GXBB_WATCHDOG
>>>>         To compile this driver as a module, choose M here: the
>>>>         module will be called meson_gxbb_wdt.
>>>> +config MESON_SEC_WATCHDOG
>>>> +    tristate "Amlogic Meson Secure watchdog support"
>>>> +    depends on MESON_SM
>>>> +    depends on ARCH_MESON || COMPILE_TEST
>>>
>>> This dependency is pointless. MESON_SM already depends on ARCH_MESON,
>>> thus specifying "COMPILE_TEST" here adds no value but only
>>> creates confusion.
>> Thanks for your analysis, perhaps i should remove the line below.
>> - depends on ARCH_MESON || COMPILE_TEST
>>
>> Is it ok to modify code above like this ?
> 
> Yes.
Thanks, fix it in next version.

> [ ... ]
> 
>>>> +static unsigned int meson_sec_wdt_get_timeleft(struct 
>>>> watchdog_device *wdt_dev)
>>>> +{
>>>> +    int ret;
>>>> +    unsigned int timeleft;
>>>> +    struct meson_sec_wdt *data = watchdog_get_drvdata(wdt_dev);
>>>> +
>>>> +    ret = meson_sm_call(data->fw, SM_WATCHDOG_OPS, Thanks&timeleft,
>>>> +                MESON_SIP_WDT_GETTIMELEFT, 0, 0, 0, 0);
>>>> +
>>>> +    if (ret)
>>>> +        return ret;
>>>
>>> Meh, that doesn't work. I just realized that the return type is 
>>> unsigned,
>>> so returning a negative error code is pointless. Guess we'll have to
>>> live with returning 0 in this case after all. I wonder if we should
>>> fix the API and return an integer (with negative error code), but that
>>> is a different question.
>> Thanks for your review.
>>
>> IMO, if returning an integer, and the value which copy to user buf 
>> should be formatted with %d instead of %u (see timeleft_show), it will 
>> cause the max value of timeleft is reduced from 4294967295 to 
>> 2147483647. but i'am not sure whether it will bring risk.
> 
> Not that it matters right now, but I don't think that limiting 'timeleft'
> reporting to 2147483647 seconds, or ~68 years, would cause any risk.
> It would just be a large patch changing several drivers all at once,
> that is all.
> 
>>
>> So i also think returning 0 may be better in this case.
> 
> Yes, please do that.
Thanks, fix it in next version.
> 
> Thanks,
> Guenter
> 
> .
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

WARNING: multiple messages have this Message-ID (diff)
From: Xingyu Chen <xingyu.chen@amlogic.com>
To: Guenter Roeck <linux@roeck-us.net>,
	Wim Van Sebroeck <wim@linux-watchdog.org>,
	Kevin Hilman <khilman@baylibre.com>,
	Neil Armstrong <narmstrong@baylibre.com>
Cc: Qianggui Song <qianggui.song@amlogic.com>,
	linux-watchdog@vger.kernel.org,
	Jianxin Pan <jianxin.pan@amlogic.com>,
	linux-kernel@vger.kernel.org, Rob Herring <robh+dt@kernel.org>,
	Jian Hu <jian.hu@amlogic.com>,
	linux-amlogic@lists.infradead.org,
	linux-arm-kernel@lists.infradead.org,
	Jerome Brunet <jbrunet@baylibre.com>
Subject: Re: [PATCH v2 3/4] watchdog: add meson secure watchdog driver
Date: Tue, 22 Oct 2019 13:49:20 +0800	[thread overview]
Message-ID: <1b841195-cf76-7128-9569-5c2b0d39c1c1@amlogic.com> (raw)
In-Reply-To: <bd5ed275-4ae4-4163-b585-23fbead9833f@roeck-us.net>

Hi, Guenter

On 2019/10/21 21:38, Guenter Roeck wrote:
> On 10/21/19 1:03 AM, Xingyu Chen wrote:
>> Hi, Guenter
>>
>> On 2019/10/21 0:56, Guenter Roeck wrote:
>>> On 10/18/19 1:33 AM, Xingyu Chen wrote:
>>>> The watchdog controller on the Meson-A/C series SoCs is moved to secure
>>>> world, watchdog operation needs to be done in secure EL3 mode via ATF,
>>>> Non-secure world can call SMC instruction to trap to AFT for watchdog
>>>> operation.
>>>>
>>>> Signed-off-by: Xingyu Chen <xingyu.chen@amlogic.com>
>>>> ---
>>>>   drivers/watchdog/Kconfig         |  17 ++++
>>>>   drivers/watchdog/Makefile        |   1 +
>>>>   drivers/watchdog/meson_sec_wdt.c | 187 
>>>> +++++++++++++++++++++++++++++++++++++++
>>>>   3 files changed, 205 insertions(+)
>>>>   create mode 100644 drivers/watchdog/meson_sec_wdt.c
>>>>
>>>> diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
>>>> index 58e7c10..e84be42 100644
>>>> --- a/drivers/watchdog/Kconfig
>>>> +++ b/drivers/watchdog/Kconfig
>>>> @@ -826,6 +826,23 @@ config MESON_GXBB_WATCHDOG
>>>>         To compile this driver as a module, choose M here: the
>>>>         module will be called meson_gxbb_wdt.
>>>> +config MESON_SEC_WATCHDOG
>>>> +    tristate "Amlogic Meson Secure watchdog support"
>>>> +    depends on MESON_SM
>>>> +    depends on ARCH_MESON || COMPILE_TEST
>>>
>>> This dependency is pointless. MESON_SM already depends on ARCH_MESON,
>>> thus specifying "COMPILE_TEST" here adds no value but only
>>> creates confusion.
>> Thanks for your analysis, perhaps i should remove the line below.
>> - depends on ARCH_MESON || COMPILE_TEST
>>
>> Is it ok to modify code above like this ?
> 
> Yes.
Thanks, fix it in next version.

> [ ... ]
> 
>>>> +static unsigned int meson_sec_wdt_get_timeleft(struct 
>>>> watchdog_device *wdt_dev)
>>>> +{
>>>> +    int ret;
>>>> +    unsigned int timeleft;
>>>> +    struct meson_sec_wdt *data = watchdog_get_drvdata(wdt_dev);
>>>> +
>>>> +    ret = meson_sm_call(data->fw, SM_WATCHDOG_OPS, Thanks&timeleft,
>>>> +                MESON_SIP_WDT_GETTIMELEFT, 0, 0, 0, 0);
>>>> +
>>>> +    if (ret)
>>>> +        return ret;
>>>
>>> Meh, that doesn't work. I just realized that the return type is 
>>> unsigned,
>>> so returning a negative error code is pointless. Guess we'll have to
>>> live with returning 0 in this case after all. I wonder if we should
>>> fix the API and return an integer (with negative error code), but that
>>> is a different question.
>> Thanks for your review.
>>
>> IMO, if returning an integer, and the value which copy to user buf 
>> should be formatted with %d instead of %u (see timeleft_show), it will 
>> cause the max value of timeleft is reduced from 4294967295 to 
>> 2147483647. but i'am not sure whether it will bring risk.
> 
> Not that it matters right now, but I don't think that limiting 'timeleft'
> reporting to 2147483647 seconds, or ~68 years, would cause any risk.
> It would just be a large patch changing several drivers all at once,
> that is all.
> 
>>
>> So i also think returning 0 may be better in this case.
> 
> Yes, please do that.
Thanks, fix it in next version.
> 
> Thanks,
> Guenter
> 
> .
> 

_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

  reply	other threads:[~2019-10-22  5:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18  8:33 [PATCH v2 0/4] add meson secure watchdog driver Xingyu Chen
2019-10-18  8:33 ` Xingyu Chen
2019-10-18  8:33 ` Xingyu Chen
2019-10-18  8:33 ` [PATCH v2 1/4] firmware: meson_sm: add new SMC ID support for accessing secure watchdog Xingyu Chen
2019-10-18  8:33   ` Xingyu Chen
2019-10-18  8:33   ` Xingyu Chen
2019-10-18  8:33 ` [PATCH v2 2/4] dt-bindings: watchdog: add new binding for meson " Xingyu Chen
2019-10-18  8:33   ` Xingyu Chen
2019-10-18  8:33   ` Xingyu Chen
2019-10-18  8:33 ` [PATCH v2 3/4] watchdog: add meson secure watchdog driver Xingyu Chen
2019-10-18  8:33   ` Xingyu Chen
2019-10-18  8:33   ` Xingyu Chen
2019-10-20 16:56   ` Guenter Roeck
2019-10-20 16:56     ` Guenter Roeck
2019-10-20 16:56     ` Guenter Roeck
2019-10-21  8:03     ` Xingyu Chen
2019-10-21  8:03       ` Xingyu Chen
2019-10-21  8:03       ` Xingyu Chen
2019-10-21 13:38       ` Guenter Roeck
2019-10-21 13:38         ` Guenter Roeck
2019-10-21 13:38         ` Guenter Roeck
2019-10-22  5:49         ` Xingyu Chen [this message]
2019-10-22  5:49           ` Xingyu Chen
2019-10-22  5:49           ` Xingyu Chen
2019-10-18  8:33 ` [PATCH v2 4/4] arm64: dts: a1: add secure watchdog controller Xingyu Chen
2019-10-18  8:33   ` Xingyu Chen
2019-10-18  8:33   ` Xingyu Chen

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=1b841195-cf76-7128-9569-5c2b0d39c1c1@amlogic.com \
    --to=xingyu.chen@amlogic.com \
    --cc=jbrunet@baylibre.com \
    --cc=jian.hu@amlogic.com \
    --cc=jianxin.pan@amlogic.com \
    --cc=khilman@baylibre.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-watchdog@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=narmstrong@baylibre.com \
    --cc=qianggui.song@amlogic.com \
    --cc=robh+dt@kernel.org \
    --cc=wim@linux-watchdog.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.