* [PATCH] MIPS: CPC: Use bitfield helpers
[not found] <a1445d3abb45cfc95cb1b03180fd53caf122035b.1637593297.git.geert+renesas@glider.be>
@ 2021-11-22 15:53 ` Geert Uytterhoeven
2021-11-29 12:32 ` Thomas Bogendoerfer
2021-11-22 15:53 ` [PATCH] MIPS: CPS: " Geert Uytterhoeven
2021-11-22 15:54 ` [PATCH] irqchip/mips-gic: " Geert Uytterhoeven
2 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2021-11-22 15:53 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: linux-mips, linux-kernel, Geert Uytterhoeven
Use the FIELD_PREP() helper, instead of open-coding the same operation.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Compile-tested only.
See "[PATCH 00/17] Non-const bitfield helper conversions"
(https://lore.kernel.org/r/cover.1637592133.git.geert+renesas@glider.be)
for background and more conversions.
---
arch/mips/kernel/mips-cpc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/mips/kernel/mips-cpc.c b/arch/mips/kernel/mips-cpc.c
index 8d2535123f11c8f3..17aff13cd7ce6ea7 100644
--- a/arch/mips/kernel/mips-cpc.c
+++ b/arch/mips/kernel/mips-cpc.c
@@ -4,6 +4,7 @@
* Author: Paul Burton <paul.burton@mips.com>
*/
+#include <linux/bitfield.h>
#include <linux/errno.h>
#include <linux/percpu.h>
#include <linux/of.h>
@@ -97,7 +98,7 @@ void mips_cpc_lock_other(unsigned int core)
curr_core = cpu_core(¤t_cpu_data);
spin_lock_irqsave(&per_cpu(cpc_core_lock, curr_core),
per_cpu(cpc_core_lock_flags, curr_core));
- write_cpc_cl_other(core << __ffs(CPC_Cx_OTHER_CORENUM));
+ write_cpc_cl_other(FIELD_PREP(CPC_Cx_OTHER_CORENUM, core));
/*
* Ensure the core-other region reflects the appropriate core &
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] MIPS: CPS: Use bitfield helpers
[not found] <a1445d3abb45cfc95cb1b03180fd53caf122035b.1637593297.git.geert+renesas@glider.be>
2021-11-22 15:53 ` [PATCH] MIPS: CPC: Use bitfield helpers Geert Uytterhoeven
@ 2021-11-22 15:53 ` Geert Uytterhoeven
2021-11-29 12:32 ` Thomas Bogendoerfer
2021-11-22 15:54 ` [PATCH] irqchip/mips-gic: " Geert Uytterhoeven
2 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2021-11-22 15:53 UTC (permalink / raw)
To: Thomas Bogendoerfer; +Cc: linux-mips, linux-kernel, Geert Uytterhoeven
Use the FIELD_GET() helper, instead of open-coding the same operation.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Compile-tested only.
See "[PATCH 00/17] Non-const bitfield helper conversions"
(https://lore.kernel.org/r/cover.1637592133.git.geert+renesas@glider.be)
for background and more conversions.
---
arch/mips/include/asm/mips-cps.h | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/arch/mips/include/asm/mips-cps.h b/arch/mips/include/asm/mips-cps.h
index fd43d876892ec4c6..c077e8d100f584f9 100644
--- a/arch/mips/include/asm/mips-cps.h
+++ b/arch/mips/include/asm/mips-cps.h
@@ -7,6 +7,7 @@
#ifndef __MIPS_ASM_MIPS_CPS_H__
#define __MIPS_ASM_MIPS_CPS_H__
+#include <linux/bitfield.h>
#include <linux/io.h>
#include <linux/types.h>
@@ -112,14 +113,10 @@ static inline void clear_##unit##_##name(uint##sz##_t val) \
*/
static inline unsigned int mips_cps_numclusters(void)
{
- unsigned int num_clusters;
-
if (mips_cm_revision() < CM_REV_CM3_5)
return 1;
- num_clusters = read_gcr_config() & CM_GCR_CONFIG_NUM_CLUSTERS;
- num_clusters >>= __ffs(CM_GCR_CONFIG_NUM_CLUSTERS);
- return num_clusters;
+ return FIELD_GET(CM_GCR_CONFIG_NUM_CLUSTERS, read_gcr_config());
}
/**
@@ -169,7 +166,8 @@ static inline unsigned int mips_cps_numcores(unsigned int cluster)
return 0;
/* Add one before masking to handle 0xff indicating no cores */
- return (mips_cps_cluster_config(cluster) + 1) & CM_GCR_CONFIG_PCORES;
+ return FIELD_GET(CM_GCR_CONFIG_PCORES,
+ mips_cps_cluster_config(cluster) + 1);
}
/**
@@ -181,14 +179,11 @@ static inline unsigned int mips_cps_numcores(unsigned int cluster)
*/
static inline unsigned int mips_cps_numiocu(unsigned int cluster)
{
- unsigned int num_iocu;
-
if (!mips_cm_present())
return 0;
- num_iocu = mips_cps_cluster_config(cluster) & CM_GCR_CONFIG_NUMIOCU;
- num_iocu >>= __ffs(CM_GCR_CONFIG_NUMIOCU);
- return num_iocu;
+ return FIELD_GET(CM_GCR_CONFIG_NUMIOCU,
+ mips_cps_cluster_config(cluster));
}
/**
@@ -230,7 +225,7 @@ static inline unsigned int mips_cps_numvps(unsigned int cluster, unsigned int co
mips_cm_unlock_other();
- return (cfg + 1) & CM_GCR_Cx_CONFIG_PVPE;
+ return FIELD_GET(CM_GCR_Cx_CONFIG_PVPE, cfg + 1);
}
#endif /* __MIPS_ASM_MIPS_CPS_H__ */
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] irqchip/mips-gic: Use bitfield helpers
[not found] <a1445d3abb45cfc95cb1b03180fd53caf122035b.1637593297.git.geert+renesas@glider.be>
2021-11-22 15:53 ` [PATCH] MIPS: CPC: Use bitfield helpers Geert Uytterhoeven
2021-11-22 15:53 ` [PATCH] MIPS: CPS: " Geert Uytterhoeven
@ 2021-11-22 15:54 ` Geert Uytterhoeven
2 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2021-11-22 15:54 UTC (permalink / raw)
To: Thomas Bogendoerfer, Serge Semin, Thomas Gleixner, Marc Zyngier
Cc: linux-mips, linux-kernel, Geert Uytterhoeven
Use the FIELD_GET() helper, instead of open-coding the same operation.
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Compile-tested only.
See "[PATCH 00/17] Non-const bitfield helper conversions"
(https://lore.kernel.org/r/cover.1637592133.git.geert+renesas@glider.be)
for background and more conversions.
---
drivers/irqchip/irq-mips-gic.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c
index d02b05a067d950a0..ff89b36267dd4955 100644
--- a/drivers/irqchip/irq-mips-gic.c
+++ b/drivers/irqchip/irq-mips-gic.c
@@ -9,6 +9,7 @@
#define pr_fmt(fmt) "irq-mips-gic: " fmt
+#include <linux/bitfield.h>
#include <linux/bitmap.h>
#include <linux/clocksource.h>
#include <linux/cpuhotplug.h>
@@ -735,8 +736,7 @@ static int __init gic_of_init(struct device_node *node,
mips_gic_base = ioremap(gic_base, gic_len);
gicconfig = read_gic_config();
- gic_shared_intrs = gicconfig & GIC_CONFIG_NUMINTERRUPTS;
- gic_shared_intrs >>= __ffs(GIC_CONFIG_NUMINTERRUPTS);
+ gic_shared_intrs = FIELD_GET(GIC_CONFIG_NUMINTERRUPTS, gicconfig);
gic_shared_intrs = (gic_shared_intrs + 1) * 8;
if (cpu_has_veic) {
--
2.25.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: CPC: Use bitfield helpers
2021-11-22 15:53 ` [PATCH] MIPS: CPC: Use bitfield helpers Geert Uytterhoeven
@ 2021-11-29 12:32 ` Thomas Bogendoerfer
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Bogendoerfer @ 2021-11-29 12:32 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: linux-mips, linux-kernel
On Mon, Nov 22, 2021 at 04:53:46PM +0100, Geert Uytterhoeven wrote:
> Use the FIELD_PREP() helper, instead of open-coding the same operation.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Compile-tested only.
>
> See "[PATCH 00/17] Non-const bitfield helper conversions"
> (https://lore.kernel.org/r/cover.1637592133.git.geert+renesas@glider.be)
> for background and more conversions.
> ---
> arch/mips/kernel/mips-cpc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/mips/kernel/mips-cpc.c b/arch/mips/kernel/mips-cpc.c
> index 8d2535123f11c8f3..17aff13cd7ce6ea7 100644
> --- a/arch/mips/kernel/mips-cpc.c
> +++ b/arch/mips/kernel/mips-cpc.c
> @@ -4,6 +4,7 @@
> * Author: Paul Burton <paul.burton@mips.com>
> */
>
> +#include <linux/bitfield.h>
> #include <linux/errno.h>
> #include <linux/percpu.h>
> #include <linux/of.h>
> @@ -97,7 +98,7 @@ void mips_cpc_lock_other(unsigned int core)
> curr_core = cpu_core(¤t_cpu_data);
> spin_lock_irqsave(&per_cpu(cpc_core_lock, curr_core),
> per_cpu(cpc_core_lock_flags, curr_core));
> - write_cpc_cl_other(core << __ffs(CPC_Cx_OTHER_CORENUM));
> + write_cpc_cl_other(FIELD_PREP(CPC_Cx_OTHER_CORENUM, core));
>
> /*
> * Ensure the core-other region reflects the appropriate core &
> --
> 2.25.1
applied to mips-next.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] MIPS: CPS: Use bitfield helpers
2021-11-22 15:53 ` [PATCH] MIPS: CPS: " Geert Uytterhoeven
@ 2021-11-29 12:32 ` Thomas Bogendoerfer
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Bogendoerfer @ 2021-11-29 12:32 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: linux-mips, linux-kernel
On Mon, Nov 22, 2021 at 04:53:58PM +0100, Geert Uytterhoeven wrote:
> Use the FIELD_GET() helper, instead of open-coding the same operation.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Compile-tested only.
>
> See "[PATCH 00/17] Non-const bitfield helper conversions"
> (https://lore.kernel.org/r/cover.1637592133.git.geert+renesas@glider.be)
> for background and more conversions.
> ---
> arch/mips/include/asm/mips-cps.h | 19 +++++++------------
> 1 file changed, 7 insertions(+), 12 deletions(-)
applied to mips-next.
Thomas.
--
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a
good idea. [ RFC1925, 2.3 ]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-11-29 12:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <a1445d3abb45cfc95cb1b03180fd53caf122035b.1637593297.git.geert+renesas@glider.be>
2021-11-22 15:53 ` [PATCH] MIPS: CPC: Use bitfield helpers Geert Uytterhoeven
2021-11-29 12:32 ` Thomas Bogendoerfer
2021-11-22 15:53 ` [PATCH] MIPS: CPS: " Geert Uytterhoeven
2021-11-29 12:32 ` Thomas Bogendoerfer
2021-11-22 15:54 ` [PATCH] irqchip/mips-gic: " Geert Uytterhoeven
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).