Skip to contentSkip to conversation

cmpxchg is not available to generic code

DISCUSSION Andrew Morton 5 participants 12 messages Jul 19, 2007 – Jul 23, 2007

lore
Share & tools
lore
#0 lore raw

arm:

drivers/char/drm/drm_lock.c: In function `drm_lock_take':
drivers/char/drm/drm_lock.c:221: error: implicit declaration of function `cmpxchg'

You might be able to use atomic_cmpxchg, which _is_ present on all architectures. Or use a spinlock.

What's that code doing anyway? driver-private locking primitives?

#1 lore raw

From: Andrew Morton <[email protected]>
Date: Thu, 19 Jul 2007 00:05:49 -0700

Quoted 1 line

What's that code doing anyway? driver-private locking primitives?

It's an atomic lock shared with userspace. Whatever implementation is used to do the lock on that object must be identical in the userspace DRM bits.

Unlike futex, the lock operation on the user side isn't optional. So if the platform can't do a true cmpxchg it generally cannot support DRM.

#2 lore raw
Quoted 5 lines · David Miller

From: Andrew Morton <[email protected]>
Date: Thu, 19 Jul 2007 00:05:49 -0700

Quoted 1 line

What's that code doing anyway? driver-private locking primitives?

Quoted 7 lines

It's an atomic lock shared with userspace. Whatever implementation is used to do the lock on that object must be identical in the userspace DRM bits.

Unlike futex, the lock operation on the user side isn't optional. So if the platform can't do a true cmpxchg it generally cannot support DRM.

Actually in theory the userspace side is optional, it should fallback to always entering the kernel and being slow, but Ive no idea how well that codepath is tested... but it's an area I'd hate to play with now ..

Maybe we could add CONFIG_HAVE_CMPXCHG and let DRM depend on it..

Dave.

#3 lore raw
Quoted 1 line · On Thu, 19 Jul 2007 18:15:03 +1000 "Dave Airlie" <[email protected]> wrote:

Maybe we could add CONFIG_HAVE_CMPXCHG and let DRM depend on it..

That would certainly be better than adding a sprinkle of architectures in DRM Kconfig dependencies.

I don't know how important DRM is on ARM. Zero?

#4 lore raw
Quoted 9 lines · Andrew Morton
Quoted 1 line · On Thu, 19 Jul 2007 18:15:03 +1000 "Dave Airlie" <[email protected]> wrote:

Maybe we could add CONFIG_HAVE_CMPXCHG and let DRM depend on it..

That would certainly be better than adding a sprinkle of architectures in DRM Kconfig dependencies.

I don't know how important DRM is on ARM. Zero?

I'd guess zero I suppose if you wanted you could hook up a PCI graphics card on ARM, but if you do that I think you could implement cmpxchg :-)

Dave.

#5 lore raw
Quoted 9 lines · Dave Airlie
Quoted 7 lines · Andrew Morton
Quoted 1 line · On Thu, 19 Jul 2007 18:15:03 +1000 "Dave Airlie" <[email protected]> wrote:

Maybe we could add CONFIG_HAVE_CMPXCHG and let DRM depend on it..

That would certainly be better than adding a sprinkle of architectures in DRM Kconfig dependencies.

Quoted 6 lines
Quoted 2 lines

I don't know how important DRM is on ARM. Zero?

I'd guess zero I suppose if you wanted you could hook up a PCI graphics card on ARM, but if you do that I think you could implement cmpxchg :-)

ARM does the locked load / store conditional thing which is at least as strong as cmpxchg, so I imagine it could implement this API in kernel and userspace quite easily if needed.

Signature · 1 line
SUSE Labs, Novell Inc.
#6 lore raw
In reply to Andrew Morton

From: Andrew Morton <[email protected]>
Date: Thu, 19 Jul 2007 01:21:41 -0700

Quoted 8 lines · On Thu, 19 Jul 2007 18:15:03 +1000 "Dave Airlie" <[email protected]> wrote:
Quoted 2 lines

Maybe we could add CONFIG_HAVE_CMPXCHG and let DRM depend on it..

That would certainly be better than adding a sprinkle of architectures in DRM Kconfig dependencies.

I don't know how important DRM is on ARM. Zero?

We already have EMULATED_CMPXCHG guarding DRM.

#7 lore raw
In reply to Dave Airlie

From: "Dave Airlie" <[email protected]>
Date: Thu, 19 Jul 2007 18:15:03 +1000

Quoted 1 line

Maybe we could add CONFIG_HAVE_CMPXCHG and let DRM depend on it..

There is already a "!EMULATED_CMPXCHG" guarding DRM, perhaps ARM's Kconfig can set that if appropriate.

#8 lore raw
In reply to Andrew Morton
Quoted 11 lines

arm:

drivers/char/drm/drm_lock.c: In function `drm_lock_take':
drivers/char/drm/drm_lock.c:221: error: implicit declaration of function `cmpxchg'

You might be able to use atomic_cmpxchg, which _is_ present on all architectures. Or use a spinlock.

What's that code doing anyway? driver-private locking primitives?

When did arm suddenly start wanting DRM? they need to grow a userpsace cmpxchg as davem mentioned to go along with this, changing the drm now isn't possible due to backwards compat..

Dave.

Signature · 3 lines
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied at skynet.ie
Linux kernel - DRI, VAX / pam_smb / ILUG
#9 lore raw
Quoted 7 lines · On Thu, 19 Jul 2007 09:02:03 +0100 (IST) Dave Airlie <[email protected]> wrote:
Quoted 7 lines

arm:

drivers/char/drm/drm_lock.c: In function `drm_lock_take':
drivers/char/drm/drm_lock.c:221: error: implicit declaration of function `cmpxchg'

Quoted 6 lines
Quoted 4 lines

You might be able to use atomic_cmpxchg, which _is_ present on all architectures. Or use a spinlock.

What's that code doing anyway? driver-private locking primitives?

When did arm suddenly start wanting DRM?

It's selectable in config. allmodconfig broke.

Quoted 3 lines

they need to grow a userpsace
cmpxchg as davem mentioned to go along with this, changing the drm now isn't possible due to backwards compat..

For reference purposes, that position is not acceptable. We _never_ accept the "oh I can't change my proposed kernel interface because I already have userspace relying on it" argument.

Hopefully that won't be an issue here. I guess DRM now needs a `depends on !ARM'.

#10 lore raw
Quoted 9 lines
Quoted 5 lines

they need to grow a userpsace
cmpxchg as davem mentioned to go along with this, changing the drm now isn't possible due to backwards compat..

For reference purposes, that position is not acceptable. We _never_ accept the "oh I can't change my proposed kernel interface because I already have userspace relying on it" argument.

Yes it is, I thought breaking userspace API was the worst crime in kernel history, (unless you are sysfs...) the userspace DRM has been around since 2.2 days at least, so there are lots of legacy userspaces to break..

Quoted 2 lines

Hopefully that won't be an issue here. I guess DRM now needs a `depends on !ARM'.

Possibly the answer..

Dave.

Signature · 3 lines
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied at skynet.ie
Linux kernel - DRI, VAX / pam_smb / ILUG
#11 lore raw
Quoted 5 lines · On Thu, 19 Jul 2007 09:19:10 +0100 (IST) Dave Airlie <[email protected]> wrote:
Quoted 5 lines
Quoted 4 lines

they need to grow a userpsace
cmpxchg as davem mentioned to go along with this, changing the drm now isn't possible due to backwards compat..

Quoted 7 lines
Quoted 3 lines

For reference purposes, that position is not acceptable. We _never_ accept the "oh I can't change my proposed kernel interface because I already have userspace relying on it" argument.

Yes it is, I thought breaking userspace API was the worst crime in kernel history, (unless you are sysfs...) the userspace DRM has been around since 2.2 days at least, so there are lots of legacy userspaces to break..

oh, sorry, I thought this cmpxchg stuff was newly-added.

I guess something changed which has now made DRM available under arm allmodconfig.