lkml.org 
[lkml]   [2019]   [Aug]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 2/2] cnic: Use refcount_t for refcount
On Wed, Jul 31, 2019 at 7:22 PM Chuhong Yuan <hslester96@gmail.com> wrote:
>
> Michael Chan <michael.chan@broadcom.com> 于2019年8月1日周四 上午1:58写道:
> >
> > On Wed, Jul 31, 2019 at 5:22 AM Chuhong Yuan <hslester96@gmail.com> wrote:
> >
> > > static void cnic_ctx_wr(struct cnic_dev *dev, u32 cid_addr, u32 off, u32 val)
> > > @@ -494,7 +494,7 @@ int cnic_register_driver(int ulp_type, struct cnic_ulp_ops *ulp_ops)
> > > }
> > > read_unlock(&cnic_dev_lock);
> > >
> > > - atomic_set(&ulp_ops->ref_count, 0);
> > > + refcount_set(&ulp_ops->ref_count, 0);
> > > rcu_assign_pointer(cnic_ulp_tbl[ulp_type], ulp_ops);
> > > mutex_unlock(&cnic_lock);
> > >
> >
> > Willem's comment applies here too. The driver needs to be modified to
> > count from 1 to use refcount_t.
> >
> > Thanks.
>
> I have revised this problem but find the other two refcounts -
> cnic_dev::ref_count
> and cnic_sock::ref_count have no set.
> I am not sure where to initialize them to 1.
>
> Besides, should ulp_ops->ref_count be set to 0 when unregistered?

I will send a patch to fix up the initialization of all the atomic ref
counts. After that, you can add your patch to convert to refcount_t.

\
 
 \ /
  Last update: 2019-08-02 01:16    [W:0.195 / U:0.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site