1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
/* { dg-do compile { target arm_thumb2 } } */
/* { dg-options "-O2 -fdump-rtl-subreg2" } */
/* { dg-final { scan-rtl-dump "REG_INC" "subreg2" } } */
/* { dg-final { cleanup-rtl-dump "subreg2" } } */
struct device;
typedef unsigned int __u32;
typedef unsigned long long u64;
typedef __u32 __le32;
typedef u64 dma_addr_t;
typedef unsigned gfp_t;
int dev_warn (const struct device *dev, const char *fmt, ...);
struct usb_bus
{
struct device *controller;
};
struct usb_hcd
{
struct usb_bus self;
};
struct xhci_generic_trb
{
__le32 field[4];
};
union xhci_trb
{
struct xhci_generic_trb generic;
};
struct xhci_segment
{
union xhci_trb *trbs;
dma_addr_t dma;
};
struct xhci_ring
{
struct xhci_segment *first_seg;
};
struct xhci_hcd
{
struct xhci_ring *cmd_ring;
struct xhci_ring *event_ring;
};
struct usb_hcd *xhci_to_hcd (struct xhci_hcd *xhci)
{
}
dma_addr_t xhci_trb_virt_to_dma (struct xhci_segment * seg,
union xhci_trb * trb);
struct xhci_segment *trb_in_td (struct xhci_segment *start_seg,
dma_addr_t suspect_dma);
xhci_test_trb_in_td (struct xhci_hcd *xhci, struct xhci_segment *input_seg,
union xhci_trb *start_trb, union xhci_trb *end_trb,
dma_addr_t input_dma, struct xhci_segment *result_seg,
char *test_name, int test_number)
{
unsigned long long start_dma;
unsigned long long end_dma;
struct xhci_segment *seg;
start_dma = xhci_trb_virt_to_dma (input_seg, start_trb);
end_dma = xhci_trb_virt_to_dma (input_seg, end_trb);
{
dev_warn (xhci_to_hcd (xhci)->self.controller,
"%d\n", test_number);
dev_warn (xhci_to_hcd (xhci)->self.controller,
"Expected seg %p, got seg %p\n", result_seg, seg);
}
}
xhci_check_trb_in_td_math (struct xhci_hcd *xhci, gfp_t mem_flags)
{
struct
{
dma_addr_t input_dma;
struct xhci_segment *result_seg;
}
simple_test_vector[] =
{
{
0, ((void *) 0)
}
,
{
xhci->event_ring->first_seg->dma - 16, ((void *) 0)}
,
{
xhci->event_ring->first_seg->dma - 1, ((void *) 0)}
,
{
xhci->event_ring->first_seg->dma, xhci->event_ring->first_seg}
,
{
xhci->event_ring->first_seg->dma + (64 - 1) * 16,
xhci->event_ring->first_seg
}
,
{
xhci->event_ring->first_seg->dma + (64 - 1) * 16 + 1, ((void *) 0)}
,
{
xhci->event_ring->first_seg->dma + (64) * 16, ((void *) 0)}
,
{
(dma_addr_t) (~0), ((void *) 0)
}
};
struct
{
struct xhci_segment *input_seg;
union xhci_trb *start_trb;
union xhci_trb *end_trb;
dma_addr_t input_dma;
struct xhci_segment *result_seg;
}
complex_test_vector[] =
{
{
.input_seg = xhci->event_ring->first_seg,.start_trb =
xhci->event_ring->first_seg->trbs,.end_trb =
&xhci->event_ring->first_seg->trbs[64 - 1],.input_dma =
xhci->cmd_ring->first_seg->dma,.result_seg = ((void *) 0),
}
,
{
.input_seg = xhci->event_ring->first_seg,.start_trb =
xhci->event_ring->first_seg->trbs,.end_trb =
&xhci->cmd_ring->first_seg->trbs[64 - 1],.input_dma =
xhci->cmd_ring->first_seg->dma,.result_seg = ((void *) 0),
}
,
{
.input_seg = xhci->event_ring->first_seg,.start_trb =
xhci->cmd_ring->first_seg->trbs,.end_trb =
&xhci->cmd_ring->first_seg->trbs[64 - 1],.input_dma =
xhci->cmd_ring->first_seg->dma,.result_seg = ((void *) 0),
}
,
{
.input_seg = xhci->event_ring->first_seg,.start_trb =
&xhci->event_ring->first_seg->trbs[0],.end_trb =
&xhci->event_ring->first_seg->trbs[3],.input_dma =
xhci->event_ring->first_seg->dma + 4 * 16,.result_seg = ((void *) 0),
}
,
{
.input_seg = xhci->event_ring->first_seg,.start_trb =
&xhci->event_ring->first_seg->trbs[3],.end_trb =
&xhci->event_ring->first_seg->trbs[6],.input_dma =
xhci->event_ring->first_seg->dma + 2 * 16,.result_seg = ((void *) 0),
}
,
{
.input_seg = xhci->event_ring->first_seg,.start_trb =
&xhci->event_ring->first_seg->trbs[64 - 3],.end_trb =
&xhci->event_ring->first_seg->trbs[1],.input_dma =
xhci->event_ring->first_seg->dma + 2 * 16,.result_seg = ((void *) 0),
}
,
{
.input_seg = xhci->event_ring->first_seg,.start_trb =
&xhci->event_ring->first_seg->trbs[64 - 3],.end_trb =
&xhci->event_ring->first_seg->trbs[1],.input_dma =
xhci->event_ring->first_seg->dma + (64 - 4) * 16,.result_seg =
((void *) 0),
}
,
{
.input_seg = xhci->event_ring->first_seg,.start_trb =
&xhci->event_ring->first_seg->trbs[64 - 3],.end_trb =
&xhci->event_ring->first_seg->trbs[1],.input_dma =
xhci->cmd_ring->first_seg->dma + 2 * 16,.result_seg = ((void *) 0),
}
};
unsigned int num_tests;
int i, ret;
num_tests =
(sizeof (simple_test_vector) / sizeof ((simple_test_vector)[0]) +
(sizeof (struct
{
}
)));
for (i = 0; i < num_tests; i++)
{
ret =
xhci_test_trb_in_td (xhci, xhci->event_ring->first_seg,
xhci->event_ring->first_seg->trbs,
&xhci->event_ring->first_seg->trbs[64 - 1],
simple_test_vector[i].input_dma,
simple_test_vector[i].result_seg, "Simple", i);
if (ret < 0)
return ret;
}
for (i = 0; i < num_tests; i++)
{
ret =
xhci_test_trb_in_td (xhci, complex_test_vector[i].input_seg,
complex_test_vector[i].start_trb,
complex_test_vector[i].end_trb,
complex_test_vector[i].input_dma,
complex_test_vector[i].result_seg, "Complex", i);
if (ret < 0)
return ret;
}
}
|