All of lore.kernel.org
 help / color / mirror / Atom feed
From: Max Filippov <jcmvbkbc@gmail.com>
To: Chris Zankel <chris@zankel.net>
Cc: Marc Gauthier <marc@tensilica.com>,
	linux-xtensa@linux-xtensa.org, linux-arch@vger.kernel.org,
	Max Filippov <jcmvbkbc@gmail.com>
Subject: [PATCH v2 03/11] xtensa: fix __delay for small loop count
Date: Fri, 30 Aug 2013 19:34:55 +0400	[thread overview]
Message-ID: <1377876903-27860-4-git-send-email-jcmvbkbc@gmail.com> (raw)
In-Reply-To: <1377876903-27860-1-git-send-email-jcmvbkbc@gmail.com>

Avoid __delay counter underflow for loop counts < 2.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
Changes v1->v2:
- make __delay fix more explicit for constant delays less than 2;

 arch/xtensa/include/asm/delay.h |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/arch/xtensa/include/asm/delay.h b/arch/xtensa/include/asm/delay.h
index 3899610..742b89f 100644
--- a/arch/xtensa/include/asm/delay.h
+++ b/arch/xtensa/include/asm/delay.h
@@ -19,9 +19,12 @@ extern unsigned long loops_per_jiffy;
 
 static inline void __delay(unsigned long loops)
 {
-	/* 2 cycles per loop. */
-	__asm__ __volatile__ ("1: addi %0, %0, -2; bgeui %0, 2, 1b"
-			      : "=r" (loops) : "0" (loops));
+	if (__builtin_constant_p(loops) && loops < 2)
+		__asm__ __volatile__ ("nop");
+	else if (loops >= 2)
+		/* 2 cycles per loop. */
+		__asm__ __volatile__ ("1: addi %0, %0, -2; bgeui %0, 2, 1b"
+				: "+r" (loops));
 }
 
 /* For SMP/NUMA systems, change boot_cpu_data to something like
-- 
1.7.7.6

  parent reply	other threads:[~2013-08-30 15:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-30 15:34 [PATCH v2 00/11] xtensa queue 2013/08/30 Max Filippov
2013-08-30 15:34 ` [PATCH v2 01/11] xtensa: kernel: add "asm/ftrace.h" for pass compiling Max Filippov
2013-08-30 15:34 ` [PATCH v2 02/11] xtensa: fix arch spinlock function names Max Filippov
2013-08-30 15:34 ` Max Filippov [this message]
2013-08-30 15:34 ` [PATCH v2 04/11] xtensa: fix build warning Max Filippov
2013-08-30 15:34 ` [PATCH v2 05/11] xtensa: check thread flags atomically on return from user exception Max Filippov
2013-08-30 15:34 ` [PATCH v2 06/11] xtensa: enable kernel preemption Max Filippov
2013-08-30 15:34 ` [PATCH v2 07/11] xtensa: keep a3 and excsave1 on entry to exception handlers Max Filippov
2013-08-30 15:35 ` [PATCH v2 08/11] xtensa: new fast_alloca handler Max Filippov
2013-08-30 15:35 ` [PATCH v2 09/11] xtensa: don't use echo -e needlessly Max Filippov
2013-08-30 15:35 ` [PATCH v2 10/11] xtensa: fix !CONFIG_XTENSA_CALIBRATE_CCOUNT build failure Max Filippov
2013-08-30 15:35 ` [PATCH v2 11/11] xtensa: remove CCOUNT_PER_JIFFY Max Filippov

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=1377876903-27860-4-git-send-email-jcmvbkbc@gmail.com \
    --to=jcmvbkbc@gmail.com \
    --cc=chris@zankel.net \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-xtensa@linux-xtensa.org \
    --cc=marc@tensilica.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.