GIT aeeb3c3d581a0c09168749f5e3325a29dc09b5e0 git+ssh://master.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git commit Author: Stefan Richter Date: Fri May 11 23:04:08 2007 +0200 firewire: fw-sbp2: remove unused struct member cleanup after support of single-buffer requests was dropped Signed-off-by: Stefan Richter Signed-off-by: Kristian Hoegsberg commit c4c72f24bb4fbfb1cb5c2bd37692e5d63fad89c9 Author: Jan Engelhardt Date: Mon Apr 30 13:29:32 2007 +0200 Use menuconfig objects II - IEEE1394 Make a "menuconfig" out of the Kconfig objects "menu, ..., endmenu", so that the user can disable all the options in that menu at once instead of having to disable each option separately. Follows Stefan's suggestion as per http://lkml.org/lkml/2007/4/28/108 Signed-off-by: Jan Engelhardt Signed-off-by: Andrew Morton Signed-off-by: Stefan Richter commit 27d5aaf2b722643446b6a9d54040c5da867ad767 Author: Stefan Richter Date: Sat May 5 17:25:51 2007 +0200 ieee1394: eth1394: handle tlabel exhaustion When eth1394 was unable to acquire a transaction label, it just dropped outgoing packets without attempt to resend them later. The transmit queue is now halted if no tlabel is available to ->hard_start_xmit(). A workqueue job is then scheduled to catch the moment when ieee1394 recycled the next lot of tlabels. Fixes http://bugzilla.kernel.org/show_bug.cgi?id=8402 Signed-off-by: Stefan Richter commit e2e88fbd4d0ffbce7bfd28b2a722d5b2149258ef Author: Stefan Richter Date: Sat May 5 17:19:09 2007 +0200 ieee1394: eth1394: remove bogus netif_wake_queue When we are within hard_start_xmit, the queue is already awake. Signed-off-by: Stefan Richter commit 6386867e80a3b5cfaa9b97ffc1c23e9ef34d8a18 Author: Stefan Richter Date: Sat May 5 17:18:12 2007 +0200 ieee1394: sbp2: include workqueue.h Signed-off-by: Stefan Richter commit 8a651d789bdd68c717ef60d63fc6a115b98b9b31 Author: Stefan Richter Date: Thu May 3 20:24:19 2007 +0200 ieee1394: ohci1394: remove dead CONFIG variable spotted by Robert P. J. Day Signed-off-by: Stefan Richter drivers/firewire/fw-sbp2.c | 6 --- drivers/ieee1394/Kconfig | 8 +++- drivers/ieee1394/eth1394.c | 84 ++++++++++++++++++++++++++++++++----------- drivers/ieee1394/eth1394.h | 4 ++ drivers/ieee1394/ohci1394.c | 51 ++++---------------------- drivers/ieee1394/sbp2.c | 1 + 6 files changed, 82 insertions(+), 72 deletions(-) diff --git a/drivers/firewire/fw-sbp2.c b/drivers/firewire/fw-sbp2.c index 6830041..3ac252d 100644 --- a/drivers/firewire/fw-sbp2.c +++ b/drivers/firewire/fw-sbp2.c @@ -207,7 +207,6 @@ struct sbp2_command_orb { struct sbp2_pointer page_table[SG_ALL]; dma_addr_t page_table_bus; - dma_addr_t request_buffer_bus; }; /* @@ -882,11 +881,6 @@ complete_command_orb(struct sbp2_orb *ba dma_unmap_single(device->card->device, orb->page_table_bus, sizeof(orb->page_table_bus), DMA_TO_DEVICE); - if (orb->request_buffer_bus != 0) - dma_unmap_single(device->card->device, orb->request_buffer_bus, - sizeof(orb->request_buffer_bus), - DMA_FROM_DEVICE); - orb->cmd->result = result; orb->done(orb->cmd); kfree(orb); diff --git a/drivers/ieee1394/Kconfig b/drivers/ieee1394/Kconfig index 8012b3b..a16b73c 100644 --- a/drivers/ieee1394/Kconfig +++ b/drivers/ieee1394/Kconfig @@ -1,5 +1,9 @@ -menu "IEEE 1394 (FireWire) support" +menuconfig IEEE1394_SUPPORT + bool "IEEE 1394 (FireWire) support" depends on PCI || BROKEN + default y + +if IEEE1394_SUPPORT source "drivers/firewire/Kconfig" @@ -147,4 +151,4 @@ config IEEE1394_RAWIO To compile this driver as a module, say M here: the module will be called raw1394. -endmenu +endif # IEEE1394_SUPPORT diff --git a/drivers/ieee1394/eth1394.c b/drivers/ieee1394/eth1394.c index 2296d43..d6b19c2 100644 --- a/drivers/ieee1394/eth1394.c +++ b/drivers/ieee1394/eth1394.c @@ -47,6 +47,7 @@ #include #include #include #include +#include #include #include @@ -235,6 +236,9 @@ static int ether1394_open(struct net_dev /* This is called after an "ifdown" */ static int ether1394_stop(struct net_device *dev) { + /* flush priv->wake */ + flush_scheduled_work(); + netif_stop_queue(dev); return 0; } @@ -531,6 +535,37 @@ static void ether1394_init_dev(struct ne } /* + * Wake the queue up after commonly encountered transmit failure conditions are + * hopefully over. Currently only tlabel exhaustion is accounted for. + */ +static void ether1394_wake_queue(struct work_struct *work) +{ + struct eth1394_priv *priv; + struct hpsb_packet *packet; + + priv = container_of(work, struct eth1394_priv, wake); + packet = hpsb_alloc_packet(0); + + /* This is really bad, but unjam the queue anyway. */ + if (!packet) + goto out; + + packet->host = priv->host; + packet->node_id = priv->wake_node; + /* + * A transaction label is all we really want. If we get one, it almost + * always means we can get a lot more because the ieee1394 core recycled + * a whole batch of tlabels, at last. + */ + if (hpsb_get_tlabel(packet) == 0) + hpsb_free_tlabel(packet); + + hpsb_free_packet(packet); +out: + netif_wake_queue(priv->wake_dev); +} + +/* * This function is called every time a card is found. It is generally called * when the module is installed. This is where we add all of our ethernet * devices. One for each host. @@ -574,6 +609,8 @@ #endif spin_lock_init(&priv->lock); priv->host = host; priv->local_fifo = fifo_addr; + INIT_WORK(&priv->wake, ether1394_wake_queue); + priv->wake_dev = dev; hi = hpsb_create_hostinfo(ð1394_highlevel, host, sizeof(*hi)); if (hi == NULL) { @@ -1390,22 +1427,17 @@ static int ether1394_prep_write_packet(s u64 addr, void *data, int tx_len) { p->node_id = node; - p->data = NULL; - p->tcode = TCODE_WRITEB; - p->header[1] = host->node_id << 16 | addr >> 32; - p->header[2] = addr & 0xffffffff; + if (hpsb_get_tlabel(p)) + return -EAGAIN; + p->tcode = TCODE_WRITEB; p->header_size = 16; p->expect_response = 1; - - if (hpsb_get_tlabel(p)) { - ETH1394_PRINT_G(KERN_ERR, "Out of tlabels\n"); - return -1; - } p->header[0] = p->node_id << 16 | p->tlabel << 10 | 1 << 8 | TCODE_WRITEB << 4; - + p->header[1] = host->node_id << 16 | addr >> 32; + p->header[2] = addr & 0xffffffff; p->header[3] = tx_len << 16; p->data_size = (tx_len + 3) & ~3; p->data = data; @@ -1451,7 +1483,7 @@ static int ether1394_send_packet(struct packet = ether1394_alloc_common_packet(priv->host); if (!packet) - return -1; + return -ENOMEM; if (ptask->tx_type == ETH1394_GASP) { int length = tx_len + 2 * sizeof(quadlet_t); @@ -1462,7 +1494,7 @@ static int ether1394_send_packet(struct ptask->addr, ptask->skb->data, tx_len)) { hpsb_free_packet(packet); - return -1; + return -EAGAIN; } ptask->packet = packet; @@ -1471,7 +1503,7 @@ static int ether1394_send_packet(struct if (hpsb_send_packet(packet) < 0) { ether1394_free_packet(packet); - return -1; + return -EIO; } return 0; @@ -1514,13 +1546,18 @@ static void ether1394_complete_cb(void * ptask->outstanding_pkts--; if (ptask->outstanding_pkts > 0 && !fail) { - int tx_len; + int tx_len, err; /* Add the encapsulation header to the fragment */ tx_len = ether1394_encapsulate(ptask->skb, ptask->max_payload, &ptask->hdr); - if (ether1394_send_packet(ptask, tx_len)) + err = ether1394_send_packet(ptask, tx_len); + if (err) { + if (err == -EAGAIN) + ETH1394_PRINT_G(KERN_ERR, "Out of tlabels\n"); + ether1394_dg_complete(ptask, 1); + } } else { ether1394_dg_complete(ptask, fail); } @@ -1633,10 +1670,18 @@ #endif /* Add the encapsulation header to the fragment */ tx_len = ether1394_encapsulate(skb, max_payload, &ptask->hdr); dev->trans_start = jiffies; - if (ether1394_send_packet(ptask, tx_len)) - goto fail; + if (ether1394_send_packet(ptask, tx_len)) { + if (dest_node == (LOCAL_BUS | ALL_NODES)) + goto fail; + + /* Most failures of ether1394_send_packet are recoverable. */ + netif_stop_queue(dev); + priv->wake_node = dest_node; + schedule_work(&priv->wake); + kmem_cache_free(packet_task_cache, ptask); + return NETDEV_TX_BUSY; + } - netif_wake_queue(dev); return NETDEV_TX_OK; fail: if (ptask) @@ -1650,9 +1695,6 @@ fail: priv->stats.tx_errors++; spin_unlock_irqrestore(&priv->lock, flags); - if (netif_queue_stopped(dev)) - netif_wake_queue(dev); - /* * FIXME: According to a patch from 2003-02-26, "returning non-zero * causes serious problems" here, allegedly. Before that patch, diff --git a/drivers/ieee1394/eth1394.h b/drivers/ieee1394/eth1394.h index a3439ee..4f3e2dd 100644 --- a/drivers/ieee1394/eth1394.h +++ b/drivers/ieee1394/eth1394.h @@ -66,6 +66,10 @@ struct eth1394_priv { int bc_dgl; /* Outgoing broadcast datagram label */ struct list_head ip_node_list; /* List of IP capable nodes */ struct unit_directory *ud_list[ALL_NODES]; /* Cached unit dir list */ + + struct work_struct wake; /* Wake up after xmit failure */ + struct net_device *wake_dev; /* Stupid backlink for .wake */ + nodeid_t wake_node; /* Destination of failed xmit */ }; diff --git a/drivers/ieee1394/ohci1394.c b/drivers/ieee1394/ohci1394.c index 5dadfd2..a75b144 100644 --- a/drivers/ieee1394/ohci1394.c +++ b/drivers/ieee1394/ohci1394.c @@ -138,19 +138,6 @@ #else #define DBGMSG(fmt, args...) do {} while (0) #endif -#ifdef CONFIG_IEEE1394_OHCI_DMA_DEBUG -#define OHCI_DMA_ALLOC(fmt, args...) \ - HPSB_ERR("%s(%s)alloc(%d): "fmt, OHCI1394_DRIVER_NAME, __FUNCTION__, \ - ++global_outstanding_dmas, ## args) -#define OHCI_DMA_FREE(fmt, args...) \ - HPSB_ERR("%s(%s)free(%d): "fmt, OHCI1394_DRIVER_NAME, __FUNCTION__, \ - --global_outstanding_dmas, ## args) -static int global_outstanding_dmas = 0; -#else -#define OHCI_DMA_ALLOC(fmt, args...) do {} while (0) -#define OHCI_DMA_FREE(fmt, args...) do {} while (0) -#endif - /* print general (card independent) information */ #define PRINT_G(level, fmt, args...) \ printk(level "%s: " fmt "\n" , OHCI1394_DRIVER_NAME , ## args) @@ -733,7 +720,6 @@ #endif pci_map_single(ohci->dev, packet->data, packet->data_size, PCI_DMA_TODEVICE)); - OHCI_DMA_ALLOC("single, block transmit packet"); d->prg_cpu[idx]->end.branchAddress = 0; d->prg_cpu[idx]->end.status = 0; @@ -783,7 +769,6 @@ #endif d->prg_cpu[idx]->end.address = cpu_to_le32( pci_map_single(ohci->dev, packet->data, packet->data_size, PCI_DMA_TODEVICE)); - OHCI_DMA_ALLOC("single, iso transmit packet"); d->prg_cpu[idx]->end.branchAddress = 0; d->prg_cpu[idx]->end.status = 0; @@ -2869,12 +2854,10 @@ #endif list_del_init(&packet->driver_list); hpsb_packet_sent(ohci->host, packet, ack); - if (datasize) { + if (datasize) pci_unmap_single(ohci->dev, cpu_to_le32(d->prg_cpu[d->sent_ind]->end.address), datasize, PCI_DMA_TODEVICE); - OHCI_DMA_FREE("single Xmit data packet"); - } d->sent_ind = (d->sent_ind+1)%d->num_desc; d->free_prgs++; @@ -2913,23 +2896,19 @@ static void free_dma_rcv_ctx(struct dma_ if (d->buf_cpu) { for (i=0; inum_desc; i++) - if (d->buf_cpu[i] && d->buf_bus[i]) { + if (d->buf_cpu[i] && d->buf_bus[i]) pci_free_consistent( ohci->dev, d->buf_size, d->buf_cpu[i], d->buf_bus[i]); - OHCI_DMA_FREE("consistent dma_rcv buf[%d]", i); - } kfree(d->buf_cpu); kfree(d->buf_bus); } if (d->prg_cpu) { for (i=0; inum_desc; i++) - if (d->prg_cpu[i] && d->prg_bus[i]) { - pci_pool_free(d->prg_pool, d->prg_cpu[i], d->prg_bus[i]); - OHCI_DMA_FREE("consistent dma_rcv prg[%d]", i); - } + if (d->prg_cpu[i] && d->prg_bus[i]) + pci_pool_free(d->prg_pool, d->prg_cpu[i], + d->prg_bus[i]); pci_pool_destroy(d->prg_pool); - OHCI_DMA_FREE("dma_rcv prg pool"); kfree(d->prg_cpu); kfree(d->prg_bus); } @@ -2998,13 +2977,10 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, } num_allocs++; - OHCI_DMA_ALLOC("dma_rcv prg pool"); - for (i=0; inum_desc; i++) { d->buf_cpu[i] = pci_alloc_consistent(ohci->dev, d->buf_size, d->buf_bus+i); - OHCI_DMA_ALLOC("consistent dma_rcv buf[%d]", i); if (d->buf_cpu[i] != NULL) { memset(d->buf_cpu[i], 0, d->buf_size); @@ -3016,7 +2992,6 @@ alloc_dma_rcv_ctx(struct ti_ohci *ohci, } d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, GFP_KERNEL, d->prg_bus+i); - OHCI_DMA_ALLOC("pool dma_rcv prg[%d]", i); if (d->prg_cpu[i] != NULL) { memset(d->prg_cpu[i], 0, sizeof(struct dma_cmd)); @@ -3057,12 +3032,10 @@ static void free_dma_trm_ctx(struct dma_ if (d->prg_cpu) { for (i=0; inum_desc; i++) - if (d->prg_cpu[i] && d->prg_bus[i]) { - pci_pool_free(d->prg_pool, d->prg_cpu[i], d->prg_bus[i]); - OHCI_DMA_FREE("pool dma_trm prg[%d]", i); - } + if (d->prg_cpu[i] && d->prg_bus[i]) + pci_pool_free(d->prg_pool, d->prg_cpu[i], + d->prg_bus[i]); pci_pool_destroy(d->prg_pool); - OHCI_DMA_FREE("dma_trm prg pool"); kfree(d->prg_cpu); kfree(d->prg_bus); } @@ -3108,11 +3081,8 @@ alloc_dma_trm_ctx(struct ti_ohci *ohci, } num_allocs++; - OHCI_DMA_ALLOC("dma_rcv prg pool"); - for (i = 0; i < d->num_desc; i++) { d->prg_cpu[i] = pci_pool_alloc(d->prg_pool, GFP_KERNEL, d->prg_bus+i); - OHCI_DMA_ALLOC("pool dma_trm prg[%d]", i); if (d->prg_cpu[i] != NULL) { memset(d->prg_cpu[i], 0, sizeof(struct at_dma_prg)); @@ -3294,7 +3264,6 @@ #endif ohci->csr_config_rom_cpu = pci_alloc_consistent(ohci->dev, OHCI_CONFIG_ROM_LEN, &ohci->csr_config_rom_bus); - OHCI_DMA_ALLOC("consistent csr_config_rom"); if (ohci->csr_config_rom_cpu == NULL) FAIL(-ENOMEM, "Failed to allocate buffer config rom"); ohci->init_state = OHCI_INIT_HAVE_CONFIG_ROM_BUFFER; @@ -3303,8 +3272,6 @@ #endif ohci->selfid_buf_cpu = pci_alloc_consistent(ohci->dev, OHCI1394_SI_DMA_BUF_SIZE, &ohci->selfid_buf_bus); - OHCI_DMA_ALLOC("consistent selfid_buf"); - if (ohci->selfid_buf_cpu == NULL) FAIL(-ENOMEM, "Failed to allocate DMA buffer for self-id packets"); ohci->init_state = OHCI_INIT_HAVE_SELFID_BUFFER; @@ -3490,13 +3457,11 @@ static void ohci1394_pci_remove(struct p pci_free_consistent(ohci->dev, OHCI1394_SI_DMA_BUF_SIZE, ohci->selfid_buf_cpu, ohci->selfid_buf_bus); - OHCI_DMA_FREE("consistent selfid_buf"); case OHCI_INIT_HAVE_CONFIG_ROM_BUFFER: pci_free_consistent(ohci->dev, OHCI_CONFIG_ROM_LEN, ohci->csr_config_rom_cpu, ohci->csr_config_rom_bus); - OHCI_DMA_FREE("consistent csr_config_rom"); case OHCI_INIT_HAVE_IOMAPPING: iounmap(ohci->registers); diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 4cb6fa2..875eadd 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -70,6 +70,7 @@ #include #include #include #include +#include #include #include