Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1664609 > unrolled thread
| Started by | Binoy Jayan <binoy.jayan@linaro.org> |
|---|---|
| First post | 2017-06-13 11:00 +0200 |
| Last post | 2017-06-13 12:40 +0200 |
| Articles | 4 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH v2 0/3] ngene: Replace semaphores with mutexes Binoy Jayan <binoy.jayan@linaro.org> - 2017-06-13 11:00 +0200
[PATCH v2 2/3] media: ngene: Replace semaphore stream_mutex with mutex Binoy Jayan <binoy.jayan@linaro.org> - 2017-06-13 11:00 +0200
Re: [PATCH v2 0/3] ngene: Replace semaphores with mutexes Arnd Bergmann <arnd@arndb.de> - 2017-06-13 12:00 +0200
Re: [PATCH v2 0/3] ngene: Replace semaphores with mutexes Binoy Jayan <binoy.jayan@linaro.org> - 2017-06-13 12:40 +0200
| From | Binoy Jayan <binoy.jayan@linaro.org> |
|---|---|
| Date | 2017-06-13 11:00 +0200 |
| Subject | [PATCH v2 0/3] ngene: Replace semaphores with mutexes |
| Message-ID | <tRPQ5-5MF-5@gated-at.bofh.it> |
These are a set of patches [v2] which removes semaphores from ngene. These are part of a bigger effort to eliminate unwanted semaphores from the linux kernel. v1 --> v2 --------- Moved mutex_[lock/unlock] outside caller for stream_mutex mutex_lock converted to mutex_destroy in cmd_mutex Binoy Jayan (3): media: ngene: Replace semaphore cmd_mutex with mutex media: ngene: Replace semaphore stream_mutex with mutex media: ngene: Replace semaphore i2c_switch_mutex with mutex drivers/media/pci/ngene/ngene-core.c | 32 ++++++++++++++------------------ drivers/media/pci/ngene/ngene-i2c.c | 6 +++--- drivers/media/pci/ngene/ngene.h | 6 +++--- 3 files changed, 20 insertions(+), 24 deletions(-) -- Binoy Jayan
[toc] | [next] | [standalone]
| From | Binoy Jayan <binoy.jayan@linaro.org> |
|---|---|
| Date | 2017-06-13 11:00 +0200 |
| Subject | [PATCH v2 2/3] media: ngene: Replace semaphore stream_mutex with mutex |
| Message-ID | <tRPQ6-5MF-21@gated-at.bofh.it> |
| In reply to | #1664609 |
The semaphore 'stream_mutex' is used as a simple mutex, so
it should be written as one. Also moving the mutex_[lock/unlock]
to the caller as it is anyway locked at the beginning of the
callee thus avoiding repetition.
Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
drivers/media/pci/ngene/ngene-core.c | 18 +++++++-----------
drivers/media/pci/ngene/ngene.h | 2 +-
2 files changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/media/pci/ngene/ngene-core.c b/drivers/media/pci/ngene/ngene-core.c
index eeb61eb..ea64901 100644
--- a/drivers/media/pci/ngene/ngene-core.c
+++ b/drivers/media/pci/ngene/ngene-core.c
@@ -560,7 +560,6 @@ static int ngene_command_stream_control(struct ngene *dev, u8 stream,
u16 BsSPI = ((stream & 1) ? 0x9800 : 0x9700);
u16 BsSDO = 0x9B00;
- down(&dev->stream_mutex);
memset(&com, 0, sizeof(com));
com.cmd.hdr.Opcode = CMD_CONTROL;
com.cmd.hdr.Length = sizeof(struct FW_STREAM_CONTROL) - 2;
@@ -586,17 +585,13 @@ static int ngene_command_stream_control(struct ngene *dev, u8 stream,
chan->State = KSSTATE_ACQUIRE;
chan->HWState = HWSTATE_STOP;
spin_unlock_irq(&chan->state_lock);
- if (ngene_command(dev, &com) < 0) {
- up(&dev->stream_mutex);
+ if (ngene_command(dev, &com) < 0)
return -1;
- }
/* clear_buffers(chan); */
flush_buffers(chan);
- up(&dev->stream_mutex);
return 0;
}
spin_unlock_irq(&chan->state_lock);
- up(&dev->stream_mutex);
return 0;
}
@@ -692,11 +687,9 @@ static int ngene_command_stream_control(struct ngene *dev, u8 stream,
chan->HWState = HWSTATE_STARTUP;
spin_unlock_irq(&chan->state_lock);
- if (ngene_command(dev, &com) < 0) {
- up(&dev->stream_mutex);
+ if (ngene_command(dev, &com) < 0)
return -1;
- }
- up(&dev->stream_mutex);
+
return 0;
}
@@ -750,8 +743,11 @@ void set_transfer(struct ngene_channel *chan, int state)
/* else printk(KERN_INFO DEVICE_NAME ": lock=%08x\n",
ngreadl(0x9310)); */
+ mutex_lock(&dev->stream_mutex);
ret = ngene_command_stream_control(dev, chan->number,
control, mode, flags);
+ mutex_unlock(&dev->stream_mutex);
+
if (!ret)
chan->running = state;
else
@@ -1347,7 +1343,7 @@ static int ngene_start(struct ngene *dev)
init_waitqueue_head(&dev->tx_wq);
init_waitqueue_head(&dev->rx_wq);
mutex_init(&dev->cmd_mutex);
- sema_init(&dev->stream_mutex, 1);
+ mutex_init(&dev->stream_mutex);
sema_init(&dev->pll_mutex, 1);
sema_init(&dev->i2c_switch_mutex, 1);
spin_lock_init(&dev->cmd_lock);
diff --git a/drivers/media/pci/ngene/ngene.h b/drivers/media/pci/ngene/ngene.h
index e600b70..0dd15d6 100644
--- a/drivers/media/pci/ngene/ngene.h
+++ b/drivers/media/pci/ngene/ngene.h
@@ -763,7 +763,7 @@ struct ngene {
wait_queue_head_t cmd_wq;
int cmd_done;
struct mutex cmd_mutex;
- struct semaphore stream_mutex;
+ struct mutex stream_mutex;
struct semaphore pll_mutex;
struct semaphore i2c_switch_mutex;
int i2c_current_channel;
--
Binoy Jayan
[toc] | [prev] | [next] | [standalone]
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Date | 2017-06-13 12:00 +0200 |
| Message-ID | <tRQMb-6li-23@gated-at.bofh.it> |
| In reply to | #1664609 |
On Tue, Jun 13, 2017 at 10:58 AM, Binoy Jayan <binoy.jayan@linaro.org> wrote:
> These are a set of patches [v2] which removes semaphores from ngene.
> These are part of a bigger effort to eliminate unwanted semaphores
> from the linux kernel.
All three
Acked-by: Arnd Bergmann <arnd@arndb.de>
I already gave an Ack for one or two of the patches in the first round, but
you seem to have dropped that. When you resend a patch with an Ack,
please include that above your Signed-off-by line. (No need to resend
for an Ack otherwise, this normally gets picked up when the patch
gets applied from the list.
Arnd
[toc] | [prev] | [next] | [standalone]
| From | Binoy Jayan <binoy.jayan@linaro.org> |
|---|---|
| Date | 2017-06-13 12:40 +0200 |
| Message-ID | <tRRoS-6Pq-13@gated-at.bofh.it> |
| In reply to | #1664664 |
Hi Arnd, On 13 June 2017 at 15:19, Arnd Bergmann <arnd@arndb.de> wrote: > On Tue, Jun 13, 2017 at 10:58 AM, Binoy Jayan <binoy.jayan@linaro.org> wrote: >> These are a set of patches [v2] which removes semaphores from ngene. >> These are part of a bigger effort to eliminate unwanted semaphores >> from the linux kernel. > > All three > > Acked-by: Arnd Bergmann <arnd@arndb.de> > > I already gave an Ack for one or two of the patches in the first round, but > you seem to have dropped that. When you resend a patch with an Ack, > please include that above your Signed-off-by line. (No need to resend > for an Ack otherwise, this normally gets picked up when the patch > gets applied from the list. Sorry I dropped it as there were changes in two of the patches. But there were obvious ones anyway. Thanks, Binoy
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web