diff options
author | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2018-05-23 13:12:01 +0200 |
---|---|---|
committer | Marcin Chrzanowski <marcin.j.chrzanowski@gmail.com> | 2018-05-23 13:12:01 +0200 |
commit | d910393a63f610d55c07408fd6f4547b86635988 (patch) | |
tree | 1971329fa21f81f8518327c8a7925813ab9f264d | |
parent | 962a5da1e9e7e3c3a0966720c0484308077918b7 (diff) |
Separate mutual exclusion for commands and ping
-rw-r--r-- | pci.c | 5 | ||||
-rw-r--r-- | private_data.h | 4 | ||||
-rw-r--r-- | surface.c | 8 |
3 files changed, 8 insertions, 9 deletions
@@ -20,7 +20,6 @@ irqreturn_t doom_irq(int irq, void *dev) uint32_t interrupts; struct doom_data *doom_data; - doom_data = dev; interrupts = get_interrupts(doom_data->iomem); @@ -59,8 +58,8 @@ int init_pci(struct pci_dev *dev) pci_set_dma_mask(dev, DMA_BIT_MASK(32)); pci_set_consistent_dma_mask(dev, DMA_BIT_MASK(32)); - mutex_init(&doom_data->mutex); - sema_init(&doom_data->ping_sem, 1); + mutex_init(&doom_data->cmd_mutex); + mutex_init(&doom_data->ping_mutex); sema_init(&doom_data->pong_sem, 0); ORFAIL(request_irq(dev->irq, doom_irq, IRQF_SHARED, diff --git a/private_data.h b/private_data.h index 39ceba8..0325b93 100644 --- a/private_data.h +++ b/private_data.h @@ -9,8 +9,8 @@ struct doom_data { struct device *device; struct device *pci_device; void __iomem *iomem; - struct mutex mutex; - struct semaphore ping_sem; + struct mutex cmd_mutex; + struct mutex ping_mutex; struct semaphore pong_sem; }; @@ -22,13 +22,13 @@ long draw_lines(struct file *filp, unsigned long arg) param = (struct doomdev_surf_ioctl_draw_lines *) arg; lines = (struct doomdev_line *) param->lines_ptr; - mutex_lock(&surface_data->doom_data->mutex); + mutex_lock(&surface_data->doom_data->cmd_mutex); for (i = 0; i < param->lines_num; i++) { draw_line(surface_data, lines[i]); } - mutex_unlock(&surface_data->doom_data->mutex); + mutex_unlock(&surface_data->doom_data->cmd_mutex); return param->lines_num; } @@ -58,7 +58,7 @@ ssize_t surface_read(struct file *filp, char __user *buf, size_t count, count = surface_data->surface_size - *offset; } - mutex_lock(&surface_data->doom_data->mutex); + mutex_lock(&surface_data->doom_data->ping_mutex); ping_sync(surface_data->doom_data->iomem); down(&surface_data->doom_data->pong_sem); @@ -68,7 +68,7 @@ ssize_t surface_read(struct file *filp, char __user *buf, size_t count, *offset += count - not_written; - mutex_unlock(&surface_data->doom_data->mutex); + mutex_unlock(&surface_data->doom_data->ping_mutex); return count - not_written; } |