linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jingoo Han <jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
To: 'Mark Brown' <broonie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	'Julia Lawall' <julia.lawall-L2FTfq7BK8M@public.gmane.org>
Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	'Jingoo Han' <jg1.han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
Subject: Re: devm_spi_register_master
Date: Tue, 12 Nov 2013 15:48:17 +0900	[thread overview]
Message-ID: <000301cedf73$2ae7a3e0$80b6eba0$%han@samsung.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1311111915570.2321@hadrien>

On Tuesday, November 12, 2013 12:19 PM, Julia Lawall wrote:
> On Tue, 12 Nov 2013, Jingoo Han wrote:
> > On Tuesday, November 12, 2013 2:45 AM, Julia Lawall wrote:
> > >
> > > I was looking into the use of devm_spi_register_master.  This function
> > > seems to take care of registering and unregistering, but not allocation
> > > and freeing.  I have the impression that that is done with
> > > spi_alloc_master and and spi_master_put, which are not managed functions.
> > > But then I wonder how this can work?  It seems that the spi_master_put
> > > function should remain in the probe or remove function, and then the
> > > object could be freed before it is unregistered?
> > >
> > > The patch 2fe7e4add3e53df7c1b97e32076f8390dd81c6b3 introduces a call to
> > > devm_spi_register_master and also removes a call to spi_master_put.  By my
> > > reasoning, this would cause a memory leak.
> >
> > Hi Julia Lawall,
> >
> > I already checked that the patch 2fe7e4a "spi: txx9: use
> > devm_spi_register_master()" is right. The call to spi_master_put()
> > was duplicated. So, it should be removed.
> >
> > When removing the driver, the following functions are called.
> > : devm_spi_unregister()
> >        -> spi_unregister_master()
> >            -> device_unregister()
> >                -> put_device()
> >
> > Also, spi_master_put() calls the following functions.
> > : spi_master_put()
> >        -> put_device()
> >
> > So, put_device() is duplicated, when devm_spi_register_master()
> > is used. In this case, spi_master_put() can be removed.
> 
> spi_register_master calls device_add, which seems to increment the
> reference count.  So it may be that both calls to put_device are needed.
> On the other hand, in that case it would be safe to invert their order.
> 

Hi Mark,

By the way, now I am testing s3c64xx by repeating modprobe & rmmod.
However, after s3c64xx_spi_remove() by rmmod, devm_spi_unregister()
is not called. So, at the next calling modprobe, it makes kernel panic.
On the other hand, When spi_unregister_master()& spi_master_put()
are added, the kernel panic does not happen.

Best regards,
Jingoo Han

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2013-11-12  6:48 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-11 17:44 devm_spi_register_master Julia Lawall
2013-11-12  0:06 ` devm_spi_register_master Jingoo Han
     [not found]   ` <002701cedf3b$19f5b280$4de11780$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-11-12  3:18     ` devm_spi_register_master Julia Lawall
2013-11-12  6:48       ` Jingoo Han [this message]
     [not found]         ` <000301cedf73$2ae7a3e0$80b6eba0$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-11-22  2:13           ` devm_spi_register_master Jingoo Han
2013-11-15  8:24       ` devm_spi_register_master Jingoo Han
     [not found]         ` <000e01cee1dc$12a4fba0$37eef2e0$%han-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org>
2013-11-15  8:49           ` devm_spi_register_master Wei Yongjun
     [not found]             ` <CAPgLHd9hFNuke_cfs9QrQ0E0E_QmRfN3=fESUtBH6PPGgx=Wbw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2013-11-16 16:05               ` devm_spi_register_master Julia Lawall
2013-11-16 10:50 ` devm_spi_register_master Mark Brown
     [not found]   ` <20131116105029.GN15393-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-11-16 15:24     ` devm_spi_register_master Julia Lawall
2013-11-16 15:45       ` devm_spi_register_master Mark Brown

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='000301cedf73$2ae7a3e0$80b6eba0$%han@samsung.com' \
    --to=jg1.han-sze3o3uu22jbdgjk7y7tuq@public.gmane.org \
    --cc=broonie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=julia.lawall-L2FTfq7BK8M@public.gmane.org \
    --cc=linux-spi-u79uwXL29TY76Z2rM5mHXA@public.gmane.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).