* [PATCH] x86/bootflag: Replace open-coded parity calculation with parity8()
@ 2025-02-27 12:55 Uros Bizjak
2025-02-27 13:00 ` Ingo Molnar
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Uros Bizjak @ 2025-02-27 12:55 UTC (permalink / raw)
To: x86, linux-kernel
Cc: Uros Bizjak, Yu-Chun Lin, Kuan-Wei Chiu, Thomas Gleixner,
Ingo Molnar, Borislav Petkov, Dave Hansen, H. Peter Anvin
Refactor parity calculations to use the standard parity8() helper. This
change eliminates redundant implementations and improves code
efficiency.
[ubizjak: Updated the patch to apply to the current source.]
Co-developed-by: Yu-Chun Lin <eleanor15x@gmail.com>
Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com>
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/lkml/20250223164217.2139331-4-visitorckw@gmail.com/
---
arch/x86/kernel/bootflag.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/arch/x86/kernel/bootflag.c b/arch/x86/kernel/bootflag.c
index b935c3e42bfd..73274d76ce16 100644
--- a/arch/x86/kernel/bootflag.c
+++ b/arch/x86/kernel/bootflag.c
@@ -8,6 +8,7 @@
#include <linux/string.h>
#include <linux/spinlock.h>
#include <linux/acpi.h>
+#include <linux/bitops.h>
#include <asm/io.h>
#include <linux/mc146818rtc.h>
@@ -20,25 +21,12 @@
int sbf_port __initdata = -1; /* set via acpi_boot_init() */
-static bool __init parity(u8 v)
-{
- int x = 0;
- int i;
-
- for (i = 0; i < 8; i++) {
- x ^= (v & 1);
- v >>= 1;
- }
-
- return !!x;
-}
-
static void __init sbf_write(u8 v)
{
unsigned long flags;
if (sbf_port != -1) {
- if (!parity(v))
+ if (!parity8(v))
v ^= SBF_PARITY;
printk(KERN_INFO "Simple Boot Flag at 0x%x set to 0x%x\n",
@@ -69,7 +57,7 @@ static bool __init sbf_value_valid(u8 v)
{
if (v & SBF_RESERVED) /* Reserved bits */
return false;
- if (!parity(v))
+ if (!parity8(v))
return false;
return true;
--
2.48.1
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [PATCH] x86/bootflag: Replace open-coded parity calculation with parity8()
2025-02-27 12:55 [PATCH] x86/bootflag: Replace open-coded parity calculation with parity8() Uros Bizjak
@ 2025-02-27 13:00 ` Ingo Molnar
2025-02-27 13:15 ` [tip: x86/boot] " tip-bot2 for Kuan-Wei Chiu
2025-02-27 13:21 ` [PATCH] " Kuan-Wei Chiu
2 siblings, 0 replies; 5+ messages in thread
From: Ingo Molnar @ 2025-02-27 13:00 UTC (permalink / raw)
To: Uros Bizjak
Cc: x86, linux-kernel, Yu-Chun Lin, Kuan-Wei Chiu, Thomas Gleixner,
Borislav Petkov, Dave Hansen, H. Peter Anvin
* Uros Bizjak <ubizjak@gmail.com> wrote:
> Refactor parity calculations to use the standard parity8() helper. This
> change eliminates redundant implementations and improves code
> efficiency.
>
> [ubizjak: Updated the patch to apply to the current source.]
Please preserve the original From line in these cases - I fixed that
up by adding:
From: Kuan-Wei Chiu <visitorckw@gmail.com>
Probably the Git rebase/conflict-resolution step made you the author
without warning.
Thanks,
Ingo
^ permalink raw reply [flat|nested] 5+ messages in thread
* [tip: x86/boot] x86/bootflag: Replace open-coded parity calculation with parity8()
2025-02-27 12:55 [PATCH] x86/bootflag: Replace open-coded parity calculation with parity8() Uros Bizjak
2025-02-27 13:00 ` Ingo Molnar
@ 2025-02-27 13:15 ` tip-bot2 for Kuan-Wei Chiu
2025-03-11 14:47 ` Kuan-Wei Chiu
2025-02-27 13:21 ` [PATCH] " Kuan-Wei Chiu
2 siblings, 1 reply; 5+ messages in thread
From: tip-bot2 for Kuan-Wei Chiu @ 2025-02-27 13:15 UTC (permalink / raw)
To: linux-tip-commits
Cc: Yu-Chun Lin, Kuan-Wei Chiu, Uros Bizjak, Ingo Molnar,
H. Peter Anvin, x86, linux-kernel
The following commit has been merged into the x86/boot branch of tip:
Commit-ID: 9c94c14ca39577b6324c667d8450ffa19fc1e5c4
Gitweb: https://git.kernel.org/tip/9c94c14ca39577b6324c667d8450ffa19fc1e5c4
Author: Kuan-Wei Chiu <visitorckw@gmail.com>
AuthorDate: Thu, 27 Feb 2025 13:55:45 +01:00
Committer: Ingo Molnar <mingo@kernel.org>
CommitterDate: Thu, 27 Feb 2025 14:00:30 +01:00
x86/bootflag: Replace open-coded parity calculation with parity8()
Refactor parity calculations to use the standard parity8() helper. This
change eliminates redundant implementations and improves code
efficiency.
[ ubizjak: Updated the patch to apply to the latest x86 tree. ]
Co-developed-by: Yu-Chun Lin <eleanor15x@gmail.com>
Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com>
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/r/20250227125616.2253774-1-ubizjak@gmail.com
---
arch/x86/kernel/bootflag.c | 18 +++---------------
1 file changed, 3 insertions(+), 15 deletions(-)
diff --git a/arch/x86/kernel/bootflag.c b/arch/x86/kernel/bootflag.c
index b935c3e..73274d7 100644
--- a/arch/x86/kernel/bootflag.c
+++ b/arch/x86/kernel/bootflag.c
@@ -8,6 +8,7 @@
#include <linux/string.h>
#include <linux/spinlock.h>
#include <linux/acpi.h>
+#include <linux/bitops.h>
#include <asm/io.h>
#include <linux/mc146818rtc.h>
@@ -20,25 +21,12 @@
int sbf_port __initdata = -1; /* set via acpi_boot_init() */
-static bool __init parity(u8 v)
-{
- int x = 0;
- int i;
-
- for (i = 0; i < 8; i++) {
- x ^= (v & 1);
- v >>= 1;
- }
-
- return !!x;
-}
-
static void __init sbf_write(u8 v)
{
unsigned long flags;
if (sbf_port != -1) {
- if (!parity(v))
+ if (!parity8(v))
v ^= SBF_PARITY;
printk(KERN_INFO "Simple Boot Flag at 0x%x set to 0x%x\n",
@@ -69,7 +57,7 @@ static bool __init sbf_value_valid(u8 v)
{
if (v & SBF_RESERVED) /* Reserved bits */
return false;
- if (!parity(v))
+ if (!parity8(v))
return false;
return true;
^ permalink raw reply related [flat|nested] 5+ messages in thread* Re: [tip: x86/boot] x86/bootflag: Replace open-coded parity calculation with parity8()
2025-02-27 13:15 ` [tip: x86/boot] " tip-bot2 for Kuan-Wei Chiu
@ 2025-03-11 14:47 ` Kuan-Wei Chiu
0 siblings, 0 replies; 5+ messages in thread
From: Kuan-Wei Chiu @ 2025-03-11 14:47 UTC (permalink / raw)
To: linux-kernel, Ingo Molnar
Cc: linux-tip-commits, Yu-Chun Lin, Uros Bizjak, Ingo Molnar,
H. Peter Anvin, x86
Hi Ingo,
On Thu, Feb 27, 2025 at 01:15:13PM -0000, tip-bot2 for Kuan-Wei Chiu wrote:
> The following commit has been merged into the x86/boot branch of tip:
>
> Commit-ID: 9c94c14ca39577b6324c667d8450ffa19fc1e5c4
> Gitweb: https://git.kernel.org/tip/9c94c14ca39577b6324c667d8450ffa19fc1e5c4
> Author: Kuan-Wei Chiu <visitorckw@gmail.com>
> AuthorDate: Thu, 27 Feb 2025 13:55:45 +01:00
> Committer: Ingo Molnar <mingo@kernel.org>
> CommitterDate: Thu, 27 Feb 2025 14:00:30 +01:00
>
> x86/bootflag: Replace open-coded parity calculation with parity8()
>
> Refactor parity calculations to use the standard parity8() helper. This
> change eliminates redundant implementations and improves code
> efficiency.
>
> [ ubizjak: Updated the patch to apply to the latest x86 tree. ]
>
> Co-developed-by: Yu-Chun Lin <eleanor15x@gmail.com>
> Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com>
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Signed-off-by: Ingo Molnar <mingo@kernel.org>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Link: https://lore.kernel.org/r/20250227125616.2253774-1-ubizjak@gmail.com
Thanks for accepting this patch.
Based on the previous email discussion, I plan to rename parity8() to
parity_odd() in the next version of the parity patch series (though I'm
not too confident it will be accepted...). If I base the series on the
current linux-next tree, it might cause conflicts when other
maintainers apply it to their own trees. On the other hand, if I base
it on Linus's tree, it would conflict with the x86 tree.
I'm not sure which tree I should base the next version on. Since this
series touches multiple subsystems, the situation is a bit tricky.
Regards,
Kuan-Wei
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] x86/bootflag: Replace open-coded parity calculation with parity8()
2025-02-27 12:55 [PATCH] x86/bootflag: Replace open-coded parity calculation with parity8() Uros Bizjak
2025-02-27 13:00 ` Ingo Molnar
2025-02-27 13:15 ` [tip: x86/boot] " tip-bot2 for Kuan-Wei Chiu
@ 2025-02-27 13:21 ` Kuan-Wei Chiu
2 siblings, 0 replies; 5+ messages in thread
From: Kuan-Wei Chiu @ 2025-02-27 13:21 UTC (permalink / raw)
To: Uros Bizjak
Cc: x86, linux-kernel, Yu-Chun Lin, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, Dave Hansen, H. Peter Anvin
On Thu, Feb 27, 2025 at 01:55:45PM +0100, Uros Bizjak wrote:
> Refactor parity calculations to use the standard parity8() helper. This
> change eliminates redundant implementations and improves code
> efficiency.
>
> [ubizjak: Updated the patch to apply to the current source.]
>
> Co-developed-by: Yu-Chun Lin <eleanor15x@gmail.com>
> Signed-off-by: Yu-Chun Lin <eleanor15x@gmail.com>
> Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
> Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
> Cc: Thomas Gleixner <tglx@linutronix.de>
> Cc: Ingo Molnar <mingo@kernel.org>
> Cc: Borislav Petkov <bp@alien8.de>
> Cc: Dave Hansen <dave.hansen@linux.intel.com>
> Cc: "H. Peter Anvin" <hpa@zytor.com>
> Link: https://lore.kernel.org/lkml/20250223164217.2139331-4-visitorckw@gmail.com/
Not sure if the Reviewed-by tag is appropriate here, but FWIW:
Reviewed-by: Kuan-Wei Chiu <visitorckw@gmail.com>
I'll exclude this patch when sending the v2 parity patch series.
Thanks!
Regards,
Kuan-Wei
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-03-11 14:47 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27 12:55 [PATCH] x86/bootflag: Replace open-coded parity calculation with parity8() Uros Bizjak
2025-02-27 13:00 ` Ingo Molnar
2025-02-27 13:15 ` [tip: x86/boot] " tip-bot2 for Kuan-Wei Chiu
2025-03-11 14:47 ` Kuan-Wei Chiu
2025-02-27 13:21 ` [PATCH] " Kuan-Wei Chiu
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.