linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] ngene: Replace semaphores with mutexes
@ 2017-06-08 10:04 Binoy Jayan
  2017-06-08 10:04 ` [PATCH 1/3] media: ngene: Replace semaphore cmd_mutex with mutex Binoy Jayan
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Binoy Jayan @ 2017-06-08 10:04 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: linux-kernel, Arnd Bergmann, Rajendra, Mark Brown,
	Mauro Carvalho Chehab, Sakari Ailus, Julia Lawall,
	Michael S. Tsirkin, Cao jin, linux-media

These are a set of patches which removes semaphores from ngene.
These are part of a bigger effort to eliminate unwanted semaphores
from the linux kernel.

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 | 28 ++++++++++++++--------------
 drivers/media/pci/ngene/ngene-i2c.c  |  6 +++---
 drivers/media/pci/ngene/ngene.h      |  6 +++---
 3 files changed, 20 insertions(+), 20 deletions(-)

-- 
Binoy Jayan

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 1/3] media: ngene: Replace semaphore cmd_mutex with mutex
  2017-06-08 10:04 [PATCH 0/3] ngene: Replace semaphores with mutexes Binoy Jayan
@ 2017-06-08 10:04 ` Binoy Jayan
  2017-06-08 15:10   ` Arnd Bergmann
  2017-06-08 10:04 ` [PATCH 2/3] media: ngene: Replace semaphore stream_mutex " Binoy Jayan
  2017-06-08 10:04 ` [PATCH 3/3] media: ngene: Replace semaphore i2c_switch_mutex " Binoy Jayan
  2 siblings, 1 reply; 10+ messages in thread
From: Binoy Jayan @ 2017-06-08 10:04 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: linux-kernel, Arnd Bergmann, Rajendra, Mark Brown,
	Mauro Carvalho Chehab, Sakari Ailus, Julia Lawall,
	Michael S. Tsirkin, Cao jin, linux-media

The semaphore 'cmd_mutex' is used as a simple mutex, so
it should be written as one. Semaphores are going away in the future.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
 drivers/media/pci/ngene/ngene-core.c | 12 ++++++------
 drivers/media/pci/ngene/ngene.h      |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/media/pci/ngene/ngene-core.c b/drivers/media/pci/ngene/ngene-core.c
index ce69e64..dfbd1e0 100644
--- a/drivers/media/pci/ngene/ngene-core.c
+++ b/drivers/media/pci/ngene/ngene-core.c
@@ -336,9 +336,9 @@ int ngene_command(struct ngene *dev, struct ngene_command *com)
 {
 	int result;
 
-	down(&dev->cmd_mutex);
+	mutex_lock(&dev->cmd_mutex);
 	result = ngene_command_mutex(dev, com);
-	up(&dev->cmd_mutex);
+	mutex_unlock(&dev->cmd_mutex);
 	return result;
 }
 
@@ -1283,7 +1283,7 @@ static int ngene_load_firm(struct ngene *dev)
 
 static void ngene_stop(struct ngene *dev)
 {
-	down(&dev->cmd_mutex);
+	mutex_lock(&dev->cmd_mutex);
 	i2c_del_adapter(&(dev->channel[0].i2c_adapter));
 	i2c_del_adapter(&(dev->channel[1].i2c_adapter));
 	ngwritel(0, NGENE_INT_ENABLE);
@@ -1346,7 +1346,7 @@ static int ngene_start(struct ngene *dev)
 	init_waitqueue_head(&dev->cmd_wq);
 	init_waitqueue_head(&dev->tx_wq);
 	init_waitqueue_head(&dev->rx_wq);
-	sema_init(&dev->cmd_mutex, 1);
+	mutex_init(&dev->cmd_mutex);
 	sema_init(&dev->stream_mutex, 1);
 	sema_init(&dev->pll_mutex, 1);
 	sema_init(&dev->i2c_switch_mutex, 1);
@@ -1606,10 +1606,10 @@ static void ngene_unlink(struct ngene *dev)
 	com.in_len = 3;
 	com.out_len = 1;
 
-	down(&dev->cmd_mutex);
+	mutex_lock(&dev->cmd_mutex);
 	ngwritel(0, NGENE_INT_ENABLE);
 	ngene_command_mutex(dev, &com);
-	up(&dev->cmd_mutex);
+	mutex_unlock(&dev->cmd_mutex);
 }
 
 void ngene_shutdown(struct pci_dev *pdev)
diff --git a/drivers/media/pci/ngene/ngene.h b/drivers/media/pci/ngene/ngene.h
index 10d8f74..e600b70 100644
--- a/drivers/media/pci/ngene/ngene.h
+++ b/drivers/media/pci/ngene/ngene.h
@@ -762,7 +762,7 @@ struct ngene {
 
 	wait_queue_head_t     cmd_wq;
 	int                   cmd_done;
-	struct semaphore      cmd_mutex;
+	struct mutex          cmd_mutex;
 	struct semaphore      stream_mutex;
 	struct semaphore      pll_mutex;
 	struct semaphore      i2c_switch_mutex;
-- 
Binoy Jayan

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/3] media: ngene: Replace semaphore stream_mutex with mutex
  2017-06-08 10:04 [PATCH 0/3] ngene: Replace semaphores with mutexes Binoy Jayan
  2017-06-08 10:04 ` [PATCH 1/3] media: ngene: Replace semaphore cmd_mutex with mutex Binoy Jayan
@ 2017-06-08 10:04 ` Binoy Jayan
  2017-06-08 15:19   ` Arnd Bergmann
  2017-06-08 10:04 ` [PATCH 3/3] media: ngene: Replace semaphore i2c_switch_mutex " Binoy Jayan
  2 siblings, 1 reply; 10+ messages in thread
From: Binoy Jayan @ 2017-06-08 10:04 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: linux-kernel, Arnd Bergmann, Rajendra, Mark Brown,
	Mauro Carvalho Chehab, Sakari Ailus, Julia Lawall,
	Michael S. Tsirkin, Cao jin, linux-media

The semaphore 'stream_mutex' is used as a simple mutex, so
it should be written as one. Semaphores are going away in the future.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
 drivers/media/pci/ngene/ngene-core.c | 14 +++++++-------
 drivers/media/pci/ngene/ngene.h      |  2 +-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/media/pci/ngene/ngene-core.c b/drivers/media/pci/ngene/ngene-core.c
index dfbd1e0..59f2e5f 100644
--- a/drivers/media/pci/ngene/ngene-core.c
+++ b/drivers/media/pci/ngene/ngene-core.c
@@ -560,7 +560,7 @@ static int ngene_command_stream_control(struct ngene *dev, u8 stream,
 	u16 BsSPI = ((stream & 1) ? 0x9800 : 0x9700);
 	u16 BsSDO = 0x9B00;
 
-	down(&dev->stream_mutex);
+	mutex_lock(&dev->stream_mutex);
 	memset(&com, 0, sizeof(com));
 	com.cmd.hdr.Opcode = CMD_CONTROL;
 	com.cmd.hdr.Length = sizeof(struct FW_STREAM_CONTROL) - 2;
@@ -587,16 +587,16 @@ static int ngene_command_stream_control(struct ngene *dev, u8 stream,
 			chan->HWState = HWSTATE_STOP;
 			spin_unlock_irq(&chan->state_lock);
 			if (ngene_command(dev, &com) < 0) {
-				up(&dev->stream_mutex);
+				mutex_unlock(&dev->stream_mutex);
 				return -1;
 			}
 			/* clear_buffers(chan); */
 			flush_buffers(chan);
-			up(&dev->stream_mutex);
+			mutex_unlock(&dev->stream_mutex);
 			return 0;
 		}
 		spin_unlock_irq(&chan->state_lock);
-		up(&dev->stream_mutex);
+		mutex_unlock(&dev->stream_mutex);
 		return 0;
 	}
 
@@ -693,10 +693,10 @@ static int ngene_command_stream_control(struct ngene *dev, u8 stream,
 	spin_unlock_irq(&chan->state_lock);
 
 	if (ngene_command(dev, &com) < 0) {
-		up(&dev->stream_mutex);
+		mutex_unlock(&dev->stream_mutex);
 		return -1;
 	}
-	up(&dev->stream_mutex);
+	mutex_unlock(&dev->stream_mutex);
 	return 0;
 }
 
@@ -1347,7 +1347,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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 3/3] media: ngene: Replace semaphore i2c_switch_mutex with mutex
  2017-06-08 10:04 [PATCH 0/3] ngene: Replace semaphores with mutexes Binoy Jayan
  2017-06-08 10:04 ` [PATCH 1/3] media: ngene: Replace semaphore cmd_mutex with mutex Binoy Jayan
  2017-06-08 10:04 ` [PATCH 2/3] media: ngene: Replace semaphore stream_mutex " Binoy Jayan
@ 2017-06-08 10:04 ` Binoy Jayan
  2017-06-08 15:17   ` Arnd Bergmann
  2 siblings, 1 reply; 10+ messages in thread
From: Binoy Jayan @ 2017-06-08 10:04 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: linux-kernel, Arnd Bergmann, Rajendra, Mark Brown,
	Mauro Carvalho Chehab, Sakari Ailus, Julia Lawall,
	Michael S. Tsirkin, Cao jin, linux-media

The semaphore 'i2c_switch_mutex' is used as a simple mutex, so
it should be written as one. Semaphores are going away in the future.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
 drivers/media/pci/ngene/ngene-core.c | 2 +-
 drivers/media/pci/ngene/ngene-i2c.c  | 6 +++---
 drivers/media/pci/ngene/ngene.h      | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/media/pci/ngene/ngene-core.c b/drivers/media/pci/ngene/ngene-core.c
index 59f2e5f..ca0c0f8 100644
--- a/drivers/media/pci/ngene/ngene-core.c
+++ b/drivers/media/pci/ngene/ngene-core.c
@@ -1349,7 +1349,7 @@ static int ngene_start(struct ngene *dev)
 	mutex_init(&dev->cmd_mutex);
 	mutex_init(&dev->stream_mutex);
 	sema_init(&dev->pll_mutex, 1);
-	sema_init(&dev->i2c_switch_mutex, 1);
+	mutex_init(&dev->i2c_switch_mutex);
 	spin_lock_init(&dev->cmd_lock);
 	for (i = 0; i < MAX_STREAM; i++)
 		spin_lock_init(&dev->channel[i].state_lock);
diff --git a/drivers/media/pci/ngene/ngene-i2c.c b/drivers/media/pci/ngene/ngene-i2c.c
index cf39fcf..fbf3635 100644
--- a/drivers/media/pci/ngene/ngene-i2c.c
+++ b/drivers/media/pci/ngene/ngene-i2c.c
@@ -118,7 +118,7 @@ static int ngene_i2c_master_xfer(struct i2c_adapter *adapter,
 		(struct ngene_channel *)i2c_get_adapdata(adapter);
 	struct ngene *dev = chan->dev;
 
-	down(&dev->i2c_switch_mutex);
+	mutex_lock(&dev->i2c_switch_mutex);
 	ngene_i2c_set_bus(dev, chan->number);
 
 	if (num == 2 && msg[1].flags & I2C_M_RD && !(msg[0].flags & I2C_M_RD))
@@ -136,11 +136,11 @@ static int ngene_i2c_master_xfer(struct i2c_adapter *adapter,
 					    msg[0].buf, msg[0].len, 0))
 			goto done;
 
-	up(&dev->i2c_switch_mutex);
+	mutex_unlock(&dev->i2c_switch_mutex);
 	return -EIO;
 
 done:
-	up(&dev->i2c_switch_mutex);
+	mutex_unlock(&dev->i2c_switch_mutex);
 	return num;
 }
 
diff --git a/drivers/media/pci/ngene/ngene.h b/drivers/media/pci/ngene/ngene.h
index 0dd15d6..7c7cd21 100644
--- a/drivers/media/pci/ngene/ngene.h
+++ b/drivers/media/pci/ngene/ngene.h
@@ -765,7 +765,7 @@ struct ngene {
 	struct mutex          cmd_mutex;
 	struct mutex          stream_mutex;
 	struct semaphore      pll_mutex;
-	struct semaphore      i2c_switch_mutex;
+	struct mutex          i2c_switch_mutex;
 	int                   i2c_current_channel;
 	int                   i2c_current_bus;
 	spinlock_t            cmd_lock;
-- 
Binoy Jayan

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] media: ngene: Replace semaphore cmd_mutex with mutex
  2017-06-08 10:04 ` [PATCH 1/3] media: ngene: Replace semaphore cmd_mutex with mutex Binoy Jayan
@ 2017-06-08 15:10   ` Arnd Bergmann
  2017-06-09  4:37     ` Binoy Jayan
  0 siblings, 1 reply; 10+ messages in thread
From: Arnd Bergmann @ 2017-06-08 15:10 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: Linux Kernel Mailing List, Rajendra, Mark Brown,
	Mauro Carvalho Chehab, Sakari Ailus, Julia Lawall,
	Michael S. Tsirkin, Cao jin, Linux Media Mailing List

On Thu, Jun 8, 2017 at 12:04 PM, Binoy Jayan <binoy.jayan@linaro.org> wrote:
> The semaphore 'cmd_mutex' is used as a simple mutex, so
> it should be written as one. Semaphores are going away in the future.
>
> Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
> ---

> @@ -1283,7 +1283,7 @@ static int ngene_load_firm(struct ngene *dev)
>
>  static void ngene_stop(struct ngene *dev)
>  {
> -       down(&dev->cmd_mutex);
> +       mutex_lock(&dev->cmd_mutex);
>         i2c_del_adapter(&(dev->channel[0].i2c_adapter));
>         i2c_del_adapter(&(dev->channel[1].i2c_adapter));
>         ngwritel(0, NGENE_INT_ENABLE);

Are you sure about this one? There is only one mutex_lock() and
then the structure gets freed without a corresponding mutex_unlock().

I suspect this violates some rules of mutexes, either when compile
testing with "make C=1", or when running with lockdep enabled.

Can we actually have a concurrently held mutex at the time we
get here? If not, using mutex_destroy() in place of the down()
may be the right answer.

       Arnd

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 3/3] media: ngene: Replace semaphore i2c_switch_mutex with mutex
  2017-06-08 10:04 ` [PATCH 3/3] media: ngene: Replace semaphore i2c_switch_mutex " Binoy Jayan
@ 2017-06-08 15:17   ` Arnd Bergmann
  0 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2017-06-08 15:17 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: Linux Kernel Mailing List, Rajendra, Mark Brown,
	Mauro Carvalho Chehab, Sakari Ailus, Julia Lawall,
	Michael S. Tsirkin, Cao jin, Linux Media Mailing List

On Thu, Jun 8, 2017 at 12:04 PM, Binoy Jayan <binoy.jayan@linaro.org> wrote:
> The semaphore 'i2c_switch_mutex' is used as a simple mutex, so
> it should be written as one. Semaphores are going away in the future.
>
> Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>

This one is obviously correct,

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/3] media: ngene: Replace semaphore stream_mutex with mutex
  2017-06-08 10:04 ` [PATCH 2/3] media: ngene: Replace semaphore stream_mutex " Binoy Jayan
@ 2017-06-08 15:19   ` Arnd Bergmann
  0 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2017-06-08 15:19 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: Linux Kernel Mailing List, Rajendra, Mark Brown,
	Mauro Carvalho Chehab, Sakari Ailus, Julia Lawall,
	Michael S. Tsirkin, Cao jin, Linux Media Mailing List

On Thu, Jun 8, 2017 at 12:04 PM, Binoy Jayan <binoy.jayan@linaro.org> wrote:
> The semaphore 'stream_mutex' is used as a simple mutex, so
> it should be written as one. Semaphores are going away in the future.
>
> Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
> ---

Looks correct, though I wonder whether it would be nicer to move the
mutex_lock/unlock() to the caller to avoid repeating the unlock() five
times.

Either way,

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] media: ngene: Replace semaphore cmd_mutex with mutex
  2017-06-08 15:10   ` Arnd Bergmann
@ 2017-06-09  4:37     ` Binoy Jayan
  2017-06-09 10:36       ` Arnd Bergmann
  0 siblings, 1 reply; 10+ messages in thread
From: Binoy Jayan @ 2017-06-09  4:37 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linux Kernel Mailing List, Rajendra, Mark Brown,
	Mauro Carvalho Chehab, Sakari Ailus, Julia Lawall,
	Michael S. Tsirkin, Cao jin, Linux Media Mailing List

On 8 June 2017 at 20:40, Arnd Bergmann <arnd@arndb.de> wrote:
> On Thu, Jun 8, 2017 at 12:04 PM, Binoy Jayan <binoy.jayan@linaro.org> wrote:
>> The semaphore 'cmd_mutex' is used as a simple mutex, so
>> it should be written as one. Semaphores are going away in the future.
>>
>> Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
>> ---
>
>> @@ -1283,7 +1283,7 @@ static int ngene_load_firm(struct ngene *dev)
>>
>>  static void ngene_stop(struct ngene *dev)
>>  {
>> -       down(&dev->cmd_mutex);
>> +       mutex_lock(&dev->cmd_mutex);
>>         i2c_del_adapter(&(dev->channel[0].i2c_adapter));
>>         i2c_del_adapter(&(dev->channel[1].i2c_adapter));
>>         ngwritel(0, NGENE_INT_ENABLE);
>
> Are you sure about this one? There is only one mutex_lock() and
> then the structure gets freed without a corresponding mutex_unlock().
>
> I suspect this violates some rules of mutexes, either when compile
> testing with "make C=1", or when running with lockdep enabled.
>
> Can we actually have a concurrently held mutex at the time we
> get here? If not, using mutex_destroy() in place of the down()
> may be the right answer.

I noticed the missing 'up' here, but may be semaphores do not have
to adhere to that rule? Thank you for pointing out that. I'll check the
concurrency part. By the way why do we need mutex_destoy?
To debug an aberrate condition?

Thanks,
Binoy

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] media: ngene: Replace semaphore cmd_mutex with mutex
  2017-06-09  4:37     ` Binoy Jayan
@ 2017-06-09 10:36       ` Arnd Bergmann
  2017-06-13  8:58         ` Binoy Jayan
  0 siblings, 1 reply; 10+ messages in thread
From: Arnd Bergmann @ 2017-06-09 10:36 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: Linux Kernel Mailing List, Rajendra, Mark Brown,
	Mauro Carvalho Chehab, Sakari Ailus, Julia Lawall,
	Michael S. Tsirkin, Cao jin, Linux Media Mailing List

On Fri, Jun 9, 2017 at 6:37 AM, Binoy Jayan <binoy.jayan@linaro.org> wrote:
> On 8 June 2017 at 20:40, Arnd Bergmann <arnd@arndb.de> wrote:
>> On Thu, Jun 8, 2017 at 12:04 PM, Binoy Jayan <binoy.jayan@linaro.org> wrote:
>>> The semaphore 'cmd_mutex' is used as a simple mutex, so
>>> it should be written as one. Semaphores are going away in the future.
>>>
>>> Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
>>> ---
>>
>>> @@ -1283,7 +1283,7 @@ static int ngene_load_firm(struct ngene *dev)
>>>
>>>  static void ngene_stop(struct ngene *dev)
>>>  {
>>> -       down(&dev->cmd_mutex);
>>> +       mutex_lock(&dev->cmd_mutex);
>>>         i2c_del_adapter(&(dev->channel[0].i2c_adapter));
>>>         i2c_del_adapter(&(dev->channel[1].i2c_adapter));
>>>         ngwritel(0, NGENE_INT_ENABLE);
>>
>> Are you sure about this one? There is only one mutex_lock() and
>> then the structure gets freed without a corresponding mutex_unlock().
>>
>> I suspect this violates some rules of mutexes, either when compile
>> testing with "make C=1", or when running with lockdep enabled.
>>
>> Can we actually have a concurrently held mutex at the time we
>> get here? If not, using mutex_destroy() in place of the down()
>> may be the right answer.
>
> I noticed the missing 'up' here, but may be semaphores do not have
> to adhere to that rule?

The rules for semaphores are very lax, the up() and down() may
be in completely separate contexts, the up() can even happen from
an interrupt handler IIRC.

I read up on the sparse annotations now and found that it only
tracks spinlocks and rwlocks using the __acquires() annotation,
but not semaphores or mutexes.

I'm still not sure whether lockdep requires the mutex to be released
before it gets freed, the code may actually be fine, but it does
seem odd.

> Thank you for pointing out that. I'll check the
> concurrency part. By the way why do we need mutex_destoy?
> To debug an aberrate condition?

At first I suspected the down() here was added for the same
purpose as a mutex_destroy: to ensure that we are in a sane
state before we free the device structure, but the way they
achieve that is completely different.

However, if there is any way that a command may still be in
progress by the time we get to ngene_stop(), we may also
be lacking reference counting on the ngene structure here.
So far I haven't found any of those, and think the mutex_destroy()
is sufficient here as a debugging help.

       Arnd

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/3] media: ngene: Replace semaphore cmd_mutex with mutex
  2017-06-09 10:36       ` Arnd Bergmann
@ 2017-06-13  8:58         ` Binoy Jayan
  0 siblings, 0 replies; 10+ messages in thread
From: Binoy Jayan @ 2017-06-13  8:58 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Linux Kernel Mailing List, Rajendra, Mark Brown,
	Mauro Carvalho Chehab, Sakari Ailus, Julia Lawall,
	Michael S. Tsirkin, Cao jin, Linux Media Mailing List

Hi Arnd,

On 9 June 2017 at 16:06, Arnd Bergmann <arnd@arndb.de> wrote:

>> Thank you for pointing out that. I'll check the
>> concurrency part. By the way why do we need mutex_destoy?
>> To debug an aberrate condition?
>
> At first I suspected the down() here was added for the same
> purpose as a mutex_destroy: to ensure that we are in a sane
> state before we free the device structure, but the way they
> achieve that is completely different.
>
> However, if there is any way that a command may still be in
> progress by the time we get to ngene_stop(), we may also
> be lacking reference counting on the ngene structure here.
> So far I haven't found any of those, and think the mutex_destroy()
> is sufficient here as a debugging help.

I've made the necessary changes. Thank you for reviewing all the patches.

Regards,
Binoy

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-06-13  8:58 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-08 10:04 [PATCH 0/3] ngene: Replace semaphores with mutexes Binoy Jayan
2017-06-08 10:04 ` [PATCH 1/3] media: ngene: Replace semaphore cmd_mutex with mutex Binoy Jayan
2017-06-08 15:10   ` Arnd Bergmann
2017-06-09  4:37     ` Binoy Jayan
2017-06-09 10:36       ` Arnd Bergmann
2017-06-13  8:58         ` Binoy Jayan
2017-06-08 10:04 ` [PATCH 2/3] media: ngene: Replace semaphore stream_mutex " Binoy Jayan
2017-06-08 15:19   ` Arnd Bergmann
2017-06-08 10:04 ` [PATCH 3/3] media: ngene: Replace semaphore i2c_switch_mutex " Binoy Jayan
2017-06-08 15:17   ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).