[PATCH v2] of: __of_update_property_sysfs only call __of_sysfs_remove_bin_file if of_node_is_attached

2018-09-19 Thread Andre Kalb
Hi Rob,

I have used an other hardware to check the patch. I hope it doesn't matter. I 
added few lines at the untitest.c. All existing unittest use an attached sysfs, 
therefore the bug isn't detectable.

The patch of the unittest is posted: 
https://lore.kernel.org/patchwork/patch/985738/

[ cut here ]
WARNING: CPU: 0 PID: 1 at fs/kernfs/dir.c:1481 
kernfs_remove_by_name_ns+0x9c/0xa4
kernfs: can not remove '(null)', no directory
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.18.7 #3
Hardware name: Freescale i.MX6 Ultralite (Device Tree)
[] (unwind_backtrace) from [] (show_stack+0x10/0x14)
[] (show_stack) from [] (__warn+0xe0/0xf8)
[] (__warn) from [] (warn_slowpath_fmt+0x44/0x68)
[] (warn_slowpath_fmt) from [] 
(kernfs_remove_by_name_ns+0x9c/0xa4)
[] (kernfs_remove_by_name_ns) from [] 
(__of_update_property_sysfs+0x38/0x50)
[] (__of_update_property_sysfs) from [] 
(of_update_property+0xc0/0x104)
[] (of_update_property) from [] (of_unittest+0x1b8/0x28d4)
[] (of_unittest) from [] (do_one_initcall+0x40/0x218)
[] (do_one_initcall) from [] 
(kernel_init_freeable+0x24c/0x2e4)
[] (kernel_init_freeable) from [] (kernel_init+0x8/0x110)
[] (kernel_init) from [] (ret_from_fork+0x14/0x2c)
Exception stack(0xcc099fb0 to 0xcc099ff8)
9fa0:    
9fc0:        
9fe0:     0013 
---[ end trace 4522f69e0760e4d5 ]---

Best regards
Andre Kalb

> -Ursprüngliche Nachricht-
> Von: Rob Herring [mailto:robh...@kernel.org]
> Gesendet: Montag, 10. September 2018 15:47
> An: Andre Kalb
> Cc: Frank Rowand; devicet...@vger.kernel.org; linux-kernel@vger.kernel.org
> Betreff: Re: [PATCH v2] of: __of_update_property_sysfs only call
> __of_sysfs_remove_bin_file if of_node_is_attached
>
> On Mon, Sep 10, 2018 at 4:51 AM Andre Kalb  wrote:
> >
> > Hi Frank,
> >
> > > -Ursprüngliche Nachricht-
> > > Von: Frank Rowand [mailto:frowand.l...@gmail.com]
> > > Gesendet: Freitag, 7. September 2018 22:01
> > > An: Andre Kalb; robh...@kernel.org; devicet...@vger.kernel.org;
> > > linux- ker...@vger.kernel.org
> > > Betreff: Re: [PATCH v2] of: __of_update_property_sysfs only call
> > > __of_sysfs_remove_bin_file if of_node_is_attached
> > >
> > > Hi Andred,
> > >
> > > On 09/04/18 08:51, Andre Kalb wrote:
> > > > To prevent warning "kernfs: can not remove '(null)', no directory"
> > > > if an overlay
> > > isn't applied to the active devicetree.
> > > >
> > > > Using of_remove_property and then of_add_property doesn't show the
> > > warning.
>
> [...]
>
> > > What is the calling path that results in the warning?
> > >
> > > -Frank
> >
> > There is the callstack of the warning.
> >
> > [   10.782830] [ cut here ]
> > [   10.830357] WARNING: CPU: 0 PID: 170 at /linux-4.x/fs/kernfs/dir.c:1276
> kernfs_remove_by_name_ns+0x30/0x80()
> > [   10.928997] kernfs: can not remove '(null)', no directory
> > [   10.993107] Modules linked in: module_capemgr(+)
> > [   11.045750] CPU: 0 PID: 170 Comm: systemd-udevd Not tainted 4.4.143-
> 00158-g8e5ca65ec7ee-dirty #114
>
> 158 patches on top of an almost 3 year old kernel...
>
> > [   12.011373] [] (module_capemgr_slot_scan [module_capemgr])
> from [] (module_capemgr_probe+0x3c/0x58 [module_capemgr])
>
> And a driver that's not upstream.
>
> Not saying the fix isn't valid, but please reproduce on recent mainline. Add a
> unittest if you have to.
>
> Rob

___

SMA Solar Technology AG
Aufsichtsrat: Dr. Erik Ehrentraut (Vorsitzender)
Vorstand: Ulrich Hadding, Dr.-Ing. Juergen Reinert, Pierre-Pascal Urbon
Handelsregister: Amtsgericht Kassel HRB 3972
Sitz der Gesellschaft: 34266 Niestetal
USt-ID-Nr. DE 113 08 59 54
WEEE-Reg.-Nr. DE 95881150
___


[PATCH v2] of: __of_update_property_sysfs only call __of_sysfs_remove_bin_file if of_node_is_attached

2018-09-17 Thread Andre Kalb
Hi Rob,

I have used an other hardware to check the patch. I hope it doesn’t matter. I 
added few lines at the untitest.c. All existing unittest use an attached sysfs, 
therefore the bug isn't detectable.

Best regards
Andre Kalb


> On Thu, Sep 13, 2018 at 4:42 PM Andre Kalb  wrote:
> From 1e86e351efa1a7cea31d157bafb0ae40b856cdcc Mon Sep 17 00:00:00
> 2001
> From: Andre Kalb 
> Date: Thu, 13 Sep 2018 16:42:48 +0200
> Subject: [PATCH] Added new unittest
>
> ---
>  drivers/of/unittest.c | 18 ++
>  1 file changed, 18 insertions(+)
>
> diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index
> 2a547ca3d443..17f6cacb4fae 100644
> --- a/drivers/of/unittest.c
> +++ b/drivers/of/unittest.c
> @@ -923,6 +923,24 @@ static int __init unittest_data_add(void)
>   return -EINVAL;
>   }
>
> + {
> + struct property *prop;
> +
> + prop = kzalloc(sizeof(*prop), GFP_KERNEL);
> + if (!prop) {
> + unittest(0, "kzalloc() failed\n");
> + return -ENOMEM;
> + }
> +
> + np = of_find_node_with_property(unittest_data_node, "prop-
> update");
> + unittest(np, "find prop-update");
> +
> + prop->name = "prop-update";
> + prop->value = "new-property-data";
> + prop->length = strlen(prop->value) + 1;
> + unittest(of_update_property(np, prop) == 0, "Update a existing
> property failed\n");
> + }
> +
>   if (!of_root) {
>   of_root = unittest_data_node;
>   for_each_of_allnodes(np)
> --
> 2.16.4

[ cut here ]
WARNING: CPU: 0 PID: 1 at fs/kernfs/dir.c:1481 
kernfs_remove_by_name_ns+0x9c/0xa4
kernfs: can not remove '(null)', no directory
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.18.7 #3
Hardware name: Freescale i.MX6 Ultralite (Device Tree)
[] (unwind_backtrace) from [] (show_stack+0x10/0x14)
[] (show_stack) from [] (__warn+0xe0/0xf8)
[] (__warn) from [] (warn_slowpath_fmt+0x44/0x68)
[] (warn_slowpath_fmt) from [] 
(kernfs_remove_by_name_ns+0x9c/0xa4)
[] (kernfs_remove_by_name_ns) from [] 
(__of_update_property_sysfs+0x38/0x50)
[] (__of_update_property_sysfs) from [] 
(of_update_property+0xc0/0x104)
[] (of_update_property) from [] (of_unittest+0x1b8/0x28d4)
[] (of_unittest) from [] (do_one_initcall+0x40/0x218)
[] (do_one_initcall) from [] 
(kernel_init_freeable+0x24c/0x2e4)
[] (kernel_init_freeable) from [] (kernel_init+0x8/0x110)
[] (kernel_init) from [] (ret_from_fork+0x14/0x2c)
Exception stack(0xcc099fb0 to 0xcc099ff8)
9fa0:    
9fc0:        
9fe0:  0000 0000  0013 
---[ end trace 4522f69e0760e4d5 ]---



> -Ursprüngliche Nachricht-
> Von: Rob Herring [mailto:robh...@kernel.org]
> Gesendet: Montag, 10. September 2018 15:47
> An: Andre Kalb
> Cc: Frank Rowand; devicet...@vger.kernel.org; linux-kernel@vger.kernel.org
> Betreff: Re: [PATCH v2] of: __of_update_property_sysfs only call
> __of_sysfs_remove_bin_file if of_node_is_attached
>
> On Mon, Sep 10, 2018 at 4:51 AM Andre Kalb  wrote:
> >
> > Hi Frank,
> >
> > > -Ursprüngliche Nachricht-
> > > Von: Frank Rowand [mailto:frowand.l...@gmail.com]
> > > Gesendet: Freitag, 7. September 2018 22:01
> > > An: Andre Kalb; robh...@kernel.org; devicet...@vger.kernel.org;
> > > linux- ker...@vger.kernel.org
> > > Betreff: Re: [PATCH v2] of: __of_update_property_sysfs only call
> > > __of_sysfs_remove_bin_file if of_node_is_attached
> > >
> > > Hi Andred,
> > >
> > > On 09/04/18 08:51, Andre Kalb wrote:
> > > > To prevent warning "kernfs: can not remove '(null)', no directory"
> > > > if an overlay
> > > isn't applied to the active devicetree.
> > > >
> > > > Using of_remove_property and then of_add_property doesn't show the
> > > warning.
>
> [...]
>
> > > What is the calling path that results in the warning?
> > >
> > > -Frank
> >
> > There is the callstack of the warning.
> >
> > [   10.782830] [ cut here ]
> > [   10.830357] WARNING: CPU: 0 PID: 170 at /linux-4.x/fs/kernfs/dir.c:1276
> kernfs_remove_by_name_ns+0x30/0x80()
> > [   10.928997] kernfs: can not remove '(null)', no directory
> > [   10.993107] Modules linked in: module_capemgr(+)
> > [   11.045750] CPU: 0 PID

AW: [PATCH v2] of: __of_update_property_sysfs only call __of_sysfs_remove_bin_file if of_node_is_attached

2018-09-13 Thread Andre Kalb
Hi Rob,

I have used an other hardware to check the patch. I hope it doesn’t matter. I 
added few lines at the untitest.c. All existing unittest use an attached sysfs, 
therefore the bug isn't detectable.

Best regards
Andre Kalb

From 1e86e351efa1a7cea31d157bafb0ae40b856cdcc Mon Sep 17 00:00:00 2001
From: Andre Kalb 
Date: Thu, 13 Sep 2018 16:42:48 +0200
Subject: [PATCH] Added new unittest

---
 drivers/of/unittest.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index 2a547ca3d443..17f6cacb4fae 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -923,6 +923,24 @@ static int __init unittest_data_add(void)
return -EINVAL;
}

+   {
+   struct property *prop;
+
+   prop = kzalloc(sizeof(*prop), GFP_KERNEL);
+   if (!prop) {
+   unittest(0, "kzalloc() failed\n");
+   return -ENOMEM;
+   }
+
+   np = of_find_node_with_property(unittest_data_node, 
"prop-update");
+   unittest(np, "find prop-update");
+
+   prop->name = "prop-update";
+   prop->value = "new-property-data";
+   prop->length = strlen(prop->value) + 1;
+   unittest(of_update_property(np, prop) == 0, "Update a existing 
property failed\n");
+   }
+
if (!of_root) {
of_root = unittest_data_node;
for_each_of_allnodes(np)
--
2.16.4


[ cut here ]
WARNING: CPU: 0 PID: 1 at fs/kernfs/dir.c:1481 
kernfs_remove_by_name_ns+0x9c/0xa4
kernfs: can not remove '(null)', no directory
Modules linked in:
CPU: 0 PID: 1 Comm: swapper Not tainted 4.18.7 #3
Hardware name: Freescale i.MX6 Ultralite (Device Tree)
[] (unwind_backtrace) from [] (show_stack+0x10/0x14)
[] (show_stack) from [] (__warn+0xe0/0xf8)
[] (__warn) from [] (warn_slowpath_fmt+0x44/0x68)
[] (warn_slowpath_fmt) from [] 
(kernfs_remove_by_name_ns+0x9c/0xa4)
[] (kernfs_remove_by_name_ns) from [] 
(__of_update_property_sysfs+0x38/0x50)
[] (__of_update_property_sysfs) from [] 
(of_update_property+0xc0/0x104)
[] (of_update_property) from [] (of_unittest+0x1b8/0x28d4)
[] (of_unittest) from [] (do_one_initcall+0x40/0x218)
[] (do_one_initcall) from [] 
(kernel_init_freeable+0x24c/0x2e4)
[] (kernel_init_freeable) from [] (kernel_init+0x8/0x110)
[] (kernel_init) from [] (ret_from_fork+0x14/0x2c)
Exception stack(0xcc099fb0 to 0xcc099ff8)
9fa0:    
9fc0:        
9fe0:     0013 
---[ end trace 4522f69e0760e4d5 ]---



> -Ursprüngliche Nachricht-
> Von: Rob Herring [mailto:robh...@kernel.org]
> Gesendet: Montag, 10. September 2018 15:47
> An: Andre Kalb
> Cc: Frank Rowand; devicet...@vger.kernel.org; linux-kernel@vger.kernel.org
> Betreff: Re: [PATCH v2] of: __of_update_property_sysfs only call
> __of_sysfs_remove_bin_file if of_node_is_attached
>
> On Mon, Sep 10, 2018 at 4:51 AM Andre Kalb  wrote:
> >
> > Hi Frank,
> >
> > > -Ursprüngliche Nachricht-
> > > Von: Frank Rowand [mailto:frowand.l...@gmail.com]
> > > Gesendet: Freitag, 7. September 2018 22:01
> > > An: Andre Kalb; robh...@kernel.org; devicet...@vger.kernel.org;
> > > linux- ker...@vger.kernel.org
> > > Betreff: Re: [PATCH v2] of: __of_update_property_sysfs only call
> > > __of_sysfs_remove_bin_file if of_node_is_attached
> > >
> > > Hi Andred,
> > >
> > > On 09/04/18 08:51, Andre Kalb wrote:
> > > > To prevent warning "kernfs: can not remove '(null)', no directory"
> > > > if an overlay
> > > isn't applied to the active devicetree.
> > > >
> > > > Using of_remove_property and then of_add_property doesn't show the
> > > warning.
>
> [...]
>
> > > What is the calling path that results in the warning?
> > >
> > > -Frank
> >
> > There is the callstack of the warning.
> >
> > [   10.782830] [ cut here ]
> > [   10.830357] WARNING: CPU: 0 PID: 170 at /linux-4.x/fs/kernfs/dir.c:1276
> kernfs_remove_by_name_ns+0x30/0x80()
> > [   10.928997] kernfs: can not remove '(null)', no directory
> > [   10.993107] Modules linked in: module_capemgr(+)
> > [   11.045750] CPU: 0 PID: 170 Comm: systemd-udevd Not tainted 4.4.143-
> 00158-g8e5ca65ec7ee-dirty #114
>
> 158 patches on top of an almost 3 year old kernel...
>
> > [   12.011373] [] (module_capemgr_slot_scan [module_capemgr])
> fro

AW: [PATCH v2] of: __of_update_property_sysfs only call __of_sysfs_remove_bin_file if of_node_is_attached

2018-09-10 Thread Andre Kalb
Hi Frank,

> -Ursprüngliche Nachricht-
> Von: Frank Rowand [mailto:frowand.l...@gmail.com]
> Gesendet: Freitag, 7. September 2018 22:01
> An: Andre Kalb; robh...@kernel.org; devicet...@vger.kernel.org; linux-
> ker...@vger.kernel.org
> Betreff: Re: [PATCH v2] of: __of_update_property_sysfs only call
> __of_sysfs_remove_bin_file if of_node_is_attached
> 
> Hi Andred,
> 
> On 09/04/18 08:51, Andre Kalb wrote:
> > To prevent warning "kernfs: can not remove '(null)', no directory" if an 
> > overlay
> isn't applied to the active devicetree.
> >
> > Using of_remove_property and then of_add_property doesn't show the
> warning.
> >
> > Signed-off-by: Andre Kalb 
> > ---
> > Changes in v2:
> >   - Fix typo
> >
> >  drivers/of/kobj.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c index
> > 7a0a18980b98..962b660e8ad1 100644
> > --- a/drivers/of/kobj.c
> > +++ b/drivers/of/kobj.c
> > @@ -104,7 +104,7 @@ void __of_update_property_sysfs(struct device_node
> *np, struct property *newprop
> > struct property *oldprop)  {
> > /* At early boot, bail out and defer setup to of_init() */
> > -   if (!of_kset)
> > +   if (!of_kset || !of_node_is_attached(np))
> > return;
> >
> > if (oldprop)
> > --
> > 2.17.1
> >
> >
> > ___
> >
> > SMA Solar Technology AG
> > Aufsichtsrat: Dr. Erik Ehrentraut (Vorsitzender)
> > Vorstand: Ulrich Hadding, Dr.-Ing. Juergen Reinert, Pierre-Pascal
> > Urbon
> > Handelsregister: Amtsgericht Kassel HRB 3972 Sitz der Gesellschaft:
> > 34266 Niestetal USt-ID-Nr. DE 113 08 59 54 WEEE-Reg.-Nr. DE 95881150
> > ___
> >
> 
> What is the calling path that results in the warning?
> 
> -Frank

There is the callstack of the warning.

[   10.782830] [ cut here ]
[   10.830357] WARNING: CPU: 0 PID: 170 at /linux-4.x/fs/kernfs/dir.c:1276 
kernfs_remove_by_name_ns+0x30/0x80()
[   10.928997] kernfs: can not remove '(null)', no directory
[   10.993107] Modules linked in: module_capemgr(+)
[   11.045750] CPU: 0 PID: 170 Comm: systemd-udevd Not tainted 
4.4.143-00158-g8e5ca65ec7ee-dirty #114
[   11.159764] Hardware name: Generic AM33XX (Flattened Device Tree)
[   11.260989] Backtrace:
[   11.276618] [] (dump_backtrace) from [] 
(show_stack+0x18/0x1c)
[   11.340099]  r6:c071b211 r5:0009 r4: r3:d0c4896c
[   11.394058] [] (show_stack) from [] 
(dump_stack+0x20/0x28)
[   11.401704] [] (dump_stack) from [] 
(warn_slowpath_common+0x90/0xb8)
[   11.471765] [] (warn_slowpath_common) from [] 
(warn_slowpath_fmt+0x38/0x40)
[   11.509244]  r8:bf000d30 r7:600f0113 r6: r5: r4:
[   11.571483] [] (warn_slowpath_fmt) from [] 
(kernfs_remove_by_name_ns+0x30/0x80)
[   11.586620]  r3: r2:c071b2e7
[   11.603293] [] (kernfs_remove_by_name_ns) from [] 
(sysfs_remove_bin_file+0x1c/0x20)
[   11.665357]  r6:cf6d2664 r5:cf6d2664 r4:cf6d27e4 r3:cf099580
[   11.703347] [] (sysfs_remove_bin_file) from [] 
(__of_sysfs_remove_bin_file+0x1c/0x28)
[   11.750587] [] (__of_sysfs_remove_bin_file) from [] 
(__of_update_property_sysfs+0x34/0x48)
[   11.805954]  r4:cf53b590 r3:cf099580
[   11.825184] [] (__of_update_property_sysfs) from [] 
(of_update_property+0x9c/0xdc)
[   11.891243]  r5:cf53b590 r4:
[   11.904186] [] (of_update_property) from [] 
(module_capemgr_slot_scan+0x590/0x69c [module_capemgr])
[   12.005277]  r7:0001 r6: r5:cf191610 r4:cf53b590
[   12.011373] [] (module_capemgr_slot_scan [module_capemgr]) from 
[] (module_capemgr_probe+0x3c/0x58 [module_capemgr])
[   12.115310]  r10:bf000e4c r9:0004 r8:c0968160 r7: r6:bf000ce4 
r5:bf000780
[   12.128143]  r4:cf191600
[   12.155023] [] (module_capemgr_probe [module_capemgr]) from 
[] (platform_drv_probe+0x58/0xa4)
[   12.184861]  r4:cf191610 r3:fdfb
[   12.204949] [] (platform_drv_probe) from [] 
(driver_probe_device+0x194/0x414)
[   12.254228]  r6:c099538c r5:bf000ce4 r4:cf191610 r3:c03b540c
[   12.260305] [] (driver_probe_device) from [] 
(__driver_attach+0x70/0x94)
[   12.294832]  r9:c090204c r8:c0968088 r7: r6:bf000ce4 r5:cf191644 
r4:cf191610
[   12.309680] [] (__driver_attach) from [] 
(bus_for_each_dev+0x7c/0x90)
[   12.374480]  r6:c03b3ccc r5:bf000ce4 r4: r3:c03b3ccc
[   12.390638] [] (bus_for_each_dev) from [] 
(driver_attach+0x20/0x28)
[   12.424719]  r6:c093c000 r5:cf5aa180 r4:bf000ce4
[   12.444029] [] (driver_attach) from [] 
(bus_add_driver+0x11c/0x248)
[   12.486713] [] (bus_add_driver) from [] 
(driver_r

[PATCH v2] of: __of_update_property_sysfs only call __of_sysfs_remove_bin_file if of_node_is_attached

2018-09-04 Thread Andre Kalb
To prevent warning "kernfs: can not remove '(null)', no directory" if an 
overlay isn't applied to the active devicetree.

Using of_remove_property and then of_add_property doesn't show the warning.

Signed-off-by: Andre Kalb 
---
Changes in v2:
  - Fix typo

 drivers/of/kobj.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c index 
7a0a18980b98..962b660e8ad1 100644
--- a/drivers/of/kobj.c
+++ b/drivers/of/kobj.c
@@ -104,7 +104,7 @@ void __of_update_property_sysfs(struct device_node *np, 
struct property *newprop
struct property *oldprop)
 {
/* At early boot, bail out and defer setup to of_init() */
-   if (!of_kset)
+   if (!of_kset || !of_node_is_attached(np))
return;

if (oldprop)
--
2.17.1


___

SMA Solar Technology AG
Aufsichtsrat: Dr. Erik Ehrentraut (Vorsitzender)
Vorstand: Ulrich Hadding, Dr.-Ing. Juergen Reinert, Pierre-Pascal Urbon
Handelsregister: Amtsgericht Kassel HRB 3972
Sitz der Gesellschaft: 34266 Niestetal
USt-ID-Nr. DE 113 08 59 54
WEEE-Reg.-Nr. DE 95881150
___


[PATCH] of: __of_update_property_sysfs only call __of_sysfs_remove_bin_file if of_node_is_attached.

2018-09-04 Thread Andre Kalb
To prevent warning "kernfs: can not remove '(null)', no directory", if an 
overlay isn't applied to the active devicetree.

Using of_remove_property and than of_add_property don't show the warning.
---
 drivers/of/kobj.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/of/kobj.c b/drivers/of/kobj.c index 
7a0a18980b98..2b71e5979580 100644
--- a/drivers/of/kobj.c
+++ b/drivers/of/kobj.c
@@ -104,7 +104,7 @@ void __of_update_property_sysfs(struct device_node *np, 
struct property *newprop
struct property *oldprop)
 {
/* At early boot, bail out and defer setup to of_init() */
-   if (!of_kset)
+   if (!of_kset || !of_node_is_attached(np)))
return;

if (oldprop)
--
2.17.1


___

SMA Solar Technology AG
Aufsichtsrat: Dr. Erik Ehrentraut (Vorsitzender)
Vorstand: Ulrich Hadding, Dr.-Ing. Juergen Reinert, Pierre-Pascal Urbon
Handelsregister: Amtsgericht Kassel HRB 3972
Sitz der Gesellschaft: 34266 Niestetal
USt-ID-Nr. DE 113 08 59 54
WEEE-Reg.-Nr. DE 95881150
___