[Linux1394-cvslog] rev 552 - trunk
Brought to you by:
aeb,
bencollins
From: SVN U. <hog...@li...> - 2002-08-25 16:02:44
|
Author: hogsberg Date: 2002-08-25 20:55:33 -0400 (Sun, 25 Aug 2002) New Revision: 552 Modified: trunk/ieee1394_core.h trunk/ohci1394.c trunk/ohci1394.h trunk/pcilynx.c trunk/pcilynx.h Log: Minor cleanup: use linux/list.h for driver-internal packet queueing Modified: trunk/ohci1394.c ============================================================================== --- trunk/ohci1394.c (original) +++ trunk/ohci1394.c 2002-08-25 20:55:34.000000000 -0400 @@ -443,10 +443,8 @@ d->sent_ind = 0; d->free_prgs = d->num_desc; d->branchAddrPtr = NULL; - d->fifo_first = NULL; - d->fifo_last = NULL; - d->pending_first = NULL; - d->pending_last = NULL; + INIT_LIST_HEAD(&d->fifo_list); + INIT_LIST_HEAD(&d->pending_list); DBGMSG(ohci->id, "Transmit DMA ctx=%d initialized", d->ctx); } @@ -789,13 +787,7 @@ d->free_prgs--; /* queue the packet in the appropriate context queue */ - if (d->fifo_last) { - d->fifo_last->xnext = packet; - d->fifo_last = packet; - } else { - d->fifo_first = packet; - d->fifo_last = packet; - } + list_add_tail(&packet->driver_list, &d->fifo_list); d->prg_ind = (d->prg_ind+1)%d->num_desc; } @@ -807,22 +799,24 @@ */ static int dma_trm_flush(struct ti_ohci *ohci, struct dma_trm_ctx *d) { + struct hpsb_packet *p; int idx,z; - if (d->pending_first == NULL || d->free_prgs == 0) + if (list_empty(&d->pending_list) || d->free_prgs == 0) return 0; + p = driver_packet(d->pending_list.next); idx = d->prg_ind; - z = (d->pending_first->data_size) ? 3 : 2; + z = (p->data_size) ? 3 : 2; /* insert the packets into the at dma fifo */ - while (d->free_prgs>0 && d->pending_first) { - insert_packet(ohci, d, d->pending_first); - d->pending_first = d->pending_first->xnext; - } - if (d->pending_first == NULL) - d->pending_last = NULL; - else + while (d->free_prgs > 0 && !list_empty(&d->pending_list)) { + struct hpsb_packet *p = driver_packet(d->pending_list.next); + list_del(&p->driver_list); + insert_packet(ohci, d, p); + } + + if (d->free_prgs == 0) PRINT(KERN_INFO, ohci->id, "Transmit DMA FIFO ctx=%d is full... waiting",d->ctx); @@ -857,7 +851,6 @@ packet->data_size); return 0; } - packet->xnext = NULL; /* Decide wether we have an iso, a request, or a response packet */ tcode = (packet->header[0]>>4)&0xf; @@ -867,15 +860,7 @@ spin_lock_irqsave(&d->lock,flags); - /* queue the packet for later insertion into the dma fifo */ - if (d->pending_last) { - d->pending_last->xnext = packet; - d->pending_last = packet; - } - else { - d->pending_first = packet; - d->pending_last = packet; - } + list_add_tail(&packet->driver_list, &d->pending_list); dma_trm_flush(ohci, d); @@ -1033,46 +1018,38 @@ static void dma_trm_reset(struct dma_trm_ctx *d) { - struct ti_ohci *ohci; unsigned long flags; - struct hpsb_packet *nextpacket; + LIST_HEAD(packet_list); - if (d==NULL) { - PRINT_G(KERN_ERR, "dma_trm_reset called with NULL arg"); - return; - } - ohci = (struct ti_ohci *)(d->ohci); - ohci1394_stop_context(ohci, d->ctrlClear, NULL); + ohci1394_stop_context(d->ohci, d->ctrlClear, NULL); - spin_lock_irqsave(&d->lock,flags); + /* Lock the context, reset it and release it. Move the packets + * that were pending in the context to packet_list and free + * them after releasing the lock. */ - /* Is there still any packet pending in the fifo ? */ - while(d->fifo_first) { - PRINT(KERN_INFO, ohci->id, - "AT dma reset ctx=%d, aborting transmission", - d->ctx); - nextpacket = d->fifo_first->xnext; - hpsb_packet_sent(ohci->host, d->fifo_first, ACKX_ABORTED); - d->fifo_first = nextpacket; - } - d->fifo_first = d->fifo_last = NULL; + spin_lock_irqsave(&d->lock, flags); - /* is there still any packet pending ? */ - while(d->pending_first) { - PRINT(KERN_INFO, ohci->id, - "AT dma reset ctx=%d, aborting transmission", - d->ctx); - nextpacket = d->pending_first->xnext; - hpsb_packet_sent(ohci->host, d->pending_first, - ACKX_ABORTED); - d->pending_first = nextpacket; - } - d->pending_first = d->pending_last = NULL; - - d->branchAddrPtr=NULL; + list_splice(&d->fifo_list, &packet_list); + list_splice(&d->pending_list, &packet_list); + INIT_LIST_HEAD(&d->fifo_list); + INIT_LIST_HEAD(&d->pending_list); + + d->branchAddrPtr = NULL; d->sent_ind = d->prg_ind; d->free_prgs = d->num_desc; - spin_unlock_irqrestore(&d->lock,flags); + + spin_unlock_irqrestore(&d->lock, flags); + + /* Now process subsystem callbacks for the packets from the + * context. */ + + while (!list_empty(&packet_list)) { + struct hpsb_packet *p = driver_packet(packet_list.next); + PRINT(KERN_INFO, d->ohci->id, + "AT dma reset ctx=%d, aborting transmission", d->ctx); + list_del(&p->driver_list); + hpsb_packet_sent(d->ohci->host, p, ACKX_ABORTED); + } } static void ohci_irq_handler(int irq, void *dev_id, @@ -1507,25 +1484,16 @@ { struct dma_trm_ctx *d = (struct dma_trm_ctx*)data; struct ti_ohci *ohci = (struct ti_ohci*)(d->ohci); - struct hpsb_packet *packet, *nextpacket; + struct hpsb_packet *packet; unsigned long flags; u32 ack; size_t datasize; spin_lock_irqsave(&d->lock, flags); - if (d->fifo_first == NULL) { -#if 0 - ohci1394_stop_context(ohci, d->ctrlClear, - "Packet sent ack received but queue is empty"); -#endif - spin_unlock_irqrestore(&d->lock, flags); - return; - } - - while (d->fifo_first) { - packet = d->fifo_first; - datasize = d->fifo_first->data_size; + while (!list_empty(&d->fifo_list)) { + packet = driver_packet(d->fifo_list.next); + datasize = packet->data_size; if (datasize && packet->type != hpsb_raw) ack = le32_to_cpu( d->prg_cpu[d->sent_ind]->end.status) >> 16; @@ -1576,7 +1544,7 @@ d->ctx); #endif - nextpacket = packet->xnext; + list_del(&packet->driver_list); hpsb_packet_sent(ohci->host, packet, ack & 0xf); if (datasize) { @@ -1588,10 +1556,7 @@ d->sent_ind = (d->sent_ind+1)%d->num_desc; d->free_prgs++; - d->fifo_first = nextpacket; } - if (d->fifo_first == NULL) - d->fifo_last = NULL; dma_trm_flush(ohci, d); Modified: trunk/ieee1394_core.h ============================================================================== --- trunk/ieee1394_core.h (original) +++ trunk/ieee1394_core.h 2002-08-25 20:55:34.000000000 -0400 @@ -16,7 +16,7 @@ struct list_head list; /* This can be used for host driver internal linking. */ - struct hpsb_packet *xnext; + struct list_head driver_list; nodeid_t node_id; @@ -77,6 +77,10 @@ quadlet_t embedded_header[5]; }; +static inline struct hpsb_packet *driver_packet(struct list_head *l) +{ + return list_entry(l, struct hpsb_packet, driver_list); +} void abort_timedouts(struct hpsb_host *host); void abort_requests(struct hpsb_host *host); Modified: trunk/ohci1394.h ============================================================================== --- trunk/ohci1394.h (original) +++ trunk/ohci1394.h 2002-08-25 20:55:34.000000000 -0400 @@ -127,12 +127,10 @@ quadlet_t *branchAddrPtr; /* list of packets inserted in the AT FIFO */ - struct hpsb_packet *fifo_first; - struct hpsb_packet *fifo_last; + struct list_head fifo_list; /* list of pending packets to be inserted in the AT FIFO */ - struct hpsb_packet *pending_first; - struct hpsb_packet *pending_last; + struct list_head pending_list; spinlock_t lock; struct tasklet_struct task; Modified: trunk/pcilynx.c ============================================================================== --- trunk/pcilynx.c (original) +++ trunk/pcilynx.c 2002-08-25 20:55:34.000000000 -0400 @@ -466,7 +466,7 @@ struct hpsb_packet *packet; d = (what == hpsb_iso ? &lynx->iso_send : &lynx->async); - packet = d->queue; + packet = driver_packet(d->queue.next); d->header_dma = pci_map_single(lynx->dev, packet->header, packet->header_size, PCI_DMA_TODEVICE); @@ -538,7 +538,6 @@ return 0; } - packet->xnext = NULL; if (packet->tcode == TCODE_WRITEQ || packet->tcode == TCODE_READQ_RESPONSE) { cpu_to_be32s(&packet->header[3]); @@ -546,14 +545,9 @@ spin_lock_irqsave(&d->queue_lock, flags); - if (d->queue == NULL) { - d->queue = packet; - d->queue_last = packet; + list_add_tail(&packet->driver_list, &d->queue); + if (d->queue.next == &packet->driver_list) send_next(lynx, packet->type); - } else { - d->queue_last->xnext = packet; - d->queue_last = packet; - } spin_unlock_irqrestore(&d->queue_lock, flags); @@ -566,7 +560,8 @@ { struct ti_lynx *lynx = host->hostdata; int retval = 0; - struct hpsb_packet *packet, *lastpacket; + struct hpsb_packet *packet; + LIST_HEAD(packet_list); unsigned long flags; switch (cmd) { @@ -620,16 +615,16 @@ spin_lock_irqsave(&lynx->async.queue_lock, flags); reg_write(lynx, DMA_CHAN_CTRL(CHANNEL_ASYNC_SEND), 0); - packet = lynx->async.queue; - lynx->async.queue = NULL; + list_splice(&lynx->async.queue, &packet_list); + INIT_LIST_HEAD(&lynx->async.queue); spin_unlock_irqrestore(&lynx->async.queue_lock, flags); - while (packet != NULL) { - lastpacket = packet; - packet = packet->xnext; - hpsb_packet_sent(host, lastpacket, ACKX_ABORTED); - } + while (!list_empty(&packet_list)) { + packet = driver_packet(packet_list.next); + list_del(&packet->driver_list); + hpsb_packet_sent(host, packet, ACKX_ABORTED); + } break; @@ -1122,8 +1117,9 @@ spin_lock(&lynx->async.queue_lock); ack = reg_read(lynx, DMA_CHAN_STAT(CHANNEL_ASYNC_SEND)); - packet = lynx->async.queue; - lynx->async.queue = packet->xnext; + + packet = driver_packet(lynx->async.queue.next); + list_del(&packet->driver_list); pci_unmap_single(lynx->dev, lynx->async.header_dma, packet->header_size, PCI_DMA_TODEVICE); @@ -1132,7 +1128,7 @@ packet->data_size, PCI_DMA_TODEVICE); } - if (lynx->async.queue != NULL) { + if (!list_empty(&lynx->async.queue)) { send_next(lynx, hpsb_async); } @@ -1154,8 +1150,8 @@ spin_lock(&lynx->iso_send.queue_lock); - packet = lynx->iso_send.queue; - lynx->iso_send.queue = packet->xnext; + packet = driver_packet(lynx->iso_send.queue.next); + list_del(&packet->driver_list); pci_unmap_single(lynx->dev, lynx->iso_send.header_dma, packet->header_size, PCI_DMA_TODEVICE); @@ -1164,7 +1160,7 @@ packet->data_size, PCI_DMA_TODEVICE); } - if (lynx->iso_send.queue != NULL) { + if (!list_empty(&lynx->iso_send.queue)) { send_next(lynx, hpsb_iso); } @@ -1471,7 +1467,8 @@ lynx->selfid_size = -1; lynx->phy_reg0 = -1; - lynx->async.queue = NULL; + INIT_LIST_HEAD(&lynx->async.queue); + INIT_LIST_HEAD(&lynx->iso_send.queue); pcl.next = pcl_bus(lynx, lynx->rcv_pcl); put_pcl(lynx, lynx->rcv_pcl_start, &pcl); Modified: trunk/pcilynx.h ============================================================================== --- trunk/pcilynx.h (original) +++ trunk/pcilynx.h 2002-08-25 20:55:34.000000000 -0400 @@ -94,7 +94,7 @@ struct lynx_send_data { pcl_t pcl_start, pcl; - struct hpsb_packet *queue, *queue_last; + struct list_head queue; spinlock_t queue_lock; dma_addr_t header_dma, data_dma; int channel; |