* [U-Boot] [RFC PATCH] bitops: Fix GENMASK definition for Sandbox
@ 2018-12-17 13:32 Vignesh R
2019-01-09 9:21 ` Vignesh R
2019-01-10 12:56 ` Simon Glass
0 siblings, 2 replies; 4+ messages in thread
From: Vignesh R @ 2018-12-17 13:32 UTC (permalink / raw)
To: u-boot
In arch/sandbox/include/asm/types.h we have
Therefore for 32 bit Sandbox build BITS_PER_LONG turns out to be 32 as
CONFIG_PHYS64 is not set
This messes up the current logic of GENMASK macro due to mismatch b/w
size of unsigned long (64 bit) and that of BITS_PER_LONG.
Fix this by using CONFIG_SANDBOX_BITS_PER_LONG which is set to 64/32
based on the host machine on which its being compiled.
Without this patch:
GENMASK(14,0) => 0x7fffffffffff
After this patch:
GENMASK(14,0) => 0x7fff
Signed-off-by: Vignesh R <vigneshr@ti.com>
---
I marked it as RFC because, I am not really sure if I am running Sandbox
tests properly.
My host machine is x86_64 (Ubuntu 18.04). Running below command[1] with
some of my yet to be upstreamed patches that use GENMASK macro shows this issue.
[1]:
$ make check
include/linux/bitops.h | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index a47f6d17bb5f..259df43fb00f 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -21,8 +21,13 @@
* position @h. For example
* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
*/
+#ifdef CONFIG_SANDBOX
+#define GENMASK(h, l) \
+ (((~0UL) << (l)) & (~0UL >> (CONFIG_SANDBOX_BITS_PER_LONG - 1 - (h))))
+#else
#define GENMASK(h, l) \
(((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
+#endif
#define GENMASK_ULL(h, l) \
(((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
--
2.20.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [RFC PATCH] bitops: Fix GENMASK definition for Sandbox
2018-12-17 13:32 [U-Boot] [RFC PATCH] bitops: Fix GENMASK definition for Sandbox Vignesh R
@ 2019-01-09 9:21 ` Vignesh R
2019-01-10 12:56 ` Simon Glass
1 sibling, 0 replies; 4+ messages in thread
From: Vignesh R @ 2019-01-09 9:21 UTC (permalink / raw)
To: u-boot
On 17/12/18 7:02 PM, Vignesh R wrote:
> In arch/sandbox/include/asm/types.h we have
> Therefore for 32 bit Sandbox build BITS_PER_LONG turns out to be 32 as
> CONFIG_PHYS64 is not set
>
> This messes up the current logic of GENMASK macro due to mismatch b/w
> size of unsigned long (64 bit) and that of BITS_PER_LONG.
> Fix this by using CONFIG_SANDBOX_BITS_PER_LONG which is set to 64/32
> based on the host machine on which its being compiled.
>
> Without this patch:
> GENMASK(14,0) => 0x7fffffffffff
> After this patch:
> GENMASK(14,0) => 0x7fff
>
> Signed-off-by: Vignesh R <vigneshr@ti.com>
> ---
>
Gentle ping.. Simon, this patch is required of upcoming SPI flash layer
changes. Any feedback on this patch?
Regards
Vignesh
> I marked it as RFC because, I am not really sure if I am running Sandbox
> tests properly.
> My host machine is x86_64 (Ubuntu 18.04). Running below command[1] with
> some of my yet to be upstreamed patches that use GENMASK macro shows this issue.
>
> [1]:
> $ make check
>
>
> include/linux/bitops.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> index a47f6d17bb5f..259df43fb00f 100644
> --- a/include/linux/bitops.h
> +++ b/include/linux/bitops.h
> @@ -21,8 +21,13 @@
> * position @h. For example
> * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000.
> */
> +#ifdef CONFIG_SANDBOX
> +#define GENMASK(h, l) \
> + (((~0UL) << (l)) & (~0UL >> (CONFIG_SANDBOX_BITS_PER_LONG - 1 - (h))))
> +#else
> #define GENMASK(h, l) \
> (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h))))
> +#endif
>
> #define GENMASK_ULL(h, l) \
> (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [RFC PATCH] bitops: Fix GENMASK definition for Sandbox
2018-12-17 13:32 [U-Boot] [RFC PATCH] bitops: Fix GENMASK definition for Sandbox Vignesh R
2019-01-09 9:21 ` Vignesh R
@ 2019-01-10 12:56 ` Simon Glass
2019-01-21 18:40 ` Simon Glass
1 sibling, 1 reply; 4+ messages in thread
From: Simon Glass @ 2019-01-10 12:56 UTC (permalink / raw)
To: u-boot
On Mon, 17 Dec 2018 at 06:31, Vignesh R <vigneshr@ti.com> wrote:
>
> In arch/sandbox/include/asm/types.h we have
> Therefore for 32 bit Sandbox build BITS_PER_LONG turns out to be 32 as
> CONFIG_PHYS64 is not set
>
> This messes up the current logic of GENMASK macro due to mismatch b/w
> size of unsigned long (64 bit) and that of BITS_PER_LONG.
> Fix this by using CONFIG_SANDBOX_BITS_PER_LONG which is set to 64/32
> based on the host machine on which its being compiled.
>
> Without this patch:
> GENMASK(14,0) => 0x7fffffffffff
> After this patch:
> GENMASK(14,0) => 0x7fff
>
> Signed-off-by: Vignesh R <vigneshr@ti.com>
> ---
>
> I marked it as RFC because, I am not really sure if I am running Sandbox
> tests properly.
> My host machine is x86_64 (Ubuntu 18.04). Running below command[1] with
> some of my yet to be upstreamed patches that use GENMASK macro shows this issue.
>
> [1]:
> $ make check
>
>
> include/linux/bitops.h | 5 +++++
> 1 file changed, 5 insertions(+)
I copied Bin who introduced this Kconfig option.
It is unfortunate that we need this #ifdef but I think it is correct.
I think we need some Kconfig help for SANDBOX_BITS_PER_LONG.
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [RFC PATCH] bitops: Fix GENMASK definition for Sandbox
2019-01-10 12:56 ` Simon Glass
@ 2019-01-21 18:40 ` Simon Glass
0 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2019-01-21 18:40 UTC (permalink / raw)
To: u-boot
On Fri, 11 Jan 2019 at 01:56, Simon Glass <sjg@chromium.org> wrote:
>
> On Mon, 17 Dec 2018 at 06:31, Vignesh R <vigneshr@ti.com> wrote:
> >
> > In arch/sandbox/include/asm/types.h we have
> > Therefore for 32 bit Sandbox build BITS_PER_LONG turns out to be 32 as
> > CONFIG_PHYS64 is not set
> >
> > This messes up the current logic of GENMASK macro due to mismatch b/w
> > size of unsigned long (64 bit) and that of BITS_PER_LONG.
> > Fix this by using CONFIG_SANDBOX_BITS_PER_LONG which is set to 64/32
> > based on the host machine on which its being compiled.
> >
> > Without this patch:
> > GENMASK(14,0) => 0x7fffffffffff
> > After this patch:
> > GENMASK(14,0) => 0x7fff
> >
> > Signed-off-by: Vignesh R <vigneshr@ti.com>
> > ---
> >
> > I marked it as RFC because, I am not really sure if I am running Sandbox
> > tests properly.
> > My host machine is x86_64 (Ubuntu 18.04). Running below command[1] with
> > some of my yet to be upstreamed patches that use GENMASK macro shows this issue.
> >
> > [1]:
> > $ make check
> >
> >
> > include/linux/bitops.h | 5 +++++
> > 1 file changed, 5 insertions(+)
>
> I copied Bin who introduced this Kconfig option.
>
> It is unfortunate that we need this #ifdef but I think it is correct.
> I think we need some Kconfig help for SANDBOX_BITS_PER_LONG.
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
Applied to u-boot-dm, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-21 18:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-17 13:32 [U-Boot] [RFC PATCH] bitops: Fix GENMASK definition for Sandbox Vignesh R
2019-01-09 9:21 ` Vignesh R
2019-01-10 12:56 ` Simon Glass
2019-01-21 18:40 ` Simon Glass
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.