diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-28 19:44:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-28 19:44:18 -0400 |
commit | ec7ae517537ae5c7b0b2cd7f562dfa3e7a05b954 (patch) | |
tree | e6b0c64a51a7c0aa0efd09d4f7a80872e3b1657a /drivers/scsi/isci | |
parent | 97d2eb13a019ec09cc1a7ea2d3705c0b117b3c0d (diff) | |
parent | 590134fa78fbdbe5fea78c7ae0b2c3364bc9572f (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi-misc-2.6: (204 commits)
[SCSI] qla4xxx: export address/port of connection (fix udev disk names)
[SCSI] ipr: Fix BUG on adapter dump timeout
[SCSI] megaraid_sas: Fix instance access in megasas_reset_timer
[SCSI] hpsa: change confusing message to be more clear
[SCSI] iscsi class: fix vlan configuration
[SCSI] qla4xxx: fix data alignment and use nl helpers
[SCSI] iscsi class: fix link local mispelling
[SCSI] iscsi class: Replace iscsi_get_next_target_id with IDA
[SCSI] aacraid: use lower snprintf() limit
[SCSI] lpfc 8.3.27: Change driver version to 8.3.27
[SCSI] lpfc 8.3.27: T10 additions for SLI4
[SCSI] lpfc 8.3.27: Fix queue allocation failure recovery
[SCSI] lpfc 8.3.27: Change algorithm for getting physical port name
[SCSI] lpfc 8.3.27: Changed worst case mailbox timeout
[SCSI] lpfc 8.3.27: Miscellanous logic and interface fixes
[SCSI] megaraid_sas: Changelog and version update
[SCSI] megaraid_sas: Add driver workaround for PERC5/1068 kdump kernel panic
[SCSI] megaraid_sas: Add multiple MSI-X vector/multiple reply queue support
[SCSI] megaraid_sas: Add support for MegaRAID 9360/9380 12GB/s controllers
[SCSI] megaraid_sas: Clear FUSION_IN_RESET before enabling interrupts
...
Diffstat (limited to 'drivers/scsi/isci')
-rw-r--r-- | drivers/scsi/isci/host.c | 69 | ||||
-rw-r--r-- | drivers/scsi/isci/host.h | 15 | ||||
-rw-r--r-- | drivers/scsi/isci/init.c | 3 | ||||
-rw-r--r-- | drivers/scsi/isci/isci.h | 2 | ||||
-rw-r--r-- | drivers/scsi/isci/phy.c | 11 | ||||
-rw-r--r-- | drivers/scsi/isci/port.c | 2 | ||||
-rw-r--r-- | drivers/scsi/isci/port_config.c | 2 | ||||
-rw-r--r-- | drivers/scsi/isci/registers.h | 122 | ||||
-rw-r--r-- | drivers/scsi/isci/remote_device.c | 24 | ||||
-rw-r--r-- | drivers/scsi/isci/remote_device.h | 9 | ||||
-rw-r--r-- | drivers/scsi/isci/request.c | 380 | ||||
-rw-r--r-- | drivers/scsi/isci/request.h | 31 | ||||
-rw-r--r-- | drivers/scsi/isci/sas.h | 2 | ||||
-rw-r--r-- | drivers/scsi/isci/task.c | 29 | ||||
-rw-r--r-- | drivers/scsi/isci/task.h | 19 |
15 files changed, 522 insertions, 198 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index 6981b773a88d..f07f30fada1b 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c | |||
@@ -1263,6 +1263,10 @@ void isci_host_deinit(struct isci_host *ihost) | |||
1263 | { | 1263 | { |
1264 | int i; | 1264 | int i; |
1265 | 1265 | ||
1266 | /* disable output data selects */ | ||
1267 | for (i = 0; i < isci_gpio_count(ihost); i++) | ||
1268 | writel(SGPIO_HW_CONTROL, &ihost->scu_registers->peg0.sgpio.output_data_select[i]); | ||
1269 | |||
1266 | isci_host_change_state(ihost, isci_stopping); | 1270 | isci_host_change_state(ihost, isci_stopping); |
1267 | for (i = 0; i < SCI_MAX_PORTS; i++) { | 1271 | for (i = 0; i < SCI_MAX_PORTS; i++) { |
1268 | struct isci_port *iport = &ihost->ports[i]; | 1272 | struct isci_port *iport = &ihost->ports[i]; |
@@ -1281,6 +1285,12 @@ void isci_host_deinit(struct isci_host *ihost) | |||
1281 | spin_unlock_irq(&ihost->scic_lock); | 1285 | spin_unlock_irq(&ihost->scic_lock); |
1282 | 1286 | ||
1283 | wait_for_stop(ihost); | 1287 | wait_for_stop(ihost); |
1288 | |||
1289 | /* disable sgpio: where the above wait should give time for the | ||
1290 | * enclosure to sample the gpios going inactive | ||
1291 | */ | ||
1292 | writel(0, &ihost->scu_registers->peg0.sgpio.interface_control); | ||
1293 | |||
1284 | sci_controller_reset(ihost); | 1294 | sci_controller_reset(ihost); |
1285 | 1295 | ||
1286 | /* Cancel any/all outstanding port timers */ | 1296 | /* Cancel any/all outstanding port timers */ |
@@ -2365,6 +2375,12 @@ int isci_host_init(struct isci_host *ihost) | |||
2365 | for (i = 0; i < SCI_MAX_PHYS; i++) | 2375 | for (i = 0; i < SCI_MAX_PHYS; i++) |
2366 | isci_phy_init(&ihost->phys[i], ihost, i); | 2376 | isci_phy_init(&ihost->phys[i], ihost, i); |
2367 | 2377 | ||
2378 | /* enable sgpio */ | ||
2379 | writel(1, &ihost->scu_registers->peg0.sgpio.interface_control); | ||
2380 | for (i = 0; i < isci_gpio_count(ihost); i++) | ||
2381 | writel(SGPIO_HW_CONTROL, &ihost->scu_registers->peg0.sgpio.output_data_select[i]); | ||
2382 | writel(0, &ihost->scu_registers->peg0.sgpio.vendor_specific_code); | ||
2383 | |||
2368 | for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) { | 2384 | for (i = 0; i < SCI_MAX_REMOTE_DEVICES; i++) { |
2369 | struct isci_remote_device *idev = &ihost->devices[i]; | 2385 | struct isci_remote_device *idev = &ihost->devices[i]; |
2370 | 2386 | ||
@@ -2760,3 +2776,56 @@ enum sci_task_status sci_controller_start_task(struct isci_host *ihost, | |||
2760 | 2776 | ||
2761 | return status; | 2777 | return status; |
2762 | } | 2778 | } |
2779 | |||
2780 | static int sci_write_gpio_tx_gp(struct isci_host *ihost, u8 reg_index, u8 reg_count, u8 *write_data) | ||
2781 | { | ||
2782 | int d; | ||
2783 | |||
2784 | /* no support for TX_GP_CFG */ | ||
2785 | if (reg_index == 0) | ||
2786 | return -EINVAL; | ||
2787 | |||
2788 | for (d = 0; d < isci_gpio_count(ihost); d++) { | ||
2789 | u32 val = 0x444; /* all ODx.n clear */ | ||
2790 | int i; | ||
2791 | |||
2792 | for (i = 0; i < 3; i++) { | ||
2793 | int bit = (i << 2) + 2; | ||
2794 | |||
2795 | bit = try_test_sas_gpio_gp_bit(to_sas_gpio_od(d, i), | ||
2796 | write_data, reg_index, | ||
2797 | reg_count); | ||
2798 | if (bit < 0) | ||
2799 | break; | ||
2800 | |||
2801 | /* if od is set, clear the 'invert' bit */ | ||
2802 | val &= ~(bit << ((i << 2) + 2)); | ||
2803 | } | ||
2804 | |||
2805 | if (i < 3) | ||
2806 | break; | ||
2807 | writel(val, &ihost->scu_registers->peg0.sgpio.output_data_select[d]); | ||
2808 | } | ||
2809 | |||
2810 | /* unless reg_index is > 1, we should always be able to write at | ||
2811 | * least one register | ||
2812 | */ | ||
2813 | return d > 0; | ||
2814 | } | ||
2815 | |||
2816 | int isci_gpio_write(struct sas_ha_struct *sas_ha, u8 reg_type, u8 reg_index, | ||
2817 | u8 reg_count, u8 *write_data) | ||
2818 | { | ||
2819 | struct isci_host *ihost = sas_ha->lldd_ha; | ||
2820 | int written; | ||
2821 | |||
2822 | switch (reg_type) { | ||
2823 | case SAS_GPIO_REG_TX_GP: | ||
2824 | written = sci_write_gpio_tx_gp(ihost, reg_index, reg_count, write_data); | ||
2825 | break; | ||
2826 | default: | ||
2827 | written = -EINVAL; | ||
2828 | } | ||
2829 | |||
2830 | return written; | ||
2831 | } | ||
diff --git a/drivers/scsi/isci/host.h b/drivers/scsi/isci/host.h index 9f33831a2f04..646051afd3cb 100644 --- a/drivers/scsi/isci/host.h +++ b/drivers/scsi/isci/host.h | |||
@@ -440,6 +440,18 @@ static inline bool is_c0(struct pci_dev *pdev) | |||
440 | return false; | 440 | return false; |
441 | } | 441 | } |
442 | 442 | ||
443 | /* set hw control for 'activity', even though active enclosures seem to drive | ||
444 | * the activity led on their own. Skip setting FSENG control on 'status' due | ||
445 | * to unexpected operation and 'error' due to not being a supported automatic | ||
446 | * FSENG output | ||
447 | */ | ||
448 | #define SGPIO_HW_CONTROL 0x00000443 | ||
449 | |||
450 | static inline int isci_gpio_count(struct isci_host *ihost) | ||
451 | { | ||
452 | return ARRAY_SIZE(ihost->scu_registers->peg0.sgpio.output_data_select); | ||
453 | } | ||
454 | |||
443 | void sci_controller_post_request(struct isci_host *ihost, | 455 | void sci_controller_post_request(struct isci_host *ihost, |
444 | u32 request); | 456 | u32 request); |
445 | void sci_controller_release_frame(struct isci_host *ihost, | 457 | void sci_controller_release_frame(struct isci_host *ihost, |
@@ -542,4 +554,7 @@ void sci_port_configuration_agent_construct( | |||
542 | enum sci_status sci_port_configuration_agent_initialize( | 554 | enum sci_status sci_port_configuration_agent_initialize( |
543 | struct isci_host *ihost, | 555 | struct isci_host *ihost, |
544 | struct sci_port_configuration_agent *port_agent); | 556 | struct sci_port_configuration_agent *port_agent); |
557 | |||
558 | int isci_gpio_write(struct sas_ha_struct *, u8 reg_type, u8 reg_index, | ||
559 | u8 reg_count, u8 *write_data); | ||
545 | #endif | 560 | #endif |
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index 29aa34efb0f5..43fe840fbe9c 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c | |||
@@ -192,6 +192,9 @@ static struct sas_domain_function_template isci_transport_ops = { | |||
192 | 192 | ||
193 | /* Phy management */ | 193 | /* Phy management */ |
194 | .lldd_control_phy = isci_phy_control, | 194 | .lldd_control_phy = isci_phy_control, |
195 | |||
196 | /* GPIO support */ | ||
197 | .lldd_write_gpio = isci_gpio_write, | ||
195 | }; | 198 | }; |
196 | 199 | ||
197 | 200 | ||
diff --git a/drivers/scsi/isci/isci.h b/drivers/scsi/isci/isci.h index d1de63312e7f..8efeb6b08321 100644 --- a/drivers/scsi/isci/isci.h +++ b/drivers/scsi/isci/isci.h | |||
@@ -97,7 +97,7 @@ | |||
97 | #define SCU_MAX_COMPLETION_QUEUE_SHIFT (ilog2(SCU_MAX_COMPLETION_QUEUE_ENTRIES)) | 97 | #define SCU_MAX_COMPLETION_QUEUE_SHIFT (ilog2(SCU_MAX_COMPLETION_QUEUE_ENTRIES)) |
98 | 98 | ||
99 | #define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096) | 99 | #define SCU_ABSOLUTE_MAX_UNSOLICITED_FRAMES (4096) |
100 | #define SCU_UNSOLICITED_FRAME_BUFFER_SIZE (1024) | 100 | #define SCU_UNSOLICITED_FRAME_BUFFER_SIZE (1024U) |
101 | #define SCU_INVALID_FRAME_INDEX (0xFFFF) | 101 | #define SCU_INVALID_FRAME_INDEX (0xFFFF) |
102 | 102 | ||
103 | #define SCU_IO_REQUEST_MAX_SGE_SIZE (0x00FFFFFF) | 103 | #define SCU_IO_REQUEST_MAX_SGE_SIZE (0x00FFFFFF) |
diff --git a/drivers/scsi/isci/phy.c b/drivers/scsi/isci/phy.c index 09e61134037f..35f50c2183e1 100644 --- a/drivers/scsi/isci/phy.c +++ b/drivers/scsi/isci/phy.c | |||
@@ -1313,6 +1313,17 @@ int isci_phy_control(struct asd_sas_phy *sas_phy, | |||
1313 | ret = isci_port_perform_hard_reset(ihost, iport, iphy); | 1313 | ret = isci_port_perform_hard_reset(ihost, iport, iphy); |
1314 | 1314 | ||
1315 | break; | 1315 | break; |
1316 | case PHY_FUNC_GET_EVENTS: { | ||
1317 | struct scu_link_layer_registers __iomem *r; | ||
1318 | struct sas_phy *phy = sas_phy->phy; | ||
1319 | |||
1320 | r = iphy->link_layer_registers; | ||
1321 | phy->running_disparity_error_count = readl(&r->running_disparity_error_count); | ||
1322 | phy->loss_of_dword_sync_count = readl(&r->loss_of_sync_error_count); | ||
1323 | phy->phy_reset_problem_count = readl(&r->phy_reset_problem_count); | ||
1324 | phy->invalid_dword_count = readl(&r->invalid_dword_counter); | ||
1325 | break; | ||
1326 | } | ||
1316 | 1327 | ||
1317 | default: | 1328 | default: |
1318 | dev_dbg(&ihost->pdev->dev, | 1329 | dev_dbg(&ihost->pdev->dev, |
diff --git a/drivers/scsi/isci/port.c b/drivers/scsi/isci/port.c index 8f6f9b77e41a..8e59c8865dcd 100644 --- a/drivers/scsi/isci/port.c +++ b/drivers/scsi/isci/port.c | |||
@@ -294,8 +294,8 @@ static void isci_port_link_down(struct isci_host *isci_host, | |||
294 | __func__, isci_device); | 294 | __func__, isci_device); |
295 | set_bit(IDEV_GONE, &isci_device->flags); | 295 | set_bit(IDEV_GONE, &isci_device->flags); |
296 | } | 296 | } |
297 | isci_port_change_state(isci_port, isci_stopping); | ||
297 | } | 298 | } |
298 | isci_port_change_state(isci_port, isci_stopping); | ||
299 | } | 299 | } |
300 | 300 | ||
301 | /* Notify libsas of the borken link, this will trigger calls to our | 301 | /* Notify libsas of the borken link, this will trigger calls to our |
diff --git a/drivers/scsi/isci/port_config.c b/drivers/scsi/isci/port_config.c index 486b113c634a..38a99d281141 100644 --- a/drivers/scsi/isci/port_config.c +++ b/drivers/scsi/isci/port_config.c | |||
@@ -678,7 +678,7 @@ static void apc_agent_timeout(unsigned long data) | |||
678 | configure_phy_mask = ~port_agent->phy_configured_mask & port_agent->phy_ready_mask; | 678 | configure_phy_mask = ~port_agent->phy_configured_mask & port_agent->phy_ready_mask; |
679 | 679 | ||
680 | if (!configure_phy_mask) | 680 | if (!configure_phy_mask) |
681 | return; | 681 | goto done; |
682 | 682 | ||
683 | for (index = 0; index < SCI_MAX_PHYS; index++) { | 683 | for (index = 0; index < SCI_MAX_PHYS; index++) { |
684 | if ((configure_phy_mask & (1 << index)) == 0) | 684 | if ((configure_phy_mask & (1 << index)) == 0) |
diff --git a/drivers/scsi/isci/registers.h b/drivers/scsi/isci/registers.h index 00afc738bbed..eaa541afc755 100644 --- a/drivers/scsi/isci/registers.h +++ b/drivers/scsi/isci/registers.h | |||
@@ -875,122 +875,6 @@ struct scu_iit_entry { | |||
875 | #define SCU_PTSxSR_GEN_BIT(name) \ | 875 | #define SCU_PTSxSR_GEN_BIT(name) \ |
876 | SCU_GEN_BIT(SCU_PTSG_PORT_TASK_SCHEDULER_STATUS_ ## name) | 876 | SCU_GEN_BIT(SCU_PTSG_PORT_TASK_SCHEDULER_STATUS_ ## name) |
877 | 877 | ||
878 | |||
879 | /* | ||
880 | * ***************************************************************************** | ||
881 | * * SGPIO Register shift and mask values | ||
882 | * ***************************************************************************** */ | ||
883 | #define SCU_SGPIO_CONTROL_SGPIO_ENABLE_SHIFT (0) | ||
884 | #define SCU_SGPIO_CONTROL_SGPIO_ENABLE_MASK (0x00000001) | ||
885 | #define SCU_SGPIO_CONTROL_SGPIO_SERIAL_CLOCK_SELECT_SHIFT (1) | ||
886 | #define SCU_SGPIO_CONTROL_SGPIO_SERIAL_CLOCK_SELECT_MASK (0x00000002) | ||
887 | #define SCU_SGPIO_CONTROL_SGPIO_SERIAL_SHIFT_WIDTH_SELECT_SHIFT (2) | ||
888 | #define SCU_SGPIO_CONTROL_SGPIO_SERIAL_SHIFT_WIDTH_SELECT_MASK (0x00000004) | ||
889 | #define SCU_SGPIO_CONTROL_SGPIO_TEST_BIT_SHIFT (15) | ||
890 | #define SCU_SGPIO_CONTROL_SGPIO_TEST_BIT_MASK (0x00008000) | ||
891 | #define SCU_SGPIO_CONTROL_SGPIO_RESERVED_MASK (0xFFFF7FF8) | ||
892 | |||
893 | #define SCU_SGICRx_GEN_BIT(name) \ | ||
894 | SCU_GEN_BIT(SCU_SGPIO_CONTROL_SGPIO_ ## name) | ||
895 | |||
896 | #define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R0_SHIFT (0) | ||
897 | #define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R0_MASK (0x0000000F) | ||
898 | #define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R1_SHIFT (4) | ||
899 | #define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R1_MASK (0x000000F0) | ||
900 | #define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R2_SHIFT (8) | ||
901 | #define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R2_MASK (0x00000F00) | ||
902 | #define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R3_SHIFT (12) | ||
903 | #define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_R3_MASK (0x0000F000) | ||
904 | #define SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_RESERVED_MASK (0xFFFF0000) | ||
905 | |||
906 | #define SCU_SGPBRx_GEN_VAL(name, value) \ | ||
907 | SCU_GEN_VALUE(SCU_SGPIO_PROGRAMMABLE_BLINK_REGISTER_ ## name, value) | ||
908 | |||
909 | #define SCU_SGPIO_START_DRIVE_LOWER_R0_SHIFT (0) | ||
910 | #define SCU_SGPIO_START_DRIVE_LOWER_R0_MASK (0x00000003) | ||
911 | #define SCU_SGPIO_START_DRIVE_LOWER_R1_SHIFT (4) | ||
912 | #define SCU_SGPIO_START_DRIVE_LOWER_R1_MASK (0x00000030) | ||
913 | #define SCU_SGPIO_START_DRIVE_LOWER_R2_SHIFT (8) | ||
914 | #define SCU_SGPIO_START_DRIVE_LOWER_R2_MASK (0x00000300) | ||
915 | #define SCU_SGPIO_START_DRIVE_LOWER_R3_SHIFT (12) | ||
916 | #define SCU_SGPIO_START_DRIVE_LOWER_R3_MASK (0x00003000) | ||
917 | #define SCU_SGPIO_START_DRIVE_LOWER_RESERVED_MASK (0xFFFF8888) | ||
918 | |||
919 | #define SCU_SGSDLRx_GEN_VAL(name, value) \ | ||
920 | SCU_GEN_VALUE(SCU_SGPIO_START_DRIVE_LOWER_ ## name, value) | ||
921 | |||
922 | #define SCU_SGPIO_START_DRIVE_UPPER_R0_SHIFT (0) | ||
923 | #define SCU_SGPIO_START_DRIVE_UPPER_R0_MASK (0x00000003) | ||
924 | #define SCU_SGPIO_START_DRIVE_UPPER_R1_SHIFT (4) | ||
925 | #define SCU_SGPIO_START_DRIVE_UPPER_R1_MASK (0x00000030) | ||
926 | #define SCU_SGPIO_START_DRIVE_UPPER_R2_SHIFT (8) | ||
927 | #define SCU_SGPIO_START_DRIVE_UPPER_R2_MASK (0x00000300) | ||
928 | #define SCU_SGPIO_START_DRIVE_UPPER_R3_SHIFT (12) | ||
929 | #define SCU_SGPIO_START_DRIVE_UPPER_R3_MASK (0x00003000) | ||
930 | #define SCU_SGPIO_START_DRIVE_UPPER_RESERVED_MASK (0xFFFF8888) | ||
931 | |||
932 | #define SCU_SGSDURx_GEN_VAL(name, value) \ | ||
933 | SCU_GEN_VALUE(SCU_SGPIO_START_DRIVE_LOWER_ ## name, value) | ||
934 | |||
935 | #define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D0_SHIFT (0) | ||
936 | #define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D0_MASK (0x00000003) | ||
937 | #define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D1_SHIFT (4) | ||
938 | #define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D1_MASK (0x00000030) | ||
939 | #define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D2_SHIFT (8) | ||
940 | #define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D2_MASK (0x00000300) | ||
941 | #define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D3_SHIFT (12) | ||
942 | #define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_D3_MASK (0x00003000) | ||
943 | #define SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_RESERVED_MASK (0xFFFF8888) | ||
944 | |||
945 | #define SCU_SGSIDLRx_GEN_VAL(name, value) \ | ||
946 | SCU_GEN_VALUE(SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_ ## name, value) | ||
947 | |||
948 | #define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D0_SHIFT (0) | ||
949 | #define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D0_MASK (0x00000003) | ||
950 | #define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D1_SHIFT (4) | ||
951 | #define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D1_MASK (0x00000030) | ||
952 | #define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D2_SHIFT (8) | ||
953 | #define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D2_MASK (0x00000300) | ||
954 | #define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D3_SHIFT (12) | ||
955 | #define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_D3_MASK (0x00003000) | ||
956 | #define SCU_SGPIO_SERIAL_INPUT_DATA_UPPER_RESERVED_MASK (0xFFFF8888) | ||
957 | |||
958 | #define SCU_SGSIDURx_GEN_VAL(name, value) \ | ||
959 | SCU_GEN_VALUE(SCU_SGPIO_SERIAL_INPUT_DATA_LOWER_ ## name, value) | ||
960 | |||
961 | #define SCU_SGPIO_VENDOR_SPECIFIC_CODE_SHIFT (0) | ||
962 | #define SCU_SGPIO_VENDOR_SPECIFIC_CODE_MASK (0x0000000F) | ||
963 | #define SCU_SGPIO_VENDOR_SPECIFIC_CODE_RESERVED_MASK (0xFFFFFFF0) | ||
964 | |||
965 | #define SCU_SGVSCR_GEN_VAL(value) \ | ||
966 | SCU_GEN_VALUE(SCU_SGPIO_VENDOR_SPECIFIC_CODE ## name, value) | ||
967 | |||
968 | #define SCU_SGPIO_OUPUT_DATA_SELECT_INPUT_DATA0_SHIFT (0) | ||
969 | #define SCU_SGPIO_OUPUT_DATA_SELECT_INPUT_DATA0_MASK (0x00000003) | ||
970 | #define SCU_SGPIO_OUPUT_DATA_SELECT_INVERT_INPUT_DATA0_SHIFT (2) | ||
971 | #define SCU_SGPIO_OUPUT_DATA_SELECT_INVERT_INPUT_DATA0_MASK (0x00000004) | ||
972 | #define SCU_SGPIO_OUPUT_DATA_SELECT_JOG_ENABLE_DATA0_SHIFT (3) | ||
973 | #define SCU_SGPIO_OUPUT_DATA_SELECT_JOG_ENABLE_DATA0_MASK (0x00000008) | ||
974 | #define SCU_SGPIO_OUPUT_DATA_SELECT_INPUT_DATA1_SHIFT (4) | ||
975 | #define SCU_SGPIO_OUPUT_DATA_SELECT_INPUT_DATA1_MASK (0x00000030) | ||
976 | #define SCU_SGPIO_OUPUT_DATA_SELECT_INVERT_INPUT_DATA1_SHIFT (6) | ||
977 | #define SCU_SGPIO_OUPUT_DATA_SELECT_INVERT_INPUT_DATA1_MASK (0x00000040) | ||
978 | #define SCU_SGPIO_OUPUT_DATA_SELECT_JOG_ENABLE_DATA1_SHIFT (7) | ||
979 | #define SCU_SGPIO_OUPUT_DATA_SELECT_JOG_ENABLE_DATA1_MASK (0x00000080) | ||
980 | #define SCU_SGPIO_OUPUT_DATA_SELECT_INPUT_DATA2_SHIFT (8) | ||
981 | #define SCU_SGPIO_OUPUT_DATA_SELECT_INPUT_DATA2_MASK (0x00000300) | ||
982 | #define SCU_SGPIO_OUPUT_DATA_SELECT_INVERT_INPUT_DATA2_SHIFT (10) | ||
983 | #define SCU_SGPIO_OUPUT_DATA_SELECT_INVERT_INPUT_DATA2_MASK (0x00000400) | ||
984 | #define SCU_SGPIO_OUPUT_DATA_SELECT_JOG_ENABLE_DATA2_SHIFT (11) | ||
985 | #define SCU_SGPIO_OUPUT_DATA_SELECT_JOG_ENABLE_DATA2_MASK (0x00000800) | ||
986 | #define SCU_SGPIO_OUPUT_DATA_SELECT_RESERVED_MASK (0xFFFFF000) | ||
987 | |||
988 | #define SCU_SGODSR_GEN_VAL(name, value) \ | ||
989 | SCU_GEN_VALUE(SCU_SGPIO_OUPUT_DATA_SELECT_ ## name, value) | ||
990 | |||
991 | #define SCU_SGODSR_GEN_BIT(name) \ | ||
992 | SCU_GEN_BIT(SCU_SGPIO_OUPUT_DATA_SELECT_ ## name) | ||
993 | |||
994 | /* | 878 | /* |
995 | * ***************************************************************************** | 879 | * ***************************************************************************** |
996 | * * SMU Registers | 880 | * * SMU Registers |
@@ -1529,10 +1413,12 @@ struct scu_sgpio_registers { | |||
1529 | u32 serial_input_upper; | 1413 | u32 serial_input_upper; |
1530 | /* 0x0018 SGPIO_SGVSCR */ | 1414 | /* 0x0018 SGPIO_SGVSCR */ |
1531 | u32 vendor_specific_code; | 1415 | u32 vendor_specific_code; |
1416 | /* 0x001C Reserved */ | ||
1417 | u32 reserved_001c; | ||
1532 | /* 0x0020 SGPIO_SGODSR */ | 1418 | /* 0x0020 SGPIO_SGODSR */ |
1533 | u32 ouput_data_select[8]; | 1419 | u32 output_data_select[8]; |
1534 | /* Remainder of memory space 256 bytes */ | 1420 | /* Remainder of memory space 256 bytes */ |
1535 | u32 reserved_1444_14ff[0x31]; | 1421 | u32 reserved_1444_14ff[0x30]; |
1536 | 1422 | ||
1537 | }; | 1423 | }; |
1538 | 1424 | ||
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c index b6e6368c2665..fbf9ce28c3f5 100644 --- a/drivers/scsi/isci/remote_device.c +++ b/drivers/scsi/isci/remote_device.c | |||
@@ -386,6 +386,18 @@ static bool is_remote_device_ready(struct isci_remote_device *idev) | |||
386 | } | 386 | } |
387 | } | 387 | } |
388 | 388 | ||
389 | /* | ||
390 | * called once the remote node context has transisitioned to a ready | ||
391 | * state (after suspending RX and/or TX due to early D2H fis) | ||
392 | */ | ||
393 | static void atapi_remote_device_resume_done(void *_dev) | ||
394 | { | ||
395 | struct isci_remote_device *idev = _dev; | ||
396 | struct isci_request *ireq = idev->working_request; | ||
397 | |||
398 | sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); | ||
399 | } | ||
400 | |||
389 | enum sci_status sci_remote_device_event_handler(struct isci_remote_device *idev, | 401 | enum sci_status sci_remote_device_event_handler(struct isci_remote_device *idev, |
390 | u32 event_code) | 402 | u32 event_code) |
391 | { | 403 | { |
@@ -432,6 +444,16 @@ enum sci_status sci_remote_device_event_handler(struct isci_remote_device *idev, | |||
432 | if (status != SCI_SUCCESS) | 444 | if (status != SCI_SUCCESS) |
433 | return status; | 445 | return status; |
434 | 446 | ||
447 | if (state == SCI_STP_DEV_ATAPI_ERROR) { | ||
448 | /* For ATAPI error state resume the RNC right away. */ | ||
449 | if (scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX || | ||
450 | scu_get_event_type(event_code) == SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX) { | ||
451 | return sci_remote_node_context_resume(&idev->rnc, | ||
452 | atapi_remote_device_resume_done, | ||
453 | idev); | ||
454 | } | ||
455 | } | ||
456 | |||
435 | if (state == SCI_STP_DEV_IDLE) { | 457 | if (state == SCI_STP_DEV_IDLE) { |
436 | 458 | ||
437 | /* We pick up suspension events to handle specifically to this | 459 | /* We pick up suspension events to handle specifically to this |
@@ -625,6 +647,7 @@ enum sci_status sci_remote_device_complete_io(struct isci_host *ihost, | |||
625 | case SCI_STP_DEV_CMD: | 647 | case SCI_STP_DEV_CMD: |
626 | case SCI_STP_DEV_NCQ: | 648 | case SCI_STP_DEV_NCQ: |
627 | case SCI_STP_DEV_NCQ_ERROR: | 649 | case SCI_STP_DEV_NCQ_ERROR: |
650 | case SCI_STP_DEV_ATAPI_ERROR: | ||
628 | status = common_complete_io(iport, idev, ireq); | 651 | status = common_complete_io(iport, idev, ireq); |
629 | if (status != SCI_SUCCESS) | 652 | if (status != SCI_SUCCESS) |
630 | break; | 653 | break; |
@@ -1020,6 +1043,7 @@ static const struct sci_base_state sci_remote_device_state_table[] = { | |||
1020 | [SCI_STP_DEV_NCQ_ERROR] = { | 1043 | [SCI_STP_DEV_NCQ_ERROR] = { |
1021 | .enter_state = sci_stp_remote_device_ready_ncq_error_substate_enter, | 1044 | .enter_state = sci_stp_remote_device_ready_ncq_error_substate_enter, |
1022 | }, | 1045 | }, |
1046 | [SCI_STP_DEV_ATAPI_ERROR] = { }, | ||
1023 | [SCI_STP_DEV_AWAIT_RESET] = { }, | 1047 | [SCI_STP_DEV_AWAIT_RESET] = { }, |
1024 | [SCI_SMP_DEV_IDLE] = { | 1048 | [SCI_SMP_DEV_IDLE] = { |
1025 | .enter_state = sci_smp_remote_device_ready_idle_substate_enter, | 1049 | .enter_state = sci_smp_remote_device_ready_idle_substate_enter, |
diff --git a/drivers/scsi/isci/remote_device.h b/drivers/scsi/isci/remote_device.h index 57ccfc3d6ad3..e1747ea0d0ea 100644 --- a/drivers/scsi/isci/remote_device.h +++ b/drivers/scsi/isci/remote_device.h | |||
@@ -244,6 +244,15 @@ enum sci_remote_device_states { | |||
244 | SCI_STP_DEV_NCQ_ERROR, | 244 | SCI_STP_DEV_NCQ_ERROR, |
245 | 245 | ||
246 | /** | 246 | /** |
247 | * This is the ATAPI error state for the STP ATAPI remote device. | ||
248 | * This state is entered when ATAPI device sends error status FIS | ||
249 | * without data while the device object is in CMD state. | ||
250 | * A suspension event is expected in this state. | ||
251 | * The device object will resume right away. | ||
252 | */ | ||
253 | SCI_STP_DEV_ATAPI_ERROR, | ||
254 | |||
255 | /** | ||
247 | * This is the READY substate indicates the device is waiting for the RESET task | 256 | * This is the READY substate indicates the device is waiting for the RESET task |
248 | * coming to be recovered from certain hardware specific error. | 257 | * coming to be recovered from certain hardware specific error. |
249 | */ | 258 | */ |
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c index b5d3a8c4d329..565a9f0a9bc2 100644 --- a/drivers/scsi/isci/request.c +++ b/drivers/scsi/isci/request.c | |||
@@ -481,7 +481,29 @@ static void sci_stp_optimized_request_construct(struct isci_request *ireq, | |||
481 | } | 481 | } |
482 | } | 482 | } |
483 | 483 | ||
484 | static void sci_atapi_construct(struct isci_request *ireq) | ||
485 | { | ||
486 | struct host_to_dev_fis *h2d_fis = &ireq->stp.cmd; | ||
487 | struct sas_task *task; | ||
488 | |||
489 | /* To simplify the implementation we take advantage of the | ||
490 | * silicon's partial acceleration of atapi protocol (dma data | ||
491 | * transfers), so we promote all commands to dma protocol. This | ||
492 | * breaks compatibility with ATA_HORKAGE_ATAPI_MOD16_DMA drives. | ||
493 | */ | ||
494 | h2d_fis->features |= ATAPI_PKT_DMA; | ||
484 | 495 | ||
496 | scu_stp_raw_request_construct_task_context(ireq); | ||
497 | |||
498 | task = isci_request_access_task(ireq); | ||
499 | if (task->data_dir == DMA_NONE) | ||
500 | task->total_xfer_len = 0; | ||
501 | |||
502 | /* clear the response so we can detect arrivial of an | ||
503 | * unsolicited h2d fis | ||
504 | */ | ||
505 | ireq->stp.rsp.fis_type = 0; | ||
506 | } | ||
485 | 507 | ||
486 | static enum sci_status | 508 | static enum sci_status |
487 | sci_io_request_construct_sata(struct isci_request *ireq, | 509 | sci_io_request_construct_sata(struct isci_request *ireq, |
@@ -491,6 +513,7 @@ sci_io_request_construct_sata(struct isci_request *ireq, | |||
491 | { | 513 | { |
492 | enum sci_status status = SCI_SUCCESS; | 514 | enum sci_status status = SCI_SUCCESS; |
493 | struct sas_task *task = isci_request_access_task(ireq); | 515 | struct sas_task *task = isci_request_access_task(ireq); |
516 | struct domain_device *dev = ireq->target_device->domain_dev; | ||
494 | 517 | ||
495 | /* check for management protocols */ | 518 | /* check for management protocols */ |
496 | if (ireq->ttype == tmf_task) { | 519 | if (ireq->ttype == tmf_task) { |
@@ -519,6 +542,13 @@ sci_io_request_construct_sata(struct isci_request *ireq, | |||
519 | 542 | ||
520 | } | 543 | } |
521 | 544 | ||
545 | /* ATAPI */ | ||
546 | if (dev->sata_dev.command_set == ATAPI_COMMAND_SET && | ||
547 | task->ata_task.fis.command == ATA_CMD_PACKET) { | ||
548 | sci_atapi_construct(ireq); | ||
549 | return SCI_SUCCESS; | ||
550 | } | ||
551 | |||
522 | /* non data */ | 552 | /* non data */ |
523 | if (task->data_dir == DMA_NONE) { | 553 | if (task->data_dir == DMA_NONE) { |
524 | scu_stp_raw_request_construct_task_context(ireq); | 554 | scu_stp_raw_request_construct_task_context(ireq); |
@@ -627,7 +657,7 @@ enum sci_status sci_task_request_construct_sata(struct isci_request *ireq) | |||
627 | 657 | ||
628 | /** | 658 | /** |
629 | * sci_req_tx_bytes - bytes transferred when reply underruns request | 659 | * sci_req_tx_bytes - bytes transferred when reply underruns request |
630 | * @sci_req: request that was terminated early | 660 | * @ireq: request that was terminated early |
631 | */ | 661 | */ |
632 | #define SCU_TASK_CONTEXT_SRAM 0x200000 | 662 | #define SCU_TASK_CONTEXT_SRAM 0x200000 |
633 | static u32 sci_req_tx_bytes(struct isci_request *ireq) | 663 | static u32 sci_req_tx_bytes(struct isci_request *ireq) |
@@ -729,6 +759,10 @@ sci_io_request_terminate(struct isci_request *ireq) | |||
729 | case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED: | 759 | case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED: |
730 | case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG: | 760 | case SCI_REQ_STP_SOFT_RESET_WAIT_H2D_DIAG: |
731 | case SCI_REQ_STP_SOFT_RESET_WAIT_D2H: | 761 | case SCI_REQ_STP_SOFT_RESET_WAIT_D2H: |
762 | case SCI_REQ_ATAPI_WAIT_H2D: | ||
763 | case SCI_REQ_ATAPI_WAIT_PIO_SETUP: | ||
764 | case SCI_REQ_ATAPI_WAIT_D2H: | ||
765 | case SCI_REQ_ATAPI_WAIT_TC_COMP: | ||
732 | sci_change_state(&ireq->sm, SCI_REQ_ABORTING); | 766 | sci_change_state(&ireq->sm, SCI_REQ_ABORTING); |
733 | return SCI_SUCCESS; | 767 | return SCI_SUCCESS; |
734 | case SCI_REQ_TASK_WAIT_TC_RESP: | 768 | case SCI_REQ_TASK_WAIT_TC_RESP: |
@@ -1194,8 +1228,8 @@ static enum sci_status sci_stp_request_pio_data_out_transmit_data(struct isci_re | |||
1194 | { | 1228 | { |
1195 | struct isci_stp_request *stp_req = &ireq->stp.req; | 1229 | struct isci_stp_request *stp_req = &ireq->stp.req; |
1196 | struct scu_sgl_element_pair *sgl_pair; | 1230 | struct scu_sgl_element_pair *sgl_pair; |
1231 | enum sci_status status = SCI_SUCCESS; | ||
1197 | struct scu_sgl_element *sgl; | 1232 | struct scu_sgl_element *sgl; |
1198 | enum sci_status status; | ||
1199 | u32 offset; | 1233 | u32 offset; |
1200 | u32 len = 0; | 1234 | u32 len = 0; |
1201 | 1235 | ||
@@ -1249,7 +1283,7 @@ static enum sci_status sci_stp_request_pio_data_out_transmit_data(struct isci_re | |||
1249 | */ | 1283 | */ |
1250 | static enum sci_status | 1284 | static enum sci_status |
1251 | sci_stp_request_pio_data_in_copy_data_buffer(struct isci_stp_request *stp_req, | 1285 | sci_stp_request_pio_data_in_copy_data_buffer(struct isci_stp_request *stp_req, |
1252 | u8 *data_buf, u32 len) | 1286 | u8 *data_buf, u32 len) |
1253 | { | 1287 | { |
1254 | struct isci_request *ireq; | 1288 | struct isci_request *ireq; |
1255 | u8 *src_addr; | 1289 | u8 *src_addr; |
@@ -1423,6 +1457,128 @@ static enum sci_status sci_stp_request_udma_general_frame_handler(struct isci_re | |||
1423 | return status; | 1457 | return status; |
1424 | } | 1458 | } |
1425 | 1459 | ||
1460 | static enum sci_status process_unsolicited_fis(struct isci_request *ireq, | ||
1461 | u32 frame_index) | ||
1462 | { | ||
1463 | struct isci_host *ihost = ireq->owning_controller; | ||
1464 | enum sci_status status; | ||
1465 | struct dev_to_host_fis *frame_header; | ||
1466 | u32 *frame_buffer; | ||
1467 | |||
1468 | status = sci_unsolicited_frame_control_get_header(&ihost->uf_control, | ||
1469 | frame_index, | ||
1470 | (void **)&frame_header); | ||
1471 | |||
1472 | if (status != SCI_SUCCESS) | ||
1473 | return status; | ||
1474 | |||
1475 | if (frame_header->fis_type != FIS_REGD2H) { | ||
1476 | dev_err(&ireq->isci_host->pdev->dev, | ||
1477 | "%s ERROR: invalid fis type 0x%X\n", | ||
1478 | __func__, frame_header->fis_type); | ||
1479 | return SCI_FAILURE; | ||
1480 | } | ||
1481 | |||
1482 | sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, | ||
1483 | frame_index, | ||
1484 | (void **)&frame_buffer); | ||
1485 | |||
1486 | sci_controller_copy_sata_response(&ireq->stp.rsp, | ||
1487 | (u32 *)frame_header, | ||
1488 | frame_buffer); | ||
1489 | |||
1490 | /* Frame has been decoded return it to the controller */ | ||
1491 | sci_controller_release_frame(ihost, frame_index); | ||
1492 | |||
1493 | return status; | ||
1494 | } | ||
1495 | |||
1496 | static enum sci_status atapi_d2h_reg_frame_handler(struct isci_request *ireq, | ||
1497 | u32 frame_index) | ||
1498 | { | ||
1499 | struct sas_task *task = isci_request_access_task(ireq); | ||
1500 | enum sci_status status; | ||
1501 | |||
1502 | status = process_unsolicited_fis(ireq, frame_index); | ||
1503 | |||
1504 | if (status == SCI_SUCCESS) { | ||
1505 | if (ireq->stp.rsp.status & ATA_ERR) | ||
1506 | status = SCI_IO_FAILURE_RESPONSE_VALID; | ||
1507 | } else { | ||
1508 | status = SCI_IO_FAILURE_RESPONSE_VALID; | ||
1509 | } | ||
1510 | |||
1511 | if (status != SCI_SUCCESS) { | ||
1512 | ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; | ||
1513 | ireq->sci_status = status; | ||
1514 | } else { | ||
1515 | ireq->scu_status = SCU_TASK_DONE_GOOD; | ||
1516 | ireq->sci_status = SCI_SUCCESS; | ||
1517 | } | ||
1518 | |||
1519 | /* the d2h ufi is the end of non-data commands */ | ||
1520 | if (task->data_dir == DMA_NONE) | ||
1521 | sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); | ||
1522 | |||
1523 | return status; | ||
1524 | } | ||
1525 | |||
1526 | static void scu_atapi_reconstruct_raw_frame_task_context(struct isci_request *ireq) | ||
1527 | { | ||
1528 | struct ata_device *dev = sas_to_ata_dev(ireq->target_device->domain_dev); | ||
1529 | void *atapi_cdb = ireq->ttype_ptr.io_task_ptr->ata_task.atapi_packet; | ||
1530 | struct scu_task_context *task_context = ireq->tc; | ||
1531 | |||
1532 | /* fill in the SCU Task Context for a DATA fis containing CDB in Raw Frame | ||
1533 | * type. The TC for previous Packet fis was already there, we only need to | ||
1534 | * change the H2D fis content. | ||
1535 | */ | ||
1536 | memset(&ireq->stp.cmd, 0, sizeof(struct host_to_dev_fis)); | ||
1537 | memcpy(((u8 *)&ireq->stp.cmd + sizeof(u32)), atapi_cdb, ATAPI_CDB_LEN); | ||
1538 | memset(&(task_context->type.stp), 0, sizeof(struct stp_task_context)); | ||
1539 | task_context->type.stp.fis_type = FIS_DATA; | ||
1540 | task_context->transfer_length_bytes = dev->cdb_len; | ||
1541 | } | ||
1542 | |||
1543 | static void scu_atapi_construct_task_context(struct isci_request *ireq) | ||
1544 | { | ||
1545 | struct ata_device *dev = sas_to_ata_dev(ireq->target_device->domain_dev); | ||
1546 | struct sas_task *task = isci_request_access_task(ireq); | ||
1547 | struct scu_task_context *task_context = ireq->tc; | ||
1548 | int cdb_len = dev->cdb_len; | ||
1549 | |||
1550 | /* reference: SSTL 1.13.4.2 | ||
1551 | * task_type, sata_direction | ||
1552 | */ | ||
1553 | if (task->data_dir == DMA_TO_DEVICE) { | ||
1554 | task_context->task_type = SCU_TASK_TYPE_PACKET_DMA_OUT; | ||
1555 | task_context->sata_direction = 0; | ||
1556 | } else { | ||
1557 | /* todo: for NO_DATA command, we need to send out raw frame. */ | ||
1558 | task_context->task_type = SCU_TASK_TYPE_PACKET_DMA_IN; | ||
1559 | task_context->sata_direction = 1; | ||
1560 | } | ||
1561 | |||
1562 | memset(&task_context->type.stp, 0, sizeof(task_context->type.stp)); | ||
1563 | task_context->type.stp.fis_type = FIS_DATA; | ||
1564 | |||
1565 | memset(&ireq->stp.cmd, 0, sizeof(ireq->stp.cmd)); | ||
1566 | memcpy(&ireq->stp.cmd.lbal, task->ata_task.atapi_packet, cdb_len); | ||
1567 | task_context->ssp_command_iu_length = cdb_len / sizeof(u32); | ||
1568 | |||
1569 | /* task phase is set to TX_CMD */ | ||
1570 | task_context->task_phase = 0x1; | ||
1571 | |||
1572 | /* retry counter */ | ||
1573 | task_context->stp_retry_count = 0; | ||
1574 | |||
1575 | /* data transfer size. */ | ||
1576 | task_context->transfer_length_bytes = task->total_xfer_len; | ||
1577 | |||
1578 | /* setup sgl */ | ||
1579 | sci_request_build_sgl(ireq); | ||
1580 | } | ||
1581 | |||
1426 | enum sci_status | 1582 | enum sci_status |
1427 | sci_io_request_frame_handler(struct isci_request *ireq, | 1583 | sci_io_request_frame_handler(struct isci_request *ireq, |
1428 | u32 frame_index) | 1584 | u32 frame_index) |
@@ -1490,29 +1646,30 @@ sci_io_request_frame_handler(struct isci_request *ireq, | |||
1490 | return SCI_SUCCESS; | 1646 | return SCI_SUCCESS; |
1491 | 1647 | ||
1492 | case SCI_REQ_SMP_WAIT_RESP: { | 1648 | case SCI_REQ_SMP_WAIT_RESP: { |
1493 | struct smp_resp *rsp_hdr = &ireq->smp.rsp; | 1649 | struct sas_task *task = isci_request_access_task(ireq); |
1494 | void *frame_header; | 1650 | struct scatterlist *sg = &task->smp_task.smp_resp; |
1651 | void *frame_header, *kaddr; | ||
1652 | u8 *rsp; | ||
1495 | 1653 | ||
1496 | sci_unsolicited_frame_control_get_header(&ihost->uf_control, | 1654 | sci_unsolicited_frame_control_get_header(&ihost->uf_control, |
1497 | frame_index, | 1655 | frame_index, |
1498 | &frame_header); | 1656 | &frame_header); |
1499 | 1657 | kaddr = kmap_atomic(sg_page(sg), KM_IRQ0); | |
1500 | /* byte swap the header. */ | 1658 | rsp = kaddr + sg->offset; |
1501 | word_cnt = SMP_RESP_HDR_SZ / sizeof(u32); | 1659 | sci_swab32_cpy(rsp, frame_header, 1); |
1502 | sci_swab32_cpy(rsp_hdr, frame_header, word_cnt); | ||
1503 | 1660 | ||
1504 | if (rsp_hdr->frame_type == SMP_RESPONSE) { | 1661 | if (rsp[0] == SMP_RESPONSE) { |
1505 | void *smp_resp; | 1662 | void *smp_resp; |
1506 | 1663 | ||
1507 | sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, | 1664 | sci_unsolicited_frame_control_get_buffer(&ihost->uf_control, |
1508 | frame_index, | 1665 | frame_index, |
1509 | &smp_resp); | 1666 | &smp_resp); |
1510 | |||
1511 | word_cnt = (sizeof(struct smp_resp) - SMP_RESP_HDR_SZ) / | ||
1512 | sizeof(u32); | ||
1513 | 1667 | ||
1514 | sci_swab32_cpy(((u8 *) rsp_hdr) + SMP_RESP_HDR_SZ, | 1668 | word_cnt = (sg->length/4)-1; |
1515 | smp_resp, word_cnt); | 1669 | if (word_cnt > 0) |
1670 | word_cnt = min_t(unsigned int, word_cnt, | ||
1671 | SCU_UNSOLICITED_FRAME_BUFFER_SIZE/4); | ||
1672 | sci_swab32_cpy(rsp + 4, smp_resp, word_cnt); | ||
1516 | 1673 | ||
1517 | ireq->scu_status = SCU_TASK_DONE_GOOD; | 1674 | ireq->scu_status = SCU_TASK_DONE_GOOD; |
1518 | ireq->sci_status = SCI_SUCCESS; | 1675 | ireq->sci_status = SCI_SUCCESS; |
@@ -1528,12 +1685,13 @@ sci_io_request_frame_handler(struct isci_request *ireq, | |||
1528 | __func__, | 1685 | __func__, |
1529 | ireq, | 1686 | ireq, |
1530 | frame_index, | 1687 | frame_index, |
1531 | rsp_hdr->frame_type); | 1688 | rsp[0]); |
1532 | 1689 | ||
1533 | ireq->scu_status = SCU_TASK_DONE_SMP_FRM_TYPE_ERR; | 1690 | ireq->scu_status = SCU_TASK_DONE_SMP_FRM_TYPE_ERR; |
1534 | ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; | 1691 | ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; |
1535 | sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); | 1692 | sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); |
1536 | } | 1693 | } |
1694 | kunmap_atomic(kaddr, KM_IRQ0); | ||
1537 | 1695 | ||
1538 | sci_controller_release_frame(ihost, frame_index); | 1696 | sci_controller_release_frame(ihost, frame_index); |
1539 | 1697 | ||
@@ -1833,6 +1991,24 @@ sci_io_request_frame_handler(struct isci_request *ireq, | |||
1833 | 1991 | ||
1834 | return status; | 1992 | return status; |
1835 | } | 1993 | } |
1994 | case SCI_REQ_ATAPI_WAIT_PIO_SETUP: { | ||
1995 | struct sas_task *task = isci_request_access_task(ireq); | ||
1996 | |||
1997 | sci_controller_release_frame(ihost, frame_index); | ||
1998 | ireq->target_device->working_request = ireq; | ||
1999 | if (task->data_dir == DMA_NONE) { | ||
2000 | sci_change_state(&ireq->sm, SCI_REQ_ATAPI_WAIT_TC_COMP); | ||
2001 | scu_atapi_reconstruct_raw_frame_task_context(ireq); | ||
2002 | } else { | ||
2003 | sci_change_state(&ireq->sm, SCI_REQ_ATAPI_WAIT_D2H); | ||
2004 | scu_atapi_construct_task_context(ireq); | ||
2005 | } | ||
2006 | |||
2007 | sci_controller_continue_io(ireq); | ||
2008 | return SCI_SUCCESS; | ||
2009 | } | ||
2010 | case SCI_REQ_ATAPI_WAIT_D2H: | ||
2011 | return atapi_d2h_reg_frame_handler(ireq, frame_index); | ||
1836 | case SCI_REQ_ABORTING: | 2012 | case SCI_REQ_ABORTING: |
1837 | /* | 2013 | /* |
1838 | * TODO: Is it even possible to get an unsolicited frame in the | 2014 | * TODO: Is it even possible to get an unsolicited frame in the |
@@ -1898,10 +2074,9 @@ static enum sci_status stp_request_udma_await_tc_event(struct isci_request *ireq | |||
1898 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_MAX_PLD_ERR): | 2074 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_MAX_PLD_ERR): |
1899 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_R_ERR): | 2075 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_LL_R_ERR): |
1900 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CMD_LL_R_ERR): | 2076 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CMD_LL_R_ERR): |
1901 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_CRC_ERR): | ||
1902 | sci_remote_device_suspend(ireq->target_device, | 2077 | sci_remote_device_suspend(ireq->target_device, |
1903 | SCU_EVENT_SPECIFIC(SCU_NORMALIZE_COMPLETION_STATUS(completion_code))); | 2078 | SCU_EVENT_SPECIFIC(SCU_NORMALIZE_COMPLETION_STATUS(completion_code))); |
1904 | /* Fall through to the default case */ | 2079 | /* Fall through to the default case */ |
1905 | default: | 2080 | default: |
1906 | /* All other completion status cause the IO to be complete. */ | 2081 | /* All other completion status cause the IO to be complete. */ |
1907 | ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); | 2082 | ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); |
@@ -1964,6 +2139,112 @@ stp_request_soft_reset_await_h2d_diagnostic_tc_event(struct isci_request *ireq, | |||
1964 | return SCI_SUCCESS; | 2139 | return SCI_SUCCESS; |
1965 | } | 2140 | } |
1966 | 2141 | ||
2142 | static enum sci_status atapi_raw_completion(struct isci_request *ireq, u32 completion_code, | ||
2143 | enum sci_base_request_states next) | ||
2144 | { | ||
2145 | enum sci_status status = SCI_SUCCESS; | ||
2146 | |||
2147 | switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { | ||
2148 | case SCU_MAKE_COMPLETION_STATUS(SCU_TASK_DONE_GOOD): | ||
2149 | ireq->scu_status = SCU_TASK_DONE_GOOD; | ||
2150 | ireq->sci_status = SCI_SUCCESS; | ||
2151 | sci_change_state(&ireq->sm, next); | ||
2152 | break; | ||
2153 | default: | ||
2154 | /* All other completion status cause the IO to be complete. | ||
2155 | * If a NAK was received, then it is up to the user to retry | ||
2156 | * the request. | ||
2157 | */ | ||
2158 | ireq->scu_status = SCU_NORMALIZE_COMPLETION_STATUS(completion_code); | ||
2159 | ireq->sci_status = SCI_FAILURE_CONTROLLER_SPECIFIC_IO_ERR; | ||
2160 | |||
2161 | sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); | ||
2162 | break; | ||
2163 | } | ||
2164 | |||
2165 | return status; | ||
2166 | } | ||
2167 | |||
2168 | static enum sci_status atapi_data_tc_completion_handler(struct isci_request *ireq, | ||
2169 | u32 completion_code) | ||
2170 | { | ||
2171 | struct isci_remote_device *idev = ireq->target_device; | ||
2172 | struct dev_to_host_fis *d2h = &ireq->stp.rsp; | ||
2173 | enum sci_status status = SCI_SUCCESS; | ||
2174 | |||
2175 | switch (SCU_GET_COMPLETION_TL_STATUS(completion_code)) { | ||
2176 | case (SCU_TASK_DONE_GOOD << SCU_COMPLETION_TL_STATUS_SHIFT): | ||
2177 | sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); | ||
2178 | break; | ||
2179 | |||
2180 | case (SCU_TASK_DONE_UNEXP_FIS << SCU_COMPLETION_TL_STATUS_SHIFT): { | ||
2181 | u16 len = sci_req_tx_bytes(ireq); | ||
2182 | |||
2183 | /* likely non-error data underrrun, workaround missing | ||
2184 | * d2h frame from the controller | ||
2185 | */ | ||
2186 | if (d2h->fis_type != FIS_REGD2H) { | ||
2187 | d2h->fis_type = FIS_REGD2H; | ||
2188 | d2h->flags = (1 << 6); | ||
2189 | d2h->status = 0x50; | ||
2190 | d2h->error = 0; | ||
2191 | d2h->lbal = 0; | ||
2192 | d2h->byte_count_low = len & 0xff; | ||
2193 | d2h->byte_count_high = len >> 8; | ||
2194 | d2h->device = 0xa0; | ||
2195 | d2h->lbal_exp = 0; | ||
2196 | d2h->lbam_exp = 0; | ||
2197 | d2h->lbah_exp = 0; | ||
2198 | d2h->_r_a = 0; | ||
2199 | d2h->sector_count = 0x3; | ||
2200 | d2h->sector_count_exp = 0; | ||
2201 | d2h->_r_b = 0; | ||
2202 | d2h->_r_c = 0; | ||
2203 | d2h->_r_d = 0; | ||
2204 | } | ||
2205 | |||
2206 | ireq->scu_status = SCU_TASK_DONE_GOOD; | ||
2207 | ireq->sci_status = SCI_SUCCESS_IO_DONE_EARLY; | ||
2208 | status = ireq->sci_status; | ||
2209 | |||
2210 | /* the hw will have suspended the rnc, so complete the | ||
2211 | * request upon pending resume | ||
2212 | */ | ||
2213 | sci_change_state(&idev->sm, SCI_STP_DEV_ATAPI_ERROR); | ||
2214 | break; | ||
2215 | } | ||
2216 | case (SCU_TASK_DONE_EXCESS_DATA << SCU_COMPLETION_TL_STATUS_SHIFT): | ||
2217 | /* In this case, there is no UF coming after. | ||
2218 | * compelte the IO now. | ||
2219 | */ | ||
2220 | ireq->scu_status = SCU_TASK_DONE_GOOD; | ||
2221 | ireq->sci_status = SCI_SUCCESS; | ||
2222 | sci_change_state(&ireq->sm, SCI_REQ_COMPLETED); | ||
2223 | break; | ||
2224 | |||
2225 | default: | ||
2226 | if (d2h->fis_type == FIS_REGD2H) { | ||
2227 | /* UF received change the device state to ATAPI_ERROR */ | ||
2228 | status = ireq->sci_status; | ||
2229 | sci_change_state(&idev->sm, SCI_STP_DEV_ATAPI_ERROR); | ||
2230 | } else { | ||
2231 | /* If receiving any non-sucess TC status, no UF | ||
2232 | * received yet, then an UF for the status fis | ||
2233 | * is coming after (XXX: suspect this is | ||
2234 | * actually a protocol error or a bug like the | ||
2235 | * DONE_UNEXP_FIS case) | ||
2236 | */ | ||
2237 | ireq->scu_status = SCU_TASK_DONE_CHECK_RESPONSE; | ||
2238 | ireq->sci_status = SCI_FAILURE_IO_RESPONSE_VALID; | ||
2239 | |||
2240 | sci_change_state(&ireq->sm, SCI_REQ_ATAPI_WAIT_D2H); | ||
2241 | } | ||
2242 | break; | ||
2243 | } | ||
2244 | |||
2245 | return status; | ||
2246 | } | ||
2247 | |||
1967 | enum sci_status | 2248 | enum sci_status |
1968 | sci_io_request_tc_completion(struct isci_request *ireq, | 2249 | sci_io_request_tc_completion(struct isci_request *ireq, |
1969 | u32 completion_code) | 2250 | u32 completion_code) |
@@ -2015,6 +2296,17 @@ sci_io_request_tc_completion(struct isci_request *ireq, | |||
2015 | return request_aborting_state_tc_event(ireq, | 2296 | return request_aborting_state_tc_event(ireq, |
2016 | completion_code); | 2297 | completion_code); |
2017 | 2298 | ||
2299 | case SCI_REQ_ATAPI_WAIT_H2D: | ||
2300 | return atapi_raw_completion(ireq, completion_code, | ||
2301 | SCI_REQ_ATAPI_WAIT_PIO_SETUP); | ||
2302 | |||
2303 | case SCI_REQ_ATAPI_WAIT_TC_COMP: | ||
2304 | return atapi_raw_completion(ireq, completion_code, | ||
2305 | SCI_REQ_ATAPI_WAIT_D2H); | ||
2306 | |||
2307 | case SCI_REQ_ATAPI_WAIT_D2H: | ||
2308 | return atapi_data_tc_completion_handler(ireq, completion_code); | ||
2309 | |||
2018 | default: | 2310 | default: |
2019 | dev_warn(&ihost->pdev->dev, | 2311 | dev_warn(&ihost->pdev->dev, |
2020 | "%s: SCIC IO Request given task completion " | 2312 | "%s: SCIC IO Request given task completion " |
@@ -2421,6 +2713,8 @@ static void isci_process_stp_response(struct sas_task *task, struct dev_to_host_ | |||
2421 | */ | 2713 | */ |
2422 | if (fis->status & ATA_DF) | 2714 | if (fis->status & ATA_DF) |
2423 | ts->stat = SAS_PROTO_RESPONSE; | 2715 | ts->stat = SAS_PROTO_RESPONSE; |
2716 | else if (fis->status & ATA_ERR) | ||
2717 | ts->stat = SAM_STAT_CHECK_CONDITION; | ||
2424 | else | 2718 | else |
2425 | ts->stat = SAM_STAT_GOOD; | 2719 | ts->stat = SAM_STAT_GOOD; |
2426 | 2720 | ||
@@ -2603,18 +2897,7 @@ static void isci_request_io_request_complete(struct isci_host *ihost, | |||
2603 | status = SAM_STAT_GOOD; | 2897 | status = SAM_STAT_GOOD; |
2604 | set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); | 2898 | set_bit(IREQ_COMPLETE_IN_TARGET, &request->flags); |
2605 | 2899 | ||
2606 | if (task->task_proto == SAS_PROTOCOL_SMP) { | 2900 | if (completion_status == SCI_IO_SUCCESS_IO_DONE_EARLY) { |
2607 | void *rsp = &request->smp.rsp; | ||
2608 | |||
2609 | dev_dbg(&ihost->pdev->dev, | ||
2610 | "%s: SMP protocol completion\n", | ||
2611 | __func__); | ||
2612 | |||
2613 | sg_copy_from_buffer( | ||
2614 | &task->smp_task.smp_resp, 1, | ||
2615 | rsp, sizeof(struct smp_resp)); | ||
2616 | } else if (completion_status | ||
2617 | == SCI_IO_SUCCESS_IO_DONE_EARLY) { | ||
2618 | 2901 | ||
2619 | /* This was an SSP / STP / SATA transfer. | 2902 | /* This was an SSP / STP / SATA transfer. |
2620 | * There is a possibility that less data than | 2903 | * There is a possibility that less data than |
@@ -2791,6 +3074,7 @@ static void sci_request_started_state_enter(struct sci_base_state_machine *sm) | |||
2791 | { | 3074 | { |
2792 | struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); | 3075 | struct isci_request *ireq = container_of(sm, typeof(*ireq), sm); |
2793 | struct domain_device *dev = ireq->target_device->domain_dev; | 3076 | struct domain_device *dev = ireq->target_device->domain_dev; |
3077 | enum sci_base_request_states state; | ||
2794 | struct sas_task *task; | 3078 | struct sas_task *task; |
2795 | 3079 | ||
2796 | /* XXX as hch said always creating an internal sas_task for tmf | 3080 | /* XXX as hch said always creating an internal sas_task for tmf |
@@ -2802,26 +3086,30 @@ static void sci_request_started_state_enter(struct sci_base_state_machine *sm) | |||
2802 | * substates | 3086 | * substates |
2803 | */ | 3087 | */ |
2804 | if (!task && dev->dev_type == SAS_END_DEV) { | 3088 | if (!task && dev->dev_type == SAS_END_DEV) { |
2805 | sci_change_state(sm, SCI_REQ_TASK_WAIT_TC_COMP); | 3089 | state = SCI_REQ_TASK_WAIT_TC_COMP; |
2806 | } else if (!task && | 3090 | } else if (!task && |
2807 | (isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_high || | 3091 | (isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_high || |
2808 | isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_low)) { | 3092 | isci_request_access_tmf(ireq)->tmf_code == isci_tmf_sata_srst_low)) { |
2809 | sci_change_state(sm, SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED); | 3093 | state = SCI_REQ_STP_SOFT_RESET_WAIT_H2D_ASSERTED; |
2810 | } else if (task && task->task_proto == SAS_PROTOCOL_SMP) { | 3094 | } else if (task && task->task_proto == SAS_PROTOCOL_SMP) { |
2811 | sci_change_state(sm, SCI_REQ_SMP_WAIT_RESP); | 3095 | state = SCI_REQ_SMP_WAIT_RESP; |
2812 | } else if (task && sas_protocol_ata(task->task_proto) && | 3096 | } else if (task && sas_protocol_ata(task->task_proto) && |
2813 | !task->ata_task.use_ncq) { | 3097 | !task->ata_task.use_ncq) { |
2814 | u32 state; | 3098 | if (dev->sata_dev.command_set == ATAPI_COMMAND_SET && |
2815 | 3099 | task->ata_task.fis.command == ATA_CMD_PACKET) { | |
2816 | if (task->data_dir == DMA_NONE) | 3100 | state = SCI_REQ_ATAPI_WAIT_H2D; |
3101 | } else if (task->data_dir == DMA_NONE) { | ||
2817 | state = SCI_REQ_STP_NON_DATA_WAIT_H2D; | 3102 | state = SCI_REQ_STP_NON_DATA_WAIT_H2D; |
2818 | else if (task->ata_task.dma_xfer) | 3103 | } else if (task->ata_task.dma_xfer) { |
2819 | state = SCI_REQ_STP_UDMA_WAIT_TC_COMP; | 3104 | state = SCI_REQ_STP_UDMA_WAIT_TC_COMP; |
2820 | else /* PIO */ | 3105 | } else /* PIO */ { |
2821 | state = SCI_REQ_STP_PIO_WAIT_H2D; | 3106 | state = SCI_REQ_STP_PIO_WAIT_H2D; |
2822 | 3107 | } | |
2823 | sci_change_state(sm, state); | 3108 | } else { |
3109 | /* SSP or NCQ are fully accelerated, no substates */ | ||
3110 | return; | ||
2824 | } | 3111 | } |
3112 | sci_change_state(sm, state); | ||
2825 | } | 3113 | } |
2826 | 3114 | ||
2827 | static void sci_request_completed_state_enter(struct sci_base_state_machine *sm) | 3115 | static void sci_request_completed_state_enter(struct sci_base_state_machine *sm) |
@@ -2913,6 +3201,10 @@ static const struct sci_base_state sci_request_state_table[] = { | |||
2913 | [SCI_REQ_TASK_WAIT_TC_RESP] = { }, | 3201 | [SCI_REQ_TASK_WAIT_TC_RESP] = { }, |
2914 | [SCI_REQ_SMP_WAIT_RESP] = { }, | 3202 | [SCI_REQ_SMP_WAIT_RESP] = { }, |
2915 | [SCI_REQ_SMP_WAIT_TC_COMP] = { }, | 3203 | [SCI_REQ_SMP_WAIT_TC_COMP] = { }, |
3204 | [SCI_REQ_ATAPI_WAIT_H2D] = { }, | ||
3205 | [SCI_REQ_ATAPI_WAIT_PIO_SETUP] = { }, | ||
3206 | [SCI_REQ_ATAPI_WAIT_D2H] = { }, | ||
3207 | [SCI_REQ_ATAPI_WAIT_TC_COMP] = { }, | ||
2916 | [SCI_REQ_COMPLETED] = { | 3208 | [SCI_REQ_COMPLETED] = { |
2917 | .enter_state = sci_request_completed_state_enter, | 3209 | .enter_state = sci_request_completed_state_enter, |
2918 | }, | 3210 | }, |
diff --git a/drivers/scsi/isci/request.h b/drivers/scsi/isci/request.h index 7a1d5a9778eb..f720b97b7bb5 100644 --- a/drivers/scsi/isci/request.h +++ b/drivers/scsi/isci/request.h | |||
@@ -96,7 +96,6 @@ enum sci_request_protocol { | |||
96 | * to wait for another fis or if the transfer is complete. Upon | 96 | * to wait for another fis or if the transfer is complete. Upon |
97 | * receipt of a d2h fis this will be the status field of that fis. | 97 | * receipt of a d2h fis this will be the status field of that fis. |
98 | * @sgl - track pio transfer progress as we iterate through the sgl | 98 | * @sgl - track pio transfer progress as we iterate through the sgl |
99 | * @device_cdb_len - atapi device advertises it's transfer constraints at setup | ||
100 | */ | 99 | */ |
101 | struct isci_stp_request { | 100 | struct isci_stp_request { |
102 | u32 pio_len; | 101 | u32 pio_len; |
@@ -107,7 +106,6 @@ struct isci_stp_request { | |||
107 | u8 set; | 106 | u8 set; |
108 | u32 offset; | 107 | u32 offset; |
109 | } sgl; | 108 | } sgl; |
110 | u32 device_cdb_len; | ||
111 | }; | 109 | }; |
112 | 110 | ||
113 | struct isci_request { | 111 | struct isci_request { |
@@ -174,9 +172,6 @@ struct isci_request { | |||
174 | }; | 172 | }; |
175 | } ssp; | 173 | } ssp; |
176 | struct { | 174 | struct { |
177 | struct smp_resp rsp; | ||
178 | } smp; | ||
179 | struct { | ||
180 | struct isci_stp_request req; | 175 | struct isci_stp_request req; |
181 | struct host_to_dev_fis cmd; | 176 | struct host_to_dev_fis cmd; |
182 | struct dev_to_host_fis rsp; | 177 | struct dev_to_host_fis rsp; |
@@ -252,6 +247,32 @@ enum sci_base_request_states { | |||
252 | SCI_REQ_STP_PIO_DATA_OUT, | 247 | SCI_REQ_STP_PIO_DATA_OUT, |
253 | 248 | ||
254 | /* | 249 | /* |
250 | * While in this state the IO request object is waiting for the TC | ||
251 | * completion notification for the H2D Register FIS | ||
252 | */ | ||
253 | SCI_REQ_ATAPI_WAIT_H2D, | ||
254 | |||
255 | /* | ||
256 | * While in this state the IO request object is waiting for either a | ||
257 | * PIO Setup. | ||
258 | */ | ||
259 | SCI_REQ_ATAPI_WAIT_PIO_SETUP, | ||
260 | |||
261 | /* | ||
262 | * The non-data IO transit to this state in this state after receiving | ||
263 | * TC completion. While in this state IO request object is waiting for | ||
264 | * D2H status frame as UF. | ||
265 | */ | ||
266 | SCI_REQ_ATAPI_WAIT_D2H, | ||
267 | |||
268 | /* | ||
269 | * When transmitting raw frames hardware reports task context completion | ||
270 | * after every frame submission, so in the non-accelerated case we need | ||
271 | * to expect the completion for the "cdb" frame. | ||
272 | */ | ||
273 | SCI_REQ_ATAPI_WAIT_TC_COMP, | ||
274 | |||
275 | /* | ||
255 | * The AWAIT_TC_COMPLETION sub-state indicates that the started raw | 276 | * The AWAIT_TC_COMPLETION sub-state indicates that the started raw |
256 | * task management request is waiting for the transmission of the | 277 | * task management request is waiting for the transmission of the |
257 | * initial frame (i.e. command, task, etc.). | 278 | * initial frame (i.e. command, task, etc.). |
diff --git a/drivers/scsi/isci/sas.h b/drivers/scsi/isci/sas.h index 462b15174d3f..dc26b4aea99e 100644 --- a/drivers/scsi/isci/sas.h +++ b/drivers/scsi/isci/sas.h | |||
@@ -204,8 +204,6 @@ struct smp_req { | |||
204 | u8 req_data[0]; | 204 | u8 req_data[0]; |
205 | } __packed; | 205 | } __packed; |
206 | 206 | ||
207 | #define SMP_RESP_HDR_SZ 4 | ||
208 | |||
209 | /* | 207 | /* |
210 | * struct sci_sas_address - This structure depicts how a SAS address is | 208 | * struct sci_sas_address - This structure depicts how a SAS address is |
211 | * represented by SCI. | 209 | * represented by SCI. |
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c index d6bcdd013dc9..e2d9418683ce 100644 --- a/drivers/scsi/isci/task.c +++ b/drivers/scsi/isci/task.c | |||
@@ -1345,29 +1345,6 @@ static void isci_smp_task_done(struct sas_task *task) | |||
1345 | complete(&task->completion); | 1345 | complete(&task->completion); |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | static struct sas_task *isci_alloc_task(void) | ||
1349 | { | ||
1350 | struct sas_task *task = kzalloc(sizeof(*task), GFP_KERNEL); | ||
1351 | |||
1352 | if (task) { | ||
1353 | INIT_LIST_HEAD(&task->list); | ||
1354 | spin_lock_init(&task->task_state_lock); | ||
1355 | task->task_state_flags = SAS_TASK_STATE_PENDING; | ||
1356 | init_timer(&task->timer); | ||
1357 | init_completion(&task->completion); | ||
1358 | } | ||
1359 | |||
1360 | return task; | ||
1361 | } | ||
1362 | |||
1363 | static void isci_free_task(struct isci_host *ihost, struct sas_task *task) | ||
1364 | { | ||
1365 | if (task) { | ||
1366 | BUG_ON(!list_empty(&task->list)); | ||
1367 | kfree(task); | ||
1368 | } | ||
1369 | } | ||
1370 | |||
1371 | static int isci_smp_execute_task(struct isci_host *ihost, | 1348 | static int isci_smp_execute_task(struct isci_host *ihost, |
1372 | struct domain_device *dev, void *req, | 1349 | struct domain_device *dev, void *req, |
1373 | int req_size, void *resp, int resp_size) | 1350 | int req_size, void *resp, int resp_size) |
@@ -1376,7 +1353,7 @@ static int isci_smp_execute_task(struct isci_host *ihost, | |||
1376 | struct sas_task *task = NULL; | 1353 | struct sas_task *task = NULL; |
1377 | 1354 | ||
1378 | for (retry = 0; retry < 3; retry++) { | 1355 | for (retry = 0; retry < 3; retry++) { |
1379 | task = isci_alloc_task(); | 1356 | task = sas_alloc_task(GFP_KERNEL); |
1380 | if (!task) | 1357 | if (!task) |
1381 | return -ENOMEM; | 1358 | return -ENOMEM; |
1382 | 1359 | ||
@@ -1439,13 +1416,13 @@ static int isci_smp_execute_task(struct isci_host *ihost, | |||
1439 | SAS_ADDR(dev->sas_addr), | 1416 | SAS_ADDR(dev->sas_addr), |
1440 | task->task_status.resp, | 1417 | task->task_status.resp, |
1441 | task->task_status.stat); | 1418 | task->task_status.stat); |
1442 | isci_free_task(ihost, task); | 1419 | sas_free_task(task); |
1443 | task = NULL; | 1420 | task = NULL; |
1444 | } | 1421 | } |
1445 | } | 1422 | } |
1446 | ex_err: | 1423 | ex_err: |
1447 | BUG_ON(retry == 3 && task != NULL); | 1424 | BUG_ON(retry == 3 && task != NULL); |
1448 | isci_free_task(ihost, task); | 1425 | sas_free_task(task); |
1449 | return res; | 1426 | return res; |
1450 | } | 1427 | } |
1451 | 1428 | ||
diff --git a/drivers/scsi/isci/task.h b/drivers/scsi/isci/task.h index 4a7fa90287ef..15b18d158993 100644 --- a/drivers/scsi/isci/task.h +++ b/drivers/scsi/isci/task.h | |||
@@ -286,6 +286,25 @@ isci_task_set_completion_status( | |||
286 | task->task_status.resp = response; | 286 | task->task_status.resp = response; |
287 | task->task_status.stat = status; | 287 | task->task_status.stat = status; |
288 | 288 | ||
289 | switch (task->task_proto) { | ||
290 | |||
291 | case SAS_PROTOCOL_SATA: | ||
292 | case SAS_PROTOCOL_STP: | ||
293 | case SAS_PROTOCOL_SATA | SAS_PROTOCOL_STP: | ||
294 | |||
295 | if (task_notification_selection | ||
296 | == isci_perform_error_io_completion) { | ||
297 | /* SATA/STP I/O has it's own means of scheduling device | ||
298 | * error handling on the normal path. | ||
299 | */ | ||
300 | task_notification_selection | ||
301 | = isci_perform_normal_io_completion; | ||
302 | } | ||
303 | break; | ||
304 | default: | ||
305 | break; | ||
306 | } | ||
307 | |||
289 | switch (task_notification_selection) { | 308 | switch (task_notification_selection) { |
290 | 309 | ||
291 | case isci_perform_error_io_completion: | 310 | case isci_perform_error_io_completion: |