Bug#654630: Please review this diff for atomic ops in mesa on m68k

2012-01-28 Thread Thorsten Glaser
Dixi quod…

Andreas Schwab dixit:

 mesa FTBFS on m68k due to lack of GCC atomic intrinsics. (Why are
 they (still) missing, anyway?) Ib

 They are now implemented in 4.7.

 Can they easily be backported to Debian's gcc 4.x (x = 6?)?

Probably.

Seems so. I’m trying that now (patched package is compiling
on m68k and an amd64 VM) so expect results in three days or
so. ☺


“Or so.”

Turns out init_sync_libfuncs (added in gcc r181134) is not
in 4.6, and without that, handling of the atomic builtins
looks funny; it touches quite a bit of MI code and probably
needs later followup commits (I’ve seen references to other
commits touching this function), so I give up on this.

We’ll “just” have to build Mesa with gcc-4.7 next time. This
of course will have to wait until gcc-4.7 is in unstable, but
it’s looked good so far.

bye,
//mirabilos
-- 
[00:02] Vutral gecko: benutzt du emacs ?
[00:03] gecko nö  [00:03] gecko nur n normalen mac
[00:04] Vutral argl   [00:04] Vutral ne den editor
-- Vutral und gecko2 in #deutsch (NB: Editor? Betriebssystem.)



--
To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/pine.bsm.4.64l.1201281421290.31...@herc.mirbsd.org



Bug#654630: Please review this diff for atomic ops in mesa on m68k

2012-01-10 Thread Thorsten Glaser
Dear m68k porters,

mesa FTBFS on m68k due to lack of GCC atomic intrinsics. (Why are
they (still) missing, anyway?) I’ve had a look at other patches
floating around on this mailing list and drafted the attached diff
which makes it at least compile again. My knowledge is not enough
to validate that this DTRT, especially where multi-threaded pro‐
gramming is involved, so please look it over.

At first I wanted to use libatomic-ops-dev, but since Gallium hard‐
codes the use of pointers to int32_t, it wasn’t feasible without
touching large parts of the code, hence the m68k-specific fix, as
seems to have been tradition in several places.

bye,
//mirabilos, who’s currently pretty busy with daylife ☹
-- 
  “Having a smoking section in a restaurant is like having
  a peeing section in a swimming pool.”
-- Edward Burrdiff -Nru mesa-7.11.2/debian/changelog mesa-7.11.2/debian/changelog
--- mesa-7.11.2/debian/changelog2012-01-10 08:48:31.0 +
+++ mesa-7.11.2/debian/changelog2012-01-10 08:49:40.0 +
@@ -1,3 +1,9 @@
+mesa (7.11.2-1+m68k.1) unreleased; urgency=low
+
+  * Add atomic operations for m68k. (Closes: #654630)
+
+ -- Thorsten Glaser t...@mirbsd.de  Sun, 08 Jan 2012 17:23:47 +
+
 mesa (7.11.2-1) unstable; urgency=low
 
   * New upstream release:
diff -Nru mesa-7.11.2/debian/patches/15-m68k-atomic-ops.diff 
mesa-7.11.2/debian/patches/15-m68k-atomic-ops.diff
--- mesa-7.11.2/debian/patches/15-m68k-atomic-ops.diff  1970-01-01 
00:00:00.0 +
+++ mesa-7.11.2/debian/patches/15-m68k-atomic-ops.diff  2012-01-10 
08:49:40.0 +
@@ -0,0 +1,90 @@
+Index: mesa-7.11.2/src/gallium/auxiliary/util/u_atomic.h
+===
+--- mesa-7.11.2.orig/src/gallium/auxiliary/util/u_atomic.h 2012-01-08 
17:41:45.0 +
 mesa-7.11.2/src/gallium/auxiliary/util/u_atomic.h  2012-01-08 
21:09:19.0 +
+@@ -31,6 +31,9 @@
+ #define PIPE_ATOMIC_ASM_GCC_X86
+ #elif (defined(PIPE_CC_GCC)  defined(PIPE_ARCH_X86_64))
+ #define PIPE_ATOMIC_ASM_GCC_X86_64
++#elif (defined(PIPE_CC_GCC)  defined(__m68k__))
++/* hopefully 68020 or better, Linux */
++#define PIPE_ATOMIC_ASM_GCC_M68K
+ #elif defined(PIPE_CC_GCC)  (PIPE_CC_GCC_VERSION = 401)
+ #define PIPE_ATOMIC_GCC_INTRINSIC
+ #else
+@@ -343,6 +346,75 @@
+ #endif
+ 
+ 
++#if defined(PIPE_ATOMIC_ASM_GCC_M68K)
++#define PIPE_ATOMIC GCC m68k assembly
++
++#ifdef __cplusplus
++extern C {
++#endif
++
++#define p_atomic_set(_v, _i) (*(_v) = (_i))
++#define p_atomic_read(_v) (*(_v))
++
++#define p_atomic_m68k_cmpxchg(p, old, new, dst)   \
++  __asm__ __volatile__(casl %0,%2,%1\
++   : =d (dst), =m (*p)\
++   : d (new), 0 (old), m (*p))
++
++static INLINE int32_t
++p_atomic_m68k_add_and_fetch(int32_t *v, int32_t i)
++{
++   int32_t prev, next;
++
++   for (;;) {
++  prev = *v;
++  next = prev + i;
++  p_atomic_m68k_cmpxchg(v, prev, next, prev);
++  if (prev == next)
++ return next;
++   }
++}
++
++static INLINE boolean
++p_atomic_dec_zero(int32_t *v)
++{
++   return (p_atomic_m68k_add_and_fetch(v, (int32_t)-1) == 0);
++}
++
++static INLINE void
++p_atomic_inc(int32_t *v)
++{
++   p_atomic_m68k_add_and_fetch(v, 1);
++}
++
++static INLINE void
++p_atomic_dec(int32_t *v)
++{
++   p_atomic_m68k_add_and_fetch(v, (int32_t)-1);
++}
++
++static INLINE int32_t
++p_atomic_cmpxchg(int32_t *v, int32_t old, int32_t _new)
++{
++   int32_t prev, dest;
++
++   for (;;) {
++  prev = *v;
++  if (prev != old)
++ return prev;
++  p_atomic_m68k_cmpxchg(v, prev, _new, dest);
++  if (dest == _new)
++ return prev;
++   }
++}
++
++#ifdef __cplusplus
++}
++#endif
++
++#endif /* PIPE_ATOMIC_ASM_GCC_M68K */
++
++
+ #ifndef PIPE_ATOMIC
+ #error No pipe_atomic implementation selected
+ #endif
diff -Nru mesa-7.11.2/debian/patches/series mesa-7.11.2/debian/patches/series
--- mesa-7.11.2/debian/patches/series   2012-01-10 08:48:31.0 +
+++ mesa-7.11.2/debian/patches/series   2012-01-10 08:49:40.0 +
@@ -7,3 +7,4 @@
 11-hurd-ftbfs-again.diff
 13-llvm-config-pick-a-version.diff
 14-load-swrastg-before-swrast.diff
+15-m68k-atomic-ops.diff


Bug#654630: Please review this diff for atomic ops in mesa on m68k

2012-01-10 Thread Geert Uytterhoeven
On Tue, Jan 10, 2012 at 09:56, Thorsten Glaser t...@mirbsd.de wrote:
 mesa FTBFS on m68k due to lack of GCC atomic intrinsics. (Why are
 they (still) missing, anyway?) I’ve had a look at other patches

Perhaps Andreas knows?

 floating around on this mailing list and drafted the attached diff
 which makes it at least compile again. My knowledge is not enough
 to validate that this DTRT, especially where multi-threaded pro‐
 gramming is involved, so please look it over.

CAS is a read-modify-write instruction, which is not guaranteed to work
on all m68k platforms (hence the existence of CONFIG_RMW_INSNS in
the kernel).

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
                                -- Linus Torvalds



--
To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/camuhmdunlpqgg7k4mutoyx6gtginqkqj1f2xdjhcnajg+i5...@mail.gmail.com



Bug#654630: Please review this diff for atomic ops in mesa on m68k

2012-01-10 Thread Andreas Schwab
Geert Uytterhoeven ge...@linux-m68k.org writes:

 On Tue, Jan 10, 2012 at 09:56, Thorsten Glaser t...@mirbsd.de wrote:
 mesa FTBFS on m68k due to lack of GCC atomic intrinsics. (Why are
 they (still) missing, anyway?) I’ve had a look at other patches

 Perhaps Andreas knows?

They are now implemented in 4.7.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.



--
To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/m262gjpviy@igel.home



Bug#654630: Please review this diff for atomic ops in mesa on m68k

2012-01-10 Thread Geert Uytterhoeven
On Tue, Jan 10, 2012 at 13:55, Andreas Schwab sch...@linux-m68k.org wrote:
 Geert Uytterhoeven ge...@linux-m68k.org writes:

 On Tue, Jan 10, 2012 at 09:56, Thorsten Glaser t...@mirbsd.de wrote:
 mesa FTBFS on m68k due to lack of GCC atomic intrinsics. (Why are
 they (still) missing, anyway?) I’ve had a look at other patches

 Perhaps Andreas knows?

 They are now implemented in 4.7.

Can they easily be backported to Debian's gcc 4.x (x = 6?)?

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
                                -- Linus Torvalds



--
To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/camuhmdwskgeop4mwcq31j-q09jidf758cz9zjuodh8abv_5...@mail.gmail.com



Bug#654630: Please review this diff for atomic ops in mesa on m68k

2012-01-10 Thread Andreas Schwab
Geert Uytterhoeven ge...@linux-m68k.org writes:

 On Tue, Jan 10, 2012 at 13:55, Andreas Schwab sch...@linux-m68k.org wrote:
 Geert Uytterhoeven ge...@linux-m68k.org writes:

 On Tue, Jan 10, 2012 at 09:56, Thorsten Glaser t...@mirbsd.de wrote:
 mesa FTBFS on m68k due to lack of GCC atomic intrinsics. (Why are
 they (still) missing, anyway?) I’ve had a look at other patches

 Perhaps Andreas knows?

 They are now implemented in 4.7.

 Can they easily be backported to Debian's gcc 4.x (x = 6?)?

Probably.

Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
And now for something completely different.



-- 
To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/m2wr8zoass@igel.home



Bug#654630: Please review this diff for atomic ops in mesa on m68k

2012-01-10 Thread Thorsten Glaser
Geert Uytterhoeven dixit:

CAS is a read-modify-write instruction, which is not guaranteed to work
on all m68k platforms (hence the existence of CONFIG_RMW_INSNS in
the kernel).

All platforms currently supported by Debian (that is, not Coldfire and
with MMU) should have it, right? I think otherwise the cmpxchg syscall
can be used, but, as I haven’t seen an example of it in use, I’ve not
felt like experimenting.

If anyone feeld like making an upstreamable diff…

Andreas Schwab dixit:

 mesa FTBFS on m68k due to lack of GCC atomic intrinsics. (Why are
 they (still) missing, anyway?) Ib

 Perhaps Andreas knows?

 They are now implemented in 4.7.

Great, good to know, thanks. Maybe we can just keep this patch
around locally until such time as 4.7 is used, so no need to
bother upstream. Unless my assumption that all Debian/m68k targets
have CAS or something else with the patch is wrong. I’ve strictly
tested only whether the result compiles. (This will fulfill quite
a lot of B-D now.)

bye,
//mirabilos, who unfortunately doesn’t see an end to dayjob work
-- 
«MyISAM tables -will- get corrupted eventually. This is a fact of life. »
“mysql is about as much database as ms access” – “MSSQL at least descends
from a database” “it's a rebranded SyBase” “MySQL however was born from a
flatfile and went downhill from there” – “at least jetDB doesn’t claim to
be a database”  -- Tonnerre, psychoschlumpf and myself in #nosec



--
To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/pine.bsm.4.64l.1201101905260.6...@herc.mirbsd.org



Bug#654630: Please review this diff for atomic ops in mesa on m68k

2012-01-10 Thread Geert Uytterhoeven
On Tue, Jan 10, 2012 at 20:09, Thorsten Glaser t...@mirbsd.de wrote:
CAS is a read-modify-write instruction, which is not guaranteed to work
on all m68k platforms (hence the existence of CONFIG_RMW_INSNS in
the kernel).

 All platforms currently supported by Debian (that is, not Coldfire and
 with MMU) should have it, right? I think otherwise the cmpxchg syscall
 can be used, but, as I haven’t seen an example of it in use, I’ve not
 felt like experimenting.

It's not a CPU issue, but a bus/platform issue.

That's why we have the syscall, which is always safe to use.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
                                -- Linus Torvalds



--
To UNSUBSCRIBE, email to debian-x-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/CAMuHMdVqTX5x_ZiPUj=ra2sw-x1jkghyvwmfanscgyhqn6h...@mail.gmail.com