Skip to contentSkip to conversation

Missing critical phys_to_virt in lib/swiotlb.c

PATCH In review Stefan Richter 1 participant 4 messages Feb 9, 2007 – Feb 10, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Missing critical phys_to_virt in lib/swiotlb.c

Date: Sun, 04 Feb 2007 13:39:40 -0500
From: David Moore <[email protected]>

Adds missing call to phys_to_virt() in the lib/swiotlb.c:swiotlb_sync_sg() function. Without this change, a kernel panic will always occur whenever a SWIOTLB bounce buffer from a scatter-gather list gets synced.

---

This is a fraction of patch "[IA64] swiotlb bug fixes" in 2.6.20-git#, commit cde14bbfb3aa79b479db35bd29e6c083513d8614. Unlike its heading suggests, it is also important for EM64T.

Example crashes caused by swiotlb_sync_sg:
http://lists.opensuse.org/opensuse-bugs/2006-12/msg02943.html
http://qa.mandriva.com/show_bug.cgi?id=28224
http://www.pchdtv.com/forum/viewtopic.php?t=2063&sid=a959a14a4c2db0eebaab7b0df56103ce

lib/swiotlb.c +1 -1
@@ -750,7 +750,7 @@ swiotlb_sync_sg(struct device *hwdev, st
 
 	for (i = 0; i < nelems; i++, sg++)
 		if (sg->dma_address != SG_ENT_PHYS_ADDRESS(sg))
-			sync_single(hwdev, (void *) sg->dma_address,
+			sync_single(hwdev, phys_to_virt(sg->dma_address),
 				    sg->dma_length, dir, target);
 }
 
Signature · 3 lines
Stefan Richter
-=====-=-=== --=- -=-=-
http://arcgraph.de/sr/
#1 lore raw

PATCH 2/3 ieee1394: video1394: DMA fix

Date: Sat, 03 Feb 2007 03:09:09 -0500
From: David Moore <[email protected]>

This together with the phys_to_virt fix in lib/swiotlb.c::swiotlb_sync_sg fixes video1394 DMA on machines with DMA bounce buffers, especially Intel x86-64 machines with > 3GB RAM.

---
 drivers/ieee1394/video1394.c |    8 ++++++++
 1 file changed, 8 insertions(+)

same as commit a5782010b4e75cba571357efaa27df22a89427c2 in linux-2.6.20-git#

drivers/ieee1394/video1394.c +8 -0
Index: linux-2.6.20/drivers/ieee1394/video1394.c
===================================================================
@@ -489,6 +489,9 @@ static void wakeup_dma_ir_ctx(unsigned l
 			reset_ir_status(d, i);
 			d->buffer_status[d->buffer_prg_assignment[i]] = VIDEO1394_BUFFER_READY;
 			do_gettimeofday(&d->buffer_time[d->buffer_prg_assignment[i]]);
+			dma_region_sync_for_cpu(&d->dma,
+				d->buffer_prg_assignment[i] * d->buf_size,
+				d->buf_size);
 		}
 	}
 
@@ -1096,6 +1099,8 @@ static long video1394_ioctl(struct file 
 			DBGMSG(ohci->host->id, "Starting iso transmit DMA ctx=%d",
 			       d->ctx);
 			put_timestamp(ohci, d, d->last_buffer);
+			dma_region_sync_for_device(&d->dma,
+				v.buffer * d->buf_size, d->buf_size);
 
 			/* Tell the controller where the first program is */
 			reg_write(ohci, d->cmdPtr,
@@ -1111,6 +1116,9 @@ static long video1394_ioctl(struct file 
 				      "Waking up iso transmit dma ctx=%d",
 				      d->ctx);
 				put_timestamp(ohci, d, d->last_buffer);
+				dma_region_sync_for_device(&d->dma,
+					v.buffer * d->buf_size, d->buf_size);
+
 				reg_write(ohci, d->ctrlSet, 0x1000);
 			}
 		}
Signature · 3 lines
Stefan Richter
-=====-=-=== --=- -=-=-
http://arcgraph.de/sr/
#2 lore raw

PATCH 3/3 ieee1394: fix host device registering when nodemgr disabled

Date: Tue, 6 Feb 2007 02:34:45 +0100 (CET)
From: Stefan Richter <[email protected]>

Since my commit 8252bbb1363b7fe963a3eb6f8a36da619a6f5a65 in 2.6.20-rc1, host devices have a dummy driver attached. Alas the driver was not registered before use if ieee1394 was loaded with disable_nodemgr=1.

This resulted in non-functional FireWire drivers or kernel lockup.
http://bugzilla.kernel.org/show_bug.cgi?id=7942

---
 drivers/ieee1394/nodemgr.c |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

same as commit 91efa462054d44ae52b0c6c8325ed5e899f2cd17 in linux-2.6.20-git#

(Side note: The parameter disable_nodemgr=1 is merely an optional tuning parameter for people who know what they are doing and who don't need device discovery and bus management.)

drivers/ieee1394/nodemgr.c +16 -8
Index: linux-2.6.20/drivers/ieee1394/nodemgr.c
===================================================================
@@ -274,7 +274,6 @@ static struct device_driver nodemgr_mid_
 struct device nodemgr_dev_template_host = {
 	.bus		= &ieee1394_bus_type,
 	.release	= nodemgr_release_host,
-	.driver		= &nodemgr_mid_layer_driver,
 };
 
 
@@ -1889,22 +1888,31 @@ int init_ieee1394_nodemgr(void)
 
 	error = class_register(&nodemgr_ne_class);
 	if (error)
-		return error;
-
+		goto fail_ne;
 	error = class_register(&nodemgr_ud_class);
-	if (error) {
-		class_unregister(&nodemgr_ne_class);
-		return error;
-	}
+	if (error)
+		goto fail_ud;
 	error = driver_register(&nodemgr_mid_layer_driver);
+	if (error)
+		goto fail_ml;
+	/* This driver is not used if nodemgr is off (disable_nodemgr=1). */
+	nodemgr_dev_template_host.driver = &nodemgr_mid_layer_driver;
+
 	hpsb_register_highlevel(&nodemgr_highlevel);
 	return 0;
+
+fail_ml:
+	class_unregister(&nodemgr_ud_class);
+fail_ud:
+	class_unregister(&nodemgr_ne_class);
+fail_ne:
+	return error;
 }
 
 void cleanup_ieee1394_nodemgr(void)
 {
 	hpsb_unregister_highlevel(&nodemgr_highlevel);
-
+	driver_unregister(&nodemgr_mid_layer_driver);
 	class_unregister(&nodemgr_ud_class);
 	class_unregister(&nodemgr_ne_class);
 }
Signature · 3 lines
Stefan Richter
-=====-=-=== --=- -=-=-
http://arcgraph.de/sr/
#3 lore raw

Re: [stable patch 2.6.20 2/3] ieee1394: video1394: DMA fix

In reply to Stefan Richter

PS: 1/3 "Missing critical phys_to_virt in lib/swiotlb.c" and 2/3 "ieee1394: video1394: DMA fix"
are applicable to older kernels too.

Signature · 3 lines
Stefan Richter
-=====-=-=== --=- -=-=-
http://arcgraph.de/sr/