Changes in 4.9.267 ARM: 8723/2: always assume the "unified" syntax for assembly code iio: hid-sensor-prox: Fix scale not correct issue ALSA: aloop: Fix initialization of controls ASoC: intel: atom: Stop advertising non working S24LE support nfc: fix refcount leak in llcp_sock_bind() nfc: fix refcount leak in llcp_sock_connect() nfc: fix memory leak in llcp_sock_connect() nfc: Avoid endless loops caused by repeated llcp_sock_connect() xen/evtchn: Change irq_info lock to raw_spinlock_t net: ipv6: check for validity before dereferencing cfg->fc_nlinfo.nlh ia64: fix user_stack_pointer() for ptrace() ocfs2: fix deadlock between setattr and dio_end_io_write fs: direct-io: fix missing sdio->boundary parisc: parisc-agp requires SBA IOMMU driver parisc: avoid a warning on u8 cast for cmpxchg on u8 pointers batman-adv: initialize "struct batadv_tvlv_tt_vlan_data"->reserved field net: sched: sch_teql: fix null-pointer dereference sch_red: fix off-by-one checks in red_check_params() gianfar: Handle error code at MAC address change net:tipc: Fix a double free in tipc_sk_mcast_rcv soc/fsl: qbman: fix conflicting alignment attributes clk: fix invalid usage of list cursor in unregister workqueue: Move the position of debug_work_activate() in __queue_work() s390/cpcmd: fix inline assembly register clobbering RDMA/cxgb4: check for ipv6 address properly while destroying listener clk: socfpga: fix iomem pointer cast on 64-bit mm: add cond_resched() in gather_pte_stats() usbip: fix vudc usbip_sockfd_store races leading to gpf cfg80211: remove WARN_ON() in cfg80211_sme_connect net: tun: set tun->dev->addr_len during TUNSETLINK processing drivers: net: fix memory leak in atusb_probe drivers: net: fix memory leak in peak_usb_create_dev net: mac802154: Fix general protection fault net: ieee802154: nl-mac: fix check on panid net: ieee802154: fix nl802154 del llsec key net: ieee802154: fix nl802154 del llsec dev net: ieee802154: fix nl802154 add llsec key net: ieee802154: fix nl802154 del llsec devkey net: ieee802154: forbid monitor for set llsec params net: ieee802154: forbid monitor for del llsec seclevel net: ieee802154: stop dump llsec params for monitors Revert "cifs: Set CIFS_MOUNT_USE_PREFIX_PATH flag on setting cifs_sb->prepath." drm/imx: imx-ldb: fix out of bounds array access warning gfs2: report "already frozen/thawed" errors netfilter: x_tables: fix compat match/target pad out-of-bound write perf map: Tighten snprintf() string precision to pass gcc check on some 32-bit arches xen/events: fix setting irq affinity Linux 4.9.267 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I5e3b199e53476e0cbd4feb7b1cd15b1e38891aec
124 lines
3.6 KiB
C
124 lines
3.6 KiB
C
/*
|
|
* forked from parisc asm/atomic.h which was:
|
|
* Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org>
|
|
* Copyright (C) 2006 Kyle McMartin <kyle@parisc-linux.org>
|
|
*/
|
|
|
|
#ifndef _ASM_PARISC_CMPXCHG_H_
|
|
#define _ASM_PARISC_CMPXCHG_H_
|
|
|
|
/* This should get optimized out since it's never called.
|
|
** Or get a link error if xchg is used "wrong".
|
|
*/
|
|
extern void __xchg_called_with_bad_pointer(void);
|
|
|
|
/* __xchg32/64 defined in arch/parisc/lib/bitops.c */
|
|
extern unsigned long __xchg8(char, char *);
|
|
extern unsigned long __xchg32(int, int *);
|
|
#ifdef CONFIG_64BIT
|
|
extern unsigned long __xchg64(unsigned long, unsigned long *);
|
|
#endif
|
|
|
|
/* optimizer better get rid of switch since size is a constant */
|
|
static inline unsigned long
|
|
__xchg(unsigned long x, __volatile__ void *ptr, int size)
|
|
{
|
|
switch (size) {
|
|
#ifdef CONFIG_64BIT
|
|
case 8: return __xchg64(x, (unsigned long *) ptr);
|
|
#endif
|
|
case 4: return __xchg32((int) x, (int *) ptr);
|
|
case 1: return __xchg8((char) x, (char *) ptr);
|
|
}
|
|
__xchg_called_with_bad_pointer();
|
|
return x;
|
|
}
|
|
|
|
/*
|
|
** REVISIT - Abandoned use of LDCW in xchg() for now:
|
|
** o need to test sizeof(*ptr) to avoid clearing adjacent bytes
|
|
** o and while we are at it, could CONFIG_64BIT code use LDCD too?
|
|
**
|
|
** if (__builtin_constant_p(x) && (x == NULL))
|
|
** if (((unsigned long)p & 0xf) == 0)
|
|
** return __ldcw(p);
|
|
*/
|
|
#define xchg(ptr, x) \
|
|
({ \
|
|
__typeof__(*(ptr)) __ret; \
|
|
__typeof__(*(ptr)) _x_ = (x); \
|
|
__ret = (__typeof__(*(ptr))) \
|
|
__xchg((unsigned long)_x_, (ptr), sizeof(*(ptr))); \
|
|
__ret; \
|
|
})
|
|
|
|
/* bug catcher for when unsupported size is used - won't link */
|
|
extern void __cmpxchg_called_with_bad_pointer(void);
|
|
|
|
/* __cmpxchg_u32/u64 defined in arch/parisc/lib/bitops.c */
|
|
extern unsigned long __cmpxchg_u32(volatile unsigned int *m, unsigned int old,
|
|
unsigned int new_);
|
|
extern u64 __cmpxchg_u64(volatile u64 *ptr, u64 old, u64 new_);
|
|
extern u8 __cmpxchg_u8(volatile u8 *ptr, u8 old, u8 new_);
|
|
|
|
/* don't worry...optimizer will get rid of most of this */
|
|
static inline unsigned long
|
|
__cmpxchg(volatile void *ptr, unsigned long old, unsigned long new_, int size)
|
|
{
|
|
switch (size) {
|
|
#ifdef CONFIG_64BIT
|
|
case 8: return __cmpxchg_u64((u64 *)ptr, old, new_);
|
|
#endif
|
|
case 4: return __cmpxchg_u32((unsigned int *)ptr,
|
|
(unsigned int)old, (unsigned int)new_);
|
|
case 1: return __cmpxchg_u8((u8 *)ptr, old & 0xff, new_ & 0xff);
|
|
}
|
|
__cmpxchg_called_with_bad_pointer();
|
|
return old;
|
|
}
|
|
|
|
#define cmpxchg(ptr, o, n) \
|
|
({ \
|
|
__typeof__(*(ptr)) _o_ = (o); \
|
|
__typeof__(*(ptr)) _n_ = (n); \
|
|
(__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
|
|
(unsigned long)_n_, sizeof(*(ptr))); \
|
|
})
|
|
|
|
#include <asm-generic/cmpxchg-local.h>
|
|
|
|
static inline unsigned long __cmpxchg_local(volatile void *ptr,
|
|
unsigned long old,
|
|
unsigned long new_, int size)
|
|
{
|
|
switch (size) {
|
|
#ifdef CONFIG_64BIT
|
|
case 8: return __cmpxchg_u64((u64 *)ptr, old, new_);
|
|
#endif
|
|
case 4: return __cmpxchg_u32(ptr, old, new_);
|
|
default:
|
|
return __cmpxchg_local_generic(ptr, old, new_, size);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
|
|
* them available.
|
|
*/
|
|
#define cmpxchg_local(ptr, o, n) \
|
|
((__typeof__(*(ptr)))__cmpxchg_local((ptr), (unsigned long)(o), \
|
|
(unsigned long)(n), sizeof(*(ptr))))
|
|
#ifdef CONFIG_64BIT
|
|
#define cmpxchg64_local(ptr, o, n) \
|
|
({ \
|
|
BUILD_BUG_ON(sizeof(*(ptr)) != 8); \
|
|
cmpxchg_local((ptr), (o), (n)); \
|
|
})
|
|
#else
|
|
#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
|
|
#endif
|
|
|
|
#define cmpxchg64(ptr, o, n) __cmpxchg_u64(ptr, o, n)
|
|
|
|
#endif /* _ASM_PARISC_CMPXCHG_H_ */
|