[PATCH v5 1/5] drivers/raw: introduce AFU raw device driver

Huang, Wei wei.huang at intel.com
Tue Jun 7 03:36:11 CEST 2022



> -----Original Message-----
> From: Stephen Hemminger <stephen at networkplumber.org>
> Sent: Monday, June 6, 2022 23:38
> To: Huang, Wei <wei.huang at intel.com>
> Cc: dev at dpdk.org; thomas at monjalon.net; nipun.gupta at nxp.com;
> hemant.agrawal at nxp.com; stable at dpdk.org; Xu, Rosen
> <rosen.xu at intel.com>; Zhang, Tianfei <tianfei.zhang at intel.com>; Zhang, Qi
> Z <qi.z.zhang at 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.huang at 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.


More information about the stable mailing list