1. 19 10月, 2017 1 次提交
    • R
      drivers: flag buses which demand DMA configuration · d89e2378
      Robin Murphy 提交于
      We do not want the common dma_configure() pathway to apply
      indiscriminately to all devices, since there are plenty of buses which
      do not have DMA capability, and if their child devices were used for
      DMA API calls it would only be indicative of a driver bug. However,
      there are a number of buses for which DMA is implicitly expected even
      when not described by firmware - those we whitelist with an automatic
      opt-in to dma_configure(), assuming that the DMA address space and the
      physical address space are equivalent if not otherwise specified.
      
      Commit 72328883 ("of: restrict DMA configuration") introduced a
      short-term fix by comparing explicit bus types, but this approach is far
      from pretty, doesn't scale well, and fails to cope at all with bus
      drivers which may be built as modules, like host1x. Let's refine things
      by making that opt-in a property of the bus type, which neatly addresses
      those problems and lets the decision of whether firmware description of
      DMA capability should be optional or mandatory stay internal to the bus
      drivers themselves.
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Acked-by: NRob Herring <robh@kernel.org>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Acked-by: NThierry Reding <treding@nvidia.com>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      d89e2378
  2. 01 9月, 2017 1 次提交
    • R
      of: restrict DMA configuration · 72328883
      Robin Murphy 提交于
      Moving DMA configuration to happen later at driver probe time had the
      unnoticed side-effect that we now perform DMA configuration for *every*
      device represented in DT, rather than only those explicitly created by
      the of_platform and PCI code.
      
      As Christoph points out, this is not really the best thing to do. Whilst
      there may well be other DMA-capable buses that can benefit from having
      their children automatically configured after the bridge has probed,
      there are also plenty of others like USB, MDIO, etc. that definitely do
      not support DMA and should not be indiscriminately processed.
      
      The good news is that in most cases the DT "dma-ranges" property serves
      as an appropriate indicator - per a strict interpretation of the spec,
      anything lacking a "dma-ranges" property should be considered not to
      have a mapping of DMA address space from its children to its parent,
      thus anything for which of_dma_get_range() does not succeed does not
      need DMA configuration. Certain bus types have a general expectation of
      DMA capability and carry a well-established precedent that an absent
      "dma-ranges" implies the same as the empty property, so we automatically
      opt those in to DMA configuration regardless, to avoid regressing most
      existing platforms.
      
      Fixes: 09515ef5 ("of/acpi: Configure dma operations at probe time for platform/amba/pci bus devices")
      Reported-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Acked-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      72328883
  3. 25 8月, 2017 3 次提交
    • A
      of: Use PLATFORM_DEVID_NONE definition · 6d7e3bf8
      Andy Shevchenko 提交于
      Use dedicated definition instead of plain -1 where it's appropriate.
      
      No functional change intended.
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      6d7e3bf8
    • B
      of/device: Fix of_device_get_modalias() buffer handling · 8c2a75e5
      Bjorn Andersson 提交于
      of_device_request_module() calls of_device_get_modalias() with "len" 0,
      to calculate the size of the buffer needed to store the result, but due
      to integer promotion the ssize_t "len" will be compared as unsigned with
      strlen(compat) and the loop will generally never break. This results in
      a call to snprintf() with a negative len, which triggers below warning,
      followed by a dereference of a invalid pointer:
      
        [    3.060067] WARNING: CPU: 0 PID: 51 at lib/vsprintf.c:2122 vsnprintf+0x348/0x6d8
        ...
        [    3.060301] [<ffffff800891ede8>] vsnprintf+0x348/0x6d8
        [    3.060308] [<ffffff800891f248>] snprintf+0x48/0x50
        [    3.060316] [<ffffff80086a7c80>] of_device_get_modalias+0x108/0x160
        [    3.060322] [<ffffff80086a7cf8>] of_device_request_module+0x20/0x88
        ...
      
      Further more of_device_get_modalias() is supposed to return the number
      of bytes needed to store the entire modalias, so the loop needs to
      continue accumulate the total size even though the buffer is full.
      
      Finally the function is not expected to ensure space for the NUL, nor
      include it in the returned size, so only 1 should be added to the length
      of "compat" in the loop (to account for the character 'C').
      
      Fixes: bc575064 ("of/device: use of_property_for_each_string to parse compatible strings")
      Cc: Rob Herring <robh@kernel.org>
      Signed-off-by: NBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      8c2a75e5
    • B
      of/device: Prevent buffer overflow in of_device_modalias() · 08ab58d9
      Bjorn Andersson 提交于
      As of_device_get_modalias() returns the number of bytes that would have
      been written to the target string, regardless of how much did fit in the
      buffer, it's possible that the returned index points beyond the buffer
      passed to of_device_modalias() - causing memory beyond the buffer to be
      null terminated.
      
      Fixes: 0634c295 ("of: Add function for generating a DT modalias with a newline")
      Cc: Rob Herring <robh@kernel.org>
      Cc: stable@vger.kernel.org
      Signed-off-by: NBjorn Andersson <bjorn.andersson@linaro.org>
      Signed-off-by: NRob Herring <robh@kernel.org>
      08ab58d9
  4. 17 8月, 2017 1 次提交
    • R
      of: fix DMA mask generation · ee7b1f31
      Robin Murphy 提交于
      Historically, DMA masks have suffered some ambiguity between whether
      they represent the range of physical memory a device can access, or the
      address bits a device is capable of driving, particularly since on many
      platforms the two are equivalent. Whilst there are some stragglers left
      (dma_max_pfn(), I'm looking at you...), the majority of DMA code has
      been cleaned up to follow the latter definition, not least since it is
      the only one which makes sense once IOMMUs are involved.
      
      In this respect, of_dma_configure() has always done the wrong thing in
      how it generates initial masks based on "dma-ranges". Although rounding
      down did not affect the TI Keystone platform where dma_addr + size is
      already a power of two, in any other case it results in a mask which is
      at best unnecessarily constrained and at worst unusable.
      
      BCM2837 illustrates the problem nicely, where we have a DMA base of 3GB
      and a size of 1GB - 16MB, giving dma_addr + size = 0xff000000 and a
      resultant mask of 0x7fffffff, which is then insufficient to even cover
      the necessary offset, effectively making all DMA addresses out-of-range.
      This has been hidden until now (mostly because we don't yet prevent
      drivers from simply overwriting this initial mask later upon probe), but
      due to recent changes elsewhere now shows up as USB being broken on
      Raspberry Pi 3.
      
      Make it right by rounding up instead of down, such that the mask
      correctly correctly describes all possisble bits the device needs to
      emit.
      
      Fixes: 9a6d7298 ("of: Calculate device DMA masks based on DT dma-range size")
      Reported-by: NStefan Wahren <stefan.wahren@i2se.com>
      Reported-by: NAndreas Färber <afaerber@suse.de>
      Reported-by: NHans Verkuil <hverkuil@xs4all.nl>
      Signed-off-by: NRobin Murphy <robin.murphy@arm.com>
      Acked-by: NRob Herring <robh@kernel.org>
      Signed-off-by: NChristoph Hellwig <hch@lst.de>
      ee7b1f31
  5. 02 8月, 2017 1 次提交
  6. 19 7月, 2017 1 次提交
  7. 30 5月, 2017 1 次提交
    • S
      iommu/of: Ignore all errors except EPROBE_DEFER · a37b19a3
      Sricharan R 提交于
      While deferring the probe of IOMMU masters, xlate and
      add_device callbacks called from of_iommu_configure
      can pass back error values like -ENODEV, which means
      the IOMMU cannot be connected with that master for real
      reasons. Before the IOMMU probe deferral, all such errors
      were ignored. Now all those errors are propagated back,
      killing the master's probe for such errors. Instead ignore
      all the errors except EPROBE_DEFER, which is the only one
      of concern and let the master work without IOMMU, thus
      restoring the old behavior. Also make explicit that
      of_dma_configure handles only -EPROBE_DEFER from
      of_iommu_configure.
      
      Fixes: 7b07cbef ("iommu: of: Handle IOMMU lookup failure with deferred probing or error")
      Reported-by: NGeert Uytterhoeven <geert@linux-m68k.org>
      Tested-by: NMagnus Damn <magnus.damn@gmail.com>
      Signed-off-by: NSricharan R <sricharan@codeaurora.org>
      Signed-off-by: NJoerg Roedel <jroedel@suse.de>
      a37b19a3
  8. 20 4月, 2017 3 次提交
  9. 23 3月, 2017 1 次提交
    • R
      of: Add function for generating a DT modalias with a newline · 0634c295
      Rob Herring 提交于
      The modalias sysfs attr is lacking a newline for DT aliases on platform
      devices. The macio and ibmebus correctly add the newline, but open code it.
      Introduce a new function, of_device_modalias(), that fills the buffer with
      the modalias including the newline and update users of the old
      of_device_get_modalias function.
      Signed-off-by: NRob Herring <robh@kernel.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Michael Ellerman <mpe@ellerman.id.au>
      Cc: Frank Rowand <frowand.list@gmail.com>
      Cc: linuxppc-dev@lists.ozlabs.org
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      0634c295
  10. 22 3月, 2017 1 次提交
    • R
      of: fix of_device_get_modalias returned length when truncating buffers · bcf54d53
      Rob Herring 提交于
      If the length of the modalias is greater than the buffer size, then the
      modalias is truncated. However the untruncated length is returned which
      will cause an error. Fix this to return the truncated length. If an error
      in the case was desired, then then we should just return -ENOMEM.
      
      The reality is no device will ever have 4KB of compatible strings to hit
      this case.
      Signed-off-by: NRob Herring <robh@kernel.org>
      Cc: Frank Rowand <frowand.list@gmail.com>
      bcf54d53
  11. 20 1月, 2017 2 次提交
  12. 09 5月, 2016 1 次提交
  13. 18 10月, 2015 1 次提交
  14. 18 9月, 2015 1 次提交
  15. 29 5月, 2015 1 次提交
  16. 13 3月, 2015 1 次提交
  17. 04 3月, 2015 2 次提交
  18. 07 7月, 2014 1 次提交
  19. 17 1月, 2014 1 次提交
  20. 06 2月, 2013 1 次提交
    • S
      of: Output devicetree alias names in uevent · ced4eec9
      Stepan Moskovchenko 提交于
      In some situations, userspace may want to resolve a
      device by function and logical number (ie, "serial0")
      rather than by the base address or full device path. Being
      able to resolve a device by alias frees userspace from the
      burden of otherwise having to maintain a mapping between
      device addresses and their logical assignments on each
      platform when multiple instances of the same hardware block
      are present in the system.
      
      Although the uevent device attribute contains devicetree
      compatible information and the full device path, the uevent
      does not list the alises that may have been defined for the
      device.
      Signed-off-by: NStepan Moskovchenko <stepanm@codeaurora.org>
      [grant.likely: Removed OF_ALIAS_N field; I don't think it's needed]
      [grant.likely: Added #ifndef _LINUX_OF_PRIVATE_H wrapper]
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      ced4eec9
  21. 02 2月, 2012 1 次提交
    • G
      drivercore: Output common devicetree information in uevent · 07d57a32
      Grant Likely 提交于
      When userspace needs to find a specific device, it currently isn't easy to
      resolve a /sys/devices/ path from a specific device tree node.  Nor is it
      easy to obtain the compatible list for devices.
      
      This patch generalizes the code that inserts OF_* values into the uevent
      device attribute so that any device that is attached to an OF node will
      have that information exported to userspace.  Without this patch only
      platform devices and some powerpc-specific busses have access to this
      data.
      
      The original function also creates a MODALIAS property for the compatible
      list, but that code has not been generalized into the common case because
      it has the potential to break module loading on a lot of bus types.  Bus
      types are still responsible for their own MODALIAS properties.
      
      Boot tested on ARM and compile tested on PowerPC and SPARC.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      Acked-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      Cc: Tobias Klauser <tklauser@distanz.ch>
      Cc: Frederic Lambert <frdrc66@gmail.com>
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Mark Brown <broonie@sirena.org.uk>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      07d57a32
  22. 28 2月, 2011 1 次提交
    • G
      dt/powerpc: move of_bus_type infrastructure to ibmebus · 710ac54b
      Grant Likely 提交于
      arch/powerpc/kernel/ibmebus.c is the only remaining user of the
      of_bus_type support code for initializing the bus and registering
      drivers.  All others have either been switched to the vanilla platform
      bus or already have their own infrastructure.
      
      This patch moves the functionality that ibmebus is using out of
      drivers/of/{platform,device}.c and into ibmebus.c where it is actually
      used.  Also renames the moved symbols from of_platform_* to
      ibmebus_bus_* to reflect the actual usage.
      
      This patch is part of moving all of the of_platform_bus_type users
      over to the platform_bus_type.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      710ac54b
  23. 22 10月, 2010 1 次提交
    • G
      of/device: Rework to use common platform_device_alloc() for allocating devices · 7096d042
      Grant Likely 提交于
      The current code allocates and manages platform_devices created from
      the device tree manually.  It also uses an unsafe shortcut for
      allocating the platform_device and the resource table at the same
      time. (which I added in the last rework; sorry).
      
      This patch refactors the code to use platform_device_alloc() for
      allocating new devices.  This reduces the amount of custom code
      implemented by of_platform, eliminates the unsafe alloc trick, and has
      the side benefit of letting the platform_bus code manage freeing the
      device data and resources when the device is freed.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: Greg Kroah-Hartman <gregkh@suse.de>
      Cc: "David S. Miller" <davem@davemloft.net>
      Cc: Michal Simek <monstr@monstr.eu>
      7096d042
  24. 06 8月, 2010 1 次提交
  25. 24 7月, 2010 2 次提交
  26. 06 7月, 2010 3 次提交
    • G
      of/device: Add OF style matching helper function · 8cec0e7b
      Grant Likely 提交于
      Add of_driver_match_device() helper function.  This function can be used
      by bus types to determine if a driver works with a device when using OF
      style matching.  If CONFIG_OF is unselected, then it is a nop.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      CC: Greg Kroah-Hartman <gregkh@suse.de>
      CC: Michal Simek <monstr@monstr.eu>
      CC: Grant Likely <grant.likely@secretlab.ca>
      CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      CC: Stephen Rothwell <sfr@canb.auug.org.au>
      CC: linux-kernel@vger.kernel.org
      CC: microblaze-uclinux@itee.uq.edu.au
      CC: linuxppc-dev@ozlabs.org
      CC: devicetree-discuss@lists.ozlabs.org
      8cec0e7b
    • G
      of: Modify of_device_get_modalias to be passed struct device · 34a1c1e8
      Grant Likely 提交于
      Now that the of_node pointer is part of struct device,
      of_device_get_modalias could be used on any struct device
      that has the device node pointer set.  This patch changes
      of_device_get_modalias to accept a struct device instead
      of a struct of_device.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      CC: Michal Simek <monstr@monstr.eu>
      CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      CC: Wolfram Sang <w.sang@pengutronix.de>
      CC: Stephen Rothwell <sfr@canb.auug.org.au>
      CC: microblaze-uclinux@itee.uq.edu.au
      CC: linuxppc-dev@ozlabs.org
      34a1c1e8
    • G
      of/device: merge of_device_uevent · dd27dcda
      Grant Likely 提交于
      Merge common code between powerpc and microblaze
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      CC: Michal Simek <monstr@monstr.eu>
      CC: Wolfram Sang <w.sang@pengutronix.de>
      CC: Stephen Rothwell <sfr@canb.auug.org.au>
      CC: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      CC: microblaze-uclinux@itee.uq.edu.au
      CC: linuxppc-dev@ozlabs.org
      dd27dcda
  27. 22 5月, 2010 1 次提交
  28. 19 5月, 2010 1 次提交
  29. 31 10月, 2008 1 次提交
    • J
      OF-device: Don't overwrite numa_node in device registration · 6098e2ee
      Jeremy Kerr 提交于
      Currently, the numa_node of OF-devices will be overwritten during
      device_register, which simply sets the node to -1.  On cell machines,
      this means that devices can't find their IOMMU, which is referenced
      through the device's numa node.
      
      Set the numa node for OF devices with no parent, and use the
      lower-level device_initialize and device_add functions, so that the
      node is preserved.
      
      We can remove the call to set_dev_node in of_device_alloc, as it
      will be overwritten during register.
      Signed-off-by: NJeremy Kerr <jk@ozlabs.org>
      Signed-off-by: NPaul Mackerras <paulus@samba.org>
      6098e2ee
  30. 20 8月, 2008 1 次提交
  31. 16 5月, 2008 1 次提交