Re: [PATCH 4.9 00/83] 4.9.191-stable review

2019-09-05 Thread Kelsey Skunberg
On Wed, Sep 04, 2019 at 07:52:52PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.9.191 release.
> There are 83 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 06 Sep 2019 05:50:23 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.191-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.9.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled, booted, and no regressions on my system.

-Kelsey



Re: [PATCH 4.14 00/57] 4.14.142-stable review

2019-09-05 Thread Kelsey Skunberg
On Wed, Sep 04, 2019 at 07:53:28PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.14.142 release.
> There are 57 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 06 Sep 2019 05:50:23 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.142-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.14.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled, booted, and no regressions on my system.

-Kelsey



Re: [PATCH 4.19 00/93] 4.19.70-stable review

2019-09-05 Thread Kelsey Skunberg
On Wed, Sep 04, 2019 at 07:53:02PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.19.70 release.
> There are 93 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 06 Sep 2019 05:50:23 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.70-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.19.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled, booted, and no regressions on my system.

-Kelsey


Re: [PATCH 5.2 000/143] 5.2.12-stable review

2019-09-05 Thread Kelsey Skunberg
On Wed, Sep 04, 2019 at 07:52:23PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.2.12 release.
> There are 143 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 06 Sep 2019 05:50:23 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.12-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-5.2.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled, booted, and no regressions on my system.

-Kelsey



Re: [PATCH 4.4 00/77] 4.4.191-stable review

2019-09-05 Thread Kelsey Skunberg
On Wed, Sep 04, 2019 at 07:52:47PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.4.191 release.
> There are 77 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 06 Sep 2019 05:50:23 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.191-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.4.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled, booted, and no regressions on my system.

-Kelsey


Re: [Linux-kernel-mentees] [PATCH] PCI/IOV: Make SR-IOV attributes with mode 0664 use 0644

2019-09-05 Thread Kelsey Skunberg
On Thu, Sep 05, 2019 at 01:29:38PM -0500, Bjorn Helgaas wrote:
> [+cc Bodong, Eli: just FYI since this affects sriov_drivers_autoprobe,
> which you added with 0e7df22401a3]
> 
> On Thu, Sep 05, 2019 at 12:32:26AM -0600, Kelsey Skunberg wrote:
> > sriov_numvfs and sriov_drivers_autoprobe have "unusual" permissions (0664)
> > with no reported or found reason for allowing group write permissions.
> > libvirt runs as root when dealing with PCI, and chowns files for qemu
> > needs. There is not a need for the "0664" permissions.
> > 
> > sriov_numvfs was introduced in:
> > commit 1789382a72a5 ("PCI: SRIOV control and status via sysfs")
> > 
> > sriov_drivers_autoprobe was introduced in:
> > commit 0e7df22401a3 ("PCI: Add sysfs sriov_drivers_autoprobe to
> >   control VF driver binding")
> > 
> > Change sriov_numvfs and sriov_drivers_autoprobe from "0664" permissions to
> > "0644" permissions.
> > 
> > Exchange DEVICE_ATTR() with DEVICE_ATTR_RW() which sets the mode to "0644".
> > DEVICE_ATTR() should only be used for "unusual" permissions.
> > 
> > Signed-off-by: Kelsey Skunberg 
> 
> Applied with Greg's Reviewed-by and Don's Acked-by to pci/misc for
> v5.4, thanks!
>

Appreciate you adding the cc and applying. Thanks, Bjorn!

-Kelsey
 
> > ---
> >  drivers/pci/iov.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> > index b335db21c85e..b3f972e8cfed 100644
> > --- a/drivers/pci/iov.c
> > +++ b/drivers/pci/iov.c
> > @@ -375,12 +375,11 @@ static ssize_t sriov_drivers_autoprobe_store(struct 
> > device *dev,
> >  }
> >  
> >  static DEVICE_ATTR_RO(sriov_totalvfs);
> > -static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show, 
> > sriov_numvfs_store);
> > +static DEVICE_ATTR_RW(sriov_numvfs);
> >  static DEVICE_ATTR_RO(sriov_offset);
> >  static DEVICE_ATTR_RO(sriov_stride);
> >  static DEVICE_ATTR_RO(sriov_vf_device);
> > -static DEVICE_ATTR(sriov_drivers_autoprobe, 0664, 
> > sriov_drivers_autoprobe_show,
> > -  sriov_drivers_autoprobe_store);
> > +static DEVICE_ATTR_RW(sriov_drivers_autoprobe);
> >  
> >  static struct attribute *sriov_dev_attrs[] = {
> > _attr_sriov_totalvfs.attr,
> > -- 
> > 2.20.1
> > 
> > ___
> > Linux-kernel-mentees mailing list
> > linux-kernel-ment...@lists.linuxfoundation.org
> > https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees


Re: [PATCH] PCI/IOV: Make SR-IOV attributes with mode 0664 use 0644

2019-09-05 Thread Kelsey Skunberg
On Thu, Sep 05, 2019 at 12:24:19PM -0400, Don Dutile wrote:
> On 09/05/2019 02:32 AM, Kelsey Skunberg wrote:
> > sriov_numvfs and sriov_drivers_autoprobe have "unusual" permissions (0664)
> > with no reported or found reason for allowing group write permissions.
> > libvirt runs as root when dealing with PCI, and chowns files for qemu
> > needs. There is not a need for the "0664" permissions.
> > 
> > sriov_numvfs was introduced in:
> > commit 1789382a72a5 ("PCI: SRIOV control and status via sysfs")
> > 
> > sriov_drivers_autoprobe was introduced in:
> > commit 0e7df22401a3 ("PCI: Add sysfs sriov_drivers_autoprobe to
> >   control VF driver binding")
> > 
> > Change sriov_numvfs and sriov_drivers_autoprobe from "0664" permissions to
> > "0644" permissions.
> > 
> > Exchange DEVICE_ATTR() with DEVICE_ATTR_RW() which sets the mode to "0644".
> > DEVICE_ATTR() should only be used for "unusual" permissions.
> > 
> > Signed-off-by: Kelsey Skunberg 
> > ---
> >   drivers/pci/iov.c | 5 ++---
> >   1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> > index b335db21c85e..b3f972e8cfed 100644
> > --- a/drivers/pci/iov.c
> > +++ b/drivers/pci/iov.c
> > @@ -375,12 +375,11 @@ static ssize_t sriov_drivers_autoprobe_store(struct 
> > device *dev,
> >   }
> >   static DEVICE_ATTR_RO(sriov_totalvfs);
> > -static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show, 
> > sriov_numvfs_store);
> > +static DEVICE_ATTR_RW(sriov_numvfs);
> >   static DEVICE_ATTR_RO(sriov_offset);
> >   static DEVICE_ATTR_RO(sriov_stride);
> >   static DEVICE_ATTR_RO(sriov_vf_device);
> > -static DEVICE_ATTR(sriov_drivers_autoprobe, 0664, 
> > sriov_drivers_autoprobe_show,
> > -  sriov_drivers_autoprobe_store);
> > +static DEVICE_ATTR_RW(sriov_drivers_autoprobe);
> >   static struct attribute *sriov_dev_attrs[] = {
> > _attr_sriov_totalvfs.attr,
> > 
> Thanks again for the cleanup.
> 
> Acked-by: Donald Dutile 
>

Glad I could contribute. Thanks for your help and the
acknowledgment. :)

-Kelsey


Re: [PATCH] PCI/IOV: Make SR-IOV attributes with mode 0664 use 0644

2019-09-05 Thread Kelsey Skunberg
On Thu, Sep 05, 2019 at 09:34:16AM +0200, Greg KH wrote:
> On Thu, Sep 05, 2019 at 12:32:26AM -0600, Kelsey Skunberg wrote:
> > sriov_numvfs and sriov_drivers_autoprobe have "unusual" permissions (0664)
> > with no reported or found reason for allowing group write permissions.
> > libvirt runs as root when dealing with PCI, and chowns files for qemu
> > needs. There is not a need for the "0664" permissions.
> > 
> > sriov_numvfs was introduced in:
> > commit 1789382a72a5 ("PCI: SRIOV control and status via sysfs")
> > 
> > sriov_drivers_autoprobe was introduced in:
> > commit 0e7df22401a3 ("PCI: Add sysfs sriov_drivers_autoprobe to
> >   control VF driver binding")
> > 
> > Change sriov_numvfs and sriov_drivers_autoprobe from "0664" permissions to
> > "0644" permissions.
> > 
> > Exchange DEVICE_ATTR() with DEVICE_ATTR_RW() which sets the mode to "0644".
> > DEVICE_ATTR() should only be used for "unusual" permissions.
> > 
> > Signed-off-by: Kelsey Skunberg 
> > ---
> >  drivers/pci/iov.c | 5 ++---
> >  1 file changed, 2 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
> > index b335db21c85e..b3f972e8cfed 100644
> > --- a/drivers/pci/iov.c
> > +++ b/drivers/pci/iov.c
> > @@ -375,12 +375,11 @@ static ssize_t sriov_drivers_autoprobe_store(struct 
> > device *dev,
> >  }
> >  
> >  static DEVICE_ATTR_RO(sriov_totalvfs);
> > -static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show, 
> > sriov_numvfs_store);
> > +static DEVICE_ATTR_RW(sriov_numvfs);
> >  static DEVICE_ATTR_RO(sriov_offset);
> >  static DEVICE_ATTR_RO(sriov_stride);
> >  static DEVICE_ATTR_RO(sriov_vf_device);
> > -static DEVICE_ATTR(sriov_drivers_autoprobe, 0664, 
> > sriov_drivers_autoprobe_show,
> > -  sriov_drivers_autoprobe_store);
> > +static DEVICE_ATTR_RW(sriov_drivers_autoprobe);
> >  
> >  static struct attribute *sriov_dev_attrs[] = {
> > _attr_sriov_totalvfs.attr,
> 
> 
> Nice!!!
> 
> Reviewed-by: Greg Kroah-Hartman 

Thank you for reviewing!

-Kelsey


Re: [PATCH 2/2] PCI: Unify pci_dev_is_disconnected() and pci_dev_is_inaccessible()

2019-09-05 Thread Kelsey Skunberg
On Wed, Sep 04, 2019 at 07:35:23AM +0200, Lukas Wunner wrote:
> On Tue, Sep 03, 2019 at 10:36:35PM -0600, Kelsey Skunberg wrote:
> > Change pci_dev_is_disconnected() call inside pci_dev_is_inaccessible() to:
> > 
> > pdev->error_state == pci_channel_io_perm_failure
> > 
> > Change remaining pci_dev_is_disconnected() calls to
> > pci_dev_is_inaccessible() calls.
> 
> I don't think that's a good idea because it introduces a config space read
> (for the vendor ID) in places where we don't want that.  E.g., after the
> check of pdev->error_state, a regular config space read may take place and
> if that returns all ones, we may already be able to determine that the
> device is inaccessible, obviating the need for a vendor ID check.
> Config space reads aren't for free.
> 
> Thanks,
> 
> Lukas

Good note. I definitely see why that would be undesirable. Thanks for
taking the time to point this out, Lukas. I'll look this over again to see
if a better solution can be done, or as Bjorn suggested, at least see if
clarification on when to use one vs. the other can be included.

Thanks again!

-Kelsey


[PATCH] PCI/IOV: Make SR-IOV attributes with mode 0664 use 0644

2019-09-05 Thread Kelsey Skunberg
sriov_numvfs and sriov_drivers_autoprobe have "unusual" permissions (0664)
with no reported or found reason for allowing group write permissions.
libvirt runs as root when dealing with PCI, and chowns files for qemu
needs. There is not a need for the "0664" permissions.

sriov_numvfs was introduced in:
commit 1789382a72a5 ("PCI: SRIOV control and status via sysfs")

sriov_drivers_autoprobe was introduced in:
commit 0e7df22401a3 ("PCI: Add sysfs sriov_drivers_autoprobe to
  control VF driver binding")

Change sriov_numvfs and sriov_drivers_autoprobe from "0664" permissions to
"0644" permissions.

Exchange DEVICE_ATTR() with DEVICE_ATTR_RW() which sets the mode to "0644".
DEVICE_ATTR() should only be used for "unusual" permissions.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/iov.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index b335db21c85e..b3f972e8cfed 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -375,12 +375,11 @@ static ssize_t sriov_drivers_autoprobe_store(struct 
device *dev,
 }
 
 static DEVICE_ATTR_RO(sriov_totalvfs);
-static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show, sriov_numvfs_store);
+static DEVICE_ATTR_RW(sriov_numvfs);
 static DEVICE_ATTR_RO(sriov_offset);
 static DEVICE_ATTR_RO(sriov_stride);
 static DEVICE_ATTR_RO(sriov_vf_device);
-static DEVICE_ATTR(sriov_drivers_autoprobe, 0664, sriov_drivers_autoprobe_show,
-  sriov_drivers_autoprobe_store);
+static DEVICE_ATTR_RW(sriov_drivers_autoprobe);
 
 static struct attribute *sriov_dev_attrs[] = {
_attr_sriov_totalvfs.attr,
-- 
2.20.1



Re: [PATCH 1/3] ACPI: Remove acpi_has_method() call from acpi_adxl.c

2019-09-04 Thread Kelsey Skunberg
On Mon, Sep 02, 2019 at 11:08:08PM +0200, Rafael J. Wysocki wrote:
> Sorry for the delayed reply.
> 
> On Mon, Jul 22, 2019 at 8:29 PM Bjorn Helgaas  wrote:
> >
> > [+cc Tony (original author), Borislav (merged original patch)]
> >
> > On Mon, Jul 22, 2019 at 10:31:11AM +0200, Rafael J. Wysocki wrote:
> > > On Mon, Jul 22, 2019 at 4:36 AM Kelsey Skunberg
> > >  wrote:
> > > >
> > > > acpi_check_dsm() will already return an error if the DSM method does not
> > > > exist. Checking if the DSM method exists before the acpi_check_dsm() 
> > > > call
> > > > is not needed. Remove acpi_has_method() call to avoid additional work.
> > > >
> > > > Signed-off-by: Kelsey Skunberg 
> > > > ---
> > > >  drivers/acpi/acpi_adxl.c | 5 -
> > > >  1 file changed, 5 deletions(-)
> > > >
> > > > diff --git a/drivers/acpi/acpi_adxl.c b/drivers/acpi/acpi_adxl.c
> > > > index 13c8f7b50c46..89aac15663fd 100644
> > > > --- a/drivers/acpi/acpi_adxl.c
> > > > +++ b/drivers/acpi/acpi_adxl.c
> > > > @@ -148,11 +148,6 @@ static int __init adxl_init(void)
> > > > return -ENODEV;
> > > > }
> > > >
> > > > -   if (!acpi_has_method(handle, "_DSM")) {
> > > > -   pr_info("No DSM method\n");
> > >
> > > And why is printing the message not useful?
> > >
> > > > -   return -ENODEV;
> > > > -   }
> > > > -
> > > > if (!acpi_check_dsm(handle, _guid, ADXL_REVISION,
> > > > ADXL_IDX_GET_ADDR_PARAMS |
> > > > ADXL_IDX_FORWARD_TRANSLATE)) {
> >
> > The next line of context (not included in the patch):
> >
> >pr_info("DSM method does not support forward translate\n");
> >
> > IMHO kernel messages that are just a constant string, with no context
> > or variable part (device ID, path, error code, etc) are questionable
> > in general.  Is there any dev_printk()-like thing that takes an
> > acpi_handle?  Seems like that would be useful for cases like this.
> >
> > This message *does* include an "ADXL: " prefix (from the pr_fmt
> > definition), and from reading the code you can see that the only
> > possible method is "\_SB.ADXL._DSM".
> >
> > There's nothing an end user can do with these messages, so I suspect
> > their value is for debugging during platform bringup, and it would be
> > sufficient to drop the first one (as Kelsey's patch does) and change
> > the second one like this:
> >
> > -  pr_info("DSM method does not support forward translate\n");
> > +  pr_info("%s DSM missing or does not support forward 
> > translate\n",
> > +  path);
> 
> You have a point, but then I would expect the changelog to mention that.
> 
> As it stands, the patch does more than the changelog says, which isn't nice.

You're right, the changelog should include this information. I'll get an
updated version made. Thank you for getting back.

-Kelsey


Re: [Linux-kernel-mentees] [PATCH v2 2/3] PCI: sysfs: Change permissions from symbolic to octal

2019-09-04 Thread Kelsey Skunberg
On Wed, Sep 04, 2019 at 02:33:44PM -0400, Don Dutile wrote:
> On 09/04/2019 02:22 AM, Kelsey Skunberg wrote:
> > On Thu, Aug 15, 2019 at 10:37:13AM -0400, Don Dutile wrote:
> > > On 08/14/2019 01:38 AM, Bjorn Helgaas wrote:
> > > > [+cc Bodong, Don, Greg for permission question]
> > > > 
> > > > On Tue, Aug 13, 2019 at 02:45:12PM -0600, Kelsey Skunberg wrote:
> > > > > Symbolic permissions such as "(S_IWUSR | S_IWGRP)" are not
> > > > > preferred and octal permissions should be used instead. Change all
> > > > > symbolic permissions to octal permissions.
> > > > > 
> > > > > Example of old:
> > > > > 
> > > > > "(S_IWUSR | S_IWGRP)"
> > > > > 
> > > > > Example of new:
> > > > > 
> > > > > "0220"
> > > > 
> > > > 
> > > > >static DEVICE_ATTR_RO(sriov_totalvfs);
> > > > > -static DEVICE_ATTR(sriov_numvfs, (S_IRUGO | S_IWUSR | S_IWGRP),
> > > > > -   sriov_numvfs_show, 
> > > > > sriov_numvfs_store);
> > > > > +static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show, 
> > > > > sriov_numvfs_store);
> > > > >static DEVICE_ATTR_RO(sriov_offset);
> > > > >static DEVICE_ATTR_RO(sriov_stride);
> > > > >static DEVICE_ATTR_RO(sriov_vf_device);
> > > > > -static DEVICE_ATTR(sriov_drivers_autoprobe, (S_IRUGO | S_IWUSR | 
> > > > > S_IWGRP),
> > > > > -sriov_drivers_autoprobe_show, 
> > > > > sriov_drivers_autoprobe_store);
> > > > > +static DEVICE_ATTR(sriov_drivers_autoprobe, 0664, 
> > > > > sriov_drivers_autoprobe_show,
> > > > > +sriov_drivers_autoprobe_store);
> > > > 
> > > > Greg noticed that sriov_numvfs and sriov_drivers_autoprobe have
> > > > "unusual" permissions.  These were added by:
> > > > 
> > > > 0e7df22401a3 ("PCI: Add sysfs sriov_drivers_autoprobe to control VF 
> > > > driver binding")
> > > > 1789382a72a5 ("PCI: SRIOV control and status via sysfs")
> > > > 
> > > > Kelsey's patch correctly preserves the existing permissions, but we
> > > > should double-check that they are the permissions they want, and
> > > > possibly add a comment about why they're different from the rest.
> > > > 
> > > > Bjorn
> > > > 
> > 
> > Hi Don,
> > 
> > > The rest being? ... 0644 vs 0664 ?
> > > The file is read & written, thus the (first) 6; I'll have to dig through 
> > > very old (7 yr) notes to see if the second 6 is needed for libvirt (so it 
> > > doesn't have to be root to enable).
> > > 
> > > -dd
> > > 
> > 
> > Were you able to see if the unusual permissions (0664) are needed for
> > libvirt? I appreciate your help!
> > 
> > -Kelsey
> > 
> Daniel Berrangé reported that libvirt runs as root when dealing with anything 
> PCI, and chowns files for qemu needs, so there is no need for the 664 
> permission.
> For all I know, it's a simple typo that was allowed to creep in. :-/
> 
> Feel free to modify to 644.
> 
> -dd
>

Thank you for checking into this and getting back so quick! I'll cc you in
the patch. :)

Thanks again!

-Kelsey


Re: [Linux-kernel-mentees] [PATCH v2 2/3] PCI: sysfs: Change permissions from symbolic to octal

2019-09-04 Thread Kelsey Skunberg
On Thu, Aug 15, 2019 at 10:37:13AM -0400, Don Dutile wrote:
> On 08/14/2019 01:38 AM, Bjorn Helgaas wrote:
> > [+cc Bodong, Don, Greg for permission question]
> > 
> > On Tue, Aug 13, 2019 at 02:45:12PM -0600, Kelsey Skunberg wrote:
> > > Symbolic permissions such as "(S_IWUSR | S_IWGRP)" are not
> > > preferred and octal permissions should be used instead. Change all
> > > symbolic permissions to octal permissions.
> > > 
> > > Example of old:
> > > 
> > > "(S_IWUSR | S_IWGRP)"
> > > 
> > > Example of new:
> > > 
> > > "0220"
> > 
> > 
> > >   static DEVICE_ATTR_RO(sriov_totalvfs);
> > > -static DEVICE_ATTR(sriov_numvfs, (S_IRUGO | S_IWUSR | S_IWGRP),
> > > -   sriov_numvfs_show, sriov_numvfs_store);
> > > +static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show, 
> > > sriov_numvfs_store);
> > >   static DEVICE_ATTR_RO(sriov_offset);
> > >   static DEVICE_ATTR_RO(sriov_stride);
> > >   static DEVICE_ATTR_RO(sriov_vf_device);
> > > -static DEVICE_ATTR(sriov_drivers_autoprobe, (S_IRUGO | S_IWUSR | 
> > > S_IWGRP),
> > > -sriov_drivers_autoprobe_show, sriov_drivers_autoprobe_store);
> > > +static DEVICE_ATTR(sriov_drivers_autoprobe, 0664, 
> > > sriov_drivers_autoprobe_show,
> > > +sriov_drivers_autoprobe_store);
> > 
> > Greg noticed that sriov_numvfs and sriov_drivers_autoprobe have
> > "unusual" permissions.  These were added by:
> > 
> >0e7df22401a3 ("PCI: Add sysfs sriov_drivers_autoprobe to control VF 
> > driver binding")
> >1789382a72a5 ("PCI: SRIOV control and status via sysfs")
> > 
> > Kelsey's patch correctly preserves the existing permissions, but we
> > should double-check that they are the permissions they want, and
> > possibly add a comment about why they're different from the rest.
> > 
> > Bjorn
> > 

Hi Don,

> The rest being? ... 0644 vs 0664 ?
> The file is read & written, thus the (first) 6; I'll have to dig through very 
> old (7 yr) notes to see if the second 6 is needed for libvirt (so it doesn't 
> have to be root to enable).
> 
> -dd
>

Were you able to see if the unusual permissions (0664) are needed for
libvirt? I appreciate your help!

-Kelsey


[PATCH 2/2] PCI: Unify pci_dev_is_disconnected() and pci_dev_is_inaccessible()

2019-09-03 Thread Kelsey Skunberg
Combine pci_dev_is_disconnected() with pci_dev_is_inaccessible() so only
one function is used to learn if we should avoid accessing a device that's
inaccessible due to surprise removal or an error condition.

The use cases for pci_dev_is_disconnected() do not need to distinguish
between a device being inaccessible due to a surprise removal or an error
condition. This provides the opportunity to unify
pci_dev_is_disconnected() and pci_dev_is_inaccessible() to reduce multiple
functions used for the same task.

Change pci_dev_is_disconnected() call inside pci_dev_is_inaccessible() to:

pdev->error_state == pci_channel_io_perm_failure

Change remaining pci_dev_is_disconnected() calls to
pci_dev_is_inaccessible() calls.

Remove pci_dev_is_disconnected() from /pci/pci.h which would now no longer
be used.

Demonstration of changes to pci_dev_is_disconnected() and
pci_dev_is_inaccessible():

Before combining:

static inline bool pci_dev_is_disconnected(const struct pci_dev *dev)
{
return dev->error_state == pci_channel_io_perm_failure;
}

bool pci_dev_is_inaccessible(struct pci_dev *pdev)
{
u32 v;

if (pci_dev_is_disconnected(pdev))
return true;
return !pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, , 
0);
}

After combining:

bool pci_dev_is_inaccessible(struct pci_dev *pdev)
{
u32 v;

if (pdev->error_state == pci_channel_io_perm_failure)
return true;
return !pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, , 
0);
    }

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/access.c| 12 ++--
 drivers/pci/msi.c   |  4 ++--
 drivers/pci/pci.c   |  2 +-
 drivers/pci/pci.h   |  5 -
 drivers/pci/pcie/portdrv_core.c |  2 +-
 5 files changed, 10 insertions(+), 15 deletions(-)

diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 544922f097c0..c096340afb8c 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -535,7 +535,7 @@ EXPORT_SYMBOL(pcie_capability_clear_and_set_dword);
 
 int pci_read_config_byte(const struct pci_dev *dev, int where, u8 *val)
 {
-   if (pci_dev_is_disconnected(dev)) {
+   if (pci_dev_is_inaccessible(dev)) {
*val = ~0;
return PCIBIOS_DEVICE_NOT_FOUND;
}
@@ -545,7 +545,7 @@ EXPORT_SYMBOL(pci_read_config_byte);
 
 int pci_read_config_word(const struct pci_dev *dev, int where, u16 *val)
 {
-   if (pci_dev_is_disconnected(dev)) {
+   if (pci_dev_is_inaccessible(dev)) {
*val = ~0;
return PCIBIOS_DEVICE_NOT_FOUND;
}
@@ -556,7 +556,7 @@ EXPORT_SYMBOL(pci_read_config_word);
 int pci_read_config_dword(const struct pci_dev *dev, int where,
u32 *val)
 {
-   if (pci_dev_is_disconnected(dev)) {
+   if (pci_dev_is_inaccessible(dev)) {
*val = ~0;
return PCIBIOS_DEVICE_NOT_FOUND;
}
@@ -566,7 +566,7 @@ EXPORT_SYMBOL(pci_read_config_dword);
 
 int pci_write_config_byte(const struct pci_dev *dev, int where, u8 val)
 {
-   if (pci_dev_is_disconnected(dev))
+   if (pci_dev_is_inaccessible(dev))
return PCIBIOS_DEVICE_NOT_FOUND;
return pci_bus_write_config_byte(dev->bus, dev->devfn, where, val);
 }
@@ -574,7 +574,7 @@ EXPORT_SYMBOL(pci_write_config_byte);
 
 int pci_write_config_word(const struct pci_dev *dev, int where, u16 val)
 {
-   if (pci_dev_is_disconnected(dev))
+   if (pci_dev_is_inaccessible(dev))
return PCIBIOS_DEVICE_NOT_FOUND;
return pci_bus_write_config_word(dev->bus, dev->devfn, where, val);
 }
@@ -583,7 +583,7 @@ EXPORT_SYMBOL(pci_write_config_word);
 int pci_write_config_dword(const struct pci_dev *dev, int where,
 u32 val)
 {
-   if (pci_dev_is_disconnected(dev))
+   if (pci_dev_is_inaccessible(dev))
return PCIBIOS_DEVICE_NOT_FOUND;
return pci_bus_write_config_dword(dev->bus, dev->devfn, where, val);
 }
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c
index 0884bedcfc7a..4680043aa315 100644
--- a/drivers/pci/msi.c
+++ b/drivers/pci/msi.c
@@ -311,7 +311,7 @@ void __pci_write_msi_msg(struct msi_desc *entry, struct 
msi_msg *msg)
 {
struct pci_dev *dev = msi_desc_to_pci_dev(entry);
 
-   if (dev->current_state != PCI_D0 || pci_dev_is_disconnected(dev)) {
+   if (dev->current_state != PCI_D0 || pci_dev_is_inaccessible(dev)) {
/* Don't touch the hardware now */
} else if (entry->msi_attrib.is_msix) {
void __iomem *base = pci_msix_desc_addr(entry);
@@ -1008,7 +1008,7 @@ static void pci_msix_shutdown(struct pci_dev *dev)
if (!pci_msi_enable || !d

[PATCH 1/2] PCI: Change pci_device_is_present() to pci_dev_is_inaccessible()

2019-09-03 Thread Kelsey Skunberg
The pci_device_is_present() name may encourage poor practice of calling
pci_device_is_present() and if true, assuming the device is still present
after the call. This type of practice can be racy when assuming a device
is still connected after checking.

Change pci_device_is_present() to pci_dev_is_inaccessible() to promote
only using to learn whether we should avoid accessing a device that's
inaccessible.

Change pci_device_is_inaccessible() to now return true if PCI device is
inaccessible.

Change the boolean values returned from calling pci_dev_is_inaccessible()
to their opposite value to reflect the change of checking if the device is
present to checking if the device is inaccessible. Example:
Before:
if (!pci_device_is_present(tp->pdev))
return -ENODEV;
After:
if (pci_dev_is_inaccessible(tp->pdev))
return -ENODEV;

Signed-off-by: Kelsey Skunberg 
---
 drivers/net/ethernet/broadcom/tg3.c   |  4 ++--
 drivers/net/ethernet/intel/igb/igb_main.c |  2 +-
 drivers/nvme/host/pci.c   |  2 +-
 drivers/pci/hotplug/acpiphp_glue.c|  2 +-
 drivers/pci/pci.c | 10 +-
 drivers/thunderbolt/nhi.c |  2 +-
 include/linux/pci.h   |  2 +-
 7 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c 
b/drivers/net/ethernet/broadcom/tg3.c
index 4c404d2213f9..7646a8303d01 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -9067,7 +9067,7 @@ static int tg3_chip_reset(struct tg3 *tp)
void (*write_op)(struct tg3 *, u32, u32);
int i, err;
 
-   if (!pci_device_is_present(tp->pdev))
+   if (pci_dev_is_inaccessible(tp->pdev))
return -ENODEV;
 
tg3_nvram_lock(tp);
@@ -11782,7 +11782,7 @@ static int tg3_close(struct net_device *dev)
 
tg3_stop(tp);
 
-   if (pci_device_is_present(tp->pdev)) {
+   if (!pci_dev_is_inaccessible(tp->pdev)) {
tg3_power_down_prepare(tp);
 
tg3_carrier_off(tp);
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c 
b/drivers/net/ethernet/intel/igb/igb_main.c
index b4df3e319467..87bc067c2abc 100644
--- a/drivers/net/ethernet/intel/igb/igb_main.c
+++ b/drivers/net/ethernet/intel/igb/igb_main.c
@@ -8835,7 +8835,7 @@ static int __maybe_unused igb_resume(struct device *dev)
pci_restore_state(pdev);
pci_save_state(pdev);
 
-   if (!pci_device_is_present(pdev))
+   if (pci_dev_is_inaccessible(pdev))
return -ENODEV;
err = pci_enable_device_mem(pdev);
if (err) {
diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index bb970ca82517..2a4500325471 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2812,7 +2812,7 @@ static void nvme_remove(struct pci_dev *pdev)
nvme_change_ctrl_state(>ctrl, NVME_CTRL_DELETING);
pci_set_drvdata(pdev, NULL);
 
-   if (!pci_device_is_present(pdev)) {
+   if (pci_dev_is_inaccessible(pdev)) {
nvme_change_ctrl_state(>ctrl, NVME_CTRL_DEAD);
nvme_dev_disable(dev, true);
nvme_dev_remove_admin(dev);
diff --git a/drivers/pci/hotplug/acpiphp_glue.c 
b/drivers/pci/hotplug/acpiphp_glue.c
index e4c46637f32f..9cc2d65877bd 100644
--- a/drivers/pci/hotplug/acpiphp_glue.c
+++ b/drivers/pci/hotplug/acpiphp_glue.c
@@ -647,7 +647,7 @@ static void trim_stale_devices(struct pci_dev *dev)
alive = alive || (ACPI_SUCCESS(status) && 
device_status_valid(sta));
}
if (!alive)
-   alive = pci_device_is_present(dev);
+   alive = !pci_dev_is_inaccessible(dev);
 
if (!alive) {
pci_dev_set_disconnected(dev, NULL);
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 29ed5ec1ac27..7b4e248db5f9 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -931,7 +931,7 @@ static int pci_raw_set_power_state(struct pci_dev *dev, 
pci_power_t state)
 void pci_update_current_state(struct pci_dev *dev, pci_power_t state)
 {
if (platform_pci_get_power_state(dev) == PCI_D3cold ||
-   !pci_device_is_present(dev)) {
+   pci_dev_is_inaccessible(dev)) {
dev->current_state = PCI_D3cold;
} else if (dev->pm_cap) {
u16 pmcsr;
@@ -5906,15 +5906,15 @@ bool pci_devs_are_dma_aliases(struct pci_dev *dev1, 
struct pci_dev *dev2)
test_bit(dev1->devfn, dev2->dma_alias_mask));
 }
 
-bool pci_device_is_present(struct pci_dev *pdev)
+bool pci_dev_is_inaccessible(struct pci_dev *pdev)
 {
u32 v;
 
if (pci_dev_is_disconnected(pdev))
-   return false;
-   return pci_bus_read_dev_vendor_id(pdev->bus, pdev->devfn, , 0);
+   return true;
+   return !pci_bus_read_dev_vendor_id(p

[PATCH 0/2] PCI: Change to using pci_dev_is_inaccessible()

2019-09-03 Thread Kelsey Skunberg
Patch 1: Change pci_device_is_present() name to pci_dev_is_inaccessible()
 to encourage only using to learn if we should not access a
 device that's inaccessible. Return value will need to be reversed
 to reflect the name change.

Patch 2: Relies on patch 1. Unify pci_dev_is_disconnected() with
 pci_dev_is_inaccessible() so there is only one function
 needed to learn if a device is inaccessible due to surprise
 removal or an error condition.

Kelsey Skunberg (2):
  PCI: Change pci_device_is_present() to pci_dev_is_inaccessible()
  PCI: Unify pci_dev_is_disconnected() and pci_dev_is_inaccessible()

 drivers/net/ethernet/broadcom/tg3.c   |  4 ++--
 drivers/net/ethernet/intel/igb/igb_main.c |  2 +-
 drivers/nvme/host/pci.c   |  2 +-
 drivers/pci/access.c  | 12 ++--
 drivers/pci/hotplug/acpiphp_glue.c|  2 +-
 drivers/pci/msi.c |  4 ++--
 drivers/pci/pci.c | 12 ++--
 drivers/pci/pci.h |  5 -
 drivers/pci/pcie/portdrv_core.c   |  2 +-
 drivers/thunderbolt/nhi.c |  2 +-
 include/linux/pci.h   |  2 +-
 11 files changed, 22 insertions(+), 27 deletions(-)

-- 
2.20.1



Re: [PATCH 5.2 000/144] 5.2.9-stable review

2019-08-16 Thread Kelsey Skunberg
On Wed, Aug 14, 2019 at 06:59:16PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.2.9 release.
> There are 144 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 16 Aug 2019 04:55:34 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.9-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-5.2.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled and booted with no dmesg regressions on my system.

Cheers,
Kelsey 
 


Re: [PATCH 4.19 00/91] 4.19.67-stable review

2019-08-16 Thread Kelsey Skunberg
On Wed, Aug 14, 2019 at 07:00:23PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.19.67 release.
> There are 91 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 16 Aug 2019 04:55:34 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.67-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.19.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled and booted with no dmesg regressions on my system.

Cheers,
Kelsey 
 


Re: [PATCH 4.14 00/69] 4.14.139-stable review

2019-08-16 Thread Kelsey Skunberg
On Wed, Aug 14, 2019 at 07:00:58PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.14.139 release.
> There are 69 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 16 Aug 2019 04:55:34 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.139-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.14.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h


Compiled and booted with no dmesg regressions on my system.

Cheers,
Kelsey 


Re: [Linux-kernel-mentees] [PATCH v2 1/3] PCI: sysfs: Define device attributes with DEVICE_ATTR*()

2019-08-15 Thread Kelsey Skunberg
On Wed, Aug 14, 2019 at 09:52:20AM +0200, Greg KH wrote:
> On Tue, Aug 13, 2019 at 02:45:11PM -0600, Kelsey Skunberg wrote:
> > Defining device attributes should be done through the helper
> > DEVICE_ATTR*(_name, _mode, _show, _store). Change all instances using
> > __ATTR*() to now use DEVICE_ATTR*().
> > 
> > Example of old:
> > 
> > struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show,
> >   _store)
> > 
> > Example of new:
> > 
> > static DEVICE_ATTR(foo, S_IWUSR | S_IRUGO, show_foo, store_foo)
> 
> Why not DEVICE_ATTR_RO() and DEVICE_ATTR_RW() and friends?  "Raw"
> DEVICE_ATTR() should almost never be used unless the files have a very
> strange mode setting.  And if that is true, they should be audited to
> find out why their permissions are so strange from the rest of the
> kernel defaults.
>

I updated the commit log to show a more encouraged example and a couple
of the DEVICE_ATTR() into DEVICE_ATTR_WO() in a new patch while adding
that patch to the series.

> > 
> > Signed-off-by: Kelsey Skunberg 
> > ---
> >  drivers/pci/pci-sysfs.c | 59 +++--
> >  1 file changed, 27 insertions(+), 32 deletions(-)
> > 
> > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> > index 965c72104150..8af7944fdccb 100644
> > --- a/drivers/pci/pci-sysfs.c
> > +++ b/drivers/pci/pci-sysfs.c
> > @@ -464,9 +464,7 @@ static ssize_t dev_rescan_store(struct device *dev,
> > }
> > return count;
> >  }
> > -static struct device_attribute dev_rescan_attr = __ATTR(rescan,
> > -   (S_IWUSR|S_IWGRP),
> > -   NULL, dev_rescan_store);
> > +static DEVICE_ATTR(rescan, (S_IWUSR | S_IWGRP), NULL, dev_rescan_store);
> 
> DEVICE_ATTR_WO()?
>

This was changed.

> >  static ssize_t remove_store(struct device *dev, struct device_attribute 
> > *attr,
> > const char *buf, size_t count)
> > @@ -480,9 +478,8 @@ static ssize_t remove_store(struct device *dev, struct 
> > device_attribute *attr,
> > pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
> > return count;
> >  }
> > -static struct device_attribute dev_remove_attr = 
> > __ATTR_IGNORE_LOCKDEP(remove,
> > -   (S_IWUSR|S_IWGRP),
> > -   NULL, remove_store);
> > +static DEVICE_ATTR_IGNORE_LOCKDEP(remove, (S_IWUSR | S_IWGRP), NULL,
> > + remove_store);
> 
> DEVICE_ATTR_WO()?
> 
> Ugh, no lockdep?  ick, ok, leave this as-is, crazy "remove" files...
> 
> >  
> >  static ssize_t dev_bus_rescan_store(struct device *dev,
> > struct device_attribute *attr,
> > @@ -504,7 +501,7 @@ static ssize_t dev_bus_rescan_store(struct device *dev,
> > }
> > return count;
> >  }
> > -static DEVICE_ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_bus_rescan_store);
> > +static DEVICE_ATTR(bus_rescan, (S_IWUSR | S_IWGRP), NULL, 
> > dev_bus_rescan_store);
> 
> DEVICE_ATTR_WO()?
>

As well as this one.

> >  
> >  #if defined(CONFIG_PM) && defined(CONFIG_ACPI)
> >  static ssize_t d3cold_allowed_store(struct device *dev,
> > @@ -687,16 +684,14 @@ static ssize_t sriov_drivers_autoprobe_store(struct 
> > device *dev,
> > return count;
> >  }
> >  
> > -static struct device_attribute sriov_totalvfs_attr = 
> > __ATTR_RO(sriov_totalvfs);
> > -static struct device_attribute sriov_numvfs_attr =
> > -   __ATTR(sriov_numvfs, (S_IRUGO|S_IWUSR|S_IWGRP),
> > -  sriov_numvfs_show, sriov_numvfs_store);
> > -static struct device_attribute sriov_offset_attr = __ATTR_RO(sriov_offset);
> > -static struct device_attribute sriov_stride_attr = __ATTR_RO(sriov_stride);
> > -static struct device_attribute sriov_vf_device_attr = 
> > __ATTR_RO(sriov_vf_device);
> > -static struct device_attribute sriov_drivers_autoprobe_attr =
> > -   __ATTR(sriov_drivers_autoprobe, (S_IRUGO|S_IWUSR|S_IWGRP),
> > -  sriov_drivers_autoprobe_show, 
> > sriov_drivers_autoprobe_store);
> > +static DEVICE_ATTR_RO(sriov_totalvfs);
> > +static DEVICE_ATTR(sriov_numvfs, (S_IRUGO | S_IWUSR | S_IWGRP),
> > + sriov_numvfs_show, sriov_numvfs_store);
> 
> DEVICE_ATTR_RW()?
> 
> > +static DEVICE_ATTR_RO(sriov_offset);

[PATCH v3 4/4] PCI/IOV: Move sysfs SR-IOV functions to iov.c

2019-08-15 Thread Kelsey Skunberg
The sysfs SR-IOV functions are for an optional feature and will be better
organized to keep with the feature's code. Move the sysfs SR-IOV functions
to /pci/iov.c.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/iov.c   | 168 ++
 drivers/pci/pci-sysfs.c | 173 
 drivers/pci/pci.h   |   2 +-
 3 files changed, 169 insertions(+), 174 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 9b48818ced01..b335db21c85e 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -240,6 +240,174 @@ void pci_iov_remove_virtfn(struct pci_dev *dev, int id)
pci_dev_put(dev);
 }
 
+static ssize_t sriov_totalvfs_show(struct device *dev,
+  struct device_attribute *attr,
+  char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev));
+}
+
+static ssize_t sriov_numvfs_show(struct device *dev,
+struct device_attribute *attr,
+char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pdev->sriov->num_VFs);
+}
+
+/*
+ * num_vfs > 0; number of VFs to enable
+ * num_vfs = 0; disable all VFs
+ *
+ * Note: SRIOV spec does not allow partial VF
+ *  disable, so it's all or none.
+ */
+static ssize_t sriov_numvfs_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+   int ret;
+   u16 num_vfs;
+
+   ret = kstrtou16(buf, 0, _vfs);
+   if (ret < 0)
+   return ret;
+
+   if (num_vfs > pci_sriov_get_totalvfs(pdev))
+   return -ERANGE;
+
+   device_lock(>dev);
+
+   if (num_vfs == pdev->sriov->num_VFs)
+   goto exit;
+
+   /* is PF driver loaded w/callback */
+   if (!pdev->driver || !pdev->driver->sriov_configure) {
+   pci_info(pdev, "Driver does not support SRIOV configuration via 
sysfs\n");
+   ret = -ENOENT;
+   goto exit;
+   }
+
+   if (num_vfs == 0) {
+   /* disable VFs */
+   ret = pdev->driver->sriov_configure(pdev, 0);
+   goto exit;
+   }
+
+   /* enable VFs */
+   if (pdev->sriov->num_VFs) {
+   pci_warn(pdev, "%d VFs already enabled. Disable before enabling 
%d VFs\n",
+pdev->sriov->num_VFs, num_vfs);
+   ret = -EBUSY;
+   goto exit;
+   }
+
+   ret = pdev->driver->sriov_configure(pdev, num_vfs);
+   if (ret < 0)
+   goto exit;
+
+   if (ret != num_vfs)
+   pci_warn(pdev, "%d VFs requested; only %d enabled\n",
+num_vfs, ret);
+
+exit:
+   device_unlock(>dev);
+
+   if (ret < 0)
+   return ret;
+
+   return count;
+}
+
+static ssize_t sriov_offset_show(struct device *dev,
+struct device_attribute *attr,
+char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pdev->sriov->offset);
+}
+
+static ssize_t sriov_stride_show(struct device *dev,
+struct device_attribute *attr,
+char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pdev->sriov->stride);
+}
+
+static ssize_t sriov_vf_device_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%x\n", pdev->sriov->vf_device);
+}
+
+static ssize_t sriov_drivers_autoprobe_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pdev->sriov->drivers_autoprobe);
+}
+
+static ssize_t sriov_drivers_autoprobe_store(struct device *dev,
+struct device_attribute *attr,
+const char *buf, size_t count)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+   bool drivers_autoprobe;
+
+   if (kstrtobool(buf, _autoprobe) < 0)
+   return -EINVAL;
+
+   pdev->sriov->drivers_autoprobe = drivers_autoprobe;
+
+   return count;
+}
+
+static DEVICE_ATTR_RO(sriov_totalvfs);
+static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show

[PATCH v3 1/4] PCI: sysfs: Define device attributes with DEVICE_ATTR*

2019-08-15 Thread Kelsey Skunberg
Defining device attributes should be done through the helper
DEVICE_ATTR_RO(), DEVICE_ATTR_WO(), or similar. Change all instances using
__ATTR* to now use its equivalent DEVICE_ATTR*.

Example of old:

static struct device_attribute dev_name_##_attr=__ATTR_RO(_name);

Example of new:

static DEVICE_ATTR_RO(_name);

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci-sysfs.c | 59 +++--
 1 file changed, 27 insertions(+), 32 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 965c72104150..8af7944fdccb 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -464,9 +464,7 @@ static ssize_t dev_rescan_store(struct device *dev,
}
return count;
 }
-static struct device_attribute dev_rescan_attr = __ATTR(rescan,
-   (S_IWUSR|S_IWGRP),
-   NULL, dev_rescan_store);
+static DEVICE_ATTR(rescan, (S_IWUSR | S_IWGRP), NULL, dev_rescan_store);
 
 static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
@@ -480,9 +478,8 @@ static ssize_t remove_store(struct device *dev, struct 
device_attribute *attr,
pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
return count;
 }
-static struct device_attribute dev_remove_attr = __ATTR_IGNORE_LOCKDEP(remove,
-   (S_IWUSR|S_IWGRP),
-   NULL, remove_store);
+static DEVICE_ATTR_IGNORE_LOCKDEP(remove, (S_IWUSR | S_IWGRP), NULL,
+ remove_store);
 
 static ssize_t dev_bus_rescan_store(struct device *dev,
struct device_attribute *attr,
@@ -504,7 +501,7 @@ static ssize_t dev_bus_rescan_store(struct device *dev,
}
return count;
 }
-static DEVICE_ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_bus_rescan_store);
+static DEVICE_ATTR(bus_rescan, (S_IWUSR | S_IWGRP), NULL, 
dev_bus_rescan_store);
 
 #if defined(CONFIG_PM) && defined(CONFIG_ACPI)
 static ssize_t d3cold_allowed_store(struct device *dev,
@@ -687,16 +684,14 @@ static ssize_t sriov_drivers_autoprobe_store(struct 
device *dev,
return count;
 }
 
-static struct device_attribute sriov_totalvfs_attr = __ATTR_RO(sriov_totalvfs);
-static struct device_attribute sriov_numvfs_attr =
-   __ATTR(sriov_numvfs, (S_IRUGO|S_IWUSR|S_IWGRP),
-  sriov_numvfs_show, sriov_numvfs_store);
-static struct device_attribute sriov_offset_attr = __ATTR_RO(sriov_offset);
-static struct device_attribute sriov_stride_attr = __ATTR_RO(sriov_stride);
-static struct device_attribute sriov_vf_device_attr = 
__ATTR_RO(sriov_vf_device);
-static struct device_attribute sriov_drivers_autoprobe_attr =
-   __ATTR(sriov_drivers_autoprobe, (S_IRUGO|S_IWUSR|S_IWGRP),
-  sriov_drivers_autoprobe_show, 
sriov_drivers_autoprobe_store);
+static DEVICE_ATTR_RO(sriov_totalvfs);
+static DEVICE_ATTR(sriov_numvfs, (S_IRUGO | S_IWUSR | S_IWGRP),
+ sriov_numvfs_show, sriov_numvfs_store);
+static DEVICE_ATTR_RO(sriov_offset);
+static DEVICE_ATTR_RO(sriov_stride);
+static DEVICE_ATTR_RO(sriov_vf_device);
+static DEVICE_ATTR(sriov_drivers_autoprobe, (S_IRUGO | S_IWUSR | S_IWGRP),
+  sriov_drivers_autoprobe_show, sriov_drivers_autoprobe_store);
 #endif /* CONFIG_PCI_IOV */
 
 static ssize_t driver_override_store(struct device *dev,
@@ -792,7 +787,7 @@ static struct attribute *pcie_dev_attrs[] = {
 };
 
 static struct attribute *pcibus_attrs[] = {
-   _attr_rescan.attr,
+   _attr_bus_rescan.attr,
_attr_cpuaffinity.attr,
_attr_cpulistaffinity.attr,
NULL,
@@ -820,7 +815,7 @@ static ssize_t boot_vga_show(struct device *dev, struct 
device_attribute *attr,
!!(pdev->resource[PCI_ROM_RESOURCE].flags &
   IORESOURCE_ROM_SHADOW));
 }
-static struct device_attribute vga_attr = __ATTR_RO(boot_vga);
+static DEVICE_ATTR_RO(boot_vga);
 
 static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
   struct bin_attribute *bin_attr, char *buf,
@@ -1458,7 +1453,7 @@ static ssize_t reset_store(struct device *dev, struct 
device_attribute *attr,
return count;
 }
 
-static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, 
reset_store);
+static DEVICE_ATTR(reset, 0200, NULL, reset_store);
 
 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
 {
@@ -1468,7 +1463,7 @@ static int pci_create_capabilities_sysfs(struct pci_dev 
*dev)
pcie_aspm_create_sysfs_dev_files(dev);
 
if (dev->reset_fn) {
-   retval = device_create_file(>dev, _attr);
+   retval = device_create_file(>dev, _attr_reset);
  

[PATCH v3 2/4] PCI: sysfs: Change permissions from symbolic to octal

2019-08-15 Thread Kelsey Skunberg
Symbolic permissions such as "(S_IWUSR | S_IWGRP)" are not
preferred and octal permissions should be used instead. Change all
symbolic permissions to octal permissions.

Example of old:

"(S_IWUSR | S_IWGRP)"

Example of new:

"0220"

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci-sysfs.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 8af7944fdccb..346193ca4826 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -464,7 +464,7 @@ static ssize_t dev_rescan_store(struct device *dev,
}
return count;
 }
-static DEVICE_ATTR(rescan, (S_IWUSR | S_IWGRP), NULL, dev_rescan_store);
+static DEVICE_ATTR(rescan, 0220, NULL, dev_rescan_store);
 
 static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
@@ -478,7 +478,7 @@ static ssize_t remove_store(struct device *dev, struct 
device_attribute *attr,
pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
return count;
 }
-static DEVICE_ATTR_IGNORE_LOCKDEP(remove, (S_IWUSR | S_IWGRP), NULL,
+static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0220, NULL,
  remove_store);
 
 static ssize_t dev_bus_rescan_store(struct device *dev,
@@ -501,7 +501,7 @@ static ssize_t dev_bus_rescan_store(struct device *dev,
}
return count;
 }
-static DEVICE_ATTR(bus_rescan, (S_IWUSR | S_IWGRP), NULL, 
dev_bus_rescan_store);
+static DEVICE_ATTR(bus_rescan, 0220, NULL, dev_bus_rescan_store);
 
 #if defined(CONFIG_PM) && defined(CONFIG_ACPI)
 static ssize_t d3cold_allowed_store(struct device *dev,
@@ -685,13 +685,12 @@ static ssize_t sriov_drivers_autoprobe_store(struct 
device *dev,
 }
 
 static DEVICE_ATTR_RO(sriov_totalvfs);
-static DEVICE_ATTR(sriov_numvfs, (S_IRUGO | S_IWUSR | S_IWGRP),
- sriov_numvfs_show, sriov_numvfs_store);
+static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show, sriov_numvfs_store);
 static DEVICE_ATTR_RO(sriov_offset);
 static DEVICE_ATTR_RO(sriov_stride);
 static DEVICE_ATTR_RO(sriov_vf_device);
-static DEVICE_ATTR(sriov_drivers_autoprobe, (S_IRUGO | S_IWUSR | S_IWGRP),
-  sriov_drivers_autoprobe_show, sriov_drivers_autoprobe_store);
+static DEVICE_ATTR(sriov_drivers_autoprobe, 0664, sriov_drivers_autoprobe_show,
+  sriov_drivers_autoprobe_store);
 #endif /* CONFIG_PCI_IOV */
 
 static ssize_t driver_override_store(struct device *dev,
@@ -1080,7 +1079,7 @@ void pci_create_legacy_files(struct pci_bus *b)
sysfs_bin_attr_init(b->legacy_io);
b->legacy_io->attr.name = "legacy_io";
b->legacy_io->size = 0x;
-   b->legacy_io->attr.mode = S_IRUSR | S_IWUSR;
+   b->legacy_io->attr.mode = 0600;
b->legacy_io->read = pci_read_legacy_io;
b->legacy_io->write = pci_write_legacy_io;
b->legacy_io->mmap = pci_mmap_legacy_io;
@@ -1094,7 +1093,7 @@ void pci_create_legacy_files(struct pci_bus *b)
sysfs_bin_attr_init(b->legacy_mem);
b->legacy_mem->attr.name = "legacy_mem";
b->legacy_mem->size = 1024*1024;
-   b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR;
+   b->legacy_mem->attr.mode = 0600;
b->legacy_mem->mmap = pci_mmap_legacy_mem;
pci_adjust_legacy_attr(b, pci_mmap_mem);
error = device_create_bin_file(>dev, b->legacy_mem);
@@ -1301,7 +1300,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, 
int write_combine)
}
}
res_attr->attr.name = res_attr_name;
-   res_attr->attr.mode = S_IRUSR | S_IWUSR;
+   res_attr->attr.mode = 0600;
res_attr->size = pci_resource_len(pdev, num);
res_attr->private = (void *)(unsigned long)num;
retval = sysfs_create_bin_file(>dev.kobj, res_attr);
@@ -1414,7 +1413,7 @@ static ssize_t pci_read_rom(struct file *filp, struct 
kobject *kobj,
 static const struct bin_attribute pci_config_attr = {
.attr = {
.name = "config",
-   .mode = S_IRUGO | S_IWUSR,
+   .mode = 0644,
},
.size = PCI_CFG_SPACE_SIZE,
.read = pci_read_config,
@@ -1424,7 +1423,7 @@ static const struct bin_attribute pci_config_attr = {
 static const struct bin_attribute pcie_config_attr = {
.attr = {
.name = "config",
-   .mode = S_IRUGO | S_IWUSR,
+   .mode = 0644,
},
.size = PCI_CFG_SPACE_EXP_SIZE,
.read = pci_read_config,
@@ -1506,7 +1505,7 @@ int __must_check pci_create_sysfs_dev_files(struct 
pci_dev *pdev)
sysfs_bin_attr_init(attr);
attr->size = rom_size;
attr->attr.name = 

[PATCH v3 3/4] PCI: sysfs: Change DEVICE_ATTR() to DEVICE_ATTR_WO()

2019-08-15 Thread Kelsey Skunberg
DEVICE_ATTR() should only be used when files have unusual permissions.
Change DEVICE_ATTR() with '0220' permissions to DEVICE_ATTR_WO().

Example of old:

static DEVICE_ATTR(_name, 0220, NULL, _store);

Example of new:

static DEVICE_ATTR_WO(_name);

Since _store is no longer passed, make the _name passed by
DEVICE_ATTR_WO() and the related _name##_store() name match with each
other.

Example:

DEVICE_ATTR_WO(bus_rescan) must be able to call bus_rescan_store()

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci-sysfs.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 346193ca4826..5bb301efec98 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -464,7 +464,7 @@ static ssize_t dev_rescan_store(struct device *dev,
}
return count;
 }
-static DEVICE_ATTR(rescan, 0220, NULL, dev_rescan_store);
+static DEVICE_ATTR_WO(dev_rescan);
 
 static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
@@ -481,9 +481,9 @@ static ssize_t remove_store(struct device *dev, struct 
device_attribute *attr,
 static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0220, NULL,
  remove_store);
 
-static ssize_t dev_bus_rescan_store(struct device *dev,
-   struct device_attribute *attr,
-   const char *buf, size_t count)
+static ssize_t bus_rescan_store(struct device *dev,
+   struct device_attribute *attr,
+   const char *buf, size_t count)
 {
unsigned long val;
struct pci_bus *bus = to_pci_bus(dev);
@@ -501,7 +501,7 @@ static ssize_t dev_bus_rescan_store(struct device *dev,
}
return count;
 }
-static DEVICE_ATTR(bus_rescan, 0220, NULL, dev_bus_rescan_store);
+static DEVICE_ATTR_WO(bus_rescan);
 
 #if defined(CONFIG_PM) && defined(CONFIG_ACPI)
 static ssize_t d3cold_allowed_store(struct device *dev,
@@ -1619,7 +1619,7 @@ static umode_t pci_dev_attrs_are_visible(struct kobject 
*kobj,
 
 static struct attribute *pci_dev_hp_attrs[] = {
_attr_remove.attr,
-   _attr_rescan.attr,
+   _attr_dev_rescan.attr,
NULL,
 };
 
-- 
2.20.1



[PATCH v3 0/4] PCI: Clean up pci-sysfs.c

2019-08-15 Thread Kelsey Skunberg
This series is designed to clean up device attributes and permissions in
pci-sysfs.c. Then move the sysfs SR-IOV functions from pci-sysfs.c to
iov.c for better organization.

Patch 1: Define device attributes with DEVICE_ATTR* instead of __ATTR*.

Patch 2: Change permissions from symbolic to the preferred octal.

Patch 3: Change DEVICE_ATTR() with 0220 permissions to DEVICE_ATTR_WO().

Patch 4: Move sysfs SR-IOV functions to iov.c to keep the feature's code
together.


Patch 1, 2, and 4 will report unusual permissions '0664' used from the
following:

  static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show,
 sriov_numvfs_store);

  static DEVICE_ATTR(sriov_drivers_autoprobe, 0664,
 sriov_drivers_autoprobe_show,
 sriov_drivers_autoprobe_store);

This series preserves the existing permissions set in:


  commit 0e7df22401a3 ("PCI: Add sysfs sriov_drivers_autoprobe to control
VF driver binding")

  commit 1789382a72a5 ("PCI: SRIOV control and status via sysfs")

Either adding a comment verifying permissions are okay or changing the
permissions is to be completed with a new patch.

Changes since v1:
Add patch 1 and 2 to fix the way device attributes are defined
and change permissions from symbolic to octal. Patch 4 which moves
sysfs SR-IOV functions to iov.c will then apply cleaner.

Changes since v2:

Patch 1: Commit log updated. Example shows DEVICE_ATTR_RO()
example instead of DEVICE_ATTR(). DEVICE_ATTR() should be avoided
unless the files have unusual permissions. Changed to reflect a
more encouraged usage.  Also updated regex to be accurate.

Patch 3: [NEW] Add patch to change DEVICE_ATTR() with 0220
permissions to DEVICE_ATTR_WO().

Updated series log to reflect new patch and unusual permissions
    information.


Kelsey Skunberg (4):
  PCI: sysfs: Define device attributes with DEVICE_ATTR*
  PCI: sysfs: Change permissions from symbolic to octal
  PCI: sysfs: Change DEVICE_ATTR() to DEVICE_ATTR_WO()
  PCI/IOV: Move sysfs SR-IOV functions to iov.c

 drivers/pci/iov.c   | 168 ++
 drivers/pci/pci-sysfs.c | 223 
 drivers/pci/pci.h   |   2 +-
 3 files changed, 191 insertions(+), 202 deletions(-)

-- 
2.20.1



Re: [Linux-kernel-mentees] [PATCH v2 1/3] PCI: sysfs: Define device attributes with DEVICE_ATTR*()

2019-08-14 Thread Kelsey Skunberg
On Wed, Aug 14, 2019 at 09:52:20AM +0200, Greg KH wrote:
> On Tue, Aug 13, 2019 at 02:45:11PM -0600, Kelsey Skunberg wrote:
> > Defining device attributes should be done through the helper
> > DEVICE_ATTR*(_name, _mode, _show, _store). Change all instances using
> > __ATTR*() to now use DEVICE_ATTR*().
> > 
> > Example of old:
> > 
> > struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show,
> >   _store)
> > 
> > Example of new:
> > 
> > static DEVICE_ATTR(foo, S_IWUSR | S_IRUGO, show_foo, store_foo)
> 
> Why not DEVICE_ATTR_RO() and DEVICE_ATTR_RW() and friends?  "Raw"
> DEVICE_ATTR() should almost never be used unless the files have a very
> strange mode setting.  And if that is true, they should be audited to
> find out why their permissions are so strange from the rest of the
> kernel defaults.
>

This makes sense. I'll put together a patch to change the DEVICE_ATTR()
applicable to be changed. Thank you, Greg!

-Kelsey

> > 
> > Signed-off-by: Kelsey Skunberg 
> > ---
> >  drivers/pci/pci-sysfs.c | 59 +++--
> >  1 file changed, 27 insertions(+), 32 deletions(-)
> > 
> > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> > index 965c72104150..8af7944fdccb 100644
> > --- a/drivers/pci/pci-sysfs.c
> > +++ b/drivers/pci/pci-sysfs.c
> > @@ -464,9 +464,7 @@ static ssize_t dev_rescan_store(struct device *dev,
> > }
> > return count;
> >  }
> > -static struct device_attribute dev_rescan_attr = __ATTR(rescan,
> > -   (S_IWUSR|S_IWGRP),
> > -   NULL, dev_rescan_store);
> > +static DEVICE_ATTR(rescan, (S_IWUSR | S_IWGRP), NULL, dev_rescan_store);
> 
> DEVICE_ATTR_WO()?
> 
> >  static ssize_t remove_store(struct device *dev, struct device_attribute 
> > *attr,
> > const char *buf, size_t count)
> > @@ -480,9 +478,8 @@ static ssize_t remove_store(struct device *dev, struct 
> > device_attribute *attr,
> > pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
> > return count;
> >  }
> > -static struct device_attribute dev_remove_attr = 
> > __ATTR_IGNORE_LOCKDEP(remove,
> > -   (S_IWUSR|S_IWGRP),
> > -   NULL, remove_store);
> > +static DEVICE_ATTR_IGNORE_LOCKDEP(remove, (S_IWUSR | S_IWGRP), NULL,
> > + remove_store);
> 
> DEVICE_ATTR_WO()?
> 
> Ugh, no lockdep?  ick, ok, leave this as-is, crazy "remove" files...
> 
> >  
> >  static ssize_t dev_bus_rescan_store(struct device *dev,
> > struct device_attribute *attr,
> > @@ -504,7 +501,7 @@ static ssize_t dev_bus_rescan_store(struct device *dev,
> > }
> > return count;
> >  }
> > -static DEVICE_ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_bus_rescan_store);
> > +static DEVICE_ATTR(bus_rescan, (S_IWUSR | S_IWGRP), NULL, 
> > dev_bus_rescan_store);
> 
> DEVICE_ATTR_WO()?
> 
> >  
> >  #if defined(CONFIG_PM) && defined(CONFIG_ACPI)
> >  static ssize_t d3cold_allowed_store(struct device *dev,
> > @@ -687,16 +684,14 @@ static ssize_t sriov_drivers_autoprobe_store(struct 
> > device *dev,
> > return count;
> >  }
> >  
> > -static struct device_attribute sriov_totalvfs_attr = 
> > __ATTR_RO(sriov_totalvfs);
> > -static struct device_attribute sriov_numvfs_attr =
> > -   __ATTR(sriov_numvfs, (S_IRUGO|S_IWUSR|S_IWGRP),
> > -  sriov_numvfs_show, sriov_numvfs_store);
> > -static struct device_attribute sriov_offset_attr = __ATTR_RO(sriov_offset);
> > -static struct device_attribute sriov_stride_attr = __ATTR_RO(sriov_stride);
> > -static struct device_attribute sriov_vf_device_attr = 
> > __ATTR_RO(sriov_vf_device);
> > -static struct device_attribute sriov_drivers_autoprobe_attr =
> > -   __ATTR(sriov_drivers_autoprobe, (S_IRUGO|S_IWUSR|S_IWGRP),
> > -  sriov_drivers_autoprobe_show, 
> > sriov_drivers_autoprobe_store);
> > +static DEVICE_ATTR_RO(sriov_totalvfs);
> > +static DEVICE_ATTR(sriov_numvfs, (S_IRUGO | S_IWUSR | S_IWGRP),
> > + sriov_numvfs_show, sriov_numvfs_store);
> 
> DEVICE_ATTR_RW()?
> 
> > +static DEVICE_ATTR_RO(sriov_offset);
> > +static DEVICE_ATTR_RO(sriov_stride);
> > +static DEVICE_ATTR_

[PATCH v2 3/3] PCI/IOV: Move sysfs SR-IOV functions to iov.c

2019-08-13 Thread Kelsey Skunberg
The sysfs SR-IOV functions are for an optional feature and will be better
organized to keep with the feature's code. Move the sysfs SR-IOV functions
to /pci/iov.c.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/iov.c   | 168 ++
 drivers/pci/pci-sysfs.c | 173 
 drivers/pci/pci.h   |   2 +-
 3 files changed, 169 insertions(+), 174 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 9b48818ced01..b335db21c85e 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -240,6 +240,174 @@ void pci_iov_remove_virtfn(struct pci_dev *dev, int id)
pci_dev_put(dev);
 }
 
+static ssize_t sriov_totalvfs_show(struct device *dev,
+  struct device_attribute *attr,
+  char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev));
+}
+
+static ssize_t sriov_numvfs_show(struct device *dev,
+struct device_attribute *attr,
+char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pdev->sriov->num_VFs);
+}
+
+/*
+ * num_vfs > 0; number of VFs to enable
+ * num_vfs = 0; disable all VFs
+ *
+ * Note: SRIOV spec does not allow partial VF
+ *  disable, so it's all or none.
+ */
+static ssize_t sriov_numvfs_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+   int ret;
+   u16 num_vfs;
+
+   ret = kstrtou16(buf, 0, _vfs);
+   if (ret < 0)
+   return ret;
+
+   if (num_vfs > pci_sriov_get_totalvfs(pdev))
+   return -ERANGE;
+
+   device_lock(>dev);
+
+   if (num_vfs == pdev->sriov->num_VFs)
+   goto exit;
+
+   /* is PF driver loaded w/callback */
+   if (!pdev->driver || !pdev->driver->sriov_configure) {
+   pci_info(pdev, "Driver does not support SRIOV configuration via 
sysfs\n");
+   ret = -ENOENT;
+   goto exit;
+   }
+
+   if (num_vfs == 0) {
+   /* disable VFs */
+   ret = pdev->driver->sriov_configure(pdev, 0);
+   goto exit;
+   }
+
+   /* enable VFs */
+   if (pdev->sriov->num_VFs) {
+   pci_warn(pdev, "%d VFs already enabled. Disable before enabling 
%d VFs\n",
+pdev->sriov->num_VFs, num_vfs);
+   ret = -EBUSY;
+   goto exit;
+   }
+
+   ret = pdev->driver->sriov_configure(pdev, num_vfs);
+   if (ret < 0)
+   goto exit;
+
+   if (ret != num_vfs)
+   pci_warn(pdev, "%d VFs requested; only %d enabled\n",
+num_vfs, ret);
+
+exit:
+   device_unlock(>dev);
+
+   if (ret < 0)
+   return ret;
+
+   return count;
+}
+
+static ssize_t sriov_offset_show(struct device *dev,
+struct device_attribute *attr,
+char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pdev->sriov->offset);
+}
+
+static ssize_t sriov_stride_show(struct device *dev,
+struct device_attribute *attr,
+char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pdev->sriov->stride);
+}
+
+static ssize_t sriov_vf_device_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%x\n", pdev->sriov->vf_device);
+}
+
+static ssize_t sriov_drivers_autoprobe_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pdev->sriov->drivers_autoprobe);
+}
+
+static ssize_t sriov_drivers_autoprobe_store(struct device *dev,
+struct device_attribute *attr,
+const char *buf, size_t count)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+   bool drivers_autoprobe;
+
+   if (kstrtobool(buf, _autoprobe) < 0)
+   return -EINVAL;
+
+   pdev->sriov->drivers_autoprobe = drivers_autoprobe;
+
+   return count;
+}
+
+static DEVICE_ATTR_RO(sriov_totalvfs);
+static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show

[PATCH v2 2/3] PCI: sysfs: Change permissions from symbolic to octal

2019-08-13 Thread Kelsey Skunberg
Symbolic permissions such as "(S_IWUSR | S_IWGRP)" are not
preferred and octal permissions should be used instead. Change all
symbolic permissions to octal permissions.

Example of old:

"(S_IWUSR | S_IWGRP)"

Example of new:

"0220"

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci-sysfs.c | 25 -
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 8af7944fdccb..346193ca4826 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -464,7 +464,7 @@ static ssize_t dev_rescan_store(struct device *dev,
}
return count;
 }
-static DEVICE_ATTR(rescan, (S_IWUSR | S_IWGRP), NULL, dev_rescan_store);
+static DEVICE_ATTR(rescan, 0220, NULL, dev_rescan_store);
 
 static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
@@ -478,7 +478,7 @@ static ssize_t remove_store(struct device *dev, struct 
device_attribute *attr,
pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
return count;
 }
-static DEVICE_ATTR_IGNORE_LOCKDEP(remove, (S_IWUSR | S_IWGRP), NULL,
+static DEVICE_ATTR_IGNORE_LOCKDEP(remove, 0220, NULL,
  remove_store);
 
 static ssize_t dev_bus_rescan_store(struct device *dev,
@@ -501,7 +501,7 @@ static ssize_t dev_bus_rescan_store(struct device *dev,
}
return count;
 }
-static DEVICE_ATTR(bus_rescan, (S_IWUSR | S_IWGRP), NULL, 
dev_bus_rescan_store);
+static DEVICE_ATTR(bus_rescan, 0220, NULL, dev_bus_rescan_store);
 
 #if defined(CONFIG_PM) && defined(CONFIG_ACPI)
 static ssize_t d3cold_allowed_store(struct device *dev,
@@ -685,13 +685,12 @@ static ssize_t sriov_drivers_autoprobe_store(struct 
device *dev,
 }
 
 static DEVICE_ATTR_RO(sriov_totalvfs);
-static DEVICE_ATTR(sriov_numvfs, (S_IRUGO | S_IWUSR | S_IWGRP),
- sriov_numvfs_show, sriov_numvfs_store);
+static DEVICE_ATTR(sriov_numvfs, 0664, sriov_numvfs_show, sriov_numvfs_store);
 static DEVICE_ATTR_RO(sriov_offset);
 static DEVICE_ATTR_RO(sriov_stride);
 static DEVICE_ATTR_RO(sriov_vf_device);
-static DEVICE_ATTR(sriov_drivers_autoprobe, (S_IRUGO | S_IWUSR | S_IWGRP),
-  sriov_drivers_autoprobe_show, sriov_drivers_autoprobe_store);
+static DEVICE_ATTR(sriov_drivers_autoprobe, 0664, sriov_drivers_autoprobe_show,
+  sriov_drivers_autoprobe_store);
 #endif /* CONFIG_PCI_IOV */
 
 static ssize_t driver_override_store(struct device *dev,
@@ -1080,7 +1079,7 @@ void pci_create_legacy_files(struct pci_bus *b)
sysfs_bin_attr_init(b->legacy_io);
b->legacy_io->attr.name = "legacy_io";
b->legacy_io->size = 0x;
-   b->legacy_io->attr.mode = S_IRUSR | S_IWUSR;
+   b->legacy_io->attr.mode = 0600;
b->legacy_io->read = pci_read_legacy_io;
b->legacy_io->write = pci_write_legacy_io;
b->legacy_io->mmap = pci_mmap_legacy_io;
@@ -1094,7 +1093,7 @@ void pci_create_legacy_files(struct pci_bus *b)
sysfs_bin_attr_init(b->legacy_mem);
b->legacy_mem->attr.name = "legacy_mem";
b->legacy_mem->size = 1024*1024;
-   b->legacy_mem->attr.mode = S_IRUSR | S_IWUSR;
+   b->legacy_mem->attr.mode = 0600;
b->legacy_mem->mmap = pci_mmap_legacy_mem;
pci_adjust_legacy_attr(b, pci_mmap_mem);
error = device_create_bin_file(>dev, b->legacy_mem);
@@ -1301,7 +1300,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, 
int write_combine)
}
}
res_attr->attr.name = res_attr_name;
-   res_attr->attr.mode = S_IRUSR | S_IWUSR;
+   res_attr->attr.mode = 0600;
res_attr->size = pci_resource_len(pdev, num);
res_attr->private = (void *)(unsigned long)num;
retval = sysfs_create_bin_file(>dev.kobj, res_attr);
@@ -1414,7 +1413,7 @@ static ssize_t pci_read_rom(struct file *filp, struct 
kobject *kobj,
 static const struct bin_attribute pci_config_attr = {
.attr = {
.name = "config",
-   .mode = S_IRUGO | S_IWUSR,
+   .mode = 0644,
},
.size = PCI_CFG_SPACE_SIZE,
.read = pci_read_config,
@@ -1424,7 +1423,7 @@ static const struct bin_attribute pci_config_attr = {
 static const struct bin_attribute pcie_config_attr = {
.attr = {
.name = "config",
-   .mode = S_IRUGO | S_IWUSR,
+   .mode = 0644,
},
.size = PCI_CFG_SPACE_EXP_SIZE,
.read = pci_read_config,
@@ -1506,7 +1505,7 @@ int __must_check pci_create_sysfs_dev_files(struct 
pci_dev *pdev)
sysfs_bin_attr_init(attr);
attr->size = rom_size;
attr->attr.name = 

[PATCH v2 1/3] PCI: sysfs: Define device attributes with DEVICE_ATTR*()

2019-08-13 Thread Kelsey Skunberg
Defining device attributes should be done through the helper
DEVICE_ATTR*(_name, _mode, _show, _store). Change all instances using
__ATTR*() to now use DEVICE_ATTR*().

Example of old:

struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show,
  _store)

Example of new:

static DEVICE_ATTR(foo, S_IWUSR | S_IRUGO, show_foo, store_foo)

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci-sysfs.c | 59 +++--
 1 file changed, 27 insertions(+), 32 deletions(-)

diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 965c72104150..8af7944fdccb 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -464,9 +464,7 @@ static ssize_t dev_rescan_store(struct device *dev,
}
return count;
 }
-static struct device_attribute dev_rescan_attr = __ATTR(rescan,
-   (S_IWUSR|S_IWGRP),
-   NULL, dev_rescan_store);
+static DEVICE_ATTR(rescan, (S_IWUSR | S_IWGRP), NULL, dev_rescan_store);
 
 static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
@@ -480,9 +478,8 @@ static ssize_t remove_store(struct device *dev, struct 
device_attribute *attr,
pci_stop_and_remove_bus_device_locked(to_pci_dev(dev));
return count;
 }
-static struct device_attribute dev_remove_attr = __ATTR_IGNORE_LOCKDEP(remove,
-   (S_IWUSR|S_IWGRP),
-   NULL, remove_store);
+static DEVICE_ATTR_IGNORE_LOCKDEP(remove, (S_IWUSR | S_IWGRP), NULL,
+ remove_store);
 
 static ssize_t dev_bus_rescan_store(struct device *dev,
struct device_attribute *attr,
@@ -504,7 +501,7 @@ static ssize_t dev_bus_rescan_store(struct device *dev,
}
return count;
 }
-static DEVICE_ATTR(rescan, (S_IWUSR|S_IWGRP), NULL, dev_bus_rescan_store);
+static DEVICE_ATTR(bus_rescan, (S_IWUSR | S_IWGRP), NULL, 
dev_bus_rescan_store);
 
 #if defined(CONFIG_PM) && defined(CONFIG_ACPI)
 static ssize_t d3cold_allowed_store(struct device *dev,
@@ -687,16 +684,14 @@ static ssize_t sriov_drivers_autoprobe_store(struct 
device *dev,
return count;
 }
 
-static struct device_attribute sriov_totalvfs_attr = __ATTR_RO(sriov_totalvfs);
-static struct device_attribute sriov_numvfs_attr =
-   __ATTR(sriov_numvfs, (S_IRUGO|S_IWUSR|S_IWGRP),
-  sriov_numvfs_show, sriov_numvfs_store);
-static struct device_attribute sriov_offset_attr = __ATTR_RO(sriov_offset);
-static struct device_attribute sriov_stride_attr = __ATTR_RO(sriov_stride);
-static struct device_attribute sriov_vf_device_attr = 
__ATTR_RO(sriov_vf_device);
-static struct device_attribute sriov_drivers_autoprobe_attr =
-   __ATTR(sriov_drivers_autoprobe, (S_IRUGO|S_IWUSR|S_IWGRP),
-  sriov_drivers_autoprobe_show, 
sriov_drivers_autoprobe_store);
+static DEVICE_ATTR_RO(sriov_totalvfs);
+static DEVICE_ATTR(sriov_numvfs, (S_IRUGO | S_IWUSR | S_IWGRP),
+ sriov_numvfs_show, sriov_numvfs_store);
+static DEVICE_ATTR_RO(sriov_offset);
+static DEVICE_ATTR_RO(sriov_stride);
+static DEVICE_ATTR_RO(sriov_vf_device);
+static DEVICE_ATTR(sriov_drivers_autoprobe, (S_IRUGO | S_IWUSR | S_IWGRP),
+  sriov_drivers_autoprobe_show, sriov_drivers_autoprobe_store);
 #endif /* CONFIG_PCI_IOV */
 
 static ssize_t driver_override_store(struct device *dev,
@@ -792,7 +787,7 @@ static struct attribute *pcie_dev_attrs[] = {
 };
 
 static struct attribute *pcibus_attrs[] = {
-   _attr_rescan.attr,
+   _attr_bus_rescan.attr,
_attr_cpuaffinity.attr,
_attr_cpulistaffinity.attr,
NULL,
@@ -820,7 +815,7 @@ static ssize_t boot_vga_show(struct device *dev, struct 
device_attribute *attr,
!!(pdev->resource[PCI_ROM_RESOURCE].flags &
   IORESOURCE_ROM_SHADOW));
 }
-static struct device_attribute vga_attr = __ATTR_RO(boot_vga);
+static DEVICE_ATTR_RO(boot_vga);
 
 static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
   struct bin_attribute *bin_attr, char *buf,
@@ -1458,7 +1453,7 @@ static ssize_t reset_store(struct device *dev, struct 
device_attribute *attr,
return count;
 }
 
-static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, 
reset_store);
+static DEVICE_ATTR(reset, 0200, NULL, reset_store);
 
 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
 {
@@ -1468,7 +1463,7 @@ static int pci_create_capabilities_sysfs(struct pci_dev 
*dev)
pcie_aspm_create_sysfs_dev_files(dev);
 
if (dev->reset_fn) {
-   retval = device_create_file(>dev, _attr);
+

[PATCH v2 0/3] PCI: pci-sysfs.c cleanup

2019-08-13 Thread Kelsey Skunberg
This series is designed to clean up device attributes and permissions in
pci-sysfs.c. Then move the sysfs SR-IOV functions from pci-sysfs.c to
iov.c for better organization. Patches build off of each other.

Patch 1: Define device attributes with DEVICE_ATTR*() instead of __ATTR*().

Patch 2: Change permissions from symbolic to the preferred octal.

Patch 3: Move sysfs SR-IOV functions to iov.c to keep the feature's code
together.

Changes since v1:
Add patch 1 and 2 to fix the way device attributes are defined
and change permissions from symbolic to octal. Patch 3 which moves
sysfs SR-IOV functions to iov.c will then apply cleaner.


Kelsey Skunberg (3):
  PCI: sysfs: Define device attributes with DEVICE_ATTR*()
  PCI: sysfs: Change permissions from symbolic to octal
  PCI/IOV: Move sysfs SR-IOV functions to iov.c

 drivers/pci/iov.c   | 168 +++
 drivers/pci/pci-sysfs.c | 217 
 drivers/pci/pci.h   |   2 +-
 3 files changed, 188 insertions(+), 199 deletions(-)

-- 
2.20.1



Re: [Linux-kernel-mentees] [PATCH] PCI/IOV: Move sysfs SR-IOV functions to iov.c

2019-08-10 Thread Kelsey Skunberg
On Sat, Aug 10, 2019 at 07:24:09PM +0200, Greg KH wrote:
> On Sat, Aug 10, 2019 at 12:15:25PM -0500, Bjorn Helgaas wrote:
> > On Sat, Aug 10, 2019 at 09:17:19AM +0200, Greg KH wrote:
> > > On Fri, Aug 09, 2019 at 01:57:21PM -0600, Kelsey Skunberg wrote:
> > > > +static struct device_attribute sriov_totalvfs_attr = 
> > > > __ATTR_RO(sriov_totalvfs);
> > > 
> > > DEVICE_ATTR_RO() please.  This is a device attribute, not a "raw"
> > > kobject attribute.
> > 
> > This patch is just a move; here's the source of the line above:
> > 
> > > > -static struct device_attribute sriov_totalvfs_attr = 
> > > > __ATTR_RO(sriov_totalvfs);
> > 
> > I certainly support using DEVICE_ATTR_RO() instead of __ATTR_RO(), but
> > that should be down with a separate patch so it's not buried in what
> > is otherwise a simple move.
> > 
> > > > +static struct device_attribute sriov_numvfs_attr =
> > > > +   __ATTR(sriov_numvfs, (S_IRUGO | S_IWUSR | S_IWGRP),
> > > > +  sriov_numvfs_show, sriov_numvfs_store);
> > > > +static struct device_attribute sriov_offset_attr = 
> > > > __ATTR_RO(sriov_offset);
> > > > +static struct device_attribute sriov_stride_attr = 
> > > > __ATTR_RO(sriov_stride);
> > > > +static struct device_attribute sriov_vf_device_attr =
> > > > +   __ATTR_RO(sriov_vf_device);
> > > > +static struct device_attribute sriov_drivers_autoprobe_attr =
> > > > +   __ATTR(sriov_drivers_autoprobe, (S_IRUGO | S_IWUSR | 
> > > > S_IWGRP),
> > > > +  sriov_drivers_autoprobe_show,
> > > > +  sriov_drivers_autoprobe_store);
> > > 
> > > Same for all of these, they should use DEVICE_ATTR* macros.
> > > 
> > > And why the odd permissions on 2 of these files?  Are you sure about
> > > that?
> > 
> > Same for these.  It'd be nice to fix them (and similar cases in
> > pci-sysfs.c, rpadlpar_sysfs.c, sgi_hotplug.c, slot.c) but in a
> > separate patch.
> > 
> > I think Kelsey did the right thing here by not mixing unrelated fixes
> > in with the code move.  A couple additional patches to change the
> > __ATTR() uses and the permissions (git grep "\ > possibilities) would be icing on the cake, but getting the SR-IOV
> > code all together is an improvement by itself.
> 
> Ah, ok, that makes more sense.  As long as this is patch 1/X, I'm fine
> with it :)
> 
> thanks,
> 
> greg k-h

I'll set up a series to cover these changes and submit it as a v2. Thank
you for reviewing Greg and Bjorn!

Cheers,
Kelsey


[PATCH] PCI/IOV: Move sysfs SR-IOV functions to iov.c

2019-08-09 Thread Kelsey Skunberg
The sysfs SR-IOV functions are for an optional feature and will be better
organized to keep with the feature's code. Move the sysfs SR-IOV functions
to /pci/iov.c.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/iov.c   | 173 +++
 drivers/pci/pci-sysfs.c | 176 
 drivers/pci/pci.h   |   2 +-
 3 files changed, 174 insertions(+), 177 deletions(-)

diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c
index 9b48818ced01..661051adf23f 100644
--- a/drivers/pci/iov.c
+++ b/drivers/pci/iov.c
@@ -240,6 +240,179 @@ void pci_iov_remove_virtfn(struct pci_dev *dev, int id)
pci_dev_put(dev);
 }
 
+static ssize_t sriov_totalvfs_show(struct device *dev,
+  struct device_attribute *attr,
+  char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pci_sriov_get_totalvfs(pdev));
+}
+
+static ssize_t sriov_numvfs_show(struct device *dev,
+struct device_attribute *attr,
+char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pdev->sriov->num_VFs);
+}
+
+/*
+ * num_vfs > 0; number of VFs to enable
+ * num_vfs = 0; disable all VFs
+ *
+ * Note: SRIOV spec does not allow partial VF
+ *   disable, so it's all or none.
+ */
+static ssize_t sriov_numvfs_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+   int ret;
+   u16 num_vfs;
+
+   ret = kstrtou16(buf, 0, _vfs);
+   if (ret < 0)
+   return ret;
+
+   if (num_vfs > pci_sriov_get_totalvfs(pdev))
+   return -ERANGE;
+
+   device_lock(>dev);
+
+   if (num_vfs == pdev->sriov->num_VFs)
+   goto exit;
+
+   /* is PF driver loaded w/callback */
+   if (!pdev->driver || !pdev->driver->sriov_configure) {
+   pci_info(pdev, "Driver does not support SRIOV configuration via 
sysfs\n");
+   ret = -ENOENT;
+   goto exit;
+   }
+
+   if (num_vfs == 0) {
+   /* disable VFs */
+   ret = pdev->driver->sriov_configure(pdev, 0);
+   goto exit;
+   }
+
+   /* enable VFs */
+   if (pdev->sriov->num_VFs) {
+   pci_warn(pdev, "%d VFs already enabled. Disable before enabling 
%d VFs\n",
+pdev->sriov->num_VFs, num_vfs);
+   ret = -EBUSY;
+   goto exit;
+   }
+
+   ret = pdev->driver->sriov_configure(pdev, num_vfs);
+   if (ret < 0)
+   goto exit;
+
+   if (ret != num_vfs)
+   pci_warn(pdev, "%d VFs requested; only %d enabled\n",
+num_vfs, ret);
+
+exit:
+   device_unlock(>dev);
+
+   if (ret < 0)
+   return ret;
+
+   return count;
+}
+
+static ssize_t sriov_offset_show(struct device *dev,
+struct device_attribute *attr,
+char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pdev->sriov->offset);
+}
+
+static ssize_t sriov_stride_show(struct device *dev,
+struct device_attribute *attr,
+char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pdev->sriov->stride);
+}
+
+static ssize_t sriov_vf_device_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%x\n", pdev->sriov->vf_device);
+}
+
+static ssize_t sriov_drivers_autoprobe_show(struct device *dev,
+   struct device_attribute *attr,
+   char *buf)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+
+   return sprintf(buf, "%u\n", pdev->sriov->drivers_autoprobe);
+}
+
+static ssize_t sriov_drivers_autoprobe_store(struct device *dev,
+struct device_attribute *attr,
+const char *buf, size_t count)
+{
+   struct pci_dev *pdev = to_pci_dev(dev);
+   bool drivers_autoprobe;
+
+   if (kstrtobool(buf, _autoprobe) < 0)
+   return -EINVAL;
+
+   pdev->sriov->drivers_autoprobe = drivers_autoprobe;
+
+   return count;
+}
+
+static struct device_attribute sriov_totalvfs_attr = __ATTR_RO(sriov_totalvfs);
+static struct device_att

Re: [PATCH 4.14 000/293] 4.14.135-stable review

2019-07-30 Thread Kelsey Skunberg
On Mon, Jul 29, 2019 at 09:18:11PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.14.135 release.
> There are 293 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Wed 31 Jul 2019 07:05:01 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.135-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.14.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled and booted with no regressions on my system.

Cheers,
Kelsey 


Re: [PATCH 4.19 000/113] 4.19.63-stable review

2019-07-30 Thread Kelsey Skunberg
On Mon, Jul 29, 2019 at 09:21:27PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.19.63 release.
> There are 113 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Wed 31 Jul 2019 07:05:01 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.63-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.19.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled and booted with no regressions on my system.

Cheers,
Kelsey 


Re: [PATCH 5.2 000/215] 5.2.5-stable review

2019-07-30 Thread Kelsey Skunberg
On Mon, Jul 29, 2019 at 09:19:56PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.2.5 release.
> There are 215 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Wed 31 Jul 2019 07:05:01 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.5-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-5.2.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled and booted with no regressions on my system.

Cheers,
Kelsey


Re: [PATCH 4.19 000/271] 4.19.61-stable review

2019-07-26 Thread Kelsey Skunberg
On Wed, Jul 24, 2019 at 09:17:49PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.19.61 release.
> There are 271 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 26 Jul 2019 07:13:35 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.61-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.19.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled and booted with no regressions on my system.

Cheers,
Kelsey
 


Re: [PATCH 5.1 000/371] 5.1.20-stable review

2019-07-26 Thread Kelsey Skunberg
On Wed, Jul 24, 2019 at 09:15:52PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.1.20 release.
> There are 371 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 26 Jul 2019 07:13:35 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.1.20-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-5.1.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled and booted with no regressions on my system.

Cheers,
Kelsey
 


Re: [PATCH 5.2 000/413] 5.2.3-stable review

2019-07-26 Thread Kelsey Skunberg
On Wed, Jul 24, 2019 at 09:14:51PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.2.3 release.
> There are 413 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 26 Jul 2019 07:13:35 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.3-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-5.2.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled and booted with no regressions on my system.

Cheers,
Kelsey


[PATCH v2 07/11] PCI: Move pcie_update_link_speed() to drivers/pci/pci.h

2019-07-24 Thread Kelsey Skunberg
pcie_update_line_speed() is only called within drivers/pci/. Since
declaration does not need to be visible to the rest of the kernel, move to
drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 1 +
 include/linux/pci.h | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 3e9dfca4b661..feec29853a44 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -299,6 +299,7 @@ u32 pcie_bandwidth_capable(struct pci_dev *dev, enum 
pci_bus_speed *speed,
   enum pcie_link_width *width);
 void __pcie_print_link_status(struct pci_dev *dev, bool verbose);
 void pcie_report_downtraining(struct pci_dev *dev);
+void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
 
 /* Single Root I/O Virtualization */
 struct pci_sriov {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index af59ecf8ccff..c6a25c32a49a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -987,7 +987,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, 
int bus,
 int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
int busnr);
-void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
 struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
 const char *name,
 struct hotplug_slot *hotplug);
-- 
2.20.1



[PATCH v2 09/11] PCI: Move ECRC declarations to drivers/pci/pci.h

2019-07-24 Thread Kelsey Skunberg
pcie_set_ecrc_checking() and pcie_ecrc_get_policy() are only called within
drivers/pci/. Since declarations do not need to be visible to the rest of
the kernel, move to drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 8 
 include/linux/pci.h | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 7c0488b64faf..5e5ce04bda59 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -541,6 +541,14 @@ static inline void pcie_aspm_create_sysfs_dev_files(struct 
pci_dev *pdev) { }
 static inline void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev) { }
 #endif
 
+#ifdef CONFIG_PCIE_ECRC
+void pcie_set_ecrc_checking(struct pci_dev *dev);
+void pcie_ecrc_get_policy(char *str);
+#else
+static inline void pcie_set_ecrc_checking(struct pci_dev *dev) { }
+static inline void pcie_ecrc_get_policy(char *str) { }
+#endif
+
 #ifdef CONFIG_PCIE_PTM
 void pci_ptm_init(struct pci_dev *dev);
 #else
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5760e19cb625..5dd4abeef8b0 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1559,14 +1559,6 @@ bool pci_aer_available(void);
 static inline bool pci_aer_available(void) { return false; }
 #endif
 
-#ifdef CONFIG_PCIE_ECRC
-void pcie_set_ecrc_checking(struct pci_dev *dev);
-void pcie_ecrc_get_policy(char *str);
-#else
-static inline void pcie_set_ecrc_checking(struct pci_dev *dev) { }
-static inline void pcie_ecrc_get_policy(char *str) { }
-#endif
-
 bool pci_ats_disabled(void);
 
 #ifdef CONFIG_PCIE_PTM
-- 
2.20.1



[PATCH v2 03/11] PCI: Move *_host_bridge_device() declarations to drivers/pci.pci.h

2019-07-24 Thread Kelsey Skunberg
pci_get_host_bridge_device() and pci_put_host_bridge_device() are only
called within drivers/pci/pci.h. Since declarations do not need to be
visible to the rest of the kernel, move to drives/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 3 +++
 include/linux/pci.h | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index ad1fe54ab8ee..f41dde136648 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -105,6 +105,9 @@ void pci_free_cap_save_buffers(struct pci_dev *dev);
 bool pci_bridge_d3_possible(struct pci_dev *dev);
 void pci_bridge_d3_update(struct pci_dev *dev);
 
+struct device *pci_get_host_bridge_device(struct pci_dev *dev);
+void pci_put_host_bridge_device(struct device *dev);
+
 static inline void pci_wakeup_event(struct pci_dev *dev)
 {
/* Wait 100 ms before the system can be put into a sleep state. */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index e1f784de459f..cd49427e198e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -644,9 +644,6 @@ static inline struct pci_dev *pci_upstream_bridge(struct 
pci_dev *dev)
return dev->bus->self;
 }
 
-struct device *pci_get_host_bridge_device(struct pci_dev *dev);
-void pci_put_host_bridge_device(struct device *dev);
-
 #ifdef CONFIG_PCI_MSI
 static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev)
 {
-- 
2.20.1



[PATCH v2 01/11] PCI: Move #define PCI_PM_* lines to drivers/pci/pci.h

2019-07-24 Thread Kelsey Skunberg
The #define PCI_PM_* lines are only used within drivers/pci/ and they do
not need to be seen by the rest of the kernel. Move #define PCI_* to
drivers/pci/pci.h

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 5 +
 include/linux/pci.h | 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 1be03a97cb92..708413632429 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -39,6 +39,11 @@ int pci_probe_reset_function(struct pci_dev *dev);
 int pci_bridge_secondary_bus_reset(struct pci_dev *dev);
 int pci_bus_error_reset(struct pci_dev *dev);
 
+#define PCI_PM_D2_DELAY 200
+#define PCI_PM_D3_WAIT  10
+#define PCI_PM_D3COLD_WAIT  100
+#define PCI_PM_BUS_WAIT 50
+
 /**
  * struct pci_platform_pm_ops - Firmware PM callbacks
  *
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9e700d9f9f28..238449460210 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -145,11 +145,6 @@ static inline const char *pci_power_name(pci_power_t state)
return pci_power_names[1 + (__force int) state];
 }
 
-#define PCI_PM_D2_DELAY200
-#define PCI_PM_D3_WAIT 10
-#define PCI_PM_D3COLD_WAIT 100
-#define PCI_PM_BUS_WAIT50
-
 /**
  * typedef pci_channel_state_t
  *
-- 
2.20.1



[PATCH v2 00/11] Hide PCI symbols that don't need to be global

2019-07-24 Thread Kelsey Skunberg
The include/linux/pci.h header file defines several symbols that are used
only in drivers/pci/. These symbols do not need to be visible to the rest
of the kernel. Move PCI symbols that are only used in drivers/pci/ to
drivers/pci/pci.h.

Changes in v2:
- Built patches to work with v5.3-rc1
- Changed line lengths on commit logs to stay below 80 characters
- Changed cover-letter log to better explain patch series


Kelsey Skunberg (11):
  PCI: Move #define PCI_PM_* lines to drivers/pci/pci.h
  PCI: Move PME declarations to drivers/pci/pci.h
  PCI: Move *_host_bridge_device() declarations to drivers/pci.pci.h
  PCI: Move PCI Virtual Channel declarations to drivers/pci/pci.h
  PCI: Move pci_hotplug_*_size declarations to drivers/pci/pci.h
  PCI: Move pci_bus_* declarations to drivers/pci/pci.h
  PCI: Move pcie_update_link_speed() to drivers/pci/pci.h
  PCI: Move pci_ats_init() to drivers/pci/pci.h
  PCI: Move ECRC declarations to drivers/pci/pci.h
  PCI: Move PTM declaration to drivers/pci/pci.h
  PCI: Move pci_*_node() declarations to drivers/pci/pci.h

 drivers/pci/pci.h   | 48 ++---
 include/linux/pci.h | 47 
 2 files changed, 45 insertions(+), 50 deletions(-)

-- 
2.20.1



[PATCH v2 06/11] PCI: Move pci_bus_* declarations to drivers/pci/pci.h

2019-07-24 Thread Kelsey Skunberg
pci_bus_* declarations are only called within drivers/pci/. Since
declarations do not need to be visible to the rest of the kernel, move to
drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 2 ++
 include/linux/pci.h | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 9391330805e9..3e9dfca4b661 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -274,6 +274,8 @@ bool pci_bus_clip_resource(struct pci_dev *dev, int idx);
 
 void pci_reassigndev_resource_alignment(struct pci_dev *dev);
 void pci_disable_bridge_window(struct pci_dev *dev);
+struct pci_bus *pci_bus_get(struct pci_bus *bus);
+void pci_bus_put(struct pci_bus *bus);
 
 /* PCIe link information */
 #define PCIE_SPEED2STR(speed) \
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 9c9554906659..af59ecf8ccff 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1282,8 +1282,6 @@ int pci_request_selected_regions_exclusive(struct pci_dev 
*, int, const char *);
 void pci_release_selected_regions(struct pci_dev *, int);
 
 /* drivers/pci/bus.c */
-struct pci_bus *pci_bus_get(struct pci_bus *bus);
-void pci_bus_put(struct pci_bus *bus);
 void pci_add_resource(struct list_head *resources, struct resource *res);
 void pci_add_resource_offset(struct list_head *resources, struct resource *res,
 resource_size_t offset);
-- 
2.20.1



[PATCH v2 10/11] PCI: Move PTM declaration to drivers/pci/pci.h

2019-07-24 Thread Kelsey Skunberg
pci_enable_ptm() is only called within drivers/pci/. Since declaration
does not need to be visible to the rest of the kernel, move to
drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 3 +++
 include/linux/pci.h | 7 ---
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 5e5ce04bda59..6cdc3500de15 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -551,8 +551,11 @@ static inline void pcie_ecrc_get_policy(char *str) { }
 
 #ifdef CONFIG_PCIE_PTM
 void pci_ptm_init(struct pci_dev *dev);
+int pci_enable_ptm(struct pci_dev *dev, u8 *granularity);
 #else
 static inline void pci_ptm_init(struct pci_dev *dev) { }
+static inline int pci_enable_ptm(struct pci_dev *dev, u8 *granularity)
+{ return -EINVAL; }
 #endif
 
 struct pci_dev_reset_methods {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 5dd4abeef8b0..a483b7598059 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1561,13 +1561,6 @@ static inline bool pci_aer_available(void) { return 
false; }
 
 bool pci_ats_disabled(void);
 
-#ifdef CONFIG_PCIE_PTM
-int pci_enable_ptm(struct pci_dev *dev, u8 *granularity);
-#else
-static inline int pci_enable_ptm(struct pci_dev *dev, u8 *granularity)
-{ return -EINVAL; }
-#endif
-
 void pci_cfg_access_lock(struct pci_dev *dev);
 bool pci_cfg_access_trylock(struct pci_dev *dev);
 void pci_cfg_access_unlock(struct pci_dev *dev);
-- 
2.20.1



[PATCH v2 08/11] PCI: Move pci_ats_init() to drivers/pci/pci.h

2019-07-24 Thread Kelsey Skunberg
pci_ats_init() is only called with drivers/pci/. Since declarations do not
need to be visible to the rest of the kernel, move to drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 7 ---
 include/linux/pci.h | 2 --
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index feec29853a44..7c0488b64faf 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -439,11 +439,12 @@ static inline void pci_restore_dpc_state(struct pci_dev 
*dev) {}
 #endif
 
 #ifdef CONFIG_PCI_ATS
+/* Address Translation Service */
+void pci_ats_init(struct pci_dev *dev);
 void pci_restore_ats_state(struct pci_dev *dev);
 #else
-static inline void pci_restore_ats_state(struct pci_dev *dev)
-{
-}
+static inline void pci_ats_init(struct pci_dev *d) { }
+static inline void pci_restore_ats_state(struct pci_dev *dev) { }
 #endif /* CONFIG_PCI_ATS */
 
 #ifdef CONFIG_PCI_IOV
diff --git a/include/linux/pci.h b/include/linux/pci.h
index c6a25c32a49a..5760e19cb625 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1766,13 +1766,11 @@ static inline bool pci_ats_disabled(void) { return 
true; }
 
 #ifdef CONFIG_PCI_ATS
 /* Address Translation Service */
-void pci_ats_init(struct pci_dev *dev);
 int pci_enable_ats(struct pci_dev *dev, int ps);
 void pci_disable_ats(struct pci_dev *dev);
 int pci_ats_queue_depth(struct pci_dev *dev);
 int pci_ats_page_aligned(struct pci_dev *dev);
 #else
-static inline void pci_ats_init(struct pci_dev *d) { }
 static inline int pci_enable_ats(struct pci_dev *d, int ps) { return -ENODEV; }
 static inline void pci_disable_ats(struct pci_dev *d) { }
 static inline int pci_ats_queue_depth(struct pci_dev *d) { return -ENODEV; }
-- 
2.20.1



[PATCH v2 05/11] PCI: Move pci_hotplug_*_size declarations to drivers/pci/pci.h

2019-07-24 Thread Kelsey Skunberg
pci_hotplug_*_size declarations are only called within drivers/pci/pci/.
Since declarations do not need to be seen by the rest of the kernel, move
to drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 3 +++
 include/linux/pci.h | 4 
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 0eb0fb7ad353..9391330805e9 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -211,6 +211,9 @@ extern const struct attribute_group *pcibus_groups[];
 extern const struct device_type pci_dev_type;
 extern const struct attribute_group *pci_bus_groups[];
 
+extern unsigned long pci_hotplug_io_size;
+extern unsigned long pci_hotplug_mem_size;
+extern unsigned long pci_hotplug_bus_size;
 
 /**
  * pci_match_one_device - Tell if a PCI device structure has a matching
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d1944e3e7eb2..9c9554906659 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2015,10 +2015,6 @@ extern unsigned long pci_cardbus_mem_size;
 extern u8 pci_dfl_cache_line_size;
 extern u8 pci_cache_line_size;
 
-extern unsigned long pci_hotplug_io_size;
-extern unsigned long pci_hotplug_mem_size;
-extern unsigned long pci_hotplug_bus_size;
-
 /* Architecture-specific versions may override these (weak) */
 void pcibios_disable_device(struct pci_dev *dev);
 void pcibios_set_master(struct pci_dev *dev);
-- 
2.20.1



[PATCH v2 02/11] PCI: Move PME declarations to drivers/pci/pci.h

2019-07-24 Thread Kelsey Skunberg
pci_check_pme_status() and pci_pme_wakeup_bus() are only
called within drivers/pci/. Since declarations do not need to be visible
to the rest of the kernel, move to drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 2 ++
 include/linux/pci.h | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 708413632429..ad1fe54ab8ee 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -89,6 +89,8 @@ void pci_power_up(struct pci_dev *dev);
 void pci_disable_enabled_device(struct pci_dev *dev);
 int pci_finish_runtime_suspend(struct pci_dev *dev);
 void pcie_clear_root_pme_status(struct pci_dev *dev);
+bool pci_check_pme_status(struct pci_dev *dev);
+void pci_pme_wakeup_bus(struct pci_bus *bus);
 int __pci_pme_wakeup(struct pci_dev *dev, void *ign);
 void pci_pme_restore(struct pci_dev *dev);
 bool pci_dev_need_resume(struct pci_dev *dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 238449460210..e1f784de459f 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1236,8 +1236,6 @@ int pci_wake_from_d3(struct pci_dev *dev, bool enable);
 int pci_prepare_to_sleep(struct pci_dev *dev);
 int pci_back_from_sleep(struct pci_dev *dev);
 bool pci_dev_run_wake(struct pci_dev *dev);
-bool pci_check_pme_status(struct pci_dev *dev);
-void pci_pme_wakeup_bus(struct pci_bus *bus);
 void pci_d3cold_enable(struct pci_dev *dev);
 void pci_d3cold_disable(struct pci_dev *dev);
 bool pcie_relaxed_ordering_enabled(struct pci_dev *dev);
-- 
2.20.1



[PATCH v2 04/11] PCI: Move PCI Virtual Channel declarations to drivers/pci/pci.h

2019-07-24 Thread Kelsey Skunberg
PCI Virtual Channel declarations are only called within drivers/pci/.
Since declarations do not need to be visible to the rest of the kernel,
move to drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 5 +
 include/linux/pci.h | 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index f41dde136648..0eb0fb7ad353 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -133,6 +133,11 @@ void pci_vpd_release(struct pci_dev *dev);
 void pcie_vpd_create_sysfs_dev_files(struct pci_dev *dev);
 void pcie_vpd_remove_sysfs_dev_files(struct pci_dev *dev);
 
+/* PCI Virtual Channel */
+int pci_save_vc_state(struct pci_dev *dev);
+void pci_restore_vc_state(struct pci_dev *dev);
+void pci_allocate_vc_save_buffers(struct pci_dev *dev);
+
 /* PCI /proc functions */
 #ifdef CONFIG_PROC_FS
 int pci_proc_attach_device(struct pci_dev *dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index cd49427e198e..d1944e3e7eb2 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1239,11 +1239,6 @@ bool pcie_relaxed_ordering_enabled(struct pci_dev *dev);
 void pci_wakeup_bus(struct pci_bus *bus);
 void pci_bus_set_current_state(struct pci_bus *bus, pci_power_t state);
 
-/* PCI Virtual Channel */
-int pci_save_vc_state(struct pci_dev *dev);
-void pci_restore_vc_state(struct pci_dev *dev);
-void pci_allocate_vc_save_buffers(struct pci_dev *dev);
-
 /* For use by arch with custom probe code */
 void set_pcie_port_type(struct pci_dev *pdev);
 void set_pcie_hotplug_bridge(struct pci_dev *pdev);
-- 
2.20.1



[PATCH v2 11/11] PCI: Move pci_*_node() declarations to drivers/pci/pci.h

2019-07-24 Thread Kelsey Skunberg
pci_*_node() is only called from drivers/pci/. Since these declarations do
not need to be visible to the rest of the kernel, move to
drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 9 +
 include/linux/pci.h | 8 
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 6cdc3500de15..27089a87dfea 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -592,6 +592,10 @@ struct device_node;
 int of_pci_parse_bus_range(struct device_node *node, struct resource *res);
 int of_get_pci_domain_nr(struct device_node *node);
 int of_pci_get_max_link_speed(struct device_node *node);
+void pci_set_of_node(struct pci_dev *dev);
+void pci_release_of_node(struct pci_dev *dev);
+void pci_set_bus_of_node(struct pci_bus *bus);
+void pci_release_bus_of_node(struct pci_bus *bus);
 
 #else
 static inline int
@@ -611,6 +615,11 @@ of_pci_get_max_link_speed(struct device_node *node)
 {
return -EINVAL;
 }
+
+static inline void pci_set_of_node(struct pci_dev *dev) { }
+static inline void pci_release_of_node(struct pci_dev *dev) { }
+static inline void pci_set_bus_of_node(struct pci_bus *bus) { }
+static inline void pci_release_bus_of_node(struct pci_bus *bus) { }
 #endif /* CONFIG_OF */
 
 #if defined(CONFIG_OF_ADDRESS)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index a483b7598059..d354fbcee5a7 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2264,10 +2264,6 @@ int pci_vpd_find_info_keyword(const u8 *buf, unsigned 
int off,
 #ifdef CONFIG_OF
 struct device_node;
 struct irq_domain;
-void pci_set_of_node(struct pci_dev *dev);
-void pci_release_of_node(struct pci_dev *dev);
-void pci_set_bus_of_node(struct pci_bus *bus);
-void pci_release_bus_of_node(struct pci_bus *bus);
 struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus);
 int pci_parse_request_of_pci_ranges(struct device *dev,
struct list_head *resources,
@@ -2277,10 +2273,6 @@ int pci_parse_request_of_pci_ranges(struct device *dev,
 struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus);
 
 #else  /* CONFIG_OF */
-static inline void pci_set_of_node(struct pci_dev *dev) { }
-static inline void pci_release_of_node(struct pci_dev *dev) { }
-static inline void pci_set_bus_of_node(struct pci_bus *bus) { }
-static inline void pci_release_bus_of_node(struct pci_bus *bus) { }
 static inline struct irq_domain *
 pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; }
 static inline int pci_parse_request_of_pci_ranges(struct device *dev,
-- 
2.20.1



[PATCH v3] drivers: net: xgene: Remove acpi_has_method() calls

2019-07-24 Thread Kelsey Skunberg
acpi_evaluate_object will already return an error if the needed method
does not exist. Remove unnecessary acpi_has_method() calls and check the
returned acpi_status for failure instead.

Signed-off-by: Kelsey Skunberg 
---
Changes in v2:
- Fixed white space warnings and errors

Changes in v3:
- Resolved build errors caused by missing bracket

 drivers/net/ethernet/apm/xgene/xgene_enet_hw.c| 9 -
 drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c | 9 +
 drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c | 9 -
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 61a465097cb8..79924efd4ab7 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -694,6 +694,7 @@ bool xgene_ring_mgr_init(struct xgene_enet_pdata *p)
 static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
 {
struct device *dev = >pdev->dev;
+   acpi_status status;
 
if (!xgene_ring_mgr_init(pdata))
return -ENODEV;
@@ -712,11 +713,9 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
udelay(5);
} else {
 #ifdef CONFIG_ACPI
-   if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_RST")) {
-   acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
-"_RST", NULL, NULL);
-   } else if (acpi_has_method(ACPI_HANDLE(>pdev->dev),
-"_INI")) {
+   status = acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
+ "_RST", NULL, NULL);
+   if (ACPI_FAILURE(status)) {
acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
 "_INI", NULL, NULL);
}
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
index 6453fc2ebb1f..3b3dc5b25b29 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
@@ -437,6 +437,7 @@ static void xgene_sgmac_tx_disable(struct xgene_enet_pdata 
*p)
 static int xgene_enet_reset(struct xgene_enet_pdata *p)
 {
struct device *dev = >pdev->dev;
+   acpi_status status;
 
if (!xgene_ring_mgr_init(p))
return -ENODEV;
@@ -460,12 +461,12 @@ static int xgene_enet_reset(struct xgene_enet_pdata *p)
}
} else {
 #ifdef CONFIG_ACPI
-   if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_RST"))
-   acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
-"_RST", NULL, NULL);
-   else if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_INI"))
+   status = acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
+ "_RST", NULL, NULL);
+   if (ACPI_FAILURE(status)) {
acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
 "_INI", NULL, NULL);
+   }
 #endif
}
 
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
index 133eb91c542e..78584089d76d 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
@@ -380,6 +380,7 @@ static void xgene_xgmac_tx_disable(struct xgene_enet_pdata 
*pdata)
 static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
 {
struct device *dev = >pdev->dev;
+   acpi_status status;
 
if (!xgene_ring_mgr_init(pdata))
return -ENODEV;
@@ -393,11 +394,9 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
udelay(5);
} else {
 #ifdef CONFIG_ACPI
-   if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_RST")) {
-   acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
-"_RST", NULL, NULL);
-   } else if (acpi_has_method(ACPI_HANDLE(>pdev->dev),
-  "_INI")) {
+   status = acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
+ "_RST", NULL, NULL);
+   if (ACPI_FAILURE(status)) {
acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
 "_INI", NULL, NULL);
}
-- 
2.20.1



Re: [PATCH v2] drivers: net: xgene: Remove acpi_has_method() calls

2019-07-23 Thread Kelsey Skunberg
On Tue, Jul 23, 2019 at 02:07:39PM -0700, David Miller wrote:
> From: David Miller 
> Date: Tue, 23 Jul 2019 14:06:46 -0700 (PDT)
> 
> > From: Kelsey Skunberg 
> > Date: Tue, 23 Jul 2019 12:58:11 -0600
> > 
> >> acpi_evaluate_object will already return an error if the needed method
> >> does not exist. Remove unnecessary acpi_has_method() calls and check the
> >> returned acpi_status for failure instead.
> >> 
> >> Signed-off-by: Kelsey Skunberg 
> >> ---
> >> Changes in v2:
> >>- Fixed white space warnings and errors
> > 
> > Applied to net-next.
> 
> Wow did you even build test this?   Reverted...
>
This patch has definitely been a mess, so thank you for your time and
sticking with me here. I thought my build tests included these files,
though discovered they did not. Since submitting v2, I was able to reproduce the
same errors you listed and corrected the problem in v3.

I also realized my .git/post-commit file needed to be fixed, so the white
space problem in v1 should also not be a problem in the future.

Please let me know if you notice anything else I can improve on. I will
learn from my mistakes and really appreciate advice. Thank you again, David.

Best Regards,
Kelsey



Re: [PATCH 00/11] PCI: Move symbols to drivers/pci/pci.h

2019-07-23 Thread Kelsey Skunberg
On Tue, Jul 23, 2019 at 06:07:01PM -0500, Bjorn Helgaas wrote:
> On Thu, Jul 11, 2019 at 04:23:30PM -0600, Kelsey Skunberg wrote:
> > Move symbols defined in include/linux/pci.h that are only used in
> > drivers/pci/ to drivers/pci/pci.h.
> > 
> > Symbols only used in drivers/pci/ do not need to be visible to the rest of
> > the kernel.
> > 
> > Kelsey Skunberg (11):
> >   PCI: Move #define PCI_PM_* lines to drivers/pci/pci.h
> >   PCI: Move PME declarations to drivers/pci/pci.h
> >   PCI: Move *_host_bridge_device() declarations to drivers/pci.pci.h
> >   PCI: Move PCI Virtual Channel declarations to drivers/pci/pci.h
> >   PCI: Move pci_hotplug_*_size declarations to drivers/pci/pci.h
> >   PCI: Move pci_bus_* declarations to drivers/pci/pci.h
> >   PCI: Move pcie_update_link_speed() to drivers/pci/pci.h
> >   PCI: Move pci_ats_init() to drivers/pci/pci.h
> >   PCI: Move ECRC declarations to drivers/pci/pci.h
> >   PCI: Move PTM declaration to drivers/pci/pci.h
> >   PCI: Move pci_*_node() declarations to drivers/pci/pci.h
> > 
> >  drivers/pci/pci.h   | 48 ++---
> >  include/linux/pci.h | 47 
> >  2 files changed, 45 insertions(+), 50 deletions(-)
> 
> Hi Kelsey,
> 
> I didn't get these applied before v5.3-rc1, so now they don't apply
> cleanly.  Would you mind refreshing them and posting a v2 that does
> apply to my "master" branch (v5.3-rc1)?
> 
> Bjorn

Hi Bjorn,

I can absolutely do that. I'll have v2 sent out soon.

-Kelsey


Re: [PATCH v2] drivers: net: xgene: Remove acpi_has_method() calls

2019-07-23 Thread Kelsey Skunberg
On Tue, Jul 23, 2019 at 05:56:04PM -0500, Bjorn Helgaas wrote:
> On Tue, Jul 23, 2019 at 1:59 PM Kelsey Skunberg
>  wrote:
> >
> > acpi_evaluate_object will already return an error if the needed method
> > does not exist. Remove unnecessary acpi_has_method() calls and check the
> > returned acpi_status for failure instead.
> 
> > diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c 
> > b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
> > index 6453fc2ebb1f..5d637b46b2bf 100644
> > --- a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
> > +++ b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
> > @@ -437,6 +437,7 @@ static void xgene_sgmac_tx_disable(struct 
> > xgene_enet_pdata *p)
> >  static int xgene_enet_reset(struct xgene_enet_pdata *p)
> >  {
> > struct device *dev = >pdev->dev;
> > +   acpi_status status;
> >
> > if (!xgene_ring_mgr_init(p))
> > return -ENODEV;
> > @@ -460,14 +461,13 @@ static int xgene_enet_reset(struct xgene_enet_pdata 
> > *p)
> > }
> > } else {
> >  #ifdef CONFIG_ACPI
> > -   if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_RST"))
> > -   acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
> > -"_RST", NULL, NULL);
> > -   else if (acpi_has_method(ACPI_HANDLE(>pdev->dev), 
> > "_INI"))
> > +   status = acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
> > + "_RST", NULL, NULL);
> > +   if (ACPI_FAILURE(status)) {
> > acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
> >  "_INI", NULL, NULL);
> > +   }
> >  #endif
> > -   }
> 
> Oops, I don't think you intended to remove that brace.
> 
> If you haven't found it already, CONFIG_COMPILE_TEST is useful for
> building things that wouldn't normally be buildable on your arch.

Thank you very much for catching that. I did not know about
CONFIG_COMPILE_TEST yet and that will be very useful. It's clear why my
build test wasn't coming up with the same errors now. I know for future
patches now and will certainly get this one fixed.
Thank you again.

-Kelsey


[PATCH v2] drivers: net: xgene: Remove acpi_has_method() calls

2019-07-23 Thread Kelsey Skunberg
acpi_evaluate_object will already return an error if the needed method
does not exist. Remove unnecessary acpi_has_method() calls and check the
returned acpi_status for failure instead.

Signed-off-by: Kelsey Skunberg 
---
Changes in v2:
- Fixed white space warnings and errors

 drivers/net/ethernet/apm/xgene/xgene_enet_hw.c|  9 -
 drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c | 10 +-
 drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c |  9 -
 3 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 61a465097cb8..79924efd4ab7 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -694,6 +694,7 @@ bool xgene_ring_mgr_init(struct xgene_enet_pdata *p)
 static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
 {
struct device *dev = >pdev->dev;
+   acpi_status status;
 
if (!xgene_ring_mgr_init(pdata))
return -ENODEV;
@@ -712,11 +713,9 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
udelay(5);
} else {
 #ifdef CONFIG_ACPI
-   if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_RST")) {
-   acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
-"_RST", NULL, NULL);
-   } else if (acpi_has_method(ACPI_HANDLE(>pdev->dev),
-"_INI")) {
+   status = acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
+ "_RST", NULL, NULL);
+   if (ACPI_FAILURE(status)) {
acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
 "_INI", NULL, NULL);
}
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
index 6453fc2ebb1f..5d637b46b2bf 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
@@ -437,6 +437,7 @@ static void xgene_sgmac_tx_disable(struct xgene_enet_pdata 
*p)
 static int xgene_enet_reset(struct xgene_enet_pdata *p)
 {
struct device *dev = >pdev->dev;
+   acpi_status status;
 
if (!xgene_ring_mgr_init(p))
return -ENODEV;
@@ -460,14 +461,13 @@ static int xgene_enet_reset(struct xgene_enet_pdata *p)
}
} else {
 #ifdef CONFIG_ACPI
-   if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_RST"))
-   acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
-"_RST", NULL, NULL);
-   else if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_INI"))
+   status = acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
+ "_RST", NULL, NULL);
+   if (ACPI_FAILURE(status)) {
acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
 "_INI", NULL, NULL);
+   }
 #endif
-   }
 
if (!p->port_id) {
xgene_enet_ecc_init(p);
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
index 133eb91c542e..78584089d76d 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
@@ -380,6 +380,7 @@ static void xgene_xgmac_tx_disable(struct xgene_enet_pdata 
*pdata)
 static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
 {
struct device *dev = >pdev->dev;
+   acpi_status status;
 
if (!xgene_ring_mgr_init(pdata))
return -ENODEV;
@@ -393,11 +394,9 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
udelay(5);
} else {
 #ifdef CONFIG_ACPI
-   if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_RST")) {
-   acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
-"_RST", NULL, NULL);
-   } else if (acpi_has_method(ACPI_HANDLE(>pdev->dev),
-  "_INI")) {
+   status = acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
+ "_RST", NULL, NULL);
+   if (ACPI_FAILURE(status)) {
acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
 "_INI", NULL, NULL);
}
-- 
2.20.1



[PATCH] platform: x86: Remove acpi_has_method() call in wmi.c

2019-07-21 Thread Kelsey Skunberg
acpi_has_method() is unnecessary within __query_block() and should be
removed to avoid extra work.

wc_status is initialized to AE_ERROR before the acpi_has_method() call.
acpi_has_method() and acpi_execute_simple_method() failing due to the
method not existing will result in the same outcome from __query_block().

Signed-off-by: Kelsey Skunberg 
---
 drivers/platform/x86/wmi.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/platform/x86/wmi.c b/drivers/platform/x86/wmi.c
index 784cea8572c2..59e9aa0f9643 100644
--- a/drivers/platform/x86/wmi.c
+++ b/drivers/platform/x86/wmi.c
@@ -340,9 +340,7 @@ static acpi_status __query_block(struct wmi_block *wblock, 
u8 instance,
 * expensive, but have no corresponding WCxx method. So we
 * should not fail if this happens.
 */
-   if (acpi_has_method(handle, wc_method))
-   wc_status = acpi_execute_simple_method(handle,
-   wc_method, 1);
+   wc_status = acpi_execute_simple_method(handle, wc_method, 1);
}
 
strcpy(method, "WQ");
-- 
2.20.1



[PATCH] drivers: net: xgene: Remove acpi_has_method() calls

2019-07-21 Thread Kelsey Skunberg
acpi_evaluate_object will already return an error if the needed method
does not exist. Remove unnecessary acpi_has_method() calls and check the
returned acpi_status for failure instead.

Signed-off-by: Kelsey Skunberg 
---
 drivers/net/ethernet/apm/xgene/xgene_enet_hw.c|  7 +++
 drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c | 10 +-
 drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c |  9 -
 3 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
index 61a465097cb8..ef75a09069a8 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -694,6 +694,7 @@ bool xgene_ring_mgr_init(struct xgene_enet_pdata *p)
 static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
 {
struct device *dev = >pdev->dev;
+   acpi_status status;
 
if (!xgene_ring_mgr_init(pdata))
return -ENODEV;
@@ -712,11 +713,9 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
udelay(5);
} else {
 #ifdef CONFIG_ACPI
-   if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_RST")) {
-   acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
+   status = acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
 "_RST", NULL, NULL);
-   } else if (acpi_has_method(ACPI_HANDLE(>pdev->dev),
-"_INI")) {
+   if (ACPI_FAILURE(status)) {
acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
 "_INI", NULL, NULL);
}
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
index 6453fc2ebb1f..6237a2cfd703 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_sgmac.c
@@ -437,6 +437,7 @@ static void xgene_sgmac_tx_disable(struct xgene_enet_pdata 
*p)
 static int xgene_enet_reset(struct xgene_enet_pdata *p)
 {
struct device *dev = >pdev->dev;
+   acpi_status status;
 
if (!xgene_ring_mgr_init(p))
return -ENODEV;
@@ -460,14 +461,13 @@ static int xgene_enet_reset(struct xgene_enet_pdata *p)
}
} else {
 #ifdef CONFIG_ACPI
-   if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_RST"))
-   acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
-"_RST", NULL, NULL);
-   else if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_INI"))
+   status = acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
+ "_RST", NULL, NULL);
+   if (ACPI_FAILURE(status)) {
acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
 "_INI", NULL, NULL);
+   }
 #endif
-   }
 
if (!p->port_id) {
xgene_enet_ecc_init(p);
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c 
b/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
index 133eb91c542e..fede3bfe4d68 100644
--- a/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_xgmac.c
@@ -380,6 +380,7 @@ static void xgene_xgmac_tx_disable(struct xgene_enet_pdata 
*pdata)
 static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
 {
struct device *dev = >pdev->dev;
+   acpi_status status;
 
if (!xgene_ring_mgr_init(pdata))
return -ENODEV;
@@ -393,11 +394,9 @@ static int xgene_enet_reset(struct xgene_enet_pdata *pdata)
udelay(5);
} else {
 #ifdef CONFIG_ACPI
-   if (acpi_has_method(ACPI_HANDLE(>pdev->dev), "_RST")) {
-   acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
-"_RST", NULL, NULL);
-   } else if (acpi_has_method(ACPI_HANDLE(>pdev->dev),
-  "_INI")) {
+   status = acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
+ "_RST", NULL, NULL);
+   if (ACPI_FAILURE(status)) {
acpi_evaluate_object(ACPI_HANDLE(>pdev->dev),
 "_INI", NULL, NULL);
}
-- 
2.20.1



[PATCH 1/3] ACPI: Remove acpi_has_method() call from acpi_adxl.c

2019-07-21 Thread Kelsey Skunberg
acpi_check_dsm() will already return an error if the DSM method does not
exist. Checking if the DSM method exists before the acpi_check_dsm() call
is not needed. Remove acpi_has_method() call to avoid additional work.

Signed-off-by: Kelsey Skunberg 
---
 drivers/acpi/acpi_adxl.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/acpi/acpi_adxl.c b/drivers/acpi/acpi_adxl.c
index 13c8f7b50c46..89aac15663fd 100644
--- a/drivers/acpi/acpi_adxl.c
+++ b/drivers/acpi/acpi_adxl.c
@@ -148,11 +148,6 @@ static int __init adxl_init(void)
return -ENODEV;
}
 
-   if (!acpi_has_method(handle, "_DSM")) {
-   pr_info("No DSM method\n");
-   return -ENODEV;
-   }
-
if (!acpi_check_dsm(handle, _guid, ADXL_REVISION,
ADXL_IDX_GET_ADDR_PARAMS |
ADXL_IDX_FORWARD_TRANSLATE)) {
-- 
2.20.1



[PATCH 0/3] ACPI: Remove unnecessary acpi_has_method() calls

2019-07-21 Thread Kelsey Skunberg
Remove acpi_has_method() calls which return an error a following call will
provide anyways. Removing the unnecessary acpi_has_method() calls help to
clean up code and remove extra work.

Kelsey Skunberg (3):
  ACPI: Remove acpi_has_method() call from acpi_adxl.c
  ACPI: Remove acpi_has_method() call from scan.c
  ACPI: Remove acpi_has_method() calls from thermal.c

 drivers/acpi/acpi_adxl.c |  5 -
 drivers/acpi/scan.c  |  3 ---
 drivers/acpi/thermal.c   | 11 +++
 3 files changed, 3 insertions(+), 16 deletions(-)

-- 
2.20.1



[PATCH 2/3] ACPI: Remove acpi_has_method() call from scan.c

2019-07-21 Thread Kelsey Skunberg
acpi_evaluate_reference() will return an error if the DEP method
does not exist. Checking if the DEP method exists before the
acpi_evaluate_reference() call is not needed. Remove acpi_has_method()
call to avoid additional work.

Signed-off-by: Kelsey Skunberg 
---
 drivers/acpi/scan.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 0e28270b0fd8..4f2b0b481cee 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1803,9 +1803,6 @@ static void acpi_device_dep_initialize(struct acpi_device 
*adev)
 
adev->dep_unmet = 0;
 
-   if (!acpi_has_method(adev->handle, "_DEP"))
-   return;
-
status = acpi_evaluate_reference(adev->handle, "_DEP", NULL,
_devices);
if (ACPI_FAILURE(status)) {
-- 
2.20.1



[PATCH 3/3] ACPI: Remove acpi_has_method() calls from thermal.c

2019-07-21 Thread Kelsey Skunberg
The following acpi_has_method() calls are unnecessary since
acpi_execute_simple_method() and acpi_evaluate_reference() will return an
error if the given method does not exist. Remove acpi_has_method() calls
to avoid additional work.

Signed-off-by: Kelsey Skunberg 
---
 drivers/acpi/thermal.c | 11 +++
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/acpi/thermal.c b/drivers/acpi/thermal.c
index 00f12a86ecbd..d831a61e0010 100644
--- a/drivers/acpi/thermal.c
+++ b/drivers/acpi/thermal.c
@@ -225,13 +225,9 @@ static int acpi_thermal_set_cooling_mode(struct 
acpi_thermal *tz, int mode)
if (!tz)
return -EINVAL;
 
-   if (!acpi_has_method(tz->device->handle, "_SCP")) {
-   ACPI_DEBUG_PRINT((ACPI_DB_INFO, "_SCP not present\n"));
+   if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle,
+   "_SCP", mode)))
return -ENODEV;
-   } else if (ACPI_FAILURE(acpi_execute_simple_method(tz->device->handle,
-  "_SCP", mode))) {
-   return -ENODEV;
-   }
 
return 0;
 }
@@ -463,8 +459,7 @@ static int acpi_thermal_trips_update(struct acpi_thermal 
*tz, int flag)
break;
}
 
-   if ((flag & ACPI_TRIPS_DEVICES)
-   && acpi_has_method(tz->device->handle, "_TZD")) {
+   if (flag & ACPI_TRIPS_DEVICES) {
memset(, 0, sizeof(devices));
status = acpi_evaluate_reference(tz->device->handle, "_TZD",
NULL, );
-- 
2.20.1



Re: [PATCH 5.2 00/21] 5.2.2-stable review

2019-07-18 Thread Kelsey Skunberg
On Thu, Jul 18, 2019 at 12:01:18PM +0900, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.2.2 release.
> There are 21 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sat 20 Jul 2019 02:59:27 AM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.2-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-5.2.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled and booted with no regressions on my system.

-Kelsey
 


Re: [PATCH 5.1 00/54] 5.1.19-stable review

2019-07-18 Thread Kelsey Skunberg
On Thu, Jul 18, 2019 at 12:00:55PM +0900, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.1.19 release.
> There are 54 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sat 20 Jul 2019 02:59:27 AM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.1.19-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-5.1.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled and booted with no regressions on my system.

-Kelsey
 


Re: [PATCH 4.19 00/47] 4.19.60-stable review

2019-07-18 Thread Kelsey Skunberg
On Thu, Jul 18, 2019 at 12:01:14PM +0900, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.19.60 release.
> There are 47 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sat 20 Jul 2019 02:59:27 AM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.60-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.19.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled and booted with no regressions on my system.

-Kelsey
 


Re: [PATCH 4.9 00/54] 4.9.186-stable review

2019-07-18 Thread Kelsey Skunberg
On Thu, Jul 18, 2019 at 12:01:30PM +0900, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.9.186 release.
> There are 54 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sat 20 Jul 2019 02:59:27 AM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.186-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.9.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled and booted with no regressions on my system.

-Kelsey
 


Re: [PATCH 4.4 00/40] 4.4.186-stable review

2019-07-18 Thread Kelsey Skunberg
On Thu, Jul 18, 2019 at 12:01:56PM +0900, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.4.186 release.
> There are 40 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sat 20 Jul 2019 02:59:27 AM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.4.186-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.4.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled and booted with no regressions on my system.

-Kelsey
 


Re: [PATCH 4.14 00/80] 4.14.134-stable review

2019-07-18 Thread Kelsey Skunberg
On Thu, Jul 18, 2019 at 12:00:51PM +0900, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.14.134 release.
> There are 80 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sat 20 Jul 2019 02:59:27 AM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.134-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.14.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled and booted with no regressions on my system.

-Kelsey


[PATCH] PCI: Stop exporting pci_bus_sem

2019-07-17 Thread Kelsey Skunberg
pci_bus_sem is not used by a loadable kernel module and does not need to
be exported. Remove line exporting pci_bus_sem.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/search.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/pci/search.c b/drivers/pci/search.c
index 7f4e65872b8d..bade14002fd8 100644
--- a/drivers/pci/search.c
+++ b/drivers/pci/search.c
@@ -15,7 +15,6 @@
 #include "pci.h"
 
 DECLARE_RWSEM(pci_bus_sem);
-EXPORT_SYMBOL_GPL(pci_bus_sem);
 
 /*
  * pci_for_each_dma_alias - Iterate over DMA aliases for a device
-- 
2.20.1



[PATCH] thermal: intel: int340x_thermal: Remove unnecessary acpi_has_method() uses

2019-07-17 Thread Kelsey Skunberg
acpi_evaluate_object() will already return in error if the method does not
exist. Checking if the method is absent before the acpi_evaluate_object()
call is not needed. Remove acpi_has_method() calls to avoid additional
work.

Signed-off-by: Kelsey Skunberg 
---
 drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c | 6 --
 1 file changed, 6 deletions(-)

diff --git a/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c 
b/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c
index 9716bc3abaf9..7130e90773ed 100644
--- a/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c
+++ b/drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c
@@ -77,9 +77,6 @@ int acpi_parse_trt(acpi_handle handle, int *trt_count, struct 
trt **trtp,
struct acpi_buffer element = { 0, NULL };
struct acpi_buffer trt_format = { sizeof("RRNN"), "RRNN" };
 
-   if (!acpi_has_method(handle, "_TRT"))
-   return -ENODEV;
-
status = acpi_evaluate_object(handle, "_TRT", NULL, );
if (ACPI_FAILURE(status))
return -ENODEV;
@@ -158,9 +155,6 @@ int acpi_parse_art(acpi_handle handle, int *art_count, 
struct art **artp,
struct acpi_buffer art_format = {
sizeof("RRNNN"), "RRNNN" };
 
-   if (!acpi_has_method(handle, "_ART"))
-   return -ENODEV;
-
status = acpi_evaluate_object(handle, "_ART", NULL, );
if (ACPI_FAILURE(status))
return -ENODEV;
-- 
2.20.1



[PATCH] PCI: Remove unused EXPORT_SYMBOL()s from drivers/pci/bus.c

2019-07-17 Thread Kelsey Skunberg
pci_bus_get() and pci_bus_put() are not used by a loadable kernel module
and do not need to be exported. Remove lines exporting pci_bus_get() and
pci_bus_put().

Functions were exported in commit fe830ef62ac6 ("PCI: Introduce
pci_bus_{get|put}() to manage PCI bus reference count"). No found history
of functions being used by a loadable kernel module.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/bus.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/pci/bus.c b/drivers/pci/bus.c
index 495059d923f7..8e40b3e6da77 100644
--- a/drivers/pci/bus.c
+++ b/drivers/pci/bus.c
@@ -417,11 +417,9 @@ struct pci_bus *pci_bus_get(struct pci_bus *bus)
get_device(>dev);
return bus;
 }
-EXPORT_SYMBOL(pci_bus_get);
 
 void pci_bus_put(struct pci_bus *bus)
 {
if (bus)
put_device(>dev);
 }
-EXPORT_SYMBOL(pci_bus_put);
-- 
2.20.1



Re: [Linux-kernel-mentees] [PATCH v2] PCI: Remove functions not called in include/linux/pci.h

2019-07-15 Thread Kelsey Skunberg
On Mon, Jul 15, 2019 at 06:37:17PM -0500, Bjorn Helgaas wrote:
> On Mon, Jul 15, 2019 at 09:42:47PM +0200, Lukas Bulwahn wrote:
> > On Mon, 15 Jul 2019, Kelsey Skunberg wrote:
> > 
> > > Remove the following uncalled functions from include/linux/pci.h:
> > > 
> > > pci_block_cfg_access()
> > > pci_block_cfg_access_in_atomic()
> > > pci_unblock_cfg_access()
> > > 
> > > Functions were added in patch fb51ccbf217c "PCI: Rework config space
> > > blocking services", ...
> 
> > Also note that commits are referred to with this format:
> > 
> > commit <12-character sha prefix> ("")
> 
> FWIW, I use this shell alias to generate these references:
> 
>   gsr is aliased to `git --no-pager show -s --abbrev-commit --abbrev=12 
> --pretty=format:"%h (\"%s\")%n"'
> 
>   $ gsr fb51ccb
>   fb51ccbf217c ("PCI: Rework config space blocking services")
> 
> Documentation/process/submitting-patches.rst mentions a 12-char (at
> least) SHA-1 but the e21d2170f36 example shows a *20*-char SHA-1,
> which seems excessive to me.
> 
> I personally skip the word "commit" because I figure it's pretty
> obvious what it is, but it's fine either way.
> 
> Bjorn

This is very useful! I definitely like the use of the alias. Thank you!

-Kelsey


[PATCH v3] PCI: Remove functions not called in include/linux/pci.h

2019-07-15 Thread Kelsey Skunberg
Remove the following uncalled functions from include/linux/pci.h:

pci_block_cfg_access()
pci_block_cfg_access_in_atomic()
pci_unblock_cfg_access()

Functions were added in commit fb51ccbf217c ("PCI: Rework config space
blocking services"), though no callers were added. Code continues to be
unused and should be removed.

Signed-off-by: Kelsey Skunberg 
---

Changes since v1:
  - Fixed Signed-off-by line to show full name

Changes since v2:
  - Change commit message to reference prior commit properly with the
following format:
commit <12-character sha prefix> ("")

 include/linux/pci.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index cf380544c700..3c9ba6133bea 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1656,11 +1656,6 @@ static inline void pci_release_regions(struct pci_dev 
*dev) { }
 
 static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
 
-static inline void pci_block_cfg_access(struct pci_dev *dev) { }
-static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev)
-{ return 0; }
-static inline void pci_unblock_cfg_access(struct pci_dev *dev) { }
-
 static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
 { return NULL; }
 static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
-- 
2.20.1



Re: [Linux-kernel-mentees] [PATCH v2] PCI: Remove functions not called in include/linux/pci.h

2019-07-15 Thread Kelsey Skunberg
On Mon, Jul 15, 2019 at 09:42:47PM +0200, Lukas Bulwahn wrote:
> 
> 
> On Mon, 15 Jul 2019, Kelsey Skunberg wrote:
> 
> > Remove the following uncalled functions from include/linux/pci.h:
> > 
> > pci_block_cfg_access()
> > pci_block_cfg_access_in_atomic()
> > pci_unblock_cfg_access()
> > 
> > Functions were added in patch fb51ccbf217c "PCI: Rework config space
> > blocking services", though no callers were added. Code continues to be
> > unused and should be removed.
> > 
> > Signed-off-by: Kelsey Skunberg 
> > ---
> > 
> 
> Nice finding. How did you discover this issue? Did you use a tool to find 
> this ununsed code or stumble over it during your code review?
>
Stumbled upon it while reviewing include/linux/pci.h to see what
could be moved to drivers/pci/pci.h.
 
> Also note that commits are referred to with this format:
> 
> commit <12-character sha prefix> ("")
>
> So, you need to change patch to commit and include brackets around your
> quoted commit message.
> 
> Lukas

Thank you for letting me know and reviewing! I will update this now.

-Kelsey

> 
> > Changes since v1:
> >   - Fixed Signed-off-by line to show full name
> > 
> >  include/linux/pci.h | 5 -
> >  1 file changed, 5 deletions(-)
> > 
> > diff --git a/include/linux/pci.h b/include/linux/pci.h
> > index cf380544c700..3c9ba6133bea 100644
> > --- a/include/linux/pci.h
> > +++ b/include/linux/pci.h
> > @@ -1656,11 +1656,6 @@ static inline void pci_release_regions(struct 
> > pci_dev *dev) { }
> >  
> >  static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return 
> > -1; }
> >  
> > -static inline void pci_block_cfg_access(struct pci_dev *dev) { }
> > -static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev)
> > -{ return 0; }
> > -static inline void pci_unblock_cfg_access(struct pci_dev *dev) { }
> > -
> >  static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
> >  { return NULL; }
> >  static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
> > -- 
> > 2.20.1
> > 
> > ___
> > Linux-kernel-mentees mailing list
> > linux-kernel-ment...@lists.linuxfoundation.org
> > https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees
> > 


[PATCH v2] PCI: Remove functions not called in include/linux/pci.h

2019-07-15 Thread Kelsey Skunberg
Remove the following uncalled functions from include/linux/pci.h:

pci_block_cfg_access()
pci_block_cfg_access_in_atomic()
pci_unblock_cfg_access()

Functions were added in patch fb51ccbf217c "PCI: Rework config space
blocking services", though no callers were added. Code continues to be
unused and should be removed.

Signed-off-by: Kelsey Skunberg 
---

Changes since v1:
  - Fixed Signed-off-by line to show full name

 include/linux/pci.h | 5 -
 1 file changed, 5 deletions(-)

diff --git a/include/linux/pci.h b/include/linux/pci.h
index cf380544c700..3c9ba6133bea 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1656,11 +1656,6 @@ static inline void pci_release_regions(struct pci_dev 
*dev) { }
 
 static inline unsigned long pci_address_to_pio(phys_addr_t addr) { return -1; }
 
-static inline void pci_block_cfg_access(struct pci_dev *dev) { }
-static inline int pci_block_cfg_access_in_atomic(struct pci_dev *dev)
-{ return 0; }
-static inline void pci_unblock_cfg_access(struct pci_dev *dev) { }
-
 static inline struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
 { return NULL; }
 static inline struct pci_dev *pci_get_slot(struct pci_bus *bus,
-- 
2.20.1



Re: [PATCH 5.1 000/138] 5.1.18-stable review

2019-07-13 Thread Kelsey Skunberg
On Fri, Jul 12, 2019 at 02:17:44PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.1.18 release.
> There are 138 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sun 14 Jul 2019 12:14:36 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.1.18-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-5.1.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 


Compiled and booted with no regressions on my system.

Cheers,
Kelsey



Re: [PATCH 5.2 00/61] 5.2.1-stable review

2019-07-13 Thread Kelsey Skunberg
On Fri, Jul 12, 2019 at 02:19:13PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.2.1 release.
> There are 61 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sun 14 Jul 2019 12:14:36 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.2.1-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-5.2.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h


Compiled and booted with no regressions on my system.

Cheers,
Kelsey
 


Re: [PATCH 4.19 00/91] 4.19.59-stable review

2019-07-13 Thread Kelsey Skunberg
On Fri, Jul 12, 2019 at 02:18:03PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.19.59 release.
> There are 91 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Sun 14 Jul 2019 12:14:36 PM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.59-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.19.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 


Compiled and booted with no regressions on my system.

Cheers,
Kelsey


[PATCH 11/11] PCI: Move pci_*_node() declarations to drivers/pci/pci.h

2019-07-11 Thread Kelsey Skunberg
pci_*_node() is only called from drivers/pci/. Since these declarations do
not need to be visible to the rest of the kernel, move to
drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 8 
 include/linux/pci.h | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 95bca00ea85a..a8d04dac3430 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -588,6 +588,10 @@ struct device_node;
 int of_pci_parse_bus_range(struct device_node *node, struct resource *res);
 int of_get_pci_domain_nr(struct device_node *node);
 int of_pci_get_max_link_speed(struct device_node *node);
+void pci_set_of_node(struct pci_dev *dev);
+void pci_release_of_node(struct pci_dev *dev);
+void pci_set_bus_of_node(struct pci_bus *bus);
+void pci_release_bus_of_node(struct pci_bus *bus);
 
 #else
 static inline int
@@ -607,6 +611,10 @@ of_pci_get_max_link_speed(struct device_node *node)
 {
return -EINVAL;
 }
+static inline void pci_set_of_node(struct pci_dev *dev) { }
+static inline void pci_release_of_node(struct pci_dev *dev) { }
+static inline void pci_set_bus_of_node(struct pci_bus *bus) { }
+static inline void pci_release_bus_of_node(struct pci_bus *bus) { }
 #endif /* CONFIG_OF */
 
 #if defined(CONFIG_OF_ADDRESS)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index ea4dfb6b6693..cf380544c700 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2206,10 +2206,6 @@ int pci_vpd_find_info_keyword(const u8 *buf, unsigned 
int off,
 #ifdef CONFIG_OF
 struct device_node;
 struct irq_domain;
-void pci_set_of_node(struct pci_dev *dev);
-void pci_release_of_node(struct pci_dev *dev);
-void pci_set_bus_of_node(struct pci_bus *bus);
-void pci_release_bus_of_node(struct pci_bus *bus);
 struct irq_domain *pci_host_bridge_of_msi_domain(struct pci_bus *bus);
 int pci_parse_request_of_pci_ranges(struct device *dev,
struct list_head *resources,
@@ -2219,10 +2215,6 @@ int pci_parse_request_of_pci_ranges(struct device *dev,
 struct device_node *pcibios_get_phb_of_node(struct pci_bus *bus);
 
 #else  /* CONFIG_OF */
-static inline void pci_set_of_node(struct pci_dev *dev) { }
-static inline void pci_release_of_node(struct pci_dev *dev) { }
-static inline void pci_set_bus_of_node(struct pci_bus *bus) { }
-static inline void pci_release_bus_of_node(struct pci_bus *bus) { }
 static inline struct irq_domain *
 pci_host_bridge_of_msi_domain(struct pci_bus *bus) { return NULL; }
 static inline int pci_parse_request_of_pci_ranges(struct device *dev,
-- 
2.20.1



[PATCH 09/11] PCI: Move ECRC declarations to drivers/pci/pci.h

2019-07-11 Thread Kelsey Skunberg
pcie_set_ecrc_checking() and pcie_ecrc_get_policy() are only called within
drivers/pci/. Since declarations do not need to be visible to the rest of
the kernel, move to drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 8 
 include/linux/pci.h | 8 
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index bc677e97a262..74249c31325c 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -537,6 +537,14 @@ static inline void pcie_aspm_create_sysfs_dev_files(struct 
pci_dev *pdev) { }
 static inline void pcie_aspm_remove_sysfs_dev_files(struct pci_dev *pdev) { }
 #endif
 
+#ifdef CONFIG_PCIE_ECRC
+void pcie_set_ecrc_checking(struct pci_dev *dev);
+void pcie_ecrc_get_policy(char *str);
+#else
+static inline void pcie_set_ecrc_checking(struct pci_dev *dev) { }
+static inline void pcie_ecrc_get_policy(char *str) { }
+#endif
+
 #ifdef CONFIG_PCIE_PTM
 void pci_ptm_init(struct pci_dev *dev);
 #else
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 263c087b95d5..8fbe3471e8f0 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1501,14 +1501,6 @@ bool pci_aer_available(void);
 static inline bool pci_aer_available(void) { return false; }
 #endif
 
-#ifdef CONFIG_PCIE_ECRC
-void pcie_set_ecrc_checking(struct pci_dev *dev);
-void pcie_ecrc_get_policy(char *str);
-#else
-static inline void pcie_set_ecrc_checking(struct pci_dev *dev) { }
-static inline void pcie_ecrc_get_policy(char *str) { }
-#endif
-
 bool pci_ats_disabled(void);
 
 #ifdef CONFIG_PCIE_PTM
-- 
2.20.1



[PATCH 10/11] PCI: Move PTM declaration to drivers/pci/pci.h

2019-07-11 Thread Kelsey Skunberg
pci_enable_ptm() is only called within drivers/pci/. Since declaration
does not need to be visible to the rest of the kernel, move to
drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 3 +++
 include/linux/pci.h | 7 ---
 2 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 74249c31325c..95bca00ea85a 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -547,8 +547,11 @@ static inline void pcie_ecrc_get_policy(char *str) { }
 
 #ifdef CONFIG_PCIE_PTM
 void pci_ptm_init(struct pci_dev *dev);
+int pci_enable_ptm(struct pci_dev *dev, u8 *granularity);
 #else
 static inline void pci_ptm_init(struct pci_dev *dev) { }
+static inline int pci_enable_ptm(struct pci_dev *dev, u8 *granularity)
+{ return -EINVAL; }
 #endif
 
 struct pci_dev_reset_methods {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 8fbe3471e8f0..ea4dfb6b6693 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1503,13 +1503,6 @@ static inline bool pci_aer_available(void) { return 
false; }
 
 bool pci_ats_disabled(void);
 
-#ifdef CONFIG_PCIE_PTM
-int pci_enable_ptm(struct pci_dev *dev, u8 *granularity);
-#else
-static inline int pci_enable_ptm(struct pci_dev *dev, u8 *granularity)
-{ return -EINVAL; }
-#endif
-
 void pci_cfg_access_lock(struct pci_dev *dev);
 bool pci_cfg_access_trylock(struct pci_dev *dev);
 void pci_cfg_access_unlock(struct pci_dev *dev);
-- 
2.20.1



[PATCH 06/11] PCI: Move pci_bus_* declarations to drivers/pci/pci.h

2019-07-11 Thread Kelsey Skunberg
pci_bus_* declarations are only called within drivers/pci/. Since
declarations do not need to be visible to the rest of the kernel, move to
drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 3 +++
 include/linux/pci.h | 2 --
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index ee7b7383e497..9b87309f5c12 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -270,6 +270,9 @@ bool pci_bus_clip_resource(struct pci_dev *dev, int idx);
 void pci_reassigndev_resource_alignment(struct pci_dev *dev);
 void pci_disable_bridge_window(struct pci_dev *dev);
 
+struct pci_bus *pci_bus_get(struct pci_bus *bus);
+void pci_bus_put(struct pci_bus *bus);
+
 /* PCIe link information */
 #define PCIE_SPEED2STR(speed) \
((speed) == PCIE_SPEED_16_0GT ? "16 GT/s" : \
diff --git a/include/linux/pci.h b/include/linux/pci.h
index ead399b8d136..54946423d901 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1233,8 +1233,6 @@ int pci_request_selected_regions_exclusive(struct pci_dev 
*, int, const char *);
 void pci_release_selected_regions(struct pci_dev *, int);
 
 /* drivers/pci/bus.c */
-struct pci_bus *pci_bus_get(struct pci_bus *bus);
-void pci_bus_put(struct pci_bus *bus);
 void pci_add_resource(struct list_head *resources, struct resource *res);
 void pci_add_resource_offset(struct list_head *resources, struct resource *res,
 resource_size_t offset);
-- 
2.20.1



[PATCH 08/11] PCI: Move pci_ats_init() to drivers/pci/pci.h

2019-07-11 Thread Kelsey Skunberg
pci_ats_init() is only called with drivers/pci/. Since declarations do not
need to be visible to the rest of the kernel, move to drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 7 ---
 include/linux/pci.h | 2 --
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 59321488da03..bc677e97a262 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -436,11 +436,12 @@ static inline void pci_restore_dpc_state(struct pci_dev 
*dev) {}
 #endif
 
 #ifdef CONFIG_PCI_ATS
+/* Address Translation Service */
+void pci_ats_init(struct pci_dev *dev);
 void pci_restore_ats_state(struct pci_dev *dev);
 #else
-static inline void pci_restore_ats_state(struct pci_dev *dev)
-{
-}
+static inline void pci_ats_init(struct pci_dev *d) { }
+static inline void pci_restore_ats_state(struct pci_dev *dev) { }
 #endif /* CONFIG_PCI_ATS */
 
 #ifdef CONFIG_PCI_IOV
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 3221d9f61ab4..263c087b95d5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1708,13 +1708,11 @@ static inline bool pci_ats_disabled(void) { return 
true; }
 
 #ifdef CONFIG_PCI_ATS
 /* Address Translation Service */
-void pci_ats_init(struct pci_dev *dev);
 int pci_enable_ats(struct pci_dev *dev, int ps);
 void pci_disable_ats(struct pci_dev *dev);
 int pci_ats_queue_depth(struct pci_dev *dev);
 int pci_ats_page_aligned(struct pci_dev *dev);
 #else
-static inline void pci_ats_init(struct pci_dev *d) { }
 static inline int pci_enable_ats(struct pci_dev *d, int ps) { return -ENODEV; }
 static inline void pci_disable_ats(struct pci_dev *d) { }
 static inline int pci_ats_queue_depth(struct pci_dev *d) { return -ENODEV; }
-- 
2.20.1



[PATCH 02/11] PCI: Move PME declarations to drivers/pci/pci.h

2019-07-11 Thread Kelsey Skunberg
pci_check_pme_status() and pci_pme_wakeup_bus() are only
called within drivers/pci/. Since declarations do not need to be visible
to the rest of the kernel, move to drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 2 ++
 include/linux/pci.h | 2 --
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 7e30fbde5c84..800fe8989f48 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -85,6 +85,8 @@ void pci_power_up(struct pci_dev *dev);
 void pci_disable_enabled_device(struct pci_dev *dev);
 int pci_finish_runtime_suspend(struct pci_dev *dev);
 void pcie_clear_root_pme_status(struct pci_dev *dev);
+bool pci_check_pme_status(struct pci_dev *dev);
+void pci_pme_wakeup_bus(struct pci_bus *bus);
 int __pci_pme_wakeup(struct pci_dev *dev, void *ign);
 void pci_pme_restore(struct pci_dev *dev);
 bool pci_dev_keep_suspended(struct pci_dev *dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 3bda6a87a815..cedebb08a32d 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1187,8 +1187,6 @@ int pci_wake_from_d3(struct pci_dev *dev, bool enable);
 int pci_prepare_to_sleep(struct pci_dev *dev);
 int pci_back_from_sleep(struct pci_dev *dev);
 bool pci_dev_run_wake(struct pci_dev *dev);
-bool pci_check_pme_status(struct pci_dev *dev);
-void pci_pme_wakeup_bus(struct pci_bus *bus);
 void pci_d3cold_enable(struct pci_dev *dev);
 void pci_d3cold_disable(struct pci_dev *dev);
 bool pcie_relaxed_ordering_enabled(struct pci_dev *dev);
-- 
2.20.1



[PATCH 00/11] PCI: Move symbols to drivers/pci/pci.h

2019-07-11 Thread Kelsey Skunberg
Move symbols defined in include/linux/pci.h that are only used in
drivers/pci/ to drivers/pci/pci.h.

Symbols only used in drivers/pci/ do not need to be visible to the rest of
the kernel.

Kelsey Skunberg (11):
  PCI: Move #define PCI_PM_* lines to drivers/pci/pci.h
  PCI: Move PME declarations to drivers/pci/pci.h
  PCI: Move *_host_bridge_device() declarations to drivers/pci.pci.h
  PCI: Move PCI Virtual Channel declarations to drivers/pci/pci.h
  PCI: Move pci_hotplug_*_size declarations to drivers/pci/pci.h
  PCI: Move pci_bus_* declarations to drivers/pci/pci.h
  PCI: Move pcie_update_link_speed() to drivers/pci/pci.h
  PCI: Move pci_ats_init() to drivers/pci/pci.h
  PCI: Move ECRC declarations to drivers/pci/pci.h
  PCI: Move PTM declaration to drivers/pci/pci.h
  PCI: Move pci_*_node() declarations to drivers/pci/pci.h

 drivers/pci/pci.h   | 48 ++---
 include/linux/pci.h | 47 
 2 files changed, 45 insertions(+), 50 deletions(-)

-- 
2.20.1



[PATCH 07/11] PCI: Move pcie_update_link_speed() to drivers/pci/pci.h

2019-07-11 Thread Kelsey Skunberg
pcie_update_line_speed() is only called within drivers/pci/. Since
declaration does not need to be visible to the rest of the kernel, move to
drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 1 +
 include/linux/pci.h | 1 -
 2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 9b87309f5c12..59321488da03 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -295,6 +295,7 @@ u32 pcie_bandwidth_capable(struct pci_dev *dev, enum 
pci_bus_speed *speed,
   enum pcie_link_width *width);
 void __pcie_print_link_status(struct pci_dev *dev, bool verbose);
 void pcie_report_downtraining(struct pci_dev *dev);
+void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
 
 /* Single Root I/O Virtualization */
 struct pci_sriov {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 54946423d901..3221d9f61ab4 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -938,7 +938,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, 
int bus,
 int pci_scan_root_bus_bridge(struct pci_host_bridge *bridge);
 struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
int busnr);
-void pcie_update_link_speed(struct pci_bus *bus, u16 link_status);
 struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
 const char *name,
 struct hotplug_slot *hotplug);
-- 
2.20.1



[PATCH 05/11] PCI: Move pci_hotplug_*_size declarations to drivers/pci/pci.h

2019-07-11 Thread Kelsey Skunberg
pci_hotplug_*_size declarations are only called within drivers/pci/pci/.
Since declarations do not need to be seen by the rest of the kernel, move
to drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 3 +++
 include/linux/pci.h | 4 
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 6ba790a77be4..ee7b7383e497 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -206,6 +206,9 @@ extern const struct attribute_group *pcibus_groups[];
 extern const struct device_type pci_dev_type;
 extern const struct attribute_group *pci_bus_groups[];
 
+extern unsigned long pci_hotplug_io_size;
+extern unsigned long pci_hotplug_mem_size;
+extern unsigned long pci_hotplug_bus_size;
 
 /**
  * pci_match_one_device - Tell if a PCI device structure has a matching
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 2c5609b5782e..ead399b8d136 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1957,10 +1957,6 @@ extern unsigned long pci_cardbus_mem_size;
 extern u8 pci_dfl_cache_line_size;
 extern u8 pci_cache_line_size;
 
-extern unsigned long pci_hotplug_io_size;
-extern unsigned long pci_hotplug_mem_size;
-extern unsigned long pci_hotplug_bus_size;
-
 /* Architecture-specific versions may override these (weak) */
 void pcibios_disable_device(struct pci_dev *dev);
 void pcibios_set_master(struct pci_dev *dev);
-- 
2.20.1



[PATCH 04/11] PCI: Move PCI Virtual Channel declarations to drivers/pci/pci.h

2019-07-11 Thread Kelsey Skunberg
PCI Virtual Channel declarations are only called within drivers/pci/.
Since declarations do not need to be visible to the rest of the kernel,
move to drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 5 +
 include/linux/pci.h | 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index f2ba33613c21..6ba790a77be4 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -128,6 +128,11 @@ void pci_vpd_release(struct pci_dev *dev);
 void pcie_vpd_create_sysfs_dev_files(struct pci_dev *dev);
 void pcie_vpd_remove_sysfs_dev_files(struct pci_dev *dev);
 
+/* PCI Virtual Channel */
+int pci_save_vc_state(struct pci_dev *dev);
+void pci_restore_vc_state(struct pci_dev *dev);
+void pci_allocate_vc_save_buffers(struct pci_dev *dev);
+
 /* PCI /proc functions */
 #ifdef CONFIG_PROC_FS
 int pci_proc_attach_device(struct pci_dev *dev);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 39e609ea316e..2c5609b5782e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1190,11 +1190,6 @@ bool pcie_relaxed_ordering_enabled(struct pci_dev *dev);
 void pci_wakeup_bus(struct pci_bus *bus);
 void pci_bus_set_current_state(struct pci_bus *bus, pci_power_t state);
 
-/* PCI Virtual Channel */
-int pci_save_vc_state(struct pci_dev *dev);
-void pci_restore_vc_state(struct pci_dev *dev);
-void pci_allocate_vc_save_buffers(struct pci_dev *dev);
-
 /* For use by arch with custom probe code */
 void set_pcie_port_type(struct pci_dev *pdev);
 void set_pcie_hotplug_bridge(struct pci_dev *pdev);
-- 
2.20.1



[PATCH 03/11] PCI: Move *_host_bridge_device() declarations to drivers/pci.pci.h

2019-07-11 Thread Kelsey Skunberg
pci_get_host_bridge_device() and pci_put_host_bridge_device() are only
called within drivers/pci/pci.h. Since declarations do not need to be visible
to the rest of the kernel, move to drivers/pci/pci.h.

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 3 +++
 include/linux/pci.h | 3 ---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 800fe8989f48..f2ba33613c21 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -100,6 +100,9 @@ void pci_free_cap_save_buffers(struct pci_dev *dev);
 bool pci_bridge_d3_possible(struct pci_dev *dev);
 void pci_bridge_d3_update(struct pci_dev *dev);
 
+struct device *pci_get_host_bridge_device(struct pci_dev *dev);
+void pci_put_host_bridge_device(struct device *dev);
+
 static inline void pci_wakeup_event(struct pci_dev *dev)
 {
/* Wait 100 ms before the system can be put into a sleep state. */
diff --git a/include/linux/pci.h b/include/linux/pci.h
index cedebb08a32d..39e609ea316e 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -639,9 +639,6 @@ static inline struct pci_dev *pci_upstream_bridge(struct 
pci_dev *dev)
return dev->bus->self;
 }
 
-struct device *pci_get_host_bridge_device(struct pci_dev *dev);
-void pci_put_host_bridge_device(struct device *dev);
-
 #ifdef CONFIG_PCI_MSI
 static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev)
 {
-- 
2.20.1



[PATCH 01/11] PCI: Move #define PCI_PM_* lines to drivers/pci/pci.h

2019-07-11 Thread Kelsey Skunberg
The #define PCI_PM_* lines are only used within drivers/pci/ and they do not
need to be seen by the rest of the kernel. Move #define PCI_* to
drivers/pci/pci.h

Signed-off-by: Kelsey Skunberg 
---
 drivers/pci/pci.h   | 5 +
 include/linux/pci.h | 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index 9cb99380c61e..7e30fbde5c84 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -39,6 +39,11 @@ int pci_probe_reset_function(struct pci_dev *dev);
 int pci_bridge_secondary_bus_reset(struct pci_dev *dev);
 int pci_bus_error_reset(struct pci_dev *dev);
 
+#define PCI_PM_D2_DELAY 200
+#define PCI_PM_D3_WAIT  10
+#define PCI_PM_D3COLD_WAIT  100
+#define PCI_PM_BUS_WAIT 50
+
 /**
  * struct pci_platform_pm_ops - Firmware PM callbacks
  *
diff --git a/include/linux/pci.h b/include/linux/pci.h
index dd436da7eccc..3bda6a87a815 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -145,11 +145,6 @@ static inline const char *pci_power_name(pci_power_t state)
return pci_power_names[1 + (__force int) state];
 }
 
-#define PCI_PM_D2_DELAY200
-#define PCI_PM_D3_WAIT 10
-#define PCI_PM_D3COLD_WAIT 100
-#define PCI_PM_BUS_WAIT50
-
 /**
  * The pci_channel state describes connectivity between the CPU and
  * the PCI device.  If some PCI bus between here and the PCI device
-- 
2.20.1



Re: [PATCH 5.1 00/55] 5.1.16-stable review

2019-07-02 Thread Kelsey Skunberg
On Tue, Jul 02, 2019 at 10:01:08AM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.1.16 release.
> There are 55 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Thu 04 Jul 2019 07:59:45 AM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.1.16-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-5.1.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled, booted, and no regressions on my system.

Cheers,
Kelsey



Re: [PATCH 4.14 00/43] 4.14.132-stable review

2019-07-02 Thread Kelsey Skunberg
On Tue, Jul 02, 2019 at 10:01:40AM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.14.132 release.
> There are 43 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Thu 04 Jul 2019 07:59:45 AM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.132-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.14.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h
> 

Compiled, booted, and no regressions on my system.

Cheers,
Kelsey



Re: [PATCH 4.19 00/72] 4.19.57-stable review

2019-07-02 Thread Kelsey Skunberg
On Tue, Jul 02, 2019 at 10:01:01AM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.19.57 release.
> There are 72 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Thu 04 Jul 2019 07:59:45 AM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.19.57-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.19.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h


Compiled, booted, and no regressions on my system.

-Kelsey


Re: [PATCH 5.1 00/46] 5.1.3-stable review

2019-05-17 Thread Kelsey Skunberg
On Wed, May 15, 2019 at 12:56:24PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.1.3 release.
> There are 46 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 17 May 2019 09:04:22 AM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.1.3-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-5.1.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled and booted with no dmesg regressions on my system.

Cheers,
Kelsey



Re: [PATCH 4.9 00/51] 4.9.177-stable review

2019-05-17 Thread Kelsey Skunberg
On Wed, May 15, 2019 at 12:55:35PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 4.9.177 release.
> There are 51 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 17 May 2019 09:04:42 AM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.9.177-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-4.9.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled and booted with no dmesg regressions on my system.

Cheers,
Kelsey



Re: [PATCH 5.0 000/137] 5.0.17-stable review

2019-05-17 Thread Kelsey Skunberg
On Wed, May 15, 2019 at 12:54:41PM +0200, Greg Kroah-Hartman wrote:
> This is the start of the stable review cycle for the 5.0.17 release.
> There are 137 patches in this series, all will be posted as a response
> to this one.  If anyone has any issues with these being applied, please
> let me know.
> 
> Responses should be made by Fri 17 May 2019 09:04:31 AM UTC.
> Anything received after that time might be too late.
> 
> The whole patch series can be found in one patch at:
>   
> https://www.kernel.org/pub/linux/kernel/v5.x/stable-review/patch-5.0.17-rc1.gz
> or in the git tree and branch at:
>   
> git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
> linux-5.0.y
> and the diffstat can be found below.
> 
> thanks,
> 
> greg k-h

Compiled and booted with no dmesg regressions on my system.

Cheers,
Kelsey


Re: [PATCH] selftests: pidfd: Create .gitignore to include pidfd_test

2019-05-16 Thread Kelsey Skunberg
On Tue, May 14, 2019 at 05:26:25PM -0600, Shuah Khan wrote:
> Hi Kelsey,
> 
> On 5/11/19 10:57 PM, Kelsey Skunberg wrote:
> > Create /selftests/pidfd/.gitignore which holds the following file name
> > created after compiling:
> 
> This patch generates the following checkpatch warning.
> 
> WARNING: use relative pathname instead of absolute in changelog text
> #85:
> Create /selftests/drivers/.gitignore which holds the following file name
> 
> 
> I fixed it and applied the patch. Please make sure to run checkpatch
> before sending patches in the future.
> 
> thanks,
> -- Shuah

Thank you for catching and fixing this! I'll make sure to remember to
run checkpatch in the future.

Thanks again!

-Kelsey


[PATCH] tools: gpio: Add include/linux/gpio.h to .gitignore

2019-05-11 Thread Kelsey Skunberg
File include/linux/gpio.h is generated after building
tools/testing/selftests

Add gpio.h to .gitignore to help clean up working tree status.

Signed-off-by: Kelsey Skunberg 
---
 tools/gpio/.gitignore | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/gpio/.gitignore b/tools/gpio/.gitignore
index 9e9dd4b681b2..a94c0e83b209 100644
--- a/tools/gpio/.gitignore
+++ b/tools/gpio/.gitignore
@@ -1,4 +1,4 @@
 gpio-event-mon
 gpio-hammer
 lsgpio
-
+include/linux/gpio.h
--
2.20.1



[PATCH] selftests: drivers: Create .gitignore to include /dma-buf/udmabuf

2019-05-11 Thread Kelsey Skunberg
Create /selftests/drivers/.gitignore which holds the following file name
created after compiling:

- /dma-buf/udmabuf

Signed-off-by: Kelsey Skunberg 
---
 tools/testing/selftests/drivers/.gitignore | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 tools/testing/selftests/drivers/.gitignore

diff --git a/tools/testing/selftests/drivers/.gitignore 
b/tools/testing/selftests/drivers/.gitignore
new file mode 100644
index ..f6aebcc27b76
--- /dev/null
+++ b/tools/testing/selftests/drivers/.gitignore
@@ -0,0 +1 @@
+/dma-buf/udmabuf
--
2.20.1



[PATCH] selftests: pidfd: Create .gitignore to include pidfd_test

2019-05-11 Thread Kelsey Skunberg
Create /selftests/pidfd/.gitignore which holds the following file name
created after compiling:

- pidfd_test

Signed-off-by: Kelsey Skunberg 
---
 tools/testing/selftests/pidfd/.gitignore | 1 +
 1 file changed, 1 insertion(+)
 create mode 100644 tools/testing/selftests/pidfd/.gitignore

diff --git a/tools/testing/selftests/pidfd/.gitignore 
b/tools/testing/selftests/pidfd/.gitignore
new file mode 100644
index ..822a1e63d045
--- /dev/null
+++ b/tools/testing/selftests/pidfd/.gitignore
@@ -0,0 +1 @@
+pidfd_test
--
2.20.1



[PATCH v2] selftests: kvm: Add files generated when compiled to .gitignore

2019-05-11 Thread Kelsey Skunberg
The following files are generated in /selftests/kvm/ after compiling and
should be added to /selftests/kvm/.gitignore:

- /x86_64/hyperv_cpuid
- /x86_64/smm_test
- /clear_dirty_log_test

Signed-off-by: Kelsey Skunberg 
---
Changes since v1:
- Included /clear_dirty_log_test to .gitignore
- Updated commit log to reflect file added

 tools/testing/selftests/kvm/.gitignore | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/testing/selftests/kvm/.gitignore 
b/tools/testing/selftests/kvm/.gitignore
index 2689d1ea6d7a..391a19231618 100644
--- a/tools/testing/selftests/kvm/.gitignore
+++ b/tools/testing/selftests/kvm/.gitignore
@@ -6,4 +6,7 @@
 /x86_64/vmx_close_while_nested_test
 /x86_64/vmx_tsc_adjust_test
 /x86_64/state_test
+/x86_64/hyperv_cpuid
+/x86_64/smm_test
+/clear_dirty_log_test
 /dirty_log_test
--
2.20.1



  1   2   >