Skip to contentSkip to conversation

FireWire updates post 2.6.37

GIT PULL Stefan Richter 1 participant 3 messages Jan 7, 2011 – Jan 13, 2011 Firewire

lore
Share & tools
lore
#0 lore raw

Linus, please pull from the for-linus branch at

    git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git for-linus

to receive the following updates for the IEEE 1394 (FireWire) subsystem. Most importantly this improves reception of asynchronous block packets with larger payload (outside physical DMA), as used by IP over 1394 or for example forensics applications.

As not all patches had been crossposted to lkml yet, I will send the full log and diff as reply to this mail.

Clemens Ladisch (10):
firewire: ohci: Asynchronous Reception rewrite
firewire: ohci: fix AT context initialization error handling
firewire: ohci: flush MMIO writes in the interrupt handler
firewire: ohci: properly clear posted write errors
firewire: make PHY packet header format consistent
firewire: ohci: optimize iso context checks in the interrupt handler
firewire: ohci: use common buffer for self IDs and AR descriptors
firewire: ohci: flush AT contexts after bus reset for OHCI 1.2
firewire: ohci: cache the context run bit
firewire: use split transaction timeout only for split transactions

Joe Perches (1):
firewire: core: Update WARN uses

Maxim Levitsky (4):
firewire: ohci: restore GUID on resume.
firewire: ohci: restart iso DMA contexts on resume from low power mode
firewire: net: ratelimit error messages
firewire: net: add carrier detection

Stefan Richter (4):
firewire: nosy: char device is not seekable
firewire: net: set carrier state at ifup
firewire: ohci: flush AT contexts after bus reset - addendum
firewire: ohci: consolidate context status flags

 drivers/firewire/Kconfig            |    2 +-
 drivers/firewire/core-cdev.c        |    7 +-
 drivers/firewire/core-transaction.c |   58 ++-
 drivers/firewire/core.h             |    4 +-
 drivers/firewire/net.c              |   47 ++-
 drivers/firewire/nosy.c             |    3 +-
 drivers/firewire/ohci.c             |  672 ++++++++++++++++++++++++-----------
 include/linux/firewire.h            |    2 +-
 8 files changed, 548 insertions(+), 247 deletions(-)

Thanks,

Signature · 3 lines
Stefan Richter
-=====-==-== ---= --===
http://arcgraph.de/sr/
author Acked-by Jarod Wilson Tested-by Maxim Levitsky
#1 lore raw
Quoted 5 lines · On Jan 07 Stefan Richter wrote:

Linus, please pull from the for-linus branch at

    git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git for-linus

to receive the following updates for the IEEE 1394 (FireWire) subsystem.

commit 410cf2bd3dc6ec1ed9e1b36b25b9d7aa927ed14e

Author: Clemens Ladisch <[email protected]>
Date:   Mon Dec 13 14:56:02 2010 +0100

firewire: use split transaction timeout only for split transactions

Instead of starting the split transaction timeout timer when any request is submitted, start it only when the destination's ACK_PENDING has been received. This prevents us from using a timeout that is too short, and, if the controller's AT queue is emptying very slowly, from cancelling a packet that has not yet been sent.

---
 drivers/firewire/core-transaction.c |   45 ++++++++++++++++++++++++----------
 include/linux/firewire.h            |    2 +-
 2 files changed, 33 insertions(+), 14 deletions(-)
drivers/firewire/core-transaction.c +32 -13
index 9e81cc5..d00f8ce 100644
@@ -72,6 +72,15 @@
 #define PHY_CONFIG_ROOT_ID(node_id)	((((node_id) & 0x3f) << 24) | (1 << 23))
 #define PHY_IDENTIFIER(id)		((id) << 30)
 
+/* returns 0 if the split timeout handler is already running */
+static int try_cancel_split_timeout(struct fw_transaction *t)
+{
+	if (t->is_split_transaction)
+		return del_timer(&t->split_timeout_timer);
+	else
+		return 1;
+}
+
 static int close_transaction(struct fw_transaction *transaction,
 			     struct fw_card *card, int rcode)
 {
@@ -81,7 +90,7 @@ static int close_transaction(struct fw_transaction *transaction,
 	spin_lock_irqsave(&card->lock, flags);
 	list_for_each_entry(t, &card->transaction_list, link) {
 		if (t == transaction) {
-			if (!del_timer(&t->split_timeout_timer)) {
+			if (!try_cancel_split_timeout(t)) {
 				spin_unlock_irqrestore(&card->lock, flags);
 				goto timed_out;
 			}
@@ -141,16 +150,28 @@ static void split_transaction_timeout_callback(unsigned long data)
 	card->tlabel_mask &= ~(1ULL << t->tlabel);
 	spin_unlock_irqrestore(&card->lock, flags);
 
-	card->driver->cancel_packet(card, &t->packet);
-
-	/*
-	 * At this point cancel_packet will never call the transaction
-	 * callback, since we just took the transaction out of the list.
-	 * So do it here.
-	 */
 	t->callback(card, RCODE_CANCELLED, NULL, 0, t->callback_data);
 }
 
+static void start_split_transaction_timeout(struct fw_transaction *t,
+					    struct fw_card *card)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&card->lock, flags);
+
+	if (list_empty(&t->link) || WARN_ON(t->is_split_transaction)) {
+		spin_unlock_irqrestore(&card->lock, flags);
+		return;
+	}
+
+	t->is_split_transaction = true;
+	mod_timer(&t->split_timeout_timer,
+		  jiffies + card->split_timeout_jiffies);
+
+	spin_unlock_irqrestore(&card->lock, flags);
+}
+
 static void transmit_complete_callback(struct fw_packet *packet,
 				       struct fw_card *card, int status)
 {
@@ -162,7 +183,7 @@ static void transmit_complete_callback(struct fw_packet *packet,
 		close_transaction(t, card, RCODE_COMPLETE);
 		break;
 	case ACK_PENDING:
-		t->timestamp = packet->timestamp;
+		start_split_transaction_timeout(t, card);
 		break;
 	case ACK_BUSY_X:
 	case ACK_BUSY_A:
@@ -349,11 +370,9 @@ void fw_send_request(struct fw_card *card, struct fw_transaction *t, int tcode,
 	t->node_id = destination_id;
 	t->tlabel = tlabel;
 	t->card = card;
+	t->is_split_transaction = false;
 	setup_timer(&t->split_timeout_timer,
 		    split_transaction_timeout_callback, (unsigned long)t);
-	/* FIXME: start this timer later, relative to t->timestamp */
-	mod_timer(&t->split_timeout_timer,
-		  jiffies + card->split_timeout_jiffies);
 	t->callback = callback;
 	t->callback_data = callback_data;
 
@@ -926,7 +945,7 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
 	spin_lock_irqsave(&card->lock, flags);
 	list_for_each_entry(t, &card->transaction_list, link) {
 		if (t->node_id == source && t->tlabel == tlabel) {
-			if (!del_timer(&t->split_timeout_timer)) {
+			if (!try_cancel_split_timeout(t)) {
 				spin_unlock_irqrestore(&card->lock, flags);
 				goto timed_out;
 			}
include/linux/firewire.h +1 -1
index 1cd637e..9a3f5f9 100644
@@ -302,9 +302,9 @@ struct fw_packet {
 struct fw_transaction {
 	int node_id; /* The generation is implied; it is always the current. */
 	int tlabel;
-	int timestamp;
 	struct list_head link;
 	struct fw_card *card;
+	bool is_split_transaction;
 	struct timer_list split_timeout_timer;
 
 	struct fw_packet packet;

commit 693a50b511818e07a131efc944cba1a504b63d3d

Author: Stefan Richter <[email protected]>
Date:   Sat Jan 1 15:17:05 2011 +0100

firewire: ohci: consolidate context status flags

"firewire: ohci: restart iso DMA contexts on resume from low power mode" added the flag struct context.active and "firewire: ohci: cache the context run bit" added struct context.running.

These flags contain the same information; combine them. Also, normalize whitespace in pci_resume().

---
 drivers/firewire/ohci.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)
drivers/firewire/ohci.c +3 -6
index 3ae84e2..d77d120 100644
@@ -156,7 +156,6 @@ struct context {
 	descriptor_callback_t callback;
 
 	struct tasklet_struct tasklet;
-	bool active;
 };
 
 #define IT_HEADER_SY(v)          ((v) <<  0)
@@ -1169,7 +1168,6 @@ static struct descriptor *context_get_descriptors(struct context *ctx,
 static void context_run(struct context *ctx, u32 extra)
 {
 	struct fw_ohci *ohci = ctx->ohci;
-	ctx->active = true;
 
 	reg_write(ohci, COMMAND_PTR(ctx->regs),
 		  le32_to_cpu(ctx->last->branch_address));
@@ -1202,7 +1200,6 @@ static void context_stop(struct context *ctx)
 	u32 reg;
 	int i;
 
-	ctx->active = false;
 	reg_write(ctx->ohci, CONTROL_CLEAR(ctx->regs), CONTEXT_RUN);
 	ctx->running = false;
 	flush_writes(ctx->ohci);
@@ -2797,13 +2794,13 @@ static void ohci_resume_iso_dma(struct fw_ohci *ohci)
 
 	for (i = 0 ; i < ohci->n_ir ; i++) {
 		ctx = &ohci->ir_context_list[i];
-		if (ctx->context.active)
+		if (ctx->context.running)
 			ohci_start_iso(&ctx->base, 0, ctx->sync, ctx->tags);
 	}
 
 	for (i = 0 ; i < ohci->n_it ; i++) {
 		ctx = &ohci->it_context_list[i];
-		if (ctx->context.active)
+		if (ctx->context.running)
 			ohci_start_iso(&ctx->base, 0, ctx->sync, ctx->tags);
 	}
 }
@@ -3363,11 +3360,11 @@ static int pci_resume(struct pci_dev *dev)
 	}
 
 	err = ohci_enable(&ohci->card, NULL, 0);
-
 	if (err)
 		return err;
 
 	ohci_resume_iso_dma(ohci);
+
 	return 0;
 }
 #endif

commit 386a4153a2c1455e424f280d636efa3c91864466

Author: Clemens Ladisch <[email protected]>
Date:   Fri Dec 24 14:42:46 2010 +0100

firewire: ohci: cache the context run bit

The DMA context run control bit is entirely controlled by software, so it is safe to cache it. This allows the driver to avoid doing an additional MMIO read when queueing an AT packet.

---
 drivers/firewire/ohci.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
drivers/firewire/ohci.c +4 -4
index cfe5afe..3ae84e2 100644
@@ -125,6 +125,7 @@ struct context {
 	struct fw_ohci *ohci;
 	u32 regs;
 	int total_allocation;
+	bool running;
 	bool flushing;
 
 	/*
@@ -1174,6 +1175,7 @@ static void context_run(struct context *ctx, u32 extra)
 		  le32_to_cpu(ctx->last->branch_address));
 	reg_write(ohci, CONTROL_CLEAR(ctx->regs), ~0);
 	reg_write(ohci, CONTROL_SET(ctx->regs), CONTEXT_RUN | extra);
+	ctx->running = true;
 	flush_writes(ohci);
 }
 
@@ -1202,6 +1204,7 @@ static void context_stop(struct context *ctx)
 
 	ctx->active = false;
 	reg_write(ctx->ohci, CONTROL_CLEAR(ctx->regs), CONTEXT_RUN);
+	ctx->running = false;
 	flush_writes(ctx->ohci);
 
 	for (i = 0; i < 10; i++) {
@@ -1232,7 +1235,6 @@ static int at_context_queue_packet(struct context *ctx,
 	struct descriptor *d, *last;
 	__le32 *header;
 	int z, tcode;
-	u32 reg;
 
 	d = context_get_descriptors(ctx, 4, &d_bus);
 	if (d == NULL) {
@@ -1351,9 +1353,7 @@ static int at_context_queue_packet(struct context *ctx,
 
 	context_append(ctx, d, z, 4 - z);
 
-	/* If the context isn't already running, start it up. */
-	reg = reg_read(ctx->ohci, CONTROL_SET(ctx->regs));
-	if ((reg & CONTEXT_RUN) == 0)
+	if (!ctx->running)
 		context_run(ctx, 0);
 
 	return 0;

commit 78dec56d6a56322e1b728d51f3a7def416d36b34

Author: Stefan Richter <[email protected]>
Date:   Sat Jan 1 15:15:40 2011 +0100

firewire: ohci: flush AT contexts after bus reset - addendum

Add comments
- on why bus_reset_tasklet flushes AT queues,
- that commit 76f73ca1b291 can possibly be reverted now.

---
 drivers/firewire/ohci.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/firewire/ohci.c +7 -0
index 3372cd1..cfe5afe 100644
@@ -1336,6 +1336,8 @@ static int at_context_queue_packet(struct context *ctx,
 	 * some controllers (like a JMicron JMB381 PCI-e) misbehave and wind
 	 * up stalling out.  So we just bail out in software and try again
 	 * later, and everyone is happy.
+	 * FIXME: Test of IntEvent.busReset may no longer be necessary since we
+	 *        flush AT queues in bus_reset_tasklet.
 	 * FIXME: Document how the locking works.
 	 */
 	if (ohci->generation != packet->generation ||
@@ -1750,6 +1752,11 @@ static void bus_reset_tasklet(unsigned long data)
 
 	spin_unlock_irqrestore(&ohci->lock, flags);
 
+	/*
+	 * Per OHCI 1.2 draft, clause 7.2.3.3, hardware may leave unsent
+	 * packets in the AT queues and software needs to drain them.
+	 * Some OHCI 1.1 controllers (JMicron) apparently require this too.
+	 */
 	at_context_flush(&ohci->at_request_ctx);
 	at_context_flush(&ohci->at_response_ctx);
 

commit 82b662dc41027527675740de15344d1b4e34958e

Author: Clemens Ladisch <[email protected]>
Date:   Fri Dec 24 14:40:15 2010 +0100

firewire: ohci: flush AT contexts after bus reset for OHCI 1.2

The OHCI 1.2 (draft) specification, clause 7.2.3.3, allows and recommends that, after a bus reset, the controller does not flush all the packets in the AT queues. Therefore, the driver has to do this itself.

---
 drivers/firewire/ohci.c |   46 +++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 39 insertions(+), 7 deletions(-)
drivers/firewire/ohci.c +39 -7

84 lines not on this page · raw message

commit c16714704bb35165e5b85d927873dcc643772648

Author: Stefan Richter <[email protected]>
Date:   Fri Dec 17 22:22:33 2010 +0100

firewire: net: set carrier state at ifup

At ifup, carrier status would be shown on even if it actually was off. Also add an include for ethtool_ops rather than to rely on the one from netdevice.h.

Note, we can alas not use fwnet_device_mutex to serialize access to dev->peer_count (as I originally wanted). This would cause a lock inversion:
- fwnet_probe | takes fwnet_device_mutex
+ register_netdev | takes rtnl_mutex
- devinet_ioctl | takes rtnl_mutex
+ fwnet_open | ...must not take fwnet_device_mutex

Hence use the dev->lock spinlock for serialization.

---
 drivers/firewire/net.c |   36 +++++++++++++++++++++---------------
 1 files changed, 21 insertions(+), 15 deletions(-)
drivers/firewire/net.c +21 -15
index 7fd51c9..c2e194c 100644
@@ -9,6 +9,7 @@
 #include <linux/bug.h>
 #include <linux/delay.h>
 #include <linux/device.h>
+#include <linux/ethtool.h>
 #include <linux/firewire.h>
 #include <linux/firewire-constants.h>
 #include <linux/highmem.h>
@@ -178,8 +179,8 @@ struct fwnet_device {
 
 	/* Number of tx datagrams that have been queued but not yet acked */
 	int queued_datagrams;
-	int peer_count;
 
+	int peer_count;
 	struct list_head peer_list;
 	struct fw_card *card;
 	struct net_device *netdev;
@@ -1222,6 +1223,14 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
 	return retval;
 }
 
+static void set_carrier_state(struct fwnet_device *dev)
+{
+	if (dev->peer_count > 1)
+		netif_carrier_on(dev->netdev);
+	else
+		netif_carrier_off(dev->netdev);
+}
+
 /* ifup */
 static int fwnet_open(struct net_device *net)
 {
@@ -1235,6 +1244,10 @@ static int fwnet_open(struct net_device *net)
 	}
 	netif_start_queue(net);
 
+	spin_lock_irq(&dev->lock);
+	set_carrier_state(dev);
+	spin_unlock_irq(&dev->lock);
+
 	return 0;
 }
 
@@ -1429,7 +1442,6 @@ static void fwnet_init_dev(struct net_device *net)
 	net->type		= ARPHRD_IEEE1394;
 	net->tx_queue_len	= FWNET_TX_QUEUE_LEN;
 	net->ethtool_ops	= &fwnet_ethtool_ops;
-
 }
 
 /* caller must hold fwnet_device_mutex */
@@ -1471,6 +1483,7 @@ static int fwnet_add_peer(struct fwnet_device *dev,
 	spin_lock_irq(&dev->lock);
 	list_add_tail(&peer->peer_link, &dev->peer_list);
 	dev->peer_count++;
+	set_carrier_state(dev);
 	spin_unlock_irq(&dev->lock);
 
 	return 0;
@@ -1542,9 +1555,6 @@ static int fwnet_probe(struct device *_dev)
 		unregister_netdev(net);
 		list_del(&dev->dev_link);
 	}
-
-	if (dev->peer_count > 1)
-		netif_carrier_on(net);
  out:
 	if (ret && allocated_netdev)
 		free_netdev(net);
@@ -1554,14 +1564,15 @@ static int fwnet_probe(struct device *_dev)
 	return ret;
 }
 
-static void fwnet_remove_peer(struct fwnet_peer *peer)
+static void fwnet_remove_peer(struct fwnet_peer *peer, struct fwnet_device *dev)
 {
 	struct fwnet_partial_datagram *pd, *pd_next;
 
-	spin_lock_irq(&peer->dev->lock);
+	spin_lock_irq(&dev->lock);
 	list_del(&peer->peer_link);
-	peer->dev->peer_count--;
-	spin_unlock_irq(&peer->dev->lock);
+	dev->peer_count--;
+	set_carrier_state(dev);
+	spin_unlock_irq(&dev->lock);
 
 	list_for_each_entry_safe(pd, pd_next, &peer->pd_list, pd_link)
 		fwnet_pd_delete(pd);
@@ -1578,12 +1589,7 @@ static int fwnet_remove(struct device *_dev)
 
 	mutex_lock(&fwnet_device_mutex);
 
-	fwnet_remove_peer(peer);
-
-	/* If we serve just one node, that means we lost link
-		with outer world */
-	if (dev->peer_count == 1)
-		netif_carrier_off(dev->netdev);
+	fwnet_remove_peer(peer, dev);
 
 	if (list_empty(&dev->peer_list)) {
 		net = dev->netdev;

commit 18bb36f9fab5980efeff063755c037a622f0231c

Author: Maxim Levitsky <[email protected]>
Date:   Wed Dec 8 04:22:57 2010 +0200

firewire: net: add carrier detection

To make userland, e.g. NetworkManager work with firewire, we need to detect whether cable is plugged or not. Simple and correct way of doing that is just counting number of peers. No peers - no link and vice versa.

---
 drivers/firewire/net.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
drivers/firewire/net.c +17 -0
index ea31e30..7fd51c9 100644
@@ -178,6 +178,7 @@ struct fwnet_device {
 
 	/* Number of tx datagrams that have been queued but not yet acked */
 	int queued_datagrams;
+	int peer_count;
 
 	struct list_head peer_list;
 	struct fw_card *card;
@@ -1405,6 +1406,10 @@ static int fwnet_change_mtu(struct net_device *net, int new_mtu)
 	return 0;
 }
 
+static const struct ethtool_ops fwnet_ethtool_ops = {
+	.get_link	= ethtool_op_get_link,
+};
+
 static const struct net_device_ops fwnet_netdev_ops = {
 	.ndo_open       = fwnet_open,
 	.ndo_stop	= fwnet_stop,
@@ -1423,6 +1428,8 @@ static void fwnet_init_dev(struct net_device *net)
 	net->hard_header_len	= FWNET_HLEN;
 	net->type		= ARPHRD_IEEE1394;
 	net->tx_queue_len	= FWNET_TX_QUEUE_LEN;
+	net->ethtool_ops	= &fwnet_ethtool_ops;
+
 }
 
 /* caller must hold fwnet_device_mutex */
@@ -1463,6 +1470,7 @@ static int fwnet_add_peer(struct fwnet_device *dev,
 
 	spin_lock_irq(&dev->lock);
 	list_add_tail(&peer->peer_link, &dev->peer_list);
+	dev->peer_count++;
 	spin_unlock_irq(&dev->lock);
 
 	return 0;
@@ -1534,6 +1542,9 @@ static int fwnet_probe(struct device *_dev)
 		unregister_netdev(net);
 		list_del(&dev->dev_link);
 	}
+
+	if (dev->peer_count > 1)
+		netif_carrier_on(net);
  out:
 	if (ret && allocated_netdev)
 		free_netdev(net);
@@ -1549,6 +1560,7 @@ static void fwnet_remove_peer(struct fwnet_peer *peer)
 
 	spin_lock_irq(&peer->dev->lock);
 	list_del(&peer->peer_link);
+	peer->dev->peer_count--;
 	spin_unlock_irq(&peer->dev->lock);
 
 	list_for_each_entry_safe(pd, pd_next, &peer->pd_list, pd_link)
@@ -1568,6 +1580,11 @@ static int fwnet_remove(struct device *_dev)
 
 	fwnet_remove_peer(peer);
 
+	/* If we serve just one node, that means we lost link
+		with outer world */
+	if (dev->peer_count == 1)
+		netif_carrier_off(dev->netdev);
+
 	if (list_empty(&dev->peer_list)) {
 		net = dev->netdev;
 		unregister_netdev(net);

commit c4d6fd40df38eb4c187565d48807f5f902481ba8

Author: Maxim Levitsky <[email protected]>
Date:   Mon Nov 29 04:09:53 2010 +0200

firewire: net: ratelimit error messages

Unfortunately its easy to trigger such error messages by removing the cable while sending streams of data over the link.

Such errors are normal, and therefore this patch stops firewire-net from flooding the kernel log with these errors, by combining series of same errors together.

(Stefan R:) Eventually we should remove this logging when firewire-net and related firewire-ohci facilities have been stabilized.

---
 drivers/firewire/net.c |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)
drivers/firewire/net.c +12 -4
index 1a467a9..ea31e30 100644
@@ -996,15 +996,23 @@ static void fwnet_transmit_packet_failed(struct fwnet_packet_task *ptask)
 static void fwnet_write_complete(struct fw_card *card, int rcode,
 				 void *payload, size_t length, void *data)
 {
-	struct fwnet_packet_task *ptask;
-
-	ptask = data;
+	struct fwnet_packet_task *ptask = data;
+	static unsigned long j;
+	static int last_rcode, errors_skipped;
 
 	if (rcode == RCODE_COMPLETE) {
 		fwnet_transmit_packet_done(ptask);
 	} else {
-		fw_error("fwnet_write_complete: failed: %x\n", rcode);
 		fwnet_transmit_packet_failed(ptask);
+
+		if (printk_timed_ratelimit(&j,  1000) || rcode != last_rcode) {
+			fw_error("fwnet_write_complete: "
+				"failed: %x (skipped %d)\n", rcode, errors_skipped);
+
+			errors_skipped = 0;
+			last_rcode = rcode;
+		} else
+			errors_skipped++;
 	}
 }
 

commit dd23736e092035b71df1117482b71fdfb5634239

Author: Maxim Levitsky <[email protected]>
Date:   Mon Nov 29 04:09:50 2010 +0200

firewire: ohci: restart iso DMA contexts on resume from low power mode

Restore iso channels DMA so that iso channels could continue to work after resume from RAM/disk.

---
 drivers/firewire/ohci.c |   54 ++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 46 insertions(+), 8 deletions(-)
drivers/firewire/ohci.c +46 -8

131 lines not on this page · raw message

commit 8662b6b029636c35e5876e184d90daf6b0072667

Author: Maxim Levitsky <[email protected]>
Date:   Mon Nov 29 04:09:49 2010 +0200

firewire: ohci: restore GUID on resume.

Some lousy BIOSes, e.g. my Aspire 5720 BIOS forget to restore the GUID register on resume from RAM.

Fix that by setting it to the last value that was read from it.

---
 drivers/firewire/ohci.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
drivers/firewire/ohci.c +7 -0
index eb7b591..3a90803 100644
@@ -3284,6 +3284,13 @@ static int pci_resume(struct pci_dev *dev)
 		return err;
 	}
 
+	/* Some systems don't setup GUID register on resume from ram  */
+	if (!reg_read(ohci, OHCI1394_GUIDLo) &&
+					!reg_read(ohci, OHCI1394_GUIDHi)) {
+		reg_write(ohci, OHCI1394_GUIDLo, (u32)ohci->card.guid);
+		reg_write(ohci, OHCI1394_GUIDHi, (u32)(ohci->card.guid >> 32));
+	}
+
 	return ohci_enable(&ohci->card, NULL, 0);
 }
 #endif

commit ec766a7970126f99665992c0b0b10bd60a4d6208

Author: Clemens Ladisch <[email protected]>
Date:   Tue Nov 30 08:25:17 2010 +0100

firewire: ohci: use common buffer for self IDs and AR descriptors

The buffers used for the selfIDs packets and the AR request and response descriptors end up using three pages because dma_alloc_coherent() allocates at least one page per call. However, these data structures would all fit into 4 KB, so we can save space by using a common buffer for them.

---
 drivers/firewire/ohci.c |   66 ++++++++++++++++++++++++----------------------
 1 files changed, 34 insertions(+), 32 deletions(-)
drivers/firewire/ohci.c +34 -32

131 lines not on this page · raw message

commit 2dd5bed59356e03610bebe1a37c397788df50b9b

Author: Clemens Ladisch <[email protected]>
Date:   Tue Nov 30 08:25:05 2010 +0100

firewire: ohci: optimize iso context checks in the interrupt handler

When the isochRx/isochTx bit is clear, we do not need to read the corresponding iso interrupt event register.

---
 drivers/firewire/ohci.c |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)
drivers/firewire/ohci.c +19 -13
index 29259f3..01b3bc9 100644
@@ -1813,22 +1813,28 @@ static irqreturn_t irq_handler(int irq, void *data)
 	if (event & OHCI1394_respTxComplete)
 		tasklet_schedule(&ohci->at_response_ctx.tasklet);
 
-	iso_event = reg_read(ohci, OHCI1394_IsoRecvIntEventClear);
-	reg_write(ohci, OHCI1394_IsoRecvIntEventClear, iso_event);
-
-	while (iso_event) {
-		i = ffs(iso_event) - 1;
-		tasklet_schedule(&ohci->ir_context_list[i].context.tasklet);
-		iso_event &= ~(1 << i);
+	if (event & OHCI1394_isochRx) {
+		iso_event = reg_read(ohci, OHCI1394_IsoRecvIntEventClear);
+		reg_write(ohci, OHCI1394_IsoRecvIntEventClear, iso_event);
+
+		while (iso_event) {
+			i = ffs(iso_event) - 1;
+			tasklet_schedule(
+				&ohci->ir_context_list[i].context.tasklet);
+			iso_event &= ~(1 << i);
+		}
 	}
 
-	iso_event = reg_read(ohci, OHCI1394_IsoXmitIntEventClear);
-	reg_write(ohci, OHCI1394_IsoXmitIntEventClear, iso_event);
+	if (event & OHCI1394_isochTx) {
+		iso_event = reg_read(ohci, OHCI1394_IsoXmitIntEventClear);
+		reg_write(ohci, OHCI1394_IsoXmitIntEventClear, iso_event);
 
-	while (iso_event) {
-		i = ffs(iso_event) - 1;
-		tasklet_schedule(&ohci->it_context_list[i].context.tasklet);
-		iso_event &= ~(1 << i);
+		while (iso_event) {
+			i = ffs(iso_event) - 1;
+			tasklet_schedule(
+				&ohci->it_context_list[i].context.tasklet);
+			iso_event &= ~(1 << i);
+		}
 	}
 
 	if (unlikely(event & OHCI1394_regAccessFail))

commit 5b06db166c4d38638980283505259fa165d4f369

Author: Clemens Ladisch <[email protected]>
Date:   Tue Nov 30 08:24:47 2010 +0100

firewire: make PHY packet header format consistent

Change the header of PHY packets to be sent to include a pseudo transaction code. This makes the header consistent with that of received PHY packets, and allows at_context_queue_packet() and log_ar_at_event() to see the packet type directly instead of having to deduce it from the header length or even from the header contents.

---
 drivers/firewire/core-cdev.c        |    7 +++--
 drivers/firewire/core-transaction.c |    7 +++--
 drivers/firewire/core.h             |    4 ++-
 drivers/firewire/ohci.c             |   44 +++++++++++++++++-----------------
 4 files changed, 33 insertions(+), 29 deletions(-)
drivers/firewire/core-cdev.c +4 -3
index 14bb7b7..48ae712 100644
@@ -1501,9 +1501,10 @@ static int ioctl_send_phy_packet(struct client *client, union ioctl_arg *arg)
 	e->client		= client;
 	e->p.speed		= SCODE_100;
 	e->p.generation		= a->generation;
-	e->p.header[0]		= a->data[0];
-	e->p.header[1]		= a->data[1];
-	e->p.header_length	= 8;
+	e->p.header[0]		= TCODE_LINK_INTERNAL << 4;
+	e->p.header[1]		= a->data[0];
+	e->p.header[2]		= a->data[1];
+	e->p.header_length	= 12;
 	e->p.callback		= outbound_phy_packet_callback;
 	e->phy_packet.closure	= a->closure;
 	e->phy_packet.type	= FW_CDEV_EVENT_PHY_PACKET_SENT;
drivers/firewire/core-transaction.c +4 -3
index ad864d8..9e81cc5 100644
@@ -423,7 +423,8 @@ static void transmit_phy_packet_callback(struct fw_packet *packet,
 }
 
 static struct fw_packet phy_config_packet = {
-	.header_length	= 8,
+	.header_length	= 12,
+	.header[0]	= TCODE_LINK_INTERNAL << 4,
 	.payload_length	= 0,
 	.speed		= SCODE_100,
 	.callback	= transmit_phy_packet_callback,
@@ -451,8 +452,8 @@ void fw_send_phy_config(struct fw_card *card,
 
 	mutex_lock(&phy_config_mutex);
 
-	phy_config_packet.header[0] = data;
-	phy_config_packet.header[1] = ~data;
+	phy_config_packet.header[1] = data;
+	phy_config_packet.header[2] = ~data;
 	phy_config_packet.generation = generation;
 	INIT_COMPLETION(phy_config_done);
 
drivers/firewire/core.h +3 -1
index e6239f9..f8dfcf1 100644
@@ -215,9 +215,11 @@ static inline bool is_next_generation(int new_generation, int old_generation)
 
 /* -transaction */
 
+#define TCODE_LINK_INTERNAL		0xe
+
 #define TCODE_IS_READ_REQUEST(tcode)	(((tcode) & ~1) == 4)
 #define TCODE_IS_BLOCK_PACKET(tcode)	(((tcode) &  1) != 0)
-#define TCODE_IS_LINK_INTERNAL(tcode)	((tcode) == 0xe)
+#define TCODE_IS_LINK_INTERNAL(tcode)	((tcode) == TCODE_LINK_INTERNAL)
 #define TCODE_IS_REQUEST(tcode)		(((tcode) &  2) == 0)
 #define TCODE_IS_RESPONSE(tcode)	(((tcode) &  2) != 0)
 #define TCODE_HAS_REQUEST_DATA(tcode)	(((tcode) & 12) != 4)
drivers/firewire/ohci.c +22 -22

92 lines not on this page · raw message

commit 8327b37b18addfc6f8cf41a2f1a4490b656377b9

Author: Clemens Ladisch <[email protected]>
Date:   Tue Nov 30 08:24:32 2010 +0100

firewire: ohci: properly clear posted write errors

To remove the error information from the controller's queue and to allow more posted writes, the driver has to read the failed posted write address before clearing the postedWriteErr interrupt bit.

(Stefan R:) The spec is somewhat fuzzy about the actual requirements. To err on the safe side, let's do these two read accesses.

---
 drivers/firewire/ohci.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
drivers/firewire/ohci.c +12 -3
index 276324d..0031ec6 100644
@@ -1790,8 +1790,12 @@ static irqreturn_t irq_handler(int irq, void *data)
 	if (!event || !~event)
 		return IRQ_NONE;
 
-	/* busReset must not be cleared yet, see OHCI 1.1 clause 7.2.3.2 */
-	reg_write(ohci, OHCI1394_IntEventClear, event & ~OHCI1394_busReset);
+	/*
+	 * busReset and postedWriteErr must not be cleared yet
+	 * (OHCI 1.1 clauses 7.2.3.2 and 13.2.8.1)
+	 */
+	reg_write(ohci, OHCI1394_IntEventClear,
+		  event & ~(OHCI1394_busReset | OHCI1394_postedWriteErr));
 	log_irqs(event);
 
 	if (event & OHCI1394_selfIDComplete)
@@ -1831,8 +1835,13 @@ static irqreturn_t irq_handler(int irq, void *data)
 		fw_error("Register access failure - "
 			 "please notify [email protected]\n");
 
-	if (unlikely(event & OHCI1394_postedWriteErr))
+	if (unlikely(event & OHCI1394_postedWriteErr)) {
+		reg_read(ohci, OHCI1394_PostedWriteAddressHi);
+		reg_read(ohci, OHCI1394_PostedWriteAddressLo);
+		reg_write(ohci, OHCI1394_IntEventClear,
+			  OHCI1394_postedWriteErr);
 		fw_error("PCI posted write error\n");
+	}
 
 	if (unlikely(event & OHCI1394_cycleTooLong)) {
 		if (printk_ratelimit())

commit e597e9898abe45beff4696159c7fe5c96f53e581

Author: Clemens Ladisch <[email protected]>
Date:   Tue Nov 30 08:24:19 2010 +0100

firewire: ohci: flush MMIO writes in the interrupt handler

Make sure that interrupt event clear bit writes are executed before the interrupt handler returns.

---
 drivers/firewire/ohci.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/firewire/ohci.c +2 -1
index 3775364..276324d 100644
@@ -1856,7 +1856,8 @@ static irqreturn_t irq_handler(int irq, void *data)
 		spin_lock(&ohci->lock);
 		update_bus_time(ohci);
 		spin_unlock(&ohci->lock);
-	}
+	} else
+		flush_writes(ohci);
 
 	return IRQ_HANDLED;
 }

commit c088ab30ebf184afae01d919c77cebcfdce39df3

Author: Clemens Ladisch <[email protected]>
Date:   Tue Nov 30 08:24:01 2010 +0100

firewire: ohci: fix AT context initialization error handling

Add proper error handling for the context_init() calls.

---
 drivers/firewire/ohci.c |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)
drivers/firewire/ohci.c +10 -4
index be0a01d..3775364 100644
@@ -3102,11 +3102,15 @@ static int __devinit pci_probe(struct pci_dev *dev,
 	if (err < 0)
 		goto fail_arreq_ctx;
 
-	context_init(&ohci->at_request_ctx, ohci,
-		     OHCI1394_AsReqTrContextControlSet, handle_at_packet);
+	err = context_init(&ohci->at_request_ctx, ohci,
+			   OHCI1394_AsReqTrContextControlSet, handle_at_packet);
+	if (err < 0)
+		goto fail_arrsp_ctx;
 
-	context_init(&ohci->at_response_ctx, ohci,
-		     OHCI1394_AsRspTrContextControlSet, handle_at_packet);
+	err = context_init(&ohci->at_response_ctx, ohci,
+			   OHCI1394_AsRspTrContextControlSet, handle_at_packet);
+	if (err < 0)
+		goto fail_atreq_ctx;
 
 	reg_write(ohci, OHCI1394_IsoRecvIntMaskSet, ~0);
 	ohci->ir_context_channels = ~0ULL;
@@ -3163,7 +3167,9 @@ static int __devinit pci_probe(struct pci_dev *dev,
 	kfree(ohci->ir_context_list);
 	kfree(ohci->it_context_list);
 	context_release(&ohci->at_response_ctx);
+ fail_atreq_ctx:
 	context_release(&ohci->at_request_ctx);
+ fail_arrsp_ctx:
 	ar_context_release(&ohci->ar_response_ctx);
  fail_arreq_ctx:
 	ar_context_release(&ohci->ar_request_ctx);

commit 7a39d8b82165462729d09066bddb395a19025acd

Author: Clemens Ladisch <[email protected]>
Date:   Fri Nov 26 08:57:31 2010 +0100

firewire: ohci: Asynchronous Reception rewrite

Move the AR DMA descriptors out of the buffer pages, and map the buffer pages linearly into the kernel's address space. This allows the driver to ignore any page boundaries in the DMA data and thus to avoid any copying around of packet payloads.

This fixes the bug where S800 packets that are so big (> 4080 bytes) that they can be split over three pages were not handled correctly.

Due to the changed algorithm, we can now use arbitrarily many buffer pages, which improves performance because the controller can more easily unload its DMA FIFO.

Furthermore, using streaming DMA mappings should improve perfomance on architectures where coherent DMA mappings are not cacheable. Even on other architectures, the caching behaviour should be improved slightly because the CPU no longer writes to the buffer pages.

v2: Detect the last filled buffer page by searching the descriptor's
residual count value fields in order (like in the old code), instead of going backwards through the transfer status fields; it looks as if some controllers do not set the latter correctly.

v3: Fix an old resume bug that would now make the handler run into
a BUG_ON, and replace that check with more useful error handling. Increase the buffer size for better performance with non-TI chips.

Maxim Levitsky writes:
Works almost perfectly. I can still see RCODE_BUSY errors sometimes, not very often though. 64K here eliminates these errors completely. This is most likely due to nouveau drivers and lowest perf level I use to lower card temperature. That increases latencies too much I think. Besides that the IO is just perfect.

---
 drivers/firewire/Kconfig |    2 +-
 drivers/firewire/ohci.c  |  411 +++++++++++++++++++++++++++++++---------------
 2 files changed, 278 insertions(+), 135 deletions(-)
drivers/firewire/Kconfig +1 -1
index 40a222e..68f942c 100644
@@ -19,7 +19,7 @@ config FIREWIRE
 
 config FIREWIRE_OHCI
 	tristate "OHCI-1394 controllers"
-	depends on PCI && FIREWIRE
+	depends on PCI && FIREWIRE && MMU
 	help
 	  Enable this driver if you have a FireWire controller based
 	  on the OHCI specification.  For all practical purposes, this
drivers/firewire/ohci.c +277 -134

513 lines not on this page · raw message

commit 5878730be4e3d0c9527d6f2f688874e38acacc98

Author: Joe Perches <[email protected]>
Date:   Sat Oct 30 14:08:27 2010 -0700

firewire: core: Update WARN uses

Add missing newlines.

---
 drivers/firewire/core-transaction.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
drivers/firewire/core-transaction.c +3 -3
index b42a0bd..ad864d8 100644
@@ -250,7 +250,7 @@ static void fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
 		break;
 
 	default:
-		WARN(1, "wrong tcode %d", tcode);
+		WARN(1, "wrong tcode %d\n", tcode);
 	}
  common:
 	packet->speed = speed;
@@ -638,7 +638,7 @@ int fw_get_response_length(struct fw_request *r)
 		}
 
 	default:
-		WARN(1, "wrong tcode %d", tcode);
+		WARN(1, "wrong tcode %d\n", tcode);
 		return 0;
 	}
 }
@@ -694,7 +694,7 @@ void fw_fill_response(struct fw_packet *response, u32 *request_header,
 		break;
 
 	default:
-		WARN(1, "wrong tcode %d", tcode);
+		WARN(1, "wrong tcode %d\n", tcode);
 	}
 
 	response->payload_mapped = false;

commit 60a74a6ff86b4e90b9558956589390efdeb4e924

Author: Stefan Richter <[email protected]>
Date:   Sat Oct 23 13:18:56 2010 +0200

firewire: nosy: char device is not seekable

Amend .open handler accordingly and remove the .llseek handler. .llseek = NULL means no_llseek (return error) since commit 776c163b1b93.

The only client that uses this interface is nosy-dump in linux/tools/firewire and it knows not to seek in this char dev.

---
 drivers/firewire/nosy.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/firewire/nosy.c +1 -2
index bf184fb..0618145 100644
@@ -302,7 +302,7 @@ nosy_open(struct inode *inode, struct file *file)
 
 	file->private_data = client;
 
-	return 0;
+	return nonseekable_open(inode, file);
 fail:
 	kfree(client);
 	lynx_put(lynx);
@@ -405,7 +405,6 @@ static const struct file_operations nosy_ops = {
 	.poll =			nosy_poll,
 	.open =			nosy_open,
 	.release =		nosy_release,
-	.llseek =		noop_llseek,
 };
 
 #define PHY_PACKET_SIZE 12 /* 1 payload, 1 inverse, 1 ack = 3 quadlets */
Signature · 3 lines
Stefan Richter
-=====-==-== ---= --===
http://arcgraph.de/sr/
#2 lore raw

[git pull] FireWire build fix

In reply to Stefan Richter

Linus, please pull from the for-linus branch at

    git://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394-2.6.git for-linus

to receive the following update for the IEEE 1394 (FireWire) subsystem. It's straightforward and runtime tested.

Clemens Ladisch (1):
firewire: ohci: fix compilation on arches without PAGE_KERNEL_RO

 drivers/firewire/ohci.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Thanks.

commit 1427130425c1239d977e8891c3a8923f53a6e352

Author: Clemens Ladisch <[email protected]>
Date:   Thu Jan 13 10:12:17 2011 +0100

firewire: ohci: fix compilation on arches without PAGE_KERNEL_RO

PAGE_KERNEL_RO is not available on all architectures, so its use in the new AR code broke compilation on sparc64.

Because the read-only mapping was just a debugging aid, just use PAGE_KERNEL instead.

James Bottomley wrote:
> On Thu, 2011-01-13 at 08:27 +0100, Clemens Ladisch wrote:
>> firewire: ohci: fix compilation on arches without PAGE_KERNEL_RO, e.g. sparc >>
>> PAGE_KERNEL_RO is not available on all architectures, so its use in the >> new AR code broke compilation on sparc64.
>>
>> Because the R/O mapping is only used to catch drivers that try to write >> to the reception buffer and not actually required for correct operation, >> we can just use a normal PAGE_KERNEL mapping where _RO is not available. [...]
>> +/*
>> + * For archs where PAGE_KERNEL_RO is not supported;
>> + * mapping the AR buffers readonly for the CPU is just a debugging aid. >> + */
>> +#ifndef PAGE_KERNEL_RO
>> +#define PAGE_KERNEL_RO PAGE_KERNEL
>> +#endif
>
> This might cause interesting issues on sparc64 if it ever acquired a > PAGE_KERNEL_RO. Sparc64 has extern pgprot_t for it's PAGE_KERNEL types > rather than #defines, so the #ifdef check wouldn't see this.
>
> I think either PAGE_PROT_RO becomes part of our arch API (so all > architectures are forced to add it), or, if it's not part of the API, > ohci isn't entitled to use it. The latter seems simplest since you have > no real use for write protection anyway.

drivers/firewire/ohci.c +1 -1
index d77d120..bd3c61b 100644
@@ -961,7 +961,7 @@ static int ar_context_init(struct ar_context *ctx, struct fw_ohci *ohci,
 	for (i = 0; i < AR_WRAPAROUND_PAGES; i++)
 		pages[AR_BUFFERS + i] = ctx->pages[i];
 	ctx->buffer = vm_map_ram(pages, AR_BUFFERS + AR_WRAPAROUND_PAGES,
-				 -1, PAGE_KERNEL_RO);
+				 -1, PAGE_KERNEL);
 	if (!ctx->buffer)
 		goto out_of_memory;
 
Signature · 3 lines
Stefan Richter
-=====-==-== ---= -==-=
http://arcgraph.de/sr/