All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] crypto: ccp - Use different flag vars for nested locks
@ 2016-03-11 16:40 Gary R Hook
  2016-03-11 23:01 ` Tom Lendacky
  2016-03-12  2:22 ` Herbert Xu
  0 siblings, 2 replies; 4+ messages in thread
From: Gary R Hook @ 2016-03-11 16:40 UTC (permalink / raw)
  To: linux-crypto; +Cc: thomas.lendacky, herbert, davem

This patch fixes a coccinelle warning about reusing a flags
variable in nested lock acquisition.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
---
 drivers/crypto/ccp/ccp-dev.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
index 336e5b7..9c7bce8 100644
--- a/drivers/crypto/ccp/ccp-dev.c
+++ b/drivers/crypto/ccp/ccp-dev.c
@@ -120,7 +120,7 @@ void ccp_del_device(struct ccp_device *ccp)
 
 static struct ccp_device *ccp_get_device(void)
 {
-	unsigned long flags;
+	unsigned long flags, rrflags;
 	struct ccp_device *dp = NULL;
 
 	/* We round-robin through the unit list.
@@ -128,14 +128,14 @@ static struct ccp_device *ccp_get_device(void)
 	 */
 	read_lock_irqsave(&ccp_unit_lock, flags);
 	if (!list_empty(&ccp_units)) {
-		write_lock_irqsave(&ccp_rr_lock, flags);
+		write_lock_irqsave(&ccp_rr_lock, rrflags);
 		dp = ccp_rr;
 		if (list_is_last(&ccp_rr->entry, &ccp_units))
 			ccp_rr = list_first_entry(&ccp_units, struct ccp_device,
 						  entry);
 		else
 			ccp_rr = list_next_entry(ccp_rr, entry);
-		write_unlock_irqrestore(&ccp_rr_lock, flags);
+		write_unlock_irqrestore(&ccp_rr_lock, rrflags);
 	}
 	read_unlock_irqrestore(&ccp_unit_lock, flags);
 

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

* Re: [PATCH] crypto: ccp - Use different flag vars for nested locks
  2016-03-11 16:40 [PATCH] crypto: ccp - Use different flag vars for nested locks Gary R Hook
@ 2016-03-11 23:01 ` Tom Lendacky
  2016-03-12  2:22 ` Herbert Xu
  1 sibling, 0 replies; 4+ messages in thread
From: Tom Lendacky @ 2016-03-11 23:01 UTC (permalink / raw)
  To: Gary R Hook, linux-crypto; +Cc: herbert, davem

On 03/11/2016 10:40 AM, Gary R Hook wrote:
> This patch fixes a coccinelle warning about reusing a flags
> variable in nested lock acquisition.
> 
> Signed-off-by: Gary R Hook <gary.hook@amd.com>

Acked-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
>  drivers/crypto/ccp/ccp-dev.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/crypto/ccp/ccp-dev.c b/drivers/crypto/ccp/ccp-dev.c
> index 336e5b7..9c7bce8 100644
> --- a/drivers/crypto/ccp/ccp-dev.c
> +++ b/drivers/crypto/ccp/ccp-dev.c
> @@ -120,7 +120,7 @@ void ccp_del_device(struct ccp_device *ccp)
>  
>  static struct ccp_device *ccp_get_device(void)
>  {
> -	unsigned long flags;
> +	unsigned long flags, rrflags;
>  	struct ccp_device *dp = NULL;
>  
>  	/* We round-robin through the unit list.
> @@ -128,14 +128,14 @@ static struct ccp_device *ccp_get_device(void)
>  	 */
>  	read_lock_irqsave(&ccp_unit_lock, flags);
>  	if (!list_empty(&ccp_units)) {
> -		write_lock_irqsave(&ccp_rr_lock, flags);
> +		write_lock_irqsave(&ccp_rr_lock, rrflags);
>  		dp = ccp_rr;
>  		if (list_is_last(&ccp_rr->entry, &ccp_units))
>  			ccp_rr = list_first_entry(&ccp_units, struct ccp_device,
>  						  entry);
>  		else
>  			ccp_rr = list_next_entry(ccp_rr, entry);
> -		write_unlock_irqrestore(&ccp_rr_lock, flags);
> +		write_unlock_irqrestore(&ccp_rr_lock, rrflags);
>  	}
>  	read_unlock_irqrestore(&ccp_unit_lock, flags);
>  
> 

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

* Re: [PATCH] crypto: ccp - Use different flag vars for nested locks
  2016-03-11 16:40 [PATCH] crypto: ccp - Use different flag vars for nested locks Gary R Hook
  2016-03-11 23:01 ` Tom Lendacky
@ 2016-03-12  2:22 ` Herbert Xu
  2016-03-14 14:15   ` Gary R Hook
  1 sibling, 1 reply; 4+ messages in thread
From: Herbert Xu @ 2016-03-12  2:22 UTC (permalink / raw)
  To: Gary R Hook; +Cc: linux-crypto, thomas.lendacky, davem

On Fri, Mar 11, 2016 at 10:40:11AM -0600, Gary R Hook wrote:
>
> @@ -128,14 +128,14 @@ static struct ccp_device *ccp_get_device(void)
>  	 */
>  	read_lock_irqsave(&ccp_unit_lock, flags);
>  	if (!list_empty(&ccp_units)) {
> -		write_lock_irqsave(&ccp_rr_lock, flags);
> +		write_lock_irqsave(&ccp_rr_lock, rrflags);

The right thing to do is to drop the _irqsave on the inner lock.

Also why is this a write lock at all as nobody seems to take it
as a read lock?

Cheers,
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH] crypto: ccp - Use different flag vars for nested locks
  2016-03-12  2:22 ` Herbert Xu
@ 2016-03-14 14:15   ` Gary R Hook
  0 siblings, 0 replies; 4+ messages in thread
From: Gary R Hook @ 2016-03-14 14:15 UTC (permalink / raw)
  To: Herbert Xu, Gary R Hook; +Cc: linux-crypto, thomas.lendacky, davem



On 03/11/2016 08:22 PM, Herbert Xu wrote:
> On Fri, Mar 11, 2016 at 10:40:11AM -0600, Gary R Hook wrote:
>> @@ -128,14 +128,14 @@ static struct ccp_device *ccp_get_device(void)
>>   	 */
>>   	read_lock_irqsave(&ccp_unit_lock, flags);
>>   	if (!list_empty(&ccp_units)) {
>> -		write_lock_irqsave(&ccp_rr_lock, flags);
>> +		write_lock_irqsave(&ccp_rr_lock, rrflags);
> The right thing to do is to drop the _irqsave on the inner lock.
>
> Also why is this a write lock at all as nobody seems to take it
> as a read lock?
Roger on the _irqsave.

As for this being a read-write lock: an optimization during development 
removed the need for a read acquisition. This use of the lock was 
overlooked, and now only needs to be a spin lock.

Since the function of this patch has changed, and the subject line 
should be different, do you prefer a v2 patch, or a new patch? This one 
can be ignored, of course.

Gary

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

end of thread, other threads:[~2016-03-14 14:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-11 16:40 [PATCH] crypto: ccp - Use different flag vars for nested locks Gary R Hook
2016-03-11 23:01 ` Tom Lendacky
2016-03-12  2:22 ` Herbert Xu
2016-03-14 14:15   ` Gary R Hook

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.