V4L/DVB (13408): firedtv: shrink buffer pointer table

Cache only addresses of whole pages, not of each buffer chunk.  Besides,
page addresses can be obtained by page_address() instead of kmap() since
they were allocated in lowmem.

Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
Stefan Richter 2009-11-18 16:00:55 -03:00 committed by Mauro Carvalho Chehab
parent b699c2712b
commit a8aeb7836e

View File

@ -6,9 +6,9 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <linux/firewire.h> #include <linux/firewire.h>
#include <linux/firewire-constants.h> #include <linux/firewire-constants.h>
#include <linux/highmem.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/mm.h>
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/types.h> #include <linux/types.h>
@ -73,7 +73,7 @@ struct firedtv_receive_context {
struct fw_iso_buffer buffer; struct fw_iso_buffer buffer;
int interrupt_packet; int interrupt_packet;
int current_packet; int current_packet;
char *packets[N_PACKETS]; char *pages[N_PAGES];
}; };
static int queue_iso(struct firedtv_receive_context *ctx, int index) static int queue_iso(struct firedtv_receive_context *ctx, int index)
@ -100,7 +100,7 @@ static void handle_iso(struct fw_iso_context *context, u32 cycle,
struct firedtv *fdtv = data; struct firedtv *fdtv = data;
struct firedtv_receive_context *ctx = fdtv->backend_data; struct firedtv_receive_context *ctx = fdtv->backend_data;
__be32 *h, *h_end; __be32 *h, *h_end;
int i = ctx->current_packet, length, err; int length, err, i = ctx->current_packet;
char *p, *p_end; char *p, *p_end;
for (h = header, h_end = h + header_length / 4; h < h_end; h++) { for (h = header, h_end = h + header_length / 4; h < h_end; h++) {
@ -110,7 +110,8 @@ static void handle_iso(struct fw_iso_context *context, u32 cycle,
length = MAX_PACKET_SIZE; length = MAX_PACKET_SIZE;
} }
p = ctx->packets[i]; p = ctx->pages[i / PACKETS_PER_PAGE]
+ (i % PACKETS_PER_PAGE) * MAX_PACKET_SIZE;
p_end = p + length; p_end = p + length;
for (p += CIP_HEADER_SIZE + MPEG2_TS_HEADER_SIZE; p < p_end; for (p += CIP_HEADER_SIZE + MPEG2_TS_HEADER_SIZE; p < p_end;
@ -130,8 +131,7 @@ static int start_iso(struct firedtv *fdtv)
{ {
struct firedtv_receive_context *ctx; struct firedtv_receive_context *ctx;
struct fw_device *device = device_of(fdtv); struct fw_device *device = device_of(fdtv);
char *p; int i, err;
int i, j, k, err;
ctx = kmalloc(sizeof(*ctx), GFP_KERNEL); ctx = kmalloc(sizeof(*ctx), GFP_KERNEL);
if (!ctx) if (!ctx)
@ -153,11 +153,8 @@ static int start_iso(struct firedtv *fdtv)
ctx->interrupt_packet = 1; ctx->interrupt_packet = 1;
ctx->current_packet = 0; ctx->current_packet = 0;
for (i = 0, k = 0; k < N_PAGES; k++) { for (i = 0; i < N_PAGES; i++)
p = kmap(ctx->buffer.pages[k]); ctx->pages[i] = page_address(ctx->buffer.pages[i]);
for (j = 0; j < PACKETS_PER_PAGE && i < N_PACKETS; j++, i++)
ctx->packets[i] = p + j * MAX_PACKET_SIZE;
}
for (i = 0; i < N_PACKETS; i++) { for (i = 0; i < N_PACKETS; i++) {
err = queue_iso(ctx, i); err = queue_iso(ctx, i);