Message ID | 13bf409f3191d066af9caef417011b6ea039dbd9.1700221559.git.oleksii.kurochko@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Introduce generic headers | expand |
On 17.11.2023 13:24, Oleksii Kurochko wrote: > All archs have the do_div implementation for BITS_PER_LONG == 64 > so do_div64.h is moved to asm-generic. > > x86 and PPC were switched to asm-generic version of div64.h. > > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> Acked-by: Jan Beulich <jbeulich@suse.com>
Hi, On 17/11/2023 12:24, Oleksii Kurochko wrote: > All archs have the do_div implementation for BITS_PER_LONG == 64 > so do_div64.h is moved to asm-generic. You are saying "all archs" but ... > > x86 and PPC were switched to asm-generic version of div64.h. ... you only switch x86/PPC to div64.h. I guess this is because for arm we have a different implementation for 32-bits. The 64-bits version is the same as x86/PPC. So I wonder if it is possible to include asm-generic/div64.h from arch/arm/include/asm/div64.h? This will avoid duplicating some code. Cheers,
Hi Julien, On Fri, 2023-11-24 at 11:29 +0000, Julien Grall wrote: > Hi, > > On 17/11/2023 12:24, Oleksii Kurochko wrote: > > All archs have the do_div implementation for BITS_PER_LONG == 64 > > so do_div64.h is moved to asm-generic. > > You are saying "all archs" but ... > > > > > x86 and PPC were switched to asm-generic version of div64.h. > > ... you only switch x86/PPC to div64.h. You are right. I wasn't precise enough. Also RISC-V uses asm-generic version of div64.h but for that I have separate patch series. > > I guess this is because for arm we have a different implementation > for > 32-bits. The 64-bits version is the same as x86/PPC. > > So I wonder if it is possible to include asm-generic/div64.h from > arch/arm/include/asm/div64.h? > > This will avoid duplicating some code. Yes, you are right. Arm wasn't switched to asm-generic/div64.h because of different implementaion for 32-bit. I think we can include asm-generic/div64.h excplicitly for Arm. I made a little test and it works so I started full CI and if it won't any issue with Arm I'll update the patch. Thanks for the comments. > Cheers, >
diff --git a/xen/arch/ppc/include/asm/Makefile b/xen/arch/ppc/include/asm/Makefile index 9b38d2d381..b4fbcc897b 100644 --- a/xen/arch/ppc/include/asm/Makefile +++ b/xen/arch/ppc/include/asm/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0-only +generic-y += div64.h generic-y += hardirq.h generic-y += hypercall.h generic-y += iocap.h diff --git a/xen/arch/ppc/include/asm/div64.h b/xen/arch/ppc/include/asm/div64.h deleted file mode 100644 index d213e50585..0000000000 --- a/xen/arch/ppc/include/asm/div64.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only */ -#ifndef __ASM_PPC_DIV64_H__ -#define __ASM_PPC_DIV64_H__ - -#include <xen/types.h> - -#define do_div(n, base) ({ \ - uint32_t base_ = (base); \ - uint32_t rem_ = (uint64_t)(n) % base_; \ - (n) = (uint64_t)(n) / base_; \ - rem_; \ -}) - -#endif /* __ASM_PPC_DIV64_H__ */ diff --git a/xen/arch/x86/include/asm/Makefile b/xen/arch/x86/include/asm/Makefile index 874429ed30..daab34ff0a 100644 --- a/xen/arch/x86/include/asm/Makefile +++ b/xen/arch/x86/include/asm/Makefile @@ -1,2 +1,3 @@ # SPDX-License-Identifier: GPL-2.0-only +generic-y += div64.h generic-y += percpu.h diff --git a/xen/arch/x86/include/asm/div64.h b/xen/arch/x86/include/asm/div64.h deleted file mode 100644 index dd49f64a3b..0000000000 --- a/xen/arch/x86/include/asm/div64.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __X86_DIV64 -#define __X86_DIV64 - -#include <xen/types.h> - -#define do_div(n,base) ({ \ - uint32_t __base = (base); \ - uint32_t __rem; \ - __rem = ((uint64_t)(n)) % __base; \ - (n) = ((uint64_t)(n)) / __base; \ - __rem; \ -}) - -#endif diff --git a/xen/include/asm-generic/div64.h b/xen/include/asm-generic/div64.h new file mode 100644 index 0000000000..068d8a11ad --- /dev/null +++ b/xen/include/asm-generic/div64.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef __ASM_GENERIC_DIV64 +#define __ASM_GENERIC_DIV64 + +#include <xen/types.h> + +#if BITS_PER_LONG == 64 + +#define do_div(n, divisor) ({ \ + uint32_t divisor_ = (divisor); \ + uint32_t rem_ = (uint64_t)(n) % divisor_; \ + (n) = (uint64_t)(n) / divisor_; \ + rem_; \ +}) + +#endif /* BITS_PER_LONG */ + +#endif + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */
All archs have the do_div implementation for BITS_PER_LONG == 64 so do_div64.h is moved to asm-generic. x86 and PPC were switched to asm-generic version of div64.h. Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com> --- Changes in V3: - Drop x86 and PPC's div64.h. - Update the commit message. --- Changes in V2: - rename base to divisor - add "#if BITS_PER_LONG == 64" - fix code style --- xen/arch/ppc/include/asm/Makefile | 1 + xen/arch/ppc/include/asm/div64.h | 14 -------------- xen/arch/x86/include/asm/Makefile | 1 + xen/arch/x86/include/asm/div64.h | 14 -------------- xen/include/asm-generic/div64.h | 27 +++++++++++++++++++++++++++ 5 files changed, 29 insertions(+), 28 deletions(-) delete mode 100644 xen/arch/ppc/include/asm/div64.h delete mode 100644 xen/arch/x86/include/asm/div64.h create mode 100644 xen/include/asm-generic/div64.h