All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
	"Wei Liu" <wei.liu2@citrix.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Julien Grall" <julien.grall@arm.com>,
	"Jan Beulich" <JBeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [PATCH 1/2] xen/lib: Introduce printk_once() and replace some opencoded examples
Date: Fri, 17 May 2019 19:58:43 +0100	[thread overview]
Message-ID: <1558119524-318-1-git-send-email-andrew.cooper3@citrix.com> (raw)

Reflow the ZynqMP message for grepability, and fix the omission of a newline.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/cpuerrata.c               | 18 ++----------------
 xen/arch/arm/platforms/xilinx-zynqmp.c |  9 ++-------
 xen/include/xen/lib.h                  | 11 +++++++++++
 3 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/xen/arch/arm/cpuerrata.c b/xen/arch/arm/cpuerrata.c
index 4431b24..8904939 100644
--- a/xen/arch/arm/cpuerrata.c
+++ b/xen/arch/arm/cpuerrata.c
@@ -336,18 +336,11 @@ static bool has_ssbd_mitigation(const struct arm_cpu_capabilities *entry)
     switch ( ssbd_state )
     {
     case ARM_SSBD_FORCE_DISABLE:
-    {
-        static bool once = true;
-
-        if ( once )
-            printk("%s disabled from command-line\n", entry->desc);
-        once = false;
+        printk_once("%s disabled from command-line\n", entry->desc);
 
         arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 0, NULL);
         required = false;
-
         break;
-    }
 
     case ARM_SSBD_RUNTIME:
         if ( required )
@@ -359,18 +352,11 @@ static bool has_ssbd_mitigation(const struct arm_cpu_capabilities *entry)
         break;
 
     case ARM_SSBD_FORCE_ENABLE:
-    {
-        static bool once = true;
-
-        if ( once )
-            printk("%s forced from command-line\n", entry->desc);
-        once = false;
+        printk_once("%s forced from command-line\n", entry->desc);
 
         arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 1, NULL);
         required = true;
-
         break;
-    }
 
     default:
         ASSERT_UNREACHABLE();
diff --git a/xen/arch/arm/platforms/xilinx-zynqmp.c b/xen/arch/arm/platforms/xilinx-zynqmp.c
index 08e3e11..3060d79 100644
--- a/xen/arch/arm/platforms/xilinx-zynqmp.c
+++ b/xen/arch/arm/platforms/xilinx-zynqmp.c
@@ -35,14 +35,9 @@ static bool zynqmp_smc(struct cpu_user_regs *regs)
      */
     if ( !cpus_have_const_cap(ARM_SMCCC_1_1) )
     {
-        static bool once = true;
+        printk_once(XENLOG_WARNING
+                    "ZynqMP firmware Error: no SMCCC 1.1 support. Disabling firmware calls\n");
 
-        if ( once )
-        {
-            printk(XENLOG_WARNING "ZynqMP firmware Error: no SMCCC 1.1 "
-                   "support. Disabling firmware calls.");
-            once = false;
-        }
         return false;
     }
     return zynqmp_eemi(regs);
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 91ed56c..ce231c5 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -105,6 +105,17 @@ debugtrace_printk(const char *fmt, ...) {}
 #define _p(_x) ((void *)(unsigned long)(_x))
 extern void printk(const char *format, ...)
     __attribute__ ((format (printf, 1, 2)));
+
+#define printk_once(fmt, args...)               \
+({                                              \
+    static bool __read_mostly once_;            \
+    if ( unlikely(!once_) )                     \
+    {                                           \
+        once_ = true;                           \
+        printk(fmt, ## args);                   \
+    }                                           \
+})
+
 extern void guest_printk(const struct domain *d, const char *format, ...)
     __attribute__ ((format (printf, 2, 3)));
 extern void noreturn panic(const char *format, ...)
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: "Stefano Stabellini" <sstabellini@kernel.org>,
	"Wei Liu" <wei.liu2@citrix.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Julien Grall" <julien.grall@arm.com>,
	"Jan Beulich" <JBeulich@suse.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>
Subject: [Xen-devel] [PATCH 1/2] xen/lib: Introduce printk_once() and replace some opencoded examples
Date: Fri, 17 May 2019 19:58:43 +0100	[thread overview]
Message-ID: <1558119524-318-1-git-send-email-andrew.cooper3@citrix.com> (raw)
Message-ID: <20190517185843.LEPobQ4bVlpbijlWoU3KgPtSU6aiaCkRb-g0CPume20@z> (raw)

Reflow the ZynqMP message for grepability, and fix the omission of a newline.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/cpuerrata.c               | 18 ++----------------
 xen/arch/arm/platforms/xilinx-zynqmp.c |  9 ++-------
 xen/include/xen/lib.h                  | 11 +++++++++++
 3 files changed, 15 insertions(+), 23 deletions(-)

diff --git a/xen/arch/arm/cpuerrata.c b/xen/arch/arm/cpuerrata.c
index 4431b24..8904939 100644
--- a/xen/arch/arm/cpuerrata.c
+++ b/xen/arch/arm/cpuerrata.c
@@ -336,18 +336,11 @@ static bool has_ssbd_mitigation(const struct arm_cpu_capabilities *entry)
     switch ( ssbd_state )
     {
     case ARM_SSBD_FORCE_DISABLE:
-    {
-        static bool once = true;
-
-        if ( once )
-            printk("%s disabled from command-line\n", entry->desc);
-        once = false;
+        printk_once("%s disabled from command-line\n", entry->desc);
 
         arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 0, NULL);
         required = false;
-
         break;
-    }
 
     case ARM_SSBD_RUNTIME:
         if ( required )
@@ -359,18 +352,11 @@ static bool has_ssbd_mitigation(const struct arm_cpu_capabilities *entry)
         break;
 
     case ARM_SSBD_FORCE_ENABLE:
-    {
-        static bool once = true;
-
-        if ( once )
-            printk("%s forced from command-line\n", entry->desc);
-        once = false;
+        printk_once("%s forced from command-line\n", entry->desc);
 
         arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2_FID, 1, NULL);
         required = true;
-
         break;
-    }
 
     default:
         ASSERT_UNREACHABLE();
diff --git a/xen/arch/arm/platforms/xilinx-zynqmp.c b/xen/arch/arm/platforms/xilinx-zynqmp.c
index 08e3e11..3060d79 100644
--- a/xen/arch/arm/platforms/xilinx-zynqmp.c
+++ b/xen/arch/arm/platforms/xilinx-zynqmp.c
@@ -35,14 +35,9 @@ static bool zynqmp_smc(struct cpu_user_regs *regs)
      */
     if ( !cpus_have_const_cap(ARM_SMCCC_1_1) )
     {
-        static bool once = true;
+        printk_once(XENLOG_WARNING
+                    "ZynqMP firmware Error: no SMCCC 1.1 support. Disabling firmware calls\n");
 
-        if ( once )
-        {
-            printk(XENLOG_WARNING "ZynqMP firmware Error: no SMCCC 1.1 "
-                   "support. Disabling firmware calls.");
-            once = false;
-        }
         return false;
     }
     return zynqmp_eemi(regs);
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 91ed56c..ce231c5 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -105,6 +105,17 @@ debugtrace_printk(const char *fmt, ...) {}
 #define _p(_x) ((void *)(unsigned long)(_x))
 extern void printk(const char *format, ...)
     __attribute__ ((format (printf, 1, 2)));
+
+#define printk_once(fmt, args...)               \
+({                                              \
+    static bool __read_mostly once_;            \
+    if ( unlikely(!once_) )                     \
+    {                                           \
+        once_ = true;                           \
+        printk(fmt, ## args);                   \
+    }                                           \
+})
+
 extern void guest_printk(const struct domain *d, const char *format, ...)
     __attribute__ ((format (printf, 2, 3)));
 extern void noreturn panic(const char *format, ...)
-- 
2.1.4


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

             reply	other threads:[~2019-05-17 18:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-17 18:58 Andrew Cooper [this message]
2019-05-17 18:58 ` [Xen-devel] [PATCH 1/2] xen/lib: Introduce printk_once() and replace some opencoded examples Andrew Cooper
2019-05-17 18:58 ` [PATCH 2/2] x86/mpparse: Don't print "limit reached" for every subsequent processor Andrew Cooper
2019-05-17 18:58   ` [Xen-devel] " Andrew Cooper
2019-05-20  8:26   ` Jan Beulich
2019-05-20  8:26     ` [Xen-devel] " Jan Beulich
2019-05-20  8:24 ` [PATCH 1/2] xen/lib: Introduce printk_once() and replace some opencoded examples Jan Beulich
2019-05-20  8:24   ` [Xen-devel] " Jan Beulich
2019-05-31 17:20 ` Julien Grall
2019-05-31 17:20   ` [Xen-devel] " Julien Grall

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=1558119524-318-1-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=julien.grall@arm.com \
    --cc=roger.pau@citrix.com \
    --cc=sstabellini@kernel.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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.