]> nv-tegra.nvidia Code Review - linux-2.6.git/blobdiff - drivers/scsi/isci/remote_device.c
isci: uplevel register hardware data structures and unsolicited frame handling
[linux-2.6.git] / drivers / scsi / isci / remote_device.c
index e766b27bdc194c0996353177d7456717ee4b459f..00334b9ccd806f9604ffe896c24141ee3a10e72e 100644 (file)
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
-#include "intel_sas.h"
-#include "sas.h"
+#include <scsi/sas.h>
 #include "isci.h"
 #include "port.h"
 #include "remote_device.h"
 #include "request.h"
-#include "scic_controller.h"
 #include "scic_io_request.h"
 #include "scic_phy.h"
 #include "scic_port.h"
-#include "scic_sds_controller.h"
 #include "scic_sds_phy.h"
 #include "scic_sds_port.h"
 #include "remote_node_context.h"
 #include "scic_sds_request.h"
-#include "sci_environment.h"
 #include "sci_util.h"
 #include "scu_event_codes.h"
 #include "task.h"
@@ -305,15 +301,20 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi
        case SCI_BASE_REMOTE_DEVICE_STATE_FAILED:
        case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: {
                struct scic_sds_request *sci_req;
-               struct sci_ssp_frame_header *hdr;
+               struct ssp_frame_hdr hdr;
+               void *frame_header;
+               ssize_t word_cnt;
 
                status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
                                                                       frame_index,
-                                                                      (void **)&hdr);
+                                                                      &frame_header);
                if (status != SCI_SUCCESS)
                        return status;
 
-               sci_req = scic_sds_controller_get_io_request_from_tag(scic, hdr->tag);
+               word_cnt = sizeof(hdr) / sizeof(u32);
+               sci_swab32_cpy(&hdr, frame_header, word_cnt);
+
+               sci_req = scic_request_by_tag(scic, be16_to_cpu(hdr.tag));
                if (sci_req && sci_req->target_device == sci_dev) {
                        /* The IO request is now in charge of releasing the frame */
                        status = sci_req->state_handlers->frame_handler(sci_req,
@@ -469,7 +470,7 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
        struct sci_base_state_machine *sm = &sci_dev->state_machine;
        enum scic_sds_remote_device_states state = sm->current_state_id;
        struct scic_sds_port *sci_port = sci_dev->owning_port;
-       struct isci_request *ireq = sci_req->ireq;
+       struct isci_request *ireq = sci_req_to_ireq(sci_req);
        enum sci_status status;
 
        switch (state) {
@@ -811,7 +812,7 @@ static void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handl
         * As a result, avoid sending the ready notification.
         */
        if (sci_dev->state_machine.previous_state_id != SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ)
-               isci_remote_device_ready(scic->ihost, idev);
+               isci_remote_device_ready(scic_to_ihost(scic), idev);
 }
 
 static void scic_sds_remote_device_initial_state_enter(void *object)
@@ -887,6 +888,7 @@ static void isci_remote_device_deconstruct(struct isci_host *ihost, struct isci_
 
        clear_bit(IDEV_START_PENDING, &idev->flags);
        clear_bit(IDEV_STOP_PENDING, &idev->flags);
+       clear_bit(IDEV_EH, &idev->flags);
        wake_up(&ihost->eventq);
 }
 
@@ -913,21 +915,16 @@ static void isci_remote_device_stop_complete(struct isci_host *ihost,
 static void scic_sds_remote_device_stopped_state_enter(void *object)
 {
        struct scic_sds_remote_device *sci_dev = object;
-       struct scic_sds_controller *scic;
-       struct isci_remote_device *idev;
-       struct isci_host *ihost;
+       struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller;
+       struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
        u32 prev_state;
 
-       scic = scic_sds_remote_device_get_controller(sci_dev);
-       ihost = scic->ihost;
-       idev = sci_dev_to_idev(sci_dev);
-
        /* If we are entering from the stopping state let the SCI User know that
         * the stop operation has completed.
         */
        prev_state = sci_dev->state_machine.previous_state_id;
        if (prev_state == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING)
-               isci_remote_device_stop_complete(ihost, idev);
+               isci_remote_device_stop_complete(scic_to_ihost(scic), idev);
 
        scic_sds_controller_remote_device_stopped(scic, sci_dev);
 }
@@ -936,7 +933,7 @@ static void scic_sds_remote_device_starting_state_enter(void *object)
 {
        struct scic_sds_remote_device *sci_dev = object;
        struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
-       struct isci_host *ihost = scic->ihost;
+       struct isci_host *ihost = scic_to_ihost(scic);
        struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
 
        isci_remote_device_not_ready(ihost, idev,
@@ -947,7 +944,8 @@ static void scic_sds_remote_device_ready_state_enter(void *object)
 {
        struct scic_sds_remote_device *sci_dev = object;
        struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller;
-       struct domain_device *dev = sci_dev_to_domain(sci_dev);
+       struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
+       struct domain_device *dev = idev->domain_dev;
 
        scic->remote_device_sequence[sci_dev->rnc.remote_node_index]++;
 
@@ -958,7 +956,7 @@ static void scic_sds_remote_device_ready_state_enter(void *object)
                sci_base_state_machine_change_state(&sci_dev->state_machine,
                                                    SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
        } else
-               isci_remote_device_ready(scic->ihost, sci_dev_to_idev(sci_dev));
+               isci_remote_device_ready(scic_to_ihost(scic), idev);
 }
 
 static void scic_sds_remote_device_ready_state_exit(void *object)
@@ -970,7 +968,7 @@ static void scic_sds_remote_device_ready_state_exit(void *object)
                struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller;
                struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
 
-               isci_remote_device_not_ready(scic->ihost, idev,
+               isci_remote_device_not_ready(scic_to_ihost(scic), idev,
                                             SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED);
        }
 }
@@ -1014,7 +1012,7 @@ static void scic_sds_stp_remote_device_ready_cmd_substate_enter(void *object)
 
        BUG_ON(sci_dev->working_request == NULL);
 
-       isci_remote_device_not_ready(scic->ihost, sci_dev_to_idev(sci_dev),
+       isci_remote_device_not_ready(scic_to_ihost(scic), sci_dev_to_idev(sci_dev),
                                     SCIC_REMOTE_DEVICE_NOT_READY_SATA_REQUEST_STARTED);
 }
 
@@ -1025,7 +1023,7 @@ static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(void *obje
        struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
 
        if (sci_dev->not_ready_reason == SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED)
-               isci_remote_device_not_ready(scic->ihost, idev,
+               isci_remote_device_not_ready(scic_to_ihost(scic), idev,
                                             sci_dev->not_ready_reason);
 }
 
@@ -1034,7 +1032,7 @@ static void scic_sds_smp_remote_device_ready_idle_substate_enter(void *object)
        struct scic_sds_remote_device *sci_dev = object;
        struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
 
-       isci_remote_device_ready(scic->ihost, sci_dev_to_idev(sci_dev));
+       isci_remote_device_ready(scic_to_ihost(scic), sci_dev_to_idev(sci_dev));
 }
 
 static void scic_sds_smp_remote_device_ready_cmd_substate_enter(void *object)
@@ -1044,7 +1042,7 @@ static void scic_sds_smp_remote_device_ready_cmd_substate_enter(void *object)
 
        BUG_ON(sci_dev->working_request == NULL);
 
-       isci_remote_device_not_ready(scic->ihost, sci_dev_to_idev(sci_dev),
+       isci_remote_device_not_ready(scic_to_ihost(scic), sci_dev_to_idev(sci_dev),
                                     SCIC_REMOTE_DEVICE_NOT_READY_SMP_REQUEST_STARTED);
 }
 
@@ -1263,7 +1261,7 @@ static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *s
 static enum sci_status isci_remote_device_construct(struct isci_port *iport,
                                                    struct isci_remote_device *idev)
 {
-       struct scic_sds_port *sci_port = iport->sci_port_handle;
+       struct scic_sds_port *sci_port = &iport->sci;
        struct isci_host *ihost = iport->isci_host;
        struct domain_device *dev = idev->domain_dev;
        enum sci_status status;