]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
Merge branches 'pci/msi', 'pci/iommu' and 'pci/cleanup' into next
authorBjorn Helgaas <bhelgaas@google.com>
Wed, 11 Jun 2014 20:38:25 +0000 (14:38 -0600)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 11 Jun 2014 20:38:25 +0000 (14:38 -0600)
* pci/msi:
  PCI/MSI: Fix memory leak in free_msi_irqs()

* pci/iommu:
  PCI: Add function 1 DMA alias quirk for HighPoint RocketRaid 642L
  PCI: Add bridge DMA alias quirk for ITE bridge

* pci/cleanup:
  PCI: Merge multi-line quoted strings
  PCI: Whitespace cleanup
  PCI: Move EXPORT_SYMBOL so it immediately follows function/variable

141 files changed:
Documentation/ABI/testing/sysfs-bus-pci
Documentation/DMA-API-HOWTO.txt
Documentation/DMA-API.txt
Documentation/DMA-ISA-LPC.txt
Documentation/devicetree/bindings/pci/designware-pcie.txt
Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt [new file with mode: 0644]
Documentation/devicetree/bindings/pci/host-generic-pci.txt [new file with mode: 0644]
Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt [new file with mode: 0644]
Documentation/devicetree/bindings/pci/rcar-pci.txt [new file with mode: 0644]
Documentation/devicetree/bindings/pci/samsung,exynos5440-pcie.txt [new file with mode: 0644]
MAINTAINERS
arch/alpha/include/asm/pci.h
arch/arm/include/asm/pci.h
arch/arm/kernel/bios32.c
arch/blackfin/include/asm/pci.h
arch/cris/include/asm/pci.h
arch/frv/include/asm/pci.h
arch/frv/mb93090-mb00/pci-irq.c
arch/ia64/include/asm/pci.h
arch/ia64/pci/fixup.c
arch/microblaze/include/asm/pci.h
arch/microblaze/pci/pci-common.c
arch/mips/include/asm/pci.h
arch/mn10300/include/asm/pci.h
arch/mn10300/unit-asb2305/pci-irq.c
arch/parisc/include/asm/pci.h
arch/powerpc/include/asm/pci.h
arch/powerpc/kernel/pci-common.c
arch/powerpc/kernel/pci-hotplug.c
arch/powerpc/kernel/pci_64.c
arch/powerpc/kernel/pci_of_scan.c
arch/s390/include/asm/pci.h
arch/s390/pci/pci.c
arch/s390/pci/pci_sysfs.c
arch/sh/drivers/pci/fixups-dreamcast.c
arch/sh/include/asm/pci.h
arch/sparc/include/asm/pci_32.h
arch/sparc/include/asm/pci_64.h
arch/sparc/kernel/pci.c
arch/unicore32/include/asm/pci.h
arch/x86/include/asm/pci.h
arch/x86/kernel/aperture_64.c
arch/x86/pci/acpi.c
arch/x86/pci/amd_bus.c
arch/x86/pci/broadcom_bus.c
arch/x86/pci/fixup.c
arch/x86/pci/i386.c
arch/xtensa/include/asm/pci.h
drivers/base/dma-coherent.c
drivers/base/dma-mapping.c
drivers/block/nvme-core.c
drivers/bus/mvebu-mbus.c
drivers/edac/i82875p_edac.c
drivers/iommu/exynos-iommu.c
drivers/misc/genwqe/card_utils.c
drivers/pci/access.c
drivers/pci/bus.c
drivers/pci/host-bridge.c
drivers/pci/host/Kconfig
drivers/pci/host/Makefile
drivers/pci/host/pci-exynos.c
drivers/pci/host/pci-host-generic.c [new file with mode: 0644]
drivers/pci/host/pci-imx6.c
drivers/pci/host/pci-mvebu.c
drivers/pci/host/pci-rcar-gen2.c
drivers/pci/host/pci-tegra.c
drivers/pci/host/pcie-designware.c
drivers/pci/host/pcie-designware.h
drivers/pci/host/pcie-rcar.c [new file with mode: 0644]
drivers/pci/hotplug-pci.c
drivers/pci/hotplug/acpiphp_core.c
drivers/pci/hotplug/acpiphp_glue.c
drivers/pci/hotplug/cpci_hotplug.h
drivers/pci/hotplug/cpci_hotplug_core.c
drivers/pci/hotplug/cpci_hotplug_pci.c
drivers/pci/hotplug/cpcihp_generic.c
drivers/pci/hotplug/cpcihp_zt5550.c
drivers/pci/hotplug/cpqphp.h
drivers/pci/hotplug/cpqphp_core.c
drivers/pci/hotplug/cpqphp_ctrl.c
drivers/pci/hotplug/cpqphp_nvram.c
drivers/pci/hotplug/cpqphp_pci.c
drivers/pci/hotplug/cpqphp_sysfs.c
drivers/pci/hotplug/ibmphp_core.c
drivers/pci/hotplug/ibmphp_ebda.c
drivers/pci/hotplug/ibmphp_hpc.c
drivers/pci/hotplug/ibmphp_pci.c
drivers/pci/hotplug/ibmphp_res.c
drivers/pci/hotplug/pci_hotplug_core.c
drivers/pci/hotplug/pciehp.h
drivers/pci/hotplug/pciehp_acpi.c
drivers/pci/hotplug/pciehp_core.c
drivers/pci/hotplug/pciehp_ctrl.c
drivers/pci/hotplug/pciehp_hpc.c
drivers/pci/hotplug/pciehp_pci.c
drivers/pci/hotplug/pcihp_skeleton.c
drivers/pci/hotplug/pcihp_slot.c
drivers/pci/hotplug/rpadlpar_core.c
drivers/pci/hotplug/rpaphp_core.c
drivers/pci/hotplug/s390_pci_hpc.c
drivers/pci/hotplug/sgi_hotplug.c
drivers/pci/hotplug/shpchp.h
drivers/pci/hotplug/shpchp_core.c
drivers/pci/hotplug/shpchp_ctrl.c
drivers/pci/hotplug/shpchp_hpc.c
drivers/pci/hotplug/shpchp_pci.c
drivers/pci/hotplug/shpchp_sysfs.c
drivers/pci/htirq.c
drivers/pci/iov.c
drivers/pci/msi.c
drivers/pci/pci-acpi.c
drivers/pci/pci-driver.c
drivers/pci/pci-label.c
drivers/pci/pci-stub.c
drivers/pci/pci-sysfs.c
drivers/pci/pci.c
drivers/pci/pci.h
drivers/pci/pcie/aer/aer_inject.c
drivers/pci/pcie/aer/aerdrv_core.c
drivers/pci/pcie/aer/aerdrv_errprint.c
drivers/pci/pcie/pme.c
drivers/pci/pcie/portdrv_core.c
drivers/pci/pcie/portdrv_pci.c
drivers/pci/probe.c
drivers/pci/proc.c
drivers/pci/quirks.c
drivers/pci/rom.c
drivers/pci/search.c
drivers/pci/setup-bus.c
drivers/pci/setup-irq.c
drivers/pci/setup-res.c
drivers/pci/syscall.c
drivers/pcmcia/cardbus.c
drivers/platform/x86/asus-wmi.c
drivers/platform/x86/eeepc-laptop.c
include/asm-generic/dma-coherent.h
include/linux/dma-mapping.h
include/linux/pci.h
include/linux/pci_ids.h
include/linux/types.h
kernel/resource.c

index a3c5a6685036103e7ec677272acdc4620d0302f6..6615fda0abfb15d2c198f17fdeb31e1df8b84888 100644 (file)
@@ -117,7 +117,7 @@ Description:
 
 What:          /sys/bus/pci/devices/.../vpd
 Date:          February 2008
-Contact:       Ben Hutchings <bhutchings@solarflare.com>
+Contact:       Ben Hutchings <bwh@kernel.org>
 Description:
                A file named vpd in a device directory will be a
                binary file containing the Vital Product Data for the
@@ -250,3 +250,24 @@ Description:
                valid.  For example, writing a 2 to this file when sriov_numvfs
                is not 0 and not 2 already will return an error. Writing a 10
                when the value of sriov_totalvfs is 8 will return an error.
+
+What:          /sys/bus/pci/devices/.../driver_override
+Date:          April 2014
+Contact:       Alex Williamson <alex.williamson@redhat.com>
+Description:
+               This file allows the driver for a device to be specified which
+               will override standard static and dynamic ID matching.  When
+               specified, only a driver with a name matching the value written
+               to driver_override will have an opportunity to bind to the
+               device.  The override is specified by writing a string to the
+               driver_override file (echo pci-stub > driver_override) and
+               may be cleared with an empty string (echo > driver_override).
+               This returns the device to standard matching rules binding.
+               Writing to driver_override does not automatically unbind the
+               device from its current driver or make any attempt to
+               automatically load the specified driver.  If no driver with a
+               matching name is currently loaded in the kernel, the device
+               will not bind to any driver.  This also allows devices to
+               opt-out of driver binding using a driver_override name such as
+               "none".  Only a single driver may be specified in the override,
+               there is no support for parsing delimiters.
index 5e983031cc11be35fba1aab90546db5a7de1eeb3..dcbbe3602d78a9f0864500c3d106feffb06f00a1 100644 (file)
@@ -9,16 +9,76 @@ This is a guide to device driver writers on how to use the DMA API
 with example pseudo-code.  For a concise description of the API, see
 DMA-API.txt.
 
-Most of the 64bit platforms have special hardware that translates bus
-addresses (DMA addresses) into physical addresses.  This is similar to
-how page tables and/or a TLB translates virtual addresses to physical
-addresses on a CPU.  This is needed so that e.g. PCI devices can
-access with a Single Address Cycle (32bit DMA address) any page in the
-64bit physical address space.  Previously in Linux those 64bit
-platforms had to set artificial limits on the maximum RAM size in the
-system, so that the virt_to_bus() static scheme works (the DMA address
-translation tables were simply filled on bootup to map each bus
-address to the physical page __pa(bus_to_virt())).
+                       CPU and DMA addresses
+
+There are several kinds of addresses involved in the DMA API, and it's
+important to understand the differences.
+
+The kernel normally uses virtual addresses.  Any address returned by
+kmalloc(), vmalloc(), and similar interfaces is a virtual address and can
+be stored in a "void *".
+
+The virtual memory system (TLB, page tables, etc.) translates virtual
+addresses to CPU physical addresses, which are stored as "phys_addr_t" or
+"resource_size_t".  The kernel manages device resources like registers as
+physical addresses.  These are the addresses in /proc/iomem.  The physical
+address is not directly useful to a driver; it must use ioremap() to map
+the space and produce a virtual address.
+
+I/O devices use a third kind of address: a "bus address" or "DMA address".
+If a device has registers at an MMIO address, or if it performs DMA to read
+or write system memory, the addresses used by the device are bus addresses.
+In some systems, bus addresses are identical to CPU physical addresses, but
+in general they are not.  IOMMUs and host bridges can produce arbitrary
+mappings between physical and bus addresses.
+
+Here's a picture and some examples:
+
+               CPU                  CPU                  Bus
+             Virtual              Physical             Address
+             Address              Address               Space
+              Space                Space
+
+            +-------+             +------+             +------+
+            |       |             |MMIO  |   Offset    |      |
+            |       |  Virtual    |Space |   applied   |      |
+          C +-------+ --------> B +------+ ----------> +------+ A
+            |       |  mapping    |      |   by host   |      |
+  +-----+   |       |             |      |   bridge    |      |   +--------+
+  |     |   |       |             +------+             |      |   |        |
+  | CPU |   |       |             | RAM  |             |      |   | Device |
+  |     |   |       |             |      |             |      |   |        |
+  +-----+   +-------+             +------+             +------+   +--------+
+            |       |  Virtual    |Buffer|   Mapping   |      |
+          X +-------+ --------> Y +------+ <---------- +------+ Z
+            |       |  mapping    | RAM  |   by IOMMU
+            |       |             |      |
+            |       |             |      |
+            +-------+             +------+
+
+During the enumeration process, the kernel learns about I/O devices and
+their MMIO space and the host bridges that connect them to the system.  For
+example, if a PCI device has a BAR, the kernel reads the bus address (A)
+from the BAR and converts it to a CPU physical address (B).  The address B
+is stored in a struct resource and usually exposed via /proc/iomem.  When a
+driver claims a device, it typically uses ioremap() to map physical address
+B at a virtual address (C).  It can then use, e.g., ioread32(C), to access
+the device registers at bus address A.
+
+If the device supports DMA, the driver sets up a buffer using kmalloc() or
+a similar interface, which returns a virtual address (X).  The virtual
+memory system maps X to a physical address (Y) in system RAM.  The driver
+can use virtual address X to access the buffer, but the device itself
+cannot because DMA doesn't go through the CPU virtual memory system.
+
+In some simple systems, the device can do DMA directly to physical address
+Y.  But in many others, there is IOMMU hardware that translates bus
+addresses to physical addresses, e.g., it translates Z to Y.  This is part
+of the reason for the DMA API: the driver can give a virtual address X to
+an interface like dma_map_single(), which sets up any required IOMMU
+mapping and returns the bus address Z.  The driver then tells the device to
+do DMA to Z, and the IOMMU maps it to the buffer at address Y in system
+RAM.
 
 So that Linux can use the dynamic DMA mapping, it needs some help from the
 drivers, namely it has to take into account that DMA addresses should be
@@ -29,17 +89,17 @@ The following API will work of course even on platforms where no such
 hardware exists.
 
 Note that the DMA API works with any bus independent of the underlying
-microprocessor architecture. You should use the DMA API rather than
-the bus specific DMA API (e.g. pci_dma_*).
+microprocessor architecture. You should use the DMA API rather than the
+bus-specific DMA API, i.e., use the dma_map_*() interfaces rather than the
+pci_map_*() interfaces.
 
 First of all, you should make sure
 
 #include <linux/dma-mapping.h>
 
-is in your driver. This file will obtain for you the definition of the
-dma_addr_t (which can hold any valid DMA address for the platform)
-type which should be used everywhere you hold a DMA (bus) address
-returned from the DMA mapping functions.
+is in your driver, which provides the definition of dma_addr_t.  This type
+can hold any valid DMA or bus address for the platform and should be used
+everywhere you hold a DMA address returned from the DMA mapping functions.
 
                         What memory is DMA'able?
 
@@ -123,9 +183,9 @@ Here, dev is a pointer to the device struct of your device, and mask
 is a bit mask describing which bits of an address your device
 supports.  It returns zero if your card can perform DMA properly on
 the machine given the address mask you provided.  In general, the
-device struct of your device is embedded in the bus specific device
-struct of your device.  For example, a pointer to the device struct of
-your PCI device is pdev->dev (pdev is a pointer to the PCI device
+device struct of your device is embedded in the bus-specific device
+struct of your device.  For example, &pdev->dev is a pointer to the
+device struct of a PCI device (pdev is a pointer to the PCI device
 struct of your device).
 
 If it returns non-zero, your device cannot perform DMA properly on
@@ -147,8 +207,7 @@ exactly why.
 The standard 32-bit addressing device would do something like this:
 
        if (dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32))) {
-               printk(KERN_WARNING
-                      "mydev: No suitable DMA available.\n");
+               dev_warn(dev, "mydev: No suitable DMA available\n");
                goto ignore_this_device;
        }
 
@@ -170,8 +229,7 @@ all 64-bits when accessing streaming DMA:
        } else if (!dma_set_mask(dev, DMA_BIT_MASK(32))) {
                using_dac = 0;
        } else {
-               printk(KERN_WARNING
-                      "mydev: No suitable DMA available.\n");
+               dev_warn(dev, "mydev: No suitable DMA available\n");
                goto ignore_this_device;
        }
 
@@ -187,22 +245,20 @@ the case would look like this:
                using_dac = 0;
                consistent_using_dac = 0;
        } else {
-               printk(KERN_WARNING
-                      "mydev: No suitable DMA available.\n");
+               dev_warn(dev, "mydev: No suitable DMA available\n");
                goto ignore_this_device;
        }
 
-The coherent coherent mask will always be able to set the same or a
-smaller mask as the streaming mask. However for the rare case that a
-device driver only uses consistent allocations, one would have to
-check the return value from dma_set_coherent_mask().
+The coherent mask will always be able to set the same or a smaller mask as
+the streaming mask. However for the rare case that a device driver only
+uses consistent allocations, one would have to check the return value from
+dma_set_coherent_mask().
 
 Finally, if your device can only drive the low 24-bits of
 address you might do something like:
 
        if (dma_set_mask(dev, DMA_BIT_MASK(24))) {
-               printk(KERN_WARNING
-                      "mydev: 24-bit DMA addressing not available.\n");
+               dev_warn(dev, "mydev: 24-bit DMA addressing not available\n");
                goto ignore_this_device;
        }
 
@@ -232,14 +288,14 @@ Here is pseudo-code showing how this might be done:
                card->playback_enabled = 1;
        } else {
                card->playback_enabled = 0;
-               printk(KERN_WARNING "%s: Playback disabled due to DMA limitations.\n",
+               dev_warn(dev, "%s: Playback disabled due to DMA limitations\n",
                       card->name);
        }
        if (!dma_set_mask(dev, RECORD_ADDRESS_BITS)) {
                card->record_enabled = 1;
        } else {
                card->record_enabled = 0;
-               printk(KERN_WARNING "%s: Record disabled due to DMA limitations.\n",
+               dev_warn(dev, "%s: Record disabled due to DMA limitations\n",
                       card->name);
        }
 
@@ -331,7 +387,7 @@ context with the GFP_ATOMIC flag.
 Size is the length of the region you want to allocate, in bytes.
 
 This routine will allocate RAM for that region, so it acts similarly to
-__get_free_pages (but takes size instead of a page order).  If your
+__get_free_pages() (but takes size instead of a page order).  If your
 driver needs regions sized smaller than a page, you may prefer using
 the dma_pool interface, described below.
 
@@ -343,11 +399,11 @@ the consistent DMA mask has been explicitly changed via
 dma_set_coherent_mask().  This is true of the dma_pool interface as
 well.
 
-dma_alloc_coherent returns two values: the virtual address which you
+dma_alloc_coherent() returns two values: the virtual address which you
 can use to access it from the CPU and dma_handle which you pass to the
 card.
 
-The cpu return address and the DMA bus master address are both
+The CPU virtual address and the DMA bus address are both
 guaranteed to be aligned to the smallest PAGE_SIZE order which
 is greater than or equal to the requested size.  This invariant
 exists (for example) to guarantee that if you allocate a chunk
@@ -359,13 +415,13 @@ To unmap and free such a DMA region, you call:
        dma_free_coherent(dev, size, cpu_addr, dma_handle);
 
 where dev, size are the same as in the above call and cpu_addr and
-dma_handle are the values dma_alloc_coherent returned to you.
+dma_handle are the values dma_alloc_coherent() returned to you.
 This function may not be called in interrupt context.
 
 If your driver needs lots of smaller memory regions, you can write
-custom code to subdivide pages returned by dma_alloc_coherent,
+custom code to subdivide pages returned by dma_alloc_coherent(),
 or you can use the dma_pool API to do that.  A dma_pool is like
-a kmem_cache, but it uses dma_alloc_coherent not __get_free_pages.
+a kmem_cache, but it uses dma_alloc_coherent(), not __get_free_pages().
 Also, it understands common hardware constraints for alignment,
 like queue heads needing to be aligned on N byte boundaries.
 
@@ -373,37 +429,37 @@ Create a dma_pool like this:
 
        struct dma_pool *pool;
 
-       pool = dma_pool_create(name, dev, size, align, alloc);
+       pool = dma_pool_create(name, dev, size, align, boundary);
 
 The "name" is for diagnostics (like a kmem_cache name); dev and size
 are as above.  The device's hardware alignment requirement for this
 type of data is "align" (which is expressed in bytes, and must be a
 power of two).  If your device has no boundary crossing restrictions,
-pass 0 for alloc; passing 4096 says memory allocated from this pool
+pass 0 for boundary; passing 4096 says memory allocated from this pool
 must not cross 4KByte boundaries (but at that time it may be better to
-go for dma_alloc_coherent directly instead).
+use dma_alloc_coherent() directly instead).
 
-Allocate memory from a dma pool like this:
+Allocate memory from a DMA pool like this:
 
        cpu_addr = dma_pool_alloc(pool, flags, &dma_handle);
 
-flags are SLAB_KERNEL if blocking is permitted (not in_interrupt nor
-holding SMP locks), SLAB_ATOMIC otherwise.  Like dma_alloc_coherent,
+flags are GFP_KERNEL if blocking is permitted (not in_interrupt nor
+holding SMP locks), GFP_ATOMIC otherwise.  Like dma_alloc_coherent(),
 this returns two values, cpu_addr and dma_handle.
 
 Free memory that was allocated from a dma_pool like this:
 
        dma_pool_free(pool, cpu_addr, dma_handle);
 
-where pool is what you passed to dma_pool_alloc, and cpu_addr and
-dma_handle are the values dma_pool_alloc returned. This function
+where pool is what you passed to dma_pool_alloc(), and cpu_addr and
+dma_handle are the values dma_pool_alloc() returned. This function
 may be called in interrupt context.
 
 Destroy a dma_pool by calling:
 
        dma_pool_destroy(pool);
 
-Make sure you've called dma_pool_free for all memory allocated
+Make sure you've called dma_pool_free() for all memory allocated
 from a pool before you destroy the pool. This function may not
 be called in interrupt context.
 
@@ -418,7 +474,7 @@ one of the following values:
  DMA_FROM_DEVICE
  DMA_NONE
 
-One should provide the exact DMA direction if you know it.
+You should provide the exact DMA direction if you know it.
 
 DMA_TO_DEVICE means "from main memory to the device"
 DMA_FROM_DEVICE means "from the device to main memory"
@@ -489,14 +545,14 @@ and to unmap it:
        dma_unmap_single(dev, dma_handle, size, direction);
 
 You should call dma_mapping_error() as dma_map_single() could fail and return
-error. Not all dma implementations support dma_mapping_error() interface.
+error. Not all DMA implementations support the dma_mapping_error() interface.
 However, it is a good practice to call dma_mapping_error() interface, which
 will invoke the generic mapping error check interface. Doing so will ensure
-that the mapping code will work correctly on all dma implementations without
+that the mapping code will work correctly on all DMA implementations without
 any dependency on the specifics of the underlying implementation. Using the
 returned address without checking for errors could result in failures ranging
 from panics to silent data corruption. A couple of examples of incorrect ways
-to check for errors that make assumptions about the underlying dma
+to check for errors that make assumptions about the underlying DMA
 implementation are as follows and these are applicable to dma_map_page() as
 well.
 
@@ -516,13 +572,13 @@ Incorrect example 2:
                goto map_error;
        }
 
-You should call dma_unmap_single when the DMA activity is finished, e.g.
+You should call dma_unmap_single() when the DMA activity is finished, e.g.,
 from the interrupt which told you that the DMA transfer is done.
 
-Using cpu pointers like this for single mappings has a disadvantage,
+Using CPU pointers like this for single mappings has a disadvantage:
 you cannot reference HIGHMEM memory in this way.  Thus, there is a
-map/unmap interface pair akin to dma_{map,unmap}_single.  These
-interfaces deal with page/offset pairs instead of cpu pointers.
+map/unmap interface pair akin to dma_{map,unmap}_single().  These
+interfaces deal with page/offset pairs instead of CPU pointers.
 Specifically:
 
        struct device *dev = &my_dev->dev;
@@ -550,7 +606,7 @@ Here, "offset" means byte offset within the given page.
 You should call dma_mapping_error() as dma_map_page() could fail and return
 error as outlined under the dma_map_single() discussion.
 
-You should call dma_unmap_page when the DMA activity is finished, e.g.
+You should call dma_unmap_page() when the DMA activity is finished, e.g.,
 from the interrupt which told you that the DMA transfer is done.
 
 With scatterlists, you map a region gathered from several regions by:
@@ -588,18 +644,16 @@ PLEASE NOTE:  The 'nents' argument to the dma_unmap_sg call must be
              it should _NOT_ be the 'count' value _returned_ from the
               dma_map_sg call.
 
-Every dma_map_{single,sg} call should have its dma_unmap_{single,sg}
-counterpart, because the bus address space is a shared resource (although
-in some ports the mapping is per each BUS so less devices contend for the
-same bus address space) and you could render the machine unusable by eating
-all bus addresses.
+Every dma_map_{single,sg}() call should have its dma_unmap_{single,sg}()
+counterpart, because the bus address space is a shared resource and
+you could render the machine unusable by consuming all bus addresses.
 
 If you need to use the same streaming DMA region multiple times and touch
 the data in between the DMA transfers, the buffer needs to be synced
-properly in order for the cpu and device to see the most uptodate and
+properly in order for the CPU and device to see the most up-to-date and
 correct copy of the DMA buffer.
 
-So, firstly, just map it with dma_map_{single,sg}, and after each DMA
+So, firstly, just map it with dma_map_{single,sg}(), and after each DMA
 transfer call either:
 
        dma_sync_single_for_cpu(dev, dma_handle, size, direction);
@@ -611,7 +665,7 @@ or:
 as appropriate.
 
 Then, if you wish to let the device get at the DMA area again,
-finish accessing the data with the cpu, and then before actually
+finish accessing the data with the CPU, and then before actually
 giving the buffer to the hardware call either:
 
        dma_sync_single_for_device(dev, dma_handle, size, direction);
@@ -623,9 +677,9 @@ or:
 as appropriate.
 
 After the last DMA transfer call one of the DMA unmap routines
-dma_unmap_{single,sg}. If you don't touch the data from the first dma_map_*
-call till dma_unmap_*, then you don't have to call the dma_sync_*
-routines at all.
+dma_unmap_{single,sg}(). If you don't touch the data from the first
+dma_map_*() call till dma_unmap_*(), then you don't have to call the
+dma_sync_*() routines at all.
 
 Here is pseudo code which shows a situation in which you would need
 to use the dma_sync_*() interfaces.
@@ -690,12 +744,12 @@ to use the dma_sync_*() interfaces.
                }
        }
 
-Drivers converted fully to this interface should not use virt_to_bus any
-longer, nor should they use bus_to_virt. Some drivers have to be changed a
-little bit, because there is no longer an equivalent to bus_to_virt in the
+Drivers converted fully to this interface should not use virt_to_bus() any
+longer, nor should they use bus_to_virt(). Some drivers have to be changed a
+little bit, because there is no longer an equivalent to bus_to_virt() in the
 dynamic DMA mapping scheme - you have to always store the DMA addresses
-returned by the dma_alloc_coherent, dma_pool_alloc, and dma_map_single
-calls (dma_map_sg stores them in the scatterlist itself if the platform
+returned by the dma_alloc_coherent(), dma_pool_alloc(), and dma_map_single()
+calls (dma_map_sg() stores them in the scatterlist itself if the platform
 supports dynamic DMA mapping in hardware) in your driver structures and/or
 in the card registers.
 
@@ -709,9 +763,9 @@ as it is impossible to correctly support them.
 DMA address space is limited on some architectures and an allocation
 failure can be determined by:
 
-- checking if dma_alloc_coherent returns NULL or dma_map_sg returns 0
+- checking if dma_alloc_coherent() returns NULL or dma_map_sg returns 0
 
-- checking the returned dma_addr_t of dma_map_single and dma_map_page
+- checking the dma_addr_t returned from dma_map_single() and dma_map_page()
   by using dma_mapping_error():
 
        dma_addr_t dma_handle;
@@ -794,7 +848,7 @@ Example 2: (if buffers are allocated in a loop, unmap all mapped buffers when
                dma_unmap_single(array[i].dma_addr);
        }
 
-Networking drivers must call dev_kfree_skb to free the socket buffer
+Networking drivers must call dev_kfree_skb() to free the socket buffer
 and return NETDEV_TX_OK if the DMA mapping fails on the transmit hook
 (ndo_start_xmit). This means that the socket buffer is just dropped in
 the failure case.
@@ -831,7 +885,7 @@ transform some example code.
                DEFINE_DMA_UNMAP_LEN(len);
        };
 
-2) Use dma_unmap_{addr,len}_set to set these values.
+2) Use dma_unmap_{addr,len}_set() to set these values.
    Example, before:
 
        ringp->mapping = FOO;
@@ -842,7 +896,7 @@ transform some example code.
        dma_unmap_addr_set(ringp, mapping, FOO);
        dma_unmap_len_set(ringp, len, BAR);
 
-3) Use dma_unmap_{addr,len} to access these values.
+3) Use dma_unmap_{addr,len}() to access these values.
    Example, before:
 
        dma_unmap_single(dev, ringp->mapping, ringp->len,
index e865279cec5855818d83eb281fcce06ee0510040..52088408668a80a03621e075dcbfc587565af8c6 100644 (file)
@@ -4,22 +4,26 @@
         James E.J. Bottomley <James.Bottomley@HansenPartnership.com>
 
 This document describes the DMA API.  For a more gentle introduction
-of the API (and actual examples) see
-Documentation/DMA-API-HOWTO.txt.
+of the API (and actual examples), see Documentation/DMA-API-HOWTO.txt.
 
-This API is split into two pieces.  Part I describes the API.  Part II
-describes the extensions to the API for supporting non-consistent
-memory machines.  Unless you know that your driver absolutely has to
-support non-consistent platforms (this is usually only legacy
-platforms) you should only use the API described in part I.
+This API is split into two pieces.  Part I describes the basic API.
+Part II describes extensions for supporting non-consistent memory
+machines.  Unless you know that your driver absolutely has to support
+non-consistent platforms (this is usually only legacy platforms) you
+should only use the API described in part I.
 
 Part I - dma_ API
 -------------------------------------
 
-To get the dma_ API, you must #include <linux/dma-mapping.h>
+To get the dma_ API, you must #include <linux/dma-mapping.h>.  This
+provides dma_addr_t and the interfaces described below.
 
+A dma_addr_t can hold any valid DMA or bus address for the platform.  It
+can be given to a device to use as a DMA source or target.  A CPU cannot
+reference a dma_addr_t directly because there may be translation between
+its physical address space and the bus address space.
 
-Part Ia - Using large dma-coherent buffers
+Part Ia - Using large DMA-coherent buffers
 ------------------------------------------
 
 void *
@@ -33,20 +37,21 @@ to make sure to flush the processor's write buffers before telling
 devices to read that memory.)
 
 This routine allocates a region of <size> bytes of consistent memory.
-It also returns a <dma_handle> which may be cast to an unsigned
-integer the same width as the bus and used as the physical address
-base of the region.
 
-Returns: a pointer to the allocated region (in the processor's virtual
+It returns a pointer to the allocated region (in the processor's virtual
 address space) or NULL if the allocation failed.
 
+It also returns a <dma_handle> which may be cast to an unsigned integer the
+same width as the bus and given to the device as the bus address base of
+the region.
+
 Note: consistent memory can be expensive on some platforms, and the
 minimum allocation length may be as big as a page, so you should
 consolidate your requests for consistent memory as much as possible.
 The simplest way to do that is to use the dma_pool calls (see below).
 
-The flag parameter (dma_alloc_coherent only) allows the caller to
-specify the GFP_ flags (see kmalloc) for the allocation (the
+The flag parameter (dma_alloc_coherent() only) allows the caller to
+specify the GFP_ flags (see kmalloc()) for the allocation (the
 implementation may choose to ignore flags that affect the location of
 the returned memory, like GFP_DMA).
 
@@ -61,24 +66,24 @@ void
 dma_free_coherent(struct device *dev, size_t size, void *cpu_addr,
                           dma_addr_t dma_handle)
 
-Free the region of consistent memory you previously allocated.  dev,
-size and dma_handle must all be the same as those passed into the
-consistent allocate.  cpu_addr must be the virtual address returned by
-the consistent allocate.
+Free a region of consistent memory you previously allocated.  dev,
+size and dma_handle must all be the same as those passed into
+dma_alloc_coherent().  cpu_addr must be the virtual address returned by
+the dma_alloc_coherent().
 
 Note that unlike their sibling allocation calls, these routines
 may only be called with IRQs enabled.
 
 
-Part Ib - Using small dma-coherent buffers
+Part Ib - Using small DMA-coherent buffers
 ------------------------------------------
 
 To get this part of the dma_ API, you must #include <linux/dmapool.h>
 
-Many drivers need lots of small dma-coherent memory regions for DMA
+Many drivers need lots of small DMA-coherent memory regions for DMA
 descriptors or I/O buffers.  Rather than allocating in units of a page
 or more using dma_alloc_coherent(), you can use DMA pools.  These work
-much like a struct kmem_cache, except that they use the dma-coherent allocator,
+much like a struct kmem_cache, except that they use the DMA-coherent allocator,
 not __get_free_pages().  Also, they understand common hardware constraints
 for alignment, like queue heads needing to be aligned on N-byte boundaries.
 
@@ -87,7 +92,7 @@ for alignment, like queue heads needing to be aligned on N-byte boundaries.
        dma_pool_create(const char *name, struct device *dev,
                        size_t size, size_t align, size_t alloc);
 
-The pool create() routines initialize a pool of dma-coherent buffers
+dma_pool_create() initializes a pool of DMA-coherent buffers
 for use with a given device.  It must be called in a context which
 can sleep.
 
@@ -102,25 +107,26 @@ from this pool must not cross 4KByte boundaries.
        void *dma_pool_alloc(struct dma_pool *pool, gfp_t gfp_flags,
                        dma_addr_t *dma_handle);
 
-This allocates memory from the pool; the returned memory will meet the size
-and alignment requirements specified at creation time.  Pass GFP_ATOMIC to
-prevent blocking, or if it's permitted (not in_interrupt, not holding SMP locks),
-pass GFP_KERNEL to allow blocking.  Like dma_alloc_coherent(), this returns
-two values:  an address usable by the cpu, and the dma address usable by the
-pool's device.
+This allocates memory from the pool; the returned memory will meet the
+size and alignment requirements specified at creation time.  Pass
+GFP_ATOMIC to prevent blocking, or if it's permitted (not
+in_interrupt, not holding SMP locks), pass GFP_KERNEL to allow
+blocking.  Like dma_alloc_coherent(), this returns two values:  an
+address usable by the CPU, and the DMA address usable by the pool's
+device.
 
 
        void dma_pool_free(struct dma_pool *pool, void *vaddr,
                        dma_addr_t addr);
 
 This puts memory back into the pool.  The pool is what was passed to
-the pool allocation routine; the cpu (vaddr) and dma addresses are what
+dma_pool_alloc(); the CPU (vaddr) and DMA addresses are what
 were returned when that routine allocated the memory being freed.
 
 
        void dma_pool_destroy(struct dma_pool *pool);
 
-The pool destroy() routines free the resources of the pool.  They must be
+dma_pool_destroy() frees the resources of the pool.  It must be
 called in a context which can sleep.  Make sure you've freed all allocated
 memory back to the pool before you destroy it.
 
@@ -187,9 +193,9 @@ dma_map_single(struct device *dev, void *cpu_addr, size_t size,
                      enum dma_data_direction direction)
 
 Maps a piece of processor virtual memory so it can be accessed by the
-device and returns the physical handle of the memory.
+device and returns the bus address of the memory.
 
-The direction for both api's may be converted freely by casting.
+The direction for both APIs may be converted freely by casting.
 However the dma_ API uses a strongly typed enumerator for its
 direction:
 
@@ -198,31 +204,30 @@ DMA_TO_DEVICE             data is going from the memory to the device
 DMA_FROM_DEVICE                data is coming from the device to the memory
 DMA_BIDIRECTIONAL      direction isn't known
 
-Notes:  Not all memory regions in a machine can be mapped by this
-API.  Further, regions that appear to be physically contiguous in
-kernel virtual space may not be contiguous as physical memory.  Since
-this API does not provide any scatter/gather capability, it will fail
-if the user tries to map a non-physically contiguous piece of memory.
-For this reason, it is recommended that memory mapped by this API be
-obtained only from sources which guarantee it to be physically contiguous
-(like kmalloc).
-
-Further, the physical address of the memory must be within the
-dma_mask of the device (the dma_mask represents a bit mask of the
-addressable region for the device.  I.e., if the physical address of
-the memory anded with the dma_mask is still equal to the physical
-address, then the device can perform DMA to the memory).  In order to
+Notes:  Not all memory regions in a machine can be mapped by this API.
+Further, contiguous kernel virtual space may not be contiguous as
+physical memory.  Since this API does not provide any scatter/gather
+capability, it will fail if the user tries to map a non-physically
+contiguous piece of memory.  For this reason, memory to be mapped by
+this API should be obtained from sources which guarantee it to be
+physically contiguous (like kmalloc).
+
+Further, the bus address of the memory must be within the
+dma_mask of the device (the dma_mask is a bit mask of the
+addressable region for the device, i.e., if the bus address of
+the memory ANDed with the dma_mask is still equal to the bus
+address, then the device can perform DMA to the memory).  To
 ensure that the memory allocated by kmalloc is within the dma_mask,
 the driver may specify various platform-dependent flags to restrict
-the physical memory range of the allocation (e.g. on x86, GFP_DMA
-guarantees to be within the first 16Mb of available physical memory,
+the bus address range of the allocation (e.g., on x86, GFP_DMA
+guarantees to be within the first 16MB of available bus addresses,
 as required by ISA devices).
 
 Note also that the above constraints on physical contiguity and
 dma_mask may not apply if the platform has an IOMMU (a device which
-supplies a physical to virtual mapping between the I/O memory bus and
-the device).  However, to be portable, device driver writers may *not*
-assume that such an IOMMU exists.
+maps an I/O bus address to a physical memory address).  However, to be
+portable, device driver writers may *not* assume that such an IOMMU
+exists.
 
 Warnings:  Memory coherency operates at a granularity called the cache
 line width.  In order for memory mapped by this API to operate
@@ -281,9 +286,9 @@ cache width is.
 int
 dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
 
-In some circumstances dma_map_single and dma_map_page will fail to create
+In some circumstances dma_map_single() and dma_map_page() will fail to create
 a mapping. A driver can check for these errors by testing the returned
-dma address with dma_mapping_error(). A non-zero return value means the mapping
+DMA address with dma_mapping_error(). A non-zero return value means the mapping
 could not be created and the driver should take appropriate action (e.g.
 reduce current DMA mapping usage or delay and try again later).
 
@@ -291,7 +296,7 @@ reduce current DMA mapping usage or delay and try again later).
        dma_map_sg(struct device *dev, struct scatterlist *sg,
                int nents, enum dma_data_direction direction)
 
-Returns: the number of physical segments mapped (this may be shorter
+Returns: the number of bus address segments mapped (this may be shorter
 than <nents> passed in if some elements of the scatter/gather list are
 physically or virtually adjacent and an IOMMU maps them with a single
 entry).
@@ -299,7 +304,7 @@ entry).
 Please note that the sg cannot be mapped again if it has been mapped once.
 The mapping process is allowed to destroy information in the sg.
 
-As with the other mapping interfaces, dma_map_sg can fail. When it
+As with the other mapping interfaces, dma_map_sg() can fail. When it
 does, 0 is returned and a driver must take appropriate action. It is
 critical that the driver do something, in the case of a block driver
 aborting the request or even oopsing is better than doing nothing and
@@ -335,7 +340,7 @@ must be the same as those and passed in to the scatter/gather mapping
 API.
 
 Note: <nents> must be the number you passed in, *not* the number of
-physical entries returned.
+bus address entries returned.
 
 void
 dma_sync_single_for_cpu(struct device *dev, dma_addr_t dma_handle, size_t size,
@@ -350,7 +355,7 @@ void
 dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg, int nelems,
                       enum dma_data_direction direction)
 
-Synchronise a single contiguous or scatter/gather mapping for the cpu
+Synchronise a single contiguous or scatter/gather mapping for the CPU
 and device. With the sync_sg API, all the parameters must be the same
 as those passed into the single mapping API. With the sync_single API,
 you can use dma_handle and size parameters that aren't identical to
@@ -391,10 +396,10 @@ The four functions above are just like the counterpart functions
 without the _attrs suffixes, except that they pass an optional
 struct dma_attrs*.
 
-struct dma_attrs encapsulates a set of "dma attributes". For the
+struct dma_attrs encapsulates a set of "DMA attributes". For the
 definition of struct dma_attrs see linux/dma-attrs.h.
 
-The interpretation of dma attributes is architecture-specific, and
+The interpretation of DMA attributes is architecture-specific, and
 each attribute should be documented in Documentation/DMA-attributes.txt.
 
 If struct dma_attrs* is NULL, the semantics of each of these
@@ -458,7 +463,7 @@ Note: where the platform can return consistent memory, it will
 guarantee that the sync points become nops.
 
 Warning:  Handling non-consistent memory is a real pain.  You should
-only ever use this API if you positively know your driver will be
+only use this API if you positively know your driver will be
 required to work on one of the rare (usually non-PCI) architectures
 that simply cannot make consistent memory.
 
@@ -492,30 +497,29 @@ continuing on for size.  Again, you *must* observe the cache line
 boundaries when doing this.
 
 int
-dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
+dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
                            dma_addr_t device_addr, size_t size, int
                            flags)
 
-Declare region of memory to be handed out by dma_alloc_coherent when
+Declare region of memory to be handed out by dma_alloc_coherent() when
 it's asked for coherent memory for this device.
 
-bus_addr is the physical address to which the memory is currently
-assigned in the bus responding region (this will be used by the
-platform to perform the mapping).
+phys_addr is the CPU physical address to which the memory is currently
+assigned (this will be ioremapped so the CPU can access the region).
 
-device_addr is the physical address the device needs to be programmed
-with actually to address this memory (this will be handed out as the
+device_addr is the bus address the device needs to be programmed
+with to actually address this memory (this will be handed out as the
 dma_addr_t in dma_alloc_coherent()).
 
 size is the size of the area (must be multiples of PAGE_SIZE).
 
-flags can be or'd together and are:
+flags can be ORed together and are:
 
 DMA_MEMORY_MAP - request that the memory returned from
 dma_alloc_coherent() be directly writable.
 
 DMA_MEMORY_IO - request that the memory returned from
-dma_alloc_coherent() be addressable using read/write/memcpy_toio etc.
+dma_alloc_coherent() be addressable using read()/write()/memcpy_toio() etc.
 
 One or both of these flags must be present.
 
@@ -572,7 +576,7 @@ region is occupied.
 Part III - Debug drivers use of the DMA-API
 -------------------------------------------
 
-The DMA-API as described above as some constraints. DMA addresses must be
+The DMA-API as described above has some constraints. DMA addresses must be
 released with the corresponding function with the same size for example. With
 the advent of hardware IOMMUs it becomes more and more important that drivers
 do not violate those constraints. In the worst case such a violation can
@@ -690,11 +694,11 @@ architectural default.
 void debug_dmap_mapping_error(struct device *dev, dma_addr_t dma_addr);
 
 dma-debug interface debug_dma_mapping_error() to debug drivers that fail
-to check dma mapping errors on addresses returned by dma_map_single() and
+to check DMA mapping errors on addresses returned by dma_map_single() and
 dma_map_page() interfaces. This interface clears a flag set by
 debug_dma_map_page() to indicate that dma_mapping_error() has been called by
 the driver. When driver does unmap, debug_dma_unmap() checks the flag and if
 this flag is still set, prints warning message that includes call trace that
 leads up to the unmap. This interface can be called from dma_mapping_error()
-routines to enable dma mapping error check debugging.
+routines to enable DMA mapping error check debugging.
 
index e767805b4182826acc049e29a183ec5109c4a39e..b1a19835e9070dbec2f6dba3d735b8cda23abd6e 100644 (file)
@@ -16,7 +16,7 @@ To do ISA style DMA you need to include two headers:
 #include <asm/dma.h>
 
 The first is the generic DMA API used to convert virtual addresses to
-physical addresses (see Documentation/DMA-API.txt for details).
+bus addresses (see Documentation/DMA-API.txt for details).
 
 The second contains the routines specific to ISA DMA transfers. Since
 this is not present on all platforms make sure you construct your
@@ -50,7 +50,7 @@ early as possible and not release it until the driver is unloaded.)
 Part III - Address translation
 ------------------------------
 
-To translate the virtual address to a physical use the normal DMA
+To translate the virtual address to a bus address, use the normal DMA
 API. Do _not_ use isa_virt_to_phys() even though it does the same
 thing. The reason for this is that the function isa_virt_to_phys()
 will require a Kconfig dependency to ISA, not just ISA_DMA_API which
index d6fae13ff0628bef56a69d671a9a684fa7ab2280..d0d15ee42834089abfd2ffad2bad205b28e33d18 100644 (file)
@@ -1,15 +1,7 @@
 * Synopsys Designware PCIe interface
 
 Required properties:
-- compatible: should contain "snps,dw-pcie" to identify the
-       core, plus an identifier for the specific instance, such
-       as "samsung,exynos5440-pcie" or "fsl,imx6q-pcie".
-- reg: base addresses and lengths of the pcie controller,
-       the phy controller, additional register for the phy controller.
-- interrupts: interrupt values for level interrupt,
-       pulse interrupt, special interrupt.
-- clocks: from common clock binding: handle to pci clock.
-- clock-names: from common clock binding: should be "pcie" and "pcie_bus".
+- compatible: should contain "snps,dw-pcie" to identify the core.
 - #address-cells: set to <3>
 - #size-cells: set to <2>
 - device_type: set to "pci"
@@ -19,65 +11,11 @@ Required properties:
        to define the mapping of the PCIe interface to interrupt
        numbers.
 - num-lanes: number of lanes to use
+- clocks: Must contain an entry for each entry in clock-names.
+       See ../clocks/clock-bindings.txt for details.
+- clock-names: Must include the following entries:
+       - "pcie"
+       - "pcie_bus"
 
 Optional properties:
 - reset-gpio: gpio pin number of power good signal
-
-Optional properties for fsl,imx6q-pcie
-- power-on-gpio: gpio pin number of power-enable signal
-- wake-up-gpio: gpio pin number of incoming wakeup signal
-- disable-gpio: gpio pin number of outgoing rfkill/endpoint disable signal
-
-Example:
-
-SoC specific DT Entry:
-
-       pcie@290000 {
-               compatible = "samsung,exynos5440-pcie", "snps,dw-pcie";
-               reg = <0x290000 0x1000
-                       0x270000 0x1000
-                       0x271000 0x40>;
-               interrupts = <0 20 0>, <0 21 0>, <0 22 0>;
-               clocks = <&clock 28>, <&clock 27>;
-               clock-names = "pcie", "pcie_bus";
-               #address-cells = <3>;
-               #size-cells = <2>;
-               device_type = "pci";
-               ranges = <0x00000800 0 0x40000000 0x40000000 0 0x00001000   /* configuration space */
-                         0x81000000 0 0          0x40001000 0 0x00010000   /* downstream I/O */
-                         0x82000000 0 0x40011000 0x40011000 0 0x1ffef000>; /* non-prefetchable memory */
-               #interrupt-cells = <1>;
-               interrupt-map-mask = <0 0 0 0>;
-               interrupt-map = <0x0 0 &gic 53>;
-               num-lanes = <4>;
-       };
-
-       pcie@2a0000 {
-               compatible = "samsung,exynos5440-pcie", "snps,dw-pcie";
-               reg = <0x2a0000 0x1000
-                       0x272000 0x1000
-                       0x271040 0x40>;
-               interrupts = <0 23 0>, <0 24 0>, <0 25 0>;
-               clocks = <&clock 29>, <&clock 27>;
-               clock-names = "pcie", "pcie_bus";
-               #address-cells = <3>;
-               #size-cells = <2>;
-               device_type = "pci";
-               ranges = <0x00000800 0 0x60000000 0x60000000 0 0x00001000   /* configuration space */
-                         0x81000000 0 0          0x60001000 0 0x00010000   /* downstream I/O */
-                         0x82000000 0 0x60011000 0x60011000 0 0x1ffef000>; /* non-prefetchable memory */
-               #interrupt-cells = <1>;
-               interrupt-map-mask = <0 0 0 0>;
-               interrupt-map = <0x0 0 &gic 56>;
-               num-lanes = <4>;
-       };
-
-Board specific DT Entry:
-
-       pcie@290000 {
-               reset-gpio = <&pin_ctrl 5 0>;
-       };
-
-       pcie@2a0000 {
-               reset-gpio = <&pin_ctrl 22 0>;
-       };
diff --git a/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt b/Documentation/devicetree/bindings/pci/fsl,imx6q-pcie.txt
new file mode 100644 (file)
index 0000000..9455fd0
--- /dev/null
@@ -0,0 +1,38 @@
+* Freescale i.MX6 PCIe interface
+
+This PCIe host controller is based on the Synopsis Designware PCIe IP
+and thus inherits all the common properties defined in designware-pcie.txt.
+
+Required properties:
+- compatible: "fsl,imx6q-pcie"
+- reg: base addresse and length of the pcie controller
+- interrupts: A list of interrupt outputs of the controller. Must contain an
+  entry for each entry in the interrupt-names property.
+- interrupt-names: Must include the following entries:
+       - "msi": The interrupt that is asserted when an MSI is received
+- clock-names: Must include the following additional entries:
+       - "pcie_phy"
+
+Example:
+
+       pcie@0x01000000 {
+               compatible = "fsl,imx6q-pcie", "snps,dw-pcie";
+               reg = <0x01ffc000 0x4000>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               device_type = "pci";
+               ranges = <0x00000800 0 0x01f00000 0x01f00000 0 0x00080000
+                         0x81000000 0 0          0x01f80000 0 0x00010000
+                         0x82000000 0 0x01000000 0x01000000 0 0x00f00000>;
+               num-lanes = <1>;
+               interrupts = <GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;
+               interrupt-names = "msi";
+               #interrupt-cells = <1>;
+               interrupt-map-mask = <0 0 0 0x7>;
+               interrupt-map = <0 0 0 1 &intc GIC_SPI 123 IRQ_TYPE_LEVEL_HIGH>,
+                               <0 0 0 2 &intc GIC_SPI 122 IRQ_TYPE_LEVEL_HIGH>,
+                               <0 0 0 3 &intc GIC_SPI 121 IRQ_TYPE_LEVEL_HIGH>,
+                               <0 0 0 4 &intc GIC_SPI 120 IRQ_TYPE_LEVEL_HIGH>;
+               clocks = <&clks 144>, <&clks 206>, <&clks 189>;
+               clock-names = "pcie", "pcie_bus", "pcie_phy";
+       };
diff --git a/Documentation/devicetree/bindings/pci/host-generic-pci.txt b/Documentation/devicetree/bindings/pci/host-generic-pci.txt
new file mode 100644 (file)
index 0000000..f0b0436
--- /dev/null
@@ -0,0 +1,100 @@
+* Generic PCI host controller
+
+Firmware-initialised PCI host controllers and PCI emulations, such as the
+virtio-pci implementations found in kvmtool and other para-virtualised
+systems, do not require driver support for complexities such as regulator
+and clock management. In fact, the controller may not even require the
+configuration of a control interface by the operating system, instead
+presenting a set of fixed windows describing a subset of IO, Memory and
+Configuration Spaces.
+
+Such a controller can be described purely in terms of the standardized device
+tree bindings communicated in pci.txt:
+
+
+Properties of the host controller node:
+
+- compatible     : Must be "pci-host-cam-generic" or "pci-host-ecam-generic"
+                   depending on the layout of configuration space (CAM vs
+                   ECAM respectively).
+
+- device_type    : Must be "pci".
+
+- ranges         : As described in IEEE Std 1275-1994, but must provide
+                   at least a definition of non-prefetchable memory. One
+                   or both of prefetchable Memory and IO Space may also
+                   be provided.
+
+- bus-range      : Optional property (also described in IEEE Std 1275-1994)
+                   to indicate the range of bus numbers for this controller.
+                   If absent, defaults to <0 255> (i.e. all buses).
+
+- #address-cells : Must be 3.
+
+- #size-cells    : Must be 2.
+
+- reg            : The Configuration Space base address and size, as accessed
+                   from the parent bus.
+
+
+Properties of the /chosen node:
+
+- linux,pci-probe-only
+                 : Optional property which takes a single-cell argument.
+                   If '0', then Linux will assign devices in its usual manner,
+                   otherwise it will not try to assign devices and instead use
+                   them as they are configured already.
+
+Configuration Space is assumed to be memory-mapped (as opposed to being
+accessed via an ioport) and laid out with a direct correspondence to the
+geography of a PCI bus address by concatenating the various components to
+form an offset.
+
+For CAM, this 24-bit offset is:
+
+        cfg_offset(bus, device, function, register) =
+                   bus << 16 | device << 11 | function << 8 | register
+
+Whilst ECAM extends this by 4 bits to accomodate 4k of function space:
+
+        cfg_offset(bus, device, function, register) =
+                   bus << 20 | device << 15 | function << 12 | register
+
+Interrupt mapping is exactly as described in `Open Firmware Recommended
+Practice: Interrupt Mapping' and requires the following properties:
+
+- #interrupt-cells   : Must be 1
+
+- interrupt-map      : <see aforementioned specification>
+
+- interrupt-map-mask : <see aforementioned specification>
+
+
+Example:
+
+pci {
+    compatible = "pci-host-cam-generic"
+    device_type = "pci";
+    #address-cells = <3>;
+    #size-cells = <2>;
+    bus-range = <0x0 0x1>;
+
+    // CPU_PHYSICAL(2)  SIZE(2)
+    reg = <0x0 0x40000000  0x0 0x1000000>;
+
+    // BUS_ADDRESS(3)  CPU_PHYSICAL(2)  SIZE(2)
+    ranges = <0x01000000 0x0 0x01000000  0x0 0x01000000  0x0 0x00010000>,
+             <0x02000000 0x0 0x41000000  0x0 0x41000000  0x0 0x3f000000>;
+
+
+    #interrupt-cells = <0x1>;
+
+    // PCI_DEVICE(3)  INT#(1)  CONTROLLER(PHANDLE)  CONTROLLER_DATA(3)
+    interrupt-map = <  0x0 0x0 0x0  0x1  &gic  0x0 0x4 0x1
+                     0x800 0x0 0x0  0x1  &gic  0x0 0x5 0x1
+                    0x1000 0x0 0x0  0x1  &gic  0x0 0x6 0x1
+                    0x1800 0x0 0x0  0x1  &gic  0x0 0x7 0x1>;
+
+    // PCI_DEVICE(3)  INT#(1)
+    interrupt-map-mask = <0xf800 0x0 0x0  0x7>;
+}
diff --git a/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt b/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt
new file mode 100644 (file)
index 0000000..d8ef5bf
--- /dev/null
@@ -0,0 +1,66 @@
+Renesas AHB to PCI bridge
+-------------------------
+
+This is the bridge used internally to connect the USB controllers to the
+AHB. There is one bridge instance per USB port connected to the internal
+OHCI and EHCI controllers.
+
+Required properties:
+- compatible: "renesas,pci-r8a7790" for the R8A7790 SoC;
+             "renesas,pci-r8a7791" for the R8A7791 SoC.
+- reg: A list of physical regions to access the device: the first is
+       the operational registers for the OHCI/EHCI controllers and the
+       second is for the bridge configuration and control registers.
+- interrupts: interrupt for the device.
+- clocks: The reference to the device clock.
+- bus-range: The PCI bus number range; as this is a single bus, the range
+            should be specified as the same value twice.
+- #address-cells: must be 3.
+- #size-cells: must be 2.
+- #interrupt-cells: must be 1.
+- interrupt-map: standard property used to define the mapping of the PCI
+  interrupts to the GIC interrupts.
+- interrupt-map-mask: standard property that helps to define the interrupt
+  mapping.
+
+Example SoC configuration:
+
+       pci0: pci@ee090000  {
+               compatible = "renesas,pci-r8a7790";
+               clocks = <&mstp7_clks R8A7790_CLK_EHCI>;
+               reg = <0x0 0xee090000 0x0 0xc00>,
+                     <0x0 0xee080000 0x0 0x1100>;
+               interrupts = <0 108 IRQ_TYPE_LEVEL_HIGH>;
+               status = "disabled";
+
+               bus-range = <0 0>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               #interrupt-cells = <1>;
+               interrupt-map-mask = <0xff00 0 0 0x7>;
+               interrupt-map = <0x0000 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH
+                                0x0800 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH
+                                0x1000 0 0 2 &gic 0 108 IRQ_TYPE_LEVEL_HIGH>;
+
+               pci@0,1 {
+                       reg = <0x800 0 0 0 0>;
+                       device_type = "pci";
+                       phys = <&usbphy 0 0>;
+                       phy-names = "usb";
+               };
+
+               pci@0,2 {
+                       reg = <0x1000 0 0 0 0>;
+                       device_type = "pci";
+                       phys = <&usbphy 0 0>;
+                       phy-names = "usb";
+               };
+       };
+
+Example board setup:
+
+&pci0 {
+       status = "okay";
+       pinctrl-0 = <&usb0_pins>;
+       pinctrl-names = "default";
+};
diff --git a/Documentation/devicetree/bindings/pci/rcar-pci.txt b/Documentation/devicetree/bindings/pci/rcar-pci.txt
new file mode 100644 (file)
index 0000000..29d3b98
--- /dev/null
@@ -0,0 +1,47 @@
+* Renesas RCar PCIe interface
+
+Required properties:
+- compatible: should contain one of the following
+       "renesas,pcie-r8a7779", "renesas,pcie-r8a7790", "renesas,pcie-r8a7791"
+- reg: base address and length of the pcie controller registers.
+- #address-cells: set to <3>
+- #size-cells: set to <2>
+- bus-range: PCI bus numbers covered
+- device_type: set to "pci"
+- ranges: ranges for the PCI memory and I/O regions.
+- dma-ranges: ranges for the inbound memory regions.
+- interrupts: two interrupt sources for MSI interrupts, followed by interrupt
+       source for hardware related interrupts (e.g. link speed change).
+- #interrupt-cells: set to <1>
+- interrupt-map-mask and interrupt-map: standard PCI properties
+       to define the mapping of the PCIe interface to interrupt
+       numbers.
+- clocks: from common clock binding: clock specifiers for the PCIe controller
+       and PCIe bus clocks.
+- clock-names: from common clock binding: should be "pcie" and "pcie_bus".
+
+Example:
+
+SoC specific DT Entry:
+
+       pcie: pcie@fe000000 {
+               compatible = "renesas,pcie-r8a7791";
+               reg = <0 0xfe000000 0 0x80000>;
+               #address-cells = <3>;
+               #size-cells = <2>;
+               bus-range = <0x00 0xff>;
+               device_type = "pci";
+               ranges = <0x01000000 0 0x00000000 0 0xfe100000 0 0x00100000
+                         0x02000000 0 0xfe200000 0 0xfe200000 0 0x00200000
+                         0x02000000 0 0x30000000 0 0x30000000 0 0x08000000
+                         0x42000000 0 0x38000000 0 0x38000000 0 0x08000000>;
+               dma-ranges = <0x42000000 0 0x40000000 0 0x40000000 0 0x40000000
+                             0x42000000 2 0x00000000 2 0x00000000 0 0x40000000>;
+               interrupts = <0 116 4>, <0 117 4>, <0 118 4>;
+               #interrupt-cells = <1>;
+               interrupt-map-mask = <0 0 0 0>;
+               interrupt-map = <0 0 0 0 &gic 0 116 4>;
+               clocks = <&mstp3_clks R8A7791_CLK_PCIE>, <&pcie_bus_clk>;
+               clock-names = "pcie", "pcie_bus";
+               status = "disabled";
+       };
diff --git a/Documentation/devicetree/bindings/pci/samsung,exynos5440-pcie.txt b/Documentation/devicetree/bindings/pci/samsung,exynos5440-pcie.txt
new file mode 100644 (file)
index 0000000..4f9d23d
--- /dev/null
@@ -0,0 +1,65 @@
+* Samsung Exynos 5440 PCIe interface
+
+This PCIe host controller is based on the Synopsis Designware PCIe IP
+and thus inherits all the common properties defined in designware-pcie.txt.
+
+Required properties:
+- compatible: "samsung,exynos5440-pcie"
+- reg: base addresses and lengths of the pcie controller,
+       the phy controller, additional register for the phy controller.
+- interrupts: A list of interrupt outputs for level interrupt,
+       pulse interrupt, special interrupt.
+
+Example:
+
+SoC specific DT Entry:
+
+       pcie@290000 {
+               compatible = "samsung,exynos5440-pcie", "snps,dw-pcie";
+               reg = <0x290000 0x1000
+                       0x270000 0x1000
+                       0x271000 0x40>;
+               interrupts = <0 20 0>, <0 21 0>, <0 22 0>;
+               clocks = <&clock 28>, <&clock 27>;
+               clock-names = "pcie", "pcie_bus";
+               #address-cells = <3>;
+               #size-cells = <2>;
+               device_type = "pci";
+               ranges = <0x00000800 0 0x40000000 0x40000000 0 0x00001000   /* configuration space */
+                         0x81000000 0 0          0x40001000 0 0x00010000   /* downstream I/O */
+                         0x82000000 0 0x40011000 0x40011000 0 0x1ffef000>; /* non-prefetchable memory */
+               #interrupt-cells = <1>;
+               interrupt-map-mask = <0 0 0 0>;
+               interrupt-map = <0 0 0 0 &gic GIC_SPI 21 IRQ_TYPE_LEVEL_HIGH>;
+               num-lanes = <4>;
+       };
+
+       pcie@2a0000 {
+               compatible = "samsung,exynos5440-pcie", "snps,dw-pcie";
+               reg = <0x2a0000 0x1000
+                       0x272000 0x1000
+                       0x271040 0x40>;
+               interrupts = <0 23 0>, <0 24 0>, <0 25 0>;
+               clocks = <&clock 29>, <&clock 27>;
+               clock-names = "pcie", "pcie_bus";
+               #address-cells = <3>;
+               #size-cells = <2>;
+               device_type = "pci";
+               ranges = <0x00000800 0 0x60000000 0x60000000 0 0x00001000   /* configuration space */
+                         0x81000000 0 0          0x60001000 0 0x00010000   /* downstream I/O */
+                         0x82000000 0 0x60011000 0x60011000 0 0x1ffef000>; /* non-prefetchable memory */
+               #interrupt-cells = <1>;
+               interrupt-map-mask = <0 0 0 0>;
+               interrupt-map = <0 0 0 0 &gic GIC_SPI 24 IRQ_TYPE_LEVEL_HIGH>;
+               num-lanes = <4>;
+       };
+
+Board specific DT Entry:
+
+       pcie@290000 {
+               reset-gpio = <&pin_ctrl 5 0>;
+       };
+
+       pcie@2a0000 {
+               reset-gpio = <&pin_ctrl 22 0>;
+       };
index 6dc67b1fdb507016d0d0d77bf66f9875ace00f99..e97b50726b2740983ad33d982c34ba842a132439 100644 (file)
@@ -6693,6 +6693,7 @@ F:        Documentation/PCI/
 F:     drivers/pci/
 F:     include/linux/pci*
 F:     arch/x86/pci/
+F:     arch/x86/kernel/quirks.c
 
 PCI DRIVER FOR IMX6
 M:     Richard Zhu <r65037@freescale.com>
@@ -6740,6 +6741,14 @@ L:       linux-pci@vger.kernel.org
 S:     Maintained
 F:     drivers/pci/host/*designware*
 
+PCI DRIVER FOR GENERIC OF HOSTS
+M:     Will Deacon <will.deacon@arm.com>
+L:     linux-pci@vger.kernel.org
+L:     linux-arm-kernel@lists.infradead.org (moderated for non-subscribers)
+S:     Maintained
+F:     Documentation/devicetree/bindings/pci/host-generic-pci.txt
+F:     drivers/pci/host/pci-host-generic.c
+
 PCMCIA SUBSYSTEM
 P:     Linux PCMCIA Team
 L:     linux-pcmcia@lists.infradead.org
index d01afb78919c076c9a064c30dd29af8deb9a8bfc..f7f680f7457dec0cc7ba0b9a5562c2041b2a5a4a 100644 (file)
@@ -59,11 +59,6 @@ struct pci_controller {
 
 extern void pcibios_set_master(struct pci_dev *dev);
 
-extern inline void pcibios_penalize_isa_irq(int irq, int active)
-{
-       /* We don't do dynamic PCI IRQ allocation */
-}
-
 /* IOMMU controls.  */
 
 /* The PCI address space does not equal the physical memory address space.
index 680a83e944672d876d7d05144ecebb2f2eff321a..7e95d8535e24fc0cf1200800bed42fed53b825d7 100644 (file)
@@ -31,11 +31,6 @@ static inline int pci_proc_domain(struct pci_bus *bus)
 }
 #endif /* CONFIG_PCI_DOMAINS */
 
-static inline void pcibios_penalize_isa_irq(int irq, int active)
-{
-       /* We don't do dynamic PCI IRQ allocation */
-}
-
 /*
  * The PCI address space does equal the physical memory address space.
  * The networking and block device layers use this boolean for bounce
index 16d43cd4561908518894f6141cdcc2a6f0a2af4b..17a26c17f7f5731d78d257e7facd0080bba12d5f 100644 (file)
@@ -545,6 +545,18 @@ void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
                 */
                pci_bus_add_devices(bus);
        }
+
+       list_for_each_entry(sys, &head, node) {
+               struct pci_bus *bus = sys->bus;
+
+               /* Configure PCI Express settings */
+               if (bus && !pci_has_flag(PCI_PROBE_ONLY)) {
+                       struct pci_bus *child;
+
+                       list_for_each_entry(child, &bus->children, node)
+                               pcie_bus_configure_settings(child);
+               }
+       }
 }
 
 #ifndef CONFIG_PCI_HOST_ITE8152
index 74352c4597d92f5802531ac0ca86c08766b6a62f..c737909fba470554d07911041bc03a6047ff71ea 100644 (file)
@@ -10,9 +10,4 @@
 #define PCIBIOS_MIN_IO 0x00001000
 #define PCIBIOS_MIN_MEM 0x10000000
 
-static inline void pcibios_penalize_isa_irq(int irq)
-{
-       /* We don't do dynamic PCI IRQ allocation */
-}
-
 #endif                         /* _ASM_BFIN_PCI_H */
index f666734926d548a233e6ab5e5bc810cb48c3d67a..cc2399c175e9ea8181e2fc837d737dad28a9f779 100644 (file)
@@ -20,7 +20,6 @@ void pcibios_config_init(void);
 struct pci_bus * pcibios_scan_root(int bus);
 
 void pcibios_set_master(struct pci_dev *dev);
-void pcibios_penalize_isa_irq(int irq);
 struct irq_routing_table *pcibios_get_irq_routing_table(void);
 int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
 
index ef03baf5d89de314f39fd1920f1e71755387a3f3..2035a4d3f9b98c36a7463741a2fd19d0e038a803 100644 (file)
@@ -24,8 +24,6 @@ struct pci_dev;
 
 extern void pcibios_set_master(struct pci_dev *dev);
 
-extern void pcibios_penalize_isa_irq(int irq);
-
 #ifdef CONFIG_MMU
 extern void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle);
 extern void consistent_free(void *vaddr);
index c677b9d81d30a00f858bf268c29717a260231b07..1c35c93f942bd17967e68edd8c07692107260a91 100644 (file)
@@ -55,10 +55,6 @@ void __init pcibios_fixup_irqs(void)
        }
 }
 
-void __init pcibios_penalize_isa_irq(int irq)
-{
-}
-
 void pcibios_enable_irq(struct pci_dev *dev)
 {
        pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
index 7d41cc0898224ec2211a6e0304e71ac4bb269a5d..52af5ed9f60ba98654f4657e7dd84e7b36f88390 100644 (file)
@@ -50,12 +50,6 @@ struct pci_dev;
 extern unsigned long ia64_max_iommu_merge_mask;
 #define PCI_DMA_BUS_IS_PHYS    (ia64_max_iommu_merge_mask == ~0UL)
 
-static inline void
-pcibios_penalize_isa_irq (int irq, int active)
-{
-       /* We don't do dynamic PCI IRQ allocation */
-}
-
 #include <asm-generic/pci-dma-compat.h>
 
 #ifdef CONFIG_PCI
index eee069a0b539747da4d4d4b4d3065de1c5373be8..1fe9aa5068eaf29a2b5096a75ed4007e91870926 100644 (file)
@@ -49,9 +49,7 @@ static void pci_fixup_video(struct pci_dev *pdev)
                 * type BRIDGE, or CARDBUS. Host to PCI controllers use
                 * PCI header type NORMAL.
                 */
-               if (bridge
-                   &&((bridge->hdr_type == PCI_HEADER_TYPE_BRIDGE)
-                      ||(bridge->hdr_type == PCI_HEADER_TYPE_CARDBUS))) {
+               if (bridge && (pci_is_bridge(bridge))) {
                        pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
                                                &config);
                        if (!(config & PCI_BRIDGE_CTL_VGA))
index 935f9bec414ae9f9cb4781faed4fc57e2f764f90..335524040fffeaef858a160bdf0626d67e2a411c 100644 (file)
@@ -44,11 +44,6 @@ struct pci_dev;
  */
 #define pcibios_assign_all_busses()    0
 
-static inline void pcibios_penalize_isa_irq(int irq, int active)
-{
-       /* We don't do dynamic PCI IRQ allocation */
-}
-
 #ifdef CONFIG_PCI
 extern void set_pci_dma_ops(struct dma_map_ops *dma_ops);
 extern struct dma_map_ops *get_pci_dma_ops(void);
index 70996cc66aa228c688d298ade87fd31c5cedaaac..a59de1bc1ce0cca8976ea6cb9bf0ebde4562ddd3 100644 (file)
@@ -168,26 +168,6 @@ struct pci_controller *pci_find_hose_for_OF_device(struct device_node *node)
        return NULL;
 }
 
-static ssize_t pci_show_devspec(struct device *dev,
-               struct device_attribute *attr, char *buf)
-{
-       struct pci_dev *pdev;
-       struct device_node *np;
-
-       pdev = to_pci_dev(dev);
-       np = pci_device_to_OF_node(pdev);
-       if (np == NULL || np->full_name == NULL)
-               return 0;
-       return sprintf(buf, "%s", np->full_name);
-}
-static DEVICE_ATTR(devspec, S_IRUGO, pci_show_devspec, NULL);
-
-/* Add sysfs properties */
-int pcibios_add_platform_entries(struct pci_dev *pdev)
-{
-       return device_create_file(&pdev->dev, &dev_attr_devspec);
-}
-
 void pcibios_set_master(struct pci_dev *dev)
 {
        /* No special bus mastering setup handling */
index 12d6842962bedc8987a689eeff86aea8e5761a10..974b0e3089633609bf84a90c6324ddfb8f6de3f8 100644 (file)
@@ -73,11 +73,6 @@ extern unsigned long PCIBIOS_MIN_MEM;
 
 extern void pcibios_set_master(struct pci_dev *dev);
 
-static inline void pcibios_penalize_isa_irq(int irq, int active)
-{
-       /* We don't do dynamic PCI IRQ allocation */
-}
-
 #define HAVE_PCI_MMAP
 
 extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
index 166323824683c50fc0aa3eb2575159e760a78458..5f70af25c7d02a54315ed2b2da2e6fd12652e7d8 100644 (file)
@@ -48,7 +48,6 @@ extern void unit_pci_init(void);
 #define PCIBIOS_MIN_MEM                0xB8000000
 
 void pcibios_set_master(struct pci_dev *dev);
-void pcibios_penalize_isa_irq(int irq);
 
 /* Dynamic DMA mapping stuff.
  * i386 has everything mapped statically.
index 77439da04671a60ba0afdffbb47636f2cf81908e..fcb28ceb824d6dfa9460826deb87190a9417cf17 100644 (file)
@@ -40,10 +40,6 @@ void __init pcibios_fixup_irqs(void)
        }
 }
 
-void __init pcibios_penalize_isa_irq(int irq)
-{
-}
-
 void pcibios_enable_irq(struct pci_dev *dev)
 {
        pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
index 465154076d23f9c1191f6ff7dcc59cf7b61333de..20df2b04fc09f469ed517df9acc240bddff386e7 100644 (file)
@@ -215,11 +215,6 @@ static inline void pci_dma_burst_advice(struct pci_dev *pdev,
 }
 #endif
 
-static inline void pcibios_penalize_isa_irq(int irq, int active)
-{
-       /* We don't need to penalize isa irq's */
-}
-
 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 {
        return channel ? 15 : 14;
index 95145a15c70822c2a98fbb7d9f4d006497839369..1b0739bc14b595655d9790d893257a627e059d80 100644 (file)
@@ -46,11 +46,6 @@ struct pci_dev;
 #define pcibios_assign_all_busses() \
        (pci_has_flag(PCI_REASSIGN_ALL_BUS))
 
-static inline void pcibios_penalize_isa_irq(int irq, int active)
-{
-       /* We don't do dynamic PCI IRQ allocation */
-}
-
 #define HAVE_ARCH_PCI_GET_LEGACY_IDE_IRQ
 static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel)
 {
index d9476c1fc9596132d27bc68d5795e2b6a3ee8a6a..24d342e917903f58aec6e37d56616aab0e1e029d 100644 (file)
@@ -201,26 +201,6 @@ struct pci_controller* pci_find_hose_for_OF_device(struct device_node* node)
        return NULL;
 }
 
-static ssize_t pci_show_devspec(struct device *dev,
-               struct device_attribute *attr, char *buf)
-{
-       struct pci_dev *pdev;
-       struct device_node *np;
-
-       pdev = to_pci_dev (dev);
-       np = pci_device_to_OF_node(pdev);
-       if (np == NULL || np->full_name == NULL)
-               return 0;
-       return sprintf(buf, "%s", np->full_name);
-}
-static DEVICE_ATTR(devspec, S_IRUGO, pci_show_devspec, NULL);
-
-/* Add sysfs properties */
-int pcibios_add_platform_entries(struct pci_dev *pdev)
-{
-       return device_create_file(&pdev->dev, &dev_attr_devspec);
-}
-
 /*
  * Reads the interrupt pin to determine if interrupt is use by card.
  * If the interrupt is used, then gets the interrupt line from the
index c1e17ae68a08047a0a60154aed49684d8b4aad2f..5b789177aa29b65b35cf8ca3493e30511c0a74a5 100644 (file)
@@ -98,8 +98,7 @@ void pcibios_add_pci_devices(struct pci_bus * bus)
                max = bus->busn_res.start;
                for (pass = 0; pass < 2; pass++) {
                        list_for_each_entry(dev, &bus->devices, bus_list) {
-                               if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-                                   dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
+                               if (pci_is_bridge(dev))
                                        max = pci_scan_bridge(bus, dev,
                                                              max, pass);
                        }
index 2a4779091a5809a42b64d187224dc46da59fa07c..155013da27e05cb801ba961b102d41f3edbfb48d 100644 (file)
@@ -208,7 +208,7 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
                          unsigned long in_devfn)
 {
        struct pci_controller* hose;
-       struct pci_bus *bus = NULL;
+       struct pci_bus *tmp_bus, *bus = NULL;
        struct device_node *hose_node;
 
        /* Argh ! Please forgive me for that hack, but that's the
@@ -229,10 +229,12 @@ long sys_pciconfig_iobase(long which, unsigned long in_bus,
         * used on pre-domains setup. We return the first match
         */
 
-       list_for_each_entry(bus, &pci_root_buses, node) {
-               if (in_bus >= bus->number && in_bus <= bus->busn_res.end)
+       list_for_each_entry(tmp_bus, &pci_root_buses, node) {
+               if (in_bus >= tmp_bus->number &&
+                   in_bus <= tmp_bus->busn_res.end) {
+                       bus = tmp_bus;
                        break;
-               bus = NULL;
+               }
        }
        if (bus == NULL || bus->dev.of_node == NULL)
                return -ENODEV;
index 83c26d829991e8b8c118d6fa8d8d5bb7ffc68fda..059e244484fe95cc6cab46729d7771b052bb896a 100644 (file)
@@ -362,8 +362,7 @@ static void __of_scan_bus(struct device_node *node, struct pci_bus *bus,
 
        /* Now scan child busses */
        list_for_each_entry(dev, &bus->devices, bus_list) {
-               if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-                   dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
+               if (pci_is_bridge(dev)) {
                        of_scan_pci_bridge(dev);
                }
        }
index 2583466f576b617181ed8b39f1db6c32106bd999..79b5f0783a30c3f9861c374d5a2cb0f2bb002fa4 100644 (file)
@@ -120,6 +120,8 @@ static inline bool zdev_enabled(struct zpci_dev *zdev)
        return (zdev->fh & (1UL << 31)) ? true : false;
 }
 
+extern const struct attribute_group *zpci_attr_groups[];
+
 /* -----------------------------------------------------------------------------
   Prototypes
 ----------------------------------------------------------------------------- */
@@ -166,10 +168,6 @@ static inline void zpci_exit_slot(struct zpci_dev *zdev) {}
 struct zpci_dev *get_zdev(struct pci_dev *);
 struct zpci_dev *get_zdev_by_fid(u32);
 
-/* sysfs */
-int zpci_sysfs_add_device(struct device *);
-void zpci_sysfs_remove_device(struct device *);
-
 /* DMA */
 int zpci_dma_init(void);
 void zpci_dma_exit(void);
index 1df1d29ac81d3710caafad1f7ce0094f530d721d..bdf02570d1dfab0c81146b4b609cbe45c9b445d7 100644 (file)
@@ -530,11 +530,6 @@ static void zpci_unmap_resources(struct zpci_dev *zdev)
        }
 }
 
-int pcibios_add_platform_entries(struct pci_dev *pdev)
-{
-       return zpci_sysfs_add_device(&pdev->dev);
-}
-
 static int __init zpci_irq_init(void)
 {
        int rc;
@@ -671,6 +666,7 @@ int pcibios_add_device(struct pci_dev *pdev)
        int i;
 
        zdev->pdev = pdev;
+       pdev->dev.groups = zpci_attr_groups;
        zpci_map_resources(zdev);
 
        for (i = 0; i < PCI_BAR_COUNT; i++) {
index ab4a91393005a920b876c610ed5d3d8605af5037..b56a3958f1a7125e1bfa97c293bbbc88879e598b 100644 (file)
@@ -72,36 +72,18 @@ static ssize_t store_recover(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR(recover, S_IWUSR, NULL, store_recover);
 
-static struct device_attribute *zpci_dev_attrs[] = {
-       &dev_attr_function_id,
-       &dev_attr_function_handle,
-       &dev_attr_pchid,
-       &dev_attr_pfgid,
-       &dev_attr_recover,
+static struct attribute *zpci_dev_attrs[] = {
+       &dev_attr_function_id.attr,
+       &dev_attr_function_handle.attr,
+       &dev_attr_pchid.attr,
+       &dev_attr_pfgid.attr,
+       &dev_attr_recover.attr,
+       NULL,
+};
+static struct attribute_group zpci_attr_group = {
+       .attrs = zpci_dev_attrs,
+};
+const struct attribute_group *zpci_attr_groups[] = {
+       &zpci_attr_group,
        NULL,
 };
-
-int zpci_sysfs_add_device(struct device *dev)
-{
-       int i, rc = 0;
-
-       for (i = 0; zpci_dev_attrs[i]; i++) {
-               rc = device_create_file(dev, zpci_dev_attrs[i]);
-               if (rc)
-                       goto error;
-       }
-       return 0;
-
-error:
-       while (--i >= 0)
-               device_remove_file(dev, zpci_dev_attrs[i]);
-       return rc;
-}
-
-void zpci_sysfs_remove_device(struct device *dev)
-{
-       int i;
-
-       for (i = 0; zpci_dev_attrs[i]; i++)
-               device_remove_file(dev, zpci_dev_attrs[i]);
-}
index d6cde700e316950f3abec82476f2e40d2b22ddd2..1d1c5a227e509e50e865011b7e9912c8db109196 100644 (file)
@@ -31,6 +31,8 @@
 static void gapspci_fixup_resources(struct pci_dev *dev)
 {
        struct pci_channel *p = dev->sysdata;
+       struct resource res;
+       struct pci_bus_region region;
 
        printk(KERN_NOTICE "PCI: Fixing up device %s\n", pci_name(dev));
 
@@ -50,11 +52,21 @@ static void gapspci_fixup_resources(struct pci_dev *dev)
 
                /*
                 * Redirect dma memory allocations to special memory window.
+                *
+                * If this GAPSPCI region were mapped by a BAR, the CPU
+                * phys_addr_t would be pci_resource_start(), and the bus
+                * address would be pci_bus_address(pci_resource_start()).
+                * But apparently there's no BAR mapping it, so we just
+                * "know" its CPU address is GAPSPCI_DMA_BASE.
                 */
+               res.start = GAPSPCI_DMA_BASE;
+               res.end = GAPSPCI_DMA_BASE + GAPSPCI_DMA_SIZE - 1;
+               res.flags = IORESOURCE_MEM;
+               pcibios_resource_to_bus(dev->bus, &region, &res);
                BUG_ON(!dma_declare_coherent_memory(&dev->dev,
-                                               GAPSPCI_DMA_BASE,
-                                               GAPSPCI_DMA_BASE,
-                                               GAPSPCI_DMA_SIZE,
+                                               res.start,
+                                               region.start,
+                                               resource_size(&res),
                                                DMA_MEMORY_MAP |
                                                DMA_MEMORY_EXCLUSIVE));
                break;
index bff96c2e7d254f520aa3c089a8bded0dc2ea2ed6..5b4511552998d9207e7be0cd7d801ccb99242290 100644 (file)
@@ -70,11 +70,6 @@ extern int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
        enum pci_mmap_state mmap_state, int write_combine);
 extern void pcibios_set_master(struct pci_dev *dev);
 
-static inline void pcibios_penalize_isa_irq(int irq, int active)
-{
-       /* We don't do dynamic PCI IRQ allocation */
-}
-
 /* Dynamic DMA mapping stuff.
  * SuperH has everything mapped statically like x86.
  */
index dc503297481f4673874b973719c9afa79f004faa..53e9b4987db0b9212116945274f6d53d9c8bc448 100644 (file)
 
 #define PCI_IRQ_NONE           0xffffffff
 
-static inline void pcibios_penalize_isa_irq(int irq, int active)
-{
-       /* We don't do dynamic PCI IRQ allocation */
-}
-
 /* Dynamic DMA mapping stuff.
  */
 #define PCI_DMA_BUS_IS_PHYS    (0)
index 1633b718d3bc3c608ef59d4a7068108e815d1029..c6c7396e7627c814115d73c361b4ef194d565516 100644 (file)
 
 #define PCI_IRQ_NONE           0xffffffff
 
-static inline void pcibios_penalize_isa_irq(int irq, int active)
-{
-       /* We don't do dynamic PCI IRQ allocation */
-}
-
 /* The PCI address space does not equal the physical memory
  * address space.  The networking and block device layers use
  * this boolean for bounce buffer decisions.
index 1555bbcae1eee617fecd7cbecaa78eb5d6ab2ca8..857ad77df9c0efa46fa21038cad0878968c4a644 100644 (file)
@@ -543,8 +543,7 @@ static void pci_of_scan_bus(struct pci_pbm_info *pbm,
                        printk("PCI: dev header type: %x\n",
                               dev->hdr_type);
 
-               if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-                   dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
+               if (pci_is_bridge(dev))
                        of_scan_pci_bridge(pbm, child, dev);
        }
 }
index f5e108f4a151a9bbb2d72865bd0c83519dee9707..654407e98619d2aa247c9f23d65504aad60dfcf1 100644 (file)
 #include <asm-generic/pci.h>
 #include <mach/hardware.h> /* for PCIBIOS_MIN_* */
 
-static inline void pcibios_penalize_isa_irq(int irq, int active)
-{
-       /* We don't do dynamic PCI IRQ allocation */
-}
-
 #ifdef CONFIG_PCI
 static inline void pci_dma_burst_advice(struct pci_dev *pdev,
                                        enum pci_dma_burst_strategy *strat,
index 96ae4f4040bb359f8f3588f82f6595e41edbc501..0892ea0e683f01dbe6e79b649922a221db00b35c 100644 (file)
@@ -68,7 +68,6 @@ void pcibios_config_init(void);
 void pcibios_scan_root(int bus);
 
 void pcibios_set_master(struct pci_dev *dev);
-void pcibios_penalize_isa_irq(int irq, int active);
 struct irq_routing_table *pcibios_get_irq_routing_table(void);
 int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq);
 
index 9fa8aa051f54b235ed516d32e2eca2c3c9d62b5e..76164e173a24f7251e3e684e66aa8afd7792f1e1 100644 (file)
@@ -10,6 +10,8 @@
  *
  * Copyright 2002 Andi Kleen, SuSE Labs.
  */
+#define pr_fmt(fmt) "AGP: " fmt
+
 #include <linux/kernel.h>
 #include <linux/types.h>
 #include <linux/init.h>
@@ -75,14 +77,13 @@ static u32 __init allocate_aperture(void)
        addr = memblock_find_in_range(GART_MIN_ADDR, GART_MAX_ADDR,
                                      aper_size, aper_size);
        if (!addr) {
-               printk(KERN_ERR
-                       "Cannot allocate aperture memory hole (%lx,%uK)\n",
-                               addr, aper_size>>10);
+               pr_err("Cannot allocate aperture memory hole [mem %#010lx-%#010lx] (%uKB)\n",
+                      addr, addr + aper_size - 1, aper_size >> 10);
                return 0;
        }
        memblock_reserve(addr, aper_size);
-       printk(KERN_INFO "Mapping aperture over %d KB of RAM @ %lx\n",
-                       aper_size >> 10, addr);
+       pr_info("Mapping aperture over RAM [mem %#010lx-%#010lx] (%uKB)\n",
+               addr, addr + aper_size - 1, aper_size >> 10);
        register_nosave_region(addr >> PAGE_SHIFT,
                               (addr+aper_size) >> PAGE_SHIFT);
 
@@ -126,10 +127,11 @@ static u32 __init read_agp(int bus, int slot, int func, int cap, u32 *order)
        u64 aper;
        u32 old_order;
 
-       printk(KERN_INFO "AGP bridge at %02x:%02x:%02x\n", bus, slot, func);
+       pr_info("pci 0000:%02x:%02x:%02x: AGP bridge\n", bus, slot, func);
        apsizereg = read_pci_config_16(bus, slot, func, cap + 0x14);
        if (apsizereg == 0xffffffff) {
-               printk(KERN_ERR "APSIZE in AGP bridge unreadable\n");
+               pr_err("pci 0000:%02x:%02x.%d: APSIZE unreadable\n",
+                      bus, slot, func);
                return 0;
        }
 
@@ -153,16 +155,18 @@ static u32 __init read_agp(int bus, int slot, int func, int cap, u32 *order)
         * On some sick chips, APSIZE is 0. It means it wants 4G
         * so let double check that order, and lets trust AMD NB settings:
         */
-       printk(KERN_INFO "Aperture from AGP @ %Lx old size %u MB\n",
-                       aper, 32 << old_order);
+       pr_info("pci 0000:%02x:%02x.%d: AGP aperture [bus addr %#010Lx-%#010Lx] (old size %uMB)\n",
+               bus, slot, func, aper, aper + (32ULL << (old_order + 20)) - 1,
+               32 << old_order);
        if (aper + (32ULL<<(20 + *order)) > 0x100000000ULL) {
-               printk(KERN_INFO "Aperture size %u MB (APSIZE %x) is not right, using settings from NB\n",
-                               32 << *order, apsizereg);
+               pr_info("pci 0000:%02x:%02x.%d: AGP aperture size %uMB (APSIZE %#x) is not right, using settings from NB\n",
+                       bus, slot, func, 32 << *order, apsizereg);
                *order = old_order;
        }
 
-       printk(KERN_INFO "Aperture from AGP @ %Lx size %u MB (APSIZE %x)\n",
-                       aper, 32 << *order, apsizereg);
+       pr_info("pci 0000:%02x:%02x.%d: AGP aperture [bus addr %#010Lx-%#010Lx] (%uMB, APSIZE %#x)\n",
+               bus, slot, func, aper, aper + (32ULL << (*order + 20)) - 1,
+               32 << *order, apsizereg);
 
        if (!aperture_valid(aper, (32*1024*1024) << *order, 32<<20))
                return 0;
@@ -218,7 +222,7 @@ static u32 __init search_agp_bridge(u32 *order, int *valid_agp)
                        }
                }
        }
-       printk(KERN_INFO "No AGP bridge found\n");
+       pr_info("No AGP bridge found\n");
 
        return 0;
 }
@@ -310,7 +314,8 @@ void __init early_gart_iommu_check(void)
                if (e820_any_mapped(aper_base, aper_base + aper_size,
                                    E820_RAM)) {
                        /* reserve it, so we can reuse it in second kernel */
-                       printk(KERN_INFO "update e820 for GART\n");
+                       pr_info("e820: reserve [mem %#010Lx-%#010Lx] for GART\n",
+                               aper_base, aper_base + aper_size - 1);
                        e820_add_region(aper_base, aper_size, E820_RESERVED);
                        update_e820();
                }
@@ -354,7 +359,7 @@ int __init gart_iommu_hole_init(void)
            !early_pci_allowed())
                return -ENODEV;
 
-       printk(KERN_INFO  "Checking aperture...\n");
+       pr_info("Checking aperture...\n");
 
        if (!fallback_aper_force)
                agp_aper_base = search_agp_bridge(&agp_aper_order, &valid_agp);
@@ -395,8 +400,9 @@ int __init gart_iommu_hole_init(void)
                        aper_base = read_pci_config(bus, slot, 3, AMD64_GARTAPERTUREBASE) & 0x7fff;
                        aper_base <<= 25;
 
-                       printk(KERN_INFO "Node %d: aperture @ %Lx size %u MB\n",
-                                       node, aper_base, aper_size >> 20);
+                       pr_info("Node %d: aperture [bus addr %#010Lx-%#010Lx] (%uMB)\n",
+                               node, aper_base, aper_base + aper_size - 1,
+                               aper_size >> 20);
                        node++;
 
                        if (!aperture_valid(aper_base, aper_size, 64<<20)) {
@@ -407,9 +413,9 @@ int __init gart_iommu_hole_init(void)
                                        if (!no_iommu &&
                                            max_pfn > MAX_DMA32_PFN &&
                                            !printed_gart_size_msg) {
-                                               printk(KERN_ERR "you are using iommu with agp, but GART size is less than 64M\n");
-                                               printk(KERN_ERR "please increase GART size in your BIOS setup\n");
-                                               printk(KERN_ERR "if BIOS doesn't have that option, contact your HW vendor!\n");
+                                               pr_err("you are using iommu with agp, but GART size is less than 64MB\n");
+                                               pr_err("please increase GART size in your BIOS setup\n");
+                                               pr_err("if BIOS doesn't have that option, contact your HW vendor!\n");
                                                printed_gart_size_msg = 1;
                                        }
                                } else {
@@ -446,13 +452,10 @@ out:
                   force_iommu ||
                   valid_agp ||
                   fallback_aper_force) {
-               printk(KERN_INFO
-                       "Your BIOS doesn't leave a aperture memory hole\n");
-               printk(KERN_INFO
-                       "Please enable the IOMMU option in the BIOS setup\n");
-               printk(KERN_INFO
-                       "This costs you %d MB of RAM\n",
-                               32 << fallback_aper_order);
+               pr_info("Your BIOS doesn't leave a aperture memory hole\n");
+               pr_info("Please enable the IOMMU option in the BIOS setup\n");
+               pr_info("This costs you %dMB of RAM\n",
+                       32 << fallback_aper_order);
 
                aper_order = fallback_aper_order;
                aper_alloc = allocate_aperture();
index 01edac6c5e1867c489b8e99dab52761dcd5b849a..5075371ab59395b37d9819c4af90ba5a0d4724e5 100644 (file)
@@ -489,8 +489,12 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
        }
 
        node = acpi_get_node(device->handle);
-       if (node == NUMA_NO_NODE)
+       if (node == NUMA_NO_NODE) {
                node = x86_pci_root_bus_node(busnum);
+               if (node != 0 && node != NUMA_NO_NODE)
+                       dev_info(&device->dev, FW_BUG "no _PXM; falling back to node %d from hardware (may be inconsistent with ACPI node numbers)\n",
+                               node);
+       }
 
        if (node != NUMA_NO_NODE && !node_online(node))
                node = NUMA_NO_NODE;
index e88f4c53d7f6b41d4268b4eb51fad5badd514c2b..c20d2cc7ef64062e1b8bf032255253488ff94b43 100644 (file)
 
 #include "bus_numa.h"
 
-/*
- * This discovers the pcibus <-> node mapping on AMD K8.
- * also get peer root bus resource for io,mmio
- */
+#define AMD_NB_F0_NODE_ID                      0x60
+#define AMD_NB_F0_UNIT_ID                      0x64
+#define AMD_NB_F1_CONFIG_MAP_REG               0xe0
+
+#define RANGE_NUM                              16
+#define AMD_NB_F1_CONFIG_MAP_RANGES            4
 
-struct pci_hostbridge_probe {
+struct amd_hostbridge {
        u32 bus;
        u32 slot;
-       u32 vendor;
        u32 device;
 };
 
-static struct pci_hostbridge_probe pci_probes[] __initdata = {
-       { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1100 },
-       { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1200 },
-       { 0xff, 0, PCI_VENDOR_ID_AMD, 0x1200 },
-       { 0, 0x18, PCI_VENDOR_ID_AMD, 0x1300 },
+/*
+ * IMPORTANT NOTE:
+ * hb_probes[] and early_root_info_init() is in maintenance mode.
+ * It only supports K8, Fam10h, Fam11h, and Fam15h_00h-0fh .
+ * Future processor will rely on information in ACPI.
+ */
+static struct amd_hostbridge hb_probes[] __initdata = {
+       { 0, 0x18, 0x1100 }, /* K8 */
+       { 0, 0x18, 0x1200 }, /* Family10h */
+       { 0xff, 0, 0x1200 }, /* Family10h */
+       { 0, 0x18, 0x1300 }, /* Family11h */
+       { 0, 0x18, 0x1600 }, /* Family15h */
 };
 
-#define RANGE_NUM 16
-
 static struct pci_root_info __init *find_pci_root_info(int node, int link)
 {
        struct pci_root_info *info;
@@ -45,12 +51,12 @@ static struct pci_root_info __init *find_pci_root_info(int node, int link)
 }
 
 /**
- * early_fill_mp_bus_to_node()
+ * early_root_info_init()
  * called before pcibios_scan_root and pci_scan_bus
- * fills the mp_bus_to_cpumask array based according to the LDT Bus Number
- * Registers found in the K8 northbridge
+ * fills the mp_bus_to_cpumask array based according
+ * to the LDT Bus Number Registers found in the northbridge.
  */
-static int __init early_fill_mp_bus_info(void)
+static int __init early_root_info_init(void)
 {
        int i;
        unsigned bus;
@@ -75,19 +81,21 @@ static int __init early_fill_mp_bus_info(void)
                return -1;
 
        found = false;
-       for (i = 0; i < ARRAY_SIZE(pci_probes); i++) {
+       for (i = 0; i < ARRAY_SIZE(hb_probes); i++) {
                u32 id;
                u16 device;
                u16 vendor;
 
-               bus = pci_probes[i].bus;
-               slot = pci_probes[i].slot;
+               bus = hb_probes[i].bus;
+               slot = hb_probes[i].slot;
                id = read_pci_config(bus, slot, 0, PCI_VENDOR_ID);
-
                vendor = id & 0xffff;
                device = (id>>16) & 0xffff;
-               if (pci_probes[i].vendor == vendor &&
-                   pci_probes[i].device == device) {
+
+               if (vendor != PCI_VENDOR_ID_AMD)
+                       continue;
+
+               if (hb_probes[i].device == device) {
                        found = true;
                        break;
                }
@@ -96,10 +104,16 @@ static int __init early_fill_mp_bus_info(void)
        if (!found)
                return 0;
 
-       for (i = 0; i < 4; i++) {
+       /*
+        * We should learn topology and routing information from _PXM and
+        * _CRS methods in the ACPI namespace.  We extract node numbers
+        * here to work around BIOSes that don't supply _PXM.
+        */
+       for (i = 0; i < AMD_NB_F1_CONFIG_MAP_RANGES; i++) {
                int min_bus;
                int max_bus;
-               reg = read_pci_config(bus, slot, 1, 0xe0 + (i << 2));
+               reg = read_pci_config(bus, slot, 1,
+                               AMD_NB_F1_CONFIG_MAP_REG + (i << 2));
 
                /* Check if that register is enabled for bus range */
                if ((reg & 7) != 3)
@@ -113,10 +127,21 @@ static int __init early_fill_mp_bus_info(void)
                info = alloc_pci_root_info(min_bus, max_bus, node, link);
        }
 
+       /*
+        * The following code extracts routing information for use on old
+        * systems where Linux doesn't automatically use host bridge _CRS
+        * methods (or when the user specifies "pci=nocrs").
+        *
+        * We only do this through Fam11h, because _CRS should be enough on
+        * newer systems.
+        */
+       if (boot_cpu_data.x86 > 0x11)
+               return 0;
+
        /* get the default node and link for left over res */
-       reg = read_pci_config(bus, slot, 0, 0x60);
+       reg = read_pci_config(bus, slot, 0, AMD_NB_F0_NODE_ID);
        def_node = (reg >> 8) & 0x07;
-       reg = read_pci_config(bus, slot, 0, 0x64);
+       reg = read_pci_config(bus, slot, 0, AMD_NB_F0_UNIT_ID);
        def_link = (reg >> 8) & 0x03;
 
        memset(range, 0, sizeof(range));
@@ -363,7 +388,7 @@ static int __init pci_io_ecs_init(void)
        int cpu;
 
        /* assume all cpus from fam10h have IO ECS */
-        if (boot_cpu_data.x86 < 0x10)
+       if (boot_cpu_data.x86 < 0x10)
                return 0;
 
        /* Try the PCI method first. */
@@ -387,7 +412,7 @@ static int __init amd_postcore_init(void)
        if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
                return 0;
 
-       early_fill_mp_bus_info();
+       early_root_info_init();
        pci_io_ecs_init();
 
        return 0;
index 614392ced7d6b620a2db74cbe2e113a5e9f24643..bb461cfd01abc78cdc45c6e69f013128e04ccdb4 100644 (file)
@@ -60,8 +60,8 @@ static void __init cnb20le_res(u8 bus, u8 slot, u8 func)
        word1 = read_pci_config_16(bus, slot, func, 0xc4);
        word2 = read_pci_config_16(bus, slot, func, 0xc6);
        if (word1 != word2) {
-               res.start = (word1 << 16) | 0x0000;
-               res.end   = (word2 << 16) | 0xffff;
+               res.start = ((resource_size_t) word1 << 16) | 0x0000;
+               res.end   = ((resource_size_t) word2 << 16) | 0xffff;
                res.flags = IORESOURCE_MEM | IORESOURCE_PREFETCH;
                update_res(info, res.start, res.end, res.flags, 0);
        }
index 94ae9ae9574fe1678eab5f65c219293a871c8c8a..b5e60268d93fa0d19ffb793921e409aa13f9a12b 100644 (file)
@@ -6,6 +6,7 @@
 #include <linux/dmi.h>
 #include <linux/pci.h>
 #include <linux/vgaarb.h>
+#include <asm/hpet.h>
 #include <asm/pci_x86.h>
 
 static void pci_fixup_i450nx(struct pci_dev *d)
@@ -337,9 +338,7 @@ static void pci_fixup_video(struct pci_dev *pdev)
                 * type BRIDGE, or CARDBUS. Host to PCI controllers use
                 * PCI header type NORMAL.
                 */
-               if (bridge
-                   && ((bridge->hdr_type == PCI_HEADER_TYPE_BRIDGE)
-                      || (bridge->hdr_type == PCI_HEADER_TYPE_CARDBUS))) {
+               if (bridge && (pci_is_bridge(bridge))) {
                        pci_read_config_word(bridge, PCI_BRIDGE_CONTROL,
                                                &config);
                        if (!(config & PCI_BRIDGE_CTL_VGA))
@@ -526,6 +525,19 @@ static void sb600_disable_hpet_bar(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATI, 0x4385, sb600_disable_hpet_bar);
 
+#ifdef CONFIG_HPET_TIMER
+static void sb600_hpet_quirk(struct pci_dev *dev)
+{
+       struct resource *r = &dev->resource[1];
+
+       if (r->flags & IORESOURCE_MEM && r->start == hpet_address) {
+               r->flags |= IORESOURCE_PCI_FIXED;
+               dev_info(&dev->dev, "reg 0x14 contains HPET; making it immovable\n");
+       }
+}
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, 0x4385, sb600_hpet_quirk);
+#endif
+
 /*
  * Twinhead H12Y needs us to block out a region otherwise we map devices
  * there and any access kills the box.
index db6b1ab43255f0179ae6d539197828ce6834c96f..a19ed92e74e4bde4bf058d822513e1b5c97c0fdd 100644 (file)
@@ -271,11 +271,16 @@ static void pcibios_allocate_dev_resources(struct pci_dev *dev, int pass)
                                        "BAR %d: reserving %pr (d=%d, p=%d)\n",
                                        idx, r, disabled, pass);
                                if (pci_claim_resource(dev, idx) < 0) {
-                                       /* We'll assign a new address later */
-                                       pcibios_save_fw_addr(dev,
-                                                       idx, r->start);
-                                       r->end -= r->start;
-                                       r->start = 0;
+                                       if (r->flags & IORESOURCE_PCI_FIXED) {
+                                               dev_info(&dev->dev, "BAR %d %pR is immovable\n",
+                                                        idx, r);
+                                       } else {
+                                               /* We'll assign a new address later */
+                                               pcibios_save_fw_addr(dev,
+                                                               idx, r->start);
+                                               r->end -= r->start;
+                                               r->start = 0;
+                                       }
                                }
                        }
                }
@@ -356,6 +361,12 @@ static int __init pcibios_assign_resources(void)
        return 0;
 }
 
+/**
+ * called in fs_initcall (one below subsys_initcall),
+ * give a chance for motherboard reserve resources
+ */
+fs_initcall(pcibios_assign_resources);
+
 void pcibios_resource_survey_bus(struct pci_bus *bus)
 {
        dev_printk(KERN_DEBUG, &bus->dev, "Allocating resources\n");
@@ -392,12 +403,6 @@ void __init pcibios_resource_survey(void)
        ioapic_insert_resources();
 }
 
-/**
- * called in fs_initcall (one below subsys_initcall),
- * give a chance for motherboard reserve resources
- */
-fs_initcall(pcibios_assign_resources);
-
 static const struct vm_operations_struct pci_mmap_ops = {
        .access = generic_access_phys,
 };
index 614be031a79ab543295d8fe6b045db3a0aadb258..5d52dc43dfe73e55b5ee9e2e439fd73630ddd731 100644 (file)
 
 extern struct pci_controller* pcibios_alloc_controller(void);
 
-static inline void pcibios_penalize_isa_irq(int irq)
-{
-       /* We don't do dynamic PCI IRQ allocation */
-}
-
 /* Assume some values. (We should revise them, if necessary) */
 
 #define PCIBIOS_MIN_IO         0x2000
index bc256b64102710039e208ec82c513e97b223a290..7d6e84a51424b269d6bfffa401f6788ac44997ed 100644 (file)
 struct dma_coherent_mem {
        void            *virt_base;
        dma_addr_t      device_base;
-       phys_addr_t     pfn_base;
+       unsigned long   pfn_base;
        int             size;
        int             flags;
        unsigned long   *bitmap;
 };
 
-int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
+int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
                                dma_addr_t device_addr, size_t size, int flags)
 {
        void __iomem *mem_base = NULL;
@@ -32,7 +32,7 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
 
        /* FIXME: this routine just ignores DMA_MEMORY_INCLUDES_CHILDREN */
 
-       mem_base = ioremap(bus_addr, size);
+       mem_base = ioremap(phys_addr, size);
        if (!mem_base)
                goto out;
 
@@ -45,7 +45,7 @@ int dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
 
        dev->dma_mem->virt_base = mem_base;
        dev->dma_mem->device_base = device_addr;
-       dev->dma_mem->pfn_base = PFN_DOWN(bus_addr);
+       dev->dma_mem->pfn_base = PFN_DOWN(phys_addr);
        dev->dma_mem->size = pages;
        dev->dma_mem->flags = flags;
 
@@ -208,7 +208,7 @@ int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma,
 
                *ret = -ENXIO;
                if (off < count && user_count <= count - off) {
-                       unsigned pfn = mem->pfn_base + start + off;
+                       unsigned long pfn = mem->pfn_base + start + off;
                        *ret = remap_pfn_range(vma, vma->vm_start, pfn,
                                               user_count << PAGE_SHIFT,
                                               vma->vm_page_prot);
index 0ce39a33b3c2c2faf23746f662d609f22c7cf46b..6cd08e145bfa042b3073c10a993c9734741faa4e 100644 (file)
@@ -175,7 +175,7 @@ static void dmam_coherent_decl_release(struct device *dev, void *res)
 /**
  * dmam_declare_coherent_memory - Managed dma_declare_coherent_memory()
  * @dev: Device to declare coherent memory for
- * @bus_addr: Bus address of coherent memory to be declared
+ * @phys_addr: Physical address of coherent memory to be declared
  * @device_addr: Device address of coherent memory to be declared
  * @size: Size of coherent memory to be declared
  * @flags: Flags
@@ -185,7 +185,7 @@ static void dmam_coherent_decl_release(struct device *dev, void *res)
  * RETURNS:
  * 0 on success, -errno on failure.
  */
-int dmam_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
+int dmam_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
                                 dma_addr_t device_addr, size_t size, int flags)
 {
        void *res;
@@ -195,7 +195,7 @@ int dmam_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
        if (!res)
                return -ENOMEM;
 
-       rc = dma_declare_coherent_memory(dev, bus_addr, device_addr, size,
+       rc = dma_declare_coherent_memory(dev, phys_addr, device_addr, size,
                                         flags);
        if (rc == 0)
                devres_add(dev, res);
index 7c64fa756cced628807e70fb873b532964ea39d9..a842c71dcc211b8f036de693633345492f9a21e6 100644 (file)
@@ -2775,6 +2775,16 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id)
        return result;
 }
 
+static void nvme_reset_notify(struct pci_dev *pdev, bool prepare)
+{
+       struct nvme_dev *dev = pci_get_drvdata(pdev);
+
+       if (prepare)
+               nvme_dev_shutdown(dev);
+       else
+               nvme_dev_resume(dev);
+}
+
 static void nvme_shutdown(struct pci_dev *pdev)
 {
        struct nvme_dev *dev = pci_get_drvdata(pdev);
@@ -2839,6 +2849,7 @@ static const struct pci_error_handlers nvme_err_handler = {
        .link_reset     = nvme_link_reset,
        .slot_reset     = nvme_slot_reset,
        .resume         = nvme_error_resume,
+       .reset_notify   = nvme_reset_notify,
 };
 
 /* Move to pci_ids.h later */
index 293e2e0a0a87c7d9877c27524fd98503ba16c1cf..00b73448b22ea7b77a55785cfbbddf022bf4bfd3 100644 (file)
@@ -56,6 +56,7 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/debugfs.h>
+#include <linux/log2.h>
 
 /*
  * DDR target is the same on all platforms.
@@ -222,12 +223,6 @@ static int mvebu_mbus_window_conflicts(struct mvebu_mbus_state *mbus,
                 */
                if ((u64)base < wend && end > wbase)
                        return 0;
-
-               /*
-                * Check if target/attribute conflicts
-                */
-               if (target == wtarget && attr == wattr)
-                       return 0;
        }
 
        return 1;
@@ -266,6 +261,17 @@ static int mvebu_mbus_setup_window(struct mvebu_mbus_state *mbus,
                mbus->soc->win_cfg_offset(win);
        u32 ctrl, remap_addr;
 
+       if (!is_power_of_2(size)) {
+               WARN(true, "Invalid MBus window size: 0x%zx\n", size);
+               return -EINVAL;
+       }
+
+       if ((base & (phys_addr_t)(size - 1)) != 0) {
+               WARN(true, "Invalid MBus base/size: %pa len 0x%zx\n", &base,
+                    size);
+               return -EINVAL;
+       }
+
        ctrl = ((size - 1) & WIN_CTRL_SIZE_MASK) |
                (attr << WIN_CTRL_ATTR_SHIFT)    |
                (target << WIN_CTRL_TGT_SHIFT)   |
@@ -413,6 +419,10 @@ static int mvebu_devs_debug_show(struct seq_file *seq, void *v)
                           win, (unsigned long long)wbase,
                           (unsigned long long)(wbase + wsize), wtarget, wattr);
 
+               if (!is_power_of_2(wsize) ||
+                   ((wbase & (u64)(wsize - 1)) != 0))
+                       seq_puts(seq, " (Invalid base/size!!)");
+
                if (win < mbus->soc->num_remappable_wins) {
                        seq_printf(seq, " (remap %016llx)\n",
                                   (unsigned long long)wremap);
index 8d0450b9b9af42e5b4db08ab68b94f44a971a0ae..64b68320249f0e5e05db5ef8a0eccc0a2925dade 100644 (file)
@@ -275,7 +275,6 @@ static int i82875p_setup_overfl_dev(struct pci_dev *pdev,
 {
        struct pci_dev *dev;
        void __iomem *window;
-       int err;
 
        *ovrfl_pdev = NULL;
        *ovrfl_window = NULL;
@@ -293,13 +292,8 @@ static int i82875p_setup_overfl_dev(struct pci_dev *pdev,
                if (dev == NULL)
                        return 1;
 
-               err = pci_bus_add_device(dev);
-               if (err) {
-                       i82875p_printk(KERN_ERR,
-                               "%s(): pci_bus_add_device() Failed\n",
-                               __func__);
-               }
                pci_bus_assign_resources(dev->bus);
+               pci_bus_add_device(dev);
        }
 
        *ovrfl_pdev = dev;
index 074018979cdfb047f96619bf050b0f26ba5a623f..2ca0744b0a45b1d8e0cef34d9fd7b2a9bc651883 100644 (file)
@@ -1011,13 +1011,13 @@ static phys_addr_t exynos_iommu_iova_to_phys(struct iommu_domain *domain,
 }
 
 static struct iommu_ops exynos_iommu_ops = {
-       .domain_init = &exynos_iommu_domain_init,
-       .domain_destroy = &exynos_iommu_domain_destroy,
-       .attach_dev = &exynos_iommu_attach_device,
-       .detach_dev = &exynos_iommu_detach_device,
-       .map = &exynos_iommu_map,
-       .unmap = &exynos_iommu_unmap,
-       .iova_to_phys = &exynos_iommu_iova_to_phys,
+       .domain_init = exynos_iommu_domain_init,
+       .domain_destroy = exynos_iommu_domain_destroy,
+       .attach_dev = exynos_iommu_attach_device,
+       .detach_dev = exynos_iommu_detach_device,
+       .map = exynos_iommu_map,
+       .unmap = exynos_iommu_unmap,
+       .iova_to_phys = exynos_iommu_iova_to_phys,
        .pgsize_bitmap = SECT_SIZE | LPAGE_SIZE | SPAGE_SIZE,
 };
 
index 6b1a6ef9f1a8c3b1348218be489a59ac519d30c5..294f667ccab6279ea372718a72d7e0b0b6733db8 100644 (file)
@@ -628,7 +628,7 @@ int genwqe_set_interrupt_capability(struct genwqe_dev *cd, int count)
        int rc;
        struct pci_dev *pci_dev = cd->pci_dev;
 
-       rc = pci_enable_msi_block(pci_dev, count);
+       rc = pci_enable_msi_exact(pci_dev, count);
        if (rc == 0)
                cd->flags |= GENWQE_FLAG_MSI_ENABLED;
        return rc;
index 7f8b78c08879cf7911fa68db21cfbe5f29394d56..d292d7cb3417062643379805a969f5d29718de2f 100644 (file)
@@ -148,7 +148,7 @@ static noinline void pci_wait_cfg(struct pci_dev *dev)
 int pci_user_read_config_##size                                                \
        (struct pci_dev *dev, int pos, type *val)                       \
 {                                                                      \
-       int ret = 0;                                                    \
+       int ret = PCIBIOS_SUCCESSFUL;                                   \
        u32 data = -1;                                                  \
        if (PCI_##size##_BAD)                                           \
                return -EINVAL;                                         \
@@ -159,9 +159,7 @@ int pci_user_read_config_##size                                             \
                                        pos, sizeof(type), &data);      \
        raw_spin_unlock_irq(&pci_lock);                         \
        *val = (type)data;                                              \
-       if (ret > 0)                                                    \
-               ret = -EINVAL;                                          \
-       return ret;                                                     \
+       return pcibios_err_to_errno(ret);                               \
 }                                                                      \
 EXPORT_SYMBOL_GPL(pci_user_read_config_##size);
 
@@ -170,7 +168,7 @@ EXPORT_SYMBOL_GPL(pci_user_read_config_##size);
 int pci_user_write_config_##size                                       \
        (struct pci_dev *dev, int pos, type val)                        \
 {                                                                      \
-       int ret = -EIO;                                                 \
+       int ret = PCIBIOS_SUCCESSFUL;                                   \
        if (PCI_##size##_BAD)                                           \
                return -EINVAL;                                         \
        raw_spin_lock_irq(&pci_lock);                           \
@@ -179,9 +177,7 @@ int pci_user_write_config_##size                                    \
        ret = dev->bus->ops->write(dev->bus, dev->devfn,                \
                                        pos, sizeof(type), val);        \
        raw_spin_unlock_irq(&pci_lock);                         \
-       if (ret > 0)                                                    \
-               ret = -EINVAL;                                          \
-       return ret;                                                     \
+       return pcibios_err_to_errno(ret);                               \
 }                                                                      \
 EXPORT_SYMBOL_GPL(pci_user_write_config_##size);
 
@@ -235,10 +231,7 @@ static int pci_vpd_pci22_wait(struct pci_dev *dev)
                }
 
                if (time_after(jiffies, timeout)) {
-                       dev_printk(KERN_DEBUG, &dev->dev,
-                                  "vpd r/w failed.  This is likely a firmware "
-                                  "bug on this device.  Contact the card "
-                                  "vendor for a firmware update.");
+                       dev_printk(KERN_DEBUG, &dev->dev, "vpd r/w failed.  This is likely a firmware bug on this device.  Contact the card vendor for a firmware update\n");
                        return -ETIMEDOUT;
                }
                if (fatal_signal_pending(current))
index fb8aed307c2821d70404dbac467fc94d914ed7e0..73aef51a28f0760fefa6b4344235e7f341bebb3d 100644 (file)
@@ -13,7 +13,6 @@
 #include <linux/errno.h>
 #include <linux/ioport.h>
 #include <linux/proc_fs.h>
-#include <linux/init.h>
 #include <linux/slab.h>
 
 #include "pci.h"
@@ -227,6 +226,7 @@ int pci_bus_alloc_resource(struct pci_bus *bus, struct resource *res,
                                         type_mask, alignf, alignf_data,
                                         &pci_32_bit);
 }
+EXPORT_SYMBOL(pci_bus_alloc_resource);
 
 void __weak pcibios_resource_survey_bus(struct pci_bus *bus) { }
 
@@ -236,7 +236,7 @@ void __weak pcibios_resource_survey_bus(struct pci_bus *bus) { }
  *
  * This adds add sysfs entries and start device drivers
  */
-int pci_bus_add_device(struct pci_dev *dev)
+void pci_bus_add_device(struct pci_dev *dev)
 {
        int retval;
 
@@ -253,9 +253,8 @@ int pci_bus_add_device(struct pci_dev *dev)
        WARN_ON(retval < 0);
 
        dev->is_added = 1;
-
-       return 0;
 }
+EXPORT_SYMBOL_GPL(pci_bus_add_device);
 
 /**
  * pci_bus_add_devices - start driver for PCI devices
@@ -267,16 +266,12 @@ void pci_bus_add_devices(const struct pci_bus *bus)
 {
        struct pci_dev *dev;
        struct pci_bus *child;
-       int retval;
 
        list_for_each_entry(dev, &bus->devices, bus_list) {
                /* Skip already-added devices */
                if (dev->is_added)
                        continue;
-               retval = pci_bus_add_device(dev);
-               if (retval)
-                       dev_err(&dev->dev, "Error adding device (%d)\n",
-                               retval);
+               pci_bus_add_device(dev);
        }
 
        list_for_each_entry(dev, &bus->devices, bus_list) {
@@ -286,6 +281,7 @@ void pci_bus_add_devices(const struct pci_bus *bus)
                        pci_bus_add_devices(child);
        }
 }
+EXPORT_SYMBOL(pci_bus_add_devices);
 
 /** pci_walk_bus - walk devices on/under bus, calling callback.
  *  @top      bus whose devices should be walked
@@ -351,6 +347,3 @@ void pci_bus_put(struct pci_bus *bus)
 }
 EXPORT_SYMBOL(pci_bus_put);
 
-EXPORT_SYMBOL(pci_bus_alloc_resource);
-EXPORT_SYMBOL_GPL(pci_bus_add_device);
-EXPORT_SYMBOL(pci_bus_add_devices);
index 47aaf22d814e195f7d397237a59267334ccf5ca2..0e5f3c95af5bd75d288d2067b79aacc6abd65a94 100644 (file)
@@ -3,7 +3,6 @@
  */
 
 #include <linux/kernel.h>
-#include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/module.h>
 
index a6f67ec8882f1f4eab68aad1f64244f55df15738..21df477be0c8ad7468c3e985467173567488c902 100644 (file)
@@ -33,4 +33,17 @@ config PCI_RCAR_GEN2
          There are 3 internal PCI controllers available with a single
          built-in EHCI/OHCI host controller present on each one.
 
+config PCI_RCAR_GEN2_PCIE
+       bool "Renesas R-Car PCIe controller"
+       depends on ARCH_SHMOBILE || (ARM && COMPILE_TEST)
+       help
+         Say Y here if you want PCIe controller support on R-Car Gen2 SoCs.
+
+config PCI_HOST_GENERIC
+       bool "Generic PCI host controller"
+       depends on ARM && OF
+       help
+         Say Y here if you want to support a simple generic PCI host
+         controller, such as the one emulated by kvmtool.
+
 endmenu
index 13fb3333aa0524458b4427fceef3ca79926bfd04..611ba4b48c9491f1ab46d2c7f4818d76405facfb 100644 (file)
@@ -4,3 +4,5 @@ obj-$(CONFIG_PCI_IMX6) += pci-imx6.o
 obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o
 obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o
 obj-$(CONFIG_PCI_RCAR_GEN2) += pci-rcar-gen2.o
+obj-$(CONFIG_PCI_RCAR_GEN2_PCIE) += pcie-rcar.o
+obj-$(CONFIG_PCI_HOST_GENERIC) += pci-host-generic.o
index 3de6bfbbe8e95b4805b216662a013f03ee8a7367..c5d0ca3845028d65e1476ea2e279a70beb6a7049 100644 (file)
@@ -415,9 +415,7 @@ static irqreturn_t exynos_pcie_msi_irq_handler(int irq, void *arg)
 {
        struct pcie_port *pp = arg;
 
-       dw_handle_msi_irq(pp);
-
-       return IRQ_HANDLED;
+       return dw_handle_msi_irq(pp);
 }
 
 static void exynos_pcie_msi_init(struct pcie_port *pp)
@@ -511,7 +509,8 @@ static struct pcie_host_ops exynos_pcie_host_ops = {
        .host_init = exynos_pcie_host_init,
 };
 
-static int add_pcie_port(struct pcie_port *pp, struct platform_device *pdev)
+static int __init add_pcie_port(struct pcie_port *pp,
+                               struct platform_device *pdev)
 {
        int ret;
 
@@ -546,7 +545,6 @@ static int add_pcie_port(struct pcie_port *pp, struct platform_device *pdev)
        pp->root_bus_nr = -1;
        pp->ops = &exynos_pcie_host_ops;
 
-       spin_lock_init(&pp->conf_lock);
        ret = dw_pcie_host_init(pp);
        if (ret) {
                dev_err(&pdev->dev, "failed to initialize host\n");
@@ -568,10 +566,8 @@ static int __init exynos_pcie_probe(struct platform_device *pdev)
 
        exynos_pcie = devm_kzalloc(&pdev->dev, sizeof(*exynos_pcie),
                                GFP_KERNEL);
-       if (!exynos_pcie) {
-               dev_err(&pdev->dev, "no memory for exynos pcie\n");
+       if (!exynos_pcie)
                return -ENOMEM;
-       }
 
        pp = &exynos_pcie->pp;
 
diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
new file mode 100644 (file)
index 0000000..44fe6aa
--- /dev/null
@@ -0,0 +1,388 @@
+/*
+ * Simple, generic PCI host controller driver targetting firmware-initialised
+ * systems and virtual machines (e.g. the PCI emulation provided by kvmtool).
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright (C) 2014 ARM Limited
+ *
+ * Author: Will Deacon <will.deacon@arm.com>
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/of_pci.h>
+#include <linux/platform_device.h>
+
+struct gen_pci_cfg_bus_ops {
+       u32 bus_shift;
+       void __iomem *(*map_bus)(struct pci_bus *, unsigned int, int);
+};
+
+struct gen_pci_cfg_windows {
+       struct resource                         res;
+       struct resource                         bus_range;
+       void __iomem                            **win;
+
+       const struct gen_pci_cfg_bus_ops        *ops;
+};
+
+struct gen_pci {
+       struct pci_host_bridge                  host;
+       struct gen_pci_cfg_windows              cfg;
+       struct list_head                        resources;
+};
+
+static void __iomem *gen_pci_map_cfg_bus_cam(struct pci_bus *bus,
+                                            unsigned int devfn,
+                                            int where)
+{
+       struct pci_sys_data *sys = bus->sysdata;
+       struct gen_pci *pci = sys->private_data;
+       resource_size_t idx = bus->number - pci->cfg.bus_range.start;
+
+       return pci->cfg.win[idx] + ((devfn << 8) | where);
+}
+
+static struct gen_pci_cfg_bus_ops gen_pci_cfg_cam_bus_ops = {
+       .bus_shift      = 16,
+       .map_bus        = gen_pci_map_cfg_bus_cam,
+};
+
+static void __iomem *gen_pci_map_cfg_bus_ecam(struct pci_bus *bus,
+                                             unsigned int devfn,
+                                             int where)
+{
+       struct pci_sys_data *sys = bus->sysdata;
+       struct gen_pci *pci = sys->private_data;
+       resource_size_t idx = bus->number - pci->cfg.bus_range.start;
+
+       return pci->cfg.win[idx] + ((devfn << 12) | where);
+}
+
+static struct gen_pci_cfg_bus_ops gen_pci_cfg_ecam_bus_ops = {
+       .bus_shift      = 20,
+       .map_bus        = gen_pci_map_cfg_bus_ecam,
+};
+
+static int gen_pci_config_read(struct pci_bus *bus, unsigned int devfn,
+                               int where, int size, u32 *val)
+{
+       void __iomem *addr;
+       struct pci_sys_data *sys = bus->sysdata;
+       struct gen_pci *pci = sys->private_data;
+
+       addr = pci->cfg.ops->map_bus(bus, devfn, where);
+
+       switch (size) {
+       case 1:
+               *val = readb(addr);
+               break;
+       case 2:
+               *val = readw(addr);
+               break;
+       default:
+               *val = readl(addr);
+       }
+
+       return PCIBIOS_SUCCESSFUL;
+}
+
+static int gen_pci_config_write(struct pci_bus *bus, unsigned int devfn,
+                                int where, int size, u32 val)
+{
+       void __iomem *addr;
+       struct pci_sys_data *sys = bus->sysdata;
+       struct gen_pci *pci = sys->private_data;
+
+       addr = pci->cfg.ops->map_bus(bus, devfn, where);
+
+       switch (size) {
+       case 1:
+               writeb(val, addr);
+               break;
+       case 2:
+               writew(val, addr);
+               break;
+       default:
+               writel(val, addr);
+       }
+
+       return PCIBIOS_SUCCESSFUL;
+}
+
+static struct pci_ops gen_pci_ops = {
+       .read   = gen_pci_config_read,
+       .write  = gen_pci_config_write,
+};
+
+static const struct of_device_id gen_pci_of_match[] = {
+       { .compatible = "pci-host-cam-generic",
+         .data = &gen_pci_cfg_cam_bus_ops },
+
+       { .compatible = "pci-host-ecam-generic",
+         .data = &gen_pci_cfg_ecam_bus_ops },
+
+       { },
+};
+MODULE_DEVICE_TABLE(of, gen_pci_of_match);
+
+static int gen_pci_calc_io_offset(struct device *dev,
+                                 struct of_pci_range *range,
+                                 struct resource *res,
+                                 resource_size_t *offset)
+{
+       static atomic_t wins = ATOMIC_INIT(0);
+       int err, idx, max_win;
+       unsigned int window;
+
+       if (!PAGE_ALIGNED(range->cpu_addr))
+               return -EINVAL;
+
+       max_win = (IO_SPACE_LIMIT + 1) / SZ_64K;
+       idx = atomic_inc_return(&wins);
+       if (idx > max_win)
+               return -ENOSPC;
+
+       window = (idx - 1) * SZ_64K;
+       err = pci_ioremap_io(window, range->cpu_addr);
+       if (err)
+               return err;
+
+       of_pci_range_to_resource(range, dev->of_node, res);
+       res->start = window;
+       res->end = res->start + range->size - 1;
+       *offset = window - range->pci_addr;
+       return 0;
+}
+
+static int gen_pci_calc_mem_offset(struct device *dev,
+                                  struct of_pci_range *range,
+                                  struct resource *res,
+                                  resource_size_t *offset)
+{
+       of_pci_range_to_resource(range, dev->of_node, res);
+       *offset = range->cpu_addr - range->pci_addr;
+       return 0;
+}
+
+static void gen_pci_release_of_pci_ranges(struct gen_pci *pci)
+{
+       struct pci_host_bridge_window *win;
+
+       list_for_each_entry(win, &pci->resources, list)
+               release_resource(win->res);
+
+       pci_free_resource_list(&pci->resources);
+}
+
+static int gen_pci_parse_request_of_pci_ranges(struct gen_pci *pci)
+{
+       struct of_pci_range range;
+       struct of_pci_range_parser parser;
+       int err, res_valid = 0;
+       struct device *dev = pci->host.dev.parent;
+       struct device_node *np = dev->of_node;
+
+       if (of_pci_range_parser_init(&parser, np)) {
+               dev_err(dev, "missing \"ranges\" property\n");
+               return -EINVAL;
+       }
+
+       for_each_of_pci_range(&parser, &range) {
+               struct resource *parent, *res;
+               resource_size_t offset;
+               u32 restype = range.flags & IORESOURCE_TYPE_BITS;
+
+               res = devm_kmalloc(dev, sizeof(*res), GFP_KERNEL);
+               if (!res) {
+                       err = -ENOMEM;
+                       goto out_release_res;
+               }
+
+               switch (restype) {
+               case IORESOURCE_IO:
+                       parent = &ioport_resource;
+                       err = gen_pci_calc_io_offset(dev, &range, res, &offset);
+                       break;
+               case IORESOURCE_MEM:
+                       parent = &iomem_resource;
+                       err = gen_pci_calc_mem_offset(dev, &range, res, &offset);
+                       res_valid |= !(res->flags & IORESOURCE_PREFETCH || err);
+                       break;
+               default:
+                       err = -EINVAL;
+                       continue;
+               }
+
+               if (err) {
+                       dev_warn(dev,
+                                "error %d: failed to add resource [type 0x%x, %lld bytes]\n",
+                                err, restype, range.size);
+                       continue;
+               }
+
+               err = request_resource(parent, res);
+               if (err)
+                       goto out_release_res;
+
+               pci_add_resource_offset(&pci->resources, res, offset);
+       }
+
+       if (!res_valid) {
+               dev_err(dev, "non-prefetchable memory resource required\n");
+               err = -EINVAL;
+               goto out_release_res;
+       }
+
+       return 0;
+
+out_release_res:
+       gen_pci_release_of_pci_ranges(pci);
+       return err;
+}
+
+static int gen_pci_parse_map_cfg_windows(struct gen_pci *pci)
+{
+       int err;
+       u8 bus_max;
+       resource_size_t busn;
+       struct resource *bus_range;
+       struct device *dev = pci->host.dev.parent;
+       struct device_node *np = dev->of_node;
+
+       if (of_pci_parse_bus_range(np, &pci->cfg.bus_range))
+               pci->cfg.bus_range = (struct resource) {
+                       .name   = np->name,
+                       .start  = 0,
+                       .end    = 0xff,
+                       .flags  = IORESOURCE_BUS,
+               };
+
+       err = of_address_to_resource(np, 0, &pci->cfg.res);
+       if (err) {
+               dev_err(dev, "missing \"reg\" property\n");
+               return err;
+       }
+
+       pci->cfg.win = devm_kcalloc(dev, resource_size(&pci->cfg.bus_range),
+                                   sizeof(*pci->cfg.win), GFP_KERNEL);
+       if (!pci->cfg.win)
+               return -ENOMEM;
+
+       /* Limit the bus-range to fit within reg */
+       bus_max = pci->cfg.bus_range.start +
+                 (resource_size(&pci->cfg.res) >> pci->cfg.ops->bus_shift) - 1;
+       pci->cfg.bus_range.end = min_t(resource_size_t, pci->cfg.bus_range.end,
+                                      bus_max);
+
+       /* Map our Configuration Space windows */
+       if (!devm_request_mem_region(dev, pci->cfg.res.start,
+                                    resource_size(&pci->cfg.res),
+                                    "Configuration Space"))
+               return -ENOMEM;
+
+       bus_range = &pci->cfg.bus_range;
+       for (busn = bus_range->start; busn <= bus_range->end; ++busn) {
+               u32 idx = busn - bus_range->start;
+               u32 sz = 1 << pci->cfg.ops->bus_shift;
+
+               pci->cfg.win[idx] = devm_ioremap(dev,
+                                                pci->cfg.res.start + busn * sz,
+                                                sz);
+               if (!pci->cfg.win[idx])
+                       return -ENOMEM;
+       }
+
+       /* Register bus resource */
+       pci_add_resource(&pci->resources, bus_range);
+       return 0;
+}
+
+static int gen_pci_setup(int nr, struct pci_sys_data *sys)
+{
+       struct gen_pci *pci = sys->private_data;
+       list_splice_init(&pci->resources, &sys->resources);
+       return 1;
+}
+
+static int gen_pci_probe(struct platform_device *pdev)
+{
+       int err;
+       const char *type;
+       const struct of_device_id *of_id;
+       const int *prop;
+       struct device *dev = &pdev->dev;
+       struct device_node *np = dev->of_node;
+       struct gen_pci *pci = devm_kzalloc(dev, sizeof(*pci), GFP_KERNEL);
+       struct hw_pci hw = {
+               .nr_controllers = 1,
+               .private_data   = (void **)&pci,
+               .setup          = gen_pci_setup,
+               .map_irq        = of_irq_parse_and_map_pci,
+               .ops            = &gen_pci_ops,
+       };
+
+       if (!pci)
+               return -ENOMEM;
+
+       type = of_get_property(np, "device_type", NULL);
+       if (!type || strcmp(type, "pci")) {
+               dev_err(dev, "invalid \"device_type\" %s\n", type);
+               return -EINVAL;
+       }
+
+       prop = of_get_property(of_chosen, "linux,pci-probe-only", NULL);
+       if (prop) {
+               if (*prop)
+                       pci_add_flags(PCI_PROBE_ONLY);
+               else
+                       pci_clear_flags(PCI_PROBE_ONLY);
+       }
+
+       of_id = of_match_node(gen_pci_of_match, np);
+       pci->cfg.ops = of_id->data;
+       pci->host.dev.parent = dev;
+       INIT_LIST_HEAD(&pci->host.windows);
+       INIT_LIST_HEAD(&pci->resources);
+
+       /* Parse our PCI ranges and request their resources */
+       err = gen_pci_parse_request_of_pci_ranges(pci);
+       if (err)
+               return err;
+
+       /* Parse and map our Configuration Space windows */
+       err = gen_pci_parse_map_cfg_windows(pci);
+       if (err) {
+               gen_pci_release_of_pci_ranges(pci);
+               return err;
+       }
+
+       pci_common_init_dev(dev, &hw);
+       return 0;
+}
+
+static struct platform_driver gen_pci_driver = {
+       .driver = {
+               .name = "pci-host-generic",
+               .owner = THIS_MODULE,
+               .of_match_table = gen_pci_of_match,
+       },
+       .probe = gen_pci_probe,
+};
+module_platform_driver(gen_pci_driver);
+
+MODULE_DESCRIPTION("Generic PCI host driver");
+MODULE_AUTHOR("Will Deacon <will.deacon@arm.com>");
+MODULE_LICENSE("GPLv2");
index ee082509b0baa730b90a6c0111673214889604dd..a568efaa331c57cc35144b08fe3f3b386118c926 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/resource.h>
 #include <linux/signal.h>
 #include <linux/types.h>
+#include <linux/interrupt.h>
 
 #include "pcie-designware.h"
 
 
 struct imx6_pcie {
        int                     reset_gpio;
-       int                     power_on_gpio;
-       int                     wake_up_gpio;
-       int                     disable_gpio;
-       struct clk              *lvds_gate;
-       struct clk              *sata_ref_100m;
-       struct clk              *pcie_ref_125m;
-       struct clk              *pcie_axi;
+       struct clk              *pcie_bus;
+       struct clk              *pcie_phy;
+       struct clk              *pcie;
        struct pcie_port        pp;
        struct regmap           *iomuxc_gpr;
        void __iomem            *mem_base;
@@ -231,36 +228,27 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp)
        struct imx6_pcie *imx6_pcie = to_imx6_pcie(pp);
        int ret;
 
-       if (gpio_is_valid(imx6_pcie->power_on_gpio))
-               gpio_set_value(imx6_pcie->power_on_gpio, 1);
-
        regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
                        IMX6Q_GPR1_PCIE_TEST_PD, 0 << 18);
        regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1,
                        IMX6Q_GPR1_PCIE_REF_CLK_EN, 1 << 16);
 
-       ret = clk_prepare_enable(imx6_pcie->sata_ref_100m);
-       if (ret) {
-               dev_err(pp->dev, "unable to enable sata_ref_100m\n");
-               goto err_sata_ref;
-       }
-
-       ret = clk_prepare_enable(imx6_pcie->pcie_ref_125m);
+       ret = clk_prepare_enable(imx6_pcie->pcie_phy);
        if (ret) {
-               dev_err(pp->dev, "unable to enable pcie_ref_125m\n");
-               goto err_pcie_ref;
+               dev_err(pp->dev, "unable to enable pcie_phy clock\n");
+               goto err_pcie_phy;
        }
 
-       ret = clk_prepare_enable(imx6_pcie->lvds_gate);
+       ret = clk_prepare_enable(imx6_pcie->pcie_bus);
        if (ret) {
-               dev_err(pp->dev, "unable to enable lvds_gate\n");
-               goto err_lvds_gate;
+               dev_err(pp->dev, "unable to enable pcie_bus clock\n");
+               goto err_pcie_bus;
        }
 
-       ret = clk_prepare_enable(imx6_pcie->pcie_axi);
+       ret = clk_prepare_enable(imx6_pcie->pcie);
        if (ret) {
-               dev_err(pp->dev, "unable to enable pcie_axi\n");
-               goto err_pcie_axi;
+               dev_err(pp->dev, "unable to enable pcie clock\n");
+               goto err_pcie;
        }
 
        /* allow the clocks to stabilize */
@@ -274,13 +262,11 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp)
        }
        return 0;
 
-err_pcie_axi:
-       clk_disable_unprepare(imx6_pcie->lvds_gate);
-err_lvds_gate:
-       clk_disable_unprepare(imx6_pcie->pcie_ref_125m);
-err_pcie_ref:
-       clk_disable_unprepare(imx6_pcie->sata_ref_100m);
-err_sata_ref:
+err_pcie:
+       clk_disable_unprepare(imx6_pcie->pcie_bus);
+err_pcie_bus:
+       clk_disable_unprepare(imx6_pcie->pcie_phy);
+err_pcie_phy:
        return ret;
 
 }
@@ -329,6 +315,13 @@ static int imx6_pcie_wait_for_link(struct pcie_port *pp)
        return 0;
 }
 
+static irqreturn_t imx6_pcie_msi_handler(int irq, void *arg)
+{
+       struct pcie_port *pp = arg;
+
+       return dw_handle_msi_irq(pp);
+}
+
 static int imx6_pcie_start_link(struct pcie_port *pp)
 {
        struct imx6_pcie *imx6_pcie = to_imx6_pcie(pp);
@@ -403,6 +396,9 @@ static void imx6_pcie_host_init(struct pcie_port *pp)
        dw_pcie_setup_rc(pp);
 
        imx6_pcie_start_link(pp);
+
+       if (IS_ENABLED(CONFIG_PCI_MSI))
+               dw_pcie_msi_init(pp);
 }
 
 static void imx6_pcie_reset_phy(struct pcie_port *pp)
@@ -487,21 +483,30 @@ static struct pcie_host_ops imx6_pcie_host_ops = {
        .host_init = imx6_pcie_host_init,
 };
 
-static int imx6_add_pcie_port(struct pcie_port *pp,
+static int __init imx6_add_pcie_port(struct pcie_port *pp,
                        struct platform_device *pdev)
 {
        int ret;
 
-       pp->irq = platform_get_irq(pdev, 0);
-       if (!pp->irq) {
-               dev_err(&pdev->dev, "failed to get irq\n");
-               return -ENODEV;
+       if (IS_ENABLED(CONFIG_PCI_MSI)) {
+               pp->msi_irq = platform_get_irq_byname(pdev, "msi");
+               if (pp->msi_irq <= 0) {
+                       dev_err(&pdev->dev, "failed to get MSI irq\n");
+                       return -ENODEV;
+               }
+
+               ret = devm_request_irq(&pdev->dev, pp->msi_irq,
+                                      imx6_pcie_msi_handler,
+                                      IRQF_SHARED, "mx6-pcie-msi", pp);
+               if (ret) {
+                       dev_err(&pdev->dev, "failed to request MSI irq\n");
+                       return -ENODEV;
+               }
        }
 
        pp->root_bus_nr = -1;
        pp->ops = &imx6_pcie_host_ops;
 
-       spin_lock_init(&pp->conf_lock);
        ret = dw_pcie_host_init(pp);
        if (ret) {
                dev_err(&pdev->dev, "failed to initialize host\n");
@@ -546,69 +551,26 @@ static int __init imx6_pcie_probe(struct platform_device *pdev)
                }
        }
 
-       imx6_pcie->power_on_gpio = of_get_named_gpio(np, "power-on-gpio", 0);
-       if (gpio_is_valid(imx6_pcie->power_on_gpio)) {
-               ret = devm_gpio_request_one(&pdev->dev,
-                                       imx6_pcie->power_on_gpio,
-                                       GPIOF_OUT_INIT_LOW,
-                                       "PCIe power enable");
-               if (ret) {
-                       dev_err(&pdev->dev, "unable to get power-on gpio\n");
-                       return ret;
-               }
-       }
-
-       imx6_pcie->wake_up_gpio = of_get_named_gpio(np, "wake-up-gpio", 0);
-       if (gpio_is_valid(imx6_pcie->wake_up_gpio)) {
-               ret = devm_gpio_request_one(&pdev->dev,
-                                       imx6_pcie->wake_up_gpio,
-                                       GPIOF_IN,
-                                       "PCIe wake up");
-               if (ret) {
-                       dev_err(&pdev->dev, "unable to get wake-up gpio\n");
-                       return ret;
-               }
-       }
-
-       imx6_pcie->disable_gpio = of_get_named_gpio(np, "disable-gpio", 0);
-       if (gpio_is_valid(imx6_pcie->disable_gpio)) {
-               ret = devm_gpio_request_one(&pdev->dev,
-                                       imx6_pcie->disable_gpio,
-                                       GPIOF_OUT_INIT_HIGH,
-                                       "PCIe disable endpoint");
-               if (ret) {
-                       dev_err(&pdev->dev, "unable to get disable-ep gpio\n");
-                       return ret;
-               }
-       }
-
        /* Fetch clocks */
-       imx6_pcie->lvds_gate = devm_clk_get(&pdev->dev, "lvds_gate");
-       if (IS_ERR(imx6_pcie->lvds_gate)) {
-               dev_err(&pdev->dev,
-                       "lvds_gate clock select missing or invalid\n");
-               return PTR_ERR(imx6_pcie->lvds_gate);
-       }
-
-       imx6_pcie->sata_ref_100m = devm_clk_get(&pdev->dev, "sata_ref_100m");
-       if (IS_ERR(imx6_pcie->sata_ref_100m)) {
+       imx6_pcie->pcie_phy = devm_clk_get(&pdev->dev, "pcie_phy");
+       if (IS_ERR(imx6_pcie->pcie_phy)) {
                dev_err(&pdev->dev,
-                       "sata_ref_100m clock source missing or invalid\n");
-               return PTR_ERR(imx6_pcie->sata_ref_100m);
+                       "pcie_phy clock source missing or invalid\n");
+               return PTR_ERR(imx6_pcie->pcie_phy);
        }
 
-       imx6_pcie->pcie_ref_125m = devm_clk_get(&pdev->dev, "pcie_ref_125m");
-       if (IS_ERR(imx6_pcie->pcie_ref_125m)) {
+       imx6_pcie->pcie_bus = devm_clk_get(&pdev->dev, "pcie_bus");
+       if (IS_ERR(imx6_pcie->pcie_bus)) {
                dev_err(&pdev->dev,
-                       "pcie_ref_125m clock source missing or invalid\n");
-               return PTR_ERR(imx6_pcie->pcie_ref_125m);
+                       "pcie_bus clock source missing or invalid\n");
+               return PTR_ERR(imx6_pcie->pcie_bus);
        }
 
-       imx6_pcie->pcie_axi = devm_clk_get(&pdev->dev, "pcie_axi");
-       if (IS_ERR(imx6_pcie->pcie_axi)) {
+       imx6_pcie->pcie = devm_clk_get(&pdev->dev, "pcie");
+       if (IS_ERR(imx6_pcie->pcie)) {
                dev_err(&pdev->dev,
-                       "pcie_axi clock source missing or invalid\n");
-               return PTR_ERR(imx6_pcie->pcie_axi);
+                       "pcie clock source missing or invalid\n");
+               return PTR_ERR(imx6_pcie->pcie);
        }
 
        /* Grab GPR config register range */
index d3d1cfd51e095f058404d96f063df76d227bd652..ce23e0f076b6663297ca403508b2e5244b639102 100644 (file)
@@ -113,7 +113,6 @@ struct mvebu_pcie {
 struct mvebu_pcie_port {
        char *name;
        void __iomem *base;
-       spinlock_t conf_lock;
        u32 port;
        u32 lane;
        int devfn;
@@ -293,6 +292,60 @@ static int mvebu_pcie_hw_wr_conf(struct mvebu_pcie_port *port,
        return PCIBIOS_SUCCESSFUL;
 }
 
+/*
+ * Remove windows, starting from the largest ones to the smallest
+ * ones.
+ */
+static void mvebu_pcie_del_windows(struct mvebu_pcie_port *port,
+                                  phys_addr_t base, size_t size)
+{
+       while (size) {
+               size_t sz = 1 << (fls(size) - 1);
+
+               mvebu_mbus_del_window(base, sz);
+               base += sz;
+               size -= sz;
+       }
+}
+
+/*
+ * MBus windows can only have a power of two size, but PCI BARs do not
+ * have this constraint. Therefore, we have to split the PCI BAR into
+ * areas each having a power of two size. We start from the largest
+ * one (i.e highest order bit set in the size).
+ */
+static void mvebu_pcie_add_windows(struct mvebu_pcie_port *port,
+                                  unsigned int target, unsigned int attribute,
+                                  phys_addr_t base, size_t size,
+                                  phys_addr_t remap)
+{
+       size_t size_mapped = 0;
+
+       while (size) {
+               size_t sz = 1 << (fls(size) - 1);
+               int ret;
+
+               ret = mvebu_mbus_add_window_remap_by_id(target, attribute, base,
+                                                       sz, remap);
+               if (ret) {
+                       phys_addr_t end = base + sz - 1;
+
+                       dev_err(&port->pcie->pdev->dev,
+                               "Could not create MBus window at [mem %pa-%pa]: %d\n",
+                               &base, &end, ret);
+                       mvebu_pcie_del_windows(port, base - size_mapped,
+                                              size_mapped);
+                       return;
+               }
+
+               size -= sz;
+               size_mapped += sz;
+               base += sz;
+               if (remap != MVEBU_MBUS_NO_REMAP)
+                       remap += sz;
+       }
+}
+
 static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
 {
        phys_addr_t iobase;
@@ -304,8 +357,8 @@ static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
 
                /* If a window was configured, remove it */
                if (port->iowin_base) {
-                       mvebu_mbus_del_window(port->iowin_base,
-                                             port->iowin_size);
+                       mvebu_pcie_del_windows(port, port->iowin_base,
+                                              port->iowin_size);
                        port->iowin_base = 0;
                        port->iowin_size = 0;
                }
@@ -331,11 +384,11 @@ static void mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
        port->iowin_base = port->pcie->io.start + iobase;
        port->iowin_size = ((0xFFF | ((port->bridge.iolimit & 0xF0) << 8) |
                            (port->bridge.iolimitupper << 16)) -
-                           iobase);
+                           iobase) + 1;
 
-       mvebu_mbus_add_window_remap_by_id(port->io_target, port->io_attr,
-                                         port->iowin_base, port->iowin_size,
-                                         iobase);
+       mvebu_pcie_add_windows(port, port->io_target, port->io_attr,
+                              port->iowin_base, port->iowin_size,
+                              iobase);
 }
 
 static void mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port)
@@ -346,8 +399,8 @@ static void mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port)
 
                /* If a window was configured, remove it */
                if (port->memwin_base) {
-                       mvebu_mbus_del_window(port->memwin_base,
-                                             port->memwin_size);
+                       mvebu_pcie_del_windows(port, port->memwin_base,
+                                              port->memwin_size);
                        port->memwin_base = 0;
                        port->memwin_size = 0;
                }
@@ -364,10 +417,11 @@ static void mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port)
        port->memwin_base  = ((port->bridge.membase & 0xFFF0) << 16);
        port->memwin_size  =
                (((port->bridge.memlimit & 0xFFF0) << 16) | 0xFFFFF) -
-               port->memwin_base;
+               port->memwin_base + 1;
 
-       mvebu_mbus_add_window_by_id(port->mem_target, port->mem_attr,
-                                   port->memwin_base, port->memwin_size);
+       mvebu_pcie_add_windows(port, port->mem_target, port->mem_attr,
+                              port->memwin_base, port->memwin_size,
+                              MVEBU_MBUS_NO_REMAP);
 }
 
 /*
@@ -560,9 +614,9 @@ static inline struct mvebu_pcie *sys_to_pcie(struct pci_sys_data *sys)
        return sys->private_data;
 }
 
-static struct mvebu_pcie_port *
-mvebu_pcie_find_port(struct mvebu_pcie *pcie, struct pci_bus *bus,
-                    int devfn)
+static struct mvebu_pcie_port *mvebu_pcie_find_port(struct mvebu_pcie *pcie,
+                                                   struct pci_bus *bus,
+                                                   int devfn)
 {
        int i;
 
@@ -585,7 +639,6 @@ static int mvebu_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
 {
        struct mvebu_pcie *pcie = sys_to_pcie(bus->sysdata);
        struct mvebu_pcie_port *port;
-       unsigned long flags;
        int ret;
 
        port = mvebu_pcie_find_port(pcie, bus, devfn);
@@ -611,10 +664,8 @@ static int mvebu_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
                return PCIBIOS_DEVICE_NOT_FOUND;
 
        /* Access the real PCIe interface */
-       spin_lock_irqsave(&port->conf_lock, flags);
        ret = mvebu_pcie_hw_wr_conf(port, bus, devfn,
                                    where, size, val);
-       spin_unlock_irqrestore(&port->conf_lock, flags);
 
        return ret;
 }
@@ -625,7 +676,6 @@ static int mvebu_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
 {
        struct mvebu_pcie *pcie = sys_to_pcie(bus->sysdata);
        struct mvebu_pcie_port *port;
-       unsigned long flags;
        int ret;
 
        port = mvebu_pcie_find_port(pcie, bus, devfn);
@@ -657,10 +707,8 @@ static int mvebu_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
        }
 
        /* Access the real PCIe interface */
-       spin_lock_irqsave(&port->conf_lock, flags);
        ret = mvebu_pcie_hw_rd_conf(port, bus, devfn,
                                    where, size, val);
-       spin_unlock_irqrestore(&port->conf_lock, flags);
 
        return ret;
 }
@@ -733,24 +781,31 @@ static void mvebu_pcie_add_bus(struct pci_bus *bus)
 }
 
 static resource_size_t mvebu_pcie_align_resource(struct pci_dev *dev,
-                                               const struct resource *res,
-                                               resource_size_t start,
-                                               resource_size_t size,
-                                               resource_size_t align)
+                                                const struct resource *res,
+                                                resource_size_t start,
+                                                resource_size_t size,
+                                                resource_size_t align)
 {
        if (dev->bus->number != 0)
                return start;
 
        /*
         * On the PCI-to-PCI bridge side, the I/O windows must have at
-        * least a 64 KB size and be aligned on their size, and the
-        * memory windows must have at least a 1 MB size and be
-        * aligned on their size
+        * least a 64 KB size and the memory windows must have at
+        * least a 1 MB size. Moreover, MBus windows need to have a
+        * base address aligned on their size, and their size must be
+        * a power of two. This means that if the BAR doesn't have a
+        * power of two size, several MBus windows will actually be
+        * created. We need to ensure that the biggest MBus window
+        * (which will be the first one) is aligned on its size, which
+        * explains the rounddown_pow_of_two() being done here.
         */
        if (res->flags & IORESOURCE_IO)
-               return round_up(start, max_t(resource_size_t, SZ_64K, size));
+               return round_up(start, max_t(resource_size_t, SZ_64K,
+                                            rounddown_pow_of_two(size)));
        else if (res->flags & IORESOURCE_MEM)
-               return round_up(start, max_t(resource_size_t, SZ_1M, size));
+               return round_up(start, max_t(resource_size_t, SZ_1M,
+                                            rounddown_pow_of_two(size)));
        else
                return start;
 }
@@ -779,7 +834,8 @@ static void mvebu_pcie_enable(struct mvebu_pcie *pcie)
  * found, maps it.
  */
 static void __iomem *mvebu_pcie_map_registers(struct platform_device *pdev,
-                     struct device_node *np, struct mvebu_pcie_port *port)
+                                             struct device_node *np,
+                                             struct mvebu_pcie_port *port)
 {
        struct resource regs;
        int ret = 0;
@@ -1000,7 +1056,6 @@ static int mvebu_pcie_probe(struct platform_device *pdev)
                mvebu_pcie_set_local_dev_nr(port, 1);
 
                port->dn = child;
-               spin_lock_init(&port->conf_lock);
                mvebu_sw_pci_bridge_init(port);
                i++;
        }
index fd3e3ab56509125db9e6d25b1b2288eaccda60fd..3ef854f5a5b5d3cc9cd40435e82df54859085d33 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
+#include <linux/of_pci.h>
 #include <linux/pci.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
@@ -98,6 +99,7 @@ struct rcar_pci_priv {
        struct resource io_res;
        struct resource mem_res;
        struct resource *cfg_res;
+       unsigned busnr;
        int irq;
        unsigned long window_size;
 };
@@ -180,8 +182,13 @@ static int rcar_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
        struct pci_sys_data *sys = dev->bus->sysdata;
        struct rcar_pci_priv *priv = sys->private_data;
+       int irq;
+
+       irq = of_irq_parse_and_map_pci(dev, slot, pin);
+       if (!irq)
+               irq = priv->irq;
 
-       return priv->irq;
+       return irq;
 }
 
 #ifdef CONFIG_PCI_DEBUG
@@ -312,8 +319,8 @@ static int rcar_pci_setup(int nr, struct pci_sys_data *sys)
        pci_add_resource(&sys->resources, &priv->io_res);
        pci_add_resource(&sys->resources, &priv->mem_res);
 
-       /* Setup bus number based on platform device id */
-       sys->busnr = to_platform_device(priv->dev)->id;
+       /* Setup bus number based on platform device id / of bus-range */
+       sys->busnr = priv->busnr;
        return 1;
 }
 
@@ -366,6 +373,23 @@ static int rcar_pci_probe(struct platform_device *pdev)
 
        priv->window_size = SZ_1G;
 
+       if (pdev->dev.of_node) {
+               struct resource busnr;
+               int ret;
+
+               ret = of_pci_parse_bus_range(pdev->dev.of_node, &busnr);
+               if (ret < 0) {
+                       dev_err(&pdev->dev, "failed to parse bus-range\n");
+                       return ret;
+               }
+
+               priv->busnr = busnr.start;
+               if (busnr.end != busnr.start)
+                       dev_warn(&pdev->dev, "only one bus number supported\n");
+       } else {
+               priv->busnr = pdev->id;
+       }
+
        hw_private[0] = priv;
        memset(&hw, 0, sizeof(hw));
        hw.nr_controllers = ARRAY_SIZE(hw_private);
@@ -377,11 +401,20 @@ static int rcar_pci_probe(struct platform_device *pdev)
        return 0;
 }
 
+static struct of_device_id rcar_pci_of_match[] = {
+       { .compatible = "renesas,pci-r8a7790", },
+       { .compatible = "renesas,pci-r8a7791", },
+       { },
+};
+
+MODULE_DEVICE_TABLE(of, rcar_pci_of_match);
+
 static struct platform_driver rcar_pci_driver = {
        .driver = {
                .name = "pci-rcar-gen2",
                .owner = THIS_MODULE,
                .suppress_bind_attrs = true,
+               .of_match_table = rcar_pci_of_match,
        },
        .probe = rcar_pci_probe,
 };
index 330f7e3a32dd9f3694a09844106b551751235296..083cf37ca04752be2cdb5658255ac55df450fa78 100644 (file)
@@ -639,10 +639,15 @@ static int tegra_pcie_setup(int nr, struct pci_sys_data *sys)
 static int tegra_pcie_map_irq(const struct pci_dev *pdev, u8 slot, u8 pin)
 {
        struct tegra_pcie *pcie = sys_to_pcie(pdev->bus->sysdata);
+       int irq;
 
        tegra_cpuidle_pcie_irqs_in_use();
 
-       return pcie->irq;
+       irq = of_irq_parse_and_map_pci(pdev, slot, pin);
+       if (!irq)
+               irq = pcie->irq;
+
+       return irq;
 }
 
 static void tegra_pcie_add_bus(struct pci_bus *bus)
index 509a29d84509364b366ef1e130ed5ea37b40a091..1eaf4df3618a18a57e0eee175272d5a19646f2bf 100644 (file)
@@ -17,6 +17,7 @@
 #include <linux/module.h>
 #include <linux/msi.h>
 #include <linux/of_address.h>
+#include <linux/of_pci.h>
 #include <linux/pci.h>
 #include <linux/pci_regs.h>
 #include <linux/types.h>
@@ -155,15 +156,17 @@ static struct irq_chip dw_msi_irq_chip = {
 };
 
 /* MSI int handler */
-void dw_handle_msi_irq(struct pcie_port *pp)
+irqreturn_t dw_handle_msi_irq(struct pcie_port *pp)
 {
        unsigned long val;
        int i, pos, irq;
+       irqreturn_t ret = IRQ_NONE;
 
        for (i = 0; i < MAX_MSI_CTRLS; i++) {
                dw_pcie_rd_own_conf(pp, PCIE_MSI_INTR0_STATUS + i * 12, 4,
                                (u32 *)&val);
                if (val) {
+                       ret = IRQ_HANDLED;
                        pos = 0;
                        while ((pos = find_next_bit(&val, 32, pos)) != 32) {
                                irq = irq_find_mapping(pp->irq_domain,
@@ -176,6 +179,8 @@ void dw_handle_msi_irq(struct pcie_port *pp)
                        }
                }
        }
+
+       return ret;
 }
 
 void dw_pcie_msi_init(struct pcie_port *pp)
@@ -490,7 +495,7 @@ int __init dw_pcie_host_init(struct pcie_port *pp)
        dw_pci.nr_controllers = 1;
        dw_pci.private_data = (void **)&pp;
 
-       pci_common_init(&dw_pci);
+       pci_common_init_dev(pp->dev, &dw_pci);
        pci_assign_unassigned_resources();
 #ifdef CONFIG_PCI_DOMAINS
        dw_pci.domain++;
@@ -520,13 +525,13 @@ static void dw_pcie_prog_viewport_cfg1(struct pcie_port *pp, u32 busdev)
        dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
                          PCIE_ATU_VIEWPORT);
        dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_CFG1, PCIE_ATU_CR1);
-       dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
        dw_pcie_writel_rc(pp, pp->cfg1_base, PCIE_ATU_LOWER_BASE);
        dw_pcie_writel_rc(pp, (pp->cfg1_base >> 32), PCIE_ATU_UPPER_BASE);
        dw_pcie_writel_rc(pp, pp->cfg1_base + pp->config.cfg1_size - 1,
                          PCIE_ATU_LIMIT);
        dw_pcie_writel_rc(pp, busdev, PCIE_ATU_LOWER_TARGET);
        dw_pcie_writel_rc(pp, 0, PCIE_ATU_UPPER_TARGET);
+       dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
 }
 
 static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
@@ -535,7 +540,6 @@ static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
        dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX0,
                          PCIE_ATU_VIEWPORT);
        dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_MEM, PCIE_ATU_CR1);
-       dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
        dw_pcie_writel_rc(pp, pp->mem_base, PCIE_ATU_LOWER_BASE);
        dw_pcie_writel_rc(pp, (pp->mem_base >> 32), PCIE_ATU_UPPER_BASE);
        dw_pcie_writel_rc(pp, pp->mem_base + pp->config.mem_size - 1,
@@ -543,6 +547,7 @@ static void dw_pcie_prog_viewport_mem_outbound(struct pcie_port *pp)
        dw_pcie_writel_rc(pp, pp->config.mem_bus_addr, PCIE_ATU_LOWER_TARGET);
        dw_pcie_writel_rc(pp, upper_32_bits(pp->config.mem_bus_addr),
                          PCIE_ATU_UPPER_TARGET);
+       dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
 }
 
 static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
@@ -551,7 +556,6 @@ static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
        dw_pcie_writel_rc(pp, PCIE_ATU_REGION_OUTBOUND | PCIE_ATU_REGION_INDEX1,
                          PCIE_ATU_VIEWPORT);
        dw_pcie_writel_rc(pp, PCIE_ATU_TYPE_IO, PCIE_ATU_CR1);
-       dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
        dw_pcie_writel_rc(pp, pp->io_base, PCIE_ATU_LOWER_BASE);
        dw_pcie_writel_rc(pp, (pp->io_base >> 32), PCIE_ATU_UPPER_BASE);
        dw_pcie_writel_rc(pp, pp->io_base + pp->config.io_size - 1,
@@ -559,6 +563,7 @@ static void dw_pcie_prog_viewport_io_outbound(struct pcie_port *pp)
        dw_pcie_writel_rc(pp, pp->config.io_bus_addr, PCIE_ATU_LOWER_TARGET);
        dw_pcie_writel_rc(pp, upper_32_bits(pp->config.io_bus_addr),
                          PCIE_ATU_UPPER_TARGET);
+       dw_pcie_writel_rc(pp, PCIE_ATU_ENABLE, PCIE_ATU_CR2);
 }
 
 static int dw_pcie_rd_other_conf(struct pcie_port *pp, struct pci_bus *bus,
@@ -638,7 +643,6 @@ static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
                        int size, u32 *val)
 {
        struct pcie_port *pp = sys_to_pcie(bus->sysdata);
-       unsigned long flags;
        int ret;
 
        if (!pp) {
@@ -651,13 +655,11 @@ static int dw_pcie_rd_conf(struct pci_bus *bus, u32 devfn, int where,
                return PCIBIOS_DEVICE_NOT_FOUND;
        }
 
-       spin_lock_irqsave(&pp->conf_lock, flags);
        if (bus->number != pp->root_bus_nr)
                ret = dw_pcie_rd_other_conf(pp, bus, devfn,
                                                where, size, val);
        else
                ret = dw_pcie_rd_own_conf(pp, where, size, val);
-       spin_unlock_irqrestore(&pp->conf_lock, flags);
 
        return ret;
 }
@@ -666,7 +668,6 @@ static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
                        int where, int size, u32 val)
 {
        struct pcie_port *pp = sys_to_pcie(bus->sysdata);
-       unsigned long flags;
        int ret;
 
        if (!pp) {
@@ -677,13 +678,11 @@ static int dw_pcie_wr_conf(struct pci_bus *bus, u32 devfn,
        if (dw_pcie_valid_config(pp, bus, PCI_SLOT(devfn)) == 0)
                return PCIBIOS_DEVICE_NOT_FOUND;
 
-       spin_lock_irqsave(&pp->conf_lock, flags);
        if (bus->number != pp->root_bus_nr)
                ret = dw_pcie_wr_other_conf(pp, bus, devfn,
                                                where, size, val);
        else
                ret = dw_pcie_wr_own_conf(pp, where, size, val);
-       spin_unlock_irqrestore(&pp->conf_lock, flags);
 
        return ret;
 }
@@ -723,7 +722,7 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 
        if (pp) {
                pp->root_bus_nr = sys->busnr;
-               bus = pci_scan_root_bus(NULL, sys->busnr, &dw_pcie_ops,
+               bus = pci_scan_root_bus(pp->dev, sys->busnr, &dw_pcie_ops,
                                        sys, &sys->resources);
        } else {
                bus = NULL;
@@ -736,8 +735,13 @@ static struct pci_bus *dw_pcie_scan_bus(int nr, struct pci_sys_data *sys)
 static int dw_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
 {
        struct pcie_port *pp = sys_to_pcie(dev->bus->sysdata);
+       int irq;
 
-       return pp->irq;
+       irq = of_irq_parse_and_map_pci(dev, slot, pin);
+       if (!irq)
+               irq = pp->irq;
+
+       return irq;
 }
 
 static void dw_pcie_add_bus(struct pci_bus *bus)
@@ -764,7 +768,7 @@ void dw_pcie_setup_rc(struct pcie_port *pp)
        u32 membase;
        u32 memlimit;
 
-       /* set the number of lines as 4 */
+       /* set the number of lanes */
        dw_pcie_readl_rc(pp, PCIE_PORT_LINK_CONTROL, &val);
        val &= ~PORT_LINK_MODE_MASK;
        switch (pp->lanes) {
index 3063b3594d8875c9f38b76780045e640ddc61e4a..77f592faa7bf28ee6d86f84cad6ee7cdfd345158 100644 (file)
@@ -41,7 +41,6 @@ struct pcie_port {
        void __iomem            *va_cfg1_base;
        u64                     io_base;
        u64                     mem_base;
-       spinlock_t              conf_lock;
        struct resource         cfg;
        struct resource         io;
        struct resource         mem;
@@ -68,7 +67,7 @@ struct pcie_host_ops {
 
 int dw_pcie_cfg_read(void __iomem *addr, int where, int size, u32 *val);
 int dw_pcie_cfg_write(void __iomem *addr, int where, int size, u32 val);
-void dw_handle_msi_irq(struct pcie_port *pp);
+irqreturn_t dw_handle_msi_irq(struct pcie_port *pp);
 void dw_pcie_msi_init(struct pcie_port *pp);
 int dw_pcie_link_up(struct pcie_port *pp);
 void dw_pcie_setup_rc(struct pcie_port *pp);
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c
new file mode 100644 (file)
index 0000000..f7d3de3
--- /dev/null
@@ -0,0 +1,1006 @@
+/*
+ * PCIe driver for Renesas R-Car SoCs
+ *  Copyright (C) 2014 Renesas Electronics Europe Ltd
+ *
+ * Based on:
+ *  arch/sh/drivers/pci/pcie-sh7786.c
+ *  arch/sh/drivers/pci/ops-sh7786.c
+ *  Copyright (C) 2009 - 2011  Paul Mundt
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ */
+
+#include <linux/clk.h>
+#include <linux/delay.h>
+#include <linux/interrupt.h>
+#include <linux/irq.h>
+#include <linux/irqdomain.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/msi.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/of_pci.h>
+#include <linux/of_platform.h>
+#include <linux/pci.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+
+#define DRV_NAME "rcar-pcie"
+
+#define PCIECAR                        0x000010
+#define PCIECCTLR              0x000018
+#define  CONFIG_SEND_ENABLE    (1 << 31)
+#define  TYPE0                 (0 << 8)
+#define  TYPE1                 (1 << 8)
+#define PCIECDR                        0x000020
+#define PCIEMSR                        0x000028
+#define PCIEINTXR              0x000400
+#define PCIEMSITXR             0x000840
+
+/* Transfer control */
+#define PCIETCTLR              0x02000
+#define  CFINIT                        1
+#define PCIETSTR               0x02004
+#define  DATA_LINK_ACTIVE      1
+#define PCIEERRFR              0x02020
+#define  UNSUPPORTED_REQUEST   (1 << 4)
+#define PCIEMSIFR              0x02044
+#define PCIEMSIALR             0x02048
+#define  MSIFE                 1
+#define PCIEMSIAUR             0x0204c
+#define PCIEMSIIER             0x02050
+
+/* root port address */
+#define PCIEPRAR(x)            (0x02080 + ((x) * 0x4))
+
+/* local address reg & mask */
+#define PCIELAR(x)             (0x02200 + ((x) * 0x20))
+#define PCIELAMR(x)            (0x02208 + ((x) * 0x20))
+#define  LAM_PREFETCH          (1 << 3)
+#define  LAM_64BIT             (1 << 2)
+#define  LAR_ENABLE            (1 << 1)
+
+/* PCIe address reg & mask */
+#define PCIEPARL(x)            (0x03400 + ((x) * 0x20))
+#define PCIEPARH(x)            (0x03404 + ((x) * 0x20))
+#define PCIEPAMR(x)            (0x03408 + ((x) * 0x20))
+#define PCIEPTCTLR(x)          (0x0340c + ((x) * 0x20))
+#define  PAR_ENABLE            (1 << 31)
+#define  IO_SPACE              (1 << 8)
+
+/* Configuration */
+#define PCICONF(x)             (0x010000 + ((x) * 0x4))
+#define PMCAP(x)               (0x010040 + ((x) * 0x4))
+#define EXPCAP(x)              (0x010070 + ((x) * 0x4))
+#define VCCAP(x)               (0x010100 + ((x) * 0x4))
+
+/* link layer */
+#define IDSETR1                        0x011004
+#define TLCTLR                 0x011048
+#define MACSR                  0x011054
+#define MACCTLR                        0x011058
+#define  SCRAMBLE_DISABLE      (1 << 27)
+
+/* R-Car H1 PHY */
+#define H1_PCIEPHYADRR         0x04000c
+#define  WRITE_CMD             (1 << 16)
+#define  PHY_ACK               (1 << 24)
+#define  RATE_POS              12
+#define  LANE_POS              8
+#define  ADR_POS               0
+#define H1_PCIEPHYDOUTR                0x040014
+#define H1_PCIEPHYSR           0x040018
+
+#define INT_PCI_MSI_NR 32
+
+#define RCONF(x)       (PCICONF(0)+(x))
+#define RPMCAP(x)      (PMCAP(0)+(x))
+#define REXPCAP(x)     (EXPCAP(0)+(x))
+#define RVCCAP(x)      (VCCAP(0)+(x))
+
+#define  PCIE_CONF_BUS(b)      (((b) & 0xff) << 24)
+#define  PCIE_CONF_DEV(d)      (((d) & 0x1f) << 19)
+#define  PCIE_CONF_FUNC(f)     (((f) & 0x7) << 16)
+
+#define PCI_MAX_RESOURCES 4
+#define MAX_NR_INBOUND_MAPS 6
+
+struct rcar_msi {
+       DECLARE_BITMAP(used, INT_PCI_MSI_NR);
+       struct irq_domain *domain;
+       struct msi_chip chip;
+       unsigned long pages;
+       struct mutex lock;
+       int irq1;
+       int irq2;
+};
+
+static inline struct rcar_msi *to_rcar_msi(struct msi_chip *chip)
+{
+       return container_of(chip, struct rcar_msi, chip);
+}
+
+/* Structure representing the PCIe interface */
+struct rcar_pcie {
+       struct device           *dev;
+       void __iomem            *base;
+       struct resource         res[PCI_MAX_RESOURCES];
+       struct resource         busn;
+       int                     root_bus_nr;
+       struct clk              *clk;
+       struct clk              *bus_clk;
+       struct                  rcar_msi msi;
+};
+
+static inline struct rcar_pcie *sys_to_pcie(struct pci_sys_data *sys)
+{
+       return sys->private_data;
+}
+
+static void pci_write_reg(struct rcar_pcie *pcie, unsigned long val,
+                         unsigned long reg)
+{
+       writel(val, pcie->base + reg);
+}
+
+static unsigned long pci_read_reg(struct rcar_pcie *pcie, unsigned long reg)
+{
+       return readl(pcie->base + reg);
+}
+
+enum {
+       PCI_ACCESS_READ,
+       PCI_ACCESS_WRITE,
+};
+
+static void rcar_rmw32(struct rcar_pcie *pcie, int where, u32 mask, u32 data)
+{
+       int shift = 8 * (where & 3);
+       u32 val = pci_read_reg(pcie, where & ~3);
+
+       val &= ~(mask << shift);
+       val |= data << shift;
+       pci_write_reg(pcie, val, where & ~3);
+}
+
+static u32 rcar_read_conf(struct rcar_pcie *pcie, int where)
+{
+       int shift = 8 * (where & 3);
+       u32 val = pci_read_reg(pcie, where & ~3);
+
+       return val >> shift;
+}
+
+/* Serialization is provided by 'pci_lock' in drivers/pci/access.c */
+static int rcar_pcie_config_access(struct rcar_pcie *pcie,
+               unsigned char access_type, struct pci_bus *bus,
+               unsigned int devfn, int where, u32 *data)
+{
+       int dev, func, reg, index;
+
+       dev = PCI_SLOT(devfn);
+       func = PCI_FUNC(devfn);
+       reg = where & ~3;
+       index = reg / 4;
+
+       /*
+        * While each channel has its own memory-mapped extended config
+        * space, it's generally only accessible when in endpoint mode.
+        * When in root complex mode, the controller is unable to target
+        * itself with either type 0 or type 1 accesses, and indeed, any
+        * controller initiated target transfer to its own config space
+        * result in a completer abort.
+        *
+        * Each channel effectively only supports a single device, but as
+        * the same channel <-> device access works for any PCI_SLOT()
+        * value, we cheat a bit here and bind the controller's config
+        * space to devfn 0 in order to enable self-enumeration. In this
+        * case the regular ECAR/ECDR path is sidelined and the mangled
+        * config access itself is initiated as an internal bus transaction.
+        */
+       if (pci_is_root_bus(bus)) {
+               if (dev != 0)
+                       return PCIBIOS_DEVICE_NOT_FOUND;
+
+               if (access_type == PCI_ACCESS_READ) {
+                       *data = pci_read_reg(pcie, PCICONF(index));
+               } else {
+                       /* Keep an eye out for changes to the root bus number */
+                       if (pci_is_root_bus(bus) && (reg == PCI_PRIMARY_BUS))
+                               pcie->root_bus_nr = *data & 0xff;
+
+                       pci_write_reg(pcie, *data, PCICONF(index));
+               }
+
+               return PCIBIOS_SUCCESSFUL;
+       }
+
+       if (pcie->root_bus_nr < 0)
+               return PCIBIOS_DEVICE_NOT_FOUND;
+
+       /* Clear errors */
+       pci_write_reg(pcie, pci_read_reg(pcie, PCIEERRFR), PCIEERRFR);
+
+       /* Set the PIO address */
+       pci_write_reg(pcie, PCIE_CONF_BUS(bus->number) | PCIE_CONF_DEV(dev) |
+                               PCIE_CONF_FUNC(func) | reg, PCIECAR);
+
+       /* Enable the configuration access */
+       if (bus->parent->number == pcie->root_bus_nr)
+               pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE0, PCIECCTLR);
+       else
+               pci_write_reg(pcie, CONFIG_SEND_ENABLE | TYPE1, PCIECCTLR);
+
+       /* Check for errors */
+       if (pci_read_reg(pcie, PCIEERRFR) & UNSUPPORTED_REQUEST)
+               return PCIBIOS_DEVICE_NOT_FOUND;
+
+       /* Check for master and target aborts */
+       if (rcar_read_conf(pcie, RCONF(PCI_STATUS)) &
+               (PCI_STATUS_REC_MASTER_ABORT | PCI_STATUS_REC_TARGET_ABORT))
+               return PCIBIOS_DEVICE_NOT_FOUND;
+
+       if (access_type == PCI_ACCESS_READ)
+               *data = pci_read_reg(pcie, PCIECDR);
+       else
+               pci_write_reg(pcie, *data, PCIECDR);
+
+       /* Disable the configuration access */
+       pci_write_reg(pcie, 0, PCIECCTLR);
+
+       return PCIBIOS_SUCCESSFUL;
+}
+
+static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn,
+                              int where, int size, u32 *val)
+{
+       struct rcar_pcie *pcie = sys_to_pcie(bus->sysdata);
+       int ret;
+
+       if ((size == 2) && (where & 1))
+               return PCIBIOS_BAD_REGISTER_NUMBER;
+       else if ((size == 4) && (where & 3))
+               return PCIBIOS_BAD_REGISTER_NUMBER;
+
+       ret = rcar_pcie_config_access(pcie, PCI_ACCESS_READ,
+                                     bus, devfn, where, val);
+       if (ret != PCIBIOS_SUCCESSFUL) {
+               *val = 0xffffffff;
+               return ret;
+       }
+
+       if (size == 1)
+               *val = (*val >> (8 * (where & 3))) & 0xff;
+       else if (size == 2)
+               *val = (*val >> (8 * (where & 2))) & 0xffff;
+
+       dev_dbg(&bus->dev, "pcie-config-read: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08lx\n",
+               bus->number, devfn, where, size, (unsigned long)*val);
+
+       return ret;
+}
+
+/* Serialization is provided by 'pci_lock' in drivers/pci/access.c */
+static int rcar_pcie_write_conf(struct pci_bus *bus, unsigned int devfn,
+                               int where, int size, u32 val)
+{
+       struct rcar_pcie *pcie = sys_to_pcie(bus->sysdata);
+       int shift, ret;
+       u32 data;
+
+       if ((size == 2) && (where & 1))
+               return PCIBIOS_BAD_REGISTER_NUMBER;
+       else if ((size == 4) && (where & 3))
+               return PCIBIOS_BAD_REGISTER_NUMBER;
+
+       ret = rcar_pcie_config_access(pcie, PCI_ACCESS_READ,
+                                     bus, devfn, where, &data);
+       if (ret != PCIBIOS_SUCCESSFUL)
+               return ret;
+
+       dev_dbg(&bus->dev, "pcie-config-write: bus=%3d devfn=0x%04x where=0x%04x size=%d val=0x%08lx\n",
+               bus->number, devfn, where, size, (unsigned long)val);
+
+       if (size == 1) {
+               shift = 8 * (where & 3);
+               data &= ~(0xff << shift);
+               data |= ((val & 0xff) << shift);
+       } else if (size == 2) {
+               shift = 8 * (where & 2);
+               data &= ~(0xffff << shift);
+               data |= ((val & 0xffff) << shift);
+       } else
+               data = val;
+
+       ret = rcar_pcie_config_access(pcie, PCI_ACCESS_WRITE,
+                                     bus, devfn, where, &data);
+
+       return ret;
+}
+
+static struct pci_ops rcar_pcie_ops = {
+       .read   = rcar_pcie_read_conf,
+       .write  = rcar_pcie_write_conf,
+};
+
+static void rcar_pcie_setup_window(int win, struct resource *res,
+                                  struct rcar_pcie *pcie)
+{
+       /* Setup PCIe address space mappings for each resource */
+       resource_size_t size;
+       u32 mask;
+
+       pci_write_reg(pcie, 0x00000000, PCIEPTCTLR(win));
+
+       /*
+        * The PAMR mask is calculated in units of 128Bytes, which
+        * keeps things pretty simple.
+        */
+       size = resource_size(res);
+       mask = (roundup_pow_of_two(size) / SZ_128) - 1;
+       pci_write_reg(pcie, mask << 7, PCIEPAMR(win));
+
+       pci_write_reg(pcie, upper_32_bits(res->start), PCIEPARH(win));
+       pci_write_reg(pcie, lower_32_bits(res->start), PCIEPARL(win));
+
+       /* First resource is for IO */
+       mask = PAR_ENABLE;
+       if (res->flags & IORESOURCE_IO)
+               mask |= IO_SPACE;
+
+       pci_write_reg(pcie, mask, PCIEPTCTLR(win));
+}
+
+static int rcar_pcie_setup(int nr, struct pci_sys_data *sys)
+{
+       struct rcar_pcie *pcie = sys_to_pcie(sys);
+       struct resource *res;
+       int i;
+
+       pcie->root_bus_nr = -1;
+
+       /* Setup PCI resources */
+       for (i = 0; i < PCI_MAX_RESOURCES; i++) {
+
+               res = &pcie->res[i];
+               if (!res->flags)
+                       continue;
+
+               rcar_pcie_setup_window(i, res, pcie);
+
+               if (res->flags & IORESOURCE_IO)
+                       pci_ioremap_io(nr * SZ_64K, res->start);
+               else
+                       pci_add_resource(&sys->resources, res);
+       }
+       pci_add_resource(&sys->resources, &pcie->busn);
+
+       return 1;
+}
+
+static void rcar_pcie_add_bus(struct pci_bus *bus)
+{
+       if (IS_ENABLED(CONFIG_PCI_MSI)) {
+               struct rcar_pcie *pcie = sys_to_pcie(bus->sysdata);
+
+               bus->msi = &pcie->msi.chip;
+       }
+}
+
+struct hw_pci rcar_pci = {
+       .setup          = rcar_pcie_setup,
+       .map_irq        = of_irq_parse_and_map_pci,
+       .ops            = &rcar_pcie_ops,
+       .add_bus        = rcar_pcie_add_bus,
+};
+
+static void rcar_pcie_enable(struct rcar_pcie *pcie)
+{
+       struct platform_device *pdev = to_platform_device(pcie->dev);
+
+       rcar_pci.nr_controllers = 1;
+       rcar_pci.private_data = (void **)&pcie;
+
+       pci_common_init_dev(&pdev->dev, &rcar_pci);
+#ifdef CONFIG_PCI_DOMAINS
+       rcar_pci.domain++;
+#endif
+}
+
+static int phy_wait_for_ack(struct rcar_pcie *pcie)
+{
+       unsigned int timeout = 100;
+
+       while (timeout--) {
+               if (pci_read_reg(pcie, H1_PCIEPHYADRR) & PHY_ACK)
+                       return 0;
+
+               udelay(100);
+       }
+
+       dev_err(pcie->dev, "Access to PCIe phy timed out\n");
+
+       return -ETIMEDOUT;
+}
+
+static void phy_write_reg(struct rcar_pcie *pcie,
+                                unsigned int rate, unsigned int addr,
+                                unsigned int lane, unsigned int data)
+{
+       unsigned long phyaddr;
+
+       phyaddr = WRITE_CMD |
+               ((rate & 1) << RATE_POS) |
+               ((lane & 0xf) << LANE_POS) |
+               ((addr & 0xff) << ADR_POS);
+
+       /* Set write data */
+       pci_write_reg(pcie, data, H1_PCIEPHYDOUTR);
+       pci_write_reg(pcie, phyaddr, H1_PCIEPHYADRR);
+
+       /* Ignore errors as they will be dealt with if the data link is down */
+       phy_wait_for_ack(pcie);
+
+       /* Clear command */
+       pci_write_reg(pcie, 0, H1_PCIEPHYDOUTR);
+       pci_write_reg(pcie, 0, H1_PCIEPHYADRR);
+
+       /* Ignore errors as they will be dealt with if the data link is down */
+       phy_wait_for_ack(pcie);
+}
+
+static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie)
+{
+       unsigned int timeout = 10;
+
+       while (timeout--) {
+               if ((pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE))
+                       return 0;
+
+               msleep(5);
+       }
+
+       return -ETIMEDOUT;
+}
+
+static int rcar_pcie_hw_init(struct rcar_pcie *pcie)
+{
+       int err;
+
+       /* Begin initialization */
+       pci_write_reg(pcie, 0, PCIETCTLR);
+
+       /* Set mode */
+       pci_write_reg(pcie, 1, PCIEMSR);
+
+       /*
+        * Initial header for port config space is type 1, set the device
+        * class to match. Hardware takes care of propagating the IDSETR
+        * settings, so there is no need to bother with a quirk.
+        */
+       pci_write_reg(pcie, PCI_CLASS_BRIDGE_PCI << 16, IDSETR1);
+
+       /*
+        * Setup Secondary Bus Number & Subordinate Bus Number, even though
+        * they aren't used, to avoid bridge being detected as broken.
+        */
+       rcar_rmw32(pcie, RCONF(PCI_SECONDARY_BUS), 0xff, 1);
+       rcar_rmw32(pcie, RCONF(PCI_SUBORDINATE_BUS), 0xff, 1);
+
+       /* Initialize default capabilities. */
+       rcar_rmw32(pcie, REXPCAP(0), 0, PCI_CAP_ID_EXP);
+       rcar_rmw32(pcie, REXPCAP(PCI_EXP_FLAGS),
+               PCI_EXP_FLAGS_TYPE, PCI_EXP_TYPE_ROOT_PORT << 4);
+       rcar_rmw32(pcie, RCONF(PCI_HEADER_TYPE), 0x7f,
+               PCI_HEADER_TYPE_BRIDGE);
+
+       /* Enable data link layer active state reporting */
+       rcar_rmw32(pcie, REXPCAP(PCI_EXP_LNKCAP), 0, PCI_EXP_LNKCAP_DLLLARC);
+
+       /* Write out the physical slot number = 0 */
+       rcar_rmw32(pcie, REXPCAP(PCI_EXP_SLTCAP), PCI_EXP_SLTCAP_PSN, 0);
+
+       /* Set the completion timer timeout to the maximum 50ms. */
+       rcar_rmw32(pcie, TLCTLR+1, 0x3f, 50);
+
+       /* Terminate list of capabilities (Next Capability Offset=0) */
+       rcar_rmw32(pcie, RVCCAP(0), 0xfff0, 0);
+
+       /* Enable MAC data scrambling. */
+       rcar_rmw32(pcie, MACCTLR, SCRAMBLE_DISABLE, 0);
+
+       /* Enable MSI */
+       if (IS_ENABLED(CONFIG_PCI_MSI))
+               pci_write_reg(pcie, 0x101f0000, PCIEMSITXR);
+
+       /* Finish initialization - establish a PCI Express link */
+       pci_write_reg(pcie, CFINIT, PCIETCTLR);
+
+       /* This will timeout if we don't have a link. */
+       err = rcar_pcie_wait_for_dl(pcie);
+       if (err)
+               return err;
+
+       /* Enable INTx interrupts */
+       rcar_rmw32(pcie, PCIEINTXR, 0, 0xF << 8);
+
+       /* Enable slave Bus Mastering */
+       rcar_rmw32(pcie, RCONF(PCI_STATUS), PCI_STATUS_DEVSEL_MASK,
+               PCI_COMMAND_IO | PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER |
+               PCI_STATUS_CAP_LIST | PCI_STATUS_DEVSEL_FAST);
+
+       wmb();
+
+       return 0;
+}
+
+static int rcar_pcie_hw_init_h1(struct rcar_pcie *pcie)
+{
+       unsigned int timeout = 10;
+
+       /* Initialize the phy */
+       phy_write_reg(pcie, 0, 0x42, 0x1, 0x0EC34191);
+       phy_write_reg(pcie, 1, 0x42, 0x1, 0x0EC34180);
+       phy_write_reg(pcie, 0, 0x43, 0x1, 0x00210188);
+       phy_write_reg(pcie, 1, 0x43, 0x1, 0x00210188);
+       phy_write_reg(pcie, 0, 0x44, 0x1, 0x015C0014);
+       phy_write_reg(pcie, 1, 0x44, 0x1, 0x015C0014);
+       phy_write_reg(pcie, 1, 0x4C, 0x1, 0x786174A0);
+       phy_write_reg(pcie, 1, 0x4D, 0x1, 0x048000BB);
+       phy_write_reg(pcie, 0, 0x51, 0x1, 0x079EC062);
+       phy_write_reg(pcie, 0, 0x52, 0x1, 0x20000000);
+       phy_write_reg(pcie, 1, 0x52, 0x1, 0x20000000);
+       phy_write_reg(pcie, 1, 0x56, 0x1, 0x00003806);
+
+       phy_write_reg(pcie, 0, 0x60, 0x1, 0x004B03A5);
+       phy_write_reg(pcie, 0, 0x64, 0x1, 0x3F0F1F0F);
+       phy_write_reg(pcie, 0, 0x66, 0x1, 0x00008000);
+
+       while (timeout--) {
+               if (pci_read_reg(pcie, H1_PCIEPHYSR))
+                       return rcar_pcie_hw_init(pcie);
+
+               msleep(5);
+       }
+
+       return -ETIMEDOUT;
+}
+
+static int rcar_msi_alloc(struct rcar_msi *chip)
+{
+       int msi;
+
+       mutex_lock(&chip->lock);
+
+       msi = find_first_zero_bit(chip->used, INT_PCI_MSI_NR);
+       if (msi < INT_PCI_MSI_NR)
+               set_bit(msi, chip->used);
+       else
+               msi = -ENOSPC;
+
+       mutex_unlock(&chip->lock);
+
+       return msi;
+}
+
+static void rcar_msi_free(struct rcar_msi *chip, unsigned long irq)
+{
+       mutex_lock(&chip->lock);
+       clear_bit(irq, chip->used);
+       mutex_unlock(&chip->lock);
+}
+
+static irqreturn_t rcar_pcie_msi_irq(int irq, void *data)
+{
+       struct rcar_pcie *pcie = data;
+       struct rcar_msi *msi = &pcie->msi;
+       unsigned long reg;
+
+       reg = pci_read_reg(pcie, PCIEMSIFR);
+
+       /* MSI & INTx share an interrupt - we only handle MSI here */
+       if (!reg)
+               return IRQ_NONE;
+
+       while (reg) {
+               unsigned int index = find_first_bit(&reg, 32);
+               unsigned int irq;
+
+               /* clear the interrupt */
+               pci_write_reg(pcie, 1 << index, PCIEMSIFR);
+
+               irq = irq_find_mapping(msi->domain, index);
+               if (irq) {
+                       if (test_bit(index, msi->used))
+                               generic_handle_irq(irq);
+                       else
+                               dev_info(pcie->dev, "unhandled MSI\n");
+               } else {
+                       /* Unknown MSI, just clear it */
+                       dev_dbg(pcie->dev, "unexpected MSI\n");
+               }
+
+               /* see if there's any more pending in this vector */
+               reg = pci_read_reg(pcie, PCIEMSIFR);
+       }
+
+       return IRQ_HANDLED;
+}
+
+static int rcar_msi_setup_irq(struct msi_chip *chip, struct pci_dev *pdev,
+                             struct msi_desc *desc)
+{
+       struct rcar_msi *msi = to_rcar_msi(chip);
+       struct rcar_pcie *pcie = container_of(chip, struct rcar_pcie, msi.chip);
+       struct msi_msg msg;
+       unsigned int irq;
+       int hwirq;
+
+       hwirq = rcar_msi_alloc(msi);
+       if (hwirq < 0)
+               return hwirq;
+
+       irq = irq_create_mapping(msi->domain, hwirq);
+       if (!irq) {
+               rcar_msi_free(msi, hwirq);
+               return -EINVAL;
+       }
+
+       irq_set_msi_desc(irq, desc);
+
+       msg.address_lo = pci_read_reg(pcie, PCIEMSIALR) & ~MSIFE;
+       msg.address_hi = pci_read_reg(pcie, PCIEMSIAUR);
+       msg.data = hwirq;
+
+       write_msi_msg(irq, &msg);
+
+       return 0;
+}
+
+static void rcar_msi_teardown_irq(struct msi_chip *chip, unsigned int irq)
+{
+       struct rcar_msi *msi = to_rcar_msi(chip);
+       struct irq_data *d = irq_get_irq_data(irq);
+
+       rcar_msi_free(msi, d->hwirq);
+}
+
+static struct irq_chip rcar_msi_irq_chip = {
+       .name = "R-Car PCIe MSI",
+       .irq_enable = unmask_msi_irq,
+       .irq_disable = mask_msi_irq,
+       .irq_mask = mask_msi_irq,
+       .irq_unmask = unmask_msi_irq,
+};
+
+static int rcar_msi_map(struct irq_domain *domain, unsigned int irq,
+                       irq_hw_number_t hwirq)
+{
+       irq_set_chip_and_handler(irq, &rcar_msi_irq_chip, handle_simple_irq);
+       irq_set_chip_data(irq, domain->host_data);
+       set_irq_flags(irq, IRQF_VALID);
+
+       return 0;
+}
+
+static const struct irq_domain_ops msi_domain_ops = {
+       .map = rcar_msi_map,
+};
+
+static int rcar_pcie_enable_msi(struct rcar_pcie *pcie)
+{
+       struct platform_device *pdev = to_platform_device(pcie->dev);
+       struct rcar_msi *msi = &pcie->msi;
+       unsigned long base;
+       int err;
+
+       mutex_init(&msi->lock);
+
+       msi->chip.dev = pcie->dev;
+       msi->chip.setup_irq = rcar_msi_setup_irq;
+       msi->chip.teardown_irq = rcar_msi_teardown_irq;
+
+       msi->domain = irq_domain_add_linear(pcie->dev->of_node, INT_PCI_MSI_NR,
+                                           &msi_domain_ops, &msi->chip);
+       if (!msi->domain) {
+               dev_err(&pdev->dev, "failed to create IRQ domain\n");
+               return -ENOMEM;
+       }
+
+       /* Two irqs are for MSI, but they are also used for non-MSI irqs */
+       err = devm_request_irq(&pdev->dev, msi->irq1, rcar_pcie_msi_irq,
+                              IRQF_SHARED, rcar_msi_irq_chip.name, pcie);
+       if (err < 0) {
+               dev_err(&pdev->dev, "failed to request IRQ: %d\n", err);
+               goto err;
+       }
+
+       err = devm_request_irq(&pdev->dev, msi->irq2, rcar_pcie_msi_irq,
+                              IRQF_SHARED, rcar_msi_irq_chip.name, pcie);
+       if (err < 0) {
+               dev_err(&pdev->dev, "failed to request IRQ: %d\n", err);
+               goto err;
+       }
+
+       /* setup MSI data target */
+       msi->pages = __get_free_pages(GFP_KERNEL, 0);
+       base = virt_to_phys((void *)msi->pages);
+
+       pci_write_reg(pcie, base | MSIFE, PCIEMSIALR);
+       pci_write_reg(pcie, 0, PCIEMSIAUR);
+
+       /* enable all MSI interrupts */
+       pci_write_reg(pcie, 0xffffffff, PCIEMSIIER);
+
+       return 0;
+
+err:
+       irq_domain_remove(msi->domain);
+       return err;
+}
+
+static int rcar_pcie_get_resources(struct platform_device *pdev,
+                                  struct rcar_pcie *pcie)
+{
+       struct resource res;
+       int err, i;
+
+       err = of_address_to_resource(pdev->dev.of_node, 0, &res);
+       if (err)
+               return err;
+
+       pcie->clk = devm_clk_get(&pdev->dev, "pcie");
+       if (IS_ERR(pcie->clk)) {
+               dev_err(pcie->dev, "cannot get platform clock\n");
+               return PTR_ERR(pcie->clk);
+       }
+       err = clk_prepare_enable(pcie->clk);
+       if (err)
+               goto fail_clk;
+
+       pcie->bus_clk = devm_clk_get(&pdev->dev, "pcie_bus");
+       if (IS_ERR(pcie->bus_clk)) {
+               dev_err(pcie->dev, "cannot get pcie bus clock\n");
+               err = PTR_ERR(pcie->bus_clk);
+               goto fail_clk;
+       }
+       err = clk_prepare_enable(pcie->bus_clk);
+       if (err)
+               goto err_map_reg;
+
+       i = irq_of_parse_and_map(pdev->dev.of_node, 0);
+       if (i < 0) {
+               dev_err(pcie->dev, "cannot get platform resources for msi interrupt\n");
+               err = -ENOENT;
+               goto err_map_reg;
+       }
+       pcie->msi.irq1 = i;
+
+       i = irq_of_parse_and_map(pdev->dev.of_node, 1);
+       if (i < 0) {
+               dev_err(pcie->dev, "cannot get platform resources for msi interrupt\n");
+               err = -ENOENT;
+               goto err_map_reg;
+       }
+       pcie->msi.irq2 = i;
+
+       pcie->base = devm_ioremap_resource(&pdev->dev, &res);
+       if (IS_ERR(pcie->base)) {
+               err = PTR_ERR(pcie->base);
+               goto err_map_reg;
+       }
+
+       return 0;
+
+err_map_reg:
+       clk_disable_unprepare(pcie->bus_clk);
+fail_clk:
+       clk_disable_unprepare(pcie->clk);
+
+       return err;
+}
+
+static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie,
+                                   struct of_pci_range *range,
+                                   int *index)
+{
+       u64 restype = range->flags;
+       u64 cpu_addr = range->cpu_addr;
+       u64 cpu_end = range->cpu_addr + range->size;
+       u64 pci_addr = range->pci_addr;
+       u32 flags = LAM_64BIT | LAR_ENABLE;
+       u64 mask;
+       u64 size;
+       int idx = *index;
+
+       if (restype & IORESOURCE_PREFETCH)
+               flags |= LAM_PREFETCH;
+
+       /*
+        * If the size of the range is larger than the alignment of the start
+        * address, we have to use multiple entries to perform the mapping.
+        */
+       if (cpu_addr > 0) {
+               unsigned long nr_zeros = __ffs64(cpu_addr);
+               u64 alignment = 1ULL << nr_zeros;
+               size = min(range->size, alignment);
+       } else {
+               size = range->size;
+       }
+       /* Hardware supports max 4GiB inbound region */
+       size = min(size, 1ULL << 32);
+
+       mask = roundup_pow_of_two(size) - 1;
+       mask &= ~0xf;
+
+       while (cpu_addr < cpu_end) {
+               /*
+                * Set up 64-bit inbound regions as the range parser doesn't
+                * distinguish between 32 and 64-bit types.
+                */
+               pci_write_reg(pcie, lower_32_bits(pci_addr), PCIEPRAR(idx));
+               pci_write_reg(pcie, lower_32_bits(cpu_addr), PCIELAR(idx));
+               pci_write_reg(pcie, lower_32_bits(mask) | flags, PCIELAMR(idx));
+
+               pci_write_reg(pcie, upper_32_bits(pci_addr), PCIEPRAR(idx+1));
+               pci_write_reg(pcie, upper_32_bits(cpu_addr), PCIELAR(idx+1));
+               pci_write_reg(pcie, 0, PCIELAMR(idx+1));
+
+               pci_addr += size;
+               cpu_addr += size;
+               idx += 2;
+
+               if (idx > MAX_NR_INBOUND_MAPS) {
+                       dev_err(pcie->dev, "Failed to map inbound regions!\n");
+                       return -EINVAL;
+               }
+       }
+       *index = idx;
+
+       return 0;
+}
+
+static int pci_dma_range_parser_init(struct of_pci_range_parser *parser,
+                                    struct device_node *node)
+{
+       const int na = 3, ns = 2;
+       int rlen;
+
+       parser->node = node;
+       parser->pna = of_n_addr_cells(node);
+       parser->np = parser->pna + na + ns;
+
+       parser->range = of_get_property(node, "dma-ranges", &rlen);
+       if (!parser->range)
+               return -ENOENT;
+
+       parser->end = parser->range + rlen / sizeof(__be32);
+       return 0;
+}
+
+static int rcar_pcie_parse_map_dma_ranges(struct rcar_pcie *pcie,
+                                         struct device_node *np)
+{
+       struct of_pci_range range;
+       struct of_pci_range_parser parser;
+       int index = 0;
+       int err;
+
+       if (pci_dma_range_parser_init(&parser, np))
+               return -EINVAL;
+
+       /* Get the dma-ranges from DT */
+       for_each_of_pci_range(&parser, &range) {
+               u64 end = range.cpu_addr + range.size - 1;
+               dev_dbg(pcie->dev, "0x%08x 0x%016llx..0x%016llx -> 0x%016llx\n",
+                       range.flags, range.cpu_addr, end, range.pci_addr);
+
+               err = rcar_pcie_inbound_ranges(pcie, &range, &index);
+               if (err)
+                       return err;
+       }
+
+       return 0;
+}
+
+static const struct of_device_id rcar_pcie_of_match[] = {
+       { .compatible = "renesas,pcie-r8a7779", .data = rcar_pcie_hw_init_h1 },
+       { .compatible = "renesas,pcie-r8a7790", .data = rcar_pcie_hw_init },
+       { .compatible = "renesas,pcie-r8a7791", .data = rcar_pcie_hw_init },
+       {},
+};
+MODULE_DEVICE_TABLE(of, rcar_pcie_of_match);
+
+static int rcar_pcie_probe(struct platform_device *pdev)
+{
+       struct rcar_pcie *pcie;
+       unsigned int data;
+       struct of_pci_range range;
+       struct of_pci_range_parser parser;
+       const struct of_device_id *of_id;
+       int err, win = 0;
+       int (*hw_init_fn)(struct rcar_pcie *);
+
+       pcie = devm_kzalloc(&pdev->dev, sizeof(*pcie), GFP_KERNEL);
+       if (!pcie)
+               return -ENOMEM;
+
+       pcie->dev = &pdev->dev;
+       platform_set_drvdata(pdev, pcie);
+
+       /* Get the bus range */
+       if (of_pci_parse_bus_range(pdev->dev.of_node, &pcie->busn)) {
+               dev_err(&pdev->dev, "failed to parse bus-range property\n");
+               return -EINVAL;
+       }
+
+       if (of_pci_range_parser_init(&parser, pdev->dev.of_node)) {
+               dev_err(&pdev->dev, "missing ranges property\n");
+               return -EINVAL;
+       }
+
+       err = rcar_pcie_get_resources(pdev, pcie);
+       if (err < 0) {
+               dev_err(&pdev->dev, "failed to request resources: %d\n", err);
+               return err;
+       }
+
+       for_each_of_pci_range(&parser, &range) {
+               of_pci_range_to_resource(&range, pdev->dev.of_node,
+                                               &pcie->res[win++]);
+
+               if (win > PCI_MAX_RESOURCES)
+                       break;
+       }
+
+        err = rcar_pcie_parse_map_dma_ranges(pcie, pdev->dev.of_node);
+        if (err)
+               return err;
+
+       if (IS_ENABLED(CONFIG_PCI_MSI)) {
+               err = rcar_pcie_enable_msi(pcie);
+               if (err < 0) {
+                       dev_err(&pdev->dev,
+                               "failed to enable MSI support: %d\n",
+                               err);
+                       return err;
+               }
+       }
+
+       of_id = of_match_device(rcar_pcie_of_match, pcie->dev);
+       if (!of_id || !of_id->data)
+               return -EINVAL;
+       hw_init_fn = of_id->data;
+
+       /* Failure to get a link might just be that no cards are inserted */
+       err = hw_init_fn(pcie);
+       if (err) {
+               dev_info(&pdev->dev, "PCIe link down\n");
+               return 0;
+       }
+
+       data = pci_read_reg(pcie, MACSR);
+       dev_info(&pdev->dev, "PCIe x%d: link up\n", (data >> 20) & 0x3f);
+
+       rcar_pcie_enable(pcie);
+
+       return 0;
+}
+
+static struct platform_driver rcar_pcie_driver = {
+       .driver = {
+               .name = DRV_NAME,
+               .owner = THIS_MODULE,
+               .of_match_table = rcar_pcie_of_match,
+               .suppress_bind_attrs = true,
+       },
+       .probe = rcar_pcie_probe,
+};
+module_platform_driver(rcar_pcie_driver);
+
+MODULE_AUTHOR("Phil Edworthy <phil.edworthy@renesas.com>");
+MODULE_DESCRIPTION("Renesas R-Car PCIe driver");
+MODULE_LICENSE("GPLv2");
index 6258dc260d9f54ac4423998e8b338d4333768ef7..c68366cee6b72efda08d590e29b67222d3b56e35 100644 (file)
@@ -4,7 +4,7 @@
 #include <linux/export.h>
 #include "pci.h"
 
-int __ref pci_hp_add_bridge(struct pci_dev *dev)
+int pci_hp_add_bridge(struct pci_dev *dev)
 {
        struct pci_bus *parent = dev->bus;
        int pass, busnr, start = parent->busn_res.start;
index 728c31f4c2c50399593bee71ee6a4c277df849b6..e291efcd02a2d4c969161989162302d675ae3ecf 100644 (file)
@@ -63,10 +63,6 @@ MODULE_LICENSE("GPL");
 MODULE_PARM_DESC(disable, "disable acpiphp driver");
 module_param_named(disable, acpiphp_disabled, bool, 0444);
 
-/* export the attention callback registration methods */
-EXPORT_SYMBOL_GPL(acpiphp_register_attention);
-EXPORT_SYMBOL_GPL(acpiphp_unregister_attention);
-
 static int enable_slot         (struct hotplug_slot *slot);
 static int disable_slot                (struct hotplug_slot *slot);
 static int set_attention_status (struct hotplug_slot *slot, u8 value);
@@ -104,6 +100,7 @@ int acpiphp_register_attention(struct acpiphp_attention_info *info)
        }
        return retval;
 }
+EXPORT_SYMBOL_GPL(acpiphp_register_attention);
 
 
 /**
@@ -124,6 +121,7 @@ int acpiphp_unregister_attention(struct acpiphp_attention_info *info)
        }
        return retval;
 }
+EXPORT_SYMBOL_GPL(acpiphp_unregister_attention);
 
 
 /**
index bccc27ee10308f4d1ec388db248d1af1ab08aaba..772d8766338a2809b7060b781f581c892c46ea9a 100644 (file)
@@ -41,7 +41,6 @@
 
 #define pr_fmt(fmt) "acpiphp_glue: " fmt
 
-#include <linux/init.h>
 #include <linux/module.h>
 
 #include <linux/kernel.h>
@@ -352,11 +351,9 @@ static acpi_status acpiphp_add_context(acpi_handle handle, u32 lvl, void *data,
                        slot->slot = NULL;
                        bridge->nr_slots--;
                        if (retval == -EBUSY)
-                               pr_warn("Slot %llu already registered by another "
-                                       "hotplug driver\n", sun);
+                               pr_warn("Slot %llu already registered by another hotplug driver\n", sun);
                        else
-                               pr_warn("acpiphp_register_hotplug_slot failed "
-                                       "(err code = 0x%x)\n", retval);
+                               pr_warn("acpiphp_register_hotplug_slot failed (err code = 0x%x)\n", retval);
                }
                /* Even if the slot registration fails, we can still use it. */
        }
@@ -501,7 +498,7 @@ static int acpiphp_rescan_slot(struct acpiphp_slot *slot)
  * This function should be called per *physical slot*,
  * not per each slot object in ACPI namespace.
  */
-static void __ref enable_slot(struct acpiphp_slot *slot)
+static void enable_slot(struct acpiphp_slot *slot)
 {
        struct pci_dev *dev;
        struct pci_bus *bus = slot->bus;
@@ -516,8 +513,7 @@ static void __ref enable_slot(struct acpiphp_slot *slot)
                        if (PCI_SLOT(dev->devfn) != slot->device)
                                continue;
 
-                       if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-                           dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
+                       if (pci_is_bridge(dev)) {
                                max = pci_scan_bridge(bus, dev, max, pass);
                                if (pass && dev->subordinate) {
                                        check_hotplug_bridge(slot, dev);
index 1356211431d0d464406be033993af91d3b87362a..6a0ddf757349d70f267e44030324aca3f2e821d1 100644 (file)
@@ -56,9 +56,9 @@ struct cpci_hp_controller_ops {
        int (*enable_irq) (void);
        int (*disable_irq) (void);
        int (*check_irq) (void *dev_id);
-       int (*hardware_test) (struct slotslot, u32 value);
-       u8  (*get_power) (struct slotslot);
-       int (*set_power) (struct slotslot, int value);
+       int (*hardware_test) (struct slot *slot, u32 value);
+       u8  (*get_power) (struct slot *slot);
+       int (*set_power) (struct slot *slot, int value);
 };
 
 struct cpci_hp_controller {
@@ -89,13 +89,13 @@ int cpci_hp_stop(void);
 u8 cpci_get_attention_status(struct slot *slot);
 u8 cpci_get_latch_status(struct slot *slot);
 u8 cpci_get_adapter_status(struct slot *slot);
-u16 cpci_get_hs_csr(struct slot * slot);
+u16 cpci_get_hs_csr(struct slot *slot);
 int cpci_set_attention_status(struct slot *slot, int status);
-int cpci_check_and_clear_ins(struct slot * slot);
-int cpci_check_ext(struct slot * slot);
-int cpci_clear_ext(struct slot * slot);
-int cpci_led_on(struct slot * slot);
-int cpci_led_off(struct slot * slot);
+int cpci_check_and_clear_ins(struct slot *slot);
+int cpci_check_ext(struct slot *slot);
+int cpci_clear_ext(struct slot *slot);
+int cpci_led_on(struct slot *slot);
+int cpci_led_off(struct slot *slot);
 int cpci_configure_slot(struct slot *slot);
 int cpci_unconfigure_slot(struct slot *slot);
 
index 00c81a3cefc9be63e6bf47c5af9bdda0eefde37f..e09cf7827d68a3cf9b8f1755cd11a209e0f473f8 100644 (file)
@@ -65,10 +65,10 @@ static int thread_finished;
 static int enable_slot(struct hotplug_slot *slot);
 static int disable_slot(struct hotplug_slot *slot);
 static int set_attention_status(struct hotplug_slot *slot, u8 value);
-static int get_power_status(struct hotplug_slot *slot, u8 * value);
-static int get_attention_status(struct hotplug_slot *slot, u8 * value);
-static int get_adapter_status(struct hotplug_slot *slot, u8 * value);
-static int get_latch_status(struct hotplug_slot *slot, u8 * value);
+static int get_power_status(struct hotplug_slot *slot, u8 *value);
+static int get_attention_status(struct hotplug_slot *slot, u8 *value);
+static int get_adapter_status(struct hotplug_slot *slot, u8 *value);
+static int get_latch_status(struct hotplug_slot *slot, u8 *value);
 
 static struct hotplug_slot_ops cpci_hotplug_slot_ops = {
        .enable_slot = enable_slot,
@@ -168,7 +168,7 @@ cpci_get_power_status(struct slot *slot)
 }
 
 static int
-get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
+get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
        struct slot *slot = hotplug_slot->private;
 
@@ -177,7 +177,7 @@ get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
 }
 
 static int
-get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value)
+get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
        struct slot *slot = hotplug_slot->private;
 
@@ -192,14 +192,14 @@ set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
 }
 
 static int
-get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
+get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
        *value = hotplug_slot->info->adapter_status;
        return 0;
 }
 
 static int
-get_latch_status(struct hotplug_slot *hotplug_slot, u8 * value)
+get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
        *value = hotplug_slot->info->latch_status;
        return 0;
@@ -299,6 +299,7 @@ error_slot:
 error:
        return status;
 }
+EXPORT_SYMBOL_GPL(cpci_hp_register_bus);
 
 int
 cpci_hp_unregister_bus(struct pci_bus *bus)
@@ -329,6 +330,7 @@ cpci_hp_unregister_bus(struct pci_bus *bus)
        up_write(&list_rwsem);
        return status;
 }
+EXPORT_SYMBOL_GPL(cpci_hp_unregister_bus);
 
 /* This is the interrupt mode interrupt handler */
 static irqreturn_t
@@ -360,7 +362,7 @@ static int
 init_slots(int clear_ins)
 {
        struct slot *slot;
-       struct pci_devdev;
+       struct pci_dev *dev;
 
        dbg("%s - enter", __func__);
        down_read(&list_rwsem);
@@ -614,6 +616,7 @@ cpci_hp_register_controller(struct cpci_hp_controller *new_controller)
                controller = new_controller;
        return status;
 }
+EXPORT_SYMBOL_GPL(cpci_hp_register_controller);
 
 static void
 cleanup_slots(void)
@@ -653,6 +656,7 @@ cpci_hp_unregister_controller(struct cpci_hp_controller *old_controller)
                status = -ENODEV;
        return status;
 }
+EXPORT_SYMBOL_GPL(cpci_hp_unregister_controller);
 
 int
 cpci_hp_start(void)
@@ -690,6 +694,7 @@ cpci_hp_start(void)
        dbg("%s - exit", __func__);
        return 0;
 }
+EXPORT_SYMBOL_GPL(cpci_hp_start);
 
 int
 cpci_hp_stop(void)
@@ -704,6 +709,7 @@ cpci_hp_stop(void)
        cpci_stop_thread();
        return 0;
 }
+EXPORT_SYMBOL_GPL(cpci_hp_stop);
 
 int __init
 cpci_hotplug_init(int debug)
@@ -721,10 +727,3 @@ cpci_hotplug_exit(void)
        cpci_hp_stop();
        cpci_hp_unregister_controller(controller);
 }
-
-EXPORT_SYMBOL_GPL(cpci_hp_register_controller);
-EXPORT_SYMBOL_GPL(cpci_hp_unregister_controller);
-EXPORT_SYMBOL_GPL(cpci_hp_register_bus);
-EXPORT_SYMBOL_GPL(cpci_hp_unregister_bus);
-EXPORT_SYMBOL_GPL(cpci_hp_start);
-EXPORT_SYMBOL_GPL(cpci_hp_stop);
index 8c1464851768140f0c31c27f60f04f93df0ff8c6..7d48ecae6695581e7ded9caa59adf782d5bf0d3f 100644 (file)
@@ -46,7 +46,7 @@ extern int cpci_debug;
 #define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n", MY_NAME , ## arg)
 
 
-u8 cpci_get_attention_status(struct slotslot)
+u8 cpci_get_attention_status(struct slot *slot)
 {
        int hs_cap;
        u16 hs_csr;
@@ -66,7 +66,7 @@ u8 cpci_get_attention_status(struct slot* slot)
        return hs_csr & 0x0008 ? 1 : 0;
 }
 
-int cpci_set_attention_status(struct slotslot, int status)
+int cpci_set_attention_status(struct slot *slot, int status)
 {
        int hs_cap;
        u16 hs_csr;
@@ -93,7 +93,7 @@ int cpci_set_attention_status(struct slot* slot, int status)
        return 1;
 }
 
-u16 cpci_get_hs_csr(struct slotslot)
+u16 cpci_get_hs_csr(struct slot *slot)
 {
        int hs_cap;
        u16 hs_csr;
@@ -111,7 +111,7 @@ u16 cpci_get_hs_csr(struct slot* slot)
        return hs_csr;
 }
 
-int cpci_check_and_clear_ins(struct slotslot)
+int cpci_check_and_clear_ins(struct slot *slot)
 {
        int hs_cap;
        u16 hs_csr;
@@ -140,7 +140,7 @@ int cpci_check_and_clear_ins(struct slot* slot)
        return ins;
 }
 
-int cpci_check_ext(struct slotslot)
+int cpci_check_ext(struct slot *slot)
 {
        int hs_cap;
        u16 hs_csr;
@@ -161,7 +161,7 @@ int cpci_check_ext(struct slot* slot)
        return ext;
 }
 
-int cpci_clear_ext(struct slotslot)
+int cpci_clear_ext(struct slot *slot)
 {
        int hs_cap;
        u16 hs_csr;
@@ -187,7 +187,7 @@ int cpci_clear_ext(struct slot* slot)
        return 0;
 }
 
-int cpci_led_on(struct slotslot)
+int cpci_led_on(struct slot *slot)
 {
        int hs_cap;
        u16 hs_csr;
@@ -216,7 +216,7 @@ int cpci_led_on(struct slot* slot)
        return 0;
 }
 
-int cpci_led_off(struct slotslot)
+int cpci_led_off(struct slot *slot)
 {
        int hs_cap;
        u16 hs_csr;
@@ -250,7 +250,7 @@ int cpci_led_off(struct slot* slot)
  * Device configuration functions
  */
 
-int __ref cpci_configure_slot(struct slot *slot)
+int cpci_configure_slot(struct slot *slot)
 {
        struct pci_dev *dev;
        struct pci_bus *parent;
@@ -289,8 +289,7 @@ int __ref cpci_configure_slot(struct slot *slot)
        list_for_each_entry(dev, &parent->devices, bus_list)
                if (PCI_SLOT(dev->devfn) != PCI_SLOT(slot->devfn))
                        continue;
-               if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
-                   (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS))
+               if (pci_is_bridge(dev))
                        pci_hp_add_bridge(dev);
 
 
@@ -304,7 +303,7 @@ int __ref cpci_configure_slot(struct slot *slot)
        return ret;
 }
 
-int cpci_unconfigure_slot(struct slotslot)
+int cpci_unconfigure_slot(struct slot *slot)
 {
        struct pci_dev *dev, *temp;
 
index 7536eef620b0909b724cae3106dbfbc29d9dc2ec..04fcd7811400bdfb6e3afe3b592bcfbbc7121f14 100644 (file)
@@ -78,8 +78,8 @@ static struct cpci_hp_controller generic_hpc;
 
 static int __init validate_parameters(void)
 {
-       charstr;
-       charp;
+       char *str;
+       char *p;
        unsigned long tmp;
 
        if(!bridge) {
@@ -142,8 +142,8 @@ static int query_enum(void)
 static int __init cpcihp_generic_init(void)
 {
        int status;
-       struct resourcer;
-       struct pci_devdev;
+       struct resource *r;
+       struct pci_dev *dev;
 
        info(DRIVER_DESC " version: " DRIVER_VERSION);
        status = validate_parameters();
index e8c4a7ccf5788f73c0cf489ea09b0f0955c9e233..6757b3ef7e10217333302f52ba4b21ab9fd6363f 100644 (file)
@@ -295,7 +295,7 @@ static struct pci_driver zt5550_hc_driver = {
 
 static int __init zt5550_init(void)
 {
-       struct resourcer;
+       struct resource *r;
        int rc;
 
        info(DRIVER_DESC " version: " DRIVER_VERSION);
index 516b87738b6e522d7c6fea05c77a9b4da4c08e49..0450f405807de036060d043e688a0840f809dcc4 100644 (file)
@@ -255,7 +255,7 @@ struct pci_func {
        struct pci_resource *io_head;
        struct pci_resource *bus_head;
        struct timer_list *p_task_event;
-       struct pci_devpci_dev;
+       struct pci_dev *pci_dev;
 };
 
 struct slot {
@@ -278,7 +278,7 @@ struct slot {
 };
 
 struct pci_resource {
-       struct pci_resource * next;
+       struct pci_resource *next;
        u32 base;
        u32 length;
 };
index 037e2612c5bd036df0afb7a56c710439839cf31c..4aaee746df88424dbf730f5431ddee927947c0fb 100644 (file)
@@ -94,7 +94,7 @@ static inline int is_slot66mhz(struct slot *slot)
  *
  * Returns pointer to the head of the SMBIOS tables (or %NULL).
  */
-static void __iomem * detect_SMBIOS_pointer(void __iomem *begin, void __iomem *end)
+static void __iomem *detect_SMBIOS_pointer(void __iomem *begin, void __iomem *end)
 {
        void __iomem *fp;
        void __iomem *endp;
@@ -131,7 +131,7 @@ static void __iomem * detect_SMBIOS_pointer(void __iomem *begin, void __iomem *e
  *
  * For unexpected switch opens
  */
-static int init_SERR(struct controller * ctrl)
+static int init_SERR(struct controller *ctrl)
 {
        u32 tempdword;
        u32 number_of_slots;
@@ -291,7 +291,7 @@ static void release_slot(struct hotplug_slot *hotplug_slot)
        kfree(slot);
 }
 
-static int ctrl_slot_cleanup (struct controller * ctrl)
+static int ctrl_slot_cleanup (struct controller *ctrl)
 {
        struct slot *old_slot, *next_slot;
 
@@ -706,8 +706,7 @@ static int ctrl_slot_setup(struct controller *ctrl,
                hotplug_slot_info->adapter_status =
                        get_presence_status(ctrl, slot);
 
-               dbg("registering bus %d, dev %d, number %d, "
-                               "ctrl->slot_device_offset %d, slot %d\n",
+               dbg("registering bus %d, dev %d, number %d, ctrl->slot_device_offset %d, slot %d\n",
                                slot->bus, slot->device,
                                slot->number, ctrl->slot_device_offset,
                                slot_number);
@@ -837,8 +836,7 @@ static int cpqhpc_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
 
        bus = pdev->subordinate;
        if (!bus) {
-               dev_notice(&pdev->dev, "the device is not a bridge, "
-                               "skipping\n");
+               dev_notice(&pdev->dev, "the device is not a bridge, skipping\n");
                rc = -ENODEV;
                goto err_disable_device;
        }
index 11845b7967995479d5fab311f0a6f4c53fb4a97f..bde47fce324822c5efd5b59b20d0d15cbfb0544c 100644 (file)
@@ -39,9 +39,9 @@
 #include <linux/kthread.h>
 #include "cpqphp.h"
 
-static u32 configure_new_device(struct controllerctrl, struct pci_func *func,
+static u32 configure_new_device(struct controller *ctrl, struct pci_func *func,
                        u8 behind_bridge, struct resource_lists *resources);
-static int configure_new_function(struct controllerctrl, struct pci_func *func,
+static int configure_new_function(struct controller *ctrl, struct pci_func *func,
                        u8 behind_bridge, struct resource_lists *resources);
 static void interrupt_event_handler(struct controller *ctrl);
 
@@ -64,7 +64,7 @@ static void long_delay(int delay)
 
 /* FIXME: The following line needs to be somewhere else... */
 #define WRONG_BUS_FREQUENCY 0x07
-static u8 handle_switch_change(u8 change, struct controller * ctrl)
+static u8 handle_switch_change(u8 change, struct controller *ctrl)
 {
        int hp_slot;
        u8 rc = 0;
@@ -138,7 +138,7 @@ static struct slot *cpqhp_find_slot(struct controller *ctrl, u8 device)
 }
 
 
-static u8 handle_presence_change(u16 change, struct controller * ctrl)
+static u8 handle_presence_change(u16 change, struct controller *ctrl)
 {
        int hp_slot;
        u8 rc = 0;
@@ -232,7 +232,7 @@ static u8 handle_presence_change(u16 change, struct controller * ctrl)
 }
 
 
-static u8 handle_power_fault(u8 change, struct controller * ctrl)
+static u8 handle_power_fault(u8 change, struct controller *ctrl)
 {
        int hp_slot;
        u8 rc = 0;
@@ -709,7 +709,8 @@ static struct pci_resource *get_max_resource(struct pci_resource **head, u32 siz
                                temp = temp->next;
                        }
 
-                       temp->next = max->next;
+                       if (temp)
+                               temp->next = max->next;
                }
 
                max->next = NULL;
@@ -996,7 +997,7 @@ struct pci_func *cpqhp_slot_create(u8 busnumber)
  *
  * Returns %0 if successful, !0 otherwise.
  */
-static int slot_remove(struct pci_func * old_slot)
+static int slot_remove(struct pci_func *old_slot)
 {
        struct pci_func *next;
 
@@ -1108,7 +1109,7 @@ struct pci_func *cpqhp_slot_find(u8 bus, u8 device, u8 index)
 
 /* DJZ: I don't think is_bridge will work as is.
  * FIXME */
-static int is_bridge(struct pci_func * func)
+static int is_bridge(struct pci_func *func)
 {
        /* Check the header type */
        if (((func->config_space[0x03] >> 16) & 0xFF) == 0x01)
@@ -1624,7 +1625,7 @@ static u32 board_added(struct pci_func *func, struct controller *ctrl)
  * @replace_flag: whether replacing or adding a new device
  * @ctrl: target controller
  */
-static u32 remove_board(struct pci_func * func, u32 replace_flag, struct controller * ctrl)
+static u32 remove_board(struct pci_func *func, u32 replace_flag, struct controller *ctrl)
 {
        int index;
        u8 skip = 0;
@@ -1741,7 +1742,7 @@ static void pushbutton_helper_thread(unsigned long data)
 
 
 /* this is the main worker thread */
-static int event_thread(voiddata)
+static int event_thread(void *data)
 {
        struct controller *ctrl;
 
@@ -1991,7 +1992,7 @@ int cpqhp_process_SI(struct controller *ctrl, struct pci_func *func)
        u16 temp_word;
        u32 tempdword;
        int rc;
-       struct slotp_slot;
+       struct slot *p_slot;
        int physical_slot = 0;
 
        tempdword = 0;
@@ -2087,7 +2088,7 @@ int cpqhp_process_SS(struct controller *ctrl, struct pci_func *func)
        u8 replace_flag;
        u32 rc = 0;
        unsigned int devfn;
-       struct slotp_slot;
+       struct slot *p_slot;
        struct pci_bus *pci_bus = ctrl->pci_bus;
        int physical_slot=0;
 
@@ -2269,8 +2270,8 @@ int cpqhp_hardware_test(struct controller *ctrl, int test_num)
  *
  * Returns 0 if success.
  */
-static u32 configure_new_device(struct controller * ctrl, struct pci_func * func,
-                                u8 behind_bridge, struct resource_lists resources)
+static u32 configure_new_device(struct controller  *ctrl, struct pci_func  *func,
+                                u8 behind_bridge, struct resource_lists  *resources)
 {
        u8 temp_byte, function, max_functions, stop_it;
        int rc;
index 76ba8a1c774dfa716d947fc12092e82b8ebfef78..0968a9bcb34568d9d83ecd5c9d7834e29dcf1616 100644 (file)
@@ -34,7 +34,6 @@
 #include <linux/workqueue.h>
 #include <linux/pci.h>
 #include <linux/pci_hotplug.h>
-#include <linux/init.h>
 #include <asm/uaccess.h>
 #include "cpqphp.h"
 #include "cpqphp_nvram.h"
@@ -108,7 +107,7 @@ static spinlock_t int15_lock;
  */
 
 
-static u32 add_byte( u32 **p_buffer, u8 value, u32 *used, u32 *avail)
+static u32 add_byte(u32 **p_buffer, u8 value, u32 *used, u32 *avail)
 {
        u8 **tByte;
 
@@ -123,7 +122,7 @@ static u32 add_byte( u32 **p_buffer, u8 value, u32 *used, u32 *avail)
 }
 
 
-static u32 add_dword( u32 **p_buffer, u32 value, u32 *used, u32 *avail)
+static u32 add_dword(u32 **p_buffer, u32 value, u32 *used, u32 *avail)
 {
        if ((*used + 4) > *avail)
                return(1);
@@ -268,12 +267,12 @@ static u32 store_HRT (void __iomem *rom_start)
        ctrl = cpqhp_ctrl_list;
 
        /* The revision of this structure */
-       rc = add_byte( &pFill, 1 + ctrl->push_flag, &usedbytes, &available);
+       rc = add_byte(&pFill, 1 + ctrl->push_flag, &usedbytes, &available);
        if (rc)
                return(rc);
 
        /* The number of controllers */
-       rc = add_byte( &pFill, 1, &usedbytes, &available);
+       rc = add_byte(&pFill, 1, &usedbytes, &available);
        if (rc)
                return(rc);
 
@@ -283,22 +282,22 @@ static u32 store_HRT (void __iomem *rom_start)
                numCtrl++;
 
                /* The bus number */
-               rc = add_byte( &pFill, ctrl->bus, &usedbytes, &available);
+               rc = add_byte(&pFill, ctrl->bus, &usedbytes, &available);
                if (rc)
                        return(rc);
 
                /* The device Number */
-               rc = add_byte( &pFill, PCI_SLOT(ctrl->pci_dev->devfn), &usedbytes, &available);
+               rc = add_byte(&pFill, PCI_SLOT(ctrl->pci_dev->devfn), &usedbytes, &available);
                if (rc)
                        return(rc);
 
                /* The function Number */
-               rc = add_byte( &pFill, PCI_FUNC(ctrl->pci_dev->devfn), &usedbytes, &available);
+               rc = add_byte(&pFill, PCI_FUNC(ctrl->pci_dev->devfn), &usedbytes, &available);
                if (rc)
                        return(rc);
 
                /* Skip the number of available entries */
-               rc = add_dword( &pFill, 0, &usedbytes, &available);
+               rc = add_dword(&pFill, 0, &usedbytes, &available);
                if (rc)
                        return(rc);
 
@@ -312,12 +311,12 @@ static u32 store_HRT (void __iomem *rom_start)
                        loop ++;
 
                        /* base */
-                       rc = add_dword( &pFill, resNode->base, &usedbytes, &available);
+                       rc = add_dword(&pFill, resNode->base, &usedbytes, &available);
                        if (rc)
                                return(rc);
 
                        /* length */
-                       rc = add_dword( &pFill, resNode->length, &usedbytes, &available);
+                       rc = add_dword(&pFill, resNode->length, &usedbytes, &available);
                        if (rc)
                                return(rc);
 
@@ -337,12 +336,12 @@ static u32 store_HRT (void __iomem *rom_start)
                        loop ++;
 
                        /* base */
-                       rc = add_dword( &pFill, resNode->base, &usedbytes, &available);
+                       rc = add_dword(&pFill, resNode->base, &usedbytes, &available);
                        if (rc)
                                return(rc);
 
                        /* length */
-                       rc = add_dword( &pFill, resNode->length, &usedbytes, &available);
+                       rc = add_dword(&pFill, resNode->length, &usedbytes, &available);
                        if (rc)
                                return(rc);
 
@@ -362,12 +361,12 @@ static u32 store_HRT (void __iomem *rom_start)
                        loop ++;
 
                        /* base */
-                       rc = add_dword( &pFill, resNode->base, &usedbytes, &available);
+                       rc = add_dword(&pFill, resNode->base, &usedbytes, &available);
                        if (rc)
                                return(rc);
 
                        /* length */
-                       rc = add_dword( &pFill, resNode->length, &usedbytes, &available);
+                       rc = add_dword(&pFill, resNode->length, &usedbytes, &available);
                        if (rc)
                                return(rc);
 
@@ -387,12 +386,12 @@ static u32 store_HRT (void __iomem *rom_start)
                        loop ++;
 
                        /* base */
-                       rc = add_dword( &pFill, resNode->base, &usedbytes, &available);
+                       rc = add_dword(&pFill, resNode->base, &usedbytes, &available);
                        if (rc)
                                return(rc);
 
                        /* length */
-                       rc = add_dword( &pFill, resNode->length, &usedbytes, &available);
+                       rc = add_dword(&pFill, resNode->length, &usedbytes, &available);
                        if (rc)
                                return(rc);
 
index a3e3c2002b58e97b9260525947db723d7c6b00e7..1c8c2f130d31684ee6761d2909bcf8776a22d0d3 100644 (file)
@@ -81,7 +81,7 @@ static void __iomem *detect_HRT_floating_pointer(void __iomem *begin, void __iom
 }
 
 
-int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
+int cpqhp_configure_device (struct controller *ctrl, struct pci_func *func)
 {
        struct pci_bus *child;
        int num;
@@ -121,7 +121,7 @@ int cpqhp_configure_device (struct controller* ctrl, struct pci_func* func)
 }
 
 
-int cpqhp_unconfigure_device(struct pci_funcfunc)
+int cpqhp_unconfigure_device(struct pci_func *func)
 {
        int j;
 
@@ -129,7 +129,7 @@ int cpqhp_unconfigure_device(struct pci_func* func)
 
        pci_lock_rescan_remove();
        for (j=0; j<8 ; j++) {
-               struct pci_devtemp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j));
+               struct pci_dev *temp = pci_get_bus_and_slot(func->bus, PCI_DEVFN(func->device, j));
                if (temp) {
                        pci_dev_put(temp);
                        pci_stop_and_remove_bus_device(temp);
@@ -203,7 +203,7 @@ int cpqhp_set_irq (u8 bus_num, u8 dev_num, u8 int_pin, u8 irq_num)
 }
 
 
-static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 * dev_num)
+static int PCI_ScanBusForNonBridge(struct controller *ctrl, u8 bus_num, u8 *dev_num)
 {
        u16 tdevice;
        u32 work;
@@ -280,7 +280,7 @@ static int PCI_GetBusDevHelper(struct controller *ctrl, u8 *bus_num, u8 *dev_num
 }
 
 
-int cpqhp_get_bus_dev (struct controller *ctrl, u8 * bus_num, u8 * dev_num, u8 slot)
+int cpqhp_get_bus_dev (struct controller *ctrl, u8 *bus_num, u8 *dev_num, u8 slot)
 {
        /* plain (bridges allowed) */
        return PCI_GetBusDevHelper(ctrl, bus_num, dev_num, slot, 0);
@@ -465,7 +465,7 @@ int cpqhp_save_config(struct controller *ctrl, int busnumber, int is_hot_plug)
  *
  * returns 0 if success
  */
-int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func * new_slot)
+int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func *new_slot)
 {
        long rc;
        u8 class_code;
@@ -549,7 +549,7 @@ int cpqhp_save_slot_config (struct controller *ctrl, struct pci_func * new_slot)
  *
  * returns 0 if success
  */
-int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func * func)
+int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func *func)
 {
        u8 cloop;
        u8 header_type;
@@ -686,7 +686,7 @@ int cpqhp_save_base_addr_length(struct controller *ctrl, struct pci_func * func)
  *
  * returns 0 if success
  */
-int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
+int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func *func)
 {
        u8 cloop;
        u8 header_type;
@@ -949,7 +949,7 @@ int cpqhp_save_used_resources (struct controller *ctrl, struct pci_func * func)
  *
  * returns 0 if success
  */
-int cpqhp_configure_board(struct controller *ctrl, struct pci_func * func)
+int cpqhp_configure_board(struct controller *ctrl, struct pci_func *func)
 {
        int cloop;
        u8 header_type;
@@ -1027,7 +1027,7 @@ int cpqhp_configure_board(struct controller *ctrl, struct pci_func * func)
  *
  * returns 0 if the board is the same nonzero otherwise
  */
-int cpqhp_valid_replace(struct controller *ctrl, struct pci_func * func)
+int cpqhp_valid_replace(struct controller *ctrl, struct pci_func *func)
 {
        u8 cloop;
        u8 header_type;
@@ -1419,7 +1419,7 @@ int cpqhp_find_available_resources(struct controller *ctrl, void __iomem *rom_st
  *
  * returns 0 if success
  */
-int cpqhp_return_board_resources(struct pci_func * func, struct resource_lists * resources)
+int cpqhp_return_board_resources(struct pci_func *func, struct resource_lists *resources)
 {
        int rc = 0;
        struct pci_resource *node;
@@ -1475,7 +1475,7 @@ int cpqhp_return_board_resources(struct pci_func * func, struct resource_lists *
  *
  * Puts node back in the resource list pointed to by head
  */
-void cpqhp_destroy_resource_list (struct resource_lists * resources)
+void cpqhp_destroy_resource_list (struct resource_lists *resources)
 {
        struct pci_resource *res, *tres;
 
@@ -1522,7 +1522,7 @@ void cpqhp_destroy_resource_list (struct resource_lists * resources)
  *
  * Puts node back in the resource list pointed to by head
  */
-void cpqhp_destroy_board_resources (struct pci_func * func)
+void cpqhp_destroy_board_resources (struct pci_func *func)
 {
        struct pci_resource *res, *tres;
 
index 17c1f36315d191b46bf81734efa69fff344bfa84..4a392c44e3d3abacef8717fac3489ede76e24376 100644 (file)
@@ -79,7 +79,7 @@ static int show_ctrl (struct controller *ctrl, char *buf)
 
 static int show_dev (struct controller *ctrl, char *buf)
 {
-       char * out = buf;
+       char *out = buf;
        int index;
        struct pci_resource *res;
        struct pci_func *new_slot;
index cf3ac1e4b099b381862131fddb91ac2e7df10ac0..f7b8684a773969df4c88b9d0e358d19e5c7f069d 100644 (file)
@@ -74,7 +74,7 @@ static inline int get_max_adapter_speed (struct hotplug_slot *hs, u8 *value)
 static inline int get_cur_bus_info(struct slot **sl)
 {
        int rc = 1;
-       struct slot * slot_cur = *sl;
+       struct slot *slot_cur = *sl;
 
        debug("options = %x\n", slot_cur->ctrl->options);
        debug("revision = %x\n", slot_cur->ctrl->revision);
@@ -114,8 +114,8 @@ static inline int slot_update(struct slot **sl)
 
 static int __init get_max_slots (void)
 {
-       struct slot * slot_cur;
-       struct list_head * tmp;
+       struct slot *slot_cur;
+       struct list_head *tmp;
        u8 slot_count = 0;
 
        list_for_each(tmp, &ibmphp_slot_head) {
@@ -280,7 +280,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value)
        return rc;
 }
 
-static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value)
+static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
        int rc = -ENODEV;
        struct slot *pslot;
@@ -311,7 +311,7 @@ static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value)
        return rc;
 }
 
-static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 * value)
+static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
        int rc = -ENODEV;
        struct slot *pslot;
@@ -338,7 +338,7 @@ static int get_latch_status(struct hotplug_slot *hotplug_slot, u8 * value)
 }
 
 
-static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
+static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
        int rc = -ENODEV;
        struct slot *pslot;
@@ -364,7 +364,7 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
        return rc;
 }
 
-static int get_adapter_present(struct hotplug_slot *hotplug_slot, u8 * value)
+static int get_adapter_present(struct hotplug_slot *hotplug_slot, u8 *value)
 {
        int rc = -ENODEV;
        struct slot *pslot;
@@ -433,7 +433,7 @@ static int get_max_bus_speed(struct slot *slot)
 }
 
 /*
-static int get_max_adapter_speed_1(struct hotplug_slot *hotplug_slot, u8 * value, u8 flag)
+static int get_max_adapter_speed_1(struct hotplug_slot *hotplug_slot, u8 *value, u8 flag)
 {
        int rc = -ENODEV;
        struct slot *pslot;
@@ -471,7 +471,7 @@ static int get_max_adapter_speed_1(struct hotplug_slot *hotplug_slot, u8 * value
        return rc;
 }
 
-static int get_bus_name(struct hotplug_slot *hotplug_slot, char * value)
+static int get_bus_name(struct hotplug_slot *hotplug_slot, char *value)
 {
        int rc = -ENODEV;
        struct slot *pslot = NULL;
@@ -671,7 +671,7 @@ static struct pci_func *ibm_slot_find(u8 busno, u8 device, u8 function)
 {
        struct pci_func *func_cur;
        struct slot *slot_cur;
-       struct list_head * tmp;
+       struct list_head *tmp;
        list_for_each(tmp, &ibmphp_slot_head) {
                slot_cur = list_entry(tmp, struct slot, ibm_slot_list);
                if (slot_cur->func) {
@@ -696,8 +696,8 @@ static struct pci_func *ibm_slot_find(u8 busno, u8 device, u8 function)
 static void free_slots(void)
 {
        struct slot *slot_cur;
-       struct list_head * tmp;
-       struct list_head * next;
+       struct list_head *tmp;
+       struct list_head *next;
 
        debug("%s -- enter\n", __func__);
 
@@ -825,10 +825,10 @@ static int ibm_configure_device(struct pci_func *func)
 /*******************************************************
  * Returns whether the bus is empty or not
  *******************************************************/
-static int is_bus_empty(struct slot * slot_cur)
+static int is_bus_empty(struct slot *slot_cur)
 {
        int rc;
-       struct slot * tmp_slot;
+       struct slot *tmp_slot;
        u8 i = slot_cur->bus_on->slot_min;
 
        while (i <= slot_cur->bus_on->slot_max) {
@@ -856,7 +856,7 @@ static int is_bus_empty(struct slot * slot_cur)
  * Parameters: slot
  * Returns: bus is set (0) or error code
  ***********************************************************/
-static int set_bus(struct slot * slot_cur)
+static int set_bus(struct slot *slot_cur)
 {
        int rc;
        u8 speed;
@@ -956,7 +956,7 @@ static int set_bus(struct slot * slot_cur)
 static int check_limitations(struct slot *slot_cur)
 {
        u8 i;
-       struct slot * tmp_slot;
+       struct slot *tmp_slot;
        u8 count = 0;
        u8 limitation = 0;
 
@@ -1045,8 +1045,7 @@ static int enable_slot(struct hotplug_slot *hs)
        rc = check_limitations(slot_cur);
        if (rc) {
                err("Adding this card exceeds the limitations of this bus.\n");
-               err("(i.e., >1 133MHz cards running on same bus, or "
-                    ">2 66 PCI cards running on same bus.\n");
+               err("(i.e., >1 133MHz cards running on same bus, or >2 66 PCI cards running on same bus.\n");
                err("Try hot-adding into another bus\n");
                rc = -EINVAL;
                goto error_nopower;
@@ -1070,12 +1069,10 @@ static int enable_slot(struct hotplug_slot *hs)
                                        !(SLOT_PWRGD(slot_cur->status)))
                        err("power fault occurred trying to power up\n");
                else if (SLOT_BUS_SPEED(slot_cur->status)) {
-                       err("bus speed mismatch occurred.  please check "
-                               "current bus speed and card capability\n");
+                       err("bus speed mismatch occurred.  please check current bus speed and card capability\n");
                        print_card_capability(slot_cur);
                } else if (SLOT_BUS_MODE(slot_cur->ext_status)) {
-                       err("bus mode mismatch occurred.  please check "
-                               "current bus mode and card capability\n");
+                       err("bus mode mismatch occurred.  please check current bus mode and card capability\n");
                        print_card_capability(slot_cur);
                }
                ibmphp_update_slot_info(slot_cur);
@@ -1098,8 +1095,7 @@ static int enable_slot(struct hotplug_slot *hs)
                goto error_power;
        }
        if (SLOT_POWER(slot_cur->status) && (SLOT_BUS_SPEED(slot_cur->status))) {
-               err("bus speed mismatch occurred.  please check current bus "
-                                       "speed and card capability\n");
+               err("bus speed mismatch occurred.  please check current bus speed and card capability\n");
                print_card_capability(slot_cur);
                goto error_power;
        }
index bd044158b36c3ba963476ea1d32c139952de90cf..0f65ac5554344ce4a3c1bc474af73d12e0833dda 100644 (file)
@@ -563,7 +563,7 @@ static int first_slot_num (u8 slot_num, u8 first_slot, u8 var)
        return rc;
 }
 
-static struct opt_rio_lo * find_rxe_num (u8 slot_num)
+static struct opt_rio_lo *find_rxe_num (u8 slot_num)
 {
        struct opt_rio_lo *opt_lo_ptr;
 
@@ -575,7 +575,7 @@ static struct opt_rio_lo * find_rxe_num (u8 slot_num)
        return NULL;
 }
 
-static struct opt_rio * find_chassis_num (u8 slot_num)
+static struct opt_rio *find_chassis_num (u8 slot_num)
 {
        struct opt_rio *opt_vg_ptr;
 
@@ -593,7 +593,7 @@ static struct opt_rio * find_chassis_num (u8 slot_num)
 static u8 calculate_first_slot (u8 slot_num)
 {
        u8 first_slot = 1;
-       struct slot * slot_cur;
+       struct slot *slot_cur;
 
        list_for_each_entry(slot_cur, &ibmphp_slot_head, ibm_slot_list) {
                if (slot_cur->ctrl) {
@@ -607,7 +607,7 @@ static u8 calculate_first_slot (u8 slot_num)
 
 #define SLOT_NAME_SIZE 30
 
-static char *create_file_name (struct slot * slot_cur)
+static char *create_file_name (struct slot *slot_cur)
 {
        struct opt_rio *opt_vg_ptr = NULL;
        struct opt_rio_lo *opt_lo_ptr = NULL;
@@ -1192,7 +1192,7 @@ int ibmphp_register_pci (void)
        }
        return rc;
 }
-static int ibmphp_probe (struct pci_dev * dev, const struct pci_device_id *ids)
+static int ibmphp_probe (struct pci_dev *dev, const struct pci_device_id *ids)
 {
        struct controller *ctrl;
 
index 5fc7a089f5323ce629175bdb568da1584d84d19a..a936022956e6d4fc8416c8992b827744952f7109 100644 (file)
@@ -533,7 +533,7 @@ static u8 hpc_readcmdtoindex (u8 cmd, u8 index)
 *
 * Return   0 or error codes
 *---------------------------------------------------------------------*/
-int ibmphp_hpc_readslot (struct slot * pslot, u8 cmd, u8 * pstatus)
+int ibmphp_hpc_readslot (struct slot *pslot, u8 cmd, u8 *pstatus)
 {
        void __iomem *wpg_bbar = NULL;
        struct controller *ctlr_ptr;
@@ -672,7 +672,7 @@ int ibmphp_hpc_readslot (struct slot * pslot, u8 cmd, u8 * pstatus)
 *
 * Action: issue a WRITE command to HPC
 *---------------------------------------------------------------------*/
-int ibmphp_hpc_writeslot (struct slot * pslot, u8 cmd)
+int ibmphp_hpc_writeslot (struct slot *pslot, u8 cmd)
 {
        void __iomem *wpg_bbar = NULL;
        struct controller *ctlr_ptr;
@@ -1102,7 +1102,7 @@ void __exit ibmphp_hpc_stop_poll_thread (void)
 * Value:
 *---------------------------------------------------------------------*/
 static int hpc_wait_ctlr_notworking (int timeout, struct controller *ctlr_ptr, void __iomem *wpg_bbar,
-                                   u8 * pstatus)
+                                   u8 *pstatus)
 {
        int rc = 0;
        u8 done = 0;
index 639ea3a75e1452ed825e7a2650fe635c2785f892..2fd296706ce7f7a056ba5a2813c97f11d68ecdd1 100644 (file)
@@ -47,7 +47,7 @@ static u8 find_sec_number (u8 primary_busno, u8 slotno);
  * We also assign the same irq numbers for multi function devices.
  * These are PIC mode, so shouldn't matter n.e.ways (hopefully)
  */
-static void assign_alt_irq (struct pci_func * cur_func, u8 class_code)
+static void assign_alt_irq (struct pci_func *cur_func, u8 class_code)
 {
        int j;
        for (j = 0; j < 4; j++) {
@@ -137,8 +137,8 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
                                     "Please choose another device.\n", cur_func->device);
                                return -ENODEV;
                        } else if (class == PCI_CLASS_DISPLAY_VGA) {
-                               err ("The device %x is not supported for hot plugging. "
-                                    "Please choose another device.\n", cur_func->device);
+                               err ("The device %x is not supported for hot plugging. Please choose another device.\n",
+                                    cur_func->device);
                                return -ENODEV;
                        }
                        switch (hdr_type) {
@@ -179,8 +179,8 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
                                case PCI_HEADER_TYPE_MULTIBRIDGE:
                                        class >>= 8;
                                        if (class != PCI_CLASS_BRIDGE_PCI) {
-                                               err ("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. "
-                                                    "Please insert another card.\n", cur_func->device);
+                                               err ("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging.  Please insert another card.\n",
+                                                    cur_func->device);
                                                return -ENODEV;
                                        }
                                        assign_alt_irq (cur_func, class_code);
@@ -247,8 +247,8 @@ int ibmphp_configure_card (struct pci_func *func, u8 slotno)
                                        class >>= 8;
                                        debug ("class now is %x\n", class);
                                        if (class != PCI_CLASS_BRIDGE_PCI) {
-                                               err ("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging. "
-                                                    "Please insert another card.\n", cur_func->device);
+                                               err ("This %x is not PCI-to-PCI bridge, and as is not supported for hot-plugging.  Please insert another card.\n",
+                                                    cur_func->device);
                                                return -ENODEV;
                                        }
 
@@ -1073,7 +1073,7 @@ error:
  * Input: bridge function
  * Output: amount of resources needed
  *****************************************************************************/
-static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno)
+static struct res_needed *scan_behind_bridge (struct pci_func *func, u8 busno)
 {
        int count, len[6];
        u16 vendor_id;
@@ -1125,13 +1125,11 @@ static struct res_needed *scan_behind_bridge (struct pci_func * func, u8 busno)
 
                                class >>= 8;    /* to take revision out, class = class.subclass.prog i/f */
                                if (class == PCI_CLASS_NOT_DEFINED_VGA) {
-                                       err ("The device %x is VGA compatible and as is not supported for hot plugging. "
-                                            "Please choose another device.\n", device);
+                                       err ("The device %x is VGA compatible and as is not supported for hot plugging.  Please choose another device.\n", device);
                                        amount->not_correct = 1;
                                        return amount;
                                } else if (class == PCI_CLASS_DISPLAY_VGA) {
-                                       err ("The device %x is not supported for hot plugging. "
-                                            "Please choose another device.\n", device);
+                                       err ("The device %x is not supported for hot plugging.  Please choose another device.\n", device);
                                        amount->not_correct = 1;
                                        return amount;
                                }
@@ -1483,12 +1481,10 @@ static int unconfigure_boot_card (struct slot *slot_cur)
                        debug ("hdr_type %x, class %x\n", hdr_type, class);
                        class >>= 8;    /* to take revision out, class = class.subclass.prog i/f */
                        if (class == PCI_CLASS_NOT_DEFINED_VGA) {
-                               err ("The device %x function %x is VGA compatible and is not supported for hot removing. "
-                                    "Please choose another device.\n", device, function);
+                               err ("The device %x function %x is VGA compatible and is not supported for hot removing.  Please choose another device.\n", device, function);
                                return -ENODEV;
                        } else if (class == PCI_CLASS_DISPLAY_VGA) {
-                               err ("The device %x function %x is not supported for hot removing. "
-                                    "Please choose another device.\n", device, function);
+                               err ("The device %x function %x is not supported for hot removing.  Please choose another device.\n", device, function);
                                return -ENODEV;
                        }
 
@@ -1513,9 +1509,7 @@ static int unconfigure_boot_card (struct slot *slot_cur)
                                case PCI_HEADER_TYPE_BRIDGE:
                                        class >>= 8;
                                        if (class != PCI_CLASS_BRIDGE_PCI) {
-                                               err ("This device %x function %x is not PCI-to-PCI bridge, "
-                                                    "and is not supported for hot-removing. "
-                                                    "Please try another card.\n", device, function);
+                                               err ("This device %x function %x is not PCI-to-PCI bridge, and is not supported for hot-removing.  Please try another card.\n", device, function);
                                                return -ENODEV;
                                        }
                                        rc = unconfigure_boot_bridge (busno, device, function);
@@ -1529,9 +1523,7 @@ static int unconfigure_boot_card (struct slot *slot_cur)
                                case PCI_HEADER_TYPE_MULTIBRIDGE:
                                        class >>= 8;
                                        if (class != PCI_CLASS_BRIDGE_PCI) {
-                                               err ("This device %x function %x is not PCI-to-PCI bridge, "
-                                                    "and is not supported for hot-removing. "
-                                                    "Please try another card.\n", device, function);
+                                               err ("This device %x function %x is not PCI-to-PCI bridge,  and is not supported for hot-removing.  Please try another card.\n", device, function);
                                                return -ENODEV;
                                        }
                                        rc = unconfigure_boot_bridge (busno, device, function);
index a265acb2d5186502d7517c3405797b3882d305c7..f34745abd5b625e3d2588cbee2ca0568d8f98128 100644 (file)
@@ -46,9 +46,9 @@ static struct bus_node *find_bus_wprev (u8, struct bus_node **, u8);
 
 static LIST_HEAD(gbuses);
 
-static struct bus_node * __init alloc_error_bus (struct ebda_pci_rsrc * curr, u8 busno, int flag)
+static struct bus_node * __init alloc_error_bus (struct ebda_pci_rsrc *curr, u8 busno, int flag)
 {
-       struct bus_node * newbus;
+       struct bus_node *newbus;
 
        if (!(curr) && !(flag)) {
                err ("NULL pointer passed\n");
@@ -69,7 +69,7 @@ static struct bus_node * __init alloc_error_bus (struct ebda_pci_rsrc * curr, u8
        return newbus;
 }
 
-static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc * curr)
+static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc *curr)
 {
        struct resource_node *rs;
 
@@ -93,7 +93,7 @@ static struct resource_node * __init alloc_resources (struct ebda_pci_rsrc * cur
 
 static int __init alloc_bus_range (struct bus_node **new_bus, struct range_node **new_range, struct ebda_pci_rsrc *curr, int flag, u8 first_bus)
 {
-       struct bus_node * newbus;
+       struct bus_node *newbus;
        struct range_node *newrange;
        u8 num_ranges = 0;
 
@@ -789,8 +789,7 @@ int ibmphp_remove_resource (struct resource_node *res)
        bus_cur = find_bus_wprev (res->busno, NULL, 0);
 
        if (!bus_cur) {
-               err ("cannot find corresponding bus of the io resource to remove  "
-                       "bailing out...\n");
+               err ("cannot find corresponding bus of the io resource to remove  bailing out...\n");
                return -ENODEV;
        }
 
@@ -934,9 +933,9 @@ int ibmphp_remove_resource (struct resource_node *res)
        return 0;
 }
 
-static struct range_node * find_range (struct bus_node *bus_cur, struct resource_node * res)
+static struct range_node *find_range (struct bus_node *bus_cur, struct resource_node *res)
 {
-       struct range_node * range = NULL;
+       struct range_node *range = NULL;
 
        switch (res->type) {
                case IO:
index cfa92a984e622ff0c8719488191daf0f618d8297..56d8486dc16704d1f93726d03131cbedfe0b4bed 100644 (file)
@@ -59,14 +59,12 @@ static bool debug;
 #define DRIVER_DESC    "PCI Hot Plug PCI Core"
 
 
-//////////////////////////////////////////////////////////////////
-
 static LIST_HEAD(pci_hotplug_slot_list);
 static DEFINE_MUTEX(pci_hp_mutex);
 
 /* Weee, fun with macros... */
-#define GET_STATUS(name,type)  \
-static int get_##name (struct hotplug_slot *slot, type *value)         \
+#define GET_STATUS(name, type) \
+static int get_##name(struct hotplug_slot *slot, type *value)          \
 {                                                                      \
        struct hotplug_slot_ops *ops = slot->ops;                       \
        int retval = 0;                                                 \
@@ -92,42 +90,41 @@ static ssize_t power_read_file(struct pci_slot *slot, char *buf)
 
        retval = get_power_status(slot->hotplug, &value);
        if (retval)
-               goto exit;
-       retval = sprintf (buf, "%d\n", value);
-exit:
-       return retval;
+               return retval;
+
+       return sprintf(buf, "%d\n", value);
 }
 
 static ssize_t power_write_file(struct pci_slot *pci_slot, const char *buf,
-               size_t count)
+                               size_t count)
 {
        struct hotplug_slot *slot = pci_slot->hotplug;
        unsigned long lpower;
        u8 power;
        int retval = 0;
 
-       lpower = simple_strtoul (buf, NULL, 10);
+       lpower = simple_strtoul(buf, NULL, 10);
        power = (u8)(lpower & 0xff);
-       dbg ("power = %d\n", power);
+       dbg("power = %d\n", power);
 
        if (!try_module_get(slot->ops->owner)) {
                retval = -ENODEV;
                goto exit;
        }
        switch (power) {
-               case 0:
-                       if (slot->ops->disable_slot)
-                               retval = slot->ops->disable_slot(slot);
-                       break;
-
-               case 1:
-                       if (slot->ops->enable_slot)
-                               retval = slot->ops->enable_slot(slot);
-                       break;
-
-               default:
-                       err ("Illegal value specified for power\n");
-                       retval = -EINVAL;
+       case 0:
+               if (slot->ops->disable_slot)
+                       retval = slot->ops->disable_slot(slot);
+               break;
+
+       case 1:
+               if (slot->ops->enable_slot)
+                       retval = slot->ops->enable_slot(slot);
+               break;
+
+       default:
+               err("Illegal value specified for power\n");
+               retval = -EINVAL;
        }
        module_put(slot->ops->owner);
 
@@ -150,24 +147,22 @@ static ssize_t attention_read_file(struct pci_slot *slot, char *buf)
 
        retval = get_attention_status(slot->hotplug, &value);
        if (retval)
-               goto exit;
-       retval = sprintf(buf, "%d\n", value);
+               return retval;
 
-exit:
-       return retval;
+       return sprintf(buf, "%d\n", value);
 }
 
 static ssize_t attention_write_file(struct pci_slot *slot, const char *buf,
-               size_t count)
+                                   size_t count)
 {
        struct hotplug_slot_ops *ops = slot->hotplug->ops;
        unsigned long lattention;
        u8 attention;
        int retval = 0;
 
-       lattention = simple_strtoul (buf, NULL, 10);
+       lattention = simple_strtoul(buf, NULL, 10);
        attention = (u8)(lattention & 0xff);
-       dbg (" - attention = %d\n", attention);
+       dbg(" - attention = %d\n", attention);
 
        if (!try_module_get(ops->owner)) {
                retval = -ENODEV;
@@ -196,11 +191,9 @@ static ssize_t latch_read_file(struct pci_slot *slot, char *buf)
 
        retval = get_latch_status(slot->hotplug, &value);
        if (retval)
-               goto exit;
-       retval = sprintf (buf, "%d\n", value);
+               return retval;
 
-exit:
-       return retval;
+       return sprintf(buf, "%d\n", value);
 }
 
 static struct pci_slot_attribute hotplug_slot_attr_latch = {
@@ -215,11 +208,9 @@ static ssize_t presence_read_file(struct pci_slot *slot, char *buf)
 
        retval = get_adapter_status(slot->hotplug, &value);
        if (retval)
-               goto exit;
-       retval = sprintf (buf, "%d\n", value);
+               return retval;
 
-exit:
-       return retval;
+       return sprintf(buf, "%d\n", value);
 }
 
 static struct pci_slot_attribute hotplug_slot_attr_presence = {
@@ -228,7 +219,7 @@ static struct pci_slot_attribute hotplug_slot_attr_presence = {
 };
 
 static ssize_t test_write_file(struct pci_slot *pci_slot, const char *buf,
-               size_t count)
+                              size_t count)
 {
        struct hotplug_slot *slot = pci_slot->hotplug;
        unsigned long ltest;
@@ -237,7 +228,7 @@ static ssize_t test_write_file(struct pci_slot *pci_slot, const char *buf,
 
        ltest = simple_strtoul (buf, NULL, 10);
        test = (u32)(ltest & 0xffffffff);
-       dbg ("test = %d\n", test);
+       dbg("test = %d\n", test);
 
        if (!try_module_get(slot->ops->owner)) {
                retval = -ENODEV;
@@ -261,6 +252,7 @@ static struct pci_slot_attribute hotplug_slot_attr_test = {
 static bool has_power_file(struct pci_slot *pci_slot)
 {
        struct hotplug_slot *slot = pci_slot->hotplug;
+
        if ((!slot) || (!slot->ops))
                return false;
        if ((slot->ops->enable_slot) ||
@@ -273,6 +265,7 @@ static bool has_power_file(struct pci_slot *pci_slot)
 static bool has_attention_file(struct pci_slot *pci_slot)
 {
        struct hotplug_slot *slot = pci_slot->hotplug;
+
        if ((!slot) || (!slot->ops))
                return false;
        if ((slot->ops->set_attention_status) ||
@@ -284,6 +277,7 @@ static bool has_attention_file(struct pci_slot *pci_slot)
 static bool has_latch_file(struct pci_slot *pci_slot)
 {
        struct hotplug_slot *slot = pci_slot->hotplug;
+
        if ((!slot) || (!slot->ops))
                return false;
        if (slot->ops->get_latch_status)
@@ -294,6 +288,7 @@ static bool has_latch_file(struct pci_slot *pci_slot)
 static bool has_adapter_file(struct pci_slot *pci_slot)
 {
        struct hotplug_slot *slot = pci_slot->hotplug;
+
        if ((!slot) || (!slot->ops))
                return false;
        if (slot->ops->get_adapter_status)
@@ -304,6 +299,7 @@ static bool has_adapter_file(struct pci_slot *pci_slot)
 static bool has_test_file(struct pci_slot *pci_slot)
 {
        struct hotplug_slot *slot = pci_slot->hotplug;
+
        if ((!slot) || (!slot->ops))
                return false;
        if (slot->ops->hardware_test)
@@ -397,13 +393,13 @@ static void fs_remove_slot(struct pci_slot *slot)
        pci_hp_remove_module_link(slot);
 }
 
-static struct hotplug_slot *get_slot_from_name (const char *name)
+static struct hotplug_slot *get_slot_from_name(const char *name)
 {
        struct hotplug_slot *slot;
        struct list_head *tmp;
 
-       list_for_each (tmp, &pci_hotplug_slot_list) {
-               slot = list_entry (tmp, struct hotplug_slot, slot_list);
+       list_for_each(tmp, &pci_hotplug_slot_list) {
+               slot = list_entry(tmp, struct hotplug_slot, slot_list);
                if (strcmp(hotplug_slot_name(slot), name) == 0)
                        return slot;
        }
@@ -436,8 +432,7 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
        if ((slot->info == NULL) || (slot->ops == NULL))
                return -EINVAL;
        if (slot->release == NULL) {
-               dbg("Why are you trying to register a hotplug slot "
-                   "without a proper release function?\n");
+               dbg("Why are you trying to register a hotplug slot without a proper release function?\n");
                return -EINVAL;
        }
 
@@ -468,6 +463,7 @@ out:
        mutex_unlock(&pci_hp_mutex);
        return result;
 }
+EXPORT_SYMBOL_GPL(__pci_hp_register);
 
 /**
  * pci_hp_deregister - deregister a hotplug_slot with the PCI hotplug subsystem
@@ -506,6 +502,7 @@ int pci_hp_deregister(struct hotplug_slot *hotplug)
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(pci_hp_deregister);
 
 /**
  * pci_hp_change_slot_info - changes the slot's information structure in the core
@@ -527,24 +524,23 @@ int pci_hp_change_slot_info(struct hotplug_slot *hotplug,
 
        return 0;
 }
+EXPORT_SYMBOL_GPL(pci_hp_change_slot_info);
 
-static int __init pci_hotplug_init (void)
+static int __init pci_hotplug_init(void)
 {
        int result;
 
        result = cpci_hotplug_init(debug);
        if (result) {
-               err ("cpci_hotplug_init with error %d\n", result);
-               goto err_cpci;
+               err("cpci_hotplug_init with error %d\n", result);
+               return result;
        }
 
-       info (DRIVER_DESC " version: " DRIVER_VERSION "\n");
-
-err_cpci:
+       info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
        return result;
 }
 
-static void __exit pci_hotplug_exit (void)
+static void __exit pci_hotplug_exit(void)
 {
        cpci_hotplug_exit();
 }
@@ -557,7 +553,3 @@ MODULE_DESCRIPTION(DRIVER_DESC);
 MODULE_LICENSE("GPL");
 module_param(debug, bool, 0644);
 MODULE_PARM_DESC(debug, "Debugging mode enabled or not");
-
-EXPORT_SYMBOL_GPL(__pci_hp_register);
-EXPORT_SYMBOL_GPL(pci_hp_deregister);
-EXPORT_SYMBOL_GPL(pci_hp_change_slot_info);
index 8a66866b8cf1ad799de42c2a15075f7549f0ca3a..8e9012dca450df581f718431e25e85d469827534 100644 (file)
@@ -127,7 +127,7 @@ struct controller {
 #define HP_SUPR_RM(ctrl)       ((ctrl)->slot_cap & PCI_EXP_SLTCAP_HPS)
 #define EMI(ctrl)              ((ctrl)->slot_cap & PCI_EXP_SLTCAP_EIP)
 #define NO_CMD_CMPL(ctrl)      ((ctrl)->slot_cap & PCI_EXP_SLTCAP_NCCS)
-#define PSN(ctrl)              ((ctrl)->slot_cap >> 19)
+#define PSN(ctrl)              (((ctrl)->slot_cap & PCI_EXP_SLTCAP_PSN) >> 19)
 
 int pciehp_sysfs_enable_slot(struct slot *slot);
 int pciehp_sysfs_disable_slot(struct slot *slot);
index 20fea57d2149c7ecf43e31c6ee16d820415ba85d..93cc9266e8cb8caa38075e044849413116ed9b71 100644 (file)
@@ -103,10 +103,10 @@ static int __init dummy_probe(struct pcie_device *dev)
 }
 
 static struct pcie_port_service_driver __initdata dummy_driver = {
-        .name           = "pciehp_dummy",
+       .name           = "pciehp_dummy",
        .port_type      = PCIE_ANY_PORT,
        .service        = PCIE_PORT_SERVICE_HP,
-        .probe          = dummy_probe,
+       .probe          = dummy_probe,
 };
 
 static int __init select_detection_mode(void)
index 0e0a2fff20a39be57f7c9abc8bb422831c771416..a2297db8081322a6ca51f2b6d32fadf385e1236c 100644 (file)
@@ -266,8 +266,7 @@ static int pciehp_probe(struct pcie_device *dev)
        rc = init_slot(ctrl);
        if (rc) {
                if (rc == -EBUSY)
-                       ctrl_warn(ctrl, "Slot already registered by another "
-                                 "hotplug driver\n");
+                       ctrl_warn(ctrl, "Slot already registered by another hotplug driver\n");
                else
                        ctrl_err(ctrl, "Slot initialization failed\n");
                goto err_out_release_ctlr;
@@ -312,12 +311,12 @@ static void pciehp_remove(struct pcie_device *dev)
 }
 
 #ifdef CONFIG_PM
-static int pciehp_suspend (struct pcie_device *dev)
+static int pciehp_suspend(struct pcie_device *dev)
 {
        return 0;
 }
 
-static int pciehp_resume (struct pcie_device *dev)
+static int pciehp_resume(struct pcie_device *dev)
 {
        struct controller *ctrl;
        struct slot *slot;
index c75e6a678dcc22f19707fc8d77200e1ee307afe6..ff32e85e1de6fb53972e2f58e62f273e350ad969 100644 (file)
@@ -175,7 +175,7 @@ void pciehp_handle_linkstate_change(struct slot *p_slot)
    hotplug controller logic
  */
 
-static void set_slot_off(struct controller *ctrl, struct slot * pslot)
+static void set_slot_off(struct controller *ctrl, struct slot *pslot)
 {
        /* turn off slot, turn on Amber LED, turn off Green LED if supported*/
        if (POWER_CTRL(ctrl)) {
@@ -376,14 +376,12 @@ static void handle_button_press_event(struct slot *p_slot)
                pciehp_get_power_status(p_slot, &getstatus);
                if (getstatus) {
                        p_slot->state = BLINKINGOFF_STATE;
-                       ctrl_info(ctrl,
-                                 "PCI slot #%s - powering off due to button "
-                                 "press.\n", slot_name(p_slot));
+                       ctrl_info(ctrl, "PCI slot #%s - powering off due to button press\n",
+                                 slot_name(p_slot));
                } else {
                        p_slot->state = BLINKINGON_STATE;
-                       ctrl_info(ctrl,
-                                 "PCI slot #%s - powering on due to button "
-                                 "press.\n", slot_name(p_slot));
+                       ctrl_info(ctrl, "PCI slot #%s - powering on due to button press\n",
+                                 slot_name(p_slot));
                }
                /* blink green LED and turn off amber */
                pciehp_green_led_blink(p_slot);
@@ -404,8 +402,8 @@ static void handle_button_press_event(struct slot *p_slot)
                else
                        pciehp_green_led_off(p_slot);
                pciehp_set_attention_status(p_slot, 0);
-               ctrl_info(ctrl, "PCI slot #%s - action canceled "
-                         "due to button press\n", slot_name(p_slot));
+               ctrl_info(ctrl, "PCI slot #%s - action canceled due to button press\n",
+                         slot_name(p_slot));
                p_slot->state = STATIC_STATE;
                break;
        case POWEROFF_STATE:
index d7d058fa19a428e5503c919979e5a6e1e5e5e0b2..42914e04d11070e4daefccc9eeb80d52a610b549 100644 (file)
@@ -159,6 +159,8 @@ static void pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
 
        pcie_capability_read_word(pdev, PCI_EXP_SLTSTA, &slot_status);
        if (slot_status & PCI_EXP_SLTSTA_CC) {
+               pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
+                                          PCI_EXP_SLTSTA_CC);
                if (!ctrl->no_cmd_complete) {
                        /*
                         * After 1 sec and CMD_COMPLETED still not set, just
@@ -172,12 +174,10 @@ static void pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
                         * event even though it supports none of power
                         * controller, attention led, power led and EMI.
                         */
-                       ctrl_dbg(ctrl, "Unexpected CMD_COMPLETED. Need to "
-                                "wait for command completed event.\n");
+                       ctrl_dbg(ctrl, "Unexpected CMD_COMPLETED. Need to wait for command completed event\n");
                        ctrl->no_cmd_complete = 0;
                } else {
-                       ctrl_dbg(ctrl, "Unexpected CMD_COMPLETED. Maybe "
-                                "the controller is broken.\n");
+                       ctrl_dbg(ctrl, "Unexpected CMD_COMPLETED. Maybe the controller is broken\n");
                }
        }
 
@@ -201,7 +201,7 @@ static void pcie_write_cmd(struct controller *ctrl, u16 cmd, u16 mask)
                if (!(slot_ctrl & PCI_EXP_SLTCTL_HPIE) ||
                    !(slot_ctrl & PCI_EXP_SLTCTL_CCIE))
                        poll = 1;
-                pcie_wait_cmd(ctrl, poll);
+               pcie_wait_cmd(ctrl, poll);
        }
        mutex_unlock(&ctrl->ctrl_lock);
 }
@@ -274,15 +274,15 @@ int pciehp_check_link_status(struct controller *ctrl)
        bool found;
        u16 lnk_status;
 
-        /*
-         * Data Link Layer Link Active Reporting must be capable for
-         * hot-plug capable downstream port. But old controller might
-         * not implement it. In this case, we wait for 1000 ms.
-         */
-        if (ctrl->link_active_reporting)
-                pcie_wait_link_active(ctrl);
-        else
-                msleep(1000);
+       /*
+        * Data Link Layer Link Active Reporting must be capable for
+        * hot-plug capable downstream port. But old controller might
+        * not implement it. In this case, we wait for 1000 ms.
+       */
+       if (ctrl->link_active_reporting)
+               pcie_wait_link_active(ctrl);
+       else
+               msleep(1000);
 
        /* wait 100ms before read pci conf, and try in 1s */
        msleep(100);
@@ -293,7 +293,7 @@ int pciehp_check_link_status(struct controller *ctrl)
        ctrl_dbg(ctrl, "%s: lnk_status = %x\n", __func__, lnk_status);
        if ((lnk_status & PCI_EXP_LNKSTA_LT) ||
            !(lnk_status & PCI_EXP_LNKSTA_NLW)) {
-               ctrl_err(ctrl, "Link Training Error occurs \n");
+               ctrl_err(ctrl, "Link Training Error occurs\n");
                return -1;
        }
 
@@ -412,7 +412,7 @@ void pciehp_set_attention_status(struct slot *slot, u8 value)
                return;
 
        switch (value) {
-       case 0 :        /* turn off */
+       case 0        /* turn off */
                slot_cmd = PCI_EXP_SLTCTL_ATTN_IND_OFF;
                break;
        case 1:         /* turn on */
@@ -468,7 +468,7 @@ void pciehp_green_led_blink(struct slot *slot)
                 PCI_EXP_SLTCTL_PWR_IND_BLINK);
 }
 
-int pciehp_power_on_slot(struct slot * slot)
+int pciehp_power_on_slot(struct slot *slot)
 {
        struct controller *ctrl = slot->ctrl;
        struct pci_dev *pdev = ctrl_dev(ctrl);
@@ -494,7 +494,7 @@ int pciehp_power_on_slot(struct slot * slot)
        return retval;
 }
 
-void pciehp_power_off_slot(struct slot * slot)
+void pciehp_power_off_slot(struct slot *slot)
 {
        struct controller *ctrl = slot->ctrl;
 
@@ -754,7 +754,7 @@ static inline void dbg_ctrl(struct controller *ctrl)
        ctrl_info(ctrl, "Slot Control           : 0x%04x\n", reg16);
 }
 
-#define FLAG(x,y)      (((x) & (y)) ? '+' : '-')
+#define FLAG(x, y)     (((x) & (y)) ? '+' : '-')
 
 struct controller *pcie_init(struct pcie_device *dev)
 {
@@ -781,14 +781,14 @@ struct controller *pcie_init(struct pcie_device *dev)
         */
        if (NO_CMD_CMPL(ctrl) ||
            !(POWER_CTRL(ctrl) | ATTN_LED(ctrl) | PWR_LED(ctrl) | EMI(ctrl)))
-           ctrl->no_cmd_complete = 1;
-
-        /* Check if Data Link Layer Link Active Reporting is implemented */
-        pcie_capability_read_dword(pdev, PCI_EXP_LNKCAP, &link_cap);
-        if (link_cap & PCI_EXP_LNKCAP_DLLLARC) {
-                ctrl_dbg(ctrl, "Link Active Reporting supported\n");
-                ctrl->link_active_reporting = 1;
-        }
+               ctrl->no_cmd_complete = 1;
+
+       /* Check if Data Link Layer Link Active Reporting is implemented */
+       pcie_capability_read_dword(pdev, PCI_EXP_LNKCAP, &link_cap);
+       if (link_cap & PCI_EXP_LNKCAP_DLLLARC) {
+               ctrl_dbg(ctrl, "Link Active Reporting supported\n");
+               ctrl->link_active_reporting = 1;
+       }
 
        /* Clear all remaining event bits in Slot Status register */
        pcie_capability_write_word(pdev, PCI_EXP_SLTSTA,
index 1b533060ce650778bbdc74e2a676d333c9afe7d7..5f871f4c4af10944e3417712f99194c2c1936349 100644 (file)
@@ -46,9 +46,8 @@ int pciehp_configure_device(struct slot *p_slot)
 
        dev = pci_get_slot(parent, PCI_DEVFN(0, 0));
        if (dev) {
-               ctrl_err(ctrl, "Device %s already exists "
-                        "at %04x:%02x:00, cannot hot-add\n", pci_name(dev),
-                        pci_domain_nr(parent), parent->number);
+               ctrl_err(ctrl, "Device %s already exists at %04x:%02x:00, cannot hot-add\n",
+                        pci_name(dev), pci_domain_nr(parent), parent->number);
                pci_dev_put(dev);
                ret = -EEXIST;
                goto out;
@@ -62,8 +61,7 @@ int pciehp_configure_device(struct slot *p_slot)
        }
 
        list_for_each_entry(dev, &parent->devices, bus_list)
-               if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
-                               (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS))
+               if (pci_is_bridge(dev))
                        pci_hp_add_bridge(dev);
 
        pci_assign_unassigned_bridge_resources(bridge);
index ac69094e4b2089804ce41b00730d81c487adebf7..d062c008fc95ffa0f075a7189e9467bbed9737dd 100644 (file)
@@ -51,7 +51,7 @@ static LIST_HEAD(slot_list);
 #define dbg(format, arg...)                                    \
        do {                                                    \
                if (debug)                                      \
-                       printk (KERN_DEBUG "%s: " format "\n",  \
+                       printk(KERN_DEBUG "%s: " format "\n",   \
                                MY_NAME , ## arg);              \
        } while (0)
 #define err(format, arg...) printk(KERN_ERR "%s: " format "\n", MY_NAME , ## arg)
@@ -128,18 +128,18 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 status)
        dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        switch (status) {
-               case 0:
-                       /*
-                        * Fill in code here to turn light off
-                        */
-                       break;
-
-               case 1:
-               default:
-                       /*
-                        * Fill in code here to turn light on
-                        */
-                       break;
+       case 0:
+               /*
+                * Fill in code here to turn light off
+                */
+               break;
+
+       case 1:
+       default:
+               /*
+                * Fill in code here to turn light on
+                */
+               break;
        }
 
        return retval;
@@ -153,12 +153,12 @@ static int hardware_test(struct hotplug_slot *hotplug_slot, u32 value)
        dbg("%s - physical_slot = %s\n", __func__, hotplug_slot->name);
 
        switch (value) {
-               case 0:
-                       /* Specify a test here */
-                       break;
-               case 1:
-                       /* Specify another test here */
-                       break;
+       case 0:
+               /* Specify a test here */
+               break;
+       case 1:
+               /* Specify another test here */
+               break;
        }
 
        return retval;
index 16f9203523179c46e99505443675c964f16f4b1a..e246a10a0d2c5e4eb729e3d4c822f6dda19f176a 100644 (file)
@@ -160,8 +160,7 @@ void pci_configure_slot(struct pci_dev *dev)
                        (dev->class >> 8) == PCI_CLASS_BRIDGE_PCI)))
                return;
 
-       if (dev->bus)
-               pcie_bus_configure_settings(dev->bus);
+       pcie_bus_configure_settings(dev->bus);
 
        memset(&hpp, 0, sizeof(hpp));
        ret = pci_get_hp_params(dev, &hpp);
index 4fcdeedda31b8eedc44101fb2ecc05d45bcb7f1c..7660232ef4607f45377c62452c92661d7d54d2a0 100644 (file)
@@ -157,8 +157,7 @@ static void dlpar_pci_add_bus(struct device_node *dn)
        }
 
        /* Scan below the new bridge */
-       if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-           dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
+       if (pci_is_bridge(dev))
                of_scan_pci_bridge(dev);
 
        /* Map IO space for child bus, which may or may not succeed */
index 4796c15fba941df07c4d3bbeed94413d2df48473..93aa29f6d39c5b3a06e699f13f72a8c960b7da34 100644 (file)
@@ -39,6 +39,7 @@
 
 bool rpaphp_debug;
 LIST_HEAD(rpaphp_slot_head);
+EXPORT_SYMBOL_GPL(rpaphp_slot_head);
 
 #define DRIVER_VERSION "0.1"
 #define DRIVER_AUTHOR  "Linda Xie <lxie@us.ibm.com>"
@@ -88,7 +89,7 @@ static int set_attention_status(struct hotplug_slot *hotplug_slot, u8 value)
  * @hotplug_slot: slot to get status
  * @value: pointer to store status
  */
-static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
+static int get_power_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
        int retval, level;
        struct slot *slot = (struct slot *)hotplug_slot->private;
@@ -104,14 +105,14 @@ static int get_power_status(struct hotplug_slot *hotplug_slot, u8 * value)
  * @hotplug_slot: slot to get status
  * @value: pointer to store status
  */
-static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 * value)
+static int get_attention_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
        struct slot *slot = (struct slot *)hotplug_slot->private;
        *value = slot->hotplug_slot->info->attention_status;
        return 0;
 }
 
-static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 * value)
+static int get_adapter_status(struct hotplug_slot *hotplug_slot, u8 *value)
 {
        struct slot *slot = (struct slot *)hotplug_slot->private;
        int rc, state;
@@ -223,16 +224,16 @@ int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
        type_tmp = (char *) &types[1];
 
        /* Iterate through parent properties, looking for my-drc-index */
-       for (i = 0; i < indexes[0]; i++) {
+       for (i = 0; i < be32_to_cpu(indexes[0]); i++) {
                if ((unsigned int) indexes[i + 1] == *my_index) {
                        if (drc_name)
                                *drc_name = name_tmp;
                        if (drc_type)
                                *drc_type = type_tmp;
                        if (drc_index)
-                               *drc_index = *my_index;
+                               *drc_index = be32_to_cpu(*my_index);
                        if (drc_power_domain)
-                               *drc_power_domain = domains[i+1];
+                               *drc_power_domain = be32_to_cpu(domains[i+1]);
                        return 0;
                }
                name_tmp += (strlen(name_tmp) + 1);
@@ -241,6 +242,7 @@ int rpaphp_get_drc_props(struct device_node *dn, int *drc_index,
 
        return -EINVAL;
 }
+EXPORT_SYMBOL_GPL(rpaphp_get_drc_props);
 
 static int is_php_type(char *drc_type)
 {
@@ -321,16 +323,19 @@ int rpaphp_add_slot(struct device_node *dn)
        /* register PCI devices */
        name = (char *) &names[1];
        type = (char *) &types[1];
-       for (i = 0; i < indexes[0]; i++) {
+       for (i = 0; i < be32_to_cpu(indexes[0]); i++) {
+               int index;
 
-               slot = alloc_slot_struct(dn, indexes[i + 1], name, power_domains[i + 1]);
+               index = be32_to_cpu(indexes[i + 1]);
+               slot = alloc_slot_struct(dn, index, name,
+                                        be32_to_cpu(power_domains[i + 1]));
                if (!slot)
                        return -ENOMEM;
 
                slot->type = simple_strtoul(type, NULL, 10);
 
                dbg("Found drc-index:0x%x drc-name:%s drc-type:%s\n",
-                               indexes[i + 1], name, type);
+                               index, name, type);
 
                retval = rpaphp_enable_slot(slot);
                if (!retval)
@@ -347,6 +352,7 @@ int rpaphp_add_slot(struct device_node *dn)
        /* XXX FIXME: reports a failure only if last entry in loop failed */
        return retval;
 }
+EXPORT_SYMBOL_GPL(rpaphp_add_slot);
 
 static void __exit cleanup_slots(void)
 {
@@ -440,7 +446,3 @@ struct hotplug_slot_ops rpaphp_hotplug_slot_ops = {
 
 module_init(rpaphp_init);
 module_exit(rpaphp_exit);
-
-EXPORT_SYMBOL_GPL(rpaphp_add_slot);
-EXPORT_SYMBOL_GPL(rpaphp_slot_head);
-EXPORT_SYMBOL_GPL(rpaphp_get_drc_props);
index 8d2ce22151eb62001e0a2184e1f68da1a606dec5..d1332d2f8730cde2ffc8775f3a8ce46d2d7baaae 100644 (file)
@@ -15,7 +15,6 @@
 #include <linux/slab.h>
 #include <linux/pci.h>
 #include <linux/pci_hotplug.h>
-#include <linux/init.h>
 #include <asm/pci_debug.h>
 #include <asm/sclp.h>
 
index 613043f7576f302c75bb5727d4dff910dd0aaaf2..bada209998705732e488a9e5e4dbb0139a43ad90 100644 (file)
@@ -188,7 +188,7 @@ static int sn_hp_slot_private_alloc(struct hotplug_slot *bss_hotplug_slot,
        return 0;
 }
 
-static struct hotplug_slot * sn_hp_destroy(void)
+static struct hotplug_slot *sn_hp_destroy(void)
 {
        struct slot *slot;
        struct pci_slot *pci_slot;
@@ -250,15 +250,13 @@ static int sn_slot_enable(struct hotplug_slot *bss_hotplug_slot,
        }
 
        if (rc == PCI_L1_ERR) {
-               dev_dbg(&slot->pci_bus->self->dev,
-                       "L1 failure %d with message: %s",
+               dev_dbg(&slot->pci_bus->self->dev, "L1 failure %d with message: %s",
                        resp.resp_sub_errno, resp.resp_l1_msg);
                return -EPERM;
        }
 
        if (rc) {
-               dev_dbg(&slot->pci_bus->self->dev,
-                       "insert failed with error %d sub-error %d\n",
+               dev_dbg(&slot->pci_bus->self->dev, "insert failed with error %d sub-error %d\n",
                        rc, resp.resp_sub_errno);
                return -EIO;
        }
@@ -288,21 +286,18 @@ static int sn_slot_disable(struct hotplug_slot *bss_hotplug_slot,
        }
 
        if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_EMPTY_33MHZ)) {
-               dev_dbg(&slot->pci_bus->self->dev,
-                       "Cannot remove last 33MHz card\n");
+               dev_dbg(&slot->pci_bus->self->dev, "Cannot remove last 33MHz card\n");
                return -EPERM;
        }
 
        if ((action == PCI_REQ_SLOT_ELIGIBLE) && (rc == PCI_L1_ERR)) {
-               dev_dbg(&slot->pci_bus->self->dev,
-                       "L1 failure %d with message \n%s\n",
+               dev_dbg(&slot->pci_bus->self->dev, "L1 failure %d with message \n%s\n",
                        resp.resp_sub_errno, resp.resp_l1_msg);
                return -EPERM;
        }
 
        if ((action == PCI_REQ_SLOT_ELIGIBLE) && rc) {
-               dev_dbg(&slot->pci_bus->self->dev,
-                       "remove failed with error %d sub-error %d\n",
+               dev_dbg(&slot->pci_bus->self->dev, "remove failed with error %d sub-error %d\n",
                        rc, resp.resp_sub_errno);
                return -EIO;
        }
@@ -417,8 +412,7 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
                phandle = acpi_device_handle(PCI_CONTROLLER(slot->pci_bus)->companion);
 
                if (acpi_bus_get_device(phandle, &pdevice)) {
-                       dev_dbg(&slot->pci_bus->self->dev,
-                               "no parent device, assuming NULL\n");
+                       dev_dbg(&slot->pci_bus->self->dev, "no parent device, assuming NULL\n");
                        pdevice = NULL;
                }
 
@@ -447,10 +441,8 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
 
                                ret = acpi_bus_scan(chandle);
                                if (ACPI_FAILURE(ret)) {
-                                       printk(KERN_ERR "%s: acpi_bus_scan "
-                                              "failed (0x%x) for slot %d "
-                                              "func %d\n", __func__,
-                                              ret, (int)(adr>>16),
+                                       printk(KERN_ERR "%s: acpi_bus_scan failed (0x%x) for slot %d func %d\n",
+                                              __func__, ret, (int)(adr>>16),
                                               (int)(adr&0xffff));
                                        /* try to continue on */
                                }
@@ -471,11 +463,9 @@ static int enable_slot(struct hotplug_slot *bss_hotplug_slot)
        mutex_unlock(&sn_hotplug_mutex);
 
        if (rc == 0)
-               dev_dbg(&slot->pci_bus->self->dev,
-                       "insert operation successful\n");
+               dev_dbg(&slot->pci_bus->self->dev, "insert operation successful\n");
        else
-               dev_dbg(&slot->pci_bus->self->dev,
-                       "insert operation failed rc = %d\n", rc);
+               dev_dbg(&slot->pci_bus->self->dev, "insert operation failed rc = %d\n", rc);
 
        return rc;
 }
@@ -561,8 +551,7 @@ static int disable_slot(struct hotplug_slot *bss_hotplug_slot)
                acpi_status ret;
                ret = acpi_unload_table_id(ssdt_id);
                if (ACPI_FAILURE(ret)) {
-                       printk(KERN_ERR "%s: acpi_unload_table_id "
-                              "failed (0x%x) for id %d\n",
+                       printk(KERN_ERR "%s: acpi_unload_table_id failed (0x%x) for id %d\n",
                               __func__, ret, ssdt_id);
                        /* try to continue on */
                }
index 61529097464d4402f19d22dd33b77433b16c5413..5897d516427baca60ef032f781e14ffec7db78bc 100644 (file)
@@ -180,7 +180,7 @@ int shpchp_configure_device(struct slot *p_slot);
 int shpchp_unconfigure_device(struct slot *p_slot);
 void cleanup_slots(struct controller *ctrl);
 void shpchp_queue_pushbutton_work(struct work_struct *work);
-int shpc_init( struct controller *ctrl, struct pci_dev *pdev);
+int shpc_init(struct controller *ctrl, struct pci_dev *pdev);
 
 static inline const char *slot_name(struct slot *slot)
 {
@@ -295,7 +295,7 @@ static inline void amd_pogo_errata_restore_misc_reg(struct slot *p_slot)
                pci_write_config_dword(p_slot->ctrl->pci_dev, PCIX_MEM_BASE_LIMIT_OFFSET, rse_set);
        }
        /* restore MiscII register */
-       pci_read_config_dword( p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, &pcix_misc2_temp );
+       pci_read_config_dword(p_slot->ctrl->pci_dev, PCIX_MISCII_OFFSET, &pcix_misc2_temp );
 
        if (p_slot->ctrl->pcix_misc2_reg & SERRFATALENABLE_MASK)
                pcix_misc2_temp |= SERRFATALENABLE_MASK;
index faf13abd5b99ded8d19fe2461c6807ac0e883ebf..294ef4b10cf198031da6a67e91c10ef965cffccf 100644 (file)
@@ -143,8 +143,7 @@ static int init_slots(struct controller *ctrl)
                snprintf(name, SLOT_NAME_SIZE, "%d", slot->number);
                hotplug_slot->ops = &shpchp_hotplug_slot_ops;
 
-               ctrl_dbg(ctrl, "Registering domain:bus:dev=%04x:%02x:%02x "
-                        "hp_slot=%x sun=%x slot_device_offset=%x\n",
+               ctrl_dbg(ctrl, "Registering domain:bus:dev=%04x:%02x:%02x hp_slot=%x sun=%x slot_device_offset=%x\n",
                         pci_domain_nr(ctrl->pci_dev->subordinate),
                         slot->bus, slot->device, slot->hp_slot, slot->number,
                         ctrl->slot_device_offset);
index 58499277903a4ab4a6225982d88876de399120e2..e57972366c910f81b4bbdab2ae3e254b159a3378 100644 (file)
@@ -162,7 +162,7 @@ u8 shpchp_handle_power_fault(u8 hp_slot, struct controller *ctrl)
 
        p_slot = shpchp_find_slot(ctrl, hp_slot + ctrl->slot_device_offset);
 
-       if ( !(p_slot->hpc_ops->query_power_fault(p_slot))) {
+       if (!(p_slot->hpc_ops->query_power_fault(p_slot))) {
                /*
                 * Power fault Cleared
                 */
@@ -196,8 +196,8 @@ static int change_bus_speed(struct controller *ctrl, struct slot *p_slot,
 
        ctrl_dbg(ctrl, "Change speed to %d\n", speed);
        if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, speed))) {
-               ctrl_err(ctrl, "%s: Issue of set bus speed mode command "
-                        "failed\n", __func__);
+               ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n",
+                        __func__);
                return WRONG_BUS_FREQUENCY;
        }
        return rc;
@@ -215,8 +215,8 @@ static int fix_bus_speed(struct controller *ctrl, struct slot *pslot,
         */
        if (flag) {
                if (asp < bsp) {
-                       ctrl_err(ctrl, "Speed of bus %x and adapter %x "
-                                "mismatch\n", bsp, asp);
+                       ctrl_err(ctrl, "Speed of bus %x and adapter %x mismatch\n",
+                                bsp, asp);
                        rc = WRONG_BUS_FREQUENCY;
                }
                return rc;
@@ -250,8 +250,7 @@ static int board_added(struct slot *p_slot)
 
        hp_slot = p_slot->device - ctrl->slot_device_offset;
 
-       ctrl_dbg(ctrl,
-                "%s: p_slot->device, slot_offset, hp_slot = %d, %d ,%d\n",
+       ctrl_dbg(ctrl, "%s: p_slot->device, slot_offset, hp_slot = %d, %d ,%d\n",
                 __func__, p_slot->device, ctrl->slot_device_offset, hp_slot);
 
        /* Power on slot without connecting to bus */
@@ -263,8 +262,8 @@ static int board_added(struct slot *p_slot)
 
        if ((ctrl->pci_dev->vendor == 0x8086) && (ctrl->pci_dev->device == 0x0332)) {
                if ((rc = p_slot->hpc_ops->set_bus_speed_mode(p_slot, PCI_SPEED_33MHz))) {
-                       ctrl_err(ctrl, "%s: Issue of set bus speed mode command"
-                                " failed\n", __func__);
+                       ctrl_err(ctrl, "%s: Issue of set bus speed mode command failed\n",
+                                __func__);
                        return WRONG_BUS_FREQUENCY;
                }
 
@@ -277,8 +276,7 @@ static int board_added(struct slot *p_slot)
 
        rc = p_slot->hpc_ops->get_adapter_speed(p_slot, &asp);
        if (rc) {
-               ctrl_err(ctrl, "Can't get adapter speed or "
-                        "bus mode mismatch\n");
+               ctrl_err(ctrl, "Can't get adapter speed or bus mode mismatch\n");
                return WRONG_BUS_FREQUENCY;
        }
 
@@ -289,8 +287,8 @@ static int board_added(struct slot *p_slot)
        if (!list_empty(&ctrl->pci_dev->subordinate->devices))
                slots_not_empty = 1;
 
-       ctrl_dbg(ctrl, "%s: slots_not_empty %d, adapter_speed %d, bus_speed %d,"
-                " max_bus_speed %d\n", __func__, slots_not_empty, asp,
+       ctrl_dbg(ctrl, "%s: slots_not_empty %d, adapter_speed %d, bus_speed %d, max_bus_speed %d\n",
+                __func__, slots_not_empty, asp,
                 bsp, msp);
 
        rc = fix_bus_speed(ctrl, p_slot, slots_not_empty, asp, bsp, msp);
@@ -490,12 +488,12 @@ static void handle_button_press_event(struct slot *p_slot)
                p_slot->hpc_ops->get_power_status(p_slot, &getstatus);
                if (getstatus) {
                        p_slot->state = BLINKINGOFF_STATE;
-                       ctrl_info(ctrl, "PCI slot #%s - powering off due to "
-                                 "button press.\n", slot_name(p_slot));
+                       ctrl_info(ctrl, "PCI slot #%s - powering off due to button press\n",
+                                 slot_name(p_slot));
                } else {
                        p_slot->state = BLINKINGON_STATE;
-                       ctrl_info(ctrl, "PCI slot #%s - powering on due to "
-                                 "button press.\n", slot_name(p_slot));
+                       ctrl_info(ctrl, "PCI slot #%s - powering on due to button press\n",
+                                 slot_name(p_slot));
                }
                /* blink green LED and turn off amber */
                p_slot->hpc_ops->green_led_blink(p_slot);
@@ -518,8 +516,8 @@ static void handle_button_press_event(struct slot *p_slot)
                else
                        p_slot->hpc_ops->green_led_off(p_slot);
                p_slot->hpc_ops->set_attention_status(p_slot, 0);
-               ctrl_info(ctrl, "PCI slot #%s - action canceled due to "
-                         "button press\n", slot_name(p_slot));
+               ctrl_info(ctrl, "PCI slot #%s - action canceled due to button press\n",
+                         slot_name(p_slot));
                p_slot->state = STATIC_STATE;
                break;
        case POWEROFF_STATE:
index 2d7f474ca0ec7036d023dbc1b413375bb0fd37ae..29e22352822cb64ee7c3ae8bf3341e1d19abac1d 100644 (file)
@@ -341,8 +341,7 @@ static int shpc_write_cmd(struct slot *slot, u8 t_slot, u8 cmd)
 
        cmd_status = hpc_check_cmd_status(slot->ctrl);
        if (cmd_status) {
-               ctrl_err(ctrl,
-                        "Failed to issued command 0x%x (error code = %d)\n",
+               ctrl_err(ctrl, "Failed to issued command 0x%x (error code = %d)\n",
                         cmd, cmd_status);
                retval = -EIO;
        }
@@ -404,7 +403,7 @@ static int hpc_get_attention_status(struct slot *slot, u8 *status)
        return 0;
 }
 
-static int hpc_get_power_status(struct slot * slot, u8 *status)
+static int hpc_get_power_status(struct slot *slot, u8 *status)
 {
        struct controller *ctrl = slot->ctrl;
        u32 slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot));
@@ -528,7 +527,7 @@ static int hpc_get_mode1_ECC_cap(struct slot *slot, u8 *mode)
        return retval;
 }
 
-static int hpc_query_power_fault(struct slot * slot)
+static int hpc_query_power_fault(struct slot *slot)
 {
        struct controller *ctrl = slot->ctrl;
        u32 slot_reg = shpc_readl(ctrl, SLOT_REG(slot->hp_slot));
@@ -614,7 +613,7 @@ static void hpc_release_ctlr(struct controller *ctrl)
        release_mem_region(ctrl->mmio_base, ctrl->mmio_size);
 }
 
-static int hpc_power_on_slot(struct slot * slot)
+static int hpc_power_on_slot(struct slot *slot)
 {
        int retval;
 
@@ -625,7 +624,7 @@ static int hpc_power_on_slot(struct slot * slot)
        return retval;
 }
 
-static int hpc_slot_enable(struct slot * slot)
+static int hpc_slot_enable(struct slot *slot)
 {
        int retval;
 
@@ -638,7 +637,7 @@ static int hpc_slot_enable(struct slot * slot)
        return retval;
 }
 
-static int hpc_slot_disable(struct slot * slot)
+static int hpc_slot_disable(struct slot *slot)
 {
        int retval;
 
@@ -720,7 +719,7 @@ static int shpc_get_cur_bus_speed(struct controller *ctrl)
 }
 
 
-static int hpc_set_bus_speed_mode(struct slot * slot, enum pci_bus_speed value)
+static int hpc_set_bus_speed_mode(struct slot *slot, enum pci_bus_speed value)
 {
        int retval;
        struct controller *ctrl = slot->ctrl;
@@ -974,8 +973,8 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev)
                for (i = 0; i < 9 + num_slots; i++) {
                        rc = shpc_indirect_read(ctrl, i, &tempdword);
                        if (rc) {
-                               ctrl_err(ctrl,
-                                        "Cannot read creg (index = %d)\n", i);
+                               ctrl_err(ctrl, "Cannot read creg (index = %d)\n",
+                                        i);
                                goto abort;
                        }
                        ctrl_dbg(ctrl, " offset %d: value %x\n", i, tempdword);
@@ -1060,10 +1059,8 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev)
                /* Installs the interrupt handler */
                rc = pci_enable_msi(pdev);
                if (rc) {
-                       ctrl_info(ctrl,
-                                 "Can't get msi for the hotplug controller\n");
-                       ctrl_info(ctrl,
-                                 "Use INTx for the hotplug controller\n");
+                       ctrl_info(ctrl, "Can't get msi for the hotplug controller\n");
+                       ctrl_info(ctrl, "Use INTx for the hotplug controller\n");
                }
 
                rc = request_irq(ctrl->pci_dev->irq, shpc_isr, IRQF_SHARED,
@@ -1071,8 +1068,8 @@ int shpc_init(struct controller *ctrl, struct pci_dev *pdev)
                ctrl_dbg(ctrl, "request_irq %d (returns %d)\n",
                         ctrl->pci_dev->irq, rc);
                if (rc) {
-                       ctrl_err(ctrl, "Can't get irq %d for the hotplug "
-                                "controller\n", ctrl->pci_dev->irq);
+                       ctrl_err(ctrl, "Can't get irq %d for the hotplug controller\n",
+                                ctrl->pci_dev->irq);
                        goto abort_iounmap;
                }
        }
index 2bf69fe1926c6b503283c43b954779ceaf2ea1d7..469454e0cc48d8eca080dc2f5035f87d83769f53 100644 (file)
@@ -34,7 +34,7 @@
 #include "../pci.h"
 #include "shpchp.h"
 
-int __ref shpchp_configure_device(struct slot *p_slot)
+int shpchp_configure_device(struct slot *p_slot)
 {
        struct pci_dev *dev;
        struct controller *ctrl = p_slot->ctrl;
@@ -46,9 +46,9 @@ int __ref shpchp_configure_device(struct slot *p_slot)
 
        dev = pci_get_slot(parent, PCI_DEVFN(p_slot->device, 0));
        if (dev) {
-               ctrl_err(ctrl, "Device %s already exists "
-                        "at %04x:%02x:%02x, cannot hot-add\n", pci_name(dev),
-                        pci_domain_nr(parent), p_slot->bus, p_slot->device);
+               ctrl_err(ctrl, "Device %s already exists at %04x:%02x:%02x, cannot hot-add\n",
+                        pci_name(dev), pci_domain_nr(parent),
+                        p_slot->bus, p_slot->device);
                pci_dev_put(dev);
                ret = -EINVAL;
                goto out;
@@ -64,8 +64,7 @@ int __ref shpchp_configure_device(struct slot *p_slot)
        list_for_each_entry(dev, &parent->devices, bus_list) {
                if (PCI_SLOT(dev->devfn) != p_slot->device)
                        continue;
-               if ((dev->hdr_type == PCI_HEADER_TYPE_BRIDGE) ||
-                   (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS))
+               if (pci_is_bridge(dev))
                        pci_hp_add_bridge(dev);
        }
 
index e8c31fe20566fbd839c7c236b234ab873f2eb428..52875b36046384fd8937a15d7a9d9b9cd06bebce 100644 (file)
@@ -38,7 +38,7 @@
 static ssize_t show_ctrl (struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct pci_dev *pdev;
-       char * out = buf;
+       char *out = buf;
        int index, busnr;
        struct resource *res;
        struct pci_bus *bus;
index 6e373ea57b32834df2076b26b4f0d72941933644..5d50b54bb51c231b90019515d0c882d2b090f4e6 100644 (file)
@@ -105,7 +105,7 @@ int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update)
        spin_unlock_irqrestore(&ht_irq_lock, flags);
 
        max_irq = (data >> 16) & 0xff;
-       if ( idx > max_irq)
+       if (idx > max_irq)
                return -EINVAL;
 
        cfg = kmalloc(sizeof(*cfg), GFP_KERNEL);
@@ -136,6 +136,7 @@ int __ht_create_irq(struct pci_dev *dev, int idx, ht_irq_update_t *update)
 
        return irq;
 }
+EXPORT_SYMBOL(__ht_create_irq);
 
 /**
  * ht_create_irq - create an irq and attach it to a device.
@@ -151,6 +152,7 @@ int ht_create_irq(struct pci_dev *dev, int idx)
 {
        return __ht_create_irq(dev, idx, NULL);
 }
+EXPORT_SYMBOL(ht_create_irq);
 
 /**
  * ht_destroy_irq - destroy an irq created with ht_create_irq
@@ -170,7 +172,4 @@ void ht_destroy_irq(unsigned int irq)
 
        kfree(cfg);
 }
-
-EXPORT_SYMBOL(__ht_create_irq);
-EXPORT_SYMBOL(ht_create_irq);
 EXPORT_SYMBOL(ht_destroy_irq);
index de7a74782f929234d808aef1abac26097f1abfe3..cb6f24740ee3e5b3f6763f7b25c2bf8700e6a1b2 100644 (file)
@@ -106,7 +106,7 @@ static int virtfn_add(struct pci_dev *dev, int id, int reset)
        pci_device_add(virtfn, virtfn->bus);
        mutex_unlock(&iov->dev->sriov->lock);
 
-       rc = pci_bus_add_device(virtfn);
+       pci_bus_add_device(virtfn);
        sprintf(buf, "virtfn%u", id);
        rc = sysfs_create_link(&dev->dev.kobj, &virtfn->dev.kobj, buf);
        if (rc)
index 955ab7990c5bd7045f2bf896e6d4c65989176089..13f3d303727296821f25fde0b7acd22106a3fc3b 100644 (file)
@@ -10,7 +10,6 @@
 #include <linux/mm.h>
 #include <linux/irq.h>
 #include <linux/interrupt.h>
-#include <linux/init.h>
 #include <linux/export.h>
 #include <linux/ioport.h>
 #include <linux/pci.h>
@@ -414,7 +413,7 @@ static void free_msi_irqs(struct pci_dev *dev)
        if (dev->msi_irq_groups) {
                sysfs_remove_groups(&dev->dev.kobj, dev->msi_irq_groups);
                msi_attrs = dev->msi_irq_groups[0]->attrs;
-               list_for_each_entry(entry, &dev->msi_list, list) {
+               while (msi_attrs[count]) {
                        dev_attr = container_of(msi_attrs[count],
                                                struct device_attribute, attr);
                        kfree(dev_attr->attr.name);
@@ -544,22 +543,18 @@ static int populate_msi_sysfs(struct pci_dev *pdev)
        if (!msi_attrs)
                return -ENOMEM;
        list_for_each_entry(entry, &pdev->msi_list, list) {
-               char *name = kmalloc(20, GFP_KERNEL);
-               if (!name)
-                       goto error_attrs;
-
                msi_dev_attr = kzalloc(sizeof(*msi_dev_attr), GFP_KERNEL);
-               if (!msi_dev_attr) {
-                       kfree(name);
+               if (!msi_dev_attr)
                        goto error_attrs;
-               }
+               msi_attrs[count] = &msi_dev_attr->attr;
 
-               sprintf(name, "%d", entry->irq);
                sysfs_attr_init(&msi_dev_attr->attr);
-               msi_dev_attr->attr.name = name;
+               msi_dev_attr->attr.name = kasprintf(GFP_KERNEL, "%d",
+                                                   entry->irq);
+               if (!msi_dev_attr->attr.name)
+                       goto error_attrs;
                msi_dev_attr->attr.mode = S_IRUGO;
                msi_dev_attr->show = msi_mode_show;
-               msi_attrs[count] = &msi_dev_attr->attr;
                ++count;
        }
 
@@ -883,50 +878,6 @@ int pci_msi_vec_count(struct pci_dev *dev)
 }
 EXPORT_SYMBOL(pci_msi_vec_count);
 
-/**
- * pci_enable_msi_block - configure device's MSI capability structure
- * @dev: device to configure
- * @nvec: number of interrupts to configure
- *
- * Allocate IRQs for a device with the MSI capability.
- * This function returns a negative errno if an error occurs.  If it
- * is unable to allocate the number of interrupts requested, it returns
- * the number of interrupts it might be able to allocate.  If it successfully
- * allocates at least the number of interrupts requested, it returns 0 and
- * updates the @dev's irq member to the lowest new interrupt number; the
- * other interrupt numbers allocated to this device are consecutive.
- */
-int pci_enable_msi_block(struct pci_dev *dev, int nvec)
-{
-       int status, maxvec;
-
-       if (dev->current_state != PCI_D0)
-               return -EINVAL;
-
-       maxvec = pci_msi_vec_count(dev);
-       if (maxvec < 0)
-               return maxvec;
-       if (nvec > maxvec)
-               return maxvec;
-
-       status = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI);
-       if (status)
-               return status;
-
-       WARN_ON(!!dev->msi_enabled);
-
-       /* Check whether driver already requested MSI-X irqs */
-       if (dev->msix_enabled) {
-               dev_info(&dev->dev, "can't enable MSI "
-                        "(MSI-X already enabled)\n");
-               return -EINVAL;
-       }
-
-       status = msi_capability_init(dev, nvec);
-       return status;
-}
-EXPORT_SYMBOL(pci_enable_msi_block);
-
 void pci_msi_shutdown(struct pci_dev *dev)
 {
        struct msi_desc *desc;
@@ -1029,8 +980,7 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec)
 
        /* Check whether driver already requested for MSI irq */
        if (dev->msi_enabled) {
-               dev_info(&dev->dev, "can't enable MSI-X "
-                      "(MSI IRQ already assigned)\n");
+               dev_info(&dev->dev, "can't enable MSI-X (MSI IRQ already assigned)\n");
                return -EINVAL;
        }
        status = msix_capability_init(dev, entries, nvec);
@@ -1132,14 +1082,45 @@ void pci_msi_init_pci_dev(struct pci_dev *dev)
  **/
 int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec)
 {
-       int nvec = maxvec;
+       int nvec;
        int rc;
 
+       if (dev->current_state != PCI_D0)
+               return -EINVAL;
+
+       WARN_ON(!!dev->msi_enabled);
+
+       /* Check whether driver already requested MSI-X irqs */
+       if (dev->msix_enabled) {
+               dev_info(&dev->dev,
+                        "can't enable MSI (MSI-X already enabled)\n");
+               return -EINVAL;
+       }
+
        if (maxvec < minvec)
                return -ERANGE;
 
+       nvec = pci_msi_vec_count(dev);
+       if (nvec < 0)
+               return nvec;
+       else if (nvec < minvec)
+               return -EINVAL;
+       else if (nvec > maxvec)
+               nvec = maxvec;
+
+       do {
+               rc = pci_msi_check_device(dev, nvec, PCI_CAP_ID_MSI);
+               if (rc < 0) {
+                       return rc;
+               } else if (rc > 0) {
+                       if (rc < minvec)
+                               return -ENOSPC;
+                       nvec = rc;
+               }
+       } while (rc);
+
        do {
-               rc = pci_enable_msi_block(dev, nvec);
+               rc = msi_capability_init(dev, nvec);
                if (rc < 0) {
                        return rc;
                } else if (rc > 0) {
index f49abef884852d3780b1d0fdb354257fee0235bf..ca4927ba84334a2b64b09b8b2e9eb60564024f65 100644 (file)
@@ -309,13 +309,7 @@ static struct acpi_device *acpi_pci_find_companion(struct device *dev)
        bool check_children;
        u64 addr;
 
-       /*
-        * pci_is_bridge() is not suitable here, because pci_dev->subordinate
-        * is set only after acpi_pci_find_device() has been called for the
-        * given device.
-        */
-       check_children = pci_dev->hdr_type == PCI_HEADER_TYPE_BRIDGE
-                       || pci_dev->hdr_type == PCI_HEADER_TYPE_CARDBUS;
+       check_children = pci_is_bridge(pci_dev);
        /* Please ref to ACPI spec for the syntax of _ADR */
        addr = (PCI_SLOT(pci_dev->devfn) << 16) | PCI_FUNC(pci_dev->devfn);
        return acpi_find_child_device(ACPI_COMPANION(dev->parent), addr,
index d911e0c1f359799ef4f110b59b2f68516868d153..3f8e3dbcaa7cbcc4d9cabb4b89685c56461f0a7d 100644 (file)
@@ -77,6 +77,7 @@ int pci_add_dynid(struct pci_driver *drv,
 
        return retval;
 }
+EXPORT_SYMBOL_GPL(pci_add_dynid);
 
 static void pci_free_dynids(struct pci_driver *drv)
 {
@@ -98,16 +99,16 @@ static void pci_free_dynids(struct pci_driver *drv)
  *
  * Allow PCI IDs to be added to an existing driver via sysfs.
  */
-static ssize_t
-store_new_id(struct device_driver *driver, const char *buf, size_t count)
+static ssize_t store_new_id(struct device_driver *driver, const char *buf,
+                           size_t count)
 {
        struct pci_driver *pdrv = to_pci_driver(driver);
        const struct pci_device_id *ids = pdrv->id_table;
-       __u32 vendor, device, subvendor=PCI_ANY_ID,
-               subdevice=PCI_ANY_ID, class=0, class_mask=0;
-       unsigned long driver_data=0;
-       int fields=0;
-       int retval;
+       __u32 vendor, device, subvendor = PCI_ANY_ID,
+               subdevice = PCI_ANY_ID, class = 0, class_mask = 0;
+       unsigned long driver_data = 0;
+       int fields = 0;
+       int retval = 0;
 
        fields = sscanf(buf, "%x %x %x %x %x %x %lx",
                        &vendor, &device, &subvendor, &subdevice,
@@ -115,6 +116,26 @@ store_new_id(struct device_driver *driver, const char *buf, size_t count)
        if (fields < 2)
                return -EINVAL;
 
+       if (fields != 7) {
+               struct pci_dev *pdev = kzalloc(sizeof(*pdev), GFP_KERNEL);
+               if (!pdev)
+                       return -ENOMEM;
+
+               pdev->vendor = vendor;
+               pdev->device = device;
+               pdev->subsystem_vendor = subvendor;
+               pdev->subsystem_device = subdevice;
+               pdev->class = class;
+
+               if (pci_match_id(pdrv->id_table, pdev))
+                       retval = -EEXIST;
+
+               kfree(pdev);
+
+               if (retval)
+                       return retval;
+       }
+
        /* Only accept driver_data values that match an existing id_table
           entry */
        if (ids) {
@@ -146,8 +167,8 @@ static DRIVER_ATTR(new_id, S_IWUSR, NULL, store_new_id);
  *
  * Removes a dynamic pci device ID to this driver.
  */
-static ssize_t
-store_remove_id(struct device_driver *driver, const char *buf, size_t count)
+static ssize_t store_remove_id(struct device_driver *driver, const char *buf,
+                              size_t count)
 {
        struct pci_dynid *dynid, *n;
        struct pci_driver *pdrv = to_pci_driver(driver);
@@ -215,6 +236,14 @@ const struct pci_device_id *pci_match_id(const struct pci_device_id *ids,
        }
        return NULL;
 }
+EXPORT_SYMBOL(pci_match_id);
+
+static const struct pci_device_id pci_device_id_any = {
+       .vendor = PCI_ANY_ID,
+       .device = PCI_ANY_ID,
+       .subvendor = PCI_ANY_ID,
+       .subdevice = PCI_ANY_ID,
+};
 
 /**
  * pci_match_device - Tell if a PCI device structure has a matching PCI device id structure
@@ -229,18 +258,30 @@ static const struct pci_device_id *pci_match_device(struct pci_driver *drv,
                                                    struct pci_dev *dev)
 {
        struct pci_dynid *dynid;
+       const struct pci_device_id *found_id = NULL;
+
+       /* When driver_override is set, only bind to the matching driver */
+       if (dev->driver_override && strcmp(dev->driver_override, drv->name))
+               return NULL;
 
        /* Look at the dynamic ids first, before the static ones */
        spin_lock(&drv->dynids.lock);
        list_for_each_entry(dynid, &drv->dynids.list, node) {
                if (pci_match_one_device(&dynid->id, dev)) {
-                       spin_unlock(&drv->dynids.lock);
-                       return &dynid->id;
+                       found_id = &dynid->id;
+                       break;
                }
        }
        spin_unlock(&drv->dynids.lock);
 
-       return pci_match_id(drv->id_table, dev);
+       if (!found_id)
+               found_id = pci_match_id(drv->id_table, dev);
+
+       /* driver_override will always match, send a dummy id */
+       if (!found_id && dev->driver_override)
+               found_id = &pci_device_id_any;
+
+       return found_id;
 }
 
 struct drv_dev_and_id {
@@ -333,8 +374,7 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
  * returns 0 on success, else error.
  * side-effect: pci_dev->driver is set to drv when drv claims pci_dev.
  */
-static int
-__pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev)
+static int __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev)
 {
        const struct pci_device_id *id;
        int error = 0;
@@ -351,7 +391,7 @@ __pci_device_probe(struct pci_driver *drv, struct pci_dev *pci_dev)
        return error;
 }
 
-static int pci_device_probe(struct device * dev)
+static int pci_device_probe(struct device *dev)
 {
        int error = 0;
        struct pci_driver *drv;
@@ -367,10 +407,10 @@ static int pci_device_probe(struct device * dev)
        return error;
 }
 
-static int pci_device_remove(struct device * dev)
+static int pci_device_remove(struct device *dev)
 {
-       struct pci_dev * pci_dev = to_pci_dev(dev);
-       struct pci_driver * drv = pci_dev->driver;
+       struct pci_dev *pci_dev = to_pci_dev(dev);
+       struct pci_driver *drv = pci_dev->driver;
 
        if (drv) {
                if (drv->remove) {
@@ -498,8 +538,8 @@ static int pci_pm_reenable_device(struct pci_dev *pci_dev)
 
 static int pci_legacy_suspend(struct device *dev, pm_message_t state)
 {
-       struct pci_dev * pci_dev = to_pci_dev(dev);
-       struct pci_driver * drv = pci_dev->driver;
+       struct pci_dev *pci_dev = to_pci_dev(dev);
+       struct pci_driver *drv = pci_dev->driver;
 
        if (drv && drv->suspend) {
                pci_power_t prev = pci_dev->current_state;
@@ -525,8 +565,8 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state)
 
 static int pci_legacy_suspend_late(struct device *dev, pm_message_t state)
 {
-       struct pci_dev * pci_dev = to_pci_dev(dev);
-       struct pci_driver * drv = pci_dev->driver;
+       struct pci_dev *pci_dev = to_pci_dev(dev);
+       struct pci_driver *drv = pci_dev->driver;
 
        if (drv && drv->suspend_late) {
                pci_power_t prev = pci_dev->current_state;
@@ -556,8 +596,8 @@ static int pci_legacy_suspend_late(struct device *dev, pm_message_t state)
 
 static int pci_legacy_resume_early(struct device *dev)
 {
-       struct pci_dev * pci_dev = to_pci_dev(dev);
-       struct pci_driver * drv = pci_dev->driver;
+       struct pci_dev *pci_dev = to_pci_dev(dev);
+       struct pci_driver *drv = pci_dev->driver;
 
        return drv && drv->resume_early ?
                        drv->resume_early(pci_dev) : 0;
@@ -565,8 +605,8 @@ static int pci_legacy_resume_early(struct device *dev)
 
 static int pci_legacy_resume(struct device *dev)
 {
-       struct pci_dev * pci_dev = to_pci_dev(dev);
-       struct pci_driver * drv = pci_dev->driver;
+       struct pci_dev *pci_dev = to_pci_dev(dev);
+       struct pci_driver *drv = pci_dev->driver;
 
        pci_fixup_device(pci_fixup_resume, pci_dev);
 
@@ -580,14 +620,14 @@ static void pci_pm_default_resume(struct pci_dev *pci_dev)
 {
        pci_fixup_device(pci_fixup_resume, pci_dev);
 
-       if (!pci_is_bridge(pci_dev))
+       if (!pci_has_subordinate(pci_dev))
                pci_enable_wake(pci_dev, PCI_D0, false);
 }
 
 static void pci_pm_default_suspend(struct pci_dev *pci_dev)
 {
        /* Disable non-bridge devices without PM support */
-       if (!pci_is_bridge(pci_dev))
+       if (!pci_has_subordinate(pci_dev))
                pci_disable_enabled_device(pci_dev);
 }
 
@@ -717,7 +757,7 @@ static int pci_pm_suspend_noirq(struct device *dev)
 
        if (!pci_dev->state_saved) {
                pci_save_state(pci_dev);
-               if (!pci_is_bridge(pci_dev))
+               if (!pci_has_subordinate(pci_dev))
                        pci_prepare_to_sleep(pci_dev);
        }
 
@@ -971,7 +1011,7 @@ static int pci_pm_poweroff_noirq(struct device *dev)
                        return error;
        }
 
-       if (!pci_dev->state_saved && !pci_is_bridge(pci_dev))
+       if (!pci_dev->state_saved && !pci_has_subordinate(pci_dev))
                pci_prepare_to_sleep(pci_dev);
 
        /*
@@ -1216,6 +1256,7 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner,
        /* register with core */
        return driver_register(&drv->driver);
 }
+EXPORT_SYMBOL(__pci_register_driver);
 
 /**
  * pci_unregister_driver - unregister a pci driver
@@ -1227,12 +1268,12 @@ int __pci_register_driver(struct pci_driver *drv, struct module *owner,
  * driverless.
  */
 
-void
-pci_unregister_driver(struct pci_driver *drv)
+void pci_unregister_driver(struct pci_driver *drv)
 {
        driver_unregister(&drv->driver);
        pci_free_dynids(drv);
 }
+EXPORT_SYMBOL(pci_unregister_driver);
 
 static struct pci_driver pci_compat_driver = {
        .name = "compat"
@@ -1245,19 +1286,19 @@ static struct pci_driver pci_compat_driver = {
  * Returns the appropriate pci_driver structure or %NULL if there is no
  * registered driver for the device.
  */
-struct pci_driver *
-pci_dev_driver(const struct pci_dev *dev)
+struct pci_driver *pci_dev_driver(const struct pci_dev *dev)
 {
        if (dev->driver)
                return dev->driver;
        else {
                int i;
-               for(i=0; i<=PCI_ROM_RESOURCE; i++)
+               for (i = 0; i <= PCI_ROM_RESOURCE; i++)
                        if (dev->resource[i].flags & IORESOURCE_BUSY)
                                return &pci_compat_driver;
        }
        return NULL;
 }
+EXPORT_SYMBOL(pci_dev_driver);
 
 /**
  * pci_bus_match - Tell if a PCI device structure has a matching PCI device id structure
@@ -1303,6 +1344,7 @@ struct pci_dev *pci_dev_get(struct pci_dev *dev)
                get_device(&dev->dev);
        return dev;
 }
+EXPORT_SYMBOL(pci_dev_get);
 
 /**
  * pci_dev_put - release a use of the pci device structure
@@ -1316,6 +1358,7 @@ void pci_dev_put(struct pci_dev *dev)
        if (dev)
                put_device(&dev->dev);
 }
+EXPORT_SYMBOL(pci_dev_put);
 
 static int pci_uevent(struct device *dev, struct kobj_uevent_env *env)
 {
@@ -1325,8 +1368,6 @@ static int pci_uevent(struct device *dev, struct kobj_uevent_env *env)
                return -ENODEV;
 
        pdev = to_pci_dev(dev);
-       if (!pdev)
-               return -ENODEV;
 
        if (add_uevent_var(env, "PCI_CLASS=%04X", pdev->class))
                return -ENOMEM;
@@ -1347,6 +1388,7 @@ static int pci_uevent(struct device *dev, struct kobj_uevent_env *env)
                           (u8)(pdev->class >> 16), (u8)(pdev->class >> 8),
                           (u8)(pdev->class)))
                return -ENOMEM;
+
        return 0;
 }
 
@@ -1362,19 +1404,10 @@ struct bus_type pci_bus_type = {
        .drv_groups     = pci_drv_groups,
        .pm             = PCI_PM_OPS_PTR,
 };
+EXPORT_SYMBOL(pci_bus_type);
 
 static int __init pci_driver_init(void)
 {
        return bus_register(&pci_bus_type);
 }
-
 postcore_initcall(pci_driver_init);
-
-EXPORT_SYMBOL_GPL(pci_add_dynid);
-EXPORT_SYMBOL(pci_match_id);
-EXPORT_SYMBOL(__pci_register_driver);
-EXPORT_SYMBOL(pci_unregister_driver);
-EXPORT_SYMBOL(pci_dev_driver);
-EXPORT_SYMBOL(pci_bus_type);
-EXPORT_SYMBOL(pci_dev_get);
-EXPORT_SYMBOL(pci_dev_put);
index 45113daaa778f384e7796a3ca43b6304e30dbf84..a3fbe2012ea3ebe9f0d2749431cc3003c99ff923 100644 (file)
@@ -40,9 +40,8 @@ enum smbios_attr_enum {
        SMBIOS_ATTR_INSTANCE_SHOW,
 };
 
-static size_t
-find_smbios_instance_string(struct pci_dev *pdev, char *buf,
-                           enum smbios_attr_enum attribute)
+static size_t find_smbios_instance_string(struct pci_dev *pdev, char *buf,
+                                         enum smbios_attr_enum attribute)
 {
        const struct dmi_device *dmi;
        struct dmi_dev_onboard *donboard;
@@ -74,9 +73,8 @@ find_smbios_instance_string(struct pci_dev *pdev, char *buf,
        return 0;
 }
 
-static umode_t
-smbios_instance_string_exist(struct kobject *kobj, struct attribute *attr,
-                            int n)
+static umode_t smbios_instance_string_exist(struct kobject *kobj,
+                                           struct attribute *attr, int n)
 {
        struct device *dev;
        struct pci_dev *pdev;
@@ -88,8 +86,8 @@ smbios_instance_string_exist(struct kobject *kobj, struct attribute *attr,
                                           S_IRUGO : 0;
 }
 
-static ssize_t
-smbioslabel_show(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t smbioslabel_show(struct device *dev,
+                               struct device_attribute *attr, char *buf)
 {
        struct pci_dev *pdev;
        pdev = to_pci_dev(dev);
@@ -98,9 +96,8 @@ smbioslabel_show(struct device *dev, struct device_attribute *attr, char *buf)
                                           SMBIOS_ATTR_LABEL_SHOW);
 }
 
-static ssize_t
-smbiosinstance_show(struct device *dev,
-                   struct device_attribute *attr, char *buf)
+static ssize_t smbiosinstance_show(struct device *dev,
+                                  struct device_attribute *attr, char *buf)
 {
        struct pci_dev *pdev;
        pdev = to_pci_dev(dev);
@@ -130,26 +127,22 @@ static struct attribute_group smbios_attr_group = {
        .is_visible = smbios_instance_string_exist,
 };
 
-static int
-pci_create_smbiosname_file(struct pci_dev *pdev)
+static int pci_create_smbiosname_file(struct pci_dev *pdev)
 {
        return sysfs_create_group(&pdev->dev.kobj, &smbios_attr_group);
 }
 
-static void
-pci_remove_smbiosname_file(struct pci_dev *pdev)
+static void pci_remove_smbiosname_file(struct pci_dev *pdev)
 {
        sysfs_remove_group(&pdev->dev.kobj, &smbios_attr_group);
 }
 #else
-static inline int
-pci_create_smbiosname_file(struct pci_dev *pdev)
+static inline int pci_create_smbiosname_file(struct pci_dev *pdev)
 {
        return -1;
 }
 
-static inline void
-pci_remove_smbiosname_file(struct pci_dev *pdev)
+static inline void pci_remove_smbiosname_file(struct pci_dev *pdev)
 {
 }
 #endif
@@ -175,8 +168,8 @@ static void dsm_label_utf16s_to_utf8s(union acpi_object *obj, char *buf)
        buf[len] = '\n';
 }
 
-static int
-dsm_get_label(struct device *dev, char *buf, enum acpi_attr_enum attr)
+static int dsm_get_label(struct device *dev, char *buf,
+                        enum acpi_attr_enum attr)
 {
        acpi_handle handle;
        union acpi_object *obj, *tmp;
@@ -212,8 +205,7 @@ dsm_get_label(struct device *dev, char *buf, enum acpi_attr_enum attr)
        return len;
 }
 
-static bool
-device_has_dsm(struct device *dev)
+static bool device_has_dsm(struct device *dev)
 {
        acpi_handle handle;
 
@@ -225,8 +217,8 @@ device_has_dsm(struct device *dev)
                                1 << DEVICE_LABEL_DSM);
 }
 
-static umode_t
-acpi_index_string_exist(struct kobject *kobj, struct attribute *attr, int n)
+static umode_t acpi_index_string_exist(struct kobject *kobj,
+                                      struct attribute *attr, int n)
 {
        struct device *dev;
 
@@ -238,14 +230,14 @@ acpi_index_string_exist(struct kobject *kobj, struct attribute *attr, int n)
        return 0;
 }
 
-static ssize_t
-acpilabel_show(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t acpilabel_show(struct device *dev,
+                             struct device_attribute *attr, char *buf)
 {
        return dsm_get_label(dev, buf, ACPI_ATTR_LABEL_SHOW);
 }
 
-static ssize_t
-acpiindex_show(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t acpiindex_show(struct device *dev,
+                             struct device_attribute *attr, char *buf)
 {
        return dsm_get_label(dev, buf, ACPI_ATTR_INDEX_SHOW);
 }
@@ -271,33 +263,28 @@ static struct attribute_group acpi_attr_group = {
        .is_visible = acpi_index_string_exist,
 };
 
-static int
-pci_create_acpi_index_label_files(struct pci_dev *pdev)
+static int pci_create_acpi_index_label_files(struct pci_dev *pdev)
 {
        return sysfs_create_group(&pdev->dev.kobj, &acpi_attr_group);
 }
 
-static int
-pci_remove_acpi_index_label_files(struct pci_dev *pdev)
+static int pci_remove_acpi_index_label_files(struct pci_dev *pdev)
 {
        sysfs_remove_group(&pdev->dev.kobj, &acpi_attr_group);
        return 0;
 }
 #else
-static inline int
-pci_create_acpi_index_label_files(struct pci_dev *pdev)
+static inline int pci_create_acpi_index_label_files(struct pci_dev *pdev)
 {
        return -1;
 }
 
-static inline int
-pci_remove_acpi_index_label_files(struct pci_dev *pdev)
+static inline int pci_remove_acpi_index_label_files(struct pci_dev *pdev)
 {
        return -1;
 }
 
-static inline bool
-device_has_dsm(struct device *dev)
+static inline bool device_has_dsm(struct device *dev)
 {
        return false;
 }
index 2ff77509d8e53b505dc3f73b35567920491b2f7d..886fb3570278c87ddde5131c34541bfc60eae096 100644 (file)
@@ -55,7 +55,7 @@ static int __init pci_stub_init(void)
        p = ids;
        while ((id = strsep(&p, ","))) {
                unsigned int vendor, device, subvendor = PCI_ANY_ID,
-                       subdevice = PCI_ANY_ID, class=0, class_mask=0;
+                       subdevice = PCI_ANY_ID, class = 0, class_mask = 0;
                int fields;
 
                if (!strlen(id))
index 4e0acefb7565d0f3b81013855efa85c86ca5a98e..9ff0a901ecf7ed2691418845bf46d82bb2d68754 100644 (file)
@@ -29,6 +29,7 @@
 #include <linux/slab.h>
 #include <linux/vgaarb.h>
 #include <linux/pm_runtime.h>
+#include <linux/of.h>
 #include "pci.h"
 
 static int sysfs_initialized;  /* = 0 */
@@ -40,8 +41,8 @@ field##_show(struct device *dev, struct device_attribute *attr, char *buf)                            \
 {                                                                      \
        struct pci_dev *pdev;                                           \
                                                                        \
-       pdev = to_pci_dev (dev);                                        \
-       return sprintf (buf, format_string, pdev->field);               \
+       pdev = to_pci_dev(dev);                                         \
+       return sprintf(buf, format_string, pdev->field);                \
 }                                                                      \
 static DEVICE_ATTR_RO(field)
 
@@ -57,7 +58,7 @@ static ssize_t broken_parity_status_show(struct device *dev,
                                         char *buf)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
-       return sprintf (buf, "%u\n", pdev->broken_parity_status);
+       return sprintf(buf, "%u\n", pdev->broken_parity_status);
 }
 
 static ssize_t broken_parity_status_store(struct device *dev,
@@ -76,10 +77,8 @@ static ssize_t broken_parity_status_store(struct device *dev,
 }
 static DEVICE_ATTR_RW(broken_parity_status);
 
-static ssize_t pci_dev_show_local_cpu(struct device *dev,
-               int type,
-               struct device_attribute *attr,
-               char *buf)
+static ssize_t pci_dev_show_local_cpu(struct device *dev, int type,
+                                     struct device_attribute *attr, char *buf)
 {
        const struct cpumask *mask;
        int len;
@@ -100,14 +99,14 @@ static ssize_t pci_dev_show_local_cpu(struct device *dev,
 }
 
 static ssize_t local_cpus_show(struct device *dev,
-                       struct device_attribute *attr, char *buf)
+                              struct device_attribute *attr, char *buf)
 {
        return pci_dev_show_local_cpu(dev, 1, attr, buf);
 }
 static DEVICE_ATTR_RO(local_cpus);
 
 static ssize_t local_cpulist_show(struct device *dev,
-                       struct device_attribute *attr, char *buf)
+                                 struct device_attribute *attr, char *buf)
 {
        return pci_dev_show_local_cpu(dev, 0, attr, buf);
 }
@@ -116,8 +115,7 @@ static DEVICE_ATTR_RO(local_cpulist);
 /*
  * PCI Bus Class Devices
  */
-static ssize_t pci_bus_show_cpuaffinity(struct device *dev,
-                                       int type,
+static ssize_t pci_bus_show_cpuaffinity(struct device *dev, int type,
                                        struct device_attribute *attr,
                                        char *buf)
 {
@@ -148,11 +146,11 @@ static ssize_t cpulistaffinity_show(struct device *dev,
 static DEVICE_ATTR_RO(cpulistaffinity);
 
 /* show resources */
-static ssize_t
-resource_show(struct device * dev, struct device_attribute *attr, char * buf)
+static ssize_t resource_show(struct device *dev, struct device_attribute *attr,
+                            char *buf)
 {
-       struct pci_dev * pci_dev = to_pci_dev(dev);
-       char * str = buf;
+       struct pci_dev *pci_dev = to_pci_dev(dev);
+       char *str = buf;
        int i;
        int max;
        resource_size_t start, end;
@@ -165,7 +163,7 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf)
        for (i = 0; i < max; i++) {
                struct resource *res =  &pci_dev->resource[i];
                pci_resource_to_user(pci_dev, i, res, &start, &end);
-               str += sprintf(str,"0x%016llx 0x%016llx 0x%016llx\n",
+               str += sprintf(str, "0x%016llx 0x%016llx 0x%016llx\n",
                               (unsigned long long)start,
                               (unsigned long long)end,
                               (unsigned long long)res->flags);
@@ -174,7 +172,8 @@ resource_show(struct device * dev, struct device_attribute *attr, char * buf)
 }
 static DEVICE_ATTR_RO(resource);
 
-static ssize_t modalias_show(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
+                            char *buf)
 {
        struct pci_dev *pci_dev = to_pci_dev(dev);
 
@@ -186,9 +185,8 @@ static ssize_t modalias_show(struct device *dev, struct device_attribute *attr,
 }
 static DEVICE_ATTR_RO(modalias);
 
-static ssize_t enabled_store(struct device *dev,
-                            struct device_attribute *attr, const char *buf,
-                            size_t count)
+static ssize_t enabled_store(struct device *dev, struct device_attribute *attr,
+                            const char *buf, size_t count)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
        unsigned long val;
@@ -212,57 +210,56 @@ static ssize_t enabled_store(struct device *dev,
        return result < 0 ? result : count;
 }
 
-static ssize_t enabled_show(struct device *dev,
-                           struct device_attribute *attr, char *buf)
+static ssize_t enabled_show(struct device *dev, struct device_attribute *attr,
+                           char *buf)
 {
        struct pci_dev *pdev;
 
-       pdev = to_pci_dev (dev);
-       return sprintf (buf, "%u\n", atomic_read(&pdev->enable_cnt));
+       pdev = to_pci_dev(dev);
+       return sprintf(buf, "%u\n", atomic_read(&pdev->enable_cnt));
 }
 static DEVICE_ATTR_RW(enabled);
 
 #ifdef CONFIG_NUMA
-static ssize_t
-numa_node_show(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t numa_node_show(struct device *dev, struct device_attribute *attr,
+                             char *buf)
 {
-       return sprintf (buf, "%d\n", dev->numa_node);
+       return sprintf(buf, "%d\n", dev->numa_node);
 }
 static DEVICE_ATTR_RO(numa_node);
 #endif
 
-static ssize_t
-dma_mask_bits_show(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t dma_mask_bits_show(struct device *dev,
+                                 struct device_attribute *attr, char *buf)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
 
-       return sprintf (buf, "%d\n", fls64(pdev->dma_mask));
+       return sprintf(buf, "%d\n", fls64(pdev->dma_mask));
 }
 static DEVICE_ATTR_RO(dma_mask_bits);
 
-static ssize_t
-consistent_dma_mask_bits_show(struct device *dev, struct device_attribute *attr,
-                                char *buf)
+static ssize_t consistent_dma_mask_bits_show(struct device *dev,
+                                            struct device_attribute *attr,
+                                            char *buf)
 {
-       return sprintf (buf, "%d\n", fls64(dev->coherent_dma_mask));
+       return sprintf(buf, "%d\n", fls64(dev->coherent_dma_mask));
 }
 static DEVICE_ATTR_RO(consistent_dma_mask_bits);
 
-static ssize_t
-msi_bus_show(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t msi_bus_show(struct device *dev, struct device_attribute *attr,
+                           char *buf)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
 
        if (!pdev->subordinate)
                return 0;
 
-       return sprintf (buf, "%u\n",
-                       !(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI));
+       return sprintf(buf, "%u\n",
+                      !(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI));
 }
 
-static ssize_t
-msi_bus_store(struct device *dev, struct device_attribute *attr,
-             const char *buf, size_t count)
+static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr,
+                            const char *buf, size_t count)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
        unsigned long val;
@@ -289,8 +286,8 @@ msi_bus_store(struct device *dev, struct device_attribute *attr,
            !!val) {
                pdev->subordinate->bus_flags ^= PCI_BUS_FLAGS_NO_MSI;
 
-               dev_warn(&pdev->dev, "forced subordinate bus to%s support MSI,"
-                        " bad things could happen\n", val ? "" : " not");
+               dev_warn(&pdev->dev, "forced subordinate bus to%s support MSI, bad things could happen\n",
+                        val ? "" : " not");
        }
 
        return count;
@@ -330,9 +327,9 @@ const struct attribute_group *pci_bus_groups[] = {
        NULL,
 };
 
-static ssize_t
-dev_rescan_store(struct device *dev, struct device_attribute *attr,
-                const char *buf, size_t count)
+static ssize_t dev_rescan_store(struct device *dev,
+                               struct device_attribute *attr, const char *buf,
+                               size_t count)
 {
        unsigned long val;
        struct pci_dev *pdev = to_pci_dev(dev);
@@ -351,9 +348,8 @@ static struct device_attribute dev_rescan_attr = __ATTR(rescan,
                                                        (S_IWUSR|S_IWGRP),
                                                        NULL, dev_rescan_store);
 
-static ssize_t
-remove_store(struct device *dev, struct device_attribute *attr,
-            const char *buf, size_t count)
+static ssize_t remove_store(struct device *dev, struct device_attribute *attr,
+                           const char *buf, size_t count)
 {
        unsigned long val;
 
@@ -368,9 +364,9 @@ static struct device_attribute dev_remove_attr = __ATTR(remove,
                                                        (S_IWUSR|S_IWGRP),
                                                        NULL, remove_store);
 
-static ssize_t
-dev_bus_rescan_store(struct device *dev, struct device_attribute *attr,
-                const char *buf, size_t count)
+static ssize_t dev_bus_rescan_store(struct device *dev,
+                                   struct device_attribute *attr,
+                                   const char *buf, size_t count)
 {
        unsigned long val;
        struct pci_bus *bus = to_pci_bus(dev);
@@ -411,11 +407,25 @@ static ssize_t d3cold_allowed_show(struct device *dev,
                                   struct device_attribute *attr, char *buf)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
-       return sprintf (buf, "%u\n", pdev->d3cold_allowed);
+       return sprintf(buf, "%u\n", pdev->d3cold_allowed);
 }
 static DEVICE_ATTR_RW(d3cold_allowed);
 #endif
 
+#ifdef CONFIG_OF
+static ssize_t devspec_show(struct device *dev,
+                           struct device_attribute *attr, char *buf)
+{
+       struct pci_dev *pdev = to_pci_dev(dev);
+       struct device_node *np = pci_device_to_OF_node(pdev);
+
+       if (np == NULL || np->full_name == NULL)
+               return 0;
+       return sprintf(buf, "%s", np->full_name);
+}
+static DEVICE_ATTR_RO(devspec);
+#endif
+
 #ifdef CONFIG_PCI_IOV
 static ssize_t sriov_totalvfs_show(struct device *dev,
                                   struct device_attribute *attr,
@@ -499,6 +509,45 @@ static struct device_attribute sriov_numvfs_attr =
                       sriov_numvfs_show, sriov_numvfs_store);
 #endif /* CONFIG_PCI_IOV */
 
+static ssize_t driver_override_store(struct device *dev,
+                                    struct device_attribute *attr,
+                                    const char *buf, size_t count)
+{
+       struct pci_dev *pdev = to_pci_dev(dev);
+       char *driver_override, *old = pdev->driver_override, *cp;
+
+       if (count > PATH_MAX)
+               return -EINVAL;
+
+       driver_override = kstrndup(buf, count, GFP_KERNEL);
+       if (!driver_override)
+               return -ENOMEM;
+
+       cp = strchr(driver_override, '\n');
+       if (cp)
+               *cp = '\0';
+
+       if (strlen(driver_override)) {
+               pdev->driver_override = driver_override;
+       } else {
+               kfree(driver_override);
+               pdev->driver_override = NULL;
+       }
+
+       kfree(old);
+
+       return count;
+}
+
+static ssize_t driver_override_show(struct device *dev,
+                                   struct device_attribute *attr, char *buf)
+{
+       struct pci_dev *pdev = to_pci_dev(dev);
+
+       return sprintf(buf, "%s\n", pdev->driver_override);
+}
+static DEVICE_ATTR_RW(driver_override);
+
 static struct attribute *pci_dev_attrs[] = {
        &dev_attr_resource.attr,
        &dev_attr_vendor.attr,
@@ -521,6 +570,10 @@ static struct attribute *pci_dev_attrs[] = {
 #if defined(CONFIG_PM_RUNTIME) && defined(CONFIG_ACPI)
        &dev_attr_d3cold_allowed.attr,
 #endif
+#ifdef CONFIG_OF
+       &dev_attr_devspec.attr,
+#endif
+       &dev_attr_driver_override.attr,
        NULL,
 };
 
@@ -549,8 +602,8 @@ const struct attribute_group *pcibus_groups[] = {
        NULL,
 };
 
-static ssize_t
-boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
+static ssize_t boot_vga_show(struct device *dev, struct device_attribute *attr,
+                            char *buf)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
        struct pci_dev *vga_dev = vga_default_device();
@@ -564,22 +617,21 @@ boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
 }
 static struct device_attribute vga_attr = __ATTR_RO(boot_vga);
 
-static ssize_t
-pci_read_config(struct file *filp, struct kobject *kobj,
-               struct bin_attribute *bin_attr,
-               char *buf, loff_t off, size_t count)
+static ssize_t pci_read_config(struct file *filp, struct kobject *kobj,
+                              struct bin_attribute *bin_attr, char *buf,
+                              loff_t off, size_t count)
 {
-       struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj));
+       struct pci_dev *dev = to_pci_dev(container_of(kobj, struct device,
+                                                     kobj));
        unsigned int size = 64;
        loff_t init_off = off;
-       u8 *data = (u8*) buf;
+       u8 *data = (u8 *) buf;
 
        /* Several chips lock up trying to read undefined config space */
-       if (security_capable(filp->f_cred, &init_user_ns, CAP_SYS_ADMIN) == 0) {
+       if (security_capable(filp->f_cred, &init_user_ns, CAP_SYS_ADMIN) == 0)
                size = dev->cfg_size;
-       } else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS) {
+       else if (dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
                size = 128;
-       }
 
        if (off > size)
                return 0;
@@ -642,15 +694,15 @@ pci_read_config(struct file *filp, struct kobject *kobj,
        return count;
 }
 
-static ssize_t
-pci_write_config(struct file* filp, struct kobject *kobj,
-                struct bin_attribute *bin_attr,
-                char *buf, loff_t off, size_t count)
+static ssize_t pci_write_config(struct file *filp, struct kobject *kobj,
+                               struct bin_attribute *bin_attr, char *buf,
+                               loff_t off, size_t count)
 {
-       struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj));
+       struct pci_dev *dev = to_pci_dev(container_of(kobj, struct device,
+                                                     kobj));
        unsigned int size = count;
        loff_t init_off = off;
-       u8 *data = (u8*) buf;
+       u8 *data = (u8 *) buf;
 
        if (off > dev->cfg_size)
                return 0;
@@ -670,10 +722,10 @@ pci_write_config(struct file* filp, struct kobject *kobj,
        if ((off & 3) && size > 2) {
                u16 val = data[off - init_off];
                val |= (u16) data[off - init_off + 1] << 8;
-                pci_user_write_config_word(dev, off, val);
-                off += 2;
-                size -= 2;
-        }
+               pci_user_write_config_word(dev, off, val);
+               off += 2;
+               size -= 2;
+       }
 
        while (size > 3) {
                u32 val = data[off - init_off];
@@ -704,10 +756,9 @@ pci_write_config(struct file* filp, struct kobject *kobj,
        return count;
 }
 
-static ssize_t
-read_vpd_attr(struct file *filp, struct kobject *kobj,
-             struct bin_attribute *bin_attr,
-             char *buf, loff_t off, size_t count)
+static ssize_t read_vpd_attr(struct file *filp, struct kobject *kobj,
+                            struct bin_attribute *bin_attr, char *buf,
+                            loff_t off, size_t count)
 {
        struct pci_dev *dev =
                to_pci_dev(container_of(kobj, struct device, kobj));
@@ -720,10 +771,9 @@ read_vpd_attr(struct file *filp, struct kobject *kobj,
        return pci_read_vpd(dev, off, count, buf);
 }
 
-static ssize_t
-write_vpd_attr(struct file *filp, struct kobject *kobj,
-              struct bin_attribute *bin_attr,
-              char *buf, loff_t off, size_t count)
+static ssize_t write_vpd_attr(struct file *filp, struct kobject *kobj,
+                             struct bin_attribute *bin_attr, char *buf,
+                             loff_t off, size_t count)
 {
        struct pci_dev *dev =
                to_pci_dev(container_of(kobj, struct device, kobj));
@@ -749,20 +799,18 @@ write_vpd_attr(struct file *filp, struct kobject *kobj,
  * Reads 1, 2, or 4 bytes from legacy I/O port space using an arch specific
  * callback routine (pci_legacy_read).
  */
-static ssize_t
-pci_read_legacy_io(struct file *filp, struct kobject *kobj,
-                  struct bin_attribute *bin_attr,
-                  char *buf, loff_t off, size_t count)
+static ssize_t pci_read_legacy_io(struct file *filp, struct kobject *kobj,
+                                 struct bin_attribute *bin_attr, char *buf,
+                                 loff_t off, size_t count)
 {
-        struct pci_bus *bus = to_pci_bus(container_of(kobj,
-                                                      struct device,
+       struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device,
                                                      kobj));
 
-        /* Only support 1, 2 or 4 byte accesses */
-        if (count != 1 && count != 2 && count != 4)
-                return -EINVAL;
+       /* Only support 1, 2 or 4 byte accesses */
+       if (count != 1 && count != 2 && count != 4)
+               return -EINVAL;
 
-        return pci_legacy_read(bus, off, (u32 *)buf, count);
+       return pci_legacy_read(bus, off, (u32 *)buf, count);
 }
 
 /**
@@ -777,19 +825,18 @@ pci_read_legacy_io(struct file *filp, struct kobject *kobj,
  * Writes 1, 2, or 4 bytes from legacy I/O port space using an arch specific
  * callback routine (pci_legacy_write).
  */
-static ssize_t
-pci_write_legacy_io(struct file *filp, struct kobject *kobj,
-                   struct bin_attribute *bin_attr,
-                   char *buf, loff_t off, size_t count)
+static ssize_t pci_write_legacy_io(struct file *filp, struct kobject *kobj,
+                                  struct bin_attribute *bin_attr, char *buf,
+                                  loff_t off, size_t count)
 {
-        struct pci_bus *bus = to_pci_bus(container_of(kobj,
-                                                     struct device,
+       struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device,
                                                      kobj));
-        /* Only support 1, 2 or 4 byte accesses */
-        if (count != 1 && count != 2 && count != 4)
-                return -EINVAL;
 
-        return pci_legacy_write(bus, off, *(u32 *)buf, count);
+       /* Only support 1, 2 or 4 byte accesses */
+       if (count != 1 && count != 2 && count != 4)
+               return -EINVAL;
+
+       return pci_legacy_write(bus, off, *(u32 *)buf, count);
 }
 
 /**
@@ -803,16 +850,14 @@ pci_write_legacy_io(struct file *filp, struct kobject *kobj,
  * legacy memory space (first meg of bus space) into application virtual
  * memory space.
  */
-static int
-pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj,
-                   struct bin_attribute *attr,
-                    struct vm_area_struct *vma)
+static int pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj,
+                              struct bin_attribute *attr,
+                              struct vm_area_struct *vma)
 {
-        struct pci_bus *bus = to_pci_bus(container_of(kobj,
-                                                      struct device,
+       struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device,
                                                      kobj));
 
-        return pci_mmap_legacy_page_range(bus, vma, pci_mmap_mem);
+       return pci_mmap_legacy_page_range(bus, vma, pci_mmap_mem);
 }
 
 /**
@@ -826,16 +871,14 @@ pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj,
  * legacy IO space (first meg of bus space) into application virtual
  * memory space. Returns -ENOSYS if the operation isn't supported
  */
-static int
-pci_mmap_legacy_io(struct file *filp, struct kobject *kobj,
-                  struct bin_attribute *attr,
-                  struct vm_area_struct *vma)
+static int pci_mmap_legacy_io(struct file *filp, struct kobject *kobj,
+                             struct bin_attribute *attr,
+                             struct vm_area_struct *vma)
 {
-        struct pci_bus *bus = to_pci_bus(container_of(kobj,
-                                                      struct device,
+       struct pci_bus *bus = to_pci_bus(container_of(kobj, struct device,
                                                      kobj));
 
-        return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io);
+       return pci_mmap_legacy_page_range(bus, vma, pci_mmap_io);
 }
 
 /**
@@ -845,10 +888,9 @@ pci_mmap_legacy_io(struct file *filp, struct kobject *kobj,
  *
  * Stub implementation. Can be overridden by arch if necessary.
  */
-void __weak
-pci_adjust_legacy_attr(struct pci_bus *b, enum pci_mmap_state mmap_type)
+void __weak pci_adjust_legacy_attr(struct pci_bus *b,
+                                  enum pci_mmap_state mmap_type)
 {
-       return;
 }
 
 /**
@@ -903,8 +945,7 @@ legacy_io_err:
        kfree(b->legacy_io);
        b->legacy_io = NULL;
 kzalloc_err:
-       printk(KERN_WARNING "pci: warning: could not create legacy I/O port "
-              "and ISA memory resources to sysfs\n");
+       printk(KERN_WARNING "pci: warning: could not create legacy I/O port and ISA memory resources to sysfs\n");
        return;
 }
 
@@ -947,9 +988,8 @@ int pci_mmap_fits(struct pci_dev *pdev, int resno, struct vm_area_struct *vma,
  *
  * Use the regular PCI mapping routines to map a PCI resource into userspace.
  */
-static int
-pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
-                 struct vm_area_struct *vma, int write_combine)
+static int pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
+                            struct vm_area_struct *vma, int write_combine)
 {
        struct pci_dev *pdev = to_pci_dev(container_of(kobj,
                                                       struct device, kobj));
@@ -965,8 +1005,7 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
                return -ENODEV;
 
        if (!pci_mmap_fits(pdev, i, vma, PCI_MMAP_SYSFS)) {
-               WARN(1, "process \"%s\" tried to map 0x%08lx bytes "
-                       "at page 0x%08lx on %s BAR %d (start 0x%16Lx, size 0x%16Lx)\n",
+               WARN(1, "process \"%s\" tried to map 0x%08lx bytes at page 0x%08lx on %s BAR %d (start 0x%16Lx, size 0x%16Lx)\n",
                        current->comm, vma->vm_end-vma->vm_start, vma->vm_pgoff,
                        pci_name(pdev), i,
                        (u64)pci_resource_start(pdev, i),
@@ -988,26 +1027,23 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr,
        return pci_mmap_page_range(pdev, vma, mmap_type, write_combine);
 }
 
-static int
-pci_mmap_resource_uc(struct file *filp, struct kobject *kobj,
-                    struct bin_attribute *attr,
-                    struct vm_area_struct *vma)
+static int pci_mmap_resource_uc(struct file *filp, struct kobject *kobj,
+                               struct bin_attribute *attr,
+                               struct vm_area_struct *vma)
 {
        return pci_mmap_resource(kobj, attr, vma, 0);
 }
 
-static int
-pci_mmap_resource_wc(struct file *filp, struct kobject *kobj,
-                    struct bin_attribute *attr,
-                    struct vm_area_struct *vma)
+static int pci_mmap_resource_wc(struct file *filp, struct kobject *kobj,
+                               struct bin_attribute *attr,
+                               struct vm_area_struct *vma)
 {
        return pci_mmap_resource(kobj, attr, vma, 1);
 }
 
-static ssize_t
-pci_resource_io(struct file *filp, struct kobject *kobj,
-               struct bin_attribute *attr, char *buf,
-               loff_t off, size_t count, bool write)
+static ssize_t pci_resource_io(struct file *filp, struct kobject *kobj,
+                              struct bin_attribute *attr, char *buf,
+                              loff_t off, size_t count, bool write)
 {
        struct pci_dev *pdev = to_pci_dev(container_of(kobj,
                                                       struct device, kobj));
@@ -1052,18 +1088,16 @@ pci_resource_io(struct file *filp, struct kobject *kobj,
        return -EINVAL;
 }
 
-static ssize_t
-pci_read_resource_io(struct file *filp, struct kobject *kobj,
-                    struct bin_attribute *attr, char *buf,
-                    loff_t off, size_t count)
+static ssize_t pci_read_resource_io(struct file *filp, struct kobject *kobj,
+                                   struct bin_attribute *attr, char *buf,
+                                   loff_t off, size_t count)
 {
        return pci_resource_io(filp, kobj, attr, buf, off, count, false);
 }
 
-static ssize_t
-pci_write_resource_io(struct file *filp, struct kobject *kobj,
-                     struct bin_attribute *attr, char *buf,
-                     loff_t off, size_t count)
+static ssize_t pci_write_resource_io(struct file *filp, struct kobject *kobj,
+                                    struct bin_attribute *attr, char *buf,
+                                    loff_t off, size_t count)
 {
        return pci_resource_io(filp, kobj, attr, buf, off, count, true);
 }
@@ -1075,8 +1109,7 @@ pci_write_resource_io(struct file *filp, struct kobject *kobj,
  * If we created resource files for @pdev, remove them from sysfs and
  * free their resources.
  */
-static void
-pci_remove_resource_files(struct pci_dev *pdev)
+static void pci_remove_resource_files(struct pci_dev *pdev)
 {
        int i;
 
@@ -1179,10 +1212,9 @@ void __weak pci_remove_resource_files(struct pci_dev *dev) { return; }
  *
  * writing anything except 0 enables it
  */
-static ssize_t
-pci_write_rom(struct file *filp, struct kobject *kobj,
-             struct bin_attribute *bin_attr,
-             char *buf, loff_t off, size_t count)
+static ssize_t pci_write_rom(struct file *filp, struct kobject *kobj,
+                            struct bin_attribute *bin_attr, char *buf,
+                            loff_t off, size_t count)
 {
        struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj));
 
@@ -1206,10 +1238,9 @@ pci_write_rom(struct file *filp, struct kobject *kobj,
  * Put @count bytes starting at @off into @buf from the ROM in the PCI
  * device corresponding to @kobj.
  */
-static ssize_t
-pci_read_rom(struct file *filp, struct kobject *kobj,
-            struct bin_attribute *bin_attr,
-            char *buf, loff_t off, size_t count)
+static ssize_t pci_read_rom(struct file *filp, struct kobject *kobj,
+                           struct bin_attribute *bin_attr, char *buf,
+                           loff_t off, size_t count)
 {
        struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj));
        void __iomem *rom;
@@ -1255,14 +1286,8 @@ static struct bin_attribute pcie_config_attr = {
        .write = pci_write_config,
 };
 
-int __weak pcibios_add_platform_entries(struct pci_dev *dev)
-{
-       return 0;
-}
-
-static ssize_t reset_store(struct device *dev,
-                          struct device_attribute *attr, const char *buf,
-                          size_t count)
+static ssize_t reset_store(struct device *dev, struct device_attribute *attr,
+                          const char *buf, size_t count)
 {
        struct pci_dev *pdev = to_pci_dev(dev);
        unsigned long val;
@@ -1329,7 +1354,7 @@ error:
        return retval;
 }
 
-int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
+int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev)
 {
        int retval;
        int rom_size = 0;
@@ -1375,11 +1400,6 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
                pdev->rom_attr = attr;
        }
 
-       /* add platform-specific attributes */
-       retval = pcibios_add_platform_entries(pdev);
-       if (retval)
-               goto err_rom_file;
-
        /* add sysfs entries for various capabilities */
        retval = pci_create_capabilities_sysfs(pdev);
        if (retval)
@@ -1472,7 +1492,6 @@ static int __init pci_sysfs_init(void)
 
        return 0;
 }
-
 late_initcall(pci_sysfs_init);
 
 static struct attribute *pci_dev_dev_attrs[] = {
@@ -1481,7 +1500,7 @@ static struct attribute *pci_dev_dev_attrs[] = {
 };
 
 static umode_t pci_dev_attrs_are_visible(struct kobject *kobj,
-                                               struct attribute *a, int n)
+                                        struct attribute *a, int n)
 {
        struct device *dev = container_of(kobj, struct device, kobj);
        struct pci_dev *pdev = to_pci_dev(dev);
@@ -1500,7 +1519,7 @@ static struct attribute *pci_dev_hp_attrs[] = {
 };
 
 static umode_t pci_dev_hp_attrs_are_visible(struct kobject *kobj,
-                                               struct attribute *a, int n)
+                                           struct attribute *a, int n)
 {
        struct device *dev = container_of(kobj, struct device, kobj);
        struct pci_dev *pdev = to_pci_dev(dev);
@@ -1524,7 +1543,7 @@ static struct attribute *sriov_dev_attrs[] = {
 };
 
 static umode_t sriov_attrs_are_visible(struct kobject *kobj,
-                                        struct attribute *a, int n)
+                                      struct attribute *a, int n)
 {
        struct device *dev = container_of(kobj, struct device, kobj);
 
index 7325d43bf030ce65d5f386f6aeeeb3bfa4d5c482..0a271a100986d2fc7815b6c1ac8774f2eab14f64 100644 (file)
@@ -106,7 +106,7 @@ static bool pcie_ari_disabled;
  * Given a PCI bus, returns the highest PCI bus number present in the set
  * including the given PCI bus and its list of child PCI buses.
  */
-unsigned char pci_bus_max_busnr(struct pci_busbus)
+unsigned char pci_bus_max_busnr(struct pci_bus *bus)
 {
        struct pci_bus *tmp;
        unsigned char max, n;
@@ -114,7 +114,7 @@ unsigned char pci_bus_max_busnr(struct pci_bus* bus)
        max = bus->busn_res.end;
        list_for_each_entry(tmp, &bus->children, node) {
                n = pci_bus_max_busnr(tmp);
-               if(n > max)
+               if (n > max)
                        max = n;
        }
        return max;
@@ -226,6 +226,7 @@ int pci_find_capability(struct pci_dev *dev, int cap)
 
        return pos;
 }
+EXPORT_SYMBOL(pci_find_capability);
 
 /**
  * pci_bus_find_capability - query for devices' capabilities
@@ -253,6 +254,7 @@ int pci_bus_find_capability(struct pci_bus *bus, unsigned int devfn, int cap)
 
        return pos;
 }
+EXPORT_SYMBOL(pci_bus_find_capability);
 
 /**
  * pci_find_next_ext_capability - Find an extended capability
@@ -403,8 +405,8 @@ EXPORT_SYMBOL_GPL(pci_find_ht_capability);
  *  For given resource region of given device, return the resource
  *  region of parent bus the given region is contained in.
  */
-struct resource *
-pci_find_parent_resource(const struct pci_dev *dev, struct resource *res)
+struct resource *pci_find_parent_resource(const struct pci_dev *dev,
+                                         struct resource *res)
 {
        const struct pci_bus *bus = dev->bus;
        struct resource *r;
@@ -436,6 +438,7 @@ pci_find_parent_resource(const struct pci_dev *dev, struct resource *res)
        }
        return NULL;
 }
+EXPORT_SYMBOL(pci_find_parent_resource);
 
 /**
  * pci_wait_for_pending - wait for @mask bit(s) to clear in status word @pos
@@ -470,8 +473,7 @@ int pci_wait_for_pending(struct pci_dev *dev, int pos, u16 mask)
  * Restore the BAR values for a given device, so as to make it
  * accessible by its driver.
  */
-static void
-pci_restore_bars(struct pci_dev *dev)
+static void pci_restore_bars(struct pci_dev *dev)
 {
        int i;
 
@@ -496,7 +498,7 @@ static inline bool platform_pci_power_manageable(struct pci_dev *dev)
 }
 
 static inline int platform_pci_set_power_state(struct pci_dev *dev,
-                                                pci_power_t t)
+                                              pci_power_t t)
 {
        return pci_platform_pm ? pci_platform_pm->set_state(dev, t) : -ENOSYS;
 }
@@ -553,8 +555,8 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
         */
        if (state != PCI_D0 && dev->current_state <= PCI_D3cold
            && dev->current_state > state) {
-               dev_err(&dev->dev, "invalid power transition "
-                       "(from state %d to %d)\n", dev->current_state, state);
+               dev_err(&dev->dev, "invalid power transition (from state %d to %d)\n",
+                       dev->current_state, state);
                return -EINVAL;
        }
 
@@ -601,8 +603,8 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
        pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
        dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
        if (dev->current_state != state && printk_ratelimit())
-               dev_info(&dev->dev, "Refused to change power state, "
-                       "currently in D%d\n", dev->current_state);
+               dev_info(&dev->dev, "Refused to change power state, currently in D%d\n",
+                        dev->current_state);
 
        /*
         * According to section 5.4.1 of the "PCI BUS POWER MANAGEMENT
@@ -846,6 +848,7 @@ int pci_set_power_state(struct pci_dev *dev, pci_power_t state)
 
        return error;
 }
+EXPORT_SYMBOL(pci_set_power_state);
 
 /**
  * pci_choose_state - Choose the power state of a PCI device
@@ -884,12 +887,10 @@ pci_power_t pci_choose_state(struct pci_dev *dev, pm_message_t state)
        }
        return PCI_D0;
 }
-
 EXPORT_SYMBOL(pci_choose_state);
 
 #define PCI_EXP_SAVE_REGS      7
 
-
 static struct pci_cap_saved_state *_pci_find_saved_cap(struct pci_dev *pci_dev,
                                                       u16 cap, bool extended)
 {
@@ -1001,8 +1002,7 @@ static void pci_restore_pcix_state(struct pci_dev *dev)
  * pci_save_state - save the PCI configuration space of a device before suspending
  * @dev: - PCI device that we're dealing with
  */
-int
-pci_save_state(struct pci_dev *dev)
+int pci_save_state(struct pci_dev *dev)
 {
        int i;
        /* XXX: 100% dword access ok here? */
@@ -1017,6 +1017,7 @@ pci_save_state(struct pci_dev *dev)
                return i;
        return 0;
 }
+EXPORT_SYMBOL(pci_save_state);
 
 static void pci_restore_config_dword(struct pci_dev *pdev, int offset,
                                     u32 saved_val, int retry)
@@ -1028,8 +1029,8 @@ static void pci_restore_config_dword(struct pci_dev *pdev, int offset,
                return;
 
        for (;;) {
-               dev_dbg(&pdev->dev, "restoring config space at offset "
-                       "%#x (was %#x, writing %#x)\n", offset, val, saved_val);
+               dev_dbg(&pdev->dev, "restoring config space at offset %#x (was %#x, writing %#x)\n",
+                       offset, val, saved_val);
                pci_write_config_dword(pdev, offset, saved_val);
                if (retry-- <= 0)
                        return;
@@ -1087,6 +1088,7 @@ void pci_restore_state(struct pci_dev *dev)
 
        dev->state_saved = false;
 }
+EXPORT_SYMBOL(pci_restore_state);
 
 struct pci_saved_state {
        u32 config_space[16];
@@ -1231,6 +1233,7 @@ int pci_reenable_device(struct pci_dev *dev)
                return do_pci_enable_device(dev, (1 << PCI_NUM_RESOURCES) - 1);
        return 0;
 }
+EXPORT_SYMBOL(pci_reenable_device);
 
 static void pci_enable_bridge(struct pci_dev *dev)
 {
@@ -1305,6 +1308,7 @@ int pci_enable_device_io(struct pci_dev *dev)
 {
        return pci_enable_device_flags(dev, IORESOURCE_IO);
 }
+EXPORT_SYMBOL(pci_enable_device_io);
 
 /**
  * pci_enable_device_mem - Initialize a device for use with Memory space
@@ -1318,6 +1322,7 @@ int pci_enable_device_mem(struct pci_dev *dev)
 {
        return pci_enable_device_flags(dev, IORESOURCE_MEM);
 }
+EXPORT_SYMBOL(pci_enable_device_mem);
 
 /**
  * pci_enable_device - Initialize device before it's used by a driver.
@@ -1334,6 +1339,7 @@ int pci_enable_device(struct pci_dev *dev)
 {
        return pci_enable_device_flags(dev, IORESOURCE_MEM | IORESOURCE_IO);
 }
+EXPORT_SYMBOL(pci_enable_device);
 
 /*
  * Managed PCI resources.  This manages device on/off, intx/msi/msix
@@ -1371,7 +1377,7 @@ static void pcim_release(struct device *gendev, void *res)
                pci_disable_device(dev);
 }
 
-static struct pci_devres * get_pci_dr(struct pci_dev *pdev)
+static struct pci_devres *get_pci_dr(struct pci_dev *pdev)
 {
        struct pci_devres *dr, *new_dr;
 
@@ -1385,7 +1391,7 @@ static struct pci_devres * get_pci_dr(struct pci_dev *pdev)
        return devres_get(&pdev->dev, new_dr, NULL, NULL);
 }
 
-static struct pci_devres * find_pci_dr(struct pci_dev *pdev)
+static struct pci_devres *find_pci_dr(struct pci_dev *pdev)
 {
        if (pci_is_managed(pdev))
                return devres_find(&pdev->dev, pcim_release, NULL, NULL);
@@ -1416,6 +1422,7 @@ int pcim_enable_device(struct pci_dev *pdev)
        }
        return rc;
 }
+EXPORT_SYMBOL(pcim_enable_device);
 
 /**
  * pcim_pin_device - Pin managed PCI device
@@ -1434,6 +1441,7 @@ void pcim_pin_device(struct pci_dev *pdev)
        if (dr)
                dr->pinned = 1;
 }
+EXPORT_SYMBOL(pcim_pin_device);
 
 /*
  * pcibios_add_device - provide arch specific hooks when adding device dev
@@ -1443,7 +1451,7 @@ void pcim_pin_device(struct pci_dev *pdev)
  * devices are added. This is the default implementation. Architecture
  * implementations can override this.
  */
-int __weak pcibios_add_device (struct pci_dev *dev)
+int __weak pcibios_add_device(struct pci_dev *dev)
 {
        return 0;
 }
@@ -1468,6 +1476,17 @@ void __weak pcibios_release_device(struct pci_dev *dev) {}
  */
 void __weak pcibios_disable_device (struct pci_dev *dev) {}
 
+/**
+ * pcibios_penalize_isa_irq - penalize an ISA IRQ
+ * @irq: ISA IRQ to penalize
+ * @active: IRQ active or not
+ *
+ * Permits the platform to provide architecture-specific functionality when
+ * penalizing ISA IRQs. This is the default implementation. Architecture
+ * implementations can override this.
+ */
+void __weak pcibios_penalize_isa_irq(int irq, int active) {}
+
 static void do_pci_disable_device(struct pci_dev *dev)
 {
        u16 pci_command;
@@ -1504,8 +1523,7 @@ void pci_disable_enabled_device(struct pci_dev *dev)
  * Note we don't actually disable the device until all callers of
  * pci_enable_device() have called pci_disable_device().
  */
-void
-pci_disable_device(struct pci_dev *dev)
+void pci_disable_device(struct pci_dev *dev)
 {
        struct pci_devres *dr;
 
@@ -1523,6 +1541,7 @@ pci_disable_device(struct pci_dev *dev)
 
        dev->is_busmaster = 0;
 }
+EXPORT_SYMBOL(pci_disable_device);
 
 /**
  * pcibios_set_pcie_reset_state - set reset state for device dev
@@ -1551,6 +1570,7 @@ int pci_set_pcie_reset_state(struct pci_dev *dev, enum pcie_reset_state state)
 {
        return pcibios_set_pcie_reset_state(dev, state);
 }
+EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
 
 /**
  * pci_check_pme_status - Check if given device has generated PME.
@@ -1630,6 +1650,7 @@ bool pci_pme_capable(struct pci_dev *dev, pci_power_t state)
 
        return !!(dev->pme_support & (1 << state));
 }
+EXPORT_SYMBOL(pci_pme_capable);
 
 static void pci_pme_list_scan(struct work_struct *work)
 {
@@ -1734,6 +1755,7 @@ void pci_pme_active(struct pci_dev *dev, bool enable)
 
        dev_dbg(&dev->dev, "PME# %s\n", enable ? "enabled" : "disabled");
 }
+EXPORT_SYMBOL(pci_pme_active);
 
 /**
  * __pci_enable_wake - enable PCI device as wakeup event source
@@ -1819,6 +1841,7 @@ int pci_wake_from_d3(struct pci_dev *dev, bool enable)
                        pci_enable_wake(dev, PCI_D3cold, enable) :
                        pci_enable_wake(dev, PCI_D3hot, enable);
 }
+EXPORT_SYMBOL(pci_wake_from_d3);
 
 /**
  * pci_target_state - find an appropriate low power state for a given PCI dev
@@ -1897,6 +1920,7 @@ int pci_prepare_to_sleep(struct pci_dev *dev)
 
        return error;
 }
+EXPORT_SYMBOL(pci_prepare_to_sleep);
 
 /**
  * pci_back_from_sleep - turn PCI device on during system-wide transition into working state
@@ -1909,6 +1933,7 @@ int pci_back_from_sleep(struct pci_dev *dev)
        pci_enable_wake(dev, PCI_D0, false);
        return pci_set_power_state(dev, PCI_D0);
 }
+EXPORT_SYMBOL(pci_back_from_sleep);
 
 /**
  * pci_finish_runtime_suspend - Carry out PCI-specific part of runtime suspend.
@@ -2404,8 +2429,7 @@ u8 pci_swizzle_interrupt_pin(const struct pci_dev *dev, u8 pin)
        return (((pin - 1) + slot) % 4) + 1;
 }
 
-int
-pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
+int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge)
 {
        u8 pin;
 
@@ -2467,6 +2491,7 @@ void pci_release_region(struct pci_dev *pdev, int bar)
        if (dr)
                dr->region_mask &= ~(1 << bar);
 }
+EXPORT_SYMBOL(pci_release_region);
 
 /**
  *     __pci_request_region - Reserved PCI I/O and memory resource
@@ -2487,8 +2512,8 @@ void pci_release_region(struct pci_dev *pdev, int bar)
  *     Returns 0 on success, or %EBUSY on error.  A warning
  *     message is also printed on failure.
  */
-static int __pci_request_region(struct pci_dev *pdev, int bar, const char *res_name,
-                                                                       int exclusive)
+static int __pci_request_region(struct pci_dev *pdev, int bar,
+                               const char *res_name, int exclusive)
 {
        struct pci_devres *dr;
 
@@ -2499,8 +2524,7 @@ static int __pci_request_region(struct pci_dev *pdev, int bar, const char *res_n
                if (!request_region(pci_resource_start(pdev, bar),
                            pci_resource_len(pdev, bar), res_name))
                        goto err_out;
-       }
-       else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
+       } else if (pci_resource_flags(pdev, bar) & IORESOURCE_MEM) {
                if (!__request_mem_region(pci_resource_start(pdev, bar),
                                        pci_resource_len(pdev, bar), res_name,
                                        exclusive))
@@ -2537,6 +2561,7 @@ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
 {
        return __pci_request_region(pdev, bar, res_name, 0);
 }
+EXPORT_SYMBOL(pci_request_region);
 
 /**
  *     pci_request_region_exclusive - Reserved PCI I/O and memory resource
@@ -2556,10 +2581,13 @@ int pci_request_region(struct pci_dev *pdev, int bar, const char *res_name)
  *     explicitly not allowed to map the resource via /dev/mem or
  *     sysfs.
  */
-int pci_request_region_exclusive(struct pci_dev *pdev, int bar, const char *res_name)
+int pci_request_region_exclusive(struct pci_dev *pdev, int bar,
+                                const char *res_name)
 {
        return __pci_request_region(pdev, bar, res_name, IORESOURCE_EXCLUSIVE);
 }
+EXPORT_SYMBOL(pci_request_region_exclusive);
+
 /**
  * pci_release_selected_regions - Release selected PCI I/O and memory resources
  * @pdev: PCI device whose resources were previously reserved
@@ -2576,9 +2604,10 @@ void pci_release_selected_regions(struct pci_dev *pdev, int bars)
                if (bars & (1 << i))
                        pci_release_region(pdev, i);
 }
+EXPORT_SYMBOL(pci_release_selected_regions);
 
 static int __pci_request_selected_regions(struct pci_dev *pdev, int bars,
-                                const char *res_name, int excl)
+                                         const char *res_name, int excl)
 {
        int i;
 
@@ -2589,7 +2618,7 @@ static int __pci_request_selected_regions(struct pci_dev *pdev, int bars,
        return 0;
 
 err_out:
-       while(--i >= 0)
+       while (--i >= 0)
                if (bars & (1 << i))
                        pci_release_region(pdev, i);
 
@@ -2608,13 +2637,15 @@ int pci_request_selected_regions(struct pci_dev *pdev, int bars,
 {
        return __pci_request_selected_regions(pdev, bars, res_name, 0);
 }
+EXPORT_SYMBOL(pci_request_selected_regions);
 
-int pci_request_selected_regions_exclusive(struct pci_dev *pdev,
-                                int bars, const char *res_name)
+int pci_request_selected_regions_exclusive(struct pci_dev *pdev, int bars,
+                                          const char *res_name)
 {
        return __pci_request_selected_regions(pdev, bars, res_name,
                        IORESOURCE_EXCLUSIVE);
 }
+EXPORT_SYMBOL(pci_request_selected_regions_exclusive);
 
 /**
  *     pci_release_regions - Release reserved PCI I/O and memory resources
@@ -2629,6 +2660,7 @@ void pci_release_regions(struct pci_dev *pdev)
 {
        pci_release_selected_regions(pdev, (1 << 6) - 1);
 }
+EXPORT_SYMBOL(pci_release_regions);
 
 /**
  *     pci_request_regions - Reserved PCI I/O and memory resources
@@ -2647,6 +2679,7 @@ int pci_request_regions(struct pci_dev *pdev, const char *res_name)
 {
        return pci_request_selected_regions(pdev, ((1 << 6) - 1), res_name);
 }
+EXPORT_SYMBOL(pci_request_regions);
 
 /**
  *     pci_request_regions_exclusive - Reserved PCI I/O and memory resources
@@ -2669,6 +2702,7 @@ int pci_request_regions_exclusive(struct pci_dev *pdev, const char *res_name)
        return pci_request_selected_regions_exclusive(pdev,
                                        ((1 << 6) - 1), res_name);
 }
+EXPORT_SYMBOL(pci_request_regions_exclusive);
 
 static void __pci_set_master(struct pci_dev *dev, bool enable)
 {
@@ -2738,6 +2772,7 @@ void pci_set_master(struct pci_dev *dev)
        __pci_set_master(dev, true);
        pcibios_set_master(dev);
 }
+EXPORT_SYMBOL(pci_set_master);
 
 /**
  * pci_clear_master - disables bus-mastering for device dev
@@ -2747,6 +2782,7 @@ void pci_clear_master(struct pci_dev *dev)
 {
        __pci_set_master(dev, false);
 }
+EXPORT_SYMBOL(pci_clear_master);
 
 /**
  * pci_set_cacheline_size - ensure the CACHE_LINE_SIZE register is programmed
@@ -2779,30 +2815,13 @@ int pci_set_cacheline_size(struct pci_dev *dev)
        if (cacheline_size == pci_cache_line_size)
                return 0;
 
-       dev_printk(KERN_DEBUG, &dev->dev, "cache line size of %d is not "
-                  "supported\n", pci_cache_line_size << 2);
+       dev_printk(KERN_DEBUG, &dev->dev, "cache line size of %d is not supported\n",
+                  pci_cache_line_size << 2);
 
        return -EINVAL;
 }
 EXPORT_SYMBOL_GPL(pci_set_cacheline_size);
 
-#ifdef PCI_DISABLE_MWI
-int pci_set_mwi(struct pci_dev *dev)
-{
-       return 0;
-}
-
-int pci_try_set_mwi(struct pci_dev *dev)
-{
-       return 0;
-}
-
-void pci_clear_mwi(struct pci_dev *dev)
-{
-}
-
-#else
-
 /**
  * pci_set_mwi - enables memory-write-invalidate PCI transaction
  * @dev: the PCI device for which MWI is enabled
@@ -2811,9 +2830,11 @@ void pci_clear_mwi(struct pci_dev *dev)
  *
  * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
  */
-int
-pci_set_mwi(struct pci_dev *dev)
+int pci_set_mwi(struct pci_dev *dev)
 {
+#ifdef PCI_DISABLE_MWI
+       return 0;
+#else
        int rc;
        u16 cmd;
 
@@ -2822,14 +2843,15 @@ pci_set_mwi(struct pci_dev *dev)
                return rc;
 
        pci_read_config_word(dev, PCI_COMMAND, &cmd);
-       if (! (cmd & PCI_COMMAND_INVALIDATE)) {
+       if (!(cmd & PCI_COMMAND_INVALIDATE)) {
                dev_dbg(&dev->dev, "enabling Mem-Wr-Inval\n");
                cmd |= PCI_COMMAND_INVALIDATE;
                pci_write_config_word(dev, PCI_COMMAND, cmd);
        }
-
        return 0;
+#endif
 }
+EXPORT_SYMBOL(pci_set_mwi);
 
 /**
  * pci_try_set_mwi - enables memory-write-invalidate PCI transaction
@@ -2842,9 +2864,13 @@ pci_set_mwi(struct pci_dev *dev)
  */
 int pci_try_set_mwi(struct pci_dev *dev)
 {
-       int rc = pci_set_mwi(dev);
-       return rc;
+#ifdef PCI_DISABLE_MWI
+       return 0;
+#else
+       return pci_set_mwi(dev);
+#endif
 }
+EXPORT_SYMBOL(pci_try_set_mwi);
 
 /**
  * pci_clear_mwi - disables Memory-Write-Invalidate for device dev
@@ -2852,9 +2878,9 @@ int pci_try_set_mwi(struct pci_dev *dev)
  *
  * Disables PCI Memory-Write-Invalidate transaction on the device
  */
-void
-pci_clear_mwi(struct pci_dev *dev)
+void pci_clear_mwi(struct pci_dev *dev)
 {
+#ifndef PCI_DISABLE_MWI
        u16 cmd;
 
        pci_read_config_word(dev, PCI_COMMAND, &cmd);
@@ -2862,8 +2888,9 @@ pci_clear_mwi(struct pci_dev *dev)
                cmd &= ~PCI_COMMAND_INVALIDATE;
                pci_write_config_word(dev, PCI_COMMAND, cmd);
        }
+#endif
 }
-#endif /* ! PCI_DISABLE_MWI */
+EXPORT_SYMBOL(pci_clear_mwi);
 
 /**
  * pci_intx - enables/disables PCI INTx for device dev
@@ -2872,18 +2899,16 @@ pci_clear_mwi(struct pci_dev *dev)
  *
  * Enables/disables PCI INTx for device dev
  */
-void
-pci_intx(struct pci_dev *pdev, int enable)
+void pci_intx(struct pci_dev *pdev, int enable)
 {
        u16 pci_command, new;
 
        pci_read_config_word(pdev, PCI_COMMAND, &pci_command);
 
-       if (enable) {
+       if (enable)
                new = pci_command & ~PCI_COMMAND_INTX_DISABLE;
-       } else {
+       else
                new = pci_command | PCI_COMMAND_INTX_DISABLE;
-       }
 
        if (new != pci_command) {
                struct pci_devres *dr;
@@ -2897,6 +2922,7 @@ pci_intx(struct pci_dev *pdev, int enable)
                }
        }
 }
+EXPORT_SYMBOL_GPL(pci_intx);
 
 /**
  * pci_intx_mask_supported - probe for INTx masking support
@@ -2926,8 +2952,8 @@ bool pci_intx_mask_supported(struct pci_dev *dev)
         * go ahead and check it.
         */
        if ((new ^ orig) & ~PCI_COMMAND_INTX_DISABLE) {
-               dev_err(&dev->dev, "Command register changed from "
-                       "0x%x to 0x%x: driver or hardware bug?\n", orig, new);
+               dev_err(&dev->dev, "Command register changed from 0x%x to 0x%x: driver or hardware bug?\n",
+                       orig, new);
        } else if ((new ^ orig) & PCI_COMMAND_INTX_DISABLE) {
                mask_supported = true;
                pci_write_config_word(dev, PCI_COMMAND, orig);
@@ -3112,8 +3138,7 @@ static int pci_af_flr(struct pci_dev *dev, int probe)
        if (pci_wait_for_pending(dev, PCI_AF_STATUS, PCI_AF_STATUS_TP))
                goto clear;
 
-       dev_err(&dev->dev, "transaction is not cleared; "
-                       "proceeding with reset anyway\n");
+       dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n");
 
 clear:
        pci_write_config_byte(dev, pos + PCI_AF_CTRL, PCI_AF_CTRL_FLR);
@@ -3305,8 +3330,27 @@ static void pci_dev_unlock(struct pci_dev *dev)
        pci_cfg_access_unlock(dev);
 }
 
+/**
+ * pci_reset_notify - notify device driver of reset
+ * @dev: device to be notified of reset
+ * @prepare: 'true' if device is about to be reset; 'false' if reset attempt
+ *           completed
+ *
+ * Must be called prior to device access being disabled and after device
+ * access is restored.
+ */
+static void pci_reset_notify(struct pci_dev *dev, bool prepare)
+{
+       const struct pci_error_handlers *err_handler =
+                       dev->driver ? dev->driver->err_handler : NULL;
+       if (err_handler && err_handler->reset_notify)
+               err_handler->reset_notify(dev, prepare);
+}
+
 static void pci_dev_save_and_disable(struct pci_dev *dev)
 {
+       pci_reset_notify(dev, true);
+
        /*
         * Wake-up device prior to save.  PM registers default to D0 after
         * reset and a simple register restore doesn't reliably return
@@ -3328,6 +3372,7 @@ static void pci_dev_save_and_disable(struct pci_dev *dev)
 static void pci_dev_restore(struct pci_dev *dev)
 {
        pci_restore_state(dev);
+       pci_reset_notify(dev, false);
 }
 
 static int pci_dev_reset(struct pci_dev *dev, int probe)
@@ -3344,6 +3389,7 @@ static int pci_dev_reset(struct pci_dev *dev, int probe)
 
        return rc;
 }
+
 /**
  * __pci_reset_function - reset a PCI device function
  * @dev: PCI device to reset
@@ -4062,6 +4108,7 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags)
                        bars |= (1 << i);
        return bars;
 }
+EXPORT_SYMBOL(pci_select_bars);
 
 /**
  * pci_resource_bar - get position of the BAR associated with a resource
@@ -4101,7 +4148,7 @@ void __init pci_register_set_vga_state(arch_set_vga_state_t func)
 }
 
 static int pci_set_vga_state_arch(struct pci_dev *dev, bool decode,
-                     unsigned int command_bits, u32 flags)
+                                 unsigned int command_bits, u32 flags)
 {
        if (arch_set_vga_state)
                return arch_set_vga_state(dev, decode, command_bits,
@@ -4125,7 +4172,7 @@ int pci_set_vga_state(struct pci_dev *dev, bool decode,
        u16 cmd;
        int rc;
 
-       WARN_ON((flags & PCI_VGA_STATE_CHANGE_DECODES) & (command_bits & ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY)));
+       WARN_ON((flags & PCI_VGA_STATE_CHANGE_DECODES) && (command_bits & ~(PCI_COMMAND_IO|PCI_COMMAND_MEMORY)));
 
        /* ARCH specific VGA enables */
        rc = pci_set_vga_state_arch(dev, decode, command_bits, flags);
@@ -4213,11 +4260,10 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev)
                        bus == dev->bus->number &&
                        slot == PCI_SLOT(dev->devfn) &&
                        func == PCI_FUNC(dev->devfn)) {
-                       if (align_order == -1) {
+                       if (align_order == -1)
                                align = PAGE_SIZE;
-                       } else {
+                       else
                                align = 1 << align_order;
-                       }
                        /* Found */
                        break;
                }
@@ -4335,7 +4381,6 @@ static int __init pci_resource_alignment_sysfs_init(void)
        return bus_create_file(&pci_bus_type,
                                        &bus_attr_resource_alignment);
 }
-
 late_initcall(pci_resource_alignment_sysfs_init);
 
 static void pci_no_domains(void)
@@ -4414,41 +4459,3 @@ static int __init pci_setup(char *str)
        return 0;
 }
 early_param("pci", pci_setup);
-
-EXPORT_SYMBOL(pci_reenable_device);
-EXPORT_SYMBOL(pci_enable_device_io);
-EXPORT_SYMBOL(pci_enable_device_mem);
-EXPORT_SYMBOL(pci_enable_device);
-EXPORT_SYMBOL(pcim_enable_device);
-EXPORT_SYMBOL(pcim_pin_device);
-EXPORT_SYMBOL(pci_disable_device);
-EXPORT_SYMBOL(pci_find_capability);
-EXPORT_SYMBOL(pci_bus_find_capability);
-EXPORT_SYMBOL(pci_release_regions);
-EXPORT_SYMBOL(pci_request_regions);
-EXPORT_SYMBOL(pci_request_regions_exclusive);
-EXPORT_SYMBOL(pci_release_region);
-EXPORT_SYMBOL(pci_request_region);
-EXPORT_SYMBOL(pci_request_region_exclusive);
-EXPORT_SYMBOL(pci_release_selected_regions);
-EXPORT_SYMBOL(pci_request_selected_regions);
-EXPORT_SYMBOL(pci_request_selected_regions_exclusive);
-EXPORT_SYMBOL(pci_set_master);
-EXPORT_SYMBOL(pci_clear_master);
-EXPORT_SYMBOL(pci_set_mwi);
-EXPORT_SYMBOL(pci_try_set_mwi);
-EXPORT_SYMBOL(pci_clear_mwi);
-EXPORT_SYMBOL_GPL(pci_intx);
-EXPORT_SYMBOL(pci_assign_resource);
-EXPORT_SYMBOL(pci_find_parent_resource);
-EXPORT_SYMBOL(pci_select_bars);
-
-EXPORT_SYMBOL(pci_set_power_state);
-EXPORT_SYMBOL(pci_save_state);
-EXPORT_SYMBOL(pci_restore_state);
-EXPORT_SYMBOL(pci_pme_capable);
-EXPORT_SYMBOL(pci_pme_active);
-EXPORT_SYMBOL(pci_wake_from_d3);
-EXPORT_SYMBOL(pci_prepare_to_sleep);
-EXPORT_SYMBOL(pci_back_from_sleep);
-EXPORT_SYMBOL_GPL(pci_set_pcie_reset_state);
index 6bd082299e3190b5676e49d781231f49e5eaa3fc..0601890db22de96131af2d67fd872651ab608133 100644 (file)
@@ -77,7 +77,7 @@ static inline void pci_wakeup_event(struct pci_dev *dev)
        pm_wakeup_event(&dev->dev, 100);
 }
 
-static inline bool pci_is_bridge(struct pci_dev *pci_dev)
+static inline bool pci_has_subordinate(struct pci_dev *pci_dev)
 {
        return !!(pci_dev->subordinate);
 }
@@ -201,11 +201,11 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
                    struct resource *res, unsigned int reg);
 int pci_resource_bar(struct pci_dev *dev, int resno, enum pci_bar_type *type);
 void pci_configure_ari(struct pci_dev *dev);
-void __ref __pci_bus_size_bridges(struct pci_bus *bus,
+void __pci_bus_size_bridges(struct pci_bus *bus,
                        struct list_head *realloc_head);
-void __ref __pci_bus_assign_resources(const struct pci_bus *bus,
-                                     struct list_head *realloc_head,
-                                     struct list_head *fail_head);
+void __pci_bus_assign_resources(const struct pci_bus *bus,
+                               struct list_head *realloc_head,
+                               struct list_head *fail_head);
 
 /**
  * pci_ari_enabled - query ARI forwarding status
index 587e7e853107136b81f416d0e1e932db855bfa61..182224acedbe79c18dbc357cb45763afef40e387 100644 (file)
@@ -397,16 +397,14 @@ static int aer_inject(struct aer_error_inj *einj)
        if (!aer_mask_override && einj->cor_status &&
            !(einj->cor_status & ~cor_mask)) {
                ret = -EINVAL;
-               printk(KERN_WARNING "The correctable error(s) is masked "
-                               "by device\n");
+               printk(KERN_WARNING "The correctable error(s) is masked by device\n");
                spin_unlock_irqrestore(&inject_lock, flags);
                goto out_put;
        }
        if (!aer_mask_override && einj->uncor_status &&
            !(einj->uncor_status & ~uncor_mask)) {
                ret = -EINVAL;
-               printk(KERN_WARNING "The uncorrectable error(s) is masked "
-                               "by device\n");
+               printk(KERN_WARNING "The uncorrectable error(s) is masked by device\n");
                spin_unlock_irqrestore(&inject_lock, flags);
                goto out_put;
        }
@@ -464,8 +462,7 @@ static int aer_inject(struct aer_error_inj *einj)
                        goto out_put;
                }
                aer_irq(-1, edev);
-       }
-       else
+       } else
                ret = -EINVAL;
 out_put:
        kfree(err_alloc);
index b2c8881da764e582982cebe9a5062e69029dfca8..5653ea94547fc8a53caf0c050f0d499936cb4a41 100644 (file)
@@ -542,8 +542,7 @@ static void aer_recover_work_func(struct work_struct *work);
 #define AER_RECOVER_RING_ORDER         4
 #define AER_RECOVER_RING_SIZE          (1 << AER_RECOVER_RING_ORDER)
 
-struct aer_recover_entry
-{
+struct aer_recover_entry {
        u8      bus;
        u8      devfn;
        u16     domain;
index 34ff7026440cac0e929df3db06cba8f93b2a5c00..36ed31b52198804524746a060d8bb1275516d099 100644 (file)
@@ -172,9 +172,7 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
        int id = ((dev->bus->number << 8) | dev->devfn);
 
        if (!info->status) {
-               dev_err(&dev->dev,
-                       "PCIe Bus Error: severity=%s, type=Unaccessible, "
-                       "id=%04x(Unregistered Agent ID)\n",
+               dev_err(&dev->dev, "PCIe Bus Error: severity=%s, type=Unaccessible, id=%04x(Unregistered Agent ID)\n",
                        aer_error_severity_string[info->severity], id);
                goto out;
        }
@@ -182,13 +180,11 @@ void aer_print_error(struct pci_dev *dev, struct aer_err_info *info)
        layer = AER_GET_LAYER_ERROR(info->severity, info->status);
        agent = AER_GET_AGENT(info->severity, info->status);
 
-       dev_err(&dev->dev,
-               "PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
+       dev_err(&dev->dev, "PCIe Bus Error: severity=%s, type=%s, id=%04x(%s)\n",
                aer_error_severity_string[info->severity],
                aer_error_layer[layer], id, aer_agent_string[agent]);
 
-       dev_err(&dev->dev,
-               "  device [%04x:%04x] error status/mask=%08x/%08x\n",
+       dev_err(&dev->dev, "  device [%04x:%04x] error status/mask=%08x/%08x\n",
                dev->vendor, dev->device,
                info->status, info->mask);
 
index bbc3bdd2b189f8a91fa73fa8c8bca28b818359d9..82e06a86cd77b38ae99316e624b1cf72f26c7dd2 100644 (file)
@@ -199,8 +199,7 @@ static void pcie_pme_handle_request(struct pci_dev *port, u16 req_id)
                 * assuming that the PME was reported by a PCIe-PCI bridge that
                 * used devfn different from zero.
                 */
-               dev_dbg(&port->dev, "PME interrupt generated for "
-                       "non-existent device %02x:%02x.%d\n",
+               dev_dbg(&port->dev, "PME interrupt generated for non-existent device %02x:%02x.%d\n",
                        busnr, PCI_SLOT(devfn), PCI_FUNC(devfn));
                found = pcie_pme_from_pci_bridge(bus, 0);
        }
index 986f8eadfd39397aff7d38c71452d86b3e6fa530..2f0ce668a775eda0ccc15ea6bbfeea133ac6c823 100644 (file)
@@ -99,7 +99,7 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask)
        for (i = 0; i < nr_entries; i++)
                msix_entries[i].entry = i;
 
-       status = pci_enable_msix(dev, msix_entries, nr_entries);
+       status = pci_enable_msix_exact(dev, msix_entries, nr_entries);
        if (status)
                goto Exit;
 
@@ -171,7 +171,7 @@ static int pcie_port_enable_msix(struct pci_dev *dev, int *vectors, int mask)
                pci_disable_msix(dev);
 
                /* Now allocate the MSI-X vectors for real */
-               status = pci_enable_msix(dev, msix_entries, nvec);
+               status = pci_enable_msix_exact(dev, msix_entries, nvec);
                if (status)
                        goto Exit;
        }
@@ -379,10 +379,13 @@ int pcie_port_device_register(struct pci_dev *dev)
        /*
         * Initialize service irqs. Don't use service devices that
         * require interrupts if there is no way to generate them.
+        * However, some drivers may have a polling mode (e.g. pciehp_poll_mode)
+        * that can be used in the absence of irqs.  Allow them to determine
+        * if that is to be used.
         */
        status = init_service_irqs(dev, irqs, capabilities);
        if (status) {
-               capabilities &= PCIE_PORT_SERVICE_VC;
+               capabilities &= PCIE_PORT_SERVICE_VC | PCIE_PORT_SERVICE_HP;
                if (!capabilities)
                        goto error_disable;
        }
index 0d8fdc48e642ffcc421464ca226ebec78211148c..80887eaa0668f5c62393e466fc7e8eb70fe4bdc4 100644 (file)
@@ -204,8 +204,8 @@ static int pcie_portdrv_probe(struct pci_dev *dev,
                return -ENODEV;
 
        if (!dev->irq && dev->pin) {
-               dev_warn(&dev->dev, "device [%04x:%04x] has invalid IRQ; "
-                        "check vendor BIOS\n", dev->vendor, dev->device);
+               dev_warn(&dev->dev, "device [%04x:%04x] has invalid IRQ; check vendor BIOS\n",
+                        dev->vendor, dev->device);
        }
        status = pcie_port_device_register(dev);
        if (status)
@@ -397,7 +397,7 @@ static struct pci_driver pcie_portdriver = {
 static int __init dmi_pcie_pme_disable_msi(const struct dmi_system_id *d)
 {
        pr_notice("%s detected: will not use MSI for PCIe PME signaling\n",
-                       d->ident);
+                 d->ident);
        pcie_pme_disable_msi();
        return 0;
 }
index ef09f5f2fe6c0bc7f0ba84ae06eaa9d46adea4e6..e3cf8a2e629216208750bc96ed84285e7a2c0118 100644 (file)
@@ -168,12 +168,13 @@ static inline unsigned long decode_bar(struct pci_dev *dev, u32 bar)
  * Returns 1 if the BAR is 64-bit, or 0 if 32-bit.
  */
 int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
-                       struct resource *res, unsigned int pos)
+                   struct resource *res, unsigned int pos)
 {
        u32 l, sz, mask;
+       u64 l64, sz64, mask64;
        u16 orig_cmd;
        struct pci_bus_region region, inverted_region;
-       bool bar_too_big = false, bar_disabled = false;
+       bool bar_too_big = false, bar_too_high = false, bar_invalid = false;
 
        mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
 
@@ -226,9 +227,9 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
        }
 
        if (res->flags & IORESOURCE_MEM_64) {
-               u64 l64 = l;
-               u64 sz64 = sz;
-               u64 mask64 = mask | (u64)~0 << 32;
+               l64 = l;
+               sz64 = sz;
+               mask64 = mask | (u64)~0 << 32;
 
                pci_read_config_dword(dev, pos + 4, &l);
                pci_write_config_dword(dev, pos + 4, ~0);
@@ -243,19 +244,22 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
                if (!sz64)
                        goto fail;
 
-               if ((sizeof(resource_size_t) < 8) && (sz64 > 0x100000000ULL)) {
+               if ((sizeof(dma_addr_t) < 8 || sizeof(resource_size_t) < 8) &&
+                   sz64 > 0x100000000ULL) {
+                       res->flags |= IORESOURCE_UNSET | IORESOURCE_DISABLED;
+                       res->start = 0;
+                       res->end = 0;
                        bar_too_big = true;
-                       goto fail;
+                       goto out;
                }
 
-               if ((sizeof(resource_size_t) < 8) && l) {
-                       /* Address above 32-bit boundary; disable the BAR */
-                       pci_write_config_dword(dev, pos, 0);
-                       pci_write_config_dword(dev, pos + 4, 0);
+               if ((sizeof(dma_addr_t) < 8) && l) {
+                       /* Above 32-bit boundary; try to reallocate */
                        res->flags |= IORESOURCE_UNSET;
-                       region.start = 0;
-                       region.end = sz64;
-                       bar_disabled = true;
+                       res->start = 0;
+                       res->end = sz64;
+                       bar_too_high = true;
+                       goto out;
                } else {
                        region.start = l64;
                        region.end = l64 + sz64;
@@ -285,11 +289,10 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
         * be claimed by the device.
         */
        if (inverted_region.start != region.start) {
-               dev_info(&dev->dev, "reg 0x%x: initial BAR value %pa invalid; forcing reassignment\n",
-                        pos, &region.start);
                res->flags |= IORESOURCE_UNSET;
-               res->end -= res->start;
                res->start = 0;
+               res->end = region.end - region.start;
+               bar_invalid = true;
        }
 
        goto out;
@@ -303,8 +306,15 @@ out:
                pci_write_config_word(dev, PCI_COMMAND, orig_cmd);
 
        if (bar_too_big)
-               dev_err(&dev->dev, "reg 0x%x: can't handle 64-bit BAR\n", pos);
-       if (res->flags && !bar_disabled)
+               dev_err(&dev->dev, "reg 0x%x: can't handle BAR larger than 4GB (size %#010llx)\n",
+                       pos, (unsigned long long) sz64);
+       if (bar_too_high)
+               dev_info(&dev->dev, "reg 0x%x: can't handle BAR above 4G (bus address %#010llx)\n",
+                        pos, (unsigned long long) l64);
+       if (bar_invalid)
+               dev_info(&dev->dev, "reg 0x%x: initial BAR value %#010llx invalid\n",
+                        pos, (unsigned long long) region.start);
+       if (res->flags)
                dev_printk(KERN_DEBUG, &dev->dev, "reg 0x%x: %pR\n", pos, res);
 
        return (res->flags & IORESOURCE_MEM_64) ? 1 : 0;
@@ -423,8 +433,7 @@ static void pci_read_bridge_mmio_pref(struct pci_bus *child)
                        limit |= ((unsigned long) mem_limit_hi) << 32;
 #else
                        if (mem_base_hi || mem_limit_hi) {
-                               dev_err(&dev->dev, "can't handle 64-bit "
-                                       "address space for bridge\n");
+                               dev_err(&dev->dev, "can't handle 64-bit address space for bridge\n");
                                return;
                        }
 #endif
@@ -465,7 +474,7 @@ void pci_read_bridge_bases(struct pci_bus *child)
 
        if (dev->transparent) {
                pci_bus_for_each_resource(child->parent, res, i) {
-                       if (res) {
+                       if (res && res->flags) {
                                pci_bus_add_resource(child, res,
                                                     PCI_SUBTRACTIVE_DECODE);
                                dev_printk(KERN_DEBUG, &dev->dev,
@@ -594,7 +603,6 @@ static enum pci_bus_speed agp_speed(int agp3, int agpstat)
        return agp_speeds[index];
 }
 
-
 static void pci_set_bus_speed(struct pci_bus *bus)
 {
        struct pci_dev *bridge = bus->self;
@@ -626,11 +634,10 @@ static void pci_set_bus_speed(struct pci_bus *bus)
                } else if (status & PCI_X_SSTATUS_266MHZ) {
                        max = PCI_SPEED_133MHz_PCIX_266;
                } else if (status & PCI_X_SSTATUS_133MHZ) {
-                       if ((status & PCI_X_SSTATUS_VERS) == PCI_X_SSTATUS_V2) {
+                       if ((status & PCI_X_SSTATUS_VERS) == PCI_X_SSTATUS_V2)
                                max = PCI_SPEED_133MHz_PCIX_ECC;
-                       } else {
+                       else
                                max = PCI_SPEED_133MHz_PCIX;
-                       }
                } else {
                        max = PCI_SPEED_66MHz_PCIX;
                }
@@ -654,7 +661,6 @@ static void pci_set_bus_speed(struct pci_bus *bus)
        }
 }
 
-
 static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
                                           struct pci_dev *bridge, int busnr)
 {
@@ -719,7 +725,8 @@ add_dev:
        return child;
 }
 
-struct pci_bus *__ref pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev, int busnr)
+struct pci_bus *pci_add_new_bus(struct pci_bus *parent, struct pci_dev *dev,
+                               int busnr)
 {
        struct pci_bus *child;
 
@@ -731,6 +738,7 @@ struct pci_bus *__ref pci_add_new_bus(struct pci_bus *parent, struct pci_dev *de
        }
        return child;
 }
+EXPORT_SYMBOL(pci_add_new_bus);
 
 /*
  * If it's a bridge, configure it and scan the bus behind it.
@@ -877,7 +885,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
                         * as cards with a PCI-to-PCI bridge can be
                         * inserted later.
                         */
-                       for (i=0; i<CARDBUS_RESERVE_BUSNR; i++) {
+                       for (i = 0; i < CARDBUS_RESERVE_BUSNR; i++) {
                                struct pci_bus *parent = bus;
                                if (pci_find_bus(pci_domain_nr(bus),
                                                        max+i+1))
@@ -924,8 +932,7 @@ int pci_scan_bridge(struct pci_bus *bus, struct pci_dev *dev, int max, int pass)
                    (child->number > bus->busn_res.end) ||
                    (child->number < bus->number) ||
                    (child->busn_res.end < bus->number)) {
-                       dev_info(&child->dev, "%pR %s "
-                               "hidden behind%s bridge %s %pR\n",
+                       dev_info(&child->dev, "%pR %s hidden behind%s bridge %s %pR\n",
                                &child->busn_res,
                                (bus->number > child->busn_res.end &&
                                 bus->busn_res.end < child->number) ?
@@ -942,6 +949,7 @@ out:
 
        return max;
 }
+EXPORT_SYMBOL(pci_scan_bridge);
 
 /*
  * Read interrupt line and base address registers.
@@ -982,6 +990,42 @@ void set_pcie_hotplug_bridge(struct pci_dev *pdev)
                pdev->is_hotplug_bridge = 1;
 }
 
+/**
+ * pci_ext_cfg_is_aliased - is ext config space just an alias of std config?
+ * @dev: PCI device
+ *
+ * PCI Express to PCI/PCI-X Bridge Specification, rev 1.0, 4.1.4 says that
+ * when forwarding a type1 configuration request the bridge must check that
+ * the extended register address field is zero.  The bridge is not permitted
+ * to forward the transactions and must handle it as an Unsupported Request.
+ * Some bridges do not follow this rule and simply drop the extended register
+ * bits, resulting in the standard config space being aliased, every 256
+ * bytes across the entire configuration space.  Test for this condition by
+ * comparing the first dword of each potential alias to the vendor/device ID.
+ * Known offenders:
+ *   ASM1083/1085 PCIe-to-PCI Reversible Bridge (1b21:1080, rev 01 & 03)
+ *   AMD/ATI SBx00 PCI to PCI Bridge (1002:4384, rev 40)
+ */
+static bool pci_ext_cfg_is_aliased(struct pci_dev *dev)
+{
+#ifdef CONFIG_PCI_QUIRKS
+       int pos;
+       u32 header, tmp;
+
+       pci_read_config_dword(dev, PCI_VENDOR_ID, &header);
+
+       for (pos = PCI_CFG_SPACE_SIZE;
+            pos < PCI_CFG_SPACE_EXP_SIZE; pos += PCI_CFG_SPACE_SIZE) {
+               if (pci_read_config_dword(dev, pos, &tmp) != PCIBIOS_SUCCESSFUL
+                   || header != tmp)
+                       return false;
+       }
+
+       return true;
+#else
+       return false;
+#endif
+}
 
 /**
  * pci_cfg_space_size - get the configuration space size of the PCI device.
@@ -1001,7 +1045,7 @@ static int pci_cfg_space_size_ext(struct pci_dev *dev)
 
        if (pci_read_config_dword(dev, pos, &status) != PCIBIOS_SUCCESSFUL)
                goto fail;
-       if (status == 0xffffffff)
+       if (status == 0xffffffff || pci_ext_cfg_is_aliased(dev))
                goto fail;
 
        return PCI_CFG_SPACE_EXP_SIZE;
@@ -1178,13 +1222,13 @@ int pci_setup_device(struct pci_dev *dev)
                break;
 
        default:                                    /* unknown header */
-               dev_err(&dev->dev, "unknown header type %02x, "
-                       "ignoring device\n", dev->hdr_type);
+               dev_err(&dev->dev, "unknown header type %02x, ignoring device\n",
+                       dev->hdr_type);
                return -EIO;
 
        bad:
-               dev_err(&dev->dev, "ignoring class %#08x (doesn't match header "
-                       "type %02x)\n", dev->class, dev->hdr_type);
+               dev_err(&dev->dev, "ignoring class %#08x (doesn't match header type %02x)\n",
+                       dev->class, dev->hdr_type);
                dev->class = PCI_CLASS_NOT_DEFINED;
        }
 
@@ -1215,6 +1259,7 @@ static void pci_release_dev(struct device *dev)
        pci_release_of_node(pci_dev);
        pcibios_release_device(pci_dev);
        pci_bus_put(pci_dev->bus);
+       kfree(pci_dev->driver_override);
        kfree(pci_dev);
 }
 
@@ -1235,7 +1280,7 @@ struct pci_dev *pci_alloc_dev(struct pci_bus *bus)
 EXPORT_SYMBOL(pci_alloc_dev);
 
 bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
-                                int crs_timeout)
+                               int crs_timeout)
 {
        int delay = 1;
 
@@ -1258,10 +1303,9 @@ bool pci_bus_read_dev_vendor_id(struct pci_bus *bus, int devfn, u32 *l,
                        return false;
                /* Card hasn't responded in 60 seconds?  Must be stuck. */
                if (delay > crs_timeout) {
-                       printk(KERN_WARNING "pci %04x:%02x:%02x.%d: not "
-                                       "responding\n", pci_domain_nr(bus),
-                                       bus->number, PCI_SLOT(devfn),
-                                       PCI_FUNC(devfn));
+                       printk(KERN_WARNING "pci %04x:%02x:%02x.%d: not responding\n",
+                              pci_domain_nr(bus), bus->number, PCI_SLOT(devfn),
+                              PCI_FUNC(devfn));
                        return false;
                }
        }
@@ -1369,7 +1413,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus)
        WARN_ON(ret < 0);
 }
 
-struct pci_dev *__ref pci_scan_single_device(struct pci_bus *bus, int devfn)
+struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn)
 {
        struct pci_dev *dev;
 
@@ -1471,6 +1515,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn)
 
        return nr;
 }
+EXPORT_SYMBOL(pci_scan_slot);
 
 static int pcie_find_smpss(struct pci_dev *dev, void *data)
 {
@@ -1565,9 +1610,7 @@ static void pcie_write_mrrs(struct pci_dev *dev)
        }
 
        if (mrrs < 128)
-               dev_err(&dev->dev, "MRRS was unable to be configured with a "
-                       "safe value.  If problems are experienced, try running "
-                       "with pci=pcie_bus_safe.\n");
+               dev_err(&dev->dev, "MRRS was unable to be configured with a safe value.  If problems are experienced, try running with pci=pcie_bus_safe\n");
 }
 
 static void pcie_bus_detect_mps(struct pci_dev *dev)
@@ -1604,8 +1647,8 @@ static int pcie_bus_configure_set(struct pci_dev *dev, void *data)
        pcie_write_mps(dev, mps);
        pcie_write_mrrs(dev);
 
-       dev_info(&dev->dev, "Max Payload Size set to %4d/%4d (was %4d), "
-                "Max Read Rq %4d\n", pcie_get_mps(dev), 128 << dev->pcie_mpss,
+       dev_info(&dev->dev, "Max Payload Size set to %4d/%4d (was %4d), Max Read Rq %4d\n",
+                pcie_get_mps(dev), 128 << dev->pcie_mpss,
                 orig_mps, pcie_get_readrq(dev));
 
        return 0;
@@ -1617,7 +1660,7 @@ static int pcie_bus_configure_set(struct pci_dev *dev, void *data)
  */
 void pcie_bus_configure_settings(struct pci_bus *bus)
 {
-       u8 smpss;
+       u8 smpss = 0;
 
        if (!bus->self)
                return;
@@ -1668,10 +1711,9 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
                bus->is_added = 1;
        }
 
-       for (pass=0; pass < 2; pass++)
+       for (pass = 0; pass < 2; pass++)
                list_for_each_entry(dev, &bus->devices, bus_list) {
-                       if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-                           dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
+                       if (pci_is_bridge(dev))
                                max = pci_scan_bridge(bus, dev, max, pass);
                }
 
@@ -1685,6 +1727,7 @@ unsigned int pci_scan_child_bus(struct pci_bus *bus)
        dev_dbg(&bus->dev, "bus scan returning with max=%02x\n", max);
        return max;
 }
+EXPORT_SYMBOL_GPL(pci_scan_child_bus);
 
 /**
  * pcibios_root_bridge_prepare - Platform-specific host bridge setup.
@@ -1958,7 +2001,7 @@ EXPORT_SYMBOL(pci_scan_bus);
  *
  * Returns the max number of subordinate bus discovered.
  */
-unsigned int __ref pci_rescan_bus_bridge_resize(struct pci_dev *bridge)
+unsigned int pci_rescan_bus_bridge_resize(struct pci_dev *bridge)
 {
        unsigned int max;
        struct pci_bus *bus = bridge->subordinate;
@@ -1981,7 +2024,7 @@ unsigned int __ref pci_rescan_bus_bridge_resize(struct pci_dev *bridge)
  *
  * Returns the max number of subordinate bus discovered.
  */
-unsigned int __ref pci_rescan_bus(struct pci_bus *bus)
+unsigned int pci_rescan_bus(struct pci_bus *bus)
 {
        unsigned int max;
 
@@ -1993,11 +2036,6 @@ unsigned int __ref pci_rescan_bus(struct pci_bus *bus)
 }
 EXPORT_SYMBOL_GPL(pci_rescan_bus);
 
-EXPORT_SYMBOL(pci_add_new_bus);
-EXPORT_SYMBOL(pci_scan_slot);
-EXPORT_SYMBOL(pci_scan_bridge);
-EXPORT_SYMBOL_GPL(pci_scan_child_bus);
-
 /*
  * pci_rescan_bus(), pci_rescan_bus_bridge_resize() and PCI device removal
  * routines should always be executed under this mutex.
@@ -2016,7 +2054,8 @@ void pci_unlock_rescan_remove(void)
 }
 EXPORT_SYMBOL_GPL(pci_unlock_rescan_remove);
 
-static int __init pci_sort_bf_cmp(const struct device *d_a, const struct device *d_b)
+static int __init pci_sort_bf_cmp(const struct device *d_a,
+                                 const struct device *d_b)
 {
        const struct pci_dev *a = to_pci_dev(d_a);
        const struct pci_dev *b = to_pci_dev(d_b);
index 46d1378f2e9ebd1aeb6ee8252af551a0350bb80b..3f155e78513fd4171dc4b57c5b7b3b41e7afea20 100644 (file)
 
 static int proc_initialized;   /* = 0 */
 
-static loff_t
-proc_bus_pci_lseek(struct file *file, loff_t off, int whence)
+static loff_t proc_bus_pci_lseek(struct file *file, loff_t off, int whence)
 {
        struct pci_dev *dev = PDE_DATA(file_inode(file));
        return fixed_size_llseek(file, off, whence, dev->cfg_size);
 }
 
-static ssize_t
-proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos)
+static ssize_t proc_bus_pci_read(struct file *file, char __user *buf,
+                                size_t nbytes, loff_t *ppos)
 {
        struct pci_dev *dev = PDE_DATA(file_inode(file));
        unsigned int pos = *ppos;
@@ -108,8 +107,8 @@ proc_bus_pci_read(struct file *file, char __user *buf, size_t nbytes, loff_t *pp
        return nbytes;
 }
 
-static ssize_t
-proc_bus_pci_write(struct file *file, const char __user *buf, size_t nbytes, loff_t *ppos)
+static ssize_t proc_bus_pci_write(struct file *file, const char __user *buf,
+                                 size_t nbytes, loff_t *ppos)
 {
        struct inode *ino = file_inode(file);
        struct pci_dev *dev = PDE_DATA(ino);
@@ -413,7 +412,7 @@ int pci_proc_detach_device(struct pci_dev *dev)
        return 0;
 }
 
-int pci_proc_detach_bus(struct pci_busbus)
+int pci_proc_detach_bus(struct pci_bus *bus)
 {
        proc_remove(bus->procdir);
        return 0;
@@ -423,6 +422,7 @@ static int proc_bus_pci_dev_open(struct inode *inode, struct file *file)
 {
        return seq_open(file, &proc_bus_pci_devices_op);
 }
+
 static const struct file_operations proc_bus_pci_dev_operations = {
        .owner          = THIS_MODULE,
        .open           = proc_bus_pci_dev_open,
@@ -443,6 +443,4 @@ static int __init pci_proc_init(void)
 
        return 0;
 }
-
 device_initcall(pci_proc_init);
-
index 6adbbe2e2280fa6d2fd84cc7f0783580ffa985ff..d0f69269eb6c4ced67b7ef688d20ff2bbd1f25cd 100644 (file)
@@ -48,8 +48,8 @@ static void quirk_mellanox_tavor(struct pci_dev *dev)
 {
        dev->broken_parity_status = 1;  /* This device gives false positives */
 }
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX,PCI_DEVICE_ID_MELLANOX_TAVOR,quirk_mellanox_tavor);
-DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX,PCI_DEVICE_ID_MELLANOX_TAVOR_BRIDGE,quirk_mellanox_tavor);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_TAVOR, quirk_mellanox_tavor);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_MELLANOX, PCI_DEVICE_ID_MELLANOX_TAVOR_BRIDGE, quirk_mellanox_tavor);
 
 /* Deal with broken BIOSes that neglect to enable passive release,
    which can cause problems in combination with the 82441FX/PPro MTRRs */
@@ -82,7 +82,7 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82441,      quirk_p
 static void quirk_isa_dma_hangs(struct pci_dev *dev)
 {
        if (!isa_dma_bridge_buggy) {
-               isa_dma_bridge_buggy=1;
+               isa_dma_bridge_buggy = 1;
                dev_info(&dev->dev, "Activating ISA DMA hang workarounds\n");
        }
 }
@@ -123,7 +123,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_TGP_LPC, quirk
  */
 static void quirk_nopcipci(struct pci_dev *dev)
 {
-       if ((pci_pci_problems & PCIPCI_FAIL)==0) {
+       if ((pci_pci_problems & PCIPCI_FAIL) == 0) {
                dev_info(&dev->dev, "Disabling direct PCI/PCI transfers\n");
                pci_pci_problems |= PCIPCI_FAIL;
        }
@@ -148,7 +148,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD,  PCI_DEVICE_ID_AMD_8151_0,       quirk_nopci
  */
 static void quirk_triton(struct pci_dev *dev)
 {
-       if ((pci_pci_problems&PCIPCI_TRITON)==0) {
+       if ((pci_pci_problems&PCIPCI_TRITON) == 0) {
                dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
                pci_pci_problems |= PCIPCI_TRITON;
        }
@@ -163,8 +163,8 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL,        PCI_DEVICE_ID_INTEL_82439TX,    quirk_
  *     Made according to a windows driver based patch by George E. Breese
  *     see PCI Latency Adjust on http://www.viahardware.com/download/viatweak.shtm
  *     and http://www.georgebreese.com/net/software/#PCI
- *      Also see http://www.au-ja.org/review-kt133a-1-en.phtml for
- *      the info on which Mr Breese based his work.
+ *     Also see http://www.au-ja.org/review-kt133a-1-en.phtml for
+ *     the info on which Mr Breese based his work.
  *
  *     Updated based on further information from the site and also on
  *     information provided by VIA
@@ -177,14 +177,14 @@ static void quirk_vialatency(struct pci_dev *dev)
           a buggy southbridge */
 
        p = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C686, NULL);
-       if (p!=NULL) {
+       if (p != NULL) {
                /* 0x40 - 0x4f == 686B, 0x10 - 0x2f == 686A; thanks Dan Hollis */
                /* Check for buggy part revisions */
                if (p->revision < 0x40 || p->revision > 0x42)
                        goto exit;
        } else {
                p = pci_get_device(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8231, NULL);
-               if (p==NULL)    /* No problem parts */
+               if (p == NULL)  /* No problem parts */
                        goto exit;
                /* Check for buggy part revisions */
                if (p->revision < 0x10 || p->revision > 0x12)
@@ -227,7 +227,7 @@ DECLARE_PCI_FIXUP_RESUME(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8361,         quirk_viala
  */
 static void quirk_viaetbf(struct pci_dev *dev)
 {
-       if ((pci_pci_problems&PCIPCI_VIAETBF)==0) {
+       if ((pci_pci_problems&PCIPCI_VIAETBF) == 0) {
                dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
                pci_pci_problems |= PCIPCI_VIAETBF;
        }
@@ -236,7 +236,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,  PCI_DEVICE_ID_VIA_82C597_0,     quirk_via
 
 static void quirk_vsfx(struct pci_dev *dev)
 {
-       if ((pci_pci_problems&PCIPCI_VSFX)==0) {
+       if ((pci_pci_problems&PCIPCI_VSFX) == 0) {
                dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
                pci_pci_problems |= PCIPCI_VSFX;
        }
@@ -251,7 +251,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,  PCI_DEVICE_ID_VIA_82C576,       quirk_vsfx)
  */
 static void quirk_alimagik(struct pci_dev *dev)
 {
-       if ((pci_pci_problems&PCIPCI_ALIMAGIK)==0) {
+       if ((pci_pci_problems&PCIPCI_ALIMAGIK) == 0) {
                dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
                pci_pci_problems |= PCIPCI_ALIMAGIK|PCIPCI_TRITON;
        }
@@ -265,7 +265,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AL,   PCI_DEVICE_ID_AL_M1651,         quirk_alimagi
  */
 static void quirk_natoma(struct pci_dev *dev)
 {
-       if ((pci_pci_problems&PCIPCI_NATOMA)==0) {
+       if ((pci_pci_problems&PCIPCI_NATOMA) == 0) {
                dev_info(&dev->dev, "Limiting direct PCI/PCI transfers\n");
                pci_pci_problems |= PCIPCI_NATOMA;
        }
@@ -315,8 +315,7 @@ static void quirk_cs5536_vsa(struct pci_dev *dev)
        if (pci_resource_len(dev, 0) != 8) {
                struct resource *res = &dev->resource[0];
                res->end = res->start + 8 - 1;
-               dev_info(&dev->dev, "CS5536 ISA bridge bug detected "
-                               "(incorrect header); workaround applied.\n");
+               dev_info(&dev->dev, "CS5536 ISA bridge bug detected (incorrect header); workaround applied\n");
        }
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_CS5536_ISA, quirk_cs5536_vsa);
@@ -400,7 +399,8 @@ static void piix4_io_quirk(struct pci_dev *dev, const char *name, unsigned int p
         * let's get enough confirmation reports first.
         */
        base &= -size;
-       dev_info(&dev->dev, "%s PIO at %04x-%04x\n", name, base, base + size - 1);
+       dev_info(&dev->dev, "%s PIO at %04x-%04x\n", name, base,
+                base + size - 1);
 }
 
 static void piix4_mem_quirk(struct pci_dev *dev, const char *name, unsigned int port, unsigned int enable)
@@ -425,7 +425,8 @@ static void piix4_mem_quirk(struct pci_dev *dev, const char *name, unsigned int
         * reserve it, but let's get enough confirmation reports first.
         */
        base &= -size;
-       dev_info(&dev->dev, "%s MMIO at %04x-%04x\n", name, base, base + size - 1);
+       dev_info(&dev->dev, "%s MMIO at %04x-%04x\n", name, base,
+                base + size - 1);
 }
 
 /*
@@ -668,8 +669,7 @@ static void quirk_xio2000a(struct pci_dev *dev)
        struct pci_dev *pdev;
        u16 command;
 
-       dev_warn(&dev->dev, "TI XIO2000a quirk detected; "
-               "secondary bus fast back-to-back transfers disabled\n");
+       dev_warn(&dev->dev, "TI XIO2000a quirk detected; secondary bus fast back-to-back transfers disabled\n");
        list_for_each_entry(pdev, &dev->subordinate->devices, bus_list) {
                pci_read_config_word(pdev, PCI_COMMAND, &command);
                if (command & PCI_COMMAND_FAST_BACK)
@@ -703,7 +703,7 @@ static void quirk_via_ioapic(struct pci_dev *dev)
               tmp == 0 ? "Disa" : "Ena");
 
        /* Offset 0x58: External APIC IRQ output control */
-       pci_write_config_byte (dev, 0x58, tmp);
+       pci_write_config_byte(dev, 0x58, tmp);
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA,     PCI_DEVICE_ID_VIA_82C686,       quirk_via_ioapic);
 DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_VIA,      PCI_DEVICE_ID_VIA_82C686,       quirk_via_ioapic);
@@ -761,8 +761,8 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_SI,   PCI_ANY_ID,                     quirk_ioapic_rmw);
 static void quirk_amd_8131_mmrbc(struct pci_dev *dev)
 {
        if (dev->subordinate && dev->revision <= 0x12) {
-               dev_info(&dev->dev, "AMD8131 rev %x detected; "
-                       "disabling PCI-X MMRBC\n", dev->revision);
+               dev_info(&dev->dev, "AMD8131 rev %x detected; disabling PCI-X MMRBC\n",
+                        dev->revision);
                dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MMRBC;
        }
 }
@@ -916,12 +916,12 @@ static void quirk_amd_ordering(struct pci_dev *dev)
 {
        u32 pcic;
        pci_read_config_dword(dev, 0x4C, &pcic);
-       if ((pcic&6)!=6) {
+       if ((pcic & 6) != 6) {
                pcic |= 6;
                dev_warn(&dev->dev, "BIOS failed to enable PCI standards compliance; fixing this error\n");
                pci_write_config_dword(dev, 0x4C, pcic);
                pci_read_config_dword(dev, 0x84, &pcic);
-               pcic |= (1<<23);        /* Required in this mode */
+               pcic |= (1 << 23);      /* Required in this mode */
                pci_write_config_dword(dev, 0x84, pcic);
        }
 }
@@ -937,7 +937,7 @@ DECLARE_PCI_FIXUP_RESUME_EARLY(PCI_VENDOR_ID_AMD,   PCI_DEVICE_ID_AMD_FE_GATE_700C
  */
 static void quirk_dunord(struct pci_dev *dev)
 {
-       struct resource *r = &dev->resource [1];
+       struct resource *r = &dev->resource[1];
 
        r->flags |= IORESOURCE_UNSET;
        r->start = 0;
@@ -967,11 +967,13 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TOSHIBA,   0x605,  quirk_transparent_bridge)
 static void quirk_mediagx_master(struct pci_dev *dev)
 {
        u8 reg;
+
        pci_read_config_byte(dev, 0x41, &reg);
        if (reg & 2) {
                reg &= ~2;
-               dev_info(&dev->dev, "Fixup for MediaGX/Geode Slave Disconnect Boundary (0x41=0x%02x)\n", reg);
-                pci_write_config_byte(dev, 0x41, reg);
+               dev_info(&dev->dev, "Fixup for MediaGX/Geode Slave Disconnect Boundary (0x41=0x%02x)\n",
+                        reg);
+               pci_write_config_byte(dev, 0x41, reg);
        }
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_CYRIX,   PCI_DEVICE_ID_CYRIX_PCI_MASTER, quirk_mediagx_master);
@@ -1120,7 +1122,7 @@ static void asus_hides_smbus_hostbridge(struct pci_dev *dev)
 {
        if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_ASUSTEK)) {
                if (dev->device == PCI_DEVICE_ID_INTEL_82845_HB)
-                       switch(dev->subsystem_device) {
+                       switch (dev->subsystem_device) {
                        case 0x8025: /* P4B-LX */
                        case 0x8070: /* P4B */
                        case 0x8088: /* P4B533 */
@@ -1128,14 +1130,14 @@ static void asus_hides_smbus_hostbridge(struct pci_dev *dev)
                                asus_hides_smbus = 1;
                        }
                else if (dev->device == PCI_DEVICE_ID_INTEL_82845G_HB)
-                       switch(dev->subsystem_device) {
+                       switch (dev->subsystem_device) {
                        case 0x80b1: /* P4GE-V */
                        case 0x80b2: /* P4PE */
                        case 0x8093: /* P4B533-V */
                                asus_hides_smbus = 1;
                        }
                else if (dev->device == PCI_DEVICE_ID_INTEL_82850_HB)
-                       switch(dev->subsystem_device) {
+                       switch (dev->subsystem_device) {
                        case 0x8030: /* P4T533 */
                                asus_hides_smbus = 1;
                        }
@@ -1175,7 +1177,7 @@ static void asus_hides_smbus_hostbridge(struct pci_dev *dev)
                        }
        } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_HP)) {
                if (dev->device ==  PCI_DEVICE_ID_INTEL_82855PM_HB)
-                       switch(dev->subsystem_device) {
+                       switch (dev->subsystem_device) {
                        case 0x088C: /* HP Compaq nc8000 */
                        case 0x0890: /* HP Compaq nc6000 */
                                asus_hides_smbus = 1;
@@ -1192,20 +1194,20 @@ static void asus_hides_smbus_hostbridge(struct pci_dev *dev)
                        case 0x12bf: /* HP xw4100 */
                                asus_hides_smbus = 1;
                        }
-       } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG)) {
-               if (dev->device ==  PCI_DEVICE_ID_INTEL_82855PM_HB)
-                       switch(dev->subsystem_device) {
-                       case 0xC00C: /* Samsung P35 notebook */
-                               asus_hides_smbus = 1;
-                       }
+       } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_SAMSUNG)) {
+               if (dev->device ==  PCI_DEVICE_ID_INTEL_82855PM_HB)
+                       switch (dev->subsystem_device) {
+                       case 0xC00C: /* Samsung P35 notebook */
+                               asus_hides_smbus = 1;
+               }
        } else if (unlikely(dev->subsystem_vendor == PCI_VENDOR_ID_COMPAQ)) {
                if (dev->device == PCI_DEVICE_ID_INTEL_82855PM_HB)
-                       switch(dev->subsystem_device) {
+                       switch (dev->subsystem_device) {
                        case 0x0058: /* Compaq Evo N620c */
                                asus_hides_smbus = 1;
                        }
                else if (dev->device == PCI_DEVICE_ID_INTEL_82810_IG3)
-                       switch(dev->subsystem_device) {
+                       switch (dev->subsystem_device) {
                        case 0xB16C: /* Compaq Deskpro EP 401963-001 (PCA# 010174) */
                                /* Motherboard doesn't have Host bridge
                                 * subvendor/subdevice IDs, therefore checking
@@ -1213,7 +1215,7 @@ static void asus_hides_smbus_hostbridge(struct pci_dev *dev)
                                asus_hides_smbus = 1;
                        }
                else if (dev->device == PCI_DEVICE_ID_INTEL_82801DB_2)
-                       switch(dev->subsystem_device) {
+                       switch (dev->subsystem_device) {
                        case 0x00b8: /* Compaq Evo D510 CMT */
                        case 0x00b9: /* Compaq Evo D510 SFF */
                        case 0x00ba: /* Compaq Evo D510 USDT */
@@ -1261,7 +1263,8 @@ static void asus_hides_smbus_lpc(struct pci_dev *dev)
                pci_write_config_word(dev, 0xF2, val & (~0x8));
                pci_read_config_word(dev, 0xF2, &val);
                if (val & 0x8)
-                       dev_info(&dev->dev, "i801 SMBus device continues to play 'hide and seek'! 0x%x\n", val);
+                       dev_info(&dev->dev, "i801 SMBus device continues to play 'hide and seek'! 0x%x\n",
+                                val);
                else
                        dev_info(&dev->dev, "Enabled i801 SMBus device\n");
        }
@@ -1409,7 +1412,8 @@ static void asus_hides_ac97_lpc(struct pci_dev *dev)
                pci_write_config_byte(dev, 0x50, val & (~0xc0));
                pci_read_config_byte(dev, 0x50, &val);
                if (val & 0xc0)
-                       dev_info(&dev->dev, "Onboard AC97/MC97 devices continue to play 'hide and seek'! 0x%x\n", val);
+                       dev_info(&dev->dev, "Onboard AC97/MC97 devices continue to play 'hide and seek'! 0x%x\n",
+                                val);
                else
                        dev_info(&dev->dev, "Enabled onboard AC97/MC97 devices\n");
        }
@@ -1514,10 +1518,8 @@ static void quirk_alder_ioapic(struct pci_dev *pdev)
 
        /* The next five BARs all seem to be rubbish, so just clean
         * them out */
-       for (i=1; i < 6; i++) {
+       for (i = 1; i < 6; i++)
                memset(&pdev->resource[i], 0, sizeof(pdev->resource[i]));
-       }
-
 }
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL,  PCI_DEVICE_ID_INTEL_EESSC,      quirk_alder_ioapic);
 #endif
@@ -1552,7 +1554,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL,      PCI_DEVICE_ID_INTEL_PXHV,       quirk_pci
  * Some Intel PCI Express chipsets have trouble with downstream
  * device power management.
  */
-static void quirk_intel_pcie_pm(struct pci_dev * dev)
+static void quirk_intel_pcie_pm(struct pci_dev *dev)
 {
        pci_pm_d3_delay = 120;
        dev->no_d1d2 = 1;
@@ -1721,8 +1723,8 @@ static void quirk_disable_amd_8111_boot_interrupt(struct pci_dev *dev)
 
        pci_read_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, &pci_config_word);
        if (!pci_config_word) {
-               dev_info(&dev->dev, "boot interrupts on device [%04x:%04x] "
-                        "already disabled\n", dev->vendor, dev->device);
+               dev_info(&dev->dev, "boot interrupts on device [%04x:%04x] already disabled\n",
+                        dev->vendor, dev->device);
                return;
        }
        pci_write_config_word(dev, AMD_8111_PCI_IRQ_ROUTING, 0);
@@ -1770,8 +1772,7 @@ static void quirk_plx_pci9050(struct pci_dev *dev)
                if (pci_resource_len(dev, bar) == 0x80 &&
                    (pci_resource_start(dev, bar) & 0x80)) {
                        struct resource *r = &dev->resource[bar];
-                       dev_info(&dev->dev,
-                                "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n",
+                       dev_info(&dev->dev, "Re-allocating PLX PCI 9050 BAR %u to length 256 to avoid bit 7 bug\n",
                                 bar);
                        r->flags |= IORESOURCE_UNSET;
                        r->start = 0;
@@ -1818,9 +1819,7 @@ static void quirk_netmos(struct pci_dev *dev)
        case PCI_DEVICE_ID_NETMOS_9845:
        case PCI_DEVICE_ID_NETMOS_9855:
                if (num_parallel) {
-                       dev_info(&dev->dev, "Netmos %04x (%u parallel, "
-                               "%u serial); changing class SERIAL to OTHER "
-                               "(use parport_serial)\n",
+                       dev_info(&dev->dev, "Netmos %04x (%u parallel, %u serial); changing class SERIAL to OTHER (use parport_serial)\n",
                                dev->device, num_parallel, num_serial);
                        dev->class = (PCI_CLASS_COMMUNICATION_OTHER << 8) |
                            (dev->class & 0xff);
@@ -1887,8 +1886,7 @@ static void quirk_e100_interrupt(struct pci_dev *dev)
 
        cmd_hi = readb(csr + 3);
        if (cmd_hi == 0) {
-               dev_warn(&dev->dev, "Firmware left e100 interrupts enabled; "
-                       "disabling\n");
+               dev_warn(&dev->dev, "Firmware left e100 interrupts enabled; disabling\n");
                writeb(1, csr + 3);
        }
 
@@ -1958,8 +1956,7 @@ static void quirk_nvidia_ck804_pcie_aer_ext_cap(struct pci_dev *dev)
        if (pci_read_config_byte(dev, 0xf41, &b) == 0) {
                if (!(b & 0x20)) {
                        pci_write_config_byte(dev, 0xf41, b | 0x20);
-                       dev_info(&dev->dev,
-                              "Linking AER extended capability\n");
+                       dev_info(&dev->dev, "Linking AER extended capability\n");
                }
        }
 }
@@ -1997,8 +1994,7 @@ static void quirk_via_cx700_pci_parking_caching(struct pci_dev *dev)
                        /* Turn off PCI Bus Parking */
                        pci_write_config_byte(dev, 0x76, b ^ 0x40);
 
-                       dev_info(&dev->dev,
-                               "Disabling VIA CX700 PCI parking\n");
+                       dev_info(&dev->dev, "Disabling VIA CX700 PCI parking\n");
                }
        }
 
@@ -2013,8 +2009,7 @@ static void quirk_via_cx700_pci_parking_caching(struct pci_dev *dev)
                        /* Disable "Read FIFO Timer" */
                        pci_write_config_byte(dev, 0x77, 0x0);
 
-                       dev_info(&dev->dev,
-                               "Disabling VIA CX700 PCI caching\n");
+                       dev_info(&dev->dev, "Disabling VIA CX700 PCI caching\n");
                }
        }
 }
@@ -2149,8 +2144,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8380_0, quirk_disab
 static void quirk_disable_msi(struct pci_dev *dev)
 {
        if (dev->subordinate) {
-               dev_warn(&dev->dev, "MSI quirk detected; "
-                       "subordinate MSI disabled\n");
+               dev_warn(&dev->dev, "MSI quirk detected; subordinate MSI disabled\n");
                dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI;
        }
 }
@@ -2189,8 +2183,7 @@ static int msi_ht_cap_enabled(struct pci_dev *dev)
                u8 flags;
 
                if (pci_read_config_byte(dev, pos + HT_MSI_FLAGS,
-                                        &flags) == 0)
-               {
+                                        &flags) == 0) {
                        dev_info(&dev->dev, "Found %s HT MSI Mapping\n",
                                flags & HT_MSI_FLAGS_ENABLE ?
                                "enabled" : "disabled");
@@ -2207,8 +2200,7 @@ static int msi_ht_cap_enabled(struct pci_dev *dev)
 static void quirk_msi_ht_cap(struct pci_dev *dev)
 {
        if (dev->subordinate && !msi_ht_cap_enabled(dev)) {
-               dev_warn(&dev->dev, "MSI quirk detected; "
-                       "subordinate MSI disabled\n");
+               dev_warn(&dev->dev, "MSI quirk detected; subordinate MSI disabled\n");
                dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI;
        }
 }
@@ -2232,8 +2224,7 @@ static void quirk_nvidia_ck804_msi_ht_cap(struct pci_dev *dev)
        if (!pdev)
                return;
        if (!msi_ht_cap_enabled(dev) && !msi_ht_cap_enabled(pdev)) {
-               dev_warn(&dev->dev, "MSI quirk detected; "
-                       "subordinate MSI disabled\n");
+               dev_warn(&dev->dev, "MSI quirk detected; subordinate MSI disabled\n");
                dev->subordinate->bus_flags |= PCI_BUS_FLAGS_NO_MSI;
        }
        pci_dev_put(pdev);
@@ -2279,8 +2270,7 @@ static void nvenet_msi_disable(struct pci_dev *dev)
        if (board_name &&
            (strstr(board_name, "P5N32-SLI PREMIUM") ||
             strstr(board_name, "P5N32-E SLI"))) {
-               dev_info(&dev->dev,
-                        "Disabling msi for MCP55 NIC on P5N32-SLI\n");
+               dev_info(&dev->dev, "Disabling msi for MCP55 NIC on P5N32-SLI\n");
                dev->no_msi = 1;
        }
 }
@@ -2489,8 +2479,7 @@ static void __nv_msi_ht_cap_quirk(struct pci_dev *dev, int all)
         */
        host_bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 0));
        if (host_bridge == NULL) {
-               dev_warn(&dev->dev,
-                        "nv_msi_ht_cap_quirk didn't locate host bridge\n");
+               dev_warn(&dev->dev, "nv_msi_ht_cap_quirk didn't locate host bridge\n");
                return;
        }
 
@@ -2817,8 +2806,7 @@ static void quirk_intel_mc_errata(struct pci_dev *dev)
         */
        err = pci_read_config_word(dev, 0x48, &rcc);
        if (err) {
-               dev_err(&dev->dev, "Error attempting to read the read "
-                       "completion coalescing register.\n");
+               dev_err(&dev->dev, "Error attempting to read the read completion coalescing register\n");
                return;
        }
 
@@ -2829,13 +2817,11 @@ static void quirk_intel_mc_errata(struct pci_dev *dev)
 
        err = pci_write_config_word(dev, 0x48, rcc);
        if (err) {
-               dev_err(&dev->dev, "Error attempting to write the read "
-                       "completion coalescing register.\n");
+               dev_err(&dev->dev, "Error attempting to write the read completion coalescing register\n");
                return;
        }
 
-       pr_info_once("Read completion coalescing disabled due to hardware "
-                    "errata relating to 256B MPS.\n");
+       pr_info_once("Read completion coalescing disabled due to hardware errata relating to 256B MPS\n");
 }
 /* Intel 5000 series memory controllers and ports 2-7 */
 DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x25c0, quirk_intel_mc_errata);
@@ -2944,8 +2930,7 @@ static void disable_igfx_irq(struct pci_dev *dev)
 
        /* Check if any interrupt line is still enabled */
        if (readl(regs + I915_DEIER_REG) != 0) {
-               dev_warn(&dev->dev, "BIOS left Intel GPU interrupts enabled; "
-                       "disabling\n");
+               dev_warn(&dev->dev, "BIOS left Intel GPU interrupts enabled; disabling\n");
 
                writel(0, regs + I915_DEIER_REG);
        }
@@ -2954,6 +2939,7 @@ static void disable_igfx_irq(struct pci_dev *dev)
 }
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0102, disable_igfx_irq);
 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x010a, disable_igfx_irq);
+DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, 0x0152, disable_igfx_irq);
 
 /*
  * PCI devices which are on Intel chips can skip the 10ms delay
@@ -2991,6 +2977,14 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CHELSIO, 0x0030,
                         quirk_broken_intx_masking);
 DECLARE_PCI_FIXUP_HEADER(0x1814, 0x0601, /* Ralink RT2800 802.11n PCI */
                         quirk_broken_intx_masking);
+/*
+ * Realtek RTL8169 PCI Gigabit Ethernet Controller (rev 10)
+ * Subsystem: Realtek RTL8169/8110 Family PCI Gigabit Ethernet NIC
+ *
+ * RTL8110SC - Fails under PCI device assignment using DisINTx masking.
+ */
+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_REALTEK, 0x8169,
+                        quirk_broken_intx_masking);
 
 static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f,
                          struct pci_fixup *end)
@@ -3031,7 +3025,7 @@ void pci_fixup_device(enum pci_fixup_pass pass, struct pci_dev *dev)
 {
        struct pci_fixup *start, *end;
 
-       switch(pass) {
+       switch (pass) {
        case pci_fixup_early:
                start = __start_pci_fixups_early;
                end = __end_pci_fixups_early;
@@ -3103,8 +3097,8 @@ static int __init pci_apply_final_quirks(void)
                        if (!tmp || cls == tmp)
                                continue;
 
-                       printk(KERN_DEBUG "PCI: CLS mismatch (%u != %u), "
-                              "using %u bytes\n", cls << 2, tmp << 2,
+                       printk(KERN_DEBUG "PCI: CLS mismatch (%u != %u), using %u bytes\n",
+                              cls << 2, tmp << 2,
                               pci_dfl_cache_line_size << 2);
                        pci_cache_line_size = pci_dfl_cache_line_size;
                }
@@ -3532,6 +3526,8 @@ static const u16 pci_quirk_intel_pch_acs_ids[] = {
        /* Wildcat PCH */
        0x9c90, 0x9c91, 0x9c92, 0x9c93, 0x9c94, 0x9c95, 0x9c96, 0x9c97,
        0x9c98, 0x9c99, 0x9c9a, 0x9c9b,
+       /* Patsburg (X79) PCH */
+       0x1d10, 0x1d12, 0x1d14, 0x1d16, 0x1d18, 0x1d1a, 0x1d1c, 0x1d1e,
 };
 
 static bool pci_quirk_intel_pch_acs_match(struct pci_dev *dev)
index c1839450d4d6cc4d77a5b37e983b7dbecdafe31b..f955edb9bea7e801b186d2b431359dd0bf7d6047 100644 (file)
@@ -38,6 +38,7 @@ int pci_enable_rom(struct pci_dev *pdev)
        pci_write_config_dword(pdev, pdev->rom_base_reg, rom_addr);
        return 0;
 }
+EXPORT_SYMBOL_GPL(pci_enable_rom);
 
 /**
  * pci_disable_rom - disable ROM decoding for a PCI device
@@ -53,6 +54,7 @@ void pci_disable_rom(struct pci_dev *pdev)
        rom_addr &= ~PCI_ROM_ADDRESS_ENABLE;
        pci_write_config_dword(pdev, pdev->rom_base_reg, rom_addr);
 }
+EXPORT_SYMBOL_GPL(pci_disable_rom);
 
 /**
  * pci_get_rom_size - obtain the actual size of the ROM image
@@ -135,7 +137,7 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
                } else {
                        /* assign the ROM an address if it doesn't have one */
                        if (res->parent == NULL &&
-                           pci_assign_resource(pdev,PCI_ROM_RESOURCE))
+                           pci_assign_resource(pdev, PCI_ROM_RESOURCE))
                                return NULL;
                        start = pci_resource_start(pdev, PCI_ROM_RESOURCE);
                        *size = pci_resource_len(pdev, PCI_ROM_RESOURCE);
@@ -166,6 +168,7 @@ void __iomem *pci_map_rom(struct pci_dev *pdev, size_t *size)
        *size = pci_get_rom_size(pdev, rom, *size);
        return rom;
 }
+EXPORT_SYMBOL(pci_map_rom);
 
 /**
  * pci_unmap_rom - unmap the ROM from kernel space
@@ -187,6 +190,7 @@ void pci_unmap_rom(struct pci_dev *pdev, void __iomem *rom)
        if (!(res->flags & (IORESOURCE_ROM_ENABLE | IORESOURCE_ROM_SHADOW)))
                pci_disable_rom(pdev);
 }
+EXPORT_SYMBOL(pci_unmap_rom);
 
 /**
  * pci_cleanup_rom - free the ROM copy created by pci_map_rom_copy
@@ -199,7 +203,7 @@ void pci_cleanup_rom(struct pci_dev *pdev)
        struct resource *res = &pdev->resource[PCI_ROM_RESOURCE];
 
        if (res->flags & IORESOURCE_ROM_COPY) {
-               kfree((void*)(unsigned long)res->start);
+               kfree((void *)(unsigned long)res->start);
                res->flags |= IORESOURCE_UNSET;
                res->flags &= ~IORESOURCE_ROM_COPY;
                res->start = 0;
@@ -222,9 +226,4 @@ void __iomem *pci_platform_rom(struct pci_dev *pdev, size_t *size)
 
        return NULL;
 }
-
-EXPORT_SYMBOL(pci_map_rom);
-EXPORT_SYMBOL(pci_unmap_rom);
-EXPORT_SYMBOL_GPL(pci_enable_rom);
-EXPORT_SYMBOL_GPL(pci_disable_rom);
 EXPORT_SYMBOL(pci_platform_rom);
index df38f73f091fef1293be85f4cbd8b23607ad1cdb..827ad831f1dd67335cf3918ed960f81579fc8405 100644 (file)
@@ -7,7 +7,6 @@
  *     Copyright (C) 2003 -- 2004 Greg Kroah-Hartman <greg@kroah.com>
  */
 
-#include <linux/init.h>
 #include <linux/pci.h>
 #include <linux/slab.h>
 #include <linux/module.h>
@@ -111,8 +110,7 @@ int pci_for_each_dma_alias(struct pci_dev *pdev,
  * legacy PCI bridge and the bridge is directly connected to bus 0), return its
  * parent
  */
-struct pci_dev *
-pci_find_upstream_pcie_bridge(struct pci_dev *pdev)
+struct pci_dev *pci_find_upstream_pcie_bridge(struct pci_dev *pdev)
 {
        struct pci_dev *tmp = NULL;
 
@@ -144,12 +142,12 @@ static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr)
        struct pci_bus *child;
        struct pci_bus *tmp;
 
-       if(bus->number == busnr)
+       if (bus->number == busnr)
                return bus;
 
        list_for_each_entry(tmp, &bus->children, node) {
                child = pci_do_find_bus(tmp, busnr);
-               if(child)
+               if (child)
                        return child;
        }
        return NULL;
@@ -164,7 +162,7 @@ static struct pci_bus *pci_do_find_bus(struct pci_bus *bus, unsigned char busnr)
  * in the global list of PCI buses.  If the bus is found, a pointer to its
  * data structure is returned.  If no bus is found, %NULL is returned.
  */
-struct pci_bus * pci_find_bus(int domain, int busnr)
+struct pci_bus *pci_find_bus(int domain, int busnr)
 {
        struct pci_bus *bus = NULL;
        struct pci_bus *tmp_bus;
@@ -178,6 +176,7 @@ struct pci_bus * pci_find_bus(int domain, int busnr)
        }
        return NULL;
 }
+EXPORT_SYMBOL(pci_find_bus);
 
 /**
  * pci_find_next_bus - begin or continue searching for a PCI bus
@@ -188,8 +187,7 @@ struct pci_bus * pci_find_bus(int domain, int busnr)
  * @from is not %NULL, searches continue from next device on the
  * global list.
  */
-struct pci_bus *
-pci_find_next_bus(const struct pci_bus *from)
+struct pci_bus *pci_find_next_bus(const struct pci_bus *from)
 {
        struct list_head *n;
        struct pci_bus *b = NULL;
@@ -202,6 +200,7 @@ pci_find_next_bus(const struct pci_bus *from)
        up_read(&pci_bus_sem);
        return b;
 }
+EXPORT_SYMBOL(pci_find_next_bus);
 
 /**
  * pci_get_slot - locate PCI device for a given PCI slot
@@ -235,6 +234,7 @@ struct pci_dev *pci_get_slot(struct pci_bus *bus, unsigned int devfn)
        up_read(&pci_bus_sem);
        return dev;
 }
+EXPORT_SYMBOL(pci_get_slot);
 
 /**
  * pci_get_domain_bus_and_slot - locate PCI device for a given PCI domain (segment), bus, and slot
@@ -339,6 +339,7 @@ struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
 
        return pci_get_dev_by_id(&id, from);
 }
+EXPORT_SYMBOL(pci_get_subsys);
 
 /**
  * pci_get_device - begin or continue searching for a PCI device by vendor/device id
@@ -354,11 +355,12 @@ struct pci_dev *pci_get_subsys(unsigned int vendor, unsigned int device,
  * from next device on the global list.  The reference count for @from is
  * always decremented if it is not %NULL.
  */
-struct pci_dev *
-pci_get_device(unsigned int vendor, unsigned int device, struct pci_dev *from)
+struct pci_dev *pci_get_device(unsigned int vendor, unsigned int device,
+                              struct pci_dev *from)
 {
        return pci_get_subsys(vendor, device, PCI_ANY_ID, PCI_ANY_ID, from);
 }
+EXPORT_SYMBOL(pci_get_device);
 
 /**
  * pci_get_class - begin or continue searching for a PCI device by class
@@ -387,6 +389,7 @@ struct pci_dev *pci_get_class(unsigned int class, struct pci_dev *from)
 
        return pci_get_dev_by_id(&id, from);
 }
+EXPORT_SYMBOL(pci_get_class);
 
 /**
  * pci_dev_present - Returns 1 if device matching the device list is present, 0 if not.
@@ -416,12 +419,3 @@ int pci_dev_present(const struct pci_device_id *ids)
        return 0;
 }
 EXPORT_SYMBOL(pci_dev_present);
-
-/* For boot time work */
-EXPORT_SYMBOL(pci_find_bus);
-EXPORT_SYMBOL(pci_find_next_bus);
-/* For everyone */
-EXPORT_SYMBOL(pci_get_device);
-EXPORT_SYMBOL(pci_get_subsys);
-EXPORT_SYMBOL(pci_get_slot);
-EXPORT_SYMBOL(pci_get_class);
index 138bdd6393be87b2ebc63ba35b1b4edaa228b8ad..a5a63ecfb6281837637cdc32846034ed2f226210 100644 (file)
@@ -68,7 +68,7 @@ static int add_to_list(struct list_head *head,
 
        tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
        if (!tmp) {
-               pr_warning("add_to_list: kmalloc() failed!\n");
+               pr_warn("add_to_list: kmalloc() failed!\n");
                return -ENOMEM;
        }
 
@@ -148,8 +148,7 @@ static void pdev_sort_resources(struct pci_dev *dev, struct list_head *head)
 
                tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
                if (!tmp)
-                       panic("pdev_sort_resources(): "
-                             "kmalloc() failed!\n");
+                       panic("pdev_sort_resources(): kmalloc() failed!\n");
                tmp->res = r;
                tmp->dev = dev;
 
@@ -713,12 +712,11 @@ static void pci_bridge_check_ranges(struct pci_bus *bus)
    bus resource of a given type. Note: we intentionally skip
    the bus resources which have already been assigned (that is,
    have non-NULL parent resource). */
-static struct resource *find_free_bus_resource(struct pci_bus *bus, unsigned long type)
+static struct resource *find_free_bus_resource(struct pci_bus *bus,
+                        unsigned long type_mask, unsigned long type)
 {
        int i;
        struct resource *r;
-       unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
-                                 IORESOURCE_PREFETCH;
 
        pci_bus_for_each_resource(bus, r, i) {
                if (r == &ioport_resource || r == &iomem_resource)
@@ -737,7 +735,7 @@ static resource_size_t calculate_iosize(resource_size_t size,
 {
        if (size < min_size)
                size = min_size;
-       if (old_size == 1 )
+       if (old_size == 1)
                old_size = 0;
        /* To be fixed in 2.5: we should have sort of HAVE_ISA
           flag in the struct pci_bus. */
@@ -758,7 +756,7 @@ static resource_size_t calculate_memsize(resource_size_t size,
 {
        if (size < min_size)
                size = min_size;
-       if (old_size == 1 )
+       if (old_size == 1)
                old_size = 0;
        if (size < old_size)
                size = old_size;
@@ -815,7 +813,8 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
                resource_size_t add_size, struct list_head *realloc_head)
 {
        struct pci_dev *dev;
-       struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO);
+       struct resource *b_res = find_free_bus_resource(bus, IORESOURCE_IO,
+                                                       IORESOURCE_IO);
        resource_size_t size = 0, size0 = 0, size1 = 0;
        resource_size_t children_add_size = 0;
        resource_size_t min_align, align;
@@ -859,9 +858,8 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
                        resource_size(b_res), min_align);
        if (!size0 && !size1) {
                if (b_res->start || b_res->end)
-                       dev_info(&bus->self->dev, "disabling bridge window "
-                                "%pR to %pR (unused)\n", b_res,
-                                &bus->busn_res);
+                       dev_info(&bus->self->dev, "disabling bridge window %pR to %pR (unused)\n",
+                                b_res, &bus->busn_res);
                b_res->flags = 0;
                return;
        }
@@ -872,10 +870,9 @@ static void pbus_size_io(struct pci_bus *bus, resource_size_t min_size,
        if (size1 > size0 && realloc_head) {
                add_to_list(realloc_head, bus->self, b_res, size1-size0,
                            min_align);
-               dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window "
-                                "%pR to %pR add_size %llx\n", b_res,
-                                &bus->busn_res,
-                                (unsigned long long)size1-size0);
+               dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window %pR to %pR add_size %llx\n",
+                          b_res, &bus->busn_res,
+                          (unsigned long long)size1-size0);
        }
 }
 
@@ -907,36 +904,40 @@ static inline resource_size_t calculate_mem_align(resource_size_t *aligns,
  * @bus : the bus
  * @mask: mask the resource flag, then compare it with type
  * @type: the type of free resource from bridge
+ * @type2: second match type
+ * @type3: third match type
  * @min_size : the minimum memory window that must to be allocated
  * @add_size : additional optional memory window
  * @realloc_head : track the additional memory window on this list
  *
  * Calculate the size of the bus and minimal alignment which
  * guarantees that all child resources fit in this size.
+ *
+ * Returns -ENOSPC if there's no available bus resource of the desired type.
+ * Otherwise, sets the bus resource start/end to indicate the required
+ * size, adds things to realloc_head (if supplied), and returns 0.
  */
 static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
-                        unsigned long type, resource_size_t min_size,
-                       resource_size_t add_size,
-                       struct list_head *realloc_head)
+                        unsigned long type, unsigned long type2,
+                        unsigned long type3,
+                        resource_size_t min_size, resource_size_t add_size,
+                        struct list_head *realloc_head)
 {
        struct pci_dev *dev;
        resource_size_t min_align, align, size, size0, size1;
-       resource_size_t aligns[12];     /* Alignments from 1Mb to 2Gb */
+       resource_size_t aligns[14];     /* Alignments from 1Mb to 8Gb */
        int order, max_order;
-       struct resource *b_res = find_free_bus_resource(bus, type);
-       unsigned int mem64_mask = 0;
+       struct resource *b_res = find_free_bus_resource(bus,
+                                       mask | IORESOURCE_PREFETCH, type);
        resource_size_t children_add_size = 0;
 
        if (!b_res)
-               return 0;
+               return -ENOSPC;
 
        memset(aligns, 0, sizeof(aligns));
        max_order = 0;
        size = 0;
 
-       mem64_mask = b_res->flags & IORESOURCE_MEM_64;
-       b_res->flags &= ~IORESOURCE_MEM_64;
-
        list_for_each_entry(dev, &bus->devices, bus_list) {
                int i;
 
@@ -944,7 +945,9 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
                        struct resource *r = &dev->resource[i];
                        resource_size_t r_size;
 
-                       if (r->parent || (r->flags & mask) != type)
+                       if (r->parent || ((r->flags & mask) != type &&
+                                         (r->flags & mask) != type2 &&
+                                         (r->flags & mask) != type3))
                                continue;
                        r_size = resource_size(r);
 #ifdef CONFIG_PCI_IOV
@@ -957,26 +960,29 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
                                continue;
                        }
 #endif
-                       /* For bridges size != alignment */
+                       /*
+                        * aligns[0] is for 1MB (since bridge memory
+                        * windows are always at least 1MB aligned), so
+                        * keep "order" from being negative for smaller
+                        * resources.
+                        */
                        align = pci_resource_alignment(dev, r);
                        order = __ffs(align) - 20;
-                       if (order > 11) {
-                               dev_warn(&dev->dev, "disabling BAR %d: %pR "
-                                        "(bad alignment %#llx)\n", i, r,
-                                        (unsigned long long) align);
+                       if (order < 0)
+                               order = 0;
+                       if (order >= ARRAY_SIZE(aligns)) {
+                               dev_warn(&dev->dev, "disabling BAR %d: %pR (bad alignment %#llx)\n",
+                                        i, r, (unsigned long long) align);
                                r->flags = 0;
                                continue;
                        }
                        size += r_size;
-                       if (order < 0)
-                               order = 0;
                        /* Exclude ranges with size > align from
                           calculation of the alignment. */
                        if (r_size == align)
                                aligns[order] += align;
                        if (order > max_order)
                                max_order = order;
-                       mem64_mask &= r->flags & IORESOURCE_MEM_64;
 
                        if (realloc_head)
                                children_add_size += get_res_add_size(realloc_head, r);
@@ -993,22 +999,21 @@ static int pbus_size_mem(struct pci_bus *bus, unsigned long mask,
                                resource_size(b_res), min_align);
        if (!size0 && !size1) {
                if (b_res->start || b_res->end)
-                       dev_info(&bus->self->dev, "disabling bridge window "
-                                "%pR to %pR (unused)\n", b_res,
-                                &bus->busn_res);
+                       dev_info(&bus->self->dev, "disabling bridge window %pR to %pR (unused)\n",
+                                b_res, &bus->busn_res);
                b_res->flags = 0;
-               return 1;
+               return 0;
        }
        b_res->start = min_align;
        b_res->end = size0 + min_align - 1;
-       b_res->flags |= IORESOURCE_STARTALIGN | mem64_mask;
+       b_res->flags |= IORESOURCE_STARTALIGN;
        if (size1 > size0 && realloc_head) {
                add_to_list(realloc_head, bus->self, b_res, size1-size0, min_align);
-               dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window "
-                                "%pR to %pR add_size %llx\n", b_res,
-                                &bus->busn_res, (unsigned long long)size1-size0);
+               dev_printk(KERN_DEBUG, &bus->self->dev, "bridge window %pR to %pR add_size %llx\n",
+                          b_res, &bus->busn_res,
+                          (unsigned long long)size1-size0);
        }
-       return 1;
+       return 0;
 }
 
 unsigned long pci_cardbus_resource_alignment(struct resource *res)
@@ -1113,12 +1118,13 @@ handle_done:
        ;
 }
 
-void __ref __pci_bus_size_bridges(struct pci_bus *bus,
-                       struct list_head *realloc_head)
+void __pci_bus_size_bridges(struct pci_bus *bus, struct list_head *realloc_head)
 {
        struct pci_dev *dev;
-       unsigned long mask, prefmask;
+       unsigned long mask, prefmask, type2 = 0, type3 = 0;
        resource_size_t additional_mem_size = 0, additional_io_size = 0;
+       struct resource *b_res;
+       int ret;
 
        list_for_each_entry(dev, &bus->devices, bus_list) {
                struct pci_bus *b = dev->subordinate;
@@ -1152,41 +1158,93 @@ void __ref __pci_bus_size_bridges(struct pci_bus *bus,
                        additional_io_size  = pci_hotplug_io_size;
                        additional_mem_size = pci_hotplug_mem_size;
                }
-               /*
-                * Follow thru
-                */
+               /* Fall through */
        default:
                pbus_size_io(bus, realloc_head ? 0 : additional_io_size,
                             additional_io_size, realloc_head);
-               /* If the bridge supports prefetchable range, size it
-                  separately. If it doesn't, or its prefetchable window
-                  has already been allocated by arch code, try
-                  non-prefetchable range for both types of PCI memory
-                  resources. */
+
+               /*
+                * If there's a 64-bit prefetchable MMIO window, compute
+                * the size required to put all 64-bit prefetchable
+                * resources in it.
+                */
+               b_res = &bus->self->resource[PCI_BRIDGE_RESOURCES];
                mask = IORESOURCE_MEM;
                prefmask = IORESOURCE_MEM | IORESOURCE_PREFETCH;
-               if (pbus_size_mem(bus, prefmask, prefmask,
+               if (b_res[2].flags & IORESOURCE_MEM_64) {
+                       prefmask |= IORESOURCE_MEM_64;
+                       ret = pbus_size_mem(bus, prefmask, prefmask,
+                                 prefmask, prefmask,
                                  realloc_head ? 0 : additional_mem_size,
-                                 additional_mem_size, realloc_head))
-                       mask = prefmask; /* Success, size non-prefetch only. */
-               else
-                       additional_mem_size += additional_mem_size;
-               pbus_size_mem(bus, mask, IORESOURCE_MEM,
+                                 additional_mem_size, realloc_head);
+
+                       /*
+                        * If successful, all non-prefetchable resources
+                        * and any 32-bit prefetchable resources will go in
+                        * the non-prefetchable window.
+                        */
+                       if (ret == 0) {
+                               mask = prefmask;
+                               type2 = prefmask & ~IORESOURCE_MEM_64;
+                               type3 = prefmask & ~IORESOURCE_PREFETCH;
+                       }
+               }
+
+               /*
+                * If there is no 64-bit prefetchable window, compute the
+                * size required to put all prefetchable resources in the
+                * 32-bit prefetchable window (if there is one).
+                */
+               if (!type2) {
+                       prefmask &= ~IORESOURCE_MEM_64;
+                       ret = pbus_size_mem(bus, prefmask, prefmask,
+                                        prefmask, prefmask,
+                                        realloc_head ? 0 : additional_mem_size,
+                                        additional_mem_size, realloc_head);
+
+                       /*
+                        * If successful, only non-prefetchable resources
+                        * will go in the non-prefetchable window.
+                        */
+                       if (ret == 0)
+                               mask = prefmask;
+                       else
+                               additional_mem_size += additional_mem_size;
+
+                       type2 = type3 = IORESOURCE_MEM;
+               }
+
+               /*
+                * Compute the size required to put everything else in the
+                * non-prefetchable window.  This includes:
+                *
+                *   - all non-prefetchable resources
+                *   - 32-bit prefetchable resources if there's a 64-bit
+                *     prefetchable window or no prefetchable window at all
+                *   - 64-bit prefetchable resources if there's no
+                *     prefetchable window at all
+                *
+                * Note that the strategy in __pci_assign_resource() must
+                * match that used here.  Specifically, we cannot put a
+                * 32-bit prefetchable resource in a 64-bit prefetchable
+                * window.
+                */
+               pbus_size_mem(bus, mask, IORESOURCE_MEM, type2, type3,
                                realloc_head ? 0 : additional_mem_size,
                                additional_mem_size, realloc_head);
                break;
        }
 }
 
-void __ref pci_bus_size_bridges(struct pci_bus *bus)
+void pci_bus_size_bridges(struct pci_bus *bus)
 {
        __pci_bus_size_bridges(bus, NULL);
 }
 EXPORT_SYMBOL(pci_bus_size_bridges);
 
-void __ref __pci_bus_assign_resources(const struct pci_bus *bus,
-                                     struct list_head *realloc_head,
-                                     struct list_head *fail_head)
+void __pci_bus_assign_resources(const struct pci_bus *bus,
+                               struct list_head *realloc_head,
+                               struct list_head *fail_head)
 {
        struct pci_bus *b;
        struct pci_dev *dev;
@@ -1211,22 +1269,22 @@ void __ref __pci_bus_assign_resources(const struct pci_bus *bus,
                        break;
 
                default:
-                       dev_info(&dev->dev, "not setting up bridge for bus "
-                                "%04x:%02x\n", pci_domain_nr(b), b->number);
+                       dev_info(&dev->dev, "not setting up bridge for bus %04x:%02x\n",
+                                pci_domain_nr(b), b->number);
                        break;
                }
        }
 }
 
-void __ref pci_bus_assign_resources(const struct pci_bus *bus)
+void pci_bus_assign_resources(const struct pci_bus *bus)
 {
        __pci_bus_assign_resources(bus, NULL, NULL);
 }
 EXPORT_SYMBOL(pci_bus_assign_resources);
 
-static void __ref __pci_bridge_assign_resources(const struct pci_dev *bridge,
-                                        struct list_head *add_head,
-                                        struct list_head *fail_head)
+static void __pci_bridge_assign_resources(const struct pci_dev *bridge,
+                                         struct list_head *add_head,
+                                         struct list_head *fail_head)
 {
        struct pci_bus *b;
 
@@ -1249,50 +1307,74 @@ static void __ref __pci_bridge_assign_resources(const struct pci_dev *bridge,
                break;
 
        default:
-               dev_info(&bridge->dev, "not setting up bridge for bus "
-                        "%04x:%02x\n", pci_domain_nr(b), b->number);
+               dev_info(&bridge->dev, "not setting up bridge for bus %04x:%02x\n",
+                        pci_domain_nr(b), b->number);
                break;
        }
 }
 static void pci_bridge_release_resources(struct pci_bus *bus,
                                          unsigned long type)
 {
-       int idx;
-       bool changed = false;
-       struct pci_dev *dev;
+       struct pci_dev *dev = bus->self;
        struct resource *r;
        unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
-                                 IORESOURCE_PREFETCH;
+                                 IORESOURCE_PREFETCH | IORESOURCE_MEM_64;
+       unsigned old_flags = 0;
+       struct resource *b_res;
+       int idx = 1;
 
-       dev = bus->self;
-       for (idx = PCI_BRIDGE_RESOURCES; idx <= PCI_BRIDGE_RESOURCE_END;
-            idx++) {
-               r = &dev->resource[idx];
-               if ((r->flags & type_mask) != type)
-                       continue;
-               if (!r->parent)
-                       continue;
-               /*
-                * if there are children under that, we should release them
-                *  all
-                */
-               release_child_resources(r);
-               if (!release_resource(r)) {
-                       dev_printk(KERN_DEBUG, &dev->dev,
-                                "resource %d %pR released\n", idx, r);
-                       /* keep the old size */
-                       r->end = resource_size(r) - 1;
-                       r->start = 0;
-                       r->flags = 0;
-                       changed = true;
-               }
-       }
+       b_res = &dev->resource[PCI_BRIDGE_RESOURCES];
+
+       /*
+        *     1. if there is io port assign fail, will release bridge
+        *        io port.
+        *     2. if there is non pref mmio assign fail, release bridge
+        *        nonpref mmio.
+        *     3. if there is 64bit pref mmio assign fail, and bridge pref
+        *        is 64bit, release bridge pref mmio.
+        *     4. if there is pref mmio assign fail, and bridge pref is
+        *        32bit mmio, release bridge pref mmio
+        *     5. if there is pref mmio assign fail, and bridge pref is not
+        *        assigned, release bridge nonpref mmio.
+        */
+       if (type & IORESOURCE_IO)
+               idx = 0;
+       else if (!(type & IORESOURCE_PREFETCH))
+               idx = 1;
+       else if ((type & IORESOURCE_MEM_64) &&
+                (b_res[2].flags & IORESOURCE_MEM_64))
+               idx = 2;
+       else if (!(b_res[2].flags & IORESOURCE_MEM_64) &&
+                (b_res[2].flags & IORESOURCE_PREFETCH))
+               idx = 2;
+       else
+               idx = 1;
+
+       r = &b_res[idx];
+
+       if (!r->parent)
+               return;
+
+       /*
+        * if there are children under that, we should release them
+        *  all
+        */
+       release_child_resources(r);
+       if (!release_resource(r)) {
+               type = old_flags = r->flags & type_mask;
+               dev_printk(KERN_DEBUG, &dev->dev, "resource %d %pR released\n",
+                                       PCI_BRIDGE_RESOURCES + idx, r);
+               /* keep the old size */
+               r->end = resource_size(r) - 1;
+               r->start = 0;
+               r->flags = 0;
 
-       if (changed) {
                /* avoiding touch the one without PREF */
                if (type & IORESOURCE_PREFETCH)
                        type = IORESOURCE_PREFETCH;
                __pci_setup_bridge(bus, type);
+               /* for next child res under same bridge */
+               r->flags = old_flags;
        }
 }
 
@@ -1304,9 +1386,9 @@ enum release_type {
  * try to release pci bridge resources that is from leaf bridge,
  * so we can allocate big new one later
  */
-static void __ref pci_bus_release_bridge_resources(struct pci_bus *bus,
-                                                  unsigned long type,
-                                                  enum release_type rel_type)
+static void pci_bus_release_bridge_resources(struct pci_bus *bus,
+                                            unsigned long type,
+                                            enum release_type rel_type)
 {
        struct pci_dev *dev;
        bool is_leaf_bridge = true;
@@ -1343,10 +1425,10 @@ static void pci_bus_dump_res(struct pci_bus *bus)
 
        pci_bus_for_each_resource(bus, res, i) {
                if (!res || !res->end || !res->flags)
-                        continue;
+                       continue;
 
                dev_printk(KERN_DEBUG, &bus->dev, "resource %d %pR\n", i, res);
-        }
+       }
 }
 
 static void pci_bus_dump_resources(struct pci_bus *bus)
@@ -1371,7 +1453,7 @@ static int pci_bus_get_depth(struct pci_bus *bus)
        int depth = 0;
        struct pci_bus *child_bus;
 
-       list_for_each_entry(child_bus, &bus->children, node){
+       list_for_each_entry(child_bus, &bus->children, node) {
                int ret;
 
                ret = pci_bus_get_depth(child_bus);
@@ -1471,7 +1553,7 @@ void pci_assign_unassigned_root_bus_resources(struct pci_bus *bus)
        LIST_HEAD(fail_head);
        struct pci_dev_resource *fail_res;
        unsigned long type_mask = IORESOURCE_IO | IORESOURCE_MEM |
-                                 IORESOURCE_PREFETCH;
+                                 IORESOURCE_PREFETCH | IORESOURCE_MEM_64;
        int pci_try_num = 1;
        enum enable_type enable_local;
 
@@ -1629,9 +1711,7 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus)
 
        down_read(&pci_bus_sem);
        list_for_each_entry(dev, &bus->devices, bus_list)
-               if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-                   dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
-                       if (dev->subordinate)
+               if (pci_is_bridge(dev) && pci_has_subordinate(dev))
                                __pci_bus_size_bridges(dev->subordinate,
                                                         &add_list);
        up_read(&pci_bus_sem);
index 9bd6864ec5d3fc3b6e18e2505f884a6dc8f94166..4e2d595d50ca19c8a63ff537f5e89b0bab6c32d6 100644 (file)
@@ -10,7 +10,6 @@
  */
 
 
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/errno.h>
@@ -23,10 +22,9 @@ void __weak pcibios_update_irq(struct pci_dev *dev, int irq)
        pci_write_config_byte(dev, PCI_INTERRUPT_LINE, irq);
 }
 
-static void
-pdev_fixup_irq(struct pci_dev *dev,
-              u8 (*swizzle)(struct pci_dev *, u8 *),
-              int (*map_irq)(const struct pci_dev *, u8, u8))
+static void pdev_fixup_irq(struct pci_dev *dev,
+                          u8 (*swizzle)(struct pci_dev *, u8 *),
+                          int (*map_irq)(const struct pci_dev *, u8, u8))
 {
        u8 pin, slot;
        int irq = 0;
@@ -59,11 +57,11 @@ pdev_fixup_irq(struct pci_dev *dev,
        pcibios_update_irq(dev, irq);
 }
 
-void
-pci_fixup_irqs(u8 (*swizzle)(struct pci_dev *, u8 *),
-              int (*map_irq)(const struct pci_dev *, u8, u8))
+void pci_fixup_irqs(u8 (*swizzle)(struct pci_dev *, u8 *),
+                   int (*map_irq)(const struct pci_dev *, u8, u8))
 {
        struct pci_dev *dev = NULL;
+
        for_each_pci_dev(dev)
                pdev_fixup_irq(dev, swizzle, map_irq);
 }
index 7eed671d55861c4ef890b33a68cfbaa2d7ef47e0..caed1ce6facd8b65f59edf76b0061a3813c13549 100644 (file)
@@ -16,7 +16,6 @@
  *          Resource sorting
  */
 
-#include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/export.h>
 #include <linux/pci.h>
@@ -97,8 +96,8 @@ void pci_update_resource(struct pci_dev *dev, int resno)
                pci_write_config_dword(dev, reg + 4, new);
                pci_read_config_dword(dev, reg + 4, &check);
                if (check != new) {
-                       dev_err(&dev->dev, "BAR %d: error updating "
-                              "(high %#08x != %#08x)\n", resno, new, check);
+                       dev_err(&dev->dev, "BAR %d: error updating (high %#08x != %#08x)\n",
+                               resno, new, check);
                }
        }
 
@@ -209,21 +208,42 @@ static int __pci_assign_resource(struct pci_bus *bus, struct pci_dev *dev,
 
        min = (res->flags & IORESOURCE_IO) ? PCIBIOS_MIN_IO : PCIBIOS_MIN_MEM;
 
-       /* First, try exact prefetching match.. */
+       /*
+        * First, try exact prefetching match.  Even if a 64-bit
+        * prefetchable bridge window is below 4GB, we can't put a 32-bit
+        * prefetchable resource in it because pbus_size_mem() assumes a
+        * 64-bit window will contain no 32-bit resources.  If we assign
+        * things differently than they were sized, not everything will fit.
+        */
        ret = pci_bus_alloc_resource(bus, res, size, align, min,
-                                    IORESOURCE_PREFETCH,
+                                    IORESOURCE_PREFETCH | IORESOURCE_MEM_64,
                                     pcibios_align_resource, dev);
+       if (ret == 0)
+               return 0;
 
-       if (ret < 0 && (res->flags & IORESOURCE_PREFETCH)) {
-               /*
-                * That failed.
-                *
-                * But a prefetching area can handle a non-prefetching
-                * window (it will just not perform as well).
-                */
-               ret = pci_bus_alloc_resource(bus, res, size, align, min, 0,
+       /*
+        * If the prefetchable window is only 32 bits wide, we can put
+        * 64-bit prefetchable resources in it.
+        */
+       if ((res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64)) ==
+            (IORESOURCE_PREFETCH | IORESOURCE_MEM_64)) {
+               ret = pci_bus_alloc_resource(bus, res, size, align, min,
+                                            IORESOURCE_PREFETCH,
                                             pcibios_align_resource, dev);
+               if (ret == 0)
+                       return 0;
        }
+
+       /*
+        * If we didn't find a better match, we can put any memory resource
+        * in a non-prefetchable window.  If this resource is 32 bits and
+        * non-prefetchable, the first call already tried the only possibility
+        * so we don't need to try again.
+        */
+       if (res->flags & (IORESOURCE_PREFETCH | IORESOURCE_MEM_64))
+               ret = pci_bus_alloc_resource(bus, res, size, align, min, 0,
+                                            pcibios_align_resource, dev);
+
        return ret;
 }
 
@@ -269,8 +289,8 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
        res->flags |= IORESOURCE_UNSET;
        align = pci_resource_alignment(dev, res);
        if (!align) {
-               dev_info(&dev->dev, "BAR %d: can't assign %pR "
-                        "(bogus alignment)\n", resno, res);
+               dev_info(&dev->dev, "BAR %d: can't assign %pR (bogus alignment)\n",
+                        resno, res);
                return -EINVAL;
        }
 
@@ -294,6 +314,7 @@ int pci_assign_resource(struct pci_dev *dev, int resno)
        }
        return ret;
 }
+EXPORT_SYMBOL(pci_assign_resource);
 
 int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsize,
                        resource_size_t min_align)
@@ -304,8 +325,8 @@ int pci_reassign_resource(struct pci_dev *dev, int resno, resource_size_t addsiz
 
        res->flags |= IORESOURCE_UNSET;
        if (!res->parent) {
-               dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR "
-                        "\n", resno, res);
+               dev_info(&dev->dev, "BAR %d: can't reassign an unassigned resource %pR\n",
+                        resno, res);
                return -EINVAL;
        }
 
index 24750a1b39b67cd9b84229204beb0945b4c09f8e..b91c4da6836574f78df3785ae9ef419b80e069be 100644 (file)
@@ -99,7 +99,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn,
        if (!dev)
                return -ENODEV;
 
-       switch(len) {
+       switch (len) {
        case 1:
                err = get_user(byte, (u8 __user *)buf);
                if (err)
index 8bde61952d20e4371b26cd80b31098cb392b67ea..4fe4cc4ae19a297a0d0553e48e613cd50bc6e891 100644 (file)
@@ -78,8 +78,7 @@ int __ref cb_alloc(struct pcmcia_socket *s)
        max = bus->busn_res.start;
        for (pass = 0; pass < 2; pass++)
                list_for_each_entry(dev, &bus->devices, bus_list)
-                       if (dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
-                           dev->hdr_type == PCI_HEADER_TYPE_CARDBUS)
+                       if (pci_is_bridge(dev))
                                max = pci_scan_bridge(bus, dev, max, pass);
 
        /*
index c5e082fb82fa1b3a56b8673f48778bdac8276cac..91ef69a52263e86d4bfbdad60ea4e26ea70185d5 100644 (file)
@@ -642,8 +642,7 @@ static void asus_rfkill_hotplug(struct asus_wmi *asus)
                        dev = pci_scan_single_device(bus, 0);
                        if (dev) {
                                pci_bus_assign_resources(bus);
-                               if (pci_bus_add_device(dev))
-                                       pr_err("Unable to hotplug wifi\n");
+                               pci_bus_add_device(dev);
                        }
                } else {
                        dev = pci_get_slot(bus, 0);
index 399e8c5621923890a43ea81f25fde5d0388f152e..9b0c57cd1d4a8a9d3c89e8a3aa2e3d1b9758f137 100644 (file)
@@ -633,8 +633,7 @@ static void eeepc_rfkill_hotplug(struct eeepc_laptop *eeepc, acpi_handle handle)
                        dev = pci_scan_single_device(bus, 0);
                        if (dev) {
                                pci_bus_assign_resources(bus);
-                               if (pci_bus_add_device(dev))
-                                       pr_err("Unable to hotplug wifi\n");
+                               pci_bus_add_device(dev);
                        }
                } else {
                        dev = pci_get_slot(bus, 0);
index 2be8a2dbc868f86f84e90c0e79a755c1f51e672b..0297e587579813d0977b75fe5613831a22f0246d 100644 (file)
@@ -16,16 +16,13 @@ int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma,
  * Standard interface
  */
 #define ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
-extern int
-dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
-                           dma_addr_t device_addr, size_t size, int flags);
+int dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
+                               dma_addr_t device_addr, size_t size, int flags);
 
-extern void
-dma_release_declared_memory(struct device *dev);
+void dma_release_declared_memory(struct device *dev);
 
-extern void *
-dma_mark_declared_memory_occupied(struct device *dev,
-                                 dma_addr_t device_addr, size_t size);
+void *dma_mark_declared_memory_occupied(struct device *dev,
+                                       dma_addr_t device_addr, size_t size);
 #else
 #define dma_alloc_from_coherent(dev, size, handle, ret) (0)
 #define dma_release_from_coherent(dev, order, vaddr) (0)
index fd4aee29ad10caa5bd8073a31c7827baa85d11ae..0c3eab1e39ac4314089befbd222a7682eb404c1e 100644 (file)
@@ -8,6 +8,12 @@
 #include <linux/dma-direction.h>
 #include <linux/scatterlist.h>
 
+/*
+ * A dma_addr_t can hold any valid DMA or bus address for the platform.
+ * It can be given to a device to use as a DMA source or target.  A CPU cannot
+ * reference a dma_addr_t directly because there may be translation between
+ * its physical address space and the bus address space.
+ */
 struct dma_map_ops {
        void* (*alloc)(struct device *dev, size_t size,
                                dma_addr_t *dma_handle, gfp_t gfp,
@@ -186,7 +192,7 @@ static inline int dma_get_cache_alignment(void)
 
 #ifndef ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
 static inline int
-dma_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
+dma_declare_coherent_memory(struct device *dev, phys_addr_t phys_addr,
                            dma_addr_t device_addr, size_t size, int flags)
 {
        return 0;
@@ -217,13 +223,14 @@ extern void *dmam_alloc_noncoherent(struct device *dev, size_t size,
 extern void dmam_free_noncoherent(struct device *dev, size_t size, void *vaddr,
                                  dma_addr_t dma_handle);
 #ifdef ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY
-extern int dmam_declare_coherent_memory(struct device *dev, dma_addr_t bus_addr,
+extern int dmam_declare_coherent_memory(struct device *dev,
+                                       phys_addr_t phys_addr,
                                        dma_addr_t device_addr, size_t size,
                                        int flags);
 extern void dmam_release_declared_memory(struct device *dev);
 #else /* ARCH_HAS_DMA_DECLARE_COHERENT_MEMORY */
 static inline int dmam_declare_coherent_memory(struct device *dev,
-                               dma_addr_t bus_addr, dma_addr_t device_addr,
+                               phys_addr_t phys_addr, dma_addr_t device_addr,
                                size_t size, gfp_t gfp)
 {
        return 0;
index 85ab35e974a95a7e2e5b1888429c5c7cb92f81f6..466bcd111d85d80916af2f7592dec3c3c539e441 100644 (file)
@@ -370,6 +370,7 @@ struct pci_dev {
 #endif
        phys_addr_t rom; /* Physical address of ROM if it's not from the BAR */
        size_t romlen; /* Length of ROM if it's not from the BAR */
+       char *driver_override; /* Driver name to force a match */
 };
 
 static inline struct pci_dev *pci_physfn(struct pci_dev *dev)
@@ -482,6 +483,19 @@ static inline bool pci_is_root_bus(struct pci_bus *pbus)
        return !(pbus->parent);
 }
 
+/**
+ * pci_is_bridge - check if the PCI device is a bridge
+ * @dev: PCI device
+ *
+ * Return true if the PCI device is bridge whether it has subordinate
+ * or not.
+ */
+static inline bool pci_is_bridge(struct pci_dev *dev)
+{
+       return dev->hdr_type == PCI_HEADER_TYPE_BRIDGE ||
+               dev->hdr_type == PCI_HEADER_TYPE_CARDBUS;
+}
+
 static inline struct pci_dev *pci_upstream_bridge(struct pci_dev *dev)
 {
        dev = pci_physfn(dev);
@@ -523,7 +537,7 @@ static inline int pcibios_err_to_errno(int err)
        case PCIBIOS_FUNC_NOT_SUPPORTED:
                return -ENOENT;
        case PCIBIOS_BAD_VENDOR_ID:
-               return -EINVAL;
+               return -ENOTTY;
        case PCIBIOS_DEVICE_NOT_FOUND:
                return -ENODEV;
        case PCIBIOS_BAD_REGISTER_NUMBER:
@@ -534,7 +548,7 @@ static inline int pcibios_err_to_errno(int err)
                return -ENOSPC;
        }
 
-       return -ENOTTY;
+       return -ERANGE;
 }
 
 /* Low-level architecture-dependent routines */
@@ -608,6 +622,9 @@ struct pci_error_handlers {
        /* PCI slot has been reset */
        pci_ers_result_t (*slot_reset)(struct pci_dev *dev);
 
+       /* PCI function reset prepare or completed */
+       void (*reset_notify)(struct pci_dev *dev, bool prepare);
+
        /* Device driver may resume normal operations */
        void (*resume)(struct pci_dev *dev);
 };
@@ -685,8 +702,8 @@ struct pci_driver {
 
 /**
  * PCI_VDEVICE - macro used to describe a specific pci device in short form
- * @vendor: the vendor name
- * @device: the 16 bit PCI Device ID
+ * @vend: the vendor name
+ * @dev: the 16 bit PCI Device ID
  *
  * This macro is used to create a struct pci_device_id that matches a
  * specific PCI device.  The subvendor, and subdevice fields will be set
@@ -694,9 +711,9 @@ struct pci_driver {
  * private data.
  */
 
-#define PCI_VDEVICE(vendor, device)            \
-       PCI_VENDOR_ID_##vendor, (device),       \
-       PCI_ANY_ID, PCI_ANY_ID, 0, 0
+#define PCI_VDEVICE(vend, dev) \
+       .vendor = PCI_VENDOR_ID_##vend, .device = (dev), \
+       .subvendor = PCI_ANY_ID, .subdevice = PCI_ANY_ID, 0, 0
 
 /* these external functions are only available when PCI support is enabled */
 #ifdef CONFIG_PCI
@@ -769,7 +786,7 @@ int pci_scan_slot(struct pci_bus *bus, int devfn);
 struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn);
 void pci_device_add(struct pci_dev *dev, struct pci_bus *bus);
 unsigned int pci_scan_child_bus(struct pci_bus *bus);
-int __must_check pci_bus_add_device(struct pci_dev *dev);
+void pci_bus_add_device(struct pci_dev *dev);
 void pci_read_bridge_bases(struct pci_bus *child);
 struct resource *pci_find_parent_resource(const struct pci_dev *dev,
                                          struct resource *res);
@@ -1163,7 +1180,6 @@ struct msix_entry {
 
 #ifdef CONFIG_PCI_MSI
 int pci_msi_vec_count(struct pci_dev *dev);
-int pci_enable_msi_block(struct pci_dev *dev, int nvec);
 void pci_msi_shutdown(struct pci_dev *dev);
 void pci_disable_msi(struct pci_dev *dev);
 int pci_msix_vec_count(struct pci_dev *dev);
@@ -1193,8 +1209,6 @@ static inline int pci_enable_msix_exact(struct pci_dev *dev,
 }
 #else
 static inline int pci_msi_vec_count(struct pci_dev *dev) { return -ENOSYS; }
-static inline int pci_enable_msi_block(struct pci_dev *dev, int nvec)
-{ return -ENOSYS; }
 static inline void pci_msi_shutdown(struct pci_dev *dev) { }
 static inline void pci_disable_msi(struct pci_dev *dev) { }
 static inline int pci_msix_vec_count(struct pci_dev *dev) { return -ENOSYS; }
@@ -1249,7 +1263,7 @@ static inline void pcie_set_ecrc_checking(struct pci_dev *dev) { }
 static inline void pcie_ecrc_get_policy(char *str) { }
 #endif
 
-#define pci_enable_msi(pdev)   pci_enable_msi_block(pdev, 1)
+#define pci_enable_msi(pdev)   pci_enable_msi_exact(pdev, 1)
 
 #ifdef CONFIG_HT_IRQ
 /* The functions a driver should call */
@@ -1577,13 +1591,13 @@ extern unsigned long pci_hotplug_io_size;
 extern unsigned long pci_hotplug_mem_size;
 
 /* Architecture-specific versions may override these (weak) */
-int pcibios_add_platform_entries(struct pci_dev *dev);
 void pcibios_disable_device(struct pci_dev *dev);
 void pcibios_set_master(struct pci_dev *dev);
 int pcibios_set_pcie_reset_state(struct pci_dev *dev,
                                 enum pcie_reset_state state);
 int pcibios_add_device(struct pci_dev *dev);
 void pcibios_release_device(struct pci_dev *dev);
+void pcibios_penalize_isa_irq(int irq, int active);
 
 #ifdef CONFIG_HIBERNATE_CALLBACKS
 extern struct dev_pm_ops pcibios_pm_ops;
index d4de24b4d4c64a184ff4270e2c0755f4ff59b4d6..7fa31731c8548e82f354df86571ee1189cec5f95 100644 (file)
 #define PCI_DEVICE_ID_ATT_VENUS_MODEM  0x480
 
 #define PCI_VENDOR_ID_SPECIALIX                0x11cb
-#define PCI_DEVICE_ID_SPECIALIX_IO8    0x2000
-#define PCI_DEVICE_ID_SPECIALIX_RIO    0x8000
 #define PCI_SUBDEVICE_ID_SPECIALIX_SPEED4 0xa004
 
 #define PCI_VENDOR_ID_ANALOG_DEVICES   0x11d4
 #define PCI_DEVICE_ID_SCALEMP_VSMP_CTL 0x1010
 
 #define PCI_VENDOR_ID_COMPUTONE                0x8e0e
-#define PCI_DEVICE_ID_COMPUTONE_IP2EX  0x0291
 #define PCI_DEVICE_ID_COMPUTONE_PG     0x0302
 #define PCI_SUBVENDOR_ID_COMPUTONE     0x8e0e
 #define PCI_SUBDEVICE_ID_COMPUTONE_PG4 0x0001
index 4d118ba113497b11a31a9855ab223da663464380..a0bb7048687f565ea959ae21fde70d2cec8282ce 100644 (file)
@@ -142,6 +142,7 @@ typedef unsigned long blkcnt_t;
 #define pgoff_t unsigned long
 #endif
 
+/* A dma_addr_t can hold any valid DMA or bus address for the platform */
 #ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT
 typedef u64 dma_addr_t;
 #else
index 8957d686e29ba94c49f2a67f9fab5ddcdfd3a050..3c2237ac32dbedf56d10444a7feef59e6b35a561 100644 (file)
@@ -1288,13 +1288,10 @@ int iomem_map_sanity_check(resource_size_t addr, unsigned long size)
                if (p->flags & IORESOURCE_BUSY)
                        continue;
 
-               printk(KERN_WARNING "resource map sanity check conflict: "
-                      "0x%llx 0x%llx 0x%llx 0x%llx %s\n",
+               printk(KERN_WARNING "resource sanity check: requesting [mem %#010llx-%#010llx], which spans more than %s %pR\n",
                       (unsigned long long)addr,
                       (unsigned long long)(addr + size - 1),
-                      (unsigned long long)p->start,
-                      (unsigned long long)p->end,
-                      p->name);
+                      p->name, p);
                err = -1;
                break;
        }