Skip to contentSkip to conversation

dell_rbu: New Dell BIOS update driver

PATCH In review Abhay Salunke 6 participants 7 messages May 10, 2005 – May 11, 2005 Documentation

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dell_rbu: New Dell BIOS update driver

The dell_rbu driver is required for updating BIOS on DELL servers and client systems. The driver lets a user application download the BIOS image in to contiguous physical memory pages; the driver exposes the memory via sysfs filesystem. The update mechanism basically has two approcahes; one by allocating contiguous physical memory and the second approach is by allocating small chunks of contiguous physical memory.

The patch file is attached to this mail.

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. echo 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 +862 -0

862 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
+        bool "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
Quoted 9 lines · Abhay Salunke

The dell_rbu driver is required for updating BIOS on DELL servers and client systems. The driver lets a user application download the BIOS image in to contiguous physical memory pages; the driver exposes the memory via sysfs filesystem. The update mechanism basically has two approcahes; one by allocating contiguous physical memory and the second approach is by allocating small chunks of contiguous physical memory.

The patch file is attached to this mail.

Greg, could you please review the sysfs usage?

Documentation/DELL_RBU.txt

Quoted 2 lines
Documentation/DELL_RBU.txt +0 -0

2.6.11.8 is very old in kernel terms. It's OK for this patch because it's pretty standalone. But in general, please raise patches against contemporary kernels. 2.6.12-rc4 would be appropriate at present.

Documentation/DELL_RBU.txt

Quoted 2 lines
Documentation/DELL_RBU.txt +2 -0
+
+#define BIT(x)	(1UL << ((x)%BITS_PER_LONG))

This is used only for:

+ rbu_data.image_update_buffer_size = BIT(ordernum) * PAGE_SIZE;

Please remove BIT() and just do

+ rbu_data.image_update_buffer_size = PAGE_SIZE << ordernum;

Documentation/DELL_RBU.txt

Quoted 2 lines
Documentation/DELL_RBU.txt +2 -0
+
+static struct {

Some gcc's don't like anonymous structs (I think?). Still, it would be more conventional to give this guy a name.

Documentation/DELL_RBU.txt

Quoted 10 lines
Documentation/DELL_RBU.txt +10 -0
+	void *image_update_buffer;
+	unsigned long image_update_buffer_size;
+	unsigned long bios_image_size;
+	unsigned long image_update_order_number;
+	spinlock_t lock;
+	unsigned long packet_read_count;
+	unsigned long packet_write_count;
+	unsigned long num_packets;
+	unsigned long packetsize;
+}rbu_data ;

Make this

   } rbu_data;
Quoted 1 line

+struct packet_data{

   struct packet_data {

Documentation/DELL_RBU.txt

Quoted 3 lines
Documentation/DELL_RBU.txt +3 -0
+       struct list_head list;
+       size_t length;
+       void *rbu_data;

Should that be

	struct rbu_data *rbu_data;

?

Documentation/DELL_RBU.txt

Quoted 3 lines
Documentation/DELL_RBU.txt +3 -0
+
+static decl_subsys(rbu,&ktype_rbu,NULL);
+
   static decl_subsys(rbu, &ktype_rbu, NULL);
Quoted 4 lines
Documentation/DELL_RBU.txt +4 -0
+static void init_rbu_lock(void *plock)
+{
+	spin_lock_init((spinlock_t *)plock);
+}

Documentation/DELL_RBU.txt

Quoted 10 lines
Documentation/DELL_RBU.txt +10 -0
+
+static void lock_rbu_access(void *plock)
+{
+	spin_lock((spinlock_t *)plock);
+}
+
+static void unlock_rbu_access(void *plock)
+{
+	spin_unlock((spinlock_t *)plock);
+}

Remove these and simply open-code the spinlock functions.

Documentation/DELL_RBU.txt

Quoted 3 lines
Documentation/DELL_RBU.txt +3 -0
+void init_packet_head(void)
+{
+	INIT_LIST_HEAD((struct list_head *)&packet_data_head);

OK, in lots of places the patch typecasts packet_data_head to a list_head, then does list_head operations on it, relying on the fact that packet_data.list is the first element. Very weird.

Please replace all those with (for example)

	INIT_LIST_HEAD(&packet_data_head.list);

Documentation/DELL_RBU.txt

Quoted 10 lines
Documentation/DELL_RBU.txt +10 -0
+static int fill_last_packet(void *data, size_t length)
+{
+	struct list_head *ptemp_list;
+	struct packet_data *ppacket = NULL;
+	int packet_count = 0;
+	
+	pr_debug("fill_last_packet: entry \n");
+
+	/* check if we have any packets */
+	if (0 == rbu_data.num_packets){

I know that some people like the `if (constant == variable)' thing to pick up "= instead of ==" typos. But gcc does warn about that mistake anyway, and I think most people find the above construct to be artificial, and harder to read. Would prefer that all these be swapped around please.

Would also prefer a space before the '{'!

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	ptemp_list = ((struct list_head *)&packet_data_head)->next;

Use packet_head_data.list

Documentation/DELL_RBU.txt

Quoted 3 lines
Documentation/DELL_RBU.txt +3 -0
+	
+	while(--packet_count)
+	{
	while (--packet_count) {

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	if ((rbu_data.packet_write_count + length) >  rbu_data.packetsize) {
                                                    ^^

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+		printk(KERN_WARNING"fill_last_packet: packet size data overrun\n");

^ space here

Documentation/DELL_RBU.txt

Quoted 4 lines
Documentation/DELL_RBU.txt +4 -0
+*/
+static void *get_free_pages_limited(unsigned long size,
+									int *ordernum,
+									unsigned long limit)

Wild whitespace here?

Documentation/DELL_RBU.txt

Quoted 2 lines
Documentation/DELL_RBU.txt +2 -0
+{
+	unsigned long ImgBufPhysAddr;

Please stick with lower case and underscores in identifiers.

Documentation/DELL_RBU.txt

Quoted 5 lines
Documentation/DELL_RBU.txt +5 -0
+	void *pbuf = NULL;
+
+	*ordernum = get_order(size);
+	/* check if we are not getting a very large file 
+	This can happen as a user error in entering the file size */

The comment layout is a bit odd.

	/*
	 * Check if we are not getting a very large file.  This can happen
	 * as a user error in entering the file size.
	 */

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	if (*ordernum == BITS_PER_LONG){

^ space

Quoted 6 lines
Documentation/DELL_RBU.txt +6 -0
+		/* The incoming size is very large */
+		pr_debug("get_free_pages_limited: Incoming size is very large\n");
+		return NULL;
+	}
+	
+	/* try allocating a new buffer to fit the request */

Documentation/DELL_RBU.txt

Quoted 10 lines
Documentation/DELL_RBU.txt +10 -0
+    pbuf =(unsigned char *)__get_free_pages(GFP_KERNEL, *ordernum);
+
+	if (pbuf != NULL) {
+		/* check if the image is with in limits */
+		ImgBufPhysAddr = (unsigned long)virt_to_phys((void *)pbuf);
+		
+		if ((limit != 0) &&
+			((ImgBufPhysAddr + size) > limit)) {
+			
+			pr_debug("Got memory above 4GB range, free this and try with DMA memory\n");

The indenting has gone funny here.

Quoted 4 lines
Documentation/DELL_RBU.txt +4 -0
+			
+			/* free this memory as we need it with in 4GB range */
+			free_pages ((unsigned long)pbuf, *ordernum);
+			

Documentation/DELL_RBU.txt

Quoted 10 lines
Documentation/DELL_RBU.txt +10 -0
+			/* try allocating a new buffer from the GFP_DMA range 
+			   as it is with in 16MB range.*/
+			pbuf =(unsigned char *)__get_free_pages(GFP_DMA, *ordernum);
+			
+			if (pbuf == NULL)
+				pr_debug("Failed to get memory of size %ld using GFP_DMA\n", size);
+		}
+	}
+	return pbuf;
+}

What architecture is this code designed for? On x86 a GFP_KERNEL allocation will never return highmem. I guess x86_64?

I assume this code is here because the x86_64 BIOS will only access the lower 4GB? If so, a comment to that extent would be useful.

Sometime I expect that x86_64 will gain a new zone, GFP_DMA32 which will be guaranteed to return memory below he 4GB point. When that happens, this driver should be converted to use it.

Documentation/DELL_RBU.txt

Quoted 4 lines
Documentation/DELL_RBU.txt +4 -0
+static int create_packet(size_t length)
+{
+	struct packet_data *newpacket;
+	int ordernum =0;

^ space

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	newpacket = kmalloc(sizeof(struct packet_data) , GFP_KERNEL);
                                                      ^

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	if(newpacket == NULL){

^ ^ spaces

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	if(newpacket->rbu_data == NULL){

Ditto. Lots of places.

Documentation/DELL_RBU.txt

Quoted 11 lines
Documentation/DELL_RBU.txt +11 -0
+		printk(KERN_WARNING"create_packet: failed to allocate new packet\n");
+		return -ENOMEM;
+	}
+
+	newpacket->ordernum = ordernum;
+
+	++rbu_data.num_packets;
+	/* initialize the newly created packet headers */
+	INIT_LIST_HEAD(&newpacket->list);
+	/* add this packet to the link list */
+	list_add_tail(&newpacket->list, (struct list_head *)&packet_data_head);

Does this list not need locking?

Use packet_data_head.list, remove the typecast.

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	/* packets are of fixed sizes so initialize the length to rbu_data.packetsize*/

Try to fit the code into an 80-column xterm, please.

Documentation/DELL_RBU.txt

Quoted 13 lines
Documentation/DELL_RBU.txt +13 -0
+/*
+ do_packet_read :
+ This is a helper function which reads the packet data of the 
+ current list.
+ data: is the incoming buffer
+ ptemp_list: points to the incoming list item
+ length: is the length of the free space in the buffer.
+ bytes_read: is the total number of bytes read already from 
+ the packet list
+ list_read_count: is the counter to keep track of the number 
+ of bytes read out of each packet.
+*/
+int do_packet_read(char * data, struct list_head *ptemp_list, int length,

It's (a bit) more conventional to not have the space after the `*' when declaring pointers:

char *data

Here, both styles are used in the same line!

Documentation/DELL_RBU.txt

Quoted 3 lines
Documentation/DELL_RBU.txt +3 -0
+{
+	void *ptemp_buf;
+	struct packet_data *newpacket = NULL;

This initialisation is unneeded.

Documentation/DELL_RBU.txt

Quoted 2 lines
Documentation/DELL_RBU.txt +2 -0
+	int bytes_copied = 0;
+	void *pDest = data;

lowercase and underscore in identifiers

Documentation/DELL_RBU.txt

Quoted 10 lines
Documentation/DELL_RBU.txt +10 -0
+	int j = 0;
+
+	newpacket = list_entry(ptemp_list,struct packet_data, list);
+	*list_read_count += newpacket->length;
+
+	if (*list_read_count > bytes_read) {
+		/* point to the start of unread data */
+		j = newpacket->length - (*list_read_count - bytes_read);
+		/* point to the offset in the packet buffer*/
+		ptemp_buf = (u8 *)newpacket->rbu_data + j;

The cast is actually unneeded - gcc will treat void* as a "pointer to something which has sizeof==1" when performing such arithmetic. I believe this is a gcc extension.

Documentation/DELL_RBU.txt

Quoted 2 lines
Documentation/DELL_RBU.txt +2 -0
+		/* check if there is enough room in the 
+		incoming buffer*/

Odd comment layout.

Quoted 7 lines
Documentation/DELL_RBU.txt +7 -0
+/*
+ packet_read_list:
+ This function reads the data out of the packet link list.
+ It will read data from multiple packets depending upon the 
+ size of the incoming buffer.
+ data: is the incoming buffer pointer
+ *pread_length: is the length of the incoming buffer. At return 

Documentation/DELL_RBU.txt

Quoted 10 lines
Documentation/DELL_RBU.txt +10 -0
+ this value is adjusted to the actual size of the data read.
+*/
+static int packet_read_list(char *data, size_t *pread_length)
+{
+	struct list_head *ptemp_list;
+	int temp_count = 0;
+	int bytes_copied = 0;
+	int bytes_read = 0;
+	int remaining_bytes =0;
+	char *pDest = data;

Are all these initialisations actually needed?

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	ptemp_list = ((struct list_head *)&packet_data_head)->next;

packet_data_head.next

Documentation/DELL_RBU.txt

Quoted 2 lines
Documentation/DELL_RBU.txt +2 -0
+	while(!list_empty(ptemp_list))
+	{
	while (!list_empty(ptemp_list)) {

Documentation/DELL_RBU.txt

Quoted 7 lines
Documentation/DELL_RBU.txt +7 -0
+static void packet_empty_list(void)
+{
+	struct list_head *ptemp_list;
+	struct list_head *pnext_list;
+	struct packet_data *newpacket;
+
+	ptemp_list = ((struct list_head *)&packet_data_head)->next;

ditto

Documentation/DELL_RBU.txt

Quoted 2 lines
Documentation/DELL_RBU.txt +2 -0
+	while(!list_empty(ptemp_list))
+	{

ditto

I think list_for_each_entry_safe() would work here.

Documentation/DELL_RBU.txt

Quoted 6 lines
Documentation/DELL_RBU.txt +6 -0
+/*
+ img_update_free:
+ Frees the buffer allocated for storing BIOS image
+ Always called with lock held
+*/
+static void img_update_free( void)

static void img_update_free(void)

Documentation/DELL_RBU.txt

Quoted 3 lines
Documentation/DELL_RBU.txt +3 -0
+{
+	if (rbu_data.image_update_buffer == NULL)
+		return;

Can this happen?

Documentation/DELL_RBU.txt

Quoted 7 lines
Documentation/DELL_RBU.txt +7 -0
+	/* zero out this buffer before freeing it */
+	memset(rbu_data.image_update_buffer, 0, rbu_data.image_update_buffer_size);
+	/* unlock as free_pages might sleep */
+	unlock_rbu_access(&rbu_data.lock);
+ 	free_pages((unsigned long)rbu_data.image_update_buffer, 
+		rbu_data.image_update_order_number);
+	lock_rbu_access(&rbu_data.lock);

free_pages() will never sleep.

Documentation/DELL_RBU.txt

Quoted 4 lines
Documentation/DELL_RBU.txt +4 -0
+	rbu_data.image_update_buffer = NULL;
+	rbu_data.image_update_buffer_size = 0;
+	rbu_data.bios_image_size = 0;
+}

Are these assignments needed?

Documentation/DELL_RBU.txt

Quoted 13 lines
Documentation/DELL_RBU.txt +13 -0
+static int img_update_realloc(unsigned long size)
+{
+	unsigned char *image_update_buffer = NULL;
+	unsigned long rc;
+	int ordernum =0;
+
+
+	/* check if the buffer of sufficient size has been already allocated */
+    if (rbu_data.image_update_buffer_size >= size) {
+		/* check for corruption */
+		if ((size != 0) && (rbu_data.image_update_buffer == NULL)) {
+			pr_debug("img_update_realloc: corruption check failed\n");
+			return -ENOMEM;

ENOMEM seems to be the wrong error to return here.

Quoted 4 lines
Documentation/DELL_RBU.txt +4 -0
+		}
+		/* we have a valid pre-allocated buffer with sufficient size */
+		return 0;
+    }

Documentation/DELL_RBU.txt

Quoted 10 lines
Documentation/DELL_RBU.txt +10 -0
+
+	/* free any previously allocated buffer */
+	img_update_free();
+
+	/* This has already been called as locked so we can now unlock 
+	and proceed to calling get_free_pages_limited as this function
+	can sleep*/
+	unlock_rbu_access(&rbu_data.lock);
+
+	image_update_buffer = (unsigned char *)get_free_pages_limited(size,

get_free_pages_limited() returns void*, so no typecast is needed.

Documentation/DELL_RBU.txt

Quoted 4 lines
Documentation/DELL_RBU.txt +4 -0
+		&ordernum,
+		BIOS_SCAN_LIMIT);
+	
+	/* acquire the semaphore again */

It's actually a spinlock, not a semaphore.

Quoted 12 lines
Documentation/DELL_RBU.txt +12 -0
+	lock_rbu_access(&rbu_data.lock);
+
+	if (image_update_buffer != NULL) {
+		/* store address for the new buffer */
+		rbu_data.image_update_buffer = image_update_buffer;
+		/* adjust allocated size */
+		rbu_data.image_update_buffer_size = BIT(ordernum) * PAGE_SIZE;
+		/* save the current order number */
+		rbu_data.image_update_order_number = ordernum;
+		/* initialize the new buffer data to 0 */
+		memset(rbu_data.image_update_buffer,0, rbu_data.image_update_buffer_size);
+		pr_debug("img_update_realloc: success\n");

Documentation/DELL_RBU.txt

Quoted 10 lines
Documentation/DELL_RBU.txt +10 -0
+		/* success */
+		rc = 0; 
+	} else {
+		pr_debug("Not enough memory for image update:order number = %d"
+			",size = %ld\n",ordernum, size);
+		rc = -ENOMEM;
+	}
+
+	return rc;
+} /* img_update_realloc */

The comment over img_update_realloc() should mention that it returns with the lock held.

Documentation/DELL_RBU.txt

Quoted 13 lines
Documentation/DELL_RBU.txt +13 -0
+
+/*
+ read_packet_data_size:
+ Returns the size of an RBU packet; if no packets present returns 0
+*/
+static ssize_t read_packet_data_size(struct kobject *kobj, char *buffer, 
+								  loff_t pos, size_t count)
+{
+	unsigned int size = 0;
+	if (pos == 0) {
+		lock_rbu_access(&rbu_data.lock);
+		size = sprintf(buffer, "%lu\n", rbu_data.packetsize);
+		unlock_rbu_access(&rbu_data.lock);

The locking here is meaningless. rbu_data.packetsize can change any time before or after the read.

Quoted 4 lines
Documentation/DELL_RBU.txt +4 -0
+	}
+	return size;
+} 
+

Documentation/DELL_RBU.txt

Quoted 10 lines
Documentation/DELL_RBU.txt +10 -0
+/*
+ write_packet_data_size:
+ Writes the RBU data size supplied by the user, if the 
+ data size supplied is non zero number, this function 
+ records the packet size for any packet allocations.
+ If a byte size of zero is supplied this function will free
+ the previously allocated packets.
+*/
+static ssize_t write_packet_data_size(struct kobject *kobj, char *buffer, 
+								   loff_t pos, size_t count)

80-cols.

Documentation/DELL_RBU.txt

Quoted 2 lines
Documentation/DELL_RBU.txt +2 -0
+static ssize_t read_rbu_data_size(struct kobject *kobj, char *buffer, 
+								  loff_t pos, size_t count)

ditto.

Documentation/DELL_RBU.txt

Quoted 6 lines
Documentation/DELL_RBU.txt +6 -0
+{
+	unsigned int size = 0;
+	if (pos == 0) {
+		lock_rbu_access(&rbu_data.lock);
+		size = sprintf(buffer, "%lu\n", rbu_data.bios_image_size);
+		unlock_rbu_access(&rbu_data.lock);

Unneeded or incorrect locking?

Documentation/DELL_RBU.txt

Quoted 3 lines
Documentation/DELL_RBU.txt +3 -0
+*/
+static ssize_t write_rbu_data_size(struct kobject *kobj, char *buffer, 
+								   loff_t pos, size_t count)

80-cols?

Documentation/DELL_RBU.txt

Quoted 7 lines
Documentation/DELL_RBU.txt +7 -0
+static ssize_t read_rbu_data(struct kobject *kobj, char *buffer, 
+							 loff_t pos, size_t count)
+{
+	unsigned char *ptemp = NULL;
+	int retVal =0;
+	int bytes_left = 0;
+	int data_length = 0;

Unneeded initialisations. Please review all the code for that.

s/retVal/retval/

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	data_length = ((bytes_left > count) ? count : bytes_left);

max()?

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	ptemp = (char *)rbu_data.image_update_buffer;

unneeded typecast

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	memcpy(buffer, (char *)(ptemp + pos), data_length);

unneeded typecast

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	if ( pos > imagesize ) {

Quite a mix of coding styles in this patch!

Documentation/DELL_RBU.txt

Quoted 1 line
Documentation/DELL_RBU.txt +1 -0
+	data_length = ((bytes_left > count) ? count : bytes_left);

max()

Documentation/DELL_RBU.txt

Quoted 11 lines
Documentation/DELL_RBU.txt +11 -0
+	if ((retVal = packet_read_list(ptempBuf, &data_length)) < 0)
+		goto read_rbu_data_exit;
+
+	if ((pos + count) > imagesize) {
+		rbu_data.packet_read_count = 0;
+		/* this was the last copy */
+		retVal = bytes_left;
+	}
+	else 
+		retVal = count;
+	
	} else {
		retVal = count;
	}

(opinions differ...)

Documentation/DELL_RBU.txt

Quoted 8 lines
Documentation/DELL_RBU.txt +8 -0
+	sysfs_create_bin_file(&rbu_subsys.kset.kobj, &rbudata_attr );
+	sysfs_create_bin_file(&rbu_subsys.kset.kobj, &rbudatasize_attr );
+	sysfs_create_bin_file(&rbu_subsys.kset.kobj, &packetdatasize_attr );
+	sysfs_create_bin_file(&rbu_subsys.kset.kobj, &packetdata_attr );
+	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 );

whitepsace

Documentation/DELL_RBU.txt

Quoted 12 lines
Documentation/DELL_RBU.txt +11 -0
+config DELL_RBU
+        bool "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.
+

Should this feature be available for all architectures, or only for X86 || X86_64? (If it compiles OK for other architectures then I'd leave it as-is, for coverage).

The patch seems to alternate between using hard tabs and using eight-spaces. Hard tabs are preferred. Please hunt that down and fix it up.

#2 lore raw
Quoted 18 lines · Andrew Morton
Quoted 4 lines
drivers/firmware/dell_rbu.c +4 -0
+			
+			/* free this memory as we need it with in 4GB range */
+			free_pages ((unsigned long)pbuf, *ordernum);
+			

drivers/firmware/dell_rbu.c line 209

Quoted 10 lines
drivers/firmware/dell_rbu.c +10 -0
+			/* try allocating a new buffer from the GFP_DMA range 
+			   as it is with in 16MB range.*/
+			pbuf =(unsigned char *)__get_free_pages(GFP_DMA, *ordernum);
+			
+			if (pbuf == NULL)
+				pr_debug("Failed to get memory of size %ld using GFP_DMA\n", size);
+		}
+	}
+	return pbuf;
+}

What architecture is this code designed for? On x86 a GFP_KERNEL allocation will never return highmem. I guess x86_64?

Quoted 6 lines

I assume this code is here because the x86_64 BIOS will only access the lower 4GB? If so, a comment to that extent would be useful.

Sometime I expect that x86_64 will gain a new zone, GFP_DMA32 which will be guaranteed to return memory below he 4GB point. When that happens, this driver should be converted to use it.

Almost always when this happens the driver actually wanted to use pci_alloc_consistent memory... (i've not seen the rest of the driver yet so can't say how appropriate that would be here)

#3 lore raw
In reply to Abhay Salunke
Quoted 13 lines · Abhay Salunke
drivers/firmware/dell_rbu.c +13 -0
+static struct bin_attribute rbudata_attr = {
+	.attr = {.name = "rbudata", .owner = THIS_MODULE, .mode = 0644},
+	.read = read_rbu_data,
+	.write = write_rbu_data,
+};
+
+static struct bin_attribute rbudatasize_attr = {
+	.attr = { .name = "rbudatasize", .owner = THIS_MODULE, .mode = 0644 },
+	.read = read_rbu_data_size,
+	.write= write_rbu_data_size,
+};
+
+static struct bin_attribute packetdatasize_attr = {

drivers/firmware/dell_rbu.c line 823

Quoted 10 lines
drivers/firmware/dell_rbu.c +10 -0
+	.attr = { .name = "packetdatasize", .owner = THIS_MODULE, .mode = 0644 },
+	.read = read_packet_data_size,
+	.write= write_packet_data_size,
+};
+
+static struct bin_attribute packetdata_attr = {
+	.attr = { .name = "packetdata", .owner = THIS_MODULE, .mode = 0644 },
+	.read = read_rbu_packet_data,
+	.write= write_rbu_packet_data,
+};

I can understand having the data use the sysfs binary attribute, but do not do this for the size files. Please just use a normal attribute for them, the binary ones are _only_ for blobs of data that are not interpreted by the kernel.

thanks,

greg k-h

#4 lore raw
In reply to Abhay Salunke
Quoted 8 lines · Abhay Salunke

The dell_rbu driver is required for updating BIOS on DELL servers and client systems. The driver lets a user application download the BIOS image in to contiguous physical memory pages; the driver exposes the memory via sysfs filesystem. The update mechanism basically has two approcahes; one by allocating contiguous physical memory and the second approach is by allocating small chunks of contiguous physical memory.

The patch file is attached to this mail.

I wonder if this wouldn't be able to use the request_firmware() interface instead... I mean, it would simplify the sysfs code a lot I suspect.

#5 lore raw
In reply to Abhay Salunke

Documentation/DELL_RBU.txt line 40

Quoted 3 lines · Abhay Salunke

+2> Download the BIOS image by copying the image file to /sys/firmware/rbudata

Documentation/DELL_RBU.txt +2 -0
+file.
+e.g. echo image.hdr > /sys/firmware/rbudata

Don't you mean 'cat' instead of 'echo' there ?

Xav

#6 lore raw
In reply to Abhay Salunke
Quoted 6 lines · Abhay Salunke

The dell_rbu driver is required for updating BIOS on DELL servers and client systems. The driver lets a user application download the BIOS image in to contiguous physical memory pages; the driver exposes the memory via sysfs filesystem. The update mechanism basically has two approcahes; one by allocating contiguous physical memory and the second approach is by allocating small chunks of contiguous physical memory.

[snip]

drivers/firmware/Kconfig config EFI_PCDP · line 62

Quoted 9 lines

diff -uprN linux-2.6.11.8.ORIG/drivers/firmware/Kconfig linux-2.6.11.8/drivers/firmware/Kconfig

drivers/firmware/Kconfig +2 -0
@@ -58,4 +58,16 @@ config EFI_PCDP
 
 	  See <http://www.dig64.org/specifications/DIG64_HCDPv20_042804.pdf>
 
+config DELL_RBU
+        bool "BIOS update support for DELL systems via sysfs"

Trivial: needs to be tristate, not bool, to make a module. Change help text then accordingly.

Thanks,
Matt

Signature · 4 lines
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com