Suppress all use of ISA DMA on Xen
Subsystems (3)
RFC 1/1 Suppress all use of ISA DMA on Xen
The kernel's ISA DMA API is just not fitting virtualization requirements.
While I didn't get a response on a query regarding the change to pnpacpi, I am going to submit both this and the floppy.c change to mainline Linux.
This was tested on 2.6.22.1, and only made apply to 2.6.18 without further testing.
Signed-off-by Jan Beulich <[email protected]>
arch/i386/kernel/setup-xen.c +5 -0
@@ -1826,6 +1826,11 @@ void __init setup_arch(char **cmdline_p)virt_to_mfn (pfn_to_mfn_frame_list_list); } +/* Mark all ISA DMA channels in-use - using them wouldn't work. */ +for (i =0 ; i <MAX_DMA_CHANNELS ; ++i) +if (i !=4 &&request_dma (i,"xen" ) !=0 ) +BUG (); +/* * NOTE: at this point the bootmem allocator is fully available. */
arch/x86_64/kernel/setup-xen.c +4 -0
@@ -863,6 +863,10 @@ void __init setup_arch(char **cmdline_p)virt_to_mfn (pfn_to_mfn_frame_list_list); } +/* Mark all ISA DMA channels in-use - using them wouldn't work. */ +for (i =0 ; i <MAX_DMA_CHANNELS ; ++i) +if (i !=4 &&request_dma (i,"xen" ) !=0 ) +BUG (); }if (!is_initial_xendomain ()) {
drivers/block/floppy.c +9 -5
@@ -4397,11 +4397,15 @@ static int floppy_grab_irq_and_dma(void)if (fd_request_dma ()) {DPRINT ("Unable to grab DMA%d for the floppy driver\n" ,FLOPPY_DMA ); -fd_free_irq (); -spin_lock_irqsave (&floppy_usage_lock, flags); - usage_count--; -spin_unlock_irqrestore (&floppy_usage_lock, flags); -return -1 ; +if (can_use_virtual_dma &2 ) + use_virtual_dma = can_use_virtual_dma =1 ; +if (!(can_use_virtual_dma &1 )) { +fd_free_irq (); +spin_lock_irqsave (&floppy_usage_lock, flags); + usage_count--; +spin_unlock_irqrestore (&floppy_usage_lock, flags); +return -1 ; + } }for (fdc =0 ; fdc <N_FDC ; fdc++) {
drivers/pnp/manager.c +10 -18
@@ -168,7 +168,7 @@ static int pnp_assign_irq(struct pnp_devreturn 0 ; } -static int pnp_assign_dma (struct pnp_dev *dev,struct pnp_dma *rule,int idx) +static void pnp_assign_dma (struct pnp_dev *dev,struct pnp_dma *rule,int idx) {resource_size_t *start, *end;unsigned long *flags;
@@ -179,18 +179,14 @@ static int pnp_assign_dma(struct pnp_dev 1, 3, 5, 6, 7, 0, 2, 4 }; -if (!dev || !rule) -return -EINVAL ; -if (idx >=PNP_MAX_DMA ) {pnp_err ("More than 2 dmas is incompatible with pnp specifications." ); -/* pretend we were successful so at least the manager won't try again */ -return 1 ; +return ; }/* check if this resource has been manually set, if so skip */ if (!(dev->res.dma_resource[idx].flags &IORESOURCE_AUTO )) -return 1 ; +return ; start = &dev->res.dma_resource[idx].start; end = &dev->res.dma_resource[idx].end;
@@ -200,19 +196,17 @@ static int pnp_assign_dma(struct pnp_dev *flags |= rule->flags |IORESOURCE_DMA ; *flags &= ~IORESOURCE_UNSET ; -if (!rule->map) { - *flags |=IORESOURCE_DISABLED ; -return 1 ;/* skip disabled resource requests */ - } -for (i =0 ; i <8 ; i++) {if (rule->map & (1 <<xtab[i])) { *start = *end = xtab[i];if (pnp_check_dma (dev, idx)) -return 1 ; +return ; } } -return 0 ; +#ifdef MAX_DMA_CHANNELS + *start = *end =MAX_DMA_CHANNELS ; +#endif + *flags |=IORESOURCE_UNSET |IORESOURCE_DISABLED ; }/**
@@ -331,8 +325,7 @@ static int pnp_assign_resources(struct p irq = irq->next; }while (dma) { -if (!pnp_assign_dma (dev, dma, ndma)) - goto fail; +pnp_assign_dma (dev, dma, ndma); ndma++; dma = dma->next; }
@@ -367,8 +360,7 @@ static int pnp_assign_resources(struct p irq = irq->next; }while (dma) { -if (!pnp_assign_dma (dev, dma, ndma)) - goto fail; +pnp_assign_dma (dev, dma, ndma); ndma++; dma = dma->next; }
include/asm-i386/mach-xen/asm/floppy.h deleted +0 -147
147 lines not on this page · raw message
include/asm-i386/mach-xen/asm/io.h +1 -1
@@ -152,7 +152,7 @@ extern void bt_iounmap(void *addr, unsig/* * ISA I/O bus memory addresses are 1:1 with the physical address. */ -#define isa_virt_to_bus (_x) isa_virt_to_bus_is_UNSUPPORTED->x +#define isa_virt_to_bus (_x) ({ BUG(); virt_to_bus(_x); })#define isa_page_to_bus (_x) isa_page_to_bus_is_UNSUPPORTED->x#define isa_bus_to_virt (_x) (void *)(__fix_to_virt(FIX_ISAMAP_BEGIN) + (_x))
include/asm-x86_64/mach-xen/asm/floppy.h deleted +0 -206
206 lines not on this page · raw message
include/asm-x86_64/mach-xen/asm/io.h +1 -1
@@ -164,7 +164,7 @@ extern void iounmap(volatile void __iome* ISA I/O bus memory addresses are 1:1 with the physical address. */ -#define isa_virt_to_bus (_x) isa_virt_to_bus_is_UNSUPPORTED->x +#define isa_virt_to_bus (_x) ({ BUG(); virt_to_bus(_x); })#define isa_page_to_bus (_x) isa_page_to_bus_is_UNSUPPORTED->x#define isa_bus_to_virt (_x) (void *)(__fix_to_virt(FIX_ISAMAP_BEGIN) + (_x))