mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee.jones@linaro.org>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Andres Salomon <dilinger@queued.net>,
	Samuel Ortiz <sameo@linux.intel.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC] mfd: Stop setting refcounting pointers in original mfd_cell arrays
Date: Wed, 4 Dec 2013 08:30:01 +0000	[thread overview]
Message-ID: <20131204083001.GD7469@lee--X1> (raw)
In-Reply-To: <1383037384-30079-1-git-send-email-geert@linux-m68k.org>

On Tue, 29 Oct 2013, Geert Uytterhoeven wrote:

> Commit 1e29af62f2b285bd18685da93c3ce8c33ca2d1db ("mfd: Add refcounting
> support to mfd_cells") had to drop the "const" keyword on the "cell"
> parameter of mfd_add_devices(), as it added the refcounting pointers
> to the objects of the passed mfd_cell array itself.
> 
> However, the mfd core code operates on copies of the mfd_cell objects,
> so there's no need to modify the originally passed objects.
> 
> Hence, move the setting of the refcounting pointers from mfd_add_devices()
> to mfd_platform_add_cell(), where the copy of the mfd_cell objects is made.
> mfd_clone_cell() can just pass (a copy of) the original usage_count
> pointer.
> 
> This allows to make the "cell" parameter of mfd_add_devices() "const"
> again, and avoids future race conditions when registering multiple
> instances of the same device in parallel.
> 
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
> ---
> Ever since this "const" keyword was removed, I was wondering what was
> really going on with these reference counts. My main use case involved
> multiple instances of the same device, where the registration of each
> successive instance would overwrite the refcounting pointer of the
> previous one.
> Finally I found some time to dive into it, and create this patch.
> If it is accepted, I'll create a follow-up patch to add
> "const" keywords to the various mfd_cell arrays.
> 
> Note that there's another issue in mfd_add_devices(): if the first call to
> mfd_add_device() fails, the array of atomic_t objects will never be freed,
> as no child devices have been registered to the parent yet, and thus
> mfd_remove_devices() won't find anything to remove nor free.
> 
>  drivers/mfd/mfd-core.c   |   17 +++++++++--------
>  include/linux/mfd/core.h |    2 +-
>  2 files changed, 10 insertions(+), 9 deletions(-)

Hmm... I didn't see my reply to this, but it has been applied for a
while.

-- 
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

      parent reply	other threads:[~2013-12-04  8:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-29  9:03 Geert Uytterhoeven
2013-10-29 14:48 ` Geert Uytterhoeven
2013-12-04  8:30 ` Lee Jones [this message]

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=20131204083001.GD7469@lee--X1 \
    --to=lee.jones@linaro.org \
    --cc=dilinger@queued.net \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sameo@linux.intel.com \
    /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

Powered by JetHome