All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fpga: altera-hps2fpga: fix multiple init of l3_remap_lock
@ 2017-06-27 15:18 Ian Abbott
  2017-06-27 16:36 ` Moritz Fischer
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Abbott @ 2017-06-27 15:18 UTC (permalink / raw)
  To: linux-fpga; +Cc: Alan Tull, Moritz Fischer, Ian Abbott, # 4 . 10+

The global spinlock `l3_remap_lock` is reinitialized every time the
"probe" function `alt_fpga_bridge_probe()` is called.  It should only be
initialized once.  Use `DEFINE_SPINLOCK()` to initialize it statically.

Fixes: e5f8efa5c8bf ("ARM: socfpga: fpga bridge driver support")
Cc: <stable@vger.kernel.org> # 4.10+
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
 drivers/fpga/altera-hps2fpga.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/fpga/altera-hps2fpga.c b/drivers/fpga/altera-hps2fpga.c
index 3066b805f2d0..08c0ecb7d109 100644
--- a/drivers/fpga/altera-hps2fpga.c
+++ b/drivers/fpga/altera-hps2fpga.c
@@ -66,7 +66,7 @@ static int alt_hps2fpga_enable_show(struct fpga_bridge *bridge)
 
 /* The L3 REMAP register is write only, so keep a cached value. */
 static unsigned int l3_remap_shadow;
-static spinlock_t l3_remap_lock;
+static DEFINE_SPINLOCK(l3_remap_lock);
 
 static int _alt_hps2fpga_enable_set(struct altera_hps2fpga_data *priv,
 				    bool enable)
@@ -171,8 +171,6 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
 		return -EBUSY;
 	}
 
-	spin_lock_init(&l3_remap_lock);
-
 	if (!of_property_read_u32(dev->of_node, "bridge-enable", &enable)) {
 		if (enable > 1) {
 			dev_warn(dev, "invalid bridge-enable %u > 1\n", enable);
-- 
2.11.0

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

* Re: [PATCH] fpga: altera-hps2fpga: fix multiple init of l3_remap_lock
  2017-06-27 15:18 [PATCH] fpga: altera-hps2fpga: fix multiple init of l3_remap_lock Ian Abbott
@ 2017-06-27 16:36 ` Moritz Fischer
  2017-07-05 18:51   ` Alan Tull
  0 siblings, 1 reply; 3+ messages in thread
From: Moritz Fischer @ 2017-06-27 16:36 UTC (permalink / raw)
  To: Ian Abbott; +Cc: linux-fpga, Alan Tull, Moritz Fischer, # 4 . 10+

[-- Attachment #1: Type: text/plain, Size: 1569 bytes --]

On Tue, Jun 27, 2017 at 04:18:42PM +0100, Ian Abbott wrote:
> The global spinlock `l3_remap_lock` is reinitialized every time the
> "probe" function `alt_fpga_bridge_probe()` is called.  It should only be
> initialized once.  Use `DEFINE_SPINLOCK()` to initialize it statically.
> 
> Fixes: e5f8efa5c8bf ("ARM: socfpga: fpga bridge driver support")
> Cc: <stable@vger.kernel.org> # 4.10+
> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Reviewed-By: Moritz Fischer <mdf@kernel.org>

Thanks for catching that,

Moritz
> ---
>  drivers/fpga/altera-hps2fpga.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/fpga/altera-hps2fpga.c b/drivers/fpga/altera-hps2fpga.c
> index 3066b805f2d0..08c0ecb7d109 100644
> --- a/drivers/fpga/altera-hps2fpga.c
> +++ b/drivers/fpga/altera-hps2fpga.c
> @@ -66,7 +66,7 @@ static int alt_hps2fpga_enable_show(struct fpga_bridge *bridge)
>  
>  /* The L3 REMAP register is write only, so keep a cached value. */
>  static unsigned int l3_remap_shadow;
> -static spinlock_t l3_remap_lock;
> +static DEFINE_SPINLOCK(l3_remap_lock);
>  
>  static int _alt_hps2fpga_enable_set(struct altera_hps2fpga_data *priv,
>  				    bool enable)
> @@ -171,8 +171,6 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
>  		return -EBUSY;
>  	}
>  
> -	spin_lock_init(&l3_remap_lock);
> -
>  	if (!of_property_read_u32(dev->of_node, "bridge-enable", &enable)) {
>  		if (enable > 1) {
>  			dev_warn(dev, "invalid bridge-enable %u > 1\n", enable);
> -- 
> 2.11.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

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

* Re: [PATCH] fpga: altera-hps2fpga: fix multiple init of l3_remap_lock
  2017-06-27 16:36 ` Moritz Fischer
@ 2017-07-05 18:51   ` Alan Tull
  0 siblings, 0 replies; 3+ messages in thread
From: Alan Tull @ 2017-07-05 18:51 UTC (permalink / raw)
  To: Moritz Fischer; +Cc: Ian Abbott, linux-fpga, Moritz Fischer, # 4 . 10+

On Tue, Jun 27, 2017 at 11:36 AM, Moritz Fischer <mdf@kernel.org> wrote:

Hi Ian,

Thanks for the fix!

Alan

> On Tue, Jun 27, 2017 at 04:18:42PM +0100, Ian Abbott wrote:
>> The global spinlock `l3_remap_lock` is reinitialized every time the
>> "probe" function `alt_fpga_bridge_probe()` is called.  It should only be
>> initialized once.  Use `DEFINE_SPINLOCK()` to initialize it statically.
>>
>> Fixes: e5f8efa5c8bf ("ARM: socfpga: fpga bridge driver support")
>> Cc: <stable@vger.kernel.org> # 4.10+
>> Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
> Reviewed-By: Moritz Fischer <mdf@kernel.org>

Signed-off-by: Alan Tull <atull@kernel.org>

>
> Thanks for catching that,
>
> Moritz
>> ---
>>  drivers/fpga/altera-hps2fpga.c | 4 +---
>>  1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/drivers/fpga/altera-hps2fpga.c b/drivers/fpga/altera-hps2fpga.c
>> index 3066b805f2d0..08c0ecb7d109 100644
>> --- a/drivers/fpga/altera-hps2fpga.c
>> +++ b/drivers/fpga/altera-hps2fpga.c
>> @@ -66,7 +66,7 @@ static int alt_hps2fpga_enable_show(struct fpga_bridge *bridge)
>>
>>  /* The L3 REMAP register is write only, so keep a cached value. */
>>  static unsigned int l3_remap_shadow;
>> -static spinlock_t l3_remap_lock;
>> +static DEFINE_SPINLOCK(l3_remap_lock);
>>
>>  static int _alt_hps2fpga_enable_set(struct altera_hps2fpga_data *priv,
>>                                   bool enable)
>> @@ -171,8 +171,6 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)
>>               return -EBUSY;
>>       }
>>
>> -     spin_lock_init(&l3_remap_lock);
>> -
>>       if (!of_property_read_u32(dev->of_node, "bridge-enable", &enable)) {
>>               if (enable > 1) {
>>                       dev_warn(dev, "invalid bridge-enable %u > 1\n", enable);
>> --
>> 2.11.0
>>

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

end of thread, other threads:[~2017-07-05 18:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-27 15:18 [PATCH] fpga: altera-hps2fpga: fix multiple init of l3_remap_lock Ian Abbott
2017-06-27 16:36 ` Moritz Fischer
2017-07-05 18:51   ` Alan Tull

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.