From: Maxime Ripard <maxime.ripard@free-electrons.com>
To: Mark Brown <broonie@kernel.org>
Cc: linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-spi@vger.kernel.org
Subject: Re: [PATCH 0/3] spi: core: Introduce devm_spi_alloc_master
Date: Sun, 2 Feb 2014 15:54:27 +0100 [thread overview]
Message-ID: <20140202145427.GB3157@lukather> (raw)
In-Reply-To: <20140201173841.GU22609@sirena.org.uk>
[-- Attachment #1: Type: text/plain, Size: 2179 bytes --]
Hi,
On Sat, Feb 01, 2014 at 05:38:41PM +0000, Mark Brown wrote:
> On Fri, Jan 31, 2014 at 02:31:11PM +0100, Maxime Ripard wrote:
> > On Fri, Jan 31, 2014 at 12:12:15PM +0000, Mark Brown wrote:
>
> > > This seems confusing - the idea here is that if we've handed the
> > > device off to the managed function then the managed function
> > > deals with destroying it. Note that spi_alloc_master() says
> > > that the put is only required after errors adding the device
> > > (which would be the expected behaviour if you look at other
> > > APIs). Looking at the code I think there is an issue here but
> > > I'm not at all clear that this is the best fix.
>
> > Ah, right, spi_master_put doesn't free the memory either...
>
> The memory is freed by the driver core calling the
> spi_master_release() callback when it's safe to do so (after the
> last reference to the device has gone away).
>
> > I guess we have a few choices here, either:
> > - Add a devm_kzalloc to spi_alloc_master, since most of the drivers
> > I've been looking at fail to free the memory, this would be the
> > least intrusive solution. We'd still have to remove all the kfree
> > calls in the driver that rightfully free the memory.
> > - Make devm_unregister_master also call kfree on the master
> > - Add a kfree to my devm_put_master so that the memory is reclaimed,
> > which isn't the case for now.
>
> > I don't have a strong preference here, maybe for the third one, since
> > it makes obvious that it's managed and you don't have to do anything
> > about it, while the other do not.
>
> None of the above, definitely nothing to do with calling kfree() once
> the device is registered. We already have that free, it's not the
> issue. The issue is making sure that we hold references when we need
> them and drop them when we don't. I (or someone) needs to sit down and
> think it through since things are a bit confused in the code.
Ok. I'll drop the patches and repost the A31 SPI patches.
Thanks!
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
prev parent reply other threads:[~2014-02-02 14:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-31 10:23 [PATCH 0/3] spi: core: Introduce devm_spi_alloc_master Maxime Ripard
2014-01-31 10:23 ` [PATCH 1/3] spi: core: Add devm_spi_alloc_master Maxime Ripard
2014-01-31 10:23 ` [PATCH 2/3] spi: core: Update the devm_spi_register_master documentation Maxime Ripard
2014-01-31 10:23 ` [PATCH 3/3] spi: switch to devm_spi_alloc_master Maxime Ripard
[not found] ` <1391163792-21819-4-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-31 16:18 ` Stephen Warren
2014-01-31 22:49 ` Maxime Ripard
2014-02-02 12:33 ` Gerhard Sittig
[not found] ` <1391163792-21819-1-git-send-email-maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2014-01-31 12:12 ` [PATCH 0/3] spi: core: Introduce devm_spi_alloc_master Mark Brown
2014-01-31 13:31 ` Maxime Ripard
2014-02-01 17:38 ` Mark Brown
2014-02-02 14:54 ` Maxime Ripard [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=20140202145427.GB3157@lukather \
--to=maxime.ripard@free-electrons.com \
--cc=broonie@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@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).