devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robherring2@gmail.com>
To: Grant Likely <grant.likely@linaro.org>
Cc: Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Rob Herring <rob.herring@calxeda.com>,
	Kishon Vijay Abraham I <kishon@ti.com>,
	George Cherian <george.cherian@ti.com>,
	"linux-samsung-soc@vger.kernel.org"
	<linux-samsung-soc@vger.kernel.org>,
	devicetree-discuss <devicetree-discuss@lists.ozlabs.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Felipe Balbi <balbi@ti.com>, Kukjin Kim <kgene.kim@samsung.com>,
	Vivek Gautam <gautam.vivek@samsung.com>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	Naveen Krishna Chatradhi <ch.naveen@samsung.com>,
	Roger Quadros <rogerq@ti.com>
Subject: Re: [PATCH] of: provide of_platform_unpopulate()
Date: Mon, 22 Jul 2013 16:16:07 -0500	[thread overview]
Message-ID: <51EDA117.10605@gmail.com> (raw)
In-Reply-To: <CACxGe6sqv2Wsp26MWqqs9W_eWO3tjs-+2z3z8fC=2fe-BjJvkA@mail.gmail.com>

On 07/21/2013 06:44 PM, Grant Likely wrote:
> On Sun, Jul 21, 2013 at 9:48 PM, Rob Herring <robherring2@gmail.com> wrote:
>> On 07/21/2013 09:42 AM, Rob Herring wrote:
>>> On 07/19/2013 01:14 PM, Sebastian Andrzej Siewior wrote:
>>>> So I called of_platform_populate() on a device to get each child device
>>>> probed and on rmmod and I need to reverse its doing. After a quick grep
>>>> I did what others did as well and rmmod ended in:
>>>>
>>>> | Unable to handle kernel NULL pointer dereference at virtual address 00000018
>>>> | PC is at release_resource+0x18/0x80
>>>> | Process rmmod (pid: 2005, stack limit = 0xedc30238)
>>>> | [<c003add0>] (release_resource+0x18/0x80) from [<c0300e08>] (platform_device_del+0x78/0xac)
>>>> | [<c0300e08>] (platform_device_del+0x78/0xac) from [<c0301358>] (platform_device_unregister+0xc/0x18)
>>>>
>>>> The problem is that platform_device_del() "releases" each ressource in its
>>>> tree. This does not work on platform_devices created by OF becuase they
>>>> were never added via insert_resource(). As a consequence old->parent in
>>>> __release_resource() is NULL and we explode while accessing ->child.
>>>> So I either I do something completly wrong _or_ nobody here tested the
>>>> rmmod path of their driver.
>>>
>>> Wouldn't the correct fix be to call insert_resource somehow? The problem
>>> I have is that while of_platform_populate is all about parsing the DT
>>> and creating devices, the removal side has nothing to do with DT. So
>>> this should not be in the DT code. I think the core device code should
>>> be able to handle removal if the device creation side is done correctly.
>>>
>>> It looks to me like of_device_add either needs to call
>>> platform_device_add rather than device_add. I think the device name
>>> setting in platform_device_add should be a nop. If not, a check that the
>>> name is already set could be added.
>>>
>>
>> BTW, it looks like Grant has attempted this already:
> 
> Yup, things broke badly. Unfortunately the of_platform_device and
> platform_device history doesn't treat resources in the same way. I
> would like to merge the code, but I haven't been able to figure out a
> clean way to do it. Looks like we do need the unpopulate function.

Was there more breakage than imx6 and amba devices? Your first version
had a fallback case for powerpc. Couldn't we do just allow that for more
than just powerpc? I'd much rather see some work-around within the core
DT code with a warning to prevent more proliferation than putting this
into drivers.

Rob

  reply	other threads:[~2013-07-22 21:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-19 18:14 [PATCH] of: provide of_platform_unpopulate() Sebastian Andrzej Siewior
     [not found] ` <1374257691-31981-1-git-send-email-bigeasy-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
2013-07-21 14:42   ` Rob Herring
     [not found]     ` <51EBF33A.4050207-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-07-21 19:47       ` Sebastian Andrzej Siewior
2013-07-21 20:48     ` Rob Herring
     [not found]       ` <51EC4908.4040504-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-07-21 23:44         ` Grant Likely
2013-07-22 21:16           ` Rob Herring [this message]
2013-07-24 14:19             ` Grant Likely
2013-07-31 15:21               ` Sebastian Andrzej Siewior
2013-07-29  9:33           ` Benjamin Herrenschmidt
2013-07-31 16:28             ` Rob Herring
2013-07-29  9:31 ` Benjamin Herrenschmidt
  -- strict thread matches above, loose matches on Subject: below --
2013-07-20  5:03 NAVEEN KRISHNA CHATRADHI
2013-07-20  5:43 NAVEEN KRISHNA CHATRADHI
2013-07-22  8:25 ` Sebastian Andrzej Siewior

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=51EDA117.10605@gmail.com \
    --to=robherring2@gmail.com \
    --cc=balbi@ti.com \
    --cc=bigeasy@linutronix.de \
    --cc=ch.naveen@samsung.com \
    --cc=devicetree-discuss@lists.ozlabs.org \
    --cc=gautam.vivek@samsung.com \
    --cc=george.cherian@ti.com \
    --cc=grant.likely@linaro.org \
    --cc=kgene.kim@samsung.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=rob.herring@calxeda.com \
    --cc=rogerq@ti.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;
as well as URLs for NNTP newsgroup(s).