public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] firewire: fw-ohci: fix possible IOMMU resource exhaustion
@ 2008-12-09 23:20 Stefan Richter
  2008-12-10 20:16 ` Jarod Wilson
  0 siblings, 1 reply; 2+ messages in thread
From: Stefan Richter @ 2008-12-09 23:20 UTC (permalink / raw)
  To: linux1394-devel; +Cc: linux-kernel

There is a DMA map/ unmap imbalance whenever a block write request
packet is sent and then dequeued with ohci_cancel_packet.  The latter
may happen frequently if the AR resp tasklet is executed before the AT
req tasklet for the same transaction.

Add the missing dma_unmap_single.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---

This was spotted due to https://bugzilla.redhat.com/show_bug.cgi?id=475156,
but whether the patch already fixes bug 475156 has yet to be tested.

 drivers/firewire/fw-ohci.c        |   11 +++++++----
 drivers/firewire/fw-transaction.c |    3 +++
 drivers/firewire/fw-transaction.h |    2 ++
 3 files changed, 12 insertions(+), 4 deletions(-)

Index: linux/drivers/firewire/fw-ohci.c
===================================================================
--- linux.orig/drivers/firewire/fw-ohci.c
+++ linux/drivers/firewire/fw-ohci.c
@@ -974,6 +974,7 @@ at_context_queue_packet(struct context *
 			packet->ack = RCODE_SEND_ERROR;
 			return -1;
 		}
+		packet->payload_bus = payload_bus;
 
 		d[2].req_count    = cpu_to_le16(packet->payload_length);
 		d[2].data_address = cpu_to_le32(payload_bus);
@@ -1025,7 +1026,6 @@ static int handle_at_packet(struct conte
 	struct driver_data *driver_data;
 	struct fw_packet *packet;
 	struct fw_ohci *ohci = context->ohci;
-	dma_addr_t payload_bus;
 	int evt;
 
 	if (last->transfer_status == 0)
@@ -1038,9 +1038,8 @@ static int handle_at_packet(struct conte
 		/* This packet was cancelled, just continue. */
 		return 1;
 
-	payload_bus = le32_to_cpu(last->data_address);
-	if (payload_bus != 0)
-		dma_unmap_single(ohci->card.device, payload_bus,
+	if (packet->payload_bus)
+		dma_unmap_single(ohci->card.device, packet->payload_bus,
 				 packet->payload_length, DMA_TO_DEVICE);
 
 	evt = le16_to_cpu(last->transfer_status) & 0x1f;
@@ -1697,6 +1696,10 @@ static int ohci_cancel_packet(struct fw_
 	if (packet->ack != 0)
 		goto out;
 
+	if (packet->payload_bus)
+		dma_unmap_single(ohci->card.device, packet->payload_bus,
+				 packet->payload_length, DMA_TO_DEVICE);
+
 	log_ar_at_event('T', packet->speed, packet->header, 0x20);
 	driver_data->packet = NULL;
 	packet->ack = RCODE_CANCELLED;
Index: linux/drivers/firewire/fw-transaction.c
===================================================================
--- linux.orig/drivers/firewire/fw-transaction.c
+++ linux/drivers/firewire/fw-transaction.c
@@ -208,6 +208,7 @@ fw_fill_request(struct fw_packet *packet
 	packet->speed = speed;
 	packet->generation = generation;
 	packet->ack = 0;
+	packet->payload_bus = 0;
 }
 
 /**
@@ -582,6 +583,8 @@ fw_fill_response(struct fw_packet *respo
 		BUG();
 		return;
 	}
+
+	response->payload_bus = 0;
 }
 EXPORT_SYMBOL(fw_fill_response);
 
Index: linux/drivers/firewire/fw-transaction.h
===================================================================
--- linux.orig/drivers/firewire/fw-transaction.h
+++ linux/drivers/firewire/fw-transaction.h
@@ -27,6 +27,7 @@
 #include <linux/list.h>
 #include <linux/spinlock_types.h>
 #include <linux/timer.h>
+#include <linux/types.h>
 #include <linux/workqueue.h>
 
 #define TCODE_IS_READ_REQUEST(tcode)	(((tcode) & ~1) == 4)
@@ -153,6 +154,7 @@ struct fw_packet {
 	size_t header_length;
 	void *payload;
 	size_t payload_length;
+	dma_addr_t payload_bus;
 	u32 timestamp;
 
 	/*

-- 
Stefan Richter
-=====-==--- ==-- -=-=-
http://arcgraph.de/sr/


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] firewire: fw-ohci: fix possible IOMMU resource exhaustion
  2008-12-09 23:20 [PATCH] firewire: fw-ohci: fix possible IOMMU resource exhaustion Stefan Richter
@ 2008-12-10 20:16 ` Jarod Wilson
  0 siblings, 0 replies; 2+ messages in thread
From: Jarod Wilson @ 2008-12-10 20:16 UTC (permalink / raw)
  To: linux1394-devel; +Cc: Stefan Richter, linux-kernel

On Tuesday 09 December 2008 18:20:38 Stefan Richter wrote:
> There is a DMA map/ unmap imbalance whenever a block write request
> packet is sent and then dequeued with ohci_cancel_packet.  The latter
> may happen frequently if the AR resp tasklet is executed before the AT
> req tasklet for the same transaction.
> 
> Add the missing dma_unmap_single.
> 
> Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>

Going to get this into the Fedora kernels ASAP, definitely looks like
it'll at least help w/the IOMMU issues.

Nb: from what I recall, I saw such problems on an 8-way opteron pretty
frequently with a debug-enabled kernel, haven't seen it on the same
box running a release kernel (but also haven't tried the bug reporters
reproducer).

Signed-off-by: Jarod Wilson <jarod@redhat.com>

-- 
Jarod Wilson
jarod@redhat.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-12-10 20:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-09 23:20 [PATCH] firewire: fw-ohci: fix possible IOMMU resource exhaustion Stefan Richter
2008-12-10 20:16 ` Jarod Wilson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox