Lines Matching full:chain
34 /* Guest physical address of the current chain. */
36 /* Count of the valid ccws in chain. */
294 * @head: address of the beginning of a CCW chain
295 * @len: number of CCWs within the chain
297 * Determine whether the address of a CCW (whether a new chain,
320 struct ccwchain *chain; in ccwchain_alloc() local
322 chain = kzalloc(sizeof(*chain), GFP_KERNEL); in ccwchain_alloc()
323 if (!chain) in ccwchain_alloc()
326 chain->ch_ccw = kcalloc(len, sizeof(*chain->ch_ccw), GFP_DMA | GFP_KERNEL); in ccwchain_alloc()
327 if (!chain->ch_ccw) in ccwchain_alloc()
330 chain->ch_pa = kcalloc(len, sizeof(*chain->ch_pa), GFP_KERNEL); in ccwchain_alloc()
331 if (!chain->ch_pa) in ccwchain_alloc()
334 list_add_tail(&chain->next, &cp->ccwchain_list); in ccwchain_alloc()
336 return chain; in ccwchain_alloc()
339 kfree(chain->ch_ccw); in ccwchain_alloc()
340 kfree(chain); in ccwchain_alloc()
344 static void ccwchain_free(struct ccwchain *chain) in ccwchain_free() argument
346 list_del(&chain->next); in ccwchain_free()
347 kfree(chain->ch_pa); in ccwchain_free()
348 kfree(chain->ch_ccw); in ccwchain_free()
349 kfree(chain); in ccwchain_free()
353 static void ccwchain_cda_free(struct ccwchain *chain, int idx) in ccwchain_cda_free() argument
355 struct ccw1 *ccw = &chain->ch_ccw[idx]; in ccwchain_cda_free()
364 * ccwchain_calc_length - calculate the length of the ccw chain.
365 * @iova: guest physical address of the target ccw chain
368 * This is the chain length not considering any TICs.
374 * Returns: the length of the ccw chain or -errno.
387 * that loops back into the current chain. The latter in ccwchain_calc_length()
406 struct ccwchain *chain; in tic_target_chain_exists() local
409 list_for_each_entry(chain, &cp->ccwchain_list, next) { in tic_target_chain_exists()
410 ccw_head = chain->ch_iova; in tic_target_chain_exists()
411 if (is_cpa_within_range(tic->cda, ccw_head, chain->ch_len)) in tic_target_chain_exists()
418 static int ccwchain_loop_tic(struct ccwchain *chain,
425 struct ccwchain *chain; in ccwchain_handle_ccw() local
439 /* Count the CCWs in the current chain */ in ccwchain_handle_ccw()
444 /* Need alloc a new chain for this one. */ in ccwchain_handle_ccw()
445 chain = ccwchain_alloc(cp, len); in ccwchain_handle_ccw()
446 if (!chain) in ccwchain_handle_ccw()
449 chain->ch_len = len; in ccwchain_handle_ccw()
450 chain->ch_iova = gcda; in ccwchain_handle_ccw()
452 /* Copy the actual CCWs into the new chain */ in ccwchain_handle_ccw()
453 memcpy(chain->ch_ccw, cp->guest_cp, len * sizeof(struct ccw1)); in ccwchain_handle_ccw()
455 /* Loop for tics on this new chain. */ in ccwchain_handle_ccw()
456 ret = ccwchain_loop_tic(chain, cp); in ccwchain_handle_ccw()
459 ccwchain_free(chain); in ccwchain_handle_ccw()
465 static int ccwchain_loop_tic(struct ccwchain *chain, struct channel_program *cp) in ccwchain_loop_tic() argument
470 for (i = 0; i < chain->ch_len; i++) { in ccwchain_loop_tic()
471 tic = &chain->ch_ccw[i]; in ccwchain_loop_tic()
476 /* May transfer to an existing chain. */ in ccwchain_loop_tic()
759 struct ccwchain *chain, *temp; in cp_free() local
766 list_for_each_entry_safe(chain, temp, &cp->ccwchain_list, next) { in cp_free()
767 for (i = 0; i < chain->ch_len; i++) { in cp_free()
768 page_array_unpin_free(&chain->ch_pa[i], vdev, idal_is_2k(cp)); in cp_free()
769 ccwchain_cda_free(chain, i); in cp_free()
771 ccwchain_free(chain); in cp_free()
784 * For each chain composing the channel program:
787 * This allows cp_free to find in ch_len the count of CCWs to free in a chain.
790 * as helpers to do ccw chain translation inside the kernel. Basically
814 struct ccwchain *chain; in cp_prefetch() local
823 list_for_each_entry(chain, &cp->ccwchain_list, next) { in cp_prefetch()
824 len = chain->ch_len; in cp_prefetch()
826 ccw = &chain->ch_ccw[idx]; in cp_prefetch()
827 pa = &chain->ch_pa[idx]; in cp_prefetch()
837 /* Only cleanup the chain elements that were actually translated. */ in cp_prefetch()
838 chain->ch_len = idx; in cp_prefetch()
839 list_for_each_entry_continue(chain, &cp->ccwchain_list, next) { in cp_prefetch()
840 chain->ch_len = 0; in cp_prefetch()
857 struct ccwchain *chain; in cp_get_orb() local
881 chain = list_first_entry(&cp->ccwchain_list, struct ccwchain, next); in cp_get_orb()
882 cpa = chain->ch_ccw; in cp_get_orb()
904 struct ccwchain *chain; in cp_update_scsw() local
917 list_for_each_entry(chain, &cp->ccwchain_list, next) { in cp_update_scsw()
918 ccw_head = dma32_to_u32(virt_to_dma32(chain->ch_ccw)); in cp_update_scsw()
921 * of the chain. in cp_update_scsw()
923 if (is_cpa_within_range(cpa, ccw_head, chain->ch_len + 1)) { in cp_update_scsw()
926 * physical ccw to its chain head. in cp_update_scsw()
927 * Adding this value to the guest physical ccw chain in cp_update_scsw()
929 * cpa = chain->ch_iova + (cpa - ccw_head) in cp_update_scsw()
931 cpa = dma32_add(cpa, chain->ch_iova - ccw_head); in cp_update_scsw()
940 * cp_iova_pinned() - check if an iova is pinned for a ccw chain.
945 * If the @iova is currently pinned for the ccw chain, return true;
950 struct ccwchain *chain; in cp_iova_pinned() local
956 list_for_each_entry(chain, &cp->ccwchain_list, next) { in cp_iova_pinned()
957 for (i = 0; i < chain->ch_len; i++) in cp_iova_pinned()
958 if (page_array_iova_pinned(&chain->ch_pa[i], iova, length)) in cp_iova_pinned()