Skip to contentSkip to conversation

FireWire updates post 2.6.23

GIT PULL Stefan Richter 1 participant 2 messages Oct 16, 2007 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 IEEE 1394/ FireWire subsystem updates. It's almost all just bugfixes, and had I anticipated that 2.6.23 was going to grow an -rc9 I would have sent most of the material for the new firewire stack already during the rc phase.

Most patches went into -mm during mid July...mid September; some simple patches are from the past two weeks. Combined diff follows in a reply. Stat and shortlog:

 drivers/firewire/fw-cdev.c        |   52 ++-
 drivers/firewire/fw-device.h      |    5 -
 drivers/firewire/fw-ohci.c        |   41 ++-
 drivers/firewire/fw-ohci.h        |    2 +
 drivers/firewire/fw-sbp2.c        |  647 +++++++++++++++++------------
 drivers/firewire/fw-topology.c    |   10 +-
 drivers/firewire/fw-topology.h    |    6 -
 drivers/firewire/fw-transaction.c |   12 +-
 drivers/ieee1394/csr1212.c        |   57 ++--
 drivers/ieee1394/csr1212.h        |    6 +-
 drivers/ieee1394/eth1394.c        |   16 +-
 drivers/ieee1394/ieee1394_core.c  |    2 +-
 drivers/ieee1394/nodemgr.c        |   22 +-
 drivers/ieee1394/pcilynx.c        |   29 +-
 drivers/ieee1394/sbp2.c           |   15 +
 include/linux/firewire-cdev.h     |   15 +
 16 files changed, 560 insertions(+), 377 deletions(-)

Jay Fenlason (1):
firewire: fw-cdev: reorder wakeup vs. spinlock

Jean Delvare (1):
ieee1394: pcilynx: I2C cleanups

Matthias Kaehlcke (1):
ieee1394: ieee1394_core.c: use DEFINE_SPINLOCK for spinlock definition

Satyam Sharma (1):
ieee1394: Fix kthread stopping in nodemgr_host_thread

Stefan Richter (20):
ieee1394: eth1394: superfluous local variable
ieee1394: eth1394: fix lock imbalance
ieee1394: pcilynx: superfluous local variables
ieee1394: sbp2: fix unsafe iteration over list of devices
ieee1394: nodemgr: fix leak of struct csr1212_keyval
ieee1394: csr1212: proper refcounting
firewire: optimize fw_core_add_address_handler
firewire: fw-core: local variable shadows a global one
firewire: fw-sbp2: always enable IRQs before calling command ORB callback
firewire: fw-sbp2: add support for multiple logical units per target
firewire: fw-sbp2: expose module parameter for workarounds
firewire: fw-sbp2: use an own workqueue (fix system responsiveness)
firewire: fw-ohci: enforce read order for selfID generation
firewire: fw-ohci: fix includes
firewire: fw-ohci: reorder includes
firewire: fw-ohci: log posted write errors
firewire: fw-ohci: missing dma_unmap_single
firewire: fw-ohci: check for misconfigured bus (phyID == 63)
firewire: adopt read cycle timer ABI from raw1394
firewire: a header cleanup

Yann Dirson (1):
firewire: in-code doc updates.

Signature · 3 lines
Stefan Richter
-=====-=-=== =-=- =---=
http://arcgraph.de/sr/
author Acked-by Kristian Høgsberg
#1 lore raw
Quoted 5 lines · 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 IEEE 1394/ FireWire subsystem updates.

commit 83431cba3d847fc2296d3f38ce7feb623a1cfc45

Author: Jay Fenlason <[email protected]>
Date:   Mon Oct 8 17:00:29 2007 -0400

firewire: fw-cdev: reorder wakeup vs. spinlock

Prompted by https://bugzilla.redhat.com/show_bug.cgi?id=323411

drivers/firewire/fw-cdev.c +2 -3
index 290d9f0..60f1a89 100644
@@ -143,11 +143,10 @@ static void queue_event(struct client *client, struct event *event,
 	event->v[1].size = size1;
 
 	spin_lock_irqsave(&client->lock, flags);
-
 	list_add_tail(&event->link, &client->event_list);
-	wake_up_interruptible(&client->wait);
-
 	spin_unlock_irqrestore(&client->lock, flags);
+
+	wake_up_interruptible(&client->wait);
 }
 
 static int

commit c1b91ce49158d607666dbef5b8d53cd77d397589

Author: Yann Dirson <[email protected]>
Date:   Sun Oct 7 02:21:29 2007 +0200

firewire: in-code doc updates.

drivers/firewire/fw-topology.c +5 -1
index 45e6f9b..0fc9b00 100644
@@ -166,7 +166,7 @@ static inline struct fw_node *fw_node(struct list_head *l)
  * This function builds the tree representation of the topology given
  * by the self IDs from the latest bus reset.  During the construction
  * of the tree, the function checks that the self IDs are valid and
- * internally consistent.  On succcess this funtions returns the
+ * internally consistent.  On succcess this function returns the
  * fw_node corresponding to the local card otherwise NULL.
  */
 static struct fw_node *build_tree(struct fw_card *card,
@@ -215,6 +215,10 @@ static struct fw_node *build_tree(struct fw_card *card,
 		 */
 		for (i = 0, h = &stack; i < child_port_count; i++)
 			h = h->prev;
+		/*
+		 * When the stack is empty, this yields an invalid value,
+		 * but that pointer will never be dereferenced.
+		 */
 		child = fw_node(h);
 
 		node = fw_node_create(q, port_count, card->color);

commit e5f84f82bdc5f8a5ce3d33aa6a2cc727fc08bda6

Author: Stefan Richter <[email protected]>
Date:   Sun Oct 7 02:10:11 2007 +0200

firewire: a header cleanup

fw_node() is not used (and not useful) outside fw-topology.c.

drivers/firewire/fw-topology.c +4 -0
index 39e5cd1..45e6f9b 100644
@@ -152,6 +152,10 @@ static void update_hop_count(struct fw_node *node)
 	node->max_hops = max(max_child_hops, depths[0] + depths[1] + 2);
 }
 
+static inline struct fw_node *fw_node(struct list_head *l)
+{
+	return list_entry(l, struct fw_node, link);
+}
 
 /**
  * build_tree - Build the tree representation of the topology
drivers/firewire/fw-topology.h +0 -6
index 1b56b4a..cedc1ec 100644
@@ -51,12 +51,6 @@ struct fw_node {
 };
 
 static inline struct fw_node *
-fw_node(struct list_head *l)
-{
-	return list_entry(l, struct fw_node, link);
-}
-
-static inline struct fw_node *
 fw_node_get(struct fw_node *node)
 {
 	atomic_inc(&node->ref_count);

commit a64408b96b5f67c2778958a230b5cfa3408a4a81

Author: Stefan Richter <[email protected]>
Date:   Sat Sep 29 10:41:58 2007 +0200

firewire: adopt read cycle timer ABI from raw1394

This duplicates the read cycle timer feature of raw1394 (added in Linux 2.6.21) in firewire-core's userspace ABI. The argument to the ioctl is reordered though to ensure 32/64 bit compatibility.

drivers/firewire/fw-cdev.c +26 -0
index b960fd9..290d9f0 100644
@@ -25,11 +25,14 @@
 #include <linux/device.h>
 #include <linux/vmalloc.h>
 #include <linux/poll.h>
+#include <linux/preempt.h>
+#include <linux/time.h>
 #include <linux/delay.h>
 #include <linux/mm.h>
 #include <linux/idr.h>
 #include <linux/compat.h>
 #include <linux/firewire-cdev.h>
+#include <asm/system.h>
 #include <asm/uaccess.h>
 #include "fw-transaction.h"
 #include "fw-topology.h"
@@ -811,6 +814,28 @@ static int ioctl_stop_iso(struct client *client, void *buffer)
 	return fw_iso_context_stop(client->iso_context);
 }
 
+static int ioctl_get_cycle_timer(struct client *client, void *buffer)
+{
+	struct fw_cdev_get_cycle_timer *request = buffer;
+	struct fw_card *card = client->device->card;
+	unsigned long long bus_time;
+	struct timeval tv;
+	unsigned long flags;
+
+	preempt_disable();
+	local_irq_save(flags);
+
+	bus_time = card->driver->get_bus_time(card);
+	do_gettimeofday(&tv);
+
+	local_irq_restore(flags);
+	preempt_enable();
+
+	request->local_time = tv.tv_sec * 1000000ULL + tv.tv_usec;
+	request->cycle_timer = bus_time & 0xffffffff;
+	return 0;
+}
+
 static int (* const ioctl_handlers[])(struct client *client, void *buffer) = {
 	ioctl_get_info,
 	ioctl_send_request,
@@ -824,6 +849,7 @@ static int (* const ioctl_handlers[])(struct client *client, void *buffer) = {
 	ioctl_queue_iso,
 	ioctl_start_iso,
 	ioctl_stop_iso,
+	ioctl_get_cycle_timer,
 };
 
 static int
include/linux/firewire-cdev.h +15 -0
index 1a45d6f..0f0e271 100644
@@ -178,6 +178,7 @@ union fw_cdev_event {
 #define FW_CDEV_IOC_QUEUE_ISO		_IOWR('#', 0x09, struct fw_cdev_queue_iso)
 #define FW_CDEV_IOC_START_ISO		_IOW('#', 0x0a, struct fw_cdev_start_iso)
 #define FW_CDEV_IOC_STOP_ISO		_IOW('#', 0x0b, struct fw_cdev_stop_iso)
+#define FW_CDEV_IOC_GET_CYCLE_TIMER	_IOR('#', 0x0c, struct fw_cdev_get_cycle_timer)
 
 /* FW_CDEV_VERSION History
  *
@@ -459,4 +460,18 @@ struct fw_cdev_stop_iso {
 	__u32 handle;
 };
 
+/**
+ * struct fw_cdev_get_cycle_timer - read cycle timer register
+ * @local_time:   system time, in microseconds since the Epoch
+ * @cycle_timer:  isochronous cycle timer, as per OHCI 1.1 clause 5.13
+ *
+ * The %FW_CDEV_IOC_GET_CYCLE_TIMER ioctl reads the isochronous cycle timer
+ * and also the system clock.  This allows to express the receive time of an
+ * isochronous packet as a system time with microsecond accuracy.
+ */
+struct fw_cdev_get_cycle_timer {
+	__u64 local_time;
+	__u32 cycle_timer;
+};
+
 #endif /* _LINUX_FIREWIRE_CDEV_H */

commit 02ff8f8ee151e880414b99a11f67cae0cecd4977

Author: Stefan Richter <[email protected]>
Date:   Thu Aug 30 00:11:40 2007 +0200

firewire: fw-ohci: check for misconfigured bus (phyID == 63)

Check NodeID.nodeNumber as per OHCI 1.1 clause 7.2.3.2. See also IEEE 1394a table 5B-1.

Also, demote the "node ID not valid" message from error to notification as it is not an error condition.

drivers/firewire/fw-ohci.c +7 -2
index ec70c9f..2f307c4 100644
@@ -917,10 +917,15 @@ static void bus_reset_tasklet(unsigned long data)
 
 	reg = reg_read(ohci, OHCI1394_NodeID);
 	if (!(reg & OHCI1394_NodeID_idValid)) {
-		fw_error("node ID not valid, new bus reset in progress\n");
+		fw_notify("node ID not valid, new bus reset in progress\n");
 		return;
 	}
-	ohci->node_id = reg & 0xffff;
+	if ((reg & OHCI1394_NodeID_nodeNumber) == 63) {
+		fw_notify("malconfigured bus\n");
+		return;
+	}
+	ohci->node_id = reg & (OHCI1394_NodeID_busNumber |
+			       OHCI1394_NodeID_nodeNumber);
 
 	/*
 	 * The count in the SelfIDCount register is the number of
drivers/firewire/fw-ohci.h +2 -0
index fa15706..dec4f04 100644
@@ -59,6 +59,8 @@
 #define   OHCI1394_LinkControl_cycleSource	(1 << 22)
 #define OHCI1394_NodeID                       0x0E8
 #define   OHCI1394_NodeID_idValid             0x80000000
+#define   OHCI1394_NodeID_nodeNumber          0x0000003f
+#define   OHCI1394_NodeID_busNumber           0x0000ffc0
 #define OHCI1394_PhyControl                   0x0EC
 #define   OHCI1394_PhyControl_Read(addr)	(((addr) << 8) | 0x00008000)
 #define   OHCI1394_PhyControl_ReadDone		0x80000000

commit ab88ca488b8af66c3defa165874e81e695319a19

Author: Stefan Richter <[email protected]>
Date:   Wed Aug 29 19:40:28 2007 +0200

firewire: fw-ohci: missing dma_unmap_single

at_context_queue_packet() didn't clean up in an early exit path.

drivers/firewire/fw-ohci.c +3 -0
index a333748..ec70c9f 100644
@@ -680,6 +680,9 @@ at_context_queue_packet(struct context *ctx, struct fw_packet *packet)
 
 	/* FIXME: Document how the locking works. */
 	if (ohci->generation != packet->generation) {
+		if (packet->payload_length > 0)
+			dma_unmap_single(ohci->card.device, payload_bus,
+					 packet->payload_length, DMA_TO_DEVICE);
 		packet->ack = RCODE_GENERATION;
 		return -1;
 	}

commit e524f616f59722bc7f93eb1fd79d3bbdcdf4f894

Author: Stefan Richter <[email protected]>
Date:   Mon Aug 20 21:58:30 2007 +0200

firewire: fw-ohci: log posted write errors

drivers/firewire/fw-ohci.c +6 -2
index c16fcb9..a333748 100644
@@ -18,6 +18,7 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include <linux/compiler.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/gfp.h>
@@ -1049,6 +1050,9 @@ static irqreturn_t irq_handler(int irq, void *data)
 		iso_event &= ~(1 << i);
 	}
 
+	if (unlikely(event & OHCI1394_postedWriteErr))
+		fw_error("PCI posted write error\n");
+
 	if (event & OHCI1394_cycle64Seconds) {
 		cycle_time = reg_read(ohci, OHCI1394_IsochronousCycleTimer);
 		if ((cycle_time & 0x80000000) == 0)
@@ -1122,8 +1126,8 @@ static int ohci_enable(struct fw_card *card, u32 *config_rom, size_t length)
 		  OHCI1394_RQPkt | OHCI1394_RSPkt |
 		  OHCI1394_reqTxComplete | OHCI1394_respTxComplete |
 		  OHCI1394_isochRx | OHCI1394_isochTx |
-		  OHCI1394_masterIntEnable |
-		  OHCI1394_cycle64Seconds);
+		  OHCI1394_postedWriteErr | OHCI1394_cycle64Seconds |
+		  OHCI1394_masterIntEnable);
 
 	/* Activate link_on bit and contender bit in our self ID packets.*/
 	if (ohci_update_phy_reg(card, 4, 0,

commit a7fb60db711fce56e372f0bb8a733c0ad1743525

Author: Stefan Richter <[email protected]>
Date:   Mon Aug 20 21:41:22 2007 +0200

firewire: fw-ohci: reorder includes

drivers/firewire/fw-ohci.c +6 -6
index 48768b5..c16fcb9 100644
@@ -18,22 +18,22 @@
  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/interrupt.h>
-#include <linux/pci.h>
 #include <linux/delay.h>
 #include <linux/dma-mapping.h>
 #include <linux/gfp.h>
+#include <linux/init.h>
+#include <linux/interrupt.h>
+#include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/module.h>
+#include <linux/pci.h>
 #include <linux/spinlock.h>
 
 #include <asm/page.h>
 #include <asm/system.h>
 
-#include "fw-transaction.h"
 #include "fw-ohci.h"
+#include "fw-transaction.h"
 
 #define DESCRIPTOR_OUTPUT_MORE		0
 #define DESCRIPTOR_OUTPUT_LAST		(1 << 12)

commit c26f02340e89c55390c9044ea65d9aef610b38f5

Author: Stefan Richter <[email protected]>
Date:   Mon Aug 20 21:40:30 2007 +0200

firewire: fw-ohci: fix includes

Add used includes, remove unused includes.

drivers/firewire/fw-ohci.c +3 -3
index a7947ba..48768b5 100644
@@ -24,12 +24,12 @@
 #include <linux/interrupt.h>
 #include <linux/pci.h>
 #include <linux/delay.h>
-#include <linux/poll.h>
 #include <linux/dma-mapping.h>
+#include <linux/gfp.h>
 #include <linux/mm.h>
+#include <linux/spinlock.h>
 
-#include <asm/uaccess.h>
-#include <asm/semaphore.h>
+#include <asm/page.h>
 #include <asm/system.h>
 
 #include "fw-transaction.h"

commit ee71c2f9ee85117e41ef87357ed8f75d29369b98

Author: Stefan Richter <[email protected]>
Date:   Sat Aug 25 14:08:19 2007 +0200

firewire: fw-ohci: enforce read order for selfID generation

It seems unlikely, but access to self_id_cpu[0] could at least in theory be deferred until after the loop over self_id_cpu[1..n] or even after the subsequent reg_read. Enforce the desired order by a read barrier.

Also prevent the reg_read from being reordered relative to the for loop. This isn't necessary if the loop's conditional printk counts as an implicit barrier, but better make it explicit.

(self_id_cpu[] is a coherent DMA buffer.)

drivers/firewire/fw-ohci.c +3 -0
index e14c1ca..a7947ba 100644
@@ -30,6 +30,7 @@
 
 #include <asm/uaccess.h>
 #include <asm/semaphore.h>
+#include <asm/system.h>
 
 #include "fw-transaction.h"
 #include "fw-ohci.h"
@@ -926,12 +927,14 @@ static void bus_reset_tasklet(unsigned long data)
 
 	self_id_count = (reg_read(ohci, OHCI1394_SelfIDCount) >> 3) & 0x3ff;
 	generation = (le32_to_cpu(ohci->self_id_cpu[0]) >> 16) & 0xff;
+	rmb();
 
 	for (i = 1, j = 0; j < self_id_count; i += 2, j++) {
 		if (ohci->self_id_cpu[i] != ~ohci->self_id_cpu[i + 1])
 			fw_error("inconsistent self IDs\n");
 		ohci->self_id_buffer[j] = le32_to_cpu(ohci->self_id_cpu[i]);
 	}
+	rmb();
 
 	/*
 	 * Check the consistency of the self IDs we just read.  The

commit df8ec2490fed5dd23316bbb2c2e90e59e7d37126

Author: Stefan Richter <[email protected]>
Date:   Sun Aug 12 12:51:18 2007 +0200

firewire: fw-sbp2: use an own workqueue (fix system responsiveness)

Firewire-sbp2 did very uncooperative things in the kernel's shared
workqueue: Sleeping until reception of management status from the target for up to 2 seconds, and performing SCSI inquiry and all of the setup of SCSI command set drivers via scsi_add_device. If there were transient or permanent error conditions, this caused long blockage of the kernel's events process, noticeable e.g. by blocked keyboard input.

We now allocate a workqueue process exclusive to fw-sbp2. As a side effect, this also increases parallelism of fw-sbp2's login and reconnect work versus fw-core's device discovery and device update work which is performed in the shared workqueue.

drivers/firewire/fw-sbp2.c +13 -4
index f96f192..5596df6 100644
@@ -39,6 +39,7 @@
 #include <linux/string.h>
 #include <linux/stringify.h>
 #include <linux/timer.h>
+#include <linux/workqueue.h>
 
 #include <scsi/scsi.h>
 #include <scsi/scsi_cmnd.h>
@@ -625,6 +626,8 @@ static void sbp2_release_target(struct kref *kref)
 	scsi_host_put(shost);
 }
 
+static struct workqueue_struct *sbp2_wq;
+
 static void sbp2_reconnect(struct work_struct *work);
 
 static void sbp2_login(struct work_struct *work)
@@ -647,7 +650,8 @@ static void sbp2_login(struct work_struct *work)
 	if (sbp2_send_management_orb(lu, node_id, generation,
 				SBP2_LOGIN_REQUEST, lu->lun, &response) < 0) {
 		if (lu->retries++ < 5) {
-			schedule_delayed_work(&lu->work, DIV_ROUND_UP(HZ, 5));
+			queue_delayed_work(sbp2_wq, &lu->work,
+					   DIV_ROUND_UP(HZ, 5));
 		} else {
 			fw_error("failed to login to %s LUN %04x\n",
 				 unit->device.bus_id, lu->lun);
@@ -866,7 +870,7 @@ static int sbp2_probe(struct device *dev)
 	 * work.
 	 */
 	list_for_each_entry(lu, &tgt->lu_list, link)
-		if (schedule_delayed_work(&lu->work, 0))
+		if (queue_delayed_work(sbp2_wq, &lu->work, 0))
 			kref_get(&tgt->kref);
 	return 0;
 
@@ -910,7 +914,7 @@ static void sbp2_reconnect(struct work_struct *work)
 			lu->retries = 0;
 			PREPARE_DELAYED_WORK(&lu->work, sbp2_login);
 		}
-		schedule_delayed_work(&lu->work, DIV_ROUND_UP(HZ, 5));
+		queue_delayed_work(sbp2_wq, &lu->work, DIV_ROUND_UP(HZ, 5));
 		return;
 	}
 
@@ -940,7 +944,7 @@ static void sbp2_update(struct fw_unit *unit)
 	 */
 	list_for_each_entry(lu, &tgt->lu_list, link) {
 		lu->retries = 0;
-		if (schedule_delayed_work(&lu->work, 0))
+		if (queue_delayed_work(sbp2_wq, &lu->work, 0))
 			kref_get(&tgt->kref);
 	}
 }
@@ -1335,12 +1339,17 @@ MODULE_ALIAS("sbp2");
 
 static int __init sbp2_init(void)
 {
+	sbp2_wq = create_singlethread_workqueue(KBUILD_MODNAME);
+	if (!sbp2_wq)
+		return -ENOMEM;
+
 	return driver_register(&sbp2_driver.driver);
 }
 
 static void __exit sbp2_cleanup(void)
 {
 	driver_unregister(&sbp2_driver.driver);
+	destroy_workqueue(sbp2_wq);
 }
 
 module_init(sbp2_init);

commit 2df222b8f8fe9e18c9c9fdfd46f60dad55f5ac14

Author: Stefan Richter <[email protected]>
Date:   Mon Aug 13 17:48:25 2007 +0200

firewire: fw-sbp2: expose module parameter for workarounds

On rare occasions, the ability to set one of the workaround flags at runtime may save the day.

People who experience I/O errors with firewire-sbp2 while the old sbp2 driver worked for them should try workarounds=1 and report to the devel mailinglist whether that improves things. Firewire-sbp2 defaults to the SCSI stack's maximum transfer size per command, while sbp2 limits them to 128 kBytes. Flag 1 accomplishes just that.

drivers/firewire/fw-sbp2.c +54 -12

102 lines not on this page · raw message

commit 5a3c2be6c9a5641a06c71c906645d676fa4d3fdc

Author: Stefan Richter <[email protected]>
Date:   Sat Aug 25 14:05:28 2007 +0200

firewire: fw-sbp2: add support for multiple logical units per target

Fixes "New firewire stack only recognizing half of a chain of drives",
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=242254

drivers/firewire/fw-device.h +0 -5
index d13e6a6..894d4a9 100644
@@ -102,11 +102,6 @@ fw_unit(struct device *dev)
 #define CSR_INSTANCE		0x18
 #define CSR_DIRECTORY_ID	0x20
 
-#define SBP2_COMMAND_SET_SPECIFIER	0x38
-#define SBP2_COMMAND_SET		0x39
-#define SBP2_COMMAND_SET_REVISION	0x3b
-#define SBP2_FIRMWARE_REVISION		0x3c
-
 struct fw_csr_iterator {
 	u32 *p;
 	u32 *end;
drivers/firewire/fw-sbp2.c +324 -251

913 lines not on this page · raw message

commit 1b34e97441384d527c438a6ee597bfc800373bce

Author: Stefan Richter <[email protected]>
Date:   Sat Aug 25 10:40:42 2007 +0200

firewire: fw-sbp2: always enable IRQs before calling command ORB callback

On IOMMU-less noncoherent architectures, orb->callback will memcpy the whole SCSI command buffer for READ-like SCSI commands. It is therefore friendlier to enable IRQs before the call, like before patch "Add ref-counting for sbp2 orbs".

drivers/firewire/fw-sbp2.c +3 -2
index 238730f..7ecc154 100644
@@ -361,11 +361,12 @@ complete_transaction(struct fw_card *card, int rcode,
 		orb->rcode = rcode;
 	if (orb->rcode != RCODE_COMPLETE) {
 		list_del(&orb->link);
+		spin_unlock_irqrestore(&card->lock, flags);
 		orb->callback(orb, NULL);
+	} else {
+		spin_unlock_irqrestore(&card->lock, flags);
 	}
 
-	spin_unlock_irqrestore(&card->lock, flags);
-
 	kref_put(&orb->kref, free_orb);
 }
 

commit 930e4b7fe3b4e1c4e14b9c22e4c9c74dc8db75f3

Author: Stefan Richter <[email protected]>
Date:   Fri Aug 3 20:56:31 2007 +0200

firewire: fw-core: local variable shadows a global one

Sparse warned about it although it was apparently harmless:

drivers/firewire/fw-cdev.c:624:23: warning: symbol 'interrupt' shadows an earlier one include/asm/hw_irq.h:29:13: originally declared here

drivers/firewire/fw-cdev.c +10 -11
index 0647130..b960fd9 100644
@@ -621,20 +621,19 @@ iso_callback(struct fw_iso_context *context, u32 cycle,
 	     size_t header_length, void *header, void *data)
 {
 	struct client *client = data;
-	struct iso_interrupt *interrupt;
+	struct iso_interrupt *irq;
 
-	interrupt = kzalloc(sizeof(*interrupt) + header_length, GFP_ATOMIC);
-	if (interrupt == NULL)
+	irq = kzalloc(sizeof(*irq) + header_length, GFP_ATOMIC);
+	if (irq == NULL)
 		return;
 
-	interrupt->interrupt.type      = FW_CDEV_EVENT_ISO_INTERRUPT;
-	interrupt->interrupt.closure   = client->iso_closure;
-	interrupt->interrupt.cycle     = cycle;
-	interrupt->interrupt.header_length = header_length;
-	memcpy(interrupt->interrupt.header, header, header_length);
-	queue_event(client, &interrupt->event,
-		    &interrupt->interrupt,
-		    sizeof(interrupt->interrupt) + header_length, NULL, 0);
+	irq->interrupt.type      = FW_CDEV_EVENT_ISO_INTERRUPT;
+	irq->interrupt.closure   = client->iso_closure;
+	irq->interrupt.cycle     = cycle;
+	irq->interrupt.header_length = header_length;
+	memcpy(irq->interrupt.header, header, header_length);
+	queue_event(client, &irq->event, &irq->interrupt,
+		    sizeof(irq->interrupt) + header_length, NULL, 0);
 }
 
 static int ioctl_create_iso_context(struct client *client, void *buffer)

commit 1415d9189e8c59aa9c77a3bba419dcea062c145f

Author: Stefan Richter <[email protected]>
Date:   Tue Jul 17 02:10:16 2007 +0200

firewire: optimize fw_core_add_address_handler

Potentially avoids unnecessary loop runs. Guarantee quadlet-aligned starts of address regions. Document the return values.

drivers/firewire/fw-transaction.c +9 -3
index 3e1cb12..9959b79 100644
@@ -410,7 +410,12 @@ EXPORT_SYMBOL(fw_unit_space_region);
  * controller.  When a request is received that falls within the
  * specified address range, the specified callback is invoked.  The
  * parameters passed to the callback give the details of the
- * particular request
+ * particular request.
+ *
+ * Return value:  0 on success, non-zero otherwise.
+ * The start offset of the handler's address region is determined by
+ * fw_core_add_address_handler() and is returned in handler->offset.
+ * The offset is quadlet-aligned.
  */
 int
 fw_core_add_address_handler(struct fw_address_handler *handler,
@@ -422,14 +427,15 @@ fw_core_add_address_handler(struct fw_address_handler *handler,
 
 	spin_lock_irqsave(&address_handler_lock, flags);
 
-	handler->offset = region->start;
+	handler->offset = roundup(region->start, 4);
 	while (handler->offset + handler->length <= region->end) {
 		other =
 		    lookup_overlapping_address_handler(&address_handler_list,
 						       handler->offset,
 						       handler->length);
 		if (other != NULL) {
-			handler->offset += other->length;
+			handler->offset =
+			    roundup(other->offset + other->length, 4);
 		} else {
 			list_add_tail(&handler->link, &address_handler_list);
 			ret = 0;

commit 002a98f14720f90b107e8c44b7733f9bd5dff728

Author: Matthias Kaehlcke <[email protected]>
Date:   Fri Oct 12 19:57:23 2007 +0200

ieee1394: ieee1394_core.c: use DEFINE_SPINLOCK for spinlock definition

drivers/ieee1394/ieee1394_core.c: Define spinlock using DEFINE_SPINLOCK instead of assignment to SPIN_LOCK_UNLOCKED

drivers/ieee1394/ieee1394_core.c +1 -1
index 98fd985..36c747b 100644
@@ -488,7 +488,7 @@ void hpsb_selfid_complete(struct hpsb_host *host, int phyid, int isroot)
 	highlevel_host_reset(host);
 }
 
-static spinlock_t pending_packets_lock = SPIN_LOCK_UNLOCKED;
+static DEFINE_SPINLOCK(pending_packets_lock);
 
 /**
  * hpsb_packet_sent - notify core of sending a packet

commit 17a19b795e9187d65b6e45cb22797725d50f7edb

Author: Stefan Richter <[email protected]>
Date:   Sat Sep 15 14:50:25 2007 +0200

ieee1394: csr1212: proper refcounting

At least since nodemgr got rid of coarse global locking, accesses to struct csr1212_keyval's reference counter should be atomic and coupled with proper barriers. Also, calls to csr1212_keep_keyval(kv) should occur before kv is being used.

(We probably should convert refcnt to struct kref, but how to keep csr1212_destroy_keyval's implementation non-recursively then?)

drivers/ieee1394/csr1212.c +30 -27

144 lines not on this page · raw message

drivers/ieee1394/csr1212.h +4 -2
index df909ce..043039f 100644
@@ -32,6 +32,7 @@
 
 #include <linux/types.h>
 #include <linux/slab.h>
+#include <asm/atomic.h>
 
 #define CSR1212_MALLOC(size)	kmalloc((size), GFP_KERNEL)
 #define CSR1212_FREE(ptr)	kfree(ptr)
@@ -149,7 +150,7 @@ struct csr1212_keyval {
 		struct csr1212_directory directory;
 	} value;
 	struct csr1212_keyval *associate;
-	int refcnt;
+	atomic_t refcnt;
 
 	/* used in generating and/or parsing CSR image */
 	struct csr1212_keyval *next, *prev;	/* flat list of CSR elements */
@@ -350,7 +351,8 @@ csr1212_get_keyval(struct csr1212_csr *csr, struct csr1212_keyval *kv);
  * need for code to retain a keyval that has been parsed. */
 static inline void csr1212_keep_keyval(struct csr1212_keyval *kv)
 {
-	kv->refcnt++;
+	atomic_inc(&kv->refcnt);
+	smp_mb__after_atomic_inc();
 }
 
 
drivers/ieee1394/nodemgr.c +2 -2
index ec8edd2..90dc75b 100644
@@ -1014,13 +1014,13 @@ static struct unit_directory *nodemgr_process_unit_directory
 			    CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0) {
 				switch (last_key_id) {
 				case CSR1212_KV_ID_VENDOR:
-					ud->vendor_name_kv = kv;
 					csr1212_keep_keyval(kv);
+					ud->vendor_name_kv = kv;
 					break;
 
 				case CSR1212_KV_ID_MODEL:
-					ud->model_name_kv = kv;
 					csr1212_keep_keyval(kv);
+					ud->model_name_kv = kv;
 					break;
 
 				}

commit 638d5bb8167c2c88552257d5af23f7f65ab4defd

Author: Stefan Richter <[email protected]>
Date:   Sat Sep 15 14:45:53 2007 +0200

ieee1394: nodemgr: fix leak of struct csr1212_keyval

csr1212_keep_keyval(kv) in nodemgr_process_root_directory was unbalanced if ne->vendor_name_kv already exists. This happens for example if eth1394 or raw1394 modify the local config ROM and it is parsed again.

As a bonus, the attempt to add the vendor_name_kv sysfs attribute when it already exists is now fixed for good.

drivers/ieee1394/nodemgr.c +9 -6
index 11712a3..ec8edd2 100644
@@ -1112,7 +1112,7 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
 {
 	unsigned int ud_id = 0;
 	struct csr1212_dentry *dentry;
-	struct csr1212_keyval *kv;
+	struct csr1212_keyval *kv, *vendor_name_kv = NULL;
 	u8 last_key_id = 0;
 
 	ne->needs_probe = 0;
@@ -1139,8 +1139,8 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
 				    CSR1212_TEXTUAL_DESCRIPTOR_LEAF_WIDTH(kv) == 0 &&
 				    CSR1212_TEXTUAL_DESCRIPTOR_LEAF_CHAR_SET(kv) == 0 &&
 				    CSR1212_TEXTUAL_DESCRIPTOR_LEAF_LANGUAGE(kv) == 0) {
-					ne->vendor_name_kv = kv;
 					csr1212_keep_keyval(kv);
+					vendor_name_kv = kv;
 				}
 			}
 			break;
@@ -1149,10 +1149,13 @@ static void nodemgr_process_root_directory(struct host_info *hi, struct node_ent
 	}
 
 	if (ne->vendor_name_kv) {
-		int error = device_create_file(&ne->device,
-					       &dev_attr_ne_vendor_name_kv);
-
-		if (error && error != -EEXIST)
+		kv = ne->vendor_name_kv;
+		ne->vendor_name_kv = vendor_name_kv;
+		csr1212_release_keyval(kv);
+	} else if (vendor_name_kv) {
+		ne->vendor_name_kv = vendor_name_kv;
+		if (device_create_file(&ne->device,
+				       &dev_attr_ne_vendor_name_kv) != 0)
 			HPSB_ERR("Failed to add sysfs attribute");
 	}
 }

commit 745647e7a2ae399f7f70aca47827e62c99c893b5

Author: Jean Delvare <[email protected]>
Date:   Sat Sep 8 14:09:19 2007 +0200

ieee1394: pcilynx: I2C cleanups

* Delete optional and empty i2c client_register and client_unregister callbacks.
* Use the proper i2c adapter ID.
* Don't use a template to initialize the i2c_adapter structure, it's inefficient.
* Update a misleading comment on why we use i2c_transfer rather than higher level i2c functions.

drivers/ieee1394/pcilynx.c +5 -21
index 7762e43..8af01ab 100644
@@ -121,16 +121,6 @@ static int bit_getsda(void *data)
 	return reg_read((struct ti_lynx *) data, SERIAL_EEPROM_CONTROL) & 0x00000010;
 }
 
-static int bit_reg(struct i2c_client *client)
-{
-	return 0;
-}
-
-static int bit_unreg(struct i2c_client *client)
-{
-	return 0;
-}
-
 static struct i2c_algo_bit_data bit_data = {
 	.setsda			= bit_setsda,
 	.setscl			= bit_setscl,
@@ -140,14 +130,6 @@ static struct i2c_algo_bit_data bit_data = {
 	.timeout		= 100,
 };
 
-static struct i2c_adapter bit_ops = {
-	.id 			= 0xAA, //FIXME: probably we should get an id in i2c-id.h
-	.client_register	= bit_reg,
-	.client_unregister	= bit_unreg,
-	.name			= "PCILynx I2C",
-};
-
-
 
 /*
  * PCL handling functions.
@@ -1435,9 +1417,11 @@ static int __devinit add_card(struct pci_dev *dev,
         	struct i2c_algo_bit_data i2c_adapter_data;
 
         	error = -ENOMEM;
-		i2c_ad = kmemdup(&bit_ops, sizeof(*i2c_ad), GFP_KERNEL);
+		i2c_ad = kzalloc(sizeof(*i2c_ad), GFP_KERNEL);
         	if (!i2c_ad) FAIL("failed to allocate I2C adapter memory");
 
+		i2c_ad->id = I2C_HW_B_PCILYNX;
+		strlcpy(i2c_ad->name, "PCILynx I2C", sizeof(i2c_ad->name));
                 i2c_adapter_data = bit_data;
                 i2c_ad->algo_data = &i2c_adapter_data;
                 i2c_adapter_data.data = lynx;
@@ -1464,8 +1448,8 @@ static int __devinit add_card(struct pci_dev *dev,
                                                   { 0x50, I2C_M_RD, 20, (unsigned char*) lynx->bus_info_block }
                                                 };
 
-                        /* we use i2c_transfer, because i2c_smbus_read_block_data does not work properly and we
-                           do it more efficiently in one transaction rather then using several reads */
+			/* we use i2c_transfer because we have no i2c_client
+			   at hand */
                         if (i2c_transfer(i2c_ad, msg, 2) < 0) {
                                 PRINT(KERN_ERR, lynx->id, "unable to read bus info block from i2c");
                         } else {

commit 69e2b602966533256edce1ed1b24fec23fe05962

Author: Satyam Sharma <[email protected]>
Date:   Wed Aug 15 20:05:38 2007 +0530

ieee1394: Fix kthread stopping in nodemgr_host_thread

The nodemgr host thread can exit on its own even when kthread_should_stop is not true, on receiving a signal (might never happen in practice, as it ignores signals). But considering kthread_stop() must not be mixed with kthreads that can exit on their own, I think changing the code like this is clearer. This change means the thread can cut its sleep short when receive a signal but looking at the code around, that sounds okay (and again, it might never actually recieve a signal in practice).

drivers/ieee1394/nodemgr.c +2 -1
index 1939fee..11712a3 100644
@@ -1712,7 +1712,8 @@ static int nodemgr_host_thread(void *__hi)
 		 * to make sure things settle down. */
 		g = get_hpsb_generation(host);
 		for (i = 0; i < 4 ; i++) {
-			if (msleep_interruptible(63) || kthread_should_stop())
+			msleep_interruptible(63);
+			if (kthread_should_stop())
 				goto exit;
 
 			/* Now get the generation in which the node ID's we collect

commit 261b5f664c6c68c5209656a71c41823eda0d938b

Author: Stefan Richter <[email protected]>
Date:   Sat Aug 11 11:52:08 2007 +0200

ieee1394: sbp2: fix unsafe iteration over list of devices

sbp2_host_reset and sbp2_handle_status_write are not serialized against sbp2_alloc_device and sbp2_remove_device.

drivers/ieee1394/sbp2.c +15 -0
index a81ba8f..1b353b9 100644
@@ -242,6 +242,8 @@ static int sbp2_max_speed_and_size(struct sbp2_lu *);
 
 static const u8 sbp2_speedto_max_payload[] = { 0x7, 0x8, 0x9, 0xA, 0xB, 0xC };
 
+static DEFINE_RWLOCK(sbp2_hi_logical_units_lock);
+
 static struct hpsb_highlevel sbp2_highlevel = {
 	.name		= SBP2_DEVICE_NAME,
 	.host_reset	= sbp2_host_reset,
@@ -732,6 +734,7 @@ static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *ud)
 	struct sbp2_fwhost_info *hi;
 	struct Scsi_Host *shost = NULL;
 	struct sbp2_lu *lu = NULL;
+	unsigned long flags;
 
 	lu = kzalloc(sizeof(*lu), GFP_KERNEL);
 	if (!lu) {
@@ -784,7 +787,9 @@ static struct sbp2_lu *sbp2_alloc_device(struct unit_directory *ud)
 
 	lu->hi = hi;
 
+	write_lock_irqsave(&sbp2_hi_logical_units_lock, flags);
 	list_add_tail(&lu->lu_list, &hi->logical_units);
+	write_unlock_irqrestore(&sbp2_hi_logical_units_lock, flags);
 
 	/* Register the status FIFO address range. We could use the same FIFO
 	 * for targets at different nodes. However we need different FIFOs per
@@ -828,16 +833,20 @@ static void sbp2_host_reset(struct hpsb_host *host)
 {
 	struct sbp2_fwhost_info *hi;
 	struct sbp2_lu *lu;
+	unsigned long flags;
 
 	hi = hpsb_get_hostinfo(&sbp2_highlevel, host);
 	if (!hi)
 		return;
+
+	read_lock_irqsave(&sbp2_hi_logical_units_lock, flags);
 	list_for_each_entry(lu, &hi->logical_units, lu_list)
 		if (likely(atomic_read(&lu->state) !=
 			   SBP2LU_STATE_IN_SHUTDOWN)) {
 			atomic_set(&lu->state, SBP2LU_STATE_IN_RESET);
 			scsi_block_requests(lu->shost);
 		}
+	read_unlock_irqrestore(&sbp2_hi_logical_units_lock, flags);
 }
 
 static int sbp2_start_device(struct sbp2_lu *lu)
@@ -919,6 +928,7 @@ alloc_fail:
 static void sbp2_remove_device(struct sbp2_lu *lu)
 {
 	struct sbp2_fwhost_info *hi;
+	unsigned long flags;
 
 	if (!lu)
 		return;
@@ -933,7 +943,9 @@ static void sbp2_remove_device(struct sbp2_lu *lu)
 	flush_scheduled_work();
 	sbp2util_remove_command_orb_pool(lu, hi->host);
 
+	write_lock_irqsave(&sbp2_hi_logical_units_lock, flags);
 	list_del(&lu->lu_list);
+	write_unlock_irqrestore(&sbp2_hi_logical_units_lock, flags);
 
 	if (lu->login_response)
 		dma_free_coherent(hi->host->device.parent,
@@ -1707,6 +1719,7 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
 	}
 
 	/* Find the unit which wrote the status. */
+	read_lock_irqsave(&sbp2_hi_logical_units_lock, flags);
 	list_for_each_entry(lu_tmp, &hi->logical_units, lu_list) {
 		if (lu_tmp->ne->nodeid == nodeid &&
 		    lu_tmp->status_fifo_addr == addr) {
@@ -1714,6 +1727,8 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid,
 			break;
 		}
 	}
+	read_unlock_irqrestore(&sbp2_hi_logical_units_lock, flags);
+
 	if (unlikely(!lu)) {
 		SBP2_ERR("lu is NULL - device is gone?");
 		return RCODE_ADDRESS_ERROR;

commit c4f3d41fed11c9050aa93bbaeed9f7f06bcc93ba

Author: Stefan Richter <[email protected]>
Date:   Sun Jul 29 00:01:35 2007 +0200

ieee1394: pcilynx: superfluous local variables

drivers/ieee1394/pcilynx.c +0 -3
index d1a5bcd..7762e43 100644
@@ -765,7 +765,6 @@ static int lynx_devctl(struct hpsb_host *host, enum devctl_cmd cmd, int arg)
                 } else {
                         struct ti_pcl pcl;
                         u32 ack;
-                        struct hpsb_packet *packet;
 
                         PRINT(KERN_INFO, lynx->id, "cancelling async packet, that was already in PCL");
 
@@ -1470,8 +1469,6 @@ static int __devinit add_card(struct pci_dev *dev,
                         if (i2c_transfer(i2c_ad, msg, 2) < 0) {
                                 PRINT(KERN_ERR, lynx->id, "unable to read bus info block from i2c");
                         } else {
-                                int i;
-
                                 PRINT(KERN_INFO, lynx->id, "got bus info block from serial eeprom");
 				/* FIXME: probably we shoud rewrite the max_rec, max_ROM(1394a),
 				 * generation(1394a) and link_spd(1394a) field and recalculate

commit 661afcae1b6b6493e4ea69f81bae78397c066f25

Author: Stefan Richter <[email protected]>
Date:   Sat Jul 28 23:45:03 2007 +0200
    ieee1394: eth1394: fix lock imbalance
    
    bad_proto can be reached from points which did not take priv->lock.
    
    Signed-off-by: Stefan Richter <[email protected]>
drivers/ieee1394/eth1394.c +5 -9
index 7aa0bf3..b166b35 100644
@@ -1220,23 +1220,19 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
 		priv->stats.rx_errors++;
 		priv->stats.rx_dropped++;
 		dev_kfree_skb_any(skb);
-		goto bad_proto;
-	}
-
-	if (netif_rx(skb) == NET_RX_DROP) {
+	} else if (netif_rx(skb) == NET_RX_DROP) {
 		priv->stats.rx_errors++;
 		priv->stats.rx_dropped++;
-		goto bad_proto;
+	} else {
+		priv->stats.rx_packets++;
+		priv->stats.rx_bytes += skb->len;
 	}
 
-	/* Statistics */
-	priv->stats.rx_packets++;
-	priv->stats.rx_bytes += skb->len;
+	spin_unlock_irqrestore(&priv->lock, flags);
 
 bad_proto:
 	if (netif_queue_stopped(dev))
 		netif_wake_queue(dev);
-	spin_unlock_irqrestore(&priv->lock, flags);
 
 	dev->last_rx = jiffies;
 

commit 3bd90303f05d24487759e4990c3fed3e7a6b6955

Author: Stefan Richter <[email protected]>
Date:   Sat Jul 28 23:44:25 2007 +0200

ieee1394: eth1394: superfluous local variable

drivers/ieee1394/eth1394.c +0 -2
index dc9dce2..7aa0bf3 100644
@@ -1153,8 +1153,6 @@ static int ether1394_data_handler(struct net_device *dev, int srcid, int destid,
 			pdg->sz++;
 			lh = find_partial_datagram(pdgl, dgl);
 		} else {
-			struct partial_datagram *pd;
-
 			pd = list_entry(lh, struct partial_datagram, list);
 
 			if (fragment_overlap(&pd->frag_info, fg_off, fg_len)) {
Signature · 3 lines
Stefan Richter
-=====-=-=== =-=- =---=
http://arcgraph.de/sr/