1. 24 7月, 2014 2 次提交
    • G
      of: Move dynamic node fixups out of powerpc and into common code · a25095d4
      Grant Likely 提交于
      PowerPC does an odd thing with dynamic nodes. It uses a notifier to
      catch new node additions and set some of the values like name and type.
      This makes no sense since that same code can be put directly into
      of_attach_node(). Besides, all dynamic node users need this, not just
      powerpc. Fix this problem by moving the logic out of arch/powerpc and
      into drivers/of/dynamic.c.
      
      It is also important to remove this notifier because we want to move the
      firing of notifiers from before the tree is modified to after so that
      the receiver gets a consistent view of the tree, but that is
      incompatible with notifiers that modify the node.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: Nathan Fontenot <nfont@austin.ibm.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      a25095d4
    • G
      of: Make devicetree sysfs update functions consistent. · 8a2b22a2
      Grant Likely 提交于
      All of the DT modification functions are split into two parts, the first
      part manipulates the DT data structure, and the second part updates
      sysfs, but the code isn't very consistent about how the second half is
      called. They don't all enforce the same rules about when it is valid to
      update sysfs, and there isn't any clarity on locking.
      
      The transactional DT modification feature that is coming also needs
      access to these functions so that it can perform all the structure
      changes together, and then all the sysfs updates as a second stage
      instead of doing each one at a time.
      
      Fix up the second have by creating a separate __of_*_sysfs() function
      for each of the helpers. The new functions have consistent naming (ie.
      of_node_add() becomes __of_attach_node_sysfs()) and all of them now
      defer if of_init hasn't been called yet.
      
      Callers of the new functions must hold the of_mutex to ensure there are
      no race conditions with of_init(). The mutex ensures that there will
      only ever be one writer to the tree at any given time. There can still
      be any number of readers and the raw_spin_lock is still used to make
      sure access to the data structure is still consistent.
      
      Finally, put the function prototypes into of_private.h so they are
      accessible to the transaction code.
      Signed-off-by: NPantelis Antoniou <pantelis.antoniou@konsulko.com>
      [grant.likely: Changed suffix from _post to _sysfs to match existing code]
      [grant.likely: Reorganized to eliminate trivial wrappers]
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      8a2b22a2
  2. 16 7月, 2014 1 次提交
    • P
      of: Create unlocked versions of node and property add/remove functions · d8c50088
      Pantelis Antoniou 提交于
      The DT overlay code will need to manipulate nodes and properties while
      already holding the devicetree lock, or on nodes that are not yet
      attached to the tree, but the current helper functions don't allow that.
      Extract the core behaviour from the accessors and create the following
      unlocked variants.
      
      The unlocked variants require either the lock to already be held or for
      the nodes to be detached from the tree. Changes to live nodes will not
      get updated in sysfs, so the caller must arrange for housekeeping to
      take place after dropping the lock.
      
      The new functions are: __of_add_property(), __of_remove_property(),
      __of_update_property(), __of_attach_node() and __of_detach_node().
      Signed-off-by: NPantelis Antoniou <pantelis.antoniou@konsulko.com>
      [Remove unnecessary diff hunks and rewrite commit text]
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      d8c50088
  3. 07 7月, 2014 2 次提交
  4. 17 6月, 2014 2 次提交
  5. 04 6月, 2014 1 次提交
  6. 23 5月, 2014 3 次提交
  7. 14 5月, 2014 1 次提交
    • T
      of: make of_update_property() usable earlier in the boot process · 582da652
      Thomas Petazzoni 提交于
      Commit 75b57ecf ('of: Make device
      nodes kobjects so they show up in sysfs') has turned Device Tree nodes
      in kobjects and added a sysfs based representation for Device Tree
      nodes. Since the sysfs logic is only available after the execution of
      a core_initcall(), the patch took precautions in of_add_property() and
      of_remove_property() to not do any sysfs related manipulation early in
      the boot process.
      
      However, it forgot to do the same for of_update_property(), which if
      used early in the boot process (before core_initcalls have been
      called), tries to call sysfs_remove_bin_file(), and crashes:
      
      ------------[ cut here ]------------
      WARNING: CPU: 0 PID: 0 at /home/thomas/projets/linux-2.6/fs/kernfs/dir.c:1216 kernfs_remove_by_name_ns+0x80/0x88()
      kernfs: can not remove '(null)', no directory
      Modules linked in:
      CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.15.0-rc1-00127-g1d7e7b2-dirty #423
      [<c0014910>] (unwind_backtrace) from [<c00110ec>] (show_stack+0x10/0x14)
      [<c00110ec>] (show_stack) from [<c04c84b8>] (dump_stack+0x84/0x94)
      [<c04c84b8>] (dump_stack) from [<c001d8c0>] (warn_slowpath_common+0x6c/0x88)
      [<c001d8c0>] (warn_slowpath_common) from [<c001d90c>] (warn_slowpath_fmt+0x30/0x40)
      [<c001d90c>] (warn_slowpath_fmt) from [<c0104468>] (kernfs_remove_by_name_ns+0x80/0x88)
      [<c0104468>] (kernfs_remove_by_name_ns) from [<c0394d98>] (of_update_property+0xc0/0xf0)
      [<c0394d98>] (of_update_property) from [<c0647248>] (mvebu_timer_and_clk_init+0xfc/0x194)
      [<c0647248>] (mvebu_timer_and_clk_init) from [<c0640934>] (start_kernel+0x218/0x350)
      [<c0640934>] (start_kernel) from [<00008070>] (0x8070)
      ---[ end trace 3406ff24bd97382e ]---
      Unable to handle kernel NULL pointer dereference at virtual address 0000003c
      pgd = c0004000
      [0000003c] *pgd=00000000
      Internal error: Oops: 5 [#1] SMP ARM
      Modules linked in:
      CPU: 0 PID: 0 Comm: swapper/0 Tainted: G        W     3.15.0-rc1-00127-g1d7e7b2-dirty #423
      task: c10ad4d8 ti: c10a2000 task.ti: c10a2000
      PC is at kernfs_find_ns+0x8/0xf0
      LR is at kernfs_find_and_get_ns+0x30/0x48
      pc : [<c0103834>]    lr : [<c010394c>]    psr: 600001d3
      sp : c10a3f34  ip : 00000073  fp : 00000000
      r10: 00000000  r9 : cfffc240  r8 : cfdf2980
      r7 : cf812c00  r6 : 00000000  r5 : 00000000  r4 : c10b45e0
      r3 : c10ad4d8  r2 : 00000000  r1 : cf812c00  r0 : 00000000
      Flags: nZCv  IRQs off  FIQs off  Mode SVC_32  ISA ARM  Segment kernel
      Control: 10c53c7d  Table: 0000404a  DAC: 00000015
      Process swapper/0 (pid: 0, stack limit = 0xc10a2240)
      Stack: (0xc10a3f34 to 0xc10a4000)
      3f20:                                              c10b45e0 00000000 00000000
      3f40: cf812c00 c010394c 00000063 cf812c00 00000001 cf812c00 cfdf29ac c03932cc
      3f60: 00000063 cf812bc0 cfdf29ac cf812c00 ffffffff c03943f8 cfdf2980 c0104468
      3f80: cfdf2a04 cfdf2980 cf812bc0 c06634b0 c10aa3c0 c0394da4 c10f74dc cfdf2980
      3fa0: cf812bc0 c0647248 c10aa3c0 ffffffff c10de940 c10aa3c0 ffffffff c0640934
      3fc0: ffffffff ffffffff c06404ec 00000000 00000000 c06634b0 00000000 10c53c7d
      3fe0: c10aa434 c06634ac c10ae4c8 0000406a 414fc091 00008070 00000000 00000000
      [<c0103834>] (kernfs_find_ns) from [<00000001>] (0x1)
      Code: e5c89001 eaffffcf e92d40f0 e1a06002 (e1d023bc)
      ---[ end trace 3406ff24bd97382f ]---
      Kernel panic - not syncing: Attempted to kill the idle task!
      ---[ end Kernel panic - not syncing: Attempted to kill the idle task!
      
      To fix this problem, we simply skip the sysfs related calls in
      of_update_property(), and rely on of_init() to fix up things when it
      will be called, exactly as is done in of_add_property() and
      of_remove_property().
      Signed-off-by: NThomas Petazzoni <thomas.petazzoni@free-electrons.com>
      Fixes: 75b57ecf ("of: Make device nodes kobjects so they show up in sysfs")
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      582da652
  8. 05 5月, 2014 1 次提交
  9. 16 4月, 2014 1 次提交
  10. 28 3月, 2014 1 次提交
  11. 19 3月, 2014 1 次提交
    • P
      of: device_node kobject lifecycle fixes · 0829f6d1
      Pantelis Antoniou 提交于
      After the move to having device nodes be proper kobjects the lifecycle
      of the node needs to be controlled better.
      
      At first convert of_add_node() in the unflattened functions to
      of_init_node() which initializes the kobject so that of_node_get/put
      work correctly even before of_init is called.
      
      Afterwards introduce of_node_is_initialized & of_node_is_attached that
      query the underlying kobject about the state (attached means kobj
      is visible in sysfs)
      
      Using that make sure the lifecycle of the tree is correct at all
      times.
      Signed-off-by: NPantelis Antoniou <panto@antoniou-consulting.com>
      [grant.likely: moved of_node_init() calls, fixed up locking, and
                     dropped __of_populate() hunks]
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      0829f6d1
  12. 12 3月, 2014 2 次提交
    • G
      of: remove /proc/device-tree · 8357041a
      Grant Likely 提交于
      The same data is now available in sysfs, so we can remove the code
      that exports it in /proc and replace it with a symlink to the sysfs
      version.
      
      Tested on versatile qemu model and mpc5200 eval board. More testing
      would be appreciated.
      
      v5: Fixed up conflicts with mainline changes
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
      Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
      8357041a
    • G
      of: Make device nodes kobjects so they show up in sysfs · 75b57ecf
      Grant Likely 提交于
      Device tree nodes are already treated as objects, and we already want to
      expose them to userspace which is done using the /proc filesystem today.
      Right now the kernel has to do a lot of work to keep the /proc view in
      sync with the in-kernel representation. If device_nodes are switched to
      be kobjects then the device tree code can be a whole lot simpler. It
      also turns out that switching to using /sysfs from /proc results in
      smaller code and data size, and the userspace ABI won't change if
      /proc/device-tree symlinks to /sys/firmware/devicetree/base.
      
      v7: Add missing sysfs_bin_attr_init()
      v6: Add __of_add_property() early init fixes from Pantelis
      v5: Rename firmware/ofw to firmware/devicetree
          Fix updating property values in sysfs
      v4: Fixed build error on Powerpc
          Fixed handling of dynamic nodes on powerpc
      v3: Fixed handling of duplicate attribute and child node names
      v2: switch to using sysfs bin_attributes which solve the problem of
          reporting incorrect property size.
      Signed-off-by: NGrant Likely <grant.likely@secretlab.ca>
      Tested-by: NSascha Hauer <s.hauer@pengutronix.de>
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Nathan Fontenot <nfont@linux.vnet.ibm.com>
      Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
      75b57ecf
  13. 07 3月, 2014 5 次提交
  14. 04 3月, 2014 1 次提交
  15. 20 2月, 2014 1 次提交
    • K
      of: reimplement the matching method for __of_match_node() · 215a14cf
      Kevin Hao 提交于
      In the current implementation of __of_match_node(), it will compare
      each given match entry against all the node's compatible strings
      with of_device_is_compatible().
      
      To achieve multiple compatible strings per node with ordering from
      specific to generic, this requires given matches to be ordered from
      specific to generic. For most of the drivers this is not true and
      also an alphabetical ordering is more sane there.
      
      Therefore, we define a following priority order for the match, and
      then scan all the entries to find the best match.
        1. specific compatible && type && name
        2. specific compatible && type
        3. specific compatible && name
        4. specific compatible
        5. general compatible && type && name
        6. general compatible && type
        7. general compatible && name
        8. general compatible
        9. type && name
        10. type
        11. name
      
      v5: Fix nested locking bug
      v4: Short-circuit failure cases instead of mucking with score, and
          remove extra __of_device_is_compatible() wrapper stub.
          Move scoring logic directly into __of_device_is_compatible()
      v3: Also need to bail out when there does have a compatible member in match
          entry, but it doesn't match with the device node's compatible.
      v2: Fix the bug such as we get the same score for the following two match
          entries with the empty node 'name2 { };'
      	struct of_device_id matches[] = {
      		{.name = "name2", },
      		{.name = "name2", .type = "type1", },
      		{}
      	};
      Signed-off-by: NKevin Hao <haokexin@gmail.com>
      [grant.likely: added v4 changes]
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Tested-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      Tested-by: NStephen Chivers <schivers@csc.com>
      Tested-by: NSachin Kamat <sachin.kamat@linaro.org>
      215a14cf
  16. 19 2月, 2014 1 次提交
  17. 16 2月, 2014 1 次提交
    • K
      of: search the best compatible match first in __of_match_node() · 06b29e76
      Kevin Hao 提交于
      Currently, of_match_node compares each given match against all node's
      compatible strings with of_device_is_compatible.
      
      To achieve multiple compatible strings per node with ordering from
      specific to generic, this requires given matches to be ordered from
      specific to generic. For most of the drivers this is not true and also
      an alphabetical ordering is more sane there.
      
      Therefore, this patch introduces a function to match each of the node's
      compatible strings against all given compatible matches without type and
      name first, before checking the next compatible string. This implies
      that node's compatibles are ordered from specific to generic while
      given matches can be in any order. If we fail to find such a match
      entry, then fall-back to the old method in order to keep compatibility.
      
      Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
      Signed-off-by: NKevin Hao <haokexin@gmail.com>
      Tested-by: NStephen Chivers <schivers@csc.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      06b29e76
  18. 15 2月, 2014 1 次提交
    • K
      Revert "OF: base: match each node compatible against all given matches first" · 4e8ca6ee
      Kevin Hao 提交于
      This reverts commit 10535314.
      Stephen Chivers reported this is broken as we will get a match
      entry '.type = "serial"' instead of the '.compatible = "ns16550"'
      in the following scenario:
      	serial0: serial@4500 {
      		compatible = "fsl,ns16550", "ns16550";
      	}
      
      	struct of_device_id of_platform_serial_table[] = {
      		{ .compatible = "ns8250",   .data = (void *)PORT_8250, },
      		{ .compatible = "ns16450",  .data = (void *)PORT_16450, },
      		{ .compatible = "ns16550a", .data = (void *)PORT_16550A, },
      		{ .compatible = "ns16550",  .data = (void *)PORT_16550, },
      		{ .compatible = "ns16750",  .data = (void *)PORT_16750, },
      		{ .compatible = "ns16850",  .data = (void *)PORT_16850, },
      		...
      		{ .type = "serial",         .data = (void *)PORT_UNKNOWN, },
      		{ /* end of list */ },
      	};
      
      So just revert this patch, we will use another implementation to find
      the best compatible match in a follow-on patch.
      Reported-by: NStephen N Chivers <schivers@csc.com.au>
      Cc: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
      Signed-off-by: NKevin Hao <haokexin@gmail.com>
      Signed-off-by: NRob Herring <robh@kernel.org>
      4e8ca6ee
  19. 12 2月, 2014 1 次提交
  20. 05 2月, 2014 2 次提交
  21. 03 2月, 2014 1 次提交
  22. 17 1月, 2014 1 次提交
    • X
      of: Fix __of_device_is_available check · 42ccd781
      Xiubo Li 提交于
      From IEEE 1275, there defined a standard 'status' property indicating the
      operational status of one device. The 'status' property has four possible
      values: 'okay/ok', 'disabled', 'fail' and 'fail-xxx'.
      
      If it is absent, that means the status of the device is unknown or okay.
      
      The __of_device_is_available checks the state of the 'status' property of
      a device. If the property is absent or set to 'okay/ok', it returns 1.
      Otherwise it returns 0.
      
      While in __of_device_is_available:
       >	status = of_get_property(device, "status", &statlen);
       >	if (status == NULL)
       >		return 1;
      The status value returned from 'of_get_property()' will be NULL in two cases:
      Firstly: the 'device' value (device node) is NULL.
      Secondly: the 'status' property is actaully not exist.
      
      If the device node is NULL, the __of_device_is_available will return true,
      that will mean the absent state of the 'status' property.
      
      So this add the device node check before checking the 'status' property's
      state, and if the device node is not exist, 0 will be returned.
      Signed-off-by: NXiubo Li <Li.Xiubo@freescale.com>
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      42ccd781
  23. 05 12月, 2013 1 次提交
  24. 31 10月, 2013 1 次提交
  25. 24 10月, 2013 1 次提交
  26. 16 10月, 2013 2 次提交
    • G
      of: Fix iteration bug over CPU reg properties · f3cea45a
      Grant Likely 提交于
      The size of each hwid in a cpu nodes 'reg' property is defined by the
      parents #address-cells property in the normal way. The cpu parsing code
      has a bug where it will overrun the end of the property if
      address-cells is greater than one. This commit fixes the problem by
      adjusting the array size by the number of address cells. It also makes
      sure address-cells isn't zero for that would cause an infinite loop.
      
      v2: bail if #address-cells is zero instead of forcing to
          OF_ROOT_NODE_ADDR_CELLS_DEFAULT. Forcing it will cause the reg
          property to be parsed incorrectly.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: Rob Herring <rob.herring@calxeda.com>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      f3cea45a
    • D
      of: Make cpu node handling more portable. · d1cb9d1a
      David Miller 提交于
      Use for_each_node_by_type() to iterate all cpu nodes in the
      system.
      
      Provide and overridable function arch_find_n_match_cpu_physical_id,
      which sees if the given device node matches 'cpu' and if so sets
      '*thread' when non-NULL to the cpu thread number within the core.
      
      The default implementation behaves the same as the existing code.
      
      Add a sparc64 implementation.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      Tested-by: NSudeep KarkadaNagesha <Sudeep.KarkadaNagesha@arm.com>
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      d1cb9d1a
  27. 14 10月, 2013 1 次提交
    • G
      of: fix unnecessary warning on missing /cpus node · 444c91e5
      Grant Likely 提交于
      Not all DT platforms have all the cpus collected under a /cpus node.
      That just happens to be a details of FDT, ePAPR and PowerPC platforms.
      Sparc does something different, but unfortunately the current code
      complains with a warning if /cpus isn't there. This became a problem
      with commit f86e4718, "driver/core cpu: initialize of_node in cpu's
      device structure", which caused the function to get called for all
      architectures.
      
      This commit is a temporary fix to fail silently if the cpus node isn't
      present. A proper fix will come later to allow arch code to provide a
      custom mechanism for decoding the CPU hwid if the 'reg' property isn't
      appropriate.
      Signed-off-by: NGrant Likely <grant.likely@linaro.org>
      Cc: David Miller <davem@davemloft.net>
      Cc: Sudeep KarkadaNagesha <Sudeep.KarkadaNagesha@arm.com>
      Cc: Rob Herring <rob.herring@calxeda.com>
      444c91e5
  28. 10 10月, 2013 1 次提交