pm80xx_hwi.c revision a6cb3d012b983b350ae3892cff2e692665df0e1e
1f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/* 2f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * PMC-Sierra SPCv/ve 8088/8089 SAS/SATA based host adapters driver 3f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * 4f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * Copyright (c) 2008-2009 PMC-Sierra, Inc., 5f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * All rights reserved. 6f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * 7f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * Redistribution and use in source and binary forms, with or without 8f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * modification, are permitted provided that the following conditions 9f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * are met: 10f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * 1. Redistributions of source code must retain the above copyright 11f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * notice, this list of conditions, and the following disclaimer, 12f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * without modification. 13f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * 2. Redistributions in binary form must reproduce at minimum a disclaimer 14f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * substantially similar to the "NO WARRANTY" disclaimer below 15f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * ("Disclaimer") and any redistribution must be conditioned upon 16f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * including a substantially similar Disclaimer requirement for further 17f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * binary redistribution. 18f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * 3. Neither the names of the above-listed copyright holders nor the names 19f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * of any contributors may be used to endorse or promote products derived 20f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * from this software without specific prior written permission. 21f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * 22f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * Alternatively, this software may be distributed under the terms of the 23f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * GNU General Public License ("GPL") version 2 as published by the Free 24f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * Software Foundation. 25f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * 26f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * NO WARRANTY 27f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 28f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 29f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR 30f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 31f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 32f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 33f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 34f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 35f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 36f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 37f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * POSSIBILITY OF SUCH DAMAGES. 38f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * 39f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 40f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K #include <linux/slab.h> 41f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K #include "pm8001_sas.h" 42f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K #include "pm80xx_hwi.h" 43f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K #include "pm8001_chips.h" 44f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K #include "pm8001_ctl.h" 45f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 46f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K#define SMP_DIRECT 1 47f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K#define SMP_INDIRECT 2 48f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 49f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * read_main_config_table - read the configure table and save it. 50f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 51f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 52f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void read_main_config_table(struct pm8001_hba_info *pm8001_ha) 53f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 54f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void __iomem *address = pm8001_ha->main_cfg_tbl_addr; 55f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 56f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.signature = 57f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_SIGNATURE_OFFSET); 58f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.interface_rev = 59f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_INTERFACE_REVISION); 60f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.firmware_rev = 61f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_FW_REVISION); 62f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io = 63f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_MAX_OUTSTANDING_IO_OFFSET); 64f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_sgl = 65f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_MAX_SGL_OFFSET); 66f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.ctrl_cap_flag = 67f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_CNTRL_CAP_OFFSET); 68f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.gst_offset = 69f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_GST_OFFSET); 70f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.inbound_queue_offset = 71f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_IBQ_OFFSET); 72f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.outbound_queue_offset = 73f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_OBQ_OFFSET); 74f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 75f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* read Error Dump Offset and Length */ 76f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_dump_offset0 = 77f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_FATAL_ERROR_RDUMP0_OFFSET); 78f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_dump_length0 = 79f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_FATAL_ERROR_RDUMP0_LENGTH); 80f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_dump_offset1 = 81f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_FATAL_ERROR_RDUMP1_OFFSET); 82f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_dump_length1 = 83f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_FATAL_ERROR_RDUMP1_LENGTH); 84f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 85f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* read GPIO LED settings from the configuration table */ 86f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.gpio_led_mapping = 87f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_GPIO_LED_FLAGS_OFFSET); 88f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 89f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* read analog Setting offset from the configuration table */ 90f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.analog_setup_table_offset = 91f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_ANALOG_SETUP_OFFSET); 92f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 93f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.int_vec_table_offset = 94f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_INT_VECTOR_TABLE_OFFSET); 95f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.phy_attr_table_offset = 96f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, MAIN_SAS_PHY_ATTR_TABLE_OFFSET); 97f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 98f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 99f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 100f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * read_general_status_table - read the general status table and save it. 101f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 102f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 103f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void read_general_status_table(struct pm8001_hba_info *pm8001_ha) 104f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 105f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void __iomem *address = pm8001_ha->general_stat_tbl_addr; 106f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.gst_len_mpistate = 107f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_GSTLEN_MPIS_OFFSET); 108f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.iq_freeze_state0 = 109f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_IQ_FREEZE_STATE0_OFFSET); 110f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.iq_freeze_state1 = 111f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_IQ_FREEZE_STATE1_OFFSET); 112f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.msgu_tcnt = 113f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_MSGUTCNT_OFFSET); 114f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.iop_tcnt = 115f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_IOPTCNT_OFFSET); 116f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.gpio_input_val = 117f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_GPIO_INPUT_VAL); 118f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[0] = 119f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_RERRINFO_OFFSET0); 120f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[1] = 121f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_RERRINFO_OFFSET1); 122f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[2] = 123f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_RERRINFO_OFFSET2); 124f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[3] = 125f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_RERRINFO_OFFSET3); 126f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[4] = 127f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_RERRINFO_OFFSET4); 128f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[5] = 129f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_RERRINFO_OFFSET5); 130f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[6] = 131f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_RERRINFO_OFFSET6); 132f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->gs_tbl.pm80xx_tbl.recover_err_info[7] = 133f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, GST_RERRINFO_OFFSET7); 134f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 135f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 136f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * read_phy_attr_table - read the phy attribute table and save it. 137f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 138f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 139f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void read_phy_attr_table(struct pm8001_hba_info *pm8001_ha) 140f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 141f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void __iomem *address = pm8001_ha->pspa_q_tbl_addr; 142f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[0] = 143f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE0_OFFSET); 144f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[1] = 145f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE1_OFFSET); 146f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[2] = 147f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE2_OFFSET); 148f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[3] = 149f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE3_OFFSET); 150f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[4] = 151f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE4_OFFSET); 152f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[5] = 153f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE5_OFFSET); 154f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[6] = 155f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE6_OFFSET); 156f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[7] = 157f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE7_OFFSET); 158f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[8] = 159f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE8_OFFSET); 160f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[9] = 161f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE9_OFFSET); 162f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[10] = 163f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE10_OFFSET); 164f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[11] = 165f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE11_OFFSET); 166f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[12] = 167f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE12_OFFSET); 168f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[13] = 169f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE13_OFFSET); 170f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[14] = 171f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE14_OFFSET); 172f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.phystart1_16[15] = 173f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_PHYSTATE15_OFFSET); 174f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 175f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[0] = 176f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID0_OFFSET); 177f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[1] = 178f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID1_OFFSET); 179f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[2] = 180f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID2_OFFSET); 181f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[3] = 182f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID3_OFFSET); 183f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[4] = 184f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID4_OFFSET); 185f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[5] = 186f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID5_OFFSET); 187f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[6] = 188f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID6_OFFSET); 189f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[7] = 190f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID7_OFFSET); 191f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[8] = 192f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID8_OFFSET); 193f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[9] = 194f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID9_OFFSET); 195f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[10] = 196f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID10_OFFSET); 197f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[11] = 198f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID11_OFFSET); 199f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[12] = 200f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID12_OFFSET); 201f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[13] = 202f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID13_OFFSET); 203f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[14] = 204f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID14_OFFSET); 205f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->phy_attr_table.outbound_hw_event_pid1_16[15] = 206f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, PSPA_OB_HW_EVENT_PID15_OFFSET); 207f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 208f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 209f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 210f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 211f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * read_inbnd_queue_table - read the inbound queue table and save it. 212f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 213f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 214f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void read_inbnd_queue_table(struct pm8001_hba_info *pm8001_ha) 215f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 216f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int i; 217f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void __iomem *address = pm8001_ha->inbnd_q_tbl_addr; 218f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K for (i = 0; i < PM8001_MAX_SPCV_INB_NUM; i++) { 219f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 offset = i * 0x20; 220f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].pi_pci_bar = 221f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K get_pci_bar_index(pm8001_mr32(address, 222f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (offset + IB_PIPCI_BAR))); 223f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].pi_offset = 224f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, (offset + IB_PIPCI_BAR_OFFSET)); 225f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 226f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 227f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 228f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 229f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * read_outbnd_queue_table - read the outbound queue table and save it. 230f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 231f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 232f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void read_outbnd_queue_table(struct pm8001_hba_info *pm8001_ha) 233f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 234f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int i; 235f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void __iomem *address = pm8001_ha->outbnd_q_tbl_addr; 236f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K for (i = 0; i < PM8001_MAX_SPCV_OUTB_NUM; i++) { 237f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 offset = i * 0x24; 238f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].ci_pci_bar = 239f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K get_pci_bar_index(pm8001_mr32(address, 240f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (offset + OB_CIPCI_BAR))); 241f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].ci_offset = 242f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(address, (offset + OB_CIPCI_BAR_OFFSET)); 243f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 244f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 245f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 246f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 247f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * init_default_table_values - init the default table. 248f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 249f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 250f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void init_default_table_values(struct pm8001_hba_info *pm8001_ha) 251f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 252f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int i; 253f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 offsetib, offsetob; 254f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void __iomem *addressib = pm8001_ha->inbnd_q_tbl_addr; 255f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void __iomem *addressob = pm8001_ha->outbnd_q_tbl_addr; 256f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 257f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.upper_event_log_addr = 258f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[AAP1].phys_addr_hi; 259f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.lower_event_log_addr = 260f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[AAP1].phys_addr_lo; 261f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_size = 262f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_EVENT_LOG_SIZE; 263f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_severity = 0x01; 264f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.upper_pcs_event_log_addr = 265f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[IOP].phys_addr_hi; 266f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.lower_pcs_event_log_addr = 267f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[IOP].phys_addr_lo; 268f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.pcs_event_log_size = 269f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_EVENT_LOG_SIZE; 270f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.pcs_event_log_severity = 0x01; 271f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_interrupt = 0x01; 272f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 273c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K /* Disable end to end CRC checking */ 274c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.crc_core_dump = (0x1 << 16); 275c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 276f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K for (i = 0; i < PM8001_MAX_SPCV_INB_NUM; i++) { 277f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].element_pri_size_cnt = 278f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MPI_QUEUE | (64 << 16) | (0x00<<30); 279f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].upper_base_addr = 280f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[IB + i].phys_addr_hi; 281f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].lower_base_addr = 282f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[IB + i].phys_addr_lo; 283f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].base_virt = 284f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (u8 *)pm8001_ha->memoryMap.region[IB + i].virt_ptr; 285f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].total_length = 286f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[IB + i].total_len; 287f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].ci_upper_base_addr = 288f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[CI + i].phys_addr_hi; 289f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].ci_lower_base_addr = 290f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[CI + i].phys_addr_lo; 291f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].ci_virt = 292f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[CI + i].virt_ptr; 293f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K offsetib = i * 0x20; 294f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].pi_pci_bar = 295f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K get_pci_bar_index(pm8001_mr32(addressib, 296f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (offsetib + 0x14))); 297f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].pi_offset = 298f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(addressib, (offsetib + 0x18)); 299f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].producer_idx = 0; 300f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[i].consumer_index = 0; 301f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 302f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K for (i = 0; i < PM8001_MAX_SPCV_OUTB_NUM; i++) { 303f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].element_size_cnt = 304f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MPI_QUEUE | (64 << 16) | (0x01<<30); 305f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].upper_base_addr = 306f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[OB + i].phys_addr_hi; 307f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].lower_base_addr = 308f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[OB + i].phys_addr_lo; 309f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].base_virt = 310f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (u8 *)pm8001_ha->memoryMap.region[OB + i].virt_ptr; 311f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].total_length = 312f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[OB + i].total_len; 313f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].pi_upper_base_addr = 314f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[PI + i].phys_addr_hi; 315f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].pi_lower_base_addr = 316f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[PI + i].phys_addr_lo; 317f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* interrupt vector based on oq */ 318f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].interrup_vec_cnt_delay = (i << 24); 319f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].pi_virt = 320f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->memoryMap.region[PI + i].virt_ptr; 321f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K offsetob = i * 0x24; 322f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].ci_pci_bar = 323f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K get_pci_bar_index(pm8001_mr32(addressob, 324f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K offsetob + 0x14)); 325f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].ci_offset = 326f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(addressob, (offsetob + 0x18)); 327f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].consumer_idx = 0; 328f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[i].producer_index = 0; 329f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 330f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 331f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 332f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 333f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * update_main_config_table - update the main default table to the HBA. 334f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 335f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 336f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void update_main_config_table(struct pm8001_hba_info *pm8001_ha) 337f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 338f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void __iomem *address = pm8001_ha->main_cfg_tbl_addr; 339f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_IQNPPD_HPPD_OFFSET, 340f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.inbound_q_nppd_hppd); 341f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_EVENT_LOG_ADDR_HI, 342f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.upper_event_log_addr); 343f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_EVENT_LOG_ADDR_LO, 344f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.lower_event_log_addr); 345f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_EVENT_LOG_BUFF_SIZE, 346f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_size); 347f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_EVENT_LOG_OPTION, 348f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.event_log_severity); 349f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_PCS_EVENT_LOG_ADDR_HI, 350f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.upper_pcs_event_log_addr); 351f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_PCS_EVENT_LOG_ADDR_LO, 352f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.lower_pcs_event_log_addr); 353f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_PCS_EVENT_LOG_BUFF_SIZE, 354f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.pcs_event_log_size); 355f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_PCS_EVENT_LOG_OPTION, 356f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.pcs_event_log_severity); 357f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_FATAL_ERROR_INTERRUPT, 358f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_interrupt); 359c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_mw32(address, MAIN_EVENT_CRC_CHECK, 360c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.crc_core_dump); 361f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 362f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* SPCv specific */ 363f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.gpio_led_mapping &= 0xCFFFFFFF; 364f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Set GPIOLED to 0x2 for LED indicator */ 365f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.gpio_led_mapping |= 0x20000000; 366f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_GPIO_LED_FLAGS_OFFSET, 367f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.gpio_led_mapping); 368f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 369f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_PORT_RECOVERY_TIMER, 370f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.port_recovery_timer); 371f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, MAIN_INT_REASSERTION_DELAY, 372f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl.pm80xx_tbl.interrupt_reassertion_delay); 373f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 374f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 375f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 376f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * update_inbnd_queue_table - update the inbound queue table to the HBA. 377f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 378f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 379f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void update_inbnd_queue_table(struct pm8001_hba_info *pm8001_ha, 380f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int number) 381f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 382f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void __iomem *address = pm8001_ha->inbnd_q_tbl_addr; 383f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u16 offset = number * 0x20; 384f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, offset + IB_PROPERITY_OFFSET, 385f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[number].element_pri_size_cnt); 386f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, offset + IB_BASE_ADDR_HI_OFFSET, 387f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[number].upper_base_addr); 388f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, offset + IB_BASE_ADDR_LO_OFFSET, 389f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[number].lower_base_addr); 390f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, offset + IB_CI_BASE_ADDR_HI_OFFSET, 391f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[number].ci_upper_base_addr); 392f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, offset + IB_CI_BASE_ADDR_LO_OFFSET, 393f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl[number].ci_lower_base_addr); 394f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 395f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 396f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 397f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * update_outbnd_queue_table - update the outbound queue table to the HBA. 398f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 399f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 400f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void update_outbnd_queue_table(struct pm8001_hba_info *pm8001_ha, 401f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int number) 402f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 403f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void __iomem *address = pm8001_ha->outbnd_q_tbl_addr; 404f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u16 offset = number * 0x24; 405f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, offset + OB_PROPERITY_OFFSET, 406f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[number].element_size_cnt); 407f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, offset + OB_BASE_ADDR_HI_OFFSET, 408f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[number].upper_base_addr); 409f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, offset + OB_BASE_ADDR_LO_OFFSET, 410f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[number].lower_base_addr); 411f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, offset + OB_PI_BASE_ADDR_HI_OFFSET, 412f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[number].pi_upper_base_addr); 413f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, offset + OB_PI_BASE_ADDR_LO_OFFSET, 414f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[number].pi_lower_base_addr); 415f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mw32(address, offset + OB_INTERRUPT_COALES_OFFSET, 416f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl[number].interrup_vec_cnt_delay); 417f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 418f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 419f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 420f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * mpi_init_check - check firmware initialization status. 421f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 422f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 423f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_init_check(struct pm8001_hba_info *pm8001_ha) 424f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 425f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 max_wait_count; 426f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 value; 427f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 gst_len_mpistate; 428f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 429f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Write bit0=1 to Inbound DoorBell Register to tell the SPC FW the 430f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K table is updated */ 431f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cw32(pm8001_ha, 0, MSGU_IBDB_SET, SPCv_MSGU_CFG_TABLE_UPDATE); 432f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* wait until Inbound DoorBell Clear Register toggled */ 433f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K max_wait_count = 2 * 1000 * 1000;/* 2 sec for spcv/ve */ 434f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K do { 435f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K udelay(1); 436f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K value = pm8001_cr32(pm8001_ha, 0, MSGU_IBDB_SET); 437f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K value &= SPCv_MSGU_CFG_TABLE_UPDATE; 438f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } while ((value != 0) && (--max_wait_count)); 439f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 440f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!max_wait_count) 441f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -1; 442f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* check the MPI-State for initialization upto 100ms*/ 443f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K max_wait_count = 100 * 1000;/* 100 msec */ 444f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K do { 445f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K udelay(1); 446f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K gst_len_mpistate = 447f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 448f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K GST_GSTLEN_MPIS_OFFSET); 449f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } while ((GST_MPI_STATE_INIT != 450f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (gst_len_mpistate & GST_MPI_STATE_MASK)) && (--max_wait_count)); 451f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!max_wait_count) 452f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -1; 453f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 454f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* check MPI Initialization error */ 455f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K gst_len_mpistate = gst_len_mpistate >> 16; 456f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (0x0000 != gst_len_mpistate) 457f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -1; 458f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 459f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 460f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 461f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 462f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 463f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * check_fw_ready - The LLDD check if the FW is ready, if not, return error. 464f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 465f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 466f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int check_fw_ready(struct pm8001_hba_info *pm8001_ha) 467f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 468f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 value; 469f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 max_wait_count; 470f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 max_wait_time; 471f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int ret = 0; 472f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 473f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* reset / PCIe ready */ 474f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K max_wait_time = max_wait_count = 100 * 1000; /* 100 milli sec */ 475f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K do { 476f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K udelay(1); 477f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K value = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1); 478f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } while ((value == 0xFFFFFFFF) && (--max_wait_count)); 479f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 480f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* check ila status */ 481f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K max_wait_time = max_wait_count = 1000 * 1000; /* 1000 milli sec */ 482f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K do { 483f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K udelay(1); 484f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K value = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1); 485f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } while (((value & SCRATCH_PAD_ILA_READY) != 486f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD_ILA_READY) && (--max_wait_count)); 487f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!max_wait_count) 488f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = -1; 489f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K else { 490f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 491f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" ila ready status in %d millisec\n", 492f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (max_wait_time - max_wait_count))); 493f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 494f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 495f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* check RAAE status */ 496f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K max_wait_time = max_wait_count = 1800 * 1000; /* 1800 milli sec */ 497f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K do { 498f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K udelay(1); 499f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K value = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1); 500f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } while (((value & SCRATCH_PAD_RAAE_READY) != 501f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD_RAAE_READY) && (--max_wait_count)); 502f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!max_wait_count) 503f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = -1; 504f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K else { 505f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 506f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" raae ready status in %d millisec\n", 507f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (max_wait_time - max_wait_count))); 508f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 509f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 510f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* check iop0 status */ 511f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K max_wait_time = max_wait_count = 600 * 1000; /* 600 milli sec */ 512f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K do { 513f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K udelay(1); 514f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K value = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1); 515f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } while (((value & SCRATCH_PAD_IOP0_READY) != SCRATCH_PAD_IOP0_READY) && 516f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (--max_wait_count)); 517f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!max_wait_count) 518f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = -1; 519f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K else { 520f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 521f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" iop0 ready status in %d millisec\n", 522f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (max_wait_time - max_wait_count))); 523f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 524f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 525f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* check iop1 status only for 16 port controllers */ 526f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((pm8001_ha->chip_id != chip_8008) && 527f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (pm8001_ha->chip_id != chip_8009)) { 528f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* 200 milli sec */ 529f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K max_wait_time = max_wait_count = 200 * 1000; 530f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K do { 531f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K udelay(1); 532f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K value = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1); 533f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } while (((value & SCRATCH_PAD_IOP1_READY) != 534f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD_IOP1_READY) && (--max_wait_count)); 535f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!max_wait_count) 536f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = -1; 537f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K else { 538f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 539f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "iop1 ready status in %d millisec\n", 540f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (max_wait_time - max_wait_count))); 541f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 542f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 543f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 544f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return ret; 545f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 546f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 547f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void init_pci_device_addresses(struct pm8001_hba_info *pm8001_ha) 548f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 549f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void __iomem *base_addr; 550f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 value; 551f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 offset; 552f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 pcibar; 553f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 pcilogic; 554f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 555f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K value = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_0); 556f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K offset = value & 0x03FFFFFF; /* scratch pad 0 TBL address */ 557f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 558f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 559f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("Scratchpad 0 Offset: 0x%x value 0x%x\n", 560f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K offset, value)); 561f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pcilogic = (value & 0xFC000000) >> 26; 562f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pcibar = get_pci_bar_index(pcilogic); 563f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 564f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("Scratchpad 0 PCI BAR: %d\n", pcibar)); 565f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl_addr = base_addr = 566f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->io_mem[pcibar].memvirtaddr + offset; 567f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->general_stat_tbl_addr = 568f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K base_addr + (pm8001_cr32(pm8001_ha, pcibar, offset + 0x18) & 569f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 0xFFFFFF); 570f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl_addr = 571f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K base_addr + (pm8001_cr32(pm8001_ha, pcibar, offset + 0x1C) & 572f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 0xFFFFFF); 573f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl_addr = 574f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K base_addr + (pm8001_cr32(pm8001_ha, pcibar, offset + 0x20) & 575f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 0xFFFFFF); 576f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->ivt_tbl_addr = 577f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K base_addr + (pm8001_cr32(pm8001_ha, pcibar, offset + 0x8C) & 578f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 0xFFFFFF); 579f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->pspa_q_tbl_addr = 580f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K base_addr + (pm8001_cr32(pm8001_ha, pcibar, offset + 0x90) & 581f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 0xFFFFFF); 582f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 583f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 584f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("GST OFFSET 0x%x\n", 585f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cr32(pm8001_ha, pcibar, offset + 0x18))); 586f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 587f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("INBND OFFSET 0x%x\n", 588f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cr32(pm8001_ha, pcibar, offset + 0x1C))); 589f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 590f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OBND OFFSET 0x%x\n", 591f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cr32(pm8001_ha, pcibar, offset + 0x20))); 592f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 593f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IVT OFFSET 0x%x\n", 594f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cr32(pm8001_ha, pcibar, offset + 0x8C))); 595f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 596f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("PSPA OFFSET 0x%x\n", 597f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cr32(pm8001_ha, pcibar, offset + 0x90))); 598f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 599f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("addr - main cfg %p general status %p\n", 600f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->main_cfg_tbl_addr, 601f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->general_stat_tbl_addr)); 602f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 603f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("addr - inbnd %p obnd %p\n", 604f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->inbnd_q_tbl_addr, 605f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->outbnd_q_tbl_addr)); 606f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 607f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("addr - pspa %p ivt %p\n", 608f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->pspa_q_tbl_addr, 609f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->ivt_tbl_addr)); 610f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 611f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 612f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 613f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm80xx_set_thermal_config - support the thermal configuration 614f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information. 615f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 616a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel Kint 617f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kpm80xx_set_thermal_config(struct pm8001_hba_info *pm8001_ha) 618f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 619f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct set_ctrl_cfg_req payload; 620f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct inbound_queue_table *circularQ; 621f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int rc; 622f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 tag; 623f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 opc = OPC_INB_SET_CONTROLLER_CONFIG; 624f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 625f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memset(&payload, 0, sizeof(struct set_ctrl_cfg_req)); 626f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K rc = pm8001_tag_alloc(pm8001_ha, &tag); 627f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (rc) 628f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -1; 629f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 630f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[0]; 631f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.tag = cpu_to_le32(tag); 632f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.cfg_pg[0] = (THERMAL_LOG_ENABLE << 9) | 633f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (THERMAL_ENABLE << 8) | THERMAL_OP_CODE; 634f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.cfg_pg[1] = (LTEMPHIL << 24) | (RTEMPHIL << 8); 635f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 636f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, 0); 637f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return rc; 638f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 639f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 640f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 641f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 642a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K* pm80xx_set_sas_protocol_timer_config - support the SAS Protocol 643a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K* Timer configuration page 644a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K* @pm8001_ha: our hba card information. 645a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K*/ 646a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel Kstatic int 647a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel Kpm80xx_set_sas_protocol_timer_config(struct pm8001_hba_info *pm8001_ha) 648a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K{ 649a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K struct set_ctrl_cfg_req payload; 650a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K struct inbound_queue_table *circularQ; 651a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K SASProtocolTimerConfig_t SASConfigPage; 652a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K int rc; 653a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K u32 tag; 654a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K u32 opc = OPC_INB_SET_CONTROLLER_CONFIG; 655a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 656a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K memset(&payload, 0, sizeof(struct set_ctrl_cfg_req)); 657a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K memset(&SASConfigPage, 0, sizeof(SASProtocolTimerConfig_t)); 658a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 659a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K rc = pm8001_tag_alloc(pm8001_ha, &tag); 660a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 661a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K if (rc) 662a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K return -1; 663a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 664a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[0]; 665a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K payload.tag = cpu_to_le32(tag); 666a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 667a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K SASConfigPage.pageCode = SAS_PROTOCOL_TIMER_CONFIG_PAGE; 668a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K SASConfigPage.MST_MSI = 3 << 15; 669a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K SASConfigPage.STP_SSP_MCT_TMO = (STP_MCT_TMO << 16) | SSP_MCT_TMO; 670a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K SASConfigPage.STP_FRM_TMO = (SAS_MAX_OPEN_TIME << 24) | 671a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K (SMP_MAX_CONN_TIMER << 16) | STP_FRM_TIMER; 672a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K SASConfigPage.STP_IDLE_TMO = STP_IDLE_TIME; 673a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 674a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K if (SASConfigPage.STP_IDLE_TMO > 0x3FFFFFF) 675a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K SASConfigPage.STP_IDLE_TMO = 0x3FFFFFF; 676a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 677a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 678a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K SASConfigPage.OPNRJT_RTRY_INTVL = (SAS_MFD << 16) | 679a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K SAS_OPNRJT_RTRY_INTVL; 680a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO = (SAS_DOPNRJT_RTRY_TMO << 16) 681a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K | SAS_COPNRJT_RTRY_TMO; 682a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR = (SAS_DOPNRJT_RTRY_THR << 16) 683a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K | SAS_COPNRJT_RTRY_THR; 684a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K SASConfigPage.MAX_AIP = SAS_MAX_AIP; 685a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 686a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_INIT_DBG(pm8001_ha, 687a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K pm8001_printk("SASConfigPage.pageCode " 688a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K "0x%08x\n", SASConfigPage.pageCode)); 689a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_INIT_DBG(pm8001_ha, 690a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K pm8001_printk("SASConfigPage.MST_MSI " 691a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K " 0x%08x\n", SASConfigPage.MST_MSI)); 692a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_INIT_DBG(pm8001_ha, 693a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K pm8001_printk("SASConfigPage.STP_SSP_MCT_TMO " 694a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K " 0x%08x\n", SASConfigPage.STP_SSP_MCT_TMO)); 695a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_INIT_DBG(pm8001_ha, 696a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K pm8001_printk("SASConfigPage.STP_FRM_TMO " 697a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K " 0x%08x\n", SASConfigPage.STP_FRM_TMO)); 698a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_INIT_DBG(pm8001_ha, 699a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K pm8001_printk("SASConfigPage.STP_IDLE_TMO " 700a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K " 0x%08x\n", SASConfigPage.STP_IDLE_TMO)); 701a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_INIT_DBG(pm8001_ha, 702a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K pm8001_printk("SASConfigPage.OPNRJT_RTRY_INTVL " 703a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K " 0x%08x\n", SASConfigPage.OPNRJT_RTRY_INTVL)); 704a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_INIT_DBG(pm8001_ha, 705a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K pm8001_printk("SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO " 706a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K " 0x%08x\n", SASConfigPage.Data_Cmd_OPNRJT_RTRY_TMO)); 707a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_INIT_DBG(pm8001_ha, 708a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K pm8001_printk("SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR " 709a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K " 0x%08x\n", SASConfigPage.Data_Cmd_OPNRJT_RTRY_THR)); 710a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_INIT_DBG(pm8001_ha, pm8001_printk("SASConfigPage.MAX_AIP " 711a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K " 0x%08x\n", SASConfigPage.MAX_AIP)); 712a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 713a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K memcpy(&payload.cfg_pg, &SASConfigPage, 714a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K sizeof(SASProtocolTimerConfig_t)); 715a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 716a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, 0); 717a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 718a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K return rc; 719a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K} 720a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K 721a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K/** 722f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm80xx_get_encrypt_info - Check for encryption 723f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information. 724f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 725f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int 726f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kpm80xx_get_encrypt_info(struct pm8001_hba_info *pm8001_ha) 727f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 728f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 scratch3_value; 729f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int ret; 730f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 731f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Read encryption status from SCRATCH PAD 3 */ 732f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K scratch3_value = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_3); 733f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 734f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((scratch3_value & SCRATCH_PAD3_ENC_MASK) == 735f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_ENC_READY) { 736f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (scratch3_value & SCRATCH_PAD3_XTS_ENABLED) 737f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.cipher_mode = CIPHER_MODE_XTS; 738f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == 739f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_SMF_ENABLED) 740f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMF; 741f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == 742f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_SMA_ENABLED) 743f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMA; 744f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == 745f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_SMB_ENABLED) 746f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMB; 747f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.status = 0; 748f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, pm8001_printk( 749f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Encryption: SCRATCH_PAD3_ENC_READY 0x%08X." 750f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Cipher mode 0x%x Sec mode 0x%x status 0x%x\n", 751f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K scratch3_value, pm8001_ha->encrypt_info.cipher_mode, 752f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode, 753f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.status)); 754f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = 0; 755f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if ((scratch3_value & SCRATCH_PAD3_ENC_READY) == 756f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_ENC_DISABLED) { 757f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, pm8001_printk( 758f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Encryption: SCRATCH_PAD3_ENC_DISABLED 0x%08X\n", 759f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K scratch3_value)); 760f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.status = 0xFFFFFFFF; 761f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.cipher_mode = 0; 762f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode = 0; 763f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 764f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if ((scratch3_value & SCRATCH_PAD3_ENC_MASK) == 765f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_ENC_DIS_ERR) { 766f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.status = 767f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (scratch3_value & SCRATCH_PAD3_ERR_CODE) >> 16; 768f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (scratch3_value & SCRATCH_PAD3_XTS_ENABLED) 769f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.cipher_mode = CIPHER_MODE_XTS; 770f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == 771f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_SMF_ENABLED) 772f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMF; 773f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == 774f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_SMA_ENABLED) 775f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMA; 776f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == 777f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_SMB_ENABLED) 778f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMB; 779f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, pm8001_printk( 780f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Encryption: SCRATCH_PAD3_DIS_ERR 0x%08X." 781f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Cipher mode 0x%x sec mode 0x%x status 0x%x\n", 782f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K scratch3_value, pm8001_ha->encrypt_info.cipher_mode, 783f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode, 784f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.status)); 785f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = -1; 786f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if ((scratch3_value & SCRATCH_PAD3_ENC_MASK) == 787f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_ENC_ENA_ERR) { 788f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 789f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.status = 790f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (scratch3_value & SCRATCH_PAD3_ERR_CODE) >> 16; 791f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (scratch3_value & SCRATCH_PAD3_XTS_ENABLED) 792f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.cipher_mode = CIPHER_MODE_XTS; 793f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == 794f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_SMF_ENABLED) 795f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMF; 796f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == 797f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_SMA_ENABLED) 798f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMA; 799f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((scratch3_value & SCRATCH_PAD3_SM_MASK) == 800f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD3_SMB_ENABLED) 801f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode = SEC_MODE_SMB; 802f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 803f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, pm8001_printk( 804f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Encryption: SCRATCH_PAD3_ENA_ERR 0x%08X." 805f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Cipher mode 0x%x sec mode 0x%x status 0x%x\n", 806f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K scratch3_value, pm8001_ha->encrypt_info.cipher_mode, 807f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.sec_mode, 808f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->encrypt_info.status)); 809f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = -1; 810f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 811f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return ret; 812f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 813f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 814f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 815f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm80xx_encrypt_update - update flash with encryption informtion 816f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information. 817f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 818f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int pm80xx_encrypt_update(struct pm8001_hba_info *pm8001_ha) 819f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 820f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct kek_mgmt_req payload; 821f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct inbound_queue_table *circularQ; 822f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int rc; 823f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 tag; 824f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 opc = OPC_INB_KEK_MANAGEMENT; 825f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 826f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memset(&payload, 0, sizeof(struct kek_mgmt_req)); 827f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K rc = pm8001_tag_alloc(pm8001_ha, &tag); 828f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (rc) 829f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -1; 830f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 831f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[0]; 832f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.tag = cpu_to_le32(tag); 833f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Currently only one key is used. New KEK index is 1. 834f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * Current KEK index is 1. Store KEK to NVRAM is 1. 835f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 836f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.new_curidx_ksop = ((1 << 24) | (1 << 16) | (1 << 8) | 837f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K KEK_MGMT_SUBOP_KEYCARDUPDATE); 838f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 839f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, 0); 840f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 841f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return rc; 842f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 843f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 844f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 845f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm8001_chip_init - the main init function that initialize whole PM8001 chip. 846f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 847f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 848f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int pm80xx_chip_init(struct pm8001_hba_info *pm8001_ha) 849f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 850f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int ret; 851f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 i = 0; 852f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 853f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* check the firmware status */ 854f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (-1 == check_fw_ready(pm8001_ha)) { 855f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, 856f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("Firmware is not ready!\n")); 857f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -EBUSY; 858f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 859f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 860f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Initialize pci space address eg: mpi offset */ 861f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K init_pci_device_addresses(pm8001_ha); 862f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K init_default_table_values(pm8001_ha); 863f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K read_main_config_table(pm8001_ha); 864f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K read_general_status_table(pm8001_ha); 865f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K read_inbnd_queue_table(pm8001_ha); 866f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K read_outbnd_queue_table(pm8001_ha); 867f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K read_phy_attr_table(pm8001_ha); 868f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 869f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* update main config table ,inbound table and outbound table */ 870f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K update_main_config_table(pm8001_ha); 871f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K for (i = 0; i < PM8001_MAX_SPCV_INB_NUM; i++) 872f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K update_inbnd_queue_table(pm8001_ha, i); 873f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K for (i = 0; i < PM8001_MAX_SPCV_OUTB_NUM; i++) 874f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K update_outbnd_queue_table(pm8001_ha, i); 875f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 876f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* notify firmware update finished and check initialization status */ 877f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (0 == mpi_init_check(pm8001_ha)) { 878f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 879f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("MPI initialize successful!\n")); 880f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else 881f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -EBUSY; 882f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 883a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K /* send SAS protocol timer configuration page to FW */ 884a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K ret = pm80xx_set_sas_protocol_timer_config(pm8001_ha); 885f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 886f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Check for encryption */ 887f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_ha->chip->encrypt) { 888f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 889f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("Checking for encryption\n")); 890f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = pm80xx_get_encrypt_info(pm8001_ha); 891f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (ret == -1) { 892f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 893f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("Encryption error !!\n")); 894f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_ha->encrypt_info.status == 0x81) { 895f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, pm8001_printk( 896f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Encryption enabled with error." 897f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Saving encryption key to flash\n")); 898f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_encrypt_update(pm8001_ha); 899f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 900f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 901f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 902f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 903f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 904f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 905f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_uninit_check(struct pm8001_hba_info *pm8001_ha) 906f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 907f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 max_wait_count; 908f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 value; 909f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 gst_len_mpistate; 910f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K init_pci_device_addresses(pm8001_ha); 911f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Write bit1=1 to Inbound DoorBell Register to tell the SPC FW the 912f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K table is stop */ 913f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cw32(pm8001_ha, 0, MSGU_IBDB_SET, SPCv_MSGU_CFG_TABLE_RESET); 914f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 915f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* wait until Inbound DoorBell Clear Register toggled */ 916f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K max_wait_count = 2 * 1000 * 1000; /* 2 sec for spcv/ve */ 917f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K do { 918f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K udelay(1); 919f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K value = pm8001_cr32(pm8001_ha, 0, MSGU_IBDB_SET); 920f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K value &= SPCv_MSGU_CFG_TABLE_RESET; 921f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } while ((value != 0) && (--max_wait_count)); 922f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 923f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!max_wait_count) { 924f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, 925f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("TIMEOUT:IBDB value/=%x\n", value)); 926f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -1; 927f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 928f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 929f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* check the MPI-State for termination in progress */ 930f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* wait until Inbound DoorBell Clear Register toggled */ 931f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K max_wait_count = 2 * 1000 * 1000; /* 2 sec for spcv/ve */ 932f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K do { 933f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K udelay(1); 934f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K gst_len_mpistate = 935f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mr32(pm8001_ha->general_stat_tbl_addr, 936f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K GST_GSTLEN_MPIS_OFFSET); 937f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (GST_MPI_STATE_UNINIT == 938f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (gst_len_mpistate & GST_MPI_STATE_MASK)) 939f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 940f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } while (--max_wait_count); 941f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!max_wait_count) { 942f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, 943f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" TIME OUT MPI State = 0x%x\n", 944f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K gst_len_mpistate & GST_MPI_STATE_MASK)); 945f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -1; 946f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 947f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 948f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 949f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 950f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 951f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 952f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm8001_chip_soft_rst - soft reset the PM8001 chip, so that the clear all 953f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * the FW register status to the originated status. 954f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 955f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 956f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 957f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int 958f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kpm80xx_chip_soft_rst(struct pm8001_hba_info *pm8001_ha) 959f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 960f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 regval; 961f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 bootloader_state; 962f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 963f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Check if MPI is in ready state to reset */ 964f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (mpi_uninit_check(pm8001_ha) != 0) { 965f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, 966f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("MPI state is not ready\n")); 967f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -1; 968f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 969f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 970f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* checked for reset register normal state; 0x0 */ 971f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K regval = pm8001_cr32(pm8001_ha, 0, SPC_REG_SOFT_RESET); 972f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 973f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("reset register before write : 0x%x\n", regval)); 974f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 975f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cw32(pm8001_ha, 0, SPC_REG_SOFT_RESET, SPCv_NORMAL_RESET_VALUE); 976f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mdelay(500); 977f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 978f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K regval = pm8001_cr32(pm8001_ha, 0, SPC_REG_SOFT_RESET); 979f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 980f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("reset register after write 0x%x\n", regval)); 981f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 982f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((regval & SPCv_SOFT_RESET_READ_MASK) == 983f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SPCv_SOFT_RESET_NORMAL_RESET_OCCURED) { 984f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 985f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" soft reset successful [regval: 0x%x]\n", 986f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K regval)); 987f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 988f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 989f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" soft reset failed [regval: 0x%x]\n", 990f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K regval)); 991f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 992f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* check bootloader is successfully executed or in HDA mode */ 993f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K bootloader_state = 994f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1) & 995f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD1_BOOTSTATE_MASK; 996f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 997f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (bootloader_state == SCRATCH_PAD1_BOOTSTATE_HDA_SEEPROM) { 998f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 999f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Bootloader state - HDA mode SEEPROM\n")); 1000f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (bootloader_state == 1001f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD1_BOOTSTATE_HDA_BOOTSTRAP) { 1002f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 1003f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Bootloader state - HDA mode Bootstrap Pin\n")); 1004f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (bootloader_state == 1005f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD1_BOOTSTATE_HDA_SOFTRESET) { 1006f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 1007f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Bootloader state - HDA mode soft reset\n")); 1008f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (bootloader_state == 1009f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SCRATCH_PAD1_BOOTSTATE_CRIT_ERROR) { 1010f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 1011f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Bootloader state-HDA mode critical error\n")); 1012f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1013f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -EBUSY; 1014f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1015f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1016f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* check the firmware status after reset */ 1017f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (-1 == check_fw_ready(pm8001_ha)) { 1018f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, 1019f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("Firmware is not ready!\n")); 1020f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -EBUSY; 1021f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1022f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 1023f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("SPCv soft reset Complete\n")); 1024f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 1025f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 1026f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1027f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void pm80xx_hw_chip_rst(struct pm8001_hba_info *pm8001_ha) 1028f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 1029f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 i; 1030f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1031f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 1032f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("chip reset start\n")); 1033f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1034f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* do SPCv chip reset. */ 1035f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cw32(pm8001_ha, 0, SPC_REG_SOFT_RESET, 0x11); 1036f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 1037f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("SPC soft reset Complete\n")); 1038f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1039f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Check this ..whether delay is required or no */ 1040f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* delay 10 usec */ 1041f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K udelay(10); 1042f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1043f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* wait for 20 msec until the firmware gets reloaded */ 1044f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K i = 20; 1045f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K do { 1046f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mdelay(1); 1047f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } while ((--i) != 0); 1048f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1049f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 1050f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("chip reset finished\n")); 1051f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 1052f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1053f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 1054f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm8001_chip_interrupt_enable - enable PM8001 chip interrupt 1055f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 1056f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 1057f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void 1058f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kpm80xx_chip_intx_interrupt_enable(struct pm8001_hba_info *pm8001_ha) 1059f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 1060f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, ODMR_CLEAR_ALL); 1061f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cw32(pm8001_ha, 0, MSGU_ODCR, ODCR_CLEAR_ALL); 1062f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 1063f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1064f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 1065f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm8001_chip_intx_interrupt_disable- disable PM8001 chip interrupt 1066f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 1067f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 1068f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void 1069f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kpm80xx_chip_intx_interrupt_disable(struct pm8001_hba_info *pm8001_ha) 1070f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 1071f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cw32(pm8001_ha, 0, MSGU_ODMR_CLR, ODMR_MASK_ALL); 1072f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 1073f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1074f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 1075f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm8001_chip_interrupt_enable - enable PM8001 chip interrupt 1076f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 1077f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 1078f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void 1079f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kpm80xx_chip_interrupt_enable(struct pm8001_hba_info *pm8001_ha, u8 vec) 1080f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 1081f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K#ifdef PM8001_USE_MSIX 1082f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 mask; 1083f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mask = (u32)(1 << vec); 1084f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1085f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cw32(pm8001_ha, 0, MSGU_ODMR_CLR, (u32)(mask & 0xFFFFFFFF)); 1086f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1087f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K#endif 1088f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_chip_intx_interrupt_enable(pm8001_ha); 1089f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1090f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 1091f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1092f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 1093f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm8001_chip_interrupt_disable- disable PM8001 chip interrupt 1094f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 1095f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 1096f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void 1097f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kpm80xx_chip_interrupt_disable(struct pm8001_hba_info *pm8001_ha, u8 vec) 1098f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 1099f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K#ifdef PM8001_USE_MSIX 1100f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 mask; 1101f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (vec == 0xFF) 1102f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mask = 0xFFFFFFFF; 1103f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K else 1104f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mask = (u32)(1 << vec); 1105f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, (u32)(mask & 0xFFFFFFFF)); 1106f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1107f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K#endif 1108f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_chip_intx_interrupt_disable(pm8001_ha); 1109f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 1110f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1111c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel Kstatic void pm80xx_send_abort_all(struct pm8001_hba_info *pm8001_ha, 1112c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct pm8001_device *pm8001_ha_dev) 1113c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K{ 1114c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K int res; 1115c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K u32 ccb_tag; 1116c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct pm8001_ccb_info *ccb; 1117c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct sas_task *task = NULL; 1118c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct task_abort_req task_abort; 1119c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct inbound_queue_table *circularQ; 1120c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K u32 opc = OPC_INB_SATA_ABORT; 1121c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K int ret; 1122c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1123c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (!pm8001_ha_dev) { 1124c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K PM8001_FAIL_DBG(pm8001_ha, pm8001_printk("dev is null\n")); 1125c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 1126c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 1127c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1128c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task = sas_alloc_slow_task(GFP_ATOMIC); 1129c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1130c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (!task) { 1131c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K PM8001_FAIL_DBG(pm8001_ha, pm8001_printk("cannot " 1132c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K "allocate task\n")); 1133c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 1134c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 1135c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1136c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task->task_done = pm8001_task_done; 1137c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1138c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); 1139c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (res) 1140c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 1141c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1142c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K ccb = &pm8001_ha->ccb_info[ccb_tag]; 1143c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K ccb->device = pm8001_ha_dev; 1144c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K ccb->ccb_tag = ccb_tag; 1145c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K ccb->task = task; 1146c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1147c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[0]; 1148c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1149c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K memset(&task_abort, 0, sizeof(task_abort)); 1150c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task_abort.abort_all = cpu_to_le32(1); 1151c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task_abort.device_id = cpu_to_le32(pm8001_ha_dev->device_id); 1152c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task_abort.tag = cpu_to_le32(ccb_tag); 1153c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1154c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &task_abort, 0); 1155c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1156c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K} 1157c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1158c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel Kstatic void pm80xx_send_read_log(struct pm8001_hba_info *pm8001_ha, 1159c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct pm8001_device *pm8001_ha_dev) 1160c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K{ 1161c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct sata_start_req sata_cmd; 1162c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K int res; 1163c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K u32 ccb_tag; 1164c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct pm8001_ccb_info *ccb; 1165c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct sas_task *task = NULL; 1166c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct host_to_dev_fis fis; 1167c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct domain_device *dev; 1168c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct inbound_queue_table *circularQ; 1169c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K u32 opc = OPC_INB_SATA_HOST_OPSTART; 1170c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1171c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task = sas_alloc_slow_task(GFP_ATOMIC); 1172c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1173c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (!task) { 1174c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K PM8001_FAIL_DBG(pm8001_ha, 1175c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_printk("cannot allocate task !!!\n")); 1176c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 1177c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 1178c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task->task_done = pm8001_task_done; 1179c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1180c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K res = pm8001_tag_alloc(pm8001_ha, &ccb_tag); 1181c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (res) { 1182c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K PM8001_FAIL_DBG(pm8001_ha, 1183c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_printk("cannot allocate tag !!!\n")); 1184c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 1185c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 1186c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1187c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K /* allocate domain device by ourselves as libsas 1188c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K * is not going to provide any 1189c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K */ 1190c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K dev = kzalloc(sizeof(struct domain_device), GFP_ATOMIC); 1191c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (!dev) { 1192c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K PM8001_FAIL_DBG(pm8001_ha, 1193c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_printk("Domain device cannot be allocated\n")); 1194c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K sas_free_task(task); 1195c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 1196c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } else { 1197c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task->dev = dev; 1198c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task->dev->lldd_dev = pm8001_ha_dev; 1199c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 1200c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1201c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K ccb = &pm8001_ha->ccb_info[ccb_tag]; 1202c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K ccb->device = pm8001_ha_dev; 1203c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K ccb->ccb_tag = ccb_tag; 1204c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K ccb->task = task; 1205c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_ha_dev->id |= NCQ_READ_LOG_FLAG; 1206c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_ha_dev->id |= NCQ_2ND_RLE_FLAG; 1207c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1208c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K memset(&sata_cmd, 0, sizeof(sata_cmd)); 1209c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[0]; 1210c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1211c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K /* construct read log FIS */ 1212c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K memset(&fis, 0, sizeof(struct host_to_dev_fis)); 1213c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K fis.fis_type = 0x27; 1214c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K fis.flags = 0x80; 1215c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K fis.command = ATA_CMD_READ_LOG_EXT; 1216c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K fis.lbal = 0x10; 1217c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K fis.sector_count = 0x1; 1218c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1219c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K sata_cmd.tag = cpu_to_le32(ccb_tag); 1220c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); 1221c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K sata_cmd.ncqtag_atap_dir_m_dad |= ((0x1 << 7) | (0x5 << 9)); 1222c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K memcpy(&sata_cmd.sata_fis, &fis, sizeof(struct host_to_dev_fis)); 1223c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1224c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K res = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &sata_cmd, 0); 1225c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1226c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K} 1227c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1228f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 1229f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * mpi_ssp_completion- process the event that FW response to the SSP request. 1230f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 1231f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: the message contents of this outbound message. 1232f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * 1233f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * When FW has completed a ssp request for example a IO request, after it has 1234f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * filled the SG data with the data, it will trigger this event represent 1235f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * that he has finished the job,please check the coresponding buffer. 1236f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * So we will tell the caller who maybe waiting the result to tell upper layer 1237f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * that the task has been finished. 1238f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 1239f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void 1240f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kmpi_ssp_completion(struct pm8001_hba_info *pm8001_ha , void *piomb) 1241f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 1242f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sas_task *t; 1243f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_ccb_info *ccb; 1244f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K unsigned long flags; 1245f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 status; 1246f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 param; 1247f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 tag; 1248f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct ssp_completion_resp *psspPayload; 1249f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct task_status_struct *ts; 1250f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct ssp_response_iu *iu; 1251f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_device *pm8001_dev; 1252f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K psspPayload = (struct ssp_completion_resp *)(piomb + 4); 1253f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K status = le32_to_cpu(psspPayload->status); 1254f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K tag = le32_to_cpu(psspPayload->tag); 1255f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb = &pm8001_ha->ccb_info[tag]; 1256f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((status == IO_ABORTED) && ccb->open_retry) { 1257f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Being completed by another */ 1258f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb->open_retry = 0; 1259f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1260f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1261f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev = ccb->device; 1262f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K param = le32_to_cpu(psspPayload->param); 1263f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t = ccb->task; 1264f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1265f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (status && status != IO_UNDERFLOW) 1266f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, 1267f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("sas IO status 0x%x\n", status)); 1268f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (unlikely(!t || !t->lldd_task || !t->dev)) 1269f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1270f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts = &t->task_status; 1271f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K switch (status) { 1272f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_SUCCESS: 1273f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1274f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_SUCCESS ,param = 0x%x\n", 1275f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K param)); 1276f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (param == 0) { 1277f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1278f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAM_STAT_GOOD; 1279f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 1280f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1281f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_PROTO_RESPONSE; 1282f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->residual = param; 1283f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K iu = &psspPayload->ssp_resp_iu; 1284f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ssp_task_response(pm8001_ha->dev, t, iu); 1285f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1286f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_dev) 1287f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->running_req--; 1288f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1289f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_ABORTED: 1290f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1291f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_ABORTED IOMB Tag\n")); 1292f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1293f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_ABORTED_TASK; 1294f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1295f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_UNDERFLOW: 1296f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* SSP Completion with error */ 1297f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1298f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_UNDERFLOW ,param = 0x%x\n", 1299f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K param)); 1300f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1301f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_UNDERRUN; 1302f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->residual = param; 1303f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_dev) 1304f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->running_req--; 1305f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1306f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_NO_DEVICE: 1307f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1308f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_NO_DEVICE\n")); 1309f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_UNDELIVERED; 1310f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_PHY_DOWN; 1311f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1312f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_BREAK: 1313f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1314f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_BREAK\n")); 1315f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1316f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1317f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Force the midlayer to retry */ 1318f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 1319f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1320f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_PHY_NOT_READY: 1321f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1322f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_PHY_NOT_READY\n")); 1323f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1324f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1325f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 1326f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1327f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: 1328f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1329f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED\n")); 1330f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1331f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1332f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_EPROTO; 1333f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1334f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_ZONE_VIOLATION: 1335f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1336f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_ZONE_VIOLATION\n")); 1337f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1338f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1339f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_UNKNOWN; 1340f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1341f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_BREAK: 1342f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1343f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_BREAK\n")); 1344f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1345f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1346f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 1347f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1348f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: 1349a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_XFER_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED: 1350a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO: 1351a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST: 1352a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE: 1353a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED: 1354f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1355f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS\n")); 1356f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1357f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1358f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_UNKNOWN; 1359f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!t->uldd_task) 1360f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_handle_event(pm8001_ha, 1361f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev, 1362f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); 1363f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1364f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_BAD_DESTINATION: 1365f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1366f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_BAD_DESTINATION\n")); 1367f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1368f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1369f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_BAD_DEST; 1370f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1371f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: 1372f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 1373f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED\n")); 1374f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1375f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1376f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_CONN_RATE; 1377f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1378f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_WRONG_DESTINATION: 1379f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1380f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_WRONG_DESTINATION\n")); 1381f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_UNDELIVERED; 1382f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1383f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_WRONG_DEST; 1384f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1385f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_NAK_RECEIVED: 1386f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1387f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_NAK_RECEIVED\n")); 1388f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1389f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1390f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 1391f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1392f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_ACK_NAK_TIMEOUT: 1393f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1394f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_ACK_NAK_TIMEOUT\n")); 1395f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1396f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_NAK_R_ERR; 1397f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1398f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_DMA: 1399f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1400f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_DMA\n")); 1401f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1402f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1403f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1404f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_OPEN_RETRY_TIMEOUT: 1405f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1406f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_OPEN_RETRY_TIMEOUT\n")); 1407f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1408f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1409f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 1410f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1411f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_OFFSET_MISMATCH: 1412f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1413f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_OFFSET_MISMATCH\n")); 1414f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1415f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1416f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1417f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_PORT_IN_RESET: 1418f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1419f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_PORT_IN_RESET\n")); 1420f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1421f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1422f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1423f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_DS_NON_OPERATIONAL: 1424f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1425f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_DS_NON_OPERATIONAL\n")); 1426f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1427f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1428f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!t->uldd_task) 1429f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_handle_event(pm8001_ha, 1430f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev, 1431f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K IO_DS_NON_OPERATIONAL); 1432f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1433f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_DS_IN_RECOVERY: 1434f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1435f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_DS_IN_RECOVERY\n")); 1436f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1437f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1438f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1439f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_TM_TAG_NOT_FOUND: 1440f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1441f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_TM_TAG_NOT_FOUND\n")); 1442f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1443f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1444f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1445f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_SSP_EXT_IU_ZERO_LEN_ERROR: 1446f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1447f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_SSP_EXT_IU_ZERO_LEN_ERROR\n")); 1448f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1449f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1450f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1451f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY: 1452f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1453f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY\n")); 1454f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1455f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1456f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 1457f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1458f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K default: 1459f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1460f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("Unknown status 0x%x\n", status)); 1461f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* not allowed case. Therefore, return failed status */ 1462f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1463f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1464f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1465f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1466f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1467f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("scsi_status = 0x%x\n ", 1468f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K psspPayload->ssp_resp_iu.status)); 1469f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irqsave(&t->task_state_lock, flags); 1470f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags &= ~SAS_TASK_STATE_PENDING; 1471f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags &= ~SAS_TASK_AT_INITIATOR; 1472f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags |= SAS_TASK_STATE_DONE; 1473f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { 1474f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&t->task_state_lock, flags); 1475f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, pm8001_printk( 1476f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "task 0x%p done with io_status 0x%x resp 0x%x " 1477f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "stat 0x%x but aborted by upper layer!\n", 1478f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t, status, ts->resp, ts->stat)); 1479f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 1480f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 1481f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&t->task_state_lock, flags); 1482f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 1483f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/* in order to force CPU ordering */ 1484f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 1485f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1486f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 1487f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1488f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/*See the comments for mpi_ssp_completion */ 1489f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void mpi_ssp_event(struct pm8001_hba_info *pm8001_ha , void *piomb) 1490f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 1491f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sas_task *t; 1492f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K unsigned long flags; 1493f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct task_status_struct *ts; 1494f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_ccb_info *ccb; 1495f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_device *pm8001_dev; 1496f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct ssp_event_resp *psspPayload = 1497f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (struct ssp_event_resp *)(piomb + 4); 1498f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 event = le32_to_cpu(psspPayload->event); 1499f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 tag = le32_to_cpu(psspPayload->tag); 1500f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 port_id = le32_to_cpu(psspPayload->port_id); 1501f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1502f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb = &pm8001_ha->ccb_info[tag]; 1503f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t = ccb->task; 1504f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev = ccb->device; 1505f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (event) 1506f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, 1507f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("sas IO status 0x%x\n", event)); 1508f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (unlikely(!t || !t->lldd_task || !t->dev)) 1509f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1510f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts = &t->task_status; 1511f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1512f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("port_id:0x%x, tag:0x%x, event:0x%x\n", 1513f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, tag, event)); 1514f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K switch (event) { 1515f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OVERFLOW: 1516f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk("IO_UNDERFLOW\n");) 1517f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1518f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_OVERRUN; 1519f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->residual = 0; 1520f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_dev) 1521f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->running_req--; 1522f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1523f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_BREAK: 1524f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1525f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_BREAK\n")); 1526f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_handle_event(pm8001_ha, t, IO_XFER_ERROR_BREAK); 1527f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1528f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_PHY_NOT_READY: 1529f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1530f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_PHY_NOT_READY\n")); 1531f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1532f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1533f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 1534f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1535f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: 1536f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 1537f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED\n")); 1538f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1539f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1540f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_EPROTO; 1541f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1542f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_ZONE_VIOLATION: 1543f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1544f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_ZONE_VIOLATION\n")); 1545f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1546f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1547f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_UNKNOWN; 1548f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1549f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_BREAK: 1550f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1551f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_BREAK\n")); 1552f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1553f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1554f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 1555f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1556f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: 1557a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_XFER_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED: 1558a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO: 1559a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST: 1560a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE: 1561a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED: 1562f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1563f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS\n")); 1564f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1565f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1566f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_UNKNOWN; 1567f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!t->uldd_task) 1568f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_handle_event(pm8001_ha, 1569f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev, 1570f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); 1571f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1572f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_BAD_DESTINATION: 1573f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1574f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_BAD_DESTINATION\n")); 1575f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1576f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1577f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_BAD_DEST; 1578f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1579f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: 1580f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 1581f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED\n")); 1582f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1583f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1584f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_CONN_RATE; 1585f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1586f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_WRONG_DESTINATION: 1587f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1588f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_WRONG_DESTINATION\n")); 1589f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1590f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1591f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_WRONG_DEST; 1592f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1593f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_NAK_RECEIVED: 1594f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1595f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_NAK_RECEIVED\n")); 1596f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1597f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1598f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 1599f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1600f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_ACK_NAK_TIMEOUT: 1601f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1602f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_ACK_NAK_TIMEOUT\n")); 1603f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1604f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_NAK_R_ERR; 1605f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1606f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_OPEN_RETRY_TIMEOUT: 1607f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1608f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_OPEN_RETRY_TIMEOUT\n")); 1609f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_handle_event(pm8001_ha, t, IO_XFER_OPEN_RETRY_TIMEOUT); 1610f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1611f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_UNEXPECTED_PHASE: 1612f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1613f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_UNEXPECTED_PHASE\n")); 1614f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1615f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_OVERRUN; 1616f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1617f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_XFER_RDY_OVERRUN: 1618f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1619f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_XFER_RDY_OVERRUN\n")); 1620f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1621f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_OVERRUN; 1622f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1623f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_XFER_RDY_NOT_EXPECTED: 1624f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1625f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_XFER_RDY_NOT_EXPECTED\n")); 1626f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1627f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_OVERRUN; 1628f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1629f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_CMD_ISSUE_ACK_NAK_TIMEOUT: 1630f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1631f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_CMD_ISSUE_ACK_NAK_TIMEOUT\n")); 1632f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1633f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_OVERRUN; 1634f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1635f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_OFFSET_MISMATCH: 1636f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1637f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_OFFSET_MISMATCH\n")); 1638f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1639f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_OVERRUN; 1640f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1641f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_XFER_ZERO_DATA_LEN: 1642f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1643f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_XFER_ZERO_DATA_LEN\n")); 1644f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1645f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_OVERRUN; 1646f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1647a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_XFER_ERROR_INTERNAL_CRC_ERROR: 1648a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_IO_DBG(pm8001_ha, 1649a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K pm8001_printk("IO_XFR_ERROR_INTERNAL_CRC_ERROR\n")); 1650a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K /* TBC: used default set values */ 1651a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K ts->resp = SAS_TASK_COMPLETE; 1652a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K ts->stat = SAS_DATA_OVERRUN; 1653a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K break; 1654f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_CMD_FRAME_ISSUED: 1655f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1656f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_CMD_FRAME_ISSUED\n")); 1657f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1658f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K default: 1659f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1660f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("Unknown status 0x%x\n", event)); 1661f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* not allowed case. Therefore, return failed status */ 1662f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1663f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_OVERRUN; 1664f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1665f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1666f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irqsave(&t->task_state_lock, flags); 1667f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags &= ~SAS_TASK_STATE_PENDING; 1668f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags &= ~SAS_TASK_AT_INITIATOR; 1669f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags |= SAS_TASK_STATE_DONE; 1670f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { 1671f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&t->task_state_lock, flags); 1672f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, pm8001_printk( 1673f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "task 0x%p done with event 0x%x resp 0x%x " 1674f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "stat 0x%x but aborted by upper layer!\n", 1675f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t, event, ts->resp, ts->stat)); 1676f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 1677f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 1678f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&t->task_state_lock, flags); 1679f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 1680f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/* in order to force CPU ordering */ 1681f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 1682f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1683f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 1684f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1685f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/*See the comments for mpi_ssp_completion */ 1686f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void 1687f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kmpi_sata_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) 1688f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 1689f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sas_task *t; 1690f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_ccb_info *ccb; 1691f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 param; 1692f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 status; 1693f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 tag; 1694f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sata_completion_resp *psataPayload; 1695f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct task_status_struct *ts; 1696f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct ata_task_resp *resp ; 1697f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 *sata_resp; 1698f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_device *pm8001_dev; 1699c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K unsigned long flags; 1700f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1701f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K psataPayload = (struct sata_completion_resp *)(piomb + 4); 1702f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K status = le32_to_cpu(psataPayload->status); 1703f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K tag = le32_to_cpu(psataPayload->tag); 1704f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1705c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (!tag) { 1706c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K PM8001_FAIL_DBG(pm8001_ha, 1707c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_printk("tag null\n")); 1708c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 1709c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 1710f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb = &pm8001_ha->ccb_info[tag]; 1711f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K param = le32_to_cpu(psataPayload->param); 1712c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (ccb) { 1713c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K t = ccb->task; 1714c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_dev = ccb->device; 1715c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } else { 1716c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K PM8001_FAIL_DBG(pm8001_ha, 1717c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_printk("ccb null\n")); 1718c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 1719c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 1720c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1721c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (t) { 1722c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (t->dev && (t->dev->lldd_dev)) 1723c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_dev = t->dev->lldd_dev; 1724c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } else { 1725c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K PM8001_FAIL_DBG(pm8001_ha, 1726c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_printk("task null\n")); 1727c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 1728c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 1729c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1730c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if ((pm8001_dev && !(pm8001_dev->id & NCQ_READ_LOG_FLAG)) 1731c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K && unlikely(!t || !t->lldd_task || !t->dev)) { 1732c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K PM8001_FAIL_DBG(pm8001_ha, 1733c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_printk("task or dev null\n")); 1734c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 1735c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 1736c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 1737f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts = &t->task_status; 1738c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (!ts) { 1739f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, 1740c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_printk("ts null\n")); 1741f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1742c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 1743f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 1744f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K switch (status) { 1745f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_SUCCESS: 1746f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk("IO_SUCCESS\n")); 1747f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (param == 0) { 1748f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1749f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAM_STAT_GOOD; 1750c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K /* check if response is for SEND READ LOG */ 1751c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (pm8001_dev && 1752c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K (pm8001_dev->id & NCQ_READ_LOG_FLAG)) { 1753c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K /* set new bit for abort_all */ 1754c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_dev->id |= NCQ_ABORT_ALL_FLAG; 1755c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K /* clear bit for read log */ 1756c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_dev->id = pm8001_dev->id & 0x7FFFFFFF; 1757c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm80xx_send_abort_all(pm8001_ha, pm8001_dev); 1758c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K /* Free the tag */ 1759c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_tag_free(pm8001_ha, tag); 1760c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K sas_free_task(t); 1761c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 1762c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 1763f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 1764f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 len; 1765f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1766f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_PROTO_RESPONSE; 1767f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->residual = param; 1768f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1769f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("SAS_PROTO_RESPONSE len = %d\n", 1770f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K param)); 1771f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_resp = &psataPayload->sata_resp[0]; 1772f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K resp = (struct ata_task_resp *)ts->buf; 1773f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (t->ata_task.dma_xfer == 0 && 1774f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->data_dir == PCI_DMA_FROMDEVICE) { 1775f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K len = sizeof(struct pio_setup_fis); 1776f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1777f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("PIO read len = %d\n", len)); 1778f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (t->ata_task.use_ncq) { 1779f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K len = sizeof(struct set_dev_bits_fis); 1780f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1781f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("FPDMA len = %d\n", len)); 1782f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 1783f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K len = sizeof(struct dev_to_host_fis); 1784f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1785f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("other len = %d\n", len)); 1786f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1787f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (SAS_STATUS_BUF_SIZE >= sizeof(*resp)) { 1788f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K resp->frame_len = len; 1789f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memcpy(&resp->ending_fis[0], sata_resp, len); 1790f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->buf_valid_size = sizeof(*resp); 1791f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else 1792f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1793f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("response to large\n")); 1794f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1795f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_dev) 1796f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->running_req--; 1797f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1798f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_ABORTED: 1799f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1800f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_ABORTED IOMB Tag\n")); 1801f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1802f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_ABORTED_TASK; 1803f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_dev) 1804f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->running_req--; 1805f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1806f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* following cases are to do cases */ 1807f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_UNDERFLOW: 1808f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* SATA Completion with error */ 1809f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1810f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_UNDERFLOW param = %d\n", param)); 1811f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1812f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_UNDERRUN; 1813f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->residual = param; 1814f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_dev) 1815f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->running_req--; 1816f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1817f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_NO_DEVICE: 1818f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1819f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_NO_DEVICE\n")); 1820f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_UNDELIVERED; 1821f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_PHY_DOWN; 1822f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1823f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_BREAK: 1824f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1825f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_BREAK\n")); 1826f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1827f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_INTERRUPTED; 1828f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1829f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_PHY_NOT_READY: 1830f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1831f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_PHY_NOT_READY\n")); 1832f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1833f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1834f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 1835f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1836f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: 1837f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 1838f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED\n")); 1839f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1840f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1841f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_EPROTO; 1842f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1843f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_ZONE_VIOLATION: 1844f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1845f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_ZONE_VIOLATION\n")); 1846f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1847f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1848f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_UNKNOWN; 1849f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1850f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_BREAK: 1851f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1852f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_BREAK\n")); 1853f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1854f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1855f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_CONT0; 1856f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1857f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: 1858a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_XFER_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED: 1859a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO: 1860a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST: 1861a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE: 1862a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED: 1863f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1864f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS\n")); 1865f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1866f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DEV_NO_RESPONSE; 1867f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!t->uldd_task) { 1868f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_handle_event(pm8001_ha, 1869f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev, 1870f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); 1871f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_UNDELIVERED; 1872f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_QUEUE_FULL; 1873f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 1874f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/*in order to force CPU ordering*/ 1875f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irq(&pm8001_ha->lock); 1876f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 1877f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irq(&pm8001_ha->lock); 1878f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1879f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1880f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1881f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_BAD_DESTINATION: 1882f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1883f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_BAD_DESTINATION\n")); 1884f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_UNDELIVERED; 1885f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1886f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_BAD_DEST; 1887f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!t->uldd_task) { 1888f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_handle_event(pm8001_ha, 1889f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev, 1890f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); 1891f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_UNDELIVERED; 1892f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_QUEUE_FULL; 1893f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 1894f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/*ditto*/ 1895f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irq(&pm8001_ha->lock); 1896f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 1897f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irq(&pm8001_ha->lock); 1898f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1899f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1900f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1901f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: 1902f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 1903f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED\n")); 1904f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1905f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1906f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_CONN_RATE; 1907f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1908f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY: 1909f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 1910f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY\n")); 1911f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1912f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DEV_NO_RESPONSE; 1913f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!t->uldd_task) { 1914f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_handle_event(pm8001_ha, 1915f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev, 1916f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K IO_OPEN_CNX_ERROR_STP_RESOURCES_BUSY); 1917f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_UNDELIVERED; 1918f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_QUEUE_FULL; 1919f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 1920f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/* ditto*/ 1921f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irq(&pm8001_ha->lock); 1922f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 1923f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irq(&pm8001_ha->lock); 1924f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1925f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1926f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1927f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_WRONG_DESTINATION: 1928f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1929f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_WRONG_DESTINATION\n")); 1930f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1931f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 1932f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_WRONG_DEST; 1933f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1934f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_NAK_RECEIVED: 1935f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1936f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_NAK_RECEIVED\n")); 1937f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1938f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_NAK_R_ERR; 1939f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1940f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_ACK_NAK_TIMEOUT: 1941f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1942f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_ACK_NAK_TIMEOUT\n")); 1943f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1944f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_NAK_R_ERR; 1945f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1946f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_DMA: 1947f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1948f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_DMA\n")); 1949f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1950f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_ABORTED_TASK; 1951f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1952f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_SATA_LINK_TIMEOUT: 1953f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1954f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_SATA_LINK_TIMEOUT\n")); 1955f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_UNDELIVERED; 1956f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DEV_NO_RESPONSE; 1957f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1958f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_REJECTED_NCQ_MODE: 1959f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1960f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_REJECTED_NCQ_MODE\n")); 1961f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1962f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_UNDERRUN; 1963f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1964f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_OPEN_RETRY_TIMEOUT: 1965f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1966f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_OPEN_RETRY_TIMEOUT\n")); 1967f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1968f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_TO; 1969f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1970f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_PORT_IN_RESET: 1971f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1972f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_PORT_IN_RESET\n")); 1973f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1974f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DEV_NO_RESPONSE; 1975f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1976f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_DS_NON_OPERATIONAL: 1977f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1978f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_DS_NON_OPERATIONAL\n")); 1979f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1980f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DEV_NO_RESPONSE; 1981f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!t->uldd_task) { 1982f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_handle_event(pm8001_ha, pm8001_dev, 1983f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K IO_DS_NON_OPERATIONAL); 1984f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_UNDELIVERED; 1985f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_QUEUE_FULL; 1986f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 1987f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/*ditto*/ 1988f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irq(&pm8001_ha->lock); 1989f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 1990f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irq(&pm8001_ha->lock); 1991f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 1992f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 1993f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 1994f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_DS_IN_RECOVERY: 1995f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 1996f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_DS_IN_RECOVERY\n")); 1997f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 1998f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DEV_NO_RESPONSE; 1999f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2000f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_DS_IN_ERROR: 2001f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2002f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_DS_IN_ERROR\n")); 2003f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2004f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DEV_NO_RESPONSE; 2005f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!t->uldd_task) { 2006f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_handle_event(pm8001_ha, pm8001_dev, 2007f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K IO_DS_IN_ERROR); 2008f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_UNDELIVERED; 2009f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_QUEUE_FULL; 2010f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 2011f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/*ditto*/ 2012f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irq(&pm8001_ha->lock); 2013f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 2014f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irq(&pm8001_ha->lock); 2015f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 2016f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2017f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2018f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY: 2019f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2020f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY\n")); 2021f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2022f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2023f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 2024f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K default: 2025f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2026f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("Unknown status 0x%x\n", status)); 2027f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* not allowed case. Therefore, return failed status */ 2028f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2029f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DEV_NO_RESPONSE; 2030f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2031f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2032f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irqsave(&t->task_state_lock, flags); 2033f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags &= ~SAS_TASK_STATE_PENDING; 2034f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags &= ~SAS_TASK_AT_INITIATOR; 2035f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags |= SAS_TASK_STATE_DONE; 2036f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { 2037f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&t->task_state_lock, flags); 2038f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, 2039f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("task 0x%p done with io_status 0x%x" 2040f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K " resp 0x%x stat 0x%x but aborted by upper layer!\n", 2041f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t, status, ts->resp, ts->stat)); 2042f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 2043f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (t->uldd_task) { 2044f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&t->task_state_lock, flags); 2045f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 2046f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/* ditto */ 2047f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irq(&pm8001_ha->lock); 2048f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 2049f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irq(&pm8001_ha->lock); 2050f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (!t->uldd_task) { 2051f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&t->task_state_lock, flags); 2052f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 2053f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/*ditto*/ 2054f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irq(&pm8001_ha->lock); 2055f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 2056f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irq(&pm8001_ha->lock); 2057f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2058f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 2059f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2060f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/*See the comments for mpi_ssp_completion */ 2061f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void mpi_sata_event(struct pm8001_hba_info *pm8001_ha , void *piomb) 2062f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 2063f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sas_task *t; 2064f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct task_status_struct *ts; 2065f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_ccb_info *ccb; 2066f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_device *pm8001_dev; 2067f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sata_event_resp *psataPayload = 2068f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (struct sata_event_resp *)(piomb + 4); 2069f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 event = le32_to_cpu(psataPayload->event); 2070f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 tag = le32_to_cpu(psataPayload->tag); 2071f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 port_id = le32_to_cpu(psataPayload->port_id); 2072c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K u32 dev_id = le32_to_cpu(psataPayload->device_id); 2073c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K unsigned long flags; 2074f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2075f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb = &pm8001_ha->ccb_info[tag]; 2076c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 2077c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (ccb) { 2078c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K t = ccb->task; 2079c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_dev = ccb->device; 2080c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } else { 2081c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K PM8001_FAIL_DBG(pm8001_ha, 2082c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_printk("No CCB !!!. returning\n")); 2083c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 2084c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 2085f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (event) 2086f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, 2087c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_printk("SATA EVENT 0x%x\n", event)); 2088c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 2089c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K /* Check if this is NCQ error */ 2090c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (event == IO_XFER_ERROR_ABORTED_NCQ_MODE) { 2091c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K /* find device using device id */ 2092c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_dev = pm8001_find_dev(pm8001_ha, dev_id); 2093c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K /* send read log extension */ 2094c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (pm8001_dev) 2095c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm80xx_send_read_log(pm8001_ha, pm8001_dev); 2096c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return; 2097c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 2098c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 2099c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (unlikely(!t || !t->lldd_task || !t->dev)) { 2100c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K PM8001_FAIL_DBG(pm8001_ha, 2101c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_printk("task or dev null\n")); 2102f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 2103c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 2104c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 2105f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts = &t->task_status; 2106f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2107f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("port_id:0x%x, tag:0x%x, event:0x%x\n", 2108f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, tag, event)); 2109f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K switch (event) { 2110f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OVERFLOW: 2111f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk("IO_UNDERFLOW\n")); 2112f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2113f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_OVERRUN; 2114f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->residual = 0; 2115f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_dev) 2116f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->running_req--; 2117f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2118f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_BREAK: 2119f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2120f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_BREAK\n")); 2121f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2122f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_INTERRUPTED; 2123f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2124f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_PHY_NOT_READY: 2125f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2126f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_PHY_NOT_READY\n")); 2127f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2128f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2129f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 2130f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2131f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: 2132f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 2133f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED\n")); 2134f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2135f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2136f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_EPROTO; 2137f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2138f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_ZONE_VIOLATION: 2139f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2140f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_ZONE_VIOLATION\n")); 2141f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2142f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2143f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_UNKNOWN; 2144f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2145f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_BREAK: 2146f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2147f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_BREAK\n")); 2148f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2149f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2150f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_CONT0; 2151f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2152f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: 2153a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_XFER_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED: 2154a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO: 2155a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST: 2156a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE: 2157a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED: 2158a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_FAIL_DBG(pm8001_ha, 2159f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS\n")); 2160f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_UNDELIVERED; 2161f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DEV_NO_RESPONSE; 2162f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!t->uldd_task) { 2163f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_handle_event(pm8001_ha, 2164f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev, 2165f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); 2166f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2167f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_QUEUE_FULL; 2168f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 2169f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/*ditto*/ 2170f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irq(&pm8001_ha->lock); 2171f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 2172f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irq(&pm8001_ha->lock); 2173f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 2174f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2175f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2176f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_BAD_DESTINATION: 2177f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2178f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_BAD_DESTINATION\n")); 2179f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_UNDELIVERED; 2180f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2181f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_BAD_DEST; 2182f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2183f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: 2184f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 2185f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED\n")); 2186f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2187f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2188f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_CONN_RATE; 2189f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2190f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_WRONG_DESTINATION: 2191f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2192f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_WRONG_DESTINATION\n")); 2193f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2194f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2195f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_WRONG_DEST; 2196f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2197f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_NAK_RECEIVED: 2198f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2199f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_NAK_RECEIVED\n")); 2200f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2201f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_NAK_R_ERR; 2202f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2203f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_PEER_ABORTED: 2204f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2205f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_PEER_ABORTED\n")); 2206f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2207f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_NAK_R_ERR; 2208f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2209f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_REJECTED_NCQ_MODE: 2210f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2211f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_REJECTED_NCQ_MODE\n")); 2212f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2213f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_UNDERRUN; 2214f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2215f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_OPEN_RETRY_TIMEOUT: 2216f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2217f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_OPEN_RETRY_TIMEOUT\n")); 2218f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2219f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_TO; 2220f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2221f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_UNEXPECTED_PHASE: 2222f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2223f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_UNEXPECTED_PHASE\n")); 2224f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2225f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_TO; 2226f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2227f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_XFER_RDY_OVERRUN: 2228f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2229f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_XFER_RDY_OVERRUN\n")); 2230f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2231f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_TO; 2232f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2233f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_XFER_RDY_NOT_EXPECTED: 2234f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2235f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_XFER_RDY_NOT_EXPECTED\n")); 2236f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2237f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_TO; 2238f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2239f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_OFFSET_MISMATCH: 2240f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2241f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_OFFSET_MISMATCH\n")); 2242f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2243f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_TO; 2244f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2245f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_XFER_ZERO_DATA_LEN: 2246f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2247f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_XFER_ZERO_DATA_LEN\n")); 2248f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2249f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_TO; 2250f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2251f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_CMD_FRAME_ISSUED: 2252f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2253f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_CMD_FRAME_ISSUED\n")); 2254f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2255f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_PIO_SETUP_ERROR: 2256f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2257f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_PIO_SETUP_ERROR\n")); 2258f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2259f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_TO; 2260f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2261a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_XFER_ERROR_INTERNAL_CRC_ERROR: 2262a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_FAIL_DBG(pm8001_ha, 2263a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K pm8001_printk("IO_XFR_ERROR_INTERNAL_CRC_ERROR\n")); 2264a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K /* TBC: used default set values */ 2265a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K ts->resp = SAS_TASK_COMPLETE; 2266a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K ts->stat = SAS_OPEN_TO; 2267a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K break; 2268a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_XFER_DMA_ACTIVATE_TIMEOUT: 2269a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K PM8001_FAIL_DBG(pm8001_ha, 2270a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K pm8001_printk("IO_XFR_DMA_ACTIVATE_TIMEOUT\n")); 2271a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K /* TBC: used default set values */ 2272a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K ts->resp = SAS_TASK_COMPLETE; 2273a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K ts->stat = SAS_OPEN_TO; 2274a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K break; 2275f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K default: 2276f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2277f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("Unknown status 0x%x\n", event)); 2278f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* not allowed case. Therefore, return failed status */ 2279f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2280f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_TO; 2281f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2282f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2283f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irqsave(&t->task_state_lock, flags); 2284f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags &= ~SAS_TASK_STATE_PENDING; 2285f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags &= ~SAS_TASK_AT_INITIATOR; 2286f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags |= SAS_TASK_STATE_DONE; 2287f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { 2288f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&t->task_state_lock, flags); 2289f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, 2290f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("task 0x%p done with io_status 0x%x" 2291f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K " resp 0x%x stat 0x%x but aborted by upper layer!\n", 2292f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t, event, ts->resp, ts->stat)); 2293f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 2294f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (t->uldd_task) { 2295f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&t->task_state_lock, flags); 2296f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 2297f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/* ditto */ 2298f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irq(&pm8001_ha->lock); 2299f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 2300f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irq(&pm8001_ha->lock); 2301f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (!t->uldd_task) { 2302f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&t->task_state_lock, flags); 2303f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 2304f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/*ditto*/ 2305f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irq(&pm8001_ha->lock); 2306f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 2307f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irq(&pm8001_ha->lock); 2308f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2309f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 2310f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2311f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/*See the comments for mpi_ssp_completion */ 2312f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void 2313f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kmpi_smp_completion(struct pm8001_hba_info *pm8001_ha, void *piomb) 2314f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 2315f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 param, i; 2316f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sas_task *t; 2317f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_ccb_info *ccb; 2318f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K unsigned long flags; 2319f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 status; 2320f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 tag; 2321f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct smp_completion_resp *psmpPayload; 2322f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct task_status_struct *ts; 2323f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_device *pm8001_dev; 2324f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K char *pdma_respaddr = NULL; 2325f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2326f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K psmpPayload = (struct smp_completion_resp *)(piomb + 4); 2327f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K status = le32_to_cpu(psmpPayload->status); 2328f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K tag = le32_to_cpu(psmpPayload->tag); 2329f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2330f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb = &pm8001_ha->ccb_info[tag]; 2331f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K param = le32_to_cpu(psmpPayload->param); 2332f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t = ccb->task; 2333f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts = &t->task_status; 2334f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev = ccb->device; 2335f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (status) 2336f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, 2337f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("smp IO status 0x%x\n", status)); 2338f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (unlikely(!t || !t->lldd_task || !t->dev)) 2339f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return; 2340f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2341f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K switch (status) { 2342f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2343f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_SUCCESS: 2344f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk("IO_SUCCESS\n")); 2345f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2346f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAM_STAT_GOOD; 2347f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_dev) 2348f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->running_req--; 2349f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_ha->smp_exp_mode == SMP_DIRECT) { 2350f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2351f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("DIRECT RESPONSE Length:%d\n", 2352f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K param)); 2353f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pdma_respaddr = (char *)(phys_to_virt(cpu_to_le64 2354f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ((u64)sg_dma_address 2355f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (&t->smp_task.smp_resp)))); 2356f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K for (i = 0; i < param; i++) { 2357f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K *(pdma_respaddr+i) = psmpPayload->_r_a[i]; 2358f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 2359f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "SMP Byte%d DMA data 0x%x psmp 0x%x\n", 2360f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K i, *(pdma_respaddr+i), 2361f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K psmpPayload->_r_a[i])); 2362f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2363f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2364f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2365f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_ABORTED: 2366f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2367f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_ABORTED IOMB\n")); 2368f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2369f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_ABORTED_TASK; 2370f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_dev) 2371f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->running_req--; 2372f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2373f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OVERFLOW: 2374f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk("IO_UNDERFLOW\n")); 2375f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2376f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DATA_OVERRUN; 2377f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->residual = 0; 2378f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_dev) 2379f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->running_req--; 2380f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2381f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_NO_DEVICE: 2382f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk("IO_NO_DEVICE\n")); 2383f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2384f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_PHY_DOWN; 2385f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2386f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_ERROR_HW_TIMEOUT: 2387f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2388f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_ERROR_HW_TIMEOUT\n")); 2389f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2390f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAM_STAT_BUSY; 2391f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2392f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_BREAK: 2393f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2394f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_BREAK\n")); 2395f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2396f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAM_STAT_BUSY; 2397f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2398f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_PHY_NOT_READY: 2399f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2400f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_PHY_NOT_READY\n")); 2401f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2402f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAM_STAT_BUSY; 2403f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2404f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED: 2405f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2406f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_PROTOCOL_NOT_SUPPORTED\n")); 2407f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2408f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2409f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_UNKNOWN; 2410f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2411f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_ZONE_VIOLATION: 2412f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2413f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_ZONE_VIOLATION\n")); 2414f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2415f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2416f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_UNKNOWN; 2417f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2418f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_BREAK: 2419f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2420f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_BREAK\n")); 2421f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2422f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2423f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_CONT0; 2424f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2425f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS: 2426a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_XFER_OPEN_RETRY_BACKOFF_THRESHOLD_REACHED: 2427a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_TMO: 2428a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_NO_DEST: 2429a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_OPEN_COLLIDE: 2430a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K case IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS_PATHWAY_BLOCKED: 2431f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2432f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS\n")); 2433f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2434f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2435f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_UNKNOWN; 2436f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_handle_event(pm8001_ha, 2437f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev, 2438f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K IO_OPEN_CNX_ERROR_IT_NEXUS_LOSS); 2439f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2440f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_BAD_DESTINATION: 2441f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2442f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_BAD_DESTINATION\n")); 2443f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2444f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2445f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_BAD_DEST; 2446f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2447f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED: 2448f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk(\ 2449f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "IO_OPEN_CNX_ERROR_CONNECTION_RATE_NOT_SUPPORTED\n")); 2450f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2451f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2452f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_CONN_RATE; 2453f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2454f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_WRONG_DESTINATION: 2455f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2456f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_WRONG_DESTINATION\n")); 2457f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2458f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2459f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_WRONG_DEST; 2460f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2461f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_ERROR_RX_FRAME: 2462f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2463f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_ERROR_RX_FRAME\n")); 2464f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2465f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DEV_NO_RESPONSE; 2466f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2467f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_XFER_OPEN_RETRY_TIMEOUT: 2468f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2469f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_XFER_OPEN_RETRY_TIMEOUT\n")); 2470f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2471f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2472f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 2473f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2474f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_ERROR_INTERNAL_SMP_RESOURCE: 2475f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2476f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_ERROR_INTERNAL_SMP_RESOURCE\n")); 2477f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2478f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_QUEUE_FULL; 2479f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2480f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_PORT_IN_RESET: 2481f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2482f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_PORT_IN_RESET\n")); 2483f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2484f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2485f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 2486f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2487f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_DS_NON_OPERATIONAL: 2488f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2489f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_DS_NON_OPERATIONAL\n")); 2490f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2491f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DEV_NO_RESPONSE; 2492f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2493f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_DS_IN_RECOVERY: 2494f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2495f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_DS_IN_RECOVERY\n")); 2496f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2497f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2498f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 2499f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2500f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY: 2501f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2502f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("IO_OPEN_CNX_ERROR_HW_RESOURCE_BUSY\n")); 2503f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2504f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_OPEN_REJECT; 2505f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->open_rej_reason = SAS_OREJ_RSVD_RETRY; 2506f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2507f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K default: 2508f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 2509f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("Unknown status 0x%x\n", status)); 2510f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->resp = SAS_TASK_COMPLETE; 2511f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ts->stat = SAS_DEV_NO_RESPONSE; 2512f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* not allowed case. Therefore, return failed status */ 2513f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2514f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2515f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irqsave(&t->task_state_lock, flags); 2516f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags &= ~SAS_TASK_STATE_PENDING; 2517f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags &= ~SAS_TASK_AT_INITIATOR; 2518f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_state_flags |= SAS_TASK_STATE_DONE; 2519f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (unlikely((t->task_state_flags & SAS_TASK_STATE_ABORTED))) { 2520f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&t->task_state_lock, flags); 2521f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_FAIL_DBG(pm8001_ha, pm8001_printk( 2522f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "task 0x%p done with io_status 0x%x resp 0x%x" 2523f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "stat 0x%x but aborted by upper layer!\n", 2524f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t, status, ts->resp, ts->stat)); 2525f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 2526f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 2527f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&t->task_state_lock, flags); 2528f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ccb_task_free(pm8001_ha, t, ccb, tag); 2529f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mb();/* in order to force CPU ordering */ 2530f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K t->task_done(t); 2531f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2532f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 2533f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2534f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 2535f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm80xx_hw_event_ack_req- For PM8001,some events need to acknowage to FW. 2536f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 2537f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @Qnum: the outbound queue message number. 2538f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @SEA: source of event to ack 2539f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @port_id: port id. 2540f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @phyId: phy id. 2541f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @param0: parameter 0. 2542f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @param1: parameter 1. 2543f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 2544f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void pm80xx_hw_event_ack_req(struct pm8001_hba_info *pm8001_ha, 2545f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 Qnum, u32 SEA, u32 port_id, u32 phyId, u32 param0, u32 param1) 2546f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 2547f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct hw_event_ack_req payload; 2548f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 opc = OPC_INB_SAS_HW_EVENT_ACK; 2549f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2550f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct inbound_queue_table *circularQ; 2551f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2552f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memset((u8 *)&payload, 0, sizeof(payload)); 2553f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[Qnum]; 2554f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.tag = cpu_to_le32(1); 2555f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.phyid_sea_portid = cpu_to_le32(((SEA & 0xFFFF) << 8) | 2556f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ((phyId & 0xFF) << 24) | (port_id & 0xFF)); 2557f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.param0 = cpu_to_le32(param0); 2558f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.param1 = cpu_to_le32(param1); 2559f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, 0); 2560f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 2561f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2562f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, 2563f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 phyId, u32 phy_op); 2564f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2565f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 2566f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * hw_event_sas_phy_up -FW tells me a SAS phy up event. 2567f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 2568f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 2569f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 2570f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void 2571f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Khw_event_sas_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb) 2572f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 2573f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct hw_event_resp *pPayload = 2574f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (struct hw_event_resp *)(piomb + 4); 2575f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 lr_status_evt_portid = 2576f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K le32_to_cpu(pPayload->lr_status_evt_portid); 2577f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 phyid_npip_portstate = le32_to_cpu(pPayload->phyid_npip_portstate); 2578f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2579f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 link_rate = 2580f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (u8)((lr_status_evt_portid & 0xF0000000) >> 28); 2581f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 port_id = (u8)(lr_status_evt_portid & 0x000000FF); 2582f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 phy_id = 2583f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (u8)((phyid_npip_portstate & 0xFF0000) >> 16); 2584f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 portstate = (u8)(phyid_npip_portstate & 0x0000000F); 2585f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2586f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_port *port = &pm8001_ha->port[port_id]; 2587f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sas_ha_struct *sas_ha = pm8001_ha->sas; 2588f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; 2589f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K unsigned long flags; 2590f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 deviceType = pPayload->sas_identify.dev_type; 2591f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port->port_state = portstate; 2592f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 2593f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "portid:%d; phyid:%d; linkrate:%d; " 2594f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "portstate:%x; devicetype:%x\n", 2595f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, phy_id, link_rate, portstate, deviceType)); 2596f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2597f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K switch (deviceType) { 2598f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case SAS_PHY_UNUSED: 2599f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2600f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("device type no device.\n")); 2601f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2602f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case SAS_END_DEVICE: 2603f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk("end device.\n")); 2604f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_chip_phy_ctl_req(pm8001_ha, phy_id, 2605f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PHY_NOTIFY_ENABLE_SPINUP); 2606f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port->port_attached = 1; 2607f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_get_lrate_mode(phy, link_rate); 2608f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2609f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case SAS_EDGE_EXPANDER_DEVICE: 2610f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2611f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("expander device.\n")); 2612f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port->port_attached = 1; 2613f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_get_lrate_mode(phy, link_rate); 2614f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2615f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case SAS_FANOUT_EXPANDER_DEVICE: 2616f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2617f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("fanout expander device.\n")); 2618f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port->port_attached = 1; 2619f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_get_lrate_mode(phy, link_rate); 2620f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2621f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K default: 2622f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2623f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("unknown device type(%x)\n", deviceType)); 2624f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2625f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2626f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_type |= PORT_TYPE_SAS; 2627f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->identify.device_type = deviceType; 2628f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 1; 2629f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (phy->identify.device_type == SAS_END_DEVICE) 2630f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->identify.target_port_protocols = SAS_PROTOCOL_SSP; 2631f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K else if (phy->identify.device_type != SAS_PHY_UNUSED) 2632f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->identify.target_port_protocols = SAS_PROTOCOL_SMP; 2633f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->sas_phy.oob_mode = SAS_OOB_MODE; 2634f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_phy_event(&phy->sas_phy, PHYE_OOB_DONE); 2635f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irqsave(&phy->sas_phy.frame_rcvd_lock, flags); 2636f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memcpy(phy->frame_rcvd, &pPayload->sas_identify, 2637f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sizeof(struct sas_identify_frame)-4); 2638f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->frame_rcvd_size = sizeof(struct sas_identify_frame) - 4; 2639f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); 2640f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); 2641f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_ha->flags == PM8001F_RUN_TIME) 2642f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mdelay(200);/*delay a moment to wait disk to spinup*/ 2643f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_bytes_dmaed(pm8001_ha, phy_id); 2644f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 2645f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2646f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 2647f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * hw_event_sata_phy_up -FW tells me a SATA phy up event. 2648f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 2649f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 2650f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 2651f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void 2652f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Khw_event_sata_phy_up(struct pm8001_hba_info *pm8001_ha, void *piomb) 2653f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 2654f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct hw_event_resp *pPayload = 2655f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (struct hw_event_resp *)(piomb + 4); 2656f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 phyid_npip_portstate = le32_to_cpu(pPayload->phyid_npip_portstate); 2657f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 lr_status_evt_portid = 2658f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K le32_to_cpu(pPayload->lr_status_evt_portid); 2659f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 link_rate = 2660f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (u8)((lr_status_evt_portid & 0xF0000000) >> 28); 2661f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 port_id = (u8)(lr_status_evt_portid & 0x000000FF); 2662f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 phy_id = 2663f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (u8)((phyid_npip_portstate & 0xFF0000) >> 16); 2664f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2665f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 portstate = (u8)(phyid_npip_portstate & 0x0000000F); 2666f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2667f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_port *port = &pm8001_ha->port[port_id]; 2668f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sas_ha_struct *sas_ha = pm8001_ha->sas; 2669f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; 2670f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K unsigned long flags; 2671f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 2672f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "port id %d, phy id %d link_rate %d portstate 0x%x\n", 2673f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, phy_id, link_rate, portstate)); 2674f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2675f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port->port_state = portstate; 2676f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port->port_attached = 1; 2677f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_get_lrate_mode(phy, link_rate); 2678f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_type |= PORT_TYPE_SATA; 2679f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 1; 2680f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->sas_phy.oob_mode = SATA_OOB_MODE; 2681f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_phy_event(&phy->sas_phy, PHYE_OOB_DONE); 2682f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irqsave(&phy->sas_phy.frame_rcvd_lock, flags); 2683f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memcpy(phy->frame_rcvd, ((u8 *)&pPayload->sata_fis - 4), 2684f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sizeof(struct dev_to_host_fis)); 2685f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->frame_rcvd_size = sizeof(struct dev_to_host_fis); 2686f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->identify.target_port_protocols = SAS_PROTOCOL_SATA; 2687f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->identify.device_type = SATA_DEV; 2688f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_get_attached_sas_addr(phy, phy->sas_phy.attached_sas_addr); 2689f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&phy->sas_phy.frame_rcvd_lock, flags); 2690f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_bytes_dmaed(pm8001_ha, phy_id); 2691f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 2692f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2693f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 2694f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * hw_event_phy_down -we should notify the libsas the phy is down. 2695f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 2696f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 2697f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 2698f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void 2699f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Khw_event_phy_down(struct pm8001_hba_info *pm8001_ha, void *piomb) 2700f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 2701f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct hw_event_resp *pPayload = 2702f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (struct hw_event_resp *)(piomb + 4); 2703f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2704f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 lr_status_evt_portid = 2705f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K le32_to_cpu(pPayload->lr_status_evt_portid); 2706f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 port_id = (u8)(lr_status_evt_portid & 0x000000FF); 2707f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 phyid_npip_portstate = le32_to_cpu(pPayload->phyid_npip_portstate); 2708f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 phy_id = 2709f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (u8)((phyid_npip_portstate & 0xFF0000) >> 16); 2710f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 portstate = (u8)(phyid_npip_portstate & 0x0000000F); 2711f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2712f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_port *port = &pm8001_ha->port[port_id]; 2713f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; 2714f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port->port_state = portstate; 2715f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_type = 0; 2716f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->identify.device_type = 0; 2717f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 0; 2718f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memset(&phy->dev_sas_addr, 0, SAS_ADDR_SIZE); 2719f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K switch (portstate) { 2720f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case PORT_VALID: 2721f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2722f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case PORT_INVALID: 2723f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2724f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" PortInvalid portID %d\n", port_id)); 2725f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2726f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" Last phy Down and port invalid\n")); 2727f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port->port_attached = 0; 2728f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_hw_event_ack_req(pm8001_ha, 0, HW_EVENT_PHY_DOWN, 2729f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, phy_id, 0, 0); 2730f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2731f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case PORT_IN_RESET: 2732f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2733f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" Port In Reset portID %d\n", port_id)); 2734f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2735f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case PORT_NOT_ESTABLISHED: 2736f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2737f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" phy Down and PORT_NOT_ESTABLISHED\n")); 2738f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port->port_attached = 0; 2739f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2740f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case PORT_LOSTCOMM: 2741f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2742f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" phy Down and PORT_LOSTCOMM\n")); 2743f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2744f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" Last phy Down and port invalid\n")); 2745f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port->port_attached = 0; 2746f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_hw_event_ack_req(pm8001_ha, 0, HW_EVENT_PHY_DOWN, 2747f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, phy_id, 0, 0); 2748f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2749f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K default: 2750f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port->port_attached = 0; 2751f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2752f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" phy Down and(default) = 0x%x\n", 2753f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K portstate)); 2754f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2755f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2756f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2757f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 2758f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2759f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_phy_start_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) 2760f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 2761f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct phy_start_resp *pPayload = 2762f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (struct phy_start_resp *)(piomb + 4); 2763f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 status = 2764f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K le32_to_cpu(pPayload->status); 2765f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 phy_id = 2766f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K le32_to_cpu(pPayload->phyid); 2767f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; 2768f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2769f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 2770f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("phy start resp status:0x%x, phyid:0x%x\n", 2771f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K status, phy_id)); 2772f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (status == 0) { 2773f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_state = 1; 2774f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_ha->flags == PM8001F_RUN_TIME) 2775f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K complete(phy->enable_completion); 2776f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2777f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 2778f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2779f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 2780f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2781f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 2782f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * mpi_thermal_hw_event -The hw event has come. 2783f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 2784f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 2785f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 2786f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_thermal_hw_event(struct pm8001_hba_info *pm8001_ha, void *piomb) 2787f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 2788f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct thermal_hw_event *pPayload = 2789f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (struct thermal_hw_event *)(piomb + 4); 2790f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2791f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 thermal_event = le32_to_cpu(pPayload->thermal_event); 2792f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 rht_lht = le32_to_cpu(pPayload->rht_lht); 2793f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2794f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (thermal_event & 0x40) { 2795f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 2796f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Thermal Event: Local high temperature violated!\n")); 2797f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 2798f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Thermal Event: Measured local high temperature %d\n", 2799f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ((rht_lht & 0xFF00) >> 8))); 2800f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2801f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (thermal_event & 0x10) { 2802f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 2803f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Thermal Event: Remote high temperature violated!\n")); 2804f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 2805f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Thermal Event: Measured remote high temperature %d\n", 2806f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ((rht_lht & 0xFF000000) >> 24))); 2807f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 2808f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 2809f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 2810f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2811f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 2812f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * mpi_hw_event -The hw event has come. 2813f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 2814f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 2815f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 2816f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_hw_event(struct pm8001_hba_info *pm8001_ha, void *piomb) 2817f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 2818f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K unsigned long flags; 2819f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct hw_event_resp *pPayload = 2820f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (struct hw_event_resp *)(piomb + 4); 2821f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 lr_status_evt_portid = 2822f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K le32_to_cpu(pPayload->lr_status_evt_portid); 2823f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 phyid_npip_portstate = le32_to_cpu(pPayload->phyid_npip_portstate); 2824f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 port_id = (u8)(lr_status_evt_portid & 0x000000FF); 2825f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 phy_id = 2826f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (u8)((phyid_npip_portstate & 0xFF0000) >> 16); 2827f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u16 eventType = 2828f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (u16)((lr_status_evt_portid & 0x00FFFF00) >> 8); 2829f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 status = 2830f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (u8)((lr_status_evt_portid & 0x0F000000) >> 24); 2831f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2832f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sas_ha_struct *sas_ha = pm8001_ha->sas; 2833f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_phy *phy = &pm8001_ha->phy[phy_id]; 2834f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct asd_sas_phy *sas_phy = sas_ha->sas_phy[phy_id]; 2835f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2836f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("portid:%d phyid:%d event:0x%x status:0x%x\n", 2837f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, phy_id, eventType, status)); 2838f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2839f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K switch (eventType) { 2840f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 2841f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_SAS_PHY_UP: 2842f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2843f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_PHY_START_STATUS\n")); 2844f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K hw_event_sas_phy_up(pm8001_ha, piomb); 2845f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2846f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_SATA_PHY_UP: 2847f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2848f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_SATA_PHY_UP\n")); 2849f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K hw_event_sata_phy_up(pm8001_ha, piomb); 2850f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2851f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_SATA_SPINUP_HOLD: 2852f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2853f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_SATA_SPINUP_HOLD\n")); 2854f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_phy_event(&phy->sas_phy, PHYE_SPINUP_HOLD); 2855f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2856f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_PHY_DOWN: 2857f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2858f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_PHY_DOWN\n")); 2859f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_phy_event(&phy->sas_phy, PHYE_LOSS_OF_SIGNAL); 2860f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 0; 2861f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_state = 0; 2862f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K hw_event_phy_down(pm8001_ha, piomb); 2863f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2864f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_PORT_INVALID: 2865f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2866f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_PORT_INVALID\n")); 2867f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy_disconnected(sas_phy); 2868f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 0; 2869f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 2870f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2871f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* the broadcast change primitive received, tell the LIBSAS this event 2872f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K to revalidate the sas domain*/ 2873f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_BROADCAST_CHANGE: 2874f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2875f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_BROADCAST_CHANGE\n")); 2876f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_hw_event_ack_req(pm8001_ha, 0, HW_EVENT_BROADCAST_CHANGE, 2877f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, phy_id, 1, 0); 2878f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irqsave(&sas_phy->sas_prim_lock, flags); 2879f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy->sas_prim = HW_EVENT_BROADCAST_CHANGE; 2880f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&sas_phy->sas_prim_lock, flags); 2881f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD); 2882f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2883f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_PHY_ERROR: 2884f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2885f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_PHY_ERROR\n")); 2886f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy_disconnected(&phy->sas_phy); 2887f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 0; 2888f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_phy_event(&phy->sas_phy, PHYE_OOB_ERROR); 2889f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2890f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_BROADCAST_EXP: 2891f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2892f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_BROADCAST_EXP\n")); 2893f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irqsave(&sas_phy->sas_prim_lock, flags); 2894f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy->sas_prim = HW_EVENT_BROADCAST_EXP; 2895f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&sas_phy->sas_prim_lock, flags); 2896f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD); 2897f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2898f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_LINK_ERR_INVALID_DWORD: 2899f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2900f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_LINK_ERR_INVALID_DWORD\n")); 2901f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_hw_event_ack_req(pm8001_ha, 0, 2902f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K HW_EVENT_LINK_ERR_INVALID_DWORD, port_id, phy_id, 0, 0); 2903f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy_disconnected(sas_phy); 2904f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 0; 2905f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 2906f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2907f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_LINK_ERR_DISPARITY_ERROR: 2908f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2909f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_LINK_ERR_DISPARITY_ERROR\n")); 2910f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_hw_event_ack_req(pm8001_ha, 0, 2911f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K HW_EVENT_LINK_ERR_DISPARITY_ERROR, 2912f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, phy_id, 0, 0); 2913f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy_disconnected(sas_phy); 2914f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 0; 2915f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 2916f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2917f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_LINK_ERR_CODE_VIOLATION: 2918f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2919f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_LINK_ERR_CODE_VIOLATION\n")); 2920f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_hw_event_ack_req(pm8001_ha, 0, 2921f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K HW_EVENT_LINK_ERR_CODE_VIOLATION, 2922f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, phy_id, 0, 0); 2923f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy_disconnected(sas_phy); 2924f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 0; 2925f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 2926f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2927f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_LINK_ERR_LOSS_OF_DWORD_SYNCH: 2928f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 2929f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "HW_EVENT_LINK_ERR_LOSS_OF_DWORD_SYNCH\n")); 2930f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_hw_event_ack_req(pm8001_ha, 0, 2931f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K HW_EVENT_LINK_ERR_LOSS_OF_DWORD_SYNCH, 2932f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, phy_id, 0, 0); 2933f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy_disconnected(sas_phy); 2934f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 0; 2935f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 2936f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2937f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_MALFUNCTION: 2938f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2939f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_MALFUNCTION\n")); 2940f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2941f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_BROADCAST_SES: 2942f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2943f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_BROADCAST_SES\n")); 2944f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irqsave(&sas_phy->sas_prim_lock, flags); 2945f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy->sas_prim = HW_EVENT_BROADCAST_SES; 2946f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&sas_phy->sas_prim_lock, flags); 2947f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_BROADCAST_RCVD); 2948f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2949f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_INBOUND_CRC_ERROR: 2950f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2951f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_INBOUND_CRC_ERROR\n")); 2952f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_hw_event_ack_req(pm8001_ha, 0, 2953f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K HW_EVENT_INBOUND_CRC_ERROR, 2954f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, phy_id, 0, 0); 2955f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2956f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_HARD_RESET_RECEIVED: 2957f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2958f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_HARD_RESET_RECEIVED\n")); 2959f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_HARD_RESET); 2960f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2961f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_ID_FRAME_TIMEOUT: 2962f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2963f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_ID_FRAME_TIMEOUT\n")); 2964f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy_disconnected(sas_phy); 2965f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 0; 2966f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 2967f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2968f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_LINK_ERR_PHY_RESET_FAILED: 2969f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2970f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_LINK_ERR_PHY_RESET_FAILED\n")); 2971f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_hw_event_ack_req(pm8001_ha, 0, 2972f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K HW_EVENT_LINK_ERR_PHY_RESET_FAILED, 2973f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K port_id, phy_id, 0, 0); 2974f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy_disconnected(sas_phy); 2975f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 0; 2976f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 2977f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2978f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_PORT_RESET_TIMER_TMO: 2979f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2980f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_PORT_RESET_TIMER_TMO\n")); 2981f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy_disconnected(sas_phy); 2982f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 0; 2983f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 2984f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2985f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_PORT_RECOVERY_TIMER_TMO: 2986f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2987f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_PORT_RECOVERY_TIMER_TMO\n")); 2988a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K pm80xx_hw_event_ack_req(pm8001_ha, 0, 2989a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K HW_EVENT_PORT_RECOVERY_TIMER_TMO, 2990a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K port_id, phy_id, 0, 0); 2991f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_phy_disconnected(sas_phy); 2992f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_attached = 0; 2993f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sas_ha->notify_port_event(sas_phy, PORTE_LINK_RESET_ERR); 2994f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2995f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_PORT_RECOVER: 2996f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 2997f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_PORT_RECOVER\n")); 2998f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 2999f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case HW_EVENT_PORT_RESET_COMPLETE: 3000f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3001f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("HW_EVENT_PORT_RESET_COMPLETE\n")); 3002f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3003f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case EVENT_BROADCAST_ASYNCH_EVENT: 3004f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3005f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("EVENT_BROADCAST_ASYNCH_EVENT\n")); 3006f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3007f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K default: 3008f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3009f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("Unknown event type 0x%x\n", eventType)); 3010f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3011f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3012f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 3013f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3014f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3015f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3016f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * mpi_phy_stop_resp - SPCv specific 3017f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 3018f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 3019f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3020f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_phy_stop_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) 3021f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3022f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct phy_stop_resp *pPayload = 3023f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (struct phy_stop_resp *)(piomb + 4); 3024f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 status = 3025f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K le32_to_cpu(pPayload->status); 3026f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 phyid = 3027f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K le32_to_cpu(pPayload->phyid); 3028f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_phy *phy = &pm8001_ha->phy[phyid]; 3029f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3030f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("phy:0x%x status:0x%x\n", 3031f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phyid, status)); 3032f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (status == 0) 3033f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy->phy_state = 0; 3034f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 3035f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3036f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3037f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3038f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * mpi_set_controller_config_resp - SPCv specific 3039f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 3040f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 3041f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3042f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_set_controller_config_resp(struct pm8001_hba_info *pm8001_ha, 3043f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void *piomb) 3044f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3045f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct set_ctrl_cfg_resp *pPayload = 3046f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (struct set_ctrl_cfg_resp *)(piomb + 4); 3047f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 status = le32_to_cpu(pPayload->status); 3048f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 err_qlfr_pgcd = le32_to_cpu(pPayload->err_qlfr_pgcd); 3049f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3050f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3051f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "SET CONTROLLER RESP: status 0x%x qlfr_pgcd 0x%x\n", 3052f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K status, err_qlfr_pgcd)); 3053f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3054f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 3055f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3056f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3057f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3058f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * mpi_get_controller_config_resp - SPCv specific 3059f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 3060f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 3061f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3062f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_get_controller_config_resp(struct pm8001_hba_info *pm8001_ha, 3063f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void *piomb) 3064f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3065f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3066f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" pm80xx_addition_functionality\n")); 3067f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3068f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 3069f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3070f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3071f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3072f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * mpi_get_phy_profile_resp - SPCv specific 3073f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 3074f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 3075f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3076f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_get_phy_profile_resp(struct pm8001_hba_info *pm8001_ha, 3077f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void *piomb) 3078f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3079f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3080f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" pm80xx_addition_functionality\n")); 3081f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3082f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 3083f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3084f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3085f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3086f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * mpi_flash_op_ext_resp - SPCv specific 3087f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 3088f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 3089f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3090f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_flash_op_ext_resp(struct pm8001_hba_info *pm8001_ha, void *piomb) 3091f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3092f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3093f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" pm80xx_addition_functionality\n")); 3094f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3095f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 3096f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3097f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3098f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3099f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * mpi_set_phy_profile_resp - SPCv specific 3100f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 3101f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 3102f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3103f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_set_phy_profile_resp(struct pm8001_hba_info *pm8001_ha, 3104f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void *piomb) 3105f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3106f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3107f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" pm80xx_addition_functionality\n")); 3108f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3109f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 3110f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3111f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3112f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3113f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * mpi_kek_management_resp - SPCv specific 3114f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 3115f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 3116f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3117f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_kek_management_resp(struct pm8001_hba_info *pm8001_ha, 3118f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void *piomb) 3119f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3120f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct kek_mgmt_resp *pPayload = (struct kek_mgmt_resp *)(piomb + 4); 3121f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3122f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 status = le32_to_cpu(pPayload->status); 3123f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 kidx_new_curr_ksop = le32_to_cpu(pPayload->kidx_new_curr_ksop); 3124f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 err_qlfr = le32_to_cpu(pPayload->err_qlfr); 3125f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3126f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3127f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "KEK MGMT RESP. Status 0x%x idx_ksop 0x%x err_qlfr 0x%x\n", 3128f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K status, kidx_new_curr_ksop, err_qlfr)); 3129f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3130f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 3131f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3132f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3133f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3134f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * mpi_dek_management_resp - SPCv specific 3135f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 3136f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 3137f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3138f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int mpi_dek_management_resp(struct pm8001_hba_info *pm8001_ha, 3139f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void *piomb) 3140f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3141f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3142f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" pm80xx_addition_functionality\n")); 3143f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3144f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 3145f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3146f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3147f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3148f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * ssp_coalesced_comp_resp - SPCv specific 3149f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 3150f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 3151f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3152f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int ssp_coalesced_comp_resp(struct pm8001_hba_info *pm8001_ha, 3153f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void *piomb) 3154f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3155f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3156f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk(" pm80xx_addition_functionality\n")); 3157f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3158f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 3159f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3160f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3161f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3162f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * process_one_iomb - process one outbound Queue memory block 3163f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information 3164f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @piomb: IO message buffer 3165f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3166f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void process_one_iomb(struct pm8001_hba_info *pm8001_ha, void *piomb) 3167f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3168f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K __le32 pHeader = *(__le32 *)piomb; 3169f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 opc = (u32)((le32_to_cpu(pHeader)) & 0xFFF); 3170f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3171f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K switch (opc) { 3172f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_ECHO: 3173f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk("OPC_OUB_ECHO\n")); 3174f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3175f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_HW_EVENT: 3176f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3177f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_HW_EVENT\n")); 3178f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_hw_event(pm8001_ha, piomb); 3179f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3180f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_THERM_HW_EVENT: 3181f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3182f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_THERMAL_EVENT\n")); 3183f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_thermal_hw_event(pm8001_ha, piomb); 3184f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3185f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SSP_COMP: 3186f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3187f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SSP_COMP\n")); 3188f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_ssp_completion(pm8001_ha, piomb); 3189f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3190f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SMP_COMP: 3191f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3192f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SMP_COMP\n")); 3193f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_smp_completion(pm8001_ha, piomb); 3194f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3195f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_LOCAL_PHY_CNTRL: 3196f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3197f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_LOCAL_PHY_CNTRL\n")); 3198f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_local_phy_ctl(pm8001_ha, piomb); 3199f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3200f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_DEV_REGIST: 3201f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3202f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_DEV_REGIST\n")); 3203f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_reg_resp(pm8001_ha, piomb); 3204f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3205f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_DEREG_DEV: 3206f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3207f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("unresgister the deviece\n")); 3208f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_dereg_resp(pm8001_ha, piomb); 3209f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3210f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_GET_DEV_HANDLE: 3211f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3212f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_GET_DEV_HANDLE\n")); 3213f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3214f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SATA_COMP: 3215f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3216f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SATA_COMP\n")); 3217f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_sata_completion(pm8001_ha, piomb); 3218f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3219f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SATA_EVENT: 3220f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3221f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SATA_EVENT\n")); 3222f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_sata_event(pm8001_ha, piomb); 3223f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3224f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SSP_EVENT: 3225f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3226f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SSP_EVENT\n")); 3227f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_ssp_event(pm8001_ha, piomb); 3228f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3229f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_DEV_HANDLE_ARRIV: 3230f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3231f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_DEV_HANDLE_ARRIV\n")); 3232f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /*This is for target*/ 3233f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3234f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SSP_RECV_EVENT: 3235f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3236f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SSP_RECV_EVENT\n")); 3237f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /*This is for target*/ 3238f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3239f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_FW_FLASH_UPDATE: 3240f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3241f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_FW_FLASH_UPDATE\n")); 3242f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_fw_flash_update_resp(pm8001_ha, piomb); 3243f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3244f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_GPIO_RESPONSE: 3245f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3246f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_GPIO_RESPONSE\n")); 3247f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3248f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_GPIO_EVENT: 3249f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3250f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_GPIO_EVENT\n")); 3251f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3252f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_GENERAL_EVENT: 3253f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3254f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_GENERAL_EVENT\n")); 3255f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_general_event(pm8001_ha, piomb); 3256f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3257f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SSP_ABORT_RSP: 3258f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3259f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SSP_ABORT_RSP\n")); 3260f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_task_abort_resp(pm8001_ha, piomb); 3261f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3262f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SATA_ABORT_RSP: 3263f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3264f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SATA_ABORT_RSP\n")); 3265f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_task_abort_resp(pm8001_ha, piomb); 3266f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3267f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SAS_DIAG_MODE_START_END: 3268f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3269f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SAS_DIAG_MODE_START_END\n")); 3270f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3271f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SAS_DIAG_EXECUTE: 3272f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3273f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SAS_DIAG_EXECUTE\n")); 3274f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3275f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_GET_TIME_STAMP: 3276f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3277f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_GET_TIME_STAMP\n")); 3278f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3279f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SAS_HW_EVENT_ACK: 3280f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3281f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SAS_HW_EVENT_ACK\n")); 3282f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3283f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_PORT_CONTROL: 3284f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3285f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_PORT_CONTROL\n")); 3286f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3287f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SMP_ABORT_RSP: 3288f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3289f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SMP_ABORT_RSP\n")); 3290f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_task_abort_resp(pm8001_ha, piomb); 3291f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3292f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_GET_NVMD_DATA: 3293f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3294f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_GET_NVMD_DATA\n")); 3295f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_get_nvmd_resp(pm8001_ha, piomb); 3296f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3297f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SET_NVMD_DATA: 3298f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3299f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SET_NVMD_DATA\n")); 3300f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_set_nvmd_resp(pm8001_ha, piomb); 3301f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3302f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_DEVICE_HANDLE_REMOVAL: 3303f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3304f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_DEVICE_HANDLE_REMOVAL\n")); 3305f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3306f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SET_DEVICE_STATE: 3307f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3308f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SET_DEVICE_STATE\n")); 3309f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_set_dev_state_resp(pm8001_ha, piomb); 3310f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3311f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_GET_DEVICE_STATE: 3312f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3313f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_GET_DEVICE_STATE\n")); 3314f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3315f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SET_DEV_INFO: 3316f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, 3317f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("OPC_OUB_SET_DEV_INFO\n")); 3318f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3319f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* spcv specifc commands */ 3320f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_PHY_START_RESP: 3321f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3322f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "OPC_OUB_PHY_START_RESP opcode:%x\n", opc)); 3323f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_phy_start_resp(pm8001_ha, piomb); 3324f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3325f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_PHY_STOP_RESP: 3326f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3327f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "OPC_OUB_PHY_STOP_RESP opcode:%x\n", opc)); 3328f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_phy_stop_resp(pm8001_ha, piomb); 3329f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3330f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SET_CONTROLLER_CONFIG: 3331f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3332f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "OPC_OUB_SET_CONTROLLER_CONFIG opcode:%x\n", opc)); 3333f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_set_controller_config_resp(pm8001_ha, piomb); 3334f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3335f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_GET_CONTROLLER_CONFIG: 3336f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3337f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "OPC_OUB_GET_CONTROLLER_CONFIG opcode:%x\n", opc)); 3338f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_get_controller_config_resp(pm8001_ha, piomb); 3339f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3340f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_GET_PHY_PROFILE: 3341f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3342f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "OPC_OUB_GET_PHY_PROFILE opcode:%x\n", opc)); 3343f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_get_phy_profile_resp(pm8001_ha, piomb); 3344f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3345f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_FLASH_OP_EXT: 3346f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3347f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "OPC_OUB_FLASH_OP_EXT opcode:%x\n", opc)); 3348f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_flash_op_ext_resp(pm8001_ha, piomb); 3349f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3350f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SET_PHY_PROFILE: 3351f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3352f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "OPC_OUB_SET_PHY_PROFILE opcode:%x\n", opc)); 3353f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_set_phy_profile_resp(pm8001_ha, piomb); 3354f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3355f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_KEK_MANAGEMENT_RESP: 3356f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3357f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "OPC_OUB_KEK_MANAGEMENT_RESP opcode:%x\n", opc)); 3358f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_kek_management_resp(pm8001_ha, piomb); 3359f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3360f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_DEK_MANAGEMENT_RESP: 3361f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3362f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "OPC_OUB_DEK_MANAGEMENT_RESP opcode:%x\n", opc)); 3363f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K mpi_dek_management_resp(pm8001_ha, piomb); 3364f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3365f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case OPC_OUB_SSP_COALESCED_COMP_RESP: 3366f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3367f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "OPC_OUB_SSP_COALESCED_COMP_RESP opcode:%x\n", opc)); 3368f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_coalesced_comp_resp(pm8001_ha, piomb); 3369f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3370f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K default: 3371f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_MSG_DBG(pm8001_ha, pm8001_printk( 3372f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Unknown outbound Queue IOMB OPC = 0x%x\n", opc)); 3373f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3374f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3375f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3376f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3377f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int process_oq(struct pm8001_hba_info *pm8001_ha, u8 vec) 3378f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3379f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct outbound_queue_table *circularQ; 3380f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K void *pMsg1 = NULL; 3381f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 uninitialized_var(bc); 3382f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 ret = MPI_IO_STATUS_FAIL; 3383f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K unsigned long flags; 3384f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3385f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_lock_irqsave(&pm8001_ha->lock, flags); 3386f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K circularQ = &pm8001_ha->outbnd_q_tbl[vec]; 3387f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K do { 3388f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = pm8001_mpi_msg_consume(pm8001_ha, circularQ, &pMsg1, &bc); 3389f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (MPI_IO_STATUS_SUCCESS == ret) { 3390f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* process the outbound message */ 3391f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K process_one_iomb(pm8001_ha, (void *)(pMsg1 - 4)); 3392f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* free the message from the outbound circular buffer */ 3393f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_msg_free_set(pm8001_ha, pMsg1, 3394f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K circularQ, bc); 3395f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3396f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (MPI_IO_STATUS_BUSY == ret) { 3397f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Update the producer index from SPC */ 3398f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K circularQ->producer_index = 3399f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(pm8001_read_32(circularQ->pi_virt)); 3400f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (le32_to_cpu(circularQ->producer_index) == 3401f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K circularQ->consumer_idx) 3402f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* OQ is empty */ 3403f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3404f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3405f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } while (1); 3406f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K spin_unlock_irqrestore(&pm8001_ha->lock, flags); 3407f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return ret; 3408f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3409f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3410f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/* PCI_DMA_... to our direction translation. */ 3411f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic const u8 data_dir_flags[] = { 3412f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K [PCI_DMA_BIDIRECTIONAL] = DATA_DIR_BYRECIPIENT,/* UNSPECIFIED */ 3413f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K [PCI_DMA_TODEVICE] = DATA_DIR_OUT,/* OUTBOUND */ 3414f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K [PCI_DMA_FROMDEVICE] = DATA_DIR_IN,/* INBOUND */ 3415f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K [PCI_DMA_NONE] = DATA_DIR_NONE,/* NO TRANSFER */ 3416f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K}; 3417f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3418f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic void build_smp_cmd(u32 deviceID, __le32 hTag, 3419f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct smp_req *psmp_cmd, int mode, int length) 3420f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3421f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K psmp_cmd->tag = hTag; 3422f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K psmp_cmd->device_id = cpu_to_le32(deviceID); 3423f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (mode == SMP_DIRECT) { 3424f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K length = length - 4; /* subtract crc */ 3425f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K psmp_cmd->len_ip_ir = cpu_to_le32(length << 16); 3426f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 3427f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K psmp_cmd->len_ip_ir = cpu_to_le32(1|(1 << 1)); 3428f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3429f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3430f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3431f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3432f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm8001_chip_smp_req - send a SMP task to FW 3433f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information. 3434f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @ccb: the ccb information this request used. 3435f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3436f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha, 3437f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_ccb_info *ccb) 3438f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3439f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int elem, rc; 3440f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sas_task *task = ccb->task; 3441f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct domain_device *dev = task->dev; 3442f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_device *pm8001_dev = dev->lldd_dev; 3443f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct scatterlist *sg_req, *sg_resp; 3444f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 req_len, resp_len; 3445f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct smp_req smp_cmd; 3446f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 opc; 3447f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct inbound_queue_table *circularQ; 3448f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K char *preq_dma_addr = NULL; 3449f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K __le64 tmp_addr; 3450f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 i, length; 3451f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3452f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memset(&smp_cmd, 0, sizeof(smp_cmd)); 3453f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* 3454f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * DMA-map SMP request, response buffers 3455f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3456f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sg_req = &task->smp_task.smp_req; 3457f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K elem = dma_map_sg(pm8001_ha->dev, sg_req, 1, PCI_DMA_TODEVICE); 3458f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!elem) 3459f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return -ENOMEM; 3460f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K req_len = sg_dma_len(sg_req); 3461f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3462f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sg_resp = &task->smp_task.smp_resp; 3463f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K elem = dma_map_sg(pm8001_ha->dev, sg_resp, 1, PCI_DMA_FROMDEVICE); 3464f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!elem) { 3465f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K rc = -ENOMEM; 3466f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K goto err_out; 3467f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3468f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K resp_len = sg_dma_len(sg_resp); 3469f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* must be in dwords */ 3470f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((req_len & 0x3) || (resp_len & 0x3)) { 3471f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K rc = -EINVAL; 3472f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K goto err_out_2; 3473f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3474f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3475f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K opc = OPC_INB_SMP_REQUEST; 3476f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[0]; 3477f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K smp_cmd.tag = cpu_to_le32(ccb->ccb_tag); 3478f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3479f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K length = sg_req->length; 3480f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 3481f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("SMP Frame Length %d\n", sg_req->length)); 3482f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (!(length - 8)) 3483f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->smp_exp_mode = SMP_DIRECT; 3484f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K else 3485f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->smp_exp_mode = SMP_INDIRECT; 3486f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3487f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* DIRECT MODE support only in spcv/ve */ 3488f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->smp_exp_mode = SMP_DIRECT; 3489f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3490f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K tmp_addr = cpu_to_le64((u64)sg_dma_address(&task->smp_task.smp_req)); 3491f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K preq_dma_addr = (char *)phys_to_virt(tmp_addr); 3492f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3493f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* INDIRECT MODE command settings. Use DMA */ 3494f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_ha->smp_exp_mode == SMP_INDIRECT) { 3495f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 3496f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("SMP REQUEST INDIRECT MODE\n")); 3497f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* for SPCv indirect mode. Place the top 4 bytes of 3498f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * SMP Request header here. */ 3499f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K for (i = 0; i < 4; i++) 3500f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K smp_cmd.smp_req16[i] = *(preq_dma_addr + i); 3501f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* exclude top 4 bytes for SMP req header */ 3502f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K smp_cmd.long_smp_req.long_req_addr = 3503f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le64((u64)sg_dma_address 3504f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (&task->smp_task.smp_req) - 4); 3505f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* exclude 4 bytes for SMP req header and CRC */ 3506f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K smp_cmd.long_smp_req.long_req_size = 3507f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32((u32)sg_dma_len(&task->smp_task.smp_req)-8); 3508f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K smp_cmd.long_smp_req.long_resp_addr = 3509f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le64((u64)sg_dma_address 3510f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (&task->smp_task.smp_resp)); 3511f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K smp_cmd.long_smp_req.long_resp_size = 3512f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32((u32)sg_dma_len 3513f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (&task->smp_task.smp_resp)-4); 3514f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { /* DIRECT MODE */ 3515f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K smp_cmd.long_smp_req.long_req_addr = 3516f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le64((u64)sg_dma_address 3517f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (&task->smp_task.smp_req)); 3518f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K smp_cmd.long_smp_req.long_req_size = 3519f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32((u32)sg_dma_len(&task->smp_task.smp_req)-4); 3520f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K smp_cmd.long_smp_req.long_resp_addr = 3521f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le64((u64)sg_dma_address 3522f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (&task->smp_task.smp_resp)); 3523f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K smp_cmd.long_smp_req.long_resp_size = 3524f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32 3525f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ((u32)sg_dma_len(&task->smp_task.smp_resp)-4); 3526f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3527f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_ha->smp_exp_mode == SMP_DIRECT) { 3528f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, 3529f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("SMP REQUEST DIRECT MODE\n")); 3530f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K for (i = 0; i < length; i++) 3531f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (i < 16) { 3532f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K smp_cmd.smp_req16[i] = *(preq_dma_addr+i); 3533f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 3534f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Byte[%d]:%x (DMA data:%x)\n", 3535f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K i, smp_cmd.smp_req16[i], 3536f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K *(preq_dma_addr))); 3537f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 3538f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K smp_cmd.smp_req[i] = *(preq_dma_addr+i); 3539f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 3540f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Byte[%d]:%x (DMA data:%x)\n", 3541f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K i, smp_cmd.smp_req[i], 3542f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K *(preq_dma_addr))); 3543f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3544f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3545f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3546f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K build_smp_cmd(pm8001_dev->device_id, smp_cmd.tag, 3547f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K &smp_cmd, pm8001_ha->smp_exp_mode, length); 3548f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, (u32 *)&smp_cmd, 0); 3549f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 3550f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3551f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kerr_out_2: 3552f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K dma_unmap_sg(pm8001_ha->dev, &ccb->task->smp_task.smp_resp, 1, 3553f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PCI_DMA_FROMDEVICE); 3554f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kerr_out: 3555f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K dma_unmap_sg(pm8001_ha->dev, &ccb->task->smp_task.smp_req, 1, 3556f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PCI_DMA_TODEVICE); 3557f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return rc; 3558f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3559f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3560f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int check_enc_sas_cmd(struct sas_task *task) 3561f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3562f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if ((task->ssp_task.cdb[0] == READ_10) 3563f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K || (task->ssp_task.cdb[0] == WRITE_10) 3564f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K || (task->ssp_task.cdb[0] == WRITE_VERIFY)) 3565f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 1; 3566f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K else 3567f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 3568f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3569f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3570f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int check_enc_sat_cmd(struct sas_task *task) 3571f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3572f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int ret = 0; 3573f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K switch (task->ata_task.fis.command) { 3574f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case ATA_CMD_FPDMA_READ: 3575f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case ATA_CMD_READ_EXT: 3576f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case ATA_CMD_READ: 3577f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case ATA_CMD_FPDMA_WRITE: 3578f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case ATA_CMD_WRITE_EXT: 3579f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case ATA_CMD_WRITE: 3580f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case ATA_CMD_PIO_READ: 3581f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case ATA_CMD_PIO_READ_EXT: 3582f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case ATA_CMD_PIO_WRITE: 3583f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K case ATA_CMD_PIO_WRITE_EXT: 3584f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = 1; 3585f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3586f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K default: 3587f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = 0; 3588f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K break; 3589f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3590f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return ret; 3591f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3592f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3593f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3594f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm80xx_chip_ssp_io_req - send a SSP task to FW 3595f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information. 3596f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @ccb: the ccb information this request used. 3597f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3598f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, 3599f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_ccb_info *ccb) 3600f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3601f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sas_task *task = ccb->task; 3602f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct domain_device *dev = task->dev; 3603f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_device *pm8001_dev = dev->lldd_dev; 3604f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct ssp_ini_io_start_req ssp_cmd; 3605f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 tag = ccb->ccb_tag; 3606f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int ret; 3607f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u64 phys_addr; 3608f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct inbound_queue_table *circularQ; 3609f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K static u32 inb; 3610f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K static u32 outb; 3611f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 opc = OPC_INB_SSPINIIOSTART; 3612f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memset(&ssp_cmd, 0, sizeof(ssp_cmd)); 3613f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memcpy(ssp_cmd.ssp_iu.lun, task->ssp_task.LUN, 8); 3614f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* data address domain added for spcv; set to 0 by host, 3615f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * used internally by controller 3616f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * 0 for SAS 1.1 and SAS 2.0 compatible TLR 3617f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3618f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.dad_dir_m_tlr = 3619f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(data_dir_flags[task->data_dir] << 8 | 0x0); 3620f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.data_len = cpu_to_le32(task->total_xfer_len); 3621f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.device_id = cpu_to_le32(pm8001_dev->device_id); 3622f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.tag = cpu_to_le32(tag); 3623f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (task->ssp_task.enable_first_burst) 3624f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.ssp_iu.efb_prio_attr |= 0x80; 3625f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_prio << 3); 3626f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_attr & 7); 3627f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memcpy(ssp_cmd.ssp_iu.cdb, task->ssp_task.cdb, 16); 3628a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[0]; 3629f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3630f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Check if encryption is set */ 3631f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_ha->chip->encrypt && 3632f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K !(pm8001_ha->encrypt_info.status) && check_enc_sas_cmd(task)) { 3633f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 3634f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Encryption enabled.Sending Encrypt SAS command 0x%x\n", 3635f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K task->ssp_task.cdb[0])); 3636f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K opc = OPC_INB_SSP_INI_DIF_ENC_IO; 3637f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* enable encryption. 0 for SAS 1.1 and SAS 2.0 compatible TLR*/ 3638f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.dad_dir_m_tlr = cpu_to_le32 3639f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ((data_dir_flags[task->data_dir] << 8) | 0x20 | 0x0); 3640f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3641f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* fill in PRD (scatter/gather) table, if any */ 3642f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (task->num_scatter > 1) { 3643f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_chip_make_sg(task->scatter, 3644f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb->n_elem, ccb->buf_prd); 3645f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phys_addr = ccb->ccb_dma_handle + 3646f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K offsetof(struct pm8001_ccb_info, buf_prd[0]); 3647f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.enc_addr_low = 3648f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(lower_32_bits(phys_addr)); 3649f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.enc_addr_high = 3650f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(upper_32_bits(phys_addr)); 3651f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.enc_esgl = cpu_to_le32(1<<31); 3652f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (task->num_scatter == 1) { 3653f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u64 dma_addr = sg_dma_address(task->scatter); 3654f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.enc_addr_low = 3655f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(lower_32_bits(dma_addr)); 3656f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.enc_addr_high = 3657f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(upper_32_bits(dma_addr)); 3658f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.enc_len = cpu_to_le32(task->total_xfer_len); 3659f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.enc_esgl = 0; 3660f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (task->num_scatter == 0) { 3661f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.enc_addr_low = 0; 3662f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.enc_addr_high = 0; 3663f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.enc_len = cpu_to_le32(task->total_xfer_len); 3664f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.enc_esgl = 0; 3665f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3666f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* XTS mode. All other fields are 0 */ 3667f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.key_cmode = 0x6 << 4; 3668f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* set tweak values. Should be the start lba */ 3669f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.twk_val0 = cpu_to_le32((task->ssp_task.cdb[2] << 24) | 3670f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ssp_task.cdb[3] << 16) | 3671f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ssp_task.cdb[4] << 8) | 3672f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ssp_task.cdb[5])); 3673f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 3674f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 3675f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Sending Normal SAS command 0x%x inb q %x\n", 3676f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K task->ssp_task.cdb[0], inb)); 3677f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* fill in PRD (scatter/gather) table, if any */ 3678f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (task->num_scatter > 1) { 3679f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_chip_make_sg(task->scatter, ccb->n_elem, 3680f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb->buf_prd); 3681f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phys_addr = ccb->ccb_dma_handle + 3682f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K offsetof(struct pm8001_ccb_info, buf_prd[0]); 3683f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.addr_low = 3684f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(lower_32_bits(phys_addr)); 3685f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.addr_high = 3686f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(upper_32_bits(phys_addr)); 3687f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.esgl = cpu_to_le32(1<<31); 3688f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (task->num_scatter == 1) { 3689f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u64 dma_addr = sg_dma_address(task->scatter); 3690f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.addr_low = cpu_to_le32(lower_32_bits(dma_addr)); 3691f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.addr_high = 3692f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(upper_32_bits(dma_addr)); 3693f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.len = cpu_to_le32(task->total_xfer_len); 3694f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.esgl = 0; 3695f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (task->num_scatter == 0) { 3696f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.addr_low = 0; 3697f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.addr_high = 0; 3698f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.len = cpu_to_le32(task->total_xfer_len); 3699f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ssp_cmd.esgl = 0; 3700f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3701f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3702f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &ssp_cmd, outb++); 3703f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3704f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* rotate the outb queue */ 3705f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K outb = outb%PM8001_MAX_SPCV_OUTB_NUM; 3706f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3707f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return ret; 3708f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3709f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3710f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, 3711f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_ccb_info *ccb) 3712f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3713f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sas_task *task = ccb->task; 3714f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct domain_device *dev = task->dev; 3715f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_device *pm8001_ha_dev = dev->lldd_dev; 3716f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 tag = ccb->ccb_tag; 3717f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int ret; 3718f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K static u32 inb; 3719f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K static u32 outb; 3720f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct sata_start_req sata_cmd; 3721f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 hdr_tag, ncg_tag = 0; 3722f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u64 phys_addr; 3723f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 ATAP = 0x0; 3724f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 dir; 3725f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct inbound_queue_table *circularQ; 3726c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K unsigned long flags; 3727f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 opc = OPC_INB_SATA_HOST_OPSTART; 3728f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memset(&sata_cmd, 0, sizeof(sata_cmd)); 3729a6cb3d012b983b350ae3892cff2e692665df0e1eSakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[0]; 3730f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3731f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (task->data_dir == PCI_DMA_NONE) { 3732f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ATAP = 0x04; /* no data*/ 3733f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk("no data\n")); 3734f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (likely(!task->ata_task.device_control_reg_update)) { 3735f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (task->ata_task.dma_xfer) { 3736f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ATAP = 0x06; /* DMA */ 3737f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk("DMA\n")); 3738f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 3739f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ATAP = 0x05; /* PIO*/ 3740f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk("PIO\n")); 3741f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3742f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (task->ata_task.use_ncq && 3743f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K dev->sata_dev.command_set != ATAPI_COMMAND_SET) { 3744f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ATAP = 0x07; /* FPDMA */ 3745f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk("FPDMA\n")); 3746f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3747f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3748c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (task->ata_task.use_ncq && pm8001_get_ncq_tag(task, &hdr_tag)) { 3749c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task->ata_task.fis.sector_count |= (u8) (hdr_tag << 3); 3750f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ncg_tag = hdr_tag; 3751c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 3752f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K dir = data_dir_flags[task->data_dir] << 8; 3753f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.tag = cpu_to_le32(tag); 3754f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.device_id = cpu_to_le32(pm8001_ha_dev->device_id); 3755f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.data_len = cpu_to_le32(task->total_xfer_len); 3756f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3757f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.sata_fis = task->ata_task.fis; 3758f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (likely(!task->ata_task.device_control_reg_update)) 3759f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.sata_fis.flags |= 0x80;/* C=1: update ATA cmd reg */ 3760f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.sata_fis.flags &= 0xF0;/* PM_PORT field shall be 0 */ 3761f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3762f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* Check if encryption is set */ 3763f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_ha->chip->encrypt && 3764f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K !(pm8001_ha->encrypt_info.status) && check_enc_sat_cmd(task)) { 3765f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 3766f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Encryption enabled.Sending Encrypt SATA cmd 0x%x\n", 3767f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.sata_fis.command)); 3768f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K opc = OPC_INB_SATA_DIF_ENC_IO; 3769f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3770f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* set encryption bit */ 3771f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.ncqtag_atap_dir_m_dad = 3772f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(((ncg_tag & 0xff)<<16)| 3773f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ((ATAP & 0x3f) << 10) | 0x20 | dir); 3774f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* dad (bit 0-1) is 0 */ 3775f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* fill in PRD (scatter/gather) table, if any */ 3776f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (task->num_scatter > 1) { 3777f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_chip_make_sg(task->scatter, 3778f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb->n_elem, ccb->buf_prd); 3779f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phys_addr = ccb->ccb_dma_handle + 3780f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K offsetof(struct pm8001_ccb_info, buf_prd[0]); 3781f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.enc_addr_low = lower_32_bits(phys_addr); 3782f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.enc_addr_high = upper_32_bits(phys_addr); 3783f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.enc_esgl = cpu_to_le32(1 << 31); 3784f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (task->num_scatter == 1) { 3785f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u64 dma_addr = sg_dma_address(task->scatter); 3786f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.enc_addr_low = lower_32_bits(dma_addr); 3787f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.enc_addr_high = upper_32_bits(dma_addr); 3788f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.enc_len = cpu_to_le32(task->total_xfer_len); 3789f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.enc_esgl = 0; 3790f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (task->num_scatter == 0) { 3791f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.enc_addr_low = 0; 3792f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.enc_addr_high = 0; 3793f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.enc_len = cpu_to_le32(task->total_xfer_len); 3794f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.enc_esgl = 0; 3795f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3796f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* XTS mode. All other fields are 0 */ 3797f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.key_index_mode = 0x6 << 4; 3798f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* set tweak values. Should be the start lba */ 3799f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.twk_val0 = 3800f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32((sata_cmd.sata_fis.lbal_exp << 24) | 3801f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (sata_cmd.sata_fis.lbah << 16) | 3802f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (sata_cmd.sata_fis.lbam << 8) | 3803f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (sata_cmd.sata_fis.lbal)); 3804f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.twk_val1 = 3805f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32((sata_cmd.sata_fis.lbah_exp << 8) | 3806f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (sata_cmd.sata_fis.lbam_exp)); 3807f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 3808f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_IO_DBG(pm8001_ha, pm8001_printk( 3809f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K "Sending Normal SATA command 0x%x inb %x\n", 3810f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.sata_fis.command, inb)); 3811f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* dad (bit 0-1) is 0 */ 3812f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.ncqtag_atap_dir_m_dad = 3813f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(((ncg_tag & 0xff)<<16) | 3814f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ((ATAP & 0x3f) << 10) | dir); 3815f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3816f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* fill in PRD (scatter/gather) table, if any */ 3817f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (task->num_scatter > 1) { 3818f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_chip_make_sg(task->scatter, 3819f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb->n_elem, ccb->buf_prd); 3820f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phys_addr = ccb->ccb_dma_handle + 3821f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K offsetof(struct pm8001_ccb_info, buf_prd[0]); 3822f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.addr_low = lower_32_bits(phys_addr); 3823f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.addr_high = upper_32_bits(phys_addr); 3824f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.esgl = cpu_to_le32(1 << 31); 3825f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (task->num_scatter == 1) { 3826f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u64 dma_addr = sg_dma_address(task->scatter); 3827f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.addr_low = lower_32_bits(dma_addr); 3828f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.addr_high = upper_32_bits(dma_addr); 3829f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.len = cpu_to_le32(task->total_xfer_len); 3830f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.esgl = 0; 3831f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else if (task->num_scatter == 0) { 3832f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.addr_low = 0; 3833f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.addr_high = 0; 3834f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.len = cpu_to_le32(task->total_xfer_len); 3835f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.esgl = 0; 3836f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3837f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* scsi cdb */ 3838f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.atapi_scsi_cdb[0] = 3839f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(((task->ata_task.atapi_packet[0]) | 3840f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ata_task.atapi_packet[1] << 8) | 3841f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ata_task.atapi_packet[2] << 16) | 3842f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ata_task.atapi_packet[3] << 24))); 3843f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.atapi_scsi_cdb[1] = 3844f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(((task->ata_task.atapi_packet[4]) | 3845f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ata_task.atapi_packet[5] << 8) | 3846f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ata_task.atapi_packet[6] << 16) | 3847f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ata_task.atapi_packet[7] << 24))); 3848f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.atapi_scsi_cdb[2] = 3849f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(((task->ata_task.atapi_packet[8]) | 3850f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ata_task.atapi_packet[9] << 8) | 3851f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ata_task.atapi_packet[10] << 16) | 3852f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ata_task.atapi_packet[11] << 24))); 3853f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K sata_cmd.atapi_scsi_cdb[3] = 3854f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(((task->ata_task.atapi_packet[12]) | 3855f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ata_task.atapi_packet[13] << 8) | 3856f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ata_task.atapi_packet[14] << 16) | 3857f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K (task->ata_task.atapi_packet[15] << 24))); 3858f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 3859c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 3860c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K /* Check for read log for failed drive and return */ 3861c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (sata_cmd.sata_fis.command == 0x2f) { 3862c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (pm8001_ha_dev && ((pm8001_ha_dev->id & NCQ_READ_LOG_FLAG) || 3863c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K (pm8001_ha_dev->id & NCQ_ABORT_ALL_FLAG) || 3864c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K (pm8001_ha_dev->id & NCQ_2ND_RLE_FLAG))) { 3865c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K struct task_status_struct *ts; 3866c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 3867c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_ha_dev->id &= 0xDFFFFFFF; 3868c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K ts = &task->task_status; 3869c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 3870c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K spin_lock_irqsave(&task->task_state_lock, flags); 3871c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K ts->resp = SAS_TASK_COMPLETE; 3872c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K ts->stat = SAM_STAT_GOOD; 3873c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task->task_state_flags &= ~SAS_TASK_STATE_PENDING; 3874c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task->task_state_flags &= ~SAS_TASK_AT_INITIATOR; 3875c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task->task_state_flags |= SAS_TASK_STATE_DONE; 3876c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K if (unlikely((task->task_state_flags & 3877c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K SAS_TASK_STATE_ABORTED))) { 3878c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K spin_unlock_irqrestore(&task->task_state_lock, 3879c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K flags); 3880c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K PM8001_FAIL_DBG(pm8001_ha, 3881c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_printk("task 0x%p resp 0x%x " 3882c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K " stat 0x%x but aborted by upper layer " 3883c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K "\n", task, ts->resp, ts->stat)); 3884c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); 3885c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return 0; 3886c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } else if (task->uldd_task) { 3887c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K spin_unlock_irqrestore(&task->task_state_lock, 3888c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K flags); 3889c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); 3890c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K mb();/* ditto */ 3891c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K spin_unlock_irq(&pm8001_ha->lock); 3892c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task->task_done(task); 3893c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K spin_lock_irq(&pm8001_ha->lock); 3894c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return 0; 3895c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } else if (!task->uldd_task) { 3896c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K spin_unlock_irqrestore(&task->task_state_lock, 3897c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K flags); 3898c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K pm8001_ccb_task_free(pm8001_ha, task, ccb, tag); 3899c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K mb();/*ditto*/ 3900c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K spin_unlock_irq(&pm8001_ha->lock); 3901c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K task->task_done(task); 3902c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K spin_lock_irq(&pm8001_ha->lock); 3903c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K return 0; 3904c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 3905c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 3906c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K } 3907c6b9ef5779c3e1edfa9de949d2a51252bc347663Sakthivel K 3908f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, 3909f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K &sata_cmd, outb++); 3910f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3911f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* rotate the outb queue */ 3912f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K outb = outb%PM8001_MAX_SPCV_OUTB_NUM; 3913f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return ret; 3914f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3915f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3916f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3917f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm80xx_chip_phy_start_req - start phy via PHY_START COMMAND 3918f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information. 3919f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @num: the inbound queue number 3920f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @phy_id: the phy id which we wanted to start up. 3921f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3922f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int 3923f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kpm80xx_chip_phy_start_req(struct pm8001_hba_info *pm8001_ha, u8 phy_id) 3924f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3925f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct phy_start_req payload; 3926f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct inbound_queue_table *circularQ; 3927f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int ret; 3928f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 tag = 0x01; 3929f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 opcode = OPC_INB_PHYSTART; 3930f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[0]; 3931f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memset(&payload, 0, sizeof(payload)); 3932f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.tag = cpu_to_le32(tag); 3933f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3934f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K PM8001_INIT_DBG(pm8001_ha, 3935f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_printk("PHY START REQ for phy_id %d\n", phy_id)); 3936f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* 3937f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ** [0:7] PHY Identifier 3938f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ** [8:11] link rate 1.5G, 3G, 6G 3939f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ** [12:13] link mode 01b SAS mode; 10b SATA mode; 11b Auto mode 3940f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ** [14] 0b disable spin up hold; 1b enable spin up hold 3941f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ** [15] ob no change in current PHY analig setup 1b enable using SPAST 3942f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3943f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.ase_sh_lm_slr_phyid = cpu_to_le32(SPINHOLD_DISABLE | 3944f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K LINKMODE_AUTO | LINKRATE_15 | 3945f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K LINKRATE_30 | LINKRATE_60 | phy_id); 3946f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /* SSC Disable and SAS Analog ST configuration */ 3947f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K /** 3948f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.ase_sh_lm_slr_phyid = 3949f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(SSC_DISABLE_30 | SAS_ASE | SPINHOLD_DISABLE | 3950f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K LINKMODE_AUTO | LINKRATE_15 | LINKRATE_30 | LINKRATE_60 | 3951f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy_id); 3952f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K Have to add "SAS PHY Analog Setup SPASTI 1 Byte" Based on need 3953f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K **/ 3954f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3955f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.sas_identify.dev_type = SAS_END_DEV; 3956f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.sas_identify.initiator_bits = SAS_PROTOCOL_ALL; 3957f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memcpy(payload.sas_identify.sas_addr, 3958f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_ha->sas_addr, SAS_ADDR_SIZE); 3959f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.sas_identify.phy_id = phy_id; 3960f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, 0); 3961f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return ret; 3962f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3963f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3964f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3965f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm8001_chip_phy_stop_req - start phy via PHY_STOP COMMAND 3966f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information. 3967f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @num: the inbound queue number 3968f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @phy_id: the phy id which we wanted to start up. 3969f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3970f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int pm80xx_chip_phy_stop_req(struct pm8001_hba_info *pm8001_ha, 3971f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 phy_id) 3972f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3973f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct phy_stop_req payload; 3974f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct inbound_queue_table *circularQ; 3975f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int ret; 3976f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 tag = 0x01; 3977f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 opcode = OPC_INB_PHYSTOP; 3978f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[0]; 3979f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memset(&payload, 0, sizeof(payload)); 3980f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.tag = cpu_to_le32(tag); 3981f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.phy_id = cpu_to_le32(phy_id); 3982f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opcode, &payload, 0); 3983f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return ret; 3984f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 3985f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 3986f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 3987f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * see comments on pm8001_mpi_reg_resp. 3988f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 3989f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int pm80xx_chip_reg_dev_req(struct pm8001_hba_info *pm8001_ha, 3990f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_device *pm8001_dev, u32 flag) 3991f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 3992f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct reg_dev_req payload; 3993f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 opc; 3994f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 stp_sspsmp_sata = 0x4; 3995f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct inbound_queue_table *circularQ; 3996f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 linkrate, phy_id; 3997f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int rc, tag = 0xdeadbeef; 3998f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct pm8001_ccb_info *ccb; 3999f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u8 retryFlag = 0x1; 4000f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u16 firstBurstSize = 0; 4001f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u16 ITNT = 2000; 4002f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct domain_device *dev = pm8001_dev->sas_device; 4003f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct domain_device *parent_dev = dev->parent; 4004f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[0]; 4005f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4006f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memset(&payload, 0, sizeof(payload)); 4007f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K rc = pm8001_tag_alloc(pm8001_ha, &tag); 4008f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (rc) 4009f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return rc; 4010f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb = &pm8001_ha->ccb_info[tag]; 4011f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb->device = pm8001_dev; 4012f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ccb->ccb_tag = tag; 4013f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.tag = cpu_to_le32(tag); 4014f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4015f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (flag == 1) { 4016f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K stp_sspsmp_sata = 0x02; /*direct attached sata */ 4017f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } else { 4018f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (pm8001_dev->dev_type == SATA_DEV) 4019f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K stp_sspsmp_sata = 0x00; /* stp*/ 4020f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K else if (pm8001_dev->dev_type == SAS_END_DEV || 4021f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->dev_type == EDGE_DEV || 4022f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->dev_type == FANOUT_DEV) 4023f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K stp_sspsmp_sata = 0x01; /*ssp or smp*/ 4024f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K } 4025f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (parent_dev && DEV_IS_EXPANDER(parent_dev->dev_type)) 4026f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy_id = parent_dev->ex_dev.ex_phy->phy_id; 4027f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K else 4028f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K phy_id = pm8001_dev->attached_phy; 4029f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4030f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K opc = OPC_INB_REG_DEV; 4031f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4032f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K linkrate = (pm8001_dev->sas_device->linkrate < dev->port->linkrate) ? 4033f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm8001_dev->sas_device->linkrate : dev->port->linkrate; 4034f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4035f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.phyid_portid = 4036f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(((pm8001_dev->sas_device->port->id) & 0xFF) | 4037f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ((phy_id & 0xFF) << 8)); 4038f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4039f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.dtype_dlr_mcn_ir_retry = cpu_to_le32((retryFlag & 0x01) | 4040f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ((linkrate & 0x0F) << 24) | 4041f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ((stp_sspsmp_sata & 0x03) << 28)); 4042f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.firstburstsize_ITNexustimeout = 4043f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(ITNT | (firstBurstSize * 0x10000)); 4044f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4045f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memcpy(payload.sas_addr, pm8001_dev->sas_device->sas_addr, 4046f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K SAS_ADDR_SIZE); 4047f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4048f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, 0); 4049f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4050f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return rc; 4051f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 4052f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4053f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 4054f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm80xx_chip_phy_ctl_req - support the local phy operation 4055f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information. 4056f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @num: the inbound queue number 4057f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @phy_id: the phy id which we wanted to operate 4058f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @phy_op: 4059f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 4060f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha, 4061f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 phyId, u32 phy_op) 4062f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 4063f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct local_phy_ctl_req payload; 4064f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K struct inbound_queue_table *circularQ; 4065f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K int ret; 4066f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 opc = OPC_INB_LOCAL_PHY_CONTROL; 4067f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K memset(&payload, 0, sizeof(payload)); 4068f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K circularQ = &pm8001_ha->inbnd_q_tbl[0]; 4069f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.tag = cpu_to_le32(1); 4070f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K payload.phyop_phyid = 4071f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K cpu_to_le32(((phy_op & 0xFF) << 8) | (phyId & 0xFF)); 4072f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &payload, 0); 4073f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return ret; 4074f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 4075f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4076f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic u32 pm80xx_chip_is_our_interupt(struct pm8001_hba_info *pm8001_ha) 4077f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 4078f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K u32 value; 4079f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K#ifdef PM8001_USE_MSIX 4080f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 1; 4081f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K#endif 4082f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K value = pm8001_cr32(pm8001_ha, 0, MSGU_ODR); 4083f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K if (value) 4084f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 1; 4085f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return 0; 4086f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4087f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 4088f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4089f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K/** 4090f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * pm8001_chip_isr - PM8001 isr handler. 4091f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @pm8001_ha: our hba card information. 4092f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @irq: irq number. 4093f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K * @stat: stat. 4094f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K */ 4095f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kstatic irqreturn_t 4096f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kpm80xx_chip_isr(struct pm8001_hba_info *pm8001_ha, u8 vec) 4097f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K{ 4098f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_chip_interrupt_disable(pm8001_ha, vec); 4099f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K process_oq(pm8001_ha, vec); 4100f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K pm80xx_chip_interrupt_enable(pm8001_ha, vec); 4101f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K return IRQ_HANDLED; 4102f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K} 4103f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K 4104f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel Kconst struct pm8001_dispatch pm8001_80xx_dispatch = { 4105f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .name = "pmc80xx", 4106f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .chip_init = pm80xx_chip_init, 4107f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .chip_soft_rst = pm80xx_chip_soft_rst, 4108f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .chip_rst = pm80xx_hw_chip_rst, 4109f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .chip_iounmap = pm8001_chip_iounmap, 4110f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .isr = pm80xx_chip_isr, 4111f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .is_our_interupt = pm80xx_chip_is_our_interupt, 4112f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .isr_process_oq = process_oq, 4113f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .interrupt_enable = pm80xx_chip_interrupt_enable, 4114f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .interrupt_disable = pm80xx_chip_interrupt_disable, 4115f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .make_prd = pm8001_chip_make_sg, 4116f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .smp_req = pm80xx_chip_smp_req, 4117f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .ssp_io_req = pm80xx_chip_ssp_io_req, 4118f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .sata_req = pm80xx_chip_sata_req, 4119f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .phy_start_req = pm80xx_chip_phy_start_req, 4120f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .phy_stop_req = pm80xx_chip_phy_stop_req, 4121f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .reg_dev_req = pm80xx_chip_reg_dev_req, 4122f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .dereg_dev_req = pm8001_chip_dereg_dev_req, 4123f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .phy_ctl_req = pm80xx_chip_phy_ctl_req, 4124f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .task_abort = pm8001_chip_abort_task, 4125f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .ssp_tm_req = pm8001_chip_ssp_tm_req, 4126f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .get_nvmd_req = pm8001_chip_get_nvmd_req, 4127f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .set_nvmd_req = pm8001_chip_set_nvmd_req, 4128f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .fw_flash_update_req = pm8001_chip_fw_flash_update_req, 4129f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K .set_dev_state_req = pm8001_chip_set_dev_state_req, 4130f5860992db55c9e36b0f120dff73f0c34abe510dSakthivel K}; 4131