Jan Beulich
2009-Nov-19 09:50 UTC
[Xen-devel] [PATCH] linux: force proper address translation in Dell RBU
Replacing virt_to_phys() by virt_to_bus(), and adding code to ensure contiguity as required by the firmware. As usual, written and tested on 2.6.27.37 and made apply to the 2.6.18 tree without further testing. Signed-off-by: Jan Beulich <jbeulich@novell.com> Tested-by: Douglas Warzecha <Douglas_Warzecha@Dell.com> --- sle11-2009-10-16.orig/drivers/firmware/dell_rbu.c 2009-02-02 09:22:26.000000000 +0100 +++ sle11-2009-10-16/drivers/firmware/dell_rbu.c 2009-10-26 16:34:16.000000000 +0100 @@ -169,9 +169,28 @@ static int create_packet(void *data, siz spin_lock(&rbu_data.lock); goto out_alloc_packet_array; } +#ifdef CONFIG_XEN + if (ordernum && xen_create_contiguous_region( + (unsigned long)packet_data_temp_buf, ordernum, 0)) { + free_pages((unsigned long)packet_data_temp_buf, + ordernum); + printk(KERN_WARNING + "dell_rbu:%s: failed to adjust new " + "packet\n", __func__); + retval = -ENOMEM; + spin_lock(&rbu_data.lock); + goto out_alloc_packet_array; + } +#endif - if ((unsigned long)virt_to_phys(packet_data_temp_buf) + if ((unsigned long)virt_to_bus(packet_data_temp_buf) < allocation_floor) { +#ifdef CONFIG_XEN + if (ordernum) + xen_destroy_contiguous_region( + (unsigned long)packet_data_temp_buf, + ordernum); +#endif pr_debug("packet 0x%lx below floor at 0x%lx.\n", (unsigned long)virt_to_phys( packet_data_temp_buf), @@ -185,7 +204,7 @@ static int create_packet(void *data, siz newpacket->data = packet_data_temp_buf; pr_debug("create_packet: newpacket at physical addr %lx\n", - (unsigned long)virt_to_phys(newpacket->data)); + (unsigned long)virt_to_bus(newpacket->data)); /* packets may not have fixed size */ newpacket->length = length; @@ -204,7 +223,7 @@ out_alloc_packet_array: /* always free packet array */ for (;idx>0;idx--) { pr_debug("freeing unused packet below floor 0x%lx.\n", - (unsigned long)virt_to_phys( + (unsigned long)virt_to_bus( invalid_addr_packet_array[idx-1])); free_pages((unsigned long)invalid_addr_packet_array[idx-1], ordernum); @@ -348,6 +367,13 @@ static void packet_empty_list(void) * to make sure there are no stale RBU packets left in memory */ memset(newpacket->data, 0, rbu_data.packetsize); +#ifdef CONFIG_XEN + if (newpacket->ordernum) + xen_destroy_contiguous_region( + (unsigned long)newpacket->data, + newpacket->ordernum); +#endif + free_pages((unsigned long) newpacket->data, newpacket->ordernum); kfree(newpacket); @@ -402,7 +428,9 @@ static int img_update_realloc(unsigned l { unsigned char *image_update_buffer = NULL; unsigned long rc; +#ifndef CONFIG_XEN unsigned long img_buf_phys_addr; +#endif int ordernum; int dma_alloc = 0; @@ -433,15 +461,19 @@ static int img_update_realloc(unsigned l spin_unlock(&rbu_data.lock); +#ifndef CONFIG_XEN ordernum = get_order(size); image_update_buffer (unsigned char *) __get_free_pages(GFP_KERNEL, ordernum); img_buf_phys_addr - (unsigned long) virt_to_phys(image_update_buffer); + (unsigned long) virt_to_bus(image_update_buffer); if (img_buf_phys_addr > BIOS_SCAN_LIMIT) { free_pages((unsigned long) image_update_buffer, ordernum); +#else + { +#endif ordernum = -1; image_update_buffer = dma_alloc_coherent(NULL, size, &dell_rbu_dmaaddr, GFP_KERNEL); @@ -706,6 +738,12 @@ static struct bin_attribute rbu_packet_s static int __init dcdrbu_init(void) { int rc = 0; + +#ifdef CONFIG_XEN + if (!is_initial_xendomain()) + return -ENODEV; +#endif + spin_lock_init(&rbu_data.lock); init_packet_head(); _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Jan Beulich
2009-Nov-19 10:01 UTC
Re: [Xen-devel] [PATCH] linux: force proper address translation in Dell RBU
>>> "Jan Beulich" <JBeulich@novell.com> 19.11.09 10:50 >>> >Replacing virt_to_phys() by virt_to_bus(), and adding code to ensure >contiguity as required by the firmware.While similar address translation changes are also needed in dcdbas, doing them is not sufficient for the driver to work under Xen. It also requires that the issuing on SMIs happens on physical CPU#0, which presently we can arrange for only by using domctl interfaces. I''m not certain however that I could, not being there is any interest in this in the first place, reliably backport to 2.6.18 the hack we use for this in our forward ported trees. Of course, some mechanism will certainly be needed in the pv-ops Dom0 case once that reaches the point where it can be used in products... Jan _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Konrad Rzeszutek Wilk
2009-Nov-19 17:22 UTC
Re: [Xen-devel] [PATCH] linux: force proper address translation in Dell RBU
On Thu, Nov 19, 2009 at 09:50:35AM +0000, Jan Beulich wrote:> Replacing virt_to_phys() by virt_to_bus(), and adding code to ensure > contiguity as required by the firmware. > > As usual, written and tested on 2.6.27.37 and made apply to the 2.6.18 > tree without further testing. > > Signed-off-by: Jan Beulich <jbeulich@novell.com> > Tested-by: Douglas Warzecha <Douglas_Warzecha@Dell.com> > > --- sle11-2009-10-16.orig/drivers/firmware/dell_rbu.c 2009-02-02 09:22:26.000000000 +0100 > +++ sle11-2009-10-16/drivers/firmware/dell_rbu.c 2009-10-26 16:34:16.000000000 +0100 > @@ -169,9 +169,28 @@ static int create_packet(void *data, siz > spin_lock(&rbu_data.lock); > goto out_alloc_packet_array; > } > +#ifdef CONFIG_XEN > + if (ordernum && xen_create_contiguous_region( > + (unsigned long)packet_data_temp_buf, ordernum, 0)) { > + free_pages((unsigned long)packet_data_temp_buf, > + ordernum); > + printk(KERN_WARNING > + "dell_rbu:%s: failed to adjust new " > + "packet\n", __func__); > + retval = -ENOMEM; > + spin_lock(&rbu_data.lock); > + goto out_alloc_packet_array; > + } > +#endifI was under the impression we did not want to create any of the #ifdef CONFIG_XEN at all. As a matter of fact, to actually eliminate or minimize the level of them. Is there no other way to do this? _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel
Konrad Rzeszutek Wilk
2009-Nov-19 17:35 UTC
Re: [Xen-devel] [PATCH] linux: force proper address translation in Dell RBU
On Thu, Nov 19, 2009 at 12:22:45PM -0500, Konrad Rzeszutek Wilk wrote:> On Thu, Nov 19, 2009 at 09:50:35AM +0000, Jan Beulich wrote: > > Replacing virt_to_phys() by virt_to_bus(), and adding code to ensure > > contiguity as required by the firmware. > > > > As usual, written and tested on 2.6.27.37 and made apply to the 2.6.18 > > tree without further testing.Duh! I need my coffee. Obviously this patch is not for the pv-ops kernel - please do ignore my comments. _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel