All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marcel Holtmann <marcel@holtmann.org>
To: David Herrmann <dh.herrmann@googlemail.com>
Cc: linux-bluetooth@vger.kernel.org, padovan@profusion.mobi
Subject: Re: [RFC 0/4] Fix hci_dev ref-counts
Date: Mon, 31 Oct 2011 12:58:58 +0100	[thread overview]
Message-ID: <1320062340.15441.265.camel@aeonflux> (raw)
In-Reply-To: <1319806804-12230-1-git-send-email-dh.herrmann@googlemail.com>

Hi David,

> We currently have two reference counters for each hci_dev. This patchset tries
> to reduce this to one ref-count and fix several bugs with them. The two
> available ref-counts currently are:
> 
> 1) hci_dev->dev internal
> This ref-count is increased by hci_alloc_dev() and decreased inside
> hci_free_dev(). No other code currently uses this refcount. It can be set with
> get_device() and put_device().
> When this ref-count drops zero, then the hci_dev structure is deallocated (see
> bt_link_release inside hci_sysfs.c), hence, this ref-count is the most important
> one. However, we currently do not use it correctly.
> 
> 2) hci_dev->refcnt
> This ref-count is used inside hci_dev_hold/put() and practically used as if it
> would protect the hci_dev structure. However, if this ref-count drops zero, then
> the ->destruct callback is called which is used by all drivers *exclusively* to
> deallocate driver structures and *not* to deallocate or destroy the hci_dev.

actually I think we should convert the tasklets into one workqueue first
and then integrate deeper into sysfs before trying to hack around this
problem.

Our core driver registration code is from the 2.4 series and needs major
updating. The sysfs code is glued on top of it and not really well
integrated. So fixing that one properly might make some of these race
conditions go away.

Regards

Marcel



  parent reply	other threads:[~2011-10-31 11:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-28 13:00 [RFC 0/4] Fix hci_dev ref-counts David Herrmann
2011-10-28 13:00 ` [RFC 1/4] Bluetooth: Remove obsolete hci-destruct callback David Herrmann
2011-10-28 13:00 ` [RFC 2/4] Bluetooth: Fix hci-sysfs ref-counts David Herrmann
2011-10-29 16:40   ` David Herrmann
2011-10-28 13:00 ` [RFC 3/4] Bluetooth: Remove hci owner field David Herrmann
2011-10-28 13:00 ` [RFC 4/4] Bluetooth: Correctly take device refcounts David Herrmann
2011-10-31 11:58 ` Marcel Holtmann [this message]
2011-11-01 19:59   ` [RFC 0/4] Fix hci_dev ref-counts David Herrmann

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=1320062340.15441.265.camel@aeonflux \
    --to=marcel@holtmann.org \
    --cc=dh.herrmann@googlemail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=padovan@profusion.mobi \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.