Re: [PATCH] TESTCASE: of: OOPS when disabling node via OF_DYNAMIC
Hi Grant, > On Jun 7, 2015, at 14:16 , Grant Likely wrote: > > On Wed, 22 Apr 2015 15:30:28 +0300 > , Pantelis Antoniou > wrote: >> Hi Wolfram, >> >>> On Apr 14, 2015, at 16:27 , Wolfram Sang wrote: >>> >>> Hi Pantelis, >>> >>> thanks for your prompt reply. Unfortunately, I had to wait until I could >>> access the test system again. >>> >> >> [snip] >> >> Sorry for the non-prompt reply; but just for kicks, can you try the attached >> patch? >> >> I have a hunch this might be the problem. >> >> Regards >> >> — Pantelis >> >> > > I played around with this some today. If I'm reading it correctly, the > following patch reproduces the same problem: > > (continued below patch) > --- > diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c > index 18016341d5a9..0a27b38c3041 100644 > --- a/drivers/of/unittest.c > +++ b/drivers/of/unittest.c > @@ -753,6 +753,11 @@ static void __init of_unittest_match_node(void) > } > } > > +static struct resource test_bus_res = { > + .start = 0xfff8, > + .end = 0xfff9, > + .flags = IORESOURCE_MEM, > +}; > static const struct platform_device_info test_bus_info = { > .name = "unittest-bus", > }; > @@ -795,6 +800,7 @@ static void __init of_unittest_platform_populate(void) > if (rc) > return; > test_bus->dev.of_node = np; > + platform_device_add_resources(test_bus, &test_bus_res, 1); > > of_platform_populate(np, match, NULL, &test_bus->dev); > for_each_child_of_node(np, child) { > > --- > > I think the fixup patch boils down to the following. It's hard to tell > because it combines refactoring with the bug fix. Do I have it correct? > If so, I'd rather commit the simple fix which can be committed now for > v4.1, and the refactoring can be pushed for v4.2 > > --- > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > index ebf034b97278..b3042e6ee3ef 100644 > --- a/drivers/base/platform.c > +++ b/drivers/base/platform.c > @@ -377,7 +377,7 @@ int platform_device_add(struct platform_device *pdev) > struct resource *r = &pdev->resource[i]; > unsigned long type = resource_type(r); > > - if (type == IORESOURCE_MEM || type == IORESOURCE_IO) > + if (r->parent) > release_resource(r); > } > > @@ -410,7 +410,7 @@ void platform_device_del(struct platform_device *pdev) > struct resource *r = &pdev->resource[i]; > unsigned long type = resource_type(r); > > - if (type == IORESOURCE_MEM || type == IORESOURCE_IO) > + if (r->parent) > release_resource(r); > } > } > Verified. No crashes. Acked-by: Pantelis Antoniou -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] TESTCASE: of: OOPS when disabling node via OF_DYNAMIC
On Tue, 09 Jun 2015 19:50:26 +0300 , Laurent Pinchart wrote: > Hi Grant, > > On Sunday 07 June 2015 12:16:32 Grant Likely wrote: > > On Wed, 22 Apr 2015 15:30:28 +0300, Pantelis Antoniou wrote: > > > > On Apr 14, 2015, at 16:27 , Wolfram Sang wrote: > > > > > > > > Hi Pantelis, > > > > > > > > thanks for your prompt reply. Unfortunately, I had to wait until I could > > > > access the test system again. > > > > > > [snip] > > > > > > Sorry for the non-prompt reply; but just for kicks, can you try the > > > attached patch? > > > > > > I have a hunch this might be the problem. > > > > > > Regards > > > > > > â Pantelis > > > > I played around with this some today. If I'm reading it correctly, the > > following patch reproduces the same problem: > > > > (continued below patch) > > --- > > diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c > > index 18016341d5a9..0a27b38c3041 100644 > > --- a/drivers/of/unittest.c > > +++ b/drivers/of/unittest.c > > @@ -753,6 +753,11 @@ static void __init of_unittest_match_node(void) > > } > > } > > > > +static struct resource test_bus_res = { > > + .start = 0xfff8, > > + .end = 0xfff9, > > + .flags = IORESOURCE_MEM, > > +}; > > static const struct platform_device_info test_bus_info = { > > .name = "unittest-bus", > > }; > > @@ -795,6 +800,7 @@ static void __init of_unittest_platform_populate(void) > > if (rc) > > return; > > test_bus->dev.of_node = np; > > + platform_device_add_resources(test_bus, &test_bus_res, 1); > > > > of_platform_populate(np, match, NULL, &test_bus->dev); > > for_each_child_of_node(np, child) { > > > > --- > > > > I think the fixup patch boils down to the following. It's hard to tell > > because it combines refactoring with the bug fix. Do I have it correct? > > If so, I'd rather commit the simple fix which can be committed now for > > v4.1, and the refactoring can be pushed for v4.2 > > The patch below looks equivalent to Pantelis' patch if we remove the > refactoring, but I don't immediately see how r->parent can be NULL in > platform_device_del() if type is equal to IORESOURCE_MEM or IORESOURCE_IO, as > platform_device_add() will have called insert_resource() in those cases, > which > should set the resource parent pointer. I must be missing something as the > patch fixes Wolfram's issue, so an explanation in the commit message would be > welcome. of_platform_populate() adds platform devices via of_device_add(). of_device_add() doesn't add the resources because there are platforms that break due to nodes with overlapping resources. g. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] TESTCASE: of: OOPS when disabling node via OF_DYNAMIC
Hi Grant, On Sunday 07 June 2015 12:16:32 Grant Likely wrote: > On Wed, 22 Apr 2015 15:30:28 +0300, Pantelis Antoniou wrote: > > > On Apr 14, 2015, at 16:27 , Wolfram Sang wrote: > > > > > > Hi Pantelis, > > > > > > thanks for your prompt reply. Unfortunately, I had to wait until I could > > > access the test system again. > > > > [snip] > > > > Sorry for the non-prompt reply; but just for kicks, can you try the > > attached patch? > > > > I have a hunch this might be the problem. > > > > Regards > > > > â Pantelis > > I played around with this some today. If I'm reading it correctly, the > following patch reproduces the same problem: > > (continued below patch) > --- > diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c > index 18016341d5a9..0a27b38c3041 100644 > --- a/drivers/of/unittest.c > +++ b/drivers/of/unittest.c > @@ -753,6 +753,11 @@ static void __init of_unittest_match_node(void) > } > } > > +static struct resource test_bus_res = { > + .start = 0xfff8, > + .end = 0xfff9, > + .flags = IORESOURCE_MEM, > +}; > static const struct platform_device_info test_bus_info = { > .name = "unittest-bus", > }; > @@ -795,6 +800,7 @@ static void __init of_unittest_platform_populate(void) > if (rc) > return; > test_bus->dev.of_node = np; > + platform_device_add_resources(test_bus, &test_bus_res, 1); > > of_platform_populate(np, match, NULL, &test_bus->dev); > for_each_child_of_node(np, child) { > > --- > > I think the fixup patch boils down to the following. It's hard to tell > because it combines refactoring with the bug fix. Do I have it correct? > If so, I'd rather commit the simple fix which can be committed now for > v4.1, and the refactoring can be pushed for v4.2 The patch below looks equivalent to Pantelis' patch if we remove the refactoring, but I don't immediately see how r->parent can be NULL in platform_device_del() if type is equal to IORESOURCE_MEM or IORESOURCE_IO, as platform_device_add() will have called insert_resource() in those cases, which should set the resource parent pointer. I must be missing something as the patch fixes Wolfram's issue, so an explanation in the commit message would be welcome. > --- > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > index ebf034b97278..b3042e6ee3ef 100644 > --- a/drivers/base/platform.c > +++ b/drivers/base/platform.c > @@ -377,7 +377,7 @@ int platform_device_add(struct platform_device *pdev) > struct resource *r = &pdev->resource[i]; > unsigned long type = resource_type(r); > > - if (type == IORESOURCE_MEM || type == IORESOURCE_IO) > + if (r->parent) > release_resource(r); > } > > @@ -410,7 +410,7 @@ void platform_device_del(struct platform_device *pdev) > struct resource *r = &pdev->resource[i]; > unsigned long type = resource_type(r); > > - if (type == IORESOURCE_MEM || type == IORESOURCE_IO) > + if (r->parent) > release_resource(r); > } > } -- Regards, Laurent Pinchart -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] TESTCASE: of: OOPS when disabling node via OF_DYNAMIC
On Wed, 22 Apr 2015 15:30:28 +0300 , Pantelis Antoniou wrote: > Hi Wolfram, > > > On Apr 14, 2015, at 16:27 , Wolfram Sang wrote: > > > > Hi Pantelis, > > > > thanks for your prompt reply. Unfortunately, I had to wait until I could > > access the test system again. > > > > [snip] > > Sorry for the non-prompt reply; but just for kicks, can you try the attached > patch? > > I have a hunch this might be the problem. > > Regards > > â Pantelis > > I played around with this some today. If I'm reading it correctly, the following patch reproduces the same problem: (continued below patch) --- diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index 18016341d5a9..0a27b38c3041 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c @@ -753,6 +753,11 @@ static void __init of_unittest_match_node(void) } } +static struct resource test_bus_res = { + .start = 0xfff8, + .end = 0xfff9, + .flags = IORESOURCE_MEM, +}; static const struct platform_device_info test_bus_info = { .name = "unittest-bus", }; @@ -795,6 +800,7 @@ static void __init of_unittest_platform_populate(void) if (rc) return; test_bus->dev.of_node = np; + platform_device_add_resources(test_bus, &test_bus_res, 1); of_platform_populate(np, match, NULL, &test_bus->dev); for_each_child_of_node(np, child) { --- I think the fixup patch boils down to the following. It's hard to tell because it combines refactoring with the bug fix. Do I have it correct? If so, I'd rather commit the simple fix which can be committed now for v4.1, and the refactoring can be pushed for v4.2 --- diff --git a/drivers/base/platform.c b/drivers/base/platform.c index ebf034b97278..b3042e6ee3ef 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c @@ -377,7 +377,7 @@ int platform_device_add(struct platform_device *pdev) struct resource *r = &pdev->resource[i]; unsigned long type = resource_type(r); - if (type == IORESOURCE_MEM || type == IORESOURCE_IO) + if (r->parent) release_resource(r); } @@ -410,7 +410,7 @@ void platform_device_del(struct platform_device *pdev) struct resource *r = &pdev->resource[i]; unsigned long type = resource_type(r); - if (type == IORESOURCE_MEM || type == IORESOURCE_IO) + if (r->parent) release_resource(r); } } -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] TESTCASE: of: OOPS when disabling node via OF_DYNAMIC
> This patch has been posted before but up to now, no-one had a test case that > triggered > the bug, At your service... ;) signature.asc Description: Digital signature
Re: [PATCH] TESTCASE: of: OOPS when disabling node via OF_DYNAMIC
Hi Wolfram, > On Apr 23, 2015, at 11:33 , Wolfram Sang wrote: > > >> Sorry for the non-prompt reply; but just for kicks, can you try the attached >> patch? >> >> I have a hunch this might be the problem. > > Yeah, this even makes my more complex driver work \o/ I will post it > once -rc1 is out. Thanks a lot for your help, much appreciated! > Good! This patch has been posted before but up to now, no-one had a test case that triggered the bug, so gregh was reluctant to pick it up. Let’s gang up on him :) Regards — Pantelis -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] TESTCASE: of: OOPS when disabling node via OF_DYNAMIC
> Sorry for the non-prompt reply; but just for kicks, can you try the attached > patch? > > I have a hunch this might be the problem. Yeah, this even makes my more complex driver work \o/ I will post it once -rc1 is out. Thanks a lot for your help, much appreciated! signature.asc Description: Digital signature
Re: [PATCH] TESTCASE: of: OOPS when disabling node via OF_DYNAMIC
Hi Wolfram, > On Apr 14, 2015, at 16:27 , Wolfram Sang wrote: > > Hi Pantelis, > > thanks for your prompt reply. Unfortunately, I had to wait until I could > access the test system again. > [snip] Sorry for the non-prompt reply; but just for kicks, can you try the attached patch? I have a hunch this might be the problem. Regards — Pantelis 0001-pdev-Fix-platform-device-resource-linking.patch Description: Binary data
Re: [PATCH] TESTCASE: of: OOPS when disabling node via OF_DYNAMIC
Hi Pantelis, thanks for your prompt reply. Unfortunately, I had to wait until I could access the test system again. > > + struct property status_chg = { .name = "status", .length = 9, .value = > > "disabled" }; > > + int ret; > > + > > ^ The status_chg property is on the stack. You can’t do that, because after > you go out > of scope the property is garbage. You should dynamically allocate. My actual driver does that dynamically. For the test case, I considered the stack to be enough to demonstrate my case. > I bet that even after you fix that you’ll crash anyway. Yes, it does. > Note is that on many platforms the path of removing platform devices is > borken. > I see that you’re using PM, that’s even more problematic. > > The good news is that we can probably fix it if you give us a detailed log and > stack trace. I'll attach the full boot log. I wonder what it contains what was not in the previous log :) Thanks, Wolfram === [0.00] Booting Linux on physical CPU 0x0 [0.00] Linux version 4.0.0-rc4-9-gcb55587ebc4047 (ninja@katana) (gcc version 4.9.2 (OSELAS.Toolchain-2014.12.0) ) #90 Tue Mar 31 17:04:52 CEST 2015 [0.00] CPU: ARMv7 Processor [413fc0f2] revision 2 (ARMv7), cr=10c5347d [0.00] CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache [0.00] Machine model: Lager [0.00] Ignoring memory block 0x14000 - 0x2 [0.00] debug: ignoring loglevel setting. [0.00] Memory policy: Data cache writeback [0.00] On node 0 totalpages: 262144 [0.00] free_area_init_node: node 0, pgdat c03dd6c0, node_mem_map eeff8000 [0.00] Normal zone: 1520 pages used for memmap [0.00] Normal zone: 0 pages reserved [0.00] Normal zone: 194560 pages, LIFO batch:31 [0.00] HighMem zone: 67584 pages, LIFO batch:15 [0.00] [ cut here ] [0.00] WARNING: CPU: 0 PID: 0 at arch/arm/kernel/devtree.c:144 arm_dt_init_cpu_maps+0xc0/0x130() [0.00] DT /cpu 2 nodes greater than max cores 1, capping them [0.00] CPU: 0 PID: 0 Comm: swapper Not tainted 4.0.0-rc4-9-gcb55587ebc4047 #90 [0.00] Hardware name: Generic R8A7790 (Flattened Device Tree) [0.00] Backtrace: [0.00] [] (dump_backtrace) from [] (show_stack+0x18/0x1c) [0.00] r6:c02ee547 r5:0009 r4: r3:0020 [0.00] [] (show_stack) from [] (dump_stack+0x20/0x28) [0.00] [] (dump_stack) from [] (warn_slowpath_common+0x8c/0xb4) [0.00] [] (warn_slowpath_common) from [] (warn_slowpath_fmt+0x38/0x40) [0.00] r8:eefcc690 r7:0001 r6: r5:0001 r4:eefcca98 [0.00] [] (warn_slowpath_fmt) from [] (arm_dt_init_cpu_maps+0xc0/0x130) [0.00] r3:0002 r2:c02ee5d3 [0.00] [] (arm_dt_init_cpu_maps) from [] (setup_arch+0x5f0/0x6c8) [0.00] r8:c02ee071 r7:c03cc630 r6:c03c7190 r5:c0340938 r4:ef7fcec0 [0.00] [] (setup_arch) from [] (start_kernel+0x88/0x394) [0.00] r10: r9:413fc0f2 r8:40004059 r7:c03c4040 r6: r5:c03de2c0 [0.00] r4: [0.00] [] (start_kernel) from [<40008070>] (0x40008070) [0.00] r9:413fc0f2 r8:40004059 r7:c03c72bc r6:c0341744 r5:c03c40b4 r4:c03de494 [0.00] ---[ end trace cb88537fdc8fa200 ]--- [0.00] CPU: All CPU(s) started in SVC mode. [0.00] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768 [0.00] pcpu-alloc: [0] 0 [0.00] Built 1 zonelists in Zone order, mobility grouping on. Total pages: 260624 [0.00] Kernel command line: ignore_loglevel rw root=/dev/nfs ip=dhcp [0.00] PID hash table entries: 4096 (order: 2, 16384 bytes) [0.00] Dentry cache hash table entries: 131072 (order: 7, 524288 bytes) [0.00] Inode-cache hash table entries: 65536 (order: 6, 262144 bytes) [0.00] Memory: 1027336K/1048576K available (2403K kernel code, 112K rwdata, 764K rodata, 644K init, 8035K bss, 21240K reserved, 0K cma-reserved, 270336K highmem) [0.00] Virtual kernel memory layout: [0.00] vector : 0x - 0x1000 ( 4 kB) [0.00] fixmap : 0xffc0 - 0xfff0 (3072 kB) [0.00] vmalloc : 0xf000 - 0xff00 ( 240 MB) [0.00] lowmem : 0xc000 - 0xef80 ( 760 MB) [0.00] pkmap : 0xbfe0 - 0xc000 ( 2 MB) [0.00] .text : 0xc0008000 - 0xc0320f7c (3172 kB) [0.00] .init : 0xc0321000 - 0xc03c2000 ( 644 kB) [0.00] .data : 0xc03c2000 - 0xc03de2c0 ( 113 kB) [0.00].bss : 0xc03de2c0 - 0xc0bb7038 (8036 kB) [0.00] NR_IRQS:16 nr_irqs:16 16 [0.00] Architected cp15 timer(s) running at 10.00MHz (virt). [0.08] sched_clock: 56 bits at 10MHz, resolution 100ns, wraps every 3435973836800ns [0.28] Switching to timer-based delay loop, resolution 100ns [
Re: [PATCH] TESTCASE: of: OOPS when disabling node via OF_DYNAMIC
Hi Wolfram, > On Mar 31, 2015, at 18:12 , Wolfram Sang wrote: > > From: Wolfram Sang > > I wanted to disable a node via OF_DYNAMIC by setting its status to disabled. > This code is the minimal testcase, the same happens in a more complex > scenario. > There is something wrong with freeing resources. Is my module wrong? Or is it > a > bug? Crashlog without CONFIG_I2C_CHARDEV, slightly shortened: > > [5.127314] of/notify UPDATE_PROPERTY /i2c@e60b:status > [5.132814] i2c-sh_mobile e60b.i2c: pm_clk_notify() 2 > [5.138504] bus: 'platform': remove device e60b.i2c > [5.143762] i2c-sh_mobile e60b.i2c: pm_clk_notify() 6 > [5.149231] device: '7-0068': device_unregister > [5.153982] bus: 'i2c': remove device 7-0068 > [5.158679] device: 'regulator.2': device_unregister > [5.165827] i2c 7-0068: uevent > [5.168997] i2c i2c-7: adapter [e60b.i2c] unregistered > [5.174462] device: 'i2c-7': device_unregister > [5.179057] bus: 'i2c': remove device i2c-7 > [5.183570] platform e60b.i2c: pm_clk_notify() 7 > [5.188595] platform e60b.i2c: Runtime PM disabled, clock forced off. > [5.195368] platform e60b.i2c: pm_clk_notify() 3 > [5.200426] Unable to handle kernel NULL pointer dereference at virtual > address 0018 > [5.208474] pgd = c0004000 > [5.211164] [0018] *pgd= > [5.214745] Internal error: Oops: 5 [#1] ARM > [5.218995] CPU: 0 PID: 1 Comm: swapper Tainted: GW > 4.0.0-rc4-9-gcb55587ebc4047 #90 > [5.228148] Hardware name: Generic R8A7790 (Flattened Device Tree) > [5.234288] task: ee84d340 ti: ee84e000 task.ti: ee84e000 > [5.239656] PC is at release_resource+0x20/0x68 > [5.244171] LR is at _raw_write_lock+0x3c/0x44 > [5.248591] pc : []lr : []psr: a113 > [5.248591] sp : ee84fcd8 ip : ee84fcb0 fp : ee84fcec > [5.259989] r10: r9 : c03de2c0 r8 : c03d5694 > [5.265180] r7 : ee84fdf4 r6 : 001c r5 : r4 : ee8efd00 > [5.271664] r3 : r2 : 0018 r1 : 0009 r0 : c03c7cd8 > [5.278149] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment > kernel > [5.285410] Control: 10c5347d Table: 40004059 DAC: 0015 > [5.291117] Process swapper (pid: 1, stack limit = 0xee84e208) > [5.296911] Stack: (0xee84fcd8 to 0xee85) > [5.301243] fcc0: > ee8f3e00 > [5.309375] fce0: ee84fd0c ee84fcf0 c01604fc c0024168 c03d39a0 ee8f3e00 > 0005 > [5.317507] fd00: ee84fd24 ee84fd10 c016054c c0160494 c03d39a0 ee8f3e10 > ee84fd3c ee84fd28 > [5.325639] fd20: c01aad54 c0160544 ee8f3e34 ee8f3e00 ee84fd64 ee84fd40 > c01ab3f8 c01aad08 > ... > [5.512643] Backtrace: > [5.515097] [] (release_resource) from [] > (platform_device_del+0x74/0x84) > [5.523561] r4:ee8f3e00 r3: > [5.527145] [] (platform_device_del) from [] > (platform_device_unregister+0x14/0x20) > [5.536469] r6:0005 r5: r4:ee8f3e00 r3:c03d39a0 > [5.542152] [] (platform_device_unregister) from [] > (of_platform_device_destroy+0x58/0xa8) > [5.552080] r4:ee8f3e10 r3:c03d39a0 > [5.555667] [] (of_platform_device_destroy) from [] > (of_platform_notify+0xcc/0xe8) > [5.564905] r4:ee8f3e00 r3:ee8f3e34 > [5.568493] [] (of_platform_notify) from [] > (notifier_call_chain+0x48/0x70) > [5.577128] r6:0005 r5: r4: > [5.581759] [] (notifier_call_chain) from [] > (__blocking_notifier_call_chain+0x4c/0x64) > [5.591429] r8:0005 r7:ee84fdf4 r6: r5:c03d7ba4 r4:c03d7b98 > r3: > [5.599192] [] (__blocking_notifier_call_chain) from > [] (blocking_notifier_call_chain+0x20/0x28) > [5.609637] r8:c0340d2c r7:c0340d2c r6:ee84fe88 r5:0005 r4:ee84fdf4 > [5.616365] [] (blocking_notifier_call_chain) from [] > (of_reconfig_notify+0x88/0xa8) > [5.625788] [] (of_reconfig_notify) from [] > (of_property_notify+0x44/0x4c) > [5.634338] r5:ee84fe88 r4:ee940440 > [5.637925] [] (of_property_notify) from [] > (__of_changeset_entry_notify+0x84/0xc4) > [5.647263] [] (__of_changeset_entry_notify) from [] > (of_changeset_apply+0xa4/0xe4) > [5.656588] r4:ee940440 > [5.659126] [] (of_changeset_apply) from [] > (test_init+0x84/0xa8) > [5.666900] r6: r5:c03356c0 r4:eefd18b8 > [5.671533] [] (test_init) from [] > (do_one_initcall+0x108/0x1bc) > [5.679220] r4:ee940440 > > Signed-off-by: Wolfram Sang > --- > drivers/of/Makefile | 2 +- > drivers/of/wsa_testcase.c | 48 +++ > 2 files changed, 49 insertions(+), 1 deletion(-) > create mode 100644 drivers/of/wsa_testcase.c > > diff --git a/drivers/of/Makefile b/drivers/of/Makefile > index 7563f36c71db34..4ec30a5bab39d5 100644 > --- a/drivers/of/Makefile > +++ b/drivers/of/Makefile > @@ -1,4 +1,4 @@ > -obj-y = base.o de
[PATCH] TESTCASE: of: OOPS when disabling node via OF_DYNAMIC
From: Wolfram Sang I wanted to disable a node via OF_DYNAMIC by setting its status to disabled. This code is the minimal testcase, the same happens in a more complex scenario. There is something wrong with freeing resources. Is my module wrong? Or is it a bug? Crashlog without CONFIG_I2C_CHARDEV, slightly shortened: [5.127314] of/notify UPDATE_PROPERTY /i2c@e60b:status [5.132814] i2c-sh_mobile e60b.i2c: pm_clk_notify() 2 [5.138504] bus: 'platform': remove device e60b.i2c [5.143762] i2c-sh_mobile e60b.i2c: pm_clk_notify() 6 [5.149231] device: '7-0068': device_unregister [5.153982] bus: 'i2c': remove device 7-0068 [5.158679] device: 'regulator.2': device_unregister [5.165827] i2c 7-0068: uevent [5.168997] i2c i2c-7: adapter [e60b.i2c] unregistered [5.174462] device: 'i2c-7': device_unregister [5.179057] bus: 'i2c': remove device i2c-7 [5.183570] platform e60b.i2c: pm_clk_notify() 7 [5.188595] platform e60b.i2c: Runtime PM disabled, clock forced off. [5.195368] platform e60b.i2c: pm_clk_notify() 3 [5.200426] Unable to handle kernel NULL pointer dereference at virtual address 0018 [5.208474] pgd = c0004000 [5.211164] [0018] *pgd= [5.214745] Internal error: Oops: 5 [#1] ARM [5.218995] CPU: 0 PID: 1 Comm: swapper Tainted: GW 4.0.0-rc4-9-gcb55587ebc4047 #90 [5.228148] Hardware name: Generic R8A7790 (Flattened Device Tree) [5.234288] task: ee84d340 ti: ee84e000 task.ti: ee84e000 [5.239656] PC is at release_resource+0x20/0x68 [5.244171] LR is at _raw_write_lock+0x3c/0x44 [5.248591] pc : []lr : []psr: a113 [5.248591] sp : ee84fcd8 ip : ee84fcb0 fp : ee84fcec [5.259989] r10: r9 : c03de2c0 r8 : c03d5694 [5.265180] r7 : ee84fdf4 r6 : 001c r5 : r4 : ee8efd00 [5.271664] r3 : r2 : 0018 r1 : 0009 r0 : c03c7cd8 [5.278149] Flags: NzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel [5.285410] Control: 10c5347d Table: 40004059 DAC: 0015 [5.291117] Process swapper (pid: 1, stack limit = 0xee84e208) [5.296911] Stack: (0xee84fcd8 to 0xee85) [5.301243] fcc0: ee8f3e00 [5.309375] fce0: ee84fd0c ee84fcf0 c01604fc c0024168 c03d39a0 ee8f3e00 0005 [5.317507] fd00: ee84fd24 ee84fd10 c016054c c0160494 c03d39a0 ee8f3e10 ee84fd3c ee84fd28 [5.325639] fd20: c01aad54 c0160544 ee8f3e34 ee8f3e00 ee84fd64 ee84fd40 c01ab3f8 c01aad08 ... [5.512643] Backtrace: [5.515097] [] (release_resource) from [] (platform_device_del+0x74/0x84) [5.523561] r4:ee8f3e00 r3: [5.527145] [] (platform_device_del) from [] (platform_device_unregister+0x14/0x20) [5.536469] r6:0005 r5: r4:ee8f3e00 r3:c03d39a0 [5.542152] [] (platform_device_unregister) from [] (of_platform_device_destroy+0x58/0xa8) [5.552080] r4:ee8f3e10 r3:c03d39a0 [5.555667] [] (of_platform_device_destroy) from [] (of_platform_notify+0xcc/0xe8) [5.564905] r4:ee8f3e00 r3:ee8f3e34 [5.568493] [] (of_platform_notify) from [] (notifier_call_chain+0x48/0x70) [5.577128] r6:0005 r5: r4: [5.581759] [] (notifier_call_chain) from [] (__blocking_notifier_call_chain+0x4c/0x64) [5.591429] r8:0005 r7:ee84fdf4 r6: r5:c03d7ba4 r4:c03d7b98 r3: [5.599192] [] (__blocking_notifier_call_chain) from [] (blocking_notifier_call_chain+0x20/0x28) [5.609637] r8:c0340d2c r7:c0340d2c r6:ee84fe88 r5:0005 r4:ee84fdf4 [5.616365] [] (blocking_notifier_call_chain) from [] (of_reconfig_notify+0x88/0xa8) [5.625788] [] (of_reconfig_notify) from [] (of_property_notify+0x44/0x4c) [5.634338] r5:ee84fe88 r4:ee940440 [5.637925] [] (of_property_notify) from [] (__of_changeset_entry_notify+0x84/0xc4) [5.647263] [] (__of_changeset_entry_notify) from [] (of_changeset_apply+0xa4/0xe4) [5.656588] r4:ee940440 [5.659126] [] (of_changeset_apply) from [] (test_init+0x84/0xa8) [5.666900] r6: r5:c03356c0 r4:eefd18b8 [5.671533] [] (test_init) from [] (do_one_initcall+0x108/0x1bc) [5.679220] r4:ee940440 Signed-off-by: Wolfram Sang --- drivers/of/Makefile | 2 +- drivers/of/wsa_testcase.c | 48 +++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 drivers/of/wsa_testcase.c diff --git a/drivers/of/Makefile b/drivers/of/Makefile index 7563f36c71db34..4ec30a5bab39d5 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile @@ -1,4 +1,4 @@ -obj-y = base.o device.o platform.o +obj-y = base.o device.o platform.o wsa_testcase.o obj-$(CONFIG_OF_DYNAMIC) += dynamic.o obj-$(CONFIG_OF_FLATTREE) += fdt.o obj-$(CONFIG_OF_EARLY_FLATTREE) += fdt_address.o diff --git a/drivers/of/wsa_testcase.c b/drivers/of/wsa_testcase.c new file mode 100