Re: [PATCH net-next 2/3] bna: change type of bna_id to atomic_t

2016-08-01 Thread Ivan Vecera

On 1.8.2016 16:20, David Laight wrote:

From: Ivan Vecera

Sent: 29 July 2016 18:53
Change type of bna_id to atomic_t. The bnad_list_mutex is used to prevent
a race when bna_id is incremented. After the change the mutex can be
removed in the next step.

...

-static u32 bna_id;
+static atomic_t bna_id;

...

bnad_lock_init(bnad);
bnad_add_to_list(bnad);
+   bnad->id = atomic_inc_return(_id) - 1;

...

Is the 'id' expected to be unique?
Looks like they get reallocated after 2^32 allocates.

David


I have just converted it to atomic type to eliminate mutex. The id is 
only used as parameter 'instance' for bfa_nw_flash_{update,read}_part(). 
There is no documentation in source code regarding this so this is a 
question to Qlogic.


Ivan


RE: [PATCH net-next 2/3] bna: change type of bna_id to atomic_t

2016-08-01 Thread David Laight
From: Ivan Vecera
> Sent: 29 July 2016 18:53
> Change type of bna_id to atomic_t. The bnad_list_mutex is used to prevent
> a race when bna_id is incremented. After the change the mutex can be
> removed in the next step.
...
> -static u32 bna_id;
> +static atomic_t bna_id;
...
>   bnad_lock_init(bnad);
>   bnad_add_to_list(bnad);
> + bnad->id = atomic_inc_return(_id) - 1;
...

Is the 'id' expected to be unique?
Looks like they get reallocated after 2^32 allocates.

David




[PATCH net-next 2/3] bna: change type of bna_id to atomic_t

2016-07-29 Thread Ivan Vecera
Change type of bna_id to atomic_t. The bnad_list_mutex is used to prevent
a race when bna_id is incremented. After the change the mutex can be
removed in the next step.

Signed-off-by: Ivan Vecera 
---
 drivers/net/ethernet/brocade/bna/bnad.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/brocade/bna/bnad.c 
b/drivers/net/ethernet/brocade/bna/bnad.c
index 696bbae..2bed050 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -54,7 +54,7 @@ MODULE_PARM_DESC(bna_debugfs_enable, "Enables debugfs 
feature, default=1,"
  * Global variables
  */
 static u32 bnad_rxqs_per_cq = 2;
-static u32 bna_id;
+static atomic_t bna_id;
 static struct mutex bnad_list_mutex;
 static const u8 bnad_bcast_addr[] __aligned(2) =
{ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
@@ -79,7 +79,6 @@ static void
 bnad_add_to_list(struct bnad *bnad)
 {
mutex_lock(_list_mutex);
-   bnad->id = bna_id++;
mutex_unlock(_list_mutex);
 }
 
@@ -3651,6 +3650,7 @@ bnad_pci_probe(struct pci_dev *pdev,
bnad = netdev_priv(netdev);
bnad_lock_init(bnad);
bnad_add_to_list(bnad);
+   bnad->id = atomic_inc_return(_id) - 1;
 
mutex_lock(>conf_mutex);
/*
-- 
2.7.3