From 5b2599a07eaee53d713fb68f5343eba88fa249c0 Mon Sep 17 00:00:00 2001 From: Clemens Ladisch Date: Tue, 15 Mar 2011 07:55:50 +0100 Subject: [PATCH] ALSA: firewire-lib: allocate DMA buffer separately For correct cache coherency on some architectures, DMA buffers must be allocated in a different cache line than data that is concurrently used by the CPU. Signed-off-by: Clemens Ladisch Signed-off-by: Takashi Iwai --- sound/firewire/cmp.c | 5 ++++- sound/firewire/iso-resources.c | 10 +++++++++- sound/firewire/iso-resources.h | 6 +++--- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/sound/firewire/cmp.c b/sound/firewire/cmp.c index c992dab4bb95..4a37f3a6fab9 100644 --- a/sound/firewire/cmp.c +++ b/sound/firewire/cmp.c @@ -117,9 +117,12 @@ int cmp_connection_init(struct cmp_connection *c, if (ipcr_index >= (impr & IMPR_PLUGS_MASK)) return -EINVAL; + err = fw_iso_resources_init(&c->resources, unit); + if (err < 0) + return err; + c->connected = false; mutex_init(&c->mutex); - fw_iso_resources_init(&c->resources, unit); c->last_pcr_value = cpu_to_be32(0x80000000); c->pcr_index = ipcr_index; c->max_speed = (impr & IMPR_SPEED_MASK) >> IMPR_SPEED_SHIFT; diff --git a/sound/firewire/iso-resources.c b/sound/firewire/iso-resources.c index 6f2b5f8651fd..775dbd5f3445 100644 --- a/sound/firewire/iso-resources.c +++ b/sound/firewire/iso-resources.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include "iso-resources.h" @@ -22,12 +23,18 @@ * If the device does not support all channel numbers, change @r->channels_mask * after calling this function. */ -void fw_iso_resources_init(struct fw_iso_resources *r, struct fw_unit *unit) +int fw_iso_resources_init(struct fw_iso_resources *r, struct fw_unit *unit) { + r->buffer = kmalloc(2 * 4, GFP_KERNEL); + if (!r->buffer) + return -ENOMEM; + r->channels_mask = ~0uLL; r->unit = fw_unit_get(unit); mutex_init(&r->mutex); r->allocated = false; + + return 0; } /** @@ -37,6 +44,7 @@ void fw_iso_resources_init(struct fw_iso_resources *r, struct fw_unit *unit) void fw_iso_resources_destroy(struct fw_iso_resources *r) { WARN_ON(r->allocated); + kfree(r->buffer); mutex_destroy(&r->mutex); fw_unit_put(r->unit); } diff --git a/sound/firewire/iso-resources.h b/sound/firewire/iso-resources.h index 9feb9f8d4745..3f0730e4d841 100644 --- a/sound/firewire/iso-resources.h +++ b/sound/firewire/iso-resources.h @@ -24,11 +24,11 @@ struct fw_iso_resources { unsigned int bandwidth_overhead; int generation; /* in which allocation is valid */ bool allocated; - __be32 buffer[2]; + __be32 *buffer; }; -void fw_iso_resources_init(struct fw_iso_resources *r, - struct fw_unit *unit); +int fw_iso_resources_init(struct fw_iso_resources *r, + struct fw_unit *unit); void fw_iso_resources_destroy(struct fw_iso_resources *r); int fw_iso_resources_allocate(struct fw_iso_resources *r, -- 2.20.1