1. 15 Aug, 2016 1 commit
  2. 12 Aug, 2016 1 commit
    • Kevin Hao's avatar
      of/platform: disable the of_platform_default_populate_init() for all the ppc boards · fc520f8b
      Kevin Hao authored
      With the commit 44a7185c ("of/platform: Add common method to
      populate default bus"), a default function is introduced to populate
      the default bus and this function is invoked at the arch_initcall_sync
      level. But a lot of ppc boards use machine_device_initcall() to
      populate the default bus. This means that the default populate function
      has higher priority and would override the arch specific population of
      the bus. The side effect is that some arch specific bus are not probed,
      then cause various malfunction due to the miss of some devices. Since
      it is very possible to introduce bugs if we simply change the initcall
      level for all these boards(about 30+). This just disable this default
      function for all the ppc boards.
      Signed-off-by: default avatarKevin Hao <haokexin@gmail.com>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
  3. 09 Aug, 2016 3 commits
    • Philipp Zabel's avatar
      of/irq: Mark interrupt controllers as populated before initialisation · e55aeb6b
      Philipp Zabel authored
      That way the init callback may clear the flag again, in case of drivers
      split between early irq chip and a normal platform driver.
      Fixes: 15cc2ed6 ("of/irq: Mark initialised interrupt controllers as populated")
      Suggested-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarPhilipp Zabel <p.zabel@pengutronix.de>
      Acked-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
    • Gavin Shan's avatar
      drivers/of: Validate device node in __unflatten_device_tree() · 89c67752
      Gavin Shan authored
      @mynodes is set to NULL when __unflatten_device_tree() is called
      to unflatten device sub-tree in PCI hot add scenario on PowerPC
      PowerNV platform. Marking @mynodes detached unconditionally causes
      kernel crash as below backtrace shows:
      Unable to handle kernel paging request for data at address 0x00000000
      Faulting instruction address: 0xc000000000b26f64
      cpu 0x0: Vector: 300 (Data Access) at [c000003fcc7cf740]
          pc: c000000000b26f64: __unflatten_device_tree+0xf4/0x190
          lr: c000000000b26f40: __unflatten_device_tree+0xd0/0x190
          sp: c000003fcc7cf9c0
         msr: 900000000280b033
         dar: 0
       dsisr: 40000000
        current = 0xc000003fcc281680
        paca    = 0xc00000000ff00000	 softe: 0	 irq_happened: 0x01
          pid   = 2724, comm = sh
      Linux version 4.7.0-gavin-07754-g92a6836 (gwshan@gwshan) (gcc version \
      4.9.3 (Buildroot 2016.02-rc2-00093-g5ea3bce) ) #539 SMP Mon Aug 1 \
      12:40:29 AEST 2016
      enter ? for help
      [c000003fcc7cfa50] c000000000b27060 of_fdt_unflatten_tree+0x60/0x90
      [c000003fcc7cfaa0] c0000000004c6288 pnv_php_set_slot_power_state+0x118/0x440
      [c000003fcc7cfb80] c0000000004c6a10 pnv_php_enable+0xc0/0x170
      [c000003fcc7cfbd0] c0000000004c4d80 power_write_file+0xa0/0x190
      [c000003fcc7cfc50] c0000000004be93c pci_slot_attr_store+0x3c/0x60
      [c000003fcc7cfc70] c0000000002d3fd4 sysfs_kf_write+0x94/0xc0
      [c000003fcc7cfcb0] c0000000002d2c30 kernfs_fop_write+0x180/0x260
      [c000003fcc7cfd00] c000000000230fe0 __vfs_write+0x40/0x190
      [c000003fcc7cfd90] c000000000232278 vfs_write+0xc8/0x240
      [c000003fcc7cfde0] c000000000233d90 SyS_write+0x60/0x110
      [c000003fcc7cfe30] c000000000009524 system_call+0x38/0x108
      This avoids the kernel crash by marking @mynodes detached only when
      @mynodes is dereferencing valid device node in __unflatten_device_tree().
      Fixes: 1d1bde55 ("of: fdt: mark unflattened tree as detached")
      Reported-by: default avatarMeng Li <shlimeng@cn.ibm.com>
      Signed-off-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
    • Markus Elfring's avatar
      of: Delete an unnecessary check before the function call "of_node_put" · beab47d5
      Markus Elfring authored
      The of_node_put() function tests whether its argument is NULL
      and then returns immediately.
      Thus the test around the call is not needed.
      This issue was detected by using the Coccinelle software.
      Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
  4. 05 Aug, 2016 1 commit
  5. 19 Jul, 2016 1 commit
  6. 18 Jul, 2016 3 commits
  7. 16 Jul, 2016 1 commit
  8. 06 Jul, 2016 1 commit
  9. 28 Jun, 2016 1 commit
    • Arnd Bergmann's avatar
      of_mdio: select fixed phy support unconditionally · a5e4bd99
      Arnd Bergmann authored
      Calling the fixed-phy functions when CONFIG_FIXED_PHY=m as a previous
      change tried cannot work if the caller is in built-in code:
      drivers/of/built-in.o: In function `of_phy_register_fixed_link':
      of_reserved_mem.c:(.text+0x85e0): undefined reference to `fixed_phy_register'
      Making of_mdio depend on 'FIXED_PHY || !FIXED_PHY' would solve this
      dependency by enforcing that OF_MDIO itself becomes a loadable module
      when FIXED_PHY=y, but that creates a different dependency as it
      breaks any built-in ethernet driver that uses of_mdio.
      Making FIXED_PHY a bool option also cannot work, since it depends on
      PHYLIB, which again is tristate.
      This version now uses 'select FIXED_PHY' to ensure that the fixed-phy
      portion of of_mdio is not optional. The main downside of this is
      a small increase in code size for cases that do not need fixed phy
      support, but it should avoid all of the link-time problems.
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Fixes: d1bd330a ("of_mdio: Enable fixed PHY support if driver is a module")
      Acked-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
  10. 24 Jun, 2016 2 commits
    • Jon Hunter's avatar
      of/irq: Mark initialised interrupt controllers as populated · 15cc2ed6
      Jon Hunter authored
      For interrupt controllers successfully initialised early via device-tree,
      mark these interrupt controllers as populated so we don't unnecessarily
      create a device and populate any platform data later on in the boot
      sequence when we populate all the various platform devices.
      Signed-off-by: default avatarJon Hunter <jonathanh@nvidia.com>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
    • Frank Rowand's avatar
      of: fix memory leak related to safe_name() · d9fc8807
      Frank Rowand authored
      Fix a memory leak resulting from memory allocation in safe_name().
      This patch fixes all call sites of safe_name().
      Mathieu Malaterre reported the memory leak on boot:
      On my PowerMac device-tree would generate a duplicate name:
      [    0.023043] device-tree: Duplicate name in PowerPC,G4@0, renamed to "l2-cache#1"
      in this case a newly allocated name is generated by `safe_name`. However
      in this case it is never deallocated.
      The bug was found using kmemleak reported as:
      unreferenced object 0xdf532e60 (size 32):
        comm "swapper", pid 1, jiffies 4294892300 (age 1993.532s)
        hex dump (first 32 bytes):
          6c 32 2d 63 61 63 68 65 23 31 00 dd e4 dd 1e c2  l2-cache#1......
          ec d4 ba ce 04 ec cc de 8e 85 e9 ca c4 ec cc 9e  ................
          [<c02d3350>] kvasprintf+0x64/0xc8
          [<c02d3400>] kasprintf+0x4c/0x5c
          [<c0453814>] safe_name.isra.1+0x80/0xc4
          [<c04545d8>] __of_attach_node_sysfs+0x6c/0x11c
          [<c075f21c>] of_core_init+0x8c/0xf8
          [<c0729594>] kernel_init_freeable+0xd4/0x208
          [<c00047e8>] kernel_init+0x24/0x11c
          [<c00158ec>] ret_from_kernel_thread+0x5c/0x64
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=120331Signed-off-by: default avatarFrank Rowand <frank.rowand@am.sony.com>
      Reported-by: mathieu.malaterre@gmail.com
      Tested-by: default avatarMathieu Malaterre <mathieu.malaterre@gmail.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
  11. 23 Jun, 2016 4 commits
  12. 09 Jun, 2016 2 commits
  13. 03 Jun, 2016 4 commits
    • Stephen Rothwell's avatar
      of: silence warnings due to max() usage · aaaab56d
      Stephen Rothwell authored
      pageblock_order can be (at least) an unsigned int or an unsigned long
      depending on the kernel config and architecture, so use max_t(unsigned
      long ...) when comparing it.
      fixes these warnings:
      In file included from include/linux/list.h:8:0,
                       from include/linux/kobject.h:20,
                       from include/linux/of.h:21,
                       from drivers/of/of_reserved_mem.c:17:
      drivers/of/of_reserved_mem.c: In function ‘__reserved_mem_alloc_size’:
      include/linux/kernel.h:748:17: warning: comparison of distinct pointer types lacks a cast
        (void) (&_max1 == &_max2);  \
      include/linux/kernel.h:747:9: note: in definition of macro ‘max’
        typeof(y) _max2 = (y);   \
      drivers/of/of_reserved_mem.c:131:48: note: in expansion of macro ‘max’
         align = max(align, (phys_addr_t)PAGE_SIZE << max(MAX_ORDER - 1, pageblock_ord
      include/linux/kernel.h:748:17: warning: comparison of distinct pointer types lacks a cast
        (void) (&_max1 == &_max2);  \
      include/linux/kernel.h:747:21: note: in definition of macro ‘max’
        typeof(y) _max2 = (y);   \
      drivers/of/of_reserved_mem.c:131:48: note: in expansion of macro ‘max’
         align = max(align, (phys_addr_t)PAGE_SIZE << max(MAX_ORDER - 1, pageblock_ord
      Fixes: 1cc8e345 ("drivers: of: of_reserved_mem: fixup the alignment with CMA setup")
      Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
    • Jaewon's avatar
      drivers: of: of_reserved_mem: fixup the CMA alignment not to affect dma-coherent · 7d482813
      Jaewon authored
      There was an alignment mismatch issue for CMA and it was fixed by
      commit 1cc8e345 ("drivers: of: of_reserved_mem: fixup the alignment with CMA setup").
      However the way of the commit considers not only dma-contiguous(CMA) but also
      dma-coherent which has no that requirement.
      This patch checks more to distinguish dma-contiguous(CMA) from dma-coherent.
      Signed-off-by: default avatarJaewon Kim <jaewon31.kim@samsung.com>
      Acked-by: default avatarJason Liu <r64343@freescale.com>
      Acked-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      [robh: remove erroneous opening bracket]
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
    • Sergei Shtylyov's avatar
      of: irq: fix of_irq_get[_byname]() kernel-doc · 39935466
      Sergei Shtylyov authored
      The kernel-doc for the of_irq_get[_byname]()  is clearly inadequate in
      describing the return values -- of_irq_get_byname() is documented better
      than of_irq_get() but it  still doesn't mention that 0 is returned iff
      irq_create_of_mapping() fails (it doesn't return an error code in this
      case). Document all possible return value variants, making the writing
      of the word "IRQ" consistent, while at it...
      Fixes: 9ec36caf ("of/irq: do irq resolution in platform_get_irq")
      Fixes: ad69674e ("of/irq: do irq resolution in platform_get_irq_byname()")
      Signed-off-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
      CC: stable@vger.kernel.org
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
    • Marek Szyprowski's avatar
      of: reserved_mem: add support for using more than one region for given device · 59ce4039
      Marek Szyprowski authored
      This patch allows device drivers to initialize more than one reserved
      memory region assigned to given device. When driver needs to use more
      than one reserved memory region, it should allocate child devices and
      initialize regions by index for each of its child devices.
      Signed-off-by: default avatarMarek Szyprowski <m.szyprowski@samsung.com>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
  14. 30 May, 2016 1 commit
  15. 19 May, 2016 3 commits
    • Javier Martinez Canillas's avatar
      of/unittest: Remove unnecessary module.h header inclusion · 27f4ec14
      Javier Martinez Canillas authored
      The OF_UNITTEST Kconfig symbol is bool so this unittest can only be
      built-in and not build as a module. Also, nothing defined in this
      header file used so is not necessary to include it.
      Signed-off-by: default avatarJavier Martinez Canillas <javier@osg.samsung.com>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
    • Gavin Shan's avatar
      drivers/of: Fix build warning in populate_node() · dddc33e5
      Gavin Shan authored
      Function populate_node() is used to unflatten FDT blob to device
      tree. It supports maximal 64 level of device nodes. There is one
      array @fpsizes[64] tracking the full name length of last unflattened
      device node in the corresponding level (index of element in the
      array - 1). Build warning is seen with CONFIG_FRAME_WARN=1024 like
      below on ARM64 as Geert reported. The issue can be reproduced on
      PPC64 as well.
        $ make drivers/of/fdt.o
        drivers/of/fdt.c:443:1: warning: the frame size of 1136 bytes is \
        larger than 1024 bytes [-Wframe-larger-than=]
      This changes the data type of @fpsizes[i] from "unsigned long" to
      "unsigned int" to avoid the build warning. The return value type
      of populate_node() and its @fpsize argument is adjusted accordingly.
      With this applied, 256 bytes saved from the stack frame on ARM64 and
      PPC64 platforms and the above warning isn't seen.
      Fixes: 50800082 ("drivers/of: Avoid recursively calling unflatten_dt_node()")
      Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
      Signed-off-by: default avatarGavin Shan <gwshan@linux.vnet.ibm.com>
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
    • Rhyland Klein's avatar
      drivers/of: Fix depth when unflattening devicetree · 78c44d91
      Rhyland Klein authored
      When the implementation for unflatten_dt_node() changed from being
      recursive to being non-recursive, it had a side effect of increasing the
      depth passed to fdt_next_node() by 1. This is fine most of the time, but
      it seems that when the end of the dtb is being parsed, it will cause the
      FDT_END condition in fdt_next_node() to return a different value
      (returning nextoffset instead of -FDT_ERR_NOTFOUND). This ends up passing
      an FDT_ERR_TRUNCATED error back to the unflatten_dt_node() which then
      sees that and complains "Error -8 processing FDT" causing boot to fail.
      This patch simply avoids incrementing depth and uses modified accesses
      for local array indices so that the depth is the same as it was before
      the change as far as fdt_next_node() is concerned.
      This problem was discovered trying to boot Tegra210-Smaug platforms.
      Fixes: 50800082 ("drivers/of: Avoid recursively calling unflatten_dt_node()")
      Signed-off-by: default avatarRhyland Klein <rklein@nvidia.com>
      [robh: squashed in KASAN fix from Rhyland]
      Signed-off-by: default avatarRob Herring <robh@kernel.org>
  16. 16 May, 2016 7 commits
  17. 12 May, 2016 1 commit
  18. 11 May, 2016 1 commit
    • Suraj Jitindar Singh's avatar
      drivers/of: Add check for null property in of_remove_property() · 201b3fe5
      Suraj Jitindar Singh authored
      The validity of the property input argument to of_remove_property() is
      never checked within the function and thus it is possible to pass a null
      value. It happens that this will be picked up in __of_remove_property()
      as no matching property of the device node will be found and thus an
      error will be returned, however once again there is no explicit check
      for a null value. By the time this is detected 2 locks have already been
      acquired which is completely unnecessary if the property to remove is
      Add an explicit check in the function of_remove_property() for a null
      property value and return -ENODEV in this case, this is consistent with
      what the previous return value would have been when the null value was
      not detected and passed to __of_remove_property().
      By moving an explicit check for the property paramenter into the
      of_remove_property() function, this will remove the need to perform this
      check in calling code before invocation of the of_remove_property()
      Signed-off-by: default avatarSuraj Jitindar Singh <sjitindarsingh@gmail.com>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
  19. 09 May, 2016 1 commit
  20. 05 May, 2016 1 commit