€•Ñ6Œsphinx.addnodes”Œdocument”“”)”}”(Œ rawsource”Œ”Œchildren”]”(Œ translations”Œ LanguagesNode”“”)”}”(hhh]”(hŒ pending_xref”“”)”}”(hhh]”Œdocutils.nodes”ŒText”“”ŒChinese (Simplified)”…””}”(hhŒparent”hubaŒ attributes”}”(Œids”]”Œclasses”]”Œnames”]”Œdupnames”]”Œbackrefs”]”Œ refdomain”Œstd”Œreftype”Œdoc”Œ reftarget”Œ(/translations/zh_CN/driver-api/sync_file”Œmodname”NŒ classname”NŒ refexplicit”ˆuŒtagname”hhh ubh)”}”(hhh]”hŒChinese (Traditional)”…””}”(hhhh2ubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/zh_TW/driver-api/sync_file”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒItalian”…””}”(hhhhFubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/it_IT/driver-api/sync_file”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒJapanese”…””}”(hhhhZubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/ja_JP/driver-api/sync_file”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒKorean”…””}”(hhhhnubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/ko_KR/driver-api/sync_file”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubh)”}”(hhh]”hŒSpanish”…””}”(hhhh‚ubah}”(h]”h ]”h"]”h$]”h&]”Œ refdomain”h)Œreftype”h+Œ reftarget”Œ(/translations/sp_SP/driver-api/sync_file”Œmodname”NŒ classname”NŒ refexplicit”ˆuh1hhh ubeh}”(h]”h ]”h"]”h$]”h&]”Œcurrent_language”ŒEnglish”uh1h hhŒ _document”hŒsource”NŒline”NubhŒsection”“”)”}”(hhh]”(hŒtitle”“”)”}”(hŒSync File API Guide”h]”hŒSync File API Guide”…””}”(hhªhh¨hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hh£hžhhŸŒB/var/lib/git/docbuild/linux/Documentation/driver-api/sync_file.rst”h KubhŒ field_list”“”)”}”(hhh]”hŒfield”“”)”}”(hhh]”(hŒ field_name”“”)”}”(hŒAuthor”h]”hŒAuthor”…””}”(hhÅhhÃhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1hÁhh¾hŸh¶h KubhŒ field_body”“”)”}”(hŒ-Gustavo Padovan ”h]”hŒ paragraph”“”)”}”(hŒ,Gustavo Padovan ”h]”hŒ,Gustavo Padovan ”…””}”(hhÛhhÙhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h KhhÓubah}”(h]”h ]”h"]”h$]”h&]”uh1hÑhh¾ubeh}”(h]”h ]”h"]”h$]”h&]”uh1h¼hŸh¶h Khh¹hžhubah}”(h]”h ]”h"]”h$]”h&]”uh1h·hh£hžhhŸh¶h KubhØ)”}”(hŒþThis document serves as a guide for device drivers writers on what the sync_file API is, and how drivers can support it. Sync file is the carrier of the fences(struct dma_fence) that are needed to synchronize between drivers or across process boundaries.”h]”hŒþThis document serves as a guide for device drivers writers on what the sync_file API is, and how drivers can support it. Sync file is the carrier of the fences(struct dma_fence) that are needed to synchronize between drivers or across process boundaries.”…””}”(hhûhhùhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h Khh£hžhubhØ)”}”(hX0The sync_file API is meant to be used to send and receive fence information to/from userspace. It enables userspace to do explicit fencing, where instead of attaching a fence to the buffer a producer driver (such as a GPU or V4L driver) sends the fence related to the buffer to userspace via a sync_file.”h]”hX0The sync_file API is meant to be used to send and receive fence information to/from userspace. It enables userspace to do explicit fencing, where instead of attaching a fence to the buffer a producer driver (such as a GPU or V4L driver) sends the fence related to the buffer to userspace via a sync_file.”…””}”(hj hjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h K hh£hžhubhØ)”}”(hXPThe sync_file then can be sent to the consumer (DRM driver for example), that will not use the buffer for anything before the fence(s) signals, i.e., the driver that issued the fence is not using/processing the buffer anymore, so it signals that the buffer is ready to use. And vice-versa for the consumer -> producer part of the cycle.”h]”hXPThe sync_file then can be sent to the consumer (DRM driver for example), that will not use the buffer for anything before the fence(s) signals, i.e., the driver that issued the fence is not using/processing the buffer anymore, so it signals that the buffer is ready to use. And vice-versa for the consumer -> producer part of the cycle.”…””}”(hjhjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h Khh£hžhubhØ)”}”(hŒXSync files allows userspace awareness on buffer sharing synchronization between drivers.”h]”hŒXSync files allows userspace awareness on buffer sharing synchronization between drivers.”…””}”(hj%hj#hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h Khh£hžhubhØ)”}”(hŒiSync file was originally added in the Android kernel but current Linux Desktop can benefit a lot from it.”h]”hŒiSync file was originally added in the Android kernel but current Linux Desktop can benefit a lot from it.”…””}”(hj3hj1hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h Khh£hžhubh¢)”}”(hhh]”(h§)”}”(hŒin-fences and out-fences”h]”hŒin-fences and out-fences”…””}”(hjDhjBhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hj?hžhhŸh¶h KubhØ)”}”(hX Sync files can go either to or from userspace. When a sync_file is sent from the driver to userspace we call the fences it contains 'out-fences'. They are related to a buffer that the driver is processing or is going to process, so the driver creates an out-fence to be able to notify, through dma_fence_signal(), when it has finished using (or processing) that buffer. Out-fences are fences that the driver creates.”h]”hX¤Sync files can go either to or from userspace. When a sync_file is sent from the driver to userspace we call the fences it contains ‘out-fences’. They are related to a buffer that the driver is processing or is going to process, so the driver creates an out-fence to be able to notify, through dma_fence_signal(), when it has finished using (or processing) that buffer. Out-fences are fences that the driver creates.”…””}”(hjRhjPhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h K hj?hžhubhØ)”}”(hŒôOn the other hand if the driver receives fence(s) through a sync_file from userspace we call these fence(s) 'in-fences'. Receiving in-fences means that we need to wait for the fence(s) to signal before using any buffer related to the in-fences.”h]”hŒøOn the other hand if the driver receives fence(s) through a sync_file from userspace we call these fence(s) ‘in-fences’. Receiving in-fences means that we need to wait for the fence(s) to signal before using any buffer related to the in-fences.”…””}”(hj`hj^hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h K'hj?hžhubeh}”(h]”Œin-fences-and-out-fences”ah ]”h"]”Œin-fences and out-fences”ah$]”h&]”uh1h¡hh£hžhhŸh¶h Kubh¢)”}”(hhh]”(h§)”}”(hŒCreating Sync Files”h]”hŒCreating Sync Files”…””}”(hjyhjwhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjthžhhŸh¶h K-ubhØ)”}”(hŒJWhen a driver needs to send an out-fence userspace it creates a sync_file.”h]”hŒJWhen a driver needs to send an out-fence userspace it creates a sync_file.”…””}”(hj‡hj…hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h K/hjthžhubhØ)”}”(hŒ Interface::”h]”hŒ Interface:”…””}”(hŒ Interface:”hj“hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h K1hjthžhubhŒ literal_block”“”)”}”(hŒfile. So it gets an fd::”h]”hŒœThe caller pass the out-fence and gets back the sync_file. That is just the first step, next it needs to install an fd on sync_file->file. So it gets an fd:”…””}”(hŒœThe caller pass the out-fence and gets back the sync_file. That is just the first step, next it needs to install an fd on sync_file->file. So it gets an fd:”hj´hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h K5hjthžhubj£)”}”(hŒ$fd = get_unused_fd_flags(O_CLOEXEC);”h]”hŒ$fd = get_unused_fd_flags(O_CLOEXEC);”…””}”(hhhjÃubah}”(h]”h ]”h"]”h$]”h&]”j²j³uh1j¢hŸh¶h K9hjthžhubhØ)”}”(hŒ$and installs it on sync_file->file::”h]”hŒ#and installs it on sync_file->file:”…””}”(hŒ#and installs it on sync_file->file:”hjÑhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h K;hjthžhubj£)”}”(hŒ fd_install(fd, sync_file->file);”h]”hŒ fd_install(fd, sync_file->file);”…””}”(hhhjàubah}”(h]”h ]”h"]”h$]”h&]”j²j³uh1j¢hŸh¶h K=hjthžhubhØ)”}”(hŒ.The sync_file fd now can be sent to userspace.”h]”hŒ.The sync_file fd now can be sent to userspace.”…””}”(hjðhjîhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h K?hjthžhubhØ)”}”(hŒ}If the creation process fail, or the sync_file needs to be released by any other reason fput(sync_file->file) should be used.”h]”hŒ}If the creation process fail, or the sync_file needs to be released by any other reason fput(sync_file->file) should be used.”…””}”(hjþhjühžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h KAhjthžhubeh}”(h]”Œcreating-sync-files”ah ]”h"]”Œcreating sync files”ah$]”h&]”uh1h¡hh£hžhhŸh¶h K-ubh¢)”}”(hhh]”(h§)”}”(hŒ#Receiving Sync Files from Userspace”h]”hŒ#Receiving Sync Files from Userspace”…””}”(hjhjhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h¦hjhžhhŸh¶h KEubhØ)”}”(hŒ¡When userspace needs to send an in-fence to the driver it passes file descriptor of the Sync File to the kernel. The kernel can then retrieve the fences from it.”h]”hŒ¡When userspace needs to send an in-fence to the driver it passes file descriptor of the Sync File to the kernel. The kernel can then retrieve the fences from it.”…””}”(hj%hj#hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h KGhjhžhubhØ)”}”(hŒ Interface::”h]”hŒ Interface:”…””}”(hŒ Interface:”hj1hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h KKhjhžhubj£)”}”(hŒ.struct dma_fence *sync_file_get_fence(int fd);”h]”hŒ.struct dma_fence *sync_file_get_fence(int fd);”…””}”(hhhj@ubah}”(h]”h ]”h"]”h$]”h&]”j²j³uh1j¢hŸh¶h KMhjhžhubhØ)”}”(hŒ•The returned reference is owned by the caller and must be disposed of afterwards using dma_fence_put(). In case of error, a NULL is returned instead.”h]”hŒ•The returned reference is owned by the caller and must be disposed of afterwards using dma_fence_put(). In case of error, a NULL is returned instead.”…””}”(hjPhjNhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h KPhjhžhubhØ)”}”(hŒ References:”h]”hŒ References:”…””}”(hj^hj\hžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h KShjhžhubhŒenumerated_list”“”)”}”(hhh]”(hŒ list_item”“”)”}”(hŒ-struct sync_file in include/linux/sync_file.h”h]”hØ)”}”(hjsh]”hŒ-struct sync_file in include/linux/sync_file.h”…””}”(hjshjuhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h KUhjqubah}”(h]”h ]”h"]”h$]”h&]”uh1johjlhžhhŸh¶h Nubjp)”}”(hŒCAll interfaces mentioned above defined in include/linux/sync_file.h”h]”hØ)”}”(hjŠh]”hŒCAll interfaces mentioned above defined in include/linux/sync_file.h”…””}”(hjŠhjŒhžhhŸNh Nubah}”(h]”h ]”h"]”h$]”h&]”uh1h×hŸh¶h KVhjˆubah}”(h]”h ]”h"]”h$]”h&]”uh1johjlhžhhŸh¶h Nubeh}”(h]”h ]”h"]”h$]”h&]”Œenumtype”Œarabic”Œprefix”hŒsuffix”Œ.”uh1jjhjhžhhŸh¶h KUubeh}”(h]”Œ#receiving-sync-files-from-userspace”ah ]”h"]”Œ#receiving sync files from userspace”ah$]”h&]”uh1h¡hh£hžhhŸh¶h KEubeh}”(h]”Œsync-file-api-guide”ah ]”h"]”Œsync file api guide”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”jÝŒ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Œ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”‰Œfile_insertion_enabled”ˆŒ raw_enabled”KŒline_length_limit”M'Œ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”‰Œ embed_images”‰Œenv”NubŒreporter”NŒindirect_targets”]”Œsubstitution_defs”}”Œsubstitution_names”}”Œrefnames”}”Œrefids”}”Œnameids”}”(j·j´jqjnjj j¯j¬uŒ nametypes”}”(j·NjqNjNj¯Nuh}”(j´h£jnj?j jtj¬juŒ 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”]”Œtransform_messages”]”Œ transformer”NŒ include_log”]”Œ decoration”Nhžhub.