Skip to contentSkip to conversation

Firewire Disk Broken in 2.4.19-pre8-ben0 kernel (was working fine with 2.4.18-ben0)

DISCUSSION Bill Fink 4 participants 9 messages May 13, 2002 – May 15, 2002

lore
Share & tools
lore

Bill Fink

author
#0 lore raw

Hi,

I was successfully using my LaCie 80 GB firewire disk drive with the 2.4.18-ben0 kernel on a dual 500 MHz G4 PPC system (with a UP kernel). However, it no longer works with the 2.4.19-pre8-ben0 kernel. I tried using the ieee1394-473 tarball but that didn't help. I also tried going back to the ieee1394-444 tarball, but that didn't help either. Here are the dmesg messages from when I modprobe ieee1394/ohci1394 (these are from using the 444 tarball):

ohci1394: $Revision: 1.101 $ Ben Collins <[email protected]>
PCI: Enabling device 02:0a.0 (0010 -> 0012)
ohci1394_0: OHCI-1394 1.0 (PCI): IRQ=[63] MMIO=[80080000-80080800] Max Packet=[2048]
ieee1394: received packet during reset; ignoring
ohci1394_0: Unexpected tcode 0xf(0x6001c1ff) in AR ctx=0, length=-1: dma prg stopped
ieee1394: ConfigROM quadlet transaction error for node 00:1023
ieee1394: Host added: Node[01:1023] GUID[00000000feeb324a] [Linux OHCI-1394]

For now, I am using the 2.4.18 ieee1394 code with the 2.4.19-pre8 kernel. For the record, here is the dmesg output from this working case:

ohci1394: $Revision: 1.98 $ Ben Collins <[email protected]>
ohci1394_0: OHCI-1394 1.0 (PCI): IRQ=[63] MMIO=[80080000-80080800] Max Packet=[2048]
ieee1394: NodeMgr: hotplug policy returned -2
ieee1394: Device added: Node[00:1023] GUID[00000000204027a1] [LaCie Group SA ]
ieee1394: Host added: Node[01:1023] GUID[00000000feeb324a] [Linux OHCI-1394]

The working 2.4.18 ieee1394 code is dated February 26 while the broken 444 tarball code is dated April 4.

-Bill

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

author
#2 lore raw
Quoted 3 lines · Ben Collins
Quoted 1 line

ohci1394: $Revision: 1.101 $ Ben Collins <[email protected]>

Try the SVN code base (check the website for how to download).

Hi Ben,

As I indicated in my earlier message, I already tried the latest ieee1394-473 tarball (dated May 13). I gave the output from the ieee1394-444 tarball (dated April 4), since that was the earliest point I knew it to be broken. For completeness, here is the dmesg output from the ieee1394-473 tarball:

ohci1394: $Rev: 460 $ Ben Collins <[email protected]>
ohci1394_0: OHCI-1394 1.0 (PCI): IRQ=[63] MMIO=[80080000-80080800] Max Packet=[2048]
ieee1394: received packet during reset; ignoring
ohci1394_0: Unexpected tcode 0xf(0x6001c1ff) in AR ctx=0, length=-1: dma prg stopped
ieee1394: ConfigROM quadlet transaction error for node 00:1023
ieee1394: Host added: Node[01:1023] GUID[00000000feeb324a] [Linux OHCI-1394]

I know it is reporting "$Rev: 460" but it is in fact from the ieee1394-473 tarball.

-Bill

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#3 lore raw
Quoted 21 lines · Bill Fink
Quoted 3 lines · Ben Collins
Quoted 1 line

ohci1394: $Revision: 1.101 $ Ben Collins <[email protected]>

Try the SVN code base (check the website for how to download).

Hi Ben,

As I indicated in my earlier message, I already tried the latest ieee1394-473 tarball (dated May 13). I gave the output from the ieee1394-444 tarball (dated April 4), since that was the earliest point I knew it to be broken. For completeness, here is the dmesg output from the ieee1394-473 tarball:

ohci1394: $Rev: 460 $ Ben Collins <[email protected]>
ohci1394_0: OHCI-1394 1.0 (PCI): IRQ=[63] MMIO=[80080000-80080800] Max Packet=[2048]
ieee1394: received packet during reset; ignoring
ohci1394_0: Unexpected tcode 0xf(0x6001c1ff) in AR ctx=0, length=-1: dma prg stopped
ieee1394: ConfigROM quadlet transaction error for node 00:1023
ieee1394: Host added: Node[01:1023] GUID[00000000feeb324a] [Linux OHCI-1394]

Quoted 2 lines

I know it is reporting "$Rev: 460" but it is in fact from the ieee1394-473 tarball.

460 was the last revision that ohci1394.c changed, so that's normal. BenH may know more about the problem here.

--
Debian - http://www.debian.org/
Linux 1394 - http://linux1394.sourceforge.net/
Subversion - http://subversion.tigris.org/
Deqo - http://www.deqo.com/

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#4 lore raw
Quoted 3 lines

460 was the last revision that ohci1394.c changed, so that's normal. BenH may know more about the problem here.

No idea, sorry. This machine has a normal OHCI (not the pismo bogus one) and so far, I had no problem with my boxes and the latest .19pre8 codebase

Ben.

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

author
#5 lore raw
In reply to Ben Collins
Quoted 22 lines · Ben Collins
Quoted 21 lines · Bill Fink
Quoted 3 lines · Ben Collins
Quoted 1 line

ohci1394: $Revision: 1.101 $ Ben Collins <[email protected]>

Try the SVN code base (check the website for how to download).

Hi Ben,

As I indicated in my earlier message, I already tried the latest ieee1394-473 tarball (dated May 13). I gave the output from the ieee1394-444 tarball (dated April 4), since that was the earliest point I knew it to be broken. For completeness, here is the dmesg output from the ieee1394-473 tarball:

ohci1394: $Rev: 460 $ Ben Collins <[email protected]>
ohci1394_0: OHCI-1394 1.0 (PCI): IRQ=[63] MMIO=[80080000-80080800] Max Packet=[2048]
ieee1394: received packet during reset; ignoring
ohci1394_0: Unexpected tcode 0xf(0x6001c1ff) in AR ctx=0, length=-1: dma prg stopped
ieee1394: ConfigROM quadlet transaction error for node 00:1023
ieee1394: Host added: Node[01:1023] GUID[00000000feeb324a] [Linux OHCI-1394]

Quoted 5 lines
Quoted 2 lines

I know it is reporting "$Rev: 460" but it is in fact from the ieee1394-473 tarball.

460 was the last revision that ohci1394.c changed, so that's normal. BenH may know more about the problem here.

Hi Ben (either or both :-),

OK, I've narrowed it down a bit. I'm enclosing a diff between a working ieee1394 CVS checkout from "26 Feb 2002 12:00" and a broken CVS checkout from "27 Feb 2002 12:00". I'm wondering if it could be a data alignment issue but since I'm not at all familiar with this code, I'll let the experts check out the diff to see if anything pops out at anyone, especially if there's anything that might be problematic for PPC.

-Thanks

-Bill

--------------------------------------------------------------------------------
Common subdirectories: ieee1394-022602/CVS and ieee1394-022702/CVS

hosts.c +43 -13
diff -u ieee1394-022602/hosts.c ieee1394-022702/hosts.c
@@ -43,6 +43,16 @@
         devctl:           dummy_devctl
 };
 
+/**
+ * hpsb_ref_host - increase reference count for host controller.
+ * @host: the host controller
+ *
+ * Increase the reference count for the specified host controller.
+ * When holding a reference to a host, the memory allocated for the
+ * host struct will not be freed and the host is guaranteed to be in a
+ * consistent state.  The driver may be unloaded or the controller may
+ * be removed (PCMCIA), but the host struct will remain valid.
+ */
 
 int hpsb_ref_host(struct hpsb_host *host)
 {
@@ -64,6 +74,15 @@
         return retval;
 }
 
+/**
+ * hpsb_unref_host - decrease reference count for host controller.
+ * @host: the host controller
+ *
+ * Decrease the reference count for the specified host controller.
+ * When the reference count reaches zero, the memory allocated for the
+ * &hpsb_host will be freed.
+ */
+
 void hpsb_unref_host(struct hpsb_host *host)
 {
         unsigned long flags;
@@ -78,26 +97,39 @@
         spin_unlock_irqrestore(&hosts_lock, flags);
 }
 
+/**
+ * hpsb_alloc_host - allocate a new host controller.
+ * @drv: the driver that will manage the host controller
+ * @extra: number of extra bytes to allocate for the driver
+ *
+ * Allocate a &hpsb_host and initialize the general subsystem specific
+ * fields.  If the driver needs to store per host data, as drivers
+ * usually do, the amount of memory required can be specified by the
+ * @extra parameter.  Once allocated, the driver should initialize the
+ * driver specific parts, enable the controller and make it available
+ * to the general subsystem using hpsb_add_host().
+ *
+ * The &hpsb_host is allocated with an single initial reference
+ * belonging to the driver.  Once the driver is done with the struct,
+ * for example, when the driver is unloaded, it should release this
+ * reference using hpsb_unref_host().
+ *
+ * Return Value: a pointer to the &hpsb_host if succesful, %NULL if
+ * no memory was available.
+ */
+
 struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra)
 {
         struct hpsb_host *h;
 
-        h = kmalloc(sizeof(struct hpsb_host), SLAB_KERNEL);
+        h = kmalloc(sizeof(struct hpsb_host) + extra, SLAB_KERNEL);
         if (!h) return NULL;
         memset(h, 0, sizeof(struct hpsb_host));
 
-	/* Drivers usually use this to allocate their private data */
-	if (extra) {
-		h->hostdata = kmalloc(extra, SLAB_KERNEL);
-		if (!h->hostdata) {
-			kfree(h);
-			return NULL;
-		}
-		memset(h->hostdata, 0, extra);
-	}
-
+	h->hostdata = h + 1;
         h->driver = drv;
         h->ops = drv->ops;
+	h->refcount = 1;
 
         INIT_LIST_HEAD(&h->pending_packets);
         spin_lock_init(&h->pending_pkt_lock);
@@ -141,9 +173,7 @@
         spin_lock_irqsave(&hosts_lock, flags);
         list_del(&host->driver_list);
         list_del(&host->host_list);
-
         drv->number_of_hosts--;
-        if (!host->refcount) kfree(host);
         spin_unlock_irqrestore(&hosts_lock, flags);
 }
 
ohci1394.c +2 -2
diff -u ieee1394-022602/ohci1394.c ieee1394-022702/ohci1394.c
@@ -161,7 +161,7 @@
 printk(level "%s_%d: " fmt "\n" , OHCI1394_DRIVER_NAME, card , ## args)
 
 static char version[] __devinitdata =
-	"$Revision: 1.98 $ Ben Collins <[email protected]>";
+	"$Revision: 1.99 $ Ben Collins <[email protected]>";
 
 /* Module Parameters */
 MODULE_PARM(attempt_root,"i");
@@ -2281,7 +2281,7 @@
 #endif /* CONFIG_ALL_PPC */
 
 	pci_set_drvdata(ohci->dev, NULL);
-	kfree(ohci);
+	hpsb_unref_host(ohci->host);
 }
 
 #define PCI_CLASS_FIREWIRE_OHCI     ((PCI_CLASS_SERIAL_FIREWIRE << 8) | 0x10)
pcilynx.c +1 -1
diff -u ieee1394-022602/pcilynx.c ieee1394-022702/pcilynx.c
@@ -1212,7 +1212,7 @@
         }
 
 	tasklet_kill(&lynx->iso_rcv.tq);
-	kfree(lynx);
+	hpsb_unref_host(lynx->host);
 }
 
 
video1394.c +1 -2
diff -u ieee1394-022602/video1394.c ieee1394-022702/video1394.c
@@ -74,8 +74,7 @@
 #define vmalloc_32(x) vmalloc(x)
 #endif
 
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,3) && LINUX_VERSION_CODE > KERNEL_VERSION(2,5,0)) || \
-	LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18)
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,3))
 #define remap_page_range_1394(vma, start, addr, size, prot) \
 	remap_page_range(start, addr, size, prot)
 #else

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

#6 lore raw

Shot in the dark....

On 14 May, this message from Bill Fink echoed through cyberspace:

Quoted 26 lines

diff -u ieee1394-022602/hosts.c ieee1394-022702/hosts.c

hosts.c +19 -0
@@ -78,26 +97,39 @@
         spin_unlock_irqrestore(&hosts_lock, flags);
 }
 
+/**
+ * hpsb_alloc_host - allocate a new host controller.
+ * @drv: the driver that will manage the host controller
+ * @extra: number of extra bytes to allocate for the driver
+ *
+ * Allocate a &hpsb_host and initialize the general subsystem specific
+ * fields.  If the driver needs to store per host data, as drivers
+ * usually do, the amount of memory required can be specified by the
+ * @extra parameter.  Once allocated, the driver should initialize the
+ * driver specific parts, enable the controller and make it available
+ * to the general subsystem using hpsb_add_host().
+ *
+ * The &hpsb_host is allocated with an single initial reference
+ * belonging to the driver.  Once the driver is done with the struct,
+ * for example, when the driver is unloaded, it should release this
+ * reference using hpsb_unref_host().
+ *
+ * Return Value: a pointer to the &hpsb_host if succesful, %NULL if
+ * no memory was available.

hosts.c line 127

Quoted 10 lines
hosts.c +3 -1
+ */
+
 struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra)
 {
         struct hpsb_host *h;
 
-        h = kmalloc(sizeof(struct hpsb_host), SLAB_KERNEL);
+        h = kmalloc(sizeof(struct hpsb_host) + extra, SLAB_KERNEL);
         if (!h) return NULL;
         memset(h, 0, sizeof(struct hpsb_host));
                        ^^^^^^^^^^^^^^^^^^^^^^^^

This should probably be sizeof(struct hpsb_host) + extra.

Quoted 8 lines
hosts.c +0 -7
-	/* Drivers usually use this to allocate their private data */
-	if (extra) {
-		h->hostdata = kmalloc(extra, SLAB_KERNEL);
-		if (!h->hostdata) {
-			kfree(h);
-			return NULL;
-		}

hosts.c line 135

Quoted 10 lines
hosts.c +2 -3
-		memset(h->hostdata, 0, extra);
-	}
-
+	h->hostdata = h + 1;
         h->driver = drv;
         h->ops = drv->ops;
+	h->refcount = 1;
 
         INIT_LIST_HEAD(&h->pending_packets);
         spin_lock_init(&h->pending_pkt_lock);

Cheers

Michel

-------------------------------------------------------------------------

Michel Lanners                 |  " Read Philosophy.  Study Art.
23, Rue Paul Henkes            |    Ask Questions.  Make Mistakes.
L-1710 Luxembourg              |
email   [email protected]            |
http://www.cpu.lu/~mlan        |                     Learn Always. "

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/

author
#8 lore raw
In reply to Michel Lanners

Hi Michel,

Nice shot! It works again with the ieee1394-473 tarball (or the distributed 2.4.19-pre8 ieee1394 code) and the change you suggested. Thanks a ton!!!

-Bill

Quoted 58 lines · Michel Lanners

Shot in the dark....

On 14 May, this message from Bill Fink echoed through cyberspace:

Quoted 26 lines

diff -u ieee1394-022602/hosts.c ieee1394-022702/hosts.c

hosts.c +19 -0
@@ -78,26 +97,39 @@
         spin_unlock_irqrestore(&hosts_lock, flags);
 }
 
+/**
+ * hpsb_alloc_host - allocate a new host controller.
+ * @drv: the driver that will manage the host controller
+ * @extra: number of extra bytes to allocate for the driver
+ *
+ * Allocate a &hpsb_host and initialize the general subsystem specific
+ * fields.  If the driver needs to store per host data, as drivers
+ * usually do, the amount of memory required can be specified by the
+ * @extra parameter.  Once allocated, the driver should initialize the
+ * driver specific parts, enable the controller and make it available
+ * to the general subsystem using hpsb_add_host().
+ *
+ * The &hpsb_host is allocated with an single initial reference
+ * belonging to the driver.  Once the driver is done with the struct,
+ * for example, when the driver is unloaded, it should release this
+ * reference using hpsb_unref_host().
+ *
+ * Return Value: a pointer to the &hpsb_host if succesful, %NULL if
+ * no memory was available.

hosts.c line 127

Quoted 10 lines
hosts.c +3 -1
+ */
+
 struct hpsb_host *hpsb_alloc_host(struct hpsb_host_driver *drv, size_t extra)
 {
         struct hpsb_host *h;
 
-        h = kmalloc(sizeof(struct hpsb_host), SLAB_KERNEL);
+        h = kmalloc(sizeof(struct hpsb_host) + extra, SLAB_KERNEL);
         if (!h) return NULL;
         memset(h, 0, sizeof(struct hpsb_host));
                        ^^^^^^^^^^^^^^^^^^^^^^^^

This should probably be sizeof(struct hpsb_host) + extra.

Quoted 16 lines
hosts.c +2 -10
-	/* Drivers usually use this to allocate their private data */
-	if (extra) {
-		h->hostdata = kmalloc(extra, SLAB_KERNEL);
-		if (!h->hostdata) {
-			kfree(h);
-			return NULL;
-		}
-		memset(h->hostdata, 0, extra);
-	}
-
+	h->hostdata = h + 1;
         h->driver = drv;
         h->ops = drv->ops;
+	h->refcount = 1;
 
Quoted 2 lines

hosts.c line 135

Quoted 2 lines
hosts.c +0 -0
         INIT_LIST_HEAD(&h->pending_packets);
         spin_lock_init(&h->pending_pkt_lock);

** Sent via the linuxppc-dev mail list. See http://lists.linuxppc.org/