Re: [PATCH 1/5] ARC/dl-runtime helper macros

2020-05-29 Thread Vineet Gupta
On 5/29/20 7:00 PM, Vineet Gupta wrote:
> This is purely for review purposes to attest the interface defined
> in prior patch
> ---
>  sysdeps/arc/dl-runtime.h | 42 
>  1 file changed, 42 insertions(+)
>  create mode 100644 sysdeps/arc/dl-runtime.h

Oops this was from a different series, please ignore. Don't post patches on 
friday
evening :-(
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v6 07/13] ARC: Linux Syscall Interface

2020-05-29 Thread Vineet Gupta
On 5/29/20 9:49 AM, Adhemerval Zanella via Libc-alpha wrote:
> 
> 
> On 22/04/2020 22:41, Vineet Gupta via Libc-alpha wrote:
>> Signed-off-by: Vineet Gupta 
> 
> As prior patches we do not use DCO, but rather copyright assignment.
> 

>> diff --git a/sysdeps/unix/sysv/linux/arc/arch-syscall.h 
>> b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
>> new file mode 100644
>> index ..2b017eb5bbaa
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
>> @@ -0,0 +1,303 @@
>> +/* AUTOGENERATED by update-syscall-lists.py.  */
>> +#define __NR_accept 202
>> +#define __NR_accept4 242
>> +#define __NR_acct 89
>> +#define __NR_add_key 217

>> +#define __NR_vmsplice 75
>> +#define __NR_wait4 260
>> +#define __NR_waitid 95
>> +#define __NR_write 64
>> +#define __NR_writev 66
> 
> Ok, although I did not confered it was done with lastest Linux kernel 
> releases used by build-many-glibcs.py. You might double check it.

I did use 5.6 kernel at the time, will double check though. Thx.

>> diff --git a/sysdeps/unix/sysv/linux/arc/clone.S 
>> b/sysdeps/unix/sysv/linux/arc/clone.S

>> +
>> +/* int clone(int (*fn)(void *), void *child_stack,
>> +   int flags, void *arg, ...
>> +   < pid_t *ptid, struct user_desc *tls, pid_t *ctid > );
>> +
>> + NOTE: I'm assuming that the last 3 args are NOT var-args and in case all
>> +3 are not relevant, caller will nevertheless pass those as NULL.
> 
> Maybe we should update our clone prototype, although this might incur 
> in a ABI break. The assumption here should be ok, since all other
> implementations do the same.
> 
>> +
>> + clone syscall in kernel (ABI: CONFIG_CLONE_BACKWARDS)
>> +
>> +  int sys_clone(unsigned long int clone_flags,
>> +unsigned long int newsp,
>> +int __user *parent_tidptr,
>> +void *tls,
>> +int __user *child_tidptr).  */
>> +
>> +ENTRY (__clone)
>> +cmp r0, 0   ; @fn can't be NULL
>> +cmp.ne  r1, 0   ; @child_stack can't be NULL
>> +bz  .L__sys_err
>> +
>> +; save some of the orig args
>> +; r0 containg @fn will be clobbered AFTER syscall (with ret val)
>> +; rest are clobbered BEFORE syscall due to different arg ordering
>> +mov r10, r0 ; @fn
>> +mov r11, r3 ; @args
>> +mov r12, r2 ; @clone_flags
>> +mov r9,  r5 ; @tls
>> +
>> +; adjust libc args for syscall
>> +
>> +mov r0, r2  ; libc @flags is 1st syscall arg
>> +mov r2, r4  ; libc @ptid
>> +mov r3, r5  ; libc @tls
>> +mov r4, r6  ; libc @ctid
>> +mov r8, __NR_clone
>> +ARC_TRAP_INSN
>> +
>> +cmp r0, 0   ; return code : 0 new process, !0 parent
>> +blt .L__sys_err2; < 0 (signed) error
>> +jnz [blink] ; Parent returns
>> +
>> +; - child starts here -
>> +
>> +; Setup TP register (only recent kernels v4.19+ do that)
>> +and.f   0, r12, CLONE_SETTLS
>> +mov.nz  r25, r9
> 
> Do you still need to set it since the minimum supported kernel
> for ARC is 5.1 ?

Right we can drop this.


> It should be safe for internal glibc usage, since for both pthread
> and posix_spawn it blocks all signals including SIGCANCEL and SIGXID.
> However this is still small race window if this is called directly 
> with pthread cancellation or g*uid in multithread.
> 
>> +
>> +; child jumps off to @fn with @arg as argument, and returns here
>> +jl.d[r10]
>> +mov r0, r11
>> +
>> +; exit() with result from @fn (already in r0)
>> +mov r8, __NR_exit
>> +ARC_TRAP_INSN
>> +; In case it ever came back
>> +flag1
>> +
>> +.L__sys_err:
> 
> Can't you use L(...) macro as other architectures? 

OK will do.

> 
>> diff --git a/sysdeps/unix/sysv/linux/arc/mmap_internal.h 
>> b/sysdeps/unix/sysv/linux/arc/mmap_internal.h
>> new file mode 100644
>> index ..19aa078dd45e
>> --- /dev/null
>> +++ b/sysdeps/unix/sysv/linux/arc/mmap_internal.h
>> @@ -0,0 +1,27 @@
>> +/* mmap - map files or devices into memory.  Linux/ARC version.
>> +   Copyright (C) 2017-2020 Free Software Foundation, Inc.
>> +   This file is part of the GNU C Library.
>> +
>> +   The GNU C Library is free software; you can redistribute it and/or
>> +   modify it under the terms of the GNU Lesser General Public
>> +   License as published by the Free Software Foundation; either
>> +   version 2.1 of the License, or (at your option) any later version.
>> +
>> +   The GNU C Library is distributed in the hope that it will be useful,
>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> +   Lesser General Public License for more details.
>> +
>> +   You should have received a copy of the GNU Lesser General Public
>> +   License along with the GNU C Library; if not, see
>> +   

[PATCH 1/5] ARC/dl-runtime helper macros

2020-05-29 Thread Vineet Gupta
This is purely for review purposes to attest the interface defined
in prior patch
---
 sysdeps/arc/dl-runtime.h | 42 
 1 file changed, 42 insertions(+)
 create mode 100644 sysdeps/arc/dl-runtime.h

diff --git a/sysdeps/arc/dl-runtime.h b/sysdeps/arc/dl-runtime.h
new file mode 100644
index ..529d49f5d0a1
--- /dev/null
+++ b/sysdeps/arc/dl-runtime.h
@@ -0,0 +1,42 @@
+/* Helpers for On-demand PLT fixup for shared objects. ARC version.
+   Copyright (C) 2017-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+/* PLT jump into resolver passes PC of PLTn, while _dl_fixup expects the
+   address of corresponding .rela.plt entry.
+
+- @plt0: runtime pc of first plt entry (DT_PLTGOT)
+- @pltn: runtime pc of plt entry being resolved
+- @size: size of .plt.rela entry (unused).  */
+static inline uintptr_t
+reloc_index (uintptr_t plt0, uintptr_t pltn, size_t size)
+{
+  unsigned long int idx = (unsigned long)pltn - (unsigned long)plt0;
+
+  /* PLT trampoline is 16 bytes. */
+  idx /= 16;
+
+  /* Exclude PLT0 and PLT1.  */
+  return idx - 2;
+}
+
+static inline uintptr_t
+reloc_offset (uintptr_t plt0, uintptr_t pltn)
+{
+  size_t sz = sizeof (ElfW(Rela));
+  return reloc_index(plt0, pltn, sz) * sz;
+}
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 3/5] iee754: prvoide gcc builtins based generic fma functions

2020-05-29 Thread Vineet Gupta
---
 sysdeps/generic/math-use-builtins.h | 4 
 sysdeps/ieee754/dbl-64/s_fma.c  | 6 ++
 sysdeps/ieee754/dbl-64/s_fmaf.c | 6 ++
 sysdeps/ieee754/float128/float128_private.h | 2 ++
 sysdeps/ieee754/ldbl-128/s_fmal.c   | 5 +
 5 files changed, 23 insertions(+)

diff --git a/sysdeps/generic/math-use-builtins.h 
b/sysdeps/generic/math-use-builtins.h
index fc724c824a17..9e96807a3370 100644
--- a/sysdeps/generic/math-use-builtins.h
+++ b/sysdeps/generic/math-use-builtins.h
@@ -63,4 +63,8 @@
 #define USE_SQRT_BUILTIN 0
 #define USE_SQRTF_BUILTIN 0
 
+#define USE_FMA_BUILTIN 0
+#define USE_FMAF_BUILTIN 0
+#define USE_FMAL_BUILTIN 0
+
 #endif /* math-use-builtins.h */
diff --git a/sysdeps/ieee754/dbl-64/s_fma.c b/sysdeps/ieee754/dbl-64/s_fma.c
index 876df6e78bdc..1e4b2da1511d 100644
--- a/sysdeps/ieee754/dbl-64/s_fma.c
+++ b/sysdeps/ieee754/dbl-64/s_fma.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* This implementation uses rounding to odd to avoid problems with
double rounding.  See a paper by Boldo and Melquiond:
@@ -33,6 +34,10 @@
 double
 __fma (double x, double y, double z)
 {
+#if USE_FMA_BUILTIN
+  return __builtin_fma (x);
+#else
+  /* Use generic implementation.  */
   union ieee754_double u, v, w;
   int adjust = 0;
   u.d = x;
@@ -292,6 +297,7 @@ __fma (double x, double y, double z)
   v.ieee.mantissa1 |= j;
   return v.d * 0x1p-108;
 }
+#endif /* ! USE_FMA_BUILTIN  */
 }
 #ifndef __fma
 libm_alias_double (__fma, fma)
diff --git a/sysdeps/ieee754/dbl-64/s_fmaf.c b/sysdeps/ieee754/dbl-64/s_fmaf.c
index 57329d0a87fe..f15b18262124 100644
--- a/sysdeps/ieee754/dbl-64/s_fmaf.c
+++ b/sysdeps/ieee754/dbl-64/s_fmaf.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* This implementation relies on double being more than twice as
precise as float and uses rounding to odd in order to avoid problems
@@ -33,6 +34,10 @@
 float
 __fmaf (float x, float y, float z)
 {
+#if USE_FMAF_BUILTIN
+  return __builtin_fmaf (x);
+#else
+  /* Use generic implementation.  */
   fenv_t env;
 
   /* Multiplication is always exact.  */
@@ -60,6 +65,7 @@ __fmaf (float x, float y, float z)
 
   /* And finally truncation with round to nearest.  */
   return (float) u.d;
+#endif /* ! USE_FMAF_BUILTIN  */
 }
 #ifndef __fmaf
 libm_alias_float (__fma, fma)
diff --git a/sysdeps/ieee754/float128/float128_private.h 
b/sysdeps/ieee754/float128/float128_private.h
index f97463d9dc1b..a697a7c29038 100644
--- a/sysdeps/ieee754/float128/float128_private.h
+++ b/sysdeps/ieee754/float128/float128_private.h
@@ -154,6 +154,8 @@
 #define USE_ROUNDL_BUILTIN USE_ROUNDF128_BUILTIN
 #undef USE_COPYSIGNL_BUILTIN
 #define USE_COPYSIGNL_BUILTIN USE_COPYSIGNF128_BUILTIN
+#undef USE_FMAL_BUILTIN
+#define USE_FMAL_BUILTIN USE_FMA128_BUILTIN
 
 /* IEEE function renames.  */
 #define __ieee754_acoshl __ieee754_acoshf128
diff --git a/sysdeps/ieee754/ldbl-128/s_fmal.c 
b/sysdeps/ieee754/ldbl-128/s_fmal.c
index 7475015bcec6..1403734a5aeb 100644
--- a/sysdeps/ieee754/ldbl-128/s_fmal.c
+++ b/sysdeps/ieee754/ldbl-128/s_fmal.c
@@ -25,6 +25,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* This implementation uses rounding to odd to avoid problems with
double rounding.  See a paper by Boldo and Melquiond:
@@ -33,6 +34,9 @@
 _Float128
 __fmal (_Float128 x, _Float128 y, _Float128 z)
 {
+#if USE_FMAL_BUILTIN
+  return __builtin_fmal (x);
+#else
   union ieee854_long_double u, v, w;
   int adjust = 0;
   u.d = x;
@@ -296,5 +300,6 @@ __fmal (_Float128 x, _Float128 y, _Float128 z)
   v.ieee.mantissa3 |= j;
   return v.d * L(0x1p-228);
 }
+#endif /* ! USE_FMAL_BUILTIN  */
 }
 libm_alias_ldouble (__fma, fma)
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 2/5] iee754: prvoide gcc builtins based generic sqrt functions

2020-05-29 Thread Vineet Gupta
---
 sysdeps/generic/math-use-builtins.h | 3 +++
 sysdeps/ieee754/dbl-64/e_sqrt.c | 6 ++
 sysdeps/ieee754/flt-32/e_sqrtf.c| 6 ++
 3 files changed, 15 insertions(+)

diff --git a/sysdeps/generic/math-use-builtins.h 
b/sysdeps/generic/math-use-builtins.h
index 8a39ef58bc95..fc724c824a17 100644
--- a/sysdeps/generic/math-use-builtins.h
+++ b/sysdeps/generic/math-use-builtins.h
@@ -60,4 +60,7 @@
 # define USE_COPYSIGNF128_BUILTIN 0
 #endif
 
+#define USE_SQRT_BUILTIN 0
+#define USE_SQRTF_BUILTIN 0
+
 #endif /* math-use-builtins.h */
diff --git a/sysdeps/ieee754/dbl-64/e_sqrt.c b/sysdeps/ieee754/dbl-64/e_sqrt.c
index d42a1a4eb6e9..518a8ae5cdaf 100644
--- a/sysdeps/ieee754/dbl-64/e_sqrt.c
+++ b/sysdeps/ieee754/dbl-64/e_sqrt.c
@@ -41,6 +41,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /*/
 /* An ultimate sqrt routine. Given an IEEE double machine number x   */
@@ -50,6 +51,10 @@
 double
 __ieee754_sqrt (double x)
 {
+#if USE_SQRT_BUILTIN
+  return __builtin_sqrt (x);
+#else
+  /* Use generic implementation.  */
   static const double
 rt0 = 9.859990725855365213134618E-01,
 rt1 = 4.495955425917856814202739E-01,
@@ -138,6 +143,7 @@ __ieee754_sqrt (double x)
return (x - x) / (x - x); /* sqrt(-ve)=sNaN */
   return 0x1p-256 * __ieee754_sqrt (x * 0x1p512);
 }
+#endif /* ! USE_SQRT_BUILTIN  */
 }
 #ifndef __ieee754_sqrt
 libm_alias_finite (__ieee754_sqrt, __sqrt)
diff --git a/sysdeps/ieee754/flt-32/e_sqrtf.c b/sysdeps/ieee754/flt-32/e_sqrtf.c
index b339444301aa..68fc80e1e1ee 100644
--- a/sysdeps/ieee754/flt-32/e_sqrtf.c
+++ b/sysdeps/ieee754/flt-32/e_sqrtf.c
@@ -16,12 +16,17 @@
 #include 
 #include 
 #include 
+#include 
 
 static const float one = 1.0, tiny=1.0e-30;
 
 float
 __ieee754_sqrtf(float x)
 {
+#if USE_SQRTF_BUILTIN
+   return __builtin_sqrtf (x);
+#else
+   /* Use generic implementation.  */
float z;
int32_t sign = (int)0x8000;
int32_t ix,s,q,m,t,i;
@@ -83,6 +88,7 @@ __ieee754_sqrtf(float x)
ix += (m <<23);
SET_FLOAT_WORD(z,ix);
return z;
+#endif /* ! USE_SQRTF_BUILTIN  */
 }
 #ifndef __ieee754_sqrtf
 libm_alias_finite (__ieee754_sqrtf, __sqrtf)
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 4/5] aarch/fpu: use generic sqrt, fma functions

2020-05-29 Thread Vineet Gupta
Signed-off-by: Vineet Gupta 
---
 sysdeps/aarch64/fpu/e_sqrt.c| 27 --
 sysdeps/aarch64/fpu/e_sqrtf.c   | 27 --
 sysdeps/aarch64/fpu/math-use-builtins.h | 70 +
 sysdeps/aarch64/fpu/s_fma.c | 28 --
 sysdeps/aarch64/fpu/s_fmaf.c| 28 --
 5 files changed, 70 insertions(+), 110 deletions(-)
 delete mode 100644 sysdeps/aarch64/fpu/e_sqrt.c
 delete mode 100644 sysdeps/aarch64/fpu/e_sqrtf.c
 create mode 100644 sysdeps/aarch64/fpu/math-use-builtins.h
 delete mode 100644 sysdeps/aarch64/fpu/s_fma.c
 delete mode 100644 sysdeps/aarch64/fpu/s_fmaf.c

diff --git a/sysdeps/aarch64/fpu/e_sqrt.c b/sysdeps/aarch64/fpu/e_sqrt.c
deleted file mode 100644
index abb67ef7b061..
--- a/sysdeps/aarch64/fpu/e_sqrt.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Square root of floating point number.
-   Copyright (C) 2015-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   .  */
-
-#include 
-#include 
-
-double
-__ieee754_sqrt (double d)
-{
-  return __builtin_sqrt (d);
-}
-libm_alias_finite (__ieee754_sqrt, __sqrt)
diff --git a/sysdeps/aarch64/fpu/e_sqrtf.c b/sysdeps/aarch64/fpu/e_sqrtf.c
deleted file mode 100644
index 13008a4f45d6..
--- a/sysdeps/aarch64/fpu/e_sqrtf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Single-precision floating point square root.
-   Copyright (C) 2015-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   .  */
-
-#include 
-#include 
-
-float
-__ieee754_sqrtf (float s)
-{
-  return __builtin_sqrtf (s);
-}
-libm_alias_finite (__ieee754_sqrtf, __sqrtf)
diff --git a/sysdeps/aarch64/fpu/math-use-builtins.h 
b/sysdeps/aarch64/fpu/math-use-builtins.h
new file mode 100644
index ..52f0a0dad6dd
--- /dev/null
+++ b/sysdeps/aarch64/fpu/math-use-builtins.h
@@ -0,0 +1,70 @@
+/* Using math gcc builtins instead of generic implementation.  aarch64 version.
+   Copyright (C) 2019-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   .  */
+
+#ifndef MATH_USE_BUILTINS_H
+#define MATH_USE_BUILTINS_H1
+
+#include  /* For __GNUC_PREREQ.  */
+
+/* Define these macros to 1 to use __builtin_xyz instead of the
+   generic implementation.  */
+#define USE_NEARBYINT_BUILTIN 0
+#define USE_NEARBYINTF_BUILTIN 0
+#define USE_NEARBYINTL_BUILTIN 0
+#define USE_NEARBYINTF128_BUILTIN 0
+
+#define USE_RINT_BUILTIN 0
+#define USE_RINTF_BUILTIN 0
+#define USE_RINTL_BUILTIN 0
+#define USE_RINTF128_BUILTIN 0
+
+#define USE_FLOOR_BUILTIN 0
+#define USE_FLOORF_BUILTIN 0
+#define USE_FLOORL_BUILTIN 0
+#define USE_FLOORF128_BUILTIN 0
+
+#define USE_CEIL_BUILTIN 0
+#define USE_CEILF_BUILTIN 0
+#define USE_CEILL_BUILTIN 0
+#define USE_CEILF128_BUILTIN 0
+
+#define USE_TRUNC_BUILTIN 0
+#define USE_TRUNCF_BUILTIN 0
+#define USE_TRUNCL_BUILTIN 0
+#define USE_TRUNCF128_BUILTIN 0
+
+#define USE_ROUND_BUILTIN 0

[PATCH 0/5] use gcc builtins for sqrt and fma functions

2020-05-29 Thread Vineet Gupta
Hi,

This was suggested as part of ARC port review.

Build tested for following targets:

aarch64-linux-gnu arm-linux-gnueabi hppa-linux-gnu x86_64-linux-gnu 
arm-linux-gnueabihf riscv64-linux-gnu-rv64imac-lp64 
riscv64-linux-gnu-rv64imafdc-lp64 powerpc-linux-gnu microblaze-linux-gnu 
nios2-linux-gnu hppa-linux-gnu

Thx,
-Vineet

Vineet Gupta (5):
  ARC/dl-runtime helper macros
  iee754: prvoide gcc builtins based generic sqrt functions
  iee754: prvoide gcc builtins based generic fma functions
  aarch/fpu: use generic sqrt, fma functions
  powerpc/fpu: use generic fma functions

 sysdeps/aarch64/fpu/e_sqrt.c| 27 
 sysdeps/aarch64/fpu/e_sqrtf.c   | 27 
 sysdeps/aarch64/fpu/math-use-builtins.h | 70 +
 sysdeps/aarch64/fpu/s_fma.c | 28 -
 sysdeps/aarch64/fpu/s_fmaf.c| 28 -
 sysdeps/arc/dl-runtime.h| 42 +
 sysdeps/generic/math-use-builtins.h |  7 +++
 sysdeps/ieee754/dbl-64/e_sqrt.c |  6 ++
 sysdeps/ieee754/dbl-64/s_fma.c  |  6 ++
 sysdeps/ieee754/dbl-64/s_fmaf.c |  6 ++
 sysdeps/ieee754/float128/float128_private.h |  2 +
 sysdeps/ieee754/flt-32/e_sqrtf.c|  6 ++
 sysdeps/ieee754/ldbl-128/s_fmal.c   |  5 ++
 sysdeps/powerpc/fpu/math-use-builtins.h | 70 +
 sysdeps/powerpc/fpu/s_fma.c | 27 
 sysdeps/powerpc/fpu/s_fmaf.c| 27 
 16 files changed, 220 insertions(+), 164 deletions(-)
 delete mode 100644 sysdeps/aarch64/fpu/e_sqrt.c
 delete mode 100644 sysdeps/aarch64/fpu/e_sqrtf.c
 create mode 100644 sysdeps/aarch64/fpu/math-use-builtins.h
 delete mode 100644 sysdeps/aarch64/fpu/s_fma.c
 delete mode 100644 sysdeps/aarch64/fpu/s_fmaf.c
 create mode 100644 sysdeps/arc/dl-runtime.h
 create mode 100644 sysdeps/powerpc/fpu/math-use-builtins.h
 delete mode 100644 sysdeps/powerpc/fpu/s_fma.c
 delete mode 100644 sysdeps/powerpc/fpu/s_fmaf.c

-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 5/5] powerpc/fpu: use generic fma functions

2020-05-29 Thread Vineet Gupta
---
 sysdeps/powerpc/fpu/math-use-builtins.h | 70 +
 sysdeps/powerpc/fpu/s_fma.c | 27 --
 sysdeps/powerpc/fpu/s_fmaf.c| 27 --
 3 files changed, 70 insertions(+), 54 deletions(-)
 create mode 100644 sysdeps/powerpc/fpu/math-use-builtins.h
 delete mode 100644 sysdeps/powerpc/fpu/s_fma.c
 delete mode 100644 sysdeps/powerpc/fpu/s_fmaf.c

diff --git a/sysdeps/powerpc/fpu/math-use-builtins.h 
b/sysdeps/powerpc/fpu/math-use-builtins.h
new file mode 100644
index ..9bdde66cf1de
--- /dev/null
+++ b/sysdeps/powerpc/fpu/math-use-builtins.h
@@ -0,0 +1,70 @@
+/* Using math gcc builtins instead of generic implementation.  PowerPC version.
+   Copyright (C) 2019-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   .  */
+
+#ifndef MATH_USE_BUILTINS_H
+#define MATH_USE_BUILTINS_H1
+
+#include  /* For __GNUC_PREREQ.  */
+
+/* Define these macros to 1 to use __builtin_xyz instead of the
+   generic implementation.  */
+#define USE_NEARBYINT_BUILTIN 0
+#define USE_NEARBYINTF_BUILTIN 0
+#define USE_NEARBYINTL_BUILTIN 0
+#define USE_NEARBYINTF128_BUILTIN 0
+
+#define USE_RINT_BUILTIN 0
+#define USE_RINTF_BUILTIN 0
+#define USE_RINTL_BUILTIN 0
+#define USE_RINTF128_BUILTIN 0
+
+#define USE_FLOOR_BUILTIN 0
+#define USE_FLOORF_BUILTIN 0
+#define USE_FLOORL_BUILTIN 0
+#define USE_FLOORF128_BUILTIN 0
+
+#define USE_CEIL_BUILTIN 0
+#define USE_CEILF_BUILTIN 0
+#define USE_CEILL_BUILTIN 0
+#define USE_CEILF128_BUILTIN 0
+
+#define USE_TRUNC_BUILTIN 0
+#define USE_TRUNCF_BUILTIN 0
+#define USE_TRUNCL_BUILTIN 0
+#define USE_TRUNCF128_BUILTIN 0
+
+#define USE_ROUND_BUILTIN 0
+#define USE_ROUNDF_BUILTIN 0
+#define USE_ROUNDL_BUILTIN 0
+#define USE_ROUNDF128_BUILTIN 0
+
+#define USE_COPYSIGNL_BUILTIN 1
+#if __GNUC_PREREQ (7, 0)
+# define USE_COPYSIGNF128_BUILTIN 1
+#else
+# define USE_COPYSIGNF128_BUILTIN 0
+#endif
+
+#define USE_SQRT_BUILTIN 0
+#define USE_SQRTF_BUILTIN 0
+
+#define USE_FMA_BUILTIN 1
+#define USE_FMAF_BUILTIN 1
+#define USE_FMAL_BUILTIN 0
+
+#endif /* math-use-builtins.h */
diff --git a/sysdeps/powerpc/fpu/s_fma.c b/sysdeps/powerpc/fpu/s_fma.c
deleted file mode 100644
index 9ddd13253485..
--- a/sysdeps/powerpc/fpu/s_fma.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Compute x * y + z as ternary operation.  PowerPC version.
-   Copyright (C) 2019-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   .  */
-
-#include 
-#include 
-
-double
-__fma (double x, double y, double z)
-{
-  return __builtin_fma (x, y, z);
-}
-libm_alias_double (__fma, fma)
diff --git a/sysdeps/powerpc/fpu/s_fmaf.c b/sysdeps/powerpc/fpu/s_fmaf.c
deleted file mode 100644
index d132c20125bb..
--- a/sysdeps/powerpc/fpu/s_fmaf.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/* Compute x * y + z as ternary operation.  PowerPC version.
-   Copyright (C) 2019-2020 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the 

Re: [PATCH v6 06/13] ARC: hardware floating point support

2020-05-29 Thread Vineet Gupta
On 5/29/20 7:12 AM, Adhemerval Zanella wrote:
> 
> 
> On 22/04/2020 22:41, Vineet Gupta via Libc-alpha wrote:
>> Signed-off-by: Vineet Gupta 

>> diff --git a/sysdeps/arc/fpu/e_sqrt.c b/sysdeps/arc/fpu/e_sqrt.c
>> +
>> +#include 
>> +#include 
>> +
>> +double
>> +__ieee754_sqrt (double d)
>> +{
>> +  return __builtin_sqrt (d);
>> +}
>> +libm_alias_finite (__ieee754_sqrt, __sqrt)
> 
> I think it is better to extend to math-use-builtins.h for cover 
> e_sqrt{f} so we can also adapt to other architecutes.

Good idea.

Side question: what do s_ / e_ prefixes mean?
The suffix is clear s_roundf (float), s_round (double), s_roundl (128).

>> diff --git a/sysdeps/arc/fpu/e_sqrtf.c b/sysdeps/arc/fpu/e_sqrtf.c
>> new file mode 100644
>> index ..13008a4f45d6
>> --- /dev/null
>> +++ b/sysdeps/arc/fpu/e_sqrtf.c

>> +#include 
>> +#include 
>> +
>> +float
>> +__ieee754_sqrtf (float s)
>> +{
>> +  return __builtin_sqrtf (s);
>> +}
>> +libm_alias_finite (__ieee754_sqrtf, __sqrtf)
> 
> Same as before.

OK.

>> diff --git a/sysdeps/arc/fpu/s_fma.c b/sysdeps/arc/fpu/s_fma.c

>> +
>> +#include 
>> +#include 
>> +
>> +double
>> +__fma (double x, double y, double z)
>> +{
>> +  return __builtin_fma (x, y, z);
>> +}
>> +
>> +libm_alias_double (__fma, fma)
> 
> Same as for sqrt{f}.

OK.


>> diff --git a/sysdeps/arc/fpu/s_fmaf.c b/sysdeps/arc/fpu/s_fmaf.c
>> new file mode 100644
>> index ..544f32e27aec
>> --- /dev/null
>> +++ b/sysdeps/arc/fpu/s_fmaf.c
>> @@ -0,0 +1,28 @@
>> +/* Copyright (C) 2011-2020 Free Software Foundation, Inc.
>> +
>> +   This file is part of the GNU C Library.
>> +
>> +   The GNU C Library is free software; you can redistribute it and/or
>> +   modify it under the terms of the GNU Lesser General Public License as
>> +   published by the Free Software Foundation; either version 2.1 of the
>> +   License, or (at your option) any later version.
>> +
>> +   The GNU C Library is distributed in the hope that it will be useful,
>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> +   Lesser General Public License for more details.
>> +
>> +   You should have received a copy of the GNU Lesser General Public
>> +   License along with the GNU C Library; if not, see
>> +   .  */
>> +
>> +#include 
>> +#include 
>> +
>> +float
>> +__fmaf (float x, float y, float z)
>> +{
>> +  return __builtin_fmaf (x, y, z);
>> +}
>> +
>> +libm_alias_float (__fma, fma)
>> diff --git a/sysdeps/arc/fpu_control.h b/sysdeps/arc/fpu_control.h
>> new file mode 100644
>> index ..121656ff7d8c
>> --- /dev/null
>> +++ b/sysdeps/arc/fpu_control.h
>> @@ -0,0 +1,106 @@
>> +/* FPU control word bits.  ARC version.
>> +   Copyright (C) 2018-2020 Free Software Foundation, Inc.
>> +   This file is part of the GNU C Library.
>> +
>> +   The GNU C Library is free software; you can redistribute it and/or
>> +   modify it under the terms of the GNU Lesser General Public
>> +   License as published by the Free Software Foundation; either
>> +   version 2.1 of the License, or (at your option) any later version.
>> +
>> +   The GNU C Library is distributed in the hope that it will be useful,
>> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
>> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
>> +   Lesser General Public License for more details.
>> +
>> +   You should have received a copy of the GNU Lesser General Public
>> +   License along with the GNU C Library.  If not, see
>> +   .  */
>> +
>> +#ifndef _FPU_CONTROL_H
>> +#define _FPU_CONTROL_H
>> +
>> +/* ARC FPU control register bits.
>> +
>> +  [  0] -> IVE: Enable invalid operation exception.
>> +   if 0, soft exception: status register IV flag set.
>> +   if 1, hardware exception trap (not supported in Linux yet).
>> +  [  1] -> DZE: Enable division by zero exception.
>> +   if 0, soft exception: status register IV flag set.
>> +   if 1, hardware exception: (not supported in Linux yet).
>> +  [9:8] -> RM: Rounding Mode:
>> +   00 - Rounding toward zero.
>> +   01 - Rounding to nearest (default).
>> +   10 - Rounding (up) toward plus infinity.
>> +   11 - Rounding (down)toward minus infinity.
>> +
>> +   ARC FPU status register bits.
>> +
>> +   [ 0]  -> IV: flag invalid operation.
>> +   [ 1]  -> DZ: flag division by zero.
>> +   [ 2]  -> OV: flag Overflow operation.
>> +   [ 3]  -> UV: flag Underflow operation.
>> +   [ 4]  -> IX: flag Inexact operation.
>> +   [31]  -> FWE: Flag Write Enable.
>> +If 1, above flags writable explicitly (clearing),
>> +else IoW and only writable indirectly via bits [12:7].  */
>> +
>> +#include 
>> +
>> +#if !defined(__ARC_FPU_SP__) &&  !defined(__ARC_FPU_DP__)
>> +
>> +# define _FPU_RESERVED 0x
>> +# define _FPU_DEFAULT  0x
>> +typedef 

[PATCH 2/2] ARC/dl-runtime helper macros

2020-05-29 Thread Vineet Gupta
This is purely for review purposes to attest the interface defined
in prior patch
---
 sysdeps/arc/dl-runtime.h | 42 
 1 file changed, 42 insertions(+)
 create mode 100644 sysdeps/arc/dl-runtime.h

diff --git a/sysdeps/arc/dl-runtime.h b/sysdeps/arc/dl-runtime.h
new file mode 100644
index ..529d49f5d0a1
--- /dev/null
+++ b/sysdeps/arc/dl-runtime.h
@@ -0,0 +1,42 @@
+/* Helpers for On-demand PLT fixup for shared objects. ARC version.
+   Copyright (C) 2017-2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public License as
+   published by the Free Software Foundation; either version 2.1 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library.  If not, see
+   .  */
+
+/* PLT jump into resolver passes PC of PLTn, while _dl_fixup expects the
+   address of corresponding .rela.plt entry.
+
+- @plt0: runtime pc of first plt entry (DT_PLTGOT)
+- @pltn: runtime pc of plt entry being resolved
+- @size: size of .plt.rela entry (unused).  */
+static inline uintptr_t
+reloc_index (uintptr_t plt0, uintptr_t pltn, size_t size)
+{
+  unsigned long int idx = (unsigned long)pltn - (unsigned long)plt0;
+
+  /* PLT trampoline is 16 bytes. */
+  idx /= 16;
+
+  /* Exclude PLT0 and PLT1.  */
+  return idx - 2;
+}
+
+static inline uintptr_t
+reloc_offset (uintptr_t plt0, uintptr_t pltn)
+{
+  size_t sz = sizeof (ElfW(Rela));
+  return reloc_index(plt0, pltn, sz) * sz;
+}
-- 
2.20.1


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 1/2] dl-runtime: reloc_{offset, index} now functions arch overide'able

2020-05-29 Thread Vineet Gupta
The existing macros are fragile and expect local variables with a
certain name. Fix this by defining them as functions with default
implementation in a new header dl-runtime.h which arches can override
if need be.

This came up during ARC port review, hence the need for argument pltgot
in reloc_index() which is not needed by existing ports.

This patch potentially only affects hppa/x86 ports,
build tested for both those configs and a few more.

Suggested-by: Adhemerval Zanella 
---
 elf/dl-runtime.c| 28 +---
 elf/dl-runtime.h| 30 ++
 sysdeps/hppa/dl-runtime.c   |  4 
 sysdeps/hppa/dl-runtime.h   | 31 +++
 sysdeps/x86_64/dl-runtime.c |  9 -
 sysdeps/x86_64/dl-runtime.h | 35 +++
 6 files changed, 113 insertions(+), 24 deletions(-)
 create mode 100644 elf/dl-runtime.h
 create mode 100644 sysdeps/hppa/dl-runtime.h
 delete mode 100644 sysdeps/x86_64/dl-runtime.c
 create mode 100644 sysdeps/x86_64/dl-runtime.h

diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
index cf5f1d3e82e1..85a229f6f019 100644
--- a/elf/dl-runtime.c
+++ b/elf/dl-runtime.c
@@ -27,6 +27,7 @@
 #include "dynamic-link.h"
 #include 
 #include 
+#include 
 
 
 #if (!ELF_MACHINE_NO_RELA && !defined ELF_MACHINE_PLT_REL) \
@@ -42,13 +43,6 @@
 # define ARCH_FIXUP_ATTRIBUTE
 #endif
 
-#ifndef reloc_offset
-# define reloc_offset reloc_arg
-# define reloc_index  reloc_arg / sizeof (PLTREL)
-#endif
-
-
-
 /* This function is called through a special trampoline from the PLT the
first time each PLT entry is called.  We must perform the relocation
specified in the PLT of the given shared object, and return the resolved
@@ -68,8 +62,11 @@ _dl_fixup (
 = (const void *) D_PTR (l, l_info[DT_SYMTAB]);
   const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
 
+  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
+
   const PLTREL *const reloc
-= (const void *) (D_PTR (l, l_info[DT_JMPREL]) + reloc_offset);
+= (const void *) (D_PTR (l, l_info[DT_JMPREL])
+ + reloc_offset (pltgot, reloc_arg));
   const ElfW(Sym) *sym = [ELFW(R_SYM) (reloc->r_info)];
   const ElfW(Sym) *refsym = sym;
   void *const rel_addr = (void *)(l->l_addr + reloc->r_offset);
@@ -180,9 +177,12 @@ _dl_profile_fixup (
l, reloc_arg);
 }
 
+  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
+
   /* This is the address in the array where we store the result of previous
  relocations.  */
-  struct reloc_result *reloc_result = >l_reloc_result[reloc_index];
+  struct reloc_result *reloc_result
+= >l_reloc_result[reloc_index (pltgot, reloc_arg, sizeof (PLTREL))];
 
  /* CONCURRENCY NOTES:
 
@@ -219,8 +219,11 @@ _dl_profile_fixup (
= (const void *) D_PTR (l, l_info[DT_SYMTAB]);
   const char *strtab = (const char *) D_PTR (l, l_info[DT_STRTAB]);
 
+  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
+
   const PLTREL *const reloc
-   = (const void *) (D_PTR (l, l_info[DT_JMPREL]) + reloc_offset);
+   = (const void *) (D_PTR (l, l_info[DT_JMPREL])
+ + reloc_offset (pltgot, reloc_arg));
   const ElfW(Sym) *refsym = [ELFW(R_SYM) (reloc->r_info)];
   const ElfW(Sym) *defsym = refsym;
   lookup_t result;
@@ -485,11 +488,14 @@ _dl_call_pltexit (struct link_map *l, ElfW(Word) 
reloc_arg,
  const void *inregs, void *outregs)
 {
 #ifdef SHARED
+  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
+
   /* This is the address in the array where we store the result of previous
  relocations.  */
   // XXX Maybe the bound information must be stored on the stack since
   // XXX with bind_not a new value could have been stored in the meantime.
-  struct reloc_result *reloc_result = >l_reloc_result[reloc_index];
+  struct reloc_result *reloc_result =
+>l_reloc_result[reloc_index (pltgot, reloc_arg, sizeof (PLTREL))];
   ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound,
l_info[DT_SYMTAB])
   + reloc_result->boundndx);
diff --git a/elf/dl-runtime.h b/elf/dl-runtime.h
new file mode 100644
index ..dd87d799465e
--- /dev/null
+++ b/elf/dl-runtime.h
@@ -0,0 +1,30 @@
+/* Helpers for On-demand PLT fixup for shared objects. Generic version.
+   Copyright (C) 2020 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   

Re: [PATCH 3/3] ARC: [plat-hsdk-4xd] initial port for HSDK-4xD board

2020-05-29 Thread Vineet Gupta
+CC Rob H (it seems the CC in patch didn't go thru)

On 5/29/20 4:55 AM, Eugeniy Paltsev wrote:
> This initial port adds support of ARC HS4x/HS4xD Development Kit board with 
> some
> basic features such serial port, USB, SD/MMC, SPI flash, Ethernet and others.
> 
> The HSDK-4xD board has much in common with its predecessor - HSDK board.
> However HSDK-4xD has some differences in comparison with its predecessor:
>  * based on quad core ARC HS48/HS47D processor (instead of quad core ARC HS38)
>  * has ThinkSilicon GPU (instead of Vivante GPU)
>  * has ARC PGU and HDMI output
>  * has separate SDIO controller for WiFi module
>  * has additional timers with clocksource independent from CPU clocksource
>(required for DVFS)
>  * has performance counters interrupt
>  * other minor stuff
> 
> NOTE:
> HSDK-4xD and HSDK may share significant part of DTS so we can move this common
> part to one .dtsi file (as we have done it in U-boot). However we have quite
> enough out of the tree patches for tweaking HSDK DTS (patches in out
> verification flow, patches for run in simulation, etc...), so I'd prefer to
> keep HSDK DTS untouched. That's why HSDK-4xD DTS is created as an separate 
> file.

I agree we need a different version of DTB for wiring up perf interrupt and gpu
(whether full copy or common parts in a dtsi I don't care). But just curious if
the "other" mods to DTS were temporary "hacks" for various testing things or do
you intend to actually productize/upstream them at some point. I mean you can
alsoways create a local copy for those and point your .config to it, do that is
not a reason to create a new dtb !  I know this is bike shedding...


> Cc: Rob Herring 
> Signed-off-by: Eugeniy Paltsev 
> ---
>  arch/arc/boot/dts/hsdk-4xd.dts  | 322 
>  arch/arc/configs/hsdk_4xd_defconfig |  99 +
>  arch/arc/kernel/devtree.c   |   1 +
>  arch/arc/plat-hsdk/Kconfig  |  24 ++-
>  arch/arc/plat-hsdk/platform.c   |   6 +
>  5 files changed, 451 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arc/boot/dts/hsdk-4xd.dts
>  create mode 100644 arch/arc/configs/hsdk_4xd_defconfig
> 
> diff --git a/arch/arc/boot/dts/hsdk-4xd.dts b/arch/arc/boot/dts/hsdk-4xd.dts
> new file mode 100644
> index ..2b7f76a01e3e
> --- /dev/null
> +++ b/arch/arc/boot/dts/hsdk-4xd.dts
> @@ -0,0 +1,322 @@
> +// SPDX-License-Identifier: GPL-2.0-only
> +/*
> + * Copyright (C) 2020 Synopsys, Inc. (www.synopsys.com)
> + */
> +
> +/*
> + * Device Tree for ARC HS4x/HS4xD Development Kit
> + */
> +/dts-v1/;
> +
> +#include 
> +#include 
> +
> +/ {
> + model = "snps,hsdk-4xd";
> + compatible = "snps,hsdk-4xd";
> +
> + #address-cells = <2>;
> + #size-cells = <2>;
> +
> + chosen {
> + bootargs = "earlycon=uart8250,mmio32,0xf0005000,115200n8 
> console=ttyS0,115200n8 debug print-fatal-signals=1";
> + };
> +
> + aliases {
> + ethernet = 
> + };
> +
> + cpus {
> + #address-cells = <1>;
> + #size-cells = <0>;
> +
> + cpu@0 {
> + device_type = "cpu";
> + compatible = "snps,archs48";
> + reg = <0>;
> + clocks = <_clk>;
> + };
> +
> + cpu@1 {
> + device_type = "cpu";
> + compatible = "snps,archs48";
> + reg = <1>;
> + clocks = <_clk>;
> + };
> +
> + cpu@2 {
> + device_type = "cpu";
> + compatible = "snps,archs48";
> + reg = <2>;
> + clocks = <_clk>;
> + };
> +
> + cpu@3 {
> + device_type = "cpu";
> + compatible = "snps,archs48";
> + reg = <3>;
> + clocks = <_clk>;
> + };
> + };
> +
> + input_clk: input-clk {
> + #clock-cells = <0>;
> + compatible = "fixed-clock";
> + clock-frequency = <>;
> + };
> +
> + reg_5v0: regulator-5v0 {
> + compatible = "regulator-fixed";
> +
> + regulator-name = "5v0-supply";
> + regulator-min-microvolt = <500>;
> + regulator-max-microvolt = <500>;
> + };
> +
> + cpu_intc: cpu-interrupt-controller {
> + compatible = "snps,archs-intc";
> + interrupt-controller;
> + #interrupt-cells = <1>;
> + };
> +
> + idu_intc: idu-interrupt-controller {
> + compatible = "snps,archs-idu-intc";
> + interrupt-controller;
> + #interrupt-cells = <1>;
> + interrupt-parent = <_intc>;
> + };
> +
> + arcpct: pct {
> + compatible = "snps,archs-pct";
> + interrupt-parent = <_intc>;
> + interrupts = <20>;
> + };
> +
> + /* TIMER0 with 

Re: [PATCH] dl-runtime: reloc_{offset,index} now functions arch overide'able

2020-05-29 Thread Adhemerval Zanella



On 29/05/2020 14:39, Vineet Gupta wrote:
> On 5/29/20 5:58 AM, Adhemerval Zanella via Libc-alpha wrote:
>>
>>
>> On 28/05/2020 16:43, Vineet Gupta wrote:
>>> The existing macros are fragile and expect local variables with a
>>> certain name. Fix this by defining them as functions with defaul
>>> timplementation in a new header dl-runtime.h which arches can overrid
>>> eif need be.
>>>
>>> This came up during ARC port review.
>>>
>>> This patch potentially only affects hppa/x86 ports,
>>> build tested for both those configs and a few more.
>>>
>>> Suggested-by: Adhemerval Zanella 
>>
>> LGTM, thanks.
>>
>> Reviewed-by: Adhemerval Zanella 
> 
> Sorry I didn't think through this before, but ARC port needs pltgot arg 
> (runtime
> address of plt0) in reloc_index not reloc_offset. I'll swap them and repost.

Hum I though I had it covered on my suggestion, but it seems I mixed them
up. Ok, I will review the new version.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 2/3] ARC: ARCv2: support loop buffer (LPB) disabling

2020-05-29 Thread Vineet Gupta
On 5/29/20 4:55 AM, Eugeniy Paltsev wrote:
> On HS cores, loop buffer (LPB) is programmable in runtime and can
> be optionally disabled.
> 
> Signed-off-by: Eugeniy Paltsev 

LGTM.

-Vineet
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH 1/3] ARC: allow to overide default mcpu compiler flag

2020-05-29 Thread Vineet Gupta
On 5/29/20 4:55 AM, Eugeniy Paltsev wrote:
> By default we set -mcpu=xxx compiler flag depending on the CPU ISA
> version. It's good starting point, however that may be not enough
> as for some platforms we may want to use some specific 'mcpu'
> options for better optimization or to workaround HW issues.
> 
> We are going to use this option for HSDK-4xD board support.
> In addition it also allows to awoid patching 'mcpu' in ARC Makefile
> when we building Linux for some non-standard simulation or FPGA-based
> platforms.
> 
> Signed-off-by: Eugeniy Paltsev 

Question: So now if I build in buildroot with -mhs38_linux, it will use hard 
float
(kernel should not use floating point) but the libgcc linked will be different 
too
and that should be OK ?

I've rewritten the changelog.

  kernel builds set their own default -mcpu for a given ISA build.
  But that gets in the way of "custom" -mcpu flags from propagating
  into kernel build.

  This will also be used in next patches for HSDK-4xD board support which
  uses a different -mcpu to effect dual issue scheduling.



___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] dl-runtime: reloc_{offset,index} now functions arch overide'able

2020-05-29 Thread Vineet Gupta
On 5/29/20 5:58 AM, Adhemerval Zanella via Libc-alpha wrote:
> 
> 
> On 28/05/2020 16:43, Vineet Gupta wrote:
>> The existing macros are fragile and expect local variables with a
>> certain name. Fix this by defining them as functions with defaul
>> timplementation in a new header dl-runtime.h which arches can overrid
>> eif need be.
>>
>> This came up during ARC port review.
>>
>> This patch potentially only affects hppa/x86 ports,
>> build tested for both those configs and a few more.
>>
>> Suggested-by: Adhemerval Zanella 
> 
> LGTM, thanks.
> 
> Reviewed-by: Adhemerval Zanella 

Sorry I didn't think through this before, but ARC port needs pltgot arg (runtime
address of plt0) in reloc_index not reloc_offset. I'll swap them and repost.

>>  /* This function is called through a special trampoline from the PLT the
>> first time each PLT entry is called.  We must perform the relocation
>> specified in the PLT of the given shared object, and return the resolved
>> @@ -68,8 +62,11 @@ _dl_fixup (
>>  = (const void *) D_PTR (l, l_info[DT_SYMTAB]);
>>const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
>>  
>> +  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
>> +
>>const PLTREL *const reloc
>> -= (const void *) (D_PTR (l, l_info[DT_JMPREL]) + reloc_offset);
>> += (const void *) (D_PTR (l, l_info[DT_JMPREL])
>> +  + reloc_offset (pltgot, reloc_arg));
>>const ElfW(Sym) *sym = [ELFW(R_SYM) (reloc->r_info)];
>>const ElfW(Sym) *refsym = sym;
>>void *const rel_addr = (void *)(l->l_addr + reloc->r_offset);
> 
> Ok (it should be dead code eliminated by compiler if reloc_offset does not
> use the pltgot field, as for default implementation).

Yep.

> 
>> diff --git a/elf/dl-runtime.h b/elf/dl-runtime.h
>> new file mode 100644
>> index ..ed5db3ba51b7
>> --- /dev/null
>> +++ b/elf/dl-runtime.h
>> @@ -0,0 +1,30 @@
>> +/* Helpers for On-demand PLT fixup for shared objects, Generic version.
> 
> Maybe period here?

OK


>> diff --git a/sysdeps/hppa/dl-runtime.h b/sysdeps/hppa/dl-runtime.h
>> new file mode 100644
>> index ..cfde0ec991e3
>> --- /dev/null
>> +++ b/sysdeps/hppa/dl-runtime.h
>> @@ -0,0 +1,31 @@
>> +/* Helpers for On-demand PLT fixup for shared objects, HPAA version.
> 
> Maybe period instead of comma here?

OK.
___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH v6 07/13] ARC: Linux Syscall Interface

2020-05-29 Thread Adhemerval Zanella



On 22/04/2020 22:41, Vineet Gupta via Libc-alpha wrote:
> Signed-off-by: Vineet Gupta 

As prior patches we do not use DCO, but rather copyright assignment.

Some comments below.

> ---
>  sysdeps/unix/sysv/linux/arc/arch-syscall.h| 303 ++
>  sysdeps/unix/sysv/linux/arc/bits/timesize.h   |  21 ++
>  sysdeps/unix/sysv/linux/arc/clone.S   |  98 ++
>  .../unix/sysv/linux/arc/fixup-asm-unistd.h|  41 +++
>  sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h  |   6 +
>  sysdeps/unix/sysv/linux/arc/kernel-features.h |  28 ++
>  sysdeps/unix/sysv/linux/arc/kernel_stat.h |  26 ++
>  sysdeps/unix/sysv/linux/arc/mmap_internal.h   |  27 ++
>  sysdeps/unix/sysv/linux/arc/pt-vfork.S|   1 +
>  sysdeps/unix/sysv/linux/arc/sigaction.c   |  31 ++
>  sysdeps/unix/sysv/linux/arc/sigrestorer.S |  29 ++
>  sysdeps/unix/sysv/linux/arc/syscall.S |  33 ++
>  sysdeps/unix/sysv/linux/arc/syscalls.list |   3 +
>  sysdeps/unix/sysv/linux/arc/sysctl.mk |   1 +
>  sysdeps/unix/sysv/linux/arc/sysdep.c  |  33 ++
>  sysdeps/unix/sysv/linux/arc/sysdep.h  | 224 +
>  sysdeps/unix/sysv/linux/arc/vfork.S   |  42 +++
>  17 files changed, 947 insertions(+)
>  create mode 100644 sysdeps/unix/sysv/linux/arc/arch-syscall.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/bits/timesize.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/clone.S
>  create mode 100644 sysdeps/unix/sysv/linux/arc/fixup-asm-unistd.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/jmp_buf-macros.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/kernel-features.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/kernel_stat.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/mmap_internal.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/pt-vfork.S
>  create mode 100644 sysdeps/unix/sysv/linux/arc/sigaction.c
>  create mode 100644 sysdeps/unix/sysv/linux/arc/sigrestorer.S
>  create mode 100644 sysdeps/unix/sysv/linux/arc/syscall.S
>  create mode 100644 sysdeps/unix/sysv/linux/arc/syscalls.list
>  create mode 100644 sysdeps/unix/sysv/linux/arc/sysctl.mk
>  create mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.c
>  create mode 100644 sysdeps/unix/sysv/linux/arc/sysdep.h
>  create mode 100644 sysdeps/unix/sysv/linux/arc/vfork.S
> 
> diff --git a/sysdeps/unix/sysv/linux/arc/arch-syscall.h 
> b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
> new file mode 100644
> index ..2b017eb5bbaa
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/arc/arch-syscall.h
> @@ -0,0 +1,303 @@
> +/* AUTOGENERATED by update-syscall-lists.py.  */
> +#define __NR_accept 202
> +#define __NR_accept4 242
> +#define __NR_acct 89
> +#define __NR_add_key 217
> +#define __NR_adjtimex 171
> +#define __NR_arc_gettls 246
> +#define __NR_arc_settls 245
> +#define __NR_arc_usr_cmpxchg 248
> +#define __NR_bind 200
> +#define __NR_bpf 280
> +#define __NR_brk 214
> +#define __NR_cacheflush 244
> +#define __NR_capget 90
> +#define __NR_capset 91
> +#define __NR_chdir 49
> +#define __NR_chroot 51
> +#define __NR_clock_adjtime64 405
> +#define __NR_clock_getres_time64 406
> +#define __NR_clock_gettime 113
> +#define __NR_clock_gettime64 403
> +#define __NR_clock_nanosleep 115
> +#define __NR_clock_nanosleep_time64 407
> +#define __NR_clock_settime 112
> +#define __NR_clock_settime64 404
> +#define __NR_clone 220
> +#define __NR_clone3 435
> +#define __NR_close 57
> +#define __NR_connect 203
> +#define __NR_copy_file_range 285
> +#define __NR_delete_module 106
> +#define __NR_dup 23
> +#define __NR_dup3 24
> +#define __NR_epoll_create1 20
> +#define __NR_epoll_ctl 21
> +#define __NR_epoll_pwait 22
> +#define __NR_eventfd2 19
> +#define __NR_execve 221
> +#define __NR_execveat 281
> +#define __NR_exit 93
> +#define __NR_exit_group 94
> +#define __NR_faccessat 48
> +#define __NR_fadvise64_64 223
> +#define __NR_fallocate 47
> +#define __NR_fanotify_init 262
> +#define __NR_fanotify_mark 263
> +#define __NR_fchdir 50
> +#define __NR_fchmod 52
> +#define __NR_fchmodat 53
> +#define __NR_fchown 55
> +#define __NR_fchownat 54
> +#define __NR_fcntl64 25
> +#define __NR_fdatasync 83
> +#define __NR_fgetxattr 10
> +#define __NR_finit_module 273
> +#define __NR_flistxattr 13
> +#define __NR_flock 32
> +#define __NR_fremovexattr 16
> +#define __NR_fsconfig 431
> +#define __NR_fsetxattr 7
> +#define __NR_fsmount 432
> +#define __NR_fsopen 430
> +#define __NR_fspick 433
> +#define __NR_fstatfs64 44
> +#define __NR_fsync 82
> +#define __NR_ftruncate64 46
> +#define __NR_futex_time64 422
> +#define __NR_get_mempolicy 236
> +#define __NR_get_robust_list 100
> +#define __NR_getcpu 168
> +#define __NR_getcwd 17
> +#define __NR_getdents64 61
> +#define __NR_getegid 177
> +#define __NR_geteuid 175
> +#define __NR_getgid 176
> +#define __NR_getgroups 158
> +#define __NR_getitimer 102
> +#define __NR_getpeername 205
> +#define __NR_getpgid 155
> +#define __NR_getpid 172
> +#define __NR_getppid 173
> +#define 

Re: [PATCH v6 06/13] ARC: hardware floating point support

2020-05-29 Thread Adhemerval Zanella



On 22/04/2020 22:41, Vineet Gupta via Libc-alpha wrote:
> Signed-off-by: Vineet Gupta 

As prior patch we do not use DCO, but rather copyright assignment.

Some comments below.

> ---
>  sysdeps/arc/fpu/e_sqrt.c|  27 
>  sysdeps/arc/fpu/e_sqrtf.c   |  27 
>  sysdeps/arc/fpu/fclrexcpt.c |  36 +++
>  sysdeps/arc/fpu/fegetenv.c  |  37 +++
>  sysdeps/arc/fpu/fegetmode.c |  31 ++
>  sysdeps/arc/fpu/fegetround.c|  32 ++
>  sysdeps/arc/fpu/feholdexcpt.c   |  43 +
>  sysdeps/arc/fpu/fesetenv.c  |  48 +++
>  sysdeps/arc/fpu/fesetexcept.c   |  32 ++
>  sysdeps/arc/fpu/fesetmode.c |  40 
>  sysdeps/arc/fpu/fesetround.c|  40 
>  sysdeps/arc/fpu/feupdateenv.c   |  51 +++
>  sysdeps/arc/fpu/fgetexcptflg.c  |  31 ++
>  sysdeps/arc/fpu/fraiseexcpt.c   |  39 
>  sysdeps/arc/fpu/fsetexcptflg.c  |  38 
>  sysdeps/arc/fpu/ftestexcept.c   |  33 ++
>  sysdeps/arc/fpu/s_fma.c |  28 +
>  sysdeps/arc/fpu/s_fmaf.c|  28 +
>  sysdeps/arc/fpu_control.h   | 106 
>  sysdeps/arc/get-rounding-mode.h |  38 
>  sysdeps/arc/math-tests-trap.h   |  27 
>  sysdeps/arc/tininess.h  |   1 +
>  22 files changed, 813 insertions(+)
>  create mode 100644 sysdeps/arc/fpu/e_sqrt.c
>  create mode 100644 sysdeps/arc/fpu/e_sqrtf.c
>  create mode 100644 sysdeps/arc/fpu/fclrexcpt.c
>  create mode 100644 sysdeps/arc/fpu/fegetenv.c
>  create mode 100644 sysdeps/arc/fpu/fegetmode.c
>  create mode 100644 sysdeps/arc/fpu/fegetround.c
>  create mode 100644 sysdeps/arc/fpu/feholdexcpt.c
>  create mode 100644 sysdeps/arc/fpu/fesetenv.c
>  create mode 100644 sysdeps/arc/fpu/fesetexcept.c
>  create mode 100644 sysdeps/arc/fpu/fesetmode.c
>  create mode 100644 sysdeps/arc/fpu/fesetround.c
>  create mode 100644 sysdeps/arc/fpu/feupdateenv.c
>  create mode 100644 sysdeps/arc/fpu/fgetexcptflg.c
>  create mode 100644 sysdeps/arc/fpu/fraiseexcpt.c
>  create mode 100644 sysdeps/arc/fpu/fsetexcptflg.c
>  create mode 100644 sysdeps/arc/fpu/ftestexcept.c
>  create mode 100644 sysdeps/arc/fpu/s_fma.c
>  create mode 100644 sysdeps/arc/fpu/s_fmaf.c
>  create mode 100644 sysdeps/arc/fpu_control.h
>  create mode 100644 sysdeps/arc/get-rounding-mode.h
>  create mode 100644 sysdeps/arc/math-tests-trap.h
>  create mode 100644 sysdeps/arc/tininess.h
> 
> diff --git a/sysdeps/arc/fpu/e_sqrt.c b/sysdeps/arc/fpu/e_sqrt.c
> new file mode 100644
> index ..abb67ef7b061
> --- /dev/null
> +++ b/sysdeps/arc/fpu/e_sqrt.c
> @@ -0,0 +1,27 @@
> +/* Square root of floating point number.
> +   Copyright (C) 2015-2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   .  */
> +
> +#include 
> +#include 
> +
> +double
> +__ieee754_sqrt (double d)
> +{
> +  return __builtin_sqrt (d);
> +}
> +libm_alias_finite (__ieee754_sqrt, __sqrt)

I think it is better to extend to math-use-builtins.h for cover 
e_sqrt{f} so we can also adapt to other architecutes.

> diff --git a/sysdeps/arc/fpu/e_sqrtf.c b/sysdeps/arc/fpu/e_sqrtf.c
> new file mode 100644
> index ..13008a4f45d6
> --- /dev/null
> +++ b/sysdeps/arc/fpu/e_sqrtf.c
> @@ -0,0 +1,27 @@
> +/* Single-precision floating point square root.
> +   Copyright (C) 2015-2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> +   Lesser General Public License for more details.
> +
> +   You should have received a copy of the GNU Lesser General Public
> +   License along with the GNU C Library; if not, see
> +   .  */
> +
> +#include 
> +#include 
> +
> +float
> 

Re: [PATCH v6 01/13] ARC: ABI Implementation

2020-05-29 Thread Adhemerval Zanella



On 27/05/2020 19:15, Vineet Gupta wrote:
> On 5/27/20 11:26 AM, Adhemerval Zanella via Libc-alpha wrote:
>>
>>
>> On 22/04/2020 22:41, Vineet Gupta via Libc-alpha wrote:
>>> This code deals with the ARC ABI.
>>>
>>> Signed-off-by: Vineet Gupta 
>>
>> We do not use DCO, but rather copyright assignment.
> 
> Right, removed that now.
> 
>> Looks ok in general, with some comments below.
> 
> Thx for taking a look.
> 
>>> +;@ r1 = value that setjmp( ) will return due to this longjmp
>>
>> Since all .S files are processed by gcc assembly implementation usually
>> use C style comment (/* ... */). Same applies to other assembly
>> implementations.
> 
> OK, I can update throughout, although I like the small assembler comments 
> which
> are on the same line.

I don't have a strong preference and I am not sure if there is a strict
code guideline for comment in assembly implementations. It was more a
suggestion, since other assembly implementations tend to use C style
comment as well.


>>> diff --git a/sysdeps/arc/memusage.h b/sysdeps/arc/memusage.h
> 
>>> +
>>> +#define GETSP() ({ register uintptr_t stack_ptr asm ("sp"); stack_ptr; })
>>> +
>>> +#define uatomic32_t unsigned int
>>
>> Not sure if this is really required now that we are moving to C11 atomic
>> model withing glibc itself. Maybe we could just use uint32_t on
>> malloc/memusage.c and rely on atomic macros instead.
> 
> But that would be much bigger change, and orthogonal to the port. So perhaps 
> we
> add it for now and then do the bigger/sweeping change.
> 

Indeed, it was more a open note for a future cleanup. The current
definition is fine as is.

___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


Re: [PATCH] dl-runtime: reloc_{offset,index} now functions arch overide'able

2020-05-29 Thread Adhemerval Zanella



On 28/05/2020 16:43, Vineet Gupta wrote:
> The existing macros are fragile and expect local variables with a
> certain name. Fix this by defining them as functions with defaul
> timplementation in a new header dl-runtime.h which arches can overrid
> eif need be.
> 
> This came up during ARC port review.
> 
> This patch potentially only affects hppa/x86 ports,
> build tested for both those configs and a few more.
> 
> Suggested-by: Adhemerval Zanella 

LGTM, thanks.

Reviewed-by: Adhemerval Zanella 

> ---
>  elf/dl-runtime.c  | 24 +++---
>  elf/dl-runtime.h  | 30 ++
>  sysdeps/hppa/dl-runtime.c |  4 ---
>  sysdeps/hppa/dl-runtime.h | 31 +++
>  sysdeps/x86_64/{dl-runtime.c => dl-runtime.h} | 13 ++--
>  5 files changed, 84 insertions(+), 18 deletions(-)
>  create mode 100644 elf/dl-runtime.h
>  create mode 100644 sysdeps/hppa/dl-runtime.h
>  rename sysdeps/x86_64/{dl-runtime.c => dl-runtime.h} (60%)
> 
> diff --git a/elf/dl-runtime.c b/elf/dl-runtime.c
> index cf5f1d3e82e1..62f90579370b 100644
> --- a/elf/dl-runtime.c
> +++ b/elf/dl-runtime.c
> @@ -27,6 +27,7 @@
>  #include "dynamic-link.h"
>  #include 
>  #include 
> +#include 
>  
>  
>  #if (!ELF_MACHINE_NO_RELA && !defined ELF_MACHINE_PLT_REL) \
> @@ -42,13 +43,6 @@
>  # define ARCH_FIXUP_ATTRIBUTE
>  #endif
>  
> -#ifndef reloc_offset
> -# define reloc_offset reloc_arg
> -# define reloc_index  reloc_arg / sizeof (PLTREL)
> -#endif
> -
> -
> -
>  /* This function is called through a special trampoline from the PLT the
> first time each PLT entry is called.  We must perform the relocation
> specified in the PLT of the given shared object, and return the resolved
> @@ -68,8 +62,11 @@ _dl_fixup (
>  = (const void *) D_PTR (l, l_info[DT_SYMTAB]);
>const char *strtab = (const void *) D_PTR (l, l_info[DT_STRTAB]);
>  
> +  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
> +
>const PLTREL *const reloc
> -= (const void *) (D_PTR (l, l_info[DT_JMPREL]) + reloc_offset);
> += (const void *) (D_PTR (l, l_info[DT_JMPREL])
> +   + reloc_offset (pltgot, reloc_arg));
>const ElfW(Sym) *sym = [ELFW(R_SYM) (reloc->r_info)];
>const ElfW(Sym) *refsym = sym;
>void *const rel_addr = (void *)(l->l_addr + reloc->r_offset);

Ok (it should be dead code eliminated by compiler if reloc_offset does not
use the pltgot field, as for default implementation).

> @@ -182,7 +179,8 @@ _dl_profile_fixup (
>  
>/* This is the address in the array where we store the result of previous
>   relocations.  */
> -  struct reloc_result *reloc_result = >l_reloc_result[reloc_index];
> +  struct reloc_result *reloc_result
> += >l_reloc_result[reloc_index (reloc_arg, sizeof (PLTREL))];
>  
>   /* CONCURRENCY NOTES:
>  
> @@ -219,8 +217,11 @@ _dl_profile_fixup (
>   = (const void *) D_PTR (l, l_info[DT_SYMTAB]);
>const char *strtab = (const char *) D_PTR (l, l_info[DT_STRTAB]);
>  
> +  const uintptr_t pltgot = (uintptr_t) D_PTR (l, l_info[DT_PLTGOT]);
> +
>const PLTREL *const reloc
> - = (const void *) (D_PTR (l, l_info[DT_JMPREL]) + reloc_offset);
> + = (const void *) (D_PTR (l, l_info[DT_JMPREL])
> +   + reloc_offset (pltgot, reloc_arg));
>const ElfW(Sym) *refsym = [ELFW(R_SYM) (reloc->r_info)];
>const ElfW(Sym) *defsym = refsym;
>lookup_t result;
> @@ -489,7 +490,8 @@ _dl_call_pltexit (struct link_map *l, ElfW(Word) 
> reloc_arg,
>   relocations.  */
>// XXX Maybe the bound information must be stored on the stack since
>// XXX with bind_not a new value could have been stored in the meantime.
> -  struct reloc_result *reloc_result = >l_reloc_result[reloc_index];
> +  struct reloc_result *reloc_result =
> +>l_reloc_result[reloc_index (reloc_arg, sizeof (PLTREL))];
>ElfW(Sym) *defsym = ((ElfW(Sym) *) D_PTR (reloc_result->bound,
>   l_info[DT_SYMTAB])
>  + reloc_result->boundndx);

Ok.

> diff --git a/elf/dl-runtime.h b/elf/dl-runtime.h
> new file mode 100644
> index ..ed5db3ba51b7
> --- /dev/null
> +++ b/elf/dl-runtime.h
> @@ -0,0 +1,30 @@
> +/* Helpers for On-demand PLT fixup for shared objects, Generic version.

Maybe period here?

> +   Copyright (C) 2020 Free Software Foundation, Inc.
> +   This file is part of the GNU C Library.
> +
> +   The GNU C Library is free software; you can redistribute it and/or
> +   modify it under the terms of the GNU Lesser General Public
> +   License as published by the Free Software Foundation; either
> +   version 2.1 of the License, or (at your option) any later version.
> +
> +   The GNU C Library is distributed in the hope that it will be useful,
> +   but WITHOUT ANY WARRANTY; without even the implied warranty of
> +   MERCHANTABILITY or FITNESS FOR A PARTICULAR 

Re: [PATCH private 1/3] ARC: allow to overwrite default mcpu compiler flag

2020-05-29 Thread Eugeniy Paltsev
Oooops, this one is duplicate and should be dropped.

---
 Eugeniy Paltsev



From: Eugeniy Paltsev 
Sent: Friday, May 29, 2020 14:55
To: linux-snps-arc@lists.infradead.org; Vineet Gupta
Cc: linux-ker...@vger.kernel.org; Alexey Brodkin; Eugeniy Paltsev
Subject: [PATCH private 1/3] ARC: allow to overwrite default mcpu compiler flag

By default we set -mcpu=xxx compiler flag depending on the CPU ISA
version. It's good starting point, however that may be not enough
as for some platforms we may want to use some specific 'mcpu'
options for better optimization or to workaround HW issues.

We are going to use this option for HSDK-4xD board support.
In addition it also allows to awoid patching 'mcpu' in ARC Makefile
when we building Linux for some non-standard simulation or FPGA-based
platforms.

Signed-off-by: Eugeniy Paltsev 
---
 arch/arc/Kconfig  | 7 +++
 arch/arc/Makefile | 4 
 2 files changed, 11 insertions(+)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index ff306246d0f8..e7805db10f7a 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -377,6 +377,13 @@ config ARC_HAS_SWAPE
bool "Insn: SWAPE (endian-swap)"
default y

+config ARC_MCPU_OVERWRITE
+   string "Overwrite default -mcpu compiler flag"
+   default ""
+   help
+ Overwrite default -mcpu=xxx compiler flag (which is set depending on
+ the ISA version) with the specified value.
+
 if ISA_ARCV2

 config ARC_USE_UNALIGNED_MEM_ACCESS
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 20e9ab6cc521..1b37e44d9b57 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -10,8 +10,12 @@ CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- 
arceb-linux-)
 endif

 cflags-y   += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
+ifeq ($(CONFIG_ARC_MCPU_OVERWRITE),"")
 cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7
 cflags-$(CONFIG_ISA_ARCV2) += -mcpu=hs38
+else
+cflags-y   += $(shell echo $(CONFIG_ARC_MCPU_OVERWRITE))
+endif

 ifdef CONFIG_ARC_CURR_IN_REG
 # For a global register defintion, make sure it gets passed to every file
--
2.21.3


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 1/3] ARC: allow to overide default mcpu compiler flag

2020-05-29 Thread Eugeniy Paltsev
By default we set -mcpu=xxx compiler flag depending on the CPU ISA
version. It's good starting point, however that may be not enough
as for some platforms we may want to use some specific 'mcpu'
options for better optimization or to workaround HW issues.

We are going to use this option for HSDK-4xD board support.
In addition it also allows to awoid patching 'mcpu' in ARC Makefile
when we building Linux for some non-standard simulation or FPGA-based
platforms.

Signed-off-by: Eugeniy Paltsev 
---
 arch/arc/Kconfig  | 7 +++
 arch/arc/Makefile | 4 
 2 files changed, 11 insertions(+)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index ff306246d0f8..2d4f85dc914e 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -377,6 +377,13 @@ config ARC_HAS_SWAPE
bool "Insn: SWAPE (endian-swap)"
default y
 
+config ARC_TUNE_MCPU
+   string "Overide default -mcpu compiler flag"
+   default ""
+   help
+ Overide default -mcpu=xxx compiler flag (which is set depending on
+ the ISA version) with the specified value.
+
 if ISA_ARCV2
 
 config ARC_USE_UNALIGNED_MEM_ACCESS
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 20e9ab6cc521..eb88ba5b1573 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -10,8 +10,12 @@ CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- 
arceb-linux-)
 endif
 
 cflags-y   += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
+ifeq ($(CONFIG_ARC_TUNE_MCPU),"")
 cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7
 cflags-$(CONFIG_ISA_ARCV2) += -mcpu=hs38
+else
+cflags-y   += $(shell echo $(CONFIG_ARC_TUNE_MCPU))
+endif
 
 ifdef CONFIG_ARC_CURR_IN_REG
 # For a global register defintion, make sure it gets passed to every file
-- 
2.21.3


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 0/3] ARC: [plat-hsdk-4xd] initial port for HSDK-4xD board

2020-05-29 Thread Eugeniy Paltsev
Eugeniy Paltsev (3):
  ARC: allow to overide default mcpu compiler flag
  ARC: ARCv2: support loop buffer (LPB) disabling
  ARC: [plat-hsdk-4xd] initial port for HSDK-4xD board

 arch/arc/Kconfig|  13 ++
 arch/arc/Makefile   |   4 +
 arch/arc/boot/dts/hsdk-4xd.dts  | 322 
 arch/arc/configs/hsdk_4xd_defconfig |  99 +
 arch/arc/kernel/devtree.c   |   1 +
 arch/arc/kernel/head.S  |   8 +
 arch/arc/plat-hsdk/Kconfig  |  24 ++-
 arch/arc/plat-hsdk/platform.c   |   6 +
 8 files changed, 476 insertions(+), 1 deletion(-)
 create mode 100644 arch/arc/boot/dts/hsdk-4xd.dts
 create mode 100644 arch/arc/configs/hsdk_4xd_defconfig

-- 
2.21.3


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH private 1/3] ARC: allow to overwrite default mcpu compiler flag

2020-05-29 Thread Eugeniy Paltsev
By default we set -mcpu=xxx compiler flag depending on the CPU ISA
version. It's good starting point, however that may be not enough
as for some platforms we may want to use some specific 'mcpu'
options for better optimization or to workaround HW issues.

We are going to use this option for HSDK-4xD board support.
In addition it also allows to awoid patching 'mcpu' in ARC Makefile
when we building Linux for some non-standard simulation or FPGA-based
platforms.

Signed-off-by: Eugeniy Paltsev 
---
 arch/arc/Kconfig  | 7 +++
 arch/arc/Makefile | 4 
 2 files changed, 11 insertions(+)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index ff306246d0f8..e7805db10f7a 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -377,6 +377,13 @@ config ARC_HAS_SWAPE
bool "Insn: SWAPE (endian-swap)"
default y
 
+config ARC_MCPU_OVERWRITE
+   string "Overwrite default -mcpu compiler flag"
+   default ""
+   help
+ Overwrite default -mcpu=xxx compiler flag (which is set depending on
+ the ISA version) with the specified value.
+
 if ISA_ARCV2
 
 config ARC_USE_UNALIGNED_MEM_ACCESS
diff --git a/arch/arc/Makefile b/arch/arc/Makefile
index 20e9ab6cc521..1b37e44d9b57 100644
--- a/arch/arc/Makefile
+++ b/arch/arc/Makefile
@@ -10,8 +10,12 @@ CROSS_COMPILE := $(call cc-cross-prefix, arc-linux- 
arceb-linux-)
 endif
 
 cflags-y   += -fno-common -pipe -fno-builtin -mmedium-calls -D__linux__
+ifeq ($(CONFIG_ARC_MCPU_OVERWRITE),"")
 cflags-$(CONFIG_ISA_ARCOMPACT) += -mA7
 cflags-$(CONFIG_ISA_ARCV2) += -mcpu=hs38
+else
+cflags-y   += $(shell echo $(CONFIG_ARC_MCPU_OVERWRITE))
+endif
 
 ifdef CONFIG_ARC_CURR_IN_REG
 # For a global register defintion, make sure it gets passed to every file
-- 
2.21.3


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 2/3] ARC: ARCv2: support loop buffer (LPB) disabling

2020-05-29 Thread Eugeniy Paltsev
On HS cores, loop buffer (LPB) is programmable in runtime and can
be optionally disabled.

Signed-off-by: Eugeniy Paltsev 
---
 arch/arc/Kconfig   | 6 ++
 arch/arc/kernel/head.S | 8 
 2 files changed, 14 insertions(+)

diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig
index 2d4f85dc914e..270504d4fdf5 100644
--- a/arch/arc/Kconfig
+++ b/arch/arc/Kconfig
@@ -471,6 +471,12 @@ config ARC_IRQ_NO_AUTOSAVE
  This is programmable and can be optionally disabled in which case
  software INTERRUPT_PROLOGUE/EPILGUE do the needed work
 
+config ARC_LPB_DISABLE
+   bool "Disable loop buffer (LPB)"
+   help
+ On HS cores, loop buffer (LPB) is programmable in runtime and can
+ be optionally disabled.
+
 endif # ISA_ARCV2
 
 endmenu   # "ARC CPU Configuration"
diff --git a/arch/arc/kernel/head.S b/arch/arc/kernel/head.S
index 6eb23f1545ee..17fd1ed700cc 100644
--- a/arch/arc/kernel/head.S
+++ b/arch/arc/kernel/head.S
@@ -59,6 +59,14 @@
bclrr5, r5, STATUS_AD_BIT
 #endif
kflag   r5
+
+#ifdef CONFIG_ARC_LPB_DISABLE
+   lr  r5, [ARC_REG_LPB_BUILD]
+   breqr5, 0, 1f   ; LPB doesn't exist
+   mov r5, 1
+   sr  r5, [ARC_REG_LPB_CTRL]
+1:
+#endif /* CONFIG_ARC_LPB_DISABLE */
 #endif
; Config DSP_CTRL properly, so kernel may use integer multiply,
; multiply-accumulate, and divide operations
-- 
2.21.3


___
linux-snps-arc mailing list
linux-snps-arc@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-snps-arc


[PATCH 3/3] ARC: [plat-hsdk-4xd] initial port for HSDK-4xD board

2020-05-29 Thread Eugeniy Paltsev
This initial port adds support of ARC HS4x/HS4xD Development Kit board with some
basic features such serial port, USB, SD/MMC, SPI flash, Ethernet and others.

The HSDK-4xD board has much in common with its predecessor - HSDK board.
However HSDK-4xD has some differences in comparison with its predecessor:
 * based on quad core ARC HS48/HS47D processor (instead of quad core ARC HS38)
 * has ThinkSilicon GPU (instead of Vivante GPU)
 * has ARC PGU and HDMI output
 * has separate SDIO controller for WiFi module
 * has additional timers with clocksource independent from CPU clocksource
   (required for DVFS)
 * has performance counters interrupt
 * other minor stuff

NOTE:
HSDK-4xD and HSDK may share significant part of DTS so we can move this common
part to one .dtsi file (as we have done it in U-boot). However we have quite
enough out of the tree patches for tweaking HSDK DTS (patches in out
verification flow, patches for run in simulation, etc...), so I'd prefer to
keep HSDK DTS untouched. That's why HSDK-4xD DTS is created as an separate file.

Cc: Rob Herring 
Signed-off-by: Eugeniy Paltsev 
---
 arch/arc/boot/dts/hsdk-4xd.dts  | 322 
 arch/arc/configs/hsdk_4xd_defconfig |  99 +
 arch/arc/kernel/devtree.c   |   1 +
 arch/arc/plat-hsdk/Kconfig  |  24 ++-
 arch/arc/plat-hsdk/platform.c   |   6 +
 5 files changed, 451 insertions(+), 1 deletion(-)
 create mode 100644 arch/arc/boot/dts/hsdk-4xd.dts
 create mode 100644 arch/arc/configs/hsdk_4xd_defconfig

diff --git a/arch/arc/boot/dts/hsdk-4xd.dts b/arch/arc/boot/dts/hsdk-4xd.dts
new file mode 100644
index ..2b7f76a01e3e
--- /dev/null
+++ b/arch/arc/boot/dts/hsdk-4xd.dts
@@ -0,0 +1,322 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (C) 2020 Synopsys, Inc. (www.synopsys.com)
+ */
+
+/*
+ * Device Tree for ARC HS4x/HS4xD Development Kit
+ */
+/dts-v1/;
+
+#include 
+#include 
+
+/ {
+   model = "snps,hsdk-4xd";
+   compatible = "snps,hsdk-4xd";
+
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   chosen {
+   bootargs = "earlycon=uart8250,mmio32,0xf0005000,115200n8 
console=ttyS0,115200n8 debug print-fatal-signals=1";
+   };
+
+   aliases {
+   ethernet = 
+   };
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   cpu@0 {
+   device_type = "cpu";
+   compatible = "snps,archs48";
+   reg = <0>;
+   clocks = <_clk>;
+   };
+
+   cpu@1 {
+   device_type = "cpu";
+   compatible = "snps,archs48";
+   reg = <1>;
+   clocks = <_clk>;
+   };
+
+   cpu@2 {
+   device_type = "cpu";
+   compatible = "snps,archs48";
+   reg = <2>;
+   clocks = <_clk>;
+   };
+
+   cpu@3 {
+   device_type = "cpu";
+   compatible = "snps,archs48";
+   reg = <3>;
+   clocks = <_clk>;
+   };
+   };
+
+   input_clk: input-clk {
+   #clock-cells = <0>;
+   compatible = "fixed-clock";
+   clock-frequency = <>;
+   };
+
+   reg_5v0: regulator-5v0 {
+   compatible = "regulator-fixed";
+
+   regulator-name = "5v0-supply";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   };
+
+   cpu_intc: cpu-interrupt-controller {
+   compatible = "snps,archs-intc";
+   interrupt-controller;
+   #interrupt-cells = <1>;
+   };
+
+   idu_intc: idu-interrupt-controller {
+   compatible = "snps,archs-idu-intc";
+   interrupt-controller;
+   #interrupt-cells = <1>;
+   interrupt-parent = <_intc>;
+   };
+
+   arcpct: pct {
+   compatible = "snps,archs-pct";
+   interrupt-parent = <_intc>;
+   interrupts = <20>;
+   };
+
+   /* TIMER0 with interrupt for clockevent */
+   timer {
+   compatible = "snps,arc-timer";
+   interrupts = <16>;
+   interrupt-parent = <_intc>;
+   clocks = <_clk>;
+   };
+
+   /* 64-bit Global Free Running Counter */
+   gfrc {
+   compatible = "snps,archs-timer-gfrc";
+   clocks = <_clk>;
+   };
+
+   soc {
+   compatible = "simple-bus";
+   #address-cells = <1>;
+   #size-cells = <1>;
+   interrupt-parent = <_intc>;
+
+   ranges = <0x 0x0 0xf000 0x1000>;
+
+   cgu_rst: reset-controller@8a0 {
+   compatible =