diff options
author | Edmund Nadolski <edmund.nadolski@intel.com> | 2011-05-19 07:59:10 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2011-07-03 07:04:49 -0400 |
commit | 5553ba2be0f3e3741e1a885a33d2b89921f9fd48 (patch) | |
tree | ba29bd7a120cc170b4b6e9f09ee8a4751a3773be | |
parent | 9269e0e898594c65dee6b20d4ed48e33dbbd4eeb (diff) |
isci: replace isci_timer list with proper embedded timers
Rather than preallocating a list of timers and doling them out at runtime,
embed a struct timerlist in each object that needs one. A struct sci_timer
interface is introduced to manage the timer cancellation semantics which
currently need to guarantee the timer is cancelled while holding
spin_lock(ihost->scic_lock). Since the timeout functions also need to acquire
the lock it currently prevents the driver from using del_timer_sync() for
runtime cancellations.
del_timer_sync() is used however before the objects go out of scope.
Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/scsi/isci/host.c | 7 | ||||
-rw-r--r-- | drivers/scsi/isci/isci.h | 33 | ||||
-rw-r--r-- | drivers/scsi/isci/port.c | 39 | ||||
-rw-r--r-- | drivers/scsi/isci/port.h | 6 |
4 files changed, 60 insertions, 25 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index 6cd7648197e1..a3269b6fa225 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c | |||
@@ -1359,6 +1359,13 @@ void isci_host_deinit(struct isci_host *ihost) | |||
1359 | 1359 | ||
1360 | wait_for_stop(ihost); | 1360 | wait_for_stop(ihost); |
1361 | scic_controller_reset(&ihost->sci); | 1361 | scic_controller_reset(&ihost->sci); |
1362 | |||
1363 | /* Cancel any/all outstanding port timers */ | ||
1364 | for (i = 0; i < ihost->sci.logical_port_entries; i++) { | ||
1365 | struct scic_sds_port *sci_port = &ihost->ports[i].sci; | ||
1366 | del_timer_sync(&sci_port->timer.timer); | ||
1367 | } | ||
1368 | |||
1362 | isci_timer_list_destroy(ihost); | 1369 | isci_timer_list_destroy(ihost); |
1363 | } | 1370 | } |
1364 | 1371 | ||
diff --git a/drivers/scsi/isci/isci.h b/drivers/scsi/isci/isci.h index 69826eac97b5..2fe5557d8590 100644 --- a/drivers/scsi/isci/isci.h +++ b/drivers/scsi/isci/isci.h | |||
@@ -551,4 +551,37 @@ extern unsigned char max_concurr_spinup; | |||
551 | irqreturn_t isci_msix_isr(int vec, void *data); | 551 | irqreturn_t isci_msix_isr(int vec, void *data); |
552 | irqreturn_t isci_intx_isr(int vec, void *data); | 552 | irqreturn_t isci_intx_isr(int vec, void *data); |
553 | irqreturn_t isci_error_isr(int vec, void *data); | 553 | irqreturn_t isci_error_isr(int vec, void *data); |
554 | |||
555 | /* | ||
556 | * Each timer is associated with a cancellation flag that is set when | ||
557 | * del_timer() is called and checked in the timer callback function. This | ||
558 | * is needed since del_timer_sync() cannot be called with scic_lock held. | ||
559 | * For deinit however, del_timer_sync() is used without holding the lock. | ||
560 | */ | ||
561 | struct sci_timer { | ||
562 | struct timer_list timer; | ||
563 | bool cancel; | ||
564 | }; | ||
565 | |||
566 | static inline | ||
567 | void sci_init_timer(struct sci_timer *tmr, void (*fn)(unsigned long)) | ||
568 | { | ||
569 | tmr->timer.function = fn; | ||
570 | tmr->timer.data = (unsigned long) tmr; | ||
571 | tmr->cancel = 0; | ||
572 | init_timer(&tmr->timer); | ||
573 | } | ||
574 | |||
575 | static inline void sci_mod_timer(struct sci_timer *tmr, unsigned long msec) | ||
576 | { | ||
577 | tmr->cancel = 0; | ||
578 | mod_timer(&tmr->timer, jiffies + msecs_to_jiffies(msec)); | ||
579 | } | ||
580 | |||
581 | static inline void sci_del_timer(struct sci_timer *tmr) | ||
582 | { | ||
583 | tmr->cancel = 1; | ||
584 | del_timer(&tmr->timer); | ||
585 | } | ||
586 | |||
554 | #endif /* __ISCI_H__ */ | 587 | #endif /* __ISCI_H__ */ |
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c index 3050415e228d..3da9048b45b7 100644 --- a/drivers/scsi/isci/port.c +++ b/drivers/scsi/isci/port.c | |||
@@ -926,17 +926,19 @@ bool scic_sds_port_link_detected( | |||
926 | return true; | 926 | return true; |
927 | } | 927 | } |
928 | 928 | ||
929 | /** | 929 | static void port_timeout(unsigned long data) |
930 | * This method is provided to timeout requests for port operations. Mostly its | ||
931 | * for the port reset operation. | ||
932 | * | ||
933 | * | ||
934 | */ | ||
935 | static void scic_sds_port_timeout_handler(void *port) | ||
936 | { | 930 | { |
937 | struct scic_sds_port *sci_port = port; | 931 | struct sci_timer *tmr = (struct sci_timer *)data; |
932 | struct scic_sds_port *sci_port = container_of(tmr, typeof(*sci_port), timer); | ||
933 | struct isci_host *ihost = scic_to_ihost(sci_port->owning_controller); | ||
934 | unsigned long flags; | ||
938 | u32 current_state; | 935 | u32 current_state; |
939 | 936 | ||
937 | spin_lock_irqsave(&ihost->scic_lock, flags); | ||
938 | |||
939 | if (tmr->cancel) | ||
940 | goto done; | ||
941 | |||
940 | current_state = sci_base_state_machine_get_state(&sci_port->state_machine); | 942 | current_state = sci_base_state_machine_get_state(&sci_port->state_machine); |
941 | 943 | ||
942 | if (current_state == SCI_BASE_PORT_STATE_RESETTING) { | 944 | if (current_state == SCI_BASE_PORT_STATE_RESETTING) { |
@@ -965,6 +967,9 @@ static void scic_sds_port_timeout_handler(void *port) | |||
965 | "%s: SCIC Port 0x%p is processing a timeout operation " | 967 | "%s: SCIC Port 0x%p is processing a timeout operation " |
966 | "in state %d.\n", __func__, sci_port, current_state); | 968 | "in state %d.\n", __func__, sci_port, current_state); |
967 | } | 969 | } |
970 | |||
971 | done: | ||
972 | spin_unlock_irqrestore(&ihost->scic_lock, flags); | ||
968 | } | 973 | } |
969 | 974 | ||
970 | /* --------------------------------------------------------------------------- */ | 975 | /* --------------------------------------------------------------------------- */ |
@@ -1259,7 +1264,6 @@ static void scic_sds_port_ready_substate_configuring_exit(struct sci_base_state_ | |||
1259 | enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port) | 1264 | enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port) |
1260 | { | 1265 | { |
1261 | struct scic_sds_controller *scic = sci_port->owning_controller; | 1266 | struct scic_sds_controller *scic = sci_port->owning_controller; |
1262 | struct isci_host *ihost = scic_to_ihost(scic); | ||
1263 | enum sci_status status = SCI_SUCCESS; | 1267 | enum sci_status status = SCI_SUCCESS; |
1264 | enum scic_sds_port_states state; | 1268 | enum scic_sds_port_states state; |
1265 | u32 phy_mask; | 1269 | u32 phy_mask; |
@@ -1280,14 +1284,6 @@ enum sci_status scic_sds_port_start(struct scic_sds_port *sci_port) | |||
1280 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; | 1284 | return SCI_FAILURE_UNSUPPORTED_PORT_CONFIGURATION; |
1281 | } | 1285 | } |
1282 | 1286 | ||
1283 | sci_port->timer_handle = | ||
1284 | isci_timer_create(ihost, | ||
1285 | sci_port, | ||
1286 | scic_sds_port_timeout_handler); | ||
1287 | |||
1288 | if (!sci_port->timer_handle) | ||
1289 | return SCI_FAILURE_INSUFFICIENT_RESOURCES; | ||
1290 | |||
1291 | if (sci_port->reserved_rni == SCU_DUMMY_INDEX) { | 1287 | if (sci_port->reserved_rni == SCU_DUMMY_INDEX) { |
1292 | u16 rni = scic_sds_remote_node_table_allocate_remote_node( | 1288 | u16 rni = scic_sds_remote_node_table_allocate_remote_node( |
1293 | &scic->available_remote_nodes, 1); | 1289 | &scic->available_remote_nodes, 1); |
@@ -1390,7 +1386,7 @@ static enum sci_status scic_port_hard_reset(struct scic_sds_port *sci_port, u32 | |||
1390 | if (status != SCI_SUCCESS) | 1386 | if (status != SCI_SUCCESS) |
1391 | return status; | 1387 | return status; |
1392 | 1388 | ||
1393 | isci_timer_start(sci_port->timer_handle, timeout); | 1389 | sci_mod_timer(&sci_port->timer, timeout); |
1394 | sci_port->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED; | 1390 | sci_port->not_ready_reason = SCIC_PORT_NOT_READY_HARD_RESET_REQUESTED; |
1395 | 1391 | ||
1396 | port_state_machine_change(sci_port, | 1392 | port_state_machine_change(sci_port, |
@@ -1757,14 +1753,14 @@ static void scic_sds_port_resetting_state_exit(struct sci_base_state_machine *sm | |||
1757 | { | 1753 | { |
1758 | struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); | 1754 | struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); |
1759 | 1755 | ||
1760 | isci_timer_stop(sci_port->timer_handle); | 1756 | sci_del_timer(&sci_port->timer); |
1761 | } | 1757 | } |
1762 | 1758 | ||
1763 | static void scic_sds_port_stopping_state_exit(struct sci_base_state_machine *sm) | 1759 | static void scic_sds_port_stopping_state_exit(struct sci_base_state_machine *sm) |
1764 | { | 1760 | { |
1765 | struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); | 1761 | struct scic_sds_port *sci_port = container_of(sm, typeof(*sci_port), state_machine); |
1766 | 1762 | ||
1767 | isci_timer_stop(sci_port->timer_handle); | 1763 | sci_del_timer(&sci_port->timer); |
1768 | 1764 | ||
1769 | scic_sds_port_destroy_dummy_resources(sci_port); | 1765 | scic_sds_port_destroy_dummy_resources(sci_port); |
1770 | } | 1766 | } |
@@ -1831,7 +1827,8 @@ void scic_sds_port_construct(struct scic_sds_port *sci_port, u8 index, | |||
1831 | sci_port->reserved_rni = SCU_DUMMY_INDEX; | 1827 | sci_port->reserved_rni = SCU_DUMMY_INDEX; |
1832 | sci_port->reserved_tci = SCU_DUMMY_INDEX; | 1828 | sci_port->reserved_tci = SCU_DUMMY_INDEX; |
1833 | 1829 | ||
1834 | sci_port->timer_handle = NULL; | 1830 | sci_init_timer(&sci_port->timer, port_timeout); |
1831 | |||
1835 | sci_port->port_task_scheduler_registers = NULL; | 1832 | sci_port->port_task_scheduler_registers = NULL; |
1836 | 1833 | ||
1837 | for (index = 0; index < SCI_MAX_PHYS; index++) | 1834 | for (index = 0; index < SCI_MAX_PHYS; index++) |
diff --git a/drivers/scsi/isci/port.h b/drivers/scsi/isci/port.h index af540e5c03a0..9a6912855fc1 100644 --- a/drivers/scsi/isci/port.h +++ b/drivers/scsi/isci/port.h | |||
@@ -139,10 +139,8 @@ struct scic_sds_port { | |||
139 | */ | 139 | */ |
140 | struct scic_sds_controller *owning_controller; | 140 | struct scic_sds_controller *owning_controller; |
141 | 141 | ||
142 | /** | 142 | /* timer used for port start/stop operations */ |
143 | * This field contains the port start/stop timer handle. | 143 | struct sci_timer timer; |
144 | */ | ||
145 | void *timer_handle; | ||
146 | 144 | ||
147 | /** | 145 | /** |
148 | * This field is the pointer to the port task scheduler registers | 146 | * This field is the pointer to the port task scheduler registers |