@@ -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 */
266260static 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 */
290273void 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 */
313287void 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 */
406373void 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
0 commit comments