Skip to content

Commit

Permalink
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…
Browse files Browse the repository at this point in the history
…/git/ieee1394/linux1394-2.6

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6:
  firewire: ohci: retransmit isochronous transmit packets on cycle loss
  firewire: net: fix panic in fwnet_write_complete
  • Loading branch information
Linus Torvalds committed Feb 16, 2010
2 parents d277993 + 7f51a10 commit 382640b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 19 deletions.
53 changes: 39 additions & 14 deletions drivers/firewire/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,20 +893,31 @@ static void fwnet_receive_broadcast(struct fw_iso_context *context,

static struct kmem_cache *fwnet_packet_task_cache;

static void fwnet_free_ptask(struct fwnet_packet_task *ptask)
{
dev_kfree_skb_any(ptask->skb);
kmem_cache_free(fwnet_packet_task_cache, ptask);
}

static int fwnet_send_packet(struct fwnet_packet_task *ptask);

static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask)
{
struct fwnet_device *dev;
struct fwnet_device *dev = ptask->dev;
unsigned long flags;

dev = ptask->dev;
bool free;

spin_lock_irqsave(&dev->lock, flags);
list_del(&ptask->pt_link);
spin_unlock_irqrestore(&dev->lock, flags);

ptask->outstanding_pkts--; /* FIXME access inside lock */
ptask->outstanding_pkts--;

/* Check whether we or the networking TX soft-IRQ is last user. */
free = (ptask->outstanding_pkts == 0 && !list_empty(&ptask->pt_link));

if (ptask->outstanding_pkts == 0)
list_del(&ptask->pt_link);

spin_unlock_irqrestore(&dev->lock, flags);

if (ptask->outstanding_pkts > 0) {
u16 dg_size;
Expand Down Expand Up @@ -951,10 +962,10 @@ static void fwnet_transmit_packet_done(struct fwnet_packet_task *ptask)
ptask->max_payload = skb->len + RFC2374_FRAG_HDR_SIZE;
}
fwnet_send_packet(ptask);
} else {
dev_kfree_skb_any(ptask->skb);
kmem_cache_free(fwnet_packet_task_cache, ptask);
}

if (free)
fwnet_free_ptask(ptask);
}

static void fwnet_write_complete(struct fw_card *card, int rcode,
Expand All @@ -977,6 +988,7 @@ static int fwnet_send_packet(struct fwnet_packet_task *ptask)
unsigned tx_len;
struct rfc2734_header *bufhdr;
unsigned long flags;
bool free;

dev = ptask->dev;
tx_len = ptask->max_payload;
Expand Down Expand Up @@ -1022,25 +1034,36 @@ static int fwnet_send_packet(struct fwnet_packet_task *ptask)
generation, SCODE_100, 0ULL, ptask->skb->data,
tx_len + 8, fwnet_write_complete, ptask);

/* FIXME race? */
spin_lock_irqsave(&dev->lock, flags);
list_add_tail(&ptask->pt_link, &dev->broadcasted_list);

/* If the AT tasklet already ran, we may be last user. */
free = (ptask->outstanding_pkts == 0 && list_empty(&ptask->pt_link));
if (!free)
list_add_tail(&ptask->pt_link, &dev->broadcasted_list);

spin_unlock_irqrestore(&dev->lock, flags);

return 0;
goto out;
}

fw_send_request(dev->card, &ptask->transaction,
TCODE_WRITE_BLOCK_REQUEST, ptask->dest_node,
ptask->generation, ptask->speed, ptask->fifo_addr,
ptask->skb->data, tx_len, fwnet_write_complete, ptask);

/* FIXME race? */
spin_lock_irqsave(&dev->lock, flags);
list_add_tail(&ptask->pt_link, &dev->sent_list);

/* If the AT tasklet already ran, we may be last user. */
free = (ptask->outstanding_pkts == 0 && list_empty(&ptask->pt_link));
if (!free)
list_add_tail(&ptask->pt_link, &dev->sent_list);

spin_unlock_irqrestore(&dev->lock, flags);

dev->netdev->trans_start = jiffies;
out:
if (free)
fwnet_free_ptask(ptask);

return 0;
}
Expand Down Expand Up @@ -1298,6 +1321,8 @@ static netdev_tx_t fwnet_tx(struct sk_buff *skb, struct net_device *net)
spin_unlock_irqrestore(&dev->lock, flags);

ptask->max_payload = max_payload;
INIT_LIST_HEAD(&ptask->pt_link);

fwnet_send_packet(ptask);

return NETDEV_TX_OK;
Expand Down
13 changes: 8 additions & 5 deletions drivers/firewire/ohci.c
Original file line number Diff line number Diff line change
Expand Up @@ -2101,11 +2101,6 @@ static int ohci_queue_iso_transmit(struct fw_iso_context *base,
u32 payload_index, payload_end_index, next_page_index;
int page, end_page, i, length, offset;

/*
* FIXME: Cycle lost behavior should be configurable: lose
* packet, retransmit or terminate..
*/

p = packet;
payload_index = payload;

Expand Down Expand Up @@ -2135,6 +2130,14 @@ static int ohci_queue_iso_transmit(struct fw_iso_context *base,
if (!p->skip) {
d[0].control = cpu_to_le16(DESCRIPTOR_KEY_IMMEDIATE);
d[0].req_count = cpu_to_le16(8);
/*
* Link the skip address to this descriptor itself. This causes
* a context to skip a cycle whenever lost cycles or FIFO
* overruns occur, without dropping the data. The application
* should then decide whether this is an error condition or not.
* FIXME: Make the context's cycle-lost behaviour configurable?
*/
d[0].branch_address = cpu_to_le32(d_bus | z);

header = (__le32 *) &d[1];
header[0] = cpu_to_le32(IT_HEADER_SY(p->sy) |
Expand Down

0 comments on commit 382640b

Please sign in to comment.