← Documents Documentation/iio/iio_dmabuf_api.rst GitHub 원문 ↗

Linux 6.18.37 · IIO

High-speed DMABUF interface for IIO

IIO DMA-BUF의 zero-copy 공유, mmap 동기화와 attach·detach·enqueue IOCTL을 설명합니다.

Source pathDocumentation/iio/iio_dmabuf_api.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

iio_dmabuf_api.rst:1-54

IIO DMA-BUF 인터페이스는 외부 버퍼를 IIO에 연결해 여러 하위 시스템과 zero-copy로 공유합니다. 고속 전송에 유리하지만 mmap 접근에서는 동기화 IOCTL이 필요하며, attach·enqueue·detach 순서와 buffer 방향별 데이터 이동을 지켜야 합니다.

문서 개요
항목내용
SourceDocumentation/iio/iio_dmabuf_api.rst
분량54 source lines
APIAttach, detach, enqueue
동기화DMA_BUF_SYNC_START/END

원문 분량과 핵심 대상을 요약합니다.

핵심 흐름
Buffer fd 획득DMA-BUF attachQueue에 enqueueZero-copy transfer와 syncDetach 또는 fd close

사용 순서를 압축합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2
3 ===================================
4 High-speed DMABUF interface for IIO
5 ===================================
6
7 1. Overview
8 ===========
9
10 The Industrial I/O subsystem supports access to buffers through a
11 file-based interface, with read() and write() access calls through the
12 IIO device's dev node.
13
14 It additionally supports a DMABUF based interface, where the userspace
15 can attach DMABUF objects (externally created) to an IIO buffer, and
16 subsequently use them for data transfers.
17
18 A userspace application can then use this interface to share DMABUF
19 objects between several interfaces, allowing it to transfer data in a
20 zero-copy fashion, for instance between IIO and the USB stack.
21
22 The userspace application can also memory-map the DMABUF objects, and
23 access the sample data directly. The advantage of doing this vs. the
24 read() interface is that it avoids an extra copy of the data between the
25 kernel and userspace. This is particularly useful for high-speed devices
26 which produce several megabytes or even gigabytes of data per second.
27 It does however increase the userspace-kernelspace synchronization
28 overhead, as the DMA_BUF_SYNC_START and DMA_BUF_SYNC_END IOCTLs have to
29 be used for data integrity.
30
31 2. User API
32 ===========
33
34 As part of this interface, three new IOCTLs have been added. These three
35 IOCTLs have to be performed on the IIO buffer's file descriptor, which
36 can be obtained using the IIO_BUFFER_GET_FD_IOCTL() ioctl.
37
38 ``IIO_BUFFER_DMABUF_ATTACH_IOCTL(int fd)``
39 Attach the DMABUF object, identified by its file descriptor, to the
40 IIO buffer. Returns zero on success, and a negative errno value on
41 error.
42
43 ``IIO_BUFFER_DMABUF_DETACH_IOCTL(int fd)``
44 Detach the given DMABUF object, identified by its file descriptor,
45 from the IIO buffer. Returns zero on success, and a negative errno
46 value on error.
47
48 Note that closing the IIO buffer's file descriptor will
49 automatically detach all previously attached DMABUF objects.
50
51 ``IIO_BUFFER_DMABUF_ENQUEUE_IOCTL(struct iio_dmabuf *iio_dmabuf)``
52 Enqueue a previously attached DMABUF object to the buffer queue.
53 Enqueued DMABUFs will be read from (if output buffer) or written to
54 (if input buffer) as long as the buffer is enabled.
55

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

고속 IIO DMA-BUF 인터페이스

1-30

이 문서는 GPL-2.0 라이선스가 적용되는 IIO 고속 DMA-BUF 인터페이스 설명서입니다.

Industrial I/O 하위 시스템은 IIO 장치의 dev node에서 `read()`와 `write()`를 호출하는 파일 기반 인터페이스로 버퍼에 접근할 수 있습니다.

또한 사용자 공간이 외부에서 만든 DMA-BUF 객체를 IIO 버퍼에 연결하고 이후 데이터 전송에 사용하는 DMA-BUF 기반 인터페이스도 지원합니다.

응용 프로그램은 여러 인터페이스 사이에서 DMA-BUF 객체를 공유할 수 있습니다. 예를 들어 IIO와 USB stack 사이에서 데이터를 zero-copy 방식으로 전송할 수 있습니다.

사용자 공간은 DMA-BUF 객체를 memory-map하고 샘플 데이터에 직접 접근할 수도 있습니다. `read()` 인터페이스와 비교하면 kernel과 userspace 사이의 추가 데이터 복사를 피할 수 있다는 장점이 있습니다.

이 방식은 초당 수 megabytes에서 수 gigabytes의 데이터를 만드는 고속 장치에 특히 유용합니다.

반면 데이터 무결성을 위해 `DMA_BUF_SYNC_START`와 `DMA_BUF_SYNC_END` IOCTL을 사용해야 하므로 userspace와 kernelspace 사이의 동기화 overhead가 증가합니다.

IIO 버퍼 접근 방식 비교
항목File interfaceDMA-BUF interface
접근`read()` / `write()`Attach·enqueue, memory-map
복사Kernel-userspace 추가 복사Zero-copy 가능
공유IIO dev node 중심IIO·USB 등 여러 interface 공유
고속 데이터복사 비용 증가MB/s~GB/s 장치에 유리
동기화일반 file semantics`DMA_BUF_SYNC_START/END` 필요

파일 기반 read/write와 DMA-BUF 경로의 장단점을 비교합니다.

DMA-BUF zero-copy 경로
외부 interface에서 DMA-BUF object 생성DMA-BUF를 IIO buffer에 attachAttached object를 buffer queue에 enqueueIIO와 USB stack 등이 같은 buffer 공유사용자 공간은 mmap과 sync IOCTL로 직접 접근

외부 버퍼 생성부터 여러 하위 시스템의 공유 전송까지의 흐름입니다.

.. SPDX-License-Identifier: GPL-2.0

===================================
High-speed DMABUF interface for IIO
===================================

1. Overview
===========

The Industrial I/O subsystem supports access to buffers through a
file-based interface, with read() and write() access calls through the
IIO device's dev node.

It additionally supports a DMABUF based interface, where the userspace
can attach DMABUF objects (externally created) to an IIO buffer, and
subsequently use them for data transfers.

A userspace application can then use this interface to share DMABUF
objects between several interfaces, allowing it to transfer data in a
zero-copy fashion, for instance between IIO and the USB stack.

The userspace application can also memory-map the DMABUF objects, and
access the sample data directly. The advantage of doing this vs. the
read() interface is that it avoids an extra copy of the data between the
kernel and userspace. This is particularly useful for high-speed devices
which produce several megabytes or even gigabytes of data per second.
It does however increase the userspace-kernelspace synchronization
overhead, as the DMA_BUF_SYNC_START and DMA_BUF_SYNC_END IOCTLs have to
be used for data integrity.

DMA-BUF 사용자 API와 세 IOCTL

31-54

이 인터페이스에는 세 개의 새 IOCTL이 추가되었습니다. 모두 IIO buffer file descriptor에 대해 실행해야 하며, 이 descriptor는 `IIO_BUFFER_GET_FD_IOCTL()` ioctl로 얻을 수 있습니다.

IIO DMA-BUF IOCTL
IOCTL인자동작·반환
`IIO_BUFFER_DMABUF_ATTACH_IOCTL(int fd)`DMA-BUF file descriptor객체를 IIO buffer에 연결, 성공 0·오류 negative errno
`IIO_BUFFER_DMABUF_DETACH_IOCTL(int fd)`DMA-BUF file descriptor객체를 IIO buffer에서 분리, 성공 0·오류 negative errno
`IIO_BUFFER_DMABUF_ENQUEUE_IOCTL(struct iio_dmabuf *iio_dmabuf)`이전에 attach한 객체Buffer queue에 삽입

세 사용자 API의 인자, 동작, 반환 규칙을 정리했습니다.

`IIO_BUFFER_DMABUF_ATTACH_IOCTL(int fd)`는 file descriptor로 식별한 DMA-BUF 객체를 IIO 버퍼에 연결합니다. 성공하면 0, 오류이면 음수 errno 값을 반환합니다.

`IIO_BUFFER_DMABUF_DETACH_IOCTL(int fd)`는 file descriptor로 식별한 DMA-BUF 객체를 IIO 버퍼에서 분리합니다. 성공하면 0, 오류이면 음수 errno 값을 반환합니다.

IIO buffer의 file descriptor를 닫으면 이전에 연결한 모든 DMA-BUF 객체가 자동으로 분리됩니다.

`IIO_BUFFER_DMABUF_ENQUEUE_IOCTL(struct iio_dmabuf *iio_dmabuf)`는 이전에 연결한 DMA-BUF 객체를 buffer queue에 넣습니다. 버퍼가 활성화되어 있는 동안 output buffer이면 enqueue한 DMA-BUF에서 읽고, input buffer이면 DMA-BUF에 씁니다.

Enqueue 뒤 데이터 방향
IIO bufferDMA-BUF 동작
Output bufferEnqueued DMA-BUF에서 읽음
Input bufferEnqueued DMA-BUF에 씀

IIO 버퍼 방향에 따른 DMA-BUF 접근을 원문 그대로 구분합니다.

DMA-BUF 객체 수명 주기
`IIO_BUFFER_GET_FD_IOCTL()`로 buffer fd 획득DMA-BUF fd를 attachAttached object를 enqueueBuffer enable 동안 데이터 전송명시적 detach 또는 buffer fd close로 자동 detach

IIO buffer file descriptor를 중심으로 한 API 순서입니다.

2. User API
===========

As part of this interface, three new IOCTLs have been added. These three
IOCTLs have to be performed on the IIO buffer's file descriptor, which
can be obtained using the IIO_BUFFER_GET_FD_IOCTL() ioctl.

  ``IIO_BUFFER_DMABUF_ATTACH_IOCTL(int fd)``
    Attach the DMABUF object, identified by its file descriptor, to the
    IIO buffer. Returns zero on success, and a negative errno value on
    error.

  ``IIO_BUFFER_DMABUF_DETACH_IOCTL(int fd)``
    Detach the given DMABUF object, identified by its file descriptor,
    from the IIO buffer. Returns zero on success, and a negative errno
    value on error.

    Note that closing the IIO buffer's file descriptor will
    automatically detach all previously attached DMABUF objects.

  ``IIO_BUFFER_DMABUF_ENQUEUE_IOCTL(struct iio_dmabuf *iio_dmabuf)``
    Enqueue a previously attached DMABUF object to the buffer queue.
    Enqueued DMABUFs will be read from (if output buffer) or written to
    (if input buffer) as long as the buffer is enabled.