isci: rework timer api
authorDan Williams <dan.j.williams@intel.com>
Wed, 2 Mar 2011 19:49:26 +0000 (11:49 -0800)
committerDan Williams <dan.j.williams@intel.com>
Sun, 3 Jul 2011 10:55:28 +0000 (03:55 -0700)
Prepare the timer api for the arrival of dynamic creation and
destruction events from the core.  It pretended to do this previously
but the core to date only used it in a static init-time only fashion.
This is an interim fix until a cleaner event queue can be developed.

1/ make all locking external to the api (add WARN_ONCE to verify)
2/ add a timer_destroy interface (to be used by the core)
3/ use del_timer_sync() prior to deallocating timer data
4/ delete the "timer_list" indirection, we only have timers allocated
   for the isci_host
5/ fix detection of timer list allocation errors

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/scsi/isci/events.c
drivers/scsi/isci/events.h
drivers/scsi/isci/host.c
drivers/scsi/isci/host.h
drivers/scsi/isci/task.c
drivers/scsi/isci/timers.c
drivers/scsi/isci/timers.h

index 8872f4c..c5cbaed 100644 (file)
  *    whenever the timer expires.
  * @controller: This parameter specifies the controller with which this timer
  *    is to be associated.
- * @cookie: This parameter specifies a piece of information that the user must
- *    retain.  This cookie is to be supplied by the user anytime a timeout
- *    occurs for the created timer.
+ * @cb_param: opaque callback parameter
  *
  * This method returns a handle to a timer object created by the user.  The
  * handle will be utilized for all further interactions relating to this timer.
  */
-void *isci_event_timer_create(
-       struct scic_sds_controller *controller,
-       void (*timer_callback)(void *),
-       void *cookie)
+void *isci_event_timer_create(struct scic_sds_controller *scic,
+                             void (*timer_callback)(void *),
+                             void *cb_param)
 {
-       struct isci_host *isci_host;
-       struct isci_timer *timer = NULL;
-
-       isci_host = (struct isci_host *)sci_object_get_association(controller);
+       struct isci_host *ihost = sci_object_get_association(scic);
+       struct isci_timer *itimer;
 
-       dev_dbg(&isci_host->pdev->dev,
-               "%s: isci_host = %p",
-               __func__, isci_host);
-
-       timer = isci_timer_create(&isci_host->timer_list_struct,
-                                 isci_host,
-                                 cookie,
-                                 timer_callback);
+       itimer = isci_timer_create(ihost, cb_param, timer_callback);
 
-       dev_dbg(&isci_host->pdev->dev, "%s: timer = %p\n", __func__, timer);
+       dev_dbg(&ihost->pdev->dev, "%s: timer = %p\n", __func__, itimer);
 
-       return (void *)timer;
+       return itimer;
 }
 
 
@@ -146,14 +134,9 @@ void isci_event_timer_start(
  * @timer: This parameter specifies the timer to be stopped.
  *
  */
-void isci_event_timer_stop(
-       struct scic_sds_controller *controller,
-       void *timer)
+void isci_event_timer_stop(struct scic_sds_controller *controller, void *timer)
 {
-       struct isci_host *isci_host;
-
-       isci_host =
-               (struct isci_host *)sci_object_get_association(controller);
+       struct isci_host *isci_host = sci_object_get_association(controller);
 
        dev_dbg(&isci_host->pdev->dev,
                "%s: isci_host = %p, timer = %p\n",
@@ -162,6 +145,16 @@ void isci_event_timer_stop(
        isci_timer_stop((struct isci_timer *)timer);
 }
 
+void isci_event_timer_destroy(struct scic_sds_controller *scic, void *timer)
+{
+        struct isci_host *ihost = sci_object_get_association(scic);
+
+       dev_dbg(&ihost->pdev->dev, "%s: ihost = %p, timer = %p\n",
+                       __func__, ihost, timer);
+
+       isci_del_timer(ihost, timer);
+}
+
 /**
  * isci_event_controller_start_complete() - This user callback will inform the
  *    user that the controller has finished the start process. The associated
index 98526e9..fa2f6aa 100644 (file)
@@ -111,6 +111,9 @@ void isci_event_timer_stop(
        struct scic_sds_controller *controller,
        void *timer);
 
+
+void isci_event_timer_destroy(struct scic_sds_controller *scic, void *timer);
+
 /**
  * isci_event_controller_start_complete() - This user callback will inform the
  *    user that the controller has finished the start process.
index d8d6f67..1bc91f2 100644 (file)
@@ -349,9 +349,14 @@ void isci_host_deinit(struct isci_host *ihost)
        }
 
        set_bit(IHOST_STOP_PENDING, &ihost->flags);
+
+       spin_lock_irq(&ihost->scic_lock);
        scic_controller_stop(scic, SCIC_CONTROLLER_STOP_TIMEOUT);
+       spin_unlock_irq(&ihost->scic_lock);
+
        wait_for_stop(ihost);
        scic_controller_reset(scic);
+       isci_timer_list_destroy(ihost);
 }
 
 static void __iomem *scu_base(struct isci_host *isci_host)
@@ -370,8 +375,6 @@ static void __iomem *smu_base(struct isci_host *isci_host)
        return pcim_iomap_table(pdev)[SCI_SMU_BAR * 2] + SCI_SMU_BAR_SIZE * id;
 }
 
-#define SCI_MAX_TIMER_COUNT 25
-
 int isci_host_init(struct isci_host *isci_host)
 {
        int err = 0;
@@ -382,11 +385,7 @@ int isci_host_init(struct isci_host *isci_host)
        union scic_oem_parameters scic_oem_params;
        union scic_user_parameters scic_user_params;
 
-       INIT_LIST_HEAD(&isci_host->timer_list_struct.timers);
-       isci_timer_list_construct(
-               &isci_host->timer_list_struct,
-               SCI_MAX_TIMER_COUNT
-               );
+       isci_timer_list_construct(isci_host);
 
        controller = scic_controller_alloc(&isci_host->pdev->dev);
 
@@ -473,7 +472,17 @@ int isci_host_init(struct isci_host *isci_host)
                }
        }
 
+       tasklet_init(&isci_host->completion_tasklet,
+                    isci_host_completion_routine, (unsigned long)isci_host);
+
+       INIT_LIST_HEAD(&(isci_host->mdl_struct_list));
+
+       INIT_LIST_HEAD(&isci_host->requests_to_complete);
+       INIT_LIST_HEAD(&isci_host->requests_to_abort);
+
+       spin_lock_irq(&isci_host->scic_lock);
        status = scic_controller_initialize(isci_host->core_controller);
+       spin_unlock_irq(&isci_host->scic_lock);
        if (status != SCI_SUCCESS) {
                dev_warn(&isci_host->pdev->dev,
                         "%s: scic_controller_initialize failed -"
@@ -482,17 +491,8 @@ int isci_host_init(struct isci_host *isci_host)
                return -ENODEV;
        }
 
-       tasklet_init(&isci_host->completion_tasklet,
-                    isci_host_completion_routine, (unsigned long)isci_host);
-
-       INIT_LIST_HEAD(&(isci_host->mdl_struct_list));
-
-       INIT_LIST_HEAD(&isci_host->requests_to_complete);
-       INIT_LIST_HEAD(&isci_host->requests_to_abort);
-
        /* populate mdl with dma memory. scu_mdl_allocate_coherent() */
        err = isci_host_mdl_allocate_coherent(isci_host);
-
        if (err)
                return err;
 
Simple merge
Simple merge
Simple merge
Simple merge