From mboxrd@z Thu Jan 1 00:00:00 1970 From: Konrad Rzeszutek Wilk Subject: Re: [PATCH 2/3] xen-fbfront: Use grant references when requested Date: Wed, 9 Mar 2011 16:53:38 -0500 Message-ID: <20110309215338.GA18343@dumpdata.com> References: <1299528672-5299-1-git-send-email-dgdegra@tycho.nsa.gov> <1299528672-5299-3-git-send-email-dgdegra@tycho.nsa.gov> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1299528672-5299-3-git-send-email-dgdegra@tycho.nsa.gov> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Daniel De Graaf Cc: Ian.Campbell@eu.citrix.com, xen-devel@lists.xensource.com, Stefano.Stabellini@eu.citrix.com List-Id: xen-devel@lists.xenproject.org > + 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?)