diff options
author | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2006-07-23 22:19:00 +0200 |
---|---|---|
committer | Stefan Richter <stefanr@s5r6.in-berlin.de> | 2006-09-17 19:29:31 +0200 |
commit | e8398bb737ceadff8825aa98cb9f4a5e96857546 (patch) | |
tree | 049eb24f1e8c2277160b58237443a7cf056325b7 /drivers/ieee1394 | |
parent | ieee1394: sbp2: more checks of status block (diff) | |
download | linux-e8398bb737ceadff8825aa98cb9f4a5e96857546.tar.xz linux-e8398bb737ceadff8825aa98cb9f4a5e96857546.zip |
ieee1394: sbp2: convert sbp2util_down_timeout to waitqueue
The waitqueue API is used to replace a custom wait mechanism. Only one
global waitqueue (instead of per-device waitqueues or completions) is
added because there is usually just one waiter.
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
Diffstat (limited to 'drivers/ieee1394')
-rw-r--r-- | drivers/ieee1394/sbp2.c | 51 | ||||
-rw-r--r-- | drivers/ieee1394/sbp2.h | 4 |
2 files changed, 24 insertions, 31 deletions
diff --git a/drivers/ieee1394/sbp2.c b/drivers/ieee1394/sbp2.c index 07030be0ef2a..6adbe1c796c2 100644 --- a/drivers/ieee1394/sbp2.c +++ b/drivers/ieee1394/sbp2.c @@ -55,12 +55,12 @@ #include <linux/smp_lock.h> #include <linux/init.h> #include <linux/pci.h> +#include <linux/wait.h> #include <asm/current.h> #include <asm/uaccess.h> #include <asm/io.h> #include <asm/byteorder.h> -#include <asm/atomic.h> #include <asm/system.h> #include <asm/scatterlist.h> @@ -420,21 +420,23 @@ static void sbp2util_packet_dump(void *buffer, int length, char *dump_name, #define sbp2util_packet_dump(w,x,y,z) #endif +static DECLARE_WAIT_QUEUE_HEAD(access_wq); + /* - * Goofy routine that basically does a down_timeout function. + * Waits for completion of an SBP-2 access request. + * Returns nonzero if timed out or prematurely interrupted. */ -static int sbp2util_down_timeout(atomic_t *done, int timeout) +static int sbp2util_access_timeout(struct scsi_id_instance_data *scsi_id, + int timeout) { - int i; + long leftover = wait_event_interruptible_timeout( + access_wq, scsi_id->access_complete, timeout); - for (i = timeout; (i > 0 && atomic_read(done) == 0); i-= HZ/10) { - if (msleep_interruptible(100)) /* 100ms */ - return 1; - } - return (i > 0) ? 0 : 1; + scsi_id->access_complete = 0; + return leftover <= 0; } -/* Free's an allocated packet */ +/* Frees an allocated packet */ static void sbp2_free_packet(struct hpsb_packet *packet) { hpsb_free_tlabel(packet); @@ -794,7 +796,6 @@ static struct scsi_id_instance_data *sbp2_alloc_device(struct unit_directory *ud scsi_id->speed_code = IEEE1394_SPEED_100; scsi_id->max_payload_size = sbp2_speedto_max_payload[IEEE1394_SPEED_100]; scsi_id->status_fifo_addr = CSR1212_INVALID_ADDR_SPACE; - atomic_set(&scsi_id->sbp2_login_complete, 0); INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_inuse); INIT_LIST_HEAD(&scsi_id->sbp2_command_orb_completed); INIT_LIST_HEAD(&scsi_id->scsi_list); @@ -1187,11 +1188,9 @@ static int sbp2_query_logins(struct scsi_id_instance_data *scsi_id) data[1] = scsi_id->query_logins_orb_dma; sbp2util_cpu_to_be32_buffer(data, 8); - atomic_set(&scsi_id->sbp2_login_complete, 0); - hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8); - if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 2*HZ)) { + if (sbp2util_access_timeout(scsi_id, 2*HZ)) { SBP2_INFO("Error querying logins to SBP-2 device - timed out"); return -EIO; } @@ -1279,15 +1278,13 @@ static int sbp2_login_device(struct scsi_id_instance_data *scsi_id) data[1] = scsi_id->login_orb_dma; sbp2util_cpu_to_be32_buffer(data, 8); - atomic_set(&scsi_id->sbp2_login_complete, 0); - hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8); /* * Wait for login status (up to 20 seconds)... */ - if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, 20*HZ)) { - SBP2_ERR("Error logging into SBP-2 device - login timed-out"); + if (sbp2util_access_timeout(scsi_id, 20*HZ)) { + SBP2_ERR("Error logging into SBP-2 device - timed out"); return -EIO; } @@ -1374,21 +1371,17 @@ static int sbp2_logout_device(struct scsi_id_instance_data *scsi_id) data[1] = scsi_id->logout_orb_dma; sbp2util_cpu_to_be32_buffer(data, 8); - atomic_set(&scsi_id->sbp2_login_complete, 0); - error = hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8); if (error) return error; /* Wait for device to logout...1 second. */ - if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, HZ)) + if (sbp2util_access_timeout(scsi_id, HZ)) return -EIO; SBP2_INFO("Logged out of SBP-2 device"); - return 0; - } /* @@ -1436,8 +1429,6 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) data[1] = scsi_id->reconnect_orb_dma; sbp2util_cpu_to_be32_buffer(data, 8); - atomic_set(&scsi_id->sbp2_login_complete, 0); - error = hpsb_node_write(scsi_id->ne, scsi_id->sbp2_management_agent_addr, data, 8); if (error) @@ -1446,8 +1437,8 @@ static int sbp2_reconnect_device(struct scsi_id_instance_data *scsi_id) /* * Wait for reconnect status (up to 1 second)... */ - if (sbp2util_down_timeout(&scsi_id->sbp2_login_complete, HZ)) { - SBP2_ERR("Error reconnecting to SBP-2 device - reconnect timed-out"); + if (sbp2util_access_timeout(scsi_id, HZ)) { + SBP2_ERR("Error reconnecting to SBP-2 device - timed out"); return -EIO; } @@ -2215,8 +2206,10 @@ static int sbp2_handle_status_write(struct hpsb_host *host, int nodeid, if ((sb->ORB_offset_lo == scsi_id->reconnect_orb_dma) || (sb->ORB_offset_lo == scsi_id->login_orb_dma) || (sb->ORB_offset_lo == scsi_id->query_logins_orb_dma) || - (sb->ORB_offset_lo == scsi_id->logout_orb_dma)) - atomic_set(&scsi_id->sbp2_login_complete, 1); + (sb->ORB_offset_lo == scsi_id->logout_orb_dma)) { + scsi_id->access_complete = 1; + wake_up_interruptible(&access_wq); + } } if (SCpnt) { diff --git a/drivers/ieee1394/sbp2.h b/drivers/ieee1394/sbp2.h index 34e3d37fc79f..89098fe565e9 100644 --- a/drivers/ieee1394/sbp2.h +++ b/drivers/ieee1394/sbp2.h @@ -320,9 +320,9 @@ struct scsi_id_instance_data { u64 status_fifo_addr; /* - * Variable used for logins, reconnects, logouts, query logins + * Waitqueue flag for logins, reconnects, logouts, query logins */ - atomic_t sbp2_login_complete; + int access_complete:1; /* * Pool of command orbs, so we can have more than overlapped command per id |