Re: [PATHC v2 0/9] ima: carry the measurement list across kexec

2016-09-16 Thread Eric W. Biederman
Thiago Jung Bauermann  writes:

> Hello Eric,
>
> Am Freitag, 16 September 2016, 14:47:13 schrieb Eric W. Biederman:
>> Mimi Zohar  writes:
>> > Hi Andrew,
>> > 
>> > On Wed, 2016-08-31 at 18:38 -0400, Mimi Zohar wrote:
>> >> On Wed, 2016-08-31 at 13:50 -0700, Andrew Morton wrote:
>> >> > On Tue, 30 Aug 2016 18:40:02 -0400 Mimi Zohar 
>  wrote:
>> >> > > The TPM PCRs are only reset on a hard reboot.  In order to validate
>> >> > > a
>> >> > > TPM's quote after a soft reboot (eg. kexec -e), the IMA measurement
>> >> > > list
>> >> > > of the running kernel must be saved and then restored on the
>> >> > > subsequent
>> >> > > boot, possibly of a different architecture.
>> >> > > 
>> >> > > The existing securityfs binary_runtime_measurements file
>> >> > > conveniently
>> >> > > provides a serialized format of the IMA measurement list. This
>> >> > > patch
>> >> > > set serializes the measurement list in this format and restores it.
>> >> > > 
>> >> > > Up to now, the binary_runtime_measurements was defined as
>> >> > > architecture
>> >> > > native format.  The assumption being that userspace could and would
>> >> > > handle any architecture conversions.  With the ability of carrying
>> >> > > the
>> >> > > measurement list across kexec, possibly from one architecture to a
>> >> > > different one, the per boot architecture information is lost and
>> >> > > with it
>> >> > > the ability of recalculating the template digest hash.  To resolve
>> >> > > this
>> >> > > problem, without breaking the existing ABI, this patch set
>> >> > > introduces
>> >> > > the boot command line option "ima_canonical_fmt", which is
>> >> > > arbitrarily
>> >> > > defined as little endian.
>> >> > > 
>> >> > > The need for this boot command line option will be limited to the
>> >> > > existing version 1 format of the binary_runtime_measurements.
>> >> > > Subsequent formats will be defined as canonical format (eg. TPM 2.0
>> >> > > support for larger digests).
>> >> > > 
>> >> > > This patch set pre-req's Thiago Bauermann's "kexec_file: Add buffer
>> >> > > hand-over for the next kernel" patch set.
>> >> > > 
>> >> > > These patches can also be found in the next-kexec-restore branch
>> >> > > of:
>> >> > > git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity
>> >> > > .git
>> >> > 
>> >> > I'll merge these into -mm to get some linux-next exposure.  I don't
>> >> > know what your upstream merge plans will be?
>> >> 
>> >> Sounds good.  I'm hoping to get some review/comments on this patch set
>> >> as well.  At the moment, I'm chasing down a kernel test robot report
>> >> from this afternoon.
>> > 
>> > My concern about changing the canonical format as originally defined in
>> > patch 9/9 from big endian to little endian never materialized.  Andreas
>> > Steffan, the patch author, is happy either way.
>> > 
>> > We proposed two methods of addressing Eric Biederman's concerns of not
>> > including the IMA measurement list segment in the kexec hash as
>> > described in  https://lkml.org/lkml/2016/9/9/355.
>> > 
>> > - defer calculating and verifying the serialized IMA measurement list
>> > buffer hash to IMA
>> > - calculate the kexec hash on load, verify it on the kexec execute,
>> > before re-calculating and updating it.
>> 
>> I need to ask: How this is anticipated to interact with kexec on panic?
>> Because honestly I can't see this ever working in that case.  The
>> assumption is that the original kernel has gone crazy.  So from a
>> practical standpoint any trusted path should have been invalided.
>
> We are not interested in carrying the measurement list in the case of kexec 
> on panic. I see that the code is adding a hand-over buffer to the crash 
> image as well, but that is a bug.
>
> The fix is to do nothing in ima_add_kexec_buffer if image->type != 
> KEXEC_TYPE_DEFAULT.
>  
>> This entire idea of updating the kexec image makes me extremely
>> extremely nervious.  It feels like sticking a screw driver through the
>> spokes of your bicicle tires while ridding down the road.
>> 
>> I can see tracking to see if the list has changed at some
>> point and causing a reboot(LINUX_REBOOT_CMD_KEXEC) to fail.
>
> Yes, that is an interesting feature that I can add using the checksum-
> verifying part of my code. I can submit a patch for that if there's 
> interest, adding a reboot notifier that verifies the checksum and causes a 
> regular reboot instead of a kexec reboot if the checksum fails.

I was thinking an early failure instead of getting all of the way down
into a kernel an discovering the tpm/ima subsystem would not
initialized.  But where that falls in the reboot pathway I don't expect
there is much value in it.

>> At least the common bootloader cases that I know of using kexec are very
>> minimal distributions that live in a ramdisk and as such it should be
>> very straight forward to measure what is needed at or before
>> 

Re: [PATHC v2 0/9] ima: carry the measurement list across kexec

2016-09-16 Thread Eric W. Biederman
Thiago Jung Bauermann  writes:

> Hello Eric,
>
> Am Freitag, 16 September 2016, 14:47:13 schrieb Eric W. Biederman:
>> Mimi Zohar  writes:
>> > Hi Andrew,
>> > 
>> > On Wed, 2016-08-31 at 18:38 -0400, Mimi Zohar wrote:
>> >> On Wed, 2016-08-31 at 13:50 -0700, Andrew Morton wrote:
>> >> > On Tue, 30 Aug 2016 18:40:02 -0400 Mimi Zohar 
>  wrote:
>> >> > > The TPM PCRs are only reset on a hard reboot.  In order to validate
>> >> > > a
>> >> > > TPM's quote after a soft reboot (eg. kexec -e), the IMA measurement
>> >> > > list
>> >> > > of the running kernel must be saved and then restored on the
>> >> > > subsequent
>> >> > > boot, possibly of a different architecture.
>> >> > > 
>> >> > > The existing securityfs binary_runtime_measurements file
>> >> > > conveniently
>> >> > > provides a serialized format of the IMA measurement list. This
>> >> > > patch
>> >> > > set serializes the measurement list in this format and restores it.
>> >> > > 
>> >> > > Up to now, the binary_runtime_measurements was defined as
>> >> > > architecture
>> >> > > native format.  The assumption being that userspace could and would
>> >> > > handle any architecture conversions.  With the ability of carrying
>> >> > > the
>> >> > > measurement list across kexec, possibly from one architecture to a
>> >> > > different one, the per boot architecture information is lost and
>> >> > > with it
>> >> > > the ability of recalculating the template digest hash.  To resolve
>> >> > > this
>> >> > > problem, without breaking the existing ABI, this patch set
>> >> > > introduces
>> >> > > the boot command line option "ima_canonical_fmt", which is
>> >> > > arbitrarily
>> >> > > defined as little endian.
>> >> > > 
>> >> > > The need for this boot command line option will be limited to the
>> >> > > existing version 1 format of the binary_runtime_measurements.
>> >> > > Subsequent formats will be defined as canonical format (eg. TPM 2.0
>> >> > > support for larger digests).
>> >> > > 
>> >> > > This patch set pre-req's Thiago Bauermann's "kexec_file: Add buffer
>> >> > > hand-over for the next kernel" patch set.
>> >> > > 
>> >> > > These patches can also be found in the next-kexec-restore branch
>> >> > > of:
>> >> > > git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity
>> >> > > .git
>> >> > 
>> >> > I'll merge these into -mm to get some linux-next exposure.  I don't
>> >> > know what your upstream merge plans will be?
>> >> 
>> >> Sounds good.  I'm hoping to get some review/comments on this patch set
>> >> as well.  At the moment, I'm chasing down a kernel test robot report
>> >> from this afternoon.
>> > 
>> > My concern about changing the canonical format as originally defined in
>> > patch 9/9 from big endian to little endian never materialized.  Andreas
>> > Steffan, the patch author, is happy either way.
>> > 
>> > We proposed two methods of addressing Eric Biederman's concerns of not
>> > including the IMA measurement list segment in the kexec hash as
>> > described in  https://lkml.org/lkml/2016/9/9/355.
>> > 
>> > - defer calculating and verifying the serialized IMA measurement list
>> > buffer hash to IMA
>> > - calculate the kexec hash on load, verify it on the kexec execute,
>> > before re-calculating and updating it.
>> 
>> I need to ask: How this is anticipated to interact with kexec on panic?
>> Because honestly I can't see this ever working in that case.  The
>> assumption is that the original kernel has gone crazy.  So from a
>> practical standpoint any trusted path should have been invalided.
>
> We are not interested in carrying the measurement list in the case of kexec 
> on panic. I see that the code is adding a hand-over buffer to the crash 
> image as well, but that is a bug.
>
> The fix is to do nothing in ima_add_kexec_buffer if image->type != 
> KEXEC_TYPE_DEFAULT.
>  
>> This entire idea of updating the kexec image makes me extremely
>> extremely nervious.  It feels like sticking a screw driver through the
>> spokes of your bicicle tires while ridding down the road.
>> 
>> I can see tracking to see if the list has changed at some
>> point and causing a reboot(LINUX_REBOOT_CMD_KEXEC) to fail.
>
> Yes, that is an interesting feature that I can add using the checksum-
> verifying part of my code. I can submit a patch for that if there's 
> interest, adding a reboot notifier that verifies the checksum and causes a 
> regular reboot instead of a kexec reboot if the checksum fails.

I was thinking an early failure instead of getting all of the way down
into a kernel an discovering the tpm/ima subsystem would not
initialized.  But where that falls in the reboot pathway I don't expect
there is much value in it.

>> At least the common bootloader cases that I know of using kexec are very
>> minimal distributions that live in a ramdisk and as such it should be
>> very straight forward to measure what is needed at or before
>> sys_kexec_load.  But that was completely dismissed as unrealistic so I
>> don't have 

Re: TRIM/UNMAP/DISCARD via ATA Passthrough

2016-09-16 Thread James Bottomley
On Fri, 2016-09-16 at 13:06 -0400, Austin S. Hemmelgarn wrote:
> On 2016-09-16 12:21, James Bottomley wrote:
> > On Fri, 2016-09-16 at 11:53 -0400, Austin S. Hemmelgarn wrote:
> > > On 2016-09-16 07:16, Hannes Reinecke wrote:
> > > > On 09/15/2016 10:52 PM, Jason A. Donenfeld wrote:
> > > > > Hi Martin,
> > > > > 
> > > > > On Thu, Sep 15, 2016 at 6:07 PM, Martin K. Petersen
> > > > > > But how do they signal that ATA passthrough is possible? Is
> > > > > > there an ATA Information VPD page? Is REPORT SUPPORTED
> > > > > > OPERATION CODES supported?
> > > > > > 
> > > > > > We need really solid discovery data before we can entertain
> > > > > > enabling something like this.
> > > > > 
> > > > > `sg_opcodes` said invalid request, so I think there isn't REPORT
> > > > > SUPPORTED OPERATION CODES, and `sg_vpd -p ai` came up illegal
> > > > > too.
> > > > > 
> > > > > However, sg_sat_identify worked reliably, which means a solid way
> > > > > of probing this would be to send IDENTIFY DEVICE ATA via
> > > > > SG_ATA_16 or SG_ATA_12.
> > > > > 
> > > > > Let me know and I can give you access to the hardware if you're
> > > > > curious.
> > > > > 
> > > > Sadly, that's not sufficient.
> > > > linux is not the only provider of an SATL (mpt3sas being the most
> > > > prominent other one).
> > > > And while they might support ATA_12/ATA_16, there is no indication
> > > > that you can pass DSM TRIM that way.
> > > So it's better to not support it at all than to support it on
> > > hardware we can reliably identify?
> > > 
> > > I get that having feature parity is a good thing, but the discussion
> > > isn't about providing support for all SATL devices, it's specifically
> > > about UAS connected SATL devices.  Last I checked, mpt3sas doesn't do
> > > anything with UAS, which means it's kind of irrelevant WRT supporting
> > > this for UAS devices.
> > 
> > We're getting a bit off topic on mptsas and it's eccentric SATL.
> > 
> > The point is, you're asking for UAS devices which each have an internal
> > SATL which you say potentially doesn't support discard.  The three
> > problems we have are
> > 
> >1. How do we identify if the UAS SATL doesn't support discard.  If it
> >   does, we really don't want to cause further SATL related issues by
> >   bypassing it, so we need a way of telling this.
> >2. If the SATL doesn't support discard, will it reliably support the
> >   ATA_12 or ATA_16 pass through (and which one) .. we need a way of
> >   checking this because there are known SATLs that don't do pass
> >   through.
> >3. How do we actually configure it?  Presumably if the SATL doesn't
> >   support discard, it also doesn't give us the useful mode page
> >   indications we use to configure TRIM, so we're going to have to do
> >   some pass through discovery as well.
> I assume by 'discard' here you're referring to SCSI UNMAP, as 
> anything that supports ATA_12 or ATA_16 pass through correctly will 
> support ATA TRIM/DISCARD on drives that support it.

discard is the block layer terminology it's mapped per transport to
UNMAP or WRITE SAME on SCSI and TRIM on ATA.

>   If that's the case, then:
> 1. If SCSI UNMAP fails, it doesn't support UNMAP.  This is of course 
> non-trivial to verify safely (we pretty much have to assume it is 
> supported if we have no clear indication it isn't, and then switch 
> based on what happens the first time we try to use it).

It's not quite that simple: to get us to configure discard in the first
place, you have to indicate support in READ CAPACITY (16): the LBPME
bit.  The chances are your UAS SATL isn't setting this.

> 2. Unless there are SATL's out there that write garbage to the device 
> or die when sent an ATA_12 or ATA_16 pass through command


Yes, there are; the problems with USB devices that fail to speak
standard versions of SCSI are legion.

> encapsulating an ATA DEVICE IDENTIFY command, this isn't an issue. 
>  Even if such SATL's exist, they can easily be blacklisted.
> 3. This isn't hard, a SATL which actually supports ATA pass through 
> will almost always pass through the mode page unmodified.

You mean the ATA Information VPD page?  Yes, that's feasible because we
already queried the supported VPD pages, so we can tell if this one's
there.

> On the note of UAS SATL's, all of them that I've seen fall into one 
> of four categories:
> 1. Supports one or both of ATA_12 or ATA_16 pass through, and 
> supports passing through ATA TRIM/DISCARD, but not SCSI UNMAP.
> 2. Supports one of ATA_12 or ATA_16 pass through, and does not 
> support passing through ATA TRIM/DISCARD or translating SCSI UNMAP. 
>  All devices I've seen that fit this will modify the ATA DEVICE 
> IDENTIFY data so it doesn't report DISCARD support, or will simply 
> return an error for DISCARD requests.  I haven't seen any like this 
> that were manufactured after UAS became standardized.
> 3. Supports neither ATA_12 or ATA_16 pass through, and doesn't 
> 

Re: TRIM/UNMAP/DISCARD via ATA Passthrough

2016-09-16 Thread James Bottomley
On Fri, 2016-09-16 at 13:06 -0400, Austin S. Hemmelgarn wrote:
> On 2016-09-16 12:21, James Bottomley wrote:
> > On Fri, 2016-09-16 at 11:53 -0400, Austin S. Hemmelgarn wrote:
> > > On 2016-09-16 07:16, Hannes Reinecke wrote:
> > > > On 09/15/2016 10:52 PM, Jason A. Donenfeld wrote:
> > > > > Hi Martin,
> > > > > 
> > > > > On Thu, Sep 15, 2016 at 6:07 PM, Martin K. Petersen
> > > > > > But how do they signal that ATA passthrough is possible? Is
> > > > > > there an ATA Information VPD page? Is REPORT SUPPORTED
> > > > > > OPERATION CODES supported?
> > > > > > 
> > > > > > We need really solid discovery data before we can entertain
> > > > > > enabling something like this.
> > > > > 
> > > > > `sg_opcodes` said invalid request, so I think there isn't REPORT
> > > > > SUPPORTED OPERATION CODES, and `sg_vpd -p ai` came up illegal
> > > > > too.
> > > > > 
> > > > > However, sg_sat_identify worked reliably, which means a solid way
> > > > > of probing this would be to send IDENTIFY DEVICE ATA via
> > > > > SG_ATA_16 or SG_ATA_12.
> > > > > 
> > > > > Let me know and I can give you access to the hardware if you're
> > > > > curious.
> > > > > 
> > > > Sadly, that's not sufficient.
> > > > linux is not the only provider of an SATL (mpt3sas being the most
> > > > prominent other one).
> > > > And while they might support ATA_12/ATA_16, there is no indication
> > > > that you can pass DSM TRIM that way.
> > > So it's better to not support it at all than to support it on
> > > hardware we can reliably identify?
> > > 
> > > I get that having feature parity is a good thing, but the discussion
> > > isn't about providing support for all SATL devices, it's specifically
> > > about UAS connected SATL devices.  Last I checked, mpt3sas doesn't do
> > > anything with UAS, which means it's kind of irrelevant WRT supporting
> > > this for UAS devices.
> > 
> > We're getting a bit off topic on mptsas and it's eccentric SATL.
> > 
> > The point is, you're asking for UAS devices which each have an internal
> > SATL which you say potentially doesn't support discard.  The three
> > problems we have are
> > 
> >1. How do we identify if the UAS SATL doesn't support discard.  If it
> >   does, we really don't want to cause further SATL related issues by
> >   bypassing it, so we need a way of telling this.
> >2. If the SATL doesn't support discard, will it reliably support the
> >   ATA_12 or ATA_16 pass through (and which one) .. we need a way of
> >   checking this because there are known SATLs that don't do pass
> >   through.
> >3. How do we actually configure it?  Presumably if the SATL doesn't
> >   support discard, it also doesn't give us the useful mode page
> >   indications we use to configure TRIM, so we're going to have to do
> >   some pass through discovery as well.
> I assume by 'discard' here you're referring to SCSI UNMAP, as 
> anything that supports ATA_12 or ATA_16 pass through correctly will 
> support ATA TRIM/DISCARD on drives that support it.

discard is the block layer terminology it's mapped per transport to
UNMAP or WRITE SAME on SCSI and TRIM on ATA.

>   If that's the case, then:
> 1. If SCSI UNMAP fails, it doesn't support UNMAP.  This is of course 
> non-trivial to verify safely (we pretty much have to assume it is 
> supported if we have no clear indication it isn't, and then switch 
> based on what happens the first time we try to use it).

It's not quite that simple: to get us to configure discard in the first
place, you have to indicate support in READ CAPACITY (16): the LBPME
bit.  The chances are your UAS SATL isn't setting this.

> 2. Unless there are SATL's out there that write garbage to the device 
> or die when sent an ATA_12 or ATA_16 pass through command


Yes, there are; the problems with USB devices that fail to speak
standard versions of SCSI are legion.

> encapsulating an ATA DEVICE IDENTIFY command, this isn't an issue. 
>  Even if such SATL's exist, they can easily be blacklisted.
> 3. This isn't hard, a SATL which actually supports ATA pass through 
> will almost always pass through the mode page unmodified.

You mean the ATA Information VPD page?  Yes, that's feasible because we
already queried the supported VPD pages, so we can tell if this one's
there.

> On the note of UAS SATL's, all of them that I've seen fall into one 
> of four categories:
> 1. Supports one or both of ATA_12 or ATA_16 pass through, and 
> supports passing through ATA TRIM/DISCARD, but not SCSI UNMAP.
> 2. Supports one of ATA_12 or ATA_16 pass through, and does not 
> support passing through ATA TRIM/DISCARD or translating SCSI UNMAP. 
>  All devices I've seen that fit this will modify the ATA DEVICE 
> IDENTIFY data so it doesn't report DISCARD support, or will simply 
> return an error for DISCARD requests.  I haven't seen any like this 
> that were manufactured after UAS became standardized.
> 3. Supports neither ATA_12 or ATA_16 pass through, and doesn't 
> 

Re: [PATCH v1 3/3] ARM: dts: imx6qdl-apalis: Use enable-gpios property for backlight

2016-09-16 Thread maitysanchayan
Hello Marcel,

On 16-09-16 13:38:54, Marcel Ziswiler wrote:
> On Wed, 2016-09-14 at 12:05 +0530, Sanchayan Maity wrote:
> > Use enable-gpios property of PWM backlight driver for backlight
> > control. While at it also fix the use of brightness levels required
> > by EDT displays which require inverted PWM's.
> 
> That part I am missing below. Did you forget to include it?

No, actually I missed fixing the commit message. Currently PWM polarity
inversion is not supported and while checking, I kept the brightness
levels as is currently but did not change the commit message.

Will send a v2 and fix this.

Regards,
Sanchayan.

> 
> > Signed-off-by: Sanchayan Maity 
> > ---
> >  arch/arm/boot/dts/imx6qdl-apalis.dtsi | 9 +
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> > b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> > index 8c67dd8..9100bde 100644
> > --- a/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> > +++ b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> > @@ -49,7 +49,10 @@
> >  
> >     backlight: backlight {
> >     compatible = "pwm-backlight";
> > +   pinctrl-names = "default";
> > +   pinctrl-0 = <_gpio_bl_on>;
> >     pwms = < 0 500>;
> > +   enable-gpios = < 13 GPIO_ACTIVE_HIGH>;
> >     status = "disabled";
> >     };
> >  
> > @@ -614,6 +617,12 @@
> >     >;
> >     };
> >  
> > +   pinctrl_gpio_bl_on: gpioblon {
> > +   fsl,pins = <
> > +   MX6QDL_PAD_EIM_DA13__GPIO3_IO13 0x1b0b0
> > +   >;
> > +   };
> > +
> >     pinctrl_gpio_keys: gpio1io04grp {
> >     fsl,pins = <
> >     /* Power button */


Re: [PATCH v1 3/3] ARM: dts: imx6qdl-apalis: Use enable-gpios property for backlight

2016-09-16 Thread maitysanchayan
Hello Marcel,

On 16-09-16 13:38:54, Marcel Ziswiler wrote:
> On Wed, 2016-09-14 at 12:05 +0530, Sanchayan Maity wrote:
> > Use enable-gpios property of PWM backlight driver for backlight
> > control. While at it also fix the use of brightness levels required
> > by EDT displays which require inverted PWM's.
> 
> That part I am missing below. Did you forget to include it?

No, actually I missed fixing the commit message. Currently PWM polarity
inversion is not supported and while checking, I kept the brightness
levels as is currently but did not change the commit message.

Will send a v2 and fix this.

Regards,
Sanchayan.

> 
> > Signed-off-by: Sanchayan Maity 
> > ---
> >  arch/arm/boot/dts/imx6qdl-apalis.dtsi | 9 +
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> > b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> > index 8c67dd8..9100bde 100644
> > --- a/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> > +++ b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> > @@ -49,7 +49,10 @@
> >  
> >     backlight: backlight {
> >     compatible = "pwm-backlight";
> > +   pinctrl-names = "default";
> > +   pinctrl-0 = <_gpio_bl_on>;
> >     pwms = < 0 500>;
> > +   enable-gpios = < 13 GPIO_ACTIVE_HIGH>;
> >     status = "disabled";
> >     };
> >  
> > @@ -614,6 +617,12 @@
> >     >;
> >     };
> >  
> > +   pinctrl_gpio_bl_on: gpioblon {
> > +   fsl,pins = <
> > +   MX6QDL_PAD_EIM_DA13__GPIO3_IO13 0x1b0b0
> > +   >;
> > +   };
> > +
> >     pinctrl_gpio_keys: gpio1io04grp {
> >     fsl,pins = <
> >     /* Power button */


RE: [PATCH 0/2] PCI/AER: Remove module parameters

2016-09-16 Thread Tang, CQ
Bjorn,
 Can we extend this aerdriver to support AER from a root complex integrated 
endpoint? Root complex event collector has the same job as root port in this 
case.

 It looks that both port driver and aer driver check 
PCI_EXP_TYPE_ROOT_PORT/PCI_EXP_TYPE_UPSTREAM/PCI_EXP_TYPE_DOWNSTREAM only.
portdrv_pci.c:127, aerdrv.c:86

  Is it just a simple addition of PCI_EXP_TYPE_RC_EC to above two places?  
Is there any difference to recover a root complex integrated endpoint? 
(compared with devices connected to root port).

Thanks.
--CQ

> -Original Message-
> From: linux-pci-ow...@vger.kernel.org [mailto:linux-pci-
> ow...@vger.kernel.org] On Behalf Of Bjorn Helgaas
> Sent: Wednesday, September 14, 2016 1:30 PM
> To: Bjorn Helgaas 
> Cc: linux-...@vger.kernel.org; Lance Ortiz ; Betty Dall
> ; Hidetoshi Seto ;
> Chen Gong ; keithbuschkeith.bu...@intel.com;
> Rafael J. Wysocki ; linux-kernel@vger.kernel.org; Shuah
> Khan ; Huang, Ying ;
> Vijay Mohan Pandarathil ; Derrick,
> Jonathan 
> Subject: Re: [PATCH 0/2] PCI/AER: Remove module parameters
> 
> On Tue, Sep 06, 2016 at 05:19:22PM -0500, Bjorn Helgaas wrote:
> > I'd like to remove the aerdriver.nosourceid and aerdriver.forceload
> > kernel parameters.  They seem like basically debugging things that are
> > not really supportable upstream.
> >
> > "nosourceid" may have some legitimate uses, but I'd rather it were
> > done via quirks with the flag Jon Derrick recently added so it happens
> > automatically, without users having to specify the parameter.
> >
> > I don't *know* of any actual users of either of these, but obviously
> > that doesn't mean there are none.  Comments welcome.
> >
> > ---
> >
> > Bjorn Helgaas (2):
> >   PCI/AER: Remove aerdriver.nosourceid kernel parameter
> >   PCI/AER: Remove aerdriver.forceload kernel parameter
> >
> >
> >  Documentation/PCI/pcieaer-howto.txt |   26 +-
> >  drivers/pci/pcie/aer/aerdrv.c   |7 +--
> >  drivers/pci/pcie/aer/aerdrv.h   |8 
> >  drivers/pci/pcie/aer/aerdrv_core.c  |   31 ---
> >  4 files changed, 14 insertions(+), 58 deletions(-)
> 
> I'm going to go out on a limb a little bit and apply these to pci/aer for 
> v4.9.
> Please let me know if you trip over any issues.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in the
> body of a message to majord...@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html


RE: [PATCH 0/2] PCI/AER: Remove module parameters

2016-09-16 Thread Tang, CQ
Bjorn,
 Can we extend this aerdriver to support AER from a root complex integrated 
endpoint? Root complex event collector has the same job as root port in this 
case.

 It looks that both port driver and aer driver check 
PCI_EXP_TYPE_ROOT_PORT/PCI_EXP_TYPE_UPSTREAM/PCI_EXP_TYPE_DOWNSTREAM only.
portdrv_pci.c:127, aerdrv.c:86

  Is it just a simple addition of PCI_EXP_TYPE_RC_EC to above two places?  
Is there any difference to recover a root complex integrated endpoint? 
(compared with devices connected to root port).

Thanks.
--CQ

> -Original Message-
> From: linux-pci-ow...@vger.kernel.org [mailto:linux-pci-
> ow...@vger.kernel.org] On Behalf Of Bjorn Helgaas
> Sent: Wednesday, September 14, 2016 1:30 PM
> To: Bjorn Helgaas 
> Cc: linux-...@vger.kernel.org; Lance Ortiz ; Betty Dall
> ; Hidetoshi Seto ;
> Chen Gong ; keithbuschkeith.bu...@intel.com;
> Rafael J. Wysocki ; linux-kernel@vger.kernel.org; Shuah
> Khan ; Huang, Ying ;
> Vijay Mohan Pandarathil ; Derrick,
> Jonathan 
> Subject: Re: [PATCH 0/2] PCI/AER: Remove module parameters
> 
> On Tue, Sep 06, 2016 at 05:19:22PM -0500, Bjorn Helgaas wrote:
> > I'd like to remove the aerdriver.nosourceid and aerdriver.forceload
> > kernel parameters.  They seem like basically debugging things that are
> > not really supportable upstream.
> >
> > "nosourceid" may have some legitimate uses, but I'd rather it were
> > done via quirks with the flag Jon Derrick recently added so it happens
> > automatically, without users having to specify the parameter.
> >
> > I don't *know* of any actual users of either of these, but obviously
> > that doesn't mean there are none.  Comments welcome.
> >
> > ---
> >
> > Bjorn Helgaas (2):
> >   PCI/AER: Remove aerdriver.nosourceid kernel parameter
> >   PCI/AER: Remove aerdriver.forceload kernel parameter
> >
> >
> >  Documentation/PCI/pcieaer-howto.txt |   26 +-
> >  drivers/pci/pcie/aer/aerdrv.c   |7 +--
> >  drivers/pci/pcie/aer/aerdrv.h   |8 
> >  drivers/pci/pcie/aer/aerdrv_core.c  |   31 ---
> >  4 files changed, 14 insertions(+), 58 deletions(-)
> 
> I'm going to go out on a limb a little bit and apply these to pci/aer for 
> v4.9.
> Please let me know if you trip over any issues.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in the
> body of a message to majord...@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html


Re: [PATCH V4] mm: Add sysfs interface to dump each node's zonelist information

2016-09-16 Thread Anshuman Khandual
On 09/12/2016 11:43 PM, David Rientjes wrote:
> On Mon, 12 Sep 2016, Anshuman Khandual wrote:
> 
> after memory or node hot[un]plug is desirable. This change adds one
> new sysfs interface (/sys/devices/system/memory/system_zone_details)
> which will fetch and dump this information.
>>> Doesn't this violate the "one value per file" sysfs rule?  Does it
>>> belong in debugfs instead?
>>
>> Yeah sure. Will make it a debugfs interface.
>>
> 
> So the intended reader of this file is running as root?

Yeah.

> 
>>> I also really question the need to dump kernel addresses out, filtered 
>>> or not.  What's the point?
>>
>> Hmm, thought it to be an additional information. But yes its additional
>> and can be dropped.
>>
> 
> I'm questioning if this information can be inferred from information 
> already in /proc/zoneinfo and sysfs.  We know the no-fallback zonelist is 
> going to include the local node, and we know the other zonelists are 
> either node ordered or zone ordered (or do we need to extend 
> vm.numa_zonelist_order for default?).  I may have missed what new 
> knowledge this interface is imparting on us.

IIUC /proc/zoneinfo lists down zone internal state and statistics for
all zones on the system at any given point of time. The no-fallback
list contains the zones from the local node and fallback (which gets
used more often than the no-fallback) list contains all zones either
in node-ordered or zone-ordered manner. In most of the platforms the
default being the node order but the sequence of present nodes in
that order is determined by various factors like NUMA distance, load,
presence of CPUs on the node etc. This order of nodes in the fallback
list is the most important information derived out of this interface.



Re: [PATCH V4] mm: Add sysfs interface to dump each node's zonelist information

2016-09-16 Thread Anshuman Khandual
On 09/12/2016 11:43 PM, David Rientjes wrote:
> On Mon, 12 Sep 2016, Anshuman Khandual wrote:
> 
> after memory or node hot[un]plug is desirable. This change adds one
> new sysfs interface (/sys/devices/system/memory/system_zone_details)
> which will fetch and dump this information.
>>> Doesn't this violate the "one value per file" sysfs rule?  Does it
>>> belong in debugfs instead?
>>
>> Yeah sure. Will make it a debugfs interface.
>>
> 
> So the intended reader of this file is running as root?

Yeah.

> 
>>> I also really question the need to dump kernel addresses out, filtered 
>>> or not.  What's the point?
>>
>> Hmm, thought it to be an additional information. But yes its additional
>> and can be dropped.
>>
> 
> I'm questioning if this information can be inferred from information 
> already in /proc/zoneinfo and sysfs.  We know the no-fallback zonelist is 
> going to include the local node, and we know the other zonelists are 
> either node ordered or zone ordered (or do we need to extend 
> vm.numa_zonelist_order for default?).  I may have missed what new 
> knowledge this interface is imparting on us.

IIUC /proc/zoneinfo lists down zone internal state and statistics for
all zones on the system at any given point of time. The no-fallback
list contains the zones from the local node and fallback (which gets
used more often than the no-fallback) list contains all zones either
in node-ordered or zone-ordered manner. In most of the platforms the
default being the node order but the sequence of present nodes in
that order is determined by various factors like NUMA distance, load,
presence of CPUs on the node etc. This order of nodes in the fallback
list is the most important information derived out of this interface.



Re: [REGRESSION] RLIMIT_DATA crashes named

2016-09-16 Thread Joe Perches
On Fri, 2016-09-16 at 17:040700, Linus Torvalds wrote:
> On Fri, Sep 16, 2016 at 4:58 PM, Linus Torvalds 
>  wrote:
> > Here's a totally untested patch. What do people say?
> Heh. It looks like "pr_xyz_once()" is used in places that haven't
> included "ratelimit.h", so this doesn't actually build for everything.
> But I guess as a concept patch it's not hard to understand, even if
> the implementation needs a bit of tweaking.

do_just_once just isn't a good name for a global
rate limited mechanism that does something very
different than the name.

Maybe allow_once_per_ratelimit or the like

There could be an equivalent do_once

https://lkml.org/lkml/2009/5/22/3



Re: [REGRESSION] RLIMIT_DATA crashes named

2016-09-16 Thread Joe Perches
On Fri, 2016-09-16 at 17:040700, Linus Torvalds wrote:
> On Fri, Sep 16, 2016 at 4:58 PM, Linus Torvalds 
>  wrote:
> > Here's a totally untested patch. What do people say?
> Heh. It looks like "pr_xyz_once()" is used in places that haven't
> included "ratelimit.h", so this doesn't actually build for everything.
> But I guess as a concept patch it's not hard to understand, even if
> the implementation needs a bit of tweaking.

do_just_once just isn't a good name for a global
rate limited mechanism that does something very
different than the name.

Maybe allow_once_per_ratelimit or the like

There could be an equivalent do_once

https://lkml.org/lkml/2009/5/22/3



Re: [PATCH v7 0/5] mfd: tps65218: Clean ups

2016-09-16 Thread Keerthy



On Friday 16 September 2016 11:06 PM, Mark Brown wrote:

On Fri, Sep 16, 2016 at 09:51:38PM +0530, Keerthy wrote:

On Friday 16 September 2016 07:01 PM, Mark Brown wrote:

On Fri, Sep 16, 2016 at 05:12:38PM +0530, Keerthy wrote:



Should i repost this series? I do not see this series in linux-next yet.



Please don't send content free pings and please allow a reasonable time
for review.  People get busy, go on holiday, attend conferences and so



I should have been clearer.
The last Lee Jones conveyed that:



"I can't take this series yet, since it relies on a change which was
taken into Mark's Regulator tree"



https://lkml.org/lkml/2016/8/31/312



So wanted to check if i needed to re-base/repost this series again.
Sorry about the confusion i think that is because of $Subject goof up in the
0th patch of the series.


I'm afraid I've no real idea what this series is about or what patches
it might depend on, sorry.  If you're waiting for me to do something
you'll need to tell me what it is but if it's a dependency that needs
cross merging then reposting this series isn't going to be needed.


The series cleans up mainly the regulator driver and implements
the device tree parsing using the regulator framework. Removes
all the redundant compatibles for the individual regulators.
Adds platform_device_id table for the gpio and power button modules.

This has been reviewed extensively.

Looks like v7 no longer applies directly on the linux-next branch as it 
conflicts with:


https://kernel.googlesource.com/pub/scm/linux/kernel/git/dtor/input/+/722dc54628ca5cffd3b4581b523775aa422b55df

I will rebase and repost on the current linux-next and post v8.





Re: [PATCH v7 0/5] mfd: tps65218: Clean ups

2016-09-16 Thread Keerthy



On Friday 16 September 2016 11:06 PM, Mark Brown wrote:

On Fri, Sep 16, 2016 at 09:51:38PM +0530, Keerthy wrote:

On Friday 16 September 2016 07:01 PM, Mark Brown wrote:

On Fri, Sep 16, 2016 at 05:12:38PM +0530, Keerthy wrote:



Should i repost this series? I do not see this series in linux-next yet.



Please don't send content free pings and please allow a reasonable time
for review.  People get busy, go on holiday, attend conferences and so



I should have been clearer.
The last Lee Jones conveyed that:



"I can't take this series yet, since it relies on a change which was
taken into Mark's Regulator tree"



https://lkml.org/lkml/2016/8/31/312



So wanted to check if i needed to re-base/repost this series again.
Sorry about the confusion i think that is because of $Subject goof up in the
0th patch of the series.


I'm afraid I've no real idea what this series is about or what patches
it might depend on, sorry.  If you're waiting for me to do something
you'll need to tell me what it is but if it's a dependency that needs
cross merging then reposting this series isn't going to be needed.


The series cleans up mainly the regulator driver and implements
the device tree parsing using the regulator framework. Removes
all the redundant compatibles for the individual regulators.
Adds platform_device_id table for the gpio and power button modules.

This has been reviewed extensively.

Looks like v7 no longer applies directly on the linux-next branch as it 
conflicts with:


https://kernel.googlesource.com/pub/scm/linux/kernel/git/dtor/input/+/722dc54628ca5cffd3b4581b523775aa422b55df

I will rebase and repost on the current linux-next and post v8.





[PATCH 2/2] power: bq27xxx_battery: allow kernel poll_interval parameter runtime update

2016-09-16 Thread Matt Ranostay
Fix issue with poll_interval being not updated till the previous
interval expired.

Signed-off-by: Matt Ranostay 
---
 drivers/power/supply/bq27xxx_battery.c | 38 +-
 include/linux/power/bq27xxx_battery.h  |  1 +
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c 
b/drivers/power/supply/bq27xxx_battery.c
index 955424e10ae2..96fd3eec98da 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -39,6 +39,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -390,8 +391,35 @@ static struct {
BQ27XXX_PROP(BQ27421, bq27421_battery_props),
 };
 
+static DEFINE_MUTEX(param_lock);
+static LIST_HEAD(bq27xxx_battery_devices);
+
+static int poll_interval_param_set(const char *val, const struct kernel_param 
*kp)
+{
+   struct bq27xxx_device_info *di;
+   int ret;
+
+   ret = param_set_uint(val, kp);
+   if (ret < 0)
+   return ret;
+
+   mutex_lock(_lock);
+   list_for_each_entry(di, _battery_devices, list) {
+   cancel_delayed_work_sync(>work);
+   schedule_delayed_work(>work, 0);
+   }
+   mutex_unlock(_lock);
+
+   return ret;
+}
+
+static const struct kernel_param_ops param_ops_poll_interval = {
+   .get = param_get_ushort,
+   .set = poll_interval_param_set,
+};
+
 static unsigned int poll_interval = 360;
-module_param(poll_interval, uint, 0644);
+module_param_cb(poll_interval, _ops_poll_interval, _interval, 0644);
 MODULE_PARM_DESC(poll_interval,
 "battery poll interval in seconds - 0 disables polling");
 
@@ -1011,6 +1039,10 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
 
bq27xxx_battery_update(di);
 
+   mutex_lock(_lock);
+   list_add(>list, _battery_devices);
+   mutex_unlock(_lock);
+
return 0;
 
 err_out:
@@ -1036,6 +1068,10 @@ void bq27xxx_battery_teardown(struct bq27xxx_device_info 
*di)
 
power_supply_unregister(di->bat);
 
+   mutex_lock(_lock);
+   list_del(>list);
+   mutex_unlock(_lock);
+
mutex_destroy(>lock);
 }
 EXPORT_SYMBOL_GPL(bq27xxx_battery_teardown);
diff --git a/include/linux/power/bq27xxx_battery.h 
b/include/linux/power/bq27xxx_battery.h
index b50c0492629d..e30deb046156 100644
--- a/include/linux/power/bq27xxx_battery.h
+++ b/include/linux/power/bq27xxx_battery.h
@@ -58,6 +58,7 @@ struct bq27xxx_device_info {
unsigned long last_update;
struct delayed_work work;
struct power_supply *bat;
+   struct list_head list;
struct mutex lock;
u8 *regs;
 };
-- 
2.7.4



[PATCH 2/2] power: bq27xxx_battery: allow kernel poll_interval parameter runtime update

2016-09-16 Thread Matt Ranostay
Fix issue with poll_interval being not updated till the previous
interval expired.

Signed-off-by: Matt Ranostay 
---
 drivers/power/supply/bq27xxx_battery.c | 38 +-
 include/linux/power/bq27xxx_battery.h  |  1 +
 2 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c 
b/drivers/power/supply/bq27xxx_battery.c
index 955424e10ae2..96fd3eec98da 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -39,6 +39,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -390,8 +391,35 @@ static struct {
BQ27XXX_PROP(BQ27421, bq27421_battery_props),
 };
 
+static DEFINE_MUTEX(param_lock);
+static LIST_HEAD(bq27xxx_battery_devices);
+
+static int poll_interval_param_set(const char *val, const struct kernel_param 
*kp)
+{
+   struct bq27xxx_device_info *di;
+   int ret;
+
+   ret = param_set_uint(val, kp);
+   if (ret < 0)
+   return ret;
+
+   mutex_lock(_lock);
+   list_for_each_entry(di, _battery_devices, list) {
+   cancel_delayed_work_sync(>work);
+   schedule_delayed_work(>work, 0);
+   }
+   mutex_unlock(_lock);
+
+   return ret;
+}
+
+static const struct kernel_param_ops param_ops_poll_interval = {
+   .get = param_get_ushort,
+   .set = poll_interval_param_set,
+};
+
 static unsigned int poll_interval = 360;
-module_param(poll_interval, uint, 0644);
+module_param_cb(poll_interval, _ops_poll_interval, _interval, 0644);
 MODULE_PARM_DESC(poll_interval,
 "battery poll interval in seconds - 0 disables polling");
 
@@ -1011,6 +1039,10 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
 
bq27xxx_battery_update(di);
 
+   mutex_lock(_lock);
+   list_add(>list, _battery_devices);
+   mutex_unlock(_lock);
+
return 0;
 
 err_out:
@@ -1036,6 +1068,10 @@ void bq27xxx_battery_teardown(struct bq27xxx_device_info 
*di)
 
power_supply_unregister(di->bat);
 
+   mutex_lock(_lock);
+   list_del(>list);
+   mutex_unlock(_lock);
+
mutex_destroy(>lock);
 }
 EXPORT_SYMBOL_GPL(bq27xxx_battery_teardown);
diff --git a/include/linux/power/bq27xxx_battery.h 
b/include/linux/power/bq27xxx_battery.h
index b50c0492629d..e30deb046156 100644
--- a/include/linux/power/bq27xxx_battery.h
+++ b/include/linux/power/bq27xxx_battery.h
@@ -58,6 +58,7 @@ struct bq27xxx_device_info {
unsigned long last_update;
struct delayed_work work;
struct power_supply *bat;
+   struct list_head list;
struct mutex lock;
u8 *regs;
 };
-- 
2.7.4



[PATCH 1/2] power: bq27xxx_battery: add configurable poll_interval by sysfs

2016-09-16 Thread Matt Ranostay
Allow the poll_interval to be runtime configurable via an sysfs entry.
This is needed for udev control of the poll interval.

Signed-off-by: Matt Ranostay 
---
 drivers/power/supply/bq27xxx_battery.c | 48 +-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c 
b/drivers/power/supply/bq27xxx_battery.c
index 3f57dd54803a..955424e10ae2 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -395,6 +395,36 @@ module_param(poll_interval, uint, 0644);
 MODULE_PARM_DESC(poll_interval,
 "battery poll interval in seconds - 0 disables polling");
 
+
+static ssize_t show_poll_interval(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+   return sprintf(buf, "%d\n", poll_interval);
+}
+
+static ssize_t store_poll_interval(struct device *dev,
+  struct device_attribute *attr,
+  const char *buf, size_t size)
+{
+   struct bq27xxx_device_info *di = dev_get_drvdata(dev);
+   int tmp = poll_interval;
+
+   if (sscanf(buf, "%d\n", _interval) != 1)
+   return -EINVAL;
+
+   if (poll_interval < 0)
+   return -EINVAL;
+
+   if (tmp != poll_interval) {
+   cancel_delayed_work_sync(>work);
+   schedule_delayed_work(>work, 0);
+   }
+
+   return size;
+}
+
+static DEVICE_ATTR(poll_interval, 0644, show_poll_interval, 
store_poll_interval);
+
 /*
  * Common code for BQ27xxx devices
  */
@@ -946,6 +976,7 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
 {
struct power_supply_desc *psy_desc;
struct power_supply_config psy_cfg = { .drv_data = di, };
+   int ret;
 
INIT_DELAYED_WORK(>work, bq27xxx_battery_poll);
mutex_init(>lock);
@@ -961,11 +992,19 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
psy_desc->num_properties = bq27xxx_battery_props[di->chip].size;
psy_desc->get_property = bq27xxx_battery_get_property;
psy_desc->external_power_changed = bq27xxx_external_power_changed;
+   dev_set_drvdata(di->dev, di);
+
+   ret = sysfs_create_file(>dev->kobj, _attr_poll_interval.attr);
+   if (ret) {
+   dev_err(di->dev, "failed to register poll_interval sysfs 
entry");
+   return ret;
+   }
 
di->bat = power_supply_register_no_ws(di->dev, psy_desc, _cfg);
if (IS_ERR(di->bat)) {
dev_err(di->dev, "failed to register battery\n");
-   return PTR_ERR(di->bat);
+   ret = PTR_ERR(di->bat);
+   goto err_out;
}
 
dev_info(di->dev, "support ver. %s enabled\n", DRIVER_VERSION);
@@ -973,6 +1012,11 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
bq27xxx_battery_update(di);
 
return 0;
+
+err_out:
+   sysfs_remove_file(>dev->kobj, _attr_poll_interval.attr);
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(bq27xxx_battery_setup);
 
@@ -988,6 +1032,8 @@ void bq27xxx_battery_teardown(struct bq27xxx_device_info 
*di)
 
cancel_delayed_work_sync(>work);
 
+   sysfs_remove_file(>dev->kobj, _attr_poll_interval.attr);
+
power_supply_unregister(di->bat);
 
mutex_destroy(>lock);
-- 
2.7.4



[PATCH 1/2] power: bq27xxx_battery: add configurable poll_interval by sysfs

2016-09-16 Thread Matt Ranostay
Allow the poll_interval to be runtime configurable via an sysfs entry.
This is needed for udev control of the poll interval.

Signed-off-by: Matt Ranostay 
---
 drivers/power/supply/bq27xxx_battery.c | 48 +-
 1 file changed, 47 insertions(+), 1 deletion(-)

diff --git a/drivers/power/supply/bq27xxx_battery.c 
b/drivers/power/supply/bq27xxx_battery.c
index 3f57dd54803a..955424e10ae2 100644
--- a/drivers/power/supply/bq27xxx_battery.c
+++ b/drivers/power/supply/bq27xxx_battery.c
@@ -395,6 +395,36 @@ module_param(poll_interval, uint, 0644);
 MODULE_PARM_DESC(poll_interval,
 "battery poll interval in seconds - 0 disables polling");
 
+
+static ssize_t show_poll_interval(struct device *dev,
+ struct device_attribute *attr, char *buf)
+{
+   return sprintf(buf, "%d\n", poll_interval);
+}
+
+static ssize_t store_poll_interval(struct device *dev,
+  struct device_attribute *attr,
+  const char *buf, size_t size)
+{
+   struct bq27xxx_device_info *di = dev_get_drvdata(dev);
+   int tmp = poll_interval;
+
+   if (sscanf(buf, "%d\n", _interval) != 1)
+   return -EINVAL;
+
+   if (poll_interval < 0)
+   return -EINVAL;
+
+   if (tmp != poll_interval) {
+   cancel_delayed_work_sync(>work);
+   schedule_delayed_work(>work, 0);
+   }
+
+   return size;
+}
+
+static DEVICE_ATTR(poll_interval, 0644, show_poll_interval, 
store_poll_interval);
+
 /*
  * Common code for BQ27xxx devices
  */
@@ -946,6 +976,7 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
 {
struct power_supply_desc *psy_desc;
struct power_supply_config psy_cfg = { .drv_data = di, };
+   int ret;
 
INIT_DELAYED_WORK(>work, bq27xxx_battery_poll);
mutex_init(>lock);
@@ -961,11 +992,19 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
psy_desc->num_properties = bq27xxx_battery_props[di->chip].size;
psy_desc->get_property = bq27xxx_battery_get_property;
psy_desc->external_power_changed = bq27xxx_external_power_changed;
+   dev_set_drvdata(di->dev, di);
+
+   ret = sysfs_create_file(>dev->kobj, _attr_poll_interval.attr);
+   if (ret) {
+   dev_err(di->dev, "failed to register poll_interval sysfs 
entry");
+   return ret;
+   }
 
di->bat = power_supply_register_no_ws(di->dev, psy_desc, _cfg);
if (IS_ERR(di->bat)) {
dev_err(di->dev, "failed to register battery\n");
-   return PTR_ERR(di->bat);
+   ret = PTR_ERR(di->bat);
+   goto err_out;
}
 
dev_info(di->dev, "support ver. %s enabled\n", DRIVER_VERSION);
@@ -973,6 +1012,11 @@ int bq27xxx_battery_setup(struct bq27xxx_device_info *di)
bq27xxx_battery_update(di);
 
return 0;
+
+err_out:
+   sysfs_remove_file(>dev->kobj, _attr_poll_interval.attr);
+
+   return ret;
 }
 EXPORT_SYMBOL_GPL(bq27xxx_battery_setup);
 
@@ -988,6 +1032,8 @@ void bq27xxx_battery_teardown(struct bq27xxx_device_info 
*di)
 
cancel_delayed_work_sync(>work);
 
+   sysfs_remove_file(>dev->kobj, _attr_poll_interval.attr);
+
power_supply_unregister(di->bat);
 
mutex_destroy(>lock);
-- 
2.7.4



[PATCH 0/2] power: bq27xxx_battery: add configurable poll_interval

2016-09-16 Thread Matt Ranostay
Patchset series fixes the kernel_parameter poll_interval not scheduling
the next event with the new interval. Also creates a sysfs entry that is
useful for udev attribute assignment.

Matt Ranostay (2):
  power: bq27xxx_battery: add configurable poll_interval by sysfs
  power: bq27xxx_battery: allow kernel poll_interval parameter runtime
update

 drivers/power/supply/bq27xxx_battery.c | 87 +-
 include/linux/power/bq27xxx_battery.h  |  1 +
 2 files changed, 86 insertions(+), 2 deletions(-)

-- 
2.7.4



[PATCH 0/2] power: bq27xxx_battery: add configurable poll_interval

2016-09-16 Thread Matt Ranostay
Patchset series fixes the kernel_parameter poll_interval not scheduling
the next event with the new interval. Also creates a sysfs entry that is
useful for udev attribute assignment.

Matt Ranostay (2):
  power: bq27xxx_battery: add configurable poll_interval by sysfs
  power: bq27xxx_battery: allow kernel poll_interval parameter runtime
update

 drivers/power/supply/bq27xxx_battery.c | 87 +-
 include/linux/power/bq27xxx_battery.h  |  1 +
 2 files changed, 86 insertions(+), 2 deletions(-)

-- 
2.7.4



Re: qemu:metag image runtime failure in -next due to 'kthread: allow to cancel kthread work'

2016-09-16 Thread Kees Cook
On Fri, Sep 16, 2016 at 4:32 PM, James Hogan  wrote:
> On Fri, Sep 16, 2016 at 02:37:18PM -0700, Guenter Roeck wrote:
>> On Fri, Sep 16, 2016 at 10:27:20PM +0100, James Hogan wrote:
>> > On Fri, Sep 16, 2016 at 01:38:19PM -0700, Guenter Roeck wrote:
>> > > Hi,
>> > >
>> > > I see the following runtime error in -next when running a metag qemu 
>> > > emulation.
>> > >
>> > > [ ... ]
>> > > workingset: timestamp_bits=30 max_order=16 bucket_order=0
>> > > io scheduler noop registered (default)
>> > > brd: module loaded
>> > > Warning: unable to open an initial console.
>> > > List of all partitions:
>> > > 0100   16384 ram0  (driver?)
>> > > No filesystem could mount root, tried:
>> > > Kernel panic - not syncing: VFS: Unable to mount root fs on 
>> > > unknown-block(1,0)
>> > >
>> > > An example for a complete log is at:
>> > > http://kerneltests.org/builders/qemu-metag-next/builds/489/steps/qemubuildcommand/logs/stdio
>> > >
>> > > bisect points to commit ef98de028afde ("kthread: allow to cancel kthread 
>> > > work").
>> > > I don't know (yet) if other architectures are affected. bisect log is 
>> > > attached.
>> > >
>> > > The scripts to run this test are available at
>> > > https://github.com/groeck/linux-build-test/tree/master/rootfs/metag.
>> > >
>> > > Guenter
>> >
>> > Thanks Guenter,
>> >
>> > It appears to be related to the command line. After that commit the
>> > command line is shown as empty (rather than your "rdinit=/sbin/init
>> > doreboot"), but it can still be overridden in the config and then it
>> > continues to work.
>> >
>> Weird.
>
> Previously the Elf had a single load program header:
>
> Program Headers:
>   Type   Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>   LOAD   0x004000 0x4000 0x4000 0x34b304 0x376230 RWE 0x4000
>   NOTE   0x1ecc08 0x401e8c08 0x401e8c08 0x0 0x0 R   0x4
>
> QEMU puts the args at 40376230, straight after the load region (unlike a
> real Meta Linux bootloader).
>
> After the above commit the ELF gets two load program headers, with a
> small alignment gap in the middle:
>
> Program Headers:
>   Type   Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>   LOAD   0x004000 0x4000 0x4000 0x18f118 0x18f118 R E 0x4000
>   LOAD   0x194000 0x4019 0x4019 0x1bd304 0x1e8230 RWE 0x4000
>   NOTE   0x1eec08 0x401eac08 0x401eac08 0x0 0x0 R   0x4
>
> Here this version of QEMU puts the args at where it thinks the end of
> the loaded image is, which is based on the number of bytes copied from
> the ELF, i.e. the total MemSiz's, not taking into account the alignment
> gap in between, so it puts them at 0x40377348.
>
> But of course:
> 40378230 B ___bss_stop
>
> so it wipes them out while clearing bss during early init.
>
> Previously:
> 4018ebd0 T __sdata
> 4018f000 R ___start_rodata
>
> now:
> 4018ed98 T __sdata
> 4019 R ___start_rodata
>
> So I'm thinking this may have been triggered by c74ba8b3480d ("arch:
> Introduce post-init read-only memory").
>
> The hack below does indeed reduce it to a single load section and this
> version of QEMU then succeeds:
>
> Program Headers:
>   Type   Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>   LOAD   0x004000 0x4000 0x4000 0x34d304 0x378230 RWE 0x4000
>   NOTE   0x1eec88 0x401eac88 0x401eac88 0x0 0x0 R   0x4
>
> diff --git a/arch/metag/include/asm/cache.h b/arch/metag/include/asm/cache.h
> index a43b650cfdc0..b5c7364a94da 100644
> --- a/arch/metag/include/asm/cache.h
> +++ b/arch/metag/include/asm/cache.h
> @@ -20,4 +20,6 @@
>
>  #define __read_mostly __attribute__((__section__(".data..read_mostly")))
>
> +#define __ro_after_init__read_mostly
> +
>  #endif
>
> Kees: Is it expected to get multiple load headers like this since your
> patch c74ba8b3480d ("arch: Introduce post-init read-only memory"),
> depending on alignment of the read only section?

I'm not expecting that, and I'm especially not expecting any LOAD to
have "RWE" flags. It looks like metag's vmlinux.lds.S is using the
common RO_DATA_SECTION, so that doesn't jump out at me as a reason for
RO_AFTER_INIT_DATA to end up in the wrong place. Also the second LOAD
in the ELF is really huge, so it's not just the RO_AFTER_INIT_DATA
section (which is currently very small).

Could the metag linker be failing to override the section flags when
putting RO_AFTER_INIT_DATA into RO_DATA_SECTION and this cuts the LOAD
in half? This smells like a linker glitch.

However, since metag doesn't support CONFIG_DEBUG_RODATA, your above
patch is likely correct. If metag marks memory read-only at kernel
load time, it's doing it early enough that __ro_after_init will fail
to work. If it never marks memory read-only, then __ro_after_init will
have no effect. (i.e. Both situations need the proposed patch).

Probably the best solution for all architectures is to invent a new
CONFIG_ARCH_HAS... to 

Re: [PATCH v3) posix-timers: make it configurable

2016-09-16 Thread Nicolas Pitre
On Fri, 16 Sep 2016, Richard Cochran wrote:

> On Thu, Sep 15, 2016 at 02:56:49PM -0700, Josh Triplett wrote:
> > > I suspect there is more of a case for having net drivers _without_ ptp 
> > > support.  This could be implemented with a ptp_clock_register() stub 
> > > returning NULL when ptp is not configured.  I didn't look at most 
> > > drivers but at least broadcom/tg3.c seems to be fine with such an 
> > > approach.
> 
> (I wouldn't be suprised if some drivers fail to deal with NULL
> gracefully, but those can always be fixed ;)

I've looked at all of them and I think they should be fine with the 
minor changes I've included below.  Tested with allyesconfig and 
CONFIG_POSIX_TIMERS=n.

- >8
Subject: [PATCH] ptp_clock: allow for it to be optional

In order to break the hard dependency between the PTP clock subsystem and
ethernet drivers capable of being clock providers, this patch provides
simple PTP stub functions to allow linkage of those drivers into the
kernel even when the PTP subsystem is configured out.

And to make it possible for PTP to be configured out, the select statement
in the Kconfig entry for those ethernet drivers is changed from selecting
PTP_1588_CLOCK to PTP_1588_CLOCK_DEFAULT whose purpose is to indicate the
default Kconfig value for the PTP subsystem.

This way the PTP subsystem may have Kconfig dependencies of its own, such
as POSIX_TIMERS, without making those ethernet drivers unavailable if
POSIX timers are cconfigured out. And when support for POSIX timers is
selected again then PTP clock support will also be selected accordingly.

Drivers must be ready to accept NULL from ptp_clock_register().
The pch_gbe driver is a bit special as it relies on extra code in
drivers/ptp/ptp_pch.c. Therefore we let the make process descend into
drivers/ptp/ even if PTP_1588_CLOCK is unselected.

Signed-off-by: Nicolas Pitre 

diff --git a/drivers/Makefile b/drivers/Makefile
index 53abb4a5f7..8a538d0856 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -105,7 +105,7 @@ obj-$(CONFIG_INPUT) += input/
 obj-$(CONFIG_RTC_LIB)  += rtc/
 obj-y  += i2c/ media/
 obj-$(CONFIG_PPS)  += pps/
-obj-$(CONFIG_PTP_1588_CLOCK)   += ptp/
+obj-y  += ptp/
 obj-$(CONFIG_W1)   += w1/
 obj-y  += power/
 obj-$(CONFIG_HWMON)+= hwmon/
diff --git a/drivers/net/ethernet/adi/Kconfig b/drivers/net/ethernet/adi/Kconfig
index 6b94ba6103..eea414337c 100644
--- a/drivers/net/ethernet/adi/Kconfig
+++ b/drivers/net/ethernet/adi/Kconfig
@@ -55,10 +55,14 @@ config BFIN_RX_DESC_NUM
---help---
  Set the number of buffer packets used in driver.
 
+config BFIN_MAC_HAS_HWSTAMP
+   def_tristate BFIN_MAC
+   depends on BF518
+   select PTP_1588_CLOCK_DEFAULT
+
 config BFIN_MAC_USE_HWSTAMP
bool "Use IEEE 1588 hwstamp"
-   depends on BFIN_MAC && BF518
-   select PTP_1588_CLOCK
+   depends on BFIN_MAC_HAS_HWSTAMP && PTP_1588_CLOCK
default y
---help---
  To support the IEEE 1588 Precision Time Protocol (PTP), select y here
diff --git a/drivers/net/ethernet/amd/Kconfig b/drivers/net/ethernet/amd/Kconfig
index 0038709fd3..c2aaa5f949 100644
--- a/drivers/net/ethernet/amd/Kconfig
+++ b/drivers/net/ethernet/amd/Kconfig
@@ -177,7 +177,7 @@ config AMD_XGBE
depends on ARM64 || COMPILE_TEST
select BITREVERSE
select CRC32
-   select PTP_1588_CLOCK
+   select PTP_1588_CLOCK_DEFAULT
---help---
  This driver supports the AMD 10GbE Ethernet device found on an
  AMD SoC.
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c 
b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
index 3eee3201b5..4aeeb018b6 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
@@ -773,7 +773,8 @@ static int xgbe_probe(struct platform_device *pdev)
goto err_wq;
}
 
-   xgbe_ptp_register(pdata);
+   if (IS_REACHABLE(CONFIG_PTP_1588_CLOCK))
+   xgbe_ptp_register(pdata);
 
xgbe_debugfs_init(pdata);
 
@@ -812,7 +813,8 @@ static int xgbe_remove(struct platform_device *pdev)
 
xgbe_debugfs_exit(pdata);
 
-   xgbe_ptp_unregister(pdata);
+   if (IS_REACHABLE(CONFIG_PTP_1588_CLOCK))
+   xgbe_ptp_unregister(pdata);
 
flush_workqueue(pdata->an_workqueue);
destroy_workqueue(pdata->an_workqueue);
diff --git a/drivers/net/ethernet/broadcom/Kconfig 
b/drivers/net/ethernet/broadcom/Kconfig
index bd8c80c0b7..9c53786a5c 100644
--- a/drivers/net/ethernet/broadcom/Kconfig
+++ b/drivers/net/ethernet/broadcom/Kconfig
@@ -110,7 +110,7 @@ config TIGON3
depends on PCI
select PHYLIB
select HWMON
-   select PTP_1588_CLOCK
+   select PTP_1588_CLOCK_DEFAULT
---help---
  This driver supports Broadcom Tigon3 based gigabit Ethernet cards.
 
@@ -120,7 

Re: qemu:metag image runtime failure in -next due to 'kthread: allow to cancel kthread work'

2016-09-16 Thread Kees Cook
On Fri, Sep 16, 2016 at 4:32 PM, James Hogan  wrote:
> On Fri, Sep 16, 2016 at 02:37:18PM -0700, Guenter Roeck wrote:
>> On Fri, Sep 16, 2016 at 10:27:20PM +0100, James Hogan wrote:
>> > On Fri, Sep 16, 2016 at 01:38:19PM -0700, Guenter Roeck wrote:
>> > > Hi,
>> > >
>> > > I see the following runtime error in -next when running a metag qemu 
>> > > emulation.
>> > >
>> > > [ ... ]
>> > > workingset: timestamp_bits=30 max_order=16 bucket_order=0
>> > > io scheduler noop registered (default)
>> > > brd: module loaded
>> > > Warning: unable to open an initial console.
>> > > List of all partitions:
>> > > 0100   16384 ram0  (driver?)
>> > > No filesystem could mount root, tried:
>> > > Kernel panic - not syncing: VFS: Unable to mount root fs on 
>> > > unknown-block(1,0)
>> > >
>> > > An example for a complete log is at:
>> > > http://kerneltests.org/builders/qemu-metag-next/builds/489/steps/qemubuildcommand/logs/stdio
>> > >
>> > > bisect points to commit ef98de028afde ("kthread: allow to cancel kthread 
>> > > work").
>> > > I don't know (yet) if other architectures are affected. bisect log is 
>> > > attached.
>> > >
>> > > The scripts to run this test are available at
>> > > https://github.com/groeck/linux-build-test/tree/master/rootfs/metag.
>> > >
>> > > Guenter
>> >
>> > Thanks Guenter,
>> >
>> > It appears to be related to the command line. After that commit the
>> > command line is shown as empty (rather than your "rdinit=/sbin/init
>> > doreboot"), but it can still be overridden in the config and then it
>> > continues to work.
>> >
>> Weird.
>
> Previously the Elf had a single load program header:
>
> Program Headers:
>   Type   Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>   LOAD   0x004000 0x4000 0x4000 0x34b304 0x376230 RWE 0x4000
>   NOTE   0x1ecc08 0x401e8c08 0x401e8c08 0x0 0x0 R   0x4
>
> QEMU puts the args at 40376230, straight after the load region (unlike a
> real Meta Linux bootloader).
>
> After the above commit the ELF gets two load program headers, with a
> small alignment gap in the middle:
>
> Program Headers:
>   Type   Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>   LOAD   0x004000 0x4000 0x4000 0x18f118 0x18f118 R E 0x4000
>   LOAD   0x194000 0x4019 0x4019 0x1bd304 0x1e8230 RWE 0x4000
>   NOTE   0x1eec08 0x401eac08 0x401eac08 0x0 0x0 R   0x4
>
> Here this version of QEMU puts the args at where it thinks the end of
> the loaded image is, which is based on the number of bytes copied from
> the ELF, i.e. the total MemSiz's, not taking into account the alignment
> gap in between, so it puts them at 0x40377348.
>
> But of course:
> 40378230 B ___bss_stop
>
> so it wipes them out while clearing bss during early init.
>
> Previously:
> 4018ebd0 T __sdata
> 4018f000 R ___start_rodata
>
> now:
> 4018ed98 T __sdata
> 4019 R ___start_rodata
>
> So I'm thinking this may have been triggered by c74ba8b3480d ("arch:
> Introduce post-init read-only memory").
>
> The hack below does indeed reduce it to a single load section and this
> version of QEMU then succeeds:
>
> Program Headers:
>   Type   Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
>   LOAD   0x004000 0x4000 0x4000 0x34d304 0x378230 RWE 0x4000
>   NOTE   0x1eec88 0x401eac88 0x401eac88 0x0 0x0 R   0x4
>
> diff --git a/arch/metag/include/asm/cache.h b/arch/metag/include/asm/cache.h
> index a43b650cfdc0..b5c7364a94da 100644
> --- a/arch/metag/include/asm/cache.h
> +++ b/arch/metag/include/asm/cache.h
> @@ -20,4 +20,6 @@
>
>  #define __read_mostly __attribute__((__section__(".data..read_mostly")))
>
> +#define __ro_after_init__read_mostly
> +
>  #endif
>
> Kees: Is it expected to get multiple load headers like this since your
> patch c74ba8b3480d ("arch: Introduce post-init read-only memory"),
> depending on alignment of the read only section?

I'm not expecting that, and I'm especially not expecting any LOAD to
have "RWE" flags. It looks like metag's vmlinux.lds.S is using the
common RO_DATA_SECTION, so that doesn't jump out at me as a reason for
RO_AFTER_INIT_DATA to end up in the wrong place. Also the second LOAD
in the ELF is really huge, so it's not just the RO_AFTER_INIT_DATA
section (which is currently very small).

Could the metag linker be failing to override the section flags when
putting RO_AFTER_INIT_DATA into RO_DATA_SECTION and this cuts the LOAD
in half? This smells like a linker glitch.

However, since metag doesn't support CONFIG_DEBUG_RODATA, your above
patch is likely correct. If metag marks memory read-only at kernel
load time, it's doing it early enough that __ro_after_init will fail
to work. If it never marks memory read-only, then __ro_after_init will
have no effect. (i.e. Both situations need the proposed patch).

Probably the best solution for all architectures is to invent a new
CONFIG_ARCH_HAS... to identify the style of 

Re: [PATCH v3) posix-timers: make it configurable

2016-09-16 Thread Nicolas Pitre
On Fri, 16 Sep 2016, Richard Cochran wrote:

> On Thu, Sep 15, 2016 at 02:56:49PM -0700, Josh Triplett wrote:
> > > I suspect there is more of a case for having net drivers _without_ ptp 
> > > support.  This could be implemented with a ptp_clock_register() stub 
> > > returning NULL when ptp is not configured.  I didn't look at most 
> > > drivers but at least broadcom/tg3.c seems to be fine with such an 
> > > approach.
> 
> (I wouldn't be suprised if some drivers fail to deal with NULL
> gracefully, but those can always be fixed ;)

I've looked at all of them and I think they should be fine with the 
minor changes I've included below.  Tested with allyesconfig and 
CONFIG_POSIX_TIMERS=n.

- >8
Subject: [PATCH] ptp_clock: allow for it to be optional

In order to break the hard dependency between the PTP clock subsystem and
ethernet drivers capable of being clock providers, this patch provides
simple PTP stub functions to allow linkage of those drivers into the
kernel even when the PTP subsystem is configured out.

And to make it possible for PTP to be configured out, the select statement
in the Kconfig entry for those ethernet drivers is changed from selecting
PTP_1588_CLOCK to PTP_1588_CLOCK_DEFAULT whose purpose is to indicate the
default Kconfig value for the PTP subsystem.

This way the PTP subsystem may have Kconfig dependencies of its own, such
as POSIX_TIMERS, without making those ethernet drivers unavailable if
POSIX timers are cconfigured out. And when support for POSIX timers is
selected again then PTP clock support will also be selected accordingly.

Drivers must be ready to accept NULL from ptp_clock_register().
The pch_gbe driver is a bit special as it relies on extra code in
drivers/ptp/ptp_pch.c. Therefore we let the make process descend into
drivers/ptp/ even if PTP_1588_CLOCK is unselected.

Signed-off-by: Nicolas Pitre 

diff --git a/drivers/Makefile b/drivers/Makefile
index 53abb4a5f7..8a538d0856 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -105,7 +105,7 @@ obj-$(CONFIG_INPUT) += input/
 obj-$(CONFIG_RTC_LIB)  += rtc/
 obj-y  += i2c/ media/
 obj-$(CONFIG_PPS)  += pps/
-obj-$(CONFIG_PTP_1588_CLOCK)   += ptp/
+obj-y  += ptp/
 obj-$(CONFIG_W1)   += w1/
 obj-y  += power/
 obj-$(CONFIG_HWMON)+= hwmon/
diff --git a/drivers/net/ethernet/adi/Kconfig b/drivers/net/ethernet/adi/Kconfig
index 6b94ba6103..eea414337c 100644
--- a/drivers/net/ethernet/adi/Kconfig
+++ b/drivers/net/ethernet/adi/Kconfig
@@ -55,10 +55,14 @@ config BFIN_RX_DESC_NUM
---help---
  Set the number of buffer packets used in driver.
 
+config BFIN_MAC_HAS_HWSTAMP
+   def_tristate BFIN_MAC
+   depends on BF518
+   select PTP_1588_CLOCK_DEFAULT
+
 config BFIN_MAC_USE_HWSTAMP
bool "Use IEEE 1588 hwstamp"
-   depends on BFIN_MAC && BF518
-   select PTP_1588_CLOCK
+   depends on BFIN_MAC_HAS_HWSTAMP && PTP_1588_CLOCK
default y
---help---
  To support the IEEE 1588 Precision Time Protocol (PTP), select y here
diff --git a/drivers/net/ethernet/amd/Kconfig b/drivers/net/ethernet/amd/Kconfig
index 0038709fd3..c2aaa5f949 100644
--- a/drivers/net/ethernet/amd/Kconfig
+++ b/drivers/net/ethernet/amd/Kconfig
@@ -177,7 +177,7 @@ config AMD_XGBE
depends on ARM64 || COMPILE_TEST
select BITREVERSE
select CRC32
-   select PTP_1588_CLOCK
+   select PTP_1588_CLOCK_DEFAULT
---help---
  This driver supports the AMD 10GbE Ethernet device found on an
  AMD SoC.
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c 
b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
index 3eee3201b5..4aeeb018b6 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c
@@ -773,7 +773,8 @@ static int xgbe_probe(struct platform_device *pdev)
goto err_wq;
}
 
-   xgbe_ptp_register(pdata);
+   if (IS_REACHABLE(CONFIG_PTP_1588_CLOCK))
+   xgbe_ptp_register(pdata);
 
xgbe_debugfs_init(pdata);
 
@@ -812,7 +813,8 @@ static int xgbe_remove(struct platform_device *pdev)
 
xgbe_debugfs_exit(pdata);
 
-   xgbe_ptp_unregister(pdata);
+   if (IS_REACHABLE(CONFIG_PTP_1588_CLOCK))
+   xgbe_ptp_unregister(pdata);
 
flush_workqueue(pdata->an_workqueue);
destroy_workqueue(pdata->an_workqueue);
diff --git a/drivers/net/ethernet/broadcom/Kconfig 
b/drivers/net/ethernet/broadcom/Kconfig
index bd8c80c0b7..9c53786a5c 100644
--- a/drivers/net/ethernet/broadcom/Kconfig
+++ b/drivers/net/ethernet/broadcom/Kconfig
@@ -110,7 +110,7 @@ config TIGON3
depends on PCI
select PHYLIB
select HWMON
-   select PTP_1588_CLOCK
+   select PTP_1588_CLOCK_DEFAULT
---help---
  This driver supports Broadcom Tigon3 based gigabit Ethernet cards.
 
@@ -120,7 +120,7 @@ config 

Re: [PATCH -next] ASoC: rt5663: fix sparse warnings

2016-09-16 Thread kbuild test robot
Hi Wei,

[auto build test WARNING on next-20160916]

url:
https://github.com/0day-ci/linux/commits/Wei-Yongjun/ASoC-rt5663-fix-sparse-warnings/20160917-094530


coccinelle warnings: (new ones prefixed by >>)

>> sound/soc/codecs/rt5663.c:3203:3-8: No need to set .owner here. The core 
>> will do it.

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


[PATCH] ASoC: rt5663: fix platform_no_drv_owner.cocci warnings

2016-09-16 Thread kbuild test robot
sound/soc/codecs/rt5663.c:3203:3-8: No need to set .owner here. The core will 
do it.

 Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

CC: Wei Yongjun 
Signed-off-by: Fengguang Wu 
---

 rt5663.c |1 -
 1 file changed, 1 deletion(-)

--- a/sound/soc/codecs/rt5663.c
+++ b/sound/soc/codecs/rt5663.c
@@ -3200,7 +3200,6 @@ static void rt5663_i2c_shutdown(struct i
 static struct i2c_driver rt5663_i2c_driver = {
.driver = {
.name = "rt5663",
-   .owner = THIS_MODULE,
.acpi_match_table = ACPI_PTR(rt5663_acpi_match),
.of_match_table = of_match_ptr(rt5663_of_match),
},


Re: [PATCH -next] ASoC: rt5663: fix sparse warnings

2016-09-16 Thread kbuild test robot
Hi Wei,

[auto build test WARNING on next-20160916]

url:
https://github.com/0day-ci/linux/commits/Wei-Yongjun/ASoC-rt5663-fix-sparse-warnings/20160917-094530


coccinelle warnings: (new ones prefixed by >>)

>> sound/soc/codecs/rt5663.c:3203:3-8: No need to set .owner here. The core 
>> will do it.

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation


[PATCH] ASoC: rt5663: fix platform_no_drv_owner.cocci warnings

2016-09-16 Thread kbuild test robot
sound/soc/codecs/rt5663.c:3203:3-8: No need to set .owner here. The core will 
do it.

 Remove .owner field if calls are used which set it automatically

Generated by: scripts/coccinelle/api/platform_no_drv_owner.cocci

CC: Wei Yongjun 
Signed-off-by: Fengguang Wu 
---

 rt5663.c |1 -
 1 file changed, 1 deletion(-)

--- a/sound/soc/codecs/rt5663.c
+++ b/sound/soc/codecs/rt5663.c
@@ -3200,7 +3200,6 @@ static void rt5663_i2c_shutdown(struct i
 static struct i2c_driver rt5663_i2c_driver = {
.driver = {
.name = "rt5663",
-   .owner = THIS_MODULE,
.acpi_match_table = ACPI_PTR(rt5663_acpi_match),
.of_match_table = of_match_ptr(rt5663_of_match),
},


Re: [PATCH v2] scripts: add script for translating stack dump function offsets

2016-09-16 Thread Linus Torvalds
On Fri, Sep 16, 2016 at 6:59 PM, Linus Torvalds
 wrote:
>
> And finally, I suspect (5) is not reasonably fixable. Oh well. It
> would require some kind of "figure out the largest common prefix of
> all the filenames in the whole object file". So I'm *not* talking
> about just passing "--basenames" to addr2line.
>
> Hmm. Maybe looking up the "DW_AT_comp_dir" tag in the debug info would
> work? And just stripping that off?

Thinking more about this, that actually sounds like it might be the
right thing to do.

It doesn't work for most projects, but the way the kernel build system
is set up, we don't actually recursively descend into subdirectories,
we always build at the top level. So DW_AT_comp_dir should always (?)
be the actual top-level build directory, and we could just scrape that
off from the addr2line output.

That said, I don't even know what the "real" way to dump the debug
symbol data is. I do *not* believe that you should use

  readelf -W --debug-dump vmlinux | grep DW_AT_comp_dir | head -1

to get the information. There is bound to be something much better.
Somebody who knows the ELF tools can now pipe in and show the world
what a maroon I am.

   Linus


Re: [PATCH v2] scripts: add script for translating stack dump function offsets

2016-09-16 Thread Linus Torvalds
On Fri, Sep 16, 2016 at 6:59 PM, Linus Torvalds
 wrote:
>
> And finally, I suspect (5) is not reasonably fixable. Oh well. It
> would require some kind of "figure out the largest common prefix of
> all the filenames in the whole object file". So I'm *not* talking
> about just passing "--basenames" to addr2line.
>
> Hmm. Maybe looking up the "DW_AT_comp_dir" tag in the debug info would
> work? And just stripping that off?

Thinking more about this, that actually sounds like it might be the
right thing to do.

It doesn't work for most projects, but the way the kernel build system
is set up, we don't actually recursively descend into subdirectories,
we always build at the top level. So DW_AT_comp_dir should always (?)
be the actual top-level build directory, and we could just scrape that
off from the addr2line output.

That said, I don't even know what the "real" way to dump the debug
symbol data is. I do *not* believe that you should use

  readelf -W --debug-dump vmlinux | grep DW_AT_comp_dir | head -1

to get the information. There is bound to be something much better.
Somebody who knows the ELF tools can now pipe in and show the world
what a maroon I am.

   Linus


Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'

2016-09-16 Thread Guenter Roeck

On 09/16/2016 04:32 PM, Rich Felker wrote:
[ ... ]


It would be useful to know what compiler version was used to build the
kernel. I wouldn't be surprised if some are buggy.


4.6.3 from kernel.org.


That is utterly ancient and probaby very buggy. I would recommend 5.x+
or at the very least 4.7 or 4.8.


I found a toolchain with 5.3.0, and using it the problem disappears. Oh well.
Sorry for the noise.

Guenter



Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'

2016-09-16 Thread Guenter Roeck

On 09/16/2016 04:32 PM, Rich Felker wrote:
[ ... ]


It would be useful to know what compiler version was used to build the
kernel. I wouldn't be surprised if some are buggy.


4.6.3 from kernel.org.


That is utterly ancient and probaby very buggy. I would recommend 5.x+
or at the very least 4.7 or 4.8.


I found a toolchain with 5.3.0, and using it the problem disappears. Oh well.
Sorry for the noise.

Guenter



Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'

2016-09-16 Thread Guenter Roeck

On 09/16/2016 04:32 PM, Rich Felker wrote:

4.6.3 from kernel.org.


That is utterly ancient and probaby very buggy. I would recommend 5.x+
or at the very least 4.7 or 4.8.


Unfortunately that is the latest one available from kernel.org :-(.
I'll try to build one myself.

Thanks,
Guenter



Re: Runtime failure running sh:qemu in -next due to 'sh: fix copy_from_user()'

2016-09-16 Thread Guenter Roeck

On 09/16/2016 04:32 PM, Rich Felker wrote:

4.6.3 from kernel.org.


That is utterly ancient and probaby very buggy. I would recommend 5.x+
or at the very least 4.7 or 4.8.


Unfortunately that is the latest one available from kernel.org :-(.
I'll try to build one myself.

Thanks,
Guenter



[PATCH 3/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slicoss.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index 8426392..2128963 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -1697,9 +1697,10 @@ static void slic_init_cleanup(struct adapter *adapter)
 
if (adapter->shmem.shmem_data) {
struct slic_shmemory *sm = >shmem;
-   struct slic_shmem_data *sm_data = sm->shmem_data;
+   struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
 
-   pci_free_consistent(adapter->pcidev, sizeof(*sm_data), sm_data,
+   pci_free_consistent(adapter->pcidev, sizeof(*sm_data),
+   (void __force *)sm_data,
sm->isr_phaddr);
}
 
-- 
2.7.4



[PATCH 3/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slicoss.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index 8426392..2128963 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -1697,9 +1697,10 @@ static void slic_init_cleanup(struct adapter *adapter)
 
if (adapter->shmem.shmem_data) {
struct slic_shmemory *sm = >shmem;
-   struct slic_shmem_data *sm_data = sm->shmem_data;
+   struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
 
-   pci_free_consistent(adapter->pcidev, sizeof(*sm_data), sm_data,
+   pci_free_consistent(adapter->pcidev, sizeof(*sm_data),
+   (void __force *)sm_data,
sm->isr_phaddr);
}
 
-- 
2.7.4



[PATCH 4/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
add IOMEM_SET_FIELD32 to set u32 value of a member of a __iomem structure;

Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slic.h| 7 +++
 drivers/staging/slicoss/slicoss.c | 8 
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
index fec9ec5..b9595c4 100644
--- a/drivers/staging/slicoss/slic.h
+++ b/drivers/staging/slicoss/slic.h
@@ -553,6 +553,13 @@ static inline void slic_flush_write(struct adapter 
*adapter)
ioread32(_base);\
 })
 
+#define IOMEM_SET_FIELD32(value, base, member) \
+({ \
+   char __iomem *_base = (char __iomem *)base; \
+   _base += offsetof(typeof(*base), member);   \
+   iowrite32(value, _base);\
+})
+
 #ifdef CONFIG_64BIT
 #define IOMEM_GET_FIELD64(base, member)
\
 ({ \
diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index 2128963..c92b8c5 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -2087,15 +2087,15 @@ static irqreturn_t slic_interrupt(int irq, void *dev_id)
struct net_device *dev = dev_id;
struct adapter *adapter = netdev_priv(dev);
struct slic_shmemory *sm = >shmem;
-   struct slic_shmem_data *sm_data = sm->shmem_data;
+   struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
u32 isr;
 
-   if (sm_data->isr) {
+   if (IOMEM_GET_FIELD32(sm_data, isr)) {
slic_write32(adapter, SLIC_REG_ICR, ICR_INT_MASK);
slic_flush_write(adapter);
 
-   isr = sm_data->isr;
-   sm_data->isr = 0;
+   isr = IOMEM_GET_FIELD32(sm_data, isr);
+   IOMEM_SET_FIELD32(0, sm_data, isr);
adapter->num_isrs++;
switch (adapter->card->state) {
case CARD_UP:
-- 
2.7.4



[PATCH 2/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
add IOMEM_GET_FIELDADDR to get address of a member of a __iomem structure;
add IOMEM_GET_FIELD64 to get u64 value of a member of a __iomem structure;

Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slic.h| 32 +
 drivers/staging/slicoss/slicoss.c | 49 +--
 2 files changed, 64 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
index 022e7f6..fec9ec5 100644
--- a/drivers/staging/slicoss/slic.h
+++ b/drivers/staging/slicoss/slic.h
@@ -539,6 +539,13 @@ static inline void slic_flush_write(struct adapter 
*adapter)
ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
+#define IOMEM_GET_FIELDADDR(base, member)  \
+({ \
+   char __iomem *_base = (char __iomem *)base; \
+   _base += offsetof(typeof(*base), member);   \
+   (void __iomem *)_base;  \
+})
+
 #define IOMEM_GET_FIELD32(base, member)
\
 ({ \
char __iomem *_base = (char __iomem *)base; \
@@ -546,6 +553,31 @@ static inline void slic_flush_write(struct adapter 
*adapter)
ioread32(_base);\
 })
 
+#ifdef CONFIG_64BIT
+#define IOMEM_GET_FIELD64(base, member)
\
+({ \
+   char __iomem *_base = (char __iomem *)base; \
+   _base += offsetof(typeof(*base), member);   \
+   readq(_base);   \
+})
+#else
+#define IOMEM_GET_FIELD64(base, member)
\
+({ \
+   char __iomem *_base = (char __iomem *)base; \
+   u64 val;\
+   _base += offsetof(typeof(*base), member);   \
+   val = ((u64)ioread8(_base + 7)) << 56;  \
+   val += ((u64)ioread8(_base + 6)) << 48; \
+   val += ((u64)ioread8(_base + 5)) << 40; \
+   val += ((u64)ioread8(_base + 4)) << 32; \
+   val += ((u64)ioread8(_base + 3)) << 24; \
+   val += ((u64)ioread8(_base + 2)) << 16; \
+   val += ((u64)ioread8(_base + 1)) << 8;  \
+   val += ioread8(_base);  \
+   le64_to_cpu(val);   \
+})
+#endif
+
 #define UPDATE_STATS(largestat, newstat, oldstat)\
 {\
if ((newstat) < (oldstat))   \
diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index 929a0d5..8426392 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -1004,8 +1004,9 @@ static void slic_upr_request_complete(struct adapter 
*adapter, u32 isr)
switch (upr->upr_request) {
case SLIC_UPR_STATS: {
struct slic_shmemory *sm = >shmem;
-   struct slic_shmem_data *sm_data = sm->shmem_data;
-   struct slic_stats *stats = _data->stats;
+   struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
+   struct slic_stats __iomem *stats =
+   IOMEM_GET_FIELDADDR(sm_data, stats);
struct slic_stats *old = >inicstats_prev;
struct slicnet_stats *stst = >slic_stats;
 
@@ -1015,48 +1016,62 @@ static void slic_upr_request_complete(struct adapter 
*adapter, u32 isr)
break;
}
 
-   UPDATE_STATS_GB(stst->tcp.xmit_tcp_segs, stats->xmit_tcp_segs,
+   UPDATE_STATS_GB(stst->tcp.xmit_tcp_segs,
+   IOMEM_GET_FIELD64(stats, xmit_tcp_segs),
old->xmit_tcp_segs);
 
-   UPDATE_STATS_GB(stst->tcp.xmit_tcp_bytes, stats->xmit_tcp_bytes,
+   UPDATE_STATS_GB(stst->tcp.xmit_tcp_bytes,
+   IOMEM_GET_FIELD64(stats, xmit_tcp_bytes),
old->xmit_tcp_bytes);
 
-   UPDATE_STATS_GB(stst->tcp.rcv_tcp_segs, stats->rcv_tcp_segs,
+   UPDATE_STATS_GB(stst->tcp.rcv_tcp_segs,
+   IOMEM_GET_FIELD64(stats, rcv_tcp_segs),
old->rcv_tcp_segs);
 
-   

[PATCH 5/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slicoss.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index c92b8c5..bf9b381 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -2230,7 +2230,7 @@ static int slic_if_init(struct adapter *adapter, unsigned 
long *flags)
struct sliccard *card = adapter->card;
struct net_device *dev = adapter->netdev;
struct slic_shmemory *sm = >shmem;
-   struct slic_shmem_data *sm_data = sm->shmem_data;
+   struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
int rc;
 
/* adapter should be down at this point */
@@ -2314,7 +2314,7 @@ static int slic_if_init(struct adapter *adapter, unsigned 
long *flags)
/*
 *clear any pending events, then enable interrupts
 */
-   sm_data->isr = 0;
+   IOMEM_SET_FIELD32(0, sm_data, isr);
slic_write32(adapter, SLIC_REG_ISR, 0);
slic_write32(adapter, SLIC_REG_ICR, ICR_INT_ON);
 
-- 
2.7.4



[PATCH 6/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slicoss.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index bf9b381..59c4fbc 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -2603,7 +2603,7 @@ static void slic_config_pci(struct pci_dev *pcidev)
 static int slic_card_init(struct sliccard *card, struct adapter *adapter)
 {
struct slic_shmemory *sm = >shmem;
-   struct slic_shmem_data *sm_data = sm->shmem_data;
+   struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
struct slic_eeprom *peeprom;
struct oslic_eeprom *pOeeprom;
dma_addr_t phys_config;
@@ -2666,9 +2666,9 @@ static int slic_card_init(struct sliccard *card, struct 
adapter *adapter)
}
 
for (;;) {
-   if (sm_data->isr) {
-   if (sm_data->isr & ISR_UPC) {
-   sm_data->isr = 0;
+   if (IOMEM_GET_FIELD32(sm_data, isr)) {
+   if (IOMEM_GET_FIELD32(sm_data, isr) & ISR_UPC) {
+   IOMEM_SET_FIELD32(0, sm_data, isr);
slic_write64(adapter, SLIC_REG_ISP, 0,
 0);
slic_write32(adapter, SLIC_REG_ISR, 0);
@@ -2678,7 +2678,7 @@ static int slic_card_init(struct sliccard *card, struct 
adapter *adapter)
break;
}
 
-   sm_data->isr = 0;
+   IOMEM_SET_FIELD32(0, sm_data, isr);
slic_write32(adapter, SLIC_REG_ISR, 0);
slic_flush_write(adapter);
} else {
-- 
2.7.4



[PATCH 7/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slicoss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index 59c4fbc..abe7592 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -2883,7 +2883,7 @@ static int slic_init_adapter(struct net_device *netdev,
if (!sm_data)
return -ENOMEM;
 
-   sm->shmem_data = sm_data;
+   sm->shmem_data = (struct slic_shmem_data __force __iomem *)sm_data;
sm->isr_phaddr = phaddr;
sm->lnkstatus_phaddr = phaddr + offsetof(struct slic_shmem_data,
 lnkstatus);
-- 
2.7.4



[PATCH 4/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
add IOMEM_SET_FIELD32 to set u32 value of a member of a __iomem structure;

Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slic.h| 7 +++
 drivers/staging/slicoss/slicoss.c | 8 
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
index fec9ec5..b9595c4 100644
--- a/drivers/staging/slicoss/slic.h
+++ b/drivers/staging/slicoss/slic.h
@@ -553,6 +553,13 @@ static inline void slic_flush_write(struct adapter 
*adapter)
ioread32(_base);\
 })
 
+#define IOMEM_SET_FIELD32(value, base, member) \
+({ \
+   char __iomem *_base = (char __iomem *)base; \
+   _base += offsetof(typeof(*base), member);   \
+   iowrite32(value, _base);\
+})
+
 #ifdef CONFIG_64BIT
 #define IOMEM_GET_FIELD64(base, member)
\
 ({ \
diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index 2128963..c92b8c5 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -2087,15 +2087,15 @@ static irqreturn_t slic_interrupt(int irq, void *dev_id)
struct net_device *dev = dev_id;
struct adapter *adapter = netdev_priv(dev);
struct slic_shmemory *sm = >shmem;
-   struct slic_shmem_data *sm_data = sm->shmem_data;
+   struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
u32 isr;
 
-   if (sm_data->isr) {
+   if (IOMEM_GET_FIELD32(sm_data, isr)) {
slic_write32(adapter, SLIC_REG_ICR, ICR_INT_MASK);
slic_flush_write(adapter);
 
-   isr = sm_data->isr;
-   sm_data->isr = 0;
+   isr = IOMEM_GET_FIELD32(sm_data, isr);
+   IOMEM_SET_FIELD32(0, sm_data, isr);
adapter->num_isrs++;
switch (adapter->card->state) {
case CARD_UP:
-- 
2.7.4



[PATCH 2/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
add IOMEM_GET_FIELDADDR to get address of a member of a __iomem structure;
add IOMEM_GET_FIELD64 to get u64 value of a member of a __iomem structure;

Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slic.h| 32 +
 drivers/staging/slicoss/slicoss.c | 49 +--
 2 files changed, 64 insertions(+), 17 deletions(-)

diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
index 022e7f6..fec9ec5 100644
--- a/drivers/staging/slicoss/slic.h
+++ b/drivers/staging/slicoss/slic.h
@@ -539,6 +539,13 @@ static inline void slic_flush_write(struct adapter 
*adapter)
ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
+#define IOMEM_GET_FIELDADDR(base, member)  \
+({ \
+   char __iomem *_base = (char __iomem *)base; \
+   _base += offsetof(typeof(*base), member);   \
+   (void __iomem *)_base;  \
+})
+
 #define IOMEM_GET_FIELD32(base, member)
\
 ({ \
char __iomem *_base = (char __iomem *)base; \
@@ -546,6 +553,31 @@ static inline void slic_flush_write(struct adapter 
*adapter)
ioread32(_base);\
 })
 
+#ifdef CONFIG_64BIT
+#define IOMEM_GET_FIELD64(base, member)
\
+({ \
+   char __iomem *_base = (char __iomem *)base; \
+   _base += offsetof(typeof(*base), member);   \
+   readq(_base);   \
+})
+#else
+#define IOMEM_GET_FIELD64(base, member)
\
+({ \
+   char __iomem *_base = (char __iomem *)base; \
+   u64 val;\
+   _base += offsetof(typeof(*base), member);   \
+   val = ((u64)ioread8(_base + 7)) << 56;  \
+   val += ((u64)ioread8(_base + 6)) << 48; \
+   val += ((u64)ioread8(_base + 5)) << 40; \
+   val += ((u64)ioread8(_base + 4)) << 32; \
+   val += ((u64)ioread8(_base + 3)) << 24; \
+   val += ((u64)ioread8(_base + 2)) << 16; \
+   val += ((u64)ioread8(_base + 1)) << 8;  \
+   val += ioread8(_base);  \
+   le64_to_cpu(val);   \
+})
+#endif
+
 #define UPDATE_STATS(largestat, newstat, oldstat)\
 {\
if ((newstat) < (oldstat))   \
diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index 929a0d5..8426392 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -1004,8 +1004,9 @@ static void slic_upr_request_complete(struct adapter 
*adapter, u32 isr)
switch (upr->upr_request) {
case SLIC_UPR_STATS: {
struct slic_shmemory *sm = >shmem;
-   struct slic_shmem_data *sm_data = sm->shmem_data;
-   struct slic_stats *stats = _data->stats;
+   struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
+   struct slic_stats __iomem *stats =
+   IOMEM_GET_FIELDADDR(sm_data, stats);
struct slic_stats *old = >inicstats_prev;
struct slicnet_stats *stst = >slic_stats;
 
@@ -1015,48 +1016,62 @@ static void slic_upr_request_complete(struct adapter 
*adapter, u32 isr)
break;
}
 
-   UPDATE_STATS_GB(stst->tcp.xmit_tcp_segs, stats->xmit_tcp_segs,
+   UPDATE_STATS_GB(stst->tcp.xmit_tcp_segs,
+   IOMEM_GET_FIELD64(stats, xmit_tcp_segs),
old->xmit_tcp_segs);
 
-   UPDATE_STATS_GB(stst->tcp.xmit_tcp_bytes, stats->xmit_tcp_bytes,
+   UPDATE_STATS_GB(stst->tcp.xmit_tcp_bytes,
+   IOMEM_GET_FIELD64(stats, xmit_tcp_bytes),
old->xmit_tcp_bytes);
 
-   UPDATE_STATS_GB(stst->tcp.rcv_tcp_segs, stats->rcv_tcp_segs,
+   UPDATE_STATS_GB(stst->tcp.rcv_tcp_segs,
+   IOMEM_GET_FIELD64(stats, rcv_tcp_segs),
old->rcv_tcp_segs);
 
-   

[PATCH 5/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slicoss.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index c92b8c5..bf9b381 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -2230,7 +2230,7 @@ static int slic_if_init(struct adapter *adapter, unsigned 
long *flags)
struct sliccard *card = adapter->card;
struct net_device *dev = adapter->netdev;
struct slic_shmemory *sm = >shmem;
-   struct slic_shmem_data *sm_data = sm->shmem_data;
+   struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
int rc;
 
/* adapter should be down at this point */
@@ -2314,7 +2314,7 @@ static int slic_if_init(struct adapter *adapter, unsigned 
long *flags)
/*
 *clear any pending events, then enable interrupts
 */
-   sm_data->isr = 0;
+   IOMEM_SET_FIELD32(0, sm_data, isr);
slic_write32(adapter, SLIC_REG_ISR, 0);
slic_write32(adapter, SLIC_REG_ICR, ICR_INT_ON);
 
-- 
2.7.4



[PATCH 6/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slicoss.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index bf9b381..59c4fbc 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -2603,7 +2603,7 @@ static void slic_config_pci(struct pci_dev *pcidev)
 static int slic_card_init(struct sliccard *card, struct adapter *adapter)
 {
struct slic_shmemory *sm = >shmem;
-   struct slic_shmem_data *sm_data = sm->shmem_data;
+   struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
struct slic_eeprom *peeprom;
struct oslic_eeprom *pOeeprom;
dma_addr_t phys_config;
@@ -2666,9 +2666,9 @@ static int slic_card_init(struct sliccard *card, struct 
adapter *adapter)
}
 
for (;;) {
-   if (sm_data->isr) {
-   if (sm_data->isr & ISR_UPC) {
-   sm_data->isr = 0;
+   if (IOMEM_GET_FIELD32(sm_data, isr)) {
+   if (IOMEM_GET_FIELD32(sm_data, isr) & ISR_UPC) {
+   IOMEM_SET_FIELD32(0, sm_data, isr);
slic_write64(adapter, SLIC_REG_ISP, 0,
 0);
slic_write32(adapter, SLIC_REG_ISR, 0);
@@ -2678,7 +2678,7 @@ static int slic_card_init(struct sliccard *card, struct 
adapter *adapter)
break;
}
 
-   sm_data->isr = 0;
+   IOMEM_SET_FIELD32(0, sm_data, isr);
slic_write32(adapter, SLIC_REG_ISR, 0);
slic_flush_write(adapter);
} else {
-- 
2.7.4



[PATCH 7/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slicoss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index 59c4fbc..abe7592 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -2883,7 +2883,7 @@ static int slic_init_adapter(struct net_device *netdev,
if (!sm_data)
return -ENOMEM;
 
-   sm->shmem_data = sm_data;
+   sm->shmem_data = (struct slic_shmem_data __force __iomem *)sm_data;
sm->isr_phaddr = phaddr;
sm->lnkstatus_phaddr = phaddr + offsetof(struct slic_shmem_data,
 lnkstatus);
-- 
2.7.4



[PATCH 0/7] staging: slicoss: fix different address space sparse warnings

2016-09-16 Thread Peng Sun
commit-id d221eb9f14f9, "Add linux-next specific files for 20160909"

add several macros to fix these warnings

Peng Sun (7):
  staging: slicoss: slicoss.c: fix different address space sparse
warning
  staging: slicoss: slicoss.c: fix different address space sparse
warning
  staging: slicoss: slicoss.c: fix different address space sparse
warning
  staging: slicoss: slicoss.c: fix different address space sparse
warning
  staging: slicoss: slicoss.c: fix different address space sparse
warning
  staging: slicoss: slicoss.c: fix different address space sparse
warning
  staging: slicoss: slicoss.c: fix different address space sparse
warning

 drivers/staging/slicoss/slic.h| 46 ++
 drivers/staging/slicoss/slicoss.c | 82 +++
 2 files changed, 95 insertions(+), 33 deletions(-)

-- 
2.7.4



[PATCH 0/7] staging: slicoss: fix different address space sparse warnings

2016-09-16 Thread Peng Sun
commit-id d221eb9f14f9, "Add linux-next specific files for 20160909"

add several macros to fix these warnings

Peng Sun (7):
  staging: slicoss: slicoss.c: fix different address space sparse
warning
  staging: slicoss: slicoss.c: fix different address space sparse
warning
  staging: slicoss: slicoss.c: fix different address space sparse
warning
  staging: slicoss: slicoss.c: fix different address space sparse
warning
  staging: slicoss: slicoss.c: fix different address space sparse
warning
  staging: slicoss: slicoss.c: fix different address space sparse
warning
  staging: slicoss: slicoss.c: fix different address space sparse
warning

 drivers/staging/slicoss/slic.h| 46 ++
 drivers/staging/slicoss/slicoss.c | 82 +++
 2 files changed, 95 insertions(+), 33 deletions(-)

-- 
2.7.4



[PATCH 1/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
add IOMEM_GET_FIELD32 to get u32 value of a member of a __iomem structure;

Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slic.h| 7 +++
 drivers/staging/slicoss/slicoss.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
index fe1d2ce..022e7f6 100644
--- a/drivers/staging/slicoss/slic.h
+++ b/drivers/staging/slicoss/slic.h
@@ -539,6 +539,13 @@ static inline void slic_flush_write(struct adapter 
*adapter)
ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
+#define IOMEM_GET_FIELD32(base, member)
\
+({ \
+   char __iomem *_base = (char __iomem *)base; \
+   _base += offsetof(typeof(*base), member);   \
+   ioread32(_base);\
+})
+
 #define UPDATE_STATS(largestat, newstat, oldstat)\
 {\
if ((newstat) < (oldstat))   \
diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index 21280a3..929a0d5 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -924,8 +924,8 @@ err_unlock_irq:
 static void slic_link_upr_complete(struct adapter *adapter, u32 isr)
 {
struct slic_shmemory *sm = >shmem;
-   struct slic_shmem_data *sm_data = sm->shmem_data;
-   u32 lst = sm_data->lnkstatus;
+   struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
+   u32 lst = IOMEM_GET_FIELD32(sm_data, lnkstatus);
uint linkup;
unsigned char linkspeed;
unsigned char linkduplex;
-- 
2.7.4



[PATCH 1/7] staging: slicoss: slicoss.c: fix different address space sparse warning

2016-09-16 Thread Peng Sun
add IOMEM_GET_FIELD32 to get u32 value of a member of a __iomem structure;

Signed-off-by: Peng Sun 
---
 drivers/staging/slicoss/slic.h| 7 +++
 drivers/staging/slicoss/slicoss.c | 4 ++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/slicoss/slic.h b/drivers/staging/slicoss/slic.h
index fe1d2ce..022e7f6 100644
--- a/drivers/staging/slicoss/slic.h
+++ b/drivers/staging/slicoss/slic.h
@@ -539,6 +539,13 @@ static inline void slic_flush_write(struct adapter 
*adapter)
ioread32(adapter->regs + SLIC_REG_HOSTID);
 }
 
+#define IOMEM_GET_FIELD32(base, member)
\
+({ \
+   char __iomem *_base = (char __iomem *)base; \
+   _base += offsetof(typeof(*base), member);   \
+   ioread32(_base);\
+})
+
 #define UPDATE_STATS(largestat, newstat, oldstat)\
 {\
if ((newstat) < (oldstat))   \
diff --git a/drivers/staging/slicoss/slicoss.c 
b/drivers/staging/slicoss/slicoss.c
index 21280a3..929a0d5 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -924,8 +924,8 @@ err_unlock_irq:
 static void slic_link_upr_complete(struct adapter *adapter, u32 isr)
 {
struct slic_shmemory *sm = >shmem;
-   struct slic_shmem_data *sm_data = sm->shmem_data;
-   u32 lst = sm_data->lnkstatus;
+   struct slic_shmem_data __iomem *sm_data = sm->shmem_data;
+   u32 lst = IOMEM_GET_FIELD32(sm_data, lnkstatus);
uint linkup;
unsigned char linkspeed;
unsigned char linkduplex;
-- 
2.7.4



Re: [PATCH 09/12] x86/process: Pin the target stack in get_wchan()

2016-09-16 Thread Jann Horn
On Tue, Sep 13, 2016 at 02:29:29PM -0700, Andy Lutomirski wrote:
> This will prevent a crash if get_wchan() runs after the task stack
> is freed.

I think I found some more stuff. Have a look at KSTK_EIP() and KSTK_ESP(), I 
think
they read from the saved userspace registers area at the top of the kernel 
stack?

Used on remote processes in:
  vma_is_stack_for_task() (via /proc/$pid/maps)
  do_task_stat() (/proc/$pid/stat)


signature.asc
Description: Digital signature


Re: [PATCH 09/12] x86/process: Pin the target stack in get_wchan()

2016-09-16 Thread Jann Horn
On Tue, Sep 13, 2016 at 02:29:29PM -0700, Andy Lutomirski wrote:
> This will prevent a crash if get_wchan() runs after the task stack
> is freed.

I think I found some more stuff. Have a look at KSTK_EIP() and KSTK_ESP(), I 
think
they read from the saved userspace registers area at the top of the kernel 
stack?

Used on remote processes in:
  vma_is_stack_for_task() (via /proc/$pid/maps)
  do_task_stat() (/proc/$pid/stat)


signature.asc
Description: Digital signature


Re: [PATCH v2] scripts: add script for translating stack dump function offsets

2016-09-16 Thread Linus Torvalds
On Fri, Sep 16, 2016 at 5:42 PM, Josh Poimboeuf  wrote:
> On Fri, Sep 16, 2016 at 05:09:15PM -0700, Linus Torvalds wrote:
>> On Fri, Sep 16, 2016 at 2:26 PM, Josh Poimboeuf  wrote:
>> >
>> > Ok, how about this.  If this looks ok, would you be willing to apply it?
>>
>> Looks good to me. Did you test the size verification with some made-up cases?
>
> Yep.  And I tested all the other edge cases that occurred to me.

Hmm. So I tested it a bit, and I found a few issues..

 (1) actual bug: you really need the "-W" flag to 'readelf'. Otherwise
it will truncate the lines to fit in 80 columns, which in turn limits
symbol names to 25 characters or something like that.

 (2) usability: I have been known to want to look up multiple symbols.
So could we support a syntax like

   /scripts/faddr2line vmlinux function1+15/226 other_fn_name+32/128

 or something like that?

 (3) noise: I have to say that it seems to work really well, but the
"skipping" messages are a bit verbose.

 I guess they practically never actually *trigger*, but

 [torvalds@i7 linux]$ ./scripts/faddr2line vmlinux type_show+0x10/45
 skipping type_show address at 0x81023690 due to size
mismatch (45 != 166)
 skipping type_show address at 0x811894f0 due to size
mismatch (45 != 41)
 /home/torvalds/v2.6/linux/drivers/video/backlight/backlight.c:213
 skipping type_show address at 0x814e9340 due to size
mismatch (45 != 119)
 skipping type_show address at 0x8157a080 due to size
mismatch (45 != 50)
 skipping type_show address at 0x815bbeb0 due to size
mismatch (45 != 38)
 skipping type_show address at 0x815ea8c0 due to size
mismatch (45 != 35)
 skipping type_show address at 0x8162c650 due to size
mismatch (45 != 40)
 skipping type_show address at 0x8162f910 due to size
mismatch (45 != 38)
 skipping type_show address at 0x81694ec0 due to size
mismatch (45 != 26)

 it's almost hard to pick out the case that succeeded from all the
noise from the ones that didn't.

 (4) ambiguous "inlining" vs "multiple possible cases":

 [torvalds@i7 linux]$ ./scripts/faddr2line vmlinux free+15/36
 /home/torvalds/v2.6/linux/./include/crypto/algapi.h:302
 /home/torvalds/v2.6/linux/crypto/lrw.c:377
 /home/torvalds/v2.6/linux/./include/crypto/algapi.h:302
 /home/torvalds/v2.6/linux/crypto/xts.c:334

 That's actually two different cases, both of which inline
crypto_instance_ctx(), and both of which are really the exact same
code (just lrw vs xts), so they have the same name and size.

 (5) I'd love for the pathnames to be shown relative to the root of the project

And (1) is trivial to fix (use "-Ws" instead of "-s" to readelf).

I don't think (2) is a huge deal, but I suspect it wouldn't be nasty
to do by just using a shell function and iterating over the
arguments..

But (3) might be a "don't care, it's so unusual as to not be an
issue", although it might also be a case of "maybe we should only show
the mismatches if there are *no* matches, or if teh user specified
verbose output with '-v' or something"

I think (4) is worth fixing. Maybe by simply outputting the function
name/offset/size again for each hit, which is something you'd need to
do for (2) anyway, so that the above case would become

 [torvalds@i7 linux]$ ./scripts/faddr2line vmlinux free+15
 vmlinux free+15/36:
 /home/torvalds/v2.6/linux/./include/crypto/algapi.h:302
 /home/torvalds/v2.6/linux/crypto/lrw.c:377
 vmlinux free+15/36:
 /home/torvalds/v2.6/linux/./include/crypto/algapi.h:302
 /home/torvalds/v2.6/linux/crypto/xts.c:334

(Note how I didn't give the size on the command line, but the printout
showed it anyway).

And finally, I suspect (5) is not reasonably fixable. Oh well. It
would require some kind of "figure out the largest common prefix of
all the filenames in the whole object file". So I'm *not* talking
about just passing "--basenames" to addr2line.

Hmm. Maybe looking up the "DW_AT_comp_dir" tag in the debug info would
work? And just stripping that off?

But on the whole, this is really nice. I always disliked the stupid
addr2line crap. This just looks like we can get *much* better output
by tweaking things to what the kernel uses/needs..

Would you mind looking at those things? Just (1) I can do myself, but
I'm hoping you'd be willing to maybe do a bit more surgery on your own
script..

  Linus


Re: [PATCH v2] scripts: add script for translating stack dump function offsets

2016-09-16 Thread Linus Torvalds
On Fri, Sep 16, 2016 at 5:42 PM, Josh Poimboeuf  wrote:
> On Fri, Sep 16, 2016 at 05:09:15PM -0700, Linus Torvalds wrote:
>> On Fri, Sep 16, 2016 at 2:26 PM, Josh Poimboeuf  wrote:
>> >
>> > Ok, how about this.  If this looks ok, would you be willing to apply it?
>>
>> Looks good to me. Did you test the size verification with some made-up cases?
>
> Yep.  And I tested all the other edge cases that occurred to me.

Hmm. So I tested it a bit, and I found a few issues..

 (1) actual bug: you really need the "-W" flag to 'readelf'. Otherwise
it will truncate the lines to fit in 80 columns, which in turn limits
symbol names to 25 characters or something like that.

 (2) usability: I have been known to want to look up multiple symbols.
So could we support a syntax like

   /scripts/faddr2line vmlinux function1+15/226 other_fn_name+32/128

 or something like that?

 (3) noise: I have to say that it seems to work really well, but the
"skipping" messages are a bit verbose.

 I guess they practically never actually *trigger*, but

 [torvalds@i7 linux]$ ./scripts/faddr2line vmlinux type_show+0x10/45
 skipping type_show address at 0x81023690 due to size
mismatch (45 != 166)
 skipping type_show address at 0x811894f0 due to size
mismatch (45 != 41)
 /home/torvalds/v2.6/linux/drivers/video/backlight/backlight.c:213
 skipping type_show address at 0x814e9340 due to size
mismatch (45 != 119)
 skipping type_show address at 0x8157a080 due to size
mismatch (45 != 50)
 skipping type_show address at 0x815bbeb0 due to size
mismatch (45 != 38)
 skipping type_show address at 0x815ea8c0 due to size
mismatch (45 != 35)
 skipping type_show address at 0x8162c650 due to size
mismatch (45 != 40)
 skipping type_show address at 0x8162f910 due to size
mismatch (45 != 38)
 skipping type_show address at 0x81694ec0 due to size
mismatch (45 != 26)

 it's almost hard to pick out the case that succeeded from all the
noise from the ones that didn't.

 (4) ambiguous "inlining" vs "multiple possible cases":

 [torvalds@i7 linux]$ ./scripts/faddr2line vmlinux free+15/36
 /home/torvalds/v2.6/linux/./include/crypto/algapi.h:302
 /home/torvalds/v2.6/linux/crypto/lrw.c:377
 /home/torvalds/v2.6/linux/./include/crypto/algapi.h:302
 /home/torvalds/v2.6/linux/crypto/xts.c:334

 That's actually two different cases, both of which inline
crypto_instance_ctx(), and both of which are really the exact same
code (just lrw vs xts), so they have the same name and size.

 (5) I'd love for the pathnames to be shown relative to the root of the project

And (1) is trivial to fix (use "-Ws" instead of "-s" to readelf).

I don't think (2) is a huge deal, but I suspect it wouldn't be nasty
to do by just using a shell function and iterating over the
arguments..

But (3) might be a "don't care, it's so unusual as to not be an
issue", although it might also be a case of "maybe we should only show
the mismatches if there are *no* matches, or if teh user specified
verbose output with '-v' or something"

I think (4) is worth fixing. Maybe by simply outputting the function
name/offset/size again for each hit, which is something you'd need to
do for (2) anyway, so that the above case would become

 [torvalds@i7 linux]$ ./scripts/faddr2line vmlinux free+15
 vmlinux free+15/36:
 /home/torvalds/v2.6/linux/./include/crypto/algapi.h:302
 /home/torvalds/v2.6/linux/crypto/lrw.c:377
 vmlinux free+15/36:
 /home/torvalds/v2.6/linux/./include/crypto/algapi.h:302
 /home/torvalds/v2.6/linux/crypto/xts.c:334

(Note how I didn't give the size on the command line, but the printout
showed it anyway).

And finally, I suspect (5) is not reasonably fixable. Oh well. It
would require some kind of "figure out the largest common prefix of
all the filenames in the whole object file". So I'm *not* talking
about just passing "--basenames" to addr2line.

Hmm. Maybe looking up the "DW_AT_comp_dir" tag in the debug info would
work? And just stripping that off?

But on the whole, this is really nice. I always disliked the stupid
addr2line crap. This just looks like we can get *much* better output
by tweaking things to what the kernel uses/needs..

Would you mind looking at those things? Just (1) I can do myself, but
I'm hoping you'd be willing to maybe do a bit more surgery on your own
script..

  Linus


[PATCH -next] vme: fake: remove unexpected unlock in fake_master_set()

2016-09-16 Thread Wei Yongjun
From: Wei Yongjun 

image->lock is unlocked in some error handling path without take the
lock, so remove those unexpected unlock.

Fixes: 658bcdae9c67 ("vme: Adding Fake VME driver")
Signed-off-by: Wei Yongjun 
---
 drivers/vme/bridges/vme_fake.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
index ebf35d3..4b2613d 100644
--- a/drivers/vme/bridges/vme_fake.c
+++ b/drivers/vme/bridges/vme_fake.c
@@ -273,7 +273,6 @@ static int fake_master_set(struct vme_master_resource 
*image, int enabled,
}
 
if (size & 0x) {
-   spin_unlock(>lock);
pr_err("Invalid size alignment\n");
retval = -EINVAL;
goto err_window;
@@ -292,7 +291,6 @@ static int fake_master_set(struct vme_master_resource 
*image, int enabled,
case VME_D32:
break;
default:
-   spin_unlock(>lock);
pr_err("Invalid data width\n");
retval = -EINVAL;
goto err_dwidth;
@@ -311,7 +309,6 @@ static int fake_master_set(struct vme_master_resource 
*image, int enabled,
case VME_USER4:
break;
default:
-   spin_unlock(>lock);
pr_err("Invalid address space\n");
retval = -EINVAL;
goto err_aspace;



[PATCH -next] vme: fake: remove unexpected unlock in fake_master_set()

2016-09-16 Thread Wei Yongjun
From: Wei Yongjun 

image->lock is unlocked in some error handling path without take the
lock, so remove those unexpected unlock.

Fixes: 658bcdae9c67 ("vme: Adding Fake VME driver")
Signed-off-by: Wei Yongjun 
---
 drivers/vme/bridges/vme_fake.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/vme/bridges/vme_fake.c b/drivers/vme/bridges/vme_fake.c
index ebf35d3..4b2613d 100644
--- a/drivers/vme/bridges/vme_fake.c
+++ b/drivers/vme/bridges/vme_fake.c
@@ -273,7 +273,6 @@ static int fake_master_set(struct vme_master_resource 
*image, int enabled,
}
 
if (size & 0x) {
-   spin_unlock(>lock);
pr_err("Invalid size alignment\n");
retval = -EINVAL;
goto err_window;
@@ -292,7 +291,6 @@ static int fake_master_set(struct vme_master_resource 
*image, int enabled,
case VME_D32:
break;
default:
-   spin_unlock(>lock);
pr_err("Invalid data width\n");
retval = -EINVAL;
goto err_dwidth;
@@ -311,7 +309,6 @@ static int fake_master_set(struct vme_master_resource 
*image, int enabled,
case VME_USER4:
break;
default:
-   spin_unlock(>lock);
pr_err("Invalid address space\n");
retval = -EINVAL;
goto err_aspace;



Re: [Documentation] State of CPU controller in cgroup v2

2016-09-16 Thread Peter Zijlstra
On Fri, Sep 16, 2016 at 11:19:38AM -0700, Andy Lutomirski wrote:
> On Fri, Sep 16, 2016 at 9:50 AM, Peter Zijlstra  wrote:

> > {1,2} {3,4} {5} seem exclusive, did I miss something? (other than that 5
> > cpu parts are 'rare').
> 
> There's no overlap, so they're logically exclusive, but it avoids
> needing the "cpu_exclusive" parameter. 

I'd need to double check, but I don't think you _need_ that. That's more
for enforcing nobody else steals your CPUs and 'accidentally' creates
overlaps. But if you configure it right, non-overlap should be enough.

That is, generate_sched_domains() only uses cpusets_overlap() which is
cpumask_intersects(). Then again, it is almost 4am, so who knows.

> > So there's a problem with sticking kernel threads (and esp. kthreadd)
> > into !root groups. For example if you place it in a cpuset that doesn't
> > have all cpus, then binding your shiny new kthread to a cpu will fail.
> >
> > You can fix that of course, and we used to do exactly that, but we kept
> > running into 'fun' cases like that.
> 
> Blech.  But may this *should* have that effect.  I'm sick of random
> kernel crap being scheduled on my RT CPUs and on the CPUs that I
> intend to be kept forcibly idle.

Hehe, so ideally those threads don't do anything unless the tasks
running on those CPUs explicitly ask for it. If you find any of the
CPU-bound kernel tasks do work that is unrelated to the tasks running on
that CPU, we should certainly look into it.

Personally I'm not much bothered by idle threads sitting about.


Re: [Documentation] State of CPU controller in cgroup v2

2016-09-16 Thread Peter Zijlstra
On Fri, Sep 16, 2016 at 11:19:38AM -0700, Andy Lutomirski wrote:
> On Fri, Sep 16, 2016 at 9:50 AM, Peter Zijlstra  wrote:

> > {1,2} {3,4} {5} seem exclusive, did I miss something? (other than that 5
> > cpu parts are 'rare').
> 
> There's no overlap, so they're logically exclusive, but it avoids
> needing the "cpu_exclusive" parameter. 

I'd need to double check, but I don't think you _need_ that. That's more
for enforcing nobody else steals your CPUs and 'accidentally' creates
overlaps. But if you configure it right, non-overlap should be enough.

That is, generate_sched_domains() only uses cpusets_overlap() which is
cpumask_intersects(). Then again, it is almost 4am, so who knows.

> > So there's a problem with sticking kernel threads (and esp. kthreadd)
> > into !root groups. For example if you place it in a cpuset that doesn't
> > have all cpus, then binding your shiny new kthread to a cpu will fail.
> >
> > You can fix that of course, and we used to do exactly that, but we kept
> > running into 'fun' cases like that.
> 
> Blech.  But may this *should* have that effect.  I'm sick of random
> kernel crap being scheduled on my RT CPUs and on the CPUs that I
> intend to be kept forcibly idle.

Hehe, so ideally those threads don't do anything unless the tasks
running on those CPUs explicitly ask for it. If you find any of the
CPU-bound kernel tasks do work that is unrelated to the tasks running on
that CPU, we should certainly look into it.

Personally I'm not much bothered by idle threads sitting about.


Re: [PATCH 1/4] mm, vmscan: Batch removal of mappings under a single lock during reclaim

2016-09-16 Thread Peter Zijlstra
On Fri, Sep 16, 2016 at 11:33:00AM -0700, Linus Torvalds wrote:
> On Fri, Sep 16, 2016 at 6:25 AM, Peter Zijlstra  wrote:
> >
> > So, once upon a time, in a galaxy far away,..  I did a concurrent
> > pagecache patch set that replaced the tree_lock with a per page bit-
> > spinlock and fine grained locking in the radix tree.
> 
> I'd love to see the patch for that. I'd be a bit worried about extra
> locking in the trivial cases (ie multi-level locking when we now take
> just the single mapping lock), but if there is some smart reason why
> that doesn't happen, then..

On average we'll likely take a few more locks, but its not as bad as
having to take the whole tree depth every time, or even touching the
root lock most times.

There's two cases, the first: the modification is only done on a single
node (like insert), here we do an RCU lookup of the node, lock it,
verify the node is still correct, do modification and unlock, done.

The second case, the modification needs to then back up the tree (like
setting/clearing tags, delete). For this case we can determine on our
way down where the first node is we need to modify, lock that, verify,
and then lock all nodes down to the last. i.e. we lock a partial path.

I can send you the 2.6.31 patches if you're interested, but if you want
something that applies to a kernel from this decade I'll have to go
rewrite them which will take a wee bit of time :-) Both the radix tree
code and the mm have changed somewhat.


Re: [PATCH 1/4] mm, vmscan: Batch removal of mappings under a single lock during reclaim

2016-09-16 Thread Peter Zijlstra
On Fri, Sep 16, 2016 at 11:33:00AM -0700, Linus Torvalds wrote:
> On Fri, Sep 16, 2016 at 6:25 AM, Peter Zijlstra  wrote:
> >
> > So, once upon a time, in a galaxy far away,..  I did a concurrent
> > pagecache patch set that replaced the tree_lock with a per page bit-
> > spinlock and fine grained locking in the radix tree.
> 
> I'd love to see the patch for that. I'd be a bit worried about extra
> locking in the trivial cases (ie multi-level locking when we now take
> just the single mapping lock), but if there is some smart reason why
> that doesn't happen, then..

On average we'll likely take a few more locks, but its not as bad as
having to take the whole tree depth every time, or even touching the
root lock most times.

There's two cases, the first: the modification is only done on a single
node (like insert), here we do an RCU lookup of the node, lock it,
verify the node is still correct, do modification and unlock, done.

The second case, the modification needs to then back up the tree (like
setting/clearing tags, delete). For this case we can determine on our
way down where the first node is we need to modify, lock that, verify,
and then lock all nodes down to the last. i.e. we lock a partial path.

I can send you the 2.6.31 patches if you're interested, but if you want
something that applies to a kernel from this decade I'll have to go
rewrite them which will take a wee bit of time :-) Both the radix tree
code and the mm have changed somewhat.


[PATCH -next] ASoC: sti: fix missing clk_disable_unprepare() on error in uni_player_start()

2016-09-16 Thread Wei Yongjun
From: Wei Yongjun 

Fix the missing clk_disable_unprepare() before return
from uni_player_start() in the error handling case.

Signed-off-by: Wei Yongjun 
---
 sound/soc/sti/uniperif_player.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sti/uniperif_player.c b/sound/soc/sti/uniperif_player.c
index 645e415..1bc8ebc 100644
--- a/sound/soc/sti/uniperif_player.c
+++ b/sound/soc/sti/uniperif_player.c
@@ -893,8 +893,10 @@ static int uni_player_start(struct uniperif *player)
SET_UNIPERIF_SOFT_RST_SOFT_RST(player);
 
ret = reset_player(player);
-   if (ret < 0)
+   if (ret < 0) {
+   clk_disable_unprepare(player->clk);
return ret;
+   }
 
/*
 * Does not use IEC61937 features of the uniperipheral hardware.



[PATCH -next] ASoC: sti: fix missing clk_disable_unprepare() on error in uni_player_start()

2016-09-16 Thread Wei Yongjun
From: Wei Yongjun 

Fix the missing clk_disable_unprepare() before return
from uni_player_start() in the error handling case.

Signed-off-by: Wei Yongjun 
---
 sound/soc/sti/uniperif_player.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/sti/uniperif_player.c b/sound/soc/sti/uniperif_player.c
index 645e415..1bc8ebc 100644
--- a/sound/soc/sti/uniperif_player.c
+++ b/sound/soc/sti/uniperif_player.c
@@ -893,8 +893,10 @@ static int uni_player_start(struct uniperif *player)
SET_UNIPERIF_SOFT_RST_SOFT_RST(player);
 
ret = reset_player(player);
-   if (ret < 0)
+   if (ret < 0) {
+   clk_disable_unprepare(player->clk);
return ret;
+   }
 
/*
 * Does not use IEC61937 features of the uniperipheral hardware.



[PATCH -next] ASoC: rt5663: fix sparse warnings

2016-09-16 Thread Wei Yongjun
From: Wei Yongjun 

Fixes the following sparse warnings:

sound/soc/codecs/rt5663.c:1367:14: warning: duplicate const 
sound/soc/codecs/rt5663.c:1577:5: warning:
 symbol 'rt5663_button_detect' was not declared. Should it be static?
sound/soc/codecs/rt5663.c:2857:24: warning:
 symbol 'rt5663_aif_dai_ops' was not declared. Should it be static?
sound/soc/codecs/rt5663.c:2866:27: warning:
 symbol 'rt5663_dai' was not declared. Should it be static?
sound/soc/codecs/rt5663.c:3193:6: warning:
 symbol 'rt5663_i2c_shutdown' was not declared. Should it be static?
sound/soc/codecs/rt5663.c:3200:19: warning:
 symbol 'rt5663_i2c_driver' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 sound/soc/codecs/rt5663.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c
index 7963a27..fa79568 100644
--- a/sound/soc/codecs/rt5663.c
+++ b/sound/soc/codecs/rt5663.c
@@ -1364,7 +1364,7 @@ static const char * const rt5663_if1_adc_data_select[] = {
"L/R", "R/L", "L/L", "R/R"
 };
 
-static const SOC_ENUM_SINGLE_DECL(rt5663_if1_adc_enum, RT5663_TDM_2,
+static SOC_ENUM_SINGLE_DECL(rt5663_if1_adc_enum, RT5663_TDM_2,
RT5663_DATA_SWAP_ADCDAT1_SHIFT, rt5663_if1_adc_data_select);
 
 static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec,
@@ -1574,7 +1574,7 @@ static int rt5663_jack_detect(struct snd_soc_codec 
*codec, int jack_insert)
return rt5663->jack_type;
 }
 
-int rt5663_button_detect(struct snd_soc_codec *codec)
+static int rt5663_button_detect(struct snd_soc_codec *codec)
 {
int btn_type, val;
 
@@ -2854,7 +2854,7 @@ static int rt5663_resume(struct snd_soc_codec *codec)
 #define RT5663_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
 
-struct snd_soc_dai_ops rt5663_aif_dai_ops = {
+static struct snd_soc_dai_ops rt5663_aif_dai_ops = {
.hw_params = rt5663_hw_params,
.set_fmt = rt5663_set_dai_fmt,
.set_sysclk = rt5663_set_dai_sysclk,
@@ -2863,7 +2863,7 @@ struct snd_soc_dai_ops rt5663_aif_dai_ops = {
.set_bclk_ratio = rt5663_set_bclk_ratio,
 };
 
-struct snd_soc_dai_driver rt5663_dai[] = {
+static struct snd_soc_dai_driver rt5663_dai[] = {
{
.name = "rt5663-aif",
.id = RT5663_AIF,
@@ -3190,14 +3190,14 @@ static int rt5663_i2c_remove(struct i2c_client *i2c)
return 0;
 }
 
-void rt5663_i2c_shutdown(struct i2c_client *client)
+static void rt5663_i2c_shutdown(struct i2c_client *client)
 {
struct rt5663_priv *rt5663 = i2c_get_clientdata(client);
 
regmap_write(rt5663->regmap, RT5663_RESET, 0);
 }
 
-struct i2c_driver rt5663_i2c_driver = {
+static struct i2c_driver rt5663_i2c_driver = {
.driver = {
.name = "rt5663",
.owner = THIS_MODULE,



[PATCH -next] ASoC: rt5663: fix sparse warnings

2016-09-16 Thread Wei Yongjun
From: Wei Yongjun 

Fixes the following sparse warnings:

sound/soc/codecs/rt5663.c:1367:14: warning: duplicate const 
sound/soc/codecs/rt5663.c:1577:5: warning:
 symbol 'rt5663_button_detect' was not declared. Should it be static?
sound/soc/codecs/rt5663.c:2857:24: warning:
 symbol 'rt5663_aif_dai_ops' was not declared. Should it be static?
sound/soc/codecs/rt5663.c:2866:27: warning:
 symbol 'rt5663_dai' was not declared. Should it be static?
sound/soc/codecs/rt5663.c:3193:6: warning:
 symbol 'rt5663_i2c_shutdown' was not declared. Should it be static?
sound/soc/codecs/rt5663.c:3200:19: warning:
 symbol 'rt5663_i2c_driver' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 sound/soc/codecs/rt5663.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/rt5663.c b/sound/soc/codecs/rt5663.c
index 7963a27..fa79568 100644
--- a/sound/soc/codecs/rt5663.c
+++ b/sound/soc/codecs/rt5663.c
@@ -1364,7 +1364,7 @@ static const char * const rt5663_if1_adc_data_select[] = {
"L/R", "R/L", "L/L", "R/R"
 };
 
-static const SOC_ENUM_SINGLE_DECL(rt5663_if1_adc_enum, RT5663_TDM_2,
+static SOC_ENUM_SINGLE_DECL(rt5663_if1_adc_enum, RT5663_TDM_2,
RT5663_DATA_SWAP_ADCDAT1_SHIFT, rt5663_if1_adc_data_select);
 
 static void rt5663_enable_push_button_irq(struct snd_soc_codec *codec,
@@ -1574,7 +1574,7 @@ static int rt5663_jack_detect(struct snd_soc_codec 
*codec, int jack_insert)
return rt5663->jack_type;
 }
 
-int rt5663_button_detect(struct snd_soc_codec *codec)
+static int rt5663_button_detect(struct snd_soc_codec *codec)
 {
int btn_type, val;
 
@@ -2854,7 +2854,7 @@ static int rt5663_resume(struct snd_soc_codec *codec)
 #define RT5663_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \
SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8)
 
-struct snd_soc_dai_ops rt5663_aif_dai_ops = {
+static struct snd_soc_dai_ops rt5663_aif_dai_ops = {
.hw_params = rt5663_hw_params,
.set_fmt = rt5663_set_dai_fmt,
.set_sysclk = rt5663_set_dai_sysclk,
@@ -2863,7 +2863,7 @@ struct snd_soc_dai_ops rt5663_aif_dai_ops = {
.set_bclk_ratio = rt5663_set_bclk_ratio,
 };
 
-struct snd_soc_dai_driver rt5663_dai[] = {
+static struct snd_soc_dai_driver rt5663_dai[] = {
{
.name = "rt5663-aif",
.id = RT5663_AIF,
@@ -3190,14 +3190,14 @@ static int rt5663_i2c_remove(struct i2c_client *i2c)
return 0;
 }
 
-void rt5663_i2c_shutdown(struct i2c_client *client)
+static void rt5663_i2c_shutdown(struct i2c_client *client)
 {
struct rt5663_priv *rt5663 = i2c_get_clientdata(client);
 
regmap_write(rt5663->regmap, RT5663_RESET, 0);
 }
 
-struct i2c_driver rt5663_i2c_driver = {
+static struct i2c_driver rt5663_i2c_driver = {
.driver = {
.name = "rt5663",
.owner = THIS_MODULE,



[PATCH] sched: Fix SCHED_HRTICK bug leading to late preemption of tasks

2016-09-16 Thread Joonwoo Park
From: Srivatsa Vaddagiri 

SCHED_HRTICK feature is useful to preempt SCHED_FAIR tasks on-the-dot
(just when they would have exceeded their ideal_runtime). It makes use
of a per-cpu hrtimer resource and hence alarming that hrtimer should
be based on total SCHED_FAIR tasks a cpu has across its various cfs_rqs,
rather than being based on number of tasks in a particular cfs_rq (as
implemented currently). As a result, with current code, its possible for
a running task (which is the sole task in its cfs_rq) to be preempted
much after its ideal_runtime has elapsed, resulting in increased latency
for tasks in other cfs_rq on same cpu.

Fix this by alarming sched hrtimer based on total number of SCHED_FAIR
tasks a CPU has across its various cfs_rqs.

Cc: Ingo Molnar 
Cc: Peter Zijlstra 
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Srivatsa Vaddagiri 
Signed-off-by: Joonwoo Park 
---

 joonwoop: Do we also need to update or remove if-statement inside
 hrtick_update()?
 I guess not because hrtick_update() doesn't want to start hrtick when cfs_rq
 has large number of nr_running where slice is longer than sched_latency.

 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 4088eed..c55c566 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4458,7 +4458,7 @@ static void hrtick_start_fair(struct rq *rq, struct 
task_struct *p)
 
WARN_ON(task_rq(p) != rq);
 
-   if (cfs_rq->nr_running > 1) {
+   if (rq->cfs.h_nr_running > 1) {
u64 slice = sched_slice(cfs_rq, se);
u64 ran = se->sum_exec_runtime - se->prev_sum_exec_runtime;
s64 delta = slice - ran;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH] sched: Fix SCHED_HRTICK bug leading to late preemption of tasks

2016-09-16 Thread Joonwoo Park
From: Srivatsa Vaddagiri 

SCHED_HRTICK feature is useful to preempt SCHED_FAIR tasks on-the-dot
(just when they would have exceeded their ideal_runtime). It makes use
of a per-cpu hrtimer resource and hence alarming that hrtimer should
be based on total SCHED_FAIR tasks a cpu has across its various cfs_rqs,
rather than being based on number of tasks in a particular cfs_rq (as
implemented currently). As a result, with current code, its possible for
a running task (which is the sole task in its cfs_rq) to be preempted
much after its ideal_runtime has elapsed, resulting in increased latency
for tasks in other cfs_rq on same cpu.

Fix this by alarming sched hrtimer based on total number of SCHED_FAIR
tasks a CPU has across its various cfs_rqs.

Cc: Ingo Molnar 
Cc: Peter Zijlstra 
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Srivatsa Vaddagiri 
Signed-off-by: Joonwoo Park 
---

 joonwoop: Do we also need to update or remove if-statement inside
 hrtick_update()?
 I guess not because hrtick_update() doesn't want to start hrtick when cfs_rq
 has large number of nr_running where slice is longer than sched_latency.

 kernel/sched/fair.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 4088eed..c55c566 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4458,7 +4458,7 @@ static void hrtick_start_fair(struct rq *rq, struct 
task_struct *p)
 
WARN_ON(task_rq(p) != rq);
 
-   if (cfs_rq->nr_running > 1) {
+   if (rq->cfs.h_nr_running > 1) {
u64 slice = sched_slice(cfs_rq, se);
u64 ran = se->sum_exec_runtime - se->prev_sum_exec_runtime;
s64 delta = slice - ran;
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



Re: [PATCH v2] scripts: add script for translating stack dump function offsets

2016-09-16 Thread Peter Zijlstra
On Fri, Sep 16, 2016 at 04:26:56PM -0500, Josh Poimboeuf wrote:
> Ok, how about this.  If this looks ok, would you be willing to apply it?

Looks good, and yes without --inline addr2line would be tons less useful
;-) Thanks for cooking this up.


Re: [PATCH v2] scripts: add script for translating stack dump function offsets

2016-09-16 Thread Peter Zijlstra
On Fri, Sep 16, 2016 at 04:26:56PM -0500, Josh Poimboeuf wrote:
> Ok, how about this.  If this looks ok, would you be willing to apply it?

Looks good, and yes without --inline addr2line would be tons less useful
;-) Thanks for cooking this up.


Re: TRIM/UNMAP/DISCARD via ATA Passthrough

2016-09-16 Thread Jason A. Donenfeld
On Fri, Sep 16, 2016 at 7:06 PM, Austin S. Hemmelgarn
 wrote:
> 1. UAS (not some other SCSI transport) without UNMAP support.
> 2. Supports ATA_12 or ATA_16 pass through.
> 3. ATA DEVICE IDENTIFY via SAT indicates that the device supports
> DISCARD/TRIM.
> Then we'd be matching behavior on Windows, and should probably be relatively
> safe.

This very clearly seems like a sensible plan. It's nice to learn that
someone with a USB sniffer (and not just a désassembler :P) confirms
this is what Windows is doing. I see no reason for Linux not to do the
same. Are there any remaining objections to this plan?


Re: TRIM/UNMAP/DISCARD via ATA Passthrough

2016-09-16 Thread Jason A. Donenfeld
On Fri, Sep 16, 2016 at 7:06 PM, Austin S. Hemmelgarn
 wrote:
> 1. UAS (not some other SCSI transport) without UNMAP support.
> 2. Supports ATA_12 or ATA_16 pass through.
> 3. ATA DEVICE IDENTIFY via SAT indicates that the device supports
> DISCARD/TRIM.
> Then we'd be matching behavior on Windows, and should probably be relatively
> safe.

This very clearly seems like a sensible plan. It's nice to learn that
someone with a USB sniffer (and not just a désassembler :P) confirms
this is what Windows is doing. I see no reason for Linux not to do the
same. Are there any remaining objections to this plan?


Re: [PATCH v2 0/4] gpio: fix an incorrect lockdep warning

2016-09-16 Thread Peter Zijlstra
On Fri, Sep 16, 2016 at 06:02:41PM +0200, Bartosz Golaszewski wrote:
> If an I2C GPIO multiplexer is driven by a GPIO provided by an expander
> when there's a second expander using the same device driver on one of
> the I2C bus segments, lockdep prints a deadlock warning when trying to
> set the direction or the value of the GPIOs provided by the second
> expander.
> 
> This series exports an already existing function from i2c-core as
> public API and reuses it in pca953x to pass a correct lock subclass
> to lockdep.

Acked-by: Peter Zijlstra (Intel) 

> Note: if this series gets merged, I'll prepare follow-up patches for
> other expanders for which a similar problem could potentially occur.

We can't push this annotation into the i2c core, can we? Since the mutex
is in driver specific code, not more generic...


Re: [PATCH v2 0/4] gpio: fix an incorrect lockdep warning

2016-09-16 Thread Peter Zijlstra
On Fri, Sep 16, 2016 at 06:02:41PM +0200, Bartosz Golaszewski wrote:
> If an I2C GPIO multiplexer is driven by a GPIO provided by an expander
> when there's a second expander using the same device driver on one of
> the I2C bus segments, lockdep prints a deadlock warning when trying to
> set the direction or the value of the GPIOs provided by the second
> expander.
> 
> This series exports an already existing function from i2c-core as
> public API and reuses it in pca953x to pass a correct lock subclass
> to lockdep.

Acked-by: Peter Zijlstra (Intel) 

> Note: if this series gets merged, I'll prepare follow-up patches for
> other expanders for which a similar problem could potentially occur.

We can't push this annotation into the i2c core, can we? Since the mutex
is in driver specific code, not more generic...


Re: [RFC/PATCH] usb: misc: Add a driver for TC7USB40MU

2016-09-16 Thread Peter Chen
On Wed, Sep 14, 2016 at 01:55:02AM -0700, Stephen Boyd wrote:
> Quoting Stephen Boyd (2016-09-13 18:42:46)
> > On the db410c 96boards platform we have a TC7USB40MU[1] on the
> > board to mux the D+/D- lines from the SoC between a micro usb
> > "device" port and a USB hub for "host" roles. Upon a role switch,
> > we need to change this mux to forward the D+/D- lines to either
> > the port or the hub. Therefore, introduce a driver for this
> > device that intercepts extcon USB_HOST events and logically
> > asserts a gpio to mux the "host" D+/D- lines when a host cable is
> > attached. When the cable goes away, it will logically deassert
> > the gpio and mux the "device" lines.
> > 
> > [1] 
> > https://toshiba.semicon-storage.com/ap-en/product/logic/bus-switch/detail.TC7USB40MU.html
> > 
> > Cc: MyungJoo Ham 
> > Cc: Chanwoo Choi 
> > Cc: 
> > Signed-off-by: Stephen Boyd 
> > ---
> > 
> > Should I make the extcon part optional? I could see a case where there are 
> > two
> > "OTG" ports connected to the mux (or two hubs), and for some reason the
> > software may want to mux between them at runtime. If we mandate an extcon,
> > that won't be possible to support. Perhaps it would be better to have
> > the node, but connect it to the usb controller with a phandle (maybe 
> > of_graph
> > endpoints would be useful too) so that when the controller wants to mux over
> > a port it can do so.
> 
> Here's some dts mock-up on top of the db410c for the of_graph stuff. I
> haven't written any code around it, but the idea is to allow the binding
> to specify how the mux is connected to upstream and downstream D+/D-
> lines. This way, we can do some dt parsing of the endpoints and their
> parent nodes to figure out if the mux needs to be set high or low to use
> a device connector or a usb hub based on if the id cable is present.
> Maybe I'm over thinking things though and we could just have a DT
> property for that.
> 
>   soc {
>   usb@78d9000 {
>   extcon = <_id>, <_id>;

Why you have two same extcon phandler? From my mind, one should id,
another should is vbus. Besides, I find extcon-usb-gpio.c is lack of
vbus support, how you support vbus detection for
connection/disconnection with PC for your chipidea msm patch set?

>   usb-controller; // needed?

Not needed. You only need to describe controller, mux ic, and hub 
(if you need platform stuffs the driver needs to know).

Peter
> 
>   ports {
>   #address-cells = <1>;
>   #size-cells = <0>;
> 
>   port@0 {
>   #address-cells = <1>;
>   #size-cells = <0>;
>   reg = <0>;
> 
>   usb_output: endpoint@0 { // USB D+/D-
>   reg = <0>;
>   remote-endpoint = 
> <_switch_input>;
>   };
>   };
>   };
>   };
>   };
> 
>   usb2513 {
>   compatible = "smsc,usb3503";
>   reset-gpios = <_gpios 3 GPIO_ACTIVE_LOW>;
>   initial-mode = <1>;
>   usb-hub; // indicate this is a hub
> 
>   ports {
>   #address-cells = <1>;
>   #size-cells = <0>;
> 
>   port@0 {
>   #address-cells = <1>;
>   #size-cells = <0>;
>   reg = <0>;
> 
>   usb_hub_input: endpoint@0 { // USB{DP,DM}_UP
>   reg = <0>;
>   remote-endpoint = <_switch_hub_ep>;
>   };
> 
>   usb_hub_output1: endpoint@1 { // USB{DP,DM}_DN1
>   reg = <1>;
>   remote-endpoint = <_a2_connector>;
>   };
> 
>   usb_hub_output2: endpoint@2 { // USB{DP,DM}_DN2
>   reg = <2>;
>   remote-endpoint = <_a1_connector>;
>   };
> 
>   usb_hub_output3: endpoint@3 { // USB{DP,DM}_DN3
>   reg = <3>;
>   // goes to expansion connector
>   };
>   };
>   };
>   };
> 
>   usb_id: usb-id {
>   compatible = "linux,extcon-usb-gpio";
>   id-gpio = < 121 GPIO_ACTIVE_HIGH>;
>   pinctrl-names = "default";

Re: [PATCH v1 1/3] ARM: dts: imx6qdl-apalis: Do not rely on DDC I2C bus bitbang for HDMI

2016-09-16 Thread Marcel Ziswiler
On Wed, 2016-09-14 at 12:05 +0530, Sanchayan Maity wrote:
> Remove the use of DDC I2C bus bitbang to support reading of EDID
> and rely on support from internal HDMI I2C master controller instead.
> As a result remove the device tree property ddc-i2c-bus.
> 
> Signed-off-by: Sanchayan Maity <maitysancha...@gmail.com>
> ---
> Hello,
> 
> This patch is tested with the following patch applied
> https://patchwork.kernel.org/patch/9296883/
> 
> and is based on the suggestions from Vladimir
> https://lkml.org/lkml/2016/8/29/322
> 
> This and following two patches are based on top of shawn's
> for-next branch.
> 
> Regards,
> Sanchayan.
> ---
>  arch/arm/boot/dts/imx6q-apalis-ixora.dts |  6 --
>  arch/arm/boot/dts/imx6qdl-apalis.dtsi| 25 +-
> ---
>  2 files changed, 9 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/imx6q-apalis-ixora.dts
> b/arch/arm/boot/dts/imx6q-apalis-ixora.dts
> index 207b85b..d99979e 100644
> --- a/arch/arm/boot/dts/imx6q-apalis-ixora.dts
> +++ b/arch/arm/boot/dts/imx6q-apalis-ixora.dts
> @@ -55,7 +55,6 @@
>    "fsl,imx6q";
>  
>   aliases {
> - i2c0 = 
>   i2c1 = 
>   i2c2 = 
>   i2c3 = 

I would suggest rising them up in rank.

> @@ -186,11 +185,6 @@
>  };
>  
>   {
> - ddc-i2c-bus = <>;
> - status = "okay";
> -};
> -
> - {
>   status = "okay";
>  };
>  
> diff --git a/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> index 99e323b..8c67dd8 100644
> --- a/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> +++ b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> @@ -53,18 +53,6 @@
>   status = "disabled";
>   };
>  
> - /* DDC_I2C: I2C2_SDA/SCL on MXM3 205/207 */
> - i2cddc: i2c@0 {
> - compatible = "i2c-gpio";
> - pinctrl-names = "default";
> - pinctrl-0 = <_i2c_ddc>;
> - gpios = < 16 GPIO_ACTIVE_HIGH /* sda */
> -   30 GPIO_ACTIVE_HIGH /* scl */
> - >;
> - i2c-gpio,delay-us = <2>;/* ~100 kHz */
> - status = "disabled";
> - };
> -
>   reg_1p8v: regulator-1p8v {
>   compatible = "regulator-fixed";
>   regulator-name = "1P8V";
> @@ -209,6 +197,12 @@
>   };
>  };
>  
> + {
> + pinctrl-names = "default";
> + pinctrl-0 = <_hdmi_ddc>;
> + status = "disabled";
> +};
> +
>  /*
>   * GEN1_I2C: I2C1_SDA/SCL on MXM3 209/211 (e.g. RTC on carrier
>   * board)
> @@ -633,11 +627,10 @@
>   >;
>   };
>  
> - pinctrl_i2c_ddc: gpioi2cddcgrp {
> + pinctrl_hdmi_ddc: hdmiddcgrp {
>       fsl,pins = <
> - /* DDC bitbang */
> - MX6QDL_PAD_EIM_EB2__GPIO2_IO30 0x1b0b0
> - MX6QDL_PAD_EIM_D16__GPIO3_IO16 0x1b0b0
> + MX6QDL_PAD_EIM_EB2__HDMI_TX_DDC_SCL
> 0x4001b8b1
> + MX6QDL_PAD_EIM_D16__HDMI_TX_DDC_SDA
> 0x4001b8b1
>   >;
>   };
 
Rest looks fine and tested working fine on top of 4.8.0-rc6-next-20160916.


Re: [RFC/PATCH] usb: misc: Add a driver for TC7USB40MU

2016-09-16 Thread Peter Chen
On Wed, Sep 14, 2016 at 01:55:02AM -0700, Stephen Boyd wrote:
> Quoting Stephen Boyd (2016-09-13 18:42:46)
> > On the db410c 96boards platform we have a TC7USB40MU[1] on the
> > board to mux the D+/D- lines from the SoC between a micro usb
> > "device" port and a USB hub for "host" roles. Upon a role switch,
> > we need to change this mux to forward the D+/D- lines to either
> > the port or the hub. Therefore, introduce a driver for this
> > device that intercepts extcon USB_HOST events and logically
> > asserts a gpio to mux the "host" D+/D- lines when a host cable is
> > attached. When the cable goes away, it will logically deassert
> > the gpio and mux the "device" lines.
> > 
> > [1] 
> > https://toshiba.semicon-storage.com/ap-en/product/logic/bus-switch/detail.TC7USB40MU.html
> > 
> > Cc: MyungJoo Ham 
> > Cc: Chanwoo Choi 
> > Cc: 
> > Signed-off-by: Stephen Boyd 
> > ---
> > 
> > Should I make the extcon part optional? I could see a case where there are 
> > two
> > "OTG" ports connected to the mux (or two hubs), and for some reason the
> > software may want to mux between them at runtime. If we mandate an extcon,
> > that won't be possible to support. Perhaps it would be better to have
> > the node, but connect it to the usb controller with a phandle (maybe 
> > of_graph
> > endpoints would be useful too) so that when the controller wants to mux over
> > a port it can do so.
> 
> Here's some dts mock-up on top of the db410c for the of_graph stuff. I
> haven't written any code around it, but the idea is to allow the binding
> to specify how the mux is connected to upstream and downstream D+/D-
> lines. This way, we can do some dt parsing of the endpoints and their
> parent nodes to figure out if the mux needs to be set high or low to use
> a device connector or a usb hub based on if the id cable is present.
> Maybe I'm over thinking things though and we could just have a DT
> property for that.
> 
>   soc {
>   usb@78d9000 {
>   extcon = <_id>, <_id>;

Why you have two same extcon phandler? From my mind, one should id,
another should is vbus. Besides, I find extcon-usb-gpio.c is lack of
vbus support, how you support vbus detection for
connection/disconnection with PC for your chipidea msm patch set?

>   usb-controller; // needed?

Not needed. You only need to describe controller, mux ic, and hub 
(if you need platform stuffs the driver needs to know).

Peter
> 
>   ports {
>   #address-cells = <1>;
>   #size-cells = <0>;
> 
>   port@0 {
>   #address-cells = <1>;
>   #size-cells = <0>;
>   reg = <0>;
> 
>   usb_output: endpoint@0 { // USB D+/D-
>   reg = <0>;
>   remote-endpoint = 
> <_switch_input>;
>   };
>   };
>   };
>   };
>   };
> 
>   usb2513 {
>   compatible = "smsc,usb3503";
>   reset-gpios = <_gpios 3 GPIO_ACTIVE_LOW>;
>   initial-mode = <1>;
>   usb-hub; // indicate this is a hub
> 
>   ports {
>   #address-cells = <1>;
>   #size-cells = <0>;
> 
>   port@0 {
>   #address-cells = <1>;
>   #size-cells = <0>;
>   reg = <0>;
> 
>   usb_hub_input: endpoint@0 { // USB{DP,DM}_UP
>   reg = <0>;
>   remote-endpoint = <_switch_hub_ep>;
>   };
> 
>   usb_hub_output1: endpoint@1 { // USB{DP,DM}_DN1
>   reg = <1>;
>   remote-endpoint = <_a2_connector>;
>   };
> 
>   usb_hub_output2: endpoint@2 { // USB{DP,DM}_DN2
>   reg = <2>;
>   remote-endpoint = <_a1_connector>;
>   };
> 
>   usb_hub_output3: endpoint@3 { // USB{DP,DM}_DN3
>   reg = <3>;
>   // goes to expansion connector
>   };
>   };
>   };
>   };
> 
>   usb_id: usb-id {
>   compatible = "linux,extcon-usb-gpio";
>   id-gpio = < 121 GPIO_ACTIVE_HIGH>;
>   pinctrl-names = "default";
>   pinctrl-0 = <_id_default>;
>   };
> 
>   usb-switch {
>   

Re: [PATCH v1 1/3] ARM: dts: imx6qdl-apalis: Do not rely on DDC I2C bus bitbang for HDMI

2016-09-16 Thread Marcel Ziswiler
On Wed, 2016-09-14 at 12:05 +0530, Sanchayan Maity wrote:
> Remove the use of DDC I2C bus bitbang to support reading of EDID
> and rely on support from internal HDMI I2C master controller instead.
> As a result remove the device tree property ddc-i2c-bus.
> 
> Signed-off-by: Sanchayan Maity 
> ---
> Hello,
> 
> This patch is tested with the following patch applied
> https://patchwork.kernel.org/patch/9296883/
> 
> and is based on the suggestions from Vladimir
> https://lkml.org/lkml/2016/8/29/322
> 
> This and following two patches are based on top of shawn's
> for-next branch.
> 
> Regards,
> Sanchayan.
> ---
>  arch/arm/boot/dts/imx6q-apalis-ixora.dts |  6 --
>  arch/arm/boot/dts/imx6qdl-apalis.dtsi| 25 +-
> ---
>  2 files changed, 9 insertions(+), 22 deletions(-)
> 
> diff --git a/arch/arm/boot/dts/imx6q-apalis-ixora.dts
> b/arch/arm/boot/dts/imx6q-apalis-ixora.dts
> index 207b85b..d99979e 100644
> --- a/arch/arm/boot/dts/imx6q-apalis-ixora.dts
> +++ b/arch/arm/boot/dts/imx6q-apalis-ixora.dts
> @@ -55,7 +55,6 @@
>    "fsl,imx6q";
>  
>   aliases {
> - i2c0 = 
>   i2c1 = 
>   i2c2 = 
>   i2c3 = 

I would suggest rising them up in rank.

> @@ -186,11 +185,6 @@
>  };
>  
>   {
> - ddc-i2c-bus = <>;
> - status = "okay";
> -};
> -
> - {
>   status = "okay";
>  };
>  
> diff --git a/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> index 99e323b..8c67dd8 100644
> --- a/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> +++ b/arch/arm/boot/dts/imx6qdl-apalis.dtsi
> @@ -53,18 +53,6 @@
>   status = "disabled";
>   };
>  
> - /* DDC_I2C: I2C2_SDA/SCL on MXM3 205/207 */
> - i2cddc: i2c@0 {
> - compatible = "i2c-gpio";
> - pinctrl-names = "default";
> - pinctrl-0 = <_i2c_ddc>;
> - gpios = < 16 GPIO_ACTIVE_HIGH /* sda */
> -   30 GPIO_ACTIVE_HIGH /* scl */
> - >;
> - i2c-gpio,delay-us = <2>;/* ~100 kHz */
> - status = "disabled";
> - };
> -
>   reg_1p8v: regulator-1p8v {
>   compatible = "regulator-fixed";
>   regulator-name = "1P8V";
> @@ -209,6 +197,12 @@
>   };
>  };
>  
> + {
> + pinctrl-names = "default";
> + pinctrl-0 = <_hdmi_ddc>;
> + status = "disabled";
> +};
> +
>  /*
>   * GEN1_I2C: I2C1_SDA/SCL on MXM3 209/211 (e.g. RTC on carrier
>   * board)
> @@ -633,11 +627,10 @@
>   >;
>   };
>  
> - pinctrl_i2c_ddc: gpioi2cddcgrp {
> + pinctrl_hdmi_ddc: hdmiddcgrp {
>   fsl,pins = <
> - /* DDC bitbang */
> - MX6QDL_PAD_EIM_EB2__GPIO2_IO30 0x1b0b0
> - MX6QDL_PAD_EIM_D16__GPIO3_IO16 0x1b0b0
> + MX6QDL_PAD_EIM_EB2__HDMI_TX_DDC_SCL
> 0x4001b8b1
> + MX6QDL_PAD_EIM_D16__HDMI_TX_DDC_SDA
> 0x4001b8b1
>   >;
>   };
 
Rest looks fine and tested working fine on top of 4.8.0-rc6-next-20160916.


[PATCH -next] drm/i915: Fix non static symbol warning

2016-09-16 Thread Wei Yongjun
From: Wei Yongjun 

Fixes the following sparse warning:

drivers/gpu/drm/i915/intel_dp.c:1527:5: warning:
 symbol 'intel_dp_compute_bpp' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 drivers/gpu/drm/i915/intel_dp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 69cee9b..acd0c51 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1524,8 +1524,8 @@ void intel_dp_compute_rate(struct intel_dp *intel_dp, int 
port_clock,
}
 }
 
-int intel_dp_compute_bpp(struct intel_dp *intel_dp,
-struct intel_crtc_state *pipe_config)
+static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
+   struct intel_crtc_state *pipe_config)
 {
int bpp, bpc;



[PATCH -next] drm/i915: Fix non static symbol warning

2016-09-16 Thread Wei Yongjun
From: Wei Yongjun 

Fixes the following sparse warning:

drivers/gpu/drm/i915/intel_dp.c:1527:5: warning:
 symbol 'intel_dp_compute_bpp' was not declared. Should it be static?

Signed-off-by: Wei Yongjun 
---
 drivers/gpu/drm/i915/intel_dp.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 69cee9b..acd0c51 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1524,8 +1524,8 @@ void intel_dp_compute_rate(struct intel_dp *intel_dp, int 
port_clock,
}
 }
 
-int intel_dp_compute_bpp(struct intel_dp *intel_dp,
-struct intel_crtc_state *pipe_config)
+static int intel_dp_compute_bpp(struct intel_dp *intel_dp,
+   struct intel_crtc_state *pipe_config)
 {
int bpp, bpc;



[PATCH] x86/vdso: Add ARCH_MAP_VDSO_X32 if CONFIG_X86_X32_ABI.

2016-09-16 Thread Vinson Lee
vdso_image_x32 is generated if CONFIG_X86_X32_ABI.

This patch fixes this build error on CentOS 6.8 with gcc 4.4.

  LD  init/built-in.o
arch/x86/built-in.o: In function `do_arch_prctl':
(.text+0x27466): undefined reference to `vdso_image_x32'
arch/x86/built-in.o: In function `do_arch_prctl':
(.text+0x27477): undefined reference to `vdso_image_x32'

Fixes: 2eefd8789698 ("x86/arch_prctl/vdso: Add ARCH_MAP_VDSO_*")
Signed-off-by: Vinson Lee 
---
 arch/x86/kernel/process_64.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index b34caea..b3760b3 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -592,7 +592,7 @@ long do_arch_prctl(struct task_struct *task, int code, 
unsigned long addr)
}
 
 #ifdef CONFIG_CHECKPOINT_RESTORE
-# ifdef CONFIG_X86_X32
+# ifdef CONFIG_X86_X32_ABI
case ARCH_MAP_VDSO_X32:
return prctl_map_vdso(_image_x32, addr);
 # endif
-- 
1.7.1



[PATCH] x86/vdso: Add ARCH_MAP_VDSO_X32 if CONFIG_X86_X32_ABI.

2016-09-16 Thread Vinson Lee
vdso_image_x32 is generated if CONFIG_X86_X32_ABI.

This patch fixes this build error on CentOS 6.8 with gcc 4.4.

  LD  init/built-in.o
arch/x86/built-in.o: In function `do_arch_prctl':
(.text+0x27466): undefined reference to `vdso_image_x32'
arch/x86/built-in.o: In function `do_arch_prctl':
(.text+0x27477): undefined reference to `vdso_image_x32'

Fixes: 2eefd8789698 ("x86/arch_prctl/vdso: Add ARCH_MAP_VDSO_*")
Signed-off-by: Vinson Lee 
---
 arch/x86/kernel/process_64.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index b34caea..b3760b3 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -592,7 +592,7 @@ long do_arch_prctl(struct task_struct *task, int code, 
unsigned long addr)
}
 
 #ifdef CONFIG_CHECKPOINT_RESTORE
-# ifdef CONFIG_X86_X32
+# ifdef CONFIG_X86_X32_ABI
case ARCH_MAP_VDSO_X32:
return prctl_map_vdso(_image_x32, addr);
 # endif
-- 
1.7.1



Re: [PATCH v4 0/3] nvme power saving

2016-09-16 Thread J Freyensee
On Fri, 2016-09-16 at 11:16 -0700, Andy Lutomirski wrote:
> Hi all-
> 
> Here's v4 of the APST patch set.  The biggest bikesheddable thing (I
> think) is the scaling factor.  I currently have it hardcoded so that
> we wait 50x the total latency before entering a power saving state.
> On my Samsung 950, this means we enter state 3 (70mW, 0.5ms entry
> latency, 5ms exit latency) after 275ms and state 4 (5mW, 2ms entry
> latency, 22ms exit latency) after 1200ms.  I have the default max
> latency set to 25ms.
> 
> FWIW, in practice, the latency this introduces seems to be well
> under 22ms, but my benchmark is a bit silly and I might have
> measured it wrong.  I certainly haven't observed a slowdown just
> using my laptop.
> 
> This time around, I changed the names of parameters after Jay
> Frayensee got confused by the first try.  Now they are:
> 
>  - ps_max_latency_us in sysfs: actually controls it.
>  - nvme_core.default_ps_max_latency_us: sets the default.
> 
> Yeah, they're mouthfuls, but they should be clearer now.
> 

I took the patches and applied them to one of my NVMe fabric hosts on
my NVMe-over-Fabrics setup.  Basically, it doesn't test much other than
Andy's explanation that "ps_max_latency_us" does not appear in any of
/sys/block/nvmeXnY sysfs nodes (I have 7) so seems good to me on this
front.

Tested-by: Jay Freyensee 
[jpf: defaults benign to NVMe-over-Fabrics]


Re: [PATCH v4 0/3] nvme power saving

2016-09-16 Thread J Freyensee
On Fri, 2016-09-16 at 11:16 -0700, Andy Lutomirski wrote:
> Hi all-
> 
> Here's v4 of the APST patch set.  The biggest bikesheddable thing (I
> think) is the scaling factor.  I currently have it hardcoded so that
> we wait 50x the total latency before entering a power saving state.
> On my Samsung 950, this means we enter state 3 (70mW, 0.5ms entry
> latency, 5ms exit latency) after 275ms and state 4 (5mW, 2ms entry
> latency, 22ms exit latency) after 1200ms.  I have the default max
> latency set to 25ms.
> 
> FWIW, in practice, the latency this introduces seems to be well
> under 22ms, but my benchmark is a bit silly and I might have
> measured it wrong.  I certainly haven't observed a slowdown just
> using my laptop.
> 
> This time around, I changed the names of parameters after Jay
> Frayensee got confused by the first try.  Now they are:
> 
>  - ps_max_latency_us in sysfs: actually controls it.
>  - nvme_core.default_ps_max_latency_us: sets the default.
> 
> Yeah, they're mouthfuls, but they should be clearer now.
> 

I took the patches and applied them to one of my NVMe fabric hosts on
my NVMe-over-Fabrics setup.  Basically, it doesn't test much other than
Andy's explanation that "ps_max_latency_us" does not appear in any of
/sys/block/nvmeXnY sysfs nodes (I have 7) so seems good to me on this
front.

Tested-by: Jay Freyensee 
[jpf: defaults benign to NVMe-over-Fabrics]


Re: [PATCH v2] scripts: add script for translating stack dump function offsets

2016-09-16 Thread Josh Poimboeuf
On Fri, Sep 16, 2016 at 05:09:15PM -0700, Linus Torvalds wrote:
> On Fri, Sep 16, 2016 at 2:26 PM, Josh Poimboeuf  wrote:
> >
> > Ok, how about this.  If this looks ok, would you be willing to apply it?
> 
> Looks good to me. Did you test the size verification with some made-up cases?

Yep.  And I tested all the other edge cases that occurred to me.

-- 
Josh


Re: [PATCH v2] scripts: add script for translating stack dump function offsets

2016-09-16 Thread Josh Poimboeuf
On Fri, Sep 16, 2016 at 05:09:15PM -0700, Linus Torvalds wrote:
> On Fri, Sep 16, 2016 at 2:26 PM, Josh Poimboeuf  wrote:
> >
> > Ok, how about this.  If this looks ok, would you be willing to apply it?
> 
> Looks good to me. Did you test the size verification with some made-up cases?

Yep.  And I tested all the other edge cases that occurred to me.

-- 
Josh


Re: [PATCH] android: binder: Disable preemption while holding the global binder lock

2016-09-16 Thread Todd Kjos
Thanks Peter. We'll give that patch a try as part of our refactoring.
Looking at finer-grained locking and we'll try going back to rt_mutex
plus this patch.

On Wed, Sep 14, 2016 at 9:55 AM, Peter Zijlstra  wrote:
> On Wed, Sep 14, 2016 at 06:13:40PM +0200, Peter Zijlstra wrote:
>> On Wed, Sep 14, 2016 at 06:11:03PM +0200, Peter Zijlstra wrote:
>> > On Tue, Sep 13, 2016 at 12:53:27PM -0700, Arve Hjønnevåg wrote:
>> > > On Tue, Sep 13, 2016 at 12:32 AM, Peter Zijlstra  
>> > > wrote:
>> > > > cgroups should be irrelevant, PI is unaware of them.
>> > >
>> > > I don't think cgroups are irrelevant. PI being unaware of them
>> > > explains the problem I described. If the task that holds the lock is
>> > > in a cgroup that has a low cpu.shares value, then boosting the task's
>> > > priority within that group does necessarily make it any more likely to
>> > > run.
>> >
>> > Thing is, for FIFO/DL the important parameters (prio and deadline resp.)
>> > are not cgroup dependent.
>> >
>> > For CFS you're right, and as per usual, cgroups will be a royal pain.
>> > While we can compute the total weight in the block chain, getting that
>> > back to a task which is stuck in a cgroup is just not going to work
>> > well.
>>
>> Not to mention the fact that the weight depends on the current running
>> state. Having those tasks block insta changes the actual weight.
>>
>> > /me curses @ cgroups.. bloody stupid things.
>>
>> More of that.
>
>
> Something a little like so... completely untested, and has a fair number
> of corner cases still left open I think..
>
>
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1691,8 +1691,8 @@ struct task_struct {
> struct seccomp seccomp;
>
>  /* Thread group tracking */
> -   u32 parent_exec_id;
> -   u32 self_exec_id;
> +   u32 parent_exec_id;
> +   u32 self_exec_id;
>  /* Protection of (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed,
>   * mempolicy */
> spinlock_t alloc_lock;
> @@ -1710,6 +1710,11 @@ struct task_struct {
> struct task_struct *pi_top_task;
> /* Deadlock detection and priority inheritance handling */
> struct rt_mutex_waiter *pi_blocked_on;
> +   unsigned long pi_weight;
> +#ifdef CONFIG_CGROUP_SCHED
> +   struct task_group *orig_task_group;
> +   unsigned long normal_weight;
> +#endif
>  #endif
>
>  #ifdef CONFIG_DEBUG_MUTEXES
> @@ -1977,6 +1982,8 @@ static inline int tsk_nr_cpus_allowed(st
> return p->nr_cpus_allowed;
>  }
>
> +extern unsigned long task_pi_weight(struct task_struct *p);
> +
>  #define TNF_MIGRATED   0x01
>  #define TNF_NO_GROUP   0x02
>  #define TNF_SHARED 0x04
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -20,6 +20,19 @@
>  #include "rtmutex_common.h"
>
>  /*
> + * !(rt_prio || dl_prio)
> + */
> +static inline bool other_prio(int prio)
> +{
> +   return prio >= MAX_RT_PRIO;
> +}
> +
> +static inline bool other_task(struct task_struct *task)
> +{
> +   return other_prio(task->prio);
> +}
> +
> +/*
>   * lock->owner state tracking:
>   *
>   * lock->owner holds the task_struct pointer of the owner. Bit 0
> @@ -226,6 +239,11 @@ rt_mutex_enqueue(struct rt_mutex *lock,
>
> rb_link_node(>tree_entry, parent, link);
> rb_insert_color(>tree_entry, >waiters);
> +   /*
> +* We want the lock->waiter_weight to reflect the sum of all queued
> +* waiters.
> +*/
> +   lock->waiters_weight += waiter->weight;
>  }
>
>  static void
> @@ -239,6 +257,7 @@ rt_mutex_dequeue(struct rt_mutex *lock,
>
> rb_erase(>tree_entry, >waiters);
> RB_CLEAR_NODE(>tree_entry);
> +   lock->waiters_weight += waiter->weight;
>  }
>
>  static void
> @@ -265,6 +284,18 @@ rt_mutex_enqueue_pi(struct task_struct *
>
> rb_link_node(>pi_tree_entry, parent, link);
> rb_insert_color(>pi_tree_entry, >pi_waiters);
> +
> +   /*
> +* Since a task can own multiple locks, and we have one pi_waiter
> +* for every lock, propagate the lock->waiter_weight, which is the sum
> +* of all weights queued on that lock, into the top waiter, and add
> +* that to the owning task's pi_weight.
> +*
> +* This results in pi_weight being the sum of all blocked waiters
> +* on this task.
> +*/
> +   waiter->top_weight = waiter->lock->waiters_weight;
> +   task->pi_weight += waiter->top_weight;
>  }
>
>  static void
> @@ -278,6 +309,7 @@ rt_mutex_dequeue_pi(struct task_struct *
>
> rb_erase(>pi_tree_entry, >pi_waiters);
> RB_CLEAR_NODE(>pi_tree_entry);
> +   task->pi_weight -= waiter->top_weight;
>  }
>
>  static void rt_mutex_adjust_prio(struct task_struct *p)
> @@ -497,7 +529,7 @@ static int rt_mutex_adjust_prio_chain(st
>  * detection is enabled we continue, but stop the
>  * requeueing in the chain walk.
>  */
> -   

Re: [PATCH] android: binder: Disable preemption while holding the global binder lock

2016-09-16 Thread Todd Kjos
Thanks Peter. We'll give that patch a try as part of our refactoring.
Looking at finer-grained locking and we'll try going back to rt_mutex
plus this patch.

On Wed, Sep 14, 2016 at 9:55 AM, Peter Zijlstra  wrote:
> On Wed, Sep 14, 2016 at 06:13:40PM +0200, Peter Zijlstra wrote:
>> On Wed, Sep 14, 2016 at 06:11:03PM +0200, Peter Zijlstra wrote:
>> > On Tue, Sep 13, 2016 at 12:53:27PM -0700, Arve Hjønnevåg wrote:
>> > > On Tue, Sep 13, 2016 at 12:32 AM, Peter Zijlstra  
>> > > wrote:
>> > > > cgroups should be irrelevant, PI is unaware of them.
>> > >
>> > > I don't think cgroups are irrelevant. PI being unaware of them
>> > > explains the problem I described. If the task that holds the lock is
>> > > in a cgroup that has a low cpu.shares value, then boosting the task's
>> > > priority within that group does necessarily make it any more likely to
>> > > run.
>> >
>> > Thing is, for FIFO/DL the important parameters (prio and deadline resp.)
>> > are not cgroup dependent.
>> >
>> > For CFS you're right, and as per usual, cgroups will be a royal pain.
>> > While we can compute the total weight in the block chain, getting that
>> > back to a task which is stuck in a cgroup is just not going to work
>> > well.
>>
>> Not to mention the fact that the weight depends on the current running
>> state. Having those tasks block insta changes the actual weight.
>>
>> > /me curses @ cgroups.. bloody stupid things.
>>
>> More of that.
>
>
> Something a little like so... completely untested, and has a fair number
> of corner cases still left open I think..
>
>
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1691,8 +1691,8 @@ struct task_struct {
> struct seccomp seccomp;
>
>  /* Thread group tracking */
> -   u32 parent_exec_id;
> -   u32 self_exec_id;
> +   u32 parent_exec_id;
> +   u32 self_exec_id;
>  /* Protection of (de-)allocation: mm, files, fs, tty, keyrings, mems_allowed,
>   * mempolicy */
> spinlock_t alloc_lock;
> @@ -1710,6 +1710,11 @@ struct task_struct {
> struct task_struct *pi_top_task;
> /* Deadlock detection and priority inheritance handling */
> struct rt_mutex_waiter *pi_blocked_on;
> +   unsigned long pi_weight;
> +#ifdef CONFIG_CGROUP_SCHED
> +   struct task_group *orig_task_group;
> +   unsigned long normal_weight;
> +#endif
>  #endif
>
>  #ifdef CONFIG_DEBUG_MUTEXES
> @@ -1977,6 +1982,8 @@ static inline int tsk_nr_cpus_allowed(st
> return p->nr_cpus_allowed;
>  }
>
> +extern unsigned long task_pi_weight(struct task_struct *p);
> +
>  #define TNF_MIGRATED   0x01
>  #define TNF_NO_GROUP   0x02
>  #define TNF_SHARED 0x04
> --- a/kernel/locking/rtmutex.c
> +++ b/kernel/locking/rtmutex.c
> @@ -20,6 +20,19 @@
>  #include "rtmutex_common.h"
>
>  /*
> + * !(rt_prio || dl_prio)
> + */
> +static inline bool other_prio(int prio)
> +{
> +   return prio >= MAX_RT_PRIO;
> +}
> +
> +static inline bool other_task(struct task_struct *task)
> +{
> +   return other_prio(task->prio);
> +}
> +
> +/*
>   * lock->owner state tracking:
>   *
>   * lock->owner holds the task_struct pointer of the owner. Bit 0
> @@ -226,6 +239,11 @@ rt_mutex_enqueue(struct rt_mutex *lock,
>
> rb_link_node(>tree_entry, parent, link);
> rb_insert_color(>tree_entry, >waiters);
> +   /*
> +* We want the lock->waiter_weight to reflect the sum of all queued
> +* waiters.
> +*/
> +   lock->waiters_weight += waiter->weight;
>  }
>
>  static void
> @@ -239,6 +257,7 @@ rt_mutex_dequeue(struct rt_mutex *lock,
>
> rb_erase(>tree_entry, >waiters);
> RB_CLEAR_NODE(>tree_entry);
> +   lock->waiters_weight += waiter->weight;
>  }
>
>  static void
> @@ -265,6 +284,18 @@ rt_mutex_enqueue_pi(struct task_struct *
>
> rb_link_node(>pi_tree_entry, parent, link);
> rb_insert_color(>pi_tree_entry, >pi_waiters);
> +
> +   /*
> +* Since a task can own multiple locks, and we have one pi_waiter
> +* for every lock, propagate the lock->waiter_weight, which is the sum
> +* of all weights queued on that lock, into the top waiter, and add
> +* that to the owning task's pi_weight.
> +*
> +* This results in pi_weight being the sum of all blocked waiters
> +* on this task.
> +*/
> +   waiter->top_weight = waiter->lock->waiters_weight;
> +   task->pi_weight += waiter->top_weight;
>  }
>
>  static void
> @@ -278,6 +309,7 @@ rt_mutex_dequeue_pi(struct task_struct *
>
> rb_erase(>pi_tree_entry, >pi_waiters);
> RB_CLEAR_NODE(>pi_tree_entry);
> +   task->pi_weight -= waiter->top_weight;
>  }
>
>  static void rt_mutex_adjust_prio(struct task_struct *p)
> @@ -497,7 +529,7 @@ static int rt_mutex_adjust_prio_chain(st
>  * detection is enabled we continue, but stop the
>  * requeueing in the chain walk.
>  */
> -   if (top_waiter != 

Re: [RFC/PATCH] usb: misc: Add a driver for TC7USB40MU

2016-09-16 Thread Peter Chen
On Thu, Sep 15, 2016 at 06:16:38PM -0700, Stephen Boyd wrote:
> 
> > For #3, it is not the
> > use case for this design. #3 is usually used for the single port which
> > needs to support switching role on the fly without disconnection.
> > So, you may only need to consider #2, you can't use extcon-usb-gpio.c
> > directly since you need to set one gpio to mux the dp/dm, Baolu Lu had
> > USB MUX patch set before which may satisfy your requirement. [1]
> 
> Ok. Did the usb mux patches go anywhere? It seemed to get tangled up in
> DRD framework and I haven't been following along. I'll look into these
> patches more.

DRD framework is denied by Felipe due to only one user can be benefit
from it (chipidea OTG), I don't know the further status of USB MUX,
maybe you can ask for it.

-- 

Best Regards,
Peter Chen


Re: [RFC/PATCH] usb: misc: Add a driver for TC7USB40MU

2016-09-16 Thread Peter Chen
On Thu, Sep 15, 2016 at 06:16:38PM -0700, Stephen Boyd wrote:
> 
> > For #3, it is not the
> > use case for this design. #3 is usually used for the single port which
> > needs to support switching role on the fly without disconnection.
> > So, you may only need to consider #2, you can't use extcon-usb-gpio.c
> > directly since you need to set one gpio to mux the dp/dm, Baolu Lu had
> > USB MUX patch set before which may satisfy your requirement. [1]
> 
> Ok. Did the usb mux patches go anywhere? It seemed to get tangled up in
> DRD framework and I haven't been following along. I'll look into these
> patches more.

DRD framework is denied by Felipe due to only one user can be benefit
from it (chipidea OTG), I don't know the further status of USB MUX,
maybe you can ask for it.

-- 

Best Regards,
Peter Chen


Re: [PATCH] ARM: dts: msm8974: Add definitions for QCE & cryptobam

2016-09-16 Thread Stephen Boyd
On 09/07/2016 06:09 AM, Stanimir Varbanov wrote:
> Hi Iaroslav,
>
> On 08/30/2016 06:37 PM, Iaroslav Gridin wrote:
>> From: Voker57 
>>
>> Add device tree definitions for Qualcomm Cryptography engine and its BAM
>> Signed-off-by: Iaroslav Gridin 
>> ---
>>  arch/arm/boot/dts/qcom-msm8974.dtsi | 42 
>> +
>>  1 file changed, 42 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi 
>> b/arch/arm/boot/dts/qcom-msm8974.dtsi
>> index 561d4d1..c0da739 100644
>> --- a/arch/arm/boot/dts/qcom-msm8974.dtsi
>> +++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
>> @@ -287,6 +287,48 @@
>>  reg = <0xf9011000 0x1000>;
>>  };
>>  
>> +cryptobam: dma@fd444000 {
>> +compatible = "qcom,bam-v1.4.0";
>> +reg = <0xfd444000 0x15000>;
>> +interrupts = <0 236 0>;
> should be
>
> interrupts = ;

Please don't use IRQ_NONE. This one looks to be IRQ_TYPE_EDGE_RISING if
I'm not mistaken.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project



Re: [PATCH] ARM: dts: msm8974: Add definitions for QCE & cryptobam

2016-09-16 Thread Stephen Boyd
On 09/07/2016 06:09 AM, Stanimir Varbanov wrote:
> Hi Iaroslav,
>
> On 08/30/2016 06:37 PM, Iaroslav Gridin wrote:
>> From: Voker57 
>>
>> Add device tree definitions for Qualcomm Cryptography engine and its BAM
>> Signed-off-by: Iaroslav Gridin 
>> ---
>>  arch/arm/boot/dts/qcom-msm8974.dtsi | 42 
>> +
>>  1 file changed, 42 insertions(+)
>>
>> diff --git a/arch/arm/boot/dts/qcom-msm8974.dtsi 
>> b/arch/arm/boot/dts/qcom-msm8974.dtsi
>> index 561d4d1..c0da739 100644
>> --- a/arch/arm/boot/dts/qcom-msm8974.dtsi
>> +++ b/arch/arm/boot/dts/qcom-msm8974.dtsi
>> @@ -287,6 +287,48 @@
>>  reg = <0xf9011000 0x1000>;
>>  };
>>  
>> +cryptobam: dma@fd444000 {
>> +compatible = "qcom,bam-v1.4.0";
>> +reg = <0xfd444000 0x15000>;
>> +interrupts = <0 236 0>;
> should be
>
> interrupts = ;

Please don't use IRQ_NONE. This one looks to be IRQ_TYPE_EDGE_RISING if
I'm not mistaken.

-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project



Re: [PATCH v2] scripts: add script for translating stack dump function offsets

2016-09-16 Thread Linus Torvalds
On Fri, Sep 16, 2016 at 2:26 PM, Josh Poimboeuf  wrote:
>
> Ok, how about this.  If this looks ok, would you be willing to apply it?

Looks good to me. Did you test the size verification with some made-up cases?

Linus


Re: [PATCH v2] scripts: add script for translating stack dump function offsets

2016-09-16 Thread Linus Torvalds
On Fri, Sep 16, 2016 at 2:26 PM, Josh Poimboeuf  wrote:
>
> Ok, how about this.  If this looks ok, would you be willing to apply it?

Looks good to me. Did you test the size verification with some made-up cases?

Linus


Re: [PATCH 1/7] Apply transparent_union attribute to union semun

2016-09-16 Thread Stafford Horne



On Sat, 17 Sep 2016, kbuild test robot wrote:


Hi Jonas,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.8-rc6 next-20160916]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]
[Suggest to use git(>=2.9.0) format-patch --base= (or --base=auto for 
convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:
https://github.com/0day-ci/linux/commits/Stafford-Horne/openrisc-Misc-fixes-from-backlog/20160916-230114
config: x86_64-randconfig-b0-09170504 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
   # save the attached .config to linux build tree
   make ARCH=x86_64

All errors (new ones prefixed by >>):

  cc1: warnings being treated as errors
  In file included from include/linux/sem.h:7,
   from include/linux/sched.h:35,
   from include/linux/kasan.h:4,
   from include/linux/slab.h:118,
   from include/linux/resource_ext.h:19,
   from include/linux/acpi.h:26,
   from drivers/gpu/drm/i915/i915_drv.c:30:

include/uapi/linux/sem.h:51: error: union cannot be made transparent


Thanks for catching this.  I missed that this would break non openrisc 
architectures.


This issue is that "
All members of the union must have the same machine representation; this 
is necessary for this argument passing to work properly.

"

Definitely int and * will not always be the same.  Investingating what we 
can do on in arch/openrisc side without breaking the build/backcompat for

others.

Any other idea's welcome.

-Stafford


vim +51 include/uapi/linux/sem.h

   45   union semun {
   46   int val;/* value for SETVAL */
   47   struct semid_ds __user *buf;/* buffer for IPC_STAT & 
IPC_SET */
   48   unsigned short __user *array;   /* array for GETALL & SETALL */
   49   struct seminfo __user *__buf;   /* buffer for IPC_INFO */
   50   void __user *__pad;
 > 51} __attribute__ ((transparent_union));
   52
   53   struct  seminfo {
   54   int semmap;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation



Re: [PATCH 1/7] Apply transparent_union attribute to union semun

2016-09-16 Thread Stafford Horne



On Sat, 17 Sep 2016, kbuild test robot wrote:


Hi Jonas,

[auto build test ERROR on linus/master]
[also build test ERROR on v4.8-rc6 next-20160916]
[if your patch is applied to the wrong git tree, please drop us a note to help 
improve the system]
[Suggest to use git(>=2.9.0) format-patch --base= (or --base=auto for 
convenience) to record what (public, well-known) commit your patch series was built on]
[Check https://git-scm.com/docs/git-format-patch for more information]

url:
https://github.com/0day-ci/linux/commits/Stafford-Horne/openrisc-Misc-fixes-from-backlog/20160916-230114
config: x86_64-randconfig-b0-09170504 (attached as .config)
compiler: gcc-4.4 (Debian 4.4.7-8) 4.4.7
reproduce:
   # save the attached .config to linux build tree
   make ARCH=x86_64

All errors (new ones prefixed by >>):

  cc1: warnings being treated as errors
  In file included from include/linux/sem.h:7,
   from include/linux/sched.h:35,
   from include/linux/kasan.h:4,
   from include/linux/slab.h:118,
   from include/linux/resource_ext.h:19,
   from include/linux/acpi.h:26,
   from drivers/gpu/drm/i915/i915_drv.c:30:

include/uapi/linux/sem.h:51: error: union cannot be made transparent


Thanks for catching this.  I missed that this would break non openrisc 
architectures.


This issue is that "
All members of the union must have the same machine representation; this 
is necessary for this argument passing to work properly.

"

Definitely int and * will not always be the same.  Investingating what we 
can do on in arch/openrisc side without breaking the build/backcompat for

others.

Any other idea's welcome.

-Stafford


vim +51 include/uapi/linux/sem.h

   45   union semun {
   46   int val;/* value for SETVAL */
   47   struct semid_ds __user *buf;/* buffer for IPC_STAT & 
IPC_SET */
   48   unsigned short __user *array;   /* array for GETALL & SETALL */
   49   struct seminfo __user *__buf;   /* buffer for IPC_INFO */
   50   void __user *__pad;
 > 51} __attribute__ ((transparent_union));
   52
   53   struct  seminfo {
   54   int semmap;

---
0-DAY kernel test infrastructureOpen Source Technology Center
https://lists.01.org/pipermail/kbuild-all   Intel Corporation



Re: [REGRESSION] RLIMIT_DATA crashes named

2016-09-16 Thread Linus Torvalds
On Fri, Sep 16, 2016 at 4:58 PM, Linus Torvalds
 wrote:
>
> Here's a totally untested patch. What do people say?

Heh. It looks like "pr_xyz_once()" is used in places that haven't
included "ratelimit.h", so this doesn't actually build for everything.

But I guess as a concept patch it's not hard to understand, even if
the implementation needs a bit of tweaking.

 Linus


Re: [REGRESSION] RLIMIT_DATA crashes named

2016-09-16 Thread Linus Torvalds
On Fri, Sep 16, 2016 at 4:58 PM, Linus Torvalds
 wrote:
>
> Here's a totally untested patch. What do people say?

Heh. It looks like "pr_xyz_once()" is used in places that haven't
included "ratelimit.h", so this doesn't actually build for everything.

But I guess as a concept patch it's not hard to understand, even if
the implementation needs a bit of tweaking.

 Linus


Re: [PATCH v2 1/4] remoteproc: Introduce auto-boot flag

2016-09-16 Thread Suman Anna
Hi Bjorn,

On 09/08/2016 05:27 PM, Bjorn Andersson wrote:
> On Wed 31 Aug 11:27 PDT 2016, Suman Anna wrote:
> 
>> Hi Bjorn,
>>
>> On 08/11/2016 04:52 PM, Bjorn Andersson wrote:
>>> Introduce an "auto-boot" flag on rprocs to make it possible to flag
>>> remote processors without vdevs to automatically boot once the firmware
>>> is found.
>>>
>>> Preserve previous behavior of the wkup_m3 processor being explicitly
>>> booted by a consumer.
>>>
>>> Cc: Lee Jones 
>>> Cc: Loic Pallardy 
>>> Cc: Suman Anna 
>>> Signed-off-by: Bjorn Andersson 
>>> ---
>>>
>>> Changes since v1:
>>> - s/always_on/auto_boot/
>>> - Fixed double increment of "power" in recover path
>>> - Marked wkup_m3 to not auto_boot
>>>
>>
>> I am seeing various issues with this series as I am testing this series
>> more thoroughly with various TI remoteproc drivers and IPC stacks based
>> on virtio devices. I use very simple firmware images that publishes the
>> rpmsg-client-sample devices, so that I can use the kernel
>> rpmsg_client_sample to test the communication.
>>
> 
> Thanks for bringing these up!
> 
>> Here's a summary of the main issues:
>>
>> 1. The rproc_boot holds a module reference count to the remoteproc
>> platform driver so that it cannot be removed when a remote processor is
>> booted. The previous architecture allowed virtio_rpmsg_bus or the
>> platform remoteproc driver to be installed independent of each other
>> with the boot actually getting triggered when the virtio_rpmsg_bus gets
>> probed in find_vqs. The boot now happens when just the platform
>> remoteproc driver is installed independent of virtio_rpmsg_bus and
>> results in holding self-reference counts. This makes it impossible to
>> remove the remoteproc platform module cleanly (we shouldn't be imposing
>> force remove), which means we can't stop the remoteprocs properly.
>>
> 
> I've always found the dependency on rpmsg awkward and don't like this
> behavior to depend on the firmware content, but rather on some sort of
> system configuration.
> 
> That said, I did not intend to break the ability of shutting down and
> unloading the module.

The remoteproc infrastructure always allowed the boot to be done by an
external module (with vdevs, it looks intrinsic because of the
invocation in remoteproc_virtio.c, but the boot was really triggered
during virtio_rpmsg probe) and provided protection against removing the
remoteproc driver removal when you had a consumer. I tried the auto-boot
when I was upstreaming the wkup_m3_rproc driver and it was rejected for
exactly this reason.

> Calling rmmod on your rproc module is a rather explicit operation, do
> you know why there's a need to hold the module reference? Wouldn't it be
> cleaner to just shutdown the remoteproc as the module is being removed -
> which would include tearing down all children (rpmsg and others)

Right, the introduction of the auto-boot ended up in a self-holding
reference count which should be fixed to allow you to remove the module.
The external module boot is still a valid usage (when auto_boot is
false) though.

> 
> I expect to be able to compile rpmsg into my kernel and still be able to
> unload my remoteproc module.
> 
>> 2. The reversal of boot between virtio_rpmsg_bus and remoteproc core
>> also meant that the virtio devices and therefore the memory for vrings
>> are allocated at the time virtio_rpmsg_bus is probed in find_vqs(). The
>> remoteproc can be booted without the virtio_rpmsg_bus module installed.
>> We do use the allocated dma addresses of the vrings in the published
>> resource table, but now the remote processor is up even before these
>> values are filled in. I had to actually move up the rproc_alloc_vring
>> alongside rproc_parse_vring to have the communication up.
>>
> 
> This also means that for a piece of firmware that exposes more than one
> virtio device we would have the same race.

Yes, if you had more virtio devices technically. The remoteproc
infrastructure so far hadn't supported more than one vdev. We did
support that in our downstream kernel but that was for a non-SMP usage
on a dual-core remoteproc subsystem and the virtio devices were still
virtio_rpmsg devices, so it scaled for us when we removed the
virtio_rpmsg_bus module as long as the reference counts were managed in
rproc_boot and rproc_shutdown()

> 
> As you say it makes more sense to allocate the vrings as we set up the
> other resources.
> 
>> 3. The remoteproc platform driver cannot be removed previously when the
>> corresponding virtio devices are probed/configured properly and all the
>> communication flow w.r.t rpmsg channel publishing followed from the
>> remoteproc boot. These channels are child devices of the parent virtio
>> devices, and since the remoteproc boot/shutdown followed the virtio
>> device probe/removal lifecycle, the rpmsg channels life-cycle followed
>> that of the parent virtio device. My 

Re: [PATCH v2 1/4] remoteproc: Introduce auto-boot flag

2016-09-16 Thread Suman Anna
Hi Bjorn,

On 09/08/2016 05:27 PM, Bjorn Andersson wrote:
> On Wed 31 Aug 11:27 PDT 2016, Suman Anna wrote:
> 
>> Hi Bjorn,
>>
>> On 08/11/2016 04:52 PM, Bjorn Andersson wrote:
>>> Introduce an "auto-boot" flag on rprocs to make it possible to flag
>>> remote processors without vdevs to automatically boot once the firmware
>>> is found.
>>>
>>> Preserve previous behavior of the wkup_m3 processor being explicitly
>>> booted by a consumer.
>>>
>>> Cc: Lee Jones 
>>> Cc: Loic Pallardy 
>>> Cc: Suman Anna 
>>> Signed-off-by: Bjorn Andersson 
>>> ---
>>>
>>> Changes since v1:
>>> - s/always_on/auto_boot/
>>> - Fixed double increment of "power" in recover path
>>> - Marked wkup_m3 to not auto_boot
>>>
>>
>> I am seeing various issues with this series as I am testing this series
>> more thoroughly with various TI remoteproc drivers and IPC stacks based
>> on virtio devices. I use very simple firmware images that publishes the
>> rpmsg-client-sample devices, so that I can use the kernel
>> rpmsg_client_sample to test the communication.
>>
> 
> Thanks for bringing these up!
> 
>> Here's a summary of the main issues:
>>
>> 1. The rproc_boot holds a module reference count to the remoteproc
>> platform driver so that it cannot be removed when a remote processor is
>> booted. The previous architecture allowed virtio_rpmsg_bus or the
>> platform remoteproc driver to be installed independent of each other
>> with the boot actually getting triggered when the virtio_rpmsg_bus gets
>> probed in find_vqs. The boot now happens when just the platform
>> remoteproc driver is installed independent of virtio_rpmsg_bus and
>> results in holding self-reference counts. This makes it impossible to
>> remove the remoteproc platform module cleanly (we shouldn't be imposing
>> force remove), which means we can't stop the remoteprocs properly.
>>
> 
> I've always found the dependency on rpmsg awkward and don't like this
> behavior to depend on the firmware content, but rather on some sort of
> system configuration.
> 
> That said, I did not intend to break the ability of shutting down and
> unloading the module.

The remoteproc infrastructure always allowed the boot to be done by an
external module (with vdevs, it looks intrinsic because of the
invocation in remoteproc_virtio.c, but the boot was really triggered
during virtio_rpmsg probe) and provided protection against removing the
remoteproc driver removal when you had a consumer. I tried the auto-boot
when I was upstreaming the wkup_m3_rproc driver and it was rejected for
exactly this reason.

> Calling rmmod on your rproc module is a rather explicit operation, do
> you know why there's a need to hold the module reference? Wouldn't it be
> cleaner to just shutdown the remoteproc as the module is being removed -
> which would include tearing down all children (rpmsg and others)

Right, the introduction of the auto-boot ended up in a self-holding
reference count which should be fixed to allow you to remove the module.
The external module boot is still a valid usage (when auto_boot is
false) though.

> 
> I expect to be able to compile rpmsg into my kernel and still be able to
> unload my remoteproc module.
> 
>> 2. The reversal of boot between virtio_rpmsg_bus and remoteproc core
>> also meant that the virtio devices and therefore the memory for vrings
>> are allocated at the time virtio_rpmsg_bus is probed in find_vqs(). The
>> remoteproc can be booted without the virtio_rpmsg_bus module installed.
>> We do use the allocated dma addresses of the vrings in the published
>> resource table, but now the remote processor is up even before these
>> values are filled in. I had to actually move up the rproc_alloc_vring
>> alongside rproc_parse_vring to have the communication up.
>>
> 
> This also means that for a piece of firmware that exposes more than one
> virtio device we would have the same race.

Yes, if you had more virtio devices technically. The remoteproc
infrastructure so far hadn't supported more than one vdev. We did
support that in our downstream kernel but that was for a non-SMP usage
on a dual-core remoteproc subsystem and the virtio devices were still
virtio_rpmsg devices, so it scaled for us when we removed the
virtio_rpmsg_bus module as long as the reference counts were managed in
rproc_boot and rproc_shutdown()

> 
> As you say it makes more sense to allocate the vrings as we set up the
> other resources.
> 
>> 3. The remoteproc platform driver cannot be removed previously when the
>> corresponding virtio devices are probed/configured properly and all the
>> communication flow w.r.t rpmsg channel publishing followed from the
>> remoteproc boot. These channels are child devices of the parent virtio
>> devices, and since the remoteproc boot/shutdown followed the virtio
>> device probe/removal lifecycle, the rpmsg channels life-cycle followed
>> that of the parent virtio device. My communication paths are now failing
>> if I remove the virtio_rpmsg_bus and insmod it again as 

Re: [REGRESSION] RLIMIT_DATA crashes named

2016-09-16 Thread Linus Torvalds
On Fri, Sep 16, 2016 at 3:30 PM, Sam Varshavchik  wrote:
>>
>> Sam, do you end up seeing the kernel warning in your logs if you just
>> go back earlier in the boot?
>
> Yes, I found it.
>
> Sep 10 07:36:29 shorty kernel: mmap: named (1108): VmData 52588544 exceed
> data ulimit 20971520. Update limits or use boot option ignore_rlimit_data.
>
> Now that I know what to search for: this appeared about 300 lines earlier in
> /var/log/messages.

Ok, so that's a pretty strong argument that we shouldn't just warn once.

Maybe the warning happened at bootup, and it is now three months
later, and somebody notices that something doesn't work. It might not
be *critical* (three months without working implies it isn't), but it
sure is silly for the kernel to say "yeah, I already warned you, I'm
not going to tell you why it's not working any more".

So it sounds like if the kernel had just had a that warning be
rate-limited instead of happening only once, there would never have
been any confusion about the RLIMIT_DATA change.

Doing a grep for "pr_warn_once()", I get the feeling that we could
just change the definition of "once" to be "at most once per minute"
and everybody would be happy.

Maybe we could change all the "pr_xyz_once()" to consider "once" to be
a softer "at most once per minute" thing. After all, these things are
*supposed* to be very uncommon to begin with, but when they do happen
we do want the user to be aware of them.

Here's a totally untested patch. What do people say?

 Linus
 include/linux/printk.h | 38 +++---
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 696a56be7d3e..ae98c388a377 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -316,31 +316,23 @@ extern asmlinkage void dump_stack(void) __cold;
 
 /*
  * Print a one-time message (analogous to WARN_ONCE() et al):
+ *
+ * "once" here is a misnomer. It's shorthand for "at most once a minute".
  */
-
 #ifdef CONFIG_PRINTK
-#define printk_once(fmt, ...)  \
-({ \
-   static bool __print_once __read_mostly; \
-   bool __ret_print_once = !__print_once;  \
-   \
-   if (!__print_once) {\
-   __print_once = true;\
-   printk(fmt, ##__VA_ARGS__); \
-   }   \
-   unlikely(__ret_print_once); \
-})
-#define printk_deferred_once(fmt, ...) \
-({ \
-   static bool __print_once __read_mostly; \
-   bool __ret_print_once = !__print_once;  \
-   \
-   if (!__print_once) {\
-   __print_once = true;\
-   printk_deferred(fmt, ##__VA_ARGS__);\
-   }   \
-   unlikely(__ret_print_once); \
-})
+
+#define do_just_once(stmt) ({  \
+   static DEFINE_RATELIMIT_STATE(_rs, HZ*60, 1);   \
+   bool __do_it = __ratelimit(&_rs);   \
+   if (unlikely(__do_it))  \
+   stmt;   \
+   unlikely(__do_it); })
+
+#define printk_once(fmt, ...) \
+   do_just_once(printk(fmt, ##__VA_ARGS__))
+#define printk_deferred_once(fmt, ...) \
+   do_just_once(printk_deferred(fmt, ##__VA_ARGS__))
+
 #else
 #define printk_once(fmt, ...)  \
no_printk(fmt, ##__VA_ARGS__)


Re: [REGRESSION] RLIMIT_DATA crashes named

2016-09-16 Thread Linus Torvalds
On Fri, Sep 16, 2016 at 3:30 PM, Sam Varshavchik  wrote:
>>
>> Sam, do you end up seeing the kernel warning in your logs if you just
>> go back earlier in the boot?
>
> Yes, I found it.
>
> Sep 10 07:36:29 shorty kernel: mmap: named (1108): VmData 52588544 exceed
> data ulimit 20971520. Update limits or use boot option ignore_rlimit_data.
>
> Now that I know what to search for: this appeared about 300 lines earlier in
> /var/log/messages.

Ok, so that's a pretty strong argument that we shouldn't just warn once.

Maybe the warning happened at bootup, and it is now three months
later, and somebody notices that something doesn't work. It might not
be *critical* (three months without working implies it isn't), but it
sure is silly for the kernel to say "yeah, I already warned you, I'm
not going to tell you why it's not working any more".

So it sounds like if the kernel had just had a that warning be
rate-limited instead of happening only once, there would never have
been any confusion about the RLIMIT_DATA change.

Doing a grep for "pr_warn_once()", I get the feeling that we could
just change the definition of "once" to be "at most once per minute"
and everybody would be happy.

Maybe we could change all the "pr_xyz_once()" to consider "once" to be
a softer "at most once per minute" thing. After all, these things are
*supposed* to be very uncommon to begin with, but when they do happen
we do want the user to be aware of them.

Here's a totally untested patch. What do people say?

 Linus
 include/linux/printk.h | 38 +++---
 1 file changed, 15 insertions(+), 23 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 696a56be7d3e..ae98c388a377 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -316,31 +316,23 @@ extern asmlinkage void dump_stack(void) __cold;
 
 /*
  * Print a one-time message (analogous to WARN_ONCE() et al):
+ *
+ * "once" here is a misnomer. It's shorthand for "at most once a minute".
  */
-
 #ifdef CONFIG_PRINTK
-#define printk_once(fmt, ...)  \
-({ \
-   static bool __print_once __read_mostly; \
-   bool __ret_print_once = !__print_once;  \
-   \
-   if (!__print_once) {\
-   __print_once = true;\
-   printk(fmt, ##__VA_ARGS__); \
-   }   \
-   unlikely(__ret_print_once); \
-})
-#define printk_deferred_once(fmt, ...) \
-({ \
-   static bool __print_once __read_mostly; \
-   bool __ret_print_once = !__print_once;  \
-   \
-   if (!__print_once) {\
-   __print_once = true;\
-   printk_deferred(fmt, ##__VA_ARGS__);\
-   }   \
-   unlikely(__ret_print_once); \
-})
+
+#define do_just_once(stmt) ({  \
+   static DEFINE_RATELIMIT_STATE(_rs, HZ*60, 1);   \
+   bool __do_it = __ratelimit(&_rs);   \
+   if (unlikely(__do_it))  \
+   stmt;   \
+   unlikely(__do_it); })
+
+#define printk_once(fmt, ...) \
+   do_just_once(printk(fmt, ##__VA_ARGS__))
+#define printk_deferred_once(fmt, ...) \
+   do_just_once(printk_deferred(fmt, ##__VA_ARGS__))
+
 #else
 #define printk_once(fmt, ...)  \
no_printk(fmt, ##__VA_ARGS__)


  1   2   3   4   5   6   7   8   9   10   >