Re: [PATCH v2 8/9] xen/gntdev: Implement dma-buf import functionality
From: Boris Ostrovsky
Date: Mon Jun 04 2018 - 18:25:43 EST
On 06/01/2018 07:41 AM, Oleksandr Andrushchenko wrote:
> /* ------------------------------------------------------------------ */
>
> +static int
> +dmabuf_imp_grant_foreign_access(struct page **pages, u32 *refs,
> + int count, int domid)
> +{
> + grant_ref_t priv_gref_head;
> + int i, ret;
> +
> + ret = gnttab_alloc_grant_references(count, &priv_gref_head);
> + if (ret < 0) {
> + pr_err("Cannot allocate grant references, ret %d\n", ret);
> + return ret;
> + }
> +
> + for (i = 0; i < count; i++) {
> + int cur_ref;
> +
> + cur_ref = gnttab_claim_grant_reference(&priv_gref_head);
> + if (cur_ref < 0) {
> + ret = cur_ref;
> + pr_err("Cannot claim grant reference, ret %d\n", ret);
> + goto out;
> + }
> +
> + gnttab_grant_foreign_access_ref(cur_ref, domid,
> + xen_page_to_gfn(pages[i]), 0);
> + refs[i] = cur_ref;
> + }
> +
> + ret = 0;
return 0?
> +
> +out:
> + gnttab_free_grant_references(priv_gref_head);
> + return ret;
> +}
> +