Exemplo n.º 1
0
static void xen_pcibk_disconnect(struct xen_pcibk_device *pdev)
{
	spin_lock(&pdev->dev_lock);

	/* Ensure the guest can't trigger our handler before removing devices */
	if (pdev->evtchn_irq != INVALID_EVTCHN_IRQ) {
		unbind_from_irqhandler(pdev->evtchn_irq, pdev);
		pdev->evtchn_irq = INVALID_EVTCHN_IRQ;
	}
	spin_unlock(&pdev->dev_lock);

	/* If the driver domain started an op, make sure we complete it
	 * before releasing the shared memory */

	/* Note, the workqueue does not use spinlocks at all.*/
	flush_workqueue(xen_pcibk_wq);

	spin_lock(&pdev->dev_lock);
	if (pdev->sh_info != NULL) {
		xenbus_unmap_ring_vfree(pdev->xdev, pdev->sh_info);
		pdev->sh_info = NULL;
	}
	spin_unlock(&pdev->dev_lock);

}
static int xen_blkif_map(struct xen_blkif *blkif, unsigned long shared_page,
			 unsigned int evtchn)
{
	int err;

	/* Already connected through? */
	if (blkif->irq)
		return 0;

	err = xenbus_map_ring_valloc(blkif->be->dev, shared_page, &blkif->blk_ring);
	if (err < 0)
		return err;

	switch (blkif->blk_protocol) {
	case BLKIF_PROTOCOL_NATIVE:
	{
		struct blkif_sring *sring;
		sring = (struct blkif_sring *)blkif->blk_ring;
		BACK_RING_INIT(&blkif->blk_rings.native, sring, PAGE_SIZE);
		break;
	}
	case BLKIF_PROTOCOL_X86_32:
	{
		struct blkif_x86_32_sring *sring_x86_32;
		sring_x86_32 = (struct blkif_x86_32_sring *)blkif->blk_ring;
		BACK_RING_INIT(&blkif->blk_rings.x86_32, sring_x86_32, PAGE_SIZE);
		break;
	}
	case BLKIF_PROTOCOL_X86_64:
	{
		struct blkif_x86_64_sring *sring_x86_64;
		sring_x86_64 = (struct blkif_x86_64_sring *)blkif->blk_ring;
		BACK_RING_INIT(&blkif->blk_rings.x86_64, sring_x86_64, PAGE_SIZE);
		break;
	}
	default:
		BUG();
	}

	err = bind_interdomain_evtchn_to_irqhandler(blkif->domid, evtchn,
						    xen_blkif_be_int, 0,
						    "blkif-backend", blkif);
	if (err < 0) {
		xenbus_unmap_ring_vfree(blkif->be->dev, blkif->blk_ring);
		blkif->blk_rings.common.sring = NULL;
		return err;
	}
	blkif->irq = err;

	return 0;
}
Exemplo n.º 3
0
static void xen_blkif_disconnect(struct xen_blkif *blkif)
{
	if (blkif->xenblkd) {
		kthread_stop(blkif->xenblkd);
		blkif->xenblkd = NULL;
	}

	atomic_dec(&blkif->refcnt);
	wait_event(blkif->waiting_to_free, atomic_read(&blkif->refcnt) == 0);
	atomic_inc(&blkif->refcnt);

	if (blkif->irq) {
		unbind_from_irqhandler(blkif->irq, blkif);
		blkif->irq = 0;
	}

	if (blkif->blk_rings.common.sring) {
		xenbus_unmap_ring_vfree(blkif->be->dev, blkif->blk_ring);
		blkif->blk_rings.common.sring = NULL;
	}
}
Exemplo n.º 4
0
/**
 * cancel connection
 *      unbind irq
 *      unmap ring
 **/
static void xen_chrif_disconnect(struct xen_chrif *chrif)
{
	unmap_frontend_pages(chrif); 
	xen_chrbk_unmap(chrif);

	if(chrif->xenchrd){
		kthread_stop(chrif->xenchrd);
		chrif->xenchrd = NULL;
	}
	
	if(chrif->irq){
        unbind_from_irqhandler(chrif->irq, chrif);
        chrif->irq = 0;
    }
    
    if(chrif->chr_ring.sring){
        xenbus_unmap_ring_vfree(chrif->be->dev, &chrif->chr_ring);
        chrif->chr_ring.sring = NULL;
    }
	
    printk("\nxen: dom0: xen chrif disconnrct finished");
}