On Fri, 27 May 2022 01:37:00 -0400 Wei Huang <wei.hu...@intel.com> wrote:
> +static inline int afu_mf_trylock(struct afu_mf_rawdev *dev) > +{ > + int32_t x = 0; > + > + if (!dev || !dev->shared) > + return -ENODEV; > + > + x = __atomic_load_n(&dev->shared->lock, __ATOMIC_RELAXED); > + > + if ((x != 0) || (__atomic_compare_exchange_n(&dev->shared->lock, &x, 1, > + 1, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED) == 0)) > + return -EBUSY; > + > + return 0; > +} > + > +static inline void afu_mf_unlock(struct afu_mf_rawdev *dev) > +{ > + if (!dev || !dev->shared) > + return; > + > + __atomic_store_n(&dev->shared->lock, 0, __ATOMIC_RELEASE); > +} What other subsystem is this shared with? Is there a good reason it can't just use existing spinlock?