Skip to contentSkip to conversation

dell_rbu: Resubmitting patch for new Dell BIOS update driver

PATCH In review Abhay Salunke 2 participants 2 messages May 13, 2005 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dell_rbu: Resubmitting patch for new Dell BIOS update driver

This is a resubmit of the patch after incorporating first round of suggestson from Andrew Morton.

By making a contribution to this project, I certify that:
The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file.

Thanks,
Abhay Salunke
Software Engineer.
DELL Inc

Documentation/DELL_RBU.txt +92 -0
diff -uprN linux-2.6.11.8.ORIG/Documentation/DELL_RBU.txt linux-2.6.11.8/Documentation/DELL_RBU.txt
@@ -0,0 +1,92 @@
+Purpose:
+Demonstrate the usage of the DELL_RBU (DELL Remote BIOS Update) driver
+for updating BIOS images on Dell hardware.
+
+Scope:
+This document discusses the functionality of the DELL_RBU driver. 
+This driver is required by BIOS update applications shipped by DELL for updating
+BIOS on DELL servers and client systems. 
+
+Overview:
+The rbu driver is designed to be running on 2.6 kernel. 
+This driver is one single dell_rbu.c file (approx 800 lines total).
+The BIOS update is done by writing the new BIOS image in to contiguous physical
+memory addressable by the BIOS. The user application indicates the BIOS regarding 
+the update of a fresh image. The BIOS then scans the memory to find the image and 
+it will then update itself. There are basically two different mechanisms for 
+writing the BIOS image in to contiguous memory 
+1> By writing the image to one single shunk of contiguous physical memory.
+2> By writing image in to smaller chunks of contiguous physical memory.
+The update mechanism is determined by the update application based on the 
+particular system type.
+
+Update mechanism using single physical chunk of memory:
+The rbu driver on its load time created the following entries in sysfs
+/sys/firmware/rbu/rbudatasize
+/sys/firmware/rbu/rbudata
+
+Steps to update the BIOS image:
+
+1> Set the incoming BIOS image size in the /sys/firmware/rbudatasize file.
+
+ e.g. echo XXXXXX > /sys/firmware/rbudatasize 
+NOTE: the size specified is always in decimal.
+
+you can also read back the image size by doing
+cat /sys/firmware/rbudatasize
+
+2> Download the BIOS image by copying the image file to /sys/firmware/rbudata 
+file.
+e.g. cat image.hdr > /sys/firmware/rbudata
+
+you can also read back the image using 
+cat /sys/firmware/rbu/rbudata
+This is usually helpful in verifying the image downloaded.
+
+Step#1 results in the driver allocating contiguous physical memory  of the size
+echoed in to rbudatasize. The subsequent writes to rbudata as described in
+step #2 results in the image getting written to the allocated contiguous physical 
+pages. Repeating step #2 will overwrite the previous data in rbudata file.
+
+On a driver unload the allocated memory is freed and the rbudatasize file reads 0.
+The user should not unload the driver after downloading the new BIOS image for 
+if it wants to update BIOS with that image.
+
+The user can overwrite the rbudata file with a new image. The user has to make 
+sure that the new image size is less than or equal to the image size copied to 
+the rbudatasize file. 
+If the new image is grater than the allocated size then only the allocated size
+gets copied the rest will not.
+
+The user can also free the previous BIOS image as follows
+echo 0 > /sys/firmware/rbu/rbudatasize
+
+If the user tries to set the BIOS image size there is a possiblity that the 
+system may not have enough contiguous physical memory for upadtes, thus the 
+image allocation will fail. The user the needs to verify this by reading back 
+the rbudatasize which will be set to 0.
+
+Update using smaller chunks (packets) of contiguous memory:
+The disadvantage of contiguous allocation is that it may not be always possible
+to get that size of contiuguous chunk of avaliable physical pages as in most 
+Linux systems the memory gets fragmented immideately after a reboot.
+The update using smaller chunks fixes this issue; it also requires the BIOS on 
+the system to support this feature; the update application needs to query this 
+with the BIOS on the system before using this technique. 
+
+The appplication breaks the BIOS image in to small packets; before starting the 
+update using this technique, the application sets the packetdatasize as follows
+
+echo XXXXXX > /sys/firmware/packetdatasize
+Any writes to /sys/firmware/packetdata results in allocation of contiguous 
+physical memory of packetdatasize and the data is written to that meomry.
+Writing 0 to packetdatasize results in freeing of all packets.
+Unloading the driver will also result in freeing up of the allocated packets.
+
+NOTE:
+Afte updating the BIOS image the appplication needs to communicate with the BIOS 
+for enabling the update on the next reboot. The application can then choose to 
+reboot the system imideately or not reboot the system and leave up to the user 
+to do a reboot.
+
+
drivers/firmware/dell_rbu.c +852 -0

852 lines not on this page · raw message

drivers/firmware/Kconfig +12 -0
diff -uprN linux-2.6.11.8.ORIG/drivers/firmware/Kconfig linux-2.6.11.8/drivers/firmware/Kconfig
@@ -58,4 +58,16 @@ config EFI_PCDP
 
 	  See <http://www.dig64.org/specifications/DIG64_HCDPv20_042804.pdf>
 
+config DELL_RBU
+        tristate "BIOS update support for DELL systems via sysfs"
+        default n
+        help
+          Say Y if you want to have the option of updating the BIOS for your
+	  DELL system. Note you need a supporting application to comunicate 
+	  with the BIOS regardign the new image for the image update to 
+	  take effect.
+
+	  See <file:Documentation/DELL_RBU.txt> for more details on the driver.
+
+
 endmenu
drivers/firmware/Makefile +1 -0
diff -uprN linux-2.6.11.8.ORIG/drivers/firmware/Makefile linux-2.6.11.8/drivers/firmware/Makefile
@@ -4,3 +4,4 @@
 obj-$(CONFIG_EDD)             	+= edd.o
 obj-$(CONFIG_EFI_VARS)		+= efivars.o
 obj-$(CONFIG_EFI_PCDP)		+= pcdp.o
+obj-$(CONFIG_DELL_RBU)		+= dell_rbu.o
#1 lore raw

On Friday 13 May 2005 23:00, Abhay Salunke wrote:
--- linux-2.6.11.8.ORIG/Documentation/DELL_RBU.txt +++ linux-2.6.11.8/Documentation/DELL_RBU.txt

Quoted 1 line

+physical memory of packetdatasize and the data is written to that meomry.

								     ^^^^^^
Quoted 1 line

+Afte updating the BIOS image the appplication needs to communicate with the BIOS

^^^^

Quoted 1 line

+reboot the system imideately or not reboot the system and leave up to the user

		     ^^^^^^^^^^

--- linux-2.6.11.8.ORIG/drivers/firmware/dell_rbu.c +++ linux-2.6.11.8/drivers/firmware/dell_rbu.c

Quoted 4 lines

+ * Changelog:
+ *
+ * 13 May 2005 Abhay Salunke <[email protected]>
+ * Modified code with suggestions from Andrew Morton;

Maintaining ChangeLogs is the job of SCM. At least don't put my name here. ;-)

Quoted 1 line

+void init_packet_head(void)

static?

drivers/firmware/dell_rbu.c line 135

Quoted 3 lines
drivers/firmware/dell_rbu.c +2 -0
+static int fill_last_packet(void *data, size_t length)
 
+	memcpy(((char *)ppacket->data + rbu_data.packet_write_count), 

No need for cast and brackets.

drivers/firmware/dell_rbu.c line 143

Quoted 3 lines
drivers/firmware/dell_rbu.c +2 -0
+		data, length);
 
+		/* adjust the total packet length */

Useless comment.

drivers/firmware/dell_rbu.c line 173

Quoted 5 lines
drivers/firmware/dell_rbu.c +3 -0
+		rbu_data.packet_write_count += length;
 
+static void *get_free_pages_limited(unsigned long size,
 
+		/* The incoming size is very large */

Useless comment.

drivers/firmware/dell_rbu.c line 179

Quoted 3 lines
drivers/firmware/dell_rbu.c +2 -0
+		pr_debug("get_free_pages_limited: Incoming size is very large\n");
 
+	pbuf =(unsigned char *)__get_free_pages(GFP_KERNEL, *ordernum);

pbuf is void *.

drivers/firmware/dell_rbu.c line 183

Quoted 1 line
drivers/firmware/dell_rbu.c +1 -0
+		img_buf_phys_addr = (unsigned long)virt_to_phys((void *)pbuf);

pbuf is void *.

drivers/firmware/dell_rbu.c line 193

Quoted 1 line
drivers/firmware/dell_rbu.c +1 -0
+			pbuf =(unsigned char *)__get_free_pages(GFP_DMA, *ordernum);

pbuf is void *.

Quoted 5 lines
drivers/firmware/dell_rbu.c +4 -0
+static int create_packet(size_t length)
 
+	newpacket = kmalloc(sizeof(struct packet_data) ,GFP_KERNEL);
+	if(newpacket == NULL) {
+		printk(KERN_WARNING"create_packet: failed to allocate new packet\n");

drivers/firmware/dell_rbu.c line 225

Quoted 10 lines
drivers/firmware/dell_rbu.c +10 -0
+		return -ENOMEM;
+	}
+
+	/* there is no upper limit on memory address for packetized mechanism */
+	newpacket->data = get_free_pages_limited(rbu_data.packetsize,&ordernum,	0);
+	pr_debug("create_packet: newpacket %p\n", newpacket->data);
+		
+	if(newpacket->data == NULL) {
+		printk(KERN_WARNING"create_packet: failed to allocate new packet\n");
+		return -ENOMEM;

You leak newpacket.

drivers/firmware/dell_rbu.c line 230

Quoted 1 line
drivers/firmware/dell_rbu.c +1 -0
+	/* initialize the newly created packet headers */

Useless comment.

drivers/firmware/dell_rbu.c line 232

Quoted 2 lines
drivers/firmware/dell_rbu.c +2 -0
+	INIT_LIST_HEAD(&newpacket->list);
+	/* add this packet to the link list */

Useless comment.

drivers/firmware/dell_rbu.c line 237

Quoted 5 lines
drivers/firmware/dell_rbu.c +5 -0
+	list_add_tail(&newpacket->list, &packet_data_head.list);
+	/* 
+	 * packets are of fixed sizes so initialize 
+	 * the length to rbu_data.packetsize
+	 */

"Packets have fixed size" is enough.

drivers/firmware/dell_rbu.c line 252

Quoted 5 lines
drivers/firmware/dell_rbu.c +3 -0
+	newpacket->length = rbu_data.packetsize;
 
+static int packetize_data(void *data, size_t length) 
 
+		/* create a new packet */

Useless comment.

drivers/firmware/dell_rbu.c line 331

Quoted 6 lines
drivers/firmware/dell_rbu.c +4 -0
+		if ((rc = create_packet(length)) != 0 )
+			return rc;
 
+static int packet_read_list(char *data, size_t *pread_length)
 
+	/* get the current read count */

Useless comment.

drivers/firmware/dell_rbu.c line 339

Quoted 6 lines
drivers/firmware/dell_rbu.c +4 -0
+	bytes_read = rbu_data.packet_read_count;
 
+	ptemp_list = (&packet_data_head.list)->next;
+	while(!list_empty(ptemp_list)) {
 
+		/* adjust the remaining bytes */

Useless comment.

drivers/firmware/dell_rbu.c line 342

Quoted 3 lines
drivers/firmware/dell_rbu.c +3 -0
+		remaining_bytes -= bytes_copied;
+		bytes_read += bytes_copied;
+		/* adjust the data pointer */

Useless comment.

drivers/firmware/dell_rbu.c line 349

Quoted 3 lines
drivers/firmware/dell_rbu.c +2 -0
+		pdest += bytes_copied;
 
+		/* point to the next packet in the list */

Useless comment.

drivers/firmware/dell_rbu.c line 367

Quoted 8 lines
drivers/firmware/dell_rbu.c +6 -0
+		ptemp_list = ptemp_list->next;
 
+static void packet_empty_list(void)
 
+	ptemp_list = (&packet_data_head.list)->next;
+	while(!list_empty(ptemp_list)) {
+		newpacket = list_entry(ptemp_list, struct packet_data, list);
+		/* get the next list ptr before we delete this entry */

Useless comment.

drivers/firmware/dell_rbu.c line 369

Quoted 2 lines
drivers/firmware/dell_rbu.c +2 -0
+		pnext_list = ptemp_list->next;
+		/* remove the list entry */

Useless comment.

drivers/firmware/dell_rbu.c line 371

Quoted 2 lines
drivers/firmware/dell_rbu.c +2 -0
+		list_del(ptemp_list);
+		/* set the list to next */

Useless comment.

drivers/firmware/dell_rbu.c line 374

Quoted 3 lines
drivers/firmware/dell_rbu.c +3 -0
+		ptemp_list = pnext_list;
+		/* zero out the RBU packet memory before freeing */
+		memset(newpacket->data, 0, rbu_data.packetsize);

For what? Useless comment, anyway.

drivers/firmware/dell_rbu.c line 375

Quoted 1 line
drivers/firmware/dell_rbu.c +1 -0
+		/* free the memory pointed by this packet */

Useless comment.

drivers/firmware/dell_rbu.c line 377

Quoted 2 lines
drivers/firmware/dell_rbu.c +2 -0
+		free_pages((unsigned long)newpacket->data, newpacket->ordernum);
+		/* now free the packet*/

Useless comment.

drivers/firmware/dell_rbu.c line 391

Quoted 3 lines
drivers/firmware/dell_rbu.c +2 -0
+		kfree(newpacket);
 
+static void img_update_free( void)
			       ^

drivers/firmware/dell_rbu.c line 397

Quoted 2 lines
drivers/firmware/dell_rbu.c +2 -0
+	/* zero out this buffer before freeing it */
+	memset(rbu_data.image_update_buffer, 0, rbu_data.image_update_buffer_size);

For what?

drivers/firmware/dell_rbu.c line 450

Quoted 7 lines
drivers/firmware/dell_rbu.c +5 -0
+ 	free_pages((unsigned long)rbu_data.image_update_buffer, 
+		rbu_data.image_update_order_number);
 
+static int img_update_realloc(unsigned long size)
 
+	if (image_update_buffer != NULL) {
+		/* store address for the new buffer */

Useless comment.

drivers/firmware/dell_rbu.c line 452

Quoted 2 lines
drivers/firmware/dell_rbu.c +2 -0
+		rbu_data.image_update_buffer = image_update_buffer;
+		/* adjust allocated size */

Useless comment.

drivers/firmware/dell_rbu.c line 454

Quoted 2 lines
drivers/firmware/dell_rbu.c +2 -0
+		rbu_data.image_update_buffer_size = PAGE_SIZE << ordernum;
+		/* save the current order number */

Useless comment.

drivers/firmware/dell_rbu.c line 456

Quoted 2 lines
drivers/firmware/dell_rbu.c +2 -0
+		rbu_data.image_update_order_number = ordernum;
+		/* initialize the new buffer data to 0 */

Useless comment.

drivers/firmware/dell_rbu.c line 459

Quoted 3 lines
drivers/firmware/dell_rbu.c +3 -0
+		memset(rbu_data.image_update_buffer,0, rbu_data.image_update_buffer_size);
+		pr_debug("img_update_realloc: success\n");
+		/* success */

Useless comment.

Review

Quoted 5 lines
(quoted diff) +3 -0
+		rc = 0; 
 
+static int __init dcdrbu_init(void)
 
+		printk(KERN_WARNING"dcdrbu_init: firmware_register failed\n");

People usually leave space after KERN_*.

Quoted 1 line

+static __exit void dcdrbu_exit( void)

				  ^

drivers/firmware/dell_rbu.c line 846

Quoted 4 lines
drivers/firmware/dell_rbu.c +4 -0
+	sysfs_remove_bin_file(&rbu_subsys.kset.kobj, &rbudata_attr );
+	sysfs_remove_bin_file(&rbu_subsys.kset.kobj, &rbudatasize_attr );
+	sysfs_remove_bin_file(&rbu_subsys.kset.kobj, &packetdatasize_attr );
+	sysfs_remove_bin_file(&rbu_subsys.kset.kobj, &packetdata_attr );

Almost trailing whitespace.

--- linux-2.6.11.8.ORIG/drivers/firmware/Kconfig
+++ linux-2.6.11.8/drivers/firmware/Kconfig

drivers/firmware/Kconfig config EFI_PCDP · line 66

Quoted 1 line
drivers/firmware/Kconfig +1 -0
+	  DELL system. Note you need a supporting application to comunicate 
								 ^^^^^^^^^^

drivers/firmware/Kconfig config EFI_PCDP · line 67

Quoted 1 line
drivers/firmware/Kconfig +1 -0
+	  with the BIOS regardign the new image for the image update to 
			^^^^^^^^^

Also, try to fit both comments and code in 80 characters, run comments through spellchecker, use consistent style for comments (

	/* foo                    /* foo
	   bar 1 */        or      * bar 1 */

) is OK.