> -----Original Message-----
> From: Stephen Hemminger <step...@networkplumber.org>
> Sent: Monday, June 6, 2022 23:38
> To: Huang, Wei <wei.hu...@intel.com>
> Cc: dev@dpdk.org; tho...@monjalon.net; nipun.gu...@nxp.com;
> hemant.agra...@nxp.com; sta...@dpdk.org; Xu, Rosen
> <rosen...@intel.com>; Zhang, Tianfei <tianfei.zh...@intel.com>; Zhang, Qi
> Z <qi.z.zh...@intel.com>
> Subject: Re: [PATCH v5 1/5] drivers/raw: introduce AFU raw device driver
>
> 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?
This lock is used in multi-process situation, it prevent AFU from being
operated by two DPDK process simultaneously.
I can use spinlock to replace it, thanks.