OSDN Git Service

uclinux-h8/linux.git
10 years agoMerge branch 'pci/pciehp' into next
Bjorn Helgaas [Thu, 20 Feb 2014 21:30:57 +0000 (14:30 -0700)]
Merge branch 'pci/pciehp' into next

* pci/pciehp:
  PCI: pciehp: Cleanup whitespace
  PCI: pciehp: Remove a non-existent card, regardless of "surprise" capability
  PCI: pciehp: Don't turn slot off when hot-added device already exists
  PCI: pciehp: Add hotplug_lock to serialize hotplug events
  PCI: pciehp: Ensure very fast hotplug events are also processed
  PCI: pciehp: Disable link notification across slot reset
  PCI: pciehp: Don't check adapter or latch status while disabling
  PCI: pciehp: Don't disable the link permanently during removal
  PCI: pciehp: Enable link state change notifications
  PCI: pciehp: Use link change notifications for hot-plug and removal
  PCI: pciehp: Make check_link_active() non-static

10 years agoMerge branch 'pci/list-for-each-entry' into next
Bjorn Helgaas [Thu, 20 Feb 2014 21:30:32 +0000 (14:30 -0700)]
Merge branch 'pci/list-for-each-entry' into next

* pci/list-for-each-entry:
  PCI: frv: replace now removed pci_bus_b() causing build failure

10 years agoPCI: frv: replace now removed pci_bus_b() causing build failure
Paul Gortmaker [Thu, 20 Feb 2014 17:46:06 +0000 (12:46 -0500)]
PCI: frv: replace now removed pci_bus_b() causing build failure

In commit 94e6a9b93064 ("PCI: Remove pci_bus_b() and use
list_for_each_entry() directly") the function pci_bus_b() was removed, but
one instance of its usage was missed.

Replace it in the same fashion that the original commit did.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Yijing Wang <wangyijing@huawei.com>
10 years agoPCI: pciehp: Cleanup whitespace
Bjorn Helgaas [Tue, 11 Feb 2014 22:26:29 +0000 (15:26 -0700)]
PCI: pciehp: Cleanup whitespace

Minor whitespace cleanup; no functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: pciehp: Remove a non-existent card, regardless of "surprise" capability
Rajat Jain [Wed, 19 Feb 2014 02:53:19 +0000 (18:53 -0800)]
PCI: pciehp: Remove a non-existent card, regardless of "surprise" capability

In case a card is physically yanked out, it should immediately be removed,
regardless of the "surprise" capability bit. Thus:

  - Always handle the physical removal - regardless of the "surprise" bit.
  - Don't use "surprise" capability when making decisions about enabling
    presence detect notifications.
  - Reword the comments to indicate the intent.

Signed-off-by: Rajat Jain <rajatxjain@gmail.com>
Signed-off-by: Rajat Jain <rajatjain@juniper.net>
Signed-off-by: Guenter Roeck <groeck@juniper.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoMerge branch 'pci/misc' into next
Bjorn Helgaas [Wed, 19 Feb 2014 00:02:04 +0000 (17:02 -0700)]
Merge branch 'pci/misc' into next

* pci/misc:
  PCI: Enable INTx if BIOS left them disabled
  ia64/PCI: Set IORESOURCE_ROM_SHADOW only for the default VGA device
  x86/PCI: Set IORESOURCE_ROM_SHADOW only for the default VGA device
  PCI: Update outdated comment for pcibios_bus_report_status()
  PCI: Cleanup per-arch list of object files
  PCI: cpqphp: Fix hex vs decimal typo in cpqhpc_probe()
  x86/PCI: Fix function definition whitespace
  x86/PCI: Reword comments
  x86/PCI: Remove unnecessary local variable initialization
  PCI: Remove unnecessary list_empty(&pci_pme_list) check

10 years agoPCI: Enable INTx if BIOS left them disabled
Bjorn Helgaas [Wed, 29 Jan 2014 23:13:51 +0000 (16:13 -0700)]
PCI: Enable INTx if BIOS left them disabled

Some firmware leaves the Interrupt Disable bit set even if the device uses
INTx interrupts.  Clear Interrupt Disable so we get those interrupts.

Based on the report mentioned below, if the user selects the "EHCI only"
option in the Intel Baytrail BIOS, the EHCI device is handed off to the OS
with the PCI_COMMAND_INTX_DISABLE bit set.

Link: http://lkml.kernel.org/r/20140114181721.GC12126@xanatos
Link: https://bugzilla.kernel.org/show_bug.cgi?id=70601
Reported-by: Chris Cheng <chris.cheng@atrustcorp.com>
Reported-and-tested-by: Jamie Chen <jamie.chen@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: stable@vger.kernel.org
CC: Sarah Sharp <sarah.a.sharp@linux.intel.com>
10 years agoMerge branch 'pci/host-mvebu' into next
Bjorn Helgaas [Tue, 18 Feb 2014 22:50:12 +0000 (15:50 -0700)]
Merge branch 'pci/host-mvebu' into next

* pci/host-mvebu:
  PCI: mvebu: Call request_resource() on the apertures
  bus: mvebu-mbus: Fix incorrect size for PCI aperture resources
  PCI: mvebu: Fix potential issue in range parsing
  PCI: mvebu: Use Device ID and revision from underlying endpoint

10 years agoMerge branch 'pci/list-for-each-entry' into next
Bjorn Helgaas [Tue, 18 Feb 2014 21:33:46 +0000 (14:33 -0700)]
Merge branch 'pci/list-for-each-entry' into next

* pci/list-for-each-entry:
  PCI: Remove pci_bus_b() and use list_for_each_entry() directly
  pcmcia: Use list_for_each_entry() for bus traversal
  powerpc/PCI: Use list_for_each_entry() for bus traversal
  drm: Use list_for_each_entry() for bus traversal
  ARM/PCI: Use list_for_each_entry() for bus traversal
  ACPI / hotplug / PCI: Use list_for_each_entry() for bus traversal

10 years agoPCI: mvebu: Call request_resource() on the apertures
Jason Gunthorpe [Wed, 12 Feb 2014 22:57:08 +0000 (15:57 -0700)]
PCI: mvebu: Call request_resource() on the apertures

It is typical for host drivers to request a resource for the aperture; once
this is done the PCI core will properly populate resources for all BARs in
the system.

With this patch cat /proc/iomem will now show:

  e0000000-efffffff : PCI MEM 0000
    e0000000-e00fffff : PCI Bus 0000:01
      e0000000-e001ffff : 0000:01:00.0

Tested on Kirkwood.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
10 years agobus: mvebu-mbus: Fix incorrect size for PCI aperture resources
Jason Gunthorpe [Wed, 12 Feb 2014 22:57:07 +0000 (15:57 -0700)]
bus: mvebu-mbus: Fix incorrect size for PCI aperture resources

reg[0] is the DT base, reg[1] is the DT length in bytes,
struct resource.end is the inclusive end address, so a -1 is required.

Tested on kirkwood.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Acked-by: Arnd Bergmann <arnd@arndb.de>
10 years agoMerge branch 'pci/msi' into next
Bjorn Helgaas [Fri, 14 Feb 2014 21:38:00 +0000 (14:38 -0700)]
Merge branch 'pci/msi' into next

* pci/msi:
  vfio: Use pci_enable_msi_range() and pci_enable_msix_range()
  ahci: Use pci_enable_msi_range() instead of pci_enable_msi_block()
  ahci: Fix broken fallback to single MSI mode
  PCI/MSI: Add pci_enable_msi_exact() and pci_enable_msix_exact()
  PCI/MSI: Fix cut-and-paste errors in documentation
  PCI/MSI: Add pci_enable_msi() documentation back
  PCI/MSI: Fix pci_msix_vec_count() htmldocs failure
  PCI/MSI: Fix leak of msi_attrs
  PCI/MSI: Check kmalloc() return value, fix leak of name

10 years agoMerge branch 'pci/virtualization' into next
Bjorn Helgaas [Fri, 14 Feb 2014 21:37:18 +0000 (14:37 -0700)]
Merge branch 'pci/virtualization' into next

* pci/virtualization:
  PCI: Enable quirks for PCIe ACS on Intel PCH root ports
  PCI: Add pci_dev_flag for ACS enable quirks
  PCI: Add device-specific PCI ACS enable

10 years agoMerge branch 'pci/scan-bridge' into next
Bjorn Helgaas [Fri, 14 Feb 2014 21:37:09 +0000 (14:37 -0700)]
Merge branch 'pci/scan-bridge' into next

* pci/scan-bridge:
  PCI: Don't scan random busses in pci_scan_bridge()
  PCI: Check for child busses which use more bus numbers than allocated
  PCI: Remove pci_fixup_parent_subordinate_busnr()
  PCI: Make sure bus number resources stay within their parents bounds
  PCI: Use request_resource_conflict() instead of insert_ for bus numbers
  PCI: Assign CardBus bus number only during the second pass
  PCI: Clarify the "scan anyway" comment in pci_scan_bridge()
  PCI: Increment max correctly in pci_scan_bridge()

10 years agovfio: Use pci_enable_msi_range() and pci_enable_msix_range()
Alexander Gordeev [Fri, 17 Jan 2014 16:02:21 +0000 (17:02 +0100)]
vfio: Use pci_enable_msi_range() and pci_enable_msix_range()

pci_enable_msix() and pci_enable_msi_block() have been deprecated; use
pci_enable_msix_range() and pci_enable_msi_range() instead.

[bhelgaas: changelog]
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
10 years agoahci: Use pci_enable_msi_range() instead of pci_enable_msi_block()
Alexander Gordeev [Wed, 29 Jan 2014 21:19:43 +0000 (14:19 -0700)]
ahci: Use pci_enable_msi_range() instead of pci_enable_msi_block()

pci_enable_msi_block() has been deprecated; use pci_enable_msi_range()
instead.

[bhelgaas: changelog]
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Tejun Heo <tj@kernel.org>
10 years agoahci: Fix broken fallback to single MSI mode
Alexander Gordeev [Fri, 17 Jan 2014 16:02:15 +0000 (17:02 +0100)]
ahci: Fix broken fallback to single MSI mode

Commit 7b92b4f61ec4 ("PCI/MSI: Remove pci_enable_msi_block_auto()")
introduced a regression: if multiple MSI initialization fails, the code
falls back to INTx rather than to single MSI.

Fixes: 7b92b4f61ec4 ("PCI/MSI: Remove pci_enable_msi_block_auto()")
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Tejun Heo <tj@kernel.org>
10 years agoia64/PCI: Set IORESOURCE_ROM_SHADOW only for the default VGA device
Sander Eikelenboom [Fri, 14 Feb 2014 18:55:13 +0000 (11:55 -0700)]
ia64/PCI: Set IORESOURCE_ROM_SHADOW only for the default VGA device

Setting the IORESOURCE_ROM_SHADOW flag on a VGA card other than the primary
prevents it from reading its own ROM.  It will get the content of the
shadow ROM at C000 instead, which is of the primary VGA card and the driver
of the secondary card will bail out.

Fix this by checking if the arch code or vga-arbitration has already
determined the vga_default_device, if so only apply the fix to this primary
video device and let the comment reflect this.

[bhelgaas: add subject, split x86 & ia64 into separate patches,
include vgaarb.h]
Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agox86/PCI: Set IORESOURCE_ROM_SHADOW only for the default VGA device
Sander Eikelenboom [Fri, 31 Jan 2014 09:28:23 +0000 (10:28 +0100)]
x86/PCI: Set IORESOURCE_ROM_SHADOW only for the default VGA device

Setting the IORESOURCE_ROM_SHADOW flag on a VGA card other than the primary
prevents it from reading its own ROM.  It will get the content of the
shadow ROM at C000 instead, which is of the primary VGA card and the driver
of the secondary card will bail out.

Fix this by checking if the arch code or vga-arbitration has already
determined the vga_default_device, if so only apply the fix to this primary
video device and let the comment reflect this.

[bhelgaas: add subject, split x86 & ia64 into separate patches]
Signed-off-by: Sander Eikelenboom <linux@eikelenboom.it>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
10 years agoPCI: Remove pci_bus_b() and use list_for_each_entry() directly
Yijing Wang [Thu, 13 Feb 2014 13:14:03 +0000 (21:14 +0800)]
PCI: Remove pci_bus_b() and use list_for_each_entry() directly

Replace list_for_each() with list_for_each_entry(), which means we no
longer need pci_bus_b() and can remove it.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: mvebu: Fix potential issue in range parsing
Jean-Jacques Hiblot [Fri, 14 Feb 2014 18:46:15 +0000 (11:46 -0700)]
PCI: mvebu: Fix potential issue in range parsing

The second parameter of of_read_number() is not the index, but a size.  As
it happens, in this case it may work just fine because of the conversion to
u32 and the favorable endianness on this architecture.

Fixes: 11be65472a427 ("PCI: mvebu: Adapt to the new device tree layout")
Tested-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@traphandler.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Cc: stable@vger.kernel.org # v3.12+
10 years agopcmcia: Use list_for_each_entry() for bus traversal
Yijing Wang [Thu, 13 Feb 2014 13:14:02 +0000 (21:14 +0800)]
pcmcia: Use list_for_each_entry() for bus traversal

Replace list_for_each() + pci_bus_b() with list_for_each_entry().

[bhelgaas: fix "silbling" typo]
Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agopowerpc/PCI: Use list_for_each_entry() for bus traversal
Yijing Wang [Thu, 13 Feb 2014 13:14:01 +0000 (21:14 +0800)]
powerpc/PCI: Use list_for_each_entry() for bus traversal

Replace list_for_each() + pci_bus_b() with list_for_each_entry().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agodrm: Use list_for_each_entry() for bus traversal
Yijing Wang [Thu, 13 Feb 2014 13:14:00 +0000 (21:14 +0800)]
drm: Use list_for_each_entry() for bus traversal

Replace list_for_each() + pci_bus_b() with list_for_each_entry().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoARM/PCI: Use list_for_each_entry() for bus traversal
Yijing Wang [Thu, 13 Feb 2014 13:13:59 +0000 (21:13 +0800)]
ARM/PCI: Use list_for_each_entry() for bus traversal

Replace list_for_each() + pci_bus_b() with list_for_each_entry().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Russell King <rmk+kernel@arm.linux.org.uk>
10 years agoACPI / hotplug / PCI: Use list_for_each_entry() for bus traversal
Yijing Wang [Thu, 13 Feb 2014 13:13:58 +0000 (21:13 +0800)]
ACPI / hotplug / PCI: Use list_for_each_entry() for bus traversal

Replace list_for_each() + pci_bus_b() with list_for_each_entry().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rjw@rjwysocki.net>
10 years agoPCI: Update outdated comment for pcibios_bus_report_status()
Yijing Wang [Thu, 13 Feb 2014 11:57:43 +0000 (19:57 +0800)]
PCI: Update outdated comment for pcibios_bus_report_status()

pci_find_device() has been superseded by pci_get_device().

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: pciehp: Don't turn slot off when hot-added device already exists
Yijing Wang [Wed, 12 Feb 2014 00:36:51 +0000 (17:36 -0700)]
PCI: pciehp: Don't turn slot off when hot-added device already exists

If we found device already exists during hot add device, we should leave
it, not turn the slot off.

Signed-off-by: Yijing Wang <wangyijing@huawei.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI/MSI: Add pci_enable_msi_exact() and pci_enable_msix_exact()
Alexander Gordeev [Thu, 13 Feb 2014 14:25:02 +0000 (15:25 +0100)]
PCI/MSI: Add pci_enable_msi_exact() and pci_enable_msix_exact()

The new functions are special cases for pci_enable_msi_range() and
pci_enable_msix_range() when a particular number of MSI or MSI-X
is needed.

By contrast with pci_enable_msi_range() and pci_enable_msix_range()
functions, pci_enable_msi_exact() and pci_enable_msix_exact()
return zero in case of success, which indicates MSI or MSI-X
interrupts have been successfully allocated.

Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI/MSI: Fix cut-and-paste errors in documentation
Alexander Gordeev [Wed, 12 Feb 2014 10:35:25 +0000 (11:35 +0100)]
PCI/MSI: Fix cut-and-paste errors in documentation

Function pci_enable_msi_range() is used in examples where
pci_enable_msix_range() should have been used instead.

Reported-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: Cleanup per-arch list of object files
Liviu Dudau [Mon, 3 Feb 2014 17:38:36 +0000 (17:38 +0000)]
PCI: Cleanup per-arch list of object files

setup-bus.o is now included unconditionally as of commit 7dc303033425
("PCI: Always build setup-bus when PCI is enabled").  Remove it from the
per-arch list of object files.

Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: cpqphp: Fix hex vs decimal typo in cpqhpc_probe()
Dan Carpenter [Mon, 10 Feb 2014 15:23:50 +0000 (18:23 +0300)]
PCI: cpqphp: Fix hex vs decimal typo in cpqhpc_probe()

This is a static checker fix and I can't test it, but from the context it
definitely looks like hexadecimal 0x20 was intended here instead of decimal
20.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agox86/PCI: Fix function definition whitespace
Bjorn Helgaas [Fri, 24 Jan 2014 17:44:42 +0000 (10:44 -0700)]
x86/PCI: Fix function definition whitespace

Consistently put the function type, name, and parameters on one line,
wrapping only as necessary.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agox86/PCI: Reword comments
Bjorn Helgaas [Fri, 24 Jan 2014 17:38:40 +0000 (10:38 -0700)]
x86/PCI: Reword comments

Reword comments so they make sense.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agox86/PCI: Remove unnecessary local variable initialization
Bjorn Helgaas [Fri, 24 Jan 2014 17:41:11 +0000 (10:41 -0700)]
x86/PCI: Remove unnecessary local variable initialization

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: mvebu: Use Device ID and revision from underlying endpoint
Andrew Lunn [Wed, 5 Feb 2014 10:55:49 +0000 (11:55 +0100)]
PCI: mvebu: Use Device ID and revision from underlying endpoint

Marvell SoCs place the SoC number into the PCIe endpoint device ID.  The
SoC stepping is placed into the PCIe revision. The old plat-orion PCIe
driver allowed this information to be seen in user space with a simple
lspci command.

The new driver places a virtual PCI-PCI bridge on top of these endpoints.
It has its own hard coded PCI device ID. Thus it is no longer possible to
see what the SoC is using lspci.

When initializing the PCI-PCI bridge, set its device ID and revision from
the underlying endpoint, thus restoring this functionality.  Debian would
like to use this in order to aid installing the correct DTB file.

Fixes: 45361a4fe4464 ("pci: PCIe driver for Marvell Armada 370/XP systems")
Signed-off-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Jason Cooper <jason@lakedaemon.net>
Cc: stable@vger.kernel.org # v3.11+
10 years agoPCI: pciehp: Add hotplug_lock to serialize hotplug events
Rajat Jain [Wed, 5 Feb 2014 02:31:11 +0000 (18:31 -0800)]
PCI: pciehp: Add hotplug_lock to serialize hotplug events

Today it is there is no protection around pciehp_enable_slot() and
pciehp_disable_slot() to ensure that they complete before another
hot-plug operation can be done on that particular slot.

This patch introduces the slot->hotplug_lock to ensure that any hotplug
operations (add / remove) complete before another hotplug event can begin
processing on that particular slot.

Signed-off-by: Rajat Jain <rajatxjain@gmail.com>
Signed-off-by: Rajat Jain <rajatjain@juniper.net>
Signed-off-by: Guenter Roeck <groeck@juniper.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: pciehp: Ensure very fast hotplug events are also processed
Rajat Jain [Wed, 5 Feb 2014 02:30:56 +0000 (18:30 -0800)]
PCI: pciehp: Ensure very fast hotplug events are also processed

Today, this is how all the hotplug and unplug events work:

Hotplug / Removal needs to be done
  => Set slot->state (protected by slot->lock) to either
    POWERON_STATE (for enabling) or POWEROFF_STATE (for disabling).
  => Submit the work item for pciehp_power_thread() to slot->wq.

Problem:
  There is a problem if the hotplug events can happen fast enough that
  they do not give SW enough time to add or remove the new devices.

  => Assume: Event for unplug comes (e.g. surprise removal). But
     before the pciehp_power_thread() work item was executed, the
     card was replaced by another card, causing surprise hotplug event.

  => What goes wrong:
    => The hot-removal event sets slot->state to POWEROFF_STATE, and
       schedules the pciehp_power_thread().
    => The hot-add event sets slot->state to POWERON_STATE, and
       schedules the pciehp_power_thread().
    => Now the pciehp_power_thread() is scheduled twice, and on both
       occasions it will find POWERON_STATE and will try to add the
       devices on the slot, and will fail complaining that the devices
       already exist.

  => Why this is a problem: If the device was replaced between the hot
     removal and hot-add, then we should unload the old driver and
     reload the new one. This does not happen today. The kernel or the
     driver is not even aware that the device was replaced.

     The problem is that the pciehp_power_thread() only looks at the
     slot->state which would only contain the *latest* state - not
     the actual event (add / remove) that was the intent of the IRQ
     handler who submitted the work.

What this patch does:

  => Hotplug events pass on an actual request (for addition or removal)
     to pciehp_power_thread() which is local to that work item
     submission.

  => pciehp_power_thread() does not need to look at slote->state and
     hence no locks needed in that.

  => Essentially this results in all the hotplug and unplug events
     "replayed" by pciehp_power_thread().

Signed-off-by: Rajat Jain <rajatxjain@gmail.com>
Signed-off-by: Rajat Jain <rajatjain@juniper.net>
Signed-off-by: Guenter Roeck <groeck@juniper.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: pciehp: Disable link notification across slot reset
Rajat Jain [Wed, 5 Feb 2014 02:30:40 +0000 (18:30 -0800)]
PCI: pciehp: Disable link notification across slot reset

Disable the link notification (in addition to presence detect
notifications) across the slot reset since the reset could flap the link,
and we don't want to treat it as hot unplug followed by a hotplug.

Signed-off-by: Rajat Jain <rajatxjain@gmail.com>
Signed-off-by: Rajat Jain <rajatjain@juniper.net>
Signed-off-by: Guenter Roeck <groeck@juniper.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: pciehp: Don't check adapter or latch status while disabling
Rajat Jain [Wed, 5 Feb 2014 02:30:21 +0000 (18:30 -0800)]
PCI: pciehp: Don't check adapter or latch status while disabling

It does not make much sense to refuse to disable a slot if an adapter is
not present or the latch is open. If an adapter is not present, it provides
an even better reason to disable the device slot.

This is specially a problem for link state hot-plug, because some ports use
in band mechanism for presence detection. Thus when link goes down,
presence detect also goes down. We _want_ that the removal should take
place in such case.

Thus remove the checks for adapter and latch in pciehp_disable_slot()

Signed-off-by: Rajat Jain <rajatxjain@gmail.com>
Signed-off-by: Rajat Jain <rajatjain@juniper.net>
Signed-off-by: Guenter Roeck <groeck@juniper.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: pciehp: Don't disable the link permanently during removal
Rajat Jain [Wed, 5 Feb 2014 02:30:04 +0000 (18:30 -0800)]
PCI: pciehp: Don't disable the link permanently during removal

We need future link up events for hot-add, thus don't disable the link
permanently during device removal. Also, remove the static functions that
are now left unused.

This reverts part of 2debd9289997 ("PCI: pciehp: Disable/enable link during
slot power off/on").  This was discussed at the URL below, where it was
revealed that it was done for a bug in a PCIe repeater chip on that
particular platform.

Link: https://lkml.kernel.org/r/CAErSpo72KZ-a2OSQLWoK71GCgwBt676XZdGt4tEYm-6UYnLmPw@mail.gmail.com
Signed-off-by: Rajat Jain <rajatxjain@gmail.com>
Signed-off-by: Rajat Jain <rajatjain@juniper.net>
Signed-off-by: Guenter Roeck <groeck@juniper.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: pciehp: Enable link state change notifications
Rajat Jain [Wed, 5 Feb 2014 02:29:23 +0000 (18:29 -0800)]
PCI: pciehp: Enable link state change notifications

Enable the Link state notifications unconditionally. Enable the
presence detection notification only if attention button is absent.
This was discussed at this thread:
    https://lkml.kernel.org/r/529E5C0E.80903@gmail.com

Signed-off-by: Rajat Jain <rajatxjain@gmail.com>
Signed-off-by: Rajat Jain <rajatjain@juniper.net>
Signed-off-by: Guenter Roeck <groeck@juniper.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: Don't scan random busses in pci_scan_bridge()
Andreas Noever [Thu, 23 Jan 2014 20:59:28 +0000 (21:59 +0100)]
PCI: Don't scan random busses in pci_scan_bridge()

When assigning a new bus number in pci_scan_bridge we check whether
max+1 is free by calling pci_find_bus. If it does already exist then we
assume that we are rescanning and that this is the right bus to scan.

This is fragile. If max+1 lies outside of bus->busn_res.end then we will
rescan some random bus from somewhere else in the hierachy. This patch
checks for this case and prints a warning.

[bhelgaas: add parent/child bus number info to dev_warn()]
Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: Check for child busses which use more bus numbers than allocated
Andreas Noever [Thu, 23 Jan 2014 20:59:27 +0000 (21:59 +0100)]
PCI: Check for child busses which use more bus numbers than allocated

pci_scan_child_bus can (potentially) return a bus number higher than the
subordinate value of the child bus. Possible reasons are that bus numbers
are reserved for SR-IOV or for CardBus (SR-IOV is done without checks and
the CardBus checks are sketchy at best).

We clamp the returned value to the actual subordinate value and print a
warning if too many bus numbers are reserved.

[bhelgaas: whitespace]
Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: Remove pci_fixup_parent_subordinate_busnr()
Andreas Noever [Thu, 23 Jan 2014 20:59:26 +0000 (21:59 +0100)]
PCI: Remove pci_fixup_parent_subordinate_busnr()

The function has no effect.

If pcibios_assign_all_busses() is not set then the function does nothing.

If it is set then in pci_scan_bridge we are always in the branch where
we assign the bus numbers ourselves and the subordinate values of all
parent busses will be set to 0xff since that is what they inherited from
their parent bus and ultimately from the root bus.

Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: Enable quirks for PCIe ACS on Intel PCH root ports
Alex Williamson [Mon, 3 Feb 2014 21:27:46 +0000 (14:27 -0700)]
PCI: Enable quirks for PCIe ACS on Intel PCH root ports

Many of the currently available Intel PCH-based root ports do not provide
PCIe ACS capabilities.  Without this, we must assume that peer-to-peer
traffic between multifunction root ports and between devices behind root
ports is possible.  This lack of isolation is exposed by grouping the
devices together in the same IOMMU group.  If we want to expose these
devices to userspace, vfio uses IOMMU groups as the unit of ownership, thus
making it very difficult to assign individual devices to separate users.

The good news is that the chipset does provide ACS-like isolation
capabilities, but we do need to verify and enable those capabilities if the
BIOS has not done so.  This patch implements the device specific enabling
and testing of equivalent ACS function for these devices.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Don Dugger <donald.d.dugger@intel.com>
10 years agoPCI: Add pci_dev_flag for ACS enable quirks
Alex Williamson [Mon, 3 Feb 2014 21:27:39 +0000 (14:27 -0700)]
PCI: Add pci_dev_flag for ACS enable quirks

Quirks that enable ACS-compatible functionality on a device need some way
to track whether a given device has been enabled.  Rather than create new
data structures for this, allocate one of the pci_dev_flags to indicate
this setup.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: Add device-specific PCI ACS enable
Alex Williamson [Mon, 3 Feb 2014 21:27:33 +0000 (14:27 -0700)]
PCI: Add device-specific PCI ACS enable

Some devices support PCI ACS-like features, but don't report it using the
standard PCIe capabilities.  We already provide hooks for device-specific
testing of ACS, but not for device-specific enabling of ACS.  This provides
that setup hook.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: pciehp: Use link change notifications for hot-plug and removal
Rajat Jain [Wed, 5 Feb 2014 02:29:10 +0000 (18:29 -0800)]
PCI: pciehp: Use link change notifications for hot-plug and removal

A lot of systems do not have the fancy buttons and LEDs, and instead
want to rely only on the Link state change events to drive the hotplug
and removal state machinery.
(http://www.spinics.net/lists/hotplug/msg05802.html)

This patch adds support for that functionality. Here are the details
about the patch itself:

* Define and use interrupt events for linkup / linkdown.

* Make the pcie_isr() also look at link events, and direct control to
  corresponding (new) link state change handler function.

* Introduce the functions to handle link-up and link-down events and
  queue the add / removal work in the slot->wq to be processed by
  pciehp_power_thread()

As a side note, this patch also fixes the bug
https://bugzilla.kernel.org/show_bug.cgi?id=65521 "pciehp ignores Data Link
Layer State Changed bit."

Signed-off-by: Rajat Jain <rajatxjain@gmail.com>
Signed-off-by: Rajat Jain <rajatjain@juniper.net>
Signed-off-by: Guenter Roeck <groeck@juniper.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: pciehp: Make check_link_active() non-static
Rajat Jain [Wed, 5 Feb 2014 02:28:43 +0000 (18:28 -0800)]
PCI: pciehp: Make check_link_active() non-static

check_link_active() functionality needs to be used by subsequent patches
(that introduce link state change based hotplug). Thus make the function
non-static, and rename it to pciehp_check_link_active() so as to be
consistent with other non-static functions.

Signed-off-by: Rajat Jain <rajatxjain@gmail.com>
Signed-off-by: Rajat Jain <rajatjain@juniper.net>
Signed-off-by: Guenter Roeck <groeck@juniper.net>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: Make sure bus number resources stay within their parents bounds
Andreas Noever [Thu, 23 Jan 2014 20:59:25 +0000 (21:59 +0100)]
PCI: Make sure bus number resources stay within their parents bounds

Right now we use 0xff for busn_res.end when probing and later reduce it to
the value that is actually used. This does not work if a parent bridge has
already a lower subordinate value. For example during hotplug of a new
bridge below an already-configured bridge the following message is printed
from pci_bus_insert_busn_res():

  pci_bus 0000:06: busn_res: can not insert [bus 06-ff] under [bus 05-9b] (conflicts with (null) [bus 05-9b])

This patch clamps the bus range to that of the parent and also ensures that
we do not exceed the parents range when assigning the final subordinate
value.

We also check that busses configured by the firmware fit into their parents
bounds.

[bhelgaas: reword dev_warn() and fix printk format warning]
Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: Use request_resource_conflict() instead of insert_ for bus numbers
Andreas Noever [Thu, 23 Jan 2014 20:59:24 +0000 (21:59 +0100)]
PCI: Use request_resource_conflict() instead of insert_ for bus numbers

If a conflict happens during insert_resource_conflict() and all conflicts
fit within the newly inserted resource then they will become children of
the new resource. This is almost certainly not what we want for bus
numbers.

Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: Assign CardBus bus number only during the second pass
Andreas Noever [Thu, 23 Jan 2014 20:59:23 +0000 (21:59 +0100)]
PCI: Assign CardBus bus number only during the second pass

Right now the CardBus code in pci_scan_bridge() is executed during both
passes. Since we always allocate the bus number ourselves it makes sense
to put it into the second pass.

Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: Clarify the "scan anyway" comment in pci_scan_bridge()
Andreas Noever [Thu, 23 Jan 2014 20:59:22 +0000 (21:59 +0100)]
PCI: Clarify the "scan anyway" comment in pci_scan_bridge()

Initially when we encountered a bus that was already present we skipped
it. Since 74710ded8e16 'PCI: always scan child buses' we continue
scanning in order to allow user triggered rescans of already existing
busses.

The old comment suggested that the reason for continuing the scan is a
bug in the i450NX chipset. This is not the case.

Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: Increment max correctly in pci_scan_bridge()
Andreas Noever [Thu, 23 Jan 2014 20:59:21 +0000 (21:59 +0100)]
PCI: Increment max correctly in pci_scan_bridge()

This patch fixes two small issues:
 - If pci_add_new_bus() fails, max must not be incremented. Otherwise
   an incorrect value is returned from pci_scan_bridge().
 - If the bus is already present, max must be incremented. I think
   that this case should only be hit if we trigger a manual rescan of a
   CardBus bridge.

Signed-off-by: Andreas Noever <andreas.noever@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI: Remove unnecessary list_empty(&pci_pme_list) check
Bjorn Helgaas [Fri, 24 Jan 2014 16:51:06 +0000 (09:51 -0700)]
PCI: Remove unnecessary list_empty(&pci_pme_list) check

list_for_each_entry() handles empty lists just fine, so there's no need to
check whether the list is empty first.

No functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rjw@rjwysocki.net>
10 years agoPCI/MSI: Add pci_enable_msi() documentation back
Alexander Gordeev [Fri, 17 Jan 2014 09:26:20 +0000 (10:26 +0100)]
PCI/MSI: Add pci_enable_msi() documentation back

We deprecated pci_enable_msi() in 302a2523c277 ("PCI/MSI: Add
pci_enable_msi_range() and pci_enable_msix_range()").

But we changed our minds after noticing that:

  - pci_enable_msi() doesn't have confusing return values like
    pci_enable_msi_block() and pci_enable_msix() did, and

  - pci_enable_msi() has a hundred or so callers that we don't want to
    change.

This adds back the pci_enable_msi() documentation.

[bhelgaas: changelog]
Signed-off-by: Alexander Gordeev <agordeev@redhat.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI/MSI: Fix pci_msix_vec_count() htmldocs failure
Masanari Iida [Mon, 20 Jan 2014 15:42:55 +0000 (00:42 +0900)]
PCI/MSI: Fix pci_msix_vec_count() htmldocs failure

An empty line in msi.c caused "make htmldocs" failure:

  Warning(/home/iida/Repo/linux-next//drivers/pci/msi.c:962): bad line:

Fixes: ff1aa430a2fa ("PCI/MSI: Add pci_msix_vec_count()")
Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoPCI/MSI: Fix leak of msi_attrs
Greg Kroah-Hartman [Thu, 23 Jan 2014 20:01:12 +0000 (12:01 -0800)]
PCI/MSI: Fix leak of msi_attrs

Coverity reported that I forgot to clean up some allocated memory on the
error path in populate_msi_sysfs(), so this patch fixes that.

Thanks to Dave Jones for pointing out where the error was, I obviously
can't read code this morning...

Found by Coverity (CID 1163317).

Fixes: 1c51b50c2995 ("PCI/MSI: Export MSI mode using attributes, not kobjects")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Cc: Dave Jones <davej@redhat.com>
10 years agoPCI/MSI: Check kmalloc() return value, fix leak of name
Greg Kroah-Hartman [Thu, 23 Jan 2014 19:30:37 +0000 (11:30 -0800)]
PCI/MSI: Check kmalloc() return value, fix leak of name

Coverity reported that I forgot to check the return value of kmalloc() when
creating the MSI attribute name, so fix that up and properly free it if
there is an error when allocating the msi_dev_attr variable.

Found by Coverity (CID 1163315 and 1163316).

Fixes: 1c51b50c2995 ("PCI/MSI: Export MSI mode using attributes, not kobjects")
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
10 years agoMerge branch 'pci/numa-cleanup' into next
Bjorn Helgaas [Mon, 3 Feb 2014 18:45:03 +0000 (10:45 -0800)]
Merge branch 'pci/numa-cleanup' into next

* pci/numa-cleanup:
  ACPI / numa: Use __weak, not the gcc-specific version
  ACPI / numa: Make __acpi_map_pxm_to_node(), acpi_get_pxm() static
  ACPI / numa: Simplify acpi_get_node() style
  ACPI / numa: Fix acpi_get_node() prototype
  ia64: Remove acpi_get_pxm() usage
  ia64 / sba_iommu: Use NUMA_NO_NODE, not MAX_NUMNODES, for unknown node
  x86/PCI: Remove acpi_get_pxm() usage
  x86/PCI: Use NUMA_NO_NODE, not -1, for unknown node
  x86/PCI: Remove unnecessary list_empty(&pci_root_infos) check
  x86/PCI: Remove mp_bus_to_node[], set_mp_bus_to_node(), get_mp_bus_to_node()
  x86/PCI: Use x86_pci_root_bus_node() instead of get_mp_bus_to_node()
  x86/PCI: Add x86_pci_root_bus_node() to look up NUMA node from PCI bus
  x86/PCI: Drop return value of pcibios_scan_root()
  x86/PCI: Merge pci_scan_bus_on_node() into pcibios_scan_root()
  x86/PCI: Use pcibios_scan_root() instead of pci_scan_bus_on_node()
  x86/PCI: Use pcibios_scan_root() instead of pci_scan_bus_with_sysdata()
  x86/PCI: Drop pcibios_scan_root() check for bus already scanned

10 years agoACPI / numa: Use __weak, not the gcc-specific version
Bjorn Helgaas [Tue, 28 Jan 2014 00:19:15 +0000 (17:19 -0700)]
ACPI / numa: Use __weak, not the gcc-specific version

Use "__weak" instead of the gcc-specific "__attribute__ ((weak))".

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agoACPI / numa: Make __acpi_map_pxm_to_node(), acpi_get_pxm() static
Bjorn Helgaas [Fri, 24 Jan 2014 22:48:01 +0000 (15:48 -0700)]
ACPI / numa: Make __acpi_map_pxm_to_node(), acpi_get_pxm() static

__acpi_map_pxm_to_node() and acpi_get_pxm() are only used within
drivers/acpi/numa.c.  This makes them static and removes their
declarations.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agoACPI / numa: Simplify acpi_get_node() style
Bjorn Helgaas [Fri, 24 Jan 2014 22:42:17 +0000 (15:42 -0700)]
ACPI / numa: Simplify acpi_get_node() style

Simplify control flow by removing local variable initialization and
returning a constant as soon as possible.  No functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agoACPI / numa: Fix acpi_get_node() prototype
Bjorn Helgaas [Fri, 24 Jan 2014 22:25:10 +0000 (15:25 -0700)]
ACPI / numa: Fix acpi_get_node() prototype

acpi_get_node() takes an acpi_handle, not an "acpi_handle *".  This
fixes the prototype and the definitions.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agoia64: Remove acpi_get_pxm() usage
Bjorn Helgaas [Fri, 24 Jan 2014 22:28:42 +0000 (15:28 -0700)]
ia64: Remove acpi_get_pxm() usage

The IOMMU, LSAPIC, IOSAPIC, and PCI host bridge code doesn't care about
_PXM values directly; it only needs to know what NUMA node the hardware is
on.

This uses acpi_get_node() directly and removes the _PXM stuff.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agoia64 / sba_iommu: Use NUMA_NO_NODE, not MAX_NUMNODES, for unknown node
Bjorn Helgaas [Fri, 24 Jan 2014 21:42:33 +0000 (14:42 -0700)]
ia64 / sba_iommu: Use NUMA_NO_NODE, not MAX_NUMNODES, for unknown node

MAX_NUMNODES is typically used for sizing arrays.  NUMA_NO_NODE is the
usual value for "we don't know what node this is on," e.g., it is the
error return from acpi_get_node().

This changes the ioc->node value for unknown nodes from MAX_NUMNODES to
NUMA_NO_NODE.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agox86/PCI: Remove acpi_get_pxm() usage
Bjorn Helgaas [Fri, 24 Jan 2014 21:40:46 +0000 (14:40 -0700)]
x86/PCI: Remove acpi_get_pxm() usage

The PCI host bridge code doesn't care about _PXM values directly; it only
needs to know what NUMA node the hardware is on.

This uses acpi_get_node() directly and removes the _PXM stuff.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agox86/PCI: Use NUMA_NO_NODE, not -1, for unknown node
Bjorn Helgaas [Fri, 24 Jan 2014 21:51:49 +0000 (14:51 -0700)]
x86/PCI: Use NUMA_NO_NODE, not -1, for unknown node

NUMA_NO_NODE is the usual value for "we don't know what node this is on,"
e.g., it is the error return from acpi_get_node().  This changes uses of -1
to NUMA_NO_NODE.  NUMA_NO_NODE is #defined to be -1 already, so this is not
a functional change.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agox86/PCI: Remove unnecessary list_empty(&pci_root_infos) check
Bjorn Helgaas [Fri, 24 Jan 2014 18:57:18 +0000 (11:57 -0700)]
x86/PCI: Remove unnecessary list_empty(&pci_root_infos) check

list_for_each_entry() handles empty lists, so there's no need to check
whether the list is empty first.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agox86/PCI: Remove mp_bus_to_node[], set_mp_bus_to_node(), get_mp_bus_to_node()
Bjorn Helgaas [Fri, 24 Jan 2014 18:56:06 +0000 (11:56 -0700)]
x86/PCI: Remove mp_bus_to_node[], set_mp_bus_to_node(), get_mp_bus_to_node()

There are no callers of get_mp_bus_to_node(), so we no longer need
mp_bus_to_node[], get_mp_bus_to_node(), or set_mp_bus_to_node().
This removes them.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agox86/PCI: Use x86_pci_root_bus_node() instead of get_mp_bus_to_node()
Bjorn Helgaas [Fri, 24 Jan 2014 18:54:51 +0000 (11:54 -0700)]
x86/PCI: Use x86_pci_root_bus_node() instead of get_mp_bus_to_node()

This replaces all uses of get_mp_bus_to_node() with x86_pci_root_bus_node().

I think these uses are all on root buses, except possibly for blind
probing, where NUMA node information is unimportant.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agox86/PCI: Add x86_pci_root_bus_node() to look up NUMA node from PCI bus
Bjorn Helgaas [Fri, 24 Jan 2014 18:54:36 +0000 (11:54 -0700)]
x86/PCI: Add x86_pci_root_bus_node() to look up NUMA node from PCI bus

The AMD early_fill_mp_bus_info() already allocates a struct pci_root_info
for each PCI host bridge it finds, and that structure contains the NUMA
node number.  We don't need to keep the same information in the
mp_bus_to_node[] table.

This adds x86_pci_root_bus_node(), which returns the NUMA node number, or
NUMA_NO_NODE if the node is unknown.

Note that unlike get_mp_bus_to_node(), x86_pci_root_bus_node() only works
for root buses.  For example, if amd_bus.c finds a host bridge on node 1 to
[bus 00-0f], get_mp_bus_to_node() returns 1 for any bus between 00 and 0f,
but x86_pci_root_bus_node() returns 1 for bus 00 and NUMA_NO_NODE for buses
01-0f.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agox86/PCI: Drop return value of pcibios_scan_root()
Bjorn Helgaas [Tue, 28 Jan 2014 23:40:36 +0000 (16:40 -0700)]
x86/PCI: Drop return value of pcibios_scan_root()

Nobody really uses the return value of pcibios_scan_root() (one place uses
it to control a printk, but the printk is not very useful).  This converts
pcibios_scan_root() to a void function.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agox86/PCI: Merge pci_scan_bus_on_node() into pcibios_scan_root()
Bjorn Helgaas [Fri, 24 Jan 2014 18:52:25 +0000 (11:52 -0700)]
x86/PCI: Merge pci_scan_bus_on_node() into pcibios_scan_root()

pci_scan_bus_on_node() is only called by pcibios_scan_root().
This merges pci_scan_bus_on_node() into pcibios_scan_root() and removes
pci_scan_bus_on_node().

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agox86/PCI: Use pcibios_scan_root() instead of pci_scan_bus_on_node()
Bjorn Helgaas [Fri, 24 Jan 2014 18:50:48 +0000 (11:50 -0700)]
x86/PCI: Use pcibios_scan_root() instead of pci_scan_bus_on_node()

pcibios_scan_root() looks up the bus's NUMA node, then calls
pci_scan_bus_on_node().  This uses pcibios_scan_root() directly and drops
the node lookup in the callers.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agox86/PCI: Use pcibios_scan_root() instead of pci_scan_bus_with_sysdata()
Bjorn Helgaas [Fri, 24 Jan 2014 18:47:05 +0000 (11:47 -0700)]
x86/PCI: Use pcibios_scan_root() instead of pci_scan_bus_with_sysdata()

pci_scan_bus_with_sysdata() and pcibios_scan_root() are quite similar:

  pci_scan_bus_with_sysdata
    pci_scan_bus_on_node(..., &pci_root_ops, -1)

  pcibios_scan_root
    pci_scan_bus_on_node(..., &pci_root_ops, get_mp_bus_to_node(busnum))

get_mp_bus_to_node() returns -1 if it couldn't find the node number, so
this removes pci_scan_bus_with_sysdata() and uses pcibios_scan_root()
instead.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agox86/PCI: Drop pcibios_scan_root() check for bus already scanned
Bjorn Helgaas [Tue, 28 Jan 2014 23:28:21 +0000 (16:28 -0700)]
x86/PCI: Drop pcibios_scan_root() check for bus already scanned

The PCI core checks to see whether we've already scanned a bus, so we don't
need to do it in pcibios_scan_root().  Here's where it happens in the core:

  pcibios_scan_root
    pci_scan_bus_on_node
      pci_scan_root_bus
        pci_create_root_bus
  b2 = pci_find_bus(pci_domain_nr(b), bus)
  if (b2)
    goto err_out;    # already scanned this bus

This removes the check from pcibios_scan_root().

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
10 years agoLinus 3.14-rc1 v3.14-rc1
Linus Torvalds [Mon, 3 Feb 2014 00:42:13 +0000 (16:42 -0800)]
Linus 3.14-rc1

10 years agoMerge branch 'parisc-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/deller...
Linus Torvalds [Mon, 3 Feb 2014 00:32:53 +0000 (16:32 -0800)]
Merge branch 'parisc-3.14' of git://git./linux/kernel/git/deller/parisc-linux

Pull parisc updates from Helge Deller:
 "The three major changes in this patchset is a implementation for
  flexible userspace memory maps, cache-flushing fixes (again), and a
  long-discussed ABI change to make EWOULDBLOCK the same value as
  EAGAIN.

  parisc has been the only platform where we had EWOULDBLOCK != EAGAIN
  to keep HP-UX compatibility.  Since we will probably never implement
  full HP-UX support, we prefer to drop this compatibility to make it
  easier for us with Linux userspace programs which mostly never checked
  for both values.  We don't expect major fall-outs because of this
  change, and if we face some, we will simply rebuild the necessary
  applications in the debian archives"

* 'parisc-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
  parisc: add flexible mmap memory layout support
  parisc: Make EWOULDBLOCK be equal to EAGAIN on parisc
  parisc: convert uapi/asm/stat.h to use native types only
  parisc: wire up sched_setattr and sched_getattr
  parisc: fix cache-flushing
  parisc/sti_console: prefer Linux fonts over built-in ROM fonts

10 years agohpfs: optimize quad buffer loading
Mikulas Patocka [Tue, 28 Jan 2014 23:11:33 +0000 (00:11 +0100)]
hpfs: optimize quad buffer loading

HPFS needs to load 4 consecutive 512-byte sectors when accessing the
directory nodes or bitmaps.  We can't switch to 2048-byte block size
because files are allocated in the units of 512-byte sectors.

Previously, the driver would allocate a 2048-byte area using kmalloc,
copy the data from four buffers to this area and eventually copy them
back if they were modified.

In the current implementation of the buffer cache, buffers are allocated
in the pagecache.  That means that 4 consecutive 512-byte buffers are
stored in consecutive areas in the kernel address space.  So, we don't
need to allocate extra memory and copy the content of the buffers there.

This patch optimizes the code to avoid copying the buffers.  It checks
if the four buffers are stored in contiguous memory - if they are not,
it falls back to allocating a 2048-byte area and copying data there.

Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
10 years agohpfs: remember free space
Mikulas Patocka [Tue, 28 Jan 2014 23:10:44 +0000 (00:10 +0100)]
hpfs: remember free space

Previously, hpfs scanned all bitmaps each time the user asked for free
space using statfs.  This patch changes it so that hpfs scans the
bitmaps only once, remembes the free space and on next invocation of
statfs it returns the value instantly.

New versions of wine are hammering on the statfs syscall very heavily,
making some games unplayable when they're stored on hpfs, with load
times in minutes.

This should be backported to the stable kernels because it fixes
user-visible problem (excessive level load times in wine).

Signed-off-by: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Cc: stable@vger.kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
10 years agoparisc: add flexible mmap memory layout support
Helge Deller [Fri, 31 Jan 2014 21:19:52 +0000 (22:19 +0100)]
parisc: add flexible mmap memory layout support

Add support for the flexible mmap memory layout (as described in
http://lwn.net/Articles/91829). This is especially very interesting on
parisc since we currently only support 32bit userspace (even with a
64bit Linux kernel).

Signed-off-by: Helge Deller <deller@gmx.de>
10 years agoparisc: Make EWOULDBLOCK be equal to EAGAIN on parisc
Guy Martin [Thu, 16 Jan 2014 16:17:53 +0000 (17:17 +0100)]
parisc: Make EWOULDBLOCK be equal to EAGAIN on parisc

On Linux, only parisc uses a different value for EWOULDBLOCK which
causes a lot of troubles for applications not checking for both values.
Since the hpux compat is long dead, make EWOULDBLOCK behave the same as
all other architectures.

Signed-off-by: Guy Martin <gmsoft@tuxicoman.be>
Signed-off-by: Helge Deller <deller@gmx.de>
10 years agoparisc: convert uapi/asm/stat.h to use native types only
Helge Deller [Fri, 31 Jan 2014 22:00:38 +0000 (23:00 +0100)]
parisc: convert uapi/asm/stat.h to use native types only

The stat.h header file is exported to userspace. Some userspace
applications failed to compile due to missing/unknown types, so we
better convert it to use native types only (like it's done on other
architectures too).

Signed-off-by: Helge Deller <deller@gmx.de>
10 years agoparisc: wire up sched_setattr and sched_getattr
Helge Deller [Fri, 31 Jan 2014 21:29:17 +0000 (22:29 +0100)]
parisc: wire up sched_setattr and sched_getattr

Signed-off-by: Helge Deller <deller@gmx.de>
10 years agoparisc: fix cache-flushing
Helge Deller [Fri, 31 Jan 2014 20:33:17 +0000 (21:33 +0100)]
parisc: fix cache-flushing

This commit:
f8dae00684d678afa13041ef170cecfd1297ed40: parisc: Ensure full cache coherency for kmap/kunmap
caused negative caching side-effects, e.g. hanging processes with expect and
too many inequivalent alias messages from flush_dcache_page() on Debian 5 systems.

This patch now partly reverts it and has been in production use on our debian buildd
makeservers since a week without any major problems.

Signed-off-by: Helge Deller <deller@gmx.de>
Signed-off-by: John David Anglin <dave.anglin@bell.net>
Cc: stable@vger.kernel.org # v3.9+
Signed-off-by: Helge Deller <deller@gmx.de>
10 years agoparisc/sti_console: prefer Linux fonts over built-in ROM fonts
Helge Deller [Fri, 31 Jan 2014 14:39:40 +0000 (15:39 +0100)]
parisc/sti_console: prefer Linux fonts over built-in ROM fonts

The built-in ROM fonts lack many necessary ASCII characters, which is
why it makes sens to prefer the Linux fonts instead if they are
available.  This makes consoles on STI graphics cards which are not
supported by the stifb driver (e.g. Visualize FXe) looks much nicer.

Signed-off-by: Helge Deller <deller@gmx.de>
Cc: stable@vger.kernel.org # v3.13
10 years agoMerge branch 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelv...
Linus Torvalds [Sun, 2 Feb 2014 19:30:57 +0000 (11:30 -0800)]
Merge branch 'hwmon-for-linus' of git://git./linux/kernel/git/jdelvare/staging

Pull hwmon kconfig fixes from Jean Delvare.

* 'hwmon-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jdelvare/staging:
  hwmon: Fix SENSORS_TMP102 dependencies to eliminate build errors
  hwmon: Fix SENSORS_LM75 dependencies to eliminate build errors

10 years agoMerge branch 'slab/next' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg...
Linus Torvalds [Sun, 2 Feb 2014 19:30:08 +0000 (11:30 -0800)]
Merge branch 'slab/next' of git://git./linux/kernel/git/penberg/linux

Pull SLAB changes from Pekka Enberg:
 "Random bug fixes that have accumulated in my inbox over the past few
  months"

* 'slab/next' of git://git.kernel.org/pub/scm/linux/kernel/git/penberg/linux:
  mm: Fix warning on make htmldocs caused by slab.c
  mm: slub: work around unneeded lockdep warning
  mm: sl[uo]b: fix misleading comments
  slub: Fix possible format string bug.
  slub: use lockdep_assert_held
  slub: Fix calculation of cpu slabs
  slab.h: remove duplicate kmalloc declaration and fix kernel-doc warnings

10 years agoMerge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux
Linus Torvalds [Sun, 2 Feb 2014 19:28:48 +0000 (11:28 -0800)]
Merge branch 'release' of git://git./linux/kernel/git/lenb/linux

Pull turbostat updates from Len Brown.

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux:
  tools/power turbostat: introduce -s to dump counters
  tools/power turbostat: remove unused command line option
  turbostat: Add option to report joules consumed per sample
  turbostat: run on HSX
  turbostat: Add a .gitignore to ignore the compiled turbostat binary
  turbostat: Clean up error handling; disambiguate error messages; use err and errx
  turbostat: Factor out common function to open file and exit on failure
  turbostat: Add a helper to parse a single int out of a file
  turbostat: Check return value of fscanf
  turbostat: Use GCC's CPUID functions to support PIC
  turbostat: Don't attempt to printf an off_t with %zx
  turbostat: Don't put unprocessed uapi headers in the include path

10 years agoMerge tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm...
Linus Torvalds [Sun, 2 Feb 2014 19:11:06 +0000 (11:11 -0800)]
Merge tag 'fixes-for-linus' of git://git./linux/kernel/git/arm/arm-soc

Pull ARM SoC fixes from Olof Johansson:
 "Here's a set of patches for (hopefully) -rc1.  Some of them are fixes,
  but a good number of them also do things such as enable new drivers in
  the defconfigs for platforms that have such devices, increases
  coverage of the multiplatform defconfig and some DTS changes that
  plumbs up some of the devices that now have bindings and driver
  support.

  The commit dates are recent; we've mostly collected these fixes in the
  last few days but I also had to rebuild the branch yesterday to sort
  out some internal conflicts which reset the timestamps.  The changes
  should have been tested by each platform maintainer already (and few
  of them have cross-platform impact) so I'm personally not too
  concerned by it at this time"

* tag 'fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (23 commits)
  ARM: multi_v7_defconfig: remove redundant entries and re-enable TI_EDMA
  ARM: multi_v7_defconfig: add mvebu drivers
  clocksource: kona: Add basic use of external clock
  drivers: bus: fix CCI driver kcalloc call parameters swap
  ARM: dts: bcm28155-ap: Fix Card Detection GPIO
  ARM: multi_v7_defconfig: Select CONFIG_AT803X_PHY
  ARM: keystone: config: fix build warning when CONFIG_DMADEVICES is not set
  MAINTAINERS: ARM: SiRF: use regex patterns to involve all SiRF drivers
  ARM: dts: zynq: Add SDHCI nodes
  ARM: hisi: don't select SMP
  ARM: tegra: rebuild tegra_defconfig to add DEBUG_FS
  ARM: multi_v7: copy most options from tegra_defconfig
  ARM: iop32x: fix power off handling for the EM7210 board
  ARM: integrator: restore static map on the CP
  ARM: msm_defconfig: Enable MSM clock drivers
  ARM: dts: msm: Add clock controller nodes and hook into uart
  ARM: OMAP4+: move errata initialization to omap4_pm_init_early
  ARM: OMAP4460: cpuidle: Extend PM_OMAP4_ROM_SMP_BOOT_ERRATUM_GICD on cpuidle
  ARM: mvebu: fix compilation warning on Armada 370 (i.e. non-SMP)
  ARM: shmobile: r8a7790.dtsi: ficx i2c[0-3] clock reference
  ...

10 years agohwmon: Fix SENSORS_TMP102 dependencies to eliminate build errors
Jean Delvare [Sun, 2 Feb 2014 16:59:07 +0000 (17:59 +0100)]
hwmon: Fix SENSORS_TMP102 dependencies to eliminate build errors

Similar to what was done for the lm75 driver.

Add depends on THERMAL since that is what provides the
register/unregister functions above, but only if THERMAL_OF was
selected as this is an optional feature of the driver.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Eduardo Valentin <eduardo.valentin@ti.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
10 years agohwmon: Fix SENSORS_LM75 dependencies to eliminate build errors
Jean Delvare [Sun, 2 Feb 2014 16:59:07 +0000 (17:59 +0100)]
hwmon: Fix SENSORS_LM75 dependencies to eliminate build errors

Based on an earlier attempt by Randy Dunlap.

Fix SENSORS_LM75 dependencies to eliminate build errors:

drivers/built-in.o: In function `lm75_remove':
lm75.c:(.text+0x12bd8c): undefined reference to `thermal_zone_of_sensor_unregister'
drivers/built-in.o: In function `lm75_probe':
lm75.c:(.text+0x12c123): undefined reference to `thermal_zone_of_sensor_register'

Add depends on THERMAL since that is what provides the
register/unregister functions above, but only if THERMAL_OF was
selected as this is an optional feature of the driver.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Eduardo Valentin <eduardo.valentin@ti.com>
Reviewed-by: Guenter Roeck <linux@roeck-us.net>
10 years agotools/power turbostat: introduce -s to dump counters
Andy Shevchenko [Thu, 23 Jan 2014 15:13:15 +0000 (17:13 +0200)]
tools/power turbostat: introduce -s to dump counters

The new option allows just run turbostat and get dump of counter values. It's
useful when we have something more than one program to test.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
10 years agotools/power turbostat: remove unused command line option
Andy Shevchenko [Thu, 23 Jan 2014 15:13:14 +0000 (17:13 +0200)]
tools/power turbostat: remove unused command line option

The -s is not used, let's remove it, and update quick help accordingly.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
10 years agoMerge branch 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Linus Torvalds [Sat, 1 Feb 2014 19:03:16 +0000 (11:03 -0800)]
Merge branch 'misc' of git://git./linux/kernel/git/mmarek/kbuild

Pull misc kbuild changes from Michal Marek:
 "The non-critical part of kbuild is small this time:
   - Three fixes for make deb-pkg
   - A new coccinelle check

  One of the deb-pkg fixes is a leftover from the last merge window,
  hence the merge commit"

* 'misc' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild:
  deb-pkg: Fix building for MIPS big-endian or ARM OABI
  deb-pkg: Fix cross-building linux-headers package
  scripts: Coccinelle script for pm_runtime_* return checks with IS_ERR_VALUE
  deb-pkg: Inhibit initramfs builders if CONFIG_BLK_DEV_INITRD is not set

10 years agoafs: proc cells and rootcell are writeable
Pali Rohár [Tue, 28 Jan 2014 20:26:44 +0000 (20:26 +0000)]
afs: proc cells and rootcell are writeable

Both proc files are writeable and used for configuring cells. But
there is missing correct mode flag for writeable files. Without
this patch both proc files are read only.

[ It turns out they aren't really read-only, since root can write to
  them even if the write bit isn't set due to CAP_DAC_OVERRIDE ]

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
10 years agotile: remove compat_sys_lookup_dcookie declaration to fix compile error
Heiko Carstens [Fri, 31 Jan 2014 06:50:36 +0000 (07:50 +0100)]
tile: remove compat_sys_lookup_dcookie declaration to fix compile error

With commit d8d14bd09cdd ("fs/compat: fix lookup_dcookie() parameter
handling") I changed the type of the len parameter of the
lookup_dcookie() syscall.

However I missed that there was still a stale declaration in
arch/tile/..  which now causes a compile error on tile:

  In file included from fs/dcookies.c:28:0:
  include/linux/compat.h:425:17: error: conflicting types for 'compat_sys_lookup_dcookie'
  fs/dcookies.c:207:1: error: conflicting types for 'compat_sys_lookup_dcookie'

Simply remove the declaration in the tile architecture, which is only a
leftover from before the different compat lookup_dcookie() versions have
been merged.  The correct declaration is now in include/linux/compat.h

The build error was reported by Fenguang's build bot.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Acked-by: Chris Metcalf <cmetcalf@tilera.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
10 years agoMerge branch 'for-linus' of git://git.samba.org/sfrench/cifs-2.6
Linus Torvalds [Sat, 1 Feb 2014 18:52:45 +0000 (10:52 -0800)]
Merge branch 'for-linus' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs fixes from Steve French:
 "A set of cifs fixes (mostly for symlinks, and SMB2 xattrs) and
  cleanups"

* 'for-linus' of git://git.samba.org/sfrench/cifs-2.6:
  cifs: Fix check for regular file in couldbe_mf_symlink()
  [CIFS] Fix SMB2 mounts so they don't try to set or get xattrs via cifs
  CIFS: Cleanup cifs open codepath
  CIFS: Remove extra indentation in cifs_sfu_type
  CIFS: Cleanup cifs_mknod
  CIFS: Cleanup CIFSSMBOpen
  cifs: Add support for follow_link on dfs shares under posix extensions
  cifs: move unix extension call to cifs_query_symlink()
  cifs: Re-order M-F Symlink code
  cifs: Add create MFSymlinks to protocol ops struct
  cifs: use protocol specific call for query_mf_symlink()
  cifs: Rename MF symlink function names
  cifs: Rename and cleanup open_query_close_cifs_symlink()
  cifs: Fix memory leak in cifs_hardlink()