Lines Matching full:chain

34 	/* Guest physical address of the current chain. */
36 /* Count of the valid ccws in chain. */
333 * @head: address of the beginning of a CCW chain
334 * @len: number of CCWs within the chain
336 * Determine whether the address of a CCW (whether a new chain,
358 struct ccwchain *chain; in ccwchain_alloc() local
363 size = ((sizeof(*chain) + 7L) & -8L) + in ccwchain_alloc()
364 sizeof(*chain->ch_ccw) * len + in ccwchain_alloc()
365 sizeof(*chain->ch_pa) * len; in ccwchain_alloc()
366 chain = kzalloc(size, GFP_DMA | GFP_KERNEL); in ccwchain_alloc()
367 if (!chain) in ccwchain_alloc()
370 data = (u8 *)chain + ((sizeof(*chain) + 7L) & -8L); in ccwchain_alloc()
371 chain->ch_ccw = (struct ccw1 *)data; in ccwchain_alloc()
373 data = (u8 *)(chain->ch_ccw) + sizeof(*chain->ch_ccw) * len; in ccwchain_alloc()
374 chain->ch_pa = (struct page_array *)data; in ccwchain_alloc()
376 chain->ch_len = len; in ccwchain_alloc()
378 list_add_tail(&chain->next, &cp->ccwchain_list); in ccwchain_alloc()
380 return chain; in ccwchain_alloc()
383 static void ccwchain_free(struct ccwchain *chain) in ccwchain_free() argument
385 list_del(&chain->next); in ccwchain_free()
386 kfree(chain); in ccwchain_free()
390 static void ccwchain_cda_free(struct ccwchain *chain, int idx) in ccwchain_cda_free() argument
392 struct ccw1 *ccw = chain->ch_ccw + idx; in ccwchain_cda_free()
401 * ccwchain_calc_length - calculate the length of the ccw chain.
402 * @iova: guest physical address of the target ccw chain
405 * This is the chain length not considering any TICs.
411 * Returns: the length of the ccw chain or -errno.
432 * that loops back into the current chain. The latter in ccwchain_calc_length()
451 struct ccwchain *chain; in tic_target_chain_exists() local
454 list_for_each_entry(chain, &cp->ccwchain_list, next) { in tic_target_chain_exists()
455 ccw_head = chain->ch_iova; in tic_target_chain_exists()
456 if (is_cpa_within_range(tic->cda, ccw_head, chain->ch_len)) in tic_target_chain_exists()
463 static int ccwchain_loop_tic(struct ccwchain *chain,
470 struct ccwchain *chain; in ccwchain_handle_ccw() local
483 /* Count the CCWs in the current chain */ in ccwchain_handle_ccw()
488 /* Need alloc a new chain for this one. */ in ccwchain_handle_ccw()
489 chain = ccwchain_alloc(cp, len); in ccwchain_handle_ccw()
490 if (!chain) in ccwchain_handle_ccw()
492 chain->ch_iova = cda; in ccwchain_handle_ccw()
494 /* Copy the actual CCWs into the new chain */ in ccwchain_handle_ccw()
495 memcpy(chain->ch_ccw, cp->guest_cp, len * sizeof(struct ccw1)); in ccwchain_handle_ccw()
497 /* Loop for tics on this new chain. */ in ccwchain_handle_ccw()
498 ret = ccwchain_loop_tic(chain, cp); in ccwchain_handle_ccw()
501 ccwchain_free(chain); in ccwchain_handle_ccw()
507 static int ccwchain_loop_tic(struct ccwchain *chain, struct channel_program *cp) in ccwchain_loop_tic() argument
512 for (i = 0; i < chain->ch_len; i++) { in ccwchain_loop_tic()
513 tic = chain->ch_ccw + i; in ccwchain_loop_tic()
518 /* May transfer to an existing chain. */ in ccwchain_loop_tic()
531 static int ccwchain_fetch_tic(struct ccwchain *chain, in ccwchain_fetch_tic() argument
535 struct ccw1 *ccw = chain->ch_ccw + idx; in ccwchain_fetch_tic()
551 static int ccwchain_fetch_direct(struct ccwchain *chain, in ccwchain_fetch_direct() argument
566 ccw = chain->ch_ccw + idx; in ccwchain_fetch_direct()
597 pa = chain->ch_pa + idx; in ccwchain_fetch_direct()
653 static int ccwchain_fetch_one(struct ccwchain *chain, in ccwchain_fetch_one() argument
657 struct ccw1 *ccw = chain->ch_ccw + idx; in ccwchain_fetch_one()
660 return ccwchain_fetch_tic(chain, idx, cp); in ccwchain_fetch_one()
662 return ccwchain_fetch_direct(chain, idx, cp); in ccwchain_fetch_one()
736 struct ccwchain *chain, *temp; in cp_free() local
743 list_for_each_entry_safe(chain, temp, &cp->ccwchain_list, next) { in cp_free()
744 for (i = 0; i < chain->ch_len; i++) { in cp_free()
745 page_array_unpin_free(chain->ch_pa + i, vdev); in cp_free()
746 ccwchain_cda_free(chain, i); in cp_free()
748 ccwchain_free(chain); in cp_free()
761 * For each chain composing the channel program:
764 * This allows cp_free to find in ch_len the count of CCWs to free in a chain.
767 * as helpers to do ccw chain translation inside the kernel. Basically
791 struct ccwchain *chain; in cp_prefetch() local
798 list_for_each_entry(chain, &cp->ccwchain_list, next) { in cp_prefetch()
799 len = chain->ch_len; in cp_prefetch()
801 ret = ccwchain_fetch_one(chain, idx, cp); in cp_prefetch()
809 /* Only cleanup the chain elements that were actually translated. */ in cp_prefetch()
810 chain->ch_len = idx; in cp_prefetch()
811 list_for_each_entry_continue(chain, &cp->ccwchain_list, next) { in cp_prefetch()
812 chain->ch_len = 0; in cp_prefetch()
830 struct ccwchain *chain; in cp_get_orb() local
846 chain = list_first_entry(&cp->ccwchain_list, struct ccwchain, next); in cp_get_orb()
847 cpa = chain->ch_ccw; in cp_get_orb()
869 struct ccwchain *chain; in cp_update_scsw() local
882 list_for_each_entry(chain, &cp->ccwchain_list, next) { in cp_update_scsw()
883 ccw_head = (u32)(u64)chain->ch_ccw; in cp_update_scsw()
886 * of the chain. in cp_update_scsw()
888 if (is_cpa_within_range(cpa, ccw_head, chain->ch_len + 1)) { in cp_update_scsw()
891 * physical ccw to its chain head. in cp_update_scsw()
892 * Adding this value to the guest physical ccw chain in cp_update_scsw()
895 cpa = chain->ch_iova + (cpa - ccw_head); in cp_update_scsw()
904 * cp_iova_pinned() - check if an iova is pinned for a ccw chain.
909 * If the @iova is currently pinned for the ccw chain, return true;
914 struct ccwchain *chain; in cp_iova_pinned() local
920 list_for_each_entry(chain, &cp->ccwchain_list, next) { in cp_iova_pinned()
921 for (i = 0; i < chain->ch_len; i++) in cp_iova_pinned()
922 if (page_array_iova_pinned(chain->ch_pa + i, iova, length)) in cp_iova_pinned()