firewire: Split the iso buffer out from fw_iso_context and avoid vmalloc.

This patch splits out the iso buffer so we can initialize it at mmap
time with the size provided in the mmap call.  Furthermore, allocate
the backing pages using alloc_page to avoid setting up kernel side
virtual memory mappings for the pages.

Signed-off-by: Kristian Høgsberg <krh@redhat.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
diff --git a/drivers/firewire/fw-transaction.h b/drivers/firewire/fw-transaction.h
index 8f0283c..89c6dda 100644
--- a/drivers/firewire/fw-transaction.h
+++ b/drivers/firewire/fw-transaction.h
@@ -27,6 +27,7 @@
 #include <linux/interrupt.h>
 #include <linux/list.h>
 #include <linux/fs.h>
+#include <linux/dma-mapping.h>
 
 #define TCODE_WRITE_QUADLET_REQUEST	0
 #define TCODE_WRITE_BLOCK_REQUEST	1
@@ -336,6 +337,18 @@
 typedef void (*fw_iso_callback_t) (struct fw_iso_context *context,
 				   int status, u32 cycle, void *data);
 
+/* An iso buffer is just a set of pages mapped for DMA in the
+ * specified direction.  Since the pages are to be used for DMA, they
+ * are not mapped into the kernel virtual address space.  We store the
+ * DMA address in the page private. The helper function
+ * fw_iso_buffer_map() will map the pages into a given vma. */
+
+struct fw_iso_buffer {
+	enum dma_data_direction direction;
+	struct page **pages;
+	int page_count;
+};
+
 struct fw_iso_context {
 	struct fw_card *card;
 	int type;
@@ -343,19 +356,24 @@
 	int speed;
 	fw_iso_callback_t callback;
 	void *callback_data;
-
-	void *buffer;
-	size_t buffer_size;
-	dma_addr_t *pages;
-	int page_count;
 };
 
+int
+fw_iso_buffer_init(struct fw_iso_buffer *buffer,
+		   struct fw_card *card,
+		   int page_count,
+		   enum dma_data_direction direction);
+int
+fw_iso_buffer_map(struct fw_iso_buffer *buffer, struct vm_area_struct *vma);
+void
+fw_iso_buffer_destroy(struct fw_iso_buffer *buffer, struct fw_card *card);
+
 struct fw_iso_context *
 fw_iso_context_create(struct fw_card *card, int type,
-		      size_t buffer_size,
 		      fw_iso_callback_t callback,
 		      void *callback_data);
 
+
 void
 fw_iso_context_destroy(struct fw_iso_context *ctx);
 
@@ -365,7 +383,9 @@
 
 int
 fw_iso_context_queue(struct fw_iso_context *ctx,
-		     struct fw_iso_packet *packet, void *payload);
+		     struct fw_iso_packet *packet,
+		     struct fw_iso_buffer *buffer,
+		     unsigned long payload);
 
 int
 fw_iso_context_send(struct fw_iso_context *ctx,
@@ -410,7 +430,9 @@
 	int (*send_iso)(struct fw_iso_context *ctx, s32 cycle);
 
 	int (*queue_iso)(struct fw_iso_context *ctx,
-			 struct fw_iso_packet *packet, void *payload);
+			 struct fw_iso_packet *packet,
+			 struct fw_iso_buffer *buffer,
+			 unsigned long payload);
 };
 
 int