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