All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Wang <peter.wang@mediatek.com>
To: Arnd Bergmann <arnd@kernel.org>,
	Stanley Chu <stanley.chu@mediatek.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	"Avri Altman" <avri.altman@wdc.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	"Bean Huo" <beanhuo@micron.com>,
	Bart Van Assche <bvanassche@acm.org>,
	<linux-scsi@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] scsi: ufs: mediatek: avoid sched_clock() misuse
Date: Thu, 21 Oct 2021 11:18:25 +0800	[thread overview]
Message-ID: <0c5b8562d49c7e81323b8a34a42385440f33f798.camel@mediatek.com> (raw)
In-Reply-To: <20211018132022.2281589-1-arnd@kernel.org>

On Mon, 2021-10-18 at 15:20 +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> sched_clock() is not meant to be used in portable driver code,
> and assuming a particular clock frequency is not how this is
> meant to be used. It also causes a build failure because of
> a missing header inclusion:
> 
> drivers/scsi/ufs/ufs-mediatek.c:321:12: error: implicit declaration
> of function 'sched_clock' [-Werror,-Wimplicit-function-declaration]
>         timeout = sched_clock() + retry_ms * 1000000UL;
> 
> A better interface to use here ktime_get_mono_fast_ns(), which
> works mostly like ktime_get() but is safe to use inside of a
> suspend callback.
> 
> Fixes: 9561f58442e4 ("scsi: ufs: mediatek: Support vops pre suspend
> to disable auto-hibern8")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/scsi/ufs/ufs-mediatek.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-
> mediatek.c
> index d1696db70ce8..a47241ed0a57 100644
> --- a/drivers/scsi/ufs/ufs-mediatek.c
> +++ b/drivers/scsi/ufs/ufs-mediatek.c
> @@ -318,15 +318,15 @@ static void ufs_mtk_wait_idle_state(struct
> ufs_hba *hba,
>  	u32 val, sm;
>  	bool wait_idle;
>  
> -	timeout = sched_clock() + retry_ms * 1000000UL;
> -
> +	/* cannot use plain ktime_get() in suspend */
> +	timeout = ktime_get_mono_fast_ns() + retry_ms * 1000000UL;

Thanks for this patch.

>  
>  	/* wait a specific time after check base */
>  	udelay(10);
>  	wait_idle = false;
>  
>  	do {
> -		time_checked = sched_clock();
> +		time_checked = ktime_get_mono_fast_ns();
>  		ufs_mtk_dbg_sel(hba);
>  		val = ufshcd_readl(hba, REG_UFS_PROBE);
>  


WARNING: multiple messages have this Message-ID (diff)
From: Peter Wang <peter.wang@mediatek.com>
To: Arnd Bergmann <arnd@kernel.org>,
	Stanley Chu <stanley.chu@mediatek.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Bean Huo <beanhuo@micron.com>,
	Bart Van Assche <bvanassche@acm.org>,
	<linux-scsi@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] scsi: ufs: mediatek: avoid sched_clock() misuse
Date: Thu, 21 Oct 2021 11:18:25 +0800	[thread overview]
Message-ID: <0c5b8562d49c7e81323b8a34a42385440f33f798.camel@mediatek.com> (raw)
In-Reply-To: <20211018132022.2281589-1-arnd@kernel.org>

On Mon, 2021-10-18 at 15:20 +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> sched_clock() is not meant to be used in portable driver code,
> and assuming a particular clock frequency is not how this is
> meant to be used. It also causes a build failure because of
> a missing header inclusion:
> 
> drivers/scsi/ufs/ufs-mediatek.c:321:12: error: implicit declaration
> of function 'sched_clock' [-Werror,-Wimplicit-function-declaration]
>         timeout = sched_clock() + retry_ms * 1000000UL;
> 
> A better interface to use here ktime_get_mono_fast_ns(), which
> works mostly like ktime_get() but is safe to use inside of a
> suspend callback.
> 
> Fixes: 9561f58442e4 ("scsi: ufs: mediatek: Support vops pre suspend
> to disable auto-hibern8")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/scsi/ufs/ufs-mediatek.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-
> mediatek.c
> index d1696db70ce8..a47241ed0a57 100644
> --- a/drivers/scsi/ufs/ufs-mediatek.c
> +++ b/drivers/scsi/ufs/ufs-mediatek.c
> @@ -318,15 +318,15 @@ static void ufs_mtk_wait_idle_state(struct
> ufs_hba *hba,
>  	u32 val, sm;
>  	bool wait_idle;
>  
> -	timeout = sched_clock() + retry_ms * 1000000UL;
> -
> +	/* cannot use plain ktime_get() in suspend */
> +	timeout = ktime_get_mono_fast_ns() + retry_ms * 1000000UL;

Thanks for this patch.

>  
>  	/* wait a specific time after check base */
>  	udelay(10);
>  	wait_idle = false;
>  
>  	do {
> -		time_checked = sched_clock();
> +		time_checked = ktime_get_mono_fast_ns();
>  		ufs_mtk_dbg_sel(hba);
>  		val = ufshcd_readl(hba, REG_UFS_PROBE);
>  


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

WARNING: multiple messages have this Message-ID (diff)
From: Peter Wang <peter.wang@mediatek.com>
To: Arnd Bergmann <arnd@kernel.org>,
	Stanley Chu <stanley.chu@mediatek.com>,
	"James E.J. Bottomley" <jejb@linux.ibm.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Alim Akhtar <alim.akhtar@samsung.com>,
	Avri Altman <avri.altman@wdc.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Bean Huo <beanhuo@micron.com>,
	Bart Van Assche <bvanassche@acm.org>,
	<linux-scsi@vger.kernel.org>,
	<linux-mediatek@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] scsi: ufs: mediatek: avoid sched_clock() misuse
Date: Thu, 21 Oct 2021 11:18:25 +0800	[thread overview]
Message-ID: <0c5b8562d49c7e81323b8a34a42385440f33f798.camel@mediatek.com> (raw)
In-Reply-To: <20211018132022.2281589-1-arnd@kernel.org>

On Mon, 2021-10-18 at 15:20 +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> sched_clock() is not meant to be used in portable driver code,
> and assuming a particular clock frequency is not how this is
> meant to be used. It also causes a build failure because of
> a missing header inclusion:
> 
> drivers/scsi/ufs/ufs-mediatek.c:321:12: error: implicit declaration
> of function 'sched_clock' [-Werror,-Wimplicit-function-declaration]
>         timeout = sched_clock() + retry_ms * 1000000UL;
> 
> A better interface to use here ktime_get_mono_fast_ns(), which
> works mostly like ktime_get() but is safe to use inside of a
> suspend callback.
> 
> Fixes: 9561f58442e4 ("scsi: ufs: mediatek: Support vops pre suspend
> to disable auto-hibern8")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/scsi/ufs/ufs-mediatek.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/scsi/ufs/ufs-mediatek.c b/drivers/scsi/ufs/ufs-
> mediatek.c
> index d1696db70ce8..a47241ed0a57 100644
> --- a/drivers/scsi/ufs/ufs-mediatek.c
> +++ b/drivers/scsi/ufs/ufs-mediatek.c
> @@ -318,15 +318,15 @@ static void ufs_mtk_wait_idle_state(struct
> ufs_hba *hba,
>  	u32 val, sm;
>  	bool wait_idle;
>  
> -	timeout = sched_clock() + retry_ms * 1000000UL;
> -
> +	/* cannot use plain ktime_get() in suspend */
> +	timeout = ktime_get_mono_fast_ns() + retry_ms * 1000000UL;

Thanks for this patch.

>  
>  	/* wait a specific time after check base */
>  	udelay(10);
>  	wait_idle = false;
>  
>  	do {
> -		time_checked = sched_clock();
> +		time_checked = ktime_get_mono_fast_ns();
>  		ufs_mtk_dbg_sel(hba);
>  		val = ufshcd_readl(hba, REG_UFS_PROBE);
>  


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

  parent reply	other threads:[~2021-10-21  3:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 13:20 [PATCH] scsi: ufs: mediatek: avoid sched_clock() misuse Arnd Bergmann
2021-10-18 13:20 ` Arnd Bergmann
2021-10-18 13:20 ` Arnd Bergmann
2021-10-20 11:04 ` Stanley Chu
2021-10-20 11:04   ` Stanley Chu
2021-10-20 11:04   ` Stanley Chu
2021-10-21  3:18 ` Peter Wang [this message]
2021-10-21  3:18   ` Peter Wang
2021-10-21  3:18   ` Peter Wang
2021-10-27  4:00 ` Martin K. Petersen
2021-10-27  4:00   ` Martin K. Petersen
2021-10-27  4:00   ` Martin K. Petersen

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=0c5b8562d49c7e81323b8a34a42385440f33f798.camel@mediatek.com \
    --to=peter.wang@mediatek.com \
    --cc=alim.akhtar@samsung.com \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=jejb@linux.ibm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=matthias.bgg@gmail.com \
    --cc=stanley.chu@mediatek.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 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.