€•ÜIŒsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”Œparent”hsbaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ,/translations/zh_CN/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”hh2sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/zh_TW/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”hhFsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/it_IT/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”hhZsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/ja_JP/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”hhnsbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/ko_KR/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”hh‚sbah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ,/translations/sp_SP/devicetree/overlay-notes”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒcomment”“”)”}”(hŒ SPDX-License-Identifier: GPL-2.0”h]”hŒ SPDX-License-Identifier: GPL-2.0”…””}”hh£sbah}”(h]”h ]”h"]”h$]”h&]”Œ xml:space”Œpreserve”uh1h¡hhhžhhŸŒF/var/lib/git/docbuild/linux/Documentation/devicetree/overlay-notes.rst”h KubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒDevicetree Overlay Notes”h]”hŒDevicetree Overlay Notes”…””}”(hh»hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hh¶hžhhŸh³h KubhŒ paragraph”“”)”}”(hŒÖThis document describes the implementation of the in-kernel device tree overlay functionality residing in drivers/of/overlay.c and is a companion document to Documentation/devicetree/dynamic-resolution-notes.rst[1]”h]”hŒÖThis document describes the implementation of the in-kernel device tree overlay functionality residing in drivers/of/overlay.c and is a companion document to Documentation/devicetree/dynamic-resolution-notes.rst[1]”…””}”(hhËhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h Khh¶hžhubhµ)”}”(hhh]”(hº)”}”(hŒHow overlays work”h]”hŒHow overlays work”…””}”(hhÜhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hhÙhžhhŸh³h K ubhÊ)”}”(hXA Devicetree's overlay purpose is to modify the kernel's live tree, and have the modification affecting the state of the kernel in a way that is reflecting the changes. Since the kernel mainly deals with devices, any new device node that result in an active device should have it created while if the device node is either disabled or removed all together, the affected device should be deregistered.”h]”hX”A Devicetree’s overlay purpose is to modify the kernel’s live tree, and have the modification affecting the state of the kernel in a way that is reflecting the changes. Since the kernel mainly deals with devices, any new device node that result in an active device should have it created while if the device node is either disabled or removed all together, the affected device should be deregistered.”…””}”(hhêhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KhhÙhžhubhÊ)”}”(hŒMLets take an example where we have a foo board with the following base tree::”h]”hŒLLets take an example where we have a foo board with the following base tree:”…””}”(hhøhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KhhÙhžhubhŒ literal_block”“”)”}”(hXõ---- foo.dts --------------------------------------------------------------- /* FOO platform */ /dts-v1/; / { compatible = "corp,foo"; /* shared resources */ res: res { }; /* On chip peripherals */ ocp: ocp { /* peripherals that are always instantiated */ peripheral1 { ... }; }; }; ---- foo.dts ---------------------------------------------------------------”h]”hXõ---- foo.dts --------------------------------------------------------------- /* FOO platform */ /dts-v1/; / { compatible = "corp,foo"; /* shared resources */ res: res { }; /* On chip peripherals */ ocp: ocp { /* peripherals that are always instantiated */ peripheral1 { ... }; }; }; ---- foo.dts ---------------------------------------------------------------”…””}”hjsbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jhŸh³h KhhÙhžhubhÊ)”}”(hŒThe overlay bar.dts, ::”h]”hŒThe overlay bar.dts,”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K)hhÙhžhubj)”}”(hXw---- bar.dts - overlay target location by label ---------------------------- /dts-v1/; /plugin/; &ocp { /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ }; }; ---- bar.dts ---------------------------------------------------------------”h]”hXw---- bar.dts - overlay target location by label ---------------------------- /dts-v1/; /plugin/; &ocp { /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ }; }; ---- bar.dts ---------------------------------------------------------------”…””}”hj$sbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jhŸh³h K,hhÙhžhubhÊ)”}”(hŒMwhen loaded (and resolved as described in [1]) should result in foo+bar.dts::”h]”hŒLwhen loaded (and resolved as described in [1]) should result in foo+bar.dts:”…””}”(hj2hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K8hhÙhžhubj)”}”(hXÑ---- foo+bar.dts ----------------------------------------------------------- /* FOO platform + bar peripheral */ / { compatible = "corp,foo"; /* shared resources */ res: res { }; /* On chip peripherals */ ocp: ocp { /* peripherals that are always instantiated */ peripheral1 { ... }; /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ }; }; }; ---- foo+bar.dts -----------------------------------------------------------”h]”hXÑ---- foo+bar.dts ----------------------------------------------------------- /* FOO platform + bar peripheral */ / { compatible = "corp,foo"; /* shared resources */ res: res { }; /* On chip peripherals */ ocp: ocp { /* peripherals that are always instantiated */ peripheral1 { ... }; /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ }; }; }; ---- foo+bar.dts -----------------------------------------------------------”…””}”hj@sbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jhŸh³h K:hhÙhžhubhÊ)”}”(hŒÂAs a result of the overlay, a new device node (bar) has been created so a bar platform device will be registered and if a matching device driver is loaded the device will be created as expected.”h]”hŒÂAs a result of the overlay, a new device node (bar) has been created so a bar platform device will be registered and if a matching device driver is loaded the device will be created as expected.”…””}”(hjNhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KQhhÙhžhubhÊ)”}”(hXxIf the base DT was not compiled with the -@ option then the "&ocp" label will not be available to resolve the overlay node(s) to the proper location in the base DT. In this case, the target path can be provided. The target location by label syntax is preferred because the overlay can be applied to any base DT containing the label, no matter where the label occurs in the DT.”h]”hX|If the base DT was not compiled with the -@ option then the “&ocp†label will not be available to resolve the overlay node(s) to the proper location in the base DT. In this case, the target path can be provided. The target location by label syntax is preferred because the overlay can be applied to any base DT containing the label, no matter where the label occurs in the DT.”…””}”(hj\hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KUhhÙhžhubhÊ)”}”(hŒAThe above bar.dts example modified to use target path syntax is::”h]”hŒ@The above bar.dts example modified to use target path syntax is:”…””}”(hjjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K[hhÙhžhubj)”}”(hXy---- bar.dts - overlay target location by explicit path -------------------- /dts-v1/; /plugin/; &{/ocp} { /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ } }; ---- bar.dts ---------------------------------------------------------------”h]”hXy---- bar.dts - overlay target location by explicit path -------------------- /dts-v1/; /plugin/; &{/ocp} { /* bar peripheral */ bar { compatible = "corp,bar"; ... /* various properties and child nodes */ } }; ---- bar.dts ---------------------------------------------------------------”…””}”hjxsbah}”(h]”h ]”h"]”h$]”h&]”h±h²uh1jhŸh³h K]hhÙhžhubeh}”(h]”Œhow-overlays-work”ah ]”h"]”Œhow overlays work”ah$]”h&]”uh1h´hh¶hžhhŸh³h K ubhµ)”}”(hhh]”(hº)”}”(hŒOverlay in-kernel API”h]”hŒOverlay in-kernel API”…””}”(hj‘hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¹hjŽhžhhŸh³h KkubhÊ)”}”(hŒThe API is quite easy to use.”h]”hŒThe API is quite easy to use.”…””}”(hjŸhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KmhjŽhžhubhŒenumerated_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒ‰Call of_overlay_fdt_apply() to create and apply an overlay changeset. The return value is an error or a cookie identifying this overlay. ”h]”hÊ)”}”(hŒˆCall of_overlay_fdt_apply() to create and apply an overlay changeset. The return value is an error or a cookie identifying this overlay.”h]”hŒˆCall of_overlay_fdt_apply() to create and apply an overlay changeset. The return value is an error or a cookie identifying this overlay.”…””}”(hj¸hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h Kohj´ubah}”(h]”h ]”h"]”h$]”h&]”uh1j²hj¯hžhhŸh³h Nubj³)”}”(hŒÒCall of_overlay_remove() to remove and cleanup the overlay changeset previously created via the call to of_overlay_fdt_apply(). Removal of an overlay changeset that is stacked by another will not be permitted. ”h]”hÊ)”}”(hŒÑCall of_overlay_remove() to remove and cleanup the overlay changeset previously created via the call to of_overlay_fdt_apply(). Removal of an overlay changeset that is stacked by another will not be permitted.”h]”hŒÑCall of_overlay_remove() to remove and cleanup the overlay changeset previously created via the call to of_overlay_fdt_apply(). Removal of an overlay changeset that is stacked by another will not be permitted.”…””}”(hjÐhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KrhjÌubah}”(h]”h ]”h"]”h$]”h&]”uh1j²hj¯hžhhŸh³h Nubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ)”uh1j­hjŽhžhhŸh³h KoubhÊ)”}”(hŒ‘Finally, if you need to remove all overlays in one-go, just call of_overlay_remove_all() which will remove every single one in the correct order.”h]”hŒ‘Finally, if you need to remove all overlays in one-go, just call of_overlay_remove_all() which will remove every single one in the correct order.”…””}”(hjïhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KvhjŽhžhubhÊ)”}”(hŒ«There is the option to register notifiers that get called on overlay operations. See of_overlay_notifier_register/unregister and enum of_overlay_notify_action for details.”h]”hŒ«There is the option to register notifiers that get called on overlay operations. See of_overlay_notifier_register/unregister and enum of_overlay_notify_action for details.”…””}”(hjýhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KzhjŽhžhubhÊ)”}”(hXÑA notifier callback for OF_OVERLAY_PRE_APPLY, OF_OVERLAY_POST_APPLY, or OF_OVERLAY_PRE_REMOVE may store pointers to a device tree node in the overlay or its content but these pointers must not persist past the notifier callback for OF_OVERLAY_POST_REMOVE. The memory containing the overlay will be kfree()ed after OF_OVERLAY_POST_REMOVE notifiers are called. Note that the memory will be kfree()ed even if the notifier for OF_OVERLAY_POST_REMOVE returns an error.”h]”hXÑA notifier callback for OF_OVERLAY_PRE_APPLY, OF_OVERLAY_POST_APPLY, or OF_OVERLAY_PRE_REMOVE may store pointers to a device tree node in the overlay or its content but these pointers must not persist past the notifier callback for OF_OVERLAY_POST_REMOVE. The memory containing the overlay will be kfree()ed after OF_OVERLAY_POST_REMOVE notifiers are called. Note that the memory will be kfree()ed even if the notifier for OF_OVERLAY_POST_REMOVE returns an error.”…””}”(hj hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K~hjŽhžhubhÊ)”}”(hXThe changeset notifiers in drivers/of/dynamic.c are a second type of notifier that could be triggered by applying or removing an overlay. These notifiers are not allowed to store pointers to a device tree node in the overlay or its content. The overlay code does not protect against such pointers remaining active when the memory containing the overlay is freed as a result of removing the overlay.”h]”hXThe changeset notifiers in drivers/of/dynamic.c are a second type of notifier that could be triggered by applying or removing an overlay. These notifiers are not allowed to store pointers to a device tree node in the overlay or its content. The overlay code does not protect against such pointers remaining active when the memory containing the overlay is freed as a result of removing the overlay.”…””}”(hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K†hjŽhžhubhÊ)”}”(hŒ§Any other code that retains a pointer to the overlay nodes or data is considered to be a bug because after removing the overlay the pointer will refer to freed memory.”h]”hŒ§Any other code that retains a pointer to the overlay nodes or data is considered to be a bug because after removing the overlay the pointer will refer to freed memory.”…””}”(hj'hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h KhjŽhžhubhÊ)”}”(hX¬Users of overlays must be especially aware of the overall operations that occur on the system to ensure that other kernel code does not retain any pointers to the overlay nodes or data. Any example of an inadvertent use of such pointers is if a driver or subsystem module is loaded after an overlay has been applied, and the driver or subsystem scans the entire devicetree or a large portion of it, including the overlay nodes.”h]”hX¬Users of overlays must be especially aware of the overall operations that occur on the system to ensure that other kernel code does not retain any pointers to the overlay nodes or data. Any example of an inadvertent use of such pointers is if a driver or subsystem module is loaded after an overlay has been applied, and the driver or subsystem scans the entire devicetree or a large portion of it, including the overlay nodes.”…””}”(hj5hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhŸh³h K‘hjŽhžhubeh}”(h]”Œoverlay-in-kernel-api”ah ]”h"]”Œoverlay in-kernel api”ah$]”h&]”uh1h´hh¶hžhhŸh³h Kkubeh}”(h]”Œdevicetree-overlay-notes”ah ]”h"]”Œdevicetree overlay notes”ah$]”h&]”uh1h´hhhžhhŸh³h Kubeh}”(h]”h ]”h"]”h$]”h&]”Œsource”h³uh1hŒcurrent_source”NŒ current_line”NŒsettings”Œdocutils.frontend”ŒValues”“”)”}”(h¹NŒ generator”NŒ datestamp”NŒ source_link”NŒ source_url”NŒ toc_backlinks”Œentry”Œfootnote_backlinks”KŒ sectnum_xform”KŒstrip_comments”NŒstrip_elements_with_classes”NŒ strip_classes”NŒ report_level”KŒ halt_level”KŒexit_status_level”KŒdebug”NŒwarning_stream”NŒ traceback”ˆŒinput_encoding”Œ utf-8-sig”Œinput_encoding_error_handler”Œstrict”Œoutput_encoding”Œutf-8”Œoutput_encoding_error_handler”jvŒerror_encoding”Œutf-8”Œerror_encoding_error_handler”Œbackslashreplace”Œ language_code”Œen”Œrecord_dependencies”NŒconfig”NŒ id_prefix”hŒauto_id_prefix”Œid”Œ dump_settings”NŒdump_internals”NŒdump_transforms”NŒdump_pseudo_xml”NŒexpose_internals”NŒstrict_visitor”NŒ_disable_config”NŒ_source”h³Œ _destination”NŒ _config_files”]”Œ7/var/lib/git/docbuild/linux/Documentation/docutils.conf”aŒfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œpep_references”NŒ pep_base_url”Œhttps://peps.python.org/”Œpep_file_url_template”Œpep-%04d”Œrfc_references”NŒ rfc_base_url”Œ&https://datatracker.ietf.org/doc/html/”Œ tab_width”KŒtrim_footnote_reference_space”‰Œsyntax_highlight”Œlong”Œ smart_quotes”ˆŒsmartquotes_locales”]”Œcharacter_level_inline_markup”‰Œdoctitle_xform”‰Œ docinfo_xform”KŒsectsubtitle_xform”‰Œ image_loading”Œlink”Œembed_stylesheet”‰Œcloak_email_addresses”ˆŒsection_self_link”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(jPjMj‹jˆjHjEuŒ nametypes”}”(jP‰j‹‰jH‰uh}”(jMh¶jˆhÙjEjŽuŒ footnote_refs”}”Œ citation_refs”}”Œ autofootnotes”]”Œautofootnote_refs”]”Œsymbol_footnotes”]”Œsymbol_footnote_refs”]”Œ footnotes”]”Œ citations”]”Œautofootnote_start”KŒsymbol_footnote_start”KŒ id_counter”Œ collections”ŒCounter”“”}”…”R”Œparse_messages”]”hŒsystem_message”“”)”}”(hhh]”hÊ)”}”(hŒfPossible title underline, too short for the title. Treating it as ordinary text because it's so short.”h]”hŒhPossible title underline, too short for the title. Treating it as ordinary text because it’s so short.”…””}”(hjÝhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÉhjÚubah}”(h]”h ]”h"]”h$]”h&]”Œlevel”KŒtype”ŒINFO”Œline”K*Œsource”h³uh1jØhhÙhžhhŸh³h K*ubaŒtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nhžhub.