Skip to content

Commit d338ae2

Browse files
Alex Elderdavem330
authored andcommitted
net: ipa: kill all other transaction lists
None of the transaction lists are actually needed any more, because transaction IDs (which have been shown to be equivalent) are used instead. So we can remove all of them, as well as the spinlock that protects updates to them. Not requiring a lock simplifies gsi_trans_free() as well; we only need to check the reference count once to decide whether we've hit the last reference. This makes the links field in the gsi_trans structure unused, so get rid of that as well. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 11902b4 commit d338ae2

File tree

3 files changed

+6
-74
lines changed

3 files changed

+6
-74
lines changed

drivers/net/ipa/gsi.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ struct gsi_trans_info {
9494

9595
struct gsi_trans_pool sg_pool; /* scatterlist pool */
9696
struct gsi_trans_pool cmd_pool; /* command payload DMA pool */
97-
98-
spinlock_t spinlock; /* protects updates to the lists */
99-
struct list_head committed; /* committed, awaiting doorbell */
100-
struct list_head pending; /* pending, awaiting completion */
101-
struct list_head complete; /* completed, awaiting poll */
102-
struct list_head polled; /* returned by gsi_channel_poll_one() */
10397
};
10498

10599
/* Hardware values signifying the state of a channel */

drivers/net/ipa/gsi_trans.c

Lines changed: 6 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -252,75 +252,43 @@ static void gsi_trans_move_committed(struct gsi_trans *trans)
252252
struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id];
253253
struct gsi_trans_info *trans_info = &channel->trans_info;
254254

255-
spin_lock_bh(&trans_info->spinlock);
256-
257-
list_add_tail(&trans->links, &trans_info->committed);
258-
259-
spin_unlock_bh(&trans_info->spinlock);
260-
261255
/* This allocated transaction is now committed */
262256
trans_info->allocated_id++;
263257
}
264258

265-
/* Move transactions from the committed list to the pending list */
259+
/* Move committed transactions to pending state */
266260
static void gsi_trans_move_pending(struct gsi_trans *trans)
267261
{
268262
struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id];
269263
struct gsi_trans_info *trans_info = &channel->trans_info;
270264
u16 trans_index = trans - &trans_info->trans[0];
271-
struct list_head list;
272265
u16 delta;
273266

274-
spin_lock_bh(&trans_info->spinlock);
275-
276-
/* Move this transaction and all predecessors to the pending list */
277-
list_cut_position(&list, &trans_info->committed, &trans->links);
278-
list_splice_tail(&list, &trans_info->pending);
279-
280-
spin_unlock_bh(&trans_info->spinlock);
281-
282267
/* These committed transactions are now pending */
283268
delta = trans_index - trans_info->committed_id + 1;
284269
trans_info->committed_id += delta % channel->tre_count;
285270
}
286271

287-
/* Move a transaction and all of its predecessors from the pending list
288-
* to the completed list.
289-
*/
272+
/* Move pending transactions to completed state */
290273
void gsi_trans_move_complete(struct gsi_trans *trans)
291274
{
292275
struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id];
293276
struct gsi_trans_info *trans_info = &channel->trans_info;
294277
u16 trans_index = trans - trans_info->trans;
295-
struct list_head list;
296278
u16 delta;
297279

298-
spin_lock_bh(&trans_info->spinlock);
299-
300-
/* Move this transaction and all predecessors to completed list */
301-
list_cut_position(&list, &trans_info->pending, &trans->links);
302-
list_splice_tail(&list, &trans_info->complete);
303-
304-
spin_unlock_bh(&trans_info->spinlock);
305-
306280
/* These pending transactions are now completed */
307281
delta = trans_index - trans_info->pending_id + 1;
308282
delta %= channel->tre_count;
309283
trans_info->pending_id += delta;
310284
}
311285

312-
/* Move a transaction from the completed list to the polled list */
286+
/* Move a transaction from completed to polled state */
313287
void gsi_trans_move_polled(struct gsi_trans *trans)
314288
{
315289
struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id];
316290
struct gsi_trans_info *trans_info = &channel->trans_info;
317291

318-
spin_lock_bh(&trans_info->spinlock);
319-
320-
list_move_tail(&trans->links, &trans_info->polled);
321-
322-
spin_unlock_bh(&trans_info->spinlock);
323-
324292
/* This completed transaction is now polled */
325293
trans_info->completed_id++;
326294
}
@@ -383,7 +351,6 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id,
383351
memset(trans, 0, sizeof(*trans));
384352

385353
/* Initialize non-zero fields in the transaction */
386-
INIT_LIST_HEAD(&trans->links);
387354
trans->gsi = gsi;
388355
trans->channel_id = channel_id;
389356
trans->rsvd_count = tre_count;
@@ -396,7 +363,7 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id,
396363
trans->direction = direction;
397364
refcount_set(&trans->refcount, 1);
398365

399-
/* This free transaction will now be allocated */
366+
/* This free transaction is now allocated */
400367
trans_info->free_id++;
401368

402369
return trans;
@@ -405,31 +372,15 @@ struct gsi_trans *gsi_channel_trans_alloc(struct gsi *gsi, u32 channel_id,
405372
/* Free a previously-allocated transaction */
406373
void gsi_trans_free(struct gsi_trans *trans)
407374
{
408-
refcount_t *refcount = &trans->refcount;
409375
struct gsi_trans_info *trans_info;
410-
bool last;
411376

412-
/* We must hold the lock to release the last reference */
413-
if (refcount_dec_not_one(refcount))
414-
return;
415-
416-
trans_info = &trans->gsi->channel[trans->channel_id].trans_info;
417-
418-
spin_lock_bh(&trans_info->spinlock);
419-
420-
/* Reference might have been added before we got the lock */
421-
last = refcount_dec_and_test(refcount);
422-
if (last)
423-
list_del(&trans->links);
424-
425-
spin_unlock_bh(&trans_info->spinlock);
426-
427-
if (!last)
377+
if (!refcount_dec_and_test(&trans->refcount))
428378
return;
429379

430380
/* Unused transactions are allocated but never committed, pending,
431381
* completed, or polled.
432382
*/
383+
trans_info = &trans->gsi->channel[trans->channel_id].trans_info;
433384
if (!trans->used_count) {
434385
trans_info->allocated_id++;
435386
trans_info->committed_id++;
@@ -692,11 +643,6 @@ void gsi_channel_trans_cancel_pending(struct gsi_channel *channel)
692643
u16 trans_id = trans_info->pending_id;
693644

694645
/* channel->gsi->mutex is held by caller */
695-
spin_lock_bh(&trans_info->spinlock);
696-
697-
list_splice_tail_init(&trans_info->pending, &trans_info->complete);
698-
699-
spin_unlock_bh(&trans_info->spinlock);
700646

701647
/* If there are no pending transactions, we're done */
702648
if (trans_id == trans_info->committed_id)
@@ -815,11 +761,6 @@ int gsi_channel_trans_init(struct gsi *gsi, u32 channel_id)
815761
if (ret)
816762
goto err_map_free;
817763

818-
spin_lock_init(&trans_info->spinlock);
819-
INIT_LIST_HEAD(&trans_info->committed);
820-
INIT_LIST_HEAD(&trans_info->pending);
821-
INIT_LIST_HEAD(&trans_info->complete);
822-
INIT_LIST_HEAD(&trans_info->polled);
823764

824765
return 0;
825766

drivers/net/ipa/gsi_trans.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ struct gsi_trans_pool;
2929
* struct gsi_trans - a GSI transaction
3030
*
3131
* Most fields in this structure for internal use by the transaction core code:
32-
* @links: Links for channel transaction lists by state
3332
* @gsi: GSI pointer
3433
* @channel_id: Channel number transaction is associated with
3534
* @cancelled: If set by the core code, transaction was cancelled
@@ -50,8 +49,6 @@ struct gsi_trans_pool;
5049
* received.
5150
*/
5251
struct gsi_trans {
53-
struct list_head links; /* gsi_channel lists */
54-
5552
struct gsi *gsi;
5653
u8 channel_id;
5754

0 commit comments

Comments
 (0)