Re: [PATCH v6 02/13] xen/pvcalls: implement frontend disconnect

From: Stefano Stabellini
Date: Wed Oct 25 2017 - 19:22:53 EST


On Wed, 25 Oct 2017, Boris Ostrovsky wrote:
> On 10/24/2017 01:33 PM, Stefano Stabellini wrote:
> > +static void pvcalls_front_free_map(struct pvcalls_bedata *bedata,
> > + struct sock_mapping *map, bool locked)
> > +{
> > +}
> > +
> > static const struct xenbus_device_id pvcalls_front_ids[] = {
> > { "pvcalls" },
> > { "" }
> > @@ -27,6 +66,32 @@
> >
> > static int pvcalls_front_remove(struct xenbus_device *dev)
> > {
> > + struct pvcalls_bedata *bedata;
> > + struct sock_mapping *map = NULL, *n;
>
> Your last comment made me look again at sock_mapping definition. And
> then I noticed that it is not defined until patch 4 ;-(

I moved the definition of struct sock_mapping to this patch. Then, I
tested the build patch by patch. I also had to move a few #includes from
patch #5 to #4, but everything builds fine now.


> > +
> > + bedata = dev_get_drvdata(&pvcalls_front_dev->dev);
> > + dev_set_drvdata(&dev->dev, NULL);
> > + pvcalls_front_dev = NULL;
> > + if (bedata->irq >= 0)
> > + unbind_from_irqhandler(bedata->irq, dev);
> > +
> > + smp_mb();
> > + while (atomic_read(&pvcalls_refcount) > 0)
> > + cpu_relax();
> > + list_for_each_entry_safe(map, n, &bedata->socket_mappings, list) {
> > + if (map->active_socket) {
> > + /* No need to lock, refcount is 0 */
> > + pvcalls_front_free_map(bedata, map, true);
> > + } else {
> > + list_del(&map->list);
> > + kfree(map);
> > + }
> > + }
> > + if (bedata->ref >= 0)
> > + gnttab_end_foreign_access(bedata->ref, 0, 0);
> > + kfree(bedata->ring.sring);
> > + kfree(bedata);
> > + xenbus_switch_state(dev, XenbusStateClosed);
> > return 0;
> > }
> >
>