WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] Re: [PATCH 2/3] xen-fbfront: Use grant references when reque

To: Daniel De Graaf <dgdegra@xxxxxxxxxxxxx>
Subject: [Xen-devel] Re: [PATCH 2/3] xen-fbfront: Use grant references when requested
From: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Date: Wed, 9 Mar 2011 16:53:38 -0500
Cc: Ian.Campbell@xxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxx, Stefano.Stabellini@xxxxxxxxxxxxx
Delivery-date: Wed, 09 Mar 2011 13:54:58 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1299528672-5299-3-git-send-email-dgdegra@xxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1299528672-5299-1-git-send-email-dgdegra@xxxxxxxxxxxxx> <1299528672-5299-3-git-send-email-dgdegra@xxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.20 (2009-06-14)
> +     int be_id = dev->otherend_id;
> +     int i, ref;
> +     unsigned long mfn;
> +     grant_ref_t gref_head;
> +     int allpages = info->nr_pages + ((info->nr_pages + epd - 1) / epd) + 1;
> +
> +     int grants = 0;
> +     xenbus_scanf(XBT_NIL, dev->otherend, "feature-grants", "%d", &grants);
> +
> +     if (grants) {
> +             int err = gnttab_alloc_grant_references(allpages, &gref_head);
> +             if (err < 0) {
> +                     xenbus_dev_fatal(dev, err, "fbdev grant refs");
> +                     info->page_gref = -ENOSPC;
> +             } else {
> +                     ref = gnttab_claim_grant_reference(&gref_head);
> +                     mfn = virt_to_mfn(info->page);
> +                     BUG_ON(ref == -ENOSPC);
> +                     gnttab_grant_foreign_access_ref(ref, be_id, mfn, 0);
> +                     info->page_gref = ref;
> +             }
> +     } else
> +             info->page_gref = -ENOENT;
>  
>       for (i = 0; i < info->nr_pages; i++)
> -             info->mfns[i] = vmalloc_to_mfn(info->fb + i * PAGE_SIZE);
> +     {
> +             mfn = vmalloc_to_mfn(info->fb + i * PAGE_SIZE);
> +             if (grants) {
> +                     ref = gnttab_claim_grant_reference(&gref_head);
> +                     BUG_ON(ref == -ENOSPC);
> +                     gnttab_grant_foreign_access_ref(ref, be_id, mfn, 1);
> +                     info->mfns[i] = ref;
> +             } else
> +                     info->mfns[i] = mfn;
> +     }
>  
>       for (i = 0; i * epd < info->nr_pages; i++)
> -             info->page->pd[i] = vmalloc_to_mfn(&info->mfns[i * epd]);
> +     {
> +             mfn = vmalloc_to_mfn(&info->mfns[i * epd]);
> +             if (grants) {
> +                     ref = gnttab_claim_grant_reference(&gref_head);
> +                     BUG_ON(ref == -ENOSPC);
> +                     gnttab_grant_foreign_access_ref(ref, be_id, mfn, 1);
> +                     info->page->pd[i] = ref;
> +             } else
> +                     info->page->pd[i] = mfn;
> +     }

Shouldn't we in xenfb_remove also cleanup (unclaim and wholesale free the
grant reference lot?)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel