linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] soc/qman: Sleep instead of stuck hacking jiffies.
@ 2017-06-25 15:13 Karim Eshapa
  2017-06-26 15:54 ` David Laight
  0 siblings, 1 reply; 3+ messages in thread
From: Karim Eshapa @ 2017-06-25 15:13 UTC (permalink / raw)
  To: oss
  Cc: claudiu.manoil, roy.pledge, colin.king, linuxppc-dev,
	linux-arm-kernel, linux-kernel, Karim Eshapa

Use msleep() instead of stucking with
long delay will be more efficient.

Signed-off-by: Karim Eshapa <karim.eshapa@gmail.com>
---
 drivers/soc/fsl/qbman/qman.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c
index 3d891db..18d391e 100644
--- a/drivers/soc/fsl/qbman/qman.c
+++ b/drivers/soc/fsl/qbman/qman.c
@@ -1084,11 +1084,7 @@ static int drain_mr_fqrni(struct qm_portal *p)
 		 * entries well before the ring has been fully consumed, so
 		 * we're being *really* paranoid here.
 		 */
-		u64 now, then = jiffies;
-
-		do {
-			now = jiffies;
-		} while ((then + 10000) > now);
+		msleep(1);
 		msg = qm_mr_current(p);
 		if (!msg)
 			return 0;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH] soc/qman: Sleep instead of stuck hacking jiffies.
  2017-06-25 15:13 [PATCH] soc/qman: Sleep instead of stuck hacking jiffies Karim Eshapa
@ 2017-06-26 15:54 ` David Laight
  2017-06-27 16:47   ` Leo Li
  0 siblings, 1 reply; 3+ messages in thread
From: David Laight @ 2017-06-26 15:54 UTC (permalink / raw)
  To: 'Karim Eshapa', oss@buserror.net
  Cc: roy.pledge@nxp.com, linux-kernel@vger.kernel.org,
	claudiu.manoil@nxp.com, colin.king@canonical.com,
	linuxppc-dev@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org

From: Karim Eshapa
> Sent: 25 June 2017 16:14
> Use msleep() instead of stucking with
> long delay will be more efficient.
...
> --- a/drivers/soc/fsl/qbman/qman.c
> +++ b/drivers/soc/fsl/qbman/qman.c
> @@ -1084,11 +1084,7 @@ static int drain_mr_fqrni(struct qm_portal *p)
>  		 * entries well before the ring has been fully consumed, so
>  		 * we're being *really* paranoid here.
>  		 */
> -		u64 now, then =3D jiffies;
> -
> -		do {
> -			now =3D jiffies;
> -		} while ((then + 10000) > now);
> +		msleep(1);
...
How is that in any way equivalent?
If HZ is 1000 the old code loops for 10 seconds.
If HZ is 250 (common for some distros) it loops for 40 seconds.

Clearly both are horrid, but it isn't at all clear that a 1ms sleep
is performing the same job.

My guess is that this code is never called, and broken if actually called.

	David

^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: [PATCH] soc/qman: Sleep instead of stuck hacking jiffies.
  2017-06-26 15:54 ` David Laight
@ 2017-06-27 16:47   ` Leo Li
  0 siblings, 0 replies; 3+ messages in thread
From: Leo Li @ 2017-06-27 16:47 UTC (permalink / raw)
  To: David Laight, 'Karim Eshapa', oss@buserror.net
  Cc: Roy Pledge, linux-kernel@vger.kernel.org, Claudiu Manoil,
	colin.king@canonical.com, linuxppc-dev@lists.ozlabs.org,
	linux-arm-kernel@lists.infradead.org



> -----Original Message-----
> From: Linuxppc-dev [mailto:linuxppc-dev-
> bounces+leoli=3Dfreescale.com@lists.ozlabs.org] On Behalf Of David Laight
> Sent: Monday, June 26, 2017 10:55 AM
> To: 'Karim Eshapa' <karim.eshapa@gmail.com>; oss@buserror.net
> Cc: Roy Pledge <roy.pledge@nxp.com>; linux-kernel@vger.kernel.org;
> Claudiu Manoil <claudiu.manoil@nxp.com>; colin.king@canonical.com;
> linuxppc-dev@lists.ozlabs.org; linux-arm-kernel@lists.infradead.org
> Subject: RE: [PATCH] soc/qman: Sleep instead of stuck hacking jiffies.
>=20
> From: Karim Eshapa
> > Sent: 25 June 2017 16:14
> > Use msleep() instead of stucking with
> > long delay will be more efficient.
> ...
> > --- a/drivers/soc/fsl/qbman/qman.c
> > +++ b/drivers/soc/fsl/qbman/qman.c
> > @@ -1084,11 +1084,7 @@ static int drain_mr_fqrni(struct qm_portal *p)
> >  		 * entries well before the ring has been fully consumed, so
> >  		 * we're being *really* paranoid here.
> >  		 */
> > -		u64 now, then =3D jiffies;
> > -
> > -		do {
> > -			now =3D jiffies;
> > -		} while ((then + 10000) > now);
> > +		msleep(1);
> ...
> How is that in any way equivalent?
> If HZ is 1000 the old code loops for 10 seconds.
> If HZ is 250 (common for some distros) it loops for 40 seconds.
>=20
> Clearly both are horrid, but it isn't at all clear that a 1ms sleep is pe=
rforming
> the same job.
>=20
> My guess is that this code is never called, and broken if actually called=
.

It was indeed broken.  The intent was to wait for 10000 cycles but mistaken=
ly coded as 10000 jiffies.  I think we choose 1ms as it is not too long and=
 almost guarantees the 10000 cycles delay.

Regards,
Leo

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-27 16:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-25 15:13 [PATCH] soc/qman: Sleep instead of stuck hacking jiffies Karim Eshapa
2017-06-26 15:54 ` David Laight
2017-06-27 16:47   ` Leo Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).