Lines Matching refs:ring

24  * Allocates a generic ring segment from the ring pool, sets the dma address,
133 * Link the ring to the new segments.
134 * Set Toggle Cycle for the new ring if needed.
137 struct cdnsp_ring *ring,
144 if (!ring || !first || !last)
147 next = ring->enq_seg->next;
148 cdnsp_link_segments(pdev, ring->enq_seg, first, ring->type);
149 cdnsp_link_segments(pdev, last, next, ring->type);
150 ring->num_segs += num_segs;
151 ring->num_trbs_free += (TRBS_PER_SEGMENT - 1) * num_segs;
153 if (ring->type != TYPE_EVENT && ring->enq_seg == ring->last_seg) {
154 ring->last_seg->trbs[TRBS_PER_SEGMENT - 1].link.control &=
158 ring->last_seg = last;
165 * tell us which stream ring the TRB came from. We could store the stream ID
169 * The radix tree maps the upper portion of the TRB DMA address to a ring
181 * will make the radix tree return the stream ID for that ring.
194 struct cdnsp_ring *ring,
211 ret = radix_tree_insert(trb_address_map, key, ring);
228 struct cdnsp_ring *ring,
239 ret = cdnsp_insert_segment_mapping(trb_address_map, ring, seg,
263 static void cdnsp_remove_stream_mapping(struct cdnsp_ring *ring)
267 seg = ring->first_seg;
269 cdnsp_remove_segment_mapping(ring->trb_address_map, seg);
271 } while (seg != ring->first_seg);
274 static int cdnsp_update_stream_mapping(struct cdnsp_ring *ring)
276 return cdnsp_update_stream_segment_mapping(ring->trb_address_map, ring,
277 ring->first_seg, ring->last_seg, GFP_ATOMIC);
280 static void cdnsp_ring_free(struct cdnsp_device *pdev, struct cdnsp_ring *ring)
282 if (!ring)
285 trace_cdnsp_ring_free(ring);
287 if (ring->first_seg) {
288 if (ring->type == TYPE_STREAM)
289 cdnsp_remove_stream_mapping(ring);
291 cdnsp_free_segments_for_ring(pdev, ring->first_seg);
294 kfree(ring);
297 void cdnsp_initialize_ring_info(struct cdnsp_ring *ring)
299 ring->enqueue = ring->first_seg->trbs;
300 ring->enq_seg = ring->first_seg;
301 ring->dequeue = ring->enqueue;
302 ring->deq_seg = ring->first_seg;
305 * The ring is initialized to 0. The producer must write 1 to the cycle
310 * handling ring expansion, set the cycle state equal to the old ring.
312 ring->cycle_state = 1;
318 ring->num_trbs_free = ring->num_segs * (TRBS_PER_SEGMENT - 1) - 1;
321 /* Allocate segments and link them for a ring. */
365 * Create a new ring with zero or more segments.
367 * Link each segment together into a ring.
376 struct cdnsp_ring *ring;
379 ring = kzalloc(sizeof *(ring), flags);
380 if (!ring)
383 ring->num_segs = num_segs;
384 ring->bounce_buf_len = max_packet;
385 INIT_LIST_HEAD(&ring->td_list);
386 ring->type = type;
389 return ring;
391 ret = cdnsp_alloc_segments_for_ring(pdev, &ring->first_seg,
392 &ring->last_seg, num_segs,
397 /* Only event ring does not use link TRB. */
399 ring->last_seg->trbs[TRBS_PER_SEGMENT - 1].link.control |=
402 cdnsp_initialize_ring_info(ring);
403 trace_cdnsp_ring_alloc(ring);
404 return ring;
406 kfree(ring);
412 cdnsp_ring_free(pdev, pep->ring);
413 pep->ring = NULL;
418 * Expand an existing ring.
419 * Allocate a new ring which has same segment numbers and link the two rings.
422 struct cdnsp_ring *ring,
435 /* Allocate number of segments we needed, or double the ring size. */
436 num_segs = max(ring->num_segs, num_segs_needed);
439 ring->cycle_state, ring->type,
440 ring->bounce_buf_len, flags);
444 if (ring->type == TYPE_STREAM)
445 ret = cdnsp_update_stream_segment_mapping(ring->trb_address_map,
446 ring, first,
455 cdnsp_link_rings(pdev, ring, first, last, num_segs);
456 trace_cdnsp_ring_expansion(ring);
549 return pep->ring;
668 /* All the cdnsp_tds in the ring's TD list should be freed at this point.*/
695 /* Allocate endpoint 0 ring. */
696 pdev->eps[0].ring = cdnsp_ring_alloc(pdev, 2, TYPE_CTRL, 0, GFP_ATOMIC);
697 if (!pdev->eps[0].ring)
718 struct cdnsp_ring *ep_ring = pdev->eps[0].ring;
769 ep0_ctx->deq = cpu_to_le64(pdev->eps[0].ring->first_seg->dma |
770 pdev->eps[0].ring->cycle_state);
988 /* Set up the endpoint ring. */
989 pep->ring = cdnsp_ring_alloc(pdev, 2, ring_type, max_packet, mem_flags);
990 if (!pep->ring)
1001 ep_ctx->deq = cpu_to_le64(pep->ring->first_seg->dma |
1002 pep->ring->cycle_state);
1108 /* Update controller event ring dequeue pointer */
1205 * device contexts, set up a command ring segment, create event
1206 * ring (one for now).
1241 * Initialize the ring segment pool. The ring must be a contiguous
1243 * however, the command ring segment needs 64-byte aligned segments
1248 pdev->segment_pool = dma_pool_create("CDNSP ring segments", dev,
1260 /* Set up the command ring to have one segments for now. */
1280 * Event ring setup: Allocate a normal ring, but also setup
1281 * the event ring segment table (ERST).
1304 /* Set the event ring dequeue address. */