Re: [PATCH 00/26] Fixing wait, exit, ptrace, exec, and CLONE_THREAD

2017-06-06 Thread Aleksa Sarai

Another easy entry point is to see that a multi-threaded setuid won't
change the credentials on a zombie thread group leader.  Which can allow
sending signals to a process that the credential change should forbid.
This is in violation of posix and the semantics we attempt to enforce in
linux.


I might be completely wrong on this point (and I haven't looked at the 
patches), but I was under the impression that multi-threaded set[ug]id 
was implemented in userspace (by glibc's nptl(7) library that uses RT 
signals internally to get each thread to update their credentials). And 
given that, I wouldn't be surprised (as a user) that zombie threads will 
have stale credentials (glibc isn't running in those threads anymore).


Am I mistaken in that belief?



--
Aleksa Sarai
Software Engineer (Containers)
SUSE Linux GmbH
https://www.cyphar.com/


Re: [PATCH 00/26] Fixing wait, exit, ptrace, exec, and CLONE_THREAD

2017-06-06 Thread Aleksa Sarai

Another easy entry point is to see that a multi-threaded setuid won't
change the credentials on a zombie thread group leader.  Which can allow
sending signals to a process that the credential change should forbid.
This is in violation of posix and the semantics we attempt to enforce in
linux.


I might be completely wrong on this point (and I haven't looked at the 
patches), but I was under the impression that multi-threaded set[ug]id 
was implemented in userspace (by glibc's nptl(7) library that uses RT 
signals internally to get each thread to update their credentials). And 
given that, I wouldn't be surprised (as a user) that zombie threads will 
have stale credentials (glibc isn't running in those threads anymore).


Am I mistaken in that belief?



--
Aleksa Sarai
Software Engineer (Containers)
SUSE Linux GmbH
https://www.cyphar.com/


Applied "regulator: bd9571mwv: Statize local symbols" to the regulator tree

2017-06-06 Thread Mark Brown
The patch

   regulator: bd9571mwv: Statize local symbols

has been applied to the regulator tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From cb42b64838654df6e8767d2f4eb8b59dfcd414c5 Mon Sep 17 00:00:00 2001
From: Axel Lin 
Date: Sun, 28 May 2017 14:02:17 +0800
Subject: [PATCH] regulator: bd9571mwv: Statize local symbols

These functions are only used by this driver, make them static.

Signed-off-by: Axel Lin 
Acked-by: Marek Vasut 
Signed-off-by: Mark Brown 
---
 drivers/regulator/bd9571mwv-regulator.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/bd9571mwv-regulator.c 
b/drivers/regulator/bd9571mwv-regulator.c
index 8ba206fec31e..c67a83d53c4c 100644
--- a/drivers/regulator/bd9571mwv-regulator.c
+++ b/drivers/regulator/bd9571mwv-regulator.c
@@ -43,7 +43,7 @@ enum bd9571mwv_regulators { VD09, VD18, VD25, VD33, DVFS };
.linear_min_sel = _lmin,\
}
 
-int bd9571mwv_avs_get_moni_state(struct regulator_dev *rdev)
+static int bd9571mwv_avs_get_moni_state(struct regulator_dev *rdev)
 {
unsigned int val;
int ret;
@@ -55,8 +55,8 @@ int bd9571mwv_avs_get_moni_state(struct regulator_dev *rdev)
return val & BD9571MWV_AVS_SET_MONI_MASK;
 }
 
-int bd9571mwv_avs_set_voltage_sel_regmap(struct regulator_dev *rdev,
-unsigned int sel)
+static int bd9571mwv_avs_set_voltage_sel_regmap(struct regulator_dev *rdev,
+   unsigned int sel)
 {
int ret;
 
@@ -68,7 +68,7 @@ int bd9571mwv_avs_set_voltage_sel_regmap(struct regulator_dev 
*rdev,
 rdev->desc->vsel_mask, sel);
 }
 
-int bd9571mwv_avs_get_voltage_sel_regmap(struct regulator_dev *rdev)
+static int bd9571mwv_avs_get_voltage_sel_regmap(struct regulator_dev *rdev)
 {
unsigned int val;
int ret;
@@ -87,8 +87,8 @@ int bd9571mwv_avs_get_voltage_sel_regmap(struct regulator_dev 
*rdev)
return val;
 }
 
-int bd9571mwv_reg_set_voltage_sel_regmap(struct regulator_dev *rdev,
-unsigned int sel)
+static int bd9571mwv_reg_set_voltage_sel_regmap(struct regulator_dev *rdev,
+   unsigned int sel)
 {
return regmap_write_bits(rdev->regmap, BD9571MWV_DVFS_SETVID,
 rdev->desc->vsel_mask, sel);
-- 
2.11.0



Applied "regulator: bd9571mwv: Statize local symbols" to the regulator tree

2017-06-06 Thread Mark Brown
The patch

   regulator: bd9571mwv: Statize local symbols

has been applied to the regulator tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From cb42b64838654df6e8767d2f4eb8b59dfcd414c5 Mon Sep 17 00:00:00 2001
From: Axel Lin 
Date: Sun, 28 May 2017 14:02:17 +0800
Subject: [PATCH] regulator: bd9571mwv: Statize local symbols

These functions are only used by this driver, make them static.

Signed-off-by: Axel Lin 
Acked-by: Marek Vasut 
Signed-off-by: Mark Brown 
---
 drivers/regulator/bd9571mwv-regulator.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/regulator/bd9571mwv-regulator.c 
b/drivers/regulator/bd9571mwv-regulator.c
index 8ba206fec31e..c67a83d53c4c 100644
--- a/drivers/regulator/bd9571mwv-regulator.c
+++ b/drivers/regulator/bd9571mwv-regulator.c
@@ -43,7 +43,7 @@ enum bd9571mwv_regulators { VD09, VD18, VD25, VD33, DVFS };
.linear_min_sel = _lmin,\
}
 
-int bd9571mwv_avs_get_moni_state(struct regulator_dev *rdev)
+static int bd9571mwv_avs_get_moni_state(struct regulator_dev *rdev)
 {
unsigned int val;
int ret;
@@ -55,8 +55,8 @@ int bd9571mwv_avs_get_moni_state(struct regulator_dev *rdev)
return val & BD9571MWV_AVS_SET_MONI_MASK;
 }
 
-int bd9571mwv_avs_set_voltage_sel_regmap(struct regulator_dev *rdev,
-unsigned int sel)
+static int bd9571mwv_avs_set_voltage_sel_regmap(struct regulator_dev *rdev,
+   unsigned int sel)
 {
int ret;
 
@@ -68,7 +68,7 @@ int bd9571mwv_avs_set_voltage_sel_regmap(struct regulator_dev 
*rdev,
 rdev->desc->vsel_mask, sel);
 }
 
-int bd9571mwv_avs_get_voltage_sel_regmap(struct regulator_dev *rdev)
+static int bd9571mwv_avs_get_voltage_sel_regmap(struct regulator_dev *rdev)
 {
unsigned int val;
int ret;
@@ -87,8 +87,8 @@ int bd9571mwv_avs_get_voltage_sel_regmap(struct regulator_dev 
*rdev)
return val;
 }
 
-int bd9571mwv_reg_set_voltage_sel_regmap(struct regulator_dev *rdev,
-unsigned int sel)
+static int bd9571mwv_reg_set_voltage_sel_regmap(struct regulator_dev *rdev,
+   unsigned int sel)
 {
return regmap_write_bits(rdev->regmap, BD9571MWV_DVFS_SETVID,
 rdev->desc->vsel_mask, sel);
-- 
2.11.0



Re: [PATCH] external references for device tree overlays

2017-06-06 Thread Stefani Seibold
Hi Pantelis,

thanks for the suggestion. This feature is not very well documented. I
tried this on my rasp1 running 4.12.0-rc3 and it doesn't work. My
source is:

// rapsi example
/dts-v1/;
/plugin/;

/ {
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

fragment@0 {
target-path = "/soc/i2s@7e203000";
__overlay__ {
#address-cells = <0x0001>;
#size-cells = <0x0001>;
test = "test";
timer = <&{/soc/timer@7e003}>;
};
};
};


The resulting overlay is (decompiled with fdtdump):

/dts-v1/;
// magic:   0xd00dfeed
// totalsize:   0x19a (410)
// off_dt_struct:   0x38
// off_dt_strings:  0x148
// off_mem_rsvmap:  0x28
// version: 17
// last_comp_version:   16
// boot_cpuid_phys: 0x0
// size_dt_strings: 0x52
// size_dt_struct:  0x110

/ {
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
fragment@0 {
target-path = "/soc/i2s@7e203000";
__overlay__ {
#address-cells = <0x0001>;
#size-cells = <0x0001>;
test = "test";
timer = <0xdeadbeef>;
};
};
__fixups__ {
/soc/timer@7e003 = "/fragment@0/__overlay__:timer:0";
};
};

But this will not apply:

OF: resolver: overlay phandle fixup failed: -22
create_overlay: Failed to resolve tree


Anyway, the reason for my patch is that i can reference to nodes which
lacks a phandle. The phandle will be created on the fly and also
destroyed when the overlay is unloaded.

I have a real use case for this patch:

I have a BIOS on some ARM64 servers which provides broken device tree.
It also lacks some devices in this tree which needs references to other
devices which lacks a phandle.

Since the BIOSes are closed source i need a way to work arround this
problem without patching all the drivers involved to this devices.

Hope this helps to understand the reason for this patch.

- Stefani

Am Montag, den 05.06.2017, 21:43 +0300 schrieb Pantelis Antoniou:
> Hi Stefani,
> 
> On Mon, 2017-06-05 at 14:59 +0200, Stefani Seibold wrote:
> > From: Stefani Seibold 
> > 
> > This patch enables external references for symbols which are not
> > exported by the current device tree. For example
> > 
> > // RASPI example (only for testing)
> > /dts-v1/;
> > /plugin/;
> > 
> > / {
> > compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
> > 
> > fragment@0 {
> > target-path = "/soc/i2s@7e203000";
> > __overlay__ {
> > #address-cells = <0x0001>;
> > #size-cells = <0x0001>;
> > test = "test";
> > timer = <>;
> > };
> > };
> > 
> > __external_symbols__ {
> > timer = "/soc/timer@7e003000";
> > };
> > };
> > 
> 
> I understand the problem. I am just not fond of the
> __external_symbols__
> solution.
> 
> There's a facility in the DT source language that allows to declare
> pathspec labels.
> 
> The 'timer = <>;' statement could be rewritten as 
> 'timer = <&{/soc/timer@7e003}>;'
> 
> Internally you can 'catch' that this refers to a symbol in the base
> tree
> and then do the same symbol insertion as the patch you've submitted.
> 
> The benefit to the above is that you don't introduce manually edited
> special nodes.
> 
> Regards
> 
> -- Pantelis
> 
> > The "timer" symbol is not exported by the RASPI device tree,
> > because it is
> > missing in the __symbols__ section of the device tree.
> > 
> > In case of the RASPI device tree this could be simple fixed by
> > modifing
> > the device tree source, but when the device tree is provided by a
> > closed
> > source BIOS this kind of missing symbol could not be fixed.
> > 
> > An additional benefit is to override a (possible broken) symbol
> > exported
> > by the currect live device tree.
> > 
> > The patch is based and tested on linux 4.12-rc3.
> > 
> > Signed-off-by: Stefani Seibold 
> > Signed-off-by: Stefani Seibold 
> > ---
> >  drivers/of/overlay.c  | 19 +++
> >  drivers/of/resolver.c | 27 ++-
> >  2 files changed, 41 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
> > index 7827786718d8..de6516ea0fcd 100644
> > --- a/drivers/of/overlay.c
> > +++ b/drivers/of/overlay.c
> > @@ -50,6 +50,7 @@ struct of_overlay {
> >     int id;
> >     struct list_head node;
> >     int count;
> > +   struct device_node *tree;
> >     struct of_overlay_info *ovinfo_tab;
> >     struct of_changeset cset;
> >  };
> > @@ -422,6 +423,8 @@ int of_overlay_create(struct device_node *tree)
> >     /* add to the tail of the overlay list */
> >     list_add_tail(>node, _list);
> >  
> > +   ov->tree = tree;
> > +
> >     of_overlay_notify(ov, OF_OVERLAY_POST_APPLY);
> >  
> >     mutex_unlock(_mutex);
> > @@ -524,6 +527,7 @@ int 

Re: [PATCH 14/16] sparc: vio: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread David Miller
From: Greg Kroah-Hartman 
Date: Tue,  6 Jun 2017 21:22:19 +0200

> The dev_attrs field has long been "depreciated" and is finally being
> removed, so move the driver to use the "correct" dev_groups field
> instead for struct bus_type.
> 
> Cc: "David S. Miller" 
> Cc: 
> Signed-off-by: Greg Kroah-Hartman 

Acked-by: David S. Miller 


Re: [PATCH] external references for device tree overlays

2017-06-06 Thread Stefani Seibold
Hi Pantelis,

thanks for the suggestion. This feature is not very well documented. I
tried this on my rasp1 running 4.12.0-rc3 and it doesn't work. My
source is:

// rapsi example
/dts-v1/;
/plugin/;

/ {
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";

fragment@0 {
target-path = "/soc/i2s@7e203000";
__overlay__ {
#address-cells = <0x0001>;
#size-cells = <0x0001>;
test = "test";
timer = <&{/soc/timer@7e003}>;
};
};
};


The resulting overlay is (decompiled with fdtdump):

/dts-v1/;
// magic:   0xd00dfeed
// totalsize:   0x19a (410)
// off_dt_struct:   0x38
// off_dt_strings:  0x148
// off_mem_rsvmap:  0x28
// version: 17
// last_comp_version:   16
// boot_cpuid_phys: 0x0
// size_dt_strings: 0x52
// size_dt_struct:  0x110

/ {
compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
fragment@0 {
target-path = "/soc/i2s@7e203000";
__overlay__ {
#address-cells = <0x0001>;
#size-cells = <0x0001>;
test = "test";
timer = <0xdeadbeef>;
};
};
__fixups__ {
/soc/timer@7e003 = "/fragment@0/__overlay__:timer:0";
};
};

But this will not apply:

OF: resolver: overlay phandle fixup failed: -22
create_overlay: Failed to resolve tree


Anyway, the reason for my patch is that i can reference to nodes which
lacks a phandle. The phandle will be created on the fly and also
destroyed when the overlay is unloaded.

I have a real use case for this patch:

I have a BIOS on some ARM64 servers which provides broken device tree.
It also lacks some devices in this tree which needs references to other
devices which lacks a phandle.

Since the BIOSes are closed source i need a way to work arround this
problem without patching all the drivers involved to this devices.

Hope this helps to understand the reason for this patch.

- Stefani

Am Montag, den 05.06.2017, 21:43 +0300 schrieb Pantelis Antoniou:
> Hi Stefani,
> 
> On Mon, 2017-06-05 at 14:59 +0200, Stefani Seibold wrote:
> > From: Stefani Seibold 
> > 
> > This patch enables external references for symbols which are not
> > exported by the current device tree. For example
> > 
> > // RASPI example (only for testing)
> > /dts-v1/;
> > /plugin/;
> > 
> > / {
> > compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
> > 
> > fragment@0 {
> > target-path = "/soc/i2s@7e203000";
> > __overlay__ {
> > #address-cells = <0x0001>;
> > #size-cells = <0x0001>;
> > test = "test";
> > timer = <>;
> > };
> > };
> > 
> > __external_symbols__ {
> > timer = "/soc/timer@7e003000";
> > };
> > };
> > 
> 
> I understand the problem. I am just not fond of the
> __external_symbols__
> solution.
> 
> There's a facility in the DT source language that allows to declare
> pathspec labels.
> 
> The 'timer = <>;' statement could be rewritten as 
> 'timer = <&{/soc/timer@7e003}>;'
> 
> Internally you can 'catch' that this refers to a symbol in the base
> tree
> and then do the same symbol insertion as the patch you've submitted.
> 
> The benefit to the above is that you don't introduce manually edited
> special nodes.
> 
> Regards
> 
> -- Pantelis
> 
> > The "timer" symbol is not exported by the RASPI device tree,
> > because it is
> > missing in the __symbols__ section of the device tree.
> > 
> > In case of the RASPI device tree this could be simple fixed by
> > modifing
> > the device tree source, but when the device tree is provided by a
> > closed
> > source BIOS this kind of missing symbol could not be fixed.
> > 
> > An additional benefit is to override a (possible broken) symbol
> > exported
> > by the currect live device tree.
> > 
> > The patch is based and tested on linux 4.12-rc3.
> > 
> > Signed-off-by: Stefani Seibold 
> > Signed-off-by: Stefani Seibold 
> > ---
> >  drivers/of/overlay.c  | 19 +++
> >  drivers/of/resolver.c | 27 ++-
> >  2 files changed, 41 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
> > index 7827786718d8..de6516ea0fcd 100644
> > --- a/drivers/of/overlay.c
> > +++ b/drivers/of/overlay.c
> > @@ -50,6 +50,7 @@ struct of_overlay {
> >     int id;
> >     struct list_head node;
> >     int count;
> > +   struct device_node *tree;
> >     struct of_overlay_info *ovinfo_tab;
> >     struct of_changeset cset;
> >  };
> > @@ -422,6 +423,8 @@ int of_overlay_create(struct device_node *tree)
> >     /* add to the tail of the overlay list */
> >     list_add_tail(>node, _list);
> >  
> > +   ov->tree = tree;
> > +
> >     of_overlay_notify(ov, OF_OVERLAY_POST_APPLY);
> >  
> >     mutex_unlock(_mutex);
> > @@ -524,6 +527,7 @@ int of_overlay_destroy(int id)
> >  {
> >     struct of_overlay *ov;
> >     int 

Re: [PATCH 14/16] sparc: vio: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread David Miller
From: Greg Kroah-Hartman 
Date: Tue,  6 Jun 2017 21:22:19 +0200

> The dev_attrs field has long been "depreciated" and is finally being
> removed, so move the driver to use the "correct" dev_groups field
> instead for struct bus_type.
> 
> Cc: "David S. Miller" 
> Cc: 
> Signed-off-by: Greg Kroah-Hartman 

Acked-by: David S. Miller 


Re: [PATCH 10/16] powerpc: vio: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
On Tue, Jun 06, 2017 at 09:22:15PM +0200, Greg Kroah-Hartman wrote:
> The dev_attrs field has long been "depreciated" and is finally being
> removed, so move the driver to use the "correct" dev_groups field
> instead for struct bus_type.
> 
> Cc: Benjamin Herrenschmidt 
> Cc: Paul Mackerras 
> Cc: Michael Ellerman 
> Cc: Vineet Gupta 
> Cc: Bart Van Assche 
> Cc: Robin Murphy 
> Cc: Joerg Roedel 
> Cc: Johan Hovold 
> Cc: Alexey Kardashevskiy 
> Cc: Krzysztof Kozlowski 
> Cc: 
> Signed-off-by: Greg Kroah-Hartman 
> ---
>  arch/powerpc/platforms/pseries/vio.c | 12 +++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/vio.c 
> b/arch/powerpc/platforms/pseries/vio.c
> index 28b09fd797ec..fd6595598662 100644
> --- a/arch/powerpc/platforms/pseries/vio.c
> +++ b/arch/powerpc/platforms/pseries/vio.c
> @@ -1537,6 +1537,7 @@ static ssize_t name_show(struct device *dev,
>  {
>   return sprintf(buf, "%s\n", to_vio_dev(dev)->name);
>  }
> +static DEVICE_ATTR_RO(name);
>  
>  static ssize_t devspec_show(struct device *dev,
>   struct device_attribute *attr, char *buf)
> @@ -1545,6 +1546,7 @@ static ssize_t devspec_show(struct device *dev,
>  
>   return sprintf(buf, "%s\n", of_node_full_name(of_node));
>  }
> +static DEVICE_ATTR_RO(devspec);
>  
>  static ssize_t modalias_show(struct device *dev, struct device_attribute 
> *attr,
>char *buf)
> @@ -1566,6 +1568,7 @@ static ssize_t modalias_show(struct device *dev, struct 
> device_attribute *attr,
>  
>   return sprintf(buf, "vio:T%sS%s\n", vio_dev->type, cp);
>  }
> +static DEVICE_ATTR_RO(modalias);
>  
>  static struct device_attribute vio_dev_attrs[] = {
>   __ATTR_RO(name),
> @@ -1573,6 +1576,13 @@ static struct device_attribute vio_dev_attrs[] = {
>   __ATTR_RO(modalias),
>   __ATTR_NULL
>  };
> +static struct attribute *vio_dev_attrs[] = {

Hm, this feels wrong, odd that 0-day passed it.  I should be deleting
the above vio_dev_attrs field as well.  Is powerpc really a dead
platform?  :)

thanks,

greg k-h


Re: [PATCHv2 0/3] Enable no_cache flag to driver_data

2017-06-06 Thread Li, Yi

Hi Luis,


On 5/24/2017 2:03 PM, Luis R. Rodriguez wrote:

On Sat, May 20, 2017 at 01:46:56AM -0500, yi1...@linux.intel.com wrote:

From: Yi Li 

Changes in v2:

   - Rebase to Luis R. Rodriguez's 20170501-driver-data-try2
 branch
   - Expose DRIVER_DATA_REQ_NO_CACHE flag to public
 driver_data_req_params structure, so upper drivers can ask
 driver_data driver to bypass the internal caching mechanism.
 This will be used for streaming and other drivers maintains
 their own caching like iwlwifi.
   - Add self test cases.


Yi Li (3):
   firmware_class: move NO_CACHE from private to driver_data_req_params
   iwlwifi: use DRIVER_DATA_REQ_NO_CACHE for driver_data
   test: add no_cache to driver_data load tester

  drivers/base/firmware_class.c   | 16 -
  drivers/net/wireless/intel/iwlwifi/iwl-drv.c|  2 ++
  include/linux/driver_data.h |  4 +++
  lib/test_driver_data.c  | 43 +++--
  tools/testing/selftests/firmware/driver_data.sh | 36 +
  5 files changed, 89 insertions(+), 12 deletions(-)


Good stuff, this series is looking good and very easy to read !  Only thing
though -- the cache test is just setting up the cache and ensuring it gets set,
it doesn't really *test* the cache is functional. Can you devise a test which
does ensure the cache is functional ?

We use the cache upon suspend to cache the firmware so that upon resume a
request will use that cache, to avoid the file lookup on disk. Doing a test
with qemu suspend + resume is possible but that requires having access to
the qemu monitor interface and doing something like this to trigger a wakeup:

echo system_wakeup | socat - /dev/pts/7,raw,echo=0,crnl

where /dev/pts/7 is assumed to be the PTY. This is rather complex for ksefltest,
so another option is to add a debug mode debugfs interface for firmware_class 
where
we can force-enable the cache mechanism without actually this being prompted by 
a
suspend/hibernate. Then we can just toggle this bit from a testing perspective 
and
excercise the caching mechanism.

So if you look at fw_pm_notify()

 switch (mode) {
 case PM_HIBERNATION_PREPARE:
 case PM_SUSPEND_PREPARE:
 case PM_RESTORE_PREPARE:
 /*
  * kill pending fallback requests with a custom fallback
  * to avoid stalling suspend.
  */
 kill_pending_fw_fallback_reqs(true);
 device_cache_fw_images();
 disable_firmware();
 break;

I am studying at the firmware caching codes and have to say it's very 
complicated. :-( Here are some questions:


1. Since device_cache_fw_images invokes dev_cache_fw_image through 
dpm_for_each_dev, adding a debugfs driver to kick it can only cache 
firmware for those associated with devices which has PM enabled, which 
do not include the driver_data_test_device. Any suggestions?


2. Look into dev_cache_fw_image function, devres_for_each_res will walk through 
the firmware have been loaded before (through assign_firmware_buf -> 
fw_add_devm_name) and add to the todo list, eventually it will create the fw_names 
list. So in the test driver, we need to load the firmware once before calling the 
kick?
dev_cache_fw_image(struct device *dev, void *data)

{

LIST_HEAD(todo);

struct fw_cache_entry *fce;

struct fw_cache_entry *fce_next;

struct firmware_cache *fwc = _cache;

devres_for_each_res(dev, fw_name_devm_release,

devm_name_match, _cache,

dev_create_fw_entry, );

list_for_each_entry_safe(fce, fce_next, , list) {

list_del(>list);

spin_lock(>name_lock);

/* only one cache entry for one firmware */

if (!__fw_entry_found(fce->name)) {

list_add(>list, >fw_names);

} else {

free_fw_cache_entry(fce);

  ...
}

kill_pending_fw_fallback_reqs(true), device_cache_fw_images(), and
disable_firmware() could be folder into a helper, then a debugfs interface
could kick that into action to put us cache mode as the
device_cache_fw_images() changes the cache state to FW_LOADER_START_CACHE, and
when this is done you'll notice that assign_firmware_buf() does:

 /*
  * After caching firmware image is started, let it piggyback
  * on request firmware.
  */
 if (!driver_data_param_nocache(_params->priv_params) &&
 buf->fwc->state == FW_LOADER_START_CACHE) {
 if (fw_cache_piggyback_on_request(buf->fw_id))
 kref_get(>ref);
 }

Which adds an incoming request to the cache. The first request that adds this 
cache
entry would be triggered by device_cache_fw_images() after the cache state is 
enabled:

static void device_cache_fw_images(void)
{
...
 fwc->state = FW_LOADER_START_CACHE;
 dpm_for_each_dev(NULL, dev_cache_fw_image);
...
}

This only applies to the devices have PM enabled.

Subsequent 

Re: [PATCH 10/16] powerpc: vio: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
On Tue, Jun 06, 2017 at 09:22:15PM +0200, Greg Kroah-Hartman wrote:
> The dev_attrs field has long been "depreciated" and is finally being
> removed, so move the driver to use the "correct" dev_groups field
> instead for struct bus_type.
> 
> Cc: Benjamin Herrenschmidt 
> Cc: Paul Mackerras 
> Cc: Michael Ellerman 
> Cc: Vineet Gupta 
> Cc: Bart Van Assche 
> Cc: Robin Murphy 
> Cc: Joerg Roedel 
> Cc: Johan Hovold 
> Cc: Alexey Kardashevskiy 
> Cc: Krzysztof Kozlowski 
> Cc: 
> Signed-off-by: Greg Kroah-Hartman 
> ---
>  arch/powerpc/platforms/pseries/vio.c | 12 +++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/platforms/pseries/vio.c 
> b/arch/powerpc/platforms/pseries/vio.c
> index 28b09fd797ec..fd6595598662 100644
> --- a/arch/powerpc/platforms/pseries/vio.c
> +++ b/arch/powerpc/platforms/pseries/vio.c
> @@ -1537,6 +1537,7 @@ static ssize_t name_show(struct device *dev,
>  {
>   return sprintf(buf, "%s\n", to_vio_dev(dev)->name);
>  }
> +static DEVICE_ATTR_RO(name);
>  
>  static ssize_t devspec_show(struct device *dev,
>   struct device_attribute *attr, char *buf)
> @@ -1545,6 +1546,7 @@ static ssize_t devspec_show(struct device *dev,
>  
>   return sprintf(buf, "%s\n", of_node_full_name(of_node));
>  }
> +static DEVICE_ATTR_RO(devspec);
>  
>  static ssize_t modalias_show(struct device *dev, struct device_attribute 
> *attr,
>char *buf)
> @@ -1566,6 +1568,7 @@ static ssize_t modalias_show(struct device *dev, struct 
> device_attribute *attr,
>  
>   return sprintf(buf, "vio:T%sS%s\n", vio_dev->type, cp);
>  }
> +static DEVICE_ATTR_RO(modalias);
>  
>  static struct device_attribute vio_dev_attrs[] = {
>   __ATTR_RO(name),
> @@ -1573,6 +1576,13 @@ static struct device_attribute vio_dev_attrs[] = {
>   __ATTR_RO(modalias),
>   __ATTR_NULL
>  };
> +static struct attribute *vio_dev_attrs[] = {

Hm, this feels wrong, odd that 0-day passed it.  I should be deleting
the above vio_dev_attrs field as well.  Is powerpc really a dead
platform?  :)

thanks,

greg k-h


Re: [PATCHv2 0/3] Enable no_cache flag to driver_data

2017-06-06 Thread Li, Yi

Hi Luis,


On 5/24/2017 2:03 PM, Luis R. Rodriguez wrote:

On Sat, May 20, 2017 at 01:46:56AM -0500, yi1...@linux.intel.com wrote:

From: Yi Li 

Changes in v2:

   - Rebase to Luis R. Rodriguez's 20170501-driver-data-try2
 branch
   - Expose DRIVER_DATA_REQ_NO_CACHE flag to public
 driver_data_req_params structure, so upper drivers can ask
 driver_data driver to bypass the internal caching mechanism.
 This will be used for streaming and other drivers maintains
 their own caching like iwlwifi.
   - Add self test cases.


Yi Li (3):
   firmware_class: move NO_CACHE from private to driver_data_req_params
   iwlwifi: use DRIVER_DATA_REQ_NO_CACHE for driver_data
   test: add no_cache to driver_data load tester

  drivers/base/firmware_class.c   | 16 -
  drivers/net/wireless/intel/iwlwifi/iwl-drv.c|  2 ++
  include/linux/driver_data.h |  4 +++
  lib/test_driver_data.c  | 43 +++--
  tools/testing/selftests/firmware/driver_data.sh | 36 +
  5 files changed, 89 insertions(+), 12 deletions(-)


Good stuff, this series is looking good and very easy to read !  Only thing
though -- the cache test is just setting up the cache and ensuring it gets set,
it doesn't really *test* the cache is functional. Can you devise a test which
does ensure the cache is functional ?

We use the cache upon suspend to cache the firmware so that upon resume a
request will use that cache, to avoid the file lookup on disk. Doing a test
with qemu suspend + resume is possible but that requires having access to
the qemu monitor interface and doing something like this to trigger a wakeup:

echo system_wakeup | socat - /dev/pts/7,raw,echo=0,crnl

where /dev/pts/7 is assumed to be the PTY. This is rather complex for ksefltest,
so another option is to add a debug mode debugfs interface for firmware_class 
where
we can force-enable the cache mechanism without actually this being prompted by 
a
suspend/hibernate. Then we can just toggle this bit from a testing perspective 
and
excercise the caching mechanism.

So if you look at fw_pm_notify()

 switch (mode) {
 case PM_HIBERNATION_PREPARE:
 case PM_SUSPEND_PREPARE:
 case PM_RESTORE_PREPARE:
 /*
  * kill pending fallback requests with a custom fallback
  * to avoid stalling suspend.
  */
 kill_pending_fw_fallback_reqs(true);
 device_cache_fw_images();
 disable_firmware();
 break;

I am studying at the firmware caching codes and have to say it's very 
complicated. :-( Here are some questions:


1. Since device_cache_fw_images invokes dev_cache_fw_image through 
dpm_for_each_dev, adding a debugfs driver to kick it can only cache 
firmware for those associated with devices which has PM enabled, which 
do not include the driver_data_test_device. Any suggestions?


2. Look into dev_cache_fw_image function, devres_for_each_res will walk through 
the firmware have been loaded before (through assign_firmware_buf -> 
fw_add_devm_name) and add to the todo list, eventually it will create the fw_names 
list. So in the test driver, we need to load the firmware once before calling the 
kick?
dev_cache_fw_image(struct device *dev, void *data)

{

LIST_HEAD(todo);

struct fw_cache_entry *fce;

struct fw_cache_entry *fce_next;

struct firmware_cache *fwc = _cache;

devres_for_each_res(dev, fw_name_devm_release,

devm_name_match, _cache,

dev_create_fw_entry, );

list_for_each_entry_safe(fce, fce_next, , list) {

list_del(>list);

spin_lock(>name_lock);

/* only one cache entry for one firmware */

if (!__fw_entry_found(fce->name)) {

list_add(>list, >fw_names);

} else {

free_fw_cache_entry(fce);

  ...
}

kill_pending_fw_fallback_reqs(true), device_cache_fw_images(), and
disable_firmware() could be folder into a helper, then a debugfs interface
could kick that into action to put us cache mode as the
device_cache_fw_images() changes the cache state to FW_LOADER_START_CACHE, and
when this is done you'll notice that assign_firmware_buf() does:

 /*
  * After caching firmware image is started, let it piggyback
  * on request firmware.
  */
 if (!driver_data_param_nocache(_params->priv_params) &&
 buf->fwc->state == FW_LOADER_START_CACHE) {
 if (fw_cache_piggyback_on_request(buf->fw_id))
 kref_get(>ref);
 }

Which adds an incoming request to the cache. The first request that adds this 
cache
entry would be triggered by device_cache_fw_images() after the cache state is 
enabled:

static void device_cache_fw_images(void)
{
...
 fwc->state = FW_LOADER_START_CACHE;
 dpm_for_each_dev(NULL, dev_cache_fw_image);
...
}

This only applies to the devices have PM enabled.

Subsequent requests then lookup 

Re: [PATCH 05/16] rpmsg: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Bjorn Andersson
On Tue 06 Jun 12:22 PDT 2017, Greg Kroah-Hartman wrote:

> The dev_attrs field has long been "depreciated" and is finally being
> removed, so move the driver to use the "correct" dev_groups field
> instead for struct bus_type.
> 
> Cc: Ohad Ben-Cohen 
> Cc: Bjorn Andersson 
> Cc: 
> Signed-off-by: Greg Kroah-Hartman 

Thanks for cleaning this up.

Acked-by: Bjorn Andersson 

Regards,
Bjorn

> ---
>  drivers/rpmsg/rpmsg_core.c | 23 +--
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
> index 600f5f9f7431..ad3d2a9df287 100644
> --- a/drivers/rpmsg/rpmsg_core.c
> +++ b/drivers/rpmsg/rpmsg_core.c
> @@ -330,7 +330,8 @@ field##_show(struct device *dev,  
> \
>   struct rpmsg_device *rpdev = to_rpmsg_device(dev);  \
>   \
>   return sprintf(buf, format_string, rpdev->path);\
> -}
> +}\
> +static DEVICE_ATTR_RO(field);
>  
>  /* for more info, see Documentation/ABI/testing/sysfs-bus-rpmsg */
>  rpmsg_show_attr(name, id.name, "%s\n");
> @@ -345,15 +346,17 @@ static ssize_t modalias_show(struct device *dev,
>  
>   return sprintf(buf, RPMSG_DEVICE_MODALIAS_FMT "\n", rpdev->id.name);
>  }
> -
> -static struct device_attribute rpmsg_dev_attrs[] = {
> - __ATTR_RO(name),
> - __ATTR_RO(modalias),
> - __ATTR_RO(dst),
> - __ATTR_RO(src),
> - __ATTR_RO(announce),
> - __ATTR_NULL
> +static DEVICE_ATTR_RO(modalias);
> +
> +static struct attribute *rpmsg_dev_attrs[] = {
> + _attr_name.attr,
> + _attr_modalias.attr,
> + _attr_dst.attr,
> + _attr_src.attr,
> + _attr_announce.attr,
> + NULL,
>  };
> +ATTRIBUTE_GROUPS(rpmsg_dev);
>  
>  /* rpmsg devices and drivers are matched using the service name */
>  static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
> @@ -455,7 +458,7 @@ static int rpmsg_dev_remove(struct device *dev)
>  static struct bus_type rpmsg_bus = {
>   .name   = "rpmsg",
>   .match  = rpmsg_dev_match,
> - .dev_attrs  = rpmsg_dev_attrs,
> + .dev_groups = rpmsg_dev_groups,
>   .uevent = rpmsg_uevent,
>   .probe  = rpmsg_dev_probe,
>   .remove = rpmsg_dev_remove,
> -- 
> 2.13.0
> 


Re: [PATCH 05/16] rpmsg: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Bjorn Andersson
On Tue 06 Jun 12:22 PDT 2017, Greg Kroah-Hartman wrote:

> The dev_attrs field has long been "depreciated" and is finally being
> removed, so move the driver to use the "correct" dev_groups field
> instead for struct bus_type.
> 
> Cc: Ohad Ben-Cohen 
> Cc: Bjorn Andersson 
> Cc: 
> Signed-off-by: Greg Kroah-Hartman 

Thanks for cleaning this up.

Acked-by: Bjorn Andersson 

Regards,
Bjorn

> ---
>  drivers/rpmsg/rpmsg_core.c | 23 +--
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
> index 600f5f9f7431..ad3d2a9df287 100644
> --- a/drivers/rpmsg/rpmsg_core.c
> +++ b/drivers/rpmsg/rpmsg_core.c
> @@ -330,7 +330,8 @@ field##_show(struct device *dev,  
> \
>   struct rpmsg_device *rpdev = to_rpmsg_device(dev);  \
>   \
>   return sprintf(buf, format_string, rpdev->path);\
> -}
> +}\
> +static DEVICE_ATTR_RO(field);
>  
>  /* for more info, see Documentation/ABI/testing/sysfs-bus-rpmsg */
>  rpmsg_show_attr(name, id.name, "%s\n");
> @@ -345,15 +346,17 @@ static ssize_t modalias_show(struct device *dev,
>  
>   return sprintf(buf, RPMSG_DEVICE_MODALIAS_FMT "\n", rpdev->id.name);
>  }
> -
> -static struct device_attribute rpmsg_dev_attrs[] = {
> - __ATTR_RO(name),
> - __ATTR_RO(modalias),
> - __ATTR_RO(dst),
> - __ATTR_RO(src),
> - __ATTR_RO(announce),
> - __ATTR_NULL
> +static DEVICE_ATTR_RO(modalias);
> +
> +static struct attribute *rpmsg_dev_attrs[] = {
> + _attr_name.attr,
> + _attr_modalias.attr,
> + _attr_dst.attr,
> + _attr_src.attr,
> + _attr_announce.attr,
> + NULL,
>  };
> +ATTRIBUTE_GROUPS(rpmsg_dev);
>  
>  /* rpmsg devices and drivers are matched using the service name */
>  static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
> @@ -455,7 +458,7 @@ static int rpmsg_dev_remove(struct device *dev)
>  static struct bus_type rpmsg_bus = {
>   .name   = "rpmsg",
>   .match  = rpmsg_dev_match,
> - .dev_attrs  = rpmsg_dev_attrs,
> + .dev_groups = rpmsg_dev_groups,
>   .uevent = rpmsg_uevent,
>   .probe  = rpmsg_dev_probe,
>   .remove = rpmsg_dev_remove,
> -- 
> 2.13.0
> 


Re: [PATCH v2] checkpatch: Change format of --color argument to --color[=WHEN]

2017-06-06 Thread Joe Perches
On Tue, 2017-06-06 at 13:07 -0400, John Brooks wrote:
> The boolean --color argument did not offer the ability to force colourized
> output even if stdout is not a terminal. Change the format of the argument
> to the familiar --color[=WHEN] construct as seen in common Linux utilities
> such as ls and dmesg, which allows the user to specify whether to colourize
> output always, never, or only when the output is a terminal ("auto").
> 
> Because the option is no longer boolean, --nocolor (or --no-color) is no
> longer available. Users of the old negative option should use --color=never
> instead.

It is possible to add --nocolor and --no-color to the
arguments for GetOptions to keep the old behavior intact.

I think this works:
---
 scripts/checkpatch.pl | 35 +--
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4b9569fa931b..372d541c2c46 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -56,7 +56,7 @@ my $codespell = 0;
 my $codespellfile = "/usr/share/codespell/dictionary.txt";
 my $conststructsfile = "$D/const_structs.checkpatch";
 my $typedefsfile = "";
-my $color = 1;
+my $color = "auto";
 my $allow_c99_comments = 1;
 
 sub help {
@@ -115,7 +115,8 @@ Options:
  (default:/usr/share/codespell/dictionary.txt)
   --codespellfileUse this codespell dictionary
   --typedefsfile Read additional types from this file
-  --colorUse colors when output is STDOUT (default: on)
+  --color[=WHEN] Use colors 'always', 'never', or only when output
+ is a terminal ('auto'). Default is 'auto'.
   -h, --help, --version  display this help and exit
 
 When FILE is - read standard input.
@@ -181,6 +182,14 @@ if (-f $conf) {
unshift(@ARGV, @conf_args) if @conf_args;
 }
 
+# Perl's Getopt::Long allows options to take optional arguments after a space.
+# Prevent --color by itself from consuming other arguments
+foreach (@ARGV) {
+   if ($_ eq "--color" || $_ eq "-color") {
+   $_ = "--color=$color";
+   }
+}
+
 GetOptions(
'q|quiet+'  => \$quiet,
'tree!' => \$tree,
@@ -211,7 +220,9 @@ GetOptions(
'codespell!'=> \$codespell,
'codespellfile=s'   => \$codespellfile,
'typedefsfile=s'=> \$typedefsfile,
-   'color!'=> \$color,
+   'color=s'   => \$color,
+   '-no-color!'=> \$color, #keep old behaviors of -nocolor
+   '-nocolor!' => \$color, #keep old behaviors of -nocolor
'h|help'=> \$help,
'version'   => \$help
 ) or help(1);
@@ -237,6 +248,18 @@ if ($#ARGV < 0) {
push(@ARGV, '-');
 }
 
+if ($color =~ /^[01]$/) {
+   $color = !$color;
+} elsif ($color =~ /^always$/i) {
+   $color = 1;
+} elsif ($color =~ /^never$/i) {
+   $color = 0;
+} elsif ($color =~ /^auto$/i) {
+   $color = (-t STDOUT);
+} else {
+   die "Invalid color mode: $color\n";
+}
+
 sub hash_save_array_words {
my ($hashRef, $arrayRef) = @_;
 
@@ -1881,7 +1904,7 @@ sub report {
return 0;
}
my $output = '';
-   if (-t STDOUT && $color) {
+   if ($color) {
if ($level eq 'ERROR') {
$output .= RED;
} elsif ($level eq 'WARNING') {
@@ -1892,10 +1915,10 @@ sub report {
}
$output .= $prefix . $level . ':';
if ($show_types) {
-   $output .= BLUE if (-t STDOUT && $color);
+   $output .= BLUE if ($color);
$output .= "$type:";
}
-   $output .= RESET if (-t STDOUT && $color);
+   $output .= RESET if ($color);
$output .= ' ' . $msg . "\n";
 
if ($showfile) {


Re: [PATCH v2] checkpatch: Change format of --color argument to --color[=WHEN]

2017-06-06 Thread Joe Perches
On Tue, 2017-06-06 at 13:07 -0400, John Brooks wrote:
> The boolean --color argument did not offer the ability to force colourized
> output even if stdout is not a terminal. Change the format of the argument
> to the familiar --color[=WHEN] construct as seen in common Linux utilities
> such as ls and dmesg, which allows the user to specify whether to colourize
> output always, never, or only when the output is a terminal ("auto").
> 
> Because the option is no longer boolean, --nocolor (or --no-color) is no
> longer available. Users of the old negative option should use --color=never
> instead.

It is possible to add --nocolor and --no-color to the
arguments for GetOptions to keep the old behavior intact.

I think this works:
---
 scripts/checkpatch.pl | 35 +--
 1 file changed, 29 insertions(+), 6 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4b9569fa931b..372d541c2c46 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -56,7 +56,7 @@ my $codespell = 0;
 my $codespellfile = "/usr/share/codespell/dictionary.txt";
 my $conststructsfile = "$D/const_structs.checkpatch";
 my $typedefsfile = "";
-my $color = 1;
+my $color = "auto";
 my $allow_c99_comments = 1;
 
 sub help {
@@ -115,7 +115,8 @@ Options:
  (default:/usr/share/codespell/dictionary.txt)
   --codespellfileUse this codespell dictionary
   --typedefsfile Read additional types from this file
-  --colorUse colors when output is STDOUT (default: on)
+  --color[=WHEN] Use colors 'always', 'never', or only when output
+ is a terminal ('auto'). Default is 'auto'.
   -h, --help, --version  display this help and exit
 
 When FILE is - read standard input.
@@ -181,6 +182,14 @@ if (-f $conf) {
unshift(@ARGV, @conf_args) if @conf_args;
 }
 
+# Perl's Getopt::Long allows options to take optional arguments after a space.
+# Prevent --color by itself from consuming other arguments
+foreach (@ARGV) {
+   if ($_ eq "--color" || $_ eq "-color") {
+   $_ = "--color=$color";
+   }
+}
+
 GetOptions(
'q|quiet+'  => \$quiet,
'tree!' => \$tree,
@@ -211,7 +220,9 @@ GetOptions(
'codespell!'=> \$codespell,
'codespellfile=s'   => \$codespellfile,
'typedefsfile=s'=> \$typedefsfile,
-   'color!'=> \$color,
+   'color=s'   => \$color,
+   '-no-color!'=> \$color, #keep old behaviors of -nocolor
+   '-nocolor!' => \$color, #keep old behaviors of -nocolor
'h|help'=> \$help,
'version'   => \$help
 ) or help(1);
@@ -237,6 +248,18 @@ if ($#ARGV < 0) {
push(@ARGV, '-');
 }
 
+if ($color =~ /^[01]$/) {
+   $color = !$color;
+} elsif ($color =~ /^always$/i) {
+   $color = 1;
+} elsif ($color =~ /^never$/i) {
+   $color = 0;
+} elsif ($color =~ /^auto$/i) {
+   $color = (-t STDOUT);
+} else {
+   die "Invalid color mode: $color\n";
+}
+
 sub hash_save_array_words {
my ($hashRef, $arrayRef) = @_;
 
@@ -1881,7 +1904,7 @@ sub report {
return 0;
}
my $output = '';
-   if (-t STDOUT && $color) {
+   if ($color) {
if ($level eq 'ERROR') {
$output .= RED;
} elsif ($level eq 'WARNING') {
@@ -1892,10 +1915,10 @@ sub report {
}
$output .= $prefix . $level . ':';
if ($show_types) {
-   $output .= BLUE if (-t STDOUT && $color);
+   $output .= BLUE if ($color);
$output .= "$type:";
}
-   $output .= RESET if (-t STDOUT && $color);
+   $output .= RESET if ($color);
$output .= ' ' . $msg . "\n";
 
if ($showfile) {


[PATCH 01/16] arm: ecard: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Russell King 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/arm/mach-rpc/ecard.c | 40 +++-
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-rpc/ecard.c b/arch/arm/mach-rpc/ecard.c
index 6b279d037774..f75b8b562d57 100644
--- a/arch/arm/mach-rpc/ecard.c
+++ b/arch/arm/mach-rpc/ecard.c
@@ -761,19 +761,21 @@ static struct expansion_card *__init ecard_alloc_card(int 
type, int slot)
return ec;
 }
 
-static ssize_t ecard_show_irq(struct device *dev, struct device_attribute 
*attr, char *buf)
+static ssize_t irq_show(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
struct expansion_card *ec = ECARD_DEV(dev);
return sprintf(buf, "%u\n", ec->irq);
 }
+static DEVICE_ATTR_RO(irq);
 
-static ssize_t ecard_show_dma(struct device *dev, struct device_attribute 
*attr, char *buf)
+static ssize_t dma_show(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
struct expansion_card *ec = ECARD_DEV(dev);
return sprintf(buf, "%u\n", ec->dma);
 }
+static DEVICE_ATTR_RO(dma);
 
-static ssize_t ecard_show_resources(struct device *dev, struct 
device_attribute *attr, char *buf)
+static ssize_t resource_show(struct device *dev, struct device_attribute 
*attr, char *buf)
 {
struct expansion_card *ec = ECARD_DEV(dev);
char *str = buf;
@@ -787,35 +789,39 @@ static ssize_t ecard_show_resources(struct device *dev, 
struct device_attribute
 
return str - buf;
 }
+static DEVICE_ATTR_RO(resource_show)
 
-static ssize_t ecard_show_vendor(struct device *dev, struct device_attribute 
*attr, char *buf)
+static ssize_t vendor_show(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
struct expansion_card *ec = ECARD_DEV(dev);
return sprintf(buf, "%u\n", ec->cid.manufacturer);
 }
+static DEVICE_ATTR_RO(vendor);
 
-static ssize_t ecard_show_device(struct device *dev, struct device_attribute 
*attr, char *buf)
+static ssize_t device_show(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
struct expansion_card *ec = ECARD_DEV(dev);
return sprintf(buf, "%u\n", ec->cid.product);
 }
+static DEVICE_ATTR_RO(device);
 
-static ssize_t ecard_show_type(struct device *dev, struct device_attribute 
*attr, char *buf)
+static ssize_t type_show(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
struct expansion_card *ec = ECARD_DEV(dev);
return sprintf(buf, "%s\n", ec->easi ? "EASI" : "IOC");
 }
-
-static struct device_attribute ecard_dev_attrs[] = {
-   __ATTR(device,   S_IRUGO, ecard_show_device,NULL),
-   __ATTR(dma,  S_IRUGO, ecard_show_dma,   NULL),
-   __ATTR(irq,  S_IRUGO, ecard_show_irq,   NULL),
-   __ATTR(resource, S_IRUGO, ecard_show_resources, NULL),
-   __ATTR(type, S_IRUGO, ecard_show_type,  NULL),
-   __ATTR(vendor,   S_IRUGO, ecard_show_vendor,NULL),
-   __ATTR_NULL,
+static DEVICE_ATTR_RO(type);
+
+static struct attribute *ecard_dev_attrs[] = {
+   _attr_device.attr,
+   _attr_dma.attr,
+   _attr_irq.attr,
+   _attr_resource.attr,
+   _attr_type.attr,
+   _attr_vendor.attr,
+   NULL,
 };
-
+ATTRIBUTE_GROUPS(ecard_dev);
 
 int ecard_request_resources(struct expansion_card *ec)
 {
@@ -1120,7 +1126,7 @@ static int ecard_match(struct device *_dev, struct 
device_driver *_drv)
 
 struct bus_type ecard_bus_type = {
.name   = "ecard",
-   .dev_attrs  = ecard_dev_attrs,
+   .dev_groups = ecard_dev_groups,
.match  = ecard_match,
.probe  = ecard_drv_probe,
.remove = ecard_drv_remove,
-- 
2.13.0



[PATCH 01/16] arm: ecard: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Russell King 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/arm/mach-rpc/ecard.c | 40 +++-
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/arch/arm/mach-rpc/ecard.c b/arch/arm/mach-rpc/ecard.c
index 6b279d037774..f75b8b562d57 100644
--- a/arch/arm/mach-rpc/ecard.c
+++ b/arch/arm/mach-rpc/ecard.c
@@ -761,19 +761,21 @@ static struct expansion_card *__init ecard_alloc_card(int 
type, int slot)
return ec;
 }
 
-static ssize_t ecard_show_irq(struct device *dev, struct device_attribute 
*attr, char *buf)
+static ssize_t irq_show(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
struct expansion_card *ec = ECARD_DEV(dev);
return sprintf(buf, "%u\n", ec->irq);
 }
+static DEVICE_ATTR_RO(irq);
 
-static ssize_t ecard_show_dma(struct device *dev, struct device_attribute 
*attr, char *buf)
+static ssize_t dma_show(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
struct expansion_card *ec = ECARD_DEV(dev);
return sprintf(buf, "%u\n", ec->dma);
 }
+static DEVICE_ATTR_RO(dma);
 
-static ssize_t ecard_show_resources(struct device *dev, struct 
device_attribute *attr, char *buf)
+static ssize_t resource_show(struct device *dev, struct device_attribute 
*attr, char *buf)
 {
struct expansion_card *ec = ECARD_DEV(dev);
char *str = buf;
@@ -787,35 +789,39 @@ static ssize_t ecard_show_resources(struct device *dev, 
struct device_attribute
 
return str - buf;
 }
+static DEVICE_ATTR_RO(resource_show)
 
-static ssize_t ecard_show_vendor(struct device *dev, struct device_attribute 
*attr, char *buf)
+static ssize_t vendor_show(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
struct expansion_card *ec = ECARD_DEV(dev);
return sprintf(buf, "%u\n", ec->cid.manufacturer);
 }
+static DEVICE_ATTR_RO(vendor);
 
-static ssize_t ecard_show_device(struct device *dev, struct device_attribute 
*attr, char *buf)
+static ssize_t device_show(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
struct expansion_card *ec = ECARD_DEV(dev);
return sprintf(buf, "%u\n", ec->cid.product);
 }
+static DEVICE_ATTR_RO(device);
 
-static ssize_t ecard_show_type(struct device *dev, struct device_attribute 
*attr, char *buf)
+static ssize_t type_show(struct device *dev, struct device_attribute *attr, 
char *buf)
 {
struct expansion_card *ec = ECARD_DEV(dev);
return sprintf(buf, "%s\n", ec->easi ? "EASI" : "IOC");
 }
-
-static struct device_attribute ecard_dev_attrs[] = {
-   __ATTR(device,   S_IRUGO, ecard_show_device,NULL),
-   __ATTR(dma,  S_IRUGO, ecard_show_dma,   NULL),
-   __ATTR(irq,  S_IRUGO, ecard_show_irq,   NULL),
-   __ATTR(resource, S_IRUGO, ecard_show_resources, NULL),
-   __ATTR(type, S_IRUGO, ecard_show_type,  NULL),
-   __ATTR(vendor,   S_IRUGO, ecard_show_vendor,NULL),
-   __ATTR_NULL,
+static DEVICE_ATTR_RO(type);
+
+static struct attribute *ecard_dev_attrs[] = {
+   _attr_device.attr,
+   _attr_dma.attr,
+   _attr_irq.attr,
+   _attr_resource.attr,
+   _attr_type.attr,
+   _attr_vendor.attr,
+   NULL,
 };
-
+ATTRIBUTE_GROUPS(ecard_dev);
 
 int ecard_request_resources(struct expansion_card *ec)
 {
@@ -1120,7 +1126,7 @@ static int ecard_match(struct device *_dev, struct 
device_driver *_drv)
 
 struct bus_type ecard_bus_type = {
.name   = "ecard",
-   .dev_attrs  = ecard_dev_attrs,
+   .dev_groups = ecard_dev_groups,
.match  = ecard_match,
.probe  = ecard_drv_probe,
.remove = ecard_drv_remove,
-- 
2.13.0



[PATCH 00/16] Driver core: remove bus_type.dev_attrs

2017-06-06 Thread Greg Kroah-Hartman
These are some patches that have been in my local trees for years, time
to finally get them flushed out.

The struct bus_type has a dev_attrs field, that duplicates the
dev_groups field (dev_groups is newer).  This patch series moves the few
remaining users of this field over to use dev_groups, and then finally
removes the dev_attrs field from the structure, and the driver core
logic.

Subsystem maintainers, I'm glad to take this series in my driver core
tree, if you just want to ack your respective patches, that's fine with
me.

This series has passed 0-day so I know it at least builds properly :)

thanks,

greg k-h

Greg Kroah-Hartman (16):
  arm: ecard: use dev_groups and not dev_attrs for bus_type
  mips: sgi-ip22: ecard: use dev_groups and not dev_attrs for bus_type
  parisc: parisc_bus_type: use dev_groups and not dev_attrs for bus_type
  amba: use dev_groups and not dev_attrs for bus_type
  rpmsg: use dev_groups and not dev_attrs for bus_type
  sh: superhyway: use dev_groups and not dev_attrs for bus_type
  macintosh: use dev_groups and not dev_attrs for bus_type
  powerpc: ps3: use dev_groups and not dev_attrs for bus_type
  powerpc: ibmebus: use dev_groups and not dev_attrs for bus_type
  powerpc: vio: use dev_groups and not dev_attrs for bus_type
  powerpc: vio_cmo: use dev_groups and not dev_attrs for bus_type
  hwtracing: intel_th: use dev_groups and not dev_attrs for bus_type
  hid: intel-ish-hid: use dev_groups and not dev_attrs for bus_type
  sparc: vio: use dev_groups and not dev_attrs for bus_type
  tty: serdev: use dev_groups and not dev_attrs for bus_type
  driver-core: remove struct bus_type.dev_attrs

 arch/arm/mach-rpc/ecard.c| 40 +++---
 arch/mips/sgi-ip22/ip22-gio.c| 16 +++
 arch/parisc/kernel/drivers.c | 23 ---
 arch/powerpc/platforms/ps3/system-bus.c  | 10 ---
 arch/powerpc/platforms/pseries/ibmebus.c | 16 +++
 arch/powerpc/platforms/pseries/vio.c | 49 +---
 arch/sparc/kernel/vio.c  | 18 +++-
 drivers/amba/bus.c   | 25 
 drivers/base/bus.c   | 37 +---
 drivers/hid/intel-ish-hid/ishtp/bus.c| 10 ---
 drivers/hwtracing/intel_th/core.c|  1 -
 drivers/macintosh/macio_asic.c   |  4 +--
 drivers/macintosh/macio_sysfs.c  | 29 +--
 drivers/rpmsg/rpmsg_core.c   | 23 ---
 drivers/sh/superhyway/superhyway-sysfs.c | 29 ---
 drivers/sh/superhyway/superhyway.c   |  2 +-
 drivers/tty/serdev/core.c| 10 ---
 include/linux/device.h   |  2 --
 include/linux/superhyway.h   |  2 +-
 19 files changed, 188 insertions(+), 158 deletions(-)

-- 
2.13.0



[PATCH 00/16] Driver core: remove bus_type.dev_attrs

2017-06-06 Thread Greg Kroah-Hartman
These are some patches that have been in my local trees for years, time
to finally get them flushed out.

The struct bus_type has a dev_attrs field, that duplicates the
dev_groups field (dev_groups is newer).  This patch series moves the few
remaining users of this field over to use dev_groups, and then finally
removes the dev_attrs field from the structure, and the driver core
logic.

Subsystem maintainers, I'm glad to take this series in my driver core
tree, if you just want to ack your respective patches, that's fine with
me.

This series has passed 0-day so I know it at least builds properly :)

thanks,

greg k-h

Greg Kroah-Hartman (16):
  arm: ecard: use dev_groups and not dev_attrs for bus_type
  mips: sgi-ip22: ecard: use dev_groups and not dev_attrs for bus_type
  parisc: parisc_bus_type: use dev_groups and not dev_attrs for bus_type
  amba: use dev_groups and not dev_attrs for bus_type
  rpmsg: use dev_groups and not dev_attrs for bus_type
  sh: superhyway: use dev_groups and not dev_attrs for bus_type
  macintosh: use dev_groups and not dev_attrs for bus_type
  powerpc: ps3: use dev_groups and not dev_attrs for bus_type
  powerpc: ibmebus: use dev_groups and not dev_attrs for bus_type
  powerpc: vio: use dev_groups and not dev_attrs for bus_type
  powerpc: vio_cmo: use dev_groups and not dev_attrs for bus_type
  hwtracing: intel_th: use dev_groups and not dev_attrs for bus_type
  hid: intel-ish-hid: use dev_groups and not dev_attrs for bus_type
  sparc: vio: use dev_groups and not dev_attrs for bus_type
  tty: serdev: use dev_groups and not dev_attrs for bus_type
  driver-core: remove struct bus_type.dev_attrs

 arch/arm/mach-rpc/ecard.c| 40 +++---
 arch/mips/sgi-ip22/ip22-gio.c| 16 +++
 arch/parisc/kernel/drivers.c | 23 ---
 arch/powerpc/platforms/ps3/system-bus.c  | 10 ---
 arch/powerpc/platforms/pseries/ibmebus.c | 16 +++
 arch/powerpc/platforms/pseries/vio.c | 49 +---
 arch/sparc/kernel/vio.c  | 18 +++-
 drivers/amba/bus.c   | 25 
 drivers/base/bus.c   | 37 +---
 drivers/hid/intel-ish-hid/ishtp/bus.c| 10 ---
 drivers/hwtracing/intel_th/core.c|  1 -
 drivers/macintosh/macio_asic.c   |  4 +--
 drivers/macintosh/macio_sysfs.c  | 29 +--
 drivers/rpmsg/rpmsg_core.c   | 23 ---
 drivers/sh/superhyway/superhyway-sysfs.c | 29 ---
 drivers/sh/superhyway/superhyway.c   |  2 +-
 drivers/tty/serdev/core.c| 10 ---
 include/linux/device.h   |  2 --
 include/linux/superhyway.h   |  2 +-
 19 files changed, 188 insertions(+), 158 deletions(-)

-- 
2.13.0



[PATCH 02/16] mips: sgi-ip22: ecard: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Ralf Baechle 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/mips/sgi-ip22/ip22-gio.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/mips/sgi-ip22/ip22-gio.c b/arch/mips/sgi-ip22/ip22-gio.c
index cdf187600010..b225033aade6 100644
--- a/arch/mips/sgi-ip22/ip22-gio.c
+++ b/arch/mips/sgi-ip22/ip22-gio.c
@@ -169,6 +169,7 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *a,
 
return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
 }
+static DEVICE_ATTR_RO(modalias);
 
 static ssize_t name_show(struct device *dev,
 struct device_attribute *attr, char *buf)
@@ -178,6 +179,7 @@ static ssize_t name_show(struct device *dev,
giodev = to_gio_device(dev);
return sprintf(buf, "%s", giodev->name);
 }
+static DEVICE_ATTR_RO(name);
 
 static ssize_t id_show(struct device *dev,
   struct device_attribute *attr, char *buf)
@@ -187,13 +189,15 @@ static ssize_t id_show(struct device *dev,
giodev = to_gio_device(dev);
return sprintf(buf, "%x", giodev->id.id);
 }
+static DEVICE_ATTR_RO(id);
 
-static struct device_attribute gio_dev_attrs[] = {
-   __ATTR_RO(modalias),
-   __ATTR_RO(name),
-   __ATTR_RO(id),
-   __ATTR_NULL,
+static struct attribute *gio_dev_attrs[] = {
+   _attr_modalias.attr,
+   _attr_name.attr,
+   _attr_id.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(gio_dev);
 
 static int gio_device_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
@@ -374,7 +378,7 @@ static void ip22_check_gio(int slotno, unsigned long addr, 
int irq)
 
 static struct bus_type gio_bus_type = {
.name  = "gio",
-   .dev_attrs = gio_dev_attrs,
+   .dev_groups = gio_dev_groups,
.match = gio_bus_match,
.probe = gio_device_probe,
.remove= gio_device_remove,
-- 
2.13.0



[PATCH 02/11] perf trace: Add mmap alias for s390

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Jiri Olsa 

The s390 architecture maps sys_mmap (nr 90) into sys_old_mmap.  For this
reason perf trace can't find the proper syscall event to get args format
from and displays it wrongly as 'continued'.

To fix that fill the "alias" field with "old_mmap" for trace's mmap record
to get the correct translation.

Before:
 0.042 ( 0.011 ms): vest/43052 fstat(statbuf: 0x389fd90
) = 0
 0.042 ( 0.028 ms): vest/43052  ... [continued]: mmap()) = 0x3fffd6e2000
 0.072 ( 0.025 ms): vest/43052 read(buf: 0x3fffd6e2000, count: 4096
) = 6

After:
 0.045 ( 0.011 ms): fstat(statbuf: 0x38a0930   
) = 0
 0.057 ( 0.018 ms): mmap(arg: 0x38a0858
) = 0x3fffd14a000
 0.076 ( 0.025 ms): read(buf: 0x3fffd14a000, count: 4096   
) = 6

Signed-off-by: Jiri Olsa 
Cc: David Ahern 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20170531113557.19175-1-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index d014350adc52..4b2a5d298197 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -681,6 +681,10 @@ static struct syscall_fmt {
{ .name = "mlockall",   .errmsg = true,
  .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, },
{ .name = "mmap",   .hexret = true,
+/* The standard mmap maps to old_mmap on s390x */
+#if defined(__s390x__)
+   .alias = "old_mmap",
+#endif
  .arg_scnprintf = { [0] = SCA_HEX,   /* addr */
 [2] = SCA_MMAP_PROT, /* prot */
 [3] = SCA_MMAP_FLAGS, /* flags */ }, },
-- 
2.9.4



[PATCH 02/16] mips: sgi-ip22: ecard: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Ralf Baechle 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/mips/sgi-ip22/ip22-gio.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/mips/sgi-ip22/ip22-gio.c b/arch/mips/sgi-ip22/ip22-gio.c
index cdf187600010..b225033aade6 100644
--- a/arch/mips/sgi-ip22/ip22-gio.c
+++ b/arch/mips/sgi-ip22/ip22-gio.c
@@ -169,6 +169,7 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *a,
 
return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
 }
+static DEVICE_ATTR_RO(modalias);
 
 static ssize_t name_show(struct device *dev,
 struct device_attribute *attr, char *buf)
@@ -178,6 +179,7 @@ static ssize_t name_show(struct device *dev,
giodev = to_gio_device(dev);
return sprintf(buf, "%s", giodev->name);
 }
+static DEVICE_ATTR_RO(name);
 
 static ssize_t id_show(struct device *dev,
   struct device_attribute *attr, char *buf)
@@ -187,13 +189,15 @@ static ssize_t id_show(struct device *dev,
giodev = to_gio_device(dev);
return sprintf(buf, "%x", giodev->id.id);
 }
+static DEVICE_ATTR_RO(id);
 
-static struct device_attribute gio_dev_attrs[] = {
-   __ATTR_RO(modalias),
-   __ATTR_RO(name),
-   __ATTR_RO(id),
-   __ATTR_NULL,
+static struct attribute *gio_dev_attrs[] = {
+   _attr_modalias.attr,
+   _attr_name.attr,
+   _attr_id.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(gio_dev);
 
 static int gio_device_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
@@ -374,7 +378,7 @@ static void ip22_check_gio(int slotno, unsigned long addr, 
int irq)
 
 static struct bus_type gio_bus_type = {
.name  = "gio",
-   .dev_attrs = gio_dev_attrs,
+   .dev_groups = gio_dev_groups,
.match = gio_bus_match,
.probe = gio_device_probe,
.remove= gio_device_remove,
-- 
2.13.0



[PATCH 02/11] perf trace: Add mmap alias for s390

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Jiri Olsa 

The s390 architecture maps sys_mmap (nr 90) into sys_old_mmap.  For this
reason perf trace can't find the proper syscall event to get args format
from and displays it wrongly as 'continued'.

To fix that fill the "alias" field with "old_mmap" for trace's mmap record
to get the correct translation.

Before:
 0.042 ( 0.011 ms): vest/43052 fstat(statbuf: 0x389fd90
) = 0
 0.042 ( 0.028 ms): vest/43052  ... [continued]: mmap()) = 0x3fffd6e2000
 0.072 ( 0.025 ms): vest/43052 read(buf: 0x3fffd6e2000, count: 4096
) = 6

After:
 0.045 ( 0.011 ms): fstat(statbuf: 0x38a0930   
) = 0
 0.057 ( 0.018 ms): mmap(arg: 0x38a0858
) = 0x3fffd14a000
 0.076 ( 0.025 ms): read(buf: 0x3fffd14a000, count: 4096   
) = 6

Signed-off-by: Jiri Olsa 
Cc: David Ahern 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20170531113557.19175-1-jo...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-trace.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index d014350adc52..4b2a5d298197 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -681,6 +681,10 @@ static struct syscall_fmt {
{ .name = "mlockall",   .errmsg = true,
  .arg_scnprintf = { [0] = SCA_HEX, /* addr */ }, },
{ .name = "mmap",   .hexret = true,
+/* The standard mmap maps to old_mmap on s390x */
+#if defined(__s390x__)
+   .alias = "old_mmap",
+#endif
  .arg_scnprintf = { [0] = SCA_HEX,   /* addr */
 [2] = SCA_MMAP_PROT, /* prot */
 [3] = SCA_MMAP_FLAGS, /* flags */ }, },
-- 
2.9.4



[PATCH 04/11] perf stat: Only print NMI watchdog hint when enabled

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Andi Kleen 

Only print the NMI watchdog hint when that watchdog it actually enabled.

This avoids printing these unnecessarily.

Signed-off-by: Andi Kleen 
Acked-by: Jiri Olsa 
Link: http://lkml.kernel.org/n/tip-lnw7edxnqsphkmeew857w...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-stat.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index a935b5023732..ad9324d1daf9 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1578,6 +1578,7 @@ static void print_header(int argc, const char **argv)
 static void print_footer(void)
 {
FILE *output = stat_config.output;
+   int n;
 
if (!null_run)
fprintf(output, "\n");
@@ -1590,7 +1591,9 @@ static void print_footer(void)
}
fprintf(output, "\n\n");
 
-   if (print_free_counters_hint)
+   if (print_free_counters_hint &&
+   sysctl__read_int("kernel/nmi_watchdog", ) >= 0 &&
+   n > 0)
fprintf(output,
 "Some events weren't counted. Try disabling the NMI watchdog:\n"
 "  echo 0 > /proc/sys/kernel/nmi_watchdog\n"
-- 
2.9.4



[PATCH 04/11] perf stat: Only print NMI watchdog hint when enabled

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Andi Kleen 

Only print the NMI watchdog hint when that watchdog it actually enabled.

This avoids printing these unnecessarily.

Signed-off-by: Andi Kleen 
Acked-by: Jiri Olsa 
Link: http://lkml.kernel.org/n/tip-lnw7edxnqsphkmeew857w...@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/builtin-stat.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index a935b5023732..ad9324d1daf9 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -1578,6 +1578,7 @@ static void print_header(int argc, const char **argv)
 static void print_footer(void)
 {
FILE *output = stat_config.output;
+   int n;
 
if (!null_run)
fprintf(output, "\n");
@@ -1590,7 +1591,9 @@ static void print_footer(void)
}
fprintf(output, "\n\n");
 
-   if (print_free_counters_hint)
+   if (print_free_counters_hint &&
+   sysctl__read_int("kernel/nmi_watchdog", ) >= 0 &&
+   n > 0)
fprintf(output,
 "Some events weren't counted. Try disabling the NMI watchdog:\n"
 "  echo 0 > /proc/sys/kernel/nmi_watchdog\n"
-- 
2.9.4



[PATCH 03/11] perf annotate: Fix branch instruction with multiple operands

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Kim Phillips 

'perf annotate' is dropping the cr* fields from branch instructions.

Fix it by adding support to display branch instructions having
multiple operands.

Power Arch objdump of int_sqrt:

 20.36 | c04d2694:   subf   r10,r10,r3
   | c04d2698: v bgtcr6,c04d26a0 
  1.82 | c04d269c:   mr r3,r10
 29.18 | c04d26a0:   mr r10,r8
   | c04d26a4: v bgtcr7,c04d26ac 
   | c04d26a8:   mr r10,r7

Power Arch Before Patch:

 20.36 |   subf   r10,r10,r3
   | v bgt40
  1.82 |   mr r3,r10
 29.18 | 40:   mr r10,r8
   | v bgt4c
   |   mr r10,r7

Power Arch After patch:

 20.36 |   subf   r10,r10,r3
   | v bgtcr6,40
  1.82 |   mr r3,r10
 29.18 | 40:   mr r10,r8
   | v bgtcr7,4c
   |   mr r10,r7

Also support AArch64 conditional branch instructions, which can
have up to three operands:

Aarch64 Non-simplified (raw objdump) view:

   │083cd11c: ↑ cbzw0, 083cd100 
Tested-by: Ravi Bangoria 
Reported-by: Anton Blanchard 
Reported-by: Robin Murphy 
Signed-off-by: Kim Phillips 
Cc: Alexander Shishkin 
Cc: Christian Borntraeger 
Cc: Mark Rutland 
Cc: Peter Zijlstra 
Cc: Taeung Song 
Link: http://lkml.kernel.org/r/20170601092959.f60d98912e8a1b66fd1e4...@arm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 33 ++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 07d5608a675f..1367d7e35242 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -239,10 +239,20 @@ static int jump__parse(struct arch *arch __maybe_unused, 
struct ins_operands *op
const char *s = strchr(ops->raw, '+');
const char *c = strchr(ops->raw, ',');
 
-   if (c++ != NULL)
+   /*
+* skip over possible up to 2 operands to get to address, e.g.:
+* tbnz  w0, #26, 083cd190 
+*/
+   if (c++ != NULL) {
ops->target.addr = strtoull(c, NULL, 16);
-   else
+   if (!ops->target.addr) {
+   c = strchr(c, ',');
+   if (c++ != NULL)
+   ops->target.addr = strtoull(c, NULL, 16);
+   }
+   } else {
ops->target.addr = strtoull(ops->raw, NULL, 16);
+   }
 
if (s++ != NULL) {
ops->target.offset = strtoull(s, NULL, 16);
@@ -257,10 +267,27 @@ static int jump__parse(struct arch *arch __maybe_unused, 
struct ins_operands *op
 static int jump__scnprintf(struct ins *ins, char *bf, size_t size,
   struct ins_operands *ops)
 {
+   const char *c = strchr(ops->raw, ',');
+
if (!ops->target.addr || ops->target.offset < 0)
return ins__raw_scnprintf(ins, bf, size, ops);
 
-   return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, 
ops->target.offset);
+   if (c != NULL) {
+   const char *c2 = strchr(c + 1, ',');
+
+   /* check for 3-op insn */
+   if (c2 != NULL)
+   c = c2;
+   c++;
+
+   /* mirror arch objdump's space-after-comma style */
+   if (*c == ' ')
+   c++;
+   }
+
+   

[PATCH 03/11] perf annotate: Fix branch instruction with multiple operands

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Kim Phillips 

'perf annotate' is dropping the cr* fields from branch instructions.

Fix it by adding support to display branch instructions having
multiple operands.

Power Arch objdump of int_sqrt:

 20.36 | c04d2694:   subf   r10,r10,r3
   | c04d2698: v bgtcr6,c04d26a0 
  1.82 | c04d269c:   mr r3,r10
 29.18 | c04d26a0:   mr r10,r8
   | c04d26a4: v bgtcr7,c04d26ac 
   | c04d26a8:   mr r10,r7

Power Arch Before Patch:

 20.36 |   subf   r10,r10,r3
   | v bgt40
  1.82 |   mr r3,r10
 29.18 | 40:   mr r10,r8
   | v bgt4c
   |   mr r10,r7

Power Arch After patch:

 20.36 |   subf   r10,r10,r3
   | v bgtcr6,40
  1.82 |   mr r3,r10
 29.18 | 40:   mr r10,r8
   | v bgtcr7,4c
   |   mr r10,r7

Also support AArch64 conditional branch instructions, which can
have up to three operands:

Aarch64 Non-simplified (raw objdump) view:

   │083cd11c: ↑ cbzw0, 083cd100 
Tested-by: Ravi Bangoria 
Reported-by: Anton Blanchard 
Reported-by: Robin Murphy 
Signed-off-by: Kim Phillips 
Cc: Alexander Shishkin 
Cc: Christian Borntraeger 
Cc: Mark Rutland 
Cc: Peter Zijlstra 
Cc: Taeung Song 
Link: http://lkml.kernel.org/r/20170601092959.f60d98912e8a1b66fd1e4...@arm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 33 ++---
 1 file changed, 30 insertions(+), 3 deletions(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 07d5608a675f..1367d7e35242 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -239,10 +239,20 @@ static int jump__parse(struct arch *arch __maybe_unused, 
struct ins_operands *op
const char *s = strchr(ops->raw, '+');
const char *c = strchr(ops->raw, ',');
 
-   if (c++ != NULL)
+   /*
+* skip over possible up to 2 operands to get to address, e.g.:
+* tbnz  w0, #26, 083cd190 
+*/
+   if (c++ != NULL) {
ops->target.addr = strtoull(c, NULL, 16);
-   else
+   if (!ops->target.addr) {
+   c = strchr(c, ',');
+   if (c++ != NULL)
+   ops->target.addr = strtoull(c, NULL, 16);
+   }
+   } else {
ops->target.addr = strtoull(ops->raw, NULL, 16);
+   }
 
if (s++ != NULL) {
ops->target.offset = strtoull(s, NULL, 16);
@@ -257,10 +267,27 @@ static int jump__parse(struct arch *arch __maybe_unused, 
struct ins_operands *op
 static int jump__scnprintf(struct ins *ins, char *bf, size_t size,
   struct ins_operands *ops)
 {
+   const char *c = strchr(ops->raw, ',');
+
if (!ops->target.addr || ops->target.offset < 0)
return ins__raw_scnprintf(ins, bf, size, ops);
 
-   return scnprintf(bf, size, "%-6.6s %" PRIx64, ins->name, 
ops->target.offset);
+   if (c != NULL) {
+   const char *c2 = strchr(c + 1, ',');
+
+   /* check for 3-op insn */
+   if (c2 != NULL)
+   c = c2;
+   c++;
+
+   /* mirror arch objdump's space-after-comma style */
+   if (*c == ' ')
+   c++;
+   }
+
+   return scnprintf(bf, size, "%-6.6s %.*s%" PRIx64,
+ins->name, c ? c - ops->raw : 0, ops->raw,
+ops->target.offset);
 }
 
 static struct ins_ops jump_ops = {
-- 
2.9.4



[PATCH 05/11] perf header: Set proper module name when build-id event found

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Namhyung Kim 

When perf processes build-id event, it creates DSOs with the build-id.
But it didn't set the module short name (like '[module-name]') so when
processing a kernel mmap event of the module, it cannot found the DSO as
it only checks the short names.

That leads for perf to create a same DSO without the build-id info and
it'll lookup the system path even if the DSO is already in the build-id
cache.  After kernel was updated, perf cannot find the DSO  and cannot
show symbols in it anymore.

You can see this if you have an old data file (w/ old kernel version):

  $ perf report -i perf.data.old -v |& grep scsi_mod
  build id event received for 
/lib/modules/3.19.2-1-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz : 
cafe1ce6ca13a98a5d9ed3425cde249e57a27fc1
  Failed to open /lib/modules/3.19.2-1-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz, 
continuing without symbols
  ...

The second message didn't show the build-id.  With this patch:

  $ perf report -i perf.data.old -v |& grep scsi_mod
  build id event received for 
/lib/modules/3.19.2-1-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz: 
cafe1ce6ca13a98a5d9ed3425cde249e57a27fc1
  /lib/modules/3.19.2-1-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz with build id 
cafe1ce6ca13a98a5d9ed3425cde249e57a27fc1 not found, continuing without symbols
  ...

Now it shows the build-id but still cannot load the symbol table.  This
is a different problem which will be fixed in the next patch.

Signed-off-by: Namhyung Kim 
Acked-by: Jiri Olsa 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Peter Zijlstra 
Cc: kernel-t...@lge.com
Link: http://lkml.kernel.org/r/20170531120105.21731-1-namhy...@kernel.org
[ Fix the build on older compilers (debian <= 8, fedora <= 21, etc) wrt 
kmod_path var init ]
Signed-off-by: Arnaldo Carvalho de Melo 

Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/header.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 314a07151fb7..c40a4d8acf8b 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1469,8 +1469,16 @@ static int __event_process_build_id(struct 
build_id_event *bev,
 
dso__set_build_id(dso, >build_id);
 
-   if (!is_kernel_module(filename, cpumode))
-   dso->kernel = dso_type;
+   if (dso_type != DSO_TYPE_USER) {
+   struct kmod_path m = { .name = NULL, };
+
+   if (!kmod_path__parse_name(, filename) && m.kmod)
+   dso__set_short_name(dso, strdup(m.name), true);
+   else
+   dso->kernel = dso_type;
+
+   free(m.name);
+   }
 
build_id__sprintf(dso->build_id, sizeof(dso->build_id),
  sbuild_id);
-- 
2.9.4



[PATCH 05/11] perf header: Set proper module name when build-id event found

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Namhyung Kim 

When perf processes build-id event, it creates DSOs with the build-id.
But it didn't set the module short name (like '[module-name]') so when
processing a kernel mmap event of the module, it cannot found the DSO as
it only checks the short names.

That leads for perf to create a same DSO without the build-id info and
it'll lookup the system path even if the DSO is already in the build-id
cache.  After kernel was updated, perf cannot find the DSO  and cannot
show symbols in it anymore.

You can see this if you have an old data file (w/ old kernel version):

  $ perf report -i perf.data.old -v |& grep scsi_mod
  build id event received for 
/lib/modules/3.19.2-1-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz : 
cafe1ce6ca13a98a5d9ed3425cde249e57a27fc1
  Failed to open /lib/modules/3.19.2-1-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz, 
continuing without symbols
  ...

The second message didn't show the build-id.  With this patch:

  $ perf report -i perf.data.old -v |& grep scsi_mod
  build id event received for 
/lib/modules/3.19.2-1-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz: 
cafe1ce6ca13a98a5d9ed3425cde249e57a27fc1
  /lib/modules/3.19.2-1-ARCH/kernel/drivers/scsi/scsi_mod.ko.gz with build id 
cafe1ce6ca13a98a5d9ed3425cde249e57a27fc1 not found, continuing without symbols
  ...

Now it shows the build-id but still cannot load the symbol table.  This
is a different problem which will be fixed in the next patch.

Signed-off-by: Namhyung Kim 
Acked-by: Jiri Olsa 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Peter Zijlstra 
Cc: kernel-t...@lge.com
Link: http://lkml.kernel.org/r/20170531120105.21731-1-namhy...@kernel.org
[ Fix the build on older compilers (debian <= 8, fedora <= 21, etc) wrt 
kmod_path var init ]
Signed-off-by: Arnaldo Carvalho de Melo 

Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/header.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 314a07151fb7..c40a4d8acf8b 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1469,8 +1469,16 @@ static int __event_process_build_id(struct 
build_id_event *bev,
 
dso__set_build_id(dso, >build_id);
 
-   if (!is_kernel_module(filename, cpumode))
-   dso->kernel = dso_type;
+   if (dso_type != DSO_TYPE_USER) {
+   struct kmod_path m = { .name = NULL, };
+
+   if (!kmod_path__parse_name(, filename) && m.kmod)
+   dso__set_short_name(dso, strdup(m.name), true);
+   else
+   dso->kernel = dso_type;
+
+   free(m.name);
+   }
 
build_id__sprintf(dso->build_id, sizeof(dso->build_id),
  sbuild_id);
-- 
2.9.4



[PATCH 08/11] perf test: Disable breakpoint signal tests for powerpc

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Jiri Olsa 

The following tests are failing on powerpc:

  # perf test break
  18: Breakpoint overflow signal handler  : FAILED!
  19: Breakpoint overflow sampling: FAILED!

The powerpc kenel so far does not have support to even create
instruction breakpoints using the perf event interface, so those tests
fail early in the config phase.

I added a '->is_supported()' callback to test struct to be able to
disable specific tests. It seems better than putting ifdefs directly to
the test array.

Signed-off-by: Jiri Olsa 
Cc: David Ahern 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20170601205450.GA398@krava
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/bp_signal.c| 14 ++
 tools/perf/tests/builtin-test.c |  7 +++
 tools/perf/tests/tests.h|  3 +++
 3 files changed, 24 insertions(+)

diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c
index e7664fe3bd33..8ba2c4618fe9 100644
--- a/tools/perf/tests/bp_signal.c
+++ b/tools/perf/tests/bp_signal.c
@@ -288,3 +288,17 @@ int test__bp_signal(int subtest __maybe_unused)
return count1 == 1 && overflows == 3 && count2 == 3 && overflows_2 == 3 
&& count3 == 2 ?
TEST_OK : TEST_FAIL;
 }
+
+bool test__bp_signal_is_supported(void)
+{
+/*
+ * The powerpc so far does not have support to even create
+ * instruction breakpoint using the perf event interface.
+ * Once it's there we can release this.
+ */
+#ifdef __powerpc__
+   return false;
+#else
+   return true;
+#endif
+}
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 9e08d297f1a9..3ccfd58a8c3c 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -97,10 +97,12 @@ static struct test generic_tests[] = {
{
.desc = "Breakpoint overflow signal handler",
.func = test__bp_signal,
+   .is_supported = test__bp_signal_is_supported,
},
{
.desc = "Breakpoint overflow sampling",
.func = test__bp_signal_overflow,
+   .is_supported = test__bp_signal_is_supported,
},
{
.desc = "Number of exit events of a simple workload",
@@ -401,6 +403,11 @@ static int __cmd_test(int argc, const char *argv[], struct 
intlist *skiplist)
if (!perf_test__matches(t, curr, argc, argv))
continue;
 
+   if (t->is_supported && !t->is_supported()) {
+   pr_debug("%2d: %-*s: Disabled\n", i, width, t->desc);
+   continue;
+   }
+
pr_info("%2d: %-*s:", i, width, t->desc);
 
if (intlist__find(skiplist, i)) {
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 631859629403..577363809c9b 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -34,6 +34,7 @@ struct test {
int (*get_nr)(void);
const char *(*get_desc)(int subtest);
} subtest;
+   bool (*is_supported)(void);
 };
 
 /* Tests */
@@ -99,6 +100,8 @@ const char *test__clang_subtest_get_desc(int subtest);
 int test__clang_subtest_get_nr(void);
 int test__unit_number__scnprint(int subtest);
 
+bool test__bp_signal_is_supported(void);
+
 #if defined(__arm__) || defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
 struct thread;
-- 
2.9.4



[PATCH 08/11] perf test: Disable breakpoint signal tests for powerpc

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Jiri Olsa 

The following tests are failing on powerpc:

  # perf test break
  18: Breakpoint overflow signal handler  : FAILED!
  19: Breakpoint overflow sampling: FAILED!

The powerpc kenel so far does not have support to even create
instruction breakpoints using the perf event interface, so those tests
fail early in the config phase.

I added a '->is_supported()' callback to test struct to be able to
disable specific tests. It seems better than putting ifdefs directly to
the test array.

Signed-off-by: Jiri Olsa 
Cc: David Ahern 
Cc: Namhyung Kim 
Cc: Peter Zijlstra 
Link: http://lkml.kernel.org/r/20170601205450.GA398@krava
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/tests/bp_signal.c| 14 ++
 tools/perf/tests/builtin-test.c |  7 +++
 tools/perf/tests/tests.h|  3 +++
 3 files changed, 24 insertions(+)

diff --git a/tools/perf/tests/bp_signal.c b/tools/perf/tests/bp_signal.c
index e7664fe3bd33..8ba2c4618fe9 100644
--- a/tools/perf/tests/bp_signal.c
+++ b/tools/perf/tests/bp_signal.c
@@ -288,3 +288,17 @@ int test__bp_signal(int subtest __maybe_unused)
return count1 == 1 && overflows == 3 && count2 == 3 && overflows_2 == 3 
&& count3 == 2 ?
TEST_OK : TEST_FAIL;
 }
+
+bool test__bp_signal_is_supported(void)
+{
+/*
+ * The powerpc so far does not have support to even create
+ * instruction breakpoint using the perf event interface.
+ * Once it's there we can release this.
+ */
+#ifdef __powerpc__
+   return false;
+#else
+   return true;
+#endif
+}
diff --git a/tools/perf/tests/builtin-test.c b/tools/perf/tests/builtin-test.c
index 9e08d297f1a9..3ccfd58a8c3c 100644
--- a/tools/perf/tests/builtin-test.c
+++ b/tools/perf/tests/builtin-test.c
@@ -97,10 +97,12 @@ static struct test generic_tests[] = {
{
.desc = "Breakpoint overflow signal handler",
.func = test__bp_signal,
+   .is_supported = test__bp_signal_is_supported,
},
{
.desc = "Breakpoint overflow sampling",
.func = test__bp_signal_overflow,
+   .is_supported = test__bp_signal_is_supported,
},
{
.desc = "Number of exit events of a simple workload",
@@ -401,6 +403,11 @@ static int __cmd_test(int argc, const char *argv[], struct 
intlist *skiplist)
if (!perf_test__matches(t, curr, argc, argv))
continue;
 
+   if (t->is_supported && !t->is_supported()) {
+   pr_debug("%2d: %-*s: Disabled\n", i, width, t->desc);
+   continue;
+   }
+
pr_info("%2d: %-*s:", i, width, t->desc);
 
if (intlist__find(skiplist, i)) {
diff --git a/tools/perf/tests/tests.h b/tools/perf/tests/tests.h
index 631859629403..577363809c9b 100644
--- a/tools/perf/tests/tests.h
+++ b/tools/perf/tests/tests.h
@@ -34,6 +34,7 @@ struct test {
int (*get_nr)(void);
const char *(*get_desc)(int subtest);
} subtest;
+   bool (*is_supported)(void);
 };
 
 /* Tests */
@@ -99,6 +100,8 @@ const char *test__clang_subtest_get_desc(int subtest);
 int test__clang_subtest_get_nr(void);
 int test__unit_number__scnprint(int subtest);
 
+bool test__bp_signal_is_supported(void);
+
 #if defined(__arm__) || defined(__aarch64__)
 #ifdef HAVE_DWARF_UNWIND_SUPPORT
 struct thread;
-- 
2.9.4



[PATCH 10/11] perf report: Include partial stacks unwound with libdw

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Milian Wolff 

So far the whole stack was thrown away when any error occurred before
the maximum stack depth was unwound. This is actually a very common
scenario though. The stacks that got unwound so far are still
interesting. This removes a large chunk of differences when comparing
perf script output for libunwind and libdw perf unwinding.

E.g. with libunwind:

~
heaptrack_gui  2228 135073.388524: 479408 cycles:
811749ed perf_iterate_ctx ([kernel.kallsyms])
81181662 perf_event_mmap ([kernel.kallsyms])
811cf5ed mmap_region ([kernel.kallsyms])
811cfe6b do_mmap ([kernel.kallsyms])
811b0dca vm_mmap_pgoff ([kernel.kallsyms])
811cdb0c sys_mmap_pgoff ([kernel.kallsyms])
81033acb sys_mmap ([kernel.kallsyms])
81631d37 entry_SYSCALL_64_fastpath ([kernel.kallsyms])
   192ca mmap64 (/usr/lib/ld-2.25.so)
59a9 _dl_map_object_from_fd (/usr/lib/ld-2.25.so)
83d0 _dl_map_object (/usr/lib/ld-2.25.so)
cda1 openaux (/usr/lib/ld-2.25.so)
   1834f _dl_catch_error (/usr/lib/ld-2.25.so)
cfe2 _dl_map_object_deps (/usr/lib/ld-2.25.so)
3481 dl_main (/usr/lib/ld-2.25.so)
   17387 _dl_sysdep_start (/usr/lib/ld-2.25.so)
4d37 _dl_start (/usr/lib/ld-2.25.so)
 d87 _start (/usr/lib/ld-2.25.so)

heaptrack_gui  2228 135073.388677: 611329 cycles:
   1a3e0 strcmp (/usr/lib/ld-2.25.so)
82b2 _dl_map_object (/usr/lib/ld-2.25.so)
cda1 openaux (/usr/lib/ld-2.25.so)
   1834f _dl_catch_error (/usr/lib/ld-2.25.so)
cfe2 _dl_map_object_deps (/usr/lib/ld-2.25.so)
3481 dl_main (/usr/lib/ld-2.25.so)
   17387 _dl_sysdep_start (/usr/lib/ld-2.25.so)
4d37 _dl_start (/usr/lib/ld-2.25.so)
 d87 _start (/usr/lib/ld-2.25.so)
~

With libdw without this patch:

~
heaptrack_gui  2228 135073.388524: 479408 cycles:
811749ed perf_iterate_ctx ([kernel.kallsyms])
81181662 perf_event_mmap ([kernel.kallsyms])
811cf5ed mmap_region ([kernel.kallsyms])
811cfe6b do_mmap ([kernel.kallsyms])
811b0dca vm_mmap_pgoff ([kernel.kallsyms])
811cdb0c sys_mmap_pgoff ([kernel.kallsyms])
81033acb sys_mmap ([kernel.kallsyms])
81631d37 entry_SYSCALL_64_fastpath ([kernel.kallsyms])

heaptrack_gui  2228 135073.388677: 611329 cycles:
~

With this patch applied, the libdw unwinder will produce the same
output as the libunwind unwinder.

Signed-off-by: Milian Wolff 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: http://lkml.kernel.org/r/20170601210021.20046-1-milian.wo...@kdab.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/unwind-libdw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index 943a06291587..b4c20124d2ee 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -224,7 +224,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
 
err = dwfl_getthread_frames(ui->dwfl, thread->tid, frame_callback, ui);
 
-   if (err && !ui->max_stack)
+   if (err && ui->max_stack != max_stack)
err = 0;
 
/*
-- 
2.9.4



[PATCH 10/11] perf report: Include partial stacks unwound with libdw

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Milian Wolff 

So far the whole stack was thrown away when any error occurred before
the maximum stack depth was unwound. This is actually a very common
scenario though. The stacks that got unwound so far are still
interesting. This removes a large chunk of differences when comparing
perf script output for libunwind and libdw perf unwinding.

E.g. with libunwind:

~
heaptrack_gui  2228 135073.388524: 479408 cycles:
811749ed perf_iterate_ctx ([kernel.kallsyms])
81181662 perf_event_mmap ([kernel.kallsyms])
811cf5ed mmap_region ([kernel.kallsyms])
811cfe6b do_mmap ([kernel.kallsyms])
811b0dca vm_mmap_pgoff ([kernel.kallsyms])
811cdb0c sys_mmap_pgoff ([kernel.kallsyms])
81033acb sys_mmap ([kernel.kallsyms])
81631d37 entry_SYSCALL_64_fastpath ([kernel.kallsyms])
   192ca mmap64 (/usr/lib/ld-2.25.so)
59a9 _dl_map_object_from_fd (/usr/lib/ld-2.25.so)
83d0 _dl_map_object (/usr/lib/ld-2.25.so)
cda1 openaux (/usr/lib/ld-2.25.so)
   1834f _dl_catch_error (/usr/lib/ld-2.25.so)
cfe2 _dl_map_object_deps (/usr/lib/ld-2.25.so)
3481 dl_main (/usr/lib/ld-2.25.so)
   17387 _dl_sysdep_start (/usr/lib/ld-2.25.so)
4d37 _dl_start (/usr/lib/ld-2.25.so)
 d87 _start (/usr/lib/ld-2.25.so)

heaptrack_gui  2228 135073.388677: 611329 cycles:
   1a3e0 strcmp (/usr/lib/ld-2.25.so)
82b2 _dl_map_object (/usr/lib/ld-2.25.so)
cda1 openaux (/usr/lib/ld-2.25.so)
   1834f _dl_catch_error (/usr/lib/ld-2.25.so)
cfe2 _dl_map_object_deps (/usr/lib/ld-2.25.so)
3481 dl_main (/usr/lib/ld-2.25.so)
   17387 _dl_sysdep_start (/usr/lib/ld-2.25.so)
4d37 _dl_start (/usr/lib/ld-2.25.so)
 d87 _start (/usr/lib/ld-2.25.so)
~

With libdw without this patch:

~
heaptrack_gui  2228 135073.388524: 479408 cycles:
811749ed perf_iterate_ctx ([kernel.kallsyms])
81181662 perf_event_mmap ([kernel.kallsyms])
811cf5ed mmap_region ([kernel.kallsyms])
811cfe6b do_mmap ([kernel.kallsyms])
811b0dca vm_mmap_pgoff ([kernel.kallsyms])
811cdb0c sys_mmap_pgoff ([kernel.kallsyms])
81033acb sys_mmap ([kernel.kallsyms])
81631d37 entry_SYSCALL_64_fastpath ([kernel.kallsyms])

heaptrack_gui  2228 135073.388677: 611329 cycles:
~

With this patch applied, the libdw unwinder will produce the same
output as the libunwind unwinder.

Signed-off-by: Milian Wolff 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: http://lkml.kernel.org/r/20170601210021.20046-1-milian.wo...@kdab.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/unwind-libdw.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index 943a06291587..b4c20124d2ee 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -224,7 +224,7 @@ int unwind__get_entries(unwind_entry_cb_t cb, void *arg,
 
err = dwfl_getthread_frames(ui->dwfl, thread->tid, frame_callback, ui);
 
-   if (err && !ui->max_stack)
+   if (err && ui->max_stack != max_stack)
err = 0;
 
/*
-- 
2.9.4



[PATCH 09/11] perf annotate: Add missing powerpc triplet

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Kim Phillips 

On an Ubuntu xenial system, 'perf annotate' says to install powerpc
objdump on a system that already has binutils-powerpc-linux-gnu
installed.  Make perf aware of the missing triplet for the
powerpc-linux-gnu target.

Signed-off-by: Kim Phillips 
Cc: Alexander Shishkin 
Cc: He Kuang 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Cc: Ravi Bangoria 
Link: http://lkml.kernel.org/r/20170529142754.7fbfb1152fd8f2663de0e...@arm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/arch/common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c
index 837067f48a4c..6b40e9f01740 100644
--- a/tools/perf/arch/common.c
+++ b/tools/perf/arch/common.c
@@ -26,6 +26,7 @@ const char *const arm64_triplets[] = {
 
 const char *const powerpc_triplets[] = {
"powerpc-unknown-linux-gnu-",
+   "powerpc-linux-gnu-",
"powerpc64-unknown-linux-gnu-",
"powerpc64-linux-gnu-",
"powerpc64le-linux-gnu-",
-- 
2.9.4



[PATCH 09/11] perf annotate: Add missing powerpc triplet

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Kim Phillips 

On an Ubuntu xenial system, 'perf annotate' says to install powerpc
objdump on a system that already has binutils-powerpc-linux-gnu
installed.  Make perf aware of the missing triplet for the
powerpc-linux-gnu target.

Signed-off-by: Kim Phillips 
Cc: Alexander Shishkin 
Cc: He Kuang 
Cc: Jiri Olsa 
Cc: Peter Zijlstra 
Cc: Ravi Bangoria 
Link: http://lkml.kernel.org/r/20170529142754.7fbfb1152fd8f2663de0e...@arm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/arch/common.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/arch/common.c b/tools/perf/arch/common.c
index 837067f48a4c..6b40e9f01740 100644
--- a/tools/perf/arch/common.c
+++ b/tools/perf/arch/common.c
@@ -26,6 +26,7 @@ const char *const arm64_triplets[] = {
 
 const char *const powerpc_triplets[] = {
"powerpc-unknown-linux-gnu-",
+   "powerpc-linux-gnu-",
"powerpc64-unknown-linux-gnu-",
"powerpc64-linux-gnu-",
"powerpc64le-linux-gnu-",
-- 
2.9.4



[PATCH 11/11] perf report: Ensure the perf DSO mapping matches what libdw sees

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Milian Wolff 

In some situations the libdw unwinder stopped working properly.  I.e.
with libunwind we see:

~
heaptrack_gui  2228 135073.400112: 641314 cycles:
e8ed _dl_fixup (/usr/lib/ld-2.25.so)
   15f06 _dl_runtime_resolve_sse_vex (/usr/lib/ld-2.25.so)
   ed94c KDynamicJobTracker::KDynamicJobTracker 
(/home/milian/projects/compiled/kf5/lib64/libKF5KIOWidgets.so.5.35.0)
   608f3 _GLOBAL__sub_I_kdynamicjobtracker.cpp 
(/home/milian/projects/compiled/kf5/lib64/libKF5KIOWidgets.so.5.35.0)
f199 call_init.part.0 (/usr/lib/ld-2.25.so)
f2a5 _dl_init (/usr/lib/ld-2.25.so)
 db9 _dl_start_user (/usr/lib/ld-2.25.so)
~

But with libdw and without this patch this sample is not properly
unwound:

~
heaptrack_gui  2228 135073.400112: 641314 cycles:
e8ed _dl_fixup (/usr/lib/ld-2.25.so)
   15f06 _dl_runtime_resolve_sse_vex (/usr/lib/ld-2.25.so)
   ed94c KDynamicJobTracker::KDynamicJobTracker 
(/home/milian/projects/compiled/kf5/lib64/libKF5KIOWidgets.so.5.35.0)
~

Debug output showed me that libdw found a module for the last frame
address, but it thinks it belongs to /usr/lib/ld-2.25.so. This patch
double-checks what libdw sees and what perf knows. If the mappings
mismatch, we now report the elf known to perf. This fixes the situation
above, and the libdw unwinder produces the same stack as libunwind.

Signed-off-by: Milian Wolff 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: http://lkml.kernel.org/r/20170602143753.16907-1-milian.wo...@kdab.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/unwind-libdw.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index b4c20124d2ee..da45c4be5fb3 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -39,6 +39,14 @@ static int __report_module(struct addr_location *al, u64 ip,
return 0;
 
mod = dwfl_addrmodule(ui->dwfl, ip);
+   if (mod) {
+   Dwarf_Addr s;
+
+   dwfl_module_info(mod, NULL, , NULL, NULL, NULL, NULL, NULL);
+   if (s != al->map->start)
+   mod = 0;
+   }
+
if (!mod)
mod = dwfl_report_elf(ui->dwfl, dso->short_name,
  dso->long_name, -1, al->map->start,
-- 
2.9.4



[PATCH 11/11] perf report: Ensure the perf DSO mapping matches what libdw sees

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Milian Wolff 

In some situations the libdw unwinder stopped working properly.  I.e.
with libunwind we see:

~
heaptrack_gui  2228 135073.400112: 641314 cycles:
e8ed _dl_fixup (/usr/lib/ld-2.25.so)
   15f06 _dl_runtime_resolve_sse_vex (/usr/lib/ld-2.25.so)
   ed94c KDynamicJobTracker::KDynamicJobTracker 
(/home/milian/projects/compiled/kf5/lib64/libKF5KIOWidgets.so.5.35.0)
   608f3 _GLOBAL__sub_I_kdynamicjobtracker.cpp 
(/home/milian/projects/compiled/kf5/lib64/libKF5KIOWidgets.so.5.35.0)
f199 call_init.part.0 (/usr/lib/ld-2.25.so)
f2a5 _dl_init (/usr/lib/ld-2.25.so)
 db9 _dl_start_user (/usr/lib/ld-2.25.so)
~

But with libdw and without this patch this sample is not properly
unwound:

~
heaptrack_gui  2228 135073.400112: 641314 cycles:
e8ed _dl_fixup (/usr/lib/ld-2.25.so)
   15f06 _dl_runtime_resolve_sse_vex (/usr/lib/ld-2.25.so)
   ed94c KDynamicJobTracker::KDynamicJobTracker 
(/home/milian/projects/compiled/kf5/lib64/libKF5KIOWidgets.so.5.35.0)
~

Debug output showed me that libdw found a module for the last frame
address, but it thinks it belongs to /usr/lib/ld-2.25.so. This patch
double-checks what libdw sees and what perf knows. If the mappings
mismatch, we now report the elf known to perf. This fixes the situation
above, and the libdw unwinder produces the same stack as libunwind.

Signed-off-by: Milian Wolff 
Cc: Jiri Olsa 
Cc: Namhyung Kim 
Link: http://lkml.kernel.org/r/20170602143753.16907-1-milian.wo...@kdab.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/unwind-libdw.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/tools/perf/util/unwind-libdw.c b/tools/perf/util/unwind-libdw.c
index b4c20124d2ee..da45c4be5fb3 100644
--- a/tools/perf/util/unwind-libdw.c
+++ b/tools/perf/util/unwind-libdw.c
@@ -39,6 +39,14 @@ static int __report_module(struct addr_location *al, u64 ip,
return 0;
 
mod = dwfl_addrmodule(ui->dwfl, ip);
+   if (mod) {
+   Dwarf_Addr s;
+
+   dwfl_module_info(mod, NULL, , NULL, NULL, NULL, NULL, NULL);
+   if (s != al->map->start)
+   mod = 0;
+   }
+
if (!mod)
mod = dwfl_report_elf(ui->dwfl, dso->short_name,
  dso->long_name, -1, al->map->start,
-- 
2.9.4



[PATCH 07/11] perf symbols: Use correct filename for compressed modules in build-id cache

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Namhyung Kim 

The decompress_kmodule() decompresses kernel modules in order to load
symbols from it.  In the DSO_BINARY_TYPE__BUILD_ID_CACHE case, it needs
the full file path to extract the file extension to determine the
decompression method.  But overwriting 'name' will fail the
decompression since it might point to a non-existing old file.

Instead, use dso->long_name for having the correct extension and use the
real filename to decompress.

In the DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP case, both names should
be the same.  This allows resolving symbols in the old modules.

Before:

  $ perf report -i perf.data.old | grep scsi_mod
 0.00%  cc1  [scsi_mod][k] 0x4aa6
 0.00%  as   [scsi_mod][k] 0x99e1
 0.00%  cc1  [scsi_mod][k] 0x9830
 0.00%  cc1  [scsi_mod][k] 0x1b8f

After:

 0.00%  cc1  [scsi_mod][k] scsi_handle_queue_ramp_up
 0.00%  as   [scsi_mod][k] scsi_sg_alloc
 0.00%  cc1  [scsi_mod][k] scsi_setup_cmnd
 0.00%  cc1  [scsi_mod][k] scsi_get_command

Signed-off-by: Namhyung Kim 
Acked-by: Jiri Olsa 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Peter Zijlstra 
Cc: kernel-t...@lge.com
Link: http://lkml.kernel.org/r/20170531120105.21731-3-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/symbol-elf.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index e7ee47f7377a..1fb2efae4f02 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -649,10 +649,7 @@ static int decompress_kmodule(struct dso *dso, const char 
*name,
type != DSO_BINARY_TYPE__BUILD_ID_CACHE)
return -1;
 
-   if (type == DSO_BINARY_TYPE__BUILD_ID_CACHE)
-   name = dso->long_name;
-
-   if (kmod_path__parse_ext(, name) || !m.comp)
+   if (kmod_path__parse_ext(, dso->long_name) || !m.comp)
return -1;
 
fd = mkstemp(tmpbuf);
-- 
2.9.4



[PATCH 06/11] perf symbols: Set module info when build-id event found

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Namhyung Kim 

Like machine__findnew_module_dso(), it should set necessary info for
kernel modules to find symbol info from the file.  Factor out
dso__set_module_info() to do it.

This is needed for dso__needs_decompress() to detect such DSOs.

Signed-off-by: Namhyung Kim 
Acked-by: Jiri Olsa 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Peter Zijlstra 
Cc: kernel-t...@lge.com
Link: http://lkml.kernel.org/r/20170531120105.21731-2-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/dso.c | 15 +++
 tools/perf/util/dso.h |  3 +++
 tools/perf/util/header.c  |  2 +-
 tools/perf/util/machine.c | 11 +--
 4 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index a96a99d2369f..b27d127cdf68 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -335,6 +335,21 @@ int __kmod_path__parse(struct kmod_path *m, const char 
*path,
return 0;
 }
 
+void dso__set_module_info(struct dso *dso, struct kmod_path *m,
+ struct machine *machine)
+{
+   if (machine__is_host(machine))
+   dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
+   else
+   dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
+
+   /* _KMODULE_COMP should be next to _KMODULE */
+   if (m->kmod && m->comp)
+   dso->symtab_type++;
+
+   dso__set_short_name(dso, strdup(m->name), true);
+}
+
 /*
  * Global list of open DSOs and the counter.
  */
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 12350b171727..5fe2ab5877bd 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -259,6 +259,9 @@ int __kmod_path__parse(struct kmod_path *m, const char 
*path,
 #define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , 
false)
 #define kmod_path__parse_ext(__m, __p)  __kmod_path__parse(__m, __p, false, 
true)
 
+void dso__set_module_info(struct dso *dso, struct kmod_path *m,
+ struct machine *machine);
+
 /*
  * The dso__data_* external interface provides following functions:
  *   dso__data_get_fd
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index c40a4d8acf8b..5cac8d5e009a 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1473,7 +1473,7 @@ static int __event_process_build_id(struct build_id_event 
*bev,
struct kmod_path m = { .name = NULL, };
 
if (!kmod_path__parse_name(, filename) && m.kmod)
-   dso__set_short_name(dso, strdup(m.name), true);
+   dso__set_module_info(dso, , machine);
else
dso->kernel = dso_type;
 
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index d97e014c3df3..d7f31cb0a4cb 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -572,16 +572,7 @@ static struct dso *machine__findnew_module_dso(struct 
machine *machine,
if (dso == NULL)
goto out_unlock;
 
-   if (machine__is_host(machine))
-   dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
-   else
-   dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
-
-   /* _KMODULE_COMP should be next to _KMODULE */
-   if (m->kmod && m->comp)
-   dso->symtab_type++;
-
-   dso__set_short_name(dso, strdup(m->name), true);
+   dso__set_module_info(dso, m, machine);
dso__set_long_name(dso, strdup(filename), true);
}
 
-- 
2.9.4



[PATCH 06/11] perf symbols: Set module info when build-id event found

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Namhyung Kim 

Like machine__findnew_module_dso(), it should set necessary info for
kernel modules to find symbol info from the file.  Factor out
dso__set_module_info() to do it.

This is needed for dso__needs_decompress() to detect such DSOs.

Signed-off-by: Namhyung Kim 
Acked-by: Jiri Olsa 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Peter Zijlstra 
Cc: kernel-t...@lge.com
Link: http://lkml.kernel.org/r/20170531120105.21731-2-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/dso.c | 15 +++
 tools/perf/util/dso.h |  3 +++
 tools/perf/util/header.c  |  2 +-
 tools/perf/util/machine.c | 11 +--
 4 files changed, 20 insertions(+), 11 deletions(-)

diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
index a96a99d2369f..b27d127cdf68 100644
--- a/tools/perf/util/dso.c
+++ b/tools/perf/util/dso.c
@@ -335,6 +335,21 @@ int __kmod_path__parse(struct kmod_path *m, const char 
*path,
return 0;
 }
 
+void dso__set_module_info(struct dso *dso, struct kmod_path *m,
+ struct machine *machine)
+{
+   if (machine__is_host(machine))
+   dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
+   else
+   dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
+
+   /* _KMODULE_COMP should be next to _KMODULE */
+   if (m->kmod && m->comp)
+   dso->symtab_type++;
+
+   dso__set_short_name(dso, strdup(m->name), true);
+}
+
 /*
  * Global list of open DSOs and the counter.
  */
diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
index 12350b171727..5fe2ab5877bd 100644
--- a/tools/perf/util/dso.h
+++ b/tools/perf/util/dso.h
@@ -259,6 +259,9 @@ int __kmod_path__parse(struct kmod_path *m, const char 
*path,
 #define kmod_path__parse_name(__m, __p) __kmod_path__parse(__m, __p, true , 
false)
 #define kmod_path__parse_ext(__m, __p)  __kmod_path__parse(__m, __p, false, 
true)
 
+void dso__set_module_info(struct dso *dso, struct kmod_path *m,
+ struct machine *machine);
+
 /*
  * The dso__data_* external interface provides following functions:
  *   dso__data_get_fd
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index c40a4d8acf8b..5cac8d5e009a 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -1473,7 +1473,7 @@ static int __event_process_build_id(struct build_id_event 
*bev,
struct kmod_path m = { .name = NULL, };
 
if (!kmod_path__parse_name(, filename) && m.kmod)
-   dso__set_short_name(dso, strdup(m.name), true);
+   dso__set_module_info(dso, , machine);
else
dso->kernel = dso_type;
 
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c
index d97e014c3df3..d7f31cb0a4cb 100644
--- a/tools/perf/util/machine.c
+++ b/tools/perf/util/machine.c
@@ -572,16 +572,7 @@ static struct dso *machine__findnew_module_dso(struct 
machine *machine,
if (dso == NULL)
goto out_unlock;
 
-   if (machine__is_host(machine))
-   dso->symtab_type = DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE;
-   else
-   dso->symtab_type = DSO_BINARY_TYPE__GUEST_KMODULE;
-
-   /* _KMODULE_COMP should be next to _KMODULE */
-   if (m->kmod && m->comp)
-   dso->symtab_type++;
-
-   dso__set_short_name(dso, strdup(m->name), true);
+   dso__set_module_info(dso, m, machine);
dso__set_long_name(dso, strdup(filename), true);
}
 
-- 
2.9.4



[PATCH 07/11] perf symbols: Use correct filename for compressed modules in build-id cache

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Namhyung Kim 

The decompress_kmodule() decompresses kernel modules in order to load
symbols from it.  In the DSO_BINARY_TYPE__BUILD_ID_CACHE case, it needs
the full file path to extract the file extension to determine the
decompression method.  But overwriting 'name' will fail the
decompression since it might point to a non-existing old file.

Instead, use dso->long_name for having the correct extension and use the
real filename to decompress.

In the DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP case, both names should
be the same.  This allows resolving symbols in the old modules.

Before:

  $ perf report -i perf.data.old | grep scsi_mod
 0.00%  cc1  [scsi_mod][k] 0x4aa6
 0.00%  as   [scsi_mod][k] 0x99e1
 0.00%  cc1  [scsi_mod][k] 0x9830
 0.00%  cc1  [scsi_mod][k] 0x1b8f

After:

 0.00%  cc1  [scsi_mod][k] scsi_handle_queue_ramp_up
 0.00%  as   [scsi_mod][k] scsi_sg_alloc
 0.00%  cc1  [scsi_mod][k] scsi_setup_cmnd
 0.00%  cc1  [scsi_mod][k] scsi_get_command

Signed-off-by: Namhyung Kim 
Acked-by: Jiri Olsa 
Cc: Andi Kleen 
Cc: David Ahern 
Cc: Peter Zijlstra 
Cc: kernel-t...@lge.com
Link: http://lkml.kernel.org/r/20170531120105.21731-3-namhy...@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/symbol-elf.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c
index e7ee47f7377a..1fb2efae4f02 100644
--- a/tools/perf/util/symbol-elf.c
+++ b/tools/perf/util/symbol-elf.c
@@ -649,10 +649,7 @@ static int decompress_kmodule(struct dso *dso, const char 
*name,
type != DSO_BINARY_TYPE__BUILD_ID_CACHE)
return -1;
 
-   if (type == DSO_BINARY_TYPE__BUILD_ID_CACHE)
-   name = dso->long_name;
-
-   if (kmod_path__parse_ext(, name) || !m.comp)
+   if (kmod_path__parse_ext(, dso->long_name) || !m.comp)
return -1;
 
fd = mkstemp(tmpbuf);
-- 
2.9.4



[PATCH 01/11] perf annotate: Fix failure when filename has special chars

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Ravi Bangoria 

When filename contains special chars, perf annotate fails
with an error:

  $ perf annotate --vmlinux ./vmlinux\(test\) --stdio native_safe_halt
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `objdump  --start-address=0x8184e840
--stop-address=0x8184e848 -l -d --no-show-raw -S -C
./vmlinux(test) 2>/dev/null|grep -v ./vmlinux(test):|expand'

Fix it by surrounding filename in double quotes.

Signed-off-by: Ravi Bangoria 
Cc: Adam Stylinski 
Cc: Alexander Shishkin 
Cc: Christian Borntraeger 
Cc: Peter Zijlstra 
Cc: Taeung Song 
Link: 
http://lkml.kernel.org/r/20170505101417.2117-1-ravi.bango...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 683f8340460c..07d5608a675f 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1429,7 +1429,7 @@ int symbol__disassemble(struct symbol *sym, struct map 
*map, const char *arch_na
snprintf(command, sizeof(command),
 "%s %s%s --start-address=0x%016" PRIx64
 " --stop-address=0x%016" PRIx64
-" -l -d %s %s -C %s 2>/dev/null|grep -v %s:|expand",
+" -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand",
 objdump_path ? objdump_path : "objdump",
 disassembler_style ? "-M " : "",
 disassembler_style ? disassembler_style : "",
-- 
2.9.4



[PATCH 14/16] sparc: vio: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: "David S. Miller" 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/sparc/kernel/vio.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c
index f6bb857254fc..78bf2cc60924 100644
--- a/arch/sparc/kernel/vio.c
+++ b/arch/sparc/kernel/vio.c
@@ -105,6 +105,7 @@ static ssize_t devspec_show(struct device *dev,
 
return sprintf(buf, "%s\n", str);
 }
+static DEVICE_ATTR_RO(devspec);
 
 static ssize_t type_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -112,6 +113,7 @@ static ssize_t type_show(struct device *dev,
struct vio_dev *vdev = to_vio_dev(dev);
return sprintf(buf, "%s\n", vdev->type);
 }
+static DEVICE_ATTR_RO(type);
 
 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 char *buf)
@@ -120,17 +122,19 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *attr,
 
return sprintf(buf, "vio:T%sS%s\n", vdev->type, vdev->compat);
 }
+static DEVICE_ATTR_RO(modalias);
 
-static struct device_attribute vio_dev_attrs[] = {
-   __ATTR_RO(devspec),
-   __ATTR_RO(type),
-   __ATTR_RO(modalias),
-   __ATTR_NULL
-};
+static struct attribute *vio_dev_attrs[] = {
+   _attr_devspec.attr,
+   _attr_type.attr,
+   _attr_modalias.attr,
+   NULL,
+ };
+ATTRIBUTE_GROUPS(vio_dev);
 
 static struct bus_type vio_bus_type = {
.name   = "vio",
-   .dev_attrs  = vio_dev_attrs,
+   .dev_groups = vio_dev_groups,
.uevent = vio_hotplug,
.match  = vio_bus_match,
.probe  = vio_device_probe,
-- 
2.13.0



[GIT PULL 00/11] perf/urgent fixes

2017-06-06 Thread Arnaldo Carvalho de Melo
Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit 6e30437bd42c4d4e9cfc4c40efda00eb83a11cde:

  tools/include: Sync kernel ABI headers with tooling headers (2017-05-24 
09:00:21 +0200)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
tags/perf-urgent-for-mingo-4.12-20170606

for you to fetch changes up to 2538b9e2450ae255337c04356e9e0f8cb9ec48d9:

  perf report: Ensure the perf DSO mapping matches what libdw sees (2017-06-05 
14:18:05 -0300)


perf/urgent fixes:

- Only print NMI watchdog hint in 'perf stat' when it is enabled (Andi Kleen)

- Fix sys_mmap/sys_old_mmap shandling in s390 in 'perf trace' (Jiri Olsa)

- Disable breakpoint signal tests in powerpc, that lacks the perf kernel
  glue to set breakpoint events and makes 'perf test' always fail (Jiri Olsa)

- Fix 'perf annotate' for branch instruction with multiple operands (Kim 
Phillips)

- Add missing powerpc triplet when disassembling with 'objdump' in 'perf
  annotate' (Kim Phillips)

- Do not trow away partial unwound stacks when using libdw, making
  callchains produced with it similar to those produced when linked with
  the other DWARF unwind library supported in perf, libunwind (Milian Wolff)

- Fixes to properly handle kernel modules when processing build-id meta
  events (Namhyung Kim)

- Fix handling of compressed modules in the build-id cache (Namhyung Kim)

- Fix 'perf annotate' failure when filename has special chars (Ravi Bangoria)

Signed-off-by: Arnaldo Carvalho de Melo <a...@redhat.com>


Andi Kleen (1):
  perf stat: Only print NMI watchdog hint when enabled

Jiri Olsa (2):
  perf trace: Add mmap alias for s390
  perf test: Disable breakpoint signal tests for powerpc

Kim Phillips (2):
  perf annotate: Fix branch instruction with multiple operands
  perf annotate: Add missing powerpc triplet

Milian Wolff (2):
  perf report: Include partial stacks unwound with libdw
  perf report: Ensure the perf DSO mapping matches what libdw sees

Namhyung Kim (3):
  perf header: Set proper module name when build-id event found
  perf symbols: Set module info when build-id event found
  perf symbols: Use correct filename for compressed modules in build-id 
cache

Ravi Bangoria (1):
  perf annotate: Fix failure when filename has special chars

 tools/perf/arch/common.c|  1 +
 tools/perf/builtin-stat.c   |  5 -
 tools/perf/builtin-trace.c  |  4 
 tools/perf/tests/bp_signal.c| 14 ++
 tools/perf/tests/builtin-test.c |  7 +++
 tools/perf/tests/tests.h|  3 +++
 tools/perf/util/annotate.c  | 35 +++
 tools/perf/util/dso.c   | 15 +++
 tools/perf/util/dso.h   |  3 +++
 tools/perf/util/header.c| 12 ++--
 tools/perf/util/machine.c   | 11 +--
 tools/perf/util/symbol-elf.c|  5 +
 tools/perf/util/unwind-libdw.c  | 10 +-
 13 files changed, 103 insertions(+), 22 deletions(-)


[PATCH 01/11] perf annotate: Fix failure when filename has special chars

2017-06-06 Thread Arnaldo Carvalho de Melo
From: Ravi Bangoria 

When filename contains special chars, perf annotate fails
with an error:

  $ perf annotate --vmlinux ./vmlinux\(test\) --stdio native_safe_halt
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `objdump  --start-address=0x8184e840
--stop-address=0x8184e848 -l -d --no-show-raw -S -C
./vmlinux(test) 2>/dev/null|grep -v ./vmlinux(test):|expand'

Fix it by surrounding filename in double quotes.

Signed-off-by: Ravi Bangoria 
Cc: Adam Stylinski 
Cc: Alexander Shishkin 
Cc: Christian Borntraeger 
Cc: Peter Zijlstra 
Cc: Taeung Song 
Link: 
http://lkml.kernel.org/r/20170505101417.2117-1-ravi.bango...@linux.vnet.ibm.com
Signed-off-by: Arnaldo Carvalho de Melo 
---
 tools/perf/util/annotate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index 683f8340460c..07d5608a675f 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -1429,7 +1429,7 @@ int symbol__disassemble(struct symbol *sym, struct map 
*map, const char *arch_na
snprintf(command, sizeof(command),
 "%s %s%s --start-address=0x%016" PRIx64
 " --stop-address=0x%016" PRIx64
-" -l -d %s %s -C %s 2>/dev/null|grep -v %s:|expand",
+" -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand",
 objdump_path ? objdump_path : "objdump",
 disassembler_style ? "-M " : "",
 disassembler_style ? disassembler_style : "",
-- 
2.9.4



[PATCH 14/16] sparc: vio: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: "David S. Miller" 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/sparc/kernel/vio.c | 18 +++---
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c
index f6bb857254fc..78bf2cc60924 100644
--- a/arch/sparc/kernel/vio.c
+++ b/arch/sparc/kernel/vio.c
@@ -105,6 +105,7 @@ static ssize_t devspec_show(struct device *dev,
 
return sprintf(buf, "%s\n", str);
 }
+static DEVICE_ATTR_RO(devspec);
 
 static ssize_t type_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -112,6 +113,7 @@ static ssize_t type_show(struct device *dev,
struct vio_dev *vdev = to_vio_dev(dev);
return sprintf(buf, "%s\n", vdev->type);
 }
+static DEVICE_ATTR_RO(type);
 
 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 char *buf)
@@ -120,17 +122,19 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *attr,
 
return sprintf(buf, "vio:T%sS%s\n", vdev->type, vdev->compat);
 }
+static DEVICE_ATTR_RO(modalias);
 
-static struct device_attribute vio_dev_attrs[] = {
-   __ATTR_RO(devspec),
-   __ATTR_RO(type),
-   __ATTR_RO(modalias),
-   __ATTR_NULL
-};
+static struct attribute *vio_dev_attrs[] = {
+   _attr_devspec.attr,
+   _attr_type.attr,
+   _attr_modalias.attr,
+   NULL,
+ };
+ATTRIBUTE_GROUPS(vio_dev);
 
 static struct bus_type vio_bus_type = {
.name   = "vio",
-   .dev_attrs  = vio_dev_attrs,
+   .dev_groups = vio_dev_groups,
.uevent = vio_hotplug,
.match  = vio_bus_match,
.probe  = vio_device_probe,
-- 
2.13.0



[GIT PULL 00/11] perf/urgent fixes

2017-06-06 Thread Arnaldo Carvalho de Melo
Hi Ingo,

Please consider pulling,

- Arnaldo

The following changes since commit 6e30437bd42c4d4e9cfc4c40efda00eb83a11cde:

  tools/include: Sync kernel ABI headers with tooling headers (2017-05-24 
09:00:21 +0200)

are available in the git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux.git 
tags/perf-urgent-for-mingo-4.12-20170606

for you to fetch changes up to 2538b9e2450ae255337c04356e9e0f8cb9ec48d9:

  perf report: Ensure the perf DSO mapping matches what libdw sees (2017-06-05 
14:18:05 -0300)


perf/urgent fixes:

- Only print NMI watchdog hint in 'perf stat' when it is enabled (Andi Kleen)

- Fix sys_mmap/sys_old_mmap shandling in s390 in 'perf trace' (Jiri Olsa)

- Disable breakpoint signal tests in powerpc, that lacks the perf kernel
  glue to set breakpoint events and makes 'perf test' always fail (Jiri Olsa)

- Fix 'perf annotate' for branch instruction with multiple operands (Kim 
Phillips)

- Add missing powerpc triplet when disassembling with 'objdump' in 'perf
  annotate' (Kim Phillips)

- Do not trow away partial unwound stacks when using libdw, making
  callchains produced with it similar to those produced when linked with
  the other DWARF unwind library supported in perf, libunwind (Milian Wolff)

- Fixes to properly handle kernel modules when processing build-id meta
  events (Namhyung Kim)

- Fix handling of compressed modules in the build-id cache (Namhyung Kim)

- Fix 'perf annotate' failure when filename has special chars (Ravi Bangoria)

Signed-off-by: Arnaldo Carvalho de Melo 


Andi Kleen (1):
  perf stat: Only print NMI watchdog hint when enabled

Jiri Olsa (2):
  perf trace: Add mmap alias for s390
  perf test: Disable breakpoint signal tests for powerpc

Kim Phillips (2):
  perf annotate: Fix branch instruction with multiple operands
  perf annotate: Add missing powerpc triplet

Milian Wolff (2):
  perf report: Include partial stacks unwound with libdw
  perf report: Ensure the perf DSO mapping matches what libdw sees

Namhyung Kim (3):
  perf header: Set proper module name when build-id event found
  perf symbols: Set module info when build-id event found
  perf symbols: Use correct filename for compressed modules in build-id 
cache

Ravi Bangoria (1):
  perf annotate: Fix failure when filename has special chars

 tools/perf/arch/common.c|  1 +
 tools/perf/builtin-stat.c   |  5 -
 tools/perf/builtin-trace.c  |  4 
 tools/perf/tests/bp_signal.c| 14 ++
 tools/perf/tests/builtin-test.c |  7 +++
 tools/perf/tests/tests.h|  3 +++
 tools/perf/util/annotate.c  | 35 +++
 tools/perf/util/dso.c   | 15 +++
 tools/perf/util/dso.h   |  3 +++
 tools/perf/util/header.c| 12 ++--
 tools/perf/util/machine.c   | 11 +--
 tools/perf/util/symbol-elf.c|  5 +
 tools/perf/util/unwind-libdw.c  | 10 +-
 13 files changed, 103 insertions(+), 22 deletions(-)


[PATCH 15/16] tty: serdev: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Rob Herring 
Cc: Jiri Slaby 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/tty/serdev/core.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 433de5ea9b02..e454162d8c6e 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -250,11 +250,13 @@ static ssize_t modalias_show(struct device *dev,
 {
return of_device_modalias(dev, buf, PAGE_SIZE);
 }
+DEVICE_ATTR_RO(modalias);
 
-static struct device_attribute serdev_device_attrs[] = {
-   __ATTR_RO(modalias),
-   __ATTR_NULL
+static struct attribute *serdev_device_attrs[] = {
+   _attr_modalias.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(serdev_device);
 
 static struct bus_type serdev_bus_type = {
.name   = "serial",
@@ -262,7 +264,7 @@ static struct bus_type serdev_bus_type = {
.probe  = serdev_drv_probe,
.remove = serdev_drv_remove,
.uevent = serdev_uevent,
-   .dev_attrs  = serdev_device_attrs,
+   .dev_groups = serdev_device_groups,
 };
 
 /**
-- 
2.13.0



[PATCH 07/16] macintosh: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Benjamin Herrenschmidt 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/macintosh/macio_asic.c  |  4 ++--
 drivers/macintosh/macio_sysfs.c | 29 +
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index f757cef293f8..62f541f968f6 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -133,7 +133,7 @@ static int macio_device_resume(struct device * dev)
return 0;
 }
 
-extern struct device_attribute macio_dev_attrs[];
+extern const struct attribute_group *macio_dev_groups[];
 
 struct bus_type macio_bus_type = {
.name   = "macio",
@@ -144,7 +144,7 @@ struct bus_type macio_bus_type = {
.shutdown = macio_device_shutdown,
.suspend= macio_device_suspend,
.resume = macio_device_resume,
-   .dev_attrs = macio_dev_attrs,
+   .dev_groups = macio_dev_groups,
 };
 
 static int __init macio_bus_driver_init(void)
diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c
index 0b1f9c76c68d..2445274f7e4b 100644
--- a/drivers/macintosh/macio_sysfs.c
+++ b/drivers/macintosh/macio_sysfs.c
@@ -10,7 +10,8 @@ field##_show (struct device *dev, struct device_attribute 
*attr,  \
 {  \
struct macio_dev *mdev = to_macio_device (dev); \
return sprintf (buf, format_string, mdev->ofdev.dev.of_node->field); \
-}
+}  \
+static DEVICE_ATTR_RO(field);
 
 static ssize_t
 compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
@@ -37,6 +38,7 @@ compatible_show (struct device *dev, struct device_attribute 
*attr, char *buf)
 
return length;
 }
+static DEVICE_ATTR_RO(compatible);
 
 static ssize_t modalias_show (struct device *dev, struct device_attribute 
*attr,
  char *buf)
@@ -52,15 +54,26 @@ static ssize_t devspec_show(struct device *dev,
ofdev = to_platform_device(dev);
return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name);
 }
+static DEVICE_ATTR_RO(modalias);
+static DEVICE_ATTR_RO(devspec);
 
 macio_config_of_attr (name, "%s\n");
 macio_config_of_attr (type, "%s\n");
 
-struct device_attribute macio_dev_attrs[] = {
-   __ATTR_RO(name),
-   __ATTR_RO(type),
-   __ATTR_RO(compatible),
-   __ATTR_RO(modalias),
-   __ATTR_RO(devspec),
-   __ATTR_NULL
+static struct attribute *macio_dev_attrs[] = {
+   _attr_name.attr,
+   _attr_type.attr,
+   _attr_compatible.attr,
+   _attr_modalias.attr,
+   _attr_devspec.attr,
+   NULL,
+};
+
+static const struct attribute_group macio_dev_group = {
+   .attrs = macio_dev_attrs,
+};
+
+const struct attribute_group *macio_dev_groups[] = {
+   _dev_group,
+   NULL,
 };
-- 
2.13.0



[PATCH 15/16] tty: serdev: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Rob Herring 
Cc: Jiri Slaby 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/tty/serdev/core.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 433de5ea9b02..e454162d8c6e 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -250,11 +250,13 @@ static ssize_t modalias_show(struct device *dev,
 {
return of_device_modalias(dev, buf, PAGE_SIZE);
 }
+DEVICE_ATTR_RO(modalias);
 
-static struct device_attribute serdev_device_attrs[] = {
-   __ATTR_RO(modalias),
-   __ATTR_NULL
+static struct attribute *serdev_device_attrs[] = {
+   _attr_modalias.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(serdev_device);
 
 static struct bus_type serdev_bus_type = {
.name   = "serial",
@@ -262,7 +264,7 @@ static struct bus_type serdev_bus_type = {
.probe  = serdev_drv_probe,
.remove = serdev_drv_remove,
.uevent = serdev_uevent,
-   .dev_attrs  = serdev_device_attrs,
+   .dev_groups = serdev_device_groups,
 };
 
 /**
-- 
2.13.0



[PATCH 07/16] macintosh: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Benjamin Herrenschmidt 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/macintosh/macio_asic.c  |  4 ++--
 drivers/macintosh/macio_sysfs.c | 29 +
 2 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/macintosh/macio_asic.c b/drivers/macintosh/macio_asic.c
index f757cef293f8..62f541f968f6 100644
--- a/drivers/macintosh/macio_asic.c
+++ b/drivers/macintosh/macio_asic.c
@@ -133,7 +133,7 @@ static int macio_device_resume(struct device * dev)
return 0;
 }
 
-extern struct device_attribute macio_dev_attrs[];
+extern const struct attribute_group *macio_dev_groups[];
 
 struct bus_type macio_bus_type = {
.name   = "macio",
@@ -144,7 +144,7 @@ struct bus_type macio_bus_type = {
.shutdown = macio_device_shutdown,
.suspend= macio_device_suspend,
.resume = macio_device_resume,
-   .dev_attrs = macio_dev_attrs,
+   .dev_groups = macio_dev_groups,
 };
 
 static int __init macio_bus_driver_init(void)
diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c
index 0b1f9c76c68d..2445274f7e4b 100644
--- a/drivers/macintosh/macio_sysfs.c
+++ b/drivers/macintosh/macio_sysfs.c
@@ -10,7 +10,8 @@ field##_show (struct device *dev, struct device_attribute 
*attr,  \
 {  \
struct macio_dev *mdev = to_macio_device (dev); \
return sprintf (buf, format_string, mdev->ofdev.dev.of_node->field); \
-}
+}  \
+static DEVICE_ATTR_RO(field);
 
 static ssize_t
 compatible_show (struct device *dev, struct device_attribute *attr, char *buf)
@@ -37,6 +38,7 @@ compatible_show (struct device *dev, struct device_attribute 
*attr, char *buf)
 
return length;
 }
+static DEVICE_ATTR_RO(compatible);
 
 static ssize_t modalias_show (struct device *dev, struct device_attribute 
*attr,
  char *buf)
@@ -52,15 +54,26 @@ static ssize_t devspec_show(struct device *dev,
ofdev = to_platform_device(dev);
return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name);
 }
+static DEVICE_ATTR_RO(modalias);
+static DEVICE_ATTR_RO(devspec);
 
 macio_config_of_attr (name, "%s\n");
 macio_config_of_attr (type, "%s\n");
 
-struct device_attribute macio_dev_attrs[] = {
-   __ATTR_RO(name),
-   __ATTR_RO(type),
-   __ATTR_RO(compatible),
-   __ATTR_RO(modalias),
-   __ATTR_RO(devspec),
-   __ATTR_NULL
+static struct attribute *macio_dev_attrs[] = {
+   _attr_name.attr,
+   _attr_type.attr,
+   _attr_compatible.attr,
+   _attr_modalias.attr,
+   _attr_devspec.attr,
+   NULL,
+};
+
+static const struct attribute_group macio_dev_group = {
+   .attrs = macio_dev_attrs,
+};
+
+const struct attribute_group *macio_dev_groups[] = {
+   _dev_group,
+   NULL,
 };
-- 
2.13.0



[PATCH 06/16] sh: superhyway: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Yoshinori Sato 
Cc: Rich Felker 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/sh/superhyway/superhyway-sysfs.c | 29 +++--
 drivers/sh/superhyway/superhyway.c   |  2 +-
 include/linux/superhyway.h   |  2 +-
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/sh/superhyway/superhyway-sysfs.c 
b/drivers/sh/superhyway/superhyway-sysfs.c
index 55434330867b..774f31b564f8 100644
--- a/drivers/sh/superhyway/superhyway-sysfs.c
+++ b/drivers/sh/superhyway/superhyway-sysfs.c
@@ -19,7 +19,8 @@ static ssize_t name##_show(struct device *dev, struct 
device_attribute *attr, ch
 {  \
struct superhyway_device *s = to_superhyway_device(dev);\
return sprintf(buf, fmt, s->field); \
-}
+}  \
+static DEVICE_ATTR_RO(name);
 
 /* VCR flags */
 superhyway_ro_attr(perr_flags, "0x%02x\n", vcr.perr_flags);
@@ -32,14 +33,22 @@ superhyway_ro_attr(top_mb, "0x%02x\n", vcr.top_mb);
 /* Misc */
 superhyway_ro_attr(resource, "0x%08lx\n", resource[0].start);
 
-struct device_attribute superhyway_dev_attrs[] = {
-   __ATTR_RO(perr_flags),
-   __ATTR_RO(merr_flags),
-   __ATTR_RO(mod_vers),
-   __ATTR_RO(mod_id),
-   __ATTR_RO(bot_mb),
-   __ATTR_RO(top_mb),
-   __ATTR_RO(resource),
-   __ATTR_NULL,
+static struct attribute *superhyway_dev_attrs[] = {
+   _attr_perr_flags.attr,
+   _attr_merr_flags.attr,
+   _attr_mod_vers.attr,
+   _attr_mod_id.attr,
+   _attr_bot_mb.attr,
+   _attr_top_mb.attr,
+   _attr_resource.attr,
+   NULL,
 };
 
+static const struct attribute_group superhyway_dev_group = {
+   .attrs = superhyway_dev_attrs,
+};
+
+const struct attribute_group *superhyway_dev_groups[] = {
+   _dev_group,
+   NULL,
+};
diff --git a/drivers/sh/superhyway/superhyway.c 
b/drivers/sh/superhyway/superhyway.c
index bb1fb7712134..348836b90605 100644
--- a/drivers/sh/superhyway/superhyway.c
+++ b/drivers/sh/superhyway/superhyway.c
@@ -209,7 +209,7 @@ struct bus_type superhyway_bus_type = {
.name   = "superhyway",
.match  = superhyway_bus_match,
 #ifdef CONFIG_SYSFS
-   .dev_attrs  = superhyway_dev_attrs,
+   .dev_groups = superhyway_dev_groups,
 #endif
.probe  = superhyway_device_probe,
.remove = superhyway_device_remove,
diff --git a/include/linux/superhyway.h b/include/linux/superhyway.h
index 17ea468fa362..8d3376775813 100644
--- a/include/linux/superhyway.h
+++ b/include/linux/superhyway.h
@@ -101,7 +101,7 @@ int superhyway_add_device(unsigned long base, struct 
superhyway_device *, struct
 int superhyway_add_devices(struct superhyway_bus *bus, struct 
superhyway_device **devices, int nr_devices);
 
 /* drivers/sh/superhyway/superhyway-sysfs.c */
-extern struct device_attribute superhyway_dev_attrs[];
+extern const struct attribute_group *superhyway_dev_groups[];
 
 #endif /* __LINUX_SUPERHYWAY_H */
 
-- 
2.13.0



[PATCH 09/16] powerpc: ibmebus: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Bart Van Assche 
Cc: Johan Hovold 
Cc: Robin Murphy 
Cc: Rob Herring 
Cc: Lars-Peter Clausen 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/platforms/pseries/ibmebus.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/ibmebus.c 
b/arch/powerpc/platforms/pseries/ibmebus.c
index b363e439ddb9..52146b1356d2 100644
--- a/arch/powerpc/platforms/pseries/ibmebus.c
+++ b/arch/powerpc/platforms/pseries/ibmebus.c
@@ -397,6 +397,7 @@ static ssize_t devspec_show(struct device *dev,
ofdev = to_platform_device(dev);
return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name);
 }
+static DEVICE_ATTR_RO(devspec);
 
 static ssize_t name_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -406,19 +407,22 @@ static ssize_t name_show(struct device *dev,
ofdev = to_platform_device(dev);
return sprintf(buf, "%s\n", ofdev->dev.of_node->name);
 }
+static DEVICE_ATTR_RO(name);
 
 static ssize_t modalias_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
return of_device_modalias(dev, buf, PAGE_SIZE);
 }
+static DEVICE_ATTR_RO(modalias);
 
-static struct device_attribute ibmebus_bus_device_attrs[] = {
-   __ATTR_RO(devspec),
-   __ATTR_RO(name),
-   __ATTR_RO(modalias),
-   __ATTR_NULL
+static struct attribute *ibmebus_bus_device_attrs[] = {
+   _attr_devspec.attr,
+   _attr_name.attr,
+   _attr_modalias.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(ibmebus_bus_device);
 
 struct bus_type ibmebus_bus_type = {
.name  = "ibmebus",
@@ -428,7 +432,7 @@ struct bus_type ibmebus_bus_type = {
.probe = ibmebus_bus_device_probe,
.remove= ibmebus_bus_device_remove,
.shutdown  = ibmebus_bus_device_shutdown,
-   .dev_attrs = ibmebus_bus_device_attrs,
+   .dev_groups = ibmebus_bus_device_groups,
 };
 EXPORT_SYMBOL(ibmebus_bus_type);
 
-- 
2.13.0



[PATCH 06/16] sh: superhyway: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Yoshinori Sato 
Cc: Rich Felker 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/sh/superhyway/superhyway-sysfs.c | 29 +++--
 drivers/sh/superhyway/superhyway.c   |  2 +-
 include/linux/superhyway.h   |  2 +-
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/sh/superhyway/superhyway-sysfs.c 
b/drivers/sh/superhyway/superhyway-sysfs.c
index 55434330867b..774f31b564f8 100644
--- a/drivers/sh/superhyway/superhyway-sysfs.c
+++ b/drivers/sh/superhyway/superhyway-sysfs.c
@@ -19,7 +19,8 @@ static ssize_t name##_show(struct device *dev, struct 
device_attribute *attr, ch
 {  \
struct superhyway_device *s = to_superhyway_device(dev);\
return sprintf(buf, fmt, s->field); \
-}
+}  \
+static DEVICE_ATTR_RO(name);
 
 /* VCR flags */
 superhyway_ro_attr(perr_flags, "0x%02x\n", vcr.perr_flags);
@@ -32,14 +33,22 @@ superhyway_ro_attr(top_mb, "0x%02x\n", vcr.top_mb);
 /* Misc */
 superhyway_ro_attr(resource, "0x%08lx\n", resource[0].start);
 
-struct device_attribute superhyway_dev_attrs[] = {
-   __ATTR_RO(perr_flags),
-   __ATTR_RO(merr_flags),
-   __ATTR_RO(mod_vers),
-   __ATTR_RO(mod_id),
-   __ATTR_RO(bot_mb),
-   __ATTR_RO(top_mb),
-   __ATTR_RO(resource),
-   __ATTR_NULL,
+static struct attribute *superhyway_dev_attrs[] = {
+   _attr_perr_flags.attr,
+   _attr_merr_flags.attr,
+   _attr_mod_vers.attr,
+   _attr_mod_id.attr,
+   _attr_bot_mb.attr,
+   _attr_top_mb.attr,
+   _attr_resource.attr,
+   NULL,
 };
 
+static const struct attribute_group superhyway_dev_group = {
+   .attrs = superhyway_dev_attrs,
+};
+
+const struct attribute_group *superhyway_dev_groups[] = {
+   _dev_group,
+   NULL,
+};
diff --git a/drivers/sh/superhyway/superhyway.c 
b/drivers/sh/superhyway/superhyway.c
index bb1fb7712134..348836b90605 100644
--- a/drivers/sh/superhyway/superhyway.c
+++ b/drivers/sh/superhyway/superhyway.c
@@ -209,7 +209,7 @@ struct bus_type superhyway_bus_type = {
.name   = "superhyway",
.match  = superhyway_bus_match,
 #ifdef CONFIG_SYSFS
-   .dev_attrs  = superhyway_dev_attrs,
+   .dev_groups = superhyway_dev_groups,
 #endif
.probe  = superhyway_device_probe,
.remove = superhyway_device_remove,
diff --git a/include/linux/superhyway.h b/include/linux/superhyway.h
index 17ea468fa362..8d3376775813 100644
--- a/include/linux/superhyway.h
+++ b/include/linux/superhyway.h
@@ -101,7 +101,7 @@ int superhyway_add_device(unsigned long base, struct 
superhyway_device *, struct
 int superhyway_add_devices(struct superhyway_bus *bus, struct 
superhyway_device **devices, int nr_devices);
 
 /* drivers/sh/superhyway/superhyway-sysfs.c */
-extern struct device_attribute superhyway_dev_attrs[];
+extern const struct attribute_group *superhyway_dev_groups[];
 
 #endif /* __LINUX_SUPERHYWAY_H */
 
-- 
2.13.0



[PATCH 09/16] powerpc: ibmebus: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Bart Van Assche 
Cc: Johan Hovold 
Cc: Robin Murphy 
Cc: Rob Herring 
Cc: Lars-Peter Clausen 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/platforms/pseries/ibmebus.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/ibmebus.c 
b/arch/powerpc/platforms/pseries/ibmebus.c
index b363e439ddb9..52146b1356d2 100644
--- a/arch/powerpc/platforms/pseries/ibmebus.c
+++ b/arch/powerpc/platforms/pseries/ibmebus.c
@@ -397,6 +397,7 @@ static ssize_t devspec_show(struct device *dev,
ofdev = to_platform_device(dev);
return sprintf(buf, "%s\n", ofdev->dev.of_node->full_name);
 }
+static DEVICE_ATTR_RO(devspec);
 
 static ssize_t name_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -406,19 +407,22 @@ static ssize_t name_show(struct device *dev,
ofdev = to_platform_device(dev);
return sprintf(buf, "%s\n", ofdev->dev.of_node->name);
 }
+static DEVICE_ATTR_RO(name);
 
 static ssize_t modalias_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
return of_device_modalias(dev, buf, PAGE_SIZE);
 }
+static DEVICE_ATTR_RO(modalias);
 
-static struct device_attribute ibmebus_bus_device_attrs[] = {
-   __ATTR_RO(devspec),
-   __ATTR_RO(name),
-   __ATTR_RO(modalias),
-   __ATTR_NULL
+static struct attribute *ibmebus_bus_device_attrs[] = {
+   _attr_devspec.attr,
+   _attr_name.attr,
+   _attr_modalias.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(ibmebus_bus_device);
 
 struct bus_type ibmebus_bus_type = {
.name  = "ibmebus",
@@ -428,7 +432,7 @@ struct bus_type ibmebus_bus_type = {
.probe = ibmebus_bus_device_probe,
.remove= ibmebus_bus_device_remove,
.shutdown  = ibmebus_bus_device_shutdown,
-   .dev_attrs = ibmebus_bus_device_attrs,
+   .dev_groups = ibmebus_bus_device_groups,
 };
 EXPORT_SYMBOL(ibmebus_bus_type);
 
-- 
2.13.0



[PATCH 03/16] parisc: parisc_bus_type: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: "James E.J. Bottomley" 
Cc: Helge Deller 
Cc: Bart Van Assche 
Cc: Doug Ledford 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/parisc/kernel/drivers.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c
index fa78419100c8..d8f77358e2ba 100644
--- a/arch/parisc/kernel/drivers.c
+++ b/arch/parisc/kernel/drivers.c
@@ -575,7 +575,8 @@ static ssize_t name##_show(struct device *dev, struct 
device_attribute *attr, ch
 {  \
struct parisc_device *padev = to_parisc_device(dev);\
return sprintf(buf, format_string, padev->field);   \
-}
+}  \
+static DEVICE_ATTR_RO(name);
 
 #define pa_dev_attr_id(field, format) pa_dev_attr(field, id.field, format)
 
@@ -589,22 +590,24 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *attr,
 {
return make_modalias(dev, buf);
 }
+static DEVICE_ATTR_RO(modalias);
 
-static struct device_attribute parisc_device_attrs[] = {
-   __ATTR_RO(irq),
-   __ATTR_RO(hw_type),
-   __ATTR_RO(rev),
-   __ATTR_RO(hversion),
-   __ATTR_RO(sversion),
-   __ATTR_RO(modalias),
-   __ATTR_NULL,
+static struct attribute *parisc_device_attrs[] = {
+   _attr_irq.attr,
+   _attr_hw_type.attr,
+   _attr_rev.attr,
+   _attr_hversion.attr,
+   _attr_sversion.attr,
+   _attr_modalias.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(parisc_device);
 
 struct bus_type parisc_bus_type = {
.name = "parisc",
.match = parisc_generic_match,
.uevent = parisc_uevent,
-   .dev_attrs = parisc_device_attrs,
+   .dev_groups = parisc_device_groups,
.probe = parisc_driver_probe,
.remove = parisc_driver_remove,
 };
-- 
2.13.0



[PATCH 03/16] parisc: parisc_bus_type: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: "James E.J. Bottomley" 
Cc: Helge Deller 
Cc: Bart Van Assche 
Cc: Doug Ledford 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/parisc/kernel/drivers.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c
index fa78419100c8..d8f77358e2ba 100644
--- a/arch/parisc/kernel/drivers.c
+++ b/arch/parisc/kernel/drivers.c
@@ -575,7 +575,8 @@ static ssize_t name##_show(struct device *dev, struct 
device_attribute *attr, ch
 {  \
struct parisc_device *padev = to_parisc_device(dev);\
return sprintf(buf, format_string, padev->field);   \
-}
+}  \
+static DEVICE_ATTR_RO(name);
 
 #define pa_dev_attr_id(field, format) pa_dev_attr(field, id.field, format)
 
@@ -589,22 +590,24 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *attr,
 {
return make_modalias(dev, buf);
 }
+static DEVICE_ATTR_RO(modalias);
 
-static struct device_attribute parisc_device_attrs[] = {
-   __ATTR_RO(irq),
-   __ATTR_RO(hw_type),
-   __ATTR_RO(rev),
-   __ATTR_RO(hversion),
-   __ATTR_RO(sversion),
-   __ATTR_RO(modalias),
-   __ATTR_NULL,
+static struct attribute *parisc_device_attrs[] = {
+   _attr_irq.attr,
+   _attr_hw_type.attr,
+   _attr_rev.attr,
+   _attr_hversion.attr,
+   _attr_sversion.attr,
+   _attr_modalias.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(parisc_device);
 
 struct bus_type parisc_bus_type = {
.name = "parisc",
.match = parisc_generic_match,
.uevent = parisc_uevent,
-   .dev_attrs = parisc_device_attrs,
+   .dev_groups = parisc_device_groups,
.probe = parisc_driver_probe,
.remove = parisc_driver_remove,
 };
-- 
2.13.0



[PATCH 10/16] powerpc: vio: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Vineet Gupta 
Cc: Bart Van Assche 
Cc: Robin Murphy 
Cc: Joerg Roedel 
Cc: Johan Hovold 
Cc: Alexey Kardashevskiy 
Cc: Krzysztof Kozlowski 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/platforms/pseries/vio.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/vio.c 
b/arch/powerpc/platforms/pseries/vio.c
index 28b09fd797ec..fd6595598662 100644
--- a/arch/powerpc/platforms/pseries/vio.c
+++ b/arch/powerpc/platforms/pseries/vio.c
@@ -1537,6 +1537,7 @@ static ssize_t name_show(struct device *dev,
 {
return sprintf(buf, "%s\n", to_vio_dev(dev)->name);
 }
+static DEVICE_ATTR_RO(name);
 
 static ssize_t devspec_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -1545,6 +1546,7 @@ static ssize_t devspec_show(struct device *dev,
 
return sprintf(buf, "%s\n", of_node_full_name(of_node));
 }
+static DEVICE_ATTR_RO(devspec);
 
 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 char *buf)
@@ -1566,6 +1568,7 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *attr,
 
return sprintf(buf, "vio:T%sS%s\n", vio_dev->type, cp);
 }
+static DEVICE_ATTR_RO(modalias);
 
 static struct device_attribute vio_dev_attrs[] = {
__ATTR_RO(name),
@@ -1573,6 +1576,13 @@ static struct device_attribute vio_dev_attrs[] = {
__ATTR_RO(modalias),
__ATTR_NULL
 };
+static struct attribute *vio_dev_attrs[] = {
+   _attr_name.attr,
+   _attr_devspec.attr,
+   _attr_modalias.attr,
+   NULL,
+};
+ATTRIBUTE_GROUPS(vio_dev);
 
 void vio_unregister_device(struct vio_dev *viodev)
 {
@@ -1608,7 +1618,7 @@ static int vio_hotplug(struct device *dev, struct 
kobj_uevent_env *env)
 
 struct bus_type vio_bus_type = {
.name = "vio",
-   .dev_attrs = vio_dev_attrs,
+   .dev_groups = vio_dev_groups,
.uevent = vio_hotplug,
.match = vio_bus_match,
.probe = vio_bus_probe,
-- 
2.13.0



[PATCH 12/16] hwtracing: intel_th: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Alexander Shishkin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/hwtracing/intel_th/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/hwtracing/intel_th/core.c 
b/drivers/hwtracing/intel_th/core.c
index 7563eceeaaea..8da567abc0ce 100644
--- a/drivers/hwtracing/intel_th/core.c
+++ b/drivers/hwtracing/intel_th/core.c
@@ -139,7 +139,6 @@ static int intel_th_remove(struct device *dev)
 
 static struct bus_type intel_th_bus = {
.name   = "intel_th",
-   .dev_attrs  = NULL,
.match  = intel_th_match,
.probe  = intel_th_probe,
.remove = intel_th_remove,
-- 
2.13.0



[PATCH 10/16] powerpc: vio: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Vineet Gupta 
Cc: Bart Van Assche 
Cc: Robin Murphy 
Cc: Joerg Roedel 
Cc: Johan Hovold 
Cc: Alexey Kardashevskiy 
Cc: Krzysztof Kozlowski 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/platforms/pseries/vio.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/platforms/pseries/vio.c 
b/arch/powerpc/platforms/pseries/vio.c
index 28b09fd797ec..fd6595598662 100644
--- a/arch/powerpc/platforms/pseries/vio.c
+++ b/arch/powerpc/platforms/pseries/vio.c
@@ -1537,6 +1537,7 @@ static ssize_t name_show(struct device *dev,
 {
return sprintf(buf, "%s\n", to_vio_dev(dev)->name);
 }
+static DEVICE_ATTR_RO(name);
 
 static ssize_t devspec_show(struct device *dev,
struct device_attribute *attr, char *buf)
@@ -1545,6 +1546,7 @@ static ssize_t devspec_show(struct device *dev,
 
return sprintf(buf, "%s\n", of_node_full_name(of_node));
 }
+static DEVICE_ATTR_RO(devspec);
 
 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 char *buf)
@@ -1566,6 +1568,7 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *attr,
 
return sprintf(buf, "vio:T%sS%s\n", vio_dev->type, cp);
 }
+static DEVICE_ATTR_RO(modalias);
 
 static struct device_attribute vio_dev_attrs[] = {
__ATTR_RO(name),
@@ -1573,6 +1576,13 @@ static struct device_attribute vio_dev_attrs[] = {
__ATTR_RO(modalias),
__ATTR_NULL
 };
+static struct attribute *vio_dev_attrs[] = {
+   _attr_name.attr,
+   _attr_devspec.attr,
+   _attr_modalias.attr,
+   NULL,
+};
+ATTRIBUTE_GROUPS(vio_dev);
 
 void vio_unregister_device(struct vio_dev *viodev)
 {
@@ -1608,7 +1618,7 @@ static int vio_hotplug(struct device *dev, struct 
kobj_uevent_env *env)
 
 struct bus_type vio_bus_type = {
.name = "vio",
-   .dev_attrs = vio_dev_attrs,
+   .dev_groups = vio_dev_groups,
.uevent = vio_hotplug,
.match = vio_bus_match,
.probe = vio_bus_probe,
-- 
2.13.0



[PATCH 12/16] hwtracing: intel_th: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Alexander Shishkin 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/hwtracing/intel_th/core.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/hwtracing/intel_th/core.c 
b/drivers/hwtracing/intel_th/core.c
index 7563eceeaaea..8da567abc0ce 100644
--- a/drivers/hwtracing/intel_th/core.c
+++ b/drivers/hwtracing/intel_th/core.c
@@ -139,7 +139,6 @@ static int intel_th_remove(struct device *dev)
 
 static struct bus_type intel_th_bus = {
.name   = "intel_th",
-   .dev_attrs  = NULL,
.match  = intel_th_match,
.probe  = intel_th_probe,
.remove = intel_th_remove,
-- 
2.13.0



[PATCH 11/16] powerpc: vio_cmo: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Vineet Gupta 
Cc: Bart Van Assche 
Cc: Robin Murphy 
Cc: Joerg Roedel 
Cc: Johan Hovold 
Cc: Alexey Kardashevskiy 
Cc: Krzysztof Kozlowski 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/platforms/pseries/vio.c | 37 +---
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/vio.c 
b/arch/powerpc/platforms/pseries/vio.c
index fd6595598662..176edf422867 100644
--- a/arch/powerpc/platforms/pseries/vio.c
+++ b/arch/powerpc/platforms/pseries/vio.c
@@ -948,7 +948,7 @@ static void vio_cmo_bus_init(void)
 /* sysfs device functions and data structures for CMO */
 
 #define viodev_cmo_rd_attr(name)\
-static ssize_t viodev_cmo_##name##_show(struct device *dev, \
+static ssize_t cmo_##name##_show(struct device *dev,\
 struct device_attribute *attr,  \
  char *buf) \
 {   \
@@ -962,7 +962,7 @@ static ssize_t viodev_cmo_allocs_failed_show(struct device 
*dev,
return sprintf(buf, "%d\n", atomic_read(>cmo.allocs_failed));
 }
 
-static ssize_t viodev_cmo_allocs_failed_reset(struct device *dev,
+static ssize_t cmo_allocs_failed_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
struct vio_dev *viodev = to_vio_dev(dev);
@@ -970,7 +970,7 @@ static ssize_t viodev_cmo_allocs_failed_reset(struct device 
*dev,
return count;
 }
 
-static ssize_t viodev_cmo_desired_set(struct device *dev,
+static ssize_t cmo_desired_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
struct vio_dev *viodev = to_vio_dev(dev);
@@ -993,18 +993,25 @@ static ssize_t name_show(struct device *, struct 
device_attribute *, char *);
 static ssize_t devspec_show(struct device *, struct device_attribute *, char 
*);
 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 char *buf);
-static struct device_attribute vio_cmo_dev_attrs[] = {
-   __ATTR_RO(name),
-   __ATTR_RO(devspec),
-   __ATTR_RO(modalias),
-   __ATTR(cmo_desired,   S_IWUSR|S_IRUSR|S_IWGRP|S_IRGRP|S_IROTH,
-  viodev_cmo_desired_show, viodev_cmo_desired_set),
-   __ATTR(cmo_entitled,  S_IRUGO, viodev_cmo_entitled_show,  NULL),
-   __ATTR(cmo_allocated, S_IRUGO, viodev_cmo_allocated_show, NULL),
-   __ATTR(cmo_allocs_failed, S_IWUSR|S_IRUSR|S_IWGRP|S_IRGRP|S_IROTH,
-  viodev_cmo_allocs_failed_show, viodev_cmo_allocs_failed_reset),
-   __ATTR_NULL
+static DEVICE_ATTR_RO(name);
+static DEVICE_ATTR_RO(devspec);
+static DEVICE_ATTR_RO(modalias);
+static DEVICE_ATTR_RO(cmo_entitled);
+static DEVICE_ATTR_RO(cmo_allocated);
+static DEVICE_ATTR_RW(cmo_desired);
+static DEVICE_ATTR_RW(cmo_allocs_failed);
+
+static struct attribute *vio_cmo_dev_attrs[] = {
+   _attr_name.attr,
+   _attr_devspec.attr,
+   _attr_modalias.attr,
+   _attr_cmo_entitled.attr,
+   _attr_cmo_allocated.attr,
+   _attr_cmo_desired.attr,
+   _attr_cmo_allocs_failed.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(vio_cmo_dev);
 
 /* sysfs bus functions and data structures for CMO */
 
@@ -1066,7 +1073,7 @@ ATTRIBUTE_GROUPS(vio_bus);
 
 static void vio_cmo_sysfs_init(void)
 {
-   vio_bus_type.dev_attrs = vio_cmo_dev_attrs;
+   vio_bus_type.dev_groups = vio_cmo_dev_groups;
vio_bus_type.bus_groups = vio_bus_groups;
 }
 #else /* CONFIG_PPC_SMLPAR */
-- 
2.13.0



[PATCH 11/16] powerpc: vio_cmo: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Vineet Gupta 
Cc: Bart Van Assche 
Cc: Robin Murphy 
Cc: Joerg Roedel 
Cc: Johan Hovold 
Cc: Alexey Kardashevskiy 
Cc: Krzysztof Kozlowski 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/platforms/pseries/vio.c | 37 +---
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/platforms/pseries/vio.c 
b/arch/powerpc/platforms/pseries/vio.c
index fd6595598662..176edf422867 100644
--- a/arch/powerpc/platforms/pseries/vio.c
+++ b/arch/powerpc/platforms/pseries/vio.c
@@ -948,7 +948,7 @@ static void vio_cmo_bus_init(void)
 /* sysfs device functions and data structures for CMO */
 
 #define viodev_cmo_rd_attr(name)\
-static ssize_t viodev_cmo_##name##_show(struct device *dev, \
+static ssize_t cmo_##name##_show(struct device *dev,\
 struct device_attribute *attr,  \
  char *buf) \
 {   \
@@ -962,7 +962,7 @@ static ssize_t viodev_cmo_allocs_failed_show(struct device 
*dev,
return sprintf(buf, "%d\n", atomic_read(>cmo.allocs_failed));
 }
 
-static ssize_t viodev_cmo_allocs_failed_reset(struct device *dev,
+static ssize_t cmo_allocs_failed_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
struct vio_dev *viodev = to_vio_dev(dev);
@@ -970,7 +970,7 @@ static ssize_t viodev_cmo_allocs_failed_reset(struct device 
*dev,
return count;
 }
 
-static ssize_t viodev_cmo_desired_set(struct device *dev,
+static ssize_t cmo_desired_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
 {
struct vio_dev *viodev = to_vio_dev(dev);
@@ -993,18 +993,25 @@ static ssize_t name_show(struct device *, struct 
device_attribute *, char *);
 static ssize_t devspec_show(struct device *, struct device_attribute *, char 
*);
 static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 char *buf);
-static struct device_attribute vio_cmo_dev_attrs[] = {
-   __ATTR_RO(name),
-   __ATTR_RO(devspec),
-   __ATTR_RO(modalias),
-   __ATTR(cmo_desired,   S_IWUSR|S_IRUSR|S_IWGRP|S_IRGRP|S_IROTH,
-  viodev_cmo_desired_show, viodev_cmo_desired_set),
-   __ATTR(cmo_entitled,  S_IRUGO, viodev_cmo_entitled_show,  NULL),
-   __ATTR(cmo_allocated, S_IRUGO, viodev_cmo_allocated_show, NULL),
-   __ATTR(cmo_allocs_failed, S_IWUSR|S_IRUSR|S_IWGRP|S_IRGRP|S_IROTH,
-  viodev_cmo_allocs_failed_show, viodev_cmo_allocs_failed_reset),
-   __ATTR_NULL
+static DEVICE_ATTR_RO(name);
+static DEVICE_ATTR_RO(devspec);
+static DEVICE_ATTR_RO(modalias);
+static DEVICE_ATTR_RO(cmo_entitled);
+static DEVICE_ATTR_RO(cmo_allocated);
+static DEVICE_ATTR_RW(cmo_desired);
+static DEVICE_ATTR_RW(cmo_allocs_failed);
+
+static struct attribute *vio_cmo_dev_attrs[] = {
+   _attr_name.attr,
+   _attr_devspec.attr,
+   _attr_modalias.attr,
+   _attr_cmo_entitled.attr,
+   _attr_cmo_allocated.attr,
+   _attr_cmo_desired.attr,
+   _attr_cmo_allocs_failed.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(vio_cmo_dev);
 
 /* sysfs bus functions and data structures for CMO */
 
@@ -1066,7 +1073,7 @@ ATTRIBUTE_GROUPS(vio_bus);
 
 static void vio_cmo_sysfs_init(void)
 {
-   vio_bus_type.dev_attrs = vio_cmo_dev_attrs;
+   vio_bus_type.dev_groups = vio_cmo_dev_groups;
vio_bus_type.bus_groups = vio_bus_groups;
 }
 #else /* CONFIG_PPC_SMLPAR */
-- 
2.13.0



[PATCH 08/16] powerpc: ps3: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Geoff Levand 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/platforms/ps3/system-bus.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/system-bus.c 
b/arch/powerpc/platforms/ps3/system-bus.c
index 2d2e5f80a3d3..3e98b4ea3df9 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -471,11 +471,13 @@ static ssize_t modalias_show(struct device *_dev, struct 
device_attribute *a,
 
return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
 }
+static DEVICE_ATTR_RO(modalias);
 
-static struct device_attribute ps3_system_bus_dev_attrs[] = {
-   __ATTR_RO(modalias),
-   __ATTR_NULL,
+static struct attribute *ps3_system_bus_dev_attrs[] = {
+   _attr_modalias.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(ps3_system_bus);
 
 struct bus_type ps3_system_bus_type = {
.name = "ps3_system_bus",
@@ -484,7 +486,7 @@ struct bus_type ps3_system_bus_type = {
.probe = ps3_system_bus_probe,
.remove = ps3_system_bus_remove,
.shutdown = ps3_system_bus_shutdown,
-   .dev_attrs = ps3_system_bus_dev_attrs,
+   .dev_groups = ps3_system_bus_dev_groups,
 };
 
 static int __init ps3_system_bus_init(void)
-- 
2.13.0



[PATCH 08/16] powerpc: ps3: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Geoff Levand 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/powerpc/platforms/ps3/system-bus.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/platforms/ps3/system-bus.c 
b/arch/powerpc/platforms/ps3/system-bus.c
index 2d2e5f80a3d3..3e98b4ea3df9 100644
--- a/arch/powerpc/platforms/ps3/system-bus.c
+++ b/arch/powerpc/platforms/ps3/system-bus.c
@@ -471,11 +471,13 @@ static ssize_t modalias_show(struct device *_dev, struct 
device_attribute *a,
 
return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
 }
+static DEVICE_ATTR_RO(modalias);
 
-static struct device_attribute ps3_system_bus_dev_attrs[] = {
-   __ATTR_RO(modalias),
-   __ATTR_NULL,
+static struct attribute *ps3_system_bus_dev_attrs[] = {
+   _attr_modalias.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(ps3_system_bus);
 
 struct bus_type ps3_system_bus_type = {
.name = "ps3_system_bus",
@@ -484,7 +486,7 @@ struct bus_type ps3_system_bus_type = {
.probe = ps3_system_bus_probe,
.remove = ps3_system_bus_remove,
.shutdown = ps3_system_bus_shutdown,
-   .dev_attrs = ps3_system_bus_dev_attrs,
+   .dev_groups = ps3_system_bus_dev_groups,
 };
 
 static int __init ps3_system_bus_init(void)
-- 
2.13.0



[PATCH 05/16] rpmsg: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Ohad Ben-Cohen 
Cc: Bjorn Andersson 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/rpmsg/rpmsg_core.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
index 600f5f9f7431..ad3d2a9df287 100644
--- a/drivers/rpmsg/rpmsg_core.c
+++ b/drivers/rpmsg/rpmsg_core.c
@@ -330,7 +330,8 @@ field##_show(struct device *dev,
\
struct rpmsg_device *rpdev = to_rpmsg_device(dev);  \
\
return sprintf(buf, format_string, rpdev->path);\
-}
+}  \
+static DEVICE_ATTR_RO(field);
 
 /* for more info, see Documentation/ABI/testing/sysfs-bus-rpmsg */
 rpmsg_show_attr(name, id.name, "%s\n");
@@ -345,15 +346,17 @@ static ssize_t modalias_show(struct device *dev,
 
return sprintf(buf, RPMSG_DEVICE_MODALIAS_FMT "\n", rpdev->id.name);
 }
-
-static struct device_attribute rpmsg_dev_attrs[] = {
-   __ATTR_RO(name),
-   __ATTR_RO(modalias),
-   __ATTR_RO(dst),
-   __ATTR_RO(src),
-   __ATTR_RO(announce),
-   __ATTR_NULL
+static DEVICE_ATTR_RO(modalias);
+
+static struct attribute *rpmsg_dev_attrs[] = {
+   _attr_name.attr,
+   _attr_modalias.attr,
+   _attr_dst.attr,
+   _attr_src.attr,
+   _attr_announce.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(rpmsg_dev);
 
 /* rpmsg devices and drivers are matched using the service name */
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
@@ -455,7 +458,7 @@ static int rpmsg_dev_remove(struct device *dev)
 static struct bus_type rpmsg_bus = {
.name   = "rpmsg",
.match  = rpmsg_dev_match,
-   .dev_attrs  = rpmsg_dev_attrs,
+   .dev_groups = rpmsg_dev_groups,
.uevent = rpmsg_uevent,
.probe  = rpmsg_dev_probe,
.remove = rpmsg_dev_remove,
-- 
2.13.0



[PATCH 16/16] driver-core: remove struct bus_type.dev_attrs

2017-06-06 Thread Greg Kroah-Hartman
Now that all in-kernel users of bus_type.dev_attrs have been converted
to use dev_groups instead, the dev_attrs field, and logic surrounding
it, can be removed.

Signed-off-by: Greg Kroah-Hartman 
---
 drivers/base/bus.c | 37 +
 include/linux/device.h |  2 --
 2 files changed, 1 insertion(+), 38 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 6470eb8088f4..66efc4b806c2 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -466,35 +466,6 @@ int bus_for_each_drv(struct bus_type *bus, struct 
device_driver *start,
 }
 EXPORT_SYMBOL_GPL(bus_for_each_drv);
 
-static int device_add_attrs(struct bus_type *bus, struct device *dev)
-{
-   int error = 0;
-   int i;
-
-   if (!bus->dev_attrs)
-   return 0;
-
-   for (i = 0; bus->dev_attrs[i].attr.name; i++) {
-   error = device_create_file(dev, >dev_attrs[i]);
-   if (error) {
-   while (--i >= 0)
-   device_remove_file(dev, >dev_attrs[i]);
-   break;
-   }
-   }
-   return error;
-}
-
-static void device_remove_attrs(struct bus_type *bus, struct device *dev)
-{
-   int i;
-
-   if (bus->dev_attrs) {
-   for (i = 0; bus->dev_attrs[i].attr.name; i++)
-   device_remove_file(dev, >dev_attrs[i]);
-   }
-}
-
 /**
  * bus_add_device - add device to bus
  * @dev: device being added
@@ -510,12 +481,9 @@ int bus_add_device(struct device *dev)
 
if (bus) {
pr_debug("bus: '%s': add device %s\n", bus->name, 
dev_name(dev));
-   error = device_add_attrs(bus, dev);
-   if (error)
-   goto out_put;
error = device_add_groups(dev, bus->dev_groups);
if (error)
-   goto out_id;
+   goto out_put;
error = sysfs_create_link(>p->devices_kset->kobj,
>kobj, dev_name(dev));
if (error)
@@ -532,8 +500,6 @@ int bus_add_device(struct device *dev)
sysfs_remove_link(>p->devices_kset->kobj, dev_name(dev));
 out_groups:
device_remove_groups(dev, bus->dev_groups);
-out_id:
-   device_remove_attrs(bus, dev);
 out_put:
bus_put(dev->bus);
return error;
@@ -590,7 +556,6 @@ void bus_remove_device(struct device *dev)
sysfs_remove_link(>kobj, "subsystem");
sysfs_remove_link(>bus->p->devices_kset->kobj,
  dev_name(dev));
-   device_remove_attrs(dev->bus, dev);
device_remove_groups(dev, dev->bus->dev_groups);
if (klist_node_attached(>p->knode_bus))
klist_del(>p->knode_bus);
diff --git a/include/linux/device.h b/include/linux/device.h
index 9ef518af5515..a04860932ceb 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -66,7 +66,6 @@ extern void bus_remove_file(struct bus_type *, struct 
bus_attribute *);
  * @name:  The name of the bus.
  * @dev_name:  Used for subsystems to enumerate devices like ("foo%u", 
dev->id).
  * @dev_root:  Default device to use as the parent.
- * @dev_attrs: Default attributes of the devices on the bus.
  * @bus_groups:Default attributes of the bus.
  * @dev_groups:Default attributes of the devices on the bus.
  * @drv_groups: Default attributes of the device drivers on the bus.
@@ -112,7 +111,6 @@ struct bus_type {
const char  *name;
const char  *dev_name;
struct device   *dev_root;
-   struct device_attribute *dev_attrs; /* use dev_groups instead */
const struct attribute_group **bus_groups;
const struct attribute_group **dev_groups;
const struct attribute_group **drv_groups;
-- 
2.13.0



[PATCH 05/16] rpmsg: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Ohad Ben-Cohen 
Cc: Bjorn Andersson 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/rpmsg/rpmsg_core.c | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c
index 600f5f9f7431..ad3d2a9df287 100644
--- a/drivers/rpmsg/rpmsg_core.c
+++ b/drivers/rpmsg/rpmsg_core.c
@@ -330,7 +330,8 @@ field##_show(struct device *dev,
\
struct rpmsg_device *rpdev = to_rpmsg_device(dev);  \
\
return sprintf(buf, format_string, rpdev->path);\
-}
+}  \
+static DEVICE_ATTR_RO(field);
 
 /* for more info, see Documentation/ABI/testing/sysfs-bus-rpmsg */
 rpmsg_show_attr(name, id.name, "%s\n");
@@ -345,15 +346,17 @@ static ssize_t modalias_show(struct device *dev,
 
return sprintf(buf, RPMSG_DEVICE_MODALIAS_FMT "\n", rpdev->id.name);
 }
-
-static struct device_attribute rpmsg_dev_attrs[] = {
-   __ATTR_RO(name),
-   __ATTR_RO(modalias),
-   __ATTR_RO(dst),
-   __ATTR_RO(src),
-   __ATTR_RO(announce),
-   __ATTR_NULL
+static DEVICE_ATTR_RO(modalias);
+
+static struct attribute *rpmsg_dev_attrs[] = {
+   _attr_name.attr,
+   _attr_modalias.attr,
+   _attr_dst.attr,
+   _attr_src.attr,
+   _attr_announce.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(rpmsg_dev);
 
 /* rpmsg devices and drivers are matched using the service name */
 static inline int rpmsg_id_match(const struct rpmsg_device *rpdev,
@@ -455,7 +458,7 @@ static int rpmsg_dev_remove(struct device *dev)
 static struct bus_type rpmsg_bus = {
.name   = "rpmsg",
.match  = rpmsg_dev_match,
-   .dev_attrs  = rpmsg_dev_attrs,
+   .dev_groups = rpmsg_dev_groups,
.uevent = rpmsg_uevent,
.probe  = rpmsg_dev_probe,
.remove = rpmsg_dev_remove,
-- 
2.13.0



[PATCH 16/16] driver-core: remove struct bus_type.dev_attrs

2017-06-06 Thread Greg Kroah-Hartman
Now that all in-kernel users of bus_type.dev_attrs have been converted
to use dev_groups instead, the dev_attrs field, and logic surrounding
it, can be removed.

Signed-off-by: Greg Kroah-Hartman 
---
 drivers/base/bus.c | 37 +
 include/linux/device.h |  2 --
 2 files changed, 1 insertion(+), 38 deletions(-)

diff --git a/drivers/base/bus.c b/drivers/base/bus.c
index 6470eb8088f4..66efc4b806c2 100644
--- a/drivers/base/bus.c
+++ b/drivers/base/bus.c
@@ -466,35 +466,6 @@ int bus_for_each_drv(struct bus_type *bus, struct 
device_driver *start,
 }
 EXPORT_SYMBOL_GPL(bus_for_each_drv);
 
-static int device_add_attrs(struct bus_type *bus, struct device *dev)
-{
-   int error = 0;
-   int i;
-
-   if (!bus->dev_attrs)
-   return 0;
-
-   for (i = 0; bus->dev_attrs[i].attr.name; i++) {
-   error = device_create_file(dev, >dev_attrs[i]);
-   if (error) {
-   while (--i >= 0)
-   device_remove_file(dev, >dev_attrs[i]);
-   break;
-   }
-   }
-   return error;
-}
-
-static void device_remove_attrs(struct bus_type *bus, struct device *dev)
-{
-   int i;
-
-   if (bus->dev_attrs) {
-   for (i = 0; bus->dev_attrs[i].attr.name; i++)
-   device_remove_file(dev, >dev_attrs[i]);
-   }
-}
-
 /**
  * bus_add_device - add device to bus
  * @dev: device being added
@@ -510,12 +481,9 @@ int bus_add_device(struct device *dev)
 
if (bus) {
pr_debug("bus: '%s': add device %s\n", bus->name, 
dev_name(dev));
-   error = device_add_attrs(bus, dev);
-   if (error)
-   goto out_put;
error = device_add_groups(dev, bus->dev_groups);
if (error)
-   goto out_id;
+   goto out_put;
error = sysfs_create_link(>p->devices_kset->kobj,
>kobj, dev_name(dev));
if (error)
@@ -532,8 +500,6 @@ int bus_add_device(struct device *dev)
sysfs_remove_link(>p->devices_kset->kobj, dev_name(dev));
 out_groups:
device_remove_groups(dev, bus->dev_groups);
-out_id:
-   device_remove_attrs(bus, dev);
 out_put:
bus_put(dev->bus);
return error;
@@ -590,7 +556,6 @@ void bus_remove_device(struct device *dev)
sysfs_remove_link(>kobj, "subsystem");
sysfs_remove_link(>bus->p->devices_kset->kobj,
  dev_name(dev));
-   device_remove_attrs(dev->bus, dev);
device_remove_groups(dev, dev->bus->dev_groups);
if (klist_node_attached(>p->knode_bus))
klist_del(>p->knode_bus);
diff --git a/include/linux/device.h b/include/linux/device.h
index 9ef518af5515..a04860932ceb 100644
--- a/include/linux/device.h
+++ b/include/linux/device.h
@@ -66,7 +66,6 @@ extern void bus_remove_file(struct bus_type *, struct 
bus_attribute *);
  * @name:  The name of the bus.
  * @dev_name:  Used for subsystems to enumerate devices like ("foo%u", 
dev->id).
  * @dev_root:  Default device to use as the parent.
- * @dev_attrs: Default attributes of the devices on the bus.
  * @bus_groups:Default attributes of the bus.
  * @dev_groups:Default attributes of the devices on the bus.
  * @drv_groups: Default attributes of the device drivers on the bus.
@@ -112,7 +111,6 @@ struct bus_type {
const char  *name;
const char  *dev_name;
struct device   *dev_root;
-   struct device_attribute *dev_attrs; /* use dev_groups instead */
const struct attribute_group **bus_groups;
const struct attribute_group **dev_groups;
const struct attribute_group **drv_groups;
-- 
2.13.0



[PATCH 13/16] hid: intel-ish-hid: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Srinivas Pandruvada 
Cc: Jiri Kosina 
Cc: Benjamin Tissoires 
Cc: Wei Yongjun 
Cc: Bhumika Goyal 
Cc: Rasmus Villemoes 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/hid/intel-ish-hid/ishtp/bus.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c 
b/drivers/hid/intel-ish-hid/ishtp/bus.c
index 5f382fedc2ab..f272cdd9bd55 100644
--- a/drivers/hid/intel-ish-hid/ishtp/bus.c
+++ b/drivers/hid/intel-ish-hid/ishtp/bus.c
@@ -321,11 +321,13 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *a,
len = snprintf(buf, PAGE_SIZE, "ishtp:%s\n", dev_name(dev));
return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
 }
+static DEVICE_ATTR_RO(modalias);
 
-static struct device_attribute ishtp_cl_dev_attrs[] = {
-   __ATTR_RO(modalias),
-   __ATTR_NULL,
+static struct attribute *ishtp_cl_dev_attrs[] = {
+   _attr_modalias.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(ishtp_cl_dev);
 
 static int ishtp_cl_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
@@ -346,7 +348,7 @@ static const struct dev_pm_ops ishtp_cl_bus_dev_pm_ops = {
 
 static struct bus_type ishtp_cl_bus_type = {
.name   = "ishtp",
-   .dev_attrs  = ishtp_cl_dev_attrs,
+   .dev_groups = ishtp_cl_dev_groups,
.probe  = ishtp_cl_device_probe,
.remove = ishtp_cl_device_remove,
.pm = _cl_bus_dev_pm_ops,
-- 
2.13.0



[PATCH 04/16] amba: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Russell King 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/amba/bus.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index a56fa2a1e9aa..e0f74ddc22b7 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -105,6 +105,7 @@ static ssize_t driver_override_store(struct device *_dev,
 
return count;
 }
+static DEVICE_ATTR_RW(driver_override);
 
 #define amba_attr_func(name,fmt,arg...)
\
 static ssize_t name##_show(struct device *_dev,
\
@@ -112,25 +113,23 @@ static ssize_t name##_show(struct device *_dev,   
\
 {  \
struct amba_device *dev = to_amba_device(_dev); \
return sprintf(buf, fmt, arg);  \
-}
-
-#define amba_attr(name,fmt,arg...) \
-amba_attr_func(name,fmt,arg)   \
-static DEVICE_ATTR(name, S_IRUGO, name##_show, NULL)
+}  \
+static DEVICE_ATTR_RO(name)
 
 amba_attr_func(id, "%08x\n", dev->periphid);
-amba_attr(irq0, "%u\n", dev->irq[0]);
-amba_attr(irq1, "%u\n", dev->irq[1]);
+amba_attr_func(irq0, "%u\n", dev->irq[0]);
+amba_attr_func(irq1, "%u\n", dev->irq[1]);
 amba_attr_func(resource, "\t%016llx\t%016llx\t%016lx\n",
 (unsigned long long)dev->res.start, (unsigned long long)dev->res.end,
 dev->res.flags);
 
-static struct device_attribute amba_dev_attrs[] = {
-   __ATTR_RO(id),
-   __ATTR_RO(resource),
-   __ATTR_RW(driver_override),
-   __ATTR_NULL,
+static struct attribute *amba_dev_attrs[] = {
+   _attr_id.attr,
+   _attr_resource.attr,
+   _attr_driver_override.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(amba_dev);
 
 #ifdef CONFIG_PM
 /*
@@ -192,7 +191,7 @@ static const struct dev_pm_ops amba_pm = {
  */
 struct bus_type amba_bustype = {
.name   = "amba",
-   .dev_attrs  = amba_dev_attrs,
+   .dev_groups = amba_dev_groups,
.match  = amba_match,
.uevent = amba_uevent,
.pm = _pm,
-- 
2.13.0



[PATCH 13/16] hid: intel-ish-hid: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Srinivas Pandruvada 
Cc: Jiri Kosina 
Cc: Benjamin Tissoires 
Cc: Wei Yongjun 
Cc: Bhumika Goyal 
Cc: Rasmus Villemoes 
Cc: 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/hid/intel-ish-hid/ishtp/bus.c | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/hid/intel-ish-hid/ishtp/bus.c 
b/drivers/hid/intel-ish-hid/ishtp/bus.c
index 5f382fedc2ab..f272cdd9bd55 100644
--- a/drivers/hid/intel-ish-hid/ishtp/bus.c
+++ b/drivers/hid/intel-ish-hid/ishtp/bus.c
@@ -321,11 +321,13 @@ static ssize_t modalias_show(struct device *dev, struct 
device_attribute *a,
len = snprintf(buf, PAGE_SIZE, "ishtp:%s\n", dev_name(dev));
return (len >= PAGE_SIZE) ? (PAGE_SIZE - 1) : len;
 }
+static DEVICE_ATTR_RO(modalias);
 
-static struct device_attribute ishtp_cl_dev_attrs[] = {
-   __ATTR_RO(modalias),
-   __ATTR_NULL,
+static struct attribute *ishtp_cl_dev_attrs[] = {
+   _attr_modalias.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(ishtp_cl_dev);
 
 static int ishtp_cl_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
@@ -346,7 +348,7 @@ static const struct dev_pm_ops ishtp_cl_bus_dev_pm_ops = {
 
 static struct bus_type ishtp_cl_bus_type = {
.name   = "ishtp",
-   .dev_attrs  = ishtp_cl_dev_attrs,
+   .dev_groups = ishtp_cl_dev_groups,
.probe  = ishtp_cl_device_probe,
.remove = ishtp_cl_device_remove,
.pm = _cl_bus_dev_pm_ops,
-- 
2.13.0



[PATCH 04/16] amba: use dev_groups and not dev_attrs for bus_type

2017-06-06 Thread Greg Kroah-Hartman
The dev_attrs field has long been "depreciated" and is finally being
removed, so move the driver to use the "correct" dev_groups field
instead for struct bus_type.

Cc: Russell King 
Signed-off-by: Greg Kroah-Hartman 
---
 drivers/amba/bus.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c
index a56fa2a1e9aa..e0f74ddc22b7 100644
--- a/drivers/amba/bus.c
+++ b/drivers/amba/bus.c
@@ -105,6 +105,7 @@ static ssize_t driver_override_store(struct device *_dev,
 
return count;
 }
+static DEVICE_ATTR_RW(driver_override);
 
 #define amba_attr_func(name,fmt,arg...)
\
 static ssize_t name##_show(struct device *_dev,
\
@@ -112,25 +113,23 @@ static ssize_t name##_show(struct device *_dev,   
\
 {  \
struct amba_device *dev = to_amba_device(_dev); \
return sprintf(buf, fmt, arg);  \
-}
-
-#define amba_attr(name,fmt,arg...) \
-amba_attr_func(name,fmt,arg)   \
-static DEVICE_ATTR(name, S_IRUGO, name##_show, NULL)
+}  \
+static DEVICE_ATTR_RO(name)
 
 amba_attr_func(id, "%08x\n", dev->periphid);
-amba_attr(irq0, "%u\n", dev->irq[0]);
-amba_attr(irq1, "%u\n", dev->irq[1]);
+amba_attr_func(irq0, "%u\n", dev->irq[0]);
+amba_attr_func(irq1, "%u\n", dev->irq[1]);
 amba_attr_func(resource, "\t%016llx\t%016llx\t%016lx\n",
 (unsigned long long)dev->res.start, (unsigned long long)dev->res.end,
 dev->res.flags);
 
-static struct device_attribute amba_dev_attrs[] = {
-   __ATTR_RO(id),
-   __ATTR_RO(resource),
-   __ATTR_RW(driver_override),
-   __ATTR_NULL,
+static struct attribute *amba_dev_attrs[] = {
+   _attr_id.attr,
+   _attr_resource.attr,
+   _attr_driver_override.attr,
+   NULL,
 };
+ATTRIBUTE_GROUPS(amba_dev);
 
 #ifdef CONFIG_PM
 /*
@@ -192,7 +191,7 @@ static const struct dev_pm_ops amba_pm = {
  */
 struct bus_type amba_bustype = {
.name   = "amba",
-   .dev_attrs  = amba_dev_attrs,
+   .dev_groups = amba_dev_groups,
.match  = amba_match,
.uevent = amba_uevent,
.pm = _pm,
-- 
2.13.0



Applied "ASoC: sun4i-codec: Add support for V3s codec" to the asoc tree

2017-06-06 Thread Mark Brown
The patch

   ASoC: sun4i-codec: Add support for V3s codec

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 8b2840b6daca728cecfa925b50bf638189e2fbca Mon Sep 17 00:00:00 2001
From: Icenowy Zheng 
Date: Mon, 5 Jun 2017 21:27:22 +0800
Subject: [PATCH] ASoC: sun4i-codec: Add support for V3s codec

The codec in the V3s is similar to the one found on the A31. One key
difference is the analog path controls are routed through the PRCM
block. This is supported by the sun8i-codec-analog driver, and tied
into this codec driver with the audio card's aux_dev.

In addition, the V3s does not have LINEIN, LINEOUT, MBIAS and MIC2,
MIC3, and the FIFO related registers are like H3.

Signed-off-by: Icenowy Zheng 
Reviewed-by: Chen-Yu Tsai 
Acked-by: Rob Herring 
Signed-off-by: Mark Brown 
---
 .../devicetree/bindings/sound/sun4i-codec.txt  | 11 ++--
 sound/soc/sunxi/sun4i-codec.c  | 63 ++
 2 files changed, 70 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/sun4i-codec.txt 
b/Documentation/devicetree/bindings/sound/sun4i-codec.txt
index 3863531d1e6d..2d4e10deb6f4 100644
--- a/Documentation/devicetree/bindings/sound/sun4i-codec.txt
+++ b/Documentation/devicetree/bindings/sound/sun4i-codec.txt
@@ -7,6 +7,7 @@ Required properties:
- "allwinner,sun7i-a20-codec"
- "allwinner,sun8i-a23-codec"
- "allwinner,sun8i-h3-codec"
+   - "allwinner,sun8i-v3s-codec"
 - reg: must contain the registers location and length
 - interrupts: must contain the codec interrupt
 - dmas: DMA channels for tx and rx dma. See the DMA client binding,
@@ -25,6 +26,7 @@ Required properties for the following compatibles:
- "allwinner,sun6i-a31-codec"
- "allwinner,sun8i-a23-codec"
- "allwinner,sun8i-h3-codec"
+   - "allwinner,sun8i-v3s-codec"
 - resets: phandle to the reset control for this device
 - allwinner,audio-routing: A list of the connections between audio components.
   Each entry is a pair of strings, the first being the
@@ -34,15 +36,15 @@ Required properties for the following compatibles:
   Audio pins on the SoC:
   "HP"
   "HPCOM"
-  "LINEIN"
-  "LINEOUT"(not on sun8i-a23)
+  "LINEIN" (not on sun8i-v3s)
+  "LINEOUT"(not on sun8i-a23 or sun8i-v3s)
   "MIC1"
-  "MIC2"
+  "MIC2"   (not on sun8i-v3s)
   "MIC3"   (sun6i-a31 only)
 
   Microphone biases from the SoC:
   "HBIAS"
-  "MBIAS"
+  "MBIAS"  (not on sun8i-v3s)
 
   Board connectors:
   "Headphone"
@@ -55,6 +57,7 @@ Required properties for the following compatibles:
 Required properties for the following compatibles:
- "allwinner,sun8i-a23-codec"
- "allwinner,sun8i-h3-codec"
+   - "allwinner,sun8i-v3s-codec"
 - allwinner,codec-analog-controls: A phandle to the codec analog controls
   block in the PRCM.
 
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index c3aab10fa085..150069987c0c 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -1339,6 +1339,44 @@ static struct snd_soc_card 
*sun8i_h3_codec_create_card(struct device *dev)
return card;
 };
 
+static struct snd_soc_card *sun8i_v3s_codec_create_card(struct device *dev)
+{
+   struct snd_soc_card *card;
+   int ret;
+
+   card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
+   if (!card)
+   return ERR_PTR(-ENOMEM);
+
+   aux_dev.codec_of_node = of_parse_phandle(dev->of_node,
+

Re: [PATCH] external references for device tree overlays

2017-06-06 Thread Stefani Seibold
Hi Frank,

On 06.06.2017, 00:20 -0700 Frank Rowand wrote::
> On 06/05/17 05:59, Stefani Seibold wrote:
> > From: Stefani Seibold 
> > 
> > This patch enables external references for symbols which are not
> > exported by the current device tree. For example
> > 
> > // RASPI example (only for testing)
> > /dts-v1/;
> > /plugin/;
> > 
> > / {
> > compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
> > 
> > fragment@0 {
> > target-path = "/soc/i2s@7e203000";
> > __overlay__ {
> > #address-cells = <0x0001>;
> > #size-cells = <0x0001>;
> > test = "test";
> > timer = <>;
> > };
> > };
> > 
> > __external_symbols__ {
> > timer = "/soc/timer@7e003000";
> > };
> > };
> 
> My hope is that the dtc compiler will stop supporting specification
> of the
> __symbols__ node in dts source, and only generate it automatically in
> the dtb.
> That change to dtc would not allow any node name specified in a dts
> to begin
> with an underscore.  Thus node __external_symbols__ would not be
> allowed.
> 

The name is not so important to me, only the solution.

> > In case of the RASPI device tree this could be simple fixed by
> > modifing
> > the device tree source, but when the device tree is provided by a
> > closed
> > source BIOS this kind of missing symbol could not be fixed.
> 
> Is there a real example of this issue, or is this a theoretical
> concern?
> If this is a real example, we should be discouraging such behavior.
> 

Yes, I have a BIOS on some ARM64 servers which provides broken device tree. It 
also lacks some devices in this tree which needs references to other devices 
which lacks a phandle.


> The suggestion by Pantelis should work, but that is just a hack to
> get
> you out of a bad situation, not a good practice.
> 

I tried it, but it doesn't work. Look at my post to Pantelis.

- Stefani


Applied "ASoC: sun4i-codec: Add support for V3s codec" to the asoc tree

2017-06-06 Thread Mark Brown
The patch

   ASoC: sun4i-codec: Add support for V3s codec

has been applied to the asoc tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 8b2840b6daca728cecfa925b50bf638189e2fbca Mon Sep 17 00:00:00 2001
From: Icenowy Zheng 
Date: Mon, 5 Jun 2017 21:27:22 +0800
Subject: [PATCH] ASoC: sun4i-codec: Add support for V3s codec

The codec in the V3s is similar to the one found on the A31. One key
difference is the analog path controls are routed through the PRCM
block. This is supported by the sun8i-codec-analog driver, and tied
into this codec driver with the audio card's aux_dev.

In addition, the V3s does not have LINEIN, LINEOUT, MBIAS and MIC2,
MIC3, and the FIFO related registers are like H3.

Signed-off-by: Icenowy Zheng 
Reviewed-by: Chen-Yu Tsai 
Acked-by: Rob Herring 
Signed-off-by: Mark Brown 
---
 .../devicetree/bindings/sound/sun4i-codec.txt  | 11 ++--
 sound/soc/sunxi/sun4i-codec.c  | 63 ++
 2 files changed, 70 insertions(+), 4 deletions(-)

diff --git a/Documentation/devicetree/bindings/sound/sun4i-codec.txt 
b/Documentation/devicetree/bindings/sound/sun4i-codec.txt
index 3863531d1e6d..2d4e10deb6f4 100644
--- a/Documentation/devicetree/bindings/sound/sun4i-codec.txt
+++ b/Documentation/devicetree/bindings/sound/sun4i-codec.txt
@@ -7,6 +7,7 @@ Required properties:
- "allwinner,sun7i-a20-codec"
- "allwinner,sun8i-a23-codec"
- "allwinner,sun8i-h3-codec"
+   - "allwinner,sun8i-v3s-codec"
 - reg: must contain the registers location and length
 - interrupts: must contain the codec interrupt
 - dmas: DMA channels for tx and rx dma. See the DMA client binding,
@@ -25,6 +26,7 @@ Required properties for the following compatibles:
- "allwinner,sun6i-a31-codec"
- "allwinner,sun8i-a23-codec"
- "allwinner,sun8i-h3-codec"
+   - "allwinner,sun8i-v3s-codec"
 - resets: phandle to the reset control for this device
 - allwinner,audio-routing: A list of the connections between audio components.
   Each entry is a pair of strings, the first being the
@@ -34,15 +36,15 @@ Required properties for the following compatibles:
   Audio pins on the SoC:
   "HP"
   "HPCOM"
-  "LINEIN"
-  "LINEOUT"(not on sun8i-a23)
+  "LINEIN" (not on sun8i-v3s)
+  "LINEOUT"(not on sun8i-a23 or sun8i-v3s)
   "MIC1"
-  "MIC2"
+  "MIC2"   (not on sun8i-v3s)
   "MIC3"   (sun6i-a31 only)
 
   Microphone biases from the SoC:
   "HBIAS"
-  "MBIAS"
+  "MBIAS"  (not on sun8i-v3s)
 
   Board connectors:
   "Headphone"
@@ -55,6 +57,7 @@ Required properties for the following compatibles:
 Required properties for the following compatibles:
- "allwinner,sun8i-a23-codec"
- "allwinner,sun8i-h3-codec"
+   - "allwinner,sun8i-v3s-codec"
 - allwinner,codec-analog-controls: A phandle to the codec analog controls
   block in the PRCM.
 
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index c3aab10fa085..150069987c0c 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -1339,6 +1339,44 @@ static struct snd_soc_card 
*sun8i_h3_codec_create_card(struct device *dev)
return card;
 };
 
+static struct snd_soc_card *sun8i_v3s_codec_create_card(struct device *dev)
+{
+   struct snd_soc_card *card;
+   int ret;
+
+   card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
+   if (!card)
+   return ERR_PTR(-ENOMEM);
+
+   aux_dev.codec_of_node = of_parse_phandle(dev->of_node,
+
"allwinner,codec-analog-controls",
+0);
+   

Re: [PATCH] external references for device tree overlays

2017-06-06 Thread Stefani Seibold
Hi Frank,

On 06.06.2017, 00:20 -0700 Frank Rowand wrote::
> On 06/05/17 05:59, Stefani Seibold wrote:
> > From: Stefani Seibold 
> > 
> > This patch enables external references for symbols which are not
> > exported by the current device tree. For example
> > 
> > // RASPI example (only for testing)
> > /dts-v1/;
> > /plugin/;
> > 
> > / {
> > compatible = "brcm,bcm2835", "brcm,bcm2708", "brcm,bcm2709";
> > 
> > fragment@0 {
> > target-path = "/soc/i2s@7e203000";
> > __overlay__ {
> > #address-cells = <0x0001>;
> > #size-cells = <0x0001>;
> > test = "test";
> > timer = <>;
> > };
> > };
> > 
> > __external_symbols__ {
> > timer = "/soc/timer@7e003000";
> > };
> > };
> 
> My hope is that the dtc compiler will stop supporting specification
> of the
> __symbols__ node in dts source, and only generate it automatically in
> the dtb.
> That change to dtc would not allow any node name specified in a dts
> to begin
> with an underscore.  Thus node __external_symbols__ would not be
> allowed.
> 

The name is not so important to me, only the solution.

> > In case of the RASPI device tree this could be simple fixed by
> > modifing
> > the device tree source, but when the device tree is provided by a
> > closed
> > source BIOS this kind of missing symbol could not be fixed.
> 
> Is there a real example of this issue, or is this a theoretical
> concern?
> If this is a real example, we should be discouraging such behavior.
> 

Yes, I have a BIOS on some ARM64 servers which provides broken device tree. It 
also lacks some devices in this tree which needs references to other devices 
which lacks a phandle.


> The suggestion by Pantelis should work, but that is just a hack to
> get
> you out of a bad situation, not a good practice.
> 

I tried it, but it doesn't work. Look at my post to Pantelis.

- Stefani


[PATCH 26/26] pidns: Ensure zap_pid_ns_processes always terminates

2017-06-06 Thread Eric W. Biederman
The function zap_pid_processes terminates when the number of pids used
by processes in a pid namespace drops to just those pids used by the
last thread of the dying thread.

Don't allow an init process aka a child_reaper to call
setpgid(0, some_other_processes_pid).  That case is already broken today
as it would result in a pid namespace that will hang when the thread group
leader dies.  Thankfully I have not received that bug report so it
appears that no one cares and uses that case.

Limiting setpgid ensures that the only two pids in the pid namespace
on the init process that are worth worrying about are the pid and the
tgid.  The pgrp will now either match the tgid or it will be from
outside the pid namespace.  Likewise the sid will either match the
tgid or be from outside the pid namespace.

To make it clear what is being counted test if the task's tgid is the same
as the the task's pid.  In particular the code does not count the
number of processes in a pid namespace, just the number of pids those
processes use.  A subtle but important distinction for understanding
the code.

Signed-off-by: "Eric W. Biederman" 
---
 kernel/pid_namespace.c | 2 +-
 kernel/sys.c   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 74a5a7255b4d..bdda73768cc0 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -208,7 +208,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
int nr;
int rc;
struct task_struct *task, *me = current;
-   int init_pids = thread_group_leader(me) ? 1 : 2;
+   int init_pids = task_pid(me) != task_tgid(me) ? 2 : 1;
 
/* Don't allow any more processes into the pid namespace */
disable_pid_allocation(pid_ns);
diff --git a/kernel/sys.c b/kernel/sys.c
index 705f14b28134..775dea1e2e06 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -975,7 +975,8 @@ SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid)
 
pgrp = find_vpid(pgid);
g = pid_task(pgrp, PIDTYPE_PGID);
-   if (!g || task_session(g) != task_session(group_leader))
+   if (!g || task_session(g) != task_session(group_leader) ||
+   is_child_reaper(task_tgid(p)))
goto out;
}
 
-- 
2.10.1



[PATCH 26/26] pidns: Ensure zap_pid_ns_processes always terminates

2017-06-06 Thread Eric W. Biederman
The function zap_pid_processes terminates when the number of pids used
by processes in a pid namespace drops to just those pids used by the
last thread of the dying thread.

Don't allow an init process aka a child_reaper to call
setpgid(0, some_other_processes_pid).  That case is already broken today
as it would result in a pid namespace that will hang when the thread group
leader dies.  Thankfully I have not received that bug report so it
appears that no one cares and uses that case.

Limiting setpgid ensures that the only two pids in the pid namespace
on the init process that are worth worrying about are the pid and the
tgid.  The pgrp will now either match the tgid or it will be from
outside the pid namespace.  Likewise the sid will either match the
tgid or be from outside the pid namespace.

To make it clear what is being counted test if the task's tgid is the same
as the the task's pid.  In particular the code does not count the
number of processes in a pid namespace, just the number of pids those
processes use.  A subtle but important distinction for understanding
the code.

Signed-off-by: "Eric W. Biederman" 
---
 kernel/pid_namespace.c | 2 +-
 kernel/sys.c   | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 74a5a7255b4d..bdda73768cc0 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -208,7 +208,7 @@ void zap_pid_ns_processes(struct pid_namespace *pid_ns)
int nr;
int rc;
struct task_struct *task, *me = current;
-   int init_pids = thread_group_leader(me) ? 1 : 2;
+   int init_pids = task_pid(me) != task_tgid(me) ? 2 : 1;
 
/* Don't allow any more processes into the pid namespace */
disable_pid_allocation(pid_ns);
diff --git a/kernel/sys.c b/kernel/sys.c
index 705f14b28134..775dea1e2e06 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -975,7 +975,8 @@ SYSCALL_DEFINE2(setpgid, pid_t, pid, pid_t, pgid)
 
pgrp = find_vpid(pgid);
g = pid_task(pgrp, PIDTYPE_PGID);
-   if (!g || task_session(g) != task_session(group_leader))
+   if (!g || task_session(g) != task_session(group_leader) ||
+   is_child_reaper(task_tgid(p)))
goto out;
}
 
-- 
2.10.1



[PATCH 25/26] signal: In ptrace_stop use CLD_TRAPPED in all ptrace signals

2017-06-06 Thread Eric W. Biederman
If the only job of the signal is to report a ptrace level event set
si_code to CLD_TRAPPED instead of possibly CLD_STOPPED.

This causes the siginfo of the signals that are sent to match the
signinfo of the signals returned by waitid.

This is a user visible difference but I don't expect anything will
care.

In fact this is a return to historical linux behavior.  In linux 2.4.0
all ptrace stops were reported through do_notify_parent with
CLD_TRAPPED.  When do_notify_parent_cldstop was added the CLD_TRAPPED
logic was not included and CLD_TRAPPED for ptrace stops was lost.  As
nothing was said about this case I assume it was an oversight.

When waitid was added a little earlier all stops were being
reported with do_notify_parent and all ptrace stops were setting
CLD_TRAPPED.  So initially signals and waitid were in sync with
respect to setting CLD_TRAPPED.

It is also worth knowing that posix uses documents CLD_TRAPPED
as "Traced child has trapped."

History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
Ref: ca3f74aa7baa ("[PATCH] waitid system call")
Fixes: Fixes: ebf5ebe31d2c ("[PATCH] signal-fixes-2.5.59-A4")
Signed-off-by: "Eric W. Biederman" 
---
 kernel/signal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index ff41e6ee2b5e..0d4ca87f1fee 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1886,9 +1886,9 @@ static void ptrace_stop(int exit_code, int why, int 
clear_code, siginfo_t *info)
 * separately unless they are going to be identical.
 */
if (!identical)
-   do_notify_parent_cldstop(current, true, why);
+   do_notify_parent_cldstop(current, true, CLD_TRAPPED);
if (gstop_done)
-   do_notify_parent_cldstop(current, false, why);
+   do_notify_parent_cldstop(current, false, CLD_STOPPED);
 
/*
 * Don't want to allow preemption here, because
@@ -1912,7 +1912,7 @@ static void ptrace_stop(int exit_code, int why, int 
clear_code, siginfo_t *info)
 * the real parent of the group stop completion is enough.
 */
if (gstop_done)
-   do_notify_parent_cldstop(current, false, why);
+   do_notify_parent_cldstop(current, false, CLD_STOPPED);
 
/* tasklist protects us from ptrace_freeze_traced() */
__set_current_state(TASK_RUNNING);
-- 
2.10.1



[PATCH 25/26] signal: In ptrace_stop use CLD_TRAPPED in all ptrace signals

2017-06-06 Thread Eric W. Biederman
If the only job of the signal is to report a ptrace level event set
si_code to CLD_TRAPPED instead of possibly CLD_STOPPED.

This causes the siginfo of the signals that are sent to match the
signinfo of the signals returned by waitid.

This is a user visible difference but I don't expect anything will
care.

In fact this is a return to historical linux behavior.  In linux 2.4.0
all ptrace stops were reported through do_notify_parent with
CLD_TRAPPED.  When do_notify_parent_cldstop was added the CLD_TRAPPED
logic was not included and CLD_TRAPPED for ptrace stops was lost.  As
nothing was said about this case I assume it was an oversight.

When waitid was added a little earlier all stops were being
reported with do_notify_parent and all ptrace stops were setting
CLD_TRAPPED.  So initially signals and waitid were in sync with
respect to setting CLD_TRAPPED.

It is also worth knowing that posix uses documents CLD_TRAPPED
as "Traced child has trapped."

History Tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
Ref: ca3f74aa7baa ("[PATCH] waitid system call")
Fixes: Fixes: ebf5ebe31d2c ("[PATCH] signal-fixes-2.5.59-A4")
Signed-off-by: "Eric W. Biederman" 
---
 kernel/signal.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/signal.c b/kernel/signal.c
index ff41e6ee2b5e..0d4ca87f1fee 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1886,9 +1886,9 @@ static void ptrace_stop(int exit_code, int why, int 
clear_code, siginfo_t *info)
 * separately unless they are going to be identical.
 */
if (!identical)
-   do_notify_parent_cldstop(current, true, why);
+   do_notify_parent_cldstop(current, true, CLD_TRAPPED);
if (gstop_done)
-   do_notify_parent_cldstop(current, false, why);
+   do_notify_parent_cldstop(current, false, CLD_STOPPED);
 
/*
 * Don't want to allow preemption here, because
@@ -1912,7 +1912,7 @@ static void ptrace_stop(int exit_code, int why, int 
clear_code, siginfo_t *info)
 * the real parent of the group stop completion is enough.
 */
if (gstop_done)
-   do_notify_parent_cldstop(current, false, why);
+   do_notify_parent_cldstop(current, false, CLD_STOPPED);
 
/* tasklist protects us from ptrace_freeze_traced() */
__set_current_state(TASK_RUNNING);
-- 
2.10.1



[PATCH 7/7] MIPS: Use generic libgcc intrinsics

2017-06-06 Thread Palmer Dabbelt
These routines in arch/mips/lib/ are functionally identical to those
recently added to lib/ so remove them and select the generic ones.

Signed-off-by: Matt Redfearn 
Signed-off-by: Palmer Dabbelt 
---
 arch/mips/Kconfig  |  5 +
 arch/mips/boot/compressed/Makefile |  4 +++-
 arch/mips/lib/Makefile |  2 +-
 arch/mips/lib/ashldi3.c| 29 -
 arch/mips/lib/ashrdi3.c| 31 ---
 arch/mips/lib/cmpdi2.c | 27 ---
 arch/mips/lib/libgcc.h | 25 -
 arch/mips/lib/lshrdi3.c| 29 -
 arch/mips/lib/ucmpdi2.c| 21 -
 9 files changed, 9 insertions(+), 164 deletions(-)
 delete mode 100644 arch/mips/lib/ashldi3.c
 delete mode 100644 arch/mips/lib/ashrdi3.c
 delete mode 100644 arch/mips/lib/cmpdi2.c
 delete mode 100644 arch/mips/lib/libgcc.h
 delete mode 100644 arch/mips/lib/lshrdi3.c
 delete mode 100644 arch/mips/lib/ucmpdi2.c

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 2828ecde133d..25713699ef1d 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -70,6 +70,11 @@ config MIPS
select HAVE_EXIT_THREAD
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_COPY_THREAD_TLS
+   select GENERIC_ASHLDI3
+   select GENERIC_ASHRDI3
+   select GENERIC_CMPDI2
+   select GENERIC_LSHRDI3
+   select GENERIC_UCMPDI2
 
 menu "Machine selection"
 
diff --git a/arch/mips/boot/compressed/Makefile 
b/arch/mips/boot/compressed/Makefile
index c675eece389a..83cc738fb7af 100644
--- a/arch/mips/boot/compressed/Makefile
+++ b/arch/mips/boot/compressed/Makefile
@@ -48,7 +48,9 @@ vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o 
$(obj)/bswapsi.o
 
 extra-y += ashldi3.c bswapsi.c
 $(obj)/ashldi3.o $(obj)/bswapsi.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib
-$(obj)/ashldi3.c $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c
+$(obj)/ashldi3.c $(obj)/%.c: $(srctree)/lib/%.c
+   $(call cmd,shipped)
+$(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c
$(call cmd,shipped)
 
 targets := $(notdir $(vmlinuzobjs-y))
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index 0344e575f522..814e739d6f86 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000)   += r3k_dump_tlb.o
 obj-$(CONFIG_CPU_TX39XX)   += r3k_dump_tlb.o
 
 # libgcc-style stuff needed in the kernel
-obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o
+obj-y += bswapsi.o bswapdi.o
diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c
deleted file mode 100644
index c3e22053d13e..
--- a/arch/mips/lib/ashldi3.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include 
-
-#include "libgcc.h"
-
-long long notrace __ashldi3(long long u, word_type b)
-{
-   DWunion uu, w;
-   word_type bm;
-
-   if (b == 0)
-   return u;
-
-   uu.ll = u;
-   bm = 32 - b;
-
-   if (bm <= 0) {
-   w.s.low = 0;
-   w.s.high = (unsigned int) uu.s.low << -bm;
-   } else {
-   const unsigned int carries = (unsigned int) uu.s.low >> bm;
-
-   w.s.low = (unsigned int) uu.s.low << b;
-   w.s.high = ((unsigned int) uu.s.high << b) | carries;
-   }
-
-   return w.ll;
-}
-
-EXPORT_SYMBOL(__ashldi3);
diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c
deleted file mode 100644
index 17456024873d..
--- a/arch/mips/lib/ashrdi3.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include 
-
-#include "libgcc.h"
-
-long long notrace __ashrdi3(long long u, word_type b)
-{
-   DWunion uu, w;
-   word_type bm;
-
-   if (b == 0)
-   return u;
-
-   uu.ll = u;
-   bm = 32 - b;
-
-   if (bm <= 0) {
-   /* w.s.high = 1..1 or 0..0 */
-   w.s.high =
-   uu.s.high >> 31;
-   w.s.low = uu.s.high >> -bm;
-   } else {
-   const unsigned int carries = (unsigned int) uu.s.high << bm;
-
-   w.s.high = uu.s.high >> b;
-   w.s.low = ((unsigned int) uu.s.low >> b) | carries;
-   }
-
-   return w.ll;
-}
-
-EXPORT_SYMBOL(__ashrdi3);
diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c
deleted file mode 100644
index 9d849d8743c9..
--- a/arch/mips/lib/cmpdi2.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include 
-
-#include "libgcc.h"
-
-word_type notrace __cmpdi2(long long a, long long b)
-{
-   const DWunion au = {
-   .ll = a
-   };
-   const DWunion bu = {
-   .ll = b
-   };
-
-   if (au.s.high < bu.s.high)
-   return 0;
-   else if (au.s.high > bu.s.high)
-   return 2;
-
-   if ((unsigned int) au.s.low < (unsigned int) bu.s.low)
-   

[PATCH 3/7] microblaze: Use libgcc files from lib/

2017-06-06 Thread Palmer Dabbelt
These files are functionally identical to the shared copies that I
recently added.

Signed-off-by: Palmer Dabbelt 
Reviewed-by: Geert Uytterhoeven 
---
 arch/microblaze/Kconfig   |  6 +
 arch/microblaze/lib/Makefile  |  3 +--
 arch/microblaze/lib/ashldi3.c | 28 -
 arch/microblaze/lib/ashrdi3.c | 30 ---
 arch/microblaze/lib/cmpdi2.c  | 26 
 arch/microblaze/lib/libgcc.h  | 32 
 arch/microblaze/lib/lshrdi3.c | 28 -
 arch/microblaze/lib/muldi3.c  | 57 ---
 arch/microblaze/lib/ucmpdi2.c | 20 ---
 9 files changed, 7 insertions(+), 223 deletions(-)
 delete mode 100644 arch/microblaze/lib/ashldi3.c
 delete mode 100644 arch/microblaze/lib/ashrdi3.c
 delete mode 100644 arch/microblaze/lib/cmpdi2.c
 delete mode 100644 arch/microblaze/lib/libgcc.h
 delete mode 100644 arch/microblaze/lib/lshrdi3.c
 delete mode 100644 arch/microblaze/lib/muldi3.c
 delete mode 100644 arch/microblaze/lib/ucmpdi2.c

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 85885a501dce..833487c17996 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -34,6 +34,12 @@ config MICROBLAZE
select TRACING_SUPPORT
select VIRT_TO_BUS
select CPU_NO_EFFICIENT_FFS
+   select GENERIC_ASHLDI3
+   select GENERIC_ASHRDI3
+   select GENERIC_CMPDI2
+   select GENERIC_LSHRDI3
+   select GENERIC_MULDI3
+   select GENERIC_UCMPDI3
 
 config SWAP
def_bool n
diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile
index 70c7ae6a3fb5..c9a4d537e2fd 100644
--- a/arch/microblaze/lib/Makefile
+++ b/arch/microblaze/lib/Makefile
@@ -19,5 +19,4 @@ endif
 lib-y += uaccess_old.o
 
 # libgcc-style stuff needed in the kernel
-obj-y += ashldi3.o ashrdi3.o cmpdi2.o divsi3.o lshrdi3.o modsi3.o
-obj-y += muldi3.o mulsi3.o ucmpdi2.o udivsi3.o umodsi3.o
+obj-y += divsi3.o modsi3.o mulsi3.o udivsi3.o umodsi3.o
diff --git a/arch/microblaze/lib/ashldi3.c b/arch/microblaze/lib/ashldi3.c
deleted file mode 100644
index 1af904cd972d..
--- a/arch/microblaze/lib/ashldi3.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include 
-
-#include "libgcc.h"
-
-long long __ashldi3(long long u, word_type b)
-{
-   DWunion uu, w;
-   word_type bm;
-
-   if (b == 0)
-   return u;
-
-   uu.ll = u;
-   bm = 32 - b;
-
-   if (bm <= 0) {
-   w.s.low = 0;
-   w.s.high = (unsigned int) uu.s.low << -bm;
-   } else {
-   const unsigned int carries = (unsigned int) uu.s.low >> bm;
-
-   w.s.low = (unsigned int) uu.s.low << b;
-   w.s.high = ((unsigned int) uu.s.high << b) | carries;
-   }
-
-   return w.ll;
-}
-EXPORT_SYMBOL(__ashldi3);
diff --git a/arch/microblaze/lib/ashrdi3.c b/arch/microblaze/lib/ashrdi3.c
deleted file mode 100644
index 32c334c05d04..
--- a/arch/microblaze/lib/ashrdi3.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include 
-
-#include "libgcc.h"
-
-long long __ashrdi3(long long u, word_type b)
-{
-   DWunion uu, w;
-   word_type bm;
-
-   if (b == 0)
-   return u;
-
-   uu.ll = u;
-   bm = 32 - b;
-
-   if (bm <= 0) {
-   /* w.s.high = 1..1 or 0..0 */
-   w.s.high =
-   uu.s.high >> 31;
-   w.s.low = uu.s.high >> -bm;
-   } else {
-   const unsigned int carries = (unsigned int) uu.s.high << bm;
-
-   w.s.high = uu.s.high >> b;
-   w.s.low = ((unsigned int) uu.s.low >> b) | carries;
-   }
-
-   return w.ll;
-}
-EXPORT_SYMBOL(__ashrdi3);
diff --git a/arch/microblaze/lib/cmpdi2.c b/arch/microblaze/lib/cmpdi2.c
deleted file mode 100644
index 67abc9ac1bd4..
--- a/arch/microblaze/lib/cmpdi2.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include 
-
-#include "libgcc.h"
-
-word_type __cmpdi2(long long a, long long b)
-{
-   const DWunion au = {
-   .ll = a
-   };
-   const DWunion bu = {
-   .ll = b
-   };
-
-   if (au.s.high < bu.s.high)
-   return 0;
-   else if (au.s.high > bu.s.high)
-   return 2;
-
-   if ((unsigned int) au.s.low < (unsigned int) bu.s.low)
-   return 0;
-   else if ((unsigned int) au.s.low > (unsigned int) bu.s.low)
-   return 2;
-
-   return 1;
-}
-EXPORT_SYMBOL(__cmpdi2);
diff --git a/arch/microblaze/lib/libgcc.h b/arch/microblaze/lib/libgcc.h
deleted file mode 100644
index ab077ef7e14b..
--- a/arch/microblaze/lib/libgcc.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __ASM_LIBGCC_H
-#define __ASM_LIBGCC_H
-
-#include 
-
-typedef int word_type __attribute__ ((mode (__word__)));
-
-#ifdef __BIG_ENDIAN
-struct DWstruct {
-   int high, low;
-};
-#elif defined(__LITTLE_ENDIAN)
-struct DWstruct {
-   int low, high;
-};

[PATCH 7/7] MIPS: Use generic libgcc intrinsics

2017-06-06 Thread Palmer Dabbelt
These routines in arch/mips/lib/ are functionally identical to those
recently added to lib/ so remove them and select the generic ones.

Signed-off-by: Matt Redfearn 
Signed-off-by: Palmer Dabbelt 
---
 arch/mips/Kconfig  |  5 +
 arch/mips/boot/compressed/Makefile |  4 +++-
 arch/mips/lib/Makefile |  2 +-
 arch/mips/lib/ashldi3.c| 29 -
 arch/mips/lib/ashrdi3.c| 31 ---
 arch/mips/lib/cmpdi2.c | 27 ---
 arch/mips/lib/libgcc.h | 25 -
 arch/mips/lib/lshrdi3.c| 29 -
 arch/mips/lib/ucmpdi2.c| 21 -
 9 files changed, 9 insertions(+), 164 deletions(-)
 delete mode 100644 arch/mips/lib/ashldi3.c
 delete mode 100644 arch/mips/lib/ashrdi3.c
 delete mode 100644 arch/mips/lib/cmpdi2.c
 delete mode 100644 arch/mips/lib/libgcc.h
 delete mode 100644 arch/mips/lib/lshrdi3.c
 delete mode 100644 arch/mips/lib/ucmpdi2.c

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 2828ecde133d..25713699ef1d 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -70,6 +70,11 @@ config MIPS
select HAVE_EXIT_THREAD
select HAVE_REGS_AND_STACK_ACCESS_API
select HAVE_COPY_THREAD_TLS
+   select GENERIC_ASHLDI3
+   select GENERIC_ASHRDI3
+   select GENERIC_CMPDI2
+   select GENERIC_LSHRDI3
+   select GENERIC_UCMPDI2
 
 menu "Machine selection"
 
diff --git a/arch/mips/boot/compressed/Makefile 
b/arch/mips/boot/compressed/Makefile
index c675eece389a..83cc738fb7af 100644
--- a/arch/mips/boot/compressed/Makefile
+++ b/arch/mips/boot/compressed/Makefile
@@ -48,7 +48,9 @@ vmlinuzobjs-$(CONFIG_KERNEL_XZ) += $(obj)/ashldi3.o 
$(obj)/bswapsi.o
 
 extra-y += ashldi3.c bswapsi.c
 $(obj)/ashldi3.o $(obj)/bswapsi.o: KBUILD_CFLAGS += -I$(srctree)/arch/mips/lib
-$(obj)/ashldi3.c $(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c
+$(obj)/ashldi3.c $(obj)/%.c: $(srctree)/lib/%.c
+   $(call cmd,shipped)
+$(obj)/bswapsi.c: $(obj)/%.c: $(srctree)/arch/mips/lib/%.c
$(call cmd,shipped)
 
 targets := $(notdir $(vmlinuzobjs-y))
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile
index 0344e575f522..814e739d6f86 100644
--- a/arch/mips/lib/Makefile
+++ b/arch/mips/lib/Makefile
@@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000)   += r3k_dump_tlb.o
 obj-$(CONFIG_CPU_TX39XX)   += r3k_dump_tlb.o
 
 # libgcc-style stuff needed in the kernel
-obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o
+obj-y += bswapsi.o bswapdi.o
diff --git a/arch/mips/lib/ashldi3.c b/arch/mips/lib/ashldi3.c
deleted file mode 100644
index c3e22053d13e..
--- a/arch/mips/lib/ashldi3.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include 
-
-#include "libgcc.h"
-
-long long notrace __ashldi3(long long u, word_type b)
-{
-   DWunion uu, w;
-   word_type bm;
-
-   if (b == 0)
-   return u;
-
-   uu.ll = u;
-   bm = 32 - b;
-
-   if (bm <= 0) {
-   w.s.low = 0;
-   w.s.high = (unsigned int) uu.s.low << -bm;
-   } else {
-   const unsigned int carries = (unsigned int) uu.s.low >> bm;
-
-   w.s.low = (unsigned int) uu.s.low << b;
-   w.s.high = ((unsigned int) uu.s.high << b) | carries;
-   }
-
-   return w.ll;
-}
-
-EXPORT_SYMBOL(__ashldi3);
diff --git a/arch/mips/lib/ashrdi3.c b/arch/mips/lib/ashrdi3.c
deleted file mode 100644
index 17456024873d..
--- a/arch/mips/lib/ashrdi3.c
+++ /dev/null
@@ -1,31 +0,0 @@
-#include 
-
-#include "libgcc.h"
-
-long long notrace __ashrdi3(long long u, word_type b)
-{
-   DWunion uu, w;
-   word_type bm;
-
-   if (b == 0)
-   return u;
-
-   uu.ll = u;
-   bm = 32 - b;
-
-   if (bm <= 0) {
-   /* w.s.high = 1..1 or 0..0 */
-   w.s.high =
-   uu.s.high >> 31;
-   w.s.low = uu.s.high >> -bm;
-   } else {
-   const unsigned int carries = (unsigned int) uu.s.high << bm;
-
-   w.s.high = uu.s.high >> b;
-   w.s.low = ((unsigned int) uu.s.low >> b) | carries;
-   }
-
-   return w.ll;
-}
-
-EXPORT_SYMBOL(__ashrdi3);
diff --git a/arch/mips/lib/cmpdi2.c b/arch/mips/lib/cmpdi2.c
deleted file mode 100644
index 9d849d8743c9..
--- a/arch/mips/lib/cmpdi2.c
+++ /dev/null
@@ -1,27 +0,0 @@
-#include 
-
-#include "libgcc.h"
-
-word_type notrace __cmpdi2(long long a, long long b)
-{
-   const DWunion au = {
-   .ll = a
-   };
-   const DWunion bu = {
-   .ll = b
-   };
-
-   if (au.s.high < bu.s.high)
-   return 0;
-   else if (au.s.high > bu.s.high)
-   return 2;
-
-   if ((unsigned int) au.s.low < (unsigned int) bu.s.low)
-   return 0;
-   else if ((unsigned int) au.s.low 

[PATCH 3/7] microblaze: Use libgcc files from lib/

2017-06-06 Thread Palmer Dabbelt
These files are functionally identical to the shared copies that I
recently added.

Signed-off-by: Palmer Dabbelt 
Reviewed-by: Geert Uytterhoeven 
---
 arch/microblaze/Kconfig   |  6 +
 arch/microblaze/lib/Makefile  |  3 +--
 arch/microblaze/lib/ashldi3.c | 28 -
 arch/microblaze/lib/ashrdi3.c | 30 ---
 arch/microblaze/lib/cmpdi2.c  | 26 
 arch/microblaze/lib/libgcc.h  | 32 
 arch/microblaze/lib/lshrdi3.c | 28 -
 arch/microblaze/lib/muldi3.c  | 57 ---
 arch/microblaze/lib/ucmpdi2.c | 20 ---
 9 files changed, 7 insertions(+), 223 deletions(-)
 delete mode 100644 arch/microblaze/lib/ashldi3.c
 delete mode 100644 arch/microblaze/lib/ashrdi3.c
 delete mode 100644 arch/microblaze/lib/cmpdi2.c
 delete mode 100644 arch/microblaze/lib/libgcc.h
 delete mode 100644 arch/microblaze/lib/lshrdi3.c
 delete mode 100644 arch/microblaze/lib/muldi3.c
 delete mode 100644 arch/microblaze/lib/ucmpdi2.c

diff --git a/arch/microblaze/Kconfig b/arch/microblaze/Kconfig
index 85885a501dce..833487c17996 100644
--- a/arch/microblaze/Kconfig
+++ b/arch/microblaze/Kconfig
@@ -34,6 +34,12 @@ config MICROBLAZE
select TRACING_SUPPORT
select VIRT_TO_BUS
select CPU_NO_EFFICIENT_FFS
+   select GENERIC_ASHLDI3
+   select GENERIC_ASHRDI3
+   select GENERIC_CMPDI2
+   select GENERIC_LSHRDI3
+   select GENERIC_MULDI3
+   select GENERIC_UCMPDI3
 
 config SWAP
def_bool n
diff --git a/arch/microblaze/lib/Makefile b/arch/microblaze/lib/Makefile
index 70c7ae6a3fb5..c9a4d537e2fd 100644
--- a/arch/microblaze/lib/Makefile
+++ b/arch/microblaze/lib/Makefile
@@ -19,5 +19,4 @@ endif
 lib-y += uaccess_old.o
 
 # libgcc-style stuff needed in the kernel
-obj-y += ashldi3.o ashrdi3.o cmpdi2.o divsi3.o lshrdi3.o modsi3.o
-obj-y += muldi3.o mulsi3.o ucmpdi2.o udivsi3.o umodsi3.o
+obj-y += divsi3.o modsi3.o mulsi3.o udivsi3.o umodsi3.o
diff --git a/arch/microblaze/lib/ashldi3.c b/arch/microblaze/lib/ashldi3.c
deleted file mode 100644
index 1af904cd972d..
--- a/arch/microblaze/lib/ashldi3.c
+++ /dev/null
@@ -1,28 +0,0 @@
-#include 
-
-#include "libgcc.h"
-
-long long __ashldi3(long long u, word_type b)
-{
-   DWunion uu, w;
-   word_type bm;
-
-   if (b == 0)
-   return u;
-
-   uu.ll = u;
-   bm = 32 - b;
-
-   if (bm <= 0) {
-   w.s.low = 0;
-   w.s.high = (unsigned int) uu.s.low << -bm;
-   } else {
-   const unsigned int carries = (unsigned int) uu.s.low >> bm;
-
-   w.s.low = (unsigned int) uu.s.low << b;
-   w.s.high = ((unsigned int) uu.s.high << b) | carries;
-   }
-
-   return w.ll;
-}
-EXPORT_SYMBOL(__ashldi3);
diff --git a/arch/microblaze/lib/ashrdi3.c b/arch/microblaze/lib/ashrdi3.c
deleted file mode 100644
index 32c334c05d04..
--- a/arch/microblaze/lib/ashrdi3.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include 
-
-#include "libgcc.h"
-
-long long __ashrdi3(long long u, word_type b)
-{
-   DWunion uu, w;
-   word_type bm;
-
-   if (b == 0)
-   return u;
-
-   uu.ll = u;
-   bm = 32 - b;
-
-   if (bm <= 0) {
-   /* w.s.high = 1..1 or 0..0 */
-   w.s.high =
-   uu.s.high >> 31;
-   w.s.low = uu.s.high >> -bm;
-   } else {
-   const unsigned int carries = (unsigned int) uu.s.high << bm;
-
-   w.s.high = uu.s.high >> b;
-   w.s.low = ((unsigned int) uu.s.low >> b) | carries;
-   }
-
-   return w.ll;
-}
-EXPORT_SYMBOL(__ashrdi3);
diff --git a/arch/microblaze/lib/cmpdi2.c b/arch/microblaze/lib/cmpdi2.c
deleted file mode 100644
index 67abc9ac1bd4..
--- a/arch/microblaze/lib/cmpdi2.c
+++ /dev/null
@@ -1,26 +0,0 @@
-#include 
-
-#include "libgcc.h"
-
-word_type __cmpdi2(long long a, long long b)
-{
-   const DWunion au = {
-   .ll = a
-   };
-   const DWunion bu = {
-   .ll = b
-   };
-
-   if (au.s.high < bu.s.high)
-   return 0;
-   else if (au.s.high > bu.s.high)
-   return 2;
-
-   if ((unsigned int) au.s.low < (unsigned int) bu.s.low)
-   return 0;
-   else if ((unsigned int) au.s.low > (unsigned int) bu.s.low)
-   return 2;
-
-   return 1;
-}
-EXPORT_SYMBOL(__cmpdi2);
diff --git a/arch/microblaze/lib/libgcc.h b/arch/microblaze/lib/libgcc.h
deleted file mode 100644
index ab077ef7e14b..
--- a/arch/microblaze/lib/libgcc.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef __ASM_LIBGCC_H
-#define __ASM_LIBGCC_H
-
-#include 
-
-typedef int word_type __attribute__ ((mode (__word__)));
-
-#ifdef __BIG_ENDIAN
-struct DWstruct {
-   int high, low;
-};
-#elif defined(__LITTLE_ENDIAN)
-struct DWstruct {
-   int low, high;
-};
-#else
-#error I feel sick.
-#endif
-

[PATCH 12/26] wait: Directly test for the two cases where wait_task_zombie is called

2017-06-06 Thread Eric W. Biederman
We call wait_task_zombie to reap child processes and to release
zombie ptraced threads.  Collect all of the tests for these two
cases into their own individual if statements to make it clear
what is going on.

This results in no change in behavior just a change in how the code is
written.

Seeing how these two cases that call wait_task_zombie
are equivalent to the original is not trivial so here
is my reasoning:

/*
 * Original test -
 */
if ((exit_state == EXIT_ZOMBIE) &&
!delay_group_leader(p) &&
((ptrace ||
  (p->ptrace && !ptrace_reparented(p))) ||
 !p->ptrace))
return wait_task_zombile(wo, p);

/*
 * Expand delay_group_leader  
 */
if ((exit_state == EXIT_ZOMBIE) &&
!(thread_group_leader(p) && !thread_group_empty(p)) &&
((ptrace ||
  (p->ptrace && !ptrace_reparented(p))) ||
 !p->ptrace))
return wait_task_zombile(wo, p);

/*
 * Moving ! via DeMorgan's law  --
 */
if ((exit_state == EXIT_ZOMBIE) &&
(!thread_group_leader(p) || thread_group_empty(p)) &&
((ptrace ||
  (p->ptrace && !ptrace_reparented(p))) ||
 !p->ptrace))
return wait_task_zombile(wo, p);

/*
 * Three basic cases from the last || expression  
 */
/* zombie child process? */
if ((exit_state == EXIT_ZOMBIE) && !ptrace && !p->ptrace &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/* ptraced zombie child process? */
if ((exit_state == EXIT_ZOMBIE) && !ptrace && p->ptrace &&
!ptrace_reparented(p) &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/* ptraced process or thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/*
 * Combining the first two cases  
 */
/* zombie child process? */
if ((exit_state == EXIT_ZOMBIE) && !ptrace &&
!ptrace_reparented(p) &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/* ptraced process or thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/*
 * Exploiting !ptrace implies thread_group_leader  ---
 */
/* zombie child process? */
if ((exit_state == EXIT_ZOMBIE) && !ptrace &&
!ptrace_reparented(p) &&
thread_group_empty(p))
return wait_task_zombie(wo, p);

/* ptraced process or thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/*
 * Splitting the second case by ptrace_reparented  ---
 */
/* zombie child process? */
if ((exit_state == EXIT_ZOMBIE) && !ptrace &&
!ptrace_reparented(p) &&
thread_group_empty(p))
return wait_task_zombie(wo, p);

/* ptraced child process or child thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
!ptrace_reparenated(p) &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/* ptraced process or thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
ptrace_reparanted(p) &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/*
 * Splitting the second case by leadership  --
 */
/* zombie child process? */
if ((exit_state == EXIT_ZOMBIE) && !ptrace &&
!ptrace_reparented(p) &&
thread_group_empty(p))
return wait_task_zombie(wo, p);

/* ptraced child process? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
!ptrace_reparenated(p) &&
thread_group_leader(p) &&
thread_group_empty(p))
return wait_task_zombie(wo, p);

/* ptraced child thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
!ptrace_reparenated(p) &&
!thread_group_leader(p))
return wait_task_zombie(wo, p);

/* ptraced process or thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
ptrace_reparanted(p) &&

[PATCH 12/26] wait: Directly test for the two cases where wait_task_zombie is called

2017-06-06 Thread Eric W. Biederman
We call wait_task_zombie to reap child processes and to release
zombie ptraced threads.  Collect all of the tests for these two
cases into their own individual if statements to make it clear
what is going on.

This results in no change in behavior just a change in how the code is
written.

Seeing how these two cases that call wait_task_zombie
are equivalent to the original is not trivial so here
is my reasoning:

/*
 * Original test -
 */
if ((exit_state == EXIT_ZOMBIE) &&
!delay_group_leader(p) &&
((ptrace ||
  (p->ptrace && !ptrace_reparented(p))) ||
 !p->ptrace))
return wait_task_zombile(wo, p);

/*
 * Expand delay_group_leader  
 */
if ((exit_state == EXIT_ZOMBIE) &&
!(thread_group_leader(p) && !thread_group_empty(p)) &&
((ptrace ||
  (p->ptrace && !ptrace_reparented(p))) ||
 !p->ptrace))
return wait_task_zombile(wo, p);

/*
 * Moving ! via DeMorgan's law  --
 */
if ((exit_state == EXIT_ZOMBIE) &&
(!thread_group_leader(p) || thread_group_empty(p)) &&
((ptrace ||
  (p->ptrace && !ptrace_reparented(p))) ||
 !p->ptrace))
return wait_task_zombile(wo, p);

/*
 * Three basic cases from the last || expression  
 */
/* zombie child process? */
if ((exit_state == EXIT_ZOMBIE) && !ptrace && !p->ptrace &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/* ptraced zombie child process? */
if ((exit_state == EXIT_ZOMBIE) && !ptrace && p->ptrace &&
!ptrace_reparented(p) &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/* ptraced process or thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/*
 * Combining the first two cases  
 */
/* zombie child process? */
if ((exit_state == EXIT_ZOMBIE) && !ptrace &&
!ptrace_reparented(p) &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/* ptraced process or thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/*
 * Exploiting !ptrace implies thread_group_leader  ---
 */
/* zombie child process? */
if ((exit_state == EXIT_ZOMBIE) && !ptrace &&
!ptrace_reparented(p) &&
thread_group_empty(p))
return wait_task_zombie(wo, p);

/* ptraced process or thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/*
 * Splitting the second case by ptrace_reparented  ---
 */
/* zombie child process? */
if ((exit_state == EXIT_ZOMBIE) && !ptrace &&
!ptrace_reparented(p) &&
thread_group_empty(p))
return wait_task_zombie(wo, p);

/* ptraced child process or child thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
!ptrace_reparenated(p) &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/* ptraced process or thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
ptrace_reparanted(p) &&
(!thread_group_leader(p) || thread_group_empty(p)))
return wait_task_zombie(wo, p);

/*
 * Splitting the second case by leadership  --
 */
/* zombie child process? */
if ((exit_state == EXIT_ZOMBIE) && !ptrace &&
!ptrace_reparented(p) &&
thread_group_empty(p))
return wait_task_zombie(wo, p);

/* ptraced child process? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
!ptrace_reparenated(p) &&
thread_group_leader(p) &&
thread_group_empty(p))
return wait_task_zombie(wo, p);

/* ptraced child thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
!ptrace_reparenated(p) &&
!thread_group_leader(p))
return wait_task_zombie(wo, p);

/* ptraced process or thread? */
if ((exit_state == EXIT_ZOMBIE) && ptrace &&
ptrace_reparanted(p) &&

Re: [PATCH] security/keys: rewrite all of big_key crypto

2017-06-06 Thread Jason A. Donenfeld
On Tue, Jun 6, 2017 at 8:45 PM, David Howells  wrote:
> Jason A. Donenfeld  wrote:
>
>> Thank you! Perfect instructions, I'll play around with this and make
>> sure it works.
>
> Don't forget that it's bimodal.  You need to give it sufficient data to
> trigger storage in swappable space.

Somewhat incredibly, it works perfectly.

First I tried the instructions you noted, and things worked, both for
big files and small ones.

Then I modified the source to print to dmesg the data buffer and the
key before and after the encryption/decryption function. I verified
with a small python script that indeed standard aes-gcm is being used
successfully.

Thus, pending Ted's approval of the new random API, this patch should
be ready for merging.

Regards,
Jason


Re: [PATCH] security/keys: rewrite all of big_key crypto

2017-06-06 Thread Jason A. Donenfeld
On Tue, Jun 6, 2017 at 8:45 PM, David Howells  wrote:
> Jason A. Donenfeld  wrote:
>
>> Thank you! Perfect instructions, I'll play around with this and make
>> sure it works.
>
> Don't forget that it's bimodal.  You need to give it sufficient data to
> trigger storage in swappable space.

Somewhat incredibly, it works perfectly.

First I tried the instructions you noted, and things worked, both for
big files and small ones.

Then I modified the source to print to dmesg the data buffer and the
key before and after the encryption/decryption function. I verified
with a small python script that indeed standard aes-gcm is being used
successfully.

Thus, pending Ted's approval of the new random API, this patch should
be ready for merging.

Regards,
Jason


[PATCH 17/26] exit: Rework the exit states for ptracees

2017-06-06 Thread Eric W. Biederman
Create two new exit states EXIT_TRACEE and EXIT_TRACED replacing
the two states "(EXIT_ZOMBIE && (!thread_group_leader(p) || !ptrace_reparented))
and EXIT_TRACE.  With EXIT_ZOMBIE replacing the state:
"(EXIT_ZOMBIE && thread_group_leader(p) && !ptrace_reparented)".

Rework the code to take advantage of the certain knowledge of
exit state progression:
   EXIT_TRACEE -> EXIT_TRACED -> EXIT_ZOMBIE -> EXIT_DEAD

This makes the code more readable/maintainable by using simple states
rather than complicated expressions.  The values of both of the new
states contain EXIT_ZOMBIE so all of these states appear to userspace
as zombies.

Signed-off-by: "Eric W. Biederman" 
---
 include/linux/sched.h |  6 +-
 kernel/exit.c | 51 +++
 kernel/ptrace.c   | 31 +--
 3 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 461ecd20731c..f2cec7f27e59 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -73,7 +73,6 @@ struct task_group;
 /* Used in tsk->exit_state: */
 #define EXIT_DEAD  16
 #define EXIT_ZOMBIE32
-#define EXIT_TRACE (EXIT_ZOMBIE | EXIT_DEAD)
 /* Used in tsk->state again: */
 #define TASK_DEAD  64
 #define TASK_WAKEKILL  128
@@ -82,6 +81,11 @@ struct task_group;
 #define TASK_NOLOAD1024
 #define TASK_NEW   2048
 #define TASK_STATE_MAX 4096
+/* Used in tsk->exit_state again: */
+#define __EXIT_TRACEE   8192
+#define __EXIT_TRACED   16384
+#define EXIT_TRACEE(EXIT_ZOMBIE | __EXIT_TRACEE)
+#define EXIT_TRACED(EXIT_ZOMBIE | __EXIT_TRACED)
 
 #define TASK_STATE_TO_CHAR_STR "RSDTtXZxKWPNn"
 
diff --git a/kernel/exit.c b/kernel/exit.c
index 72591eb5e361..ff2ed1d60a8c 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -580,8 +580,7 @@ static void reparent_leader(struct task_struct *father, 
struct task_struct *p,
p->exit_signal = SIGCHLD;
 
/* If it has exited notify the new parent about this child's death. */
-   if (!p->ptrace &&
-   p->exit_state == EXIT_ZOMBIE && thread_group_empty(p)) {
+   if (p->exit_state == EXIT_ZOMBIE && thread_group_empty(p)) {
if (do_notify_parent(p, p->exit_signal)) {
p->exit_state = EXIT_DEAD;
list_add(>ptrace_entry, dead);
@@ -639,7 +638,7 @@ static void forget_original_parent(struct task_struct 
*father,
  */
 static void exit_notify(struct task_struct *tsk, int group_dead)
 {
-   bool autoreap = true;
+   int state = EXIT_DEAD;
struct task_struct *p, *n;
LIST_HEAD(dead);
 
@@ -650,14 +649,18 @@ static void exit_notify(struct task_struct *tsk, int 
group_dead)
kill_orphaned_pgrp(tsk->group_leader, NULL);
 
if (thread_group_leader(tsk) && !ptrace_reparented(tsk)) {
-   autoreap = thread_group_empty(tsk) &&
-   do_notify_parent(tsk, tsk->exit_signal);
+   state = EXIT_ZOMBIE;
+   if (thread_group_empty(tsk) &&
+   do_notify_parent(tsk, tsk->exit_signal))
+   state = EXIT_DEAD;
}
else if (unlikely(tsk->ptrace)) {
-   autoreap = do_notify_parent(tsk, SIGCHLD);
+   state = EXIT_TRACEE;
+   if (do_notify_parent(tsk, SIGCHLD))
+   state = EXIT_DEAD;
}
 
-   tsk->exit_state = autoreap ? EXIT_DEAD : EXIT_ZOMBIE;
+   tsk->exit_state = state;
if (tsk->exit_state == EXIT_DEAD)
list_add(>ptrace_entry, );
 
@@ -1001,7 +1004,7 @@ static int wait_noreap_copyout(struct wait_opts *wo, 
struct task_struct *p,
  * the lock and this task is uninteresting.  If we return nonzero, we have
  * released the lock and the system call should return.
  */
-static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
+static int wait_task_zombie(struct wait_opts *wo, int old_state, struct 
task_struct *p)
 {
int state, retval, status;
pid_t pid = task_pid_vnr(p);
@@ -1029,11 +1032,11 @@ static int wait_task_zombie(struct wait_opts *wo, 
struct task_struct *p)
return wait_noreap_copyout(wo, p, pid, uid, why, status);
}
/*
-* Move the task's state to DEAD/TRACE, only one thread can do this.
+* Move the task's state to DEAD/TRACED only one thread can do this.
 */
-   state = (ptrace_reparented(p) && thread_group_leader(p)) ?
-   EXIT_TRACE : EXIT_DEAD;
-   if (cmpxchg(>exit_state, EXIT_ZOMBIE, state) != EXIT_ZOMBIE)
+   state = ((old_state == EXIT_TRACEE) && thread_group_leader(p)) ?
+   EXIT_TRACED : EXIT_DEAD;
+   if (cmpxchg(>exit_state, 

[PATCH 23/26] signal: Fix SIGCONT before group stop completes.

2017-06-06 Thread Eric W. Biederman
Today initiating a group stop with SIGSTOP, SIGTSTP, SIGTTIN, or
SIGTTOU and then have it contined with SIGCONT before the group stop
is complete results in SIGCHLD being sent with a si_status of 0.  The
field si_status is defined by posix to be the stop signal.  Which means
we wind up violating posix and any reasonable meaning of siginfo
delivered with SIGCHLD by reporting this partial group stop.

A partial group stop will result in even stranger things when seen in
the context of ptrace.  If all of the threads are ptraced they should
all enter a ptrace stop but the cancelation of the group stop before
the group stop completes results in only some of the threads entering
a ptrace stop.

Fix this by performing a delayed thread group wakeup that will take
effect as the last thread is signaling that the group stop is
complete.

This makes reasoning about the code much simpler, fixes partial
group stop interactions with ptrace, and the signal set for
a group stop that sees SIGCONT before it completes.  For
a similar cost in code.

I looked into the history to see if I could understand where this
problematic behavior came from, and the source of the behavior goes
back to the original development of thread groups in the kernel.  A
bug fix was made to improve the handling of SIGCONT that introduced
group_stop_count and the resuming of partial stops that makes no sense
today in the context of ptrace SIGSTOP handling.

At the time that was not a problem because stops when being ptraced
were in ordinary TASK_STOPPED stops.  It potentially became a problem
shortly thereafter when ptrace stops became TASK_TRACED stops which
can not be gotten out of with SIGCONT.  Howeve for it to actually
become a problem the code had to wait until recently when 5224fa3660ad
("ptrace: Make do_signal_stop() use ptrace_stop() if the task is being ptraced")
was merged for ptraced processes to stop with in TASK_TRACED when
they were ptraced.

The practical issue with sending an invalid si_status appears to have
been introduced much later after the locking changed to make it
necessary to send signals to the parent from the destination process
itself.  When Oleg unified partial and full stop handling
group_exit_code wound up being cleared on both code paths.  Not just
the for the full stop case.  That in turn introduced the invalid
si_status of 0.  As until that point group_exit_code always held the
signal when do_notify_parent_cldstop was called for stop signals.

Historical tree: 
https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
Fixes: 5224fa3660ad ("ptrace: Make do_signal_stop() use ptrace_stop() if the 
task is being ptraced")
Fixes: fc321d2e60d6 ("handle_stop_signal: unify partial/full stop handling")
Reference: e442055193e4 ("signals: re-assign CLD_CONTINUED notification from 
the sender to reciever")
Reference: cece79ae3a39 ("[PATCH] cleanup ptrace stops and remove 
notify_parent")
Reference: ca3f74aa7baa ("[PATCH] waitid system call")
Reference: ebf5ebe31d2c ("[PATCH] signal-fixes-2.5.59-A4")
Signed-off-by: "Eric W. Biederman" 
---
 include/linux/sched/signal.h | 26 +++--
 kernel/signal.c  | 89 
 2 files changed, 63 insertions(+), 52 deletions(-)

diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index 0cc626dd79a8..dac2d90217c2 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -227,21 +227,17 @@ struct signal_struct {
 /*
  * Bits in flags field of signal_struct.
  */
-#define SIGNAL_STOP_STOPPED0x0001 /* job control stop in effect */
-#define SIGNAL_STOP_CONTINUED  0x0002 /* SIGCONT since WCONTINUED reap */
-#define SIGNAL_GROUP_EXIT  0x0004 /* group exit in progress */
-#define SIGNAL_GROUP_COREDUMP  0x0008 /* coredump in progress */
-/*
- * Pending notifications to parent.
- */
-#define SIGNAL_CLD_STOPPED 0x0010
-#define SIGNAL_CLD_CONTINUED   0x0020
-#define SIGNAL_CLD_MASK
(SIGNAL_CLD_STOPPED|SIGNAL_CLD_CONTINUED)
+#define SIGNAL_CLD_CONTINUED   0x0001 /* Need to send SIGCONT to parent */
+#define SIGNAL_STOP_STOPPED0x0002 /* job control stop in effect */
+#define SIGNAL_STOP_CONTINUED  0x0004 /* SIGCONT since WCONTINUED reap */
+#define SIGNAL_WAKEUP_PENDING  0x0008 /* Wakeup for SIGCONT pending */
+#define SIGNAL_GROUP_EXIT  0x0010 /* group exit in progress */
+#define SIGNAL_GROUP_COREDUMP  0x0020 /* coredump in progress */
 
 #define SIGNAL_UNKILLABLE  0x0040 /* for init: ignore fatal signals */
 
-#define SIGNAL_STOP_MASK (SIGNAL_CLD_MASK | SIGNAL_STOP_STOPPED | \
- SIGNAL_STOP_CONTINUED)
+#define SIGNAL_STOP_MASK (SIGNAL_CLD_CONTINUED | SIGNAL_STOP_STOPPED | \
+ SIGNAL_STOP_CONTINUED | SIGNAL_WAKEUP_PENDING)
 
 static inline void signal_set_stop_flags(struct signal_struct *sig,
 unsigned 

[PATCH 17/26] exit: Rework the exit states for ptracees

2017-06-06 Thread Eric W. Biederman
Create two new exit states EXIT_TRACEE and EXIT_TRACED replacing
the two states "(EXIT_ZOMBIE && (!thread_group_leader(p) || !ptrace_reparented))
and EXIT_TRACE.  With EXIT_ZOMBIE replacing the state:
"(EXIT_ZOMBIE && thread_group_leader(p) && !ptrace_reparented)".

Rework the code to take advantage of the certain knowledge of
exit state progression:
   EXIT_TRACEE -> EXIT_TRACED -> EXIT_ZOMBIE -> EXIT_DEAD

This makes the code more readable/maintainable by using simple states
rather than complicated expressions.  The values of both of the new
states contain EXIT_ZOMBIE so all of these states appear to userspace
as zombies.

Signed-off-by: "Eric W. Biederman" 
---
 include/linux/sched.h |  6 +-
 kernel/exit.c | 51 +++
 kernel/ptrace.c   | 31 +--
 3 files changed, 45 insertions(+), 43 deletions(-)

diff --git a/include/linux/sched.h b/include/linux/sched.h
index 461ecd20731c..f2cec7f27e59 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -73,7 +73,6 @@ struct task_group;
 /* Used in tsk->exit_state: */
 #define EXIT_DEAD  16
 #define EXIT_ZOMBIE32
-#define EXIT_TRACE (EXIT_ZOMBIE | EXIT_DEAD)
 /* Used in tsk->state again: */
 #define TASK_DEAD  64
 #define TASK_WAKEKILL  128
@@ -82,6 +81,11 @@ struct task_group;
 #define TASK_NOLOAD1024
 #define TASK_NEW   2048
 #define TASK_STATE_MAX 4096
+/* Used in tsk->exit_state again: */
+#define __EXIT_TRACEE   8192
+#define __EXIT_TRACED   16384
+#define EXIT_TRACEE(EXIT_ZOMBIE | __EXIT_TRACEE)
+#define EXIT_TRACED(EXIT_ZOMBIE | __EXIT_TRACED)
 
 #define TASK_STATE_TO_CHAR_STR "RSDTtXZxKWPNn"
 
diff --git a/kernel/exit.c b/kernel/exit.c
index 72591eb5e361..ff2ed1d60a8c 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -580,8 +580,7 @@ static void reparent_leader(struct task_struct *father, 
struct task_struct *p,
p->exit_signal = SIGCHLD;
 
/* If it has exited notify the new parent about this child's death. */
-   if (!p->ptrace &&
-   p->exit_state == EXIT_ZOMBIE && thread_group_empty(p)) {
+   if (p->exit_state == EXIT_ZOMBIE && thread_group_empty(p)) {
if (do_notify_parent(p, p->exit_signal)) {
p->exit_state = EXIT_DEAD;
list_add(>ptrace_entry, dead);
@@ -639,7 +638,7 @@ static void forget_original_parent(struct task_struct 
*father,
  */
 static void exit_notify(struct task_struct *tsk, int group_dead)
 {
-   bool autoreap = true;
+   int state = EXIT_DEAD;
struct task_struct *p, *n;
LIST_HEAD(dead);
 
@@ -650,14 +649,18 @@ static void exit_notify(struct task_struct *tsk, int 
group_dead)
kill_orphaned_pgrp(tsk->group_leader, NULL);
 
if (thread_group_leader(tsk) && !ptrace_reparented(tsk)) {
-   autoreap = thread_group_empty(tsk) &&
-   do_notify_parent(tsk, tsk->exit_signal);
+   state = EXIT_ZOMBIE;
+   if (thread_group_empty(tsk) &&
+   do_notify_parent(tsk, tsk->exit_signal))
+   state = EXIT_DEAD;
}
else if (unlikely(tsk->ptrace)) {
-   autoreap = do_notify_parent(tsk, SIGCHLD);
+   state = EXIT_TRACEE;
+   if (do_notify_parent(tsk, SIGCHLD))
+   state = EXIT_DEAD;
}
 
-   tsk->exit_state = autoreap ? EXIT_DEAD : EXIT_ZOMBIE;
+   tsk->exit_state = state;
if (tsk->exit_state == EXIT_DEAD)
list_add(>ptrace_entry, );
 
@@ -1001,7 +1004,7 @@ static int wait_noreap_copyout(struct wait_opts *wo, 
struct task_struct *p,
  * the lock and this task is uninteresting.  If we return nonzero, we have
  * released the lock and the system call should return.
  */
-static int wait_task_zombie(struct wait_opts *wo, struct task_struct *p)
+static int wait_task_zombie(struct wait_opts *wo, int old_state, struct 
task_struct *p)
 {
int state, retval, status;
pid_t pid = task_pid_vnr(p);
@@ -1029,11 +1032,11 @@ static int wait_task_zombie(struct wait_opts *wo, 
struct task_struct *p)
return wait_noreap_copyout(wo, p, pid, uid, why, status);
}
/*
-* Move the task's state to DEAD/TRACE, only one thread can do this.
+* Move the task's state to DEAD/TRACED only one thread can do this.
 */
-   state = (ptrace_reparented(p) && thread_group_leader(p)) ?
-   EXIT_TRACE : EXIT_DEAD;
-   if (cmpxchg(>exit_state, EXIT_ZOMBIE, state) != EXIT_ZOMBIE)
+   state = ((old_state == EXIT_TRACEE) && thread_group_leader(p)) ?
+   EXIT_TRACED : EXIT_DEAD;
+   if (cmpxchg(>exit_state, old_state, state) != 

[PATCH 23/26] signal: Fix SIGCONT before group stop completes.

2017-06-06 Thread Eric W. Biederman
Today initiating a group stop with SIGSTOP, SIGTSTP, SIGTTIN, or
SIGTTOU and then have it contined with SIGCONT before the group stop
is complete results in SIGCHLD being sent with a si_status of 0.  The
field si_status is defined by posix to be the stop signal.  Which means
we wind up violating posix and any reasonable meaning of siginfo
delivered with SIGCHLD by reporting this partial group stop.

A partial group stop will result in even stranger things when seen in
the context of ptrace.  If all of the threads are ptraced they should
all enter a ptrace stop but the cancelation of the group stop before
the group stop completes results in only some of the threads entering
a ptrace stop.

Fix this by performing a delayed thread group wakeup that will take
effect as the last thread is signaling that the group stop is
complete.

This makes reasoning about the code much simpler, fixes partial
group stop interactions with ptrace, and the signal set for
a group stop that sees SIGCONT before it completes.  For
a similar cost in code.

I looked into the history to see if I could understand where this
problematic behavior came from, and the source of the behavior goes
back to the original development of thread groups in the kernel.  A
bug fix was made to improve the handling of SIGCONT that introduced
group_stop_count and the resuming of partial stops that makes no sense
today in the context of ptrace SIGSTOP handling.

At the time that was not a problem because stops when being ptraced
were in ordinary TASK_STOPPED stops.  It potentially became a problem
shortly thereafter when ptrace stops became TASK_TRACED stops which
can not be gotten out of with SIGCONT.  Howeve for it to actually
become a problem the code had to wait until recently when 5224fa3660ad
("ptrace: Make do_signal_stop() use ptrace_stop() if the task is being ptraced")
was merged for ptraced processes to stop with in TASK_TRACED when
they were ptraced.

The practical issue with sending an invalid si_status appears to have
been introduced much later after the locking changed to make it
necessary to send signals to the parent from the destination process
itself.  When Oleg unified partial and full stop handling
group_exit_code wound up being cleared on both code paths.  Not just
the for the full stop case.  That in turn introduced the invalid
si_status of 0.  As until that point group_exit_code always held the
signal when do_notify_parent_cldstop was called for stop signals.

Historical tree: 
https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git
Fixes: 5224fa3660ad ("ptrace: Make do_signal_stop() use ptrace_stop() if the 
task is being ptraced")
Fixes: fc321d2e60d6 ("handle_stop_signal: unify partial/full stop handling")
Reference: e442055193e4 ("signals: re-assign CLD_CONTINUED notification from 
the sender to reciever")
Reference: cece79ae3a39 ("[PATCH] cleanup ptrace stops and remove 
notify_parent")
Reference: ca3f74aa7baa ("[PATCH] waitid system call")
Reference: ebf5ebe31d2c ("[PATCH] signal-fixes-2.5.59-A4")
Signed-off-by: "Eric W. Biederman" 
---
 include/linux/sched/signal.h | 26 +++--
 kernel/signal.c  | 89 
 2 files changed, 63 insertions(+), 52 deletions(-)

diff --git a/include/linux/sched/signal.h b/include/linux/sched/signal.h
index 0cc626dd79a8..dac2d90217c2 100644
--- a/include/linux/sched/signal.h
+++ b/include/linux/sched/signal.h
@@ -227,21 +227,17 @@ struct signal_struct {
 /*
  * Bits in flags field of signal_struct.
  */
-#define SIGNAL_STOP_STOPPED0x0001 /* job control stop in effect */
-#define SIGNAL_STOP_CONTINUED  0x0002 /* SIGCONT since WCONTINUED reap */
-#define SIGNAL_GROUP_EXIT  0x0004 /* group exit in progress */
-#define SIGNAL_GROUP_COREDUMP  0x0008 /* coredump in progress */
-/*
- * Pending notifications to parent.
- */
-#define SIGNAL_CLD_STOPPED 0x0010
-#define SIGNAL_CLD_CONTINUED   0x0020
-#define SIGNAL_CLD_MASK
(SIGNAL_CLD_STOPPED|SIGNAL_CLD_CONTINUED)
+#define SIGNAL_CLD_CONTINUED   0x0001 /* Need to send SIGCONT to parent */
+#define SIGNAL_STOP_STOPPED0x0002 /* job control stop in effect */
+#define SIGNAL_STOP_CONTINUED  0x0004 /* SIGCONT since WCONTINUED reap */
+#define SIGNAL_WAKEUP_PENDING  0x0008 /* Wakeup for SIGCONT pending */
+#define SIGNAL_GROUP_EXIT  0x0010 /* group exit in progress */
+#define SIGNAL_GROUP_COREDUMP  0x0020 /* coredump in progress */
 
 #define SIGNAL_UNKILLABLE  0x0040 /* for init: ignore fatal signals */
 
-#define SIGNAL_STOP_MASK (SIGNAL_CLD_MASK | SIGNAL_STOP_STOPPED | \
- SIGNAL_STOP_CONTINUED)
+#define SIGNAL_STOP_MASK (SIGNAL_CLD_CONTINUED | SIGNAL_STOP_STOPPED | \
+ SIGNAL_STOP_CONTINUED | SIGNAL_WAKEUP_PENDING)
 
 static inline void signal_set_stop_flags(struct signal_struct *sig,
 unsigned int flags)
@@ -250,6 

[PATCH 22/26] exit: Fix auto-wait of ptraced children

2017-06-06 Thread Eric W. Biederman
In November of 2005 Oleg fixed a kernel crash with commit 7ed0175a462c
("[PATCH] Don't auto-reap traced children").  Oleg's patch was the fix
for CVE-2005-3784 where one description says:

The auto-reap of child processes in Linux kernel 2.6 before 2.6.15
includes processes with ptrace attached, which leads to a dangling
ptrace reference and allows local users to cause a denial of
service (crash) and gain root privileges.

Not reaping the zombies resulted in zombies on the ptrace list when
threads that ignored them exited.  Resulting in Roland authoring
666f164f4fbf ("fix dangling zombie when new parent ignores children").

Which winds up auto-waiting for those zombies not when the tasks exit
and become zombies but when the ptracer exits.

As the kernel is already auto-waiting zombies for ptraced children
rewrite the code to use the same code paths for auto-waiting as we use
for all other children.

This is a user visible change so something might care but as auto-wait
at exit semantics are not documented anywhere, are in direct violation
of what SIG_IGN and SA_NOCLDWAIT are documented by posix to do, and
added to avoid a kernel crash, I don't expect there will be problems.

Fixes: 7ed0175a462c ("[PATCH] Don't auto-reap traced children")
Signed-off-by: "Eric W. Biederman" 
---
 kernel/exit.c   | 10 +++---
 kernel/ptrace.c | 23 +--
 kernel/signal.c |  2 +-
 3 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 2f01b75e3b2e..eaea41c8e646 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -638,7 +638,7 @@ static void forget_original_parent(struct task_struct 
*father,
  */
 static void exit_notify(struct task_struct *tsk, int group_dead)
 {
-   int state = EXIT_DEAD;
+   int state;
struct task_struct *p, *n;
LIST_HEAD(dead);
 
@@ -648,6 +648,8 @@ static void exit_notify(struct task_struct *tsk, int 
group_dead)
if (group_dead)
kill_orphaned_pgrp(tsk->group_leader, NULL);
 
+renotify:
+   state = EXIT_DEAD;
if (thread_group_leader(tsk) && !ptrace_reparented(tsk)) {
state = EXIT_ZOMBIE;
if (thread_group_empty(tsk) &&
@@ -656,8 +658,10 @@ static void exit_notify(struct task_struct *tsk, int 
group_dead)
}
else if (unlikely(tsk->ptrace)) {
state = EXIT_TRACEE;
-   if (do_notify_parent(tsk, SIGCHLD))
-   state = EXIT_DEAD;
+   if (do_notify_parent(tsk, SIGCHLD)) {
+   __ptrace_unlink(tsk);
+   goto renotify;
+   }
}
 
tsk->exit_state = state;
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 003567a615f9..c52cbbcbe258 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -468,19 +468,6 @@ static int ptrace_traceme(void)
 }
 
 /*
- * Called with irqs disabled, returns true if childs should reap themselves.
- */
-static int ignoring_children(struct sighand_struct *sigh)
-{
-   int ret;
-   spin_lock(>siglock);
-   ret = (sigh->action[SIGCHLD-1].sa.sa_handler == SIG_IGN) ||
- (sigh->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT);
-   spin_unlock(>siglock);
-   return ret;
-}
-
-/*
  * Called with tasklist_lock held for writing.
  * Unlink a traced task, and clean it up if it was a traced zombie.
  * Return true if it needs to be reaped with release_task().
@@ -501,15 +488,7 @@ static bool __exit_ptrace(struct task_struct *tracer, 
struct task_struct *p)
 
__ptrace_unlink(p);
 
-   if (state == EXIT_ZOMBIE) {
-   /* Honor the parents request to autoreap children */
-   if (thread_group_empty(p) &&
-   ignoring_children(tracer->sighand)) {
-   state = EXIT_DEAD;
-   __wake_up_parent(p, tracer);
-   }
-   }
-   else if (state == EXIT_TRACEE) {
+   if (state == EXIT_TRACEE) {
state = EXIT_DEAD;
if (thread_group_leader(p)) {
state = EXIT_ZOMBIE;
diff --git a/kernel/signal.c b/kernel/signal.c
index 627b482fa3f8..30d652f86964 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1645,7 +1645,7 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
 
psig = tsk->parent->sighand;
spin_lock_irqsave(>siglock, flags);
-   if (!tsk->ptrace && sig == SIGCHLD &&
+   if (sig == SIGCHLD &&
(psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN ||
 (psig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT))) {
/*
-- 
2.10.1



[PATCH 22/26] exit: Fix auto-wait of ptraced children

2017-06-06 Thread Eric W. Biederman
In November of 2005 Oleg fixed a kernel crash with commit 7ed0175a462c
("[PATCH] Don't auto-reap traced children").  Oleg's patch was the fix
for CVE-2005-3784 where one description says:

The auto-reap of child processes in Linux kernel 2.6 before 2.6.15
includes processes with ptrace attached, which leads to a dangling
ptrace reference and allows local users to cause a denial of
service (crash) and gain root privileges.

Not reaping the zombies resulted in zombies on the ptrace list when
threads that ignored them exited.  Resulting in Roland authoring
666f164f4fbf ("fix dangling zombie when new parent ignores children").

Which winds up auto-waiting for those zombies not when the tasks exit
and become zombies but when the ptracer exits.

As the kernel is already auto-waiting zombies for ptraced children
rewrite the code to use the same code paths for auto-waiting as we use
for all other children.

This is a user visible change so something might care but as auto-wait
at exit semantics are not documented anywhere, are in direct violation
of what SIG_IGN and SA_NOCLDWAIT are documented by posix to do, and
added to avoid a kernel crash, I don't expect there will be problems.

Fixes: 7ed0175a462c ("[PATCH] Don't auto-reap traced children")
Signed-off-by: "Eric W. Biederman" 
---
 kernel/exit.c   | 10 +++---
 kernel/ptrace.c | 23 +--
 kernel/signal.c |  2 +-
 3 files changed, 9 insertions(+), 26 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index 2f01b75e3b2e..eaea41c8e646 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -638,7 +638,7 @@ static void forget_original_parent(struct task_struct 
*father,
  */
 static void exit_notify(struct task_struct *tsk, int group_dead)
 {
-   int state = EXIT_DEAD;
+   int state;
struct task_struct *p, *n;
LIST_HEAD(dead);
 
@@ -648,6 +648,8 @@ static void exit_notify(struct task_struct *tsk, int 
group_dead)
if (group_dead)
kill_orphaned_pgrp(tsk->group_leader, NULL);
 
+renotify:
+   state = EXIT_DEAD;
if (thread_group_leader(tsk) && !ptrace_reparented(tsk)) {
state = EXIT_ZOMBIE;
if (thread_group_empty(tsk) &&
@@ -656,8 +658,10 @@ static void exit_notify(struct task_struct *tsk, int 
group_dead)
}
else if (unlikely(tsk->ptrace)) {
state = EXIT_TRACEE;
-   if (do_notify_parent(tsk, SIGCHLD))
-   state = EXIT_DEAD;
+   if (do_notify_parent(tsk, SIGCHLD)) {
+   __ptrace_unlink(tsk);
+   goto renotify;
+   }
}
 
tsk->exit_state = state;
diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 003567a615f9..c52cbbcbe258 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -468,19 +468,6 @@ static int ptrace_traceme(void)
 }
 
 /*
- * Called with irqs disabled, returns true if childs should reap themselves.
- */
-static int ignoring_children(struct sighand_struct *sigh)
-{
-   int ret;
-   spin_lock(>siglock);
-   ret = (sigh->action[SIGCHLD-1].sa.sa_handler == SIG_IGN) ||
- (sigh->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT);
-   spin_unlock(>siglock);
-   return ret;
-}
-
-/*
  * Called with tasklist_lock held for writing.
  * Unlink a traced task, and clean it up if it was a traced zombie.
  * Return true if it needs to be reaped with release_task().
@@ -501,15 +488,7 @@ static bool __exit_ptrace(struct task_struct *tracer, 
struct task_struct *p)
 
__ptrace_unlink(p);
 
-   if (state == EXIT_ZOMBIE) {
-   /* Honor the parents request to autoreap children */
-   if (thread_group_empty(p) &&
-   ignoring_children(tracer->sighand)) {
-   state = EXIT_DEAD;
-   __wake_up_parent(p, tracer);
-   }
-   }
-   else if (state == EXIT_TRACEE) {
+   if (state == EXIT_TRACEE) {
state = EXIT_DEAD;
if (thread_group_leader(p)) {
state = EXIT_ZOMBIE;
diff --git a/kernel/signal.c b/kernel/signal.c
index 627b482fa3f8..30d652f86964 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -1645,7 +1645,7 @@ bool do_notify_parent(struct task_struct *tsk, int sig)
 
psig = tsk->parent->sighand;
spin_lock_irqsave(>siglock, flags);
-   if (!tsk->ptrace && sig == SIGCHLD &&
+   if (sig == SIGCHLD &&
(psig->action[SIGCHLD-1].sa.sa_handler == SIG_IGN ||
 (psig->action[SIGCHLD-1].sa.sa_flags & SA_NOCLDWAIT))) {
/*
-- 
2.10.1



[PATCH 18/26] wait: Fix WSTOPPED on a ptraced child

2017-06-06 Thread Eric W. Biederman
When ptracing waitpid(pid, WUNTRACED) has two possible meanings.
- Wait for ptrace stops from the task with tid == pid
- Wait for ordinary stops from the process with tgid == pid

The only sensible behavior and the Linux behavior in 2.2 and
2.4 has been to consume both ptrace stops and group stops
in this case.  It looks like when Oleg disentangled thread
stops and group stops in 2.6.30 fixing a lot of other issues
the case when we want to reap both was overlooked.

Consume both the group and the ptrace stop state when
waitpid(pid, WUNTRACED) could be asking for both, and
the wait status for both is idenitical.  This keeps
us from double reporting the stop and causing confusion.

This is very slight user visible change and is only visible
in the unlikely case a ptracer specifies WUNTRACED aka
WSTOPPED.

Write this code in such a way that it doesn't matter which
list we are traversing when we find a child whose stop states
we care about.

Fixes: 90bc8d8b1a38 ("do_wait: fix waiting for the group stop with the dead 
leader")
Signed-off-by: "Eric W. Biederman" 
---
 kernel/exit.c | 82 +--
 1 file changed, 40 insertions(+), 42 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index ff2ed1d60a8c..4e2d2b6f5581 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1151,22 +1151,23 @@ static int wait_task_zombie(struct wait_opts *wo, int 
old_state, struct task_str
return retval;
 }
 
-static int *task_stopped_code(struct task_struct *p, bool ptrace)
+static int *task_trace_stopped_code(struct task_struct *p)
 {
-   if (ptrace) {
-   if (task_is_traced(p) && !(p->jobctl & JOBCTL_LISTENING))
-   return >exit_code;
-   } else {
-   if (p->signal->flags & SIGNAL_STOP_STOPPED)
-   return >signal->group_exit_code;
-   }
+   if (task_is_traced(p) && !(p->jobctl & JOBCTL_LISTENING))
+   return >exit_code;
+   return NULL;
+}
+
+static int *task_group_stopped_code(struct task_struct *p)
+{
+   if (p->signal->flags & SIGNAL_STOP_STOPPED)
+   return >signal->group_exit_code;
return NULL;
 }
 
 /**
  * wait_task_stopped - Wait for %TASK_STOPPED or %TASK_TRACED
  * @wo: wait options
- * @ptrace: is the wait for ptrace
  * @p: task to wait for
  *
  * Handle sys_wait4() work for %p in state %TASK_STOPPED or %TASK_TRACED.
@@ -1181,49 +1182,47 @@ static int *task_stopped_code(struct task_struct *p, 
bool ptrace)
  * success, implies that tasklist_lock is released and wait condition
  * search should terminate.
  */
-static int wait_task_stopped(struct wait_opts *wo,
-   int ptrace, struct task_struct *p)
+static int wait_task_stopped(struct wait_opts *wo, struct task_struct *p)
 {
struct siginfo __user *infop;
-   int retval, exit_code, *p_code, why;
-   uid_t uid = 0; /* unneeded, required by compiler */
+   int retval, exit_code, *p_code, *g_code, why;
+   bool group, gstop, pstop;
+   uid_t uid;
pid_t pid;
 
/*
-* Hide group stop state from real parent; otherwise a single
-* stop can be reported twice as group and ptrace stop.  If a
-* ptracer wants to distinguish these two events for its own
-* children it should create a separate process which takes the
-* role of real parent.
-*/
-   if (!ptrace && p->ptrace && !ptrace_reparented(p))
-   ptrace = 1;
-
-   /*
 * Traditionally we see ptrace'd stopped tasks regardless of options.
 */
-   if (!ptrace && !(wo->wo_flags & WUNTRACED))
+   group = thread_group_leader(p) && !ptrace_reparented(p);
+   pstop = same_thread_group(current, p->parent);
+   gstop = group && (wo->wo_flags & WUNTRACED);
+   if (!pstop && !gstop)
return 0;
 
-   if (!task_stopped_code(p, ptrace))
+   if ((!pstop || !task_trace_stopped_code(p)) &&
+   (!gstop || !task_group_stopped_code(p)))
return 0;
 
exit_code = 0;
spin_lock_irq(>sighand->siglock);
 
-   p_code = task_stopped_code(p, ptrace);
-   if (unlikely(!p_code))
-   goto unlock_sig;
-
-   exit_code = *p_code;
-   if (!exit_code)
-   goto unlock_sig;
-
-   if (!unlikely(wo->wo_flags & WNOWAIT))
-   *p_code = 0;
-
-   uid = from_kuid_munged(current_user_ns(), task_uid(p));
-unlock_sig:
+   p_code = g_code = NULL;
+   if (pstop)
+   p_code = task_trace_stopped_code(p);
+   if (gstop)
+   g_code = task_group_stopped_code(p);
+   if (p_code) {
+   exit_code = *p_code;
+   why = CLD_TRAPPED;
+   if (!(wo->wo_flags & WNOWAIT))
+   *p_code = 0;
+   }
+   if (g_code && (!exit_code || (*g_code == exit_code))) {
+   exit_code = *g_code;
+

[PATCH] MIPS: fix boot with DT passed via UHI

2017-06-06 Thread Andrea Merello
commit 15f37e158892 ("MIPS: store the appended dtb address in a variable")
seems to have introduced code that relies on delay slots after branch,
however it seems that, since no directive ".set noreorder" is present, the
AS already fills delay slots with NOPs.

This caused failure in assigning proper DT blob address to fw_passed_dtb
variable, causing failure when booting passing DT via UHI; this has been
seen on a Lantiq VR9 SoC (Fritzbox 3370) and u-boot as bootloader.

[0.00] Linux version 4.12.0-fritz+ (andrea@horizon) (gcc version 4.9.0 
(GCC) ) #29 SMP Tue Jun 6 20:49:59 CEST 2017
[0.00] SoC: xRX200 rev 1.2
[0.00] bootconsole [early0] enabled
[0.00] CPU0 revision is: 00019556 (MIPS 34Kc)
[0.00] Determined physical RAM map:
[0.00]  memory: 00696000 @ 2000 (usable)
[0.00]  memory: 00038000 @ 00698000 (usable after init)
[0.00] Wasting 64 bytes for tracking 2 unused pages
[0.00] Kernel panic - not syncing: No memory area to place a bootmap 
bitmap
[0.00] Rebooting in 1 seconds..
[0.00] Reboot failed -- System halted

This patch moves the instruction meant to be placed in the delay slot
before the preceding BEQ instruction, while the delay slot will be
filled with a NOP by the AS.

After this patch the kernel fetches the DR correctly

[0.00] Linux version 4.12.0-fritz+ (andrea@horizon) (gcc version 4.9.0 
(GCC) ) #30 SMP
Tue Jun 6 20:52:40 CEST 2017
[0.00] SoC: xRX200 rev 1.2
[0.00] bootconsole [early0] enabled
[0.00] CPU0 revision is: 00019556 (MIPS 34Kc)
[0.00] MIPS: machine is FRITZ3370 - Fritz!Box WLAN 3370
[0.00] Determined physical RAM map:
[0.00]  memory: 0800 @  (usable)
[0.00] Detected 1 available secondary CPU(s)
[0.00] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes.
[0.00] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 
bytes
[0.00] Zone ranges:
[0.00]   Normal   [mem 0x-0x07ff]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x-0x07ff]
[0.00] Initmem setup node 0 [mem 0x-0x07ff]
[0.00] percpu: Embedded 15 pages/cpu @8110c000 s30176 r8192 d23072 
u61440
[0.00] Built 1 zonelists in Zone order, mobility grouping on.  Total 
pages: 32512
[0.00] Kernel command line: rootwait root=/dev/sda1 console=ttyLTQ0
...

Cc: linux-kernel@vger.kernel.org
Cc: Jonas Gorski 
Cc: Daniel Schwierzeck 
Signed-off-by: Andrea Merello 

diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index cf05220..d1bb506 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -106,8 +106,8 @@ NESTED(kernel_entry, 16, sp)# 
kernel entry point
beq t0, t1, dtb_found
 #endif
li  t1, -2
-   beq a0, t1, dtb_found
movet2, a1
+   beq a0, t1, dtb_found
 
li  t2, 0
 dtb_found:
-- 
2.7.4



[PATCH 18/26] wait: Fix WSTOPPED on a ptraced child

2017-06-06 Thread Eric W. Biederman
When ptracing waitpid(pid, WUNTRACED) has two possible meanings.
- Wait for ptrace stops from the task with tid == pid
- Wait for ordinary stops from the process with tgid == pid

The only sensible behavior and the Linux behavior in 2.2 and
2.4 has been to consume both ptrace stops and group stops
in this case.  It looks like when Oleg disentangled thread
stops and group stops in 2.6.30 fixing a lot of other issues
the case when we want to reap both was overlooked.

Consume both the group and the ptrace stop state when
waitpid(pid, WUNTRACED) could be asking for both, and
the wait status for both is idenitical.  This keeps
us from double reporting the stop and causing confusion.

This is very slight user visible change and is only visible
in the unlikely case a ptracer specifies WUNTRACED aka
WSTOPPED.

Write this code in such a way that it doesn't matter which
list we are traversing when we find a child whose stop states
we care about.

Fixes: 90bc8d8b1a38 ("do_wait: fix waiting for the group stop with the dead 
leader")
Signed-off-by: "Eric W. Biederman" 
---
 kernel/exit.c | 82 +--
 1 file changed, 40 insertions(+), 42 deletions(-)

diff --git a/kernel/exit.c b/kernel/exit.c
index ff2ed1d60a8c..4e2d2b6f5581 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -1151,22 +1151,23 @@ static int wait_task_zombie(struct wait_opts *wo, int 
old_state, struct task_str
return retval;
 }
 
-static int *task_stopped_code(struct task_struct *p, bool ptrace)
+static int *task_trace_stopped_code(struct task_struct *p)
 {
-   if (ptrace) {
-   if (task_is_traced(p) && !(p->jobctl & JOBCTL_LISTENING))
-   return >exit_code;
-   } else {
-   if (p->signal->flags & SIGNAL_STOP_STOPPED)
-   return >signal->group_exit_code;
-   }
+   if (task_is_traced(p) && !(p->jobctl & JOBCTL_LISTENING))
+   return >exit_code;
+   return NULL;
+}
+
+static int *task_group_stopped_code(struct task_struct *p)
+{
+   if (p->signal->flags & SIGNAL_STOP_STOPPED)
+   return >signal->group_exit_code;
return NULL;
 }
 
 /**
  * wait_task_stopped - Wait for %TASK_STOPPED or %TASK_TRACED
  * @wo: wait options
- * @ptrace: is the wait for ptrace
  * @p: task to wait for
  *
  * Handle sys_wait4() work for %p in state %TASK_STOPPED or %TASK_TRACED.
@@ -1181,49 +1182,47 @@ static int *task_stopped_code(struct task_struct *p, 
bool ptrace)
  * success, implies that tasklist_lock is released and wait condition
  * search should terminate.
  */
-static int wait_task_stopped(struct wait_opts *wo,
-   int ptrace, struct task_struct *p)
+static int wait_task_stopped(struct wait_opts *wo, struct task_struct *p)
 {
struct siginfo __user *infop;
-   int retval, exit_code, *p_code, why;
-   uid_t uid = 0; /* unneeded, required by compiler */
+   int retval, exit_code, *p_code, *g_code, why;
+   bool group, gstop, pstop;
+   uid_t uid;
pid_t pid;
 
/*
-* Hide group stop state from real parent; otherwise a single
-* stop can be reported twice as group and ptrace stop.  If a
-* ptracer wants to distinguish these two events for its own
-* children it should create a separate process which takes the
-* role of real parent.
-*/
-   if (!ptrace && p->ptrace && !ptrace_reparented(p))
-   ptrace = 1;
-
-   /*
 * Traditionally we see ptrace'd stopped tasks regardless of options.
 */
-   if (!ptrace && !(wo->wo_flags & WUNTRACED))
+   group = thread_group_leader(p) && !ptrace_reparented(p);
+   pstop = same_thread_group(current, p->parent);
+   gstop = group && (wo->wo_flags & WUNTRACED);
+   if (!pstop && !gstop)
return 0;
 
-   if (!task_stopped_code(p, ptrace))
+   if ((!pstop || !task_trace_stopped_code(p)) &&
+   (!gstop || !task_group_stopped_code(p)))
return 0;
 
exit_code = 0;
spin_lock_irq(>sighand->siglock);
 
-   p_code = task_stopped_code(p, ptrace);
-   if (unlikely(!p_code))
-   goto unlock_sig;
-
-   exit_code = *p_code;
-   if (!exit_code)
-   goto unlock_sig;
-
-   if (!unlikely(wo->wo_flags & WNOWAIT))
-   *p_code = 0;
-
-   uid = from_kuid_munged(current_user_ns(), task_uid(p));
-unlock_sig:
+   p_code = g_code = NULL;
+   if (pstop)
+   p_code = task_trace_stopped_code(p);
+   if (gstop)
+   g_code = task_group_stopped_code(p);
+   if (p_code) {
+   exit_code = *p_code;
+   why = CLD_TRAPPED;
+   if (!(wo->wo_flags & WNOWAIT))
+   *p_code = 0;
+   }
+   if (g_code && (!exit_code || (*g_code == exit_code))) {
+   exit_code = *g_code;
+   why = 

[PATCH] MIPS: fix boot with DT passed via UHI

2017-06-06 Thread Andrea Merello
commit 15f37e158892 ("MIPS: store the appended dtb address in a variable")
seems to have introduced code that relies on delay slots after branch,
however it seems that, since no directive ".set noreorder" is present, the
AS already fills delay slots with NOPs.

This caused failure in assigning proper DT blob address to fw_passed_dtb
variable, causing failure when booting passing DT via UHI; this has been
seen on a Lantiq VR9 SoC (Fritzbox 3370) and u-boot as bootloader.

[0.00] Linux version 4.12.0-fritz+ (andrea@horizon) (gcc version 4.9.0 
(GCC) ) #29 SMP Tue Jun 6 20:49:59 CEST 2017
[0.00] SoC: xRX200 rev 1.2
[0.00] bootconsole [early0] enabled
[0.00] CPU0 revision is: 00019556 (MIPS 34Kc)
[0.00] Determined physical RAM map:
[0.00]  memory: 00696000 @ 2000 (usable)
[0.00]  memory: 00038000 @ 00698000 (usable after init)
[0.00] Wasting 64 bytes for tracking 2 unused pages
[0.00] Kernel panic - not syncing: No memory area to place a bootmap 
bitmap
[0.00] Rebooting in 1 seconds..
[0.00] Reboot failed -- System halted

This patch moves the instruction meant to be placed in the delay slot
before the preceding BEQ instruction, while the delay slot will be
filled with a NOP by the AS.

After this patch the kernel fetches the DR correctly

[0.00] Linux version 4.12.0-fritz+ (andrea@horizon) (gcc version 4.9.0 
(GCC) ) #30 SMP
Tue Jun 6 20:52:40 CEST 2017
[0.00] SoC: xRX200 rev 1.2
[0.00] bootconsole [early0] enabled
[0.00] CPU0 revision is: 00019556 (MIPS 34Kc)
[0.00] MIPS: machine is FRITZ3370 - Fritz!Box WLAN 3370
[0.00] Determined physical RAM map:
[0.00]  memory: 0800 @  (usable)
[0.00] Detected 1 available secondary CPU(s)
[0.00] Primary instruction cache 32kB, VIPT, 4-way, linesize 32 bytes.
[0.00] Primary data cache 32kB, 4-way, VIPT, cache aliases, linesize 32 
bytes
[0.00] Zone ranges:
[0.00]   Normal   [mem 0x-0x07ff]
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x-0x07ff]
[0.00] Initmem setup node 0 [mem 0x-0x07ff]
[0.00] percpu: Embedded 15 pages/cpu @8110c000 s30176 r8192 d23072 
u61440
[0.00] Built 1 zonelists in Zone order, mobility grouping on.  Total 
pages: 32512
[0.00] Kernel command line: rootwait root=/dev/sda1 console=ttyLTQ0
...

Cc: linux-kernel@vger.kernel.org
Cc: Jonas Gorski 
Cc: Daniel Schwierzeck 
Signed-off-by: Andrea Merello 

diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index cf05220..d1bb506 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -106,8 +106,8 @@ NESTED(kernel_entry, 16, sp)# 
kernel entry point
beq t0, t1, dtb_found
 #endif
li  t1, -2
-   beq a0, t1, dtb_found
movet2, a1
+   beq a0, t1, dtb_found
 
li  t2, 0
 dtb_found:
-- 
2.7.4



<    1   2   3   4   5   6   7   8   9   10   >