All of lore.kernel.org
 help / color / mirror / Atom feed
From: Manuel Estrada Sainz <ranty@debian.org>
To: Marcel Holtmann <marcel@holtmann.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	greg@kroah.com, willy@debian.org
Subject: [PATCH] Re: Firmware loading problem
Date: Sat, 26 Jul 2003 11:04:58 +0200	[thread overview]
Message-ID: <20030726090458.GA16634@ranty.pantax.net> (raw)
In-Reply-To: <1058888301.2755.8.camel@pegasus>

[-- Attachment #1: Type: text/plain, Size: 2883 bytes --]

On Tue, Jul 22, 2003 at 05:38:15PM +0200, Marcel Holtmann wrote:
> Hi Manuel,
> 
> > > I installed linux-2.6.0-test1-ac2 and tried to port my driver for the
> > > BlueFRITZ! USB Bluetooth dongle to 2.6. This device needs a firmware
> > > download and I want to use the new firmware class for getting the
> > > firmware file from userspace. After reading the documentation and
> > > testing the driver samples I got the results that I expected.
> > > 
> > > My problem is now that the firmware loader is not working with my
> > > firmware file and it seems that this is a problem of the file size,
> > > because copying small files through the same interface is working fine.
> > > This is the file I want to load:
> > > 
> > > -rw-r--r--  1 holtmann staff  418352 Jul 11 12:38 bfubase.frm
> > > 
> > > I have written my own firmware.agent hotplug script, which looks in
> > > general something like this:
> > > 
> > > 	echo 1 > $LOADING
> > > 	cp bfubase.frm $DATA
> > > 	echo 0 > $LOADING
> > > 
> > > Loading the above firmware file through this interface results in
> > > different behaviours. The results are complete freezes, instant reboots,
> > > X server crashes with black screens and sometimes I see an oops about
> > > virtual memory, but it goes bye bye too fast to let me do anything
> > > useful with it.
> > 
> >  Could you send me a tarball with a sample showing the problem. If
> >  possible I would like to do "make test" and have it compile and crash
> >  the system appropriately :)
> 
> I tracked down the problem to request_firmware() or a sysfs problem.
> With the firmware included in a header file the driver itself works
> perfect.

 You are right, the problem was in sysfs, attached goes a patch that
 WorksForMe (tm), please test and report.

> Attached is a sample of how I use the request_firmware() and from the
> documentation it seems correct to me.

 Not what I was asking for, but it seams OK.

 About the patch:
	- undo recent change, made in the believe that "buffer" was the
	  size of the whole file, it is just PAGE_SIZE in size.
		- Since files are allowed to have unknown sizes, by
		  setting their size to 0, we can't preallocate a buffer
		  of their size on open.

	- don't use any offset when handling buffer
		- simplifies code
		- since it is temporary storage it doesn't really matter

	- undo relevant changes to request_firmware() code.

	- hopefully adapt drivers/pci/pci-sysfs.c to this changes
		- Please double check, I didn't look very carefully on
		  this.

 Have a nice day

 	Manuel
-- 
--- Manuel Estrada Sainz <ranty@debian.org>
                         <ranty@bigfoot.com>
			 <ranty@users.sourceforge.net>
------------------------ <manuel.estrada@hispalinux.es> -------------------
Let us have the serenity to accept the things we cannot change, courage to
change the things we can, and wisdom to know the difference.

[-- Attachment #2: sysfs-bin-unbreak.diff --]
[-- Type: text/plain, Size: 3299 bytes --]

Index: drivers/base/firmware_class.c
===================================================================
RCS file: /home/cvs/linux-2.5/drivers/base/firmware_class.c,v
retrieving revision 1.3
diff -u -r1.3 firmware_class.c
--- drivers/base/firmware_class.c	4 Jul 2003 02:21:18 -0000	1.3
+++ drivers/base/firmware_class.c	26 Jul 2003 06:53:47 -0000
@@ -149,7 +149,7 @@
 	if (offset + count > fw->size)
 		count = fw->size - offset;
 
-	memcpy(buffer + offset, fw->data + offset, count);
+	memcpy(buffer, fw->data + offset, count);
 	return count;
 }
 static int
@@ -198,7 +198,7 @@
 	if (retval)
 		return retval;
 
-	memcpy(fw->data + offset, buffer + offset, count);
+	memcpy(fw->data + offset, buffer, count);
 
 	fw->size = max_t(size_t, offset + count, fw->size);
 
Index: drivers/pci/pci-sysfs.c
===================================================================
RCS file: /home/cvs/linux-2.5/drivers/pci/pci-sysfs.c,v
retrieving revision 1.6
diff -u -r1.6 pci-sysfs.c
--- drivers/pci/pci-sysfs.c	4 Jul 2003 02:21:18 -0000	1.6
+++ drivers/pci/pci-sysfs.c	26 Jul 2003 06:53:50 -0000
@@ -87,7 +87,7 @@
 	while (off & 3) {
 		unsigned char val;
 		pci_read_config_byte(dev, off, &val);
-		buf[off] = val;
+		buf[0] = val;
 		off++;
 		if (--size == 0)
 			break;
@@ -96,10 +96,10 @@
 	while (size > 3) {
 		unsigned int val;
 		pci_read_config_dword(dev, off, &val);
-		buf[off] = val & 0xff;
-		buf[off + 1] = (val >> 8) & 0xff;
-		buf[off + 2] = (val >> 16) & 0xff;
-		buf[off + 3] = (val >> 24) & 0xff;
+		buf[0] = val & 0xff;
+		buf[1] = (val >> 8) & 0xff;
+		buf[2] = (val >> 16) & 0xff;
+		buf[3] = (val >> 24) & 0xff;
 		off += 4;
 		size -= 4;
 	}
@@ -107,7 +107,7 @@
 	while (size > 0) {
 		unsigned char val;
 		pci_read_config_byte(dev, off, &val);
-		buf[off] = val;
+		buf[0] = val;
 		off++;
 		--size;
 	}
@@ -129,24 +129,24 @@
 	}
 
 	while (off & 3) {
-		pci_write_config_byte(dev, off, buf[off]);
+		pci_write_config_byte(dev, off, buf[0]);
 		off++;
 		if (--size == 0)
 			break;
 	}
 
 	while (size > 3) {
-		unsigned int val = buf[off];
-		val |= (unsigned int) buf[off + 1] << 8;
-		val |= (unsigned int) buf[off + 2] << 16;
-		val |= (unsigned int) buf[off + 3] << 24;
+		unsigned int val = buf[0];
+		val |= (unsigned int) buf[1] << 8;
+		val |= (unsigned int) buf[2] << 16;
+		val |= (unsigned int) buf[3] << 24;
 		pci_write_config_dword(dev, off, val);
 		off += 4;
 		size -= 4;
 	}
 
 	while (size > 0) {
-		pci_write_config_byte(dev, off, buf[off]);
+		pci_write_config_byte(dev, off, buf[0]);
 		off++;
 		--size;
 	}
Index: fs/sysfs/bin.c
===================================================================
RCS file: /home/cvs/linux-2.5/fs/sysfs/bin.c,v
retrieving revision 1.9
diff -u -r1.9 bin.c
--- fs/sysfs/bin.c	4 Jul 2003 02:21:18 -0000	1.9
+++ fs/sysfs/bin.c	26 Jul 2003 06:53:59 -0000
@@ -47,7 +47,7 @@
 		return ret;
 	count = ret;
 
-	if (copy_to_user(userbuf, buffer + offs, count) != 0)
+	if (copy_to_user(userbuf, buffer, count) != 0)
 		return -EINVAL;
 
 	pr_debug("offs = %lld, *off = %lld, count = %zd\n", offs, *off, count);
@@ -83,7 +83,7 @@
 			count = size - offs;
 	}
 
-	if (copy_from_user(buffer + offs, userbuf, count))
+	if (copy_from_user(buffer, userbuf, count))
 		return -EFAULT;
 
 	count = flush_write(dentry, buffer, offs, count);

  reply	other threads:[~2003-07-26  8:50 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-22 14:45 Firmware loading problem Marcel Holtmann
2003-07-22 14:55 ` Manuel Estrada Sainz
2003-07-22 15:38   ` Marcel Holtmann
2003-07-26  9:04     ` Manuel Estrada Sainz [this message]
2003-07-26 11:14       ` [PATCH] " Marcel Holtmann
2003-07-26 11:26         ` Manuel Estrada Sainz
2003-07-27 19:21       ` Matthew Wilcox
2003-07-27 21:21         ` Manuel Estrada Sainz
2003-08-01 15:05           ` Manuel Estrada Sainz
2003-08-01 18:50             ` Manuel Estrada Sainz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030726090458.GA16634@ranty.pantax.net \
    --to=ranty@debian.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    --cc=willy@debian.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.