Skip to content

Commit ad2dcba

Browse files
WillLesterdavem330
authored andcommitted
cxgb4: smt: Use normal int for refcount
All refcount operations are protected by spinlocks now. Then the atomic counter can be replaced by a normal int. This patch depends on PATCH 1/2. Signed-off-by: Chuhong Yuan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4a8937b commit ad2dcba

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

drivers/net/ethernet/chelsio/cxgb4/smt.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct smt_data *t4_init_smt(void)
5757
s->smtab[i].state = SMT_STATE_UNUSED;
5858
memset(&s->smtab[i].src_mac, 0, ETH_ALEN);
5959
spin_lock_init(&s->smtab[i].lock);
60-
atomic_set(&s->smtab[i].refcnt, 0);
60+
s->smtab[i].refcnt = 0;
6161
}
6262
return s;
6363
}
@@ -68,7 +68,7 @@ static struct smt_entry *find_or_alloc_smte(struct smt_data *s, u8 *smac)
6868
struct smt_entry *e, *end;
6969

7070
for (e = &s->smtab[0], end = &s->smtab[s->smt_size]; e != end; ++e) {
71-
if (atomic_read(&e->refcnt) == 0) {
71+
if (e->refcnt == 0) {
7272
if (!first_free)
7373
first_free = e;
7474
} else {
@@ -97,7 +97,7 @@ static struct smt_entry *find_or_alloc_smte(struct smt_data *s, u8 *smac)
9797

9898
static void t4_smte_free(struct smt_entry *e)
9999
{
100-
if (atomic_read(&e->refcnt) == 0) { /* hasn't been recycled */
100+
if (e->refcnt == 0) { /* hasn't been recycled */
101101
e->state = SMT_STATE_UNUSED;
102102
}
103103
}
@@ -110,7 +110,7 @@ static void t4_smte_free(struct smt_entry *e)
110110
void cxgb4_smt_release(struct smt_entry *e)
111111
{
112112
spin_lock_bh(&e->lock);
113-
if (atomic_dec_and_test(&e->refcnt))
113+
if ((--e->refcnt) == 0)
114114
t4_smte_free(e);
115115
spin_unlock_bh(&e->lock);
116116
}
@@ -215,14 +215,14 @@ static struct smt_entry *t4_smt_alloc_switching(struct adapter *adap, u16 pfvf,
215215
e = find_or_alloc_smte(s, smac);
216216
if (e) {
217217
spin_lock(&e->lock);
218-
if (!atomic_read(&e->refcnt)) {
219-
atomic_set(&e->refcnt, 1);
218+
if (!e->refcnt) {
219+
e->refcnt = 1;
220220
e->state = SMT_STATE_SWITCHING;
221221
e->pfvf = pfvf;
222222
memcpy(e->src_mac, smac, ETH_ALEN);
223223
write_smt_entry(adap, e);
224224
} else {
225-
atomic_inc(&e->refcnt);
225+
++e->refcnt;
226226
}
227227
spin_unlock(&e->lock);
228228
}

drivers/net/ethernet/chelsio/cxgb4/smt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ struct smt_entry {
5959
u16 idx;
6060
u16 pfvf;
6161
u8 src_mac[ETH_ALEN];
62-
atomic_t refcnt;
62+
int refcnt;
6363
spinlock_t lock; /* protect smt entry add,removal */
6464
};
6565

0 commit comments

Comments
 (0)