aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClemens Ladisch <clemens@ladisch.de>2011-03-15 02:55:50 -0400
committerTakashi Iwai <tiwai@suse.de>2011-03-15 03:42:28 -0400
commit5b2599a07eaee53d713fb68f5343eba88fa249c0 (patch)
tree43cd8d7bebd8b1d9f86ca8f2db69d985da82e94f
parentbe454366324b31922a2460c63c65d5e3cebe9641 (diff)
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 <clemens@ladisch.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/firewire/cmp.c5
-rw-r--r--sound/firewire/iso-resources.c10
-rw-r--r--sound/firewire/iso-resources.h6
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,
117 if (ipcr_index >= (impr & IMPR_PLUGS_MASK)) 117 if (ipcr_index >= (impr & IMPR_PLUGS_MASK))
118 return -EINVAL; 118 return -EINVAL;
119 119
120 err = fw_iso_resources_init(&c->resources, unit);
121 if (err < 0)
122 return err;
123
120 c->connected = false; 124 c->connected = false;
121 mutex_init(&c->mutex); 125 mutex_init(&c->mutex);
122 fw_iso_resources_init(&c->resources, unit);
123 c->last_pcr_value = cpu_to_be32(0x80000000); 126 c->last_pcr_value = cpu_to_be32(0x80000000);
124 c->pcr_index = ipcr_index; 127 c->pcr_index = ipcr_index;
125 c->max_speed = (impr & IMPR_SPEED_MASK) >> IMPR_SPEED_SHIFT; 128 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 @@
11#include <linux/jiffies.h> 11#include <linux/jiffies.h>
12#include <linux/mutex.h> 12#include <linux/mutex.h>
13#include <linux/sched.h> 13#include <linux/sched.h>
14#include <linux/slab.h>
14#include <linux/spinlock.h> 15#include <linux/spinlock.h>
15#include "iso-resources.h" 16#include "iso-resources.h"
16 17
@@ -22,12 +23,18 @@
22 * If the device does not support all channel numbers, change @r->channels_mask 23 * If the device does not support all channel numbers, change @r->channels_mask
23 * after calling this function. 24 * after calling this function.
24 */ 25 */
25void fw_iso_resources_init(struct fw_iso_resources *r, struct fw_unit *unit) 26int fw_iso_resources_init(struct fw_iso_resources *r, struct fw_unit *unit)
26{ 27{
28 r->buffer = kmalloc(2 * 4, GFP_KERNEL);
29 if (!r->buffer)
30 return -ENOMEM;
31
27 r->channels_mask = ~0uLL; 32 r->channels_mask = ~0uLL;
28 r->unit = fw_unit_get(unit); 33 r->unit = fw_unit_get(unit);
29 mutex_init(&r->mutex); 34 mutex_init(&r->mutex);
30 r->allocated = false; 35 r->allocated = false;
36
37 return 0;
31} 38}
32 39
33/** 40/**
@@ -37,6 +44,7 @@ void fw_iso_resources_init(struct fw_iso_resources *r, struct fw_unit *unit)
37void fw_iso_resources_destroy(struct fw_iso_resources *r) 44void fw_iso_resources_destroy(struct fw_iso_resources *r)
38{ 45{
39 WARN_ON(r->allocated); 46 WARN_ON(r->allocated);
47 kfree(r->buffer);
40 mutex_destroy(&r->mutex); 48 mutex_destroy(&r->mutex);
41 fw_unit_put(r->unit); 49 fw_unit_put(r->unit);
42} 50}
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 {
24 unsigned int bandwidth_overhead; 24 unsigned int bandwidth_overhead;
25 int generation; /* in which allocation is valid */ 25 int generation; /* in which allocation is valid */
26 bool allocated; 26 bool allocated;
27 __be32 buffer[2]; 27 __be32 *buffer;
28}; 28};
29 29
30void fw_iso_resources_init(struct fw_iso_resources *r, 30int fw_iso_resources_init(struct fw_iso_resources *r,
31 struct fw_unit *unit); 31 struct fw_unit *unit);
32void fw_iso_resources_destroy(struct fw_iso_resources *r); 32void fw_iso_resources_destroy(struct fw_iso_resources *r);
33 33
34int fw_iso_resources_allocate(struct fw_iso_resources *r, 34int fw_iso_resources_allocate(struct fw_iso_resources *r,