cascardo/linux.git
7 years agoPCI: xgene: Remove unused platform data
Bjorn Helgaas [Thu, 6 Oct 2016 18:43:42 +0000 (13:43 -0500)]
PCI: xgene: Remove unused platform data

The xgene driver never uses the platform drvdata pointer, so don't
bother setting it.  No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: xgene: Add local struct device pointers
Bjorn Helgaas [Thu, 6 Oct 2016 18:43:42 +0000 (13:43 -0500)]
PCI: xgene: Add local struct device pointers

Use a local "struct device *dev" for brevity and consistency with other
drivers.  No functional change intended.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoMerge branch 'pci/host-vmd' into next
Bjorn Helgaas [Wed, 5 Oct 2016 19:00:21 +0000 (14:00 -0500)]
Merge branch 'pci/host-vmd' into next

* pci/host-vmd:
  x86/PCI: VMD: Move VMD driver to drivers/pci/host
  x86/PCI: VMD: Synchronize with RCU freeing MSI IRQ descs
  x86/PCI: VMD: Eliminate index member from IRQ list
  x86/PCI: VMD: Eliminate vmd_vector member from list type
  x86/PCI: VMD: Convert to use pci_alloc_irq_vectors() API
  x86/PCI: VMD: Allocate IRQ lists with correct MSI-X count
  PCI: Use positive flags in pci_alloc_irq_vectors()
  PCI: Update "pci=resource_alignment" documentation

Conflicts:
drivers/pci/host/Kconfig
drivers/pci/host/Makefile

7 years agoMerge branches 'pci/host-aardvark', 'pci/host-altera', 'pci/host-artpec', 'pci/host...
Bjorn Helgaas [Wed, 5 Oct 2016 18:59:14 +0000 (13:59 -0500)]
Merge branches 'pci/host-aardvark', 'pci/host-altera', 'pci/host-artpec', 'pci/host-designware', 'pci/host-hv', 'pci/host-keystone', 'pci/host-rcar', 'pci/host-rockchip', 'pci/host-tegra' and 'pci/host-xilinx' into next

* pci/host-aardvark:
  PCI: aardvark: Remove redundant dev_err call in advk_pcie_probe()

* pci/host-altera:
  PCI: altera: Remove redundant platform_get_resource() return value check
  PCI: altera: Move retrain from fixup to altera_pcie_host_init()
  PCI: altera: Rework config accessors for use without a struct pci_bus
  PCI: altera: Poll for link training status after retraining the link

* pci/host-artpec:
  PCI: artpec6: Drop __init from artpec6_add_pcie_port()

* pci/host-designware:
  PCI: designware: Remove redundant platform_get_resource() return value check
  PCI: designware: Exchange viewport of `MEMORYs' and `CFGs/IOs'
  PCI: designware: Keep viewport fixed for IO transaction if num_viewport > 2
  PCI: designware: Check LTSSM training bit before deciding link is up
  PCI: designware: Add iATU Unroll feature
  PCI: designware: Wait for iATU enable
  PCI: designware: Move link wait definitions to .c file
  PCI: designware: Return data directly from dw_pcie_readl_rc()

* pci/host-hv:
  PCI: hv: Handle hv_pci_generic_compl() error case
  PCI: hv: Handle vmbus_sendpacket() failure in hv_compose_msi_msg()
  PCI: hv: Remove the unused 'wrk' in struct hv_pcibus_device
  PCI: hv: Use pci_function_description[0] in struct definitions
  PCI: hv: Use zero-length array in struct pci_packet
  PCI: hv: Use list_move_tail() instead of list_del() + list_add_tail()

* pci/host-keystone:
  PCI: keystone: Propagate request_irq() failure

* pci/host-rcar:
  PCI: rcar: Try increasing PCIe link speed to 5 GT/s at boot
  PCI: rcar: Fix some checkpatch warnings
  PCI: rcar: Add multi-MSI support
  PCI: rcar: Don't disable/unprepare clocks on prepare/enable failure
  PCI: rcar: Consolidate register space lookup and ioremap

* pci/host-rockchip:
  PCI: rockchip: Fix wrong transmitted FTS count
  PCI: rockchip: Improve the deassert sequence of four reset pins
  PCI: rockchip: Increase the Max Credit update interval
  PCI: rockchip: Add Rockchip PCIe controller support
  dt-bindings: PCI: rockchip: Add DT bindings for Rockchip PCIe controller

* pci/host-tegra:
  PCI: tegra: Use of_device_get_match_data()
  PCI: tegra: Remove redundant _data suffix

* pci/host-xilinx:
  microblaze/PCI: Add multidomain support for procfs
  PCI: xilinx: Dispose of MSI virtual IRQ
  PCI: xilinx: Clear correct MSI set bit
  PCI: xilinx: Clear interrupt register for invalid interrupt
  PCI: xilinx: Keep both legacy and MSI interrupt domain references
  PCI: xilinx-nwl: Enable all MSI interrupts using MSI mask
  PCI: xilinx-nwl: Expand error logging

Conflicts:
drivers/pci/host/pcie-xilinx.c

7 years agox86/PCI: VMD: Move VMD driver to drivers/pci/host
Keith Busch [Tue, 4 Oct 2016 17:26:37 +0000 (12:26 -0500)]
x86/PCI: VMD: Move VMD driver to drivers/pci/host

Move the driver source and Kconfig to the PCI host bridge drivers directory
and move the config option to a more appropriate sub-menu instead of
occupying the top-level location.

Update the Kconfig option with the X86_64 dependency that was implicitly
included from the previous location, and add information about the module
name when built as a loadable module.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Jon Derrick <jonathan.derrick@intel.com>
7 years agoPCI: rockchip: Fix wrong transmitted FTS count
Shawn Lin [Tue, 4 Oct 2016 17:20:22 +0000 (12:20 -0500)]
PCI: rockchip: Fix wrong transmitted FTS count

If the expected number of FTS aren't received by RC when exiting from L0s,
the LTSSM will fall into recover state, which means it will need to send TS
for retraining which makes the latency of exiting from L0s a little longer
than expected.  This issue is caused by an incorrect reset value of FTS
count on PLC1 register (offset 0x4).  The expected value for Gen1/2 should
be more than 240 and we may leave a little margin here.  Fix this before
starting Gen1 training which will make TS1 contain the correct FTS count.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rockchip: Improve the deassert sequence of four reset pins
Shawn Lin [Fri, 23 Sep 2016 02:05:59 +0000 (10:05 +0800)]
PCI: rockchip: Improve the deassert sequence of four reset pins

Per TRM, we need to deassert the four reset pins simultaneously.  Currently
the reset framework doesn't support that so we did it one by one.  It seems
no side effect found but it does impact the state machine of controller, so
sometimes the change speed bit is not set when sending training sequence
from recover state.  After the silicon RTL review from SoC guys, we don't
need to do the sequence recommended by TRM, and could just move the
deassert of mgmt_sticky_rst to the first place.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rockchip: Increase the Max Credit update interval
Rajat Jain [Fri, 23 Sep 2016 00:50:42 +0000 (17:50 -0700)]
PCI: rockchip: Increase the Max Credit update interval

Increase the likelihood of link state to automatically go to L1 and save
some power.

The default credit update interval of 7.5 us results in the rootport
sending UpdateFC-P and UpdateFC-NP packets too often, thus resulting in the
link never going to L1, and always staying in L0/L0s.  The value 24 us was
chosen after some experiments and peeking over the PCIe bus to see that we
do enter L1 substate when there is not enough traffic on the PCIe bus.

Signed-off-by: Rajat Jain <rajatja@google.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Shawn Lin <shawn.lin@rock-chips.com>
7 years agoPCI: rcar: Try increasing PCIe link speed to 5 GT/s at boot
Sergei Shtylyov [Thu, 22 Sep 2016 20:20:18 +0000 (23:20 +0300)]
PCI: rcar: Try increasing PCIe link speed to 5 GT/s at boot

The PCIe link speed is initially set to 2.5 GT/s.  Try to increase the link
speed to 5 GT/s.

Based on original patch by Grigory Kletsko
<grigory.kletsko@cogentembedded.com>.

[bhelgaas: remove "Trying speed up" message, remove unused SPCHG]
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
7 years agoMerge branch 'pci/virtualization' into next
Bjorn Helgaas [Mon, 3 Oct 2016 14:43:21 +0000 (09:43 -0500)]
Merge branch 'pci/virtualization' into next

* pci/virtualization:
  PCI: xilinx: Relax device number checking to allow SR-IOV
  PCI: designware: Relax device number checking to allow SR-IOV
  PCI: altera: Relax device number checking to allow SR-IOV
  PCI: Check for pci_setup_device() failure in pci_iov_add_virtfn()
  PCI: Mark Atheros AR9580 to avoid bus reset

7 years agoMerge branch 'pci/resource' into next
Bjorn Helgaas [Mon, 3 Oct 2016 14:43:21 +0000 (09:43 -0500)]
Merge branch 'pci/resource' into next

* pci/resource:
  PCI: Ignore requested alignment for VF BARs
  PCI: Ignore requested alignment for PROBE_ONLY and fixed resources

7 years agoMerge branch 'pci/pm' into next
Bjorn Helgaas [Mon, 3 Oct 2016 14:43:21 +0000 (09:43 -0500)]
Merge branch 'pci/pm' into next

* pci/pm:
  PCI: Avoid unnecessary resume after direct-complete
  PCI: Recognize D3cold in pci_update_current_state()
  PCI: Query platform firmware for device power state
  PCI: Afford direct-complete to devices with non-standard PM

7 years agoMerge branch 'pci/msi' into next
Bjorn Helgaas [Mon, 3 Oct 2016 14:43:20 +0000 (09:43 -0500)]
Merge branch 'pci/msi' into next

* pci/msi:
  PCI/MSI: Enable PCI_MSI_IRQ_DOMAIN support for ARC

7 years agoMerge branch 'pci/misc' into next
Bjorn Helgaas [Mon, 3 Oct 2016 14:43:20 +0000 (09:43 -0500)]
Merge branch 'pci/misc' into next

* pci/misc:
  PCI: Drop CONFIG_KEXEC_CORE ifdeffery

7 years agoMerge branch 'pci/hotplug' into next
Bjorn Helgaas [Mon, 3 Oct 2016 14:43:19 +0000 (09:43 -0500)]
Merge branch 'pci/hotplug' into next

* pci/hotplug:
  x86/PCI: VMD: Request userspace control of PCIe hotplug indicators
  PCI: pciehp: Allow exclusive userspace control of indicators
  PCI: pciehp: Remove useless pciehp_get_latch_status() calls
  PCI: pciehp: Clean up dmesg "Slot(%s)" messages
  PCI: pciehp: Remove unnecessary guard
  PCI: pciehp: Don't re-read Slot Status when handling surprise event
  PCI: pciehp: Don't re-read Slot Status when queuing hotplug event
  PCI: pciehp: Process all hotplug events before looking for new ones
  PCI: pciehp: Return IRQ_NONE when we can't read interrupt status
  PCI: pciehp: Rename pcie_isr() locals for clarity
  PCI: pciehp: Clear attention LED on device add

7 years agoMerge branch 'pci/enumeration' into next
Bjorn Helgaas [Mon, 3 Oct 2016 14:43:19 +0000 (09:43 -0500)]
Merge branch 'pci/enumeration' into next

* pci/enumeration:
  PCI: tegra: Fix pci_remap_iospace() failure path
  PCI: generic: Fix pci_remap_iospace() failure path
  PCI: rcar: Fix pci_remap_iospace() failure path
  PCI: versatile: Fix pci_remap_iospace() failure path
  PCI: designware: Fix pci_remap_iospace() failure path
  PCI: aardvark: Fix pci_remap_iospace() failure path

7 years agoMerge branch 'pci/aer' into next
Bjorn Helgaas [Mon, 3 Oct 2016 14:42:57 +0000 (09:42 -0500)]
Merge branch 'pci/aer' into next

* pci/aer:
  PCI/AER: Fix aer_probe() kernel-doc comment
  PCI/AER: Cache capability position
  PCI/AER: Avoid memory allocation in interrupt handling path
  ACPI / APEI: Send correct severity to calculate AER severity
  PCI/AER: Remove duplicate AER severity translation
  PCI/AER: Remove aerdriver.forceload kernel parameter
  PCI/AER: Remove aerdriver.nosourceid kernel parameter
  x86/PCI: VMD: Add quirk for AER to ignore source ID
  PCI/AER: Add bus flag to skip source ID matching

Conflicts:
drivers/pci/probe.c

7 years agoPCI/AER: Fix aer_probe() kernel-doc comment
Cao jin [Fri, 30 Sep 2016 15:06:23 +0000 (10:06 -0500)]
PCI/AER: Fix aer_probe() kernel-doc comment

0516c8bcd252 ("PCI: PCIe portdrv: Simplily probe callback of service
drivers") removed the "id" argument of aer_probe() but neglected to remove
the kernel-doc comment.  Update the comment.

[bhelgaas: changelog]
Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Ignore requested alignment for VF BARs
Yongji Xie [Tue, 13 Sep 2016 09:00:32 +0000 (17:00 +0800)]
PCI: Ignore requested alignment for VF BARs

Resource allocation for VFs is done via the VF BARx registers in the PF's
SR-IOV Capability, and the BARs in the VFs themselves are read-only zeros
(see SR-IOV spec r1.1, secs 3.3.14 and 3.4.1.11).

Even though the actual VF BARs are read-only zeros, the VF dev->resource[]
structs describe the space allocated for the VF (this is a piece of the
space described by the VF BARx register in the PF's SR-IOV capability).

It's meaningless to request additional alignment for a VF: the VF BAR
alignment is completely determined by the alignment of the VF BARx in the
PF and the size of the VF BAR.

Ignore the user's alignment requests for VF devices.

Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Ignore requested alignment for PROBE_ONLY and fixed resources
Yongji Xie [Tue, 13 Sep 2016 09:00:31 +0000 (17:00 +0800)]
PCI: Ignore requested alignment for PROBE_ONLY and fixed resources

Users may request additional alignment of PCI resources, e.g., to align
BARs on page boundaries so they can be shared with guests via VFIO.  This
of course may require reallocation if firmware has already assigned the
BARs with smaller alignments.

If the platform has requested PCI_PROBE_ONLY, we should never change any
PCI BARs, so we can't provide any additional alignment.  Also, if a BAR is
marked as IORESOURCE_PCI_FIXED, e.g., for PCI Enhanced Allocation or if the
firmware depends on the current BAR value, we can't change the alignment.

In these cases, log a message and ignore the user's alignment requests.

[bhelgaas: changelog, use goto to simplify PCI_PROBE_ONLY check]
Signed-off-by: Yongji Xie <xyjxie@linux.vnet.ibm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Avoid unnecessary resume after direct-complete
Lukas Wunner [Sun, 18 Sep 2016 03:39:20 +0000 (05:39 +0200)]
PCI: Avoid unnecessary resume after direct-complete

Commit 58a1fbbb2ee8 ("PM / PCI / ACPI: Kick devices that might have been
reset by firmware") added a runtime resume for devices that were runtime
suspended when the system entered sleep.

The motivation was that devices might be in a reset-power-on state after
waking from system sleep, so their power state as perceived by Linux
(stored in pci_dev->current_state) would no longer reflect reality.  By
resuming such devices, we allow them to return to a low-power state via
autosuspend and also bring their current_state in sync with reality.

However for devices that are *not* in a reset-power-on state, doing an
unconditional resume wastes energy.  A more refined approach is called for
which issues a runtime resume only if the power state after direct-complete
is shallower than it was before. To achieve this, update the device's
current_state and compare it to its pre-sleep value.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
7 years agoPCI: Recognize D3cold in pci_update_current_state()
Lukas Wunner [Sun, 18 Sep 2016 03:39:20 +0000 (05:39 +0200)]
PCI: Recognize D3cold in pci_update_current_state()

Whenever a device is resumed or its power state is changed using the
platform, its new power state is read from the PM Control & Status Register
and cached in pci_dev->current_state by calling pci_update_current_state().

If the device is in D3cold, reading from config space typically results in
a fabricated "all ones" response.  But if it's in D3hot, the two bits
representing the power state in the PMCSR are *also* set to 1.  Thus D3hot
and D3cold are not discernible by just reading the PMCSR.

To account for this, pci_update_current_state() uses two workarounds:

- When transitioning to D3cold using pci_platform_power_transition(), the
  new power state is set blindly by pci_update_current_state(), i.e.
  without verifying that the device actually *is* in D3cold.  This is
  achieved by setting the "state" argument to PCI_D3cold.  The "state"
  argument was originally intended to convey the new state in case the
  device doesn't have the PM capability.  It is *also* used to convey the
  device state if the PM capability is present and the new state is D3cold,
  but this was never explained in the kerneldoc.

- Once the current_state is set to D3cold, further invocations of
  pci_update_current_state() will blindly assume that the device is still
  in D3cold and leave the current_state unmodified.  To get out of this
  impasse, the current_state has to be set directly, typically by calling
  pci_raw_set_power_state() or pci_enable_device().

It would be desirable if pci_update_current_state() could reliably detect
D3cold by itself.  That would allow us to do away with these workarounds,
and it would allow for a smarter, more energy conserving runtime resume
strategy after system sleep:  Currently devices which utilize
direct_complete are mandatorily runtime resumed in their ->complete stage.
This can be avoided if their power state after system sleep is the same as
before, but it requires a mechanism to detect the power state reliably.

We've just gained the ability to query the platform firmware for its
opinion on the device's power state.  On platforms conforming to ACPI 4.0
or newer, this allows recognition of D3cold.  Pre-4.0 platforms lack _PR3
and therefore the deepest power state that will ever be reported is D3hot,
even though the device may actually be in D3cold.  To detect D3cold in
those cases, accessibility of the vendor ID in config space is probed using
pci_device_is_present().  This also works for devices which are not
platform-power-manageable at all, but can be suspended to D3cold using a
nonstandard mechanism (e.g. some hybrid graphics laptops or Thunderbolt on
the Mac).

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
7 years agoPCI: Query platform firmware for device power state
Lukas Wunner [Sun, 18 Sep 2016 03:39:20 +0000 (05:39 +0200)]
PCI: Query platform firmware for device power state

Usually the most accurate way to determine a PCI device's power state is to
read its PM Control & Status Register.  There are two cases however when
this is not an option:  If the device doesn't have the PM capability at
all, or if it is in D3cold (in which case its config space is
inaccessible).

In both cases, we can alternatively query the platform firmware for its
opinion on the device's power state.  To facilitate this, augment struct
pci_platform_pm_ops with a ->get_power callback and implement it for
acpi_pci_platform_pm (the only pci_platform_pm_ops existing so far).

It is used by a forthcoming commit to let pci_update_current_state()
recognize D3cold.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
7 years agoPCI: Afford direct-complete to devices with non-standard PM
Lukas Wunner [Sun, 18 Sep 2016 03:39:20 +0000 (05:39 +0200)]
PCI: Afford direct-complete to devices with non-standard PM

There are devices not power-manageable by the platform, but still able to
runtime suspend to D3cold with a non-standard mechanism.  One example is
laptop hybrid graphics where the discrete GPU and its built-in HDA
controller are power-managed either with a _DSM (AMD PowerXpress, Nvidia
Optimus) or a separate gmux controller (MacBook Pro).  Another example is
Thunderbolt on Macs which is power-managed with custom ACPI methods.

When putting the system to sleep, we currently handle such devices
improperly by transitioning them from D3cold to D3hot (the default power
state defined at the top of pci_target_state()).  This wastes energy and
prolongs the suspend sequence (powering up the Thunderbolt controller takes
2 seconds).

Avoid that by assuming that a non-standard PM mechanism is at work if the
device is not platform-power-manageable but currently in D3cold.

If the device is wakeup enabled, we might still have to wake it up from
D3cold if PME cannot be signaled from that power state.

The check for devices without PM capability comes before the check for
D3cold since such devices could in theory also be powered down by
non-standard means and should then be afforded direct-complete as well.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
7 years agoPCI/AER: Cache capability position
Keith Busch [Tue, 27 Sep 2016 20:23:34 +0000 (16:23 -0400)]
PCI/AER: Cache capability position

Save the position of the error reporting capability so it doesn't need to
be rediscovered during error handling.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Lukas Wunner <lukas@wunner.de>
7 years agoPCI/AER: Avoid memory allocation in interrupt handling path
Jon Derrick [Wed, 14 Sep 2016 16:38:55 +0000 (10:38 -0600)]
PCI/AER: Avoid memory allocation in interrupt handling path

When handling AER events, we previously allocated a struct aer_err_info,
processed the error, and freed the struct.  But aer_isr_one_error() is
serialized by rpc_mutex, so we never need more than one copy of the struct,
and the struct is only about 70 bytes, so we're not saving much by
allocating it dynamically.

Embed a struct aer_err_info directly in struct aer_rpc, which is allocated
at probe-time by aer_probe().

[bhelgaas: changelog]
Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agox86/PCI: VMD: Request userspace control of PCIe hotplug indicators
Keith Busch [Tue, 13 Sep 2016 15:05:40 +0000 (09:05 -0600)]
x86/PCI: VMD: Request userspace control of PCIe hotplug indicators

Add set_dev_domain_options() to set PCI domain-specific options as devices
are added.  The first usage is to request exclusive userspace control of
PCIe hotplug indicators in VMD domains.

Devices in a VMD domain use PCIe hotplug Attention and Power Indicators in
a non-standard way; tell pciehp to ignore the indicators so userspace can
control them via the sysfs "attention" file.

To determine whether a bus is within a VMD domain, add a bool to the
pci_sysdata structure that the VMD driver sets during initialization.

[bhelgaas: changelog]
Requested-by: Kapil Karkra <kapil.karkra@intel.com>
Tested-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: pciehp: Allow exclusive userspace control of indicators
Keith Busch [Tue, 13 Sep 2016 16:31:59 +0000 (10:31 -0600)]
PCI: pciehp: Allow exclusive userspace control of indicators

PCIe hotplug supports optional Attention and Power Indicators, which are
used internally by pciehp.  Users can't control the Power Indicator, but
they can control the Attention Indicator by writing to a sysfs "attention"
file.

The Slot Control register has two bits for each indicator, and the PCIe
spec defines the encodings for each as (Reserved/On/Blinking/Off).  For
sysfs "attention" writes, pciehp_set_attention_status() maps into these
encodings, so the only useful write values are 0 (Off), 1 (On), and 2
(Blinking).

However, some platforms use all four bits for platform-specific indicators,
and they need to allow direct user control of them while preventing pciehp
from using them at all.

Add a "hotplug_user_indicators" flag to the pci_dev structure.  When set,
pciehp does not use either the Attention Indicator or the Power Indicator,
and the low four bits (values 0x0 - 0xf) of sysfs "attention" write values
are written directly to the Attention Indicator Control and Power Indicator
Control fields.

[bhelgaas: changelog, rename flag and accessors to s/attention/indicator/]
Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoACPI / APEI: Send correct severity to calculate AER severity
Tyler Baicar [Wed, 14 Sep 2016 21:14:46 +0000 (15:14 -0600)]
ACPI / APEI: Send correct severity to calculate AER severity

Currently the AER severity is calculated by calling cper_severity_to_aer(),
but the parameter sent is actually the GHES severity.  This causes the AER
severity to be incorrect.

Fix the parameter to be the CPER severity instead of the GHES severity.

Signed-off-by: Tyler Baicar <tbaicar@codeaurora.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Borislav Petkov <bp@suse.de>
7 years agoPCI/AER: Remove duplicate AER severity translation
Tyler Baicar [Wed, 14 Sep 2016 21:14:45 +0000 (15:14 -0600)]
PCI/AER: Remove duplicate AER severity translation

Currently the AER severity is being translated twice in the code flow for
PCIe errors.  It is first translated in ghes_do_proc() before calling into
the AER driver.  Then it is translated again when the AER driver calls
cper_print_aer().  This causes the severity that is used in
cper_print_aer() to be incorrect.

Remove the second translation that is in cper_print_aer() since this
function is already receiving the correct AER severity.

Signed-off-by: Tyler Baicar <tbaicar@codeaurora.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Borislav Petkov <bp@suse.de>
7 years agox86/PCI: VMD: Synchronize with RCU freeing MSI IRQ descs
Keith Busch [Thu, 4 Aug 2016 22:09:09 +0000 (16:09 -0600)]
x86/PCI: VMD: Synchronize with RCU freeing MSI IRQ descs

Fix a potential race when disabling MSI/MSI-X on a VMD domain device.  If
the VMD interrupt service is running, it may see a disabled IRQ.  We can
synchronize RCU just before freeing the MSI descriptor.  This is safe since
the irq_desc lock isn't held, and the descriptor is valid even though it is
disabled.  After vmd_msi_free(), though, the handler is reinitialized to
handle_bad_irq(), so we can't let the VMD ISR's list iteration see the
disabled IRQ after this.

Signed-off-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by Jon Derrick: <jonathan.derrick@intel.com>

7 years agox86/PCI: VMD: Eliminate index member from IRQ list
Jon Derrick [Fri, 2 Sep 2016 17:53:05 +0000 (11:53 -0600)]
x86/PCI: VMD: Eliminate index member from IRQ list

Use math to discover the IRQ list index number relative to the IRQ list
head.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Keith Busch <keith.busch@intel.com>
7 years agox86/PCI: VMD: Eliminate vmd_vector member from list type
Jon Derrick [Fri, 2 Sep 2016 17:53:04 +0000 (11:53 -0600)]
x86/PCI: VMD: Eliminate vmd_vector member from list type

Eliminate unused vmd and vector members from vmd_irq_list and discover the
vector using pci_irq_vector().

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Keith Busch <keith.busch@intel.com>
7 years agox86/PCI: VMD: Convert to use pci_alloc_irq_vectors() API
Jon Derrick [Mon, 29 Aug 2016 17:19:02 +0000 (11:19 -0600)]
x86/PCI: VMD: Convert to use pci_alloc_irq_vectors() API

Convert to use the pci_alloc_irq_vectors() API.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
7 years agox86/PCI: VMD: Allocate IRQ lists with correct MSI-X count
Jon Derrick [Mon, 29 Aug 2016 17:19:01 +0000 (11:19 -0600)]
x86/PCI: VMD: Allocate IRQ lists with correct MSI-X count

To reduce the amount of memory required for IRQ lists, only allocate their
space after calling pci_msix_enable_range() which may reduce the number of
MSI-X vectors allocated.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Keith Busch <keith.busch@intel.com>
7 years agoPCI: artpec6: Drop __init from artpec6_add_pcie_port()
Niklas Cassel [Fri, 9 Sep 2016 07:45:30 +0000 (09:45 +0200)]
PCI: artpec6: Drop __init from artpec6_add_pcie_port()

artpec6_add_pcie_port() is called from artpec6_pcie_probe(), which is not
marked __init.  It is wrong to call an __init function from a non-__init
one, so remove __init from artpec6_add_pcie_port().

[bhelgaas: changelog]
Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rcar: Fix some checkpatch warnings
Sergei Shtylyov [Thu, 8 Sep 2016 22:26:18 +0000 (01:26 +0300)]
PCI: rcar: Fix some checkpatch warnings

The R-Car PCIe driver causes 13 warnings from scripts/checkpatch.pl --
let's fix at least 10 easier ones:

  - line over 80 characters;
  - blank line missing after declarations;
  - statements not starting on a tabstop.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
7 years agoPCI: rcar: Add multi-MSI support
Grigory Kletsko [Thu, 8 Sep 2016 19:32:59 +0000 (22:32 +0300)]
PCI: rcar: Add multi-MSI support

Implement the MSI .setup_irqs() method which enables allocation of several
MSIs at once.

[Sergei Shtylyov: removed unrelated/unneeded changes, fixed too long lines,
reordered the variable declarations, reworded the summary/description.]
Signed-off-by: Grigory Kletsko <grigory.kletsko@cogentembedded.com>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
7 years agoPCI/AER: Remove aerdriver.forceload kernel parameter
Bjorn Helgaas [Tue, 6 Sep 2016 21:24:37 +0000 (16:24 -0500)]
PCI/AER: Remove aerdriver.forceload kernel parameter

Per the PCI Firmware spec, r3.0, sec 4.5.1, on ACPI systems, the OS must
not use AER unless _OSC is present and _OSC grants AER control to the OS.
The aerdriver.forceload kernel parameter was a way to enable Linux AER
support on ACPI systems that lack _OSC or fail to grant control the the OS.

Enabling Linux AER support when the firmware doesn't want us to is a recipe
for problems, e.g., the firmware might be handling AER itself.

Remove the aerdriver.forceload kernel parameter and related supporting
code.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/AER: Remove aerdriver.nosourceid kernel parameter
Bjorn Helgaas [Tue, 6 Sep 2016 21:09:19 +0000 (16:09 -0500)]
PCI/AER: Remove aerdriver.nosourceid kernel parameter

The aerdriver.nosourceid kernel parameter was intended for working around
broken chipsets don't supply the source ID for AER events.  We recently
added PCI_BUS_FLAGS_NO_AERSID, which can be set by quirks for the same
purpose.

Remove the aerdriver.nosourceid kernel parameter.  For anything other than
debugging, asking users to find and use kernel parameters is a poor user
experience.  Instead, we should add PCI_BUS_FLAGS_NO_AERSID quirks for any
hardware that needs it.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: pciehp: Remove useless pciehp_get_latch_status() calls
Bjorn Helgaas [Wed, 7 Sep 2016 22:50:30 +0000 (17:50 -0500)]
PCI: pciehp: Remove useless pciehp_get_latch_status() calls

Long ago, we updated a "switch_save" field based on the latch status.  But
switch_save was unused, and ed6cbcf2ac70 ("[PATCH] pciehp: miscellaneous
cleanups") removed it.

We no longer use the latch status, so remove calls to
pciehp_get_latch_status().  No functional change intended.

Tested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
7 years agoPCI: pciehp: Clean up dmesg "Slot(%s)" messages
Bjorn Helgaas [Thu, 8 Sep 2016 20:19:58 +0000 (15:19 -0500)]
PCI: pciehp: Clean up dmesg "Slot(%s)" messages

Print slot name consistently as "Slot(%s)".  I don't know whether that's
ideal, but we can at least do it the same way all the time.  No functional
change intended.

Tested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
7 years agoPCI: pciehp: Remove unnecessary guard
Bjorn Helgaas [Thu, 8 Sep 2016 20:15:24 +0000 (15:15 -0500)]
PCI: pciehp: Remove unnecessary guard

In pcie_isr(), we return early if no status bits other than
PCI_EXP_SLTSTA_CC are set.  This was introduced by dbd79aed1aea ("pciehp:
fix NULL dereference in interrupt handler"), but it is no longer necessary
because all the subsequent pcie_isr() code is already predicated on a
status bit being set.

Remove the unnecessary test for ~PCI_EXP_SLTSTA_CC.  No functional change
intended.

Tested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
7 years agoPCI: pciehp: Don't re-read Slot Status when handling surprise event
Mayurkumar Patel [Tue, 23 Aug 2016 08:58:51 +0000 (08:58 +0000)]
PCI: pciehp: Don't re-read Slot Status when handling surprise event

Previously we read Slot Status when handling a surprise event.  But Slot
Status might have changed since we identified the event, and the event_type
already tells us whether to enable or disable the slot, so there's no need
to read it again.

Remove handle_surprise_event() and queue the power work directly.

[bhelgaas: changelog]
Tested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Mayurkumar Patel <mayurkumar.patel@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Rajat Jain <rajatxjain@gmail.com>
7 years agoPCI: pciehp: Don't re-read Slot Status when queuing hotplug event
Mayurkumar Patel [Fri, 9 Sep 2016 14:10:17 +0000 (09:10 -0500)]
PCI: pciehp: Don't re-read Slot Status when queuing hotplug event

Previously we read Slot Status to learn about hotplug events, then cleared
the events, then re-read Slot Status to find out what happened.  But Slot
Status might have changed before the second read.

Capture the Slot Status once before clearing the events.  Also capture the
Link Status if we had a link status change.

[bhelgaas: changelog, split to separate patch]
Tested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Mayurkumar Patel <mayurkumar.patel@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
7 years agoPCI: pciehp: Process all hotplug events before looking for new ones
Mayurkumar Patel [Thu, 8 Sep 2016 20:07:56 +0000 (15:07 -0500)]
PCI: pciehp: Process all hotplug events before looking for new ones

Previously we accumulated hotplug events, then processed them, essentially
like this:

  events = 0
  do {
    status = read(Slot Status)
    status &= EVENT_MASK              # only look at events
    events |= status                  # accumulate events
    write(Slot Status, events)        # clear events
  } while (status)
  process events

The problem is that as soon as we clear events in Slot Status, the hardware
may send notifications for new events, and we lose information about the
first events.  For example, we might see two Presence Detect Changed
events, but lose the fact that the slot was temporarily empty:

  read  PCI_EXP_SLTSTA_PDC set, PCI_EXP_SLTSTA_PDS clear  # slot empty
  write PCI_EXP_SLTSTA_PDC                                # clear PDC event
  read  PCI_EXP_SLTSTA_PDC set, PCI_EXP_SLTSTA_PDS set    # slot occupied

The current code does not process a removal; it only processes the
insertion, which fails because we didn't remove the original device.

To avoid this problem, read Slot Status once and process all the events
before reading it again, like this:

  do {
    read events
    clear events
    process events
  } while (events)

[bhelgaas: changelog, add external loop around pciehp_isr()]
Tested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Mayurkumar Patel <mayurkumar.patel@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
7 years agoPCI: pciehp: Return IRQ_NONE when we can't read interrupt status
Bjorn Helgaas [Thu, 8 Sep 2016 21:43:40 +0000 (16:43 -0500)]
PCI: pciehp: Return IRQ_NONE when we can't read interrupt status

After 1469d17dd341 ("PCI: pciehp: Handle invalid data when reading from
non-existent devices"), we returned IRQ_HANDLED when we failed to read
interrupt status from the bridge.  I think it's better to return IRQ_NONE,
as we do in other cases where there's no interrupt pending.  This will
facilitate refactoring the loop in pcie_isr(): we'll be able to call the
ISR in a loop as long as it returns IRQ_HANDLED.

Return IRQ_NONE if we couldn't read interrupt status.

Tested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
7 years agomicroblaze/PCI: Add multidomain support for procfs
Bharat Kumar Gogada [Thu, 1 Sep 2016 10:14:46 +0000 (15:44 +0530)]
microblaze/PCI: Add multidomain support for procfs

We create a procfs directory for every PCI bus.  Previously, the directory
name was just the bus number, so using the same bus number in different
domains caused a kernel crash when we tried to create a duplicate
directory.

Make pci_proc_domain() return the domain number, so procfs directories for
buses in domain 0 are named with just the bus number, and directories for
buses in other domains include both the domain number and the bus number.

[bhelgaas: changelog]
Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
7 years agoPCI: xilinx: Dispose of MSI virtual IRQ
Bharat Kumar Gogada [Thu, 1 Sep 2016 10:14:44 +0000 (15:44 +0530)]
PCI: xilinx: Dispose of MSI virtual IRQ

Dispose of virtual IRQ being created for MSI interrupts.

Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
7 years agoPCI: xilinx: Clear correct MSI set bit
Bharat Kumar Gogada [Thu, 1 Sep 2016 10:14:43 +0000 (15:44 +0530)]
PCI: xilinx: Clear correct MSI set bit

Kernel provides virtual IRQ number at teardown.  Get hwirq number from
virtual IRQ and clear correct MSI set bit.

Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
7 years agoPCI: xilinx: Clear interrupt register for invalid interrupt
Bharat Kumar Gogada [Thu, 1 Sep 2016 10:14:42 +0000 (15:44 +0530)]
PCI: xilinx: Clear interrupt register for invalid interrupt

The interrupt decode register is not being cleared if an invalid interrupt
arises.  Clear the decode register in this case.

Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
7 years agoPCI: xilinx: Keep both legacy and MSI interrupt domain references
Bharat Kumar Gogada [Thu, 1 Sep 2016 10:14:41 +0000 (15:44 +0530)]
PCI: xilinx: Keep both legacy and MSI interrupt domain references

When built with MSI support, the legacy domain reference was being
overwritten with MSI.

Create two separate domains for MSI and legacy interrupts.

Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Michal Simek <michal.simek@xilinx.com>
7 years agoPCI: xilinx-nwl: Enable all MSI interrupts using MSI mask
Bharat Kumar Gogada [Tue, 30 Aug 2016 10:39:17 +0000 (16:09 +0530)]
PCI: xilinx-nwl: Enable all MSI interrupts using MSI mask

The current mask enables and allows only one MSI interrupt on each MSI
line.  Enable all MSI interrupts, which will also support Endpoints with
multi-MSI support.

Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: xilinx-nwl: Expand error logging
Bharat Kumar Gogada [Tue, 30 Aug 2016 10:39:16 +0000 (16:09 +0530)]
PCI: xilinx-nwl: Expand error logging

The current driver logs PCIe core errors.  Add logging for individual core
events.

[bhelgaas: changelog]
Signed-off-by: Bharat Kumar Gogada <bharatku@xilinx.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: rcar: Don't disable/unprepare clocks on prepare/enable failure
Geert Uytterhoeven [Wed, 31 Aug 2016 09:28:22 +0000 (11:28 +0200)]
PCI: rcar: Don't disable/unprepare clocks on prepare/enable failure

If clk_prepare_enable() fails, we must not call clk_disable_unprepare() in
the error path.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: altera: Remove redundant platform_get_resource() return value check
Bjorn Helgaas [Mon, 22 Aug 2016 19:12:11 +0000 (14:12 -0500)]
PCI: altera: Remove redundant platform_get_resource() return value check

devm_ioremap_resource() fails gracefully when given a NULL resource
pointer, so we don't need to check separately for failure from
platform_get_resource_byname().  Remove the redundant check.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: altera: Move retrain from fixup to altera_pcie_host_init()
Ley Foon Tan [Fri, 26 Aug 2016 01:47:25 +0000 (09:47 +0800)]
PCI: altera: Move retrain from fixup to altera_pcie_host_init()

Previously we used a PCI early fixup to initiate a link retrain on Altera
devices.  But Altera PCIe IP can be configured as either a Root Port or an
Endpoint, and they might have same vendor ID, so the fixup would be run for
both.

We only want to initiate a link retrain for Altera Root Port devices, not
for Endpoints, so move the link retrain functionality from the fixup to
altera_pcie_host_init().

[bhelgaas: changelog]
Signed-off-by: Ley Foon Tan <lftan@altera.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: xilinx: Relax device number checking to allow SR-IOV
Po Liu [Mon, 29 Aug 2016 07:26:58 +0000 (15:26 +0800)]
PCI: xilinx: Relax device number checking to allow SR-IOV

Previously we only allowed device 0 to be directly attached to the root
port.  But SR-IOV devices may use non-zero device numbers for VFs.

Remove the restriction that only device 0 may be attached to a root port.

[bhelgaas: changelog]
Signed-off-by: Po Liu <po.liu@nxp.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: designware: Relax device number checking to allow SR-IOV
Po Liu [Mon, 29 Aug 2016 07:26:58 +0000 (15:26 +0800)]
PCI: designware: Relax device number checking to allow SR-IOV

Previously we only allowed device 0 to be directly attached to the root
port.  But SR-IOV devices may use non-zero device numbers for VFs.

Remove the restriction that only device 0 may be attached to a root port.

[bhelgaas: changelog]
Signed-off-by: Po Liu <po.liu@nxp.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Jingoo Han <jingoohan1@gmail.com>
7 years agoPCI: altera: Relax device number checking to allow SR-IOV
Po Liu [Mon, 29 Aug 2016 07:26:58 +0000 (15:26 +0800)]
PCI: altera: Relax device number checking to allow SR-IOV

Previously we only allowed device 0 to be directly attached to the root
port.  But SR-IOV devices may use non-zero device numbers for VFs.

Remove the restriction that only device 0 may be attached to a root port.

[bhelgaas: changelog]
Signed-off-by: Po Liu <po.liu@nxp.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Ley Foon Tan <lftan@altera.com>
7 years agoPCI: Check for pci_setup_device() failure in pci_iov_add_virtfn()
Po Liu [Mon, 29 Aug 2016 07:28:01 +0000 (15:28 +0800)]
PCI: Check for pci_setup_device() failure in pci_iov_add_virtfn()

If pci_setup_device() returns failure, we must return failure from
pci_iov_add_virtfn().  If we ignore the failure and continue with an
uninitialized pci_dev for virtfn, we crash later when we try to use those
uninitialized parts.

Signed-off-by: Po Liu <po.liu@nxp.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: pciehp: Rename pcie_isr() locals for clarity
Bjorn Helgaas [Thu, 8 Sep 2016 22:30:38 +0000 (17:30 -0500)]
PCI: pciehp: Rename pcie_isr() locals for clarity

Rename "detected" and "intr_loc" to "status" and "events" for clarity.
"status" is the value we read from the Slot Status register; "events" is
the set of hot-plug events we need to process.  No functional change
intended.

Tested-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
7 years agox86/PCI: VMD: Add quirk for AER to ignore source ID
Jon Derrick [Tue, 6 Sep 2016 19:15:24 +0000 (14:15 -0500)]
x86/PCI: VMD: Add quirk for AER to ignore source ID

VMD root ports change all source ids to the VMD device ID.  To find the
sender of the AER notification, we need to scan all child devices for the
AER sender, rather than relying on the source ID from the message.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI/AER: Add bus flag to skip source ID matching
Jon Derrick [Thu, 25 Aug 2016 23:26:10 +0000 (17:26 -0600)]
PCI/AER: Add bus flag to skip source ID matching

Allow root port buses to choose to skip source id matching when finding the
faulting device.  Certain root port devices may return an incorrect source
ID and recommend to scan child device registers for AER notifications.

Signed-off-by: Jon Derrick <jonathan.derrick@intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: tegra: Fix pci_remap_iospace() failure path
Lorenzo Pieralisi [Mon, 15 Aug 2016 16:50:46 +0000 (17:50 +0100)]
PCI: tegra: Fix pci_remap_iospace() failure path

On ARM/ARM64 architectures, PCI IO ports are emulated through memory mapped
IO, by reserving a chunk of virtual address space starting at PCI_IOBASE
and by mapping the PCI host bridges memory address space driving PCI IO
cycles to it.

PCI host bridge drivers that enable downstream PCI IO cycles map the host
bridge memory address responding to PCI IO cycles to the fixed virtual
address space through the pci_remap_iospace() API.

This means that if the pci_remap_iospace() function fails, the
corresponding host bridge PCI IO resource must be considered invalid, in
that there is no way for the kernel to actually drive PCI IO transactions
if the memory addresses responding to PCI IO cycles cannot be mapped into
the CPU virtual address space.

The PCI tegra host bridge driver adds the PCI IO resource retrieved from
firmware to the host bridge resource windows even if the
pci_remap_iospace() call fails; this is an actual bug in that the PCI host
bridge would consider the PCI IO resource valid (and possibly assign it to
downstream devices) even if the kernel was not able to map the PCI host
bridge memory address driving IO cycle to the CPU virtual address space (ie
pci_remap_iospace() failures).

Add the PCI host bridge driver pci_remap_iospace() failure path and do not
add the corresponding PCI host bridge PCI IO resources retrieved through
firmware when the pci_remap_iospace() function call fails, fixing the
issue.

Fixes: e6e9f471f5fe ("PCI: tegra: Use generic pci_remap_iospace() rather than ARM32-specific one")
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Thierry Reding <treding@nvidia.com>
7 years agoPCI: generic: Fix pci_remap_iospace() failure path
Lorenzo Pieralisi [Mon, 15 Aug 2016 16:50:45 +0000 (17:50 +0100)]
PCI: generic: Fix pci_remap_iospace() failure path

On ARM/ARM64 architectures, PCI IO ports are emulated through memory mapped
IO, by reserving a chunk of virtual address space starting at PCI_IOBASE
and by mapping the PCI host bridges memory address space driving PCI IO
cycles to it.

PCI host bridge drivers that enable downstream PCI IO cycles map the host
bridge memory address responding to PCI IO cycles to the fixed virtual
address space through the pci_remap_iospace() API.

This means that if the pci_remap_iospace() function fails, the
corresponding host bridge PCI IO resource must be considered invalid, in
that there is no way for the kernel to actually drive PCI IO transactions
if the memory addresses responding to PCI IO cycles cannot be mapped into
the CPU virtual address space.

The PCI common host bridge driver does not remove the PCI IO resource from
the host bridge resource windows if the pci_remap_iospace() call fails;
this is an actual bug in that the PCI host bridge would consider the PCI IO
resource valid (and possibly assign it to downstream devices) even if the
kernel was not able to map the PCI host bridge memory address driving IO
cycle to the CPU virtual address space (ie pci_remap_iospace() failures).

Fix the PCI host bridge driver pci_remap_iospace() failure path, by
destroying the PCI host bridge PCI IO resources retrieved through firmware
when the pci_remap_iospace() function call fails, therefore preventing the
kernel from adding the respective PCI IO resource to the list of PCI host
bridge valid resources, fixing the issue.

Fixes: 4e64dbe226e7 ("PCI: generic: Expose pci_host_common_probe() for use by other drivers")
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Will Deacon <will.deacon@arm.com>
7 years agoPCI: rcar: Fix pci_remap_iospace() failure path
Lorenzo Pieralisi [Mon, 15 Aug 2016 16:50:44 +0000 (17:50 +0100)]
PCI: rcar: Fix pci_remap_iospace() failure path

On ARM/ARM64 architectures, PCI IO ports are emulated through memory mapped
IO, by reserving a chunk of virtual address space starting at PCI_IOBASE
and by mapping the PCI host bridges memory address space driving PCI IO
cycles to it.

PCI host bridge drivers that enable downstream PCI IO cycles map the host
bridge memory address responding to PCI IO cycles to the fixed virtual
address space through the pci_remap_iospace() API.

This means that if the pci_remap_iospace() function fails, the
corresponding host bridge PCI IO resource must be considered invalid, in
that there is no way for the kernel to actually drive PCI IO transactions
if the memory addresses responding to PCI IO cycles cannot be mapped into
the CPU virtual address space.

The PCI rcar host bridge driver does not remove the PCI IO resource from
the host bridge resource windows if the pci_remap_iospace() call fails;
this is an actual bug in that the PCI host bridge would consider the PCI IO
resource valid (and possibly assign it to downstream devices) even if the
kernel was not able to map the PCI host bridge memory address driving IO
cycle to the CPU virtual address space (ie pci_remap_iospace() failures).

Fix the PCI host bridge driver pci_remap_iospace() failure path, by
destroying the PCI host bridge PCI IO resources retrieved through firmware
when the pci_remap_iospace() function call fails, therefore preventing the
kernel from adding the respective PCI IO resource to the list of PCI host
bridge valid resources, fixing the issue.

Fixes: 5d2917d469fa ("PCI: rcar: Convert to DT resource parsing API")
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Phil Edworthy <phil.edworthy@renesas.com>
CC: Simon Horman <horms+renesas@verge.net.au>
7 years agoPCI: versatile: Fix pci_remap_iospace() failure path
Lorenzo Pieralisi [Mon, 15 Aug 2016 16:50:43 +0000 (17:50 +0100)]
PCI: versatile: Fix pci_remap_iospace() failure path

On ARM/ARM64 architectures, PCI IO ports are emulated through memory mapped
IO, by reserving a chunk of virtual address space starting at PCI_IOBASE
and by mapping the PCI host bridges memory address space driving PCI IO
cycles to it.

PCI host bridge drivers that enable downstream PCI IO cycles map the host
bridge memory address responding to PCI IO cycles to the fixed virtual
address space through the pci_remap_iospace() API.

This means that if the pci_remap_iospace() function fails, the
corresponding host bridge PCI IO resource must be considered invalid, in
that there is no way for the kernel to actually drive PCI IO transactions
if the memory addresses responding to PCI IO cycles cannot be mapped into
the CPU virtual address space.

The PCI versatile host bridge driver does not remove the PCI IO resource
from the host bridge resource windows if the pci_remap_iospace() call
fails; this is an actual bug in that the PCI host bridge would consider the
PCI IO resource valid (and possibly assign it to downstream devices) even
if the kernel was not able to map the PCI host bridge memory address
driving IO cycle to the CPU virtual address space (ie pci_remap_iospace()
failures).

Fix the PCI host bridge driver pci_remap_iospace() failure path, by
destroying the PCI host bridge PCI IO resources retrieved through firmware
when the pci_remap_iospace() function call fails, therefore preventing the
kernel from adding the respective PCI IO resource to the list of PCI host
bridge valid resources, fixing the issue.

Fixes: b7e78170efd4 ("PCI: versatile: Add DT-based ARM Versatile PB PCIe host driver")
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Rob Herring <robh@kernel.org>
7 years agoPCI: designware: Fix pci_remap_iospace() failure path
Lorenzo Pieralisi [Mon, 15 Aug 2016 16:50:42 +0000 (17:50 +0100)]
PCI: designware: Fix pci_remap_iospace() failure path

On ARM/ARM64 architectures, PCI IO ports are emulated through memory mapped
IO, by reserving a chunk of virtual address space starting at PCI_IOBASE
and by mapping the PCI host bridges memory address space driving PCI IO
cycles to it.

PCI host bridge drivers that enable downstream PCI IO cycles map the host
bridge memory address responding to PCI IO cycles to the fixed virtual
address space through the pci_remap_iospace() API.

This means that if the pci_remap_iospace() function fails, the
corresponding host bridge PCI IO resource must be considered invalid, in
that there is no way for the kernel to actually drive PCI IO transactions
if the memory addresses responding to PCI IO cycles cannot be mapped into
the CPU virtual address space.

The PCI designware host bridge driver does not remove the PCI IO resource
from the host bridge resource windows if the pci_remap_iospace() call
fails; this is an actual bug in that the PCI host bridge would consider the
PCI IO resource valid (and possibly assign it to downstream devices) even
if the kernel was not able to map the PCI host bridge memory address
driving IO cycle to the CPU virtual address space (ie pci_remap_iospace()
failures).

Fix the PCI host bridge driver pci_remap_iospace() failure path, by
destroying the PCI host bridge PCI IO resources retrieved through firmware
when the pci_remap_iospace() function call fails, therefore preventing the
kernel from adding the respective PCI IO resource to the list of PCI host
bridge valid resources, fixing the issue.

Fixes: cbce7900598c ("PCI: designware: Make driver arch-agnostic")
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Jingoo Han <jingoohan1@gmail.com>
CC: Pratyush Anand <pratyush.anand@gmail.com>
7 years agoPCI: aardvark: Fix pci_remap_iospace() failure path
Lorenzo Pieralisi [Mon, 15 Aug 2016 16:50:41 +0000 (17:50 +0100)]
PCI: aardvark: Fix pci_remap_iospace() failure path

On ARM/ARM64 architectures, PCI IO ports are emulated through memory mapped
IO, by reserving a chunk of virtual address space starting at PCI_IOBASE
and by mapping the PCI host bridge's memory address space driving PCI IO
cycles to it.

PCI host bridge drivers that enable downstream PCI IO cycles map the host
bridge memory address responding to PCI IO cycles to the fixed virtual
address space through the pci_remap_iospace() API.

This means that if the pci_remap_iospace() function fails, the
corresponding host bridge PCI IO resource must be considered invalid, in
that there is no way for the kernel to actually drive PCI IO transactions
if the memory addresses responding to PCI IO cycles cannot be mapped into
the CPU virtual address space.

The PCI aardvark host bridge driver does not remove the PCI IO resource
from the host bridge resource windows if the pci_remap_iospace() call
fails; this is an actual bug in that the PCI host bridge would consider the
PCI IO resource valid (and possibly assign it to downstream devices) even
if the kernel was not able to map the PCI host bridge memory address
driving IO cycle to the CPU virtual address space (ie pci_remap_iospace()
failures).

Fix the PCI host bridge driver pci_remap_iospace() failure path, by
destroying the PCI host bridge PCI IO resources retrieved through firmware
when the pci_remap_iospace() function call fails, therefore preventing the
kernel from adding the respective PCI IO resource to the list of PCI host
bridge valid resources, fixing the issue.

Fixes: 8c39d710363c ("PCI: aardvark: Add Aardvark PCI host controller driver")
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
7 years agoPCI: hv: Handle hv_pci_generic_compl() error case
Dexuan Cui [Tue, 23 Aug 2016 04:49:22 +0000 (04:49 +0000)]
PCI: hv: Handle hv_pci_generic_compl() error case

'completion_status' is used in some places, e.g.,
hv_pci_protocol_negotiation(), so we should make sure it's initialized in
error case too, though the error is unlikely here.

[bhelgaas: fix changelog typo and nearby whitespace]
Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: KY Srinivasan <kys@microsoft.com>
CC: Jake Oshins <jakeo@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Vitaly Kuznetsov <vkuznets@redhat.com>
7 years agoPCI: hv: Handle vmbus_sendpacket() failure in hv_compose_msi_msg()
Dexuan Cui [Tue, 23 Aug 2016 04:48:11 +0000 (04:48 +0000)]
PCI: hv: Handle vmbus_sendpacket() failure in hv_compose_msi_msg()

Handle vmbus_sendpacket() failure in hv_compose_msi_msg().

I happened to find this when reading the code.  I didn't get a real issue
however.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: KY Srinivasan <kys@microsoft.com>
CC: Jake Oshins <jakeo@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Vitaly Kuznetsov <vkuznets@redhat.com>
7 years agoPCI: hv: Remove the unused 'wrk' in struct hv_pcibus_device
Dexuan Cui [Tue, 23 Aug 2016 04:47:23 +0000 (04:47 +0000)]
PCI: hv: Remove the unused 'wrk' in struct hv_pcibus_device

Remove the unused 'wrk' member in struct hv_pcibus_device.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: KY Srinivasan <kys@microsoft.com>
CC: Jake Oshins <jakeo@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Vitaly Kuznetsov <vkuznets@redhat.com>
7 years agoPCI: hv: Use pci_function_description[0] in struct definitions
Dexuan Cui [Tue, 23 Aug 2016 04:46:39 +0000 (04:46 +0000)]
PCI: hv: Use pci_function_description[0] in struct definitions

The 2 structs can use a zero-length array here, because dynamic memory of
the correct size is allocated in hv_pci_devices_present() and we don't need
this extra element.

No functional change.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: KY Srinivasan <kys@microsoft.com>
CC: Jake Oshins <jakeo@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Vitaly Kuznetsov <vkuznets@redhat.com>
7 years agoPCI: hv: Use zero-length array in struct pci_packet
Dexuan Cui [Tue, 23 Aug 2016 04:45:51 +0000 (04:45 +0000)]
PCI: hv: Use zero-length array in struct pci_packet

Use zero-length array in struct pci_packet and rename struct pci_message's
field "message_type" to "type".  This makes the code more readable.

No functionality change.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: KY Srinivasan <kys@microsoft.com>
CC: Jake Oshins <jakeo@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Vitaly Kuznetsov <vkuznets@redhat.com>
7 years agoPCI/MSI: Enable PCI_MSI_IRQ_DOMAIN support for ARC
Joao Pinto [Tue, 9 Aug 2016 15:49:37 +0000 (16:49 +0100)]
PCI/MSI: Enable PCI_MSI_IRQ_DOMAIN support for ARC

Add ARC as an arch that supports PCI_MSI_IRQ_DOMAIN and add generation of
msi.h in the ARC arch.

Signed-off-by: Joao Pinto <jpinto@synopsys.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Vineet Gupta <vgupta@synopsys.com>
7 years agoPCI: rockchip: Add Rockchip PCIe controller support
Shawn Lin [Sat, 3 Sep 2016 16:41:09 +0000 (11:41 -0500)]
PCI: rockchip: Add Rockchip PCIe controller support

Add support for the Rockchip PCIe controller found on RK3399 SoC platform.

[bhelgaas: fold in Brian's rockchip_pcie_client_irq_handler() OR fix, other
fixes and cleanups from Guenter Roeck <linux@roeck-us.net> and me,
uninitialized variable fix from Arnd Bergmann <arnd@arndb.de>]
Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
7 years agodt-bindings: PCI: rockchip: Add DT bindings for Rockchip PCIe controller
Shawn Lin [Thu, 4 Aug 2016 07:52:07 +0000 (15:52 +0800)]
dt-bindings: PCI: rockchip: Add DT bindings for Rockchip PCIe controller

Add a binding that describes the Rockchip PCIe controller found on Rockchip
SoCs PCIe interface.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Acked-by: Rob Herring <robh@kernel.org>
7 years agoMerge branch 'pci/ptm' into next
Bjorn Helgaas [Thu, 1 Sep 2016 14:04:55 +0000 (09:04 -0500)]
Merge branch 'pci/ptm' into next

* pci/ptm:
  PCI: Add PTM clock granularity information
  PCI: Add pci_enable_ptm() for drivers to enable PTM on endpoints
  PCI: Add Precision Time Measurement (PTM) support

7 years agoMerge branch 'pci/demodularize' into next
Bjorn Helgaas [Thu, 1 Sep 2016 14:04:28 +0000 (09:04 -0500)]
Merge branch 'pci/demodularize' into next

* pci/demodularize:
  PCI: pciehp: Make explicitly non-modular
  PCI: hotplug: Make core explicitly non-modular
  PCI: xilinx-nwl: Make explicitly non-modular
  PCI: xilinx: Make explicitly non-modular
  PCI: qcom: Make explicitly non-modular
  PCI: dra7xx: Make explicitly non-modular
  PCI/AER: Make explicitly non-modular
  PCI/PME: Make explicitly non-modular
  PCI: Make DPC explicitly non-modular
  PCI: generic: Make explicitly non-modular
  PCI: exynos: Make explicitly non-modular
  PCI: designware: Make explicitly non-modular
  PCI: spear: Make explicitly non-modular
  PCI: portdrv: Make explicitly non-modular
  PCI: imx6: Make explicitly non-modular
  PCI: altera: Make explicitly non-modular
  PCI: altera: Make MSI explicitly non-modular

7 years agoPCI: altera: Rework config accessors for use without a struct pci_bus
Ley Foon Tan [Fri, 26 Aug 2016 01:47:24 +0000 (09:47 +0800)]
PCI: altera: Rework config accessors for use without a struct pci_bus

Rework configs accessors so a future patch can use them in _probe() with
struct altera_pcie instead of struct pci_bus.

Signed-off-by: Ley Foon Tan <lftan@altera.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Add PTM clock granularity information
Bjorn Helgaas [Sun, 12 Jun 2016 21:26:40 +0000 (16:26 -0500)]
PCI: Add PTM clock granularity information

The PTM Control register (PCIe r3.1, sec 7.32.3) contains an Effective
Granularity field:

  This provides information relating to the expected accuracy of the PTM
  clock, but does not otherwise affect the PTM mechanism.

Set the Effective Granularity based on the PTM Root and any intervening PTM
Time Sources.

This does not set Effective Granularity for Root Complex Integrated
Endpoints because I don't know how to figure out clock granularity for
them.  The spec says:

  ... system software must set [Effective Granularity] to the value
  reported in the Local Clock Granularity field by the associated PTM
  Time Source.

but I don't know how to identify the associated PTM Time Source.  Normally
it's the upstream bridge, but an integrated endpoint has no upstream
bridge.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: pciehp: Make explicitly non-modular
Paul Gortmaker [Wed, 24 Aug 2016 20:57:52 +0000 (16:57 -0400)]
PCI: pciehp: Make explicitly non-modular

This code is not being built as a module by anyone:

  obj-$(CONFIG_HOTPLUG_PCI_PCIE)          += pciehp.o
  pciehp-objs                             := pciehp_core.o   \

  drivers/pci/pcie/Kconfig:config HOTPLUG_PCI_PCIE
  drivers/pci/pcie/Kconfig:  bool "PCI Express Hotplug driver"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Note that for non-modular code, module_init() translates to
device_initcall().  One could argue that we should use subsys_initcall()
here, but for now we stick with runtime equivalence.

We delete module.h but we keep the moduleparam.h include, since we are
keeping the module_param() that the file has as-is for now.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Kristen Carlson Accardi <kristen@linux.intel.com>
7 years agoPCI: hotplug: Make core explicitly non-modular
Paul Gortmaker [Wed, 24 Aug 2016 20:57:51 +0000 (16:57 -0400)]
PCI: hotplug: Make core explicitly non-modular

This code is not being built as a module by anyone:

  obj-$(CONFIG_HOTPLUG_PCI)           += pci_hotplug.o
  [...]
  pci_hotplug-objs                    := pci_hotplug_core.o

  drivers/pci/hotplug/Kconfig:menuconfig HOTPLUG_PCI
  drivers/pci/hotplug/Kconfig:  bool "Support for PCI Hotplug"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Remove orphaned exit function in cpci_hotplug_core.c.

Note that for non-modular code, module_init() translates to
device_initcall().  One could argue that we should use subsys_initcall()
here, but for now we stick with runtime equivalence.

We would delete module.h and just keep the moduleparam.h include (since the
file does use module_param), but there is a try_module_get and module_put
pairing that prevents us from doing that.

[bhelgaas: changelog]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Scott Murray <scott@spiteful.org>
CC: Kristen Carlson Accardi <kristen@linux.intel.com>
7 years agoPCI: xilinx-nwl: Make explicitly non-modular
Paul Gortmaker [Wed, 24 Aug 2016 20:57:50 +0000 (16:57 -0400)]
PCI: xilinx-nwl: Make explicitly non-modular

This code is not being built as a module by anyone:

  drivers/pci/host/Kconfig:config PCIE_XILINX_NWL
  drivers/pci/host/Kconfig:  bool "NWL PCIe Core"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Explicitly disallow driver unbind, since that doesn't have a sensible use
case anyway, and it allows us to drop the ".remove" code for non-modular
drivers.  Delete several functions only used by the remove function.

Note that for non-modular code, builtin_platform_driver() uses the same
init level priority as module_platform_driver(), so this doesn't change
init ordering.

[bhelgaas: changelog]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Michal Simek <michal.simek@xilinx.com>
CC: "Sören Brinkmann" <soren.brinkmann@xilinx.com>
CC: Marc Zyngier <marc.zyngier@arm.com>
CC: Bharat Kumar Gogada <bharat.kumar.gogada@xilinx.com>
7 years agoPCI: xilinx: Make explicitly non-modular
Paul Gortmaker [Wed, 24 Aug 2016 20:57:49 +0000 (16:57 -0400)]
PCI: xilinx: Make explicitly non-modular

This code is not being built as a module by anyone:

  drivers/pci/host/Kconfig:config PCIE_XILINX
  drivers/pci/host/Kconfig:  bool "Xilinx AXI PCIe host bridge support"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Note that for non-modular code, builtin_platform_driver() uses the same
init level priority as module_platform_driver(), so this doesn't change
init ordering.

[bhelgaas: changelog]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Michal Simek <michal.simek@xilinx.com>
CC: "Sören Brinkmann" <soren.brinkmann@xilinx.com>
7 years agoPCI: qcom: Make explicitly non-modular
Paul Gortmaker [Wed, 24 Aug 2016 20:57:48 +0000 (16:57 -0400)]
PCI: qcom: Make explicitly non-modular

This code is not being built as a module by anyone:

  drivers/pci/host/Kconfig:config PCIE_QCOM
  drivers/pci/host/Kconfig:  bool "Qualcomm PCIe controller"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Note that for non-modular code, MODULE_DEVICE_TABLE is a no-op and
builtin_platform_driver() uses the same init level priority as
module_platform_driver(), so this doesn't change init ordering.

Explicitly disallow driver unbind, since that doesn't have a sensible use
case anyway, and it allows us to drop the ".remove" code for non-modular
drivers.

[bhelgaas: changelog]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Stanimir Varbanov <svarbanov@mm-sol.com>
7 years agoPCI: dra7xx: Make explicitly non-modular
Paul Gortmaker [Wed, 24 Aug 2016 20:57:47 +0000 (16:57 -0400)]
PCI: dra7xx: Make explicitly non-modular

This code is not being built as a module by anyone:

  drivers/pci/host/Kconfig:config PCI_DRA7XX
  drivers/pci/host/Kconfig:  bool "TI DRA7xx PCIe controller"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Note that for non-modular code, MODULE_DEVICE_TABLE is a no-op and
builtin_platform_driver_probe() uses the same init level priority as
module_platform_driver_probe(), so this doesn't change init ordering.

Explicitly disallow driver unbind, since that doesn't have a sensible use
case anyway, and it allows us to drop the ".remove" code for non-modular
drivers.

[bhelgaas: changelog]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Kishon Vijay Abraham I <kishon@ti.com>
7 years agoPCI/AER: Make explicitly non-modular
Paul Gortmaker [Wed, 24 Aug 2016 20:57:46 +0000 (16:57 -0400)]
PCI/AER: Make explicitly non-modular

This code is not being built as a module by anyone:

  obj-$(CONFIG_PCIEAER) += aerdriver.o
  aerdriver-objs := aerdrv_errprint.o aerdrv_core.o aerdrv.o

  drivers/pci/pcie/aer/Kconfig:config PCIEAER
  drivers/pci/pcie/aer/Kconfig:  bool "Root Port Advanced Error Reporting support"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Note that for non-modular code, module_init() translates to
device_initcall().

[bhelgaas: changelog]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Tom Long Nguyen <tom.l.nguyen@intel.com>
7 years agoPCI/PME: Make explicitly non-modular
Paul Gortmaker [Wed, 24 Aug 2016 20:57:45 +0000 (16:57 -0400)]
PCI/PME: Make explicitly non-modular

This code is not being built as a module by anyone:

  config PCIE_PME
        def_bool y
        depends on PCIEPORTBUS && PM

Remove traces of modularity so that when reading the driver there is no
doubt it is builtin-only.

Also delete the .remove function, since that doesn't seem to have a
sensible use case.  With "normal" endpoint drivers, we have in the past set
the suppress_bind_attrs bit to make it clear that the use of ".remove" in a
builtin driver was deleted, but here for PCI, it seems overkill to jump
through the pcie_port_service_driver and into the struct device_driver in
order to finally try and do something similar with the bind setting.

Note that for non-modular code, module_init() translates to
device_initcall().

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: Make DPC explicitly non-modular
Paul Gortmaker [Wed, 24 Aug 2016 20:57:44 +0000 (16:57 -0400)]
PCI: Make DPC explicitly non-modular

This code is not being built as a module by anyone:

  drivers/pci/pcie/Kconfig:config PCIE_DPC
  drivers/pci/pcie/Kconfig:  bool "PCIe Downstream Port Containment support"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Note that for non-modular code, module_init() translates to
device_initcall().

[bhelgaas: changelog]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Keith Busch <keith.busch@intel.com>
CC: Mika Westerberg <mika.westerberg@linux.intel.com>
7 years agoPCI: generic: Make explicitly non-modular
Paul Gortmaker [Mon, 22 Aug 2016 21:59:48 +0000 (17:59 -0400)]
PCI: generic: Make explicitly non-modular

This code is not being built as a module by anyone:

  drivers/pci/host/Kconfig:config PCI_HOST_COMMON
  drivers/pci/host/Kconfig:  bool

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Will Deacon <will.deacon@arm.com>
7 years agoPCI: designware: Remove redundant platform_get_resource() return value check
Wei Yongjun [Thu, 28 Jul 2016 16:14:54 +0000 (16:14 +0000)]
PCI: designware: Remove redundant platform_get_resource() return value check

devm_ioremap_resource() fails gracefully when given a NULL resource
pointer, so we don't need to check separately for failure from
platform_get_resource_byname().  Remove the redundant check.

[bhelgaas: changelog]
Signed-off-by: Wei Yongjun <weiyj.lk@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: designware: Exchange viewport of `MEMORYs' and `CFGs/IOs'
Dong Bo [Mon, 4 Jul 2016 16:14:43 +0000 (21:44 +0530)]
PCI: designware: Exchange viewport of `MEMORYs' and `CFGs/IOs'

When we have only two view ports in a DesignWare PCIe platform, iatu0
is used for both CFG and IO accesses.  When CFGs are sent to peripherals
(e.g., lspci), iatu0 frequently switches between CFG and IO.

For such scenarios, a MEMORY might be sent as an IOs by mistake.
Considering the following configurations:

  MEMORY  ->   BASE_ADDR: 0xb4100000, LIMIT: 0xb4100FFF, TYPE=mem
  CFG     ->   BASE_ADDR: 0xb4000000, LIMIT: 0xb4000FFF, TYPE=cfg
  IO      ->   BASE_ADDR: 0xFFFFFFFF, LIMIT: 0xFFFFFFFE, TYPE=io

Suppose PCIe has just completed a CFG access.  To switch back to IO, it
sets the BASE_ADDR to 0xFFFFFFFF, LIMIT 0xFFFFFFFE and TYPE to IO.  When
another CFG comes, the BASE_ADDR is set to 0xb4000000 to switch to CFG.  At
this moment, a MEMORY access shows up, since it matches with iatu0 (due to
0xb4000000 <= MEMORY BASE_ADDR <= MEMORY LIMIT <= 0xFFFFFFF), it is treated
as an IO access by mistake, then sent to perpheral.

This patch fixes the problem by exchanging the assignments of `MEMORYs' and
`CFGs/IOs', which assigning MEMORYs to iatu0, CFGs and IOs to iatu1.

We can still have issues with IO transfer, however memory transfer is used
predominantly therefore we are just minimizing the risk of failure.
Actually, we can not do much when we have only two viewports.  We can
either not allow the less frequent IO transfers at all, or can live with a
remote possibility of getting it corrupted.

Signed-off-by: Dong Bo <dongbo4@huawei.com>
[pratyush.anand@gmail.com: Modified commit log to capture remote risk]
Signed-off-by: Pratyush Anand <pratyush.anand@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
7 years agoPCI: exynos: Make explicitly non-modular
Paul Gortmaker [Mon, 22 Aug 2016 21:59:47 +0000 (17:59 -0400)]
PCI: exynos: Make explicitly non-modular

This code is not being built as a module by anyone:

  drivers/pci/host/Kconfig:config PCI_EXYNOS
  drivers/pci/host/Kconfig:  bool "Samsung Exynos PCIe controller"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Note that for non-modular code, MODULE_DEVICE_TABLE is a no-op.

[bhelgaas: changelog]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Krzysztof Kozlowski <krzk@kernel.org>
CC: Jingoo Han <jingoohan1@gmail.com>
CC: Kukjin Kim <kgene@kernel.org>
7 years agoPCI: designware: Make explicitly non-modular
Paul Gortmaker [Mon, 22 Aug 2016 21:59:46 +0000 (17:59 -0400)]
PCI: designware: Make explicitly non-modular

This code is not being built as a module by anyone:

  drivers/pci/host/Kconfig:config PCIE_DW
  drivers/pci/host/Kconfig:  bool

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

[bhelgaas: changelog]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Jingoo Han <jingoohan1@gmail.com>
CC: Pratyush Anand <pratyush.anand@gmail.com>
7 years agoPCI: spear: Make explicitly non-modular
Paul Gortmaker [Mon, 22 Aug 2016 21:59:45 +0000 (17:59 -0400)]
PCI: spear: Make explicitly non-modular

This code is not being built as a module by anyone:

  drivers/pci/host/Kconfig:config PCIE_SPEAR13XX
  drivers/pci/host/Kconfig:  bool "STMicroelectronics SPEAr PCIe controller"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Note that for non-modular code, MODULE_DEVICE_TABLE is a no-op and
module_init() translates to device_initcall().

[bhelgaas: changelog]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Pratyush Anand <pratyush.anand@gmail.com>
7 years agoPCI: portdrv: Make explicitly non-modular
Paul Gortmaker [Mon, 22 Aug 2016 21:59:44 +0000 (17:59 -0400)]
PCI: portdrv: Make explicitly non-modular

This code is not being built as a module by anyone:

  pcieportdrv-y               := portdrv_core.o portdrv_pci.o portdrv_bus.o
  obj-$(CONFIG_PCIEPORTBUS)   += pcieportdrv.o

  drivers/pci/pcie/Kconfig:config PCIEPORTBUS
  drivers/pci/pcie/Kconfig:  bool "PCI Express Port Bus support"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Note that for non-modular code, MODULE_DEVICE_TABLE is a no-op and
module_init() translates to device_initcall().

[bhelgaas: changelog, remove unused DRIVER_* macros]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Tom Long Nguyen <tom.l.nguyen@intel.com>
7 years agoPCI: imx6: Make explicitly non-modular
Paul Gortmaker [Mon, 22 Aug 2016 21:59:43 +0000 (17:59 -0400)]
PCI: imx6: Make explicitly non-modular

This code is not being built as a module by anyone:

  drivers/pci/host/Kconfig:config PCI_IMX6
  drivers/pci/host/Kconfig:  bool "Freescale i.MX6 PCIe controller"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Note that for non-modular code, MODULE_DEVICE_TABLE is a no-op and
module_init() translates to device_initcall().

[bhelgaas: changelog]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Richard Zhu <Richard.Zhu@freescale.com>
CC: Lucas Stach <l.stach@pengutronix.de>
7 years agoPCI: altera: Make explicitly non-modular
Paul Gortmaker [Mon, 22 Aug 2016 21:59:42 +0000 (17:59 -0400)]
PCI: altera: Make explicitly non-modular

This code is not being built as a module by anyone:

  drivers/pci/host/Kconfig:config PCIE_ALTERA
  drivers/pci/host/Kconfig:  bool "Altera PCIe controller"

Remove uses of MODULE_DESCRIPTION(), MODULE_AUTHOR(), MODULE_LICENSE(),
etc., so that when reading the driver there is no doubt it is builtin-only.
The information is preserved in comments at the top of the file.

Note that for non-modular code, MODULE_DEVICE_TABLE is a no-op and
module_init() translates to device_initcall().

[bhelgaas: changelog]
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Ley Foon Tan <lftan@altera.com>