void *crcsr_kernel;
dma_addr_t crcsr_bus;
struct vme_master_resource *flush_image;
-struct semaphore vme_rmw; /* Only one RMW cycle at a time */
-struct semaphore vme_int; /*
+struct mutex vme_rmw; /* Only one RMW cycle at a time */
+struct mutex vme_int; /*
* Only one VME interrupt can be
* generated at a time, provide locking
*/
-struct semaphore vme_irq; /* Locking for VME irq callback configuration */
-struct semaphore vme_lm; /* Locking for location monitor operations */
+struct mutex vme_irq; /* Locking for VME irq callback configuration */
+struct mutex vme_lm; /* Locking for location monitor operations */
static char driver_name[] = "vme_tsi148";
{
u32 tmp;
- /* Get semaphore */
- down(&(vme_irq));
+ mutex_lock(&(vme_irq));
if(tsi148_bridge->irq[level - 1].callback[statid].func) {
- up(&(vme_irq));
+ mutex_unlock(&(vme_irq));
printk("VME Interrupt already taken\n");
return -EBUSY;
}
tmp |= TSI148_LCSR_INTEN_IRQEN[level - 1];
iowrite32be(tmp, tsi148_bridge->base + TSI148_LCSR_INTEN);
- /* Release semaphore */
- up(&(vme_irq));
+ mutex_unlock(&(vme_irq));
return 0;
}
u32 tmp;
struct pci_dev *pdev;
- /* Get semaphore */
- down(&(vme_irq));
+ mutex_lock(&(vme_irq));
tsi148_bridge->irq[level - 1].count--;
tsi148_bridge->irq[level - 1].callback[statid].func = NULL;
tsi148_bridge->irq[level - 1].callback[statid].priv_data = NULL;
- /* Release semaphore */
- up(&(vme_irq));
+ mutex_unlock(&(vme_irq));
}
/*
* Generate a VME bus interrupt at the requested level & vector. Wait for
* interrupt to be acked.
- *
- * Only one interrupt can be generated at a time - so add a semaphore.
*/
int tsi148_generate_irq(int level, int statid)
{
u32 tmp;
- /* Get semaphore */
- down(&(vme_int));
+ mutex_lock(&(vme_int));
/* Read VICR register */
tmp = ioread32be(tsi148_bridge->base + TSI148_LCSR_VICR);
/* XXX Consider implementing a timeout? */
wait_event_interruptible(iack_queue, tsi148_iack_received());
- /* Release semaphore */
- up(&(vme_int));
+ mutex_unlock(&(vme_int));
return 0;
}
}
-/* XXX We need to change vme_master_resource->sem to a spinlock so that read
+/* XXX We need to change vme_master_resource->mtx to a spinlock so that read
* and write functions can be used in an interrupt context
*/
ssize_t tsi148_master_write(struct vme_master_resource *image, void *buf,
i = image->number;
/* Locking as we can only do one of these at a time */
- down(&(vme_rmw));
+ mutex_lock(&(vme_rmw));
/* Lock image */
spin_lock(&(image->lock));
spin_unlock(&(image->lock));
- up(&(vme_rmw));
+ mutex_unlock(&(vme_rmw));
return result;
}
ctrlr = list->parent;
- down(&(ctrlr->sem));
+ mutex_lock(&(ctrlr->mtx));
channel = ctrlr->number;
* Return busy.
*/
/* Need to add to pending here */
- up(&(ctrlr->sem));
+ mutex_unlock(&(ctrlr->mtx));
return -EBUSY;
} else {
list_add(&(list->list), &(ctrlr->running));
bus_addr = virt_to_bus(&(entry->descriptor));
- up(&(ctrlr->sem));
+ mutex_unlock(&(ctrlr->mtx));
reg_split(bus_addr, &bus_addr_high, &bus_addr_low);
}
/* Remove list from running list */
- down(&(ctrlr->sem));
+ mutex_lock(&(ctrlr->mtx));
list_del(&(list->list));
- up(&(ctrlr->sem));
+ mutex_unlock(&(ctrlr->mtx));
return retval;
}
u32 lm_base_high, lm_base_low, lm_ctl = 0;
int i;
- /* Get semaphore */
- down(&(vme_lm));
+ mutex_lock(&(vme_lm));
/* If we already have a callback attached, we can't move it! */
for (i = 0; i < 4; i++) {
if(lm_callback[i] != NULL) {
- up(&(vme_lm));
+ mutex_unlock(&(vme_lm));
printk("Location monitor callback attached, can't "
"reset\n");
return -EBUSY;
lm_ctl |= TSI148_LCSR_LMAT_AS_A64;
break;
default:
- up(&(vme_lm));
+ mutex_unlock(&(vme_lm));
printk("Invalid address space\n");
return -EINVAL;
break;
iowrite32be(lm_base_low, tsi148_bridge->base + TSI148_LCSR_LMBAL);
iowrite32be(lm_ctl, tsi148_bridge->base + TSI148_LCSR_LMAT);
- up(&(vme_lm));
+ mutex_unlock(&(vme_lm));
return 0;
}
{
u32 lm_base_high, lm_base_low, lm_ctl, enabled = 0;
- /* Get semaphore */
- down(&(vme_lm));
+ mutex_lock(&(vme_lm));
lm_base_high = ioread32be(tsi148_bridge->base + TSI148_LCSR_LMBAU);
lm_base_low = ioread32be(tsi148_bridge->base + TSI148_LCSR_LMBAL);
if (lm_ctl & TSI148_LCSR_LMAT_DATA)
*cycle |= VME_DATA;
- up(&(vme_lm));
+ mutex_unlock(&(vme_lm));
return enabled;
}
{
u32 lm_ctl, tmp;
- /* Get semaphore */
- down(&(vme_lm));
+ mutex_lock(&(vme_lm));
/* Ensure that the location monitor is configured - need PGM or DATA */
lm_ctl = ioread32be(tsi148_bridge->base + TSI148_LCSR_LMAT);
if ((lm_ctl & (TSI148_LCSR_LMAT_PGM | TSI148_LCSR_LMAT_DATA)) == 0) {
- up(&(vme_lm));
+ mutex_unlock(&(vme_lm));
printk("Location monitor not properly configured\n");
return -EINVAL;
}
/* Check that a callback isn't already attached */
if (lm_callback[monitor] != NULL) {
- up(&(vme_lm));
+ mutex_unlock(&(vme_lm));
printk("Existing callback attached\n");
return -EBUSY;
}
iowrite32be(lm_ctl, tsi148_bridge->base + TSI148_LCSR_LMAT);
}
- up(&(vme_lm));
+ mutex_unlock(&(vme_lm));
return 0;
}
{
u32 lm_en, tmp;
- /* Get semaphore */
- down(&(vme_lm));
+ mutex_lock(&(vme_lm));
/* Disable Location Monitor and ensure previous interrupts are clear */
lm_en = ioread32be(tsi148_bridge->base + TSI148_LCSR_INTEN);
iowrite32be(tmp, tsi148_bridge->base + TSI148_LCSR_LMAT);
}
- up(&(vme_lm));
+ mutex_unlock(&(vme_lm));
return 0;
}
init_waitqueue_head(&dma_queue[0]);
init_waitqueue_head(&dma_queue[1]);
init_waitqueue_head(&iack_queue);
- init_MUTEX(&(vme_int));
- init_MUTEX(&(vme_irq));
- init_MUTEX(&(vme_rmw));
- init_MUTEX(&(vme_lm));
+ mutex_init(&(vme_int));
+ mutex_init(&(vme_irq));
+ mutex_init(&(vme_rmw));
+ mutex_init(&(vme_lm));
tsi148_bridge->parent = &(pdev->dev);
strcpy(tsi148_bridge->name, driver_name);
goto err_slave;
}
slave_image->parent = tsi148_bridge;
- init_MUTEX(&(slave_image->sem));
+ mutex_init(&(slave_image->mtx));
slave_image->locked = 0;
slave_image->number = i;
slave_image->address_attr = VME_A16 | VME_A24 | VME_A32 |
goto err_dma;
}
dma_ctrlr->parent = tsi148_bridge;
- init_MUTEX(&(dma_ctrlr->sem));
+ mutex_init(&(dma_ctrlr->mtx));
dma_ctrlr->locked = 0;
dma_ctrlr->number = i;
INIT_LIST_HEAD(&(dma_ctrlr->pending));
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/syscalls.h>
-#include <linux/semaphore.h>
+#include <linux/mutex.h>
#include <linux/spinlock.h>
#include "vme.h"
#include "vme_bridge.h"
-/* Bitmask and semaphore to keep track of bridge numbers */
+/* Bitmask and mutex to keep track of bridge numbers */
static unsigned int vme_bus_numbers;
-DECLARE_MUTEX(vme_bus_num_sem);
+DEFINE_MUTEX(vme_bus_num_mtx);
static void __exit vme_exit (void);
static int __init vme_init (void);
}
/* Find an unlocked and compatible image */
- down(&(slave_image->sem));
+ mutex_lock(&(slave_image->mtx));
if(((slave_image->address_attr & address) == address) &&
((slave_image->cycle_attr & cycle) == cycle) &&
(slave_image->locked == 0)) {
slave_image->locked = 1;
- up(&(slave_image->sem));
+ mutex_unlock(&(slave_image->mtx));
allocated_image = slave_image;
break;
}
- up(&(slave_image->sem));
+ mutex_unlock(&(slave_image->mtx));
}
/* No free image */
err_alloc:
/* Unlock image */
- down(&(slave_image->sem));
+ mutex_lock(&(slave_image->mtx));
slave_image->locked = 0;
- up(&(slave_image->sem));
+ mutex_unlock(&(slave_image->mtx));
err_image:
err_bus:
return NULL;
}
/* Unlock image */
- down(&(slave_image->sem));
+ mutex_lock(&(slave_image->mtx));
if (slave_image->locked == 0)
printk(KERN_ERR "Image is already free\n");
slave_image->locked = 0;
- up(&(slave_image->sem));
+ mutex_unlock(&(slave_image->mtx));
/* Free up resource memory */
kfree(resource);
}
/* Find an unlocked controller */
- down(&(dma_ctrlr->sem));
+ mutex_lock(&(dma_ctrlr->mtx));
if(dma_ctrlr->locked == 0) {
dma_ctrlr->locked = 1;
- up(&(dma_ctrlr->sem));
+ mutex_unlock(&(dma_ctrlr->mtx));
allocated_ctrlr = dma_ctrlr;
break;
}
- up(&(dma_ctrlr->sem));
+ mutex_unlock(&(dma_ctrlr->mtx));
}
/* Check to see if we found a resource */
err_alloc:
/* Unlock image */
- down(&(dma_ctrlr->sem));
+ mutex_lock(&(dma_ctrlr->mtx));
dma_ctrlr->locked = 0;
- up(&(dma_ctrlr->sem));
+ mutex_unlock(&(dma_ctrlr->mtx));
err_ctrlr:
err_bus:
return NULL;
}
INIT_LIST_HEAD(&(dma_list->entries));
dma_list->parent = ctrlr;
- init_MUTEX(&(dma_list->sem));
+ mutex_init(&(dma_list->mtx));
return dma_list;
}
return -EINVAL;
}
- if (down_trylock(&(list->sem))) {
+ if (mutex_trylock(&(list->mtx))) {
printk("Link List already submitted\n");
return -EINVAL;
}
retval = bridge->dma_list_add(list, src, dest, count);
- up(&(list->sem));
+ mutex_unlock(&(list->mtx));
return retval;
}
return -EINVAL;
}
- down(&(list->sem));
+ mutex_lock(&(list->mtx));
retval = bridge->dma_list_exec(list);
- up(&(list->sem));
+ mutex_unlock(&(list->mtx));
return retval;
}
return -EINVAL;
}
- if (down_trylock(&(list->sem))) {
+ if (mutex_trylock(&(list->mtx))) {
printk("Link List in use\n");
return -EINVAL;
}
retval = bridge->dma_list_empty(list);
if (retval) {
printk("Unable to empty link-list entries\n");
- up(&(list->sem));
+ mutex_unlock(&(list->mtx));
return retval;
}
- up(&(list->sem));
+ mutex_unlock(&(list->mtx));
kfree(list);
return retval;
ctrlr = list_entry(resource->entry, struct vme_dma_resource, list);
- if (down_trylock(&(ctrlr->sem))) {
+ if (mutex_trylock(&(ctrlr->mtx))) {
printk("Resource busy, can't free\n");
return -EBUSY;
}
if (!(list_empty(&(ctrlr->pending)) && list_empty(&(ctrlr->running)))) {
printk("Resource still processing transfers\n");
- up(&(ctrlr->sem));
+ mutex_unlock(&(ctrlr->mtx));
return -EBUSY;
}
ctrlr->locked = 0;
- up(&(ctrlr->sem));
+ mutex_unlock(&(ctrlr->mtx));
return 0;
}
{
int i;
- down(&vme_bus_num_sem);
+ mutex_lock(&vme_bus_num_mtx);
for (i = 0; i < sizeof(vme_bus_numbers) * 8; i++) {
if (((vme_bus_numbers >> i) & 0x1) == 0) {
vme_bus_numbers |= (0x1 << i);
break;
}
}
- up(&vme_bus_num_sem);
+ mutex_unlock(&vme_bus_num_mtx);
return i;
}
static void vme_free_bus_num(int bus)
{
- down(&vme_bus_num_sem);
+ mutex_lock(&vme_bus_num_mtx);
vme_bus_numbers |= ~(0x1 << bus);
- up(&vme_bus_num_sem);
+ mutex_unlock(&vme_bus_num_mtx);
}
int vme_register_bridge (struct vme_bridge *bridge)