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 10/11] xen gntdev: use gnttab_map_refs and gnttab

To: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
Subject: [Xen-devel] Re: [PATCH 10/11] xen gntdev: use gnttab_map_refs and gnttab_unmap_refs
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Mon, 10 Jan 2011 10:33:15 +0000
Cc: Jeremy Fitzhardinge <Jeremy.Fitzhardinge@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>, "linux-kernel@xxxxxxxxxxxxxxx" <linux-kernel@xxxxxxxxxxxxxxx>, Stefano Stabellini <Stefano.Stabellini@xxxxxxxxxxxxx>
Delivery-date: Mon, 10 Jan 2011 02:37:54 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <20110105202349.GA29993@xxxxxxxxxxxx>
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: <alpine.DEB.2.00.1012151259510.2390@kaball-desktop> <1292420446-3348-10-git-send-email-stefano.stabellini@xxxxxxxxxxxxx> <20110105202349.GA29993@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Alpine 2.00 (DEB 1167 2008-08-23)
On Wed, 5 Jan 2011, Konrad Rzeszutek Wilk wrote:
> On Wed, Dec 15, 2010 at 01:40:45PM +0000, stefano.stabellini@xxxxxxxxxxxxx 
> wrote:
> > From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> > 
> > Use gnttab_map_refs and gnttab_unmap_refs to map and unmap the grant
> > ref, so that we can have a corresponding struct page.
> > 
> > Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
> > Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@xxxxxxxxxx>
> > ---
> >  drivers/xen/gntdev.c |   37 ++++++++++++++++++++++++++++++-------
> >  1 files changed, 30 insertions(+), 7 deletions(-)
> > 
> > diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
> > index fc5e420..35de6bb 100644
> > --- a/drivers/xen/gntdev.c
> > +++ b/drivers/xen/gntdev.c
> > @@ -68,6 +68,7 @@ struct grant_map {
> >     struct ioctl_gntdev_grant_ref *grants;
> >     struct gnttab_map_grant_ref   *map_ops;
> >     struct gnttab_unmap_grant_ref *unmap_ops;
> > +   struct page **pages;
> >  };
> >  
> >  /* ------------------------------------------------------------------ */
> > @@ -88,6 +89,7 @@ static void gntdev_print_maps(struct gntdev_priv *priv,
> >  static struct grant_map *gntdev_alloc_map(struct gntdev_priv *priv, int 
> > count)
> >  {
> >     struct grant_map *add;
> > +   int i;
> 
> So 'int' here.
> >  
> >     add = kzalloc(sizeof(struct grant_map), GFP_KERNEL);
> >     if (NULL == add)
> > @@ -96,11 +98,19 @@ static struct grant_map *gntdev_alloc_map(struct 
> > gntdev_priv *priv, int count)
> >     add->grants    = kzalloc(sizeof(add->grants[0])    * count, GFP_KERNEL);
> >     add->map_ops   = kzalloc(sizeof(add->map_ops[0])   * count, GFP_KERNEL);
> >     add->unmap_ops = kzalloc(sizeof(add->unmap_ops[0]) * count, GFP_KERNEL);
> > -   if (NULL == add->grants  ||
> > -       NULL == add->map_ops ||
> > -       NULL == add->unmap_ops)
> > +   add->pages     = kzalloc(sizeof(add->pages[0])     * count, GFP_KERNEL);
> > +   if (NULL == add->grants    ||
> > +       NULL == add->map_ops   ||
> > +       NULL == add->unmap_ops ||
> > +       NULL == add->pages)
> >             goto err;
> >  
> > +   for (i = 0; i < count; i++) {
> > +           add->pages[i] = alloc_page(GFP_KERNEL | __GFP_HIGHMEM);
> > +           if (add->pages[i] == NULL)
> > +                   goto err;
> > +   }
> > +
> >     add->index = 0;
> >     add->count = count;
> >     add->priv  = priv;
> > @@ -111,6 +121,12 @@ static struct grant_map *gntdev_alloc_map(struct 
> > gntdev_priv *priv, int count)
> >     return add;
> >  
> >  err:
> > +   if (add->pages)
> > +           for (i = 0; i < count; i++) {
> > +                   if (add->pages[i])
> > +                           __free_page(add->pages[i]);
> > +           }
> > +   kfree(add->pages);
> >     kfree(add->grants);
> >     kfree(add->map_ops);
> >     kfree(add->unmap_ops);
> > @@ -186,8 +202,17 @@ static int gntdev_del_map(struct grant_map *map)
> >  
> >  static void gntdev_free_map(struct grant_map *map)
> >  {
> > +   unsigned i;
> 
> But 'unsigned' here?
> 

Good eye! Changed both to int.

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

<Prev in Thread] Current Thread [Next in Thread>