netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Chuhong Yuan <hslester96@gmail.com>
To: Michael Chan <michael.chan@broadcom.com>
Cc: "David S . Miller" <davem@davemloft.net>,
	Netdev <netdev@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 2/2] cnic: Use refcount_t for refcount
Date: Thu, 1 Aug 2019 10:22:07 +0800	[thread overview]
Message-ID: <CANhBUQ1J8hXBZv4x3pJhG_08ZS1zR=9Uj2EUta2sgtyND_QKPw@mail.gmail.com> (raw)
In-Reply-To: <CACKFLinuFebDgJN=BgK5e-bNaFqNpk61teva0=2xMH6R_iT39g@mail.gmail.com>

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?

  reply	other threads:[~2019-08-01  2:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-31 12:22 [PATCH 2/2] cnic: Use refcount_t for refcount Chuhong Yuan
2019-07-31 17:58 ` Michael Chan
2019-08-01  2:22   ` Chuhong Yuan [this message]
2019-08-01 23:15     ` Michael Chan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CANhBUQ1J8hXBZv4x3pJhG_08ZS1zR=9Uj2EUta2sgtyND_QKPw@mail.gmail.com' \
    --to=hslester96@gmail.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.chan@broadcom.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).