1. 19 Mar, 2014 13 commits
    • Bjorn Helgaas's avatar
      PCI: Log IDE resource quirk in dmesg · 075eb9e3
      Bjorn Helgaas authored
      Make a note in dmesg when we overwrite legacy IDE BAR info.  We previously
      logged something like this:
      
        pci 0000:00:1f.1: reg 0x10: [io  0x0000-0x0007]
      
      and then silently overwrote the resource.  There's an example in the
      bugzilla below.  This doesn't fix the bugzilla; it just makes what's going
      on more obvious.
      
      No functional change; merely adds some dev_info() calls.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=48451Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      075eb9e3
    • Bjorn Helgaas's avatar
      PCI: Change pci_bus_alloc_resource() type_mask to unsigned long · 664c2848
      Bjorn Helgaas authored
      The pci_bus_alloc_resource() "type_mask" parameter is used to compare with
      the "flags" member of a struct resource, so it should be the same type,
      namely "unsigned long".
      
      No functional change because all current IORESOURCE_* flags fit in 32 bits.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      664c2848
    • Bjorn Helgaas's avatar
      PCI: Check all IORESOURCE_TYPE_BITS in pci_bus_alloc_from_region() · aa11fc58
      Bjorn Helgaas authored
      When allocating space from a bus resource, i.e., from apertures leading to
      this bus, make sure the entire resource type matches.  The previous code
      assumed the IORESOURCE_TYPE_BITS field was a bitmask with only a single bit
      set, but this is not true.  IORESOURCE_TYPE_BITS is really an enumeration,
      and we have to check all the bits.
      
      See 72dcb119 ("resources: Add register address resource type").
      
      No functional change.  If we used this path for allocating IRQs, DMA
      channels, or bus numbers, this would fix a bug because those types are
      indistinguishable when masked by IORESOURCE_IO | IORESOURCE_MEM.  But we
      don't, so this shouldn't make any difference.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      aa11fc58
    • Bjorn Helgaas's avatar
      resources: Set type in __request_region() · 6404e88e
      Bjorn Helgaas authored
      We don't set the type (I/O, memory, etc.) of resources added by
      __request_region(), which leads to confusing messages like this:
      
          address space collision: [io  0x1000-0x107f] conflicts with ACPI CPU throttle [??? 0x00001010-0x00001015 flags 0x80000000]
      
      Set the type of a new resource added by __request_region() (used by
      request_region() and request_mem_region()) to the type of its parent.  This
      makes the resource tree internally consistent and fixes messages like the
      above, where the ACPI CPU throttle resource really is an I/O port region,
      but request_region() didn't fill in the type, so %pR didn't know how to
      print it.
      
      Sample dmesg showing the issue at the link below.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=71611Reported-by: default avatarPaul Bolle <pebolle@tiscali.nl>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      6404e88e
    • Bjorn Helgaas's avatar
      PCI: Don't check resource_size() in pci_bus_alloc_resource() · e20fa660
      Bjorn Helgaas authored
      Paul reported that after f75b99d5 ("PCI: Enforce bus address limits in
      resource allocation") on a 32-bit kernel (CONFIG_PHYS_ADDR_T_64BIT not
      set), intel-gtt complained "can't ioremap flush page - no chipset
      flushing".  In addition, other PCI resource allocations, e.g., for bridge
      windows, failed.
      
      This happens because we incorrectly skip bus resources of
      [mem 0x00000000-0xffffffff] because we think they are of size zero.
      When resource_size_t is 32 bits wide, resource_size() on
      [mem 0x00000000-0xffffffff] returns 0 because (r->end - r->start + 1)
      overflows.
      
      Therefore, we can't use "resource_size() == 0" to decide that allocation
      from this resource will fail.  allocate_resource() should fail anyway if it
      can't satisfy the address constraints, so we should just depend on that.
      
      A [mem 0x00000000-0xffffffff] bus resource is obviously not really valid,
      but we do fall back to it as a default when we don't have information about
      host bridge apertures.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=71611
      Fixes: f75b99d5 PCI: Enforce bus address limits in resource allocation
      Reported-and-tested-by: default avatarPaul Bolle <pebolle@tiscali.nl>
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      e20fa660
    • Bjorn Helgaas's avatar
      s390/PCI: Use generic pci_enable_resources() · d7533232
      Bjorn Helgaas authored
      The generic pci_enable_resources() does essentially the same thing as the
      code in the s390 version of pcibios_enable_device().
      
      There are differences, but I don't think any of them are a problem.  The
      generic code:
      
        - Checks everything up to PCI_NUM_RESOURCES, not PCI_BAR_COUNT (6), so
          we'll now check the ROM resource, IOV resources, and bridge windows.
      
        - Checks for res->flags & IORESOURCE_UNSET.  The s390 code never sets
          IORESOURCE_UNSET, so this isn't a problem.
      
        - Checks res->parent.  The s390 pcibios_add_device() calls
          pci_claim_resource() on all BARs (except ROM, IOV, and bridge windows)
          so this isn't a problem either.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Acked-by: default avatarSebastian Ott <sebott@linux.vnet.ibm.com>
      d7533232
    • Bjorn Helgaas's avatar
      tile PCI RC: Use default pcibios_enable_device() · 05d58f60
      Bjorn Helgaas authored
      We don't need anything arch-specific in pcibios_enable_device(), so drop
      the arch implementation and use the default generic one.
      
      Note: pci_enable_resources() checks that r->parent is non-NULL, which
      basically checks that pci_claim_resource() or request_resource() has been
      called for each BAR.  I don't see where that happens for tile, but this
      patch doesn't change that behavior, so if it worked before, it should still
      work.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      Acked-by: default avatarChris Metcalf <cmetcalf@tilera.com>
      05d58f60
    • Bjorn Helgaas's avatar
      sparc/PCI: Use default pcibios_enable_device() (Leon only) · f6baf35f
      Bjorn Helgaas authored
      We don't need anything arch-specific in pcibios_enable_device() so drop
      the arch implementation and use the default generic one.
      
      Note that sparc has two pcibios_enable_device() implementations other than
      the one removed here.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      CC: Daniel Hellstrom <daniel@gaisler.com
      f6baf35f
    • Bjorn Helgaas's avatar
      sh/PCI: Use default pcibios_enable_device() · 3a6fc2fb
      Bjorn Helgaas authored
      We don't need anything arch-specific in pcibios_enable_device(), so drop
      the arch implementation and use the default generic one.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      CC: Paul Mundt <lethal@linux-sh.org>
      CC: linux-sh@vger.kernel.org
      3a6fc2fb
    • Bjorn Helgaas's avatar
      microblaze/PCI: Use default pcibios_enable_device() · cd3183ba
      Bjorn Helgaas authored
      We don't need anything arch-specific in pcibios_enable_device(), so drop
      the arch implementation and use the default generic one.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      CC: Michal Simek <monstr@monstr.eu>
      CC: microblaze-uclinux@itee.uq.edu.au
      cd3183ba
    • Bjorn Helgaas's avatar
      alpha/PCI: Use default pcibios_enable_device() · 3eb03bdb
      Bjorn Helgaas authored
      We don't need anything arch-specific in pcibios_enable_device(), so drop
      the arch implementation and use the default generic one.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      CC: linux-alpha@vger.kernel.org
      3eb03bdb
    • Bjorn Helgaas's avatar
      PCI: Add "weak" generic pcibios_enable_device() implementation · 8a9d5609
      Bjorn Helgaas authored
      Many architectures implement pcibios_enable_device() the same way, so
      provide a default implementation in the core.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      8a9d5609
    • Bjorn Helgaas's avatar
      PCI: Don't enable decoding if BAR hasn't been assigned an address · 3cedcc36
      Bjorn Helgaas authored
      Don't enable memory or I/O decoding if we haven't assigned or claimed the
      BAR's resource.
      
      If we enable decoding for a BAR that hasn't been assigned an address, we'll
      likely cause bus conflicts.  This declines to enable decoding for resources
      with IORESOURCE_UNSET.
      
      Note that drivers can use pci_enable_device_io() or pci_enable_device_mem()
      if they only care about specific types of BARs.  In that case, we don't
      bother checking whether the corresponding resources are assigned or
      claimed.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      3cedcc36
  2. 27 Feb, 2014 6 commits
    • Bjorn Helgaas's avatar
      PCI: Mark 64-bit resource as IORESOURCE_UNSET if we only support 32-bit · c83bd900
      Bjorn Helgaas authored
      If we don't support 64-bit addresses, i.e., CONFIG_PHYS_ADDR_T_64BIT is not
      set, we can't deal with BARs above 4GB.  In this case we already pretend
      the BAR contained zero; this patch also sets IORESOURCE_UNSET so we can try
      to reallocate it later.
      
      I don't think this is exactly correct: what we care about here are *bus*
      addresses, not CPU addresses, so the tests of sizeof(resource_size_t)
      probably should be on sizeof(dma_addr_t) instead.  But this is what's been
      in -next, so we'll fix that later.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      c83bd900
    • Bjorn Helgaas's avatar
      PCI: Don't try to claim IORESOURCE_UNSET resources · 29003beb
      Bjorn Helgaas authored
      If the IORESOURCE_UNSET bit is set, it means we haven't assigned an address
      yet, so don't try to claim the region.
      
      Also, make the error messages more uniform and add info about which BAR is
      involved.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      29003beb
    • Bjorn Helgaas's avatar
      PCI: Check IORESOURCE_UNSET before updating BAR · cd8a4d36
      Bjorn Helgaas authored
      Check to make sure we don't update a BAR with an address we haven't
      assigned.
      
      If we haven't assigned an address to a resource, we shouldn't write it to a
      BAR.  This isn't a problem for the usual path via pci_assign_resource(),
      which clears IORESOURCE_UNSET before calling pci_update_resource(), but
      paths like pci_restore_bars() can call this for resources we haven't
      assigned.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      cd8a4d36
    • Bjorn Helgaas's avatar
      PCI: Don't clear IORESOURCE_UNSET when updating BAR · 434aafc1
      Bjorn Helgaas authored
      Clear IORESOURCE_UNSET when we assign an address to a resource, not when we
      write the address to the BAR.
      
      Also, drop the "BAR %d: set to %pR" message; this is mostly redundant with
      the "BAR %d: assigned %pR" message from pci_assign_resource().
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      434aafc1
    • Bjorn Helgaas's avatar
      PCI: Mark resources as IORESOURCE_UNSET if we can't assign them · bd064f0a
      Bjorn Helgaas authored
      When assigning addresses to resources, mark them with IORESOURCE_UNSET
      before we start and clear IORESOURCE_UNSET if assignment is successful.
      That means that if we print the resource during assignment, we will show
      the size, not a meaningless address.
      
      Also, clear IORESOURCE_UNSET if we do assign an address, so we print the
      address when it is valid.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      bd064f0a
    • Bjorn Helgaas's avatar
      PCI: Remove pci_find_parent_resource() use for allocation · f44116ae
      Bjorn Helgaas authored
      If the resource hasn't been allocated yet, pci_find_parent_resource() is
      documented as returning the region "where it should be allocated from."
      This is impossible in general because there may be several candidates: a
      prefetchable BAR can be put in either a prefetchable or non-prefetchable
      window, a transparent bridge may have overlapping positively- and
      subtractively-decoded windows, and a root bus may have several windows of
      the same type.
      
      Allocation should be done by pci_bus_alloc_resource(), which iterates
      through all bus resources and looks for the best match, e.g., one with the
      desired prefetchability attributes, and falls back to less-desired
      possibilities.
      
      The only valid use of pci_find_parent_resource() is to find the parent of
      an already-allocated resource so we can claim it via request_resource(),
      and all we need for that is a bus region of the correct type that contains
      the resource.
      
      Note that like 8c8def26 ("PCI: allow matching of prefetchable resources
      to non-prefetchable windows"), this depends on pci_bus_for_each_resource()
      iterating through positively-decoded regions before subtractively-decoded
      ones.  We prefer not to return a subtractively-decoded region because
      requesting from it will likely conflict with the overlapping positively-
      decoded window (see Launchpad report below).
      
      Link: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/424142Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      CC: Linus Torvalds <torvalds@linux-foundation.org>
      f44116ae
  3. 26 Feb, 2014 6 commits
    • Bjorn Helgaas's avatar
      vsprintf: Add support for IORESOURCE_UNSET in %pR · d19cb803
      Bjorn Helgaas authored
      Sometimes we have a struct resource where we know the type (MEM/IO/etc.)
      and the size, but we haven't assigned address space for it.  The
      IORESOURCE_UNSET flag is a way to indicate this situation.  For these
      "unset" resources, the start address is meaningless, so print only the
      size, e.g.,
      
        - pci 0000:0c:00.0: reg 184: [mem 0x00000000-0x00001fff 64bit]
        + pci 0000:0c:00.0: reg 184: [mem size 0x2000 64bit]
      
      For %pr (printing with raw flags), we still print the address range,
      because %pr is mostly used for debugging anyway.
      
      Thanks to Fengguang Wu <fengguang.wu@intel.com> for suggesting
      resource_size().
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      d19cb803
    • Bjorn Helgaas's avatar
      resource: Add resource_contains() · 5edb93b8
      Bjorn Helgaas authored
      We have two identical copies of resource_contains() already, and more
      places that could use it.  This moves it to ioport.h where it can be
      shared.
      
      resource_contains(struct resource *r1, struct resource *r2) returns true
      iff r1 and r2 are the same type (most callers already checked this
      separately) and the r1 address range completely contains r2.
      
      In addition, the new resource_contains() checks that both r1 and r2 have
      addresses assigned to them.  If a resource is IORESOURCE_UNSET, it doesn't
      have a valid address and can't contain or be contained by another resource.
      Some callers already check this or for res->start.
      
      No functional change.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      5edb93b8
    • Bjorn Helgaas's avatar
      i2o: Use pci_bus_alloc_resource(), not allocate_resource() directly · d2e074cc
      Bjorn Helgaas authored
      Convert i2o_res_alloc() to use pci_bus_alloc_resource() rather than
      pci_find_parent_resource() and allocate_resource().  We don't have a
      resource to start with, so pci_find_parent_resource() can't do anything
      useful: a bus may have several memory resources available, so there might
      be several possible parents.  This is more likely on root buses because
      host bridges may have any number of apertures.
      
      I'm pretty sure this didn't work in the first place because it passed
      size == min == max to allocate_resource().  The min and max parameters are
      constraints on the *addresses* of the resource, not on its size, so I think
      it was impossible for allocate_resource() to succeed.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      d2e074cc
    • Bjorn Helgaas's avatar
      i2o: Refactor i2o_iop_systab_set() PCI space allocation · 60f061e1
      Bjorn Helgaas authored
      Refactor the PCI space allocation in i2o_iop_systab_set().  This might
      improve readability slightly, but mainly it is to make the next patch
      simpler.
      
      No functional change.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      60f061e1
    • Bjorn Helgaas's avatar
      i2o: Fix I/O space alignment requirement · 5c513bd5
      Bjorn Helgaas authored
      When i2o_iop_systab_set() allocates I/O port space, it specifies 1Mb
      alignment required.  This seems unlikely, since most platforms have only
      64Kb of I/O space total.  I think 4Kb is a more reasonable choice, since
      that's the minimum alignment of a PCI-PCI bridge I/O window.
      
      My guess is that this is a copy/paste error from the memory allocation
      code, which specifies 1Mb alignment (which is the minimum alignment of a
      PCI-PCI bridge memory window).
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      5c513bd5
    • Bjorn Helgaas's avatar
      i2o: Fix I/O space allocation copy/paste error · 7ed37fc3
      Bjorn Helgaas authored
      When i2o_iop_systab_set() allocates I/O port space, it assigns the base of
      the new I/O port region to sb->current_mem_base, not sb->current_io_base.
      This looks like a copy/paste error, because we do use current_io_base, but
      there's no other place that sets it.
      Signed-off-by: default avatarBjorn Helgaas <bhelgaas@google.com>
      7ed37fc3
  4. 03 Feb, 2014 4 commits
    • Linus Torvalds's avatar
      Linus 3.14-rc1 · 38dbfb59
      Linus Torvalds authored
      38dbfb59
    • Linus Torvalds's avatar
      Merge branch 'parisc-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux · 69048e01
      Linus Torvalds authored
      Pull parisc updates from Helge Deller:
       "The three major changes in this patchset is a implementation for
        flexible userspace memory maps, cache-flushing fixes (again), and a
        long-discussed ABI change to make EWOULDBLOCK the same value as
        EAGAIN.
      
        parisc has been the only platform where we had EWOULDBLOCK != EAGAIN
        to keep HP-UX compatibility.  Since we will probably never implement
        full HP-UX support, we prefer to drop this compatibility to make it
        easier for us with Linux userspace programs which mostly never checked
        for both values.  We don't expect major fall-outs because of this
        change, and if we face some, we will simply rebuild the necessary
        applications in the debian archives"
      
      * 'parisc-3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/parisc-linux:
        parisc: add flexible mmap memory layout support
        parisc: Make EWOULDBLOCK be equal to EAGAIN on parisc
        parisc: convert uapi/asm/stat.h to use native types only
        parisc: wire up sched_setattr and sched_getattr
        parisc: fix cache-flushing
        parisc/sti_console: prefer Linux fonts over built-in ROM fonts
      69048e01
    • Mikulas Patocka's avatar
      hpfs: optimize quad buffer loading · 1c0b8a7a
      Mikulas Patocka authored
      HPFS needs to load 4 consecutive 512-byte sectors when accessing the
      directory nodes or bitmaps.  We can't switch to 2048-byte block size
      because files are allocated in the units of 512-byte sectors.
      
      Previously, the driver would allocate a 2048-byte area using kmalloc,
      copy the data from four buffers to this area and eventually copy them
      back if they were modified.
      
      In the current implementation of the buffer cache, buffers are allocated
      in the pagecache.  That means that 4 consecutive 512-byte buffers are
      stored in consecutive areas in the kernel address space.  So, we don't
      need to allocate extra memory and copy the content of the buffers there.
      
      This patch optimizes the code to avoid copying the buffers.  It checks
      if the four buffers are stored in contiguous memory - if they are not,
      it falls back to allocating a 2048-byte area and copying data there.
      Signed-off-by: default avatarMikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      1c0b8a7a
    • Mikulas Patocka's avatar
      hpfs: remember free space · 2cbe5c76
      Mikulas Patocka authored
      Previously, hpfs scanned all bitmaps each time the user asked for free
      space using statfs.  This patch changes it so that hpfs scans the
      bitmaps only once, remembes the free space and on next invocation of
      statfs it returns the value instantly.
      
      New versions of wine are hammering on the statfs syscall very heavily,
      making some games unplayable when they're stored on hpfs, with load
      times in minutes.
      
      This should be backported to the stable kernels because it fixes
      user-visible problem (excessive level load times in wine).
      Signed-off-by: default avatarMikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2cbe5c76
  5. 02 Feb, 2014 11 commits