Documentation/driver-api/usb/anchors.rst GitHub 원문 ↗

Linux 6.18.37 · Driver API

USB Anchors

USB anchor로 여러 URB를 추적하고 연결·해제·kill·대기·조회하는 API를 설명하는 한국어 전문 번역입니다.

Source pathDocumentation/driver-api/usb/anchors.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

anchors.rst:1-72

USB anchor는 driver가 제출한 여러 URB를 하나의 수명주기로 묶어 callback 중단 시 안전하게 완료·kill·회수할 수 있게 합니다.

문서 구성
원문 줄핵심 내용
1-13anchor의 목적
14-26수명주기
27-37URB 연결·해제
38-58일괄 operation
59-72상태 조회와 URB 회수

2. 영어 원문 전체

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

원문 전체 펼치기
1 USB Anchors
2 ~~~~~~~~~~~
3
4 What is anchor?
5 ===============
6
7 A USB driver needs to support some callbacks requiring
8 a driver to cease all IO to an interface. To do so, a
9 driver has to keep track of the URBs it has submitted
10 to know they've all completed or to call usb_kill_urb
11 for them. The anchor is a data structure takes care of
12 keeping track of URBs and provides methods to deal with
13 multiple URBs.
14
15 Allocation and Initialisation
16 =============================
17
18 There's no API to allocate an anchor. It is simply declared
19 as struct usb_anchor. :c:func:`init_usb_anchor` must be called to
20 initialise the data structure.
21
22 Deallocation
23 ============
24
25 Once it has no more URBs associated with it, the anchor can be
26 freed with normal memory management operations.
27
28 Association and disassociation of URBs with anchors
29 ===================================================
30
31 An association of URBs to an anchor is made by an explicit
32 call to :c:func:`usb_anchor_urb`. The association is maintained until
33 an URB is finished by (successful) completion. Thus disassociation
34 is automatic. A function is provided to forcibly finish (kill)
35 all URBs associated with an anchor.
36 Furthermore, disassociation can be made with :c:func:`usb_unanchor_urb`
37
38 Operations on multitudes of URBs
39 ================================
40
41 :c:func:`usb_kill_anchored_urbs`
42 --------------------------------
43
44 This function kills all URBs associated with an anchor. The URBs
45 are called in the reverse temporal order they were submitted.
46 This way no data can be reordered.
47
48 :c:func:`usb_scuttle_anchored_urbs`
49 -----------------------------------
50
51 All URBs of an anchor are unanchored en masse.
52
53 :c:func:`usb_wait_anchor_empty_timeout`
54 ---------------------------------------
55
56 This function waits for all URBs associated with an anchor to finish
57 or a timeout, whichever comes first. Its return value will tell you
58 whether the timeout was reached.
59
60 :c:func:`usb_anchor_empty`
61 --------------------------
62
63 Returns true if no URBs are associated with an anchor. Locking
64 is the caller's responsibility.
65
66 :c:func:`usb_get_from_anchor`
67 -----------------------------
68
69 Returns the oldest anchored URB of an anchor. The URB is unanchored
70 and returned with a reference. As you may mix URBs to several
71 destinations in one anchor you have no guarantee the chronologically
72 first submitted URB is returned.
73

3. 한국어 전문 번역

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

USB anchor의 역할

1-13

USB driver의 일부 callback은 interface에 대한 모든 I/O를 중단해야 합니다. Driver는 제출한 URB를 추적해 모두 완료됐는지 확인하거나 각 URB에 `usb_kill_urb`를 호출할 수 있어야 합니다.

Anchor는 URB 추적을 담당하고 여러 URB를 함께 처리하는 method를 제공하는 data structure입니다.

Anchor 기반 I/O 중단
URB 제출anchor에 연결
정상 completion자동 연결 해제
I/O 중단 callback남은 URB 확인·kill

여러 URB를 추적해 interface I/O가 완전히 멈췄는지 확인합니다.

USB Anchors
~~~~~~~~~~~

What is anchor?
===============

A USB driver needs to support some callbacks requiring
a driver to cease all IO to an interface. To do so, a
driver has to keep track of the URBs it has submitted
to know they've all completed or to call usb_kill_urb
for them. The anchor is a data structure takes care of
keeping track of URBs and provides methods to deal with
multiple URBs.

할당·초기화와 해제

14-26

Anchor 전용 allocation API는 없습니다. `struct usb_anchor`를 직접 선언하고 `init_usb_anchor()`를 호출해 data structure를 초기화합니다.

더 이상 연결된 URB가 없으면 일반 memory management operation으로 anchor를 해제할 수 있습니다.

Anchor 수명주기
단계방법
선언`struct usb_anchor`
초기화`init_usb_anchor()`
해제 조건연결된 URB가 없음
해제일반 memory management


Allocation and Initialisation
=============================

There's no API to allocate an anchor. It is simply declared
as struct usb_anchor. :c:func:`init_usb_anchor` must be called to
initialise the data structure.

Deallocation
============

Once it has no more URBs associated with it, the anchor can be
freed with normal memory management operations.

URB 연결과 연결 해제

27-37

URB는 `usb_anchor_urb()`를 명시적으로 호출해 anchor에 연결합니다. 성공적인 completion으로 URB가 끝날 때까지 연결이 유지되며 completion 시 자동으로 해제됩니다.

Anchor에 연결된 모든 URB를 강제로 끝내는 함수가 제공됩니다. 개별 URB는 `usb_unanchor_urb()`로 직접 연결 해제할 수도 있습니다.

URB association
`usb_anchor_urb()`anchor에 URB 연결
성공 completion자동 disassociation
`usb_unanchor_urb()`개별 수동 해제
일괄 kill연결된 URB 강제 종료

명시적 연결 뒤 정상 completion 또는 강제·수동 경로로 해제됩니다.


Association and disassociation of URBs with anchors
===================================================

An association of URBs to an anchor is made by an explicit
call to :c:func:`usb_anchor_urb`. The association is maintained until
an URB is finished by (successful) completion. Thus disassociation
is automatic. A function is provided to forcibly finish (kill)
all URBs associated with an anchor.
Furthermore, disassociation can be made with :c:func:`usb_unanchor_urb`

여러 URB에 대한 일괄 operation

38-58

`usb_kill_anchored_urbs()`는 anchor에 연결된 모든 URB를 kill합니다. URB는 제출한 시간의 역순으로 처리되므로 data 순서가 뒤바뀌지 않습니다.

`usb_scuttle_anchored_urbs()`는 anchor의 모든 URB를 한꺼번에 unanchor합니다.

`usb_wait_anchor_empty_timeout()`은 연결된 모든 URB가 끝나거나 timeout에 도달할 때까지 기다리며 반환값으로 timeout 도달 여부를 알립니다.

Anchor 일괄 operation
함수동작
`usb_kill_anchored_urbs()`역제출 순서로 모든 URB kill
`usb_scuttle_anchored_urbs()`모든 URB 일괄 unanchor
`usb_wait_anchor_empty_timeout()`empty 또는 timeout까지 대기

Operations on multitudes of URBs
================================

:c:func:`usb_kill_anchored_urbs`
--------------------------------

This function kills all URBs associated with an anchor. The URBs
are called in the reverse temporal order they were submitted.
This way no data can be reordered.

:c:func:`usb_scuttle_anchored_urbs`
-----------------------------------

All URBs of an anchor are unanchored en masse.

:c:func:`usb_wait_anchor_empty_timeout`
---------------------------------------

This function waits for all URBs associated with an anchor to finish
or a timeout, whichever comes first. Its return value will tell you
whether the timeout was reached.

Anchor 상태 조회와 오래된 URB 회수

59-72

`usb_anchor_empty()`는 anchor에 연결된 URB가 없으면 true를 반환합니다. Locking은 caller가 책임집니다.

`usb_get_from_anchor()`는 anchor에서 가장 오래된 anchored URB를 unanchor하고 reference를 보유한 상태로 반환합니다. 하나의 anchor에 여러 destination용 URB를 섞을 수 있으므로 시간상 가장 먼저 제출된 URB가 반드시 반환된다는 보장은 없습니다.

Anchor query
함수반환·책임
`usb_anchor_empty()`연결 URB 없음 여부, locking은 caller 책임
`usb_get_from_anchor()`가장 오래된 anchored URB와 reference, 전체 제출 순서 보장 없음


:c:func:`usb_anchor_empty`
--------------------------

Returns true if no URBs are associated with an anchor. Locking
is the caller's responsibility.

:c:func:`usb_get_from_anchor`
-----------------------------

Returns the oldest anchored URB of an anchor. The URB is unanchored
and returned with a reference. As you may mix URBs to several
destinations in one anchor you have no guarantee the chronologically
first submitted URB is returned.