[PATCH] ANDROID: binder: rename parameter to resolve name collision.

2018-05-29 Thread kuangrufan
From: Kuang Rufan 

both bind.c & binder_alloc.c define the same kernel parameter 'debug_mask',
rename the one in binder_alloc.c to 'alloc_debug_mask'.

Signed-off-by: Kuang Rufan 
---
 drivers/android/binder_alloc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c
index 5a426c877dfb..3850dab493d4 100644
--- a/drivers/android/binder_alloc.c
+++ b/drivers/android/binder_alloc.c
@@ -42,7 +42,7 @@ enum {
 };
 static uint32_t binder_alloc_debug_mask;
 
-module_param_named(debug_mask, binder_alloc_debug_mask,
+module_param_named(alloc_debug_mask, binder_alloc_debug_mask,
   uint, 0644);
 
 #define binder_alloc_debug(mask, x...) \
-- 
2.15.1 (Apple Git-101)

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH 1/6] staging: mt7621-dts: fix property #interrupt-cells for the gpio node

2018-05-29 Thread Sergio Paracuellos
On Wed, May 30, 2018 at 09:34:39AM +1000, NeilBrown wrote:
> On Tue, May 29 2018, Sergio Paracuellos wrote:
> 
> > Most gpio chips have two cells for interrupts and this should be also.
> > Set this property accordly fixing this up.
> >
> > Signed-off-by: Sergio Paracuellos 
> > ---
> >  drivers/staging/mt7621-dts/mt7621.dtsi | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi 
> > b/drivers/staging/mt7621-dts/mt7621.dtsi
> > index d7e4981..bce6029 100644
> > --- a/drivers/staging/mt7621-dts/mt7621.dtsi
> > +++ b/drivers/staging/mt7621-dts/mt7621.dtsi
> > @@ -70,7 +70,7 @@
> > interrupt-parent = <>;
> > interrupts = ;
> > interrupt-controller;
> > -   #interrupt-cells = <1>;
> > +   #interrupt-cells = <2>;
> 
> Thanks for this ongoing effort.
> 
> I thought I should test this change.  It didn't quite go as I expected.
> My board has one GPIO wired to a push-button so it is normally
> configured with
> 
>   gpio-keys {
>   compatible = "gpio-keys";
> 
>   reset {
>   label = "reset";
>   gpios = < 18 GPIO_ACTIVE_HIGH>;
>   ...
> 
> (though in upstream it still uses the old gpio-keys-polled).
> I removed the gpios line and replaced with
> 
>   interrupt-parent = <>;
>   interrupts = <18 IRQ_TYPE_EDGE_FALLING>;
> 
> which should produce a key-press event whenever the button is pressed.
> It didn't.
> 
> The reason is
> 
>.xlate = irq_domain_xlate_onecell,
> 
> in irq_domain_ops in gpio-mt7621.c.
> "onecell" obviously correlated with #interrupt-cells = <1>.
> I changed it to
>.xlate = irq_domain_xlate_twocell,
> 
> and now it works as expected.  So we need to combine that change with
> the change to #interrupt-cells.  I'm certain that we do really want 2
> cells here, as it is possible to change the trigger type.
> 
> You might have noticed that I added
>   interrupt-parent = <>;
> 
> even though there is no 'gpio:' tag in the devicetree.  I had to add
> one.
> 
> -   gpio@600 {
> +   gpio: gpio@600 {
> 
> so that I could refer to the gpio interrupts.
> This feels a bit untidy.  The gpios are grouped into banks of 32:
>  gpio0 gpio1 grio2
> but the interrupts are just a single bank of 96 interrupts.
> I don't know that this is a problem and I'm not advocating that we "fix"
> it.  But it might be something that will be queried when we
> submit to linux-gpio - I really don't know.
> 
> So if you could redo this patch to added the gpio: label and change
> the xlate function, that would be excellent.
> For all the rest:
>   Reviewed-by: NeilBrown 
> 
> Thanks a lot,
> NeilBrown

Thanks for your review and clear explanation, Neil. That really helps.

I have just send v2 version for this patch with the changes you are
pointing out here.

Hope this helps.

Best regards,
Sergio Paracuellos

> 
> >  
> > gpio0: bank@0 {
> > reg = <0>;
> > -- 
> > 2.7.4


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [greybus-dev] [PATCH 01/13] staging: greybus: camera: no need to check debugfs return values

2018-05-29 Thread Viresh Kumar
On 29-05-18, 16:29, Greg Kroah-Hartman wrote:
> When calling debugfs functions, there is no need to ever check the
> return value.  The function can work or not, but the code logic should
> never do something different based on this.
> 
> Clean up the greybus camera driver by not caring about the value of
> debugfs calls.  This ends up removing a number of lines of code that
> are not needed.
> 
> Cc: Johan Hovold 
> Cc: Alex Elder 
> Cc: Greg Kroah-Hartman 
> Cc: greybus-...@lists.linaro.org
> Signed-off-by: Greg Kroah-Hartman 
> ---
>  drivers/staging/greybus/camera.c | 17 +++--
>  1 file changed, 3 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/staging/greybus/camera.c 
> b/drivers/staging/greybus/camera.c
> index 07ebfb88db9b..341f729a9779 100644
> --- a/drivers/staging/greybus/camera.c
> +++ b/drivers/staging/greybus/camera.c
> @@ -1174,11 +1174,6 @@ static int gb_camera_debugfs_init(struct gb_camera 
> *gcam)
>gcam->bundle->id);
>  
>   gcam->debugfs.root = debugfs_create_dir(dirname, gb_debugfs_get());
> - if (IS_ERR(gcam->debugfs.root)) {
> - gcam_err(gcam, "debugfs root create failed (%ld)\n",
> -  PTR_ERR(gcam->debugfs.root));
> - return PTR_ERR(gcam->debugfs.root);
> - }
>  
>   gcam->debugfs.buffers = vmalloc(sizeof(*gcam->debugfs.buffers) *
>   GB_CAMERA_DEBUGFS_BUFFER_MAX);
> @@ -1188,18 +1183,12 @@ static int gb_camera_debugfs_init(struct gb_camera 
> *gcam)
>   for (i = 0; i < ARRAY_SIZE(gb_camera_debugfs_entries); ++i) {
>   const struct gb_camera_debugfs_entry *entry =
>   _camera_debugfs_entries[i];
> - struct dentry *dentry;
>  
>   gcam->debugfs.buffers[i].length = 0;
>  
> - dentry = debugfs_create_file(entry->name, entry->mask,
> -  gcam->debugfs.root, gcam,
> -  _camera_debugfs_ops);
> - if (IS_ERR(dentry)) {
> - gcam_err(gcam,
> -  "debugfs operation %s create failed (%ld)\n",
> -  entry->name, PTR_ERR(dentry));
> - return PTR_ERR(dentry);
> + debugfs_create_file(entry->name, entry->mask,
> + gcam->debugfs.root, gcam,
> + _camera_debugfs_ops);
>   }
>   }

Reviewed-by: Viresh Kumar 

-- 
viresh
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2] staging: mt7621-gpio: update #interrupt-cells for the gpio node

2018-05-29 Thread Sergio Paracuellos
Most gpio chips have two cells for interrupts and this should be also.
Set this property in the device tree accordly fixing this up. In order
to make this working properly the xlate function for the irq_domain must
be updated to use the  'irq_domain_xlate_twocell' one in the driver.
One more minimal change is needed two refer gpio's interrupt-parent from
other nodes which is to add new 'gpio' label in the device tree.

Signed-off-by: Sergio Paracuellos 
---
Changes in v2:
- commit message has been changed with more proper one
- new label to refer gpio from other nodes added to the DT
- use 'irq_domain_xlate_twocell'

 drivers/staging/mt7621-dts/mt7621.dtsi| 4 ++--
 drivers/staging/mt7621-gpio/gpio-mt7621.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi 
b/drivers/staging/mt7621-dts/mt7621.dtsi
index d7e4981..eb3966b 100644
--- a/drivers/staging/mt7621-dts/mt7621.dtsi
+++ b/drivers/staging/mt7621-dts/mt7621.dtsi
@@ -60,7 +60,7 @@
reg = <0x100 0x100>;
};
 
-   gpio@600 {
+   gpio: gpio@600 {
#address-cells = <1>;
#size-cells = <0>;
 
@@ -70,7 +70,7 @@
interrupt-parent = <>;
interrupts = ;
interrupt-controller;
-   #interrupt-cells = <1>;
+   #interrupt-cells = <2>;
 
gpio0: bank@0 {
reg = <0>;
diff --git a/drivers/staging/mt7621-gpio/gpio-mt7621.c 
b/drivers/staging/mt7621-gpio/gpio-mt7621.c
index c96ae67..79b8c58 100644
--- a/drivers/staging/mt7621-gpio/gpio-mt7621.c
+++ b/drivers/staging/mt7621-gpio/gpio-mt7621.c
@@ -317,7 +317,7 @@ mediatek_gpio_gpio_map(struct irq_domain *d, unsigned int 
irq,
 }
 
 static const struct irq_domain_ops irq_domain_ops = {
-   .xlate = irq_domain_xlate_onecell,
+   .xlate = irq_domain_xlate_twocell,
.map = mediatek_gpio_gpio_map,
 };
 
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v1] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic

2018-05-29 Thread Greg KH
On Wed, May 30, 2018 at 06:42:14AM +0200, Greg KH wrote:
> On Tue, May 29, 2018 at 08:11:40PM +, Sunil Muthuswamy wrote:
> > The V3 patch should address the concerns/comments below. Happy to
> > address any additional comments, if there are any.
> 
> Why not respond to the v3 patch so I don't have to go dig it up?  :)
> 
> And really, it's up to the maintainer of this subsystem to provide the
> final review, and that's not me.  Why did you not cc: them on the patch
> in the beginning?

And as proof of that, I don't even have this patch in my "to-review"
local queue as I assumed the hyperv maintainers would take care of it.

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v1] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic

2018-05-29 Thread Greg KH
On Tue, May 29, 2018 at 08:11:40PM +, Sunil Muthuswamy wrote:
> The V3 patch should address the concerns/comments below. Happy to
> address any additional comments, if there are any.

Why not respond to the v3 patch so I don't have to go dig it up?  :)

And really, it's up to the maintainer of this subsystem to provide the
final review, and that's not me.  Why did you not cc: them on the patch
in the beginning?

thanks,

greg k-h
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next v4 5/8] dsa: port: Ignore bridge VLAN events

2018-05-29 Thread Florian Fainelli



On 05/29/2018 05:59 PM, Petr Machata wrote:
> A follow-up patch enables emitting VLAN notifications for the bridge CPU
> port in addition to the existing slave port notifications. These
> notifications have orig_dev set to the bridge in question.
> 
> Because there's no specific support for these VLANs, just ignore the
> notifications to maintain the current behavior.
> 
> Signed-off-by: Petr Machata 
> Reviewed-by: Vivien Didelot 

Reviewed-by: Florian Fainelli 
-- 
Florian
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: mt7621-eth: Refactor RX ring resource allocation and cleanup

2018-05-29 Thread NeilBrown
On Tue, May 29 2018, Dan Carpenter wrote:

> On Mon, May 21, 2018 at 09:37:31AM +1000, NeilBrown wrote:
>> On Fri, May 18 2018, Kamal Heib wrote:
>> 
>> > Simplify the code of allocate and cleanup RX ring resources by using
>> > helper functions, also make sure to free the allocated resources in
>> > cause of allocation failure.
>> >
>> > Signed-off-by: Kamal Heib 
>> > ---
>> >  drivers/staging/mt7621-eth/mtk_eth_soc.c | 122 
>> > ---
>> >  1 file changed, 81 insertions(+), 41 deletions(-)
>> >
>> 
>> >  static int mtk_dma_rx_alloc(struct mtk_eth *eth, struct mtk_rx_ring *ring)
>> >  {
>> > -  int i, pad = 0;
>> > +  int err;
>> >  
>> >ring->frag_size = mtk_max_frag_size(ETH_DATA_LEN);
>> >ring->rx_buf_size = mtk_max_buf_size(ring->frag_size);
>> > @@ -317,38 +366,23 @@ static int mtk_dma_rx_alloc(struct mtk_eth *eth, 
>> > struct mtk_rx_ring *ring)
>> >ring->rx_data = kcalloc(ring->rx_ring_size, sizeof(*ring->rx_data),
>> >GFP_KERNEL);
>> >if (!ring->rx_data)
>> > -  goto no_rx_mem;
>> > +  return -ENOMEM;
>> 
>> Hi
>>  I haven't tested this patch yet (will try to in the next day or so) but
>>  it mostly looks good to me.
>>  I would rather see the above "return -ENOMEM" as a "goto free_rx_data".
>>  Having a single error-exit is generally more maintainable than having
>>  lots of separate 'return's, and kfree() is quite happy to be asked to
>>  kfree(NULL).
>>  In fact, all of the free function (even dma_free_coherent) cope
>>  ok will not having anything to free.  As devm_kzallo() and kcalloc()
>>  are used, all the pointers default to NULL which is safe. I would would
>>  prefer a single 'nomem' label which did:
>> 
>> nomem:
>>   dma_free_coherent(eth->dev, ring->rx_ring_size * sizeof(*ring->rx_dma),
>>ring->rx_dma, ring->rx_phys);
>>   mtk_rx_free_frags(ring);
>>   kfree(ring->rx_data);
>>   return -ENOMEM;
>> 
>> 
>> But that is just my personal preference.
>
> You're sort of advocating two closely related styles of error handling.
> The first is a do-nothing error handling instead of direct returns.  The
> other style is a do-everything style error handling.

Yes, exactly.  And when there is nothing that needs doing, "everything"
and "nothing" are the same thing.

>
> Direct returns are preferable to do-nothing gotos because they are more
> readable.  "return -ENOMEM;" is more clear than "ret = -ENOMEM;
> goto free_rx_data;".  The second one seems clear but it doesn't free
> anything so the label name is actively misleading and confusing.  Do
> nothing gotos introduce "forgot to set the error code" bugs.

I don't like direct returns because they do not make modification easy.
If I find a need to allocate something else earlier, I need to go
and find all the direct returns and turn them into gotos.  I prefer to
make them gotos from the start.

And your examples are not good.  My preferred pattern is:

ret = -ENOMEM;
foo = alloc_foo();
if (!foo)
goto abort;

You may only need to set ret once or twice.
I see nothing misleading or confusing there.

>
> The do-everything style error handling is the most bug prone style in
> the kernel.  So far this week I have seen 4 buggy one label patches vs
> 1 buggy multi label patch.

I cannot challenge your statistics, but I wonder if you might be
throwing the baby out with the bath water here.  Undoubtedly it is
possible to write do-everything error handling badly.  It is also
possible to write it well.  I'm not convinced it is fair blame the bad
code on the broad description "do everything error handling".

>
> I feel slightly bad picking on you but with your sample code which uses
> the nomem: label, you can't free dma resources which haven't been
> allocated.  I know you would have spotted it if you were writing a real
> patch instead of just throwing together sample code in your email
> client.  But the second issue is that you can't call
> mtk_rx_free_frags(ring); when "ring->rx_data" is NULL or it will Oops.
> That's subtle and so far as I know, static analysis would not warn about
> it.

"obviously" we would first fix mtk_rx_free_frags() to do the right thing
if ring->rx_data were NULL.  This is a crucial part of robust error
handling.
The very best error handling style is devm_*.  When that is not
practical, kfree() style, which quietly accepts NULL, is a good second
best.
Could it be that the various bugs you have seen could be blamed on
resource-release function which do not handle NULL well?  When these
bugs were fixed, were they fixed by fixing the resource-release
function (which would benefit many) or were they fixed by making the
code more robust against a poor interface by adding more checking?

>
> Multi label error handling is self documenting so you don't need to jump
> to the bottom of the function.  You only need to track the most recently
> allocated resource.
>
>   foo = 

[PATCH net-next v4 8/8] mlxsw: spectrum_switchdev: Schedule respin during trans prepare

2018-05-29 Thread Petr Machata
Since there's no special support for the bridge events, the driver
returns -EOPNOTSUPP, and thus the commit never happens. Therefore
schedule respin during the prepare stage: there's no real difference one
way or another.

This fixes the problem that mirror-to-gretap offload wouldn't adapt to
changes in bridge vlan configuration right away and another notification
would have to arrive for mlxsw to catch up.

Signed-off-by: Petr Machata 
Reviewed-by: Ido Schimmel 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index cbc8fab..8a15ac4 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -1697,7 +1697,7 @@ static int mlxsw_sp_port_obj_add(struct net_device *dev,
vlan = SWITCHDEV_OBJ_PORT_VLAN(obj);
err = mlxsw_sp_port_vlans_add(mlxsw_sp_port, vlan, trans);
 
-   if (switchdev_trans_ph_commit(trans)) {
+   if (switchdev_trans_ph_prepare(trans)) {
/* The event is emitted before the changes are actually
 * applied to the bridge. Therefore schedule the respin
 * call for later, so that the respin logic sees the
-- 
2.4.11

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v4 7/8] net: bridge: Notify about bridge VLANs

2018-05-29 Thread Petr Machata
A driver might need to react to changes in settings of brentry VLANs.
Therefore send switchdev port notifications for these as well. Reuse
SWITCHDEV_OBJ_ID_PORT_VLAN for this purpose. Listeners should use
netif_is_bridge_master() on orig_dev to determine whether the
notification is about a bridge port or a bridge.

Signed-off-by: Petr Machata 
---
 net/bridge/br_vlan.c | 28 +---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index 602c869..7df2690 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -246,6 +246,10 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags)
goto out_filt;
v->brvlan = masterv;
v->stats = masterv->stats;
+   } else {
+   err = br_switchdev_port_vlan_add(dev, v->vid, flags);
+   if (err && err != -EOPNOTSUPP)
+   goto out;
}
 
/* Add the dev mac and count the vlan only if it's usable */
@@ -281,6 +285,8 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags)
br_vlan_put_master(masterv);
v->brvlan = NULL;
}
+   } else {
+   br_switchdev_port_vlan_del(dev, v->vid);
}
 
goto out;
@@ -306,6 +312,11 @@ static int __vlan_del(struct net_bridge_vlan *v)
err = __vlan_vid_del(p->dev, p->br, v->vid);
if (err)
goto out;
+   } else {
+   err = br_switchdev_port_vlan_del(v->br->dev, v->vid);
+   if (err && err != -EOPNOTSUPP)
+   goto out;
+   err = 0;
}
 
if (br_vlan_should_use(v)) {
@@ -558,16 +569,22 @@ static int br_vlan_add_existing(struct net_bridge *br,
 {
int err;
 
+   err = br_switchdev_port_vlan_add(br->dev, vlan->vid, flags);
+   if (err && err != -EOPNOTSUPP)
+   return err;
+
if (!br_vlan_is_brentry(vlan)) {
/* Trying to change flags of non-existent bridge vlan */
-   if (!(flags & BRIDGE_VLAN_INFO_BRENTRY))
-   return -EINVAL;
+   if (!(flags & BRIDGE_VLAN_INFO_BRENTRY)) {
+   err = -EINVAL;
+   goto err_flags;
+   }
/* It was only kept for port vlans, now make it real */
err = br_fdb_insert(br, NULL, br->dev->dev_addr,
vlan->vid);
if (err) {
br_err(br, "failed to insert local address into bridge 
forwarding table\n");
-   return err;
+   goto err_fdb_insert;
}
 
refcount_inc(>refcnt);
@@ -580,6 +597,11 @@ static int br_vlan_add_existing(struct net_bridge *br,
*changed = true;
 
return 0;
+
+err_fdb_insert:
+err_flags:
+   br_switchdev_port_vlan_del(br->dev, vlan->vid);
+   return err;
 }
 
 /* Must be protected by RTNL.
-- 
2.4.11

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v4 6/8] staging: fsl-dpaa2: ethsw: Ignore bridge VLAN events

2018-05-29 Thread Petr Machata
A follow-up patch enables emitting VLAN notifications for the bridge CPU
port in addition to the existing slave port notifications. These
notifications have orig_dev set to the bridge in question.

Because there's no specific support for these VLANs, just ignore the
notifications to maintain the current behavior.

Signed-off-by: Petr Machata 
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index c723a04..a17dd29 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -719,6 +719,9 @@ static int port_vlans_add(struct net_device *netdev,
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
int vid, err;
 
+   if (netif_is_bridge_master(vlan->obj.orig_dev))
+   return -EOPNOTSUPP;
+
if (switchdev_trans_ph_prepare(trans))
return 0;
 
@@ -873,6 +876,9 @@ static int port_vlans_del(struct net_device *netdev,
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
int vid, err;
 
+   if (netif_is_bridge_master(vlan->obj.orig_dev))
+   return -EOPNOTSUPP;
+
for (vid = vlan->vid_begin; vid <= vlan->vid_end; vid++) {
err = ethsw_port_del_vlan(port_priv, vid);
if (err)
-- 
2.4.11

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v4 5/8] dsa: port: Ignore bridge VLAN events

2018-05-29 Thread Petr Machata
A follow-up patch enables emitting VLAN notifications for the bridge CPU
port in addition to the existing slave port notifications. These
notifications have orig_dev set to the bridge in question.

Because there's no specific support for these VLANs, just ignore the
notifications to maintain the current behavior.

Signed-off-by: Petr Machata 
Reviewed-by: Vivien Didelot 
---
 net/dsa/port.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/net/dsa/port.c b/net/dsa/port.c
index 2413beb..ed05954 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -252,6 +252,9 @@ int dsa_port_vlan_add(struct dsa_port *dp,
.vlan = vlan,
};
 
+   if (netif_is_bridge_master(vlan->obj.orig_dev))
+   return -EOPNOTSUPP;
+
if (br_vlan_enabled(dp->bridge_dev))
return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_ADD, );
 
@@ -267,6 +270,9 @@ int dsa_port_vlan_del(struct dsa_port *dp,
.vlan = vlan,
};
 
+   if (netif_is_bridge_master(vlan->obj.orig_dev))
+   return -EOPNOTSUPP;
+
if (br_vlan_enabled(dp->bridge_dev))
return dsa_port_notify(dp, DSA_NOTIFIER_VLAN_DEL, );
 
-- 
2.4.11

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v4 4/8] rocker: rocker_main: Ignore bridge VLAN events

2018-05-29 Thread Petr Machata
A follow-up patch enables emitting VLAN notifications for the bridge CPU
port in addition to the existing slave port notifications. These
notifications have orig_dev set to the bridge in question.

Because there's no specific support for these VLANs, just ignore the
notifications to maintain the current behavior.

Signed-off-by: Petr Machata 
---
 drivers/net/ethernet/rocker/rocker_main.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index e73e4fe..aeafdb9 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -1632,6 +1632,9 @@ rocker_world_port_obj_vlan_add(struct rocker_port 
*rocker_port,
 {
struct rocker_world_ops *wops = rocker_port->rocker->wops;
 
+   if (netif_is_bridge_master(vlan->obj.orig_dev))
+   return -EOPNOTSUPP;
+
if (!wops->port_obj_vlan_add)
return -EOPNOTSUPP;
 
@@ -1647,6 +1650,9 @@ rocker_world_port_obj_vlan_del(struct rocker_port 
*rocker_port,
 {
struct rocker_world_ops *wops = rocker_port->rocker->wops;
 
+   if (netif_is_bridge_master(vlan->obj.orig_dev))
+   return -EOPNOTSUPP;
+
if (!wops->port_obj_vlan_del)
return -EOPNOTSUPP;
return wops->port_obj_vlan_del(rocker_port, vlan);
-- 
2.4.11

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v4 3/8] mlxsw: spectrum_switchdev: Ignore bridge VLAN events

2018-05-29 Thread Petr Machata
A follow-up patch enables emitting VLAN notifications for the bridge CPU
port in addition to the existing slave port notifications. These
notifications have orig_dev set to the bridge in question.

Because there's no specific support for these VLANs, just ignore the
notifications to maintain the current behavior.

Signed-off-by: Petr Machata 
Reviewed-by: Ido Schimmel 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 8c9cf8e..cbc8fab 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -1144,6 +1144,9 @@ static int mlxsw_sp_port_vlans_add(struct mlxsw_sp_port 
*mlxsw_sp_port,
struct mlxsw_sp_bridge_port *bridge_port;
u16 vid;
 
+   if (netif_is_bridge_master(orig_dev))
+   return -EOPNOTSUPP;
+
if (switchdev_trans_ph_prepare(trans))
return 0;
 
@@ -1741,6 +1744,9 @@ static int mlxsw_sp_port_vlans_del(struct mlxsw_sp_port 
*mlxsw_sp_port,
struct mlxsw_sp_bridge_port *bridge_port;
u16 vid;
 
+   if (netif_is_bridge_master(orig_dev))
+   return -EOPNOTSUPP;
+
bridge_port = mlxsw_sp_bridge_port_find(mlxsw_sp->bridge, orig_dev);
if (WARN_ON(!bridge_port))
return -EINVAL;
-- 
2.4.11

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v4 2/8] net: bridge: Extract br_vlan_add_existing()

2018-05-29 Thread Petr Machata
Extract the code that deals with adding a preexisting VLAN to bridge CPU
port to a separate function. A follow-up patch introduces a need to roll
back operations in this block due to an error, and this split will make
the error-handling code clearer.

Signed-off-by: Petr Machata 
---
 net/bridge/br_vlan.c | 55 +++-
 1 file changed, 33 insertions(+), 22 deletions(-)

diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index e3b14c0..602c869 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -551,6 +551,37 @@ bool br_should_learn(struct net_bridge_port *p, struct 
sk_buff *skb, u16 *vid)
return false;
 }
 
+static int br_vlan_add_existing(struct net_bridge *br,
+   struct net_bridge_vlan_group *vg,
+   struct net_bridge_vlan *vlan,
+   u16 flags, bool *changed)
+{
+   int err;
+
+   if (!br_vlan_is_brentry(vlan)) {
+   /* Trying to change flags of non-existent bridge vlan */
+   if (!(flags & BRIDGE_VLAN_INFO_BRENTRY))
+   return -EINVAL;
+   /* It was only kept for port vlans, now make it real */
+   err = br_fdb_insert(br, NULL, br->dev->dev_addr,
+   vlan->vid);
+   if (err) {
+   br_err(br, "failed to insert local address into bridge 
forwarding table\n");
+   return err;
+   }
+
+   refcount_inc(>refcnt);
+   vlan->flags |= BRIDGE_VLAN_INFO_BRENTRY;
+   vg->num_vlans++;
+   *changed = true;
+   }
+
+   if (__vlan_add_flags(vlan, flags))
+   *changed = true;
+
+   return 0;
+}
+
 /* Must be protected by RTNL.
  * Must be called with vid in range from 1 to 4094 inclusive.
  * changed must be true only if the vlan was created or updated
@@ -566,28 +597,8 @@ int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags, 
bool *changed)
*changed = false;
vg = br_vlan_group(br);
vlan = br_vlan_find(vg, vid);
-   if (vlan) {
-   if (!br_vlan_is_brentry(vlan)) {
-   /* Trying to change flags of non-existent bridge vlan */
-   if (!(flags & BRIDGE_VLAN_INFO_BRENTRY))
-   return -EINVAL;
-   /* It was only kept for port vlans, now make it real */
-   ret = br_fdb_insert(br, NULL, br->dev->dev_addr,
-   vlan->vid);
-   if (ret) {
-   br_err(br, "failed insert local address into 
bridge forwarding table\n");
-   return ret;
-   }
-   refcount_inc(>refcnt);
-   vlan->flags |= BRIDGE_VLAN_INFO_BRENTRY;
-   vg->num_vlans++;
-   *changed = true;
-   }
-   if (__vlan_add_flags(vlan, flags))
-   *changed = true;
-
-   return 0;
-   }
+   if (vlan)
+   return br_vlan_add_existing(br, vg, vlan, flags, changed);
 
vlan = kzalloc(sizeof(*vlan), GFP_KERNEL);
if (!vlan)
-- 
2.4.11

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH net-next v4 1/8] net: bridge: Extract boilerplate around switchdev_port_obj_*()

2018-05-29 Thread Petr Machata
A call to switchdev_port_obj_add() or switchdev_port_obj_del() involves
initializing a struct switchdev_obj_port_vlan, a piece of code that
repeats on each call site almost verbatim. While in the current codebase
there is just one duplicated add call, the follow-up patches add more of
both add and del calls.

Thus to remove the duplication, extract the repetition into named
functions and reuse.

Signed-off-by: Petr Machata 
Reviewed-by: Vivien Didelot 
---
 net/bridge/br_private.h   | 13 +
 net/bridge/br_switchdev.c | 25 +
 net/bridge/br_vlan.c  | 26 +++---
 3 files changed, 41 insertions(+), 23 deletions(-)

diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 11520ed..5216a52 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -1139,6 +1139,8 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,
   unsigned long mask);
 void br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb,
 int type);
+int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags);
+int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid);
 
 static inline void br_switchdev_frame_unmark(struct sk_buff *skb)
 {
@@ -1168,6 +1170,17 @@ static inline int br_switchdev_set_port_flag(struct 
net_bridge_port *p,
return 0;
 }
 
+static inline int br_switchdev_port_vlan_add(struct net_device *dev,
+u16 vid, u16 flags)
+{
+   return -EOPNOTSUPP;
+}
+
+static inline int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid)
+{
+   return -EOPNOTSUPP;
+}
+
 static inline void
 br_switchdev_fdb_notify(const struct net_bridge_fdb_entry *fdb, int type)
 {
diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index 35474d4..d77f807 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -136,3 +136,28 @@ br_switchdev_fdb_notify(const struct net_bridge_fdb_entry 
*fdb, int type)
break;
}
 }
+
+int br_switchdev_port_vlan_add(struct net_device *dev, u16 vid, u16 flags)
+{
+   struct switchdev_obj_port_vlan v = {
+   .obj.orig_dev = dev,
+   .obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
+   .flags = flags,
+   .vid_begin = vid,
+   .vid_end = vid,
+   };
+
+   return switchdev_port_obj_add(dev, );
+}
+
+int br_switchdev_port_vlan_del(struct net_device *dev, u16 vid)
+{
+   struct switchdev_obj_port_vlan v = {
+   .obj.orig_dev = dev,
+   .obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
+   .vid_begin = vid,
+   .vid_end = vid,
+   };
+
+   return switchdev_port_obj_del(dev, );
+}
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index dc832c09..e3b14c0 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -82,19 +82,12 @@ static bool __vlan_add_flags(struct net_bridge_vlan *v, u16 
flags)
 static int __vlan_vid_add(struct net_device *dev, struct net_bridge *br,
  u16 vid, u16 flags)
 {
-   struct switchdev_obj_port_vlan v = {
-   .obj.orig_dev = dev,
-   .obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
-   .flags = flags,
-   .vid_begin = vid,
-   .vid_end = vid,
-   };
int err;
 
/* Try switchdev op first. In case it is not supported, fallback to
 * 8021q add.
 */
-   err = switchdev_port_obj_add(dev, );
+   err = br_switchdev_port_vlan_add(dev, vid, flags);
if (err == -EOPNOTSUPP)
return vlan_vid_add(dev, br->vlan_proto, vid);
return err;
@@ -130,18 +123,12 @@ static void __vlan_del_list(struct net_bridge_vlan *v)
 static int __vlan_vid_del(struct net_device *dev, struct net_bridge *br,
  u16 vid)
 {
-   struct switchdev_obj_port_vlan v = {
-   .obj.orig_dev = dev,
-   .obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
-   .vid_begin = vid,
-   .vid_end = vid,
-   };
int err;
 
/* Try switchdev op first. In case it is not supported, fallback to
 * 8021q del.
 */
-   err = switchdev_port_obj_del(dev, );
+   err = br_switchdev_port_vlan_del(dev, vid);
if (err == -EOPNOTSUPP) {
vlan_vid_del(dev, br->vlan_proto, vid);
return 0;
@@ -1053,13 +1040,6 @@ int nbp_vlan_init(struct net_bridge_port *p)
 int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,
 bool *changed)
 {
-   struct switchdev_obj_port_vlan v = {
-   .obj.orig_dev = port->dev,
-   .obj.id = SWITCHDEV_OBJ_ID_PORT_VLAN,
-   .flags = flags,
-   .vid_begin = vid,
-   .vid_end = vid,
-   };
struct net_bridge_vlan *vlan;
int ret;
 
@@ -1069,7 +1049,7 @@ int 

[PATCH net-next v4 0/8] net: bridge: Notify about bridge VLANs

2018-05-29 Thread Petr Machata
In commit 946a11e7408e ("mlxsw: spectrum_span: Allow bridge for gretap
mirror"), mlxsw got support for offloading mirror-to-gretap such that
the underlay packet path involves a bridge. In that case, the offload is
also influenced by PVID setting of said bridge. However, changes to VLAN
configuration of the bridge itself do not generate switchdev
notifications, so there's no mechanism to prod mlxsw to update the
offload when these settings change.

In this patchset, the problem is resolved by distributing the switchdev
notification SWITCHDEV_OBJ_ID_PORT_VLAN also for configuration changes
on bridge VLANs. Since stacked devices distribute the notification to
lower devices, such event eventually reaches the driver, which can
determine whether it's a bridge or port VLAN by inspecting orig_dev.

To keep things consistent, the newly-distributed notifications observe
the same protocol as the existing ones: dual prepare/commit, with
-EOPNOTSUPP indicating lack of support, even though there's currently
nothing to prepare for and nothing to support. Correspondingly, all
switchdev drivers have been updated to return -EOPNOTSUPP for bridge
VLAN notifications.

In patches #1 and #2, the code base is changed to support the following
additions: functions br_switchdev_port_vlan_add() and
br_switchdev_port_vlan_del() are introduced to simplify sending
notifications; and br_vlan_add_existing() is introduced to later make it
simpler to add error-handling code for the case of configuring a
preexisting VLAN on bridge CPU port.

In patches #3-#6, respectively for mlxsw, rocker, DSA and DPAA2 ethsw,
the new notifications (which are not enabled yet) are ignored to
maintain the current behavior.

In patch #7, the notification is actually enabled.

In patch #8, mlxsw is changed to update offloads of mirror-to-gre also
for bridge-related notifications.

Changes from v3 to v4:

- In patch #1, separate variable declarations from program logic.
- Add patch #2.
- In patch #7, add error handling around a newly-introduced call to
  br_switchdev_port_vlan_add().
- Rephrase commit messages of patches #3-#6 to explain motivation for
  the change.

Changes from v2 to v3:

- Add a fallback definition for br_switchdev_port_obj_add() and
  br_switchdev_port_obj_del() when !CONFIG_NET_SWITCHDEV.

Changes from v1 to v2:

- Rename br_switchdev_port_obj_add() and br_switchdev_port_obj_del() to
  br_switchdev_port_vlan_add() and br_switchdev_port_vlan_del(), and
  move from br_vlan.c to br_switchdev.c.

Petr Machata (8):
  net: bridge: Extract boilerplate around switchdev_port_obj_*()
  net: bridge: Extract br_vlan_add_existing()
  mlxsw: spectrum_switchdev: Ignore bridge VLAN events
  rocker: rocker_main: Ignore bridge VLAN events
  dsa: port: Ignore bridge VLAN events
  staging: fsl-dpaa2: ethsw: Ignore bridge VLAN events
  net: bridge: Notify about bridge VLANs
  mlxsw: spectrum_switchdev: Schedule respin during trans prepare

 .../ethernet/mellanox/mlxsw/spectrum_switchdev.c   |   8 +-
 drivers/net/ethernet/rocker/rocker_main.c  |   6 ++
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c|   6 ++
 net/bridge/br_private.h|  13 +++
 net/bridge/br_switchdev.c  |  25 +
 net/bridge/br_vlan.c   | 103 -
 net/dsa/port.c |   6 ++
 7 files changed, 121 insertions(+), 46 deletions(-)

-- 
2.4.11

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2 01/25] staging: lustre: libcfs: restore UMP handling

2018-05-29 Thread NeilBrown
On Tue, May 29 2018, James Simmons wrote:

> With the cleanup of the libcfs SMP handling all UMP handling
> was removed. In the process now various NULL pointers and
> empty fields are return in the UMP case which causes lustre
> to crash hard. Restore the proper UMP handling so Lustre can
> properly function.

Can't we just get lustre to handle the NULL pointer?
Is most cases, the pointer is accessed through an accessor function, and
on !CONFIG_SMP, that can be a static inline that doesn't even look at
the pointer.

I really think this is a step backwards.  If you can identify specific
problems caused by the current code, I'm sure we can fix them.

>
> Signed-off-by: James Simmons 
> Signed-off-by: Amir Shehata 
> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734

This bug doesn't seem to mention this patch at all

> Reviewed-on: http://review.whamcloud.com/18916

Nor does this review.

Thanks,
NeilBrown


> Reviewed-by: Olaf Weber 
> Reviewed-by: Doug Oucharek 
> Signed-off-by: James Simmons 
> ---
> Changelog:
>
> v1) New patch to handle the disappearence of UMP support
>
>  .../lustre/include/linux/libcfs/libcfs_cpu.h   | 87 
> --
>  drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c|  4 -
>  drivers/staging/lustre/lnet/libcfs/module.c|  4 +
>  3 files changed, 69 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h 
> b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
> index 61641c4..2ad12a6 100644
> --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
> +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
> @@ -74,6 +74,7 @@
>  
>  #include 
>  #include 
> +#include 
>  #include 
>  
>  /* any CPU partition */
> @@ -89,10 +90,11 @@ struct cfs_cpu_partition {
>   /* spread rotor for NUMA allocator */
>   unsigned intcpt_spread_rotor;
>  };
> -
> +#endif /* CONFIG_SMP */
>  
>  /** descriptor for CPU partitions */
>  struct cfs_cpt_table {
> +#ifdef CONFIG_SMP
>   /* version, reserved for hotplug */
>   unsigned intctb_version;
>   /* spread rotor for NUMA allocator */
> @@ -103,14 +105,26 @@ struct cfs_cpt_table {
>   struct cfs_cpu_partition*ctb_parts;
>   /* shadow HW CPU to CPU partition ID */
>   int *ctb_cpu2cpt;
> - /* all cpus in this partition table */
> - cpumask_var_t   ctb_cpumask;
>   /* all nodes in this partition table */
>   nodemask_t  *ctb_nodemask;
> +#else
> + nodemask_t  ctb_nodemask;
> +#endif /* CONFIG_SMP */
> + /* all cpus in this partition table */
> + cpumask_var_t   ctb_cpumask;
>  };
>  
>  extern struct cfs_cpt_table  *cfs_cpt_tab;
>  
> +#ifdef CONFIG_SMP
> +/**
> + * destroy a CPU partition table
> + */
> +void cfs_cpt_table_free(struct cfs_cpt_table *cptab);
> +/**
> + * create a cfs_cpt_table with \a ncpt number of partitions
> + */
> +struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt);
>  /**
>   * return cpumask of CPU partition \a cpt
>   */
> @@ -208,20 +222,52 @@ void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab,
>  void cfs_cpu_fini(void);
>  
>  #else /* !CONFIG_SMP */
> -struct cfs_cpt_table;
> -#define cfs_cpt_tab ((struct cfs_cpt_table *)NULL)
>  
> -static inline cpumask_var_t *
> -cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
> +static inline void cfs_cpt_table_free(struct cfs_cpt_table *cptab)
>  {
> - return NULL;
> + kfree(cptab);
>  }
>  
> -static inline int
> -cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
> +static inline struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt)
>  {
> - return 0;
> + struct cfs_cpt_table *cptab;
> +
> + if (ncpt != 1)
> + return NULL;
> +
> + cptab = kzalloc(sizeof(*cptab), GFP_NOFS);
> + if (!cptab)
> + return NULL;
> +
> + if (!zalloc_cpumask_var(>ctb_cpumask, GFP_NOFS)) {
> + kfree(cptab);
> + return NULL;
> + }
> + cpumask_set_cpu(0, cptab->ctb_cpumask);
> + node_set(0, cptab->ctb_nodemask);
> +
> + return cptab;
> +}
> +
> +static inline int cfs_cpt_table_print(struct cfs_cpt_table *cptab,
> +   char *buf, int len)
> +{
> + int rc;
> +
> + rc = snprintf(buf, len, "0\t: 0\n");
> + len -= rc;
> + if (len <= 0)
> + return -EFBIG;
> +
> + return rc;
>  }
> +
> +static inline cpumask_var_t *
> +cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
> +{
> + return >ctb_cpumask;
> +}
> +
>  static inline int
>  cfs_cpt_number(struct cfs_cpt_table *cptab)
>  {
> @@ -243,7 +289,7 @@ void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab,
>  static inline nodemask_t *
>  cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt)
>  {
> - return NULL;
> + return >ctb_nodemask;
>  }
>  
>  

Re: [PATCH 1/6] staging: mt7621-dts: fix property #interrupt-cells for the gpio node

2018-05-29 Thread NeilBrown
On Tue, May 29 2018, Sergio Paracuellos wrote:

> Most gpio chips have two cells for interrupts and this should be also.
> Set this property accordly fixing this up.
>
> Signed-off-by: Sergio Paracuellos 
> ---
>  drivers/staging/mt7621-dts/mt7621.dtsi | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/mt7621-dts/mt7621.dtsi 
> b/drivers/staging/mt7621-dts/mt7621.dtsi
> index d7e4981..bce6029 100644
> --- a/drivers/staging/mt7621-dts/mt7621.dtsi
> +++ b/drivers/staging/mt7621-dts/mt7621.dtsi
> @@ -70,7 +70,7 @@
>   interrupt-parent = <>;
>   interrupts = ;
>   interrupt-controller;
> - #interrupt-cells = <1>;
> + #interrupt-cells = <2>;

Thanks for this ongoing effort.

I thought I should test this change.  It didn't quite go as I expected.
My board has one GPIO wired to a push-button so it is normally
configured with

gpio-keys {
compatible = "gpio-keys";

reset {
label = "reset";
gpios = < 18 GPIO_ACTIVE_HIGH>;
  ...

(though in upstream it still uses the old gpio-keys-polled).
I removed the gpios line and replaced with

interrupt-parent = <>;
interrupts = <18 IRQ_TYPE_EDGE_FALLING>;

which should produce a key-press event whenever the button is pressed.
It didn't.

The reason is

   .xlate = irq_domain_xlate_onecell,

in irq_domain_ops in gpio-mt7621.c.
"onecell" obviously correlated with #interrupt-cells = <1>.
I changed it to
   .xlate = irq_domain_xlate_twocell,

and now it works as expected.  So we need to combine that change with
the change to #interrupt-cells.  I'm certain that we do really want 2
cells here, as it is possible to change the trigger type.

You might have noticed that I added
interrupt-parent = <>;

even though there is no 'gpio:' tag in the devicetree.  I had to add
one.

-   gpio@600 {
+   gpio: gpio@600 {

so that I could refer to the gpio interrupts.
This feels a bit untidy.  The gpios are grouped into banks of 32:
 gpio0 gpio1 grio2
but the interrupts are just a single bank of 96 interrupts.
I don't know that this is a problem and I'm not advocating that we "fix"
it.  But it might be something that will be queried when we
submit to linux-gpio - I really don't know.

So if you could redo this patch to added the gpio: label and change
the xlate function, that would be excellent.
For all the rest:
  Reviewed-by: NeilBrown 

Thanks a lot,
NeilBrown

>  
>   gpio0: bank@0 {
>   reg = <0>;
> -- 
> 2.7.4


signature.asc
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v1] media: staging: tegra-vde: Reset VDE regardless of memory client resetting failure

2018-05-29 Thread Dmitry Osipenko
A failed memory client reset doesn't prevent VDE from resetting, hence
reset VDE regardless of preceding memory client resetting failure.

Signed-off-by: Dmitry Osipenko 
---
 drivers/staging/media/tegra-vde/tegra-vde.c | 13 +
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/tegra-vde/tegra-vde.c 
b/drivers/staging/media/tegra-vde/tegra-vde.c
index 6dd3bf4481be..6f06061a40d9 100644
--- a/drivers/staging/media/tegra-vde/tegra-vde.c
+++ b/drivers/staging/media/tegra-vde/tegra-vde.c
@@ -901,15 +901,12 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde 
*vde,
 * the whole system.
 */
err = reset_control_assert(vde->rst_mc);
-   if (!err) {
-   err = reset_control_assert(vde->rst);
-   if (err)
-   dev_err(dev,
-   "DEC end: Failed to assert HW reset: %d\n",
-   err);
-   } else {
+   if (err)
dev_err(dev, "DEC end: Failed to assert MC reset: %d\n", err);
-   }
+
+   err = reset_control_assert(vde->rst);
+   if (err)
+   dev_err(dev, "DEC end: Failed to assert HW reset: %d\n", err);
 
 put_runtime_pm:
pm_runtime_mark_last_busy(dev);
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: mt7621-mmc: Fix line size exceeding 80 columns.

2018-05-29 Thread NeilBrown
On Tue, May 29 2018, Sankalp Negi wrote:

> This patch fixes the checkpatch.pl warning:
>
> WARNING: line over 80 characters
>
> Signed-off-by: Sankalp Negi 
> ---
>  drivers/staging/mt7621-mmc/dbg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/mt7621-mmc/dbg.c 
> b/drivers/staging/mt7621-mmc/dbg.c
> index d897b1216348..0b007e060ddc 100644
> --- a/drivers/staging/mt7621-mmc/dbg.c
> +++ b/drivers/staging/mt7621-mmc/dbg.c
> @@ -229,7 +229,7 @@ static int msdc_debug_proc_read(struct seq_file *s, void 
> *p)
>  }
>  
>  static ssize_t msdc_debug_proc_write(struct file *file,
> - const char __user *buf, size_t count, loff_t 
> *data)
> + const char __user *buf, size_t count, loff_t *data)

Thanks, but  not like this please.
The code inside () should never be indented before the '(' unless the
'(' is at the end of a line.
So you could make it

static ssize_t msdc_debug_proc_write(struct file *file, const char __user *buf,
 size_t count, loff_t *data)

or

static ssize_t
msdc_debug_proc_write(struct file *file, const char __user *buf, size_t count,
  loff_t *data)

or even

static ssize_t msdc_debug_proc_write(
struct file *file, const char __user *buf, size_t count, loff_t *data)

(though I don't think checkpatch will like that).
But neither the original or your new version are indented properly.
Try to do more than just remove the warnings - try to make the code
beautiful!

Thanks,
NeilBrown

>  {
>   int ret;
>  
> -- 
> 2.11.0


signature.asc
Description: PGP signature
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


RE: [PATCH] PCI: hv: Do not wait forever on a device that has disappeared

2018-05-29 Thread Dexuan Cui
> From: Andy Shevchenko 
> Sent: Tuesday, May 29, 2018 14:21
> On Thu, May 24, 2018 at 12:12 AM, Dexuan Cui 
> wrote:
> >
> > Before the guest finishes the device initialization, the device can be
> > removed anytime by the host, and after that the host won't respond to
> > the guest's request, so the guest should be prepared to handle this
> > case.
> 
> > +   while (true) {
> > +   if (hdev->channel->rescind) {
> > +   dev_warn_once(>device, "The device is
> gone.\n");
> > +   return -ENODEV;
> > +   }
> > +
> > +   if (wait_for_completion_timeout(comp, HZ / 10))
> > +   break;
> > +   }
> 
> Infinite loops are usually a red flags.
> 
> What's wrong with simple:
> 
> do {
>   ...
> } while (wait_...(...) == 0);
> 
> ?
Thanks for the suggestion, Andy!
The coding style you suggested looks better to me. :-)

> > +   if (!ret)
> > +   ret = wait_for_response(hdev, );
> 
> Better to use well established patterns, i.e.
> 
> if (ret)
>  return ret;
Agreed.

> 
> > +   if (!ret)
> > +   ret = wait_for_response(hdev,
> _pkt.host_event);
> 
> Here it looks okay on the first glance, but better to think about it
> again and refactor.

> With Best Regards,
> Andy Shevchenko

I'll try to send out a patch to improve the coding style, after I address
Michael Kelley's concern of a race.

Thanks,
-- Dexuan
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] PCI: hv: Do not wait forever on a device that has disappeared

2018-05-29 Thread Andy Shevchenko
On Thu, May 24, 2018 at 12:12 AM, Dexuan Cui  wrote:
>
> Before the guest finishes the device initialization, the device can be
> removed anytime by the host, and after that the host won't respond to
> the guest's request, so the guest should be prepared to handle this
> case.

> +   while (true) {
> +   if (hdev->channel->rescind) {
> +   dev_warn_once(>device, "The device is gone.\n");
> +   return -ENODEV;
> +   }
> +
> +   if (wait_for_completion_timeout(comp, HZ / 10))
> +   break;
> +   }

Infinite loops are usually a red flags.

What's wrong with simple:

do {
  ...
} while (wait_...(...) == 0);

?

> +   if (!ret)
> +   ret = wait_for_response(hdev, );

Better to use well established patterns, i.e.

if (ret)
 return ret;

> +   if (!ret)
> +   ret = wait_for_response(hdev, _pkt.host_event);

Here it looks okay on the first glance, but better to think about it
again and refactor.

-- 
With Best Regards,
Andy Shevchenko
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[staging:debugfs_cleanup 283/813] drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: ieee80211_sta_wakeup.cold.36()+0x22: sibling call from callable instruction with modified st

2018-05-29 Thread kbuild test robot
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git 
debugfs_cleanup
head:   a93e95df61f8aab471226cb38eaf46923727c4d6
commit: a40c973eebe61aa9242f5501d5d5598778e3bea2 [283/813] staging: rtl8192u: 
Replace GFP_ATOMIC with GFP_KERNEL in ieee80211_softmac_init
config: x86_64-allyesdebian (attached as .config)
compiler: gcc-8 (Debian 8.1.0-3) 8.1.0
reproduce:
git checkout a40c973eebe61aa9242f5501d5d5598778e3bea2
# save the attached .config to linux build tree
make ARCH=x86_64 

All warnings (new ones prefixed by >>):

   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c: In function 
'ieee80211_softmac_new_net':
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:1463:6: warning: 
'strncpy' output may be truncated copying 32 bytes from a string of length 32 
[-Wstringop-truncation]
 strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE);
 ^~~~
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:1468:5: warning: 
'strncpy' output may be truncated copying 32 bytes from a string of length 32 
[-Wstringop-truncation]
strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE);
^~~~
   In function 'ieee80211_softmac_new_net',
   inlined from 'ieee80211_softmac_check_all_nets' at 
drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:1531:4:
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:1463:6: warning: 
'strncpy' output may be truncated copying 32 bytes from a string of length 32 
[-Wstringop-truncation]
 strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE);
 ^~~~
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c:1468:5: warning: 
'strncpy' output may be truncated copying 32 bytes from a string of length 32 
[-Wstringop-truncation]
strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE);
^~~~
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_wpa_set_encryption()+0x76: sibling call from callable instruction 
with modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_wpa_set_param()+0x25: sibling call from callable instruction with 
modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_associate_abort()+0x80: sibling call from callable instruction with 
modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_softmac_new_net()+0x1bb: sibling call from callable instruction with 
modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_softmac_check_all_nets()+0x24f: sibling call from callable 
instruction with modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_sta_wakeup()+0x4e: sibling call from callable instruction with 
modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
softmac_mgmt_xmit()+0x1c1: sibling call from callable instruction with modified 
stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
SendDisassociation_rsl()+0x24d: sibling call from callable instruction with 
modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_associate_procedure_wq()+0x95: sibling call from callable instruction 
with modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_send_probe()+0x357: sibling call from callable instruction with 
modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_check_auth_response()+0x5c7: sibling call from callable instruction 
with modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_rx_frame_softmac()+0x40c: sibling call from callable instruction with 
modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_send_beacon()+0x1b9: sibling call from callable instruction with 
modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_start_ibss_wq()+0xe5: sibling call from callable instruction with 
modified stack frame
   drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
ieee80211_softmac_init()+0x433: sibling call from callable instruction with 
modified stack frame
>> drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.o: warning: objtool: 
>> ieee80211_sta_wakeup.cold.36()+0x22: sibling call from callable instruction 
>> with modified stack frame


RE: [PATCH v1] Drivers: HV: Send one page worth of kmsg dump over Hyper-V during panic

2018-05-29 Thread Sunil Muthuswamy
The V3 patch should address the concerns/comments below. Happy to address any 
additional comments, if there are any.

- Sunil

> -Original Message-
> From: Sunil Muthuswamy
> Sent: Monday, May 21, 2018 9:48 AM
> To: 'Greg KH' 
> Cc: de...@linuxdriverproject.org; Haiyang Zhang
> ; Stephen Hemminger
> 
> Subject: RE: [PATCH v1] Drivers: HV: Send one page worth of kmsg dump
> over Hyper-V during panic
> 
> The v2 patch that I sent was prior to responding to this thread. I am sending
> out v3 which addresses the comments here.
> 
> > -Original Message-
> > From: Greg KH 
> > Sent: Saturday, May 19, 2018 12:01 AM
> > To: Sunil Muthuswamy 
> > Cc: de...@linuxdriverproject.org; Haiyang Zhang
> > ; Stephen Hemminger
> > 
> > Subject: Re: [PATCH v1] Drivers: HV: Send one page worth of kmsg dump
> > over Hyper-V during panic
> >
> > On Fri, May 18, 2018 at 09:00:51PM +, Sunil Muthuswamy wrote:
> > > Thanks, Greg.
> > >
> > > My first patch to the Linux kernel. Still making mistakes, but, learning
> > through the documented process.
> > >
> > > > -Original Message-
> > > > From: Greg KH 
> > > > Sent: Wednesday, May 9, 2018 11:51 PM
> > > > To: Sunil Muthuswamy 
> > > > Cc: Haiyang Zhang ;
> > > > de...@linuxdriverproject.org; Stephen Hemminger
> > > > 
> > > > Subject: Re: [PATCH v1] Drivers: HV: Send one page worth of kmsg
> dump
> > > > over Hyper-V during panic
> > > >
> > > > On Wed, May 09, 2018 at 07:19:24PM +, Sunil Muthuswamy wrote:
> > > > > In the VM mode on Hyper-V, currently, when the kernel panics, an
> > error
> > > > > code and few register values are populated in an MSR and the
> > Hypervisor
> > > > > notified. This information is collected on the host. The amount of
> > > > > information currently collected is found to be limited and not 
> > > > > very
> > > > > actionable. To gather more actionable data, such as stack trace, 
> > > > > the
> > > > > proposal is to write one page worth of kmsg data on an allocated
> page
> > > > > and the Hypervisor notified of the page address through the MSR.
> > > >
> > > > Odd indentation, what editor made you do that?  Please move it all to
> the
> > > > left.
> > > I inserted them. Will fix.
> > > >
> > > > >
> > > > > CC: k...@microsoft.com
> > > > > CC: sthem...@microsoft.com
> > > > > Signed-off-by: Sunil Muthuswamy 
> > > > > ---
> > > > >  arch/x86/hyperv/hv_init.c  | 28 +
> > > > >  arch/x86/include/asm/hyperv-tlfs.h |  5 ++--
> > > > >  arch/x86/include/asm/mshyperv.h|  1 +
> > > > >  drivers/hv/vmbus_drv.c | 61
> > > > ++
> > > > >  4 files changed, 93 insertions(+), 2 deletions(-)
> > > > >
> > > > > diff --git a/arch/x86/hyperv/hv_init.c b/arch/x86/hyperv/hv_init.c
> > > > > index cfecc22..88ee90d 100644
> > > > > --- a/arch/x86/hyperv/hv_init.c
> > > > > +++ b/arch/x86/hyperv/hv_init.c
> > > > > @@ -395,6 +395,34 @@ void hyperv_report_panic(struct pt_regs
> > *regs,
> > > > > long err)  }  EXPORT_SYMBOL_GPL(hyperv_report_panic);
> > > > >
> > > > > +void hyperv_report_panic_msg(phys_addr_t pa, size_t size) {
> > > > > + static bool panic_msg_reported;
> > > > > +
> > > > > + if (panic_msg_reported)
> > > > > + return;
> > > > > + panic_msg_reported = true;
> > > >
> > > > Why do you only care about the first message?
> > > It is following the general direction from ' hyperv_report_panic', but, I
> don't
> > think it needs to. Will change.
> > > >
> > > > > +
> > > > > + /*
> > > > > +  * P3 to contain the physical address of the panic page & P4 to
> > > > > +  * contain the size of the panic data in that page. Rest of the
> > > > > +  * registers are no-op when the NOTIFY_MSG flag is set.
> > > > > +  */
> > > > > + wrmsrl(HV_X64_MSR_CRASH_P0, 0);
> > > > > + wrmsrl(HV_X64_MSR_CRASH_P1, 0);
> > > > > + wrmsrl(HV_X64_MSR_CRASH_P2, 0);
> > > > > + wrmsrl(HV_X64_MSR_CRASH_P3, pa);
> > > > > + wrmsrl(HV_X64_MSR_CRASH_P4, size);
> > > > > +
> > > > > + /*
> > > > > +  * Let Hyper-V know there is crash data available along with
> > > > > +  * the panic message.
> > > > > +  */
> > > > > + wrmsrl(HV_X64_MSR_CRASH_CTL,
> > > > > +(HV_CRASH_CTL_CRASH_NOTIFY |
> > > > HV_CRASH_CTL_CRASH_NOTIFY_MSG));
> > > > > +} EXPORT_SYMBOL_GPL(hyperv_report_panic_msg);
> > > > > +
> > > > >  bool hv_is_hyperv_initialized(void)
> > > > >  {
> > > > >   union hv_x64_msr_hypercall_contents hypercall_msr; diff --
> git
> > > > > a/arch/x86/include/asm/hyperv-tlfs.h
> > > > > b/arch/x86/include/asm/hyperv-tlfs.h
> > > > > index 416cb0e..fc2932c 100644
> > > > > --- a/arch/x86/include/asm/hyperv-tlfs.h
> > > > > +++ b/arch/x86/include/asm/hyperv-tlfs.h
> > > > > @@ -171,9 +171,10 @@
> > > > >  #define HV_X64_ENLIGHTENED_VMCS_RECOMMENDED(1 << 14)
> > > > >
> > > > >  /*
> > > > > - * Crash notification flag.
> > > > > + * Crash 

RE: [PATCH] PCI: hv: Do not wait forever on a device that has disappeared

2018-05-29 Thread Dexuan Cui
> From: Michael Kelley (EOSG)
> Sent: Monday, May 28, 2018 17:19
> 
> While this patch solves the immediate problem of getting hung waiting
> for a response from Hyper-V that will never come, there's another scenario
> to look at that I think introduces a race.  Suppose the guest VM issues a
> vmbus_sendpacket() request in one of the cases covered by this patch,
> and suppose that Hyper-V queues a response to the request, and then
> immediately follows with a rescind request.   Processing the response will
> get queued to a tasklet associated with the channel, while processing the
> rescind will get queued to a tasklet associated with the top-level vmbus
> connection.   From what I can see, the code doesn't impose any ordering
> on processing the two.  If the rescind is processed first, the new
> wait_for_response() function may wake up, notice the rescind flag, and
> return an error.  Its caller will return an error, and in doing so pop the
> completion packet off the stack.   When the response is processed later,
> it will try to signal completion via a completion packet that no longer
> exists, and memory corruption will likely occur.
> 
> Am I missing anything that would prevent this scenario from happening?
> It is admittedly low probability, and a solution seems non-trivial.  I haven't
> looked specifically, but a similar scenario is probably possible with the
> drivers for other VMbus devices.  We should work on a generic solution.
> 
> Michael

Thanks for spotting the race! 

IMO we can disable the per-channel tasklet to exclude the race:

--- a/drivers/pci/host/pci-hyperv.c
+++ b/drivers/pci/host/pci-hyperv.c
@@ -565,6 +565,7 @@ static int wait_for_response(struct hv_device *hdev,
 {
while (true) {
if (hdev->channel->rescind) {
+   tasklet_disable(>channel->callback_event);
dev_warn_once(>device, "The device is gone.\n");
return -ENODEV;
}

This way, when we exit the loop, we're sure hv_pci_onchannelcallback() can not 
run anymore. What do you think of this?


It looks the list of the other vmbus devices that can be hot-removed is:

the hv_utils devices
hv_sock devices
storvsc device
netvsc device

As I checked, the first 3 types of devices don't have this "send a request to 
the
host and wait for the response forever" pattern. NetVSC should be fixed as it 
has
the same pattern.

-- Dexuan
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 1/2] staging: wilc1000: fix some endianness sparse warnings

2018-05-29 Thread Thibaut Robert
This commit fix a few sparse warnings. It mostly consists of fixing the type 
declarations
and avoiding the use of variables with mixed endianness values.

Signed-off-by: Thibaut Robert 
---
 drivers/staging/wilc1000/wilc_spi.c   | 15 ++-
 .../staging/wilc1000/wilc_wfi_cfgoperations.c |  2 +-
 drivers/staging/wilc1000/wilc_wlan.c  | 26 +--
 drivers/staging/wilc1000/wilc_wlan_cfg.c  |  8 +++---
 drivers/staging/wilc1000/wilc_wlan_cfg.h  |  4 +--
 5 files changed, 27 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_spi.c 
b/drivers/staging/wilc1000/wilc_spi.c
index 647526387784..e51f0d91a376 100644
--- a/drivers/staging/wilc1000/wilc_spi.c
+++ b/drivers/staging/wilc1000/wilc_spi.c
@@ -666,11 +666,11 @@ static int spi_data_write(struct wilc *wilc, u8 *b, u32 
sz)
 static int spi_internal_write(struct wilc *wilc, u32 adr, u32 dat)
 {
struct spi_device *spi = to_spi_device(wilc->dev);
+   __le32 le32dat = cpu_to_le32(dat);
int result;
 
-   dat = cpu_to_le32(dat);
-   result = spi_cmd_complete(wilc, CMD_INTERNAL_WRITE, adr, (u8 *), 4,
- 0);
+   result = spi_cmd_complete(wilc, CMD_INTERNAL_WRITE, adr, (u8 *),
+ 4, 0);
if (result != N_OK)
dev_err(>dev, "Failed internal write cmd...\n");
 
@@ -689,7 +689,7 @@ static int spi_internal_read(struct wilc *wilc, u32 adr, 
u32 *data)
return 0;
}
 
-   *data = cpu_to_le32(*data);
+   le32_to_cpus(data);
 
return 1;
 }
@@ -706,15 +706,16 @@ static int wilc_spi_write_reg(struct wilc *wilc, u32 
addr, u32 data)
int result = N_OK;
u8 cmd = CMD_SINGLE_WRITE;
u8 clockless = 0;
+   __le32 le32data = cpu_to_le32(data);
 
-   data = cpu_to_le32(data);
if (addr < 0x30) {
/* Clockless register */
cmd = CMD_INTERNAL_WRITE;
clockless = 1;
}
 
-   result = spi_cmd_complete(wilc, cmd, addr, (u8 *), 4, clockless);
+   result = spi_cmd_complete(wilc, cmd, addr, (u8 *), 4,
+ clockless);
if (result != N_OK)
dev_err(>dev, "Failed cmd, write reg (%08x)...\n", addr);
 
@@ -769,7 +770,7 @@ static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, 
u32 *data)
return 0;
}
 
-   *data = cpu_to_le32(*data);
+   le32_to_cpus(data);
 
return 1;
 }
diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c 
b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
index e248702ee519..745bf5ca2622 100644
--- a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
+++ b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
@@ -1431,7 +1431,7 @@ void wilc_wfi_p2p_rx(struct net_device *dev, u8 *buff, 
u32 size)
 
freq = ieee80211_channel_to_frequency(curr_channel, NL80211_BAND_2GHZ);
 
-   if (!ieee80211_is_action(buff[FRAME_TYPE_ID])) {
+   if (!ieee80211_is_action(cpu_to_le16(buff[FRAME_TYPE_ID]))) {
cfg80211_rx_mgmt(priv->wdev, freq, 0, buff, size, 0);
return;
}
diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index 28c93f3f846e..a5ac1d26590b 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -560,7 +560,8 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*txq_count)
int ret = 0;
int counter;
int timeout;
-   u32 vmm_table[WILC_VMM_TBL_SIZE];
+   __le32 vmm_table[WILC_VMM_TBL_SIZE];
+   u32 table_entry;
struct wilc_vif *vif;
struct wilc *wilc;
const struct wilc_hif_func *func;
@@ -598,10 +599,10 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*txq_count)
if ((sum + vmm_sz) > LINUX_TX_SIZE)
break;
 
-   vmm_table[i] = vmm_sz / 4;
+   table_entry = vmm_sz / 4;
if (tqe->type == WILC_CFG_PKT)
-   vmm_table[i] |= BIT(10);
-   vmm_table[i] = cpu_to_le32(vmm_table[i]);
+   table_entry |= BIT(10);
+   vmm_table[i] = cpu_to_le32(table_entry);
 
i++;
sum += vmm_sz;
@@ -704,8 +705,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*txq_count)
if (vmm_table[i] == 0)
break;
 
-   vmm_table[i] = cpu_to_le32(vmm_table[i]);
-   vmm_sz = (vmm_table[i] & 0x3ff);
+   vmm_sz = (le32_to_cpu(vmm_table[i]) & 0x3ff);
vmm_sz *= 4;
header = (tqe->type << 31) |
 (tqe->buffer_size << 15) |
@@ -715,8 +715,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 
*txq_count)
else
 

[PATCH 1/1] staging: wilc1000: Use common structs to parse ip packets

2018-05-29 Thread Thibaut Robert
Use structs ethhdr, iphdr and tcphdr instead of manual parsing in
tcp_process.
This commit fix handling of ip packets containing options.
It also fixes the following sparse warning:

drivers/staging/wilc1000//wilc_wlan.c:201:19: warning: cast to restricted __be16

Signed-off-by: Thibaut Robert 
---
 drivers/staging/wilc1000/wilc_wlan.c | 44 +++-
 1 file changed, 17 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/wilc1000/wilc_wlan.c 
b/drivers/staging/wilc1000/wilc_wlan.c
index d4ebbf67e50b..28c93f3f846e 100644
--- a/drivers/staging/wilc1000/wilc_wlan.c
+++ b/drivers/staging/wilc1000/wilc_wlan.c
@@ -1,4 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0
+#include 
+#include 
 #include "wilc_wfi_netdevice.h"
 #include "wilc_wlan_cfg.h"
 
@@ -184,9 +186,9 @@ static inline int add_tcp_pending_ack(u32 ack, u32 
session_index,
 
 static inline void tcp_process(struct net_device *dev, struct txq_entry_t *tqe)
 {
-   u8 *eth_hdr_ptr;
+   const struct ethhdr *eth_hdr_ptr = (const struct ethhdr *)tqe->buffer;
+
u8 *buffer = tqe->buffer;
-   unsigned short h_proto;
int i;
unsigned long flags;
struct wilc_vif *vif;
@@ -197,37 +199,25 @@ static inline void tcp_process(struct net_device *dev, 
struct txq_entry_t *tqe)
 
spin_lock_irqsave(>txq_spinlock, flags);
 
-   eth_hdr_ptr = [0];
-   h_proto = ntohs(*((unsigned short *)_hdr_ptr[12]));
-   if (h_proto == ETH_P_IP) {
-   u8 *ip_hdr_ptr;
-   u8 protocol;
-
-   ip_hdr_ptr = [ETHERNET_HDR_LEN];
-   protocol = ip_hdr_ptr[9];
+   if (eth_hdr_ptr->h_proto == htons(ETH_P_IP)) {
+   const struct iphdr *ip_hdr_ptr = (const struct iphdr *)
+ (buffer + ETH_HLEN);
 
-   if (protocol == 0x06) {
-   u8 *tcp_hdr_ptr;
+   if (ip_hdr_ptr->protocol == IPPROTO_TCP) {
+   const struct tcphdr *tcp_hdr_ptr;
u32 IHL, total_length, data_offset;
 
-   tcp_hdr_ptr = _hdr_ptr[IP_HDR_LEN];
-   IHL = (ip_hdr_ptr[0] & 0xf) << 2;
-   total_length = ((u32)ip_hdr_ptr[2] << 8) +
-   (u32)ip_hdr_ptr[3];
-   data_offset = ((u32)tcp_hdr_ptr[12] & 0xf0) >> 2;
+   IHL = ip_hdr_ptr->ihl << 2;
+   tcp_hdr_ptr = (const struct tcphdr *)
+ ((u8 *)ip_hdr_ptr + IHL);
+   total_length = ntohs(ip_hdr_ptr->tot_len);
+
+   data_offset = tcp_hdr_ptr->doff << 2;
if (total_length == (IHL + data_offset)) {
u32 seq_no, ack_no;
 
-   seq_no = ((u32)tcp_hdr_ptr[4] << 24) +
-((u32)tcp_hdr_ptr[5] << 16) +
-((u32)tcp_hdr_ptr[6] << 8) +
-(u32)tcp_hdr_ptr[7];
-
-   ack_no = ((u32)tcp_hdr_ptr[8] << 24) +
-((u32)tcp_hdr_ptr[9] << 16) +
-((u32)tcp_hdr_ptr[10] << 8) +
-(u32)tcp_hdr_ptr[11];
-
+   seq_no = ntohl(tcp_hdr_ptr->seq);
+   ack_no = ntohl(tcp_hdr_ptr->ack_seq);
for (i = 0; i < tcp_session; i++) {
u32 j = ack_session_info[i].seq_num;
 
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: comedi: comedi_usb.h: SPDX License Identifier is added in the first line

2018-05-29 Thread Bhanusree Pola
SPDX License Identifier is added in form of a comment.

Signed-off-by: Bhanusree Pola 
---
 drivers/staging/comedi/comedi_usb.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/comedi/comedi_usb.h 
b/drivers/staging/comedi/comedi_usb.h
index 50287de..601e29d 100644
--- a/drivers/staging/comedi/comedi_usb.h
+++ b/drivers/staging/comedi/comedi_usb.h
@@ -1,6 +1,5 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * comedi_usb.h
+/* SPDX-License-Identifier: GPL-2.0+ */
+/* comedi_usb.h
  * header file for USB Comedi drivers
  *
  * COMEDI - Linux Control and Measurement Device Interface
-- 
2.7.4

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] staging: mt7621-mmc: Fix line size exceeding 80 columns.

2018-05-29 Thread Sankalp Negi
This patch fixes the checkpatch.pl warning:

WARNING: line over 80 characters

Signed-off-by: Sankalp Negi 
---
 drivers/staging/mt7621-mmc/dbg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/mt7621-mmc/dbg.c b/drivers/staging/mt7621-mmc/dbg.c
index d897b1216348..0b007e060ddc 100644
--- a/drivers/staging/mt7621-mmc/dbg.c
+++ b/drivers/staging/mt7621-mmc/dbg.c
@@ -229,7 +229,7 @@ static int msdc_debug_proc_read(struct seq_file *s, void *p)
 }
 
 static ssize_t msdc_debug_proc_write(struct file *file,
-   const char __user *buf, size_t count, loff_t 
*data)
+   const char __user *buf, size_t count, loff_t *data)
 {
int ret;
 
-- 
2.11.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next v2 3/7] rocker: rocker_main: Ignore bridge VLAN events

2018-05-29 Thread Ilias Apalodimas
On Tue, May 29, 2018 at 05:37:30PM +0300, Petr Machata wrote:
> Ilias Apalodimas  writes:
> 
> >> diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
> >> b/drivers/net/ethernet/rocker/rocker_main.c
> >> index e73e4fe..aeafdb9 100644
> >> --- a/drivers/net/ethernet/rocker/rocker_main.c
> >> +++ b/drivers/net/ethernet/rocker/rocker_main.c
> >> @@ -1632,6 +1632,9 @@ rocker_world_port_obj_vlan_add(struct rocker_port 
> >> *rocker_port,
> >>  {
> >>struct rocker_world_ops *wops = rocker_port->rocker->wops;
> >>  
> >> +  if (netif_is_bridge_master(vlan->obj.orig_dev))
> >> +  return -EOPNOTSUPP;
> >> +
> > What will happen to the "bridge vlan add dev br0 vid X pvid untagged self" 
> > when
> > the lower level (the driver) returns -EOPNOTSUPP? Will it avoid adding a 
> > vlan on
> > the bridge ?
> 
> No, it will still do it. The reasons are:
> 
> - that's what currently happens anyway: none of the drivers has any
>   support, yet the bridge logic is done
> 
> - -EOPNOTSUPP is what switchdev_port_obj_*() return if switchdev is not
>   compiled in
> 
> In order to suppress the setting, return e.g. -EINVAL:
> 
> # bridge vlan add dev br vid 111 self
> RTNETLINK answers: Invalid argument
> # bridge vlan show dev br
> portvlan ids
> br   1 PVID Egress Untagged
> 
> Thanks,
> Petr
Ok that's perfect then. As i mentioned it's really useful for a use case i am
doing on a switch that needs it's cpu port configured individually.

Thanks,
Ilias
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next v2 3/7] rocker: rocker_main: Ignore bridge VLAN events

2018-05-29 Thread Petr Machata
Ilias Apalodimas  writes:

>> diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
>> b/drivers/net/ethernet/rocker/rocker_main.c
>> index e73e4fe..aeafdb9 100644
>> --- a/drivers/net/ethernet/rocker/rocker_main.c
>> +++ b/drivers/net/ethernet/rocker/rocker_main.c
>> @@ -1632,6 +1632,9 @@ rocker_world_port_obj_vlan_add(struct rocker_port 
>> *rocker_port,
>>  {
>>  struct rocker_world_ops *wops = rocker_port->rocker->wops;
>>  
>> +if (netif_is_bridge_master(vlan->obj.orig_dev))
>> +return -EOPNOTSUPP;
>> +
> What will happen to the "bridge vlan add dev br0 vid X pvid untagged self" 
> when
> the lower level (the driver) returns -EOPNOTSUPP? Will it avoid adding a vlan 
> on
> the bridge ?

No, it will still do it. The reasons are:

- that's what currently happens anyway: none of the drivers has any
  support, yet the bridge logic is done

- -EOPNOTSUPP is what switchdev_port_obj_*() return if switchdev is not
  compiled in

In order to suppress the setting, return e.g. -EINVAL:

# bridge vlan add dev br vid 111 self
RTNETLINK answers: Invalid argument
# bridge vlan show dev br
portvlan ids
br   1 PVID Egress Untagged

Thanks,
Petr
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 10/13] staging: lustre: unwrap some ldebugfs_register() calls

2018-05-29 Thread Greg Kroah-Hartman
When the third option (list) to ldebugfs_register() is NULL, it's the
same as just calling debugfs_create_dir().  So unwind this and call
debugfs_create_dir() directly.

This ends up saving lots of code as we do not need to do any error
checking of the return value (because it does not matter).

The ldebugfs_register() call will be removed in a later patch when it is
fully removed, right now there are 2 outstanding users of it in the
tree.

Cc: Oleg Drokin 
Cc: Andreas Dilger 
Cc: James Simmons 
Cc: NeilBrown 
Cc: Aastha Gupta 
Cc: Arnd Bergmann 
Cc: Ingo Molnar 
Cc: Quentin Bouget 
Cc: Patrick Farrell 
Cc: Aliaksei Karaliou 
Cc: "John L. Hammond" 
Cc: Mathias Rav 
Cc: Andriy Skulysh 
Cc: Ben Evans 
Cc: Bob Glosman 
Cc: lustre-de...@lists.lustre.org
Signed-off-by: Greg Kroah-Hartman 
---
 .../staging/lustre/lustre/fid/fid_request.c   | 20 +++
 .../staging/lustre/lustre/fld/fld_request.c   | 20 +++
 .../staging/lustre/lustre/ldlm/ldlm_pool.c|  9 +
 .../lustre/lustre/ldlm/ldlm_resource.c| 34 +++
 .../staging/lustre/lustre/llite/lproc_llite.c |  7 +---
 drivers/staging/lustre/lustre/lov/lov_obd.c   |  5 ++-
 .../staging/lustre/lustre/obdclass/genops.c   | 11 ++
 .../lustre/lustre/ptlrpc/lproc_ptlrpc.c   | 11 ++
 8 files changed, 24 insertions(+), 93 deletions(-)

diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c 
b/drivers/staging/lustre/lustre/fid/fid_request.c
index c674652af03a..dfcac0afa106 100644
--- a/drivers/staging/lustre/lustre/fid/fid_request.c
+++ b/drivers/staging/lustre/lustre/fid/fid_request.c
@@ -299,17 +299,8 @@ static int seq_client_debugfs_init(struct lu_client_seq 
*seq)
 {
int rc;
 
-   seq->lcs_debugfs_entry = ldebugfs_register(seq->lcs_name,
-  seq_debugfs_dir,
-  NULL, NULL);
-
-   if (IS_ERR_OR_NULL(seq->lcs_debugfs_entry)) {
-   CERROR("%s: LdebugFS failed in seq-init\n", seq->lcs_name);
-   rc = seq->lcs_debugfs_entry ? PTR_ERR(seq->lcs_debugfs_entry)
-   : -ENOMEM;
-   seq->lcs_debugfs_entry = NULL;
-   return rc;
-   }
+   seq->lcs_debugfs_entry = debugfs_create_dir(seq->lcs_name,
+   seq_debugfs_dir);
 
rc = ldebugfs_add_vars(seq->lcs_debugfs_entry,
   seq_client_debugfs_list, seq);
@@ -424,10 +415,9 @@ static int __init fid_init(void)
if (rc)
return rc;
 
-   seq_debugfs_dir = ldebugfs_register(LUSTRE_SEQ_NAME,
-   debugfs_lustre_root,
-   NULL, NULL);
-   return PTR_ERR_OR_ZERO(seq_debugfs_dir);
+   seq_debugfs_dir = debugfs_create_dir(LUSTRE_SEQ_NAME,
+debugfs_lustre_root);
+   return 0;
 }
 
 static void __exit fid_exit(void)
diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c 
b/drivers/staging/lustre/lustre/fld/fld_request.c
index 7b7ba93a4db6..409850379fc3 100644
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -221,17 +221,8 @@ static int fld_client_debugfs_init(struct lu_client_fld 
*fld)
 {
int rc;
 
-   fld->lcf_debugfs_entry = ldebugfs_register(fld->lcf_name,
-  fld_debugfs_dir,
-  NULL, NULL);
-
-   if (IS_ERR_OR_NULL(fld->lcf_debugfs_entry)) {
-   CERROR("%s: LdebugFS failed in fld-init\n", fld->lcf_name);
-   rc = fld->lcf_debugfs_entry ? PTR_ERR(fld->lcf_debugfs_entry)
-   : -ENOMEM;
-   fld->lcf_debugfs_entry = NULL;
-   return rc;
-   }
+   fld->lcf_debugfs_entry = debugfs_create_dir(fld->lcf_name,
+   fld_debugfs_dir);
 
rc = ldebugfs_add_vars(fld->lcf_debugfs_entry,
   fld_client_debugfs_list, fld);
@@ -455,10 +446,9 @@ static int __init fld_init(void)
if (rc)
return rc;
 
-   fld_debugfs_dir = ldebugfs_register(LUSTRE_FLD_NAME,
-   debugfs_lustre_root,
-   NULL, NULL);
-   return PTR_ERR_OR_ZERO(fld_debugfs_dir);
+   fld_debugfs_dir = debugfs_create_dir(LUSTRE_FLD_NAME,
+debugfs_lustre_root);
+   return 0;
 }
 
 static void __exit fld_exit(void)
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index b83e93256cd1..146b348ca312 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -572,14 +572,7 @@ static 

[PATCH 05/13] staging: lustre: no need to check debugfs return values

2018-05-29 Thread Greg Kroah-Hartman
When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Clean up the lustre core code by not caring about the value of debugfs
calls.  This ends up removing a number of lines of code that are not
needed.

Note, more work is needed to remove the unneeded debugfs wrapper
functions in the future.

Cc: Oleg Drokin 
Cc: Andreas Dilger 
Cc: James Simmons 
Cc: NeilBrown 
Cc: Ben Evans 
Cc: Arvind Yadav 
Cc: "John L. Hammond" 
Cc: Dafna Hirschfeld 
Cc: Mathias Rav 
Cc: "Gustavo A. R. Silva" 
Cc: lustre-de...@lists.lustre.org
Signed-off-by: Greg Kroah-Hartman 
---
 .../lustre/obdclass/linux/linux-module.c  | 19 ++-
 .../lustre/lustre/obdclass/lprocfs_status.c   | 11 ---
 2 files changed, 2 insertions(+), 28 deletions(-)

diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c 
b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
index d3196439985b..9c800580053b 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
@@ -481,7 +481,6 @@ static const struct attribute_group lustre_attr_group = {
 int class_procfs_init(void)
 {
int rc = -ENOMEM;
-   struct dentry *file;
 
lustre_kobj = kobject_create_and_add("lustre", fs_kobj);
if (!lustre_kobj)
@@ -495,23 +494,9 @@ int class_procfs_init(void)
}
 
debugfs_lustre_root = debugfs_create_dir("lustre", NULL);
-   if (IS_ERR_OR_NULL(debugfs_lustre_root)) {
-   rc = debugfs_lustre_root ? PTR_ERR(debugfs_lustre_root)
-: -ENOMEM;
-   debugfs_lustre_root = NULL;
-   sysfs_remove_group(lustre_kobj, _attr_group);
-   kobject_put(lustre_kobj);
-   goto out;
-   }
 
-   file = debugfs_create_file("devices", 0444, debugfs_lustre_root, NULL,
-  _device_list_fops);
-   if (IS_ERR_OR_NULL(file)) {
-   rc = file ? PTR_ERR(file) : -ENOMEM;
-   sysfs_remove_group(lustre_kobj, _attr_group);
-   kobject_put(lustre_kobj);
-   goto out;
-   }
+   debugfs_create_file("devices", 0444, debugfs_lustre_root, NULL,
+   _device_list_fops);
 out:
return rc;
 }
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c 
b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index eb6396add78d..c3f57b025f10 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -315,10 +315,6 @@ struct dentry *ldebugfs_add_simple(struct dentry *root,
if (fops->write)
mode |= 0200;
entry = debugfs_create_file(name, mode, root, data, fops);
-   if (IS_ERR_OR_NULL(entry)) {
-   CERROR("LprocFS: No memory to create  entry %s\n", 
name);
-   return entry ?: ERR_PTR(-ENOMEM);
-   }
return entry;
 }
 EXPORT_SYMBOL_GPL(ldebugfs_add_simple);
@@ -348,8 +344,6 @@ int ldebugfs_add_vars(struct dentry *parent,
list->data ?: data,
list->fops ?: _generic_fops
   );
-   if (IS_ERR_OR_NULL(entry))
-   return entry ? PTR_ERR(entry) : -ENOMEM;
list++;
}
return 0;
@@ -1358,9 +1352,6 @@ int ldebugfs_register_stats(struct dentry *parent, const 
char *name,
 
entry = debugfs_create_file(name, 0644, parent, stats,
_stats_seq_fops);
-   if (IS_ERR_OR_NULL(entry))
-   return entry ? PTR_ERR(entry) : -ENOMEM;
-
return 0;
 }
 EXPORT_SYMBOL_GPL(ldebugfs_register_stats);
@@ -1588,8 +1579,6 @@ int ldebugfs_seq_create(struct dentry *parent, const char 
*name,
LASSERT((!seq_fops->write) == ((mode & 0222) == 0));
 
entry = debugfs_create_file(name, mode, parent, data, seq_fops);
-   if (IS_ERR_OR_NULL(entry))
-   return entry ? PTR_ERR(entry) : -ENOMEM;
 
return 0;
 }
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 08/13] staging: lustre: remove ldebugfs_seq_create() wrapper function

2018-05-29 Thread Greg Kroah-Hartman
It was just calling debugfs_create_file() so unwind things and just call
the real function instead.  This ends up saving a number of lines as
there was never any error handling happening anyway, so that all can be
removed as well.

Cc: Oleg Drokin 
Cc: Andreas Dilger 
Cc: James Simmons 
Cc: Quentin Bouget 
Cc: NeilBrown 
Cc: Ben Evans 
Cc: Arushi Singhal 
Cc: Arvind Yadav 
Cc: "John L. Hammond" 
Cc: Vitaly Fertman 
Cc: Julia Lawall 
Cc: Dafna Hirschfeld 
Cc: Mathias Rav 
Cc: "Gustavo A. R. Silva" 
Cc: Bob Glosman 
Cc: lustre-de...@lists.lustre.org
Signed-off-by: Greg Kroah-Hartman 
---
 .../lustre/lustre/include/lprocfs_status.h|  5 
 .../staging/lustre/lustre/llite/lproc_llite.c | 30 ++-
 drivers/staging/lustre/lustre/lmv/lmv_obd.c   |  7 ++---
 drivers/staging/lustre/lustre/lov/lov_obd.c   |  6 ++--
 .../lustre/lustre/obdclass/lprocfs_status.c   | 19 ++--
 drivers/staging/lustre/lustre/osc/lproc_osc.c |  9 +++---
 .../lustre/lustre/ptlrpc/lproc_ptlrpc.c   |  8 ++---
 7 files changed, 21 insertions(+), 63 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h 
b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index 7aafe873cb39..54abcc2eaeb6 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -465,11 +465,6 @@ int lprocfs_obd_setup(struct obd_device *obd, struct 
lprocfs_vars *list,
  const struct attribute_group *attrs);
 int lprocfs_obd_cleanup(struct obd_device *obd);
 
-int ldebugfs_seq_create(struct dentry *parent,
-   const char *name,
-   umode_t mode,
-   const struct file_operations *seq_fops,
-   void *data);
 int ldebugfs_obd_seq_create(struct obd_device *dev,
const char *name,
umode_t mode,
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c 
b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index 2297a14f00ca..1f122f8a54dc 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -1139,7 +1139,7 @@ int ldebugfs_register_mountpoint(struct dentry *parent,
struct obd_device *obd;
struct dentry *dir;
char name[MAX_STRING_SIZE + 1], *ptr;
-   int err, id, len, rc;
+   int err, id, len;
 
name[MAX_STRING_SIZE] = '\0';
 
@@ -1165,26 +1165,14 @@ int ldebugfs_register_mountpoint(struct dentry *parent,
}
sbi->ll_debugfs_entry = dir;
 
-   rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "dump_page_cache", 0444,
-_dump_pgcache_file_ops, sbi);
-   if (rc)
-   CWARN("Error adding the dump_page_cache file\n");
-
-   rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "extents_stats", 0644,
-_rw_extents_stats_fops, sbi);
-   if (rc)
-   CWARN("Error adding the extent_stats file\n");
-
-   rc = ldebugfs_seq_create(sbi->ll_debugfs_entry,
-"extents_stats_per_process",
-0644, _rw_extents_stats_pp_fops, sbi);
-   if (rc)
-   CWARN("Error adding the extents_stats_per_process file\n");
-
-   rc = ldebugfs_seq_create(sbi->ll_debugfs_entry, "offset_stats", 0644,
-_rw_offset_stats_fops, sbi);
-   if (rc)
-   CWARN("Error adding the offset_stats file\n");
+   debugfs_create_file("dump_page_cache", 0444, dir, sbi,
+   _dump_pgcache_file_ops);
+   debugfs_create_file("extents_stats", 0644, dir, sbi,
+   _rw_extents_stats_fops);
+   debugfs_create_file("extents_stats_per_process", 0644,
+   dir, sbi, _rw_extents_stats_pp_fops);
+   debugfs_create_file("offset_stats", 0644, dir, sbi,
+   _rw_offset_stats_fops);
 
/* File operations stats */
sbi->ll_stats = lprocfs_alloc_stats(LPROC_LL_FILE_OPCODES,
diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c 
b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
index 60cdba99e4a4..85b6e8392759 100644
--- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c
+++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c
@@ -1264,11 +1264,8 @@ static int lmv_setup(struct obd_device *obd, struct 
lustre_cfg *lcfg)
lprocfs_lmv_init_vars();
 
lprocfs_obd_setup(obd, lvars.obd_vars, lvars.sysfs_vars);
-   rc = ldebugfs_seq_create(obd->obd_debugfs_entry, "target_obd",
-0444, _proc_target_fops, obd);
-   if (rc)
-   CWARN("%s: error adding LMV target_obd file: rc = %d\n",
- obd->obd_name, rc);
+   debugfs_create_file("target_obd", 0444, obd->obd_debugfs_entry, obd,
+   _proc_target_fops);
rc = 

[PATCH 12/13] staging: lustre: make ldebugfs_add_vars a void function

2018-05-29 Thread Greg Kroah-Hartman
The call to ldebugfs_add_vars() can not really fail, so have it just
return nothing, which allows us to clean up a lot of unused error
handling code.

Cc: Oleg Drokin 
Cc: Andreas Dilger 
Cc: James Simmons 
Cc: NeilBrown 
Cc: Roman Storozhenko 
Cc: Arnd Bergmann 
Cc: Quentin Bouget 
Cc: Aastha Gupta 
Cc: Ben Evans 
Cc: Arvind Yadav 
Cc: Arushi Singhal 
Cc: Frank Zago 
Cc: Patrick Farrell 
Cc: Simo Koskinen 
Cc: Andriy Skulysh 
Cc: "John L. Hammond" 
Cc: Mathias Rav 
Cc: Dafna Hirschfeld 
Cc: "Gustavo A. R. Silva" 
Cc: lustre-de...@lists.lustre.org
Signed-off-by: Greg Kroah-Hartman 
---
 .../staging/lustre/lustre/fid/fid_request.c   | 37 ---
 .../staging/lustre/lustre/fld/fld_request.c   | 30 +++
 .../lustre/lustre/include/lprocfs_status.h|  5 +--
 .../lustre/lustre/include/lustre_dlm.h|  2 +-
 .../staging/lustre/lustre/ldlm/ldlm_lockd.c   |  4 +-
 .../lustre/lustre/ldlm/ldlm_resource.c| 21 +--
 .../staging/lustre/lustre/llite/lproc_llite.c |  5 +--
 .../lustre/lustre/obdclass/lprocfs_status.c   | 17 -
 8 files changed, 27 insertions(+), 94 deletions(-)

diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c 
b/drivers/staging/lustre/lustre/fid/fid_request.c
index dfcac0afa106..bc748ab6645d 100644
--- a/drivers/staging/lustre/lustre/fid/fid_request.c
+++ b/drivers/staging/lustre/lustre/fid/fid_request.c
@@ -295,26 +295,12 @@ static void seq_client_debugfs_fini(struct lu_client_seq 
*seq)
ldebugfs_remove(>lcs_debugfs_entry);
 }
 
-static int seq_client_debugfs_init(struct lu_client_seq *seq)
+static void seq_client_debugfs_init(struct lu_client_seq *seq)
 {
-   int rc;
-
seq->lcs_debugfs_entry = debugfs_create_dir(seq->lcs_name,
seq_debugfs_dir);
 
-   rc = ldebugfs_add_vars(seq->lcs_debugfs_entry,
-  seq_client_debugfs_list, seq);
-   if (rc) {
-   CERROR("%s: Can't init sequence manager debugfs, rc %d\n",
-  seq->lcs_name, rc);
-   goto out_cleanup;
-   }
-
-   return 0;
-
-out_cleanup:
-   seq_client_debugfs_fini(seq);
-   return rc;
+   ldebugfs_add_vars(seq->lcs_debugfs_entry, seq_client_debugfs_list, seq);
 }
 
 static void seq_client_fini(struct lu_client_seq *seq)
@@ -327,13 +313,9 @@ static void seq_client_fini(struct lu_client_seq *seq)
}
 }
 
-static int seq_client_init(struct lu_client_seq *seq,
-  struct obd_export *exp,
-  enum lu_cli_type type,
-  const char *prefix)
+static void seq_client_init(struct lu_client_seq *seq, struct obd_export *exp,
+   enum lu_cli_type type, const char *prefix)
 {
-   int rc;
-
LASSERT(seq);
LASSERT(prefix);
 
@@ -354,10 +336,7 @@ static int seq_client_init(struct lu_client_seq *seq,
snprintf(seq->lcs_name, sizeof(seq->lcs_name),
 "cli-%s", prefix);
 
-   rc = seq_client_debugfs_init(seq);
-   if (rc)
-   seq_client_fini(seq);
-   return rc;
+   seq_client_debugfs_init(seq);
 }
 
 int client_fid_init(struct obd_device *obd,
@@ -380,12 +359,10 @@ int client_fid_init(struct obd_device *obd,
snprintf(prefix, MAX_OBD_NAME + 5, "cli-%s", obd->obd_name);
 
/* Init client side sequence-manager */
-   rc = seq_client_init(cli->cl_seq, exp, type, prefix);
+   seq_client_init(cli->cl_seq, exp, type, prefix);
kfree(prefix);
-   if (rc)
-   goto out_free_seq;
 
-   return rc;
+   return 0;
 out_free_seq:
kfree(cli->cl_seq);
cli->cl_seq = NULL;
diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c 
b/drivers/staging/lustre/lustre/fld/fld_request.c
index 409850379fc3..cb67fee19451 100644
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -217,25 +217,12 @@ int fld_client_del_target(struct lu_client_fld *fld, 
__u64 idx)
 
 static struct dentry *fld_debugfs_dir;
 
-static int fld_client_debugfs_init(struct lu_client_fld *fld)
+static void fld_client_debugfs_init(struct lu_client_fld *fld)
 {
-   int rc;
-
fld->lcf_debugfs_entry = debugfs_create_dir(fld->lcf_name,
fld_debugfs_dir);
 
-   rc = ldebugfs_add_vars(fld->lcf_debugfs_entry,
-  fld_client_debugfs_list, fld);
-   if (rc) {
-   CERROR("%s: Can't init FLD debufs, rc %d\n", fld->lcf_name, rc);
-   goto out_cleanup;
-   }
-
-   return 0;
-
-out_cleanup:
-   fld_client_debugfs_fini(fld);
-   return rc;
+   ldebugfs_add_vars(fld->lcf_debugfs_entry, fld_client_debugfs_list, fld);
 }
 
 void fld_client_debugfs_fini(struct lu_client_fld *fld)
@@ -254,7 +241,7 @@ int fld_client_init(struct lu_client_fld *fld,
const 

[PATCH 06/13] staging: lustre: remove ldebugfs_add_simple() wrapper

2018-05-29 Thread Greg Kroah-Hartman
It was only being called in one place, and is an unneeded wrapper
function around debugfs_create_file() so just call the real debugfs
function instead.  This ends up cleaning up some unneeded error handling
logic that was never needed as well.

Cc: Oleg Drokin 
Cc: Andreas Dilger 
Cc: James Simmons 
Cc: Quentin Bouget 
Cc: Ben Evans 
Cc: NeilBrown 
Cc: Arvind Yadav 
Cc: Arushi Singhal 
Cc: Dafna Hirschfeld 
Cc: Mathias Rav 
Cc: "Gustavo A. R. Silva" 
Cc: lustre-de...@lists.lustre.org
Signed-off-by: Greg Kroah-Hartman 
---
 .../lustre/lustre/include/lprocfs_status.h|  5 -
 drivers/staging/lustre/lustre/lov/lov_pool.c  | 21 +--
 .../lustre/lustre/obdclass/lprocfs_status.c   | 19 -
 3 files changed, 5 insertions(+), 40 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h 
b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index 1322ecffda13..9eac7dac8c7b 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -447,11 +447,6 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int 
index,
  const char *units);
 struct obd_export;
 int lprocfs_exp_cleanup(struct obd_export *exp);
-struct dentry *ldebugfs_add_simple(struct dentry *root,
-  char *name,
-  void *data,
-  const struct file_operations *fops);
-
 int ldebugfs_register_stats(struct dentry *parent,
const char *name,
struct lprocfs_stats *stats);
diff --git a/drivers/staging/lustre/lustre/lov/lov_pool.c 
b/drivers/staging/lustre/lustre/lov/lov_pool.c
index 6d2dec9266b6..9ce7038c9b0e 100644
--- a/drivers/staging/lustre/lustre/lov/lov_pool.c
+++ b/drivers/staging/lustre/lustre/lov/lov_pool.c
@@ -80,7 +80,6 @@ void lov_pool_putref(struct pool_desc *pool)
CDEBUG(D_INFO, "pool %p\n", pool);
if (atomic_dec_and_test(>pool_refcount)) {
LASSERT(list_empty(>pool_list));
-   LASSERT(!pool->pool_debugfs_entry);
lov_ost_pool_free(>pool_obds);
kfree_rcu(pool, rcu);
}
@@ -377,18 +376,11 @@ int lov_pool_new(struct obd_device *obd, char *poolname)
 
/* get ref for debugfs file */
lov_pool_getref(new_pool);
-   new_pool->pool_debugfs_entry = ldebugfs_add_simple(
+
+   new_pool->pool_debugfs_entry = debugfs_create_file(poolname, 0444,
lov->lov_pool_debugfs_entry,
-   poolname, new_pool,
+   new_pool,
_proc_operations);
-   if (IS_ERR_OR_NULL(new_pool->pool_debugfs_entry)) {
-   CWARN("Cannot add debugfs pool entry " LOV_POOLNAMEF "\n",
- poolname);
-   new_pool->pool_debugfs_entry = NULL;
-   lov_pool_putref(new_pool);
-   }
-   CDEBUG(D_INFO, "pool %p - proc %p\n",
-  new_pool, new_pool->pool_debugfs_entry);
 
spin_lock(>obd_dev_lock);
list_add_tail(_pool->pool_list, >lov_pool_list);
@@ -443,11 +435,8 @@ int lov_pool_del(struct obd_device *obd, char *poolname)
if (!pool)
return -ENOENT;
 
-   if (!IS_ERR_OR_NULL(pool->pool_debugfs_entry)) {
-   CDEBUG(D_INFO, "proc entry %p\n", pool->pool_debugfs_entry);
-   ldebugfs_remove(>pool_debugfs_entry);
-   lov_pool_putref(pool);
-   }
+   ldebugfs_remove(>pool_debugfs_entry);
+   lov_pool_putref(pool);
 
spin_lock(>obd_dev_lock);
list_del_init(>pool_list);
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c 
b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index c3f57b025f10..68e85f46a146 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -300,25 +300,6 @@ EXPORT_SYMBOL(lprocfs_seq_release);
 
 /* lprocfs API calls */
 
-struct dentry *ldebugfs_add_simple(struct dentry *root,
-  char *name, void *data,
-  const struct file_operations *fops)
-{
-   struct dentry *entry;
-   umode_t mode = 0;
-
-   if (!root || !name || !fops)
-   return ERR_PTR(-EINVAL);
-
-   if (fops->read)
-   mode = 0444;
-   if (fops->write)
-   mode |= 0200;
-   entry = debugfs_create_file(name, mode, root, data, fops);
-   return entry;
-}
-EXPORT_SYMBOL_GPL(ldebugfs_add_simple);
-
 static const struct file_operations lprocfs_generic_fops = { };
 
 int ldebugfs_add_vars(struct dentry *parent,
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org

[PATCH 01/13] staging: greybus: camera: no need to check debugfs return values

2018-05-29 Thread Greg Kroah-Hartman
When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Clean up the greybus camera driver by not caring about the value of
debugfs calls.  This ends up removing a number of lines of code that
are not needed.

Cc: Johan Hovold 
Cc: Alex Elder 
Cc: Greg Kroah-Hartman 
Cc: greybus-...@lists.linaro.org
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/greybus/camera.c | 17 +++--
 1 file changed, 3 insertions(+), 14 deletions(-)

diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c
index 07ebfb88db9b..341f729a9779 100644
--- a/drivers/staging/greybus/camera.c
+++ b/drivers/staging/greybus/camera.c
@@ -1174,11 +1174,6 @@ static int gb_camera_debugfs_init(struct gb_camera *gcam)
 gcam->bundle->id);
 
gcam->debugfs.root = debugfs_create_dir(dirname, gb_debugfs_get());
-   if (IS_ERR(gcam->debugfs.root)) {
-   gcam_err(gcam, "debugfs root create failed (%ld)\n",
-PTR_ERR(gcam->debugfs.root));
-   return PTR_ERR(gcam->debugfs.root);
-   }
 
gcam->debugfs.buffers = vmalloc(sizeof(*gcam->debugfs.buffers) *
GB_CAMERA_DEBUGFS_BUFFER_MAX);
@@ -1188,18 +1183,12 @@ static int gb_camera_debugfs_init(struct gb_camera 
*gcam)
for (i = 0; i < ARRAY_SIZE(gb_camera_debugfs_entries); ++i) {
const struct gb_camera_debugfs_entry *entry =
_camera_debugfs_entries[i];
-   struct dentry *dentry;
 
gcam->debugfs.buffers[i].length = 0;
 
-   dentry = debugfs_create_file(entry->name, entry->mask,
-gcam->debugfs.root, gcam,
-_camera_debugfs_ops);
-   if (IS_ERR(dentry)) {
-   gcam_err(gcam,
-"debugfs operation %s create failed (%ld)\n",
-entry->name, PTR_ERR(dentry));
-   return PTR_ERR(dentry);
+   debugfs_create_file(entry->name, entry->mask,
+   gcam->debugfs.root, gcam,
+   _camera_debugfs_ops);
}
}
 
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 04/13] staging: vc04_services: no need to check debugfs return values

2018-05-29 Thread Greg Kroah-Hartman
When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Clean up the vchiq_arm code by not caring about the value of debugfs
calls.  This ends up removing a number of lines of code that are not
needed.

Cc: Eric Anholt 
Cc: Stefan Wahren 
Cc: Kees Cook 
Cc: Dan Carpenter 
Cc: Arnd Bergmann 
Cc: Keerthi Reddy 
Cc: linux-rpi-ker...@lists.infradead.org
Cc: linux-arm-ker...@lists.infradead.org
Signed-off-by: Greg Kroah-Hartman 
---
 .../interface/vchiq_arm/vchiq_arm.c   | 13 +---
 .../interface/vchiq_arm/vchiq_debugfs.c   | 72 +++
 .../interface/vchiq_arm/vchiq_debugfs.h   |  4 +-
 3 files changed, 15 insertions(+), 74 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
index aaa264f3b598..bc05c69383b8 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
@@ -2018,7 +2018,6 @@ vchiq_open(struct inode *inode, struct file *file)
vchiq_log_info(vchiq_arm_log_level, "vchiq_open");
switch (dev) {
case VCHIQ_MINOR: {
-   int ret;
VCHIQ_STATE_T *state = vchiq_get_state();
VCHIQ_INSTANCE_T instance;
 
@@ -2035,11 +2034,7 @@ vchiq_open(struct inode *inode, struct file *file)
instance->state = state;
instance->pid = current->tgid;
 
-   ret = vchiq_debugfs_add_instance(instance);
-   if (ret != 0) {
-   kfree(instance);
-   return ret;
-   }
+   vchiq_debugfs_add_instance(instance);
 
sema_init(>insert_event, 0);
sema_init(>remove_event, 0);
@@ -3630,9 +3625,7 @@ static int vchiq_probe(struct platform_device *pdev)
goto failed_device_create;
 
/* create debugfs entries */
-   err = vchiq_debugfs_init();
-   if (err != 0)
-   goto failed_debugfs_init;
+   vchiq_debugfs_init();
 
vchiq_log_info(vchiq_arm_log_level,
"vchiq: initialised - version %d (min %d), device %d.%d",
@@ -3645,8 +3638,6 @@ static int vchiq_probe(struct platform_device *pdev)
 
return 0;
 
-failed_debugfs_init:
-   device_destroy(vchiq_class, vchiq_devid);
 failed_device_create:
class_destroy(vchiq_class);
 failed_class_create:
diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c 
b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
index 766b4fe5f32c..103fec955e2c 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_debugfs.c
@@ -158,15 +158,12 @@ static const struct file_operations debugfs_log_fops = {
 };
 
 /* create an entry under /vchiq/log for each log category */
-static int vchiq_debugfs_create_log_entries(struct dentry *top)
+static void vchiq_debugfs_create_log_entries(struct dentry *top)
 {
struct dentry *dir;
size_t i;
-   int ret = 0;
 
dir = debugfs_create_dir("log", vchiq_debugfs_top());
-   if (!dir)
-   return -ENOMEM;
debugfs_info.log_categories = dir;
 
for (i = 0; i < n_log_entries; i++) {
@@ -177,14 +174,8 @@ static int vchiq_debugfs_create_log_entries(struct dentry 
*top)
  debugfs_info.log_categories,
  levp,
  _log_fops);
-   if (!dir) {
-   ret = -ENOMEM;
-   break;
-   }
-
vchiq_debugfs_log_entries[i].dir = dir;
}
-   return ret;
 }
 
 static int debugfs_usecount_show(struct seq_file *f, void *offset)
@@ -268,43 +259,22 @@ static const struct file_operations debugfs_trace_fops = {
 };
 
 /* add an instance (process) to the debugfs entries */
-int vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
+void vchiq_debugfs_add_instance(VCHIQ_INSTANCE_T instance)
 {
char pidstr[16];
-   struct dentry *top, *use_count, *trace;
+   struct dentry *top;
struct dentry *clients = vchiq_clients_top();
 
snprintf(pidstr, sizeof(pidstr), "%d",
 vchiq_instance_get_pid(instance));
 
top = debugfs_create_dir(pidstr, clients);
-   if (!top)
-   goto fail_top;
-
-   use_count = debugfs_create_file("use_count",
-   0444, top,
-   instance,
-   _usecount_fops);
-   if (!use_count)
-   goto fail_use_count;
-
-   trace = debugfs_create_file("trace",
-   0644, top,
- 

[PATCH 07/13] staging: lustre: remove ldebugfs_register_stats() wrapper function

2018-05-29 Thread Greg Kroah-Hartman
It was just calling debugfs_create_file() so unwind things and just call
the real function instead.  This ends up saving a number of lines as
there was never any error handling happening anyway, so that all can be
removed as well.

Cc: Oleg Drokin 
Cc: Andreas Dilger 
Cc: James Simmons 
Cc: Ben Evans 
Cc: Quentin Bouget 
Cc: NeilBrown 
Cc: Arushi Singhal 
Cc: Arvind Yadav 
Cc: Patrick Farrell 
Cc: Aliaksei Karaliou 
Cc: Aastha Gupta 
Cc: Dafna Hirschfeld 
Cc: Mathias Rav 
Cc: "Gustavo A. R. Silva" 
Cc: Bob Glosman 
Cc: lustre-de...@lists.lustre.org
Signed-off-by: Greg Kroah-Hartman 
---
 .../lustre/lustre/include/lprocfs_status.h  |  4 +---
 drivers/staging/lustre/lustre/ldlm/ldlm_pool.c  |  4 ++--
 .../staging/lustre/lustre/llite/lproc_llite.c   | 13 +
 .../lustre/lustre/obdclass/lprocfs_status.c | 16 ++--
 .../staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 17 ++---
 5 files changed, 16 insertions(+), 38 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h 
b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index 9eac7dac8c7b..7aafe873cb39 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -447,9 +447,7 @@ void lprocfs_counter_init(struct lprocfs_stats *stats, int 
index,
  const char *units);
 struct obd_export;
 int lprocfs_exp_cleanup(struct obd_export *exp);
-int ldebugfs_register_stats(struct dentry *parent,
-   const char *name,
-   struct lprocfs_stats *stats);
+extern const struct file_operations lprocfs_stats_seq_fops;
 
 /* lprocfs_status.c */
 int ldebugfs_add_vars(struct dentry *parent,
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index 53b8f33e54b5..b83e93256cd1 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -627,8 +627,8 @@ static int ldlm_pool_debugfs_init(struct ldlm_pool *pl)
lprocfs_counter_init(pl->pl_stats, LDLM_POOL_TIMING_STAT,
 LPROCFS_CNTR_AVGMINMAX | LPROCFS_CNTR_STDDEV,
 "recalc_timing", "sec");
-   rc = ldebugfs_register_stats(pl->pl_debugfs_entry, "stats",
-pl->pl_stats);
+   debugfs_create_file("stats", 0644, pl->pl_debugfs_entry, pl->pl_stats,
+   _stats_seq_fops);
 
 out_free_name:
kfree(var_name);
diff --git a/drivers/staging/lustre/lustre/llite/lproc_llite.c 
b/drivers/staging/lustre/lustre/llite/lproc_llite.c
index 164fe4d6b6b8..2297a14f00ca 100644
--- a/drivers/staging/lustre/lustre/llite/lproc_llite.c
+++ b/drivers/staging/lustre/lustre/llite/lproc_llite.c
@@ -1209,10 +1209,9 @@ int ldebugfs_register_mountpoint(struct dentry *parent,
 (type & LPROCFS_CNTR_AVGMINMAX),
 llite_opcode_table[id].opname, ptr);
}
-   err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "stats",
- sbi->ll_stats);
-   if (err)
-   goto out;
+
+   debugfs_create_file("stats", 0644, sbi->ll_debugfs_entry, sbi->ll_stats,
+   _stats_seq_fops);
 
sbi->ll_ra_stats = lprocfs_alloc_stats(ARRAY_SIZE(ra_stat_string),
   LPROCFS_STATS_FLAG_NONE);
@@ -1225,10 +1224,8 @@ int ldebugfs_register_mountpoint(struct dentry *parent,
lprocfs_counter_init(sbi->ll_ra_stats, id, 0,
 ra_stat_string[id], "pages");
 
-   err = ldebugfs_register_stats(sbi->ll_debugfs_entry, "read_ahead_stats",
- sbi->ll_ra_stats);
-   if (err)
-   goto out;
+   debugfs_create_file("stats", 0644, sbi->ll_debugfs_entry,
+   sbi->ll_ra_stats, _stats_seq_fops);
 
err = ldebugfs_add_vars(sbi->ll_debugfs_entry,
lprocfs_llite_obd_vars, sb);
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c 
b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 68e85f46a146..089a3d74f3ea 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -1315,7 +1315,7 @@ static int lprocfs_stats_seq_open(struct inode *inode, 
struct file *file)
return 0;
 }
 
-static const struct file_operations lprocfs_stats_seq_fops = {
+const struct file_operations lprocfs_stats_seq_fops = {
.owner   = THIS_MODULE,
.open= lprocfs_stats_seq_open,
.read= seq_read,
@@ -1323,19 +1323,7 @@ static const struct file_operations 
lprocfs_stats_seq_fops = {
.llseek  = seq_lseek,
.release = lprocfs_seq_release,
 };
-
-int ldebugfs_register_stats(struct 

[PATCH 09/13] staging: lustre: remove ldebugfs_obd_seq_create() wrapper function

2018-05-29 Thread Greg Kroah-Hartman
It was just calling debugfs_create_file() so unwind things and just call
the real function instead.  This ends up saving a number of lines as
there was never any error handling happening anyway, so that all can be
removed as well.

Cc: Oleg Drokin 
Cc: Andreas Dilger 
Cc: James Simmons 
Cc: Quentin Bouget 
Cc: Ben Evans 
Cc: NeilBrown 
Cc: Arushi Singhal 
Cc: Arvind Yadav 
Cc: Julia Lawall 
Cc: Dafna Hirschfeld 
Cc: Mathias Rav 
Cc: "Gustavo A. R. Silva" 
Cc: Roman Storozhenko 
Cc: lustre-de...@lists.lustre.org
Signed-off-by: Greg Kroah-Hartman 
---
 .../lustre/lustre/include/lprocfs_status.h|  6 --
 .../lustre/lustre/obdclass/lprocfs_status.c   | 11 --
 drivers/staging/lustre/lustre/osc/lproc_osc.c | 10 +++--
 .../staging/lustre/lustre/osc/osc_internal.h  |  2 +-
 .../staging/lustre/lustre/ptlrpc/sec_lproc.c  | 21 ---
 5 files changed, 8 insertions(+), 42 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h 
b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index 54abcc2eaeb6..cc230c520189 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -465,12 +465,6 @@ int lprocfs_obd_setup(struct obd_device *obd, struct 
lprocfs_vars *list,
  const struct attribute_group *attrs);
 int lprocfs_obd_cleanup(struct obd_device *obd);
 
-int ldebugfs_obd_seq_create(struct obd_device *dev,
-   const char *name,
-   umode_t mode,
-   const struct file_operations *seq_fops,
-   void *data);
-
 /* Generic callbacks */
 
 int lprocfs_rd_uint(struct seq_file *m, void *data);
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c 
b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 6e0ea4e76a1b..6e306cafa95a 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -1538,17 +1538,6 @@ char *lprocfs_find_named_value(const char *buffer, const 
char *name,
 }
 EXPORT_SYMBOL(lprocfs_find_named_value);
 
-int ldebugfs_obd_seq_create(struct obd_device *dev,
-   const char *name,
-   umode_t mode,
-   const struct file_operations *seq_fops,
-   void *data)
-{
-   debugfs_create_file(name, mode, dev->obd_debugfs_entry, data, seq_fops);
-   return 0;
-}
-EXPORT_SYMBOL_GPL(ldebugfs_obd_seq_create);
-
 void lprocfs_oh_tally(struct obd_histogram *oh, unsigned int value)
 {
if (value >= OBD_HIST_MAX)
diff --git a/drivers/staging/lustre/lustre/osc/lproc_osc.c 
b/drivers/staging/lustre/lustre/osc/lproc_osc.c
index 31f49f3fca59..6a705bc5420c 100644
--- a/drivers/staging/lustre/lustre/osc/lproc_osc.c
+++ b/drivers/staging/lustre/lustre/osc/lproc_osc.c
@@ -801,16 +801,12 @@ static ssize_t osc_stats_seq_write(struct file *file,
 
 LPROC_SEQ_FOPS(osc_stats);
 
-int lproc_osc_attach_seqstat(struct obd_device *dev)
+void lproc_osc_attach_seqstat(struct obd_device *dev)
 {
-   int rc;
-
debugfs_create_file("osc_stats", 0644, dev->obd_debugfs_entry, dev,
_stats_fops);
-   rc = ldebugfs_obd_seq_create(dev, "rpc_stats", 0644,
-_rpc_stats_fops, dev);
-
-   return rc;
+   debugfs_create_file("rpc_stats", 0644, dev->obd_debugfs_entry, dev,
+   _rpc_stats_fops);
 }
 
 static struct attribute *osc_attrs[] = {
diff --git a/drivers/staging/lustre/lustre/osc/osc_internal.h 
b/drivers/staging/lustre/lustre/osc/osc_internal.h
index fca020568c19..4ddba1354bef 100644
--- a/drivers/staging/lustre/lustre/osc/osc_internal.h
+++ b/drivers/staging/lustre/lustre/osc/osc_internal.h
@@ -141,7 +141,7 @@ unsigned long osc_ldlm_weigh_ast(struct ldlm_lock *dlmlock);
 
 int osc_setup(struct obd_device *obd, struct lustre_cfg *lcfg);
 
-int lproc_osc_attach_seqstat(struct obd_device *dev);
+void lproc_osc_attach_seqstat(struct obd_device *dev);
 void lprocfs_osc_init_vars(struct lprocfs_static_vars *lvars);
 
 extern struct lu_device_type osc_device_type;
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c
index fd609b63d2de..cd1bb3dabb63 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec_lproc.c
@@ -133,8 +133,6 @@ LPROC_SEQ_FOPS_RO(sptlrpc_ctxs_lprocfs);
 
 int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
 {
-   int rc;
-
if (strcmp(dev->obd_type->typ_name, LUSTRE_OSC_NAME) != 0 &&
strcmp(dev->obd_type->typ_name, LUSTRE_MDC_NAME) != 0 &&
strcmp(dev->obd_type->typ_name, LUSTRE_MGC_NAME) != 0) {
@@ -143,21 +141,10 @@ int sptlrpc_lprocfs_cliobd_attach(struct obd_device *dev)
return -EINVAL;
}
 
-   rc = 

[PATCH 03/13] staging: unisys: visornic: no need to check debugfs return values

2018-05-29 Thread Greg Kroah-Hartman
When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Clean up the visornic driver code by not caring about the value of
debugfs calls.  This ends up removing a number of lines of code that are
not needed.

Cc: David Kershner 
Cc: Tim Sell 
Cc: David Binder 
Cc: Sameer Wadgaonkar 
Cc: Charles Daniels 
Cc: sparmaintai...@unisys.com
Signed-off-by: Greg Kroah-Hartman 
---
 .../staging/unisys/visornic/visornic_main.c   | 23 +--
 1 file changed, 6 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/unisys/visornic/visornic_main.c 
b/drivers/staging/unisys/visornic/visornic_main.c
index f734e835b382..3647b8f1ed28 100644
--- a/drivers/staging/unisys/visornic/visornic_main.c
+++ b/drivers/staging/unisys/visornic/visornic_main.c
@@ -2126,30 +2126,19 @@ static struct visor_driver visornic_driver = {
  */
 static int visornic_init(void)
 {
-   struct dentry *ret;
-   int err = -ENOMEM;
+   int err;
 
visornic_debugfs_dir = debugfs_create_dir("visornic", NULL);
-   if (!visornic_debugfs_dir)
-   return err;
 
-   ret = debugfs_create_file("info", 0400, visornic_debugfs_dir, NULL,
- _info_fops);
-   if (!ret)
-   goto cleanup_debugfs;
-   ret = debugfs_create_file("enable_ints", 0200, visornic_debugfs_dir,
- NULL, _enable_ints_fops);
-   if (!ret)
-   goto cleanup_debugfs;
+   debugfs_create_file("info", 0400, visornic_debugfs_dir, NULL,
+   _info_fops);
+   debugfs_create_file("enable_ints", 0200, visornic_debugfs_dir, NULL,
+   _enable_ints_fops);
 
err = visorbus_register_visor_driver(_driver);
if (err)
-   goto cleanup_debugfs;
+   debugfs_remove_recursive(visornic_debugfs_dir);
 
-   return 0;
-
-cleanup_debugfs:
-   debugfs_remove_recursive(visornic_debugfs_dir);
return err;
 }
 
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH 11/13] staging: lustre: remove last two users of ldebugfs_register()

2018-05-29 Thread Greg Kroah-Hartman
ldebugfs_register() is just a call to debugfs_create_dir() and
ldebugfs_add_vars() if the list option is set.  Fix up the last two
users of this function to just call these two functions instead, and
delete the now unused ldebugfs_register() call.

This ends up cleaning up more code and making things smaller, always a
good thing.

Cc: Oleg Drokin 
Cc: Andreas Dilger 
Cc: James Simmons 
Cc: NeilBrown 
Cc: Ben Evans 
Cc: Quentin Bouget 
Cc: Arvind Yadav 
Cc: Arushi Singhal 
Cc: Julia Lawall 
Cc: Mathias Rav 
Cc: Dafna Hirschfeld 
Cc: "Gustavo A. R. Silva" 
Cc: Patrick Farrell 
Cc: Nadav Amit 
Cc: lustre-de...@lists.lustre.org
Signed-off-by: Greg Kroah-Hartman 
---
 .../lustre/lustre/include/lprocfs_status.h|  5 ---
 .../lustre/lustre/obdclass/lprocfs_status.c   | 39 ++-
 .../lustre/lustre/ptlrpc/ptlrpc_internal.h|  2 +-
 drivers/staging/lustre/lustre/ptlrpc/sec.c|  6 +--
 .../staging/lustre/lustre/ptlrpc/sec_lproc.c  | 17 ++--
 5 files changed, 8 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h 
b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index cc230c520189..912c65b2f72b 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -454,11 +454,6 @@ int ldebugfs_add_vars(struct dentry *parent,
  struct lprocfs_vars *var,
  void *data);
 
-struct dentry *ldebugfs_register(const char *name,
-struct dentry *parent,
-struct lprocfs_vars *list,
-void *data);
-
 void ldebugfs_remove(struct dentry **entryp);
 
 int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c 
b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 6e306cafa95a..91af79facbc0 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -338,32 +338,6 @@ void ldebugfs_remove(struct dentry **entryp)
 }
 EXPORT_SYMBOL_GPL(ldebugfs_remove);
 
-struct dentry *ldebugfs_register(const char *name,
-struct dentry *parent,
-struct lprocfs_vars *list, void *data)
-{
-   struct dentry *entry;
-
-   entry = debugfs_create_dir(name, parent);
-   if (IS_ERR_OR_NULL(entry)) {
-   entry = entry ?: ERR_PTR(-ENOMEM);
-   goto out;
-   }
-
-   if (!IS_ERR_OR_NULL(list)) {
-   int rc;
-
-   rc = ldebugfs_add_vars(entry, list, data);
-   if (rc != 0) {
-   debugfs_remove(entry);
-   entry = ERR_PTR(rc);
-   }
-   }
-out:
-   return entry;
-}
-EXPORT_SYMBOL_GPL(ldebugfs_register);
-
 /* Generic callbacks */
 static ssize_t uuid_show(struct kobject *kobj, struct attribute *attr,
 char *buf)
@@ -1026,16 +1000,9 @@ int lprocfs_obd_setup(struct obd_device *obd, struct 
lprocfs_vars *list,
}
}
 
-   obd->obd_debugfs_entry = ldebugfs_register(obd->obd_name,
-  
obd->obd_type->typ_debugfs_entry,
-  list, obd);
-   if (IS_ERR_OR_NULL(obd->obd_debugfs_entry)) {
-   rc = obd->obd_debugfs_entry ? PTR_ERR(obd->obd_debugfs_entry)
-   : -ENOMEM;
-   CERROR("error %d setting up lprocfs for %s\n",
-  rc, obd->obd_name);
-   obd->obd_debugfs_entry = NULL;
-   }
+   obd->obd_debugfs_entry = debugfs_create_dir(obd->obd_name,
+   obd->obd_type->typ_debugfs_entry);
+   ldebugfs_add_vars(obd->obd_debugfs_entry, list, obd);
 
return rc;
 }
diff --git a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h 
b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
index b7a8d7537a66..134b74234519 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
+++ b/drivers/staging/lustre/lustre/ptlrpc/ptlrpc_internal.h
@@ -264,7 +264,7 @@ void sptlrpc_enc_pool_fini(void);
 int sptlrpc_proc_enc_pool_seq_show(struct seq_file *m, void *v);
 
 /* sec_lproc.c */
-int  sptlrpc_lproc_init(void);
+void sptlrpc_lproc_init(void);
 void sptlrpc_lproc_fini(void);
 
 /* sec_gc.c */
diff --git a/drivers/staging/lustre/lustre/ptlrpc/sec.c 
b/drivers/staging/lustre/lustre/ptlrpc/sec.c
index 256421465bcd..e193f3346e6f 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/sec.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/sec.c
@@ -2352,14 +2352,10 @@ int sptlrpc_init(void)
if (rc)
goto out_null;
 
-   rc = sptlrpc_lproc_init();
-   if (rc)
-   goto out_plain;
+   sptlrpc_lproc_init();
 
return 

[PATCH 13/13] staging: lustre: get rid of ldebugfs_remove()

2018-05-29 Thread Greg Kroah-Hartman
It was just a dumb wrapper around debugfs_remove_recursive() so just
call the function properly.  Also, there is no need to set the dentry to
NULL, it's gone, who cares about it anymore...

Cc: Oleg Drokin 
Cc: Andreas Dilger 
Cc: James Simmons 
Cc: NeilBrown 
Cc: Ingo Molnar 
Cc: Roman Storozhenko 
Cc: Aastha Gupta 
Cc: Ben Evans 
Cc: Quentin Bouget 
Cc: Arvind Yadav 
Cc: Arushi Singhal 
Cc: Patrick Farrell 
Cc: Aliaksei Karaliou 
Cc: Mathias Rav 
Cc: Andriy Skulysh 
Cc: Dafna Hirschfeld 
Cc: "Gustavo A. R. Silva" 
Cc: Bob Glosman 
Cc: lustre-de...@lists.lustre.org
Signed-off-by: Greg Kroah-Hartman 
---
 .../staging/lustre/lustre/fid/fid_request.c   |  6 ++
 .../staging/lustre/lustre/fld/fld_request.c   |  6 ++
 .../lustre/lustre/include/lprocfs_status.h|  2 --
 .../staging/lustre/lustre/ldlm/ldlm_pool.c|  5 +
 .../lustre/lustre/ldlm/ldlm_resource.c| 21 ---
 .../staging/lustre/lustre/llite/lproc_llite.c | 14 ++---
 drivers/staging/lustre/lustre/lov/lov_pool.c  |  4 ++--
 .../staging/lustre/lustre/obdclass/genops.c   |  3 +--
 .../lustre/lustre/obdclass/lprocfs_status.c   | 10 +
 .../lustre/lustre/ptlrpc/lproc_ptlrpc.c   |  6 ++
 .../staging/lustre/lustre/ptlrpc/sec_lproc.c  |  3 +--
 11 files changed, 22 insertions(+), 58 deletions(-)

diff --git a/drivers/staging/lustre/lustre/fid/fid_request.c 
b/drivers/staging/lustre/lustre/fid/fid_request.c
index bc748ab6645d..a34fd90ca5e5 100644
--- a/drivers/staging/lustre/lustre/fid/fid_request.c
+++ b/drivers/staging/lustre/lustre/fid/fid_request.c
@@ -291,8 +291,7 @@ EXPORT_SYMBOL(seq_client_flush);
 
 static void seq_client_debugfs_fini(struct lu_client_seq *seq)
 {
-   if (!IS_ERR_OR_NULL(seq->lcs_debugfs_entry))
-   ldebugfs_remove(>lcs_debugfs_entry);
+   debugfs_remove_recursive(seq->lcs_debugfs_entry);
 }
 
 static void seq_client_debugfs_init(struct lu_client_seq *seq)
@@ -399,8 +398,7 @@ static int __init fid_init(void)
 
 static void __exit fid_exit(void)
 {
-   if (!IS_ERR_OR_NULL(seq_debugfs_dir))
-   ldebugfs_remove(_debugfs_dir);
+   debugfs_remove_recursive(seq_debugfs_dir);
 }
 
 MODULE_AUTHOR("OpenSFS, Inc. ");
diff --git a/drivers/staging/lustre/lustre/fld/fld_request.c 
b/drivers/staging/lustre/lustre/fld/fld_request.c
index cb67fee19451..97f7ea632346 100644
--- a/drivers/staging/lustre/lustre/fld/fld_request.c
+++ b/drivers/staging/lustre/lustre/fld/fld_request.c
@@ -227,8 +227,7 @@ static void fld_client_debugfs_init(struct lu_client_fld 
*fld)
 
 void fld_client_debugfs_fini(struct lu_client_fld *fld)
 {
-   if (!IS_ERR_OR_NULL(fld->lcf_debugfs_entry))
-   ldebugfs_remove(>lcf_debugfs_entry);
+   debugfs_remove_recursive(fld->lcf_debugfs_entry);
 }
 EXPORT_SYMBOL(fld_client_debugfs_fini);
 
@@ -435,8 +434,7 @@ static int __init fld_init(void)
 
 static void __exit fld_exit(void)
 {
-   if (!IS_ERR_OR_NULL(fld_debugfs_dir))
-   ldebugfs_remove(_debugfs_dir);
+   debugfs_remove_recursive(fld_debugfs_dir);
 }
 
 MODULE_AUTHOR("OpenSFS, Inc. ");
diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h 
b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index b18bcb337504..495e6f5f676b 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -453,8 +453,6 @@ extern const struct file_operations lprocfs_stats_seq_fops;
 void ldebugfs_add_vars(struct dentry *parent, struct lprocfs_vars *var,
   void *data);
 
-void ldebugfs_remove(struct dentry **entryp);
-
 int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list,
  const struct attribute_group *attrs);
 int lprocfs_obd_cleanup(struct obd_device *obd);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index 146b348ca312..36d14ee4e5b1 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -640,10 +640,7 @@ static void ldlm_pool_debugfs_fini(struct ldlm_pool *pl)
lprocfs_free_stats(>pl_stats);
pl->pl_stats = NULL;
}
-   if (pl->pl_debugfs_entry) {
-   ldebugfs_remove(>pl_debugfs_entry);
-   pl->pl_debugfs_entry = NULL;
-   }
+   debugfs_remove_recursive(pl->pl_debugfs_entry);
 }
 
 int ldlm_pool_init(struct ldlm_pool *pl, struct ldlm_namespace *ns,
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c 
b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
index 6b94a2b2a0fc..c93b019b8e37 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_resource.c
@@ -121,18 +121,9 @@ void ldlm_debugfs_setup(void)
 
 void ldlm_debugfs_cleanup(void)
 {
-   if (!IS_ERR_OR_NULL(ldlm_svc_debugfs_dir))
-   

[PATCH 02/13] staging: rtlwifi: don't check the return value of debugfs_create_file

2018-05-29 Thread Greg Kroah-Hartman
We never did anything with the return value, and it does not matter if
the call succeeds or not (it's just debugging code), so don't even check
it.

Cc: Larry Finger 
Cc: Ping-Ke Shih 
Cc: Colin Ian King 
Cc: "Frank A. Cancio Bello" 
Cc: Nathan Chancellor 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/staging/rtlwifi/debug.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/rtlwifi/debug.c b/drivers/staging/rtlwifi/debug.c
index c041bc315616..9f04647ec3b0 100644
--- a/drivers/staging/rtlwifi/debug.c
+++ b/drivers/staging/rtlwifi/debug.c
@@ -519,12 +519,9 @@ static const struct file_operations file_ops_common_rw = {
 #define RTL_DEBUGFS_ADD_CORE(name, mode, fopname) \
do {   \
rtl_debug_priv_ ##name.rtlpriv = rtlpriv;  \
-   if (!debugfs_create_file(#name, mode,  \
-parent, _debug_priv_ ##name,  \
-_ops_ ##fopname))\
-   pr_err("Unable to initialize debugfs:%s/%s\n", \
-  rtlpriv->dbg.debugfs_name,  \
-  #name); \
+   debugfs_create_file(#name, mode, parent,   \
+   _debug_priv_ ##name,   \
+   _ops_ ##fopname); \
} while (0)
 
 #define RTL_DEBUGFS_ADD(name) \
-- 
2.17.0

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 17/25] staging: lustre: libcfs: rename cpumask_var_t variables to *_mask

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

Because we handle both cpu mask as well as core identifiers it can
easily be confused. To avoid this rename various cpumask_var_t to
have appended *_mask to their names.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata 
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. No changes in code from earlier patch

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 62 -
 1 file changed, 31 insertions(+), 31 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 1c10529..fb27dac 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -710,23 +710,23 @@ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
  * We always prefer to choose CPU in the same core/socket.
  */
 static int cfs_cpt_choose_ncpus(struct cfs_cpt_table *cptab, int cpt,
-   cpumask_t *node, int number)
+   cpumask_t *node_mask, int number)
 {
-   cpumask_var_t socket;
-   cpumask_var_t core;
+   cpumask_var_t socket_mask;
+   cpumask_var_t core_mask;
int rc = 0;
int cpu;
 
LASSERT(number > 0);
 
-   if (number >= cpumask_weight(node)) {
-   while (!cpumask_empty(node)) {
-   cpu = cpumask_first(node);
+   if (number >= cpumask_weight(node_mask)) {
+   while (!cpumask_empty(node_mask)) {
+   cpu = cpumask_first(node_mask);
 
rc = cfs_cpt_set_cpu(cptab, cpt, cpu);
if (!rc)
return -EINVAL;
-   cpumask_clear_cpu(cpu, node);
+   cpumask_clear_cpu(cpu, node_mask);
}
return 0;
}
@@ -736,34 +736,34 @@ static int cfs_cpt_choose_ncpus(struct cfs_cpt_table 
*cptab, int cpt,
 * As we cannot initialize a cpumask_var_t, we need
 * to alloc both before we can risk trying to free either
 */
-   if (!zalloc_cpumask_var(, GFP_NOFS))
+   if (!zalloc_cpumask_var(_mask, GFP_NOFS))
rc = -ENOMEM;
-   if (!zalloc_cpumask_var(, GFP_NOFS))
+   if (!zalloc_cpumask_var(_mask, GFP_NOFS))
rc = -ENOMEM;
if (rc)
goto out;
 
-   while (!cpumask_empty(node)) {
-   cpu = cpumask_first(node);
+   while (!cpumask_empty(node_mask)) {
+   cpu = cpumask_first(node_mask);
 
/* get cpumask for cores in the same socket */
-   cpumask_copy(socket, topology_core_cpumask(cpu));
-   cpumask_and(socket, socket, node);
+   cpumask_copy(socket_mask, topology_core_cpumask(cpu));
+   cpumask_and(socket_mask, socket_mask, node_mask);
 
-   LASSERT(!cpumask_empty(socket));
+   LASSERT(!cpumask_empty(socket_mask));
 
-   while (!cpumask_empty(socket)) {
+   while (!cpumask_empty(socket_mask)) {
int i;
 
/* get cpumask for hts in the same core */
-   cpumask_copy(core, topology_sibling_cpumask(cpu));
-   cpumask_and(core, core, node);
+   cpumask_copy(core_mask, topology_sibling_cpumask(cpu));
+   cpumask_and(core_mask, core_mask, node_mask);
 
-   LASSERT(!cpumask_empty(core));
+   LASSERT(!cpumask_empty(core_mask));
 
-   for_each_cpu(i, core) {
-   cpumask_clear_cpu(i, socket);
-   cpumask_clear_cpu(i, node);
+   for_each_cpu(i, core_mask) {
+   cpumask_clear_cpu(i, socket_mask);
+   cpumask_clear_cpu(i, node_mask);
 
rc = cfs_cpt_set_cpu(cptab, cpt, i);
if (!rc) {
@@ -774,13 +774,13 @@ static int cfs_cpt_choose_ncpus(struct cfs_cpt_table 
*cptab, int cpt,
if (!--number)
goto out;
}
-   cpu = cpumask_first(socket);
+   cpu = cpumask_first(socket_mask);
}
}
 
 out:
-   free_cpumask_var(socket);
-   free_cpumask_var(core);
+   free_cpumask_var(socket_mask);
+   free_cpumask_var(core_mask);
return rc;
 }
 
@@ -831,7 +831,7 @@ static int cfs_cpt_num_estimate(void)
 static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)
 {
struct cfs_cpt_table *cptab = NULL;
-   cpumask_var_t mask;
+   

[PATCH v2 25/25] staging: lustre: ptlrpc: use current CPU instead of hardcoded 0

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

fix crash if CPU 0 disabled.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8710
Reviewed-on: https://review.whamcloud.com/23305
Reviewed-by: Doug Oucharek 
Reviewed-by: Andreas Dilger 
Signed-off-by: James Simmons 
---
Changelog:

v1) New patch to address crash in ptlrpc

 drivers/staging/lustre/lustre/ptlrpc/service.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/service.c 
b/drivers/staging/lustre/lustre/ptlrpc/service.c
index 3fd8c74..8e74a45 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/service.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/service.c
@@ -421,7 +421,7 @@ static void ptlrpc_at_timer(struct timer_list *t)
 * there are.
 */
/* weight is # of HTs */
-   if (cpumask_weight(topology_sibling_cpumask(0)) > 1) {
+   if 
(cpumask_weight(topology_sibling_cpumask(smp_processor_id())) > 1) {
/* depress thread factor for hyper-thread */
factor = factor - (factor >> 1) + (factor >> 3);
}
@@ -2221,15 +2221,16 @@ static int ptlrpc_hr_main(void *arg)
struct ptlrpc_hr_thread *hrt = arg;
struct ptlrpc_hr_partition *hrp = hrt->hrt_partition;
LIST_HEAD(replies);
-   char threadname[20];
int rc;
 
-   snprintf(threadname, sizeof(threadname), "ptlrpc_hr%02d_%03d",
-hrp->hrp_cpt, hrt->hrt_id);
unshare_fs_struct();
 
rc = cfs_cpt_bind(ptlrpc_hr.hr_cpt_table, hrp->hrp_cpt);
if (rc != 0) {
+   char threadname[20];
+
+   snprintf(threadname, sizeof(threadname), "ptlrpc_hr%02d_%03d",
+hrp->hrp_cpt, hrt->hrt_id);
CWARN("Failed to bind %s on CPT %d of CPT table %p: rc = %d\n",
  threadname, hrp->hrp_cpt, ptlrpc_hr.hr_cpt_table, rc);
}
@@ -2528,7 +2529,7 @@ int ptlrpc_hr_init(void)
 
init_waitqueue_head(_hr.hr_waitq);
 
-   weight = cpumask_weight(topology_sibling_cpumask(0));
+   weight = cpumask_weight(topology_sibling_cpumask(smp_processor_id()));
 
cfs_percpt_for_each(hrp, i, ptlrpc_hr.hr_partitions) {
hrp->hrp_cpt = i;
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 19/25] staging: lustre: libcfs: update debug messages

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

For cfs_cpt_bind() change the CERROR to CDEBUG. Make the debug
message in cfs_cpt_table_create_pattern() more understandable.
Report rc value for when cfs_cpt_create_table() fails.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata 
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. No changes in code from earlier patch

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 15 +--
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index e12d337..7f1061e 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -480,7 +480,8 @@ void cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int 
cpt, int cpu)
/* caller doesn't know the partition ID */
cpt = cptab->ctb_cpu2cpt[cpu];
if (cpt < 0) { /* not set in this CPT-table */
-   CDEBUG(D_INFO, "Try to unset cpu %d which is not in 
CPT-table %p\n",
+   CDEBUG(D_INFO,
+  "Try to unset cpu %d which is not in CPT-table 
%p\n",
   cpt, cptab);
return;
}
@@ -506,7 +507,8 @@ int cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int 
cpt,
 
if (!cpumask_weight(mask) ||
cpumask_any_and(mask, cpu_online_mask) >= nr_cpu_ids) {
-   CDEBUG(D_INFO, "No online CPU is found in the CPU mask for CPU 
partition %d\n",
+   CDEBUG(D_INFO,
+  "No online CPU is found in the CPU mask for CPU 
partition %d\n",
   cpt);
return 0;
}
@@ -683,7 +685,8 @@ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
}
 
if (cpumask_any_and(*cpumask, cpu_online_mask) >= nr_cpu_ids) {
-   CERROR("No online CPU found in CPU partition %d, did someone do 
CPU hotplug on system? You might need to reload Lustre modules to keep system 
working well.\n",
+   CDEBUG(D_INFO,
+  "No online CPU found in CPU partition %d, did someone do 
CPU hotplug on system? You might need to reload Lustre modules to keep system 
working well.\n",
   cpt);
return -EINVAL;
}
@@ -914,8 +917,8 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)
 failed_mask:
free_cpumask_var(node_mask);
 failed:
-   CERROR("Failed to setup CPU-partition-table with %d CPU-partitions, 
online HW nodes: %d, HW cpus: %d.\n",
-  ncpt, num_online_nodes(), num_online_cpus());
+   CERROR("Failed (rc = %d) to setup CPU partition table with %d 
partitions, online HW NUMA nodes: %d, HW CPU cores: %d.\n",
+  rc, ncpt, num_online_nodes(), num_online_cpus());
 
if (cptab)
cfs_cpt_table_free(cptab);
@@ -1030,7 +1033,7 @@ static struct cfs_cpt_table 
*cfs_cpt_table_create_pattern(char *pattern)
 
bracket = strchr(str, ']');
if (!bracket) {
-   CERROR("missing right bracket for cpt %d, %s\n",
+   CERROR("Missing right bracket for partition %d, %s\n",
   cpt, str);
goto failed;
}
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 20/25] staging: lustre: libcfs: make tolerant to offline CPUs and empty NUMA nodes

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

Rework CPU partition code in the way of make it more tolerant to
offline CPUs and empty nodes.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata 
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. No changes in code from earlier patch

 .../lustre/include/linux/libcfs/libcfs_cpu.h   |   2 +
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c| 132 +
 drivers/staging/lustre/lnet/lnet/lib-msg.c |   2 +
 3 files changed, 60 insertions(+), 76 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 9f4ba9d..c0aa0b3 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -91,6 +91,8 @@ struct cfs_cpu_partition {
unsigned int*cpt_distance;
/* spread rotor for NUMA allocator */
int cpt_spread_rotor;
+   /* NUMA node if cpt_nodemask is empty */
+   int cpt_node;
 };
 #endif /* CONFIG_SMP */
 
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 7f1061e..99a9494 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -457,8 +457,16 @@ int cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, 
int cpu)
return 0;
}
 
-   LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_cpumask));
-   LASSERT(!cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask));
+   if (cpumask_test_cpu(cpu, cptab->ctb_cpumask)) {
+   CDEBUG(D_INFO, "CPU %d is already in cpumask\n", cpu);
+   return 0;
+   }
+
+   if (cpumask_test_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask)) {
+   CDEBUG(D_INFO, "CPU %d is already in partition %d cpumask\n",
+  cpu, cptab->ctb_cpu2cpt[cpu]);
+   return 0;
+   }
 
cfs_cpt_add_cpu(cptab, cpt, cpu);
cfs_cpt_add_node(cptab, cpt, cpu_to_node(cpu));
@@ -527,8 +535,10 @@ void cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, 
int cpt,
 {
int cpu;
 
-   for_each_cpu(cpu, mask)
-   cfs_cpt_unset_cpu(cptab, cpt, cpu);
+   for_each_cpu(cpu, mask) {
+   cfs_cpt_del_cpu(cptab, cpt, cpu);
+   cfs_cpt_del_node(cptab, cpt, cpu_to_node(cpu));
+   }
 }
 EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
 
@@ -579,10 +589,8 @@ int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int 
cpt,
 {
int node;
 
-   for_each_node_mask(node, *mask) {
-   if (!cfs_cpt_set_node(cptab, cpt, node))
-   return 0;
-   }
+   for_each_node_mask(node, *mask)
+   cfs_cpt_set_node(cptab, cpt, node);
 
return 1;
 }
@@ -603,7 +611,7 @@ int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int 
cpt)
nodemask_t *mask;
int weight;
int rotor;
-   int node;
+   int node = 0;
 
/* convert CPU partition ID to HW node id */
 
@@ -613,20 +621,20 @@ int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int 
cpt)
} else {
mask = cptab->ctb_parts[cpt].cpt_nodemask;
rotor = cptab->ctb_parts[cpt].cpt_spread_rotor++;
+   node  = cptab->ctb_parts[cpt].cpt_node;
}
 
weight = nodes_weight(*mask);
-   LASSERT(weight > 0);
-
-   rotor %= weight;
+   if (weight > 0) {
+   rotor %= weight;
 
-   for_each_node_mask(node, *mask) {
-   if (!rotor--)
-   return node;
+   for_each_node_mask(node, *mask) {
+   if (!rotor--)
+   return node;
+   }
}
 
-   LBUG();
-   return 0;
+   return node;
 }
 EXPORT_SYMBOL(cfs_cpt_spread_node);
 
@@ -719,17 +727,21 @@ static int cfs_cpt_choose_ncpus(struct cfs_cpt_table 
*cptab, int cpt,
cpumask_var_t core_mask;
int rc = 0;
int cpu;
+   int i;
 
LASSERT(number > 0);
 
if (number >= cpumask_weight(node_mask)) {
while (!cpumask_empty(node_mask)) {
cpu = cpumask_first(node_mask);
+   cpumask_clear_cpu(cpu, node_mask);
+
+   if (!cpu_online(cpu))
+   continue;
 
rc = cfs_cpt_set_cpu(cptab, cpt, cpu);
if (!rc)
return -EINVAL;
-   cpumask_clear_cpu(cpu, node_mask);
}
return 0;
}
@@ -750,24 +762,19 @@ static int 

[PATCH v2 23/25] staging: lustre: libcfs: rework CPU pattern parsing code

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

Currently the module param string for CPU pattern can be
modified which is wrong. Rewrite CPU pattern parsing code
to avoid the passed buffer from being changed. This change
also enables us to add real errors propogation to the caller
functions.

Signed-off-by: Dmitry Eremin 
Signed-off-by: Amir Shehata 
Signed-off-by: Andreas Dilger 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23306
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9715
Reviewed-on: https://review.whamcloud.com/27872
Reviewed-by: James Simmons 
Reviewed-by: Andreas Dilger 
Reviewed-by: Patrick Farrell 
Reviewed-by: Olaf Weber 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. No changes in code from earlier patch

 .../lustre/include/linux/libcfs/libcfs_cpu.h   |   2 +-
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c| 146 -
 2 files changed, 87 insertions(+), 61 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index c0aa0b3..12ed0a9 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -393,7 +393,7 @@ static inline int cfs_cpu_init(void)
 
 static inline void cfs_cpu_fini(void)
 {
-   if (cfs_cpt_tab) {
+   if (!IS_ERR_OR_NULL(cfs_cpt_tab)) {
cfs_cpt_table_free(cfs_cpt_tab);
cfs_cpt_tab = NULL;
}
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 649f7f9..aed48de 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -692,11 +692,11 @@ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
nodemask = cptab->ctb_parts[cpt].cpt_nodemask;
}
 
-   if (cpumask_any_and(*cpumask, cpu_online_mask) >= nr_cpu_ids) {
+   if (!cpumask_intersects(*cpumask, cpu_online_mask)) {
CDEBUG(D_INFO,
   "No online CPU found in CPU partition %d, did someone do 
CPU hotplug on system? You might need to reload Lustre modules to keep system 
working well.\n",
   cpt);
-   return -EINVAL;
+   return -ENODEV;
}
 
for_each_online_cpu(cpu) {
@@ -860,11 +860,13 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int 
ncpt)
cptab = cfs_cpt_table_alloc(ncpt);
if (!cptab) {
CERROR("Failed to allocate CPU map(%d)\n", ncpt);
+   rc = -ENOMEM;
goto failed;
}
 
if (!zalloc_cpumask_var(_mask, GFP_NOFS)) {
CERROR("Failed to allocate scratch cpumask\n");
+   rc = -ENOMEM;
goto failed;
}
 
@@ -879,8 +881,10 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int ncpt)
 
rc = cfs_cpt_choose_ncpus(cptab, cpt, node_mask,
  num - ncpu);
-   if (rc < 0)
+   if (rc < 0) {
+   rc = -EINVAL;
goto failed_mask;
+   }
 
ncpu = cpumask_weight(part->cpt_cpumask);
if (ncpu == num + !!(rem > 0)) {
@@ -903,37 +907,51 @@ static struct cfs_cpt_table *cfs_cpt_table_create(int 
ncpt)
if (cptab)
cfs_cpt_table_free(cptab);
 
-   return NULL;
+   return ERR_PTR(rc);
 }
 
-static struct cfs_cpt_table *cfs_cpt_table_create_pattern(char *pattern)
+static struct cfs_cpt_table *cfs_cpt_table_create_pattern(const char *pattern)
 {
struct cfs_cpt_table *cptab;
+   char *pattern_dup;
+   char *bracket;
char *str;
int node = 0;
-   int high;
int ncpt = 0;
-   int cpt;
+   int cpt = 0;
+   int high;
int rc;
int c;
int i;
 
-   str = strim(pattern);
+   pattern_dup = kstrdup(pattern, GFP_KERNEL);
+   if (!pattern_dup) {
+   CERROR("Failed to duplicate pattern '%s'\n", pattern);
+   return ERR_PTR(-ENOMEM);
+   }
+
+   str = strim(pattern_dup);
if (*str == 'n' || *str == 'N') {
-   pattern = str + 1;
-   if (*pattern != '\0') {
-   node = 1;
-   } else { /* shortcut to create CPT from NUMA & CPU topology */
+   str++; /* skip 'N' char */
+   node = 1; /* NUMA pattern */
+   if (*str == '\0') {
node = -1;
-   ncpt = num_online_nodes();
+   for_each_online_node(i) {
+   if (!cpumask_empty(cpumask_of_node(i)))
+   ncpt++;
+ 

[PATCH v2 24/25] staging: lustre: libcfs: change CPT estimate algorithm

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

The main idea to have more CPU partitions is based on KNL experience.
When a thread submit IO for network communication one of threads from
current CPT is used for network stack. Whith high parallelization many
threads become involved in network submission but having less CPU
partitions they will wait until single thread process them from network
queue. So, the bottleneck just moves into network layer in case of
small amount of CPU partitions. My experiments showed that the best
performance was when for each IO thread we have one network thread.
This condition can be provided having 2 real HW cores (without hyper
threads) per CPT. This is exactly what implemented in this patch.

Change CPT estimate algorithm from 2 * (N - 1)^2 < NCPUS <= 2 * N^2
to 2 HW cores per CPT. This is critical for machines with number of
cores different from 2^N.

Current algorithm splits CPTs in KNL:
LNet: HW CPU cores: 272, npartitions: 16
cpu_partition_table=
0   : 0-4,68-71,136-139,204-207
1   : 5-9,73-76,141-144,209-212
2   : 10-14,78-81,146-149,214-217
3   : 15-17,72,77,83-85,140,145,151-153,208,219-221
4   : 18-21,82,86-88,150,154-156,213,218,222-224
5   : 22-26,90-93,158-161,226-229
6   : 27-31,95-98,163-166,231-234
7   : 32-35,89,100-103,168-171,236-239
8   : 36-38,94,99,104-105,157,162,167,172-173,225,230,235,240-241
9   : 39-43,107-110,175-178,243-246
10  : 44-48,112-115,180-183,248-251
11  : 49-51,106,111,117-119,174,179,185-187,242,253-255
12  : 52-55,116,120-122,184,188-190,247,252,256-258
13  : 56-60,124-127,192-195,260-263
14  : 61-65,129-132,197-200,265-268
15  : 66-67,123,128,133-135,191,196,201-203,259,264,269-271

New algorithm will split CPTs in KNL:
LNet: HW CPU cores: 272, npartitions: 34
cpu_partition_table=
0   : 0-1,68-69,136-137,204-205
1   : 2-3,70-71,138-139,206-207
2   : 4-5,72-73,140-141,208-209
3   : 6-7,74-75,142-143,210-211
4   : 8-9,76-77,144-145,212-213
5   : 10-11,78-79,146-147,214-215
6   : 12-13,80-81,148-149,216-217
7   : 14-15,82-83,150-151,218-219
8   : 16-17,84-85,152-153,220-221
9   : 18-19,86-87,154-155,222-223
10  : 20-21,88-89,156-157,224-225
11  : 22-23,90-91,158-159,226-227
12  : 24-25,92-93,160-161,228-229
13  : 26-27,94-95,162-163,230-231
14  : 28-29,96-97,164-165,232-233
15  : 30-31,98-99,166-167,234-235
16  : 32-33,100-101,168-169,236-237
17  : 34-35,102-103,170-171,238-239
18  : 36-37,104-105,172-173,240-241
19  : 38-39,106-107,174-175,242-243
20  : 40-41,108-109,176-177,244-245
21  : 42-43,110-111,178-179,246-247
22  : 44-45,112-113,180-181,248-249
23  : 46-47,114-115,182-183,250-251
24  : 48-49,116-117,184-185,252-253
25  : 50-51,118-119,186-187,254-255
26  : 52-53,120-121,188-189,256-257
27  : 54-55,122-123,190-191,258-259
28  : 56-57,124-125,192-193,260-261
29  : 58-59,126-127,194-195,262-263
30  : 60-61,128-129,196-197,264-265
31  : 62-63,130-131,198-199,266-267
32  : 64-65,132-133,200-201,268-269
33  : 66-67,134-135,202-203,270-271

'N' pattern in KNL works is not always good.
in flat mode it will be one CPT with all CPUs inside.

in SNC-4 mode:
cpu_partition_table=
0   : 0-17,68-85,136-153,204-221
1   : 18-35,86-103,154-171,222-239
2   : 36-51,104-119,172-187,240-255
3   : 52-67,120-135,188-203,256-271

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/24304
Reviewed-by: James Simmons 
Reviewed-by: Andreas Dilger 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. No changes in code from earlier patch

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 30 +
 1 file changed, 5 insertions(+), 25 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index aed48de..ff752d5 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -798,34 +798,14 @@ static int cfs_cpt_choose_ncpus(struct cfs_cpt_table 
*cptab, int cpt,
 
 static int cfs_cpt_num_estimate(void)
 {
-   int nnode = num_online_nodes();
+   int nthr = cpumask_weight(topology_sibling_cpumask(smp_processor_id()));
int ncpu = num_online_cpus();
-   int ncpt;
+   int ncpt = 1;
 
-   if (ncpu <= CPT_WEIGHT_MIN) {
-   ncpt = 1;
-   goto out;
-   }
-
-   /* generate reasonable number of CPU partitions based on total number
-* of CPUs, Preferred N should be power2 and match this condition:
-* 2 * (N - 1)^2 < NCPUS 

[PATCH v2 22/25] staging: lustre: libcfs: update debug messages in CPT code

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

Update the debug messages for the CPT table creation code. Place
the passed in string in quotes to make it clear what it is.
Captialize cpu in the debug strings.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23306
Reviewed-by: James Simmons 
Reviewed-by: Andreas Dilger 
Reviewed-by: Patrick Farrell 
Reviewed-by: Olaf Weber 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. No changes in code from earlier patch

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 0fc102c..649f7f9 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -496,7 +496,7 @@ void cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int 
cpt, int cpu)
 
} else if (cpt != cptab->ctb_cpu2cpt[cpu]) {
CDEBUG(D_INFO,
-  "CPU %d is not in cpu-partition %d\n", cpu, cpt);
+  "CPU %d is not in CPU partition %d\n", cpu, cpt);
return;
}
 
@@ -940,14 +940,14 @@ static struct cfs_cpt_table 
*cfs_cpt_table_create_pattern(char *pattern)
if (!ncpt ||
(node && ncpt > num_online_nodes()) ||
(!node && ncpt > num_online_cpus())) {
-   CERROR("Invalid pattern %s, or too many partitions %d\n",
+   CERROR("Invalid pattern '%s', or too many partitions %d\n",
   pattern, ncpt);
return NULL;
}
 
cptab = cfs_cpt_table_alloc(ncpt);
if (!cptab) {
-   CERROR("Failed to allocate cpu partition table\n");
+   CERROR("Failed to allocate CPU partition table\n");
return NULL;
}
 
@@ -978,11 +978,11 @@ static struct cfs_cpt_table 
*cfs_cpt_table_create_pattern(char *pattern)
 
if (!bracket) {
if (*str) {
-   CERROR("Invalid pattern %s\n", str);
+   CERROR("Invalid pattern '%s'\n", str);
goto failed;
}
if (c != ncpt) {
-   CERROR("expect %d partitions but found %d\n",
+   CERROR("Expect %d partitions but found %d\n",
   ncpt, c);
goto failed;
}
@@ -990,7 +990,7 @@ static struct cfs_cpt_table 
*cfs_cpt_table_create_pattern(char *pattern)
}
 
if (sscanf(str, "%d%n", , ) < 1) {
-   CERROR("Invalid cpu pattern %s\n", str);
+   CERROR("Invalid CPU pattern '%s'\n", str);
goto failed;
}
 
@@ -1007,20 +1007,20 @@ static struct cfs_cpt_table 
*cfs_cpt_table_create_pattern(char *pattern)
 
str = strim(str + n);
if (str != bracket) {
-   CERROR("Invalid pattern %s\n", str);
+   CERROR("Invalid pattern '%s'\n", str);
goto failed;
}
 
bracket = strchr(str, ']');
if (!bracket) {
-   CERROR("Missing right bracket for partition %d, %s\n",
+   CERROR("Missing right bracket for partition %d in 
'%s'\n",
   cpt, str);
goto failed;
}
 
if (cfs_expr_list_parse(str, (bracket - str) + 1,
0, high, )) {
-   CERROR("Can't parse number range: %s\n", str);
+   CERROR("Can't parse number range in '%s'\n", str);
goto failed;
}
 
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 18/25] staging: lustre: libcfs: rename goto label in cfs_cpt_table_print

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

Change goto label out to err.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata 
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. No changes in code from earlier patch

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index fb27dac..e12d337 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -193,20 +193,20 @@ int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char 
*buf, int len)
 
for (i = 0; i < cptab->ctb_nparts; i++) {
if (len <= 0)
-   goto out;
+   goto err;
 
rc = snprintf(tmp, len, "%d\t:", i);
len -= rc;
 
if (len <= 0)
-   goto out;
+   goto err;
 
tmp += rc;
for_each_cpu(j, cptab->ctb_parts[i].cpt_cpumask) {
rc = snprintf(tmp, len, "%d ", j);
len -= rc;
if (len <= 0)
-   goto out;
+   goto err;
tmp += rc;
}
 
@@ -216,7 +216,7 @@ int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char 
*buf, int len)
}
 
return tmp - buf;
-out:
+err:
return -E2BIG;
 }
 EXPORT_SYMBOL(cfs_cpt_table_print);
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 13/25] staging: lustre: libcfs: fix libcfs_cpu coding style

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

This patch bring the lustre CPT code into alignment with the
Linux kernel coding style.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23304
Reviewed-by: James Simmons 
Reviewed-by: Doug Oucharek 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch to handle recent libcfs changes

 .../lustre/include/linux/libcfs/libcfs_cpu.h   | 76 --
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c| 92 --
 2 files changed, 66 insertions(+), 102 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index d5237d0..2c97adf 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -144,8 +144,7 @@ struct cfs_cpt_table {
 /**
  * return total number of CPU partitions in \a cptab
  */
-int
-cfs_cpt_number(struct cfs_cpt_table *cptab);
+int cfs_cpt_number(struct cfs_cpt_table *cptab);
 /**
  * return number of HW cores or hyper-threadings in a CPU partition \a cpt
  */
@@ -207,25 +206,24 @@ void cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab,
  * remove all cpus in NUMA node \a node from CPU partition \a cpt
  */
 void cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node);
-
 /**
  * add all cpus in node mask \a mask to CPU partition \a cpt
  * return 1 if successfully set all CPUs, otherwise return 0
  */
 int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab,
-int cpt, nodemask_t *mask);
+int cpt, const nodemask_t *mask);
 /**
  * remove all cpus in node mask \a mask from CPU partition \a cpt
  */
 void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab,
-   int cpt, nodemask_t *mask);
+   int cpt, const nodemask_t *mask);
 /**
  * convert partition id \a cpt to numa node id, if there are more than one
  * nodes in this partition, it might return a different node id each time.
  */
 int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt);
 
-int  cfs_cpu_init(void);
+int cfs_cpu_init(void);
 void cfs_cpu_fini(void);
 
 #else /* !CONFIG_SMP */
@@ -282,32 +280,29 @@ static inline int cfs_cpt_distance_print(struct 
cfs_cpt_table *cptab,
return rc;
 }
 
-static inline cpumask_var_t *
-cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
+static inline cpumask_var_t *cfs_cpt_cpumask(struct cfs_cpt_table *cptab,
+int cpt)
 {
return >ctb_cpumask;
 }
 
-static inline int
-cfs_cpt_number(struct cfs_cpt_table *cptab)
+static inline int cfs_cpt_number(struct cfs_cpt_table *cptab)
 {
return 1;
 }
 
-static inline int
-cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
+static inline int cfs_cpt_weight(struct cfs_cpt_table *cptab, int cpt)
 {
return 1;
 }
 
-static inline int
-cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
+static inline int cfs_cpt_online(struct cfs_cpt_table *cptab, int cpt)
 {
return 1;
 }
 
-static inline nodemask_t *
-cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt)
+static inline nodemask_t *cfs_cpt_nodemask(struct cfs_cpt_table *cptab,
+  int cpt)
 {
return >ctb_nodemask;
 }
@@ -318,66 +313,61 @@ static inline unsigned int cfs_cpt_distance(struct 
cfs_cpt_table *cptab,
return 1;
 }
 
-static inline int
-cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
+static inline int cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt,
+ int cpu)
 {
return 1;
 }
 
-static inline void
-cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
+static inline void cfs_cpt_unset_cpu(struct cfs_cpt_table *cptab, int cpt,
+int cpu)
 {
 }
 
-static inline int
-cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt,
-   const cpumask_t *mask)
+static inline int cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt,
+ const cpumask_t *mask)
 {
return 1;
 }
 
-static inline void
-cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt,
- const cpumask_t *mask)
+static inline void cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt,
+const cpumask_t *mask)
 {
 }
 
-static inline int
-cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt, int node)
+static inline int cfs_cpt_set_node(struct cfs_cpt_table *cptab, int cpt,
+  int node)
 {
return 1;
 }
 
-static inline void
-cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt, int node)
+static inline void cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int cpt,
+  

[PATCH v2 16/25] staging: lustre: libcfs: rename i to cpu for cfs_cpt_bind

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

Rename variable i to cpu to make code easier to understand.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata 
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. No changes in code

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index bac5601..1c10529 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -669,8 +669,8 @@ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
 {
cpumask_var_t *cpumask;
nodemask_t *nodemask;
+   int cpu;
int rc;
-   int i;
 
LASSERT(cpt == CFS_CPT_ANY || (cpt >= 0 && cpt < cptab->ctb_nparts));
 
@@ -688,8 +688,8 @@ int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
return -EINVAL;
}
 
-   for_each_online_cpu(i) {
-   if (cpumask_test_cpu(i, *cpumask))
+   for_each_online_cpu(cpu) {
+   if (cpumask_test_cpu(cpu, *cpumask))
continue;
 
rc = set_cpus_allowed_ptr(current, *cpumask);
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 15/25] staging: lustre: libcfs: rename i to node for cfs_cpt_set_nodemask

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

Rename variable i to node to make code easier to understand.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23222
Reviewed-by: Amir Shehata 
Reviewed-by: James Simmons 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. No changes in code

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 14d5791..bac5601 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -575,10 +575,10 @@ void cfs_cpt_unset_node(struct cfs_cpt_table *cptab, int 
cpt, int node)
 int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int cpt,
 const nodemask_t *mask)
 {
-   int i;
+   int node;
 
-   for_each_node_mask(i, *mask) {
-   if (!cfs_cpt_set_node(cptab, cpt, i))
+   for_each_node_mask(node, *mask) {
+   if (!cfs_cpt_set_node(cptab, cpt, node))
return 0;
}
 
@@ -589,10 +589,10 @@ int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab, int 
cpt,
 void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab, int cpt,
const nodemask_t *mask)
 {
-   int i;
+   int node;
 
-   for_each_node_mask(i, *mask)
-   cfs_cpt_unset_node(cptab, cpt, i);
+   for_each_node_mask(node, *mask)
+   cfs_cpt_unset_node(cptab, cpt, node);
 }
 EXPORT_SYMBOL(cfs_cpt_unset_nodemask);
 
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 21/25] staging: lustre: libcfs: report NUMA node instead of just node

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

Reporting "HW nodes" is too generic. It really is reporting
"HW NUMA nodes". Update the debug message.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23306
Reviewed-by: James Simmons 
Reviewed-by: Andreas Dilger 
Reviewed-by: Patrick Farrell 
Reviewed-by: Olaf Weber 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. No changes in code from earlier patch

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 99a9494..0fc102c 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -1138,7 +1138,7 @@ int cfs_cpu_init(void)
 
put_online_cpus();
 
-   LCONSOLE(0, "HW nodes: %d, HW CPU cores: %d, npartitions: %d\n",
+   LCONSOLE(0, "HW NUMA nodes: %d, HW CPU cores: %d, npartitions: %d\n",
 num_online_nodes(), num_online_cpus(),
 cfs_cpt_number(cfs_cpt_tab));
return 0;
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 08/25] staging: lustre: libcfs: NUMA support

2018-05-29 Thread James Simmons
From: Amir Shehata 

This patch adds NUMA node support. NUMA node information is stored
in the CPT table. A NUMA node mask is maintained for the entire
table as well as for each CPT to track the NUMA nodes related to
each of the CPTs. Add new function cfs_cpt_of_node() which returns
the CPT of a particular NUMA node.

Signed-off-by: Amir Shehata 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber 
Reviewed-by: Doug Oucharek 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch to handle recent libcfs changes

 .../lustre/include/linux/libcfs/libcfs_cpu.h| 11 +++
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 21 +
 2 files changed, 32 insertions(+)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 3626969..487625d 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -103,6 +103,8 @@ struct cfs_cpt_table {
struct cfs_cpu_partition*ctb_parts;
/* shadow HW CPU to CPU partition ID */
int *ctb_cpu2cpt;
+   /* shadow HW node to CPU partition ID */
+   int *ctb_node2cpt;
/* all nodes in this partition table */
nodemask_t  *ctb_nodemask;
 #else
@@ -157,6 +159,10 @@ struct cfs_cpt_table {
  */
 int cfs_cpt_of_cpu(struct cfs_cpt_table *cptab, int cpu);
 /**
+ * shadow HW node ID \a NODE to CPU-partition ID by \a cptab
+ */
+int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node);
+/**
  * bind current thread on a CPU-partition \a cpt of \a cptab
  */
 int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt);
@@ -345,6 +351,11 @@ static inline int cfs_cpt_table_print(struct cfs_cpt_table 
*cptab,
return 0;
 }
 
+static inline int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node)
+{
+   return 0;
+}
+
 static inline int
 cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
 {
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 3f855a8..f616073 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -98,6 +98,15 @@ struct cfs_cpt_table *
memset(cptab->ctb_cpu2cpt, -1,
   nr_cpu_ids * sizeof(cptab->ctb_cpu2cpt[0]));
 
+   cptab->ctb_node2cpt = kvmalloc_array(nr_node_ids,
+sizeof(cptab->ctb_node2cpt[0]),
+GFP_KERNEL);
+   if (!cptab->ctb_node2cpt)
+   goto failed_alloc_node2cpt;
+
+   memset(cptab->ctb_node2cpt, -1,
+  nr_node_ids * sizeof(cptab->ctb_node2cpt[0]));
+
cptab->ctb_parts = kvmalloc_array(ncpt, sizeof(cptab->ctb_parts[0]),
  GFP_KERNEL);
if (!cptab->ctb_parts)
@@ -129,6 +138,8 @@ struct cfs_cpt_table *
 
kvfree(cptab->ctb_parts);
 failed_alloc_ctb_parts:
+   kvfree(cptab->ctb_node2cpt);
+failed_alloc_node2cpt:
kvfree(cptab->ctb_cpu2cpt);
 failed_alloc_cpu2cpt:
kfree(cptab->ctb_nodemask);
@@ -146,6 +157,7 @@ struct cfs_cpt_table *
int i;
 
kvfree(cptab->ctb_cpu2cpt);
+   kvfree(cptab->ctb_node2cpt);
 
for (i = 0; cptab->ctb_parts && i < cptab->ctb_nparts; i++) {
struct cfs_cpu_partition *part = >ctb_parts[i];
@@ -511,6 +523,15 @@ struct cfs_cpt_table *
 }
 EXPORT_SYMBOL(cfs_cpt_of_cpu);
 
+int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node)
+{
+   if (node < 0 || node > nr_node_ids)
+   return CFS_CPT_ANY;
+
+   return cptab->ctb_node2cpt[node];
+}
+EXPORT_SYMBOL(cfs_cpt_of_node);
+
 int
 cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt)
 {
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 14/25] staging: lustre: libcfs: use int type for CPT identification.

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

Use int type for CPT identification to match the linux kernel
CPU identification.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23304
Reviewed-by: James Simmons 
Reviewed-by: Doug Oucharek 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch to handle recent libcfs changes

 drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h |  8 
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c  | 14 +++---
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 2c97adf..9f4ba9d 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -90,7 +90,7 @@ struct cfs_cpu_partition {
/* NUMA distance between CPTs */
unsigned int*cpt_distance;
/* spread rotor for NUMA allocator */
-   unsigned intcpt_spread_rotor;
+   int cpt_spread_rotor;
 };
 #endif /* CONFIG_SMP */
 
@@ -98,11 +98,11 @@ struct cfs_cpu_partition {
 struct cfs_cpt_table {
 #ifdef CONFIG_SMP
/* spread rotor for NUMA allocator */
-   unsigned intctb_spread_rotor;
+   int ctb_spread_rotor;
/* maximum NUMA distance between all nodes in table */
unsigned intctb_distance;
/* # of CPU partitions */
-   unsigned intctb_nparts;
+   int ctb_nparts;
/* partitions tables */
struct cfs_cpu_partition*ctb_parts;
/* shadow HW CPU to CPU partition ID */
@@ -128,7 +128,7 @@ struct cfs_cpt_table {
 /**
  * create a cfs_cpt_table with \a ncpt number of partitions
  */
-struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt);
+struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt);
 /**
  * return cpumask of CPU partition \a cpt
  */
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index fab6675..14d5791 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -69,7 +69,7 @@
 module_param(cpu_pattern, charp, 0444);
 MODULE_PARM_DESC(cpu_pattern, "CPU partitions pattern");
 
-struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt)
+struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt)
 {
struct cfs_cpt_table *cptab;
int i;
@@ -784,13 +784,13 @@ static int cfs_cpt_choose_ncpus(struct cfs_cpt_table 
*cptab, int cpt,
return rc;
 }
 
-#define CPT_WEIGHT_MIN  4u
+#define CPT_WEIGHT_MIN 4
 
-static unsigned int cfs_cpt_num_estimate(void)
+static int cfs_cpt_num_estimate(void)
 {
-   unsigned int nnode = num_online_nodes();
-   unsigned int ncpu = num_online_cpus();
-   unsigned int ncpt;
+   int nnode = num_online_nodes();
+   int ncpu = num_online_cpus();
+   int ncpt;
 
if (ncpu <= CPT_WEIGHT_MIN) {
ncpt = 1;
@@ -820,7 +820,7 @@ static unsigned int cfs_cpt_num_estimate(void)
/* config many CPU partitions on 32-bit system could consume
 * too much memory
 */
-   ncpt = min(2U, ncpt);
+   ncpt = min(2, ncpt);
 #endif
while (ncpu % ncpt)
ncpt--; /* worst case is 1 */
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 12/25] staging: lustre: libcfs: invert error handling for cfs_cpt_table_print

2018-05-29 Thread James Simmons
From: Amir Shehata 

Instead of setting rc to -EFBIG for several cases in the loop lets
just go to the out label on error which returns -E2BIG directly.

Signed-off-by: Amir Shehata 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber 
Reviewed-by: Doug Oucharek 
Signed-off-by: James Simmons 
---
Changelog:

v1) New patch to replace several patches. Went crazy for the one
change per patch approach.

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 25 ++---
 1 file changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 9ff9fe9..bf41ba3 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -190,29 +190,26 @@ struct cfs_cpt_table *
 cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
 {
char *tmp = buf;
-   int rc = 0;
+   int rc;
int i;
int j;
 
for (i = 0; i < cptab->ctb_nparts; i++) {
-   if (len > 0) {
-   rc = snprintf(tmp, len, "%d\t:", i);
-   len -= rc;
-   }
+   if (len <= 0)
+   goto out;
+
+   rc = snprintf(tmp, len, "%d\t:", i);
+   len -= rc;
 
-   if (len <= 0) {
-   rc = -EFBIG;
+   if (len <= 0)
goto out;
-   }
 
tmp += rc;
for_each_cpu(j, cptab->ctb_parts[i].cpt_cpumask) {
rc = snprintf(tmp, len, "%d ", j);
len -= rc;
-   if (len <= 0) {
-   rc = -EFBIG;
+   if (len <= 0)
goto out;
-   }
tmp += rc;
}
 
@@ -221,11 +218,9 @@ struct cfs_cpt_table *
len--;
}
 
- out:
-   if (rc < 0)
-   return rc;
-
return tmp - buf;
+out:
+   return -E2BIG;
 }
 EXPORT_SYMBOL(cfs_cpt_table_print);
 
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 10/25] staging: lustre: libcfs: use distance in cpu and node handling

2018-05-29 Thread James Simmons
From: Amir Shehata 

Take into consideration the location of NUMA nodes and core
when calling cfs_cpt_[un]set_cpu() and cfs_cpt_[un]set_node().
This enables functioning on platforms with 100s of cores and
NUMA nodes.

Signed-off-by: Amir Shehata 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber 
Reviewed-by: Doug Oucharek 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch to handle recent libcfs changes

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 192 ++--
 1 file changed, 143 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 2a74e51..9ff9fe9 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -330,11 +330,134 @@ unsigned int cfs_cpt_distance(struct cfs_cpt_table 
*cptab, int cpt1, int cpt2)
 }
 EXPORT_SYMBOL(cfs_cpt_distance);
 
+/*
+ * Calculate the maximum NUMA distance between all nodes in the
+ * from_mask and all nodes in the to_mask.
+ */
+static unsigned int cfs_cpt_distance_calculate(nodemask_t *from_mask,
+  nodemask_t *to_mask)
+{
+   unsigned int maximum;
+   unsigned int distance;
+   int from;
+   int to;
+
+   maximum = 0;
+   for_each_node_mask(from, *from_mask) {
+   for_each_node_mask(to, *to_mask) {
+   distance = node_distance(from, to);
+   if (maximum < distance)
+   maximum = distance;
+   }
+   }
+   return maximum;
+}
+
+static void cfs_cpt_add_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
+{
+   cptab->ctb_cpu2cpt[cpu] = cpt;
+
+   cpumask_set_cpu(cpu, cptab->ctb_cpumask);
+   cpumask_set_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
+}
+
+static void cfs_cpt_del_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
+{
+   cpumask_clear_cpu(cpu, cptab->ctb_parts[cpt].cpt_cpumask);
+   cpumask_clear_cpu(cpu, cptab->ctb_cpumask);
+
+   cptab->ctb_cpu2cpt[cpu] = -1;
+}
+
+static void cfs_cpt_add_node(struct cfs_cpt_table *cptab, int cpt, int node)
+{
+   struct cfs_cpu_partition *part;
+
+   if (!node_isset(node, *cptab->ctb_nodemask)) {
+   unsigned int dist;
+
+   /* first time node is added to the CPT table */
+   node_set(node, *cptab->ctb_nodemask);
+   cptab->ctb_node2cpt[node] = cpt;
+
+   dist = cfs_cpt_distance_calculate(cptab->ctb_nodemask,
+ cptab->ctb_nodemask);
+   cptab->ctb_distance = dist;
+   }
+
+   part = >ctb_parts[cpt];
+   if (!node_isset(node, *part->cpt_nodemask)) {
+   int cpt2;
+
+   /* first time node is added to this CPT */
+   node_set(node, *part->cpt_nodemask);
+   for (cpt2 = 0; cpt2 < cptab->ctb_nparts; cpt2++) {
+   struct cfs_cpu_partition *part2;
+   unsigned int dist;
+
+   part2 = >ctb_parts[cpt2];
+   dist = cfs_cpt_distance_calculate(part->cpt_nodemask,
+ part2->cpt_nodemask);
+   part->cpt_distance[cpt2] = dist;
+   dist = cfs_cpt_distance_calculate(part2->cpt_nodemask,
+ part->cpt_nodemask);
+   part2->cpt_distance[cpt] = dist;
+   }
+   }
+}
+
+static void cfs_cpt_del_node(struct cfs_cpt_table *cptab, int cpt, int node)
+{
+   struct cfs_cpu_partition *part = >ctb_parts[cpt];
+   int cpu;
+
+   for_each_cpu(cpu, part->cpt_cpumask) {
+   /* this CPT has other CPU belonging to this node? */
+   if (cpu_to_node(cpu) == node)
+   break;
+   }
+
+   if (cpu >= nr_cpu_ids && node_isset(node,  *part->cpt_nodemask)) {
+   int cpt2;
+
+   /* No more CPUs in the node for this CPT. */
+   node_clear(node, *part->cpt_nodemask);
+   for (cpt2 = 0; cpt2 < cptab->ctb_nparts; cpt2++) {
+   struct cfs_cpu_partition *part2;
+   unsigned int dist;
+
+   part2 = >ctb_parts[cpt2];
+   if (node_isset(node, *part2->cpt_nodemask))
+   cptab->ctb_node2cpt[node] = cpt2;
+
+   dist = cfs_cpt_distance_calculate(part->cpt_nodemask,
+ part2->cpt_nodemask);
+   part->cpt_distance[cpt2] = dist;
+   dist = cfs_cpt_distance_calculate(part2->cpt_nodemask,
+

[PATCH v2 01/25] staging: lustre: libcfs: restore UMP handling

2018-05-29 Thread James Simmons
With the cleanup of the libcfs SMP handling all UMP handling
was removed. In the process now various NULL pointers and
empty fields are return in the UMP case which causes lustre
to crash hard. Restore the proper UMP handling so Lustre can
properly function.

Signed-off-by: James Simmons 
Signed-off-by: Amir Shehata 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber 
Reviewed-by: Doug Oucharek 
Signed-off-by: James Simmons 
---
Changelog:

v1) New patch to handle the disappearence of UMP support

 .../lustre/include/linux/libcfs/libcfs_cpu.h   | 87 --
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c|  4 -
 drivers/staging/lustre/lnet/libcfs/module.c|  4 +
 3 files changed, 69 insertions(+), 26 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 61641c4..2ad12a6 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -74,6 +74,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 /* any CPU partition */
@@ -89,10 +90,11 @@ struct cfs_cpu_partition {
/* spread rotor for NUMA allocator */
unsigned intcpt_spread_rotor;
 };
-
+#endif /* CONFIG_SMP */
 
 /** descriptor for CPU partitions */
 struct cfs_cpt_table {
+#ifdef CONFIG_SMP
/* version, reserved for hotplug */
unsigned intctb_version;
/* spread rotor for NUMA allocator */
@@ -103,14 +105,26 @@ struct cfs_cpt_table {
struct cfs_cpu_partition*ctb_parts;
/* shadow HW CPU to CPU partition ID */
int *ctb_cpu2cpt;
-   /* all cpus in this partition table */
-   cpumask_var_t   ctb_cpumask;
/* all nodes in this partition table */
nodemask_t  *ctb_nodemask;
+#else
+   nodemask_t  ctb_nodemask;
+#endif /* CONFIG_SMP */
+   /* all cpus in this partition table */
+   cpumask_var_t   ctb_cpumask;
 };
 
 extern struct cfs_cpt_table*cfs_cpt_tab;
 
+#ifdef CONFIG_SMP
+/**
+ * destroy a CPU partition table
+ */
+void cfs_cpt_table_free(struct cfs_cpt_table *cptab);
+/**
+ * create a cfs_cpt_table with \a ncpt number of partitions
+ */
+struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt);
 /**
  * return cpumask of CPU partition \a cpt
  */
@@ -208,20 +222,52 @@ void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab,
 void cfs_cpu_fini(void);
 
 #else /* !CONFIG_SMP */
-struct cfs_cpt_table;
-#define cfs_cpt_tab ((struct cfs_cpt_table *)NULL)
 
-static inline cpumask_var_t *
-cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
+static inline void cfs_cpt_table_free(struct cfs_cpt_table *cptab)
 {
-   return NULL;
+   kfree(cptab);
 }
 
-static inline int
-cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len)
+static inline struct cfs_cpt_table *cfs_cpt_table_alloc(int ncpt)
 {
-   return 0;
+   struct cfs_cpt_table *cptab;
+
+   if (ncpt != 1)
+   return NULL;
+
+   cptab = kzalloc(sizeof(*cptab), GFP_NOFS);
+   if (!cptab)
+   return NULL;
+
+   if (!zalloc_cpumask_var(>ctb_cpumask, GFP_NOFS)) {
+   kfree(cptab);
+   return NULL;
+   }
+   cpumask_set_cpu(0, cptab->ctb_cpumask);
+   node_set(0, cptab->ctb_nodemask);
+
+   return cptab;
+}
+
+static inline int cfs_cpt_table_print(struct cfs_cpt_table *cptab,
+ char *buf, int len)
+{
+   int rc;
+
+   rc = snprintf(buf, len, "0\t: 0\n");
+   len -= rc;
+   if (len <= 0)
+   return -EFBIG;
+
+   return rc;
 }
+
+static inline cpumask_var_t *
+cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
+{
+   return >ctb_cpumask;
+}
+
 static inline int
 cfs_cpt_number(struct cfs_cpt_table *cptab)
 {
@@ -243,7 +289,7 @@ void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab,
 static inline nodemask_t *
 cfs_cpt_nodemask(struct cfs_cpt_table *cptab, int cpt)
 {
-   return NULL;
+   return >ctb_nodemask;
 }
 
 static inline int
@@ -328,24 +374,21 @@ void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab,
 static inline int
 cfs_cpu_init(void)
 {
-   return 0;
+   cfs_cpt_tab = cfs_cpt_table_alloc(1);
+
+   return cfs_cpt_tab ? 0 : -1;
 }
 
 static inline void cfs_cpu_fini(void)
 {
+   if (cfs_cpt_tab) {
+   cfs_cpt_table_free(cfs_cpt_tab);
+   cfs_cpt_tab = NULL;
+   }
 }
 
 #endif /* CONFIG_SMP */
 
-/**
- * destroy a CPU partition table
- */
-void cfs_cpt_table_free(struct cfs_cpt_table *cptab);
-/**
- * create a cfs_cpt_table with \a ncpt number of partitions
- */
-struct cfs_cpt_table *cfs_cpt_table_alloc(unsigned int ncpt);
-
 /*
  * allocate 

[PATCH v2 04/25] staging: lustre: libcfs: properly handle failure cases in SMP code

2018-05-29 Thread James Simmons
While pushing the SMP work some bugs were pointed out by Dan
Carpenter in the code. Due to single err label in cfs_cpu_init()
and cfs_cpt_table_alloc() a few items were being cleaned up that
were never initialized. This can lead to crashed and other problems.
In those initialization function introduce individual labels to
jump to only the thing initialized get freed on failure.

Signed-off-by: James Simmons 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10932
Reviewed-on: https://review.whamcloud.com/32085
Reviewed-by: Dmitry Eremin 
Reviewed-by: Andreas Dilger 
Signed-off-by: James Simmons 
---
Changelog:

v1) New patch to make libcfs SMP code handle failure paths correctly.

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 72 ++---
 1 file changed, 52 insertions(+), 20 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 34df7ed..b67a60c 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -81,17 +81,19 @@ struct cfs_cpt_table *
 
cptab->ctb_nparts = ncpt;
 
+   if (!zalloc_cpumask_var(>ctb_cpumask, GFP_NOFS))
+   goto failed_alloc_cpumask;
+
cptab->ctb_nodemask = kzalloc(sizeof(*cptab->ctb_nodemask),
  GFP_NOFS);
-   if (!zalloc_cpumask_var(>ctb_cpumask, GFP_NOFS) ||
-   !cptab->ctb_nodemask)
-   goto failed;
+   if (!cptab->ctb_nodemask)
+   goto failed_alloc_nodemask;
 
cptab->ctb_cpu2cpt = kvmalloc_array(num_possible_cpus(),
sizeof(cptab->ctb_cpu2cpt[0]),
GFP_KERNEL);
if (!cptab->ctb_cpu2cpt)
-   goto failed;
+   goto failed_alloc_cpu2cpt;
 
memset(cptab->ctb_cpu2cpt, -1,
   num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0]));
@@ -99,22 +101,41 @@ struct cfs_cpt_table *
cptab->ctb_parts = kvmalloc_array(ncpt, sizeof(cptab->ctb_parts[0]),
  GFP_KERNEL);
if (!cptab->ctb_parts)
-   goto failed;
+   goto failed_alloc_ctb_parts;
+
+   memset(cptab->ctb_parts, -1, ncpt * sizeof(cptab->ctb_parts[0]));
 
for (i = 0; i < ncpt; i++) {
struct cfs_cpu_partition *part = >ctb_parts[i];
 
+   if (!zalloc_cpumask_var(>cpt_cpumask, GFP_NOFS))
+   goto failed_setting_ctb_parts;
+
part->cpt_nodemask = kzalloc(sizeof(*part->cpt_nodemask),
 GFP_NOFS);
-   if (!zalloc_cpumask_var(>cpt_cpumask, GFP_NOFS) ||
-   !part->cpt_nodemask)
-   goto failed;
+   if (!part->cpt_nodemask)
+   goto failed_setting_ctb_parts;
}
 
return cptab;
 
- failed:
-   cfs_cpt_table_free(cptab);
+failed_setting_ctb_parts:
+   while (i-- >= 0) {
+   struct cfs_cpu_partition *part = >ctb_parts[i];
+
+   kfree(part->cpt_nodemask);
+   free_cpumask_var(part->cpt_cpumask);
+   }
+
+   kvfree(cptab->ctb_parts);
+failed_alloc_ctb_parts:
+   kvfree(cptab->ctb_cpu2cpt);
+failed_alloc_cpu2cpt:
+   kfree(cptab->ctb_nodemask);
+failed_alloc_nodemask:
+   free_cpumask_var(cptab->ctb_cpumask);
+failed_alloc_cpumask:
+   kfree(cptab);
return NULL;
 }
 EXPORT_SYMBOL(cfs_cpt_table_alloc);
@@ -940,7 +961,7 @@ static int cfs_cpu_dead(unsigned int cpu)
 int
 cfs_cpu_init(void)
 {
-   int ret = 0;
+   int ret;
 
LASSERT(!cfs_cpt_tab);
 
@@ -949,23 +970,23 @@ static int cfs_cpu_dead(unsigned int cpu)
"staging/lustre/cfe:dead", NULL,
cfs_cpu_dead);
if (ret < 0)
-   goto failed;
+   goto failed_cpu_dead;
+
ret = cpuhp_setup_state_nocalls(CPUHP_AP_ONLINE_DYN,
"staging/lustre/cfe:online",
cfs_cpu_online, NULL);
if (ret < 0)
-   goto failed;
+   goto failed_cpu_online;
+
lustre_cpu_online = ret;
 #endif
-   ret = -EINVAL;
-
get_online_cpus();
if (*cpu_pattern) {
char *cpu_pattern_dup = kstrdup(cpu_pattern, GFP_KERNEL);
 
if (!cpu_pattern_dup) {
CERROR("Failed to duplicate cpu_pattern\n");
-   goto failed;
+   goto failed_alloc_table;
}
 
cfs_cpt_tab = cfs_cpt_table_create_pattern(cpu_pattern_dup);
@@ -973,7 +994,7 @@ static int cfs_cpu_dead(unsigned int cpu)
if (!cfs_cpt_tab) {
CERROR("Failed to create cptab from pattern %s\n",
 

[PATCH v2 09/25] staging: lustre: libcfs: add cpu distance handling

2018-05-29 Thread James Simmons
From: Amir Shehata 

Add functionality to calculate the distance between two CPTs.
Expose those distance in debugfs so people deploying a setup
can debug what is being created for CPTs.

Signed-off-by: Amir Shehata 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber 
Reviewed-by: Doug Oucharek 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch to handle recent libcfs changes

 .../lustre/include/linux/libcfs/libcfs_cpu.h   | 31 +++
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c| 61 ++
 2 files changed, 92 insertions(+)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 487625d..d5237d0 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -87,6 +87,8 @@ struct cfs_cpu_partition {
cpumask_var_t   cpt_cpumask;
/* nodes mask for this partition */
nodemask_t  *cpt_nodemask;
+   /* NUMA distance between CPTs */
+   unsigned int*cpt_distance;
/* spread rotor for NUMA allocator */
unsigned intcpt_spread_rotor;
 };
@@ -97,6 +99,8 @@ struct cfs_cpt_table {
 #ifdef CONFIG_SMP
/* spread rotor for NUMA allocator */
unsigned intctb_spread_rotor;
+   /* maximum NUMA distance between all nodes in table */
+   unsigned intctb_distance;
/* # of CPU partitions */
unsigned intctb_nparts;
/* partitions tables */
@@ -134,6 +138,10 @@ struct cfs_cpt_table {
  */
 int cfs_cpt_table_print(struct cfs_cpt_table *cptab, char *buf, int len);
 /**
+ * print distance information of cpt-table
+ */
+int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len);
+/**
  * return total number of CPU partitions in \a cptab
  */
 int
@@ -163,6 +171,10 @@ struct cfs_cpt_table {
  */
 int cfs_cpt_of_node(struct cfs_cpt_table *cptab, int node);
 /**
+ * NUMA distance between \a cpt1 and \a cpt2 in \a cptab
+ */
+unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab, int cpt1, int cpt2);
+/**
  * bind current thread on a CPU-partition \a cpt of \a cptab
  */
 int cfs_cpt_bind(struct cfs_cpt_table *cptab, int cpt);
@@ -257,6 +269,19 @@ static inline int cfs_cpt_table_print(struct cfs_cpt_table 
*cptab,
return rc;
 }
 
+static inline int cfs_cpt_distance_print(struct cfs_cpt_table *cptab,
+char *buf, int len)
+{
+   int rc;
+
+   rc = snprintf(buf, len, "0\t: 0:1\n");
+   len -= rc;
+   if (len <= 0)
+   return -EFBIG;
+
+   return rc;
+}
+
 static inline cpumask_var_t *
 cfs_cpt_cpumask(struct cfs_cpt_table *cptab, int cpt)
 {
@@ -287,6 +312,12 @@ static inline int cfs_cpt_table_print(struct cfs_cpt_table 
*cptab,
return >ctb_nodemask;
 }
 
+static inline unsigned int cfs_cpt_distance(struct cfs_cpt_table *cptab,
+   int cpt1, int cpt2)
+{
+   return 1;
+}
+
 static inline int
 cfs_cpt_set_cpu(struct cfs_cpt_table *cptab, int cpt, int cpu)
 {
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index f616073..2a74e51 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -124,6 +124,15 @@ struct cfs_cpt_table *
 GFP_NOFS);
if (!part->cpt_nodemask)
goto failed_setting_ctb_parts;
+
+   part->cpt_distance = kvmalloc_array(cptab->ctb_nparts,
+   
sizeof(part->cpt_distance[0]),
+   GFP_KERNEL);
+   if (!part->cpt_distance)
+   goto failed_setting_ctb_parts;
+
+   memset(part->cpt_distance, -1,
+  cptab->ctb_nparts * sizeof(part->cpt_distance[0]));
}
 
return cptab;
@@ -134,6 +143,7 @@ struct cfs_cpt_table *
 
kfree(part->cpt_nodemask);
free_cpumask_var(part->cpt_cpumask);
+   kvfree(part->cpt_distance);
}
 
kvfree(cptab->ctb_parts);
@@ -164,6 +174,7 @@ struct cfs_cpt_table *
 
kfree(part->cpt_nodemask);
free_cpumask_var(part->cpt_cpumask);
+   kvfree(part->cpt_distance);
}
 
kvfree(cptab->ctb_parts);
@@ -218,6 +229,44 @@ struct cfs_cpt_table *
 }
 EXPORT_SYMBOL(cfs_cpt_table_print);
 
+int cfs_cpt_distance_print(struct cfs_cpt_table *cptab, char *buf, int len)
+{
+   char *tmp = buf;
+   int rc;
+   int i;
+   int j;
+
+   for (i = 0; i < 

[PATCH v2 11/25] staging: lustre: libcfs: provide debugfs files for distance handling

2018-05-29 Thread James Simmons
From: Amir Shehata 

On systems with large number of NUMA nodes and cores it is easy
to incorrectly configure their use with Lustre. Provide debugfs
files which can help track down any issues.

Signed-off-by: Amir Shehata 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber 
Reviewed-by: Doug Oucharek 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. No code changes from original patch

 drivers/staging/lustre/lnet/libcfs/module.c | 53 +
 1 file changed, 53 insertions(+)

diff --git a/drivers/staging/lustre/lnet/libcfs/module.c 
b/drivers/staging/lustre/lnet/libcfs/module.c
index b438d456..d2dfc29 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -468,6 +468,53 @@ static int proc_cpt_table(struct ctl_table *table, int 
write,
__proc_cpt_table);
 }
 
+static int __proc_cpt_distance(void *data, int write,
+  loff_t pos, void __user *buffer, int nob)
+{
+   char *buf = NULL;
+   int len = 4096;
+   int rc = 0;
+
+   if (write)
+   return -EPERM;
+
+   LASSERT(cfs_cpt_tab);
+
+   while (1) {
+   buf = kzalloc(len, GFP_KERNEL);
+   if (!buf)
+   return -ENOMEM;
+
+   rc = cfs_cpt_distance_print(cfs_cpt_tab, buf, len);
+   if (rc >= 0)
+   break;
+
+   if (rc == -EFBIG) {
+   kfree(buf);
+   len <<= 1;
+   continue;
+   }
+   goto out;
+   }
+
+   if (pos >= rc) {
+   rc = 0;
+   goto out;
+   }
+
+   rc = cfs_trace_copyout_string(buffer, nob, buf + pos, NULL);
+out:
+   kfree(buf);
+   return rc;
+}
+
+static int proc_cpt_distance(struct ctl_table *table, int write,
+void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+   return lprocfs_call_handler(table->data, write, ppos, buffer, lenp,
+   __proc_cpt_distance);
+}
+
 static struct ctl_table lnet_table[] = {
{
.procname = "debug",
@@ -497,6 +544,12 @@ static int proc_cpt_table(struct ctl_table *table, int 
write,
.proc_handler = _cpt_table,
},
{
+   .procname = "cpu_partition_distance",
+   .maxlen   = 128,
+   .mode = 0444,
+   .proc_handler = _cpt_distance,
+   },
+   {
.procname = "debug_log_upcall",
.data = lnet_debug_log_upcall,
.maxlen   = sizeof(lnet_debug_log_upcall),
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 05/25] staging: lustre: libcfs: replace MAX_NUMNODES with nr_node_ids

2018-05-29 Thread James Simmons
From: Amir Shehata 

Replace MAX_NUMNODES which is considered deprocated with
nr_nodes_ids. Looking at page_malloc.c you will see that
nr_nodes_ids is equal to MAX_NUMNODES. MAX_NUMNODES is
actually setup with Kconfig.

Signed-off-by: Amir Shehata 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber 
Reviewed-by: Doug Oucharek 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Same code but added in more details in commit message

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index b67a60c..d3017e8 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -395,7 +395,7 @@ struct cfs_cpt_table *
 {
const cpumask_t *mask;
 
-   if (node < 0 || node >= MAX_NUMNODES) {
+   if (node < 0 || node >= nr_node_ids) {
CDEBUG(D_INFO,
   "Invalid NUMA id %d for CPU partition %d\n", node, cpt);
return 0;
@@ -412,7 +412,7 @@ struct cfs_cpt_table *
 {
const cpumask_t *mask;
 
-   if (node < 0 || node >= MAX_NUMNODES) {
+   if (node < 0 || node >= nr_node_ids) {
CDEBUG(D_INFO,
   "Invalid NUMA id %d for CPU partition %d\n", node, cpt);
return;
@@ -836,7 +836,7 @@ struct cfs_cpt_table *
return cptab;
}
 
-   high = node ? MAX_NUMNODES - 1 : nr_cpu_ids - 1;
+   high = node ? nr_node_ids - 1 : nr_cpu_ids - 1;
 
for (str = strim(pattern), c = 0;; c++) {
struct cfs_range_expr *range;
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 v2 07/25] staging: lustre: libcfs: replace num_possible_cpus() with nr_cpu_ids

2018-05-29 Thread James Simmons
From: Amir Shehata 

Move from num_possible_cpus() to nr_cpu_ids.

Signed-off-by: Amir Shehata 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber 
Reviewed-by: Doug Oucharek 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. Same code

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index d9d1388..3f855a8 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -89,14 +89,14 @@ struct cfs_cpt_table *
if (!cptab->ctb_nodemask)
goto failed_alloc_nodemask;
 
-   cptab->ctb_cpu2cpt = kvmalloc_array(num_possible_cpus(),
+   cptab->ctb_cpu2cpt = kvmalloc_array(nr_cpu_ids,
sizeof(cptab->ctb_cpu2cpt[0]),
GFP_KERNEL);
if (!cptab->ctb_cpu2cpt)
goto failed_alloc_cpu2cpt;
 
memset(cptab->ctb_cpu2cpt, -1,
-  num_possible_cpus() * sizeof(cptab->ctb_cpu2cpt[0]));
+  nr_cpu_ids * sizeof(cptab->ctb_cpu2cpt[0]));
 
cptab->ctb_parts = kvmalloc_array(ncpt, sizeof(cptab->ctb_parts[0]),
  GFP_KERNEL);
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 00/25] staging: lustre: libcfs: SMP rework

2018-05-29 Thread James Simmons
From: James Simmons 

Recently lustre support has been expanded to extreme machines with as
many as a 1000+ cores. On the other end lustre also has been ported
to platforms like ARM and KNL which have uniquie NUMA and core setup.
For example some devices exist that have NUMA nodes with no cores.
With these new platforms the limitations of the Lustre's SMP code
came to light so a lot of work was needed. This resulted in this
patch set which has been tested on these platforms.

Amir Shehata (8):
  staging: lustre: libcfs: replace MAX_NUMNODES with nr_node_ids
  staging: lustre: libcfs: remove excess space
  staging: lustre: libcfs: replace num_possible_cpus() with nr_cpu_ids
  staging: lustre: libcfs: NUMA support
  staging: lustre: libcfs: add cpu distance handling
  staging: lustre: libcfs: use distance in cpu and node handling
  staging: lustre: libcfs: provide debugfs files for distance handling
  staging: lustre: libcfs: invert error handling for cfs_cpt_table_print

Dmitry Eremin (15):
  staging: lustre: libcfs: remove useless CPU partition code
  staging: lustre: libcfs: rename variable i to cpu
  staging: lustre: libcfs: fix libcfs_cpu coding style
  staging: lustre: libcfs: use int type for CPT identification.
  staging: lustre: libcfs: rename i to node for cfs_cpt_set_nodemask
  staging: lustre: libcfs: rename i to cpu for cfs_cpt_bind
  staging: lustre: libcfs: rename cpumask_var_t variables to *_mask
  staging: lustre: libcfs: rename goto label in cfs_cpt_table_print
  staging: lustre: libcfs: update debug messages
  staging: lustre: libcfs: make tolerant to offline CPUs and empty NUMA nodes
  staging: lustre: libcfs: report NUMA node instead of just node
  staging: lustre: libcfs: update debug messages in CPT code
  staging: lustre: libcfs: rework CPU pattern parsing code
  staging: lustre: libcfs: change CPT estimate algorithm
  staging: lustre: ptlrpc: use current CPU instead of hardcoded 0

James Simmons (2):
  staging: lustre: libcfs: restore UMP handling
  staging: lustre: libcfs: properly handle failure cases in SMP code

 .../lustre/include/linux/libcfs/libcfs_cpu.h   | 225 +++--
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c| 965 +++--
 drivers/staging/lustre/lnet/libcfs/module.c|  57 ++
 drivers/staging/lustre/lnet/lnet/lib-msg.c |   2 +
 drivers/staging/lustre/lustre/ptlrpc/service.c |  11 +-
 5 files changed, 728 insertions(+), 532 deletions(-)

-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 03/25] staging: lustre: libcfs: rename variable i to cpu

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

Change the name of the variable i used for for_each_cpu() to cpu
for code readability.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23303
Reviewed-by: James Simmons 
Reviewed-by: Doug Oucharek 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased to handle recent cleanups in libcfs

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 951a9ca..34df7ed 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -340,7 +340,7 @@ struct cfs_cpt_table *
 cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt,
const cpumask_t *mask)
 {
-   int i;
+   int cpu;
 
if (!cpumask_weight(mask) ||
cpumask_any_and(mask, cpu_online_mask) >= nr_cpu_ids) {
@@ -349,8 +349,8 @@ struct cfs_cpt_table *
return 0;
}
 
-   for_each_cpu(i, mask) {
-   if (!cfs_cpt_set_cpu(cptab, cpt, i))
+   for_each_cpu(cpu, mask) {
+   if (!cfs_cpt_set_cpu(cptab, cpt, cpu))
return 0;
}
 
@@ -362,10 +362,10 @@ struct cfs_cpt_table *
 cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt,
  const cpumask_t *mask)
 {
-   int i;
+   int cpu;
 
-   for_each_cpu(i, mask)
-   cfs_cpt_unset_cpu(cptab, cpt, i);
+   for_each_cpu(cpu, mask)
+   cfs_cpt_unset_cpu(cptab, cpt, cpu);
 }
 EXPORT_SYMBOL(cfs_cpt_unset_cpumask);
 
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 3/6] staging: lustre: llite: remove unused parameters from md_{get, set}xattr()

2018-05-29 Thread James Simmons
From: "John L. Hammond" 

md_getxattr() and md_setxattr() each have several unused
parameters. Remove them and improve the naming or remaining
parameters.

Signed-off-by: John L. Hammond 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10792
Reviewed-on: https://review.whamcloud.com/
Reviewed-by: Dmitry Eremin 
Reviewed-by: James Simmons 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch

v2) Rebased to new parent patch

v3) Rebased againt to new parent patch using acl.c file

 drivers/staging/lustre/lustre/include/obd.h   |  7 ++---
 drivers/staging/lustre/lustre/include/obd_class.h | 21 ++
 drivers/staging/lustre/lustre/llite/acl.c |  2 +-
 drivers/staging/lustre/lustre/llite/file.c|  3 +-
 drivers/staging/lustre/lustre/llite/xattr.c   |  6 ++--
 drivers/staging/lustre/lustre/lmv/lmv_obd.c   | 22 +++
 drivers/staging/lustre/lustre/mdc/mdc_request.c   | 34 +--
 7 files changed, 46 insertions(+), 49 deletions(-)

diff --git a/drivers/staging/lustre/lustre/include/obd.h 
b/drivers/staging/lustre/lustre/include/obd.h
index da99a0f..b1907bb 100644
--- a/drivers/staging/lustre/lustre/include/obd.h
+++ b/drivers/staging/lustre/lustre/include/obd.h
@@ -940,12 +940,11 @@ struct md_ops {
  struct ptlrpc_request **);
 
int (*setxattr)(struct obd_export *, const struct lu_fid *,
-   u64, const char *, const char *, int, int, int, __u32,
-   struct ptlrpc_request **);
+   u64, const char *, const void *, size_t, unsigned int,
+   u32, struct ptlrpc_request **);
 
int (*getxattr)(struct obd_export *, const struct lu_fid *,
-   u64, const char *, const char *, int, int, int,
-   struct ptlrpc_request **);
+   u64, const char *, size_t, struct ptlrpc_request **);
 
int (*init_ea_size)(struct obd_export *, u32, u32);
 
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h 
b/drivers/staging/lustre/lustre/include/obd_class.h
index a3b1465..fc9c772 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -1385,29 +1385,26 @@ static inline int md_merge_attr(struct obd_export *exp,
 }
 
 static inline int md_setxattr(struct obd_export *exp, const struct lu_fid *fid,
- u64 valid, const char *name,
- const char *input, int input_size,
- int output_size, int flags, __u32 suppgid,
+ u64 obd_md_valid, const char *name,
+ const char *value, size_t value_size,
+ unsigned int xattr_flags, u32 suppgid,
  struct ptlrpc_request **request)
 {
EXP_CHECK_MD_OP(exp, setxattr);
EXP_MD_COUNTER_INCREMENT(exp, setxattr);
-   return MDP(exp->exp_obd, setxattr)(exp, fid, valid, name, input,
-  input_size, output_size, flags,
+   return MDP(exp->exp_obd, setxattr)(exp, fid, obd_md_valid, name,
+  value, value_size, xattr_flags,
   suppgid, request);
 }
 
 static inline int md_getxattr(struct obd_export *exp, const struct lu_fid *fid,
- u64 valid, const char *name,
- const char *input, int input_size,
- int output_size, int flags,
- struct ptlrpc_request **request)
+ u64 obd_md_valid, const char *name,
+ size_t buf_size, struct ptlrpc_request **req)
 {
EXP_CHECK_MD_OP(exp, getxattr);
EXP_MD_COUNTER_INCREMENT(exp, getxattr);
-   return MDP(exp->exp_obd, getxattr)(exp, fid, valid, name, input,
-  input_size, output_size, flags,
-  request);
+   return MDP(exp->exp_obd, getxattr)(exp, fid, obd_md_valid, name,
+  buf_size, req);
 }
 
 static inline int md_set_open_replay_data(struct obd_export *exp,
diff --git a/drivers/staging/lustre/lustre/llite/acl.c 
b/drivers/staging/lustre/lustre/llite/acl.c
index de1499b..2ee9ff9 100644
--- a/drivers/staging/lustre/lustre/llite/acl.c
+++ b/drivers/staging/lustre/lustre/llite/acl.c
@@ -94,7 +94,7 @@ int ll_set_acl(struct inode *inode, struct posix_acl *acl, 
int type)
 
rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode),
 value ? OBD_MD_FLXATTR : OBD_MD_FLXATTRRM,
-name, value, value_size, 0, 0, 0, );
+name, value, value_size, 0, 0, );
 
ptlrpc_req_finished(req);
 out_value:
diff --git a/drivers/staging/lustre/lustre/llite/file.c 

[PATCH v2 06/25] staging: lustre: libcfs: remove excess space

2018-05-29 Thread James Simmons
From: Amir Shehata 

The function cfs_cpt_table_print() was adding two spaces
to the string buffer. Just add it once.

Signed-off-by: Amir Shehata 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7734
Reviewed-on: http://review.whamcloud.com/18916
Reviewed-by: Olaf Weber 
Reviewed-by: Doug Oucharek 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. Same code

 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index d3017e8..d9d1388 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -173,7 +173,7 @@ struct cfs_cpt_table *
 
for (i = 0; i < cptab->ctb_nparts; i++) {
if (len > 0) {
-   rc = snprintf(tmp, len, "%d\t: ", i);
+   rc = snprintf(tmp, len, "%d\t:", i);
len -= rc;
}
 
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 02/25] staging: lustre: libcfs: remove useless CPU partition code

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

* remove scratch buffer and mutex which guard it.
* remove global cpumask and spinlock which guard it.
* remove cpt_version for checking CPUs state change during setup
  because of just disable CPUs state change during setup.
* remove whole global struct cfs_cpt_data cpt_data.
* remove few unused APIs.

Signed-off-by: Dmitry Eremin 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-8703
Reviewed-on: https://review.whamcloud.com/23303
Reviewed-on: https://review.whamcloud.com/25048
Reviewed-by: James Simmons 
Reviewed-by: Doug Oucharek 
Reviewed-by: Andreas Dilger 
Reviewed-by: Olaf Weber 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased to handle recent cleanups in libcfs

 .../lustre/include/linux/libcfs/libcfs_cpu.h   |  32 ++
 drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c| 115 +++--
 2 files changed, 22 insertions(+), 125 deletions(-)

diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h 
b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
index 2ad12a6..3626969 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_cpu.h
@@ -95,8 +95,6 @@ struct cfs_cpu_partition {
 /** descriptor for CPU partitions */
 struct cfs_cpt_table {
 #ifdef CONFIG_SMP
-   /* version, reserved for hotplug */
-   unsigned intctb_version;
/* spread rotor for NUMA allocator */
unsigned intctb_spread_rotor;
/* # of CPU partitions */
@@ -176,12 +174,12 @@ struct cfs_cpt_table {
  * return 1 if successfully set all CPUs, otherwise return 0
  */
 int cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab,
-   int cpt, cpumask_t *mask);
+   int cpt, const cpumask_t *mask);
 /**
  * remove all cpus in \a mask from CPU partition \a cpt
  */
 void cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab,
-  int cpt, cpumask_t *mask);
+  int cpt, const cpumask_t *mask);
 /**
  * add all cpus in NUMA node \a node to CPU partition \a cpt
  * return 1 if successfully set all CPUs, otherwise return 0
@@ -204,20 +202,11 @@ int cfs_cpt_set_nodemask(struct cfs_cpt_table *cptab,
 void cfs_cpt_unset_nodemask(struct cfs_cpt_table *cptab,
int cpt, nodemask_t *mask);
 /**
- * unset all cpus for CPU partition \a cpt
- */
-void cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt);
-/**
  * convert partition id \a cpt to numa node id, if there are more than one
  * nodes in this partition, it might return a different node id each time.
  */
 int cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt);
 
-/**
- * return number of HTs in the same core of \a cpu
- */
-int cfs_cpu_ht_nsiblings(int cpu);
-
 int  cfs_cpu_init(void);
 void cfs_cpu_fini(void);
 
@@ -304,13 +293,15 @@ static inline int cfs_cpt_table_print(struct 
cfs_cpt_table *cptab,
 }
 
 static inline int
-cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
+cfs_cpt_set_cpumask(struct cfs_cpt_table *cptab, int cpt,
+   const cpumask_t *mask)
 {
return 1;
 }
 
 static inline void
-cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt, cpumask_t *mask)
+cfs_cpt_unset_cpumask(struct cfs_cpt_table *cptab, int cpt,
+ const cpumask_t *mask)
 {
 }
 
@@ -336,11 +327,6 @@ static inline int cfs_cpt_table_print(struct cfs_cpt_table 
*cptab,
 {
 }
 
-static inline void
-cfs_cpt_clear(struct cfs_cpt_table *cptab, int cpt)
-{
-}
-
 static inline int
 cfs_cpt_spread_node(struct cfs_cpt_table *cptab, int cpt)
 {
@@ -348,12 +334,6 @@ static inline int cfs_cpt_table_print(struct cfs_cpt_table 
*cptab,
 }
 
 static inline int
-cfs_cpu_ht_nsiblings(int cpu)
-{
-   return 1;
-}
-
-static inline int
 cfs_cpt_current(struct cfs_cpt_table *cptab, int remap)
 {
return 0;
diff --git a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c 
b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
index 803fc58..951a9ca 100644
--- a/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
+++ b/drivers/staging/lustre/lnet/libcfs/libcfs_cpu.c
@@ -69,19 +69,6 @@
 module_param(cpu_pattern, charp, 0444);
 MODULE_PARM_DESC(cpu_pattern, "CPU partitions pattern");
 
-static struct cfs_cpt_data {
-   /* serialize hotplug etc */
-   spinlock_t  cpt_lock;
-   /* reserved for hotplug */
-   unsigned long   cpt_version;
-   /* mutex to protect cpt_cpumask */
-   struct mutexcpt_mutex;
-   /* scratch buffer for set/unset_node */
-   cpumask_var_t   cpt_cpumask;
-} cpt_data;
-
-#define CFS_CPU_VERSION_MAGIC 0xbabecafe
-
 struct cfs_cpt_table *
 cfs_cpt_table_alloc(unsigned int ncpt)
 {
@@ -124,11 +111,6 @@ struct cfs_cpt_table *
goto failed;
}
 
-   spin_lock(_data.cpt_lock);
-   /* 

[PATCH v2 6/6] staging: lustre: mdc: use large xattr buffers for old servers

2018-05-29 Thread James Simmons
From: "John L. Hammond" 

Pre 2.10.1 MDTs will crash when they receive a listxattr (MDS_GETXATTR
with OBD_MD_FLXATTRLS) RPC for an orphan or dead object. So for
clients connected to these older MDTs, try to avoid sending listxattr
RPCs by making the bulk getxattr (MDS_GETXATTR with OBD_MD_FLXATTRALL)
more likely to succeed and thereby reducing the chances of falling
back to listxattr.

Signed-off-by: John L. Hammond 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10912
Reviewed-on: https://review.whamcloud.com/31990
Reviewed-by: Andreas Dilger 
Reviewed-by: Fan Yong 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) Rebased patch. No changes

 drivers/staging/lustre/lustre/mdc/mdc_locks.c | 31 +--
 1 file changed, 24 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c 
b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
index a8aa0fa..b991c6f 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
@@ -326,8 +326,10 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req,
 {
struct ptlrpc_request   *req;
struct ldlm_intent  *lit;
+   u32 min_buf_size = 0;
int rc, count = 0;
LIST_HEAD(cancels);
+   u32 buf_size = 0;
 
req = ptlrpc_request_alloc(class_exp2cliimp(exp),
   _LDLM_INTENT_GETXATTR);
@@ -344,18 +346,33 @@ static void mdc_realloc_openmsg(struct ptlrpc_request 
*req,
lit = req_capsule_client_get(>rq_pill, _LDLM_INTENT);
lit->opc = IT_GETXATTR;
 
+#if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(3, 0, 53, 0)
+   /* If the supplied buffer is too small then the server will
+* return -ERANGE and llite will fallback to using non cached
+* xattr operations. On servers before 2.10.1 a (non-cached)
+* listxattr RPC for an orphan or dead file causes an oops. So
+* let's try to avoid sending too small a buffer to too old a
+* server. This is effectively undoing the memory conservation
+* of LU-9417 when it would be *more* likely to crash the
+* server. See LU-9856.
+*/
+   if (exp->exp_connect_data.ocd_version < OBD_OCD_VERSION(2, 10, 1, 0))
+   min_buf_size = exp->exp_connect_data.ocd_max_easize;
+#endif
+   buf_size = max_t(u32, min_buf_size,
+GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM);
+
/* pack the intended request */
-   mdc_pack_body(req, _data->op_fid1, op_data->op_valid,
- GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM, -1, 0);
+   mdc_pack_body(req, _data->op_fid1, op_data->op_valid, buf_size,
+ -1, 0);
 
-   req_capsule_set_size(>rq_pill, _EADATA, RCL_SERVER,
-GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM);
+   req_capsule_set_size(>rq_pill, _EADATA, RCL_SERVER, buf_size);
 
-   req_capsule_set_size(>rq_pill, _EAVALS, RCL_SERVER,
-GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM);
+   req_capsule_set_size(>rq_pill, _EAVALS, RCL_SERVER, buf_size);
 
req_capsule_set_size(>rq_pill, _EAVALS_LENS, RCL_SERVER,
-sizeof(u32) * GA_DEFAULT_EA_NUM);
+max_t(u32, min_buf_size,
+  sizeof(u32) * GA_DEFAULT_EA_NUM));
 
req_capsule_set_size(>rq_pill, _ACL, RCL_SERVER, 0);
 
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 1/6] staging: lustre: llite: create acl.c file

2018-05-29 Thread James Simmons
Move ll_get_acl() to its own file acl.c just like all the other
linux file systems do.

Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6142
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch to add acl.c file which contains acl handling
for lustre

 drivers/staging/lustre/lustre/llite/Makefile   |  2 +
 drivers/staging/lustre/lustre/llite/acl.c  | 51 ++
 drivers/staging/lustre/lustre/llite/file.c | 13 --
 .../staging/lustre/lustre/llite/llite_internal.h   |  5 +++
 4 files changed, 58 insertions(+), 13 deletions(-)
 create mode 100644 drivers/staging/lustre/lustre/llite/acl.c

diff --git a/drivers/staging/lustre/lustre/llite/Makefile 
b/drivers/staging/lustre/lustre/llite/Makefile
index 519fd74..5200924 100644
--- a/drivers/staging/lustre/lustre/llite/Makefile
+++ b/drivers/staging/lustre/lustre/llite/Makefile
@@ -9,3 +9,5 @@ lustre-y := dcache.o dir.o file.o llite_lib.o llite_nfs.o \
super25.o statahead.o glimpse.o lcommon_cl.o lcommon_misc.o \
vvp_dev.o vvp_page.o vvp_lock.o vvp_io.o vvp_object.o \
lproc_llite.o
+
+lustre-$(CONFIG_FS_POSIX_ACL) += acl.o
diff --git a/drivers/staging/lustre/lustre/llite/acl.c 
b/drivers/staging/lustre/lustre/llite/acl.c
new file mode 100644
index 000..d7c3bf9
--- /dev/null
+++ b/drivers/staging/lustre/lustre/llite/acl.c
@@ -0,0 +1,51 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.gnu.org/licenses/gpl-2.0.html
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2015, Intel Corporation.
+ */
+/*
+ * This file is part of Lustre, http://www.lustre.org/
+ * Lustre is a trademark of Sun Microsystems, Inc.
+ *
+ * lustre/llite/acl.c
+ */
+
+#define DEBUG_SUBSYSTEM S_LLITE
+
+#include "llite_internal.h"
+
+struct posix_acl *ll_get_acl(struct inode *inode, int type)
+{
+   struct ll_inode_info *lli = ll_i2info(inode);
+   struct posix_acl *acl = NULL;
+
+   spin_lock(>lli_lock);
+   /* VFS' acl_permission_check->check_acl will release the refcount */
+   acl = posix_acl_dup(lli->lli_posix_acl);
+   spin_unlock(>lli_lock);
+
+   return acl;
+}
diff --git a/drivers/staging/lustre/lustre/llite/file.c 
b/drivers/staging/lustre/lustre/llite/file.c
index a77cadc..ccbf91b 100644
--- a/drivers/staging/lustre/lustre/llite/file.c
+++ b/drivers/staging/lustre/lustre/llite/file.c
@@ -3030,19 +3030,6 @@ static int ll_fiemap(struct inode *inode, struct 
fiemap_extent_info *fieinfo,
return rc;
 }
 
-struct posix_acl *ll_get_acl(struct inode *inode, int type)
-{
-   struct ll_inode_info *lli = ll_i2info(inode);
-   struct posix_acl *acl = NULL;
-
-   spin_lock(>lli_lock);
-   /* VFS' acl_permission_check->check_acl will release the refcount */
-   acl = posix_acl_dup(lli->lli_posix_acl);
-   spin_unlock(>lli_lock);
-
-   return acl;
-}
-
 int ll_inode_permission(struct inode *inode, int mask)
 {
struct ll_sb_info *sbi;
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h 
b/drivers/staging/lustre/lustre/llite/llite_internal.h
index 379d88e..bdb1564 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -754,7 +754,12 @@ enum ldlm_mode ll_take_md_lock(struct inode *inode, __u64 
bits,
 int ll_md_real_close(struct inode *inode, fmode_t fmode);
 int ll_getattr(const struct path *path, struct kstat *stat,
   u32 request_mask, unsigned int flags);
+#ifdef CONFIG_FS_POSIX_ACL
 struct posix_acl *ll_get_acl(struct inode *inode, int type);
+#else
+#define ll_get_acl NULL
+#endif /* CONFIG_FS_POSIX_ACL */
+
 int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
   const char *name, int namelen);
 int ll_get_fid_by_name(struct inode *parent, const char *name,
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 4/6] staging: lustre: acl: increase ACL entries limitation

2018-05-29 Thread James Simmons
From: Fan Yong 

Originally, the limitation of ACL entries is 32, that is not
enough for some use cases. In fact, restricting ACL entries
count is mainly for preparing the RPC reply buffer to receive
the ACL data. So we cannot make the ACL entries count to be
unlimited. But we can enlarge the RPC reply buffer to hold
more ACL entries. On the other hand, MDT backend filesystem
has its own EA size limitation. For example, for ldiskfs case,
if large EA enable, then the max ACL size is 1048492 bytes;
otherwise, it is 4012 bytes. For ZFS backend, such value is
32768 bytes. With such hard limitation, we can calculate how
many ACL entries we can have at most. This patch increases
the RPC reply buffer to match such hard limitation. For old
client, to avoid buffer overflow because of large ACL data
(more than 32 ACL entries), the MDT will forbid the old client
to access the file with large ACL data. As for how to know
whether it is old client or new, a new connection flag
OBD_CONNECT_LARGE_ACL is used for that.

Signed-off-by: Fan Yong 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-7473
Reviewed-on: https://review.whamcloud.com/19790
Reviewed-by: Andreas Dilger 
Reviewed-by: Li Xi 
Reviewed-by: Lai Siyao 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---

Changelog:

v1) Initial patch
v2) Rebased patch. No changes

 drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h | 2 +-
 drivers/staging/lustre/lustre/include/lustre_acl.h| 7 ++-
 drivers/staging/lustre/lustre/llite/llite_lib.c   | 3 ++-
 drivers/staging/lustre/lustre/mdc/mdc_locks.c | 6 ++
 drivers/staging/lustre/lustre/mdc/mdc_reint.c | 2 ++
 drivers/staging/lustre/lustre/mdc/mdc_request.c   | 4 
 drivers/staging/lustre/lustre/ptlrpc/layout.c | 4 +---
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c   | 4 ++--
 8 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h 
b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
index aac98db..8778c6f 100644
--- a/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
+++ b/drivers/staging/lustre/include/uapi/linux/lustre/lustre_idl.h
@@ -615,7 +615,7 @@ struct ptlrpc_body_v2 {
 #define OBD_CONNECT_REQPORTAL   0x40ULL /*Separate non-IO req portal */
 #define OBD_CONNECT_ACL 0x80ULL /*access control lists 
*/
 #define OBD_CONNECT_XATTR  0x100ULL /*client use extended attr */
-#define OBD_CONNECT_CROW   0x200ULL /*MDS+OST create obj on write*/
+#define OBD_CONNECT_LARGE_ACL  0x200ULL /* more than 32 ACL entries */
 #define OBD_CONNECT_TRUNCLOCK  0x400ULL /*locks on server for punch */
 #define OBD_CONNECT_TRANSNO0x800ULL /*replay sends init transno */
 #define OBD_CONNECT_IBITS 0x1000ULL /*support for inodebits locks*/
diff --git a/drivers/staging/lustre/lustre/include/lustre_acl.h 
b/drivers/staging/lustre/lustre/include/lustre_acl.h
index 35ff61c..e7575a1 100644
--- a/drivers/staging/lustre/lustre/include/lustre_acl.h
+++ b/drivers/staging/lustre/lustre/include/lustre_acl.h
@@ -36,11 +36,16 @@
 
 #include 
 #include 
+#ifdef CONFIG_FS_POSIX_ACL
 #include 
 
 #define LUSTRE_POSIX_ACL_MAX_ENTRIES   32
-#define LUSTRE_POSIX_ACL_MAX_SIZE  
\
+#define LUSTRE_POSIX_ACL_MAX_SIZE_OLD  
\
(sizeof(struct posix_acl_xattr_header) +
\
 LUSTRE_POSIX_ACL_MAX_ENTRIES * sizeof(struct posix_acl_xattr_entry))
 
+#else /* ! CONFIG_FS_POSIX_ACL */
+#define LUSTRE_POSIX_ACL_MAX_SIZE_OLD 0
+#endif /* CONFIG_FS_POSIX_ACL */
+
 #endif
diff --git a/drivers/staging/lustre/lustre/llite/llite_lib.c 
b/drivers/staging/lustre/lustre/llite/llite_lib.c
index 1bc0782..36066c8 100644
--- a/drivers/staging/lustre/lustre/llite/llite_lib.c
+++ b/drivers/staging/lustre/lustre/llite/llite_lib.c
@@ -199,7 +199,8 @@ static int client_common_fill_super(struct super_block *sb, 
char *md, char *dt)
if (sbi->ll_flags & LL_SBI_LRU_RESIZE)
data->ocd_connect_flags |= OBD_CONNECT_LRU_RESIZE;
 #ifdef CONFIG_FS_POSIX_ACL
-   data->ocd_connect_flags |= OBD_CONNECT_ACL | OBD_CONNECT_UMASK;
+   data->ocd_connect_flags |= OBD_CONNECT_ACL | OBD_CONNECT_UMASK |
+  OBD_CONNECT_LARGE_ACL;
 #endif
 
if (OBD_FAIL_CHECK(OBD_FAIL_MDC_LIGHTWEIGHT))
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c 
b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
index 253a545..65a5341 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
@@ -308,6 +308,8 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req,
 
req_capsule_set_size(>rq_pill, _MDT_MD, RCL_SERVER,
 

[PATCH v2 2/6] staging: lustre: llite: add support set_acl method in inode operations

2018-05-29 Thread James Simmons
From: Dmitry Eremin 

Linux kernel v3.14 adds set_acl method to inode operations.
This patch adds support to Lustre for proper acl management.

Signed-off-by: Dmitry Eremin 
Signed-off-by: John L. Hammond 
Signed-off-by: James Simmons 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9183
Reviewed-on: https://review.whamcloud.com/25965
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10541
Reviewed-on: https://review.whamcloud.com/31588
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-10926
Reviewed-on: https://review.whamcloud.com/32045
Reviewed-by: Bob Glossman 
Reviewed-by: James Simmons 
Reviewed-by: Andreas Dilger 
Reviewed-by: Dmitry Eremin 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial ported patch

v2) Updated patch with fixes that address issues pointed out by
   Can Carpenter

v3) Rebased to contain new code in acl.c

 drivers/staging/lustre/lustre/llite/acl.c  | 57 ++
 .../staging/lustre/lustre/llite/llite_internal.h   |  2 +
 2 files changed, 59 insertions(+)

diff --git a/drivers/staging/lustre/lustre/llite/acl.c 
b/drivers/staging/lustre/lustre/llite/acl.c
index d7c3bf9..de1499b 100644
--- a/drivers/staging/lustre/lustre/llite/acl.c
+++ b/drivers/staging/lustre/lustre/llite/acl.c
@@ -49,3 +49,60 @@ struct posix_acl *ll_get_acl(struct inode *inode, int type)
 
return acl;
 }
+
+int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type)
+{
+   struct ll_sb_info *sbi = ll_i2sbi(inode);
+   struct ptlrpc_request *req = NULL;
+   const char *name = NULL;
+   size_t value_size = 0;
+   char *value = NULL;
+   int rc = 0;
+
+   switch (type) {
+   case ACL_TYPE_ACCESS:
+   name = XATTR_NAME_POSIX_ACL_ACCESS;
+   if (acl)
+   rc = posix_acl_update_mode(inode, >i_mode, );
+   break;
+
+   case ACL_TYPE_DEFAULT:
+   name = XATTR_NAME_POSIX_ACL_DEFAULT;
+   if (!S_ISDIR(inode->i_mode))
+   rc = acl ? -EACCES : 0;
+   break;
+
+   default:
+   rc = -EINVAL;
+   break;
+   }
+   if (rc)
+   return rc;
+
+   if (acl) {
+   value_size = posix_acl_xattr_size(acl->a_count);
+   value = kmalloc(value_size, GFP_NOFS);
+   if (!value) {
+   rc = -ENOMEM;
+   goto out;
+   }
+
+   rc = posix_acl_to_xattr(_user_ns, acl, value, value_size);
+   if (rc < 0)
+   goto out_value;
+   }
+
+   rc = md_setxattr(sbi->ll_md_exp, ll_inode2fid(inode),
+value ? OBD_MD_FLXATTR : OBD_MD_FLXATTRRM,
+name, value, value_size, 0, 0, 0, );
+
+   ptlrpc_req_finished(req);
+out_value:
+   kfree(value);
+out:
+   if (rc)
+   forget_cached_acl(inode, type);
+   else
+   set_cached_acl(inode, type, acl);
+   return rc;
+}
diff --git a/drivers/staging/lustre/lustre/llite/llite_internal.h 
b/drivers/staging/lustre/lustre/llite/llite_internal.h
index bdb1564..c08a6e1 100644
--- a/drivers/staging/lustre/lustre/llite/llite_internal.h
+++ b/drivers/staging/lustre/lustre/llite/llite_internal.h
@@ -756,8 +756,10 @@ int ll_getattr(const struct path *path, struct kstat *stat,
   u32 request_mask, unsigned int flags);
 #ifdef CONFIG_FS_POSIX_ACL
 struct posix_acl *ll_get_acl(struct inode *inode, int type);
+int ll_set_acl(struct inode *inode, struct posix_acl *acl, int type);
 #else
 #define ll_get_acl NULL
+#define ll_set_acl NULL
 #endif /* CONFIG_FS_POSIX_ACL */
 
 int ll_migrate(struct inode *parent, struct file *file, int mdtidx,
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 5/6] staging: lustre: mdc: excessive memory consumption by the xattr cache

2018-05-29 Thread James Simmons
From: Andrew Perepechko 

The refill operation of the xattr cache does not know the
reply size in advance, so it makes a guess based on
the maxeasize value returned by the MDS.

In practice, it allocates 16 KiB for the common case and
4 MiB for the large xattr case. However, a typical reply
is just a few hundred bytes.

If we follow the conservative approach, we can prepare a
single memory page for the reply. It is large enough for
any reasonable xattr set and, at the same time, it does
not require multiple page memory reclaim, which can be
costly.

If, for a specific file, the reply is larger than a single
page, the client is prepared to handle that and will fall back
to non-cached xattr code. Indeed, if this happens often and
xattrs are often used to store large values, it makes sense to
disable the xattr cache at all since it wasn't designed for
such [mis]use.

Signed-off-by: Andrew Perepechko 
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-9417
Reviewed-on: https://review.whamcloud.com/26887
Reviewed-by: Fan Yong 
Reviewed-by: Ben Evans 
Reviewed-by: Oleg Drokin 
Signed-off-by: James Simmons 
---
Changelog:

v1) Initial patch
v2) rebased patch. No changes

 drivers/staging/lustre/lustre/mdc/mdc_locks.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/lustre/lustre/mdc/mdc_locks.c 
b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
index 65a5341..a8aa0fa 100644
--- a/drivers/staging/lustre/lustre/mdc/mdc_locks.c
+++ b/drivers/staging/lustre/lustre/mdc/mdc_locks.c
@@ -315,6 +315,10 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req,
return req;
 }
 
+#define GA_DEFAULT_EA_NAME_LEN 20
+#define GA_DEFAULT_EA_VAL_LEN  250
+#define GA_DEFAULT_EA_NUM  10
+
 static struct ptlrpc_request *
 mdc_intent_getxattr_pack(struct obd_export *exp,
 struct lookup_intent *it,
@@ -323,7 +327,6 @@ static void mdc_realloc_openmsg(struct ptlrpc_request *req,
struct ptlrpc_request   *req;
struct ldlm_intent  *lit;
int rc, count = 0;
-   u32 maxdata;
LIST_HEAD(cancels);
 
req = ptlrpc_request_alloc(class_exp2cliimp(exp),
@@ -341,20 +344,20 @@ static void mdc_realloc_openmsg(struct ptlrpc_request 
*req,
lit = req_capsule_client_get(>rq_pill, _LDLM_INTENT);
lit->opc = IT_GETXATTR;
 
-   maxdata = class_exp2cliimp(exp)->imp_connect_data.ocd_max_easize;
-
/* pack the intended request */
-   mdc_pack_body(req, _data->op_fid1, op_data->op_valid, maxdata, -1,
- 0);
+   mdc_pack_body(req, _data->op_fid1, op_data->op_valid,
+ GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM, -1, 0);
 
-   req_capsule_set_size(>rq_pill, _EADATA, RCL_SERVER, maxdata);
+   req_capsule_set_size(>rq_pill, _EADATA, RCL_SERVER,
+GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM);
 
-   req_capsule_set_size(>rq_pill, _EAVALS, RCL_SERVER, maxdata);
+   req_capsule_set_size(>rq_pill, _EAVALS, RCL_SERVER,
+GA_DEFAULT_EA_NAME_LEN * GA_DEFAULT_EA_NUM);
 
-   req_capsule_set_size(>rq_pill, _EAVALS_LENS,
-RCL_SERVER, maxdata);
+   req_capsule_set_size(>rq_pill, _EAVALS_LENS, RCL_SERVER,
+sizeof(u32) * GA_DEFAULT_EA_NUM);
 
-   req_capsule_set_size(>rq_pill, _ACL, RCL_SERVER, maxdata);
+   req_capsule_set_size(>rq_pill, _ACL, RCL_SERVER, 0);
 
ptlrpc_request_set_replen(req);
 
-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH v2 0/6] staging: lustre: llite: remaining xattr patches

2018-05-29 Thread James Simmons
From: James Simmons 

Fixed the bugs in the set_acl patch pointed out by Dan Carpenter.
Rebased the next patch 'remove unused parameter..." on the parent
patch. Created new acl.c file to match what other linx kernel file
systems do. Added newer xattr fixes that were recently pushed.

Andrew Perepechko (1):
  staging: lustre: mdc: excessive memory consumption by the xattr cache

Dmitry Eremin (1):
  staging: lustre: llite: add support set_acl method in inode operations

Fan Yong (1):
  staging: lustre: acl: increase ACL entries limitation

James Simmons (1):
  staging: lustre: llite: create acl.c file

John L. Hammond (2):
  staging: lustre: llite: remove unused parameters from md_{get,set}xattr()
  staging: lustre: mdc: use large xattr buffers for old servers

 .../lustre/include/uapi/linux/lustre/lustre_idl.h  |   2 +-
 drivers/staging/lustre/lustre/include/lustre_acl.h |   7 +-
 drivers/staging/lustre/lustre/include/obd.h|   7 +-
 drivers/staging/lustre/lustre/include/obd_class.h  |  21 ++--
 drivers/staging/lustre/lustre/llite/Makefile   |   2 +
 drivers/staging/lustre/lustre/llite/acl.c  | 108 +
 drivers/staging/lustre/lustre/llite/file.c |  16 +--
 .../staging/lustre/lustre/llite/llite_internal.h   |   7 ++
 drivers/staging/lustre/lustre/llite/llite_lib.c|   3 +-
 drivers/staging/lustre/lustre/llite/xattr.c|   6 +-
 drivers/staging/lustre/lustre/lmv/lmv_obd.c|  22 ++---
 drivers/staging/lustre/lustre/mdc/mdc_locks.c  |  42 ++--
 drivers/staging/lustre/lustre/mdc/mdc_reint.c  |   2 +
 drivers/staging/lustre/lustre/mdc/mdc_request.c|  38 +---
 drivers/staging/lustre/lustre/ptlrpc/layout.c  |   4 +-
 drivers/staging/lustre/lustre/ptlrpc/wiretest.c|   4 +-
 16 files changed, 214 insertions(+), 77 deletions(-)
 create mode 100644 drivers/staging/lustre/lustre/llite/acl.c
--
Changelog:

v1) Initial patch set with fixes to address issues pointed by Dan.
v2) Created new acl.c file and rebased the patches due to that change

-- 
1.8.3.1

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging:media:imx Fix multiple assignments in a line

2018-05-29 Thread Janani Sankara Babu
This patch solves multiple assignments warning shown by checkpatch
script.

Signed-off-by: Janani Sankara Babu 
---
 drivers/staging/media/imx/imx-media-csi.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/imx/imx-media-csi.c 
b/drivers/staging/media/imx/imx-media-csi.c
index aeab05f..15068f7 100644
--- a/drivers/staging/media/imx/imx-media-csi.c
+++ b/drivers/staging/media/imx/imx-media-csi.c
@@ -1191,10 +1191,12 @@ static int csi_enum_frame_size(struct v4l2_subdev *sd,
} else {
crop = __csi_get_crop(priv, cfg, fse->which);

-   fse->min_width = fse->max_width = fse->index & 1 ?
+   fse->min_width = fse->index & 1 ?
crop->width / 2 : crop->width;
-   fse->min_height = fse->max_height = fse->index & 2 ?
+   fse->max_width = fse->min_width;
+   fse->min_height = fse->index & 2 ?
crop->height / 2 : crop->height;
+   fse->max_height = fse->min_height;
}

mutex_unlock(>lock);
--
1.9.1
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next v3 6/7] net: bridge: Notify about bridge VLANs

2018-05-29 Thread Petr Machata
Dan Carpenter  writes:

> On Mon, May 28, 2018 at 05:11:04PM +0200, Petr Machata wrote:
>> @@ -580,6 +591,9 @@ int br_vlan_add(struct net_bridge *br, u16 vid, u16 
>> flags, bool *changed)
>>  vg->num_vlans++;
>>  *changed = true;
>>  }
>> +ret = br_switchdev_port_vlan_add(br->dev, vid, flags);
>> +if (ret && ret != -EOPNOTSUPP)
>> +return ret;
>
> We should probably do some error handling instead of returning directly?

I missed that, you are right. There's a bunch of mutations in the block
above.

Thanks,
Petr
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] media: staging: tegra-vde: Reset memory client

2018-05-29 Thread Dmitry Osipenko
On 29.05.2018 09:18, Hans Verkuil wrote:
> Hi Dmitry,
> 
> On 05/26/2018 04:27 PM, Dmitry Osipenko wrote:
>> DMA requests must be blocked before resetting VDE HW, otherwise it is
>> possible to get a memory corruption or a machine hang. Use the reset
>> control provided by the Memory Controller to block DMA before resetting
>> the VDE HW.
>>
>> Signed-off-by: Dmitry Osipenko 
>> ---
>>
>> Changelog:
>>
>> v2:
>>  - Reset HW even if Memory Client resetting fails.
> 
> Please note that v1 has already been merged, so if you can make a v3 rebased
> on top of the latest media_tree master branch, then I'll queue that up for
> 4.18.
> 

Thank you very much for letting me know, I'll make v3.

Thierry, wouldn't you mind to queue the relevant devicetree patches for 4.18, or
it's too late now? We'll have a full set in 4.18 then.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next v3 1/7] net: bridge: Extract boilerplate around switchdev_port_obj_*()

2018-05-29 Thread Vivien Didelot
Hi Petr,

Petr Machata  writes:

> A call to switchdev_port_obj_add() or switchdev_port_obj_del() involves
> initializing a struct switchdev_obj_port_vlan, a piece of code that
> repeats on each call site almost verbatim. While in the current codebase
> there is just one duplicated add call, the follow-up patches add more of
> both add and del calls.
>
> Thus to remove the duplication, extract the repetition into named
> functions and reuse.
>
> Signed-off-by: Petr Machata 

Considering Dan's comment as well:

Reviewed-by: Vivien Didelot 

Thanks,

Vivien
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH] staging: mt7621-eth: Refactor RX ring resource allocation and cleanup

2018-05-29 Thread Dan Carpenter
On Mon, May 21, 2018 at 09:37:31AM +1000, NeilBrown wrote:
> On Fri, May 18 2018, Kamal Heib wrote:
> 
> > Simplify the code of allocate and cleanup RX ring resources by using
> > helper functions, also make sure to free the allocated resources in
> > cause of allocation failure.
> >
> > Signed-off-by: Kamal Heib 
> > ---
> >  drivers/staging/mt7621-eth/mtk_eth_soc.c | 122 
> > ---
> >  1 file changed, 81 insertions(+), 41 deletions(-)
> >
> 
> >  static int mtk_dma_rx_alloc(struct mtk_eth *eth, struct mtk_rx_ring *ring)
> >  {
> > -   int i, pad = 0;
> > +   int err;
> >  
> > ring->frag_size = mtk_max_frag_size(ETH_DATA_LEN);
> > ring->rx_buf_size = mtk_max_buf_size(ring->frag_size);
> > @@ -317,38 +366,23 @@ static int mtk_dma_rx_alloc(struct mtk_eth *eth, 
> > struct mtk_rx_ring *ring)
> > ring->rx_data = kcalloc(ring->rx_ring_size, sizeof(*ring->rx_data),
> > GFP_KERNEL);
> > if (!ring->rx_data)
> > -   goto no_rx_mem;
> > +   return -ENOMEM;
> 
> Hi
>  I haven't tested this patch yet (will try to in the next day or so) but
>  it mostly looks good to me.
>  I would rather see the above "return -ENOMEM" as a "goto free_rx_data".
>  Having a single error-exit is generally more maintainable than having
>  lots of separate 'return's, and kfree() is quite happy to be asked to
>  kfree(NULL).
>  In fact, all of the free function (even dma_free_coherent) cope
>  ok will not having anything to free.  As devm_kzallo() and kcalloc()
>  are used, all the pointers default to NULL which is safe. I would would
>  prefer a single 'nomem' label which did:
> 
> nomem:
>   dma_free_coherent(eth->dev, ring->rx_ring_size * sizeof(*ring->rx_dma),
> ring->rx_dma, ring->rx_phys);
>   mtk_rx_free_frags(ring);
>   kfree(ring->rx_data);
>   return -ENOMEM;
> 
> 
> But that is just my personal preference.

You're sort of advocating two closely related styles of error handling.
The first is a do-nothing error handling instead of direct returns.  The
other style is a do-everything style error handling.

Direct returns are preferable to do-nothing gotos because they are more
readable.  "return -ENOMEM;" is more clear than "ret = -ENOMEM;
goto free_rx_data;".  The second one seems clear but it doesn't free
anything so the label name is actively misleading and confusing.  Do
nothing gotos introduce "forgot to set the error code" bugs.

The do-everything style error handling is the most bug prone style in
the kernel.  So far this week I have seen 4 buggy one label patches vs
1 buggy multi label patch.

I feel slightly bad picking on you but with your sample code which uses
the nomem: label, you can't free dma resources which haven't been
allocated.  I know you would have spotted it if you were writing a real
patch instead of just throwing together sample code in your email
client.  But the second issue is that you can't call
mtk_rx_free_frags(ring); when "ring->rx_data" is NULL or it will Oops.
That's subtle and so far as I know, static analysis would not warn about
it.

Multi label error handling is self documenting so you don't need to jump
to the bottom of the function.  You only need to track the most recently
allocated resource.

foo = allocate_foo();
if (!foo)
return -ENOMEM;

bar = allocate_bar();
if (!bar) {
ret = -ENOMEM;
goto err_free_foo;
}

This style of error handling is the most maintainable.  For example, I
see bugs where people change a function from returning NULL to returning
an error pointer but the error handling was relying on that kfree(NULL)
is a no-op.  If you only free resources which have been allocated then
you avoid that.

One argument I have heard is that using single exit style code will
prevent locking bugs where people do a direct return without dropping
the lock.  I once looked at git history to find if this was true or not.
My conclusion was that there are some people who add direct returns
without thinking about locking at all.  Which ever style of error
handling you use will not affect them.

Sorry for the rant...  I should probably try to put together some
figures to back this up...  But I think that if you look at the number
of bugs, multi label error handling is going to be the clear winner.

regards,
dan carpenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


[PATCH] Staging:rtl888eu:include Fix CamelCase issue

2018-05-29 Thread Janani Sankara Babu
This patch is created to solve the CamelCase issue. The members 'IEs'
and 'IELength' of struct wlan_bssid_ex are being modified to 'ie' and
'ie_length' to solve the issue. And the places where these variables
are referenced inside rtl8188eu driver are also changed.

Signed-off-by: Janani Sankara Babu 
---
 drivers/staging/rtl8188eu/core/rtw_ap.c |  72 -
 drivers/staging/rtl8188eu/core/rtw_cmd.c|  26 +++---
 drivers/staging/rtl8188eu/core/rtw_ieee80211.c  |  20 ++---
 drivers/staging/rtl8188eu/core/rtw_ioctl_set.c  |   2 +-
 drivers/staging/rtl8188eu/core/rtw_mlme.c   |  38 -
 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c   | 100 
 drivers/staging/rtl8188eu/core/rtw_wlan_util.c  |  34 
 drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c|  16 ++--
 drivers/staging/rtl8188eu/include/wlan_bssdef.h |  10 +--
 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c  |  12 +--
 10 files changed, 165 insertions(+), 165 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c 
b/drivers/staging/rtl8188eu/core/rtw_ap.c
index fa61145..4140e37 100644
--- a/drivers/staging/rtl8188eu/core/rtw_ap.c
+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c
@@ -69,19 +69,19 @@ static void update_BCNTIM(struct adapter *padapter)
struct mlme_ext_priv *pmlmeext = >mlmeextpriv;
struct mlme_ext_info *pmlmeinfo = >mlmext_info;
struct wlan_bssid_ex *pnetwork_mlmeext = >network;
-   unsigned char *pie = pnetwork_mlmeext->IEs;
+   unsigned char *pie = pnetwork_mlmeext->ies;
u8 *p, *dst_ie, *premainder_ie = NULL;
u8 *pbackup_remainder_ie = NULL;
uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen;

/* update TIM IE */
p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, _ielen,
-   pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_);
+   pnetwork_mlmeext->ie_length - _FIXED_IE_LENGTH_);
if (p && tim_ielen > 0) {
tim_ielen += 2;
premainder_ie = p + tim_ielen;
tim_ie_offset = (int)(p - pie);
-   remainder_ielen = pnetwork_mlmeext->IELength -
+   remainder_ielen = pnetwork_mlmeext->ie_length -
tim_ie_offset - tim_ielen;
/* append TIM IE from dst_ie offset */
dst_ie = p;
@@ -94,7 +94,7 @@ static void update_BCNTIM(struct adapter *padapter)

/*  get supported rates len */
p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_,
-  _len, (pnetwork_mlmeext->IELength -
+  _len, (pnetwork_mlmeext->ie_length -
  _BEACON_IE_OFFSET_));
if (p)
offset += tmp_len+2;
@@ -104,7 +104,7 @@ static void update_BCNTIM(struct adapter *padapter)

premainder_ie = pie + offset;

-   remainder_ielen = pnetwork_mlmeext->IELength -
+   remainder_ielen = pnetwork_mlmeext->ie_length -
offset - tim_ielen;

/* append TIM IE from offset */
@@ -148,7 +148,7 @@ static void update_BCNTIM(struct adapter *padapter)
kfree(pbackup_remainder_ie);
}
offset =  (uint)(dst_ie - pie);
-   pnetwork_mlmeext->IELength = offset + remainder_ielen;
+   pnetwork_mlmeext->ie_length = offset + remainder_ielen;

set_tx_beacon_cmd(padapter);
 }
@@ -158,13 +158,13 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct 
wlan_bssid_ex *pnetwork,
 {
struct ndis_802_11_var_ie *pIE;
u8 bmatch = false;
-   u8 *pie = pnetwork->IEs;
+   u8 *pie = pnetwork->ies;
u8 *p = NULL, *dst_ie = NULL, *premainder_ie = NULL;
u8 *pbackup_remainder_ie = NULL;
u32 i, offset, ielen = 0, ie_offset, remainder_ielen = 0;

-   for (i = sizeof(struct ndis_802_11_fixed_ie); i < pnetwork->IELength;) {
-   pIE = (struct ndis_802_11_var_ie *)(pnetwork->IEs + i);
+   for (i = sizeof(struct ndis_802_11_fixed_ie); i < pnetwork->ie_length;) 
{
+   pIE = (struct ndis_802_11_var_ie *)(pnetwork->ies + i);

if (pIE->ElementID > index) {
break;
@@ -187,7 +187,7 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct 
wlan_bssid_ex *pnetwork,

ie_offset = (int)(p - pie);

-   remainder_ielen = pnetwork->IELength - ie_offset - ielen;
+   remainder_ielen = pnetwork->ie_length - ie_offset - ielen;

if (bmatch)
dst_ie = p;
@@ -216,7 +216,7 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct 
wlan_bssid_ex *pnetwork,
}

offset =  (uint)(dst_ie - pie);
-   pnetwork->IELength = offset + remainder_ielen;
+   pnetwork->ie_length = offset + remainder_ielen;
 }

 void 

Re: [PATCH net-next v3 0/7] net: bridge: Notify about bridge VLANs

2018-05-29 Thread Ido Schimmel
On Tue, May 29, 2018 at 01:46:09PM +0300, Dan Carpenter wrote:
> It occured to me that I should read the cover letter and here are the
> answers I was looking for.  But the cover letter isn't saved after the
> commits are merged.

DaveM adds the cover letter to the merge commit.
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next v3 0/7] net: bridge: Notify about bridge VLANs

2018-05-29 Thread Dan Carpenter
On Tue, May 29, 2018 at 01:58:53PM +0300, Ido Schimmel wrote:
> On Tue, May 29, 2018 at 01:46:09PM +0300, Dan Carpenter wrote:
> > It occured to me that I should read the cover letter and here are the
> > answers I was looking for.  But the cover letter isn't saved after the
> > commits are merged.
> 
> DaveM adds the cover letter to the merge commit.

That's true but it doesn't help.  When I want to find why line of code
is there I look up the commit message, not the merge commit.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next v3 6/7] net: bridge: Notify about bridge VLANs

2018-05-29 Thread Dan Carpenter
On Mon, May 28, 2018 at 05:11:04PM +0200, Petr Machata wrote:
> @@ -580,6 +591,9 @@ int br_vlan_add(struct net_bridge *br, u16 vid, u16 
> flags, bool *changed)
>   vg->num_vlans++;
>   *changed = true;
>   }
> + ret = br_switchdev_port_vlan_add(br->dev, vid, flags);
> + if (ret && ret != -EOPNOTSUPP)
> + return ret;

We should probably do some error handling instead of returning directly?

>   if (__vlan_add_flags(vlan, flags))
>   *changed = true;
>  

regards,
dan caprenter
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next v3 0/7] net: bridge: Notify about bridge VLANs

2018-05-29 Thread Dan Carpenter
On Mon, May 28, 2018 at 05:10:22PM +0200, Petr Machata wrote:
> In commit 946a11e7408e ("mlxsw: spectrum_span: Allow bridge for gretap
> mirror"), mlxsw got support for offloading mirror-to-gretap such that
> the underlay packet path involves a bridge. In that case, the offload is
> also influenced by PVID setting of said bridge. However, changes to VLAN
> configuration of the bridge itself do not generate switchdev
> notifications, so there's no mechanism to prod mlxsw to update the
> offload when these settings change.
> 
> In this patchset, the problem is resolved by distributing the switchdev
> notification SWITCHDEV_OBJ_ID_PORT_VLAN also for configuration changes
> on bridge VLANs. Since stacked devices distribute the notification to
> lower devices, such event eventually reaches the driver, which can
> determine whether it's a bridge or port VLAN by inspecting orig_dev.
> 
> To keep things consistent, the newly-distributed notifications observe
> the same protocol as the existing ones: dual prepare/commit, with
> -EOPNOTSUPP indicating lack of support, even though there's currently
> nothing to prepare for and nothing to support. Correspondingly, all
> switchdev drivers have been updated to return -EOPNOTSUPP for bridge
> VLAN notifications.
> 
> In patch #1, the code to send notifications for adding and deleting is
> factored out into two named functions.
> 
> In patches #2-#5, respectively for mlxsw, rocker, DSA and DPAA2 ethsw,
> the new notifications (which are not enabled yet) are ignored to
> maintain the current behavior.
> 

It occured to me that I should read the cover letter and here are the
answers I was looking for.  But the cover letter isn't saved after the
commits are merged.  This should really be in the commit messages itself
so that we can look it up in the git history.

> In patch #6, the notification is actually enabled.
> 
> In patch #7, mlxsw is changed to update offloads of mirror-to-gre also
> for bridge-related notifications.

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next v3 2/7] mlxsw: spectrum_switchdev: Ignore bridge VLAN events

2018-05-29 Thread Dan Carpenter
On Mon, May 28, 2018 at 05:10:40PM +0200, Petr Machata wrote:
> Ignore VLAN events where the orig_dev is the bridge device itself.
> 

I don't know this code, and I have not looked at it either...  But this
changelog just says what you are doing and not why.  Is this a bug fix?
What are the user visible effects of this patch?  Perhaps it is
something which will be required in the future but has no effect now?

You know how the New York Times is written for people with at least a
10th grade education?  I feel like maybe if I knew this code I would
know the answers to my question, but kernel commit descriptions should
generally be written to Dan Carpenter level of education.  Which is
pretty darn ignorant...  Can you please resend?

regards,
dan carpenter


___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next v3 1/7] net: bridge: Extract boilerplate around switchdev_port_obj_*()

2018-05-29 Thread Dan Carpenter
On Mon, May 28, 2018 at 05:10:28PM +0200, Petr Machata wrote:
>   /* Try switchdev op first. In case it is not supported, fallback to
>* 8021q add.
>*/
> - err = switchdev_port_obj_add(dev, );
> + int err = br_switchdev_port_vlan_add(dev, vid, flags);
>   if (err == -EOPNOTSUPP)

This will introduce a checkpatch warning if you re-run with the --file
option.  (I haven't tested).  It's sort of ugly to put function logic in
the declaration block.  That's really just for initializing variables
like "int start = 0; struct foo *p = parent_of_bar();"  Do it like this
instead:

int err;

err = br_switchdev_port_vlan_add(dev, vid, flags);
if (err == -EOPNOTSUPP)

regards,
dan carpenter

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH net-next v2 3/7] rocker: rocker_main: Ignore bridge VLAN events

2018-05-29 Thread Ilias Apalodimas
Hi Petr, 

On Mon, May 28, 2018 at 12:50:09PM +0200, Petr Machata wrote:
> Ignore VLAN events where the orig_dev is the bridge device itself.
> 
> Signed-off-by: Petr Machata 
> ---
>  drivers/net/ethernet/rocker/rocker_main.c | 6 ++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
> b/drivers/net/ethernet/rocker/rocker_main.c
> index e73e4fe..aeafdb9 100644
> --- a/drivers/net/ethernet/rocker/rocker_main.c
> +++ b/drivers/net/ethernet/rocker/rocker_main.c
> @@ -1632,6 +1632,9 @@ rocker_world_port_obj_vlan_add(struct rocker_port 
> *rocker_port,
>  {
>   struct rocker_world_ops *wops = rocker_port->rocker->wops;
>  
> + if (netif_is_bridge_master(vlan->obj.orig_dev))
> + return -EOPNOTSUPP;
> +
What will happen to the "bridge vlan add dev br0 vid X pvid untagged self" when
the lower level (the driver) returns -EOPNOTSUPP? Will it avoid adding a vlan on
the bridge ?

>   if (!wops->port_obj_vlan_add)
>   return -EOPNOTSUPP;
>  
> @@ -1647,6 +1650,9 @@ rocker_world_port_obj_vlan_del(struct rocker_port 
> *rocker_port,
>  {
>   struct rocker_world_ops *wops = rocker_port->rocker->wops;
>  
> + if (netif_is_bridge_master(vlan->obj.orig_dev))
> + return -EOPNOTSUPP;
> +
>   if (!wops->port_obj_vlan_del)
>   return -EOPNOTSUPP;
>   return wops->port_obj_vlan_del(rocker_port, vlan);
> -- 
> 2.4.11
> 
___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel


Re: [PATCH v2] media: staging: tegra-vde: Reset memory client

2018-05-29 Thread Hans Verkuil
Hi Dmitry,

On 05/26/2018 04:27 PM, Dmitry Osipenko wrote:
> DMA requests must be blocked before resetting VDE HW, otherwise it is
> possible to get a memory corruption or a machine hang. Use the reset
> control provided by the Memory Controller to block DMA before resetting
> the VDE HW.
> 
> Signed-off-by: Dmitry Osipenko 
> ---
> 
> Changelog:
> 
> v2:
>   - Reset HW even if Memory Client resetting fails.

Please note that v1 has already been merged, so if you can make a v3 rebased
on top of the latest media_tree master branch, then I'll queue that up for
4.18.

Regards,

Hans
> 
>  drivers/staging/media/tegra-vde/tegra-vde.c | 35 +++--
>  1 file changed, 33 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/tegra-vde/tegra-vde.c 
> b/drivers/staging/media/tegra-vde/tegra-vde.c
> index 90177a59b97c..6f06061a40d9 100644
> --- a/drivers/staging/media/tegra-vde/tegra-vde.c
> +++ b/drivers/staging/media/tegra-vde/tegra-vde.c
> @@ -73,6 +73,7 @@ struct tegra_vde {
>   struct mutex lock;
>   struct miscdevice miscdev;
>   struct reset_control *rst;
> + struct reset_control *rst_mc;
>   struct gen_pool *iram_pool;
>   struct completion decode_completion;
>   struct clk *clk;
> @@ -850,9 +851,23 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde 
> *vde,
>* We rely on the VDE registers reset value, otherwise VDE
>* causes bus lockup.
>*/
> + ret = reset_control_assert(vde->rst_mc);
> + if (ret) {
> + dev_err(dev, "DEC start: Failed to assert MC reset: %d\n",
> + ret);
> + goto put_runtime_pm;
> + }
> +
>   ret = reset_control_reset(vde->rst);
>   if (ret) {
> - dev_err(dev, "Failed to reset HW: %d\n", ret);
> + dev_err(dev, "DEC start: Failed to reset HW: %d\n", ret);
> + goto put_runtime_pm;
> + }
> +
> + ret = reset_control_deassert(vde->rst_mc);
> + if (ret) {
> + dev_err(dev, "DEC start: Failed to deassert MC reset: %d\n",
> + ret);
>   goto put_runtime_pm;
>   }
>  
> @@ -880,9 +895,18 @@ static int tegra_vde_ioctl_decode_h264(struct tegra_vde 
> *vde,
>   ret = timeout;
>   }
>  
> + /*
> +  * At first reset memory client to avoid resetting VDE HW in the
> +  * middle of DMA which could result into memory corruption or hang
> +  * the whole system.
> +  */
> + err = reset_control_assert(vde->rst_mc);
> + if (err)
> + dev_err(dev, "DEC end: Failed to assert MC reset: %d\n", err);
> +
>   err = reset_control_assert(vde->rst);
>   if (err)
> - dev_err(dev, "Failed to assert HW reset: %d\n", err);
> + dev_err(dev, "DEC end: Failed to assert HW reset: %d\n", err);
>  
>  put_runtime_pm:
>   pm_runtime_mark_last_busy(dev);
> @@ -1074,6 +1098,13 @@ static int tegra_vde_probe(struct platform_device 
> *pdev)
>   return err;
>   }
>  
> + vde->rst_mc = devm_reset_control_get_optional(dev, "mc");
> + if (IS_ERR(vde->rst_mc)) {
> + err = PTR_ERR(vde->rst_mc);
> + dev_err(dev, "Could not get MC reset %d\n", err);
> + return err;
> + }
> +
>   irq = platform_get_irq_byname(pdev, "sync-token");
>   if (irq < 0)
>   return irq;
> 

___
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel