Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b2599a0 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Takashi Iwai
Browse files

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: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent be454366
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -117,9 +117,12 @@ int cmp_connection_init(struct cmp_connection *c,
	if (ipcr_index >= (impr & IMPR_PLUGS_MASK))
	if (ipcr_index >= (impr & IMPR_PLUGS_MASK))
		return -EINVAL;
		return -EINVAL;


	err = fw_iso_resources_init(&c->resources, unit);
	if (err < 0)
		return err;

	c->connected = false;
	c->connected = false;
	mutex_init(&c->mutex);
	mutex_init(&c->mutex);
	fw_iso_resources_init(&c->resources, unit);
	c->last_pcr_value = cpu_to_be32(0x80000000);
	c->last_pcr_value = cpu_to_be32(0x80000000);
	c->pcr_index = ipcr_index;
	c->pcr_index = ipcr_index;
	c->max_speed = (impr & IMPR_SPEED_MASK) >> IMPR_SPEED_SHIFT;
	c->max_speed = (impr & IMPR_SPEED_MASK) >> IMPR_SPEED_SHIFT;
+9 −1
Original line number Original line Diff line number Diff line
@@ -11,6 +11,7 @@
#include <linux/jiffies.h>
#include <linux/jiffies.h>
#include <linux/mutex.h>
#include <linux/mutex.h>
#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/spinlock.h>
#include "iso-resources.h"
#include "iso-resources.h"


@@ -22,12 +23,18 @@
 * If the device does not support all channel numbers, change @r->channels_mask
 * If the device does not support all channel numbers, change @r->channels_mask
 * after calling this function.
 * 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->channels_mask = ~0uLL;
	r->unit = fw_unit_get(unit);
	r->unit = fw_unit_get(unit);
	mutex_init(&r->mutex);
	mutex_init(&r->mutex);
	r->allocated = false;
	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)
void fw_iso_resources_destroy(struct fw_iso_resources *r)
{
{
	WARN_ON(r->allocated);
	WARN_ON(r->allocated);
	kfree(r->buffer);
	mutex_destroy(&r->mutex);
	mutex_destroy(&r->mutex);
	fw_unit_put(r->unit);
	fw_unit_put(r->unit);
}
}
+3 −3
Original line number Original line Diff line number Diff line
@@ -24,10 +24,10 @@ struct fw_iso_resources {
	unsigned int bandwidth_overhead;
	unsigned int bandwidth_overhead;
	int generation; /* in which allocation is valid */
	int generation; /* in which allocation is valid */
	bool allocated;
	bool allocated;
	__be32 buffer[2];
	__be32 *buffer;
};
};


void fw_iso_resources_init(struct fw_iso_resources *r,
int fw_iso_resources_init(struct fw_iso_resources *r,
			  struct fw_unit *unit);
			  struct fw_unit *unit);
void fw_iso_resources_destroy(struct fw_iso_resources *r);
void fw_iso_resources_destroy(struct fw_iso_resources *r);